wxt 0.17.2 → 0.17.4-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OLUK5FJF.js → chunk-63LEV65X.js} +17 -11
- package/dist/chunk-P57PW2II.js +11 -0
- package/dist/cli.js +14 -10
- package/dist/client.d.ts +1 -1
- package/dist/{index-v_64CCcw.d.ts → index-mYGv2dqk.d.ts} +23 -0
- package/dist/{index-V1QWdhdh.d.cts → index-vpYNIeCJ.d.cts} +27 -0
- package/dist/{index-V1QWdhdh.d.ts → index-vpYNIeCJ.d.ts} +27 -0
- package/dist/index.cjs +11 -9
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/sandbox.d.ts +1 -1
- package/dist/storage.cjs +38 -24
- package/dist/storage.d.cts +2 -1
- package/dist/storage.d.ts +2 -1
- package/dist/storage.js +40 -24
- package/dist/testing.cjs +10 -8
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-P57PW2II.js";
|
|
4
|
+
|
|
1
5
|
// package.json
|
|
2
|
-
var version = "0.17.
|
|
6
|
+
var version = "0.17.4-alpha1";
|
|
3
7
|
|
|
4
8
|
// src/core/utils/paths.ts
|
|
5
9
|
import systemPath from "node:path";
|
|
@@ -907,8 +911,8 @@ var reactRefreshPreamble = "";
|
|
|
907
911
|
function devHtmlPrerender(config) {
|
|
908
912
|
const htmlReloadId = "@wxt/reload-html";
|
|
909
913
|
const resolvedHtmlReloadId = resolve6(
|
|
910
|
-
config.
|
|
911
|
-
"
|
|
914
|
+
config.wxtModuleDir,
|
|
915
|
+
"dist/virtual/reload-html.js"
|
|
912
916
|
);
|
|
913
917
|
const virtualReactRefreshId = "@wxt/virtual-react-refresh";
|
|
914
918
|
const resolvedVirtualReactRefreshId = "\0" + virtualReactRefreshId;
|
|
@@ -1253,10 +1257,7 @@ function virtualEntrypoint(type, config) {
|
|
|
1253
1257
|
return;
|
|
1254
1258
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
1255
1259
|
const template = await fs7.readFile(
|
|
1256
|
-
resolve8(
|
|
1257
|
-
config.root,
|
|
1258
|
-
`node_modules/wxt/dist/virtual/${type}-entrypoint.js`
|
|
1259
|
-
),
|
|
1260
|
+
resolve8(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
|
|
1260
1261
|
"utf-8"
|
|
1261
1262
|
);
|
|
1262
1263
|
return template.replace(`virtual:user-${type}`, inputPath);
|
|
@@ -1362,8 +1363,8 @@ function webextensionPolyfillMock(config) {
|
|
|
1362
1363
|
alias: {
|
|
1363
1364
|
// Alias to use a mocked version of the polyfill
|
|
1364
1365
|
"webextension-polyfill": path4.resolve(
|
|
1365
|
-
config.
|
|
1366
|
-
"
|
|
1366
|
+
config.wxtModuleDir,
|
|
1367
|
+
"dist/virtual/mock-browser"
|
|
1367
1368
|
)
|
|
1368
1369
|
}
|
|
1369
1370
|
},
|
|
@@ -1702,6 +1703,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1702
1703
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
1703
1704
|
);
|
|
1704
1705
|
const wxtDir = path5.resolve(root, ".wxt");
|
|
1706
|
+
const wxtModuleDir = resolveWxtModuleDir();
|
|
1705
1707
|
const srcDir = path5.resolve(root, mergedConfig.srcDir ?? root);
|
|
1706
1708
|
const entrypointsDir = path5.resolve(
|
|
1707
1709
|
srcDir,
|
|
@@ -1752,6 +1754,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1752
1754
|
outBaseDir,
|
|
1753
1755
|
outDir,
|
|
1754
1756
|
publicDir,
|
|
1757
|
+
wxtModuleDir,
|
|
1755
1758
|
root,
|
|
1756
1759
|
runnerConfig,
|
|
1757
1760
|
srcDir,
|
|
@@ -1918,6 +1921,9 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1918
1921
|
defaultOptions
|
|
1919
1922
|
);
|
|
1920
1923
|
}
|
|
1924
|
+
function resolveWxtModuleDir() {
|
|
1925
|
+
return path5.resolve(__require.resolve("wxt"), "../..");
|
|
1926
|
+
}
|
|
1921
1927
|
|
|
1922
1928
|
// src/core/utils/building/group-entrypoints.ts
|
|
1923
1929
|
function groupEntrypoints(entrypoints) {
|
|
@@ -2007,8 +2013,8 @@ async function importEntrypointFile(path7) {
|
|
|
2007
2013
|
esmResolve: true,
|
|
2008
2014
|
alias: {
|
|
2009
2015
|
"webextension-polyfill": resolve10(
|
|
2010
|
-
wxt.config.
|
|
2011
|
-
"
|
|
2016
|
+
wxt.config.wxtModuleDir,
|
|
2017
|
+
"dist/virtual/mock-browser.js"
|
|
2012
2018
|
)
|
|
2013
2019
|
},
|
|
2014
2020
|
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
__require
|
|
11
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-73I7FAJU.js";
|
|
3
5
|
|
|
4
6
|
// src/cli/commands.ts
|
|
5
7
|
import cac from "cac";
|
|
@@ -932,8 +934,8 @@ var reactRefreshPreamble = "";
|
|
|
932
934
|
function devHtmlPrerender(config) {
|
|
933
935
|
const htmlReloadId = "@wxt/reload-html";
|
|
934
936
|
const resolvedHtmlReloadId = resolve6(
|
|
935
|
-
config.
|
|
936
|
-
"
|
|
937
|
+
config.wxtModuleDir,
|
|
938
|
+
"dist/virtual/reload-html.js"
|
|
937
939
|
);
|
|
938
940
|
const virtualReactRefreshId = "@wxt/virtual-react-refresh";
|
|
939
941
|
const resolvedVirtualReactRefreshId = "\0" + virtualReactRefreshId;
|
|
@@ -1278,10 +1280,7 @@ function virtualEntrypoint(type, config) {
|
|
|
1278
1280
|
return;
|
|
1279
1281
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
1280
1282
|
const template = await fs7.readFile(
|
|
1281
|
-
resolve8(
|
|
1282
|
-
config.root,
|
|
1283
|
-
`node_modules/wxt/dist/virtual/${type}-entrypoint.js`
|
|
1284
|
-
),
|
|
1283
|
+
resolve8(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
|
|
1285
1284
|
"utf-8"
|
|
1286
1285
|
);
|
|
1287
1286
|
return template.replace(`virtual:user-${type}`, inputPath);
|
|
@@ -1702,6 +1701,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1702
1701
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
1703
1702
|
);
|
|
1704
1703
|
const wxtDir = path4.resolve(root, ".wxt");
|
|
1704
|
+
const wxtModuleDir = resolveWxtModuleDir();
|
|
1705
1705
|
const srcDir = path4.resolve(root, mergedConfig.srcDir ?? root);
|
|
1706
1706
|
const entrypointsDir = path4.resolve(
|
|
1707
1707
|
srcDir,
|
|
@@ -1752,6 +1752,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1752
1752
|
outBaseDir,
|
|
1753
1753
|
outDir,
|
|
1754
1754
|
publicDir,
|
|
1755
|
+
wxtModuleDir,
|
|
1755
1756
|
root,
|
|
1756
1757
|
runnerConfig,
|
|
1757
1758
|
srcDir,
|
|
@@ -1918,6 +1919,9 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1918
1919
|
defaultOptions
|
|
1919
1920
|
);
|
|
1920
1921
|
}
|
|
1922
|
+
function resolveWxtModuleDir() {
|
|
1923
|
+
return path4.resolve(__require.resolve("wxt"), "../..");
|
|
1924
|
+
}
|
|
1921
1925
|
|
|
1922
1926
|
// src/core/utils/building/group-entrypoints.ts
|
|
1923
1927
|
function groupEntrypoints(entrypoints) {
|
|
@@ -2007,8 +2011,8 @@ async function importEntrypointFile(path8) {
|
|
|
2007
2011
|
esmResolve: true,
|
|
2008
2012
|
alias: {
|
|
2009
2013
|
"webextension-polyfill": resolve10(
|
|
2010
|
-
wxt.config.
|
|
2011
|
-
"
|
|
2014
|
+
wxt.config.wxtModuleDir,
|
|
2015
|
+
"dist/virtual/mock-browser.js"
|
|
2012
2016
|
)
|
|
2013
2017
|
},
|
|
2014
2018
|
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
@@ -2181,7 +2185,7 @@ function getChunkSortWeight(filename) {
|
|
|
2181
2185
|
import pc4 from "picocolors";
|
|
2182
2186
|
|
|
2183
2187
|
// package.json
|
|
2184
|
-
var version = "0.17.
|
|
2188
|
+
var version = "0.17.4-alpha1";
|
|
2185
2189
|
|
|
2186
2190
|
// src/core/utils/log/printHeader.ts
|
|
2187
2191
|
import { consola as consola2 } from "consola";
|
package/dist/client.d.ts
CHANGED
|
@@ -13,6 +13,29 @@ declare class WxtLocationChangeEvent extends Event {
|
|
|
13
13
|
*
|
|
14
14
|
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
15
15
|
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
16
|
+
*
|
|
17
|
+
* To create context for testing, you can use the class's constructor:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { ContentScriptContext } from 'wxt/client';
|
|
21
|
+
*
|
|
22
|
+
* test("storage listener should be removed when context is invalidated", () => {
|
|
23
|
+
* const ctx = new ContentScriptContext('test');
|
|
24
|
+
* const item = storage.defineItem("local:count", { defaultValue: 0 });
|
|
25
|
+
* const watcher = vi.fn();
|
|
26
|
+
*
|
|
27
|
+
* const unwatch = item.watch(watcher);
|
|
28
|
+
* ctx.onInvalidated(unwatch); // Listen for invalidate here
|
|
29
|
+
*
|
|
30
|
+
* await item.setValue(1);
|
|
31
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
32
|
+
* expect(watcher).toBeCalledWith(1, 0);
|
|
33
|
+
*
|
|
34
|
+
* ctx.notifyInvalidated(); // Use this function to invalidate the context
|
|
35
|
+
* await item.setValue(2);
|
|
36
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
16
39
|
*/
|
|
17
40
|
declare class ContentScriptContext implements AbortController {
|
|
18
41
|
#private;
|
|
@@ -20,6 +20,29 @@ declare class WxtLocationChangeEvent extends Event {
|
|
|
20
20
|
*
|
|
21
21
|
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
22
22
|
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
23
|
+
*
|
|
24
|
+
* To create context for testing, you can use the class's constructor:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { ContentScriptContext } from 'wxt/client';
|
|
28
|
+
*
|
|
29
|
+
* test("storage listener should be removed when context is invalidated", () => {
|
|
30
|
+
* const ctx = new ContentScriptContext('test');
|
|
31
|
+
* const item = storage.defineItem("local:count", { defaultValue: 0 });
|
|
32
|
+
* const watcher = vi.fn();
|
|
33
|
+
*
|
|
34
|
+
* const unwatch = item.watch(watcher);
|
|
35
|
+
* ctx.onInvalidated(unwatch); // Listen for invalidate here
|
|
36
|
+
*
|
|
37
|
+
* await item.setValue(1);
|
|
38
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
39
|
+
* expect(watcher).toBeCalledWith(1, 0);
|
|
40
|
+
*
|
|
41
|
+
* ctx.notifyInvalidated(); // Use this function to invalidate the context
|
|
42
|
+
* await item.setValue(2);
|
|
43
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
23
46
|
*/
|
|
24
47
|
declare class ContentScriptContext implements AbortController {
|
|
25
48
|
#private;
|
|
@@ -953,6 +976,10 @@ interface ResolvedConfig {
|
|
|
953
976
|
outBaseDir: string;
|
|
954
977
|
outDir: string;
|
|
955
978
|
debug: boolean;
|
|
979
|
+
/**
|
|
980
|
+
* Directory pointing to `node_modules/wxt`, wherever WXT is installed.
|
|
981
|
+
*/
|
|
982
|
+
wxtModuleDir: string;
|
|
956
983
|
mode: string;
|
|
957
984
|
command: 'build' | 'serve';
|
|
958
985
|
browser: TargetBrowser;
|
|
@@ -20,6 +20,29 @@ declare class WxtLocationChangeEvent extends Event {
|
|
|
20
20
|
*
|
|
21
21
|
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
22
22
|
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
23
|
+
*
|
|
24
|
+
* To create context for testing, you can use the class's constructor:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { ContentScriptContext } from 'wxt/client';
|
|
28
|
+
*
|
|
29
|
+
* test("storage listener should be removed when context is invalidated", () => {
|
|
30
|
+
* const ctx = new ContentScriptContext('test');
|
|
31
|
+
* const item = storage.defineItem("local:count", { defaultValue: 0 });
|
|
32
|
+
* const watcher = vi.fn();
|
|
33
|
+
*
|
|
34
|
+
* const unwatch = item.watch(watcher);
|
|
35
|
+
* ctx.onInvalidated(unwatch); // Listen for invalidate here
|
|
36
|
+
*
|
|
37
|
+
* await item.setValue(1);
|
|
38
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
39
|
+
* expect(watcher).toBeCalledWith(1, 0);
|
|
40
|
+
*
|
|
41
|
+
* ctx.notifyInvalidated(); // Use this function to invalidate the context
|
|
42
|
+
* await item.setValue(2);
|
|
43
|
+
* expect(watcher).toBeCalledTimes(1);
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
23
46
|
*/
|
|
24
47
|
declare class ContentScriptContext implements AbortController {
|
|
25
48
|
#private;
|
|
@@ -953,6 +976,10 @@ interface ResolvedConfig {
|
|
|
953
976
|
outBaseDir: string;
|
|
954
977
|
outDir: string;
|
|
955
978
|
debug: boolean;
|
|
979
|
+
/**
|
|
980
|
+
* Directory pointing to `node_modules/wxt`, wherever WXT is installed.
|
|
981
|
+
*/
|
|
982
|
+
wxtModuleDir: string;
|
|
956
983
|
mode: string;
|
|
957
984
|
command: 'build' | 'serve';
|
|
958
985
|
browser: TargetBrowser;
|
package/dist/index.cjs
CHANGED
|
@@ -970,8 +970,8 @@ var reactRefreshPreamble = "";
|
|
|
970
970
|
function devHtmlPrerender(config) {
|
|
971
971
|
const htmlReloadId = "@wxt/reload-html";
|
|
972
972
|
const resolvedHtmlReloadId = (0, import_node_path4.resolve)(
|
|
973
|
-
config.
|
|
974
|
-
"
|
|
973
|
+
config.wxtModuleDir,
|
|
974
|
+
"dist/virtual/reload-html.js"
|
|
975
975
|
);
|
|
976
976
|
const virtualReactRefreshId = "@wxt/virtual-react-refresh";
|
|
977
977
|
const resolvedVirtualReactRefreshId = "\0" + virtualReactRefreshId;
|
|
@@ -1316,10 +1316,7 @@ function virtualEntrypoint(type, config) {
|
|
|
1316
1316
|
return;
|
|
1317
1317
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
1318
1318
|
const template = await import_fs_extra7.default.readFile(
|
|
1319
|
-
(0, import_path6.resolve)(
|
|
1320
|
-
config.root,
|
|
1321
|
-
`node_modules/wxt/dist/virtual/${type}-entrypoint.js`
|
|
1322
|
-
),
|
|
1319
|
+
(0, import_path6.resolve)(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
|
|
1323
1320
|
"utf-8"
|
|
1324
1321
|
);
|
|
1325
1322
|
return template.replace(`virtual:user-${type}`, inputPath);
|
|
@@ -1743,6 +1740,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1743
1740
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
1744
1741
|
);
|
|
1745
1742
|
const wxtDir = import_node_path9.default.resolve(root, ".wxt");
|
|
1743
|
+
const wxtModuleDir = resolveWxtModuleDir();
|
|
1746
1744
|
const srcDir = import_node_path9.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
1747
1745
|
const entrypointsDir = import_node_path9.default.resolve(
|
|
1748
1746
|
srcDir,
|
|
@@ -1793,6 +1791,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1793
1791
|
outBaseDir,
|
|
1794
1792
|
outDir,
|
|
1795
1793
|
publicDir,
|
|
1794
|
+
wxtModuleDir,
|
|
1796
1795
|
root,
|
|
1797
1796
|
runnerConfig,
|
|
1798
1797
|
srcDir,
|
|
@@ -1959,6 +1958,9 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1959
1958
|
defaultOptions
|
|
1960
1959
|
);
|
|
1961
1960
|
}
|
|
1961
|
+
function resolveWxtModuleDir() {
|
|
1962
|
+
return import_node_path9.default.resolve(require.resolve("wxt"), "../..");
|
|
1963
|
+
}
|
|
1962
1964
|
|
|
1963
1965
|
// src/core/utils/building/group-entrypoints.ts
|
|
1964
1966
|
function groupEntrypoints(entrypoints) {
|
|
@@ -2049,8 +2051,8 @@ async function importEntrypointFile(path9) {
|
|
|
2049
2051
|
esmResolve: true,
|
|
2050
2052
|
alias: {
|
|
2051
2053
|
"webextension-polyfill": (0, import_node_path10.resolve)(
|
|
2052
|
-
wxt.config.
|
|
2053
|
-
"
|
|
2054
|
+
wxt.config.wxtModuleDir,
|
|
2055
|
+
"dist/virtual/mock-browser.js"
|
|
2054
2056
|
)
|
|
2055
2057
|
},
|
|
2056
2058
|
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
@@ -2223,7 +2225,7 @@ function getChunkSortWeight(filename) {
|
|
|
2223
2225
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
2224
2226
|
|
|
2225
2227
|
// package.json
|
|
2226
|
-
var version = "0.17.
|
|
2228
|
+
var version = "0.17.4-alpha1";
|
|
2227
2229
|
|
|
2228
2230
|
// src/core/utils/log/printHeader.ts
|
|
2229
2231
|
var import_consola2 = require("consola");
|
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 './index-
|
|
2
|
-
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-vpYNIeCJ.cjs';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-vpYNIeCJ.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -64,6 +64,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
64
64
|
*/
|
|
65
65
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
66
|
|
|
67
|
-
var version = "0.17.
|
|
67
|
+
var version = "0.17.4-alpha1";
|
|
68
68
|
|
|
69
69
|
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 './index-
|
|
2
|
-
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-vpYNIeCJ.js';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, p as Entrypoint, q as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, Z as ExtensionRunner, Y as FsCache, G as GenericEntrypoint, N as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, X as ResolvedConfig, a1 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, K as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, _ as VirtualEntrypointType, V as Wxt, H as WxtBuilder, J as WxtBuilderServer, Q as WxtHooks, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-vpYNIeCJ.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -64,6 +64,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
64
64
|
*/
|
|
65
65
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
66
|
|
|
67
|
-
var version = "0.17.
|
|
67
|
+
var version = "0.17.4-alpha1";
|
|
68
68
|
|
|
69
69
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-
|
|
1
|
+
import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-mYGv2dqk.js';
|
|
2
2
|
export * from '@webext-core/match-patterns';
|
|
3
3
|
import 'webextension-polyfill';
|
|
4
4
|
|
package/dist/storage.cjs
CHANGED
|
@@ -272,14 +272,14 @@ function createStorage() {
|
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
const migrate = async () => {
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
const driverMetaKey = getMetaKey(driverKey);
|
|
276
|
+
const [{ value }, { value: meta }] = await driver.getItems([
|
|
277
|
+
driverKey,
|
|
278
|
+
driverMetaKey
|
|
279
279
|
]);
|
|
280
280
|
if (value == null)
|
|
281
281
|
return;
|
|
282
|
-
const currentVersion = meta
|
|
282
|
+
const currentVersion = meta?.v ?? 1;
|
|
283
283
|
if (currentVersion > targetVersion) {
|
|
284
284
|
throw Error(
|
|
285
285
|
`Version downgrade detected (v${currentVersion} -> v${targetVersion}) for "${key}"`
|
|
@@ -296,36 +296,47 @@ function createStorage() {
|
|
|
296
296
|
for (const migrateToVersion of migrationsToRun) {
|
|
297
297
|
migratedValue = await migrations?.[migrateToVersion]?.(migratedValue) ?? migratedValue;
|
|
298
298
|
}
|
|
299
|
-
await
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
setMeta(driver, driverKey, { v: targetVersion })
|
|
299
|
+
await driver.setItems([
|
|
300
|
+
{ key: driverKey, value: migratedValue },
|
|
301
|
+
{ key: driverMetaKey, value: { ...meta, v: targetVersion } }
|
|
303
302
|
]);
|
|
304
303
|
logger.debug(
|
|
305
304
|
`Storage migration completed for ${key} v${targetVersion}`,
|
|
306
305
|
{ migratedValue }
|
|
307
306
|
);
|
|
308
307
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return;
|
|
312
|
-
try {
|
|
313
|
-
await migrate();
|
|
314
|
-
} catch (err) {
|
|
315
|
-
logger.error(`Migration failed for ${key}`, err);
|
|
316
|
-
}
|
|
308
|
+
const migrationsDone = opts?.migrations == null ? Promise.resolve() : migrate().catch((err) => {
|
|
309
|
+
logger.error(`Migration failed for ${key}`, err);
|
|
317
310
|
});
|
|
318
311
|
const getDefaultValue = () => opts?.defaultValue ?? null;
|
|
319
312
|
return {
|
|
320
313
|
get defaultValue() {
|
|
321
314
|
return getDefaultValue();
|
|
322
315
|
},
|
|
323
|
-
getValue: () =>
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
316
|
+
getValue: async () => {
|
|
317
|
+
await migrationsDone;
|
|
318
|
+
return await getItem(driver, driverKey, opts);
|
|
319
|
+
},
|
|
320
|
+
getMeta: async () => {
|
|
321
|
+
await migrationsDone;
|
|
322
|
+
return await getMeta(driver, driverKey);
|
|
323
|
+
},
|
|
324
|
+
setValue: async (value) => {
|
|
325
|
+
await migrationsDone;
|
|
326
|
+
return await setItem(driver, driverKey, value);
|
|
327
|
+
},
|
|
328
|
+
setMeta: async (properties) => {
|
|
329
|
+
await migrationsDone;
|
|
330
|
+
return await setMeta(driver, driverKey, properties);
|
|
331
|
+
},
|
|
332
|
+
removeValue: async (opts2) => {
|
|
333
|
+
await migrationsDone;
|
|
334
|
+
return await removeItem(driver, driverKey, opts2);
|
|
335
|
+
},
|
|
336
|
+
removeMeta: async (properties) => {
|
|
337
|
+
await migrationsDone;
|
|
338
|
+
return await removeMeta(driver, driverKey, properties);
|
|
339
|
+
},
|
|
329
340
|
watch: (cb) => watch(
|
|
330
341
|
driver,
|
|
331
342
|
driverKey,
|
|
@@ -353,7 +364,10 @@ function createDriver(storageArea) {
|
|
|
353
364
|
"You must add the 'storage' permission to your manifest to use 'wxt/storage'"
|
|
354
365
|
);
|
|
355
366
|
}
|
|
356
|
-
|
|
367
|
+
const area = browser.storage[storageArea];
|
|
368
|
+
if (area == null)
|
|
369
|
+
throw Error(`"browser.storage.${storageArea}" is undefined`);
|
|
370
|
+
return area;
|
|
357
371
|
};
|
|
358
372
|
const watchListeners = /* @__PURE__ */ new Set();
|
|
359
373
|
return {
|
package/dist/storage.d.cts
CHANGED
|
@@ -8,7 +8,8 @@ interface WxtStorage {
|
|
|
8
8
|
*/
|
|
9
9
|
getItem<T>(key: string, opts?: GetItemOptions<T>): Promise<T | null>;
|
|
10
10
|
/**
|
|
11
|
-
* Get multiple items from storage.
|
|
11
|
+
* Get multiple items from storage. The return order is guaranteed to be the same as the order
|
|
12
|
+
* requested.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* await storage.getItems(["local:installDate", "session:someCounter"]);
|
package/dist/storage.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ interface WxtStorage {
|
|
|
8
8
|
*/
|
|
9
9
|
getItem<T>(key: string, opts?: GetItemOptions<T>): Promise<T | null>;
|
|
10
10
|
/**
|
|
11
|
-
* Get multiple items from storage.
|
|
11
|
+
* Get multiple items from storage. The return order is guaranteed to be the same as the order
|
|
12
|
+
* requested.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* await storage.getItems(["local:installDate", "session:someCounter"]);
|
package/dist/storage.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./chunk-P57PW2II.js";
|
|
2
|
+
|
|
1
3
|
// src/browser.ts
|
|
2
4
|
import originalBrowser from "webextension-polyfill";
|
|
3
5
|
var browser = originalBrowser;
|
|
@@ -235,14 +237,14 @@ function createStorage() {
|
|
|
235
237
|
);
|
|
236
238
|
}
|
|
237
239
|
const migrate = async () => {
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
const driverMetaKey = getMetaKey(driverKey);
|
|
241
|
+
const [{ value }, { value: meta }] = await driver.getItems([
|
|
242
|
+
driverKey,
|
|
243
|
+
driverMetaKey
|
|
242
244
|
]);
|
|
243
245
|
if (value == null)
|
|
244
246
|
return;
|
|
245
|
-
const currentVersion = meta
|
|
247
|
+
const currentVersion = meta?.v ?? 1;
|
|
246
248
|
if (currentVersion > targetVersion) {
|
|
247
249
|
throw Error(
|
|
248
250
|
`Version downgrade detected (v${currentVersion} -> v${targetVersion}) for "${key}"`
|
|
@@ -259,36 +261,47 @@ function createStorage() {
|
|
|
259
261
|
for (const migrateToVersion of migrationsToRun) {
|
|
260
262
|
migratedValue = await migrations?.[migrateToVersion]?.(migratedValue) ?? migratedValue;
|
|
261
263
|
}
|
|
262
|
-
await
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
setMeta(driver, driverKey, { v: targetVersion })
|
|
264
|
+
await driver.setItems([
|
|
265
|
+
{ key: driverKey, value: migratedValue },
|
|
266
|
+
{ key: driverMetaKey, value: { ...meta, v: targetVersion } }
|
|
266
267
|
]);
|
|
267
268
|
logger.debug(
|
|
268
269
|
`Storage migration completed for ${key} v${targetVersion}`,
|
|
269
270
|
{ migratedValue }
|
|
270
271
|
);
|
|
271
272
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return;
|
|
275
|
-
try {
|
|
276
|
-
await migrate();
|
|
277
|
-
} catch (err) {
|
|
278
|
-
logger.error(`Migration failed for ${key}`, err);
|
|
279
|
-
}
|
|
273
|
+
const migrationsDone = opts?.migrations == null ? Promise.resolve() : migrate().catch((err) => {
|
|
274
|
+
logger.error(`Migration failed for ${key}`, err);
|
|
280
275
|
});
|
|
281
276
|
const getDefaultValue = () => opts?.defaultValue ?? null;
|
|
282
277
|
return {
|
|
283
278
|
get defaultValue() {
|
|
284
279
|
return getDefaultValue();
|
|
285
280
|
},
|
|
286
|
-
getValue: () =>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
281
|
+
getValue: async () => {
|
|
282
|
+
await migrationsDone;
|
|
283
|
+
return await getItem(driver, driverKey, opts);
|
|
284
|
+
},
|
|
285
|
+
getMeta: async () => {
|
|
286
|
+
await migrationsDone;
|
|
287
|
+
return await getMeta(driver, driverKey);
|
|
288
|
+
},
|
|
289
|
+
setValue: async (value) => {
|
|
290
|
+
await migrationsDone;
|
|
291
|
+
return await setItem(driver, driverKey, value);
|
|
292
|
+
},
|
|
293
|
+
setMeta: async (properties) => {
|
|
294
|
+
await migrationsDone;
|
|
295
|
+
return await setMeta(driver, driverKey, properties);
|
|
296
|
+
},
|
|
297
|
+
removeValue: async (opts2) => {
|
|
298
|
+
await migrationsDone;
|
|
299
|
+
return await removeItem(driver, driverKey, opts2);
|
|
300
|
+
},
|
|
301
|
+
removeMeta: async (properties) => {
|
|
302
|
+
await migrationsDone;
|
|
303
|
+
return await removeMeta(driver, driverKey, properties);
|
|
304
|
+
},
|
|
292
305
|
watch: (cb) => watch(
|
|
293
306
|
driver,
|
|
294
307
|
driverKey,
|
|
@@ -316,7 +329,10 @@ function createDriver(storageArea) {
|
|
|
316
329
|
"You must add the 'storage' permission to your manifest to use 'wxt/storage'"
|
|
317
330
|
);
|
|
318
331
|
}
|
|
319
|
-
|
|
332
|
+
const area = browser.storage[storageArea];
|
|
333
|
+
if (area == null)
|
|
334
|
+
throw Error(`"browser.storage.${storageArea}" is undefined`);
|
|
335
|
+
return area;
|
|
320
336
|
};
|
|
321
337
|
const watchListeners = /* @__PURE__ */ new Set();
|
|
322
338
|
return {
|
package/dist/testing.cjs
CHANGED
|
@@ -75,8 +75,8 @@ var reactRefreshPreamble = "";
|
|
|
75
75
|
function devHtmlPrerender(config) {
|
|
76
76
|
const htmlReloadId = "@wxt/reload-html";
|
|
77
77
|
const resolvedHtmlReloadId = (0, import_node_path3.resolve)(
|
|
78
|
-
config.
|
|
79
|
-
"
|
|
78
|
+
config.wxtModuleDir,
|
|
79
|
+
"dist/virtual/reload-html.js"
|
|
80
80
|
);
|
|
81
81
|
const virtualReactRefreshId = "@wxt/virtual-react-refresh";
|
|
82
82
|
const resolvedVirtualReactRefreshId = "\0" + virtualReactRefreshId;
|
|
@@ -412,10 +412,7 @@ function virtualEntrypoint(type, config) {
|
|
|
412
412
|
return;
|
|
413
413
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
414
414
|
const template = await import_fs_extra2.default.readFile(
|
|
415
|
-
(0, import_path2.resolve)(
|
|
416
|
-
config.root,
|
|
417
|
-
`node_modules/wxt/dist/virtual/${type}-entrypoint.js`
|
|
418
|
-
),
|
|
415
|
+
(0, import_path2.resolve)(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
|
|
419
416
|
"utf-8"
|
|
420
417
|
);
|
|
421
418
|
return template.replace(`virtual:user-${type}`, inputPath);
|
|
@@ -579,8 +576,8 @@ function webextensionPolyfillMock(config) {
|
|
|
579
576
|
alias: {
|
|
580
577
|
// Alias to use a mocked version of the polyfill
|
|
581
578
|
"webextension-polyfill": import_node_path6.default.resolve(
|
|
582
|
-
config.
|
|
583
|
-
"
|
|
579
|
+
config.wxtModuleDir,
|
|
580
|
+
"dist/virtual/mock-browser"
|
|
584
581
|
)
|
|
585
582
|
}
|
|
586
583
|
},
|
|
@@ -1008,6 +1005,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1008
1005
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
1009
1006
|
);
|
|
1010
1007
|
const wxtDir = import_node_path9.default.resolve(root, ".wxt");
|
|
1008
|
+
const wxtModuleDir = resolveWxtModuleDir();
|
|
1011
1009
|
const srcDir = import_node_path9.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
1012
1010
|
const entrypointsDir = import_node_path9.default.resolve(
|
|
1013
1011
|
srcDir,
|
|
@@ -1058,6 +1056,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
1058
1056
|
outBaseDir,
|
|
1059
1057
|
outDir,
|
|
1060
1058
|
publicDir,
|
|
1059
|
+
wxtModuleDir,
|
|
1061
1060
|
root,
|
|
1062
1061
|
runnerConfig,
|
|
1063
1062
|
srcDir,
|
|
@@ -1224,6 +1223,9 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
1224
1223
|
defaultOptions
|
|
1225
1224
|
);
|
|
1226
1225
|
}
|
|
1226
|
+
function resolveWxtModuleDir() {
|
|
1227
|
+
return import_node_path9.default.resolve(require.resolve("wxt"), "../..");
|
|
1228
|
+
}
|
|
1227
1229
|
|
|
1228
1230
|
// src/core/utils/building/import-entrypoint.ts
|
|
1229
1231
|
var import_jiti = __toESM(require("jiti"), 1);
|
package/dist/testing.d.cts
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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-vpYNIeCJ.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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-vpYNIeCJ.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED