@vivliostyle/cli 9.1.1 → 9.2.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/dist/{chunk-BHM4LPO5.js → chunk-5WSXXCJP.js} +2 -2
- package/dist/{chunk-QPBFK57G.js → chunk-IBR32DAW.js} +2 -2
- package/dist/{chunk-MMDG5WCG.js → chunk-SZ6PUNZP.js} +2 -2
- package/dist/{chunk-23EG3WEZ.js → chunk-XYOW6HSN.js} +89 -27
- package/dist/chunk-XYOW6HSN.js.map +1 -0
- package/dist/commands/build.js +2 -2
- package/dist/commands/preview.js +2 -2
- package/dist/config/schema.d.ts +1653 -1653
- package/dist/index.js +4 -4
- package/dist/vite-adapter.js +2 -2
- package/package.json +4 -3
- package/dist/chunk-23EG3WEZ.js.map +0 -1
- /package/dist/{chunk-BHM4LPO5.js.map → chunk-5WSXXCJP.js.map} +0 -0
- /package/dist/{chunk-QPBFK57G.js.map → chunk-IBR32DAW.js.map} +0 -0
- /package/dist/{chunk-MMDG5WCG.js.map → chunk-SZ6PUNZP.js.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
mergeInlineConfig,
|
|
10
10
|
resolveTaskConfig,
|
|
11
11
|
warnDeprecatedConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XYOW6HSN.js";
|
|
13
13
|
import {
|
|
14
14
|
Logger,
|
|
15
15
|
isUnicodeSupported,
|
|
@@ -85,4 +85,4 @@ ${blueBright("\u2559\u2500")} ${dim(`Preview URL: ${terminalLink(url, url, { fal
|
|
|
85
85
|
export {
|
|
86
86
|
preview
|
|
87
87
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-5WSXXCJP.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
vsStaticServePlugin,
|
|
8
8
|
vsViewerPlugin,
|
|
9
9
|
warnDeprecatedConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-XYOW6HSN.js";
|
|
11
11
|
import {
|
|
12
12
|
Logger,
|
|
13
13
|
setupConfigFromFlags
|
|
@@ -54,4 +54,4 @@ async function createVitePlugin(inlineConfig = {}) {
|
|
|
54
54
|
export {
|
|
55
55
|
createVitePlugin
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-IBR32DAW.js.map
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
prepareThemeDirectory,
|
|
18
18
|
resolveTaskConfig,
|
|
19
19
|
warnDeprecatedConfig
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XYOW6HSN.js";
|
|
21
21
|
import {
|
|
22
22
|
importNodeModule
|
|
23
23
|
} from "./chunk-FXUEYQRY.js";
|
|
@@ -726,4 +726,4 @@ async function build(inlineConfig, { containerForkMode = false } = {}) {
|
|
|
726
726
|
export {
|
|
727
727
|
build
|
|
728
728
|
};
|
|
729
|
-
//# sourceMappingURL=chunk-
|
|
729
|
+
//# sourceMappingURL=chunk-SZ6PUNZP.js.map
|
|
@@ -351,6 +351,7 @@ function parseTheme({
|
|
|
351
351
|
name,
|
|
352
352
|
specifier: resolvedSpecifier,
|
|
353
353
|
location: upath2.join(themesDir, "node_modules", name),
|
|
354
|
+
registry: Boolean(parsed.registry),
|
|
354
355
|
importPath
|
|
355
356
|
};
|
|
356
357
|
}
|
|
@@ -399,6 +400,26 @@ function parseFileMetadata({
|
|
|
399
400
|
}
|
|
400
401
|
return { title, themes };
|
|
401
402
|
}
|
|
403
|
+
function parseCustomStyle({
|
|
404
|
+
customStyle,
|
|
405
|
+
entryContextDir
|
|
406
|
+
}) {
|
|
407
|
+
if (isValidUri(customStyle)) {
|
|
408
|
+
return customStyle;
|
|
409
|
+
}
|
|
410
|
+
const stylePath = upath2.resolve(entryContextDir, customStyle);
|
|
411
|
+
if (!pathContains(entryContextDir, stylePath)) {
|
|
412
|
+
throw Error(
|
|
413
|
+
`Custom style file ${customStyle} is not in ${entryContextDir}. Make sure the file is located in the context directory or a subdirectory.`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
if (!fs3.existsSync(stylePath)) {
|
|
417
|
+
throw new Error(`Custom style file not found: ${customStyle}`);
|
|
418
|
+
}
|
|
419
|
+
return pathToFileURL2(stylePath).href.slice(
|
|
420
|
+
pathToFileURL2(entryContextDir).href.replace(/\/$/, "").length + 1
|
|
421
|
+
);
|
|
422
|
+
}
|
|
402
423
|
function resolveTaskConfig(config, options) {
|
|
403
424
|
const context = options.cwd ?? cwd;
|
|
404
425
|
Logger.debug("resolveTaskConfig > context %s", context);
|
|
@@ -410,8 +431,6 @@ function resolveTaskConfig(config, options) {
|
|
|
410
431
|
const bleed = options.bleed;
|
|
411
432
|
const cropOffset = options.cropOffset;
|
|
412
433
|
const css = options.css;
|
|
413
|
-
const customStyle = options.style && (isValidUri(options.style) ? options.style : pathToFileURL2(options.style).href);
|
|
414
|
-
const customUserStyle = options.userStyle && (isValidUri(options.userStyle) ? options.userStyle : pathToFileURL2(options.userStyle).href);
|
|
415
434
|
const singleDoc = options.singleDoc ?? false;
|
|
416
435
|
const quick = options.quick ?? false;
|
|
417
436
|
const temporaryFilePrefix = config.temporaryFilePrefix ?? `.vs-${Date.now()}.`;
|
|
@@ -443,6 +462,8 @@ function resolveTaskConfig(config, options) {
|
|
|
443
462
|
const staticRoutes = config.static ?? {};
|
|
444
463
|
const viteConfig = config.vite;
|
|
445
464
|
const viteConfigFile = config.viteConfigFile ?? true;
|
|
465
|
+
const customStyle = options.style && parseCustomStyle({ customStyle: options.style, entryContextDir }) || void 0;
|
|
466
|
+
const customUserStyle = options.userStyle && parseCustomStyle({ customStyle: options.userStyle, entryContextDir }) || void 0;
|
|
446
467
|
const outputs = (() => {
|
|
447
468
|
const defaultPdfOptions = {
|
|
448
469
|
format: "pdf",
|
|
@@ -728,9 +749,6 @@ function resolveSingleInputConfig({
|
|
|
728
749
|
let webbookPath;
|
|
729
750
|
if (isValidUri(sourcePath)) {
|
|
730
751
|
const url = new URL(sourcePath);
|
|
731
|
-
if (/^https?:/i.test(url.protocol) && !url.pathname.endsWith("/") && !/\.\w+$/.test(url.pathname)) {
|
|
732
|
-
url.pathname = `${url.pathname}/`;
|
|
733
|
-
}
|
|
734
752
|
webbookEntryUrl = url.href;
|
|
735
753
|
} else {
|
|
736
754
|
const rootFileUrl = pathToFileURL2(workspaceDir).href;
|
|
@@ -1184,10 +1202,9 @@ import upath7 from "upath";
|
|
|
1184
1202
|
import { copy as copy3, move } from "fs-extra/esm";
|
|
1185
1203
|
import fs8 from "node:fs";
|
|
1186
1204
|
import picomatch from "picomatch";
|
|
1187
|
-
import prettier from "prettier";
|
|
1188
|
-
import parserHtml from "prettier/parser-html";
|
|
1189
1205
|
import { glob as glob2 } from "tinyglobby";
|
|
1190
1206
|
import upath6 from "upath";
|
|
1207
|
+
import serializeToXml2 from "w3c-xmlserializer";
|
|
1191
1208
|
import MIMEType2 from "whatwg-mimetype";
|
|
1192
1209
|
|
|
1193
1210
|
// src/output/webbook.ts
|
|
@@ -1317,7 +1334,7 @@ async function getJsdomFromUrlOrFile({
|
|
|
1317
1334
|
dom = await JSDOM.fromFile(fileURLToPath2(url), {
|
|
1318
1335
|
virtualConsole,
|
|
1319
1336
|
resources: resourceLoader,
|
|
1320
|
-
contentType: "text/html; charset=UTF-8"
|
|
1337
|
+
contentType: src.endsWith(".xhtml") || src.endsWith(".xml") ? "application/xhtml+xml; charset=UTF-8" : "text/html; charset=UTF-8"
|
|
1321
1338
|
});
|
|
1322
1339
|
} else if (url.protocol === "data:") {
|
|
1323
1340
|
const [head, body] = url.href.split(",", 2);
|
|
@@ -2545,7 +2562,11 @@ async function retrieveWebbookEntry({
|
|
|
2545
2562
|
manifest && JSON.stringify(manifest, null, 2)
|
|
2546
2563
|
);
|
|
2547
2564
|
return {
|
|
2548
|
-
entryHtmlFile: upath5.join(
|
|
2565
|
+
entryHtmlFile: upath5.join(
|
|
2566
|
+
outputDir,
|
|
2567
|
+
entryHtml,
|
|
2568
|
+
...upath5.extname(entryHtml) ? [] : ["index.html"]
|
|
2569
|
+
),
|
|
2549
2570
|
manifest
|
|
2550
2571
|
};
|
|
2551
2572
|
}
|
|
@@ -2603,7 +2624,9 @@ async function copyWebPublicationAssets({
|
|
|
2603
2624
|
manifestPath,
|
|
2604
2625
|
input,
|
|
2605
2626
|
outputDir,
|
|
2606
|
-
entries
|
|
2627
|
+
entries,
|
|
2628
|
+
customStyle,
|
|
2629
|
+
customUserStyle
|
|
2607
2630
|
}) {
|
|
2608
2631
|
const relExportAliases = exportAliases.map(({ source, target }) => ({
|
|
2609
2632
|
source: upath5.relative(input, source),
|
|
@@ -2615,7 +2638,9 @@ async function copyWebPublicationAssets({
|
|
|
2615
2638
|
cwd: input,
|
|
2616
2639
|
outputs,
|
|
2617
2640
|
themesDir,
|
|
2618
|
-
entries
|
|
2641
|
+
entries,
|
|
2642
|
+
customStyle,
|
|
2643
|
+
customUserStyle
|
|
2619
2644
|
}),
|
|
2620
2645
|
...await glob(
|
|
2621
2646
|
[
|
|
@@ -3058,10 +3083,13 @@ async function transformManuscript(entry, {
|
|
|
3058
3083
|
styleOptions: coverEntry
|
|
3059
3084
|
});
|
|
3060
3085
|
}
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3086
|
+
let html;
|
|
3087
|
+
if (content.window.document.contentType === "application/xhtml+xml") {
|
|
3088
|
+
html = `${XML_DECLARATION}
|
|
3089
|
+
${serializeToXml2(content.window.document)}`;
|
|
3090
|
+
} else {
|
|
3091
|
+
html = content.serialize();
|
|
3092
|
+
}
|
|
3065
3093
|
const htmlBuffer = Buffer.from(html, "utf8");
|
|
3066
3094
|
if (!source || source.type === "file" && !pathEquals(source.pathname, entry.target)) {
|
|
3067
3095
|
writeFileIfChanged(entry.target, htmlBuffer);
|
|
@@ -3157,6 +3185,8 @@ function getAssetMatcherSettings({
|
|
|
3157
3185
|
outputs,
|
|
3158
3186
|
themesDir,
|
|
3159
3187
|
entries,
|
|
3188
|
+
customStyle,
|
|
3189
|
+
customUserStyle,
|
|
3160
3190
|
cwd: cwd2,
|
|
3161
3191
|
ignore = []
|
|
3162
3192
|
}) {
|
|
@@ -3180,7 +3210,12 @@ function getAssetMatcherSettings({
|
|
|
3180
3210
|
// Step 2: Glob files matched with `includes`
|
|
3181
3211
|
// Ignore only files matched `excludes`
|
|
3182
3212
|
{
|
|
3183
|
-
patterns:
|
|
3213
|
+
patterns: [
|
|
3214
|
+
...includes,
|
|
3215
|
+
// Copy custom (user) style if specified
|
|
3216
|
+
customStyle,
|
|
3217
|
+
customUserStyle
|
|
3218
|
+
].filter((s) => Boolean(s)),
|
|
3184
3219
|
ignore: ignorePatterns
|
|
3185
3220
|
}
|
|
3186
3221
|
];
|
|
@@ -3211,7 +3246,9 @@ async function copyAssets({
|
|
|
3211
3246
|
copyAsset,
|
|
3212
3247
|
outputs,
|
|
3213
3248
|
themesDir,
|
|
3214
|
-
entries
|
|
3249
|
+
entries,
|
|
3250
|
+
customStyle,
|
|
3251
|
+
customUserStyle
|
|
3215
3252
|
}) {
|
|
3216
3253
|
if (pathEquals(entryContextDir, workspaceDir)) {
|
|
3217
3254
|
return;
|
|
@@ -3223,6 +3260,8 @@ async function copyAssets({
|
|
|
3223
3260
|
outputs,
|
|
3224
3261
|
themesDir,
|
|
3225
3262
|
entries,
|
|
3263
|
+
customStyle,
|
|
3264
|
+
customUserStyle,
|
|
3226
3265
|
ignore: [
|
|
3227
3266
|
// don't copy workspace itself
|
|
3228
3267
|
...relWorkspaceDir ? [upath6.join(relWorkspaceDir, "**")] : []
|
|
@@ -3323,7 +3362,7 @@ function vsDevServerPlugin({
|
|
|
3323
3362
|
let server;
|
|
3324
3363
|
let program;
|
|
3325
3364
|
const transformCache = /* @__PURE__ */ new Map();
|
|
3326
|
-
|
|
3365
|
+
let matchProjectDep;
|
|
3327
3366
|
async function reload(forceUpdate = false) {
|
|
3328
3367
|
const prevConfig = config;
|
|
3329
3368
|
config = await reloadConfig(prevConfig, inlineConfig, server?.config);
|
|
@@ -3366,14 +3405,34 @@ function vsDevServerPlugin({
|
|
|
3366
3405
|
serveAssetsMatcher
|
|
3367
3406
|
};
|
|
3368
3407
|
const configPath = locateVivliostyleConfig(inlineConfig);
|
|
3408
|
+
const projectDeps = [];
|
|
3369
3409
|
if (configPath) {
|
|
3370
|
-
projectDeps.
|
|
3410
|
+
projectDeps.push(configPath);
|
|
3371
3411
|
server?.watcher.add(configPath);
|
|
3372
3412
|
}
|
|
3373
3413
|
if (config.viewerInput.type === "webpub") {
|
|
3374
|
-
projectDeps.
|
|
3414
|
+
projectDeps.push(config.viewerInput.manifestPath);
|
|
3375
3415
|
server?.watcher.add(config.viewerInput.manifestPath);
|
|
3376
3416
|
}
|
|
3417
|
+
const flattenWatchTarget = (themes) => [...themes].flatMap((theme) => {
|
|
3418
|
+
if (theme.type === "file") {
|
|
3419
|
+
return [theme.source];
|
|
3420
|
+
}
|
|
3421
|
+
if (theme.type === "package" && !theme.registry) {
|
|
3422
|
+
return [theme.specifier];
|
|
3423
|
+
}
|
|
3424
|
+
return [];
|
|
3425
|
+
});
|
|
3426
|
+
const prevThemeFiles = flattenWatchTarget(prevConfig.themeIndexes);
|
|
3427
|
+
const themeFiles = flattenWatchTarget(config.themeIndexes);
|
|
3428
|
+
server?.watcher.unwatch(
|
|
3429
|
+
prevThemeFiles.filter((target) => !themeFiles.includes(target))
|
|
3430
|
+
);
|
|
3431
|
+
server?.watcher.add(themeFiles);
|
|
3432
|
+
projectDeps.push(...themeFiles);
|
|
3433
|
+
matchProjectDep = (pathname) => projectDeps.some(
|
|
3434
|
+
(dep) => pathEquals(dep, pathname) || pathContains(dep, pathname)
|
|
3435
|
+
);
|
|
3377
3436
|
}
|
|
3378
3437
|
async function transform(entry, config2, host) {
|
|
3379
3438
|
const rootUrl = host ? `${server?.config.server.https ? "https" : "http"}://${host}` : config2.rootUrl;
|
|
@@ -3390,7 +3449,7 @@ function vsDevServerPlugin({
|
|
|
3390
3449
|
}
|
|
3391
3450
|
return { content: html, etag };
|
|
3392
3451
|
} catch (error) {
|
|
3393
|
-
|
|
3452
|
+
server?.config.logger.error(getFormattedError(error));
|
|
3394
3453
|
transformCache.delete(entry.target);
|
|
3395
3454
|
return;
|
|
3396
3455
|
}
|
|
@@ -3493,7 +3552,7 @@ function vsDevServerPlugin({
|
|
|
3493
3552
|
configureServer(viteServer) {
|
|
3494
3553
|
server = viteServer;
|
|
3495
3554
|
const handleUpdate = async (pathname) => {
|
|
3496
|
-
if (!
|
|
3555
|
+
if (!matchProjectDep?.(pathname)) {
|
|
3497
3556
|
return;
|
|
3498
3557
|
}
|
|
3499
3558
|
await reload();
|
|
@@ -3643,7 +3702,8 @@ function getViewerParams(src, {
|
|
|
3643
3702
|
customUserStyle,
|
|
3644
3703
|
singleDoc,
|
|
3645
3704
|
quick,
|
|
3646
|
-
viewerParam
|
|
3705
|
+
viewerParam,
|
|
3706
|
+
base
|
|
3647
3707
|
}) {
|
|
3648
3708
|
const pageSizeValue = size && ("format" in size ? size.format : `${size.width} ${size.height}`);
|
|
3649
3709
|
function escapeParam(url) {
|
|
@@ -3652,10 +3712,12 @@ function getViewerParams(src, {
|
|
|
3652
3712
|
let viewerParams = src ? `src=${escapeParam(src)}` : "";
|
|
3653
3713
|
viewerParams += `&bookMode=${!singleDoc}&renderAllPages=${!quick}`;
|
|
3654
3714
|
if (customStyle) {
|
|
3655
|
-
|
|
3715
|
+
const param = isValidUri(customStyle) ? customStyle : upath10.posix.join(base, customStyle);
|
|
3716
|
+
viewerParams += `&style=${escapeParam(param)}`;
|
|
3656
3717
|
}
|
|
3657
3718
|
if (customUserStyle) {
|
|
3658
|
-
|
|
3719
|
+
const param = isValidUri(customUserStyle) ? customUserStyle : upath10.posix.join(base, customUserStyle);
|
|
3720
|
+
viewerParams += `&userStyle=${escapeParam(param)}`;
|
|
3659
3721
|
}
|
|
3660
3722
|
if (pageSizeValue || cropMarks || bleed || cropOffset || css) {
|
|
3661
3723
|
let pageStyle = "@page{";
|
|
@@ -3730,7 +3792,7 @@ async function getViewerFullUrl({
|
|
|
3730
3792
|
});
|
|
3731
3793
|
const viewerParams = getViewerParams(
|
|
3732
3794
|
sourceUrl === EMPTY_DATA_URI ? void 0 : sourceUrl,
|
|
3733
|
-
config
|
|
3795
|
+
{ base, ...config }
|
|
3734
3796
|
);
|
|
3735
3797
|
viewerUrl.hash = "";
|
|
3736
3798
|
return `${viewerUrl.href}#${viewerParams}`;
|
|
@@ -3847,4 +3909,4 @@ export {
|
|
|
3847
3909
|
getViewerFullUrl,
|
|
3848
3910
|
createViteServer
|
|
3849
3911
|
};
|
|
3850
|
-
//# sourceMappingURL=chunk-
|
|
3912
|
+
//# sourceMappingURL=chunk-XYOW6HSN.js.map
|