wxt 0.18.3 → 0.18.5
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-XAYX5BXI.js → chunk-7AOGIMIM.js} +145 -21
- package/dist/cli.js +153 -32
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1 -1
- package/dist/execa-5TSWMF32.js +6190 -0
- package/dist/execa-QQUOQNS3.js +6191 -0
- package/dist/{index-CiL7hzu6.d.ts → index-Bk-a0SkY.d.ts} +2 -1
- package/dist/{index-xOGXP3vY.d.cts → index-q2ZwJBs6.d.cts} +89 -5
- package/dist/{index-xOGXP3vY.d.ts → index-q2ZwJBs6.d.ts} +89 -5
- package/dist/index.cjs +6299 -1478
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -7
- package/dist/modules.cjs +88 -0
- package/dist/modules.d.cts +91 -0
- package/dist/modules.d.ts +91 -0
- package/dist/modules.js +51 -0
- package/dist/sandbox.d.ts +4 -2
- package/dist/sandbox.js +7 -1
- package/dist/storage.d.cts +20 -18
- package/dist/storage.d.ts +20 -18
- package/dist/testing.cjs +57 -3
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/background-entrypoint.js +2 -0
- package/dist/virtual/content-script-isolated-world-entrypoint.js +2 -0
- package/dist/virtual/content-script-main-world-entrypoint.js +2 -0
- package/dist/virtual/unlisted-script-entrypoint.js +2 -0
- package/package.json +15 -10
- package/dist/execa-6HO2IY2B.js +0 -2192
- package/dist/execa-VDW6HLFV.js +0 -2191
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 { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, 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-q2ZwJBs6.cjs';
|
|
2
|
+
export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, a9 as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a4 as WxtPackageManager, aa as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-q2ZwJBs6.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.18.
|
|
68
|
+
var version = "0.18.5";
|
|
69
69
|
|
|
70
70
|
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 { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, 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-q2ZwJBs6.js';
|
|
2
|
+
export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, a9 as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a4 as WxtPackageManager, aa as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-q2ZwJBs6.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.18.
|
|
68
|
+
var version = "0.18.5";
|
|
69
69
|
|
|
70
70
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
unnormalizePath,
|
|
20
20
|
version,
|
|
21
21
|
wxt
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7AOGIMIM.js";
|
|
23
23
|
import "./chunk-5X3S6AWF.js";
|
|
24
24
|
import {
|
|
25
25
|
consola
|
|
@@ -614,13 +614,10 @@ async function zipDir(directory, outputPath, options) {
|
|
|
614
614
|
cwd: directory,
|
|
615
615
|
// Ignore node_modules, otherwise this glob step takes forever
|
|
616
616
|
ignore: ["**/node_modules"],
|
|
617
|
-
onlyFiles: true
|
|
617
|
+
onlyFiles: true,
|
|
618
|
+
dot: true
|
|
618
619
|
})).filter((relativePath) => {
|
|
619
|
-
return
|
|
620
|
-
(pattern) => minimatch(relativePath, pattern)
|
|
621
|
-
) || !wxt.config.zip.excludeSources.some(
|
|
622
|
-
(pattern) => minimatch(relativePath, pattern)
|
|
623
|
-
);
|
|
620
|
+
return options?.include?.some((pattern) => minimatch(relativePath, pattern)) || !options?.exclude?.some((pattern) => minimatch(relativePath, pattern));
|
|
624
621
|
});
|
|
625
622
|
const filesToZip = [
|
|
626
623
|
...files,
|
package/dist/modules.cjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/modules.ts
|
|
31
|
+
var modules_exports = {};
|
|
32
|
+
__export(modules_exports, {
|
|
33
|
+
addEntrypoint: () => addEntrypoint,
|
|
34
|
+
addPublicAssets: () => addPublicAssets,
|
|
35
|
+
addViteConfig: () => addViteConfig,
|
|
36
|
+
addWxtPlugin: () => addWxtPlugin,
|
|
37
|
+
defineWxtModule: () => defineWxtModule
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(modules_exports);
|
|
40
|
+
var vite = __toESM(require("vite"), 1);
|
|
41
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
42
|
+
var import_node_path = require("path");
|
|
43
|
+
function defineWxtModule(module2) {
|
|
44
|
+
if (typeof module2 === "function")
|
|
45
|
+
return { setup: module2 };
|
|
46
|
+
return module2;
|
|
47
|
+
}
|
|
48
|
+
function addEntrypoint(wxt, entrypoint) {
|
|
49
|
+
wxt.hooks.hook("entrypoints:resolved", (wxt2, entrypoints) => {
|
|
50
|
+
entrypoints.push(entrypoint);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function addPublicAssets(wxt, dir) {
|
|
54
|
+
wxt.hooks.hook("build:publicAssets", async (wxt2, files) => {
|
|
55
|
+
const moreFiles = await (0, import_fast_glob.default)("**/*", { cwd: dir });
|
|
56
|
+
if (moreFiles.length === 0) {
|
|
57
|
+
wxt2.logger.warn("No files to copy in", dir);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
moreFiles.forEach((file) => {
|
|
61
|
+
files.unshift({ absoluteSrc: (0, import_node_path.resolve)(dir, file), relativeDest: file });
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function addViteConfig(wxt, viteConfig) {
|
|
66
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
67
|
+
const userVite = wxt2.config.vite;
|
|
68
|
+
wxt2.config.vite = (env) => vite.mergeConfig(
|
|
69
|
+
// Use config added by module as base
|
|
70
|
+
viteConfig(env) ?? {},
|
|
71
|
+
// Overwrite module config with user config
|
|
72
|
+
userVite(env)
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function addWxtPlugin(wxt, plugin) {
|
|
77
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
78
|
+
wxt2.config.plugins.push(plugin);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
addEntrypoint,
|
|
84
|
+
addPublicAssets,
|
|
85
|
+
addViteConfig,
|
|
86
|
+
addWxtPlugin,
|
|
87
|
+
defineWxtModule
|
|
88
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-q2ZwJBs6.cjs';
|
|
2
|
+
import * as vite from 'vite';
|
|
3
|
+
import 'webextension-polyfill';
|
|
4
|
+
import 'unimport';
|
|
5
|
+
import 'consola';
|
|
6
|
+
import '@aklinker1/rollup-plugin-visualizer';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
import 'c12';
|
|
9
|
+
import 'hookable';
|
|
10
|
+
import 'nypm';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Utilities for creating reusable, build-time modules for WXT.
|
|
14
|
+
*
|
|
15
|
+
* @module wxt/modules
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function defineWxtModule<TOptions extends WxtModuleOptions>(module: WxtModule<TOptions> | WxtModuleSetup<TOptions>): WxtModule<TOptions>;
|
|
19
|
+
/**
|
|
20
|
+
* Adds a TS/JS file as an entrypoint to the project. This file will be bundled
|
|
21
|
+
* along with the other entrypoints.
|
|
22
|
+
|
|
23
|
+
* If you're publishing the module to NPM, you should probably pre-build the
|
|
24
|
+
* entrypoint and use `addPublicAssets` instead to copy pre-bundled assets into
|
|
25
|
+
* the output directory. This will speed up project builds since it just has to
|
|
26
|
+
* copy some files instead of bundling them.
|
|
27
|
+
*
|
|
28
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
29
|
+
* @param entrypoint The entrypoint to be bundled along with the extension.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* export default defineWxtModule((wxt, options) => {
|
|
33
|
+
* addEntrypoint(wxt, {
|
|
34
|
+
* type: "unlisted-page",
|
|
35
|
+
* name: "changelog",
|
|
36
|
+
* inputPath: "wxt-module-changelog/index.html"
|
|
37
|
+
* outputDir: wxt.config.outputDir,
|
|
38
|
+
* options: {},
|
|
39
|
+
* });
|
|
40
|
+
* });
|
|
41
|
+
*/
|
|
42
|
+
declare function addEntrypoint(wxt: Wxt, entrypoint: Entrypoint): void;
|
|
43
|
+
/**
|
|
44
|
+
* Copy files inside a directory (as if it were the public directory) into the
|
|
45
|
+
* extension's output directory. The directory itself is not copied, just the
|
|
46
|
+
* files inside it. If a filename matches an existing one, it is ignored.
|
|
47
|
+
*
|
|
48
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
49
|
+
* @param dir The directory to copy.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* export default defineWxtModule((wxt, options) => {
|
|
53
|
+
* addPublicAssets(wxt, "./dist/prebundled");
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
declare function addPublicAssets(wxt: Wxt, dir: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Merge additional vite config for one or more entrypoint "groups" that make
|
|
59
|
+
* up individual builds. Config in the project's `wxt.config.ts` file takes
|
|
60
|
+
* precedence over any config added by this function.
|
|
61
|
+
*
|
|
62
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
63
|
+
* @param viteConfig A function that returns the vite config the module is
|
|
64
|
+
adding. Same format as `vite` in `wxt.config.ts`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* export default defineWxtModule((wxt, options) => {
|
|
68
|
+
* addViteConfig(wxt, () => ({
|
|
69
|
+
* build: {
|
|
70
|
+
* sourceMaps: true,
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
* });
|
|
74
|
+
*/
|
|
75
|
+
declare function addViteConfig(wxt: Wxt, viteConfig: (env: vite.ConfigEnv) => vite.UserConfig | undefined): void;
|
|
76
|
+
/**
|
|
77
|
+
* Add a runtime plugin to the project. In each entrypoint, before executing
|
|
78
|
+
* the `main` function, plugins are executed.
|
|
79
|
+
*
|
|
80
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
81
|
+
* @param plugin An import from an NPM module, or an absolute file path to the
|
|
82
|
+
* file to load at runtime.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* export default defineWxtModule((wxt) => {
|
|
86
|
+
* addWxtPlugin(wxt, "wxt-module-analytics/client-plugin");
|
|
87
|
+
* });
|
|
88
|
+
*/
|
|
89
|
+
declare function addWxtPlugin(wxt: Wxt, plugin: string): void;
|
|
90
|
+
|
|
91
|
+
export { addEntrypoint, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-q2ZwJBs6.js';
|
|
2
|
+
import * as vite from 'vite';
|
|
3
|
+
import 'webextension-polyfill';
|
|
4
|
+
import 'unimport';
|
|
5
|
+
import 'consola';
|
|
6
|
+
import '@aklinker1/rollup-plugin-visualizer';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
import 'c12';
|
|
9
|
+
import 'hookable';
|
|
10
|
+
import 'nypm';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Utilities for creating reusable, build-time modules for WXT.
|
|
14
|
+
*
|
|
15
|
+
* @module wxt/modules
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function defineWxtModule<TOptions extends WxtModuleOptions>(module: WxtModule<TOptions> | WxtModuleSetup<TOptions>): WxtModule<TOptions>;
|
|
19
|
+
/**
|
|
20
|
+
* Adds a TS/JS file as an entrypoint to the project. This file will be bundled
|
|
21
|
+
* along with the other entrypoints.
|
|
22
|
+
|
|
23
|
+
* If you're publishing the module to NPM, you should probably pre-build the
|
|
24
|
+
* entrypoint and use `addPublicAssets` instead to copy pre-bundled assets into
|
|
25
|
+
* the output directory. This will speed up project builds since it just has to
|
|
26
|
+
* copy some files instead of bundling them.
|
|
27
|
+
*
|
|
28
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
29
|
+
* @param entrypoint The entrypoint to be bundled along with the extension.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* export default defineWxtModule((wxt, options) => {
|
|
33
|
+
* addEntrypoint(wxt, {
|
|
34
|
+
* type: "unlisted-page",
|
|
35
|
+
* name: "changelog",
|
|
36
|
+
* inputPath: "wxt-module-changelog/index.html"
|
|
37
|
+
* outputDir: wxt.config.outputDir,
|
|
38
|
+
* options: {},
|
|
39
|
+
* });
|
|
40
|
+
* });
|
|
41
|
+
*/
|
|
42
|
+
declare function addEntrypoint(wxt: Wxt, entrypoint: Entrypoint): void;
|
|
43
|
+
/**
|
|
44
|
+
* Copy files inside a directory (as if it were the public directory) into the
|
|
45
|
+
* extension's output directory. The directory itself is not copied, just the
|
|
46
|
+
* files inside it. If a filename matches an existing one, it is ignored.
|
|
47
|
+
*
|
|
48
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
49
|
+
* @param dir The directory to copy.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* export default defineWxtModule((wxt, options) => {
|
|
53
|
+
* addPublicAssets(wxt, "./dist/prebundled");
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
declare function addPublicAssets(wxt: Wxt, dir: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Merge additional vite config for one or more entrypoint "groups" that make
|
|
59
|
+
* up individual builds. Config in the project's `wxt.config.ts` file takes
|
|
60
|
+
* precedence over any config added by this function.
|
|
61
|
+
*
|
|
62
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
63
|
+
* @param viteConfig A function that returns the vite config the module is
|
|
64
|
+
adding. Same format as `vite` in `wxt.config.ts`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* export default defineWxtModule((wxt, options) => {
|
|
68
|
+
* addViteConfig(wxt, () => ({
|
|
69
|
+
* build: {
|
|
70
|
+
* sourceMaps: true,
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
* });
|
|
74
|
+
*/
|
|
75
|
+
declare function addViteConfig(wxt: Wxt, viteConfig: (env: vite.ConfigEnv) => vite.UserConfig | undefined): void;
|
|
76
|
+
/**
|
|
77
|
+
* Add a runtime plugin to the project. In each entrypoint, before executing
|
|
78
|
+
* the `main` function, plugins are executed.
|
|
79
|
+
*
|
|
80
|
+
* @param wxt The wxt instance provided by the module's setup function.
|
|
81
|
+
* @param plugin An import from an NPM module, or an absolute file path to the
|
|
82
|
+
* file to load at runtime.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* export default defineWxtModule((wxt) => {
|
|
86
|
+
* addWxtPlugin(wxt, "wxt-module-analytics/client-plugin");
|
|
87
|
+
* });
|
|
88
|
+
*/
|
|
89
|
+
declare function addWxtPlugin(wxt: Wxt, plugin: string): void;
|
|
90
|
+
|
|
91
|
+
export { addEntrypoint, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
|
package/dist/modules.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "./chunk-VBXJIVYU.js";
|
|
2
|
+
|
|
3
|
+
// src/modules.ts
|
|
4
|
+
import * as vite from "vite";
|
|
5
|
+
import glob from "fast-glob";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
function defineWxtModule(module) {
|
|
8
|
+
if (typeof module === "function")
|
|
9
|
+
return { setup: module };
|
|
10
|
+
return module;
|
|
11
|
+
}
|
|
12
|
+
function addEntrypoint(wxt, entrypoint) {
|
|
13
|
+
wxt.hooks.hook("entrypoints:resolved", (wxt2, entrypoints) => {
|
|
14
|
+
entrypoints.push(entrypoint);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function addPublicAssets(wxt, dir) {
|
|
18
|
+
wxt.hooks.hook("build:publicAssets", async (wxt2, files) => {
|
|
19
|
+
const moreFiles = await glob("**/*", { cwd: dir });
|
|
20
|
+
if (moreFiles.length === 0) {
|
|
21
|
+
wxt2.logger.warn("No files to copy in", dir);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
moreFiles.forEach((file) => {
|
|
25
|
+
files.unshift({ absoluteSrc: resolve(dir, file), relativeDest: file });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function addViteConfig(wxt, viteConfig) {
|
|
30
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
31
|
+
const userVite = wxt2.config.vite;
|
|
32
|
+
wxt2.config.vite = (env) => vite.mergeConfig(
|
|
33
|
+
// Use config added by module as base
|
|
34
|
+
viteConfig(env) ?? {},
|
|
35
|
+
// Overwrite module config with user config
|
|
36
|
+
userVite(env)
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function addWxtPlugin(wxt, plugin) {
|
|
41
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
42
|
+
wxt2.config.plugins.push(plugin);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
addEntrypoint,
|
|
47
|
+
addPublicAssets,
|
|
48
|
+
addViteConfig,
|
|
49
|
+
addWxtPlugin,
|
|
50
|
+
defineWxtModule
|
|
51
|
+
};
|
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, W as WxtPlugin } from './index-Bk-a0SkY.js';
|
|
2
2
|
export * from '@webext-core/match-patterns';
|
|
3
3
|
import 'webextension-polyfill';
|
|
4
4
|
|
|
@@ -10,4 +10,6 @@ declare function defineBackground(definition: BackgroundDefinition): BackgroundD
|
|
|
10
10
|
|
|
11
11
|
declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
declare function defineWxtPlugin(plugin: WxtPlugin): WxtPlugin;
|
|
14
|
+
|
|
15
|
+
export { defineBackground, defineContentScript, defineUnlistedScript, defineWxtPlugin };
|
package/dist/sandbox.js
CHANGED
|
@@ -17,10 +17,16 @@ function defineContentScript(definition) {
|
|
|
17
17
|
return definition;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// src/sandbox/define-wxt-plugin.ts
|
|
21
|
+
function defineWxtPlugin(plugin) {
|
|
22
|
+
return plugin;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
// src/sandbox/index.ts
|
|
21
26
|
export * from "@webext-core/match-patterns";
|
|
22
27
|
export {
|
|
23
28
|
defineBackground,
|
|
24
29
|
defineContentScript,
|
|
25
|
-
defineUnlistedScript
|
|
30
|
+
defineUnlistedScript,
|
|
31
|
+
defineWxtPlugin
|
|
26
32
|
};
|
package/dist/storage.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ interface WxtStorage {
|
|
|
6
6
|
* @example
|
|
7
7
|
* await storage.getItem<number>("local:installDate");
|
|
8
8
|
*/
|
|
9
|
-
getItem<T>(key:
|
|
9
|
+
getItem<T>(key: StorageItemKey, opts?: GetItemOptions<T>): Promise<T | null>;
|
|
10
10
|
/**
|
|
11
11
|
* Get multiple items from storage. The return order is guaranteed to be the same as the order
|
|
12
12
|
* requested.
|
|
@@ -14,11 +14,11 @@ interface WxtStorage {
|
|
|
14
14
|
* @example
|
|
15
15
|
* await storage.getItems(["local:installDate", "session:someCounter"]);
|
|
16
16
|
*/
|
|
17
|
-
getItems(keys: Array<
|
|
18
|
-
key:
|
|
17
|
+
getItems(keys: Array<StorageItemKey | {
|
|
18
|
+
key: StorageItemKey;
|
|
19
19
|
options?: GetItemOptions<any>;
|
|
20
20
|
}>): Promise<Array<{
|
|
21
|
-
key:
|
|
21
|
+
key: StorageItemKey;
|
|
22
22
|
value: any;
|
|
23
23
|
}>>;
|
|
24
24
|
/**
|
|
@@ -28,7 +28,7 @@ interface WxtStorage {
|
|
|
28
28
|
* @example
|
|
29
29
|
* await storage.getMeta("local:installDate");
|
|
30
30
|
*/
|
|
31
|
-
getMeta<T extends Record<string, unknown>>(key:
|
|
31
|
+
getMeta<T extends Record<string, unknown>>(key: StorageItemKey): Promise<T>;
|
|
32
32
|
/**
|
|
33
33
|
* Set a value in storage. Setting a value to `null` or `undefined` is equivalent to calling
|
|
34
34
|
* `removeItem`.
|
|
@@ -36,7 +36,7 @@ interface WxtStorage {
|
|
|
36
36
|
* @example
|
|
37
37
|
* await storage.setItem<number>("local:installDate", Date.now());
|
|
38
38
|
*/
|
|
39
|
-
setItem<T>(key:
|
|
39
|
+
setItem<T>(key: StorageItemKey, value: T | null): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Set multiple values in storage. If a value is set to `null` or `undefined`, the key is removed.
|
|
42
42
|
*
|
|
@@ -47,7 +47,7 @@ interface WxtStorage {
|
|
|
47
47
|
* ]);
|
|
48
48
|
*/
|
|
49
49
|
setItems(values: Array<{
|
|
50
|
-
key:
|
|
50
|
+
key: StorageItemKey;
|
|
51
51
|
value: any;
|
|
52
52
|
}>): Promise<void>;
|
|
53
53
|
/**
|
|
@@ -57,19 +57,19 @@ interface WxtStorage {
|
|
|
57
57
|
* @example
|
|
58
58
|
* await storage.setMeta("local:installDate", { appVersion });
|
|
59
59
|
*/
|
|
60
|
-
setMeta<T extends Record<string, unknown>>(key:
|
|
60
|
+
setMeta<T extends Record<string, unknown>>(key: StorageItemKey, properties: T | null): Promise<void>;
|
|
61
61
|
/**
|
|
62
62
|
* Removes an item from storage.
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* await storage.removeItem("local:installDate");
|
|
66
66
|
*/
|
|
67
|
-
removeItem(key:
|
|
67
|
+
removeItem(key: StorageItemKey, opts?: RemoveItemOptions): Promise<void>;
|
|
68
68
|
/**
|
|
69
69
|
* Remove a list of keys from storage.
|
|
70
70
|
*/
|
|
71
|
-
removeItems(keys: Array<
|
|
72
|
-
key:
|
|
71
|
+
removeItems(keys: Array<StorageItemKey | {
|
|
72
|
+
key: StorageItemKey;
|
|
73
73
|
options?: RemoveItemOptions;
|
|
74
74
|
}>): Promise<void>;
|
|
75
75
|
/**
|
|
@@ -82,20 +82,20 @@ interface WxtStorage {
|
|
|
82
82
|
* // Remove only specific the "v" field
|
|
83
83
|
* await storage.removeMeta("local:installDate", "v")
|
|
84
84
|
*/
|
|
85
|
-
removeMeta(key:
|
|
85
|
+
removeMeta(key: StorageItemKey, properties?: string | string[]): Promise<void>;
|
|
86
86
|
/**
|
|
87
87
|
* Return all the items in storage.
|
|
88
88
|
*/
|
|
89
|
-
snapshot(base:
|
|
89
|
+
snapshot(base: StorageArea, opts?: SnapshotOptions): Promise<Record<string, unknown>>;
|
|
90
90
|
/**
|
|
91
91
|
* Restores the results of `snapshot`. If new properties have been saved since the snapshot, they are
|
|
92
92
|
* not overridden. Only values existing in the snapshot are overridden.
|
|
93
93
|
*/
|
|
94
|
-
restoreSnapshot(base:
|
|
94
|
+
restoreSnapshot(base: StorageArea, data: any): Promise<void>;
|
|
95
95
|
/**
|
|
96
96
|
* Watch for changes to a specific key in storage.
|
|
97
97
|
*/
|
|
98
|
-
watch<T>(key:
|
|
98
|
+
watch<T>(key: StorageItemKey, cb: WatchCallback<T | null>): Unwatch;
|
|
99
99
|
/**
|
|
100
100
|
* Remove all watch listeners.
|
|
101
101
|
*/
|
|
@@ -105,8 +105,8 @@ interface WxtStorage {
|
|
|
105
105
|
*
|
|
106
106
|
* Read full docs: https://wxt.dev/guide/storage.html#defining-storage-items
|
|
107
107
|
*/
|
|
108
|
-
defineItem<TValue, TMetadata extends Record<string, unknown> = {}>(key:
|
|
109
|
-
defineItem<TValue, TMetadata extends Record<string, unknown> = {}>(key:
|
|
108
|
+
defineItem<TValue, TMetadata extends Record<string, unknown> = {}>(key: StorageItemKey): WxtStorageItem<TValue | null, TMetadata>;
|
|
109
|
+
defineItem<TValue, TMetadata extends Record<string, unknown> = {}>(key: StorageItemKey, options: WxtStorageItemOptions<TValue>): WxtStorageItem<TValue, TMetadata>;
|
|
110
110
|
}
|
|
111
111
|
interface WxtStorageItem<TValue, TMetadata extends Record<string, unknown>> {
|
|
112
112
|
defaultValue: TValue;
|
|
@@ -146,6 +146,8 @@ interface WxtStorageItem<TValue, TMetadata extends Record<string, unknown>> {
|
|
|
146
146
|
*/
|
|
147
147
|
migrate(): Promise<void>;
|
|
148
148
|
}
|
|
149
|
+
type StorageArea = 'local' | 'session' | 'sync' | 'managed';
|
|
150
|
+
type StorageItemKey = `${StorageArea}:${string}`;
|
|
149
151
|
interface GetItemOptions<T> {
|
|
150
152
|
/**
|
|
151
153
|
* Value returned from `getValue` when it would otherwise return null.
|
|
@@ -195,4 +197,4 @@ type WatchCallback<T> = (newValue: T, oldValue: T) => void;
|
|
|
195
197
|
*/
|
|
196
198
|
type Unwatch = () => void;
|
|
197
199
|
|
|
198
|
-
export { type GetItemOptions, type NullablePartial, type RemoveItemOptions, type SnapshotOptions, type Unwatch, type WatchCallback, type WxtStorage, type WxtStorageItem, type WxtStorageItemOptions, storage };
|
|
200
|
+
export { type GetItemOptions, type NullablePartial, type RemoveItemOptions, type SnapshotOptions, type StorageArea, type StorageItemKey, type Unwatch, type WatchCallback, type WxtStorage, type WxtStorageItem, type WxtStorageItemOptions, storage };
|