@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
@@ -1,41 +0,0 @@
1
- import { createRequire } from 'node:module';
2
- // TODO: Change to static import after JSON module becomes stable
3
- const require = createRequire(import.meta.url);
4
- const bcpSchema = require('../../schemas/pub-manifest/module/bcp.schema.json');
5
- const contextSchema = require('../../schemas/pub-manifest/module/context.schema.json');
6
- const contributorObjectSchema = require('../../schemas/pub-manifest/module/contributor-object.schema.json');
7
- const contributorSchema = require('../../schemas/pub-manifest/module/contributor.schema.json');
8
- const dateSchema = require('../../schemas/pub-manifest/module/date.schema.json');
9
- const durationSchema = require('../../schemas/pub-manifest/module/duration.schema.json');
10
- const itemListsSchema = require('../../schemas/pub-manifest/module/item-lists.schema.json');
11
- const itemListSchema = require('../../schemas/pub-manifest/module/ItemList.schema.json');
12
- const languageSchema = require('../../schemas/pub-manifest/module/language.schema.json');
13
- const linkSchema = require('../../schemas/pub-manifest/module/link.schema.json');
14
- const localizableObjectSchema = require('../../schemas/pub-manifest/module/localizable-object.schema.json');
15
- const localizableSchema = require('../../schemas/pub-manifest/module/localizable.schema.json');
16
- const resourceCategorizationSchema = require('../../schemas/pub-manifest/module/resource.categorization.schema.json');
17
- const stringsSchema = require('../../schemas/pub-manifest/module/strings.schema.json');
18
- const urlSchema = require('../../schemas/pub-manifest/module/url.schema.json');
19
- const urlsSchema = require('../../schemas/pub-manifest/module/urls.schema.json');
20
- const publicationSchema = require('../../schemas/pub-manifest/publication.schema.json');
21
- export const publicationSchemas = [
22
- bcpSchema,
23
- contextSchema,
24
- contributorObjectSchema,
25
- contributorSchema,
26
- dateSchema,
27
- durationSchema,
28
- itemListsSchema,
29
- itemListSchema,
30
- languageSchema,
31
- linkSchema,
32
- localizableObjectSchema,
33
- localizableSchema,
34
- resourceCategorizationSchema,
35
- stringsSchema,
36
- urlSchema,
37
- urlsSchema,
38
- publicationSchema,
39
- ];
40
- export { publicationSchema };
41
- //# sourceMappingURL=pub-manifest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pub-manifest.js","sourceRoot":"","sources":["../../src/schema/pub-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,iEAAiE;AACjE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,SAAS,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC/E,MAAM,aAAa,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACvF,MAAM,uBAAuB,GAAG,OAAO,CAAC,kEAAkE,CAAC,CAAC;AAC5G,MAAM,iBAAiB,GAAG,OAAO,CAAC,2DAA2D,CAAC,CAAC;AAC/F,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,eAAe,GAAG,OAAO,CAAC,0DAA0D,CAAC,CAAC;AAC5F,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,uBAAuB,GAAG,OAAO,CAAC,kEAAkE,CAAC,CAAC;AAC5G,MAAM,iBAAiB,GAAG,OAAO,CAAC,2DAA2D,CAAC,CAAC;AAC/F,MAAM,4BAA4B,GAAG,OAAO,CAAC,uEAAuE,CAAC,CAAC;AACtH,MAAM,aAAa,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACvF,MAAM,SAAS,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC/E,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,iBAAiB,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS;IACT,aAAa;IACb,uBAAuB;IACvB,iBAAiB;IACjB,UAAU;IACV,cAAc;IACd,eAAe;IACf,cAAc;IACd,cAAc;IACd,UAAU;IACV,uBAAuB;IACvB,iBAAiB;IACjB,4BAA4B;IAC5B,aAAa;IACb,SAAS;IACT,UAAU;IACV,iBAAiB;CACT,CAAC;AAEX,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,104 +0,0 @@
1
- /**
2
- * This file was automatically generated by json-schema-to-typescript.
3
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
- * and run json-schema-to-typescript to regenerate this file.
5
- */
6
- export type PublicationContexts = [] | ['https://schema.org'] | [
7
- 'https://schema.org',
8
- 'https://www.w3.org/ns/pub-context',
9
- ...(string | {
10
- language: BCP47LanguageTag;
11
- direction?: never;
12
- [k: string]: unknown;
13
- } | {
14
- direction: 'ltr' | 'rtl';
15
- language?: never;
16
- [k: string]: unknown;
17
- } | {
18
- language: BCP47LanguageTag;
19
- direction: 'ltr' | 'rtl';
20
- [k: string]: unknown;
21
- } | {
22
- language?: never;
23
- direction?: never;
24
- [k: string]: unknown;
25
- })[]
26
- ];
27
- export type BCP47LanguageTag = string;
28
- export type URL = string;
29
- export type UniqueStrings = string | string[];
30
- export type ListsOfItemList = SchemaOrgItemListObject | SchemaOrgItemListObject[];
31
- export type LocalizableStringOrObject = string | (string | LocalizableStringObject)[] | LocalizableStringObject;
32
- export type Contributor = string | (string | ContributorObject)[] | ContributorObject;
33
- export type URLs = string | string[];
34
- export type Duration = string;
35
- export type Languages = BCP47LanguageTag | BCP47LanguageTag[];
36
- export type Dates = string;
37
- export type ResourceCategorization = (URL | PublicationLinks) | (URL | PublicationLinks)[];
38
- export interface PublicationManifest {
39
- '@context': PublicationContexts;
40
- type?: string | string[];
41
- conformsTo: URL | URL[];
42
- id?: string;
43
- abridged?: boolean;
44
- accessMode?: UniqueStrings;
45
- accessModeSufficient?: ListsOfItemList;
46
- accessibilityFeature?: UniqueStrings;
47
- accessibilityHazard?: UniqueStrings;
48
- accessibilitySummary?: LocalizableStringOrObject;
49
- artist?: Contributor;
50
- author?: Contributor;
51
- colorist?: Contributor;
52
- contributor?: Contributor;
53
- creator?: Contributor;
54
- editor?: Contributor;
55
- illustrator?: Contributor;
56
- inker?: Contributor;
57
- letterer?: Contributor;
58
- penciler?: Contributor;
59
- publisher?: Contributor;
60
- readBy?: Contributor;
61
- translator?: Contributor;
62
- url?: URLs;
63
- duration?: Duration;
64
- inLanguage?: Languages;
65
- dateModified?: Dates;
66
- datePublished?: Dates;
67
- name?: LocalizableStringOrObject;
68
- readingOrder?: ResourceCategorization;
69
- resources?: ResourceCategorization;
70
- links?: ResourceCategorization;
71
- readingProgression?: 'ltr' | 'rtl';
72
- [k: string]: unknown;
73
- }
74
- export interface SchemaOrgItemListObject {
75
- type: 'ItemList' | string[];
76
- itemListElement: string[];
77
- [k: string]: unknown;
78
- }
79
- export interface LocalizableStringObject {
80
- value: string;
81
- language?: BCP47LanguageTag;
82
- [k: string]: unknown;
83
- }
84
- export interface ContributorObject {
85
- name: LocalizableStringOrObject;
86
- id?: URL;
87
- type?: ('Person' | 'Organization') | string[];
88
- url?: URL;
89
- identifier?: string[];
90
- [k: string]: unknown;
91
- }
92
- export interface PublicationLinks {
93
- type?: 'LinkedResource' | string[];
94
- url: URL;
95
- encodingFormat?: string;
96
- name?: LocalizableStringOrObject;
97
- description?: string | LocalizableStringObject;
98
- rel?: string | string[];
99
- integrity?: string;
100
- duration?: Duration;
101
- alternate?: ResourceCategorization;
102
- [k: string]: unknown;
103
- }
104
- //# sourceMappingURL=publication.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publication.schema.d.ts","sourceRoot":"","sources":["../../src/schema/publication.schema.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,EAAE,GACF,CAAC,oBAAoB,CAAC,GACtB;IACE,oBAAoB;IACpB,mCAAmC;IACnC,GAAG,CACC,MAAM,GACN;QACE,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,CAAC,EAAE,KAAK,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;QACzB,QAAQ,CAAC,EAAE,KAAK,CAAC;QACjB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,QAAQ,CAAC,EAAE,KAAK,CAAC;QACjB,SAAS,CAAC,EAAE,KAAK,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MAAM,GAAG,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,yBAAyB,CAAC;IAChC,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,IAAI,CAAC,EAAE,CAAC,QAAQ,GAAG,cAAc,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9C,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAAC;IACnC,GAAG,EAAE,GAAG,CAAC;IACT,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,yBAAyB,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -1,8 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
- export {};
8
- //# sourceMappingURL=publication.schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publication.schema.js","sourceRoot":"","sources":["../../src/schema/publication.schema.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;GAIG"}
package/dist/server.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { PreviewServer, ResolvedConfig as ResolvedViteConfig, ViteDevServer } from 'vite';
2
- import { ResolvedTaskConfig } from './config/resolve.js';
3
- import { ParsedVivliostyleInlineConfig } from './config/schema.js';
4
- export type ViewerUrlOption = Pick<ResolvedTaskConfig, 'size' | 'cropMarks' | 'bleed' | 'cropOffset' | 'css' | 'customStyle' | 'customUserStyle' | 'singleDoc' | 'quick' | 'viewerParam'>;
5
- export declare function getViewerParams(src: string | undefined, { size, cropMarks, bleed, cropOffset, css, customStyle, customUserStyle, singleDoc, quick, viewerParam, }: ViewerUrlOption): string;
6
- export declare function getSourceUrl({ viewerInput, base, workspaceDir, rootUrl, }: Pick<ResolvedTaskConfig, 'viewerInput' | 'base' | 'workspaceDir' | 'rootUrl'>): Promise<string>;
7
- export declare function getViewerFullUrl({ viewerInput, base, workspaceDir, rootUrl, viewer, ...config }: ViewerUrlOption & Pick<ResolvedTaskConfig, 'viewerInput' | 'base' | 'workspaceDir' | 'rootUrl' | 'viewer'>): Promise<string>;
8
- export declare function createViteServer(args: {
9
- config: ResolvedTaskConfig;
10
- viteConfig: ResolvedViteConfig;
11
- inlineConfig: ParsedVivliostyleInlineConfig;
12
- mode: 'preview';
13
- }): Promise<ViteDevServer>;
14
- export declare function createViteServer(args: {
15
- config: ResolvedTaskConfig;
16
- viteConfig: ResolvedViteConfig;
17
- inlineConfig: ParsedVivliostyleInlineConfig;
18
- mode: 'build';
19
- }): Promise<PreviewServer>;
20
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,aAAa,EACb,cAAc,IAAI,kBAAkB,EACpC,aAAa,EACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AASnE,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,kBAAkB,EAChB,MAAM,GACN,WAAW,GACX,OAAO,GACP,YAAY,GACZ,KAAK,GACL,aAAa,GACb,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,aAAa,CAChB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,EACE,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,GAAG,EACH,WAAW,EACX,eAAe,EACf,SAAS,EACT,KAAK,EACL,WAAW,GACZ,EAAE,eAAe,GACjB,MAAM,CAkDR;AAED,wBAAsB,YAAY,CAAC,EACjC,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,OAAO,GACR,EAAE,IAAI,CACL,kBAAkB,EAClB,aAAa,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CACpD,mBA8BA;AAED,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,GAAG,MAAM,EACV,EAAE,eAAe,GAChB,IAAI,CACF,kBAAkB,EAClB,aAAa,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,CAC/D,mBAkBF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,6BAA6B,CAAC;IAC5C,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3B,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,6BAA6B,CAAC;IAC5C,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC"}
package/dist/server.js DELETED
@@ -1,117 +0,0 @@
1
- import fs from 'node:fs';
2
- import { URL } from 'node:url';
3
- import upath from 'upath';
4
- import { createServer, preview, } from 'vite';
5
- import { EMPTY_DATA_URI, VIEWER_ROOT_PATH } from './const.js';
6
- import { Logger } from './logger.js';
7
- import { getDefaultEpubOpfPath, isValidUri, openEpub } from './util.js';
8
- import { vsBrowserPlugin } from './vite/vite-plugin-browser.js';
9
- import { vsDevServerPlugin } from './vite/vite-plugin-dev-server.js';
10
- import { vsStaticServePlugin } from './vite/vite-plugin-static-serve.js';
11
- import { vsViewerPlugin } from './vite/vite-plugin-viewer.js';
12
- export function getViewerParams(src, { size, cropMarks, bleed, cropOffset, css, customStyle, customUserStyle, singleDoc, quick, viewerParam, }) {
13
- const pageSizeValue = size && ('format' in size ? size.format : `${size.width} ${size.height}`);
14
- function escapeParam(url) {
15
- return url.replace(/&/g, '%26');
16
- }
17
- let viewerParams = src ? `src=${escapeParam(src)}` : '';
18
- viewerParams += `&bookMode=${!singleDoc}&renderAllPages=${!quick}`;
19
- if (customStyle) {
20
- viewerParams += `&style=${escapeParam(customStyle)}`;
21
- }
22
- if (customUserStyle) {
23
- viewerParams += `&userStyle=${escapeParam(customUserStyle)}`;
24
- }
25
- if (pageSizeValue || cropMarks || bleed || cropOffset || css) {
26
- let pageStyle = '@page{';
27
- if (pageSizeValue) {
28
- pageStyle += `size:${pageSizeValue};`;
29
- }
30
- if (cropMarks) {
31
- pageStyle += `marks:crop cross;`;
32
- }
33
- if (bleed || cropMarks) {
34
- pageStyle += `bleed:${bleed ?? '3mm'};`;
35
- }
36
- if (cropOffset) {
37
- pageStyle += `crop-offset:${cropOffset};`;
38
- }
39
- pageStyle += '}';
40
- // The pageStyle settings are put between the `/*<viewer>*/` and `/*</viewer>*/`
41
- // in the `&style=data:,…` viewer parameter so that they are reflected in the
42
- // Settings menu of the Viewer. Also the custom CSS code is appended after the
43
- // `/*</viewer>*/` so that it is shown in the Edit CSS box in the Settings menu.
44
- viewerParams += `&style=data:,/*<viewer>*/${encodeURIComponent(pageStyle)}/*</viewer>*/${encodeURIComponent(css ?? '')}`;
45
- }
46
- if (viewerParam) {
47
- // append additional viewer parameters
48
- viewerParams += `&${viewerParam}`;
49
- }
50
- return viewerParams;
51
- }
52
- export async function getSourceUrl({ viewerInput, base, workspaceDir, rootUrl, }) {
53
- let input;
54
- switch (viewerInput.type) {
55
- case 'webpub':
56
- input = viewerInput.manifestPath;
57
- break;
58
- case 'webbook':
59
- input = viewerInput.webbookEntryUrl;
60
- break;
61
- case 'epub-opf':
62
- input = viewerInput.epubOpfPath;
63
- break;
64
- case 'epub': {
65
- if (!fs.existsSync(viewerInput.epubTmpOutputDir)) {
66
- await openEpub(viewerInput.epubPath, viewerInput.epubTmpOutputDir);
67
- }
68
- input = getDefaultEpubOpfPath(viewerInput.epubTmpOutputDir);
69
- break;
70
- }
71
- default:
72
- input = viewerInput;
73
- }
74
- return (isValidUri(input)
75
- ? new URL(input)
76
- : new URL(upath.posix.join(base, upath.relative(workspaceDir, input)), rootUrl)).href;
77
- }
78
- export async function getViewerFullUrl({ viewerInput, base, workspaceDir, rootUrl, viewer, ...config }) {
79
- const viewerUrl = viewer
80
- ? new URL(viewer)
81
- : new URL(`${VIEWER_ROOT_PATH}/index.html`, rootUrl);
82
- const sourceUrl = await getSourceUrl({
83
- viewerInput,
84
- base,
85
- workspaceDir,
86
- rootUrl,
87
- });
88
- const viewerParams = getViewerParams(sourceUrl === EMPTY_DATA_URI
89
- ? undefined // open Viewer start page
90
- : sourceUrl, config);
91
- viewerUrl.hash = '';
92
- return `${viewerUrl.href}#${viewerParams}`;
93
- }
94
- export async function createViteServer({ config, viteConfig, inlineConfig, mode, }) {
95
- const viteInlineConfig = {
96
- clearScreen: false,
97
- configFile: false,
98
- appType: 'custom',
99
- plugins: [
100
- vsDevServerPlugin({ config, inlineConfig }),
101
- vsViewerPlugin({ config, inlineConfig }),
102
- vsBrowserPlugin({ config, inlineConfig }),
103
- vsStaticServePlugin({ config, inlineConfig }),
104
- ],
105
- server: viteConfig.server,
106
- preview: viteConfig.preview,
107
- customLogger: viteConfig.customLogger,
108
- };
109
- Logger.debug('createViteServer > viteInlineConfig %O', viteInlineConfig);
110
- if (mode === 'preview') {
111
- return await createServer(viteInlineConfig);
112
- }
113
- else {
114
- return await preview(viteInlineConfig);
115
- }
116
- }
117
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EAEZ,OAAO,GAIR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAgB9D,MAAM,UAAU,eAAe,CAC7B,GAAuB,EACvB,EACE,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,GAAG,EACH,WAAW,EACX,eAAe,EACf,SAAS,EACT,KAAK,EACL,WAAW,GACK;IAElB,MAAM,aAAa,GACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5E,SAAS,WAAW,CAAC,GAAW;QAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAA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fs';
2
- import { BaseIssue } from 'valibot';
3
- import type { PublicationManifest } from './schema/publication.schema.js';
4
- export declare const cwd: string;
5
- export declare let beforeExitHandlers: (() => void)[];
6
- export declare function runExitHandlers(): void;
7
- export declare class DetailError extends Error {
8
- detail: string | undefined;
9
- constructor(message: string | undefined, detail: string | undefined);
10
- }
11
- export declare function getFormattedError(err: Error): string;
12
- export declare function gracefulError(err: Error): void;
13
- export declare function readJSON(path: string): any;
14
- export declare function statFileSync(filePath: string, { errorMessage, }?: {
15
- errorMessage?: string;
16
- }): fs.Stats;
17
- export declare function inflateZip(filePath: string, dest: string): Promise<void>;
18
- export declare function useTmpDirectory(): Promise<[string, () => void]>;
19
- export declare function touchTmpFile(path: string): () => void;
20
- export declare function pathEquals(path1: string, path2: string): boolean;
21
- export declare function pathContains(parentPath: string, childPath: string): boolean;
22
- export declare function isValidUri(str: string): boolean;
23
- export declare function isInContainer(): boolean;
24
- export declare function openEpub(epubPath: string, tmpDir: string): Promise<() => void>;
25
- export declare function getDefaultEpubOpfPath(epubDir: string): string;
26
- export declare function getEpubRootDir(epubOpfPath: string): string | undefined;
27
- export declare const assertPubManifestSchema: (obj: unknown) => obj is PublicationManifest;
28
- export declare function parseJsonc(rawJsonc: string): string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | {
29
- [property: string]: string | number | boolean | any | any | null;
30
- } | null)[] | {
31
- [property: string]: string | number | boolean | any | any | null;
32
- } | null)[] | {
33
- [property: string]: string | number | boolean | any | any | null;
34
- } | null)[] | {
35
- [property: string]: string | number | boolean | any | any | null;
36
- } | null)[] | {
37
- [property: string]: string | number | boolean | any | any | null;
38
- } | null)[] | {
39
- [property: string]: string | number | boolean | any | any | null;
40
- } | null)[] | {
41
- [property: string]: string | number | boolean | any | any | null;
42
- } | null)[] | {
43
- [property: string]: string | number | boolean | any | any | null;
44
- } | null)[] | {
45
- [property: string]: string | number | boolean | any | any | null;
46
- } | null)[] | {
47
- [property: string]: string | number | boolean | any | any | null;
48
- } | null)[] | {
49
- [property: string]: string | number | boolean | any | any | null;
50
- } | null)[] | {
51
- [property: string]: string | number | boolean | any | any | null;
52
- } | null;
53
- export declare function prettifySchemaError(rawJsonc: string, issues: BaseIssue<unknown>[]): string;
54
- export declare function writeFileIfChanged(filePath: string, content: Buffer): void;
55
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,SAAS,CAAC;AAKzB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,eAAO,MAAM,GAAG,QAAiC,CAAC;AAElD,eAAO,IAAI,kBAAkB,EAAE,CAAC,MAAM,IAAI,CAAC,EAAO,CAAC;AACnD,wBAAgB,eAAe,SAQ9B;AA2BD,qBAAa,WAAY,SAAQ,KAAK;IAG3B,MAAM,EAAE,MAAM,GAAG,SAAS;gBADjC,OAAO,EAAE,MAAM,GAAG,SAAS,EACpB,MAAM,EAAE,MAAM,GAAG,SAAS;CAIpC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,KAAK,UAI3C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,QAMvC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,OAMpC;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,EACE,YAA+C,GAChD,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,YAUlC;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAoB9D;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,CAoB/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,IAAI,CAWrD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAS9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,UAWpD;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,sBAgBjD;AAsBD,eAAO,MAAM,uBAAuB,QAd5B,OAAO,KAAG,GAAG,uBAkBlB,CAAC;AAEJ,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;SAO1C;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,UAoD7B;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAKnE"}
package/dist/util.js DELETED
@@ -1,269 +0,0 @@
1
- import { codeFrameColumns } from '@babel/code-frame';
2
- import { evaluate, parse, } from '@humanwhocodes/momoa';
3
- import AjvModule from 'ajv';
4
- import AjvFormatsModule from 'ajv-formats';
5
- import { XMLParser } from 'fast-xml-parser';
6
- import { removeSync } from 'fs-extra/esm';
7
- import StreamZip from 'node-stream-zip';
8
- import fs from 'node:fs';
9
- import readline from 'node:readline';
10
- import util from 'node:util';
11
- import tmp from 'tmp';
12
- import upath from 'upath';
13
- import { gray, red, redBright } from 'yoctocolors';
14
- import { Logger } from './logger.js';
15
- import { publicationSchema, publicationSchemas, } from './schema/pub-manifest.js';
16
- export const cwd = upath.normalize(process.cwd());
17
- export let beforeExitHandlers = [];
18
- export function runExitHandlers() {
19
- while (beforeExitHandlers.length) {
20
- try {
21
- beforeExitHandlers.shift()?.();
22
- }
23
- catch (e) {
24
- // NOOP
25
- }
26
- }
27
- }
28
- const exitSignals = ['exit', 'SIGINT', 'SIGTERM', 'SIGHUP'];
29
- exitSignals.forEach((sig) => {
30
- process.on(sig, () => {
31
- runExitHandlers();
32
- if (sig !== 'exit') {
33
- process.exit(1);
34
- }
35
- });
36
- });
37
- if (process.platform === 'win32') {
38
- // Windows does not support signals, so use readline interface
39
- const rl = readline.createInterface({
40
- input: process.stdin,
41
- output: process.stdout,
42
- });
43
- rl.on('SIGINT', () => {
44
- runExitHandlers();
45
- process.exit(1);
46
- });
47
- beforeExitHandlers.push(() => {
48
- rl.close();
49
- });
50
- }
51
- export class DetailError extends Error {
52
- detail;
53
- constructor(message, detail) {
54
- super(message);
55
- this.detail = detail;
56
- }
57
- }
58
- export function getFormattedError(err) {
59
- return err instanceof DetailError
60
- ? `${err.message}\n${err.detail}`
61
- : err.stack || `${err.message}`;
62
- }
63
- export function gracefulError(err) {
64
- console.log(`${redBright('ERROR')} ${getFormattedError(err)}
65
-
66
- ${gray('If you think this is a bug, please report at https://github.com/vivliostyle/vivliostyle-cli/issues')}`);
67
- process.exit(1);
68
- }
69
- export function readJSON(path) {
70
- try {
71
- return JSON.parse(fs.readFileSync(path, 'utf8'));
72
- }
73
- catch (err) {
74
- return undefined;
75
- }
76
- }
77
- export function statFileSync(filePath, { errorMessage = 'Specified input does not exist', } = {}) {
78
- try {
79
- return fs.statSync(filePath);
80
- }
81
- catch (err) {
82
- if (err.code === 'ENOENT') {
83
- throw new Error(`${errorMessage}: ${filePath}`);
84
- }
85
- throw err;
86
- }
87
- }
88
- export async function inflateZip(filePath, dest) {
89
- return await new Promise((res, rej) => {
90
- try {
91
- const zip = new StreamZip({
92
- file: filePath,
93
- storeEntries: true,
94
- });
95
- zip.on('error', (err) => {
96
- rej(err);
97
- });
98
- zip.on('ready', async () => {
99
- await util.promisify(zip.extract)(null, dest);
100
- await util.promisify(zip.close)();
101
- Logger.debug(`Unzipped ${filePath} to ${dest}`);
102
- res();
103
- });
104
- }
105
- catch (err) {
106
- rej(err);
107
- }
108
- });
109
- }
110
- export function useTmpDirectory() {
111
- return new Promise((res, rej) => {
112
- tmp.dir({ unsafeCleanup: true }, (err, path, clear) => {
113
- if (err) {
114
- return rej(err);
115
- }
116
- Logger.debug(`Created the temporary directory: ${path}`);
117
- if (import.meta.env?.VITEST) {
118
- return res([path, () => { }]);
119
- }
120
- const callback = () => {
121
- // clear function doesn't work well?
122
- // clear();
123
- removeSync(path);
124
- Logger.debug(`Removed the temporary directory: ${path}`);
125
- };
126
- beforeExitHandlers.push(callback);
127
- res([path, callback]);
128
- });
129
- });
130
- }
131
- export function touchTmpFile(path) {
132
- fs.mkdirSync(upath.dirname(path), { recursive: true });
133
- // Create file if not exist
134
- fs.closeSync(fs.openSync(path, 'a'));
135
- Logger.debug(`Created the temporary file: ${path}`);
136
- const callback = () => {
137
- removeSync(path);
138
- Logger.debug(`Removed the temporary file: ${path}`);
139
- };
140
- beforeExitHandlers.push(callback);
141
- return callback;
142
- }
143
- export function pathEquals(path1, path2) {
144
- return upath.relative(path1, path2) === '';
145
- }
146
- export function pathContains(parentPath, childPath) {
147
- const rel = upath.relative(parentPath, childPath);
148
- return rel !== '' && !rel.startsWith('..');
149
- }
150
- export function isValidUri(str) {
151
- return /^(https?|file|data):/i.test(str);
152
- }
153
- export function isInContainer() {
154
- return fs.existsSync('/opt/vivliostyle-cli/.vs-cli-version');
155
- }
156
- export async function openEpub(epubPath, tmpDir) {
157
- await inflateZip(epubPath, tmpDir);
158
- Logger.debug(`Created the temporary EPUB directory: ${tmpDir}`);
159
- const deleteEpub = () => {
160
- fs.rmSync(tmpDir, { recursive: true });
161
- Logger.debug(`Removed the temporary EPUB directory: ${tmpDir}`);
162
- };
163
- beforeExitHandlers.push(deleteEpub);
164
- return deleteEpub;
165
- }
166
- export function getDefaultEpubOpfPath(epubDir) {
167
- const containerXmlPath = upath.join(epubDir, 'META-INF/container.xml');
168
- const xmlParser = new XMLParser({
169
- ignoreAttributes: false,
170
- });
171
- const { container } = xmlParser.parse(fs.readFileSync(containerXmlPath, 'utf8'));
172
- const rootfile = [container.rootfiles.rootfile].flat()[0]; // Only supports a default rendition
173
- const epubOpfPath = upath.join(epubDir, rootfile['@_full-path']);
174
- return epubOpfPath;
175
- }
176
- export function getEpubRootDir(epubOpfPath) {
177
- function traverse(dir) {
178
- const files = fs.readdirSync(dir);
179
- if (files.includes('META-INF') &&
180
- pathEquals(epubOpfPath, getDefaultEpubOpfPath(dir))) {
181
- return dir;
182
- }
183
- const next = upath.dirname(dir);
184
- if (pathEquals(dir, next)) {
185
- return;
186
- }
187
- return traverse(next);
188
- }
189
- return traverse(upath.dirname(epubOpfPath));
190
- }
191
- // FIXME: https://github.com/ajv-validator/ajv/issues/2047
192
- const Ajv = AjvModule.default;
193
- const addFormats = AjvFormatsModule.default;
194
- const getAjvValidatorFunction = (schema, refSchemas) => (obj) => {
195
- const ajv = new Ajv({ strict: false });
196
- addFormats(ajv);
197
- if (refSchemas) {
198
- ajv.addSchema(refSchemas);
199
- }
200
- const validate = ajv.compile(schema);
201
- const valid = validate(obj);
202
- if (!valid) {
203
- throw validate.errors?.[0] || new Error();
204
- }
205
- return true;
206
- };
207
- export const assertPubManifestSchema = getAjvValidatorFunction(publicationSchema, publicationSchemas);
208
- export function parseJsonc(rawJsonc) {
209
- const ast = parse(rawJsonc, {
210
- mode: 'jsonc',
211
- ranges: false,
212
- tokens: false,
213
- });
214
- return evaluate(ast);
215
- }
216
- export function prettifySchemaError(rawJsonc, issues) {
217
- const parsed = parse(rawJsonc, {
218
- mode: 'jsonc',
219
- ranges: false,
220
- tokens: false,
221
- });
222
- // Traverse to the deepest issue
223
- function traverse(issues, depth) {
224
- return issues.flatMap((issue) => {
225
- const p = issue.path?.length || 0;
226
- if (!issue.issues) {
227
- return [[[issue], depth + p]];
228
- }
229
- return traverse(issue.issues, depth + p).map(([i, d]) => [
230
- [issue, ...i],
231
- d,
232
- ]);
233
- });
234
- }
235
- const all = traverse(issues, 0);
236
- const maxDepth = Math.max(...all.map(([, d]) => d));
237
- const issuesTraversed = all.find(([, d]) => d === maxDepth)[0];
238
- let jsonValue = parsed.body;
239
- for (const p of issuesTraversed.flatMap((v) => v.path ?? [])) {
240
- let childValue;
241
- if (p.type === 'object' && jsonValue.type === 'Object') {
242
- childValue = jsonValue.members.find((m) => (m.name.type === 'Identifier' && m.name.name === p.key) ||
243
- (m.name.type === 'String' && m.name.value === p.key))?.value;
244
- }
245
- if (p.type === 'array' && jsonValue.type === 'Array') {
246
- childValue = jsonValue.elements[p.key]?.value;
247
- }
248
- if (childValue) {
249
- jsonValue = childValue;
250
- }
251
- else {
252
- break;
253
- }
254
- }
255
- let message = `${red(issuesTraversed.at(-1).message)}`;
256
- if (jsonValue) {
257
- message += `\n${codeFrameColumns(rawJsonc, jsonValue.loc, {
258
- highlightCode: true,
259
- })}`;
260
- }
261
- return message;
262
- }
263
- export function writeFileIfChanged(filePath, content) {
264
- if (!fs.existsSync(filePath) || !fs.readFileSync(filePath).equals(content)) {
265
- fs.mkdirSync(upath.dirname(filePath), { recursive: true });
266
- fs.writeFileSync(filePath, content);
267
- }
268
- }
269
- //# sourceMappingURL=util.js.map