wxt 0.19.3 → 0.19.5
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/chrome.d.ts +1 -4
- package/dist/browser/index.d.ts +7 -7
- package/dist/client/content-scripts/ui/types.d.ts +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.mjs +1 -0
- package/dist/client/inject-script.d.ts +18 -0
- package/dist/client/inject-script.mjs +14 -0
- package/dist/core/runners/web-ext.mjs +4 -1
- package/dist/core/utils/building/find-entrypoints.mjs +11 -1
- package/dist/core/utils/building/generate-wxt-dir.mjs +4 -4
- package/dist/core/utils/building/resolve-config.mjs +1 -1
- package/dist/core/utils/testing/fake-objects.d.ts +8 -2
- package/dist/core/utils/testing/fake-objects.mjs +1 -1
- package/dist/core/zip.mjs +4 -4
- package/dist/types.d.ts +11 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
package/dist/browser/chrome.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WxtRuntime, WxtI18n } from './index';
|
|
1
2
|
/**
|
|
2
3
|
* EXPERIMENTAL
|
|
3
4
|
*
|
|
@@ -5,10 +6,6 @@
|
|
|
5
6
|
*
|
|
6
7
|
* @module wxt/browser/chrome
|
|
7
8
|
*/
|
|
8
|
-
export interface WxtRuntime {
|
|
9
|
-
}
|
|
10
|
-
export interface WxtI18n {
|
|
11
|
-
}
|
|
12
9
|
export type Chrome = typeof chrome;
|
|
13
10
|
export type WxtBrowser = Omit<Chrome, 'runtime' | 'i18n'> & {
|
|
14
11
|
runtime: WxtRuntime & Omit<Chrome['runtime'], 'getURL'>;
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module wxt/browser
|
|
5
5
|
*/
|
|
6
|
-
import { Browser
|
|
7
|
-
export
|
|
8
|
-
runtime: WxtRuntime
|
|
9
|
-
i18n: WxtI18n
|
|
6
|
+
import { Browser } from 'webextension-polyfill';
|
|
7
|
+
export type AugmentedBrowser = Omit<Browser, 'runtime' | 'i18n'> & {
|
|
8
|
+
runtime: WxtRuntime & Omit<Browser['runtime'], 'getURL'>;
|
|
9
|
+
i18n: WxtI18n & Omit<Browser['i18n'], 'getMessage'>;
|
|
10
|
+
};
|
|
11
|
+
export interface WxtRuntime {
|
|
10
12
|
}
|
|
11
|
-
export interface
|
|
12
|
-
}
|
|
13
|
-
export interface WxtI18n extends I18n.Static {
|
|
13
|
+
export interface WxtI18n {
|
|
14
14
|
}
|
|
15
15
|
export declare const browser: AugmentedBrowser;
|
|
16
16
|
/** @ignore */
|
|
@@ -71,7 +71,7 @@ export type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMou
|
|
|
71
71
|
* The path to the HTML page that will be shown in the iframe. This string is passed into
|
|
72
72
|
* `browser.runtime.getURL`.
|
|
73
73
|
*/
|
|
74
|
-
page:
|
|
74
|
+
page: import('wxt/browser').HtmlPublicPath;
|
|
75
75
|
/**
|
|
76
76
|
* Callback executed when mounting the UI. Use this function to customize the iframe or wrapper
|
|
77
77
|
* element's appearance. It is called every time `ui.mount()` is called.
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.mjs
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ScriptPublicPath = Extract<import('wxt/browser').PublicPath, `${string}.js`>;
|
|
2
|
+
/**
|
|
3
|
+
* This function can only be called inside content scripts.
|
|
4
|
+
*
|
|
5
|
+
* Inject an unlisted script into the page. Scripts are added to the `<head>`
|
|
6
|
+
* element or `document.documentElement` if there is no head.
|
|
7
|
+
*
|
|
8
|
+
* Make sure to add the injected script to your manifest's
|
|
9
|
+
* `web_accessible_resources`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function injectScript(path: ScriptPublicPath, options?: InjectScriptOptions): Promise<void>;
|
|
12
|
+
export interface InjectScriptOptions {
|
|
13
|
+
/**
|
|
14
|
+
* By default, the injected script is removed from the DOM after being
|
|
15
|
+
* injected. To disable this behavior, set this flag to true.
|
|
16
|
+
*/
|
|
17
|
+
keepInDom?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { browser } from "wxt/browser";
|
|
2
|
+
export async function injectScript(path, options) {
|
|
3
|
+
const url = browser.runtime.getURL(path);
|
|
4
|
+
const script = document.createElement("script");
|
|
5
|
+
if (browser.runtime.getManifest().manifest_version === 2) {
|
|
6
|
+
script.innerHTML = await fetch(url).then((res) => res.text());
|
|
7
|
+
} else {
|
|
8
|
+
script.src = url;
|
|
9
|
+
}
|
|
10
|
+
if (!options?.keepInDom) {
|
|
11
|
+
script.onload = () => script.remove();
|
|
12
|
+
}
|
|
13
|
+
(document.head ?? document.documentElement).append(script);
|
|
14
|
+
}
|
|
@@ -72,7 +72,10 @@ const DEFAULT_CHROMIUM_PREFS = {
|
|
|
72
72
|
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
73
73
|
// and log locations show up properly, see:
|
|
74
74
|
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
75
|
-
skipContentScripts: false
|
|
75
|
+
skipContentScripts: false,
|
|
76
|
+
// Was renamed at some point, see:
|
|
77
|
+
// https://github.com/wxt-dev/wxt/issues/912#issuecomment-2284288171
|
|
78
|
+
"skip-content-scripts": false
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
};
|
|
@@ -15,7 +15,17 @@ import { wxt } from "../../wxt.mjs";
|
|
|
15
15
|
import { createExtensionEnvironment } from "../environments/index.mjs";
|
|
16
16
|
export async function findEntrypoints() {
|
|
17
17
|
await fs.mkdir(wxt.config.wxtDir, { recursive: true });
|
|
18
|
-
|
|
18
|
+
try {
|
|
19
|
+
await fs.writeJson(
|
|
20
|
+
resolve(wxt.config.wxtDir, "tsconfig.json"),
|
|
21
|
+
{},
|
|
22
|
+
{ flag: "wx" }
|
|
23
|
+
);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
if (!(err instanceof Error) || !("code" in err) || err.code !== "EEXIST") {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
const relativePaths = await glob(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
20
30
|
cwd: wxt.config.entrypointsDir
|
|
21
31
|
});
|
|
@@ -50,9 +50,9 @@ async function getPathsDeclarationEntry(entrypoints) {
|
|
|
50
50
|
await wxt.hooks.callHook("prepare:publicPaths", wxt, paths);
|
|
51
51
|
const unions = paths.map(normalizePath).sort().map((path2) => ` | "/${path2}"`).join("\n");
|
|
52
52
|
const template = `// Generated by wxt
|
|
53
|
-
import "
|
|
53
|
+
import "wxt/browser";
|
|
54
54
|
|
|
55
|
-
declare module "
|
|
55
|
+
declare module "wxt/browser" {
|
|
56
56
|
export type PublicPath =
|
|
57
57
|
{{ union }}
|
|
58
58
|
type HtmlPublicPath = Extract<PublicPath, \`\${string}.html\`>
|
|
@@ -71,9 +71,9 @@ declare module "${wxt.config.browserModule}" {
|
|
|
71
71
|
async function getI18nDeclarationEntry() {
|
|
72
72
|
const defaultLocale = wxt.config.manifest.default_locale;
|
|
73
73
|
const template = `// Generated by wxt
|
|
74
|
-
import "
|
|
74
|
+
import "wxt/browser";
|
|
75
75
|
|
|
76
|
-
declare module "
|
|
76
|
+
declare module "wxt/browser" {
|
|
77
77
|
/**
|
|
78
78
|
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
|
|
79
79
|
*/
|
|
@@ -134,7 +134,6 @@ export async function resolveConfig(inlineConfig, command) {
|
|
|
134
134
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
135
135
|
alias,
|
|
136
136
|
extensionApi,
|
|
137
|
-
browserModule: extensionApi === "chrome" ? "wxt/browser/chrome" : "wxt/browser",
|
|
138
137
|
entrypointLoader: mergedConfig.entrypointLoader ?? "vite-node",
|
|
139
138
|
experimental: defu(mergedConfig.experimental, {}),
|
|
140
139
|
dev: {
|
|
@@ -188,6 +187,7 @@ function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
|
188
187
|
includeSources: [],
|
|
189
188
|
compressionLevel: 9,
|
|
190
189
|
...mergedConfig.zip,
|
|
190
|
+
exclude: mergedConfig.zip?.exclude ?? [],
|
|
191
191
|
excludeSources: [
|
|
192
192
|
"**/node_modules",
|
|
193
193
|
// WXT files
|
|
@@ -453,6 +453,7 @@ export declare const fakeResolvedConfig: (overrides?: {
|
|
|
453
453
|
downloadedPackagesDir?: string | undefined;
|
|
454
454
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
455
455
|
compressionLevel?: 0 | 1 | 9 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined;
|
|
456
|
+
exclude?: (string | undefined)[] | undefined;
|
|
456
457
|
} | undefined;
|
|
457
458
|
transformManifest?: {} | undefined;
|
|
458
459
|
analysis?: {
|
|
@@ -647,6 +648,7 @@ export declare const fakeResolvedConfig: (overrides?: {
|
|
|
647
648
|
sourcesRoot?: string | undefined;
|
|
648
649
|
includeSources?: (string | undefined)[] | undefined;
|
|
649
650
|
excludeSources?: (string | undefined)[] | undefined;
|
|
651
|
+
exclude?: (string | undefined)[] | undefined;
|
|
650
652
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
651
653
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
652
654
|
} | undefined;
|
|
@@ -969,6 +971,7 @@ export declare const fakeResolvedConfig: (overrides?: {
|
|
|
969
971
|
sourcesRoot?: string | undefined;
|
|
970
972
|
includeSources?: (string | undefined)[] | undefined;
|
|
971
973
|
excludeSources?: (string | undefined)[] | undefined;
|
|
974
|
+
exclude?: (string | undefined)[] | undefined;
|
|
972
975
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
973
976
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
974
977
|
} | undefined;
|
|
@@ -1317,6 +1320,7 @@ export declare const fakeResolvedConfig: (overrides?: {
|
|
|
1317
1320
|
sourcesRoot?: string | undefined;
|
|
1318
1321
|
includeSources?: (string | undefined)[] | undefined;
|
|
1319
1322
|
excludeSources?: (string | undefined)[] | undefined;
|
|
1323
|
+
exclude?: (string | undefined)[] | undefined;
|
|
1320
1324
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
1321
1325
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
1322
1326
|
} | undefined;
|
|
@@ -1481,7 +1485,6 @@ export declare const fakeResolvedConfig: (overrides?: {
|
|
|
1481
1485
|
[x: string]: string | undefined;
|
|
1482
1486
|
} | undefined;
|
|
1483
1487
|
extensionApi?: "webextension-polyfill" | "chrome" | undefined;
|
|
1484
|
-
browserModule?: "wxt/browser" | "wxt/browser/chrome" | undefined;
|
|
1485
1488
|
entrypointLoader?: "vite-node" | "jiti" | undefined;
|
|
1486
1489
|
experimental?: {} | undefined;
|
|
1487
1490
|
dev?: {
|
|
@@ -2009,6 +2012,7 @@ export declare const fakeWxt: (overrides?: {
|
|
|
2009
2012
|
downloadedPackagesDir?: string | undefined;
|
|
2010
2013
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
2011
2014
|
compressionLevel?: 0 | 1 | 9 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined;
|
|
2015
|
+
exclude?: (string | undefined)[] | undefined;
|
|
2012
2016
|
} | undefined;
|
|
2013
2017
|
transformManifest?: {} | undefined;
|
|
2014
2018
|
analysis?: {
|
|
@@ -2203,6 +2207,7 @@ export declare const fakeWxt: (overrides?: {
|
|
|
2203
2207
|
sourcesRoot?: string | undefined;
|
|
2204
2208
|
includeSources?: (string | undefined)[] | undefined;
|
|
2205
2209
|
excludeSources?: (string | undefined)[] | undefined;
|
|
2210
|
+
exclude?: (string | undefined)[] | undefined;
|
|
2206
2211
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
2207
2212
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
2208
2213
|
} | undefined;
|
|
@@ -2525,6 +2530,7 @@ export declare const fakeWxt: (overrides?: {
|
|
|
2525
2530
|
sourcesRoot?: string | undefined;
|
|
2526
2531
|
includeSources?: (string | undefined)[] | undefined;
|
|
2527
2532
|
excludeSources?: (string | undefined)[] | undefined;
|
|
2533
|
+
exclude?: (string | undefined)[] | undefined;
|
|
2528
2534
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
2529
2535
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
2530
2536
|
} | undefined;
|
|
@@ -2873,6 +2879,7 @@ export declare const fakeWxt: (overrides?: {
|
|
|
2873
2879
|
sourcesRoot?: string | undefined;
|
|
2874
2880
|
includeSources?: (string | undefined)[] | undefined;
|
|
2875
2881
|
excludeSources?: (string | undefined)[] | undefined;
|
|
2882
|
+
exclude?: (string | undefined)[] | undefined;
|
|
2876
2883
|
downloadPackages?: (string | undefined)[] | undefined;
|
|
2877
2884
|
compressionLevel?: (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined;
|
|
2878
2885
|
} | undefined;
|
|
@@ -3037,7 +3044,6 @@ export declare const fakeWxt: (overrides?: {
|
|
|
3037
3044
|
[x: string]: string | undefined;
|
|
3038
3045
|
} | undefined;
|
|
3039
3046
|
extensionApi?: "webextension-polyfill" | "chrome" | undefined;
|
|
3040
|
-
browserModule?: "wxt/browser" | "wxt/browser/chrome" | undefined;
|
|
3041
3047
|
entrypointLoader?: "vite-node" | "jiti" | undefined;
|
|
3042
3048
|
experimental?: {} | undefined;
|
|
3043
3049
|
dev?: {
|
|
@@ -235,6 +235,7 @@ export const fakeResolvedConfig = fakeObjectCreator(() => {
|
|
|
235
235
|
artifactTemplate: "{{name}}-{{version}}.zip",
|
|
236
236
|
includeSources: [],
|
|
237
237
|
excludeSources: [],
|
|
238
|
+
exclude: [],
|
|
238
239
|
sourcesRoot: fakeDir(),
|
|
239
240
|
sourcesTemplate: "{{name}}-sources.zip",
|
|
240
241
|
name: faker.person.firstName().toLowerCase(),
|
|
@@ -247,7 +248,6 @@ export const fakeResolvedConfig = fakeObjectCreator(() => {
|
|
|
247
248
|
userConfigMetadata: {},
|
|
248
249
|
alias: {},
|
|
249
250
|
extensionApi: "webextension-polyfill",
|
|
250
|
-
browserModule: "wxt/browser",
|
|
251
251
|
entrypointLoader: "vite-node",
|
|
252
252
|
experimental: {},
|
|
253
253
|
dev: {
|
package/dist/core/zip.mjs
CHANGED
|
@@ -26,7 +26,9 @@ export async function zip(config) {
|
|
|
26
26
|
await fs.ensureDir(wxt.config.outBaseDir);
|
|
27
27
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
28
28
|
const outZipPath = path.resolve(wxt.config.outBaseDir, outZipFilename);
|
|
29
|
-
await zipDir(wxt.config.outDir, outZipPath
|
|
29
|
+
await zipDir(wxt.config.outDir, outZipPath, {
|
|
30
|
+
exclude: wxt.config.zip.exclude
|
|
31
|
+
});
|
|
30
32
|
zipFiles.push(outZipPath);
|
|
31
33
|
if (wxt.config.browser === "firefox") {
|
|
32
34
|
const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
|
|
@@ -57,13 +59,11 @@ export async function zip(config) {
|
|
|
57
59
|
}
|
|
58
60
|
async function zipDir(directory, outputPath, options) {
|
|
59
61
|
const archive = new JSZip();
|
|
60
|
-
const files = (await glob("**/*", {
|
|
62
|
+
const files = (await glob(["**/*", ...options?.include || []], {
|
|
61
63
|
cwd: directory,
|
|
62
64
|
// Ignore node_modules, otherwise this glob step takes forever
|
|
63
65
|
ignore: ["**/node_modules"],
|
|
64
66
|
onlyFiles: true
|
|
65
|
-
// TODO: Fix #738
|
|
66
|
-
// dot: true,
|
|
67
67
|
})).filter((relativePath) => {
|
|
68
68
|
return options?.include?.some((pattern) => minimatch(relativePath, pattern)) || !options?.exclude?.some((pattern) => minimatch(relativePath, pattern));
|
|
69
69
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -180,6 +180,16 @@ export interface InlineConfig {
|
|
|
180
180
|
* ]
|
|
181
181
|
*/
|
|
182
182
|
excludeSources?: string[];
|
|
183
|
+
/**
|
|
184
|
+
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
185
|
+
* zipping the extension.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* [
|
|
189
|
+
* "**\/*.map", // Exclude all sourcemaps
|
|
190
|
+
* ]
|
|
191
|
+
*/
|
|
192
|
+
exclude?: string[];
|
|
183
193
|
/**
|
|
184
194
|
* The Firefox review process requires the extension be buildable from source to make reviewing
|
|
185
195
|
* easier. This field allows you to use private packages without exposing your auth tokens.
|
|
@@ -1078,6 +1088,7 @@ export interface ResolvedConfig {
|
|
|
1078
1088
|
downloadedPackagesDir: string;
|
|
1079
1089
|
downloadPackages: string[];
|
|
1080
1090
|
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1091
|
+
exclude: string[];
|
|
1081
1092
|
};
|
|
1082
1093
|
/**
|
|
1083
1094
|
* @deprecated Use `build:manifestGenerated` hook instead.
|
|
@@ -1101,7 +1112,6 @@ export interface ResolvedConfig {
|
|
|
1101
1112
|
*/
|
|
1102
1113
|
alias: Record<string, string>;
|
|
1103
1114
|
extensionApi: 'webextension-polyfill' | 'chrome';
|
|
1104
|
-
browserModule: 'wxt/browser' | 'wxt/browser/chrome';
|
|
1105
1115
|
entrypointLoader: 'vite-node' | 'jiti';
|
|
1106
1116
|
experimental: {};
|
|
1107
1117
|
dev: {
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.19.
|
|
1
|
+
export const version = "0.19.5";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.5",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"defu": "^6.1.4",
|
|
85
85
|
"dequal": "^2.0.3",
|
|
86
86
|
"esbuild": "^0.23.0",
|
|
87
|
+
"execa": "^9.3.0",
|
|
87
88
|
"fast-glob": "^3.3.2",
|
|
88
89
|
"filesize": "^10.1.4",
|
|
89
90
|
"fs-extra": "^11.2.0",
|
|
@@ -122,7 +123,6 @@
|
|
|
122
123
|
"@types/node": "^20.14.12",
|
|
123
124
|
"@types/normalize-path": "^3.0.2",
|
|
124
125
|
"@types/prompts": "^2.4.9",
|
|
125
|
-
"execa": "^9.3.0",
|
|
126
126
|
"extract-zip": "^2.0.1",
|
|
127
127
|
"happy-dom": "^14.12.3",
|
|
128
128
|
"lodash.merge": "^4.6.2",
|