@bendyline/squisq 1.5.2 → 2.0.0

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 (263) hide show
  1. package/README.md +63 -10
  2. package/dist/{Doc-BBVGq1_9.d.ts → Doc-ylqWKDc_.d.ts} +248 -37
  3. package/dist/{ImageEditDoc-FuyGtt6o.d.ts → ImageEditDoc-D828IXJ1.d.ts} +1 -1
  4. package/dist/annotationCoercion-Dr_DY9Hx.d.ts +86 -0
  5. package/dist/{chunk-VWUFZ6ZG.js → chunk-3E5F2XMR.js} +2 -29
  6. package/dist/chunk-3E5F2XMR.js.map +1 -0
  7. package/dist/chunk-4X3JQXNM.js +35 -0
  8. package/dist/chunk-4X3JQXNM.js.map +1 -0
  9. package/dist/{chunk-P3K7NLHF.js → chunk-5DKBFXPY.js} +31 -121
  10. package/dist/chunk-5DKBFXPY.js.map +1 -0
  11. package/dist/{chunk-DLXZMS5K.js → chunk-5J4HKRJF.js} +51 -3
  12. package/dist/chunk-5J4HKRJF.js.map +1 -0
  13. package/dist/chunk-5UYI3RJB.js +2503 -0
  14. package/dist/chunk-5UYI3RJB.js.map +1 -0
  15. package/dist/{chunk-BEQODJWV.js → chunk-66QO7XFB.js} +11 -291
  16. package/dist/chunk-66QO7XFB.js.map +1 -0
  17. package/dist/{chunk-KKNUBQ6Y.js → chunk-6PJRB2CF.js} +156 -91
  18. package/dist/chunk-6PJRB2CF.js.map +1 -0
  19. package/dist/{chunk-HWVFJAAH.js → chunk-AMIR72JP.js} +28 -10
  20. package/dist/chunk-AMIR72JP.js.map +1 -0
  21. package/dist/chunk-FVJUUTEM.js +74 -0
  22. package/dist/chunk-FVJUUTEM.js.map +1 -0
  23. package/dist/{chunk-5TYS5V3G.js → chunk-GF3BVNLU.js} +4127 -3538
  24. package/dist/chunk-GF3BVNLU.js.map +1 -0
  25. package/dist/{chunk-Q3ROPT5H.js → chunk-GZY66SDN.js} +1 -1
  26. package/dist/{chunk-Q3ROPT5H.js.map → chunk-GZY66SDN.js.map} +1 -1
  27. package/dist/chunk-JOQYPRDZ.js +127 -0
  28. package/dist/chunk-JOQYPRDZ.js.map +1 -0
  29. package/dist/{chunk-A4O7GIWE.js → chunk-LYNJEOAC.js} +10 -73
  30. package/dist/chunk-LYNJEOAC.js.map +1 -0
  31. package/dist/{chunk-LDQ2HJIX.js → chunk-PXLVXTLW.js} +252 -54
  32. package/dist/chunk-PXLVXTLW.js.map +1 -0
  33. package/dist/{chunk-TQWLI6S2.js → chunk-Q7LROV2H.js} +4 -2
  34. package/dist/{chunk-TQWLI6S2.js.map → chunk-Q7LROV2H.js.map} +1 -1
  35. package/dist/{chunk-T5UK6YOB.js → chunk-QTSJOY54.js} +60 -17
  36. package/dist/chunk-QTSJOY54.js.map +1 -0
  37. package/dist/chunk-QVANWDPH.js +2358 -0
  38. package/dist/chunk-QVANWDPH.js.map +1 -0
  39. package/dist/{chunk-GPLTCSXO.js → chunk-R2GC6RLD.js} +7 -7
  40. package/dist/chunk-R2GC6RLD.js.map +1 -0
  41. package/dist/chunk-R2YZTCLO.js +292 -0
  42. package/dist/chunk-R2YZTCLO.js.map +1 -0
  43. package/dist/chunk-S7A5D7ZJ.js +174 -0
  44. package/dist/chunk-S7A5D7ZJ.js.map +1 -0
  45. package/dist/chunk-T3TI7GSZ.js +884 -0
  46. package/dist/chunk-T3TI7GSZ.js.map +1 -0
  47. package/dist/{chunk-LTN6I7QW.js → chunk-TUWMK62B.js} +55 -4
  48. package/dist/chunk-TUWMK62B.js.map +1 -0
  49. package/dist/{chunk-IMSCRLLV.js → chunk-VR7UPJ7C.js} +35 -25
  50. package/dist/chunk-VR7UPJ7C.js.map +1 -0
  51. package/dist/doc/index.d.ts +2334 -5
  52. package/dist/doc/index.js +127 -33
  53. package/dist/generate/index.d.ts +7 -2
  54. package/dist/generate/index.js +1 -1
  55. package/dist/imageEdit/index.d.ts +9 -6
  56. package/dist/imageEdit/index.js +3 -3
  57. package/dist/index.d.ts +12 -10
  58. package/dist/index.js +246 -80
  59. package/dist/jsonForm/index.d.ts +7 -3
  60. package/dist/jsonForm/index.js +9 -4
  61. package/dist/markdown/index.d.ts +6 -70
  62. package/dist/markdown/index.js +13 -9
  63. package/dist/narration/index.d.ts +618 -0
  64. package/dist/narration/index.js +82 -0
  65. package/dist/recommend/index.d.ts +15 -1
  66. package/dist/recommend/index.js +2 -2
  67. package/dist/schemas/index.d.ts +28 -6
  68. package/dist/schemas/index.js +15 -13
  69. package/dist/spatial/index.d.ts +0 -1
  70. package/dist/spatial/index.js +1 -1
  71. package/dist/storage/index.js +1 -1
  72. package/dist/{themeLibrary-CehcJhzz.d.ts → themeLibrary-RjVgLpUi.d.ts} +10 -11
  73. package/dist/timing/index.js +5 -3
  74. package/dist/transform/index.d.ts +35 -24
  75. package/dist/transform/index.js +9 -10
  76. package/dist/{types-DlAZ7MW4.d.ts → types-BwMPl2CB.d.ts} +1 -1
  77. package/dist/{types-D98li1gV.d.ts → types-C4kiRn_k.d.ts} +3 -1
  78. package/dist/versions/index.d.ts +2 -1
  79. package/dist/versions/index.js +2 -2
  80. package/package.json +6 -6
  81. package/src/__tests__/applyNarrationTiming.test.ts +190 -0
  82. package/src/__tests__/applyRenderStyle.test.ts +3 -3
  83. package/src/__tests__/asciiDiagramBattle.test.ts +246 -0
  84. package/src/__tests__/asciiDiagramDetect.test.ts +162 -0
  85. package/src/__tests__/asciiDiagramMapping.test.ts +38 -0
  86. package/src/__tests__/asciiDiagramParse.test.ts +233 -0
  87. package/src/__tests__/asciiDiagramPipeline.test.ts +273 -0
  88. package/src/__tests__/asciiDiagramRender.test.ts +162 -0
  89. package/src/__tests__/asciiDiagramRepair.test.ts +84 -0
  90. package/src/__tests__/asciiTimelineDetect.test.ts +157 -0
  91. package/src/__tests__/asciiTimelineParse.test.ts +205 -0
  92. package/src/__tests__/asciiTimelinePipeline.test.ts +349 -0
  93. package/src/__tests__/asciiTimelineRender.test.ts +376 -0
  94. package/src/__tests__/attrTokens.test.ts +5 -0
  95. package/src/__tests__/contentContainer.test.ts +43 -0
  96. package/src/__tests__/customTemplatesFrontmatter.test.ts +0 -15
  97. package/src/__tests__/dataTable.test.ts +25 -15
  98. package/src/__tests__/diagramBlock.test.ts +3 -3
  99. package/src/__tests__/diagramText.test.ts +26 -0
  100. package/src/__tests__/docToMarkdownMedia.test.ts +83 -0
  101. package/src/__tests__/drawingBlock.test.ts +3 -3
  102. package/src/__tests__/fixtures/asciiDiagramBattle.ts +512 -0
  103. package/src/__tests__/fixtures/asciiDiagrams.ts +287 -0
  104. package/src/__tests__/fixtures/asciiTimelines.ts +35 -0
  105. package/src/__tests__/fixtures/treeviewFixtures.ts +243 -0
  106. package/src/__tests__/getLayers.test.ts +32 -18
  107. package/src/__tests__/getLayersFallback.test.ts +8 -8
  108. package/src/__tests__/imageEditVersions.test.ts +2 -0
  109. package/src/__tests__/jsonForm.pointer.test.ts +47 -1
  110. package/src/__tests__/layoutBlock.test.ts +3 -3
  111. package/src/__tests__/majorApiTypes.test.ts +18 -0
  112. package/src/__tests__/markdown.test.ts +41 -0
  113. package/src/__tests__/matchFontFamily.test.ts +114 -0
  114. package/src/__tests__/materializeBlockLayers.test.ts +135 -0
  115. package/src/__tests__/materializeTestUtils.ts +17 -0
  116. package/src/__tests__/narrationAlign.test.ts +150 -0
  117. package/src/__tests__/narrationFeatures.test.ts +71 -0
  118. package/src/__tests__/narrationNuclei.test.ts +45 -0
  119. package/src/__tests__/narrationPacing.test.ts +189 -0
  120. package/src/__tests__/narrationScript.test.ts +149 -0
  121. package/src/__tests__/narrationSessionRepro.test.ts +62 -0
  122. package/src/__tests__/narrationSidecar.test.ts +88 -0
  123. package/src/__tests__/narrationSyllables.test.ts +65 -0
  124. package/src/__tests__/narrationTestSignals.ts +167 -0
  125. package/src/__tests__/narrationVad.test.ts +66 -0
  126. package/src/__tests__/resolveDocTheme.test.ts +16 -2
  127. package/src/__tests__/rootExports.test.ts +18 -0
  128. package/src/__tests__/scopedContentContainer.test.ts +20 -0
  129. package/src/__tests__/shapeGeometry.test.ts +12 -0
  130. package/src/__tests__/templateAnnotationParse.test.ts +10 -0
  131. package/src/__tests__/templateInputs.test.ts +69 -0
  132. package/src/__tests__/templateMetadata.test.ts +2 -1
  133. package/src/__tests__/templates.test.ts +143 -17
  134. package/src/__tests__/themeCompile.test.ts +49 -22
  135. package/src/__tests__/transformProvenance.test.ts +160 -0
  136. package/src/__tests__/transformV2.test.ts +40 -14
  137. package/src/__tests__/treeviewBattle.test.ts +76 -0
  138. package/src/__tests__/treeviewDetect.test.ts +168 -0
  139. package/src/__tests__/treeviewParse.test.ts +118 -0
  140. package/src/__tests__/treeviewPipeline.test.ts +183 -0
  141. package/src/__tests__/treeviewRender.test.ts +91 -0
  142. package/src/__tests__/versions.test.ts +44 -0
  143. package/src/doc/applyNarrationTiming.ts +244 -0
  144. package/src/doc/asciiDiagram/chars.ts +210 -0
  145. package/src/doc/asciiDiagram/detect.ts +175 -0
  146. package/src/doc/asciiDiagram/index.ts +38 -0
  147. package/src/doc/asciiDiagram/mapping.ts +225 -0
  148. package/src/doc/asciiDiagram/parse.ts +1095 -0
  149. package/src/doc/asciiDiagram/render.ts +963 -0
  150. package/src/doc/asciiDiagram/repair.ts +400 -0
  151. package/src/doc/asciiDiagram/types.ts +65 -0
  152. package/src/doc/asciiTimeline/detect.ts +138 -0
  153. package/src/doc/asciiTimeline/index.ts +26 -0
  154. package/src/doc/asciiTimeline/mapping.ts +43 -0
  155. package/src/doc/asciiTimeline/parse.ts +870 -0
  156. package/src/doc/asciiTimeline/render.ts +427 -0
  157. package/src/doc/asciiTimeline/types.ts +73 -0
  158. package/src/doc/asciiTimeline/wrappedFlow.ts +427 -0
  159. package/src/doc/audioMapping.ts +60 -46
  160. package/src/doc/customTemplatesFrontmatter.ts +0 -41
  161. package/src/doc/docToMarkdown.ts +70 -2
  162. package/src/doc/index.ts +76 -4
  163. package/src/doc/markdownToDoc.ts +135 -1
  164. package/src/doc/materializeBlockLayers.ts +304 -0
  165. package/src/doc/mediaAnnotations.ts +20 -0
  166. package/src/doc/resolveDocTheme.ts +8 -7
  167. package/src/doc/templateInputs.ts +185 -2
  168. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +22 -8
  169. package/src/doc/templates/diagramBlock.ts +237 -38
  170. package/src/doc/templates/fallbackBlock.ts +1 -1
  171. package/src/doc/templates/index.ts +134 -279
  172. package/src/doc/templates/inputDescriptors.ts +20 -1
  173. package/src/doc/templates/metadata.ts +10 -0
  174. package/src/doc/templates/persistentLayers.ts +12 -126
  175. package/src/doc/templates/registry.ts +88 -0
  176. package/src/doc/templates/templateNames.ts +22 -0
  177. package/src/doc/templates/timelineBlock.ts +613 -0
  178. package/src/doc/templates/treeBlock.ts +131 -0
  179. package/src/doc/treeview/chars.ts +72 -0
  180. package/src/doc/treeview/detect.ts +145 -0
  181. package/src/doc/treeview/index.ts +30 -0
  182. package/src/doc/treeview/mapping.ts +95 -0
  183. package/src/doc/treeview/parse.ts +201 -0
  184. package/src/doc/treeview/render.ts +41 -0
  185. package/src/doc/treeview/types.ts +43 -0
  186. package/src/doc/utils/applyRenderStyle.ts +2 -9
  187. package/src/doc/utils/diagramText.ts +78 -0
  188. package/src/doc/utils/shapeGeometry.ts +67 -5
  189. package/src/doc/validate.ts +1 -1
  190. package/src/generate/templateMapper.ts +7 -0
  191. package/src/imageEdit/export.ts +6 -5
  192. package/src/imageEdit/versionPaths.ts +13 -26
  193. package/src/imageEdit/versions.ts +21 -100
  194. package/src/index.ts +1 -0
  195. package/src/internal/immutable.ts +58 -0
  196. package/src/jsonForm/index.ts +9 -1
  197. package/src/jsonForm/pointer.ts +68 -23
  198. package/src/markdown/attrTokens.ts +7 -5
  199. package/src/markdown/index.ts +1 -0
  200. package/src/markdown/stringify.ts +4 -9
  201. package/src/markdown/utils.ts +36 -14
  202. package/src/narration/align.ts +514 -0
  203. package/src/narration/features.ts +231 -0
  204. package/src/narration/index.ts +86 -0
  205. package/src/narration/nuclei.ts +118 -0
  206. package/src/narration/pacing.ts +211 -0
  207. package/src/narration/script.ts +239 -0
  208. package/src/narration/session.ts +100 -0
  209. package/src/narration/sidecar.ts +187 -0
  210. package/src/narration/syllables.ts +85 -0
  211. package/src/narration/trace.ts +50 -0
  212. package/src/narration/types.ts +299 -0
  213. package/src/narration/vad.ts +131 -0
  214. package/src/recommend/numberHighlight.ts +25 -0
  215. package/src/recommend/templates.ts +108 -12
  216. package/src/schemas/BlockTemplates.ts +156 -7
  217. package/src/schemas/Doc.ts +72 -9
  218. package/src/schemas/Media.ts +12 -2
  219. package/src/schemas/Theme.ts +45 -25
  220. package/src/schemas/Viewport.ts +2 -2
  221. package/src/schemas/fontStacks.ts +79 -0
  222. package/src/schemas/themeCompile.ts +15 -0
  223. package/src/schemas/themeConstants.ts +2 -0
  224. package/src/schemas/themeLibrary.ts +25 -19
  225. package/src/schemas/themeValidator.ts +1 -1
  226. package/src/spatial/Geohash.ts +0 -3
  227. package/src/storage/ContentContainer.ts +17 -9
  228. package/src/storage/ScopedContentContainer.ts +45 -15
  229. package/src/transform/applyTransform.ts +5 -5
  230. package/src/transform/index.ts +3 -1
  231. package/src/transform/registry.ts +169 -49
  232. package/src/transform/templateSelector.ts +21 -2
  233. package/src/transform/timingAllocator.ts +152 -21
  234. package/src/transform/types.ts +14 -1
  235. package/src/versions/gitignore.ts +34 -0
  236. package/src/versions/index.ts +2 -0
  237. package/src/versions/operations.ts +18 -104
  238. package/src/versions/paths.ts +13 -28
  239. package/src/versions/snapshotStore.ts +202 -0
  240. package/src/versions/types.ts +3 -1
  241. package/dist/chunk-5TYS5V3G.js.map +0 -1
  242. package/dist/chunk-A4O7GIWE.js.map +0 -1
  243. package/dist/chunk-BEQODJWV.js.map +0 -1
  244. package/dist/chunk-DLXZMS5K.js.map +0 -1
  245. package/dist/chunk-GPLTCSXO.js.map +0 -1
  246. package/dist/chunk-HWVFJAAH.js.map +0 -1
  247. package/dist/chunk-IMSCRLLV.js.map +0 -1
  248. package/dist/chunk-JELIRVDP.js +0 -24
  249. package/dist/chunk-JELIRVDP.js.map +0 -1
  250. package/dist/chunk-KKNUBQ6Y.js.map +0 -1
  251. package/dist/chunk-LDQ2HJIX.js.map +0 -1
  252. package/dist/chunk-LTN6I7QW.js.map +0 -1
  253. package/dist/chunk-P3K7NLHF.js.map +0 -1
  254. package/dist/chunk-T5UK6YOB.js.map +0 -1
  255. package/dist/chunk-UY7KGQ5R.js +0 -192
  256. package/dist/chunk-UY7KGQ5R.js.map +0 -1
  257. package/dist/chunk-VLJJHDAC.js +0 -218
  258. package/dist/chunk-VLJJHDAC.js.map +0 -1
  259. package/dist/chunk-VWUFZ6ZG.js.map +0 -1
  260. package/dist/story/index.d.ts +0 -1801
  261. package/dist/story/index.js +0 -279
  262. package/src/doc/getLayers.ts +0 -195
  263. /package/dist/{story → narration}/index.js.map +0 -0
@@ -1,1801 +0,0 @@
1
- import { a4 as PersistentLayer, az as Theme, S as Layer, a5 as PersistentLayerConfig, aG as TitleBlockInput, au as TemplateContext, ai as SectionHeaderInput, ao as StatHighlightInput, ad as QuoteBlockInput, I as FactCardInput, aI as TwoColumnInput, u as DateEventInput, Q as ImageWithCaptionInput, V as LeftFeatureInput, ag as RightFeatureInput, Y as MapBlockInput, an as StartBlockConfig, L as FullBleedQuoteInput, X as ListBlockInput, a9 as PhotoGridInput, w as DefinitionCardInput, n as ComparisonBarInput, ac as PullQuoteInput, aM as VideoWithCaptionInput, aL as VideoPullQuoteInput, t as DataTableInput, x as DiagramBlockInput, B as Block, F as DrawingBlockInput, a0 as MarkerStyle, at as TemplateBlock, A as AccentImage, P as ImageTreatment, a as AccentPosition, aN as ViewportConfig, p as CustomTemplateDefinition, z as DocBlock, aw as TemplateRegistry, c as Animation, d as AnimationType, aB as ThemeColorScheme, y as Doc, E as DocDiagnostic } from '../Doc-BBVGq1_9.js';
2
- export { G as FRONTMATTER_CUSTOM_TEMPLATES_KEY, H as FRONTMATTER_CUSTOM_THEMES_KEY, U as LayoutHints, af as RenderStyle, aA as ThemeColorPalette, aE as ThemeStyle, aF as ThemeTypography, aJ as VIEWPORT_PRESETS, aO as ViewportOrientation, aP as ViewportPreset, aU as createTemplateContext, a_ as getLayoutHints, b2 as getTwoColumnPositions, b3 as getViewport, b4 as getViewportOrientation, b6 as isTemplateBlock, bb as scaledFontSize } from '../Doc-BBVGq1_9.js';
3
- import { I as MarkdownNode, $ as TransitionType, _ as TransitionDirection, M as MarkdownBlockNode, q as MarkdownHeading, m as MarkdownDocument, P as MarkdownTable, h as MarkdownCodeBlock } from '../types-DlAZ7MW4.js';
4
- import { C as ContentContainer } from '../ContentContainer-BXUlIf18.js';
5
- export { D as DEFAULT_THEME, g as getAvailableThemes, b as getThemeSummaries, r as resolveTheme } from '../themeLibrary-CehcJhzz.js';
6
-
7
- /**
8
- * Canonical, framework-free UI metadata for every built-in block template.
9
- *
10
- * This is the single source of truth for the human-readable label and the
11
- * one-sentence description of each template id in {@link templateRegistry}.
12
- * The editor's `TemplatePicker` renders its gallery from this map (joining
13
- * each id with a locally-defined SVG icon, which can't live in this
14
- * framework-free package), so a template only has to be added here and to
15
- * `templateRegistry` for it to surface in the editor.
16
- *
17
- * `templateMetadata.test.ts` asserts this map and `templateRegistry` stay
18
- * exactly 1:1 — adding a template to one without the other fails the build.
19
- *
20
- * Order matters: pickers iterate this object's insertion order, so it doubles
21
- * as the canonical gallery order.
22
- */
23
- interface TemplateMetadata {
24
- /** Human-readable label shown in pickers (e.g. "Image with Caption"). */
25
- label: string;
26
- /** One-sentence description of when to reach for this template. */
27
- description: string;
28
- }
29
- declare const TEMPLATE_METADATA: Record<string, TemplateMetadata>;
30
-
31
- /**
32
- * Persistent Layers Expansion
33
- *
34
- * Expands persistent layer templates (solid backgrounds, gradients, overlays)
35
- * into raw Layer arrays. These layers are injected into each block based on
36
- * per-block flags (useBottomLayer, useTopLayer).
37
- *
38
- * This is shared code used by both site and efb-app doc renderers.
39
- *
40
- * Related Files:
41
- * - schemas/BlockTemplates.ts - PersistentLayerConfig types
42
- */
43
-
44
- /**
45
- * Expand all persistent layers in a config to raw Layer arrays.
46
- */
47
- declare function expandPersistentLayers(layers: PersistentLayer[] | undefined, theme?: Theme): Layer[];
48
- /** Legacy style preset names. Prefer using `Theme.persistentLayers` directly. */
49
- type DocStylePreset = 'minimal' | 'documentary' | 'branded' | 'cinematic' | 'clean';
50
- /**
51
- * Get a PersistentLayerConfig from a style preset.
52
- *
53
- * @param preset - Style preset name
54
- * @param articleTitle - Article title for title caption
55
- * @param heroSrc - Optional hero image for cinematic style
56
- */
57
- declare function getDocStyleConfig(preset: DocStylePreset, articleTitle: string, heroSrc?: string, subtitle?: string): PersistentLayerConfig;
58
- /**
59
- * Get persistent layers from a Theme. Returns the theme's baked-in
60
- * persistentLayers config, or an empty config when the theme has none.
61
- */
62
- declare function getPersistentLayersFromTheme(theme: Theme): PersistentLayerConfig;
63
- /**
64
- * Resolve the effective persistent-layer config for a doc: the doc's own
65
- * config wins **wholesale** when present; only docs with no persistent
66
- * layers inherit the theme's.
67
- *
68
- * Doc-wins-wholesale (rather than merging) protects pre-baked documents
69
- * that carry their own background/branding layers — merging a theme's
70
- * atmosphere on top of those would double up backgrounds and stack
71
- * overlays the doc author never saw.
72
- */
73
- declare function resolvePersistentLayers(doc: {
74
- persistentLayers?: PersistentLayerConfig;
75
- }, theme: Theme): PersistentLayerConfig | undefined;
76
- /**
77
- * Compose a block's layers between pre-expanded persistent bottom/top
78
- * layers, honoring the per-block `useBottomLayer` / `useTopLayer` opt-outs.
79
- * Single shared implementation for `expandDocBlocks` and `getLayers`.
80
- */
81
- declare function wrapWithPersistentLayers(layers: Layer[], block: {
82
- useBottomLayer?: boolean;
83
- useTopLayer?: boolean;
84
- }, bottomLayers: Layer[], topLayers: Layer[]): Layer[];
85
-
86
- /**
87
- * Title Block Template
88
- *
89
- * Large title with optional subtitle for doc intros.
90
- * Centered text with fade-in animations, composed as one lockup:
91
- * accent rule, title, and subtitle are spaced from the title's
92
- * estimated height instead of fixed slots that collide on wrap.
93
- * Adapts font sizes and positioning for different viewports.
94
- *
95
- * This is shared code used by both site and efb-app doc renderers.
96
- */
97
-
98
- declare function titleBlock(input: TitleBlockInput, context: TemplateContext): Layer[];
99
-
100
- /**
101
- * Section Header Template
102
- *
103
- * Section title card with optional background image.
104
- * Used to introduce new sections of a story.
105
- * When an image is provided, displays like a title slide with the image as background.
106
- * Without an image, falls back to a colored background.
107
- *
108
- * This is shared code used by both site and efb-app doc renderers.
109
- */
110
-
111
- declare function sectionHeader(input: SectionHeaderInput, context: TemplateContext): Layer[];
112
-
113
- /**
114
- * Stat Highlight Template
115
- *
116
- * Large statistic/number with description and optional detail.
117
- * Great for emphasizing key data points.
118
- * Adapts font sizes and positioning for different viewports.
119
- *
120
- * Supports optional accent images that appear as tasteful side/bottom strips.
121
- *
122
- * This is shared code used by both site and efb-app doc renderers.
123
- */
124
-
125
- declare function statHighlight(input: StatHighlightInput, context: TemplateContext): Layer[];
126
-
127
- /**
128
- * Quote Block Template
129
- *
130
- * Large centered quote with optional attribution, composed as one
131
- * vertically-centered lockup: the attribution hangs a fixed distance
132
- * below the quote's estimated bottom edge instead of being pinned to a
133
- * far-away layout slot.
134
- * Adapts font sizes and positioning for different viewports.
135
- *
136
- * Supports optional accent images that appear as tasteful side/bottom strips.
137
- *
138
- * This is shared code used by both site and efb-app doc renderers.
139
- */
140
-
141
- declare function quoteBlock(input: QuoteBlockInput, context: TemplateContext): Layer[];
142
-
143
- /**
144
- * Fact Card Template
145
- *
146
- * Key fact with explanation and optional source, composed as one
147
- * vertically-centered lockup: each element is placed relative to the
148
- * estimated height of the one above it, so short content doesn't leave
149
- * fixed-slot voids and long content doesn't collide.
150
- * Adapts font sizes and positioning for different viewports.
151
- *
152
- * Supports optional accent images that appear as tasteful side/bottom strips.
153
- *
154
- * This is shared code used by both site and efb-app doc renderers.
155
- */
156
-
157
- declare function factCard(input: FactCardInput, context: TemplateContext): Layer[];
158
-
159
- /**
160
- * Two Column Template
161
- *
162
- * Side-by-side comparison of two items.
163
- * Each column has a label and optional sublabel.
164
- * Adapts font sizes and positioning for different viewports.
165
- *
166
- * Portrait mode: Stacks columns vertically (top/bottom) instead of side-by-side.
167
- *
168
- * This is shared code used by both site and efb-app doc renderers.
169
- */
170
-
171
- declare function twoColumn(input: TwoColumnInput, context: TemplateContext): Layer[];
172
-
173
- /**
174
- * Date Event Template
175
- *
176
- * Timeline-style slide with prominent date and description.
177
- * Supports different moods: neutral, somber, celebratory.
178
- * Adapts font sizes and positioning for different viewports.
179
- *
180
- * Supports optional accent images that appear as tasteful side/bottom strips.
181
- *
182
- * This is shared code used by both site and efb-app doc renderers.
183
- */
184
-
185
- declare function dateEvent(input: DateEventInput, context: TemplateContext): Layer[];
186
-
187
- /**
188
- * Image With Caption Template
189
- *
190
- * Full-screen background image with text overlay.
191
- * Supports Ken Burns animation effects (zoom, pan).
192
- * Adapts caption positioning and font sizes for different viewports.
193
- *
194
- * This is shared code used by both site and efb-app doc renderers.
195
- */
196
-
197
- declare function imageWithCaption(input: ImageWithCaptionInput, context: TemplateContext): Layer[];
198
-
199
- /**
200
- * Feature Block Templates — `leftFeature` and `rightFeature`
201
- *
202
- * Pairs a "feature" image on one side of the block with a title + body
203
- * paragraph on the other. The two templates are mirror images, so the
204
- * actual layer-builder lives here once and the per-side template files
205
- * just call it with a `side` parameter.
206
- *
207
- * Used for editorial layouts like product highlights, profile cards,
208
- * and section intros where a single image deserves to sit next to a
209
- * short text block rather than behind it (which is what
210
- * `imageWithCaption` does).
211
- */
212
-
213
- declare function leftFeature(input: LeftFeatureInput, context: TemplateContext): Layer[];
214
- declare function rightFeature(input: RightFeatureInput, context: TemplateContext): Layer[];
215
-
216
- /**
217
- * Map Block Template
218
- *
219
- * Full-screen geographic map with optional title and caption overlays.
220
- * Great for establishing geographic context at the start of a doc
221
- * or when discussing location-specific content.
222
- * Adapts font sizes and positioning for different viewports.
223
- *
224
- * Map tiles are fetched from free/open-source providers.
225
- * See docs/MAP_TILES.md for available styles and attribution requirements.
226
- *
227
- * This is shared code used by both site and efb-app doc renderers.
228
- */
229
-
230
- declare function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[];
231
-
232
- /**
233
- * Cover Block Template
234
- *
235
- * Full-screen hero image with title overlay, shown before playback starts.
236
- * This is the "poster for the doc, displaying the
237
- * article's hero image with elegant title treatment.
238
- *
239
- * Features:
240
- * - Full-screen hero image with Ken Burns ambient motion
241
- * - Gradient overlay for text readability
242
- * - Large centered title with optional subtitle
243
- * - No animation delays (shown at rest, not during playback)
244
- *
245
- * This is shared code used by both site and efb-app doc renderers.
246
- */
247
-
248
- /**
249
- * Input for coverBlock template - matches StartBlockConfig
250
- */
251
- interface CoverBlockInput {
252
- /** Path to hero image (omit for theme-driven background) */
253
- heroSrc?: string;
254
- /** Alt text for the hero image */
255
- heroAlt?: string;
256
- /** Title to display over the hero */
257
- title: string;
258
- /** Optional subtitle */
259
- subtitle?: string;
260
- /** Ambient motion for the hero image */
261
- ambientMotion?: 'zoomIn' | 'zoomOut' | 'panLeft' | 'panRight';
262
- /** Photo credit / artist name */
263
- heroCredit?: string;
264
- /** License identifier */
265
- heroLicense?: string;
266
- /** Per-block override for the theme's photographic image grade. */
267
- imageTreatment?: 'none' | 'mono' | 'duotone' | 'warm' | 'cool';
268
- }
269
- /**
270
- * Generate cover block layers from StartBlockConfig.
271
- */
272
- declare function coverBlock(input: CoverBlockInput, context: TemplateContext): Layer[];
273
- /**
274
- * Expand a StartBlockConfig into a renderable Block.
275
- * This is used by the player to render the cover block at rest.
276
- */
277
- declare function expandCoverBlock(config: StartBlockConfig, context: TemplateContext): Layer[];
278
-
279
- /**
280
- * Full Bleed Quote Template
281
- *
282
- * Short dramatic text filling the viewport like a movie title card.
283
- * Designed for punchy text under 60 characters. Uses massive font
284
- * centered on a dark vignette background.
285
- *
286
- * This is shared code used by both site and efb-app doc renderers.
287
- */
288
-
289
- declare function fullBleedQuote(input: FullBleedQuoteInput, context: TemplateContext): Layer[];
290
-
291
- /**
292
- * List Block Template
293
- *
294
- * Displays 3-5 items in a numbered vertical list with staggered animations.
295
- * Good for enumerations like "things to see", "key features", or "tips".
296
- * Supports optional accent images.
297
- *
298
- * This is shared code used by both site and efb-app doc renderers.
299
- */
300
-
301
- declare function listBlock(input: ListBlockInput, context: TemplateContext): Layer[];
302
-
303
- /**
304
- * Photo Grid Template
305
- *
306
- * Displays 2-4 images in a tiled layout for visual variety.
307
- * Layout adapts based on image count and viewport orientation:
308
- *
309
- * Landscape:
310
- * - 2 images: side-by-side 50/50
311
- * - 3 images: one large left (60%) + two stacked right
312
- * - 4 images: 2x2 grid
313
- *
314
- * Portrait (9:16): images stack horizontally (top/bottom) instead of
315
- * side-by-side, giving each image full width on narrow screens.
316
- *
317
- * This is shared code used by both site and efb-app doc renderers.
318
- */
319
-
320
- declare function photoGrid(input: PhotoGridInput, context: TemplateContext): Layer[];
321
-
322
- /**
323
- * Definition Card Template
324
- *
325
- * Dictionary-style slide with a large term and its definition.
326
- * Good for explaining local words, place names, or cultural concepts.
327
- * Supports optional accent images.
328
- *
329
- * This is shared code used by both site and efb-app doc renderers.
330
- */
331
-
332
- declare function definitionCard(input: DefinitionCardInput, context: TemplateContext): Layer[];
333
-
334
- /**
335
- * Comparison Bar Template
336
- *
337
- * Two horizontal bars showing relative numeric values side by side.
338
- * Bar widths are proportional to the values for immediate visual comparison.
339
- * Good for population, distance, or measurement comparisons.
340
- *
341
- * This is shared code used by both site and efb-app doc renderers.
342
- */
343
-
344
- declare function comparisonBar(input: ComparisonBarInput, context: TemplateContext): Layer[];
345
-
346
- /**
347
- * Pull Quote Template
348
- *
349
- * Quote text over a full-bleed background image with dark overlay.
350
- * Cinematic alternative to quoteBlock when a high-quality image is available.
351
- * Combines the visual impact of imageWithCaption with the text focus of quoteBlock.
352
- *
353
- * This is shared code used by both site and efb-app doc renderers.
354
- */
355
-
356
- declare function pullQuote(input: PullQuoteInput, context: TemplateContext): Layer[];
357
-
358
- /**
359
- * Video With Caption Template
360
- *
361
- * Full-screen background video clip with text overlay. Mirrors the structure of
362
- * imageWithCaption but uses a VideoLayer instead of an ImageLayer. The video
363
- * plays muted — narration audio is the only sound track.
364
- *
365
- * Adapts caption positioning and font sizes for different viewports.
366
- *
367
- * This is shared code used by both site and efb-app doc renderers.
368
- *
369
- * Related Files:
370
- * - shared/story/templates/imageWithCaption.ts — image equivalent
371
- * - schemas/StoryScript.ts — VideoLayer type
372
- * - site/src/components/story/layers/VideoLayer.tsx — rendering component
373
- */
374
-
375
- declare function videoWithCaption(input: VideoWithCaptionInput, context: TemplateContext): Layer[];
376
-
377
- /**
378
- * Video Pull Quote Template
379
- *
380
- * Quote text over a video clip background with dark overlay.
381
- * Cinematic alternative to pullQuote when a video clip is available.
382
- * Combines the visual dynamism of live video with the text focus of quoteBlock.
383
- *
384
- * The video plays muted — narration audio is the only sound track.
385
- *
386
- * This is shared code used by both site and efb-app doc renderers.
387
- *
388
- * Related Files:
389
- * - shared/story/templates/pullQuote.ts — image-based equivalent
390
- * - schemas/StoryScript.ts — VideoLayer type
391
- * - site/src/components/story/layers/VideoLayer.tsx — rendering component
392
- */
393
-
394
- declare function videoPullQuote(input: VideoPullQuoteInput, context: TemplateContext): Layer[];
395
-
396
- /**
397
- * Data Table Template
398
- *
399
- * Renders a themed table with header row and data rows.
400
- * Uses a TableLayer (foreignObject-based HTML table inside SVG)
401
- * for proper table layout within the viewport.
402
- *
403
- * Adapts font sizes for different viewports and uses theme colors
404
- * for header background, text, borders, and body cells.
405
- */
406
-
407
- declare function dataTable(input: DataTableInput, context: TemplateContext): Layer[];
408
-
409
- /**
410
- * Diagram block template.
411
- *
412
- * Renders the parent block's children as a node-and-edge diagram:
413
- * - Each child becomes a rounded-rect node card with its title as label.
414
- * - Each `child.connectsTo` entry becomes a path edge (cubic-bezier curve
415
- * with an arrowhead at the target end).
416
- * - Children with `x`/`y` set are placed at those coordinates; the rest
417
- * are auto-laid out below in a square-ish grid (see `diagramLayout.ts`).
418
- *
419
- * Layout coordinates from `x=`/`y=` are author-defined units. The
420
- * template computes a bounding box of all nodes and scales it to fit
421
- * the block's viewport with padding, so users don't have to think about
422
- * absolute pixel ranges.
423
- */
424
-
425
- declare function diagramBlock(input: DiagramBlockInput, context: TemplateContext): Layer[];
426
-
427
- /**
428
- * Diagram layout — shared between the read-only SVG render path
429
- * (`diagramBlock` template) and the interactive editor (React Flow in
430
- * `@bendyline/squisq-editor-react`). Same children + same options always
431
- * produce the same node positions and edge list, so previews and the
432
- * editor stay visually consistent.
433
- *
434
- * Layout rules:
435
- * 1. Children with both `x` and `y` set keep their authored coordinates.
436
- * 2. Children missing either coordinate are auto-placed in a square-ish
437
- * grid in declaration order, offset below the bounding box of the
438
- * explicitly-positioned children.
439
- * 3. Edges come from each child's `connectsTo`. Targets that don't match
440
- * any sibling id are dropped (and counted in `warnings`).
441
- */
442
-
443
- interface DiagramNodePosition {
444
- /** Block id (matches `Block.id`). */
445
- id: string;
446
- /** Display label (block title or fallback to id). */
447
- label: string;
448
- /** Pixel x coordinate (canvas-relative). */
449
- x: number;
450
- /** Pixel y coordinate (canvas-relative). */
451
- y: number;
452
- /** True when the position came from `x=`/`y=` attributes; false when auto-laid out. */
453
- pinned: boolean;
454
- /** Optional `.class` tokens carried over from the heading. */
455
- classes?: string[];
456
- }
457
- interface DiagramEdge {
458
- /** Synthetic stable edge id. */
459
- id: string;
460
- /** Source node id. */
461
- source: string;
462
- /** Target node id. */
463
- target: string;
464
- /** Connection type from `connectsTo=target:type` (used as edge label). */
465
- type?: string;
466
- }
467
- interface DiagramLayout {
468
- nodes: DiagramNodePosition[];
469
- edges: DiagramEdge[];
470
- warnings: string[];
471
- }
472
- interface DiagramLayoutOptions {
473
- /** Horizontal grid pitch between auto-laid-out nodes. Default: 260 (node width 180 + 80 air). */
474
- gapX?: number;
475
- /** Vertical grid pitch between auto-laid-out nodes. Default: 140. */
476
- gapY?: number;
477
- /** Padding around the explicit-positions bounding box before the grid starts. Default: 80. */
478
- gridPad?: number;
479
- /** Origin x for the grid when no explicit nodes anchor it. Default: 80. */
480
- gridOriginX?: number;
481
- /** Origin y for the grid when no explicit nodes anchor it. Default: 80. */
482
- gridOriginY?: number;
483
- }
484
- /**
485
- * Compute node positions and edges for a diagram from a parent block's
486
- * children. Pure function — same inputs always produce the same output.
487
- */
488
- declare function computeDiagramLayout(children: readonly Block[], options?: DiagramLayoutOptions): DiagramLayout;
489
-
490
- /**
491
- * Drawing block template.
492
- *
493
- * Renders the parent block's children as free-form shapes on a canvas:
494
- * - Each child becomes a shape (`rect`/`circle` → ShapeLayer, `line`/
495
- * `arrow`/`path` → PathLayer, `text` → TextLayer) with its title as a
496
- * centered label and its body text as an optional sublabel.
497
- * - `line`/`arrow` children with `from`/`to` (and any child's
498
- * `connectsTo`) become connectors clipped to the shapes they join.
499
- *
500
- * Coordinates from `x`/`y`/`width`/`height` are author-defined units; the
501
- * template fits the bounding box of all shapes to the viewport with
502
- * padding (same approach as `diagramBlock`), so authors don't think in
503
- * absolute pixels.
504
- */
505
-
506
- declare function drawingBlock(input: DrawingBlockInput, context: TemplateContext): Layer[];
507
-
508
- /**
509
- * shapeGeometry — pure SVG geometry for the drawing/diagram shape vocabulary.
510
- *
511
- * Three concerns, all deterministic and dependency-free:
512
- * - `shapePath(kind, x, y, w, h)` → an SVG path `d` for a named shape inscribed
513
- * in a bounding box. Returns null for the natively-rendered primitives
514
- * (rect / circle / line / text / path) so the caller can keep using a
515
- * `ShapeLayer` for those; everything else becomes a computed `PathLayer`.
516
- * - `markerPath(style, dir)` → the `<marker>` path for a line end-style, in the
517
- * standard 0–10 marker viewBox (shared by the SSR `PathLayer` renderer and the
518
- * editor's edge renderer).
519
- * - `connectorPath(routing, start, end)` + `snapEndpoints(a, b)` → the line/edge
520
- * geometry between two shapes (straight / orthogonal / curved), lifted from the
521
- * diagram template so drawings and diagrams draw identical connectors. The older
522
- * `clipEndpoints(a, b)` helper remains for free-angle clipping, but rendered
523
- * connectors use snapped ports so authored lines land on stable attachment points.
524
- */
525
-
526
- /** Connector routing styles. */
527
- type ConnectorRouting = 'straight' | 'orthogonal' | 'curved';
528
- /**
529
- * Shape kinds rendered as computed paths (everything except the primitives the
530
- * renderer draws natively). Used by templates to decide ShapeLayer vs PathLayer.
531
- */
532
- declare const PATH_SHAPE_KINDS: Set<string>;
533
- /**
534
- * SVG path `d` for a named shape inscribed in `[x, y, w, h]`, or null when the
535
- * kind is rendered natively (rect / circle / line / text / path / arrow).
536
- */
537
- declare function shapePath(kind: string, x: number, y: number, w: number, h: number): string | null;
538
- /**
539
- * The `<marker>` path for a line end-style, in the 0–10 marker viewBox.
540
- * `dir` selects orientation (`end` points along +x; `start` is mirrored).
541
- * Returns null for `'none'`. `filled` shapes paint with the stroke color;
542
- * non-filled (`open`) draw as a stroked outline.
543
- */
544
- declare function markerPath(style: MarkerStyle, dir: 'start' | 'end'): {
545
- d: string;
546
- filled: boolean;
547
- } | null;
548
- interface ClipBox {
549
- cx: number;
550
- cy: number;
551
- rx: number;
552
- ry: number;
553
- }
554
- type ConnectorPort = 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
555
- interface ConnectorSnapPoint {
556
- port: ConnectorPort;
557
- x: number;
558
- y: number;
559
- }
560
- /** Intersection of the center-to-center line with `from`'s bounding box. */
561
- declare function clipPoint(from: ClipBox, to: ClipBox): {
562
- x: number;
563
- y: number;
564
- };
565
- /** Clip both endpoints of an edge to the two shapes it joins. */
566
- declare function clipEndpoints(a: ClipBox, b: ClipBox): {
567
- start: {
568
- x: number;
569
- y: number;
570
- };
571
- end: {
572
- x: number;
573
- y: number;
574
- };
575
- };
576
- /** The stable connector ports exposed around a shape/card box. */
577
- declare function snapPoints(box: ClipBox): ConnectorSnapPoint[];
578
- /** Nearest stable connector port on `box` to an arbitrary point. */
579
- declare function nearestSnapPoint(box: ClipBox, point: {
580
- x: number;
581
- y: number;
582
- }): ConnectorSnapPoint;
583
- /**
584
- * Pick the pair of connector ports, one on each box, with the shortest
585
- * distance between them. This gives stable attachments to side/corner handles
586
- * instead of arbitrary center-ray intersections.
587
- */
588
- declare function snapEndpoints(a: ClipBox, b: ClipBox): {
589
- start: ConnectorSnapPoint;
590
- end: ConnectorSnapPoint;
591
- };
592
- /** Build the SVG `d` for a connector between two clipped endpoints. */
593
- declare function connectorPath(routing: ConnectorRouting, start: {
594
- x: number;
595
- y: number;
596
- }, end: {
597
- x: number;
598
- y: number;
599
- }): string;
600
- /** Map a `lineStyle` (solid|dashed|dotted) to an SVG `stroke-dasharray`. */
601
- declare function lineStyleDasharray(style: string | undefined): string | undefined;
602
-
603
- /**
604
- * Drawing layout — shared, pure derivation of shapes + connectors from a
605
- * drawing block's child headings. Same children always produce the same
606
- * shapes, so SSR previews, exports, and (eventually) the editor stay
607
- * visually consistent. Mirrors `diagramLayout.ts` for the richer
608
- * free-form shape vocabulary.
609
- *
610
- * Each child heading is one shape. Its `{[shape …]}` annotation names the
611
- * primitive (`child.template`) and carries geometry/style as string params
612
- * (`child.templateOverrides`); `child.id` makes it referenceable;
613
- * `child.title` is the label.
614
- *
615
- * Layout rules (parallel to the diagram):
616
- * 1. Shapes with both `x` and `y` keep their authored coordinates.
617
- * 2. Shapes missing either are auto-placed in a square-ish grid below the
618
- * bounding box of the explicitly-positioned shapes.
619
- * 3. `line`/`arrow` shapes with `from`/`to` (or any shape's `connectsTo`)
620
- * become connectors; endpoints that match no sibling id are dropped
621
- * (and counted in `warnings`).
622
- */
623
-
624
- /**
625
- * The shape kinds a drawing can render. `rect`/`circle`/`line` render as a
626
- * native `ShapeLayer`; everything else (and `path`/`arrow`) renders as a
627
- * computed `PathLayer` (see `shapeGeometry.ts`). `text` is a `TextLayer`.
628
- */
629
- type DrawingShapeKind = 'rect' | 'circle' | 'line' | 'arrow' | 'path' | 'text' | 'triangle' | 'right-triangle' | 'diamond' | 'pentagon' | 'hexagon' | 'octagon' | 'star' | 'star4' | 'star6' | 'parallelogram' | 'trapezoid' | 'plus' | 'chevron' | 'arrow-right' | 'arrow-left' | 'arrow-up' | 'arrow-down' | 'double-arrow' | 'callout' | 'cylinder' | 'cloud' | 'heart' | 'lightning';
630
- /**
631
- * Author-facing shape annotation names accepted on a drawing's children
632
- * (the `{[…]}` token). Shared with validation so an unknown shape gets a
633
- * "did you mean" suggestion. Aliases (`rectangle`→rect, `ellipse`→circle)
634
- * are included.
635
- */
636
- declare const SHAPE_NAMES: readonly ["rectangle", "rect", "square", "circle", "ellipse", "oval", "line", "arrow", "path", "text", "triangle", "right-triangle", "diamond", "rhombus", "pentagon", "hexagon", "octagon", "star", "star4", "star6", "parallelogram", "trapezoid", "plus", "cross", "chevron", "arrow-right", "arrow-left", "arrow-up", "arrow-down", "double-arrow", "callout", "speech", "cylinder", "cloud", "heart", "lightning", "bolt"];
637
- /**
638
- * Resolve a child's `{[…]}` annotation name to a shape kind, or `null`
639
- * when it isn't a shape. Case-insensitive.
640
- */
641
- declare function normalizeShapeKind(name: string | undefined): DrawingShapeKind | null;
642
- /** True when `name` is an accepted shape annotation (any alias). */
643
- declare function isShapeName(name: string | undefined): boolean;
644
- /** A positioned shape in author-defined units (top-left origin). */
645
- interface DrawingShape {
646
- id: string;
647
- kind: DrawingShapeKind;
648
- x: number;
649
- y: number;
650
- width: number;
651
- height: number;
652
- /** True when position came from `x=`/`y=`; false when auto-laid out. */
653
- pinned: boolean;
654
- /** Heading text used as the shape's label ('' when none). */
655
- label: string;
656
- /** Body text under the heading, used as a sublabel (when present). */
657
- sublabel?: string;
658
- /** Text content for `text` shapes (`text=` param, else label, else body). */
659
- text?: string;
660
- /** Raw SVG path `d` for `path` shapes. */
661
- d?: string;
662
- fill?: string;
663
- stroke?: string;
664
- strokeWidth?: number;
665
- borderRadius?: number;
666
- dasharray?: string;
667
- }
668
- /** A connector joining two shapes by id. */
669
- interface DrawingConnector {
670
- id: string;
671
- kind: 'line' | 'arrow';
672
- /** Source shape id (resolved to an existing shape). */
673
- from: string;
674
- /** Target shape id (resolved to an existing shape). */
675
- to: string;
676
- /** Optional midpoint label (heading text, or `connectsTo` type). */
677
- label?: string;
678
- stroke?: string;
679
- strokeWidth?: number;
680
- dasharray?: string;
681
- /** End-of-line markers (default: `arrow` kind → filled arrow at `to`). */
682
- startMarker: MarkerStyle;
683
- endMarker: MarkerStyle;
684
- /** How the line is routed between the two shapes. Default: 'straight'. */
685
- routing: ConnectorRouting;
686
- }
687
- interface DrawingLayout {
688
- shapes: DrawingShape[];
689
- connectors: DrawingConnector[];
690
- warnings: string[];
691
- }
692
- interface DrawingLayoutOptions {
693
- /** Horizontal spacing between auto-laid-out shapes. Default: 180. */
694
- gapX?: number;
695
- /** Vertical spacing between auto-laid-out shapes. Default: 140. */
696
- gapY?: number;
697
- /** Padding below the explicit bounding box before the grid starts. Default: 80. */
698
- gridPad?: number;
699
- /** Grid origin when no explicit shapes anchor it. Default: 80, 80. */
700
- gridOriginX?: number;
701
- gridOriginY?: number;
702
- }
703
- /**
704
- * Compute shapes + connectors for a drawing from its parent block's
705
- * children. Pure — same inputs always produce the same output.
706
- */
707
- declare function computeDrawingLayout(children: readonly Block[], options?: DrawingLayoutOptions): DrawingLayout;
708
-
709
- /**
710
- * Layout block template.
711
- *
712
- * Renders the parent block's children as free-form, **absolutely
713
- * positioned** layers on a canvas (text boxes, shapes, images). Unlike
714
- * `drawingBlock`, coordinates are used as-is — there is no fit-to-viewport
715
- * scaling — because a layout is a fixed-canvas composition.
716
- *
717
- * Each child is one layer: `### {#id} {[<type> x=.. y=.. …]}`. A text box's
718
- * content lives in its child body as markdown (see `computeLayoutLayers`).
719
- * Children render in document order (first child = back-most layer).
720
- */
721
-
722
- declare function layoutBlock(input: TemplateBlock, context: TemplateContext): Layer[];
723
-
724
- interface LayoutLayersResult {
725
- layers: Layer[];
726
- warnings: string[];
727
- }
728
- interface LayoutLayerDefaults {
729
- /**
730
- * Default ink — text color and path/line stroke — used when the author
731
- * omits `color=`/`stroke=`. `layoutBlock` passes the theme text color so
732
- * un-styled text stays legible on dark themes; the editor's scene canvas
733
- * omits it and gets the dark-slate default that suits its fixed light
734
- * surface.
735
- */
736
- ink?: string;
737
- }
738
- /** Minimal Block shape this derivation reads (subset of `Block`). */
739
- interface LayoutChildBlock {
740
- id: string;
741
- template?: string;
742
- templateOverrides?: Record<string, string>;
743
- title?: string;
744
- contents?: MarkdownNode[];
745
- }
746
- /**
747
- * Map a layout block's children → positioned layers. Pure: same children
748
- * always produce the same layers.
749
- */
750
- declare function computeLayoutLayers(children: readonly LayoutChildBlock[], _viewport: {
751
- width: number;
752
- height: number;
753
- }, defaults?: LayoutLayerDefaults): LayoutLayersResult;
754
-
755
- /**
756
- * Accent Image Utility
757
- *
758
- * Creates image layers and layout adjustments for accent images on text-based slides.
759
- * Accent images are tasteful additions that complement text without overwhelming it.
760
- *
761
- * Layout patterns:
762
- * - left-strip: 35% width vertical strip on left, text area shifted to right 65%
763
- * - right-strip: 35% width vertical strip on right, text area shifted to left 65%
764
- * - bottom-strip: 35% height horizontal strip at bottom, text area in upper 65%
765
- * - corner-inset: Small 25% corner image with gradient vignette
766
- *
767
- * This is shared code used by both site and efb-app doc renderers.
768
- */
769
-
770
- /**
771
- * Layout adjustments when an accent image is present.
772
- * Templates use these values to reposition their text content.
773
- */
774
- interface AccentLayout {
775
- /** X offset for text center (e.g., '64%' for left-strip) */
776
- textCenterX: string;
777
- /** Width available for text content */
778
- textWidth: string;
779
- /** Y offset adjustment for vertical positioning */
780
- textYAdjust: number;
781
- /** Whether to adjust Y positions (for bottom-strip) */
782
- adjustY: boolean;
783
- }
784
- /**
785
- * Default layout when no accent image is present.
786
- */
787
- declare const DEFAULT_LAYOUT: AccentLayout;
788
- /**
789
- * Get layout adjustments based on accent position.
790
- */
791
- declare function getAccentLayout(position: AccentPosition): AccentLayout;
792
- /**
793
- * Create layers for an accent image.
794
- * Returns the image layer and any overlay/gradient layers needed.
795
- */
796
- declare function createAccentLayers(accent: AccentImage, slideId: string, treatment?: ImageTreatment): Layer[];
797
- /**
798
- * Adjust a Y position value based on accent layout.
799
- * Used by templates to shift content when bottom-strip is present.
800
- */
801
- declare function adjustY(originalY: string | number, layout: AccentLayout): string;
802
-
803
- /**
804
- * Block Template Registry
805
- *
806
- * Central registry of all block templates. Provides functions to:
807
- * - Look up templates by name
808
- * - Expand template blocks into full Layer arrays
809
- * - Convert a template-based doc script into a renderable format
810
- *
811
- * Supports multiple viewport configurations for different aspect ratios.
812
- *
813
- * This is shared code used by both site and efb-app doc renderers.
814
- */
815
-
816
- /**
817
- * Registry mapping template ids (the strings that appear in
818
- * `{[name]}` markdown annotations) to their implementation functions.
819
- *
820
- * Some implementation functions keep historical "Block" suffixes
821
- * (`titleBlock`, `quoteBlock`, `mapBlock`, `listBlock`) for source
822
- * readability — the registry surfaces them under the cleaner short
823
- * ids (`title`, `quote`, `map`, `list`). {@link TEMPLATE_ALIASES} keeps
824
- * the legacy long ids resolvable for documents written before the
825
- * rename.
826
- *
827
- * Note: coverBlock is not in the registry as it's used directly for
828
- * start blocks, not as a regular template in the block sequence.
829
- */
830
- declare const templateRegistry: TemplateRegistry;
831
- /**
832
- * Back-compat: maps legacy template ids (kept around for documents
833
- * authored before the "Block" suffix was dropped) to the canonical
834
- * short ids. Resolved by {@link resolveTemplateName} so both the
835
- * registry lookup and `hasTemplate()` accept either form.
836
- */
837
- declare const TEMPLATE_ALIASES: Readonly<Record<string, string>>;
838
- /**
839
- * Resolve a template id through {@link TEMPLATE_ALIASES}. Returns the
840
- * input unchanged when no alias is registered.
841
- */
842
- declare function resolveTemplateName(name: string): string;
843
- /**
844
- * Container templates render their parent block by consuming the block's
845
- * child headings (via `context.children`) — `diagram` draws them as nodes,
846
- * `drawing` as shapes, `layout` as absolutely-positioned layers. Those
847
- * children are therefore NOT independently renderable slides/sections;
848
- * render paths use {@link isContainerTemplate} to skip descending into
849
- * them (see `flattenRenderableBlocks`).
850
- */
851
- declare const CONTAINER_TEMPLATES: ReadonlySet<string>;
852
- /** True when `name` (or its alias) is a children-consuming container template. */
853
- declare function isContainerTemplate(name: string | undefined): boolean;
854
- /**
855
- * Merge user-defined custom templates onto the built-in registry.
856
- * Built-in names take precedence on collision — a user can't shadow
857
- * `title` or `diagram` from a custom definition. Returns a frozen view
858
- * so callers don't accidentally mutate the global registry.
859
- */
860
- type RuntimeTemplateRegistry = Record<string, (input: TemplateBlock, ctx: TemplateContext) => Layer[]>;
861
- declare function buildRegistry(custom?: readonly CustomTemplateDefinition[]): RuntimeTemplateRegistry;
862
- /**
863
- * Expand a template block into a full Block with layers.
864
- *
865
- * `registry` lets callers swap in a registry that includes user-defined
866
- * custom templates. Defaults to the built-in registry when omitted.
867
- */
868
- declare function expandTemplateBlock(templateBlock: TemplateBlock, context: TemplateContext, registry?: RuntimeTemplateRegistry): Block;
869
- /**
870
- * Audio segment timing info for aligning blocks with audio.
871
- */
872
- interface AudioSegmentTiming {
873
- /** Start time of this segment in the overall timeline */
874
- startTime: number;
875
- /** Duration of this segment */
876
- duration: number;
877
- }
878
- /**
879
- * Options for expanding doc blocks.
880
- */
881
- interface ExpandDocBlocksOptions {
882
- /** Theme for template rendering (defaults to DEFAULT_THEME) */
883
- theme?: Theme;
884
- /** Viewport configuration (defaults to 16:9 landscape) */
885
- viewport?: ViewportConfig;
886
- /** Persistent layers for visual consistency across blocks */
887
- persistentLayers?: PersistentLayerConfig;
888
- /**
889
- * Audio segment timing information.
890
- * When provided, blocks are timed relative to their audio segment's start time,
891
- * ensuring proper synchronization with audio playback.
892
- */
893
- audioSegments?: AudioSegmentTiming[];
894
- /**
895
- * User-defined custom templates to merge onto the built-in registry
896
- * before expanding blocks. Typically passed straight from
897
- * `Doc.customTemplates`. Built-in names take precedence on collision.
898
- */
899
- customTemplates?: readonly CustomTemplateDefinition[];
900
- }
901
- declare function expandDocBlocks(blocks: DocBlock[], options?: ExpandDocBlocksOptions): Block[];
902
- /**
903
- * Get list of available template names.
904
- */
905
- declare function getAvailableTemplates(): string[];
906
- /**
907
- * Check if a template exists. Accepts both the canonical short id
908
- * (`title`, `quote`, `map`, `list`) and legacy aliases
909
- * (`titleBlock`, `quoteBlock`, `mapBlock`, `listBlock`).
910
- */
911
- declare function hasTemplate(name: string): boolean;
912
-
913
- /**
914
- * Animation Utilities
915
- *
916
- * Helper functions for mapping Doc animations to CSS classes and styles.
917
- * Generates the appropriate animation class names and CSS custom properties
918
- * for duration, delay, and easing.
919
- *
920
- * This is shared code used by both site and efb-app doc renderers.
921
- */
922
-
923
- interface AnimationResult {
924
- /** CSS class name to apply */
925
- className: string;
926
- /** Inline styles for CSS custom properties */
927
- style: Record<string, string>;
928
- }
929
- /**
930
- * Get CSS class and styles for an animation.
931
- */
932
- declare function getAnimationStyle(animation: Animation | undefined, _currentTime?: number): AnimationResult;
933
- /**
934
- * Get default duration for an animation type.
935
- */
936
- declare function getDefaultAnimationDuration(type: AnimationType): number;
937
- /**
938
- * Get transition class for slide entry/exit.
939
- */
940
- declare function getTransitionClass(type: TransitionType, entering: boolean, direction?: TransitionDirection): string;
941
- /**
942
- * Calculate animation progress (0-1) based on current time.
943
- */
944
- declare function getAnimationProgress(animation: Animation, currentTime: number, slideDuration: number): number;
945
-
946
- /**
947
- * Theme Utilities
948
- *
949
- * Template-facing helpers that read from the Theme object on the
950
- * TemplateContext. Templates call these instead of hard-coding style
951
- * decisions, so the same template code adapts to any theme.
952
- */
953
-
954
- /**
955
- * Resolve a named color scheme from the theme, with a safe fallback.
956
- * Templates call this instead of `COLOR_SCHEMES[name]`.
957
- */
958
- declare function resolveColorScheme(context: TemplateContext, name: string | undefined): ThemeColorScheme;
959
- /**
960
- * Get the theme font family for a given role, resolved to a CSS string.
961
- * Templates call this to set `fontFamily` on text layers.
962
- *
963
- * Theme fields are structured `FontFamily` references (`{ stackId }` or
964
- * `{ custom: { name, fallback } }`); this helper resolves them to a
965
- * CSS font-family string with safe fallbacks.
966
- */
967
- declare function getThemeFont(context: TemplateContext, role: 'title' | 'body' | 'mono'): string;
968
- /**
969
- * Calculate a theme-aware scaled font size.
970
- * Applies the theme's typography scale multipliers on top of the
971
- * viewport-based font scale from LayoutStrategy.
972
- *
973
- * @param basePx Base font size designed for 1920×1080
974
- * @param context Template context (includes fontScale, layout, theme)
975
- * @param isTitle Whether this is title text (uses titleScale) or body (bodyScale)
976
- */
977
- declare function themedFontSize(basePx: number, context: TemplateContext, isTitle?: boolean): number;
978
- /**
979
- * Scale an animation duration by the theme's animationSpeed multiplier.
980
- * A speed of 1.0 returns the base duration unchanged.
981
- */
982
- declare function scaleAnimationDuration(baseDuration: number, context: TemplateContext): number;
983
- /**
984
- * Get the theme's default animation type for a layer kind.
985
- * Returns `undefined` when the theme doesn't specify one (template picks its own).
986
- */
987
- declare function getDefaultAnimation(context: TemplateContext, layerType: 'text' | 'image'): AnimationType | undefined;
988
- /**
989
- * Theme-aware entrance animation for a template layer.
990
- *
991
- * The theme's `renderStyle.defaultTextAnimation` / `defaultImageAnimation`
992
- * overrides the entrance *type*; the template keeps its authored duration,
993
- * delay, and stagger. Templates opt in per layer:
994
- *
995
- * ```ts
996
- * animation: themedEntrance(context, 'text', { type: 'fadeIn', duration: 2 })
997
- * ```
998
- *
999
- * `slowZoom` is excluded — it's an ambient treatment handled by the
1000
- * `applyRenderStyleToLayers` post-pass, not an entrance.
1001
- */
1002
- declare function themedEntrance(context: TemplateContext, layerType: 'text' | 'image', fallback: Animation): Animation;
1003
- /**
1004
- * Whether the theme defaults to text shadows.
1005
- * Templates should consult this when choosing `shadow: true/false`.
1006
- */
1007
- declare function shouldUseShadow(context: TemplateContext): boolean;
1008
- /**
1009
- * Get the theme's overlay opacity for image-backed blocks.
1010
- */
1011
- declare function getOverlayOpacity(context: TemplateContext): number;
1012
- /**
1013
- * Resolve the effective photographic treatment for a block's imagery.
1014
- *
1015
- * Precedence: the block's `imageTreatment` override ('none' opts out, a
1016
- * type forces that grade) → the theme's `style.imageTreatment` → none.
1017
- * Duotone tints default to the theme primary. Templates pass the result
1018
- * straight into `ImageLayer.content.treatment`.
1019
- */
1020
- declare function themedImageTreatment(context: TemplateContext, override?: 'none' | 'mono' | 'duotone' | 'warm' | 'cool'): ImageTreatment | undefined;
1021
- /**
1022
- * Theme-derived surface gradient for text-first templates.
1023
- *
1024
- * Runs from the theme's alternate surface into a slightly deepened
1025
- * background, staying inside the theme's own hue. Templates must use
1026
- * this instead of hard-coding a dark endpoint (`#0f1520`, `#1e2030`, …):
1027
- * hard-coded navy endpoints made light themes render dark panels and
1028
- * warm themes drift cold halfway down the block.
1029
- */
1030
- declare function themedSurfaceGradient(context: TemplateContext, angleDeg?: number): string;
1031
- /**
1032
- * Translucent overlay tint derived from the theme background, for text
1033
- * bands/scrims painted over imagery. Light themes get a light scrim with
1034
- * dark theme text on top; dark themes get the familiar dark scrim —
1035
- * `theme.colors.text` stays legible on it by construction.
1036
- */
1037
- declare function themedScrim(context: TemplateContext, alpha?: number): string;
1038
- /**
1039
- * Read a per-template hint from the theme's renderStyle.
1040
- * Returns `fallback` when the hint isn't defined.
1041
- *
1042
- * @example
1043
- * ```ts
1044
- * const entrance = getTemplateHint(context, 'statHighlight', 'entrance', 'subtle');
1045
- * ```
1046
- */
1047
- declare function getTemplateHint<T extends string | number | boolean>(context: TemplateContext, templateName: string, key: string, fallback: T): T;
1048
-
1049
- /**
1050
- * Render-style post-pass — applies a theme's mechanical motion defaults to
1051
- * template-generated layers.
1052
- *
1053
- * This is the intent-free half of theme motion (see `themedEntrance` in
1054
- * [themeUtils.ts](./themeUtils.ts) for the intent-bearing half): it never
1055
- * decides *what kind* of entrance a layer gets, only
1056
- *
1057
- * 1. scales existing animation durations/delays by the theme's
1058
- * `style.animationSpeed` multiplier (1.4 = calmer/slower, 0.7 = snappier,
1059
- * 1.0 = no-op), and
1060
- * 2. gives full-bleed cover imagery with no authored animation a gentle,
1061
- * deterministic Ken Burns when the theme opts into ambient motion.
1062
- *
1063
- * Applied ONLY to template-generated layers — raw authored `block.layers`
1064
- * are never touched, and an explicit `animation` (including
1065
- * `{ type: 'none' }`) always wins.
1066
- */
1067
-
1068
- /**
1069
- * Whether the theme asks for ambient Ken Burns on otherwise-static imagery.
1070
- * `defaultImageAnimation: 'slowZoom'` is treated as an alias for the boolean
1071
- * (that's what themes authoring it were reaching for).
1072
- */
1073
- declare function themeWantsAmbientMotion(theme: Theme): boolean;
1074
- /**
1075
- * Apply the theme's mechanical motion defaults to a block's
1076
- * template-generated layers. Pure: returns new layer objects where a change
1077
- * applies and the original objects where none does.
1078
- *
1079
- * @param layers Template-generated layers (never raw authored layers)
1080
- * @param block The source block — supplies the ambient-motion seed and duration
1081
- * @param theme Resolved theme
1082
- */
1083
- declare function applyRenderStyleToLayers(layers: Layer[], block: {
1084
- id: string;
1085
- duration?: number;
1086
- }, theme: Theme): Layer[];
1087
-
1088
- /**
1089
- * Image treatment → CSS filter derivation.
1090
- *
1091
- * Treatments are theme-level photographic grades (see `ImageTreatment` in
1092
- * [Doc.ts](../../schemas/Doc.ts)). They compile to plain CSS `filter`
1093
- * functions so the same string works on a foreignObject `<img>`, an SVG
1094
- * `<image>` element, and in headless frame capture — no SVG filter defs to
1095
- * coordinate, no renderer-specific code paths.
1096
- */
1097
-
1098
- /**
1099
- * Build the CSS `filter` value for a treatment and/or blur.
1100
- * Returns `undefined` when there is nothing to apply.
1101
- */
1102
- declare function cssFilterForTreatment(treatment?: ImageTreatment, blur?: number): string | undefined;
1103
-
1104
- /**
1105
- * Template input derivation — build a template's required inputs from a
1106
- * block's heading + markdown body.
1107
- *
1108
- * Used by:
1109
- * - `markdownToDoc`'s content-aware auto template picking, so an
1110
- * auto-picked `quote`/`statHighlight`/`leftFeature` block carries the
1111
- * inputs its template needs through every render path (player, linear
1112
- * view, exports).
1113
- * - `LinearDocView` / editor previews, to render annotated blocks whose
1114
- * authors didn't spell out every template param.
1115
- *
1116
- * Two modes:
1117
- * - strict (default): returns `null` when an essential input can't be
1118
- * derived (no image for a feature block, no table for dataTable…) —
1119
- * auto-picking uses this to fall back to the structural default.
1120
- * - placeholders: returns visible placeholder values instead of failing —
1121
- * preview surfaces use this so a half-authored block still renders.
1122
- */
1123
-
1124
- /** First image discovered in a block's body, with explicit dimensions when present. */
1125
- interface FirstImage {
1126
- src: string;
1127
- alt: string;
1128
- width?: number;
1129
- height?: number;
1130
- }
1131
- /** Plain text of a block's body contents (excluding the heading). */
1132
- declare function extractBodyPlainText(contents?: MarkdownBlockNode[]): string;
1133
- /** Extract list items as plain text. */
1134
- declare function extractListItems(contents?: MarkdownBlockNode[]): string[];
1135
- /**
1136
- * Find images referenced anywhere in block contents — both markdown
1137
- * shorthand `![alt](url)` (type `image`) and raw HTML `<img>` tags
1138
- * (type `htmlBlock`/`htmlInline`). The WYSIWYG editor emits the HTML form
1139
- * whenever a user resizes an image, so missing that path silently breaks
1140
- * every resized image.
1141
- *
1142
- * @param limit Stop after this many images (default: all).
1143
- */
1144
- declare function extractImages(contents: MarkdownBlockNode[] | undefined, limit?: number): FirstImage[];
1145
- /** First image in a block's body, or null. */
1146
- declare function extractFirstImage(contents: MarkdownBlockNode[] | undefined): FirstImage | null;
1147
- /** Extract table data (headers, rows, alignment) from block contents. */
1148
- declare function extractTableFromContents(contents?: MarkdownBlockNode[]): {
1149
- headers: string[];
1150
- rows: string[][];
1151
- align?: (('left' | 'right' | 'center') | null)[];
1152
- } | null;
1153
- /** First blockquote's plain text, or ''. */
1154
- declare function extractBlockquoteText(contents?: MarkdownBlockNode[]): string;
1155
- interface DeriveTemplateInputsOptions {
1156
- /**
1157
- * Return visible placeholder values instead of `null` when an essential
1158
- * input can't be derived (preview surfaces). Default false (strict).
1159
- */
1160
- placeholders?: boolean;
1161
- }
1162
- /**
1163
- * Derive a template's inputs from a block's heading text and body nodes.
1164
- * Returns the input fields to merge onto the block, or `null` in strict
1165
- * mode when an essential input is missing.
1166
- */
1167
- declare function deriveTemplateInputs(templateName: string, headingText: string, contents: MarkdownBlockNode[] | undefined, options?: DeriveTemplateInputsOptions): Record<string, unknown> | null;
1168
-
1169
- /**
1170
- * Markdown → Doc Conversion
1171
- *
1172
- * Converts a MarkdownDocument into a hierarchical Doc whose Block tree
1173
- * mirrors the heading structure of the markdown. Every heading (H1–H6)
1174
- * becomes a Block; body content between headings populates `contents`;
1175
- * sub-headings nest as `children`.
1176
- *
1177
- * This enables using BlockTemplates to supply alternate visualizations
1178
- * for each section of a markdown document.
1179
- *
1180
- * @example
1181
- * ```ts
1182
- * import { parseMarkdown } from '@bendyline/squisq/markdown';
1183
- * import { markdownToDoc } from '@bendyline/squisq/doc';
1184
- *
1185
- * const md = parseMarkdown('# Intro\n\nHello world\n\n## Details\n\nMore text');
1186
- * const doc = markdownToDoc(md);
1187
- * // doc.blocks[0].sourceHeading.depth === 1 ("# Intro")
1188
- * // doc.blocks[0].contents → [paragraph("Hello world")]
1189
- * // doc.blocks[0].children[0].sourceHeading.depth === 2 ("## Details")
1190
- * ```
1191
- */
1192
-
1193
- /**
1194
- * Options for markdownToDoc().
1195
- */
1196
- interface MarkdownToDocOptions {
1197
- /** Article ID for the generated Doc. Default: 'markdown-doc' */
1198
- articleId?: string;
1199
- /** Default template name for heading blocks. Default: 'sectionHeader' */
1200
- defaultTemplate?: string;
1201
- /** Default duration per block in seconds. Default: 5 */
1202
- defaultDuration?: number;
1203
- /** Custom ID generator. Receives the heading node and its index. */
1204
- generateId?: (heading: MarkdownHeading, index: number) => string;
1205
- /**
1206
- * Whether to auto-generate a cover startBlock from the first H1 heading.
1207
- * When true (default), a StartBlockConfig is created using the first H1's
1208
- * text as the title. If the document contains an image, the first image
1209
- * is used as the hero. Set to false to suppress automatic cover generation.
1210
- */
1211
- generateCoverBlock?: boolean;
1212
- /**
1213
- * Timestamp recorded as `captions.generatedAt`. When omitted, the field
1214
- * is left unset so that conversion is fully deterministic — the same
1215
- * markdown always converts to an identical Doc (important for snapshot
1216
- * tests, caching, and agents that verify their output by re-converting).
1217
- */
1218
- captionsGeneratedAt?: string;
1219
- /**
1220
- * Content-aware template auto-picking for unannotated headings
1221
- * (default: true). When a heading block carries a strong content signal
1222
- * — a table, images, a blockquote, a list, a stat-looking line — the
1223
- * matching template is applied (with inputs derived from the body)
1224
- * instead of the structural `defaultTemplate`. Explicit `{[template]}`
1225
- * annotations always win. Authors can also disable per document with
1226
- * frontmatter `squisq-auto-templates: false`.
1227
- */
1228
- autoTemplates?: boolean;
1229
- }
1230
- declare function markdownToDoc(markdownDoc: MarkdownDocument, options?: MarkdownToDocOptions): Doc;
1231
- /**
1232
- * Flatten a nested block tree into a depth-first ordered array.
1233
- * Useful for calculating sequential timing or iterating all blocks.
1234
- */
1235
- declare function flattenBlocks(blocks: Block[]): Block[];
1236
- /**
1237
- * Flatten the block tree into the list of *independently renderable*
1238
- * blocks — like {@link flattenBlocks}, but it does NOT descend into the
1239
- * children of a container template (`diagram`, `drawing`; see
1240
- * `isContainerTemplate`). Those children are consumed by the parent's
1241
- * render (as nodes / shapes), so they must not also surface as their own
1242
- * slides or sections.
1243
- *
1244
- * Use this anywhere a doc is flattened for rendering (slideshow, video,
1245
- * static pages). Use {@link flattenBlocks} when you genuinely need every
1246
- * block regardless of role — validation, timing, duplicate-id checks.
1247
- */
1248
- declare function flattenRenderableBlocks(blocks: Block[]): Block[];
1249
- /**
1250
- * Count the total number of blocks in a nested tree (including children at all levels).
1251
- */
1252
- declare function countBlocks(blocks: Block[]): number;
1253
- /**
1254
- * Get the heading depth for a block. Returns 0 for preamble blocks (no heading).
1255
- */
1256
- declare function getBlockDepth(block: Block): number;
1257
-
1258
- /**
1259
- * Doc → Markdown Conversion
1260
- *
1261
- * Converts a Doc with a heading-driven Block hierarchy back into a
1262
- * MarkdownDocument. This is the reverse of markdownToDoc() and enables
1263
- * round-tripping: edit a Doc's block tree, then serialize back to markdown.
1264
- *
1265
- * **Algorithm:**
1266
- * Walk the block tree depth-first. For each block:
1267
- * 1. If it has a `sourceHeading`, emit that heading node
1268
- * 2. Emit all nodes in `contents`
1269
- * 3. Recurse into `children`
1270
- *
1271
- * @example
1272
- * ```ts
1273
- * import { markdownToDoc, docToMarkdown } from '@bendyline/squisq/doc';
1274
- * import { parseMarkdown, stringifyMarkdown } from '@bendyline/squisq/markdown';
1275
- *
1276
- * const md = '# Hello\n\nWorld\n';
1277
- * const doc = markdownToDoc(parseMarkdown(md));
1278
- * const roundTripped = stringifyMarkdown(docToMarkdown(doc));
1279
- * ```
1280
- */
1281
-
1282
- /**
1283
- * Convert a Doc with heading-driven blocks back to a MarkdownDocument.
1284
- *
1285
- * Walks the block tree depth-first, emitting heading nodes and contents
1286
- * in document order. Blocks without a `sourceHeading` (preamble blocks)
1287
- * emit only their contents.
1288
- *
1289
- * If a block has a `template` or `templateOverrides` that aren't already
1290
- * reflected in the heading's `templateAnnotation`, the annotation is
1291
- * injected so the round-trip preserves template assignments.
1292
- *
1293
- * @param doc - A Doc whose blocks may have `sourceHeading`, `contents`, and `children`
1294
- * @returns A MarkdownDocument that can be stringified back to markdown
1295
- */
1296
- declare function docToMarkdown(doc: Doc): MarkdownDocument;
1297
-
1298
- /**
1299
- * Frontmatter serialization for user-defined custom templates (layouts).
1300
- *
1301
- * Custom template definitions live in the document's YAML frontmatter
1302
- * under the key `squisq-custom-templates`. They're stored as a single
1303
- * **compact JSON** object keyed by template name:
1304
- *
1305
- * ```yaml
1306
- * squisq-custom-templates: {"hero":{"lb":"Hero Section","ly":[{"ty":"text",…}]}}
1307
- * ```
1308
- *
1309
- * Squisq's frontmatter parser is line-based; a JSON object literal
1310
- * round-trips through it verbatim (no leading quote to strip, single
1311
- * line), so the value is written **unquoted** and stays human-readable
1312
- * and diffable — important for a codebase edited by people and agents.
1313
- *
1314
- * The JSON is kept small by:
1315
- * - keying definitions by `name` (drops the `name` field + array wrapper),
1316
- * - omitting the viewport when it's the 1920×1080 default,
1317
- * - renaming well-known property names to two-letter codes via
1318
- * {@link LONG_TO_SHORT} (e.g. `fontSize` → `fz`).
1319
- *
1320
- * The rename is a generic, recursive, bijective pass: **any property not
1321
- * in the map passes through unchanged**, so the format is lossless even
1322
- * as the Layer schema grows — new fields are simply stored under their
1323
- * full name until (optionally) added to the map.
1324
- *
1325
- * Back-compat: the reader still accepts the historical base64-of-JSON
1326
- * payload and a structured array, so older documents load unchanged.
1327
- * The first save migrates them to the compact form.
1328
- *
1329
- * The `encodeLayersForFrontmatter` / `decodeLayersFromFrontmatter` pair
1330
- * handles a single Layer array for the editor's `dataLayers="…"` Pandoc
1331
- * param path; that path stays base64 (it's a different, per-block
1332
- * mechanism) and is re-exported here for locality.
1333
- */
1334
-
1335
- /**
1336
- * Base64-encode a Layer array as JSON, UTF-8 safe. Used by the editor's
1337
- * per-block `dataLayers="…"` Pandoc param (not the doc-level template
1338
- * list, which uses the compact JSON above).
1339
- *
1340
- * `btoa` only accepts Latin1 strings — any character outside that range
1341
- * (e.g. an em-dash in a description) throws — so we round through
1342
- * `TextEncoder`. Works in Node ≥18 and browsers.
1343
- */
1344
- declare function encodeLayersForFrontmatter(layers: readonly Layer[]): string;
1345
- /** Inverse of {@link encodeLayersForFrontmatter}. Returns [] on parse failure. */
1346
- declare function decodeLayersFromFrontmatter(encoded: string): Layer[];
1347
- /**
1348
- * Read the `squisq-custom-templates` frontmatter key and decode it into
1349
- * an array of CustomTemplateDefinitions. Returns undefined when the key
1350
- * is absent or unparseable so callers can omit the field from the Doc.
1351
- *
1352
- * Accepts, in order: the compact JSON object (current), a base64-JSON
1353
- * string (legacy), and an already-structured array/object (in case a
1354
- * richer YAML parser delivers it). Malformed payloads return undefined
1355
- * rather than failing the whole doc load.
1356
- */
1357
- declare function readCustomTemplatesFromFrontmatter(frontmatter: Record<string, unknown> | undefined): CustomTemplateDefinition[] | undefined;
1358
- /**
1359
- * Encode a list of custom template definitions into the compact JSON
1360
- * object described in the module header. Returns undefined when the
1361
- * input list is empty so callers can leave the key off the output.
1362
- */
1363
- declare function writeCustomTemplatesToFrontmatter(templates: readonly CustomTemplateDefinition[] | undefined, options?: {
1364
- pretty?: boolean;
1365
- }): string | undefined;
1366
-
1367
- /**
1368
- * Frontmatter serialization for user-defined custom themes.
1369
- *
1370
- * The theme analog of {@link ./customTemplatesFrontmatter.ts}. Custom Theme
1371
- * definitions live in the document's YAML frontmatter under the key
1372
- * `squisq-custom-themes`, stored as a single **compact JSON** object keyed
1373
- * by theme id:
1374
- *
1375
- * ```yaml
1376
- * squisq-custom-themes: {"my-brand":{"schemaVersion":"1","id":"my-brand",…}}
1377
- * ```
1378
- *
1379
- * Squisq's frontmatter parser is line-based; a JSON object literal
1380
- * round-trips through it verbatim (single line, no leading quote to strip),
1381
- * so the value is written **unquoted** and stays human-readable and diffable
1382
- * — the same mechanism the custom-templates codec relies on.
1383
- *
1384
- * Only one theme is *active* per doc (selected by id via the `squisq-theme`
1385
- * frontmatter key / `Doc.themeId`), but the payload is a keyed map — parallel
1386
- * to custom templates — so a doc can carry a small catalog and switch between
1387
- * them, and `resolveThemeForDoc` can resolve any of them doc-scoped.
1388
- *
1389
- * Malformed entries are dropped (via `validateTheme`) rather than failing the
1390
- * whole doc load, matching the tolerant behavior of the templates reader.
1391
- */
1392
-
1393
- /**
1394
- * Read the custom themes inlined into a document's frontmatter. Returns
1395
- * undefined when the key is absent or holds no valid theme, so callers can
1396
- * omit the field from the Doc.
1397
- */
1398
- declare function readCustomThemesFromFrontmatter(frontmatter: Record<string, unknown> | undefined): Theme[] | undefined;
1399
- /**
1400
- * Encode a list of custom themes into the compact JSON object described in
1401
- * the module header (keyed by theme id). Returns undefined when the input is
1402
- * empty so callers can leave the key off the output.
1403
- */
1404
- declare function writeCustomThemesToFrontmatter(themes: readonly Theme[] | undefined, options?: {
1405
- pretty?: boolean;
1406
- }): string | undefined;
1407
-
1408
- /**
1409
- * Doc-scoped theme resolution.
1410
- *
1411
- * The theme analog of how `buildRegistry` resolves custom templates: pure and
1412
- * doc-scoped, with no global state. `resolveThemeForDoc` looks up the active
1413
- * theme id in the doc's own custom themes first, then falls back to the
1414
- * built-in / globally-registered themes via `resolveTheme`.
1415
- *
1416
- * It accepts either a squisq `Doc` (which carries a typed `customThemes`
1417
- * array) or anything with raw `frontmatter` — notably a `MarkdownDocument`,
1418
- * which is the shape every export pipeline pivots through. In the latter case
1419
- * the inline themes are decoded from the `squisq-custom-themes` frontmatter
1420
- * payload. Either way, resolution needs no `registerTheme` call — an inline
1421
- * custom theme ships with the doc, exactly like custom templates.
1422
- */
1423
-
1424
- /**
1425
- * The minimal shape `resolveThemeForDoc` needs. Satisfied by both the squisq
1426
- * `Doc` (typed `customThemes` + `themeId`) and a `MarkdownDocument` (raw
1427
- * `frontmatter` carrying the encoded payload).
1428
- */
1429
- interface ThemeResolvable {
1430
- themeId?: string;
1431
- customThemes?: Theme[];
1432
- frontmatter?: Record<string, unknown>;
1433
- }
1434
- /**
1435
- * Resolve the Theme a document should render with.
1436
- *
1437
- * @param doc - the document (may carry inline custom themes plus a `themeId`
1438
- * / `squisq-theme` frontmatter selector).
1439
- * @param explicitId - an id that overrides the doc's own selection (e.g. the
1440
- * editor's theme dropdown, or an export `--theme` option). When omitted, the
1441
- * doc's `themeId` / frontmatter theme id is used.
1442
- * @returns the matching inline custom theme (doc-scoped) when present, else
1443
- * the built-in / registered theme for that id, else the default theme.
1444
- */
1445
- declare function resolveThemeForDoc(doc: ThemeResolvable | null | undefined, explicitId?: string): Theme;
1446
-
1447
- /**
1448
- * getLayers — Compute visual layers for a block on demand.
1449
- *
1450
- * This is the preferred way to obtain renderable layers for a block.
1451
- * Instead of storing pre-computed layers on the Block object, call
1452
- * `getLayers(block, context)` to derive them from the block's template
1453
- * name, content, and the current render context (theme, viewport, etc.).
1454
- *
1455
- * For raw blocks that already carry a `layers` array, those layers are
1456
- * returned directly (with optional persistent layer injection).
1457
- *
1458
- * @example
1459
- * ```ts
1460
- * import { getLayers } from '@bendyline/squisq/doc';
1461
- *
1462
- * const layers = getLayers(block, {
1463
- * theme: DEFAULT_THEME,
1464
- * viewport: VIEWPORT_PRESETS.landscape,
1465
- * blockIndex: 0,
1466
- * totalBlocks: 10,
1467
- * });
1468
- * ```
1469
- */
1470
-
1471
- /**
1472
- * Context needed to compute layers for a block.
1473
- *
1474
- * Captures the visual rendering parameters: theme colors, viewport
1475
- * configuration, persistent layers, and the block's position within
1476
- * the doc (for template functions that vary output by index).
1477
- */
1478
- interface RenderContext {
1479
- /** Theme for template rendering. Defaults to DEFAULT_THEME (documentary). */
1480
- theme?: Theme;
1481
- /** Target viewport configuration. Defaults to 16:9 landscape. */
1482
- viewport?: ViewportConfig;
1483
- /** Persistent layers injected behind and/or on top of all block content. */
1484
- persistentLayers?: PersistentLayerConfig;
1485
- /** 0-based index of this block in the sequence. Defaults to 0. */
1486
- blockIndex?: number;
1487
- /** Total number of blocks in the doc. Defaults to 1. */
1488
- totalBlocks?: number;
1489
- }
1490
- /**
1491
- * Compute the visual layers for a block.
1492
- *
1493
- * Resolution order:
1494
- * 1. If the block already has a non-empty `layers` array, use it (raw block).
1495
- * 2. If the block has a `template` name that exists in the registry,
1496
- * call the template function to generate layers.
1497
- * 3. Otherwise return an empty array.
1498
- *
1499
- * Persistent layers (bottom/top) from the render context are injected
1500
- * around the result unless the block opts out via `useBottomLayer: false`
1501
- * or `useTopLayer: false`.
1502
- *
1503
- * @param block A Block or TemplateBlock to render.
1504
- * @param context Render context (theme, viewport, persistent layers, position).
1505
- * @returns The computed Layer[] for the block, ready for BlockRenderer.
1506
- */
1507
- declare function getLayers(block: DocBlock, context?: RenderContext): Layer[];
1508
-
1509
- /**
1510
- * Audio Mapping
1511
- *
1512
- * Associates audio segments (MP3 files) with document blocks.
1513
- * Supports two modes:
1514
- *
1515
- * 1. **Explicit annotation**: Blocks with `{[audio=filename.mp3]}` in their
1516
- * heading annotation are directly mapped to that audio file.
1517
- *
1518
- * 2. **Auto-matching**: When no annotations exist but the container has MP3s
1519
- * with `.timing.json` files, matches MP3s to blocks by comparing the
1520
- * timing.json `sourceText` against block text content (word overlap).
1521
- * Falls back to filename-based matching (slugified title comparison).
1522
- */
1523
-
1524
- /**
1525
- * Calculate Jaccard similarity between two texts (word overlap).
1526
- * Returns 0–1 where 1 = identical word sets.
1527
- */
1528
- declare function scoreTextSimilarity(a: string, b: string): number;
1529
- /**
1530
- * Resolve audio mapping for a Doc using a ContentContainer.
1531
- *
1532
- * Tries explicit `{[audio=filename.mp3]}` annotations first,
1533
- * then falls back to auto-matching by content similarity.
1534
- *
1535
- * Returns a new Doc with `audio.segments` populated and blocks
1536
- * assigned to the correct `audioSegment` indices.
1537
- *
1538
- * @param doc - The source Doc (not mutated).
1539
- * @param container - ContentContainer with MP3 and timing files.
1540
- * @returns New Doc with audio segments resolved, or original doc if no matches.
1541
- */
1542
- declare function resolveAudioMapping(doc: Doc, container: ContentContainer): Promise<Doc>;
1543
-
1544
- /**
1545
- * Structured template data from markdown body content.
1546
- *
1547
- * Attribute strings on a heading annotation are fine for scalar params,
1548
- * but tabular or nested inputs (dataTable rows, map markers, chart data)
1549
- * don't pack well into a single quoted line. This module supplies the two
1550
- * structured channels instead:
1551
- *
1552
- * 1. **Data fences** — a fenced code block whose info string is
1553
- * `json data` or `yaml data`, placed in a heading's body content:
1554
- *
1555
- * ````markdown
1556
- * ## Quarterly numbers {[dataTable]}
1557
- *
1558
- * ```json data
1559
- * { "headers": ["Q", "Revenue"], "rows": [["Q1", "1.2M"], ["Q2", "1.4M"]] }
1560
- * ```
1561
- * ````
1562
- *
1563
- * The parsed object lands on `block.templateData` and merges into the
1564
- * template input (after defaults, before `{[…]}` string overrides).
1565
- * The `data` marker keeps ordinary ```json code samples — which should
1566
- * render as code — out of the template input.
1567
- *
1568
- * 2. **GFM tables** — for the `dataTable` template, the first table in the
1569
- * section body supplies `headers` / `rows` / `align` when the author
1570
- * didn't provide them explicitly.
1571
- *
1572
- * YAML support is a documented subset (this package has no YAML
1573
- * dependency): top-level `key: scalar`, `key: [inline, array]`, `key:`
1574
- * followed by an indented `- item` block sequence (scalars or inline
1575
- * arrays), and `key:` followed by *one level* of indented `subkey: scalar`
1576
- * lines (a nested map, e.g. `center:` + indented `lat:` / `lng:`). Deeper
1577
- * nesting, and mixing list items with mapping keys under one key, are
1578
- * rejected with a clear error — use a `json data` fence for those.
1579
- */
1580
-
1581
- /**
1582
- * Whether a code block is a structured-data fence: lang `json`/`yaml`/`yml`
1583
- * with the word `data` in the fence meta (` ```json data `).
1584
- */
1585
- declare function isDataFence(node: MarkdownCodeBlock): boolean;
1586
- interface DataFenceParseResult {
1587
- /** Parsed key→value map. Undefined when parsing failed. */
1588
- data?: Record<string, unknown>;
1589
- /** Parse failure description. Undefined when parsing succeeded. */
1590
- error?: string;
1591
- }
1592
- /**
1593
- * Parse a data fence's content into a key→value map. JSON fences must
1594
- * contain a top-level object (arrays have no key to merge under); YAML
1595
- * fences are parsed with {@link parseYamlSubset}.
1596
- */
1597
- declare function parseDataFence(node: MarkdownCodeBlock): DataFenceParseResult;
1598
- /**
1599
- * Return a new contents array with the first data fence's code content
1600
- * replaced by `data` (pretty-printed JSON). The fence node keeps its
1601
- * language and `data` marker; only `value` changes. When no data fence
1602
- * exists, a new ` ```json data ` fence is appended instead.
1603
- *
1604
- * Pure: neither `contents` nor its nodes are mutated. This is the write
1605
- * half of the data-fence channel — editors update `block.templateData`
1606
- * and call this to reflect the change back into `block.contents`.
1607
- */
1608
- declare function replaceDataFence(contents: MarkdownBlockNode[], data: Record<string, unknown>): MarkdownBlockNode[];
1609
- /**
1610
- * Parse the supported YAML subset (see module doc) into a key→value map.
1611
- * Throws an Error with a line-anchored message on anything outside the
1612
- * subset, so callers can surface a precise diagnostic.
1613
- */
1614
- declare function parseYamlSubset(src: string): Record<string, unknown>;
1615
- interface ExtractedTableData {
1616
- headers: string[];
1617
- rows: string[][];
1618
- align?: (('left' | 'right' | 'center') | null)[];
1619
- }
1620
- /** Find the first GFM table among a block's body contents. */
1621
- declare function findFirstTable(contents: MarkdownBlockNode[] | undefined): MarkdownTable | undefined;
1622
- /**
1623
- * Extract `headers` / `rows` / `align` (the `dataTable` input shape) from a
1624
- * GFM table node. The first row is the header row.
1625
- */
1626
- declare function extractTableData(table: MarkdownTable): ExtractedTableData;
1627
-
1628
- /**
1629
- * Markdown document validation.
1630
- *
1631
- * `validateMarkdownSource()` gives authors and agents fast, structural
1632
- * feedback on a squisq markdown document — the same checks the renderer
1633
- * applies, surfaced as diagnostics instead of degraded slides:
1634
- *
1635
- * - unknown template names (with a did-you-mean suggestion)
1636
- * - unknown drawing shapes, and shape annotations used outside a `{[drawing]}`
1637
- * - `{[…]}` text that was not recognized as an annotation (bad quoting,
1638
- * non-heading placement, unknown inline icon)
1639
- * - malformed heading-attribute values (`x=abc`, bad `startTime`) and
1640
- * non-numeric drawing-shape geometry
1641
- * - `connectsTo` / drawing `from`/`to` targets that don't resolve,
1642
- * duplicate block ids, unparseable data fences (reported by `markdownToDoc`)
1643
- * - image references missing from the provided asset set (.dbk contents)
1644
- *
1645
- * The CLI exposes this as `squisq validate <input>`; agents can also call
1646
- * it directly and iterate until the diagnostics list is empty.
1647
- */
1648
-
1649
- interface ValidateOptions {
1650
- /**
1651
- * Known asset paths for image/video reference checks — typically the
1652
- * file list of a .dbk container or the document's folder. Relative
1653
- * references not present here produce a `missing-asset` warning.
1654
- * When omitted, asset checks are skipped.
1655
- */
1656
- assets?: ReadonlySet<string> | ((path: string) => boolean);
1657
- /**
1658
- * Additional template names to accept beyond the built-in registry and
1659
- * the document's own `customTemplates` (e.g. app-registered templates).
1660
- */
1661
- extraTemplates?: readonly string[];
1662
- }
1663
- interface MarkdownValidationResult {
1664
- /** All findings, in source order where line information exists. */
1665
- diagnostics: DocDiagnostic[];
1666
- errorCount: number;
1667
- warningCount: number;
1668
- infoCount: number;
1669
- /** The converted Doc (conversion diagnostics are included above). */
1670
- doc: Doc;
1671
- }
1672
- /**
1673
- * Validate a squisq markdown source string. Parses, converts (collecting
1674
- * the conversion's own diagnostics), and runs the structural checks above.
1675
- */
1676
- declare function validateMarkdownSource(source: string, options?: ValidateOptions): MarkdownValidationResult;
1677
- /**
1678
- * Validate an already-parsed MarkdownDocument. See {@link validateMarkdownSource}.
1679
- */
1680
- declare function validateMarkdownDoc(markdownDoc: MarkdownDocument, options?: ValidateOptions): MarkdownValidationResult;
1681
-
1682
- /**
1683
- * Fallback Block Rendering
1684
- *
1685
- * The graceful-degradation guarantee: a block whose template can't render —
1686
- * unknown template name, template function threw, or returned a non-array —
1687
- * still renders its heading and body text as a plain, readable card instead
1688
- * of a blank slide. A small notice line names the problem so authors (and
1689
- * agents reviewing screenshots) can see *why* the block degraded.
1690
- *
1691
- * This is intentionally not a registered template: it can't be requested by
1692
- * name, only reached when a requested template fails. See `getLayers()`.
1693
- */
1694
-
1695
- /**
1696
- * Render a block's heading + body text as plain layers, with a notice line
1697
- * describing why the requested template didn't render.
1698
- *
1699
- * @param block The block that failed to render via its template.
1700
- * @param context Template context (theme, viewport).
1701
- * @param notice Short problem description, e.g. `Unknown template "photGrid"`.
1702
- */
1703
- declare function fallbackBlockLayers(block: DocBlock, context: TemplateContext, notice: string): Layer[];
1704
-
1705
- /**
1706
- * Template input descriptors — a typed catalog of the inline `{[…]}` params
1707
- * each built-in template understands, plus the pure coercion + lint logic
1708
- * that consumes it.
1709
- *
1710
- * Two jobs, one source of truth:
1711
- *
1712
- * - **Coercion (`coerceTemplateParams`)** turns a flat `key → raw string`
1713
- * param map (from a `{[name key=value]}` annotation, always strings) into a
1714
- * partial typed input the template functions can consume directly — e.g.
1715
- * `center="47.6,-122.3"` → `{ lat: 47.6, lng: -122.3 }`, `zoom=9` → `9`.
1716
- * This is what makes `{[map center="47.6,-122.3" zoom=9]}` render with no
1717
- * changes to any template function. Unknown keys ALWAYS pass through
1718
- * untouched (as strings), so coercion is never lossy; coercion failures are
1719
- * returned as `warnings` and the raw string is preserved.
1720
- *
1721
- * - **Linting (`lintTemplateParams`)** checks a param map against the
1722
- * descriptors and reports unknown keys (with a did-you-mean suggestion),
1723
- * values outside a closed enum / that fail coercion, and missing required
1724
- * inputs. The document validator surfaces these as diagnostics.
1725
- *
1726
- * This mirrors the proven block-meta descriptor pattern in
1727
- * `markdown/annotationCoercion.ts` (`BLOCK_META_KEY_DESCRIPTORS`), extended
1728
- * from block geometry/timing to per-template content inputs.
1729
- *
1730
- * The descriptors are the `{[…]}` counterpart of the template input
1731
- * interfaces in `schemas/BlockTemplates.ts` — only keys/enums that provably
1732
- * exist on those interfaces are declared. Keys that can't be meaningfully
1733
- * expressed as a single inline string (e.g. a `dataTable`'s `rows`) are still
1734
- * declared with `coerce: 'string'` so they aren't mis-flagged as unknown.
1735
- */
1736
- /** How a raw `{[…]}` param string is coerced into a typed input value. */
1737
- type InputCoercion = 'string' | 'number' | 'boolean' | 'latLng' | 'labeledPair' | 'stringList';
1738
- /**
1739
- * Editor/validator-facing description of a single template input key: what it
1740
- * does, how to coerce its raw string, and either its closed set of valid
1741
- * values or a free-form format hint. `values`/`valueHint` are mutually
1742
- * exclusive (a key has a closed enum OR a hint, not both).
1743
- */
1744
- interface TemplateInputDescriptor {
1745
- /** The `{[name key=…]}` param key, matching the template input interface. */
1746
- key: string;
1747
- /** One-line description of the input. */
1748
- description: string;
1749
- /** Coercion strategy for the raw string (default `'string'`). */
1750
- coerce?: InputCoercion;
1751
- /** Closed set of valid values, for keys backed by an enum. */
1752
- values?: readonly string[];
1753
- /** Format hint shown when the value is free-form (no closed set). */
1754
- valueHint?: string;
1755
- /** When true, the validator warns if the key is absent and can't be derived. */
1756
- required?: boolean;
1757
- }
1758
- /** A single lint finding produced by {@link lintTemplateParams}. */
1759
- interface TemplateParamFinding {
1760
- kind: 'unknown-input' | 'invalid-input-value' | 'missing-input';
1761
- key: string;
1762
- message: string;
1763
- /** Did-you-mean candidate (for `unknown-input`). */
1764
- suggestion?: string;
1765
- }
1766
- /**
1767
- * Inputs shared by every template via `BaseTemplateBlock`. Merged into each
1768
- * template's known-key set for coercion + lint. Block-level timing/geometry
1769
- * keys (`duration`, `x`, `y`, …) are NOT here — those stay owned by the
1770
- * block-meta registry (`KNOWN_BLOCK_META_KEYS`) and are folded into the lint
1771
- * known-key set separately.
1772
- */
1773
- declare const BASE_INPUT_DESCRIPTORS: readonly TemplateInputDescriptor[];
1774
- /**
1775
- * Per-template input descriptors, keyed by canonical template id. A template
1776
- * absent from this map has no descriptors and is exempt from lint (custom
1777
- * templates and not-yet-described built-ins).
1778
- */
1779
- declare const TEMPLATE_INPUT_DESCRIPTORS: Readonly<Record<string, readonly TemplateInputDescriptor[]>>;
1780
- /**
1781
- * Coerce a flat `{[…]}` param map into a partial typed template input.
1782
- *
1783
- * Known descriptor keys are coerced per their `coerce` strategy; unknown keys
1784
- * (and `string`-typed keys) pass through unchanged. A coercion failure leaves
1785
- * the raw string in place and adds a human-readable `warnings` entry — the
1786
- * output is never lossy. Returns a fresh object; the caller must NOT feed
1787
- * `templateOverrides` back in — only the ephemeral merged input is coerced.
1788
- */
1789
- declare function coerceTemplateParams(template: string | undefined, params: Record<string, string>): {
1790
- input: Record<string, unknown>;
1791
- warnings: string[];
1792
- };
1793
- /**
1794
- * Lint a template's `{[…]}` params against its descriptors. Returns findings
1795
- * for unknown keys, values outside a closed enum / that fail coercion, and
1796
- * missing required inputs. Templates without descriptors (custom or
1797
- * not-yet-described built-ins) return `[]`.
1798
- */
1799
- declare function lintTemplateParams(template: string, params: Record<string, string>): TemplateParamFinding[];
1800
-
1801
- export { type AccentLayout, type AudioSegmentTiming, BASE_INPUT_DESCRIPTORS, CONTAINER_TEMPLATES, type ClipBox, type ConnectorPort, type ConnectorRouting, type ConnectorSnapPoint, type CoverBlockInput, DEFAULT_LAYOUT, type DataFenceParseResult, type DeriveTemplateInputsOptions, type DiagramEdge, type DiagramLayout, type DiagramLayoutOptions, type DiagramNodePosition, DocBlock, type DocStylePreset, type DrawingConnector, type DrawingLayout, type DrawingLayoutOptions, type DrawingShape, type DrawingShapeKind, type ExpandDocBlocksOptions, type ExtractedTableData, type FirstImage, type InputCoercion, type LayoutLayerDefaults, type LayoutLayersResult, type MarkdownToDocOptions, type MarkdownValidationResult, PATH_SHAPE_KINDS, PersistentLayerConfig, type RenderContext, type RuntimeTemplateRegistry, SHAPE_NAMES, TEMPLATE_ALIASES, TEMPLATE_INPUT_DESCRIPTORS, TEMPLATE_METADATA, TemplateBlock, TemplateContext, type TemplateInputDescriptor, type TemplateMetadata, type TemplateParamFinding, Theme, ThemeColorScheme, type ValidateOptions, ViewportConfig, adjustY, applyRenderStyleToLayers, buildRegistry, clipEndpoints, clipPoint, coerceTemplateParams, comparisonBar, computeDiagramLayout, computeDrawingLayout, computeLayoutLayers, connectorPath, countBlocks, coverBlock, createAccentLayers, cssFilterForTreatment, dataTable, dateEvent, decodeLayersFromFrontmatter, definitionCard, deriveTemplateInputs, diagramBlock, docToMarkdown, drawingBlock, encodeLayersForFrontmatter, expandCoverBlock, expandDocBlocks, expandPersistentLayers, expandTemplateBlock, extractBlockquoteText, extractBodyPlainText, extractFirstImage, extractImages, extractListItems, extractTableData, extractTableFromContents, factCard, fallbackBlockLayers, findFirstTable, flattenBlocks, flattenRenderableBlocks, fullBleedQuote, getAccentLayout, getAnimationProgress, getAnimationStyle, getAvailableTemplates, getBlockDepth, getDefaultAnimation, getDefaultAnimationDuration, getDocStyleConfig, getLayers, getOverlayOpacity, getPersistentLayersFromTheme, getTemplateHint, getThemeFont, getTransitionClass, hasTemplate, imageWithCaption, isContainerTemplate, isDataFence, isShapeName, layoutBlock, leftFeature, lineStyleDasharray, lintTemplateParams, listBlock, mapBlock, markdownToDoc, markerPath, nearestSnapPoint, normalizeShapeKind, parseDataFence, parseYamlSubset, photoGrid, pullQuote, quoteBlock, readCustomTemplatesFromFrontmatter, readCustomThemesFromFrontmatter, replaceDataFence, resolveAudioMapping, resolveColorScheme, resolvePersistentLayers, resolveTemplateName, resolveThemeForDoc, rightFeature, scaleAnimationDuration, scoreTextSimilarity, sectionHeader, shapePath, shouldUseShadow, snapEndpoints, snapPoints, statHighlight, templateRegistry, themeWantsAmbientMotion, themedEntrance, themedFontSize, themedImageTreatment, themedScrim, themedSurfaceGradient, titleBlock, twoColumn, validateMarkdownDoc, validateMarkdownSource, videoPullQuote, videoWithCaption, wrapWithPersistentLayers, writeCustomTemplatesToFrontmatter, writeCustomThemesToFrontmatter };