-
-
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 @@
-
-
-
-
-
-
-
-
diff --git a/apps/content/src/browser/components/menus/HamburgerMenu/HamburgerMenuItem.svelte b/apps/content/src/browser/components/menus/HamburgerMenu/HamburgerMenuItem.svelte
deleted file mode 100644
index 51d2773..0000000
--- a/apps/content/src/browser/components/menus/HamburgerMenu/HamburgerMenuItem.svelte
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
diff --git a/apps/content/src/browser/components/menus/index.ts b/apps/content/src/browser/components/menus/index.ts
deleted file mode 100644
index 09cc653..0000000
--- a/apps/content/src/browser/components/menus/index.ts
+++ /dev/null
@@ -1,18 +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 BrowserContextMenu from './BrowserContextMenu.svelte'
-import HamburgerMenu from './HamburgerMenu/HamburgerMenu.svelte'
-
-/**
- * @param target The target element to open at
- * @param anchor Information about the anchor point {@link https://udn.realityripple.com/docs/Archive/Mozilla/XUL/PopupGuide/Positioning}
- */
-export const openHamburgerMenu = (target: HTMLElement, anchor: string) =>
- (document.getElementById('hamburgerMenu') as XULPanel | null)?.openPopup(
- target,
- anchor,
- )
-
-export { BrowserContextMenu, HamburgerMenu }
diff --git a/apps/content/src/browser/components/omnibox/Bookmarks.svelte b/apps/content/src/browser/components/omnibox/Bookmarks.svelte
deleted file mode 100644
index e9f9271..0000000
--- a/apps/content/src/browser/components/omnibox/Bookmarks.svelte
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-{/if}
-
-
diff --git a/apps/content/src/browser/components/tabs/tabDrag.ts b/apps/content/src/browser/components/tabs/tabDrag.ts
deleted file mode 100644
index 280b4f4..0000000
--- a/apps/content/src/browser/components/tabs/tabDrag.ts
+++ /dev/null
@@ -1,202 +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 { waitForEvent } from '@experiment/shared'
-import type { Action } from 'svelte/action'
-import { type Readable, type Writable, get, writable } from 'svelte/store'
-
-import { resource } from '@browser/lib/resources'
-import { spinLock } from '@browser/lib/spinlock'
-import type { Tab } from '@browser/lib/window/tab'
-import {
- ABOUT_BLANK,
- moveTabAfter,
- moveTabBefore,
- openTab,
-} from '@browser/lib/window/tabs'
-import { getWindowById } from '@browser/lib/window/window'
-
-/* eslint listeners/no-missing-remove-event-listener: 'error' */
-
-export const TAB_DATA_TYPE = 'experiment/tab'
-
-const dragOver = (
- tab: Tab,
- dropBefore: Writable,
- dropAfter: Writable,
-) => {
- let lastDragIsBefore: boolean | undefined
-
- return (event: DragEvent) => {
- const currentTarget = event.currentTarget as HTMLDivElement
- const rawDragRepresentation = event.dataTransfer?.getData(TAB_DATA_TYPE)
-
- if (!currentTarget.classList.contains('tab')) return
- if (!rawDragRepresentation) {
- console.warn('No drag representation')
- return
- }
-
- const { windowId, tabId } = JSON.parse(rawDragRepresentation) as ReturnType<
- Tab['getDragRepresentation']
- >
- const sameWindow = windowId === window.windowApi.id
-
- const boundingRect = currentTarget.getBoundingClientRect()
- const xMiddle = boundingRect.x + boundingRect.width / 2
- const isBefore = event.x <= xMiddle
-
- if ((tabId == tab.getId() && sameWindow) || lastDragIsBefore === isBefore)
- return
- lastDragIsBefore = isBefore
-
- // Trigger the drop handler
- if (event.dataTransfer) event.dataTransfer.dropEffect = 'move'
- event.preventDefault()
- event.stopPropagation()
-
- if (!sameWindow) {
- dropBefore.set(isBefore)
- dropAfter.set(!isBefore)
-
- return
- }
-
- dropBefore.set(false)
- dropAfter.set(false)
-
- if (isBefore) moveTabBefore(tabId, tab.getId())
- else moveTabAfter(tabId, tab.getId())
- }
-}
-
-const drop = async (event: DragEvent) => {
- const currentTarget = event.currentTarget as HTMLDivElement
- const rawDragRepresentation = event.dataTransfer?.getData(TAB_DATA_TYPE)
-
- if (!currentTarget.classList.contains('tab')) return
- if (!rawDragRepresentation) {
- console.warn('No drag representation')
- return
- }
-
- const { windowId, tabId } = JSON.parse(rawDragRepresentation) as ReturnType<
- Tab['getDragRepresentation']
- >
- const sameWindow = windowId === window.windowApi.id
-
- if (sameWindow) return
-
- event.preventDefault()
- event.stopPropagation()
-
- const toMoveWindow = getWindowById(windowId)
- if (!toMoveWindow) {
- console.warn('Window not found')
- return
- }
-
- const tabToMove = toMoveWindow.windowApi.tabs.getTabById(tabId)
- if (!tabToMove) {
- console.warn('Tab not found')
- return
- }
-
- // We need to do the following to change a tab between windows:
- // 1. Create a donor tab in our current window
- // 2. Wait for teh donor tab to finish initializing
- // 3. Perform a docshell swap with the donor tab
- // 4. Destroy the tab to move
- // 5. Show the donor tab
-
- const donorTab = openTab(ABOUT_BLANK)
- donorTab.hidden.set(true)
- await donorTab.goToUri(ABOUT_BLANK)
- await spinLock(() => !get(donorTab.loading))
-
- donorTab.swapWithTab(tabToMove)
- donorTab.hidden.set(false)
-
- toMoveWindow.windowApi.tabs.closeTab(tabToMove)
-}
-
-const dragEnd = (tabToMove: Tab) => async (event: DragEvent) => {
- if (event.dataTransfer?.dropEffect != 'none') return
-
- // The next window that is created is going to be for the new tab
- const newWindowPromise = waitForEvent(
- resource.WindowTracker.events,
- 'windowCreated',
- )
-
- // Create the new window
- window.windowApi.window.new({
- initialUrl: 'about:blank',
- })
-
- const newWindow = await newWindowPromise
- const donorTab = newWindow.windowApi.tabs.tabs[0]
- donorTab.hidden.set(true)
- await donorTab.goToUri(ABOUT_BLANK)
- await spinLock(() => !get(donorTab.loading))
-
- donorTab.swapWithTab(tabToMove)
- donorTab.hidden.set(false)
-
- window.windowApi.tabs.closeTab(tabToMove)
-}
-
-export function createTabDrag(tab: Tab) {
- const dropBefore = writable(false)
- const dropAfter = writable(false)
-
- const dragOverEvent = dragOver(tab, dropBefore, dropAfter)
- const setDataTransferEvent = async (event: DragEvent) => {
- event.dataTransfer?.setData(
- TAB_DATA_TYPE,
- JSON.stringify(tab.getDragRepresentation()),
- )
- const canvas = await tab.captureTabToCanvas()
- if (canvas) event.dataTransfer?.setDragImage(canvas, 0, 0)
- }
- const dragLeaveEvent = () => {
- dropBefore.set(false)
- dropAfter.set(false)
- }
- const preventDefault = (event: DragEvent) => event.preventDefault()
- const onDrop = drop
- const onDragEnd = dragEnd(tab)
-
- const tabDrag: Action = (node) => {
- const initialDraggable = node.draggable
- node.draggable = true
-
- node.addEventListener('dragstart', setDataTransferEvent)
- node.addEventListener('dragover', dragOverEvent)
- node.addEventListener('dragleave', dragLeaveEvent)
- node.addEventListener('drop', preventDefault)
- node.addEventListener('drop', onDrop)
- node.addEventListener('dragend', onDragEnd)
-
- return {
- destroy() {
- node.draggable = initialDraggable
-
- node.removeEventListener('dragstart', setDataTransferEvent)
- node.removeEventListener('dragover', dragOverEvent)
- node.removeEventListener('dragleave', dragLeaveEvent)
- node.removeEventListener('drop', preventDefault)
- node.removeEventListener('drop', onDrop)
- node.removeEventListener('dragend', onDragEnd)
- },
- }
- }
-
- return {
- tabDrag,
- drop: {
- before: dropBefore satisfies Readable,
- after: dropAfter satisfies Readable,
- },
- }
-}
diff --git a/apps/content/src/browser/lib/binaryEnums.ts b/apps/content/src/browser/lib/binaryEnums.ts
deleted file mode 100644
index 304bbc1..0000000
--- a/apps/content/src/browser/lib/binaryEnums.ts
+++ /dev/null
@@ -1,7 +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 { curry } from 'fnts'
-
-export const isBitSet = curry((bit: number, num: number) => (num & bit) !== 0)
-export const isBitSetFast = curry((bit: number, num: number) => num & bit)
diff --git a/apps/content/src/browser/lib/devtools.ts b/apps/content/src/browser/lib/devtools.ts
deleted file mode 100644
index 7b6eb6e..0000000
--- a/apps/content/src/browser/lib/devtools.ts
+++ /dev/null
@@ -1,13 +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/. */
-
-/* eslint-disable @typescript-eslint/no-explicit-any */
-
-const lazy: any = {}
-;(ChromeUtils as any).defineESModuleGetters(lazy, {
- BrowserToolboxLauncher:
- 'resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs',
-})
-
-export const initDevTools = lazy.BrowserToolboxLauncher.init
diff --git a/apps/content/src/browser/lib/fp.ts b/apps/content/src/browser/lib/fp.ts
deleted file mode 100644
index 1503470..0000000
--- a/apps/content/src/browser/lib/fp.ts
+++ /dev/null
@@ -1,34 +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/. */
-
-type ResultInner =
- | { _type: 'value'; inner: Value }
- | { _type: 'error'; inner: Error }
-export class Result {
- inner: ResultInner
-
- private constructor(inner: ResultInner) {
- this.inner = inner
- }
-
- static ok(value: V): Result {
- return new Result({ _type: 'value', inner: value })
- }
-
- static err(error: E): Result {
- return new Result({ _type: 'error', inner: error })
- }
-
- /**
- * Returns the value or throws the error if it exists. You should only use this in testing code
- * @deprecated
- */
- unwrap(): Value {
- if (this.inner._type === 'error') {
- throw this.inner.inner
- }
-
- return this.inner.inner
- }
-}
diff --git a/apps/content/src/browser/lib/keybinds.ts b/apps/content/src/browser/lib/keybinds.ts
deleted file mode 100644
index 1a4c3dc..0000000
--- a/apps/content/src/browser/lib/keybinds.ts
+++ /dev/null
@@ -1,159 +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 { Result } from './fp'
-
-export type ModifierType = (typeof modifiers)[number]
-const modifiers = ['shift', 'control', 'alt', 'meta', 'accel'] as const
-
-export type KeyCodeType = (typeof keycodes)[number]
-const keycodes = [
- 'VK_CANCEL',
- 'VK_BACK',
- 'VK_TAB',
- 'VK_CLEAR',
- 'VK_RETURN',
- 'VK_ENTER',
- 'VK_SHIFT',
- 'VK_CONTROL',
- 'VK_ALT',
- 'VK_PAUSE',
- 'VK_CAPS_LOCK',
- 'VK_ESCAPE',
- 'VK_SPACE',
- 'VK_PAGE_UP',
- 'VK_PAGE_DOWN',
- 'VK_END',
- 'VK_HOME',
- 'VK_LEFT',
- 'VK_UP',
- 'VK_RIGHT',
- 'VK_DOWN',
- 'VK_PRINTSCREEN',
- 'VK_INSERT',
- 'VK_DELETE',
- 'VK_0',
- 'VK_1',
- 'VK_2',
- 'VK_3',
- 'VK_4',
- 'VK_5',
- 'VK_6',
- 'VK_7',
- 'VK_8',
- 'VK_9',
- 'VK_SEMICOLON',
- 'VK_EQUALS',
- 'VK_A',
- 'VK_B',
- 'VK_C',
- 'VK_D',
- 'VK_E',
- 'VK_F',
- 'VK_G',
- 'VK_H',
- 'VK_I',
- 'VK_J',
- 'VK_K',
- 'VK_L',
- 'VK_M',
- 'VK_N',
- 'VK_O',
- 'VK_P',
- 'VK_Q',
- 'VK_R',
- 'VK_S',
- 'VK_T',
- 'VK_U',
- 'VK_V',
- 'VK_W',
- 'VK_X',
- 'VK_Y',
- 'VK_Z',
- 'VK_NUMPAD0',
- 'VK_NUMPAD1',
- 'VK_NUMPAD2',
- 'VK_NUMPAD3',
- 'VK_NUMPAD4',
- 'VK_NUMPAD5',
- 'VK_NUMPAD6',
- 'VK_NUMPAD7',
- 'VK_NUMPAD8',
- 'VK_NUMPAD9',
- 'VK_MULTIPLY',
- 'VK_ADD',
- 'VK_SEPARATOR',
- 'VK_SUBTRACT',
- 'VK_DECIMAL',
- 'VK_DIVIDE',
- 'VK_F1',
- 'VK_F2',
- 'VK_F3',
- 'VK_F4',
- 'VK_F5',
- 'VK_F6',
- 'VK_F7',
- 'VK_F8',
- 'VK_F9',
- 'VK_F10',
- 'VK_F11',
- 'VK_F12',
- 'VK_F13',
- 'VK_F14',
- 'VK_F15',
- 'VK_F16',
- 'VK_F17',
- 'VK_F18',
- 'VK_F19',
- 'VK_F20',
- 'VK_F21',
- 'VK_F22',
- 'VK_F23',
- 'VK_F24',
- 'VK_NUM_LOCK',
- 'VK_SCROLL_LOCK',
- 'VK_COMMA',
- 'VK_PERIOD',
- 'VK_SLASH',
- 'VK_BACK_QUOTE',
- 'VK_OPEN_BRACKET',
- 'VK_BACK_SLASH',
- 'VK_CLOSE_BRACKET',
- 'VK_QUOTE',
- 'VK_HELP',
-] as const
-
-export interface Keybind {
- modifiers: ModifierType[]
- key?: string
- keycode?: KeyCodeType
-}
-
-export type KeybindingParsingErrors = { error: 'invlidModifier'; value: string }
-
-export const keybindFromString = (
- str: string,
-): Result => {
- const items = str.split('+')
-
- const key = items.pop()
- const isKeyCode = keycodes.includes(key as KeyCodeType)
-
- // Validate all of the modifiers
- for (const modifier of items) {
- if (!modifiers.includes(modifier as ModifierType))
- return Result.err({ error: 'invlidModifier', value: modifier })
- }
-
- if (isKeyCode) {
- return Result.ok({
- modifiers: items as ModifierType[],
- keycode: key as KeyCodeType,
- })
- } else {
- return Result.ok({
- modifiers: items as ModifierType[],
- key,
- })
- }
-}
diff --git a/apps/content/src/browser/lib/modules/EPageActionsBindings.ts b/apps/content/src/browser/lib/modules/EPageActionsBindings.ts
deleted file mode 100644
index ff22c67..0000000
--- a/apps/content/src/browser/lib/modules/EPageActionsBindings.ts
+++ /dev/null
@@ -1,46 +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 { readable } from 'svelte/store'
-
-import type { PageActionImpl } from 'resource://app/modules/EPageActions.sys.mjs'
-
-import { resource } from '../resources'
-
-/**
- * @todo lazy loading store
- */
-export const pageActions = readable(
- [...resource.EPageActions.pageActions.entries()],
- (set) => {
- const update = () => set([...resource.EPageActions.pageActions.entries()])
- resource.EPageActions.events.on('*', update)
- return () => resource.EPageActions.events.off('*', update)
- },
-)
-
-export const pageActionIcons = (pageAction: PageActionImpl) =>
- readable | undefined>(pageAction.icons, (set) =>
- pageAction.events.on('updateIcon', set),
- )
-
-export function getIconUrlForPreferredSize(
- icon: Record,
- preferredSize: number,
-) {
- let bestSize
-
- if (icon[preferredSize]) {
- bestSize = preferredSize
- } else if (icon[preferredSize * 2]) {
- bestSize = preferredSize * 2
- } else {
- const sizes = Object.keys(icon)
- .map((key) => parseInt(key, 10))
- .sort((a, b) => a - b)
- bestSize =
- sizes.find((candidate) => candidate > preferredSize) || sizes.pop()!
- }
-
- return icon[bestSize]
-}
diff --git a/apps/content/src/browser/lib/resources.ts b/apps/content/src/browser/lib/resources.ts
deleted file mode 100644
index af87056..0000000
--- a/apps/content/src/browser/lib/resources.ts
+++ /dev/null
@@ -1,15 +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 { lazyESModuleGetters } from '../../shared/TypedImportUtilities'
-
-/*eslint sort-keys: "error"*/
-
-export const resource = lazyESModuleGetters({
- E10SUtils: 'resource://gre/modules/E10SUtils.sys.mjs',
- EPageActions: 'resource://app/modules/EPageActions.sys.mjs',
- NetUtil: 'resource://gre/modules/NetUtil.sys.mjs',
- PageThumbs: 'resource://gre/modules/PageThumbs.sys.mjs',
- WindowTracker: 'resource://app/modules/BrowserWindowTracker.sys.mjs',
- ZoomStore: 'resource://app/modules/ZoomStore.sys.mjs',
-})
diff --git a/apps/content/src/browser/lib/shortcuts.ts b/apps/content/src/browser/lib/shortcuts.ts
deleted file mode 100644
index 2fd74a3..0000000
--- a/apps/content/src/browser/lib/shortcuts.ts
+++ /dev/null
@@ -1,39 +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 { runOnCurrentTab } from './window/tabs'
-
-interface AppCommandEvent extends Event {
- command:
- | 'Back'
- | 'Forward'
- | 'Reload'
- | 'Stop'
- | 'Search'
- | 'Bookmarks'
- | 'Home'
- | 'New'
- | 'Close'
- | 'Find'
- | 'Help'
- | 'Open'
- | 'Print'
- | 'Save'
- | 'SendMail'
-}
-
-export function initializeShortcuts() {
- document.addEventListener('AppCommand', (untypedEvent) => {
- const event = untypedEvent as AppCommandEvent
- switch (event.command) {
- case 'Back':
- runOnCurrentTab((tab) => tab.goBack())
- break
- case 'Forward':
- runOnCurrentTab((tab) => tab.goForward())
- break
- default:
- console.warn('Unknown event', event)
- }
- })
-}
diff --git a/apps/content/src/browser/lib/spinlock.ts b/apps/content/src/browser/lib/spinlock.ts
deleted file mode 100644
index d805fc0..0000000
--- a/apps/content/src/browser/lib/spinlock.ts
+++ /dev/null
@@ -1,13 +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/. */
-
-export function sleep(duration: number): Promise {
- return new Promise((res) => setTimeout(res, duration))
-}
-
-export async function spinLock(predicate: () => boolean): Promise {
- while (!predicate()) {
- await sleep(1)
- }
-}
diff --git a/apps/content/src/browser/lib/window/api.ts b/apps/content/src/browser/lib/window/api.ts
deleted file mode 100644
index db784dd..0000000
--- a/apps/content/src/browser/lib/window/api.ts
+++ /dev/null
@@ -1,80 +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 mitt from 'mitt'
-
-import type { WindowArguments } from '.'
-import {
- browserContextMenuInfo,
- setContextMenuParentActor,
-} from './contextMenu'
-import {
- closeTab,
- getCurrentTab,
- getTabById,
- openTab,
- runOnCurrentTab,
- setCurrentTab,
- tabs,
-} from './tabs'
-import { id, setId } from './window'
-
-export const windowApi: WindowApi = {
- id,
-
- setId,
-
- windowTriggers: mitt(),
- window: {
- /**
- * @todo Move this into BrowserWindowTracker
- */
- new: (args?: WindowArguments) =>
- Services.ww.openWindow(
- // @ts-expect-error Incorrect type generation
- null,
- Services.prefs.getStringPref('app.content'),
- '_blank',
- 'chrome,dialog=no,all',
- args,
- ),
- },
- tabs: {
- closeTab,
- openTab,
- runOnCurrentTab,
- setCurrentTab,
- getCurrentTab,
- getTabById,
- get tabs() {
- return tabs.readOnce()
- },
- setIcon: (browser: XULBrowserElement, iconURL: string) =>
- tabs
- .readOnce()
- .find((tab) => tab.getTabId() == browser.browserId)
- ?.icon.set(iconURL),
- },
- contextMenu: {
- showContextMenu: (
- menuInfo: ContextMenuInfo,
- actor: JSWindowActorParent,
- ) => {
- browserContextMenuInfo.set(menuInfo)
- setContextMenuParentActor(actor)
-
- requestAnimationFrame(() => {
- const contextMenu = document.getElementById(
- 'browser_context_menu',
- ) as XULMenuPopup
- contextMenu.openPopupAtScreen(
- menuInfo.position.screenX,
- menuInfo.position.screenY,
- true,
- )
- })
- },
- },
-}
-
-window.windowApi = windowApi
diff --git a/apps/content/src/browser/lib/window/arguments.ts b/apps/content/src/browser/lib/window/arguments.ts
deleted file mode 100644
index 0c0fa4d..0000000
--- a/apps/content/src/browser/lib/window/arguments.ts
+++ /dev/null
@@ -1,30 +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/. */
-
-const defaultWindowConfiguration: WindowConfiguration = {
- initialUrl: Services.prefs.getStringPref(
- 'browser.newwindow.default',
- 'about:blank',
- ),
-}
-
-/**
- * These are the arguments that we want to pass between windows.
- */
-export type WindowArguments = Partial
-
-export function getFullWindowConfiguration(
- args: WindowArguments,
-): WindowConfiguration {
- return {
- ...defaultWindowConfiguration,
- ...args,
- }
-}
-
-export function nsISupportsWinArgs(
- args: WindowArguments,
-): WindowArguments & nsISupportsType {
- return args as unknown as WindowArguments & nsISupportsType
-}
diff --git a/apps/content/src/browser/lib/window/contextMenu.ts b/apps/content/src/browser/lib/window/contextMenu.ts
deleted file mode 100644
index 67ae667..0000000
--- a/apps/content/src/browser/lib/window/contextMenu.ts
+++ /dev/null
@@ -1,14 +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 { writable } from 'svelte/store'
-
-export let contextMenuParentActor: JSWindowActorParent
-export const browserContextMenuInfo = writable({
- position: { screenX: 0, screenY: 0, inputSource: 0 },
- context: {},
-})
-
-export function setContextMenuParentActor(actor: JSWindowActorParent) {
- contextMenuParentActor = actor
-}
diff --git a/apps/content/src/browser/lib/window/index.ts b/apps/content/src/browser/lib/window/index.ts
deleted file mode 100644
index 025bc9a..0000000
--- a/apps/content/src/browser/lib/window/index.ts
+++ /dev/null
@@ -1,6 +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/. */
-
-export * from './arguments'
-export * from './initialize'
diff --git a/apps/content/src/browser/lib/window/initialize.ts b/apps/content/src/browser/lib/window/initialize.ts
deleted file mode 100644
index 2ddbfc5..0000000
--- a/apps/content/src/browser/lib/window/initialize.ts
+++ /dev/null
@@ -1,30 +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 { resource } from '../resources'
-import { type WindowArguments, getFullWindowConfiguration } from './arguments'
-import { openTab } from './tabs'
-import {
- initializeWindowDragOverHandler,
- registerWithWindowTracker,
-} from './window'
-
-export function initializeWindow(args: WindowArguments | undefined) {
- // When opened via nsIWindowWatcher.openWindow, the arguments are
- // passed through C++, and they arrive to us wrapped as an XPCOM
- // object. We use wrappedJSObject to get at the underlying JS
- // object.
- // @ts-expect-error Incorrect type generation
- if (args instanceof Ci.nsISupports) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- args = (args as any).wrappedJSObject as WindowArguments
- }
-
- const configuration = getFullWindowConfiguration(args || {})
-
- // Setup tabs
- openTab(resource.NetUtil.newURI(configuration.initialUrl))
-
- initializeWindowDragOverHandler()
- registerWithWindowTracker()
-}
diff --git a/apps/content/src/browser/lib/window/tab.ts b/apps/content/src/browser/lib/window/tab.ts
deleted file mode 100644
index 8906a8a..0000000
--- a/apps/content/src/browser/lib/window/tab.ts
+++ /dev/null
@@ -1,465 +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 { type ViewableWritable, viewableWritable } from '@experiment/shared'
-import mitt from 'mitt'
-import { type Writable, get, writable } from 'svelte/store'
-
-import type { ZoomStoreEvents } from 'resource://app/modules/ZoomStore.sys.mjs'
-
-import { type BookmarkTreeNode, search } from '@shared/ExtBookmarkAPI'
-
-import { resource } from '../resources'
-import { spinLock } from '../spinlock'
-import { createBrowser, getBrowserRemoteType, setURI } from '../xul/browser'
-import { domContentLoaded } from '../xul/domevents'
-
-export const lastTabAction = { id: -1, before: false }
-
-let localTabId = 0
-
-/**
- * This provides a consistent internal representation of a tab, including the
- * browser elements it contains & information derived from listeners about its current state
- */
-export class Tab {
- private _id: number = ++localTabId
- private tabId: number | undefined
-
- private browserElement: XULBrowserElement
- private progressListener = new TabProgressListener()
-
- // Publicly available data. Even though these are writable, updating them will not change
- // the state of the browser element
- public title = writable('')
- public icon: ViewableWritable = viewableWritable(null)
- public uri: ViewableWritable
- public bookmarkInfo: Writable = writable(null)
-
- public findbar: ViewableWritable =
- viewableWritable(undefined)
-
- public canGoBack = writable(false)
- public canGoForward = writable(false)
-
- public loading = writable(false)
- public loadingProgress = writable(0)
-
- public zoom = writable(1)
-
- public focusedOmnibox = writable(true)
- public hidden = writable(false)
-
- constructor(uri: nsIURIType) {
- this.browserElement = createBrowser({
- remoteType: getBrowserRemoteType(uri),
- })
-
- this.uri = viewableWritable(uri)
- this.goToUri(uri)
- this.title.set(uri.asciiHost)
-
- this.zoom.subscribe((newZoom) => {
- if (
- !this.browserElement.browsingContext ||
- this.browserElement.fullZoom === newZoom
- ) {
- return
- }
-
- this.browserElement.fullZoom = newZoom
- resource.ZoomStore.setZoomForUri(this.uri.readOnce(), newZoom)
- })
- this.uri.subscribe(async (uri) =>
- this.bookmarkInfo.set(
- await search({ url: uri.spec }).then((r) =>
- r.length > 0 ? (r[0] as BookmarkTreeNode) : null,
- ),
- ),
- )
-
- // Remember to unsubscribe from any listeners you register here!
- resource.ZoomStore.events.on('setZoom', this.zoomChange)
- }
-
- public getId(): number {
- return this._id
- }
-
- /**
- * Gecko's internal tab/browser id. Note that this is not always ready on first render, so
- * you should use {@link this.getId()} for keys etc
- */
- public getTabId(): number {
- return this.tabId || 0
- }
-
- public getBrowserElement() {
- return this.browserElement
- }
-
- public getDragRepresentation() {
- return {
- windowId: window.windowApi.id,
- tabId: this.getId(),
- }
- }
-
- _initialized: Promise | undefined
- public get initialized() {
- if (this._initialized) return this._initialized
- // Force fetching the docshell
- this.browserElement.docShell
- return (this._initialized = spinLock(
- () => this.browserElement.mInitialized,
- ))
- }
-
- // ===========================================================================
- // Event listeners
-
- protected useEventListeners() {
- this.browserElement.addEventListener(
- 'pagetitlechanged',
- this.onPageTitleChanged.bind(this),
- )
-
- this.browserElement.addEventListener(
- 'DidChangeBrowserRemoteness',
- this.onDidChangeBrowserRemoteness.bind(this),
- )
-
- // Set up progress notifications. These are used for listening on location change etc
- this.progressListener.setup(this.browserElement)
- this.useProgressListener()
- }
-
- protected removeEventListeners() {
- this.browserElement.removeEventListener(
- 'pagetitlechanged',
- this.onPageTitleChanged.bind(this),
- )
- this.browserElement.removeEventListener(
- 'DidChangeBrowserRemoteness',
- this.onDidChangeBrowserRemoteness.bind(this),
- )
- }
-
- protected onPageTitleChanged() {
- this.title.set(this.browserElement.contentTitle)
- }
-
- protected onDidChangeBrowserRemoteness(e: Event) {
- const browser = e.target as XULBrowserElement
- // TODO: Does this leak memory?
- this.progressListener.remove(browser)
- this.progressListener = new TabProgressListener()
- this.progressListener.setup(browser)
- this.useProgressListener()
- }
-
- zoomChange = (event: ZoomStoreEvents['setZoom']) => {
- if (this.uri.readOnce().asciiHost != event.host) return
- this.zoom.set(event.zoom)
- }
-
- protected useProgressListener() {
- this.progressListener.events.on('locationChange', (event) => {
- if (!event.aWebProgress.isTopLevel) return
-
- const sameLocation =
- event.aFlags & 0x01 /* LOCATION_CHANGE_SAME_DOCUMENT */
- if (!sameLocation) {
- this.icon.set(null)
- }
-
- this.uri.set(event.aLocation)
- this.canGoBack.set(this.browserElement.canGoBack)
- this.canGoForward.set(this.browserElement.canGoForward)
-
- this.zoom.set(resource.ZoomStore.getZoomForUri(event.aLocation))
- })
-
- this.progressListener.events.on('progressPercent', this.loadingProgress.set)
- this.progressListener.events.on('loadingChange', this.loading.set)
- }
-
- public async setContainer(container: HTMLElement) {
- container.appendChild(this.browserElement)
- this.tabId = this.browserElement.browserId
-
- this.useEventListeners()
- }
-
- public async goToUri(uri: nsIURIType) {
- // Load the URI once we are sure that the dom has fully loaded
- await domContentLoaded.promise
- // Wait for browser to initialize
- await this.initialized
- setURI(this.browserElement, uri)
- }
-
- public destroy() {
- resource.ZoomStore.events.off('setZoom', this.zoomChange)
- this.browserElement.remove()
- }
-
- public goBack() {
- this.browserElement.goBack()
- }
-
- public goForward() {
- this.browserElement.goForward()
- }
-
- public reload() {
- this.browserElement.reload()
- }
-
- public showFindBar() {
- if (!this.browserElement) {
- throw new Error('Browser not initialized when adding findbar')
- }
-
- const findbar = this.findbar.readOnce()
- if (findbar) {
- findbar.onFindCommand()
- return
- }
-
- this.findbar.update(() => document.createXULElement('findbar'))
- }
-
- public async setupFindbar(
- container: HTMLElement,
- findbar: XULFindBarElement,
- ) {
- container.append(findbar)
-
- await new Promise((r) => requestAnimationFrame(r))
- findbar.browser = this.browserElement
- this.showFindBar()
- }
-
- public swapWithTab(tab: Tab) {
- this.removeEventListeners()
- tab.removeEventListeners()
-
- this.browserElement.swapDocShells(tab.browserElement)
-
- this.useEventListeners()
- tab.useEventListeners()
-
- if (this.browserElement.id) this.tabId = this.browserElement.browserId
- if (tab.browserElement.id) tab.tabId = tab.browserElement.browserId
-
- const otherTitle = get(tab.title)
- const otherIcon = get(tab.icon)
- const otherUri = get(tab.uri)
- const otherBookmarkInfo = get(tab.bookmarkInfo)
-
- tab.title.set(get(this.title))
- tab.icon.set(get(this.icon))
- tab.uri.set(get(this.uri))
- tab.bookmarkInfo.set(get(this.bookmarkInfo))
-
- this.title.set(otherTitle)
- this.icon.set(otherIcon)
- this.uri.set(otherUri)
- this.bookmarkInfo.set(otherBookmarkInfo)
-
- const thisFindbar = get(this.findbar)
- thisFindbar?.remove()
- this.findbar.set(undefined)
-
- const otherFindbar = get(tab.findbar)
- otherFindbar?.remove()
- tab.findbar.set(undefined)
- }
-
- public async captureTabToCanvas(
- canvas: HTMLCanvasElement | null = resource.PageThumbs.createCanvas(window),
- ) {
- try {
- await resource.PageThumbs.captureToCanvas(
- this.browserElement,
- canvas,
- undefined,
- )
- } catch (e) {
- console.error(e)
- canvas = null
- }
-
- return canvas
- }
-}
-
-type TabProgressListenerEventDefaults = {
- aWebProgress: nsIWebProgressType
- aRequest: nsIRequestType
- id: number
-}
-
-type TabProgressListenerEvent = {
- locationChange: {
- aLocation: nsIURIType
- aFlags: number
- } & TabProgressListenerEventDefaults
- progressPercent: number
- loadingChange: boolean
-}
-
-/* eslint-disable @typescript-eslint/no-unused-vars */
-
-let progressListenerCounter = 0
-class TabProgressListener
- implements
- Partial,
- Partial
-{
- id = progressListenerCounter++
-
- events = mitt()
- browser: XULBrowserElement | undefined
-
- filter: (nsIWebProgressListenerType & nsIWebProgressType) | undefined
-
- setup(browser: XULBrowserElement) {
- this.browser = browser
-
- this.filter = Cc[
- '@mozilla.org/appshell/component/browser-status-filter;1'
- ].createInstance(Ci.nsIWebProgress) as nsIWebProgressListenerType &
- nsIWebProgressType
- this.filter.addProgressListener(
- this as unknown as nsIWebProgressListenerType,
- Ci.nsIWebProgress.NOTIFY_ALL,
- )
- browser.webProgress.addProgressListener(
- this.filter,
- Ci.nsIWebProgress.NOTIFY_ALL,
- )
- }
-
- remove(browser: XULBrowserElement) {
- browser.webProgress.removeProgressListener(
- this.filter as nsIWebProgressListenerType,
- )
- // @ts-expect-error Incorrect type generation
- this.filter?.removeProgressListener(this)
-
- this.filter = undefined
- }
-
- /**
- * This request is identical to {@link onProgressChange64}. The only
- * difference is that the c++ impl uses `long long`s instead of `long`s
- */
- onProgressChange64(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aCurSelfProgress: number,
- aMaxSelfProgress: number,
- aCurTotalProgress: number,
- aMaxTotalProgress: number,
- ): void {
- return this.onProgressChange(
- aWebProgress,
- aRequest,
- aCurSelfProgress,
- aMaxSelfProgress,
- aCurTotalProgress,
- aMaxTotalProgress,
- )
- }
-
- onRefreshAttempted(
- _aWebProgress: nsIWebProgressType,
- _aRefreshURI: nsIURIType,
- _aMillis: number,
- _aSameURI: boolean,
- ): boolean {
- // TODO: There is special functionality that should probibly go here
- return true
- }
- onStateChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aStateFlags: number,
- aStatus: number,
- ): void {
- if (!aWebProgress.isTopLevel) return
- if (
- aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
- aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK
- ) {
- this.events.emit('loadingChange', true)
- }
-
- if (
- aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
- aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK
- ) {
- this.events.emit('loadingChange', false)
- }
- }
-
- onProgressChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aCurSelfProgress: number,
- aMaxSelfProgress: number,
- aCurTotalProgress: number,
- aMaxTotalProgress: number,
- ): void {
- if (!aWebProgress || !aWebProgress.isTopLevel) return
- this.events.emit(
- 'progressPercent',
- aMaxTotalProgress !== 0 ? aCurTotalProgress / aMaxTotalProgress : 0,
- )
- }
-
- onLocationChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aLocation: nsIURIType,
- aFlags: number,
- ): void {
- this.events.emit('locationChange', {
- aWebProgress,
- aRequest,
- aLocation,
- aFlags,
- id: this.id,
- })
- }
- onStatusChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aStatus: number,
- aMessage: string,
- ): void {
- // console.log('onStatusChange')
- }
- onSecurityChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aState: number,
- ): void {
- // console.log('onSecurityChange')
- }
- onContentBlockingEvent(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aEvent: number,
- ): void {
- // console.log('onContentBlockingEvent')
- }
-
- QueryInterface = ChromeUtils.generateQI([
- 'nsIWebProgressListener',
- 'nsIWebProgressListener2',
- 'nsISupportsWeakReference',
- ])
-}
diff --git a/apps/content/src/browser/lib/window/tabs.ts b/apps/content/src/browser/lib/window/tabs.ts
deleted file mode 100644
index de8b9d7..0000000
--- a/apps/content/src/browser/lib/window/tabs.ts
+++ /dev/null
@@ -1,126 +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 { Ring, not, viewableWritable } from '@experiment/shared'
-
-import { resource } from '../resources'
-import { Tab } from './tab'
-
-const tabHistory = new Ring(10)
-export const selectedTabId = viewableWritable(-1)
-selectedTabId.subscribe((id) => tabHistory.next(id))
-
-const uriPref = (pref: string) => (): nsIURIType =>
- resource.NetUtil.newURI(Services.prefs.getStringPref(pref, 'about:blank'))
-const newTabUri = uriPref('browser.newtab.default')
-export const ABOUT_BLANK = resource.NetUtil.newURI('about:blank')
-
-export const tabs = viewableWritable([])
-
-const matchTab = (id: number) => (tab: Tab) => tab.getId() === id
-
-export function openTab(uri: nsIURIType = newTabUri()) {
- const newTab = new Tab(uri)
-
- // We only want to focus the omnibox on new tab pages
- if (uri.asciiSpec != newTabUri().asciiSpec) {
- newTab.focusedOmnibox.set(false)
- }
-
- tabs.update((tabs) => {
- selectedTabId.set(newTab.getId())
- return [...tabs, newTab]
- })
- return newTab
-}
-
-export function closeTab(tab: Tab) {
- tabs.update((tabs) => {
- const tabIndex = tabs.findIndex(matchTab(tab.getId()))
- const filtered = tabs.filter(not(matchTab(tab.getId())))
-
- if (filtered.length == 0) {
- window.close()
- return []
- }
-
- const lastTabId = tabHistory.prev()
- const hasLastTab = filtered.some(matchTab(lastTabId))
- if (hasLastTab) {
- selectedTabId.set(lastTabId)
- } else {
- if (filtered[tabIndex]) {
- selectedTabId.set(filtered[tabIndex].getId())
- } else {
- selectedTabId.set(filtered[tabIndex - 1].getId())
- }
- }
-
- tab.destroy()
- return filtered
- })
-}
-
-export function getTabById(id: number): Tab | undefined {
- return tabs.readOnce().find(matchTab(id))
-}
-
-export function getCurrentTab(): Tab | undefined {
- return getTabById(selectedTabId.readOnce())
-}
-
-export function setCurrentTab(tab: Tab) {
- const index = tabs.readOnce().findIndex(matchTab(tab.getId()))
- setCurrentTabIndex(index)
-}
-
-export function runOnCurrentTab(method: (tab: Tab) => R): R | undefined {
- const currentTab = getCurrentTab()
- if (currentTab) return method(currentTab)
-}
-
-export function getCurrentTabIndex(): number {
- return tabs.readOnce().findIndex(matchTab(selectedTabId.readOnce()))
-}
-
-export function setCurrentTabIndex(index: number) {
- const allTabs = tabs.readOnce()
-
- // Wrap the index
- if (index < 0) index = allTabs.length - 1
- if (index >= allTabs.length) index = 0
-
- const tabId = allTabs[index].getId()
- selectedTabId.set(tabId)
-}
-
-export function moveTabBefore(toMoveId: number, targetId: number) {
- tabs.update((tabs) => {
- const toMoveIndex = tabs.findIndex(matchTab(toMoveId))
- const targetIndex = Math.max(tabs.findIndex(matchTab(targetId)) - 1, 0)
-
- // If we do in-place modifications with tabs, svelte won't notice the
- // change
- const newTabs = [...tabs]
- insertAndShift(newTabs, toMoveIndex, targetIndex)
- return newTabs
- })
-}
-
-export function moveTabAfter(toMoveId: number, targetId: number) {
- tabs.update((tabs) => {
- const toMoveIndex = tabs.findIndex(matchTab(toMoveId))
- const targetIndex = tabs.findIndex(matchTab(targetId))
-
- // If we do in-place modifications with tabs, svelte won't notice the
- // change
- const newTabs = [...tabs]
- insertAndShift(newTabs, toMoveIndex, targetIndex)
- return newTabs
- })
-}
-
-function insertAndShift(arr: T[], from: number, to: number) {
- const cutOut = arr.splice(from, 1)[0]
- arr.splice(to, 0, cutOut)
-}
diff --git a/apps/content/src/browser/lib/window/window.ts b/apps/content/src/browser/lib/window/window.ts
deleted file mode 100644
index fe69bf9..0000000
--- a/apps/content/src/browser/lib/window/window.ts
+++ /dev/null
@@ -1,47 +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 { TAB_DATA_TYPE } from '@browser/components/tabs/tabDrag'
-
-import { resource } from '../resources'
-
-export let id = -1
-export const setId = (newId: number) => (id = newId)
-
-export const getWindowById = (id: number) =>
- resource.WindowTracker.getWindowById(id)
-
-/**
- * If we want to detect drops outside of the window, we need to ensure that all
- * drops **within** a browser window are handled.
- *
- * This listens for all events with a type equivalent to {@link TAB_DATA_TYPE}
- * and makes sure they have an attached drop type.
- */
-export function initializeWindowDragOverHandler() {
- const handleDragEvent = (event: DragEvent) => {
- const rawDragRepresentation = event.dataTransfer?.getData(TAB_DATA_TYPE)
- if (!rawDragRepresentation) return
-
- // Set this to some drop event other than 'none' so we can detect drops
- // outside of the window in the tab's drag handler
- if (event.dataTransfer) event.dataTransfer.dropEffect = 'link'
- event.preventDefault()
- }
-
- window.addEventListener('dragover', handleDragEvent)
- window.addEventListener('drop', handleDragEvent)
-}
-
-/**
- * Ensures that the window tracker is aware of this window & that when it is
- * closed, the correct cleanup is performed.
- */
-export function registerWithWindowTracker() {
- resource.WindowTracker.registerWindow(window)
- window.addEventListener('unload', () =>
- resource.WindowTracker.removeWindow(window),
- )
-
- window.addEventListener('focus', () => resource.WindowTracker.focusWindow(id))
-}
diff --git a/apps/content/src/browser/lib/xul/NSBrowserAccess.ts b/apps/content/src/browser/lib/xul/NSBrowserAccess.ts
deleted file mode 100644
index 201f9e1..0000000
--- a/apps/content/src/browser/lib/xul/NSBrowserAccess.ts
+++ /dev/null
@@ -1,78 +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/. */
-
-/* eslint-disable @typescript-eslint/no-unused-vars */
-
-export enum OpenWhere {
- DefaultWindow = 0,
- CurrentWindow = 1,
- NewWindow = 2,
- NewTab = 3,
- PrintBrowser = 4,
-}
-
-export enum OpenFlags {
- New = 0x0,
- /** Open was triggered by a thirdparty application */
- External = 0x1,
- NoOpener = 0x4,
- NoReferer = 0x8,
-}
-
-export class NSBrowserAccess {
- createContentWindow(
- aURI: nsIURIType,
- aOpenWindowInfo: nsIOpenWindowInfoType,
- aWhere: number,
- aFlags: number,
- aTriggeringPrincipal: nsIPrincipalType,
- aCsp: nsIContentSecurityPolicyType,
- ) {
- throw new Error('Method not implemented.')
- }
-
- createContentWindowInFrame(
- aURI: nsIURIType,
- params: nsIOpenURIInFrameParamsType,
- aWhere: number,
- ): Element | null {
- if (aWhere !== OpenWhere.NewTab) {
- console.warn('NSBrowserAccess: Only OpenWhere.NewTab is supported')
- return null
- }
-
- // TODO: Handle params
- // TODO: Handle unhandled arguments (see nsIBrowserDOMWindow)
- const tab = window.windowApi.tabs.openTab(aURI)
- const browser = tab.getBrowserElement()
- return browser
- }
-
- openURI(
- aURI: nsIURIType,
- aOpenWindowInfo: nsIOpenWindowInfoType,
- aWhere: number,
- aFlags: number,
- aTriggeringPrincipal: nsIPrincipalType,
- aCsp: nsIContentSecurityPolicyType,
- ) {
- throw new Error('Method not implemented.')
- }
- openURIInFrame(
- aURI: nsIURIType,
- params: nsIOpenURIInFrameParamsType,
- aWhere: number,
- aFlags: number,
- aName: string,
- ): Element {
- throw new Error('Method not implemented.')
- }
- canClose(): boolean {
- // TODO: Logic
- return true
- }
- tabCount: number = 0
-
- QueryInterface = ChromeUtils.generateQI(['nsIBrowserDOMWindow'])
-}
diff --git a/apps/content/src/browser/lib/xul/XULBrowserWindow.ts b/apps/content/src/browser/lib/xul/XULBrowserWindow.ts
deleted file mode 100644
index 30c87d1..0000000
--- a/apps/content/src/browser/lib/xul/XULBrowserWindow.ts
+++ /dev/null
@@ -1,109 +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/. */
-
-/* eslint-disable @typescript-eslint/no-unused-vars */
-
-export class XULBrowserWindow {
- QueryInterface = ChromeUtils.generateQI([
- 'nsIWebProgressListener',
- 'nsIWebProgressListener2',
- 'nsISupportsWeakReference',
- 'nsIXULBrowserWindow',
- ])
-
- setOverLink(link: string): void {
- // TODO: Do something with information about link hover
- }
- onBeforeLinkTraversal(
- originalTarget: string,
- linkURI: nsIURIType,
- linkNode: Node,
- isAppTab: boolean,
- ): string {
- throw new Error('Method not implemented.')
- }
- showTooltip(
- x: number,
- y: number,
- tooltip: string,
- direction: string,
- browser: Element,
- ): void {
- // TODO: Implement link tooltips
- }
- hideTooltip(): void {
- // TODO: Implment link tooltips
- }
- getTabCount() {
- throw new Error('Method not implemented.')
- }
- onProgressChange64(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aCurSelfProgress: number,
- aMaxSelfProgress: number,
- aCurTotalProgress: number,
- aMaxTotalProgress: number,
- ): void {
- throw new Error('Method not implemented.')
- }
- onRefreshAttempted(
- aWebProgress: nsIWebProgressType,
- aRefreshURI: nsIURIType,
- aMillis: number,
- aSameURI: boolean,
- ): boolean {
- throw new Error('Method not implemented.')
- }
- onStateChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aStateFlags: number,
- aStatus: number,
- ): void {
- throw new Error('Method not implemented.')
- }
- onProgressChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aCurSelfProgress: number,
- aMaxSelfProgress: number,
- aCurTotalProgress: number,
- aMaxTotalProgress: number,
- ): void {
- throw new Error('Method not implemented.')
- }
- onLocationChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aLocation: nsIURIType,
- aFlags: number,
- ): void {
- throw new Error('Method not implemented.')
- }
- onStatusChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aStatus: number,
- aMessage: string,
- ): void {
- throw new Error('Method not implemented.')
- }
- onSecurityChange(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aState: number,
- ): void {
- throw new Error('Method not implemented.')
- }
- onContentBlockingEvent(
- aWebProgress: nsIWebProgressType,
- aRequest: nsIRequestType,
- aEvent: number,
- ): void {
- throw new Error('Method not implemented.')
- }
-}
-
-export const globalXULBrowserWindow = new XULBrowserWindow()
diff --git a/apps/content/src/browser/lib/xul/browser.ts b/apps/content/src/browser/lib/xul/browser.ts
deleted file mode 100644
index d2b05f0..0000000
--- a/apps/content/src/browser/lib/xul/browser.ts
+++ /dev/null
@@ -1,73 +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 { resource } from '../resources'
-
-const { useRemoteTabs, useRemoteSubframe } = window.docShell.QueryInterface(
- Ci.nsILoadContext,
-)
-
-const DEFAULT_BROWSER_ATTRIBUTES = {
- message: 'true',
- messagemanagergroup: 'browsers',
- type: 'content',
- contextmenu: 'browser_context_menu',
-} as const
-
-export function setURI(browser: XULBrowserElement, uri: nsIURIType) {
- browser.source = uri.spec
- try {
- browser.loadURI(uri, {
- triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
- // remoteTypeOverride: getBrowserRemoteType(uri),
- })
- } catch (e) {
- console.log(browser, uri)
- console.error(e)
- }
-}
-
-export function getBrowserRemoteType(uri: nsIURIType) {
- const oa = resource.E10SUtils.predictOriginAttributes({ window })
- return resource.E10SUtils.getRemoteTypeForURI(
- uri.spec,
- useRemoteTabs,
- useRemoteSubframe,
- resource.E10SUtils.DEFAULT_REMOTE_TYPE,
- uri,
- oa,
- )
-}
-
-export function createBrowser({
- remoteType,
- attributes,
-}: {
- remoteType?: string
- attributes?: {
- disableglobalhistory?: string
- messagemanagergroup?: string
- ['webextension-view-type']?: string
- }
-} = {}): XULBrowserElement {
- const browser = document.createXULElement('browser')
- if (remoteType) {
- browser.setAttribute('remoteType', remoteType)
- browser.setAttribute('remote', true)
- }
-
- const mergedAttributes = {
- ...DEFAULT_BROWSER_ATTRIBUTES,
- ...(attributes || {}),
- }
-
- for (const attribute in mergedAttributes)
- browser.setAttribute(
- attribute,
- mergedAttributes[attribute as keyof typeof mergedAttributes],
- )
-
- if (useRemoteTabs) browser.setAttribute('maychangeremoteness', 'true')
-
- return browser
-}
diff --git a/apps/content/src/browser/lib/xul/ccWrapper.ts b/apps/content/src/browser/lib/xul/ccWrapper.ts
deleted file mode 100644
index 242f348..0000000
--- a/apps/content/src/browser/lib/xul/ccWrapper.ts
+++ /dev/null
@@ -1,11 +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/. */
-
-/* eslint-disable @typescript-eslint/no-explicit-any */
-
-export function getClipboardHelper(): nsIClipboardHelperType {
- return (Cc['@mozilla.org/widget/clipboardhelper;1'] as any).getService(
- Ci.nsIClipboardHelper,
- )
-}
diff --git a/apps/content/src/browser/lib/xul/domevents.ts b/apps/content/src/browser/lib/xul/domevents.ts
deleted file mode 100644
index 9ac030b..0000000
--- a/apps/content/src/browser/lib/xul/domevents.ts
+++ /dev/null
@@ -1,25 +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 { Deferred } from '@experiment/shared'
-
-import { NSBrowserAccess } from './NSBrowserAccess'
-import { globalXULBrowserWindow } from './XULBrowserWindow'
-
-export const domContentLoaded: Deferred = new Deferred()
-window.addEventListener(
- 'load',
- () => {
- // This code needs to be run before the first remote browser is created
- window.docShell.treeOwner
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIAppWindow).XULBrowserWindow = globalXULBrowserWindow
- window.browserDOMWindow =
- new NSBrowserAccess() as unknown as nsIBrowserDOMWindowType
-
- domContentLoaded.resolve && domContentLoaded.resolve(null)
- },
- {
- once: true,
- },
-)
diff --git a/apps/content/src/credits/credits.ts b/apps/content/src/credits/credits.js
similarity index 88%
rename from apps/content/src/credits/credits.ts
rename to apps/content/src/credits/credits.js
index cf28646..9b19a18 100644
--- a/apps/content/src/credits/credits.ts
+++ b/apps/content/src/credits/credits.js
@@ -1,8 +1,6 @@
/* 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 '@shared/styles/global.css'
-
import Credits from './Credits.svelte'
new Credits({ target: document.body })
diff --git a/apps/content/src/history/History.svelte b/apps/content/src/history/History.svelte
deleted file mode 100644
index 5faef98..0000000
--- a/apps/content/src/history/History.svelte
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- {#if $model.root}
-
- {#each children as child}
-
- {/each}
-
- {/if}
-
-
-
diff --git a/apps/content/src/history/component/Entry.svelte b/apps/content/src/history/component/Entry.svelte
deleted file mode 100644
index 03f31d7..0000000
--- a/apps/content/src/history/component/Entry.svelte
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/apps/content/src/history/component/HistoryContainerNode.svelte b/apps/content/src/history/component/HistoryContainerNode.svelte
deleted file mode 100644
index 6f71ff2..0000000
--- a/apps/content/src/history/component/HistoryContainerNode.svelte
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
- {#if open}
-
- {:else}
-
- {/if}
-
-
-
- {#if open}
- {#each children as node}
-
- {/each}
- {/if}
-
-
-
-
diff --git a/apps/content/src/history/component/HistoryItemNode.svelte b/apps/content/src/history/component/HistoryItemNode.svelte
deleted file mode 100644
index e240430..0000000
--- a/apps/content/src/history/component/HistoryItemNode.svelte
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
diff --git a/apps/content/src/history/component/HistoryNode.svelte b/apps/content/src/history/component/HistoryNode.svelte
deleted file mode 100644
index f04f6a0..0000000
--- a/apps/content/src/history/component/HistoryNode.svelte
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-{#if isContainer}
-
-{:else}
-
-{/if}
diff --git a/apps/content/src/settings/settings.css b/apps/content/src/history/history.js
similarity index 84%
rename from apps/content/src/settings/settings.css
rename to apps/content/src/history/history.js
index d20f0d3..e003224 100644
--- a/apps/content/src/settings/settings.css
+++ b/apps/content/src/history/history.js
@@ -1,7 +1,3 @@
/* 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/. */
-
-html {
- scroll-behavior: smooth;
-}
diff --git a/apps/content/src/history/history.ts b/apps/content/src/history/history.ts
deleted file mode 100644
index ccf360b..0000000
--- a/apps/content/src/history/history.ts
+++ /dev/null
@@ -1,12 +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 History from './History.svelte'
-
-new History({
- target: document.body,
-})
diff --git a/apps/content/src/settings/Settings.svelte b/apps/content/src/settings/Settings.svelte
deleted file mode 100644
index 549c11a..0000000
--- a/apps/content/src/settings/Settings.svelte
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-
-
-
-
- Window page
- New tab page
-
-
-
-
-
- {#await searchEngines then searchEngines}
- ({
- value: engine._extensionID,
- label: engine._name,
- icon: engine.iconURI.spec,
- }))}
- pref={SEARCH_ENGINE_PREF}
- defaultValue={DEFAULT_SEARCH_ENGINE}>Default search engine
- {/await}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Open browser toolbox
-
-
- Reload browser chrome
-
-
-
-
- New Window
- New Tab
- Refresh Tab
- Close Active Tab
- Next tab
- Previous Tab
-
- Zoom in
- Zoom out
- Reset Zoom
-
- {#each [1, 2, 3, 4, 5, 6, 7, 8] as tabNum}
- Jump to tab {tabNum}
- {/each}
- Find In Page
-
-
-
-
-
-
-
-
diff --git a/apps/content/src/settings/components/pref/ContextMenuPref/index.ts b/apps/content/src/settings/components/pref/ContextMenuPref/index.ts
deleted file mode 100644
index f47c7be..0000000
--- a/apps/content/src/settings/components/pref/ContextMenuPref/index.ts
+++ /dev/null
@@ -1,7 +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 ContextMenuPref from './ContextMenuPref.svelte'
-
-export { ContextMenuPref }
diff --git a/apps/content/src/settings/components/pref/ContextMenuPref/prefWrapper.ts b/apps/content/src/settings/components/pref/ContextMenuPref/prefWrapper.ts
deleted file mode 100644
index 5f12630..0000000
--- a/apps/content/src/settings/components/pref/ContextMenuPref/prefWrapper.ts
+++ /dev/null
@@ -1,22 +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 { writable } from 'svelte/store'
-
-import { type MenuItem, fromIdString, toIdString } from '@shared/contextMenus'
-
-export function contextMenuPrefWrapper(pref: string) {
- const store = writable