@bendyline/squisq-formats 2.8.8 → 2.8.9

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 (35) hide show
  1. package/dist/chunk-4LIFEQKX.js +358 -0
  2. package/dist/{chunk-UXEANVBI.js → chunk-5HUHSLGA.js} +1 -84
  3. package/dist/{chunk-6ALSRHD7.js → chunk-6HUQFEP3.js} +61 -4
  4. package/dist/{chunk-BXWNU4T5.js → chunk-DTJQK7U7.js} +43 -0
  5. package/dist/{chunk-QU4EVC62.js → chunk-GFHUJ7L4.js} +1 -1
  6. package/dist/{chunk-TMOXUUTG.js → chunk-NQNIFIDP.js} +6 -4
  7. package/dist/{chunk-LK4KCVN6.js → chunk-SZ3OIY6G.js} +150 -28
  8. package/dist/{chunk-KROH7FNT.js → chunk-VKLJUHC2.js} +6 -4
  9. package/dist/{chunk-GDUZJ75A.js → chunk-WVDAFJFS.js} +59 -21
  10. package/dist/chunk-YRFBWYAD.js +128 -0
  11. package/dist/{chunk-SVYTUYZM.js → chunk-ZJERBWTB.js} +6 -4
  12. package/dist/data/index.d.ts +27 -5
  13. package/dist/data/index.js +6 -2
  14. package/dist/diagrams/index.d.ts +19 -8
  15. package/dist/diagrams/index.js +7 -242
  16. package/dist/docx/index.d.ts +1 -1
  17. package/dist/docx/index.js +3 -3
  18. package/dist/epub/index.d.ts +1 -1
  19. package/dist/epub/index.js +3 -3
  20. package/dist/fontAwesome-C6FRDYTY.js +14 -0
  21. package/dist/html/index.d.ts +85 -1
  22. package/dist/html/index.js +9 -4
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +10 -9
  25. package/dist/{materialize-G4WC5UG3.js → materialize-ICXNO4S4.js} +4 -1
  26. package/dist/outside-in/index.d.ts +12 -0
  27. package/dist/outside-in/index.js +2 -2
  28. package/dist/pdf/index.d.ts +1 -1
  29. package/dist/pdf/index.js +3 -3
  30. package/dist/plainHtmlIcons-KBSIJ5EN.js +62 -0
  31. package/dist/pptx/index.js +2 -2
  32. package/dist/readers-3P5A6A2A.js +17 -0
  33. package/dist/registry/index.js +1 -1
  34. package/package.json +2 -2
  35. /package/dist/{chunk-LBXBRFBZ.js → chunk-DDMPZZJF.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { DataSourceReader } from '@bendyline/squisq/doc';
1
+ import { DataSourceReader, DataSourceTable } from '@bendyline/squisq/doc';
2
2
  import { ContentContainer } from '@bendyline/squisq/storage';
3
3
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
4
4
 
@@ -31,12 +31,34 @@ declare function defaultDataReaders(): DataSourceReader[];
31
31
  * (its body link simply doesn't survive a tables-only export).
32
32
  */
33
33
 
34
+ /**
35
+ * Rows a data reference shows in a document or page, which cannot carry the
36
+ * file it points at; the reader follows the author's link for the rest.
37
+ */
38
+ declare const DATA_PREVIEW_ROWS = 100;
39
+ interface MaterializeDataReferencesOptions {
40
+ /**
41
+ * Embed at most this many data rows per reference — a block's own
42
+ * `previewRows` param wins — followed by a "Showing N of M rows" note when
43
+ * rows were left out. Default: every row.
44
+ */
45
+ maxRows?: number;
46
+ /**
47
+ * A caller-owned memo of reader results, keyed by file and read options,
48
+ * for a caller that materializes the same document repeatedly (a live
49
+ * preview). The caller clears it when the files may have changed.
50
+ */
51
+ tableCache?: Map<string, Promise<DataSourceTable>>;
52
+ }
34
53
  /**
35
54
  * Returns a copy of `markdownDoc` where every heading annotated with a
36
- * resolvable data `src` is followed by the full source table. The input
37
- * document is returned unchanged (same object) when nothing materialized.
55
+ * resolvable data `src` is followed by the source table (in full unless
56
+ * `options.maxRows` bounds it). A reference whose heading is already followed
57
+ * by a table keeps it — author data wins, as in `resolveDataReferences` — so
58
+ * materializing twice adds nothing. The input document is returned unchanged
59
+ * (same object) when nothing materialized.
38
60
  */
39
- declare function materializeDataReferences(markdownDoc: MarkdownDocument, container: ContentContainer | null | undefined, onWarning?: (message: string) => void): Promise<MarkdownDocument>;
61
+ declare function materializeDataReferences(markdownDoc: MarkdownDocument, container: ContentContainer | null | undefined, onWarning?: (message: string) => void, options?: MaterializeDataReferencesOptions): Promise<MarkdownDocument>;
40
62
 
41
63
  /**
42
64
  * Sidecar naming shared by the spill-capable importers (`xlsxToContainer`,
@@ -75,4 +97,4 @@ declare function sidecarReferenceDoc(plan: DataSidecarPlan): MarkdownDocument;
75
97
  /** {@link sidecarReferenceDoc} as serialized markdown source. */
76
98
  declare function sidecarReferenceMarkdown(plan: DataSidecarPlan): string;
77
99
 
78
- export { type DataSidecarPlan, csvDataReader, defaultDataReaders, docSlugForFileName, materializeDataReferences, parquetDataReader, planDataSidecar, sanitizeSourceFileName, sidecarReferenceDoc, sidecarReferenceMarkdown, xlsxDataReader };
100
+ export { DATA_PREVIEW_ROWS, type DataSidecarPlan, type MaterializeDataReferencesOptions, csvDataReader, defaultDataReaders, docSlugForFileName, materializeDataReferences, parquetDataReader, planDataSidecar, sanitizeSourceFileName, sidecarReferenceDoc, sidecarReferenceMarkdown, xlsxDataReader };
@@ -1,10 +1,13 @@
1
+ import {
2
+ DATA_PREVIEW_ROWS,
3
+ materializeDataReferences
4
+ } from "../chunk-YRFBWYAD.js";
1
5
  import {
2
6
  csvDataReader,
3
7
  defaultDataReaders,
4
- materializeDataReferences,
5
8
  parquetDataReader,
6
9
  xlsxDataReader
7
- } from "../chunk-UXEANVBI.js";
10
+ } from "../chunk-5HUHSLGA.js";
8
11
  import "../chunk-ATWVNF7D.js";
9
12
  import "../chunk-Q77KNJIN.js";
10
13
  import {
@@ -17,6 +20,7 @@ import {
17
20
  import "../chunk-S5PCVMKU.js";
18
21
  import "../chunk-7AWFHP5U.js";
19
22
  export {
23
+ DATA_PREVIEW_ROWS,
20
24
  csvDataReader,
21
25
  defaultDataReaders,
22
26
  docSlugForFileName,
@@ -21,25 +21,28 @@ import { MarkdownDocument, MarkdownCodeBlock } from '@bendyline/squisq/markdown'
21
21
  * and PPTX embed an island natively as vector art, so by default it is
22
22
  * left in place. Ask for it to picture islands for PDF, or to get the
23
23
  * `svg` map of PNG fallbacks the Office exporters place beside the vector.
24
+ * - chart heading blocks (`{[barChart]}`, `{[pieChart]}`, …) whose first
25
+ * table is chartable: the picture replaces the table, as the player shows
26
+ * the chart alone (the table stays beneath it with `showTable`).
24
27
  *
25
- * `docToPptx` keeps drawings, timelines and ASCII diagrams as native shapes;
26
- * for it, use the returned `mermaid` map as its `diagramImages` option.
28
+ * `docToPptx` keeps drawings, timelines, ASCII diagrams and charts as native
29
+ * shapes; for it, use the returned `mermaid` map as its `diagramImages` option.
27
30
  */
28
31
 
29
32
  /** What kind of diagram a picture is wanted for. */
30
- type ExportDiagramKind = 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container' | 'svg';
33
+ type ExportDiagramKind = 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container' | 'svg' | 'chart';
31
34
  /** Every kind, `svg` included — for exporters with no vector picture of their own (PDF). */
32
35
  declare const EXPORT_DIAGRAM_KINDS: readonly ExportDiagramKind[];
33
36
  interface ExportDiagram {
34
37
  readonly kind: ExportDiagramKind;
35
38
  /**
36
- * The diagram's own markdown: its fence, or for a container its heading
37
- * and every child heading and body it owns.
39
+ * The diagram's own markdown: its fence, for a container its heading and
40
+ * every child heading and body it owns, for a chart its heading and table.
38
41
  */
39
42
  readonly markdown: string;
40
- /** The fence content for fence kinds; '' for containers. */
43
+ /** The fence content for fence kinds; '' for containers and charts. */
41
44
  readonly source: string;
42
- /** The container's template (`drawing`, `layout`, `diagram`); '' for fences. */
45
+ /** The container's or chart's template (`drawing`, `barChart`, …); '' for fences. */
43
46
  readonly template: string;
44
47
  /** A text alternative for the picture. */
45
48
  readonly alt: string;
@@ -87,6 +90,14 @@ interface RasterizedDiagrams {
87
90
  declare function fenceDiagramKind(node: MarkdownCodeBlock): ExportDiagramKind | null;
88
91
  /** Every diagram in `doc`, in document order. */
89
92
  declare function findDiagrams(doc: MarkdownDocument): ExportDiagram[];
93
+ /**
94
+ * A renderer that remembers what it drew, for a host that renders the same
95
+ * document again and again — a live preview, or a file regenerated on every
96
+ * save — so each pass redraws only the diagrams that changed. A picture is
97
+ * keyed by the diagram itself; the least recently used beyond `limit` are
98
+ * forgotten, and a failure is never remembered.
99
+ */
100
+ declare function cachingDiagramRasterizer(render: DiagramRasterizer, limit?: number): DiagramRasterizer;
90
101
  /**
91
102
  * Picture every diagram in `doc` with `render`, one at a time, and return
92
103
  * the document with each pictured diagram replaced by an image of it. A
@@ -94,4 +105,4 @@ declare function findDiagrams(doc: MarkdownDocument): ExportDiagram[];
94
105
  */
95
106
  declare function rasterizeDiagrams(doc: MarkdownDocument, render: DiagramRasterizer, options?: RasterizeDiagramsOptions): Promise<RasterizedDiagrams>;
96
107
 
97
- export { type DiagramPicture, type DiagramRasterizer, EXPORT_DIAGRAM_KINDS, type ExportDiagram, type ExportDiagramKind, type RasterizeDiagramsOptions, type RasterizedDiagrams, fenceDiagramKind, findDiagrams, rasterizeDiagrams };
108
+ export { type DiagramPicture, type DiagramRasterizer, EXPORT_DIAGRAM_KINDS, type ExportDiagram, type ExportDiagramKind, type RasterizeDiagramsOptions, type RasterizedDiagrams, cachingDiagramRasterizer, fenceDiagramKind, findDiagrams, rasterizeDiagrams };
@@ -1,248 +1,13 @@
1
- // src/diagrams/index.ts
2
1
  import {
3
- extractPlainText,
4
- isSvgIslandLang,
5
- parseSvgIsland,
6
- stringifyMarkdown
7
- } from "@bendyline/squisq/markdown";
8
- import {
9
- detectAsciiDiagram,
10
- detectAsciiTimeline,
11
- detectTree,
12
- isContainerTemplate,
13
- isEligibleAsciiFenceLang,
14
- isEligibleAsciiTimelineFenceLang,
15
- isEligibleTreeFenceLang,
16
- isExplicitDiagramLang,
17
- isExplicitTimelineLang,
18
- isExplicitTreeLang,
19
- resolveTemplateName
20
- } from "@bendyline/squisq/doc";
21
- var DEFAULT_KINDS = [
22
- "mermaid",
23
- "diagram",
24
- "timeline",
25
- "tree",
26
- "container"
27
- ];
28
- var EXPORT_DIAGRAM_KINDS = [...DEFAULT_KINDS, "svg"];
29
- var KIND_NAMES = {
30
- mermaid: "Diagram",
31
- diagram: "Diagram",
32
- timeline: "Timeline",
33
- tree: "Tree",
34
- container: "Diagram",
35
- svg: "Illustration"
36
- };
37
- function fenceDiagramKind(node) {
38
- const lang = node.lang ?? null;
39
- if ((lang ?? "").trim().toLowerCase() === "mermaid") return "mermaid";
40
- if (isSvgIslandLang(lang)) return parseSvgIsland(node.value).ok ? "svg" : null;
41
- if (isEligibleAsciiFenceLang(lang)) {
42
- const detection = detectAsciiDiagram(node.value, { explicit: isExplicitDiagramLang(lang) });
43
- if (detection.isDiagram) return "diagram";
44
- }
45
- if (isEligibleTreeFenceLang(lang)) {
46
- if (detectTree(node.value, { explicit: isExplicitTreeLang(lang) }).isTree) return "tree";
47
- }
48
- if (isEligibleAsciiTimelineFenceLang(lang)) {
49
- const detection = detectAsciiTimeline(node.value, { explicit: isExplicitTimelineLang(lang) });
50
- if (detection.isTimeline) return "timeline";
51
- }
52
- return null;
53
- }
54
- function containerTemplateOf(node) {
55
- if (node.type !== "heading") return null;
56
- const requested = node.templateAnnotation?.template;
57
- if (!requested || !isContainerTemplate(requested)) return null;
58
- return resolveTemplateName(requested);
59
- }
60
- function mermaidAlt(source) {
61
- const title = /^\s*accTitle\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
62
- const description = /^\s*accDescr\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
63
- return [title, description].filter(Boolean).join(". ");
64
- }
65
- function fenceAlt(kind, source) {
66
- if (kind === "mermaid") return mermaidAlt(source);
67
- if (kind === "svg") {
68
- const result = parseSvgIsland(source);
69
- return result.ok && result.island.title || "";
70
- }
71
- return "";
72
- }
73
- function fenceMarkdown(node) {
74
- return stringifyMarkdown({ type: "document", children: [node] }).trim();
75
- }
76
- function findInDocument(doc) {
77
- const found = [];
78
- const children = doc.children;
79
- const walk = (nodes) => {
80
- for (const node of nodes) {
81
- if (node.type === "code") {
82
- const fence = node;
83
- const kind = fenceDiagramKind(fence);
84
- if (kind) {
85
- found.push({
86
- fence,
87
- diagram: {
88
- kind,
89
- markdown: fenceMarkdown(fence),
90
- source: fence.value,
91
- template: "",
92
- alt: fenceAlt(kind, fence.value) || KIND_NAMES[kind]
93
- }
94
- });
95
- }
96
- continue;
97
- }
98
- const nested = node.children;
99
- if (Array.isArray(nested) && node.type !== "heading" && node.type !== "paragraph") {
100
- walk(nested);
101
- }
102
- }
103
- };
104
- for (let index = 0; index < children.length; index++) {
105
- const node = children[index];
106
- const template = containerTemplateOf(node);
107
- if (!template) {
108
- walk([node]);
109
- continue;
110
- }
111
- const depth = node.depth;
112
- let end = index + 1;
113
- while (end < children.length) {
114
- const next = children[end];
115
- if (next.type === "heading" && next.depth <= depth) break;
116
- end++;
117
- }
118
- const heading = extractPlainText(node).trim();
119
- found.push({
120
- containerIndex: index,
121
- containerEnd: end,
122
- diagram: {
123
- kind: "container",
124
- markdown: stringifyMarkdown({
125
- type: "document",
126
- children: children.slice(index, end)
127
- }).trim(),
128
- source: "",
129
- template,
130
- alt: heading || KIND_NAMES.container
131
- }
132
- });
133
- index = end - 1;
134
- }
135
- return found;
136
- }
137
- function imageUrls(nodes, into) {
138
- for (const node of nodes) {
139
- if (node.type === "image") into.add(node.url);
140
- const nested = node.children;
141
- if (Array.isArray(nested)) imageUrls(nested, into);
142
- }
143
- return into;
144
- }
145
- function findDiagrams(doc) {
146
- return findInDocument(doc).map((entry) => entry.diagram);
147
- }
148
- function imageParagraph(url, alt) {
149
- const image = { type: "image", url, alt, title: null };
150
- return { type: "paragraph", children: [image] };
151
- }
152
- function replaceFences(nodes, replacements) {
153
- let changed = false;
154
- const next = nodes.map((node) => {
155
- const replacement = replacements.get(node);
156
- if (replacement) {
157
- changed = true;
158
- return replacement;
159
- }
160
- const nested = node.children;
161
- if (Array.isArray(nested)) {
162
- const replaced = replaceFences(nested, replacements);
163
- if (replaced !== nested) {
164
- changed = true;
165
- return { ...node, children: replaced };
166
- }
167
- }
168
- return node;
169
- });
170
- return changed ? next : nodes;
171
- }
172
- async function rasterizeDiagrams(doc, render, options = {}) {
173
- const kinds = new Set(options.kinds ?? DEFAULT_KINDS);
174
- const prefix = options.urlPrefix ?? "diagram";
175
- const taken = imageUrls(doc.children, /* @__PURE__ */ new Set());
176
- let counter = 0;
177
- const nextUrl = () => {
178
- let url;
179
- do
180
- url = `${prefix}-${String(++counter)}.png`;
181
- while (taken.has(url));
182
- taken.add(url);
183
- return url;
184
- };
185
- const images = /* @__PURE__ */ new Map();
186
- const mermaid = /* @__PURE__ */ new Map();
187
- const svg = /* @__PURE__ */ new Map();
188
- const fenceReplacements = /* @__PURE__ */ new Map();
189
- const containerReplacements = [];
190
- for (const entry of findInDocument(doc)) {
191
- options.signal?.throwIfAborted();
192
- if (!kinds.has(entry.diagram.kind)) continue;
193
- let picture = null;
194
- try {
195
- picture = await render(entry.diagram);
196
- } catch (error) {
197
- options.onWarning?.(
198
- `A ${KIND_NAMES[entry.diagram.kind].toLowerCase()} could not be drawn and was kept as text: ${error instanceof Error ? error.message : String(error)}`
199
- );
200
- }
201
- if (!picture || picture.width <= 0 || picture.height <= 0) continue;
202
- const data = picture.data instanceof Uint8Array ? picture.data : new Uint8Array(picture.data);
203
- const url = nextUrl();
204
- images.set(url, {
205
- data,
206
- contentType: "image/png",
207
- width: picture.width,
208
- height: picture.height
209
- });
210
- if (entry.diagram.kind === "mermaid") mermaid.set(entry.diagram.source.trim(), picture);
211
- if (entry.diagram.kind === "svg") svg.set(entry.diagram.source.trim(), picture);
212
- const paragraph = imageParagraph(url, entry.diagram.alt);
213
- if (entry.fence) {
214
- fenceReplacements.set(entry.fence, paragraph);
215
- } else if (entry.containerIndex !== void 0 && entry.containerEnd !== void 0) {
216
- const heading = doc.children[entry.containerIndex];
217
- const { templateAnnotation: _template, ...plainHeading } = heading;
218
- containerReplacements.push({
219
- start: entry.containerIndex,
220
- end: entry.containerEnd,
221
- nodes: [plainHeading, paragraph]
222
- });
223
- }
224
- }
225
- let children = doc.children;
226
- if (containerReplacements.length > 0) {
227
- const rebuilt = [];
228
- let cursor = 0;
229
- for (const replacement of containerReplacements) {
230
- rebuilt.push(...children.slice(cursor, replacement.start), ...replacement.nodes);
231
- cursor = replacement.end;
232
- }
233
- rebuilt.push(...children.slice(cursor));
234
- children = rebuilt;
235
- }
236
- if (fenceReplacements.size > 0) children = replaceFences(children, fenceReplacements);
237
- return {
238
- markdownDoc: children === doc.children ? doc : { ...doc, children },
239
- images,
240
- mermaid,
241
- svg
242
- };
243
- }
2
+ EXPORT_DIAGRAM_KINDS,
3
+ cachingDiagramRasterizer,
4
+ fenceDiagramKind,
5
+ findDiagrams,
6
+ rasterizeDiagrams
7
+ } from "../chunk-4LIFEQKX.js";
244
8
  export {
245
9
  EXPORT_DIAGRAM_KINDS,
10
+ cachingDiagramRasterizer,
246
11
  fenceDiagramKind,
247
12
  findDiagrams,
248
13
  rasterizeDiagrams
@@ -84,7 +84,7 @@ interface DocxExportOptions {
84
84
  * @param options - Export options
85
85
  * @returns An ArrayBuffer containing the .docx file
86
86
  */
87
- declare function markdownDocToDocx(doc: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
87
+ declare function markdownDocToDocx(source: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
88
88
  /**
89
89
  * Convert a squisq Doc to a .docx Blob.
90
90
  *
@@ -4,7 +4,7 @@ import {
4
4
  docxToDoc,
5
5
  docxToMarkdownDoc,
6
6
  markdownDocToDocx
7
- } from "../chunk-KROH7FNT.js";
7
+ } from "../chunk-VKLJUHC2.js";
8
8
  import "../chunk-DHAK4PII.js";
9
9
  import "../chunk-VCZUXQUL.js";
10
10
  import "../chunk-BZ5SHMOY.js";
@@ -12,9 +12,9 @@ import "../chunk-ILCJ3WFD.js";
12
12
  import "../chunk-JU2RHXUB.js";
13
13
  import "../chunk-S5PCVMKU.js";
14
14
  import "../chunk-7AWFHP5U.js";
15
- import "../chunk-BXWNU4T5.js";
15
+ import "../chunk-DTJQK7U7.js";
16
16
  import "../chunk-IIQYS2YH.js";
17
- import "../chunk-LBXBRFBZ.js";
17
+ import "../chunk-DDMPZZJF.js";
18
18
  import "../chunk-JZR32FON.js";
19
19
  export {
20
20
  docToDocx,
@@ -66,7 +66,7 @@ interface EpubExportOptions {
66
66
  * Chapters are split at H1/H2 heading boundaries. All referenced images
67
67
  * (provided via `options.images`) are embedded in the archive.
68
68
  */
69
- declare function markdownDocToEpub(sourceDoc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
69
+ declare function markdownDocToEpub(authoredDoc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
70
70
  /**
71
71
  * Convert a squisq Doc to an EPUB 3 file.
72
72
  *
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  docToEpub,
3
3
  markdownDocToEpub
4
- } from "../chunk-SVYTUYZM.js";
4
+ } from "../chunk-ZJERBWTB.js";
5
5
  import "../chunk-WMIDXNGR.js";
6
6
  import "../chunk-VCZUXQUL.js";
7
7
  import "../chunk-BZ5SHMOY.js";
8
8
  import "../chunk-JU2RHXUB.js";
9
- import "../chunk-BXWNU4T5.js";
10
- import "../chunk-LBXBRFBZ.js";
9
+ import "../chunk-DTJQK7U7.js";
10
+ import "../chunk-DDMPZZJF.js";
11
11
  import "../chunk-JZR32FON.js";
12
12
  export {
13
13
  docToEpub,
@@ -0,0 +1,14 @@
1
+ import {
2
+ collectInlineIconFamilies,
3
+ fontAwesomeFace,
4
+ fontAwesomeFaces,
5
+ fontAwesomeGlyph,
6
+ obfuscateDocxFont
7
+ } from "./chunk-DDMPZZJF.js";
8
+ export {
9
+ collectInlineIconFamilies,
10
+ fontAwesomeFace,
11
+ fontAwesomeFaces,
12
+ fontAwesomeGlyph,
13
+ obfuscateDocxFont
14
+ };
@@ -2,6 +2,9 @@ import { Theme, ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
2
2
  import { H as HtmlExportOptions } from '../import-ipP4Ghp8.js';
3
3
  export { a as HtmlImportOptions, c as collectImagePaths, g as generateExternalHtml, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from '../import-ipP4Ghp8.js';
4
4
  import { HtmlPolicy, MarkdownDocument } from '@bendyline/squisq/markdown';
5
+ import { DataSourceTable } from '@bendyline/squisq/doc';
6
+ import { ContentContainer } from '@bendyline/squisq/storage';
7
+ import { DiagramRasterizer } from '../diagrams/index.js';
5
8
 
6
9
  /**
7
10
  * Image Utilities for HTML Export
@@ -128,6 +131,19 @@ interface PlainHtmlExportOptions {
128
131
  * inherit the sandbox, so the player would load broken), or print.
129
132
  */
130
133
  videoEmbeds?: 'player' | 'poster';
134
+ /**
135
+ * Inline icons as SVG, keyed `family:name` (`solid:star`) — the `icons` that
136
+ * `prepareMarkdownDocForPlainHtml` returns. An icon found here is drawn as
137
+ * an inline `<svg>` in the text color and needs no Font Awesome stylesheet;
138
+ * any other icon keeps its Font Awesome markup (see {@link iconsCss}).
139
+ */
140
+ icons?: ReadonlyMap<string, PlainHtmlIcon>;
141
+ }
142
+ /** One icon's outline: an SVG path in a `0 0 width height` box whose height is 1em. */
143
+ interface PlainHtmlIcon {
144
+ width: number;
145
+ height: number;
146
+ path: string;
131
147
  }
132
148
  /**
133
149
  * Render a parsed markdown document as a complete, semantic HTML page.
@@ -163,6 +179,74 @@ interface PlainHtmlParts {
163
179
  */
164
180
  declare function markdownDocToPlainHtmlParts(doc: MarkdownDocument, options?: PlainHtmlExportOptions): PlainHtmlParts;
165
181
 
182
+ /**
183
+ * Preparing a document for a static HTML page.
184
+ *
185
+ * A plain HTML page (`markdownDocToPlainHtml`, or a page template filled from
186
+ * `markdownDocToPlainHtmlParts`) runs no script, so what the player draws at
187
+ * runtime has to be settled before the page is written:
188
+ *
189
+ * - `{[dataTable src=…]}` references (and charts fed by one) get the table
190
+ * they point at, bounded to a preview window with a "Showing N of M rows"
191
+ * note — the author's body link to the full file follows it;
192
+ * - Mermaid fences, ASCII diagrams and timelines, drawing / layout / diagram
193
+ * blocks, and charts become pictures, drawn by a host-supplied renderer
194
+ * (drawing needs a browser) and returned as `data:` URLs;
195
+ * - inline icons become inline SVG outlines, so the page needs no Font
196
+ * Awesome stylesheet or font.
197
+ *
198
+ * File trees stay preformatted text, which a page shows as well as a picture
199
+ * would and keeps selectable; SVG islands the renderer already draws.
200
+ */
201
+
202
+ interface PlainHtmlPreparationOptions {
203
+ /**
204
+ * Draws diagrams and charts as pictures. In a browser, pass
205
+ * `createDiagramPictureRenderer()` from
206
+ * `@bendyline/squisq-react/diagram-pictures`. Without one, diagrams stay as
207
+ * their source and charts as their table.
208
+ */
209
+ renderDiagram?: DiagramRasterizer;
210
+ /**
211
+ * The container holding the document's data sidecars. Without one, a data
212
+ * reference keeps only its link.
213
+ */
214
+ container?: ContentContainer | null;
215
+ /** Rows per data table; a block's own `previewRows` wins. Default 100. */
216
+ maxDataRows?: number;
217
+ /**
218
+ * A caller-owned memo of data-file reads, for a host that prepares the
219
+ * same document again and again (a live preview). The caller clears it
220
+ * when the files may have changed.
221
+ */
222
+ dataTableCache?: Map<string, Promise<DataSourceTable>>;
223
+ signal?: AbortSignal;
224
+ /** Receives a note for each table or picture that could not be produced. */
225
+ onWarning?: (message: string) => void;
226
+ }
227
+ interface PreparedPlainHtmlDocument {
228
+ /** The document to render, with data tables filled in and pictures in place. */
229
+ markdownDoc: MarkdownDocument;
230
+ /**
231
+ * The pictures as `data:` URLs, keyed by the image URL written into
232
+ * `markdownDoc`. Merge them into the renderer's `images` option.
233
+ */
234
+ images: Map<string, string>;
235
+ /** Outlines of the document's inline icons: the renderer's `icons` option. */
236
+ icons: Map<string, PlainHtmlIcon>;
237
+ }
238
+ /**
239
+ * Whether {@link prepareMarkdownDocForPlainHtml} would change anything for
240
+ * `doc` with these options — so a live preview renders a document with
241
+ * nothing to prepare at once, without waiting on the asynchronous step.
242
+ */
243
+ declare function needsPlainHtmlPreparation(doc: MarkdownDocument, options?: Pick<PlainHtmlPreparationOptions, 'renderDiagram' | 'container'>): boolean;
244
+ /**
245
+ * Settle everything in `doc` a script-free page cannot draw. Never throws for
246
+ * one table or picture: each degrades to its link or source with a warning.
247
+ */
248
+ declare function prepareMarkdownDocForPlainHtml(doc: MarkdownDocument, options?: PlainHtmlPreparationOptions): Promise<PreparedPlainHtmlDocument>;
249
+
166
250
  /**
167
251
  * HTML Page Templates
168
252
  *
@@ -477,4 +561,4 @@ declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
477
561
  */
478
562
  declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
479
563
 
480
- export { HTML_PAGE_TEMPLATE_CONTENT_END, HTML_PAGE_TEMPLATE_CONTENT_START, type HtmlBundleOptions, HtmlExportOptions, type HtmlPageTemplateContent, HtmlPageTemplateError, type HtmlPageTemplateInspection, type HtmlPageTemplateIssue, type HtmlPageTemplateOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, type PlainHtmlParts, applyHtmlPageTemplate, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, extractHtmlPageTemplateContent, inferMimeType, inspectHtmlPageTemplate, isHtmlPageTemplate, markdownDocToPlainHtml, markdownDocToPlainHtmlParts, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
564
+ export { HTML_PAGE_TEMPLATE_CONTENT_END, HTML_PAGE_TEMPLATE_CONTENT_START, type HtmlBundleOptions, HtmlExportOptions, type HtmlPageTemplateContent, HtmlPageTemplateError, type HtmlPageTemplateInspection, type HtmlPageTemplateIssue, type HtmlPageTemplateOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, type PlainHtmlIcon, type PlainHtmlParts, type PlainHtmlPreparationOptions, type PreparedPlainHtmlDocument, applyHtmlPageTemplate, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, extractHtmlPageTemplateContent, inferMimeType, inspectHtmlPageTemplate, isHtmlPageTemplate, markdownDocToPlainHtml, markdownDocToPlainHtmlParts, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle, needsPlainHtmlPreparation, prepareMarkdownDocForPlainHtml };
@@ -17,15 +17,18 @@ import {
17
17
  markdownDocToPlainHtml,
18
18
  markdownDocToPlainHtmlParts,
19
19
  markdownDocsToHtmlBundle,
20
- markdownDocsToPlainHtmlBundle
21
- } from "../chunk-LK4KCVN6.js";
20
+ markdownDocsToPlainHtmlBundle,
21
+ needsPlainHtmlPreparation,
22
+ prepareMarkdownDocForPlainHtml
23
+ } from "../chunk-SZ3OIY6G.js";
24
+ import "../chunk-4LIFEQKX.js";
22
25
  import {
23
26
  arrayBufferToBase64DataUrl,
24
27
  extractFilename,
25
28
  inferMimeType
26
29
  } from "../chunk-WMIDXNGR.js";
27
30
  import "../chunk-VCZUXQUL.js";
28
- import "../chunk-BXWNU4T5.js";
31
+ import "../chunk-DTJQK7U7.js";
29
32
  import "../chunk-JZR32FON.js";
30
33
  export {
31
34
  HTML_PAGE_TEMPLATE_CONTENT_END,
@@ -49,5 +52,7 @@ export {
49
52
  markdownDocToPlainHtml,
50
53
  markdownDocToPlainHtmlParts,
51
54
  markdownDocsToHtmlBundle,
52
- markdownDocsToPlainHtmlBundle
55
+ markdownDocsToPlainHtmlBundle,
56
+ needsPlainHtmlPreparation,
57
+ prepareMarkdownDocForPlainHtml
53
58
  };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ import '@bendyline/squisq/markdown';
19
19
  import './reader-B_m1aKZC.js';
20
20
  import '@bendyline/squisq/storage';
21
21
  import './layouts-CTdPlB-u.js';
22
+ import '@bendyline/squisq/doc';
23
+ import './diagrams/index.js';
22
24
  import './themeReader-DCtwC83Q.js';
23
25
  import '@bendyline/squisq/transform';
24
26
  import './container/index.js';