wxt 0.20.18 → 0.20.20
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/bin/wxt-publish-extension.mjs +4 -3
- package/dist/browser.d.mts +7 -6
- package/dist/browser.mjs +6 -5
- package/dist/builtin-modules/index.mjs +1 -3
- package/dist/builtin-modules/unimport.mjs +1 -3
- package/dist/cli/cli-utils.mjs +5 -6
- package/dist/cli/commands.mjs +1 -3
- package/dist/cli/index.mjs +1 -3
- package/dist/core/build.d.mts +9 -8
- package/dist/core/build.mjs +10 -11
- package/dist/core/builders/vite/index.mjs +27 -25
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +1 -3
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +6 -6
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +3 -4
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +33 -25
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +3 -3
- package/dist/core/builders/vite/plugins/download.mjs +15 -11
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +2 -6
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +13 -8
- package/dist/core/builders/vite/plugins/globals.mjs +1 -3
- package/dist/core/builders/vite/plugins/iifeAnonymous.mjs +1 -2
- package/dist/core/builders/vite/plugins/iifeFooter.mjs +14 -7
- package/dist/core/builders/vite/plugins/index.mjs +18 -19
- package/dist/core/builders/vite/plugins/noopBackground.mjs +14 -9
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +10 -12
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +14 -10
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +15 -13
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +1 -2
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +22 -17
- package/dist/core/clean.d.mts +7 -7
- package/dist/core/clean.mjs +6 -7
- package/dist/core/create-server.d.mts +6 -5
- package/dist/core/create-server.mjs +12 -11
- package/dist/core/define-config.mjs +1 -2
- package/dist/core/define-web-ext-config.d.mts +3 -4
- package/dist/core/define-web-ext-config.mjs +4 -7
- package/dist/core/generate-wxt-dir.mjs +8 -9
- package/dist/core/index.mjs +10 -11
- package/dist/core/initialize.mjs +10 -11
- package/dist/core/keyboard-shortcuts.mjs +2 -6
- package/dist/core/package-managers/bun.mjs +1 -3
- package/dist/core/package-managers/deno.mjs +1 -2
- package/dist/core/package-managers/index.mjs +1 -3
- package/dist/core/package-managers/npm.mjs +3 -5
- package/dist/core/package-managers/pnpm.mjs +1 -3
- package/dist/core/package-managers/yarn.mjs +1 -3
- package/dist/core/prepare.mjs +1 -3
- package/dist/core/resolve-config.mjs +20 -23
- package/dist/core/runners/index.mjs +1 -3
- package/dist/core/runners/manual.mjs +2 -6
- package/dist/core/runners/safari.mjs +3 -4
- package/dist/core/runners/web-ext.mjs +2 -6
- package/dist/core/runners/wsl.mjs +3 -4
- package/dist/core/utils/arrays.mjs +4 -11
- package/dist/core/utils/building/build-entrypoints.mjs +8 -9
- package/dist/core/utils/building/detect-dev-changes.mjs +21 -13
- package/dist/core/utils/building/find-entrypoints.mjs +16 -11
- package/dist/core/utils/building/group-entrypoints.mjs +3 -4
- package/dist/core/utils/building/index.mjs +7 -8
- package/dist/core/utils/building/internal-build.mjs +13 -13
- package/dist/core/utils/building/rebuild.mjs +10 -10
- package/dist/core/utils/cache.mjs +6 -8
- package/dist/core/utils/constants.mjs +3 -4
- package/dist/core/utils/content-scripts.mjs +3 -4
- package/dist/core/utils/content-security-policy.mjs +2 -5
- package/dist/core/utils/entrypoints.mjs +6 -10
- package/dist/core/utils/env.mjs +2 -6
- package/dist/core/utils/environments/browser-environment.mjs +1 -3
- package/dist/core/utils/environments/environment.mjs +1 -2
- package/dist/core/utils/environments/extension-environment.mjs +1 -3
- package/dist/core/utils/environments/index.mjs +3 -4
- package/dist/core/utils/eslint.mjs +1 -2
- package/dist/core/utils/fs.mjs +23 -14
- package/dist/core/utils/globals.mjs +1 -2
- package/dist/core/utils/i18n.mjs +1 -2
- package/dist/core/utils/index.mjs +2 -3
- package/dist/core/utils/log/index.mjs +5 -6
- package/dist/core/utils/log/printBuildSummary.mjs +1 -3
- package/dist/core/utils/log/printFileList.mjs +3 -5
- package/dist/core/utils/log/printHeader.mjs +1 -3
- package/dist/core/utils/log/printTable.mjs +1 -2
- package/dist/core/utils/manifest.mjs +23 -31
- package/dist/core/utils/minimatch-multiple.mjs +5 -7
- package/dist/core/utils/network.mjs +3 -5
- package/dist/core/utils/number.mjs +1 -2
- package/dist/core/utils/package.mjs +3 -5
- package/dist/core/utils/paths.d.mts +2 -2
- package/dist/core/utils/paths.mjs +7 -9
- package/dist/core/utils/strings.mjs +4 -7
- package/dist/core/utils/syntax-errors.mjs +1 -3
- package/dist/core/utils/time.mjs +2 -5
- package/dist/core/utils/transform.mjs +8 -6
- package/dist/core/utils/validation.mjs +1 -2
- package/dist/core/utils/virtual-modules.mjs +9 -15
- package/dist/core/utils/wsl.mjs +2 -6
- package/dist/core/wxt.mjs +7 -9
- package/dist/core/zip.d.mts +1 -0
- package/dist/core/zip.mjs +11 -10
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +1 -2
- package/dist/modules.d.mts +64 -61
- package/dist/modules.mjs +70 -66
- package/dist/testing/fake-browser.mjs +1 -2
- package/dist/testing/index.mjs +1 -2
- package/dist/testing/wxt-vitest-plugin.d.mts +4 -2
- package/dist/testing/wxt-vitest-plugin.mjs +5 -5
- package/dist/types.d.mts +455 -435
- package/dist/utils/app-config.mjs +1 -3
- package/dist/utils/content-script-context.d.mts +49 -39
- package/dist/utils/content-script-context.mjs +36 -31
- package/dist/utils/content-script-ui/iframe.d.mts +12 -13
- package/dist/utils/content-script-ui/iframe.mjs +1 -3
- package/dist/utils/content-script-ui/integrated.d.mts +8 -7
- package/dist/utils/content-script-ui/integrated.mjs +1 -3
- package/dist/utils/content-script-ui/shadow-root.d.mts +37 -25
- package/dist/utils/content-script-ui/shadow-root.mjs +4 -7
- package/dist/utils/content-script-ui/shared.mjs +1 -3
- package/dist/utils/content-script-ui/types.d.mts +29 -34
- package/dist/utils/content-script-ui/types.mjs +1 -1
- package/dist/utils/define-app-config.d.mts +4 -3
- package/dist/utils/define-app-config.mjs +5 -5
- package/dist/utils/define-background.mjs +1 -2
- package/dist/utils/define-content-script.mjs +1 -2
- package/dist/utils/define-unlisted-script.mjs +1 -2
- package/dist/utils/define-wxt-plugin.mjs +1 -2
- package/dist/utils/inject-script.mjs +1 -3
- package/dist/utils/internal/custom-events.mjs +3 -4
- package/dist/utils/internal/location-watcher.mjs +4 -6
- package/dist/utils/internal/logger.mjs +2 -5
- package/dist/utils/match-patterns.mjs +2 -3
- package/dist/utils/split-shadow-root-css.d.mts +6 -2
- package/dist/utils/split-shadow-root-css.mjs +7 -4
- package/dist/utils/storage.mjs +2 -3
- package/dist/version.mjs +2 -3
- package/dist/virtual/background-entrypoint.mjs +4 -16
- package/dist/virtual/content-script-isolated-world-entrypoint.mjs +2 -7
- package/dist/virtual/content-script-main-world-entrypoint.mjs +2 -7
- package/dist/virtual/mock-browser.mjs +1 -3
- package/dist/virtual/reload-html.mjs +3 -10
- package/dist/virtual/unlisted-script-entrypoint.mjs +2 -7
- package/package.json +17 -19
|
@@ -5,17 +5,19 @@ interface ContentScriptUi<TMounted> extends MountFunctions {
|
|
|
5
5
|
}
|
|
6
6
|
type ContentScriptUiOptions<TMounted> = ContentScriptPositioningOptions & ContentScriptAnchoredOptions & {
|
|
7
7
|
/**
|
|
8
|
-
* Callback called before the UI is removed from the webpage. Use to cleanup
|
|
9
|
-
* unmounting your Vue or React apps.
|
|
8
|
+
* Callback called before the UI is removed from the webpage. Use to cleanup
|
|
9
|
+
* your UI, like unmounting your Vue or React apps.
|
|
10
10
|
*
|
|
11
|
-
* Note that this callback is called only when `ui.remove` is called - that
|
|
12
|
-
* not called automatically when the anchor is removed, unless
|
|
11
|
+
* Note that this callback is called only when `ui.remove` is called - that
|
|
12
|
+
* means it is not called automatically when the anchor is removed, unless
|
|
13
|
+
* you use `autoMount`.
|
|
13
14
|
*/
|
|
14
15
|
onRemove?: (mounted: TMounted | undefined) => void;
|
|
15
16
|
};
|
|
16
17
|
type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* [Visualization of different append
|
|
20
|
+
* modes](https://wxt.dev/content-script-ui-append.png)
|
|
19
21
|
*/
|
|
20
22
|
type ContentScriptAppendMode = 'last' | 'first' | 'replace' | 'before' | 'after' | ((anchor: Element, ui: Element) => void);
|
|
21
23
|
interface ContentScriptInlinePositioningOptions {
|
|
@@ -24,38 +26,41 @@ interface ContentScriptInlinePositioningOptions {
|
|
|
24
26
|
interface ContentScriptOverlayPositioningOptions {
|
|
25
27
|
position: 'overlay';
|
|
26
28
|
/**
|
|
27
|
-
* The `z-index` used on the `wrapper` element. Set to a positive number to
|
|
28
|
-
* content.
|
|
29
|
+
* The `z-index` used on the `wrapper` element. Set to a positive number to
|
|
30
|
+
* show your UI over website content.
|
|
29
31
|
*/
|
|
30
32
|
zIndex?: number;
|
|
31
33
|
/**
|
|
32
|
-
* When using `type: "overlay"`, the mounted element is 0px by 0px in size.
|
|
33
|
-
* which corner is aligned with that 0x0 pixel space.
|
|
34
|
+
* When using `type: "overlay"`, the mounted element is 0px by 0px in size.
|
|
35
|
+
* Alignment specifies which corner is aligned with that 0x0 pixel space.
|
|
34
36
|
*
|
|
35
|
-
*
|
|
37
|
+
* [Visualization of alignment
|
|
38
|
+
* options](https://wxt.dev/content-script-ui-alignment.png)
|
|
36
39
|
*
|
|
37
|
-
* @default
|
|
40
|
+
* @default 'top-left'
|
|
38
41
|
*/
|
|
39
42
|
alignment?: ContentScriptOverlayAlignment;
|
|
40
43
|
}
|
|
41
44
|
interface ContentScriptModalPositioningOptions {
|
|
42
45
|
position: 'modal';
|
|
43
46
|
/**
|
|
44
|
-
* The `z-index` used on the `shadowHost`. Set to a positive number to show
|
|
45
|
-
* content.
|
|
47
|
+
* The `z-index` used on the `shadowHost`. Set to a positive number to show
|
|
48
|
+
* your UI over website content.
|
|
46
49
|
*/
|
|
47
50
|
zIndex?: number;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* Choose between `"inline"`, `"overlay"`, or `"modal"` positions.
|
|
51
54
|
*
|
|
52
|
-
*
|
|
55
|
+
* [Visualization of different
|
|
56
|
+
* types](https://wxt.dev/content-script-ui-position.png)
|
|
53
57
|
*/
|
|
54
58
|
type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
|
|
55
59
|
interface ContentScriptAnchoredOptions {
|
|
56
60
|
/**
|
|
57
|
-
* A CSS selector, XPath expression, element, or function that returns one of
|
|
58
|
-
* `anchor` dictates where in the page the
|
|
61
|
+
* A CSS selector, XPath expression, element, or function that returns one of
|
|
62
|
+
* the three. Along with `append`, the `anchor` dictates where in the page the
|
|
63
|
+
* UI will be added.
|
|
59
64
|
*/
|
|
60
65
|
anchor?: string | Element | null | undefined | (() => string | Element | null | undefined);
|
|
61
66
|
/**
|
|
@@ -66,41 +71,31 @@ interface ContentScriptAnchoredOptions {
|
|
|
66
71
|
* - `"replace"` - Replace the `anchor` element with the UI.
|
|
67
72
|
* - `"before"` - Add the UI as the sibling before the `anchor` element
|
|
68
73
|
* - `"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
|
|
74
|
+
* - `(anchor, ui) => void` - Customizable function that let's you add the UI to
|
|
75
|
+
* the DOM
|
|
70
76
|
*/
|
|
71
77
|
append?: ContentScriptAppendMode | ((anchor: Element, ui: Element) => void);
|
|
72
78
|
}
|
|
73
79
|
interface BaseMountFunctions {
|
|
74
|
-
/**
|
|
75
|
-
* Function that mounts or remounts the UI on the page.
|
|
76
|
-
*/
|
|
80
|
+
/** Function that mounts or remounts the UI on the page. */
|
|
77
81
|
mount: () => void;
|
|
78
|
-
/**
|
|
79
|
-
* Function that removes the UI from the webpage.
|
|
80
|
-
*/
|
|
82
|
+
/** Function that removes the UI from the webpage. */
|
|
81
83
|
remove: () => void;
|
|
82
84
|
}
|
|
83
85
|
interface MountFunctions extends BaseMountFunctions {
|
|
84
86
|
/**
|
|
85
|
-
* Call `ui.autoMount()` to automatically mount and remove the UI as the
|
|
87
|
+
* Call `ui.autoMount()` to automatically mount and remove the UI as the
|
|
88
|
+
* anchor is dynamically added/removed by the webpage.
|
|
86
89
|
*/
|
|
87
90
|
autoMount: (options?: AutoMountOptions) => void;
|
|
88
91
|
}
|
|
89
92
|
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
|
-
*/
|
|
93
|
+
/** When true, only mount and unmount a UI once. */once?: boolean; /** The callback triggered when `StopAutoMount` is called. */
|
|
97
94
|
onStop?: () => void;
|
|
98
95
|
};
|
|
99
96
|
type StopAutoMount = () => void;
|
|
100
97
|
interface AutoMount {
|
|
101
|
-
/**
|
|
102
|
-
* Stop watching the anchor element for changes, but keep the UI mounted.
|
|
103
|
-
*/
|
|
98
|
+
/** Stop watching the anchor element for changes, but keep the UI mounted. */
|
|
104
99
|
stopAutoMount: StopAutoMount;
|
|
105
100
|
}
|
|
106
101
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
@@ -4,15 +4,16 @@ interface WxtAppConfig {}
|
|
|
4
4
|
/**
|
|
5
5
|
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
6
6
|
*
|
|
7
|
-
* You can add fields to this interface via ["Module
|
|
7
|
+
* You can add fields to this interface via ["Module
|
|
8
|
+
* Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
|
|
8
9
|
*
|
|
9
10
|
* ```ts
|
|
10
11
|
* // app.config.ts
|
|
11
12
|
* import 'wxt/utils/define-app-config';
|
|
12
13
|
*
|
|
13
|
-
* declare module
|
|
14
|
+
* declare module 'wxt/utils/define-app-config' {
|
|
14
15
|
* export interface WxtAppConfig {
|
|
15
|
-
* analytics: AnalyticsConfig
|
|
16
|
+
* analytics: AnalyticsConfig;
|
|
16
17
|
* }
|
|
17
18
|
* }
|
|
18
19
|
* ```
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
4
4
|
*
|
|
5
|
-
* You can add fields to this interface via ["Module
|
|
5
|
+
* You can add fields to this interface via ["Module
|
|
6
|
+
* Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
|
|
6
7
|
*
|
|
7
8
|
* ```ts
|
|
8
9
|
* // app.config.ts
|
|
9
10
|
* import 'wxt/utils/define-app-config';
|
|
10
11
|
*
|
|
11
|
-
* declare module
|
|
12
|
+
* declare module 'wxt/utils/define-app-config' {
|
|
12
13
|
* export interface WxtAppConfig {
|
|
13
|
-
* analytics: AnalyticsConfig
|
|
14
|
+
* analytics: AnalyticsConfig;
|
|
14
15
|
* }
|
|
15
16
|
* }
|
|
16
17
|
* ```
|
|
@@ -18,6 +19,5 @@
|
|
|
18
19
|
function defineAppConfig(config) {
|
|
19
20
|
return config;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
22
|
//#endregion
|
|
23
|
-
export { defineAppConfig };
|
|
23
|
+
export { defineAppConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { browser } from "wxt/browser";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/inject-script.ts
|
|
4
3
|
/** @module wxt/utils/inject-script */
|
|
5
4
|
/**
|
|
@@ -43,6 +42,5 @@ function makeLoadedPromise(script) {
|
|
|
43
42
|
script.addEventListener("error", onerror);
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
|
-
export { injectScript };
|
|
46
|
+
export { injectScript };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { browser } from "wxt/browser";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/internal/custom-events.ts
|
|
4
3
|
var WxtLocationChangeEvent = class WxtLocationChangeEvent extends Event {
|
|
5
4
|
static EVENT_NAME = getUniqueEventName("wxt:locationchange");
|
|
@@ -10,11 +9,11 @@ var WxtLocationChangeEvent = class WxtLocationChangeEvent extends Event {
|
|
|
10
9
|
}
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
13
|
-
* Returns an event name unique to the extension and content script that's
|
|
12
|
+
* Returns an event name unique to the extension and content script that's
|
|
13
|
+
* running.
|
|
14
14
|
*/
|
|
15
15
|
function getUniqueEventName(eventName) {
|
|
16
16
|
return `${browser?.runtime?.id}:${import.meta.env.ENTRYPOINT}:${eventName}`;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
//#endregion
|
|
20
|
-
export { WxtLocationChangeEvent, getUniqueEventName };
|
|
19
|
+
export { WxtLocationChangeEvent, getUniqueEventName };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { WxtLocationChangeEvent } from "./custom-events.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/internal/location-watcher.ts
|
|
4
3
|
const supportsNavigationApi = typeof globalThis.navigation?.addEventListener === "function";
|
|
5
4
|
/**
|
|
6
|
-
* Create a util that watches for URL changes, dispatching the custom event when
|
|
7
|
-
* watching when content script is invalidated. Uses Navigation
|
|
8
|
-
* falls back to polling.
|
|
5
|
+
* Create a util that watches for URL changes, dispatching the custom event when
|
|
6
|
+
* detected. Stops watching when content script is invalidated. Uses Navigation
|
|
7
|
+
* API when available, otherwise falls back to polling.
|
|
9
8
|
*/
|
|
10
9
|
function createLocationWatcher(ctx) {
|
|
11
10
|
let lastUrl;
|
|
@@ -29,6 +28,5 @@ function createLocationWatcher(ctx) {
|
|
|
29
28
|
}, 1e3);
|
|
30
29
|
} };
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
//#endregion
|
|
34
|
-
export { createLocationWatcher };
|
|
32
|
+
export { createLocationWatcher };
|
|
@@ -4,15 +4,12 @@ function print(method, ...args) {
|
|
|
4
4
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
5
5
|
else method("[wxt]", ...args);
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
9
|
-
*/
|
|
7
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
10
8
|
const logger = {
|
|
11
9
|
debug: (...args) => print(console.debug, ...args),
|
|
12
10
|
log: (...args) => print(console.log, ...args),
|
|
13
11
|
warn: (...args) => print(console.warn, ...args),
|
|
14
12
|
error: (...args) => print(console.error, ...args)
|
|
15
13
|
};
|
|
16
|
-
|
|
17
14
|
//#endregion
|
|
18
|
-
export { logger };
|
|
15
|
+
export { logger };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "@webext-core/match-patterns"
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
export * from "@webext-core/match-patterns";
|
|
2
|
+
export {};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
//#region src/utils/split-shadow-root-css.d.ts
|
|
2
2
|
/** @module wxt/utils/split-shadow-root-css */
|
|
3
3
|
/**
|
|
4
|
-
* Given a CSS string that will be loaded into a shadow root, split it into two
|
|
5
|
-
*
|
|
4
|
+
* Given a CSS string that will be loaded into a shadow root, split it into two
|
|
5
|
+
* parts:
|
|
6
|
+
*
|
|
7
|
+
* - `documentCss`: CSS that needs to be applied to the document (like
|
|
8
|
+
* `@property`)
|
|
6
9
|
* - `shadowCss`: CSS that needs to be applied to the shadow root
|
|
10
|
+
*
|
|
7
11
|
* @param css
|
|
8
12
|
*/
|
|
9
13
|
declare function splitShadowRootCss(css: string): {
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
/** @module wxt/utils/split-shadow-root-css */
|
|
3
3
|
const AT_RULE_BLOCKS = /(\s*@(property|font-face)[\s\S]*?{[\s\S]*?})/gm;
|
|
4
4
|
/**
|
|
5
|
-
* Given a CSS string that will be loaded into a shadow root, split it into two
|
|
6
|
-
*
|
|
5
|
+
* Given a CSS string that will be loaded into a shadow root, split it into two
|
|
6
|
+
* parts:
|
|
7
|
+
*
|
|
8
|
+
* - `documentCss`: CSS that needs to be applied to the document (like
|
|
9
|
+
* `@property`)
|
|
7
10
|
* - `shadowCss`: CSS that needs to be applied to the shadow root
|
|
11
|
+
*
|
|
8
12
|
* @param css
|
|
9
13
|
*/
|
|
10
14
|
function splitShadowRootCss(css) {
|
|
@@ -13,6 +17,5 @@ function splitShadowRootCss(css) {
|
|
|
13
17
|
shadowCss: css.replace(AT_RULE_BLOCKS, "").trim()
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
|
-
|
|
17
20
|
//#endregion
|
|
18
|
-
export { splitShadowRootCss };
|
|
21
|
+
export { splitShadowRootCss };
|
package/dist/utils/storage.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "@wxt-dev/storage"
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
export * from "@wxt-dev/storage";
|
|
2
|
+
export {};
|
package/dist/version.mjs
CHANGED
|
@@ -2,29 +2,23 @@ import definition from "virtual:user-background-entrypoint";
|
|
|
2
2
|
import { initPlugins } from "virtual:wxt-plugins";
|
|
3
3
|
import { browser } from "wxt/browser";
|
|
4
4
|
import { MatchPattern } from "wxt/utils/match-patterns";
|
|
5
|
-
|
|
6
5
|
//#region src/utils/internal/logger.ts
|
|
7
6
|
function print(method, ...args) {
|
|
8
7
|
if (import.meta.env.MODE === "production") return;
|
|
9
8
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
10
9
|
else method("[wxt]", ...args);
|
|
11
10
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
14
|
-
*/
|
|
11
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
15
12
|
const logger = {
|
|
16
13
|
debug: (...args) => print(console.debug, ...args),
|
|
17
14
|
log: (...args) => print(console.log, ...args),
|
|
18
15
|
warn: (...args) => print(console.warn, ...args),
|
|
19
16
|
error: (...args) => print(console.error, ...args)
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
//#endregion
|
|
23
19
|
//#region src/utils/internal/dev-server-websocket.ts
|
|
24
20
|
let ws;
|
|
25
|
-
/**
|
|
26
|
-
* Connect to the websocket and listen for messages.
|
|
27
|
-
*/
|
|
21
|
+
/** Connect to the websocket and listen for messages. */
|
|
28
22
|
function getDevServerWebSocket() {
|
|
29
23
|
if (import.meta.env.COMMAND !== "serve") throw Error("Must be running WXT dev command to connect to call getDevServerWebSocket()");
|
|
30
24
|
if (ws == null) {
|
|
@@ -57,18 +51,14 @@ function getDevServerWebSocket() {
|
|
|
57
51
|
}
|
|
58
52
|
return ws;
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
//#endregion
|
|
62
55
|
//#region src/virtual/utils/keep-service-worker-alive.ts
|
|
63
|
-
/**
|
|
64
|
-
* https://developer.chrome.com/blog/longer-esw-lifetimes/
|
|
65
|
-
*/
|
|
56
|
+
/** https://developer.chrome.com/blog/longer-esw-lifetimes/ */
|
|
66
57
|
function keepServiceWorkerAlive() {
|
|
67
58
|
setInterval(async () => {
|
|
68
59
|
await browser.runtime.getPlatformInfo();
|
|
69
60
|
}, 5e3);
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
//#endregion
|
|
73
63
|
//#region src/virtual/utils/reload-content-scripts.ts
|
|
74
64
|
function reloadContentScript(payload) {
|
|
@@ -137,7 +127,6 @@ async function reloadTabsForContentScript(contentScript) {
|
|
|
137
127
|
async function reloadContentScriptMv2(_payload) {
|
|
138
128
|
throw Error("TODO: reloadContentScriptMv2");
|
|
139
129
|
}
|
|
140
|
-
|
|
141
130
|
//#endregion
|
|
142
131
|
//#region src/virtual/background-entrypoint.ts
|
|
143
132
|
if (import.meta.env.COMMAND === "serve") {
|
|
@@ -170,6 +159,5 @@ try {
|
|
|
170
159
|
throw err;
|
|
171
160
|
}
|
|
172
161
|
var background_entrypoint_default = result;
|
|
173
|
-
|
|
174
162
|
//#endregion
|
|
175
|
-
export { background_entrypoint_default as default };
|
|
163
|
+
export { background_entrypoint_default as default };
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import definition from "virtual:user-content-script-isolated-world-entrypoint";
|
|
2
2
|
import { ContentScriptContext } from "wxt/utils/content-script-context";
|
|
3
3
|
import { initPlugins } from "virtual:wxt-plugins";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/internal/logger.ts
|
|
6
5
|
function print(method, ...args) {
|
|
7
6
|
if (import.meta.env.MODE === "production") return;
|
|
8
7
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
9
8
|
else method("[wxt]", ...args);
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
13
|
-
*/
|
|
10
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
14
11
|
const logger = {
|
|
15
12
|
debug: (...args) => print(console.debug, ...args),
|
|
16
13
|
log: (...args) => print(console.log, ...args),
|
|
17
14
|
warn: (...args) => print(console.warn, ...args),
|
|
18
15
|
error: (...args) => print(console.error, ...args)
|
|
19
16
|
};
|
|
20
|
-
|
|
21
17
|
//#endregion
|
|
22
18
|
//#region src/virtual/content-script-isolated-world-entrypoint.ts
|
|
23
19
|
const result = (async () => {
|
|
@@ -30,6 +26,5 @@ const result = (async () => {
|
|
|
30
26
|
throw err;
|
|
31
27
|
}
|
|
32
28
|
})();
|
|
33
|
-
|
|
34
29
|
//#endregion
|
|
35
|
-
export { result as default };
|
|
30
|
+
export { result as default };
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import definition from "virtual:user-content-script-main-world-entrypoint";
|
|
2
2
|
import { initPlugins } from "virtual:wxt-plugins";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/internal/logger.ts
|
|
5
4
|
function print(method, ...args) {
|
|
6
5
|
if (import.meta.env.MODE === "production") return;
|
|
7
6
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
8
7
|
else method("[wxt]", ...args);
|
|
9
8
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
12
|
-
*/
|
|
9
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
13
10
|
const logger = {
|
|
14
11
|
debug: (...args) => print(console.debug, ...args),
|
|
15
12
|
log: (...args) => print(console.log, ...args),
|
|
16
13
|
warn: (...args) => print(console.warn, ...args),
|
|
17
14
|
error: (...args) => print(console.error, ...args)
|
|
18
15
|
};
|
|
19
|
-
|
|
20
16
|
//#endregion
|
|
21
17
|
//#region src/virtual/content-script-main-world-entrypoint.ts
|
|
22
18
|
const result = (async () => {
|
|
@@ -28,6 +24,5 @@ const result = (async () => {
|
|
|
28
24
|
throw err;
|
|
29
25
|
}
|
|
30
26
|
})();
|
|
31
|
-
|
|
32
27
|
//#endregion
|
|
33
|
-
export { result as default };
|
|
28
|
+
export { result as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { fakeBrowser } from "wxt/testing";
|
|
2
|
-
|
|
3
2
|
//#region src/virtual/mock-browser.ts
|
|
4
3
|
const browser = fakeBrowser;
|
|
5
4
|
var mock_browser_default = fakeBrowser;
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
|
-
export { browser, mock_browser_default as default };
|
|
6
|
+
export { browser, mock_browser_default as default };
|
|
@@ -4,22 +4,17 @@ function print(method, ...args) {
|
|
|
4
4
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
5
5
|
else method("[wxt]", ...args);
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
9
|
-
*/
|
|
7
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
10
8
|
const logger = {
|
|
11
9
|
debug: (...args) => print(console.debug, ...args),
|
|
12
10
|
log: (...args) => print(console.log, ...args),
|
|
13
11
|
warn: (...args) => print(console.warn, ...args),
|
|
14
12
|
error: (...args) => print(console.error, ...args)
|
|
15
13
|
};
|
|
16
|
-
|
|
17
14
|
//#endregion
|
|
18
15
|
//#region src/utils/internal/dev-server-websocket.ts
|
|
19
16
|
let ws;
|
|
20
|
-
/**
|
|
21
|
-
* Connect to the websocket and listen for messages.
|
|
22
|
-
*/
|
|
17
|
+
/** Connect to the websocket and listen for messages. */
|
|
23
18
|
function getDevServerWebSocket() {
|
|
24
19
|
if (import.meta.env.COMMAND !== "serve") throw Error("Must be running WXT dev command to connect to call getDevServerWebSocket()");
|
|
25
20
|
if (ws == null) {
|
|
@@ -52,7 +47,6 @@ function getDevServerWebSocket() {
|
|
|
52
47
|
}
|
|
53
48
|
return ws;
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
//#endregion
|
|
57
51
|
//#region src/virtual/reload-html.ts
|
|
58
52
|
if (import.meta.env.COMMAND === "serve") try {
|
|
@@ -62,6 +56,5 @@ if (import.meta.env.COMMAND === "serve") try {
|
|
|
62
56
|
} catch (err) {
|
|
63
57
|
logger.error("Failed to setup web socket connection with dev server", err);
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
//#endregion
|
|
67
|
-
export {
|
|
60
|
+
export {};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import definition from "virtual:user-unlisted-script-entrypoint";
|
|
2
2
|
import { initPlugins } from "virtual:wxt-plugins";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/internal/logger.ts
|
|
5
4
|
function print(method, ...args) {
|
|
6
5
|
if (import.meta.env.MODE === "production") return;
|
|
7
6
|
if (typeof args[0] === "string") method(`[wxt] ${args.shift()}`, ...args);
|
|
8
7
|
else method("[wxt]", ...args);
|
|
9
8
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Wrapper around `console` with a "[wxt]" prefix
|
|
12
|
-
*/
|
|
9
|
+
/** Wrapper around `console` with a "[wxt]" prefix */
|
|
13
10
|
const logger = {
|
|
14
11
|
debug: (...args) => print(console.debug, ...args),
|
|
15
12
|
log: (...args) => print(console.log, ...args),
|
|
16
13
|
warn: (...args) => print(console.warn, ...args),
|
|
17
14
|
error: (...args) => print(console.error, ...args)
|
|
18
15
|
};
|
|
19
|
-
|
|
20
16
|
//#endregion
|
|
21
17
|
//#region src/virtual/unlisted-script-entrypoint.ts
|
|
22
18
|
const result = (() => {
|
|
@@ -39,6 +35,5 @@ const result = (() => {
|
|
|
39
35
|
}
|
|
40
36
|
return result;
|
|
41
37
|
})();
|
|
42
|
-
|
|
43
38
|
//#endregion
|
|
44
|
-
export { result as default };
|
|
39
|
+
export { result as default };
|