wxt 0.17.4 → 0.17.6
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/{chunk-E5MGUY6P.js → chunk-3ZE2CHPV.js} +313 -35
- package/dist/chunk-VBXJIVYU.js +38 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +455 -101
- package/dist/execa-4F7CCWCA.js +2191 -0
- package/dist/{index-vpYNIeCJ.d.cts → index-l43sonfW.d.cts} +83 -3
- package/dist/{index-vpYNIeCJ.d.ts → index-l43sonfW.d.ts} +83 -3
- package/dist/index.cjs +2914 -182
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +105 -27
- package/dist/storage.js +1 -1
- package/dist/testing.cjs +71 -44
- package/dist/testing.d.cts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +2 -2
- package/package.json +5 -3
- package/dist/chunk-P57PW2II.js +0 -11
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 './index-
|
|
2
|
-
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-l43sonfW.cjs';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-l43sonfW.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -8,6 +8,7 @@ import '@aklinker1/rollup-plugin-visualizer';
|
|
|
8
8
|
import 'chokidar';
|
|
9
9
|
import 'c12';
|
|
10
10
|
import 'hookable';
|
|
11
|
+
import 'nypm';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
@@ -59,11 +60,11 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Build and zip the extension for distribution.
|
|
62
|
-
* @param config
|
|
63
|
+
* @param config Optional config that will override your `<root>/wxt.config.ts`.
|
|
63
64
|
* @returns A list of all files included in the ZIP.
|
|
64
65
|
*/
|
|
65
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
67
|
|
|
67
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.6";
|
|
68
69
|
|
|
69
70
|
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 './index-
|
|
2
|
-
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-l43sonfW.js';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-l43sonfW.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -8,6 +8,7 @@ import '@aklinker1/rollup-plugin-visualizer';
|
|
|
8
8
|
import 'chokidar';
|
|
9
9
|
import 'c12';
|
|
10
10
|
import 'hookable';
|
|
11
|
+
import 'nypm';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in
|
|
@@ -59,11 +60,11 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Build and zip the extension for distribution.
|
|
62
|
-
* @param config
|
|
63
|
+
* @param config Optional config that will override your `<root>/wxt.config.ts`.
|
|
63
64
|
* @returns A list of all files included in the ZIP.
|
|
64
65
|
*/
|
|
65
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
67
|
|
|
67
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.6";
|
|
68
69
|
|
|
69
70
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
isHtmlEntrypoint,
|
|
12
12
|
kebabCaseAlphanumeric,
|
|
13
13
|
mapWxtOptionsToRegisteredContentScript,
|
|
14
|
+
normalizePath,
|
|
14
15
|
printFileList,
|
|
15
16
|
rebuild,
|
|
16
17
|
registerWxt,
|
|
17
18
|
unnormalizePath,
|
|
18
19
|
version,
|
|
19
20
|
wxt
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-3ZE2CHPV.js";
|
|
22
|
+
import "./chunk-VBXJIVYU.js";
|
|
22
23
|
|
|
23
24
|
// src/core/build.ts
|
|
24
25
|
async function build(config) {
|
|
@@ -271,8 +272,8 @@ async function createServer(inlineConfig) {
|
|
|
271
272
|
reloadContentScript(payload) {
|
|
272
273
|
server.ws.send("wxt:reload-content-script", payload);
|
|
273
274
|
},
|
|
274
|
-
reloadPage(
|
|
275
|
-
server.ws.send("wxt:reload-page",
|
|
275
|
+
reloadPage(path4) {
|
|
276
|
+
server.ws.send("wxt:reload-page", path4);
|
|
276
277
|
},
|
|
277
278
|
reloadExtension() {
|
|
278
279
|
server.ws.send("wxt:reload-extension");
|
|
@@ -303,11 +304,11 @@ async function getPort() {
|
|
|
303
304
|
function createFileReloader(server) {
|
|
304
305
|
const fileChangedMutex = new Mutex();
|
|
305
306
|
const changeQueue = [];
|
|
306
|
-
return async (event,
|
|
307
|
+
return async (event, path4) => {
|
|
307
308
|
await wxt.reloadConfig();
|
|
308
|
-
if (
|
|
309
|
+
if (path4.startsWith(wxt.config.outBaseDir))
|
|
309
310
|
return;
|
|
310
|
-
changeQueue.push([event,
|
|
311
|
+
changeQueue.push([event, path4]);
|
|
311
312
|
await fileChangedMutex.runExclusive(async () => {
|
|
312
313
|
if (server.currentOutput == null)
|
|
313
314
|
return;
|
|
@@ -386,8 +387,8 @@ function reloadContentScripts(steps, server) {
|
|
|
386
387
|
function reloadHtmlPages(groups, server) {
|
|
387
388
|
const htmlEntries = groups.flat().filter(isHtmlEntrypoint);
|
|
388
389
|
htmlEntries.forEach((entry) => {
|
|
389
|
-
const
|
|
390
|
-
server.reloadPage(
|
|
390
|
+
const path4 = getEntrypointBundlePath(entry, wxt.config.outDir, ".html");
|
|
391
|
+
server.reloadPage(path4);
|
|
391
392
|
});
|
|
392
393
|
return {
|
|
393
394
|
reloadedNames: htmlEntries.map((entry) => entry.name)
|
|
@@ -543,10 +544,11 @@ async function prepare(config) {
|
|
|
543
544
|
}
|
|
544
545
|
|
|
545
546
|
// src/core/zip.ts
|
|
546
|
-
import
|
|
547
|
-
import { dirname, relative as relative5, resolve } from "node:path";
|
|
547
|
+
import path3 from "node:path";
|
|
548
548
|
import fs3 from "fs-extra";
|
|
549
549
|
import { minimatch } from "minimatch";
|
|
550
|
+
import JSZip from "jszip";
|
|
551
|
+
import glob2 from "fast-glob";
|
|
550
552
|
async function zip(config) {
|
|
551
553
|
await registerWxt("build", config);
|
|
552
554
|
const output = await internalBuild();
|
|
@@ -554,7 +556,7 @@ async function zip(config) {
|
|
|
554
556
|
wxt.logger.info("Zipping extension...");
|
|
555
557
|
const zipFiles = [];
|
|
556
558
|
const projectName = wxt.config.zip.name ?? kebabCaseAlphanumeric(
|
|
557
|
-
(await getPackageJson())?.name || dirname(process.cwd())
|
|
559
|
+
(await getPackageJson())?.name || path3.dirname(process.cwd())
|
|
558
560
|
);
|
|
559
561
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
560
562
|
"{{version}}",
|
|
@@ -562,24 +564,25 @@ async function zip(config) {
|
|
|
562
564
|
).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
563
565
|
await fs3.ensureDir(wxt.config.outBaseDir);
|
|
564
566
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
565
|
-
const outZipPath = resolve(wxt.config.outBaseDir, outZipFilename);
|
|
566
|
-
await
|
|
567
|
-
saveTo: outZipPath
|
|
568
|
-
});
|
|
567
|
+
const outZipPath = path3.resolve(wxt.config.outBaseDir, outZipFilename);
|
|
568
|
+
await zipDir(wxt.config.outDir, outZipPath);
|
|
569
569
|
zipFiles.push(outZipPath);
|
|
570
570
|
if (wxt.config.browser === "firefox") {
|
|
571
|
+
const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
|
|
571
572
|
const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
|
|
572
|
-
const sourcesZipPath = resolve(
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
573
|
+
const sourcesZipPath = path3.resolve(
|
|
574
|
+
wxt.config.outBaseDir,
|
|
575
|
+
sourcesZipFilename
|
|
576
|
+
);
|
|
577
|
+
await zipDir(wxt.config.zip.sourcesRoot, sourcesZipPath, {
|
|
578
|
+
include: wxt.config.zip.includeSources,
|
|
579
|
+
exclude: wxt.config.zip.excludeSources,
|
|
580
|
+
transform(file, content) {
|
|
581
|
+
if (file.endsWith("package.json")) {
|
|
582
|
+
return addOverridesToPackageJson(content, overrides);
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
additionalFiles: downloadedPackages
|
|
583
586
|
});
|
|
584
587
|
zipFiles.push(sourcesZipPath);
|
|
585
588
|
}
|
|
@@ -591,6 +594,81 @@ async function zip(config) {
|
|
|
591
594
|
);
|
|
592
595
|
return zipFiles;
|
|
593
596
|
}
|
|
597
|
+
async function zipDir(directory, outputPath, options) {
|
|
598
|
+
const archive = new JSZip();
|
|
599
|
+
const files = (await glob2("**/*", {
|
|
600
|
+
cwd: directory,
|
|
601
|
+
// Ignore node_modules, otherwise this glob step takes forever
|
|
602
|
+
ignore: ["**/node_modules"],
|
|
603
|
+
onlyFiles: true
|
|
604
|
+
})).filter((relativePath) => {
|
|
605
|
+
return wxt.config.zip.includeSources.some(
|
|
606
|
+
(pattern) => minimatch(relativePath, pattern)
|
|
607
|
+
) || !wxt.config.zip.excludeSources.some(
|
|
608
|
+
(pattern) => minimatch(relativePath, pattern)
|
|
609
|
+
);
|
|
610
|
+
});
|
|
611
|
+
const filesToZip = [
|
|
612
|
+
...files,
|
|
613
|
+
...(options?.additionalFiles ?? []).map(
|
|
614
|
+
(file) => path3.relative(directory, file)
|
|
615
|
+
)
|
|
616
|
+
];
|
|
617
|
+
for (const file of filesToZip) {
|
|
618
|
+
const absolutePath = path3.resolve(directory, file);
|
|
619
|
+
if (file.endsWith(".json")) {
|
|
620
|
+
const content = await fs3.readFile(absolutePath, "utf-8");
|
|
621
|
+
archive.file(
|
|
622
|
+
file,
|
|
623
|
+
await options?.transform?.(file, content) || content
|
|
624
|
+
);
|
|
625
|
+
} else {
|
|
626
|
+
const content = await fs3.readFile(absolutePath);
|
|
627
|
+
archive.file(file, content);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
await options?.additionalWork?.(archive);
|
|
631
|
+
const buffer = await archive.generateAsync({ type: "base64" });
|
|
632
|
+
await fs3.writeFile(outputPath, buffer, "base64");
|
|
633
|
+
}
|
|
634
|
+
async function downloadPrivatePackages() {
|
|
635
|
+
const overrides = {};
|
|
636
|
+
const files = [];
|
|
637
|
+
if (wxt.config.zip.downloadPackages.length > 0) {
|
|
638
|
+
const _downloadPackages = new Set(wxt.config.zip.downloadPackages);
|
|
639
|
+
const allPackages = await wxt.pm.listDependencies({
|
|
640
|
+
all: true,
|
|
641
|
+
cwd: wxt.config.root
|
|
642
|
+
});
|
|
643
|
+
const downloadPackages = allPackages.filter(
|
|
644
|
+
(pkg) => _downloadPackages.has(pkg.name)
|
|
645
|
+
);
|
|
646
|
+
for (const pkg of downloadPackages) {
|
|
647
|
+
wxt.logger.info(`Downloading package: ${pkg.name}@${pkg.version}`);
|
|
648
|
+
const id = `${pkg.name}@${pkg.version}`;
|
|
649
|
+
const tgzPath = await wxt.pm.downloadDependency(
|
|
650
|
+
id,
|
|
651
|
+
wxt.config.zip.downloadedPackagesDir
|
|
652
|
+
);
|
|
653
|
+
files.push(tgzPath);
|
|
654
|
+
overrides[id] = "file://./" + normalizePath(path3.relative(wxt.config.root, tgzPath));
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return { overrides, files };
|
|
658
|
+
}
|
|
659
|
+
function addOverridesToPackageJson(content, overrides) {
|
|
660
|
+
if (Object.keys(overrides).length === 0)
|
|
661
|
+
return content;
|
|
662
|
+
const oldPackage = JSON.parse(content);
|
|
663
|
+
const newPackage = {
|
|
664
|
+
...oldPackage,
|
|
665
|
+
[wxt.pm.overridesKey]: {
|
|
666
|
+
...oldPackage[wxt.pm.overridesKey],
|
|
667
|
+
...overrides
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
return JSON.stringify(newPackage, null, 2);
|
|
671
|
+
}
|
|
594
672
|
export {
|
|
595
673
|
build,
|
|
596
674
|
clean,
|
package/dist/storage.js
CHANGED
package/dist/testing.cjs
CHANGED
|
@@ -44,8 +44,8 @@ var import_node_path2 = __toESM(require("path"), 1);
|
|
|
44
44
|
// src/core/utils/paths.ts
|
|
45
45
|
var import_node_path = __toESM(require("path"), 1);
|
|
46
46
|
var import_normalize_path = __toESM(require("normalize-path"), 1);
|
|
47
|
-
function normalizePath(
|
|
48
|
-
return (0, import_normalize_path.default)(
|
|
47
|
+
function normalizePath(path8) {
|
|
48
|
+
return (0, import_normalize_path.default)(path8);
|
|
49
49
|
}
|
|
50
50
|
var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
|
|
51
51
|
var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
|
|
@@ -191,10 +191,10 @@ function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
|
191
191
|
(0, import_node_path3.relative)(config.root, resolvedAbsolutePath)
|
|
192
192
|
);
|
|
193
193
|
if (relativePath.startsWith(".")) {
|
|
194
|
-
let
|
|
195
|
-
if (!
|
|
196
|
-
|
|
197
|
-
element.setAttribute(attr, `${server.origin}/@fs${
|
|
194
|
+
let path8 = normalizePath(resolvedAbsolutePath);
|
|
195
|
+
if (!path8.startsWith("/"))
|
|
196
|
+
path8 = "/" + path8;
|
|
197
|
+
element.setAttribute(attr, `${server.origin}/@fs${path8}`);
|
|
198
198
|
} else {
|
|
199
199
|
const url = new URL(relativePath, server.origin);
|
|
200
200
|
element.setAttribute(attr, url.href);
|
|
@@ -647,26 +647,33 @@ function defineImportMeta() {
|
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
// src/core/utils/fs.ts
|
|
650
|
-
var
|
|
650
|
+
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
651
651
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
652
652
|
|
|
653
653
|
// src/core/wxt.ts
|
|
654
654
|
var import_hookable = require("hookable");
|
|
655
655
|
|
|
656
|
+
// src/core/package-managers/index.ts
|
|
657
|
+
var import_nypm = require("nypm");
|
|
658
|
+
|
|
659
|
+
// src/core/package-managers/npm.ts
|
|
660
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
661
|
+
var import_fs_extra3 = require("fs-extra");
|
|
662
|
+
|
|
656
663
|
// src/core/utils/fs.ts
|
|
657
664
|
async function writeFileIfDifferent(file, newContents) {
|
|
658
|
-
const existingContents = await
|
|
665
|
+
const existingContents = await import_fs_extra4.default.readFile(file, "utf-8").catch(() => void 0);
|
|
659
666
|
if (existingContents !== newContents) {
|
|
660
|
-
await
|
|
667
|
+
await import_fs_extra4.default.writeFile(file, newContents);
|
|
661
668
|
}
|
|
662
669
|
}
|
|
663
670
|
|
|
664
671
|
// src/core/utils/building/build-entrypoints.ts
|
|
665
|
-
var
|
|
672
|
+
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
666
673
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
667
674
|
|
|
668
675
|
// src/core/utils/building/find-entrypoints.ts
|
|
669
|
-
var
|
|
676
|
+
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
670
677
|
var import_minimatch = require("minimatch");
|
|
671
678
|
var import_linkedom2 = require("linkedom");
|
|
672
679
|
var import_json5 = __toESM(require("json5"), 1);
|
|
@@ -714,28 +721,28 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
714
721
|
|
|
715
722
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
716
723
|
var import_unimport2 = require("unimport");
|
|
717
|
-
var
|
|
718
|
-
var
|
|
724
|
+
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
725
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
719
726
|
|
|
720
727
|
// src/core/utils/building/resolve-config.ts
|
|
721
728
|
var import_c12 = require("c12");
|
|
722
|
-
var
|
|
729
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
723
730
|
|
|
724
731
|
// src/core/utils/cache.ts
|
|
725
|
-
var
|
|
732
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
726
733
|
var import_path3 = require("path");
|
|
727
734
|
function createFsCache(wxtDir) {
|
|
728
735
|
const getPath = (key) => (0, import_path3.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
729
736
|
return {
|
|
730
737
|
async set(key, value) {
|
|
731
|
-
const
|
|
732
|
-
await (0,
|
|
733
|
-
await writeFileIfDifferent(
|
|
738
|
+
const path8 = getPath(key);
|
|
739
|
+
await (0, import_fs_extra8.ensureDir)((0, import_path3.dirname)(path8));
|
|
740
|
+
await writeFileIfDifferent(path8, value);
|
|
734
741
|
},
|
|
735
742
|
async get(key) {
|
|
736
|
-
const
|
|
743
|
+
const path8 = getPath(key);
|
|
737
744
|
try {
|
|
738
|
-
return await
|
|
745
|
+
return await import_fs_extra8.default.readFile(path8, "utf-8");
|
|
739
746
|
} catch {
|
|
740
747
|
return void 0;
|
|
741
748
|
}
|
|
@@ -969,13 +976,14 @@ function getRollupEntry(entrypoint) {
|
|
|
969
976
|
var import_defu = __toESM(require("defu"), 1);
|
|
970
977
|
|
|
971
978
|
// src/core/utils/package.ts
|
|
972
|
-
var
|
|
973
|
-
var
|
|
979
|
+
var import_node_path9 = require("path");
|
|
980
|
+
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
974
981
|
function isModuleInstalled(name) {
|
|
975
982
|
return import(name).then(() => true).catch(() => false);
|
|
976
983
|
}
|
|
977
984
|
|
|
978
985
|
// src/core/utils/building/resolve-config.ts
|
|
986
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
979
987
|
var import_meta = {};
|
|
980
988
|
async function resolveConfig(inlineConfig, command, server) {
|
|
981
989
|
let userConfig = {};
|
|
@@ -1002,21 +1010,27 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1002
1010
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
1003
1011
|
const mode = mergedConfig.mode ?? (command === "build" ? "production" : "development");
|
|
1004
1012
|
const env = { browser, command, manifestVersion, mode };
|
|
1005
|
-
const root =
|
|
1013
|
+
const root = import_node_path10.default.resolve(
|
|
1006
1014
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
1007
1015
|
);
|
|
1008
|
-
const wxtDir =
|
|
1016
|
+
const wxtDir = import_node_path10.default.resolve(root, ".wxt");
|
|
1009
1017
|
const wxtModuleDir = await resolveWxtModuleDir();
|
|
1010
|
-
const srcDir =
|
|
1011
|
-
const entrypointsDir =
|
|
1018
|
+
const srcDir = import_node_path10.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
1019
|
+
const entrypointsDir = import_node_path10.default.resolve(
|
|
1012
1020
|
srcDir,
|
|
1013
1021
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
1014
1022
|
);
|
|
1023
|
+
if (await isDirMissing(entrypointsDir)) {
|
|
1024
|
+
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
1025
|
+
}
|
|
1015
1026
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
1016
|
-
const publicDir =
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1027
|
+
const publicDir = import_node_path10.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
1028
|
+
if (await isDirMissing(publicDir)) {
|
|
1029
|
+
logMissingDir(logger, "Public", publicDir);
|
|
1030
|
+
}
|
|
1031
|
+
const typesDir = import_node_path10.default.resolve(wxtDir, "types");
|
|
1032
|
+
const outBaseDir = import_node_path10.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
1033
|
+
const outDir = import_node_path10.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
1020
1034
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
1021
1035
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
1022
1036
|
name: "web-ext",
|
|
@@ -1033,14 +1047,14 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1033
1047
|
"~": srcDir,
|
|
1034
1048
|
"@@": root,
|
|
1035
1049
|
"~~": root
|
|
1036
|
-
}).map(([key, value]) => [key,
|
|
1050
|
+
}).map(([key, value]) => [key, import_node_path10.default.resolve(root, value)])
|
|
1037
1051
|
);
|
|
1038
|
-
const analysisOutputFile =
|
|
1052
|
+
const analysisOutputFile = import_node_path10.default.resolve(
|
|
1039
1053
|
root,
|
|
1040
1054
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
1041
1055
|
);
|
|
1042
|
-
const analysisOutputDir =
|
|
1043
|
-
const analysisOutputName =
|
|
1056
|
+
const analysisOutputDir = import_node_path10.default.dirname(analysisOutputFile);
|
|
1057
|
+
const analysisOutputName = import_node_path10.default.parse(analysisOutputFile).name;
|
|
1044
1058
|
const finalConfig = {
|
|
1045
1059
|
browser,
|
|
1046
1060
|
command,
|
|
@@ -1165,6 +1179,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1165
1179
|
};
|
|
1166
1180
|
}
|
|
1167
1181
|
function resolveInternalZipConfig(root, mergedConfig) {
|
|
1182
|
+
const downloadedPackagesDir = import_node_path10.default.resolve(root, ".wxt/local_modules");
|
|
1168
1183
|
return {
|
|
1169
1184
|
name: void 0,
|
|
1170
1185
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -1183,7 +1198,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1183
1198
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1184
1199
|
// From user
|
|
1185
1200
|
...mergedConfig.zip?.excludeSources ?? []
|
|
1186
|
-
]
|
|
1201
|
+
],
|
|
1202
|
+
downloadPackages: mergedConfig.zip?.downloadPackages ?? [],
|
|
1203
|
+
downloadedPackagesDir
|
|
1187
1204
|
};
|
|
1188
1205
|
}
|
|
1189
1206
|
async function getUnimportOptions(wxtDir, logger, config) {
|
|
@@ -1215,7 +1232,7 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1215
1232
|
dirs: ["components", "composables", "hooks", "utils"],
|
|
1216
1233
|
eslintrc: {
|
|
1217
1234
|
enabled,
|
|
1218
|
-
filePath:
|
|
1235
|
+
filePath: import_node_path10.default.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
1219
1236
|
globalsPropValue: true
|
|
1220
1237
|
}
|
|
1221
1238
|
};
|
|
@@ -1226,25 +1243,35 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1226
1243
|
}
|
|
1227
1244
|
async function resolveWxtModuleDir() {
|
|
1228
1245
|
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta.url).resolve;
|
|
1229
|
-
return
|
|
1246
|
+
return import_node_path10.default.resolve(requireResolve("wxt"), "../..");
|
|
1247
|
+
}
|
|
1248
|
+
async function isDirMissing(dir) {
|
|
1249
|
+
return !await import_fs_extra10.default.exists(dir);
|
|
1250
|
+
}
|
|
1251
|
+
function logMissingDir(logger, name, expected) {
|
|
1252
|
+
logger.warn(
|
|
1253
|
+
`${name} directory not found: ./${normalizePath(
|
|
1254
|
+
import_node_path10.default.relative(process.cwd(), expected)
|
|
1255
|
+
)}`
|
|
1256
|
+
);
|
|
1230
1257
|
}
|
|
1231
1258
|
|
|
1232
1259
|
// src/core/utils/building/import-entrypoint.ts
|
|
1233
1260
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
1234
1261
|
var import_unimport3 = require("unimport");
|
|
1235
|
-
var
|
|
1236
|
-
var
|
|
1262
|
+
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
1263
|
+
var import_node_path11 = require("path");
|
|
1237
1264
|
var import_esbuild = require("esbuild");
|
|
1238
1265
|
var import_node_url = require("url");
|
|
1239
1266
|
|
|
1240
1267
|
// src/core/utils/building/internal-build.ts
|
|
1241
1268
|
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
1242
|
-
var
|
|
1269
|
+
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
1243
1270
|
|
|
1244
1271
|
// src/core/utils/log/printFileList.ts
|
|
1245
|
-
var
|
|
1272
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1246
1273
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
1247
|
-
var
|
|
1274
|
+
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
1248
1275
|
var import_filesize = require("filesize");
|
|
1249
1276
|
var DEFAULT_COLOR = import_picocolors3.default.blue;
|
|
1250
1277
|
var CHUNK_COLORS = {
|
|
@@ -1267,11 +1294,11 @@ var import_consola2 = require("consola");
|
|
|
1267
1294
|
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
1268
1295
|
|
|
1269
1296
|
// src/core/utils/manifest.ts
|
|
1270
|
-
var
|
|
1297
|
+
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
1271
1298
|
var import_defu2 = __toESM(require("defu"), 1);
|
|
1272
1299
|
|
|
1273
1300
|
// src/core/utils/building/internal-build.ts
|
|
1274
|
-
var
|
|
1301
|
+
var import_node_path13 = require("path");
|
|
1275
1302
|
var import_consola3 = __toESM(require("consola"), 1);
|
|
1276
1303
|
var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
|
|
1277
1304
|
|
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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-l43sonfW.cjs';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
|
@@ -8,6 +8,7 @@ import '@aklinker1/rollup-plugin-visualizer';
|
|
|
8
8
|
import 'chokidar';
|
|
9
9
|
import 'c12';
|
|
10
10
|
import 'hookable';
|
|
11
|
+
import 'nypm';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Vite plugin that configures Vitest with everything required to test a WXT extension, based on the `<root>/wxt.config.ts`
|
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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-l43sonfW.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
|
@@ -8,6 +8,7 @@ import '@aklinker1/rollup-plugin-visualizer';
|
|
|
8
8
|
import 'chokidar';
|
|
9
9
|
import 'c12';
|
|
10
10
|
import 'hookable';
|
|
11
|
+
import 'nypm';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Vite plugin that configures Vitest with everything required to test a WXT extension, based on the `<root>/wxt.config.ts`
|
package/dist/testing.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
tsconfigPaths,
|
|
6
6
|
unimport,
|
|
7
7
|
webextensionPolyfillMock
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-3ZE2CHPV.js";
|
|
9
|
+
import "./chunk-VBXJIVYU.js";
|
|
10
10
|
|
|
11
11
|
// src/testing/fake-browser.ts
|
|
12
12
|
import { fakeBrowser } from "@webext-core/fake-browser";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.6",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -107,10 +107,12 @@
|
|
|
107
107
|
"is-wsl": "^3.0.0",
|
|
108
108
|
"jiti": "^1.21.0",
|
|
109
109
|
"json5": "^2.2.3",
|
|
110
|
+
"jszip": "^3.10.1",
|
|
110
111
|
"linkedom": "^0.16.1",
|
|
111
112
|
"minimatch": "^9.0.3",
|
|
112
113
|
"natural-compare": "^1.4.0",
|
|
113
114
|
"normalize-path": "^3.0.0",
|
|
115
|
+
"nypm": "^0.3.6",
|
|
114
116
|
"ora": "^7.0.1",
|
|
115
117
|
"picocolors": "^1.0.0",
|
|
116
118
|
"prompts": "^2.4.2",
|
|
@@ -118,8 +120,7 @@
|
|
|
118
120
|
"unimport": "^3.4.0",
|
|
119
121
|
"vite": "^5.1.3",
|
|
120
122
|
"web-ext-run": "^0.2.0",
|
|
121
|
-
"webextension-polyfill": "^0.10.0"
|
|
122
|
-
"zip-dir": "^2.0.0"
|
|
123
|
+
"webextension-polyfill": "^0.10.0"
|
|
123
124
|
},
|
|
124
125
|
"devDependencies": {
|
|
125
126
|
"@faker-js/faker": "^8.3.1",
|
|
@@ -131,6 +132,7 @@
|
|
|
131
132
|
"@types/prompts": "^2.4.9",
|
|
132
133
|
"@vitest/coverage-v8": "^1.0.1",
|
|
133
134
|
"execa": "^8.0.1",
|
|
135
|
+
"extract-zip": "^2.0.1",
|
|
134
136
|
"happy-dom": "^13.3.8",
|
|
135
137
|
"lint-staged": "^15.2.0",
|
|
136
138
|
"lodash.merge": "^4.6.2",
|
package/dist/chunk-P57PW2II.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
__require
|
|
11
|
-
};
|