wxt 0.11.2 → 0.12.1
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/bin/wxt.mjs +2 -0
- package/dist/{chunk-XTGVY6KL.js → chunk-ENVSDI4C.js} +62 -35
- package/dist/cli.js +3119 -0
- package/dist/client.d.ts +3 -8
- package/dist/client.js +1 -15
- package/dist/{external-PmmO6xnl.d.ts → external-TYmXqKVq.d.ts} +24 -11
- package/dist/{external-irU6kFSB.d.cts → external-tVP-84Pg.d.cts} +24 -11
- package/dist/{external-irU6kFSB.d.ts → external-tVP-84Pg.d.ts} +24 -11
- package/dist/index.cjs +107 -79
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/sandbox.d.ts +7 -2
- package/dist/sandbox.js +14 -0
- package/dist/testing.cjs +21 -10
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/{content-script-entrypoint.js → content-script-isolated-world-entrypoint.js} +3 -3
- package/dist/virtual/content-script-main-world-entrypoint.js +33 -0
- package/package.json +38 -19
- package/bin/wxt.cjs +0 -2
- package/dist/cli.cjs +0 -5506
package/dist/index.cjs
CHANGED
|
@@ -577,16 +577,16 @@ function npmRunPath(options = {}) {
|
|
|
577
577
|
execPath = import_node_process.default.execPath
|
|
578
578
|
} = options;
|
|
579
579
|
let previous;
|
|
580
|
-
const cwdString = cwd instanceof URL ?
|
|
581
|
-
let cwdPath =
|
|
580
|
+
const cwdString = cwd instanceof URL ? import_node_url2.default.fileURLToPath(cwd) : cwd;
|
|
581
|
+
let cwdPath = import_node_path11.default.resolve(cwdString);
|
|
582
582
|
const result = [];
|
|
583
583
|
while (previous !== cwdPath) {
|
|
584
|
-
result.push(
|
|
584
|
+
result.push(import_node_path11.default.join(cwdPath, "node_modules/.bin"));
|
|
585
585
|
previous = cwdPath;
|
|
586
|
-
cwdPath =
|
|
586
|
+
cwdPath = import_node_path11.default.resolve(cwdPath, "..");
|
|
587
587
|
}
|
|
588
|
-
result.push(
|
|
589
|
-
return [...result, path_].join(
|
|
588
|
+
result.push(import_node_path11.default.resolve(cwdString, execPath, ".."));
|
|
589
|
+
return [...result, path_].join(import_node_path11.default.delimiter);
|
|
590
590
|
}
|
|
591
591
|
function npmRunPathEnv({ env = import_node_process.default.env, ...options } = {}) {
|
|
592
592
|
env = { ...env };
|
|
@@ -595,13 +595,13 @@ function npmRunPathEnv({ env = import_node_process.default.env, ...options } = {
|
|
|
595
595
|
env[path10] = npmRunPath(options);
|
|
596
596
|
return env;
|
|
597
597
|
}
|
|
598
|
-
var import_node_process,
|
|
598
|
+
var import_node_process, import_node_path11, import_node_url2;
|
|
599
599
|
var init_npm_run_path = __esm({
|
|
600
600
|
"node_modules/.pnpm/npm-run-path@5.1.0/node_modules/npm-run-path/index.js"() {
|
|
601
601
|
"use strict";
|
|
602
602
|
import_node_process = __toESM(require("process"), 1);
|
|
603
|
-
|
|
604
|
-
|
|
603
|
+
import_node_path11 = __toESM(require("path"), 1);
|
|
604
|
+
import_node_url2 = __toESM(require("url"), 1);
|
|
605
605
|
init_path_key();
|
|
606
606
|
}
|
|
607
607
|
});
|
|
@@ -2337,12 +2337,12 @@ function execaNode(scriptPath, args, options = {}) {
|
|
|
2337
2337
|
}
|
|
2338
2338
|
);
|
|
2339
2339
|
}
|
|
2340
|
-
var import_node_buffer2,
|
|
2340
|
+
var import_node_buffer2, import_node_path12, import_node_child_process3, import_node_process4, import_cross_spawn, DEFAULT_MAX_BUFFER, getEnv, handleArguments, handleOutput, normalizeScriptStdin, normalizeScriptOptions, $;
|
|
2341
2341
|
var init_execa = __esm({
|
|
2342
2342
|
"node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js"() {
|
|
2343
2343
|
"use strict";
|
|
2344
2344
|
import_node_buffer2 = require("buffer");
|
|
2345
|
-
|
|
2345
|
+
import_node_path12 = __toESM(require("path"), 1);
|
|
2346
2346
|
import_node_child_process3 = __toESM(require("child_process"), 1);
|
|
2347
2347
|
import_node_process4 = __toESM(require("process"), 1);
|
|
2348
2348
|
import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
@@ -2388,7 +2388,7 @@ var init_execa = __esm({
|
|
|
2388
2388
|
};
|
|
2389
2389
|
options.env = getEnv(options);
|
|
2390
2390
|
options.stdio = normalizeStdio(options);
|
|
2391
|
-
if (import_node_process4.default.platform === "win32" &&
|
|
2391
|
+
if (import_node_process4.default.platform === "win32" && import_node_path12.default.basename(file, ".exe") === "cmd") {
|
|
2392
2392
|
args.unshift("/q");
|
|
2393
2393
|
}
|
|
2394
2394
|
return { file, args, options, parsed };
|
|
@@ -2633,6 +2633,7 @@ async function findEntrypoints(config) {
|
|
|
2633
2633
|
}
|
|
2634
2634
|
return results;
|
|
2635
2635
|
}, []);
|
|
2636
|
+
preventNoEntrypoints(config, entrypointInfos);
|
|
2636
2637
|
preventDuplicateEntrypointNames(config, entrypointInfos);
|
|
2637
2638
|
let hasBackground = false;
|
|
2638
2639
|
const entrypoints = await Promise.all(
|
|
@@ -2734,6 +2735,11 @@ ${errorContent}`
|
|
|
2734
2735
|
);
|
|
2735
2736
|
}
|
|
2736
2737
|
}
|
|
2738
|
+
function preventNoEntrypoints(config, files) {
|
|
2739
|
+
if (files.length === 0) {
|
|
2740
|
+
throw Error(`No entrypoints found in ${config.entrypointsDir}`);
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2737
2743
|
function getHtmlBaseOptions(document) {
|
|
2738
2744
|
const options = {};
|
|
2739
2745
|
const includeContent = document.querySelector("meta[name='manifest.include']")?.getAttribute("content");
|
|
@@ -3726,7 +3732,8 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3726
3732
|
devHtmlPrerender(wxtConfig),
|
|
3727
3733
|
unimport(wxtConfig),
|
|
3728
3734
|
virtualEntrypoint("background", wxtConfig),
|
|
3729
|
-
virtualEntrypoint("content-script", wxtConfig),
|
|
3735
|
+
virtualEntrypoint("content-script-isolated-world", wxtConfig),
|
|
3736
|
+
virtualEntrypoint("content-script-main-world", wxtConfig),
|
|
3730
3737
|
virtualEntrypoint("unlisted-script", wxtConfig),
|
|
3731
3738
|
devServerGlobals(wxtConfig),
|
|
3732
3739
|
tsconfigPaths(wxtConfig),
|
|
@@ -3740,12 +3747,17 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3740
3747
|
return config;
|
|
3741
3748
|
};
|
|
3742
3749
|
const getLibModeConfig = (entrypoint) => {
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
"
|
|
3746
|
-
"unlisted-script"
|
|
3747
|
-
|
|
3748
|
-
|
|
3750
|
+
let virtualEntrypointType;
|
|
3751
|
+
switch (entrypoint.type) {
|
|
3752
|
+
case "background":
|
|
3753
|
+
case "unlisted-script":
|
|
3754
|
+
virtualEntrypointType = entrypoint.type;
|
|
3755
|
+
break;
|
|
3756
|
+
case "content-script":
|
|
3757
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
3758
|
+
break;
|
|
3759
|
+
}
|
|
3760
|
+
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
3749
3761
|
const plugins = [
|
|
3750
3762
|
entrypointGroupGlobals(entrypoint)
|
|
3751
3763
|
];
|
|
@@ -3906,7 +3918,10 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
3906
3918
|
const { config: loadedConfig, ...metadata } = await (0, import_c12.loadConfig)({
|
|
3907
3919
|
name: "wxt",
|
|
3908
3920
|
cwd: inlineConfig.root ?? process.cwd(),
|
|
3909
|
-
rcFile: false
|
|
3921
|
+
rcFile: false,
|
|
3922
|
+
jitiOptions: {
|
|
3923
|
+
esmResolve: true
|
|
3924
|
+
}
|
|
3910
3925
|
});
|
|
3911
3926
|
userConfig = loadedConfig ?? {};
|
|
3912
3927
|
userConfigMetadata = metadata;
|
|
@@ -4115,7 +4130,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
4115
4130
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
4116
4131
|
var import_unimport5 = require("unimport");
|
|
4117
4132
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
4118
|
-
var
|
|
4133
|
+
var import_node_path8 = require("path");
|
|
4119
4134
|
|
|
4120
4135
|
// src/core/utils/strings.ts
|
|
4121
4136
|
function kebabCaseAlphanumeric(str) {
|
|
@@ -4129,14 +4144,15 @@ function removeImportStatements(text) {
|
|
|
4129
4144
|
}
|
|
4130
4145
|
function removeProjectImportStatements(text) {
|
|
4131
4146
|
const noImports = removeImportStatements(text);
|
|
4132
|
-
return `import { defineContentScript, defineBackground } from 'wxt/
|
|
4133
|
-
import { defineUnlistedScript } from 'wxt/sandbox';
|
|
4147
|
+
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
4134
4148
|
|
|
4135
4149
|
${noImports}`;
|
|
4136
4150
|
}
|
|
4137
4151
|
|
|
4138
4152
|
// src/core/utils/building/import-entrypoint.ts
|
|
4139
4153
|
var import_esbuild = require("esbuild");
|
|
4154
|
+
var import_node_url = require("url");
|
|
4155
|
+
var import_meta = {};
|
|
4140
4156
|
async function importEntrypointFile(path10, config) {
|
|
4141
4157
|
config.logger.debug("Loading file metadata:", path10);
|
|
4142
4158
|
const normalPath = normalizePath(path10);
|
|
@@ -4152,30 +4168,42 @@ async function importEntrypointFile(path10, config) {
|
|
|
4152
4168
|
config.logger.debug(
|
|
4153
4169
|
["Text:", text, "No imports:", textNoImports, "Code:", code].join("\n")
|
|
4154
4170
|
);
|
|
4155
|
-
const jiti = (0, import_jiti.default)(
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
"
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4171
|
+
const jiti = (0, import_jiti.default)(
|
|
4172
|
+
typeof __filename !== "undefined" ? __filename : (0, import_node_url.fileURLToPath)(import_meta.url),
|
|
4173
|
+
{
|
|
4174
|
+
cache: false,
|
|
4175
|
+
debug: config.debug,
|
|
4176
|
+
esmResolve: true,
|
|
4177
|
+
alias: {
|
|
4178
|
+
"webextension-polyfill": (0, import_node_path8.resolve)(
|
|
4179
|
+
config.root,
|
|
4180
|
+
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
4181
|
+
)
|
|
4182
|
+
},
|
|
4183
|
+
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
4184
|
+
// respect the custom transform function when using it's native bun option.
|
|
4185
|
+
experimentalBun: false,
|
|
4186
|
+
// List of extensions to transform with esbuild
|
|
4187
|
+
extensions: [
|
|
4188
|
+
".ts",
|
|
4189
|
+
".cts",
|
|
4190
|
+
".mts",
|
|
4191
|
+
".tsx",
|
|
4192
|
+
".js",
|
|
4193
|
+
".cjs",
|
|
4194
|
+
".mjs",
|
|
4195
|
+
".jsx"
|
|
4196
|
+
],
|
|
4197
|
+
transform(opts) {
|
|
4198
|
+
const isEntrypoint = opts.filename === normalPath;
|
|
4199
|
+
return (0, import_esbuild.transformSync)(
|
|
4200
|
+
// Use modified source code for entrypoints
|
|
4201
|
+
isEntrypoint ? code : opts.source,
|
|
4202
|
+
getEsbuildOptions(opts)
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4177
4205
|
}
|
|
4178
|
-
|
|
4206
|
+
);
|
|
4179
4207
|
try {
|
|
4180
4208
|
const res = await jiti(path10);
|
|
4181
4209
|
return res.default;
|
|
@@ -4198,10 +4226,10 @@ var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
|
4198
4226
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
4199
4227
|
|
|
4200
4228
|
// src/core/utils/log/printBuildSummary.ts
|
|
4201
|
-
var
|
|
4229
|
+
var import_path7 = require("path");
|
|
4202
4230
|
|
|
4203
4231
|
// src/core/utils/log/printFileList.ts
|
|
4204
|
-
var
|
|
4232
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
4205
4233
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
4206
4234
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
4207
4235
|
var import_filesize = require("filesize");
|
|
@@ -4239,8 +4267,8 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
4239
4267
|
const fileRows = await Promise.all(
|
|
4240
4268
|
files.map(async (file, i) => {
|
|
4241
4269
|
const parts = [
|
|
4242
|
-
|
|
4243
|
-
|
|
4270
|
+
import_node_path9.default.relative(process.cwd(), baseDir) + import_node_path9.default.sep,
|
|
4271
|
+
import_node_path9.default.relative(baseDir, file)
|
|
4244
4272
|
];
|
|
4245
4273
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
4246
4274
|
const color = getChunkColor(file);
|
|
@@ -4285,7 +4313,7 @@ async function printBuildSummary(log, header, output, config) {
|
|
|
4285
4313
|
return diff;
|
|
4286
4314
|
return l.fileName.localeCompare(r.fileName);
|
|
4287
4315
|
});
|
|
4288
|
-
const files = chunks.map((chunk) => (0,
|
|
4316
|
+
const files = chunks.map((chunk) => (0, import_path7.resolve)(config.outDir, chunk.fileName));
|
|
4289
4317
|
await printFileList(log, header, config.outDir, files);
|
|
4290
4318
|
}
|
|
4291
4319
|
var DEFAULT_SORT_WEIGHT = 100;
|
|
@@ -4306,7 +4334,7 @@ function getChunkSortWeight(filename) {
|
|
|
4306
4334
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4307
4335
|
|
|
4308
4336
|
// package.json
|
|
4309
|
-
var version = "0.
|
|
4337
|
+
var version = "0.12.1";
|
|
4310
4338
|
|
|
4311
4339
|
// src/core/utils/log/printHeader.ts
|
|
4312
4340
|
var import_consola2 = require("consola");
|
|
@@ -4316,7 +4344,7 @@ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
|
4316
4344
|
|
|
4317
4345
|
// src/core/utils/manifest.ts
|
|
4318
4346
|
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
4319
|
-
var
|
|
4347
|
+
var import_path8 = require("path");
|
|
4320
4348
|
|
|
4321
4349
|
// src/core/utils/content-security-policy.ts
|
|
4322
4350
|
var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
@@ -4420,10 +4448,10 @@ function mapWxtOptionsToContentScript(options, config) {
|
|
|
4420
4448
|
}
|
|
4421
4449
|
|
|
4422
4450
|
// src/core/utils/package.ts
|
|
4423
|
-
var
|
|
4451
|
+
var import_node_path10 = require("path");
|
|
4424
4452
|
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
4425
4453
|
async function getPackageJson(config) {
|
|
4426
|
-
const file = (0,
|
|
4454
|
+
const file = (0, import_node_path10.resolve)(config.root, "package.json");
|
|
4427
4455
|
try {
|
|
4428
4456
|
return await import_fs_extra10.default.readJson(file);
|
|
4429
4457
|
} catch (err) {
|
|
@@ -4440,7 +4468,7 @@ var import_defu3 = __toESM(require("defu"), 1);
|
|
|
4440
4468
|
async function writeManifest(manifest, output, config) {
|
|
4441
4469
|
const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
4442
4470
|
await import_fs_extra11.default.ensureDir(config.outDir);
|
|
4443
|
-
await writeFileIfDifferent((0,
|
|
4471
|
+
await writeFileIfDifferent((0, import_path8.resolve)(config.outDir, "manifest.json"), str);
|
|
4444
4472
|
output.publicAssets.unshift({
|
|
4445
4473
|
type: "asset",
|
|
4446
4474
|
fileName: "manifest.json"
|
|
@@ -4909,7 +4937,7 @@ async function build(config) {
|
|
|
4909
4937
|
}
|
|
4910
4938
|
|
|
4911
4939
|
// src/core/clean.ts
|
|
4912
|
-
var
|
|
4940
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
4913
4941
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
4914
4942
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
4915
4943
|
var import_consola3 = require("consola");
|
|
@@ -4924,7 +4952,7 @@ async function clean(root = process.cwd()) {
|
|
|
4924
4952
|
];
|
|
4925
4953
|
import_consola3.consola.debug("Looking for:", tempDirs.map(import_picocolors5.default.cyan).join(", "));
|
|
4926
4954
|
const directories = await (0, import_fast_glob4.default)(tempDirs, {
|
|
4927
|
-
cwd:
|
|
4955
|
+
cwd: import_node_path13.default.resolve(root),
|
|
4928
4956
|
absolute: true,
|
|
4929
4957
|
onlyDirectories: true,
|
|
4930
4958
|
deep: 2
|
|
@@ -4935,11 +4963,11 @@ async function clean(root = process.cwd()) {
|
|
|
4935
4963
|
}
|
|
4936
4964
|
import_consola3.consola.debug(
|
|
4937
4965
|
"Found:",
|
|
4938
|
-
directories.map((dir) => import_picocolors5.default.cyan(
|
|
4966
|
+
directories.map((dir) => import_picocolors5.default.cyan(import_node_path13.default.relative(root, dir))).join(", ")
|
|
4939
4967
|
);
|
|
4940
4968
|
for (const directory of directories) {
|
|
4941
4969
|
await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
|
|
4942
|
-
import_consola3.consola.debug("Deleted " + import_picocolors5.default.cyan(
|
|
4970
|
+
import_consola3.consola.debug("Deleted " + import_picocolors5.default.cyan(import_node_path13.default.relative(root, directory)));
|
|
4943
4971
|
}
|
|
4944
4972
|
}
|
|
4945
4973
|
|
|
@@ -4954,12 +4982,12 @@ function defineRunnerConfig(config) {
|
|
|
4954
4982
|
}
|
|
4955
4983
|
|
|
4956
4984
|
// src/core/runners/wsl.ts
|
|
4957
|
-
var
|
|
4985
|
+
var import_node_path14 = require("path");
|
|
4958
4986
|
function createWslRunner() {
|
|
4959
4987
|
return {
|
|
4960
4988
|
async openBrowser(config) {
|
|
4961
4989
|
config.logger.warn(
|
|
4962
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
4990
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path14.relative)(
|
|
4963
4991
|
process.cwd(),
|
|
4964
4992
|
config.outDir
|
|
4965
4993
|
)}" as an unpacked extension manually`
|
|
@@ -5031,12 +5059,12 @@ var WARN_LOG_LEVEL = 40;
|
|
|
5031
5059
|
var ERROR_LOG_LEVEL = 50;
|
|
5032
5060
|
|
|
5033
5061
|
// src/core/runners/safari.ts
|
|
5034
|
-
var
|
|
5062
|
+
var import_node_path15 = require("path");
|
|
5035
5063
|
function createSafariRunner() {
|
|
5036
5064
|
return {
|
|
5037
5065
|
async openBrowser(config) {
|
|
5038
5066
|
config.logger.warn(
|
|
5039
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
5067
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path15.relative)(
|
|
5040
5068
|
process.cwd(),
|
|
5041
5069
|
config.outDir
|
|
5042
5070
|
)}" as an unpacked extension manually`
|
|
@@ -5048,12 +5076,12 @@ function createSafariRunner() {
|
|
|
5048
5076
|
}
|
|
5049
5077
|
|
|
5050
5078
|
// src/core/runners/manual.ts
|
|
5051
|
-
var
|
|
5079
|
+
var import_node_path16 = require("path");
|
|
5052
5080
|
function createManualRunner() {
|
|
5053
5081
|
return {
|
|
5054
5082
|
async openBrowser(config) {
|
|
5055
5083
|
config.logger.info(
|
|
5056
|
-
`Load "${(0,
|
|
5084
|
+
`Load "${(0, import_node_path16.relative)(
|
|
5057
5085
|
process.cwd(),
|
|
5058
5086
|
config.outDir
|
|
5059
5087
|
)}" as an unpacked extension manually`
|
|
@@ -5085,7 +5113,7 @@ async function createExtensionRunner(config) {
|
|
|
5085
5113
|
var import_consola4 = require("consola");
|
|
5086
5114
|
var import_async_mutex = require("async-mutex");
|
|
5087
5115
|
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
5088
|
-
var
|
|
5116
|
+
var import_node_path17 = require("path");
|
|
5089
5117
|
async function createServer(inlineConfig) {
|
|
5090
5118
|
const port = await getPort();
|
|
5091
5119
|
const hostname = "localhost";
|
|
@@ -5165,11 +5193,11 @@ function createFileReloader(options) {
|
|
|
5165
5193
|
if (changes.type === "no-change")
|
|
5166
5194
|
return;
|
|
5167
5195
|
config.logger.info(
|
|
5168
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors6.default.dim((0,
|
|
5196
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors6.default.dim((0, import_node_path17.relative)(config.root, file))).join(", ")}`
|
|
5169
5197
|
);
|
|
5170
5198
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
5171
5199
|
return import_picocolors6.default.cyan(
|
|
5172
|
-
(0,
|
|
5200
|
+
(0, import_node_path17.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
5173
5201
|
);
|
|
5174
5202
|
}).join(import_picocolors6.default.dim(", "));
|
|
5175
5203
|
const { output: newOutput } = await rebuild(
|
|
@@ -5236,7 +5264,7 @@ var import_prompts = __toESM(require("prompts"), 1);
|
|
|
5236
5264
|
var import_consola5 = require("consola");
|
|
5237
5265
|
var import_giget = require("giget");
|
|
5238
5266
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
5239
|
-
var
|
|
5267
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
5240
5268
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
5241
5269
|
async function initialize(options) {
|
|
5242
5270
|
import_consola5.consola.info("Initalizing new project");
|
|
@@ -5284,7 +5312,7 @@ async function initialize(options) {
|
|
|
5284
5312
|
input.template ??= defaultTemplate;
|
|
5285
5313
|
input.packageManager ??= options.packageManager;
|
|
5286
5314
|
await cloneProject(input);
|
|
5287
|
-
const cdPath =
|
|
5315
|
+
const cdPath = import_node_path18.default.relative(process.cwd(), import_node_path18.default.resolve(input.directory));
|
|
5288
5316
|
console.log();
|
|
5289
5317
|
import_consola5.consola.log(
|
|
5290
5318
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -5336,14 +5364,14 @@ async function cloneProject({
|
|
|
5336
5364
|
force: true
|
|
5337
5365
|
});
|
|
5338
5366
|
await import_fs_extra14.default.move(
|
|
5339
|
-
|
|
5340
|
-
|
|
5367
|
+
import_node_path18.default.join(directory, "_gitignore"),
|
|
5368
|
+
import_node_path18.default.join(directory, ".gitignore")
|
|
5341
5369
|
).catch(
|
|
5342
5370
|
(err) => import_consola5.consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
5343
5371
|
);
|
|
5344
5372
|
if (packageManager === "pnpm") {
|
|
5345
5373
|
await import_fs_extra14.default.writeFile(
|
|
5346
|
-
|
|
5374
|
+
import_node_path18.default.join(directory, ".npmrc"),
|
|
5347
5375
|
"shamefully-hoist=true\n"
|
|
5348
5376
|
);
|
|
5349
5377
|
}
|
|
@@ -5376,7 +5404,7 @@ async function prepare(config) {
|
|
|
5376
5404
|
|
|
5377
5405
|
// src/core/zip.ts
|
|
5378
5406
|
var import_zip_dir = __toESM(require("zip-dir"), 1);
|
|
5379
|
-
var
|
|
5407
|
+
var import_node_path19 = require("path");
|
|
5380
5408
|
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
5381
5409
|
var import_minimatch2 = require("minimatch");
|
|
5382
5410
|
async function zip(config) {
|
|
@@ -5386,7 +5414,7 @@ async function zip(config) {
|
|
|
5386
5414
|
internalConfig.logger.info("Zipping extension...");
|
|
5387
5415
|
const zipFiles = [];
|
|
5388
5416
|
const projectName = internalConfig.zip.name ?? kebabCaseAlphanumeric(
|
|
5389
|
-
(await getPackageJson(internalConfig))?.name || (0,
|
|
5417
|
+
(await getPackageJson(internalConfig))?.name || (0, import_node_path19.dirname)(process.cwd())
|
|
5390
5418
|
);
|
|
5391
5419
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", internalConfig.browser).replaceAll(
|
|
5392
5420
|
"{{version}}",
|
|
@@ -5394,7 +5422,7 @@ async function zip(config) {
|
|
|
5394
5422
|
).replaceAll("{{manifestVersion}}", `mv${internalConfig.manifestVersion}`);
|
|
5395
5423
|
await import_fs_extra15.default.ensureDir(internalConfig.outBaseDir);
|
|
5396
5424
|
const outZipFilename = applyTemplate(internalConfig.zip.artifactTemplate);
|
|
5397
|
-
const outZipPath = (0,
|
|
5425
|
+
const outZipPath = (0, import_node_path19.resolve)(internalConfig.outBaseDir, outZipFilename);
|
|
5398
5426
|
await (0, import_zip_dir.default)(internalConfig.outDir, {
|
|
5399
5427
|
saveTo: outZipPath
|
|
5400
5428
|
});
|
|
@@ -5403,14 +5431,14 @@ async function zip(config) {
|
|
|
5403
5431
|
const sourcesZipFilename = applyTemplate(
|
|
5404
5432
|
internalConfig.zip.sourcesTemplate
|
|
5405
5433
|
);
|
|
5406
|
-
const sourcesZipPath = (0,
|
|
5434
|
+
const sourcesZipPath = (0, import_node_path19.resolve)(
|
|
5407
5435
|
internalConfig.outBaseDir,
|
|
5408
5436
|
sourcesZipFilename
|
|
5409
5437
|
);
|
|
5410
5438
|
await (0, import_zip_dir.default)(internalConfig.zip.sourcesRoot, {
|
|
5411
5439
|
saveTo: sourcesZipPath,
|
|
5412
5440
|
filter(path10) {
|
|
5413
|
-
const relativePath = (0,
|
|
5441
|
+
const relativePath = (0, import_node_path19.relative)(internalConfig.zip.sourcesRoot, path10);
|
|
5414
5442
|
const matchedPattern = internalConfig.zip.ignoredSources.find(
|
|
5415
5443
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5416
5444
|
);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-tVP-84Pg.cjs';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-tVP-84Pg.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.
|
|
65
|
+
var version = "0.12.1";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-tVP-84Pg.js';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-tVP-84Pg.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.
|
|
65
|
+
var version = "0.12.1";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { U as UnlistedScriptDefinition } from './external-
|
|
1
|
+
import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './external-TYmXqKVq.js';
|
|
2
2
|
import 'webextension-polyfill';
|
|
3
3
|
|
|
4
4
|
declare function defineUnlistedScript(main: () => void): UnlistedScriptDefinition;
|
|
5
5
|
declare function defineUnlistedScript(definition: UnlistedScriptDefinition): UnlistedScriptDefinition;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
declare function defineBackground(main: () => void): BackgroundDefinition;
|
|
8
|
+
declare function defineBackground(definition: BackgroundDefinition): BackgroundDefinition;
|
|
9
|
+
|
|
10
|
+
declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
|
|
11
|
+
|
|
12
|
+
export { defineBackground, defineContentScript, defineUnlistedScript };
|
package/dist/sandbox.js
CHANGED
|
@@ -4,6 +4,20 @@ function defineUnlistedScript(arg) {
|
|
|
4
4
|
return { main: arg };
|
|
5
5
|
return arg;
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
// src/sandbox/define-background.ts
|
|
9
|
+
function defineBackground(arg) {
|
|
10
|
+
if (typeof arg === "function")
|
|
11
|
+
return { main: arg };
|
|
12
|
+
return arg;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/sandbox/define-content-script.ts
|
|
16
|
+
function defineContentScript(definition) {
|
|
17
|
+
return definition;
|
|
18
|
+
}
|
|
7
19
|
export {
|
|
20
|
+
defineBackground,
|
|
21
|
+
defineContentScript,
|
|
8
22
|
defineUnlistedScript
|
|
9
23
|
};
|
package/dist/testing.cjs
CHANGED
|
@@ -754,7 +754,8 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
754
754
|
devHtmlPrerender(wxtConfig),
|
|
755
755
|
unimport(wxtConfig),
|
|
756
756
|
virtualEntrypoint("background", wxtConfig),
|
|
757
|
-
virtualEntrypoint("content-script", wxtConfig),
|
|
757
|
+
virtualEntrypoint("content-script-isolated-world", wxtConfig),
|
|
758
|
+
virtualEntrypoint("content-script-main-world", wxtConfig),
|
|
758
759
|
virtualEntrypoint("unlisted-script", wxtConfig),
|
|
759
760
|
devServerGlobals(wxtConfig),
|
|
760
761
|
tsconfigPaths(wxtConfig),
|
|
@@ -768,12 +769,17 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
768
769
|
return config;
|
|
769
770
|
};
|
|
770
771
|
const getLibModeConfig = (entrypoint) => {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
"
|
|
774
|
-
"unlisted-script"
|
|
775
|
-
|
|
776
|
-
|
|
772
|
+
let virtualEntrypointType;
|
|
773
|
+
switch (entrypoint.type) {
|
|
774
|
+
case "background":
|
|
775
|
+
case "unlisted-script":
|
|
776
|
+
virtualEntrypointType = entrypoint.type;
|
|
777
|
+
break;
|
|
778
|
+
case "content-script":
|
|
779
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
777
783
|
const plugins = [
|
|
778
784
|
entrypointGroupGlobals(entrypoint)
|
|
779
785
|
];
|
|
@@ -934,7 +940,10 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
934
940
|
const { config: loadedConfig, ...metadata } = await (0, import_c12.loadConfig)({
|
|
935
941
|
name: "wxt",
|
|
936
942
|
cwd: inlineConfig.root ?? process.cwd(),
|
|
937
|
-
rcFile: false
|
|
943
|
+
rcFile: false,
|
|
944
|
+
jitiOptions: {
|
|
945
|
+
esmResolve: true
|
|
946
|
+
}
|
|
938
947
|
});
|
|
939
948
|
userConfig = loadedConfig ?? {};
|
|
940
949
|
userConfigMetadata = metadata;
|
|
@@ -1107,14 +1116,16 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1107
1116
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
1108
1117
|
var import_unimport5 = require("unimport");
|
|
1109
1118
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
1119
|
+
var import_node_path8 = require("path");
|
|
1110
1120
|
var import_esbuild = require("esbuild");
|
|
1121
|
+
var import_node_url = require("url");
|
|
1111
1122
|
|
|
1112
1123
|
// src/core/utils/building/internal-build.ts
|
|
1113
1124
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
1114
1125
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
1115
1126
|
|
|
1116
1127
|
// src/core/utils/log/printFileList.ts
|
|
1117
|
-
var
|
|
1128
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
1118
1129
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
1119
1130
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
1120
1131
|
var import_filesize = require("filesize");
|
|
@@ -1142,7 +1153,7 @@ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
|
1142
1153
|
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
1143
1154
|
|
|
1144
1155
|
// src/core/utils/package.ts
|
|
1145
|
-
var
|
|
1156
|
+
var import_node_path10 = require("path");
|
|
1146
1157
|
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
1147
1158
|
|
|
1148
1159
|
// src/core/utils/manifest.ts
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-tVP-84Pg.cjs';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-tVP-84Pg.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|