@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.
- package/dist/container/index.d.ts +7 -5
- package/dist/container/index.js +39 -70
- package/dist/container/index.js.map +1 -1
- package/dist/docx/index.d.ts +128 -15
- package/dist/docx/index.js +17 -22
- package/dist/docx/index.js.map +1 -1
- package/dist/epub/index.d.ts +66 -11
- package/dist/epub/index.js +10 -18
- package/dist/epub/index.js.map +1 -1
- package/dist/html/index.d.ts +278 -15
- package/dist/html/index.js +26 -165
- package/dist/html/index.js.map +1 -1
- package/dist/index.d.ts +9 -38
- package/dist/index.js +62 -37
- package/dist/index.js.map +1 -1
- package/dist/ooxml/index.d.ts +353 -14
- package/dist/ooxml/index.js +116 -22
- package/dist/ooxml/index.js.map +1 -1
- package/dist/pdf/index.d.ts +143 -17
- package/dist/pdf/index.js +16 -25
- package/dist/pdf/index.js.map +1 -1
- package/dist/pptx/index.d.ts +83 -8
- package/dist/pptx/index.js +14 -34
- package/dist/pptx/index.js.map +1 -1
- package/dist/xlsx/index.d.ts +12 -9
- package/dist/xlsx/index.js +12 -44
- package/dist/xlsx/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/container.test.d.ts +0 -8
- package/dist/__tests__/container.test.d.ts.map +0 -1
- package/dist/__tests__/container.test.js +0 -147
- package/dist/__tests__/container.test.js.map +0 -1
- package/dist/__tests__/docxExport.test.d.ts +0 -8
- package/dist/__tests__/docxExport.test.d.ts.map +0 -1
- package/dist/__tests__/docxExport.test.js +0 -383
- package/dist/__tests__/docxExport.test.js.map +0 -1
- package/dist/__tests__/docxImport.test.d.ts +0 -8
- package/dist/__tests__/docxImport.test.d.ts.map +0 -1
- package/dist/__tests__/docxImport.test.js +0 -309
- package/dist/__tests__/docxImport.test.js.map +0 -1
- package/dist/__tests__/epub.test.d.ts +0 -8
- package/dist/__tests__/epub.test.d.ts.map +0 -1
- package/dist/__tests__/epub.test.js +0 -472
- package/dist/__tests__/epub.test.js.map +0 -1
- package/dist/__tests__/html.test.d.ts +0 -8
- package/dist/__tests__/html.test.d.ts.map +0 -1
- package/dist/__tests__/html.test.js +0 -317
- package/dist/__tests__/html.test.js.map +0 -1
- package/dist/__tests__/ooxml.test.d.ts +0 -5
- package/dist/__tests__/ooxml.test.d.ts.map +0 -1
- package/dist/__tests__/ooxml.test.js +0 -152
- package/dist/__tests__/ooxml.test.js.map +0 -1
- package/dist/__tests__/pdfExport.test.d.ts +0 -8
- package/dist/__tests__/pdfExport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfExport.test.js +0 -275
- package/dist/__tests__/pdfExport.test.js.map +0 -1
- package/dist/__tests__/pdfImport.test.d.ts +0 -11
- package/dist/__tests__/pdfImport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfImport.test.js +0 -254
- package/dist/__tests__/pdfImport.test.js.map +0 -1
- package/dist/__tests__/plainHtml.test.d.ts +0 -5
- package/dist/__tests__/plainHtml.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtml.test.js +0 -327
- package/dist/__tests__/plainHtml.test.js.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.d.ts +0 -11
- package/dist/__tests__/plainHtmlBundle.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.js +0 -210
- package/dist/__tests__/plainHtmlBundle.test.js.map +0 -1
- package/dist/__tests__/roundTrip.test.d.ts +0 -7
- package/dist/__tests__/roundTrip.test.d.ts.map +0 -1
- package/dist/__tests__/roundTrip.test.js +0 -173
- package/dist/__tests__/roundTrip.test.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/docx/export.d.ts +0 -69
- package/dist/docx/export.d.ts.map +0 -1
- package/dist/docx/export.js +0 -985
- package/dist/docx/export.js.map +0 -1
- package/dist/docx/import.d.ts +0 -65
- package/dist/docx/import.d.ts.map +0 -1
- package/dist/docx/import.js +0 -779
- package/dist/docx/import.js.map +0 -1
- package/dist/docx/index.d.ts.map +0 -1
- package/dist/docx/styles.d.ts +0 -68
- package/dist/docx/styles.d.ts.map +0 -1
- package/dist/docx/styles.js +0 -125
- package/dist/docx/styles.js.map +0 -1
- package/dist/epub/export.d.ts +0 -72
- package/dist/epub/export.d.ts.map +0 -1
- package/dist/epub/export.js +0 -698
- package/dist/epub/export.js.map +0 -1
- package/dist/epub/index.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.d.ts +0 -53
- package/dist/html/docsHtmlBundle.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.js +0 -299
- package/dist/html/docsHtmlBundle.js.map +0 -1
- package/dist/html/htmlTemplate.d.ts +0 -70
- package/dist/html/htmlTemplate.d.ts.map +0 -1
- package/dist/html/htmlTemplate.js +0 -282
- package/dist/html/htmlTemplate.js.map +0 -1
- package/dist/html/imageUtils.d.ts +0 -29
- package/dist/html/imageUtils.d.ts.map +0 -1
- package/dist/html/imageUtils.js +0 -63
- package/dist/html/imageUtils.js.map +0 -1
- package/dist/html/index.d.ts.map +0 -1
- package/dist/html/plainHtml.d.ts +0 -79
- package/dist/html/plainHtml.d.ts.map +0 -1
- package/dist/html/plainHtml.js +0 -614
- package/dist/html/plainHtml.js.map +0 -1
- package/dist/html/plainHtmlBundle.d.ts +0 -93
- package/dist/html/plainHtmlBundle.d.ts.map +0 -1
- package/dist/html/plainHtmlBundle.js +0 -357
- package/dist/html/plainHtmlBundle.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/ooxml/index.d.ts.map +0 -1
- package/dist/ooxml/namespaces.d.ts +0 -77
- package/dist/ooxml/namespaces.d.ts.map +0 -1
- package/dist/ooxml/namespaces.js +0 -104
- package/dist/ooxml/namespaces.js.map +0 -1
- package/dist/ooxml/reader.d.ts +0 -52
- package/dist/ooxml/reader.d.ts.map +0 -1
- package/dist/ooxml/reader.js +0 -190
- package/dist/ooxml/reader.js.map +0 -1
- package/dist/ooxml/types.d.ts +0 -82
- package/dist/ooxml/types.d.ts.map +0 -1
- package/dist/ooxml/types.js +0 -9
- package/dist/ooxml/types.js.map +0 -1
- package/dist/ooxml/writer.d.ts +0 -71
- package/dist/ooxml/writer.d.ts.map +0 -1
- package/dist/ooxml/writer.js +0 -200
- package/dist/ooxml/writer.js.map +0 -1
- package/dist/ooxml/xmlUtils.d.ts +0 -76
- package/dist/ooxml/xmlUtils.d.ts.map +0 -1
- package/dist/ooxml/xmlUtils.js +0 -108
- package/dist/ooxml/xmlUtils.js.map +0 -1
- package/dist/pdf/export.d.ts +0 -56
- package/dist/pdf/export.d.ts.map +0 -1
- package/dist/pdf/export.js +0 -768
- package/dist/pdf/export.js.map +0 -1
- package/dist/pdf/import.d.ts +0 -94
- package/dist/pdf/import.d.ts.map +0 -1
- package/dist/pdf/import.js +0 -796
- package/dist/pdf/import.js.map +0 -1
- package/dist/pdf/index.d.ts.map +0 -1
- package/dist/pdf/styles.d.ts +0 -142
- package/dist/pdf/styles.d.ts.map +0 -1
- package/dist/pdf/styles.js +0 -145
- package/dist/pdf/styles.js.map +0 -1
- package/dist/pptx/export.d.ts +0 -75
- package/dist/pptx/export.d.ts.map +0 -1
- package/dist/pptx/export.js +0 -724
- package/dist/pptx/export.js.map +0 -1
- package/dist/pptx/index.d.ts.map +0 -1
- package/dist/pptx/styles.d.ts +0 -54
- package/dist/pptx/styles.d.ts.map +0 -1
- package/dist/pptx/styles.js +0 -73
- package/dist/pptx/styles.js.map +0 -1
- package/dist/pptx/templates.d.ts +0 -24
- package/dist/pptx/templates.d.ts.map +0 -1
- package/dist/pptx/templates.js +0 -158
- package/dist/pptx/templates.js.map +0 -1
- package/dist/xlsx/index.d.ts.map +0 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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,13 +362,6 @@ export declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
|
|
|
92
362
|
* const url = URL.createObjectURL(blob);
|
|
93
363
|
* ```
|
|
94
364
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
export {
|
|
98
|
-
export { markdownDocToPlainHtml } from './plainHtml.js';
|
|
99
|
-
export type { PlainHtmlExportOptions } from './plainHtml.js';
|
|
100
|
-
export { markdownDocsToPlainHtmlBundle, collectLinkRefs } from './plainHtmlBundle.js';
|
|
101
|
-
export type { PlainHtmlBundleOptions } from './plainHtmlBundle.js';
|
|
102
|
-
export { markdownDocsToHtmlBundle } from './docsHtmlBundle.js';
|
|
103
|
-
export type { HtmlBundleOptions } from './docsHtmlBundle.js';
|
|
104
|
-
//# 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 };
|
package/dist/html/index.js
CHANGED
|
@@ -1,166 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
/**
|
|
35
|
-
* Normalize a doc-referenced path for use as a zip entry name. Strips
|
|
36
|
-
* leading slashes and rejects any path that tries to escape the archive
|
|
37
|
-
* root via `..` segments (a malicious or malformed doc shouldn't be able
|
|
38
|
-
* to write outside the zip when extracted). Backslashes are folded to
|
|
39
|
-
* forward slashes so Windows-authored paths still produce a consistent
|
|
40
|
-
* tree across extractors.
|
|
41
|
-
*/
|
|
42
|
-
function sanitizeZipPath(path) {
|
|
43
|
-
const normalized = path.replace(/\\/g, '/').replace(/^\/+/, '');
|
|
44
|
-
if (!normalized)
|
|
45
|
-
return null;
|
|
46
|
-
if (normalized.split('/').some((seg) => seg === '..'))
|
|
47
|
-
return null;
|
|
48
|
-
return normalized;
|
|
49
|
-
}
|
|
50
|
-
// ── Single HTML Export ─────────────────────────────────────────────
|
|
51
|
-
/**
|
|
52
|
-
* Export a Doc as a single, self-contained HTML file.
|
|
53
|
-
*
|
|
54
|
-
* The player JS is embedded inline, images are base64-encoded as data URIs,
|
|
55
|
-
* and playback uses a timer (no audio) for compact file size.
|
|
56
|
-
*
|
|
57
|
-
* @param doc - The Doc to export
|
|
58
|
-
* @param options - Export options (must include `playerScript`)
|
|
59
|
-
* @returns Complete HTML document as a string
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* const html = docToHtml(myDoc, {
|
|
64
|
-
* playerScript: PLAYER_BUNDLE,
|
|
65
|
-
* images: imageMap,
|
|
66
|
-
* title: 'My Document',
|
|
67
|
-
* mode: 'slideshow',
|
|
68
|
-
* });
|
|
69
|
-
* const blob = new Blob([html], { type: 'text/html' });
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export function docToHtml(doc, options) {
|
|
73
|
-
return generateInlineHtml(doc, options);
|
|
74
|
-
}
|
|
75
|
-
// ── ZIP Archive Export ─────────────────────────────────────────────
|
|
76
|
-
/**
|
|
77
|
-
* Export a Doc as a ZIP archive containing HTML, JS, images, and optionally audio.
|
|
78
|
-
*
|
|
79
|
-
* The archive structure:
|
|
80
|
-
* ```
|
|
81
|
-
* document.zip
|
|
82
|
-
* ├── index.html # HTML page referencing squisq-player.js
|
|
83
|
-
* ├── squisq-player.js # Standalone IIFE bundle
|
|
84
|
-
* ├── images/ # Extracted image files
|
|
85
|
-
* │ ├── hero.jpg
|
|
86
|
-
* │ └── ...
|
|
87
|
-
* └── audio/ # Optional audio segment files
|
|
88
|
-
* ├── intro.mp3
|
|
89
|
-
* └── ...
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @param doc - The Doc to export
|
|
93
|
-
* @param options - Export options (must include `playerScript`)
|
|
94
|
-
* @returns A Promise resolving to a ZIP Blob
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```ts
|
|
98
|
-
* const blob = await docToHtmlZip(myDoc, {
|
|
99
|
-
* playerScript: PLAYER_BUNDLE,
|
|
100
|
-
* images: imageMap,
|
|
101
|
-
* audio: audioMap,
|
|
102
|
-
* });
|
|
103
|
-
* // Trigger browser download
|
|
104
|
-
* const url = URL.createObjectURL(blob);
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export async function docToHtmlZip(doc, options) {
|
|
108
|
-
const { playerScript, images, audio, mode = 'slideshow', title, autoPlay } = options;
|
|
109
|
-
const zip = new JSZip();
|
|
110
|
-
// 1. Add player JS as a separate file
|
|
111
|
-
zip.file('squisq-player.js', playerScript);
|
|
112
|
-
// 2. Add images preserving their original relative paths.
|
|
113
|
-
//
|
|
114
|
-
// We used to flatten everything into `images/<basename>`, but that
|
|
115
|
-
// requires the player to rewrite every `<img src>` at render time using
|
|
116
|
-
// the path map — and the static (non-slideshow) renderer doesn't do
|
|
117
|
-
// that, so its emitted `<img>` tags 404'd against the renamed assets.
|
|
118
|
-
// Keeping the original layout means direct `src="folder/file.png"`
|
|
119
|
-
// references just work, and the exported zip mirrors how the source
|
|
120
|
-
// folder is organized (e.g. pandoc-style `notes_files/` sidecars).
|
|
121
|
-
const imagePathMap = {};
|
|
122
|
-
if (images) {
|
|
123
|
-
for (const [originalPath, buffer] of images.entries()) {
|
|
124
|
-
const zipPath = sanitizeZipPath(originalPath);
|
|
125
|
-
if (!zipPath)
|
|
126
|
-
continue;
|
|
127
|
-
zip.file(zipPath, buffer);
|
|
128
|
-
imagePathMap[originalPath] = zipPath;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// 3. Add audio to audio/ folder and build path mapping
|
|
132
|
-
const audioPathMap = {};
|
|
133
|
-
if (audio) {
|
|
134
|
-
for (const [segmentKey, buffer] of audio.entries()) {
|
|
135
|
-
const filename = extractFilename(segmentKey);
|
|
136
|
-
// Ensure .mp3 extension
|
|
137
|
-
const finalName = filename.includes('.') ? filename : `${filename}.mp3`;
|
|
138
|
-
const zipPath = `audio/${finalName}`;
|
|
139
|
-
zip.file(zipPath, buffer);
|
|
140
|
-
audioPathMap[segmentKey] = zipPath;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// 4. Generate HTML that references external files
|
|
144
|
-
const html = generateExternalHtml(doc, {
|
|
145
|
-
playerScriptPath: 'squisq-player.js',
|
|
146
|
-
imagePathMap: Object.keys(imagePathMap).length > 0 ? imagePathMap : undefined,
|
|
147
|
-
audioPathMap: Object.keys(audioPathMap).length > 0 ? audioPathMap : undefined,
|
|
148
|
-
mode,
|
|
149
|
-
title,
|
|
150
|
-
autoPlay,
|
|
151
|
-
});
|
|
152
|
-
zip.file('index.html', html);
|
|
153
|
-
// 5. Generate ZIP blob
|
|
154
|
-
return zip.generateAsync({
|
|
155
|
-
type: 'blob',
|
|
156
|
-
compression: 'DEFLATE',
|
|
157
|
-
compressionOptions: { level: 6 },
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// ── Re-exports ─────────────────────────────────────────────────────
|
|
161
|
-
export { collectImagePaths } from './htmlTemplate.js';
|
|
162
|
-
export { inferMimeType, arrayBufferToBase64DataUrl, extractFilename } from './imageUtils.js';
|
|
163
|
-
export { markdownDocToPlainHtml } from './plainHtml.js';
|
|
164
|
-
export { markdownDocsToPlainHtmlBundle, collectLinkRefs } from './plainHtmlBundle.js';
|
|
165
|
-
export { markdownDocsToHtmlBundle } from './docsHtmlBundle.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
|
+
};
|
|
166
27
|
//# sourceMappingURL=index.js.map
|
package/dist/html/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|