wxt 0.2.0 → 0.2.2
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 +98 -78
- package/dist/client.d.ts +44 -3
- package/dist/index.cjs +95 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +45 -6
- package/dist/index.js +75 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,50 @@
|
|
|
1
|
+
import { Manifest } from 'webextension-polyfill';
|
|
2
|
+
|
|
1
3
|
interface ContentScriptDefinition {
|
|
2
|
-
matches:
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
matches: Manifest.ContentScript['matches'];
|
|
5
|
+
/**
|
|
6
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
7
|
+
* @default "documentIdle"
|
|
8
|
+
*/
|
|
9
|
+
runAt?: Manifest.ContentScript['run_at'];
|
|
10
|
+
/**
|
|
11
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
matchAboutBlank?: Manifest.ContentScript['match_about_blank'];
|
|
15
|
+
/**
|
|
16
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
17
|
+
* @default []
|
|
18
|
+
*/
|
|
19
|
+
excludeMatches?: Manifest.ContentScript['exclude_matches'];
|
|
20
|
+
/**
|
|
21
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
22
|
+
* @default []
|
|
23
|
+
*/
|
|
24
|
+
includeGlobs?: Manifest.ContentScript['include_globs'];
|
|
25
|
+
/**
|
|
26
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
27
|
+
* @default []
|
|
28
|
+
*/
|
|
29
|
+
excludeGlobs?: Manifest.ContentScript['exclude_globs'];
|
|
30
|
+
/**
|
|
31
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
allFrames?: Manifest.ContentScript['all_frames'];
|
|
35
|
+
/**
|
|
36
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
5
39
|
matchOriginAsFallback?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
42
|
+
* @default "ISOLATED"
|
|
43
|
+
*/
|
|
6
44
|
world?: 'ISOLATED' | 'MAIN';
|
|
45
|
+
/**
|
|
46
|
+
* Main function executed when the content script is loaded.
|
|
47
|
+
*/
|
|
7
48
|
main(): void | Promise<void>;
|
|
8
49
|
}
|
|
9
50
|
interface BackgroundScriptDefintition {
|
package/dist/index.cjs
CHANGED
|
@@ -337,32 +337,15 @@ function tsconfigPaths(config) {
|
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
-
// src/core/vite-plugins/hmrLogger.ts
|
|
341
|
-
var import_path4 = require("path");
|
|
342
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
343
|
-
function hmrLogger(config) {
|
|
344
|
-
return {
|
|
345
|
-
name: "wxt:hmr-logger",
|
|
346
|
-
apply: "serve",
|
|
347
|
-
handleHotUpdate(ctx) {
|
|
348
|
-
if (ctx.file.startsWith(config.srcDir) && !ctx.file.startsWith(config.wxtDir) && !ctx.file.endsWith(".html")) {
|
|
349
|
-
config.logger.info(
|
|
350
|
-
"Hot reload: " + import_picocolors.default.dim((0, import_path4.relative)(process.cwd(), ctx.file))
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
|
|
357
340
|
// src/core/utils/createFsCache.ts
|
|
358
341
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
359
|
-
var
|
|
342
|
+
var import_path4 = require("path");
|
|
360
343
|
function createFsCache(wxtDir) {
|
|
361
|
-
const getPath = (key) => (0,
|
|
344
|
+
const getPath = (key) => (0, import_path4.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
362
345
|
return {
|
|
363
346
|
async set(key, value) {
|
|
364
347
|
const path5 = getPath(key);
|
|
365
|
-
await (0, import_fs_extra3.ensureDir)((0,
|
|
348
|
+
await (0, import_fs_extra3.ensureDir)((0, import_path4.dirname)(path5));
|
|
366
349
|
await import_fs_extra3.default.writeFile(path5, value, "utf-8");
|
|
367
350
|
},
|
|
368
351
|
async get(key) {
|
|
@@ -507,7 +490,6 @@ async function getInternalConfig(config, command) {
|
|
|
507
490
|
);
|
|
508
491
|
finalConfig.vite.plugins.push(devServerGlobals(finalConfig));
|
|
509
492
|
finalConfig.vite.plugins.push(tsconfigPaths(finalConfig));
|
|
510
|
-
finalConfig.vite.plugins.push(hmrLogger(finalConfig));
|
|
511
493
|
finalConfig.vite.define ??= {};
|
|
512
494
|
getGlobals(finalConfig).forEach((global) => {
|
|
513
495
|
finalConfig.vite.define[global.name] = JSON.stringify(global.value);
|
|
@@ -519,7 +501,7 @@ async function resolveManifestConfig(env, manifest) {
|
|
|
519
501
|
}
|
|
520
502
|
|
|
521
503
|
// src/index.ts
|
|
522
|
-
var
|
|
504
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
523
505
|
var vite5 = __toESM(require("vite"), 1);
|
|
524
506
|
|
|
525
507
|
// src/core/utils/arrays.ts
|
|
@@ -623,11 +605,11 @@ var vite2 = __toESM(require("vite"), 1);
|
|
|
623
605
|
|
|
624
606
|
// src/core/utils/removeEmptyDirs.ts
|
|
625
607
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
626
|
-
var
|
|
608
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
627
609
|
async function removeEmptyDirs(dir) {
|
|
628
610
|
const files = await import_fs_extra4.default.readdir(dir);
|
|
629
611
|
for (const file of files) {
|
|
630
|
-
const filePath =
|
|
612
|
+
const filePath = import_path5.default.join(dir, file);
|
|
631
613
|
const stats = await import_fs_extra4.default.stat(filePath);
|
|
632
614
|
if (stats.isDirectory()) {
|
|
633
615
|
await removeEmptyDirs(filePath);
|
|
@@ -642,7 +624,7 @@ async function removeEmptyDirs(dir) {
|
|
|
642
624
|
// src/core/build/buildEntrypoints.ts
|
|
643
625
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
644
626
|
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
645
|
-
var
|
|
627
|
+
var import_path6 = require("path");
|
|
646
628
|
async function buildEntrypoints(groups, config) {
|
|
647
629
|
const steps = [];
|
|
648
630
|
for (const group of groups) {
|
|
@@ -734,9 +716,9 @@ async function copyPublicDirectory(config) {
|
|
|
734
716
|
return publicAssets;
|
|
735
717
|
const files = await (0, import_fast_glob.default)("**/*", { cwd: config.publicDir });
|
|
736
718
|
for (const file of files) {
|
|
737
|
-
const srcPath = (0,
|
|
738
|
-
const outPath = (0,
|
|
739
|
-
await import_fs_extra5.default.ensureDir((0,
|
|
719
|
+
const srcPath = (0, import_path6.resolve)(config.publicDir, file);
|
|
720
|
+
const outPath = (0, import_path6.resolve)(config.outDir, file);
|
|
721
|
+
await import_fs_extra5.default.ensureDir((0, import_path6.dirname)(outPath));
|
|
740
722
|
await import_fs_extra5.default.copyFile(srcPath, outPath);
|
|
741
723
|
publicAssets.push({
|
|
742
724
|
type: "asset",
|
|
@@ -750,7 +732,7 @@ async function copyPublicDirectory(config) {
|
|
|
750
732
|
}
|
|
751
733
|
|
|
752
734
|
// src/core/build/findEntrypoints.ts
|
|
753
|
-
var
|
|
735
|
+
var import_path8 = require("path");
|
|
754
736
|
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
755
737
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
756
738
|
var import_linkedom2 = require("linkedom");
|
|
@@ -760,7 +742,7 @@ var import_json5 = __toESM(require("json5"), 1);
|
|
|
760
742
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
761
743
|
var import_unimport2 = require("unimport");
|
|
762
744
|
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
763
|
-
var
|
|
745
|
+
var import_path7 = require("path");
|
|
764
746
|
var import_babel = __toESM(require("jiti/dist/babel"), 1);
|
|
765
747
|
async function importTsFile(path5, config) {
|
|
766
748
|
config.logger.debug("Loading file metadata:", path5);
|
|
@@ -782,7 +764,7 @@ async function importTsFile(path5, config) {
|
|
|
782
764
|
esmResolve: true,
|
|
783
765
|
interopDefault: true,
|
|
784
766
|
alias: {
|
|
785
|
-
"webextension-polyfill": (0,
|
|
767
|
+
"webextension-polyfill": (0, import_path7.resolve)(
|
|
786
768
|
config.root,
|
|
787
769
|
"node_modules/wxt/dist/virtual-modules/fake-browser.js"
|
|
788
770
|
)
|
|
@@ -814,7 +796,7 @@ async function findEntrypoints(config) {
|
|
|
814
796
|
const entrypoints = [];
|
|
815
797
|
await Promise.all(
|
|
816
798
|
relativePaths.map(async (relativePath) => {
|
|
817
|
-
const path5 = (0,
|
|
799
|
+
const path5 = (0, import_path8.resolve)(config.entrypointsDir, relativePath);
|
|
818
800
|
const matchingGlob = pathGlobs.find(
|
|
819
801
|
(glob3) => import_picomatch.default.isMatch(relativePath, glob3)
|
|
820
802
|
);
|
|
@@ -861,8 +843,8 @@ ${JSON.stringify(
|
|
|
861
843
|
if (withSameName) {
|
|
862
844
|
throw Error(
|
|
863
845
|
`Multiple entrypoints with the name "${entrypoint.name}" detected, but only one is allowed: ${[
|
|
864
|
-
(0,
|
|
865
|
-
(0,
|
|
846
|
+
(0, import_path8.relative)(config.root, withSameName.inputPath),
|
|
847
|
+
(0, import_path8.relative)(config.root, entrypoint.inputPath)
|
|
866
848
|
].join(", ")}`
|
|
867
849
|
);
|
|
868
850
|
}
|
|
@@ -951,7 +933,7 @@ async function getContentScriptEntrypoint(config, name, path5) {
|
|
|
951
933
|
type: "content-script",
|
|
952
934
|
name: getEntrypointName(config.entrypointsDir, path5),
|
|
953
935
|
inputPath: path5,
|
|
954
|
-
outputDir: (0,
|
|
936
|
+
outputDir: (0, import_path8.resolve)(config.outDir, "content-scripts"),
|
|
955
937
|
options
|
|
956
938
|
};
|
|
957
939
|
}
|
|
@@ -991,7 +973,7 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
991
973
|
// src/core/build/generateTypesDir.ts
|
|
992
974
|
var import_unimport3 = require("unimport");
|
|
993
975
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
994
|
-
var
|
|
976
|
+
var import_path9 = require("path");
|
|
995
977
|
async function generateTypesDir(entrypoints, config) {
|
|
996
978
|
await import_fs_extra8.default.ensureDir(config.typesDir);
|
|
997
979
|
const references = [];
|
|
@@ -1002,7 +984,7 @@ async function generateTypesDir(entrypoints, config) {
|
|
|
1002
984
|
await writeTsConfigFile(mainReference, config);
|
|
1003
985
|
}
|
|
1004
986
|
async function writeImportsDeclarationFile(config) {
|
|
1005
|
-
const filePath = (0,
|
|
987
|
+
const filePath = (0, import_path9.resolve)(config.typesDir, "imports.d.ts");
|
|
1006
988
|
const unimport2 = (0, import_unimport3.createUnimport)(getUnimportOptions(config));
|
|
1007
989
|
await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
|
|
1008
990
|
await import_fs_extra8.default.writeFile(
|
|
@@ -1014,7 +996,7 @@ async function writeImportsDeclarationFile(config) {
|
|
|
1014
996
|
return filePath;
|
|
1015
997
|
}
|
|
1016
998
|
async function writePathsDeclarationFile(entrypoints, config) {
|
|
1017
|
-
const filePath = (0,
|
|
999
|
+
const filePath = (0, import_path9.resolve)(config.typesDir, "paths.d.ts");
|
|
1018
1000
|
const unions = entrypoints.map((entry) => {
|
|
1019
1001
|
const path5 = getEntrypointBundlePath(
|
|
1020
1002
|
entry,
|
|
@@ -1034,7 +1016,7 @@ async function writePathsDeclarationFile(entrypoints, config) {
|
|
|
1034
1016
|
return filePath;
|
|
1035
1017
|
}
|
|
1036
1018
|
async function writeGlobalsDeclarationFile(config) {
|
|
1037
|
-
const filePath = (0,
|
|
1019
|
+
const filePath = (0, import_path9.resolve)(config.typesDir, "globals.d.ts");
|
|
1038
1020
|
const globals = getGlobals(config);
|
|
1039
1021
|
await import_fs_extra8.default.writeFile(
|
|
1040
1022
|
filePath,
|
|
@@ -1051,14 +1033,14 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
1051
1033
|
}
|
|
1052
1034
|
async function writeMainDeclarationFile(references, config) {
|
|
1053
1035
|
const dir = config.wxtDir;
|
|
1054
|
-
const filePath = (0,
|
|
1036
|
+
const filePath = (0, import_path9.resolve)(dir, "wxt.d.ts");
|
|
1055
1037
|
await import_fs_extra8.default.writeFile(
|
|
1056
1038
|
filePath,
|
|
1057
1039
|
[
|
|
1058
1040
|
"// Generated by wxt",
|
|
1059
1041
|
`/// <reference types="vite/client" />`,
|
|
1060
1042
|
...references.map(
|
|
1061
|
-
(ref) => `/// <reference types="./${(0,
|
|
1043
|
+
(ref) => `/// <reference types="./${(0, import_path9.relative)(dir, ref)}" />`
|
|
1062
1044
|
)
|
|
1063
1045
|
].join("\n") + "\n"
|
|
1064
1046
|
);
|
|
@@ -1067,7 +1049,7 @@ async function writeMainDeclarationFile(references, config) {
|
|
|
1067
1049
|
async function writeTsConfigFile(mainReference, config) {
|
|
1068
1050
|
const dir = config.wxtDir;
|
|
1069
1051
|
await import_fs_extra8.default.writeFile(
|
|
1070
|
-
(0,
|
|
1052
|
+
(0, import_path9.resolve)(dir, "tsconfig.json"),
|
|
1071
1053
|
`{
|
|
1072
1054
|
"compilerOptions": {
|
|
1073
1055
|
"target": "ESNext",
|
|
@@ -1085,30 +1067,30 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
1085
1067
|
"skipLibCheck": true,
|
|
1086
1068
|
|
|
1087
1069
|
/* Aliases */
|
|
1088
|
-
"baseUrl": "${(0,
|
|
1070
|
+
"baseUrl": "${(0, import_path9.relative)(dir, config.root)}",
|
|
1089
1071
|
"paths": {
|
|
1090
1072
|
"@@": ["."],
|
|
1091
1073
|
"@@/*": ["./*"],
|
|
1092
1074
|
"~~": ["."],
|
|
1093
1075
|
"~~/*": ["./*"],
|
|
1094
|
-
"@": ["${(0,
|
|
1095
|
-
"@/*": ["${(0,
|
|
1096
|
-
"~": ["${(0,
|
|
1097
|
-
"~/*": ["${(0,
|
|
1076
|
+
"@": ["${(0, import_path9.relative)(config.root, config.srcDir)}"],
|
|
1077
|
+
"@/*": ["${(0, import_path9.relative)(config.root, config.srcDir)}/*"],
|
|
1078
|
+
"~": ["${(0, import_path9.relative)(config.root, config.srcDir)}"],
|
|
1079
|
+
"~/*": ["${(0, import_path9.relative)(config.root, config.srcDir)}/*"]
|
|
1098
1080
|
}
|
|
1099
1081
|
},
|
|
1100
1082
|
"include": [
|
|
1101
|
-
"${(0,
|
|
1102
|
-
"./${(0,
|
|
1083
|
+
"${(0, import_path9.relative)(dir, config.root)}/**/*",
|
|
1084
|
+
"./${(0, import_path9.relative)(dir, mainReference)}"
|
|
1103
1085
|
],
|
|
1104
|
-
"exclude": ["${(0,
|
|
1086
|
+
"exclude": ["${(0, import_path9.relative)(dir, config.outBaseDir)}"]
|
|
1105
1087
|
}`
|
|
1106
1088
|
);
|
|
1107
1089
|
}
|
|
1108
1090
|
|
|
1109
1091
|
// src/core/utils/manifest.ts
|
|
1110
1092
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
1111
|
-
var
|
|
1093
|
+
var import_path10 = require("path");
|
|
1112
1094
|
|
|
1113
1095
|
// src/core/utils/ContentSecurityPolicy.ts
|
|
1114
1096
|
var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
@@ -1153,11 +1135,49 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
|
1153
1135
|
}
|
|
1154
1136
|
};
|
|
1155
1137
|
|
|
1138
|
+
// src/core/utils/content-scripts.ts
|
|
1139
|
+
function hashContentScriptOptions(options) {
|
|
1140
|
+
const withDefaults = {
|
|
1141
|
+
excludeGlobs: [],
|
|
1142
|
+
excludeMatches: [],
|
|
1143
|
+
includeGlobs: [],
|
|
1144
|
+
matchAboutBlank: false,
|
|
1145
|
+
matchOriginAsFallback: false,
|
|
1146
|
+
runAt: "document_idle",
|
|
1147
|
+
allFrames: false,
|
|
1148
|
+
world: "ISOLATED",
|
|
1149
|
+
// TODO: strip undefined fields from options object to improve content script grouping.
|
|
1150
|
+
...options
|
|
1151
|
+
};
|
|
1152
|
+
return JSON.stringify(
|
|
1153
|
+
Object.entries(withDefaults).map(([key, value]) => {
|
|
1154
|
+
if (Array.isArray(value))
|
|
1155
|
+
return [key, value.sort()];
|
|
1156
|
+
else
|
|
1157
|
+
return [key, value];
|
|
1158
|
+
}).sort((l, r) => l[0].localeCompare(r[0]))
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
function mapWxtOptionsToContentScript(options) {
|
|
1162
|
+
return {
|
|
1163
|
+
matches: options.matches,
|
|
1164
|
+
all_frames: options.allFrames,
|
|
1165
|
+
match_about_blank: options.matchAboutBlank,
|
|
1166
|
+
exclude_globs: options.excludeGlobs,
|
|
1167
|
+
exclude_matches: options.excludeMatches,
|
|
1168
|
+
include_globs: options.includeGlobs,
|
|
1169
|
+
run_at: options.runAt,
|
|
1170
|
+
// @ts-expect-error: untyped chrome options
|
|
1171
|
+
match_origin_as_fallback: options.matchOriginAsFallback,
|
|
1172
|
+
world: options.world
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1156
1176
|
// src/core/utils/manifest.ts
|
|
1157
1177
|
async function writeManifest(manifest, output, config) {
|
|
1158
1178
|
const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
1159
1179
|
await import_fs_extra9.default.ensureDir(config.outDir);
|
|
1160
|
-
await import_fs_extra9.default.writeFile((0,
|
|
1180
|
+
await import_fs_extra9.default.writeFile((0, import_path10.resolve)(config.outDir, "manifest.json"), str, "utf-8");
|
|
1161
1181
|
output.publicAssets.unshift({
|
|
1162
1182
|
type: "asset",
|
|
1163
1183
|
fileName: "manifest.json",
|
|
@@ -1190,7 +1210,7 @@ async function generateMainfest(entrypoints, buildOutput, config) {
|
|
|
1190
1210
|
return manifest;
|
|
1191
1211
|
}
|
|
1192
1212
|
async function getPackageJson(config) {
|
|
1193
|
-
return await import_fs_extra9.default.readJson((0,
|
|
1213
|
+
return await import_fs_extra9.default.readJson((0, import_path10.resolve)(config.root, "package.json"));
|
|
1194
1214
|
}
|
|
1195
1215
|
function simplifyVersion(versionName) {
|
|
1196
1216
|
const version3 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
|
|
@@ -1355,7 +1375,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
1355
1375
|
);
|
|
1356
1376
|
} else {
|
|
1357
1377
|
const hashToEntrypointsMap = contentScripts.reduce((map, script) => {
|
|
1358
|
-
const hash =
|
|
1378
|
+
const hash = hashContentScriptOptions(script.options);
|
|
1359
1379
|
if (map.has(hash))
|
|
1360
1380
|
map.get(hash)?.push(script);
|
|
1361
1381
|
else
|
|
@@ -1364,7 +1384,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
1364
1384
|
}, /* @__PURE__ */ new Map());
|
|
1365
1385
|
manifest.content_scripts = Array.from(hashToEntrypointsMap.entries()).map(
|
|
1366
1386
|
([, scripts]) => ({
|
|
1367
|
-
...scripts[0].options,
|
|
1387
|
+
...mapWxtOptionsToContentScript(scripts[0].options),
|
|
1368
1388
|
// TOOD: Sorting css and js arrays here so we get consistent test results... but we
|
|
1369
1389
|
// shouldn't have to. Where is the inconsistency coming from?
|
|
1370
1390
|
css: getContentScriptCssFiles(scripts, buildOutput)?.sort(),
|
|
@@ -1433,7 +1453,7 @@ function addHostPermission(manifest, hostPermission) {
|
|
|
1433
1453
|
}
|
|
1434
1454
|
|
|
1435
1455
|
// src/core/build.ts
|
|
1436
|
-
var
|
|
1456
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
1437
1457
|
var vite3 = __toESM(require("vite"), 1);
|
|
1438
1458
|
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
1439
1459
|
|
|
@@ -1483,7 +1503,7 @@ function formatDuration(duration) {
|
|
|
1483
1503
|
}
|
|
1484
1504
|
|
|
1485
1505
|
// src/core/log/printBuildSummary.ts
|
|
1486
|
-
var
|
|
1506
|
+
var import_path11 = __toESM(require("path"), 1);
|
|
1487
1507
|
|
|
1488
1508
|
// src/core/log/printTable.ts
|
|
1489
1509
|
function printTable(log, rows, gap = 2) {
|
|
@@ -1512,7 +1532,7 @@ function printTable(log, rows, gap = 2) {
|
|
|
1512
1532
|
}
|
|
1513
1533
|
|
|
1514
1534
|
// src/core/log/printBuildSummary.ts
|
|
1515
|
-
var
|
|
1535
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
1516
1536
|
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
1517
1537
|
var import_filesize = require("filesize");
|
|
1518
1538
|
async function printBuildSummary(output, config) {
|
|
@@ -1531,23 +1551,23 @@ async function printBuildSummary(output, config) {
|
|
|
1531
1551
|
const chunkRows = await Promise.all(
|
|
1532
1552
|
chunks.map(async (chunk, i) => {
|
|
1533
1553
|
const file = [
|
|
1534
|
-
(0,
|
|
1554
|
+
(0, import_path11.relative)(process.cwd(), config.outDir) + import_path11.default.sep,
|
|
1535
1555
|
chunk.fileName
|
|
1536
1556
|
];
|
|
1537
1557
|
const prefix = i === chunks.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
1538
1558
|
const color = getChunkColor(chunk.fileName);
|
|
1539
|
-
const stats = await import_fs_extra10.default.lstat((0,
|
|
1559
|
+
const stats = await import_fs_extra10.default.lstat((0, import_path11.resolve)(config.outDir, chunk.fileName));
|
|
1540
1560
|
totalSize += stats.size;
|
|
1541
1561
|
const size = String((0, import_filesize.filesize)(stats.size));
|
|
1542
1562
|
return [
|
|
1543
|
-
`${
|
|
1544
|
-
|
|
1563
|
+
`${import_picocolors.default.gray(prefix)} ${import_picocolors.default.dim(file[0])}${color(file[1])}`,
|
|
1564
|
+
import_picocolors.default.dim(size)
|
|
1545
1565
|
];
|
|
1546
1566
|
})
|
|
1547
1567
|
);
|
|
1548
1568
|
printTable(config.logger.log, chunkRows);
|
|
1549
1569
|
config.logger.log(
|
|
1550
|
-
`${
|
|
1570
|
+
`${import_picocolors.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`
|
|
1551
1571
|
);
|
|
1552
1572
|
}
|
|
1553
1573
|
var DEFAULT_SORT_WEIGHT = 100;
|
|
@@ -1563,12 +1583,12 @@ function getChunkSortWeight(filename) {
|
|
|
1563
1583
|
([key]) => filename.endsWith(key)
|
|
1564
1584
|
)?.[1] ?? DEFAULT_SORT_WEIGHT;
|
|
1565
1585
|
}
|
|
1566
|
-
var DEFAULT_COLOR =
|
|
1586
|
+
var DEFAULT_COLOR = import_picocolors.default.blue;
|
|
1567
1587
|
var CHUNK_COLORS = {
|
|
1568
|
-
".js.map":
|
|
1569
|
-
".html":
|
|
1570
|
-
".css":
|
|
1571
|
-
".js":
|
|
1588
|
+
".js.map": import_picocolors.default.gray,
|
|
1589
|
+
".html": import_picocolors.default.green,
|
|
1590
|
+
".css": import_picocolors.default.magenta,
|
|
1591
|
+
".js": import_picocolors.default.cyan
|
|
1572
1592
|
};
|
|
1573
1593
|
function getChunkColor(filename) {
|
|
1574
1594
|
return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
|
|
@@ -1579,7 +1599,7 @@ async function buildInternal(config) {
|
|
|
1579
1599
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
1580
1600
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
1581
1601
|
config.logger.info(
|
|
1582
|
-
`${verb} ${
|
|
1602
|
+
`${verb} ${import_picocolors2.default.cyan(target)} for ${import_picocolors2.default.cyan(config.mode)} with ${import_picocolors2.default.green(
|
|
1583
1603
|
`Vite ${vite3.version}`
|
|
1584
1604
|
)}`
|
|
1585
1605
|
);
|
|
@@ -1781,9 +1801,9 @@ function reloadContentScripts(steps, config, server) {
|
|
|
1781
1801
|
const js = [getEntrypointBundlePath(entry, config.outDir, ".js")];
|
|
1782
1802
|
const css = getContentScriptCssFiles([entry], server.currentOutput);
|
|
1783
1803
|
server.reloadContentScript({
|
|
1804
|
+
...entry.options,
|
|
1784
1805
|
js,
|
|
1785
|
-
css
|
|
1786
|
-
...entry.options
|
|
1806
|
+
css
|
|
1787
1807
|
});
|
|
1788
1808
|
});
|
|
1789
1809
|
} else {
|
|
@@ -1798,7 +1818,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1798
1818
|
}
|
|
1799
1819
|
|
|
1800
1820
|
// package.json
|
|
1801
|
-
var version2 = "0.2.
|
|
1821
|
+
var version2 = "0.2.2";
|
|
1802
1822
|
|
|
1803
1823
|
// src/core/utils/defineConfig.ts
|
|
1804
1824
|
function defineConfig(config) {
|
|
@@ -1842,13 +1862,13 @@ async function createServer2(config) {
|
|
|
1842
1862
|
if (changes.type === "no-change")
|
|
1843
1863
|
return;
|
|
1844
1864
|
internalConfig.logger.info(
|
|
1845
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) =>
|
|
1865
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors3.default.dim((0, import_node_path4.relative)(internalConfig.root, file))).join(", ")}`
|
|
1846
1866
|
);
|
|
1847
1867
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
1848
|
-
return
|
|
1868
|
+
return import_picocolors3.default.cyan(
|
|
1849
1869
|
(0, import_node_path4.relative)(internalConfig.outDir, getEntrypointOutputFile(entry, ""))
|
|
1850
1870
|
);
|
|
1851
|
-
}).join(
|
|
1871
|
+
}).join(import_picocolors3.default.dim(", "));
|
|
1852
1872
|
internalConfig = await getLatestInternalConfig();
|
|
1853
1873
|
internalConfig.server = server;
|
|
1854
1874
|
const { output: newOutput } = await rebuild(
|