@bendyline/squisq-formats 2.6.14 → 2.6.16

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 (34) hide show
  1. package/README.md +41 -13
  2. package/dist/{chunk-MIK4NMOP.js → chunk-EMAPNC32.js} +45 -6
  3. package/dist/{chunk-XJNOZTAY.js → chunk-EQAHFGGX.js} +17 -44
  4. package/dist/{chunk-3ITGQRL5.js → chunk-NVMYRBOJ.js} +1 -1
  5. package/dist/chunk-RSU3V5IQ.js +73 -0
  6. package/dist/{chunk-XG6KFCPM.js → chunk-SAMQZRJU.js} +1 -1
  7. package/dist/{chunk-C7SPLITE.js → chunk-TLDBJH7D.js} +1 -1
  8. package/dist/{chunk-2SUIARE4.js → chunk-VE2ADQ5T.js} +4 -1
  9. package/dist/{chunk-VPWPEMZJ.js → chunk-YVCUNZB5.js} +1 -1
  10. package/dist/{chunk-ROF7SSQP.js → chunk-ZDRSDYXN.js} +73 -1
  11. package/dist/diagrams/index.d.ts +86 -0
  12. package/dist/diagrams/index.js +222 -0
  13. package/dist/docx/index.d.ts +7 -0
  14. package/dist/docx/index.js +2 -2
  15. package/dist/epub/index.js +3 -3
  16. package/dist/html/index.js +3 -3
  17. package/dist/images-CAWESWRF.js +10 -0
  18. package/dist/{import-C16E8Y4X.d.ts → import-Cn_V1_7e.d.ts} +12 -0
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +11 -11
  21. package/dist/infer/index.js +6 -6
  22. package/dist/outside-in/index.d.ts +2 -2
  23. package/dist/outside-in/index.js +2 -2
  24. package/dist/pdf/index.d.ts +16 -0
  25. package/dist/pdf/index.js +2 -1
  26. package/dist/pptx/index.d.ts +2 -2
  27. package/dist/pptx/index.js +3 -3
  28. package/dist/registry/index.d.ts +3 -3
  29. package/dist/registry/index.js +1 -1
  30. package/dist/{types-Ba_aUHZJ.d.ts → types-Cubj9A8c.d.ts} +1 -1
  31. package/package.json +7 -2
  32. package/dist/chunk-B7GEAZBI.js +0 -37
  33. package/dist/images-JLBFCDD4.js +0 -6
  34. package/dist/{chunk-7DQP2I57.js → chunk-3KXEE7KH.js} +5 -5
@@ -0,0 +1,222 @@
1
+ // src/diagrams/index.ts
2
+ import { extractPlainText, stringifyMarkdown } from "@bendyline/squisq/markdown";
3
+ import {
4
+ detectAsciiDiagram,
5
+ detectAsciiTimeline,
6
+ detectTree,
7
+ isContainerTemplate,
8
+ isEligibleAsciiFenceLang,
9
+ isEligibleAsciiTimelineFenceLang,
10
+ isEligibleTreeFenceLang,
11
+ isExplicitDiagramLang,
12
+ isExplicitTimelineLang,
13
+ isExplicitTreeLang,
14
+ resolveTemplateName
15
+ } from "@bendyline/squisq/doc";
16
+ var KIND_NAMES = {
17
+ mermaid: "Diagram",
18
+ diagram: "Diagram",
19
+ timeline: "Timeline",
20
+ tree: "Tree",
21
+ container: "Diagram"
22
+ };
23
+ function fenceDiagramKind(node) {
24
+ const lang = node.lang ?? null;
25
+ if ((lang ?? "").trim().toLowerCase() === "mermaid") return "mermaid";
26
+ if (isEligibleAsciiFenceLang(lang)) {
27
+ const detection = detectAsciiDiagram(node.value, { explicit: isExplicitDiagramLang(lang) });
28
+ if (detection.isDiagram) return "diagram";
29
+ }
30
+ if (isEligibleTreeFenceLang(lang)) {
31
+ if (detectTree(node.value, { explicit: isExplicitTreeLang(lang) }).isTree) return "tree";
32
+ }
33
+ if (isEligibleAsciiTimelineFenceLang(lang)) {
34
+ const detection = detectAsciiTimeline(node.value, { explicit: isExplicitTimelineLang(lang) });
35
+ if (detection.isTimeline) return "timeline";
36
+ }
37
+ return null;
38
+ }
39
+ function containerTemplateOf(node) {
40
+ if (node.type !== "heading") return null;
41
+ const requested = node.templateAnnotation?.template;
42
+ if (!requested || !isContainerTemplate(requested)) return null;
43
+ return resolveTemplateName(requested);
44
+ }
45
+ function mermaidAlt(source) {
46
+ const title = /^\s*accTitle\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
47
+ const description = /^\s*accDescr\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
48
+ return [title, description].filter(Boolean).join(". ");
49
+ }
50
+ function fenceMarkdown(node) {
51
+ return stringifyMarkdown({ type: "document", children: [node] }).trim();
52
+ }
53
+ function findInDocument(doc) {
54
+ const found = [];
55
+ const children = doc.children;
56
+ const walk = (nodes) => {
57
+ for (const node of nodes) {
58
+ if (node.type === "code") {
59
+ const fence = node;
60
+ const kind = fenceDiagramKind(fence);
61
+ if (kind) {
62
+ found.push({
63
+ fence,
64
+ diagram: {
65
+ kind,
66
+ markdown: fenceMarkdown(fence),
67
+ source: fence.value,
68
+ template: "",
69
+ alt: (kind === "mermaid" ? mermaidAlt(fence.value) : "") || KIND_NAMES[kind]
70
+ }
71
+ });
72
+ }
73
+ continue;
74
+ }
75
+ const nested = node.children;
76
+ if (Array.isArray(nested) && node.type !== "heading" && node.type !== "paragraph") {
77
+ walk(nested);
78
+ }
79
+ }
80
+ };
81
+ for (let index = 0; index < children.length; index++) {
82
+ const node = children[index];
83
+ const template = containerTemplateOf(node);
84
+ if (!template) {
85
+ walk([node]);
86
+ continue;
87
+ }
88
+ const depth = node.depth;
89
+ let end = index + 1;
90
+ while (end < children.length) {
91
+ const next = children[end];
92
+ if (next.type === "heading" && next.depth <= depth) break;
93
+ end++;
94
+ }
95
+ const heading = extractPlainText(node).trim();
96
+ found.push({
97
+ containerIndex: index,
98
+ containerEnd: end,
99
+ diagram: {
100
+ kind: "container",
101
+ markdown: stringifyMarkdown({
102
+ type: "document",
103
+ children: children.slice(index, end)
104
+ }).trim(),
105
+ source: "",
106
+ template,
107
+ alt: heading || KIND_NAMES.container
108
+ }
109
+ });
110
+ index = end - 1;
111
+ }
112
+ return found;
113
+ }
114
+ function imageUrls(nodes, into) {
115
+ for (const node of nodes) {
116
+ if (node.type === "image") into.add(node.url);
117
+ const nested = node.children;
118
+ if (Array.isArray(nested)) imageUrls(nested, into);
119
+ }
120
+ return into;
121
+ }
122
+ function findDiagrams(doc) {
123
+ return findInDocument(doc).map((entry) => entry.diagram);
124
+ }
125
+ function imageParagraph(url, alt) {
126
+ const image = { type: "image", url, alt, title: null };
127
+ return { type: "paragraph", children: [image] };
128
+ }
129
+ function replaceFences(nodes, replacements) {
130
+ let changed = false;
131
+ const next = nodes.map((node) => {
132
+ const replacement = replacements.get(node);
133
+ if (replacement) {
134
+ changed = true;
135
+ return replacement;
136
+ }
137
+ const nested = node.children;
138
+ if (Array.isArray(nested)) {
139
+ const replaced = replaceFences(nested, replacements);
140
+ if (replaced !== nested) {
141
+ changed = true;
142
+ return { ...node, children: replaced };
143
+ }
144
+ }
145
+ return node;
146
+ });
147
+ return changed ? next : nodes;
148
+ }
149
+ async function rasterizeDiagrams(doc, render, options = {}) {
150
+ const kinds = options.kinds ? new Set(options.kinds) : null;
151
+ const prefix = options.urlPrefix ?? "diagram";
152
+ const taken = imageUrls(doc.children, /* @__PURE__ */ new Set());
153
+ let counter = 0;
154
+ const nextUrl = () => {
155
+ let url;
156
+ do
157
+ url = `${prefix}-${String(++counter)}.png`;
158
+ while (taken.has(url));
159
+ taken.add(url);
160
+ return url;
161
+ };
162
+ const images = /* @__PURE__ */ new Map();
163
+ const mermaid = /* @__PURE__ */ new Map();
164
+ const fenceReplacements = /* @__PURE__ */ new Map();
165
+ const containerReplacements = [];
166
+ for (const entry of findInDocument(doc)) {
167
+ options.signal?.throwIfAborted();
168
+ if (kinds && !kinds.has(entry.diagram.kind)) continue;
169
+ let picture = null;
170
+ try {
171
+ picture = await render(entry.diagram);
172
+ } catch (error) {
173
+ options.onWarning?.(
174
+ `A ${KIND_NAMES[entry.diagram.kind].toLowerCase()} could not be drawn and was kept as text: ${error instanceof Error ? error.message : String(error)}`
175
+ );
176
+ }
177
+ if (!picture || picture.width <= 0 || picture.height <= 0) continue;
178
+ const data = picture.data instanceof Uint8Array ? picture.data : new Uint8Array(picture.data);
179
+ const url = nextUrl();
180
+ images.set(url, {
181
+ data,
182
+ contentType: "image/png",
183
+ width: picture.width,
184
+ height: picture.height
185
+ });
186
+ if (entry.diagram.kind === "mermaid") mermaid.set(entry.diagram.source.trim(), picture);
187
+ const paragraph = imageParagraph(url, entry.diagram.alt);
188
+ if (entry.fence) {
189
+ fenceReplacements.set(entry.fence, paragraph);
190
+ } else if (entry.containerIndex !== void 0 && entry.containerEnd !== void 0) {
191
+ const heading = doc.children[entry.containerIndex];
192
+ const { templateAnnotation: _template, ...plainHeading } = heading;
193
+ containerReplacements.push({
194
+ start: entry.containerIndex,
195
+ end: entry.containerEnd,
196
+ nodes: [plainHeading, paragraph]
197
+ });
198
+ }
199
+ }
200
+ let children = doc.children;
201
+ if (containerReplacements.length > 0) {
202
+ const rebuilt = [];
203
+ let cursor = 0;
204
+ for (const replacement of containerReplacements) {
205
+ rebuilt.push(...children.slice(cursor, replacement.start), ...replacement.nodes);
206
+ cursor = replacement.end;
207
+ }
208
+ rebuilt.push(...children.slice(cursor));
209
+ children = rebuilt;
210
+ }
211
+ if (fenceReplacements.size > 0) children = replaceFences(children, fenceReplacements);
212
+ return {
213
+ markdownDoc: children === doc.children ? doc : { ...doc, children },
214
+ images,
215
+ mermaid
216
+ };
217
+ }
218
+ export {
219
+ fenceDiagramKind,
220
+ findDiagrams,
221
+ rasterizeDiagrams
222
+ };
@@ -51,10 +51,17 @@ interface DocxExportOptions {
51
51
  * Pre-resolved image data keyed by image URL/path as it appears in the
52
52
  * markdown source. When provided, images are embedded in the .docx file
53
53
  * as binary parts instead of emitting placeholder text.
54
+ *
55
+ * `width` / `height` give the display size in CSS pixels (96 per inch).
56
+ * Pass them for a high-density image, such as a diagram rendered at 2×,
57
+ * that should not print at its pixel size; otherwise the size is read from
58
+ * the image header.
54
59
  */
55
60
  images?: Map<string, {
56
61
  data: ArrayBuffer | Uint8Array;
57
62
  contentType: string;
63
+ width?: number;
64
+ height?: number;
58
65
  }>;
59
66
  /** Permit carefully validated relative hyperlink targets. Default: false. */
60
67
  allowRelativeHyperlinks?: boolean;
@@ -4,9 +4,8 @@ import {
4
4
  docxToDoc,
5
5
  docxToMarkdownDoc,
6
6
  markdownDocToDocx
7
- } from "../chunk-XJNOZTAY.js";
7
+ } from "../chunk-EQAHFGGX.js";
8
8
  import "../chunk-A6N6IN3I.js";
9
- import "../chunk-B7GEAZBI.js";
10
9
  import "../chunk-AVOZAKGP.js";
11
10
  import "../chunk-ILCJ3WFD.js";
12
11
  import "../chunk-JU2RHXUB.js";
@@ -15,6 +14,7 @@ import "../chunk-7AWFHP5U.js";
15
14
  import "../chunk-BXWNU4T5.js";
16
15
  import "../chunk-IIQYS2YH.js";
17
16
  import "../chunk-USU6HTKB.js";
17
+ import "../chunk-RSU3V5IQ.js";
18
18
  export {
19
19
  docToDocx,
20
20
  docxToContainer,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  docToEpub,
3
3
  markdownDocToEpub
4
- } from "../chunk-3ITGQRL5.js";
5
- import "../chunk-VPWPEMZJ.js";
6
- import "../chunk-B7GEAZBI.js";
4
+ } from "../chunk-NVMYRBOJ.js";
5
+ import "../chunk-YVCUNZB5.js";
7
6
  import "../chunk-AVOZAKGP.js";
8
7
  import "../chunk-JU2RHXUB.js";
9
8
  import "../chunk-BXWNU4T5.js";
10
9
  import "../chunk-USU6HTKB.js";
10
+ import "../chunk-RSU3V5IQ.js";
11
11
  export {
12
12
  docToEpub,
13
13
  markdownDocToEpub
@@ -10,14 +10,14 @@ import {
10
10
  markdownDocToPlainHtml,
11
11
  markdownDocsToHtmlBundle,
12
12
  markdownDocsToPlainHtmlBundle
13
- } from "../chunk-C7SPLITE.js";
13
+ } from "../chunk-TLDBJH7D.js";
14
14
  import {
15
15
  arrayBufferToBase64DataUrl,
16
16
  extractFilename,
17
17
  inferMimeType
18
- } from "../chunk-VPWPEMZJ.js";
19
- import "../chunk-B7GEAZBI.js";
18
+ } from "../chunk-YVCUNZB5.js";
20
19
  import "../chunk-BXWNU4T5.js";
20
+ import "../chunk-RSU3V5IQ.js";
21
21
  export {
22
22
  arrayBufferToBase64DataUrl,
23
23
  collectImagePaths,
@@ -0,0 +1,10 @@
1
+ import {
2
+ extToMime,
3
+ fitWithin,
4
+ readImageDimensions
5
+ } from "./chunk-RSU3V5IQ.js";
6
+ export {
7
+ extToMime,
8
+ fitWithin,
9
+ readImageDimensions
10
+ };
@@ -71,6 +71,18 @@ interface PptxExportOptions {
71
71
  * showing `[Image: alt]` placeholders.
72
72
  */
73
73
  images?: Map<string, ArrayBuffer>;
74
+ /**
75
+ * Pictures of Mermaid diagrams, keyed by the Mermaid source as written in
76
+ * the fence (trimmed). A Mermaid layer with a picture here is drawn as that
77
+ * picture, fitted inside its area; otherwise its source shows as text.
78
+ * `width` / `height` are the picture's display size and set its aspect
79
+ * ratio, which also shapes the slide area reserved for the diagram.
80
+ */
81
+ diagramImages?: Map<string, {
82
+ data: ArrayBuffer | Uint8Array;
83
+ width: number;
84
+ height: number;
85
+ }>;
74
86
  /** Permit carefully validated relative hyperlink targets. Default: false. */
75
87
  allowRelativeHyperlinks?: boolean;
76
88
  /**
package/dist/index.d.ts CHANGED
@@ -6,12 +6,12 @@ export { PdfExportOptions, PdfImportOptions, configurePdfWorker, docToPdf, markd
6
6
  export { HtmlZipExportOptions, docToHtml, docToHtmlZip } from './html/index.js';
7
7
  export { EpubExportOptions, docToEpub, markdownDocToEpub } from './epub/index.js';
8
8
  export { ExtractedFileTheme, InferSourceFormat, InferThemeOptions, InferredFileTheme, compileExtractedTheme, inferThemeFromFile } from './infer/index.js';
9
- export { B as BUILTIN_FORMAT_IDS, a as BuiltinFormatOptions, C as ConversionLimits, b as ConversionResult, c as ConvertOptions, d as ConvertSource, D as DEFAULT_CONVERSION_LIMITS, e as DbkFormatOptions, F as FormatDefinition, f as FormatId, g as FormatRegistry, M as MarkdownFormatOptions, N as NormalizedInput, P as PreparedConversion, h as PreparedExportOptions, r as resolveConversionLimits } from './types-Ba_aUHZJ.js';
9
+ export { B as BUILTIN_FORMAT_IDS, a as BuiltinFormatOptions, C as ConversionLimits, b as ConversionResult, c as ConvertOptions, d as ConvertSource, D as DEFAULT_CONVERSION_LIMITS, e as DbkFormatOptions, F as FormatDefinition, f as FormatId, g as FormatRegistry, M as MarkdownFormatOptions, N as NormalizedInput, P as PreparedConversion, h as PreparedExportOptions, r as resolveConversionLimits } from './types-Cubj9A8c.js';
10
10
  export { ConversionError, ConversionErrorCode, ConversionErrorOptions, convert, createRegistry, defaultFormats, defaultRegistry, prepareConversion } from './registry/index.js';
11
11
  export { ImportedOutsideInDocument, OUTSIDE_IN_FORMAT_IDS, OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY, OutsideInFormatId, OutsideInLayout, OutsideInMetadata, RenderOutsideInOptions, chooseOutsideInMarkdownPath, importOutsideInDocument, isOutsideInMarkdownEditingEnabled, isOutsideInTargetPath, readOutsideInMetadata, renderOutsideInDocument, resolveOutsideInLayout, withOutsideInMarkdownEditing, withOutsideInMetadata } from './outside-in/index.js';
12
12
  export { Z as ZipSafetyError, a as ZipSafetyErrorCode, b as ZipSafetyErrorOptions, c as ZipSafetyLimits } from './zipLimits-BOKCB7qk.js';
13
13
  export { H as HtmlExportOptions, a as HtmlImportOptions, c as collectImagePaths, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from './import-D8y5SV0T.js';
14
- export { P as PptxExportOptions, a as PptxImportOptions, d as docToPptx, m as markdownDocToPptx, p as pptxToMarkdownDoc } from './import-C16E8Y4X.js';
14
+ export { P as PptxExportOptions, a as PptxImportOptions, d as docToPptx, m as markdownDocToPptx, p as pptxToMarkdownDoc } from './import-Cn_V1_7e.js';
15
15
  export { X as XlsxExportOptions, a as XlsxImportOptions, b as XlsxTable, c as XlsxTableColumn, d as XlsxTablesOptions, e as docToXlsx, g as gridToTables, m as markdownDocToXlsx, x as xlsxToMarkdownDoc, f as xlsxToTables } from './export-C4bBD3Mx.js';
16
16
  import '@bendyline/squisq/schemas';
17
17
  import '@bendyline/squisq/markdown';
package/dist/index.js CHANGED
@@ -5,17 +5,18 @@ import {
5
5
  htmlToMarkdown,
6
6
  htmlToMarkdownDoc,
7
7
  htmlToMarkdownDocSync
8
- } from "./chunk-C7SPLITE.js";
8
+ } from "./chunk-TLDBJH7D.js";
9
9
  import {
10
10
  docToEpub,
11
11
  markdownDocToEpub
12
- } from "./chunk-3ITGQRL5.js";
12
+ } from "./chunk-NVMYRBOJ.js";
13
13
  import {
14
14
  BUILTIN_FORMAT_IDS
15
15
  } from "./chunk-2P5HJAQL.js";
16
16
  import {
17
17
  inferThemeFromFile
18
- } from "./chunk-7DQP2I57.js";
18
+ } from "./chunk-3KXEE7KH.js";
19
+ import "./chunk-WATAOG4Y.js";
19
20
  import {
20
21
  compileExtractedTheme
21
22
  } from "./chunk-2JJ5RFDZ.js";
@@ -31,7 +32,7 @@ import {
31
32
  resolveOutsideInLayout,
32
33
  withOutsideInMarkdownEditing,
33
34
  withOutsideInMetadata
34
- } from "./chunk-XG6KFCPM.js";
35
+ } from "./chunk-SAMQZRJU.js";
35
36
  import {
36
37
  DEFAULT_CONVERSION_LIMITS,
37
38
  convert,
@@ -40,27 +41,25 @@ import {
40
41
  defaultRegistry,
41
42
  prepareConversion,
42
43
  resolveConversionLimits
43
- } from "./chunk-2SUIARE4.js";
44
+ } from "./chunk-VE2ADQ5T.js";
44
45
  import {
45
46
  ConversionError
46
47
  } from "./chunk-KXOZMWBS.js";
47
- import "./chunk-WATAOG4Y.js";
48
48
  import {
49
49
  docToDocx,
50
50
  docxToDoc,
51
51
  docxToMarkdownDoc,
52
52
  markdownDocToDocx
53
- } from "./chunk-XJNOZTAY.js";
53
+ } from "./chunk-EQAHFGGX.js";
54
54
  import {
55
55
  docToPptx,
56
56
  markdownDocToPptx,
57
57
  pptxToDoc,
58
58
  pptxToMarkdownDoc
59
- } from "./chunk-MIK4NMOP.js";
59
+ } from "./chunk-EMAPNC32.js";
60
60
  import "./chunk-6N2J7C2B.js";
61
- import "./chunk-VPWPEMZJ.js";
61
+ import "./chunk-YVCUNZB5.js";
62
62
  import "./chunk-A6N6IN3I.js";
63
- import "./chunk-B7GEAZBI.js";
64
63
  import {
65
64
  docToXlsx,
66
65
  markdownDocToXlsx,
@@ -92,10 +91,11 @@ import {
92
91
  markdownDocToPdf,
93
92
  pdfToDoc,
94
93
  pdfToMarkdownDoc
95
- } from "./chunk-ROF7SSQP.js";
94
+ } from "./chunk-ZDRSDYXN.js";
96
95
  import "./chunk-BXWNU4T5.js";
97
96
  import "./chunk-IIQYS2YH.js";
98
97
  import "./chunk-USU6HTKB.js";
98
+ import "./chunk-RSU3V5IQ.js";
99
99
  export {
100
100
  BUILTIN_FORMAT_IDS,
101
101
  ConversionError,
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  inferThemeFromFile
3
- } from "../chunk-7DQP2I57.js";
3
+ } from "../chunk-3KXEE7KH.js";
4
+ import {
5
+ extractDocxTheme,
6
+ extractPptxTheme,
7
+ extractXlsxTheme
8
+ } from "../chunk-WATAOG4Y.js";
4
9
  import {
5
10
  colorHintsFromExtraction,
6
11
  compileExtractedTheme,
7
12
  extractedThemeToPartial
8
13
  } from "../chunk-2JJ5RFDZ.js";
9
14
  import "../chunk-KXOZMWBS.js";
10
- import {
11
- extractDocxTheme,
12
- extractPptxTheme,
13
- extractXlsxTheme
14
- } from "../chunk-WATAOG4Y.js";
15
15
  import "../chunk-OK622ILP.js";
16
16
  import "../chunk-S5PCVMKU.js";
17
17
  import "../chunk-7AWFHP5U.js";
@@ -1,12 +1,12 @@
1
1
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
2
2
  import { ContentContainer } from '@bendyline/squisq/storage';
3
- import { c as ConvertOptions, b as ConversionResult } from '../types-Ba_aUHZJ.js';
3
+ import { c as ConvertOptions, b as ConversionResult } from '../types-Cubj9A8c.js';
4
4
  import '@bendyline/squisq/schemas';
5
5
  import '@bendyline/squisq/transform';
6
6
  import '../docx/index.js';
7
7
  import '../reader-B_m1aKZC.js';
8
8
  import '../zipLimits-BOKCB7qk.js';
9
- import '../import-C16E8Y4X.js';
9
+ import '../import-Cn_V1_7e.js';
10
10
  import '../export-C4bBD3Mx.js';
11
11
  import '../csv/index.js';
12
12
  import '../pdf/index.js';
@@ -10,8 +10,8 @@ import {
10
10
  resolveOutsideInLayout,
11
11
  withOutsideInMarkdownEditing,
12
12
  withOutsideInMetadata
13
- } from "../chunk-XG6KFCPM.js";
14
- import "../chunk-2SUIARE4.js";
13
+ } from "../chunk-SAMQZRJU.js";
14
+ import "../chunk-VE2ADQ5T.js";
15
15
  import "../chunk-KXOZMWBS.js";
16
16
  import "../chunk-7AWFHP5U.js";
17
17
  export {
@@ -49,6 +49,22 @@ interface PdfExportOptions {
49
49
  themeId?: string;
50
50
  /** Explicit caller-owned registry for non-document custom themes. */
51
51
  themeRegistry?: ThemeRegistry;
52
+ /**
53
+ * Image data keyed by the image URL/path as it appears in the markdown.
54
+ * A PNG or JPEG found here is drawn when it stands alone in a paragraph
55
+ * (scaled to the text width and the page, centered); images inside running
56
+ * text, and any not supplied, still print as an `[Image: alt]` note.
57
+ *
58
+ * `width` / `height` give the display size in CSS pixels (96 per inch).
59
+ * Pass them for a high-density image, such as a diagram rendered at 2×;
60
+ * otherwise the pixel size is used.
61
+ */
62
+ images?: Map<string, {
63
+ data: ArrayBuffer | Uint8Array;
64
+ contentType?: string;
65
+ width?: number;
66
+ height?: number;
67
+ }>;
52
68
  /**
53
69
  * Receives non-fatal notes about the export — today, the one-shot summary
54
70
  * raised when characters outside the standard PDF fonts' WinAnsi encoding
package/dist/pdf/index.js CHANGED
@@ -5,10 +5,11 @@ import {
5
5
  pdfToContainer,
6
6
  pdfToDoc,
7
7
  pdfToMarkdownDoc
8
- } from "../chunk-ROF7SSQP.js";
8
+ } from "../chunk-ZDRSDYXN.js";
9
9
  import "../chunk-BXWNU4T5.js";
10
10
  import "../chunk-IIQYS2YH.js";
11
11
  import "../chunk-USU6HTKB.js";
12
+ import "../chunk-RSU3V5IQ.js";
12
13
  export {
13
14
  configurePdfWorker,
14
15
  docToPdf,
@@ -1,5 +1,5 @@
1
- import { a as PptxImportOptions } from '../import-C16E8Y4X.js';
2
- export { P as PptxExportOptions, d as docToPptx, m as markdownDocToPptx, b as pptxToContainer, p as pptxToMarkdownDoc } from '../import-C16E8Y4X.js';
1
+ import { a as PptxImportOptions } from '../import-Cn_V1_7e.js';
2
+ export { P as PptxExportOptions, d as docToPptx, m as markdownDocToPptx, b as pptxToContainer, p as pptxToMarkdownDoc } from '../import-Cn_V1_7e.js';
3
3
  import { Doc } from '@bendyline/squisq/schemas';
4
4
  export { A as AnalyzePptxLayoutsOptions, a as AnalyzedLayout, E as ExtractedPlaceholder, b as ExtractedSlideLayout, I as InspectPptxLayoutsOptions, L as LayoutVerdict, P as PptxColorHints, c as PptxLayoutInference, d as PptxLayoutSummary, e as analyzePptxLayouts, i as inspectPptxLayouts } from '../layouts-CTdPlB-u.js';
5
5
  import '@bendyline/squisq/markdown';
@@ -4,14 +4,13 @@ import {
4
4
  pptxToContainer,
5
5
  pptxToDoc,
6
6
  pptxToMarkdownDoc
7
- } from "../chunk-MIK4NMOP.js";
7
+ } from "../chunk-EMAPNC32.js";
8
8
  import {
9
9
  analyzePptxLayouts,
10
10
  inspectPptxLayouts
11
11
  } from "../chunk-6N2J7C2B.js";
12
- import "../chunk-VPWPEMZJ.js";
12
+ import "../chunk-YVCUNZB5.js";
13
13
  import "../chunk-A6N6IN3I.js";
14
- import "../chunk-B7GEAZBI.js";
15
14
  import "../chunk-AVOZAKGP.js";
16
15
  import "../chunk-ILCJ3WFD.js";
17
16
  import "../chunk-JU2RHXUB.js";
@@ -19,6 +18,7 @@ import "../chunk-S5PCVMKU.js";
19
18
  import "../chunk-7AWFHP5U.js";
20
19
  import "../chunk-IIQYS2YH.js";
21
20
  import "../chunk-USU6HTKB.js";
21
+ import "../chunk-RSU3V5IQ.js";
22
22
  export {
23
23
  analyzePptxLayouts,
24
24
  docToPptx,
@@ -1,5 +1,5 @@
1
- import { f as FormatId, g as FormatRegistry, F as FormatDefinition, d as ConvertSource, c as ConvertOptions, b as ConversionResult, P as PreparedConversion } from '../types-Ba_aUHZJ.js';
2
- export { B as BUILTIN_FORMAT_IDS, a as BuiltinFormatOptions, C as ConversionLimits, D as DEFAULT_CONVERSION_LIMITS, e as DbkFormatOptions, M as MarkdownFormatOptions, N as NormalizedInput, h as PreparedExportOptions, r as resolveConversionLimits } from '../types-Ba_aUHZJ.js';
1
+ import { f as FormatId, g as FormatRegistry, F as FormatDefinition, d as ConvertSource, c as ConvertOptions, b as ConversionResult, P as PreparedConversion } from '../types-Cubj9A8c.js';
2
+ export { B as BUILTIN_FORMAT_IDS, a as BuiltinFormatOptions, C as ConversionLimits, D as DEFAULT_CONVERSION_LIMITS, e as DbkFormatOptions, M as MarkdownFormatOptions, N as NormalizedInput, h as PreparedExportOptions, r as resolveConversionLimits } from '../types-Cubj9A8c.js';
3
3
  import '@bendyline/squisq/schemas';
4
4
  import '@bendyline/squisq/transform';
5
5
  import '@bendyline/squisq/markdown';
@@ -7,7 +7,7 @@ import '@bendyline/squisq/storage';
7
7
  import '../docx/index.js';
8
8
  import '../reader-B_m1aKZC.js';
9
9
  import '../zipLimits-BOKCB7qk.js';
10
- import '../import-C16E8Y4X.js';
10
+ import '../import-Cn_V1_7e.js';
11
11
  import '../export-C4bBD3Mx.js';
12
12
  import '../csv/index.js';
13
13
  import '../pdf/index.js';
@@ -9,7 +9,7 @@ import {
9
9
  defaultRegistry,
10
10
  prepareConversion,
11
11
  resolveConversionLimits
12
- } from "../chunk-2SUIARE4.js";
12
+ } from "../chunk-VE2ADQ5T.js";
13
13
  import {
14
14
  ConversionError
15
15
  } from "../chunk-KXOZMWBS.js";
@@ -3,7 +3,7 @@ import { TransformStyleInput, TransformStyleRegistry } from '@bendyline/squisq/t
3
3
  import { ParseOptions, StringifyOptions, MarkdownDocument } from '@bendyline/squisq/markdown';
4
4
  import { ContentContainer } from '@bendyline/squisq/storage';
5
5
  import { DocxImportOptions, DocxExportOptions } from './docx/index.js';
6
- import { a as PptxImportOptions, P as PptxExportOptions } from './import-C16E8Y4X.js';
6
+ import { a as PptxImportOptions, P as PptxExportOptions } from './import-Cn_V1_7e.js';
7
7
  import { j as XlsxContainerOptions, X as XlsxExportOptions } from './export-C4bBD3Mx.js';
8
8
  import { CsvContainerOptions, CsvExportOptions } from './csv/index.js';
9
9
  import { PdfImportOptions, PdfExportOptions } from './pdf/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/squisq-formats",
3
- "version": "2.6.14",
3
+ "version": "2.6.16",
4
4
  "description": "Document format converters — DOCX, PDF, OOXML import/export",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",
@@ -107,6 +107,11 @@
107
107
  "types": "./dist/outside-in/index.d.ts",
108
108
  "import": "./dist/outside-in/index.js",
109
109
  "default": "./dist/outside-in/index.js"
110
+ },
111
+ "./diagrams": {
112
+ "types": "./dist/diagrams/index.d.ts",
113
+ "import": "./dist/diagrams/index.js",
114
+ "default": "./dist/diagrams/index.js"
110
115
  }
111
116
  },
112
117
  "scripts": {
@@ -115,7 +120,7 @@
115
120
  "typecheck": "tsc --noEmit"
116
121
  },
117
122
  "dependencies": {
118
- "@bendyline/squisq": "2.11.14",
123
+ "@bendyline/squisq": "2.11.16",
119
124
  "@pdf-lib/fontkit": "1.1.1",
120
125
  "@pdf-lib/upng": "1.0.1",
121
126
  "@xmldom/xmldom": "0.9.12",
@@ -1,37 +0,0 @@
1
- // src/shared/images.ts
2
- var EXT_TO_MIME = {
3
- // Raster / vector images
4
- png: "image/png",
5
- jpg: "image/jpeg",
6
- jpeg: "image/jpeg",
7
- gif: "image/gif",
8
- webp: "image/webp",
9
- bmp: "image/bmp",
10
- svg: "image/svg+xml",
11
- tiff: "image/tiff",
12
- tif: "image/tiff",
13
- ico: "image/x-icon",
14
- avif: "image/avif",
15
- // Office vector formats (docx/pptx embedded metafiles)
16
- emf: "image/emf",
17
- wmf: "image/wmf",
18
- // Audio / video (html export inlines these as data URIs)
19
- mp3: "audio/mpeg",
20
- wav: "audio/wav",
21
- ogg: "audio/ogg",
22
- mp4: "video/mp4",
23
- webm: "video/webm",
24
- // Sidecar data files (`{[dataTable src=…]}` references)
25
- csv: "text/csv",
26
- tsv: "text/tab-separated-values",
27
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
28
- parquet: "application/vnd.apache.parquet"
29
- };
30
- function extToMime(ext) {
31
- const key = ext.replace(/^\./, "").toLowerCase();
32
- return EXT_TO_MIME[key] ?? "application/octet-stream";
33
- }
34
-
35
- export {
36
- extToMime
37
- };
@@ -1,6 +0,0 @@
1
- import {
2
- extToMime
3
- } from "./chunk-B7GEAZBI.js";
4
- export {
5
- extToMime
6
- };