@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.
- package/README.md +21 -0
- package/dist/chunk-4LIFEQKX.js +358 -0
- package/dist/{chunk-UXEANVBI.js → chunk-5HUHSLGA.js} +1 -84
- package/dist/{chunk-IYNDHW2C.js → chunk-6HUQFEP3.js} +75 -5
- package/dist/{chunk-BXWNU4T5.js → chunk-DTJQK7U7.js} +43 -0
- package/dist/{chunk-QU4EVC62.js → chunk-GFHUJ7L4.js} +1 -1
- package/dist/{chunk-TMOXUUTG.js → chunk-NQNIFIDP.js} +6 -4
- package/dist/{chunk-B6UQPW75.js → chunk-SZ3OIY6G.js} +697 -44
- package/dist/{chunk-KROH7FNT.js → chunk-VKLJUHC2.js} +6 -4
- package/dist/{chunk-C23JYVPG.js → chunk-WJTC5OD6.js} +2 -0
- package/dist/{chunk-ALDCFHZT.js → chunk-WVDAFJFS.js} +59 -21
- package/dist/chunk-YRFBWYAD.js +128 -0
- package/dist/{chunk-SVYTUYZM.js → chunk-ZJERBWTB.js} +6 -4
- package/dist/data/index.d.ts +27 -5
- package/dist/data/index.js +6 -2
- package/dist/diagrams/index.d.ts +19 -8
- package/dist/diagrams/index.js +7 -242
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/index.js +3 -3
- package/dist/epub/index.d.ts +1 -1
- package/dist/epub/index.js +3 -3
- package/dist/fontAwesome-C6FRDYTY.js +14 -0
- package/dist/html/index.d.ts +214 -2
- package/dist/html/index.js +25 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.js +15 -10
- package/dist/{materialize-G4WC5UG3.js → materialize-ICXNO4S4.js} +4 -1
- package/dist/outside-in/index.d.ts +21 -2
- package/dist/outside-in/index.js +7 -3
- package/dist/outside-in/layout.d.ts +7 -1
- package/dist/outside-in/layout.js +3 -1
- package/dist/pdf/index.d.ts +1 -1
- package/dist/pdf/index.js +3 -3
- package/dist/plainHtmlIcons-KBSIJ5EN.js +62 -0
- package/dist/pptx/index.js +2 -2
- package/dist/readers-3P5A6A2A.js +17 -0
- package/dist/registry/index.js +1 -1
- package/package.json +2 -2
- /package/dist/{chunk-LBXBRFBZ.js → chunk-DDMPZZJF.js} +0 -0
|
@@ -55,8 +55,9 @@ import {
|
|
|
55
55
|
resolveTarget
|
|
56
56
|
} from "./chunk-S5PCVMKU.js";
|
|
57
57
|
import {
|
|
58
|
-
renumberFootnotes
|
|
59
|
-
|
|
58
|
+
renumberFootnotes,
|
|
59
|
+
withoutBlockTags
|
|
60
|
+
} from "./chunk-DTJQK7U7.js";
|
|
60
61
|
import {
|
|
61
62
|
buildContainer
|
|
62
63
|
} from "./chunk-IIQYS2YH.js";
|
|
@@ -65,7 +66,7 @@ import {
|
|
|
65
66
|
fontAwesomeFaces,
|
|
66
67
|
fontAwesomeGlyph,
|
|
67
68
|
obfuscateDocxFont
|
|
68
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-DDMPZZJF.js";
|
|
69
70
|
import {
|
|
70
71
|
authoredImageSize,
|
|
71
72
|
extToMime,
|
|
@@ -214,8 +215,9 @@ function pointsToTwips(points) {
|
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
// src/docx/export.ts
|
|
217
|
-
async function markdownDocToDocx(
|
|
218
|
+
async function markdownDocToDocx(source, options = {}) {
|
|
218
219
|
options.signal?.throwIfAborted();
|
|
220
|
+
const doc = withoutBlockTags(source);
|
|
219
221
|
const resolvedOptions = options.themeId !== void 0 ? options : { ...options, themeId: readFrontmatterThemeId(doc.frontmatter) };
|
|
220
222
|
const ctx = new ExportContext(resolvedOptions, doc);
|
|
221
223
|
const stories = partitionDocumentStories(doc.children);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/outside-in/layout.ts
|
|
2
2
|
var OUTSIDE_IN_FORMAT_IDS = ["html", "docx", "pdf", "pptx", "xlsx", "csv"];
|
|
3
|
+
var OUTSIDE_IN_OUTPUT_TEMPLATE_KEY = "squisq-output-template";
|
|
3
4
|
var OUTSIDE_IN_FORMAT_SET = new Set(OUTSIDE_IN_FORMAT_IDS);
|
|
4
5
|
function normalizePath(path) {
|
|
5
6
|
const slash = path.replace(/\\/g, "/");
|
|
@@ -83,6 +84,7 @@ function chooseOutsideInMarkdownPath(layout, paths) {
|
|
|
83
84
|
|
|
84
85
|
export {
|
|
85
86
|
OUTSIDE_IN_FORMAT_IDS,
|
|
87
|
+
OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
|
|
86
88
|
resolveOutsideInLayout,
|
|
87
89
|
isOutsideInTargetPath,
|
|
88
90
|
chooseOutsideInMarkdownPath
|
|
@@ -251,7 +251,7 @@ async function collectContainerAssets(container, pattern, signal, flattenBasenam
|
|
|
251
251
|
async function collectContainerImages(container, signal) {
|
|
252
252
|
return collectContainerAssets(container, IMAGE_ASSET_RE, signal);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function dataReferenceSources(doc) {
|
|
255
255
|
const srcs = /* @__PURE__ */ new Set();
|
|
256
256
|
const visit = (blocks) => {
|
|
257
257
|
for (const block of blocks) {
|
|
@@ -261,10 +261,38 @@ function dataReferenceWarnings(doc, formatLabel) {
|
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
263
|
visit(doc.blocks);
|
|
264
|
-
return
|
|
265
|
-
|
|
264
|
+
return srcs;
|
|
265
|
+
}
|
|
266
|
+
function dataReferenceWarnings(doc, formatLabel) {
|
|
267
|
+
return [...dataReferenceSources(doc)].map(
|
|
268
|
+
(src) => `${formatLabel} cannot embed the data sidecar "${src}"; the export shows its first rows and the link will not resolve outside the source container.`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
async function markdownWithDataPreview(input, warnings) {
|
|
272
|
+
const markdownDoc = await markdownOf(input);
|
|
273
|
+
if (dataReferenceSources(input.doc).size === 0) return markdownDoc;
|
|
274
|
+
const { materializeDataReferences, DATA_PREVIEW_ROWS } = await import("./materialize-ICXNO4S4.js");
|
|
275
|
+
return materializeDataReferences(
|
|
276
|
+
markdownDoc,
|
|
277
|
+
input.container,
|
|
278
|
+
(message) => warnings.push(message),
|
|
279
|
+
{ maxRows: DATA_PREVIEW_ROWS }
|
|
266
280
|
);
|
|
267
281
|
}
|
|
282
|
+
async function docWithDataPreview(input, warnings) {
|
|
283
|
+
if (dataReferenceSources(input.doc).size === 0) return input.doc;
|
|
284
|
+
const [{ resolveDataReferences }, { defaultDataReaders }] = await Promise.all([
|
|
285
|
+
import("@bendyline/squisq/doc"),
|
|
286
|
+
import("./readers-3P5A6A2A.js")
|
|
287
|
+
]);
|
|
288
|
+
const { doc, diagnostics } = await resolveDataReferences(input.doc, input.container, {
|
|
289
|
+
readers: defaultDataReaders()
|
|
290
|
+
});
|
|
291
|
+
for (const diagnostic of diagnostics) {
|
|
292
|
+
if (diagnostic.severity !== "info") warnings.push(diagnostic.message);
|
|
293
|
+
}
|
|
294
|
+
return doc;
|
|
295
|
+
}
|
|
268
296
|
async function collectContainerDocxImages(container, signal) {
|
|
269
297
|
const images = await collectContainerImages(container, signal);
|
|
270
298
|
const { extToMime } = await import("./images-PQCYRJJ5.js");
|
|
@@ -351,7 +379,8 @@ function defaultFormats() {
|
|
|
351
379
|
async exportDoc(input, options) {
|
|
352
380
|
const { markdownDocToDocx } = await import("./docx/index.js");
|
|
353
381
|
const raw = optionsFor(options, "docx");
|
|
354
|
-
const
|
|
382
|
+
const warnings = [];
|
|
383
|
+
const markdownDoc = await markdownWithDataPreview(input, warnings);
|
|
355
384
|
const containerImages = await collectContainerDocxImages(input.container, options.signal);
|
|
356
385
|
const images = new Map([...containerImages, ...raw.images ?? /* @__PURE__ */ new Map()]);
|
|
357
386
|
const buf = await markdownDocToDocx(markdownDoc, {
|
|
@@ -361,7 +390,10 @@ function defaultFormats() {
|
|
|
361
390
|
themeRegistry: options.themeRegistry ?? raw.themeRegistry,
|
|
362
391
|
images
|
|
363
392
|
});
|
|
364
|
-
return ok(await toBytes(buf), MIME.docx,
|
|
393
|
+
return ok(await toBytes(buf), MIME.docx, [
|
|
394
|
+
...markdownFidelityWarnings(markdownDoc, "docx"),
|
|
395
|
+
...warnings
|
|
396
|
+
]);
|
|
365
397
|
}
|
|
366
398
|
};
|
|
367
399
|
const pdf = {
|
|
@@ -381,8 +413,8 @@ function defaultFormats() {
|
|
|
381
413
|
async exportDoc(input, options) {
|
|
382
414
|
const { markdownDocToPdf } = await import("./pdf/index.js");
|
|
383
415
|
const raw = optionsFor(options, "pdf");
|
|
384
|
-
const markdownDoc = await markdownOf(input);
|
|
385
416
|
const pdfWarnings = [];
|
|
417
|
+
const markdownDoc = await markdownWithDataPreview(input, pdfWarnings);
|
|
386
418
|
const containerImages = await collectContainerDocxImages(input.container, options.signal);
|
|
387
419
|
const images = new Map([...containerImages, ...raw.images ?? /* @__PURE__ */ new Map()]);
|
|
388
420
|
const buf = await markdownDocToPdf(markdownDoc, {
|
|
@@ -420,7 +452,8 @@ function defaultFormats() {
|
|
|
420
452
|
const containerImages = await collectContainerImages(input.container, options.signal);
|
|
421
453
|
const images = new Map([...containerImages, ...raw.images ?? /* @__PURE__ */ new Map()]);
|
|
422
454
|
const pptxWarnings = [];
|
|
423
|
-
const
|
|
455
|
+
const doc = await docWithDataPreview(input, pptxWarnings);
|
|
456
|
+
const buf = await docToPptx(doc, {
|
|
424
457
|
...raw,
|
|
425
458
|
...options.title !== void 0 ? { title: options.title } : {},
|
|
426
459
|
themeId: resolveThemeId(input, options),
|
|
@@ -456,7 +489,7 @@ function defaultFormats() {
|
|
|
456
489
|
},
|
|
457
490
|
async exportDoc(input, options) {
|
|
458
491
|
const { markdownDocToXlsx } = await import("./xlsx/index.js");
|
|
459
|
-
const { materializeDataReferences } = await import("./materialize-
|
|
492
|
+
const { materializeDataReferences } = await import("./materialize-ICXNO4S4.js");
|
|
460
493
|
const warnings = [];
|
|
461
494
|
const markdownDoc = await materializeDataReferences(
|
|
462
495
|
await markdownOf(input),
|
|
@@ -495,7 +528,7 @@ function defaultFormats() {
|
|
|
495
528
|
},
|
|
496
529
|
async exportDoc(input, options) {
|
|
497
530
|
const { markdownDocToCsv } = await import("./csv/index.js");
|
|
498
|
-
const { materializeDataReferences } = await import("./materialize-
|
|
531
|
+
const { materializeDataReferences } = await import("./materialize-ICXNO4S4.js");
|
|
499
532
|
const warnings = [];
|
|
500
533
|
const markdownDoc = await materializeDataReferences(
|
|
501
534
|
await markdownOf(input),
|
|
@@ -528,9 +561,11 @@ function defaultFormats() {
|
|
|
528
561
|
// so there is nothing to extract into a container this wave.
|
|
529
562
|
async exportDoc(input, options) {
|
|
530
563
|
const raw = optionsFor(options, "html");
|
|
564
|
+
const warnings = [];
|
|
565
|
+
const doc = await docWithDataPreview(input, warnings);
|
|
531
566
|
if (raw.playerScriptPath) {
|
|
532
567
|
const { generateExternalHtml } = await import("./html/index.js");
|
|
533
|
-
const htmlText2 = generateExternalHtml(
|
|
568
|
+
const htmlText2 = generateExternalHtml(doc, {
|
|
534
569
|
...raw,
|
|
535
570
|
playerScriptPath: raw.playerScriptPath,
|
|
536
571
|
title: options.title ?? input.baseName,
|
|
@@ -538,7 +573,7 @@ function defaultFormats() {
|
|
|
538
573
|
themeId: resolveThemeId(input, options),
|
|
539
574
|
themeRegistry: options.themeRegistry ?? raw.themeRegistry
|
|
540
575
|
});
|
|
541
|
-
return ok(new TextEncoder().encode(htmlText2), MIME.html);
|
|
576
|
+
return ok(new TextEncoder().encode(htmlText2), MIME.html, warnings);
|
|
542
577
|
}
|
|
543
578
|
const playerScript = await requirePlayerScript(options, "html");
|
|
544
579
|
const { docToHtml } = await import("./html/index.js");
|
|
@@ -550,7 +585,7 @@ function defaultFormats() {
|
|
|
550
585
|
false
|
|
551
586
|
);
|
|
552
587
|
const images = new Map([...containerImages, ...media, ...raw.images ?? /* @__PURE__ */ new Map()]);
|
|
553
|
-
const htmlText = docToHtml(
|
|
588
|
+
const htmlText = docToHtml(doc, {
|
|
554
589
|
...raw,
|
|
555
590
|
playerScript,
|
|
556
591
|
images,
|
|
@@ -560,11 +595,10 @@ function defaultFormats() {
|
|
|
560
595
|
themeId: resolveThemeId(input, options),
|
|
561
596
|
themeRegistry: options.themeRegistry ?? raw.themeRegistry
|
|
562
597
|
});
|
|
563
|
-
return ok(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
);
|
|
598
|
+
return ok(new TextEncoder().encode(htmlText), MIME.html, [
|
|
599
|
+
...dataReferenceWarnings(input.doc, "Single-file HTML"),
|
|
600
|
+
...warnings
|
|
601
|
+
]);
|
|
568
602
|
}
|
|
569
603
|
};
|
|
570
604
|
const htmlzip = {
|
|
@@ -596,7 +630,9 @@ function defaultFormats() {
|
|
|
596
630
|
...media,
|
|
597
631
|
...raw.images ?? /* @__PURE__ */ new Map()
|
|
598
632
|
]);
|
|
599
|
-
const
|
|
633
|
+
const warnings = [];
|
|
634
|
+
const doc = await docWithDataPreview(input, warnings);
|
|
635
|
+
const blob = await docToHtmlZip(doc, {
|
|
600
636
|
...raw,
|
|
601
637
|
playerScript,
|
|
602
638
|
images,
|
|
@@ -606,7 +642,7 @@ function defaultFormats() {
|
|
|
606
642
|
themeId: resolveThemeId(input, options),
|
|
607
643
|
themeRegistry: options.themeRegistry ?? raw.themeRegistry
|
|
608
644
|
});
|
|
609
|
-
return ok(await toBytes(blob), MIME.zip);
|
|
645
|
+
return ok(await toBytes(blob), MIME.zip, warnings);
|
|
610
646
|
}
|
|
611
647
|
};
|
|
612
648
|
const epub = {
|
|
@@ -618,7 +654,8 @@ function defaultFormats() {
|
|
|
618
654
|
async exportDoc(input, options) {
|
|
619
655
|
const { markdownDocToEpub } = await import("./epub/index.js");
|
|
620
656
|
const raw = optionsFor(options, "epub");
|
|
621
|
-
const
|
|
657
|
+
const warnings = [];
|
|
658
|
+
const markdownDoc = await markdownWithDataPreview(input, warnings);
|
|
622
659
|
const containerImages = await collectContainerImages(input.container, options.signal);
|
|
623
660
|
const images = new Map([...containerImages, ...raw.images ?? /* @__PURE__ */ new Map()]);
|
|
624
661
|
const buf = await markdownDocToEpub(markdownDoc, {
|
|
@@ -630,7 +667,8 @@ function defaultFormats() {
|
|
|
630
667
|
});
|
|
631
668
|
return ok(await toBytes(buf), MIME.epub, [
|
|
632
669
|
...markdownFidelityWarnings(markdownDoc, "epub"),
|
|
633
|
-
...dataReferenceWarnings(input.doc, "EPUB")
|
|
670
|
+
...dataReferenceWarnings(input.doc, "EPUB"),
|
|
671
|
+
...warnings
|
|
634
672
|
]);
|
|
635
673
|
}
|
|
636
674
|
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultDataReaders
|
|
3
|
+
} from "./chunk-5HUHSLGA.js";
|
|
4
|
+
|
|
5
|
+
// src/data/materialize.ts
|
|
6
|
+
import {
|
|
7
|
+
isDataFilePath
|
|
8
|
+
} from "@bendyline/squisq/doc";
|
|
9
|
+
function tableRow(cells) {
|
|
10
|
+
return {
|
|
11
|
+
type: "tableRow",
|
|
12
|
+
children: cells.map((value) => ({
|
|
13
|
+
type: "tableCell",
|
|
14
|
+
children: value ? [{ type: "text", value }] : []
|
|
15
|
+
}))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function count(n) {
|
|
19
|
+
return n.toLocaleString("en-US");
|
|
20
|
+
}
|
|
21
|
+
function extensionOf(path) {
|
|
22
|
+
const base = path.split("/").pop() ?? path;
|
|
23
|
+
const dot = base.lastIndexOf(".");
|
|
24
|
+
return dot > 0 ? base.slice(dot + 1).toLowerCase() : "";
|
|
25
|
+
}
|
|
26
|
+
var DATA_PREVIEW_ROWS = 100;
|
|
27
|
+
async function materializeDataReferences(markdownDoc, container, onWarning, options = {}) {
|
|
28
|
+
const readers = defaultDataReaders();
|
|
29
|
+
const children = [];
|
|
30
|
+
let changed = false;
|
|
31
|
+
for (const [index, node] of markdownDoc.children.entries()) {
|
|
32
|
+
children.push(node);
|
|
33
|
+
if (node.type !== "heading") continue;
|
|
34
|
+
const params = node.templateAnnotation?.params;
|
|
35
|
+
const src = params?.src;
|
|
36
|
+
if (!src || !isDataFilePath(src)) continue;
|
|
37
|
+
if (markdownDoc.children[index + 1]?.type === "table") continue;
|
|
38
|
+
const label = params?.sheet && params?.anchor ? `${params.sheet}!${params.anchor}` : src;
|
|
39
|
+
if (!container) {
|
|
40
|
+
onWarning?.(
|
|
41
|
+
`Data reference "${src}" could not be embedded: the export has no source container to read it from.`
|
|
42
|
+
);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const ext = extensionOf(src);
|
|
46
|
+
const reader = readers.find((r) => r.extensions.includes(ext));
|
|
47
|
+
if (!reader) {
|
|
48
|
+
onWarning?.(`Data reference "${src}" could not be embedded: no reader for ".${ext}".`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const previewRows = Number.parseInt(params?.previewRows ?? "", 10);
|
|
52
|
+
const maxRows = options.maxRows === void 0 ? Number.POSITIVE_INFINITY : previewRows > 0 ? previewRows : options.maxRows;
|
|
53
|
+
const readOptions = {
|
|
54
|
+
maxRows,
|
|
55
|
+
...params?.sheet ? { sheet: params.sheet } : {},
|
|
56
|
+
...params?.anchor ? { anchor: params.anchor } : {},
|
|
57
|
+
...params?.headerRow !== void 0 ? { headerRow: params.headerRow !== "false" } : {},
|
|
58
|
+
// Exports honor the author's curated view: the sort/filter params
|
|
59
|
+
// shape the embedded full table exactly as they shape previews.
|
|
60
|
+
...params?.sort ? { sort: params.sort } : {},
|
|
61
|
+
...params?.filter ? { filter: params.filter } : {}
|
|
62
|
+
};
|
|
63
|
+
const cacheKey = [
|
|
64
|
+
src,
|
|
65
|
+
readOptions.sheet ?? "",
|
|
66
|
+
readOptions.anchor ?? "",
|
|
67
|
+
String(readOptions.headerRow ?? ""),
|
|
68
|
+
readOptions.sort ?? "",
|
|
69
|
+
readOptions.filter ?? "",
|
|
70
|
+
String(maxRows)
|
|
71
|
+
].join("\0");
|
|
72
|
+
let pending = options.tableCache?.get(cacheKey);
|
|
73
|
+
if (!pending) {
|
|
74
|
+
let bytes = null;
|
|
75
|
+
try {
|
|
76
|
+
bytes = await container.readFile(src);
|
|
77
|
+
} catch {
|
|
78
|
+
bytes = null;
|
|
79
|
+
}
|
|
80
|
+
if (!bytes) {
|
|
81
|
+
onWarning?.(`Data reference "${src}" could not be embedded: file not found in container.`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
pending = reader.read(bytes, readOptions);
|
|
85
|
+
options.tableCache?.set(cacheKey, pending);
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const table = await pending;
|
|
89
|
+
const mdTable = {
|
|
90
|
+
type: "table",
|
|
91
|
+
children: [tableRow(table.headers), ...table.rows.map(tableRow)]
|
|
92
|
+
};
|
|
93
|
+
children.push(mdTable);
|
|
94
|
+
if (table.totalRows > table.rows.length) {
|
|
95
|
+
children.push({
|
|
96
|
+
type: "paragraph",
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
type: "emphasis",
|
|
100
|
+
children: [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
value: `Showing ${count(table.rows.length)} of ${count(table.totalRows)} rows.`
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
changed = true;
|
|
111
|
+
if (ext === "xlsx") {
|
|
112
|
+
onWarning?.(
|
|
113
|
+
`Region ${label} exported as values; formulas in the sidecar workbook were not carried over.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
onWarning?.(
|
|
118
|
+
`Data reference "${src}" could not be embedded: ${err instanceof Error ? err.message : String(err)}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return changed ? { ...markdownDoc, children } : markdownDoc;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
DATA_PREVIEW_ROWS,
|
|
127
|
+
materializeDataReferences
|
|
128
|
+
};
|
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
} from "./chunk-JU2RHXUB.js";
|
|
15
15
|
import {
|
|
16
16
|
FootnoteIndex,
|
|
17
|
-
footnoteIds
|
|
18
|
-
|
|
17
|
+
footnoteIds,
|
|
18
|
+
withoutBlockTags
|
|
19
|
+
} from "./chunk-DTJQK7U7.js";
|
|
19
20
|
import {
|
|
20
21
|
collectInlineIconFamilies,
|
|
21
22
|
fontAwesomeFaces,
|
|
22
23
|
fontAwesomeGlyph
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-DDMPZZJF.js";
|
|
24
25
|
import {
|
|
25
26
|
imageSizeAttributes
|
|
26
27
|
} from "./chunk-JZR32FON.js";
|
|
@@ -30,8 +31,9 @@ import JSZip from "jszip";
|
|
|
30
31
|
import { resolveFontFamily } from "@bendyline/squisq/schemas";
|
|
31
32
|
import { resolveThemeForDoc } from "@bendyline/squisq/doc";
|
|
32
33
|
import { isHtmlLineBreak, readFrontmatterThemeId, sanitizeUrl } from "@bendyline/squisq/markdown";
|
|
33
|
-
async function markdownDocToEpub(
|
|
34
|
+
async function markdownDocToEpub(authoredDoc, options = {}) {
|
|
34
35
|
options.signal?.throwIfAborted();
|
|
36
|
+
const sourceDoc = withoutBlockTags(authoredDoc);
|
|
35
37
|
const themeId = options.themeId ?? readFrontmatterThemeId(sourceDoc.frontmatter);
|
|
36
38
|
const islandColor = themeId ? resolveThemeForDoc(sourceDoc, themeId, options.themeRegistry).colors.text : void 0;
|
|
37
39
|
const { doc, images: islandImages } = svgIslandsAsImages(sourceDoc, { color: islandColor });
|
package/dist/data/index.d.ts
CHANGED
|
@@ -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
|
|
37
|
-
*
|
|
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 };
|
package/dist/data/index.js
CHANGED
|
@@ -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-
|
|
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,
|
package/dist/diagrams/index.d.ts
CHANGED
|
@@ -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
|
|
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,
|
|
37
|
-
*
|
|
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`, `
|
|
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 };
|