@bendyline/squisq 2.11.16 → 2.11.18

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 (37) hide show
  1. package/dist/{Doc-Bd2kdzuy.d.ts → Doc-B6TYHYGc.d.ts} +41 -2
  2. package/dist/{ImageEditDoc-C3HOltpW.d.ts → ImageEditDoc-CN_3Ysj5.d.ts} +1 -1
  3. package/dist/chunk-3XEABCT3.js +114 -0
  4. package/dist/{chunk-WMXQDP2C.js → chunk-7IGKCHDP.js} +352 -17
  5. package/dist/{chunk-C3NAY5YP.js → chunk-A5QJJZ5S.js} +8 -5
  6. package/dist/{chunk-HVJ6VFDX.js → chunk-GB7OFYUK.js} +4 -0
  7. package/dist/{chunk-NC6LD6D3.js → chunk-J4ACZBO4.js} +50 -8
  8. package/dist/{chunk-ANH2OZ2M.js → chunk-LJZHC6GN.js} +146 -11
  9. package/dist/{chunk-IFJPPI63.js → chunk-NM747LUO.js} +829 -298
  10. package/dist/{chunk-GDHXT5Q7.js → chunk-PGWYC3S2.js} +2 -2
  11. package/dist/{chunk-X7BNDUNI.js → chunk-Q6ELOAOQ.js} +383 -1
  12. package/dist/{chunk-IRVXZUVU.js → chunk-RYO4QW6R.js} +2 -4
  13. package/dist/{chunk-TMOHAFYE.js → chunk-WSFXV5BT.js} +17 -0
  14. package/dist/doc/index.d.ts +35 -24
  15. package/dist/doc/index.js +13 -7
  16. package/dist/fence/index.d.ts +1 -1
  17. package/dist/generate/index.d.ts +1 -1
  18. package/dist/imageEdit/index.d.ts +3 -3
  19. package/dist/index.d.ts +7 -7
  20. package/dist/index.js +88 -34
  21. package/dist/jsonForm/index.d.ts +1 -1
  22. package/dist/jsonForm/index.js +1 -1
  23. package/dist/markdown/index.d.ts +170 -4
  24. package/dist/markdown/index.js +24 -4
  25. package/dist/{materializePageSection-FRv9whYy.d.ts → materializePageSection-IYXU3tDN.d.ts} +6 -1
  26. package/dist/mediaEdit/index.d.ts +2 -2
  27. package/dist/narration/index.d.ts +1 -1
  28. package/dist/narration/index.js +10 -9
  29. package/dist/recommend/index.js +2 -2
  30. package/dist/schemas/index.d.ts +4 -4
  31. package/dist/schemas/index.js +1 -1
  32. package/dist/{themeLibrary-BbF3EKWM.d.ts → themeLibrary-_46saKYO.d.ts} +1 -1
  33. package/dist/timing/index.d.ts +1 -1
  34. package/dist/transform/index.d.ts +84 -4
  35. package/dist/transform/index.js +38 -8
  36. package/package.json +1 -1
  37. package/dist/chunk-5W7F46OO.js +0 -337
@@ -1,10 +1,13 @@
1
1
  import {
2
- buildNarrationScript,
3
2
  parseNarrationTimingJson
4
- } from "./chunk-5W7F46OO.js";
3
+ } from "./chunk-3XEABCT3.js";
4
+ import {
5
+ applySavedPresentation
6
+ } from "./chunk-NM747LUO.js";
5
7
  import {
6
8
  SHAPE_NAMES,
7
9
  buildChartData,
10
+ buildNarrationScript,
8
11
  buildRegistry,
9
12
  coerceTemplateParams,
10
13
  deriveTemplateInputs,
@@ -32,7 +35,7 @@ import {
32
35
  templateRegistry,
33
36
  writeCustomTemplatesToFrontmatter,
34
37
  writeCustomThemesToFrontmatter
35
- } from "./chunk-WMXQDP2C.js";
38
+ } from "./chunk-7IGKCHDP.js";
36
39
  import {
37
40
  ASCII_TREE_VOCAB,
38
41
  ASCII_VOCAB,
@@ -49,7 +52,7 @@ import {
49
52
  toCells,
50
53
  toGrid,
51
54
  traceBoxes
52
- } from "./chunk-C3NAY5YP.js";
55
+ } from "./chunk-A5QJJZ5S.js";
53
56
  import {
54
57
  iconMarker
55
58
  } from "./chunk-7ZAAICW4.js";
@@ -82,7 +85,7 @@ import {
82
85
  } from "./chunk-L7QZORLB.js";
83
86
  import {
84
87
  parseMarkdown
85
- } from "./chunk-GDHXT5Q7.js";
88
+ } from "./chunk-PGWYC3S2.js";
86
89
  import {
87
90
  KNOWN_BLOCK_META_KEYS,
88
91
  TABLE_FED_TEMPLATES,
@@ -91,13 +94,16 @@ import {
91
94
  isContainerTemplate,
92
95
  resolveTemplateName,
93
96
  serializeAnnotation
94
- } from "./chunk-TMOHAFYE.js";
97
+ } from "./chunk-WSFXV5BT.js";
95
98
  import {
96
99
  extractPlainText,
100
+ findBlockVideoEmbed,
97
101
  getChildren,
102
+ isVideoEmbedUrl,
98
103
  parseHtmlToNodes,
104
+ parseVideoEmbedUrl,
99
105
  readFrontmatterThemeId
100
- } from "./chunk-X7BNDUNI.js";
106
+ } from "./chunk-Q6ELOAOQ.js";
101
107
  import {
102
108
  buildCaptionTrack
103
109
  } from "./chunk-4OQFLZ6G.js";
@@ -894,6 +900,9 @@ function getTemplateDefaults(templateName, headingText, block) {
894
900
  return deriveTemplateInputs(templateName, headingText, block.contents) ?? {
895
901
  items: ["Item 1", "Item 2", "Item 3"]
896
902
  };
903
+ case "videoWithCaption":
904
+ case "videoPullQuote":
905
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? {};
897
906
  case "definitionCard":
898
907
  return { term: headingText, definition: body || headingText };
899
908
  case "dateEvent":
@@ -1027,6 +1036,8 @@ function resolveDocumentTitle(doc, provided) {
1027
1036
  return provided?.trim() ?? "";
1028
1037
  }
1029
1038
  function buildPreviewDoc(doc, options) {
1039
+ doc = applySavedPresentation(doc);
1040
+ if (doc.presentationApplied) options = { ...options, interleaveImages: false };
1030
1041
  const flat = flattenRenderableBlocks(doc.blocks);
1031
1042
  const allImages = collectAllDocImages(doc.blocks);
1032
1043
  const usedImageSrcs = /* @__PURE__ */ new Set();
@@ -1467,6 +1478,20 @@ var pullQuote = (input) => {
1467
1478
  };
1468
1479
  var videoWithCaption = (input) => {
1469
1480
  const v = input;
1481
+ if (isVideoEmbedUrl(v.videoSrc)) {
1482
+ return {
1483
+ kind: "media-figure",
1484
+ variant: "video",
1485
+ slots: {
1486
+ media: {
1487
+ type: "videoEmbed",
1488
+ url: v.videoSrc,
1489
+ ...v.videoAlt ? { title: v.videoAlt } : {}
1490
+ },
1491
+ caption: v.caption
1492
+ }
1493
+ };
1494
+ }
1470
1495
  return {
1471
1496
  kind: "media-figure",
1472
1497
  variant: "video",
@@ -1665,8 +1690,14 @@ function markdownNodeContainsMedia(value) {
1665
1690
  function unconsumedRichContent(block, draft, widgetFenceLangs) {
1666
1691
  if (!block.contents || block.contents.length === 0) return void 0;
1667
1692
  const templateHasMedia = Boolean(draft.slots.media) || Boolean(draft.slots.items?.some((item) => item.media !== void 0));
1693
+ const media = draft.slots.media;
1694
+ const playedVideo = media?.type === "videoEmbed" ? parseVideoEmbedUrl(media.url)?.watchUrl ?? media.url : null;
1695
+ const isUnplayedVideo = (node) => {
1696
+ const video = findBlockVideoEmbed(node);
1697
+ return video !== null && video.embed.watchUrl !== playedVideo;
1698
+ };
1668
1699
  const markdown = block.contents.filter(
1669
- (node) => isWidgetFence(node, widgetFenceLangs) || !templateHasMedia && markdownNodeContainsMedia(node)
1700
+ (node) => isWidgetFence(node, widgetFenceLangs) || !templateHasMedia && markdownNodeContainsMedia(node) || isUnplayedVideo(node)
1670
1701
  );
1671
1702
  if (markdown.length === 0) return void 0;
1672
1703
  return {
@@ -2369,6 +2400,7 @@ var PAGE_BASE_CSS = `
2369
2400
  /* \u2500\u2500 Media figure \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2370
2401
  .squisq-page-figure { margin: 0; }
2371
2402
  .squisq-page-figure img, .squisq-page-figure video { width: 100%; display: block; }
2403
+ .squisq-page-figure .squisq-video-embed { max-width: none; margin: 0; }
2372
2404
  .squisq-page-figure figcaption { margin-top: 0.9em; font-size: 0.9rem; color: var(--squisq-page-text-muted); text-align: center; }
2373
2405
  .squisq-page-media-credit { font-size: 0.78rem; opacity: 0.75; }
2374
2406
 
@@ -4391,6 +4423,16 @@ async function applyNarrationTiming(doc, container) {
4391
4423
  ...doc,
4392
4424
  blocks,
4393
4425
  duration,
4426
+ presentationNarration: {
4427
+ sourceText: timing.sourceText,
4428
+ src: clip.src,
4429
+ startTime: clip.startAt,
4430
+ duration: playedDuration,
4431
+ bookmarks: timing.bookmarks.flatMap((bookmark) => {
4432
+ const time = timeMap ? timeMap.sourceToPlayed(bookmark.time) : bookmark.time;
4433
+ return time !== null && time >= 0 && time <= playedDuration ? [{ ...bookmark, time: clip.startAt + time }] : [];
4434
+ })
4435
+ },
4394
4436
  ...captions ? { captions } : {},
4395
4437
  ...ctx.diagnostics.length > 0 ? { diagnostics: [...doc.diagnostics ?? [], ...ctx.diagnostics] } : {}
4396
4438
  };
@@ -2,14 +2,14 @@ import {
2
2
  assertMarkdownDocumentWithinLimits,
3
3
  parseMarkdown,
4
4
  toMdast
5
- } from "./chunk-GDHXT5Q7.js";
5
+ } from "./chunk-PGWYC3S2.js";
6
6
  import {
7
7
  formatFrontmatterYaml,
8
8
  getChildren,
9
9
  splitFrontmatterBlock,
10
10
  stringifyHtmlNodes,
11
11
  walkMarkdownTree
12
- } from "./chunk-X7BNDUNI.js";
12
+ } from "./chunk-Q6ELOAOQ.js";
13
13
 
14
14
  // src/markdown/stringify.ts
15
15
  import { unified } from "unified";
@@ -21,17 +21,41 @@ var defaultProcessor;
21
21
  var DQ_RUN = `"(?:[^"\\\\]|\\\\.)*"`;
22
22
  var SQ_RUN = `'(?:[^'\\\\]|\\\\.)*'`;
23
23
  var ESCAPED_TEMPLATE_SPAN_RE = new RegExp(
24
- `\\{\\\\\\[((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^\\]\\\\])*)\\]\\}`,
24
+ `\\{\\\\\\[((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^\\]\\\\"'])*)\\]\\}`,
25
25
  "g"
26
26
  );
27
27
  var HEADING_LINE_RE = /^#{1,6} .*$/gm;
28
28
  var TRAILING_ESCAPED_PANDOC_SPAN_RE = new RegExp(
29
- `\\{(?!\\\\?\\[)((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^}\\\\])*)\\}(?=\\s*(?:\\{\\[.*)?$)`
29
+ `\\{(?!\\\\?\\[)((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^}\\\\"'])*)\\}(?=\\s*(?:\\{\\[.*)?$)`
30
30
  );
31
31
  var UNESCAPE_PUNCT_RE = /\\([\\[\]:#.,+=/?;@%$(){}'"-])/g;
32
32
  function unescapeMarkdownPunct(text) {
33
33
  return text.replace(UNESCAPE_PUNCT_RE, "$1");
34
34
  }
35
+ function literalTextUnsafe(options) {
36
+ return [
37
+ // GFM's writer only guards lowercase protocol endings, while its parser
38
+ // recognizes uppercase ones. Escape the colon before the domain dot can
39
+ // become a literal backslash inside an automatically recognized URL.
40
+ ...options?.gfm === false ? [] : [
41
+ {
42
+ character: ":",
43
+ before: "[PS]",
44
+ after: "\\/",
45
+ inConstruct: "phrasing",
46
+ notInConstruct: [
47
+ "autolink",
48
+ "link",
49
+ "image",
50
+ "label"
51
+ ]
52
+ }
53
+ ],
54
+ { character: "\\", after: "[ ]", inConstruct: "phrasing" },
55
+ ...options?.math === false ? [] : [{ character: "$", inConstruct: "phrasing" }],
56
+ ...options?.directive === false ? [] : [{ character: ":", after: "[A-Za-z]", inConstruct: "phrasing" }]
57
+ ];
58
+ }
35
59
  var PREFERRED_MASK_SENTINEL = "\0";
36
60
  function pickMaskSentinel(text) {
37
61
  const present = new Set(text);
@@ -154,7 +178,8 @@ function stringifyMarkdown(doc, options) {
154
178
  strong: "*",
155
179
  rule: "-",
156
180
  fence: "`",
157
- setext: false
181
+ setext: false,
182
+ unsafe: literalTextUnsafe()
158
183
  });
159
184
  }
160
185
  processor = defaultProcessor;
@@ -176,7 +201,8 @@ function stringifyMarkdown(doc, options) {
176
201
  strong: options?.strong ?? "*",
177
202
  rule: options?.rule ?? "-",
178
203
  fence: options?.fence ?? "`",
179
- setext: options?.setext ?? false
204
+ setext: options?.setext ?? false,
205
+ unsafe: literalTextUnsafe(options)
180
206
  });
181
207
  }
182
208
  const result = processor.stringify(mdastTree);
@@ -1204,11 +1230,22 @@ function rewriteMarkdownReferences(source, options = {}) {
1204
1230
 
1205
1231
  // src/markdown/docfxMarkdown.ts
1206
1232
  function normalizeDocfxMarkdown(source, options = {}) {
1207
- const { frontmatter, body } = splitFrontmatterBlock(source);
1233
+ let output = normalizeDocfxMarkdownPass(source, options);
1234
+ if (options.unknownDirectives === "preserve") {
1235
+ for (let pass = 0; pass < 2 && output !== source && /:::/u.test(output); pass++) {
1236
+ source = output;
1237
+ output = normalizeDocfxMarkdownPass(source, options);
1238
+ }
1239
+ }
1240
+ return output;
1241
+ }
1242
+ function normalizeDocfxMarkdownPass(source, options = {}) {
1243
+ const { frontmatter, body: originalBody } = splitFrontmatterBlock(source);
1244
+ const body = flattenDocfxLayout(originalBody);
1208
1245
  const protectedSpans = [];
1209
- for (const comment of body.matchAll(/<!--[\s\S]*?-->/g))
1246
+ for (const comment of body.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
1210
1247
  protectedSpans.push([comment.index, comment.index + comment[0].length]);
1211
- walkMarkdownTree(parseMarkdown(body, { frontmatter: false }), (node) => {
1248
+ walkMarkdownTree(parseMarkdown(body, { frontmatter: false, directive: false }), (node) => {
1212
1249
  if ((node.type === "code" || node.type === "inlineCode") && node.position?.start.offset !== void 0 && node.position.end.offset !== void 0)
1213
1250
  protectedSpans.push([node.position.start.offset, node.position.end.offset]);
1214
1251
  });
@@ -1216,8 +1253,8 @@ function normalizeDocfxMarkdown(source, options = {}) {
1216
1253
  type: "document",
1217
1254
  children: [{ type: "paragraph", children: [{ type: "text", value: text }] }]
1218
1255
  }).trimEnd();
1219
- const output = body.replace(
1220
- /(^[^\S\n]*(?:>\s*)?):::\s*([\w-]+)([^\n]*?)(?=\r?$)|(^[^\S\n]*>\s*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|div)\b([^\]]*)\]|:::\s*(image)\b([^\n]*?):::/gim,
1256
+ let output = body.replace(
1257
+ /(^[^\S\n]*(?:>\s*)?):::\s*([\w-]+)([^\n]*?)(?=\r?$)|(^[^\S\n]*>\s*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|div)\b([^\]]*)\]|:::\s*(image|no-loc)\b([^\n]*?):::/gim,
1221
1258
  (match, prefix, name, raw, quote, admonition, _extra, inlineName, inlineRaw, offset) => {
1222
1259
  if (protectedSpans.some(([start, end]) => offset >= start && offset < end)) return match;
1223
1260
  if (admonition)
@@ -1239,6 +1276,16 @@ function normalizeDocfxMarkdown(source, options = {}) {
1239
1276
  }).trimEnd();
1240
1277
  return `${prefix ?? ""}${image}`;
1241
1278
  }
1279
+ case "code":
1280
+ if (options.reference && attributes.has("source"))
1281
+ return (prefix ?? "") + options.reference("code", attributes.get("source"), raw?.trim() ?? "Code example");
1282
+ throw new Error("Unsupported DocFX code without a source reference resolver");
1283
+ case "no-loc":
1284
+ return (prefix ?? "") + escape(attributes.get("text") ?? "");
1285
+ case "moniker":
1286
+ return (prefix ?? "") + "**Applies to: " + escape(attributes.get("range") ?? raw?.trim() ?? "") + "**";
1287
+ case "moniker-end":
1288
+ return "";
1242
1289
  case "zone":
1243
1290
  return attributes.has("pivot") ? `${prefix ?? ""}**Applies to: ${escape(attributes.get("pivot"))}**
1244
1291
  ` : "";
@@ -1250,12 +1297,100 @@ function normalizeDocfxMarkdown(source, options = {}) {
1250
1297
  case "column-end":
1251
1298
  return "";
1252
1299
  default:
1300
+ if (options.unknownDirectives === "preserve") {
1301
+ const fence = "`".repeat(
1302
+ Math.max(1, ...Array.from(match.matchAll(/`+/g), (m) => m[0].length + 1))
1303
+ );
1304
+ return `${prefix ?? ""}${fence}${match.trim()}${fence}`;
1305
+ }
1253
1306
  throw new Error(`Unsupported DocFX directive: ${name}`);
1254
1307
  }
1255
1308
  }
1256
1309
  );
1310
+ if (options.reference) {
1311
+ const spans = [];
1312
+ for (const comment of output.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
1313
+ spans.push([comment.index, comment.index + comment[0].length]);
1314
+ walkMarkdownTree(parseMarkdown(output, { frontmatter: false, directive: false }), (node) => {
1315
+ if ((node.type === "code" || node.type === "inlineCode") && node.position)
1316
+ spans.push([node.position.start.offset, node.position.end.offset]);
1317
+ });
1318
+ output = output.replace(
1319
+ /\[!code-[\w-]+\s*\[([^\]]*)\]\(([^)\n]+)\)\]|<xref:([^>\n]+)>/gi,
1320
+ (match, label, target, uid, offset) => {
1321
+ if (spans.some(([start, end]) => offset >= start && offset < end)) return match;
1322
+ return uid ? options.reference("xref", uid, uid.split("?")[0]) : options.reference("code", target, label || "Code example");
1323
+ }
1324
+ );
1325
+ }
1326
+ if (options.unknownDirectives === "preserve" && /\[!code-|\[!INCLUDE\b|<xref:/i.test(output)) {
1327
+ const spans = [];
1328
+ for (const comment of output.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
1329
+ spans.push([comment.index, comment.index + comment[0].length]);
1330
+ walkMarkdownTree(parseMarkdown(output, { frontmatter: false, directive: false }), (node) => {
1331
+ if ((node.type === "code" || node.type === "inlineCode") && node.position)
1332
+ spans.push([node.position.start.offset, node.position.end.offset]);
1333
+ });
1334
+ output = output.replace(
1335
+ /\[!code-[^\n]*|\[!INCLUDE[^\n]*|<xref:[^\n]*/gi,
1336
+ (match, offset) => {
1337
+ if (spans.some(([start, end]) => offset >= start && offset < end)) return match;
1338
+ options.onPreservedReference?.(match);
1339
+ const fence = String.fromCharCode(96).repeat(
1340
+ Math.max(1, ...Array.from(match.matchAll(/\x60+/g), (m) => m[0].length + 1))
1341
+ );
1342
+ return fence + " " + match + " " + fence;
1343
+ }
1344
+ );
1345
+ }
1346
+ if (options.frontmatterAsCode && frontmatter) {
1347
+ const fence = "`".repeat(
1348
+ Math.max(3, ...Array.from(frontmatter.matchAll(/`+/g), (m) => m[0].length + 1))
1349
+ );
1350
+ return output + "\n\n## Original source metadata\n\n" + fence + "text\n" + frontmatter.trimEnd() + "\n" + fence + "\n";
1351
+ }
1257
1352
  return (frontmatter ?? "") + output;
1258
1353
  }
1354
+ function flattenDocfxLayout(source) {
1355
+ const stack = [];
1356
+ let fence;
1357
+ let comment = false;
1358
+ return source.split("\n").map((line) => {
1359
+ const column = [...stack].reverse().find((entry) => entry.kind === "column");
1360
+ const margin = column ? column.indent + 4 : 0;
1361
+ const indent = /^ */.exec(line)[0].length;
1362
+ const content = line.slice(Math.min(indent, margin));
1363
+ const boundary = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(content);
1364
+ if (fence) {
1365
+ if (boundary && boundary[1][0] === fence.character && boundary[1].length >= fence.length && !boundary[2].trim())
1366
+ fence = void 0;
1367
+ return content;
1368
+ }
1369
+ const commented = comment || line.includes("<!--");
1370
+ const opening = line.lastIndexOf("<!--");
1371
+ const closing = line.lastIndexOf("-->");
1372
+ if (opening > closing) comment = true;
1373
+ else if (closing >= 0) comment = false;
1374
+ if (commented) return content;
1375
+ if (boundary) {
1376
+ fence = { character: boundary[1][0], length: boundary[1].length };
1377
+ return content;
1378
+ }
1379
+ const marker = /^ *:::(row|column)(-end)?(?=\s|:|$)[^\n]*$/i.exec(line);
1380
+ if (!marker || !stack.length && indent > 3) return content;
1381
+ const kind = marker[1].toLowerCase();
1382
+ if (marker[2]) {
1383
+ const index = stack.map((entry) => entry.kind).lastIndexOf(kind);
1384
+ if (index < 0) return content;
1385
+ stack.splice(index);
1386
+ } else {
1387
+ if (stack.length >= 128)
1388
+ throw new Error("DocFX layout exceeds the 128-level nesting safety limit");
1389
+ stack.push({ kind, indent });
1390
+ }
1391
+ return "";
1392
+ }).join("\n");
1393
+ }
1259
1394
 
1260
1395
  export {
1261
1396
  stringifyMarkdown,