@bendyline/squisq 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +24 -0
  3. package/dist/{ContentContainer-BXUlIf18.d.ts → ContentContainer-B2w9sUoL.d.ts} +15 -0
  4. package/dist/{Doc-ylqWKDc_.d.ts → Doc-BubIpWsp.d.ts} +160 -3
  5. package/dist/{ImageEditDoc-D828IXJ1.d.ts → ImageEditDoc-CGxk5CHc.d.ts} +1 -1
  6. package/dist/{annotationCoercion-Dr_DY9Hx.d.ts → annotationCoercion-PtRQhk5V.d.ts} +1 -1
  7. package/dist/chunk-2L55443L.js +0 -0
  8. package/dist/chunk-2ZWIXGAC.js +214 -0
  9. package/dist/{chunk-2PWOO4ZE.js → chunk-32R2RZAO.js} +72 -3
  10. package/dist/chunk-3IGPAPQ7.js +645 -0
  11. package/dist/{chunk-QE7TWGVT.js → chunk-4VOD55SX.js} +0 -1
  12. package/dist/{chunk-3E5F2XMR.js → chunk-67L6WRJN.js} +0 -1
  13. package/dist/{chunk-5DKBFXPY.js → chunk-6ECMNUIP.js} +26 -18
  14. package/dist/{chunk-X6DUONGT.js → chunk-7ARJZYQY.js} +280 -128
  15. package/dist/{chunk-DBS6RIFL.js → chunk-7N4G32LG.js} +0 -1
  16. package/dist/{chunk-JOQYPRDZ.js → chunk-7YEZFHLS.js} +10 -8
  17. package/dist/{chunk-2UQOHYE2.js → chunk-7ZAAICW4.js} +0 -1
  18. package/dist/{chunk-66QO7XFB.js → chunk-ACZOVWX3.js} +117 -7
  19. package/dist/{chunk-5J4HKRJF.js → chunk-BAOV476U.js} +0 -1
  20. package/dist/chunk-BCCXTMN5.js +699 -0
  21. package/dist/{chunk-W4O2TX5I.js → chunk-C33GTPUZ.js} +579 -4
  22. package/dist/{chunk-MMPBOUK7.js → chunk-CB45YGAM.js} +7 -2
  23. package/dist/{chunk-CY2R2VPR.js → chunk-DYPMOPIW.js} +18 -2
  24. package/dist/{chunk-VR7UPJ7C.js → chunk-FCG3BIZN.js} +12 -1
  25. package/dist/{chunk-5UYI3RJB.js → chunk-FDYDYL77.js} +54 -40
  26. package/dist/{chunk-TFJVXUHH.js → chunk-I2O6W7DX.js} +1513 -79
  27. package/dist/{chunk-Q7LROV2H.js → chunk-NKNMGIIN.js} +0 -1
  28. package/dist/chunk-OPO5K4DZ.js +241 -0
  29. package/dist/{chunk-TUWMK62B.js → chunk-PUS54YU6.js} +45 -2
  30. package/dist/chunk-QKPXHDLR.js +0 -0
  31. package/dist/{chunk-GZY66SDN.js → chunk-R3KTTOMS.js} +0 -1
  32. package/dist/{chunk-PXLVXTLW.js → chunk-RS5AP3J4.js} +72 -15
  33. package/dist/chunk-WV5ARNDA.js +0 -0
  34. package/dist/{chunk-4X3JQXNM.js → chunk-XOFT65EX.js} +1 -2
  35. package/dist/{chunk-FVTQSNR7.js → chunk-XRW6P7IF.js} +13 -5
  36. package/dist/chunk-XWNNA3KE.js +0 -0
  37. package/dist/chunk-YZNGMV3G.js +0 -0
  38. package/dist/{chunk-R2YZTCLO.js → chunk-ZQKZSJAX.js} +1 -2
  39. package/dist/doc/index.d.ts +166 -12
  40. package/dist/doc/index.js +36 -17
  41. package/dist/generate/index.d.ts +2 -2
  42. package/dist/generate/index.js +2 -3
  43. package/dist/icons/index.js +3 -4
  44. package/dist/icons/inlineIconMarker.js +1 -2
  45. package/dist/imageEdit/index.d.ts +48 -17
  46. package/dist/imageEdit/index.js +3 -4
  47. package/dist/index.d.ts +13 -12
  48. package/dist/index.js +118 -33
  49. package/dist/jsonForm/index.d.ts +10 -3
  50. package/dist/jsonForm/index.js +8 -7
  51. package/dist/markdown/index.d.ts +75 -11
  52. package/dist/markdown/index.js +32 -7
  53. package/dist/materializePageSection-wSLA2A1g.d.ts +223 -0
  54. package/dist/narration/index.d.ts +16 -3
  55. package/dist/narration/index.js +13 -14
  56. package/dist/random/index.d.ts +11 -2
  57. package/dist/random/index.js +2 -3
  58. package/dist/recommend/index.d.ts +1 -1
  59. package/dist/recommend/index.js +3 -4
  60. package/dist/schemas/index.d.ts +31 -6
  61. package/dist/schemas/index.js +43 -6
  62. package/dist/spatial/index.d.ts +2 -1
  63. package/dist/spatial/index.js +1 -2
  64. package/dist/storage/index.d.ts +4 -2
  65. package/dist/storage/index.js +1 -2
  66. package/dist/{themeLibrary-RjVgLpUi.d.ts → themeLibrary-DU9mUmVl.d.ts} +1 -1
  67. package/dist/timing/index.js +3 -4
  68. package/dist/transform/index.d.ts +9 -10
  69. package/dist/transform/index.js +6 -7
  70. package/dist/{types-C4kiRn_k.d.ts → types-8QjefM9J.d.ts} +38 -2
  71. package/dist/{types-BwMPl2CB.d.ts → types-CUNc9biN.d.ts} +24 -1
  72. package/dist/versions/index.d.ts +14 -11
  73. package/dist/versions/index.js +2 -3
  74. package/package.json +4 -2
  75. package/dist/chunk-2PWOO4ZE.js.map +0 -1
  76. package/dist/chunk-2UQOHYE2.js.map +0 -1
  77. package/dist/chunk-3E5F2XMR.js.map +0 -1
  78. package/dist/chunk-4X3JQXNM.js.map +0 -1
  79. package/dist/chunk-5DKBFXPY.js.map +0 -1
  80. package/dist/chunk-5J4HKRJF.js.map +0 -1
  81. package/dist/chunk-5UYI3RJB.js.map +0 -1
  82. package/dist/chunk-66QO7XFB.js.map +0 -1
  83. package/dist/chunk-AMIR72JP.js +0 -380
  84. package/dist/chunk-AMIR72JP.js.map +0 -1
  85. package/dist/chunk-CY2R2VPR.js.map +0 -1
  86. package/dist/chunk-DBS6RIFL.js.map +0 -1
  87. package/dist/chunk-DNJKBAI7.js +0 -1
  88. package/dist/chunk-DNJKBAI7.js.map +0 -1
  89. package/dist/chunk-ET53IIEP.js +0 -1
  90. package/dist/chunk-ET53IIEP.js.map +0 -1
  91. package/dist/chunk-FVJUUTEM.js +0 -74
  92. package/dist/chunk-FVJUUTEM.js.map +0 -1
  93. package/dist/chunk-FVTQSNR7.js.map +0 -1
  94. package/dist/chunk-GZY66SDN.js.map +0 -1
  95. package/dist/chunk-JOQYPRDZ.js.map +0 -1
  96. package/dist/chunk-MMPBOUK7.js.map +0 -1
  97. package/dist/chunk-PGGGKYWG.js +0 -1
  98. package/dist/chunk-PGGGKYWG.js.map +0 -1
  99. package/dist/chunk-PXLVXTLW.js.map +0 -1
  100. package/dist/chunk-Q7LROV2H.js.map +0 -1
  101. package/dist/chunk-QE7TWGVT.js.map +0 -1
  102. package/dist/chunk-R2GC6RLD.js +0 -344
  103. package/dist/chunk-R2GC6RLD.js.map +0 -1
  104. package/dist/chunk-R2YZTCLO.js.map +0 -1
  105. package/dist/chunk-S7A5D7ZJ.js +0 -174
  106. package/dist/chunk-S7A5D7ZJ.js.map +0 -1
  107. package/dist/chunk-TFJVXUHH.js.map +0 -1
  108. package/dist/chunk-TUWMK62B.js.map +0 -1
  109. package/dist/chunk-V543AI2F.js +0 -1
  110. package/dist/chunk-V543AI2F.js.map +0 -1
  111. package/dist/chunk-VR7UPJ7C.js.map +0 -1
  112. package/dist/chunk-W4O2TX5I.js.map +0 -1
  113. package/dist/chunk-X6DUONGT.js.map +0 -1
  114. package/dist/chunk-ZLQKNOZQ.js +0 -1
  115. package/dist/chunk-ZLQKNOZQ.js.map +0 -1
  116. package/dist/doc/index.js.map +0 -1
  117. package/dist/generate/index.js.map +0 -1
  118. package/dist/icons/index.js.map +0 -1
  119. package/dist/icons/inlineIconMarker.js.map +0 -1
  120. package/dist/imageEdit/index.js.map +0 -1
  121. package/dist/index.js.map +0 -1
  122. package/dist/jsonForm/index.js.map +0 -1
  123. package/dist/markdown/index.js.map +0 -1
  124. package/dist/narration/index.js.map +0 -1
  125. package/dist/random/index.js.map +0 -1
  126. package/dist/recommend/index.js.map +0 -1
  127. package/dist/schemas/index.js.map +0 -1
  128. package/dist/spatial/index.js.map +0 -1
  129. package/dist/storage/index.js.map +0 -1
  130. package/dist/timing/index.js.map +0 -1
  131. package/dist/transform/index.js.map +0 -1
  132. package/dist/versions/index.js.map +0 -1
  133. package/src/__tests__/animationUtils.test.ts +0 -117
  134. package/src/__tests__/annotationCoercion.test.ts +0 -243
  135. package/src/__tests__/applyNarrationTiming.test.ts +0 -190
  136. package/src/__tests__/applyRenderStyle.test.ts +0 -146
  137. package/src/__tests__/asciiDiagramBattle.test.ts +0 -246
  138. package/src/__tests__/asciiDiagramDetect.test.ts +0 -162
  139. package/src/__tests__/asciiDiagramMapping.test.ts +0 -38
  140. package/src/__tests__/asciiDiagramParse.test.ts +0 -233
  141. package/src/__tests__/asciiDiagramPipeline.test.ts +0 -273
  142. package/src/__tests__/asciiDiagramRender.test.ts +0 -162
  143. package/src/__tests__/asciiDiagramRepair.test.ts +0 -84
  144. package/src/__tests__/asciiTimelineDetect.test.ts +0 -157
  145. package/src/__tests__/asciiTimelineParse.test.ts +0 -205
  146. package/src/__tests__/asciiTimelinePipeline.test.ts +0 -349
  147. package/src/__tests__/asciiTimelineRender.test.ts +0 -376
  148. package/src/__tests__/atmosphereLayers.test.ts +0 -108
  149. package/src/__tests__/attrTokens.test.ts +0 -167
  150. package/src/__tests__/colorUtils.test.ts +0 -112
  151. package/src/__tests__/contentContainer.test.ts +0 -325
  152. package/src/__tests__/contentExtractor.test.ts +0 -243
  153. package/src/__tests__/coverBlock.test.ts +0 -310
  154. package/src/__tests__/customTemplateSample.test.ts +0 -144
  155. package/src/__tests__/customTemplatesFrontmatter.test.ts +0 -221
  156. package/src/__tests__/customThemesFrontmatter.test.ts +0 -146
  157. package/src/__tests__/dataTable.test.ts +0 -145
  158. package/src/__tests__/diagramBlock.test.ts +0 -122
  159. package/src/__tests__/diagramLayout.test.ts +0 -134
  160. package/src/__tests__/diagramText.test.ts +0 -26
  161. package/src/__tests__/docToMarkdownMedia.test.ts +0 -83
  162. package/src/__tests__/drawing.test.ts +0 -109
  163. package/src/__tests__/drawingBlock.test.ts +0 -124
  164. package/src/__tests__/drawingLayout.test.ts +0 -171
  165. package/src/__tests__/fixtures/asciiDiagramBattle.ts +0 -512
  166. package/src/__tests__/fixtures/asciiDiagrams.ts +0 -287
  167. package/src/__tests__/fixtures/asciiTimelines.ts +0 -35
  168. package/src/__tests__/fixtures/treeviewFixtures.ts +0 -243
  169. package/src/__tests__/geohash.test.ts +0 -110
  170. package/src/__tests__/getLayers.test.ts +0 -243
  171. package/src/__tests__/getLayersFallback.test.ts +0 -103
  172. package/src/__tests__/haversine.test.ts +0 -63
  173. package/src/__tests__/iconResolve.test.ts +0 -122
  174. package/src/__tests__/imageEditExportSvg.test.ts +0 -70
  175. package/src/__tests__/imageEditState.test.ts +0 -74
  176. package/src/__tests__/imageEditVersions.test.ts +0 -243
  177. package/src/__tests__/inferDocumentTitle.test.ts +0 -50
  178. package/src/__tests__/inlineIconMarker.test.ts +0 -36
  179. package/src/__tests__/inputDescriptors.test.ts +0 -162
  180. package/src/__tests__/jsonForm.chooseControl.test.ts +0 -86
  181. package/src/__tests__/jsonForm.evaluateWhen.test.ts +0 -59
  182. package/src/__tests__/jsonForm.inferSchema.test.ts +0 -25
  183. package/src/__tests__/jsonForm.pointer.test.ts +0 -149
  184. package/src/__tests__/jsonForm.tokens.test.ts +0 -84
  185. package/src/__tests__/layoutBlock.test.ts +0 -83
  186. package/src/__tests__/layoutLayout.test.ts +0 -169
  187. package/src/__tests__/localForageAdapter.test.ts +0 -155
  188. package/src/__tests__/majorApiTypes.test.ts +0 -18
  189. package/src/__tests__/markdown.test.ts +0 -1009
  190. package/src/__tests__/markdownIcons.test.ts +0 -104
  191. package/src/__tests__/markdownSanitize.test.ts +0 -81
  192. package/src/__tests__/markdownToDoc.test.ts +0 -957
  193. package/src/__tests__/matchFontFamily.test.ts +0 -114
  194. package/src/__tests__/materializeBlockLayers.test.ts +0 -135
  195. package/src/__tests__/materializeTestUtils.ts +0 -17
  196. package/src/__tests__/mediaAnnotations.test.ts +0 -91
  197. package/src/__tests__/mediaSchedule.test.ts +0 -118
  198. package/src/__tests__/narrationAlign.test.ts +0 -150
  199. package/src/__tests__/narrationFeatures.test.ts +0 -71
  200. package/src/__tests__/narrationNuclei.test.ts +0 -45
  201. package/src/__tests__/narrationPacing.test.ts +0 -189
  202. package/src/__tests__/narrationScript.test.ts +0 -149
  203. package/src/__tests__/narrationSessionRepro.test.ts +0 -62
  204. package/src/__tests__/narrationSidecar.test.ts +0 -88
  205. package/src/__tests__/narrationSyllables.test.ts +0 -65
  206. package/src/__tests__/narrationTestSignals.ts +0 -167
  207. package/src/__tests__/narrationVad.test.ts +0 -66
  208. package/src/__tests__/pandocAttrParse.test.ts +0 -187
  209. package/src/__tests__/recommendTemplates.test.ts +0 -183
  210. package/src/__tests__/resolveDocTheme.test.ts +0 -69
  211. package/src/__tests__/rootExports.test.ts +0 -61
  212. package/src/__tests__/scopedContentContainer.test.ts +0 -109
  213. package/src/__tests__/seededRandom.test.ts +0 -142
  214. package/src/__tests__/shapeGeometry.test.ts +0 -138
  215. package/src/__tests__/shapeVocabulary.test.ts +0 -133
  216. package/src/__tests__/storage.test.ts +0 -60
  217. package/src/__tests__/structuredData.test.ts +0 -249
  218. package/src/__tests__/surface.test.ts +0 -68
  219. package/src/__tests__/templateAnnotationParse.test.ts +0 -160
  220. package/src/__tests__/templateInputs.test.ts +0 -69
  221. package/src/__tests__/templateMetadata.test.ts +0 -32
  222. package/src/__tests__/templates.test.ts +0 -710
  223. package/src/__tests__/themeCompile.test.ts +0 -225
  224. package/src/__tests__/themeValidator.test.ts +0 -131
  225. package/src/__tests__/timing.test.ts +0 -167
  226. package/src/__tests__/transformProvenance.test.ts +0 -160
  227. package/src/__tests__/transformV2.test.ts +0 -163
  228. package/src/__tests__/transitionNormalize.test.ts +0 -61
  229. package/src/__tests__/treeviewBattle.test.ts +0 -76
  230. package/src/__tests__/treeviewDetect.test.ts +0 -168
  231. package/src/__tests__/treeviewParse.test.ts +0 -118
  232. package/src/__tests__/treeviewPipeline.test.ts +0 -183
  233. package/src/__tests__/treeviewRender.test.ts +0 -91
  234. package/src/__tests__/validateDoc.test.ts +0 -260
  235. package/src/__tests__/versions.test.ts +0 -459
  236. package/src/doc/annotationBlocks.ts +0 -117
  237. package/src/doc/applyNarrationTiming.ts +0 -244
  238. package/src/doc/asciiDiagram/chars.ts +0 -210
  239. package/src/doc/asciiDiagram/detect.ts +0 -175
  240. package/src/doc/asciiDiagram/index.ts +0 -38
  241. package/src/doc/asciiDiagram/mapping.ts +0 -225
  242. package/src/doc/asciiDiagram/parse.ts +0 -1095
  243. package/src/doc/asciiDiagram/render.ts +0 -963
  244. package/src/doc/asciiDiagram/repair.ts +0 -400
  245. package/src/doc/asciiDiagram/types.ts +0 -65
  246. package/src/doc/asciiTimeline/detect.ts +0 -138
  247. package/src/doc/asciiTimeline/index.ts +0 -26
  248. package/src/doc/asciiTimeline/mapping.ts +0 -43
  249. package/src/doc/asciiTimeline/parse.ts +0 -870
  250. package/src/doc/asciiTimeline/render.ts +0 -427
  251. package/src/doc/asciiTimeline/types.ts +0 -73
  252. package/src/doc/asciiTimeline/wrappedFlow.ts +0 -427
  253. package/src/doc/audioMapping.ts +0 -442
  254. package/src/doc/customTemplatesFrontmatter.ts +0 -273
  255. package/src/doc/customThemesFrontmatter.ts +0 -95
  256. package/src/doc/docToMarkdown.ts +0 -284
  257. package/src/doc/index.ts +0 -127
  258. package/src/doc/markdownToDoc.ts +0 -1054
  259. package/src/doc/materializeBlockLayers.ts +0 -304
  260. package/src/doc/mediaAnnotations.ts +0 -120
  261. package/src/doc/resolveDocTheme.ts +0 -56
  262. package/src/doc/standaloneAnnotation.ts +0 -58
  263. package/src/doc/structuredData.ts +0 -301
  264. package/src/doc/templateInputs.ts +0 -423
  265. package/src/doc/templates/__tests__/customTemplate.test.ts +0 -170
  266. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +0 -124
  267. package/src/doc/templates/__tests__/listBlock.test.ts +0 -64
  268. package/src/doc/templates/accentImage.ts +0 -362
  269. package/src/doc/templates/captionUtils.ts +0 -56
  270. package/src/doc/templates/comparisonBar.ts +0 -173
  271. package/src/doc/templates/coverBlock.ts +0 -255
  272. package/src/doc/templates/customTemplate.ts +0 -51
  273. package/src/doc/templates/dataTable.ts +0 -102
  274. package/src/doc/templates/dateEvent.ts +0 -147
  275. package/src/doc/templates/definitionCard.ts +0 -140
  276. package/src/doc/templates/diagramBlock.ts +0 -403
  277. package/src/doc/templates/diagramLayout.ts +0 -159
  278. package/src/doc/templates/drawingBlock.ts +0 -325
  279. package/src/doc/templates/drawingLayout.ts +0 -539
  280. package/src/doc/templates/factCard.ts +0 -146
  281. package/src/doc/templates/fallbackBlock.ts +0 -123
  282. package/src/doc/templates/featureBlock.ts +0 -209
  283. package/src/doc/templates/fullBleedQuote.ts +0 -83
  284. package/src/doc/templates/imageWithCaption.ts +0 -186
  285. package/src/doc/templates/index.ts +0 -642
  286. package/src/doc/templates/inputDescriptors.ts +0 -451
  287. package/src/doc/templates/layoutBlock.ts +0 -43
  288. package/src/doc/templates/layoutLayout.ts +0 -243
  289. package/src/doc/templates/listBlock.ts +0 -207
  290. package/src/doc/templates/mapBlock.ts +0 -138
  291. package/src/doc/templates/metadata.ts +0 -130
  292. package/src/doc/templates/persistentLayers.ts +0 -526
  293. package/src/doc/templates/photoGrid.ts +0 -190
  294. package/src/doc/templates/pullQuote.ts +0 -141
  295. package/src/doc/templates/quoteBlock.ts +0 -141
  296. package/src/doc/templates/registry.ts +0 -88
  297. package/src/doc/templates/sectionHeader.ts +0 -120
  298. package/src/doc/templates/statHighlight.ts +0 -146
  299. package/src/doc/templates/templateNames.ts +0 -22
  300. package/src/doc/templates/timelineBlock.ts +0 -613
  301. package/src/doc/templates/titleBlock.ts +0 -150
  302. package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +0 -487
  303. package/src/doc/templates/tokens/resolveTokens.ts +0 -453
  304. package/src/doc/templates/treeBlock.ts +0 -131
  305. package/src/doc/templates/twoColumn.ts +0 -263
  306. package/src/doc/templates/videoPullQuote.ts +0 -142
  307. package/src/doc/templates/videoWithCaption.ts +0 -135
  308. package/src/doc/treeview/chars.ts +0 -72
  309. package/src/doc/treeview/detect.ts +0 -145
  310. package/src/doc/treeview/index.ts +0 -30
  311. package/src/doc/treeview/mapping.ts +0 -95
  312. package/src/doc/treeview/parse.ts +0 -201
  313. package/src/doc/treeview/render.ts +0 -41
  314. package/src/doc/treeview/types.ts +0 -43
  315. package/src/doc/utils/animationUtils.ts +0 -399
  316. package/src/doc/utils/applyRenderStyle.ts +0 -106
  317. package/src/doc/utils/diagramText.ts +0 -78
  318. package/src/doc/utils/imageTreatment.ts +0 -70
  319. package/src/doc/utils/nearest.ts +0 -59
  320. package/src/doc/utils/shapeGeometry.ts +0 -614
  321. package/src/doc/utils/themeUtils.ts +0 -243
  322. package/src/doc/validate.ts +0 -575
  323. package/src/generate/contentExtractor.ts +0 -921
  324. package/src/generate/index.ts +0 -18
  325. package/src/generate/templateMapper.ts +0 -177
  326. package/src/icons/iconData.ts +0 -31
  327. package/src/icons/index.ts +0 -26
  328. package/src/icons/inlineIconMarker.ts +0 -73
  329. package/src/icons/resolve.ts +0 -139
  330. package/src/imageEdit/ImageEditVersionManager.ts +0 -73
  331. package/src/imageEdit/export.ts +0 -410
  332. package/src/imageEdit/index.ts +0 -72
  333. package/src/imageEdit/persistence.ts +0 -113
  334. package/src/imageEdit/state.ts +0 -112
  335. package/src/imageEdit/versionPaths.ts +0 -44
  336. package/src/imageEdit/versions.ts +0 -152
  337. package/src/index.ts +0 -15
  338. package/src/internal/immutable.ts +0 -58
  339. package/src/jsonForm/chooseControl.ts +0 -88
  340. package/src/jsonForm/evaluateWhen.ts +0 -59
  341. package/src/jsonForm/index.ts +0 -32
  342. package/src/jsonForm/inferSchema.ts +0 -25
  343. package/src/jsonForm/pointer.ts +0 -154
  344. package/src/jsonForm/tokens.ts +0 -78
  345. package/src/jsonForm/types.ts +0 -167
  346. package/src/markdown/annotationCoercion.ts +0 -295
  347. package/src/markdown/attrTokens.ts +0 -243
  348. package/src/markdown/convert.ts +0 -1353
  349. package/src/markdown/htmlParse.ts +0 -212
  350. package/src/markdown/index.ts +0 -152
  351. package/src/markdown/parse.ts +0 -103
  352. package/src/markdown/sanitize.ts +0 -318
  353. package/src/markdown/stringify.ts +0 -207
  354. package/src/markdown/types.ts +0 -710
  355. package/src/markdown/utils.ts +0 -459
  356. package/src/narration/align.ts +0 -514
  357. package/src/narration/features.ts +0 -231
  358. package/src/narration/index.ts +0 -86
  359. package/src/narration/nuclei.ts +0 -118
  360. package/src/narration/pacing.ts +0 -211
  361. package/src/narration/script.ts +0 -239
  362. package/src/narration/session.ts +0 -100
  363. package/src/narration/sidecar.ts +0 -187
  364. package/src/narration/syllables.ts +0 -85
  365. package/src/narration/trace.ts +0 -50
  366. package/src/narration/types.ts +0 -299
  367. package/src/narration/vad.ts +0 -131
  368. package/src/ngeohash.d.ts +0 -11
  369. package/src/random/SeededRandom.ts +0 -127
  370. package/src/random/index.ts +0 -1
  371. package/src/recommend/index.ts +0 -16
  372. package/src/recommend/numberHighlight.ts +0 -25
  373. package/src/recommend/templates.ts +0 -393
  374. package/src/schemas/BlockTemplates.ts +0 -1046
  375. package/src/schemas/CustomTemplates.ts +0 -126
  376. package/src/schemas/Doc.ts +0 -1052
  377. package/src/schemas/ImageEditDoc.ts +0 -102
  378. package/src/schemas/LayoutStrategy.ts +0 -178
  379. package/src/schemas/Media.ts +0 -179
  380. package/src/schemas/MediaProvider.ts +0 -70
  381. package/src/schemas/Theme.ts +0 -406
  382. package/src/schemas/Transitions.ts +0 -224
  383. package/src/schemas/Types.ts +0 -15
  384. package/src/schemas/Viewport.ts +0 -91
  385. package/src/schemas/colorUtils.ts +0 -219
  386. package/src/schemas/fontStacks.ts +0 -339
  387. package/src/schemas/index.ts +0 -29
  388. package/src/schemas/themeCompile.ts +0 -237
  389. package/src/schemas/themeConstants.ts +0 -2
  390. package/src/schemas/themeLibrary.ts +0 -60
  391. package/src/schemas/themeValidator.ts +0 -426
  392. package/src/schemas/themes/bold.json +0 -48
  393. package/src/schemas/themes/cinematic.json +0 -111
  394. package/src/schemas/themes/documentary.json +0 -96
  395. package/src/schemas/themes/gezellig.json +0 -93
  396. package/src/schemas/themes/index.ts +0 -53
  397. package/src/schemas/themes/magazine.json +0 -89
  398. package/src/schemas/themes/minimalist.json +0 -45
  399. package/src/schemas/themes/morning-light.json +0 -85
  400. package/src/schemas/themes/standard-dark.json +0 -85
  401. package/src/schemas/themes/standard.json +0 -74
  402. package/src/schemas/themes/tech-dark.json +0 -101
  403. package/src/schemas/themes/warm-earth.json +0 -50
  404. package/src/spatial/Geohash.ts +0 -196
  405. package/src/spatial/Haversine.ts +0 -59
  406. package/src/spatial/index.ts +0 -2
  407. package/src/storage/ContentContainer.ts +0 -220
  408. package/src/storage/LocalForageAdapter.ts +0 -103
  409. package/src/storage/LocalStorageAdapter.ts +0 -57
  410. package/src/storage/MediaProviderFromContainer.ts +0 -92
  411. package/src/storage/MemoryStorageAdapter.ts +0 -37
  412. package/src/storage/ScopedContentContainer.ts +0 -143
  413. package/src/storage/Storage.ts +0 -28
  414. package/src/storage/index.ts +0 -9
  415. package/src/timing/index.ts +0 -17
  416. package/src/timing/narrationTiming.ts +0 -220
  417. package/src/timing/readingTime.ts +0 -94
  418. package/src/transform/applyTransform.ts +0 -122
  419. package/src/transform/blockAnalyzer.ts +0 -181
  420. package/src/transform/index.ts +0 -23
  421. package/src/transform/registry.ts +0 -198
  422. package/src/transform/styles/dataDriven.ts +0 -17
  423. package/src/transform/styles/documentary.ts +0 -17
  424. package/src/transform/styles/index.ts +0 -5
  425. package/src/transform/styles/magazine.ts +0 -18
  426. package/src/transform/styles/minimal.ts +0 -17
  427. package/src/transform/styles/narrative.ts +0 -18
  428. package/src/transform/templateSelector.ts +0 -389
  429. package/src/transform/timingAllocator.ts +0 -257
  430. package/src/transform/types.ts +0 -151
  431. package/src/versions/DocumentVersionManager.ts +0 -70
  432. package/src/versions/gitignore.ts +0 -34
  433. package/src/versions/index.ts +0 -56
  434. package/src/versions/operations.ts +0 -144
  435. package/src/versions/paths.ts +0 -51
  436. package/src/versions/snapshotStore.ts +0 -202
  437. package/src/versions/timestamp.ts +0 -48
  438. package/src/versions/types.ts +0 -93
@@ -1,957 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { parseMarkdown, stringifyMarkdown } from '../markdown/index';
3
- import type { MarkdownText } from '../markdown/types';
4
- import { markdownToDoc, flattenBlocks, countBlocks, getBlockDepth } from '../doc/markdownToDoc';
5
- import { docToMarkdown } from '../doc/docToMarkdown';
6
-
7
- // Helper: parse markdown and return the first top-level block.
8
- function firstHeadingBlock(md: string) {
9
- const parsed = parseMarkdown(md);
10
- const doc = markdownToDoc(parsed, { articleId: 'test', generateCoverBlock: false });
11
- return doc.blocks[0];
12
- }
13
-
14
- // Helper: strip positions from markdown nodes for cleaner assertions
15
- function stripPositions(obj: unknown): unknown {
16
- if (obj === null || obj === undefined) return obj;
17
- if (typeof obj !== 'object') return obj;
18
- if (Array.isArray(obj)) return obj.map(stripPositions);
19
- const result: Record<string, unknown> = {};
20
- for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
21
- if (key === 'position') continue;
22
- result[key] = stripPositions(value);
23
- }
24
- return result;
25
- }
26
-
27
- describe('markdownToDoc', () => {
28
- it('converts a simple heading + paragraph into a single block', () => {
29
- const md = parseMarkdown('# Title\n\nHello world');
30
- const doc = markdownToDoc(md);
31
-
32
- expect(doc.blocks).toHaveLength(1);
33
- expect(doc.blocks[0].id).toBe('title');
34
- expect(doc.blocks[0].sourceHeading).toBeDefined();
35
- expect(doc.blocks[0].sourceHeading!.depth).toBe(1);
36
- expect(doc.blocks[0].contents).toHaveLength(1);
37
- expect(doc.blocks[0].contents![0].type).toBe('paragraph');
38
- });
39
-
40
- it('creates preamble block for content before first heading', () => {
41
- const md = parseMarkdown('Some intro text\n\n# First Heading\n\nBody');
42
- const doc = markdownToDoc(md);
43
-
44
- expect(doc.blocks).toHaveLength(2);
45
- // Preamble block
46
- expect(doc.blocks[0].id).toBe('preamble');
47
- expect(doc.blocks[0].sourceHeading).toBeUndefined();
48
- expect(doc.blocks[0].contents).toHaveLength(1);
49
- expect(doc.blocks[0].contents![0].type).toBe('paragraph');
50
- // Heading block
51
- expect(doc.blocks[1].sourceHeading).toBeDefined();
52
- expect(doc.blocks[1].contents).toHaveLength(1);
53
- });
54
-
55
- it('nests H2 under H1 as children', () => {
56
- const md = parseMarkdown(
57
- '# Chapter\n\nIntro\n\n## Section A\n\nContent A\n\n## Section B\n\nContent B',
58
- );
59
- const doc = markdownToDoc(md);
60
-
61
- expect(doc.blocks).toHaveLength(1); // One root block (H1)
62
- const root = doc.blocks[0];
63
- expect(root.sourceHeading!.depth).toBe(1);
64
- expect(root.contents).toHaveLength(1); // "Intro" paragraph
65
-
66
- expect(root.children).toHaveLength(2);
67
- expect(root.children![0].sourceHeading!.depth).toBe(2);
68
- expect(root.children![0].contents).toHaveLength(1); // "Content A"
69
- expect(root.children![1].sourceHeading!.depth).toBe(2);
70
- expect(root.children![1].contents).toHaveLength(1); // "Content B"
71
- });
72
-
73
- it('handles same-level headings as siblings', () => {
74
- const md = parseMarkdown('## A\n\nText A\n\n## B\n\nText B\n\n## C\n\nText C');
75
- const doc = markdownToDoc(md);
76
-
77
- expect(doc.blocks).toHaveLength(3);
78
- expect(doc.blocks[0].id).toBe('a');
79
- expect(doc.blocks[1].id).toBe('b');
80
- expect(doc.blocks[2].id).toBe('c');
81
- });
82
-
83
- it('handles deep nesting H1→H2→H3→H4→H5→H6', () => {
84
- const md = parseMarkdown(
85
- '# L1\n\n## L2\n\n### L3\n\n#### L4\n\n##### L5\n\n###### L6\n\nDeep content',
86
- );
87
- const doc = markdownToDoc(md);
88
-
89
- expect(doc.blocks).toHaveLength(1); // One root
90
- let block = doc.blocks[0];
91
- for (let depth = 1; depth <= 5; depth++) {
92
- expect(block.sourceHeading!.depth).toBe(depth);
93
- expect(block.children).toHaveLength(1);
94
- block = block.children![0];
95
- }
96
- expect(block.sourceHeading!.depth).toBe(6);
97
- expect(block.contents).toHaveLength(1);
98
- expect(block.children).toBeUndefined();
99
- });
100
-
101
- it('handles mixed content between headings', () => {
102
- const md = parseMarkdown(
103
- '# Title\n\nParagraph\n\n- Item 1\n- Item 2\n\n```js\ncode\n```\n\n> Quote',
104
- );
105
- const doc = markdownToDoc(md);
106
-
107
- expect(doc.blocks[0].contents).toHaveLength(4); // paragraph, list, code, blockquote
108
- expect(doc.blocks[0].contents![0].type).toBe('paragraph');
109
- expect(doc.blocks[0].contents![1].type).toBe('list');
110
- expect(doc.blocks[0].contents![2].type).toBe('code');
111
- expect(doc.blocks[0].contents![3].type).toBe('blockquote');
112
- });
113
-
114
- it('deduplicates IDs for duplicate headings', () => {
115
- const md = parseMarkdown('# Intro\n\n# Intro\n\n# Intro');
116
- const doc = markdownToDoc(md);
117
-
118
- expect(doc.blocks).toHaveLength(3);
119
- expect(doc.blocks[0].id).toBe('intro');
120
- expect(doc.blocks[1].id).toBe('intro-2');
121
- expect(doc.blocks[2].id).toBe('intro-3');
122
- });
123
-
124
- it('handles empty document', () => {
125
- const md = parseMarkdown('');
126
- const doc = markdownToDoc(md);
127
-
128
- expect(doc.blocks).toHaveLength(0);
129
- expect(doc.duration).toBe(0);
130
- });
131
-
132
- it('handles document with only content (no headings)', () => {
133
- const md = parseMarkdown('Just some text\n\nAnd more text');
134
- const doc = markdownToDoc(md);
135
-
136
- expect(doc.blocks).toHaveLength(1);
137
- expect(doc.blocks[0].id).toBe('preamble');
138
- expect(doc.blocks[0].sourceHeading).toBeUndefined();
139
- expect(doc.blocks[0].contents).toHaveLength(2);
140
- });
141
-
142
- it('sets default template on heading blocks', () => {
143
- const md = parseMarkdown('# Hello');
144
- const doc = markdownToDoc(md);
145
- expect(doc.blocks[0].template).toBe('sectionHeader');
146
- });
147
-
148
- it('respects custom options', () => {
149
- const md = parseMarkdown('# Test');
150
- const doc = markdownToDoc(md, {
151
- articleId: 'custom-article',
152
- defaultTemplate: 'title',
153
- defaultDuration: 10,
154
- });
155
-
156
- expect(doc.articleId).toBe('custom-article');
157
- expect(doc.blocks[0].template).toBe('title');
158
- expect(doc.blocks[0].duration).toBe(10);
159
- });
160
-
161
- it('respects custom ID generator', () => {
162
- const md = parseMarkdown('# Hello\n\n## World');
163
- const doc = markdownToDoc(md, {
164
- generateId: (_heading, index) => `block-${index}`,
165
- });
166
-
167
- expect(doc.blocks[0].id).toBe('block-0');
168
- expect(doc.blocks[0].children![0].id).toBe('block-1');
169
- });
170
-
171
- it('calculates timing sequentially across all blocks', () => {
172
- const md = parseMarkdown('# A\n\n## A1\n\n## A2\n\n# B');
173
- const doc = markdownToDoc(md, { defaultDuration: 5 });
174
-
175
- const flat = flattenBlocks(doc.blocks);
176
- expect(flat).toHaveLength(4);
177
- expect(flat[0].startTime).toBe(0); // # A
178
- expect(flat[1].startTime).toBe(5); // ## A1
179
- expect(flat[2].startTime).toBe(10); // ## A2
180
- expect(flat[3].startTime).toBe(15); // # B
181
- expect(doc.duration).toBe(20);
182
- });
183
-
184
- it('handles heading depth going back up (H3 → H1)', () => {
185
- const md = parseMarkdown('# Top\n\n### Deep\n\nDeep content\n\n# Back to top\n\nTop content');
186
- const doc = markdownToDoc(md);
187
-
188
- expect(doc.blocks).toHaveLength(2);
189
- expect(doc.blocks[0].sourceHeading!.depth).toBe(1);
190
- // H3 nests under H1 even though H2 was skipped
191
- expect(doc.blocks[0].children).toHaveLength(1);
192
- expect(doc.blocks[0].children![0].sourceHeading!.depth).toBe(3);
193
- expect(doc.blocks[1].sourceHeading!.depth).toBe(1);
194
- expect(doc.blocks[1].contents).toHaveLength(1);
195
- });
196
- });
197
-
198
- describe('flattenBlocks', () => {
199
- it('flattens nested blocks depth-first', () => {
200
- const md = parseMarkdown('# A\n\n## A1\n\n### A1a\n\n## A2\n\n# B');
201
- const doc = markdownToDoc(md);
202
- const flat = flattenBlocks(doc.blocks);
203
-
204
- expect(flat.map((b) => b.id)).toEqual(['a', 'a1', 'a1a', 'a2', 'b']);
205
- });
206
- });
207
-
208
- describe('countBlocks', () => {
209
- it('counts all blocks including nested children', () => {
210
- const md = parseMarkdown('# A\n\n## A1\n\n### A1a\n\n## A2\n\n# B');
211
- const doc = markdownToDoc(md);
212
-
213
- expect(countBlocks(doc.blocks)).toBe(5);
214
- });
215
- });
216
-
217
- describe('getBlockDepth', () => {
218
- it('returns heading depth for heading blocks', () => {
219
- const md = parseMarkdown('# Title');
220
- const doc = markdownToDoc(md);
221
- expect(getBlockDepth(doc.blocks[0])).toBe(1);
222
- });
223
-
224
- it('returns 0 for preamble blocks', () => {
225
- const md = parseMarkdown('Just text');
226
- const doc = markdownToDoc(md);
227
- expect(getBlockDepth(doc.blocks[0])).toBe(0);
228
- });
229
- });
230
-
231
- describe('docToMarkdown (round-trip)', () => {
232
- it('converts a doc back to equivalent markdown', () => {
233
- const input = '# Hello\n\nWorld\n\n## Details\n\nMore content\n';
234
- const md = parseMarkdown(input);
235
- const doc = markdownToDoc(md);
236
- const roundTripped = docToMarkdown(doc);
237
-
238
- // The resulting MarkdownDocument should have the same structure
239
- expect(stripPositions(roundTripped)).toEqual(stripPositions(md));
240
- });
241
-
242
- it('round-trips through stringify', () => {
243
- const input = '# Intro\n\nParagraph one.\n\n## Sub\n\nParagraph two.\n';
244
- const md = parseMarkdown(input);
245
- const doc = markdownToDoc(md);
246
- const markdown2 = docToMarkdown(doc);
247
- const output = stringifyMarkdown(markdown2);
248
- // Parse again and compare ASTs
249
- const md2 = parseMarkdown(output);
250
- expect(stripPositions(md2)).toEqual(stripPositions(md));
251
- });
252
-
253
- it('round-trips inline coerced template params, keeping overrides raw', () => {
254
- const input = '# Downtown {[map center="47.6,-122.3" zoom=9 mapStyle="road"]}\n\nSome text.\n';
255
- const md = parseMarkdown(input);
256
- const doc = markdownToDoc(md, { generateCoverBlock: false });
257
-
258
- // The overrides must stay RAW strings — coercion only ever touches the
259
- // ephemeral render input, never the stored block, so round-trips are lossless.
260
- expect(doc.blocks[0].templateOverrides).toEqual({
261
- center: '47.6,-122.3',
262
- zoom: '9',
263
- mapStyle: 'road',
264
- });
265
-
266
- // Byte-stable: one full cycle reaches a fixed point that a second cycle
267
- // reproduces exactly.
268
- const once = stringifyMarkdown(docToMarkdown(doc));
269
- const twice = stringifyMarkdown(
270
- docToMarkdown(markdownToDoc(parseMarkdown(once), { generateCoverBlock: false })),
271
- );
272
- expect(twice).toBe(once);
273
- // And the annotation with its raw values survives serialization.
274
- expect(once).toContain('center=47.6,-122.3');
275
- expect(once).toContain('zoom=9');
276
- });
277
-
278
- it('round-trips preamble content', () => {
279
- const input = 'Preamble text\n\n# Heading\n\nBody\n';
280
- const md = parseMarkdown(input);
281
- const doc = markdownToDoc(md);
282
- const roundTripped = docToMarkdown(doc);
283
- expect(stripPositions(roundTripped)).toEqual(stripPositions(md));
284
- });
285
-
286
- it('round-trips deeply nested headings', () => {
287
- const input = '# L1\n\nT1\n\n## L2\n\nT2\n\n### L3\n\nT3\n\n#### L4\n\nT4\n';
288
- const md = parseMarkdown(input);
289
- const doc = markdownToDoc(md);
290
- const roundTripped = docToMarkdown(doc);
291
- expect(stripPositions(roundTripped)).toEqual(stripPositions(md));
292
- });
293
-
294
- it('round-trips complex mixed content', () => {
295
- const input = `# Title
296
-
297
- Intro paragraph.
298
-
299
- - List item 1
300
- - List item 2
301
-
302
- ## Code Section
303
-
304
- \`\`\`js
305
- const x = 1;
306
- \`\`\`
307
-
308
- ## Quote Section
309
-
310
- > A blockquote
311
-
312
- ---
313
- `;
314
- const md = parseMarkdown(input);
315
- const doc = markdownToDoc(md);
316
- const roundTripped = docToMarkdown(doc);
317
- expect(stripPositions(roundTripped)).toEqual(stripPositions(md));
318
- });
319
-
320
- it('handles empty doc → empty markdown', () => {
321
- const md = parseMarkdown('');
322
- const doc = markdownToDoc(md);
323
- const roundTripped = docToMarkdown(doc);
324
- expect(roundTripped.children).toEqual([]);
325
- });
326
- });
327
-
328
- // ============================================
329
- // Template Annotation → Block mapping
330
- // ============================================
331
-
332
- describe('template annotation in markdownToDoc', () => {
333
- it('sets block.template from heading annotation', () => {
334
- const md = parseMarkdown('## Report {[chart]}\n\nSome data');
335
- const doc = markdownToDoc(md);
336
-
337
- expect(doc.blocks).toHaveLength(1);
338
- expect(doc.blocks[0].template).toBe('chart');
339
- });
340
-
341
- it('sets block.templateOverrides from key=value params', () => {
342
- const md = parseMarkdown('## Stats {[statHighlight colorScheme=blue size=large]}\n\nContent');
343
- const doc = markdownToDoc(md);
344
-
345
- expect(doc.blocks[0].template).toBe('statHighlight');
346
- expect(doc.blocks[0].templateOverrides).toEqual({
347
- colorScheme: 'blue',
348
- size: 'large',
349
- });
350
- });
351
-
352
- it('uses defaultTemplate when no annotation is present', () => {
353
- const md = parseMarkdown('## Plain Heading\n\nBody');
354
- const doc = markdownToDoc(md);
355
-
356
- expect(doc.blocks[0].template).toBe('sectionHeader');
357
- expect(doc.blocks[0].templateOverrides).toBeUndefined();
358
- });
359
-
360
- it('annotation stripping does not affect heading display text in sourceHeading', () => {
361
- const md = parseMarkdown('## My Section {[chart]}\n\nBody');
362
- const doc = markdownToDoc(md);
363
- const heading = doc.blocks[0].sourceHeading!;
364
-
365
- // The heading children should have the annotation stripped
366
- expect(heading.templateAnnotation).toEqual({ template: 'chart' });
367
- const textChild = heading.children.find((c) => c.type === 'text') as MarkdownText;
368
- expect(textChild.value).toBe('My Section');
369
- });
370
-
371
- it('round-trips annotation through markdownToDoc → docToMarkdown → stringify', () => {
372
- const input = '## Data {[chart colorScheme=blue]}\n\nContent here';
373
- const md = parseMarkdown(input);
374
- const doc = markdownToDoc(md);
375
- const roundTripped = docToMarkdown(doc);
376
- const output = stringifyMarkdown(roundTripped);
377
-
378
- expect(output).toContain('{[chart colorScheme=blue]}');
379
- expect(output).toContain('Data');
380
- });
381
-
382
- it('docToMarkdown injects annotation when block.template differs from default', () => {
383
- // Create a doc programmatically with a non-default template
384
- const md = parseMarkdown('## Section\n\nBody');
385
- const doc = markdownToDoc(md);
386
-
387
- // Programmatically set a custom template
388
- doc.blocks[0].template = 'factCard';
389
- doc.blocks[0].templateOverrides = { style: 'minimal' };
390
-
391
- const roundTripped = docToMarkdown(doc);
392
- const output = stringifyMarkdown(roundTripped);
393
-
394
- expect(output).toContain('{[factCard style=minimal]}');
395
- });
396
-
397
- it('docToMarkdown injects transition params into the squiggly annotation', () => {
398
- const md = parseMarkdown('## Section\n\nBody');
399
- const doc = markdownToDoc(md);
400
- doc.blocks[0].transition = { type: 'wipe', duration: 0.8, direction: 'left' };
401
-
402
- const output = stringifyMarkdown(docToMarkdown(doc));
403
-
404
- expect(output).toContain('{[transition=wipe transitionDuration=0.8 transitionDirection=left]}');
405
- expect(output).not.toContain('{transition=wipe');
406
- });
407
-
408
- it('a programmatic transition survives the string round trip', () => {
409
- const doc = markdownToDoc(parseMarkdown('## Section\n\nBody'));
410
- doc.blocks[0].transition = { type: 'wipe', duration: 0.8, direction: 'left' };
411
-
412
- const reparsed = markdownToDoc(parseMarkdown(stringifyMarkdown(docToMarkdown(doc))));
413
-
414
- expect(reparsed.blocks[0].transition).toEqual({
415
- type: 'wipe',
416
- duration: 0.8,
417
- direction: 'left',
418
- });
419
- });
420
-
421
- it('a programmatic transition survives the in-memory round trip (no stringify)', () => {
422
- // markdownToDoc reads heading.attributes.blockMeta directly — it never
423
- // re-coerces params — so docToMarkdown must keep blockMeta in sync with
424
- // the params it writes for stringifyMarkdown.
425
- const doc = markdownToDoc(parseMarkdown('## Section\n\nBody'));
426
- doc.blocks[0].transition = { type: 'wipe', duration: 0.8, direction: 'left' };
427
-
428
- const reconverted = markdownToDoc(docToMarkdown(doc));
429
-
430
- expect(reconverted.blocks[0].transition).toEqual({
431
- type: 'wipe',
432
- duration: 0.8,
433
- direction: 'left',
434
- });
435
- });
436
-
437
- it('an updated transition replaces a previously authored one in both round trips', () => {
438
- // The heading already carries a parsed transition (params + blockMeta);
439
- // a programmatic change must win over the stale blockMeta.
440
- const doc = markdownToDoc(parseMarkdown('## Section {transition=fade}\n\nBody'));
441
- expect(doc.blocks[0].transition).toEqual({ type: 'fade' });
442
- doc.blocks[0].transition = { type: 'wipe', direction: 'left' };
443
-
444
- const inMemory = markdownToDoc(docToMarkdown(doc));
445
- expect(inMemory.blocks[0].transition).toEqual({ type: 'wipe', direction: 'left' });
446
-
447
- const output = stringifyMarkdown(docToMarkdown(doc));
448
- expect(output).toContain('transition=wipe');
449
- expect(output).toContain('{[transition=wipe transitionDirection=left]}');
450
- expect(output).not.toContain('{transition=wipe');
451
- const reparsed = markdownToDoc(parseMarkdown(output));
452
- expect(reparsed.blocks[0].transition).toEqual({ type: 'wipe', direction: 'left' });
453
- });
454
-
455
- it('nested headings preserve their own annotations', () => {
456
- const input = '# Chapter {[title]}\n\nIntro\n\n## Section {[chart]}\n\nData';
457
- const md = parseMarkdown(input);
458
- const doc = markdownToDoc(md);
459
-
460
- expect(doc.blocks[0].template).toBe('title');
461
- expect(doc.blocks[0].children).toHaveLength(1);
462
- expect(doc.blocks[0].children![0].template).toBe('chart');
463
- });
464
- });
465
-
466
- // ============================================
467
- // Reading-time durations & caption generation
468
- // ============================================
469
-
470
- describe('reading-time durations', () => {
471
- it('sets block duration based on body content reading time', () => {
472
- // ~50 words at 200 WPM = 15 seconds
473
- const body = Array.from({ length: 50 }, (_, i) => `word${i}`).join(' ');
474
- const md = parseMarkdown(`# Title\n\n${body}`);
475
- const doc = markdownToDoc(md);
476
-
477
- const block = doc.blocks[0];
478
- expect(block.duration).toBeGreaterThan(5); // more than default
479
- expect(block.duration).toBe(15); // 50 words / 200 WPM * 60 = 15s
480
- });
481
-
482
- it('applies minimum 3s duration for very short content', () => {
483
- const md = parseMarkdown('# Title\n\nHi.');
484
- const doc = markdownToDoc(md);
485
-
486
- expect(doc.blocks[0].duration).toBe(3);
487
- });
488
-
489
- it('uses defaultDuration for blocks with no body content', () => {
490
- const md = parseMarkdown('# Title');
491
- const doc = markdownToDoc(md);
492
-
493
- expect(doc.blocks[0].duration).toBe(5); // default
494
- });
495
-
496
- it('doc.duration sums all reading-time block durations', () => {
497
- // Block A: no body → 5s default. Block B: ~20 words → 6s
498
- const body = Array.from({ length: 20 }, (_, i) => `word${i}`).join(' ');
499
- const md = parseMarkdown(`# A\n\n# B\n\n${body}`);
500
- const doc = markdownToDoc(md);
501
-
502
- const flat = flattenBlocks(doc.blocks);
503
- expect(flat[0].duration).toBe(5); // A: no body
504
- expect(flat[1].duration).toBe(6); // B: 20 words / 200 WPM * 60 = 6s
505
- expect(doc.duration).toBe(11);
506
- });
507
- });
508
-
509
- describe('caption generation', () => {
510
- it('generates captions from body content', () => {
511
- const md = parseMarkdown('# Title\n\nThis is the first sentence. This is the second sentence.');
512
- const doc = markdownToDoc(md);
513
-
514
- expect(doc.captions).toBeDefined();
515
- expect(doc.captions!.phrases.length).toBeGreaterThanOrEqual(2);
516
- expect(doc.captions!.phrases[0].text).toContain('first sentence');
517
- expect(doc.captions!.phrases[1].text).toContain('second sentence');
518
- });
519
-
520
- it('caption times span the block duration', () => {
521
- const md = parseMarkdown('# Section\n\nSome text here. More text follows.');
522
- const doc = markdownToDoc(md);
523
-
524
- expect(doc.captions).toBeDefined();
525
- const phrases = doc.captions!.phrases;
526
- // First phrase starts at block start
527
- expect(phrases[0].startTime).toBe(doc.blocks[0].startTime);
528
- // Last phrase ends at block end
529
- const last = phrases[phrases.length - 1];
530
- expect(last.endTime).toBeCloseTo(doc.blocks[0].startTime + doc.blocks[0].duration, 1);
531
- });
532
-
533
- it('does not generate captions for blocks without body content', () => {
534
- const md = parseMarkdown('# A\n\n# B\n\n# C');
535
- const doc = markdownToDoc(md);
536
-
537
- // No body content anywhere → no captions
538
- expect(doc.captions).toBeUndefined();
539
- });
540
-
541
- it('generates captions version; timestamp only when supplied (deterministic default)', () => {
542
- const md = parseMarkdown('# Title\n\nHello world and more text.');
543
- const doc = markdownToDoc(md);
544
-
545
- expect(doc.captions!.version).toBe(1);
546
- // No clock reads during conversion — generatedAt is opt-in.
547
- expect(doc.captions!.generatedAt).toBeUndefined();
548
-
549
- const stamped = markdownToDoc(md, { captionsGeneratedAt: '2026-01-01T00:00:00.000Z' });
550
- expect(stamped.captions!.generatedAt).toBe('2026-01-01T00:00:00.000Z');
551
- });
552
-
553
- it('caption phrases have sequential non-overlapping times', () => {
554
- const md = parseMarkdown(
555
- '# A\n\nFirst sentence here. Second sentence here.\n\n# B\n\nThird sentence. Fourth sentence.',
556
- );
557
- const doc = markdownToDoc(md);
558
-
559
- const phrases = doc.captions!.phrases;
560
- for (let i = 1; i < phrases.length; i++) {
561
- expect(phrases[i].startTime).toBeGreaterThanOrEqual(phrases[i - 1].endTime - 0.001);
562
- }
563
- });
564
- });
565
-
566
- // ============================================
567
- // Auto cover block (startBlock) generation
568
- // ============================================
569
-
570
- describe('auto cover block generation', () => {
571
- it('creates startBlock from H1 title', () => {
572
- const md = parseMarkdown('# My Great Article\n\nSome introduction text.');
573
- const doc = markdownToDoc(md);
574
-
575
- expect(doc.startBlock).toBeDefined();
576
- expect(doc.startBlock!.title).toBe('My Great Article');
577
- });
578
-
579
- it('uses first paragraph after H1 as subtitle', () => {
580
- const md = parseMarkdown('# Title\n\nThis is a subtitle paragraph.\n\n## Section\n\nBody');
581
- const doc = markdownToDoc(md);
582
-
583
- expect(doc.startBlock).toBeDefined();
584
- expect(doc.startBlock!.subtitle).toBe('This is a subtitle paragraph.');
585
- });
586
-
587
- it('picks first image as heroSrc', () => {
588
- const md = parseMarkdown('# Title\n\n![photo](hero.jpg)\n\nSome text.');
589
- const doc = markdownToDoc(md);
590
-
591
- expect(doc.startBlock).toBeDefined();
592
- expect(doc.startBlock!.heroSrc).toBe('hero.jpg');
593
- expect(doc.startBlock!.heroAlt).toBe('photo');
594
- });
595
-
596
- it('picks image from deeper in document', () => {
597
- const md = parseMarkdown(
598
- '# Title\n\nIntro text.\n\n## Section\n\nBody text.\n\n![deep pic](deep.png)',
599
- );
600
- const doc = markdownToDoc(md);
601
-
602
- expect(doc.startBlock).toBeDefined();
603
- expect(doc.startBlock!.heroSrc).toBe('deep.png');
604
- });
605
-
606
- it('picks raw HTML <img> as heroSrc (WYSIWYG resize case)', () => {
607
- // The WYSIWYG editor serializes resized images as raw `<img src width>`
608
- // because markdown shorthand has no width syntax. The cover scanner
609
- // must see through that, or every resized image silently drops out
610
- // of exports.
611
- const md = parseMarkdown(
612
- '# Title\n\n<img alt="resized" src="resized.jpg" width="194">\n\nText.',
613
- );
614
- const doc = markdownToDoc(md);
615
-
616
- expect(doc.startBlock).toBeDefined();
617
- expect(doc.startBlock!.heroSrc).toBe('resized.jpg');
618
- expect(doc.startBlock!.heroAlt).toBe('resized');
619
- });
620
-
621
- it('works without images (no heroSrc)', () => {
622
- const md = parseMarkdown('# Title\n\nPlain text, no images.');
623
- const doc = markdownToDoc(md);
624
-
625
- expect(doc.startBlock).toBeDefined();
626
- expect(doc.startBlock!.title).toBe('Title');
627
- expect(doc.startBlock!.heroSrc).toBeUndefined();
628
- });
629
-
630
- it('sets ambientMotion to zoomIn by default', () => {
631
- const md = parseMarkdown('# Title\n\nContent.');
632
- const doc = markdownToDoc(md);
633
-
634
- expect(doc.startBlock!.ambientMotion).toBe('zoomIn');
635
- });
636
-
637
- it('does not create startBlock when no H1 exists', () => {
638
- const md = parseMarkdown('## Section A\n\nText A\n\n## Section B\n\nText B');
639
- const doc = markdownToDoc(md);
640
-
641
- expect(doc.startBlock).toBeUndefined();
642
- });
643
-
644
- it('does not create startBlock when generateCoverBlock is false', () => {
645
- const md = parseMarkdown('# Title\n\nContent.');
646
- const doc = markdownToDoc(md, { generateCoverBlock: false });
647
-
648
- expect(doc.startBlock).toBeUndefined();
649
- });
650
-
651
- it('does not create startBlock for heading-only document with no content', () => {
652
- const md = parseMarkdown('# Title');
653
- const doc = markdownToDoc(md);
654
-
655
- expect(doc.startBlock).toBeDefined();
656
- expect(doc.startBlock!.title).toBe('Title');
657
- expect(doc.startBlock!.subtitle).toBeUndefined();
658
- });
659
- });
660
-
661
- describe('markdownToDoc with Pandoc attributes', () => {
662
- it('overrides block id from {#id}', () => {
663
- const block = firstHeadingBlock('## Section title {#intro}');
664
- expect(block.id).toBe('intro');
665
- });
666
-
667
- it('applies x / y to typed Block fields', () => {
668
- // `diagramNode` is a legacy alias for the canonical `diagram` template;
669
- // the alias resolves at template-resolution time.
670
- const block = firstHeadingBlock('## Step 1 {#step1 x=400 y=200} {[diagramNode]}');
671
- expect(block.id).toBe('step1');
672
- expect(block.x).toBe(400);
673
- expect(block.y).toBe(200);
674
- expect(block.template).toBe('diagram');
675
- });
676
-
677
- it('applies multiple connectsTo entries with mixed types', () => {
678
- const block = firstHeadingBlock(
679
- '## Architecture {#arch x=600 y=300 connectsTo=foo:veryImportant,bar:requires,baz:requires} {[diagramNode]}',
680
- );
681
- expect(block.connectsTo).toEqual([
682
- { target: 'foo', type: 'veryImportant' },
683
- { target: 'bar', type: 'requires' },
684
- { target: 'baz', type: 'requires' },
685
- ]);
686
- });
687
-
688
- it('parses connections without types', () => {
689
- const block = firstHeadingBlock('## Summary {#summary connectsTo=intro,middle,end}');
690
- expect(block.connectsTo).toEqual([
691
- { target: 'intro' },
692
- { target: 'middle' },
693
- { target: 'end' },
694
- ]);
695
- });
696
-
697
- it('parses mix of typed and untyped connections in one list', () => {
698
- const block = firstHeadingBlock(
699
- '## Decision {#decision connectsTo=alt1,alt2:rejected,alt3:chosen}',
700
- );
701
- expect(block.connectsTo).toEqual([
702
- { target: 'alt1' },
703
- { target: 'alt2', type: 'rejected' },
704
- { target: 'alt3', type: 'chosen' },
705
- ]);
706
- });
707
-
708
- it('overrides startTime / duration with attribute values (seconds)', () => {
709
- const block = firstHeadingBlock('## Closing {#closing startTime=02:30 duration=00:45}');
710
- expect(block.startTime).toBe(150);
711
- expect(block.duration).toBe(45);
712
- });
713
-
714
- it('sets transition metadata from Pandoc attributes', () => {
715
- const block = firstHeadingBlock(
716
- '## Closing {#closing transition=checkerboard transitionDuration=1.2 transitionDirection=vertical}',
717
- );
718
- expect(block.transition).toEqual({
719
- type: 'checkerboard',
720
- duration: 1.2,
721
- direction: 'vertical',
722
- });
723
- });
724
-
725
- it('puts unknown keys into block.metadata', () => {
726
- const block = firstHeadingBlock('## X {#x priority=high status=draft}');
727
- expect(block.metadata).toEqual({ priority: 'high', status: 'draft' });
728
- });
729
-
730
- it('routes template params separately from block-level metadata', () => {
731
- const block = firstHeadingBlock(
732
- '## X {#big x=400 priority=high} {[diagramNode colorScheme=blue]}',
733
- );
734
- expect(block.templateOverrides).toEqual({ colorScheme: 'blue' });
735
- expect(block.metadata).toEqual({ priority: 'high' });
736
- expect(block.x).toBe(400);
737
- });
738
-
739
- it('stores Pandoc classes on block.classes', () => {
740
- const block = firstHeadingBlock('## X {#x .alpha .beta}');
741
- expect(block.classes).toEqual(['alpha', 'beta']);
742
- });
743
-
744
- it('backward compat: plain {[…]}-only heading is unchanged', () => {
745
- const block = firstHeadingBlock('## X {[chart colorScheme=blue]}');
746
- expect(block.template).toBe('chart');
747
- expect(block.templateOverrides).toEqual({ colorScheme: 'blue' });
748
- expect(block.x).toBeUndefined();
749
- expect(block.metadata).toBeUndefined();
750
- expect(block.classes).toBeUndefined();
751
- });
752
- });
753
-
754
- describe('markdownToDoc block-meta in the squiggly {[…]} form', () => {
755
- it('reads duration from a pure key-value {[duration=N]} annotation', () => {
756
- const block = firstHeadingBlock('## Closing {[duration=8]}\n\nSome body text here.\n');
757
- expect(block.duration).toBe(8);
758
- });
759
-
760
- it('does not let reading-time overwrite a squiggly-pinned duration', () => {
761
- // Body long enough that the reading-time estimate would exceed 8s if it ran.
762
- const body = Array(80).fill('word').join(' ');
763
- const block = firstHeadingBlock(`## Closing {[duration=8]}\n\n${body}\n`);
764
- expect(block.duration).toBe(8);
765
- });
766
-
767
- it('folds duration alongside a template name', () => {
768
- const block = firstHeadingBlock('## Hero {[sectionHeader duration=6]}');
769
- expect(block.template).toBe('sectionHeader');
770
- expect(block.duration).toBe(6);
771
- });
772
-
773
- it('folds transition alongside a template name', () => {
774
- const block = firstHeadingBlock(
775
- '## Hero {[sectionHeader transition=fly-through transitionDuration=750ms]}',
776
- );
777
- expect(block.template).toBe('sectionHeader');
778
- expect(block.transition).toEqual({
779
- type: 'flyThrough',
780
- duration: 0.75,
781
- });
782
- });
783
-
784
- it('accepts startTime in the squiggly form too', () => {
785
- const block = firstHeadingBlock('## Closing {[startTime=02:30 duration=45]}');
786
- expect(block.startTime).toBe(150);
787
- expect(block.duration).toBe(45);
788
- });
789
-
790
- it('Pandoc attrs win when a key appears in both forms', () => {
791
- const block = firstHeadingBlock('## X {duration=3} {[duration=9]}');
792
- expect(block.duration).toBe(3);
793
- });
794
- });
795
-
796
- describe('auto template picking (autoTemplates, default on)', () => {
797
- const toDocFromMd = (md: string, options?: Parameters<typeof markdownToDoc>[1]) =>
798
- markdownToDoc(parseMarkdown(md), options);
799
-
800
- it('picks quote for a blockquote-bearing section and derives the quote text', () => {
801
- const doc = toDocFromMd('# Wisdom\n\n> The best template feels obvious.\n');
802
- const block = doc.blocks[0];
803
- expect(block.template).toBe('quote');
804
- expect(block.autoTemplate).toBe(true);
805
- expect(block.templateData?.quote).toBe('The best template feels obvious.');
806
- });
807
-
808
- it('picks dataTable for a table-bearing section with derived headers/rows', () => {
809
- const doc = toDocFromMd('# Results\n\n| A | B |\n| - | - |\n| 1 | 2 |\n');
810
- const block = doc.blocks[0];
811
- expect(block.template).toBe('dataTable');
812
- expect(block.templateData?.headers).toEqual(['A', 'B']);
813
- expect(block.templateData?.rows).toEqual([['1', '2']]);
814
- });
815
-
816
- it('picks list for list-bearing sections and photoGrid for multi-image sections', () => {
817
- const doc = toDocFromMd('# Steps\n\n- one\n- two\n\n# Gallery\n\n![a](a.jpg)\n\n![b](b.jpg)\n');
818
- expect(doc.blocks[0].template).toBe('list');
819
- expect(doc.blocks[0].templateData?.items).toEqual(['one', 'two']);
820
- expect(doc.blocks[1].template).toBe('photoGrid');
821
- });
822
-
823
- it('alternates left/right feature for consecutive single-image sections', () => {
824
- const doc = toDocFromMd('# One\n\n![a](a.jpg)\n\n# Two\n\n![b](b.jpg)\n');
825
- expect(doc.blocks[0].template).toBe('leftFeature');
826
- expect(doc.blocks[1].template).toBe('rightFeature');
827
- expect(doc.blocks[0].templateData?.imageSrc).toBe('a.jpg');
828
- });
829
-
830
- it('leaves plain prose sections on the structural default', () => {
831
- const doc = toDocFromMd('# About\n\nJust a paragraph of prose.\n');
832
- expect(doc.blocks[0].template).toBe('sectionHeader');
833
- expect(doc.blocks[0].autoTemplate).toBeUndefined();
834
- });
835
-
836
- it('never overrides an explicit annotation', () => {
837
- const doc = toDocFromMd('# Wisdom {[factCard fact="F"]}\n\n> quoted\n');
838
- expect(doc.blocks[0].template).toBe('factCard');
839
- });
840
-
841
- it('is disabled by the option and by frontmatter', () => {
842
- const md = '# Wisdom\n\n> quoted\n';
843
- const viaOption = toDocFromMd(md, { autoTemplates: false });
844
- expect(viaOption.blocks[0].template).toBe('sectionHeader');
845
-
846
- const viaFrontmatter = markdownToDoc(
847
- parseMarkdown('---\nsquisq-auto-templates: false\n---\n\n' + md),
848
- );
849
- expect(viaFrontmatter.blocks[0].template).toBe('sectionHeader');
850
- });
851
-
852
- it('keeps the round-trip lossless (no materialized annotations)', () => {
853
- const md = '# Wisdom\n\n> The best template feels obvious.\n';
854
- const doc = toDocFromMd(md);
855
- expect(doc.blocks[0].template).toBe('quote');
856
- const roundTripped = stringifyMarkdown(docToMarkdown(doc));
857
- expect(roundTripped).not.toContain('{[quote');
858
- });
859
- });
860
-
861
- describe('standalone annotation blocks (S2)', () => {
862
- const toDoc = (md: string, options?: Parameters<typeof markdownToDoc>[1]) =>
863
- markdownToDoc(parseMarkdown(md), { articleId: 't', generateCoverBlock: false, ...options });
864
-
865
- it('turns a standalone {[template]} paragraph into a heading-less block', () => {
866
- const doc = toDoc('# Intro\n\nlead para\n\n{[quote]}\n\nquoted body\n');
867
- // Containing block keeps only the leading content.
868
- const intro = doc.blocks[0];
869
- expect(intro.title).toBe('Intro');
870
- expect(intro.contents?.map((n) => n.type)).toEqual(['paragraph']);
871
- // The produced block is a sibling right after the containing block.
872
- const q = doc.blocks[1];
873
- expect(q.template).toBe('quote');
874
- expect(q.standaloneAnnotation).toBe(true);
875
- expect(q.sourceHeading).toBeUndefined();
876
- expect(q.sourceAnnotation).toEqual({ template: 'quote' });
877
- expect(q.contents?.map((n) => n.type)).toEqual(['paragraph']);
878
- });
879
-
880
- it('attaches trailing contents up to the next annotation; params → overrides + title', () => {
881
- const doc = toDoc(
882
- '# H\n\n{[statHighlight title="Q1 Revenue" colorScheme=blue]}\n\nbig number\n\n{[quote]}\n\nq\n',
883
- );
884
- const stat = doc.blocks[1];
885
- expect(stat.template).toBe('statHighlight');
886
- expect(stat.title).toBe('Q1 Revenue');
887
- expect(stat.templateOverrides).toEqual({ title: 'Q1 Revenue', colorScheme: 'blue' });
888
- expect(stat.contents?.length).toBe(1); // "big number", ended by the next annotation
889
- const quote = doc.blocks[2];
890
- expect(quote.template).toBe('quote');
891
- expect(quote.contents?.length).toBe(1); // "q"
892
- });
893
-
894
- it('produces adjacent blocks for consecutive annotations (no content between)', () => {
895
- const doc = toDoc('# H\n\n{[quote]}\n\n{[factCard]}\n\ntail\n');
896
- expect(doc.blocks[1].template).toBe('quote');
897
- expect(doc.blocks[1].contents ?? []).toHaveLength(0);
898
- expect(doc.blocks[2].template).toBe('factCard');
899
- expect(doc.blocks[2].contents?.length).toBe(1); // "tail"
900
- });
901
-
902
- it('handles an annotation as the last node (no trailing contents)', () => {
903
- const doc = toDoc('# H\n\nbody\n\n{[quote]}\n');
904
- expect(doc.blocks[1].template).toBe('quote');
905
- expect(doc.blocks[1].contents ?? []).toHaveLength(0);
906
- });
907
-
908
- it('generates unique slug ids that dedupe against headings', () => {
909
- const doc = toDoc('# Quote\n\n{[quote title=Quote]}\n\nbody\n');
910
- expect(doc.blocks[0].id).toBe('quote');
911
- expect(doc.blocks[1].id).toBe('quote-2');
912
- });
913
-
914
- it('lifts an annotation out of the preamble (before the first heading)', () => {
915
- const doc = toDoc('intro\n\n{[quote]}\n\nquoted\n\n# Heading\n\nrest\n');
916
- // preamble keeps "intro", quote block next, then the heading block.
917
- expect(doc.blocks[0].sourceHeading).toBeUndefined();
918
- expect(doc.blocks[0].contents?.length).toBe(1);
919
- expect(doc.blocks[1].template).toBe('quote');
920
- expect(doc.blocks[2].title).toBe('Heading');
921
- });
922
-
923
- it('drops a preamble that was entirely a standalone annotation', () => {
924
- const doc = toDoc('{[quote]}\n\nquoted\n\n# Heading\n');
925
- expect(doc.blocks[0].template).toBe('quote');
926
- expect(doc.blocks[0].standaloneAnnotation).toBe(true);
927
- expect(doc.blocks[1].title).toBe('Heading');
928
- });
929
-
930
- it('honors a pinned duration on a standalone annotation', () => {
931
- const doc = toDoc('# H\n\n{[quote duration=9]}\n\nbody\n');
932
- expect(doc.blocks[1].duration).toBe(9);
933
- });
934
-
935
- it('does not treat annotations nested inside a list as blocks', () => {
936
- const doc = toDoc('# H\n\n- {[quote]}\n');
937
- // Only the heading block — the list annotation stays in contents.
938
- expect(doc.blocks).toHaveLength(1);
939
- expect(doc.blocks[0].contents?.[0].type).toBe('list');
940
- });
941
-
942
- it('round-trips a standalone annotation block byte-for-byte', () => {
943
- const md = '# Intro\n\nlead\n\n{[quote]}\n\nquoted body\n';
944
- const doc = toDoc(md);
945
- const out = stringifyMarkdown(docToMarkdown(doc));
946
- expect(out).toBe(md);
947
- // And re-parsing is stable.
948
- const doc2 = toDoc(out);
949
- expect(stringifyMarkdown(docToMarkdown(doc2))).toBe(md);
950
- });
951
-
952
- it('round-trips params (quoting) byte-for-byte', () => {
953
- const md = '# H\n\n{[statHighlight title="Q1 Revenue" colorScheme=blue]}\n\nbody\n';
954
- const out = stringifyMarkdown(docToMarkdown(toDoc(md)));
955
- expect(out).toBe(md);
956
- });
957
- });