wxt 0.21.4 → 0.21.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/README.md +1 -1
- package/dist/{core/build.d.mts → build.d.mts} +2 -2
- package/dist/{core/build.mjs → build.mjs} +3 -4
- package/dist/{core/clean.d.mts → clean.d.mts} +2 -2
- package/dist/{core/clean.mjs → clean.mjs} +3 -3
- package/dist/cli/cli-utils.mjs +6 -6
- package/dist/cli/commands.mjs +10 -9
- package/dist/{core/create-server.d.mts → create-server.d.mts} +2 -2
- package/dist/{core/create-server.mjs → create-server.mjs} +13 -14
- package/dist/define-config.d.mts +6 -0
- package/dist/{core/define-config.mjs → define-config.mjs} +1 -1
- package/dist/{core/define-web-ext-config.d.mts → define-web-ext-config.d.mts} +2 -2
- package/dist/{core/define-web-ext-config.mjs → define-web-ext-config.mjs} +1 -1
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +10 -11
- package/dist/{core/initialize.d.mts → initialize.d.mts} +2 -1
- package/dist/{core/initialize.mjs → initialize.mjs} +22 -7
- package/dist/inline/dotenv-expand/index.mjs +31 -0
- package/dist/{core/utils/building → internal}/build-entrypoints.mjs +5 -5
- package/dist/internal/builders/unknown.mjs +22 -0
- package/dist/{core → internal}/builders/vite/index.mjs +136 -138
- package/dist/internal/builders/vite/plugins/add-entrypoint-group-runtime-env-entries.mjs +16 -0
- package/dist/internal/builders/vite/plugins/add-runtime-env-entries.mjs +14 -0
- package/dist/{core/builders/vite/plugins/bundleAnalysis.mjs → internal/builders/vite/plugins/bundle-analysis.mjs} +1 -1
- package/dist/{core/builders/vite/plugins/cssEntrypoints.mjs → internal/builders/vite/plugins/css-entrypoints.mjs} +2 -2
- package/dist/{core/builders/vite/plugins/defineImportMeta.mjs → internal/builders/vite/plugins/define-import-meta.mjs} +1 -1
- package/dist/{core/builders/vite/plugins/devHtmlPrerender.mjs → internal/builders/vite/plugins/dev-html-prerender.mjs} +4 -5
- package/dist/{core/builders/vite/plugins/devServerGlobals.mjs → internal/builders/vite/plugins/dev-server-globals.mjs} +1 -1
- package/dist/{core/builders/vite/plugins/extensionApiMock.mjs → internal/builders/vite/plugins/extension-api-mock.mjs} +1 -1
- package/dist/{core/builders/vite/plugins/iifeAnonymous.mjs → internal/builders/vite/plugins/iife-anonymous.mjs} +1 -1
- package/dist/{core/builders/vite/plugins/iifeFooter.mjs → internal/builders/vite/plugins/iife-footer.mjs} +1 -1
- package/dist/internal/builders/vite/plugins/index.mjs +17 -0
- package/dist/{core/builders/vite/plugins/noopBackground.mjs → internal/builders/vite/plugins/noop-background.mjs} +2 -2
- package/dist/{core/builders/vite/plugins/removeEntrypointMainFunction.mjs → internal/builders/vite/plugins/remove-entrypoint-main-function.mjs} +3 -4
- package/dist/{core/builders/vite/plugins/resolveAppConfig.mjs → internal/builders/vite/plugins/resolve-app-config.mjs} +2 -2
- package/dist/{core/builders/vite/plugins/resolveVirtualModules.mjs → internal/builders/vite/plugins/resolve-virtual-modules.mjs} +8 -6
- package/dist/{core/builders/vite/plugins/tsconfigPaths.mjs → internal/builders/vite/plugins/tsconfig-paths.mjs} +1 -1
- package/dist/internal/builders/vite/plugins/wxt-plugin-loader.mjs +77 -0
- package/dist/{builtin-modules → internal/builtin-modules}/escape-unicode.mjs +2 -2
- package/dist/{builtin-modules → internal/builtin-modules}/favicon-permission.mjs +2 -2
- package/dist/{builtin-modules → internal/builtin-modules}/index.mjs +4 -2
- package/dist/internal/builtin-modules/plugins.mjs +21 -0
- package/dist/{builtin-modules → internal/builtin-modules}/unimport.mjs +17 -6
- package/dist/{core/utils → internal}/constants.mjs +1 -1
- package/dist/internal/detect-builder.mjs +9 -0
- package/dist/{core/utils/building → internal}/detect-dev-changes.mjs +4 -4
- package/dist/internal/detect-runner.mjs +11 -0
- package/dist/internal/entrypoint-finders/flat.mjs +84 -0
- package/dist/internal/environments/browser-environment.mjs +48 -0
- package/dist/{core/utils → internal}/environments/environment.mjs +1 -1
- package/dist/{core/utils → internal}/environments/extension-environment.mjs +1 -1
- package/dist/{core/utils/create-file-reloader.mjs → internal/file-reloader.mjs} +10 -11
- package/dist/{core/utils/building → internal}/find-entrypoints.mjs +8 -73
- package/dist/{core → internal}/generate-wxt-dir.mjs +10 -10
- package/dist/internal/get-public-files.mjs +14 -0
- package/dist/{core/utils/building → internal}/group-entrypoints.mjs +1 -1
- package/dist/{core/utils → internal}/i18n.mjs +1 -1
- package/dist/{core/utils/building → internal}/internal-build.mjs +10 -10
- package/dist/{core → internal}/keyboard-shortcuts.mjs +1 -1
- package/dist/{core/utils → internal}/manifest.mjs +9 -9
- package/dist/{core → internal}/package-managers/bun.mjs +1 -1
- package/dist/{core → internal}/package-managers/deno.mjs +1 -1
- package/dist/{core → internal}/package-managers/index.mjs +1 -1
- package/dist/{core → internal}/package-managers/npm.mjs +1 -1
- package/dist/{core → internal}/package-managers/pnpm.mjs +1 -1
- package/dist/{core → internal}/package-managers/yarn.mjs +1 -1
- package/dist/{core/utils → internal}/package.mjs +3 -3
- package/dist/{core/utils/building → internal}/rebuild.mjs +5 -5
- package/dist/{core → internal}/resolve-config.mjs +14 -32
- package/dist/internal/runners/manual.mjs +22 -0
- package/dist/internal/runners/web-ext.mjs +79 -0
- package/dist/{core/utils/globals.mjs → internal/runtime-env-entries.mjs} +4 -4
- package/dist/{core/utils → internal}/spinner.mjs +1 -1
- package/dist/{core/utils → internal}/syntax-errors.mjs +2 -2
- package/dist/{core/utils → internal}/theme-icons.mjs +3 -3
- package/dist/{core/utils → internal}/transform.mjs +1 -1
- package/dist/{core/utils → internal}/validation.mjs +1 -1
- package/dist/{core → internal}/wxt.mjs +24 -7
- package/dist/{core/utils/arrays.mjs → internal-utils/array-utils.mjs} +1 -1
- package/dist/{core/utils/cache.mjs → internal-utils/cache-utils.mjs} +3 -3
- package/dist/{core/utils/content-scripts.mjs → internal-utils/content-script-utils.mjs} +2 -2
- package/dist/{core/utils/content-security-policy.mjs → internal-utils/csp-utils.mjs} +1 -1
- package/dist/{core/utils/entrypoints.d.mts → internal-utils/entrypoint-utils.d.mts} +2 -2
- package/dist/{core/utils/entrypoints.mjs → internal-utils/entrypoint-utils.mjs} +2 -2
- package/dist/{core/utils/env.mjs → internal-utils/env-utils.mjs} +3 -3
- package/dist/internal-utils/eslint-utils.mjs +8 -0
- package/dist/{core/utils/fs.mjs → internal-utils/fs-utils.mjs} +2 -12
- package/dist/internal-utils/log/index.mjs +6 -0
- package/dist/{core/utils/log/printBuildSummary.mjs → internal-utils/log/print-build-summary.mjs} +3 -3
- package/dist/{core/utils/log/printFileList.mjs → internal-utils/log/print-file-list.mjs} +7 -6
- package/dist/{core/utils/log/printHeader.mjs → internal-utils/log/print-header.mjs} +2 -2
- package/dist/{core/utils/log/printTable.mjs → internal-utils/log/print-table.mjs} +1 -1
- package/dist/{core/utils/log/wxtLogger.mjs → internal-utils/log/wxt-logger.mjs} +1 -1
- package/dist/internal-utils/module-utils.mjs +32 -0
- package/dist/{core/utils/number.mjs → internal-utils/number-utils.mjs} +1 -1
- package/dist/{core/utils/paths.d.mts → internal-utils/path-utils.d.mts} +1 -1
- package/dist/{core/utils/paths.mjs → internal-utils/path-utils.mjs} +2 -2
- package/dist/{core/utils/strings.mjs → internal-utils/string-utils.mjs} +2 -2
- package/dist/{core/utils/time.mjs → internal-utils/time-utils.mjs} +1 -1
- package/dist/{core/utils/types.d.mts → internal-utils/type-utils.d.mts} +2 -1
- package/dist/{modules.d.mts → modules/index.d.mts} +10 -4
- package/dist/{modules.mjs → modules/index.mjs} +14 -5
- package/dist/prepare.d.mts +6 -0
- package/dist/prepare.mjs +11 -0
- package/dist/testing/wxt-vitest-plugin.mjs +7 -7
- package/dist/types.d.mts +72 -19
- package/dist/utils/content-script-context.d.mts +1 -1
- package/dist/utils/content-script-ui/iframe.d.mts +5 -0
- package/dist/utils/content-script-ui/integrated.d.mts +5 -0
- package/dist/utils/content-script-ui/shadow-root.d.mts +5 -0
- package/dist/utils/content-script-ui/types.d.mts +23 -7
- package/dist/utils/internal/custom-events.d.mts +11 -1
- package/dist/utils/internal/custom-events.mjs +4 -0
- package/dist/version.mjs +1 -1
- package/dist/virtual/background-entrypoint.mjs +11 -0
- package/dist/{core/zip.d.mts → zip.d.mts} +2 -2
- package/dist/{core/zip.mjs → zip.mjs} +11 -13
- package/package.json +7 -7
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +0 -16
- package/dist/core/builders/vite/plugins/globals.mjs +0 -14
- package/dist/core/builders/vite/plugins/index.mjs +0 -17
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +0 -56
- package/dist/core/define-config.d.mts +0 -6
- package/dist/core/index.d.mts +0 -10
- package/dist/core/index.mjs +0 -12
- package/dist/core/prepare.d.mts +0 -6
- package/dist/core/prepare.mjs +0 -12
- package/dist/core/runners/manual.mjs +0 -11
- package/dist/core/runners/safari.mjs +0 -14
- package/dist/core/runners/web-ext.mjs +0 -63
- package/dist/core/runners/wsl.mjs +0 -14
- package/dist/core/utils/building/index.mjs +0 -7
- package/dist/core/utils/environments/browser-environment.mjs +0 -18
- package/dist/core/utils/eslint.mjs +0 -11
- package/dist/core/utils/index.d.mts +0 -2
- package/dist/core/utils/index.mjs +0 -3
- package/dist/core/utils/log/index.mjs +0 -6
- /package/dist/{core/utils → internal}/environments/index.mjs +0 -0
- /package/dist/{core/utils → internal}/virtual-modules.mjs +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
Next-gen framework for developing web extensions.<br/>⚡<br/><q><i>It's like Nuxt, but for Web Extensions</i></q>
|
|
12
12
|
|
|
13
13
|
[Get Started](https://wxt.dev/guide/installation.html) •
|
|
14
|
-
[Configuration](https://wxt.dev/api/
|
|
14
|
+
[Configuration](https://wxt.dev/api/reference/wxt/interfaces/inlineconfig.html) •
|
|
15
15
|
[Examples](https://wxt.dev/examples.html) •
|
|
16
16
|
[Changelog](https://github.com/wxt-dev/wxt/blob/main/packages/wxt/CHANGELOG.md) •
|
|
17
17
|
[Discord](https://discord.gg/ZFsZqGery9)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BuildOutput, InlineConfig } from "
|
|
1
|
+
import { BuildOutput, InlineConfig } from "./types.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/build.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Bundles the extension for production. Returns a promise of the build result.
|
|
6
6
|
* Discovers the `wxt.config.ts` file in the root directory, and merges that
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { registerWxt } from "./wxt.mjs";
|
|
2
|
-
import { internalBuild } from "./
|
|
3
|
-
|
|
4
|
-
//#region src/core/build.ts
|
|
1
|
+
import { registerWxt } from "./internal/wxt.mjs";
|
|
2
|
+
import { internalBuild } from "./internal/internal-build.mjs";
|
|
3
|
+
//#region src/build.ts
|
|
5
4
|
/**
|
|
6
5
|
* Bundles the extension for production. Returns a promise of the build result.
|
|
7
6
|
* Discovers the `wxt.config.ts` file in the root directory, and merges that
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { registerWxt, wxt } from "./wxt.mjs";
|
|
1
|
+
import { registerWxt, wxt } from "./internal/wxt.mjs";
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
|
-
import { glob } from "tinyglobby";
|
|
4
3
|
import path from "node:path";
|
|
4
|
+
import { glob } from "tinyglobby";
|
|
5
5
|
import { styleText } from "node:util";
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/clean.ts
|
|
7
7
|
/**
|
|
8
8
|
* Remove generated/temp files from the directory.
|
|
9
9
|
*
|
package/dist/cli/cli-utils.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { filterTruthy, toArray } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { printHeader } from "../
|
|
5
|
-
import "../
|
|
6
|
-
import { ValidationError } from "../
|
|
1
|
+
import { filterTruthy, toArray } from "../internal-utils/array-utils.mjs";
|
|
2
|
+
import { formatDuration } from "../internal-utils/time-utils.mjs";
|
|
3
|
+
import { registerWxt } from "../internal/wxt.mjs";
|
|
4
|
+
import { printHeader } from "../internal-utils/log/print-header.mjs";
|
|
5
|
+
import "../internal-utils/log/index.mjs";
|
|
6
|
+
import { ValidationError } from "../internal/validation.mjs";
|
|
7
7
|
import { x } from "tinyexec";
|
|
8
8
|
import consola, { LogLevels } from "consola";
|
|
9
9
|
//#region src/cli/cli-utils.ts
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { build } from "../
|
|
2
|
-
import { clean } from "../
|
|
3
|
-
import { createServer } from "../
|
|
4
|
-
import { initialize } from "../
|
|
5
|
-
import { prepare } from "../
|
|
6
|
-
import { zip } from "../
|
|
7
|
-
import "../
|
|
1
|
+
import { build } from "../build.mjs";
|
|
2
|
+
import { clean } from "../clean.mjs";
|
|
3
|
+
import { createServer } from "../create-server.mjs";
|
|
4
|
+
import { initialize } from "../initialize.mjs";
|
|
5
|
+
import { prepare } from "../prepare.mjs";
|
|
6
|
+
import { zip } from "../zip.mjs";
|
|
7
|
+
import "../index.mjs";
|
|
8
8
|
import { createAliasedCommand, getArrayFromFlags, wrapAction } from "./cli-utils.mjs";
|
|
9
9
|
import cac from "cac";
|
|
10
10
|
//#region src/cli/commands.ts
|
|
@@ -67,11 +67,12 @@ cli.command("clean [root]", "clean generated files and caches").alias("cleanup")
|
|
|
67
67
|
debug: flags.debug
|
|
68
68
|
});
|
|
69
69
|
}));
|
|
70
|
-
cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").action(wrapAction(async (directory, flags) => {
|
|
70
|
+
cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").option("--no-git", "skip initialize git repo").action(wrapAction(async (directory, flags) => {
|
|
71
71
|
await initialize({
|
|
72
72
|
directory,
|
|
73
73
|
template: flags.template,
|
|
74
|
-
packageManager: flags.pm
|
|
74
|
+
packageManager: flags.pm,
|
|
75
|
+
requireGit: flags.git
|
|
75
76
|
});
|
|
76
77
|
}, { disableFinishedLog: true }));
|
|
77
78
|
createAliasedCommand(cli, "submit", "publish-extension", "wxt-publish-extension", "https://www.npmjs.com/publish-browser-extension");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InlineConfig, WxtDevServer } from "
|
|
1
|
+
import { InlineConfig, WxtDevServer } from "./types.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/create-server.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates a dev server and pre-builds all the files that need to exist before
|
|
6
6
|
* loading the extension.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { unnormalizePath } from "./utils/
|
|
2
|
-
import { deinitWxtModules, initWxtModules, registerWxt, wxt } from "./wxt.mjs";
|
|
3
|
-
import { internalBuild } from "./
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createFileReloader, reloadContentScripts } from "./utils/create-file-reloader.mjs";
|
|
1
|
+
import { unnormalizePath } from "./internal-utils/path-utils.mjs";
|
|
2
|
+
import { deinitWxtModules, initWxtModules, registerWxt, wxt } from "./internal/wxt.mjs";
|
|
3
|
+
import { internalBuild } from "./internal/internal-build.mjs";
|
|
4
|
+
import { createKeyboardShortcuts } from "./internal/keyboard-shortcuts.mjs";
|
|
5
|
+
import { isBabelSyntaxError, logBabelSyntaxError } from "./internal/syntax-errors.mjs";
|
|
6
|
+
import { createFileReloader, reloadContentScripts } from "./internal/file-reloader.mjs";
|
|
8
7
|
import chokidar from "chokidar";
|
|
9
|
-
//#region src/
|
|
8
|
+
//#region src/create-server.ts
|
|
10
9
|
/**
|
|
11
10
|
* Creates a dev server and pre-builds all the files that need to exist before
|
|
12
11
|
* loading the extension.
|
|
@@ -74,7 +73,7 @@ async function createServerInternal() {
|
|
|
74
73
|
async stop() {
|
|
75
74
|
wasStopped = true;
|
|
76
75
|
keyboardShortcuts.stop();
|
|
77
|
-
await wxt.
|
|
76
|
+
await wxt.runner.closeBrowser?.();
|
|
78
77
|
await builderServer.close();
|
|
79
78
|
await wxt.hooks.callHook("server:closed", wxt, server);
|
|
80
79
|
deinitWxtModules();
|
|
@@ -97,12 +96,12 @@ async function createServerInternal() {
|
|
|
97
96
|
server.ws.send("wxt:reload-extension");
|
|
98
97
|
},
|
|
99
98
|
async restartBrowser() {
|
|
100
|
-
await wxt.
|
|
99
|
+
await wxt.runner.closeBrowser?.();
|
|
101
100
|
keyboardShortcuts.stop();
|
|
102
101
|
await wxt.reloadConfig();
|
|
103
|
-
await wxt.
|
|
102
|
+
await wxt.runner.openBrowser();
|
|
104
103
|
keyboardShortcuts.start();
|
|
105
|
-
keyboardShortcuts.printHelp({ canReopenBrowser: !wxt.config.webExt.config.disabled && !!wxt.
|
|
104
|
+
keyboardShortcuts.printHelp({ canReopenBrowser: !wxt.config.webExt.config.disabled && !!wxt.runner.canOpen?.() });
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
const keyboardShortcuts = createKeyboardShortcuts(server);
|
|
@@ -131,9 +130,9 @@ async function createServerInternal() {
|
|
|
131
130
|
} catch (err) {
|
|
132
131
|
wxt.config.logger.warn("Failed to register additional file paths:", err);
|
|
133
132
|
}
|
|
134
|
-
await wxt.
|
|
133
|
+
await wxt.runner.openBrowser();
|
|
135
134
|
keyboardShortcuts.start();
|
|
136
|
-
keyboardShortcuts.printHelp({ canReopenBrowser: !wxt.config.webExt.config.disabled && !!wxt.
|
|
135
|
+
keyboardShortcuts.printHelp({ canReopenBrowser: !wxt.config.webExt.config.disabled && !!wxt.runner.canOpen?.() });
|
|
137
136
|
};
|
|
138
137
|
builderServer.on?.("close", () => keyboardShortcuts.stop());
|
|
139
138
|
return server;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WebExtConfig } from "
|
|
1
|
+
import { WebExtConfig } from "./types.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/define-web-ext-config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Configure how [`web-ext`](https://github.com/mozilla/web-ext) starts the
|
|
6
6
|
* browser during development.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointGroup, EntrypointInfo, EslintConfigVersion, 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, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtLogger, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig } from "./types.mjs";
|
|
2
|
-
import { build } from "./
|
|
3
|
-
import { clean } from "./
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { initialize } from "./
|
|
8
|
-
import { prepare } from "./
|
|
9
|
-
import { zip } from "./core/zip.mjs";
|
|
10
|
-
import { normalizePath } from "./core/utils/paths.mjs";
|
|
11
|
-
import { getEntrypointBundlePath } from "./core/utils/entrypoints.mjs";
|
|
1
|
+
import { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointFinder, EntrypointGroup, EntrypointInfo, EslintConfigVersion, 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, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtLogger, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtPluginEntry, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig } from "./types.mjs";
|
|
2
|
+
import { build } from "./build.mjs";
|
|
3
|
+
import { clean } from "./clean.mjs";
|
|
4
|
+
import { createServer } from "./create-server.mjs";
|
|
5
|
+
import { defineConfig } from "./define-config.mjs";
|
|
6
|
+
import { defineWebExtConfig } from "./define-web-ext-config.mjs";
|
|
7
|
+
import { initialize } from "./initialize.mjs";
|
|
8
|
+
import { prepare } from "./prepare.mjs";
|
|
12
9
|
import { version } from "./version.mjs";
|
|
13
|
-
|
|
10
|
+
import { zip } from "./zip.mjs";
|
|
11
|
+
import { getEntrypointBundlePath } from "./internal-utils/entrypoint-utils.mjs";
|
|
12
|
+
import { normalizePath } from "./internal-utils/path-utils.mjs";
|
|
13
|
+
export { BackgroundDefinition, BackgroundEntrypoint, BackgroundEntrypointOptions, BaseContentScriptEntrypointOptions, BaseEntrypoint, BaseEntrypointOptions, BaseScriptEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, CopiedPublicFile, Dependency, Entrypoint, EntrypointFinder, EntrypointGroup, EntrypointInfo, EslintConfigVersion, 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, ResolvedEslintrc, ResolvedPerBrowserOptions, ResolvedPublicFile, ServerInfo, SidepanelEntrypoint, SidepanelEntrypointOptions, TargetBrowser, TargetManifestVersion, ThemeIcon, UnlistedScriptDefinition, UnlistedScriptEntrypoint, UserConfig, UserManifest, UserManifestFn, WebExtConfig, Wxt, WxtBuilder, WxtBuilderServer, WxtCommand, WxtDevServer, WxtDirEntry, WxtDirFileEntry, WxtDirTypeReferenceEntry, WxtHooks, WxtLogger, WxtModule, WxtModuleOptions, WxtModuleSetup, WxtModuleWithMetadata, WxtPackageManager, WxtPlugin, WxtPluginEntry, WxtResolvedUnimportOptions, WxtUnimportOptions, WxtViteConfig, build, clean, createServer, defineConfig, defineWebExtConfig, getEntrypointBundlePath, initialize, normalizePath, prepare, version, zip };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { normalizePath } from "./
|
|
2
|
-
import { getEntrypointBundlePath } from "./
|
|
1
|
+
import { normalizePath } from "./internal-utils/path-utils.mjs";
|
|
2
|
+
import { getEntrypointBundlePath } from "./internal-utils/entrypoint-utils.mjs";
|
|
3
3
|
import { version } from "./version.mjs";
|
|
4
|
-
import { build } from "./
|
|
5
|
-
import { clean } from "./
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { initialize } from "./
|
|
10
|
-
import { prepare } from "./
|
|
11
|
-
import { zip } from "./
|
|
12
|
-
import "./core/index.mjs";
|
|
4
|
+
import { build } from "./build.mjs";
|
|
5
|
+
import { clean } from "./clean.mjs";
|
|
6
|
+
import { createServer } from "./create-server.mjs";
|
|
7
|
+
import { defineConfig } from "./define-config.mjs";
|
|
8
|
+
import { defineWebExtConfig } from "./define-web-ext-config.mjs";
|
|
9
|
+
import { initialize } from "./initialize.mjs";
|
|
10
|
+
import { prepare } from "./prepare.mjs";
|
|
11
|
+
import { zip } from "./zip.mjs";
|
|
13
12
|
export { build, clean, createServer, defineConfig, defineWebExtConfig, getEntrypointBundlePath, initialize, normalizePath, prepare, version, zip };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/initialize.d.ts
|
|
2
2
|
declare function initialize(options: {
|
|
3
3
|
directory?: string;
|
|
4
4
|
template?: string;
|
|
5
5
|
packageManager?: string;
|
|
6
|
+
requireGit?: boolean;
|
|
6
7
|
}): Promise<void>;
|
|
7
8
|
//#endregion
|
|
8
9
|
export { initialize };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { normalizePath } from "./internal-utils/path-utils.mjs";
|
|
2
|
+
import { pathExists } from "./internal-utils/fs-utils.mjs";
|
|
3
|
+
import { createSpinner } from "./internal/spinner.mjs";
|
|
3
4
|
import { readdir, rename } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
6
|
+
import { x } from "tinyexec";
|
|
5
7
|
import { consola as consola$1 } from "consola";
|
|
6
8
|
import { styleText } from "node:util";
|
|
7
|
-
import { question, select } from "@topcli/prompts";
|
|
9
|
+
import { confirm, question, select } from "@topcli/prompts";
|
|
8
10
|
import { downloadTemplate } from "giget";
|
|
9
|
-
//#region src/
|
|
11
|
+
//#region src/initialize.ts
|
|
10
12
|
async function initialize(options) {
|
|
11
13
|
consola$1.info("Initializing new project");
|
|
12
14
|
const templates = await listTemplates();
|
|
@@ -37,6 +39,7 @@ async function initialize(options) {
|
|
|
37
39
|
value: "yarn"
|
|
38
40
|
}
|
|
39
41
|
] });
|
|
42
|
+
const requireGitInitialized = options.requireGit ?? await confirm("Initialize a new git repository?", { initial: true });
|
|
40
43
|
if (await pathExists(directory)) {
|
|
41
44
|
if (!((await readdir(directory)).filter((dir) => dir !== ".git").length === 0)) {
|
|
42
45
|
consola$1.error(`The directory ${path.resolve(directory)} is not empty. Aborted.`);
|
|
@@ -45,7 +48,8 @@ async function initialize(options) {
|
|
|
45
48
|
}
|
|
46
49
|
await cloneProject({
|
|
47
50
|
directory,
|
|
48
|
-
template
|
|
51
|
+
template,
|
|
52
|
+
requireGitInitialized
|
|
49
53
|
});
|
|
50
54
|
const cdPath = path.relative(process.cwd(), path.resolve(directory));
|
|
51
55
|
console.log();
|
|
@@ -80,14 +84,25 @@ async function listTemplatesGithub() {
|
|
|
80
84
|
if (res.status !== 200) throw Error(`Request failed with status ${res.status} ${res.statusText}: ${await res.text()}`);
|
|
81
85
|
return await res.json();
|
|
82
86
|
}
|
|
83
|
-
async function cloneProject({ directory, template }) {
|
|
87
|
+
async function cloneProject({ directory, template, requireGitInitialized }) {
|
|
84
88
|
const spinner = createSpinner("Downloading template").start();
|
|
85
89
|
try {
|
|
86
|
-
await downloadTemplate(`gh:${REPO}/${template.path}`, {
|
|
90
|
+
const response = await downloadTemplate(`gh:${REPO}/${template.path}`, {
|
|
87
91
|
dir: directory,
|
|
88
92
|
force: true
|
|
89
93
|
});
|
|
90
94
|
await rename(path.join(directory, "_gitignore"), path.join(directory, ".gitignore")).catch((err) => consola$1.warn("Failed to move _gitignore to .gitignore:", err));
|
|
95
|
+
if (requireGitInitialized) try {
|
|
96
|
+
await x("git", ["init"], {
|
|
97
|
+
throwOnError: true,
|
|
98
|
+
nodeOptions: {
|
|
99
|
+
cwd: normalizePath(response.dir),
|
|
100
|
+
shell: true
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(error);
|
|
105
|
+
}
|
|
91
106
|
spinner.success();
|
|
92
107
|
} catch (err) {
|
|
93
108
|
spinner.error();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var dotenv_expand_default = ((e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports))(((e, t) => {
|
|
2
|
+
function n(e) {
|
|
3
|
+
return e.replace(/\\\$/g, `$`);
|
|
4
|
+
}
|
|
5
|
+
function r(e, t, n) {
|
|
6
|
+
let r = {
|
|
7
|
+
...n,
|
|
8
|
+
...t
|
|
9
|
+
}, i = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g, a = e, o, s = /* @__PURE__ */ new Set();
|
|
10
|
+
for (; (o = i.exec(a)) !== null;) {
|
|
11
|
+
s.add(a);
|
|
12
|
+
let [e, t, c] = o, l = t || c, u = l.match(/(:\+|\+|:-|-)/), d = u ? u[0] : null, f = l.split(d), p, m, h = f.shift();
|
|
13
|
+
if ([`:+`, `+`].includes(d) ? (p = r[h] ? f.join(d) : ``, m = null) : (p = f.join(d), m = r[h]), a = m ? s.has(m) ? a.replace(e, p) : a.replace(e, m) : a.replace(e, p), a === n[h]) break;
|
|
14
|
+
i.lastIndex = 0;
|
|
15
|
+
}
|
|
16
|
+
return a;
|
|
17
|
+
}
|
|
18
|
+
function i(e) {
|
|
19
|
+
let t = {}, i = process.env;
|
|
20
|
+
e && e.processEnv != null && (i = e.processEnv);
|
|
21
|
+
for (let a in e.parsed) {
|
|
22
|
+
let o = e.parsed[a];
|
|
23
|
+
o = i[a] && i[a] !== o ? i[a] : r(o, i, t), e.parsed[a] = n(o), t[a] = n(o);
|
|
24
|
+
}
|
|
25
|
+
for (let t in e.parsed) i[t] = e.parsed[t];
|
|
26
|
+
return e;
|
|
27
|
+
}
|
|
28
|
+
t.exports.expand = i;
|
|
29
|
+
}))();
|
|
30
|
+
//#endregion
|
|
31
|
+
export { dotenv_expand_default as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { toArray } from "../
|
|
2
|
-
import { wxt } from "
|
|
3
|
-
import { getPublicFiles } from "
|
|
4
|
-
import { copyFile, mkdir, writeFile } from "node:fs/promises";
|
|
1
|
+
import { toArray } from "../internal-utils/array-utils.mjs";
|
|
2
|
+
import { wxt } from "./wxt.mjs";
|
|
3
|
+
import { getPublicFiles } from "./get-public-files.mjs";
|
|
5
4
|
import { dirname, resolve } from "path";
|
|
5
|
+
import { copyFile, mkdir, writeFile } from "node:fs/promises";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
|
-
//#region src/
|
|
7
|
+
//#region src/internal/build-entrypoints.ts
|
|
8
8
|
async function buildEntrypoints(groups, spinner) {
|
|
9
9
|
const steps = [];
|
|
10
10
|
for (let i = 0; i < groups.length; i++) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/internal/builders/unknown.ts
|
|
2
|
+
var UnknownBuilder = class {
|
|
3
|
+
name = "unknown";
|
|
4
|
+
version = "0.0.0";
|
|
5
|
+
build() {
|
|
6
|
+
this.missingBuilder();
|
|
7
|
+
}
|
|
8
|
+
importEntrypoint() {
|
|
9
|
+
this.missingBuilder();
|
|
10
|
+
}
|
|
11
|
+
importEntrypoints() {
|
|
12
|
+
this.missingBuilder();
|
|
13
|
+
}
|
|
14
|
+
createServer() {
|
|
15
|
+
this.missingBuilder();
|
|
16
|
+
}
|
|
17
|
+
missingBuilder() {
|
|
18
|
+
throw Error("No builder available. Install `vite`");
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { UnknownBuilder };
|