@vivliostyle/cli 9.1.0 → 9.1.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/{chunk-KSJHCVYG.js → chunk-23EG3WEZ.js} +67 -20
- package/dist/chunk-23EG3WEZ.js.map +1 -0
- package/dist/{chunk-2O2YEPBK.js → chunk-BHM4LPO5.js} +4 -4
- package/dist/{chunk-ES2EB7JI.js → chunk-FWYKLMUD.js} +2 -2
- package/dist/{chunk-ICXF2SCI.js → chunk-MMDG5WCG.js} +16 -12
- package/dist/chunk-MMDG5WCG.js.map +1 -0
- package/dist/{chunk-GWTECQAW.js → chunk-PL4PTHOJ.js} +2 -2
- package/dist/{chunk-WBVBMEED.js → chunk-QPBFK57G.js} +4 -4
- package/dist/{chunk-ASL7KKVE.js → chunk-SEVGSYUZ.js} +10 -2
- package/dist/{chunk-ASL7KKVE.js.map → chunk-SEVGSYUZ.js.map} +1 -1
- package/dist/{chunk-7BGVK3JL.js → chunk-U63QI2TT.js} +12 -14
- package/dist/chunk-U63QI2TT.js.map +1 -0
- package/dist/commands/build.js +9 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/init.js +3 -3
- package/dist/commands/preview.js +5 -5
- package/dist/config/schema.d.ts +132 -21
- package/dist/config/schema.js +1 -1
- package/dist/index.js +8 -8
- package/dist/vite-adapter.js +4 -4
- package/package.json +1 -2
- package/types/command-exists.d.ts +15 -0
- package/dist/chunk-7BGVK3JL.js.map +0 -1
- package/dist/chunk-ICXF2SCI.js.map +0 -1
- package/dist/chunk-KSJHCVYG.js.map +0 -1
- /package/dist/{chunk-2O2YEPBK.js.map → chunk-BHM4LPO5.js.map} +0 -0
- /package/dist/{chunk-ES2EB7JI.js.map → chunk-FWYKLMUD.js.map} +0 -0
- /package/dist/{chunk-GWTECQAW.js.map → chunk-PL4PTHOJ.js.map} +0 -0
- /package/dist/{chunk-WBVBMEED.js.map → chunk-QPBFK57G.js.map} +0 -0
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
touchTmpFile,
|
|
26
26
|
useTmpDirectory,
|
|
27
27
|
writeFileIfChanged
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-U63QI2TT.js";
|
|
29
29
|
import {
|
|
30
30
|
VivliostyleConfigSchema
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-SEVGSYUZ.js";
|
|
32
32
|
import {
|
|
33
33
|
CONTAINER_LOCAL_HOSTNAME,
|
|
34
34
|
CONTAINER_URL,
|
|
@@ -230,7 +230,7 @@ function mergeInlineConfig({ tasks, inlineOptions }, inlineConfig) {
|
|
|
230
230
|
import { VFM } from "@vivliostyle/vfm";
|
|
231
231
|
import { lookup as mime } from "mime-types";
|
|
232
232
|
import fs3 from "node:fs";
|
|
233
|
-
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
233
|
+
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
234
234
|
import npa from "npm-package-arg";
|
|
235
235
|
import upath2 from "upath";
|
|
236
236
|
|
|
@@ -446,9 +446,9 @@ function resolveTaskConfig(config, options) {
|
|
|
446
446
|
const outputs = (() => {
|
|
447
447
|
const defaultPdfOptions = {
|
|
448
448
|
format: "pdf",
|
|
449
|
-
renderMode: "local",
|
|
450
|
-
preflight: config.pressReady ? "press-ready" : void 0,
|
|
451
|
-
preflightOption: []
|
|
449
|
+
renderMode: options.renderMode ?? "local",
|
|
450
|
+
preflight: options.preflight ?? (config.pressReady ? "press-ready" : void 0),
|
|
451
|
+
preflightOption: options.preflightOption ?? []
|
|
452
452
|
};
|
|
453
453
|
if (config.output) {
|
|
454
454
|
return config.output.map((target) => {
|
|
@@ -490,18 +490,23 @@ function resolveTaskConfig(config, options) {
|
|
|
490
490
|
})();
|
|
491
491
|
const { server, rootUrl } = (() => {
|
|
492
492
|
let host = config.server?.host ?? false;
|
|
493
|
+
let allowedHosts = config.server?.allowedHosts || [];
|
|
493
494
|
const port = config.server?.port ?? 13e3;
|
|
494
495
|
if (outputs.some(
|
|
495
496
|
(target) => target.format === "pdf" && target.renderMode === "docker"
|
|
496
|
-
)) {
|
|
497
|
+
) && !isInContainer()) {
|
|
497
498
|
host = true;
|
|
499
|
+
if (Array.isArray(allowedHosts) && !allowedHosts.includes(CONTAINER_LOCAL_HOSTNAME)) {
|
|
500
|
+
allowedHosts.push(CONTAINER_LOCAL_HOSTNAME);
|
|
501
|
+
}
|
|
498
502
|
}
|
|
499
|
-
const rootHostname =
|
|
503
|
+
const rootHostname = !host ? "localhost" : host === true ? "0.0.0.0" : host;
|
|
500
504
|
return {
|
|
501
505
|
server: {
|
|
502
506
|
host,
|
|
503
507
|
port,
|
|
504
|
-
proxy: config.server?.proxy ?? {}
|
|
508
|
+
proxy: config.server?.proxy ?? {},
|
|
509
|
+
allowedHosts
|
|
505
510
|
},
|
|
506
511
|
rootUrl: `http://${rootHostname}:${port}`
|
|
507
512
|
};
|
|
@@ -620,12 +625,19 @@ function resolveSingleInputConfig({
|
|
|
620
625
|
const author = config?.author;
|
|
621
626
|
const entries = [];
|
|
622
627
|
const exportAliases = [];
|
|
628
|
+
let isLocalResource = true;
|
|
623
629
|
if (isValidUri(input.entry)) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
630
|
+
const url = new URL(input.entry);
|
|
631
|
+
if (url.protocol === "file:") {
|
|
632
|
+
sourcePath = fileURLToPath(url);
|
|
633
|
+
} else {
|
|
634
|
+
isLocalResource = false;
|
|
635
|
+
sourcePath = input.entry;
|
|
636
|
+
}
|
|
627
637
|
} else {
|
|
628
638
|
sourcePath = upath2.resolve(context, input.entry);
|
|
639
|
+
}
|
|
640
|
+
if (isLocalResource) {
|
|
629
641
|
statFileSync(sourcePath);
|
|
630
642
|
switch (input.format) {
|
|
631
643
|
case "webbook":
|
|
@@ -648,6 +660,9 @@ function resolveSingleInputConfig({
|
|
|
648
660
|
return input.format;
|
|
649
661
|
}
|
|
650
662
|
serverRootDir = workspaceDir;
|
|
663
|
+
} else {
|
|
664
|
+
serverRootDir = UseTemporaryServerRoot;
|
|
665
|
+
workspaceDir = context;
|
|
651
666
|
}
|
|
652
667
|
const themesDir = upath2.resolve(workspaceDir, "themes");
|
|
653
668
|
if (input.format === "markdown") {
|
|
@@ -1190,7 +1205,7 @@ import jsdom, {
|
|
|
1190
1205
|
} from "@vivliostyle/jsdom";
|
|
1191
1206
|
import DOMPurify from "dompurify";
|
|
1192
1207
|
import { toHtml } from "hast-util-to-html";
|
|
1193
|
-
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
1208
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
1194
1209
|
import upath3 from "upath";
|
|
1195
1210
|
import MIMEType from "whatwg-mimetype";
|
|
1196
1211
|
import { jsx, jsxs } from "hastscript/jsx-runtime";
|
|
@@ -1228,7 +1243,8 @@ var htmlPurify = DOMPurify(
|
|
|
1228
1243
|
// @ts-expect-error: jsdom.DOMWindow should have trustedTypes property
|
|
1229
1244
|
new JSDOM("").window
|
|
1230
1245
|
);
|
|
1231
|
-
var ResourceLoader = class extends BaseResourceLoader {
|
|
1246
|
+
var ResourceLoader = class _ResourceLoader extends BaseResourceLoader {
|
|
1247
|
+
static dataUrlOrigin = "http://localhost/";
|
|
1232
1248
|
fetcherMap = /* @__PURE__ */ new Map();
|
|
1233
1249
|
fetch(url, options) {
|
|
1234
1250
|
Logger.debug(`[JSDOM] Fetching resource: ${url}`);
|
|
@@ -1244,7 +1260,7 @@ var ResourceLoader = class extends BaseResourceLoader {
|
|
|
1244
1260
|
outputDir,
|
|
1245
1261
|
onError
|
|
1246
1262
|
}) {
|
|
1247
|
-
const rootHref = /^https?:/i.test(
|
|
1263
|
+
const rootHref = rootUrl.startsWith("data:") ? _ResourceLoader.dataUrlOrigin : /^https?:/i.test(rootUrl) ? new URL("/", rootUrl).href : new URL(".", rootUrl).href;
|
|
1248
1264
|
const normalizeToLocalPath = (urlString, mimeType) => {
|
|
1249
1265
|
let url = new URL(urlString);
|
|
1250
1266
|
url.hash = "";
|
|
@@ -1295,14 +1311,40 @@ async function getJsdomFromUrlOrFile({
|
|
|
1295
1311
|
});
|
|
1296
1312
|
} else if (url.protocol === "file:") {
|
|
1297
1313
|
if (resourceLoader) {
|
|
1298
|
-
const file = resourceLoader._readFile(
|
|
1314
|
+
const file = resourceLoader._readFile(fileURLToPath2(url));
|
|
1299
1315
|
resourceLoader.fetcherMap.set(url.href, file);
|
|
1300
1316
|
}
|
|
1301
|
-
dom = await JSDOM.fromFile(
|
|
1317
|
+
dom = await JSDOM.fromFile(fileURLToPath2(url), {
|
|
1302
1318
|
virtualConsole,
|
|
1303
1319
|
resources: resourceLoader,
|
|
1304
1320
|
contentType: "text/html; charset=UTF-8"
|
|
1305
1321
|
});
|
|
1322
|
+
} else if (url.protocol === "data:") {
|
|
1323
|
+
const [head, body] = url.href.split(",", 2);
|
|
1324
|
+
const data = decodeURIComponent(body);
|
|
1325
|
+
const buffer = Buffer.from(
|
|
1326
|
+
data,
|
|
1327
|
+
/;base64$/i.test(head) ? "base64" : "utf8"
|
|
1328
|
+
);
|
|
1329
|
+
const dummyUrl = `${ResourceLoader.dataUrlOrigin}index.html`;
|
|
1330
|
+
if (resourceLoader) {
|
|
1331
|
+
let timeoutId;
|
|
1332
|
+
const promise = new Promise((resolve) => {
|
|
1333
|
+
timeoutId = setTimeout(resolve, 0, buffer);
|
|
1334
|
+
});
|
|
1335
|
+
promise.abort = () => {
|
|
1336
|
+
if (timeoutId !== void 0) {
|
|
1337
|
+
clearTimeout(timeoutId);
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
resourceLoader.fetcherMap.set(dummyUrl, promise);
|
|
1341
|
+
}
|
|
1342
|
+
dom = new JSDOM(buffer.toString(), {
|
|
1343
|
+
virtualConsole,
|
|
1344
|
+
resources: resourceLoader,
|
|
1345
|
+
contentType: "text/html; charset=UTF-8",
|
|
1346
|
+
url: dummyUrl
|
|
1347
|
+
});
|
|
1306
1348
|
} else {
|
|
1307
1349
|
throw new Error(`Unsupported protocol: ${url.protocol}`);
|
|
1308
1350
|
}
|
|
@@ -2429,8 +2471,13 @@ async function retrieveWebbookEntry({
|
|
|
2429
2471
|
resourceLoader,
|
|
2430
2472
|
baseUrl: webbookEntryUrl
|
|
2431
2473
|
}) || {};
|
|
2432
|
-
|
|
2433
|
-
|
|
2474
|
+
let pathContains2;
|
|
2475
|
+
if (webbookEntryUrl.startsWith("data:")) {
|
|
2476
|
+
pathContains2 = (url) => false;
|
|
2477
|
+
} else {
|
|
2478
|
+
const rootUrl = /^https?:/i.test(webbookEntryUrl) ? new URL("/", webbookEntryUrl).href : new URL(".", webbookEntryUrl).href;
|
|
2479
|
+
pathContains2 = (url) => !upath5.relative(rootUrl, url).startsWith("..");
|
|
2480
|
+
}
|
|
2434
2481
|
const retriever = new Map(resourceLoader.fetcherMap);
|
|
2435
2482
|
if (manifest && manifestUrl) {
|
|
2436
2483
|
[manifest.resources || []].flat().forEach((v2) => {
|
|
@@ -3800,4 +3847,4 @@ export {
|
|
|
3800
3847
|
getViewerFullUrl,
|
|
3801
3848
|
createViteServer
|
|
3802
3849
|
};
|
|
3803
|
-
//# sourceMappingURL=chunk-
|
|
3850
|
+
//# sourceMappingURL=chunk-23EG3WEZ.js.map
|