wxt 0.19.17 → 0.19.19
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/client/content-scripts/content-script-context.d.ts +5 -4
- package/dist/client/content-scripts/content-script-context.mjs +0 -18
- package/dist/core/create-server.mjs +8 -1
- package/dist/core/keyboard-shortcuts.d.ts +10 -0
- package/dist/core/keyboard-shortcuts.mjs +39 -0
- package/dist/core/utils/building/find-entrypoints.mjs +46 -55
- package/dist/core/utils/building/group-entrypoints.d.ts +2 -2
- package/dist/core/utils/building/group-entrypoints.mjs +1 -0
- package/dist/core/utils/manifest.mjs +6 -2
- package/dist/core/utils/testing/fake-objects.d.ts +2 -2
- package/dist/core/utils/testing/fake-objects.mjs +8 -4
- package/dist/core/wxt.mjs +5 -0
- package/dist/core/zip.mjs +10 -2
- package/dist/types.d.ts +9 -1
- package/dist/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -99,11 +99,13 @@ export declare class ContentScriptContext implements AbortController {
|
|
|
99
99
|
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
100
100
|
* // ...
|
|
101
101
|
* });
|
|
102
|
-
* ctx.addEventListener(
|
|
102
|
+
* ctx.addEventListener(window, "wxt:locationchange", () => {
|
|
103
103
|
* // ...
|
|
104
104
|
* });
|
|
105
105
|
*/
|
|
106
|
-
addEventListener<
|
|
106
|
+
addEventListener<TType extends keyof WxtWindowEventMap>(target: Window, type: TType, handler: (event: WxtWindowEventMap[TType]) => void, options?: AddEventListenerOptions): void;
|
|
107
|
+
addEventListener<TType extends keyof DocumentEventMap>(target: Document, type: keyof DocumentEventMap, handler: (event: DocumentEventMap[TType]) => void, options?: AddEventListenerOptions): void;
|
|
108
|
+
addEventListener<TTarget extends EventTarget>(target: TTarget, ...params: Parameters<TTarget['addEventListener']>): void;
|
|
107
109
|
/**
|
|
108
110
|
* @internal
|
|
109
111
|
* Abort the abort controller and execute all `onInvalidated` listeners.
|
|
@@ -114,7 +116,6 @@ export declare class ContentScriptContext implements AbortController {
|
|
|
114
116
|
ignoreFirstEvent?: boolean;
|
|
115
117
|
}): void;
|
|
116
118
|
}
|
|
117
|
-
interface
|
|
119
|
+
export interface WxtWindowEventMap extends WindowEventMap {
|
|
118
120
|
'wxt:locationchange': WxtLocationChangeEvent;
|
|
119
121
|
}
|
|
120
|
-
export {};
|
|
@@ -109,30 +109,12 @@ export class ContentScriptContext {
|
|
|
109
109
|
this.onInvalidated(() => cancelIdleCallback(id));
|
|
110
110
|
return id;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Call `target.addEventListener` and remove the event listener when the context is invalidated.
|
|
114
|
-
*
|
|
115
|
-
* Includes additional events useful for content scripts:
|
|
116
|
-
*
|
|
117
|
-
* - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
|
|
118
|
-
* scripts are not reloaded when navigating this way, so this can be used to reset the content
|
|
119
|
-
* script state on URL change, or run custom code.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
123
|
-
* // ...
|
|
124
|
-
* });
|
|
125
|
-
* ctx.addEventListener(document, "wxt:locationchange", () => {
|
|
126
|
-
* // ...
|
|
127
|
-
* });
|
|
128
|
-
*/
|
|
129
112
|
addEventListener(target, type, handler, options) {
|
|
130
113
|
if (type === "wxt:locationchange") {
|
|
131
114
|
if (this.isValid) this.locationWatcher.run();
|
|
132
115
|
}
|
|
133
116
|
target.addEventListener?.(
|
|
134
117
|
type.startsWith("wxt:") ? getUniqueEventName(type) : type,
|
|
135
|
-
// @ts-expect-error: Event don't match, but that's OK, EventTarget doesn't allow custom types in the callback
|
|
136
118
|
handler,
|
|
137
119
|
{
|
|
138
120
|
...options,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getContentScriptJs,
|
|
21
21
|
mapWxtOptionsToRegisteredContentScript
|
|
22
22
|
} from "./utils/content-scripts.mjs";
|
|
23
|
+
import { createKeyboardShortcuts } from "./keyboard-shortcuts.mjs";
|
|
23
24
|
export async function createServer(inlineConfig) {
|
|
24
25
|
await registerWxt("serve", inlineConfig);
|
|
25
26
|
wxt.server = await createServerInternal();
|
|
@@ -67,16 +68,19 @@ async function createServerInternal() {
|
|
|
67
68
|
await builderServer.listen();
|
|
68
69
|
wxt.logger.success(`Started dev server @ ${server.origin}`);
|
|
69
70
|
await wxt.hooks.callHook("server:started", wxt, server);
|
|
70
|
-
await buildAndOpenBrowser();
|
|
71
71
|
server.ws.on("wxt:background-initialized", () => {
|
|
72
72
|
if (server.currentOutput == null) return;
|
|
73
73
|
reloadContentScripts(server.currentOutput.steps, server);
|
|
74
74
|
});
|
|
75
|
+
await buildAndOpenBrowser();
|
|
75
76
|
const reloadOnChange = createFileReloader(server);
|
|
76
77
|
server.watcher.on("all", reloadOnChange);
|
|
78
|
+
keyboardShortcuts.start();
|
|
79
|
+
keyboardShortcuts.printHelp();
|
|
77
80
|
},
|
|
78
81
|
async stop() {
|
|
79
82
|
wasStopped = true;
|
|
83
|
+
keyboardShortcuts.stop();
|
|
80
84
|
await runner.closeBrowser();
|
|
81
85
|
await builderServer.close();
|
|
82
86
|
await wxt.hooks.callHook("server:closed", wxt, server);
|
|
@@ -101,11 +105,14 @@ async function createServerInternal() {
|
|
|
101
105
|
},
|
|
102
106
|
async restartBrowser() {
|
|
103
107
|
await runner.closeBrowser();
|
|
108
|
+
keyboardShortcuts.stop();
|
|
104
109
|
await wxt.reloadConfig();
|
|
105
110
|
runner = await createExtensionRunner();
|
|
106
111
|
await runner.openBrowser();
|
|
112
|
+
keyboardShortcuts.start();
|
|
107
113
|
}
|
|
108
114
|
};
|
|
115
|
+
const keyboardShortcuts = createKeyboardShortcuts(server);
|
|
109
116
|
const buildAndOpenBrowser = async () => {
|
|
110
117
|
server.currentOutput = await internalBuild();
|
|
111
118
|
try {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WxtDevServer } from '../types';
|
|
2
|
+
export interface KeyboardShortcutWatcher {
|
|
3
|
+
start(): void;
|
|
4
|
+
stop(): void;
|
|
5
|
+
printHelp(): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Function that creates a keyboard shortcut handler for the extension.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createKeyboardShortcuts(server: WxtDevServer): KeyboardShortcutWatcher;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import readline from "node:readline";
|
|
2
|
+
import { wxt } from "./wxt.mjs";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
export function createKeyboardShortcuts(server) {
|
|
5
|
+
let isWatching = false;
|
|
6
|
+
let rl;
|
|
7
|
+
const handleInput = (line) => {
|
|
8
|
+
if (line.trim() === "o") {
|
|
9
|
+
server.restartBrowser();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
start() {
|
|
14
|
+
if (isWatching) return;
|
|
15
|
+
rl = readline.createInterface({
|
|
16
|
+
input: process.stdin,
|
|
17
|
+
terminal: false
|
|
18
|
+
// Don't intercept ctrl+C, ctrl+Z, etc
|
|
19
|
+
});
|
|
20
|
+
rl.on("line", handleInput);
|
|
21
|
+
isWatching = true;
|
|
22
|
+
},
|
|
23
|
+
stop() {
|
|
24
|
+
if (!isWatching) return;
|
|
25
|
+
if (rl) {
|
|
26
|
+
rl.close();
|
|
27
|
+
rl = void 0;
|
|
28
|
+
}
|
|
29
|
+
isWatching = false;
|
|
30
|
+
},
|
|
31
|
+
printHelp() {
|
|
32
|
+
if (!wxt.config.runnerConfig.config.disabled) {
|
|
33
|
+
wxt.logger.info(
|
|
34
|
+
`${pc.dim("Press")} ${pc.bold("o + enter")} ${pc.dim("to reopen the browser")}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -39,12 +39,7 @@ export async function findEntrypoints() {
|
|
|
39
39
|
);
|
|
40
40
|
if (matchingGlob) {
|
|
41
41
|
const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
|
|
42
|
-
results.push({
|
|
43
|
-
name,
|
|
44
|
-
inputPath,
|
|
45
|
-
type,
|
|
46
|
-
skipped: wxt.config.filterEntrypoints != null && !wxt.config.filterEntrypoints.has(name)
|
|
47
|
-
});
|
|
42
|
+
results.push({ name, inputPath, type });
|
|
48
43
|
}
|
|
49
44
|
return results;
|
|
50
45
|
}, []);
|
|
@@ -52,7 +47,7 @@ export async function findEntrypoints() {
|
|
|
52
47
|
preventDuplicateEntrypointNames(entrypointInfos);
|
|
53
48
|
let hasBackground = false;
|
|
54
49
|
const env = createExtensionEnvironment();
|
|
55
|
-
const
|
|
50
|
+
const entrypointsWithoutSkipped = await env.run(
|
|
56
51
|
() => Promise.all(
|
|
57
52
|
entrypointInfos.map(async (info) => {
|
|
58
53
|
const { type } = info;
|
|
@@ -97,45 +92,32 @@ export async function findEntrypoints() {
|
|
|
97
92
|
)
|
|
98
93
|
);
|
|
99
94
|
if (wxt.config.command === "serve" && !hasBackground) {
|
|
100
|
-
|
|
95
|
+
entrypointsWithoutSkipped.push(
|
|
101
96
|
await getBackgroundEntrypoint({
|
|
102
97
|
inputPath: VIRTUAL_NOOP_BACKGROUND_MODULE_ID,
|
|
103
98
|
name: "background",
|
|
104
|
-
type: "background"
|
|
105
|
-
skipped: false
|
|
99
|
+
type: "background"
|
|
106
100
|
})
|
|
107
101
|
);
|
|
108
102
|
}
|
|
103
|
+
const entrypoints = entrypointsWithoutSkipped.map((entry) => ({
|
|
104
|
+
...entry,
|
|
105
|
+
skipped: isEntrypointSkipped(entry)
|
|
106
|
+
}));
|
|
109
107
|
wxt.logger.debug("All entrypoints:", entrypoints);
|
|
110
|
-
const skippedEntrypointNames =
|
|
108
|
+
const skippedEntrypointNames = entrypoints.filter((item) => item.skipped).map((item) => item.name);
|
|
111
109
|
if (skippedEntrypointNames.length) {
|
|
112
110
|
wxt.logger.warn(
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
[
|
|
112
|
+
"The following entrypoints have been skipped:",
|
|
113
|
+
...skippedEntrypointNames.map(
|
|
114
|
+
(item) => `${pc.dim("-")} ${pc.cyan(item)}`
|
|
115
|
+
)
|
|
116
|
+
].join("\n")
|
|
115
117
|
);
|
|
116
118
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (include?.length && exclude?.length) {
|
|
120
|
-
wxt.logger.warn(
|
|
121
|
-
`The ${entry.name} entrypoint lists both include and exclude, but only one can be used per entrypoint. Entrypoint ignored.`
|
|
122
|
-
);
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
if (exclude?.length && !include?.length) {
|
|
126
|
-
return !exclude.includes(wxt.config.browser);
|
|
127
|
-
}
|
|
128
|
-
if (include?.length && !exclude?.length) {
|
|
129
|
-
return include.includes(wxt.config.browser);
|
|
130
|
-
}
|
|
131
|
-
if (skippedEntrypointNames.includes(entry.name)) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
return true;
|
|
135
|
-
});
|
|
136
|
-
wxt.logger.debug(`${wxt.config.browser} entrypoints:`, targetEntrypoints);
|
|
137
|
-
await wxt.hooks.callHook("entrypoints:resolved", wxt, targetEntrypoints);
|
|
138
|
-
return targetEntrypoints;
|
|
119
|
+
await wxt.hooks.callHook("entrypoints:resolved", wxt, entrypoints);
|
|
120
|
+
return entrypoints;
|
|
139
121
|
}
|
|
140
122
|
function preventDuplicateEntrypointNames(files) {
|
|
141
123
|
const namesToPaths = files.reduce(
|
|
@@ -196,8 +178,7 @@ async function getPopupEntrypoint(info) {
|
|
|
196
178
|
name: "popup",
|
|
197
179
|
options: resolvePerBrowserOptions(options, wxt.config.browser),
|
|
198
180
|
inputPath: info.inputPath,
|
|
199
|
-
outputDir: wxt.config.outDir
|
|
200
|
-
skipped: info.skipped
|
|
181
|
+
outputDir: wxt.config.outDir
|
|
201
182
|
};
|
|
202
183
|
}
|
|
203
184
|
async function getOptionsEntrypoint(info) {
|
|
@@ -216,8 +197,7 @@ async function getOptionsEntrypoint(info) {
|
|
|
216
197
|
name: "options",
|
|
217
198
|
options: resolvePerBrowserOptions(options, wxt.config.browser),
|
|
218
199
|
inputPath: info.inputPath,
|
|
219
|
-
outputDir: wxt.config.outDir
|
|
220
|
-
skipped: info.skipped
|
|
200
|
+
outputDir: wxt.config.outDir
|
|
221
201
|
};
|
|
222
202
|
}
|
|
223
203
|
async function getUnlistedPageEntrypoint(info) {
|
|
@@ -230,14 +210,12 @@ async function getUnlistedPageEntrypoint(info) {
|
|
|
230
210
|
name: info.name,
|
|
231
211
|
inputPath: info.inputPath,
|
|
232
212
|
outputDir: wxt.config.outDir,
|
|
233
|
-
options
|
|
234
|
-
skipped: info.skipped
|
|
213
|
+
options
|
|
235
214
|
};
|
|
236
215
|
}
|
|
237
216
|
async function getUnlistedScriptEntrypoint({
|
|
238
217
|
inputPath,
|
|
239
|
-
name
|
|
240
|
-
skipped
|
|
218
|
+
name
|
|
241
219
|
}) {
|
|
242
220
|
const defaultExport = await wxt.builder.importEntrypoint(inputPath);
|
|
243
221
|
if (defaultExport == null) {
|
|
@@ -251,14 +229,12 @@ async function getUnlistedScriptEntrypoint({
|
|
|
251
229
|
name,
|
|
252
230
|
inputPath,
|
|
253
231
|
outputDir: wxt.config.outDir,
|
|
254
|
-
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
255
|
-
skipped
|
|
232
|
+
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
256
233
|
};
|
|
257
234
|
}
|
|
258
235
|
async function getBackgroundEntrypoint({
|
|
259
236
|
inputPath,
|
|
260
|
-
name
|
|
261
|
-
skipped
|
|
237
|
+
name
|
|
262
238
|
}) {
|
|
263
239
|
let options = {};
|
|
264
240
|
if (inputPath !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
|
|
@@ -279,14 +255,12 @@ async function getBackgroundEntrypoint({
|
|
|
279
255
|
name,
|
|
280
256
|
inputPath,
|
|
281
257
|
outputDir: wxt.config.outDir,
|
|
282
|
-
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
283
|
-
skipped
|
|
258
|
+
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
284
259
|
};
|
|
285
260
|
}
|
|
286
261
|
async function getContentScriptEntrypoint({
|
|
287
262
|
inputPath,
|
|
288
|
-
name
|
|
289
|
-
skipped
|
|
263
|
+
name
|
|
290
264
|
}) {
|
|
291
265
|
const defaultExport = await wxt.builder.importEntrypoint(inputPath);
|
|
292
266
|
if (defaultExport == null) {
|
|
@@ -305,8 +279,7 @@ async function getContentScriptEntrypoint({
|
|
|
305
279
|
name,
|
|
306
280
|
inputPath,
|
|
307
281
|
outputDir: resolve(wxt.config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
308
|
-
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
309
|
-
skipped
|
|
282
|
+
options: resolvePerBrowserOptions(options, wxt.config.browser)
|
|
310
283
|
};
|
|
311
284
|
}
|
|
312
285
|
async function getSidepanelEntrypoint(info) {
|
|
@@ -332,8 +305,7 @@ async function getSidepanelEntrypoint(info) {
|
|
|
332
305
|
name: info.name,
|
|
333
306
|
options: resolvePerBrowserOptions(options, wxt.config.browser),
|
|
334
307
|
inputPath: info.inputPath,
|
|
335
|
-
outputDir: wxt.config.outDir
|
|
336
|
-
skipped: info.skipped
|
|
308
|
+
outputDir: wxt.config.outDir
|
|
337
309
|
};
|
|
338
310
|
}
|
|
339
311
|
async function getHtmlEntrypointOptions(info, keyMap, queries, parsers) {
|
|
@@ -357,6 +329,25 @@ async function getHtmlEntrypointOptions(info, keyMap, queries, parsers) {
|
|
|
357
329
|
});
|
|
358
330
|
return options;
|
|
359
331
|
}
|
|
332
|
+
function isEntrypointSkipped(entry) {
|
|
333
|
+
if (wxt.config.filterEntrypoints != null) {
|
|
334
|
+
return !wxt.config.filterEntrypoints.has(entry.name);
|
|
335
|
+
}
|
|
336
|
+
const { include, exclude } = entry.options;
|
|
337
|
+
if (include?.length && exclude?.length) {
|
|
338
|
+
wxt.logger.warn(
|
|
339
|
+
`The ${entry.name} entrypoint lists both include and exclude, but only one can be used per entrypoint. Entrypoint skipped.`
|
|
340
|
+
);
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (exclude?.length && !include?.length) {
|
|
344
|
+
return exclude.includes(wxt.config.browser);
|
|
345
|
+
}
|
|
346
|
+
if (include?.length && !exclude?.length) {
|
|
347
|
+
return !include.includes(wxt.config.browser);
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
360
351
|
const PATH_GLOB_TO_TYPE_MAP = {
|
|
361
352
|
"sandbox.html": "sandbox",
|
|
362
353
|
"sandbox/index.html": "sandbox",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entrypoint, EntrypointGroup } from '../../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Entrypoints
|
|
4
|
-
* content scripts must be build individually.
|
|
3
|
+
* Entrypoints are built in groups. HTML pages can all be built together in a single step,
|
|
4
|
+
* content scripts must be build individually, etc.
|
|
5
5
|
*
|
|
6
6
|
* This function returns the entrypoints put into these types of groups.
|
|
7
7
|
*/
|
|
@@ -2,6 +2,7 @@ export function groupEntrypoints(entrypoints) {
|
|
|
2
2
|
const groupIndexMap = {};
|
|
3
3
|
const groups = [];
|
|
4
4
|
for (const entry of entrypoints) {
|
|
5
|
+
if (entry.skipped) continue;
|
|
5
6
|
let group = ENTRY_TYPE_TO_GROUP_MAP[entry.type];
|
|
6
7
|
if (entry.type === "background" && entry.options.type === "module") {
|
|
7
8
|
group = "esm";
|
|
@@ -45,9 +45,13 @@ export async function generateManifest(entrypoints, buildOutput) {
|
|
|
45
45
|
baseManifest
|
|
46
46
|
);
|
|
47
47
|
if (wxt.config.command === "serve" && wxt.config.dev.reloadCommand) {
|
|
48
|
-
if (manifest.commands &&
|
|
48
|
+
if (manifest.commands && // If the following limit is exceeded, Chrome will fail to load the extension.
|
|
49
|
+
// Error: "Too many commands specified for 'commands': The maximum is 4."
|
|
50
|
+
Object.values(manifest.commands).filter(
|
|
51
|
+
(command) => command.suggested_key
|
|
52
|
+
).length >= 4) {
|
|
49
53
|
warnings.push([
|
|
50
|
-
"Extension already has 4 registered commands, WXT's reload command is disabled"
|
|
54
|
+
"Extension already has 4 registered commands with suggested keys, WXT's reload command is disabled"
|
|
51
55
|
]);
|
|
52
56
|
} else {
|
|
53
57
|
manifest.commands ??= {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Manifest } from 'wxt/browser';
|
|
2
2
|
import { ResolvedConfig, WxtDevServer, BackgroundEntrypoint, ContentScriptEntrypoint, GenericEntrypoint, OptionsEntrypoint, PopupEntrypoint, OutputChunk, OutputFile, OutputAsset, BuildOutput, BuildStepOutput, UserManifest, Wxt, SidepanelEntrypoint } from '../../../types';
|
|
3
3
|
type DeepPartial<T> = T extends object ? {
|
|
4
4
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
@@ -8781,7 +8781,7 @@ export declare const fakeBuildStepOutput: (overrides?: {
|
|
|
8781
8781
|
moduleIds?: (string | undefined)[] | undefined;
|
|
8782
8782
|
} | undefined)[] | undefined;
|
|
8783
8783
|
} | undefined) => BuildStepOutput;
|
|
8784
|
-
export declare const fakeManifestCommand: (overrides?: any) =>
|
|
8784
|
+
export declare const fakeManifestCommand: (overrides?: any) => Manifest.WebExtensionManifestCommandsType;
|
|
8785
8785
|
export declare const fakeDevServer: (overrides?: {
|
|
8786
8786
|
currentOutput?: {
|
|
8787
8787
|
manifest?: any;
|
|
@@ -301,10 +301,14 @@ export const fakeBuildStepOutput = fakeObjectCreator(() => ({
|
|
|
301
301
|
}));
|
|
302
302
|
export const fakeManifestCommand = fakeObjectCreator(() => ({
|
|
303
303
|
description: faker.string.sample(),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
suggested_key: {
|
|
305
|
+
default: `${faker.helpers.arrayElement(["ctrl", "alt"])}+${faker.number.int(
|
|
306
|
+
{
|
|
307
|
+
min: 0,
|
|
308
|
+
max: 9
|
|
309
|
+
}
|
|
310
|
+
)}`
|
|
311
|
+
}
|
|
308
312
|
}));
|
|
309
313
|
export const fakeDevServer = fakeObjectCreator(() => ({
|
|
310
314
|
hostname: "localhost",
|
package/dist/core/wxt.mjs
CHANGED
|
@@ -19,6 +19,11 @@ export async function registerWxt(command, inlineConfig = {}) {
|
|
|
19
19
|
return config.logger;
|
|
20
20
|
},
|
|
21
21
|
async reloadConfig() {
|
|
22
|
+
if (wxt.config.dev.server?.port) {
|
|
23
|
+
inlineConfig.dev ??= {};
|
|
24
|
+
inlineConfig.dev.server ??= {};
|
|
25
|
+
inlineConfig.dev.server.port = wxt.config.dev.server.port;
|
|
26
|
+
}
|
|
22
27
|
wxt.config = await resolveConfig(inlineConfig, command);
|
|
23
28
|
await wxt.hooks.callHook("config:resolved", wxt);
|
|
24
29
|
},
|
package/dist/core/zip.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { getPackageJson } from "./utils/package.mjs";
|
|
|
5
5
|
import { minimatch } from "minimatch";
|
|
6
6
|
import { formatDuration } from "./utils/time.mjs";
|
|
7
7
|
import { printFileList } from "./utils/log/printFileList.mjs";
|
|
8
|
-
import { internalBuild } from "./utils/building/index.mjs";
|
|
8
|
+
import { findEntrypoints, internalBuild } from "./utils/building/index.mjs";
|
|
9
9
|
import { registerWxt, wxt } from "./wxt.mjs";
|
|
10
10
|
import JSZip from "jszip";
|
|
11
11
|
import glob from "fast-glob";
|
|
@@ -34,6 +34,14 @@ export async function zip(config) {
|
|
|
34
34
|
zipFiles.push(outZipPath);
|
|
35
35
|
await wxt.hooks.callHook("zip:extension:done", wxt, outZipPath);
|
|
36
36
|
if (wxt.config.zip.zipSources) {
|
|
37
|
+
const entrypoints = await findEntrypoints();
|
|
38
|
+
const skippedEntrypoints = entrypoints.filter((entry) => entry.skipped);
|
|
39
|
+
const excludeSources = [
|
|
40
|
+
...wxt.config.zip.excludeSources,
|
|
41
|
+
...skippedEntrypoints.map(
|
|
42
|
+
(entry) => path.relative(wxt.config.zip.sourcesRoot, entry.inputPath)
|
|
43
|
+
)
|
|
44
|
+
].map((paths) => paths.replaceAll("\\", "/"));
|
|
37
45
|
await wxt.hooks.callHook("zip:sources:start", wxt);
|
|
38
46
|
const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
|
|
39
47
|
const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
|
|
@@ -43,7 +51,7 @@ export async function zip(config) {
|
|
|
43
51
|
);
|
|
44
52
|
await zipDir(wxt.config.zip.sourcesRoot, sourcesZipPath, {
|
|
45
53
|
include: wxt.config.zip.includeSources,
|
|
46
|
-
exclude:
|
|
54
|
+
exclude: excludeSources,
|
|
47
55
|
transform(absolutePath, zipPath, content) {
|
|
48
56
|
if (zipPath.endsWith("package.json")) {
|
|
49
57
|
return addOverridesToPackageJson(absolutePath, content, overrides);
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface InlineConfig {
|
|
|
44
44
|
* A list of entrypoint names (`"popup"`, `"options"`, etc.) to build. Will speed up the build if
|
|
45
45
|
* your extension has lots of entrypoints, and you don't need to build all of them to develop a
|
|
46
46
|
* feature.
|
|
47
|
+
* If specified, this completely overrides the `include`/`exclude` option provided per-entrypoint.
|
|
47
48
|
*/
|
|
48
49
|
filterEntrypoints?: string[];
|
|
49
50
|
/**
|
|
@@ -682,7 +683,14 @@ export interface BaseEntrypoint {
|
|
|
682
683
|
* subdirectory of it.
|
|
683
684
|
*/
|
|
684
685
|
outputDir: string;
|
|
685
|
-
|
|
686
|
+
/**
|
|
687
|
+
* When true, the entrypoint will not be built by WXT. Normally this is set
|
|
688
|
+
* based on the `filterEntrypoints` config or the entrypoint's
|
|
689
|
+
* `include`/`exclude` options defined inside the file.
|
|
690
|
+
*
|
|
691
|
+
* See https://wxt.dev/guide/essentials/target-different-browsers.html#filtering-entrypoints
|
|
692
|
+
*/
|
|
693
|
+
skipped?: boolean;
|
|
686
694
|
}
|
|
687
695
|
export interface GenericEntrypoint extends BaseEntrypoint {
|
|
688
696
|
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.19.
|
|
1
|
+
export const version = "0.19.19";
|