diff --git a/CHANGELOG.md b/CHANGELOG.md index 140fa3bb..8d48f233 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 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 - **Add "tridactylrc" support** diff --git a/src/config.ts b/src/config.ts index e13f0a6c..a3b54b50 100644 --- a/src/config.ts +++ b/src/config.ts @@ -15,24 +15,42 @@ * */ +/** @hidden */ const CONFIGNAME = "userconfig" +/** @hidden */ const WAITERS = [] +/** @hidden */ let INITIALISED = false +/** @hidden */ // make a naked object function o(object) { return Object.assign(Object.create(null), object) } +/** @hidden */ // "Import" is a reserved word so this will have to do function schlepp(settings) { Object.assign(USERCONFIG, settings) } -// TODO: have list of possibilities for settings, e.g. hintmode: reverse | normal +/** @hidden */ 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", + + /** + * nmaps contain all of the bindings for "normal mode". + * + * They consist of key sequences mapped to ex commands. + */ nmaps: { "": "help", o: "fillcmdline open", @@ -64,8 +82,6 @@ const _DEFAULTS = { gg: "scrollto 0", "": "scrollpage -0.5", "": "scrollpage 0.5", - // Disabled while our find mode is bad - /* "": "scrollpage -1", */ // "": "scrollpage -1", $: "scrollto 100 x", // "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* } -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 @param target path of properties as an array + @hidden */ function getDeepProperty(obj, target) { if (obj !== undefined && target.length) { @@ -289,6 +308,7 @@ function getDeepProperty(obj, target) { If the path is an empty array, replace the obj. @param target path of properties as an array + @hidden */ function setDeepProperty(obj, value, target) { 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 defaults, if one exists, else undefined. + @hidden */ export function get(...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. This is useful if you are a content script and you've just been loaded. + @hidden */ export async function getAsync(...target) { if (INITIALISED) { @@ -344,6 +366,8 @@ export async function getAsync(...target) { set("nmaps", "o", "open") set("search", "default", "google") set("aucmd", "BufRead", "memrise.com", "open memrise.com") + + @hidden */ export function set(...args) { if (args.length < 2) { @@ -357,7 +381,8 @@ export function set(...args) { save() } -/** Delete the key at target if it exists */ +/** Delete the key at target if it exists + * @hidden */ export function unset(...target) { const parent = getDeepProperty(USERCONFIG, target.slice(0, -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 sometime after this happens. + + @hidden */ export async function save(storage: "local" | "sync" = get("storageloc")) { // 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 When adding updaters, don't forget to set("configversion", newversionnumber)! + @hidden */ export async function update() { let updaters = { @@ -423,6 +451,7 @@ export async function update() { /** Read all user configuration from storage API then notify any waiting asynchronous calls asynchronous calls generated by getAsync. + @hidden */ async function init() { let syncConfig = await browser.storage.sync.get(CONFIGNAME) diff --git a/src/config_rc.ts b/src/config_rc.ts index 93bb45ad..327a793d 100644 --- a/src/config_rc.ts +++ b/src/config_rc.ts @@ -10,8 +10,9 @@ export async function source(filename = "auto") { } else { rctext = (await Native.read(filename)).content } - + if (rctext === undefined) return false runRc(rctext) + return true } export async function runRc(rc: string) { diff --git a/src/excmds.ts b/src/excmds.ts index ede3fc24..a4cac0bf 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -4,7 +4,7 @@ Use `:help ` 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`. For more information, and FAQs, check out our [readme][4] on github. @@ -33,7 +33,7 @@ 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: @@ -324,7 +324,7 @@ export async function installnative() { //#background export async function source(...fileArr: string[]) { 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") } /** diff --git a/src/manifest.json b/src/manifest.json index bc31839d..0a832768 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Tridactyl", - "version": "1.11.1", + "version": "1.11.2", "icons": { "64": "static/logo/Tridactyl_64px.png", "100": "static/logo/Tridactyl_100px.png", diff --git a/src/native_background.ts b/src/native_background.ts index 1b5c4066..14fa64d2 100644 --- a/src/native_background.ts +++ b/src/native_background.ts @@ -58,7 +58,8 @@ export async function getrc(): Promise { logger.info(`Successfully retrieved fs config:\n${res.content}`) return res.content } 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}`) } } diff --git a/src/static/typedoc/assets/css/main.css b/src/static/typedoc/assets/css/main.css index 258c9e0f..27d9c9fd 100644 --- a/src/static/typedoc/assets/css/main.css +++ b/src/static/typedoc/assets/css/main.css @@ -931,6 +931,10 @@ ul.tsd-descriptions h4 { border: unset; } +.tsd-signature { + text-align: left; +} + .tsd-flag { font-size: unset; border-radius: 2px; @@ -945,6 +949,24 @@ ul.tsd-descriptions h4 { 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: