wxt 0.11.1 → 0.12.0

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-irU6kFSB.cjs';
2
- export { n as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, t as ConfigEnv, m as ContentScriptDefinition, C as ContentScriptEntrypoint, j as Entrypoint, k as EntrypointGroup, q as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, p as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, o as UnlistedScriptDefinition, r as UserManifest, s as UserManifestFn, u as WxtBuilder, v as WxtBuilderServer, a as WxtViteConfig } from './external-irU6kFSB.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-tVP-84Pg.cjs';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-tVP-84Pg.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.11.1";
65
+ var version = "0.12.0";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-irU6kFSB.js';
2
- export { n as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, t as ConfigEnv, m as ContentScriptDefinition, C as ContentScriptEntrypoint, j as Entrypoint, k as EntrypointGroup, q as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, p as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, o as UnlistedScriptDefinition, r as UserManifest, s as UserManifestFn, u as WxtBuilder, v as WxtBuilderServer, a as WxtViteConfig } from './external-irU6kFSB.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-tVP-84Pg.js';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-tVP-84Pg.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.11.1";
65
+ var version = "0.12.0";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  rebuild,
16
16
  resolvePerBrowserOption,
17
17
  version
18
- } from "./chunk-65FJ5ESC.js";
18
+ } from "./chunk-UY7NE73P.js";
19
19
  import "./chunk-VBXJIVYU.js";
20
20
 
21
21
  // src/core/build.ts
package/dist/sandbox.d.ts CHANGED
@@ -1,7 +1,12 @@
1
- import { U as UnlistedScriptDefinition } from './external-PmmO6xnl.js';
1
+ import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './external-TYmXqKVq.js';
2
2
  import 'webextension-polyfill';
3
3
 
4
4
  declare function defineUnlistedScript(main: () => void): UnlistedScriptDefinition;
5
5
  declare function defineUnlistedScript(definition: UnlistedScriptDefinition): UnlistedScriptDefinition;
6
6
 
7
- export { defineUnlistedScript };
7
+ declare function defineBackground(main: () => void): BackgroundDefinition;
8
+ declare function defineBackground(definition: BackgroundDefinition): BackgroundDefinition;
9
+
10
+ declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
11
+
12
+ export { defineBackground, defineContentScript, defineUnlistedScript };
package/dist/sandbox.js CHANGED
@@ -4,6 +4,20 @@ function defineUnlistedScript(arg) {
4
4
  return { main: arg };
5
5
  return arg;
6
6
  }
7
+
8
+ // src/sandbox/define-background.ts
9
+ function defineBackground(arg) {
10
+ if (typeof arg === "function")
11
+ return { main: arg };
12
+ return arg;
13
+ }
14
+
15
+ // src/sandbox/define-content-script.ts
16
+ function defineContentScript(definition) {
17
+ return definition;
18
+ }
7
19
  export {
20
+ defineBackground,
21
+ defineContentScript,
8
22
  defineUnlistedScript
9
23
  };
package/dist/testing.cjs CHANGED
@@ -691,12 +691,10 @@ var PATH_GLOB_TO_TYPE_MAP = {
691
691
  "options/index.html": "options",
692
692
  "*.html": "unlisted-page",
693
693
  "*/index.html": "unlisted-page",
694
- "*.[jt]s": "unlisted-script",
695
- "*/index.ts": "unlisted-script",
694
+ "*.[jt]s?(x)": "unlisted-script",
695
+ "*/index.[jt]s?(x)": "unlisted-script",
696
696
  [`*.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
697
- [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
698
- // Don't warn about any files in subdirectories, like CSS or JS entrypoints for HTML files or tests
699
- "*/**": "ignored"
697
+ [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style"
700
698
  };
701
699
 
702
700
  // src/core/utils/building/generate-wxt-dir.ts
@@ -756,7 +754,8 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
756
754
  devHtmlPrerender(wxtConfig),
757
755
  unimport(wxtConfig),
758
756
  virtualEntrypoint("background", wxtConfig),
759
- virtualEntrypoint("content-script", wxtConfig),
757
+ virtualEntrypoint("content-script-isolated-world", wxtConfig),
758
+ virtualEntrypoint("content-script-main-world", wxtConfig),
760
759
  virtualEntrypoint("unlisted-script", wxtConfig),
761
760
  devServerGlobals(wxtConfig),
762
761
  tsconfigPaths(wxtConfig),
@@ -770,12 +769,17 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
770
769
  return config;
771
770
  };
772
771
  const getLibModeConfig = (entrypoint) => {
773
- const isVirtual = [
774
- "background",
775
- "content-script",
776
- "unlisted-script"
777
- ].includes(entrypoint.type);
778
- const entry = isVirtual ? `virtual:wxt-${entrypoint.type}?${entrypoint.inputPath}` : entrypoint.inputPath;
772
+ let virtualEntrypointType;
773
+ switch (entrypoint.type) {
774
+ case "background":
775
+ case "unlisted-script":
776
+ virtualEntrypointType = entrypoint.type;
777
+ break;
778
+ case "content-script":
779
+ virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
780
+ break;
781
+ }
782
+ const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
779
783
  const plugins = [
780
784
  entrypointGroupGlobals(entrypoint)
781
785
  ];
@@ -936,7 +940,10 @@ async function getInternalConfig(inlineConfig, command, server) {
936
940
  const { config: loadedConfig, ...metadata } = await (0, import_c12.loadConfig)({
937
941
  name: "wxt",
938
942
  cwd: inlineConfig.root ?? process.cwd(),
939
- rcFile: false
943
+ rcFile: false,
944
+ jitiOptions: {
945
+ esmResolve: true
946
+ }
940
947
  });
941
948
  userConfig = loadedConfig ?? {};
942
949
  userConfigMetadata = metadata;
@@ -1109,14 +1116,16 @@ function resolveInternalZipConfig(root, mergedConfig) {
1109
1116
  var import_jiti = __toESM(require("jiti"), 1);
1110
1117
  var import_unimport5 = require("unimport");
1111
1118
  var import_fs_extra8 = __toESM(require("fs-extra"), 1);
1119
+ var import_node_path8 = require("path");
1112
1120
  var import_esbuild = require("esbuild");
1121
+ var import_node_url = require("url");
1113
1122
 
1114
1123
  // src/core/utils/building/internal-build.ts
1115
1124
  var import_picocolors4 = __toESM(require("picocolors"), 1);
1116
1125
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
1117
1126
 
1118
1127
  // src/core/utils/log/printFileList.ts
1119
- var import_node_path8 = __toESM(require("path"), 1);
1128
+ var import_node_path9 = __toESM(require("path"), 1);
1120
1129
  var import_picocolors2 = __toESM(require("picocolors"), 1);
1121
1130
  var import_fs_extra9 = __toESM(require("fs-extra"), 1);
1122
1131
  var import_filesize = require("filesize");
@@ -1144,7 +1153,7 @@ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
1144
1153
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
1145
1154
 
1146
1155
  // src/core/utils/package.ts
1147
- var import_node_path9 = require("path");
1156
+ var import_node_path10 = require("path");
1148
1157
  var import_fs_extra10 = __toESM(require("fs-extra"), 1);
1149
1158
 
1150
1159
  // src/core/utils/manifest.ts
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './external-irU6kFSB.cjs';
3
+ import { I as InlineConfig } from './external-tVP-84Pg.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './external-irU6kFSB.js';
3
+ import { I as InlineConfig } from './external-tVP-84Pg.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  unimport,
7
7
  webextensionPolyfillAlias,
8
8
  webextensionPolyfillInlineDeps
9
- } from "./chunk-65FJ5ESC.js";
9
+ } from "./chunk-UY7NE73P.js";
10
10
  import "./chunk-VBXJIVYU.js";
11
11
 
12
12
  // src/testing/fake-browser.ts
@@ -1,5 +1,5 @@
1
- // src/virtual/content-script-entrypoint.ts
2
- import definition from "virtual:user-content-script";
1
+ // src/virtual/content-script-isolated-world-entrypoint.ts
2
+ import definition from "virtual:user-content-script-isolated-world";
3
3
 
4
4
  // src/client/utils/logger.ts
5
5
  function print(method, ...args) {
@@ -233,7 +233,7 @@ var ContentScriptContext = class _ContentScriptContext {
233
233
  }
234
234
  };
235
235
 
236
- // src/virtual/content-script-entrypoint.ts
236
+ // src/virtual/content-script-isolated-world-entrypoint.ts
237
237
  (async () => {
238
238
  try {
239
239
  const { main, ...options } = definition;
@@ -0,0 +1,33 @@
1
+ // src/virtual/content-script-main-world-entrypoint.ts
2
+ import definition from "virtual:user-content-script-main-world";
3
+
4
+ // src/client/utils/logger.ts
5
+ function print(method, ...args) {
6
+ if (import.meta.env.MODE === "production")
7
+ return;
8
+ if (typeof args[0] === "string") {
9
+ const message = args.shift();
10
+ method(`[wxt] ${message}`, ...args);
11
+ } else {
12
+ method("[wxt]", ...args);
13
+ }
14
+ }
15
+ var logger = {
16
+ debug: (...args) => print(console.debug, ...args),
17
+ log: (...args) => print(console.log, ...args),
18
+ warn: (...args) => print(console.warn, ...args),
19
+ error: (...args) => print(console.error, ...args)
20
+ };
21
+
22
+ // src/virtual/content-script-main-world-entrypoint.ts
23
+ (async () => {
24
+ try {
25
+ const { main } = definition;
26
+ await main();
27
+ } catch (err) {
28
+ logger.error(
29
+ `The content script "${__ENTRYPOINT__}" crashed on startup!`,
30
+ err
31
+ );
32
+ }
33
+ })();
@@ -75,12 +75,10 @@ var PATH_GLOB_TO_TYPE_MAP = {
75
75
  "options/index.html": "options",
76
76
  "*.html": "unlisted-page",
77
77
  "*/index.html": "unlisted-page",
78
- "*.[jt]s": "unlisted-script",
79
- "*/index.ts": "unlisted-script",
78
+ "*.[jt]s?(x)": "unlisted-script",
79
+ "*/index.[jt]s?(x)": "unlisted-script",
80
80
  [`*.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
81
- [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
82
- // Don't warn about any files in subdirectories, like CSS or JS entrypoints for HTML files or tests
83
- "*/**": "ignored"
81
+ [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style"
84
82
  };
85
83
 
86
84
  // src/core/utils/building/generate-wxt-dir.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.11.1",
4
+ "version": "0.12.0",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -30,7 +30,7 @@
30
30
  "bin",
31
31
  "dist"
32
32
  ],
33
- "bin": "./bin/wxt.cjs",
33
+ "bin": "./bin/wxt.mjs",
34
34
  "main": "./dist/index.cjs",
35
35
  "module": "./dist/index.js",
36
36
  "types": "./dist/index.d.ts",
package/bin/wxt.cjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../dist/cli.cjs');