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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Browser, browser as browser$1 } from "@wxt-dev/browser";
|
|
2
|
+
|
|
3
|
+
//#region src/browser.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* This interface is empty because it is generated per-project when running `wxt prepare`. See:
|
|
6
|
+
* - `.wxt/types/paths.d.ts`
|
|
7
|
+
*/
|
|
8
|
+
interface WxtRuntime {}
|
|
9
|
+
/**
|
|
10
|
+
* This interface is empty because it is generated per-project when running `wxt prepare`. See:
|
|
11
|
+
* - `.wxt/types/i18n.d.ts`
|
|
12
|
+
*/
|
|
13
|
+
interface WxtI18n {}
|
|
14
|
+
type WxtBrowser = Omit<typeof browser$1, 'runtime' | 'i18n'> & {
|
|
15
|
+
runtime: WxtRuntime & Omit<(typeof browser$1)['runtime'], 'getURL'>;
|
|
16
|
+
i18n: WxtI18n & Omit<(typeof browser$1)['i18n'], 'getMessage'>;
|
|
17
|
+
};
|
|
18
|
+
declare const browser: WxtBrowser;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Browser, WxtBrowser, WxtI18n, WxtRuntime, browser };
|
package/dist/browser.mjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import { browser as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { browser as browser$1 } from "@wxt-dev/browser";
|
|
2
|
+
|
|
3
|
+
//#region src/browser.ts
|
|
4
|
+
/**
|
|
5
|
+
* Contains the `browser` export which you should use to access the extension APIs in your project:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { browser } from 'wxt/browser';
|
|
8
|
+
*
|
|
9
|
+
* browser.runtime.onInstalled.addListener(() => {
|
|
10
|
+
* // ...
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
* @module wxt/browser
|
|
14
|
+
*/
|
|
15
|
+
const browser = browser$1;
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { browser };
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import unimport_default from "./unimport.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/builtin-modules/index.ts
|
|
4
|
+
const builtinModules = [unimport_default];
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { builtinModules };
|
|
@@ -1,88 +1,79 @@
|
|
|
1
1
|
import { addViteConfig, defineWxtModule } from "../modules.mjs";
|
|
2
2
|
import { createUnimport, toExports } from "unimport";
|
|
3
3
|
import UnimportPlugin from "unimport/unplugin";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
wxt.config.imports
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
addViteConfig(wxt, () => ({
|
|
38
|
-
plugins: [UnimportPlugin.vite(wxt.config.imports)]
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
4
|
+
|
|
5
|
+
//#region src/builtin-modules/unimport.ts
|
|
6
|
+
var unimport_default = defineWxtModule({
|
|
7
|
+
name: "wxt:built-in:unimport",
|
|
8
|
+
setup(wxt) {
|
|
9
|
+
let unimport;
|
|
10
|
+
const isEnabled = () => !wxt.config.imports.disabled;
|
|
11
|
+
wxt.hooks.hook("config:resolved", () => {
|
|
12
|
+
const addModuleImports = (module) => {
|
|
13
|
+
if (!module.imports) return;
|
|
14
|
+
wxt.config.imports.imports ??= [];
|
|
15
|
+
wxt.config.imports.imports.push(...module.imports);
|
|
16
|
+
};
|
|
17
|
+
wxt.config.builtinModules.forEach(addModuleImports);
|
|
18
|
+
wxt.config.userModules.forEach(addModuleImports);
|
|
19
|
+
});
|
|
20
|
+
wxt.hooks.afterEach((event) => {
|
|
21
|
+
if (event.name === "config:resolved") unimport = createUnimport(wxt.config.imports);
|
|
22
|
+
});
|
|
23
|
+
wxt.hooks.hook("prepare:types", async (_, entries) => {
|
|
24
|
+
await unimport.init();
|
|
25
|
+
entries.push(await getImportsModuleEntry(wxt, unimport));
|
|
26
|
+
if (!isEnabled()) return;
|
|
27
|
+
entries.push(await getImportsDeclarationEntry(unimport));
|
|
28
|
+
if (wxt.config.imports.eslintrc.enabled === false) return;
|
|
29
|
+
entries.push(await getEslintConfigEntry(unimport, wxt.config.imports.eslintrc.enabled, wxt.config.imports));
|
|
30
|
+
});
|
|
31
|
+
addViteConfig(wxt, () => ({ plugins: [UnimportPlugin.vite(wxt.config.imports)] }));
|
|
32
|
+
}
|
|
41
33
|
});
|
|
42
34
|
async function getImportsDeclarationEntry(unimport) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
return {
|
|
36
|
+
path: "types/imports.d.ts",
|
|
37
|
+
text: [
|
|
38
|
+
"// Generated by wxt",
|
|
39
|
+
await unimport.generateTypeDeclarations(),
|
|
40
|
+
""
|
|
41
|
+
].join("\n"),
|
|
42
|
+
tsReference: true
|
|
43
|
+
};
|
|
52
44
|
}
|
|
53
45
|
async function getImportsModuleEntry(wxt, unimport) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
46
|
+
return {
|
|
47
|
+
path: "types/imports-module.d.ts",
|
|
48
|
+
text: [
|
|
49
|
+
"// Generated by wxt",
|
|
50
|
+
"// Types for the #import virtual module",
|
|
51
|
+
"declare module '#imports' {",
|
|
52
|
+
` ${toExports(await unimport.getImports(), wxt.config.wxtDir, true).replaceAll("\n", "\n ")}`,
|
|
53
|
+
"}",
|
|
54
|
+
""
|
|
55
|
+
].join("\n"),
|
|
56
|
+
tsReference: true
|
|
57
|
+
};
|
|
67
58
|
}
|
|
68
59
|
async function getEslintConfigEntry(unimport, version, options) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
const globals = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals, name) => {
|
|
61
|
+
globals[name] = options.eslintrc.globalsPropValue;
|
|
62
|
+
return globals;
|
|
63
|
+
}, {});
|
|
64
|
+
if (version <= 8) return getEslint8ConfigEntry(options, globals);
|
|
65
|
+
else return getEslint9ConfigEntry(options, globals);
|
|
75
66
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
function getEslint8ConfigEntry(options, globals) {
|
|
68
|
+
return {
|
|
69
|
+
path: options.eslintrc.filePath,
|
|
70
|
+
text: JSON.stringify({ globals }, null, 2) + "\n"
|
|
71
|
+
};
|
|
81
72
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
function getEslint9ConfigEntry(options, globals) {
|
|
74
|
+
return {
|
|
75
|
+
path: options.eslintrc.filePath,
|
|
76
|
+
text: `const globals = ${JSON.stringify(globals, null, 2)}
|
|
86
77
|
|
|
87
78
|
export default {
|
|
88
79
|
name: "wxt/auto-imports",
|
|
@@ -93,5 +84,8 @@ export default {
|
|
|
93
84
|
},
|
|
94
85
|
};
|
|
95
86
|
`
|
|
96
|
-
|
|
87
|
+
};
|
|
97
88
|
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { unimport_default as default };
|
package/dist/cli/cli-utils.mjs
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
import consola, { LogLevels } from "consola";
|
|
2
|
-
import { filterTruthy, toArray } from "../core/utils/arrays.mjs";
|
|
3
|
-
import { printHeader } from "../core/utils/log/index.mjs";
|
|
4
1
|
import { formatDuration } from "../core/utils/time.mjs";
|
|
5
|
-
import {
|
|
2
|
+
import { filterTruthy, toArray } from "../core/utils/arrays.mjs";
|
|
6
3
|
import { registerWxt } from "../core/wxt.mjs";
|
|
4
|
+
import { printHeader } from "../core/utils/log/printHeader.mjs";
|
|
5
|
+
import "../core/utils/log/index.mjs";
|
|
6
|
+
import { ValidationError } from "../core/utils/validation.mjs";
|
|
7
|
+
import consola, { LogLevels } from "consola";
|
|
7
8
|
import spawn from "nano-spawn";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (err instanceof ValidationError) {
|
|
27
|
-
} else {
|
|
28
|
-
consola.error(err);
|
|
29
|
-
}
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
9
|
+
|
|
10
|
+
//#region src/cli/cli-utils.ts
|
|
11
|
+
/**
|
|
12
|
+
* Wrap an action handler to add a timer, error handling, and maybe enable debug mode.
|
|
13
|
+
*/
|
|
14
|
+
function wrapAction(cb, options) {
|
|
15
|
+
return async (...args) => {
|
|
16
|
+
if (!!args.find((arg) => arg?.debug)) consola.level = LogLevels.debug;
|
|
17
|
+
const startTime = Date.now();
|
|
18
|
+
try {
|
|
19
|
+
printHeader();
|
|
20
|
+
if (!(await cb(...args))?.isOngoing && !options?.disableFinishedLog) consola.success(`Finished in ${formatDuration(Date.now() - startTime)}`);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
consola.fail(`Command failed after ${formatDuration(Date.now() - startTime)}`);
|
|
23
|
+
if (err instanceof ValidationError) {} else consola.error(err);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Array flags, when not passed, are either `undefined` or `[undefined]`. This function filters out
|
|
30
|
+
* the
|
|
31
|
+
*/
|
|
32
|
+
function getArrayFromFlags(flags, name) {
|
|
33
|
+
const result = filterTruthy(toArray(flags[name]));
|
|
34
|
+
return result.length ? result : void 0;
|
|
38
35
|
}
|
|
39
36
|
const aliasCommandNames = /* @__PURE__ */ new Set();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @param base Command to add this one to
|
|
39
|
+
* @param name The command name to add
|
|
40
|
+
* @param alias The CLI tool being aliased
|
|
41
|
+
* @param bin The CLI tool binary name. Usually the same as the alias
|
|
42
|
+
* @param docsUrl URL to the docs for the aliased CLI tool
|
|
43
|
+
*/
|
|
44
|
+
function createAliasedCommand(base, name, alias, bin, docsUrl) {
|
|
45
|
+
const aliasedCommand = base.command(name, `Alias for ${alias} (${docsUrl})`).allowUnknownOptions().action(async () => {
|
|
46
|
+
try {
|
|
47
|
+
await registerWxt("build");
|
|
48
|
+
await spawn(bin, process.argv.slice(process.argv.indexOf(aliasedCommand.name) + 1), { stdio: "inherit" });
|
|
49
|
+
} catch {
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
aliasCommandNames.add(aliasedCommand.name);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
function isAliasedCommand(command) {
|
|
56
|
+
return !!command && aliasCommandNames.has(command.name);
|
|
58
57
|
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { createAliasedCommand, getArrayFromFlags, isAliasedCommand, wrapAction };
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -1,106 +1,80 @@
|
|
|
1
|
+
import { build } from "../core/build.mjs";
|
|
2
|
+
import { clean } from "../core/clean.mjs";
|
|
3
|
+
import { createServer } from "../core/create-server.mjs";
|
|
4
|
+
import { initialize } from "../core/initialize.mjs";
|
|
5
|
+
import { prepare } from "../core/prepare.mjs";
|
|
6
|
+
import { zip } from "../core/zip.mjs";
|
|
7
|
+
import "../core/index.mjs";
|
|
8
|
+
import { createAliasedCommand, getArrayFromFlags, wrapAction } from "./cli-utils.mjs";
|
|
1
9
|
import cac from "cac";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
createAliasedCommand,
|
|
5
|
-
getArrayFromFlags,
|
|
6
|
-
wrapAction
|
|
7
|
-
} from "./cli-utils.mjs";
|
|
10
|
+
|
|
11
|
+
//#region src/cli/commands.ts
|
|
8
12
|
const cli = cac("wxt");
|
|
9
13
|
cli.option("--debug", "enable debug mode");
|
|
10
|
-
cli.command("[root]", "start dev server").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option("--host <host>", "specify a host for the dev server to bind to").option("-p, --port <port>", "specify a port for the dev server to bind to").option(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
).option("--
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
cli
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
configFile: flags.config,
|
|
78
|
-
debug: flags.debug
|
|
79
|
-
});
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
cli.command("clean [root]", "clean generated files and caches").alias("cleanup").option("-c, --config <file>", "use specified config file").action(
|
|
83
|
-
wrapAction(async (root, flags) => {
|
|
84
|
-
await clean({ root, configFile: flags.config, debug: flags.debug });
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").action(
|
|
88
|
-
wrapAction(
|
|
89
|
-
async (directory, flags) => {
|
|
90
|
-
await initialize({
|
|
91
|
-
directory,
|
|
92
|
-
template: flags.template,
|
|
93
|
-
packageManager: flags.pm
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
{ disableFinishedLog: true }
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
createAliasedCommand(
|
|
100
|
-
cli,
|
|
101
|
-
"submit",
|
|
102
|
-
"publish-extension",
|
|
103
|
-
"wxt-publish-extension",
|
|
104
|
-
"https://www.npmjs.com/publish-browser-extension"
|
|
105
|
-
);
|
|
106
|
-
export default cli;
|
|
14
|
+
cli.command("[root]", "start dev server").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option("--host <host>", "specify a host for the dev server to bind to").option("-p, --port <port>", "specify a port for the dev server to bind to").option("-e, --filter-entrypoint <entrypoint>", "only build specific entrypoints", { type: [] }).option("--mv3", "target manifest v3").option("--mv2", "target manifest v2").action(wrapAction(async (root, flags) => {
|
|
15
|
+
const serverOptions = {};
|
|
16
|
+
if (flags.host) serverOptions.host = flags.host;
|
|
17
|
+
if (flags.port) serverOptions.port = parseInt(flags.port);
|
|
18
|
+
await (await createServer({
|
|
19
|
+
root,
|
|
20
|
+
mode: flags.mode,
|
|
21
|
+
browser: flags.browser,
|
|
22
|
+
manifestVersion: flags.mv3 ? 3 : flags.mv2 ? 2 : void 0,
|
|
23
|
+
configFile: flags.config,
|
|
24
|
+
debug: flags.debug,
|
|
25
|
+
filterEntrypoints: getArrayFromFlags(flags, "filterEntrypoint"),
|
|
26
|
+
dev: Object.keys(serverOptions).length === 0 ? void 0 : { server: serverOptions }
|
|
27
|
+
})).start();
|
|
28
|
+
return { isOngoing: true };
|
|
29
|
+
}));
|
|
30
|
+
cli.command("build [root]", "build for production").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option("-e, --filter-entrypoint <entrypoint>", "only build specific entrypoints", { type: [] }).option("--mv3", "target manifest v3").option("--mv2", "target manifest v2").option("--analyze", "visualize extension bundle").option("--analyze-open", "automatically open stats.html in browser").action(wrapAction(async (root, flags) => {
|
|
31
|
+
await build({
|
|
32
|
+
root,
|
|
33
|
+
mode: flags.mode,
|
|
34
|
+
browser: flags.browser,
|
|
35
|
+
manifestVersion: flags.mv3 ? 3 : flags.mv2 ? 2 : void 0,
|
|
36
|
+
configFile: flags.config,
|
|
37
|
+
debug: flags.debug,
|
|
38
|
+
analysis: flags.analyze ? {
|
|
39
|
+
enabled: true,
|
|
40
|
+
open: flags.analyzeOpen
|
|
41
|
+
} : void 0,
|
|
42
|
+
filterEntrypoints: getArrayFromFlags(flags, "filterEntrypoint")
|
|
43
|
+
});
|
|
44
|
+
}));
|
|
45
|
+
cli.command("zip [root]", "build for production and zip output").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option("--mv3", "target manifest v3").option("--mv2", "target manifest v2").option("--sources", "always create sources zip").action(wrapAction(async (root, flags) => {
|
|
46
|
+
await zip({
|
|
47
|
+
root,
|
|
48
|
+
mode: flags.mode,
|
|
49
|
+
browser: flags.browser,
|
|
50
|
+
manifestVersion: flags.mv3 ? 3 : flags.mv2 ? 2 : void 0,
|
|
51
|
+
configFile: flags.config,
|
|
52
|
+
debug: flags.debug,
|
|
53
|
+
zip: { zipSources: flags.sources }
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
cli.command("prepare [root]", "prepare typescript project").option("-c, --config <file>", "use specified config file").action(wrapAction(async (root, flags) => {
|
|
57
|
+
await prepare({
|
|
58
|
+
root,
|
|
59
|
+
configFile: flags.config,
|
|
60
|
+
debug: flags.debug
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
cli.command("clean [root]", "clean generated files and caches").alias("cleanup").option("-c, --config <file>", "use specified config file").action(wrapAction(async (root, flags) => {
|
|
64
|
+
await clean({
|
|
65
|
+
root,
|
|
66
|
+
configFile: flags.config,
|
|
67
|
+
debug: flags.debug
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
70
|
+
cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").action(wrapAction(async (directory, flags) => {
|
|
71
|
+
await initialize({
|
|
72
|
+
directory,
|
|
73
|
+
template: flags.template,
|
|
74
|
+
packageManager: flags.pm
|
|
75
|
+
});
|
|
76
|
+
}, { disableFinishedLog: true }));
|
|
77
|
+
createAliasedCommand(cli, "submit", "publish-extension", "wxt-publish-extension", "https://www.npmjs.com/publish-browser-extension");
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { cli as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import cli from "./commands.mjs";
|
|
2
1
|
import { version } from "../version.mjs";
|
|
3
2
|
import { isAliasedCommand } from "./cli-utils.mjs";
|
|
3
|
+
import cli from "./commands.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/index.ts
|
|
4
6
|
cli.parse(process.argv, { run: false });
|
|
5
7
|
if (!isAliasedCommand(cli.matchedCommand)) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
cli.help();
|
|
9
|
+
cli.version(version);
|
|
10
|
+
cli.parse(process.argv, { run: false });
|
|
9
11
|
}
|
|
10
12
|
await cli.runMatchedCommand();
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { BuildOutput, InlineConfig } from
|
|
1
|
+
import { BuildOutput, InlineConfig } from "../types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/build.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
4
6
|
* the root directory, and merges that config with what is passed in.
|
|
@@ -12,4 +14,6 @@ import { BuildOutput, InlineConfig } from '../types';
|
|
|
12
14
|
* // Override config...
|
|
13
15
|
* })
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
declare function build(config?: InlineConfig): Promise<BuildOutput>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { build };
|
package/dist/core/build.mjs
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import { internalBuild } from "./utils/building/index.mjs";
|
|
2
1
|
import { registerWxt } from "./wxt.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { internalBuild } from "./utils/building/internal-build.mjs";
|
|
3
|
+
import "./utils/building/index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/core/build.ts
|
|
6
|
+
/**
|
|
7
|
+
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
8
|
+
* the root directory, and merges that config with what is passed in.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Use config from `wxt.config.ts`
|
|
12
|
+
* const res = await build()
|
|
13
|
+
*
|
|
14
|
+
* // or override config `from wxt.config.ts`
|
|
15
|
+
* const res = await build({
|
|
16
|
+
* // Override config...
|
|
17
|
+
* })
|
|
18
|
+
*/
|
|
19
|
+
async function build(config) {
|
|
20
|
+
await registerWxt("build", config);
|
|
21
|
+
return await internalBuild();
|
|
6
22
|
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { build };
|