wxt 0.18.14 → 0.19.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/wxt.mjs +1 -1
- package/dist/browser/chrome.d.ts +17 -0
- package/dist/browser/chrome.mjs +7 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.mjs +1 -0
- package/dist/browser/webextension-polyfill.d.ts +18 -0
- package/dist/browser/webextension-polyfill.mjs +2 -0
- package/dist/builtin-modules/index.d.ts +2 -0
- package/dist/builtin-modules/index.mjs +2 -0
- package/dist/builtin-modules/unimport.d.ts +8 -0
- package/dist/builtin-modules/unimport.mjs +99 -0
- package/dist/cli/cli-utils.d.ts +25 -0
- package/dist/cli/cli-utils.mjs +58 -0
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.mjs +11 -0
- package/dist/client/app-config.d.ts +2 -0
- package/dist/client/app-config.mjs +4 -0
- package/dist/client/content-scripts/content-script-context.d.ts +114 -0
- package/dist/client/content-scripts/content-script-context.mjs +169 -0
- package/dist/client/content-scripts/custom-events.d.ts +10 -0
- package/dist/client/content-scripts/custom-events.mjs +13 -0
- package/dist/client/content-scripts/index.d.ts +2 -0
- package/dist/client/content-scripts/index.mjs +2 -0
- package/dist/client/content-scripts/location-watcher.d.ts +12 -0
- package/dist/client/content-scripts/location-watcher.mjs +22 -0
- package/dist/client/content-scripts/ui/index.d.ts +23 -0
- package/dist/client/content-scripts/ui/index.mjs +188 -0
- package/dist/{client.d.ts → client/content-scripts/ui/types.d.ts} +15 -43
- package/dist/client/content-scripts/ui/types.mjs +0 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.mjs +2 -0
- package/dist/core/build.d.ts +15 -0
- package/dist/core/build.mjs +6 -0
- package/dist/core/builders/vite/index.d.ts +3 -0
- package/dist/core/builders/vite/index.mjs +297 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +7 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +15 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +13 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +22 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +14 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +13 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +7 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +140 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -0
- package/dist/core/builders/vite/plugins/download.d.ts +10 -0
- package/dist/core/builders/vite/plugins/download.mjs +14 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +16 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +11 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +26 -0
- package/dist/core/builders/vite/plugins/globals.d.ts +3 -0
- package/dist/core/builders/vite/plugins/globals.mjs +15 -0
- package/dist/core/builders/vite/plugins/index.d.ts +17 -0
- package/dist/core/builders/vite/plugins/index.mjs +17 -0
- package/dist/core/builders/vite/plugins/multipageMove.d.ts +20 -0
- package/dist/core/builders/vite/plugins/multipageMove.mjs +59 -0
- package/dist/core/builders/vite/plugins/noopBackground.d.ts +6 -0
- package/dist/core/builders/vite/plugins/noopBackground.mjs +17 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +6 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +12 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +10 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +15 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +30 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +3 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +12 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +6 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +56 -0
- package/dist/core/clean.d.ts +21 -0
- package/dist/core/clean.mjs +38 -0
- package/dist/core/create-server.d.ts +11 -0
- package/dist/core/create-server.mjs +206 -0
- package/dist/core/define-config.d.ts +2 -0
- package/dist/core/define-config.mjs +3 -0
- package/dist/core/define-runner-config.d.ts +2 -0
- package/dist/core/define-runner-config.mjs +3 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.mjs +8 -0
- package/dist/core/initialize.d.ts +5 -0
- package/dist/core/initialize.mjs +128 -0
- package/dist/core/package-managers/bun.d.ts +2 -0
- package/dist/core/package-managers/bun.mjs +19 -0
- package/dist/core/package-managers/index.d.ts +2 -0
- package/dist/core/package-managers/index.mjs +65 -0
- package/dist/core/package-managers/npm.d.ts +17 -0
- package/dist/core/package-managers/npm.mjs +58 -0
- package/dist/core/package-managers/pnpm.d.ts +2 -0
- package/dist/core/package-managers/pnpm.mjs +21 -0
- package/dist/core/package-managers/types.d.ts +2 -0
- package/dist/core/package-managers/types.mjs +0 -0
- package/dist/core/package-managers/yarn.d.ts +2 -0
- package/dist/core/package-managers/yarn.mjs +31 -0
- package/dist/core/prepare.d.ts +2 -0
- package/dist/core/prepare.mjs +8 -0
- package/dist/core/runners/index.d.ts +2 -0
- package/dist/core/runners/index.mjs +12 -0
- package/dist/core/runners/manual.d.ts +5 -0
- package/dist/core/runners/manual.mjs +16 -0
- package/dist/core/runners/safari.d.ts +5 -0
- package/dist/core/runners/safari.mjs +16 -0
- package/dist/core/runners/web-ext.d.ts +5 -0
- package/dist/core/runners/web-ext.mjs +78 -0
- package/dist/core/runners/wsl.d.ts +5 -0
- package/dist/core/runners/wsl.mjs +16 -0
- package/dist/core/utils/arrays.d.ts +13 -0
- package/dist/{chunk-BERPNPEZ.js → core/utils/arrays.mjs} +6 -10
- package/dist/core/utils/building/build-entrypoints.d.ts +3 -0
- package/dist/core/utils/building/build-entrypoints.mjs +47 -0
- package/dist/core/utils/building/detect-dev-changes.d.ts +57 -0
- package/dist/core/utils/building/detect-dev-changes.mjs +93 -0
- package/dist/core/utils/building/find-entrypoints.d.ts +5 -0
- package/dist/core/utils/building/find-entrypoints.mjs +385 -0
- package/dist/core/utils/building/generate-wxt-dir.d.ts +5 -0
- package/dist/core/utils/building/generate-wxt-dir.mjs +190 -0
- package/dist/core/utils/building/group-entrypoints.d.ts +8 -0
- package/dist/core/utils/building/group-entrypoints.mjs +37 -0
- package/dist/core/utils/building/import-entrypoint.d.ts +16 -0
- package/dist/core/utils/building/import-entrypoint.mjs +97 -0
- package/dist/core/utils/building/index.d.ts +9 -0
- package/dist/core/utils/building/index.mjs +9 -0
- package/dist/core/utils/building/internal-build.d.ts +12 -0
- package/dist/core/utils/building/internal-build.mjs +112 -0
- package/dist/core/utils/building/rebuild.d.ts +23 -0
- package/dist/core/utils/building/rebuild.mjs +39 -0
- package/dist/core/utils/building/resolve-config.d.ts +11 -0
- package/dist/core/utils/building/resolve-config.mjs +365 -0
- package/dist/core/utils/cache.d.ts +8 -0
- package/dist/core/utils/cache.mjs +21 -0
- package/dist/core/utils/cli.d.ts +3 -0
- package/dist/core/utils/cli.mjs +26 -0
- package/dist/core/utils/constants.d.ts +5 -0
- package/dist/core/utils/constants.mjs +1 -0
- package/dist/core/utils/content-scripts.d.ts +11 -0
- package/dist/core/utils/content-scripts.mjs +60 -0
- package/dist/core/utils/content-security-policy.d.ts +14 -0
- package/dist/core/utils/content-security-policy.mjs +39 -0
- package/dist/core/utils/entrypoints.d.ts +25 -0
- package/dist/core/utils/entrypoints.mjs +31 -0
- package/dist/core/utils/eslint.d.ts +1 -0
- package/dist/core/utils/eslint.mjs +11 -0
- package/dist/core/utils/fs.d.ts +13 -0
- package/dist/core/utils/fs.mjs +15 -0
- package/dist/core/utils/globals.d.ts +11 -0
- package/dist/core/utils/globals.mjs +53 -0
- package/dist/core/utils/i18n.d.ts +11 -0
- package/dist/core/utils/i18n.mjs +35 -0
- package/dist/core/utils/log/index.d.ts +4 -0
- package/dist/core/utils/log/index.mjs +4 -0
- package/dist/core/utils/log/printBuildSummary.d.ts +2 -0
- package/dist/core/utils/log/printBuildSummary.mjs +32 -0
- package/dist/core/utils/log/printFileList.d.ts +1 -0
- package/dist/core/utils/log/printFileList.mjs +42 -0
- package/dist/core/utils/log/printHeader.d.ts +1 -0
- package/dist/core/utils/log/printHeader.mjs +7 -0
- package/dist/core/utils/log/printTable.d.ts +1 -0
- package/dist/core/utils/log/printTable.mjs +22 -0
- package/dist/core/utils/manifest.d.ts +44 -0
- package/dist/core/utils/manifest.mjs +512 -0
- package/dist/core/utils/network.d.ts +7 -0
- package/dist/core/utils/network.mjs +38 -0
- package/dist/core/utils/package.d.ts +6 -0
- package/dist/core/utils/package.mjs +14 -0
- package/dist/core/utils/paths.d.ts +11 -0
- package/dist/core/utils/paths.mjs +10 -0
- package/dist/core/utils/strings.d.ts +14 -0
- package/dist/core/utils/strings.mjs +18 -0
- package/dist/core/utils/testing/fake-objects.d.ts +4520 -0
- package/dist/core/utils/testing/fake-objects.mjs +323 -0
- package/dist/core/utils/time.d.ts +9 -0
- package/dist/core/utils/time.mjs +17 -0
- package/dist/core/utils/transform.d.ts +9 -0
- package/dist/core/utils/transform.mjs +17 -0
- package/dist/core/utils/types.d.ts +10 -0
- package/dist/core/utils/types.mjs +0 -0
- package/dist/core/utils/validation.d.ts +15 -0
- package/dist/core/utils/validation.mjs +55 -0
- package/dist/core/utils/virtual-modules.d.ts +22 -0
- package/dist/core/utils/virtual-modules.mjs +14 -0
- package/dist/core/utils/wsl.d.ts +4 -0
- package/dist/core/utils/wsl.mjs +4 -0
- package/dist/core/wxt.d.ts +19 -0
- package/dist/core/wxt.mjs +41 -0
- package/dist/core/zip.d.ts +7 -0
- package/dist/core/zip.mjs +137 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.mjs +3 -0
- package/dist/modules.d.ts +10 -20
- package/dist/{chunk-6XSIWUWF.js → modules.mjs} +7 -16
- package/dist/sandbox/define-app-config.d.ts +19 -0
- package/dist/sandbox/define-app-config.mjs +3 -0
- package/dist/sandbox/define-background.d.ts +3 -0
- package/dist/sandbox/define-background.mjs +4 -0
- package/dist/sandbox/define-content-script.d.ts +2 -0
- package/dist/sandbox/define-content-script.mjs +3 -0
- package/dist/sandbox/define-unlisted-script.d.ts +3 -0
- package/dist/sandbox/define-unlisted-script.mjs +4 -0
- package/dist/sandbox/define-wxt-plugin.d.ts +2 -0
- package/dist/sandbox/define-wxt-plugin.mjs +3 -0
- package/dist/sandbox/dev-server-websocket.d.ts +21 -0
- package/dist/sandbox/dev-server-websocket.mjs +37 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.mjs +6 -0
- package/dist/sandbox/utils/logger.d.ts +9 -0
- package/dist/sandbox/utils/logger.mjs +15 -0
- package/dist/storage.d.ts +13 -15
- package/dist/{storage.js → storage.mjs} +5 -34
- package/dist/testing/fake-browser.d.ts +1 -0
- package/dist/testing/fake-browser.mjs +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/{testing.d.ts → testing/wxt-vitest-plugin.d.ts} +3 -15
- package/dist/testing/wxt-vitest-plugin.mjs +26 -0
- package/dist/{index-CM35KuSH.d.cts → types.d.ts} +119 -250
- package/dist/types.mjs +0 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.mjs +1 -0
- package/dist/virtual/{background-entrypoint.js → background-entrypoint.mjs} +31 -40
- package/dist/virtual/{content-script-isolated-world-entrypoint.js → content-script-isolated-world-entrypoint.mjs} +9 -13
- package/dist/virtual/{content-script-main-world-entrypoint.js → content-script-main-world-entrypoint.mjs} +9 -14
- package/dist/virtual/mock-browser.mjs +6 -0
- package/dist/virtual/{reload-html.js → reload-html.mjs} +8 -9
- package/dist/virtual/{unlisted-script-entrypoint.js → unlisted-script-entrypoint.mjs} +8 -12
- package/package.json +51 -57
- package/dist/browser.d.ts +0 -18
- package/dist/browser.js +0 -6
- package/dist/chunk-BM6QYGAW.js +0 -1063
- package/dist/chunk-FNTE2L27.js +0 -7
- package/dist/chunk-KPD5J7PZ.js +0 -1065
- package/dist/chunk-QGM4M3NI.js +0 -37
- package/dist/chunk-SGKCDMVR.js +0 -38
- package/dist/chunk-ZONHOHIX.js +0 -3608
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -4429
- package/dist/client.js +0 -424
- package/dist/define-app-config-bg54F_lV.d.ts +0 -294
- package/dist/execa-4UBDUBJZ.js +0 -7244
- package/dist/execa-QLUM2B3W.js +0 -7245
- package/dist/index-CM35KuSH.d.ts +0 -1401
- package/dist/index.cjs +0 -14464
- package/dist/index.d.cts +0 -81
- package/dist/index.js +0 -696
- package/dist/modules.cjs +0 -96
- package/dist/modules.d.cts +0 -119
- package/dist/modules.js +0 -17
- package/dist/prompt-25QIVJDC.js +0 -755
- package/dist/prompt-7BMKNSWS.js +0 -754
- package/dist/sandbox.d.ts +0 -16
- package/dist/sandbox.js +0 -36
- package/dist/storage.cjs +0 -439
- package/dist/storage.d.cts +0 -200
- package/dist/testing.cjs +0 -2806
- package/dist/testing.d.cts +0 -30
- package/dist/testing.js +0 -40
- package/dist/virtual/mock-browser.js +0 -6
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { browser } from "wxt/browser";
|
|
2
|
+
import { logger } from "../../sandbox/utils/logger.mjs";
|
|
3
|
+
import { getUniqueEventName } from "./custom-events.mjs";
|
|
4
|
+
import { createLocationWatcher } from "./location-watcher.mjs";
|
|
5
|
+
export class ContentScriptContext {
|
|
6
|
+
constructor(contentScriptName, options) {
|
|
7
|
+
this.contentScriptName = contentScriptName;
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.#abortController = new AbortController();
|
|
10
|
+
if (this.#isTopFrame) {
|
|
11
|
+
this.#stopOldScripts();
|
|
12
|
+
}
|
|
13
|
+
this.setTimeout(() => {
|
|
14
|
+
this.#listenForNewerScripts();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static SCRIPT_STARTED_MESSAGE_TYPE = "wxt:content-script-started";
|
|
18
|
+
#isTopFrame = window.self === window.top;
|
|
19
|
+
#abortController;
|
|
20
|
+
#locationWatcher = createLocationWatcher(this);
|
|
21
|
+
get signal() {
|
|
22
|
+
return this.#abortController.signal;
|
|
23
|
+
}
|
|
24
|
+
abort(reason) {
|
|
25
|
+
return this.#abortController.abort(reason);
|
|
26
|
+
}
|
|
27
|
+
get isInvalid() {
|
|
28
|
+
if (browser.runtime.id == null) {
|
|
29
|
+
this.notifyInvalidated();
|
|
30
|
+
}
|
|
31
|
+
return this.signal.aborted;
|
|
32
|
+
}
|
|
33
|
+
get isValid() {
|
|
34
|
+
return !this.isInvalid;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Add a listener that is called when the content script's context is invalidated.
|
|
38
|
+
*
|
|
39
|
+
* @returns A function to remove the listener.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* browser.runtime.onMessage.addListener(cb);
|
|
43
|
+
* const removeInvalidatedListener = ctx.onInvalidated(() => {
|
|
44
|
+
* browser.runtime.onMessage.removeListener(cb);
|
|
45
|
+
* })
|
|
46
|
+
* // ...
|
|
47
|
+
* removeInvalidatedListener();
|
|
48
|
+
*/
|
|
49
|
+
onInvalidated(cb) {
|
|
50
|
+
this.signal.addEventListener("abort", cb);
|
|
51
|
+
return () => this.signal.removeEventListener("abort", cb);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Return a promise that never resolves. Useful if you have an async function that shouldn't run
|
|
55
|
+
* after the context is expired.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const getValueFromStorage = async () => {
|
|
59
|
+
* if (ctx.isInvalid) return ctx.block();
|
|
60
|
+
*
|
|
61
|
+
* // ...
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
block() {
|
|
65
|
+
return new Promise(() => {
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
|
|
70
|
+
*/
|
|
71
|
+
setInterval(handler, timeout) {
|
|
72
|
+
const id = setInterval(() => {
|
|
73
|
+
if (this.isValid) handler();
|
|
74
|
+
}, timeout);
|
|
75
|
+
this.onInvalidated(() => clearInterval(id));
|
|
76
|
+
return id;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
|
|
80
|
+
*/
|
|
81
|
+
setTimeout(handler, timeout) {
|
|
82
|
+
const id = setTimeout(() => {
|
|
83
|
+
if (this.isValid) handler();
|
|
84
|
+
}, timeout);
|
|
85
|
+
this.onInvalidated(() => clearTimeout(id));
|
|
86
|
+
return id;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
|
|
90
|
+
* invalidated.
|
|
91
|
+
*/
|
|
92
|
+
requestAnimationFrame(callback) {
|
|
93
|
+
const id = requestAnimationFrame((...args) => {
|
|
94
|
+
if (this.isValid) callback(...args);
|
|
95
|
+
});
|
|
96
|
+
this.onInvalidated(() => cancelAnimationFrame(id));
|
|
97
|
+
return id;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Wrapper around `window.requestIdleCallback` that automatically cancels the request when
|
|
101
|
+
* invalidated.
|
|
102
|
+
*/
|
|
103
|
+
requestIdleCallback(callback, options) {
|
|
104
|
+
const id = requestIdleCallback((...args) => {
|
|
105
|
+
if (!this.signal.aborted) callback(...args);
|
|
106
|
+
}, options);
|
|
107
|
+
this.onInvalidated(() => cancelIdleCallback(id));
|
|
108
|
+
return id;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Call `target.addEventListener` and remove the event listener when the context is invalidated.
|
|
112
|
+
*
|
|
113
|
+
* Includes additional events useful for content scripts:
|
|
114
|
+
*
|
|
115
|
+
* - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
|
|
116
|
+
* scripts are not reloaded when navigating this way, so this can be used to reset the content
|
|
117
|
+
* script state on URL change, or run custom code.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
121
|
+
* // ...
|
|
122
|
+
* });
|
|
123
|
+
* ctx.addEventListener(document, "wxt:locationchange", () => {
|
|
124
|
+
* // ...
|
|
125
|
+
* });
|
|
126
|
+
*/
|
|
127
|
+
addEventListener(target, type, handler, options) {
|
|
128
|
+
if (type === "wxt:locationchange") {
|
|
129
|
+
if (this.isValid) this.#locationWatcher.run();
|
|
130
|
+
}
|
|
131
|
+
target.addEventListener?.(
|
|
132
|
+
type.startsWith("wxt:") ? getUniqueEventName(type) : type,
|
|
133
|
+
// @ts-expect-error: Event don't match, but that's OK, EventTarget doesn't allow custom types in the callback
|
|
134
|
+
handler,
|
|
135
|
+
{
|
|
136
|
+
...options,
|
|
137
|
+
signal: this.signal
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
* Abort the abort controller and execute all `onInvalidated` listeners.
|
|
144
|
+
*/
|
|
145
|
+
notifyInvalidated() {
|
|
146
|
+
this.abort("Content script context invalidated");
|
|
147
|
+
logger.debug(
|
|
148
|
+
`Content script "${this.contentScriptName}" context invalidated`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
#stopOldScripts() {
|
|
152
|
+
window.postMessage(
|
|
153
|
+
{
|
|
154
|
+
type: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
|
|
155
|
+
contentScriptName: this.contentScriptName
|
|
156
|
+
},
|
|
157
|
+
"*"
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
#listenForNewerScripts() {
|
|
161
|
+
const cb = (event) => {
|
|
162
|
+
if (event.data?.type === ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE && event.data?.contentScriptName === this.contentScriptName) {
|
|
163
|
+
this.notifyInvalidated();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
addEventListener("message", cb);
|
|
167
|
+
this.onInvalidated(() => removeEventListener("message", cb));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class WxtLocationChangeEvent extends Event {
|
|
2
|
+
readonly newUrl: URL;
|
|
3
|
+
readonly oldUrl: URL;
|
|
4
|
+
static EVENT_NAME: string;
|
|
5
|
+
constructor(newUrl: URL, oldUrl: URL);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns an event name unique to the extension and content script that's running.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getUniqueEventName(eventName: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { browser } from "wxt/browser";
|
|
2
|
+
export class WxtLocationChangeEvent extends Event {
|
|
3
|
+
constructor(newUrl, oldUrl) {
|
|
4
|
+
super(WxtLocationChangeEvent.EVENT_NAME, {});
|
|
5
|
+
this.newUrl = newUrl;
|
|
6
|
+
this.oldUrl = oldUrl;
|
|
7
|
+
}
|
|
8
|
+
static EVENT_NAME = getUniqueEventName("wxt:locationchange");
|
|
9
|
+
}
|
|
10
|
+
export function getUniqueEventName(eventName) {
|
|
11
|
+
const entrypointName = typeof import.meta.env === "undefined" ? "build" : import.meta.env.ENTRYPOINT;
|
|
12
|
+
return `${browser?.runtime?.id}:${entrypointName}:${eventName}`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ContentScriptContext } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* Create a util that watches for URL changes, dispatching the custom event when detected. Stops
|
|
4
|
+
* watching when content script is invalidated.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createLocationWatcher(ctx: ContentScriptContext): {
|
|
7
|
+
/**
|
|
8
|
+
* Ensure the location watcher is actively looking for URL changes. If it's already watching,
|
|
9
|
+
* this is a noop.
|
|
10
|
+
*/
|
|
11
|
+
run(): void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WxtLocationChangeEvent } from "./custom-events.mjs";
|
|
2
|
+
export function createLocationWatcher(ctx) {
|
|
3
|
+
let interval;
|
|
4
|
+
let oldUrl;
|
|
5
|
+
return {
|
|
6
|
+
/**
|
|
7
|
+
* Ensure the location watcher is actively looking for URL changes. If it's already watching,
|
|
8
|
+
* this is a noop.
|
|
9
|
+
*/
|
|
10
|
+
run() {
|
|
11
|
+
if (interval != null) return;
|
|
12
|
+
oldUrl = new URL(location.href);
|
|
13
|
+
interval = ctx.setInterval(() => {
|
|
14
|
+
let newUrl = new URL(location.href);
|
|
15
|
+
if (newUrl.href !== oldUrl.href) {
|
|
16
|
+
window.dispatchEvent(new WxtLocationChangeEvent(newUrl, oldUrl));
|
|
17
|
+
oldUrl = newUrl;
|
|
18
|
+
}
|
|
19
|
+
}, 1e3);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContentScriptContext } from '..';
|
|
2
|
+
import { IframeContentScriptUi, IframeContentScriptUiOptions, IntegratedContentScriptUi, IntegratedContentScriptUiOptions, ShadowRootContentScriptUi, ShadowRootContentScriptUiOptions } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Create a content script UI without any isolation.
|
|
6
|
+
*
|
|
7
|
+
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#integrated
|
|
8
|
+
*/
|
|
9
|
+
export declare function createIntegratedUi<TMounted>(ctx: ContentScriptContext, options: IntegratedContentScriptUiOptions<TMounted>): IntegratedContentScriptUi<TMounted>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a content script UI using an iframe.
|
|
12
|
+
*
|
|
13
|
+
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#iframe
|
|
14
|
+
*/
|
|
15
|
+
export declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: IframeContentScriptUiOptions<TMounted>): IframeContentScriptUi<TMounted>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a content script UI inside a [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
|
|
18
|
+
*
|
|
19
|
+
* > This function is async because it has to load the CSS via a network call.
|
|
20
|
+
*
|
|
21
|
+
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#shadowroot
|
|
22
|
+
*/
|
|
23
|
+
export declare function createShadowRootUi<TMounted>(ctx: ContentScriptContext, options: ShadowRootContentScriptUiOptions<TMounted>): Promise<ShadowRootContentScriptUi<TMounted>>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { browser } from "wxt/browser";
|
|
2
|
+
import { logger } from "../../../sandbox/utils/logger.mjs";
|
|
3
|
+
import { createIsolatedElement } from "@webext-core/isolated-element";
|
|
4
|
+
export * from "./types.mjs";
|
|
5
|
+
export function createIntegratedUi(ctx, options) {
|
|
6
|
+
const wrapper = document.createElement(options.tag || "div");
|
|
7
|
+
wrapper.setAttribute("data-wxt-integrated", "");
|
|
8
|
+
let mounted = void 0;
|
|
9
|
+
const mount = () => {
|
|
10
|
+
applyPosition(wrapper, void 0, options);
|
|
11
|
+
mountUi(wrapper, options);
|
|
12
|
+
mounted = options.onMount?.(wrapper);
|
|
13
|
+
};
|
|
14
|
+
const remove = () => {
|
|
15
|
+
options.onRemove?.(mounted);
|
|
16
|
+
wrapper.remove();
|
|
17
|
+
mounted = void 0;
|
|
18
|
+
};
|
|
19
|
+
ctx.onInvalidated(remove);
|
|
20
|
+
return {
|
|
21
|
+
get mounted() {
|
|
22
|
+
return mounted;
|
|
23
|
+
},
|
|
24
|
+
wrapper,
|
|
25
|
+
mount,
|
|
26
|
+
remove
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function createIframeUi(ctx, options) {
|
|
30
|
+
const wrapper = document.createElement("div");
|
|
31
|
+
wrapper.setAttribute("data-wxt-iframe", "");
|
|
32
|
+
const iframe = document.createElement("iframe");
|
|
33
|
+
iframe.src = browser.runtime.getURL(options.page);
|
|
34
|
+
wrapper.appendChild(iframe);
|
|
35
|
+
let mounted = void 0;
|
|
36
|
+
const mount = () => {
|
|
37
|
+
applyPosition(wrapper, iframe, options);
|
|
38
|
+
mountUi(wrapper, options);
|
|
39
|
+
mounted = options.onMount?.(wrapper, iframe);
|
|
40
|
+
};
|
|
41
|
+
const remove = () => {
|
|
42
|
+
options.onRemove?.(mounted);
|
|
43
|
+
wrapper.remove();
|
|
44
|
+
mounted = void 0;
|
|
45
|
+
};
|
|
46
|
+
ctx.onInvalidated(remove);
|
|
47
|
+
return {
|
|
48
|
+
get mounted() {
|
|
49
|
+
return mounted;
|
|
50
|
+
},
|
|
51
|
+
iframe,
|
|
52
|
+
wrapper,
|
|
53
|
+
mount,
|
|
54
|
+
remove
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export async function createShadowRootUi(ctx, options) {
|
|
58
|
+
const css = [options.css ?? ""];
|
|
59
|
+
if (ctx.options?.cssInjectionMode === "ui") {
|
|
60
|
+
const entryCss = await loadCss();
|
|
61
|
+
css.push(entryCss.replaceAll(":root", ":host"));
|
|
62
|
+
}
|
|
63
|
+
const {
|
|
64
|
+
isolatedElement: uiContainer,
|
|
65
|
+
parentElement: shadowHost,
|
|
66
|
+
shadow
|
|
67
|
+
} = await createIsolatedElement({
|
|
68
|
+
name: options.name,
|
|
69
|
+
css: {
|
|
70
|
+
textContent: css.join("\n").trim()
|
|
71
|
+
},
|
|
72
|
+
mode: options.mode ?? "open",
|
|
73
|
+
isolateEvents: options.isolateEvents
|
|
74
|
+
});
|
|
75
|
+
shadowHost.setAttribute("data-wxt-shadow-root", "");
|
|
76
|
+
let mounted;
|
|
77
|
+
const mount = () => {
|
|
78
|
+
mountUi(shadowHost, options);
|
|
79
|
+
applyPosition(shadowHost, shadow.querySelector("html"), options);
|
|
80
|
+
mounted = options.onMount(uiContainer, shadow, shadowHost);
|
|
81
|
+
};
|
|
82
|
+
const remove = () => {
|
|
83
|
+
options.onRemove?.(mounted);
|
|
84
|
+
shadowHost.remove();
|
|
85
|
+
while (uiContainer.lastChild)
|
|
86
|
+
uiContainer.removeChild(uiContainer.lastChild);
|
|
87
|
+
mounted = void 0;
|
|
88
|
+
};
|
|
89
|
+
ctx.onInvalidated(remove);
|
|
90
|
+
return {
|
|
91
|
+
shadow,
|
|
92
|
+
shadowHost,
|
|
93
|
+
uiContainer,
|
|
94
|
+
mount,
|
|
95
|
+
remove,
|
|
96
|
+
get mounted() {
|
|
97
|
+
return mounted;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function applyPosition(root, positionedElement, options) {
|
|
102
|
+
if (options.position === "inline") return;
|
|
103
|
+
if (options.zIndex != null) root.style.zIndex = String(options.zIndex);
|
|
104
|
+
root.style.overflow = "visible";
|
|
105
|
+
root.style.position = "relative";
|
|
106
|
+
root.style.width = "0";
|
|
107
|
+
root.style.height = "0";
|
|
108
|
+
root.style.display = "block";
|
|
109
|
+
if (positionedElement) {
|
|
110
|
+
if (options.position === "overlay") {
|
|
111
|
+
positionedElement.style.position = "absolute";
|
|
112
|
+
if (options.alignment?.startsWith("bottom-"))
|
|
113
|
+
positionedElement.style.bottom = "0";
|
|
114
|
+
else positionedElement.style.top = "0";
|
|
115
|
+
if (options.alignment?.endsWith("-right"))
|
|
116
|
+
positionedElement.style.right = "0";
|
|
117
|
+
else positionedElement.style.left = "0";
|
|
118
|
+
} else {
|
|
119
|
+
positionedElement.style.position = "fixed";
|
|
120
|
+
positionedElement.style.top = "0";
|
|
121
|
+
positionedElement.style.bottom = "0";
|
|
122
|
+
positionedElement.style.left = "0";
|
|
123
|
+
positionedElement.style.right = "0";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getAnchor(options) {
|
|
128
|
+
if (options.anchor == null) return document.body;
|
|
129
|
+
let resolved = typeof options.anchor === "function" ? options.anchor() : options.anchor;
|
|
130
|
+
if (typeof resolved === "string") {
|
|
131
|
+
if (resolved.startsWith("/")) {
|
|
132
|
+
const result = document.evaluate(
|
|
133
|
+
resolved,
|
|
134
|
+
document,
|
|
135
|
+
null,
|
|
136
|
+
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
137
|
+
null
|
|
138
|
+
);
|
|
139
|
+
return result.singleNodeValue ?? void 0;
|
|
140
|
+
} else {
|
|
141
|
+
return document.querySelector(resolved) ?? void 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return resolved ?? void 0;
|
|
145
|
+
}
|
|
146
|
+
function mountUi(root, options) {
|
|
147
|
+
const anchor = getAnchor(options);
|
|
148
|
+
if (anchor == null)
|
|
149
|
+
throw Error(
|
|
150
|
+
"Failed to mount content script UI: could not find anchor element"
|
|
151
|
+
);
|
|
152
|
+
switch (options.append) {
|
|
153
|
+
case void 0:
|
|
154
|
+
case "last":
|
|
155
|
+
anchor.append(root);
|
|
156
|
+
break;
|
|
157
|
+
case "first":
|
|
158
|
+
anchor.prepend(root);
|
|
159
|
+
break;
|
|
160
|
+
case "replace":
|
|
161
|
+
anchor.replaceWith(root);
|
|
162
|
+
break;
|
|
163
|
+
case "after":
|
|
164
|
+
anchor.parentElement?.insertBefore(root, anchor.nextElementSibling);
|
|
165
|
+
break;
|
|
166
|
+
case "before":
|
|
167
|
+
anchor.parentElement?.insertBefore(root, anchor);
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
options.append(anchor, root);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async function loadCss() {
|
|
175
|
+
const url = browser.runtime.getURL(
|
|
176
|
+
`/content-scripts/${import.meta.env.ENTRYPOINT}.css`
|
|
177
|
+
);
|
|
178
|
+
try {
|
|
179
|
+
const res = await fetch(url);
|
|
180
|
+
return await res.text();
|
|
181
|
+
} catch (err) {
|
|
182
|
+
logger.warn(
|
|
183
|
+
`Failed to load styles @ ${url}. Did you forget to import the stylesheet in your entrypoint?`,
|
|
184
|
+
err
|
|
185
|
+
);
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import 'webextension-polyfill';
|
|
3
|
-
|
|
4
|
-
interface IntegratedContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
1
|
+
export interface IntegratedContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
5
2
|
/**
|
|
6
3
|
* A wrapper div that assists in positioning.
|
|
7
4
|
*/
|
|
8
5
|
wrapper: HTMLElement;
|
|
9
6
|
}
|
|
10
|
-
interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
7
|
+
export interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
11
8
|
/**
|
|
12
9
|
* The iframe added to the DOM.
|
|
13
10
|
*/
|
|
@@ -17,7 +14,7 @@ interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
|
17
14
|
*/
|
|
18
15
|
wrapper: HTMLDivElement;
|
|
19
16
|
}
|
|
20
|
-
interface ShadowRootContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
17
|
+
export interface ShadowRootContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
21
18
|
/**
|
|
22
19
|
* The `HTMLElement` hosting the shadow root used to isolate the UI's styles. This is the element
|
|
23
20
|
* that get's added to the DOM. This element's style is not isolated from the webpage.
|
|
@@ -33,7 +30,7 @@ interface ShadowRootContentScriptUi<TMounted> extends ContentScriptUi<TMounted>
|
|
|
33
30
|
*/
|
|
34
31
|
shadow: ShadowRoot;
|
|
35
32
|
}
|
|
36
|
-
interface ContentScriptUi<TMounted> {
|
|
33
|
+
export interface ContentScriptUi<TMounted> {
|
|
37
34
|
/**
|
|
38
35
|
* Function that mounts or remounts the UI on the page.
|
|
39
36
|
*/
|
|
@@ -47,14 +44,14 @@ interface ContentScriptUi<TMounted> {
|
|
|
47
44
|
*/
|
|
48
45
|
mounted: TMounted | undefined;
|
|
49
46
|
}
|
|
50
|
-
type ContentScriptUiOptions<TMounted> = ContentScriptPositioningOptions & ContentScriptAnchoredOptions & {
|
|
47
|
+
export type ContentScriptUiOptions<TMounted> = ContentScriptPositioningOptions & ContentScriptAnchoredOptions & {
|
|
51
48
|
/**
|
|
52
49
|
* Callback called before the UI is removed from the webpage. Use to cleanup your UI, like
|
|
53
50
|
* unmounting your Vue or React apps.
|
|
54
51
|
*/
|
|
55
52
|
onRemove?: (mounted: TMounted | undefined) => void;
|
|
56
53
|
};
|
|
57
|
-
type IntegratedContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
54
|
+
export type IntegratedContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
58
55
|
/**
|
|
59
56
|
* Tag used to create the wrapper element.
|
|
60
57
|
*
|
|
@@ -69,7 +66,7 @@ type IntegratedContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounte
|
|
|
69
66
|
*/
|
|
70
67
|
onMount: (wrapper: HTMLElement) => TMounted;
|
|
71
68
|
};
|
|
72
|
-
type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
69
|
+
export type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
73
70
|
/**
|
|
74
71
|
* The path to the HTML page that will be shown in the iframe. This string is passed into
|
|
75
72
|
* `browser.runtime.getURL`.
|
|
@@ -83,7 +80,7 @@ type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> &
|
|
|
83
80
|
*/
|
|
84
81
|
onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
|
|
85
82
|
};
|
|
86
|
-
type ShadowRootContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
83
|
+
export type ShadowRootContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
87
84
|
/**
|
|
88
85
|
* The name of the custom component used to host the ShadowRoot. Must be kebab-case.
|
|
89
86
|
*/
|
|
@@ -118,15 +115,15 @@ type ShadowRootContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounte
|
|
|
118
115
|
*/
|
|
119
116
|
onMount: (uiContainer: HTMLElement, shadow: ShadowRoot, shadowHost: HTMLElement) => TMounted;
|
|
120
117
|
};
|
|
121
|
-
type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
118
|
+
export type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
122
119
|
/**
|
|
123
120
|
* 
|
|
124
121
|
*/
|
|
125
|
-
type ContentScriptAppendMode = 'last' | 'first' | 'replace' | 'before' | 'after' | ((anchor: Element, ui: Element) => void);
|
|
126
|
-
interface ContentScriptInlinePositioningOptions {
|
|
122
|
+
export type ContentScriptAppendMode = 'last' | 'first' | 'replace' | 'before' | 'after' | ((anchor: Element, ui: Element) => void);
|
|
123
|
+
export interface ContentScriptInlinePositioningOptions {
|
|
127
124
|
position: 'inline';
|
|
128
125
|
}
|
|
129
|
-
interface ContentScriptOverlayPositioningOptions {
|
|
126
|
+
export interface ContentScriptOverlayPositioningOptions {
|
|
130
127
|
position: 'overlay';
|
|
131
128
|
/**
|
|
132
129
|
* The `z-index` used on the `wrapper` element. Set to a positive number to show your UI over website
|
|
@@ -143,7 +140,7 @@ interface ContentScriptOverlayPositioningOptions {
|
|
|
143
140
|
*/
|
|
144
141
|
alignment?: ContentScriptOverlayAlignment;
|
|
145
142
|
}
|
|
146
|
-
interface ContentScriptModalPositioningOptions {
|
|
143
|
+
export interface ContentScriptModalPositioningOptions {
|
|
147
144
|
position: 'modal';
|
|
148
145
|
/**
|
|
149
146
|
* The `z-index` used on the `shadowHost`. Set to a positive number to show your UI over website
|
|
@@ -156,8 +153,8 @@ interface ContentScriptModalPositioningOptions {
|
|
|
156
153
|
*
|
|
157
154
|
* 
|
|
158
155
|
*/
|
|
159
|
-
type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
|
|
160
|
-
interface ContentScriptAnchoredOptions {
|
|
156
|
+
export type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
|
|
157
|
+
export interface ContentScriptAnchoredOptions {
|
|
161
158
|
/**
|
|
162
159
|
* A CSS selector, XPath expression, element, or function that returns one of the three. Along with `append`, the
|
|
163
160
|
* `anchor` dictates where in the page the UI will be added.
|
|
@@ -175,28 +172,3 @@ interface ContentScriptAnchoredOptions {
|
|
|
175
172
|
*/
|
|
176
173
|
append?: ContentScriptAppendMode | ((anchor: Element, ui: Element) => void);
|
|
177
174
|
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Create a content script UI without any isolation.
|
|
181
|
-
*
|
|
182
|
-
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#integrated
|
|
183
|
-
*/
|
|
184
|
-
declare function createIntegratedUi<TMounted>(ctx: ContentScriptContext, options: IntegratedContentScriptUiOptions<TMounted>): IntegratedContentScriptUi<TMounted>;
|
|
185
|
-
/**
|
|
186
|
-
* Create a content script UI using an iframe.
|
|
187
|
-
*
|
|
188
|
-
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#iframe
|
|
189
|
-
*/
|
|
190
|
-
declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: IframeContentScriptUiOptions<TMounted>): IframeContentScriptUi<TMounted>;
|
|
191
|
-
/**
|
|
192
|
-
* Create a content script UI inside a [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
|
|
193
|
-
*
|
|
194
|
-
* > This function is async because it has to load the CSS via a network call.
|
|
195
|
-
*
|
|
196
|
-
* @see https://wxt.dev/guide/key-concepts/content-script-ui.html#shadowroot
|
|
197
|
-
*/
|
|
198
|
-
declare function createShadowRootUi<TMounted>(ctx: ContentScriptContext, options: ShadowRootContentScriptUiOptions<TMounted>): Promise<ShadowRootContentScriptUi<TMounted>>;
|
|
199
|
-
|
|
200
|
-
declare function useAppConfig(): WxtAppConfig;
|
|
201
|
-
|
|
202
|
-
export { type ContentScriptAnchoredOptions, type ContentScriptAppendMode, ContentScriptContext, type ContentScriptInlinePositioningOptions, type ContentScriptModalPositioningOptions, type ContentScriptOverlayAlignment, type ContentScriptOverlayPositioningOptions, type ContentScriptPositioningOptions, type ContentScriptUi, type ContentScriptUiOptions, type IframeContentScriptUi, type IframeContentScriptUiOptions, type IntegratedContentScriptUi, type IntegratedContentScriptUiOptions, type ShadowRootContentScriptUi, type ShadowRootContentScriptUiOptions, createIframeUi, createIntegratedUi, createShadowRootUi, useAppConfig };
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BuildOutput, InlineConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
4
|
+
* the root directory, and merges that config with what is passed in.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Use config from `wxt.config.ts`
|
|
8
|
+
* const res = await build()
|
|
9
|
+
*
|
|
10
|
+
* // or override config `from wxt.config.ts`
|
|
11
|
+
* const res = await build({
|
|
12
|
+
* // Override config...
|
|
13
|
+
* })
|
|
14
|
+
*/
|
|
15
|
+
export declare function build(config?: InlineConfig): Promise<BuildOutput>;
|