wxt 0.20.13 → 0.20.14
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 +52 -50
- package/dist/cli/commands.mjs +77 -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 +292 -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 +104 -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 +25 -23
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +25 -23
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +27 -26
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +11 -11
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +41 -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 +109 -148
- package/dist/core/index.d.mts +8 -0
- package/dist/core/index.mjs +10 -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 +11 -6
- package/dist/core/runners/manual.mjs +16 -14
- package/dist/core/runners/safari.mjs +16 -14
- package/dist/core/runners/web-ext.mjs +62 -83
- package/dist/core/runners/wsl.mjs +16 -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 +275 -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 +87 -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/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 +10 -5
- package/dist/core/utils/log/printTable.mjs +19 -21
- package/dist/core/utils/manifest.mjs +364 -479
- package/dist/core/utils/minimatch-multiple.mjs +26 -15
- package/dist/core/utils/network.mjs +30 -33
- package/dist/core/utils/number.mjs +7 -3
- package/dist/core/utils/package.mjs +20 -13
- 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 +10 -3
- package/dist/core/wxt.mjs +66 -60
- package/dist/core/{zip.d.ts → zip.d.mts} +6 -2
- package/dist/core/zip.mjs +116 -140
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -3
- package/dist/{modules.d.ts → modules.d.mts} +14 -16
- package/dist/modules.mjs +181 -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 +1453 -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 +137 -0
- package/dist/utils/content-script-context.mjs +192 -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 +117 -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 +146 -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 +60 -53
- package/dist/virtual/unlisted-script-entrypoint.d.mts +4 -0
- package/dist/virtual/unlisted-script-entrypoint.mjs +35 -43
- package/package.json +47 -49
- 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
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
import { faker } from "@faker-js/faker";
|
|
3
|
-
import merge from "lodash.merge";
|
|
4
|
-
import { mock } from "vitest-mock-extended";
|
|
5
|
-
import { vi } from "vitest";
|
|
6
|
-
import { setWxtForTesting } from "../../../core/wxt.mjs";
|
|
7
|
-
faker.seed(import.meta.test.SEED);
|
|
8
|
-
function fakeObjectCreator(base) {
|
|
9
|
-
return (overrides) => merge(base(), overrides);
|
|
10
|
-
}
|
|
11
|
-
export function fakeFileName() {
|
|
12
|
-
return faker.string.alphanumeric() + "." + faker.string.alpha({ length: 3 });
|
|
13
|
-
}
|
|
14
|
-
export function fakeFile(root = process.cwd()) {
|
|
15
|
-
return resolve(root, fakeFileName());
|
|
16
|
-
}
|
|
17
|
-
export function fakeDir(root = process.cwd()) {
|
|
18
|
-
return resolve(root, faker.string.alphanumeric());
|
|
19
|
-
}
|
|
20
|
-
export const fakeEntrypoint = (options) => faker.helpers.arrayElement([
|
|
21
|
-
fakePopupEntrypoint,
|
|
22
|
-
fakeGenericEntrypoint,
|
|
23
|
-
fakeOptionsEntrypoint,
|
|
24
|
-
fakeBackgroundEntrypoint,
|
|
25
|
-
fakeContentScriptEntrypoint,
|
|
26
|
-
fakeUnlistedScriptEntrypoint
|
|
27
|
-
])(options);
|
|
28
|
-
export const fakeContentScriptEntrypoint = fakeObjectCreator(() => ({
|
|
29
|
-
type: "content-script",
|
|
30
|
-
inputPath: fakeFile("src"),
|
|
31
|
-
name: faker.string.alpha(),
|
|
32
|
-
options: {
|
|
33
|
-
matches: [],
|
|
34
|
-
matchAboutBlank: faker.datatype.boolean(),
|
|
35
|
-
matchOriginAsFallback: faker.helpers.arrayElement([
|
|
36
|
-
true,
|
|
37
|
-
false,
|
|
38
|
-
void 0
|
|
39
|
-
]),
|
|
40
|
-
runAt: faker.helpers.arrayElement([
|
|
41
|
-
"document_start",
|
|
42
|
-
"document_end",
|
|
43
|
-
"document_idle",
|
|
44
|
-
void 0
|
|
45
|
-
])
|
|
46
|
-
},
|
|
47
|
-
outputDir: fakeDir(".output"),
|
|
48
|
-
skipped: faker.datatype.boolean()
|
|
49
|
-
}));
|
|
50
|
-
export const fakeBackgroundEntrypoint = fakeObjectCreator(
|
|
51
|
-
() => ({
|
|
52
|
-
type: "background",
|
|
53
|
-
inputPath: "entrypoints/background.ts",
|
|
54
|
-
name: "background",
|
|
55
|
-
options: {
|
|
56
|
-
persistent: faker.datatype.boolean(),
|
|
57
|
-
type: faker.helpers.maybe(() => "module")
|
|
58
|
-
},
|
|
59
|
-
outputDir: fakeDir(".output"),
|
|
60
|
-
skipped: faker.datatype.boolean()
|
|
61
|
-
})
|
|
62
|
-
);
|
|
63
|
-
export const fakeUnlistedScriptEntrypoint = fakeObjectCreator(() => ({
|
|
64
|
-
type: "unlisted-script",
|
|
65
|
-
inputPath: fakeFile("src"),
|
|
66
|
-
name: faker.string.alpha(),
|
|
67
|
-
outputDir: fakeDir(".output"),
|
|
68
|
-
options: {},
|
|
69
|
-
skipped: faker.datatype.boolean()
|
|
70
|
-
}));
|
|
71
|
-
export const fakeOptionsEntrypoint = fakeObjectCreator(
|
|
72
|
-
() => ({
|
|
73
|
-
type: "options",
|
|
74
|
-
inputPath: "entrypoints/options.html",
|
|
75
|
-
name: "options",
|
|
76
|
-
outputDir: fakeDir(".output"),
|
|
77
|
-
options: {
|
|
78
|
-
browserStyle: faker.datatype.boolean(),
|
|
79
|
-
chromeStyle: faker.datatype.boolean(),
|
|
80
|
-
openInTab: faker.datatype.boolean()
|
|
81
|
-
},
|
|
82
|
-
skipped: faker.datatype.boolean()
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
export const fakePopupEntrypoint = fakeObjectCreator(() => ({
|
|
86
|
-
type: "popup",
|
|
87
|
-
inputPath: "entrypoints/popup.html",
|
|
88
|
-
name: "popup",
|
|
89
|
-
outputDir: fakeDir(".output"),
|
|
90
|
-
options: {
|
|
91
|
-
defaultTitle: faker.helpers.arrayElement([
|
|
92
|
-
faker.person.fullName(),
|
|
93
|
-
void 0
|
|
94
|
-
]),
|
|
95
|
-
defaultIcon: faker.helpers.arrayElement([
|
|
96
|
-
{
|
|
97
|
-
"16": "icon/16.png",
|
|
98
|
-
"24": "icon/24.png",
|
|
99
|
-
"64": "icon/64.png"
|
|
100
|
-
}
|
|
101
|
-
]),
|
|
102
|
-
mv2Key: faker.helpers.arrayElement([
|
|
103
|
-
"browser_action",
|
|
104
|
-
"page_action",
|
|
105
|
-
void 0
|
|
106
|
-
])
|
|
107
|
-
},
|
|
108
|
-
skipped: faker.datatype.boolean()
|
|
109
|
-
}));
|
|
110
|
-
export const fakeSidepanelEntrypoint = fakeObjectCreator(
|
|
111
|
-
() => ({
|
|
112
|
-
type: "sidepanel",
|
|
113
|
-
inputPath: "entrypoints/sidepanel.html",
|
|
114
|
-
name: "sidepanel",
|
|
115
|
-
outputDir: fakeDir(".output"),
|
|
116
|
-
options: {
|
|
117
|
-
defaultTitle: faker.helpers.arrayElement([
|
|
118
|
-
faker.person.fullName(),
|
|
119
|
-
void 0
|
|
120
|
-
]),
|
|
121
|
-
defaultIcon: faker.helpers.arrayElement([
|
|
122
|
-
{
|
|
123
|
-
"16": "icon/16.png",
|
|
124
|
-
"24": "icon/24.png",
|
|
125
|
-
"64": "icon/64.png"
|
|
126
|
-
}
|
|
127
|
-
]),
|
|
128
|
-
openAtInstall: faker.helpers.arrayElement([true, false, void 0])
|
|
129
|
-
},
|
|
130
|
-
skipped: faker.datatype.boolean()
|
|
131
|
-
})
|
|
132
|
-
);
|
|
133
|
-
export const fakeGenericEntrypoint = fakeObjectCreator(
|
|
134
|
-
() => ({
|
|
135
|
-
type: faker.helpers.arrayElement([
|
|
136
|
-
"sandbox",
|
|
137
|
-
"bookmarks",
|
|
138
|
-
"history",
|
|
139
|
-
"newtab",
|
|
140
|
-
"devtools",
|
|
141
|
-
"unlisted-page",
|
|
142
|
-
"unlisted-script"
|
|
143
|
-
]),
|
|
144
|
-
inputPath: fakeFile("src"),
|
|
145
|
-
name: faker.string.alpha(),
|
|
146
|
-
outputDir: fakeDir(".output"),
|
|
147
|
-
options: {},
|
|
148
|
-
skipped: faker.datatype.boolean()
|
|
149
|
-
})
|
|
150
|
-
);
|
|
151
|
-
export const fakeOutputChunk = fakeObjectCreator(() => ({
|
|
152
|
-
type: "chunk",
|
|
153
|
-
fileName: faker.string.alphanumeric(),
|
|
154
|
-
moduleIds: []
|
|
155
|
-
}));
|
|
156
|
-
export const fakeOutputAsset = fakeObjectCreator(() => ({
|
|
157
|
-
type: "asset",
|
|
158
|
-
fileName: fakeFileName()
|
|
159
|
-
}));
|
|
160
|
-
export function fakeOutputFile() {
|
|
161
|
-
return faker.helpers.arrayElement([fakeOutputAsset(), fakeOutputChunk()]);
|
|
162
|
-
}
|
|
163
|
-
export const fakeManifest = fakeObjectCreator(() => ({
|
|
164
|
-
manifest_version: faker.helpers.arrayElement([2, 3]),
|
|
165
|
-
name: faker.string.alphanumeric(),
|
|
166
|
-
version: `${faker.number.int()}.${faker.number.int()}.${faker.number.int()}`
|
|
167
|
-
}));
|
|
168
|
-
export const fakeUserManifest = fakeObjectCreator(() => ({
|
|
169
|
-
name: faker.string.alphanumeric(),
|
|
170
|
-
version: `${faker.number.int()}.${faker.number.int()}.${faker.number.int()}`
|
|
171
|
-
}));
|
|
172
|
-
export function fakeArray(createItem, count = 3) {
|
|
173
|
-
const array = [];
|
|
174
|
-
for (let i = 0; i < count; i++) {
|
|
175
|
-
array.push(createItem());
|
|
176
|
-
}
|
|
177
|
-
return array;
|
|
178
|
-
}
|
|
179
|
-
export const fakeResolvedConfig = fakeObjectCreator(() => {
|
|
180
|
-
const browser = faker.helpers.arrayElement(["chrome", "firefox"]);
|
|
181
|
-
const command = faker.helpers.arrayElement(["build", "serve"]);
|
|
182
|
-
const manifestVersion = faker.helpers.arrayElement([2, 3]);
|
|
183
|
-
const mode = faker.helpers.arrayElement(["development", "production"]);
|
|
184
|
-
return {
|
|
185
|
-
browser,
|
|
186
|
-
targetBrowsers: [],
|
|
187
|
-
command,
|
|
188
|
-
entrypointsDir: fakeDir(),
|
|
189
|
-
modulesDir: fakeDir(),
|
|
190
|
-
builtinModules: [],
|
|
191
|
-
userModules: [],
|
|
192
|
-
env: { browser, command, manifestVersion, mode },
|
|
193
|
-
fsCache: mock(),
|
|
194
|
-
imports: {
|
|
195
|
-
disabled: faker.datatype.boolean(),
|
|
196
|
-
eslintrc: {
|
|
197
|
-
enabled: faker.helpers.arrayElement([false, 8, 9]),
|
|
198
|
-
filePath: fakeFile(),
|
|
199
|
-
globalsPropValue: faker.helpers.arrayElement([
|
|
200
|
-
true,
|
|
201
|
-
false,
|
|
202
|
-
"readable",
|
|
203
|
-
"readonly",
|
|
204
|
-
"writable",
|
|
205
|
-
"writeable"
|
|
206
|
-
])
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
logger: mock(),
|
|
210
|
-
manifest: fakeUserManifest(),
|
|
211
|
-
manifestVersion,
|
|
212
|
-
mode,
|
|
213
|
-
outBaseDir: fakeDir(),
|
|
214
|
-
outDir: fakeDir(),
|
|
215
|
-
publicDir: fakeDir(),
|
|
216
|
-
root: fakeDir(),
|
|
217
|
-
wxtModuleDir: fakeDir(),
|
|
218
|
-
runnerConfig: {
|
|
219
|
-
config: {}
|
|
220
|
-
},
|
|
221
|
-
debug: faker.datatype.boolean(),
|
|
222
|
-
srcDir: fakeDir(),
|
|
223
|
-
typesDir: fakeDir(),
|
|
224
|
-
wxtDir: fakeDir(),
|
|
225
|
-
analysis: {
|
|
226
|
-
enabled: false,
|
|
227
|
-
open: false,
|
|
228
|
-
template: "treemap",
|
|
229
|
-
outputFile: fakeFile(),
|
|
230
|
-
outputDir: fakeDir(),
|
|
231
|
-
outputName: "stats",
|
|
232
|
-
keepArtifacts: false
|
|
233
|
-
},
|
|
234
|
-
zip: {
|
|
235
|
-
artifactTemplate: "{{name}}-{{version}}.zip",
|
|
236
|
-
includeSources: [],
|
|
237
|
-
excludeSources: [],
|
|
238
|
-
exclude: [],
|
|
239
|
-
sourcesRoot: fakeDir(),
|
|
240
|
-
sourcesTemplate: "{{name}}-sources.zip",
|
|
241
|
-
name: faker.person.firstName().toLowerCase(),
|
|
242
|
-
downloadedPackagesDir: fakeDir(),
|
|
243
|
-
downloadPackages: [],
|
|
244
|
-
compressionLevel: 9,
|
|
245
|
-
zipSources: false
|
|
246
|
-
},
|
|
247
|
-
userConfigMetadata: {},
|
|
248
|
-
alias: {},
|
|
249
|
-
experimental: {},
|
|
250
|
-
dev: {
|
|
251
|
-
reloadCommand: "Alt+R"
|
|
252
|
-
},
|
|
253
|
-
hooks: {},
|
|
254
|
-
vite: () => ({}),
|
|
255
|
-
plugins: []
|
|
256
|
-
};
|
|
257
|
-
});
|
|
258
|
-
export const fakeWxt = fakeObjectCreator(() => ({
|
|
259
|
-
config: fakeResolvedConfig(),
|
|
260
|
-
hook: vi.fn(),
|
|
261
|
-
hooks: mock(),
|
|
262
|
-
logger: mock(),
|
|
263
|
-
reloadConfig: vi.fn(),
|
|
264
|
-
pm: mock(),
|
|
265
|
-
server: faker.helpers.arrayElement([void 0, fakeWxtDevServer()]),
|
|
266
|
-
builder: mock()
|
|
267
|
-
}));
|
|
268
|
-
export const fakeWxtDevServer = fakeObjectCreator(() => ({
|
|
269
|
-
currentOutput: fakeBuildOutput(),
|
|
270
|
-
host: "localhost",
|
|
271
|
-
port: 3e3,
|
|
272
|
-
origin: "http://localhost:3000",
|
|
273
|
-
reloadContentScript: vi.fn(),
|
|
274
|
-
reloadExtension: vi.fn(),
|
|
275
|
-
reloadPage: vi.fn(),
|
|
276
|
-
restart: vi.fn(),
|
|
277
|
-
restartBrowser: vi.fn(),
|
|
278
|
-
start: vi.fn(),
|
|
279
|
-
stop: vi.fn(),
|
|
280
|
-
transformHtml: vi.fn(),
|
|
281
|
-
watcher: mock(),
|
|
282
|
-
ws: mock()
|
|
283
|
-
}));
|
|
284
|
-
export function setFakeWxt(overrides) {
|
|
285
|
-
const wxt = fakeWxt(overrides);
|
|
286
|
-
setWxtForTesting(wxt);
|
|
287
|
-
return wxt;
|
|
288
|
-
}
|
|
289
|
-
export const fakeBuildOutput = fakeObjectCreator(() => ({
|
|
290
|
-
manifest: fakeManifest(),
|
|
291
|
-
publicAssets: fakeArray(fakeOutputAsset),
|
|
292
|
-
steps: fakeArray(fakeBuildStepOutput)
|
|
293
|
-
}));
|
|
294
|
-
export const fakeBuildStepOutput = fakeObjectCreator(() => ({
|
|
295
|
-
chunks: fakeArray(fakeOutputChunk),
|
|
296
|
-
entrypoints: fakeArray(fakeEntrypoint)
|
|
297
|
-
}));
|
|
298
|
-
export const fakeManifestCommand = fakeObjectCreator(
|
|
299
|
-
() => ({
|
|
300
|
-
description: faker.string.sample(),
|
|
301
|
-
suggested_key: {
|
|
302
|
-
default: `${faker.helpers.arrayElement(["ctrl", "alt"])}+${faker.number.int(
|
|
303
|
-
{
|
|
304
|
-
min: 0,
|
|
305
|
-
max: 9
|
|
306
|
-
}
|
|
307
|
-
)}`
|
|
308
|
-
}
|
|
309
|
-
})
|
|
310
|
-
);
|
|
311
|
-
export const fakeDevServer = fakeObjectCreator(() => ({
|
|
312
|
-
host: "localhost",
|
|
313
|
-
port: 5173,
|
|
314
|
-
origin: "http://localhost:3000",
|
|
315
|
-
reloadContentScript: vi.fn(),
|
|
316
|
-
reloadExtension: vi.fn(),
|
|
317
|
-
reloadPage: vi.fn(),
|
|
318
|
-
restart: vi.fn(),
|
|
319
|
-
restartBrowser: vi.fn(),
|
|
320
|
-
stop: vi.fn(),
|
|
321
|
-
start: vi.fn(),
|
|
322
|
-
watcher: mock(),
|
|
323
|
-
transformHtml: vi.fn(),
|
|
324
|
-
ws: mock(),
|
|
325
|
-
currentOutput: void 0
|
|
326
|
-
}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function formatDuration(duration: number): string;
|
|
2
|
-
/**
|
|
3
|
-
* Add a timeout to a promise.
|
|
4
|
-
*/
|
|
5
|
-
export declare function withTimeout<T>(promise: Promise<T>, duration: number): Promise<T>;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Don't use in production, just for testing and slowing things down.
|
|
8
|
-
*/
|
|
9
|
-
export declare function sleep(ms: number): Promise<void>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes any code used at runtime related to an entrypoint's main function.
|
|
3
|
-
* 1. Removes or clears out `main` function from returned object
|
|
4
|
-
* 2. Removes any unused functions/variables outside the definition that aren't being called/used
|
|
5
|
-
* 3. Removes unused imports
|
|
6
|
-
* 3. Removes value-less, side-effect only imports (like `import "./styles.css"` or `import "polyfill"`)
|
|
7
|
-
*/
|
|
8
|
-
export declare function removeMainFunctionCode(code: string): {
|
|
9
|
-
code: string;
|
|
10
|
-
map?: string;
|
|
11
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Browser } from '@wxt-dev/browser';
|
|
2
|
-
/**
|
|
3
|
-
* Remove optional from key, but keep undefined if present
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* type Test = NullablyRequired<{a?: string, b: number}>
|
|
7
|
-
* // type Test = {a: string | undefined, b: number}
|
|
8
|
-
*/
|
|
9
|
-
export type NullablyRequired<T> = {
|
|
10
|
-
[K in keyof Required<T>]: T[K];
|
|
11
|
-
};
|
|
12
|
-
export type ManifestContentScript = NonNullable<Browser.runtime.Manifest['content_scripts']>[number];
|
|
13
|
-
export type ManifestV3WebAccessibleResource = NonNullable<Browser.runtime.ManifestV3['web_accessible_resources']>[number];
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Entrypoint } from '../../types';
|
|
2
|
-
export declare function validateEntrypoints(entrypoints: Entrypoint[]): ValidationResults;
|
|
3
|
-
export interface ValidationResult {
|
|
4
|
-
type: 'warning' | 'error';
|
|
5
|
-
message: string;
|
|
6
|
-
entrypoint: Entrypoint;
|
|
7
|
-
value: any;
|
|
8
|
-
}
|
|
9
|
-
export interface ValidationResults {
|
|
10
|
-
errors: ValidationResult[];
|
|
11
|
-
errorCount: number;
|
|
12
|
-
warningCount: number;
|
|
13
|
-
}
|
|
14
|
-
export declare class ValidationError extends Error {
|
|
15
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const virtualEntrypointTypes: ("background" | "unlisted-script" | "content-script-main-world" | "content-script-isolated-world")[];
|
|
2
|
-
export type VirtualEntrypointType = (typeof virtualEntrypointTypes)[0];
|
|
3
|
-
/**
|
|
4
|
-
* All the names of entrypoint files in the `src/virtual/` and `dist/virtual/` directories, minus the extension.
|
|
5
|
-
*/
|
|
6
|
-
export declare const virtualEntrypointModuleNames: ("background-entrypoint" | "unlisted-script-entrypoint" | "content-script-main-world-entrypoint" | "content-script-isolated-world-entrypoint")[];
|
|
7
|
-
/**
|
|
8
|
-
* Name of entrypoint files in the `src/virtual/` and `dist/virtual/` directories, minus the extension.
|
|
9
|
-
*/
|
|
10
|
-
export type VirtualEntrypointModuleName = (typeof virtualEntrypointModuleNames)[0];
|
|
11
|
-
/**
|
|
12
|
-
* All the names of files in the `src/virtual/` and `dist/virtual/` directories, minus the extension.
|
|
13
|
-
*/
|
|
14
|
-
export declare const virtualModuleNames: ("background-entrypoint" | "unlisted-script-entrypoint" | "content-script-main-world-entrypoint" | "content-script-isolated-world-entrypoint" | "mock-browser" | "reload-html")[];
|
|
15
|
-
/**
|
|
16
|
-
* Name of files in the `src/virtual/` and `dist/virtual/` directories, minus the extension.
|
|
17
|
-
*/
|
|
18
|
-
export type VirtualModuleName = (typeof virtualModuleNames)[0];
|
|
19
|
-
/**
|
|
20
|
-
* Import alias used for importing a virtual module
|
|
21
|
-
*/
|
|
22
|
-
export type VirtualModuleId = `virtual:wxt-${VirtualModuleName}`;
|
package/dist/core/utils/wsl.d.ts
DELETED
package/dist/core/wxt.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { InlineConfig, Wxt, WxtCommand } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Global variable set once `createWxt` is called once. Since this variable is used everywhere, this
|
|
4
|
-
* global can be used instead of passing the variable as a function parameter everywhere.
|
|
5
|
-
*/
|
|
6
|
-
export declare let wxt: Wxt;
|
|
7
|
-
/**
|
|
8
|
-
* Create and register a global instance of the Wxt interface for use throughout the project.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerWxt(command: WxtCommand, inlineConfig?: InlineConfig): Promise<void>;
|
|
11
|
-
export declare function initWxtModules(): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Unloads WXT modules.
|
|
14
|
-
*/
|
|
15
|
-
export declare function deinitWxtModules(): void;
|
|
16
|
-
/**
|
|
17
|
-
* @internal ONLY USE FOR TESTING.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* setWxtForTesting(fakeWxt({ ... }));
|
|
21
|
-
* // Or use the shorthand
|
|
22
|
-
* setFakeWxt({ ... })
|
|
23
|
-
*/
|
|
24
|
-
export declare function setWxtForTesting(testInstance: Wxt): void;
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module contains:
|
|
3
|
-
* - JS APIs used by the CLI to build extensions or start dev mode.
|
|
4
|
-
* - Helper functions for defining project config.
|
|
5
|
-
* - Types for building and extension or configuring WXT.
|
|
6
|
-
*
|
|
7
|
-
* @module wxt
|
|
8
|
-
*/
|
|
9
|
-
export * from './core';
|
|
10
|
-
export * from './types';
|
|
11
|
-
export * from './version';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The fake browser is automatically used as a mock for the `wxt/browser` import
|
|
3
|
-
* when using `wxt/testing/vitest-plugin` with Vitest. It is also setup to
|
|
4
|
-
* reset all state before each test.
|
|
5
|
-
*
|
|
6
|
-
* This module is just a re-export of [@webext-core/fake-browser](https://webext-core.aklinker1.io/fake-browser/triggering-events).
|
|
7
|
-
*
|
|
8
|
-
* @module wxt/testing/fake-browser
|
|
9
|
-
*/
|
|
10
|
-
export { fakeBrowser, type FakeBrowser } from '@webext-core/fake-browser';
|
package/dist/testing/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for unit testing WXT extensions.
|
|
3
|
-
*
|
|
4
|
-
* @deprecated Use `wxt/testing/*` instead to prevent issues with JSDOM or
|
|
5
|
-
* HappyDOM environments. Will be removed in the next major version of WXT.
|
|
6
|
-
*
|
|
7
|
-
* @module wxt/testing
|
|
8
|
-
*/
|
|
9
|
-
export * from './fake-browser';
|
|
10
|
-
export * from './wxt-vitest-plugin';
|