@bendyline/squisq 1.5.1 → 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.
- package/README.md +63 -10
- package/dist/{Doc-BBVGq1_9.d.ts → Doc-ylqWKDc_.d.ts} +248 -37
- package/dist/{ImageEditDoc-FuyGtt6o.d.ts → ImageEditDoc-D828IXJ1.d.ts} +1 -1
- package/dist/annotationCoercion-Dr_DY9Hx.d.ts +86 -0
- package/dist/{chunk-VWUFZ6ZG.js → chunk-3E5F2XMR.js} +2 -29
- package/dist/chunk-3E5F2XMR.js.map +1 -0
- package/dist/chunk-4X3JQXNM.js +35 -0
- package/dist/chunk-4X3JQXNM.js.map +1 -0
- package/dist/{chunk-2OIBZYKP.js → chunk-5DKBFXPY.js} +31 -121
- package/dist/chunk-5DKBFXPY.js.map +1 -0
- package/dist/{chunk-DLXZMS5K.js → chunk-5J4HKRJF.js} +51 -3
- package/dist/chunk-5J4HKRJF.js.map +1 -0
- package/dist/chunk-5UYI3RJB.js +2503 -0
- package/dist/chunk-5UYI3RJB.js.map +1 -0
- package/dist/{chunk-TEEEILMP.js → chunk-66QO7XFB.js} +19 -292
- package/dist/chunk-66QO7XFB.js.map +1 -0
- package/dist/{chunk-KKNUBQ6Y.js → chunk-6PJRB2CF.js} +156 -91
- package/dist/chunk-6PJRB2CF.js.map +1 -0
- package/dist/{chunk-HWVFJAAH.js → chunk-AMIR72JP.js} +28 -10
- package/dist/chunk-AMIR72JP.js.map +1 -0
- package/dist/chunk-FVJUUTEM.js +74 -0
- package/dist/chunk-FVJUUTEM.js.map +1 -0
- package/dist/{chunk-LH7I6SH7.js → chunk-GF3BVNLU.js} +6360 -5723
- package/dist/chunk-GF3BVNLU.js.map +1 -0
- package/dist/{chunk-Q3ROPT5H.js → chunk-GZY66SDN.js} +1 -1
- package/dist/{chunk-Q3ROPT5H.js.map → chunk-GZY66SDN.js.map} +1 -1
- package/dist/chunk-JOQYPRDZ.js +127 -0
- package/dist/chunk-JOQYPRDZ.js.map +1 -0
- package/dist/{chunk-A4O7GIWE.js → chunk-LYNJEOAC.js} +10 -73
- package/dist/chunk-LYNJEOAC.js.map +1 -0
- package/dist/{chunk-LDQ2HJIX.js → chunk-PXLVXTLW.js} +252 -54
- package/dist/chunk-PXLVXTLW.js.map +1 -0
- package/dist/{chunk-TQWLI6S2.js → chunk-Q7LROV2H.js} +4 -2
- package/dist/{chunk-TQWLI6S2.js.map → chunk-Q7LROV2H.js.map} +1 -1
- package/dist/{chunk-T5UK6YOB.js → chunk-QTSJOY54.js} +60 -17
- package/dist/chunk-QTSJOY54.js.map +1 -0
- package/dist/chunk-QVANWDPH.js +2358 -0
- package/dist/chunk-QVANWDPH.js.map +1 -0
- package/dist/{chunk-6ATE2PSM.js → chunk-R2GC6RLD.js} +7 -7
- package/dist/chunk-R2GC6RLD.js.map +1 -0
- package/dist/chunk-R2YZTCLO.js +292 -0
- package/dist/chunk-R2YZTCLO.js.map +1 -0
- package/dist/chunk-S7A5D7ZJ.js +174 -0
- package/dist/chunk-S7A5D7ZJ.js.map +1 -0
- package/dist/chunk-T3TI7GSZ.js +884 -0
- package/dist/chunk-T3TI7GSZ.js.map +1 -0
- package/dist/{chunk-RUDYOTA6.js → chunk-TUWMK62B.js} +110 -4
- package/dist/chunk-TUWMK62B.js.map +1 -0
- package/dist/{chunk-IMSCRLLV.js → chunk-VR7UPJ7C.js} +35 -25
- package/dist/chunk-VR7UPJ7C.js.map +1 -0
- package/dist/doc/index.d.ts +2334 -5
- package/dist/doc/index.js +134 -34
- package/dist/generate/index.d.ts +7 -2
- package/dist/generate/index.js +1 -1
- package/dist/imageEdit/index.d.ts +9 -6
- package/dist/imageEdit/index.js +3 -3
- package/dist/index.d.ts +12 -10
- package/dist/index.js +253 -81
- package/dist/jsonForm/index.d.ts +7 -3
- package/dist/jsonForm/index.js +9 -4
- package/dist/markdown/index.d.ts +6 -70
- package/dist/markdown/index.js +13 -9
- package/dist/narration/index.d.ts +618 -0
- package/dist/narration/index.js +82 -0
- package/dist/recommend/index.d.ts +15 -1
- package/dist/recommend/index.js +2 -2
- package/dist/schemas/index.d.ts +28 -6
- package/dist/schemas/index.js +15 -13
- package/dist/spatial/index.d.ts +0 -1
- package/dist/spatial/index.js +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/{themeLibrary-CehcJhzz.d.ts → themeLibrary-RjVgLpUi.d.ts} +10 -11
- package/dist/timing/index.js +5 -3
- package/dist/transform/index.d.ts +35 -24
- package/dist/transform/index.js +9 -10
- package/dist/{types-DlAZ7MW4.d.ts → types-BwMPl2CB.d.ts} +1 -1
- package/dist/{types-D98li1gV.d.ts → types-C4kiRn_k.d.ts} +3 -1
- package/dist/versions/index.d.ts +2 -1
- package/dist/versions/index.js +2 -2
- package/package.json +6 -6
- package/src/__tests__/applyNarrationTiming.test.ts +190 -0
- package/src/__tests__/applyRenderStyle.test.ts +3 -3
- package/src/__tests__/asciiDiagramBattle.test.ts +246 -0
- package/src/__tests__/asciiDiagramDetect.test.ts +162 -0
- package/src/__tests__/asciiDiagramMapping.test.ts +38 -0
- package/src/__tests__/asciiDiagramParse.test.ts +233 -0
- package/src/__tests__/asciiDiagramPipeline.test.ts +273 -0
- package/src/__tests__/asciiDiagramRender.test.ts +162 -0
- package/src/__tests__/asciiDiagramRepair.test.ts +84 -0
- package/src/__tests__/asciiTimelineDetect.test.ts +157 -0
- package/src/__tests__/asciiTimelineParse.test.ts +205 -0
- package/src/__tests__/asciiTimelinePipeline.test.ts +349 -0
- package/src/__tests__/asciiTimelineRender.test.ts +376 -0
- package/src/__tests__/attrTokens.test.ts +5 -0
- package/src/__tests__/contentContainer.test.ts +43 -0
- package/src/__tests__/coverBlock.test.ts +33 -2
- package/src/__tests__/customTemplatesFrontmatter.test.ts +0 -15
- package/src/__tests__/dataTable.test.ts +25 -15
- package/src/__tests__/diagramBlock.test.ts +3 -3
- package/src/__tests__/diagramText.test.ts +26 -0
- package/src/__tests__/docToMarkdownMedia.test.ts +83 -0
- package/src/__tests__/drawingBlock.test.ts +3 -3
- package/src/__tests__/fixtures/asciiDiagramBattle.ts +512 -0
- package/src/__tests__/fixtures/asciiDiagrams.ts +287 -0
- package/src/__tests__/fixtures/asciiTimelines.ts +35 -0
- package/src/__tests__/fixtures/treeviewFixtures.ts +243 -0
- package/src/__tests__/getLayers.test.ts +32 -18
- package/src/__tests__/getLayersFallback.test.ts +8 -8
- package/src/__tests__/imageEditVersions.test.ts +2 -0
- package/src/__tests__/jsonForm.pointer.test.ts +47 -1
- package/src/__tests__/layoutBlock.test.ts +3 -3
- package/src/__tests__/majorApiTypes.test.ts +18 -0
- package/src/__tests__/markdown.test.ts +41 -0
- package/src/__tests__/markdownToDoc.test.ts +5 -2
- package/src/__tests__/matchFontFamily.test.ts +114 -0
- package/src/__tests__/materializeBlockLayers.test.ts +135 -0
- package/src/__tests__/materializeTestUtils.ts +17 -0
- package/src/__tests__/narrationAlign.test.ts +150 -0
- package/src/__tests__/narrationFeatures.test.ts +71 -0
- package/src/__tests__/narrationNuclei.test.ts +45 -0
- package/src/__tests__/narrationPacing.test.ts +189 -0
- package/src/__tests__/narrationScript.test.ts +149 -0
- package/src/__tests__/narrationSessionRepro.test.ts +62 -0
- package/src/__tests__/narrationSidecar.test.ts +88 -0
- package/src/__tests__/narrationSyllables.test.ts +65 -0
- package/src/__tests__/narrationTestSignals.ts +167 -0
- package/src/__tests__/narrationVad.test.ts +66 -0
- package/src/__tests__/resolveDocTheme.test.ts +16 -2
- package/src/__tests__/rootExports.test.ts +18 -0
- package/src/__tests__/scopedContentContainer.test.ts +20 -0
- package/src/__tests__/shapeGeometry.test.ts +49 -0
- package/src/__tests__/templateAnnotationParse.test.ts +10 -0
- package/src/__tests__/templateInputs.test.ts +69 -0
- package/src/__tests__/templateMetadata.test.ts +2 -1
- package/src/__tests__/templates.test.ts +143 -17
- package/src/__tests__/themeCompile.test.ts +49 -22
- package/src/__tests__/transformProvenance.test.ts +160 -0
- package/src/__tests__/transformV2.test.ts +40 -14
- package/src/__tests__/treeviewBattle.test.ts +76 -0
- package/src/__tests__/treeviewDetect.test.ts +168 -0
- package/src/__tests__/treeviewParse.test.ts +118 -0
- package/src/__tests__/treeviewPipeline.test.ts +183 -0
- package/src/__tests__/treeviewRender.test.ts +91 -0
- package/src/__tests__/versions.test.ts +44 -0
- package/src/doc/applyNarrationTiming.ts +244 -0
- package/src/doc/asciiDiagram/chars.ts +210 -0
- package/src/doc/asciiDiagram/detect.ts +175 -0
- package/src/doc/asciiDiagram/index.ts +38 -0
- package/src/doc/asciiDiagram/mapping.ts +225 -0
- package/src/doc/asciiDiagram/parse.ts +1095 -0
- package/src/doc/asciiDiagram/render.ts +963 -0
- package/src/doc/asciiDiagram/repair.ts +400 -0
- package/src/doc/asciiDiagram/types.ts +65 -0
- package/src/doc/asciiTimeline/detect.ts +138 -0
- package/src/doc/asciiTimeline/index.ts +26 -0
- package/src/doc/asciiTimeline/mapping.ts +43 -0
- package/src/doc/asciiTimeline/parse.ts +870 -0
- package/src/doc/asciiTimeline/render.ts +427 -0
- package/src/doc/asciiTimeline/types.ts +73 -0
- package/src/doc/asciiTimeline/wrappedFlow.ts +427 -0
- package/src/doc/audioMapping.ts +60 -46
- package/src/doc/customTemplatesFrontmatter.ts +0 -41
- package/src/doc/docToMarkdown.ts +126 -39
- package/src/doc/index.ts +76 -4
- package/src/doc/markdownToDoc.ts +135 -1
- package/src/doc/materializeBlockLayers.ts +304 -0
- package/src/doc/mediaAnnotations.ts +20 -0
- package/src/doc/resolveDocTheme.ts +8 -7
- package/src/doc/templateInputs.ts +185 -2
- package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +22 -8
- package/src/doc/templates/coverBlock.ts +49 -13
- package/src/doc/templates/diagramBlock.ts +237 -38
- package/src/doc/templates/drawingBlock.ts +2 -2
- package/src/doc/templates/fallbackBlock.ts +1 -1
- package/src/doc/templates/index.ts +134 -279
- package/src/doc/templates/inputDescriptors.ts +20 -1
- package/src/doc/templates/metadata.ts +10 -0
- package/src/doc/templates/persistentLayers.ts +12 -126
- package/src/doc/templates/registry.ts +88 -0
- package/src/doc/templates/templateNames.ts +22 -0
- package/src/doc/templates/timelineBlock.ts +613 -0
- package/src/doc/templates/treeBlock.ts +131 -0
- package/src/doc/treeview/chars.ts +72 -0
- package/src/doc/treeview/detect.ts +145 -0
- package/src/doc/treeview/index.ts +30 -0
- package/src/doc/treeview/mapping.ts +95 -0
- package/src/doc/treeview/parse.ts +201 -0
- package/src/doc/treeview/render.ts +41 -0
- package/src/doc/treeview/types.ts +43 -0
- package/src/doc/utils/applyRenderStyle.ts +2 -9
- package/src/doc/utils/diagramText.ts +78 -0
- package/src/doc/utils/shapeGeometry.ts +157 -7
- package/src/doc/validate.ts +1 -1
- package/src/generate/templateMapper.ts +7 -0
- package/src/imageEdit/export.ts +6 -5
- package/src/imageEdit/versionPaths.ts +13 -26
- package/src/imageEdit/versions.ts +21 -100
- package/src/index.ts +1 -0
- package/src/internal/immutable.ts +58 -0
- package/src/jsonForm/index.ts +9 -1
- package/src/jsonForm/pointer.ts +68 -23
- package/src/markdown/attrTokens.ts +7 -5
- package/src/markdown/convert.ts +11 -1
- package/src/markdown/index.ts +1 -0
- package/src/markdown/stringify.ts +4 -9
- package/src/markdown/utils.ts +36 -14
- package/src/narration/align.ts +514 -0
- package/src/narration/features.ts +231 -0
- package/src/narration/index.ts +86 -0
- package/src/narration/nuclei.ts +118 -0
- package/src/narration/pacing.ts +211 -0
- package/src/narration/script.ts +239 -0
- package/src/narration/session.ts +100 -0
- package/src/narration/sidecar.ts +187 -0
- package/src/narration/syllables.ts +85 -0
- package/src/narration/trace.ts +50 -0
- package/src/narration/types.ts +299 -0
- package/src/narration/vad.ts +131 -0
- package/src/recommend/numberHighlight.ts +25 -0
- package/src/recommend/templates.ts +108 -12
- package/src/schemas/BlockTemplates.ts +156 -7
- package/src/schemas/Doc.ts +72 -9
- package/src/schemas/Media.ts +12 -2
- package/src/schemas/Theme.ts +45 -25
- package/src/schemas/Viewport.ts +2 -2
- package/src/schemas/fontStacks.ts +79 -0
- package/src/schemas/themeCompile.ts +15 -0
- package/src/schemas/themeConstants.ts +2 -0
- package/src/schemas/themeLibrary.ts +25 -19
- package/src/schemas/themeValidator.ts +1 -1
- package/src/spatial/Geohash.ts +0 -3
- package/src/storage/ContentContainer.ts +17 -9
- package/src/storage/ScopedContentContainer.ts +45 -15
- package/src/transform/applyTransform.ts +5 -5
- package/src/transform/index.ts +3 -1
- package/src/transform/registry.ts +169 -49
- package/src/transform/templateSelector.ts +21 -2
- package/src/transform/timingAllocator.ts +152 -21
- package/src/transform/types.ts +14 -1
- package/src/versions/gitignore.ts +34 -0
- package/src/versions/index.ts +2 -0
- package/src/versions/operations.ts +18 -104
- package/src/versions/paths.ts +13 -28
- package/src/versions/snapshotStore.ts +202 -0
- package/src/versions/types.ts +3 -1
- package/dist/chunk-2OIBZYKP.js.map +0 -1
- package/dist/chunk-6ATE2PSM.js.map +0 -1
- package/dist/chunk-A4O7GIWE.js.map +0 -1
- package/dist/chunk-DLXZMS5K.js.map +0 -1
- package/dist/chunk-HWVFJAAH.js.map +0 -1
- package/dist/chunk-IMSCRLLV.js.map +0 -1
- package/dist/chunk-JELIRVDP.js +0 -24
- package/dist/chunk-JELIRVDP.js.map +0 -1
- package/dist/chunk-KKNUBQ6Y.js.map +0 -1
- package/dist/chunk-LDQ2HJIX.js.map +0 -1
- package/dist/chunk-LH7I6SH7.js.map +0 -1
- package/dist/chunk-RUDYOTA6.js.map +0 -1
- package/dist/chunk-T5UK6YOB.js.map +0 -1
- package/dist/chunk-TEEEILMP.js.map +0 -1
- package/dist/chunk-UY7KGQ5R.js +0 -192
- package/dist/chunk-UY7KGQ5R.js.map +0 -1
- package/dist/chunk-VLJJHDAC.js +0 -218
- package/dist/chunk-VLJJHDAC.js.map +0 -1
- package/dist/chunk-VWUFZ6ZG.js.map +0 -1
- package/dist/story/index.d.ts +0 -1777
- package/dist/story/index.js +0 -273
- package/src/doc/getLayers.ts +0 -195
- /package/dist/{story → narration}/index.js.map +0 -0
package/dist/story/index.d.ts
DELETED
|
@@ -1,1777 +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)` + `clipEndpoints(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.
|
|
522
|
-
*/
|
|
523
|
-
|
|
524
|
-
/** Connector routing styles. */
|
|
525
|
-
type ConnectorRouting = 'straight' | 'orthogonal' | 'curved';
|
|
526
|
-
/**
|
|
527
|
-
* Shape kinds rendered as computed paths (everything except the primitives the
|
|
528
|
-
* renderer draws natively). Used by templates to decide ShapeLayer vs PathLayer.
|
|
529
|
-
*/
|
|
530
|
-
declare const PATH_SHAPE_KINDS: Set<string>;
|
|
531
|
-
/**
|
|
532
|
-
* SVG path `d` for a named shape inscribed in `[x, y, w, h]`, or null when the
|
|
533
|
-
* kind is rendered natively (rect / circle / line / text / path / arrow).
|
|
534
|
-
*/
|
|
535
|
-
declare function shapePath(kind: string, x: number, y: number, w: number, h: number): string | null;
|
|
536
|
-
/**
|
|
537
|
-
* The `<marker>` path for a line end-style, in the 0–10 marker viewBox.
|
|
538
|
-
* `dir` selects orientation (`end` points along +x; `start` is mirrored).
|
|
539
|
-
* Returns null for `'none'`. `filled` shapes paint with the stroke color;
|
|
540
|
-
* non-filled (`open`) draw as a stroked outline.
|
|
541
|
-
*/
|
|
542
|
-
declare function markerPath(style: MarkerStyle, dir: 'start' | 'end'): {
|
|
543
|
-
d: string;
|
|
544
|
-
filled: boolean;
|
|
545
|
-
} | null;
|
|
546
|
-
interface ClipBox {
|
|
547
|
-
cx: number;
|
|
548
|
-
cy: number;
|
|
549
|
-
rx: number;
|
|
550
|
-
ry: number;
|
|
551
|
-
}
|
|
552
|
-
/** Intersection of the center-to-center line with `from`'s bounding box. */
|
|
553
|
-
declare function clipPoint(from: ClipBox, to: ClipBox): {
|
|
554
|
-
x: number;
|
|
555
|
-
y: number;
|
|
556
|
-
};
|
|
557
|
-
/** Clip both endpoints of an edge to the two shapes it joins. */
|
|
558
|
-
declare function clipEndpoints(a: ClipBox, b: ClipBox): {
|
|
559
|
-
start: {
|
|
560
|
-
x: number;
|
|
561
|
-
y: number;
|
|
562
|
-
};
|
|
563
|
-
end: {
|
|
564
|
-
x: number;
|
|
565
|
-
y: number;
|
|
566
|
-
};
|
|
567
|
-
};
|
|
568
|
-
/** Build the SVG `d` for a connector between two clipped endpoints. */
|
|
569
|
-
declare function connectorPath(routing: ConnectorRouting, start: {
|
|
570
|
-
x: number;
|
|
571
|
-
y: number;
|
|
572
|
-
}, end: {
|
|
573
|
-
x: number;
|
|
574
|
-
y: number;
|
|
575
|
-
}): string;
|
|
576
|
-
/** Map a `lineStyle` (solid|dashed|dotted) to an SVG `stroke-dasharray`. */
|
|
577
|
-
declare function lineStyleDasharray(style: string | undefined): string | undefined;
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Drawing layout — shared, pure derivation of shapes + connectors from a
|
|
581
|
-
* drawing block's child headings. Same children always produce the same
|
|
582
|
-
* shapes, so SSR previews, exports, and (eventually) the editor stay
|
|
583
|
-
* visually consistent. Mirrors `diagramLayout.ts` for the richer
|
|
584
|
-
* free-form shape vocabulary.
|
|
585
|
-
*
|
|
586
|
-
* Each child heading is one shape. Its `{[shape …]}` annotation names the
|
|
587
|
-
* primitive (`child.template`) and carries geometry/style as string params
|
|
588
|
-
* (`child.templateOverrides`); `child.id` makes it referenceable;
|
|
589
|
-
* `child.title` is the label.
|
|
590
|
-
*
|
|
591
|
-
* Layout rules (parallel to the diagram):
|
|
592
|
-
* 1. Shapes with both `x` and `y` keep their authored coordinates.
|
|
593
|
-
* 2. Shapes missing either are auto-placed in a square-ish grid below the
|
|
594
|
-
* bounding box of the explicitly-positioned shapes.
|
|
595
|
-
* 3. `line`/`arrow` shapes with `from`/`to` (or any shape's `connectsTo`)
|
|
596
|
-
* become connectors; endpoints that match no sibling id are dropped
|
|
597
|
-
* (and counted in `warnings`).
|
|
598
|
-
*/
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* The shape kinds a drawing can render. `rect`/`circle`/`line` render as a
|
|
602
|
-
* native `ShapeLayer`; everything else (and `path`/`arrow`) renders as a
|
|
603
|
-
* computed `PathLayer` (see `shapeGeometry.ts`). `text` is a `TextLayer`.
|
|
604
|
-
*/
|
|
605
|
-
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';
|
|
606
|
-
/**
|
|
607
|
-
* Author-facing shape annotation names accepted on a drawing's children
|
|
608
|
-
* (the `{[…]}` token). Shared with validation so an unknown shape gets a
|
|
609
|
-
* "did you mean" suggestion. Aliases (`rectangle`→rect, `ellipse`→circle)
|
|
610
|
-
* are included.
|
|
611
|
-
*/
|
|
612
|
-
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"];
|
|
613
|
-
/**
|
|
614
|
-
* Resolve a child's `{[…]}` annotation name to a shape kind, or `null`
|
|
615
|
-
* when it isn't a shape. Case-insensitive.
|
|
616
|
-
*/
|
|
617
|
-
declare function normalizeShapeKind(name: string | undefined): DrawingShapeKind | null;
|
|
618
|
-
/** True when `name` is an accepted shape annotation (any alias). */
|
|
619
|
-
declare function isShapeName(name: string | undefined): boolean;
|
|
620
|
-
/** A positioned shape in author-defined units (top-left origin). */
|
|
621
|
-
interface DrawingShape {
|
|
622
|
-
id: string;
|
|
623
|
-
kind: DrawingShapeKind;
|
|
624
|
-
x: number;
|
|
625
|
-
y: number;
|
|
626
|
-
width: number;
|
|
627
|
-
height: number;
|
|
628
|
-
/** True when position came from `x=`/`y=`; false when auto-laid out. */
|
|
629
|
-
pinned: boolean;
|
|
630
|
-
/** Heading text used as the shape's label ('' when none). */
|
|
631
|
-
label: string;
|
|
632
|
-
/** Body text under the heading, used as a sublabel (when present). */
|
|
633
|
-
sublabel?: string;
|
|
634
|
-
/** Text content for `text` shapes (`text=` param, else label, else body). */
|
|
635
|
-
text?: string;
|
|
636
|
-
/** Raw SVG path `d` for `path` shapes. */
|
|
637
|
-
d?: string;
|
|
638
|
-
fill?: string;
|
|
639
|
-
stroke?: string;
|
|
640
|
-
strokeWidth?: number;
|
|
641
|
-
borderRadius?: number;
|
|
642
|
-
dasharray?: string;
|
|
643
|
-
}
|
|
644
|
-
/** A connector joining two shapes by id. */
|
|
645
|
-
interface DrawingConnector {
|
|
646
|
-
id: string;
|
|
647
|
-
kind: 'line' | 'arrow';
|
|
648
|
-
/** Source shape id (resolved to an existing shape). */
|
|
649
|
-
from: string;
|
|
650
|
-
/** Target shape id (resolved to an existing shape). */
|
|
651
|
-
to: string;
|
|
652
|
-
/** Optional midpoint label (heading text, or `connectsTo` type). */
|
|
653
|
-
label?: string;
|
|
654
|
-
stroke?: string;
|
|
655
|
-
strokeWidth?: number;
|
|
656
|
-
dasharray?: string;
|
|
657
|
-
/** End-of-line markers (default: `arrow` kind → filled arrow at `to`). */
|
|
658
|
-
startMarker: MarkerStyle;
|
|
659
|
-
endMarker: MarkerStyle;
|
|
660
|
-
/** How the line is routed between the two shapes. Default: 'straight'. */
|
|
661
|
-
routing: ConnectorRouting;
|
|
662
|
-
}
|
|
663
|
-
interface DrawingLayout {
|
|
664
|
-
shapes: DrawingShape[];
|
|
665
|
-
connectors: DrawingConnector[];
|
|
666
|
-
warnings: string[];
|
|
667
|
-
}
|
|
668
|
-
interface DrawingLayoutOptions {
|
|
669
|
-
/** Horizontal spacing between auto-laid-out shapes. Default: 180. */
|
|
670
|
-
gapX?: number;
|
|
671
|
-
/** Vertical spacing between auto-laid-out shapes. Default: 140. */
|
|
672
|
-
gapY?: number;
|
|
673
|
-
/** Padding below the explicit bounding box before the grid starts. Default: 80. */
|
|
674
|
-
gridPad?: number;
|
|
675
|
-
/** Grid origin when no explicit shapes anchor it. Default: 80, 80. */
|
|
676
|
-
gridOriginX?: number;
|
|
677
|
-
gridOriginY?: number;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Compute shapes + connectors for a drawing from its parent block's
|
|
681
|
-
* children. Pure — same inputs always produce the same output.
|
|
682
|
-
*/
|
|
683
|
-
declare function computeDrawingLayout(children: readonly Block[], options?: DrawingLayoutOptions): DrawingLayout;
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Layout block template.
|
|
687
|
-
*
|
|
688
|
-
* Renders the parent block's children as free-form, **absolutely
|
|
689
|
-
* positioned** layers on a canvas (text boxes, shapes, images). Unlike
|
|
690
|
-
* `drawingBlock`, coordinates are used as-is — there is no fit-to-viewport
|
|
691
|
-
* scaling — because a layout is a fixed-canvas composition.
|
|
692
|
-
*
|
|
693
|
-
* Each child is one layer: `### {#id} {[<type> x=.. y=.. …]}`. A text box's
|
|
694
|
-
* content lives in its child body as markdown (see `computeLayoutLayers`).
|
|
695
|
-
* Children render in document order (first child = back-most layer).
|
|
696
|
-
*/
|
|
697
|
-
|
|
698
|
-
declare function layoutBlock(input: TemplateBlock, context: TemplateContext): Layer[];
|
|
699
|
-
|
|
700
|
-
interface LayoutLayersResult {
|
|
701
|
-
layers: Layer[];
|
|
702
|
-
warnings: string[];
|
|
703
|
-
}
|
|
704
|
-
interface LayoutLayerDefaults {
|
|
705
|
-
/**
|
|
706
|
-
* Default ink — text color and path/line stroke — used when the author
|
|
707
|
-
* omits `color=`/`stroke=`. `layoutBlock` passes the theme text color so
|
|
708
|
-
* un-styled text stays legible on dark themes; the editor's scene canvas
|
|
709
|
-
* omits it and gets the dark-slate default that suits its fixed light
|
|
710
|
-
* surface.
|
|
711
|
-
*/
|
|
712
|
-
ink?: string;
|
|
713
|
-
}
|
|
714
|
-
/** Minimal Block shape this derivation reads (subset of `Block`). */
|
|
715
|
-
interface LayoutChildBlock {
|
|
716
|
-
id: string;
|
|
717
|
-
template?: string;
|
|
718
|
-
templateOverrides?: Record<string, string>;
|
|
719
|
-
title?: string;
|
|
720
|
-
contents?: MarkdownNode[];
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Map a layout block's children → positioned layers. Pure: same children
|
|
724
|
-
* always produce the same layers.
|
|
725
|
-
*/
|
|
726
|
-
declare function computeLayoutLayers(children: readonly LayoutChildBlock[], _viewport: {
|
|
727
|
-
width: number;
|
|
728
|
-
height: number;
|
|
729
|
-
}, defaults?: LayoutLayerDefaults): LayoutLayersResult;
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Accent Image Utility
|
|
733
|
-
*
|
|
734
|
-
* Creates image layers and layout adjustments for accent images on text-based slides.
|
|
735
|
-
* Accent images are tasteful additions that complement text without overwhelming it.
|
|
736
|
-
*
|
|
737
|
-
* Layout patterns:
|
|
738
|
-
* - left-strip: 35% width vertical strip on left, text area shifted to right 65%
|
|
739
|
-
* - right-strip: 35% width vertical strip on right, text area shifted to left 65%
|
|
740
|
-
* - bottom-strip: 35% height horizontal strip at bottom, text area in upper 65%
|
|
741
|
-
* - corner-inset: Small 25% corner image with gradient vignette
|
|
742
|
-
*
|
|
743
|
-
* This is shared code used by both site and efb-app doc renderers.
|
|
744
|
-
*/
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Layout adjustments when an accent image is present.
|
|
748
|
-
* Templates use these values to reposition their text content.
|
|
749
|
-
*/
|
|
750
|
-
interface AccentLayout {
|
|
751
|
-
/** X offset for text center (e.g., '64%' for left-strip) */
|
|
752
|
-
textCenterX: string;
|
|
753
|
-
/** Width available for text content */
|
|
754
|
-
textWidth: string;
|
|
755
|
-
/** Y offset adjustment for vertical positioning */
|
|
756
|
-
textYAdjust: number;
|
|
757
|
-
/** Whether to adjust Y positions (for bottom-strip) */
|
|
758
|
-
adjustY: boolean;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Default layout when no accent image is present.
|
|
762
|
-
*/
|
|
763
|
-
declare const DEFAULT_LAYOUT: AccentLayout;
|
|
764
|
-
/**
|
|
765
|
-
* Get layout adjustments based on accent position.
|
|
766
|
-
*/
|
|
767
|
-
declare function getAccentLayout(position: AccentPosition): AccentLayout;
|
|
768
|
-
/**
|
|
769
|
-
* Create layers for an accent image.
|
|
770
|
-
* Returns the image layer and any overlay/gradient layers needed.
|
|
771
|
-
*/
|
|
772
|
-
declare function createAccentLayers(accent: AccentImage, slideId: string, treatment?: ImageTreatment): Layer[];
|
|
773
|
-
/**
|
|
774
|
-
* Adjust a Y position value based on accent layout.
|
|
775
|
-
* Used by templates to shift content when bottom-strip is present.
|
|
776
|
-
*/
|
|
777
|
-
declare function adjustY(originalY: string | number, layout: AccentLayout): string;
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Block Template Registry
|
|
781
|
-
*
|
|
782
|
-
* Central registry of all block templates. Provides functions to:
|
|
783
|
-
* - Look up templates by name
|
|
784
|
-
* - Expand template blocks into full Layer arrays
|
|
785
|
-
* - Convert a template-based doc script into a renderable format
|
|
786
|
-
*
|
|
787
|
-
* Supports multiple viewport configurations for different aspect ratios.
|
|
788
|
-
*
|
|
789
|
-
* This is shared code used by both site and efb-app doc renderers.
|
|
790
|
-
*/
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* Registry mapping template ids (the strings that appear in
|
|
794
|
-
* `{[name]}` markdown annotations) to their implementation functions.
|
|
795
|
-
*
|
|
796
|
-
* Some implementation functions keep historical "Block" suffixes
|
|
797
|
-
* (`titleBlock`, `quoteBlock`, `mapBlock`, `listBlock`) for source
|
|
798
|
-
* readability — the registry surfaces them under the cleaner short
|
|
799
|
-
* ids (`title`, `quote`, `map`, `list`). {@link TEMPLATE_ALIASES} keeps
|
|
800
|
-
* the legacy long ids resolvable for documents written before the
|
|
801
|
-
* rename.
|
|
802
|
-
*
|
|
803
|
-
* Note: coverBlock is not in the registry as it's used directly for
|
|
804
|
-
* start blocks, not as a regular template in the block sequence.
|
|
805
|
-
*/
|
|
806
|
-
declare const templateRegistry: TemplateRegistry;
|
|
807
|
-
/**
|
|
808
|
-
* Back-compat: maps legacy template ids (kept around for documents
|
|
809
|
-
* authored before the "Block" suffix was dropped) to the canonical
|
|
810
|
-
* short ids. Resolved by {@link resolveTemplateName} so both the
|
|
811
|
-
* registry lookup and `hasTemplate()` accept either form.
|
|
812
|
-
*/
|
|
813
|
-
declare const TEMPLATE_ALIASES: Readonly<Record<string, string>>;
|
|
814
|
-
/**
|
|
815
|
-
* Resolve a template id through {@link TEMPLATE_ALIASES}. Returns the
|
|
816
|
-
* input unchanged when no alias is registered.
|
|
817
|
-
*/
|
|
818
|
-
declare function resolveTemplateName(name: string): string;
|
|
819
|
-
/**
|
|
820
|
-
* Container templates render their parent block by consuming the block's
|
|
821
|
-
* child headings (via `context.children`) — `diagram` draws them as nodes,
|
|
822
|
-
* `drawing` as shapes, `layout` as absolutely-positioned layers. Those
|
|
823
|
-
* children are therefore NOT independently renderable slides/sections;
|
|
824
|
-
* render paths use {@link isContainerTemplate} to skip descending into
|
|
825
|
-
* them (see `flattenRenderableBlocks`).
|
|
826
|
-
*/
|
|
827
|
-
declare const CONTAINER_TEMPLATES: ReadonlySet<string>;
|
|
828
|
-
/** True when `name` (or its alias) is a children-consuming container template. */
|
|
829
|
-
declare function isContainerTemplate(name: string | undefined): boolean;
|
|
830
|
-
/**
|
|
831
|
-
* Merge user-defined custom templates onto the built-in registry.
|
|
832
|
-
* Built-in names take precedence on collision — a user can't shadow
|
|
833
|
-
* `title` or `diagram` from a custom definition. Returns a frozen view
|
|
834
|
-
* so callers don't accidentally mutate the global registry.
|
|
835
|
-
*/
|
|
836
|
-
type RuntimeTemplateRegistry = Record<string, (input: TemplateBlock, ctx: TemplateContext) => Layer[]>;
|
|
837
|
-
declare function buildRegistry(custom?: readonly CustomTemplateDefinition[]): RuntimeTemplateRegistry;
|
|
838
|
-
/**
|
|
839
|
-
* Expand a template block into a full Block with layers.
|
|
840
|
-
*
|
|
841
|
-
* `registry` lets callers swap in a registry that includes user-defined
|
|
842
|
-
* custom templates. Defaults to the built-in registry when omitted.
|
|
843
|
-
*/
|
|
844
|
-
declare function expandTemplateBlock(templateBlock: TemplateBlock, context: TemplateContext, registry?: RuntimeTemplateRegistry): Block;
|
|
845
|
-
/**
|
|
846
|
-
* Audio segment timing info for aligning blocks with audio.
|
|
847
|
-
*/
|
|
848
|
-
interface AudioSegmentTiming {
|
|
849
|
-
/** Start time of this segment in the overall timeline */
|
|
850
|
-
startTime: number;
|
|
851
|
-
/** Duration of this segment */
|
|
852
|
-
duration: number;
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Options for expanding doc blocks.
|
|
856
|
-
*/
|
|
857
|
-
interface ExpandDocBlocksOptions {
|
|
858
|
-
/** Theme for template rendering (defaults to DEFAULT_THEME) */
|
|
859
|
-
theme?: Theme;
|
|
860
|
-
/** Viewport configuration (defaults to 16:9 landscape) */
|
|
861
|
-
viewport?: ViewportConfig;
|
|
862
|
-
/** Persistent layers for visual consistency across blocks */
|
|
863
|
-
persistentLayers?: PersistentLayerConfig;
|
|
864
|
-
/**
|
|
865
|
-
* Audio segment timing information.
|
|
866
|
-
* When provided, blocks are timed relative to their audio segment's start time,
|
|
867
|
-
* ensuring proper synchronization with audio playback.
|
|
868
|
-
*/
|
|
869
|
-
audioSegments?: AudioSegmentTiming[];
|
|
870
|
-
/**
|
|
871
|
-
* User-defined custom templates to merge onto the built-in registry
|
|
872
|
-
* before expanding blocks. Typically passed straight from
|
|
873
|
-
* `Doc.customTemplates`. Built-in names take precedence on collision.
|
|
874
|
-
*/
|
|
875
|
-
customTemplates?: readonly CustomTemplateDefinition[];
|
|
876
|
-
}
|
|
877
|
-
declare function expandDocBlocks(blocks: DocBlock[], options?: ExpandDocBlocksOptions): Block[];
|
|
878
|
-
/**
|
|
879
|
-
* Get list of available template names.
|
|
880
|
-
*/
|
|
881
|
-
declare function getAvailableTemplates(): string[];
|
|
882
|
-
/**
|
|
883
|
-
* Check if a template exists. Accepts both the canonical short id
|
|
884
|
-
* (`title`, `quote`, `map`, `list`) and legacy aliases
|
|
885
|
-
* (`titleBlock`, `quoteBlock`, `mapBlock`, `listBlock`).
|
|
886
|
-
*/
|
|
887
|
-
declare function hasTemplate(name: string): boolean;
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Animation Utilities
|
|
891
|
-
*
|
|
892
|
-
* Helper functions for mapping Doc animations to CSS classes and styles.
|
|
893
|
-
* Generates the appropriate animation class names and CSS custom properties
|
|
894
|
-
* for duration, delay, and easing.
|
|
895
|
-
*
|
|
896
|
-
* This is shared code used by both site and efb-app doc renderers.
|
|
897
|
-
*/
|
|
898
|
-
|
|
899
|
-
interface AnimationResult {
|
|
900
|
-
/** CSS class name to apply */
|
|
901
|
-
className: string;
|
|
902
|
-
/** Inline styles for CSS custom properties */
|
|
903
|
-
style: Record<string, string>;
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Get CSS class and styles for an animation.
|
|
907
|
-
*/
|
|
908
|
-
declare function getAnimationStyle(animation: Animation | undefined, _currentTime?: number): AnimationResult;
|
|
909
|
-
/**
|
|
910
|
-
* Get default duration for an animation type.
|
|
911
|
-
*/
|
|
912
|
-
declare function getDefaultAnimationDuration(type: AnimationType): number;
|
|
913
|
-
/**
|
|
914
|
-
* Get transition class for slide entry/exit.
|
|
915
|
-
*/
|
|
916
|
-
declare function getTransitionClass(type: TransitionType, entering: boolean, direction?: TransitionDirection): string;
|
|
917
|
-
/**
|
|
918
|
-
* Calculate animation progress (0-1) based on current time.
|
|
919
|
-
*/
|
|
920
|
-
declare function getAnimationProgress(animation: Animation, currentTime: number, slideDuration: number): number;
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Theme Utilities
|
|
924
|
-
*
|
|
925
|
-
* Template-facing helpers that read from the Theme object on the
|
|
926
|
-
* TemplateContext. Templates call these instead of hard-coding style
|
|
927
|
-
* decisions, so the same template code adapts to any theme.
|
|
928
|
-
*/
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
* Resolve a named color scheme from the theme, with a safe fallback.
|
|
932
|
-
* Templates call this instead of `COLOR_SCHEMES[name]`.
|
|
933
|
-
*/
|
|
934
|
-
declare function resolveColorScheme(context: TemplateContext, name: string | undefined): ThemeColorScheme;
|
|
935
|
-
/**
|
|
936
|
-
* Get the theme font family for a given role, resolved to a CSS string.
|
|
937
|
-
* Templates call this to set `fontFamily` on text layers.
|
|
938
|
-
*
|
|
939
|
-
* Theme fields are structured `FontFamily` references (`{ stackId }` or
|
|
940
|
-
* `{ custom: { name, fallback } }`); this helper resolves them to a
|
|
941
|
-
* CSS font-family string with safe fallbacks.
|
|
942
|
-
*/
|
|
943
|
-
declare function getThemeFont(context: TemplateContext, role: 'title' | 'body' | 'mono'): string;
|
|
944
|
-
/**
|
|
945
|
-
* Calculate a theme-aware scaled font size.
|
|
946
|
-
* Applies the theme's typography scale multipliers on top of the
|
|
947
|
-
* viewport-based font scale from LayoutStrategy.
|
|
948
|
-
*
|
|
949
|
-
* @param basePx Base font size designed for 1920×1080
|
|
950
|
-
* @param context Template context (includes fontScale, layout, theme)
|
|
951
|
-
* @param isTitle Whether this is title text (uses titleScale) or body (bodyScale)
|
|
952
|
-
*/
|
|
953
|
-
declare function themedFontSize(basePx: number, context: TemplateContext, isTitle?: boolean): number;
|
|
954
|
-
/**
|
|
955
|
-
* Scale an animation duration by the theme's animationSpeed multiplier.
|
|
956
|
-
* A speed of 1.0 returns the base duration unchanged.
|
|
957
|
-
*/
|
|
958
|
-
declare function scaleAnimationDuration(baseDuration: number, context: TemplateContext): number;
|
|
959
|
-
/**
|
|
960
|
-
* Get the theme's default animation type for a layer kind.
|
|
961
|
-
* Returns `undefined` when the theme doesn't specify one (template picks its own).
|
|
962
|
-
*/
|
|
963
|
-
declare function getDefaultAnimation(context: TemplateContext, layerType: 'text' | 'image'): AnimationType | undefined;
|
|
964
|
-
/**
|
|
965
|
-
* Theme-aware entrance animation for a template layer.
|
|
966
|
-
*
|
|
967
|
-
* The theme's `renderStyle.defaultTextAnimation` / `defaultImageAnimation`
|
|
968
|
-
* overrides the entrance *type*; the template keeps its authored duration,
|
|
969
|
-
* delay, and stagger. Templates opt in per layer:
|
|
970
|
-
*
|
|
971
|
-
* ```ts
|
|
972
|
-
* animation: themedEntrance(context, 'text', { type: 'fadeIn', duration: 2 })
|
|
973
|
-
* ```
|
|
974
|
-
*
|
|
975
|
-
* `slowZoom` is excluded — it's an ambient treatment handled by the
|
|
976
|
-
* `applyRenderStyleToLayers` post-pass, not an entrance.
|
|
977
|
-
*/
|
|
978
|
-
declare function themedEntrance(context: TemplateContext, layerType: 'text' | 'image', fallback: Animation): Animation;
|
|
979
|
-
/**
|
|
980
|
-
* Whether the theme defaults to text shadows.
|
|
981
|
-
* Templates should consult this when choosing `shadow: true/false`.
|
|
982
|
-
*/
|
|
983
|
-
declare function shouldUseShadow(context: TemplateContext): boolean;
|
|
984
|
-
/**
|
|
985
|
-
* Get the theme's overlay opacity for image-backed blocks.
|
|
986
|
-
*/
|
|
987
|
-
declare function getOverlayOpacity(context: TemplateContext): number;
|
|
988
|
-
/**
|
|
989
|
-
* Resolve the effective photographic treatment for a block's imagery.
|
|
990
|
-
*
|
|
991
|
-
* Precedence: the block's `imageTreatment` override ('none' opts out, a
|
|
992
|
-
* type forces that grade) → the theme's `style.imageTreatment` → none.
|
|
993
|
-
* Duotone tints default to the theme primary. Templates pass the result
|
|
994
|
-
* straight into `ImageLayer.content.treatment`.
|
|
995
|
-
*/
|
|
996
|
-
declare function themedImageTreatment(context: TemplateContext, override?: 'none' | 'mono' | 'duotone' | 'warm' | 'cool'): ImageTreatment | undefined;
|
|
997
|
-
/**
|
|
998
|
-
* Theme-derived surface gradient for text-first templates.
|
|
999
|
-
*
|
|
1000
|
-
* Runs from the theme's alternate surface into a slightly deepened
|
|
1001
|
-
* background, staying inside the theme's own hue. Templates must use
|
|
1002
|
-
* this instead of hard-coding a dark endpoint (`#0f1520`, `#1e2030`, …):
|
|
1003
|
-
* hard-coded navy endpoints made light themes render dark panels and
|
|
1004
|
-
* warm themes drift cold halfway down the block.
|
|
1005
|
-
*/
|
|
1006
|
-
declare function themedSurfaceGradient(context: TemplateContext, angleDeg?: number): string;
|
|
1007
|
-
/**
|
|
1008
|
-
* Translucent overlay tint derived from the theme background, for text
|
|
1009
|
-
* bands/scrims painted over imagery. Light themes get a light scrim with
|
|
1010
|
-
* dark theme text on top; dark themes get the familiar dark scrim —
|
|
1011
|
-
* `theme.colors.text` stays legible on it by construction.
|
|
1012
|
-
*/
|
|
1013
|
-
declare function themedScrim(context: TemplateContext, alpha?: number): string;
|
|
1014
|
-
/**
|
|
1015
|
-
* Read a per-template hint from the theme's renderStyle.
|
|
1016
|
-
* Returns `fallback` when the hint isn't defined.
|
|
1017
|
-
*
|
|
1018
|
-
* @example
|
|
1019
|
-
* ```ts
|
|
1020
|
-
* const entrance = getTemplateHint(context, 'statHighlight', 'entrance', 'subtle');
|
|
1021
|
-
* ```
|
|
1022
|
-
*/
|
|
1023
|
-
declare function getTemplateHint<T extends string | number | boolean>(context: TemplateContext, templateName: string, key: string, fallback: T): T;
|
|
1024
|
-
|
|
1025
|
-
/**
|
|
1026
|
-
* Render-style post-pass — applies a theme's mechanical motion defaults to
|
|
1027
|
-
* template-generated layers.
|
|
1028
|
-
*
|
|
1029
|
-
* This is the intent-free half of theme motion (see `themedEntrance` in
|
|
1030
|
-
* [themeUtils.ts](./themeUtils.ts) for the intent-bearing half): it never
|
|
1031
|
-
* decides *what kind* of entrance a layer gets, only
|
|
1032
|
-
*
|
|
1033
|
-
* 1. scales existing animation durations/delays by the theme's
|
|
1034
|
-
* `style.animationSpeed` multiplier (1.4 = calmer/slower, 0.7 = snappier,
|
|
1035
|
-
* 1.0 = no-op), and
|
|
1036
|
-
* 2. gives full-bleed cover imagery with no authored animation a gentle,
|
|
1037
|
-
* deterministic Ken Burns when the theme opts into ambient motion.
|
|
1038
|
-
*
|
|
1039
|
-
* Applied ONLY to template-generated layers — raw authored `block.layers`
|
|
1040
|
-
* are never touched, and an explicit `animation` (including
|
|
1041
|
-
* `{ type: 'none' }`) always wins.
|
|
1042
|
-
*/
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* Whether the theme asks for ambient Ken Burns on otherwise-static imagery.
|
|
1046
|
-
* `defaultImageAnimation: 'slowZoom'` is treated as an alias for the boolean
|
|
1047
|
-
* (that's what themes authoring it were reaching for).
|
|
1048
|
-
*/
|
|
1049
|
-
declare function themeWantsAmbientMotion(theme: Theme): boolean;
|
|
1050
|
-
/**
|
|
1051
|
-
* Apply the theme's mechanical motion defaults to a block's
|
|
1052
|
-
* template-generated layers. Pure: returns new layer objects where a change
|
|
1053
|
-
* applies and the original objects where none does.
|
|
1054
|
-
*
|
|
1055
|
-
* @param layers Template-generated layers (never raw authored layers)
|
|
1056
|
-
* @param block The source block — supplies the ambient-motion seed and duration
|
|
1057
|
-
* @param theme Resolved theme
|
|
1058
|
-
*/
|
|
1059
|
-
declare function applyRenderStyleToLayers(layers: Layer[], block: {
|
|
1060
|
-
id: string;
|
|
1061
|
-
duration?: number;
|
|
1062
|
-
}, theme: Theme): Layer[];
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
* Image treatment → CSS filter derivation.
|
|
1066
|
-
*
|
|
1067
|
-
* Treatments are theme-level photographic grades (see `ImageTreatment` in
|
|
1068
|
-
* [Doc.ts](../../schemas/Doc.ts)). They compile to plain CSS `filter`
|
|
1069
|
-
* functions so the same string works on a foreignObject `<img>`, an SVG
|
|
1070
|
-
* `<image>` element, and in headless frame capture — no SVG filter defs to
|
|
1071
|
-
* coordinate, no renderer-specific code paths.
|
|
1072
|
-
*/
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Build the CSS `filter` value for a treatment and/or blur.
|
|
1076
|
-
* Returns `undefined` when there is nothing to apply.
|
|
1077
|
-
*/
|
|
1078
|
-
declare function cssFilterForTreatment(treatment?: ImageTreatment, blur?: number): string | undefined;
|
|
1079
|
-
|
|
1080
|
-
/**
|
|
1081
|
-
* Template input derivation — build a template's required inputs from a
|
|
1082
|
-
* block's heading + markdown body.
|
|
1083
|
-
*
|
|
1084
|
-
* Used by:
|
|
1085
|
-
* - `markdownToDoc`'s content-aware auto template picking, so an
|
|
1086
|
-
* auto-picked `quote`/`statHighlight`/`leftFeature` block carries the
|
|
1087
|
-
* inputs its template needs through every render path (player, linear
|
|
1088
|
-
* view, exports).
|
|
1089
|
-
* - `LinearDocView` / editor previews, to render annotated blocks whose
|
|
1090
|
-
* authors didn't spell out every template param.
|
|
1091
|
-
*
|
|
1092
|
-
* Two modes:
|
|
1093
|
-
* - strict (default): returns `null` when an essential input can't be
|
|
1094
|
-
* derived (no image for a feature block, no table for dataTable…) —
|
|
1095
|
-
* auto-picking uses this to fall back to the structural default.
|
|
1096
|
-
* - placeholders: returns visible placeholder values instead of failing —
|
|
1097
|
-
* preview surfaces use this so a half-authored block still renders.
|
|
1098
|
-
*/
|
|
1099
|
-
|
|
1100
|
-
/** First image discovered in a block's body, with explicit dimensions when present. */
|
|
1101
|
-
interface FirstImage {
|
|
1102
|
-
src: string;
|
|
1103
|
-
alt: string;
|
|
1104
|
-
width?: number;
|
|
1105
|
-
height?: number;
|
|
1106
|
-
}
|
|
1107
|
-
/** Plain text of a block's body contents (excluding the heading). */
|
|
1108
|
-
declare function extractBodyPlainText(contents?: MarkdownBlockNode[]): string;
|
|
1109
|
-
/** Extract list items as plain text. */
|
|
1110
|
-
declare function extractListItems(contents?: MarkdownBlockNode[]): string[];
|
|
1111
|
-
/**
|
|
1112
|
-
* Find images referenced anywhere in block contents — both markdown
|
|
1113
|
-
* shorthand `` (type `image`) and raw HTML `<img>` tags
|
|
1114
|
-
* (type `htmlBlock`/`htmlInline`). The WYSIWYG editor emits the HTML form
|
|
1115
|
-
* whenever a user resizes an image, so missing that path silently breaks
|
|
1116
|
-
* every resized image.
|
|
1117
|
-
*
|
|
1118
|
-
* @param limit Stop after this many images (default: all).
|
|
1119
|
-
*/
|
|
1120
|
-
declare function extractImages(contents: MarkdownBlockNode[] | undefined, limit?: number): FirstImage[];
|
|
1121
|
-
/** First image in a block's body, or null. */
|
|
1122
|
-
declare function extractFirstImage(contents: MarkdownBlockNode[] | undefined): FirstImage | null;
|
|
1123
|
-
/** Extract table data (headers, rows, alignment) from block contents. */
|
|
1124
|
-
declare function extractTableFromContents(contents?: MarkdownBlockNode[]): {
|
|
1125
|
-
headers: string[];
|
|
1126
|
-
rows: string[][];
|
|
1127
|
-
align?: (('left' | 'right' | 'center') | null)[];
|
|
1128
|
-
} | null;
|
|
1129
|
-
/** First blockquote's plain text, or ''. */
|
|
1130
|
-
declare function extractBlockquoteText(contents?: MarkdownBlockNode[]): string;
|
|
1131
|
-
interface DeriveTemplateInputsOptions {
|
|
1132
|
-
/**
|
|
1133
|
-
* Return visible placeholder values instead of `null` when an essential
|
|
1134
|
-
* input can't be derived (preview surfaces). Default false (strict).
|
|
1135
|
-
*/
|
|
1136
|
-
placeholders?: boolean;
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* Derive a template's inputs from a block's heading text and body nodes.
|
|
1140
|
-
* Returns the input fields to merge onto the block, or `null` in strict
|
|
1141
|
-
* mode when an essential input is missing.
|
|
1142
|
-
*/
|
|
1143
|
-
declare function deriveTemplateInputs(templateName: string, headingText: string, contents: MarkdownBlockNode[] | undefined, options?: DeriveTemplateInputsOptions): Record<string, unknown> | null;
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* Markdown → Doc Conversion
|
|
1147
|
-
*
|
|
1148
|
-
* Converts a MarkdownDocument into a hierarchical Doc whose Block tree
|
|
1149
|
-
* mirrors the heading structure of the markdown. Every heading (H1–H6)
|
|
1150
|
-
* becomes a Block; body content between headings populates `contents`;
|
|
1151
|
-
* sub-headings nest as `children`.
|
|
1152
|
-
*
|
|
1153
|
-
* This enables using BlockTemplates to supply alternate visualizations
|
|
1154
|
-
* for each section of a markdown document.
|
|
1155
|
-
*
|
|
1156
|
-
* @example
|
|
1157
|
-
* ```ts
|
|
1158
|
-
* import { parseMarkdown } from '@bendyline/squisq/markdown';
|
|
1159
|
-
* import { markdownToDoc } from '@bendyline/squisq/doc';
|
|
1160
|
-
*
|
|
1161
|
-
* const md = parseMarkdown('# Intro\n\nHello world\n\n## Details\n\nMore text');
|
|
1162
|
-
* const doc = markdownToDoc(md);
|
|
1163
|
-
* // doc.blocks[0].sourceHeading.depth === 1 ("# Intro")
|
|
1164
|
-
* // doc.blocks[0].contents → [paragraph("Hello world")]
|
|
1165
|
-
* // doc.blocks[0].children[0].sourceHeading.depth === 2 ("## Details")
|
|
1166
|
-
* ```
|
|
1167
|
-
*/
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* Options for markdownToDoc().
|
|
1171
|
-
*/
|
|
1172
|
-
interface MarkdownToDocOptions {
|
|
1173
|
-
/** Article ID for the generated Doc. Default: 'markdown-doc' */
|
|
1174
|
-
articleId?: string;
|
|
1175
|
-
/** Default template name for heading blocks. Default: 'sectionHeader' */
|
|
1176
|
-
defaultTemplate?: string;
|
|
1177
|
-
/** Default duration per block in seconds. Default: 5 */
|
|
1178
|
-
defaultDuration?: number;
|
|
1179
|
-
/** Custom ID generator. Receives the heading node and its index. */
|
|
1180
|
-
generateId?: (heading: MarkdownHeading, index: number) => string;
|
|
1181
|
-
/**
|
|
1182
|
-
* Whether to auto-generate a cover startBlock from the first H1 heading.
|
|
1183
|
-
* When true (default), a StartBlockConfig is created using the first H1's
|
|
1184
|
-
* text as the title. If the document contains an image, the first image
|
|
1185
|
-
* is used as the hero. Set to false to suppress automatic cover generation.
|
|
1186
|
-
*/
|
|
1187
|
-
generateCoverBlock?: boolean;
|
|
1188
|
-
/**
|
|
1189
|
-
* Timestamp recorded as `captions.generatedAt`. When omitted, the field
|
|
1190
|
-
* is left unset so that conversion is fully deterministic — the same
|
|
1191
|
-
* markdown always converts to an identical Doc (important for snapshot
|
|
1192
|
-
* tests, caching, and agents that verify their output by re-converting).
|
|
1193
|
-
*/
|
|
1194
|
-
captionsGeneratedAt?: string;
|
|
1195
|
-
/**
|
|
1196
|
-
* Content-aware template auto-picking for unannotated headings
|
|
1197
|
-
* (default: true). When a heading block carries a strong content signal
|
|
1198
|
-
* — a table, images, a blockquote, a list, a stat-looking line — the
|
|
1199
|
-
* matching template is applied (with inputs derived from the body)
|
|
1200
|
-
* instead of the structural `defaultTemplate`. Explicit `{[template]}`
|
|
1201
|
-
* annotations always win. Authors can also disable per document with
|
|
1202
|
-
* frontmatter `squisq-auto-templates: false`.
|
|
1203
|
-
*/
|
|
1204
|
-
autoTemplates?: boolean;
|
|
1205
|
-
}
|
|
1206
|
-
declare function markdownToDoc(markdownDoc: MarkdownDocument, options?: MarkdownToDocOptions): Doc;
|
|
1207
|
-
/**
|
|
1208
|
-
* Flatten a nested block tree into a depth-first ordered array.
|
|
1209
|
-
* Useful for calculating sequential timing or iterating all blocks.
|
|
1210
|
-
*/
|
|
1211
|
-
declare function flattenBlocks(blocks: Block[]): Block[];
|
|
1212
|
-
/**
|
|
1213
|
-
* Flatten the block tree into the list of *independently renderable*
|
|
1214
|
-
* blocks — like {@link flattenBlocks}, but it does NOT descend into the
|
|
1215
|
-
* children of a container template (`diagram`, `drawing`; see
|
|
1216
|
-
* `isContainerTemplate`). Those children are consumed by the parent's
|
|
1217
|
-
* render (as nodes / shapes), so they must not also surface as their own
|
|
1218
|
-
* slides or sections.
|
|
1219
|
-
*
|
|
1220
|
-
* Use this anywhere a doc is flattened for rendering (slideshow, video,
|
|
1221
|
-
* static pages). Use {@link flattenBlocks} when you genuinely need every
|
|
1222
|
-
* block regardless of role — validation, timing, duplicate-id checks.
|
|
1223
|
-
*/
|
|
1224
|
-
declare function flattenRenderableBlocks(blocks: Block[]): Block[];
|
|
1225
|
-
/**
|
|
1226
|
-
* Count the total number of blocks in a nested tree (including children at all levels).
|
|
1227
|
-
*/
|
|
1228
|
-
declare function countBlocks(blocks: Block[]): number;
|
|
1229
|
-
/**
|
|
1230
|
-
* Get the heading depth for a block. Returns 0 for preamble blocks (no heading).
|
|
1231
|
-
*/
|
|
1232
|
-
declare function getBlockDepth(block: Block): number;
|
|
1233
|
-
|
|
1234
|
-
/**
|
|
1235
|
-
* Doc → Markdown Conversion
|
|
1236
|
-
*
|
|
1237
|
-
* Converts a Doc with a heading-driven Block hierarchy back into a
|
|
1238
|
-
* MarkdownDocument. This is the reverse of markdownToDoc() and enables
|
|
1239
|
-
* round-tripping: edit a Doc's block tree, then serialize back to markdown.
|
|
1240
|
-
*
|
|
1241
|
-
* **Algorithm:**
|
|
1242
|
-
* Walk the block tree depth-first. For each block:
|
|
1243
|
-
* 1. If it has a `sourceHeading`, emit that heading node
|
|
1244
|
-
* 2. Emit all nodes in `contents`
|
|
1245
|
-
* 3. Recurse into `children`
|
|
1246
|
-
*
|
|
1247
|
-
* @example
|
|
1248
|
-
* ```ts
|
|
1249
|
-
* import { markdownToDoc, docToMarkdown } from '@bendyline/squisq/doc';
|
|
1250
|
-
* import { parseMarkdown, stringifyMarkdown } from '@bendyline/squisq/markdown';
|
|
1251
|
-
*
|
|
1252
|
-
* const md = '# Hello\n\nWorld\n';
|
|
1253
|
-
* const doc = markdownToDoc(parseMarkdown(md));
|
|
1254
|
-
* const roundTripped = stringifyMarkdown(docToMarkdown(doc));
|
|
1255
|
-
* ```
|
|
1256
|
-
*/
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* Convert a Doc with heading-driven blocks back to a MarkdownDocument.
|
|
1260
|
-
*
|
|
1261
|
-
* Walks the block tree depth-first, emitting heading nodes and contents
|
|
1262
|
-
* in document order. Blocks without a `sourceHeading` (preamble blocks)
|
|
1263
|
-
* emit only their contents.
|
|
1264
|
-
*
|
|
1265
|
-
* If a block has a `template` or `templateOverrides` that aren't already
|
|
1266
|
-
* reflected in the heading's `templateAnnotation`, the annotation is
|
|
1267
|
-
* injected so the round-trip preserves template assignments.
|
|
1268
|
-
*
|
|
1269
|
-
* @param doc - A Doc whose blocks may have `sourceHeading`, `contents`, and `children`
|
|
1270
|
-
* @returns A MarkdownDocument that can be stringified back to markdown
|
|
1271
|
-
*/
|
|
1272
|
-
declare function docToMarkdown(doc: Doc): MarkdownDocument;
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* Frontmatter serialization for user-defined custom templates (layouts).
|
|
1276
|
-
*
|
|
1277
|
-
* Custom template definitions live in the document's YAML frontmatter
|
|
1278
|
-
* under the key `squisq-custom-templates`. They're stored as a single
|
|
1279
|
-
* **compact JSON** object keyed by template name:
|
|
1280
|
-
*
|
|
1281
|
-
* ```yaml
|
|
1282
|
-
* squisq-custom-templates: {"hero":{"lb":"Hero Section","ly":[{"ty":"text",…}]}}
|
|
1283
|
-
* ```
|
|
1284
|
-
*
|
|
1285
|
-
* Squisq's frontmatter parser is line-based; a JSON object literal
|
|
1286
|
-
* round-trips through it verbatim (no leading quote to strip, single
|
|
1287
|
-
* line), so the value is written **unquoted** and stays human-readable
|
|
1288
|
-
* and diffable — important for a codebase edited by people and agents.
|
|
1289
|
-
*
|
|
1290
|
-
* The JSON is kept small by:
|
|
1291
|
-
* - keying definitions by `name` (drops the `name` field + array wrapper),
|
|
1292
|
-
* - omitting the viewport when it's the 1920×1080 default,
|
|
1293
|
-
* - renaming well-known property names to two-letter codes via
|
|
1294
|
-
* {@link LONG_TO_SHORT} (e.g. `fontSize` → `fz`).
|
|
1295
|
-
*
|
|
1296
|
-
* The rename is a generic, recursive, bijective pass: **any property not
|
|
1297
|
-
* in the map passes through unchanged**, so the format is lossless even
|
|
1298
|
-
* as the Layer schema grows — new fields are simply stored under their
|
|
1299
|
-
* full name until (optionally) added to the map.
|
|
1300
|
-
*
|
|
1301
|
-
* Back-compat: the reader still accepts the historical base64-of-JSON
|
|
1302
|
-
* payload and a structured array, so older documents load unchanged.
|
|
1303
|
-
* The first save migrates them to the compact form.
|
|
1304
|
-
*
|
|
1305
|
-
* The `encodeLayersForFrontmatter` / `decodeLayersFromFrontmatter` pair
|
|
1306
|
-
* handles a single Layer array for the editor's `dataLayers="…"` Pandoc
|
|
1307
|
-
* param path; that path stays base64 (it's a different, per-block
|
|
1308
|
-
* mechanism) and is re-exported here for locality.
|
|
1309
|
-
*/
|
|
1310
|
-
|
|
1311
|
-
/**
|
|
1312
|
-
* Base64-encode a Layer array as JSON, UTF-8 safe. Used by the editor's
|
|
1313
|
-
* per-block `dataLayers="…"` Pandoc param (not the doc-level template
|
|
1314
|
-
* list, which uses the compact JSON above).
|
|
1315
|
-
*
|
|
1316
|
-
* `btoa` only accepts Latin1 strings — any character outside that range
|
|
1317
|
-
* (e.g. an em-dash in a description) throws — so we round through
|
|
1318
|
-
* `TextEncoder`. Works in Node ≥18 and browsers.
|
|
1319
|
-
*/
|
|
1320
|
-
declare function encodeLayersForFrontmatter(layers: readonly Layer[]): string;
|
|
1321
|
-
/** Inverse of {@link encodeLayersForFrontmatter}. Returns [] on parse failure. */
|
|
1322
|
-
declare function decodeLayersFromFrontmatter(encoded: string): Layer[];
|
|
1323
|
-
/**
|
|
1324
|
-
* Read the `squisq-custom-templates` frontmatter key and decode it into
|
|
1325
|
-
* an array of CustomTemplateDefinitions. Returns undefined when the key
|
|
1326
|
-
* is absent or unparseable so callers can omit the field from the Doc.
|
|
1327
|
-
*
|
|
1328
|
-
* Accepts, in order: the compact JSON object (current), a base64-JSON
|
|
1329
|
-
* string (legacy), and an already-structured array/object (in case a
|
|
1330
|
-
* richer YAML parser delivers it). Malformed payloads return undefined
|
|
1331
|
-
* rather than failing the whole doc load.
|
|
1332
|
-
*/
|
|
1333
|
-
declare function readCustomTemplatesFromFrontmatter(frontmatter: Record<string, unknown> | undefined): CustomTemplateDefinition[] | undefined;
|
|
1334
|
-
/**
|
|
1335
|
-
* Encode a list of custom template definitions into the compact JSON
|
|
1336
|
-
* object described in the module header. Returns undefined when the
|
|
1337
|
-
* input list is empty so callers can leave the key off the output.
|
|
1338
|
-
*/
|
|
1339
|
-
declare function writeCustomTemplatesToFrontmatter(templates: readonly CustomTemplateDefinition[] | undefined, options?: {
|
|
1340
|
-
pretty?: boolean;
|
|
1341
|
-
}): string | undefined;
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Frontmatter serialization for user-defined custom themes.
|
|
1345
|
-
*
|
|
1346
|
-
* The theme analog of {@link ./customTemplatesFrontmatter.ts}. Custom Theme
|
|
1347
|
-
* definitions live in the document's YAML frontmatter under the key
|
|
1348
|
-
* `squisq-custom-themes`, stored as a single **compact JSON** object keyed
|
|
1349
|
-
* by theme id:
|
|
1350
|
-
*
|
|
1351
|
-
* ```yaml
|
|
1352
|
-
* squisq-custom-themes: {"my-brand":{"schemaVersion":"1","id":"my-brand",…}}
|
|
1353
|
-
* ```
|
|
1354
|
-
*
|
|
1355
|
-
* Squisq's frontmatter parser is line-based; a JSON object literal
|
|
1356
|
-
* round-trips through it verbatim (single line, no leading quote to strip),
|
|
1357
|
-
* so the value is written **unquoted** and stays human-readable and diffable
|
|
1358
|
-
* — the same mechanism the custom-templates codec relies on.
|
|
1359
|
-
*
|
|
1360
|
-
* Only one theme is *active* per doc (selected by id via the `squisq-theme`
|
|
1361
|
-
* frontmatter key / `Doc.themeId`), but the payload is a keyed map — parallel
|
|
1362
|
-
* to custom templates — so a doc can carry a small catalog and switch between
|
|
1363
|
-
* them, and `resolveThemeForDoc` can resolve any of them doc-scoped.
|
|
1364
|
-
*
|
|
1365
|
-
* Malformed entries are dropped (via `validateTheme`) rather than failing the
|
|
1366
|
-
* whole doc load, matching the tolerant behavior of the templates reader.
|
|
1367
|
-
*/
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Read the custom themes inlined into a document's frontmatter. Returns
|
|
1371
|
-
* undefined when the key is absent or holds no valid theme, so callers can
|
|
1372
|
-
* omit the field from the Doc.
|
|
1373
|
-
*/
|
|
1374
|
-
declare function readCustomThemesFromFrontmatter(frontmatter: Record<string, unknown> | undefined): Theme[] | undefined;
|
|
1375
|
-
/**
|
|
1376
|
-
* Encode a list of custom themes into the compact JSON object described in
|
|
1377
|
-
* the module header (keyed by theme id). Returns undefined when the input is
|
|
1378
|
-
* empty so callers can leave the key off the output.
|
|
1379
|
-
*/
|
|
1380
|
-
declare function writeCustomThemesToFrontmatter(themes: readonly Theme[] | undefined, options?: {
|
|
1381
|
-
pretty?: boolean;
|
|
1382
|
-
}): string | undefined;
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
* Doc-scoped theme resolution.
|
|
1386
|
-
*
|
|
1387
|
-
* The theme analog of how `buildRegistry` resolves custom templates: pure and
|
|
1388
|
-
* doc-scoped, with no global state. `resolveThemeForDoc` looks up the active
|
|
1389
|
-
* theme id in the doc's own custom themes first, then falls back to the
|
|
1390
|
-
* built-in / globally-registered themes via `resolveTheme`.
|
|
1391
|
-
*
|
|
1392
|
-
* It accepts either a squisq `Doc` (which carries a typed `customThemes`
|
|
1393
|
-
* array) or anything with raw `frontmatter` — notably a `MarkdownDocument`,
|
|
1394
|
-
* which is the shape every export pipeline pivots through. In the latter case
|
|
1395
|
-
* the inline themes are decoded from the `squisq-custom-themes` frontmatter
|
|
1396
|
-
* payload. Either way, resolution needs no `registerTheme` call — an inline
|
|
1397
|
-
* custom theme ships with the doc, exactly like custom templates.
|
|
1398
|
-
*/
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
* The minimal shape `resolveThemeForDoc` needs. Satisfied by both the squisq
|
|
1402
|
-
* `Doc` (typed `customThemes` + `themeId`) and a `MarkdownDocument` (raw
|
|
1403
|
-
* `frontmatter` carrying the encoded payload).
|
|
1404
|
-
*/
|
|
1405
|
-
interface ThemeResolvable {
|
|
1406
|
-
themeId?: string;
|
|
1407
|
-
customThemes?: Theme[];
|
|
1408
|
-
frontmatter?: Record<string, unknown>;
|
|
1409
|
-
}
|
|
1410
|
-
/**
|
|
1411
|
-
* Resolve the Theme a document should render with.
|
|
1412
|
-
*
|
|
1413
|
-
* @param doc - the document (may carry inline custom themes plus a `themeId`
|
|
1414
|
-
* / `squisq-theme` frontmatter selector).
|
|
1415
|
-
* @param explicitId - an id that overrides the doc's own selection (e.g. the
|
|
1416
|
-
* editor's theme dropdown, or an export `--theme` option). When omitted, the
|
|
1417
|
-
* doc's `themeId` / frontmatter theme id is used.
|
|
1418
|
-
* @returns the matching inline custom theme (doc-scoped) when present, else
|
|
1419
|
-
* the built-in / registered theme for that id, else the default theme.
|
|
1420
|
-
*/
|
|
1421
|
-
declare function resolveThemeForDoc(doc: ThemeResolvable | null | undefined, explicitId?: string): Theme;
|
|
1422
|
-
|
|
1423
|
-
/**
|
|
1424
|
-
* getLayers — Compute visual layers for a block on demand.
|
|
1425
|
-
*
|
|
1426
|
-
* This is the preferred way to obtain renderable layers for a block.
|
|
1427
|
-
* Instead of storing pre-computed layers on the Block object, call
|
|
1428
|
-
* `getLayers(block, context)` to derive them from the block's template
|
|
1429
|
-
* name, content, and the current render context (theme, viewport, etc.).
|
|
1430
|
-
*
|
|
1431
|
-
* For raw blocks that already carry a `layers` array, those layers are
|
|
1432
|
-
* returned directly (with optional persistent layer injection).
|
|
1433
|
-
*
|
|
1434
|
-
* @example
|
|
1435
|
-
* ```ts
|
|
1436
|
-
* import { getLayers } from '@bendyline/squisq/doc';
|
|
1437
|
-
*
|
|
1438
|
-
* const layers = getLayers(block, {
|
|
1439
|
-
* theme: DEFAULT_THEME,
|
|
1440
|
-
* viewport: VIEWPORT_PRESETS.landscape,
|
|
1441
|
-
* blockIndex: 0,
|
|
1442
|
-
* totalBlocks: 10,
|
|
1443
|
-
* });
|
|
1444
|
-
* ```
|
|
1445
|
-
*/
|
|
1446
|
-
|
|
1447
|
-
/**
|
|
1448
|
-
* Context needed to compute layers for a block.
|
|
1449
|
-
*
|
|
1450
|
-
* Captures the visual rendering parameters: theme colors, viewport
|
|
1451
|
-
* configuration, persistent layers, and the block's position within
|
|
1452
|
-
* the doc (for template functions that vary output by index).
|
|
1453
|
-
*/
|
|
1454
|
-
interface RenderContext {
|
|
1455
|
-
/** Theme for template rendering. Defaults to DEFAULT_THEME (documentary). */
|
|
1456
|
-
theme?: Theme;
|
|
1457
|
-
/** Target viewport configuration. Defaults to 16:9 landscape. */
|
|
1458
|
-
viewport?: ViewportConfig;
|
|
1459
|
-
/** Persistent layers injected behind and/or on top of all block content. */
|
|
1460
|
-
persistentLayers?: PersistentLayerConfig;
|
|
1461
|
-
/** 0-based index of this block in the sequence. Defaults to 0. */
|
|
1462
|
-
blockIndex?: number;
|
|
1463
|
-
/** Total number of blocks in the doc. Defaults to 1. */
|
|
1464
|
-
totalBlocks?: number;
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Compute the visual layers for a block.
|
|
1468
|
-
*
|
|
1469
|
-
* Resolution order:
|
|
1470
|
-
* 1. If the block already has a non-empty `layers` array, use it (raw block).
|
|
1471
|
-
* 2. If the block has a `template` name that exists in the registry,
|
|
1472
|
-
* call the template function to generate layers.
|
|
1473
|
-
* 3. Otherwise return an empty array.
|
|
1474
|
-
*
|
|
1475
|
-
* Persistent layers (bottom/top) from the render context are injected
|
|
1476
|
-
* around the result unless the block opts out via `useBottomLayer: false`
|
|
1477
|
-
* or `useTopLayer: false`.
|
|
1478
|
-
*
|
|
1479
|
-
* @param block A Block or TemplateBlock to render.
|
|
1480
|
-
* @param context Render context (theme, viewport, persistent layers, position).
|
|
1481
|
-
* @returns The computed Layer[] for the block, ready for BlockRenderer.
|
|
1482
|
-
*/
|
|
1483
|
-
declare function getLayers(block: DocBlock, context?: RenderContext): Layer[];
|
|
1484
|
-
|
|
1485
|
-
/**
|
|
1486
|
-
* Audio Mapping
|
|
1487
|
-
*
|
|
1488
|
-
* Associates audio segments (MP3 files) with document blocks.
|
|
1489
|
-
* Supports two modes:
|
|
1490
|
-
*
|
|
1491
|
-
* 1. **Explicit annotation**: Blocks with `{[audio=filename.mp3]}` in their
|
|
1492
|
-
* heading annotation are directly mapped to that audio file.
|
|
1493
|
-
*
|
|
1494
|
-
* 2. **Auto-matching**: When no annotations exist but the container has MP3s
|
|
1495
|
-
* with `.timing.json` files, matches MP3s to blocks by comparing the
|
|
1496
|
-
* timing.json `sourceText` against block text content (word overlap).
|
|
1497
|
-
* Falls back to filename-based matching (slugified title comparison).
|
|
1498
|
-
*/
|
|
1499
|
-
|
|
1500
|
-
/**
|
|
1501
|
-
* Calculate Jaccard similarity between two texts (word overlap).
|
|
1502
|
-
* Returns 0–1 where 1 = identical word sets.
|
|
1503
|
-
*/
|
|
1504
|
-
declare function scoreTextSimilarity(a: string, b: string): number;
|
|
1505
|
-
/**
|
|
1506
|
-
* Resolve audio mapping for a Doc using a ContentContainer.
|
|
1507
|
-
*
|
|
1508
|
-
* Tries explicit `{[audio=filename.mp3]}` annotations first,
|
|
1509
|
-
* then falls back to auto-matching by content similarity.
|
|
1510
|
-
*
|
|
1511
|
-
* Returns a new Doc with `audio.segments` populated and blocks
|
|
1512
|
-
* assigned to the correct `audioSegment` indices.
|
|
1513
|
-
*
|
|
1514
|
-
* @param doc - The source Doc (not mutated).
|
|
1515
|
-
* @param container - ContentContainer with MP3 and timing files.
|
|
1516
|
-
* @returns New Doc with audio segments resolved, or original doc if no matches.
|
|
1517
|
-
*/
|
|
1518
|
-
declare function resolveAudioMapping(doc: Doc, container: ContentContainer): Promise<Doc>;
|
|
1519
|
-
|
|
1520
|
-
/**
|
|
1521
|
-
* Structured template data from markdown body content.
|
|
1522
|
-
*
|
|
1523
|
-
* Attribute strings on a heading annotation are fine for scalar params,
|
|
1524
|
-
* but tabular or nested inputs (dataTable rows, map markers, chart data)
|
|
1525
|
-
* don't pack well into a single quoted line. This module supplies the two
|
|
1526
|
-
* structured channels instead:
|
|
1527
|
-
*
|
|
1528
|
-
* 1. **Data fences** — a fenced code block whose info string is
|
|
1529
|
-
* `json data` or `yaml data`, placed in a heading's body content:
|
|
1530
|
-
*
|
|
1531
|
-
* ````markdown
|
|
1532
|
-
* ## Quarterly numbers {[dataTable]}
|
|
1533
|
-
*
|
|
1534
|
-
* ```json data
|
|
1535
|
-
* { "headers": ["Q", "Revenue"], "rows": [["Q1", "1.2M"], ["Q2", "1.4M"]] }
|
|
1536
|
-
* ```
|
|
1537
|
-
* ````
|
|
1538
|
-
*
|
|
1539
|
-
* The parsed object lands on `block.templateData` and merges into the
|
|
1540
|
-
* template input (after defaults, before `{[…]}` string overrides).
|
|
1541
|
-
* The `data` marker keeps ordinary ```json code samples — which should
|
|
1542
|
-
* render as code — out of the template input.
|
|
1543
|
-
*
|
|
1544
|
-
* 2. **GFM tables** — for the `dataTable` template, the first table in the
|
|
1545
|
-
* section body supplies `headers` / `rows` / `align` when the author
|
|
1546
|
-
* didn't provide them explicitly.
|
|
1547
|
-
*
|
|
1548
|
-
* YAML support is a documented subset (this package has no YAML
|
|
1549
|
-
* dependency): top-level `key: scalar`, `key: [inline, array]`, `key:`
|
|
1550
|
-
* followed by an indented `- item` block sequence (scalars or inline
|
|
1551
|
-
* arrays), and `key:` followed by *one level* of indented `subkey: scalar`
|
|
1552
|
-
* lines (a nested map, e.g. `center:` + indented `lat:` / `lng:`). Deeper
|
|
1553
|
-
* nesting, and mixing list items with mapping keys under one key, are
|
|
1554
|
-
* rejected with a clear error — use a `json data` fence for those.
|
|
1555
|
-
*/
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* Whether a code block is a structured-data fence: lang `json`/`yaml`/`yml`
|
|
1559
|
-
* with the word `data` in the fence meta (` ```json data `).
|
|
1560
|
-
*/
|
|
1561
|
-
declare function isDataFence(node: MarkdownCodeBlock): boolean;
|
|
1562
|
-
interface DataFenceParseResult {
|
|
1563
|
-
/** Parsed key→value map. Undefined when parsing failed. */
|
|
1564
|
-
data?: Record<string, unknown>;
|
|
1565
|
-
/** Parse failure description. Undefined when parsing succeeded. */
|
|
1566
|
-
error?: string;
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* Parse a data fence's content into a key→value map. JSON fences must
|
|
1570
|
-
* contain a top-level object (arrays have no key to merge under); YAML
|
|
1571
|
-
* fences are parsed with {@link parseYamlSubset}.
|
|
1572
|
-
*/
|
|
1573
|
-
declare function parseDataFence(node: MarkdownCodeBlock): DataFenceParseResult;
|
|
1574
|
-
/**
|
|
1575
|
-
* Return a new contents array with the first data fence's code content
|
|
1576
|
-
* replaced by `data` (pretty-printed JSON). The fence node keeps its
|
|
1577
|
-
* language and `data` marker; only `value` changes. When no data fence
|
|
1578
|
-
* exists, a new ` ```json data ` fence is appended instead.
|
|
1579
|
-
*
|
|
1580
|
-
* Pure: neither `contents` nor its nodes are mutated. This is the write
|
|
1581
|
-
* half of the data-fence channel — editors update `block.templateData`
|
|
1582
|
-
* and call this to reflect the change back into `block.contents`.
|
|
1583
|
-
*/
|
|
1584
|
-
declare function replaceDataFence(contents: MarkdownBlockNode[], data: Record<string, unknown>): MarkdownBlockNode[];
|
|
1585
|
-
/**
|
|
1586
|
-
* Parse the supported YAML subset (see module doc) into a key→value map.
|
|
1587
|
-
* Throws an Error with a line-anchored message on anything outside the
|
|
1588
|
-
* subset, so callers can surface a precise diagnostic.
|
|
1589
|
-
*/
|
|
1590
|
-
declare function parseYamlSubset(src: string): Record<string, unknown>;
|
|
1591
|
-
interface ExtractedTableData {
|
|
1592
|
-
headers: string[];
|
|
1593
|
-
rows: string[][];
|
|
1594
|
-
align?: (('left' | 'right' | 'center') | null)[];
|
|
1595
|
-
}
|
|
1596
|
-
/** Find the first GFM table among a block's body contents. */
|
|
1597
|
-
declare function findFirstTable(contents: MarkdownBlockNode[] | undefined): MarkdownTable | undefined;
|
|
1598
|
-
/**
|
|
1599
|
-
* Extract `headers` / `rows` / `align` (the `dataTable` input shape) from a
|
|
1600
|
-
* GFM table node. The first row is the header row.
|
|
1601
|
-
*/
|
|
1602
|
-
declare function extractTableData(table: MarkdownTable): ExtractedTableData;
|
|
1603
|
-
|
|
1604
|
-
/**
|
|
1605
|
-
* Markdown document validation.
|
|
1606
|
-
*
|
|
1607
|
-
* `validateMarkdownSource()` gives authors and agents fast, structural
|
|
1608
|
-
* feedback on a squisq markdown document — the same checks the renderer
|
|
1609
|
-
* applies, surfaced as diagnostics instead of degraded slides:
|
|
1610
|
-
*
|
|
1611
|
-
* - unknown template names (with a did-you-mean suggestion)
|
|
1612
|
-
* - unknown drawing shapes, and shape annotations used outside a `{[drawing]}`
|
|
1613
|
-
* - `{[…]}` text that was not recognized as an annotation (bad quoting,
|
|
1614
|
-
* non-heading placement, unknown inline icon)
|
|
1615
|
-
* - malformed heading-attribute values (`x=abc`, bad `startTime`) and
|
|
1616
|
-
* non-numeric drawing-shape geometry
|
|
1617
|
-
* - `connectsTo` / drawing `from`/`to` targets that don't resolve,
|
|
1618
|
-
* duplicate block ids, unparseable data fences (reported by `markdownToDoc`)
|
|
1619
|
-
* - image references missing from the provided asset set (.dbk contents)
|
|
1620
|
-
*
|
|
1621
|
-
* The CLI exposes this as `squisq validate <input>`; agents can also call
|
|
1622
|
-
* it directly and iterate until the diagnostics list is empty.
|
|
1623
|
-
*/
|
|
1624
|
-
|
|
1625
|
-
interface ValidateOptions {
|
|
1626
|
-
/**
|
|
1627
|
-
* Known asset paths for image/video reference checks — typically the
|
|
1628
|
-
* file list of a .dbk container or the document's folder. Relative
|
|
1629
|
-
* references not present here produce a `missing-asset` warning.
|
|
1630
|
-
* When omitted, asset checks are skipped.
|
|
1631
|
-
*/
|
|
1632
|
-
assets?: ReadonlySet<string> | ((path: string) => boolean);
|
|
1633
|
-
/**
|
|
1634
|
-
* Additional template names to accept beyond the built-in registry and
|
|
1635
|
-
* the document's own `customTemplates` (e.g. app-registered templates).
|
|
1636
|
-
*/
|
|
1637
|
-
extraTemplates?: readonly string[];
|
|
1638
|
-
}
|
|
1639
|
-
interface MarkdownValidationResult {
|
|
1640
|
-
/** All findings, in source order where line information exists. */
|
|
1641
|
-
diagnostics: DocDiagnostic[];
|
|
1642
|
-
errorCount: number;
|
|
1643
|
-
warningCount: number;
|
|
1644
|
-
infoCount: number;
|
|
1645
|
-
/** The converted Doc (conversion diagnostics are included above). */
|
|
1646
|
-
doc: Doc;
|
|
1647
|
-
}
|
|
1648
|
-
/**
|
|
1649
|
-
* Validate a squisq markdown source string. Parses, converts (collecting
|
|
1650
|
-
* the conversion's own diagnostics), and runs the structural checks above.
|
|
1651
|
-
*/
|
|
1652
|
-
declare function validateMarkdownSource(source: string, options?: ValidateOptions): MarkdownValidationResult;
|
|
1653
|
-
/**
|
|
1654
|
-
* Validate an already-parsed MarkdownDocument. See {@link validateMarkdownSource}.
|
|
1655
|
-
*/
|
|
1656
|
-
declare function validateMarkdownDoc(markdownDoc: MarkdownDocument, options?: ValidateOptions): MarkdownValidationResult;
|
|
1657
|
-
|
|
1658
|
-
/**
|
|
1659
|
-
* Fallback Block Rendering
|
|
1660
|
-
*
|
|
1661
|
-
* The graceful-degradation guarantee: a block whose template can't render —
|
|
1662
|
-
* unknown template name, template function threw, or returned a non-array —
|
|
1663
|
-
* still renders its heading and body text as a plain, readable card instead
|
|
1664
|
-
* of a blank slide. A small notice line names the problem so authors (and
|
|
1665
|
-
* agents reviewing screenshots) can see *why* the block degraded.
|
|
1666
|
-
*
|
|
1667
|
-
* This is intentionally not a registered template: it can't be requested by
|
|
1668
|
-
* name, only reached when a requested template fails. See `getLayers()`.
|
|
1669
|
-
*/
|
|
1670
|
-
|
|
1671
|
-
/**
|
|
1672
|
-
* Render a block's heading + body text as plain layers, with a notice line
|
|
1673
|
-
* describing why the requested template didn't render.
|
|
1674
|
-
*
|
|
1675
|
-
* @param block The block that failed to render via its template.
|
|
1676
|
-
* @param context Template context (theme, viewport).
|
|
1677
|
-
* @param notice Short problem description, e.g. `Unknown template "photGrid"`.
|
|
1678
|
-
*/
|
|
1679
|
-
declare function fallbackBlockLayers(block: DocBlock, context: TemplateContext, notice: string): Layer[];
|
|
1680
|
-
|
|
1681
|
-
/**
|
|
1682
|
-
* Template input descriptors — a typed catalog of the inline `{[…]}` params
|
|
1683
|
-
* each built-in template understands, plus the pure coercion + lint logic
|
|
1684
|
-
* that consumes it.
|
|
1685
|
-
*
|
|
1686
|
-
* Two jobs, one source of truth:
|
|
1687
|
-
*
|
|
1688
|
-
* - **Coercion (`coerceTemplateParams`)** turns a flat `key → raw string`
|
|
1689
|
-
* param map (from a `{[name key=value]}` annotation, always strings) into a
|
|
1690
|
-
* partial typed input the template functions can consume directly — e.g.
|
|
1691
|
-
* `center="47.6,-122.3"` → `{ lat: 47.6, lng: -122.3 }`, `zoom=9` → `9`.
|
|
1692
|
-
* This is what makes `{[map center="47.6,-122.3" zoom=9]}` render with no
|
|
1693
|
-
* changes to any template function. Unknown keys ALWAYS pass through
|
|
1694
|
-
* untouched (as strings), so coercion is never lossy; coercion failures are
|
|
1695
|
-
* returned as `warnings` and the raw string is preserved.
|
|
1696
|
-
*
|
|
1697
|
-
* - **Linting (`lintTemplateParams`)** checks a param map against the
|
|
1698
|
-
* descriptors and reports unknown keys (with a did-you-mean suggestion),
|
|
1699
|
-
* values outside a closed enum / that fail coercion, and missing required
|
|
1700
|
-
* inputs. The document validator surfaces these as diagnostics.
|
|
1701
|
-
*
|
|
1702
|
-
* This mirrors the proven block-meta descriptor pattern in
|
|
1703
|
-
* `markdown/annotationCoercion.ts` (`BLOCK_META_KEY_DESCRIPTORS`), extended
|
|
1704
|
-
* from block geometry/timing to per-template content inputs.
|
|
1705
|
-
*
|
|
1706
|
-
* The descriptors are the `{[…]}` counterpart of the template input
|
|
1707
|
-
* interfaces in `schemas/BlockTemplates.ts` — only keys/enums that provably
|
|
1708
|
-
* exist on those interfaces are declared. Keys that can't be meaningfully
|
|
1709
|
-
* expressed as a single inline string (e.g. a `dataTable`'s `rows`) are still
|
|
1710
|
-
* declared with `coerce: 'string'` so they aren't mis-flagged as unknown.
|
|
1711
|
-
*/
|
|
1712
|
-
/** How a raw `{[…]}` param string is coerced into a typed input value. */
|
|
1713
|
-
type InputCoercion = 'string' | 'number' | 'boolean' | 'latLng' | 'labeledPair' | 'stringList';
|
|
1714
|
-
/**
|
|
1715
|
-
* Editor/validator-facing description of a single template input key: what it
|
|
1716
|
-
* does, how to coerce its raw string, and either its closed set of valid
|
|
1717
|
-
* values or a free-form format hint. `values`/`valueHint` are mutually
|
|
1718
|
-
* exclusive (a key has a closed enum OR a hint, not both).
|
|
1719
|
-
*/
|
|
1720
|
-
interface TemplateInputDescriptor {
|
|
1721
|
-
/** The `{[name key=…]}` param key, matching the template input interface. */
|
|
1722
|
-
key: string;
|
|
1723
|
-
/** One-line description of the input. */
|
|
1724
|
-
description: string;
|
|
1725
|
-
/** Coercion strategy for the raw string (default `'string'`). */
|
|
1726
|
-
coerce?: InputCoercion;
|
|
1727
|
-
/** Closed set of valid values, for keys backed by an enum. */
|
|
1728
|
-
values?: readonly string[];
|
|
1729
|
-
/** Format hint shown when the value is free-form (no closed set). */
|
|
1730
|
-
valueHint?: string;
|
|
1731
|
-
/** When true, the validator warns if the key is absent and can't be derived. */
|
|
1732
|
-
required?: boolean;
|
|
1733
|
-
}
|
|
1734
|
-
/** A single lint finding produced by {@link lintTemplateParams}. */
|
|
1735
|
-
interface TemplateParamFinding {
|
|
1736
|
-
kind: 'unknown-input' | 'invalid-input-value' | 'missing-input';
|
|
1737
|
-
key: string;
|
|
1738
|
-
message: string;
|
|
1739
|
-
/** Did-you-mean candidate (for `unknown-input`). */
|
|
1740
|
-
suggestion?: string;
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Inputs shared by every template via `BaseTemplateBlock`. Merged into each
|
|
1744
|
-
* template's known-key set for coercion + lint. Block-level timing/geometry
|
|
1745
|
-
* keys (`duration`, `x`, `y`, …) are NOT here — those stay owned by the
|
|
1746
|
-
* block-meta registry (`KNOWN_BLOCK_META_KEYS`) and are folded into the lint
|
|
1747
|
-
* known-key set separately.
|
|
1748
|
-
*/
|
|
1749
|
-
declare const BASE_INPUT_DESCRIPTORS: readonly TemplateInputDescriptor[];
|
|
1750
|
-
/**
|
|
1751
|
-
* Per-template input descriptors, keyed by canonical template id. A template
|
|
1752
|
-
* absent from this map has no descriptors and is exempt from lint (custom
|
|
1753
|
-
* templates and not-yet-described built-ins).
|
|
1754
|
-
*/
|
|
1755
|
-
declare const TEMPLATE_INPUT_DESCRIPTORS: Readonly<Record<string, readonly TemplateInputDescriptor[]>>;
|
|
1756
|
-
/**
|
|
1757
|
-
* Coerce a flat `{[…]}` param map into a partial typed template input.
|
|
1758
|
-
*
|
|
1759
|
-
* Known descriptor keys are coerced per their `coerce` strategy; unknown keys
|
|
1760
|
-
* (and `string`-typed keys) pass through unchanged. A coercion failure leaves
|
|
1761
|
-
* the raw string in place and adds a human-readable `warnings` entry — the
|
|
1762
|
-
* output is never lossy. Returns a fresh object; the caller must NOT feed
|
|
1763
|
-
* `templateOverrides` back in — only the ephemeral merged input is coerced.
|
|
1764
|
-
*/
|
|
1765
|
-
declare function coerceTemplateParams(template: string | undefined, params: Record<string, string>): {
|
|
1766
|
-
input: Record<string, unknown>;
|
|
1767
|
-
warnings: string[];
|
|
1768
|
-
};
|
|
1769
|
-
/**
|
|
1770
|
-
* Lint a template's `{[…]}` params against its descriptors. Returns findings
|
|
1771
|
-
* for unknown keys, values outside a closed enum / that fail coercion, and
|
|
1772
|
-
* missing required inputs. Templates without descriptors (custom or
|
|
1773
|
-
* not-yet-described built-ins) return `[]`.
|
|
1774
|
-
*/
|
|
1775
|
-
declare function lintTemplateParams(template: string, params: Record<string, string>): TemplateParamFinding[];
|
|
1776
|
-
|
|
1777
|
-
export { type AccentLayout, type AudioSegmentTiming, BASE_INPUT_DESCRIPTORS, CONTAINER_TEMPLATES, type ClipBox, type ConnectorRouting, 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, normalizeShapeKind, parseDataFence, parseYamlSubset, photoGrid, pullQuote, quoteBlock, readCustomTemplatesFromFrontmatter, readCustomThemesFromFrontmatter, replaceDataFence, resolveAudioMapping, resolveColorScheme, resolvePersistentLayers, resolveTemplateName, resolveThemeForDoc, rightFeature, scaleAnimationDuration, scoreTextSimilarity, sectionHeader, shapePath, shouldUseShadow, statHighlight, templateRegistry, themeWantsAmbientMotion, themedEntrance, themedFontSize, themedImageTreatment, themedScrim, themedSurfaceGradient, titleBlock, twoColumn, validateMarkdownDoc, validateMarkdownSource, videoPullQuote, videoWithCaption, wrapWithPersistentLayers, writeCustomTemplatesToFrontmatter, writeCustomThemesToFrontmatter };
|