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
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__require
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VBXJIVYU.js";
|
|
4
4
|
|
|
5
5
|
// package.json
|
|
6
|
-
var version = "0.17.
|
|
6
|
+
var version = "0.17.6";
|
|
7
7
|
|
|
8
8
|
// src/core/utils/paths.ts
|
|
9
9
|
import systemPath from "node:path";
|
|
10
10
|
import normalize from "normalize-path";
|
|
11
|
-
function normalizePath(
|
|
12
|
-
return normalize(
|
|
11
|
+
function normalizePath(path8) {
|
|
12
|
+
return normalize(path8);
|
|
13
13
|
}
|
|
14
|
-
function unnormalizePath(
|
|
15
|
-
return systemPath.normalize(
|
|
14
|
+
function unnormalizePath(path8) {
|
|
15
|
+
return systemPath.normalize(path8);
|
|
16
16
|
}
|
|
17
17
|
var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
|
|
18
18
|
var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
|
|
@@ -733,7 +733,7 @@ async function writePathsDeclarationFile(entrypoints) {
|
|
|
733
733
|
wxt.config.outDir,
|
|
734
734
|
isHtmlEntrypoint(entry) ? ".html" : ".js"
|
|
735
735
|
)
|
|
736
|
-
).concat(await getPublicFiles()).map(normalizePath).map((
|
|
736
|
+
).concat(await getPublicFiles()).map(normalizePath).map((path8) => ` | "/${path8}"`).sort().join("\n");
|
|
737
737
|
const template = `// Generated by wxt
|
|
738
738
|
import "wxt/browser";
|
|
739
739
|
|
|
@@ -841,7 +841,7 @@ async function writeMainDeclarationFile(references) {
|
|
|
841
841
|
}
|
|
842
842
|
async function writeTsConfigFile(mainReference) {
|
|
843
843
|
const dir = wxt.config.wxtDir;
|
|
844
|
-
const getTsconfigPath = (
|
|
844
|
+
const getTsconfigPath = (path8) => normalizePath(relative3(dir, path8));
|
|
845
845
|
const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
|
|
846
846
|
const aliasPath = getTsconfigPath(absolutePath);
|
|
847
847
|
return [
|
|
@@ -886,14 +886,14 @@ function createFsCache(wxtDir) {
|
|
|
886
886
|
const getPath = (key) => resolve5(wxtDir, "cache", encodeURIComponent(key));
|
|
887
887
|
return {
|
|
888
888
|
async set(key, value) {
|
|
889
|
-
const
|
|
890
|
-
await ensureDir(dirname2(
|
|
891
|
-
await writeFileIfDifferent(
|
|
889
|
+
const path8 = getPath(key);
|
|
890
|
+
await ensureDir(dirname2(path8));
|
|
891
|
+
await writeFileIfDifferent(path8, value);
|
|
892
892
|
},
|
|
893
893
|
async get(key) {
|
|
894
|
-
const
|
|
894
|
+
const path8 = getPath(key);
|
|
895
895
|
try {
|
|
896
|
-
return await fs5.readFile(
|
|
896
|
+
return await fs5.readFile(path8, "utf-8");
|
|
897
897
|
} catch {
|
|
898
898
|
return void 0;
|
|
899
899
|
}
|
|
@@ -1027,10 +1027,10 @@ function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
|
1027
1027
|
relative4(config.root, resolvedAbsolutePath)
|
|
1028
1028
|
);
|
|
1029
1029
|
if (relativePath.startsWith(".")) {
|
|
1030
|
-
let
|
|
1031
|
-
if (!
|
|
1032
|
-
|
|
1033
|
-
element.setAttribute(attr, `${server.origin}/@fs${
|
|
1030
|
+
let path8 = normalizePath(resolvedAbsolutePath);
|
|
1031
|
+
if (!path8.startsWith("/"))
|
|
1032
|
+
path8 = "/" + path8;
|
|
1033
|
+
element.setAttribute(attr, `${server.origin}/@fs${path8}`);
|
|
1034
1034
|
} else {
|
|
1035
1035
|
const url = new URL(relativePath, server.origin);
|
|
1036
1036
|
element.setAttribute(attr, url.href);
|
|
@@ -1674,6 +1674,7 @@ function isModuleInstalled(name) {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
|
|
1676
1676
|
// src/core/utils/building/resolve-config.ts
|
|
1677
|
+
import fs9 from "fs-extra";
|
|
1677
1678
|
async function resolveConfig(inlineConfig, command, server) {
|
|
1678
1679
|
let userConfig = {};
|
|
1679
1680
|
let userConfigMetadata;
|
|
@@ -1709,8 +1710,14 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1709
1710
|
srcDir,
|
|
1710
1711
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
1711
1712
|
);
|
|
1713
|
+
if (await isDirMissing(entrypointsDir)) {
|
|
1714
|
+
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
1715
|
+
}
|
|
1712
1716
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
1713
1717
|
const publicDir = path5.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
1718
|
+
if (await isDirMissing(publicDir)) {
|
|
1719
|
+
logMissingDir(logger, "Public", publicDir);
|
|
1720
|
+
}
|
|
1714
1721
|
const typesDir = path5.resolve(wxtDir, "types");
|
|
1715
1722
|
const outBaseDir = path5.resolve(root, mergedConfig.outDir ?? ".output");
|
|
1716
1723
|
const outDir = path5.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
@@ -1862,6 +1869,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1862
1869
|
};
|
|
1863
1870
|
}
|
|
1864
1871
|
function resolveInternalZipConfig(root, mergedConfig) {
|
|
1872
|
+
const downloadedPackagesDir = path5.resolve(root, ".wxt/local_modules");
|
|
1865
1873
|
return {
|
|
1866
1874
|
name: void 0,
|
|
1867
1875
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -1880,7 +1888,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1880
1888
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1881
1889
|
// From user
|
|
1882
1890
|
...mergedConfig.zip?.excludeSources ?? []
|
|
1883
|
-
]
|
|
1891
|
+
],
|
|
1892
|
+
downloadPackages: mergedConfig.zip?.downloadPackages ?? [],
|
|
1893
|
+
downloadedPackagesDir
|
|
1884
1894
|
};
|
|
1885
1895
|
}
|
|
1886
1896
|
async function getUnimportOptions(wxtDir, logger, config) {
|
|
@@ -1925,6 +1935,16 @@ async function resolveWxtModuleDir() {
|
|
|
1925
1935
|
const requireResolve = __require?.resolve ?? (await import("node:module")).default.createRequire(import.meta.url).resolve;
|
|
1926
1936
|
return path5.resolve(requireResolve("wxt"), "../..");
|
|
1927
1937
|
}
|
|
1938
|
+
async function isDirMissing(dir) {
|
|
1939
|
+
return !await fs9.exists(dir);
|
|
1940
|
+
}
|
|
1941
|
+
function logMissingDir(logger, name, expected) {
|
|
1942
|
+
logger.warn(
|
|
1943
|
+
`${name} directory not found: ./${normalizePath(
|
|
1944
|
+
path5.relative(process.cwd(), expected)
|
|
1945
|
+
)}`
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
1928
1948
|
|
|
1929
1949
|
// src/core/utils/building/group-entrypoints.ts
|
|
1930
1950
|
function groupEntrypoints(entrypoints) {
|
|
@@ -1968,7 +1988,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
1968
1988
|
// src/core/utils/building/import-entrypoint.ts
|
|
1969
1989
|
import createJITI from "jiti";
|
|
1970
1990
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
1971
|
-
import
|
|
1991
|
+
import fs10 from "fs-extra";
|
|
1972
1992
|
import { relative as relative5, resolve as resolve10 } from "node:path";
|
|
1973
1993
|
|
|
1974
1994
|
// src/core/utils/strings.ts
|
|
@@ -1991,16 +2011,16 @@ ${noImports}`;
|
|
|
1991
2011
|
// src/core/utils/building/import-entrypoint.ts
|
|
1992
2012
|
import { transformSync } from "esbuild";
|
|
1993
2013
|
import { fileURLToPath } from "node:url";
|
|
1994
|
-
async function importEntrypointFile(
|
|
1995
|
-
wxt.logger.debug("Loading file metadata:",
|
|
1996
|
-
const normalPath = normalizePath(
|
|
2014
|
+
async function importEntrypointFile(path8) {
|
|
2015
|
+
wxt.logger.debug("Loading file metadata:", path8);
|
|
2016
|
+
const normalPath = normalizePath(path8);
|
|
1997
2017
|
const unimport2 = createUnimport3({
|
|
1998
2018
|
...wxt.config.imports,
|
|
1999
2019
|
// Only allow specific imports, not all from the project
|
|
2000
2020
|
dirs: []
|
|
2001
2021
|
});
|
|
2002
2022
|
await unimport2.init();
|
|
2003
|
-
const text = await
|
|
2023
|
+
const text = await fs10.readFile(path8, "utf-8");
|
|
2004
2024
|
const textNoImports = removeProjectImportStatements(text);
|
|
2005
2025
|
const { code } = await unimport2.injectImports(textNoImports);
|
|
2006
2026
|
wxt.logger.debug(
|
|
@@ -2043,10 +2063,10 @@ async function importEntrypointFile(path7) {
|
|
|
2043
2063
|
}
|
|
2044
2064
|
);
|
|
2045
2065
|
try {
|
|
2046
|
-
const res = await jiti(
|
|
2066
|
+
const res = await jiti(path8);
|
|
2047
2067
|
return res.default;
|
|
2048
2068
|
} catch (err) {
|
|
2049
|
-
const filePath = relative5(wxt.config.root,
|
|
2069
|
+
const filePath = relative5(wxt.config.root, path8);
|
|
2050
2070
|
if (err instanceof ReferenceError) {
|
|
2051
2071
|
const variableName = err.message.replace(" is not defined", "");
|
|
2052
2072
|
throw Error(
|
|
@@ -2075,7 +2095,7 @@ function getEsbuildOptions(opts) {
|
|
|
2075
2095
|
|
|
2076
2096
|
// src/core/utils/building/internal-build.ts
|
|
2077
2097
|
import pc5 from "picocolors";
|
|
2078
|
-
import
|
|
2098
|
+
import fs13 from "fs-extra";
|
|
2079
2099
|
|
|
2080
2100
|
// src/core/utils/log/printBuildSummary.ts
|
|
2081
2101
|
import { resolve as resolve11 } from "path";
|
|
@@ -2083,7 +2103,7 @@ import { resolve as resolve11 } from "path";
|
|
|
2083
2103
|
// src/core/utils/log/printFileList.ts
|
|
2084
2104
|
import path6 from "node:path";
|
|
2085
2105
|
import pc3 from "picocolors";
|
|
2086
|
-
import
|
|
2106
|
+
import fs11 from "fs-extra";
|
|
2087
2107
|
import { filesize } from "filesize";
|
|
2088
2108
|
|
|
2089
2109
|
// src/core/utils/log/printTable.ts
|
|
@@ -2124,7 +2144,7 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
2124
2144
|
];
|
|
2125
2145
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
2126
2146
|
const color = getChunkColor(file);
|
|
2127
|
-
const stats = await
|
|
2147
|
+
const stats = await fs11.lstat(file);
|
|
2128
2148
|
totalSize += stats.size;
|
|
2129
2149
|
const size = String(filesize(stats.size));
|
|
2130
2150
|
return [
|
|
@@ -2192,7 +2212,7 @@ import { consola as consola2 } from "consola";
|
|
|
2192
2212
|
import glob3 from "fast-glob";
|
|
2193
2213
|
|
|
2194
2214
|
// src/core/utils/manifest.ts
|
|
2195
|
-
import
|
|
2215
|
+
import fs12 from "fs-extra";
|
|
2196
2216
|
import { resolve as resolve12 } from "path";
|
|
2197
2217
|
|
|
2198
2218
|
// src/core/utils/content-security-policy.ts
|
|
@@ -2303,7 +2323,7 @@ function mapWxtOptionsToRegisteredContentScript(options, js, css) {
|
|
|
2303
2323
|
import defu2 from "defu";
|
|
2304
2324
|
async function writeManifest(manifest, output) {
|
|
2305
2325
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
2306
|
-
await
|
|
2326
|
+
await fs12.ensureDir(wxt.config.outDir);
|
|
2307
2327
|
await writeFileIfDifferent(resolve12(wxt.config.outDir, "manifest.json"), str);
|
|
2308
2328
|
output.publicAssets.unshift({
|
|
2309
2329
|
type: "asset",
|
|
@@ -2359,11 +2379,14 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
2359
2379
|
addDevModePermissions(manifest);
|
|
2360
2380
|
wxt.config.transformManifest(manifest);
|
|
2361
2381
|
await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
|
|
2362
|
-
if (wxt.config.manifestVersion === 2)
|
|
2382
|
+
if (wxt.config.manifestVersion === 2) {
|
|
2363
2383
|
convertWebAccessibleResourcesToMv2(manifest);
|
|
2384
|
+
convertActionToMv2(manifest);
|
|
2385
|
+
}
|
|
2364
2386
|
if (wxt.config.manifestVersion === 3) {
|
|
2365
2387
|
validateMv3WebAccessbileResources(manifest);
|
|
2366
2388
|
}
|
|
2389
|
+
stripKeys(manifest);
|
|
2367
2390
|
if (manifest.name == null)
|
|
2368
2391
|
throw Error(
|
|
2369
2392
|
"Manifest 'name' is missing. Either:\n1. Set the name in your <rootDir>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
|
|
@@ -2739,6 +2762,11 @@ function convertWebAccessibleResourcesToMv2(manifest) {
|
|
|
2739
2762
|
)
|
|
2740
2763
|
);
|
|
2741
2764
|
}
|
|
2765
|
+
function convertActionToMv2(manifest) {
|
|
2766
|
+
if (manifest.action == null || manifest.browser_action != null || manifest.page_action != null)
|
|
2767
|
+
return;
|
|
2768
|
+
manifest.browser_action = manifest.action;
|
|
2769
|
+
}
|
|
2742
2770
|
function validateMv3WebAccessbileResources(manifest) {
|
|
2743
2771
|
if (manifest.web_accessible_resources == null)
|
|
2744
2772
|
return;
|
|
@@ -2753,6 +2781,46 @@ function validateMv3WebAccessbileResources(manifest) {
|
|
|
2753
2781
|
);
|
|
2754
2782
|
}
|
|
2755
2783
|
}
|
|
2784
|
+
function stripKeys(manifest) {
|
|
2785
|
+
let keysToRemove = [];
|
|
2786
|
+
if (wxt.config.manifestVersion === 2) {
|
|
2787
|
+
keysToRemove.push(...mv3OnlyKeys);
|
|
2788
|
+
if (wxt.config.browser === "firefox")
|
|
2789
|
+
keysToRemove.push(...firefoxMv3OnlyKeys);
|
|
2790
|
+
} else {
|
|
2791
|
+
keysToRemove.push(...mv2OnlyKeys);
|
|
2792
|
+
}
|
|
2793
|
+
keysToRemove.forEach((key) => {
|
|
2794
|
+
delete manifest[key];
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
var mv2OnlyKeys = [
|
|
2798
|
+
"page_action",
|
|
2799
|
+
"browser_action",
|
|
2800
|
+
"automation",
|
|
2801
|
+
"content_capabilities",
|
|
2802
|
+
"converted_from_user_script",
|
|
2803
|
+
"current_locale",
|
|
2804
|
+
"differential_fingerprint",
|
|
2805
|
+
"event_rules",
|
|
2806
|
+
"file_browser_handlers",
|
|
2807
|
+
"file_system_provider_capabilities",
|
|
2808
|
+
"input_components",
|
|
2809
|
+
"nacl_modules",
|
|
2810
|
+
"natively_connectable",
|
|
2811
|
+
"offline_enabled",
|
|
2812
|
+
"platforms",
|
|
2813
|
+
"replacement_web_app",
|
|
2814
|
+
"system_indicator",
|
|
2815
|
+
"user_scripts"
|
|
2816
|
+
];
|
|
2817
|
+
var mv3OnlyKeys = [
|
|
2818
|
+
"action",
|
|
2819
|
+
"export",
|
|
2820
|
+
"optional_host_permissions",
|
|
2821
|
+
"side_panel"
|
|
2822
|
+
];
|
|
2823
|
+
var firefoxMv3OnlyKeys = ["host_permissions"];
|
|
2756
2824
|
|
|
2757
2825
|
// src/core/utils/building/rebuild.ts
|
|
2758
2826
|
async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
@@ -2867,8 +2935,8 @@ async function internalBuild() {
|
|
|
2867
2935
|
)}`
|
|
2868
2936
|
);
|
|
2869
2937
|
const startTime = Date.now();
|
|
2870
|
-
await
|
|
2871
|
-
await
|
|
2938
|
+
await fs13.rm(wxt.config.outDir, { recursive: true, force: true });
|
|
2939
|
+
await fs13.ensureDir(wxt.config.outDir);
|
|
2872
2940
|
const entrypoints = await findEntrypoints();
|
|
2873
2941
|
wxt.logger.debug("Detected entrypoints:", entrypoints);
|
|
2874
2942
|
const validationResults = validateEntrypoints(entrypoints);
|
|
@@ -2914,7 +2982,7 @@ async function combineAnalysisStats() {
|
|
|
2914
2982
|
filename: wxt.config.analysis.outputFile
|
|
2915
2983
|
});
|
|
2916
2984
|
if (!wxt.config.analysis.keepArtifacts) {
|
|
2917
|
-
await Promise.all(absolutePaths.map((statsFile) =>
|
|
2985
|
+
await Promise.all(absolutePaths.map((statsFile) => fs13.remove(statsFile)));
|
|
2918
2986
|
}
|
|
2919
2987
|
}
|
|
2920
2988
|
function printValidationResults({
|
|
@@ -2946,10 +3014,218 @@ function printValidationResults({
|
|
|
2946
3014
|
|
|
2947
3015
|
// src/core/wxt.ts
|
|
2948
3016
|
import { createHooks } from "hookable";
|
|
3017
|
+
|
|
3018
|
+
// src/core/package-managers/index.ts
|
|
3019
|
+
import {
|
|
3020
|
+
detectPackageManager,
|
|
3021
|
+
addDependency,
|
|
3022
|
+
addDevDependency,
|
|
3023
|
+
ensureDependencyInstalled,
|
|
3024
|
+
installDependencies,
|
|
3025
|
+
removeDependency
|
|
3026
|
+
} from "nypm";
|
|
3027
|
+
|
|
3028
|
+
// src/core/package-managers/npm.ts
|
|
3029
|
+
import path7 from "node:path";
|
|
3030
|
+
import { ensureDir as ensureDir3 } from "fs-extra";
|
|
3031
|
+
var npm = {
|
|
3032
|
+
overridesKey: "overrides",
|
|
3033
|
+
async downloadDependency(id, downloadDir) {
|
|
3034
|
+
await ensureDir3(downloadDir);
|
|
3035
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
3036
|
+
const res = await execa("npm", ["pack", id, "--json"], {
|
|
3037
|
+
cwd: downloadDir
|
|
3038
|
+
});
|
|
3039
|
+
const packed = JSON.parse(res.stdout);
|
|
3040
|
+
return path7.resolve(downloadDir, packed[0].filename);
|
|
3041
|
+
},
|
|
3042
|
+
async listDependencies(options) {
|
|
3043
|
+
const args = ["ls", "--json"];
|
|
3044
|
+
if (options?.all) {
|
|
3045
|
+
args.push("--depth", "Infinity");
|
|
3046
|
+
}
|
|
3047
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
3048
|
+
const res = await execa("npm", args, { cwd: options?.cwd });
|
|
3049
|
+
const project = JSON.parse(res.stdout);
|
|
3050
|
+
return flattenNpmListOutput([project]);
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
function flattenNpmListOutput(projects) {
|
|
3054
|
+
const queue = projects.flatMap(
|
|
3055
|
+
(project) => {
|
|
3056
|
+
const acc = [];
|
|
3057
|
+
if (project.dependencies)
|
|
3058
|
+
acc.push(project.dependencies);
|
|
3059
|
+
if (project.devDependencies)
|
|
3060
|
+
acc.push(project.devDependencies);
|
|
3061
|
+
return acc;
|
|
3062
|
+
}
|
|
3063
|
+
);
|
|
3064
|
+
const dependencies = [];
|
|
3065
|
+
while (queue.length > 0) {
|
|
3066
|
+
Object.entries(queue.pop()).forEach(([name, meta]) => {
|
|
3067
|
+
dependencies.push({
|
|
3068
|
+
name,
|
|
3069
|
+
version: meta.version
|
|
3070
|
+
});
|
|
3071
|
+
if (meta.dependencies)
|
|
3072
|
+
queue.push(meta.dependencies);
|
|
3073
|
+
if (meta.devDependencies)
|
|
3074
|
+
queue.push(meta.devDependencies);
|
|
3075
|
+
});
|
|
3076
|
+
}
|
|
3077
|
+
return dedupeDependencies(dependencies);
|
|
3078
|
+
}
|
|
3079
|
+
function dedupeDependencies(dependencies) {
|
|
3080
|
+
const hashes = /* @__PURE__ */ new Set();
|
|
3081
|
+
return dependencies.filter((dep) => {
|
|
3082
|
+
const hash = `${dep.name}@${dep.version}`;
|
|
3083
|
+
if (hashes.has(hash)) {
|
|
3084
|
+
return false;
|
|
3085
|
+
} else {
|
|
3086
|
+
hashes.add(hash);
|
|
3087
|
+
return true;
|
|
3088
|
+
}
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
// src/core/package-managers/bun.ts
|
|
3093
|
+
var bun = {
|
|
3094
|
+
overridesKey: "overrides",
|
|
3095
|
+
// But also supports "resolutions"
|
|
3096
|
+
downloadDependency(...args) {
|
|
3097
|
+
return npm.downloadDependency(...args);
|
|
3098
|
+
},
|
|
3099
|
+
async listDependencies(options) {
|
|
3100
|
+
const args = ["pm", "ls"];
|
|
3101
|
+
if (options?.all) {
|
|
3102
|
+
args.push("--all");
|
|
3103
|
+
}
|
|
3104
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
3105
|
+
const res = await execa("bun", args, { cwd: options?.cwd });
|
|
3106
|
+
return dedupeDependencies(
|
|
3107
|
+
res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
|
|
3108
|
+
);
|
|
3109
|
+
}
|
|
3110
|
+
};
|
|
3111
|
+
|
|
3112
|
+
// src/core/package-managers/yarn.ts
|
|
3113
|
+
var yarn = {
|
|
3114
|
+
overridesKey: "resolutions",
|
|
3115
|
+
downloadDependency(...args) {
|
|
3116
|
+
return npm.downloadDependency(...args);
|
|
3117
|
+
},
|
|
3118
|
+
async listDependencies(options) {
|
|
3119
|
+
const args = ["list", "--json"];
|
|
3120
|
+
if (options?.all) {
|
|
3121
|
+
args.push("--depth", "Infinity");
|
|
3122
|
+
}
|
|
3123
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
3124
|
+
const res = await execa("yarn", args, { cwd: options?.cwd });
|
|
3125
|
+
const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
|
|
3126
|
+
if (tree == null)
|
|
3127
|
+
throw Error("'yarn list --json' did not output a tree");
|
|
3128
|
+
const queue = [...tree.trees];
|
|
3129
|
+
const dependencies = [];
|
|
3130
|
+
while (queue.length > 0) {
|
|
3131
|
+
const { name: treeName, children } = queue.pop();
|
|
3132
|
+
const match = /(@?\S+)@(\S+)$/.exec(treeName);
|
|
3133
|
+
if (match) {
|
|
3134
|
+
const [_, name, version2] = match;
|
|
3135
|
+
dependencies.push({ name, version: version2 });
|
|
3136
|
+
}
|
|
3137
|
+
if (children != null) {
|
|
3138
|
+
queue.push(...children);
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
return dedupeDependencies(dependencies);
|
|
3142
|
+
}
|
|
3143
|
+
};
|
|
3144
|
+
|
|
3145
|
+
// src/core/package-managers/pnpm.ts
|
|
3146
|
+
var pnpm = {
|
|
3147
|
+
overridesKey: "resolutions",
|
|
3148
|
+
// "pnpm.overrides" has a higher priority, but I don't want to deal with nesting
|
|
3149
|
+
downloadDependency(...args) {
|
|
3150
|
+
return npm.downloadDependency(...args);
|
|
3151
|
+
},
|
|
3152
|
+
async listDependencies(options) {
|
|
3153
|
+
const args = ["ls", "-r", "--json"];
|
|
3154
|
+
if (options?.all) {
|
|
3155
|
+
args.push("--depth", "Infinity");
|
|
3156
|
+
}
|
|
3157
|
+
if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
|
|
3158
|
+
args.push("--ignore-workspace");
|
|
3159
|
+
}
|
|
3160
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
3161
|
+
const res = await execa("pnpm", args, { cwd: options?.cwd });
|
|
3162
|
+
const projects = JSON.parse(res.stdout);
|
|
3163
|
+
return flattenNpmListOutput(projects);
|
|
3164
|
+
}
|
|
3165
|
+
};
|
|
3166
|
+
|
|
3167
|
+
// src/core/package-managers/index.ts
|
|
3168
|
+
async function createWxtPackageManager(root) {
|
|
3169
|
+
const pm = await detectPackageManager(root, {
|
|
3170
|
+
includeParentDirs: true
|
|
3171
|
+
});
|
|
3172
|
+
const requirePm = (cb) => {
|
|
3173
|
+
if (pm == null)
|
|
3174
|
+
throw Error("Could not detect package manager");
|
|
3175
|
+
return cb(pm);
|
|
3176
|
+
};
|
|
3177
|
+
return {
|
|
3178
|
+
get name() {
|
|
3179
|
+
return requirePm((pm2) => pm2.name);
|
|
3180
|
+
},
|
|
3181
|
+
get command() {
|
|
3182
|
+
return requirePm((pm2) => pm2.command);
|
|
3183
|
+
},
|
|
3184
|
+
get version() {
|
|
3185
|
+
return requirePm((pm2) => pm2.version);
|
|
3186
|
+
},
|
|
3187
|
+
get majorVersion() {
|
|
3188
|
+
return requirePm((pm2) => pm2.majorVersion);
|
|
3189
|
+
},
|
|
3190
|
+
get lockFile() {
|
|
3191
|
+
return requirePm((pm2) => pm2.lockFile);
|
|
3192
|
+
},
|
|
3193
|
+
get files() {
|
|
3194
|
+
return requirePm((pm2) => pm2.files);
|
|
3195
|
+
},
|
|
3196
|
+
addDependency,
|
|
3197
|
+
addDevDependency,
|
|
3198
|
+
ensureDependencyInstalled,
|
|
3199
|
+
installDependencies,
|
|
3200
|
+
removeDependency,
|
|
3201
|
+
get overridesKey() {
|
|
3202
|
+
return requirePm((pm2) => packageManagers[pm2.name].overridesKey);
|
|
3203
|
+
},
|
|
3204
|
+
downloadDependency(...args) {
|
|
3205
|
+
return requirePm(
|
|
3206
|
+
(pm2) => packageManagers[pm2.name].downloadDependency(...args)
|
|
3207
|
+
);
|
|
3208
|
+
},
|
|
3209
|
+
listDependencies(...args) {
|
|
3210
|
+
return requirePm(
|
|
3211
|
+
(pm2) => packageManagers[pm2.name].listDependencies(...args)
|
|
3212
|
+
);
|
|
3213
|
+
}
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
var packageManagers = {
|
|
3217
|
+
npm,
|
|
3218
|
+
pnpm,
|
|
3219
|
+
bun,
|
|
3220
|
+
yarn
|
|
3221
|
+
};
|
|
3222
|
+
|
|
3223
|
+
// src/core/wxt.ts
|
|
2949
3224
|
var wxt;
|
|
2950
3225
|
async function registerWxt(command, inlineConfig = {}, server) {
|
|
2951
3226
|
const config = await resolveConfig(inlineConfig, command, server);
|
|
2952
3227
|
const hooks = createHooks();
|
|
3228
|
+
const pm = await createWxtPackageManager(config.root);
|
|
2953
3229
|
wxt = {
|
|
2954
3230
|
config,
|
|
2955
3231
|
hooks,
|
|
@@ -2958,13 +3234,15 @@ async function registerWxt(command, inlineConfig = {}, server) {
|
|
|
2958
3234
|
},
|
|
2959
3235
|
async reloadConfig() {
|
|
2960
3236
|
wxt.config = await resolveConfig(inlineConfig, command, server);
|
|
2961
|
-
}
|
|
3237
|
+
},
|
|
3238
|
+
pm
|
|
2962
3239
|
};
|
|
2963
3240
|
wxt.hooks.addHooks(config.hooks);
|
|
2964
3241
|
await wxt.hooks.callHook("ready", wxt);
|
|
2965
3242
|
}
|
|
2966
3243
|
|
|
2967
3244
|
export {
|
|
3245
|
+
normalizePath,
|
|
2968
3246
|
unnormalizePath,
|
|
2969
3247
|
wxt,
|
|
2970
3248
|
registerWxt,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined")
|
|
11
|
+
return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
__require,
|
|
36
|
+
__commonJS,
|
|
37
|
+
__toESM
|
|
38
|
+
};
|
package/dist/cli.d.ts
ADDED