From 619d6135b4cf1e58721206d931767da31e44f6b8 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 23 Apr 2021 18:49:19 +0530 Subject: [PATCH 01/23] Added drawable no mouse mode --- src/content/toys.ts | 42 +++++++++++++++++++++++++++++++++++++++++- src/excmds.ts | 15 ++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index b0c27fe2..826cb990 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -7,6 +7,15 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +var erasor = false; +export function toggle_pen() { + erasor = !erasor +} + +export function drawable() { + make_drawable(makeBlock()) +} export function jack_in() { // chinese characters - taken from the unicode charset const chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split("") @@ -14,7 +23,6 @@ export function jack_in() { rain(makeBlock(), chinese, colour) } - export function music() { // music characters - taken from the unicode charset const music = "𝄞𝄟𝄰𝅘𝅥𝅮𝅘𝅥𝅯𝅘𝅥𝅰𝄽".split("") @@ -43,6 +51,38 @@ function makeBlock() { return overlaydiv } +function make_drawable(overlaydiv){ + const c = document.createElement("canvas") + overlaydiv.appendChild(c) + + // making the canvas full screen + c.height = window.innerHeight + c.width = window.innerWidth + + const state = { + mousedown: false, + context: c.getContext("2d"), + x: 0, + y: 0} + c.addEventListener("mousedown", () => state.mousedown = true) + c.addEventListener("mouseup", () => state.mousedown = false) + c.addEventListener("mousemove", e => { state.x = e.clientX; state.y = e.clientY }) + function draw() { + window.requestAnimationFrame(() => { + if(erasor){ + state.context.globalCompositeOperation = "destination-out"; + } else { + state.context.fillStyle = "black" + } + if (state.mousedown) { + state.context.fillRect(state.x, state.y, 3, 3) + } + draw() + }) + } + draw() +} + export function removeBlock() { Array.from(document.getElementsByClassName("_tridactyl_no_mouse_")).map((el: Element & { intid?: number | null}) => { if(typeof el.intid === "number") { diff --git a/src/excmds.ts b/src/excmds.ts index 94b2126e..38b18714 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1634,7 +1634,20 @@ export function snow_mouse_mode() { export function pied_piper_mouse_mode() { toys.music() } - +/** + * Drawable variant of [[no_mouse_mode]] + */ +//#content +export function drawable_mouse_mode() { + toys.drawable() +} +/** + * Toggle pen and erasor for drawable + */ +//#content +export function toggle_pen() { + toys.toggle_pen() +} /** * Revert any variant of the [[no_mouse_mode]] * From df484c44e6e31cbf11ff9ecd521d099ba09d6e9f Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 23 Apr 2021 19:05:10 +0530 Subject: [PATCH 02/23] fix lint errors --- src/content/toys.ts | 9 ++++++--- src/excmds.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 826cb990..7ce30e03 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -8,7 +8,7 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -var erasor = false; +let erasor = false; export function toggle_pen() { erasor = !erasor } @@ -54,7 +54,7 @@ function makeBlock() { function make_drawable(overlaydiv){ const c = document.createElement("canvas") overlaydiv.appendChild(c) - + // making the canvas full screen c.height = window.innerHeight c.width = window.innerWidth @@ -66,7 +66,10 @@ function make_drawable(overlaydiv){ y: 0} c.addEventListener("mousedown", () => state.mousedown = true) c.addEventListener("mouseup", () => state.mousedown = false) - c.addEventListener("mousemove", e => { state.x = e.clientX; state.y = e.clientY }) + c.addEventListener("mousemove", e => { + state.x = e.clientX + state.y = e.clientY + }) function draw() { window.requestAnimationFrame(() => { if(erasor){ diff --git a/src/excmds.ts b/src/excmds.ts index 38b18714..21d0058c 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1642,7 +1642,7 @@ export function drawable_mouse_mode() { toys.drawable() } /** - * Toggle pen and erasor for drawable + * Toggle pen and erasor for drawable */ //#content export function toggle_pen() { From e8efa696007abbaf912c0b8f2e7607569d955cf6 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sat, 24 Apr 2021 16:31:30 +0530 Subject: [PATCH 03/23] Major fixes - Fixes stroke fill - make canvas full page - fix as per review Changes to be committed: modified: src/content/toys.ts modified: src/excmds.ts --- src/content/toys.ts | 116 ++++++++++++++++++++++++++++---------------- src/excmds.ts | 12 +++-- 2 files changed, 81 insertions(+), 47 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 7ce30e03..cec69108 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -8,14 +8,6 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -let erasor = false; -export function toggle_pen() { - erasor = !erasor -} - -export function drawable() { - make_drawable(makeBlock()) -} export function jack_in() { // chinese characters - taken from the unicode charset const chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split("") @@ -40,50 +32,88 @@ function makeBlock() { overlaydiv.style.position = "fixed" overlaydiv.style.display = "block" overlaydiv.style.width = String(window.innerWidth) - overlaydiv.style.height = String(window.innerHeight) - overlaydiv.style.top = "0" - overlaydiv.style.left = "0" - overlaydiv.style.right = "0" - overlaydiv.style.bottom = "0" - overlaydiv.style.zIndex = "1000" - overlaydiv.style.opacity = "0.5" + overlaydiv.style.height = String(document.documentElement.scrollHeight) + overlaydiv.style.top = "0px" + overlaydiv.style.bottom = "0px" + overlaydiv.style.left = "0px" + overlaydiv.style.right = "0px" + overlaydiv.style.zIndex = "100" + overlaydiv.style.opacity = "0.8" document.body.appendChild(overlaydiv) return overlaydiv } -function make_drawable(overlaydiv){ +export function drawable() { + make_drawable(makeBlock()) +} + +const clickX = [] +const clickY = [] +const clickDrag = [] +let ink + +let eraser = false; +export function eraser_toggle() { + eraser = !eraser +} + +function addClick(x, y, dragging) { + clickX.push(x) + clickY.push(y) + clickDrag.push(dragging) +} + +function redraw(context) { + if(eraser) { + context.globalCompositeOperation = "destination-out" + context.lineWidth = 18 + } else { + context.globalCompositeOperation = "source-over" + context.lineWidth = 3 + } + context.strokeStyle = "#000000" + context.lineJoin = "round" + for(let i=0; i < clickX.length; i++) { + context.beginPath() + if(clickDrag[i] && i){ + context.moveTo(clickX[i-1], clickY[i-1]) + } else { + context.moveTo(clickX[i]-1, clickY[i]) + } + context.lineTo(clickX[i], clickY[i]) + context.closePath() + context.stroke() + } +} + +function make_drawable(overlaydiv) { + overlaydiv.style.position = "absolute" const c = document.createElement("canvas") overlaydiv.appendChild(c) - + const context = c.getContext("2d") // making the canvas full screen - c.height = window.innerHeight - c.width = window.innerWidth + c.height = document.documentElement.scrollHeight + c.width = window.innerWidth*0.98 - const state = { - mousedown: false, - context: c.getContext("2d"), - x: 0, - y: 0} - c.addEventListener("mousedown", () => state.mousedown = true) - c.addEventListener("mouseup", () => state.mousedown = false) - c.addEventListener("mousemove", e => { - state.x = e.clientX - state.y = e.clientY + c.addEventListener("mousedown", (e) => { + ink = true + let mouseX = e.pageX + let mouseY = e.pageY + addClick(mouseX, mouseY, false) + redraw(context) + }) + c.addEventListener("mouseup", () => { + ink = false + clickX.length = 0 + clickY.length = 0 + clickDrag.length = 0 + }) + c.addEventListener("mousemove", e => { + if(ink){ + addClick(e.pageX, e.pageY, true); + redraw(context); + } }) - function draw() { - window.requestAnimationFrame(() => { - if(erasor){ - state.context.globalCompositeOperation = "destination-out"; - } else { - state.context.fillStyle = "black" - } - if (state.mousedown) { - state.context.fillRect(state.x, state.y, 3, 3) - } - draw() - }) - } - draw() } export function removeBlock() { diff --git a/src/excmds.ts b/src/excmds.ts index 21d0058c..34bea50c 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1636,22 +1636,26 @@ export function pied_piper_mouse_mode() { } /** * Drawable variant of [[no_mouse_mode]] + * In this mode, you can click the mouse to draw. To erase any drawings, use [[eraser_toggle]] + * Use [[mouse_mode]] to return, or refresh page. + * Suggested usage: `autocmd DocLoad .* drawable_mouse_mode` */ //#content export function drawable_mouse_mode() { toys.drawable() } /** - * Toggle pen and erasor for drawable + * Toggle pen and eraser for [[drawable_mouse_mode]] + * Suggested usage: `bind e eraser_toggle` and map pen button to `e` */ //#content -export function toggle_pen() { - toys.toggle_pen() +export function eraser_toggle() { + toys.eraser_toggle() } /** * Revert any variant of the [[no_mouse_mode]] * - * Suggested usage: `bind mouse_mode` with the autocmd mentioned in [[no_mouse_mode]]. + * Suggested usage: `bind mouse_mode` with the autocmd mentioned in [[no_mouse_mode]] or [[drawable_mouse_mode]]. */ //#content export function mouse_mode() { From 3274c5aef531d1419617585a57e5be9f001f6ef5 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sat, 24 Apr 2021 16:38:40 +0530 Subject: [PATCH 04/23] fix lint errors --- src/content/toys.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index cec69108..a6fb13e6 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -97,9 +97,7 @@ function make_drawable(overlaydiv) { c.addEventListener("mousedown", (e) => { ink = true - let mouseX = e.pageX - let mouseY = e.pageY - addClick(mouseX, mouseY, false) + addClick(e.pageX, e.pageY, false) redraw(context) }) c.addEventListener("mouseup", () => { From fdc65fdfc5ce15b198389d7ac63d21bb05d2b836 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sat, 24 Apr 2021 17:18:25 +0530 Subject: [PATCH 05/23] fix docs as per review Co-authored-by: Oliver Blanthorn --- src/excmds.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index 34bea50c..2936628c 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1645,8 +1645,8 @@ export function drawable_mouse_mode() { toys.drawable() } /** - * Toggle pen and eraser for [[drawable_mouse_mode]] - * Suggested usage: `bind e eraser_toggle` and map pen button to `e` + * Switch between pen and eraser for [[drawable_mouse_mode]] + * Suggested usage: `bind e eraser_toggle`. If you have a digital pen, map the button to `e` to switch easily. */ //#content export function eraser_toggle() { From ca9e9c174d4013848b36a8ab519d43fc43dc6147 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sat, 24 Apr 2021 17:43:59 +0530 Subject: [PATCH 06/23] fix zIndex and add 0.98 comment --- src/content/toys.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index a6fb13e6..0924b46b 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -37,7 +37,7 @@ function makeBlock() { overlaydiv.style.bottom = "0px" overlaydiv.style.left = "0px" overlaydiv.style.right = "0px" - overlaydiv.style.zIndex = "100" + overlaydiv.style.zIndex = "1000" overlaydiv.style.opacity = "0.8" document.body.appendChild(overlaydiv) return overlaydiv @@ -93,7 +93,7 @@ function make_drawable(overlaydiv) { const context = c.getContext("2d") // making the canvas full screen c.height = document.documentElement.scrollHeight - c.width = window.innerWidth*0.98 + c.width = window.innerWidth*0.98 // workaround to fix canvas overflow c.addEventListener("mousedown", (e) => { ink = true From 60d30b47d2dc1af202b561298fc132b4a402b37e Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sat, 24 Apr 2021 18:17:24 +0530 Subject: [PATCH 07/23] revert opacity as per review --- src/content/toys.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 0924b46b..1f04ef81 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -38,7 +38,7 @@ function makeBlock() { overlaydiv.style.left = "0px" overlaydiv.style.right = "0px" overlaydiv.style.zIndex = "1000" - overlaydiv.style.opacity = "0.8" + overlaydiv.style.opacity = "0.5" document.body.appendChild(overlaydiv) return overlaydiv } @@ -88,6 +88,7 @@ function redraw(context) { function make_drawable(overlaydiv) { overlaydiv.style.position = "absolute" + overlaydiv.style.opacity = "0.8" const c = document.createElement("canvas") overlaydiv.appendChild(c) const context = c.getContext("2d") From 4669cea9dabb911a2f2f2e5042cdc99a7b5f62f1 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:16:13 +0530 Subject: [PATCH 08/23] Fix usage for pen tablet/stylus --- src/content/toys.ts | 49 +++++++++++++++++++++++++++------------------ src/excmds.ts | 4 +++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 1f04ef81..ddffa3a4 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -44,6 +44,7 @@ function makeBlock() { } export function drawable() { + eraser = false make_drawable(makeBlock()) } @@ -72,7 +73,7 @@ function redraw(context) { context.lineWidth = 3 } context.strokeStyle = "#000000" - context.lineJoin = "round" + context.lineJoin = "miter" for(let i=0; i < clickX.length; i++) { context.beginPath() if(clickDrag[i] && i){ @@ -85,7 +86,29 @@ function redraw(context) { context.stroke() } } - +function handleDown(e, context){ + ink = true + addClick(e.pageX, e.pageY, false) + redraw(context) + e.preventDefault() + e.stopPropagation() +} +function handleUp(e){ + ink = false + clickX.length = 0 + clickY.length = 0 + clickDrag.length = 0 + e.stopPropagation() + e.preventDefault() +} +function handleMove(e, context) { + if(ink){ + addClick(e.pageX, e.pageY, true); + redraw(context); + } + e.preventDefault() + e.stopPropagation() +} function make_drawable(overlaydiv) { overlaydiv.style.position = "absolute" overlaydiv.style.opacity = "0.8" @@ -95,24 +118,10 @@ function make_drawable(overlaydiv) { // making the canvas full screen c.height = document.documentElement.scrollHeight c.width = window.innerWidth*0.98 // workaround to fix canvas overflow - - c.addEventListener("mousedown", (e) => { - ink = true - addClick(e.pageX, e.pageY, false) - redraw(context) - }) - c.addEventListener("mouseup", () => { - ink = false - clickX.length = 0 - clickY.length = 0 - clickDrag.length = 0 - }) - c.addEventListener("mousemove", e => { - if(ink){ - addClick(e.pageX, e.pageY, true); - redraw(context); - } - }) + c.style.touchAction = "none" // for pen tablet to work + c.addEventListener("pointerdown", e=>handleDown(e,context)) + c.addEventListener("pointerup", handleUp) + c.addEventListener("pointermove", e=>handleMove(e,context)) } export function removeBlock() { diff --git a/src/excmds.ts b/src/excmds.ts index 2936628c..6a27954f 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1636,9 +1636,11 @@ export function pied_piper_mouse_mode() { } /** * Drawable variant of [[no_mouse_mode]] - * In this mode, you can click the mouse to draw. To erase any drawings, use [[eraser_toggle]] + * In this mode, you can use the mouse or a pen table to draw. To erase any drawings, use [[eraser_toggle]] * Use [[mouse_mode]] to return, or refresh page. * Suggested usage: `autocmd DocLoad .* drawable_mouse_mode` + * + * **Warning**: Windows Ink enabled input devices don't work, disable it for your browser, or use a mouse. */ //#content export function drawable_mouse_mode() { From eb0c84f1cda795f90d6009feb4c07d4da7735c87 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Sun, 25 Apr 2021 20:20:36 +0530 Subject: [PATCH 09/23] Update src/excmds.ts Co-authored-by: Oliver Blanthorn --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index 6a27954f..65d141d3 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1636,7 +1636,7 @@ export function pied_piper_mouse_mode() { } /** * Drawable variant of [[no_mouse_mode]] - * In this mode, you can use the mouse or a pen table to draw. To erase any drawings, use [[eraser_toggle]] + * In this mode, you can use the mouse or a digital stylus to draw. To switch to an eraser, use [[eraser_toggle]] * Use [[mouse_mode]] to return, or refresh page. * Suggested usage: `autocmd DocLoad .* drawable_mouse_mode` * From 1488a7d84b64cd346c2e13022f05649822006424 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 30 Apr 2021 01:28:46 +0000 Subject: [PATCH 10/23] Bump eslint-plugin-jsdoc from 32.3.3 to 32.3.4 Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 32.3.3 to 32.3.4. - [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases) - [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v32.3.3...v32.3.4) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0cd825f5..7de45490 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "eslint": "^7.25.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jsdoc": "^32.3.3", + "eslint-plugin-jsdoc": "^32.3.4", "eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-sonarjs": "^0.5.0", "geckodriver": "^1.22.3", diff --git a/yarn.lock b/yarn.lock index 9e069fc4..6e54cf21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2659,10 +2659,10 @@ eslint-plugin-import@^2.22.1: resolve "^1.17.0" tsconfig-paths "^3.9.0" -eslint-plugin-jsdoc@^32.3.3: - version "32.3.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.3.tgz#c430f5d289b6251cb1bf49585858b2335890dab3" - integrity sha512-WxXohbMYlZvCt3r7MepwT++nTLsO4CPegWcm5toM4IGq3MBmYkG+Uf5yDa+n1MwPXLg+KbJqAsI19hmkVD7MPg== +eslint-plugin-jsdoc@^32.3.4: + version "32.3.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.4.tgz#6888f3b2dbb9f73fb551458c639a4e8c84fe9ddc" + integrity sha512-xSWfsYvffXnN0OkwLnB7MoDDDDjqcp46W7YlY1j7JyfAQBQ+WnGCfLov3gVNZjUGtK9Otj8mEhTZTqJu4QtIGA== dependencies: comment-parser "1.1.5" debug "^4.3.1" From 4776d73a52c14de291a33c27dfe741c34ace9ff8 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 09:39:09 +0200 Subject: [PATCH 11/23] Remove git dependency for stable rebuilds --- .gitignore | 1 + scripts/authors.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ba24b87..af701185 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ compiler/**/*.js .*.generated.ts .tmp/ .DS_Store +.build_cache/ diff --git a/scripts/authors.sh b/scripts/authors.sh index d0d9ead4..415d1d84 100755 --- a/scripts/authors.sh +++ b/scripts/authors.sh @@ -4,10 +4,18 @@ set -e err() { echo "error: line $(caller)"; } trap err ERR +mkdir -p .build_cache cd src/static authors="../../build/static/authors.html" sed "/REPLACETHIS/,$ d" authors.html > "$authors" -git shortlog -sn HEAD | cut -c8- | awk '!seen[$0]++' | sed 's/^/

/' | sed 's/$/<\/p>/' >> "$authors" + +# If we're in a git repo, refresh the cache +if [ -d "../../.git/" ]; then + git shortlog -sn HEAD | cut -c8- | awk '!seen[$0]++' | sed 's/^/

/' | sed 's/$/<\/p>/' > ../../.build_cache/authors +fi + +cat ../../.build_cache/authors >> "$authors" + sed "1,/REPLACETHIS/ d" authors.html >> "$authors" From c9d9fb8edc3cec521194ede2fddb7135ac5275c1 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:05:15 +0200 Subject: [PATCH 12/23] Remove git dependency for beta rebuilds --- scripts/version.js | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/scripts/version.js b/scripts/version.js index d153ab1b..301e1aaf 100755 --- a/scripts/version.js +++ b/scripts/version.js @@ -1,6 +1,7 @@ #!/usr/bin/env node const { exec } = require("child_process") +const fs = require("fs") function bump_version(versionstr, component = 2) { const versionarr = versionstr.split(".") @@ -12,21 +13,37 @@ function bump_version(versionstr, component = 2) { } async function add_beta(versionstr) { - return new Promise((resolve, err) => { - exec("git rev-list --count HEAD", (execerr, stdout, stderr) => { - if (execerr) err(execerr) - resolve(versionstr + "pre" + stdout.trim()) + await fs.promises.mkdir(".build_cache", {recursive: true}) + try { + await fs.promises.access(".git") + await new Promise((resolve, err) => { + exec("git rev-list --count HEAD > .build_cache/count", (execerr, stdout, stderr) => { + if (execerr) err(execerr) + resolve(stdout.trim()) + }) }) - }) + } + catch { + ; // Not in a git directory - don't do anything + } + return versionstr + "pre" + (await fs.promises.readFile(".build_cache/count", {encoding: "utf8"})).trim() } async function get_hash() { - return new Promise((resolve, err) => { - exec("git rev-parse --short HEAD", (execerr, stdout, stderr) => { - if (execerr) err(execerr) - resolve(stdout.trim()) + await fs.promises.mkdir(".build_cache", {recursive: true}) + try { + await fs.promises.access(".git") + await new Promise((resolve, err) => { + exec("git rev-parse --short HEAD > .build_cache/hash", (execerr, stdout, stderr) => { + if (execerr) err(execerr) + resolve(stdout.trim()) + }) }) - }) + } + catch { + ; // Not in a git directory - don't do anything + } + return (await fs.promises.readFile(".build_cache/hash", {encoding: "utf8"})).trim() } function make_update_json(versionstr) { @@ -102,7 +119,7 @@ async function main() { make_update_json(manifest.version), ) } catch(e) { - console.warn("updates.json wasn't updated: " + e) + console.warn("Unless you're the buildbot, ignore this error: " + e) } // Save manifest.json From c68e1a59d6dbf75bb75294f066f99f1d9ebb7be2 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:42:34 +0200 Subject: [PATCH 13/23] Reduce source archive size For stable and add beta source archive --- scripts/sign | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/sign b/scripts/sign index 194c3187..54926f72 100755 --- a/scripts/sign +++ b/scripts/sign @@ -23,6 +23,7 @@ publish_beta() { scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json sign_and_submit + tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . } build_no_sign_beta(){ @@ -53,7 +54,7 @@ publish_stable() { yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json sign_and_submit - tar --exclude-from=.gitignore -czf ../../public_html/betas/tridactyl_source.tar.gz . + tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . } case $1 in From d74a4b9d4ba073b043a838a58766e763f23b84ae Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 10:47:11 +0200 Subject: [PATCH 14/23] Cheer up shellcheck --- scripts/sign | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/sign b/scripts/sign index 54926f72..25bf30c3 100755 --- a/scripts/sign +++ b/scripts/sign @@ -4,7 +4,7 @@ set -e sign_and_submit() { # Don't trust the return value of web-ext sign. - (source AMOKEYS && (web-ext sign -s build --api-key $AMOKEY --api-secret $AMOSECRET "$@" || true)) + (source AMOKEYS && (yarn run web-ext sign -s build --api-key "$AMOKEY" --api-secret "$AMOSECRET" "$@" || true)) } publish_beta_nonewtab() { @@ -23,7 +23,7 @@ publish_beta() { scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json sign_and_submit - tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . + tar --exclude-from=<(.grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . } build_no_sign_beta(){ @@ -32,9 +32,9 @@ build_no_sign_beta(){ scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json mkdir -p web-ext-artifacts - $(yarn bin)/web-ext build --source-dir ./build --overwrite-dest + yarn run web-ext build --source-dir ./build --overwrite-dest for f in web-ext-artifacts/*.zip; do - mv $f ${f%.zip}.xpi + mv "$f" "${f%.zip}".xpi done } @@ -43,9 +43,9 @@ build_no_sign_stable(){ yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json mkdir -p web-ext-artifacts - $(yarn bin)/web-ext build --source-dir ./build --overwrite-dest + yarn run web-ext build --source-dir ./build --overwrite-dest for f in web-ext-artifacts/*.zip; do - mv $f ${f%.zip}.xpi + mv "$f" "${f%.zip}".xpi done } @@ -54,7 +54,7 @@ publish_stable() { yarn run build --no-native sed 's/tridactyl.vim.betas@cmcaine/tridactyl.vim@cmcaine/' -i build/manifest.json sign_and_submit - tar --exclude-from=<(cat .gitignore | grep -v .build_cache/) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . + tar --exclude-from=<(grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source.tar.gz . } case $1 in @@ -62,5 +62,6 @@ case $1 in nosignstable) build_no_sign_stable;; nosignbeta) build_no_sign_beta;; nonewtab) publish_beta_nonewtab;; - *|beta) publish_beta;; + beta) publish_beta;; + *) publish_beta;; esac From 3e94800c92fc27da23dcfdcdbae5693426f7b337 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 12:20:12 +0200 Subject: [PATCH 15/23] Add error log to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index af701185..c1a7dab3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ compiler/**/*.js .tmp/ .DS_Store .build_cache/ +yarn-error.log From fa868afd7ab081c81de9844b90305457428438e5 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 30 Apr 2021 12:22:22 +0200 Subject: [PATCH 16/23] Fix typo --- scripts/sign | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sign b/scripts/sign index 25bf30c3..103ce11b 100755 --- a/scripts/sign +++ b/scripts/sign @@ -23,7 +23,7 @@ publish_beta() { scripts/version.js beta sed 's/"name": "Tridactyl"/"name": "Tridactyl: Beta"/' -i build/manifest.json sign_and_submit - tar --exclude-from=<(.grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . + tar --exclude-from=<(grep -v .build_cache/ .gitignore) --exclude-vcs -czf ../../public_html/betas/tridactyl_source_beta.tar.gz . } build_no_sign_beta(){ From c307c03639a5c9111480a8b71185fde0d763eb45 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 12:52:38 +0200 Subject: [PATCH 17/23] Rename drawing commands --- src/excmds.ts | 14 +++++++------- src/lib/config.ts | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index 65d141d3..ee129b4f 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1636,28 +1636,28 @@ export function pied_piper_mouse_mode() { } /** * Drawable variant of [[no_mouse_mode]] - * In this mode, you can use the mouse or a digital stylus to draw. To switch to an eraser, use [[eraser_toggle]] + * In this mode, you can use the mouse or a digital stylus to draw. To switch to an eraser, use [[drawingerasertoggle]] * Use [[mouse_mode]] to return, or refresh page. - * Suggested usage: `autocmd DocLoad .* drawable_mouse_mode` + * Suggested usage: `autocmd DocLoad .* drawingstart * * **Warning**: Windows Ink enabled input devices don't work, disable it for your browser, or use a mouse. */ //#content -export function drawable_mouse_mode() { +export function drawingstart() { toys.drawable() } /** - * Switch between pen and eraser for [[drawable_mouse_mode]] - * Suggested usage: `bind e eraser_toggle`. If you have a digital pen, map the button to `e` to switch easily. + * Switch between pen and eraser for [[drawingstart]] + * Suggested usage: `bind e drawingerasertoggle`. If you have a digital pen, map the button to `e` to switch easily. */ //#content -export function eraser_toggle() { +export function drawingerasertoggle() { toys.eraser_toggle() } /** * Revert any variant of the [[no_mouse_mode]] * - * Suggested usage: `bind mouse_mode` with the autocmd mentioned in [[no_mouse_mode]] or [[drawable_mouse_mode]]. + * Suggested usage: `bind mouse_mode` with the autocmd mentioned in [[no_mouse_mode]] or [[drawingstart]]. */ //#content export function mouse_mode() { diff --git a/src/lib/config.ts b/src/lib/config.ts index 8949e6b4..b1687202 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -609,6 +609,7 @@ export class default_config { "mktridactylrc!": "mktridactylrc -f", mpvsafe: "js -p tri.excmds.shellescape(JS_ARG).then(url => tri.excmds.exclaim_quiet('mpv --no-terminal ' + url))", + drawingstop: "no_mouse_mode", exto: "extoptions", extpreferences: "extoptions", extp: "extpreferences", From 5092be9e3663c9de681c5895cfe22c0d394fa328 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 12:56:29 +0200 Subject: [PATCH 18/23] Remove .ts from imports Webpack supports it but TypeScript does not --- src/background/editor.ts | 4 ++-- src/completions/Sessions.ts | 2 +- src/completions/Tab.ts | 2 +- src/completions/Window.ts | 5 +++-- src/content/editor.ts | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/background/editor.ts b/src/background/editor.ts index 5e9ecb7d..d8e3bb59 100644 --- a/src/background/editor.ts +++ b/src/background/editor.ts @@ -1,5 +1,5 @@ -import { messageActiveTab } from "@src/lib/messaging.ts" -import * as _EditorCmds from "@src/lib/editor.ts" +import { messageActiveTab } from "@src/lib/messaging" +import * as _EditorCmds from "@src/lib/editor" type cmdsType = typeof _EditorCmds type ArgumentsType = T extends (elem, ...args: infer U) => any ? U : never diff --git a/src/completions/Sessions.ts b/src/completions/Sessions.ts index c7e92065..8042c74e 100644 --- a/src/completions/Sessions.ts +++ b/src/completions/Sessions.ts @@ -1,4 +1,4 @@ -import { browserBg } from "@src/lib/webext.ts" +import { browserBg } from "@src/lib/webext" import * as Completions from "@src/completions" import * as config from "@src/lib/config" diff --git a/src/completions/Tab.ts b/src/completions/Tab.ts index c71a25bf..09a7832e 100644 --- a/src/completions/Tab.ts +++ b/src/completions/Tab.ts @@ -1,5 +1,5 @@ import * as Perf from "@src/perf" -import { browserBg } from "@src/lib/webext.ts" +import { browserBg } from "@src/lib/webext" import { enumerate } from "@src/lib/itertools" import * as Containers from "@src/lib/containers" import * as Completions from "@src/completions" diff --git a/src/completions/Window.ts b/src/completions/Window.ts index 1abd6682..8ab949ed 100644 --- a/src/completions/Window.ts +++ b/src/completions/Window.ts @@ -1,7 +1,8 @@ -import { browserBg } from "@src/lib/webext.ts" +import { browserBg } from "@src/lib/webext" import * as Completions from "@src/completions" -class WindowCompletionOption extends Completions.CompletionOptionHTML +class WindowCompletionOption + extends Completions.CompletionOptionHTML implements Completions.CompletionOptionFuse { public fuseKeys = [] diff --git a/src/content/editor.ts b/src/content/editor.ts index 14e244d9..446040ef 100644 --- a/src/content/editor.ts +++ b/src/content/editor.ts @@ -2,9 +2,9 @@ import { messageOwnTab, addListener, attributeCaller, -} from "@src/lib/messaging.ts" +} from "@src/lib/messaging" import * as DOM from "@src/lib/dom" -import * as _EditorCmds from "@src/lib/editor.ts" +import * as _EditorCmds from "@src/lib/editor" export const EditorCmds = new Proxy(_EditorCmds, { get(target, property) { From eb979892ff2796de96ead72195f1bed4fc9d83f4 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 13:26:47 +0200 Subject: [PATCH 19/23] Remove web-ext-types The definitely typed package is fine now --- package.json | 1 - src/lib/webext.ts | 7 ++++++- tsconfig.json | 2 +- yarn.lock | 5 ----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7de45490..11a2bb37 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "typedoc": "^0.19.2", "typescript": "^3.9.9", "web-ext": "^6.0.0", - "web-ext-types": "^3.2.1", "webpack": "^5.36.1", "webpack-cli": "^4.6.0" }, diff --git a/src/lib/webext.ts b/src/lib/webext.ts index efc0440e..ad408a9f 100644 --- a/src/lib/webext.ts +++ b/src/lib/webext.ts @@ -10,7 +10,12 @@ export function inContentScript() { export function getTriVersion() { const manifest = browser.runtime.getManifest() - return manifest.version_name + + // version_name only really exists in Chrome + // but we're using it anyway for our own purposes + return (manifest as browser._manifest.WebExtensionManifest & { + version_name: string + }).version_name } export function getPrettyTriVersion() { diff --git a/tsconfig.json b/tsconfig.json index 4df05064..90d4f27e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "noImplicitThis": true, "strictFunctionTypes": true, "baseUrl": "src/", - "types": ["@types/ramda", "@types/firefox-webext-browser", "web-ext-types"], + "types": ["@types/ramda", "@types/firefox-webext-browser"], "paths": { "@src/*": ["*"] } diff --git a/yarn.lock b/yarn.lock index 6e54cf21..19e396d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7515,11 +7515,6 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" -web-ext-types@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/web-ext-types/-/web-ext-types-3.2.1.tgz#3edc0e3c2e8fe121d7d7e4ca0b7ee0c883cea832" - integrity sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew== - web-ext@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/web-ext/-/web-ext-6.0.0.tgz#0da07ab1b88aa450374fea43c793114c42348d41" From 4e50ab486659afc6018f9d88cd6ef6982fe3f417 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 14:20:05 +0200 Subject: [PATCH 20/23] Use definitely typed management types --- src/lib/extension_info.ts | 4 +- src/tridactyl.d.ts | 96 --------------------------------------- 2 files changed, 2 insertions(+), 98 deletions(-) diff --git a/src/lib/extension_info.ts b/src/lib/extension_info.ts index 4e79e426..316490ee 100644 --- a/src/lib/extension_info.ts +++ b/src/lib/extension_info.ts @@ -16,11 +16,11 @@ export const KNOWN_EXTENSIONS: { [name: string]: string } = { /** List of currently installed extensions. */ const installedExtensions: { - [id: string]: browser.management.IExtensionInfo + [id: string]: browser.management.ExtensionInfo } = {} function updateExtensionInfo( - extension: browser.management.IExtensionInfo, + extension: browser.management.ExtensionInfo, ): void { installedExtensions[extension.id] = extension } diff --git a/src/tridactyl.d.ts b/src/tridactyl.d.ts index a4e2338e..e2a06664 100644 --- a/src/tridactyl.d.ts +++ b/src/tridactyl.d.ts @@ -89,102 +89,6 @@ interface WebExtEventBase< hasListener(cb: TCallback): boolean } -type WebExtEvent any> = WebExtEventBase< - (callback: TCallback) => void, - TCallback -> -declare namespace browser.management { - /* management types */ - - /** Information about an icon belonging to an extension. */ - interface IconInfo { - /** - * A number representing the width and height of the icon. Likely values include (but are not limited to) 128, - * 48, 24, and 16. - */ - size: number - /** - * The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is - * disabled, for example), append `?grayscale=true` to the URL. - */ - url: string - } - - /** A reason the item is disabled. */ - type ExtensionDisabledReason = "unknown" | "permissions_increase" - - /** The type of this extension. Will always be 'extension'. */ - type ExtensionType = "extension" | "theme" - - /** - * How the extension was installed. One of - * `development`: The extension was loaded unpacked in developer mode, - * `normal`: The extension was installed normally via an .xpi file, - * `sideload`: The extension was installed by other software on the machine, - * `other`: The extension was installed by other means. - */ - type ExtensionInstallType = "development" | "normal" | "sideload" | "other" - - /** Information about an installed extension. */ - interface IExtensionInfo { - /** The extension's unique identifier. */ - id: string - /** The name of this extension. */ - name: string - /** A short version of the name of this extension. */ - shortName?: string - /** The description of this extension. */ - description: string - /** The version of this extension. */ - version: string - /** The version name of this extension if the manifest specified one. */ - versionName?: string - /** Whether this extension can be disabled or uninstalled by the user. */ - mayDisable: boolean - /** Whether it is currently enabled or disabled. */ - enabled: boolean - /** A reason the item is disabled. */ - disabledReason?: ExtensionDisabledReason - /** The type of this extension. Will always return 'extension'. */ - type: ExtensionType - /** The URL of the homepage of this extension. */ - homepageUrl?: string - /** The update URL of this extension. */ - updateUrl?: string - /** The url for the item's options page, if it has one. */ - optionsUrl: string - /** - * A list of icon information. Note that this just reflects what was declared in the manifest, and the actual - * image at that url may be larger or smaller than what was declared, so you might consider using explicit - * width and height attributes on img tags referencing these images. See the manifest documentation on icons - * for more details. - */ - icons?: IconInfo[] - /** Returns a list of API based permissions. */ - permissions?: string[] - /** Returns a list of host based permissions. */ - hostPermissions?: string[] - /** How the extension was installed. */ - installType: ExtensionInstallType - } - - /* management functions */ - /** Returns a list of information about installed extensions. */ - function getAll(): Promise - - /* management events */ - /** Fired when an addon has been disabled. */ - const onDisabled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been enabled. */ - const onEnabled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been installed. */ - const onInstalled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been uninstalled. */ - const onUninstalled: WebExtEvent<(info: IExtensionInfo) => void> -} // html-tagged-template.js declare function html( From afda42e7f99ae9b5d7fa5b98e658e6b754f8298e Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 14:25:38 +0200 Subject: [PATCH 21/23] Fix various minor typescript errors --- src/completions.ts | 4 ++-- src/content/hinting.ts | 4 ++-- src/excmds.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/completions.ts b/src/completions.ts index d94e78e7..5d295c86 100644 --- a/src/completions.ts +++ b/src/completions.ts @@ -29,7 +29,7 @@ export abstract class CompletionOption { /** What to fill into cmdline */ value: string /** Control presentation of the option */ - state: OptionState + abstract state: OptionState } export abstract class CompletionSource { @@ -94,7 +94,7 @@ export abstract class CompletionSource { /** Update [[node]] to display completions relevant to exstr */ public abstract filter(exstr: string): Promise - abstract async next(inc?: number): Promise + abstract next(inc?: number): Promise } // Default classes diff --git a/src/content/hinting.ts b/src/content/hinting.ts index 5fa01d26..0f368bb5 100644 --- a/src/content/hinting.ts +++ b/src/content/hinting.ts @@ -402,8 +402,8 @@ interface Hintables { export function hintPage( hintableElements: Hintables[], onSelect: HintSelectedCallback, - resolve = () => {}, // eslint-disable-line @typescript-eslint/no-empty-function - reject = () => {}, // eslint-disable-line @typescript-eslint/no-empty-function + resolve: (x?) => void = () => {}, // eslint-disable-line @typescript-eslint/no-empty-function + reject: (x?) => void = () => {}, // eslint-disable-line @typescript-eslint/no-empty-function rapid = false, ) { const buildHints: HintBuilder = defaultHintBuilder() diff --git a/src/excmds.ts b/src/excmds.ts index ee129b4f..8f081e61 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -3274,7 +3274,7 @@ export async function fillcmdline_tmp(ms: number, ...strarr: string[]) { const str = strarr.join(" ") showcmdline(false) Messaging.messageOwnTab("commandline_frame", "fillcmdline", [strarr.join(" "), false, false]) - return new Promise(resolve => + return new Promise(resolve => setTimeout(async () => { if ((await Messaging.messageOwnTab("commandline_frame", "getContent", [])) === str) { CommandLineContent.hide_and_blur() @@ -4762,7 +4762,11 @@ export function buildFilterConfigs(filters: string[]): Perf.StatsFilterConfig[] } else if (filter === ":measure") { return { kind: "eventType", eventType: "measure" } } else { - return { kind: "functionName", functionName: name } + // This used to say `functionName: name` + // which didn't seem to exist anywhere + // + // So at least we return something now + return { kind: "functionName", functionName: filter } } }, ) From e5b9f4118ac1f69c30de8db36c71ea5caa7fc053 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 14:48:39 +0200 Subject: [PATCH 22/23] Fix tests --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index ad6bb8c2..d967fda7 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { "ts-jest": { tsConfig: { ...tsConfig.compilerOptions, - types: ["jest", "node", "web-ext-types"] + types: ["jest", "node", "@types/firefox-webext-browser"] }, diagnostics: { ignoreCodes: [151001] From 91ee67b6e1c3d28abd0436a02eb7c94ec74fb0fd Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 17:23:00 +0200 Subject: [PATCH 23/23] Add discardall command to RC --- .tridactylrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.tridactylrc b/.tridactylrc index 0ec26612..1bece711 100644 --- a/.tridactylrc +++ b/.tridactylrc @@ -85,6 +85,9 @@ command hint_focus hint -; " Open right click menu on links bind ;C composite hint_focus; !s xdotool key Menu +" Suspend / "discard" all tabs - handy for stretching out battery life +command discardall jsb browser.tabs.query({}).then(ts => browser.tabs.discard(ts.map(t=>t.id))) + " Julia docs' built in search is bad set searchurls.julia https://www.google.com/search?q=site:http://docs.julialang.org/en/v1%20