@vivliostyle/cli 9.9.0 → 10.0.0
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 +74 -30
- package/dist/{chunk-QWX5MAON.js → chunk-2M2KXPDN.js} +16 -17
- package/dist/chunk-2M2KXPDN.js.map +1 -0
- package/dist/{chunk-OZ4XTSAH.js → chunk-5DB6XVJN.js} +2 -2
- package/dist/chunk-5DB6XVJN.js.map +1 -0
- package/dist/{chunk-3O3N2V7D.js → chunk-5K3NGLBV.js} +6 -7
- package/dist/chunk-5K3NGLBV.js.map +1 -0
- package/dist/{chunk-UYKCTF6F.js → chunk-IIKRNYAM.js} +445 -228
- package/dist/chunk-IIKRNYAM.js.map +1 -0
- package/dist/{chunk-G3GROLBN.js → chunk-MQYXBSRJ.js} +397 -88
- package/dist/chunk-MQYXBSRJ.js.map +1 -0
- package/dist/chunk-RPMMYPTR.js +1076 -0
- package/dist/chunk-RPMMYPTR.js.map +1 -0
- package/dist/{chunk-WELNNHOB.js → chunk-YN3JNBNT.js} +415 -384
- package/dist/chunk-YN3JNBNT.js.map +1 -0
- package/dist/{chunk-6UU7DEUR.js → chunk-YVNDJXMI.js} +32 -33
- package/dist/chunk-YVNDJXMI.js.map +1 -0
- package/dist/{chunk-FXUEYQRY.js → chunk-ZIK6DINS.js} +3 -3
- package/dist/chunk-ZIK6DINS.js.map +1 -0
- package/dist/chunk-ZKEIYNLT.js +331 -0
- package/dist/chunk-ZKEIYNLT.js.map +1 -0
- package/dist/cli.js +7 -8
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.js +29 -17
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.js +64 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/init.js +23 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/preview.js +26 -20
- package/dist/commands/preview.js.map +1 -1
- package/dist/config/schema.d.ts +7815 -4012
- package/dist/config/schema.js +16 -4
- package/dist/index.d.ts +46 -7
- package/dist/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/dist/node-modules.d.ts +5 -5
- package/dist/node-modules.js +1 -1
- package/dist/vite-adapter.d.ts +1 -0
- package/dist/vite-adapter.js +6 -6
- package/package.json +37 -26
- package/dist/chunk-3O3N2V7D.js.map +0 -1
- package/dist/chunk-4IIM6RSG.js +0 -71
- package/dist/chunk-4IIM6RSG.js.map +0 -1
- package/dist/chunk-6KEOMYDZ.js +0 -89
- package/dist/chunk-6KEOMYDZ.js.map +0 -1
- package/dist/chunk-6UU7DEUR.js.map +0 -1
- package/dist/chunk-FXUEYQRY.js.map +0 -1
- package/dist/chunk-G3GROLBN.js.map +0 -1
- package/dist/chunk-OZ4XTSAH.js.map +0 -1
- package/dist/chunk-QWX5MAON.js.map +0 -1
- package/dist/chunk-UYKCTF6F.js.map +0 -1
- package/dist/chunk-WELNNHOB.js.map +0 -1
- package/types/playwright.d.ts +0 -49
|
@@ -1,33 +1,84 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VivliostyleInlineConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IIKRNYAM.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
DEFAULT_BROWSER_VERSIONS,
|
|
6
|
+
EMPTY_DATA_URI,
|
|
7
|
+
languages
|
|
8
|
+
} from "./chunk-ZKEIYNLT.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/cli-flags.ts
|
|
11
|
+
import "commander";
|
|
12
|
+
import * as v from "valibot";
|
|
13
|
+
function createParserProgram({
|
|
14
|
+
setupProgram,
|
|
15
|
+
parseArgs
|
|
16
|
+
}) {
|
|
17
|
+
return (argv) => {
|
|
18
|
+
const program = setupProgram();
|
|
19
|
+
program.parse(argv);
|
|
20
|
+
let options = program.opts();
|
|
21
|
+
options = parseArgs?.(options, program.args ?? []) || options;
|
|
22
|
+
options = warnDeprecatedFlags(options);
|
|
23
|
+
return v.parse(VivliostyleInlineConfig, options);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function setupConfigFromFlags(flags) {
|
|
27
|
+
if (!flags.input) {
|
|
28
|
+
if (flags.enableViewerStartPage) {
|
|
29
|
+
return {
|
|
30
|
+
tasks: [{ entry: [] }],
|
|
31
|
+
inlineOptions: {
|
|
32
|
+
input: { format: "webbook", entry: EMPTY_DATA_URI }
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"No input is set. Please set an appropriate entry or a Vivliostyle config file."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
tasks: [{ entry: [] }],
|
|
43
|
+
inlineOptions: { ...flags }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function warnDeprecatedFlags(options) {
|
|
47
|
+
const modifiedOptions = { ...options };
|
|
48
|
+
return modifiedOptions;
|
|
49
|
+
}
|
|
7
50
|
|
|
8
51
|
// src/util.ts
|
|
9
52
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
10
53
|
import {
|
|
11
54
|
evaluate,
|
|
12
|
-
parse
|
|
55
|
+
parse as parse2
|
|
13
56
|
} from "@humanwhocodes/momoa";
|
|
14
57
|
import { Ajv } from "ajv";
|
|
15
58
|
import formatsPlugin from "ajv-formats";
|
|
16
59
|
import { XMLParser } from "fast-xml-parser";
|
|
60
|
+
import lcid from "lcid";
|
|
17
61
|
import StreamZip from "node-stream-zip";
|
|
62
|
+
import childProcess from "node:child_process";
|
|
18
63
|
import fs from "node:fs";
|
|
64
|
+
import os from "node:os";
|
|
19
65
|
import readline from "node:readline";
|
|
20
66
|
import util from "node:util";
|
|
67
|
+
import { osLocale } from "os-locale";
|
|
68
|
+
import { titleCase } from "title-case";
|
|
21
69
|
import tmp from "tmp";
|
|
22
70
|
import upath from "upath";
|
|
23
71
|
import { gray, red, redBright as redBright2 } from "yoctocolors";
|
|
24
72
|
|
|
25
73
|
// src/logger.ts
|
|
26
74
|
import debug from "debug";
|
|
75
|
+
import { Console } from "node:console";
|
|
27
76
|
import yoctoSpinner from "yocto-spinner";
|
|
28
77
|
import { blueBright, greenBright, redBright, yellowBright } from "yoctocolors";
|
|
29
78
|
var isUnicodeSupported = process.platform !== "win32" || Boolean(process.env.WT_SESSION);
|
|
30
79
|
var randomBookSymbol = ["\u{1F4D5}", "\u{1F4D7}", "\u{1F4D8}", "\u{1F4D9}"][Math.floor(Math.random() * 4)];
|
|
80
|
+
var spinnerFrames = isUnicodeSupported ? ["\u2581\u2581\u2571 ", "\u2581\u2551\u2581 ", "\u2572\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 "] : ["- ", "\\ ", "| ", "/ "];
|
|
81
|
+
var spinnerInterval = 80;
|
|
31
82
|
var infoSymbol = blueBright("INFO");
|
|
32
83
|
var successSymbol = greenBright("SUCCESS");
|
|
33
84
|
var warnSymbol = yellowBright("WARN");
|
|
@@ -41,13 +92,42 @@ var Logger = class _Logger {
|
|
|
41
92
|
static #nonBlockingLogPrinted = false;
|
|
42
93
|
static #customLogger;
|
|
43
94
|
static #logPrefix;
|
|
95
|
+
static #stdin = process.stdin;
|
|
96
|
+
static #stdout = process.stdout;
|
|
97
|
+
static #stderr = process.stderr;
|
|
98
|
+
static #signal;
|
|
44
99
|
static debug = debug("vs-cli");
|
|
100
|
+
static get #console() {
|
|
101
|
+
if (this.#customLogger) {
|
|
102
|
+
return {
|
|
103
|
+
...this.#customLogger,
|
|
104
|
+
log: () => {
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return new Console({
|
|
109
|
+
stdout: this.#stdout,
|
|
110
|
+
stderr: this.#stderr
|
|
111
|
+
});
|
|
112
|
+
}
|
|
45
113
|
static get #spinner() {
|
|
46
114
|
return this.#loggerInstance && this.#loggerInstance.#_spinner;
|
|
47
115
|
}
|
|
116
|
+
static get stdin() {
|
|
117
|
+
return this.#stdin;
|
|
118
|
+
}
|
|
119
|
+
static get stdout() {
|
|
120
|
+
return this.#stdout;
|
|
121
|
+
}
|
|
122
|
+
static get stderr() {
|
|
123
|
+
return this.#stderr;
|
|
124
|
+
}
|
|
125
|
+
static get signal() {
|
|
126
|
+
return this.#signal;
|
|
127
|
+
}
|
|
48
128
|
static get isInteractive() {
|
|
49
129
|
return Boolean(
|
|
50
|
-
!this.#customLogger &&
|
|
130
|
+
!this.#customLogger && this.#stderr.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env) && !import.meta.env?.VITEST && !debug.enabled("vs-cli") && // Prevent stream output in docker container so that not to spawn process
|
|
51
131
|
!isInContainer()
|
|
52
132
|
);
|
|
53
133
|
}
|
|
@@ -63,7 +143,7 @@ var Logger = class _Logger {
|
|
|
63
143
|
this.#loggerInstance.#_spinner.text = text;
|
|
64
144
|
return this.#loggerInstance;
|
|
65
145
|
}
|
|
66
|
-
this.#loggerInstance = new _Logger();
|
|
146
|
+
this.#loggerInstance = new _Logger(this.#stderr);
|
|
67
147
|
this.#loggerInstance.#start(text);
|
|
68
148
|
return this.#loggerInstance;
|
|
69
149
|
}
|
|
@@ -82,7 +162,7 @@ var Logger = class _Logger {
|
|
|
82
162
|
return {
|
|
83
163
|
[Symbol.dispose]() {
|
|
84
164
|
if (_Logger.isInteractive) {
|
|
85
|
-
console.log("");
|
|
165
|
+
_Logger.#console.log("");
|
|
86
166
|
_Logger.#spinner?.start(currentMsg);
|
|
87
167
|
_Logger.#nonBlockingLogPrinted = true;
|
|
88
168
|
}
|
|
@@ -93,7 +173,7 @@ var Logger = class _Logger {
|
|
|
93
173
|
if (this.#logLevel < 1) {
|
|
94
174
|
return;
|
|
95
175
|
}
|
|
96
|
-
console.log(...messages);
|
|
176
|
+
_Logger.#console.log(...messages);
|
|
97
177
|
}
|
|
98
178
|
static logUpdate(...messages) {
|
|
99
179
|
if (!this.#spinner || !this.isInteractive) {
|
|
@@ -114,7 +194,7 @@ var Logger = class _Logger {
|
|
|
114
194
|
if (this.#logPrefix) {
|
|
115
195
|
message = `${this.#logPrefix} ${message}`;
|
|
116
196
|
}
|
|
117
|
-
this.#logLevel >= 3 ? this.debug(message) :
|
|
197
|
+
this.#logLevel >= 3 ? this.debug(message) : this.#console[logMethod](message);
|
|
118
198
|
return;
|
|
119
199
|
}
|
|
120
200
|
this.logUpdate(this.#spinner.text);
|
|
@@ -164,35 +244,54 @@ var Logger = class _Logger {
|
|
|
164
244
|
}
|
|
165
245
|
this.#nonBlockingLog("info", this.getMessage(messages.join(" ")));
|
|
166
246
|
}
|
|
167
|
-
static
|
|
168
|
-
|
|
169
|
-
|
|
247
|
+
static setLogOptions({
|
|
248
|
+
logLevel,
|
|
249
|
+
logger,
|
|
250
|
+
stdin,
|
|
251
|
+
stdout,
|
|
252
|
+
stderr,
|
|
253
|
+
signal
|
|
254
|
+
}) {
|
|
255
|
+
if (logLevel) {
|
|
256
|
+
this.#logLevel = {
|
|
257
|
+
silent: 0,
|
|
258
|
+
info: 1,
|
|
259
|
+
verbose: 2,
|
|
260
|
+
debug: 3
|
|
261
|
+
}[logLevel];
|
|
262
|
+
if (this.#logLevel >= 3) {
|
|
263
|
+
debug.enable("vs-cli");
|
|
264
|
+
}
|
|
170
265
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
if (
|
|
178
|
-
|
|
266
|
+
if (logger) {
|
|
267
|
+
this.#customLogger = logger;
|
|
268
|
+
}
|
|
269
|
+
if (stdin) {
|
|
270
|
+
this.#stdin = stdin;
|
|
271
|
+
}
|
|
272
|
+
if (stdout) {
|
|
273
|
+
this.#stdout = stdout;
|
|
274
|
+
}
|
|
275
|
+
if (stderr) {
|
|
276
|
+
this.#stderr = stderr;
|
|
277
|
+
}
|
|
278
|
+
if (signal) {
|
|
279
|
+
this.#signal = signal;
|
|
179
280
|
}
|
|
180
|
-
}
|
|
181
|
-
static setCustomLogger(logger) {
|
|
182
|
-
this.#customLogger = logger;
|
|
183
281
|
}
|
|
184
282
|
static setLogPrefix(prefix) {
|
|
185
283
|
this.#logPrefix = prefix;
|
|
186
284
|
}
|
|
187
285
|
#_spinner;
|
|
188
286
|
#_disposeSpinnerExitHandler;
|
|
189
|
-
constructor() {
|
|
287
|
+
constructor(stream) {
|
|
190
288
|
this.#_spinner = yoctoSpinner({
|
|
191
289
|
spinner: {
|
|
192
|
-
frames:
|
|
193
|
-
interval:
|
|
290
|
+
frames: spinnerFrames,
|
|
291
|
+
interval: spinnerInterval
|
|
194
292
|
},
|
|
195
|
-
color: "gray"
|
|
293
|
+
color: "gray",
|
|
294
|
+
stream
|
|
196
295
|
});
|
|
197
296
|
return this;
|
|
198
297
|
}
|
|
@@ -775,6 +874,15 @@ var publicationSchemas = [
|
|
|
775
874
|
|
|
776
875
|
// src/util.ts
|
|
777
876
|
var cwd = upath.normalize(process.cwd());
|
|
877
|
+
var execFile = util.promisify(childProcess.execFile);
|
|
878
|
+
async function exec(command, args = [], options = {}) {
|
|
879
|
+
const subprocess = await execFile(command, args, {
|
|
880
|
+
...options,
|
|
881
|
+
encoding: "utf8"
|
|
882
|
+
});
|
|
883
|
+
subprocess.stdout = subprocess.stdout.trim();
|
|
884
|
+
return subprocess;
|
|
885
|
+
}
|
|
778
886
|
var beforeExitHandlers = [];
|
|
779
887
|
var registerExitHandler = (debugMessage, handler) => {
|
|
780
888
|
const callback = () => {
|
|
@@ -785,7 +893,7 @@ var registerExitHandler = (debugMessage, handler) => {
|
|
|
785
893
|
return () => {
|
|
786
894
|
const index = beforeExitHandlers.indexOf(callback);
|
|
787
895
|
if (index !== -1) {
|
|
788
|
-
beforeExitHandlers.splice(index, 1);
|
|
896
|
+
return beforeExitHandlers.splice(index, 1)[0];
|
|
789
897
|
}
|
|
790
898
|
};
|
|
791
899
|
};
|
|
@@ -821,6 +929,7 @@ if (process.platform === "win32") {
|
|
|
821
929
|
});
|
|
822
930
|
}
|
|
823
931
|
var DetailError = class extends Error {
|
|
932
|
+
detail;
|
|
824
933
|
constructor(message, detail) {
|
|
825
934
|
super(message);
|
|
826
935
|
this.detail = detail;
|
|
@@ -918,12 +1027,16 @@ function pathContains(parentPath, childPath) {
|
|
|
918
1027
|
function isValidUri(str) {
|
|
919
1028
|
return /^(https?|file|data):/i.test(str);
|
|
920
1029
|
}
|
|
921
|
-
function
|
|
922
|
-
|
|
1030
|
+
function cachedFn(fn) {
|
|
1031
|
+
let cache = null;
|
|
1032
|
+
return () => cache ?? (cache = fn());
|
|
923
1033
|
}
|
|
924
|
-
function
|
|
1034
|
+
var isInContainer = cachedFn(function isInContainer2() {
|
|
1035
|
+
return fs.existsSync("/opt/vivliostyle-cli/.vs-cli-version");
|
|
1036
|
+
});
|
|
1037
|
+
var isRunningOnWSL = cachedFn(function isRunningOnWSL2() {
|
|
925
1038
|
return fs.existsSync("/proc/version") && fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
|
|
926
|
-
}
|
|
1039
|
+
});
|
|
927
1040
|
async function openEpub(epubPath, tmpDir) {
|
|
928
1041
|
await inflateZip(epubPath, tmpDir);
|
|
929
1042
|
Logger.debug(`Created the temporary EPUB directory: ${tmpDir}`);
|
|
@@ -981,7 +1094,7 @@ var assertPubManifestSchema = getAjvValidatorFunction(
|
|
|
981
1094
|
publicationSchemas
|
|
982
1095
|
);
|
|
983
1096
|
function parseJsonc(rawJsonc) {
|
|
984
|
-
const ast =
|
|
1097
|
+
const ast = parse2(rawJsonc, {
|
|
985
1098
|
mode: "jsonc",
|
|
986
1099
|
ranges: false,
|
|
987
1100
|
tokens: false
|
|
@@ -989,7 +1102,7 @@ function parseJsonc(rawJsonc) {
|
|
|
989
1102
|
return evaluate(ast);
|
|
990
1103
|
}
|
|
991
1104
|
function prettifySchemaError(rawJsonc, issues) {
|
|
992
|
-
const parsed =
|
|
1105
|
+
const parsed = parse2(rawJsonc, {
|
|
993
1106
|
mode: "jsonc",
|
|
994
1107
|
ranges: false,
|
|
995
1108
|
tokens: false
|
|
@@ -1041,6 +1154,48 @@ function writeFileIfChanged(filePath, content) {
|
|
|
1041
1154
|
fs.writeFileSync(filePath, content);
|
|
1042
1155
|
}
|
|
1043
1156
|
}
|
|
1157
|
+
var cachedLocale;
|
|
1158
|
+
async function getOsLocale() {
|
|
1159
|
+
if (import.meta.env?.VITEST) {
|
|
1160
|
+
return process.env.TEST_LOCALE || "en";
|
|
1161
|
+
}
|
|
1162
|
+
if (cachedLocale) {
|
|
1163
|
+
return cachedLocale;
|
|
1164
|
+
}
|
|
1165
|
+
let locale;
|
|
1166
|
+
if (process.platform === "win32") {
|
|
1167
|
+
const { stdout } = await exec("wmic", ["os", "get", "locale"]);
|
|
1168
|
+
const lcidCode = Number.parseInt(stdout.replace("Locale", ""), 16);
|
|
1169
|
+
locale = lcid.from(lcidCode);
|
|
1170
|
+
}
|
|
1171
|
+
if (process.platform === "darwin") {
|
|
1172
|
+
const results = await Promise.all([
|
|
1173
|
+
exec("defaults", ["read", "-globalDomain", "AppleLocale"]).then(
|
|
1174
|
+
({ stdout }) => stdout
|
|
1175
|
+
),
|
|
1176
|
+
exec("locale", ["-a"]).then(({ stdout }) => stdout)
|
|
1177
|
+
]);
|
|
1178
|
+
if (results[1].includes(results[0])) {
|
|
1179
|
+
locale = results[0];
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
if (locale) {
|
|
1183
|
+
locale = locale.replace(/_/, "-");
|
|
1184
|
+
} else {
|
|
1185
|
+
locale = await osLocale();
|
|
1186
|
+
}
|
|
1187
|
+
const langs = Object.keys(languages);
|
|
1188
|
+
locale = langs.includes(locale) ? locale : langs.includes(locale.split("-")[0]) ? locale.split("-")[0] : "en";
|
|
1189
|
+
return cachedLocale = locale.replace(/_/, "-");
|
|
1190
|
+
}
|
|
1191
|
+
function toTitleCase(input) {
|
|
1192
|
+
if (typeof input !== "string") {
|
|
1193
|
+
return input;
|
|
1194
|
+
}
|
|
1195
|
+
return titleCase(
|
|
1196
|
+
input.replace(/[\W_]/g, " ").replace(/\s+/g, " ").trim()
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1044
1199
|
function debounce(func, wait, options = {}) {
|
|
1045
1200
|
const leading = options.leading ?? false;
|
|
1046
1201
|
const trailing = options.trailing ?? !leading;
|
|
@@ -1070,71 +1225,217 @@ function debounce(func, wait, options = {}) {
|
|
|
1070
1225
|
}
|
|
1071
1226
|
};
|
|
1072
1227
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1228
|
+
var getCacheDir = cachedFn(function getCacheDir2() {
|
|
1229
|
+
let osCacheDir;
|
|
1230
|
+
if (process.platform === "linux") {
|
|
1231
|
+
osCacheDir = process.env.XDG_CACHE_HOME || upath.join(os.homedir(), ".cache");
|
|
1232
|
+
} else if (process.platform === "darwin") {
|
|
1233
|
+
osCacheDir = upath.join(os.homedir(), "Library", "Caches");
|
|
1234
|
+
} else if (process.platform === "win32") {
|
|
1235
|
+
osCacheDir = process.env.LOCALAPPDATA || upath.join(os.homedir(), "AppData", "Local");
|
|
1236
|
+
} else {
|
|
1237
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
1238
|
+
}
|
|
1239
|
+
return upath.join(osCacheDir, "vivliostyle");
|
|
1240
|
+
});
|
|
1241
|
+
var detectBrowserPlatform = cachedFn(function detectBrowserPlatform2() {
|
|
1242
|
+
const platform = process.platform;
|
|
1243
|
+
const arch = process.arch;
|
|
1244
|
+
switch (platform) {
|
|
1245
|
+
case "darwin":
|
|
1246
|
+
return arch === "arm64" ? "mac_arm" : "mac";
|
|
1247
|
+
case "linux":
|
|
1248
|
+
return arch === "arm64" ? "linux_arm" : "linux";
|
|
1249
|
+
case "win32":
|
|
1250
|
+
return arch === "x64" || // Windows 11 for ARM supports x64 emulation
|
|
1251
|
+
arch === "arm64" && isWindows11(os.release()) ? "win64" : "win32";
|
|
1252
|
+
default:
|
|
1253
|
+
return void 0;
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
function isWindows11(version) {
|
|
1257
|
+
const parts = version.split(".");
|
|
1258
|
+
if (parts.length > 2) {
|
|
1259
|
+
const major = parseInt(parts[0], 10);
|
|
1260
|
+
const minor = parseInt(parts[1], 10);
|
|
1261
|
+
const patch = parseInt(parts[2], 10);
|
|
1262
|
+
return major > 10 || major === 10 && minor > 0 || major === 10 && minor === 0 && patch >= 22e3;
|
|
1086
1263
|
}
|
|
1087
|
-
return
|
|
1264
|
+
return false;
|
|
1088
1265
|
}
|
|
1089
|
-
|
|
1090
|
-
if (
|
|
1091
|
-
|
|
1092
|
-
return {
|
|
1093
|
-
tasks: [{ entry: [] }],
|
|
1094
|
-
inlineOptions: {
|
|
1095
|
-
input: { format: "webbook", entry: EMPTY_DATA_URI }
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
} else {
|
|
1099
|
-
throw new Error(
|
|
1100
|
-
"No input is set. Please set an appropriate entry or a Vivliostyle config file."
|
|
1101
|
-
);
|
|
1102
|
-
}
|
|
1266
|
+
var getDefaultBrowserTag = (browserType) => {
|
|
1267
|
+
if (import.meta.env?.VITEST) {
|
|
1268
|
+
return "100.0";
|
|
1103
1269
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1270
|
+
const platform = detectBrowserPlatform();
|
|
1271
|
+
return platform && DEFAULT_BROWSER_VERSIONS[browserType][platform];
|
|
1272
|
+
};
|
|
1273
|
+
function whichPm() {
|
|
1274
|
+
if (!process.env.npm_config_user_agent) {
|
|
1275
|
+
return "npm";
|
|
1276
|
+
}
|
|
1277
|
+
const pmSpec = process.env.npm_config_user_agent.split(" ")[0];
|
|
1278
|
+
const separatorPos = pmSpec.lastIndexOf("/");
|
|
1279
|
+
const name = pmSpec.substring(0, separatorPos);
|
|
1280
|
+
return name;
|
|
1108
1281
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1282
|
+
|
|
1283
|
+
// src/processor/asset.ts
|
|
1284
|
+
import { copy } from "fs-extra/esm";
|
|
1285
|
+
import fs2 from "node:fs";
|
|
1286
|
+
import picomatch from "picomatch";
|
|
1287
|
+
import { glob } from "tinyglobby";
|
|
1288
|
+
import upath2 from "upath";
|
|
1289
|
+
var GlobMatcher = class {
|
|
1290
|
+
matcherConfig;
|
|
1291
|
+
#_matchers;
|
|
1292
|
+
constructor(matcherConfig) {
|
|
1293
|
+
this.matcherConfig = matcherConfig;
|
|
1294
|
+
this.#_matchers = matcherConfig.map(
|
|
1295
|
+
({ patterns, ...options }) => picomatch(patterns, options)
|
|
1114
1296
|
);
|
|
1115
|
-
modifiedOptions.executableBrowser = options.executableChromium;
|
|
1116
1297
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
"'--verbose' option was deprecated and will be removed in a future release. Please replace with '--log-level verbose' option."
|
|
1120
|
-
);
|
|
1121
|
-
modifiedOptions.logLevel = "verbose";
|
|
1298
|
+
match(test) {
|
|
1299
|
+
return this.#_matchers.some((matcher) => matcher(test));
|
|
1122
1300
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1301
|
+
async glob(globOptions = {}) {
|
|
1302
|
+
return new Set(
|
|
1303
|
+
(await Promise.all(
|
|
1304
|
+
this.matcherConfig.map(
|
|
1305
|
+
(config) => glob({ ...config, ...globOptions })
|
|
1306
|
+
)
|
|
1307
|
+
)).flat()
|
|
1126
1308
|
);
|
|
1127
1309
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1310
|
+
};
|
|
1311
|
+
function getIgnoreThemeDirectoryPatterns({
|
|
1312
|
+
themesDir,
|
|
1313
|
+
cwd: cwd2
|
|
1314
|
+
}) {
|
|
1315
|
+
return pathContains(cwd2, themesDir) ? [
|
|
1316
|
+
`${upath2.relative(cwd2, themesDir)}/node_modules/*/example`,
|
|
1317
|
+
`${upath2.relative(cwd2, themesDir)}/node_modules/*/*/example`
|
|
1318
|
+
] : [];
|
|
1319
|
+
}
|
|
1320
|
+
function getIgnoreAssetPatterns({
|
|
1321
|
+
outputs,
|
|
1322
|
+
entries,
|
|
1323
|
+
cwd: cwd2
|
|
1324
|
+
}) {
|
|
1325
|
+
return [
|
|
1326
|
+
...outputs.flatMap(
|
|
1327
|
+
({ format, path: p }) => !pathContains(cwd2, p) ? [] : format === "webpub" ? upath2.join(upath2.relative(cwd2, p), "**") : upath2.relative(cwd2, p)
|
|
1328
|
+
),
|
|
1329
|
+
...entries.flatMap(({ template }) => {
|
|
1330
|
+
return template?.type === "file" && pathContains(cwd2, template.pathname) ? upath2.relative(cwd2, template.pathname) : [];
|
|
1331
|
+
})
|
|
1332
|
+
];
|
|
1333
|
+
}
|
|
1334
|
+
function getWebPubResourceMatcher({
|
|
1335
|
+
outputs,
|
|
1336
|
+
themesDir,
|
|
1337
|
+
entries,
|
|
1338
|
+
cwd: cwd2,
|
|
1339
|
+
manifestPath,
|
|
1340
|
+
copyAsset: { fileExtensions }
|
|
1341
|
+
}) {
|
|
1342
|
+
return new GlobMatcher([
|
|
1343
|
+
{
|
|
1344
|
+
patterns: [
|
|
1345
|
+
`**/${upath2.relative(cwd2, manifestPath)}`,
|
|
1346
|
+
"**/*.{html,htm,xhtml,xht}",
|
|
1347
|
+
`**/*.{${fileExtensions.join(",")}}`
|
|
1348
|
+
],
|
|
1349
|
+
ignore: [
|
|
1350
|
+
...getIgnoreAssetPatterns({
|
|
1351
|
+
cwd: cwd2,
|
|
1352
|
+
outputs,
|
|
1353
|
+
entries
|
|
1354
|
+
}),
|
|
1355
|
+
...getIgnoreThemeDirectoryPatterns({
|
|
1356
|
+
cwd: cwd2,
|
|
1357
|
+
themesDir
|
|
1358
|
+
}),
|
|
1359
|
+
// Ignore node_modules in the root directory
|
|
1360
|
+
"node_modules/**",
|
|
1361
|
+
// only include dotfiles starting with `.vs-`
|
|
1362
|
+
"**/.!(vs-*)/**"
|
|
1363
|
+
],
|
|
1364
|
+
dot: true,
|
|
1365
|
+
cwd: cwd2
|
|
1366
|
+
}
|
|
1367
|
+
]);
|
|
1368
|
+
}
|
|
1369
|
+
function getAssetMatcher({
|
|
1370
|
+
copyAsset: { fileExtensions, includes, excludes },
|
|
1371
|
+
outputs,
|
|
1372
|
+
themesDir,
|
|
1373
|
+
entries,
|
|
1374
|
+
cwd: cwd2,
|
|
1375
|
+
ignore = []
|
|
1376
|
+
}) {
|
|
1377
|
+
const ignorePatterns = [
|
|
1378
|
+
...ignore,
|
|
1379
|
+
...excludes,
|
|
1380
|
+
...getIgnoreAssetPatterns({ outputs, entries, cwd: cwd2 })
|
|
1381
|
+
];
|
|
1382
|
+
return new GlobMatcher([
|
|
1383
|
+
// Step 1: Glob files with an extension in `fileExtension`
|
|
1384
|
+
// Ignore files in node_modules directory, theme example files and files matched `excludes`
|
|
1385
|
+
{
|
|
1386
|
+
patterns: fileExtensions.map((ext) => `**/*.${ext}`),
|
|
1387
|
+
ignore: [
|
|
1388
|
+
"**/node_modules/**",
|
|
1389
|
+
...ignorePatterns,
|
|
1390
|
+
...getIgnoreThemeDirectoryPatterns({ themesDir, cwd: cwd2 })
|
|
1391
|
+
],
|
|
1392
|
+
cwd: cwd2
|
|
1393
|
+
},
|
|
1394
|
+
// Step 2: Glob files matched with `includes`
|
|
1395
|
+
// Ignore only files matched `excludes`
|
|
1396
|
+
{
|
|
1397
|
+
patterns: includes,
|
|
1398
|
+
ignore: ignorePatterns,
|
|
1399
|
+
cwd: cwd2
|
|
1400
|
+
}
|
|
1401
|
+
]);
|
|
1402
|
+
}
|
|
1403
|
+
async function copyAssets({
|
|
1404
|
+
entryContextDir,
|
|
1405
|
+
workspaceDir,
|
|
1406
|
+
copyAsset,
|
|
1407
|
+
outputs,
|
|
1408
|
+
themesDir,
|
|
1409
|
+
entries
|
|
1410
|
+
}) {
|
|
1411
|
+
if (pathEquals(entryContextDir, workspaceDir)) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const relWorkspaceDir = upath2.relative(entryContextDir, workspaceDir);
|
|
1415
|
+
const assets = await getAssetMatcher({
|
|
1416
|
+
copyAsset,
|
|
1417
|
+
cwd: entryContextDir,
|
|
1418
|
+
outputs,
|
|
1419
|
+
themesDir,
|
|
1420
|
+
entries,
|
|
1421
|
+
ignore: [
|
|
1422
|
+
// don't copy workspace itself
|
|
1423
|
+
...relWorkspaceDir ? [upath2.join(relWorkspaceDir, "**")] : []
|
|
1424
|
+
]
|
|
1425
|
+
}).glob({ followSymbolicLinks: true });
|
|
1426
|
+
Logger.debug("assets", assets);
|
|
1427
|
+
for (const asset of assets) {
|
|
1428
|
+
const target = upath2.join(workspaceDir, asset);
|
|
1429
|
+
fs2.mkdirSync(upath2.dirname(target), { recursive: true });
|
|
1430
|
+
await copy(upath2.resolve(entryContextDir, asset), target);
|
|
1132
1431
|
}
|
|
1133
|
-
return modifiedOptions;
|
|
1134
1432
|
}
|
|
1135
1433
|
|
|
1136
1434
|
export {
|
|
1435
|
+
createParserProgram,
|
|
1436
|
+
setupConfigFromFlags,
|
|
1137
1437
|
cwd,
|
|
1438
|
+
exec,
|
|
1138
1439
|
registerExitHandler,
|
|
1139
1440
|
runExitHandlers,
|
|
1140
1441
|
DetailError,
|
|
@@ -1156,11 +1457,19 @@ export {
|
|
|
1156
1457
|
parseJsonc,
|
|
1157
1458
|
prettifySchemaError,
|
|
1158
1459
|
writeFileIfChanged,
|
|
1460
|
+
getOsLocale,
|
|
1461
|
+
toTitleCase,
|
|
1159
1462
|
debounce,
|
|
1463
|
+
getCacheDir,
|
|
1464
|
+
detectBrowserPlatform,
|
|
1465
|
+
getDefaultBrowserTag,
|
|
1466
|
+
whichPm,
|
|
1160
1467
|
isUnicodeSupported,
|
|
1161
1468
|
randomBookSymbol,
|
|
1162
1469
|
Logger,
|
|
1163
|
-
|
|
1164
|
-
|
|
1470
|
+
GlobMatcher,
|
|
1471
|
+
getWebPubResourceMatcher,
|
|
1472
|
+
getAssetMatcher,
|
|
1473
|
+
copyAssets
|
|
1165
1474
|
};
|
|
1166
|
-
//# sourceMappingURL=chunk-
|
|
1475
|
+
//# sourceMappingURL=chunk-MQYXBSRJ.js.map
|