wxt 0.21.2 → 0.21.4
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/builtin-modules/escape-unicode.mjs +34 -0
- package/dist/builtin-modules/index.mjs +6 -1
- package/dist/builtin-modules/unimport.mjs +3 -3
- package/dist/cli/cli-utils.mjs +5 -2
- package/dist/core/builders/vite/index.mjs +8 -1
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +2 -2
- package/dist/core/initialize.d.mts +3 -3
- package/dist/core/initialize.mjs +33 -47
- package/dist/core/keyboard-shortcuts.mjs +1 -0
- package/dist/core/package-managers/bun.mjs +5 -2
- package/dist/core/package-managers/npm.mjs +10 -4
- package/dist/core/package-managers/pnpm.mjs +5 -2
- package/dist/core/package-managers/yarn.mjs +5 -2
- package/dist/core/resolve-config.mjs +17 -20
- package/dist/core/utils/building/find-entrypoints.mjs +3 -3
- package/dist/core/utils/building/internal-build.mjs +3 -3
- package/dist/core/utils/building/rebuild.mjs +1 -1
- package/dist/core/utils/create-file-reloader.mjs +3 -3
- package/dist/core/utils/env.mjs +5 -1
- package/dist/core/utils/fs.mjs +6 -1
- package/dist/core/utils/log/index.mjs +1 -0
- package/dist/core/utils/log/printFileList.mjs +3 -3
- package/dist/core/utils/log/wxtLogger.mjs +32 -0
- package/dist/core/utils/manifest.mjs +6 -6
- package/dist/core/utils/paths.mjs +2 -2
- package/dist/core/utils/spinner.mjs +69 -0
- package/dist/core/utils/strings.mjs +2 -2
- package/dist/core/zip.mjs +6 -13
- package/dist/index.d.mts +2 -2
- package/dist/inline/get-port-please/index.mjs +196 -0
- package/dist/inline/is-wsl/index.mjs +44 -0
- package/dist/inline/normalize-path/index.mjs +23 -0
- package/dist/inline/ohash/index.mjs +113 -0
- package/dist/inline/scule/index.mjs +50 -0
- package/dist/types.d.mts +49 -34
- package/dist/utils/content-script-ui/iframe.d.mts +2 -0
- package/dist/utils/content-script-ui/iframe.mjs +2 -0
- package/dist/utils/content-script-ui/integrated.d.mts +2 -0
- package/dist/utils/content-script-ui/integrated.mjs +2 -0
- package/dist/utils/content-script-ui/shadow-root.d.mts +2 -0
- package/dist/utils/content-script-ui/shadow-root.mjs +2 -0
- package/dist/version.mjs +1 -1
- package/package.json +16 -19
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/core/utils/log/wxtLogger.ts
|
|
2
|
+
const warned = /* @__PURE__ */ new Set();
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a `Logger` with a `warnOnce`. The set of already-warned messages is
|
|
5
|
+
* scoped to this wrapper instance, so it's reset whenever a new wrapper is
|
|
6
|
+
* created, e.g. once per `resolveConfig` call.
|
|
7
|
+
*/
|
|
8
|
+
function createWxtLogger(logger) {
|
|
9
|
+
return {
|
|
10
|
+
get level() {
|
|
11
|
+
return logger.level;
|
|
12
|
+
},
|
|
13
|
+
set level(value) {
|
|
14
|
+
logger.level = value;
|
|
15
|
+
},
|
|
16
|
+
debug: logger.debug,
|
|
17
|
+
log: logger.log.bind(logger),
|
|
18
|
+
info: logger.info.bind(logger),
|
|
19
|
+
warn: logger.warn.bind(logger),
|
|
20
|
+
error: logger.error.bind(logger),
|
|
21
|
+
fatal: logger.fatal.bind(logger),
|
|
22
|
+
success: logger.success.bind(logger),
|
|
23
|
+
warnOnce: (...args) => {
|
|
24
|
+
const key = JSON.stringify(args);
|
|
25
|
+
if (warned.has(key)) return;
|
|
26
|
+
warned.add(key);
|
|
27
|
+
logger.warn(...args);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createWxtLogger };
|
|
@@ -28,7 +28,7 @@ async function generateManifest(allEntrypoints, buildOutput) {
|
|
|
28
28
|
let versionName = wxt.config.manifest.version_name ?? wxt.config.manifest.version ?? pkg?.version;
|
|
29
29
|
if (versionName == null) {
|
|
30
30
|
versionName = "0.0.0";
|
|
31
|
-
wxt.logger.
|
|
31
|
+
wxt.logger.warnOnce("Extension version not found, defaulting to \"0.0.0\". Add a version to your `package.json` or `wxt.config.ts` file. For more details, see: https://wxt.dev/guide/key-concepts/manifest.html#version-and-version-name");
|
|
32
32
|
}
|
|
33
33
|
const version = wxt.config.manifest.version ?? simplifyVersion(versionName);
|
|
34
34
|
const baseManifest = {
|
|
@@ -42,7 +42,7 @@ async function generateManifest(allEntrypoints, buildOutput) {
|
|
|
42
42
|
const userManifest = wxt.config.manifest;
|
|
43
43
|
if (userManifest.manifest_version) {
|
|
44
44
|
delete userManifest.manifest_version;
|
|
45
|
-
wxt.logger.
|
|
45
|
+
wxt.logger.warnOnce("`manifest.manifest_version` config was set, but ignored. To change the target manifest version, use the `manifestVersion` option or the `--mv2`/`--mv3` CLI flags.\nSee https://wxt.dev/guide/essentials/target-different-browsers.html#target-a-manifest-version");
|
|
46
46
|
}
|
|
47
47
|
let manifest = defu(userManifest, baseManifest);
|
|
48
48
|
if (wxt.config.command === "serve" && wxt.config.dev.reloadCommand) if (manifest.commands && Object.values(manifest.commands).filter((command) => command.suggested_key).length >= 4) warnings.push(["Extension already has 4 registered commands with suggested keys, WXT's reload command is disabled"]);
|
|
@@ -55,8 +55,8 @@ async function generateManifest(allEntrypoints, buildOutput) {
|
|
|
55
55
|
}
|
|
56
56
|
manifest.version = version;
|
|
57
57
|
manifest.version_name = wxt.config.browser === "firefox" || versionName === version ? void 0 : versionName;
|
|
58
|
-
if (wxt.config.browser === "firefox" && !userManifest.browser_specific_settings?.gecko?.data_collection_permissions && !wxt.config.suppressWarnings?.firefoxDataCollection) wxt.logger.
|
|
59
|
-
if (wxt.config.browser === "firefox" && !manifest.browser_specific_settings?.gecko?.id && !wxt.config.suppressWarnings?.firefoxId) wxt.logger.
|
|
58
|
+
if (wxt.config.browser === "firefox" && !userManifest.browser_specific_settings?.gecko?.data_collection_permissions && !wxt.config.suppressWarnings?.firefoxDataCollection) wxt.logger.warnOnce("Firefox requires `data_collection_permissions` for new extensions from November 3, 2025. Existing extensions are exempt for now.\nFor more details, see: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/\nTo suppress this warning, set `suppressWarnings.firefoxDataCollection` to `true` in your wxt config.\n");
|
|
59
|
+
if (wxt.config.browser === "firefox" && !manifest.browser_specific_settings?.gecko?.id && !wxt.config.suppressWarnings?.firefoxId) wxt.logger.warnOnce("Firefox requires extension ID for MV3 and recommends it for MV2.\nFor more details, see: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#id");
|
|
60
60
|
addEntrypoints(manifest, entrypoints, buildOutput);
|
|
61
61
|
if (wxt.config.browser === "firefox") addDiscoveredThemeIcons(manifest, buildOutput);
|
|
62
62
|
if (wxt.config.command === "serve") addDevModeCsp(manifest);
|
|
@@ -190,7 +190,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
|
|
|
190
190
|
return map;
|
|
191
191
|
}, /* @__PURE__ */ new Map());
|
|
192
192
|
const manifestContentScripts = Array.from(hashToEntrypointsMap.values()).map((scripts) => mapWxtOptionsToContentScript(scripts[0].options, scripts.map((entry) => getEntrypointBundlePath(entry, wxt.config.outDir, ".js")), getContentScriptCssFiles(scripts, cssMap)));
|
|
193
|
-
if (manifestContentScripts.length
|
|
193
|
+
if (manifestContentScripts.length > 0) {
|
|
194
194
|
manifest.content_scripts ??= [];
|
|
195
195
|
manifest.content_scripts.push(...manifestContentScripts);
|
|
196
196
|
}
|
|
@@ -284,7 +284,7 @@ function getContentScriptCssWebAccessibleResources(contentScripts, contentScript
|
|
|
284
284
|
if (cssFile == null) return;
|
|
285
285
|
resources.push({
|
|
286
286
|
resources: [cssFile],
|
|
287
|
-
use_dynamic_url: true,
|
|
287
|
+
...wxt.config.browser !== "firefox" && wxt.config.browser !== "safari" ? { use_dynamic_url: true } : {},
|
|
288
288
|
matches: script.options.matches?.map((matchPattern) => stripPathFromMatchPattern(matchPattern)) ?? []
|
|
289
289
|
});
|
|
290
290
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import normalize_path_default from "../../inline/normalize-path/index.mjs";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import normalize from "normalize-path";
|
|
3
3
|
//#region src/core/utils/paths.ts
|
|
4
4
|
/**
|
|
5
5
|
* Converts system paths to normalized bundler path. On Windows, this returns
|
|
6
6
|
* paths with `/` instead of `\`.
|
|
7
7
|
*/
|
|
8
8
|
function normalizePath(path) {
|
|
9
|
-
return
|
|
9
|
+
return normalize_path_default(path);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Given a normalized path, convert it to the system path style. On Windows,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
//#region src/core/utils/spinner.ts
|
|
3
|
+
function createSpinner(initialText = "", options = {}) {
|
|
4
|
+
const { color = "cyan" } = options;
|
|
5
|
+
const frames = [
|
|
6
|
+
"⠋",
|
|
7
|
+
"⠙",
|
|
8
|
+
"⠹",
|
|
9
|
+
"⠸",
|
|
10
|
+
"⠼",
|
|
11
|
+
"⠴",
|
|
12
|
+
"⠦",
|
|
13
|
+
"⠧",
|
|
14
|
+
"⠇",
|
|
15
|
+
"⠏"
|
|
16
|
+
];
|
|
17
|
+
const FRAME_INTERVAL = 80;
|
|
18
|
+
let frameIndex = 0;
|
|
19
|
+
let timer = null;
|
|
20
|
+
let text = initialText;
|
|
21
|
+
function render() {
|
|
22
|
+
const frame = frames[frameIndex % frames.length];
|
|
23
|
+
const coloredFrame = color ? styleText(color, frame) : frame;
|
|
24
|
+
process.stdout.write(`\r${coloredFrame} ${text}\x1B[K`);
|
|
25
|
+
}
|
|
26
|
+
const spinner = {
|
|
27
|
+
start(startText) {
|
|
28
|
+
if (startText !== void 0) text = startText;
|
|
29
|
+
if (timer) return spinner;
|
|
30
|
+
process.stdout.write("\x1B[?25l");
|
|
31
|
+
render();
|
|
32
|
+
timer = setInterval(() => {
|
|
33
|
+
frameIndex++;
|
|
34
|
+
render();
|
|
35
|
+
}, FRAME_INTERVAL);
|
|
36
|
+
return spinner;
|
|
37
|
+
},
|
|
38
|
+
update(opts = {}) {
|
|
39
|
+
text = typeof opts === "string" ? opts : opts.text ?? text;
|
|
40
|
+
if (timer) render();
|
|
41
|
+
return spinner;
|
|
42
|
+
},
|
|
43
|
+
clear() {
|
|
44
|
+
if (timer) {
|
|
45
|
+
clearInterval(timer);
|
|
46
|
+
timer = null;
|
|
47
|
+
}
|
|
48
|
+
process.stdout.write("\r\x1B[K");
|
|
49
|
+
process.stdout.write("\x1B[?25h");
|
|
50
|
+
return spinner;
|
|
51
|
+
},
|
|
52
|
+
stop(finalText = "") {
|
|
53
|
+
spinner.clear();
|
|
54
|
+
if (finalText) process.stdout.write(finalText + "\n");
|
|
55
|
+
return spinner;
|
|
56
|
+
},
|
|
57
|
+
success(finalText) {
|
|
58
|
+
const message = finalText ?? text;
|
|
59
|
+
return spinner.stop(`${styleText("green", "✔")} ${message}`);
|
|
60
|
+
},
|
|
61
|
+
error(finalText) {
|
|
62
|
+
const message = finalText ?? text;
|
|
63
|
+
return spinner.stop(`${styleText("red", "✖")} ${message}`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return spinner;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { createSpinner };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s } from "../../inline/scule/index.mjs";
|
|
2
2
|
//#region src/core/utils/strings.ts
|
|
3
3
|
function kebabCaseAlphanumeric(str) {
|
|
4
4
|
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
5
5
|
}
|
|
6
6
|
/** Return a safe variable name for a given string. */
|
|
7
7
|
function safeVarName(str) {
|
|
8
|
-
const name =
|
|
8
|
+
const name = s(kebabCaseAlphanumeric(str));
|
|
9
9
|
if (name.match(/^[a-z]/)) return name;
|
|
10
10
|
return "_" + name;
|
|
11
11
|
}
|
package/dist/core/zip.mjs
CHANGED
|
@@ -9,11 +9,10 @@ import "./utils/log/index.mjs";
|
|
|
9
9
|
import { getPackageJson } from "./utils/package.mjs";
|
|
10
10
|
import { internalBuild } from "./utils/building/internal-build.mjs";
|
|
11
11
|
import "./utils/building/index.mjs";
|
|
12
|
-
import { mkdir, readFile } from "node:fs/promises";
|
|
12
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
13
13
|
import { glob } from "tinyglobby";
|
|
14
14
|
import path from "node:path";
|
|
15
|
-
import {
|
|
16
|
-
import JSZip from "jszip";
|
|
15
|
+
import { createZip } from "@aklinker1/zero-zip";
|
|
17
16
|
//#region src/core/zip.ts
|
|
18
17
|
/**
|
|
19
18
|
* Build and zip the extension for distribution.
|
|
@@ -67,7 +66,7 @@ async function zip(config) {
|
|
|
67
66
|
return zipFiles;
|
|
68
67
|
}
|
|
69
68
|
async function zipDir(directory, outputPath, options) {
|
|
70
|
-
const archive =
|
|
69
|
+
const archive = createZip({ level: wxt.config.zip.compressionLevel });
|
|
71
70
|
const filesToZip = [...await glob(options?.include ?? ["**/*"], {
|
|
72
71
|
cwd: directory,
|
|
73
72
|
ignore: options?.exclude ?? [],
|
|
@@ -78,20 +77,14 @@ async function zipDir(directory, outputPath, options) {
|
|
|
78
77
|
const absolutePath = path.resolve(directory, file);
|
|
79
78
|
if (file.endsWith(".json")) {
|
|
80
79
|
const content = await readFile(absolutePath, "utf-8");
|
|
81
|
-
archive.
|
|
80
|
+
archive.addFile(file, await options?.transform?.(absolutePath, file, content) || content);
|
|
82
81
|
} else {
|
|
83
82
|
const content = await readFile(absolutePath);
|
|
84
|
-
archive.
|
|
83
|
+
archive.addFile(file, content);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
await options?.additionalWork?.(archive);
|
|
88
|
-
await
|
|
89
|
-
type: "nodebuffer",
|
|
90
|
-
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
91
|
-
compression: "DEFLATE",
|
|
92
|
-
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
93
|
-
}
|
|
94
|
-
}).pipe(createWriteStream(outputPath)).on("error", reject).on("close", resolve));
|
|
87
|
+
await writeFile(outputPath, await archive.toBuffer());
|
|
95
88
|
return filesToZip;
|
|
96
89
|
}
|
|
97
90
|
async function downloadPrivatePackages() {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PrepareTsconfigs, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig } from "./types.mjs";
|
|
1
|
+
import { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintConfigVersion, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PrepareTsconfigs, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtLogger, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig } from "./types.mjs";
|
|
2
2
|
import { build } from "./core/build.mjs";
|
|
3
3
|
import { clean } from "./core/clean.mjs";
|
|
4
4
|
import { defineConfig } from "./core/define-config.mjs";
|
|
@@ -10,4 +10,4 @@ import { zip } from "./core/zip.mjs";
|
|
|
10
10
|
import { normalizePath } from "./core/utils/paths.mjs";
|
|
11
11
|
import { getEntrypointBundlePath } from "./core/utils/entrypoints.mjs";
|
|
12
12
|
import { version } from "./version.mjs";
|
|
13
|
-
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PrepareTsconfigs, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig, build, clean, createServer, defineConfig, defineWebExtConfig, getEntrypointBundlePath, initialize, normalizePath, prepare, version, zip };
|
|
13
|
+
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintConfigVersion, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PrepareTsconfigs, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtLogger, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig, build, clean, createServer, defineConfig, defineWebExtConfig, getEntrypointBundlePath, initialize, normalizePath, prepare, version, zip };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import "node:fs/promises";
|
|
2
|
+
import "node:path";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { networkInterfaces } from "node:os";
|
|
5
|
+
//#region inline/get-port-please/index.mjs
|
|
6
|
+
const o = new Set([
|
|
7
|
+
1,
|
|
8
|
+
7,
|
|
9
|
+
9,
|
|
10
|
+
11,
|
|
11
|
+
13,
|
|
12
|
+
15,
|
|
13
|
+
17,
|
|
14
|
+
19,
|
|
15
|
+
20,
|
|
16
|
+
21,
|
|
17
|
+
22,
|
|
18
|
+
23,
|
|
19
|
+
25,
|
|
20
|
+
37,
|
|
21
|
+
42,
|
|
22
|
+
43,
|
|
23
|
+
53,
|
|
24
|
+
69,
|
|
25
|
+
77,
|
|
26
|
+
79,
|
|
27
|
+
87,
|
|
28
|
+
95,
|
|
29
|
+
101,
|
|
30
|
+
102,
|
|
31
|
+
103,
|
|
32
|
+
104,
|
|
33
|
+
109,
|
|
34
|
+
110,
|
|
35
|
+
111,
|
|
36
|
+
113,
|
|
37
|
+
115,
|
|
38
|
+
117,
|
|
39
|
+
119,
|
|
40
|
+
123,
|
|
41
|
+
135,
|
|
42
|
+
137,
|
|
43
|
+
139,
|
|
44
|
+
143,
|
|
45
|
+
161,
|
|
46
|
+
179,
|
|
47
|
+
389,
|
|
48
|
+
427,
|
|
49
|
+
465,
|
|
50
|
+
512,
|
|
51
|
+
513,
|
|
52
|
+
514,
|
|
53
|
+
515,
|
|
54
|
+
526,
|
|
55
|
+
530,
|
|
56
|
+
531,
|
|
57
|
+
532,
|
|
58
|
+
540,
|
|
59
|
+
548,
|
|
60
|
+
554,
|
|
61
|
+
556,
|
|
62
|
+
563,
|
|
63
|
+
587,
|
|
64
|
+
601,
|
|
65
|
+
636,
|
|
66
|
+
989,
|
|
67
|
+
990,
|
|
68
|
+
993,
|
|
69
|
+
995,
|
|
70
|
+
1719,
|
|
71
|
+
1720,
|
|
72
|
+
1723,
|
|
73
|
+
2049,
|
|
74
|
+
3659,
|
|
75
|
+
4045,
|
|
76
|
+
5060,
|
|
77
|
+
5061,
|
|
78
|
+
6e3,
|
|
79
|
+
6566,
|
|
80
|
+
6665,
|
|
81
|
+
6666,
|
|
82
|
+
6667,
|
|
83
|
+
6668,
|
|
84
|
+
6669,
|
|
85
|
+
6697,
|
|
86
|
+
10080
|
|
87
|
+
]);
|
|
88
|
+
function s(e) {
|
|
89
|
+
return o.has(e);
|
|
90
|
+
}
|
|
91
|
+
function c(e) {
|
|
92
|
+
return !s(e);
|
|
93
|
+
}
|
|
94
|
+
var l = class extends Error {
|
|
95
|
+
constructor(e, t) {
|
|
96
|
+
super(e, t), this.message = e;
|
|
97
|
+
}
|
|
98
|
+
name = `GetPortError`;
|
|
99
|
+
};
|
|
100
|
+
function u(e, t) {
|
|
101
|
+
e && console.log(`[get-port] ${t}`);
|
|
102
|
+
}
|
|
103
|
+
function d(e, t) {
|
|
104
|
+
if (t < e) return [];
|
|
105
|
+
let n = [];
|
|
106
|
+
for (let r = e; r <= t; r++) n.push(r);
|
|
107
|
+
return n;
|
|
108
|
+
}
|
|
109
|
+
function f(e, n) {
|
|
110
|
+
return new Promise((r) => {
|
|
111
|
+
let i = createServer();
|
|
112
|
+
i.unref(), i.on(`error`, () => {
|
|
113
|
+
r(!1);
|
|
114
|
+
}), i.listen({
|
|
115
|
+
port: e,
|
|
116
|
+
host: n
|
|
117
|
+
}, () => {
|
|
118
|
+
let { port: e } = i.address();
|
|
119
|
+
i.close(() => {
|
|
120
|
+
r(c(e) && e);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function p(e) {
|
|
126
|
+
let t = new Set(e);
|
|
127
|
+
for (let e of Object.values(networkInterfaces())) for (let n of e || []) n.address && !n.internal && !n.address.startsWith(`fe80::`) && !n.address.startsWith(`169.254`) && t.add(n.address);
|
|
128
|
+
return [...t];
|
|
129
|
+
}
|
|
130
|
+
async function m(e, t) {
|
|
131
|
+
for (let n of e) {
|
|
132
|
+
let e = await f(n, t);
|
|
133
|
+
if (e) return e;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function h(e) {
|
|
137
|
+
return e ? `on host ${JSON.stringify(e)}` : `on any host`;
|
|
138
|
+
}
|
|
139
|
+
const g = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
|
|
140
|
+
function _(e, t, n) {
|
|
141
|
+
if (e && !g.test(e)) {
|
|
142
|
+
let r = t ? `0.0.0.0` : `127.0.0.1`;
|
|
143
|
+
return u(n, `Invalid hostname: ${JSON.stringify(e)}. Using ${JSON.stringify(r)} as fallback.`), r;
|
|
144
|
+
}
|
|
145
|
+
return e;
|
|
146
|
+
}
|
|
147
|
+
async function v(e = {}) {
|
|
148
|
+
(typeof e == `number` || typeof e == `string`) && (e = { port: Number.parseInt(e + ``) || 0 });
|
|
149
|
+
let t = Number(e.port ?? process.env.PORT), n = !!(e.port || e.ports?.length || e.portRange?.length), r = {
|
|
150
|
+
random: t === 0,
|
|
151
|
+
ports: [],
|
|
152
|
+
portRange: [],
|
|
153
|
+
alternativePortRange: n ? [] : [3e3, 3100],
|
|
154
|
+
verbose: !1,
|
|
155
|
+
...e,
|
|
156
|
+
port: t,
|
|
157
|
+
host: _(e.host ?? process.env.HOST, e.public, e.verbose)
|
|
158
|
+
};
|
|
159
|
+
if (r.random && !n) return y(r.host);
|
|
160
|
+
let i = [
|
|
161
|
+
r.port,
|
|
162
|
+
...r.ports,
|
|
163
|
+
...d(...r.portRange)
|
|
164
|
+
].filter((e) => e ? c(e) ? !0 : (u(r.verbose, `Ignoring unsafe port: ${e}`), !1) : !1);
|
|
165
|
+
i.length === 0 && i.push(3e3);
|
|
166
|
+
let a = await m(i, r.host);
|
|
167
|
+
if (!a && r.alternativePortRange.length > 0 && (a = await m(d(...r.alternativePortRange), r.host), i.length > 0)) {
|
|
168
|
+
let e = `Unable to find an available port (tried ${i.join(`-`)} ${h(r.host)}).`;
|
|
169
|
+
a && (e += ` Using alternative port ${a}.`), u(r.verbose, e);
|
|
170
|
+
}
|
|
171
|
+
if (!a && e.random !== !1 && (a = await y(r.host), a && u(r.verbose, `Using random port ${a}`)), !a) {
|
|
172
|
+
let e = [
|
|
173
|
+
r.port,
|
|
174
|
+
r.portRange.join(`-`),
|
|
175
|
+
r.alternativePortRange.join(`-`)
|
|
176
|
+
].filter(Boolean).join(`, `);
|
|
177
|
+
throw new l(`Unable to find an available port ${h(r.host)} (tried ${e})`);
|
|
178
|
+
}
|
|
179
|
+
return a;
|
|
180
|
+
}
|
|
181
|
+
async function y(e) {
|
|
182
|
+
let t = await x(0, e);
|
|
183
|
+
if (t === !1) throw new l(`Unable to find a random port ${h(e)}`);
|
|
184
|
+
return t;
|
|
185
|
+
}
|
|
186
|
+
async function x(e, t = process.env.HOST, n) {
|
|
187
|
+
if (t ||= p([void 0, `0.0.0.0`]), !Array.isArray(t)) return f(e, t);
|
|
188
|
+
for (let r of t) {
|
|
189
|
+
let t = await f(e, r);
|
|
190
|
+
if (t === !1) return e < 1024 && n && u(n, `Unable to listen to the privileged port ${e} ${h(r)}`), !1;
|
|
191
|
+
e === 0 && t !== 0 && (e = t);
|
|
192
|
+
}
|
|
193
|
+
return e;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
export { v };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import n from "node:fs";
|
|
2
|
+
import t from "node:os";
|
|
3
|
+
import e from "node:process";
|
|
4
|
+
//#region inline/is-wsl/index.mjs
|
|
5
|
+
let r;
|
|
6
|
+
function i() {
|
|
7
|
+
try {
|
|
8
|
+
return n.statSync(`/.dockerenv`), !0;
|
|
9
|
+
} catch {
|
|
10
|
+
return !1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function a() {
|
|
14
|
+
try {
|
|
15
|
+
return n.readFileSync(`/proc/self/cgroup`, `utf8`).includes(`docker`);
|
|
16
|
+
} catch {
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function o() {
|
|
21
|
+
return r === void 0 && (r = i() || a()), r;
|
|
22
|
+
}
|
|
23
|
+
let s;
|
|
24
|
+
const c = () => {
|
|
25
|
+
try {
|
|
26
|
+
return n.statSync(`/run/.containerenv`), !0;
|
|
27
|
+
} catch {
|
|
28
|
+
return !1;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function l() {
|
|
32
|
+
return s === void 0 && (s = c() || o()), s;
|
|
33
|
+
}
|
|
34
|
+
const u = () => {
|
|
35
|
+
if (e.platform !== `linux`) return !1;
|
|
36
|
+
if (t.release().toLowerCase().includes(`microsoft`)) return !l();
|
|
37
|
+
try {
|
|
38
|
+
if (n.readFileSync(`/proc/version`, `utf8`).toLowerCase().includes(`microsoft`)) return !l();
|
|
39
|
+
} catch {}
|
|
40
|
+
return n.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`) || n.existsSync(`/run/WSL`) ? !l() : !1;
|
|
41
|
+
};
|
|
42
|
+
var d = e.env.__IS_WSL_TEST__ ? u : u();
|
|
43
|
+
//#endregion
|
|
44
|
+
export { d };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var normalize_path_default = ((e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports))(((e, t) => {
|
|
2
|
+
/*!
|
|
3
|
+
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
t.exports = function(e, t) {
|
|
9
|
+
if (typeof e != `string`) throw TypeError(`expected path to be a string`);
|
|
10
|
+
if (e === `\\` || e === `/`) return `/`;
|
|
11
|
+
var n = e.length;
|
|
12
|
+
if (n <= 1) return e;
|
|
13
|
+
var r = ``;
|
|
14
|
+
if (n > 4 && e[3] === `\\`) {
|
|
15
|
+
var i = e[2];
|
|
16
|
+
(i === `?` || i === `.`) && e.slice(0, 2) === `\\\\` && (e = e.slice(2), r = `//`);
|
|
17
|
+
}
|
|
18
|
+
var a = e.split(/[/\\]+/);
|
|
19
|
+
return t !== !1 && a[a.length - 1] === `` && a.pop(), r + a.join(`/`);
|
|
20
|
+
};
|
|
21
|
+
}))();
|
|
22
|
+
//#endregion
|
|
23
|
+
export { normalize_path_default as default };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
//#region inline/ohash/index.mjs
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e == `string` ? `'${e}'` : new n().serialize(e);
|
|
5
|
+
}
|
|
6
|
+
const n = function() {
|
|
7
|
+
class e {
|
|
8
|
+
#e = /* @__PURE__ */ new Map();
|
|
9
|
+
compare(e, t) {
|
|
10
|
+
let n = typeof e, r = typeof t;
|
|
11
|
+
return n === `string` && r === `string` ? e.localeCompare(t) : n === `number` && r === `number` ? e - t : String.prototype.localeCompare.call(this.serialize(e, !0), this.serialize(t, !0));
|
|
12
|
+
}
|
|
13
|
+
serialize(e, t) {
|
|
14
|
+
if (e === null) return `null`;
|
|
15
|
+
switch (typeof e) {
|
|
16
|
+
case `string`: return t ? e : `'${e}'`;
|
|
17
|
+
case `bigint`: return `${e}n`;
|
|
18
|
+
case `object`: return this.$object(e);
|
|
19
|
+
case `function`: return this.$function(e);
|
|
20
|
+
}
|
|
21
|
+
return String(e);
|
|
22
|
+
}
|
|
23
|
+
serializeObject(e) {
|
|
24
|
+
let t = Object.prototype.toString.call(e);
|
|
25
|
+
if (t !== `[object Object]`) return this.serializeBuiltInType(t.length < 10 ? `unknown:${t}` : t.slice(8, -1), e);
|
|
26
|
+
let n = e.constructor, r = n === Object || n === void 0 ? `` : n.name;
|
|
27
|
+
if (r !== `` && globalThis[r] === n) return this.serializeBuiltInType(r, e);
|
|
28
|
+
if (typeof e.toJSON == `function`) {
|
|
29
|
+
let t = e.toJSON();
|
|
30
|
+
return r + (typeof t == `object` && t ? this.$object(t) : `(${this.serialize(t)})`);
|
|
31
|
+
}
|
|
32
|
+
return this.serializeObjectEntries(r, Object.entries(e));
|
|
33
|
+
}
|
|
34
|
+
serializeBuiltInType(e, t) {
|
|
35
|
+
let n = this[`$` + e];
|
|
36
|
+
if (n) return n.call(this, t);
|
|
37
|
+
if (typeof t?.entries == `function`) return this.serializeObjectEntries(e, t.entries());
|
|
38
|
+
throw Error(`Cannot serialize ${e}`);
|
|
39
|
+
}
|
|
40
|
+
serializeObjectEntries(e, t) {
|
|
41
|
+
let n = Array.from(t).sort((e, t) => this.compare(e[0], t[0])), r = `${e}{`;
|
|
42
|
+
for (let e = 0; e < n.length; e++) {
|
|
43
|
+
let [t, i] = n[e];
|
|
44
|
+
r += `${this.serialize(t, !0)}:${this.serialize(i)}`, e < n.length - 1 && (r += `,`);
|
|
45
|
+
}
|
|
46
|
+
return r + `}`;
|
|
47
|
+
}
|
|
48
|
+
$object(e) {
|
|
49
|
+
let t = this.#e.get(e);
|
|
50
|
+
return t === void 0 && (this.#e.set(e, `#${this.#e.size}`), t = this.serializeObject(e), this.#e.set(e, t)), t;
|
|
51
|
+
}
|
|
52
|
+
$function(e) {
|
|
53
|
+
let t = Function.prototype.toString.call(e);
|
|
54
|
+
return t.slice(-15) === `[native code] }` ? `${e.name || ``}()[native]` : `${e.name}(${e.length})${t.replace(/\s*\n\s*/g, ``)}`;
|
|
55
|
+
}
|
|
56
|
+
$Array(e) {
|
|
57
|
+
let t = `[`;
|
|
58
|
+
for (let n = 0; n < e.length; n++) t += this.serialize(e[n]), n < e.length - 1 && (t += `,`);
|
|
59
|
+
return t + `]`;
|
|
60
|
+
}
|
|
61
|
+
$Date(e) {
|
|
62
|
+
try {
|
|
63
|
+
return `Date(${e.toISOString()})`;
|
|
64
|
+
} catch {
|
|
65
|
+
return `Date(null)`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
$ArrayBuffer(e) {
|
|
69
|
+
return `ArrayBuffer[${new Uint8Array(e).join(`,`)}]`;
|
|
70
|
+
}
|
|
71
|
+
$Set(e) {
|
|
72
|
+
return `Set${this.$Array(Array.from(e).sort((e, t) => this.compare(e, t)))}`;
|
|
73
|
+
}
|
|
74
|
+
$Map(e) {
|
|
75
|
+
return this.serializeObjectEntries(`Map`, e.entries());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (let t of [
|
|
79
|
+
`Error`,
|
|
80
|
+
`RegExp`,
|
|
81
|
+
`URL`
|
|
82
|
+
]) e.prototype[`$` + t] = function(e) {
|
|
83
|
+
return `${t}(${e})`;
|
|
84
|
+
};
|
|
85
|
+
for (let t of [
|
|
86
|
+
`Int8Array`,
|
|
87
|
+
`Uint8Array`,
|
|
88
|
+
`Uint8ClampedArray`,
|
|
89
|
+
`Int16Array`,
|
|
90
|
+
`Uint16Array`,
|
|
91
|
+
`Int32Array`,
|
|
92
|
+
`Uint32Array`,
|
|
93
|
+
`Float32Array`,
|
|
94
|
+
`Float64Array`
|
|
95
|
+
]) e.prototype[`$` + t] = function(e) {
|
|
96
|
+
return `${t}[${e.join(`,`)}]`;
|
|
97
|
+
};
|
|
98
|
+
for (let t of [`BigInt64Array`, `BigUint64Array`]) e.prototype[`$` + t] = function(e) {
|
|
99
|
+
return `${t}[${e.join(`n,`)}${e.length > 0 ? `n` : ``}]`;
|
|
100
|
+
};
|
|
101
|
+
return e;
|
|
102
|
+
}();
|
|
103
|
+
const i = globalThis.process?.getBuiltinModule?.(`crypto`)?.hash, a = `sha256`, o = `base64url`;
|
|
104
|
+
function s(t) {
|
|
105
|
+
if (i) return i(a, t, o);
|
|
106
|
+
let n = createHash(a).update(t);
|
|
107
|
+
return globalThis.process?.versions?.webcontainer ? n.digest().toString(o) : n.digest(o);
|
|
108
|
+
}
|
|
109
|
+
function c(e) {
|
|
110
|
+
return s(t(e));
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { c };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region inline/scule/index.mjs
|
|
2
|
+
const e = /\d/, t = [
|
|
3
|
+
`-`,
|
|
4
|
+
`_`,
|
|
5
|
+
`/`,
|
|
6
|
+
`.`
|
|
7
|
+
];
|
|
8
|
+
function n(t = ``) {
|
|
9
|
+
if (!e.test(t)) return t !== t.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function r(e, r) {
|
|
12
|
+
let i = r ?? t, a = [];
|
|
13
|
+
if (!e || typeof e != `string`) return a;
|
|
14
|
+
let o = ``, s, c;
|
|
15
|
+
for (let t of e) {
|
|
16
|
+
let e = i.includes(t);
|
|
17
|
+
if (e === !0) {
|
|
18
|
+
a.push(o), o = ``, s = void 0;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
let r = n(t);
|
|
22
|
+
if (c === !1) {
|
|
23
|
+
if (s === !1 && r === !0) {
|
|
24
|
+
a.push(o), o = t, s = r;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (s === !0 && r === !1 && o.length > 1) {
|
|
28
|
+
let e = o.at(-1);
|
|
29
|
+
a.push(o.slice(0, Math.max(0, o.length - 1))), o = e + t, s = r;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
o += t, s = r, c = e;
|
|
34
|
+
}
|
|
35
|
+
return a.push(o), a;
|
|
36
|
+
}
|
|
37
|
+
function i(e) {
|
|
38
|
+
return e ? e[0].toUpperCase() + e.slice(1) : ``;
|
|
39
|
+
}
|
|
40
|
+
function a(e) {
|
|
41
|
+
return e ? e[0].toLowerCase() + e.slice(1) : ``;
|
|
42
|
+
}
|
|
43
|
+
function o(e, t) {
|
|
44
|
+
return e ? (Array.isArray(e) ? e : r(e)).map((e) => i(t?.normalize ? e.toLowerCase() : e)).join(``) : ``;
|
|
45
|
+
}
|
|
46
|
+
function s(e, t) {
|
|
47
|
+
return a(o(e || ``, t));
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { s };
|