wxt 0.19.29 → 0.20.0-beta2
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.ts +30 -0
- package/dist/browser.mjs +3 -0
- package/dist/builtin-modules/unimport.mjs +29 -10
- package/dist/cli/index.mjs +0 -1
- package/dist/core/builders/vite/index.mjs +17 -37
- package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +1 -6
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +2 -4
- package/dist/core/builders/vite/plugins/index.d.ts +0 -1
- package/dist/core/builders/vite/plugins/index.mjs +0 -1
- package/dist/core/builders/vite/plugins/noopBackground.mjs +1 -1
- package/dist/core/define-web-ext-config.d.ts +9 -0
- package/dist/core/define-web-ext-config.mjs +10 -0
- package/dist/core/generate-wxt-dir.mjs +3 -6
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/core/resolve-config.mjs +142 -49
- package/dist/core/utils/building/index.d.ts +0 -1
- package/dist/core/utils/building/index.mjs +0 -1
- package/dist/core/utils/building/rebuild.d.ts +2 -2
- package/dist/core/utils/content-scripts.d.ts +4 -3
- package/dist/core/utils/content-scripts.mjs +2 -0
- package/dist/core/utils/manifest.d.ts +4 -8
- package/dist/core/utils/manifest.mjs +4 -7
- package/dist/core/utils/strings.d.ts +0 -4
- package/dist/core/utils/strings.mjs +0 -6
- package/dist/core/utils/testing/fake-objects.d.ts +3376 -1013
- package/dist/core/utils/testing/fake-objects.mjs +19 -22
- package/dist/core/utils/transform.d.ts +1 -1
- package/dist/core/utils/types.d.ts +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/modules.d.ts +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/wxt-vitest-plugin.mjs +1 -3
- package/dist/types.d.ts +42 -76
- package/dist/utils/app-config.d.ts +2 -0
- package/dist/{client/content-scripts → utils}/content-script-context.d.ts +4 -3
- package/dist/{client/content-scripts → utils}/content-script-context.mjs +5 -3
- package/dist/utils/content-script-ui/iframe.d.ts +32 -0
- package/dist/utils/content-script-ui/iframe.mjs +30 -0
- package/dist/utils/content-script-ui/integrated.d.ts +34 -0
- package/dist/utils/content-script-ui/integrated.mjs +32 -0
- package/dist/utils/content-script-ui/shadow-root.d.ts +76 -0
- package/dist/utils/content-script-ui/shadow-root.mjs +73 -0
- package/dist/utils/content-script-ui/shared.d.ts +5 -0
- package/dist/{client/content-scripts/ui/index.mjs → utils/content-script-ui/shared.mjs} +5 -138
- package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.d.ts +1 -96
- package/dist/{sandbox → utils}/define-app-config.d.ts +3 -2
- package/dist/{sandbox → utils}/define-background.d.ts +1 -0
- package/dist/{sandbox → utils}/define-content-script.d.ts +1 -0
- package/dist/{sandbox → utils}/define-unlisted-script.d.ts +1 -0
- package/dist/{sandbox → utils}/define-wxt-plugin.d.ts +1 -0
- package/dist/{sandbox → utils/internal}/dev-server-websocket.mjs +1 -1
- package/dist/{client/content-scripts → utils/internal}/location-watcher.d.ts +1 -1
- package/dist/utils/match-patterns.d.ts +5 -0
- package/dist/utils/match-patterns.mjs +1 -0
- package/dist/utils/storage.d.ts +5 -0
- package/dist/version.mjs +1 -1
- package/dist/virtual/background-entrypoint.mjs +1 -1
- package/dist/virtual/content-script-isolated-world-entrypoint.mjs +1 -1
- package/package.json +109 -76
- package/dist/browser/chrome.d.ts +0 -13
- package/dist/browser/chrome.mjs +0 -7
- package/dist/browser/index.d.ts +0 -26
- package/dist/browser/index.mjs +0 -2
- package/dist/client/app-config.d.ts +0 -2
- package/dist/client/content-scripts/index.d.ts +0 -2
- package/dist/client/content-scripts/index.mjs +0 -2
- package/dist/client/content-scripts/ui/index.d.ts +0 -23
- package/dist/client/index.d.ts +0 -8
- package/dist/client/index.mjs +0 -3
- package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +0 -10
- package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +0 -15
- package/dist/core/define-runner-config.d.ts +0 -2
- package/dist/core/define-runner-config.mjs +0 -3
- package/dist/core/utils/building/import-entrypoint.d.ts +0 -16
- package/dist/core/utils/building/import-entrypoint.mjs +0 -99
- package/dist/sandbox/index.d.ts +0 -11
- package/dist/sandbox/index.mjs +0 -6
- package/dist/storage.d.ts +0 -4
- /package/dist/{client → utils}/app-config.mjs +0 -0
- /package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.mjs +0 -0
- /package/dist/{sandbox → utils}/define-app-config.mjs +0 -0
- /package/dist/{sandbox → utils}/define-background.mjs +0 -0
- /package/dist/{sandbox → utils}/define-content-script.mjs +0 -0
- /package/dist/{sandbox → utils}/define-unlisted-script.mjs +0 -0
- /package/dist/{sandbox → utils}/define-wxt-plugin.mjs +0 -0
- /package/dist/{client → utils}/inject-script.d.ts +0 -0
- /package/dist/{client → utils}/inject-script.mjs +0 -0
- /package/dist/{client/content-scripts → utils/internal}/custom-events.d.ts +0 -0
- /package/dist/{client/content-scripts → utils/internal}/custom-events.mjs +0 -0
- /package/dist/{sandbox → utils/internal}/dev-server-websocket.d.ts +0 -0
- /package/dist/{client/content-scripts → utils/internal}/location-watcher.mjs +0 -0
- /package/dist/{sandbox/utils → utils/internal}/logger.d.ts +0 -0
- /package/dist/{sandbox/utils → utils/internal}/logger.mjs +0 -0
- /package/dist/{storage.mjs → utils/storage.mjs} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { browser } from "wxt/browser";
|
|
2
|
+
import { createIsolatedElement } from "@webext-core/isolated-element";
|
|
3
|
+
import { applyPosition, createMountFunctions, mountUi } from "./shared.mjs";
|
|
4
|
+
import { logger } from "../internal/logger.mjs";
|
|
5
|
+
export async function createShadowRootUi(ctx, options) {
|
|
6
|
+
const css = [];
|
|
7
|
+
if (!options.inheritStyles) {
|
|
8
|
+
css.push(`/* WXT Shadow Root Reset */ body{all:initial;}`);
|
|
9
|
+
}
|
|
10
|
+
if (options.css) {
|
|
11
|
+
css.push(options.css);
|
|
12
|
+
}
|
|
13
|
+
if (ctx.options?.cssInjectionMode === "ui") {
|
|
14
|
+
const entryCss = await loadCss();
|
|
15
|
+
css.push(entryCss.replaceAll(":root", ":host"));
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
isolatedElement: uiContainer,
|
|
19
|
+
parentElement: shadowHost,
|
|
20
|
+
shadow
|
|
21
|
+
} = await createIsolatedElement({
|
|
22
|
+
name: options.name,
|
|
23
|
+
css: {
|
|
24
|
+
textContent: css.join("\n").trim()
|
|
25
|
+
},
|
|
26
|
+
mode: options.mode ?? "open",
|
|
27
|
+
isolateEvents: options.isolateEvents
|
|
28
|
+
});
|
|
29
|
+
shadowHost.setAttribute("data-wxt-shadow-root", "");
|
|
30
|
+
let mounted;
|
|
31
|
+
const mount = () => {
|
|
32
|
+
mountUi(shadowHost, options);
|
|
33
|
+
applyPosition(shadowHost, shadow.querySelector("html"), options);
|
|
34
|
+
mounted = options.onMount(uiContainer, shadow, shadowHost);
|
|
35
|
+
};
|
|
36
|
+
const remove = () => {
|
|
37
|
+
options.onRemove?.(mounted);
|
|
38
|
+
shadowHost.remove();
|
|
39
|
+
while (uiContainer.lastChild)
|
|
40
|
+
uiContainer.removeChild(uiContainer.lastChild);
|
|
41
|
+
mounted = void 0;
|
|
42
|
+
};
|
|
43
|
+
const mountFunctions = createMountFunctions(
|
|
44
|
+
{
|
|
45
|
+
mount,
|
|
46
|
+
remove
|
|
47
|
+
},
|
|
48
|
+
options
|
|
49
|
+
);
|
|
50
|
+
ctx.onInvalidated(remove);
|
|
51
|
+
return {
|
|
52
|
+
shadow,
|
|
53
|
+
shadowHost,
|
|
54
|
+
uiContainer,
|
|
55
|
+
...mountFunctions,
|
|
56
|
+
get mounted() {
|
|
57
|
+
return mounted;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function loadCss() {
|
|
62
|
+
const url = browser.runtime.getURL(`/content-scripts/${import.meta.env.ENTRYPOINT}.css`);
|
|
63
|
+
try {
|
|
64
|
+
const res = await fetch(url);
|
|
65
|
+
return await res.text();
|
|
66
|
+
} catch (err) {
|
|
67
|
+
logger.warn(
|
|
68
|
+
`Failed to load styles @ ${url}. Did you forget to import the stylesheet in your entrypoint?`,
|
|
69
|
+
err
|
|
70
|
+
);
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentScriptAnchoredOptions, ContentScriptPositioningOptions, BaseMountFunctions, ContentScriptUiOptions, MountFunctions } from './types';
|
|
2
|
+
export declare function applyPosition(root: HTMLElement, positionedElement: HTMLElement | undefined | null, options: ContentScriptPositioningOptions): void;
|
|
3
|
+
export declare function getAnchor(options: ContentScriptAnchoredOptions): Element | undefined;
|
|
4
|
+
export declare function mountUi(root: HTMLElement, options: ContentScriptAnchoredOptions): void;
|
|
5
|
+
export declare function createMountFunctions<TMounted>(baseFunctions: BaseMountFunctions, options: ContentScriptUiOptions<TMounted>): MountFunctions;
|
|
@@ -1,128 +1,10 @@
|
|
|
1
|
-
import { browser } from "wxt/browser";
|
|
2
1
|
import { waitElement } from "@1natsu/wait-element";
|
|
3
2
|
import {
|
|
4
3
|
isExist as mountDetector,
|
|
5
4
|
isNotExist as removeDetector
|
|
6
5
|
} from "@1natsu/wait-element/detectors";
|
|
7
|
-
import { logger } from "
|
|
8
|
-
|
|
9
|
-
export * from "./types.mjs";
|
|
10
|
-
export function createIntegratedUi(ctx, options) {
|
|
11
|
-
const wrapper = document.createElement(options.tag || "div");
|
|
12
|
-
wrapper.setAttribute("data-wxt-integrated", "");
|
|
13
|
-
let mounted = void 0;
|
|
14
|
-
const mount = () => {
|
|
15
|
-
applyPosition(wrapper, void 0, options);
|
|
16
|
-
mountUi(wrapper, options);
|
|
17
|
-
mounted = options.onMount?.(wrapper);
|
|
18
|
-
};
|
|
19
|
-
const remove = () => {
|
|
20
|
-
options.onRemove?.(mounted);
|
|
21
|
-
wrapper.replaceChildren();
|
|
22
|
-
wrapper.remove();
|
|
23
|
-
mounted = void 0;
|
|
24
|
-
};
|
|
25
|
-
const mountFunctions = createMountFunctions(
|
|
26
|
-
{
|
|
27
|
-
mount,
|
|
28
|
-
remove
|
|
29
|
-
},
|
|
30
|
-
options
|
|
31
|
-
);
|
|
32
|
-
ctx.onInvalidated(remove);
|
|
33
|
-
return {
|
|
34
|
-
get mounted() {
|
|
35
|
-
return mounted;
|
|
36
|
-
},
|
|
37
|
-
wrapper,
|
|
38
|
-
...mountFunctions
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export function createIframeUi(ctx, options) {
|
|
42
|
-
const wrapper = document.createElement("div");
|
|
43
|
-
wrapper.setAttribute("data-wxt-iframe", "");
|
|
44
|
-
const iframe = document.createElement("iframe");
|
|
45
|
-
iframe.src = browser.runtime.getURL(options.page);
|
|
46
|
-
wrapper.appendChild(iframe);
|
|
47
|
-
let mounted = void 0;
|
|
48
|
-
const mount = () => {
|
|
49
|
-
applyPosition(wrapper, iframe, options);
|
|
50
|
-
mountUi(wrapper, options);
|
|
51
|
-
mounted = options.onMount?.(wrapper, iframe);
|
|
52
|
-
};
|
|
53
|
-
const remove = () => {
|
|
54
|
-
options.onRemove?.(mounted);
|
|
55
|
-
wrapper.remove();
|
|
56
|
-
mounted = void 0;
|
|
57
|
-
};
|
|
58
|
-
const mountFunctions = createMountFunctions(
|
|
59
|
-
{
|
|
60
|
-
mount,
|
|
61
|
-
remove
|
|
62
|
-
},
|
|
63
|
-
options
|
|
64
|
-
);
|
|
65
|
-
ctx.onInvalidated(remove);
|
|
66
|
-
return {
|
|
67
|
-
get mounted() {
|
|
68
|
-
return mounted;
|
|
69
|
-
},
|
|
70
|
-
iframe,
|
|
71
|
-
wrapper,
|
|
72
|
-
...mountFunctions
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export async function createShadowRootUi(ctx, options) {
|
|
76
|
-
const css = [options.css ?? ""];
|
|
77
|
-
if (ctx.options?.cssInjectionMode === "ui") {
|
|
78
|
-
const entryCss = await loadCss();
|
|
79
|
-
css.push(entryCss.replaceAll(":root", ":host"));
|
|
80
|
-
}
|
|
81
|
-
const {
|
|
82
|
-
isolatedElement: uiContainer,
|
|
83
|
-
parentElement: shadowHost,
|
|
84
|
-
shadow
|
|
85
|
-
} = await createIsolatedElement({
|
|
86
|
-
name: options.name,
|
|
87
|
-
css: {
|
|
88
|
-
textContent: css.join("\n").trim()
|
|
89
|
-
},
|
|
90
|
-
mode: options.mode ?? "open",
|
|
91
|
-
isolateEvents: options.isolateEvents
|
|
92
|
-
});
|
|
93
|
-
shadowHost.setAttribute("data-wxt-shadow-root", "");
|
|
94
|
-
let mounted;
|
|
95
|
-
const mount = () => {
|
|
96
|
-
mountUi(shadowHost, options);
|
|
97
|
-
applyPosition(shadowHost, shadow.querySelector("html"), options);
|
|
98
|
-
mounted = options.onMount(uiContainer, shadow, shadowHost);
|
|
99
|
-
};
|
|
100
|
-
const remove = () => {
|
|
101
|
-
options.onRemove?.(mounted);
|
|
102
|
-
shadowHost.remove();
|
|
103
|
-
while (uiContainer.lastChild)
|
|
104
|
-
uiContainer.removeChild(uiContainer.lastChild);
|
|
105
|
-
mounted = void 0;
|
|
106
|
-
};
|
|
107
|
-
const mountFunctions = createMountFunctions(
|
|
108
|
-
{
|
|
109
|
-
mount,
|
|
110
|
-
remove
|
|
111
|
-
},
|
|
112
|
-
options
|
|
113
|
-
);
|
|
114
|
-
ctx.onInvalidated(remove);
|
|
115
|
-
return {
|
|
116
|
-
shadow,
|
|
117
|
-
shadowHost,
|
|
118
|
-
uiContainer,
|
|
119
|
-
...mountFunctions,
|
|
120
|
-
get mounted() {
|
|
121
|
-
return mounted;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function applyPosition(root, positionedElement, options) {
|
|
6
|
+
import { logger } from "../../utils/internal/logger.mjs";
|
|
7
|
+
export function applyPosition(root, positionedElement, options) {
|
|
126
8
|
if (options.position === "inline") return;
|
|
127
9
|
if (options.zIndex != null) root.style.zIndex = String(options.zIndex);
|
|
128
10
|
root.style.overflow = "visible";
|
|
@@ -148,7 +30,7 @@ function applyPosition(root, positionedElement, options) {
|
|
|
148
30
|
}
|
|
149
31
|
}
|
|
150
32
|
}
|
|
151
|
-
function getAnchor(options) {
|
|
33
|
+
export function getAnchor(options) {
|
|
152
34
|
if (options.anchor == null) return document.body;
|
|
153
35
|
let resolved = typeof options.anchor === "function" ? options.anchor() : options.anchor;
|
|
154
36
|
if (typeof resolved === "string") {
|
|
@@ -167,7 +49,7 @@ function getAnchor(options) {
|
|
|
167
49
|
}
|
|
168
50
|
return resolved ?? void 0;
|
|
169
51
|
}
|
|
170
|
-
function mountUi(root, options) {
|
|
52
|
+
export function mountUi(root, options) {
|
|
171
53
|
const anchor = getAnchor(options);
|
|
172
54
|
if (anchor == null)
|
|
173
55
|
throw Error(
|
|
@@ -195,7 +77,7 @@ function mountUi(root, options) {
|
|
|
195
77
|
break;
|
|
196
78
|
}
|
|
197
79
|
}
|
|
198
|
-
function createMountFunctions(baseFunctions, options) {
|
|
80
|
+
export function createMountFunctions(baseFunctions, options) {
|
|
199
81
|
let autoMountInstance = void 0;
|
|
200
82
|
const stopAutoMount = () => {
|
|
201
83
|
autoMountInstance?.stopAutoMount();
|
|
@@ -273,18 +155,3 @@ function autoMountUi(uiCallbacks, options) {
|
|
|
273
155
|
observeElement(resolvedAnchor);
|
|
274
156
|
return { stopAutoMount: _stopAutoMount };
|
|
275
157
|
}
|
|
276
|
-
async function loadCss() {
|
|
277
|
-
const url = browser.runtime.getURL(
|
|
278
|
-
`/content-scripts/${import.meta.env.ENTRYPOINT}.css`
|
|
279
|
-
);
|
|
280
|
-
try {
|
|
281
|
-
const res = await fetch(url);
|
|
282
|
-
return await res.text();
|
|
283
|
-
} catch (err) {
|
|
284
|
-
logger.warn(
|
|
285
|
-
`Failed to load styles @ ${url}. Did you forget to import the stylesheet in your entrypoint?`,
|
|
286
|
-
err
|
|
287
|
-
);
|
|
288
|
-
return "";
|
|
289
|
-
}
|
|
290
|
-
}
|
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A wrapper div that assists in positioning.
|
|
4
|
-
*/
|
|
5
|
-
wrapper: HTMLElement;
|
|
6
|
-
}
|
|
7
|
-
export interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
8
|
-
/**
|
|
9
|
-
* The iframe added to the DOM.
|
|
10
|
-
*/
|
|
11
|
-
iframe: HTMLIFrameElement;
|
|
12
|
-
/**
|
|
13
|
-
* A wrapper div that assists in positioning.
|
|
14
|
-
*/
|
|
15
|
-
wrapper: HTMLDivElement;
|
|
16
|
-
}
|
|
17
|
-
export interface ShadowRootContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
18
|
-
/**
|
|
19
|
-
* The `HTMLElement` hosting the shadow root used to isolate the UI's styles. This is the element
|
|
20
|
-
* that get's added to the DOM. This element's style is not isolated from the webpage.
|
|
21
|
-
*/
|
|
22
|
-
shadowHost: HTMLElement;
|
|
23
|
-
/**
|
|
24
|
-
* The container element inside the `ShadowRoot` whose styles are isolated. The UI is mounted
|
|
25
|
-
* inside this `HTMLElement`.
|
|
26
|
-
*/
|
|
27
|
-
uiContainer: HTMLElement;
|
|
28
|
-
/**
|
|
29
|
-
* The shadow root performing the isolation.
|
|
30
|
-
*/
|
|
31
|
-
shadow: ShadowRoot;
|
|
32
|
-
}
|
|
1
|
+
/** @module wxt/utils/content-script-ui/types */
|
|
33
2
|
export interface ContentScriptUi<TMounted> extends MountFunctions {
|
|
34
3
|
mounted: TMounted | undefined;
|
|
35
4
|
}
|
|
@@ -40,70 +9,6 @@ export type ContentScriptUiOptions<TMounted> = ContentScriptPositioningOptions &
|
|
|
40
9
|
*/
|
|
41
10
|
onRemove?: (mounted: TMounted | undefined) => void;
|
|
42
11
|
};
|
|
43
|
-
export type IntegratedContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
44
|
-
/**
|
|
45
|
-
* Tag used to create the wrapper element.
|
|
46
|
-
*
|
|
47
|
-
* @default "div"
|
|
48
|
-
*/
|
|
49
|
-
tag?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Callback executed when mounting the UI. This function should create and append the UI to the
|
|
52
|
-
* `wrapper` element. It is called every time `ui.mount()` is called.
|
|
53
|
-
*
|
|
54
|
-
* Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
|
|
55
|
-
*/
|
|
56
|
-
onMount: (wrapper: HTMLElement) => TMounted;
|
|
57
|
-
};
|
|
58
|
-
export type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
59
|
-
/**
|
|
60
|
-
* The path to the HTML page that will be shown in the iframe. This string is passed into
|
|
61
|
-
* `browser.runtime.getURL`.
|
|
62
|
-
*/
|
|
63
|
-
page: import('wxt/browser').HtmlPublicPath;
|
|
64
|
-
/**
|
|
65
|
-
* Callback executed when mounting the UI. Use this function to customize the iframe or wrapper
|
|
66
|
-
* element's appearance. It is called every time `ui.mount()` is called.
|
|
67
|
-
*
|
|
68
|
-
* Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
|
|
69
|
-
*/
|
|
70
|
-
onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
|
|
71
|
-
};
|
|
72
|
-
export type ShadowRootContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
|
|
73
|
-
/**
|
|
74
|
-
* The name of the custom component used to host the ShadowRoot. Must be kebab-case.
|
|
75
|
-
*/
|
|
76
|
-
name: string;
|
|
77
|
-
/**
|
|
78
|
-
* Custom CSS text to apply to the UI. If your content script imports/generates CSS and you've
|
|
79
|
-
* set `cssInjectionMode: "ui"`, the imported CSS will be included automatically. You do not need
|
|
80
|
-
* to pass those styles in here. This is for any additional styles not in the imported CSS.
|
|
81
|
-
*/
|
|
82
|
-
css?: string;
|
|
83
|
-
/**
|
|
84
|
-
* ShadowRoot's mode.
|
|
85
|
-
*
|
|
86
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/mode
|
|
87
|
-
* @default "open"
|
|
88
|
-
*/
|
|
89
|
-
mode?: 'open' | 'closed';
|
|
90
|
-
/**
|
|
91
|
-
* When enabled, `event.stopPropagation` will be called on events trying to bubble out of the
|
|
92
|
-
* shadow root.
|
|
93
|
-
*
|
|
94
|
-
* - Set to `true` to stop the propagation of a default set of events,
|
|
95
|
-
* `["keyup", "keydown", "keypress"]`
|
|
96
|
-
* - Set to an array of event names to stop the propagation of a custom list of events
|
|
97
|
-
*/
|
|
98
|
-
isolateEvents?: boolean | string[];
|
|
99
|
-
/**
|
|
100
|
-
* Callback executed when mounting the UI. This function should create and append the UI to the
|
|
101
|
-
* `uiContainer` element. It is called every time `ui.mount()` is called.
|
|
102
|
-
*
|
|
103
|
-
* Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
|
|
104
|
-
*/
|
|
105
|
-
onMount: (uiContainer: HTMLElement, shadow: ShadowRoot, shadowHost: HTMLElement) => TMounted;
|
|
106
|
-
};
|
|
107
12
|
export type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
108
13
|
/**
|
|
109
14
|
* 
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module wxt/utils/define-app-config */
|
|
1
2
|
export interface WxtAppConfig {
|
|
2
3
|
}
|
|
3
4
|
/**
|
|
@@ -7,9 +8,9 @@ export interface WxtAppConfig {
|
|
|
7
8
|
*
|
|
8
9
|
* ```ts
|
|
9
10
|
* // app.config.ts
|
|
10
|
-
* import 'wxt/
|
|
11
|
+
* import 'wxt/utils/define-app-config';
|
|
11
12
|
*
|
|
12
|
-
* declare module "wxt/
|
|
13
|
+
* declare module "wxt/utils/define-app-config" {
|
|
13
14
|
* export interface WxtAppConfig {
|
|
14
15
|
* analytics: AnalyticsConfig
|
|
15
16
|
* }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module wxt/utils/define-background */
|
|
1
2
|
import type { BackgroundDefinition } from '../types';
|
|
2
3
|
export declare function defineBackground(main: () => void): BackgroundDefinition;
|
|
3
4
|
export declare function defineBackground(definition: BackgroundDefinition): BackgroundDefinition;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module wxt/utils/define-unlisted-script */
|
|
1
2
|
import type { UnlistedScriptDefinition } from '../types';
|
|
2
3
|
export declare function defineUnlistedScript(main: () => void): UnlistedScriptDefinition;
|
|
3
4
|
export declare function defineUnlistedScript(definition: UnlistedScriptDefinition): UnlistedScriptDefinition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webext-core/match-patterns";
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.
|
|
1
|
+
export const version = "0.20.0-beta2";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import definition from 'virtual:user-background-entrypoint';
|
|
2
2
|
import { initPlugins } from 'virtual:wxt-plugins';
|
|
3
3
|
import { browser } from 'wxt/browser';
|
|
4
|
-
import { MatchPattern } from 'wxt/
|
|
4
|
+
import { MatchPattern } from 'wxt/utils/match-patterns';
|
|
5
5
|
|
|
6
6
|
function print(method, ...args) {
|
|
7
7
|
if (import.meta.env.MODE === "production") return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import definition from 'virtual:user-content-script-isolated-world-entrypoint';
|
|
2
|
-
import { ContentScriptContext } from 'wxt/
|
|
2
|
+
import { ContentScriptContext } from 'wxt/utils/content-script-context';
|
|
3
3
|
import { initPlugins } from 'virtual:wxt-plugins';
|
|
4
4
|
|
|
5
5
|
function print(method, ...args) {
|
package/package.json
CHANGED
|
@@ -1,80 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0-beta2",
|
|
5
5
|
"description": "⚡ Next-gen Web Extension Framework",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/wxt-dev/wxt.git"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://wxt.dev",
|
|
11
|
-
"keywords": [
|
|
12
|
-
"vite",
|
|
13
|
-
"chrome",
|
|
14
|
-
"web",
|
|
15
|
-
"extension",
|
|
16
|
-
"browser",
|
|
17
|
-
"bundler",
|
|
18
|
-
"framework"
|
|
19
|
-
],
|
|
20
|
-
"author": {
|
|
21
|
-
"name": "Aaron Klinker",
|
|
22
|
-
"email": "aaronklinker1+wxt@gmail.com"
|
|
23
|
-
},
|
|
24
6
|
"license": "MIT",
|
|
25
|
-
"funding": "https://github.com/sponsors/wxt-dev",
|
|
26
|
-
"files": [
|
|
27
|
-
"bin",
|
|
28
|
-
"dist"
|
|
29
|
-
],
|
|
30
|
-
"bin": {
|
|
31
|
-
"wxt": "./bin/wxt.mjs",
|
|
32
|
-
"wxt-publish-extension": "./bin/wxt-publish-extension.cjs"
|
|
33
|
-
},
|
|
34
|
-
"module": "./dist/index.mjs",
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
|
-
"exports": {
|
|
37
|
-
".": {
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
|
-
"default": "./dist/index.mjs"
|
|
40
|
-
},
|
|
41
|
-
"./client": {
|
|
42
|
-
"types": "./dist/client/index.d.ts",
|
|
43
|
-
"default": "./dist/client/index.mjs"
|
|
44
|
-
},
|
|
45
|
-
"./sandbox": {
|
|
46
|
-
"types": "./dist/sandbox/index.d.ts",
|
|
47
|
-
"default": "./dist/sandbox/index.mjs"
|
|
48
|
-
},
|
|
49
|
-
"./browser": {
|
|
50
|
-
"types": "./dist/browser/index.d.ts",
|
|
51
|
-
"default": "./dist/browser/index.mjs"
|
|
52
|
-
},
|
|
53
|
-
"./browser/chrome": {
|
|
54
|
-
"types": "./dist/browser/chrome.d.ts",
|
|
55
|
-
"import": "./dist/browser/chrome.mjs"
|
|
56
|
-
},
|
|
57
|
-
"./testing": {
|
|
58
|
-
"types": "./dist/testing/index.d.ts",
|
|
59
|
-
"default": "./dist/testing/index.mjs"
|
|
60
|
-
},
|
|
61
|
-
"./storage": {
|
|
62
|
-
"types": "./dist/storage.d.ts",
|
|
63
|
-
"default": "./dist/storage.mjs"
|
|
64
|
-
},
|
|
65
|
-
"./vite-builder-env": {
|
|
66
|
-
"types": "./dist/vite-builder-env.d.ts"
|
|
67
|
-
},
|
|
68
|
-
"./modules": {
|
|
69
|
-
"types": "./dist/modules.d.ts",
|
|
70
|
-
"default": "./dist/modules.mjs"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
7
|
"dependencies": {
|
|
74
8
|
"@1natsu/wait-element": "^4.1.2",
|
|
75
9
|
"@aklinker1/rollup-plugin-visualizer": "5.12.0",
|
|
76
|
-
"@types/chrome": "^0.0.280",
|
|
77
|
-
"@types/webextension-polyfill": "^0.12.1",
|
|
78
10
|
"@webext-core/fake-browser": "^1.3.1",
|
|
79
11
|
"@webext-core/isolated-element": "^1.1.2",
|
|
80
12
|
"@webext-core/match-patterns": "^1.0.3",
|
|
@@ -93,11 +25,10 @@
|
|
|
93
25
|
"filesize": "^10.1.6",
|
|
94
26
|
"fs-extra": "^11.2.0",
|
|
95
27
|
"get-port-please": "^3.1.2",
|
|
96
|
-
"giget": "^1.2.3",
|
|
28
|
+
"giget": "^1.2.3 || ^2.0.0",
|
|
97
29
|
"hookable": "^5.5.3",
|
|
98
30
|
"import-meta-resolve": "^4.1.0",
|
|
99
31
|
"is-wsl": "^3.1.0",
|
|
100
|
-
"jiti": "^2.4.2",
|
|
101
32
|
"json5": "^2.2.3",
|
|
102
33
|
"jszip": "^3.10.1",
|
|
103
34
|
"linkedom": "^0.18.5",
|
|
@@ -114,11 +45,11 @@
|
|
|
114
45
|
"prompts": "^2.4.2",
|
|
115
46
|
"publish-browser-extension": "^2.3.0 || ^3.0.0",
|
|
116
47
|
"scule": "^1.3.0",
|
|
117
|
-
"unimport": "^3.13.1",
|
|
48
|
+
"unimport": "^3.13.1 || ^4.0.0",
|
|
118
49
|
"vite": "^5.0.0 || ^6.0.0",
|
|
119
50
|
"vite-node": "^2.1.4 || ^3.0.0",
|
|
120
51
|
"web-ext-run": "^0.2.1",
|
|
121
|
-
"
|
|
52
|
+
"@wxt-dev/browser": "0.0.310"
|
|
122
53
|
},
|
|
123
54
|
"devDependencies": {
|
|
124
55
|
"@aklinker1/check": "^1.4.5",
|
|
@@ -138,9 +69,111 @@
|
|
|
138
69
|
"vitest": "^3.0.7",
|
|
139
70
|
"vitest-plugin-random-seed": "^1.1.1"
|
|
140
71
|
},
|
|
141
|
-
"peerDependenciesMeta": {
|
|
142
|
-
|
|
143
|
-
|
|
72
|
+
"peerDependenciesMeta": {},
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "git+https://github.com/wxt-dev/wxt.git"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://wxt.dev",
|
|
78
|
+
"keywords": [
|
|
79
|
+
"vite",
|
|
80
|
+
"chrome",
|
|
81
|
+
"web",
|
|
82
|
+
"extension",
|
|
83
|
+
"browser",
|
|
84
|
+
"bundler",
|
|
85
|
+
"framework"
|
|
86
|
+
],
|
|
87
|
+
"author": {
|
|
88
|
+
"name": "Aaron Klinker",
|
|
89
|
+
"email": "aaronklinker1+wxt@gmail.com"
|
|
90
|
+
},
|
|
91
|
+
"funding": "https://github.com/sponsors/wxt-dev",
|
|
92
|
+
"files": [
|
|
93
|
+
"bin",
|
|
94
|
+
"dist"
|
|
95
|
+
],
|
|
96
|
+
"bin": {
|
|
97
|
+
"wxt": "./bin/wxt.mjs",
|
|
98
|
+
"wxt-publish-extension": "./bin/wxt-publish-extension.cjs"
|
|
99
|
+
},
|
|
100
|
+
"module": "./dist/index.mjs",
|
|
101
|
+
"types": "./dist/index.d.ts",
|
|
102
|
+
"exports": {
|
|
103
|
+
".": {
|
|
104
|
+
"types": "./dist/index.d.ts",
|
|
105
|
+
"default": "./dist/index.mjs"
|
|
106
|
+
},
|
|
107
|
+
"./utils/app-config": {
|
|
108
|
+
"types": "./dist/utils/app-config.d.ts",
|
|
109
|
+
"default": "./dist/utils/app-config.mjs"
|
|
110
|
+
},
|
|
111
|
+
"./utils/inject-script": {
|
|
112
|
+
"types": "./dist/utils/inject-script.d.ts",
|
|
113
|
+
"default": "./dist/utils/inject-script.mjs"
|
|
114
|
+
},
|
|
115
|
+
"./utils/content-script-context": {
|
|
116
|
+
"types": "./dist/utils/content-script-context.d.ts",
|
|
117
|
+
"default": "./dist/utils/content-script-context.mjs"
|
|
118
|
+
},
|
|
119
|
+
"./utils/content-script-ui/types": {
|
|
120
|
+
"types": "./dist/utils/content-script-ui/types.d.ts",
|
|
121
|
+
"default": "./dist/utils/content-script-ui/types.mjs"
|
|
122
|
+
},
|
|
123
|
+
"./utils/content-script-ui/integrated": {
|
|
124
|
+
"types": "./dist/utils/content-script-ui/integrated.d.ts",
|
|
125
|
+
"default": "./dist/utils/content-script-ui/integrated.mjs"
|
|
126
|
+
},
|
|
127
|
+
"./utils/content-script-ui/shadow-root": {
|
|
128
|
+
"types": "./dist/utils/content-script-ui/shadow-root.d.ts",
|
|
129
|
+
"default": "./dist/utils/content-script-ui/shadow-root.mjs"
|
|
130
|
+
},
|
|
131
|
+
"./utils/content-script-ui/iframe": {
|
|
132
|
+
"types": "./dist/utils/content-script-ui/iframe.d.ts",
|
|
133
|
+
"default": "./dist/utils/content-script-ui/iframe.mjs"
|
|
134
|
+
},
|
|
135
|
+
"./utils/define-app-config": {
|
|
136
|
+
"types": "./dist/utils/define-app-config.d.ts",
|
|
137
|
+
"default": "./dist/utils/define-app-config.mjs"
|
|
138
|
+
},
|
|
139
|
+
"./utils/define-background": {
|
|
140
|
+
"types": "./dist/utils/define-background.d.ts",
|
|
141
|
+
"default": "./dist/utils/define-background.mjs"
|
|
142
|
+
},
|
|
143
|
+
"./utils/define-content-script": {
|
|
144
|
+
"types": "./dist/utils/define-content-script.d.ts",
|
|
145
|
+
"default": "./dist/utils/define-content-script.mjs"
|
|
146
|
+
},
|
|
147
|
+
"./utils/define-unlisted-script": {
|
|
148
|
+
"types": "./dist/utils/define-unlisted-script.d.ts",
|
|
149
|
+
"default": "./dist/utils/define-unlisted-script.mjs"
|
|
150
|
+
},
|
|
151
|
+
"./utils/define-wxt-plugin": {
|
|
152
|
+
"types": "./dist/utils/define-wxt-plugin.d.ts",
|
|
153
|
+
"default": "./dist/utils/define-wxt-plugin.mjs"
|
|
154
|
+
},
|
|
155
|
+
"./utils/match-patterns": {
|
|
156
|
+
"types": "./dist/utils/match-patterns.d.ts",
|
|
157
|
+
"default": "./dist/utils/match-patterns.mjs"
|
|
158
|
+
},
|
|
159
|
+
"./utils/storage": {
|
|
160
|
+
"types": "./dist/utils/storage.d.ts",
|
|
161
|
+
"default": "./dist/utils/storage.mjs"
|
|
162
|
+
},
|
|
163
|
+
"./browser": {
|
|
164
|
+
"types": "./dist/browser.d.ts",
|
|
165
|
+
"default": "./dist/browser.mjs"
|
|
166
|
+
},
|
|
167
|
+
"./testing": {
|
|
168
|
+
"types": "./dist/testing/index.d.ts",
|
|
169
|
+
"default": "./dist/testing/index.mjs"
|
|
170
|
+
},
|
|
171
|
+
"./vite-builder-env": {
|
|
172
|
+
"types": "./dist/vite-builder-env.d.ts"
|
|
173
|
+
},
|
|
174
|
+
"./modules": {
|
|
175
|
+
"types": "./dist/modules.d.ts",
|
|
176
|
+
"default": "./dist/modules.mjs"
|
|
144
177
|
}
|
|
145
178
|
},
|
|
146
179
|
"scripts": {
|