@bendyline/squisq 2.13.13 → 2.13.15

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/{Doc-BhvotZx_.d.ts → Doc-C_Sh49ot.d.ts} +59 -6
  2. package/dist/{ImageEditDoc-D8hYio6b.d.ts → ImageEditDoc-Sqw3Tw-R.d.ts} +1 -1
  3. package/dist/{chunk-OIQ2GO2O.js → chunk-2CB37BOU.js} +1 -1
  4. package/dist/{chunk-CTT4XAGO.js → chunk-4HQ7QZKB.js} +2289 -630
  5. package/dist/chunk-C7DKMO4H.js +88 -0
  6. package/dist/{chunk-C4SB3NN4.js → chunk-DDJHIZED.js} +1 -1
  7. package/dist/{chunk-TCGGJUKC.js → chunk-FYP7GNER.js} +93 -15
  8. package/dist/chunk-N3FQSUVT.js +515 -0
  9. package/dist/{chunk-SGNWO7OF.js → chunk-OFE5RZWW.js} +490 -24
  10. package/dist/{chunk-YQQWE4HG.js → chunk-OJCAKUHW.js} +192 -260
  11. package/dist/{chunk-7MS26OXD.js → chunk-UDPPWYYM.js} +6 -0
  12. package/dist/{chunk-5DFFVW75.js → chunk-Y34KYMAS.js} +1 -1
  13. package/dist/doc/index.d.ts +337 -22
  14. package/dist/doc/index.js +56 -8
  15. package/dist/fence/index.d.ts +1 -1
  16. package/dist/generate/index.d.ts +1 -1
  17. package/dist/imageEdit/index.d.ts +3 -3
  18. package/dist/index.d.ts +8 -8
  19. package/dist/index.js +127 -21
  20. package/dist/jsonForm/index.d.ts +1 -1
  21. package/dist/markdown/index.js +3 -3
  22. package/dist/{materializePageSection-CWxou4mX.d.ts → materializePageSection-Dmf-rf1b.d.ts} +121 -8
  23. package/dist/mediaEdit/index.d.ts +2 -2
  24. package/dist/narration/index.d.ts +1 -1
  25. package/dist/narration/index.js +4 -4
  26. package/dist/recommend/index.d.ts +129 -2
  27. package/dist/recommend/index.js +11 -3
  28. package/dist/schemas/index.d.ts +4 -4
  29. package/dist/{themeLibrary-BIYE6aLw.d.ts → themeLibrary-B4VLovhW.d.ts} +1 -1
  30. package/dist/timing/index.d.ts +66 -2
  31. package/dist/timing/index.js +12 -0
  32. package/dist/transform/index.d.ts +173 -16
  33. package/dist/transform/index.js +55 -16
  34. package/package.json +1 -1
  35. package/dist/chunk-FCB6JLWB.js +0 -125
@@ -0,0 +1,88 @@
1
+ // src/timing/captionFiles.ts
2
+ function cuesOf(track, offset) {
3
+ const cues = (track?.phrases ?? []).map((phrase) => ({
4
+ start: Math.max(0, phrase.startTime + offset),
5
+ end: Math.max(0, phrase.endTime + offset),
6
+ text: phrase.text.replace(/\s+/gu, " ").trim()
7
+ })).filter((cue) => cue.text && Number.isFinite(cue.start) && Number.isFinite(cue.end)).sort((a, b) => a.start - b.start);
8
+ return cues.map((cue, index) => {
9
+ const next = cues[index + 1];
10
+ return next && cue.end > next.start ? { ...cue, end: next.start } : cue;
11
+ }).filter((cue) => cue.end > cue.start);
12
+ }
13
+ function timestamp(seconds, separator) {
14
+ const total = Math.max(0, Math.round(seconds * 1e3));
15
+ const pad = (value, width = 2) => String(value).padStart(width, "0");
16
+ return `${pad(Math.floor(total / 36e5))}:${pad(Math.floor(total / 6e4) % 60)}:${pad(Math.floor(total / 1e3) % 60)}${separator}${pad(total % 1e3, 3)}`;
17
+ }
18
+ function formatCaptionsSrt(track, options = {}) {
19
+ return cuesOf(track, options.offset ?? 0).map(
20
+ (cue, index) => `${index + 1}
21
+ ${timestamp(cue.start, ",")} --> ${timestamp(cue.end, ",")}
22
+ ${cue.text}
23
+ `
24
+ ).join("\n");
25
+ }
26
+ function formatCaptionsVtt(track, options = {}) {
27
+ const escape = (text) => text.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/-->/gu, "--&gt;");
28
+ const cues = cuesOf(track, options.offset ?? 0).map(
29
+ (cue) => `${timestamp(cue.start, ".")} --> ${timestamp(cue.end, ".")}
30
+ ${escape(cue.text)}
31
+ `
32
+ );
33
+ return ["WEBVTT\n", ...cues].join("\n");
34
+ }
35
+ function docChapters(doc, options = {}) {
36
+ const offset = options.offset ?? 0;
37
+ const minDuration = options.minDuration ?? 10;
38
+ const blocks = Array.isArray(doc) ? doc : doc.blocks;
39
+ const chapters = [];
40
+ const visit = (list) => {
41
+ for (const block of list) {
42
+ const title = (block.title ?? "").replace(/\s+/gu, " ").trim();
43
+ const startTime = Math.max(0, (block.startTime ?? 0) + offset);
44
+ const previous = chapters[chapters.length - 1];
45
+ const opens = !previous || title !== previous.title && startTime - previous.startTime >= minDuration;
46
+ if (title && (block.duration ?? 0) > 0 && Number.isFinite(startTime) && opens)
47
+ chapters.push({ startTime, title });
48
+ if (block.children?.length) visit(block.children);
49
+ }
50
+ };
51
+ visit(blocks);
52
+ if (chapters.length) chapters[0] = { ...chapters[0], startTime: 0 };
53
+ return chapters;
54
+ }
55
+ function formatChaptersFfmetadata(chapters, duration) {
56
+ const escape = (text) => text.replace(/[=;#\\\n]/gu, (match) => `\\${match}`);
57
+ const lines = [";FFMETADATA1"];
58
+ chapters.forEach((chapter, index) => {
59
+ const end = chapters[index + 1]?.startTime ?? Math.max(duration, chapter.startTime);
60
+ lines.push(
61
+ "[CHAPTER]",
62
+ "TIMEBASE=1/1000",
63
+ `START=${Math.round(chapter.startTime * 1e3)}`,
64
+ `END=${Math.round(end * 1e3)}`,
65
+ `title=${escape(chapter.title)}`
66
+ );
67
+ });
68
+ return `${lines.join("\n")}
69
+ `;
70
+ }
71
+ function formatChaptersText(chapters) {
72
+ const long = chapters.some((chapter) => chapter.startTime >= 3600);
73
+ const stamp = (seconds) => {
74
+ const total = Math.floor(seconds);
75
+ const [h, m, s] = [Math.floor(total / 3600), Math.floor(total / 60) % 60, total % 60];
76
+ const two = (value) => String(value).padStart(2, "0");
77
+ return long ? `${h}:${two(m)}:${two(s)}` : `${m}:${two(s)}`;
78
+ };
79
+ return chapters.map((chapter) => `${stamp(chapter.startTime)} ${chapter.title}`).join("\n");
80
+ }
81
+
82
+ export {
83
+ formatCaptionsSrt,
84
+ formatCaptionsVtt,
85
+ docChapters,
86
+ formatChaptersFfmetadata,
87
+ formatChaptersText
88
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isReservedAnnotationToken
3
- } from "./chunk-7MS26OXD.js";
3
+ } from "./chunk-UDPPWYYM.js";
4
4
  import {
5
5
  coerceAnnotationValues,
6
6
  matchTrailingPandocAttr,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-HKHOFTGM.js";
4
4
  import {
5
5
  applySavedPresentation
6
- } from "./chunk-YQQWE4HG.js";
6
+ } from "./chunk-OJCAKUHW.js";
7
7
  import {
8
8
  SHAPE_NAMES,
9
9
  buildChartData,
@@ -28,11 +28,10 @@ import {
28
28
  placeLayersInRect,
29
29
  readCustomThemesFromFrontmatter,
30
30
  resolvePersistentLayers,
31
- splitConceptItem,
32
31
  templateRegistry,
33
32
  writeCustomTemplatesToFrontmatter,
34
33
  writeCustomThemesToFrontmatter
35
- } from "./chunk-CTT4XAGO.js";
34
+ } from "./chunk-4HQ7QZKB.js";
36
35
  import {
37
36
  ASCII_TREE_VOCAB,
38
37
  ASCII_VOCAB,
@@ -43,6 +42,7 @@ import {
43
42
  cellWidth,
44
43
  deriveTemplateInputs,
45
44
  detectAsciiDiagram,
45
+ extractBlockquote,
46
46
  extractBodyPlainText,
47
47
  extractRichListItems,
48
48
  isHoriz,
@@ -52,10 +52,12 @@ import {
52
52
  isVert,
53
53
  parseAsciiDiagram,
54
54
  parseStandaloneAnnotation,
55
+ splitConceptItem,
56
+ splitStatItem,
55
57
  toCells,
56
58
  toGrid,
57
59
  traceBoxes
58
- } from "./chunk-SGNWO7OF.js";
60
+ } from "./chunk-OFE5RZWW.js";
59
61
  import {
60
62
  iconMarker
61
63
  } from "./chunk-7ZAAICW4.js";
@@ -88,19 +90,20 @@ import {
88
90
  } from "./chunk-L7QZORLB.js";
89
91
  import {
90
92
  parseMarkdown
91
- } from "./chunk-C4SB3NN4.js";
93
+ } from "./chunk-DDJHIZED.js";
92
94
  import {
93
95
  TABLE_FED_TEMPLATES,
94
96
  TEMPLATE_ALIASES,
95
97
  isContainerTemplate,
96
98
  resolveTemplateName
97
- } from "./chunk-7MS26OXD.js";
99
+ } from "./chunk-UDPPWYYM.js";
98
100
  import {
99
101
  KNOWN_BLOCK_META_KEYS,
100
102
  coerceAnnotationValues,
101
103
  extractPlainText,
102
104
  findBlockVideoEmbed,
103
105
  getChildren,
106
+ isHtmlLineBreak,
104
107
  isVideoEmbedUrl,
105
108
  parseHtmlToNodes,
106
109
  parseVideoEmbedUrl,
@@ -571,6 +574,21 @@ function resolveCoverSlideSettings(frontmatter, overrides = {}) {
571
574
  };
572
575
  }
573
576
 
577
+ // src/doc/coverLeadingBlock.ts
578
+ function coverRepeatsLeadingBlock(doc) {
579
+ const cover = doc.startBlock;
580
+ const first = doc.blocks[0];
581
+ if (!cover || !first?.sourceHeading) return false;
582
+ if (first.sourceHeading.templateAnnotation?.template || first.promotedBodyAnnotation) {
583
+ return false;
584
+ }
585
+ if (first.title?.trim() !== cover.title.trim()) return false;
586
+ if ((first.layers?.length ?? 0) > 0 || (first.media?.length ?? 0) > 0) return false;
587
+ const contents = first.contents ?? [];
588
+ if (contents.length === 0) return true;
589
+ return contents.length === 1 && contents[0].type === "paragraph" && !!cover.subtitle && extractPlainText(contents[0]).trim() === cover.subtitle.trim();
590
+ }
591
+
574
592
  // src/doc/docToMarkdown.ts
575
593
  var TRANSITION_PARAM_KEYS = ["transition", "transitionDuration", "transitionDirection"];
576
594
  var DEFAULT_TEMPLATE = "sectionHeader";
@@ -838,8 +856,11 @@ function extractRichText(node) {
838
856
  if ("value" in node && typeof node.value === "string") {
839
857
  return node.value;
840
858
  }
859
+ if (node.type === "break") return "\n";
860
+ if (node.type === "htmlInline" && isHtmlLineBreak(node.rawHtml))
861
+ return "\n";
841
862
  const children = getChildren(node);
842
- const separator = node.type === "list" || node.type === "listItem" ? "\n" : "";
863
+ const separator = node.type === "list" || node.type === "listItem" || node.type === "table" ? "\n" : node.type === "tableRow" ? " " : "";
843
864
  return children.map(extractRichText).join(separator);
844
865
  }
845
866
  function extractBodyText(contents) {
@@ -923,14 +944,20 @@ function collectAllDocImages(blocks) {
923
944
  }
924
945
  function getTemplateDefaults(templateName, headingText, block) {
925
946
  const body = extractBodyText(block.contents);
947
+ const hasBody2 = (block.contents?.length ?? 0) > 0;
926
948
  switch (templateName) {
927
949
  case "statHighlight":
928
950
  return deriveTemplateInputs(templateName, headingText, block.contents) ?? {
929
951
  stat: headingText,
930
952
  description: body || headingText
931
953
  };
932
- case "quote":
933
- return { quote: body || headingText };
954
+ case "quote": {
955
+ const quoted = extractBlockquote(block.contents);
956
+ return quoted.text ? {
957
+ quote: quoted.text,
958
+ ...quoted.attribution ? { attribution: quoted.attribution } : {}
959
+ } : { quote: body || headingText };
960
+ }
934
961
  case "fullBleedQuote":
935
962
  case "pullQuote":
936
963
  return deriveTemplateInputs(templateName, headingText, block.contents) ?? {
@@ -939,14 +966,27 @@ function getTemplateDefaults(templateName, headingText, block) {
939
966
  case "factCard":
940
967
  return { fact: headingText, explanation: body || headingText };
941
968
  case "comparisonBar":
942
- return { leftLabel: "A", leftValue: 60, rightLabel: "B", rightValue: 40 };
969
+ return hasBody2 ? {} : { leftLabel: "A", leftValue: 60, rightLabel: "B", rightValue: 40 };
943
970
  case "list":
944
- return deriveTemplateInputs(templateName, headingText, block.contents) ?? {
945
- items: ["Item 1", "Item 2", "Item 3"]
946
- };
971
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? (hasBody2 ? {} : { items: ["Item 1", "Item 2", "Item 3"] });
972
+ case "transcript":
973
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? {};
974
+ case "twoColumn":
975
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? {};
947
976
  case "videoWithCaption":
948
977
  case "videoPullQuote":
949
978
  return deriveTemplateInputs(templateName, headingText, block.contents) ?? {};
979
+ case "cards":
980
+ case "process":
981
+ case "cycle":
982
+ case "layers":
983
+ case "stats":
984
+ case "pyramid":
985
+ case "funnel":
986
+ case "hub":
987
+ case "venn":
988
+ case "matrix":
989
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? {};
950
990
  case "definitionCard":
951
991
  return { term: headingText, definition: body || headingText };
952
992
  case "dateEvent":
@@ -1261,6 +1301,10 @@ function bodyRichText(input) {
1261
1301
  const text = contents.map((node) => extractPlainText(node)).join("\n").trim();
1262
1302
  return text ? { text, markdown: contents } : void 0;
1263
1303
  }
1304
+ function asProse(input, heading) {
1305
+ const title2 = input.title ?? heading;
1306
+ return { kind: "prose", slots: { title: title2, body: bodyRichText(input) } };
1307
+ }
1264
1308
  function accentImageMedia(accent) {
1265
1309
  if (!accent?.src) return void 0;
1266
1310
  return {
@@ -1345,6 +1389,7 @@ var statHighlight = (input) => {
1345
1389
  kind: "stat-band",
1346
1390
  variant: "single",
1347
1391
  slots: {
1392
+ title: s.headline,
1348
1393
  items: [{ value: s.stat, title: s.description, body: s.detail }],
1349
1394
  media: accentImageMedia(s.accentImage)
1350
1395
  },
@@ -1380,6 +1425,7 @@ var factCard = (input) => {
1380
1425
  };
1381
1426
  var twoColumn = (input) => {
1382
1427
  const t = input;
1428
+ if (!t.left?.label || !t.right?.label) return asProse(input, t.header);
1383
1429
  return {
1384
1430
  kind: "card-grid",
1385
1431
  variant: "two-column",
@@ -1409,6 +1455,7 @@ var dateEvent = (input) => {
1409
1455
  };
1410
1456
  var imageWithCaption = (input) => {
1411
1457
  const i = input;
1458
+ if (!i.imageSrc) return asProse(input, i.caption);
1412
1459
  const media = {
1413
1460
  type: "image",
1414
1461
  src: i.imageSrc,
@@ -1463,6 +1510,7 @@ var fullBleedQuote = (input) => {
1463
1510
  var list = (input) => {
1464
1511
  const l = input;
1465
1512
  const contents = input.contents;
1513
+ if (!l.items?.length) return asProse(input, l.title);
1466
1514
  const richItems = extractRichListItems(contents);
1467
1515
  return {
1468
1516
  kind: "item-list",
@@ -1479,6 +1527,7 @@ var list = (input) => {
1479
1527
  };
1480
1528
  var concept = (input) => {
1481
1529
  const c = input;
1530
+ if (!c.items?.length) return asProse(input, c.title);
1482
1531
  return {
1483
1532
  kind: "item-list",
1484
1533
  slots: {
@@ -1491,6 +1540,22 @@ var concept = (input) => {
1491
1540
  colorScheme: c.colorScheme
1492
1541
  };
1493
1542
  };
1543
+ var stats = (input, ctx) => {
1544
+ const s = input;
1545
+ const items = (s.items ?? []).map((item) => splitStatItem(String(item ?? "")));
1546
+ if (!items.some((item) => item.figure)) return concept(input, ctx);
1547
+ return {
1548
+ kind: "stat-band",
1549
+ variant: "row",
1550
+ slots: {
1551
+ title: s.title,
1552
+ items: items.map(
1553
+ (item) => item.figure ? { value: item.figure, title: item.caption } : { title: item.caption }
1554
+ )
1555
+ },
1556
+ colorScheme: s.colorScheme
1557
+ };
1558
+ };
1494
1559
  var photoGrid = (input) => {
1495
1560
  const p = input;
1496
1561
  const images = p.images ?? [];
@@ -1531,6 +1596,8 @@ var definitionCard = (input) => {
1531
1596
  };
1532
1597
  var comparisonBar = (input) => {
1533
1598
  const c = input;
1599
+ if (!c.leftLabel && !c.rightLabel && !Number.isFinite(c.leftValue) && !Number.isFinite(c.rightValue))
1600
+ return asProse(input);
1534
1601
  return {
1535
1602
  kind: "stat-band",
1536
1603
  variant: "comparison",
@@ -1562,6 +1629,7 @@ var pullQuote = (input) => {
1562
1629
  };
1563
1630
  var videoWithCaption = (input) => {
1564
1631
  const v = input;
1632
+ if (!v.videoSrc) return asProse(input, v.caption);
1565
1633
  if (isVideoEmbedUrl(v.videoSrc)) {
1566
1634
  return {
1567
1635
  kind: "media-figure",
@@ -1667,6 +1735,12 @@ var sectionExtractors = {
1667
1735
  process: concept,
1668
1736
  cycle: concept,
1669
1737
  layers: concept,
1738
+ stats,
1739
+ pyramid: concept,
1740
+ funnel: concept,
1741
+ hub: concept,
1742
+ venn: concept,
1743
+ matrix: concept,
1670
1744
  photoGrid,
1671
1745
  definitionCard,
1672
1746
  comparisonBar,
@@ -4166,11 +4240,14 @@ function shouldTreatAsImplicitGroup(block) {
4166
4240
  const children = block.children ?? [];
4167
4241
  if (children.length === 0) return false;
4168
4242
  if (hasExplicitCardDescendant(block)) return true;
4169
- if (hasBody(block)) return false;
4243
+ const completeCards = children.filter(looksLikeCompleteCard).length;
4244
+ if (hasBody(block)) {
4245
+ return completeCards >= 2 && !children.some(isGenericAnswerBlock);
4246
+ }
4170
4247
  if (children.length === 1) {
4171
4248
  return looksLikeCompleteCard(children[0]) && !isGenericAnswerBlock(children[0]);
4172
4249
  }
4173
- return children.filter(looksLikeCompleteCard).length >= 2;
4250
+ return completeCards >= 2;
4174
4251
  }
4175
4252
  function explanationFor(block) {
4176
4253
  return hasBody(block) ? face(bodyOnly(block)) : void 0;
@@ -6937,6 +7014,7 @@ export {
6937
7014
  DEFAULT_COVER_SLIDE_SETTINGS,
6938
7015
  MAX_COVER_SLIDE_DURATION_SECONDS,
6939
7016
  resolveCoverSlideSettings,
7017
+ coverRepeatsLeadingBlock,
6940
7018
  docToMarkdown,
6941
7019
  previewBlockTemplate,
6942
7020
  documentTitleFromFileName,