wxt 0.20.13 → 0.20.15
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/dist/browser.d.mts +20 -0
- package/dist/browser.mjs +18 -3
- package/dist/builtin-modules/index.mjs +7 -2
- package/dist/builtin-modules/unimport.mjs +69 -75
- package/dist/cli/cli-utils.mjs +54 -50
- package/dist/cli/commands.mjs +78 -103
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +9 -4
- package/dist/core/{build.d.ts → build.d.mts} +6 -2
- package/dist/core/build.mjs +23 -4
- package/dist/core/builders/vite/index.mjs +293 -343
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +11 -12
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +27 -20
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +17 -12
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +105 -136
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -14
- package/dist/core/builders/vite/plugins/download.mjs +23 -12
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +18 -14
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +31 -33
- package/dist/core/builders/vite/plugins/globals.mjs +14 -13
- package/dist/core/builders/vite/plugins/iifeFooter.mjs +17 -11
- package/dist/core/builders/vite/plugins/index.mjs +18 -16
- package/dist/core/builders/vite/plugins/noopBackground.mjs +21 -15
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +26 -23
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -24
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +28 -26
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +11 -11
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +42 -47
- package/dist/core/{clean.d.ts → clean.d.mts} +7 -3
- package/dist/core/clean.mjs +38 -35
- package/dist/core/{create-server.d.ts → create-server.d.mts} +6 -2
- package/dist/core/create-server.mjs +236 -247
- package/dist/core/define-config.d.mts +6 -0
- package/dist/core/define-config.mjs +6 -2
- package/dist/core/define-web-ext-config.d.mts +13 -0
- package/dist/core/define-web-ext-config.mjs +16 -7
- package/dist/core/generate-wxt-dir.mjs +110 -148
- package/dist/core/index.d.mts +9 -0
- package/dist/core/index.mjs +12 -8
- package/dist/core/initialize.d.mts +8 -0
- package/dist/core/initialize.mjs +110 -124
- package/dist/core/keyboard-shortcuts.mjs +30 -28
- package/dist/core/package-managers/bun.mjs +18 -16
- package/dist/core/package-managers/deno.mjs +12 -8
- package/dist/core/package-managers/index.mjs +52 -60
- package/dist/core/package-managers/npm.mjs +51 -52
- package/dist/core/package-managers/pnpm.mjs +21 -18
- package/dist/core/package-managers/yarn.mjs +31 -28
- package/dist/core/prepare.d.mts +6 -0
- package/dist/core/prepare.mjs +12 -7
- package/dist/core/resolve-config.mjs +393 -462
- package/dist/core/runners/index.mjs +15 -10
- package/dist/core/runners/manual.mjs +13 -14
- package/dist/core/runners/safari.mjs +13 -14
- package/dist/core/runners/web-ext.mjs +62 -83
- package/dist/core/runners/wsl.mjs +13 -14
- package/dist/core/utils/arrays.mjs +23 -12
- package/dist/core/utils/building/build-entrypoints.mjs +44 -40
- package/dist/core/utils/building/detect-dev-changes.mjs +84 -105
- package/dist/core/utils/building/find-entrypoints.mjs +278 -359
- package/dist/core/utils/building/group-entrypoints.mjs +42 -35
- package/dist/core/utils/building/index.mjs +8 -6
- package/dist/core/utils/building/internal-build.mjs +86 -102
- package/dist/core/utils/building/rebuild.mjs +50 -30
- package/dist/core/utils/cache.mjs +29 -18
- package/dist/core/utils/constants.mjs +9 -1
- package/dist/core/utils/content-scripts.mjs +56 -54
- package/dist/core/utils/content-security-policy.mjs +36 -39
- package/dist/core/utils/entrypoints.mjs +51 -28
- package/dist/core/utils/env.mjs +22 -17
- package/dist/core/utils/environments/browser-environment.mjs +13 -12
- package/dist/core/utils/environments/environment.mjs +36 -33
- package/dist/core/utils/environments/extension-environment.mjs +15 -10
- package/dist/core/utils/environments/index.mjs +4 -2
- package/dist/core/utils/eslint.mjs +11 -10
- package/dist/core/utils/fs.mjs +23 -11
- package/dist/core/utils/globals.mjs +53 -51
- package/dist/core/utils/i18n.mjs +41 -32
- package/dist/core/utils/index.mjs +3 -0
- package/dist/core/utils/log/index.mjs +6 -4
- package/dist/core/utils/log/printBuildSummary.mjs +20 -25
- package/dist/core/utils/log/printFileList.mjs +30 -33
- package/dist/core/utils/log/printHeader.mjs +9 -5
- package/dist/core/utils/log/printTable.mjs +19 -21
- package/dist/core/utils/manifest.mjs +366 -479
- package/dist/core/utils/minimatch-multiple.mjs +26 -15
- package/dist/core/utils/network.mjs +27 -33
- package/dist/core/utils/number.mjs +7 -3
- package/dist/core/utils/package.mjs +20 -13
- package/dist/core/utils/paths.d.mts +8 -0
- package/dist/core/utils/paths.mjs +26 -7
- package/dist/core/utils/strings.mjs +19 -14
- package/dist/core/utils/syntax-errors.mjs +14 -16
- package/dist/core/utils/time.mjs +19 -15
- package/dist/core/utils/transform.mjs +129 -160
- package/dist/core/utils/types.d.mts +6 -0
- package/dist/core/utils/validation.mjs +43 -50
- package/dist/core/utils/virtual-modules.mjs +20 -12
- package/dist/core/utils/wsl.mjs +11 -3
- package/dist/core/wxt.mjs +65 -60
- package/dist/core/{zip.d.ts → zip.d.mts} +6 -2
- package/dist/core/zip.mjs +118 -140
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +13 -3
- package/dist/{modules.d.ts → modules.d.mts} +14 -16
- package/dist/modules.mjs +179 -51
- package/dist/testing/fake-browser.d.mts +2 -0
- package/dist/testing/fake-browser.mjs +3 -1
- package/dist/testing/index.d.mts +3 -0
- package/dist/testing/index.mjs +4 -2
- package/dist/testing/{wxt-vitest-plugin.d.ts → wxt-vitest-plugin.d.mts} +7 -9
- package/dist/testing/wxt-vitest-plugin.mjs +38 -19
- package/dist/types.d.mts +1475 -0
- package/dist/utils/app-config.d.mts +6 -0
- package/dist/utils/app-config.mjs +8 -2
- package/dist/utils/content-script-context.d.mts +134 -0
- package/dist/utils/content-script-context.mjs +187 -175
- package/dist/utils/content-script-ui/iframe.d.mts +42 -0
- package/dist/utils/content-script-ui/iframe.mjs +42 -27
- package/dist/utils/content-script-ui/integrated.d.mts +37 -0
- package/dist/utils/content-script-ui/integrated.mjs +36 -29
- package/dist/utils/content-script-ui/shadow-root.d.mts +80 -0
- package/dist/utils/content-script-ui/shadow-root.mjs +75 -82
- package/dist/utils/content-script-ui/shared.mjs +115 -150
- package/dist/utils/content-script-ui/types.d.mts +107 -0
- package/dist/utils/content-script-ui/types.mjs +1 -0
- package/dist/utils/{define-app-config.d.ts → define-app-config.d.mts} +5 -3
- package/dist/utils/define-app-config.mjs +22 -2
- package/dist/utils/define-background.d.mts +7 -0
- package/dist/utils/define-background.mjs +7 -3
- package/dist/utils/define-content-script.d.mts +6 -0
- package/dist/utils/define-content-script.mjs +6 -2
- package/dist/utils/define-unlisted-script.d.mts +7 -0
- package/dist/utils/define-unlisted-script.mjs +7 -3
- package/dist/utils/define-wxt-plugin.d.mts +6 -0
- package/dist/utils/define-wxt-plugin.mjs +6 -2
- package/dist/utils/inject-script.d.mts +41 -0
- package/dist/utils/inject-script.mjs +44 -34
- package/dist/utils/internal/custom-events.d.mts +9 -0
- package/dist/utils/internal/custom-events.mjs +18 -10
- package/dist/utils/internal/location-watcher.mjs +23 -20
- package/dist/utils/internal/logger.mjs +15 -12
- package/dist/utils/match-patterns.d.mts +1 -0
- package/dist/utils/match-patterns.mjs +3 -1
- package/dist/utils/{split-shadow-root-css.d.ts → split-shadow-root-css.d.mts} +6 -3
- package/dist/utils/split-shadow-root-css.mjs +16 -7
- package/dist/utils/storage.d.mts +1 -0
- package/dist/utils/storage.mjs +3 -1
- package/dist/version.d.mts +4 -0
- package/dist/version.mjs +5 -1
- package/dist/virtual/background-entrypoint.d.mts +4 -0
- package/dist/virtual/background-entrypoint.mjs +143 -161
- package/dist/virtual/content-script-isolated-world-entrypoint.d.mts +4 -0
- package/dist/virtual/content-script-isolated-world-entrypoint.mjs +26 -27
- package/dist/virtual/content-script-main-world-entrypoint.d.mts +4 -0
- package/dist/virtual/content-script-main-world-entrypoint.mjs +24 -24
- package/dist/virtual/mock-browser.d.mts +6 -0
- package/dist/virtual/mock-browser.mjs +5 -3
- package/dist/virtual/reload-html.d.mts +1 -0
- package/dist/virtual/reload-html.mjs +57 -53
- package/dist/virtual/unlisted-script-entrypoint.d.mts +4 -0
- package/dist/virtual/unlisted-script-entrypoint.mjs +35 -43
- package/package.json +56 -50
- package/dist/browser.d.ts +0 -30
- package/dist/builtin-modules/index.d.ts +0 -2
- package/dist/builtin-modules/unimport.d.ts +0 -5
- package/dist/cli/cli-utils.d.ts +0 -25
- package/dist/cli/commands.d.ts +0 -2
- package/dist/cli/index.d.ts +0 -1
- package/dist/core/builders/vite/index.d.ts +0 -7
- package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +0 -7
- package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +0 -13
- package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +0 -14
- package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +0 -7
- package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +0 -6
- package/dist/core/builders/vite/plugins/download.d.ts +0 -10
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +0 -6
- package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +0 -6
- package/dist/core/builders/vite/plugins/globals.d.ts +0 -3
- package/dist/core/builders/vite/plugins/iifeFooter.d.ts +0 -8
- package/dist/core/builders/vite/plugins/index.d.ts +0 -16
- package/dist/core/builders/vite/plugins/noopBackground.d.ts +0 -6
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +0 -6
- package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +0 -6
- package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +0 -6
- package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +0 -3
- package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +0 -6
- package/dist/core/define-config.d.ts +0 -2
- package/dist/core/define-web-ext-config.d.ts +0 -9
- package/dist/core/generate-wxt-dir.d.ts +0 -5
- package/dist/core/index.d.ts +0 -8
- package/dist/core/initialize.d.ts +0 -5
- package/dist/core/keyboard-shortcuts.d.ts +0 -12
- package/dist/core/package-managers/bun.d.ts +0 -2
- package/dist/core/package-managers/deno.d.ts +0 -2
- package/dist/core/package-managers/index.d.ts +0 -2
- package/dist/core/package-managers/npm.d.ts +0 -17
- package/dist/core/package-managers/pnpm.d.ts +0 -2
- package/dist/core/package-managers/types.d.ts +0 -2
- package/dist/core/package-managers/types.mjs +0 -0
- package/dist/core/package-managers/yarn.d.ts +0 -2
- package/dist/core/prepare.d.ts +0 -2
- package/dist/core/resolve-config.d.ts +0 -11
- package/dist/core/runners/index.d.ts +0 -2
- package/dist/core/runners/manual.d.ts +0 -5
- package/dist/core/runners/safari.d.ts +0 -5
- package/dist/core/runners/web-ext.d.ts +0 -5
- package/dist/core/runners/wsl.d.ts +0 -5
- package/dist/core/utils/arrays.d.ts +0 -13
- package/dist/core/utils/building/build-entrypoints.d.ts +0 -3
- package/dist/core/utils/building/detect-dev-changes.d.ts +0 -61
- package/dist/core/utils/building/find-entrypoints.d.ts +0 -5
- package/dist/core/utils/building/group-entrypoints.d.ts +0 -8
- package/dist/core/utils/building/index.d.ts +0 -6
- package/dist/core/utils/building/internal-build.d.ts +0 -12
- package/dist/core/utils/building/rebuild.d.ts +0 -23
- package/dist/core/utils/cache.d.ts +0 -8
- package/dist/core/utils/cli.d.ts +0 -3
- package/dist/core/utils/cli.mjs +0 -26
- package/dist/core/utils/constants.d.ts +0 -5
- package/dist/core/utils/content-scripts.d.ts +0 -12
- package/dist/core/utils/content-security-policy.d.ts +0 -14
- package/dist/core/utils/entrypoints.d.ts +0 -31
- package/dist/core/utils/env.d.ts +0 -5
- package/dist/core/utils/environments/browser-environment.d.ts +0 -3
- package/dist/core/utils/environments/environment.d.ts +0 -8
- package/dist/core/utils/environments/extension-environment.d.ts +0 -6
- package/dist/core/utils/environments/index.d.ts +0 -2
- package/dist/core/utils/eslint.d.ts +0 -1
- package/dist/core/utils/fs.d.ts +0 -13
- package/dist/core/utils/globals.d.ts +0 -11
- package/dist/core/utils/i18n.d.ts +0 -11
- package/dist/core/utils/log/index.d.ts +0 -4
- package/dist/core/utils/log/printBuildSummary.d.ts +0 -2
- package/dist/core/utils/log/printFileList.d.ts +0 -1
- package/dist/core/utils/log/printHeader.d.ts +0 -1
- package/dist/core/utils/log/printTable.d.ts +0 -1
- package/dist/core/utils/manifest.d.ts +0 -40
- package/dist/core/utils/minimatch-multiple.d.ts +0 -15
- package/dist/core/utils/network.d.ts +0 -7
- package/dist/core/utils/number.d.ts +0 -1
- package/dist/core/utils/package.d.ts +0 -6
- package/dist/core/utils/paths.d.ts +0 -11
- package/dist/core/utils/strings.d.ts +0 -14
- package/dist/core/utils/syntax-errors.d.ts +0 -11
- package/dist/core/utils/testing/fake-objects.d.ts +0 -11665
- package/dist/core/utils/testing/fake-objects.mjs +0 -326
- package/dist/core/utils/time.d.ts +0 -9
- package/dist/core/utils/transform.d.ts +0 -11
- package/dist/core/utils/types.d.ts +0 -13
- package/dist/core/utils/types.mjs +0 -0
- package/dist/core/utils/validation.d.ts +0 -15
- package/dist/core/utils/virtual-modules.d.ts +0 -22
- package/dist/core/utils/wsl.d.ts +0 -4
- package/dist/core/wxt.d.ts +0 -24
- package/dist/index.d.ts +0 -11
- package/dist/testing/fake-browser.d.ts +0 -10
- package/dist/testing/index.d.ts +0 -10
- package/dist/types.d.ts +0 -1459
- package/dist/types.mjs +0 -0
- package/dist/utils/app-config.d.ts +0 -2
- package/dist/utils/content-script-context.d.ts +0 -134
- package/dist/utils/content-script-ui/iframe.d.ts +0 -32
- package/dist/utils/content-script-ui/integrated.d.ts +0 -34
- package/dist/utils/content-script-ui/shadow-root.d.ts +0 -76
- package/dist/utils/content-script-ui/shared.d.ts +0 -5
- package/dist/utils/content-script-ui/types.d.ts +0 -104
- package/dist/utils/define-background.d.ts +0 -4
- package/dist/utils/define-content-script.d.ts +0 -3
- package/dist/utils/define-unlisted-script.d.ts +0 -4
- package/dist/utils/define-wxt-plugin.d.ts +0 -3
- package/dist/utils/inject-script.d.ts +0 -36
- package/dist/utils/internal/custom-events.d.ts +0 -10
- package/dist/utils/internal/dev-server-websocket.d.ts +0 -21
- package/dist/utils/internal/dev-server-websocket.mjs +0 -37
- package/dist/utils/internal/location-watcher.d.ts +0 -12
- package/dist/utils/internal/logger.d.ts +0 -9
- package/dist/utils/match-patterns.d.ts +0 -5
- package/dist/utils/storage.d.ts +0 -5
- package/dist/version.d.ts +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//#region src/utils/content-script-ui/types.d.ts
|
|
2
|
+
/** @module wxt/utils/content-script-ui/types */
|
|
3
|
+
interface ContentScriptUi<TMounted> extends MountFunctions {
|
|
4
|
+
mounted: TMounted | undefined;
|
|
5
|
+
}
|
|
6
|
+
type ContentScriptUiOptions<TMounted> = ContentScriptPositioningOptions & ContentScriptAnchoredOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Callback called before the UI is removed from the webpage. Use to cleanup your UI, like
|
|
9
|
+
* unmounting your Vue or React apps.
|
|
10
|
+
*
|
|
11
|
+
* Note that this callback is called only when `ui.remove` is called - that means it is
|
|
12
|
+
* not called automatically when the anchor is removed, unless you use `autoMount`.
|
|
13
|
+
*/
|
|
14
|
+
onRemove?: (mounted: TMounted | undefined) => void;
|
|
15
|
+
};
|
|
16
|
+
type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
17
|
+
/**
|
|
18
|
+
* 
|
|
19
|
+
*/
|
|
20
|
+
type ContentScriptAppendMode = 'last' | 'first' | 'replace' | 'before' | 'after' | ((anchor: Element, ui: Element) => void);
|
|
21
|
+
interface ContentScriptInlinePositioningOptions {
|
|
22
|
+
position: 'inline';
|
|
23
|
+
}
|
|
24
|
+
interface ContentScriptOverlayPositioningOptions {
|
|
25
|
+
position: 'overlay';
|
|
26
|
+
/**
|
|
27
|
+
* The `z-index` used on the `wrapper` element. Set to a positive number to show your UI over website
|
|
28
|
+
* content.
|
|
29
|
+
*/
|
|
30
|
+
zIndex?: number;
|
|
31
|
+
/**
|
|
32
|
+
* When using `type: "overlay"`, the mounted element is 0px by 0px in size. Alignment specifies
|
|
33
|
+
* which corner is aligned with that 0x0 pixel space.
|
|
34
|
+
*
|
|
35
|
+
* 
|
|
36
|
+
*
|
|
37
|
+
* @default "top-left"
|
|
38
|
+
*/
|
|
39
|
+
alignment?: ContentScriptOverlayAlignment;
|
|
40
|
+
}
|
|
41
|
+
interface ContentScriptModalPositioningOptions {
|
|
42
|
+
position: 'modal';
|
|
43
|
+
/**
|
|
44
|
+
* The `z-index` used on the `shadowHost`. Set to a positive number to show your UI over website
|
|
45
|
+
* content.
|
|
46
|
+
*/
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Choose between `"inline"`, `"overlay"`, or `"modal"` positions.
|
|
51
|
+
*
|
|
52
|
+
* 
|
|
53
|
+
*/
|
|
54
|
+
type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
|
|
55
|
+
interface ContentScriptAnchoredOptions {
|
|
56
|
+
/**
|
|
57
|
+
* A CSS selector, XPath expression, element, or function that returns one of the three. Along with `append`, the
|
|
58
|
+
* `anchor` dictates where in the page the UI will be added.
|
|
59
|
+
*/
|
|
60
|
+
anchor?: string | Element | null | undefined | (() => string | Element | null | undefined);
|
|
61
|
+
/**
|
|
62
|
+
* In combination with `anchor`, decide how to add the UI to the DOM.
|
|
63
|
+
*
|
|
64
|
+
* - `"last"` (default) - Add the UI as the last child of the `anchor` element
|
|
65
|
+
* - `"first"` - Add the UI as the first child of the `anchor` element
|
|
66
|
+
* - `"replace"` - Replace the `anchor` element with the UI.
|
|
67
|
+
* - `"before"` - Add the UI as the sibling before the `anchor` element
|
|
68
|
+
* - `"after"` - Add the UI as the sibling after the `anchor` element
|
|
69
|
+
* - `(anchor, ui) => void` - Customizable function that let's you add the UI to the DOM
|
|
70
|
+
*/
|
|
71
|
+
append?: ContentScriptAppendMode | ((anchor: Element, ui: Element) => void);
|
|
72
|
+
}
|
|
73
|
+
interface BaseMountFunctions {
|
|
74
|
+
/**
|
|
75
|
+
* Function that mounts or remounts the UI on the page.
|
|
76
|
+
*/
|
|
77
|
+
mount: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Function that removes the UI from the webpage.
|
|
80
|
+
*/
|
|
81
|
+
remove: () => void;
|
|
82
|
+
}
|
|
83
|
+
interface MountFunctions extends BaseMountFunctions {
|
|
84
|
+
/**
|
|
85
|
+
* Call `ui.autoMount()` to automatically mount and remove the UI as the anchor is dynamically added/removed by the webpage.
|
|
86
|
+
*/
|
|
87
|
+
autoMount: (options?: AutoMountOptions) => void;
|
|
88
|
+
}
|
|
89
|
+
type AutoMountOptions = {
|
|
90
|
+
/**
|
|
91
|
+
* When true, only mount and unmount a UI once.
|
|
92
|
+
*/
|
|
93
|
+
once?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The callback triggered when `StopAutoMount` is called.
|
|
96
|
+
*/
|
|
97
|
+
onStop?: () => void;
|
|
98
|
+
};
|
|
99
|
+
type StopAutoMount = () => void;
|
|
100
|
+
interface AutoMount {
|
|
101
|
+
/**
|
|
102
|
+
* Stop watching the anchor element for changes, but keep the UI mounted.
|
|
103
|
+
*/
|
|
104
|
+
stopAutoMount: StopAutoMount;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { AutoMount, AutoMountOptions, BaseMountFunctions, ContentScriptAnchoredOptions, ContentScriptAppendMode, ContentScriptInlinePositioningOptions, ContentScriptModalPositioningOptions, ContentScriptOverlayAlignment, ContentScriptOverlayPositioningOptions, ContentScriptPositioningOptions, ContentScriptUi, ContentScriptUiOptions, MountFunctions, StopAutoMount };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
//#region src/utils/define-app-config.d.ts
|
|
1
2
|
/** @module wxt/utils/define-app-config */
|
|
2
|
-
|
|
3
|
-
}
|
|
3
|
+
interface WxtAppConfig {}
|
|
4
4
|
/**
|
|
5
5
|
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
6
6
|
*
|
|
@@ -17,4 +17,6 @@ export interface WxtAppConfig {
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
declare function defineAppConfig(config: WxtAppConfig): WxtAppConfig;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { WxtAppConfig, defineAppConfig };
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/define-app-config.ts
|
|
2
|
+
/**
|
|
3
|
+
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
4
|
+
*
|
|
5
|
+
* You can add fields to this interface via ["Module Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // app.config.ts
|
|
9
|
+
* import 'wxt/utils/define-app-config';
|
|
10
|
+
*
|
|
11
|
+
* declare module "wxt/utils/define-app-config" {
|
|
12
|
+
* export interface WxtAppConfig {
|
|
13
|
+
* analytics: AnalyticsConfig
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function defineAppConfig(config) {
|
|
19
|
+
return config;
|
|
3
20
|
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defineAppConfig };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BackgroundDefinition } from "../types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/define-background.d.ts
|
|
4
|
+
declare function defineBackground(main: () => void): BackgroundDefinition;
|
|
5
|
+
declare function defineBackground(definition: BackgroundDefinition): BackgroundDefinition;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { defineBackground };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/utils/define-background.ts
|
|
2
|
+
function defineBackground(arg) {
|
|
3
|
+
if (arg == null || typeof arg === "function") return { main: arg };
|
|
4
|
+
return arg;
|
|
4
5
|
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { defineBackground };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UnlistedScriptDefinition } from "../types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/define-unlisted-script.d.ts
|
|
4
|
+
declare function defineUnlistedScript(main: () => void): UnlistedScriptDefinition;
|
|
5
|
+
declare function defineUnlistedScript(definition: UnlistedScriptDefinition): UnlistedScriptDefinition;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { defineUnlistedScript };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/utils/define-unlisted-script.ts
|
|
2
|
+
function defineUnlistedScript(arg) {
|
|
3
|
+
if (arg == null || typeof arg === "function") return { main: arg };
|
|
4
|
+
return arg;
|
|
4
5
|
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { defineUnlistedScript };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as wxt_browser0 from "wxt/browser";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/inject-script.d.ts
|
|
4
|
+
type ScriptPublicPath = Extract<wxt_browser0.PublicPath, `${string}.js`>;
|
|
5
|
+
/**
|
|
6
|
+
* This function can only be called inside content scripts.
|
|
7
|
+
*
|
|
8
|
+
* Inject an unlisted script into the page. Scripts are added to the `<head>`
|
|
9
|
+
* element or `document.documentElement` if there is no head.
|
|
10
|
+
*
|
|
11
|
+
* Make sure to add the injected script to your manifest's
|
|
12
|
+
* `web_accessible_resources`.
|
|
13
|
+
*
|
|
14
|
+
* @returns A result object containing the created script element.
|
|
15
|
+
*/
|
|
16
|
+
declare function injectScript(path: ScriptPublicPath, options?: InjectScriptOptions): Promise<InjectScriptResult>;
|
|
17
|
+
interface InjectScriptOptions {
|
|
18
|
+
/**
|
|
19
|
+
* By default, the injected script is removed from the DOM after being
|
|
20
|
+
* injected. To disable this behavior, set this flag to true.
|
|
21
|
+
*/
|
|
22
|
+
keepInDom?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Modify the script element just before it is added to the DOM.
|
|
25
|
+
*
|
|
26
|
+
* It can be used to e.g. modify `script.async`/`script.defer`, add event
|
|
27
|
+
* listeners to the element, or pass data to the script via `script.dataset`
|
|
28
|
+
* (which can be accessed by the script via `document.currentScript`).
|
|
29
|
+
*/
|
|
30
|
+
modifyScript?: (script: HTMLScriptElement) => Promise<void> | void;
|
|
31
|
+
}
|
|
32
|
+
interface InjectScriptResult {
|
|
33
|
+
/**
|
|
34
|
+
* The created script element. It can be used to e.g. send messages to the
|
|
35
|
+
* script in the form of custom events. The script can add an event listener
|
|
36
|
+
* for them via `document.currentScript`.
|
|
37
|
+
*/
|
|
38
|
+
script: HTMLScriptElement;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { InjectScriptOptions, InjectScriptResult, ScriptPublicPath, injectScript };
|
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
import { browser } from "wxt/browser";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/utils/inject-script.ts
|
|
4
|
+
/** @module wxt/utils/inject-script */
|
|
5
|
+
/**
|
|
6
|
+
* This function can only be called inside content scripts.
|
|
7
|
+
*
|
|
8
|
+
* Inject an unlisted script into the page. Scripts are added to the `<head>`
|
|
9
|
+
* element or `document.documentElement` if there is no head.
|
|
10
|
+
*
|
|
11
|
+
* Make sure to add the injected script to your manifest's
|
|
12
|
+
* `web_accessible_resources`.
|
|
13
|
+
*
|
|
14
|
+
* @returns A result object containing the created script element.
|
|
15
|
+
*/
|
|
16
|
+
async function injectScript(path, options) {
|
|
17
|
+
const url = browser.runtime.getURL(path);
|
|
18
|
+
const script = document.createElement("script");
|
|
19
|
+
if (browser.runtime.getManifest().manifest_version === 2) script.text = await fetch(url).then((res) => res.text());
|
|
20
|
+
else script.src = url;
|
|
21
|
+
const loadedPromise = makeLoadedPromise(script);
|
|
22
|
+
await options?.modifyScript?.(script);
|
|
23
|
+
(document.head ?? document.documentElement).append(script);
|
|
24
|
+
if (!options?.keepInDom) script.remove();
|
|
25
|
+
await loadedPromise;
|
|
26
|
+
return { script };
|
|
20
27
|
}
|
|
21
28
|
function makeLoadedPromise(script) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const onload = () => {
|
|
31
|
+
resolve();
|
|
32
|
+
cleanup();
|
|
33
|
+
};
|
|
34
|
+
const onerror = () => {
|
|
35
|
+
reject(/* @__PURE__ */ new Error(`Failed to load script: ${script.src}`));
|
|
36
|
+
cleanup();
|
|
37
|
+
};
|
|
38
|
+
const cleanup = () => {
|
|
39
|
+
script.removeEventListener("load", onload);
|
|
40
|
+
script.removeEventListener("error", onerror);
|
|
41
|
+
};
|
|
42
|
+
script.addEventListener("load", onload);
|
|
43
|
+
script.addEventListener("error", onerror);
|
|
44
|
+
});
|
|
38
45
|
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { injectScript };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/internal/custom-events.d.ts
|
|
2
|
+
declare class WxtLocationChangeEvent extends Event {
|
|
3
|
+
readonly newUrl: URL;
|
|
4
|
+
readonly oldUrl: URL;
|
|
5
|
+
static EVENT_NAME: string;
|
|
6
|
+
constructor(newUrl: URL, oldUrl: URL);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { WxtLocationChangeEvent };
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { browser } from "wxt/browser";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/utils/internal/custom-events.ts
|
|
4
|
+
var WxtLocationChangeEvent = class WxtLocationChangeEvent extends Event {
|
|
5
|
+
static EVENT_NAME = getUniqueEventName("wxt:locationchange");
|
|
6
|
+
constructor(newUrl, oldUrl) {
|
|
7
|
+
super(WxtLocationChangeEvent.EVENT_NAME, {});
|
|
8
|
+
this.newUrl = newUrl;
|
|
9
|
+
this.oldUrl = oldUrl;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns an event name unique to the extension and content script that's running.
|
|
14
|
+
*/
|
|
15
|
+
function getUniqueEventName(eventName) {
|
|
16
|
+
return `${browser?.runtime?.id}:${import.meta.env.ENTRYPOINT}:${eventName}`;
|
|
12
17
|
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { WxtLocationChangeEvent, getUniqueEventName };
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { WxtLocationChangeEvent } from "./custom-events.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/utils/internal/location-watcher.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a util that watches for URL changes, dispatching the custom event when detected. Stops
|
|
6
|
+
* watching when content script is invalidated.
|
|
7
|
+
*/
|
|
8
|
+
function createLocationWatcher(ctx) {
|
|
9
|
+
let interval;
|
|
10
|
+
let oldUrl;
|
|
11
|
+
return { run() {
|
|
12
|
+
if (interval != null) return;
|
|
13
|
+
oldUrl = new URL(location.href);
|
|
14
|
+
interval = ctx.setInterval(() => {
|
|
15
|
+
let newUrl = new URL(location.href);
|
|
16
|
+
if (newUrl.href !== oldUrl.href) {
|
|
17
|
+
window.dispatchEvent(new WxtLocationChangeEvent(newUrl, oldUrl));
|
|
18
|
+
oldUrl = newUrl;
|
|
19
|
+
}
|
|
20
|
+
}, 1e3);
|
|
21
|
+
} };
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { createLocationWatcher };
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
//#region src/utils/internal/logger.ts
|
|
1
2
|
function print(method, ...args) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
method(`[wxt] ${message}`, ...args);
|
|
6
|
-
} else {
|
|
7
|
-
method("[wxt]", ...args);
|
|
8
|
-
}
|
|
3
|
+
if (import.meta.env.MODE === "production") return;
|
|
4
|
+
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
5
|
+
else method("[wxt]", ...args);
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper around `console` with a "[wxt]" prefix
|
|
9
|
+
*/
|
|
10
|
+
const logger = {
|
|
11
|
+
debug: (...args) => print(console.debug, ...args),
|
|
12
|
+
log: (...args) => print(console.log, ...args),
|
|
13
|
+
warn: (...args) => print(console.warn, ...args),
|
|
14
|
+
error: (...args) => print(console.error, ...args)
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { logger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webext-core/match-patterns";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/utils/split-shadow-root-css.d.ts
|
|
1
2
|
/** @module wxt/utils/split-shadow-root-css */
|
|
2
3
|
/**
|
|
3
4
|
* Given a CSS string that will be loaded into a shadow root, split it into two parts:
|
|
@@ -5,7 +6,9 @@
|
|
|
5
6
|
* - `shadowCss`: CSS that needs to be applied to the shadow root
|
|
6
7
|
* @param css
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
declare function splitShadowRootCss(css: string): {
|
|
10
|
+
documentCss: string;
|
|
11
|
+
shadowCss: string;
|
|
11
12
|
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { splitShadowRootCss };
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
//#region src/utils/split-shadow-root-css.ts
|
|
2
|
+
/** @module wxt/utils/split-shadow-root-css */
|
|
1
3
|
const AT_RULE_BLOCKS = /(\s*@(property|font-face)[\s\S]*?{[\s\S]*?})/gm;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Given a CSS string that will be loaded into a shadow root, split it into two parts:
|
|
6
|
+
* - `documentCss`: CSS that needs to be applied to the document (like `@property`)
|
|
7
|
+
* - `shadowCss`: CSS that needs to be applied to the shadow root
|
|
8
|
+
* @param css
|
|
9
|
+
*/
|
|
10
|
+
function splitShadowRootCss(css) {
|
|
11
|
+
return {
|
|
12
|
+
documentCss: Array.from(css.matchAll(AT_RULE_BLOCKS), (m) => m[0]).join("").trim(),
|
|
13
|
+
shadowCss: css.replace(AT_RULE_BLOCKS, "").trim()
|
|
14
|
+
};
|
|
9
15
|
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { splitShadowRootCss };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@wxt-dev/storage";
|
package/dist/utils/storage.mjs
CHANGED
package/dist/version.mjs
CHANGED