wxt 0.19.22 → 0.20.0-beta1
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/README.md +6 -0
- package/dist/browser.d.ts +28 -0
- package/dist/builtin-modules/unimport.d.ts +1 -1
- package/dist/builtin-modules/unimport.mjs +36 -12
- package/dist/cli/index.mjs +0 -1
- package/dist/core/builders/vite/index.mjs +21 -38
- 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/create-server.mjs +1 -0
- 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 +4 -6
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/core/initialize.mjs +2 -5
- package/dist/core/keyboard-shortcuts.mjs +3 -9
- package/dist/core/resolve-config.mjs +152 -55
- package/dist/core/runners/web-ext.mjs +1 -1
- package/dist/core/utils/building/find-entrypoints.mjs +2 -1
- 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 +1 -2
- package/dist/core/utils/content-scripts.d.ts +3 -3
- package/dist/core/utils/content-scripts.mjs +2 -0
- package/dist/core/utils/eslint.mjs +3 -5
- package/dist/core/utils/manifest.d.ts +3 -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 +3416 -991
- 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 +2 -0
- package/dist/core/utils/validation.mjs +2 -2
- 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 +3 -5
- package/dist/types.d.ts +48 -70
- 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 +0 -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 +108 -71
- package/dist/browser/chrome.d.ts +0 -13
- 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 -100
- package/dist/sandbox/index.d.ts +0 -11
- package/dist/sandbox/index.mjs +0 -6
- package/dist/storage.d.ts +0 -4
- /package/dist/{browser/chrome.mjs → browser.mjs} +0 -0
- /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
package/README.md
CHANGED
|
@@ -76,6 +76,12 @@ Or see the [installation guide](https://wxt.dev/guide/installation.html) to get
|
|
|
76
76
|
- 📏 Bundle analysis
|
|
77
77
|
- ⬇️ Download and bundle remote URL imports
|
|
78
78
|
|
|
79
|
+
## Sponsors
|
|
80
|
+
|
|
81
|
+
WXT is a [MIT-licensed](https://github.com/wxt-dev/wxt/blob/main/LICENSE) open source project with its ongoing development made possible entirely by the support of these awesome backers. If you'd like to join them, please consider [sponsoring WXT's development](https://github.com/sponsors/wxt-dev).
|
|
82
|
+
|
|
83
|
+
<a href="https://github.com/sponsors/wxt-dev"><img alt="WXT Sponsors" src="https://raw.githubusercontent.com/wxt-dev/static/refs/heads/main/sponsorkit/sponsors.svg"></a>
|
|
84
|
+
|
|
79
85
|
## Contributors
|
|
80
86
|
|
|
81
87
|
<!-- automd:contributors author="aklinker1" license="MIT" github="wxt-dev/wxt" -->
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains the `browser` export which you should use to access the extension APIs in your project:
|
|
3
|
+
* ```ts
|
|
4
|
+
* import { browser } from 'wxt/browser';
|
|
5
|
+
*
|
|
6
|
+
* browser.runtime.onInstalled.addListener(() => {
|
|
7
|
+
* // ...
|
|
8
|
+
* })
|
|
9
|
+
* ```
|
|
10
|
+
* @module wxt/browser
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* This interface is empty because it is generated per-project when running `wxt prepare`. See:
|
|
14
|
+
* - `.wxt/types/paths.d.ts`
|
|
15
|
+
*/
|
|
16
|
+
export interface WxtRuntime {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This interface is empty because it is generated per-project when running `wxt prepare`. See:
|
|
20
|
+
* - `.wxt/types/i18n.d.ts`
|
|
21
|
+
*/
|
|
22
|
+
export interface WxtI18n {
|
|
23
|
+
}
|
|
24
|
+
export type WxtBrowser = Omit<typeof chrome, 'runtime' | 'i18n'> & {
|
|
25
|
+
runtime: WxtRuntime & Omit<(typeof chrome)['runtime'], 'getURL'>;
|
|
26
|
+
i18n: WxtI18n & Omit<(typeof chrome)['i18n'], 'getMessage'>;
|
|
27
|
+
};
|
|
28
|
+
export declare const browser: WxtBrowser;
|
|
@@ -3,6 +3,6 @@ import { type Unimport } from 'unimport';
|
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
declare const _default: WxtModule<import("../types").WxtModuleOptions>;
|
|
5
5
|
export default _default;
|
|
6
|
-
export declare function vitePlugin(unimport: Unimport): Plugin;
|
|
6
|
+
export declare function vitePlugin(unimport: Unimport, autoImportsEnabled: boolean): Plugin;
|
|
7
7
|
export declare function getEslint8ConfigEntry(options: WxtResolvedUnimportOptions, globals: Record<string, EslintGlobalsPropValue>): WxtDirFileEntry;
|
|
8
8
|
export declare function getEslint9ConfigEntry(options: WxtResolvedUnimportOptions, globals: Record<string, EslintGlobalsPropValue>): WxtDirFileEntry;
|
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
import { addViteConfig, defineWxtModule } from "../modules.mjs";
|
|
2
|
-
import { createUnimport } from "unimport";
|
|
2
|
+
import { createUnimport, toExports } from "unimport";
|
|
3
3
|
import { extname } from "node:path";
|
|
4
4
|
export default defineWxtModule({
|
|
5
5
|
name: "wxt:built-in:unimport",
|
|
6
6
|
setup(wxt) {
|
|
7
|
-
const options = wxt.config.imports;
|
|
8
|
-
if (options === false) return;
|
|
9
7
|
let unimport;
|
|
8
|
+
const isEnabled = () => !wxt.config.imports.disabled;
|
|
10
9
|
wxt.hooks.hook("config:resolved", () => {
|
|
11
10
|
const addModuleImports = (module) => {
|
|
12
11
|
if (!module.imports) return;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
wxt.config.imports.imports ??= [];
|
|
13
|
+
wxt.config.imports.imports.push(...module.imports);
|
|
15
14
|
};
|
|
16
15
|
wxt.config.builtinModules.forEach(addModuleImports);
|
|
17
16
|
wxt.config.userModules.forEach(addModuleImports);
|
|
18
17
|
});
|
|
19
18
|
wxt.hooks.afterEach((event) => {
|
|
20
19
|
if (event.name === "config:resolved") {
|
|
21
|
-
unimport = createUnimport(
|
|
20
|
+
unimport = createUnimport(wxt.config.imports);
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
wxt.hooks.hook("prepare:types", async (_, entries) => {
|
|
25
24
|
await unimport.init();
|
|
25
|
+
entries.push(await getImportsModuleEntry(wxt, unimport));
|
|
26
|
+
if (!isEnabled()) return;
|
|
26
27
|
entries.push(await getImportsDeclarationEntry(unimport));
|
|
27
|
-
if (
|
|
28
|
+
if (wxt.config.imports.eslintrc.enabled === false) return;
|
|
28
29
|
entries.push(
|
|
29
|
-
await getEslintConfigEntry(
|
|
30
|
+
await getEslintConfigEntry(
|
|
31
|
+
unimport,
|
|
32
|
+
wxt.config.imports.eslintrc.enabled,
|
|
33
|
+
wxt.config.imports
|
|
34
|
+
)
|
|
30
35
|
);
|
|
31
36
|
});
|
|
32
37
|
addViteConfig(wxt, () => ({
|
|
33
|
-
plugins: [vitePlugin(unimport)]
|
|
38
|
+
plugins: [vitePlugin(unimport, isEnabled())]
|
|
34
39
|
}));
|
|
35
40
|
}
|
|
36
41
|
});
|
|
37
|
-
export function vitePlugin(unimport) {
|
|
42
|
+
export function vitePlugin(unimport, autoImportsEnabled) {
|
|
38
43
|
const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
39
44
|
".js",
|
|
40
45
|
".jsx",
|
|
@@ -48,7 +53,12 @@ export function vitePlugin(unimport) {
|
|
|
48
53
|
async transform(code, id) {
|
|
49
54
|
if (id.includes("node_modules")) return;
|
|
50
55
|
if (!ENABLED_EXTENSIONS.has(extname(id))) return;
|
|
51
|
-
const injected = await unimport.injectImports(code, id
|
|
56
|
+
const injected = await unimport.injectImports(code, id, {
|
|
57
|
+
// Only auto-import modules if enabled
|
|
58
|
+
autoImport: autoImportsEnabled,
|
|
59
|
+
// Always resolve the #imports module, even when auto-imports are disabled
|
|
60
|
+
transformVirtualImports: true
|
|
61
|
+
});
|
|
52
62
|
return {
|
|
53
63
|
code: injected.code,
|
|
54
64
|
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
@@ -57,7 +67,6 @@ export function vitePlugin(unimport) {
|
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
69
|
async function getImportsDeclarationEntry(unimport) {
|
|
60
|
-
await unimport.init();
|
|
61
70
|
return {
|
|
62
71
|
path: "types/imports.d.ts",
|
|
63
72
|
text: [
|
|
@@ -68,6 +77,21 @@ async function getImportsDeclarationEntry(unimport) {
|
|
|
68
77
|
tsReference: true
|
|
69
78
|
};
|
|
70
79
|
}
|
|
80
|
+
async function getImportsModuleEntry(wxt, unimport) {
|
|
81
|
+
const imports = await unimport.getImports();
|
|
82
|
+
return {
|
|
83
|
+
path: "types/imports-module.d.ts",
|
|
84
|
+
text: [
|
|
85
|
+
"// Generated by wxt",
|
|
86
|
+
"// Types for the #import virtual module",
|
|
87
|
+
"declare module '#imports' {",
|
|
88
|
+
` ${toExports(imports, wxt.config.wxtDir, true).replaceAll("\n", "\n ")}`,
|
|
89
|
+
"}",
|
|
90
|
+
""
|
|
91
|
+
].join("\n"),
|
|
92
|
+
tsReference: true
|
|
93
|
+
};
|
|
94
|
+
}
|
|
71
95
|
async function getEslintConfigEntry(unimport, version, options) {
|
|
72
96
|
const globals = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals2, name) => {
|
|
73
97
|
globals2[name] = options.eslintrc.globalsPropValue;
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import cli from "./commands.mjs";
|
|
2
2
|
import { version } from "../version.mjs";
|
|
3
3
|
import { isAliasedCommand } from "./cli-utils.mjs";
|
|
4
|
-
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
5
4
|
cli.parse(process.argv, { run: false });
|
|
6
5
|
if (!isAliasedCommand(cli.matchedCommand)) {
|
|
7
6
|
cli.help();
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
} from "../../utils/entrypoints.mjs";
|
|
6
6
|
import { toArray } from "../../utils/arrays.mjs";
|
|
7
7
|
import { safeVarName } from "../../utils/strings.mjs";
|
|
8
|
-
import { importEntrypointFile } from "../../utils/building/index.mjs";
|
|
9
8
|
import { ViteNodeServer } from "vite-node/server";
|
|
10
9
|
import { ViteNodeRunner } from "vite-node/client";
|
|
11
10
|
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
@@ -45,7 +44,6 @@ export async function createViteBuilder(wxtConfig, hooks, getWxtDevServer) {
|
|
|
45
44
|
wxtPlugins.tsconfigPaths(wxtConfig),
|
|
46
45
|
wxtPlugins.noopBackground(),
|
|
47
46
|
wxtPlugins.globals(wxtConfig),
|
|
48
|
-
wxtPlugins.resolveExtensionApi(wxtConfig),
|
|
49
47
|
wxtPlugins.defineImportMeta(),
|
|
50
48
|
wxtPlugins.wxtPluginLoader(wxtConfig),
|
|
51
49
|
wxtPlugins.resolveAppConfig(wxtConfig)
|
|
@@ -214,44 +212,26 @@ export async function createViteBuilder(wxtConfig, hooks, getWxtDevServer) {
|
|
|
214
212
|
version: vite.version,
|
|
215
213
|
async importEntrypoint(path) {
|
|
216
214
|
const env = createExtensionEnvironment();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
case "vite-node": {
|
|
223
|
-
const { runner, server } = await createViteNodeImporter([path]);
|
|
224
|
-
const res = await env.run(() => runner.executeFile(path));
|
|
225
|
-
await server.close();
|
|
226
|
-
requireDefaultExport(path, res);
|
|
227
|
-
return res.default;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
215
|
+
const { runner, server } = await createViteNodeImporter([path]);
|
|
216
|
+
const res = await env.run(() => runner.executeFile(path));
|
|
217
|
+
await server.close();
|
|
218
|
+
requireDefaultExport(path, res);
|
|
219
|
+
return res.default;
|
|
230
220
|
},
|
|
231
221
|
async importEntrypoints(paths) {
|
|
232
222
|
const env = createExtensionEnvironment();
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const mod = await runner.executeFile(path);
|
|
246
|
-
requireDefaultExport(path, mod);
|
|
247
|
-
return mod.default;
|
|
248
|
-
})
|
|
249
|
-
)
|
|
250
|
-
);
|
|
251
|
-
await server.close();
|
|
252
|
-
return res;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
223
|
+
const { runner, server } = await createViteNodeImporter(paths);
|
|
224
|
+
const res = await env.run(
|
|
225
|
+
() => Promise.all(
|
|
226
|
+
paths.map(async (path) => {
|
|
227
|
+
const mod = await runner.executeFile(path);
|
|
228
|
+
requireDefaultExport(path, mod);
|
|
229
|
+
return mod.default;
|
|
230
|
+
})
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
await server.close();
|
|
234
|
+
return res;
|
|
255
235
|
},
|
|
256
236
|
async build(group) {
|
|
257
237
|
let entryConfig;
|
|
@@ -302,7 +282,10 @@ export async function createViteBuilder(wxtConfig, hooks, getWxtDevServer) {
|
|
|
302
282
|
viteServer.ws.on(message, cb);
|
|
303
283
|
}
|
|
304
284
|
},
|
|
305
|
-
watcher: viteServer.watcher
|
|
285
|
+
watcher: viteServer.watcher,
|
|
286
|
+
on(event, cb) {
|
|
287
|
+
viteServer.httpServer?.on(event, cb);
|
|
288
|
+
}
|
|
306
289
|
};
|
|
307
290
|
return server;
|
|
308
291
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
2
|
import { ResolvedConfig } from '../../../../types';
|
|
3
3
|
/**
|
|
4
|
-
* Mock `
|
|
5
|
-
* all dependencies that import them and adding a custom alias so that Vite
|
|
6
|
-
* resolves to a mocked version of the module.
|
|
7
|
-
*
|
|
8
|
-
* TODO: Detect non-wxt dependencies (like `@webext-core/*`) that import `webextension-polyfill` via
|
|
9
|
-
* `npm list` and inline them automatically.
|
|
4
|
+
* Mock `wxt/browser` and stub the global `browser`/`chrome` types with a fake version of the extension APIs
|
|
10
5
|
*/
|
|
11
6
|
export declare function extensionApiMock(config: ResolvedConfig): vite.PluginOption;
|
|
@@ -15,14 +15,12 @@ export function extensionApiMock(config) {
|
|
|
15
15
|
},
|
|
16
16
|
resolve: {
|
|
17
17
|
alias: [
|
|
18
|
-
{ find: "webextension-polyfill", replacement },
|
|
19
18
|
// wxt/browser, wxt/browser/...
|
|
20
|
-
{ find:
|
|
19
|
+
{ find: "wxt/browser", replacement }
|
|
21
20
|
]
|
|
22
21
|
},
|
|
23
22
|
ssr: {
|
|
24
|
-
// Inline all WXT modules
|
|
25
|
-
// be resolved
|
|
23
|
+
// Inline all WXT modules subdependencies can be mocked
|
|
26
24
|
noExternal: ["wxt"]
|
|
27
25
|
}
|
|
28
26
|
};
|
|
@@ -9,7 +9,6 @@ export * from './cssEntrypoints';
|
|
|
9
9
|
export * from './bundleAnalysis';
|
|
10
10
|
export * from './globals';
|
|
11
11
|
export * from './extensionApiMock';
|
|
12
|
-
export * from './resolveExtensionApi';
|
|
13
12
|
export * from './entrypointGroupGlobals';
|
|
14
13
|
export * from './defineImportMeta';
|
|
15
14
|
export * from './removeEntrypointMainFunction';
|
|
@@ -9,7 +9,6 @@ export * from "./cssEntrypoints.mjs";
|
|
|
9
9
|
export * from "./bundleAnalysis.mjs";
|
|
10
10
|
export * from "./globals.mjs";
|
|
11
11
|
export * from "./extensionApiMock.mjs";
|
|
12
|
-
export * from "./resolveExtensionApi.mjs";
|
|
13
12
|
export * from "./entrypointGroupGlobals.mjs";
|
|
14
13
|
export * from "./defineImportMeta.mjs";
|
|
15
14
|
export * from "./removeEntrypointMainFunction.mjs";
|
|
@@ -9,7 +9,7 @@ export function noopBackground() {
|
|
|
9
9
|
},
|
|
10
10
|
load(id) {
|
|
11
11
|
if (id === resolvedVirtualModuleId) {
|
|
12
|
-
return `import { defineBackground } from 'wxt/
|
|
12
|
+
return `import { defineBackground } from 'wxt/utils/define-background';
|
|
13
13
|
export default defineBackground(() => void 0)`;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebExtConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `defineWebExtConfig` instead. Same function, different name.
|
|
4
|
+
*/
|
|
5
|
+
export declare function defineRunnerConfig(config: WebExtConfig): WebExtConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Configure how [`web-ext`](https://github.com/mozilla/web-ext) starts the browser during development.
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineWebExtConfig(config: WebExtConfig): WebExtConfig;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import consola from "consola";
|
|
2
|
+
export function defineRunnerConfig(config) {
|
|
3
|
+
consola.warn(
|
|
4
|
+
"`defineRunnerConfig` is deprecated, use `defineWebExtConfig` instead. See https://wxt.dev/guide/resources/upgrading.html#v0-19-0-rarr-v0-20-0"
|
|
5
|
+
);
|
|
6
|
+
return defineWebExtConfig(config);
|
|
7
|
+
}
|
|
8
|
+
export function defineWebExtConfig(config) {
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
@@ -19,9 +19,7 @@ export async function generateWxtDir(entrypoints) {
|
|
|
19
19
|
entries.push(await getPathsDeclarationEntry(entrypoints));
|
|
20
20
|
entries.push(await getI18nDeclarationEntry());
|
|
21
21
|
entries.push(await getGlobalsDeclarationEntry());
|
|
22
|
-
|
|
23
|
-
entries.push({ module: "@types/chrome" });
|
|
24
|
-
}
|
|
22
|
+
entries.push({ module: "@types/chrome" });
|
|
25
23
|
entries.push(await getTsConfigEntry());
|
|
26
24
|
await wxt.hooks.callHook("prepare:types", wxt, entries);
|
|
27
25
|
entries.push(getMainDeclarationEntry(entries));
|
|
@@ -180,10 +178,10 @@ async function getTsConfigEntry() {
|
|
|
180
178
|
const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
|
|
181
179
|
const aliasPath = getTsconfigPath(absolutePath);
|
|
182
180
|
return [
|
|
183
|
-
`
|
|
184
|
-
`
|
|
181
|
+
`"${alias}": ["${aliasPath}"]`,
|
|
182
|
+
`"${alias}/*": ["${aliasPath}/*"]`
|
|
185
183
|
];
|
|
186
|
-
}).join(",\n");
|
|
184
|
+
}).map((line) => ` ${line}`).join(",\n");
|
|
187
185
|
const text = `{
|
|
188
186
|
"compilerOptions": {
|
|
189
187
|
"target": "ESNext",
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './build';
|
|
2
2
|
export * from './clean';
|
|
3
3
|
export * from './define-config';
|
|
4
|
-
export * from './define-
|
|
4
|
+
export * from './define-web-ext-config';
|
|
5
5
|
export * from './create-server';
|
|
6
6
|
export * from './initialize';
|
|
7
7
|
export * from './prepare';
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./build.mjs";
|
|
2
2
|
export * from "./clean.mjs";
|
|
3
3
|
export * from "./define-config.mjs";
|
|
4
|
-
export * from "./define-
|
|
4
|
+
export * from "./define-web-ext-config.mjs";
|
|
5
5
|
export * from "./create-server.mjs";
|
|
6
6
|
export * from "./initialize.mjs";
|
|
7
7
|
export * from "./prepare.mjs";
|
package/dist/core/initialize.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import fs from "fs-extra";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
export async function initialize(options) {
|
|
8
|
-
consola.info("
|
|
8
|
+
consola.info("Initializing new project");
|
|
9
9
|
const templates = await listTemplates();
|
|
10
10
|
const defaultTemplate = templates.find(
|
|
11
11
|
(template) => template.name === options.template?.toLowerCase().trim()
|
|
@@ -35,10 +35,7 @@ export async function initialize(options) {
|
|
|
35
35
|
{ title: pc.red("npm"), value: "npm" },
|
|
36
36
|
{ title: pc.yellow("pnpm"), value: "pnpm" },
|
|
37
37
|
{ title: pc.cyan("yarn"), value: "yarn" },
|
|
38
|
-
{
|
|
39
|
-
title: `${pc.magenta("bun")}${pc.gray(" (experimental)")}`,
|
|
40
|
-
value: "bun"
|
|
41
|
-
}
|
|
38
|
+
{ title: pc.magenta("bun"), value: "bun" }
|
|
42
39
|
]
|
|
43
40
|
}
|
|
44
41
|
],
|
|
@@ -2,7 +2,6 @@ import readline from "node:readline";
|
|
|
2
2
|
import { wxt } from "./wxt.mjs";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
export function createKeyboardShortcuts(server) {
|
|
5
|
-
let isWatching = false;
|
|
6
5
|
let rl;
|
|
7
6
|
const handleInput = (line) => {
|
|
8
7
|
if (line.trim() === "o") {
|
|
@@ -11,22 +10,17 @@ export function createKeyboardShortcuts(server) {
|
|
|
11
10
|
};
|
|
12
11
|
return {
|
|
13
12
|
start() {
|
|
14
|
-
if (
|
|
13
|
+
if (rl) return;
|
|
15
14
|
rl = readline.createInterface({
|
|
16
15
|
input: process.stdin,
|
|
17
16
|
terminal: false
|
|
18
17
|
// Don't intercept ctrl+C, ctrl+Z, etc
|
|
19
18
|
});
|
|
20
19
|
rl.on("line", handleInput);
|
|
21
|
-
isWatching = true;
|
|
22
20
|
},
|
|
23
21
|
stop() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
rl.close();
|
|
27
|
-
rl = void 0;
|
|
28
|
-
}
|
|
29
|
-
isWatching = false;
|
|
22
|
+
rl?.close();
|
|
23
|
+
rl = void 0;
|
|
30
24
|
},
|
|
31
25
|
printHelp(flags) {
|
|
32
26
|
if (flags.canReopenBrowser) {
|