@vivliostyle/cli 9.0.0-next.2 → 9.0.0-next.4

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 (186) hide show
  1. package/dist/chunk-BIEQXUOY.js +50 -0
  2. package/dist/chunk-DMARNPN5.js +1073 -0
  3. package/dist/chunk-DMGAKSPH.js +590 -0
  4. package/dist/{core/init.js → chunk-E7QOXL6M.js} +39 -26
  5. package/dist/chunk-EX7EA34F.js +64 -0
  6. package/dist/chunk-LASMQBPP.js +85 -0
  7. package/dist/chunk-QC3BOE2G.js +74 -0
  8. package/dist/chunk-VBEHGS67.js +4990 -0
  9. package/dist/chunk-WX6JHPSL.js +16 -0
  10. package/dist/chunk-Y3ETBU5J.js +54 -0
  11. package/dist/cli.d.ts +0 -2
  12. package/dist/cli.js +17 -18
  13. package/dist/commands/build.d.ts +2 -2
  14. package/dist/commands/build.js +165 -17
  15. package/dist/commands/init.d.ts +2 -2
  16. package/dist/commands/init.js +35 -12
  17. package/dist/commands/preview.d.ts +2 -2
  18. package/dist/commands/preview.js +98 -12
  19. package/dist/config/schema.d.ts +1707 -1671
  20. package/dist/config/schema.js +50 -575
  21. package/dist/index.d.ts +116 -7
  22. package/dist/index.js +38 -42
  23. package/dist/node-modules.d.ts +21 -0
  24. package/dist/node-modules.js +9 -0
  25. package/dist/vite-adapter.d.ts +8 -2
  26. package/dist/vite-adapter.js +11 -28
  27. package/package.json +34 -15
  28. package/dist/browser.d.ts +0 -19
  29. package/dist/browser.d.ts.map +0 -1
  30. package/dist/browser.js +0 -154
  31. package/dist/browser.js.map +0 -1
  32. package/dist/cli.d.ts.map +0 -1
  33. package/dist/cli.js.map +0 -1
  34. package/dist/commands/build.d.ts.map +0 -1
  35. package/dist/commands/build.js.map +0 -1
  36. package/dist/commands/build.parser.d.ts +0 -3
  37. package/dist/commands/build.parser.d.ts.map +0 -1
  38. package/dist/commands/build.parser.js +0 -102
  39. package/dist/commands/build.parser.js.map +0 -1
  40. package/dist/commands/cli-flags.d.ts +0 -42
  41. package/dist/commands/cli-flags.d.ts.map +0 -1
  42. package/dist/commands/cli-flags.js +0 -58
  43. package/dist/commands/cli-flags.js.map +0 -1
  44. package/dist/commands/init.d.ts.map +0 -1
  45. package/dist/commands/init.js.map +0 -1
  46. package/dist/commands/init.parser.d.ts +0 -3
  47. package/dist/commands/init.parser.d.ts.map +0 -1
  48. package/dist/commands/init.parser.js +0 -17
  49. package/dist/commands/init.parser.js.map +0 -1
  50. package/dist/commands/preview.d.ts.map +0 -1
  51. package/dist/commands/preview.js.map +0 -1
  52. package/dist/commands/preview.parser.d.ts +0 -3
  53. package/dist/commands/preview.parser.d.ts.map +0 -1
  54. package/dist/commands/preview.parser.js +0 -50
  55. package/dist/commands/preview.parser.js.map +0 -1
  56. package/dist/config/load.d.ts +0 -4
  57. package/dist/config/load.d.ts.map +0 -1
  58. package/dist/config/load.js +0 -75
  59. package/dist/config/load.js.map +0 -1
  60. package/dist/config/merge.d.ts +0 -4
  61. package/dist/config/merge.d.ts.map +0 -1
  62. package/dist/config/merge.js +0 -55
  63. package/dist/config/merge.js.map +0 -1
  64. package/dist/config/resolve.d.ts +0 -205
  65. package/dist/config/resolve.d.ts.map +0 -1
  66. package/dist/config/resolve.js +0 -770
  67. package/dist/config/resolve.js.map +0 -1
  68. package/dist/config/schema.d.ts.map +0 -1
  69. package/dist/config/schema.js.map +0 -1
  70. package/dist/config/vite.d.ts +0 -6
  71. package/dist/config/vite.d.ts.map +0 -1
  72. package/dist/config/vite.js +0 -47
  73. package/dist/config/vite.js.map +0 -1
  74. package/dist/const.d.ts +0 -20
  75. package/dist/const.d.ts.map +0 -1
  76. package/dist/const.js +0 -41
  77. package/dist/const.js.map +0 -1
  78. package/dist/container.d.ts +0 -21
  79. package/dist/container.d.ts.map +0 -1
  80. package/dist/container.js +0 -175
  81. package/dist/container.js.map +0 -1
  82. package/dist/core/build.d.ts +0 -3
  83. package/dist/core/build.d.ts.map +0 -1
  84. package/dist/core/build.js +0 -167
  85. package/dist/core/build.js.map +0 -1
  86. package/dist/core/init.d.ts +0 -3
  87. package/dist/core/init.d.ts.map +0 -1
  88. package/dist/core/init.js.map +0 -1
  89. package/dist/core/preview.d.ts +0 -4
  90. package/dist/core/preview.d.ts.map +0 -1
  91. package/dist/core/preview.js +0 -113
  92. package/dist/core/preview.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist/logger.d.ts +0 -23
  96. package/dist/logger.d.ts.map +0 -1
  97. package/dist/logger.js +0 -162
  98. package/dist/logger.js.map +0 -1
  99. package/dist/output/epub.d.ts +0 -10
  100. package/dist/output/epub.d.ts.map +0 -1
  101. package/dist/output/epub.js +0 -505
  102. package/dist/output/epub.js.map +0 -1
  103. package/dist/output/pdf-postprocess.d.ts +0 -30
  104. package/dist/output/pdf-postprocess.d.ts.map +0 -1
  105. package/dist/output/pdf-postprocess.js +0 -270
  106. package/dist/output/pdf-postprocess.js.map +0 -1
  107. package/dist/output/pdf.d.ts +0 -6
  108. package/dist/output/pdf.d.ts.map +0 -1
  109. package/dist/output/pdf.js +0 -200
  110. package/dist/output/pdf.js.map +0 -1
  111. package/dist/output/webbook.d.ts +0 -45
  112. package/dist/output/webbook.d.ts.map +0 -1
  113. package/dist/output/webbook.js +0 -413
  114. package/dist/output/webbook.js.map +0 -1
  115. package/dist/processor/compile.d.ts +0 -30
  116. package/dist/processor/compile.d.ts.map +0 -1
  117. package/dist/processor/compile.js +0 -349
  118. package/dist/processor/compile.js.map +0 -1
  119. package/dist/processor/html.d.ts +0 -107
  120. package/dist/processor/html.d.ts.map +0 -1
  121. package/dist/processor/html.js +0 -494
  122. package/dist/processor/html.js.map +0 -1
  123. package/dist/processor/markdown.d.ts +0 -12
  124. package/dist/processor/markdown.d.ts.map +0 -1
  125. package/dist/processor/markdown.js +0 -23
  126. package/dist/processor/markdown.js.map +0 -1
  127. package/dist/processor/theme.d.ts +0 -4
  128. package/dist/processor/theme.d.ts.map +0 -1
  129. package/dist/processor/theme.js +0 -41
  130. package/dist/processor/theme.js.map +0 -1
  131. package/dist/schema/pub-manifest.d.ts +0 -4
  132. package/dist/schema/pub-manifest.d.ts.map +0 -1
  133. package/dist/schema/pub-manifest.js +0 -41
  134. package/dist/schema/pub-manifest.js.map +0 -1
  135. package/dist/schema/publication.schema.d.ts +0 -104
  136. package/dist/schema/publication.schema.d.ts.map +0 -1
  137. package/dist/schema/publication.schema.js +0 -8
  138. package/dist/schema/publication.schema.js.map +0 -1
  139. package/dist/server.d.ts +0 -20
  140. package/dist/server.d.ts.map +0 -1
  141. package/dist/server.js +0 -117
  142. package/dist/server.js.map +0 -1
  143. package/dist/util.d.ts +0 -55
  144. package/dist/util.d.ts.map +0 -1
  145. package/dist/util.js +0 -269
  146. package/dist/util.js.map +0 -1
  147. package/dist/vite/plugin-util.d.ts +0 -6
  148. package/dist/vite/plugin-util.d.ts.map +0 -1
  149. package/dist/vite/plugin-util.js +0 -18
  150. package/dist/vite/plugin-util.js.map +0 -1
  151. package/dist/vite/vite-plugin-browser.d.ts +0 -8
  152. package/dist/vite/vite-plugin-browser.d.ts.map +0 -1
  153. package/dist/vite/vite-plugin-browser.js +0 -54
  154. package/dist/vite/vite-plugin-browser.js.map +0 -1
  155. package/dist/vite/vite-plugin-dev-server.d.ts +0 -8
  156. package/dist/vite/vite-plugin-dev-server.d.ts.map +0 -1
  157. package/dist/vite/vite-plugin-dev-server.js +0 -270
  158. package/dist/vite/vite-plugin-dev-server.js.map +0 -1
  159. package/dist/vite/vite-plugin-static-serve.d.ts +0 -8
  160. package/dist/vite/vite-plugin-static-serve.d.ts.map +0 -1
  161. package/dist/vite/vite-plugin-static-serve.js +0 -31
  162. package/dist/vite/vite-plugin-static-serve.js.map +0 -1
  163. package/dist/vite/vite-plugin-viewer.d.ts +0 -8
  164. package/dist/vite/vite-plugin-viewer.d.ts.map +0 -1
  165. package/dist/vite/vite-plugin-viewer.js +0 -52
  166. package/dist/vite/vite-plugin-viewer.js.map +0 -1
  167. package/dist/vite-adapter.d.ts.map +0 -1
  168. package/dist/vite-adapter.js.map +0 -1
  169. package/schemas/pub-manifest/README.md +0 -5
  170. package/schemas/pub-manifest/module/ItemList.schema.json +0 -32
  171. package/schemas/pub-manifest/module/bcp.schema.json +0 -7
  172. package/schemas/pub-manifest/module/context.schema.json +0 -62
  173. package/schemas/pub-manifest/module/contributor-object.schema.json +0 -42
  174. package/schemas/pub-manifest/module/contributor.schema.json +0 -26
  175. package/schemas/pub-manifest/module/date.schema.json +0 -7
  176. package/schemas/pub-manifest/module/duration.schema.json +0 -7
  177. package/schemas/pub-manifest/module/item-lists.schema.json +0 -16
  178. package/schemas/pub-manifest/module/language.schema.json +0 -16
  179. package/schemas/pub-manifest/module/link.schema.json +0 -60
  180. package/schemas/pub-manifest/module/localizable-object.schema.json +0 -15
  181. package/schemas/pub-manifest/module/localizable.schema.json +0 -26
  182. package/schemas/pub-manifest/module/resource.categorization.schema.json +0 -31
  183. package/schemas/pub-manifest/module/strings.schema.json +0 -9
  184. package/schemas/pub-manifest/module/url.schema.json +0 -7
  185. package/schemas/pub-manifest/module/urls.schema.json +0 -18
  186. package/schemas/pub-manifest/publication.schema.json +0 -123
@@ -0,0 +1,1073 @@
1
+ // src/config/schema.ts
2
+ import upath from "upath";
3
+ import * as v from "valibot";
4
+ var $ = (strings, ...values) => {
5
+ const lines = String.raw({ raw: strings }, ...values).split("\n");
6
+ const indent = lines.filter((line) => line.trim()).map((line) => line.match(/^\s*/)?.[0].length ?? 0).reduce((min, len) => Math.min(min, len), Infinity);
7
+ return lines.map((line) => line.slice(indent)).join("\n").trim();
8
+ };
9
+ var StructuredDocument = v.pipe(
10
+ v.object({
11
+ title: v.string(),
12
+ href: v.string(),
13
+ children: v.array(v.lazy(() => StructuredDocument)),
14
+ sections: v.optional(v.array(v.lazy(() => StructuredDocumentSection)))
15
+ }),
16
+ v.title("StructuredDocument")
17
+ );
18
+ var StructuredDocumentSection = v.pipe(
19
+ v.object({
20
+ headingHtml: v.string(),
21
+ headingText: v.string(),
22
+ level: v.number(),
23
+ children: v.array(v.lazy(() => StructuredDocumentSection)),
24
+ href: v.optional(v.string()),
25
+ id: v.optional(v.string())
26
+ }),
27
+ v.title("StructuredDocumentSection")
28
+ );
29
+ var ValidString = v.pipe(
30
+ v.string(),
31
+ v.trim(),
32
+ v.minLength(1, "At least one character is required")
33
+ );
34
+ var ThemeConfig = v.pipe(
35
+ v.intersect([
36
+ v.required(
37
+ v.object({
38
+ specifier: v.pipe(
39
+ ValidString,
40
+ v.description($`
41
+ The specifier name for importing the theme package or the path to a CSS file.
42
+ - An npm-style package argument is allowed (e.g., \`@vivliostyle/theme-academic@1\`, \`./local-pkg\`).
43
+ - A URL or a local path to a CSS file is allowed (e.g., \`./style.css\`, \`https://example.com/style.css\`).
44
+ `)
45
+ )
46
+ }),
47
+ "Missing required field: specifier"
48
+ ),
49
+ v.partial(
50
+ v.object({
51
+ import: v.pipe(
52
+ v.union([v.array(ValidString), ValidString]),
53
+ v.transform((input) => [input].flat()),
54
+ v.description($`
55
+ The path(s) to the CSS file(s) to import from the package.
56
+ Specify this if you want to import files other than the default.
57
+ `)
58
+ )
59
+ })
60
+ )
61
+ ]),
62
+ v.title("ThemeConfig")
63
+ );
64
+ var ThemeSpecifier = v.pipe(
65
+ v.union([
66
+ v.array(v.union([ThemeConfig, ValidString])),
67
+ ThemeConfig,
68
+ ValidString
69
+ ]),
70
+ v.transform(
71
+ (input) => [input].flat().map((item) => typeof item === "string" ? { specifier: item } : item)
72
+ )
73
+ );
74
+ var ArticleEntryConfig = v.pipe(
75
+ v.required(
76
+ v.object({
77
+ path: ValidString,
78
+ output: v.optional(ValidString),
79
+ title: v.optional(ValidString),
80
+ theme: v.optional(ThemeSpecifier),
81
+ encodingFormat: v.optional(ValidString),
82
+ rel: v.optional(
83
+ v.pipe(
84
+ v.union([v.array(ValidString), ValidString]),
85
+ v.transform((input) => [input].flat())
86
+ )
87
+ )
88
+ }),
89
+ ["path"],
90
+ "Missing required field: path"
91
+ ),
92
+ v.title("ArticleEntryConfig")
93
+ );
94
+ var PageBreak = v.union([
95
+ v.literal("left"),
96
+ v.literal("right"),
97
+ v.literal("recto"),
98
+ v.literal("verso")
99
+ ]);
100
+ var ContentsEntryConfig = v.pipe(
101
+ v.object({
102
+ rel: v.literal("contents"),
103
+ path: v.optional(ValidString),
104
+ output: v.optional(ValidString),
105
+ title: v.optional(ValidString),
106
+ theme: v.optional(ThemeSpecifier),
107
+ pageBreakBefore: v.pipe(
108
+ v.optional(PageBreak),
109
+ v.description($`
110
+ Specifies the page break position before this document.
111
+ Useful for determining which side the first page of the document should be placed on in a two-page spread.
112
+ `)
113
+ ),
114
+ pageCounterReset: v.pipe(
115
+ v.optional(v.pipe(v.number(), v.safeInteger())),
116
+ v.description($`
117
+ Resets the starting page number of this document to the specified integer.
118
+ Useful for controlling page numbers when including a page.
119
+ `)
120
+ )
121
+ }),
122
+ v.title("ContentsEntryConfig")
123
+ );
124
+ var CoverEntryConfig = v.pipe(
125
+ v.object({
126
+ rel: v.literal("cover"),
127
+ path: v.optional(ValidString),
128
+ output: v.optional(ValidString),
129
+ title: v.optional(ValidString),
130
+ theme: v.optional(ThemeSpecifier),
131
+ imageSrc: v.optional(ValidString),
132
+ imageAlt: v.optional(v.string()),
133
+ // Allow empty string
134
+ pageBreakBefore: v.pipe(
135
+ v.optional(PageBreak),
136
+ v.description($`
137
+ Specifies the page break position before this document.
138
+ Useful for determining which side the first page of the document should be placed on in a two-page spread.
139
+ `)
140
+ )
141
+ }),
142
+ v.title("CoverEntryConfig")
143
+ );
144
+ var EntryConfig = v.union([
145
+ ContentsEntryConfig,
146
+ CoverEntryConfig,
147
+ ArticleEntryConfig
148
+ ]);
149
+ var OutputFormat = v.union([
150
+ v.literal("pdf"),
151
+ v.literal("epub"),
152
+ v.literal("webpub")
153
+ ]);
154
+ var RenderMode = v.union([v.literal("local"), v.literal("docker")]);
155
+ var OutputConfig = v.pipe(
156
+ v.intersect([
157
+ v.required(
158
+ v.object({
159
+ path: v.pipe(
160
+ ValidString,
161
+ v.description($`
162
+ Specifies the output file name or directory. (default: \`<title>.pdf\`)
163
+ `)
164
+ )
165
+ }),
166
+ "Missing required field: path"
167
+ ),
168
+ v.partial(
169
+ v.object({
170
+ format: v.pipe(
171
+ OutputFormat,
172
+ v.description($`
173
+ Specifies the output format.
174
+ `)
175
+ ),
176
+ renderMode: v.pipe(
177
+ RenderMode,
178
+ v.description($`
179
+ If set to \`docker\`, Vivliostyle will render the PDF using a Docker container. (default: \`local\`)
180
+ `)
181
+ ),
182
+ preflight: v.pipe(
183
+ v.union([v.literal("press-ready"), v.literal("press-ready-local")]),
184
+ v.description($`
185
+ Apply the process to generate a print-ready PDF.
186
+ `)
187
+ ),
188
+ preflightOption: v.pipe(
189
+ v.array(ValidString),
190
+ v.description($`
191
+ Options for the preflight process (e.g., \`gray-scale\`, \`enforce-outline\`).
192
+ Refer to the press-ready documentation for more information: [press-ready](https://github.com/vibranthq/press-ready)
193
+ `)
194
+ )
195
+ })
196
+ )
197
+ ]),
198
+ v.title("OutputConfig")
199
+ );
200
+ var VfmReplaceRule = v.looseObject({
201
+ test: v.instance(RegExp),
202
+ match: v.pipe(
203
+ v.function(),
204
+ // https://github.com/fabian-hiller/valibot/issues/243
205
+ v.metadata({
206
+ typeString: "(result: RegExpMatchArray, h: any) => Object | string"
207
+ })
208
+ )
209
+ });
210
+ var BrowserType = v.union([
211
+ v.literal("chromium"),
212
+ v.literal("firefox"),
213
+ v.literal("webkit")
214
+ ]);
215
+ var ReadingProgression = v.union([v.literal("ltr"), v.literal("rtl")]);
216
+ var LogLevel = v.union([
217
+ v.literal("silent"),
218
+ v.literal("info"),
219
+ v.literal("verbose"),
220
+ v.literal("debug")
221
+ ]);
222
+ var notAllowedPatternRe = /(^\s*[/\\]|^(.*[/\\])?\s*\.\.\s*([/\\].*)?$)/g;
223
+ var validateAssetPatternSettings = (propName) => v.check(
224
+ (input) => input.every((pattern) => !notAllowedPatternRe.test(pattern)),
225
+ `Invalid pattern was found in copyAsset.${propName} option`
226
+ );
227
+ var notAllowedExtensionRe = /([\\/*?@+!|(){}[\]]|\.\.|^\s*\.)/g;
228
+ var validateAssetExtensionSettings = (propName) => v.check(
229
+ (input) => input.every((pattern) => !notAllowedExtensionRe.test(pattern)),
230
+ `Invalid pattern was found in copyAsset.${propName} option`
231
+ );
232
+ var CopyAssetConfig = v.pipe(
233
+ v.partial(
234
+ v.object({
235
+ includes: v.pipe(
236
+ v.array(ValidString),
237
+ validateAssetPatternSettings("includes"),
238
+ v.description($`
239
+ Directories and files to include as asset files. Supports wildcard characters for glob patterns.
240
+ `)
241
+ ),
242
+ excludes: v.pipe(
243
+ v.array(ValidString),
244
+ validateAssetPatternSettings("excludes"),
245
+ v.description($`
246
+ Directories and files to exclude from asset files. Supports wildcard characters for glob patterns.
247
+ `)
248
+ ),
249
+ includeFileExtensions: v.pipe(
250
+ v.array(ValidString),
251
+ validateAssetExtensionSettings("includeFileExtensions"),
252
+ v.description($`
253
+ File extensions to include as asset files. (default: \`[png, jpg, jpeg, svg, gif, webp, apng, ttf, otf, woff, woff2]\`)
254
+ `)
255
+ ),
256
+ excludeFileExtensions: v.pipe(
257
+ v.array(ValidString),
258
+ validateAssetExtensionSettings("excludeFileExtensions"),
259
+ v.description($`
260
+ File extensions to exclude from asset files.
261
+ `)
262
+ )
263
+ })
264
+ ),
265
+ v.title("CopyAssetConfig")
266
+ );
267
+ var TocConfig = v.pipe(
268
+ v.partial(
269
+ v.object({
270
+ title: v.pipe(
271
+ ValidString,
272
+ v.description($`
273
+ Title of the generated ToC document.
274
+ `)
275
+ ),
276
+ htmlPath: v.pipe(
277
+ ValidString,
278
+ v.description($`
279
+ Location where the generated ToC document will be saved. (default: \`index.html\`)
280
+ `)
281
+ ),
282
+ sectionDepth: v.pipe(
283
+ v.number(),
284
+ v.integer(),
285
+ v.minValue(0),
286
+ v.maxValue(6),
287
+ v.description($`
288
+ Depth of sections to include in the ToC document. (default: \`0\`)
289
+ `)
290
+ ),
291
+ transformDocumentList: v.pipe(
292
+ v.function(),
293
+ v.metadata({
294
+ typeString: "(nodeList: StructuredDocument[]) => (propsList: { children: any }[]) => any",
295
+ typeReferences: [StructuredDocument]
296
+ }),
297
+ v.description($`
298
+ Function to transform the document list.
299
+ `)
300
+ ),
301
+ transformSectionList: v.pipe(
302
+ v.function(),
303
+ v.metadata({
304
+ typeString: "(nodeList: StructuredDocumentSection[]) => (propsList: { children: any }[]) => any",
305
+ typeReferences: [StructuredDocumentSection]
306
+ }),
307
+ v.description($`
308
+ Function to transform the section list.
309
+ `)
310
+ )
311
+ })
312
+ ),
313
+ v.title("TocConfig")
314
+ );
315
+ var CoverConfig = v.pipe(
316
+ v.intersect([
317
+ v.required(
318
+ v.object({
319
+ src: v.pipe(
320
+ ValidString,
321
+ v.description($`
322
+ Path to the cover image for the cover page.
323
+ `)
324
+ )
325
+ }),
326
+ "Missing required field: src"
327
+ ),
328
+ v.partial(
329
+ v.object({
330
+ name: v.pipe(
331
+ v.string(),
332
+ // Allow empty string
333
+ v.description($`
334
+ Alternative text for the cover image.
335
+ `)
336
+ ),
337
+ htmlPath: v.pipe(
338
+ v.union([ValidString, v.boolean()]),
339
+ v.description($`
340
+ Path where the generated cover document will be saved. (default: \`cover.html\`)
341
+ If set to a falsy value, the cover document will not be generated.
342
+ `)
343
+ )
344
+ })
345
+ )
346
+ ]),
347
+ v.title("CoverConfig")
348
+ );
349
+ var VfmConfig = v.pipe(
350
+ v.partial(
351
+ // Use v.looseObject to allow unknown keys in future VFM versions
352
+ v.looseObject({
353
+ style: v.pipe(
354
+ v.union([v.array(ValidString), ValidString]),
355
+ v.transform((input) => [input].flat()),
356
+ v.description($`
357
+ Path(s) or URL(s) to custom stylesheets.
358
+ `)
359
+ ),
360
+ partial: v.pipe(
361
+ v.boolean(),
362
+ v.description($`
363
+ Output markdown fragments instead of a full document.
364
+ `)
365
+ ),
366
+ title: v.pipe(
367
+ ValidString,
368
+ v.description($`
369
+ Title of the document (ignored in partial mode).
370
+ `)
371
+ ),
372
+ language: v.pipe(
373
+ ValidString,
374
+ v.description($`
375
+ Language of the document (ignored in partial mode).
376
+ `)
377
+ ),
378
+ replace: v.pipe(
379
+ v.array(VfmReplaceRule),
380
+ v.description($`
381
+ Handlers for replacing matched HTML strings.
382
+ `)
383
+ ),
384
+ hardLineBreaks: v.pipe(
385
+ v.boolean(),
386
+ v.description($`
387
+ Insert \`<br>\` tags at hard line breaks without requiring spaces.
388
+ `)
389
+ ),
390
+ disableFormatHtml: v.pipe(
391
+ v.boolean(),
392
+ v.description($`
393
+ Disable automatic HTML formatting.
394
+ `)
395
+ ),
396
+ math: v.pipe(
397
+ v.boolean(),
398
+ v.description($`
399
+ Enable support for math syntax.
400
+ `)
401
+ )
402
+ })
403
+ ),
404
+ v.title("VfmConfig")
405
+ );
406
+ var ServerConfig = v.pipe(
407
+ v.partial(
408
+ v.object({
409
+ host: v.pipe(
410
+ v.union([v.boolean(), ValidString]),
411
+ v.description($`
412
+ IP address the server should listen on.
413
+ Set to \`true\` to listen on all addresses.
414
+ (default: \`true\` if a PDF build with Docker render mode is required, otherwise \`false\`)
415
+ `)
416
+ ),
417
+ port: v.pipe(
418
+ v.number(),
419
+ v.minValue(0),
420
+ v.maxValue(65535),
421
+ v.description($`
422
+ Port the server should listen on. (default: \`13000\`)
423
+ `)
424
+ ),
425
+ proxy: v.pipe(
426
+ v.record(
427
+ ValidString,
428
+ v.union([
429
+ v.pipe(
430
+ v.custom(
431
+ (value) => Boolean(value && typeof value === "object")
432
+ ),
433
+ v.metadata({
434
+ typeString: 'import("vite").ProxyOptions'
435
+ })
436
+ ),
437
+ ValidString
438
+ ])
439
+ ),
440
+ v.description($`
441
+ Custom proxy rules for the Vivliostyle preview server.
442
+ `)
443
+ )
444
+ })
445
+ ),
446
+ v.title("ServerConfig")
447
+ );
448
+ var BuildTask = v.pipe(
449
+ v.intersect([
450
+ v.required(
451
+ v.object({
452
+ entry: v.pipe(
453
+ v.union([
454
+ v.pipe(
455
+ v.array(v.union([ValidString, EntryConfig])),
456
+ v.minLength(1, "At least one entry is required")
457
+ ),
458
+ ArticleEntryConfig,
459
+ ValidString
460
+ ]),
461
+ v.transform(
462
+ (input) => [input].flat().map(
463
+ (item) => typeof item === "string" ? { path: item } : item
464
+ )
465
+ ),
466
+ v.description($`
467
+ Entry file(s) of the document.
468
+ `)
469
+ )
470
+ }),
471
+ "Missing required field: entry"
472
+ ),
473
+ v.partial(
474
+ v.object({
475
+ title: v.pipe(
476
+ ValidString,
477
+ v.description($`
478
+ Title of the document.
479
+ `)
480
+ ),
481
+ author: v.pipe(
482
+ ValidString,
483
+ v.description($`
484
+ Author of the document.
485
+ `)
486
+ ),
487
+ theme: v.pipe(
488
+ ThemeSpecifier,
489
+ v.description($`
490
+ Theme package path(s) or URL(s) of the CSS file.
491
+ `)
492
+ ),
493
+ entryContext: v.pipe(
494
+ ValidString,
495
+ v.description($`
496
+ Directory containing the referenced entry file(s).
497
+ `)
498
+ ),
499
+ output: v.pipe(
500
+ v.union([
501
+ v.array(v.union([OutputConfig, ValidString])),
502
+ OutputConfig,
503
+ ValidString
504
+ ]),
505
+ v.transform(
506
+ (input) => [input].flat().map((item) => {
507
+ const obj = typeof item === "string" ? { path: item } : item;
508
+ const ext = upath.extname(obj.path).toLowerCase();
509
+ return {
510
+ ...obj,
511
+ format: obj.format || (ext === ".pdf" ? "pdf" : ext === ".epub" ? "epub" : "webpub")
512
+ };
513
+ })
514
+ ),
515
+ v.description($`
516
+ Output options.
517
+ `)
518
+ ),
519
+ workspaceDir: v.pipe(
520
+ ValidString,
521
+ v.description($`
522
+ Directory where intermediate files (e.g., manuscript HTMLs, publication.json) are saved. (default: \`.vivliostyle\`)
523
+ `)
524
+ ),
525
+ /** @deprecated */
526
+ includeAssets: v.pipe(
527
+ v.union([v.array(ValidString), ValidString]),
528
+ v.transform((input) => [input].flat()),
529
+ v.metadata({ deprecated: true }),
530
+ v.description($`
531
+ Use \`copyAsset.includes\` instead.
532
+ `)
533
+ ),
534
+ copyAsset: v.pipe(
535
+ v.union([CopyAssetConfig]),
536
+ v.description($`
537
+ Options for asset files to be copied when exporting output.
538
+ `)
539
+ ),
540
+ size: v.pipe(
541
+ ValidString,
542
+ v.description($`
543
+ PDF output size. (default: \`letter\`)
544
+ - Preset: \`A5\`, \`A4\`, \`A3\`, \`B5\`, \`B4\`, \`JIS-B5\`, \`JIS-B4\`, \`letter\`, \`legal\`, \`ledger\`
545
+ - Custom (comma-separated): \`182mm,257mm\` or \`8.5in,11in\`
546
+ `)
547
+ ),
548
+ pressReady: v.pipe(
549
+ v.boolean(),
550
+ v.description($`
551
+ Generate a press-ready PDF compatible with PDF/X-1a. (default: \`false\`)
552
+ This option is equivalent to setting \`"preflight": "press-ready"\`.
553
+ `)
554
+ ),
555
+ language: v.pipe(
556
+ ValidString,
557
+ v.description($`
558
+ Language of the document.
559
+ `)
560
+ ),
561
+ readingProgression: v.pipe(
562
+ ReadingProgression,
563
+ v.description($`
564
+ Specifies the reading progression of the document.
565
+ This is typically determined automatically by the CSS writing-mode.
566
+ Use this option only if explicit configuration is needed.
567
+ `)
568
+ ),
569
+ toc: v.pipe(
570
+ v.union([TocConfig, v.boolean(), ValidString]),
571
+ v.transform(
572
+ (input) => typeof input === "string" ? { htmlPath: input } : input === true ? {} : input || void 0
573
+ ),
574
+ v.description($`
575
+ Options for Table of Contents (ToC) documents.
576
+ `)
577
+ ),
578
+ /** @deprecated */
579
+ tocTitle: v.pipe(
580
+ ValidString,
581
+ v.metadata({ deprecated: true }),
582
+ v.description($`
583
+ Use \`toc.title\` instead
584
+ `)
585
+ ),
586
+ cover: v.pipe(
587
+ v.union([CoverConfig, ValidString]),
588
+ v.transform(
589
+ (input) => typeof input === "string" ? { src: input } : input
590
+ ),
591
+ v.description($`
592
+ Options for cover images and cover page documents.
593
+ `)
594
+ ),
595
+ timeout: v.pipe(
596
+ v.number(),
597
+ v.description($`
598
+ Timeout limit for waiting for the Vivliostyle process (in ms). (default: \`120000\`)
599
+ `)
600
+ ),
601
+ documentProcessor: v.pipe(
602
+ v.function(),
603
+ v.metadata({
604
+ typeString: '(option: import("@vivliostyle/vfm").StringifyMarkdownOptions, metadata: import("@vivliostyle/vfm").Metadata) => import("unified").Processor'
605
+ }),
606
+ v.description($`
607
+ Custom function to provide a unified Processor for converting markdown to HTML.
608
+ `)
609
+ ),
610
+ vfm: v.pipe(
611
+ v.union([VfmConfig]),
612
+ v.description($`
613
+ Options for converting Markdown into a stringified format (HTML).
614
+ `)
615
+ ),
616
+ image: v.pipe(
617
+ ValidString,
618
+ v.description($`
619
+ Docker image used for rendering.
620
+ `)
621
+ ),
622
+ /** @deprecated */
623
+ http: v.pipe(
624
+ v.boolean(),
625
+ v.metadata({ deprecated: true }),
626
+ v.description($`
627
+ This option is enabled by default, and the file protocol is no longer supported.
628
+ `)
629
+ ),
630
+ viewer: v.pipe(
631
+ ValidString,
632
+ v.description($`
633
+ URL of a custom viewer to display content instead of the default Vivliostyle CLI viewer.
634
+ Useful for using a custom viewer with staging features (e.g., \`https://vivliostyle.vercel.app/\`).
635
+ `)
636
+ ),
637
+ viewerParam: v.pipe(
638
+ ValidString,
639
+ v.description($`
640
+ Parameters for the Vivliostyle viewer (e.g., \`allowScripts=false&pixelRatio=16\`).
641
+ `)
642
+ ),
643
+ browser: v.pipe(
644
+ BrowserType,
645
+ v.description($`
646
+ EXPERIMENTAL SUPPORT: Specifies the browser type for launching the Vivliostyle viewer.
647
+ Currently, Firefox and Webkit support only the preview command.
648
+ `)
649
+ ),
650
+ base: v.pipe(
651
+ ValidString,
652
+ v.regex(/^\//, "Base path must start with a slash"),
653
+ v.check((value) => value !== "/", "Base path must not be root"),
654
+ v.transform((value) => value.replace(/(?!^)\/+$/, "")),
655
+ v.description($`
656
+ Base path of the served documents. (default: \`/vivliostyle\`)
657
+ `)
658
+ ),
659
+ server: v.pipe(
660
+ v.union([ServerConfig]),
661
+ v.description($`
662
+ Options for the preview server.
663
+ `)
664
+ ),
665
+ static: v.pipe(
666
+ v.record(
667
+ v.pipe(
668
+ ValidString,
669
+ v.regex(/^\//, "Base path must start with a slash"),
670
+ v.transform((value) => value.replace(/(?!^)\/+$/, ""))
671
+ ),
672
+ v.pipe(
673
+ v.union([v.array(ValidString), ValidString]),
674
+ v.transform((input) => [input].flat())
675
+ )
676
+ ),
677
+ v.description($`
678
+ Specifies static files to be served by the preview server.
679
+ \`\`\`js
680
+ export default {
681
+ static: {
682
+ '/static': 'path/to/static',
683
+ '/': ['root1', 'root2'],
684
+ },
685
+ };
686
+ \`\`\`
687
+ `),
688
+ v.transform((input) => {
689
+ return input;
690
+ })
691
+ ),
692
+ temporaryFilePrefix: v.pipe(
693
+ ValidString,
694
+ v.description($`
695
+ Prefix for temporary file names.
696
+ `)
697
+ ),
698
+ vite: v.pipe(
699
+ v.custom(() => true),
700
+ v.metadata({
701
+ typeString: 'import("vite").UserConfig'
702
+ }),
703
+ v.description($`
704
+ Configuration options for the Vite server.
705
+ `)
706
+ ),
707
+ viteConfigFile: v.pipe(
708
+ v.union([ValidString, v.boolean()]),
709
+ v.description($`
710
+ Path to the Vite config file.
711
+ If a falsy value is provided, Vivliostyle CLI ignores the existing Vite config file.
712
+ `)
713
+ )
714
+ })
715
+ )
716
+ ]),
717
+ v.title("BuildTask")
718
+ );
719
+ var VivliostyleConfigSchema = v.pipe(
720
+ v.union([
721
+ v.pipe(
722
+ v.array(BuildTask),
723
+ v.minLength(1, "At least one config entry is required")
724
+ ),
725
+ BuildTask
726
+ ]),
727
+ v.transform(
728
+ (input) => ({
729
+ tasks: [input].flat(),
730
+ inlineOptions: {}
731
+ })
732
+ ),
733
+ v.title("VivliostyleConfigSchema")
734
+ );
735
+ var VivliostyleInlineConfig = v.pipe(
736
+ v.partial(
737
+ v.object({
738
+ cwd: v.pipe(
739
+ ValidString,
740
+ v.description($`
741
+ Set a working directory.
742
+ `)
743
+ ),
744
+ config: v.pipe(
745
+ ValidString,
746
+ v.description($`
747
+ Path to vivliostyle.config.js.
748
+ `)
749
+ ),
750
+ configData: v.pipe(
751
+ v.custom(() => true),
752
+ v.metadata({
753
+ typeString: "VivliostyleConfigSchema"
754
+ }),
755
+ v.description($`
756
+ Vivliostyle config object.
757
+ `)
758
+ ),
759
+ input: v.pipe(
760
+ ValidString,
761
+ v.transform((input) => {
762
+ const ext = upath.extname(input).toLowerCase();
763
+ if (/^https?:/.test(input)) {
764
+ return { format: "webbook", entry: input };
765
+ } else if (ext === ".md" || ext === ".markdown") {
766
+ return { format: "markdown", entry: input };
767
+ } else if (ext === ".json" || ext === ".jsonld") {
768
+ return { format: "pub-manifest", entry: input };
769
+ } else if (ext === ".epub") {
770
+ return { format: "epub", entry: input };
771
+ } else if (ext === ".opf") {
772
+ return { format: "epub-opf", entry: input };
773
+ } else if ([".html", ".htm", ".xhtml", ".xht"].includes(ext)) {
774
+ return { format: "webbook", entry: input };
775
+ }
776
+ throw new Error(`Cannot detect an input format: ${input}`);
777
+ }),
778
+ v.description($`
779
+ Input file of document.
780
+ `)
781
+ ),
782
+ output: v.pipe(
783
+ v.union([
784
+ v.array(v.union([OutputConfig, ValidString])),
785
+ OutputConfig,
786
+ ValidString
787
+ ]),
788
+ v.transform(
789
+ (input) => [input].flat().map((item) => {
790
+ const obj = typeof item === "string" ? { path: item } : item;
791
+ const ext = upath.extname(obj.path).toLowerCase();
792
+ return {
793
+ ...obj,
794
+ format: obj.format || (ext === ".pdf" ? "pdf" : ext === ".epub" ? "epub" : "webpub")
795
+ };
796
+ })
797
+ ),
798
+ v.description($`
799
+ Output file name or directory.
800
+ `)
801
+ ),
802
+ theme: v.pipe(
803
+ ThemeSpecifier,
804
+ v.description($`
805
+ Theme path or package name.
806
+ `)
807
+ ),
808
+ size: v.pipe(
809
+ ValidString,
810
+ v.description($`
811
+ Output pdf size.
812
+ preset: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal, ledger
813
+ custom(comma separated): 182mm,257mm or 8.5in,11in
814
+ `)
815
+ ),
816
+ cropMarks: v.pipe(
817
+ v.boolean(),
818
+ v.description($`
819
+ Print crop marks.
820
+ `)
821
+ ),
822
+ bleed: v.pipe(
823
+ ValidString,
824
+ v.description($`
825
+ Extent of the bleed area for printing with crop marks. [3mm]
826
+ `)
827
+ ),
828
+ cropOffset: v.pipe(
829
+ ValidString,
830
+ v.description($`
831
+ Distance between the edge of the trim size and the edge of the media size. [auto (13mm + bleed)]
832
+ `)
833
+ ),
834
+ css: v.pipe(
835
+ ValidString,
836
+ v.description($`
837
+ Custom style CSS code. (ex: ":root {--my-color: lime;}")
838
+ `)
839
+ ),
840
+ style: v.pipe(
841
+ ValidString,
842
+ v.description($`
843
+ Additional stylesheet URL or path.
844
+ `)
845
+ ),
846
+ userStyle: v.pipe(
847
+ ValidString,
848
+ v.description($`
849
+ User stylesheet URL or path.
850
+ `)
851
+ ),
852
+ singleDoc: v.pipe(
853
+ v.boolean(),
854
+ v.description($`
855
+ Single HTML document input.
856
+ `)
857
+ ),
858
+ quick: v.pipe(
859
+ v.boolean(),
860
+ v.description($`
861
+ Quick loading with rough page count.
862
+ `)
863
+ ),
864
+ pressReady: v.pipe(
865
+ v.boolean(),
866
+ v.description($`
867
+ Make generated PDF compatible with press ready PDF/X-1a.
868
+ This option is equivalent with "preflight": "press-ready"
869
+ `)
870
+ ),
871
+ title: v.pipe(ValidString, v.description($`Title`)),
872
+ author: v.pipe(ValidString, v.description($`Author`)),
873
+ language: v.pipe(ValidString, v.description($`Language`)),
874
+ readingProgression: v.pipe(
875
+ ReadingProgression,
876
+ v.description($`
877
+ Direction of reading progression.
878
+ `)
879
+ ),
880
+ timeout: v.pipe(
881
+ v.number(),
882
+ v.description($`
883
+ Timeout limit for waiting Vivliostyle process (ms).
884
+ `)
885
+ ),
886
+ renderMode: v.pipe(
887
+ RenderMode,
888
+ v.description($`
889
+ If docker is set, Vivliostyle try to render PDF on Docker container. [local]
890
+ `)
891
+ ),
892
+ preflight: v.pipe(
893
+ v.union([v.literal("press-ready"), v.literal("press-ready-local")]),
894
+ v.description($`
895
+ Apply the process to generate PDF for printing.
896
+ `)
897
+ ),
898
+ preflightOption: v.pipe(
899
+ v.union([v.array(ValidString), ValidString]),
900
+ v.transform((input) => [input].flat()),
901
+ v.description($`
902
+ Options for preflight process (ex: gray-scale, enforce-outline).
903
+ Please refer the document of press-ready for further information.
904
+ `)
905
+ ),
906
+ sandbox: v.pipe(
907
+ v.boolean(),
908
+ v.description($`Launch chrome with sandbox.`)
909
+ ),
910
+ executableBrowser: v.pipe(
911
+ ValidString,
912
+ v.description($`
913
+ Specify a path of executable browser you installed.
914
+ `)
915
+ ),
916
+ image: v.pipe(
917
+ ValidString,
918
+ v.description($`
919
+ Specify a docker image to render.
920
+ `)
921
+ ),
922
+ viewer: v.pipe(
923
+ ValidString,
924
+ v.description($`
925
+ Specify a URL of displaying viewer instead of vivliostyle-cli's one.
926
+ It is useful that using own viewer that has staging features. (ex: https://vivliostyle.vercel.app/)
927
+ `)
928
+ ),
929
+ viewerParam: v.pipe(
930
+ ValidString,
931
+ v.description($`
932
+ Specify viewer parameters. (ex: "allowScripts=false&pixelRatio=16")
933
+ `)
934
+ ),
935
+ browser: v.pipe(
936
+ BrowserType,
937
+ v.description($`
938
+ Specify a browser type to launch Vivliostyle viewer [chromium].
939
+ `)
940
+ ),
941
+ proxyServer: v.pipe(
942
+ ValidString,
943
+ v.description($`
944
+ HTTP/SOCK proxy server url for underlying Playwright.
945
+ `)
946
+ ),
947
+ proxyBypass: v.pipe(
948
+ ValidString,
949
+ v.description($`
950
+ Optional comma-separated domains to bypass proxy.
951
+ `)
952
+ ),
953
+ proxyUser: v.pipe(
954
+ ValidString,
955
+ v.description($`
956
+ Optional username for HTTP proxy authentication.
957
+ `)
958
+ ),
959
+ proxyPass: v.pipe(
960
+ ValidString,
961
+ v.description($`
962
+ Optional password for HTTP proxy authentication.
963
+ `)
964
+ ),
965
+ logLevel: v.pipe(
966
+ LogLevel,
967
+ v.description($`
968
+ Specify a log level of console outputs.
969
+ `)
970
+ ),
971
+ ignoreHttpsErrors: v.pipe(
972
+ v.boolean(),
973
+ v.description($`
974
+ true to ignore HTTPS errors when Playwright browser opens a new page.
975
+ `)
976
+ ),
977
+ openViewer: v.pipe(
978
+ v.boolean(),
979
+ v.description($`
980
+ Open a browser to display the document preview.
981
+ `)
982
+ ),
983
+ enableStaticServe: v.pipe(
984
+ v.boolean(),
985
+ v.description($`
986
+ Enable static file serving as configured in the Vivliostyle config file.
987
+ `)
988
+ ),
989
+ enableViewerStartPage: v.pipe(
990
+ v.boolean(),
991
+ v.description($`
992
+ Open a start page of the viewer when the input file is not specified.
993
+ `)
994
+ ),
995
+ vite: v.pipe(
996
+ v.custom(() => true),
997
+ v.metadata({
998
+ typeString: 'import("vite").UserConfig'
999
+ }),
1000
+ v.description($`
1001
+ Configuration options for the Vite server.
1002
+ `)
1003
+ ),
1004
+ viteConfigFile: v.pipe(
1005
+ v.union([ValidString, v.boolean()]),
1006
+ v.description($`
1007
+ Path to the Vite config file.
1008
+ If a falsy value is provided, Vivliostyle CLI ignores the existing Vite config file.
1009
+ `)
1010
+ ),
1011
+ host: v.pipe(
1012
+ v.union([v.boolean(), ValidString]),
1013
+ v.description($`
1014
+ IP address the server should listen on.
1015
+ Set to \`true\` to listen on all addresses.
1016
+ (default: \`true\` if a PDF build with Docker render mode is required, otherwise \`false\`)
1017
+ `)
1018
+ ),
1019
+ port: v.pipe(
1020
+ v.number(),
1021
+ v.minValue(0),
1022
+ v.maxValue(65535),
1023
+ v.description($`
1024
+ Port the server should listen on. (default: \`13000\`)
1025
+ `)
1026
+ ),
1027
+ logger: v.pipe(
1028
+ v.custom(() => true),
1029
+ v.metadata({
1030
+ typeString: "LoggerInterface"
1031
+ }),
1032
+ v.description($`
1033
+ Custom logger interface.
1034
+ `)
1035
+ )
1036
+ })
1037
+ ),
1038
+ v.check(
1039
+ (options) => !options.input || !options.output || !["epub", "epub-opf"].includes(options.input.format) || options.output.every((o) => o.format !== "webpub"),
1040
+ "Exporting webpub format from EPUB or OPF file is not supported."
1041
+ ),
1042
+ v.check(
1043
+ (options) => !options.input || !options.output || !["epub", "epub-opf"].includes(options.input.format) || options.output.every((o) => o.format !== "epub"),
1044
+ "Exporting EPUB format from EPUB or OPF file is not supported."
1045
+ ),
1046
+ v.title("VivliostyleInlineConfig")
1047
+ );
1048
+
1049
+ export {
1050
+ StructuredDocument,
1051
+ StructuredDocumentSection,
1052
+ ValidString,
1053
+ ThemeConfig,
1054
+ ThemeSpecifier,
1055
+ ArticleEntryConfig,
1056
+ ContentsEntryConfig,
1057
+ CoverEntryConfig,
1058
+ EntryConfig,
1059
+ OutputFormat,
1060
+ RenderMode,
1061
+ OutputConfig,
1062
+ VfmReplaceRule,
1063
+ BrowserType,
1064
+ ReadingProgression,
1065
+ LogLevel,
1066
+ CopyAssetConfig,
1067
+ TocConfig,
1068
+ CoverConfig,
1069
+ ServerConfig,
1070
+ BuildTask,
1071
+ VivliostyleConfigSchema,
1072
+ VivliostyleInlineConfig
1073
+ };