diff --git a/apps/actors/lib/LinkHandlerParent.sys.mjs b/apps/actors/lib/LinkHandlerParent.sys.mjs index 1c0ba31..2c6eb90 100644 --- a/apps/actors/lib/LinkHandlerParent.sys.mjs +++ b/apps/actors/lib/LinkHandlerParent.sys.mjs @@ -8,14 +8,15 @@ export class LinkHandlerParent extends JSWindowActorParent { /** @param {{ name: 'Link:SetIcon'; data: { iconURL: string } }} aMsg */ receiveMessage(aMsg) { + /** @type {Window} */ const win = this.browsingContext.topChromeWindow switch (aMsg.name) { case 'Link:SetIcon': - return win.windowApi.tabs.setIcon( - this.browsingContext.embedderElement, - aMsg.data.iconURL, - ) + return win.eventBus.emit('iconUpdate', { + browserId: this.browsingContext.embedderElement.browserId, + iconUrl: aMsg.data.iconURL, + }) } } } diff --git a/apps/actors/lib/ThemeMetaChild.sys.mjs b/apps/actors/lib/ThemeMetaChild.sys.mjs new file mode 100644 index 0000000..d90c1bf --- /dev/null +++ b/apps/actors/lib/ThemeMetaChild.sys.mjs @@ -0,0 +1,92 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// @ts-check +/// + +/** + * @typedef {object} CurrentPageColors + * @property {string} [meta] + * @property {string} [body] + */ + +export class ThemeMetaChild extends JSWindowActorChild { + /** @type {CurrentPageColors} */ + currentColorOptions = {} + + /** + * @param {DOMMetaAddedEvent|DOMMetaChangedEvent} event + */ + handleMetaEvent(event) { + const { target } = event + + if (target.name === 'theme-color') { + this.currentColorOptions.meta = + target.getAttribute('content') || undefined + + this.sendUpdatedThemeColors() + } + } + + /** + * @param {PageShowEvent} event + */ + handlePageLoad(event) { + const document = event.target + this.currentColorOptions.body = + this.getHeaderColor(document.body, document.body) || undefined + + this.sendUpdatedThemeColors() + } + + /** + * @param {HTMLElement} element + * @param {HTMLElement} body + * @returns {string | null} + */ + getHeaderColor(element, body) { + if (!element.getBoundingClientRect) { + return null + } + + if (element != body && element.getBoundingClientRect().y != 0) { + return null + } + + let elementColor = null + + if (element.firstChild) { + elementColor = this.getHeaderColor(element.firstChild, body) + } + + if (!elementColor) { + elementColor = this.contentWindow.getComputedStyle(element).background + if ( + elementColor.toLowerCase() == 'none' || + elementColor.toLowerCase() == 'transperent' + ) { + return null + } + } + + return elementColor + } + + sendUpdatedThemeColors() { + this.sendAsyncMessage('Theme:ColorsUpdated', this.currentColorOptions) + } + + /** + * @param {PageShowEvent | DOMMetaAddedEvent | DOMMetaChangedEvent} event + */ + handleEvent(event) { + switch (event.type) { + case 'DOMMetaAdded': + case 'DOMMetaChanged': + return this.handleMetaEvent(event) + case 'pageshow': + return this.handlePageLoad(event) + } + } +} diff --git a/apps/actors/lib/ThemeMetaParent.sys.mjs b/apps/actors/lib/ThemeMetaParent.sys.mjs new file mode 100644 index 0000000..692956c --- /dev/null +++ b/apps/actors/lib/ThemeMetaParent.sys.mjs @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// @ts-check +/// + +export class ThemeMetaParent extends JSWindowActorParent { + receiveMessage(aMsg) { + /** @type {Window} */ + const win = this.browsingContext.topChromeWindow + + if (aMsg.name === 'Theme:ColorsUpdated') { + win.eventBus.emit('themeUpdate', { + ...aMsg.data, + browserId: this.browsingContext.embedderElement.browserId, + }) + } + } +} diff --git a/apps/content/package.json b/apps/content/package.json index dc71cf6..40d4942 100644 --- a/apps/content/package.json +++ b/apps/content/package.json @@ -12,17 +12,17 @@ "license": "ISC", "devDependencies": { "@browser/link": "workspace:*", - "@melt-ui/pp": "^0.3.0", "@total-typescript/ts-reset": "^0.5.1", "@tsconfig/svelte": "^5.0.2", "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.8.1", + "gecko-types": "github:quark-platform/gecko-types", "html-webpack-plugin": "^5.6.0", "mini-css-extract-plugin": "^2.7.6", "postcss-loader": "^7.3.4", "style-loader": "^3.3.3", - "svelte": "^4.2.8", - "svelte-loader": "^3.1.9", + "svelte": "^4.2.12", + "svelte-loader": "^3.2.0", "svelte-preprocess": "^5.1.3", "svelte-sequential-preprocessor": "^2.0.1", "ts-loader": "^9.5.1", @@ -33,14 +33,15 @@ "webpack-license-plugin": "^4.4.2" }, "dependencies": { + "@amadeus-it-group/tansu": "^1.0.0", "@catppuccin/palette": "^1.0.1", - "@experiment/shared": "workspace:*", - "@melt-ui/svelte": "^0.67.0", + "colorjs.io": "^0.5.0", "fnts": "^2.1.0", "mitt": "^3.0.1", "nanoid": "^5.0.4", "remixicon": "^4.0.1", "snarkdown": "^2.0.0", + "svelte-remixicon": "^2.4.0", "zora": "^5.2.0" } } diff --git a/apps/content/patches/@melt-ui__svelte@0.64.5.patch b/apps/content/patches/@melt-ui__svelte@0.64.5.patch deleted file mode 100644 index c09e07a..0000000 --- a/apps/content/patches/@melt-ui__svelte@0.64.5.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/package.json b/package.json -index 9b7faa1b796b3fd8ac90b3364450f57896d866c0..b852ad9188adb271ad2b3b07b2e61bbb6ff124a0 100644 ---- a/package.json -+++ b/package.json -@@ -7,7 +7,8 @@ - "exports": { - ".": { - "types": "./dist/index.d.ts", -- "svelte": "./dist/index.js" -+ "svelte": "./dist/index.js", -+ "import": "./dist/index.js" - }, - "./internal/*": { - "types": "./dist/internal/*/index.d.ts", -@@ -130,7 +131,6 @@ - "svelte": "./dist/index.js", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", -- "type": "module", - "packageManager": "pnpm@8.6.3", - "scripts": { - "dev": "vite dev", diff --git a/apps/content/src/bookmarks/Bookmarks.svelte b/apps/content/src/bookmarks/Bookmarks.svelte deleted file mode 100644 index 6d16001..0000000 --- a/apps/content/src/bookmarks/Bookmarks.svelte +++ /dev/null @@ -1,45 +0,0 @@ - - - - -
- {#await $fullTree} -

Loading...

- {:then tree} - - - {#if selectedBookmark} - { - selectedBookmarkId = undefined - selectedBookmark = undefined - }} - /> - {/if} - {/await} -
- - diff --git a/apps/content/src/browser/components/customizableUI/index.ts b/apps/content/src/bookmarks/bookmarks.js similarity index 100% rename from apps/content/src/browser/components/customizableUI/index.ts rename to apps/content/src/bookmarks/bookmarks.js diff --git a/apps/content/src/bookmarks/bookmarks.ts b/apps/content/src/bookmarks/bookmarks.ts deleted file mode 100644 index ef5c124..0000000 --- a/apps/content/src/bookmarks/bookmarks.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import 'remixicon/fonts/remixicon.css' - -import '@shared/styles/window.css' - -import App from './Bookmarks.svelte' - -new App({ target: document.body }) diff --git a/apps/content/src/bookmarks/components/BookmarkEditor.svelte b/apps/content/src/bookmarks/components/BookmarkEditor.svelte deleted file mode 100644 index 97b55cd..0000000 --- a/apps/content/src/bookmarks/components/BookmarkEditor.svelte +++ /dev/null @@ -1,65 +0,0 @@ - - - - -
- Title - - {#if url} - URL - {/if} - - -
- - diff --git a/apps/content/src/bookmarks/components/BookmarkItem.svelte b/apps/content/src/bookmarks/components/BookmarkItem.svelte deleted file mode 100644 index 521f803..0000000 --- a/apps/content/src/bookmarks/components/BookmarkItem.svelte +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -
{ - opened = !opened - selectedBookmark = node.id - }} - aria-selected={selectedBookmark == node.id} -> -
-