wxt 0.10.3 → 0.11.0
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.ts +1 -1
- package/dist/{chunk-BHUP6PAP.js → chunk-6V4H2CZ4.js} +952 -891
- package/dist/cli.cjs +1446 -1399
- package/dist/client.d.ts +2 -2
- package/dist/{execa-Z7B33P3C.js → execa-4F7CCWCA.js} +3 -3
- package/dist/{external-9107db91.d.ts → external-6YqvLCcd.d.ts} +1 -1
- package/dist/{external-d75ae6fd.d.ts → external-n9SucYhJ.d.cts} +113 -32
- package/dist/external-n9SucYhJ.d.ts +694 -0
- package/dist/index.cjs +1446 -1399
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +75 -91
- package/dist/sandbox.d.ts +1 -1
- package/dist/storage.d.cts +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +1 -1
- package/dist/testing.cjs +377 -112
- package/dist/testing.d.cts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +2 -2
- package/dist/virtual/mock-browser.js +9 -14
- package/package.json +18 -17
- /package/dist/{chunk-YUG22S6W.js → chunk-VBXJIVYU.js} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export {
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-n9SucYhJ.cjs';
|
|
2
|
+
export { n as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, t as ConfigEnv, m as ContentScriptDefinition, C as ContentScriptEntrypoint, j as Entrypoint, k as EntrypointGroup, q as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, p as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, o as UnlistedScriptDefinition, r as UserManifest, s as UserManifestFn, u as WxtBuilder, v as WxtBuilderServer, a as WxtViteConfig } from './external-n9SucYhJ.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
|
7
7
|
import 'rollup-plugin-visualizer';
|
|
8
|
+
import 'chokidar';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
@@ -44,7 +45,7 @@ declare function defineRunnerConfig(config: ExtensionRunnerConfig): ExtensionRun
|
|
|
44
45
|
* });
|
|
45
46
|
* await server.start();
|
|
46
47
|
*/
|
|
47
|
-
declare function createServer(
|
|
48
|
+
declare function createServer(inlineConfig?: InlineConfig): Promise<WxtDevServer>;
|
|
48
49
|
|
|
49
50
|
declare function initialize(options: {
|
|
50
51
|
directory: string;
|
|
@@ -61,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
61
62
|
*/
|
|
62
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
63
64
|
|
|
64
|
-
var version = "0.
|
|
65
|
+
var version = "0.11.0";
|
|
65
66
|
|
|
66
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export {
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-n9SucYhJ.js';
|
|
2
|
+
export { n as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, t as ConfigEnv, m as ContentScriptDefinition, C as ContentScriptEntrypoint, j as Entrypoint, k as EntrypointGroup, q as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, p as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, o as UnlistedScriptDefinition, r as UserManifest, s as UserManifestFn, u as WxtBuilder, v as WxtBuilderServer, a as WxtViteConfig } from './external-n9SucYhJ.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
|
7
7
|
import 'rollup-plugin-visualizer';
|
|
8
|
+
import 'chokidar';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
@@ -44,7 +45,7 @@ declare function defineRunnerConfig(config: ExtensionRunnerConfig): ExtensionRun
|
|
|
44
45
|
* });
|
|
45
46
|
* await server.start();
|
|
46
47
|
*/
|
|
47
|
-
declare function createServer(
|
|
48
|
+
declare function createServer(inlineConfig?: InlineConfig): Promise<WxtDevServer>;
|
|
48
49
|
|
|
49
50
|
declare function initialize(options: {
|
|
50
51
|
directory: string;
|
|
@@ -61,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
61
62
|
*/
|
|
62
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
63
64
|
|
|
64
|
-
var version = "0.
|
|
65
|
+
var version = "0.11.0";
|
|
65
66
|
|
|
66
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
rebuild,
|
|
16
16
|
resolvePerBrowserOption,
|
|
17
17
|
version
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-6V4H2CZ4.js";
|
|
19
|
+
import "./chunk-VBXJIVYU.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
22
22
|
async function build(config) {
|
|
@@ -69,9 +69,6 @@ function defineRunnerConfig(config) {
|
|
|
69
69
|
return config;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// src/core/create-server.ts
|
|
73
|
-
import * as vite from "vite";
|
|
74
|
-
|
|
75
72
|
// src/core/runners/wsl.ts
|
|
76
73
|
import { relative } from "node:path";
|
|
77
74
|
function createWslRunner() {
|
|
@@ -205,27 +202,75 @@ import { consola as consola2 } from "consola";
|
|
|
205
202
|
import { Mutex } from "async-mutex";
|
|
206
203
|
import pc2 from "picocolors";
|
|
207
204
|
import { relative as relative4 } from "node:path";
|
|
208
|
-
async function
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
"serve"
|
|
217
|
-
);
|
|
205
|
+
async function createServer(inlineConfig) {
|
|
206
|
+
const port = await getPort();
|
|
207
|
+
const hostname = "localhost";
|
|
208
|
+
const origin = `http://${hostname}:${port}`;
|
|
209
|
+
const serverInfo = {
|
|
210
|
+
port,
|
|
211
|
+
hostname,
|
|
212
|
+
origin
|
|
218
213
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
214
|
+
const server = {
|
|
215
|
+
...serverInfo,
|
|
216
|
+
watcher: void 0,
|
|
217
|
+
// Filled out later down below
|
|
218
|
+
ws: void 0,
|
|
219
|
+
// Filled out later down below
|
|
220
|
+
currentOutput: void 0,
|
|
221
|
+
// Filled out later down below
|
|
222
|
+
async start() {
|
|
223
|
+
await builderServer.listen();
|
|
224
|
+
config.logger.success(`Started dev server @ ${serverInfo.origin}`);
|
|
225
|
+
server.currentOutput = await internalBuild(config);
|
|
226
|
+
await runner.openBrowser(config);
|
|
227
|
+
},
|
|
228
|
+
transformHtml(url, html, originalUrl) {
|
|
229
|
+
return builderServer.transformHtml(url, html, originalUrl);
|
|
230
|
+
},
|
|
231
|
+
reloadContentScript(contentScript) {
|
|
232
|
+
server.ws.send("wxt:reload-content-script", contentScript);
|
|
233
|
+
},
|
|
234
|
+
reloadPage(path3) {
|
|
235
|
+
server.ws.send("wxt:reload-page", path3);
|
|
236
|
+
},
|
|
237
|
+
reloadExtension() {
|
|
238
|
+
server.ws.send("wxt:reload-extension");
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const getLatestConfig = () => getInternalConfig(inlineConfig ?? {}, "serve", server);
|
|
242
|
+
let config = await getLatestConfig();
|
|
243
|
+
const [runner, builderServer] = await Promise.all([
|
|
244
|
+
createExtensionRunner(config),
|
|
245
|
+
config.builder.createServer(server)
|
|
246
|
+
]);
|
|
247
|
+
server.watcher = builderServer.watcher;
|
|
248
|
+
server.ws = builderServer.ws;
|
|
224
249
|
server.ws.on("wxt:background-initialized", () => {
|
|
225
|
-
reloadContentScripts(server.currentOutput.steps,
|
|
250
|
+
reloadContentScripts(server.currentOutput.steps, config, server);
|
|
226
251
|
});
|
|
227
|
-
|
|
228
|
-
|
|
252
|
+
const reloadOnChange = createFileReloader({
|
|
253
|
+
server,
|
|
254
|
+
getLatestConfig,
|
|
255
|
+
updateConfig(newConfig) {
|
|
256
|
+
config = newConfig;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
server.watcher.on("all", reloadOnChange);
|
|
260
|
+
return server;
|
|
261
|
+
}
|
|
262
|
+
async function getPort() {
|
|
263
|
+
const { default: getPort2, portNumbers } = await import("get-port");
|
|
264
|
+
return await getPort2({ port: portNumbers(3e3, 3010) });
|
|
265
|
+
}
|
|
266
|
+
function createFileReloader(options) {
|
|
267
|
+
const { server, getLatestConfig, updateConfig } = options;
|
|
268
|
+
const fileChangedMutex = new Mutex();
|
|
269
|
+
const changeQueue = [];
|
|
270
|
+
return async (event, path3) => {
|
|
271
|
+
const config = await getLatestConfig();
|
|
272
|
+
updateConfig(config);
|
|
273
|
+
if (path3.startsWith(config.outBaseDir))
|
|
229
274
|
return;
|
|
230
275
|
changeQueue.push([event, path3]);
|
|
231
276
|
await fileChangedMutex.runExclusive(async () => {
|
|
@@ -235,18 +280,16 @@ async function createServer2(config) {
|
|
|
235
280
|
const changes = detectDevChanges(fileChanges, server.currentOutput);
|
|
236
281
|
if (changes.type === "no-change")
|
|
237
282
|
return;
|
|
238
|
-
|
|
239
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc2.dim(relative4(
|
|
283
|
+
config.logger.info(
|
|
284
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc2.dim(relative4(config.root, file))).join(", ")}`
|
|
240
285
|
);
|
|
241
286
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
242
287
|
return pc2.cyan(
|
|
243
|
-
relative4(
|
|
288
|
+
relative4(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
244
289
|
);
|
|
245
290
|
}).join(pc2.dim(", "));
|
|
246
|
-
internalConfig = await getLatestInternalConfig();
|
|
247
|
-
internalConfig.server = server;
|
|
248
291
|
const { output: newOutput } = await rebuild(
|
|
249
|
-
|
|
292
|
+
config,
|
|
250
293
|
// TODO: this excludes new entrypoints, so they're not built until the dev command is restarted
|
|
251
294
|
changes.rebuildGroups,
|
|
252
295
|
changes.cachedOutput
|
|
@@ -257,75 +300,16 @@ async function createServer2(config) {
|
|
|
257
300
|
server.reloadExtension();
|
|
258
301
|
break;
|
|
259
302
|
case "html-reload":
|
|
260
|
-
reloadHtmlPages(changes.rebuildGroups, server,
|
|
303
|
+
reloadHtmlPages(changes.rebuildGroups, server, config);
|
|
261
304
|
break;
|
|
262
305
|
case "content-script-reload":
|
|
263
|
-
reloadContentScripts(changes.changedSteps,
|
|
306
|
+
reloadContentScripts(changes.changedSteps, config, server);
|
|
264
307
|
break;
|
|
265
308
|
}
|
|
266
309
|
consola2.success(`Reloaded: ${rebuiltNames}`);
|
|
267
310
|
});
|
|
268
|
-
});
|
|
269
|
-
return server;
|
|
270
|
-
}
|
|
271
|
-
async function getServerInfo() {
|
|
272
|
-
const { default: getPort, portNumbers } = await import("get-port");
|
|
273
|
-
const port = await getPort({ port: portNumbers(3e3, 3010) });
|
|
274
|
-
const hostname = "localhost";
|
|
275
|
-
const origin = `http://${hostname}:${port}`;
|
|
276
|
-
const serverConfig = {
|
|
277
|
-
server: {
|
|
278
|
-
origin
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
return {
|
|
282
|
-
port,
|
|
283
|
-
hostname,
|
|
284
|
-
origin,
|
|
285
|
-
viteServerConfig: serverConfig
|
|
286
311
|
};
|
|
287
312
|
}
|
|
288
|
-
async function setupServer(serverInfo, config) {
|
|
289
|
-
const runner = await createExtensionRunner(config);
|
|
290
|
-
const viteServer = await vite.createServer(
|
|
291
|
-
vite.mergeConfig(serverInfo, await config.vite(config.env))
|
|
292
|
-
);
|
|
293
|
-
const start = async () => {
|
|
294
|
-
await viteServer.listen(server.port);
|
|
295
|
-
config.logger.success(`Started dev server @ ${serverInfo.origin}`);
|
|
296
|
-
server.currentOutput = await internalBuild(config);
|
|
297
|
-
await runner.openBrowser(config);
|
|
298
|
-
};
|
|
299
|
-
const reloadExtension = () => {
|
|
300
|
-
viteServer.ws.send("wxt:reload-extension");
|
|
301
|
-
};
|
|
302
|
-
const reloadPage = (path3) => {
|
|
303
|
-
viteServer.ws.send("wxt:reload-page", path3);
|
|
304
|
-
};
|
|
305
|
-
const reloadContentScript = (contentScript) => {
|
|
306
|
-
viteServer.ws.send("wxt:reload-content-script", contentScript);
|
|
307
|
-
};
|
|
308
|
-
const server = {
|
|
309
|
-
...viteServer,
|
|
310
|
-
start,
|
|
311
|
-
currentOutput: {
|
|
312
|
-
manifest: {
|
|
313
|
-
manifest_version: 3,
|
|
314
|
-
name: "",
|
|
315
|
-
version: ""
|
|
316
|
-
},
|
|
317
|
-
publicAssets: [],
|
|
318
|
-
steps: []
|
|
319
|
-
},
|
|
320
|
-
port: serverInfo.port,
|
|
321
|
-
hostname: serverInfo.hostname,
|
|
322
|
-
origin: serverInfo.origin,
|
|
323
|
-
reloadExtension,
|
|
324
|
-
reloadPage,
|
|
325
|
-
reloadContentScript
|
|
326
|
-
};
|
|
327
|
-
return server;
|
|
328
|
-
}
|
|
329
313
|
function reloadContentScripts(steps, config, server) {
|
|
330
314
|
if (config.manifestVersion === 3) {
|
|
331
315
|
steps.forEach((step) => {
|
|
@@ -562,7 +546,7 @@ async function zip(config) {
|
|
|
562
546
|
export {
|
|
563
547
|
build,
|
|
564
548
|
clean,
|
|
565
|
-
|
|
549
|
+
createServer,
|
|
566
550
|
defineConfig,
|
|
567
551
|
defineRunnerConfig,
|
|
568
552
|
initialize,
|
package/dist/sandbox.d.ts
CHANGED
package/dist/storage.d.cts
CHANGED
|
@@ -12,4 +12,4 @@ declare const webExtensionDriver: (opts: WebExtensionDriverOptions) => Driver;
|
|
|
12
12
|
type StorageValue = null | string | number | boolean | object;
|
|
13
13
|
declare const storage: Storage<StorageValue>;
|
|
14
14
|
|
|
15
|
-
export { StorageValue, WebExtensionDriverOptions, storage, webExtensionDriver };
|
|
15
|
+
export { type StorageValue, type WebExtensionDriverOptions, storage, webExtensionDriver };
|
package/dist/storage.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ declare const webExtensionDriver: (opts: WebExtensionDriverOptions) => Driver;
|
|
|
12
12
|
type StorageValue = null | string | number | boolean | object;
|
|
13
13
|
declare const storage: Storage<StorageValue>;
|
|
14
14
|
|
|
15
|
-
export { StorageValue, WebExtensionDriverOptions, storage, webExtensionDriver };
|
|
15
|
+
export { type StorageValue, type WebExtensionDriverOptions, storage, webExtensionDriver };
|
package/dist/storage.js
CHANGED