Merge branch 'configdocs' of github.com:cmcaine/tridactyl into configdocs

This commit is contained in:
Oliver Blanthorn 2018-05-12 12:57:32 +01:00
commit 56df3f97a6
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
7 changed files with 71 additions and 12 deletions

View file

@ -1,5 +1,11 @@
# Tridactyl changelog # Tridactyl changelog
## Release 1.11.2 / 2018-05-11
- Hotfix to prevent "config undefined" errors on browser start if no rc file was found
- It was mysteriously only reproducible sometimes...
- Make newtab changelog a bit wider
## Release 1.11.1 / 2018-05-11 ## Release 1.11.1 / 2018-05-11
- **Add "tridactylrc" support** - **Add "tridactylrc" support**

View file

@ -15,24 +15,42 @@
* *
*/ */
/** @hidden */
const CONFIGNAME = "userconfig" const CONFIGNAME = "userconfig"
/** @hidden */
const WAITERS = [] const WAITERS = []
/** @hidden */
let INITIALISED = false let INITIALISED = false
/** @hidden */
// make a naked object // make a naked object
function o(object) { function o(object) {
return Object.assign(Object.create(null), object) return Object.assign(Object.create(null), object)
} }
/** @hidden */
// "Import" is a reserved word so this will have to do // "Import" is a reserved word so this will have to do
function schlepp(settings) { function schlepp(settings) {
Object.assign(USERCONFIG, settings) Object.assign(USERCONFIG, settings)
} }
// TODO: have list of possibilities for settings, e.g. hintmode: reverse | normal /** @hidden */
let USERCONFIG = o({}) let USERCONFIG = o({})
const _DEFAULTS = {
/**
* This is the default configuration that Tridactyl comes with.
*
* You can change anything here using `set key1.key2.key3 value` or specific things any of the various helper commands such as `bind` or `command`.
*
*/
const default_config = {
configversion: "0.0", configversion: "0.0",
/**
* nmaps contain all of the bindings for "normal mode".
*
* They consist of key sequences mapped to ex commands.
*/
nmaps: { nmaps: {
"<F1>": "help", "<F1>": "help",
o: "fillcmdline open", o: "fillcmdline open",
@ -64,8 +82,6 @@ const _DEFAULTS = {
gg: "scrollto 0", gg: "scrollto 0",
"<c-u>": "scrollpage -0.5", "<c-u>": "scrollpage -0.5",
"<c-d>": "scrollpage 0.5", "<c-d>": "scrollpage 0.5",
// Disabled while our find mode is bad
/* "<c-f>": "scrollpage -1", */
// "<c-b>": "scrollpage -1", // "<c-b>": "scrollpage -1",
$: "scrollto 100 x", $: "scrollto 100 x",
// "0": "scrollto 0 x", // will get interpreted as a count // "0": "scrollto 0 x", // will get interpreted as a count
@ -270,11 +286,14 @@ const _DEFAULTS = {
csp: "untouched", // change this to "clobber" to ruin the CSP of all sites and make Tridactyl run a bit better on some of them, e.g. raw.github* csp: "untouched", // change this to "clobber" to ruin the CSP of all sites and make Tridactyl run a bit better on some of them, e.g. raw.github*
} }
const DEFAULTS = o(_DEFAULTS)
/** @hidden */
const DEFAULTS = o(default_config)
/** Given an object and a target, extract the target if it exists, else return undefined /** Given an object and a target, extract the target if it exists, else return undefined
@param target path of properties as an array @param target path of properties as an array
@hidden
*/ */
function getDeepProperty(obj, target) { function getDeepProperty(obj, target) {
if (obj !== undefined && target.length) { if (obj !== undefined && target.length) {
@ -289,6 +308,7 @@ function getDeepProperty(obj, target) {
If the path is an empty array, replace the obj. If the path is an empty array, replace the obj.
@param target path of properties as an array @param target path of properties as an array
@hidden
*/ */
function setDeepProperty(obj, value, target) { function setDeepProperty(obj, value, target) {
if (target.length > 1) { if (target.length > 1) {
@ -306,6 +326,7 @@ function setDeepProperty(obj, value, target) {
If the user has not specified a key, use the corresponding key from If the user has not specified a key, use the corresponding key from
defaults, if one exists, else undefined. defaults, if one exists, else undefined.
@hidden
*/ */
export function get(...target) { export function get(...target) {
const user = getDeepProperty(USERCONFIG, target) const user = getDeepProperty(USERCONFIG, target)
@ -327,6 +348,7 @@ export function get(...target) {
database first if it has not been at least once before. database first if it has not been at least once before.
This is useful if you are a content script and you've just been loaded. This is useful if you are a content script and you've just been loaded.
@hidden
*/ */
export async function getAsync(...target) { export async function getAsync(...target) {
if (INITIALISED) { if (INITIALISED) {
@ -344,6 +366,8 @@ export async function getAsync(...target) {
set("nmaps", "o", "open") set("nmaps", "o", "open")
set("search", "default", "google") set("search", "default", "google")
set("aucmd", "BufRead", "memrise.com", "open memrise.com") set("aucmd", "BufRead", "memrise.com", "open memrise.com")
@hidden
*/ */
export function set(...args) { export function set(...args) {
if (args.length < 2) { if (args.length < 2) {
@ -357,7 +381,8 @@ export function set(...args) {
save() save()
} }
/** Delete the key at target if it exists */ /** Delete the key at target if it exists
* @hidden */
export function unset(...target) { export function unset(...target) {
const parent = getDeepProperty(USERCONFIG, target.slice(0, -1)) const parent = getDeepProperty(USERCONFIG, target.slice(0, -1))
if (parent !== undefined) delete parent[target[target.length - 1]] if (parent !== undefined) delete parent[target[target.length - 1]]
@ -368,6 +393,8 @@ export function unset(...target) {
Config is not synchronised between different instances of this module until Config is not synchronised between different instances of this module until
sometime after this happens. sometime after this happens.
@hidden
*/ */
export async function save(storage: "local" | "sync" = get("storageloc")) { export async function save(storage: "local" | "sync" = get("storageloc")) {
// let storageobj = storage == "local" ? browser.storage.local : browser.storage.sync // let storageobj = storage == "local" ? browser.storage.local : browser.storage.sync
@ -386,6 +413,7 @@ export async function save(storage: "local" | "sync" = get("storageloc")) {
a default setting a default setting
When adding updaters, don't forget to set("configversion", newversionnumber)! When adding updaters, don't forget to set("configversion", newversionnumber)!
@hidden
*/ */
export async function update() { export async function update() {
let updaters = { let updaters = {
@ -423,6 +451,7 @@ export async function update() {
/** Read all user configuration from storage API then notify any waiting asynchronous calls /** Read all user configuration from storage API then notify any waiting asynchronous calls
asynchronous calls generated by getAsync. asynchronous calls generated by getAsync.
@hidden
*/ */
async function init() { async function init() {
let syncConfig = await browser.storage.sync.get(CONFIGNAME) let syncConfig = await browser.storage.sync.get(CONFIGNAME)

View file

@ -10,8 +10,9 @@ export async function source(filename = "auto") {
} else { } else {
rctext = (await Native.read(filename)).content rctext = (await Native.read(filename)).content
} }
if (rctext === undefined) return false
runRc(rctext) runRc(rctext)
return true
} }
export async function runRc(rc: string) { export async function runRc(rc: string) {

View file

@ -4,7 +4,7 @@
Use `:help <excmd>` or scroll down to show [[help]] for a particular excmd. Use `:help <excmd>` or scroll down to show [[help]] for a particular excmd.
The default keybinds can be found [here](/static/docs/modules/_config_.html#defaults) or all active binds can be seen with `:viewconfig nmaps`. The default keybinds can be found [here](/static/docs/modules/_config_.html#_defaults) or all active binds can be seen with `:viewconfig nmaps`.
You can also view them with [[bind]]. Try `bind j`. You can also view them with [[bind]]. Try `bind j`.
For more information, and FAQs, check out our [readme][4] on github. For more information, and FAQs, check out our [readme][4] on github.
@ -33,7 +33,7 @@
You do not need to worry about types. You do not need to worry about types.
At the bottom of each function's help page, you can click on a link that will take you straight to that function's definition in our code. This is especially recommended for browsing the [config](/static/docs/modules/_config_.html#defaults) which is nigh-on unreadable on these pages. At the bottom of each function's help page, you can click on a link that will take you straight to that function's definition in our code.
## Highlighted features: ## Highlighted features:
@ -324,7 +324,7 @@ export async function installnative() {
//#background //#background
export async function source(...fileArr: string[]) { export async function source(...fileArr: string[]) {
const file = fileArr.join(" ") || undefined const file = fileArr.join(" ") || undefined
if (await Native.nativegate("0.1.3")) rc.source(file) if (await Native.nativegate("0.1.3")) if (!await rc.source(file)) logger.error("Could not find RC file")
} }
/** /**

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Tridactyl", "name": "Tridactyl",
"version": "1.11.1", "version": "1.11.2",
"icons": { "icons": {
"64": "static/logo/Tridactyl_64px.png", "64": "static/logo/Tridactyl_64px.png",
"100": "static/logo/Tridactyl_100px.png", "100": "static/logo/Tridactyl_100px.png",

View file

@ -58,7 +58,8 @@ export async function getrc(): Promise<string> {
logger.info(`Successfully retrieved fs config:\n${res.content}`) logger.info(`Successfully retrieved fs config:\n${res.content}`)
return res.content return res.content
} else { } else {
logger.error(`Error in retrieving config: ${res.error}`) // Have to make this a warning as async exceptions apparently don't get caught
logger.info(`Error in retrieving config: ${res.error}`)
} }
} }

View file

@ -931,6 +931,10 @@ ul.tsd-descriptions h4 {
border: unset; border: unset;
} }
.tsd-signature {
text-align: left;
}
.tsd-flag { .tsd-flag {
font-size: unset; font-size: unset;
border-radius: 2px; border-radius: 2px;
@ -945,6 +949,24 @@ ul.tsd-descriptions h4 {
border: none border: none
} }
.tsd-panel {
padding: 0px;
padding-left: 3rem;
}
.tsd-parent-kind-object-literal > .tsd-panel {
margin: 0px;
border-top-width: 0.5px
}
.tsd-parent-kind-object-literal > .tsd-signature {
margin: 0px;
padding: 3px;
}
.tsd-signature-type {
display: none
}
/* Other changes: /* Other changes: