wxt 0.20.21 → 0.20.22
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/core/builders/vite/index.mjs +7 -2
- package/dist/core/resolve-config.mjs +7 -0
- package/dist/core/utils/env.mjs +2 -5
- package/dist/core/utils/manifest.mjs +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/types.d.mts +61 -1
- package/dist/utils/inject-script.mjs +3 -2
- package/dist/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -52,8 +52,10 @@ async function createViteBuilder(wxtConfig, hooks, getWxtDevServer) {
|
|
|
52
52
|
config.server.watch = { ignored: [`${wxtConfig.outBaseDir}/**`, `${wxtConfig.wxtDir}/**`] };
|
|
53
53
|
config.legacy ??= {};
|
|
54
54
|
config.legacy.skipWebSocketTokenCheck = true;
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (isRolldownVersion(vite.version)) {} else {
|
|
56
|
+
config.esbuild ??= {};
|
|
57
|
+
if (config.esbuild) config.esbuild.charset = "ascii";
|
|
58
|
+
}
|
|
57
59
|
const server = getWxtDevServer?.();
|
|
58
60
|
config.plugins ??= [];
|
|
59
61
|
config.plugins.push(download(wxtConfig), devHtmlPrerender(wxtConfig, server), resolveVirtualModules(wxtConfig), devServerGlobals(wxtConfig, server), tsconfigPaths(wxtConfig), noopBackground(), globals(wxtConfig), defineImportMeta(), wxtPluginLoader(wxtConfig), resolveAppConfig(wxtConfig));
|
|
@@ -312,5 +314,8 @@ async function removeEmptyDirs(dir) {
|
|
|
312
314
|
await rmdir(dir);
|
|
313
315
|
} catch {}
|
|
314
316
|
}
|
|
317
|
+
function isRolldownVersion(version) {
|
|
318
|
+
return Number(version.split(".")[0]) >= 8;
|
|
319
|
+
}
|
|
315
320
|
//#endregion
|
|
316
321
|
export { createViteBuilder };
|
|
@@ -91,11 +91,16 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
91
91
|
const host = mergedConfig.dev?.server?.host ?? mergedConfig.dev?.server?.hostname ?? "localhost";
|
|
92
92
|
let port = mergedConfig.dev?.server?.port;
|
|
93
93
|
const origin = mergedConfig.dev?.server?.origin ?? mergedConfig.dev?.server?.hostname ?? "localhost";
|
|
94
|
+
const strictPort = mergedConfig.dev?.server?.strictPort ?? false;
|
|
94
95
|
if (port == null || !isFinite(port)) port = await getPort({
|
|
95
96
|
host,
|
|
96
97
|
port: 3e3,
|
|
97
98
|
portRange: [3001, 3010]
|
|
98
99
|
});
|
|
100
|
+
else if (!strictPort) port = await getPort({
|
|
101
|
+
host,
|
|
102
|
+
port
|
|
103
|
+
});
|
|
99
104
|
const originWithProtocolAndPort = [
|
|
100
105
|
origin.match(/^https?:\/\//) ? "" : "http://",
|
|
101
106
|
origin,
|
|
@@ -105,6 +110,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
105
110
|
host,
|
|
106
111
|
port,
|
|
107
112
|
origin: originWithProtocolAndPort,
|
|
113
|
+
strictPort,
|
|
108
114
|
watchDebounce: safeStringToNumber(process.env.WXT_WATCH_DEBOUNCE) ?? 800
|
|
109
115
|
};
|
|
110
116
|
}
|
|
@@ -142,6 +148,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
142
148
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
143
149
|
alias,
|
|
144
150
|
experimental: defu(mergedConfig.experimental, {}),
|
|
151
|
+
suppressWarnings: mergedConfig.suppressWarnings ?? {},
|
|
145
152
|
dev: {
|
|
146
153
|
server: devServerConfig,
|
|
147
154
|
reloadCommand
|
package/dist/core/utils/env.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { expand } from "dotenv-expand";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { parseEnv } from "node:util";
|
|
3
|
-
import { expand } from "dotenv-expand";
|
|
4
4
|
//#region src/core/utils/env.ts
|
|
5
5
|
/** Load environment files based on the current mode and browser. */
|
|
6
6
|
function loadEnv(mode, browser) {
|
|
@@ -23,10 +23,7 @@ function loadEnv(mode, browser) {
|
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
25
25
|
}));
|
|
26
|
-
expand({
|
|
27
|
-
parsed,
|
|
28
|
-
processEnv: { ...process.env }
|
|
29
|
-
});
|
|
26
|
+
expand({ parsed });
|
|
30
27
|
return parsed;
|
|
31
28
|
}
|
|
32
29
|
//#endregion
|
|
@@ -55,6 +55,7 @@ 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.warn("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");
|
|
58
59
|
addEntrypoints(manifest, entrypoints, buildOutput);
|
|
59
60
|
if (wxt.config.browser === "firefox") addDiscoveredThemeIcons(manifest, buildOutput);
|
|
60
61
|
if (wxt.config.command === "serve") addDevModeCsp(manifest);
|
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, ExtensionRunnerConfig, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, 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, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, ExtensionRunnerConfig, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, 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";
|
|
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";
|
|
@@ -9,4 +9,4 @@ import { prepare } from "./core/prepare.mjs";
|
|
|
9
9
|
import { zip } from "./core/zip.mjs";
|
|
10
10
|
import { normalizePath } from "./core/utils/paths.mjs";
|
|
11
11
|
import { version } from "./version.mjs";
|
|
12
|
-
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, ExtensionRunnerConfig, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, 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, defineRunnerConfig, defineWebExtConfig, initialize, normalizePath, prepare, version, zip };
|
|
12
|
+
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, ExtensionRunnerConfig, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, 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, defineRunnerConfig, defineWebExtConfig, initialize, normalizePath, prepare, version, zip };
|
package/dist/types.d.mts
CHANGED
|
@@ -164,6 +164,25 @@ interface InlineConfig {
|
|
|
164
164
|
* function that returns an object or promise.
|
|
165
165
|
*/
|
|
166
166
|
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
|
|
167
|
+
/**
|
|
168
|
+
* Suppress specific warnings during the build process.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* export default defineConfig({
|
|
173
|
+
* suppressWarnings: {
|
|
174
|
+
* firefoxDataCollection: true,
|
|
175
|
+
* },
|
|
176
|
+
* })
|
|
177
|
+
* ```;
|
|
178
|
+
*/
|
|
179
|
+
suppressWarnings?: {
|
|
180
|
+
/**
|
|
181
|
+
* Suppress warnings for:
|
|
182
|
+
* https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent
|
|
183
|
+
*/
|
|
184
|
+
firefoxDataCollection?: boolean;
|
|
185
|
+
};
|
|
167
186
|
/**
|
|
168
187
|
* Configure browser startup. Options set here can be overridden in a
|
|
169
188
|
* `web-ext.config.ts` file.
|
|
@@ -389,6 +408,14 @@ interface InlineConfig {
|
|
|
389
408
|
* @default 'http://localhost:3000'
|
|
390
409
|
*/
|
|
391
410
|
origin?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Whether the dev server should fail if the specified port is already in
|
|
413
|
+
* use. When `false` and a `port` is specified, the next available port
|
|
414
|
+
* will be used instead of throwing an error.
|
|
415
|
+
*
|
|
416
|
+
* @default false
|
|
417
|
+
*/
|
|
418
|
+
strictPort?: boolean;
|
|
392
419
|
/**
|
|
393
420
|
* Hostname to run the dev server on.
|
|
394
421
|
*
|
|
@@ -880,6 +907,29 @@ type PerBrowserMap<T> = {
|
|
|
880
907
|
* `PerBrowserOption`, like `defaultIcon`.
|
|
881
908
|
*/
|
|
882
909
|
type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = { [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key] } & { [key in TOmitted]: T[key] };
|
|
910
|
+
/**
|
|
911
|
+
* Firefox data collection permission types for personal data. See:
|
|
912
|
+
* https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
|
|
913
|
+
*/
|
|
914
|
+
type FirefoxDataCollectionType = 'locationInfo' | 'browsingActivity' | 'websiteContent' | 'websiteActivity' | 'searchTerms' | 'bookmarksInfo' | 'healthInfo' | 'contactInfo' | 'socialInfo' | (string & {});
|
|
915
|
+
/**
|
|
916
|
+
* Firefox data collection permissions configuration. See:
|
|
917
|
+
* https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
|
|
918
|
+
*/
|
|
919
|
+
interface FirefoxDataCollectionPermissions {
|
|
920
|
+
/**
|
|
921
|
+
* Required data collection permissions. Users must opt in to use the
|
|
922
|
+
* extension. Can include personal data types or "none" to explicitly indicate
|
|
923
|
+
* no data collection.
|
|
924
|
+
*/
|
|
925
|
+
required?: Array<FirefoxDataCollectionType | 'none'>;
|
|
926
|
+
/**
|
|
927
|
+
* Optional data collection permissions. Users can opt in after installation.
|
|
928
|
+
* Can include personal data types or "technicalAndInteraction" (which can
|
|
929
|
+
* only be optional).
|
|
930
|
+
*/
|
|
931
|
+
optional?: Array<FirefoxDataCollectionType | 'technicalAndInteraction'>;
|
|
932
|
+
}
|
|
883
933
|
/**
|
|
884
934
|
* Manifest customization available in the `wxt.config.ts` file. You cannot
|
|
885
935
|
* configure entrypoints here, they are configured inline.
|
|
@@ -903,6 +953,11 @@ type UserManifest = { [key in keyof Browser.runtime.ManifestV3 as key extends 'a
|
|
|
903
953
|
strict_min_version?: string;
|
|
904
954
|
strict_max_version?: string;
|
|
905
955
|
update_url?: string;
|
|
956
|
+
/**
|
|
957
|
+
* Firefox data collection permissions configuration. See:
|
|
958
|
+
* https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
|
|
959
|
+
*/
|
|
960
|
+
data_collection_permissions?: FirefoxDataCollectionPermissions;
|
|
906
961
|
};
|
|
907
962
|
gecko_android?: {
|
|
908
963
|
strict_min_version?: string;
|
|
@@ -1311,11 +1366,16 @@ interface ResolvedConfig$1 {
|
|
|
1311
1366
|
/** Import aliases to absolute paths. */
|
|
1312
1367
|
alias: Record<string, string>;
|
|
1313
1368
|
experimental: {};
|
|
1369
|
+
/** List of warning identifiers to suppress during the build process. */
|
|
1370
|
+
suppressWarnings: {
|
|
1371
|
+
firefoxDataCollection?: boolean;
|
|
1372
|
+
};
|
|
1314
1373
|
dev: {
|
|
1315
1374
|
/** Only defined during dev command */server?: {
|
|
1316
1375
|
host: string;
|
|
1317
1376
|
port: number;
|
|
1318
1377
|
origin: string;
|
|
1378
|
+
strictPort: boolean;
|
|
1319
1379
|
/**
|
|
1320
1380
|
* The milliseconds to debounce when a file is saved before reloading. The
|
|
1321
1381
|
* only way to set this option is to set the `WXT_WATCH_DEBOUNCE`
|
|
@@ -1536,4 +1596,4 @@ interface WxtDirFileEntry {
|
|
|
1536
1596
|
tsReference?: boolean;
|
|
1537
1597
|
}
|
|
1538
1598
|
//#endregion
|
|
1539
|
-
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, ExtensionRunnerConfig, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig$1 as 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 };
|
|
1599
|
+
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner, ExtensionRunnerConfig, FirefoxDataCollectionPermissions, FirefoxDataCollectionType, FsCache, GeneratedPublicFile, GenericEntrypoint, HookResult, InlineConfig, IsolatedWorldContentScriptDefinition, IsolatedWorldContentScriptEntrypointOptions, Logger, MainWorldContentScriptDefinition, MainWorldContentScriptEntrypointOptions, OnContentScriptStopped, OptionsEntrypoint, OptionsEntrypointOptions, OutputAsset, OutputChunk, OutputFile, PerBrowserMap, PerBrowserOption, PopupEntrypoint, PopupEntrypointOptions, PublicPathEntry, ReloadContentScriptPayload, ResolvedBasePublicFile, ResolvedConfig$1 as 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 };
|
|
@@ -15,9 +15,10 @@ import { browser } from "wxt/browser";
|
|
|
15
15
|
async function injectScript(path, options) {
|
|
16
16
|
const url = browser.runtime.getURL(path);
|
|
17
17
|
const script = document.createElement("script");
|
|
18
|
-
|
|
18
|
+
const isManifestV2 = browser.runtime.getManifest().manifest_version === 2;
|
|
19
|
+
if (isManifestV2) script.text = await fetch(url).then((res) => res.text());
|
|
19
20
|
else script.src = url;
|
|
20
|
-
const loadedPromise = makeLoadedPromise(script);
|
|
21
|
+
const loadedPromise = isManifestV2 ? void 0 : makeLoadedPromise(script);
|
|
21
22
|
await options?.modifyScript?.(script);
|
|
22
23
|
(document.head ?? document.documentElement).append(script);
|
|
23
24
|
if (!options?.keepInDom) script.remove();
|
package/dist/version.mjs
CHANGED