From e810cec2c4423f4a14e16927bc5fe640e4e859f6 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Tue, 4 Apr 2023 21:29:58 +0200 Subject: [PATCH 01/98] adding link utils for custom protocolLauncher --- app/common/config-schemata.ts | 1 + app/common/link-util.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/common/config-schemata.ts b/app/common/config-schemata.ts index e2db7b80f..37ca35964 100644 --- a/app/common/config-schemata.ts +++ b/app/common/config-schemata.ts @@ -24,6 +24,7 @@ export const configSchemata = { lastActiveTab: z.number(), promptDownload: z.boolean(), proxyBypass: z.string(), + protocolLaunchers: z.object(), // eslint-disable-next-line @typescript-eslint/naming-convention proxyPAC: z.string(), proxyRules: z.string(), diff --git a/app/common/link-util.ts b/app/common/link-util.ts index c89798c0e..b3cb03aaf 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -1,13 +1,22 @@ -import {shell} from "electron/common"; +import { shell } from "electron/common"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import * as ConfigUtil from "./config-util.js"; -import {html} from "./html.js"; +import { html } from "./html.js"; + +/* Fetches the current protocolLaunchers from settings.json */ +const protocolLaunchers = ConfigUtil.getConfigItem("protocolLaunchers", {}); export async function openBrowser(url: URL): Promise { if (["http:", "https:", "mailto:"].includes(url.protocol)) { await shell.openExternal(url.href); + } else if (protocolLaunchers.includes(url.protocol)) { + // custom protocol launchers + let executable = protocolLaunchers[url.protocol]; + let command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; + await shell.openExternal(executable + " " + command); } else { // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file. From d198a8d3557885789481112482b9f2c5a0b560b9 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 00:48:28 +0200 Subject: [PATCH 02/98] replacing object schema by map schema --- app/common/config-schemata.ts | 2 +- app/common/link-util.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/common/config-schemata.ts b/app/common/config-schemata.ts index 37ca35964..2a93389cb 100644 --- a/app/common/config-schemata.ts +++ b/app/common/config-schemata.ts @@ -24,7 +24,7 @@ export const configSchemata = { lastActiveTab: z.number(), promptDownload: z.boolean(), proxyBypass: z.string(), - protocolLaunchers: z.object(), + protocolLaunchers: z.map(z.string().min(1), z.string().min(1)), // eslint-disable-next-line @typescript-eslint/naming-convention proxyPAC: z.string(), proxyRules: z.string(), diff --git a/app/common/link-util.ts b/app/common/link-util.ts index b3cb03aaf..3b3ad5546 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -7,14 +7,14 @@ import * as ConfigUtil from "./config-util.js"; import { html } from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ -const protocolLaunchers = ConfigUtil.getConfigItem("protocolLaunchers", {}); +const protocolLaunchers = ConfigUtil.getConfigItem("protocolLaunchers", new Map()); export async function openBrowser(url: URL): Promise { if (["http:", "https:", "mailto:"].includes(url.protocol)) { await shell.openExternal(url.href); - } else if (protocolLaunchers.includes(url.protocol)) { - // custom protocol launchers - let executable = protocolLaunchers[url.protocol]; + } else if (protocolLaunchers.has(url.protocol)) { + // custom protocol launchers based on a protocol-executable map + let executable = protocolLaunchers.get(url.protocol); let command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; await shell.openExternal(executable + " " + command); } else { From 521dddb78a7e7348b1a2a789c782b58c037251a9 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:02:19 +0200 Subject: [PATCH 03/98] cleaned up code style --- app/common/link-util.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 3b3ad5546..052be186a 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -1,22 +1,24 @@ -import { shell } from "electron/common"; +import {shell} from "electron/common"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import * as ConfigUtil from "./config-util.js"; - -import { html } from "./html.js"; +import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ -const protocolLaunchers = ConfigUtil.getConfigItem("protocolLaunchers", new Map()); +const protocolLaunchers = ConfigUtil.getConfigItem( + "protocolLaunchers", + new Map() +); export async function openBrowser(url: URL): Promise { if (["http:", "https:", "mailto:"].includes(url.protocol)) { await shell.openExternal(url.href); } else if (protocolLaunchers.has(url.protocol)) { - // custom protocol launchers based on a protocol-executable map - let executable = protocolLaunchers.get(url.protocol); - let command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; - await shell.openExternal(executable + " " + command); + // Custom protocol launchers based on a protocol-executable map + const executable = protocolLaunchers.get(url.protocol); + const command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; + await shell.openExternal(String(executable) + " " + String(command)); } else { // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file. From 0af82b4ef6f874be9ece32bc60569a6957c26a6b Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:05:43 +0200 Subject: [PATCH 04/98] cleanup up import structure --- app/common/link-util.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 052be186a..e124d61e1 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -2,13 +2,15 @@ import {shell} from "electron/common"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import * as ConfigUtil from "./config-util.js"; + import {html} from "./html.js"; +import * as ConfigUtil from "./config-util.js"; + /* Fetches the current protocolLaunchers from settings.json */ const protocolLaunchers = ConfigUtil.getConfigItem( - "protocolLaunchers", - new Map() + "protocolLaunchers", + new Map(), ); export async function openBrowser(url: URL): Promise { From 377f70880d38bec14e597f14c2c2ea357da169f7 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:08:05 +0200 Subject: [PATCH 05/98] fix import order --- app/common/link-util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index e124d61e1..ee5f63d9a 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -3,9 +3,8 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import {html} from "./html.js"; - import * as ConfigUtil from "./config-util.js"; +import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ const protocolLaunchers = ConfigUtil.getConfigItem( From 122533ac9a0fc6e98c788762bede33b41de08d70 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 13:19:06 +0200 Subject: [PATCH 06/98] added whitelistProtocols to config --- app/common/config-schemata.ts | 2 +- app/common/link-util.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/common/config-schemata.ts b/app/common/config-schemata.ts index 2a93389cb..f59b364f0 100644 --- a/app/common/config-schemata.ts +++ b/app/common/config-schemata.ts @@ -24,7 +24,7 @@ export const configSchemata = { lastActiveTab: z.number(), promptDownload: z.boolean(), proxyBypass: z.string(), - protocolLaunchers: z.map(z.string().min(1), z.string().min(1)), + whitelistedProtocols: z.string().array(), // eslint-disable-next-line @typescript-eslint/naming-convention proxyPAC: z.string(), proxyRules: z.string(), diff --git a/app/common/link-util.ts b/app/common/link-util.ts index ee5f63d9a..ca4a48f62 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -7,19 +7,15 @@ import * as ConfigUtil from "./config-util.js"; import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ -const protocolLaunchers = ConfigUtil.getConfigItem( - "protocolLaunchers", - new Map(), -); +const whitelistedProtocols = ConfigUtil.getConfigItem("whitelistedProtocols", [ + "http:", + "https:", + "mailto:", +]); export async function openBrowser(url: URL): Promise { - if (["http:", "https:", "mailto:"].includes(url.protocol)) { + if (whitelistedProtocols.includes(url.protocol)) { await shell.openExternal(url.href); - } else if (protocolLaunchers.has(url.protocol)) { - // Custom protocol launchers based on a protocol-executable map - const executable = protocolLaunchers.get(url.protocol); - const command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; - await shell.openExternal(String(executable) + " " + String(command)); } else { // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file. From f25b7e7c87a90923f2e8dc9107e5701f15d458d1 Mon Sep 17 00:00:00 2001 From: "Jonas_sorgenfrei@yahoo.de" Date: Fri, 27 Dec 2024 13:30:24 +0100 Subject: [PATCH 07/98] added tel and sip to default protocols --- app/common/link-util.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 784a3b8ec..87305e5e7 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -11,6 +11,8 @@ const whitelistedProtocols = ConfigUtil.getConfigItem("whitelistedProtocols", [ "http:", "https:", "mailto:", + "tel:", + "sip:", ]); export async function openBrowser(url: URL): Promise { From 0256e8e48dcae554806e275e1fccefd0780ae748 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 4 Apr 2023 15:17:04 -0700 Subject: [PATCH 08/98] preference: Fix spellchecker languages dropdown positioning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently the Tagify defaults don’t work inside a shadow root. Fixes #1286. Closes #1290. Signed-off-by: Anders Kaseorg --- app/renderer/css/preference.css | 11 +++++++++++ .../js/pages/preference/general-section.ts | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/renderer/css/preference.css b/app/renderer/css/preference.css index 89f1c0436..9e7abb481 100644 --- a/app/renderer/css/preference.css +++ b/app/renderer/css/preference.css @@ -10,6 +10,11 @@ letter-spacing: -0.08px; line-height: 18px; color: rgb(139 142 143 / 100%); + + /* Copied from https://github.com/yairEO/tagify/blob/v4.17.7/src/tagify.scss#L4-L8 */ + --tagify-dd-color-primary: rgb(53 149 246); + --tagify-dd-bg-color: rgb(255 255 255); + --tagify-dd-item-pad: 0.3em 0.5em; } kbd { @@ -760,3 +765,9 @@ i.open-network-button { top: 0; bottom: 0; } + +.settings-tagify-dropdown { + position: relative; + z-index: 9999; + height: 0; +} diff --git a/app/renderer/js/pages/preference/general-section.ts b/app/renderer/js/pages/preference/general-section.ts index 3ebcd5e3d..0c921b0f3 100644 --- a/app/renderer/js/pages/preference/general-section.ts +++ b/app/renderer/js/pages/preference/general-section.ts @@ -610,7 +610,9 @@ export function initGeneralSection({$root}: GeneralSectionProps): void { const spellDiv: HTMLElement = $root.querySelector("#spellcheck-langs")!; spellDiv.innerHTML += html`
${t.__("Spellchecker Languages")}
- +
+ +
`.html; const availableLanguages = session.fromPartition( @@ -652,8 +654,20 @@ export function initGeneralSection({$root}: GeneralSectionProps): void { maxItems: Number.POSITIVE_INFINITY, closeOnSelect: false, highlightFirst: true, + position: "manual", + classname: "settings-tagify-dropdown", }, }); + tagify.DOM.input.addEventListener("focus", () => { + tagify.dropdown.show(); + $root + .querySelector("#spellcheck-langs-value")! + .append(tagify.DOM.dropdown); + }); + tagify.DOM.input.addEventListener("blur", () => { + tagify.dropdown.hide(true); + tagify.DOM.dropdown.remove(); + }); const configuredLanguages: string[] = ( ConfigUtil.getConfigItem("spellcheckerLanguages", null) ?? [] From 1cdda213d0954c22186b70f92e256da9a3af28d8 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:02:19 +0200 Subject: [PATCH 09/98] cleaned up code style --- app/common/link-util.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 3b3ad5546..052be186a 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -1,22 +1,24 @@ -import { shell } from "electron/common"; +import {shell} from "electron/common"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import * as ConfigUtil from "./config-util.js"; - -import { html } from "./html.js"; +import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ -const protocolLaunchers = ConfigUtil.getConfigItem("protocolLaunchers", new Map()); +const protocolLaunchers = ConfigUtil.getConfigItem( + "protocolLaunchers", + new Map() +); export async function openBrowser(url: URL): Promise { if (["http:", "https:", "mailto:"].includes(url.protocol)) { await shell.openExternal(url.href); } else if (protocolLaunchers.has(url.protocol)) { - // custom protocol launchers based on a protocol-executable map - let executable = protocolLaunchers.get(url.protocol); - let command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; - await shell.openExternal(executable + " " + command); + // Custom protocol launchers based on a protocol-executable map + const executable = protocolLaunchers.get(url.protocol); + const command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; + await shell.openExternal(String(executable) + " " + String(command)); } else { // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file. From f7cfcb66aa0ed99fd1da8ca144cbeecda8bd9ad5 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:05:43 +0200 Subject: [PATCH 10/98] cleanup up import structure --- app/common/link-util.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 052be186a..e124d61e1 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -2,13 +2,15 @@ import {shell} from "electron/common"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import * as ConfigUtil from "./config-util.js"; + import {html} from "./html.js"; +import * as ConfigUtil from "./config-util.js"; + /* Fetches the current protocolLaunchers from settings.json */ const protocolLaunchers = ConfigUtil.getConfigItem( - "protocolLaunchers", - new Map() + "protocolLaunchers", + new Map(), ); export async function openBrowser(url: URL): Promise { From 2128169539f53154f442601b1ee0ea1451028d24 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 01:08:05 +0200 Subject: [PATCH 11/98] fix import order --- app/common/link-util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/common/link-util.ts b/app/common/link-util.ts index e124d61e1..ee5f63d9a 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -3,9 +3,8 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import {html} from "./html.js"; - import * as ConfigUtil from "./config-util.js"; +import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ const protocolLaunchers = ConfigUtil.getConfigItem( From c9769a54cd88a623dd0d1ab539b8fc9560e94b69 Mon Sep 17 00:00:00 2001 From: Jonas Sorgenfrei Date: Thu, 6 Apr 2023 13:19:06 +0200 Subject: [PATCH 12/98] added whitelistProtocols to config --- app/common/config-schemata.ts | 2 +- app/common/link-util.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/common/config-schemata.ts b/app/common/config-schemata.ts index 2a93389cb..f59b364f0 100644 --- a/app/common/config-schemata.ts +++ b/app/common/config-schemata.ts @@ -24,7 +24,7 @@ export const configSchemata = { lastActiveTab: z.number(), promptDownload: z.boolean(), proxyBypass: z.string(), - protocolLaunchers: z.map(z.string().min(1), z.string().min(1)), + whitelistedProtocols: z.string().array(), // eslint-disable-next-line @typescript-eslint/naming-convention proxyPAC: z.string(), proxyRules: z.string(), diff --git a/app/common/link-util.ts b/app/common/link-util.ts index ee5f63d9a..ca4a48f62 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -7,19 +7,15 @@ import * as ConfigUtil from "./config-util.js"; import {html} from "./html.js"; /* Fetches the current protocolLaunchers from settings.json */ -const protocolLaunchers = ConfigUtil.getConfigItem( - "protocolLaunchers", - new Map(), -); +const whitelistedProtocols = ConfigUtil.getConfigItem("whitelistedProtocols", [ + "http:", + "https:", + "mailto:", +]); export async function openBrowser(url: URL): Promise { - if (["http:", "https:", "mailto:"].includes(url.protocol)) { + if (whitelistedProtocols.includes(url.protocol)) { await shell.openExternal(url.href); - } else if (protocolLaunchers.has(url.protocol)) { - // Custom protocol launchers based on a protocol-executable map - const executable = protocolLaunchers.get(url.protocol); - const command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash; - await shell.openExternal(String(executable) + " " + String(command)); } else { // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file. From 13a55ac62a283123c4541e70a74db7c2f0825a98 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 18 Apr 2023 12:48:06 -0700 Subject: [PATCH 13/98] Handle exceptions when reading server icons. Signed-off-by: Anders Kaseorg --- app/renderer/js/main.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/renderer/js/main.ts b/app/renderer/js/main.ts index 6a408e207..912d5a1dc 100644 --- a/app/renderer/js/main.ts +++ b/app/renderer/js/main.ts @@ -363,13 +363,20 @@ export class ServerManagerView { initServer(server: ServerConf, index: number): void { const tabIndex = this.getTabIndex(); + let icon; + try { + icon = `data:application/octet-stream;base64,${fs.readFileSync( + server.icon, + "base64", + )}`; + } catch { + icon = "data:,"; + } + this.tabs.push( new ServerTab({ role: "server", - icon: `data:application/octet-stream;base64,${fs.readFileSync( - server.icon, - "base64", - )}`, + icon, name: server.alias, $root: this.$tabsContainer, onClick: this.activateLastTab.bind(this, index), From 66e9bbff33dabb93fd44e176296c7a9aa2e8b0ae Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 18 Apr 2023 13:09:24 -0700 Subject: [PATCH 14/98] =?UTF-8?q?Don=E2=80=99t=20show=20visual=20notificat?= =?UTF-8?q?ions=20when=20they=E2=80=99re=20turned=20off.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1299. Signed-off-by: Anders Kaseorg --- app/renderer/js/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/renderer/js/main.ts b/app/renderer/js/main.ts index 912d5a1dc..c020cb4c9 100644 --- a/app/renderer/js/main.ts +++ b/app/renderer/js/main.ts @@ -392,7 +392,9 @@ export class ServerManagerView { url: server.url, role: "server", hasPermission: (origin: string, permission: string) => - origin === server.url && permission === "notifications", + origin === server.url && + permission === "notifications" && + ConfigUtil.getConfigItem("showNotification", true), isActive: () => index === this.activeTabIndex, switchLoading: async (loading: boolean, url: string) => { if (loading) { From dd2bec3027d54aa61b1044c9bb88a23557d89b4d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 18 Apr 2023 14:03:45 -0700 Subject: [PATCH 15/98] xo: Remove redundant exclusion of unicorn/prefer-json-parse-buffer. Signed-off-by: Anders Kaseorg --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 1f5c961ae..3d1843e75 100644 --- a/package.json +++ b/package.json @@ -270,7 +270,6 @@ } ], "strict": "error", - "unicorn/prefer-json-parse-buffer": "off", "unicorn/prefer-module": "off", "unicorn/prefer-top-level-await": "off" }, From 58e7e39c5b591d20738cc559a155c30b63f6ffaa Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 18 Apr 2023 14:16:48 -0700 Subject: [PATCH 16/98] preference: Fix CSS in Vite dev mode. Signed-off-by: Anders Kaseorg --- app/renderer/css/preference.css | 2 ++ app/renderer/preference.html | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/renderer/css/preference.css b/app/renderer/css/preference.css index 9e7abb481..ee6e26fac 100644 --- a/app/renderer/css/preference.css +++ b/app/renderer/css/preference.css @@ -1,3 +1,5 @@ +@import url("@yaireo/tagify/dist/tagify.css"); + :host { contain: strict; display: flow-root; diff --git a/app/renderer/preference.html b/app/renderer/preference.html index c729c553d..3290b25b6 100644 --- a/app/renderer/preference.html +++ b/app/renderer/preference.html @@ -2,9 +2,6 @@ -