@bendyline/squisq-formats 1.2.3 → 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 (166) hide show
  1. package/dist/chunk-33YRFXZZ.js +1187 -0
  2. package/dist/chunk-33YRFXZZ.js.map +1 -0
  3. package/dist/{chunk-EUQQYBZZ.js → chunk-ERZ627GR.js} +4 -4
  4. package/dist/chunk-ERZ627GR.js.map +1 -0
  5. package/dist/{chunk-MEZF76JA.js → chunk-UDS45KUJ.js} +68 -25
  6. package/dist/chunk-UDS45KUJ.js.map +1 -0
  7. package/dist/{chunk-NGWHV77G.js → chunk-VN2KEOYB.js} +7 -6
  8. package/dist/chunk-VN2KEOYB.js.map +1 -0
  9. package/dist/container/index.d.ts +7 -5
  10. package/dist/container/index.js +39 -70
  11. package/dist/container/index.js.map +1 -1
  12. package/dist/docx/index.d.ts +128 -15
  13. package/dist/docx/index.js +17 -22
  14. package/dist/docx/index.js.map +1 -1
  15. package/dist/epub/index.d.ts +66 -11
  16. package/dist/epub/index.js +10 -18
  17. package/dist/epub/index.js.map +1 -1
  18. package/dist/html/index.d.ts +278 -9
  19. package/dist/html/index.js +26 -137
  20. package/dist/html/index.js.map +1 -1
  21. package/dist/index.d.ts +9 -38
  22. package/dist/index.js +62 -37
  23. package/dist/index.js.map +1 -1
  24. package/dist/ooxml/index.d.ts +353 -14
  25. package/dist/ooxml/index.js +116 -22
  26. package/dist/ooxml/index.js.map +1 -1
  27. package/dist/pdf/index.d.ts +143 -17
  28. package/dist/pdf/index.js +16 -25
  29. package/dist/pdf/index.js.map +1 -1
  30. package/dist/pptx/index.d.ts +83 -8
  31. package/dist/pptx/index.js +14 -34
  32. package/dist/pptx/index.js.map +1 -1
  33. package/dist/xlsx/index.d.ts +12 -9
  34. package/dist/xlsx/index.js +12 -44
  35. package/dist/xlsx/index.js.map +1 -1
  36. package/package.json +3 -2
  37. package/src/__tests__/html.test.ts +82 -4
  38. package/src/__tests__/pdfExport.test.ts +1 -1
  39. package/src/__tests__/plainHtml.test.ts +372 -0
  40. package/src/__tests__/plainHtmlBundle.test.ts +235 -0
  41. package/src/docx/export.ts +163 -22
  42. package/src/epub/export.ts +3 -3
  43. package/src/html/docsHtmlBundle.ts +369 -0
  44. package/src/html/htmlTemplate.ts +40 -0
  45. package/src/html/index.ts +32 -3
  46. package/src/html/plainHtml.ts +736 -0
  47. package/src/html/plainHtmlBundle.ts +419 -0
  48. package/src/pptx/export.ts +10 -9
  49. package/dist/__tests__/container.test.d.ts +0 -8
  50. package/dist/__tests__/container.test.d.ts.map +0 -1
  51. package/dist/__tests__/container.test.js +0 -147
  52. package/dist/__tests__/container.test.js.map +0 -1
  53. package/dist/__tests__/docxExport.test.d.ts +0 -8
  54. package/dist/__tests__/docxExport.test.d.ts.map +0 -1
  55. package/dist/__tests__/docxExport.test.js +0 -383
  56. package/dist/__tests__/docxExport.test.js.map +0 -1
  57. package/dist/__tests__/docxImport.test.d.ts +0 -8
  58. package/dist/__tests__/docxImport.test.d.ts.map +0 -1
  59. package/dist/__tests__/docxImport.test.js +0 -309
  60. package/dist/__tests__/docxImport.test.js.map +0 -1
  61. package/dist/__tests__/epub.test.d.ts +0 -8
  62. package/dist/__tests__/epub.test.d.ts.map +0 -1
  63. package/dist/__tests__/epub.test.js +0 -472
  64. package/dist/__tests__/epub.test.js.map +0 -1
  65. package/dist/__tests__/html.test.d.ts +0 -8
  66. package/dist/__tests__/html.test.d.ts.map +0 -1
  67. package/dist/__tests__/html.test.js +0 -243
  68. package/dist/__tests__/html.test.js.map +0 -1
  69. package/dist/__tests__/ooxml.test.d.ts +0 -5
  70. package/dist/__tests__/ooxml.test.d.ts.map +0 -1
  71. package/dist/__tests__/ooxml.test.js +0 -152
  72. package/dist/__tests__/ooxml.test.js.map +0 -1
  73. package/dist/__tests__/pdfExport.test.d.ts +0 -8
  74. package/dist/__tests__/pdfExport.test.d.ts.map +0 -1
  75. package/dist/__tests__/pdfExport.test.js +0 -275
  76. package/dist/__tests__/pdfExport.test.js.map +0 -1
  77. package/dist/__tests__/pdfImport.test.d.ts +0 -11
  78. package/dist/__tests__/pdfImport.test.d.ts.map +0 -1
  79. package/dist/__tests__/pdfImport.test.js +0 -254
  80. package/dist/__tests__/pdfImport.test.js.map +0 -1
  81. package/dist/__tests__/roundTrip.test.d.ts +0 -7
  82. package/dist/__tests__/roundTrip.test.d.ts.map +0 -1
  83. package/dist/__tests__/roundTrip.test.js +0 -173
  84. package/dist/__tests__/roundTrip.test.js.map +0 -1
  85. package/dist/chunk-EUQQYBZZ.js.map +0 -1
  86. package/dist/chunk-MEZF76JA.js.map +0 -1
  87. package/dist/chunk-NGWHV77G.js.map +0 -1
  88. package/dist/chunk-UM5V2XZG.js +0 -242
  89. package/dist/chunk-UM5V2XZG.js.map +0 -1
  90. package/dist/container/index.d.ts.map +0 -1
  91. package/dist/docx/export.d.ts +0 -69
  92. package/dist/docx/export.d.ts.map +0 -1
  93. package/dist/docx/export.js +0 -854
  94. package/dist/docx/export.js.map +0 -1
  95. package/dist/docx/import.d.ts +0 -65
  96. package/dist/docx/import.d.ts.map +0 -1
  97. package/dist/docx/import.js +0 -779
  98. package/dist/docx/import.js.map +0 -1
  99. package/dist/docx/index.d.ts.map +0 -1
  100. package/dist/docx/styles.d.ts +0 -68
  101. package/dist/docx/styles.d.ts.map +0 -1
  102. package/dist/docx/styles.js +0 -125
  103. package/dist/docx/styles.js.map +0 -1
  104. package/dist/epub/export.d.ts +0 -72
  105. package/dist/epub/export.d.ts.map +0 -1
  106. package/dist/epub/export.js +0 -698
  107. package/dist/epub/export.js.map +0 -1
  108. package/dist/epub/index.d.ts.map +0 -1
  109. package/dist/html/htmlTemplate.d.ts +0 -70
  110. package/dist/html/htmlTemplate.d.ts.map +0 -1
  111. package/dist/html/htmlTemplate.js +0 -239
  112. package/dist/html/htmlTemplate.js.map +0 -1
  113. package/dist/html/imageUtils.d.ts +0 -29
  114. package/dist/html/imageUtils.d.ts.map +0 -1
  115. package/dist/html/imageUtils.js +0 -63
  116. package/dist/html/imageUtils.js.map +0 -1
  117. package/dist/html/index.d.ts.map +0 -1
  118. package/dist/index.d.ts.map +0 -1
  119. package/dist/ooxml/index.d.ts.map +0 -1
  120. package/dist/ooxml/namespaces.d.ts +0 -77
  121. package/dist/ooxml/namespaces.d.ts.map +0 -1
  122. package/dist/ooxml/namespaces.js +0 -104
  123. package/dist/ooxml/namespaces.js.map +0 -1
  124. package/dist/ooxml/reader.d.ts +0 -52
  125. package/dist/ooxml/reader.d.ts.map +0 -1
  126. package/dist/ooxml/reader.js +0 -190
  127. package/dist/ooxml/reader.js.map +0 -1
  128. package/dist/ooxml/types.d.ts +0 -82
  129. package/dist/ooxml/types.d.ts.map +0 -1
  130. package/dist/ooxml/types.js +0 -9
  131. package/dist/ooxml/types.js.map +0 -1
  132. package/dist/ooxml/writer.d.ts +0 -71
  133. package/dist/ooxml/writer.d.ts.map +0 -1
  134. package/dist/ooxml/writer.js +0 -200
  135. package/dist/ooxml/writer.js.map +0 -1
  136. package/dist/ooxml/xmlUtils.d.ts +0 -76
  137. package/dist/ooxml/xmlUtils.d.ts.map +0 -1
  138. package/dist/ooxml/xmlUtils.js +0 -108
  139. package/dist/ooxml/xmlUtils.js.map +0 -1
  140. package/dist/pdf/export.d.ts +0 -56
  141. package/dist/pdf/export.d.ts.map +0 -1
  142. package/dist/pdf/export.js +0 -768
  143. package/dist/pdf/export.js.map +0 -1
  144. package/dist/pdf/import.d.ts +0 -94
  145. package/dist/pdf/import.d.ts.map +0 -1
  146. package/dist/pdf/import.js +0 -796
  147. package/dist/pdf/import.js.map +0 -1
  148. package/dist/pdf/index.d.ts.map +0 -1
  149. package/dist/pdf/styles.d.ts +0 -142
  150. package/dist/pdf/styles.d.ts.map +0 -1
  151. package/dist/pdf/styles.js +0 -145
  152. package/dist/pdf/styles.js.map +0 -1
  153. package/dist/pptx/export.d.ts +0 -75
  154. package/dist/pptx/export.d.ts.map +0 -1
  155. package/dist/pptx/export.js +0 -722
  156. package/dist/pptx/export.js.map +0 -1
  157. package/dist/pptx/index.d.ts.map +0 -1
  158. package/dist/pptx/styles.d.ts +0 -54
  159. package/dist/pptx/styles.d.ts.map +0 -1
  160. package/dist/pptx/styles.js +0 -73
  161. package/dist/pptx/styles.js.map +0 -1
  162. package/dist/pptx/templates.d.ts +0 -24
  163. package/dist/pptx/templates.d.ts.map +0 -1
  164. package/dist/pptx/templates.js +0 -158
  165. package/dist/pptx/templates.js.map +0 -1
  166. package/dist/xlsx/index.d.ts.map +0 -1
@@ -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":[]}
@@ -1,3 +1,275 @@
1
+ import { Doc, Theme } from '@bendyline/squisq/schemas';
2
+ import { MarkdownDocument } from '@bendyline/squisq/markdown';
3
+
4
+ /**
5
+ * HTML Template Generation for SquisqPlayer Exports
6
+ *
7
+ * Generates complete, self-contained HTML documents that load the SquisqPlayer
8
+ * IIFE bundle and render a Doc as either an interactive slideshow or a static
9
+ * scrollable document.
10
+ *
11
+ * Two variants:
12
+ * 1. **Inline** — All JS, CSS, and images are embedded in the HTML (single file).
13
+ * 2. **External** — JS is referenced via `<script src>`, images via relative paths.
14
+ */
15
+
16
+ interface HtmlExportOptions {
17
+ /** The IIFE player bundle source code (from @bendyline/squisq-react/standalone-source) */
18
+ playerScript: string;
19
+ /**
20
+ * Map of relative image paths (as they appear in the Doc) to binary image data.
21
+ * For inline HTML export, these are converted to base64 data URIs.
22
+ * For ZIP export, these are written as separate files.
23
+ */
24
+ images?: Map<string, ArrayBuffer>;
25
+ /**
26
+ * Map of audio segment identifiers to binary audio data.
27
+ * Keys should match the audio segment `name` or `url` fields in the Doc.
28
+ * Only used in ZIP exports — single HTML uses timer-based playback.
29
+ */
30
+ audio?: Map<string, ArrayBuffer>;
31
+ /** Rendering mode: 'slideshow' (interactive, default) or 'static' (scrollable) */
32
+ mode?: 'slideshow' | 'static';
33
+ /** HTML page title (default: 'Squisq Document') */
34
+ title?: string;
35
+ /** Auto-play slideshow on load (default: false) */
36
+ autoPlay?: boolean;
37
+ /**
38
+ * Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
39
+ * When set, the theme is assigned to the Doc before rendering,
40
+ * so the SquisqPlayer renders with that theme's colors and typography.
41
+ */
42
+ themeId?: string;
43
+ }
44
+ /**
45
+ * Collect all relative image paths referenced in a Doc's layers and template blocks.
46
+ * Returns a Set of unique relative paths that need to be resolved.
47
+ */
48
+ declare function collectImagePaths(doc: Doc): Set<string>;
49
+
50
+ /**
51
+ * Image Utilities for HTML Export
52
+ *
53
+ * Browser-compatible helpers for converting image data to base64 data URIs
54
+ * and inferring MIME types from filenames.
55
+ */
56
+ /**
57
+ * Infer a MIME type from a filename's extension.
58
+ * Returns 'application/octet-stream' for unknown types.
59
+ */
60
+ declare function inferMimeType(filename: string): string;
61
+ /**
62
+ * Convert an ArrayBuffer to a base64-encoded data URI string.
63
+ *
64
+ * @param buffer - The binary image data
65
+ * @param mimeType - MIME type (e.g., 'image/jpeg'). If not provided, defaults to
66
+ * 'application/octet-stream'.
67
+ * @returns A `data:` URI string
68
+ */
69
+ declare function arrayBufferToBase64DataUrl(buffer: ArrayBuffer, mimeType: string): string;
70
+ /**
71
+ * Extract the filename from a path or URL (strips directory and query).
72
+ *
73
+ * @example
74
+ * extractFilename('images/hero.jpg') // 'hero.jpg'
75
+ * extractFilename('https://example.com/photo.png?v=2') // 'photo.png'
76
+ */
77
+ declare function extractFilename(path: string): string;
78
+
79
+ /**
80
+ * Plain HTML Export — semantic, player-free
81
+ *
82
+ * Renders a MarkdownDocument to a self-contained HTML string. Unlike
83
+ * `docToHtml` (which bundles the SquisqPlayer IIFE and renders SVG block
84
+ * cards), this output is what a reader-mode tool would produce: semantic
85
+ * `<h1>`/`<p>`/`<ul>`/etc. with a small embedded stylesheet, no JS, no
86
+ * runtime path-rewriting. Drives both the "Page" preview tab in the
87
+ * editor and the plain-style branch of the export dialog so what users
88
+ * see live matches the file they download.
89
+ *
90
+ * Image URLs default to the markdown's own paths. Pass `images` to
91
+ * substitute a different value per source URL — typically pre-resolved
92
+ * blob URLs (live preview) or data URIs (single-file export).
93
+ */
94
+
95
+ interface PlainHtmlExportOptions {
96
+ /** Document title — populates `<title>` and is HTML-escaped. */
97
+ title?: string;
98
+ /**
99
+ * Substitution map for image `src` URLs. Keys are the URL exactly as
100
+ * it appears in the markdown source; values are the URL to emit in
101
+ * the rendered `<img src>`. URLs not present in the map fall through
102
+ * unchanged (so external `https://…` references still work).
103
+ */
104
+ images?: Map<string, string>;
105
+ /**
106
+ * Substitution map for anchor `href` URLs. Keys are the URL exactly
107
+ * as it appears in the markdown source (e.g. `'resume.md'`,
108
+ * `'resume.md#experience'`); values are the URL to emit. URLs not in
109
+ * the map pass through unchanged. Used by the recursive bundle
110
+ * exporter to rewrite `.md` references to `.html` so a static export
111
+ * of a linked document tree is internally browsable.
112
+ */
113
+ links?: Map<string, string>;
114
+ /**
115
+ * Optional Squisq theme. When provided, the rendered page uses the
116
+ * theme's colors and typography, and any Google-hosted fonts the
117
+ * theme references are loaded via a `<link>` to fonts.googleapis.com
118
+ * so the face renders correctly without host preloads.
119
+ *
120
+ * When omitted, the function falls back (in order) to {@link themeId}
121
+ * and then to `doc.frontmatter.themeId` — so an authored
122
+ * `themeId: warm-earth` in the doc's frontmatter styles the export
123
+ * automatically, without the caller having to wire theme resolution
124
+ * themselves.
125
+ */
126
+ theme?: Theme;
127
+ /**
128
+ * Optional theme id (e.g. `'warm-earth'`, `'gezellig'`). Convenient
129
+ * for hosts whose export dialog tracks themes by id — they can pass
130
+ * the id straight through instead of resolving to a `Theme` object.
131
+ * When both `theme` and `themeId` are provided, `theme` wins.
132
+ */
133
+ themeId?: string;
134
+ /**
135
+ * Optional FontAwesome CSS text to inline into the rendered page,
136
+ * replacing the default cross-origin `<link>` to cdnjs. Required for
137
+ * sandboxed iframe previews where tracking prevention or stricter
138
+ * origin policies can silently drop cross-origin font fetches —
139
+ * inlining keeps the icons resolvable purely from same-origin
140
+ * resources. Hosts typically gather this string by scraping
141
+ * `document.styleSheets` for `@font-face` rules whose family starts
142
+ * with `"Font Awesome"`. The CDN `<link>` is only emitted when this
143
+ * option is not provided.
144
+ */
145
+ iconsCss?: string;
146
+ }
147
+ /**
148
+ * Render a parsed markdown document as a complete, semantic HTML page.
149
+ *
150
+ * When `options.theme` is provided, the output adopts the theme's
151
+ * colors and typography. Google-hosted fonts referenced by the theme
152
+ * are loaded via a single `<link>` to fonts.googleapis.com so the page
153
+ * renders consistently when opened standalone.
154
+ */
155
+ declare function markdownDocToPlainHtml(doc: MarkdownDocument, options?: PlainHtmlExportOptions): string;
156
+
157
+ /**
158
+ * Recursive plain-HTML bundle export.
159
+ *
160
+ * `markdownDocsToPlainHtmlBundle` starts from a single entry markdown
161
+ * file, walks its relative `[…](other.md)` links, recursively pulls in
162
+ * any sibling/child documents (scope-limited to the entry doc's
163
+ * directory tree), renders every visited file via
164
+ * `markdownDocToPlainHtml`, rewrites cross-doc references from `.md`
165
+ * to `.html`, and ships everything as a single ZIP.
166
+ *
167
+ * The function is provider-agnostic — callers pass `readDocument` and
168
+ * `readBinary` callbacks that resolve relative paths against whatever
169
+ * storage they use (`FileSystemContentContainer`, `MemoryContent-
170
+ * Container`, in-memory map for tests, …). Failure to read any
171
+ * discovered file aborts the whole export with a thrown error.
172
+ */
173
+
174
+ interface PlainHtmlBundleOptions {
175
+ /** Entry document path relative to the container root (e.g. `'home.md'`). */
176
+ entryPath: string;
177
+ /** Reads a UTF-8 markdown file from the container. Returns null when absent. */
178
+ readDocument: (path: string) => Promise<string | null>;
179
+ /** Reads a binary asset (image) from the container. Returns null when absent. */
180
+ readBinary: (path: string) => Promise<ArrayBuffer | null>;
181
+ /** Optional document title for the entry. Others derive from filename. */
182
+ title?: string;
183
+ /** Optional theme applied uniformly to every page. Overrides {@link themeId}. */
184
+ theme?: Theme;
185
+ /**
186
+ * Optional theme id (e.g. `'warm-earth'`, `'gezellig'`). Resolved via
187
+ * `resolveTheme` and applied to every page. Convenient for callers
188
+ * that track themes by id (like the host export dialog) without
189
+ * having to resolve to a `Theme` object first. When both `theme` and
190
+ * `themeId` are supplied, `theme` wins.
191
+ */
192
+ themeId?: string;
193
+ /** Maximum recursion depth (default: unlimited; cycles always handled). */
194
+ maxDepth?: number;
195
+ /**
196
+ * Emit the entry doc as `index.html` (preserving its parent directory)
197
+ * instead of `<basename>.html`. Cross-doc links pointing at the entry
198
+ * also rewrite to `index.html`, so a sibling `resume.md → home.md`
199
+ * link doesn't 404 after the rename. Convenient for static-site
200
+ * deploys where the landing page must be named `index.html`.
201
+ * Default: false.
202
+ */
203
+ entryAsIndex?: boolean;
204
+ }
205
+ /**
206
+ * Render an entry markdown document and every reachable sibling/child
207
+ * `.md` document it links to, bundled as a single ZIP with plain-HTML
208
+ * pages, per-document asset folders, and cross-doc `<a href>`
209
+ * references rewritten from `.md` to `.html`.
210
+ */
211
+ declare function markdownDocsToPlainHtmlBundle(options: PlainHtmlBundleOptions): Promise<Blob>;
212
+ /**
213
+ * Collect every `<a>`-style link URL referenced in a document. Markdown
214
+ * `link` nodes plus any raw HTML `<a href>` tags. Returns the raw URLs
215
+ * as authored, so callers can use them as both the linkMap *key* and
216
+ * the basis for resolution.
217
+ */
218
+ declare function collectLinkRefs(doc: MarkdownDocument): Set<string>;
219
+
220
+ /**
221
+ * Recursive rendered-HTML bundle export.
222
+ *
223
+ * `markdownDocsToHtmlBundle` is the rendered-pipeline counterpart of
224
+ * `markdownDocsToPlainHtmlBundle`. Starting from a single entry markdown
225
+ * file, it walks every relative `[…](other.md)` link, builds a Doc for
226
+ * each visited page via `markdownToDoc`, rewrites cross-doc link URLs
227
+ * inside the Doc tree from `.md` → relative `.html`, then renders each
228
+ * Doc to a SquisqPlayer-backed HTML page sharing one `squisq-player.js`.
229
+ * Images preserve their authored relative paths so per-doc folders
230
+ * (`resume_files/hero.png`, etc.) sit beside the rendered HTML.
231
+ *
232
+ * The rewrite happens on the Doc, *before* JSON serialization, because
233
+ * the rendered HTML embeds the Doc as JSON and SquisqPlayer emits the
234
+ * `<a href>` at runtime — there is no post-render link rewrite hook in
235
+ * the player path.
236
+ */
237
+ interface HtmlBundleOptions {
238
+ /** Entry document path relative to the container root (e.g. `'home.md'`). */
239
+ entryPath: string;
240
+ /** Reads a UTF-8 markdown file from the container. Returns null when absent. */
241
+ readDocument: (path: string) => Promise<string | null>;
242
+ /** Reads a binary asset (image) from the container. Returns null when absent. */
243
+ readBinary: (path: string) => Promise<ArrayBuffer | null>;
244
+ /** SquisqPlayer IIFE bundle. Written once as `squisq-player.js` in the zip. */
245
+ playerScript: string;
246
+ /** Optional document title for the entry. Other pages derive from filename. */
247
+ title?: string;
248
+ /** Theme id applied uniformly to every page. */
249
+ themeId?: string;
250
+ /** Rendering mode for every page (default: 'static' — scrollable, link-friendly). */
251
+ mode?: 'slideshow' | 'static';
252
+ /** Maximum recursion depth (default: unlimited; cycles always handled). */
253
+ maxDepth?: number;
254
+ /**
255
+ * Emit the entry doc as `index.html` (preserving its parent directory)
256
+ * instead of `<basename>.html`. Cross-doc links pointing at the entry
257
+ * also rewrite to `index.html`, so a sibling `resume.md → home.md`
258
+ * link doesn't 404 after the rename. Convenient for static-site
259
+ * deploys where the landing page must be named `index.html`.
260
+ * Default: false.
261
+ */
262
+ entryAsIndex?: boolean;
263
+ }
264
+ /**
265
+ * Render an entry markdown document and every reachable sibling/child
266
+ * `.md` document it links to, bundled as a single ZIP with one rendered
267
+ * HTML page per doc, per-document asset folders, a shared
268
+ * `squisq-player.js`, and cross-doc `<a href>` references rewritten
269
+ * from `.md` to `.html` inside each Doc's serialized AST.
270
+ */
271
+ declare function markdownDocsToHtmlBundle(options: HtmlBundleOptions): Promise<Blob>;
272
+
1
273
  /**
2
274
  * HTML Export Module — @bendyline/squisq-formats/html
3
275
  *
@@ -28,10 +300,8 @@
28
300
  * const zipBlob = await docToHtmlZip(doc, { playerScript: PLAYER_BUNDLE, images, audio });
29
301
  * ```
30
302
  */
31
- import type { Doc } from '@bendyline/squisq/schemas';
32
- import { type HtmlExportOptions } from './htmlTemplate.js';
33
- export type { HtmlExportOptions };
34
- export interface HtmlZipExportOptions extends HtmlExportOptions {
303
+
304
+ interface HtmlZipExportOptions extends HtmlExportOptions {
35
305
  /**
36
306
  * Map of audio segment identifiers to binary audio data.
37
307
  * Keys should match the audio segment `name` or `url` fields in the Doc.
@@ -60,7 +330,7 @@ export interface HtmlZipExportOptions extends HtmlExportOptions {
60
330
  * const blob = new Blob([html], { type: 'text/html' });
61
331
  * ```
62
332
  */
63
- export declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
333
+ declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
64
334
  /**
65
335
  * Export a Doc as a ZIP archive containing HTML, JS, images, and optionally audio.
66
336
  *
@@ -92,7 +362,6 @@ export declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
92
362
  * const url = URL.createObjectURL(blob);
93
363
  * ```
94
364
  */
95
- export declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
96
- export { collectImagePaths } from './htmlTemplate.js';
97
- export { inferMimeType, arrayBufferToBase64DataUrl, extractFilename } from './imageUtils.js';
98
- //# sourceMappingURL=index.d.ts.map
365
+ declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
366
+
367
+ export { type HtmlBundleOptions, type HtmlExportOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, arrayBufferToBase64DataUrl, collectImagePaths, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, inferMimeType, markdownDocToPlainHtml, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
@@ -1,138 +1,27 @@
1
- /**
2
- * HTML Export Module — @bendyline/squisq-formats/html
3
- *
4
- * Exports squisq documents as self-contained HTML files or ZIP archives.
5
- *
6
- * Two export modes:
7
- *
8
- * 1. **Single HTML** (`docToHtml`) — Everything embedded in one file:
9
- * - SquisqPlayer IIFE bundle inlined in `<script>`
10
- * - Images base64-encoded as data URIs
11
- * - Timer-based playback (no audio — too large for inline)
12
- *
13
- * 2. **ZIP Archive** (`docToHtmlZip`) — Multi-file package:
14
- * - `index.html` referencing external `squisq-player.js`
15
- * - `squisq-player.js` — the IIFE bundle
16
- * - `images/` — extracted image files
17
- * - `audio/` — optional audio segment files (enables full playback)
18
- *
19
- * @example
20
- * ```ts
21
- * import { PLAYER_BUNDLE } from '@bendyline/squisq-react/standalone-source';
22
- * import { docToHtml, docToHtmlZip } from '@bendyline/squisq-formats/html';
23
- *
24
- * // Single HTML file
25
- * const html = docToHtml(doc, { playerScript: PLAYER_BUNDLE, images });
26
- *
27
- * // ZIP archive
28
- * const zipBlob = await docToHtmlZip(doc, { playerScript: PLAYER_BUNDLE, images, audio });
29
- * ```
30
- */
31
- import JSZip from 'jszip';
32
- import { generateInlineHtml, generateExternalHtml, } from './htmlTemplate.js';
33
- import { extractFilename } from './imageUtils.js';
34
- // ── Single HTML Export ─────────────────────────────────────────────
35
- /**
36
- * Export a Doc as a single, self-contained HTML file.
37
- *
38
- * The player JS is embedded inline, images are base64-encoded as data URIs,
39
- * and playback uses a timer (no audio) for compact file size.
40
- *
41
- * @param doc - The Doc to export
42
- * @param options - Export options (must include `playerScript`)
43
- * @returns Complete HTML document as a string
44
- *
45
- * @example
46
- * ```ts
47
- * const html = docToHtml(myDoc, {
48
- * playerScript: PLAYER_BUNDLE,
49
- * images: imageMap,
50
- * title: 'My Document',
51
- * mode: 'slideshow',
52
- * });
53
- * const blob = new Blob([html], { type: 'text/html' });
54
- * ```
55
- */
56
- export function docToHtml(doc, options) {
57
- return generateInlineHtml(doc, options);
58
- }
59
- // ── ZIP Archive Export ─────────────────────────────────────────────
60
- /**
61
- * Export a Doc as a ZIP archive containing HTML, JS, images, and optionally audio.
62
- *
63
- * The archive structure:
64
- * ```
65
- * document.zip
66
- * ├── index.html # HTML page referencing squisq-player.js
67
- * ├── squisq-player.js # Standalone IIFE bundle
68
- * ├── images/ # Extracted image files
69
- * │ ├── hero.jpg
70
- * │ └── ...
71
- * └── audio/ # Optional audio segment files
72
- * ├── intro.mp3
73
- * └── ...
74
- * ```
75
- *
76
- * @param doc - The Doc to export
77
- * @param options - Export options (must include `playerScript`)
78
- * @returns A Promise resolving to a ZIP Blob
79
- *
80
- * @example
81
- * ```ts
82
- * const blob = await docToHtmlZip(myDoc, {
83
- * playerScript: PLAYER_BUNDLE,
84
- * images: imageMap,
85
- * audio: audioMap,
86
- * });
87
- * // Trigger browser download
88
- * const url = URL.createObjectURL(blob);
89
- * ```
90
- */
91
- export async function docToHtmlZip(doc, options) {
92
- const { playerScript, images, audio, mode = 'slideshow', title, autoPlay } = options;
93
- const zip = new JSZip();
94
- // 1. Add player JS as a separate file
95
- zip.file('squisq-player.js', playerScript);
96
- // 2. Add images to images/ folder and build path mapping
97
- const imagePathMap = {};
98
- if (images) {
99
- for (const [originalPath, buffer] of images.entries()) {
100
- const filename = extractFilename(originalPath);
101
- const zipPath = `images/${filename}`;
102
- zip.file(zipPath, buffer);
103
- imagePathMap[originalPath] = zipPath;
104
- }
105
- }
106
- // 3. Add audio to audio/ folder and build path mapping
107
- const audioPathMap = {};
108
- if (audio) {
109
- for (const [segmentKey, buffer] of audio.entries()) {
110
- const filename = extractFilename(segmentKey);
111
- // Ensure .mp3 extension
112
- const finalName = filename.includes('.') ? filename : `${filename}.mp3`;
113
- const zipPath = `audio/${finalName}`;
114
- zip.file(zipPath, buffer);
115
- audioPathMap[segmentKey] = zipPath;
116
- }
117
- }
118
- // 4. Generate HTML that references external files
119
- const html = generateExternalHtml(doc, {
120
- playerScriptPath: 'squisq-player.js',
121
- imagePathMap: Object.keys(imagePathMap).length > 0 ? imagePathMap : undefined,
122
- audioPathMap: Object.keys(audioPathMap).length > 0 ? audioPathMap : undefined,
123
- mode,
124
- title,
125
- autoPlay,
126
- });
127
- zip.file('index.html', html);
128
- // 5. Generate ZIP blob
129
- return zip.generateAsync({
130
- type: 'blob',
131
- compression: 'DEFLATE',
132
- compressionOptions: { level: 6 },
133
- });
134
- }
135
- // ── Re-exports ─────────────────────────────────────────────────────
136
- export { collectImagePaths } from './htmlTemplate.js';
137
- export { inferMimeType, arrayBufferToBase64DataUrl, extractFilename } from './imageUtils.js';
1
+ import {
2
+ collectImagePaths,
3
+ collectLinkRefs,
4
+ docToHtml,
5
+ docToHtmlZip,
6
+ markdownDocToPlainHtml,
7
+ markdownDocsToHtmlBundle,
8
+ markdownDocsToPlainHtmlBundle
9
+ } from "../chunk-33YRFXZZ.js";
10
+ import {
11
+ arrayBufferToBase64DataUrl,
12
+ extractFilename,
13
+ inferMimeType
14
+ } from "../chunk-A3FHLTY5.js";
15
+ export {
16
+ arrayBufferToBase64DataUrl,
17
+ collectImagePaths,
18
+ collectLinkRefs,
19
+ docToHtml,
20
+ docToHtmlZip,
21
+ extractFilename,
22
+ inferMimeType,
23
+ markdownDocToPlainHtml,
24
+ markdownDocsToHtmlBundle,
25
+ markdownDocsToPlainHtmlBundle
26
+ };
138
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/html/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,38 +1,9 @@
1
- /**
2
- * @bendyline/squisq-formats
3
- *
4
- * Format converters for squisq documents. Converts between squisq's
5
- * MarkdownDocument / Doc and various file formats via Office Open XML.
6
- *
7
- * Supported formats:
8
- * - **DOCX** — Microsoft Word (import + export) ✅
9
- * - **PDF** — Portable Document Format (import + export) ✅
10
- * - **PPTX** — Microsoft PowerPoint (export ✅, import planned)
11
- * - **XLSX** — Microsoft Excel (planned)
12
- *
13
- * All converters run in the browser — no server or native binaries required.
14
- * The shared `ooxml/` subpath export provides reusable OOXML infrastructure.
15
- *
16
- * @example
17
- * ```ts
18
- * // Import from root
19
- * import { markdownDocToDocx, docxToMarkdownDoc } from '@bendyline/squisq-formats';
20
- *
21
- * // Or import from subpath
22
- * import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
23
- * import { createPackage } from '@bendyline/squisq-formats/ooxml';
24
- * ```
25
- */
26
- export { markdownDocToDocx, docToDocx, docxToMarkdownDoc, docxToDoc } from './docx/index.js';
27
- export type { DocxExportOptions, DocxImportOptions } from './docx/index.js';
28
- export { markdownDocToPptx, docToPptx, pptxToMarkdownDoc, pptxToDoc } from './pptx/index.js';
29
- export type { PptxExportOptions, PptxImportOptions } from './pptx/index.js';
30
- export { markdownDocToXlsx, docToXlsx, xlsxToMarkdownDoc, xlsxToDoc } from './xlsx/index.js';
31
- export type { XlsxExportOptions, XlsxImportOptions } from './xlsx/index.js';
32
- export { markdownDocToPdf, docToPdf, pdfToMarkdownDoc, pdfToDoc, configurePdfWorker, } from './pdf/index.js';
33
- export type { PdfExportOptions, PdfImportOptions } from './pdf/index.js';
34
- export { docToHtml, docToHtmlZip, collectImagePaths } from './html/index.js';
35
- export type { HtmlExportOptions, HtmlZipExportOptions } from './html/index.js';
36
- export { markdownDocToEpub, docToEpub } from './epub/index.js';
37
- export type { EpubExportOptions } from './epub/index.js';
38
- //# sourceMappingURL=index.d.ts.map
1
+ export { DocxExportOptions, DocxImportOptions, docToDocx, docxToDoc, docxToMarkdownDoc, markdownDocToDocx } from './docx/index.js';
2
+ export { PptxExportOptions, PptxImportOptions, docToPptx, markdownDocToPptx, pptxToDoc, pptxToMarkdownDoc } from './pptx/index.js';
3
+ export { XlsxExportOptions, XlsxImportOptions, docToXlsx, markdownDocToXlsx, xlsxToDoc, xlsxToMarkdownDoc } from './xlsx/index.js';
4
+ export { PdfExportOptions, PdfImportOptions, configurePdfWorker, docToPdf, markdownDocToPdf, pdfToDoc, pdfToMarkdownDoc } from './pdf/index.js';
5
+ export { HtmlExportOptions, HtmlZipExportOptions, collectImagePaths, docToHtml, docToHtmlZip } from './html/index.js';
6
+ export { EpubExportOptions, docToEpub, markdownDocToEpub } from './epub/index.js';
7
+ import '@bendyline/squisq/schemas';
8
+ import '@bendyline/squisq/markdown';
9
+ import '@bendyline/squisq/storage';
package/dist/index.js CHANGED
@@ -1,38 +1,63 @@
1
- /**
2
- * @bendyline/squisq-formats
3
- *
4
- * Format converters for squisq documents. Converts between squisq's
5
- * MarkdownDocument / Doc and various file formats via Office Open XML.
6
- *
7
- * Supported formats:
8
- * - **DOCX** — Microsoft Word (import + export) ✅
9
- * - **PDF** — Portable Document Format (import + export) ✅
10
- * - **PPTX** — Microsoft PowerPoint (export ✅, import planned)
11
- * - **XLSX** — Microsoft Excel (planned)
12
- *
13
- * All converters run in the browser — no server or native binaries required.
14
- * The shared `ooxml/` subpath export provides reusable OOXML infrastructure.
15
- *
16
- * @example
17
- * ```ts
18
- * // Import from root
19
- * import { markdownDocToDocx, docxToMarkdownDoc } from '@bendyline/squisq-formats';
20
- *
21
- * // Or import from subpath
22
- * import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
23
- * import { createPackage } from '@bendyline/squisq-formats/ooxml';
24
- * ```
25
- */
26
- // DOCX (fully implemented)
27
- export { markdownDocToDocx, docToDocx, docxToMarkdownDoc, docxToDoc } from './docx/index.js';
28
- // PPTX (export implemented, import stub)
29
- export { markdownDocToPptx, docToPptx, pptxToMarkdownDoc, pptxToDoc } from './pptx/index.js';
30
- // XLSX (stub)
31
- export { markdownDocToXlsx, docToXlsx, xlsxToMarkdownDoc, xlsxToDoc } from './xlsx/index.js';
32
- // PDF (fully implemented)
33
- export { markdownDocToPdf, docToPdf, pdfToMarkdownDoc, pdfToDoc, configurePdfWorker, } from './pdf/index.js';
34
- // HTML (fully implemented)
35
- export { docToHtml, docToHtmlZip, collectImagePaths } from './html/index.js';
36
- // EPUB (export)
37
- export { markdownDocToEpub, docToEpub } from './epub/index.js';
1
+ import {
2
+ docToDocx,
3
+ docxToDoc,
4
+ docxToMarkdownDoc,
5
+ markdownDocToDocx
6
+ } from "./chunk-UDS45KUJ.js";
7
+ import {
8
+ docToPptx,
9
+ markdownDocToPptx,
10
+ pptxToDoc,
11
+ pptxToMarkdownDoc
12
+ } from "./chunk-VN2KEOYB.js";
13
+ import {
14
+ docToXlsx,
15
+ markdownDocToXlsx,
16
+ xlsxToDoc,
17
+ xlsxToMarkdownDoc
18
+ } from "./chunk-67KIJHV2.js";
19
+ import "./chunk-YN5HFCEW.js";
20
+ import "./chunk-7DEUGIOO.js";
21
+ import {
22
+ configurePdfWorker,
23
+ docToPdf,
24
+ markdownDocToPdf,
25
+ pdfToDoc,
26
+ pdfToMarkdownDoc
27
+ } from "./chunk-S3Y7H2BK.js";
28
+ import {
29
+ collectImagePaths,
30
+ docToHtml,
31
+ docToHtmlZip
32
+ } from "./chunk-33YRFXZZ.js";
33
+ import {
34
+ docToEpub,
35
+ markdownDocToEpub
36
+ } from "./chunk-ERZ627GR.js";
37
+ import "./chunk-U4MRIFKL.js";
38
+ import "./chunk-A3FHLTY5.js";
39
+ export {
40
+ collectImagePaths,
41
+ configurePdfWorker,
42
+ docToDocx,
43
+ docToEpub,
44
+ docToHtml,
45
+ docToHtmlZip,
46
+ docToPdf,
47
+ docToPptx,
48
+ docToXlsx,
49
+ docxToDoc,
50
+ docxToMarkdownDoc,
51
+ markdownDocToDocx,
52
+ markdownDocToEpub,
53
+ markdownDocToPdf,
54
+ markdownDocToPptx,
55
+ markdownDocToXlsx,
56
+ pdfToDoc,
57
+ pdfToMarkdownDoc,
58
+ pptxToDoc,
59
+ pptxToMarkdownDoc,
60
+ xlsxToDoc,
61
+ xlsxToMarkdownDoc
62
+ };
38
63
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,yCAAyC;AACzC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,0BAA0B;AAC1B,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}