@bendyline/squisq 2.4.0 → 2.4.2

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-DLpyOAXJ.d.ts → Doc-BKKcPjfe.d.ts} +137 -9
  2. package/dist/{ImageEditDoc-Cu30xb9b.d.ts → ImageEditDoc-CU1cXxRd.d.ts} +1 -1
  3. package/dist/{annotationCoercion-PtRQhk5V.d.ts → annotationCoercion-CPHEggo3.d.ts} +1 -1
  4. package/dist/{chunk-F2IEPSMA.js → chunk-2HY2ZA7U.js} +161 -80
  5. package/dist/{chunk-D4LPP3P5.js → chunk-7TJJA2RI.js} +3 -1
  6. package/dist/{chunk-KPBZZVGY.js → chunk-AQF5ZYDI.js} +50 -14
  7. package/dist/{chunk-2VCNTDNZ.js → chunk-D6YTLQCL.js} +71 -0
  8. package/dist/{chunk-32R2RZAO.js → chunk-DAMIRKTO.js} +1 -1
  9. package/dist/{chunk-ZHLNKB2I.js → chunk-EMXYZLRH.js} +1 -1
  10. package/dist/{chunk-2S74DPJH.js → chunk-GAZKTT4R.js} +24 -4
  11. package/dist/{chunk-REDUXXDJ.js → chunk-GODLNXO4.js} +45 -3
  12. package/dist/{chunk-ZYO3DBTA.js → chunk-JUAC2QWP.js} +1 -1
  13. package/dist/{chunk-C33GTPUZ.js → chunk-SBAX4ZPO.js} +438 -0
  14. package/dist/doc/index.d.ts +17 -7
  15. package/dist/doc/index.js +11 -10
  16. package/dist/generate/index.d.ts +2 -2
  17. package/dist/imageEdit/index.d.ts +4 -4
  18. package/dist/index.d.ts +7 -7
  19. package/dist/index.js +20 -14
  20. package/dist/jsonForm/index.d.ts +2 -2
  21. package/dist/jsonForm/index.js +4 -4
  22. package/dist/markdown/index.d.ts +3 -3
  23. package/dist/markdown/index.js +3 -3
  24. package/dist/{materializePageSection-CgNs5Qmw.d.ts → materializePageSection-WDJCTJEm.d.ts} +2 -2
  25. package/dist/narration/index.d.ts +2 -2
  26. package/dist/narration/index.js +4 -4
  27. package/dist/recommend/index.d.ts +1 -1
  28. package/dist/schemas/index.d.ts +33 -6
  29. package/dist/schemas/index.js +9 -3
  30. package/dist/storage/index.d.ts +2 -3
  31. package/dist/{themeLibrary-RWsNtlOu.d.ts → themeLibrary-BMXXLZBU.d.ts} +1 -1
  32. package/dist/timing/index.d.ts +1 -2
  33. package/dist/transform/index.d.ts +3 -3
  34. package/dist/{types-CUNc9biN.d.ts → types-CcrDFdWH.d.ts} +1 -1
  35. package/package.json +2 -2
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  SHAPE_NAMES,
3
- TEMPLATE_ALIASES,
4
3
  buildChartData,
5
4
  buildNarrationScript,
6
5
  coerceTemplateParams,
@@ -11,7 +10,6 @@ import {
11
10
  flattenRenderableBlocks,
12
11
  getBlockBodyText,
13
12
  getPinnedBlockMeta,
14
- isContainerTemplate,
15
13
  isDataFence,
16
14
  isShapeName,
17
15
  lintTemplateParams,
@@ -22,11 +20,10 @@ import {
22
20
  parseNarrationTimingJson,
23
21
  parseStandaloneAnnotation,
24
22
  readCustomThemesFromFrontmatter,
25
- resolveTemplateName,
26
23
  templateRegistry,
27
24
  writeCustomTemplatesToFrontmatter,
28
25
  writeCustomThemesToFrontmatter
29
- } from "./chunk-F2IEPSMA.js";
26
+ } from "./chunk-2HY2ZA7U.js";
30
27
  import {
31
28
  ASCII_TREE_VOCAB,
32
29
  ASCII_VOCAB,
@@ -46,7 +43,7 @@ import {
46
43
  import {
47
44
  defaultPageStyle,
48
45
  resolveMediaSchedule
49
- } from "./chunk-2S74DPJH.js";
46
+ } from "./chunk-GAZKTT4R.js";
50
47
  import {
51
48
  DEFAULT_THEME,
52
49
  FRONTMATTER_CUSTOM_TEMPLATES_KEY,
@@ -54,19 +51,22 @@ import {
54
51
  hexHueDegrees,
55
52
  resolveFontFamily,
56
53
  resolveTheme
57
- } from "./chunk-C33GTPUZ.js";
54
+ } from "./chunk-SBAX4ZPO.js";
58
55
  import {
59
56
  VIEWPORT_PRESETS,
60
57
  isTemplateBlock
61
58
  } from "./chunk-BAOV476U.js";
62
59
  import {
63
60
  parseMarkdown
64
- } from "./chunk-D4LPP3P5.js";
61
+ } from "./chunk-7TJJA2RI.js";
65
62
  import {
66
63
  KNOWN_BLOCK_META_KEYS,
64
+ TEMPLATE_ALIASES,
67
65
  coerceAnnotationValues,
66
+ isContainerTemplate,
67
+ resolveTemplateName,
68
68
  serializeAnnotation
69
- } from "./chunk-2VCNTDNZ.js";
69
+ } from "./chunk-D6YTLQCL.js";
70
70
  import {
71
71
  extractPlainText,
72
72
  getChildren,
@@ -356,15 +356,21 @@ function docToMarkdown(doc, options = {}) {
356
356
  children.push(synthesizeMediaParagraph(clip));
357
357
  }
358
358
  function emitBlock(block) {
359
+ const promoted = block.promotedBodyAnnotation;
360
+ const promotedUnedited = promoted !== void 0 && !isPromotedBodyEdited(block, promoted);
359
361
  if (block.sourceHeading) {
360
- const heading = ensureAnnotation(block, block.sourceHeading, defaultTemplate);
361
- children.push(heading);
362
+ if (promotedUnedited) {
363
+ children.push(block.sourceHeading);
364
+ } else {
365
+ const heading = ensureAnnotation(block, block.sourceHeading, defaultTemplate);
366
+ children.push(heading);
367
+ }
362
368
  } else if (block.standaloneAnnotation) {
363
369
  children.push(synthesizeAnnotationParagraph(block));
364
370
  }
365
371
  const clips = [...block.media ?? [], ...docMediaByBlock.get(block.id) ?? []];
372
+ const contents = [...block.contents ?? []];
366
373
  if (clips.length > 0) {
367
- const contents = [...block.contents ?? []];
368
374
  const anchored = clips.filter((clip) => clip.origin).sort((a, b) => a.origin.index - b.origin.index);
369
375
  for (const clip of anchored) {
370
376
  contents.splice(
@@ -376,10 +382,11 @@ function docToMarkdown(doc, options = {}) {
376
382
  for (const clip of clips.filter((c) => !c.origin).reverse()) {
377
383
  contents.unshift(synthesizeMediaParagraph(clip));
378
384
  }
379
- children.push(...contents);
380
- } else if (block.contents) {
381
- children.push(...block.contents);
382
385
  }
386
+ if (promotedUnedited) {
387
+ reinsertPromotedBodyAnnotation(contents, promoted);
388
+ }
389
+ children.push(...contents);
383
390
  if (block.children) {
384
391
  for (const child of block.children) {
385
392
  emitBlock(child);
@@ -416,6 +423,32 @@ function synthesizeAnnotationParagraph(block) {
416
423
  const text = serializeAnnotation(block.sourceAnnotation?.template, block.templateOverrides);
417
424
  return { type: "paragraph", children: [{ type: "text", value: text }] };
418
425
  }
426
+ function isPromotedBodyEdited(block, p) {
427
+ const templateSame = resolveTemplateName(block.template ?? "") === resolveTemplateName(p.template);
428
+ const paramsSame = paramsEqual(block.templateOverrides ?? {}, p.params ?? {});
429
+ return !(templateSame && paramsSame);
430
+ }
431
+ function reinsertPromotedBodyAnnotation(contents, p) {
432
+ if (p.origin.kind === "paragraph") {
433
+ contents.push({ type: "paragraph", children: [{ type: "text", value: p.origin.raw }] });
434
+ return;
435
+ }
436
+ const last = contents[contents.length - 1];
437
+ if (last && last.type === "paragraph") {
438
+ const children = last.children ?? [];
439
+ const lastChild = children[children.length - 1];
440
+ if (lastChild && lastChild.type === "text") {
441
+ const cloned = [...children];
442
+ cloned[cloned.length - 1] = { ...lastChild, value: lastChild.value + p.origin.suffix };
443
+ contents[contents.length - 1] = { ...last, children: cloned };
444
+ return;
445
+ }
446
+ }
447
+ contents.push({
448
+ type: "paragraph",
449
+ children: [{ type: "text", value: p.origin.suffix.replace(/^\s+/, "") }]
450
+ });
451
+ }
419
452
  function synthesizeMediaParagraph(clip) {
420
453
  if (clip.origin?.format === "html" && clip.origin.raw) {
421
454
  return {
@@ -429,6 +462,9 @@ function synthesizeMediaParagraph(clip) {
429
462
  }
430
463
  const params = { src: clip.src };
431
464
  if (clip.placement) params.placement = clip.placement;
465
+ if (clip.pipSize) params.pipSize = clip.pipSize;
466
+ if (clip.pipShape) params.pipShape = clip.pipShape;
467
+ if (clip.pipPosition) params.pipPosition = clip.pipPosition;
432
468
  if (clip.lockToBlock != null) params.lockToBlock = String(clip.lockToBlock);
433
469
  if (clip.anchor === "document") params.anchor = "document";
434
470
  if (clip.startAt) params.startAt = String(clip.startAt);
@@ -5,6 +5,71 @@ import {
5
5
  normalizeTransitionType
6
6
  } from "./chunk-4VOD55SX.js";
7
7
 
8
+ // src/doc/templates/templateNames.ts
9
+ var TEMPLATE_ALIASES = Object.freeze({
10
+ titleBlock: "title",
11
+ quoteBlock: "quote",
12
+ mapBlock: "map",
13
+ listBlock: "list",
14
+ diagramBlock: "diagram",
15
+ diagramNode: "diagram"
16
+ });
17
+ function resolveTemplateName(name) {
18
+ return TEMPLATE_ALIASES[name] ?? name;
19
+ }
20
+ var TABLE_FED_TEMPLATES = /* @__PURE__ */ new Set([
21
+ "dataTable",
22
+ "barChart",
23
+ "columnChart",
24
+ "pieChart",
25
+ "donutChart",
26
+ "lineChart",
27
+ "areaChart",
28
+ "scatterChart"
29
+ ]);
30
+ var CONTAINER_TEMPLATES = /* @__PURE__ */ new Set(["diagram", "drawing", "layout"]);
31
+ function isContainerTemplate(name) {
32
+ return !!name && CONTAINER_TEMPLATES.has(resolveTemplateName(name));
33
+ }
34
+ var TEMPLATE_TOKEN_NAMES = /* @__PURE__ */ new Set([
35
+ "title",
36
+ "sectionHeader",
37
+ "content",
38
+ "statHighlight",
39
+ "quote",
40
+ "factCard",
41
+ "twoColumn",
42
+ "dateEvent",
43
+ "imageWithCaption",
44
+ "leftFeature",
45
+ "rightFeature",
46
+ "map",
47
+ "fullBleedQuote",
48
+ "list",
49
+ "photoGrid",
50
+ "definitionCard",
51
+ "comparisonBar",
52
+ "pullQuote",
53
+ "videoWithCaption",
54
+ "videoPullQuote",
55
+ "dataTable",
56
+ "barChart",
57
+ "columnChart",
58
+ "pieChart",
59
+ "donutChart",
60
+ "lineChart",
61
+ "areaChart",
62
+ "scatterChart",
63
+ "diagram",
64
+ "tree",
65
+ "timeline",
66
+ "layout",
67
+ "drawing"
68
+ ]);
69
+ function isReservedAnnotationToken(token) {
70
+ return TEMPLATE_TOKEN_NAMES.has(resolveTemplateName(token));
71
+ }
72
+
8
73
  // src/markdown/sanitize.ts
9
74
  var SAFE_LINK_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto", "tel"]);
10
75
  var SAFE_MEDIA_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "blob"]);
@@ -518,6 +583,12 @@ function serializeAnnotation(template, params) {
518
583
  }
519
584
 
520
585
  export {
586
+ TEMPLATE_ALIASES,
587
+ resolveTemplateName,
588
+ TABLE_FED_TEMPLATES,
589
+ CONTAINER_TEMPLATES,
590
+ isContainerTemplate,
591
+ isReservedAnnotationToken,
521
592
  sanitizeUrl,
522
593
  sanitizeHtmlNodes,
523
594
  KNOWN_BLOCK_META_KEYS,
@@ -2,7 +2,7 @@ import {
2
2
  DEFAULT_THEME,
3
3
  applySurface,
4
4
  resolveFontFamily
5
- } from "./chunk-C33GTPUZ.js";
5
+ } from "./chunk-SBAX4ZPO.js";
6
6
 
7
7
  // src/jsonForm/chooseControl.ts
8
8
  var ENUM_SEGMENTED_LIMIT = 4;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  expectedSyllablesAt,
3
3
  wordPosAtExpectedSyllables
4
- } from "./chunk-F2IEPSMA.js";
4
+ } from "./chunk-2HY2ZA7U.js";
5
5
 
6
6
  // src/narration/types.ts
7
7
  var DEFAULT_FEATURE_CONFIG = Object.freeze({
@@ -10,6 +10,13 @@ function clipLength(clip) {
10
10
  if (clip.clipEnd == null) return null;
11
11
  return Math.max(0, clip.clipEnd - (clip.clipStart ?? 0));
12
12
  }
13
+ function intrinsicPlayedLength(clip, opts) {
14
+ if (clip.clipEnd != null || clip.lockToBlock === true) return null;
15
+ const intrinsic = opts?.intrinsicDuration?.(clip);
16
+ if (intrinsic == null || !Number.isFinite(intrinsic) || intrinsic <= 0) return null;
17
+ const played = intrinsic - (clip.clipStart ?? 0);
18
+ return played > 0 ? played : null;
19
+ }
13
20
  function baseTimelineEnd(doc) {
14
21
  const blockEnd = flatten(doc.blocks).reduce(
15
22
  (max, b) => Math.max(max, b.startTime + b.duration),
@@ -17,7 +24,7 @@ function baseTimelineEnd(doc) {
17
24
  );
18
25
  return Math.max(doc.duration ?? 0, blockEnd);
19
26
  }
20
- function resolveMediaSchedule(doc) {
27
+ function resolveMediaSchedule(doc, opts) {
21
28
  const out = [];
22
29
  const docEnd = baseTimelineEnd(doc);
23
30
  for (const block of flatten(doc.blocks)) {
@@ -31,11 +38,16 @@ function resolveMediaSchedule(doc) {
31
38
  } else {
32
39
  end = len != null ? Math.min(start + len, blockEnd) : blockEnd;
33
40
  }
41
+ const natLen = intrinsicPlayedLength(clip, opts);
42
+ if (natLen != null) end = Math.min(end, start + natLen);
34
43
  out.push({
35
44
  id: clip.id,
36
45
  src: clip.src,
37
46
  kind: clip.kind,
38
47
  ...clip.placement ? { placement: clip.placement } : {},
48
+ ...clip.pipSize ? { pipSize: clip.pipSize } : {},
49
+ ...clip.pipShape ? { pipShape: clip.pipShape } : {},
50
+ ...clip.pipPosition ? { pipPosition: clip.pipPosition } : {},
39
51
  ...clip.lockToBlock != null ? { lockToBlock: clip.lockToBlock } : {},
40
52
  absoluteStart: start,
41
53
  absoluteEnd: Math.max(start, end),
@@ -49,12 +61,17 @@ function resolveMediaSchedule(doc) {
49
61
  for (const clip of doc.documentMedia ?? []) {
50
62
  const start = clip.startAt;
51
63
  const len = clipLength(clip);
52
- const end = len != null ? start + len : docEnd;
64
+ let end = len != null ? start + len : docEnd;
65
+ const natLen = intrinsicPlayedLength(clip, opts);
66
+ if (natLen != null) end = Math.min(end, start + natLen);
53
67
  out.push({
54
68
  id: clip.id,
55
69
  src: clip.src,
56
70
  kind: clip.kind,
57
71
  ...clip.placement ? { placement: clip.placement } : {},
72
+ ...clip.pipSize ? { pipSize: clip.pipSize } : {},
73
+ ...clip.pipShape ? { pipShape: clip.pipShape } : {},
74
+ ...clip.pipPosition ? { pipPosition: clip.pipPosition } : {},
58
75
  ...clip.lockToBlock != null ? { lockToBlock: clip.lockToBlock } : {},
59
76
  absoluteStart: start,
60
77
  absoluteEnd: Math.max(start, end),
@@ -65,9 +82,12 @@ function resolveMediaSchedule(doc) {
65
82
  }
66
83
  return out;
67
84
  }
68
- function getDocPlaybackDuration(doc) {
85
+ function getDocPlaybackDuration(doc, opts) {
69
86
  const base = baseTimelineEnd(doc);
70
- const mediaEnd = resolveMediaSchedule(doc).reduce((max, c) => Math.max(max, c.absoluteEnd), 0);
87
+ const mediaEnd = resolveMediaSchedule(doc, opts).reduce(
88
+ (max, c) => Math.max(max, c.absoluteEnd),
89
+ 0
90
+ );
71
91
  return Math.max(base, mediaEnd);
72
92
  }
73
93
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultPageStyle
3
- } from "./chunk-2S74DPJH.js";
3
+ } from "./chunk-GAZKTT4R.js";
4
4
  import {
5
5
  FONT_FALLBACKS,
6
6
  THEME_SCHEMA_VERSION,
@@ -13,8 +13,9 @@ import {
13
13
  oklchSetChroma,
14
14
  pickContrastingText,
15
15
  relativeLuminance,
16
- resolveFontFamily
17
- } from "./chunk-C33GTPUZ.js";
16
+ resolveFontFamily,
17
+ withAlpha
18
+ } from "./chunk-SBAX4ZPO.js";
18
19
 
19
20
  // src/schemas/Doc.ts
20
21
  function calculateDuration(audio) {
@@ -47,6 +48,46 @@ function getCaptionAtTime(captions, time) {
47
48
  return null;
48
49
  }
49
50
 
51
+ // src/schemas/pipStyle.ts
52
+ var DEFAULT_SHADOW = "0 0.75em 2em rgba(0, 0, 0, 0.34)";
53
+ var DERIVED_BORDER_WIDTH = "max(1px, 0.12vw)";
54
+ function cssLength(value) {
55
+ return typeof value === "number" ? `${value}px` : value;
56
+ }
57
+ function resolveRadius(theme) {
58
+ const explicit = theme.style.pip?.cornerRadius;
59
+ if (explicit != null) {
60
+ if (typeof explicit === "number") return explicit <= 0 ? "0" : `${explicit}px`;
61
+ return explicit;
62
+ }
63
+ const br = theme.style.borderRadius ?? 0;
64
+ if (br <= 0) return "0";
65
+ return `${Math.min(28, Math.max(6, Math.round(br)))}%`;
66
+ }
67
+ function resolveBorder(theme) {
68
+ const border = theme.style.pip?.border;
69
+ if (border === "none") return "none";
70
+ if (border && typeof border === "object") {
71
+ const width = border.width == null ? DERIVED_BORDER_WIDTH : cssLength(border.width);
72
+ const color = border.color ?? withAlpha(theme.colors.text, 0.35);
73
+ return `${width} solid ${color}`;
74
+ }
75
+ return `${DERIVED_BORDER_WIDTH} solid ${withAlpha(theme.colors.text, 0.35)}`;
76
+ }
77
+ function resolveShadow(theme) {
78
+ const shadow = theme.style.pip?.shadow;
79
+ if (shadow === false || shadow === "none") return "none";
80
+ if (typeof shadow === "string") return shadow;
81
+ return DEFAULT_SHADOW;
82
+ }
83
+ function pipStyleVars(theme) {
84
+ return {
85
+ "--squisq-pip-radius": resolveRadius(theme),
86
+ "--squisq-pip-border": resolveBorder(theme),
87
+ "--squisq-pip-shadow": resolveShadow(theme)
88
+ };
89
+ }
90
+
50
91
  // src/schemas/themeCompile.ts
51
92
  var STARTER_BODY_FONT = { stackId: "system-sans" };
52
93
  var STARTER_TITLE_FONT = { stackId: "system-serif" };
@@ -308,6 +349,7 @@ export {
308
349
  getSegmentAtTime,
309
350
  getBlockAtTime,
310
351
  getCaptionAtTime,
352
+ pipStyleVars,
311
353
  STARTER_THEME,
312
354
  deriveColorPalette,
313
355
  accentToColorScheme,
@@ -2,7 +2,7 @@ import {
2
2
  assertMarkdownDocumentWithinLimits,
3
3
  parseMarkdown,
4
4
  toMdast
5
- } from "./chunk-D4LPP3P5.js";
5
+ } from "./chunk-7TJJA2RI.js";
6
6
  import {
7
7
  formatFrontmatterYaml,
8
8
  getChildren,