wxt 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +74 -29
- package/dist/index.cjs +63 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +59 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -205,6 +205,22 @@ interface InlineConfig {
|
|
|
205
205
|
*/
|
|
206
206
|
ignoredSources?: string[];
|
|
207
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
210
|
+
* parameter directly, do not return a new object. Return values are ignored.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* defineConfig({
|
|
214
|
+
* // Add a CSS-only content script.
|
|
215
|
+
* transformManifest(manifest) {
|
|
216
|
+
* manifest.content_scripts.push({
|
|
217
|
+
* matches: ["*://google.com/*"],
|
|
218
|
+
* css: ["content-scripts/some-example.css"],
|
|
219
|
+
* });
|
|
220
|
+
* }
|
|
221
|
+
* })
|
|
222
|
+
*/
|
|
223
|
+
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
208
224
|
}
|
|
209
225
|
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
210
226
|
build?: Omit<vite.BuildOptions, 'outDir'>;
|
|
@@ -483,7 +499,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
|
483
499
|
*/
|
|
484
500
|
declare function clean(root?: string): Promise<void>;
|
|
485
501
|
|
|
486
|
-
var version = "0.6.
|
|
502
|
+
var version = "0.6.1";
|
|
487
503
|
|
|
488
504
|
declare function defineConfig(config: UserConfig): UserConfig;
|
|
489
505
|
|
package/dist/index.d.ts
CHANGED
|
@@ -205,6 +205,22 @@ interface InlineConfig {
|
|
|
205
205
|
*/
|
|
206
206
|
ignoredSources?: string[];
|
|
207
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
210
|
+
* parameter directly, do not return a new object. Return values are ignored.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* defineConfig({
|
|
214
|
+
* // Add a CSS-only content script.
|
|
215
|
+
* transformManifest(manifest) {
|
|
216
|
+
* manifest.content_scripts.push({
|
|
217
|
+
* matches: ["*://google.com/*"],
|
|
218
|
+
* css: ["content-scripts/some-example.css"],
|
|
219
|
+
* });
|
|
220
|
+
* }
|
|
221
|
+
* })
|
|
222
|
+
*/
|
|
223
|
+
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
208
224
|
}
|
|
209
225
|
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
210
226
|
build?: Omit<vite.BuildOptions, 'outDir'>;
|
|
@@ -483,7 +499,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
|
483
499
|
*/
|
|
484
500
|
declare function clean(root?: string): Promise<void>;
|
|
485
501
|
|
|
486
|
-
var version = "0.6.
|
|
502
|
+
var version = "0.6.1";
|
|
487
503
|
|
|
488
504
|
declare function defineConfig(config: UserConfig): UserConfig;
|
|
489
505
|
|
package/dist/index.js
CHANGED
|
@@ -523,7 +523,11 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
523
523
|
vite: () => ({}),
|
|
524
524
|
// Real value added after this object is initialized.
|
|
525
525
|
wxtDir,
|
|
526
|
-
zip: resolveInternalZipConfig(root, mergedConfig)
|
|
526
|
+
zip: resolveInternalZipConfig(root, mergedConfig),
|
|
527
|
+
transformManifest(manifest) {
|
|
528
|
+
userConfig.transformManifest?.(manifest);
|
|
529
|
+
inlineConfig.transformManifest?.(manifest);
|
|
530
|
+
}
|
|
527
531
|
};
|
|
528
532
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
529
533
|
return finalConfig;
|
|
@@ -726,7 +730,7 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
726
730
|
// src/index.ts
|
|
727
731
|
import { Mutex } from "async-mutex";
|
|
728
732
|
import { consola as consola3 } from "consola";
|
|
729
|
-
import { relative as
|
|
733
|
+
import { relative as relative7 } from "node:path";
|
|
730
734
|
|
|
731
735
|
// src/core/build/buildEntrypoints.ts
|
|
732
736
|
import * as vite3 from "vite";
|
|
@@ -1537,6 +1541,7 @@ async function getPackageJson(config) {
|
|
|
1537
1541
|
}
|
|
1538
1542
|
|
|
1539
1543
|
// src/core/utils/manifest.ts
|
|
1544
|
+
import { produce } from "immer";
|
|
1540
1545
|
async function writeManifest(manifest, output, config) {
|
|
1541
1546
|
const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
1542
1547
|
await fs12.ensureDir(config.outDir);
|
|
@@ -1578,7 +1583,7 @@ async function generateMainfest(entrypoints, buildOutput, config) {
|
|
|
1578
1583
|
"Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
|
|
1579
1584
|
);
|
|
1580
1585
|
}
|
|
1581
|
-
return manifest;
|
|
1586
|
+
return produce(manifest, config.transformManifest);
|
|
1582
1587
|
}
|
|
1583
1588
|
function simplifyVersion(versionName) {
|
|
1584
1589
|
const version3 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
|
|
@@ -2075,15 +2080,29 @@ async function rebuild(config, entrypointGroups, existingOutput = {
|
|
|
2075
2080
|
// src/core/server.ts
|
|
2076
2081
|
import * as vite5 from "vite";
|
|
2077
2082
|
|
|
2078
|
-
// src/core/runners/
|
|
2083
|
+
// src/core/runners/wsl.ts
|
|
2084
|
+
import { relative as relative5 } from "node:path";
|
|
2085
|
+
function createWslRunner() {
|
|
2086
|
+
return {
|
|
2087
|
+
async openBrowser(config) {
|
|
2088
|
+
config.logger.warn(
|
|
2089
|
+
`Cannot open browser when using WSL. Load "${relative5(
|
|
2090
|
+
process.cwd(),
|
|
2091
|
+
config.outDir
|
|
2092
|
+
)}" as an unpacked extension manually`
|
|
2093
|
+
);
|
|
2094
|
+
},
|
|
2095
|
+
async closeBrowser() {
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// src/core/runners/web-ext.ts
|
|
2079
2101
|
function createWebExtRunner() {
|
|
2080
2102
|
let runner;
|
|
2081
2103
|
return {
|
|
2082
2104
|
async openBrowser(config) {
|
|
2083
|
-
|
|
2084
|
-
config.logger.warn("Cannot open safari automatically.");
|
|
2085
|
-
return;
|
|
2086
|
-
}
|
|
2105
|
+
config.logger.info("Opening browser...");
|
|
2087
2106
|
const webExtLogger = await import("web-ext-run/util/logger");
|
|
2088
2107
|
webExtLogger.consoleStream.write = ({ level, msg, name }) => {
|
|
2089
2108
|
if (level >= ERROR_LOG_LEVEL)
|
|
@@ -2123,6 +2142,7 @@ function createWebExtRunner() {
|
|
|
2123
2142
|
config.logger.debug("web-ext options:", options);
|
|
2124
2143
|
const webExt = await import("web-ext-run");
|
|
2125
2144
|
runner = await webExt.default.cmd.run(finalConfig, options);
|
|
2145
|
+
config.logger.success("Opened!");
|
|
2126
2146
|
},
|
|
2127
2147
|
async closeBrowser() {
|
|
2128
2148
|
return await runner?.exit();
|
|
@@ -2132,6 +2152,33 @@ function createWebExtRunner() {
|
|
|
2132
2152
|
var WARN_LOG_LEVEL = 40;
|
|
2133
2153
|
var ERROR_LOG_LEVEL = 50;
|
|
2134
2154
|
|
|
2155
|
+
// src/core/runners/safari.ts
|
|
2156
|
+
import { relative as relative6 } from "node:path";
|
|
2157
|
+
function createSafariRunner() {
|
|
2158
|
+
return {
|
|
2159
|
+
async openBrowser(config) {
|
|
2160
|
+
config.logger.warn(
|
|
2161
|
+
`Cannot Safari using web-ext. Load "${relative6(
|
|
2162
|
+
process.cwd(),
|
|
2163
|
+
config.outDir
|
|
2164
|
+
)}" as an unpacked extension manually`
|
|
2165
|
+
);
|
|
2166
|
+
},
|
|
2167
|
+
async closeBrowser() {
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
// src/core/runners/index.ts
|
|
2173
|
+
async function createExtensionRunner(config) {
|
|
2174
|
+
if (config.browser === "safari")
|
|
2175
|
+
return createSafariRunner();
|
|
2176
|
+
const { default: isWsl } = await import("is-wsl");
|
|
2177
|
+
if (isWsl)
|
|
2178
|
+
return createWslRunner();
|
|
2179
|
+
return createWebExtRunner();
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2135
2182
|
// src/core/server.ts
|
|
2136
2183
|
async function getServerInfo() {
|
|
2137
2184
|
const { default: getPort, portNumbers } = await import("get-port");
|
|
@@ -2151,7 +2198,7 @@ async function getServerInfo() {
|
|
|
2151
2198
|
};
|
|
2152
2199
|
}
|
|
2153
2200
|
async function setupServer(serverInfo, config) {
|
|
2154
|
-
const runner =
|
|
2201
|
+
const runner = await createExtensionRunner(config);
|
|
2155
2202
|
const viteServer = await vite5.createServer(
|
|
2156
2203
|
vite5.mergeConfig(serverInfo, await config.vite(config.env))
|
|
2157
2204
|
);
|
|
@@ -2159,9 +2206,7 @@ async function setupServer(serverInfo, config) {
|
|
|
2159
2206
|
await viteServer.listen(server.port);
|
|
2160
2207
|
config.logger.success(`Started dev server @ ${serverInfo.origin}`);
|
|
2161
2208
|
server.currentOutput = await buildInternal(config);
|
|
2162
|
-
config.logger.info("Opening browser...");
|
|
2163
2209
|
await runner.openBrowser(config);
|
|
2164
|
-
config.logger.success("Opened!");
|
|
2165
2210
|
};
|
|
2166
2211
|
const reloadExtension = () => {
|
|
2167
2212
|
viteServer.ws.send("wxt:reload-extension");
|
|
@@ -2254,7 +2299,7 @@ async function clean(root = process.cwd()) {
|
|
|
2254
2299
|
}
|
|
2255
2300
|
|
|
2256
2301
|
// package.json
|
|
2257
|
-
var version2 = "0.6.
|
|
2302
|
+
var version2 = "0.6.1";
|
|
2258
2303
|
|
|
2259
2304
|
// src/core/utils/defineConfig.ts
|
|
2260
2305
|
function defineConfig(config) {
|
|
@@ -2302,11 +2347,11 @@ async function createServer2(config) {
|
|
|
2302
2347
|
if (changes.type === "no-change")
|
|
2303
2348
|
return;
|
|
2304
2349
|
internalConfig.logger.info(
|
|
2305
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc4.dim(
|
|
2350
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc4.dim(relative7(internalConfig.root, file))).join(", ")}`
|
|
2306
2351
|
);
|
|
2307
2352
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
2308
2353
|
return pc4.cyan(
|
|
2309
|
-
|
|
2354
|
+
relative7(internalConfig.outDir, getEntrypointOutputFile(entry, ""))
|
|
2310
2355
|
);
|
|
2311
2356
|
}).join(pc4.dim(", "));
|
|
2312
2357
|
internalConfig = await getLatestInternalConfig();
|