epub-codec 1.2.12 → 1.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 (170) hide show
  1. package/README.md +24 -10
  2. package/dist/base64--HuymRl_.d.cts +5 -0
  3. package/dist/base64--HuymRl_.d.ts +5 -0
  4. package/dist/build-B1UxbO20.d.cts +5 -0
  5. package/dist/build-BCUsHLYw.d.ts +5 -0
  6. package/dist/codec-CX2Pa6Jq.d.ts +2876 -0
  7. package/dist/codec-qyKMOMt6.d.cts +2876 -0
  8. package/dist/codec.cjs +16 -0
  9. package/dist/codec.d.cts +2 -2702
  10. package/dist/codec.d.ts +2 -2702
  11. package/dist/codec.js +14 -1
  12. package/dist/container-B6cHHiY9.d.cts +4 -0
  13. package/dist/container-B6cHHiY9.d.ts +4 -0
  14. package/dist/context-CTgx7PwU.d.ts +28 -0
  15. package/dist/context-CXs2Yc9w.d.cts +28 -0
  16. package/dist/dimensions-B7ogpvKQ.d.cts +11 -0
  17. package/dist/dimensions-B7ogpvKQ.d.ts +11 -0
  18. package/dist/entities-CfQKtI34.d.ts +7 -0
  19. package/dist/entities-wt9zCx5q.d.cts +7 -0
  20. package/dist/footnote-CxsO5tCV.d.cts +7 -0
  21. package/dist/footnote-iZAPC_NT.d.ts +7 -0
  22. package/dist/format-DxUddUPj.d.cts +6 -0
  23. package/dist/format-DxUddUPj.d.ts +6 -0
  24. package/dist/format.d.cts +1 -5
  25. package/dist/format.d.ts +1 -5
  26. package/dist/image/dimensions.d.cts +1 -10
  27. package/dist/image/dimensions.d.ts +1 -10
  28. package/dist/index.cjs +24 -8
  29. package/dist/index.d.cts +31 -31
  30. package/dist/index.d.ts +31 -31
  31. package/dist/index.js +13 -10
  32. package/dist/inline-DDj6Sl3e.d.ts +12 -0
  33. package/dist/inline-YZOQY2wR.d.cts +12 -0
  34. package/dist/list-id-BB_yxm1H.d.cts +13 -0
  35. package/dist/list-id-BB_yxm1H.d.ts +13 -0
  36. package/dist/metadata-DXto7sM6.d.cts +7 -0
  37. package/dist/metadata-T5V2ovtS.d.ts +7 -0
  38. package/dist/model/package.cjs +19 -0
  39. package/dist/model/package.d.cts +2 -0
  40. package/dist/model/package.d.ts +2 -0
  41. package/dist/model/package.js +15 -0
  42. package/dist/nav/nav3.cjs +1 -1
  43. package/dist/nav/nav3.d.cts +1 -3
  44. package/dist/nav/nav3.d.ts +1 -3
  45. package/dist/nav/nav3.js +1 -1
  46. package/dist/nav/ncx.cjs +1 -1
  47. package/dist/nav/ncx.d.cts +1 -3
  48. package/dist/nav/ncx.d.ts +1 -3
  49. package/dist/nav/ncx.js +1 -1
  50. package/dist/nav/reconcile.d.cts +1 -3
  51. package/dist/nav/reconcile.d.ts +1 -3
  52. package/dist/nav/write.cjs +1 -1
  53. package/dist/nav/write.d.cts +1 -9
  54. package/dist/nav/write.d.ts +1 -9
  55. package/dist/nav/write.js +1 -1
  56. package/dist/nav3-SbAp8zlu.d.cts +4 -0
  57. package/dist/nav3-SbAp8zlu.d.ts +4 -0
  58. package/dist/ncx-kYhlXucj.d.cts +4 -0
  59. package/dist/ncx-kYhlXucj.d.ts +4 -0
  60. package/dist/node-CJLSSs1k.d.cts +84 -0
  61. package/dist/node-CJLSSs1k.d.ts +84 -0
  62. package/dist/ocf/container.cjs +1 -1
  63. package/dist/ocf/container.d.cts +1 -3
  64. package/dist/ocf/container.d.ts +1 -3
  65. package/dist/ocf/container.js +1 -1
  66. package/dist/ocf/write.d.cts +1 -3
  67. package/dist/ocf/write.d.ts +1 -3
  68. package/dist/opf/metadata.d.cts +1 -6
  69. package/dist/opf/metadata.d.ts +1 -6
  70. package/dist/opf/parse.cjs +1 -1
  71. package/dist/opf/parse.d.cts +1 -5
  72. package/dist/opf/parse.d.ts +1 -5
  73. package/dist/opf/parse.js +1 -1
  74. package/dist/opf/types.d.cts +1 -19
  75. package/dist/opf/types.d.ts +1 -19
  76. package/dist/opf/write.cjs +1 -1
  77. package/dist/opf/write.d.cts +1 -11
  78. package/dist/opf/write.d.ts +1 -11
  79. package/dist/opf/write.js +1 -1
  80. package/dist/package-io/read.cjs +39 -0
  81. package/dist/package-io/read.d.cts +2 -0
  82. package/dist/package-io/read.d.ts +2 -0
  83. package/dist/package-io/read.js +37 -0
  84. package/dist/package-io/write.cjs +34 -0
  85. package/dist/package-io/write.d.cts +2 -0
  86. package/dist/package-io/write.d.ts +2 -0
  87. package/dist/package-io/write.js +32 -0
  88. package/dist/parse-Bkkb7qXz.d.cts +6 -0
  89. package/dist/parse-C5GxodcX.d.ts +6 -0
  90. package/dist/parse-CmCjyz8i.d.cts +5 -0
  91. package/dist/parse-Dc76LQIj.d.ts +5 -0
  92. package/dist/path-Cx8-QMD6.d.cts +5 -0
  93. package/dist/path-Cx8-QMD6.d.ts +5 -0
  94. package/dist/path.d.cts +1 -4
  95. package/dist/path.d.ts +1 -4
  96. package/dist/query-B79eElol.d.ts +12 -0
  97. package/dist/query-C6ftPqNQ.d.cts +12 -0
  98. package/dist/read-B7kc_MeO.d.cts +10 -0
  99. package/dist/read-BMGq_D9y.d.cts +30 -0
  100. package/dist/read-Czqr3aop.d.ts +30 -0
  101. package/dist/read-DPkpZsYG.d.ts +10 -0
  102. package/dist/read.cjs +51 -6
  103. package/dist/read.d.cts +1 -9
  104. package/dist/read.d.ts +1 -9
  105. package/dist/read.js +52 -7
  106. package/dist/reconcile-BHky0kta.d.cts +4 -0
  107. package/dist/reconcile-BHky0kta.d.ts +4 -0
  108. package/dist/style-constants-RVoHdmju.d.cts +8 -0
  109. package/dist/style-constants-RVoHdmju.d.ts +8 -0
  110. package/dist/types-BxmkPT_F.d.cts +20 -0
  111. package/dist/types-BxmkPT_F.d.ts +20 -0
  112. package/dist/util/base64.d.cts +1 -4
  113. package/dist/util/base64.d.ts +1 -4
  114. package/dist/write-B89sagtw.d.cts +12 -0
  115. package/dist/write-BQcrPQvx.d.ts +10 -0
  116. package/dist/write-Boxi3aK0.d.cts +10 -0
  117. package/dist/write-COdkb8lG.d.cts +10 -0
  118. package/dist/write-COdkb8lG.d.ts +10 -0
  119. package/dist/write-DwaEwwgZ.d.ts +12 -0
  120. package/dist/write-DxiR-9eH.d.cts +4 -0
  121. package/dist/write-DxiR-9eH.d.ts +4 -0
  122. package/dist/write-Klo0WDhT.d.ts +13 -0
  123. package/dist/write-WSIgARHT.d.cts +13 -0
  124. package/dist/write.cjs +28 -6
  125. package/dist/write.d.cts +1 -9
  126. package/dist/write.d.ts +1 -9
  127. package/dist/write.js +28 -6
  128. package/dist/xhtml/context.d.cts +2 -22
  129. package/dist/xhtml/context.d.ts +2 -22
  130. package/dist/xhtml/footnote.cjs +4 -8
  131. package/dist/xhtml/footnote.d.cts +2 -7
  132. package/dist/xhtml/footnote.d.ts +2 -7
  133. package/dist/xhtml/footnote.js +4 -8
  134. package/dist/xhtml/inline.cjs +13 -7
  135. package/dist/xhtml/inline.d.cts +1 -11
  136. package/dist/xhtml/inline.d.ts +1 -11
  137. package/dist/xhtml/inline.js +13 -7
  138. package/dist/xhtml/link-target.cjs +18 -0
  139. package/dist/xhtml/link-target.d.cts +8 -0
  140. package/dist/xhtml/link-target.d.ts +8 -0
  141. package/dist/xhtml/link-target.js +17 -0
  142. package/dist/xhtml/list-id.d.cts +1 -12
  143. package/dist/xhtml/list-id.d.ts +1 -12
  144. package/dist/xhtml/read.cjs +50 -18
  145. package/dist/xhtml/read.d.cts +2 -20
  146. package/dist/xhtml/read.d.ts +2 -20
  147. package/dist/xhtml/read.js +49 -19
  148. package/dist/xhtml/style-constants.d.cts +1 -7
  149. package/dist/xhtml/style-constants.d.ts +1 -7
  150. package/dist/xhtml/write.cjs +44 -19
  151. package/dist/xhtml/write.d.cts +1 -11
  152. package/dist/xhtml/write.d.ts +1 -11
  153. package/dist/xhtml/write.js +44 -19
  154. package/dist/xml/build.d.cts +1 -4
  155. package/dist/xml/build.d.ts +1 -4
  156. package/dist/xml/entities.d.cts +1 -6
  157. package/dist/xml/entities.d.ts +1 -6
  158. package/dist/xml/node.d.cts +1 -83
  159. package/dist/xml/node.d.ts +1 -83
  160. package/dist/xml/parse.d.cts +1 -4
  161. package/dist/xml/parse.d.ts +1 -4
  162. package/dist/xml/query.cjs +1 -1
  163. package/dist/xml/query.d.cts +1 -11
  164. package/dist/xml/query.d.ts +1 -11
  165. package/dist/xml/query.js +1 -1
  166. package/dist/zip-ie17sOo5.d.cts +9 -0
  167. package/dist/zip-ie17sOo5.d.ts +9 -0
  168. package/dist/zip.d.cts +1 -8
  169. package/dist/zip.d.ts +1 -8
  170. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ import { i as EpubDiagnosticSink } from "./diagnostics-C0CRdoda.js";
2
+ import { l as XmlElement } from "./node-CJLSSs1k.js";
3
+ import { LayoutMetadata } from "document-schema.js";
4
+ //#region src/opf/metadata.d.ts
5
+ declare function readOpfMetadata(metadataElement: XmlElement, sink: EpubDiagnosticSink): LayoutMetadata;
6
+ //#endregion
7
+ export { readOpfMetadata as t };
@@ -0,0 +1,19 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_node = require("../xml/node.cjs");
3
+ let zod = require("zod");
4
+ //#region src/model/package.ts
5
+ const XmlPartSchema = zod.z.object({
6
+ kind: zod.z.literal("xml"),
7
+ nodes: zod.z.array(require_xml_node.XmlNodeSchema)
8
+ });
9
+ const BinaryPartSchema = zod.z.object({
10
+ kind: zod.z.literal("binary"),
11
+ base64: zod.z.string()
12
+ });
13
+ const PartSchema = zod.z.discriminatedUnion("kind", [XmlPartSchema, BinaryPartSchema]);
14
+ const EpubPackageSchema = zod.z.object({ parts: zod.z.record(zod.z.string(), PartSchema) });
15
+ //#endregion
16
+ exports.BinaryPartSchema = BinaryPartSchema;
17
+ exports.EpubPackageSchema = EpubPackageSchema;
18
+ exports.PartSchema = PartSchema;
19
+ exports.XmlPartSchema = XmlPartSchema;
@@ -0,0 +1,2 @@
1
+ import { _ as XmlPart, d as BinaryPart, f as BinaryPartSchema, g as PartSchema, h as Part, m as EpubPackageSchema, p as EpubPackage, v as XmlPartSchema } from "../codec-qyKMOMt6.cjs";
2
+ export { BinaryPart, BinaryPartSchema, EpubPackage, EpubPackageSchema, Part, PartSchema, XmlPart, XmlPartSchema };
@@ -0,0 +1,2 @@
1
+ import { _ as XmlPart, d as BinaryPart, f as BinaryPartSchema, g as PartSchema, h as Part, m as EpubPackageSchema, p as EpubPackage, v as XmlPartSchema } from "../codec-CX2Pa6Jq.js";
2
+ export { BinaryPart, BinaryPartSchema, EpubPackage, EpubPackageSchema, Part, PartSchema, XmlPart, XmlPartSchema };
@@ -0,0 +1,15 @@
1
+ import { XmlNodeSchema } from "../xml/node.js";
2
+ import { z } from "zod";
3
+ //#region src/model/package.ts
4
+ const XmlPartSchema = z.object({
5
+ kind: z.literal("xml"),
6
+ nodes: z.array(XmlNodeSchema)
7
+ });
8
+ const BinaryPartSchema = z.object({
9
+ kind: z.literal("binary"),
10
+ base64: z.string()
11
+ });
12
+ const PartSchema = z.discriminatedUnion("kind", [XmlPartSchema, BinaryPartSchema]);
13
+ const EpubPackageSchema = z.object({ parts: z.record(z.string(), PartSchema) });
14
+ //#endregion
15
+ export { BinaryPartSchema, EpubPackageSchema, PartSchema, XmlPartSchema };
package/dist/nav/nav3.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_xml_query = require("../xml/query.cjs");
3
2
  const require_xml_parse = require("../xml/parse.cjs");
3
+ const require_xml_query = require("../xml/query.cjs");
4
4
  //#region src/nav/nav3.ts
5
5
  function readNav3TocHrefs(navXhtml) {
6
6
  const nodes = require_xml_parse.parseXml(navXhtml);
@@ -1,4 +1,2 @@
1
- //#region src/nav/nav3.d.ts
2
- declare function readNav3TocHrefs(navXhtml: string): string[] | undefined;
3
- //#endregion
1
+ import { t as readNav3TocHrefs } from "../nav3-SbAp8zlu.cjs";
4
2
  export { readNav3TocHrefs };
@@ -1,4 +1,2 @@
1
- //#region src/nav/nav3.d.ts
2
- declare function readNav3TocHrefs(navXhtml: string): string[] | undefined;
3
- //#endregion
1
+ import { t as readNav3TocHrefs } from "../nav3-SbAp8zlu.js";
4
2
  export { readNav3TocHrefs };
package/dist/nav/nav3.js CHANGED
@@ -1,5 +1,5 @@
1
- import { attrValue, elementsWithTag, findChildElement, findElement, rootElement } from "../xml/query.js";
2
1
  import { parseXml } from "../xml/parse.js";
2
+ import { attrValue, elementsWithTag, findChildElement, findElement, rootElement } from "../xml/query.js";
3
3
  //#region src/nav/nav3.ts
4
4
  function readNav3TocHrefs(navXhtml) {
5
5
  const nodes = parseXml(navXhtml);
package/dist/nav/ncx.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_xml_query = require("../xml/query.cjs");
3
2
  const require_xml_parse = require("../xml/parse.cjs");
3
+ const require_xml_query = require("../xml/query.cjs");
4
4
  //#region src/nav/ncx.ts
5
5
  function readNcxHrefs(ncxXml) {
6
6
  const nodes = require_xml_parse.parseXml(ncxXml);
@@ -1,4 +1,2 @@
1
- //#region src/nav/ncx.d.ts
2
- declare function readNcxHrefs(ncxXml: string): string[] | undefined;
3
- //#endregion
1
+ import { t as readNcxHrefs } from "../ncx-kYhlXucj.cjs";
4
2
  export { readNcxHrefs };
package/dist/nav/ncx.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- //#region src/nav/ncx.d.ts
2
- declare function readNcxHrefs(ncxXml: string): string[] | undefined;
3
- //#endregion
1
+ import { t as readNcxHrefs } from "../ncx-kYhlXucj.js";
4
2
  export { readNcxHrefs };
package/dist/nav/ncx.js CHANGED
@@ -1,5 +1,5 @@
1
- import { attrValue, elementsWithTag, findChildElement, rootElement } from "../xml/query.js";
2
1
  import { parseXml } from "../xml/parse.js";
2
+ import { attrValue, elementsWithTag, findChildElement, rootElement } from "../xml/query.js";
3
3
  //#region src/nav/ncx.ts
4
4
  function readNcxHrefs(ncxXml) {
5
5
  const nodes = parseXml(ncxXml);
@@ -1,4 +1,2 @@
1
- //#region src/nav/reconcile.d.ts
2
- declare function navMatchesSpine(navHrefs: readonly string[], spineHrefs: readonly string[]): boolean;
3
- //#endregion
1
+ import { t as navMatchesSpine } from "../reconcile-BHky0kta.cjs";
4
2
  export { navMatchesSpine };
@@ -1,4 +1,2 @@
1
- //#region src/nav/reconcile.d.ts
2
- declare function navMatchesSpine(navHrefs: readonly string[], spineHrefs: readonly string[]): boolean;
3
- //#endregion
1
+ import { t as navMatchesSpine } from "../reconcile-BHky0kta.js";
4
2
  export { navMatchesSpine };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_xml_entities = require("../xml/entities.cjs");
3
2
  const require_xml_build = require("../xml/build.cjs");
3
+ const require_xml_entities = require("../xml/entities.cjs");
4
4
  //#region src/nav/write.ts
5
5
  function element(tag, attrs = {}, children = []) {
6
6
  return {
@@ -1,10 +1,2 @@
1
- import { ContentSection } from "document-schema.js";
2
- //#region src/nav/write.d.ts
3
- interface NavSectionEntry {
4
- readonly href: string;
5
- readonly section: ContentSection;
6
- }
7
- declare function sectionTitle(section: ContentSection, index: number): string;
8
- declare function writeNav3Document(entries: readonly NavSectionEntry[]): string;
9
- //#endregion
1
+ import { n as sectionTitle, r as writeNav3Document, t as NavSectionEntry } from "../write-COdkb8lG.cjs";
10
2
  export { NavSectionEntry, sectionTitle, writeNav3Document };
@@ -1,10 +1,2 @@
1
- import { ContentSection } from "document-schema.js";
2
- //#region src/nav/write.d.ts
3
- interface NavSectionEntry {
4
- readonly href: string;
5
- readonly section: ContentSection;
6
- }
7
- declare function sectionTitle(section: ContentSection, index: number): string;
8
- declare function writeNav3Document(entries: readonly NavSectionEntry[]): string;
9
- //#endregion
1
+ import { n as sectionTitle, r as writeNav3Document, t as NavSectionEntry } from "../write-COdkb8lG.js";
10
2
  export { NavSectionEntry, sectionTitle, writeNav3Document };
package/dist/nav/write.js CHANGED
@@ -1,5 +1,5 @@
1
- import { encodeEntities } from "../xml/entities.js";
2
1
  import { buildXml } from "../xml/build.js";
2
+ import { encodeEntities } from "../xml/entities.js";
3
3
  //#region src/nav/write.ts
4
4
  function element(tag, attrs = {}, children = []) {
5
5
  return {
@@ -0,0 +1,4 @@
1
+ //#region src/nav/nav3.d.ts
2
+ declare function readNav3TocHrefs(navXhtml: string): string[] | undefined;
3
+ //#endregion
4
+ export { readNav3TocHrefs as t };
@@ -0,0 +1,4 @@
1
+ //#region src/nav/nav3.d.ts
2
+ declare function readNav3TocHrefs(navXhtml: string): string[] | undefined;
3
+ //#endregion
4
+ export { readNav3TocHrefs as t };
@@ -0,0 +1,4 @@
1
+ //#region src/nav/ncx.d.ts
2
+ declare function readNcxHrefs(ncxXml: string): string[] | undefined;
3
+ //#endregion
4
+ export { readNcxHrefs as t };
@@ -0,0 +1,4 @@
1
+ //#region src/nav/ncx.d.ts
2
+ declare function readNcxHrefs(ncxXml: string): string[] | undefined;
3
+ //#endregion
4
+ export { readNcxHrefs as t };
@@ -0,0 +1,84 @@
1
+ import { z } from "zod";
2
+ //#region src/xml/node.d.ts
3
+ declare const AttributeSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ value: z.ZodString;
6
+ }, z.core.$strip>;
7
+ type Attribute = z.infer<typeof AttributeSchema>;
8
+ declare const XmlTextSchema: z.ZodObject<{
9
+ type: z.ZodLiteral<"text">;
10
+ value: z.ZodString;
11
+ }, z.core.$strip>;
12
+ type XmlText = z.infer<typeof XmlTextSchema>;
13
+ declare const XmlCdataSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"cdata">;
15
+ value: z.ZodString;
16
+ }, z.core.$strip>;
17
+ type XmlCdata = z.infer<typeof XmlCdataSchema>;
18
+ declare const XmlCommentSchema: z.ZodObject<{
19
+ type: z.ZodLiteral<"comment">;
20
+ value: z.ZodString;
21
+ }, z.core.$strip>;
22
+ type XmlComment = z.infer<typeof XmlCommentSchema>;
23
+ declare const XmlDeclarationSchema: z.ZodObject<{
24
+ type: z.ZodLiteral<"declaration">;
25
+ attributes: z.ZodArray<z.ZodObject<{
26
+ name: z.ZodString;
27
+ value: z.ZodString;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>;
30
+ type XmlDeclaration = z.infer<typeof XmlDeclarationSchema>;
31
+ declare const XmlPiSchema: z.ZodObject<{
32
+ type: z.ZodLiteral<"pi">;
33
+ target: z.ZodString;
34
+ content: z.ZodString;
35
+ }, z.core.$strip>;
36
+ type XmlPi = z.infer<typeof XmlPiSchema>;
37
+ interface XmlElement {
38
+ type: "element";
39
+ tag: string;
40
+ attributes: Attribute[];
41
+ children: XmlNode[];
42
+ }
43
+ type XmlNode = XmlText | XmlCdata | XmlComment | XmlDeclaration | XmlPi | XmlElement;
44
+ declare function isTextLikeNode(node: XmlNode): node is XmlText | XmlCdata;
45
+ declare function isXmlNode(value: unknown): value is XmlNode;
46
+ declare const XmlElementSchema: z.ZodObject<{
47
+ type: z.ZodLiteral<"element">;
48
+ tag: z.ZodString;
49
+ attributes: z.ZodArray<z.ZodObject<{
50
+ name: z.ZodString;
51
+ value: z.ZodString;
52
+ }, z.core.$strip>>;
53
+ children: z.ZodArray<z.ZodCustom<XmlNode, XmlNode>>;
54
+ }, z.core.$strip>;
55
+ declare const XmlNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
56
+ type: z.ZodLiteral<"text">;
57
+ value: z.ZodString;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ type: z.ZodLiteral<"cdata">;
60
+ value: z.ZodString;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"comment">;
63
+ value: z.ZodString;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ type: z.ZodLiteral<"declaration">;
66
+ attributes: z.ZodArray<z.ZodObject<{
67
+ name: z.ZodString;
68
+ value: z.ZodString;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ type: z.ZodLiteral<"pi">;
72
+ target: z.ZodString;
73
+ content: z.ZodString;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ type: z.ZodLiteral<"element">;
76
+ tag: z.ZodString;
77
+ attributes: z.ZodArray<z.ZodObject<{
78
+ name: z.ZodString;
79
+ value: z.ZodString;
80
+ }, z.core.$strip>>;
81
+ children: z.ZodArray<z.ZodCustom<XmlNode, XmlNode>>;
82
+ }, z.core.$strip>], "type">;
83
+ //#endregion
84
+ export { isTextLikeNode as _, XmlComment as a, XmlDeclarationSchema as c, XmlNode as d, XmlNodeSchema as f, XmlTextSchema as g, XmlText as h, XmlCdataSchema as i, XmlElement as l, XmlPiSchema as m, AttributeSchema as n, XmlCommentSchema as o, XmlPi as p, XmlCdata as r, XmlDeclaration as s, Attribute as t, XmlElementSchema as u, isXmlNode as v };
@@ -0,0 +1,84 @@
1
+ import { z } from "zod";
2
+ //#region src/xml/node.d.ts
3
+ declare const AttributeSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ value: z.ZodString;
6
+ }, z.core.$strip>;
7
+ type Attribute = z.infer<typeof AttributeSchema>;
8
+ declare const XmlTextSchema: z.ZodObject<{
9
+ type: z.ZodLiteral<"text">;
10
+ value: z.ZodString;
11
+ }, z.core.$strip>;
12
+ type XmlText = z.infer<typeof XmlTextSchema>;
13
+ declare const XmlCdataSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"cdata">;
15
+ value: z.ZodString;
16
+ }, z.core.$strip>;
17
+ type XmlCdata = z.infer<typeof XmlCdataSchema>;
18
+ declare const XmlCommentSchema: z.ZodObject<{
19
+ type: z.ZodLiteral<"comment">;
20
+ value: z.ZodString;
21
+ }, z.core.$strip>;
22
+ type XmlComment = z.infer<typeof XmlCommentSchema>;
23
+ declare const XmlDeclarationSchema: z.ZodObject<{
24
+ type: z.ZodLiteral<"declaration">;
25
+ attributes: z.ZodArray<z.ZodObject<{
26
+ name: z.ZodString;
27
+ value: z.ZodString;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>;
30
+ type XmlDeclaration = z.infer<typeof XmlDeclarationSchema>;
31
+ declare const XmlPiSchema: z.ZodObject<{
32
+ type: z.ZodLiteral<"pi">;
33
+ target: z.ZodString;
34
+ content: z.ZodString;
35
+ }, z.core.$strip>;
36
+ type XmlPi = z.infer<typeof XmlPiSchema>;
37
+ interface XmlElement {
38
+ type: "element";
39
+ tag: string;
40
+ attributes: Attribute[];
41
+ children: XmlNode[];
42
+ }
43
+ type XmlNode = XmlText | XmlCdata | XmlComment | XmlDeclaration | XmlPi | XmlElement;
44
+ declare function isTextLikeNode(node: XmlNode): node is XmlText | XmlCdata;
45
+ declare function isXmlNode(value: unknown): value is XmlNode;
46
+ declare const XmlElementSchema: z.ZodObject<{
47
+ type: z.ZodLiteral<"element">;
48
+ tag: z.ZodString;
49
+ attributes: z.ZodArray<z.ZodObject<{
50
+ name: z.ZodString;
51
+ value: z.ZodString;
52
+ }, z.core.$strip>>;
53
+ children: z.ZodArray<z.ZodCustom<XmlNode, XmlNode>>;
54
+ }, z.core.$strip>;
55
+ declare const XmlNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
56
+ type: z.ZodLiteral<"text">;
57
+ value: z.ZodString;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ type: z.ZodLiteral<"cdata">;
60
+ value: z.ZodString;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"comment">;
63
+ value: z.ZodString;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ type: z.ZodLiteral<"declaration">;
66
+ attributes: z.ZodArray<z.ZodObject<{
67
+ name: z.ZodString;
68
+ value: z.ZodString;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ type: z.ZodLiteral<"pi">;
72
+ target: z.ZodString;
73
+ content: z.ZodString;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ type: z.ZodLiteral<"element">;
76
+ tag: z.ZodString;
77
+ attributes: z.ZodArray<z.ZodObject<{
78
+ name: z.ZodString;
79
+ value: z.ZodString;
80
+ }, z.core.$strip>>;
81
+ children: z.ZodArray<z.ZodCustom<XmlNode, XmlNode>>;
82
+ }, z.core.$strip>], "type">;
83
+ //#endregion
84
+ export { isTextLikeNode as _, XmlComment as a, XmlDeclarationSchema as c, XmlNode as d, XmlNodeSchema as f, XmlTextSchema as g, XmlText as h, XmlCdataSchema as i, XmlElement as l, XmlPiSchema as m, AttributeSchema as n, XmlCommentSchema as o, XmlPi as p, XmlCdata as r, XmlDeclaration as s, Attribute as t, XmlElementSchema as u, isXmlNode as v };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_parse = require("../xml/parse.cjs");
2
3
  const require_diagnostics = require("../diagnostics.cjs");
3
4
  const require_xml_query = require("../xml/query.cjs");
4
- const require_xml_parse = require("../xml/parse.cjs");
5
5
  //#region src/ocf/container.ts
6
6
  const OPF_MEDIA_TYPE = "application/oebps-package+xml";
7
7
  function resolveOpfPath(containerXml) {
@@ -1,4 +1,2 @@
1
- //#region src/ocf/container.d.ts
2
- declare function resolveOpfPath(containerXml: string): string;
3
- //#endregion
1
+ import { t as resolveOpfPath } from "../container-B6cHHiY9.cjs";
4
2
  export { resolveOpfPath };
@@ -1,4 +1,2 @@
1
- //#region src/ocf/container.d.ts
2
- declare function resolveOpfPath(containerXml: string): string;
3
- //#endregion
1
+ import { t as resolveOpfPath } from "../container-B6cHHiY9.js";
4
2
  export { resolveOpfPath };
@@ -1,6 +1,6 @@
1
+ import { parseXml } from "../xml/parse.js";
1
2
  import { EpubInvalidContainerError } from "../diagnostics.js";
2
3
  import { attrValue, childrenWithTag, findChildElement, rootElement } from "../xml/query.js";
3
- import { parseXml } from "../xml/parse.js";
4
4
  //#region src/ocf/container.ts
5
5
  const OPF_MEDIA_TYPE = "application/oebps-package+xml";
6
6
  function resolveOpfPath(containerXml) {
@@ -1,4 +1,2 @@
1
- //#region src/ocf/write.d.ts
2
- declare function writeContainerXml(opfPath: string): string;
3
- //#endregion
1
+ import { t as writeContainerXml } from "../write-DxiR-9eH.cjs";
4
2
  export { writeContainerXml };
@@ -1,4 +1,2 @@
1
- //#region src/ocf/write.d.ts
2
- declare function writeContainerXml(opfPath: string): string;
3
- //#endregion
1
+ import { t as writeContainerXml } from "../write-DxiR-9eH.js";
4
2
  export { writeContainerXml };
@@ -1,7 +1,2 @@
1
- import { i as EpubDiagnosticSink } from "../diagnostics-C0CRdoda.cjs";
2
- import { XmlElement } from "../xml/node.cjs";
3
- import { LayoutMetadata } from "document-schema.js";
4
- //#region src/opf/metadata.d.ts
5
- declare function readOpfMetadata(metadataElement: XmlElement, sink: EpubDiagnosticSink): LayoutMetadata;
6
- //#endregion
1
+ import { t as readOpfMetadata } from "../metadata-DXto7sM6.cjs";
7
2
  export { readOpfMetadata };
@@ -1,7 +1,2 @@
1
- import { i as EpubDiagnosticSink } from "../diagnostics-C0CRdoda.js";
2
- import { XmlElement } from "../xml/node.js";
3
- import { LayoutMetadata } from "document-schema.js";
4
- //#region src/opf/metadata.d.ts
5
- declare function readOpfMetadata(metadataElement: XmlElement, sink: EpubDiagnosticSink): LayoutMetadata;
6
- //#endregion
1
+ import { t as readOpfMetadata } from "../metadata-T5V2ovtS.js";
7
2
  export { readOpfMetadata };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_parse = require("../xml/parse.cjs");
2
3
  const require_diagnostics = require("../diagnostics.cjs");
3
4
  const require_xml_query = require("../xml/query.cjs");
4
- const require_xml_parse = require("../xml/parse.cjs");
5
5
  const require_opf_metadata = require("./metadata.cjs");
6
6
  //#region src/opf/parse.ts
7
7
  function parseOpf(opfXml, sink = require_diagnostics.NOOP_EPUB_DIAGNOSTIC_SINK) {
@@ -1,6 +1,2 @@
1
- import { i as EpubDiagnosticSink } from "../diagnostics-C0CRdoda.cjs";
2
- import { OpfPackage } from "./types.cjs";
3
- //#region src/opf/parse.d.ts
4
- declare function parseOpf(opfXml: string, sink?: EpubDiagnosticSink): OpfPackage;
5
- //#endregion
1
+ import { t as parseOpf } from "../parse-Bkkb7qXz.cjs";
6
2
  export { parseOpf };
@@ -1,6 +1,2 @@
1
- import { i as EpubDiagnosticSink } from "../diagnostics-C0CRdoda.js";
2
- import { OpfPackage } from "./types.js";
3
- //#region src/opf/parse.d.ts
4
- declare function parseOpf(opfXml: string, sink?: EpubDiagnosticSink): OpfPackage;
5
- //#endregion
1
+ import { t as parseOpf } from "../parse-C5GxodcX.js";
6
2
  export { parseOpf };
package/dist/opf/parse.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { parseXml } from "../xml/parse.js";
1
2
  import { EpubInvalidOpfError, NOOP_EPUB_DIAGNOSTIC_SINK } from "../diagnostics.js";
2
3
  import { attrValue, childrenWithTag, findChildElement, rootElement } from "../xml/query.js";
3
- import { parseXml } from "../xml/parse.js";
4
4
  import { readOpfMetadata } from "./metadata.js";
5
5
  //#region src/opf/parse.ts
6
6
  function parseOpf(opfXml, sink = NOOP_EPUB_DIAGNOSTIC_SINK) {
@@ -1,20 +1,2 @@
1
- import { LayoutMetadata } from "document-schema.js";
2
- //#region src/opf/types.d.ts
3
- interface OpfManifestItem {
4
- readonly id: string;
5
- readonly href: string;
6
- readonly mediaType: string;
7
- readonly properties: readonly string[];
8
- }
9
- interface OpfSpineItemRef {
10
- readonly idref: string;
11
- readonly linear: boolean;
12
- }
13
- interface OpfPackage {
14
- readonly metadata: LayoutMetadata;
15
- readonly manifest: readonly OpfManifestItem[];
16
- readonly spine: readonly OpfSpineItemRef[];
17
- readonly ncxId: string | undefined;
18
- }
19
- //#endregion
1
+ import { n as OpfPackage, r as OpfSpineItemRef, t as OpfManifestItem } from "../types-BxmkPT_F.cjs";
20
2
  export { OpfManifestItem, OpfPackage, OpfSpineItemRef };
@@ -1,20 +1,2 @@
1
- import { LayoutMetadata } from "document-schema.js";
2
- //#region src/opf/types.d.ts
3
- interface OpfManifestItem {
4
- readonly id: string;
5
- readonly href: string;
6
- readonly mediaType: string;
7
- readonly properties: readonly string[];
8
- }
9
- interface OpfSpineItemRef {
10
- readonly idref: string;
11
- readonly linear: boolean;
12
- }
13
- interface OpfPackage {
14
- readonly metadata: LayoutMetadata;
15
- readonly manifest: readonly OpfManifestItem[];
16
- readonly spine: readonly OpfSpineItemRef[];
17
- readonly ncxId: string | undefined;
18
- }
19
- //#endregion
1
+ import { n as OpfPackage, r as OpfSpineItemRef, t as OpfManifestItem } from "../types-BxmkPT_F.js";
20
2
  export { OpfManifestItem, OpfPackage, OpfSpineItemRef };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_xml_entities = require("../xml/entities.cjs");
3
2
  const require_xml_build = require("../xml/build.cjs");
3
+ const require_xml_entities = require("../xml/entities.cjs");
4
4
  //#region src/opf/write.ts
5
5
  function element(tag, attrs = {}, children = []) {
6
6
  return {
@@ -1,12 +1,2 @@
1
- import { OpfManifestItem } from "./types.cjs";
2
- import { LayoutMetadata } from "document-schema.js";
3
- //#region src/opf/write.d.ts
4
- interface WriteOpfInput {
5
- readonly metadata: LayoutMetadata;
6
- readonly manifestItems: readonly OpfManifestItem[];
7
- readonly spineIdrefs: readonly string[];
8
- readonly identifier: string;
9
- }
10
- declare function writeOpf(input: WriteOpfInput): string;
11
- //#endregion
1
+ import { n as writeOpf, t as WriteOpfInput } from "../write-B89sagtw.cjs";
12
2
  export { WriteOpfInput, writeOpf };
@@ -1,12 +1,2 @@
1
- import { OpfManifestItem } from "./types.js";
2
- import { LayoutMetadata } from "document-schema.js";
3
- //#region src/opf/write.d.ts
4
- interface WriteOpfInput {
5
- readonly metadata: LayoutMetadata;
6
- readonly manifestItems: readonly OpfManifestItem[];
7
- readonly spineIdrefs: readonly string[];
8
- readonly identifier: string;
9
- }
10
- declare function writeOpf(input: WriteOpfInput): string;
11
- //#endregion
1
+ import { n as writeOpf, t as WriteOpfInput } from "../write-DwaEwwgZ.js";
12
2
  export { WriteOpfInput, writeOpf };
package/dist/opf/write.js CHANGED
@@ -1,5 +1,5 @@
1
- import { encodeEntities } from "../xml/entities.js";
2
1
  import { buildXml } from "../xml/build.js";
2
+ import { encodeEntities } from "../xml/entities.js";
3
3
  //#region src/opf/write.ts
4
4
  function element(tag, attrs = {}, children = []) {
5
5
  return {
@@ -0,0 +1,39 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_util_base64 = require("../util/base64.cjs");
3
+ const require_xml_parse = require("../xml/parse.cjs");
4
+ const require_zip = require("../zip.cjs");
5
+ //#region src/package-io/read.ts
6
+ function parsePackage(bytes) {
7
+ return packageFromEntries(require_zip.unzipPackage(bytes));
8
+ }
9
+ function packageFromEntries(entries) {
10
+ const parts = {};
11
+ for (const [path, partBytes] of Object.entries(entries)) if (looksLikeXml(partBytes)) {
12
+ const xml = new TextDecoder("utf-8").decode(partBytes);
13
+ parts[path] = {
14
+ kind: "xml",
15
+ nodes: require_xml_parse.parseXml(xml)
16
+ };
17
+ } else parts[path] = {
18
+ kind: "binary",
19
+ base64: require_util_base64.bytesToBase64(partBytes)
20
+ };
21
+ return { parts };
22
+ }
23
+ function looksLikeXml(bytes) {
24
+ let i = 0;
25
+ if (bytes.length >= 3 && bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) i = 3;
26
+ while (i < bytes.length) {
27
+ const b = bytes[i];
28
+ if (b === void 0) return false;
29
+ if (b === 32 || b === 9 || b === 10 || b === 13) {
30
+ i = i + 1;
31
+ continue;
32
+ }
33
+ return b === 60;
34
+ }
35
+ return false;
36
+ }
37
+ //#endregion
38
+ exports.packageFromEntries = packageFromEntries;
39
+ exports.parsePackage = parsePackage;
@@ -0,0 +1,2 @@
1
+ import { l as packageFromEntries, u as parsePackage } from "../codec-qyKMOMt6.cjs";
2
+ export { packageFromEntries, parsePackage };
@@ -0,0 +1,2 @@
1
+ import { l as packageFromEntries, u as parsePackage } from "../codec-CX2Pa6Jq.js";
2
+ export { packageFromEntries, parsePackage };