@bendyline/squisq 1.3.0 → 1.4.1

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 (533) hide show
  1. package/dist/{Doc-Ch4tc3vv.d.ts → Doc-BeSeH2iX.d.ts} +118 -41
  2. package/dist/ImageEditDoc-BTIvw0oq.d.ts +84 -0
  3. package/dist/{chunk-CYQHG27J.js → chunk-2TMAWB4Y.js} +74 -1
  4. package/dist/chunk-2TMAWB4Y.js.map +1 -0
  5. package/dist/{chunk-OASJKWO5.js → chunk-3K5OG6KI.js} +92 -7
  6. package/dist/chunk-3K5OG6KI.js.map +1 -0
  7. package/dist/chunk-57CVQCFX.js +193 -0
  8. package/dist/chunk-57CVQCFX.js.map +1 -0
  9. package/dist/{chunk-QM5PKNPW.js → chunk-5WFRKURX.js} +1 -1
  10. package/dist/chunk-5WFRKURX.js.map +1 -0
  11. package/dist/chunk-B4EEON3N.js +1317 -0
  12. package/dist/chunk-B4EEON3N.js.map +1 -0
  13. package/dist/chunk-DBS6RIFL.js +81 -0
  14. package/dist/chunk-DBS6RIFL.js.map +1 -0
  15. package/dist/{chunk-MIBRIRGJ.js → chunk-FR2RBTKO.js} +3 -3
  16. package/dist/{chunk-MIBRIRGJ.js.map → chunk-FR2RBTKO.js.map} +1 -1
  17. package/dist/chunk-H3AXU4MJ.js +179 -0
  18. package/dist/chunk-H3AXU4MJ.js.map +1 -0
  19. package/dist/chunk-JELIRVDP.js +24 -0
  20. package/dist/chunk-JELIRVDP.js.map +1 -0
  21. package/dist/chunk-K32VJONL.js +193 -0
  22. package/dist/chunk-K32VJONL.js.map +1 -0
  23. package/dist/{chunk-6BAVXFYC.js → chunk-KSWJR66U.js} +218 -42
  24. package/dist/chunk-KSWJR66U.js.map +1 -0
  25. package/dist/{chunk-TSG2OSE6.js → chunk-MYIH7FWD.js} +3 -3
  26. package/dist/chunk-MYIH7FWD.js.map +1 -0
  27. package/dist/chunk-VLJJHDAC.js +218 -0
  28. package/dist/chunk-VLJJHDAC.js.map +1 -0
  29. package/dist/chunk-WMOI7FN3.js +182 -0
  30. package/dist/chunk-WMOI7FN3.js.map +1 -0
  31. package/dist/chunk-ZTX4PFFT.js +520 -0
  32. package/dist/chunk-ZTX4PFFT.js.map +1 -0
  33. package/dist/doc/index.d.ts +5 -10
  34. package/dist/doc/index.js +145 -7
  35. package/dist/doc/index.js.map +1 -1
  36. package/dist/generate/index.d.ts +99 -7
  37. package/dist/generate/index.js +16 -3
  38. package/dist/generate/index.js.map +1 -1
  39. package/dist/icons/index.d.ts +87 -0
  40. package/dist/icons/index.js +17 -0
  41. package/dist/icons/index.js.map +1 -0
  42. package/dist/imageEdit/index.d.ts +216 -0
  43. package/dist/imageEdit/index.js +54 -0
  44. package/dist/imageEdit/index.js.map +1 -0
  45. package/dist/index.d.ts +21 -9
  46. package/dist/index.js +461 -8
  47. package/dist/index.js.map +1 -1
  48. package/dist/jsonForm/index.d.ts +191 -0
  49. package/dist/jsonForm/index.js +27 -0
  50. package/dist/jsonForm/index.js.map +1 -0
  51. package/dist/markdown/index.d.ts +265 -19
  52. package/dist/markdown/index.js +39 -33
  53. package/dist/markdown/index.js.map +1 -1
  54. package/dist/random/index.d.ts +51 -2
  55. package/dist/random/index.js +9 -1
  56. package/dist/random/index.js.map +1 -1
  57. package/dist/recommend/index.d.ts +42 -0
  58. package/dist/recommend/index.js +10 -0
  59. package/dist/recommend/index.js.map +1 -0
  60. package/dist/schemas/index.d.ts +188 -10
  61. package/dist/schemas/index.js +120 -7
  62. package/dist/schemas/index.js.map +1 -1
  63. package/dist/spatial/index.d.ts +111 -3
  64. package/dist/spatial/index.js +24 -2
  65. package/dist/spatial/index.js.map +1 -1
  66. package/dist/storage/index.d.ts +159 -9
  67. package/dist/storage/index.js +20 -5
  68. package/dist/storage/index.js.map +1 -1
  69. package/dist/story/index.d.ts +53 -13
  70. package/dist/story/index.js +12 -4
  71. package/dist/themeLibrary-BHjJ0Qx6.d.ts +40 -0
  72. package/dist/timing/index.d.ts +109 -4
  73. package/dist/timing/index.js +23 -2
  74. package/dist/timing/index.js.map +1 -1
  75. package/dist/transform/index.d.ts +175 -6
  76. package/dist/transform/index.js +490 -3
  77. package/dist/transform/index.js.map +1 -1
  78. package/dist/{types-CkNttVSF.d.ts → types-BdZkdJ3z.d.ts} +17 -2
  79. package/dist/types-D98li1gV.d.ts +93 -0
  80. package/dist/versions/index.d.ts +128 -0
  81. package/dist/versions/index.js +35 -0
  82. package/dist/versions/index.js.map +1 -0
  83. package/package.json +28 -1
  84. package/src/__tests__/colorUtils.test.ts +112 -0
  85. package/src/__tests__/getLayers.test.ts +32 -7
  86. package/src/__tests__/iconResolve.test.ts +122 -0
  87. package/src/__tests__/imageEditState.test.ts +74 -0
  88. package/src/__tests__/imageEditVersions.test.ts +169 -0
  89. package/src/__tests__/inferDocumentTitle.test.ts +50 -0
  90. package/src/__tests__/jsonForm.chooseControl.test.ts +86 -0
  91. package/src/__tests__/jsonForm.evaluateWhen.test.ts +59 -0
  92. package/src/__tests__/jsonForm.inferSchema.test.ts +25 -0
  93. package/src/__tests__/jsonForm.pointer.test.ts +103 -0
  94. package/src/__tests__/markdownIcons.test.ts +104 -0
  95. package/src/__tests__/markdownToDoc.test.ts +19 -4
  96. package/src/__tests__/recommendTemplates.test.ts +183 -0
  97. package/src/__tests__/scopedContentContainer.test.ts +89 -0
  98. package/src/__tests__/slideshowGenerator.test.ts +1 -1
  99. package/src/__tests__/templateAnnotationParse.test.ts +42 -0
  100. package/src/__tests__/templates.test.ts +93 -9
  101. package/src/__tests__/themeCompile.test.ts +156 -0
  102. package/src/__tests__/themeValidator.test.ts +125 -0
  103. package/src/__tests__/versions.test.ts +415 -0
  104. package/src/doc/audioMapping.ts +55 -11
  105. package/src/doc/getLayers.ts +32 -21
  106. package/src/doc/markdownToDoc.ts +45 -7
  107. package/src/doc/templates/featureBlock.ts +202 -0
  108. package/src/doc/templates/fullBleedQuote.ts +13 -0
  109. package/src/doc/templates/index.ts +50 -16
  110. package/src/doc/templates/listBlock.ts +24 -5
  111. package/src/doc/templates/statHighlight.ts +13 -0
  112. package/src/doc/templates/titleBlock.ts +9 -0
  113. package/src/doc/utils/themeUtils.ts +8 -7
  114. package/src/generate/slideshowGenerator.ts +1 -1
  115. package/src/generate/templateMapper.ts +2 -2
  116. package/src/icons/iconData.ts +31 -0
  117. package/src/icons/index.ts +18 -0
  118. package/src/icons/resolve.ts +139 -0
  119. package/src/imageEdit/ImageEditVersionManager.ts +73 -0
  120. package/src/imageEdit/export.ts +326 -0
  121. package/src/imageEdit/index.ts +71 -0
  122. package/src/imageEdit/persistence.ts +62 -0
  123. package/src/imageEdit/state.ts +112 -0
  124. package/src/imageEdit/versionPaths.ts +57 -0
  125. package/src/imageEdit/versions.ts +231 -0
  126. package/src/index.ts +4 -0
  127. package/src/jsonForm/chooseControl.ts +88 -0
  128. package/src/jsonForm/evaluateWhen.ts +59 -0
  129. package/src/jsonForm/index.ts +22 -0
  130. package/src/jsonForm/inferSchema.ts +25 -0
  131. package/src/jsonForm/pointer.ts +109 -0
  132. package/src/jsonForm/types.ts +167 -0
  133. package/src/markdown/convert.ts +145 -5
  134. package/src/markdown/index.ts +3 -0
  135. package/src/markdown/types.ts +19 -2
  136. package/src/markdown/utils.ts +159 -0
  137. package/src/recommend/index.ts +16 -0
  138. package/src/recommend/templates.ts +273 -0
  139. package/src/schemas/BlockTemplates.ts +50 -7
  140. package/src/schemas/ImageEditDoc.ts +95 -0
  141. package/src/schemas/Theme.ts +98 -31
  142. package/src/schemas/colorUtils.ts +186 -0
  143. package/src/schemas/fontStacks.ts +257 -0
  144. package/src/schemas/index.ts +12 -0
  145. package/src/schemas/themeCompile.ts +203 -0
  146. package/src/schemas/themeLibrary.ts +18 -597
  147. package/src/schemas/themeValidator.ts +388 -0
  148. package/src/schemas/themes/bold.json +48 -0
  149. package/src/schemas/themes/cinematic.json +54 -0
  150. package/src/schemas/themes/documentary.json +49 -0
  151. package/src/schemas/themes/gezellig.json +44 -0
  152. package/src/schemas/themes/index.ts +53 -0
  153. package/src/schemas/themes/magazine.json +44 -0
  154. package/src/schemas/themes/minimalist.json +45 -0
  155. package/src/schemas/themes/morning-light.json +42 -0
  156. package/src/schemas/themes/standard-dark.json +50 -0
  157. package/src/schemas/themes/standard.json +42 -0
  158. package/src/schemas/themes/tech-dark.json +48 -0
  159. package/src/schemas/themes/warm-earth.json +50 -0
  160. package/src/storage/ScopedContentContainer.ts +113 -0
  161. package/src/storage/index.ts +1 -0
  162. package/src/versions/DocumentVersionManager.ts +70 -0
  163. package/src/versions/index.ts +54 -0
  164. package/src/versions/operations.ts +230 -0
  165. package/src/versions/paths.ts +66 -0
  166. package/src/versions/timestamp.ts +48 -0
  167. package/src/versions/types.ts +91 -0
  168. package/dist/__tests__/animationUtils.test.d.ts +0 -2
  169. package/dist/__tests__/animationUtils.test.d.ts.map +0 -1
  170. package/dist/__tests__/animationUtils.test.js +0 -60
  171. package/dist/__tests__/animationUtils.test.js.map +0 -1
  172. package/dist/__tests__/contentContainer.test.d.ts +0 -2
  173. package/dist/__tests__/contentContainer.test.d.ts.map +0 -1
  174. package/dist/__tests__/contentContainer.test.js +0 -234
  175. package/dist/__tests__/contentContainer.test.js.map +0 -1
  176. package/dist/__tests__/contentExtractor.test.d.ts +0 -2
  177. package/dist/__tests__/contentExtractor.test.d.ts.map +0 -1
  178. package/dist/__tests__/contentExtractor.test.js +0 -151
  179. package/dist/__tests__/contentExtractor.test.js.map +0 -1
  180. package/dist/__tests__/coverBlock.test.d.ts +0 -2
  181. package/dist/__tests__/coverBlock.test.d.ts.map +0 -1
  182. package/dist/__tests__/coverBlock.test.js +0 -197
  183. package/dist/__tests__/coverBlock.test.js.map +0 -1
  184. package/dist/__tests__/dataTable.test.d.ts +0 -2
  185. package/dist/__tests__/dataTable.test.d.ts.map +0 -1
  186. package/dist/__tests__/dataTable.test.js +0 -110
  187. package/dist/__tests__/dataTable.test.js.map +0 -1
  188. package/dist/__tests__/geohash.test.d.ts +0 -2
  189. package/dist/__tests__/geohash.test.d.ts.map +0 -1
  190. package/dist/__tests__/geohash.test.js +0 -87
  191. package/dist/__tests__/geohash.test.js.map +0 -1
  192. package/dist/__tests__/getLayers.test.d.ts +0 -2
  193. package/dist/__tests__/getLayers.test.d.ts.map +0 -1
  194. package/dist/__tests__/getLayers.test.js +0 -167
  195. package/dist/__tests__/getLayers.test.js.map +0 -1
  196. package/dist/__tests__/haversine.test.d.ts +0 -2
  197. package/dist/__tests__/haversine.test.d.ts.map +0 -1
  198. package/dist/__tests__/haversine.test.js +0 -56
  199. package/dist/__tests__/haversine.test.js.map +0 -1
  200. package/dist/__tests__/localForageAdapter.test.d.ts +0 -8
  201. package/dist/__tests__/localForageAdapter.test.d.ts.map +0 -1
  202. package/dist/__tests__/localForageAdapter.test.js +0 -130
  203. package/dist/__tests__/localForageAdapter.test.js.map +0 -1
  204. package/dist/__tests__/markdown.test.d.ts +0 -2
  205. package/dist/__tests__/markdown.test.d.ts.map +0 -1
  206. package/dist/__tests__/markdown.test.js +0 -715
  207. package/dist/__tests__/markdown.test.js.map +0 -1
  208. package/dist/__tests__/markdownToDoc.test.d.ts +0 -2
  209. package/dist/__tests__/markdownToDoc.test.d.ts.map +0 -1
  210. package/dist/__tests__/markdownToDoc.test.js +0 -447
  211. package/dist/__tests__/markdownToDoc.test.js.map +0 -1
  212. package/dist/__tests__/seededRandom.test.d.ts +0 -2
  213. package/dist/__tests__/seededRandom.test.d.ts.map +0 -1
  214. package/dist/__tests__/seededRandom.test.js +0 -125
  215. package/dist/__tests__/seededRandom.test.js.map +0 -1
  216. package/dist/__tests__/slideshowGenerator.test.d.ts +0 -2
  217. package/dist/__tests__/slideshowGenerator.test.d.ts.map +0 -1
  218. package/dist/__tests__/slideshowGenerator.test.js +0 -114
  219. package/dist/__tests__/slideshowGenerator.test.js.map +0 -1
  220. package/dist/__tests__/storage.test.d.ts +0 -2
  221. package/dist/__tests__/storage.test.d.ts.map +0 -1
  222. package/dist/__tests__/storage.test.js +0 -51
  223. package/dist/__tests__/storage.test.js.map +0 -1
  224. package/dist/__tests__/surface.test.d.ts +0 -2
  225. package/dist/__tests__/surface.test.d.ts.map +0 -1
  226. package/dist/__tests__/surface.test.js +0 -57
  227. package/dist/__tests__/surface.test.js.map +0 -1
  228. package/dist/__tests__/templates.test.d.ts +0 -2
  229. package/dist/__tests__/templates.test.d.ts.map +0 -1
  230. package/dist/__tests__/templates.test.js +0 -217
  231. package/dist/__tests__/templates.test.js.map +0 -1
  232. package/dist/__tests__/timing.test.d.ts +0 -2
  233. package/dist/__tests__/timing.test.d.ts.map +0 -1
  234. package/dist/__tests__/timing.test.js +0 -131
  235. package/dist/__tests__/timing.test.js.map +0 -1
  236. package/dist/chunk-6BAVXFYC.js.map +0 -1
  237. package/dist/chunk-7GF6RDED.js +0 -82
  238. package/dist/chunk-7GF6RDED.js.map +0 -1
  239. package/dist/chunk-CYQHG27J.js.map +0 -1
  240. package/dist/chunk-F22AE6BY.js +0 -121
  241. package/dist/chunk-F22AE6BY.js.map +0 -1
  242. package/dist/chunk-FIQR4AJG.js +0 -517
  243. package/dist/chunk-FIQR4AJG.js.map +0 -1
  244. package/dist/chunk-OASJKWO5.js.map +0 -1
  245. package/dist/chunk-QM5PKNPW.js.map +0 -1
  246. package/dist/chunk-TSG2OSE6.js.map +0 -1
  247. package/dist/doc/audioMapping.d.ts +0 -36
  248. package/dist/doc/audioMapping.d.ts.map +0 -1
  249. package/dist/doc/audioMapping.js +0 -315
  250. package/dist/doc/audioMapping.js.map +0 -1
  251. package/dist/doc/docToMarkdown.d.ts +0 -41
  252. package/dist/doc/docToMarkdown.d.ts.map +0 -1
  253. package/dist/doc/docToMarkdown.js +0 -88
  254. package/dist/doc/docToMarkdown.js.map +0 -1
  255. package/dist/doc/getLayers.d.ts +0 -65
  256. package/dist/doc/getLayers.d.ts.map +0 -1
  257. package/dist/doc/getLayers.js +0 -103
  258. package/dist/doc/getLayers.js.map +0 -1
  259. package/dist/doc/index.d.ts.map +0 -1
  260. package/dist/doc/markdownToDoc.d.ts +0 -75
  261. package/dist/doc/markdownToDoc.d.ts.map +0 -1
  262. package/dist/doc/markdownToDoc.js +0 -398
  263. package/dist/doc/markdownToDoc.js.map +0 -1
  264. package/dist/doc/templates/accentImage.d.ts +0 -59
  265. package/dist/doc/templates/accentImage.d.ts.map +0 -1
  266. package/dist/doc/templates/accentImage.js +0 -275
  267. package/dist/doc/templates/accentImage.js.map +0 -1
  268. package/dist/doc/templates/captionUtils.d.ts +0 -20
  269. package/dist/doc/templates/captionUtils.d.ts.map +0 -1
  270. package/dist/doc/templates/captionUtils.js +0 -29
  271. package/dist/doc/templates/captionUtils.js.map +0 -1
  272. package/dist/doc/templates/comparisonBar.d.ts +0 -13
  273. package/dist/doc/templates/comparisonBar.d.ts.map +0 -1
  274. package/dist/doc/templates/comparisonBar.js +0 -145
  275. package/dist/doc/templates/comparisonBar.js.map +0 -1
  276. package/dist/doc/templates/coverBlock.d.ts +0 -51
  277. package/dist/doc/templates/coverBlock.d.ts.map +0 -1
  278. package/dist/doc/templates/coverBlock.js +0 -153
  279. package/dist/doc/templates/coverBlock.js.map +0 -1
  280. package/dist/doc/templates/dataTable.d.ts +0 -14
  281. package/dist/doc/templates/dataTable.d.ts.map +0 -1
  282. package/dist/doc/templates/dataTable.js +0 -73
  283. package/dist/doc/templates/dataTable.js.map +0 -1
  284. package/dist/doc/templates/dateEvent.d.ts +0 -15
  285. package/dist/doc/templates/dateEvent.d.ts.map +0 -1
  286. package/dist/doc/templates/dateEvent.js +0 -114
  287. package/dist/doc/templates/dateEvent.js.map +0 -1
  288. package/dist/doc/templates/definitionCard.d.ts +0 -13
  289. package/dist/doc/templates/definitionCard.d.ts.map +0 -1
  290. package/dist/doc/templates/definitionCard.js +0 -117
  291. package/dist/doc/templates/definitionCard.js.map +0 -1
  292. package/dist/doc/templates/factCard.d.ts +0 -15
  293. package/dist/doc/templates/factCard.d.ts.map +0 -1
  294. package/dist/doc/templates/factCard.js +0 -104
  295. package/dist/doc/templates/factCard.js.map +0 -1
  296. package/dist/doc/templates/fullBleedQuote.d.ts +0 -13
  297. package/dist/doc/templates/fullBleedQuote.d.ts.map +0 -1
  298. package/dist/doc/templates/fullBleedQuote.js +0 -55
  299. package/dist/doc/templates/fullBleedQuote.js.map +0 -1
  300. package/dist/doc/templates/imageWithCaption.d.ts +0 -13
  301. package/dist/doc/templates/imageWithCaption.d.ts.map +0 -1
  302. package/dist/doc/templates/imageWithCaption.js +0 -146
  303. package/dist/doc/templates/imageWithCaption.js.map +0 -1
  304. package/dist/doc/templates/index.d.ts +0 -105
  305. package/dist/doc/templates/index.d.ts.map +0 -1
  306. package/dist/doc/templates/index.js +0 -445
  307. package/dist/doc/templates/index.js.map +0 -1
  308. package/dist/doc/templates/listBlock.d.ts +0 -13
  309. package/dist/doc/templates/listBlock.d.ts.map +0 -1
  310. package/dist/doc/templates/listBlock.js +0 -92
  311. package/dist/doc/templates/listBlock.js.map +0 -1
  312. package/dist/doc/templates/mapBlock.d.ts +0 -17
  313. package/dist/doc/templates/mapBlock.d.ts.map +0 -1
  314. package/dist/doc/templates/mapBlock.js +0 -115
  315. package/dist/doc/templates/mapBlock.js.map +0 -1
  316. package/dist/doc/templates/persistentLayers.d.ts +0 -39
  317. package/dist/doc/templates/persistentLayers.d.ts.map +0 -1
  318. package/dist/doc/templates/persistentLayers.js +0 -447
  319. package/dist/doc/templates/persistentLayers.js.map +0 -1
  320. package/dist/doc/templates/photoGrid.d.ts +0 -20
  321. package/dist/doc/templates/photoGrid.d.ts.map +0 -1
  322. package/dist/doc/templates/photoGrid.js +0 -175
  323. package/dist/doc/templates/photoGrid.js.map +0 -1
  324. package/dist/doc/templates/pullQuote.d.ts +0 -13
  325. package/dist/doc/templates/pullQuote.d.ts.map +0 -1
  326. package/dist/doc/templates/pullQuote.js +0 -113
  327. package/dist/doc/templates/pullQuote.js.map +0 -1
  328. package/dist/doc/templates/quoteBlock.d.ts +0 -15
  329. package/dist/doc/templates/quoteBlock.d.ts.map +0 -1
  330. package/dist/doc/templates/quoteBlock.js +0 -101
  331. package/dist/doc/templates/quoteBlock.js.map +0 -1
  332. package/dist/doc/templates/sectionHeader.d.ts +0 -14
  333. package/dist/doc/templates/sectionHeader.d.ts.map +0 -1
  334. package/dist/doc/templates/sectionHeader.js +0 -97
  335. package/dist/doc/templates/sectionHeader.js.map +0 -1
  336. package/dist/doc/templates/statHighlight.d.ts +0 -15
  337. package/dist/doc/templates/statHighlight.d.ts.map +0 -1
  338. package/dist/doc/templates/statHighlight.js +0 -102
  339. package/dist/doc/templates/statHighlight.js.map +0 -1
  340. package/dist/doc/templates/titleBlock.d.ts +0 -13
  341. package/dist/doc/templates/titleBlock.d.ts.map +0 -1
  342. package/dist/doc/templates/titleBlock.js +0 -95
  343. package/dist/doc/templates/titleBlock.js.map +0 -1
  344. package/dist/doc/templates/twoColumn.d.ts +0 -15
  345. package/dist/doc/templates/twoColumn.d.ts.map +0 -1
  346. package/dist/doc/templates/twoColumn.js +0 -225
  347. package/dist/doc/templates/twoColumn.js.map +0 -1
  348. package/dist/doc/templates/videoPullQuote.d.ts +0 -20
  349. package/dist/doc/templates/videoPullQuote.d.ts.map +0 -1
  350. package/dist/doc/templates/videoPullQuote.js +0 -122
  351. package/dist/doc/templates/videoPullQuote.js.map +0 -1
  352. package/dist/doc/templates/videoWithCaption.d.ts +0 -20
  353. package/dist/doc/templates/videoWithCaption.d.ts.map +0 -1
  354. package/dist/doc/templates/videoWithCaption.js +0 -107
  355. package/dist/doc/templates/videoWithCaption.js.map +0 -1
  356. package/dist/doc/utils/animationUtils.d.ts +0 -34
  357. package/dist/doc/utils/animationUtils.d.ts.map +0 -1
  358. package/dist/doc/utils/animationUtils.js +0 -110
  359. package/dist/doc/utils/animationUtils.js.map +0 -1
  360. package/dist/doc/utils/themeUtils.d.ts +0 -64
  361. package/dist/doc/utils/themeUtils.d.ts.map +0 -1
  362. package/dist/doc/utils/themeUtils.js +0 -135
  363. package/dist/doc/utils/themeUtils.js.map +0 -1
  364. package/dist/generate/contentExtractor.d.ts +0 -112
  365. package/dist/generate/contentExtractor.d.ts.map +0 -1
  366. package/dist/generate/contentExtractor.js +0 -638
  367. package/dist/generate/contentExtractor.js.map +0 -1
  368. package/dist/generate/index.d.ts.map +0 -1
  369. package/dist/generate/slideshowGenerator.d.ts +0 -72
  370. package/dist/generate/slideshowGenerator.d.ts.map +0 -1
  371. package/dist/generate/slideshowGenerator.js +0 -159
  372. package/dist/generate/slideshowGenerator.js.map +0 -1
  373. package/dist/generate/templateMapper.d.ts +0 -23
  374. package/dist/generate/templateMapper.d.ts.map +0 -1
  375. package/dist/generate/templateMapper.js +0 -114
  376. package/dist/generate/templateMapper.js.map +0 -1
  377. package/dist/index.d.ts.map +0 -1
  378. package/dist/markdown/convert.d.ts +0 -71
  379. package/dist/markdown/convert.d.ts.map +0 -1
  380. package/dist/markdown/convert.js +0 -845
  381. package/dist/markdown/convert.js.map +0 -1
  382. package/dist/markdown/htmlParse.d.ts +0 -26
  383. package/dist/markdown/htmlParse.d.ts.map +0 -1
  384. package/dist/markdown/htmlParse.js +0 -195
  385. package/dist/markdown/htmlParse.js.map +0 -1
  386. package/dist/markdown/index.d.ts.map +0 -1
  387. package/dist/markdown/parse.d.ts +0 -27
  388. package/dist/markdown/parse.d.ts.map +0 -1
  389. package/dist/markdown/parse.js +0 -90
  390. package/dist/markdown/parse.js.map +0 -1
  391. package/dist/markdown/stringify.d.ts +0 -32
  392. package/dist/markdown/stringify.d.ts.map +0 -1
  393. package/dist/markdown/stringify.js +0 -108
  394. package/dist/markdown/stringify.js.map +0 -1
  395. package/dist/markdown/types.d.ts +0 -516
  396. package/dist/markdown/types.d.ts.map +0 -1
  397. package/dist/markdown/types.js +0 -17
  398. package/dist/markdown/types.js.map +0 -1
  399. package/dist/markdown/utils.d.ts +0 -78
  400. package/dist/markdown/utils.d.ts.map +0 -1
  401. package/dist/markdown/utils.js +0 -153
  402. package/dist/markdown/utils.js.map +0 -1
  403. package/dist/random/SeededRandom.d.ts +0 -50
  404. package/dist/random/SeededRandom.d.ts.map +0 -1
  405. package/dist/random/SeededRandom.js +0 -115
  406. package/dist/random/SeededRandom.js.map +0 -1
  407. package/dist/random/index.d.ts.map +0 -1
  408. package/dist/schemas/BlockTemplates.d.ts +0 -600
  409. package/dist/schemas/BlockTemplates.d.ts.map +0 -1
  410. package/dist/schemas/BlockTemplates.js +0 -72
  411. package/dist/schemas/BlockTemplates.js.map +0 -1
  412. package/dist/schemas/Doc.d.ts +0 -503
  413. package/dist/schemas/Doc.d.ts.map +0 -1
  414. package/dist/schemas/Doc.js +0 -90
  415. package/dist/schemas/Doc.js.map +0 -1
  416. package/dist/schemas/LayoutStrategy.d.ts +0 -84
  417. package/dist/schemas/LayoutStrategy.d.ts.map +0 -1
  418. package/dist/schemas/LayoutStrategy.js +0 -123
  419. package/dist/schemas/LayoutStrategy.js.map +0 -1
  420. package/dist/schemas/MediaProvider.d.ts +0 -65
  421. package/dist/schemas/MediaProvider.d.ts.map +0 -1
  422. package/dist/schemas/MediaProvider.js +0 -13
  423. package/dist/schemas/MediaProvider.js.map +0 -1
  424. package/dist/schemas/Theme.d.ts +0 -194
  425. package/dist/schemas/Theme.d.ts.map +0 -1
  426. package/dist/schemas/Theme.js +0 -97
  427. package/dist/schemas/Theme.js.map +0 -1
  428. package/dist/schemas/Types.d.ts +0 -14
  429. package/dist/schemas/Types.d.ts.map +0 -1
  430. package/dist/schemas/Types.js +0 -5
  431. package/dist/schemas/Types.js.map +0 -1
  432. package/dist/schemas/Viewport.d.ts +0 -74
  433. package/dist/schemas/Viewport.d.ts.map +0 -1
  434. package/dist/schemas/Viewport.js +0 -63
  435. package/dist/schemas/Viewport.js.map +0 -1
  436. package/dist/schemas/index.d.ts.map +0 -1
  437. package/dist/schemas/themeLibrary.d.ts +0 -41
  438. package/dist/schemas/themeLibrary.d.ts.map +0 -1
  439. package/dist/schemas/themeLibrary.js +0 -597
  440. package/dist/schemas/themeLibrary.js.map +0 -1
  441. package/dist/spatial/Geohash.d.ts +0 -85
  442. package/dist/spatial/Geohash.d.ts.map +0 -1
  443. package/dist/spatial/Geohash.js +0 -142
  444. package/dist/spatial/Geohash.js.map +0 -1
  445. package/dist/spatial/Haversine.d.ts +0 -24
  446. package/dist/spatial/Haversine.d.ts.map +0 -1
  447. package/dist/spatial/Haversine.js +0 -48
  448. package/dist/spatial/Haversine.js.map +0 -1
  449. package/dist/spatial/index.d.ts.map +0 -1
  450. package/dist/storage/ContentContainer.d.ts +0 -87
  451. package/dist/storage/ContentContainer.d.ts.map +0 -1
  452. package/dist/storage/ContentContainer.js +0 -131
  453. package/dist/storage/ContentContainer.js.map +0 -1
  454. package/dist/storage/LocalForageAdapter.d.ts +0 -36
  455. package/dist/storage/LocalForageAdapter.d.ts.map +0 -1
  456. package/dist/storage/LocalForageAdapter.js +0 -82
  457. package/dist/storage/LocalForageAdapter.js.map +0 -1
  458. package/dist/storage/LocalStorageAdapter.d.ts +0 -16
  459. package/dist/storage/LocalStorageAdapter.d.ts.map +0 -1
  460. package/dist/storage/LocalStorageAdapter.js +0 -50
  461. package/dist/storage/LocalStorageAdapter.js.map +0 -1
  462. package/dist/storage/MediaProviderFromContainer.d.ts +0 -21
  463. package/dist/storage/MediaProviderFromContainer.d.ts.map +0 -1
  464. package/dist/storage/MediaProviderFromContainer.js +0 -79
  465. package/dist/storage/MediaProviderFromContainer.js.map +0 -1
  466. package/dist/storage/MemoryStorageAdapter.d.ts +0 -15
  467. package/dist/storage/MemoryStorageAdapter.d.ts.map +0 -1
  468. package/dist/storage/MemoryStorageAdapter.js +0 -34
  469. package/dist/storage/MemoryStorageAdapter.js.map +0 -1
  470. package/dist/storage/Storage.d.ts +0 -23
  471. package/dist/storage/Storage.d.ts.map +0 -1
  472. package/dist/storage/Storage.js +0 -9
  473. package/dist/storage/Storage.js.map +0 -1
  474. package/dist/storage/index.d.ts.map +0 -1
  475. package/dist/themeLibrary-CEo2D4b6.d.ts +0 -44
  476. package/dist/timing/index.d.ts.map +0 -1
  477. package/dist/timing/narrationTiming.d.ts +0 -54
  478. package/dist/timing/narrationTiming.d.ts.map +0 -1
  479. package/dist/timing/narrationTiming.js +0 -190
  480. package/dist/timing/narrationTiming.js.map +0 -1
  481. package/dist/timing/readingTime.d.ts +0 -54
  482. package/dist/timing/readingTime.d.ts.map +0 -1
  483. package/dist/timing/readingTime.js +0 -49
  484. package/dist/timing/readingTime.js.map +0 -1
  485. package/dist/transform/applyTransform.d.ts +0 -22
  486. package/dist/transform/applyTransform.d.ts.map +0 -1
  487. package/dist/transform/applyTransform.js +0 -68
  488. package/dist/transform/applyTransform.js.map +0 -1
  489. package/dist/transform/blockAnalyzer.d.ts +0 -48
  490. package/dist/transform/blockAnalyzer.d.ts.map +0 -1
  491. package/dist/transform/blockAnalyzer.js +0 -135
  492. package/dist/transform/blockAnalyzer.js.map +0 -1
  493. package/dist/transform/index.d.ts.map +0 -1
  494. package/dist/transform/registry.d.ts +0 -19
  495. package/dist/transform/registry.d.ts.map +0 -1
  496. package/dist/transform/registry.js +0 -41
  497. package/dist/transform/registry.js.map +0 -1
  498. package/dist/transform/styles/dataDriven.d.ts +0 -4
  499. package/dist/transform/styles/dataDriven.d.ts.map +0 -1
  500. package/dist/transform/styles/dataDriven.js +0 -15
  501. package/dist/transform/styles/dataDriven.js.map +0 -1
  502. package/dist/transform/styles/documentary.d.ts +0 -4
  503. package/dist/transform/styles/documentary.d.ts.map +0 -1
  504. package/dist/transform/styles/documentary.js +0 -15
  505. package/dist/transform/styles/documentary.js.map +0 -1
  506. package/dist/transform/styles/index.d.ts +0 -6
  507. package/dist/transform/styles/index.d.ts.map +0 -1
  508. package/dist/transform/styles/index.js +0 -6
  509. package/dist/transform/styles/index.js.map +0 -1
  510. package/dist/transform/styles/magazine.d.ts +0 -4
  511. package/dist/transform/styles/magazine.d.ts.map +0 -1
  512. package/dist/transform/styles/magazine.js +0 -15
  513. package/dist/transform/styles/magazine.js.map +0 -1
  514. package/dist/transform/styles/minimal.d.ts +0 -4
  515. package/dist/transform/styles/minimal.d.ts.map +0 -1
  516. package/dist/transform/styles/minimal.js +0 -15
  517. package/dist/transform/styles/minimal.js.map +0 -1
  518. package/dist/transform/styles/narrative.d.ts +0 -4
  519. package/dist/transform/styles/narrative.d.ts.map +0 -1
  520. package/dist/transform/styles/narrative.js +0 -15
  521. package/dist/transform/styles/narrative.js.map +0 -1
  522. package/dist/transform/templateSelector.d.ts +0 -30
  523. package/dist/transform/templateSelector.d.ts.map +0 -1
  524. package/dist/transform/templateSelector.js +0 -218
  525. package/dist/transform/templateSelector.js.map +0 -1
  526. package/dist/transform/timingAllocator.d.ts +0 -21
  527. package/dist/transform/timingAllocator.d.ts.map +0 -1
  528. package/dist/transform/timingAllocator.js +0 -111
  529. package/dist/transform/timingAllocator.js.map +0 -1
  530. package/dist/transform/types.d.ts +0 -86
  531. package/dist/transform/types.d.ts.map +0 -1
  532. package/dist/transform/types.js +0 -9
  533. package/dist/transform/types.js.map +0 -1
@@ -1,845 +0,0 @@
1
- /**
2
- * mdast ↔ Squisq Markdown Node Conversion
3
- *
4
- * Converts between the remark/mdast AST format and the squisq
5
- * MarkdownDocument JSON format. This is the bridge layer that allows
6
- * us to use the battle-tested unified/remark ecosystem for parsing
7
- * and serialization while exposing our own clean, well-typed interfaces.
8
- *
9
- * The conversion is designed for perfect round-tripping:
10
- * toMdast(fromMdast(tree)) should produce an equivalent mdast tree.
11
- */
12
- import { parseHtmlToNodes } from './htmlParse.js';
13
- // ============================================
14
- // Position conversion
15
- // ============================================
16
- function convertPosition(pos) {
17
- if (!pos)
18
- return undefined;
19
- return {
20
- start: {
21
- line: pos.start.line,
22
- column: pos.start.column,
23
- ...(pos.start.offset != null ? { offset: pos.start.offset } : {}),
24
- },
25
- end: {
26
- line: pos.end.line,
27
- column: pos.end.column,
28
- ...(pos.end.offset != null ? { offset: pos.end.offset } : {}),
29
- },
30
- };
31
- }
32
- function toMdastPosition(pos) {
33
- return {
34
- start: {
35
- line: pos.start.line,
36
- column: pos.start.column,
37
- ...(pos.start.offset != null ? { offset: pos.start.offset } : {}),
38
- },
39
- end: {
40
- line: pos.end.line,
41
- column: pos.end.column,
42
- ...(pos.end.offset != null ? { offset: pos.end.offset } : {}),
43
- },
44
- };
45
- }
46
- /** Conditionally include position in node. */
47
- function posField(pos) {
48
- return pos ? { position: pos } : {};
49
- }
50
- function mdastPosField(pos) {
51
- return pos ? { position: toMdastPosition(pos) } : {};
52
- }
53
- // ============================================
54
- // mdast → Squisq (fromMdast)
55
- // ============================================
56
- /**
57
- * Extract plain text content from an mdast node tree.
58
- * Used for directive labels.
59
- */
60
- function extractText(node) {
61
- if (node.value != null)
62
- return node.value;
63
- if (node.children) {
64
- return node.children.map(extractText).join('');
65
- }
66
- return '';
67
- }
68
- // ============================================
69
- // Template annotation helpers
70
- // ============================================
71
- /**
72
- * Regex matching a trailing `{[templateName key=value …]}` annotation.
73
- * Captures the content between `{[` and `]}`.
74
- */
75
- const TEMPLATE_ANNOTATION_RE = /\s*\{\[([^\]]+)\]\}\s*$/;
76
- /**
77
- * Extract a `{[templateName key=value …]}` annotation from a heading's
78
- * inline children. Mutates the children array in-place: strips the
79
- * annotation text from the last text node (or removes the node entirely).
80
- *
81
- * @returns The parsed annotation, or null if none found.
82
- */
83
- function extractTemplateAnnotation(children) {
84
- // Walk backwards to find the last text node
85
- for (let i = children.length - 1; i >= 0; i--) {
86
- const child = children[i];
87
- if (child.type === 'text') {
88
- const match = child.value.match(TEMPLATE_ANNOTATION_RE);
89
- if (match) {
90
- const inner = match[1].trim();
91
- const annotation = parseAnnotationTokens(inner);
92
- // Strip the matched portion from the text
93
- const stripped = child.value.slice(0, match.index).replace(/\s+$/, '');
94
- if (stripped) {
95
- child.value = stripped;
96
- }
97
- else {
98
- // Remove the now-empty text node
99
- children.splice(i, 1);
100
- }
101
- return annotation;
102
- }
103
- // Only check the last text node (trailing position)
104
- break;
105
- }
106
- // If the last child isn't a text node, there's no annotation
107
- break;
108
- }
109
- return null;
110
- }
111
- /**
112
- * Parse the inner content of a `{[…]}` annotation into template + params.
113
- *
114
- * Input: `"chart colorScheme=blue size=large"`
115
- * Output: `{ template: 'chart', params: { colorScheme: 'blue', size: 'large' } }`
116
- */
117
- function parseAnnotationTokens(inner) {
118
- const tokens = inner.split(/\s+/);
119
- const params = {};
120
- // If the first token contains '=', there's no template name —
121
- // the annotation is purely key-value (e.g., `{[audio=intro.mp3]}`).
122
- const firstIsParam = tokens[0].indexOf('=') > 0;
123
- const template = firstIsParam ? undefined : tokens[0];
124
- const startIdx = firstIsParam ? 0 : 1;
125
- for (let i = startIdx; i < tokens.length; i++) {
126
- const eqIdx = tokens[i].indexOf('=');
127
- if (eqIdx > 0) {
128
- params[tokens[i].slice(0, eqIdx)] = tokens[i].slice(eqIdx + 1);
129
- }
130
- }
131
- const result = {};
132
- if (template) {
133
- result.template = template;
134
- }
135
- if (Object.keys(params).length > 0) {
136
- result.params = params;
137
- }
138
- return result;
139
- }
140
- /**
141
- * Serialize a HeadingTemplateAnnotation back to `{[templateName key=value …]}` text.
142
- */
143
- function serializeTemplateAnnotation(annotation) {
144
- const parts = [];
145
- if (annotation.template) {
146
- parts.push(annotation.template);
147
- }
148
- if (annotation.params) {
149
- for (const [key, value] of Object.entries(annotation.params)) {
150
- parts.push(`${key}=${value}`);
151
- }
152
- }
153
- return `{[${parts.join(' ')}]}`;
154
- }
155
- /**
156
- * Convert an mdast Root node to a MarkdownDocument.
157
- *
158
- * @param root - The mdast root node (from remark-parse)
159
- * @param options - Conversion options
160
- * @returns A MarkdownDocument
161
- */
162
- export function fromMdast(root, options) {
163
- const doParseHtml = options?.parseHtml !== false;
164
- return {
165
- type: 'document',
166
- children: convertBlockChildren(root.children ?? [], doParseHtml),
167
- ...posField(convertPosition(root.position)),
168
- };
169
- }
170
- function convertBlockChildren(children, parseHtml) {
171
- const result = [];
172
- for (const child of children) {
173
- const node = convertBlockNode(child, parseHtml);
174
- if (node)
175
- result.push(node);
176
- }
177
- return result;
178
- }
179
- function convertInlineChildren(children, parseHtml) {
180
- const result = [];
181
- for (const child of children) {
182
- const node = convertInlineNode(child, parseHtml);
183
- if (node)
184
- result.push(node);
185
- }
186
- return coalesceMentions(result);
187
- }
188
- /**
189
- * Post-process an inline-children list to collapse `text('@') + link(scheme:id)`
190
- * pairs into a single `mention` node. The wire format `@[Display](scheme:id)`
191
- * comes back from remark as two adjacent nodes — we merge them so consumers
192
- * see a single atomic mention. A plain link whose URL doesn't have `scheme:id`
193
- * shape, or that isn't immediately preceded by `@`, is left alone so ordinary
194
- * links keep working.
195
- */
196
- function coalesceMentions(inlines) {
197
- const out = [];
198
- for (const cur of inlines) {
199
- const prev = out[out.length - 1];
200
- if (cur.type === 'link' &&
201
- typeof cur.url === 'string' &&
202
- prev &&
203
- prev.type === 'text' &&
204
- prev.value.endsWith('@')) {
205
- const schemeMatch = cur.url.match(/^([a-z][a-z0-9+.-]*):(.+)$/i);
206
- if (schemeMatch && schemeMatch[1] && schemeMatch[2]) {
207
- const targetKind = schemeMatch[1];
208
- const targetId = schemeMatch[2];
209
- const displayName = extractInlineText(cur.children);
210
- if (prev.value === '@') {
211
- out.pop();
212
- }
213
- else {
214
- prev.value = prev.value.slice(0, -1);
215
- }
216
- out.push({
217
- type: 'mention',
218
- targetKind,
219
- targetId,
220
- displayName,
221
- ...(cur.position ? { position: cur.position } : {}),
222
- });
223
- continue;
224
- }
225
- }
226
- out.push(cur);
227
- }
228
- return out;
229
- }
230
- /** Plain-text of an inline children list — used to pull the display name
231
- * out of a mention link's children. */
232
- function extractInlineText(nodes) {
233
- let out = '';
234
- for (const n of nodes) {
235
- if (n.type === 'text' || n.type === 'inlineCode')
236
- out += n.value;
237
- else if ('children' in n && Array.isArray(n.children)) {
238
- out += extractInlineText(n.children);
239
- }
240
- }
241
- return out;
242
- }
243
- function convertBlockNode(node, parseHtml) {
244
- const pos = convertPosition(node.position);
245
- switch (node.type) {
246
- case 'heading': {
247
- const headingChildren = convertInlineChildren(node.children ?? [], parseHtml);
248
- const annotation = extractTemplateAnnotation(headingChildren);
249
- const result = {
250
- type: 'heading',
251
- depth: (node.depth ?? 1),
252
- children: headingChildren,
253
- ...posField(pos),
254
- };
255
- if (annotation) {
256
- result.templateAnnotation = annotation;
257
- }
258
- return result;
259
- }
260
- case 'paragraph':
261
- return {
262
- type: 'paragraph',
263
- children: convertInlineChildren(node.children ?? [], parseHtml),
264
- ...posField(pos),
265
- };
266
- case 'blockquote':
267
- return {
268
- type: 'blockquote',
269
- children: convertBlockChildren(node.children ?? [], parseHtml),
270
- ...posField(pos),
271
- };
272
- case 'list':
273
- return {
274
- type: 'list',
275
- ordered: node.ordered ?? false,
276
- ...(node.start != null ? { start: node.start } : {}),
277
- ...(node.spread != null ? { spread: node.spread } : {}),
278
- children: (node.children ?? []).map((item) => convertListItem(item, parseHtml)),
279
- ...posField(pos),
280
- };
281
- case 'code':
282
- return {
283
- type: 'code',
284
- ...(node.lang != null ? { lang: node.lang } : {}),
285
- ...(node.meta != null ? { meta: node.meta } : {}),
286
- value: node.value ?? '',
287
- ...posField(pos),
288
- };
289
- case 'thematicBreak':
290
- return {
291
- type: 'thematicBreak',
292
- ...posField(pos),
293
- };
294
- case 'table':
295
- return {
296
- type: 'table',
297
- ...(node.align
298
- ? { align: node.align.map((a) => a) }
299
- : {}),
300
- children: (node.children ?? []).map((row, i) => convertTableRow(row, i === 0, parseHtml)),
301
- ...posField(pos),
302
- };
303
- case 'html':
304
- return {
305
- type: 'htmlBlock',
306
- rawHtml: node.value ?? '',
307
- htmlChildren: parseHtml ? parseHtmlToNodes(node.value ?? '') : [],
308
- ...posField(pos),
309
- };
310
- case 'math':
311
- return {
312
- type: 'math',
313
- value: node.value ?? '',
314
- ...(node.meta != null ? { meta: node.meta } : {}),
315
- ...posField(pos),
316
- };
317
- case 'definition':
318
- return {
319
- type: 'definition',
320
- identifier: node.identifier ?? '',
321
- ...(node.label != null ? { label: node.label } : {}),
322
- url: node.url ?? '',
323
- ...(node.title != null ? { title: node.title } : {}),
324
- ...posField(pos),
325
- };
326
- case 'footnoteDefinition':
327
- return {
328
- type: 'footnoteDefinition',
329
- identifier: node.identifier ?? '',
330
- ...(node.label != null ? { label: node.label } : {}),
331
- children: convertBlockChildren(node.children ?? [], parseHtml),
332
- ...posField(pos),
333
- };
334
- case 'containerDirective': {
335
- const allChildren = node.children ?? [];
336
- let label;
337
- let contentChildren = allChildren;
338
- // Extract directive label (first paragraph with directiveLabel flag)
339
- if (allChildren.length > 0 &&
340
- allChildren[0].type === 'paragraph' &&
341
- allChildren[0].data?.directiveLabel === true) {
342
- label = extractText(allChildren[0]);
343
- contentChildren = allChildren.slice(1);
344
- }
345
- return {
346
- type: 'containerDirective',
347
- name: node.name ?? '',
348
- ...(label ? { label } : {}),
349
- ...(node.attributes && Object.keys(node.attributes).length > 0
350
- ? { attributes: node.attributes }
351
- : {}),
352
- children: convertBlockChildren(contentChildren, parseHtml),
353
- ...posField(pos),
354
- };
355
- }
356
- case 'leafDirective':
357
- return {
358
- type: 'leafDirective',
359
- name: node.name ?? '',
360
- ...(node.attributes && Object.keys(node.attributes).length > 0
361
- ? { attributes: node.attributes }
362
- : {}),
363
- children: convertInlineChildren(node.children ?? [], parseHtml),
364
- ...posField(pos),
365
- };
366
- case 'yaml':
367
- // YAML frontmatter nodes are handled separately in parse.ts — skip silently
368
- return null;
369
- default:
370
- // Unknown block node — skip with a warning
371
- if (typeof console !== 'undefined') {
372
- console.warn(`[squisq/markdown] Unknown mdast block node type: "${node.type}"`);
373
- }
374
- return null;
375
- }
376
- }
377
- function convertListItem(node, parseHtml) {
378
- const pos = convertPosition(node.position);
379
- return {
380
- type: 'listItem',
381
- ...(node.checked != null ? { checked: node.checked } : {}),
382
- ...(node.spread != null ? { spread: node.spread } : {}),
383
- children: convertBlockChildren(node.children ?? [], parseHtml),
384
- ...posField(pos),
385
- };
386
- }
387
- function convertTableRow(node, isHeader, parseHtml) {
388
- const pos = convertPosition(node.position);
389
- return {
390
- type: 'tableRow',
391
- children: (node.children ?? []).map((cell) => convertTableCell(cell, isHeader, parseHtml)),
392
- ...posField(pos),
393
- };
394
- }
395
- function convertTableCell(node, isHeader, parseHtml) {
396
- const pos = convertPosition(node.position);
397
- return {
398
- type: 'tableCell',
399
- ...(isHeader ? { isHeader: true } : {}),
400
- children: convertInlineChildren(node.children ?? [], parseHtml),
401
- ...posField(pos),
402
- };
403
- }
404
- function convertInlineNode(node, parseHtml) {
405
- const pos = convertPosition(node.position);
406
- switch (node.type) {
407
- case 'text':
408
- return {
409
- type: 'text',
410
- value: node.value ?? '',
411
- ...posField(pos),
412
- };
413
- case 'emphasis':
414
- return {
415
- type: 'emphasis',
416
- children: convertInlineChildren(node.children ?? [], parseHtml),
417
- ...posField(pos),
418
- };
419
- case 'strong':
420
- return {
421
- type: 'strong',
422
- children: convertInlineChildren(node.children ?? [], parseHtml),
423
- ...posField(pos),
424
- };
425
- case 'delete':
426
- return {
427
- type: 'delete',
428
- children: convertInlineChildren(node.children ?? [], parseHtml),
429
- ...posField(pos),
430
- };
431
- case 'inlineCode':
432
- return {
433
- type: 'inlineCode',
434
- value: node.value ?? '',
435
- ...posField(pos),
436
- };
437
- case 'link':
438
- return {
439
- type: 'link',
440
- url: node.url ?? '',
441
- ...(node.title != null ? { title: node.title } : {}),
442
- children: convertInlineChildren(node.children ?? [], parseHtml),
443
- ...posField(pos),
444
- };
445
- case 'image':
446
- return {
447
- type: 'image',
448
- url: node.url ?? '',
449
- ...(node.alt != null ? { alt: node.alt } : {}),
450
- ...(node.title != null ? { title: node.title } : {}),
451
- ...posField(pos),
452
- };
453
- case 'break':
454
- return {
455
- type: 'break',
456
- ...posField(pos),
457
- };
458
- case 'html':
459
- return {
460
- type: 'htmlInline',
461
- rawHtml: node.value ?? '',
462
- htmlChildren: parseHtml ? parseHtmlToNodes(node.value ?? '') : [],
463
- ...posField(pos),
464
- };
465
- case 'inlineMath':
466
- return {
467
- type: 'inlineMath',
468
- value: node.value ?? '',
469
- ...posField(pos),
470
- };
471
- case 'footnoteReference':
472
- return {
473
- type: 'footnoteReference',
474
- identifier: node.identifier ?? '',
475
- ...(node.label != null ? { label: node.label } : {}),
476
- ...posField(pos),
477
- };
478
- case 'linkReference':
479
- return {
480
- type: 'linkReference',
481
- identifier: node.identifier ?? '',
482
- ...(node.label != null ? { label: node.label } : {}),
483
- referenceType: (node.referenceType ?? 'full'),
484
- children: convertInlineChildren(node.children ?? [], parseHtml),
485
- ...posField(pos),
486
- };
487
- case 'imageReference':
488
- return {
489
- type: 'imageReference',
490
- identifier: node.identifier ?? '',
491
- ...(node.label != null ? { label: node.label } : {}),
492
- referenceType: (node.referenceType ?? 'full'),
493
- ...(node.alt != null ? { alt: node.alt } : {}),
494
- ...posField(pos),
495
- };
496
- case 'textDirective':
497
- return {
498
- type: 'textDirective',
499
- name: node.name ?? '',
500
- ...(node.attributes && Object.keys(node.attributes).length > 0
501
- ? { attributes: node.attributes }
502
- : {}),
503
- children: convertInlineChildren(node.children ?? [], parseHtml),
504
- ...posField(pos),
505
- };
506
- default:
507
- if (typeof console !== 'undefined') {
508
- console.warn(`[squisq/markdown] Unknown mdast inline node type: "${node.type}"`);
509
- }
510
- return null;
511
- }
512
- }
513
- // ============================================
514
- // Squisq → mdast (toMdast)
515
- // ============================================
516
- /**
517
- * Convert a MarkdownDocument back to an mdast Root node.
518
- *
519
- * @param doc - A MarkdownDocument
520
- * @returns An mdast Root node suitable for remark-stringify
521
- */
522
- export function toMdast(doc) {
523
- return {
524
- type: 'root',
525
- children: doc.children.map((n) => blockToMdast(n)),
526
- ...mdastPosField(doc.position),
527
- };
528
- }
529
- function blockToMdast(node) {
530
- switch (node.type) {
531
- case 'heading': {
532
- const mdastChildren = inlineChildrenToMdast(node.children);
533
- if (node.templateAnnotation) {
534
- const suffix = serializeTemplateAnnotation(node.templateAnnotation);
535
- // Append to last text node, or create a new one
536
- const lastChild = mdastChildren[mdastChildren.length - 1];
537
- if (lastChild && lastChild.type === 'text') {
538
- lastChild.value = (lastChild.value ?? '') + ' ' + suffix;
539
- }
540
- else {
541
- mdastChildren.push({ type: 'text', value: ' ' + suffix });
542
- }
543
- }
544
- return {
545
- type: 'heading',
546
- depth: node.depth,
547
- children: mdastChildren,
548
- ...mdastPosField(node.position),
549
- };
550
- }
551
- case 'paragraph':
552
- return {
553
- type: 'paragraph',
554
- children: inlineChildrenToMdast(node.children),
555
- ...mdastPosField(node.position),
556
- };
557
- case 'blockquote':
558
- return {
559
- type: 'blockquote',
560
- children: node.children.map(blockToMdast),
561
- ...mdastPosField(node.position),
562
- };
563
- case 'list':
564
- return {
565
- type: 'list',
566
- ordered: node.ordered,
567
- ...(node.start != null ? { start: node.start } : {}),
568
- ...(node.spread != null ? { spread: node.spread } : {}),
569
- children: node.children.map(listItemToMdast),
570
- ...mdastPosField(node.position),
571
- };
572
- case 'code':
573
- return {
574
- type: 'code',
575
- ...(node.lang != null ? { lang: node.lang } : {}),
576
- ...(node.meta != null ? { meta: node.meta } : {}),
577
- value: node.value,
578
- ...mdastPosField(node.position),
579
- };
580
- case 'thematicBreak':
581
- return {
582
- type: 'thematicBreak',
583
- ...mdastPosField(node.position),
584
- };
585
- case 'table':
586
- return {
587
- type: 'table',
588
- ...(node.align ? { align: node.align } : {}),
589
- children: node.children.map(tableRowToMdast),
590
- ...mdastPosField(node.position),
591
- };
592
- case 'htmlBlock':
593
- return {
594
- type: 'html',
595
- value: node.rawHtml,
596
- ...mdastPosField(node.position),
597
- };
598
- case 'math':
599
- return {
600
- type: 'math',
601
- value: node.value,
602
- ...(node.meta != null ? { meta: node.meta } : {}),
603
- ...mdastPosField(node.position),
604
- };
605
- case 'definition':
606
- return {
607
- type: 'definition',
608
- identifier: node.identifier,
609
- ...(node.label != null ? { label: node.label } : {}),
610
- url: node.url,
611
- ...(node.title != null ? { title: node.title } : {}),
612
- ...mdastPosField(node.position),
613
- };
614
- case 'footnoteDefinition':
615
- return {
616
- type: 'footnoteDefinition',
617
- identifier: node.identifier,
618
- ...(node.label != null ? { label: node.label } : {}),
619
- children: node.children.map(blockToMdast),
620
- ...mdastPosField(node.position),
621
- };
622
- case 'containerDirective': {
623
- const children = [];
624
- // Reinject label as first paragraph with directiveLabel flag
625
- if (node.label) {
626
- children.push({
627
- type: 'paragraph',
628
- data: { directiveLabel: true },
629
- children: [{ type: 'text', value: node.label }],
630
- });
631
- }
632
- children.push(...node.children.map(blockToMdast));
633
- return {
634
- type: 'containerDirective',
635
- name: node.name,
636
- ...(node.attributes ? { attributes: node.attributes } : {}),
637
- children,
638
- ...mdastPosField(node.position),
639
- };
640
- }
641
- case 'leafDirective':
642
- return {
643
- type: 'leafDirective',
644
- name: node.name,
645
- ...(node.attributes ? { attributes: node.attributes } : {}),
646
- children: inlineChildrenToMdast(node.children),
647
- ...mdastPosField(node.position),
648
- };
649
- case 'definitionList':
650
- // Definition lists don't map to standard mdast.
651
- // Convert to HTML as fallback.
652
- return {
653
- type: 'html',
654
- value: definitionListToHtml(node),
655
- ...mdastPosField(node.position),
656
- };
657
- default:
658
- return { type: 'html', value: '' };
659
- }
660
- }
661
- function listItemToMdast(item) {
662
- return {
663
- type: 'listItem',
664
- ...(item.checked != null ? { checked: item.checked } : {}),
665
- ...(item.spread != null ? { spread: item.spread } : {}),
666
- children: item.children.map(blockToMdast),
667
- ...mdastPosField(item.position),
668
- };
669
- }
670
- function tableRowToMdast(row) {
671
- return {
672
- type: 'tableRow',
673
- children: row.children.map(tableCellToMdast),
674
- ...mdastPosField(row.position),
675
- };
676
- }
677
- function tableCellToMdast(cell) {
678
- return {
679
- type: 'tableCell',
680
- children: inlineChildrenToMdast(cell.children),
681
- ...mdastPosField(cell.position),
682
- };
683
- }
684
- /**
685
- * Serialize an array of inline nodes to mdast, flat-mapping the result so
686
- * a single `mention` expands to two mdast nodes (`text('@')` + `link`).
687
- * Use in place of `.map(inlineToMdast)` wherever we walk a children array.
688
- */
689
- function inlineChildrenToMdast(nodes) {
690
- const out = [];
691
- for (const n of nodes) {
692
- if (n.type === 'mention') {
693
- out.push({ type: 'text', value: '@' });
694
- out.push({
695
- type: 'link',
696
- url: `${n.targetKind}:${n.targetId}`,
697
- children: [{ type: 'text', value: n.displayName }],
698
- ...mdastPosField(n.position),
699
- });
700
- }
701
- else {
702
- out.push(inlineToMdast(n));
703
- }
704
- }
705
- return out;
706
- }
707
- function inlineToMdast(node) {
708
- switch (node.type) {
709
- case 'text':
710
- return {
711
- type: 'text',
712
- value: node.value,
713
- ...mdastPosField(node.position),
714
- };
715
- case 'emphasis':
716
- return {
717
- type: 'emphasis',
718
- children: inlineChildrenToMdast(node.children),
719
- ...mdastPosField(node.position),
720
- };
721
- case 'strong':
722
- return {
723
- type: 'strong',
724
- children: inlineChildrenToMdast(node.children),
725
- ...mdastPosField(node.position),
726
- };
727
- case 'delete':
728
- return {
729
- type: 'delete',
730
- children: inlineChildrenToMdast(node.children),
731
- ...mdastPosField(node.position),
732
- };
733
- case 'inlineCode':
734
- return {
735
- type: 'inlineCode',
736
- value: node.value,
737
- ...mdastPosField(node.position),
738
- };
739
- case 'link':
740
- return {
741
- type: 'link',
742
- url: node.url,
743
- ...(node.title != null ? { title: node.title } : {}),
744
- children: inlineChildrenToMdast(node.children),
745
- ...mdastPosField(node.position),
746
- };
747
- case 'image':
748
- return {
749
- type: 'image',
750
- url: node.url,
751
- ...(node.alt != null ? { alt: node.alt } : {}),
752
- ...(node.title != null ? { title: node.title } : {}),
753
- ...mdastPosField(node.position),
754
- };
755
- case 'break':
756
- return {
757
- type: 'break',
758
- ...mdastPosField(node.position),
759
- };
760
- case 'htmlInline':
761
- return {
762
- type: 'html',
763
- value: node.rawHtml,
764
- ...mdastPosField(node.position),
765
- };
766
- case 'inlineMath':
767
- return {
768
- type: 'inlineMath',
769
- value: node.value,
770
- ...mdastPosField(node.position),
771
- };
772
- case 'footnoteReference':
773
- return {
774
- type: 'footnoteReference',
775
- identifier: node.identifier,
776
- ...(node.label != null ? { label: node.label } : {}),
777
- ...mdastPosField(node.position),
778
- };
779
- case 'linkReference':
780
- return {
781
- type: 'linkReference',
782
- identifier: node.identifier,
783
- ...(node.label != null ? { label: node.label } : {}),
784
- referenceType: node.referenceType,
785
- children: inlineChildrenToMdast(node.children),
786
- ...mdastPosField(node.position),
787
- };
788
- case 'imageReference':
789
- return {
790
- type: 'imageReference',
791
- identifier: node.identifier,
792
- ...(node.label != null ? { label: node.label } : {}),
793
- referenceType: node.referenceType,
794
- ...(node.alt != null ? { alt: node.alt } : {}),
795
- ...mdastPosField(node.position),
796
- };
797
- case 'textDirective':
798
- return {
799
- type: 'textDirective',
800
- name: node.name,
801
- ...(node.attributes ? { attributes: node.attributes } : {}),
802
- children: inlineChildrenToMdast(node.children),
803
- ...mdastPosField(node.position),
804
- };
805
- case 'mention':
806
- // Fallback: when `inlineToMdast` is called directly (not via
807
- // `inlineChildrenToMdast`), collapse the mention to just the link
808
- // form. The `@` prefix is lost, but the id+name still round-trip.
809
- // Normal call sites go through `inlineChildrenToMdast` and get
810
- // the proper text('@') + link pair.
811
- return {
812
- type: 'link',
813
- url: `${node.targetKind}:${node.targetId}`,
814
- children: [{ type: 'text', value: node.displayName }],
815
- ...mdastPosField(node.position),
816
- };
817
- default:
818
- return { type: 'text', value: '' };
819
- }
820
- }
821
- // ============================================
822
- // Helpers
823
- // ============================================
824
- /**
825
- * Convert a MarkdownDefinitionList to an HTML <dl> string.
826
- * Fallback for serialization since mdast doesn't support definition lists.
827
- */
828
- function definitionListToHtml(list) {
829
- let html = '<dl>\n';
830
- for (const child of list.children) {
831
- if (child.type === 'definitionTerm') {
832
- // Extract plain text from inline children
833
- const text = child.children
834
- .map((c) => c.value ?? '')
835
- .join('');
836
- html += ` <dt>${text}</dt>\n`;
837
- }
838
- else if (child.type === 'definitionDescription') {
839
- html += ` <dd>...</dd>\n`;
840
- }
841
- }
842
- html += '</dl>';
843
- return html;
844
- }
845
- //# sourceMappingURL=convert.js.map