@bendyline/squisq-formats 1.3.0 → 1.3.1

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 (161) hide show
  1. package/dist/container/index.d.ts +7 -5
  2. package/dist/container/index.js +39 -70
  3. package/dist/container/index.js.map +1 -1
  4. package/dist/docx/index.d.ts +128 -15
  5. package/dist/docx/index.js +17 -22
  6. package/dist/docx/index.js.map +1 -1
  7. package/dist/epub/index.d.ts +66 -11
  8. package/dist/epub/index.js +10 -18
  9. package/dist/epub/index.js.map +1 -1
  10. package/dist/html/index.d.ts +278 -15
  11. package/dist/html/index.js +26 -165
  12. package/dist/html/index.js.map +1 -1
  13. package/dist/index.d.ts +9 -38
  14. package/dist/index.js +62 -37
  15. package/dist/index.js.map +1 -1
  16. package/dist/ooxml/index.d.ts +353 -14
  17. package/dist/ooxml/index.js +116 -22
  18. package/dist/ooxml/index.js.map +1 -1
  19. package/dist/pdf/index.d.ts +143 -17
  20. package/dist/pdf/index.js +16 -25
  21. package/dist/pdf/index.js.map +1 -1
  22. package/dist/pptx/index.d.ts +83 -8
  23. package/dist/pptx/index.js +14 -34
  24. package/dist/pptx/index.js.map +1 -1
  25. package/dist/xlsx/index.d.ts +12 -9
  26. package/dist/xlsx/index.js +12 -44
  27. package/dist/xlsx/index.js.map +1 -1
  28. package/package.json +2 -2
  29. package/dist/__tests__/container.test.d.ts +0 -8
  30. package/dist/__tests__/container.test.d.ts.map +0 -1
  31. package/dist/__tests__/container.test.js +0 -147
  32. package/dist/__tests__/container.test.js.map +0 -1
  33. package/dist/__tests__/docxExport.test.d.ts +0 -8
  34. package/dist/__tests__/docxExport.test.d.ts.map +0 -1
  35. package/dist/__tests__/docxExport.test.js +0 -383
  36. package/dist/__tests__/docxExport.test.js.map +0 -1
  37. package/dist/__tests__/docxImport.test.d.ts +0 -8
  38. package/dist/__tests__/docxImport.test.d.ts.map +0 -1
  39. package/dist/__tests__/docxImport.test.js +0 -309
  40. package/dist/__tests__/docxImport.test.js.map +0 -1
  41. package/dist/__tests__/epub.test.d.ts +0 -8
  42. package/dist/__tests__/epub.test.d.ts.map +0 -1
  43. package/dist/__tests__/epub.test.js +0 -472
  44. package/dist/__tests__/epub.test.js.map +0 -1
  45. package/dist/__tests__/html.test.d.ts +0 -8
  46. package/dist/__tests__/html.test.d.ts.map +0 -1
  47. package/dist/__tests__/html.test.js +0 -317
  48. package/dist/__tests__/html.test.js.map +0 -1
  49. package/dist/__tests__/ooxml.test.d.ts +0 -5
  50. package/dist/__tests__/ooxml.test.d.ts.map +0 -1
  51. package/dist/__tests__/ooxml.test.js +0 -152
  52. package/dist/__tests__/ooxml.test.js.map +0 -1
  53. package/dist/__tests__/pdfExport.test.d.ts +0 -8
  54. package/dist/__tests__/pdfExport.test.d.ts.map +0 -1
  55. package/dist/__tests__/pdfExport.test.js +0 -275
  56. package/dist/__tests__/pdfExport.test.js.map +0 -1
  57. package/dist/__tests__/pdfImport.test.d.ts +0 -11
  58. package/dist/__tests__/pdfImport.test.d.ts.map +0 -1
  59. package/dist/__tests__/pdfImport.test.js +0 -254
  60. package/dist/__tests__/pdfImport.test.js.map +0 -1
  61. package/dist/__tests__/plainHtml.test.d.ts +0 -5
  62. package/dist/__tests__/plainHtml.test.d.ts.map +0 -1
  63. package/dist/__tests__/plainHtml.test.js +0 -327
  64. package/dist/__tests__/plainHtml.test.js.map +0 -1
  65. package/dist/__tests__/plainHtmlBundle.test.d.ts +0 -11
  66. package/dist/__tests__/plainHtmlBundle.test.d.ts.map +0 -1
  67. package/dist/__tests__/plainHtmlBundle.test.js +0 -210
  68. package/dist/__tests__/plainHtmlBundle.test.js.map +0 -1
  69. package/dist/__tests__/roundTrip.test.d.ts +0 -7
  70. package/dist/__tests__/roundTrip.test.d.ts.map +0 -1
  71. package/dist/__tests__/roundTrip.test.js +0 -173
  72. package/dist/__tests__/roundTrip.test.js.map +0 -1
  73. package/dist/container/index.d.ts.map +0 -1
  74. package/dist/docx/export.d.ts +0 -69
  75. package/dist/docx/export.d.ts.map +0 -1
  76. package/dist/docx/export.js +0 -985
  77. package/dist/docx/export.js.map +0 -1
  78. package/dist/docx/import.d.ts +0 -65
  79. package/dist/docx/import.d.ts.map +0 -1
  80. package/dist/docx/import.js +0 -779
  81. package/dist/docx/import.js.map +0 -1
  82. package/dist/docx/index.d.ts.map +0 -1
  83. package/dist/docx/styles.d.ts +0 -68
  84. package/dist/docx/styles.d.ts.map +0 -1
  85. package/dist/docx/styles.js +0 -125
  86. package/dist/docx/styles.js.map +0 -1
  87. package/dist/epub/export.d.ts +0 -72
  88. package/dist/epub/export.d.ts.map +0 -1
  89. package/dist/epub/export.js +0 -698
  90. package/dist/epub/export.js.map +0 -1
  91. package/dist/epub/index.d.ts.map +0 -1
  92. package/dist/html/docsHtmlBundle.d.ts +0 -53
  93. package/dist/html/docsHtmlBundle.d.ts.map +0 -1
  94. package/dist/html/docsHtmlBundle.js +0 -299
  95. package/dist/html/docsHtmlBundle.js.map +0 -1
  96. package/dist/html/htmlTemplate.d.ts +0 -70
  97. package/dist/html/htmlTemplate.d.ts.map +0 -1
  98. package/dist/html/htmlTemplate.js +0 -282
  99. package/dist/html/htmlTemplate.js.map +0 -1
  100. package/dist/html/imageUtils.d.ts +0 -29
  101. package/dist/html/imageUtils.d.ts.map +0 -1
  102. package/dist/html/imageUtils.js +0 -63
  103. package/dist/html/imageUtils.js.map +0 -1
  104. package/dist/html/index.d.ts.map +0 -1
  105. package/dist/html/plainHtml.d.ts +0 -79
  106. package/dist/html/plainHtml.d.ts.map +0 -1
  107. package/dist/html/plainHtml.js +0 -614
  108. package/dist/html/plainHtml.js.map +0 -1
  109. package/dist/html/plainHtmlBundle.d.ts +0 -93
  110. package/dist/html/plainHtmlBundle.d.ts.map +0 -1
  111. package/dist/html/plainHtmlBundle.js +0 -357
  112. package/dist/html/plainHtmlBundle.js.map +0 -1
  113. package/dist/index.d.ts.map +0 -1
  114. package/dist/ooxml/index.d.ts.map +0 -1
  115. package/dist/ooxml/namespaces.d.ts +0 -77
  116. package/dist/ooxml/namespaces.d.ts.map +0 -1
  117. package/dist/ooxml/namespaces.js +0 -104
  118. package/dist/ooxml/namespaces.js.map +0 -1
  119. package/dist/ooxml/reader.d.ts +0 -52
  120. package/dist/ooxml/reader.d.ts.map +0 -1
  121. package/dist/ooxml/reader.js +0 -190
  122. package/dist/ooxml/reader.js.map +0 -1
  123. package/dist/ooxml/types.d.ts +0 -82
  124. package/dist/ooxml/types.d.ts.map +0 -1
  125. package/dist/ooxml/types.js +0 -9
  126. package/dist/ooxml/types.js.map +0 -1
  127. package/dist/ooxml/writer.d.ts +0 -71
  128. package/dist/ooxml/writer.d.ts.map +0 -1
  129. package/dist/ooxml/writer.js +0 -200
  130. package/dist/ooxml/writer.js.map +0 -1
  131. package/dist/ooxml/xmlUtils.d.ts +0 -76
  132. package/dist/ooxml/xmlUtils.d.ts.map +0 -1
  133. package/dist/ooxml/xmlUtils.js +0 -108
  134. package/dist/ooxml/xmlUtils.js.map +0 -1
  135. package/dist/pdf/export.d.ts +0 -56
  136. package/dist/pdf/export.d.ts.map +0 -1
  137. package/dist/pdf/export.js +0 -768
  138. package/dist/pdf/export.js.map +0 -1
  139. package/dist/pdf/import.d.ts +0 -94
  140. package/dist/pdf/import.d.ts.map +0 -1
  141. package/dist/pdf/import.js +0 -796
  142. package/dist/pdf/import.js.map +0 -1
  143. package/dist/pdf/index.d.ts.map +0 -1
  144. package/dist/pdf/styles.d.ts +0 -142
  145. package/dist/pdf/styles.d.ts.map +0 -1
  146. package/dist/pdf/styles.js +0 -145
  147. package/dist/pdf/styles.js.map +0 -1
  148. package/dist/pptx/export.d.ts +0 -75
  149. package/dist/pptx/export.d.ts.map +0 -1
  150. package/dist/pptx/export.js +0 -724
  151. package/dist/pptx/export.js.map +0 -1
  152. package/dist/pptx/index.d.ts.map +0 -1
  153. package/dist/pptx/styles.d.ts +0 -54
  154. package/dist/pptx/styles.d.ts.map +0 -1
  155. package/dist/pptx/styles.js +0 -73
  156. package/dist/pptx/styles.js.map +0 -1
  157. package/dist/pptx/templates.d.ts +0 -24
  158. package/dist/pptx/templates.d.ts.map +0 -1
  159. package/dist/pptx/templates.js +0 -158
  160. package/dist/pptx/templates.js.map +0 -1
  161. package/dist/xlsx/index.d.ts.map +0 -1
@@ -1,3 +1,5 @@
1
+ import { ContentContainer, MemoryContentContainer } from '@bendyline/squisq/storage';
2
+
1
3
  /**
2
4
  * Container ZIP serialization — convert between ContentContainer and ZIP archives.
3
5
  *
@@ -10,8 +12,7 @@
10
12
  * audio/narration.mp3
11
13
  * timing.json
12
14
  */
13
- import type { ContentContainer } from '@bendyline/squisq/storage';
14
- import { MemoryContentContainer } from '@bendyline/squisq/storage';
15
+
15
16
  /**
16
17
  * Serialize a ContentContainer to a ZIP blob.
17
18
  *
@@ -21,7 +22,7 @@ import { MemoryContentContainer } from '@bendyline/squisq/storage';
21
22
  * @param container — The container to serialize
22
23
  * @returns A Blob containing the ZIP archive
23
24
  */
24
- export declare function containerToZip(container: ContentContainer): Promise<Blob>;
25
+ declare function containerToZip(container: ContentContainer): Promise<Blob>;
25
26
  /**
26
27
  * Deserialize a ZIP archive into a MemoryContentContainer.
27
28
  *
@@ -32,5 +33,6 @@ export declare function containerToZip(container: ContentContainer): Promise<Blo
32
33
  * @param zipData — The ZIP archive as ArrayBuffer, Uint8Array, or Blob
33
34
  * @returns A MemoryContentContainer populated with the ZIP's contents
34
35
  */
35
- export declare function zipToContainer(zipData: ArrayBuffer | Uint8Array | Blob): Promise<MemoryContentContainer>;
36
- //# sourceMappingURL=index.d.ts.map
36
+ declare function zipToContainer(zipData: ArrayBuffer | Uint8Array | Blob): Promise<MemoryContentContainer>;
37
+
38
+ export { containerToZip, zipToContainer };
@@ -1,74 +1,43 @@
1
- /**
2
- * Container ZIP serialization — convert between ContentContainer and ZIP archives.
3
- *
4
- * Uses JSZip (already a formats dependency) to serialize a ContentContainer to
5
- * a ZIP blob and to deserialize a ZIP blob into a MemoryContentContainer.
6
- *
7
- * ZIP structure mirrors the container's flat path hierarchy directly:
8
- * index.md
9
- * images/hero.jpg
10
- * audio/narration.mp3
11
- * timing.json
12
- */
13
- import JSZip from 'jszip';
14
- import { MemoryContentContainer } from '@bendyline/squisq/storage';
15
- /**
16
- * Serialize a ContentContainer to a ZIP blob.
17
- *
18
- * All files in the container are written to the ZIP archive preserving
19
- * their path structure. The resulting blob can be saved as a .zip file.
20
- *
21
- * @param container — The container to serialize
22
- * @returns A Blob containing the ZIP archive
23
- */
24
- export async function containerToZip(container) {
25
- const zip = new JSZip();
26
- const entries = await container.listFiles();
27
- for (const entry of entries) {
28
- const data = await container.readFile(entry.path);
29
- if (data) {
30
- zip.file(entry.path, new Uint8Array(data));
31
- }
1
+ // src/container/index.ts
2
+ import JSZip from "jszip";
3
+ import { MemoryContentContainer } from "@bendyline/squisq/storage";
4
+ async function containerToZip(container) {
5
+ const zip = new JSZip();
6
+ const entries = await container.listFiles();
7
+ for (const entry of entries) {
8
+ const data = await container.readFile(entry.path);
9
+ if (data) {
10
+ zip.file(entry.path, new Uint8Array(data));
32
11
  }
33
- return zip.generateAsync({
34
- type: 'blob',
35
- compression: 'DEFLATE',
36
- compressionOptions: { level: 6 },
37
- });
12
+ }
13
+ return zip.generateAsync({
14
+ type: "blob",
15
+ compression: "DEFLATE",
16
+ compressionOptions: { level: 6 }
17
+ });
38
18
  }
39
- /**
40
- * Deserialize a ZIP archive into a MemoryContentContainer.
41
- *
42
- * Reads all files from the ZIP and writes them into a new MemoryContentContainer.
43
- * Directory entries are skipped. The resulting container can be used immediately
44
- * for rendering, editing, or saving to persistent storage.
45
- *
46
- * @param zipData — The ZIP archive as ArrayBuffer, Uint8Array, or Blob
47
- * @returns A MemoryContentContainer populated with the ZIP's contents
48
- */
49
- export async function zipToContainer(zipData) {
50
- const zip = await JSZip.loadAsync(zipData);
51
- const container = new MemoryContentContainer();
52
- const filePromises = [];
53
- zip.forEach((relativePath, zipEntry) => {
54
- // Skip directories
55
- if (zipEntry.dir)
56
- return;
57
- // Strip leading slash if present
58
- const entryPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;
59
- if (!entryPath)
60
- return;
61
- // Path-traversal protection: reject absolute paths, backslashes, and .. segments
62
- if (entryPath.startsWith('/') ||
63
- entryPath.includes('\\') ||
64
- entryPath.split('/').some((seg) => seg === '..')) {
65
- return;
66
- }
67
- filePromises.push(zipEntry.async('arraybuffer').then((data) => {
68
- return container.writeFile(entryPath, data);
69
- }));
70
- });
71
- await Promise.all(filePromises);
72
- return container;
19
+ async function zipToContainer(zipData) {
20
+ const zip = await JSZip.loadAsync(zipData);
21
+ const container = new MemoryContentContainer();
22
+ const filePromises = [];
23
+ zip.forEach((relativePath, zipEntry) => {
24
+ if (zipEntry.dir) return;
25
+ const entryPath = relativePath.startsWith("/") ? relativePath.slice(1) : relativePath;
26
+ if (!entryPath) return;
27
+ if (entryPath.startsWith("/") || entryPath.includes("\\") || entryPath.split("/").some((seg) => seg === "..")) {
28
+ return;
29
+ }
30
+ filePromises.push(
31
+ zipEntry.async("arraybuffer").then((data) => {
32
+ return container.writeFile(entryPath, data);
33
+ })
34
+ );
35
+ });
36
+ await Promise.all(filePromises);
37
+ return container;
73
38
  }
39
+ export {
40
+ containerToZip,
41
+ zipToContainer
42
+ };
74
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,SAA2B;IAC9D,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,CAAC;IAE5C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,EAAE,CAAC;YACT,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,aAAa,CAAC;QACvB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,SAAS;QACtB,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;KACjC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAwC;IAExC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAE/C,MAAM,YAAY,GAAoB,EAAE,CAAC;IAEzC,GAAG,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,EAAE;QACrC,mBAAmB;QACnB,IAAI,QAAQ,CAAC,GAAG;YAAE,OAAO;QAEzB,iCAAiC;QACjC,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QACtF,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,iFAAiF;QACjF,IACE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;YACzB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;YACxB,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,EAChD,CAAC;YACD,OAAO;QACT,CAAC;QAED,YAAY,CAAC,IAAI,CACf,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1C,OAAO,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"sources":["../../src/container/index.ts"],"sourcesContent":["/**\n * Container ZIP serialization — convert between ContentContainer and ZIP archives.\n *\n * Uses JSZip (already a formats dependency) to serialize a ContentContainer to\n * a ZIP blob and to deserialize a ZIP blob into a MemoryContentContainer.\n *\n * ZIP structure mirrors the container's flat path hierarchy directly:\n * index.md\n * images/hero.jpg\n * audio/narration.mp3\n * timing.json\n */\n\nimport JSZip from 'jszip';\nimport type { ContentContainer } from '@bendyline/squisq/storage';\nimport { MemoryContentContainer } from '@bendyline/squisq/storage';\n\n/**\n * Serialize a ContentContainer to a ZIP blob.\n *\n * All files in the container are written to the ZIP archive preserving\n * their path structure. The resulting blob can be saved as a .zip file.\n *\n * @param container — The container to serialize\n * @returns A Blob containing the ZIP archive\n */\nexport async function containerToZip(container: ContentContainer): Promise<Blob> {\n const zip = new JSZip();\n const entries = await container.listFiles();\n\n for (const entry of entries) {\n const data = await container.readFile(entry.path);\n if (data) {\n zip.file(entry.path, new Uint8Array(data));\n }\n }\n\n return zip.generateAsync({\n type: 'blob',\n compression: 'DEFLATE',\n compressionOptions: { level: 6 },\n });\n}\n\n/**\n * Deserialize a ZIP archive into a MemoryContentContainer.\n *\n * Reads all files from the ZIP and writes them into a new MemoryContentContainer.\n * Directory entries are skipped. The resulting container can be used immediately\n * for rendering, editing, or saving to persistent storage.\n *\n * @param zipData — The ZIP archive as ArrayBuffer, Uint8Array, or Blob\n * @returns A MemoryContentContainer populated with the ZIP's contents\n */\nexport async function zipToContainer(\n zipData: ArrayBuffer | Uint8Array | Blob,\n): Promise<MemoryContentContainer> {\n const zip = await JSZip.loadAsync(zipData);\n const container = new MemoryContentContainer();\n\n const filePromises: Promise<void>[] = [];\n\n zip.forEach((relativePath, zipEntry) => {\n // Skip directories\n if (zipEntry.dir) return;\n\n // Strip leading slash if present\n const entryPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;\n if (!entryPath) return;\n\n // Path-traversal protection: reject absolute paths, backslashes, and .. segments\n if (\n entryPath.startsWith('/') ||\n entryPath.includes('\\\\') ||\n entryPath.split('/').some((seg) => seg === '..')\n ) {\n return;\n }\n\n filePromises.push(\n zipEntry.async('arraybuffer').then((data) => {\n return container.writeFile(entryPath, data);\n }),\n );\n });\n\n await Promise.all(filePromises);\n return container;\n}\n"],"mappings":";AAaA,OAAO,WAAW;AAElB,SAAS,8BAA8B;AAWvC,eAAsB,eAAe,WAA4C;AAC/E,QAAM,MAAM,IAAI,MAAM;AACtB,QAAM,UAAU,MAAM,UAAU,UAAU;AAE1C,aAAW,SAAS,SAAS;AAC3B,UAAM,OAAO,MAAM,UAAU,SAAS,MAAM,IAAI;AAChD,QAAI,MAAM;AACR,UAAI,KAAK,MAAM,MAAM,IAAI,WAAW,IAAI,CAAC;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,IAAI,cAAc;AAAA,IACvB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB,EAAE,OAAO,EAAE;AAAA,EACjC,CAAC;AACH;AAYA,eAAsB,eACpB,SACiC;AACjC,QAAM,MAAM,MAAM,MAAM,UAAU,OAAO;AACzC,QAAM,YAAY,IAAI,uBAAuB;AAE7C,QAAM,eAAgC,CAAC;AAEvC,MAAI,QAAQ,CAAC,cAAc,aAAa;AAEtC,QAAI,SAAS,IAAK;AAGlB,UAAM,YAAY,aAAa,WAAW,GAAG,IAAI,aAAa,MAAM,CAAC,IAAI;AACzE,QAAI,CAAC,UAAW;AAGhB,QACE,UAAU,WAAW,GAAG,KACxB,UAAU,SAAS,IAAI,KACvB,UAAU,MAAM,GAAG,EAAE,KAAK,CAAC,QAAQ,QAAQ,IAAI,GAC/C;AACA;AAAA,IACF;AAEA,iBAAa;AAAA,MACX,SAAS,MAAM,aAAa,EAAE,KAAK,CAAC,SAAS;AAC3C,eAAO,UAAU,UAAU,WAAW,IAAI;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,IAAI,YAAY;AAC9B,SAAO;AACT;","names":[]}
@@ -1,23 +1,136 @@
1
+ import { Doc } from '@bendyline/squisq/schemas';
2
+ import { MarkdownDocument } from '@bendyline/squisq/markdown';
3
+ import { ContentContainer } from '@bendyline/squisq/storage';
4
+
1
5
  /**
2
- * @bendyline/squisq-formats DOCX Module
6
+ * DOCX Export
3
7
  *
4
- * Import and export squisq documents (MarkdownDocument / Doc)
5
- * to/from Microsoft Word .docx files (Office Open XML WordprocessingML).
8
+ * Converts a squisq MarkdownDocument (or Doc) into a .docx file
9
+ * by generating WordprocessingML XML and assembling the OOXML package.
6
10
  *
7
- * All operations run in the browser no server required.
11
+ * No third-party docx library all XML is generated directly using
12
+ * the shared ooxml/ infrastructure of this package.
8
13
  *
9
14
  * @example
10
15
  * ```ts
11
- * import {
12
- * markdownDocToDocx,
13
- * docToDocx,
14
- * docxToMarkdownDoc,
15
- * docxToDoc,
16
- * } from '@bendyline/squisq-formats/docx';
16
+ * import { parseMarkdown } from '@bendyline/squisq/markdown';
17
+ * import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
18
+ *
19
+ * const md = parseMarkdown('# Hello\n\nWorld **bold** text');
20
+ * const blob = await markdownDocToDocx(md);
21
+ * ```
22
+ */
23
+
24
+ /**
25
+ * Options for DOCX export.
26
+ */
27
+ interface DocxExportOptions {
28
+ /** Document title (appears in core properties) */
29
+ title?: string;
30
+ /** Document author */
31
+ author?: string;
32
+ /** Document description */
33
+ description?: string;
34
+ /** Default body font family. Default: "Calibri" */
35
+ defaultFont?: string;
36
+ /** Default body font size in points. Default: 11 */
37
+ defaultFontSize?: number;
38
+ /**
39
+ * Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
40
+ * When set, overrides fonts with the theme's typography and applies
41
+ * the theme's primary color to headings.
42
+ */
43
+ themeId?: string;
44
+ /**
45
+ * Pre-resolved image data keyed by image URL/path as it appears in the
46
+ * markdown source. When provided, images are embedded in the .docx file
47
+ * as binary parts instead of emitting placeholder text.
48
+ */
49
+ images?: Map<string, {
50
+ data: ArrayBuffer | Uint8Array;
51
+ contentType: string;
52
+ }>;
53
+ }
54
+ /**
55
+ * Convert a MarkdownDocument to a .docx Blob.
56
+ *
57
+ * @param doc - The parsed markdown document
58
+ * @param options - Export options
59
+ * @returns An ArrayBuffer containing the .docx file
60
+ */
61
+ declare function markdownDocToDocx(doc: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
62
+ /**
63
+ * Convert a squisq Doc to a .docx Blob.
64
+ *
65
+ * Convenience wrapper that converts Doc → MarkdownDocument → DOCX.
66
+ *
67
+ * @param doc - The squisq Doc
68
+ * @param options - Export options
69
+ * @returns An ArrayBuffer containing the .docx file
70
+ */
71
+ declare function docToDocx(doc: Doc, options?: DocxExportOptions): Promise<ArrayBuffer>;
72
+
73
+ /**
74
+ * DOCX Import
75
+ *
76
+ * Parses a .docx file (Office Open XML WordprocessingML) and converts
77
+ * its content into a squisq MarkdownDocument (or Doc).
78
+ *
79
+ * Uses JSZip + DOMParser to read the archive and parse the XML — no
80
+ * third-party docx library. Handles headings, paragraphs, inline
81
+ * formatting (bold, italic, strikethrough), hyperlinks, lists, tables,
82
+ * blockquotes, code blocks, images, and footnotes.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { docxToMarkdownDoc } from '@bendyline/squisq-formats/docx';
87
+ *
88
+ * const response = await fetch('document.docx');
89
+ * const data = await response.arrayBuffer();
90
+ * const doc = await docxToMarkdownDoc(data);
17
91
  * ```
18
92
  */
19
- export { markdownDocToDocx, docToDocx } from './export.js';
20
- export type { DocxExportOptions } from './export.js';
21
- export { docxToMarkdownDoc, docxToDoc, docxToContainer } from './import.js';
22
- export type { DocxImportOptions } from './import.js';
23
- //# sourceMappingURL=index.d.ts.map
93
+
94
+ /**
95
+ * Options for DOCX import.
96
+ */
97
+ interface DocxImportOptions {
98
+ /**
99
+ * Whether to extract embedded images as base64 data URIs.
100
+ * When false, images are represented as `[Image]` placeholders.
101
+ * Default: false
102
+ */
103
+ extractImages?: boolean;
104
+ }
105
+ /**
106
+ * Convert a .docx file to a MarkdownDocument.
107
+ *
108
+ * @param data - The raw .docx file as ArrayBuffer or Blob
109
+ * @param options - Import options
110
+ * @returns A MarkdownDocument representing the document content
111
+ */
112
+ declare function docxToMarkdownDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<MarkdownDocument>;
113
+ /**
114
+ * Convert a .docx file to a squisq Doc.
115
+ *
116
+ * Convenience wrapper: DOCX → MarkdownDocument → Doc.
117
+ *
118
+ * @param data - The raw .docx file as ArrayBuffer or Blob
119
+ * @param options - Import options
120
+ * @returns A squisq Doc
121
+ */
122
+ declare function docxToDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<Doc>;
123
+ /**
124
+ * Convert a .docx file to a ContentContainer with markdown + extracted images.
125
+ *
126
+ * The container will contain:
127
+ * - The primary markdown document (index.md)
128
+ * - Any embedded images under images/ (e.g., images/image1.png)
129
+ *
130
+ * @param data - The raw .docx file as ArrayBuffer or Blob
131
+ * @param options - Import options
132
+ * @returns A ContentContainer with the document and its media
133
+ */
134
+ declare function docxToContainer(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<ContentContainer>;
135
+
136
+ export { type DocxExportOptions, type DocxImportOptions, docToDocx, docxToContainer, docxToDoc, docxToMarkdownDoc, markdownDocToDocx };
@@ -1,23 +1,18 @@
1
- /**
2
- * @bendyline/squisq-formats DOCX Module
3
- *
4
- * Import and export squisq documents (MarkdownDocument / Doc)
5
- * to/from Microsoft Word .docx files (Office Open XML WordprocessingML).
6
- *
7
- * All operations run in the browser — no server required.
8
- *
9
- * @example
10
- * ```ts
11
- * import {
12
- * markdownDocToDocx,
13
- * docToDocx,
14
- * docxToMarkdownDoc,
15
- * docxToDoc,
16
- * } from '@bendyline/squisq-formats/docx';
17
- * ```
18
- */
19
- // Export
20
- export { markdownDocToDocx, docToDocx } from './export.js';
21
- // Import
22
- export { docxToMarkdownDoc, docxToDoc, docxToContainer } from './import.js';
1
+ import {
2
+ docToDocx,
3
+ docxToContainer,
4
+ docxToDoc,
5
+ docxToMarkdownDoc,
6
+ markdownDocToDocx
7
+ } from "../chunk-UDS45KUJ.js";
8
+ import "../chunk-YN5HFCEW.js";
9
+ import "../chunk-7DEUGIOO.js";
10
+ import "../chunk-U4MRIFKL.js";
11
+ export {
12
+ docToDocx,
13
+ docxToContainer,
14
+ docxToDoc,
15
+ docxToMarkdownDoc,
16
+ markdownDocToDocx
17
+ };
23
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,SAAS;AACT,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG3D,SAAS;AACT,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,20 +1,75 @@
1
+ import { AudioSegment, Doc } from '@bendyline/squisq/schemas';
2
+ import { MarkdownDocument } from '@bendyline/squisq/markdown';
3
+
1
4
  /**
2
- * @bendyline/squisq-formats EPUB Module
5
+ * EPUB 3 Export
3
6
  *
4
- * Export squisq documents (MarkdownDocument / Doc) to EPUB 3 e-book files.
7
+ * Converts a MarkdownDocument (or Doc) to an EPUB 3 file (.epub).
5
8
  *
6
- * Content is split into chapters at H1/H2 heading boundaries. Images
7
- * referenced in the markdown are embedded in the archive when provided
8
- * via the `images` option.
9
+ * An EPUB is a ZIP archive containing XHTML chapter files, images,
10
+ * a package manifest (content.opf), and a navigation document (toc.xhtml).
11
+ * Content is split into chapters at H1/H2 heading boundaries.
12
+ *
13
+ * Uses JSZip for packaging (already a dependency), escapeXml from the
14
+ * OOXML utils, and image utilities from the HTML exporter.
9
15
  *
10
16
  * @example
11
17
  * ```ts
12
- * import { markdownDocToEpub, docToEpub } from '@bendyline/squisq-formats/epub';
18
+ * import { markdownDocToEpub } from '@bendyline/squisq-formats/epub';
13
19
  *
14
- * const epub = await markdownDocToEpub(markdownDoc, { title: 'My Book' });
15
- * const epub2 = await docToEpub(doc, { author: 'Jane Doe' });
20
+ * const epub = await markdownDocToEpub(markdownDoc, {
21
+ * title: 'My Book',
22
+ * author: 'Jane Doe',
23
+ * });
16
24
  * ```
17
25
  */
18
- export { markdownDocToEpub, docToEpub } from './export.js';
19
- export type { EpubExportOptions } from './export.js';
20
- //# sourceMappingURL=index.d.ts.map
26
+
27
+ interface EpubExportOptions {
28
+ /** Book title (default: 'Untitled') */
29
+ title?: string;
30
+ /** Author name */
31
+ author?: string;
32
+ /** Book description / summary */
33
+ description?: string;
34
+ /** BCP-47 language code (default: 'en') */
35
+ language?: string;
36
+ /** Publisher name */
37
+ publisher?: string;
38
+ /** Squisq theme ID for CSS styling */
39
+ themeId?: string;
40
+ /** Pre-resolved image data keyed by relative path as it appears in the markdown */
41
+ images?: Map<string, ArrayBuffer>;
42
+ /** Cover image data (JPEG or PNG) */
43
+ coverImage?: ArrayBuffer;
44
+ /**
45
+ * Audio narration data keyed by segment src/name.
46
+ * When provided alongside audioSegments, EPUB 3 Media Overlays (SMIL)
47
+ * are generated for synchronized audio playback.
48
+ */
49
+ audio?: Map<string, ArrayBuffer>;
50
+ /**
51
+ * Audio segment metadata (from Doc.audio.segments).
52
+ * Required together with `audio` to generate Media Overlays.
53
+ * Each segment's duration and startTime are used to build SMIL timing.
54
+ */
55
+ audioSegments?: AudioSegment[];
56
+ /** Total document duration in seconds (used for Media Overlay metadata) */
57
+ totalDuration?: number;
58
+ }
59
+ /**
60
+ * Convert a MarkdownDocument to an EPUB 3 file.
61
+ *
62
+ * Chapters are split at H1/H2 heading boundaries. All referenced images
63
+ * (provided via `options.images`) are embedded in the archive.
64
+ */
65
+ declare function markdownDocToEpub(doc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
66
+ /**
67
+ * Convert a squisq Doc to an EPUB 3 file.
68
+ *
69
+ * Convenience wrapper: Doc → MarkdownDocument → EPUB.
70
+ * When the Doc has audio segments and `options.audio` is provided,
71
+ * EPUB 3 Media Overlays are generated for narrated playback.
72
+ */
73
+ declare function docToEpub(doc: Doc, options?: EpubExportOptions): Promise<ArrayBuffer>;
74
+
75
+ export { type EpubExportOptions, docToEpub, markdownDocToEpub };
@@ -1,19 +1,11 @@
1
- /**
2
- * @bendyline/squisq-formats EPUB Module
3
- *
4
- * Export squisq documents (MarkdownDocument / Doc) to EPUB 3 e-book files.
5
- *
6
- * Content is split into chapters at H1/H2 heading boundaries. Images
7
- * referenced in the markdown are embedded in the archive when provided
8
- * via the `images` option.
9
- *
10
- * @example
11
- * ```ts
12
- * import { markdownDocToEpub, docToEpub } from '@bendyline/squisq-formats/epub';
13
- *
14
- * const epub = await markdownDocToEpub(markdownDoc, { title: 'My Book' });
15
- * const epub2 = await docToEpub(doc, { author: 'Jane Doe' });
16
- * ```
17
- */
18
- export { markdownDocToEpub, docToEpub } from './export.js';
1
+ import {
2
+ docToEpub,
3
+ markdownDocToEpub
4
+ } from "../chunk-ERZ627GR.js";
5
+ import "../chunk-U4MRIFKL.js";
6
+ import "../chunk-A3FHLTY5.js";
7
+ export {
8
+ docToEpub,
9
+ markdownDocToEpub
10
+ };
19
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/epub/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}