wxt 0.20.27 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/cli/cli-utils.mjs +2 -2
- package/dist/core/builders/vite/index.mjs +85 -46
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +1 -1
- package/dist/core/builders/vite/plugins/index.mjs +0 -1
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +1 -1
- package/dist/core/clean.d.mts +0 -11
- package/dist/core/clean.mjs +9 -2
- package/dist/core/create-server.mjs +12 -11
- package/dist/core/define-web-ext-config.d.mts +1 -3
- package/dist/core/define-web-ext-config.mjs +1 -7
- package/dist/core/generate-wxt-dir.mjs +27 -25
- package/dist/core/index.d.mts +3 -2
- package/dist/core/index.mjs +1 -0
- package/dist/core/initialize.mjs +5 -5
- package/dist/core/resolve-config.mjs +40 -24
- package/dist/core/runners/web-ext.mjs +6 -5
- package/dist/core/utils/building/detect-dev-changes.mjs +17 -7
- package/dist/core/utils/building/internal-build.mjs +1 -1
- package/dist/core/utils/create-file-reloader.mjs +82 -27
- package/dist/core/utils/entrypoints.d.mts +10 -0
- package/dist/core/utils/index.d.mts +2 -0
- package/dist/core/utils/index.mjs +1 -0
- package/dist/core/utils/time.mjs +1 -10
- package/dist/core/utils/transform.mjs +1 -1
- package/dist/core/zip.mjs +15 -11
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -2
- package/dist/testing/wxt-vitest-plugin.mjs +0 -2
- package/dist/types.d.mts +102 -41
- package/dist/utils/app-config.d.mts +1 -0
- package/dist/utils/app-config.mjs +2 -0
- package/dist/utils/content-script-ui/shadow-root.mjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/virtual/mock-browser.d.mts +1 -1
- package/dist/virtual/mock-browser.mjs +1 -1
- package/package.json +22 -20
- package/dist/core/builders/vite/plugins/download.mjs +0 -30
- package/dist/core/runners/index.mjs +0 -15
- package/dist/core/utils/network.mjs +0 -36
- package/dist/core/utils/picomatch-multiple.mjs +0 -24
- package/dist/core/utils/wsl.mjs +0 -8
- package/dist/testing/index.d.mts +0 -3
- package/dist/testing/index.mjs +0 -3
package/dist/types.d.mts
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
import { ManifestContentScript } from "./core/utils/types.mjs";
|
|
23
23
|
import { Hookable, NestedHooks } from "hookable";
|
|
24
24
|
import { Import, UnimportOptions } from "unimport";
|
|
25
|
-
import { LogLevel } from "consola";
|
|
26
25
|
import { PluginVisualizerOptions } from "@aklinker1/rollup-plugin-visualizer";
|
|
27
26
|
import * as Nypm from "nypm";
|
|
28
27
|
import { ResolvedConfig } from "c12";
|
|
28
|
+
import { LogLevel } from "consola";
|
|
29
29
|
import { Browser } from "@wxt-dev/browser";
|
|
30
30
|
import * as vite from "vite";
|
|
31
31
|
|
|
@@ -152,6 +152,20 @@ interface InlineConfig {
|
|
|
152
152
|
* line `--mv2` or `--mv3` option.
|
|
153
153
|
*/
|
|
154
154
|
manifestVersion?: TargetManifestVersion;
|
|
155
|
+
/**
|
|
156
|
+
* Chokidar options used by dev-mode file watchers. This is useful in
|
|
157
|
+
* containers, WSL, and network file systems where native file events can be
|
|
158
|
+
* unreliable.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* export default defineConfig({
|
|
162
|
+
* watchOptions: {
|
|
163
|
+
* usePolling: true,
|
|
164
|
+
* interval: 1000,
|
|
165
|
+
* },
|
|
166
|
+
* });
|
|
167
|
+
*/
|
|
168
|
+
watchOptions?: vite.WatchOptions;
|
|
155
169
|
/**
|
|
156
170
|
* Override the logger used.
|
|
157
171
|
*
|
|
@@ -191,8 +205,6 @@ interface InlineConfig {
|
|
|
191
205
|
* `web-ext.config.ts` file.
|
|
192
206
|
*/
|
|
193
207
|
webExt?: WebExtConfig;
|
|
194
|
-
/** @deprecated Use `webExt` instead. Same option, just renamed. */
|
|
195
|
-
runner?: WebExtConfig;
|
|
196
208
|
zip?: {
|
|
197
209
|
/**
|
|
198
210
|
* Configure the filename output when zipping files.
|
|
@@ -201,16 +213,20 @@ interface InlineConfig {
|
|
|
201
213
|
*
|
|
202
214
|
* - <span v-pre>`{{name}}`</span> - The project's name converted to
|
|
203
215
|
* kebab-case
|
|
204
|
-
* - <span v-pre>`{{version}}`</span> - The
|
|
205
|
-
*
|
|
216
|
+
* - <span v-pre>`{{version}}`</span> - The version from the manifest
|
|
217
|
+
* - <span v-pre>`{{versionName}}`</span> - The `version_name` from the
|
|
218
|
+
* manifest or, if not set (i.e. if built for Firefox), the `version` from
|
|
219
|
+
* the manifest
|
|
206
220
|
* - <span v-pre>`{{packageVersion}}`</span> - The version from the
|
|
207
221
|
* package.json
|
|
208
222
|
* - <span v-pre>`{{browser}}`</span> - The target browser from the
|
|
209
223
|
* `--browser` CLI flag
|
|
210
224
|
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
225
|
+
* - <span v-pre>`{{modeSuffix}}`</span>: A suffix based on the mode ('-dev'
|
|
226
|
+
* for development, '' for production)
|
|
211
227
|
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
212
228
|
*
|
|
213
|
-
* @default '{{name}}-{{
|
|
229
|
+
* @default '{{name}}-{{packageVersion}}-{{browser}}{{modeSuffix}}.zip'
|
|
214
230
|
*/
|
|
215
231
|
artifactTemplate?: string;
|
|
216
232
|
/**
|
|
@@ -230,16 +246,20 @@ interface InlineConfig {
|
|
|
230
246
|
*
|
|
231
247
|
* - <span v-pre>`{{name}}`</span> - The project's name converted to
|
|
232
248
|
* kebab-case
|
|
233
|
-
* - <span v-pre>`{{version}}`</span> - The
|
|
234
|
-
*
|
|
249
|
+
* - <span v-pre>`{{version}}`</span> - The version from the manifest
|
|
250
|
+
* - <span v-pre>`{{versionName}}`</span> - The `version_name` from the
|
|
251
|
+
* manifest or, if not set (i.e. if built for Firefox), the `version` from
|
|
252
|
+
* the manifest
|
|
235
253
|
* - <span v-pre>`{{packageVersion}}`</span> - The version from the
|
|
236
254
|
* package.json
|
|
237
255
|
* - <span v-pre>`{{browser}}`</span> - The target browser from the
|
|
238
256
|
* `--browser` CLI flag
|
|
239
257
|
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
258
|
+
* - <span v-pre>`{{modeSuffix}}`</span>: A suffix based on the mode ('-dev'
|
|
259
|
+
* for development, '' for production)
|
|
240
260
|
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
241
261
|
*
|
|
242
|
-
* @default '{{name}}-{{
|
|
262
|
+
* @default '{{name}}-{{packageVersion}}-sources{{modeSuffix}}.zip'
|
|
243
263
|
*/
|
|
244
264
|
sourcesTemplate?: string;
|
|
245
265
|
/**
|
|
@@ -255,25 +275,39 @@ interface InlineConfig {
|
|
|
255
275
|
*/
|
|
256
276
|
sourcesRoot?: string;
|
|
257
277
|
/**
|
|
258
|
-
* [
|
|
259
|
-
*
|
|
260
|
-
*
|
|
278
|
+
* [Tinyglobby](https://npmjs.org/tinyglobby) patterns of files to include
|
|
279
|
+
* when creating a ZIP of all your source code for Firefox. Patterns are
|
|
280
|
+
* relative to your `config.zip.sourcesRoot`.
|
|
261
281
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
282
|
+
* Sources ZIP files are created using standard allowlist/blocklist
|
|
283
|
+
* behavior:
|
|
284
|
+
*
|
|
285
|
+
* - You specify a pattern to "include" (via `includeSources`), then a pattern
|
|
286
|
+
* to "exclude" from the included files (via `excludeSources`).
|
|
287
|
+
*
|
|
288
|
+
* By default, this option includes all files except for hidden files and
|
|
289
|
+
* directories (files/directories starting with a `.`).
|
|
290
|
+
*
|
|
291
|
+
* If you want to include hidden files/directories in your sources ZIP, see
|
|
292
|
+
* `InlineConfig.zip.dotSources`.
|
|
264
293
|
*
|
|
265
294
|
* @example
|
|
266
|
-
* [
|
|
267
|
-
* 'coverage', // Include the coverage directory in the `sourcesRoot`
|
|
268
|
-
* ];
|
|
295
|
+
* ['entrypoints/**', 'wxt.config.ts', 'package.json', 'tsconfig.json'];
|
|
269
296
|
*/
|
|
270
297
|
includeSources?: string[];
|
|
271
298
|
/**
|
|
272
|
-
* [
|
|
273
|
-
*
|
|
274
|
-
*
|
|
299
|
+
* [Tinyglobby](https://npmjs.org/tinyglobby) patterns of files to exclude
|
|
300
|
+
* when creating a ZIP of all your source code for Firefox. Patterns are
|
|
301
|
+
* relative to your `config.zip.sourcesRoot`.
|
|
275
302
|
*
|
|
276
|
-
*
|
|
303
|
+
* By default, WXT excludes some files:
|
|
304
|
+
*
|
|
305
|
+
* - `node_modules`
|
|
306
|
+
* - Tests files and directories
|
|
307
|
+
* - Output directory
|
|
308
|
+
*
|
|
309
|
+
* Any values specified in this option will be merged with the ones above -
|
|
310
|
+
* you cannot replace the default values, only add to them.
|
|
277
311
|
*
|
|
278
312
|
* @example
|
|
279
313
|
* [
|
|
@@ -282,13 +316,31 @@ interface InlineConfig {
|
|
|
282
316
|
*/
|
|
283
317
|
excludeSources?: string[];
|
|
284
318
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
319
|
+
* Include hidden files/directories in your sources ZIP.
|
|
320
|
+
*
|
|
321
|
+
* [Tinyglobby](https://npmjs.org/tinyglobby) does not match against files
|
|
322
|
+
* and directory that start with a `.` by default. For example, if you need
|
|
323
|
+
* to include a `.env` file, you need to set this to `true`, then exclude
|
|
324
|
+
* other hidden files/directories in `excludeSources`.
|
|
325
|
+
*
|
|
326
|
+
* **Be very careful when this is enabled - WXT may include files with
|
|
327
|
+
* secrets in your ZIP you did not intend to share with Mozilla or upload to
|
|
328
|
+
* other places**. Make sure all hidden files you don't want to include are
|
|
329
|
+
* added to `excludeSources`.
|
|
330
|
+
*
|
|
331
|
+
* @default false
|
|
332
|
+
*/
|
|
333
|
+
dotSources?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* [Tinyglobby](https://npmjs.org/tinyglobby) patterns of files to exclude
|
|
336
|
+
* when zipping the extension.
|
|
287
337
|
*
|
|
288
338
|
* @example
|
|
289
339
|
* [
|
|
290
340
|
* '**\/*.map', // Exclude all sourcemaps
|
|
291
341
|
* ];
|
|
342
|
+
*
|
|
343
|
+
* @default [ ]
|
|
292
344
|
*/
|
|
293
345
|
exclude?: string[];
|
|
294
346
|
/**
|
|
@@ -419,13 +471,6 @@ interface InlineConfig {
|
|
|
419
471
|
* @default false
|
|
420
472
|
*/
|
|
421
473
|
strictPort?: boolean;
|
|
422
|
-
/**
|
|
423
|
-
* Hostname to run the dev server on.
|
|
424
|
-
*
|
|
425
|
-
* @deprecated Use `host` to specify the interface to bind to, or use
|
|
426
|
-
* `origin` to specify the dev server hostname.
|
|
427
|
-
*/
|
|
428
|
-
hostname?: string;
|
|
429
474
|
};
|
|
430
475
|
/**
|
|
431
476
|
* Controls whether a custom keyboard shortcut command, `Alt+R`, is added
|
|
@@ -619,12 +664,12 @@ interface BaseScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
|
619
664
|
* name
|
|
620
665
|
* - `false`: Output the IIFE without a variable name, making it anonymous. This
|
|
621
666
|
* is the safest option to avoid conflicts with existing variables on the
|
|
622
|
-
* page.
|
|
667
|
+
* page.
|
|
623
668
|
* - `string`: Use the provided string as the global variable name.
|
|
624
669
|
* - `function`: A function that receives the entrypoint and returns a string to
|
|
625
670
|
* use as the variable name.
|
|
626
671
|
*
|
|
627
|
-
* @default
|
|
672
|
+
* @default false
|
|
628
673
|
*/
|
|
629
674
|
globalName?: string | boolean | ((entrypoint: Entrypoint) => string);
|
|
630
675
|
}
|
|
@@ -1022,8 +1067,6 @@ interface ConfigEnv {
|
|
|
1022
1067
|
manifestVersion: 2 | 3;
|
|
1023
1068
|
}
|
|
1024
1069
|
type WxtCommand = 'build' | 'serve';
|
|
1025
|
-
/** @deprecated Use `WebExtConfig` instead. */
|
|
1026
|
-
type ExtensionRunnerConfig = WebExtConfig;
|
|
1027
1070
|
/**
|
|
1028
1071
|
* Options for how [`web-ext`](https://github.com/mozilla/web-ext) starts the
|
|
1029
1072
|
* browser.
|
|
@@ -1105,7 +1148,7 @@ interface WxtBuilder {
|
|
|
1105
1148
|
* Import a JS entrypoint file, returning the default export containing the
|
|
1106
1149
|
* options.
|
|
1107
1150
|
*/
|
|
1108
|
-
importEntrypoint<T>(path: string): Promise<T>;
|
|
1151
|
+
importEntrypoint<T>(this: WxtBuilder, path: string): Promise<T>;
|
|
1109
1152
|
/** Import a list of JS entrypoint files, returning their options. */
|
|
1110
1153
|
importEntrypoints(paths: string[]): Promise<Record<string, unknown>[]>;
|
|
1111
1154
|
/**
|
|
@@ -1147,6 +1190,9 @@ interface ServerInfo {
|
|
|
1147
1190
|
/** Ex: `"http://localhost:3000"` */
|
|
1148
1191
|
origin: string;
|
|
1149
1192
|
}
|
|
1193
|
+
type PrepareTsconfigs = {
|
|
1194
|
+
/** The JSON contents of the `.wxt/tsconfig.json` file. */tsconfig: any;
|
|
1195
|
+
};
|
|
1150
1196
|
type HookResult = Promise<void> | void;
|
|
1151
1197
|
interface WxtHooks {
|
|
1152
1198
|
/**
|
|
@@ -1164,6 +1210,17 @@ interface WxtHooks {
|
|
|
1164
1210
|
*/
|
|
1165
1211
|
'config:resolved': (wxt: Wxt) => HookResult;
|
|
1166
1212
|
'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
|
|
1213
|
+
/**
|
|
1214
|
+
* Called before WXT writes your tsconfig to the disk, allowing full
|
|
1215
|
+
* customization by modifying the object by reference.
|
|
1216
|
+
*
|
|
1217
|
+
* @since 0.20.28
|
|
1218
|
+
* @example
|
|
1219
|
+
* wxt.hooks.hook('prepare:tsconfig', (wxt, { tsconfig }) => {
|
|
1220
|
+
* tsconfig.compilerOptions.lib.push('WebWorker');
|
|
1221
|
+
* });
|
|
1222
|
+
*/
|
|
1223
|
+
'prepare:tsconfig': (wxt: Wxt, configs: PrepareTsconfigs) => HookResult;
|
|
1167
1224
|
/**
|
|
1168
1225
|
* Called before generating the list of public paths inside
|
|
1169
1226
|
* `.wxt/types/paths.d.ts`. Use this hook to add additional paths (relative to
|
|
@@ -1364,13 +1421,15 @@ interface ResolvedConfig$1 {
|
|
|
1364
1421
|
imports: WxtResolvedUnimportOptions;
|
|
1365
1422
|
manifest: UserManifest;
|
|
1366
1423
|
fsCache: FsCache;
|
|
1367
|
-
|
|
1424
|
+
webExt: ResolvedConfig<WebExtConfig>;
|
|
1425
|
+
runner: ExtensionRunner;
|
|
1368
1426
|
zip: {
|
|
1369
1427
|
name?: string;
|
|
1370
1428
|
artifactTemplate: string;
|
|
1371
1429
|
sourcesTemplate: string;
|
|
1372
1430
|
includeSources: string[];
|
|
1373
1431
|
excludeSources: string[];
|
|
1432
|
+
dotSources: boolean;
|
|
1374
1433
|
sourcesRoot: string;
|
|
1375
1434
|
downloadedPackagesDir: string;
|
|
1376
1435
|
downloadPackages: string[];
|
|
@@ -1396,6 +1455,8 @@ interface ResolvedConfig$1 {
|
|
|
1396
1455
|
firefoxDataCollection?: boolean;
|
|
1397
1456
|
firefoxId?: boolean;
|
|
1398
1457
|
};
|
|
1458
|
+
/** Chokidar options used by dev-mode file watchers. */
|
|
1459
|
+
watchOptions: vite.WatchOptions;
|
|
1399
1460
|
dev: {
|
|
1400
1461
|
/** Only defined during dev command */server?: {
|
|
1401
1462
|
host: string;
|
|
@@ -1452,16 +1513,16 @@ interface Eslintrc {
|
|
|
1452
1513
|
* When true, generates a file that can be used by ESLint to know which
|
|
1453
1514
|
* variables are valid globals.
|
|
1454
1515
|
*
|
|
1455
|
-
* - `false`: Don't generate the file.
|
|
1456
1516
|
* - `'auto'`: Check if eslint is installed, and if it is, generate a compatible
|
|
1457
1517
|
* config file.
|
|
1458
|
-
* - `true`: Same as `
|
|
1518
|
+
* - `true`: Same as `'auto'`.
|
|
1519
|
+
* - `false`: Don't generate the file.
|
|
1459
1520
|
* - `8`: Generate a config file compatible with ESLint 8.
|
|
1460
1521
|
* - `9`: Generate a config file compatible with ESLint 9.
|
|
1461
1522
|
*
|
|
1462
1523
|
* @default 'auto'
|
|
1463
1524
|
*/
|
|
1464
|
-
enabled?:
|
|
1525
|
+
enabled?: 'auto' | boolean | 8 | 9;
|
|
1465
1526
|
/**
|
|
1466
1527
|
* File path to save the generated eslint config.
|
|
1467
1528
|
*
|
|
@@ -1506,7 +1567,7 @@ type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
|
1506
1567
|
};
|
|
1507
1568
|
/**
|
|
1508
1569
|
* Package management utils built on top of
|
|
1509
|
-
* [`nypm`](https://
|
|
1570
|
+
* [`nypm`](https://npmjs.org/package/nypm)
|
|
1510
1571
|
*/
|
|
1511
1572
|
interface WxtPackageManager extends Nypm.PackageManager {
|
|
1512
1573
|
addDependency: typeof Nypm.addDependency;
|
|
@@ -1622,4 +1683,4 @@ interface WxtDirFileEntry {
|
|
|
1622
1683
|
tsReference?: boolean;
|
|
1623
1684
|
}
|
|
1624
1685
|
//#endregion
|
|
1625
|
-
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintGlobalsPropValue, Eslintrc, ExtensionRunner,
|
|
1686
|
+
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$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 };
|
|
@@ -10,6 +10,7 @@ declare function getAppConfig(): WxtAppConfig;
|
|
|
10
10
|
/**
|
|
11
11
|
* Alias for {@link getAppConfig}.
|
|
12
12
|
*
|
|
13
|
+
* @deprecated Use {@link getAppConfig} instead. Same function, different name.
|
|
13
14
|
* @see https://wxt.dev/guide/essentials/config/runtime.html
|
|
14
15
|
*/
|
|
15
16
|
declare function useAppConfig(): WxtAppConfig;
|
|
@@ -12,9 +12,11 @@ function getAppConfig() {
|
|
|
12
12
|
/**
|
|
13
13
|
* Alias for {@link getAppConfig}.
|
|
14
14
|
*
|
|
15
|
+
* @deprecated Use {@link getAppConfig} instead. Same function, different name.
|
|
15
16
|
* @see https://wxt.dev/guide/essentials/config/runtime.html
|
|
16
17
|
*/
|
|
17
18
|
function useAppConfig() {
|
|
19
|
+
if (import.meta.env.DEV) console.warn("[wxt] `useAppConfig` is deprecated. Please use `getAppConfig` instead.");
|
|
18
20
|
return getAppConfig();
|
|
19
21
|
}
|
|
20
22
|
//#endregion
|
|
@@ -32,7 +32,7 @@ async function createShadowRootUi(ctx, options) {
|
|
|
32
32
|
let mounted;
|
|
33
33
|
const mount = () => {
|
|
34
34
|
mountUi(shadowHost, options);
|
|
35
|
-
applyPosition(shadowHost,
|
|
35
|
+
applyPosition(shadowHost, uiContainer, options);
|
|
36
36
|
if (documentCss && !document.querySelector(`style[wxt-shadow-root-document-styles="${instanceId}"]`)) {
|
|
37
37
|
const style = document.createElement("style");
|
|
38
38
|
style.textContent = documentCss;
|
package/dist/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.1",
|
|
5
5
|
"description": "⚡ Next-gen Web Extension Framework",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -12,16 +12,15 @@
|
|
|
12
12
|
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
|
13
13
|
"test": "buildc --deps-only -- vitest",
|
|
14
14
|
"test:coverage": "bun run test run --coverage",
|
|
15
|
-
"sync-releases": "pnpx changelogen@latest gh release",
|
|
16
15
|
"prepack": "bun run build"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
18
|
"@1natsu/wait-element": "^4.1.2",
|
|
20
19
|
"@aklinker1/rollup-plugin-visualizer": "5.12.0",
|
|
21
|
-
"@webext-core/fake-browser": "^
|
|
22
|
-
"@webext-core/isolated-element": "^1.1.3",
|
|
23
|
-
"@webext-core/match-patterns": "^
|
|
24
|
-
"@wxt-dev/browser": "^0.2.
|
|
20
|
+
"@webext-core/fake-browser": "^2.0.1",
|
|
21
|
+
"@webext-core/isolated-element": "^1.1.3 || ^2 || ^3",
|
|
22
|
+
"@webext-core/match-patterns": "^2.0.0",
|
|
23
|
+
"@wxt-dev/browser": "^0.2.2",
|
|
25
24
|
"@wxt-dev/storage": "^1.0.0",
|
|
26
25
|
"async-mutex": "^0.5.0",
|
|
27
26
|
"c12": "^3.3.4",
|
|
@@ -30,8 +29,7 @@
|
|
|
30
29
|
"ci-info": "^4.4.0",
|
|
31
30
|
"consola": "^3.4.2",
|
|
32
31
|
"defu": "^6.1.4",
|
|
33
|
-
"dotenv-expand": "^
|
|
34
|
-
"esbuild": "^0.27.1",
|
|
32
|
+
"dotenv-expand": "^13.0.0",
|
|
35
33
|
"filesize": "^11.0.17",
|
|
36
34
|
"get-port-please": "^3.2.0",
|
|
37
35
|
"giget": "^1.2.3 || ^2.0.0 || ^3.0.0",
|
|
@@ -48,23 +46,29 @@
|
|
|
48
46
|
"nypm": "^0.6.5",
|
|
49
47
|
"ohash": "^2.0.11",
|
|
50
48
|
"open": "^11.0.0",
|
|
51
|
-
"perfect-debounce": "^2.1.0",
|
|
52
49
|
"picomatch": "^4.0.3",
|
|
53
50
|
"prompts": "^2.4.2",
|
|
54
|
-
"publish-browser-extension": "^
|
|
51
|
+
"publish-browser-extension": "^5.1.0",
|
|
55
52
|
"scule": "^1.3.0",
|
|
56
53
|
"tinyglobby": "^0.2.16",
|
|
57
54
|
"unimport": "^3.13.1 || ^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
58
|
-
"vite": "^5.4.19 || ^6.3.4 || ^7.0.0 || ^8.0.0-0",
|
|
59
|
-
"vite-node": "^3.2.4 || ^5.0.0 || ^6.0.0",
|
|
60
55
|
"web-ext-run": "^0.2.4"
|
|
61
56
|
},
|
|
62
57
|
"peerDependencies": {
|
|
63
|
-
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0"
|
|
58
|
+
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
59
|
+
"vite": "^6.3.4 || ^7.0.0 || ^8.0.0-0",
|
|
60
|
+
"web-ext": ">=9.2.0",
|
|
61
|
+
"typescript": ">=5.4"
|
|
64
62
|
},
|
|
65
63
|
"peerDependenciesMeta": {
|
|
66
64
|
"eslint": {
|
|
67
65
|
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"web-ext": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"typescript": {
|
|
71
|
+
"optional": true
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
74
|
"devDependencies": {
|
|
@@ -72,7 +76,7 @@
|
|
|
72
76
|
"@faker-js/faker": "^10.3.0",
|
|
73
77
|
"@types/bun": "^1.3.5",
|
|
74
78
|
"@types/lodash.merge": "^4.6.9",
|
|
75
|
-
"@types/node": "^
|
|
79
|
+
"@types/node": "^22",
|
|
76
80
|
"@types/normalize-path": "^3.0.2",
|
|
77
81
|
"@types/picomatch": "^4.0.2",
|
|
78
82
|
"@types/prompts": "^2.4.9",
|
|
@@ -84,8 +88,10 @@
|
|
|
84
88
|
"publint": "^0.3.18",
|
|
85
89
|
"tsdown": "^0.21.0",
|
|
86
90
|
"typescript": "^6.0.3",
|
|
91
|
+
"vite": "^7.3.1",
|
|
87
92
|
"vitest": "^4.1.5",
|
|
88
|
-
"vitest-plugin-random-seed": "^1.1.2"
|
|
93
|
+
"vitest-plugin-random-seed": "^1.1.2",
|
|
94
|
+
"web-ext": "^10.5.0"
|
|
89
95
|
},
|
|
90
96
|
"repository": {
|
|
91
97
|
"type": "git",
|
|
@@ -193,10 +199,6 @@
|
|
|
193
199
|
"types": "./dist/testing/wxt-vitest-plugin.d.mts",
|
|
194
200
|
"default": "./dist/testing/wxt-vitest-plugin.mjs"
|
|
195
201
|
},
|
|
196
|
-
"./testing": {
|
|
197
|
-
"types": "./dist/testing/index.d.mts",
|
|
198
|
-
"default": "./dist/testing/index.mjs"
|
|
199
|
-
},
|
|
200
202
|
"./vite-builder-env": {
|
|
201
203
|
"types": "./dist/vite-builder-env.d.ts"
|
|
202
204
|
},
|
|
@@ -206,7 +208,7 @@
|
|
|
206
208
|
}
|
|
207
209
|
},
|
|
208
210
|
"engines": {
|
|
209
|
-
"node": ">=
|
|
211
|
+
"node": ">=22",
|
|
210
212
|
"bun": ">=1.2.0"
|
|
211
213
|
}
|
|
212
214
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { fetchCached } from "../../../utils/network.mjs";
|
|
2
|
-
//#region src/core/builders/vite/plugins/download.ts
|
|
3
|
-
/**
|
|
4
|
-
* Downloads any URL imports, like Google Analytics, into virtual modules so
|
|
5
|
-
* they are bundled with the extension instead of depending on remote code at
|
|
6
|
-
* runtime.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import 'url:https://google-tagmanager.com/gtag?id=XYZ';
|
|
10
|
-
*/
|
|
11
|
-
function download(config) {
|
|
12
|
-
return {
|
|
13
|
-
name: "wxt:download",
|
|
14
|
-
enforce: "pre",
|
|
15
|
-
resolveId: {
|
|
16
|
-
filter: { id: /^url:/ },
|
|
17
|
-
handler(id) {
|
|
18
|
-
return `\0${id}`;
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
load: {
|
|
22
|
-
filter: { id: /^\x00url:/ },
|
|
23
|
-
handler(id) {
|
|
24
|
-
return fetchCached(id.replace("\0url:", ""), config);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
//#endregion
|
|
30
|
-
export { download };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { wxt } from "../wxt.mjs";
|
|
2
|
-
import { isWsl } from "../utils/wsl.mjs";
|
|
3
|
-
import { createManualRunner } from "./manual.mjs";
|
|
4
|
-
import { createSafariRunner } from "./safari.mjs";
|
|
5
|
-
import { createWebExtRunner } from "./web-ext.mjs";
|
|
6
|
-
import { createWslRunner } from "./wsl.mjs";
|
|
7
|
-
//#region src/core/runners/index.ts
|
|
8
|
-
async function createExtensionRunner() {
|
|
9
|
-
if (wxt.config.browser === "safari") return createSafariRunner();
|
|
10
|
-
if (isWsl()) return createWslRunner();
|
|
11
|
-
if (wxt.config.runnerConfig.config?.disabled) return createManualRunner();
|
|
12
|
-
return createWebExtRunner();
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { createExtensionRunner };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { withTimeout } from "./time.mjs";
|
|
2
|
-
import dns from "node:dns";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
//#region src/core/utils/network.ts
|
|
5
|
-
async function isOffline() {
|
|
6
|
-
try {
|
|
7
|
-
return await withTimeout(new Promise((res) => {
|
|
8
|
-
dns.resolve("google.com", (err) => res(err != null));
|
|
9
|
-
}), 1e3);
|
|
10
|
-
} catch (error) {
|
|
11
|
-
consola.error("Error checking offline status:", error);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async function isOnline() {
|
|
16
|
-
return !await isOffline();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Fetches a URL with a simple GET request. Grabs it from cache if it doesn't
|
|
20
|
-
* exist, or throws an error if it can't be resolved via the network or cache.
|
|
21
|
-
*/
|
|
22
|
-
async function fetchCached(url, config) {
|
|
23
|
-
let content = "";
|
|
24
|
-
if (await isOnline()) {
|
|
25
|
-
const res = await fetch(url);
|
|
26
|
-
if (res.status < 300) {
|
|
27
|
-
content = await res.text();
|
|
28
|
-
await config.fsCache.set(url, content);
|
|
29
|
-
} else config.logger.debug(`Failed to download "${url}", falling back to cache...`);
|
|
30
|
-
}
|
|
31
|
-
if (!content) content = await config.fsCache.get(url) ?? "";
|
|
32
|
-
if (!content) throw Error(`Offline and "${url}" has not been cached. Try again when online.`);
|
|
33
|
-
return content;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { fetchCached };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import picomatch from "picomatch";
|
|
2
|
-
//#region src/core/utils/picomatch-multiple.ts
|
|
3
|
-
/**
|
|
4
|
-
* Run [`picomatch`](https://npmjs.com/package/picomatch) against multiple
|
|
5
|
-
* patterns.
|
|
6
|
-
*
|
|
7
|
-
* Supports negated patterns, the order does not matter. If your `search` string
|
|
8
|
-
* matches any of the negative patterns, it will return `false`.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* picomatchMultiple('a.json', ['*.json', '!b.json']); // => true
|
|
12
|
-
* picomatchMultiple('b.json', ['*.json', '!b.json']); // => false
|
|
13
|
-
*/
|
|
14
|
-
function picomatchMultiple(search, patterns, options) {
|
|
15
|
-
if (patterns == null) return false;
|
|
16
|
-
const negatePatterns = [];
|
|
17
|
-
const positivePatterns = [];
|
|
18
|
-
for (const pattern of patterns) if (pattern[0] === "!") negatePatterns.push(pattern.slice(1));
|
|
19
|
-
else positivePatterns.push(pattern);
|
|
20
|
-
if (negatePatterns.some((negatePattern) => picomatch(negatePattern, options)(search))) return false;
|
|
21
|
-
return positivePatterns.some((positivePattern) => picomatch(positivePattern, options)(search));
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { picomatchMultiple };
|
package/dist/core/utils/wsl.mjs
DELETED
package/dist/testing/index.d.mts
DELETED
package/dist/testing/index.mjs
DELETED