@vivliostyle/cli 10.2.0 → 10.3.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.
Files changed (37) hide show
  1. package/dist/{chunk-CKXFRCPH.js → chunk-3QOSSWIX.js} +129 -7
  2. package/dist/chunk-3QOSSWIX.js.map +1 -0
  3. package/dist/{chunk-5MEUINC4.js → chunk-ALY3QX7K.js} +530 -51
  4. package/dist/chunk-ALY3QX7K.js.map +1 -0
  5. package/dist/{chunk-E6QVHS6D.js → chunk-ECEGM36O.js} +2 -1
  6. package/dist/chunk-ECEGM36O.js.map +1 -0
  7. package/dist/{chunk-37OLZSNI.js → chunk-NVNEYZ3J.js} +4 -4
  8. package/dist/{chunk-O3CBPX4R.js → chunk-QLK3XMQI.js} +3 -3
  9. package/dist/{chunk-XMCTTVR7.js → chunk-RBKPG6VU.js} +2 -2
  10. package/dist/{chunk-T2VWLU2I.js → chunk-RILZCPJE.js} +5 -3
  11. package/dist/chunk-RILZCPJE.js.map +1 -0
  12. package/dist/{chunk-62AC6XGJ.js → chunk-WIGLU3EK.js} +4 -4
  13. package/dist/{chunk-BR2V7MHE.js → chunk-YNX6D2I6.js} +207 -53
  14. package/dist/chunk-YNX6D2I6.js.map +1 -0
  15. package/dist/commands/build.js +7 -7
  16. package/dist/commands/build.js.map +1 -1
  17. package/dist/commands/create.js +3 -3
  18. package/dist/commands/init.js +3 -3
  19. package/dist/commands/preview.js +6 -6
  20. package/dist/config/schema.d.ts +21143 -21173
  21. package/dist/config/schema.js +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +16 -10
  24. package/dist/index.js.map +1 -1
  25. package/dist/node-modules.d.ts +3 -1
  26. package/dist/node-modules.js +1 -1
  27. package/dist/vite-adapter.js +5 -5
  28. package/package.json +4 -3
  29. package/dist/chunk-5MEUINC4.js.map +0 -1
  30. package/dist/chunk-BR2V7MHE.js.map +0 -1
  31. package/dist/chunk-CKXFRCPH.js.map +0 -1
  32. package/dist/chunk-E6QVHS6D.js.map +0 -1
  33. package/dist/chunk-T2VWLU2I.js.map +0 -1
  34. /package/dist/{chunk-37OLZSNI.js.map → chunk-NVNEYZ3J.js.map} +0 -0
  35. /package/dist/{chunk-O3CBPX4R.js.map → chunk-QLK3XMQI.js.map} +0 -0
  36. /package/dist/{chunk-XMCTTVR7.js.map → chunk-RBKPG6VU.js.map} +0 -0
  37. /package/dist/{chunk-62AC6XGJ.js.map → chunk-WIGLU3EK.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  importNodeModule
3
- } from "./chunk-E6QVHS6D.js";
3
+ } from "./chunk-ECEGM36O.js";
4
4
  import {
5
5
  DetailError,
6
6
  GlobMatcher,
@@ -33,10 +33,10 @@ import {
33
33
  touchTmpFile,
34
34
  useTmpDirectory,
35
35
  writeFileIfChanged
36
- } from "./chunk-T2VWLU2I.js";
36
+ } from "./chunk-RILZCPJE.js";
37
37
  import {
38
38
  VivliostyleConfigSchema
39
- } from "./chunk-CKXFRCPH.js";
39
+ } from "./chunk-3QOSSWIX.js";
40
40
  import {
41
41
  CONTAINER_LOCAL_HOSTNAME,
42
42
  CONTAINER_URL,
@@ -77,7 +77,7 @@ function locateVivliostyleConfig({
77
77
  if (config) {
78
78
  return upath.resolve(cwd2, config);
79
79
  }
80
- return [".js", ".mjs", ".cjs", ".json"].map((ext) => upath.join(cwd2, `vivliostyle.config${ext}`)).find((p) => fs.existsSync(p));
80
+ return [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts", ".json"].map((ext) => upath.join(cwd2, `vivliostyle.config${ext}`)).find((p) => fs.existsSync(p));
81
81
  }
82
82
  async function loadVivliostyleConfig({
83
83
  config,
@@ -149,6 +149,25 @@ function warnDeprecatedConfig(config) {
149
149
  "'http' property of Vivliostyle config was deprecated and will be removed in a future release. This option is enabled by default, and the file protocol is no longer supported."
150
150
  );
151
151
  }
152
+ if (config.tasks.some((task) => task.pressReady !== void 0)) {
153
+ Logger.logWarn(
154
+ `'pressReady' property of Vivliostyle config was deprecated and will be removed in a future release. Please use 'pdfPostprocess.preflight: "press-ready"' property instead.`
155
+ );
156
+ }
157
+ if (config.tasks.some(
158
+ (task) => task.output && [task.output].flat().some((o) => o.preflight)
159
+ )) {
160
+ Logger.logWarn(
161
+ "'preflight' property of output config was deprecated and will be removed in a future release. Please use 'pdfPostprocess.preflight' property instead."
162
+ );
163
+ }
164
+ if (config.tasks.some(
165
+ (task) => task.output && [task.output].flat().some((o) => o.preflightOption)
166
+ )) {
167
+ Logger.logWarn(
168
+ "'preflightOption' property of output config was deprecated and will be removed in a future release. Please use 'pdfPostprocess.preflightOption' property instead."
169
+ );
170
+ }
152
171
  }
153
172
 
154
173
  // src/config/merge.ts
@@ -249,6 +268,7 @@ import { lookup as mime } from "mime-types";
249
268
  import fs3 from "node:fs";
250
269
  import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
251
270
  import npa from "npm-package-arg";
271
+ import { globSync } from "tinyglobby";
252
272
  import upath2 from "upath";
253
273
 
254
274
  // src/processor/markdown.ts
@@ -493,24 +513,105 @@ function resolveTaskConfig(config, options) {
493
513
  const customStyle = options.style && parseCustomStyle({ customStyle: options.style, entryContextDir }) || void 0;
494
514
  const customUserStyle = options.userStyle && parseCustomStyle({ customStyle: options.userStyle, entryContextDir }) || void 0;
495
515
  const outputs = (() => {
516
+ const resolveCmykConfig = (cmykOption) => {
517
+ if (cmykOption && typeof cmykOption === "object") {
518
+ return {
519
+ warnUnmapped: cmykOption.warnUnmapped ?? true,
520
+ overrideMap: cmykOption.overrideMap ?? [],
521
+ mapOutput: cmykOption.mapOutput ? upath2.resolve(context, cmykOption.mapOutput) : void 0
522
+ };
523
+ }
524
+ if (options.cmyk || cmykOption === true) {
525
+ return { warnUnmapped: true, overrideMap: [], mapOutput: void 0 };
526
+ }
527
+ return false;
528
+ };
529
+ const resolveReplaceImageConfig = (replaceImageOption) => {
530
+ if (!replaceImageOption) {
531
+ return [];
532
+ }
533
+ const allFiles = globSync("**/*", {
534
+ cwd: entryContextDir,
535
+ onlyFiles: true
536
+ });
537
+ return replaceImageOption.flatMap(({ source, replacement }) => {
538
+ if (source instanceof RegExp) {
539
+ return allFiles.filter((file) => source.test(file)).map((file) => ({
540
+ source: upath2.resolve(entryContextDir, file),
541
+ replacement: upath2.resolve(
542
+ entryContextDir,
543
+ file.replace(source, replacement)
544
+ )
545
+ }));
546
+ }
547
+ return {
548
+ source: upath2.resolve(entryContextDir, source),
549
+ replacement: upath2.resolve(entryContextDir, replacement)
550
+ };
551
+ });
552
+ };
553
+ const resolveDefaultPreflight = () => {
554
+ if (options.preflight) {
555
+ return options.preflight;
556
+ }
557
+ const pp = config.pdfPostprocess;
558
+ if (pp && "preflight" in pp) {
559
+ return pp.preflight;
560
+ }
561
+ if (config.pressReady) {
562
+ return "press-ready";
563
+ }
564
+ return void 0;
565
+ };
566
+ const resolveDefaultPreflightOption = () => {
567
+ if (options.preflightOption) {
568
+ return options.preflightOption;
569
+ }
570
+ return config.pdfPostprocess?.preflightOption ?? [];
571
+ };
496
572
  const defaultPdfOptions = {
497
573
  format: "pdf",
498
574
  renderMode: options.renderMode ?? "local",
499
- preflight: options.preflight ?? (config.pressReady ? "press-ready" : void 0),
500
- preflightOption: options.preflightOption ?? []
575
+ preflight: resolveDefaultPreflight(),
576
+ preflightOption: resolveDefaultPreflightOption(),
577
+ cmyk: resolveCmykConfig(config.pdfPostprocess?.cmyk),
578
+ replaceImage: resolveReplaceImageConfig(
579
+ config.pdfPostprocess?.replaceImage
580
+ )
501
581
  };
502
582
  if (config.output) {
503
583
  return config.output.map((target) => {
504
584
  const outputPath = upath2.resolve(context, target.path);
505
585
  const format = target.format;
506
586
  switch (format) {
507
- case "pdf":
587
+ case "pdf": {
588
+ const targetPp = target.pdfPostprocess;
589
+ const { pdfPostprocess: _, ...targetRest } = target;
590
+ const resolvedPreflight = (() => {
591
+ if (options.preflight) return options.preflight;
592
+ if (targetPp?.preflight) return targetPp.preflight;
593
+ if (target.preflight) return target.preflight;
594
+ return defaultPdfOptions.preflight;
595
+ })();
596
+ const resolvedPreflightOption = (() => {
597
+ if (options.preflightOption) return options.preflightOption;
598
+ if (targetPp?.preflightOption) return targetPp.preflightOption;
599
+ if (target.preflightOption) return target.preflightOption;
600
+ return defaultPdfOptions.preflightOption;
601
+ })();
602
+ const resolvedCmyk = targetPp?.cmyk !== void 0 ? resolveCmykConfig(targetPp.cmyk) : defaultPdfOptions.cmyk;
603
+ const resolvedReplaceImage = targetPp?.replaceImage !== void 0 ? resolveReplaceImageConfig(targetPp.replaceImage) : defaultPdfOptions.replaceImage;
508
604
  return {
509
605
  ...defaultPdfOptions,
510
- ...target,
606
+ ...targetRest,
511
607
  format,
512
- path: outputPath
608
+ path: outputPath,
609
+ preflight: resolvedPreflight,
610
+ preflightOption: resolvedPreflightOption,
611
+ cmyk: resolvedCmyk,
612
+ replaceImage: resolvedReplaceImage
513
613
  };
614
+ }
514
615
  case "epub":
515
616
  return {
516
617
  ...target,
@@ -1128,7 +1229,8 @@ async function launchBrowser({
1128
1229
  headless,
1129
1230
  noSandbox,
1130
1231
  disableDevShmUsage,
1131
- ignoreHttpsErrors
1232
+ ignoreHttpsErrors,
1233
+ protocolTimeout
1132
1234
  }) {
1133
1235
  const puppeteer = await importNodeModule("puppeteer-core");
1134
1236
  const args = [];
@@ -1197,7 +1299,8 @@ async function launchBrowser({
1197
1299
  browser: browserType === "chromium" ? "chrome" : browserType,
1198
1300
  headless,
1199
1301
  acceptInsecureCerts: ignoreHttpsErrors,
1200
- waitForInitialPage: false
1302
+ waitForInitialPage: false,
1303
+ protocolTimeout
1201
1304
  };
1202
1305
  Logger.debug("launchOptions %O", launchOptions);
1203
1306
  const browser = await puppeteer.launch({
@@ -1321,7 +1424,13 @@ async function launchPreview({
1321
1424
  url,
1322
1425
  onBrowserOpen,
1323
1426
  onPageOpen,
1324
- config: { browser: browserConfig, proxy, sandbox, ignoreHttpsErrors }
1427
+ config: {
1428
+ browser: browserConfig,
1429
+ proxy,
1430
+ sandbox,
1431
+ ignoreHttpsErrors,
1432
+ timeout
1433
+ }
1325
1434
  }) {
1326
1435
  let executableBrowser = browserConfig.executablePath;
1327
1436
  Logger.debug(`Specified browser path: ${executableBrowser}`);
@@ -1351,7 +1460,8 @@ async function launchPreview({
1351
1460
  headless: mode === "build",
1352
1461
  noSandbox: !sandbox,
1353
1462
  disableDevShmUsage: isInContainer(),
1354
- ignoreHttpsErrors
1463
+ ignoreHttpsErrors,
1464
+ protocolTimeout: timeout
1355
1465
  });
1356
1466
  await onBrowserOpen?.(browser);
1357
1467
  const page = (await browserContext.pages())[0] ?? await browserContext.newPage();
@@ -1378,7 +1488,7 @@ async function launchPreview({
1378
1488
  // src/server.ts
1379
1489
  import fs10 from "node:fs";
1380
1490
  import { URL as URL2 } from "node:url";
1381
- import upath11 from "upath";
1491
+ import upath12 from "upath";
1382
1492
  import {
1383
1493
  createServer,
1384
1494
  preview
@@ -1388,14 +1498,14 @@ import {
1388
1498
  import escapeRe from "escape-string-regexp";
1389
1499
  import { pathToFileURL as pathToFileURL6 } from "node:url";
1390
1500
  import sirv from "sirv";
1391
- import upath8 from "upath";
1501
+ import upath9 from "upath";
1392
1502
  import "vite";
1393
1503
 
1394
1504
  // src/processor/compile.ts
1395
1505
  import "@vivliostyle/jsdom";
1396
1506
  import { copy as copy3, move } from "fs-extra/esm";
1397
1507
  import fs8 from "node:fs";
1398
- import upath7 from "upath";
1508
+ import upath8 from "upath";
1399
1509
  import serializeToXml2 from "w3c-xmlserializer";
1400
1510
  import MIMEType2 from "whatwg-mimetype";
1401
1511
 
@@ -2991,10 +3101,37 @@ async function buildWebPublication({
2991
3101
  // src/processor/theme.ts
2992
3102
  import Arborist from "@npmcli/arborist";
2993
3103
  import fs7 from "node:fs";
3104
+ import upath7 from "upath";
3105
+ function* iterateSymlinksInThemesNodeModules(themesDir) {
3106
+ if (!fs7.existsSync(themesDir)) {
3107
+ return;
3108
+ }
3109
+ const nodeModulesDir = upath7.join(themesDir, "node_modules");
3110
+ if (!fs7.existsSync(nodeModulesDir)) {
3111
+ return;
3112
+ }
3113
+ for (const entry of fs7.readdirSync(nodeModulesDir, { withFileTypes: true })) {
3114
+ if (!entry.isSymbolicLink()) {
3115
+ continue;
3116
+ }
3117
+ const linkPath = upath7.join(nodeModulesDir, entry.name);
3118
+ const target = fs7.readlinkSync(linkPath);
3119
+ yield upath7.resolve(nodeModulesDir, target);
3120
+ }
3121
+ }
3122
+ function removeThemesDirIfBrokenSymlinks(themesDir) {
3123
+ for (const target of iterateSymlinksInThemesNodeModules(themesDir)) {
3124
+ if (!fs7.existsSync(target)) {
3125
+ fs7.rmSync(themesDir, { recursive: true });
3126
+ return;
3127
+ }
3128
+ }
3129
+ }
2994
3130
  async function checkThemeInstallationNecessity({
2995
3131
  themesDir,
2996
3132
  themeIndexes
2997
3133
  }) {
3134
+ removeThemesDirIfBrokenSymlinks(themesDir);
2998
3135
  if (!fs7.existsSync(themesDir)) {
2999
3136
  return [...themeIndexes].some((theme) => theme.type === "package");
3000
3137
  }
@@ -3010,11 +3147,17 @@ async function checkThemeInstallationNecessity({
3010
3147
  (theme) => theme.type === "package" && !pkgs.includes(theme.name)
3011
3148
  );
3012
3149
  }
3150
+ function getLocalThemePaths({
3151
+ themesDir
3152
+ }) {
3153
+ return [...iterateSymlinksInThemesNodeModules(themesDir)];
3154
+ }
3013
3155
  async function installThemeDependencies({
3014
3156
  themesDir,
3015
3157
  themeIndexes
3016
3158
  }) {
3017
3159
  fs7.mkdirSync(themesDir, { recursive: true });
3160
+ removeThemesDirIfBrokenSymlinks(themesDir);
3018
3161
  try {
3019
3162
  const commonOpt = {
3020
3163
  path: themesDir,
@@ -3033,8 +3176,17 @@ async function installThemeDependencies({
3033
3176
  const rm = existing.filter((v2) => !add.includes(v2));
3034
3177
  const opt = { ...commonOpt, rm, add };
3035
3178
  const arb = new Arborist(opt);
3036
- await arb.reify(opt);
3037
- return;
3179
+ const actualTree = await arb.reify(opt);
3180
+ for (const child of actualTree.children.values()) {
3181
+ if (child.resolved?.startsWith("file:")) {
3182
+ const sourcePath = upath7.resolve(themesDir, child.resolved.slice(5));
3183
+ if (fs7.existsSync(child.path)) {
3184
+ fs7.rmSync(child.path, { recursive: true });
3185
+ }
3186
+ const relPath = upath7.relative(upath7.dirname(child.path), sourcePath);
3187
+ fs7.symlinkSync(relPath, child.path, "junction");
3188
+ }
3189
+ }
3038
3190
  } catch (error) {
3039
3191
  const thrownError = error;
3040
3192
  throw new DetailError(
@@ -3050,20 +3202,20 @@ function locateThemePath(theme, from) {
3050
3202
  return theme.location;
3051
3203
  }
3052
3204
  if (theme.type === "file") {
3053
- return upath7.relative(from, theme.location);
3205
+ return upath8.relative(from, theme.location);
3054
3206
  }
3055
3207
  if (theme.importPath) {
3056
3208
  return [theme.importPath].flat().map((locator) => {
3057
- const resolvedPath = upath7.resolve(theme.location, locator);
3209
+ const resolvedPath = upath8.resolve(theme.location, locator);
3058
3210
  if (!pathContains(theme.location, resolvedPath) || !fs8.existsSync(resolvedPath)) {
3059
3211
  throw new Error(
3060
3212
  `Could not find a style path ${theme.importPath} for the theme: ${theme.name}.`
3061
3213
  );
3062
3214
  }
3063
- return upath7.relative(from, resolvedPath);
3215
+ return upath8.relative(from, resolvedPath);
3064
3216
  });
3065
3217
  } else {
3066
- const pkgJsonPath = upath7.join(theme.location, "package.json");
3218
+ const pkgJsonPath = upath8.join(theme.location, "package.json");
3067
3219
  const packageJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf8"));
3068
3220
  const maybeStyle = packageJson?.vivliostyle?.theme?.style ?? packageJson.style ?? packageJson.main;
3069
3221
  if (!maybeStyle) {
@@ -3072,7 +3224,7 @@ function locateThemePath(theme, from) {
3072
3224
  "Please ensure this package satisfies a `vivliostyle.theme.style` property."
3073
3225
  );
3074
3226
  }
3075
- return upath7.relative(from, upath7.join(theme.location, maybeStyle));
3227
+ return upath8.relative(from, upath8.join(theme.location, maybeStyle));
3076
3228
  }
3077
3229
  }
3078
3230
  async function cleanupWorkspace({
@@ -3089,15 +3241,15 @@ async function cleanupWorkspace({
3089
3241
  Logger.debug("cleanup workspace files", workspaceDir);
3090
3242
  let movedWorkspacePath;
3091
3243
  if (pathContains(workspaceDir, themesDir) && fs8.existsSync(themesDir)) {
3092
- movedWorkspacePath = upath7.join(
3093
- upath7.dirname(workspaceDir),
3244
+ movedWorkspacePath = upath8.join(
3245
+ upath8.dirname(workspaceDir),
3094
3246
  `.vs-${Date.now()}`
3095
3247
  );
3096
- const movedThemePath = upath7.join(
3248
+ const movedThemePath = upath8.join(
3097
3249
  movedWorkspacePath,
3098
- upath7.relative(workspaceDir, themesDir)
3250
+ upath8.relative(workspaceDir, themesDir)
3099
3251
  );
3100
- fs8.mkdirSync(upath7.dirname(movedThemePath), { recursive: true });
3252
+ fs8.mkdirSync(upath8.dirname(movedThemePath), { recursive: true });
3101
3253
  registerExitHandler(
3102
3254
  `Removing the moved workspace directory: ${movedWorkspacePath}`,
3103
3255
  () => {
@@ -3117,10 +3269,10 @@ async function prepareThemeDirectory({
3117
3269
  themesDir,
3118
3270
  themeIndexes
3119
3271
  }) {
3120
- if (fs8.existsSync(upath7.join(themesDir, "packages")) && !fs8.existsSync(upath7.join(themesDir, "node_modules"))) {
3272
+ if (fs8.existsSync(upath8.join(themesDir, "packages")) && !fs8.existsSync(upath8.join(themesDir, "node_modules"))) {
3121
3273
  fs8.renameSync(
3122
- upath7.join(themesDir, "packages"),
3123
- upath7.join(themesDir, "node_modules")
3274
+ upath8.join(themesDir, "packages"),
3275
+ upath8.join(themesDir, "node_modules")
3124
3276
  );
3125
3277
  }
3126
3278
  if (await checkThemeInstallationNecessity({ themesDir, themeIndexes })) {
@@ -3129,10 +3281,11 @@ async function prepareThemeDirectory({
3129
3281
  }
3130
3282
  for (const theme of themeIndexes) {
3131
3283
  if (theme.type === "file" && !pathEquals(theme.source, theme.location)) {
3132
- fs8.mkdirSync(upath7.dirname(theme.location), { recursive: true });
3284
+ fs8.mkdirSync(upath8.dirname(theme.location), { recursive: true });
3133
3285
  await copy3(theme.source, theme.location);
3134
3286
  }
3135
3287
  }
3288
+ return getLocalThemePaths({ themesDir });
3136
3289
  }
3137
3290
  async function transformManuscript(entry, {
3138
3291
  entryContextDir,
@@ -3149,7 +3302,7 @@ async function transformManuscript(entry, {
3149
3302
  let resourceLoader;
3150
3303
  let resourceUrl;
3151
3304
  const style = entry.themes.flatMap(
3152
- (theme) => locateThemePath(theme, upath7.dirname(entry.target))
3305
+ (theme) => locateThemePath(theme, upath8.dirname(entry.target))
3153
3306
  );
3154
3307
  if (source?.type === "file") {
3155
3308
  if (source.documentProcessor) {
@@ -3245,7 +3398,7 @@ async function transformManuscript(entry, {
3245
3398
  content = await processTocHtml(content, {
3246
3399
  entries: manuscriptEntries,
3247
3400
  manifestPath,
3248
- distDir: upath7.dirname(contentsEntry.target),
3401
+ distDir: upath8.dirname(contentsEntry.target),
3249
3402
  tocTitle: contentsEntry.tocTitle,
3250
3403
  sectionDepth: contentsEntry.sectionDepth,
3251
3404
  styleOptions: contentsEntry,
@@ -3255,10 +3408,10 @@ async function transformManuscript(entry, {
3255
3408
  if (entry.rel === "cover") {
3256
3409
  const coverEntry = entry;
3257
3410
  content = await processCoverHtml(content, {
3258
- imageSrc: upath7.relative(
3259
- upath7.join(
3411
+ imageSrc: upath8.relative(
3412
+ upath8.join(
3260
3413
  entryContextDir,
3261
- upath7.relative(workspaceDir, coverEntry.target),
3414
+ upath8.relative(workspaceDir, coverEntry.target),
3262
3415
  ".."
3263
3416
  ),
3264
3417
  coverEntry.coverImageSrc
@@ -3308,7 +3461,7 @@ async function generateManifest({
3308
3461
  }) {
3309
3462
  const manifestEntries = entries.map((entry) => ({
3310
3463
  title: entry.rel === "contents" && entry.tocTitle || entry.title,
3311
- path: upath7.relative(workspaceDir, entry.target),
3464
+ path: upath8.relative(workspaceDir, entry.target),
3312
3465
  encodingFormat: !("contentType" in entry) || entry.contentType === "text/markdown" || entry.contentType === "text/x-vivliostyle-custom" || entry.contentType === "text/html" ? void 0 : entry.contentType,
3313
3466
  rel: entry.rel
3314
3467
  }));
@@ -3318,7 +3471,7 @@ async function generateManifest({
3318
3471
  language,
3319
3472
  readingProgression,
3320
3473
  cover: cover && {
3321
- url: upath7.relative(entryContextDir, cover.src),
3474
+ url: upath8.relative(entryContextDir, cover.src),
3322
3475
  name: cover.name
3323
3476
  },
3324
3477
  entries: manifestEntries,
@@ -3374,7 +3527,7 @@ function createEntriesRouteLookup(entries, cwd2) {
3374
3527
  return arr;
3375
3528
  };
3376
3529
  const cache = entries.reduce((acc, e) => {
3377
- acc[`/${upath8.relative(cwd2, e.target).normalize().replace(/\\+/g, "/")}`] = e;
3530
+ acc[`/${upath9.relative(cwd2, e.target).normalize().replace(/\\+/g, "/")}`] = e;
3378
3531
  return acc;
3379
3532
  }, {});
3380
3533
  return (uri) => {
@@ -3407,8 +3560,8 @@ function getWorkspaceMatcher({
3407
3560
  switch (viewerInput.type) {
3408
3561
  case "epub":
3409
3562
  entryFiles = [
3410
- upath8.join(
3411
- upath8.relative(workspaceDir, viewerInput.epubTmpOutputDir),
3563
+ upath9.join(
3564
+ upath9.relative(workspaceDir, viewerInput.epubTmpOutputDir),
3412
3565
  "**"
3413
3566
  )
3414
3567
  ];
@@ -3447,7 +3600,7 @@ function vsDevServerPlugin({
3447
3600
  if (isWebPubConfig(config) && config.viewerInput.needToGenerateManifest && needToUpdateManifest) {
3448
3601
  await generateManifest(config);
3449
3602
  }
3450
- await prepareThemeDirectory(config);
3603
+ const localThemePaths = await prepareThemeDirectory(config);
3451
3604
  const entriesLookup = createEntriesRouteLookup(
3452
3605
  config.entries,
3453
3606
  config.workspaceDir
@@ -3514,7 +3667,8 @@ function vsDevServerPlugin({
3514
3667
  prevThemeFiles.filter((target) => !themeFiles.includes(target))
3515
3668
  );
3516
3669
  server?.watcher.add(themeFiles);
3517
- projectDeps.push(...themeFiles);
3670
+ server?.watcher.add(localThemePaths);
3671
+ projectDeps.push(...themeFiles, ...localThemePaths);
3518
3672
  matchProjectDep = (pathname) => projectDeps.some(
3519
3673
  (dep) => pathEquals(dep, pathname) || pathContains(dep, pathname)
3520
3674
  );
@@ -3713,7 +3867,7 @@ function vsDevServerPlugin({
3713
3867
 
3714
3868
  // src/vite/vite-plugin-static-serve.ts
3715
3869
  import sirv2 from "sirv";
3716
- import upath9 from "upath";
3870
+ import upath10 from "upath";
3717
3871
  import "vite";
3718
3872
  function vsStaticServePlugin({
3719
3873
  config: _config,
@@ -3728,7 +3882,7 @@ function vsStaticServePlugin({
3728
3882
  ([base, dirs]) => dirs.map(
3729
3883
  (dir) => [
3730
3884
  base,
3731
- sirv2(upath9.resolve(config.serverRootDir, dir), {
3885
+ sirv2(upath10.resolve(config.serverRootDir, dir), {
3732
3886
  dev: true,
3733
3887
  etag: false
3734
3888
  })
@@ -3759,7 +3913,7 @@ function vsStaticServePlugin({
3759
3913
  // src/vite/vite-plugin-viewer.ts
3760
3914
  import fs9 from "node:fs";
3761
3915
  import sirv3 from "sirv";
3762
- import upath10 from "upath";
3916
+ import upath11 from "upath";
3763
3917
  import "vite";
3764
3918
  var viewerClientId = "@vivliostyle:viewer:client";
3765
3919
  var viewerClientRequestPath = `/${viewerClientId}`;
@@ -3773,13 +3927,13 @@ if (import.meta.hot) {
3773
3927
  }`
3774
3928
  );
3775
3929
  function vsViewerPlugin(_) {
3776
- const serveRootDir = upath10.join(viewerRoot, "lib");
3930
+ const serveRootDir = upath11.join(viewerRoot, "lib");
3777
3931
  const serve = sirv3(serveRootDir, { dev: false, etag: true });
3778
3932
  let cachedIndexHtml;
3779
3933
  const middleware = async function vivliostyleViewerMiddleware(req, res, next) {
3780
3934
  if (req.url === "/" || req.url === "/index.html") {
3781
3935
  cachedIndexHtml ??= prependToHead(
3782
- fs9.readFileSync(upath10.join(serveRootDir, "index.html"), "utf-8"),
3936
+ fs9.readFileSync(upath11.join(serveRootDir, "index.html"), "utf-8"),
3783
3937
  `<script type="module" src="${viewerClientRequestPath}"></script>`
3784
3938
  );
3785
3939
  res.statusCode = 200;
@@ -3834,11 +3988,11 @@ function getViewerParams(src, {
3834
3988
  let viewerParams = src ? `src=${escapeParam(src)}` : "";
3835
3989
  viewerParams += `&bookMode=${!singleDoc}&renderAllPages=${!quick}`;
3836
3990
  if (customStyle) {
3837
- const param = isValidUri(customStyle) ? customStyle : upath11.posix.join(base, customStyle);
3991
+ const param = isValidUri(customStyle) ? customStyle : upath12.posix.join(base, customStyle);
3838
3992
  viewerParams += `&style=${escapeParam(param)}`;
3839
3993
  }
3840
3994
  if (customUserStyle) {
3841
- const param = isValidUri(customUserStyle) ? customUserStyle : upath11.posix.join(base, customUserStyle);
3995
+ const param = isValidUri(customUserStyle) ? customUserStyle : upath12.posix.join(base, customUserStyle);
3842
3996
  viewerParams += `&userStyle=${escapeParam(param)}`;
3843
3997
  }
3844
3998
  if (pageSizeValue || cropMarks || bleed || cropOffset || css) {
@@ -3893,7 +4047,7 @@ async function getSourceUrl({
3893
4047
  input = viewerInput;
3894
4048
  }
3895
4049
  return (isValidUri(input) ? new URL2(input) : new URL2(
3896
- upath11.posix.join(base, upath11.relative(workspaceDir, input)),
4050
+ upath12.posix.join(base, upath12.relative(workspaceDir, input)),
3897
4051
  rootUrl
3898
4052
  )).href;
3899
4053
  }
@@ -4036,4 +4190,4 @@ export {
4036
4190
  getViewerFullUrl,
4037
4191
  createViteServer
4038
4192
  };
4039
- //# sourceMappingURL=chunk-BR2V7MHE.js.map
4193
+ //# sourceMappingURL=chunk-YNX6D2I6.js.map