From 01959116068e93b56c876963eb36292980bb57f7 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 11 May 2018 21:33:10 +0100 Subject: [PATCH 1/5] Add a bunch of hacks to fix #518 --- src/config_rc.ts | 3 ++- src/excmds.ts | 2 +- src/native_background.ts | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) 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..17714328 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -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/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}`) } } From 36177024fc94cb72c0fd8f2d4d414da3e9472d50 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 11 May 2018 21:36:58 +0100 Subject: [PATCH 2/5] Add changelog for 1.11.2 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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** From 230d718af6bdb35b9864202d9168729b85107112 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 11 May 2018 21:37:08 +0100 Subject: [PATCH 3/5] release 1.11.2 --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 14d7acc5313a3bca6a709a21ae5526c8a46893da Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 11 May 2018 19:46:44 +0100 Subject: [PATCH 4/5] Make config docs a bit useful --- src/config.ts | 47 +++++++++++++++----------- src/static/typedoc/assets/css/main.css | 9 +++++ 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/config.ts b/src/config.ts index bb42e708..e13f0a6c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -31,9 +31,9 @@ function schlepp(settings) { // TODO: have list of possibilities for settings, e.g. hintmode: reverse | normal let USERCONFIG = o({}) -const DEFAULTS = o({ +const _DEFAULTS = { configversion: "0.0", - nmaps: o({ + nmaps: { "": "help", o: "fillcmdline open", O: "current_url open", @@ -132,13 +132,19 @@ const DEFAULTS = o({ ".": "repeat", "ba": "open https://www.youtube.com/watch?v=M3iOROuTuMA", - }), - autocmds: o({ - DocStart: o({ + }, + autocmds: { + DocStart: { "addons.mozilla.org": "mode ignore", - }), - }), - exaliases: o({ + }, + }, + + /** + * Aliases for use in the command line. The key is replaced with the value. + * + * Related ex command: `command` + */ + exaliases: { alias: "command", au: "autocmd", b: "buffer", @@ -169,13 +175,13 @@ const DEFAULTS = o({ openwith: "hint -W", "!": "exclaim", "!s": "exclaim_quiet", - }), - followpagepatterns: o({ - next: "^(next|newer)\\b|»|>>|more", - prev: "^(prev(ious)?|older)\\b|«|<<", - }), + }, + followpagepatterns: { + next: "^(next|newer\\b|»|>>|more", + prev: "^(prev(ious?|older\\b|«|<<", + }, searchengine: "google", - searchurls: o({ + searchurls: { google: "https://www.google.com/search?q=", scholar: "https://scholar.google.com/scholar?q=", googleuk: "https://www.google.co.uk/search?q=", @@ -199,7 +205,7 @@ const DEFAULTS = o({ gentoo_wiki: "https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=", qwant: "https://www.qwant.com/?q=", - }), + }, newtab: "", viewsource: "tridactyl", // "tridactyl" or "default" @@ -210,7 +216,7 @@ const DEFAULTS = o({ // Controls whether the page can focus elements for you via js // Remember to also change browser.autofocus (autofocusing elements via - // HTML) in about:config + // HTML in about:config // Maybe have a nice user-vicible message when the setting is changed? allowautofocus: "true", @@ -234,21 +240,21 @@ const DEFAULTS = o({ modeindicator: "true", // Default logging levels - 2 === WARNING - logging: o({ + logging: { messaging: 2, cmdline: 2, controller: 2, hinting: 2, state: 2, excmd: 1, - }), + }, noiframeon: [], // Native messenger settings // This has to be a command that stays in the foreground for the whole editing session // "auto" will attempt to find a sane editor in your path. // Please send your requests to have your favourite terminal moved further up the list to /dev/null. - // (but we are probably happy to add your terminal to the list if it isn't already there). + // (but we are probably happy to add your terminal to the list if it isn't already there. editorcmd: "auto", browser: "firefox", nativeinstallcmd: @@ -263,7 +269,8 @@ const DEFAULTS = o({ // Security settings 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) /** Given an object and a target, extract the target if it exists, else return undefined diff --git a/src/static/typedoc/assets/css/main.css b/src/static/typedoc/assets/css/main.css index be84e49d..258c9e0f 100644 --- a/src/static/typedoc/assets/css/main.css +++ b/src/static/typedoc/assets/css/main.css @@ -937,6 +937,15 @@ ul.tsd-descriptions h4 { } +.tsd-parent-kind-object-literal > h3, .tsd-sources { + display: none +} + +.tsd-parent-kind-object-literal > .tsd-signature { + border: none +} + + /* Other changes: * - removed all background images in CSS above From c18d37bf58e769d23bd134366be185f45c783529 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 11 May 2018 22:09:34 +0100 Subject: [PATCH 5/5] Progress --- src/config.ts | 41 ++++++++++++++++++++++---- src/excmds.ts | 4 +-- src/static/typedoc/assets/css/main.css | 23 +++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) 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/excmds.ts b/src/excmds.ts index 17714328..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: diff --git a/src/static/typedoc/assets/css/main.css b/src/static/typedoc/assets/css/main.css index 258c9e0f..43ed3877 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,25 @@ 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: