@bendyline/squisq-formats 2.8.7 → 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 (39) hide show
  1. package/README.md +21 -0
  2. package/dist/chunk-4LIFEQKX.js +358 -0
  3. package/dist/{chunk-UXEANVBI.js → chunk-5HUHSLGA.js} +1 -84
  4. package/dist/{chunk-IYNDHW2C.js → chunk-6HUQFEP3.js} +75 -5
  5. package/dist/{chunk-BXWNU4T5.js → chunk-DTJQK7U7.js} +43 -0
  6. package/dist/{chunk-QU4EVC62.js → chunk-GFHUJ7L4.js} +1 -1
  7. package/dist/{chunk-TMOXUUTG.js → chunk-NQNIFIDP.js} +6 -4
  8. package/dist/{chunk-B6UQPW75.js → chunk-SZ3OIY6G.js} +697 -44
  9. package/dist/{chunk-KROH7FNT.js → chunk-VKLJUHC2.js} +6 -4
  10. package/dist/{chunk-C23JYVPG.js → chunk-WJTC5OD6.js} +2 -0
  11. package/dist/{chunk-ALDCFHZT.js → chunk-WVDAFJFS.js} +59 -21
  12. package/dist/chunk-YRFBWYAD.js +128 -0
  13. package/dist/{chunk-SVYTUYZM.js → chunk-ZJERBWTB.js} +6 -4
  14. package/dist/data/index.d.ts +27 -5
  15. package/dist/data/index.js +6 -2
  16. package/dist/diagrams/index.d.ts +19 -8
  17. package/dist/diagrams/index.js +7 -242
  18. package/dist/docx/index.d.ts +1 -1
  19. package/dist/docx/index.js +3 -3
  20. package/dist/epub/index.d.ts +1 -1
  21. package/dist/epub/index.js +3 -3
  22. package/dist/fontAwesome-C6FRDYTY.js +14 -0
  23. package/dist/html/index.d.ts +214 -2
  24. package/dist/html/index.js +25 -4
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +15 -10
  27. package/dist/{materialize-G4WC5UG3.js → materialize-ICXNO4S4.js} +4 -1
  28. package/dist/outside-in/index.d.ts +21 -2
  29. package/dist/outside-in/index.js +7 -3
  30. package/dist/outside-in/layout.d.ts +7 -1
  31. package/dist/outside-in/layout.js +3 -1
  32. package/dist/pdf/index.d.ts +1 -1
  33. package/dist/pdf/index.js +3 -3
  34. package/dist/plainHtmlIcons-KBSIJ5EN.js +62 -0
  35. package/dist/pptx/index.js +2 -2
  36. package/dist/readers-3P5A6A2A.js +17 -0
  37. package/dist/registry/index.js +1 -1
  38. package/package.json +2 -2
  39. /package/dist/{chunk-LBXBRFBZ.js → chunk-DDMPZZJF.js} +0 -0
package/dist/index.js CHANGED
@@ -5,11 +5,11 @@ import {
5
5
  htmlToMarkdown,
6
6
  htmlToMarkdownDoc,
7
7
  htmlToMarkdownDocSync
8
- } from "./chunk-B6UQPW75.js";
8
+ } from "./chunk-SZ3OIY6G.js";
9
9
  import {
10
10
  docToEpub,
11
11
  markdownDocToEpub
12
- } from "./chunk-SVYTUYZM.js";
12
+ } from "./chunk-ZJERBWTB.js";
13
13
  import {
14
14
  BUILTIN_FORMAT_IDS
15
15
  } from "./chunk-2P5HJAQL.js";
@@ -25,10 +25,11 @@ import {
25
25
  importOutsideInDocument,
26
26
  isOutsideInMarkdownEditingEnabled,
27
27
  readOutsideInMetadata,
28
+ readOutsideInOutputTemplate,
28
29
  renderOutsideInDocument,
29
30
  withOutsideInMarkdownEditing,
30
31
  withOutsideInMetadata
31
- } from "./chunk-IYNDHW2C.js";
32
+ } from "./chunk-6HUQFEP3.js";
32
33
  import {
33
34
  DEFAULT_CONVERSION_LIMITS,
34
35
  convert,
@@ -37,28 +38,30 @@ import {
37
38
  defaultRegistry,
38
39
  prepareConversion,
39
40
  resolveConversionLimits
40
- } from "./chunk-ALDCFHZT.js";
41
+ } from "./chunk-WVDAFJFS.js";
41
42
  import {
42
43
  ConversionError
43
44
  } from "./chunk-KXOZMWBS.js";
44
45
  import {
45
46
  OUTSIDE_IN_FORMAT_IDS,
47
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
46
48
  chooseOutsideInMarkdownPath,
47
49
  isOutsideInTargetPath,
48
50
  resolveOutsideInLayout
49
- } from "./chunk-C23JYVPG.js";
51
+ } from "./chunk-WJTC5OD6.js";
52
+ import "./chunk-4LIFEQKX.js";
50
53
  import {
51
54
  docToDocx,
52
55
  docxToDoc,
53
56
  docxToMarkdownDoc,
54
57
  markdownDocToDocx
55
- } from "./chunk-KROH7FNT.js";
58
+ } from "./chunk-VKLJUHC2.js";
56
59
  import {
57
60
  docToPptx,
58
61
  markdownDocToPptx,
59
62
  pptxToDoc,
60
63
  pptxToMarkdownDoc
61
- } from "./chunk-QU4EVC62.js";
64
+ } from "./chunk-GFHUJ7L4.js";
62
65
  import "./chunk-6N2J7C2B.js";
63
66
  import "./chunk-WMIDXNGR.js";
64
67
  import "./chunk-DHAK4PII.js";
@@ -94,17 +97,18 @@ import {
94
97
  markdownDocToPdf,
95
98
  pdfToDoc,
96
99
  pdfToMarkdownDoc
97
- } from "./chunk-TMOXUUTG.js";
100
+ } from "./chunk-NQNIFIDP.js";
98
101
  import "./chunk-34KECNZO.js";
99
- import "./chunk-BXWNU4T5.js";
102
+ import "./chunk-DTJQK7U7.js";
100
103
  import "./chunk-IIQYS2YH.js";
101
- import "./chunk-LBXBRFBZ.js";
104
+ import "./chunk-DDMPZZJF.js";
102
105
  import "./chunk-JZR32FON.js";
103
106
  export {
104
107
  BUILTIN_FORMAT_IDS,
105
108
  ConversionError,
106
109
  DEFAULT_CONVERSION_LIMITS,
107
110
  OUTSIDE_IN_FORMAT_IDS,
111
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
108
112
  OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY,
109
113
  ZipSafetyError,
110
114
  chooseOutsideInMarkdownPath,
@@ -147,6 +151,7 @@ export {
147
151
  pptxToMarkdownDoc,
148
152
  prepareConversion,
149
153
  readOutsideInMetadata,
154
+ readOutsideInOutputTemplate,
150
155
  renderOutsideInDocument,
151
156
  resolveConversionLimits,
152
157
  resolveOutsideInLayout,
@@ -1,11 +1,14 @@
1
1
  import {
2
+ DATA_PREVIEW_ROWS,
2
3
  materializeDataReferences
3
- } from "./chunk-UXEANVBI.js";
4
+ } from "./chunk-YRFBWYAD.js";
5
+ import "./chunk-5HUHSLGA.js";
4
6
  import "./chunk-ATWVNF7D.js";
5
7
  import "./chunk-Q77KNJIN.js";
6
8
  import "./chunk-DXYWKZ52.js";
7
9
  import "./chunk-S5PCVMKU.js";
8
10
  import "./chunk-7AWFHP5U.js";
9
11
  export {
12
+ DATA_PREVIEW_ROWS,
10
13
  materializeDataReferences
11
14
  };
@@ -1,8 +1,9 @@
1
1
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
2
2
  import { ContentContainer } from '@bendyline/squisq/storage';
3
3
  import { c as ConvertOptions, b as ConversionResult } from '../types-CVv9eldp.js';
4
+ import { DiagramRasterizer } from '../diagrams/index.js';
4
5
  import { OutsideInLayout, OutsideInFormatId } from './layout.js';
5
- export { OUTSIDE_IN_FORMAT_IDS, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout } from './layout.js';
6
+ export { OUTSIDE_IN_FORMAT_IDS, OUTSIDE_IN_OUTPUT_TEMPLATE_KEY, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout } from './layout.js';
6
7
  import '@bendyline/squisq/schemas';
7
8
  import '@bendyline/squisq/transform';
8
9
  import '../docx/index.js';
@@ -58,6 +59,17 @@ interface RenderOutsideInOptions extends ConvertOptions {
58
59
  /** URL from the rendered HTML file to its companion media folder. */
59
60
  basePath?: string;
60
61
  };
62
+ /**
63
+ * Draws diagrams as pictures for the targets that cannot draw them: Word
64
+ * and PDF get pictures in place of Mermaid, ASCII diagrams, timelines, file
65
+ * trees, drawings, and layouts (PDF also of SVG islands, which Word embeds
66
+ * as vector art over the picture); PowerPoint, whose own shapes draw the
67
+ * rest, gets pictures of Mermaid and of SVG islands. In a browser, pass
68
+ * `createDiagramPictureRenderer()` from
69
+ * `@bendyline/squisq-react/diagram-pictures`. Without one those diagrams
70
+ * render as their source text. HTML targets draw their own.
71
+ */
72
+ renderDiagram?: DiagramRasterizer;
61
73
  }
62
74
  /** Read outside-in metadata without interpreting the output path as authority. */
63
75
  declare function readOutsideInMetadata(source: string): OutsideInMetadata | null;
@@ -65,6 +77,13 @@ declare function readOutsideInMetadata(source: string): OutsideInMetadata | null
65
77
  declare function withOutsideInMetadata(source: string, layout: OutsideInLayout): string;
66
78
  /** True only when the companion explicitly opts into rendered-file updates. */
67
79
  declare function isOutsideInMarkdownEditingEnabled(source: string | MarkdownDocument): boolean;
80
+ /**
81
+ * The companion's page template choice: the authored path, `'none'` when it
82
+ * opts out of any host default, or null when it names none. Resolving the
83
+ * path against the companion is the host's job, since only the host knows
84
+ * where the container root is.
85
+ */
86
+ declare function readOutsideInOutputTemplate(source: string | MarkdownDocument): string | null;
68
87
  /**
69
88
  * Opt a companion into or out of Markdown-driven regeneration while keeping
70
89
  * the portable target relationship current.
@@ -82,4 +101,4 @@ declare function renderOutsideInDocument(source: {
82
101
  container?: ContentContainer;
83
102
  }, options?: RenderOutsideInOptions): Promise<ConversionResult>;
84
103
 
85
- export { type ImportedOutsideInDocument, OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY, OutsideInFormatId, OutsideInLayout, type OutsideInMetadata, type RenderOutsideInOptions, importOutsideInDocument, isOutsideInMarkdownEditingEnabled, readOutsideInMetadata, renderOutsideInDocument, withOutsideInMarkdownEditing, withOutsideInMetadata };
104
+ export { type ImportedOutsideInDocument, OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY, OutsideInFormatId, OutsideInLayout, type OutsideInMetadata, type RenderOutsideInOptions, importOutsideInDocument, isOutsideInMarkdownEditingEnabled, readOutsideInMetadata, readOutsideInOutputTemplate, renderOutsideInDocument, withOutsideInMarkdownEditing, withOutsideInMetadata };
@@ -3,27 +3,31 @@ import {
3
3
  importOutsideInDocument,
4
4
  isOutsideInMarkdownEditingEnabled,
5
5
  readOutsideInMetadata,
6
+ readOutsideInOutputTemplate,
6
7
  renderOutsideInDocument,
7
8
  withOutsideInMarkdownEditing,
8
9
  withOutsideInMetadata
9
- } from "../chunk-IYNDHW2C.js";
10
- import "../chunk-ALDCFHZT.js";
10
+ } from "../chunk-6HUQFEP3.js";
11
+ import "../chunk-WVDAFJFS.js";
11
12
  import "../chunk-KXOZMWBS.js";
12
13
  import {
13
14
  OUTSIDE_IN_FORMAT_IDS,
15
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
14
16
  chooseOutsideInMarkdownPath,
15
17
  isOutsideInTargetPath,
16
18
  resolveOutsideInLayout
17
- } from "../chunk-C23JYVPG.js";
19
+ } from "../chunk-WJTC5OD6.js";
18
20
  import "../chunk-7AWFHP5U.js";
19
21
  export {
20
22
  OUTSIDE_IN_FORMAT_IDS,
23
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
21
24
  OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY,
22
25
  chooseOutsideInMarkdownPath,
23
26
  importOutsideInDocument,
24
27
  isOutsideInMarkdownEditingEnabled,
25
28
  isOutsideInTargetPath,
26
29
  readOutsideInMetadata,
30
+ readOutsideInOutputTemplate,
27
31
  renderOutsideInDocument,
28
32
  resolveOutsideInLayout,
29
33
  withOutsideInMarkdownEditing,
@@ -19,6 +19,12 @@
19
19
  */
20
20
  declare const OUTSIDE_IN_FORMAT_IDS: readonly ["html", "docx", "pdf", "pptx", "xlsx", "csv"];
21
21
  type OutsideInFormatId = (typeof OUTSIDE_IN_FORMAT_IDS)[number];
22
+ /**
23
+ * Frontmatter naming the page template a rendered output is generated
24
+ * through: a path relative to the companion Markdown, a `/`-prefixed path
25
+ * from the container root, or `none` to opt out of a host default.
26
+ */
27
+ declare const OUTSIDE_IN_OUTPUT_TEMPLATE_KEY = "squisq-output-template";
22
28
  interface OutsideInLayout {
23
29
  /** User-facing rendered file, relative to the host's workspace root. */
24
30
  targetPath: string;
@@ -55,4 +61,4 @@ declare function isOutsideInTargetPath(path: string): boolean;
55
61
  */
56
62
  declare function chooseOutsideInMarkdownPath(layout: OutsideInLayout, paths: readonly string[]): string | null;
57
63
 
58
- export { OUTSIDE_IN_FORMAT_IDS, type OutsideInFormatId, type OutsideInLayout, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout };
64
+ export { OUTSIDE_IN_FORMAT_IDS, OUTSIDE_IN_OUTPUT_TEMPLATE_KEY, type OutsideInFormatId, type OutsideInLayout, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout };
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  OUTSIDE_IN_FORMAT_IDS,
3
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
3
4
  chooseOutsideInMarkdownPath,
4
5
  isOutsideInTargetPath,
5
6
  resolveOutsideInLayout
6
- } from "../chunk-C23JYVPG.js";
7
+ } from "../chunk-WJTC5OD6.js";
7
8
  export {
8
9
  OUTSIDE_IN_FORMAT_IDS,
10
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
9
11
  chooseOutsideInMarkdownPath,
10
12
  isOutsideInTargetPath,
11
13
  resolveOutsideInLayout
@@ -116,7 +116,7 @@ interface PdfExportOptions {
116
116
  /**
117
117
  * Convert a MarkdownDocument to a PDF ArrayBuffer.
118
118
  */
119
- declare function markdownDocToPdf(doc: MarkdownDocument, options?: PdfExportOptions): Promise<ArrayBuffer>;
119
+ declare function markdownDocToPdf(source: MarkdownDocument, options?: PdfExportOptions): Promise<ArrayBuffer>;
120
120
  /**
121
121
  * Convert a squisq Doc to a PDF ArrayBuffer.
122
122
  *
package/dist/pdf/index.js CHANGED
@@ -5,11 +5,11 @@ import {
5
5
  pdfToContainer,
6
6
  pdfToDoc,
7
7
  pdfToMarkdownDoc
8
- } from "../chunk-TMOXUUTG.js";
8
+ } from "../chunk-NQNIFIDP.js";
9
9
  import "../chunk-34KECNZO.js";
10
- import "../chunk-BXWNU4T5.js";
10
+ import "../chunk-DTJQK7U7.js";
11
11
  import "../chunk-IIQYS2YH.js";
12
- import "../chunk-LBXBRFBZ.js";
12
+ import "../chunk-DDMPZZJF.js";
13
13
  import "../chunk-JZR32FON.js";
14
14
  export {
15
15
  configurePdfWorker,
@@ -0,0 +1,62 @@
1
+ // src/html/plainHtmlIcons.ts
2
+ var fonts = /* @__PURE__ */ new Map();
3
+ function loadFont(family) {
4
+ let font = fonts.get(family);
5
+ if (!font) {
6
+ font = Promise.all([import("@pdf-lib/fontkit"), import("./fontAwesome-C6FRDYTY.js")]).then(
7
+ ([fontkit, { fontAwesomeFace }]) => fontkit.default.create(fontAwesomeFace(family).data)
8
+ );
9
+ font.catch(() => fonts.delete(family));
10
+ fonts.set(family, font);
11
+ }
12
+ return font;
13
+ }
14
+ function usedIcons(doc) {
15
+ const used = /* @__PURE__ */ new Map();
16
+ const visit = (node) => {
17
+ if (!node || typeof node !== "object") return;
18
+ const n = node;
19
+ if (n.type === "inlineIcon" && n.family && n.name) {
20
+ used.set(`${n.family}:${n.name}`, [n.family, n.name]);
21
+ }
22
+ if (Array.isArray(n.children)) n.children.forEach(visit);
23
+ };
24
+ visit(doc);
25
+ return used;
26
+ }
27
+ var round = (n) => Math.round(n * 100) / 100;
28
+ function glyphPath(font, glyph) {
29
+ const y = (value) => round(font.ascent - value);
30
+ const parts = [];
31
+ const sink = {
32
+ moveTo: (x, py) => parts.push(`M${round(x)} ${y(py)}`),
33
+ lineTo: (x, py) => parts.push(`L${round(x)} ${y(py)}`),
34
+ quadraticCurveTo: (cx, cy, x, py) => parts.push(`Q${round(cx)} ${y(cy)} ${round(x)} ${y(py)}`),
35
+ bezierCurveTo: (c1x, c1y, c2x, c2y, x, py) => parts.push(`C${round(c1x)} ${y(c1y)} ${round(c2x)} ${y(c2y)} ${round(x)} ${y(py)}`),
36
+ closePath: () => parts.push("Z")
37
+ };
38
+ glyph.path.toFunction()(sink);
39
+ return parts.join("");
40
+ }
41
+ async function plainHtmlIcons(doc) {
42
+ const icons = /* @__PURE__ */ new Map();
43
+ const used = usedIcons(doc);
44
+ if (used.size === 0) return icons;
45
+ const { fontAwesomeGlyph } = await import("./fontAwesome-C6FRDYTY.js");
46
+ for (const [key, [family, name]] of used) {
47
+ const glyph = fontAwesomeGlyph(family, name);
48
+ if (!glyph) continue;
49
+ const font = await loadFont(family);
50
+ const outline = font.glyphForCodePoint(glyph.codePointAt(0));
51
+ if (!outline || outline.advanceWidth <= 0) continue;
52
+ icons.set(key, {
53
+ width: outline.advanceWidth,
54
+ height: font.unitsPerEm,
55
+ path: glyphPath(font, outline)
56
+ });
57
+ }
58
+ return icons;
59
+ }
60
+ export {
61
+ plainHtmlIcons
62
+ };
@@ -4,7 +4,7 @@ import {
4
4
  pptxToContainer,
5
5
  pptxToDoc,
6
6
  pptxToMarkdownDoc
7
- } from "../chunk-QU4EVC62.js";
7
+ } from "../chunk-GFHUJ7L4.js";
8
8
  import {
9
9
  analyzePptxLayouts,
10
10
  inspectPptxLayouts
@@ -18,7 +18,7 @@ import "../chunk-JU2RHXUB.js";
18
18
  import "../chunk-S5PCVMKU.js";
19
19
  import "../chunk-7AWFHP5U.js";
20
20
  import "../chunk-IIQYS2YH.js";
21
- import "../chunk-LBXBRFBZ.js";
21
+ import "../chunk-DDMPZZJF.js";
22
22
  import "../chunk-JZR32FON.js";
23
23
  export {
24
24
  analyzePptxLayouts,
@@ -0,0 +1,17 @@
1
+ import {
2
+ csvDataReader,
3
+ defaultDataReaders,
4
+ parquetDataReader,
5
+ xlsxDataReader
6
+ } from "./chunk-5HUHSLGA.js";
7
+ import "./chunk-ATWVNF7D.js";
8
+ import "./chunk-Q77KNJIN.js";
9
+ import "./chunk-DXYWKZ52.js";
10
+ import "./chunk-S5PCVMKU.js";
11
+ import "./chunk-7AWFHP5U.js";
12
+ export {
13
+ csvDataReader,
14
+ defaultDataReaders,
15
+ parquetDataReader,
16
+ xlsxDataReader
17
+ };
@@ -9,7 +9,7 @@ import {
9
9
  defaultRegistry,
10
10
  prepareConversion,
11
11
  resolveConversionLimits
12
- } from "../chunk-ALDCFHZT.js";
12
+ } from "../chunk-WVDAFJFS.js";
13
13
  import {
14
14
  ConversionError
15
15
  } from "../chunk-KXOZMWBS.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/squisq-formats",
3
- "version": "2.8.7",
3
+ "version": "2.8.9",
4
4
  "description": "Document format converters — DOCX, PDF, OOXML import/export",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",
@@ -125,7 +125,7 @@
125
125
  "typecheck": "tsc --noEmit"
126
126
  },
127
127
  "dependencies": {
128
- "@bendyline/squisq": "2.13.6",
128
+ "@bendyline/squisq": "2.13.8",
129
129
  "@pdf-lib/fontkit": "1.1.1",
130
130
  "@pdf-lib/upng": "1.0.1",
131
131
  "@xmldom/xmldom": "0.9.12",
File without changes