@tai42/studio-sdk 15.0.0 → 16.0.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 (322) hide show
  1. package/dist/components/explorer-body.d.ts +49 -0
  2. package/dist/components/explorer-body.d.ts.map +1 -0
  3. package/dist/components/explorer-body.js +67 -0
  4. package/dist/components/explorer-body.js.map +1 -0
  5. package/dist/components/explorer-page-size.d.ts +4 -0
  6. package/dist/components/explorer-page-size.d.ts.map +1 -0
  7. package/dist/components/explorer-page-size.js +36 -0
  8. package/dist/components/explorer-page-size.js.map +1 -0
  9. package/dist/components/explorer-tag-filter.d.ts +17 -0
  10. package/dist/components/explorer-tag-filter.d.ts.map +1 -0
  11. package/dist/components/explorer-tag-filter.js +29 -0
  12. package/dist/components/explorer-tag-filter.js.map +1 -0
  13. package/dist/components/explorer-tags.d.ts +22 -0
  14. package/dist/components/explorer-tags.d.ts.map +1 -0
  15. package/dist/components/explorer-tags.js +51 -0
  16. package/dist/components/explorer-tags.js.map +1 -0
  17. package/dist/components/explorer-view.d.ts +3 -17
  18. package/dist/components/explorer-view.d.ts.map +1 -1
  19. package/dist/components/explorer-view.js +53 -170
  20. package/dist/components/explorer-view.js.map +1 -1
  21. package/dist/components/extension-combo-builder.d.ts +0 -5
  22. package/dist/components/extension-combo-builder.d.ts.map +1 -1
  23. package/dist/components/extension-combo-builder.js +4 -42
  24. package/dist/components/extension-combo-builder.js.map +1 -1
  25. package/dist/components/extension-combo-parts.d.ts +44 -0
  26. package/dist/components/extension-combo-parts.d.ts.map +1 -0
  27. package/dist/components/extension-combo-parts.js +57 -0
  28. package/dist/components/extension-combo-parts.js.map +1 -0
  29. package/dist/components/fleet-report.d.ts.map +1 -1
  30. package/dist/components/fleet-report.js +51 -37
  31. package/dist/components/fleet-report.js.map +1 -1
  32. package/dist/components/icons/chrome-marks.d.ts +50 -0
  33. package/dist/components/icons/chrome-marks.d.ts.map +1 -0
  34. package/dist/components/icons/chrome-marks.js +51 -0
  35. package/dist/components/icons/chrome-marks.js.map +1 -0
  36. package/dist/components/icons/icon-frame.d.ts +29 -0
  37. package/dist/components/icons/icon-frame.d.ts.map +1 -0
  38. package/dist/components/icons/icon-frame.js +19 -0
  39. package/dist/components/icons/icon-frame.js.map +1 -0
  40. package/dist/components/icons/index.d.ts +40 -0
  41. package/dist/components/icons/index.d.ts.map +1 -0
  42. package/dist/components/icons/index.js +6 -0
  43. package/dist/components/icons/index.js.map +1 -0
  44. package/dist/components/icons/nav-map.d.ts +14 -0
  45. package/dist/components/icons/nav-map.d.ts.map +1 -0
  46. package/dist/components/icons/nav-map.js +28 -0
  47. package/dist/components/icons/nav-map.js.map +1 -0
  48. package/dist/components/icons/nav-marks.d.ts +44 -0
  49. package/dist/components/icons/nav-marks.d.ts.map +1 -0
  50. package/dist/components/icons/nav-marks.js +45 -0
  51. package/dist/components/icons/nav-marks.js.map +1 -0
  52. package/dist/components/icons/status-marks.d.ts +21 -0
  53. package/dist/components/icons/status-marks.d.ts.map +1 -0
  54. package/dist/components/icons/status-marks.js +22 -0
  55. package/dist/components/icons/status-marks.js.map +1 -0
  56. package/dist/components/icons/theme-marks.d.ts +9 -0
  57. package/dist/components/icons/theme-marks.d.ts.map +1 -0
  58. package/dist/components/icons/theme-marks.js +10 -0
  59. package/dist/components/icons/theme-marks.js.map +1 -0
  60. package/dist/components/json-diff.d.ts.map +1 -1
  61. package/dist/components/json-diff.js +1 -3
  62. package/dist/components/json-diff.js.map +1 -1
  63. package/dist/components/json-tree-context.d.ts +13 -0
  64. package/dist/components/json-tree-context.d.ts.map +1 -0
  65. package/dist/components/json-tree-context.js +15 -0
  66. package/dist/components/json-tree-context.js.map +1 -0
  67. package/dist/components/json-tree-model.d.ts +56 -0
  68. package/dist/components/json-tree-model.d.ts.map +1 -0
  69. package/dist/components/json-tree-model.js +125 -0
  70. package/dist/components/json-tree-model.js.map +1 -0
  71. package/dist/components/json-tree-nodes.d.ts +30 -0
  72. package/dist/components/json-tree-nodes.d.ts.map +1 -0
  73. package/dist/components/json-tree-nodes.js +118 -0
  74. package/dist/components/json-tree-nodes.js.map +1 -0
  75. package/dist/components/json-tree.d.ts.map +1 -1
  76. package/dist/components/json-tree.js +7 -295
  77. package/dist/components/json-tree.js.map +1 -1
  78. package/dist/components/json-value-format.d.ts +20 -0
  79. package/dist/components/json-value-format.d.ts.map +1 -0
  80. package/dist/components/json-value-format.js +63 -0
  81. package/dist/components/json-value-format.js.map +1 -0
  82. package/dist/components/markdown-blocks.d.ts +38 -0
  83. package/dist/components/markdown-blocks.d.ts.map +1 -0
  84. package/dist/components/markdown-blocks.js +168 -0
  85. package/dist/components/markdown-blocks.js.map +1 -0
  86. package/dist/components/markdown-inline.d.ts +24 -0
  87. package/dist/components/markdown-inline.d.ts.map +1 -0
  88. package/dist/components/markdown-inline.js +257 -0
  89. package/dist/components/markdown-inline.js.map +1 -0
  90. package/dist/components/markdown.d.ts +3 -52
  91. package/dist/components/markdown.d.ts.map +1 -1
  92. package/dist/components/markdown.js +4 -376
  93. package/dist/components/markdown.js.map +1 -1
  94. package/dist/components/observer-registry.d.ts +38 -0
  95. package/dist/components/observer-registry.d.ts.map +1 -0
  96. package/dist/components/observer-registry.js +131 -0
  97. package/dist/components/observer-registry.js.map +1 -0
  98. package/dist/components/overflow-measure.d.ts +38 -0
  99. package/dist/components/overflow-measure.d.ts.map +1 -0
  100. package/dist/components/overflow-measure.js +54 -0
  101. package/dist/components/overflow-measure.js.map +1 -0
  102. package/dist/components/prose-regions.d.ts +81 -0
  103. package/dist/components/prose-regions.d.ts.map +1 -0
  104. package/dist/components/prose-regions.js +128 -0
  105. package/dist/components/prose-regions.js.map +1 -0
  106. package/dist/components/scroll-region.d.ts.map +1 -1
  107. package/dist/components/scroll-region.js +3 -298
  108. package/dist/components/scroll-region.js.map +1 -1
  109. package/dist/components/tab-stop-parse.d.ts +53 -0
  110. package/dist/components/tab-stop-parse.d.ts.map +1 -0
  111. package/dist/components/tab-stop-parse.js +202 -0
  112. package/dist/components/tab-stop-parse.js.map +1 -0
  113. package/dist/components/templated-text-field.d.ts.map +1 -1
  114. package/dist/components/templated-text-field.js +10 -148
  115. package/dist/components/templated-text-field.js.map +1 -1
  116. package/dist/components/templated-text-kwargs-editor.d.ts +24 -0
  117. package/dist/components/templated-text-kwargs-editor.d.ts.map +1 -0
  118. package/dist/components/templated-text-kwargs-editor.js +48 -0
  119. package/dist/components/templated-text-kwargs-editor.js.map +1 -0
  120. package/dist/components/templated-text-kwargs.d.ts +37 -0
  121. package/dist/components/templated-text-kwargs.d.ts.map +1 -0
  122. package/dist/components/templated-text-kwargs.js +66 -0
  123. package/dist/components/templated-text-kwargs.js.map +1 -0
  124. package/dist/components/templated-text-source.d.ts +33 -0
  125. package/dist/components/templated-text-source.d.ts.map +1 -0
  126. package/dist/components/templated-text-source.js +53 -0
  127. package/dist/components/templated-text-source.js.map +1 -0
  128. package/dist/components/tool-picker-parts.d.ts +39 -0
  129. package/dist/components/tool-picker-parts.d.ts.map +1 -0
  130. package/dist/components/tool-picker-parts.js +87 -0
  131. package/dist/components/tool-picker-parts.js.map +1 -0
  132. package/dist/components/tool-picker.d.ts +1 -2
  133. package/dist/components/tool-picker.d.ts.map +1 -1
  134. package/dist/components/tool-picker.js +4 -66
  135. package/dist/components/tool-picker.js.map +1 -1
  136. package/dist/components/version-history-panel.d.ts.map +1 -1
  137. package/dist/components/version-history-panel.js +7 -34
  138. package/dist/components/version-history-panel.js.map +1 -1
  139. package/dist/components/version-history-rows.d.ts +48 -0
  140. package/dist/components/version-history-rows.d.ts.map +1 -0
  141. package/dist/components/version-history-rows.js +51 -0
  142. package/dist/components/version-history-rows.js.map +1 -0
  143. package/dist/guards.d.ts +6 -0
  144. package/dist/guards.d.ts.map +1 -0
  145. package/dist/guards.js +8 -0
  146. package/dist/guards.js.map +1 -0
  147. package/dist/hooks/interactions-connection.d.ts +43 -0
  148. package/dist/hooks/interactions-connection.d.ts.map +1 -0
  149. package/dist/hooks/interactions-connection.js +171 -0
  150. package/dist/hooks/interactions-connection.js.map +1 -0
  151. package/dist/hooks/interactions-stream.d.ts +80 -0
  152. package/dist/hooks/interactions-stream.d.ts.map +1 -0
  153. package/dist/hooks/interactions-stream.js +233 -0
  154. package/dist/hooks/interactions-stream.js.map +1 -0
  155. package/dist/hooks/useApi.d.ts +2409 -2293
  156. package/dist/hooks/useApi.d.ts.map +1 -1
  157. package/dist/hooks/useSse.d.ts +3 -6
  158. package/dist/hooks/useSse.d.ts.map +1 -1
  159. package/dist/hooks/useSse.js +38 -451
  160. package/dist/hooks/useSse.js.map +1 -1
  161. package/dist/navigation/app-link.d.ts +25 -0
  162. package/dist/navigation/app-link.d.ts.map +1 -0
  163. package/dist/navigation/app-link.js +33 -0
  164. package/dist/navigation/app-link.js.map +1 -0
  165. package/dist/navigation/context.d.ts +3 -20
  166. package/dist/navigation/context.d.ts.map +1 -1
  167. package/dist/navigation/context.js +7 -267
  168. package/dist/navigation/context.js.map +1 -1
  169. package/dist/navigation/entry-state.d.ts +23 -0
  170. package/dist/navigation/entry-state.d.ts.map +1 -0
  171. package/dist/navigation/entry-state.js +39 -0
  172. package/dist/navigation/entry-state.js.map +1 -0
  173. package/dist/navigation/guard-registry.d.ts +30 -0
  174. package/dist/navigation/guard-registry.d.ts.map +1 -0
  175. package/dist/navigation/guard-registry.js +46 -0
  176. package/dist/navigation/guard-registry.js.map +1 -0
  177. package/dist/navigation/guarded-navigation.d.ts +24 -0
  178. package/dist/navigation/guarded-navigation.d.ts.map +1 -0
  179. package/dist/navigation/guarded-navigation.js +102 -0
  180. package/dist/navigation/guarded-navigation.js.map +1 -0
  181. package/dist/navigation/index.d.ts +3 -2
  182. package/dist/navigation/index.d.ts.map +1 -1
  183. package/dist/navigation/index.js +2 -1
  184. package/dist/navigation/index.js.map +1 -1
  185. package/dist/navigation/types.d.ts +8 -11
  186. package/dist/navigation/types.d.ts.map +1 -1
  187. package/dist/navigation/use-back-forward-guard.d.ts +5 -0
  188. package/dist/navigation/use-back-forward-guard.d.ts.map +1 -0
  189. package/dist/navigation/use-back-forward-guard.js +82 -0
  190. package/dist/navigation/use-back-forward-guard.js.map +1 -0
  191. package/dist/plugin/registry.d.ts +6 -15
  192. package/dist/plugin/registry.d.ts.map +1 -1
  193. package/dist/plugin/registry.js +83 -75
  194. package/dist/plugin/registry.js.map +1 -1
  195. package/dist/schema-editor/SchemaEditor.d.ts +8 -1
  196. package/dist/schema-editor/SchemaEditor.d.ts.map +1 -1
  197. package/dist/schema-editor/SchemaEditor.js +2 -2
  198. package/dist/schema-editor/SchemaEditor.js.map +1 -1
  199. package/dist/schema-form/SecretRefField.d.ts +2 -3
  200. package/dist/schema-form/SecretRefField.d.ts.map +1 -1
  201. package/dist/schema-form/SecretRefField.js +23 -12
  202. package/dist/schema-form/SecretRefField.js.map +1 -1
  203. package/dist/schema-form/classify.d.ts +1 -122
  204. package/dist/schema-form/classify.d.ts.map +1 -1
  205. package/dist/schema-form/classify.js +174 -237
  206. package/dist/schema-form/classify.js.map +1 -1
  207. package/dist/schema-form/default-value.d.ts.map +1 -1
  208. package/dist/schema-form/default-value.js +42 -19
  209. package/dist/schema-form/default-value.js.map +1 -1
  210. package/dist/schema-form/enum-field.d.ts +1 -1
  211. package/dist/schema-form/enum-field.d.ts.map +1 -1
  212. package/dist/schema-form/field-model.d.ts +121 -0
  213. package/dist/schema-form/field-model.d.ts.map +1 -0
  214. package/dist/schema-form/field-model.js +2 -0
  215. package/dist/schema-form/field-model.js.map +1 -0
  216. package/dist/schema-form/field-node.d.ts.map +1 -1
  217. package/dist/schema-form/field-node.js +25 -14
  218. package/dist/schema-form/field-node.js.map +1 -1
  219. package/dist/schema-form/media-field.d.ts +1 -1
  220. package/dist/schema-form/media-field.d.ts.map +1 -1
  221. package/dist/schema-form/media-field.js +47 -28
  222. package/dist/schema-form/media-field.js.map +1 -1
  223. package/dist/schema-form/string-annotations.d.ts +20 -0
  224. package/dist/schema-form/string-annotations.d.ts.map +1 -0
  225. package/dist/schema-form/string-annotations.js +105 -0
  226. package/dist/schema-form/string-annotations.js.map +1 -0
  227. package/dist/schema-form/string-field.d.ts +1 -1
  228. package/dist/schema-form/string-field.d.ts.map +1 -1
  229. package/dist/schema-form/union-field.d.ts +1 -1
  230. package/dist/schema-form/union-field.d.ts.map +1 -1
  231. package/dist/schema-form/union-field.js.map +1 -1
  232. package/dist/schema-form/union.d.ts +1 -1
  233. package/dist/schema-form/union.d.ts.map +1 -1
  234. package/dist/schema-form/validate.d.ts.map +1 -1
  235. package/dist/schema-form/validate.js +126 -105
  236. package/dist/schema-form/validate.js.map +1 -1
  237. package/dist/state-binding/AdapterMapping.d.ts.map +1 -1
  238. package/dist/state-binding/AdapterMapping.js +0 -0
  239. package/dist/state-binding/AdapterMapping.js.map +1 -1
  240. package/dist/state-binding/StateAttachRow.d.ts.map +1 -1
  241. package/dist/state-binding/StateAttachRow.js +52 -36
  242. package/dist/state-binding/StateAttachRow.js.map +1 -1
  243. package/dist/state-binding/adapter-mapping-row.d.ts +17 -0
  244. package/dist/state-binding/adapter-mapping-row.d.ts.map +1 -0
  245. package/dist/state-binding/adapter-mapping-row.js +87 -0
  246. package/dist/state-binding/adapter-mapping-row.js.map +1 -0
  247. package/dist/structured-output/StructuredOutput.d.ts.map +1 -1
  248. package/dist/structured-output/StructuredOutput.js +1 -3
  249. package/dist/structured-output/StructuredOutput.js.map +1 -1
  250. package/package.json +2 -2
  251. package/src/components/explorer-body.tsx +239 -0
  252. package/src/components/explorer-page-size.ts +39 -0
  253. package/src/components/explorer-tag-filter.tsx +80 -0
  254. package/src/components/explorer-tags.ts +64 -0
  255. package/src/components/explorer-view.tsx +114 -366
  256. package/src/components/extension-combo-builder.tsx +35 -152
  257. package/src/components/extension-combo-parts.tsx +237 -0
  258. package/src/components/fleet-report.tsx +97 -54
  259. package/src/components/icons/chrome-marks.tsx +195 -0
  260. package/src/components/icons/icon-frame.tsx +50 -0
  261. package/src/components/icons/index.ts +84 -0
  262. package/src/components/icons/nav-map.ts +55 -0
  263. package/src/components/icons/nav-marks.tsx +205 -0
  264. package/src/components/icons/status-marks.tsx +46 -0
  265. package/src/components/icons/theme-marks.tsx +33 -0
  266. package/src/components/json-diff.tsx +1 -4
  267. package/src/components/json-tree-context.ts +26 -0
  268. package/src/components/json-tree-model.ts +139 -0
  269. package/src/components/json-tree-nodes.tsx +224 -0
  270. package/src/components/json-tree.tsx +15 -434
  271. package/src/components/json-value-format.ts +64 -0
  272. package/src/components/markdown-blocks.ts +198 -0
  273. package/src/components/markdown-inline.tsx +365 -0
  274. package/src/components/markdown.tsx +5 -471
  275. package/src/components/observer-registry.ts +139 -0
  276. package/src/components/overflow-measure.ts +69 -0
  277. package/src/components/prose-regions.ts +153 -0
  278. package/src/components/scroll-region.tsx +20 -360
  279. package/src/components/tab-stop-parse.ts +217 -0
  280. package/src/components/templated-text-field.tsx +38 -330
  281. package/src/components/templated-text-kwargs-editor.tsx +147 -0
  282. package/src/components/templated-text-kwargs.ts +92 -0
  283. package/src/components/templated-text-source.tsx +226 -0
  284. package/src/components/tool-picker-parts.tsx +184 -0
  285. package/src/components/tool-picker.tsx +22 -114
  286. package/src/components/version-history-panel.tsx +38 -142
  287. package/src/components/version-history-rows.tsx +220 -0
  288. package/src/guards.ts +7 -0
  289. package/src/hooks/interactions-connection.ts +227 -0
  290. package/src/hooks/interactions-stream.ts +274 -0
  291. package/src/hooks/useSse.ts +50 -477
  292. package/src/navigation/app-link.tsx +70 -0
  293. package/src/navigation/context.tsx +11 -330
  294. package/src/navigation/entry-state.ts +42 -0
  295. package/src/navigation/guard-registry.ts +65 -0
  296. package/src/navigation/guarded-navigation.ts +147 -0
  297. package/src/navigation/index.ts +2 -2
  298. package/src/navigation/types.ts +8 -11
  299. package/src/navigation/use-back-forward-guard.ts +90 -0
  300. package/src/plugin/registry.ts +111 -90
  301. package/src/schema-editor/SchemaEditor.tsx +9 -1
  302. package/src/schema-form/SecretRefField.tsx +121 -71
  303. package/src/schema-form/classify.ts +244 -395
  304. package/src/schema-form/default-value.ts +48 -17
  305. package/src/schema-form/enum-field.tsx +1 -1
  306. package/src/schema-form/field-model.ts +133 -0
  307. package/src/schema-form/field-node.tsx +94 -38
  308. package/src/schema-form/media-field.tsx +134 -65
  309. package/src/schema-form/string-annotations.ts +111 -0
  310. package/src/schema-form/string-field.tsx +1 -1
  311. package/src/schema-form/union-field.tsx +2 -1
  312. package/src/schema-form/union.ts +1 -1
  313. package/src/schema-form/validate.ts +184 -103
  314. package/src/state-binding/AdapterMapping.tsx +0 -0
  315. package/src/state-binding/StateAttachRow.tsx +222 -147
  316. package/src/state-binding/adapter-mapping-row.tsx +232 -0
  317. package/src/structured-output/StructuredOutput.tsx +1 -4
  318. package/dist/components/icons.d.ts +0 -160
  319. package/dist/components/icons.d.ts.map +0 -1
  320. package/dist/components/icons.js +0 -160
  321. package/dist/components/icons.js.map +0 -1
  322. package/src/components/icons.tsx +0 -586
@@ -19,304 +19,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  * The scrolling pane IS the scrolling box, carrying the region attributes itself
20
20
  * rather than nesting a `ScrollRegion` that would add a second scroller.
21
21
  */
22
- import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
23
- import { CheckIcon, CopyIcon, XCircleIcon } from './icons';
22
+ import { useCallback, useMemo, useState } from 'react';
23
+ import { XCircleIcon } from './icons';
24
24
  import { useOverflowRegion } from './scroll-region';
25
- import { COPIED_LABEL, COPIED_RESET_MS, useClipboardCopy } from '../hooks/useClipboardCopy';
25
+ import { useClipboardCopy } from '../hooks/useClipboardCopy';
26
+ import { PAGE_SIZE, computeOpen, expandedOpenPaths, initialBaseline, isContainer, } from './json-tree-model';
27
+ import { NO_CLIPBOARD, copyFailed, serializeForCopy } from './json-value-format';
28
+ import { JsonTreeContext } from './json-tree-context';
29
+ import { COPY_LABEL, CopyButton, JsonNode } from './json-tree-nodes';
26
30
  /** The region's name when the caller supplies none. */
27
31
  const DEFAULT_LABEL = 'JSON';
28
- /** The deepest level opened by the guarded default; deeper nodes start collapsed. */
29
- const AUTO_EXPAND_DEPTH = 1;
30
- /**
31
- * The deepest level EXPAND-ALL reaches. Past it a node opens only on an explicit
32
- * click, so the one action that opens the whole tree still cannot force an
33
- * unbounded-depth payload into the DOM in a single stroke.
34
- */
35
- const MAX_AUTO_DEPTH = 6;
36
- /** Children rendered per page; the rest wait behind a "show more" control. */
37
- const PAGE_SIZE = 100;
38
- /**
39
- * The most rendered nodes EXPAND-ALL may auto-open in one stroke. The depth cap and
40
- * the per-page limit each bound ONE dimension, but a payload that is wide AND deep
41
- * multiplies them — auto-opening every node up to the cap would lay out on the order
42
- * of PAGE_SIZE^depth nodes and freeze the tab. Expand-all instead opens containers
43
- * breadth-first only until this budget is spent; a node past it stays collapsed and
44
- * opens on an explicit click, so a huge payload opens a bounded, usable subset.
45
- */
46
- const AUTO_EXPAND_NODE_BUDGET = 1500;
47
- /** A copy control's resting face; whichever is exposed is also its accessible name. */
48
- const COPY_LABEL = 'Copy';
49
- /** Shown when the browser offers no clipboard at all (any non-secure context). */
50
- const NO_CLIPBOARD = 'This browser will not write to the clipboard here. Select the value and copy it by hand.';
51
- /** Shown when the write, or the value's serialization, is offered and refused. */
52
- function copyFailed(reason) {
53
- const detail = reason instanceof Error ? reason.message : String(reason);
54
- return `Copy failed: ${detail}.`;
55
- }
56
- function isRecord(value) {
57
- return typeof value === 'object' && value !== null && !Array.isArray(value);
58
- }
59
- /** Whether a value is a disclosure (object or array) rather than a leaf. */
60
- function isContainer(value) {
61
- return Array.isArray(value) || isRecord(value);
62
- }
63
- function primitiveText(value) {
64
- if (value === null)
65
- return 'null';
66
- switch (typeof value) {
67
- case 'undefined':
68
- return 'undefined';
69
- case 'string':
70
- return `"${value}"`;
71
- case 'number':
72
- case 'bigint':
73
- case 'boolean':
74
- return String(value);
75
- case 'symbol':
76
- return value.toString();
77
- case 'function':
78
- return '[Function]';
79
- default:
80
- return '[object]';
81
- }
82
- }
83
- /**
84
- * `JSON.stringify` is TYPED to always return `string`, but a value it cannot
85
- * represent (a function, a bare `undefined`) yields `undefined` at runtime. This
86
- * boundary admits the absence the standard-library overload denies, so the guard
87
- * below is a real check rather than a cast around one.
88
- */
89
- function stringifyJson(value) {
90
- return JSON.stringify(value, null, 2);
91
- }
92
- /**
93
- * The value's pretty JSON for the clipboard. A value JSON cannot represent (a
94
- * function, a bare `undefined`) has no JSON, so its readable form is copied
95
- * rather than an empty string. A value JSON REFUSES (a `bigint`) throws here, and
96
- * the caller renders that as the same visible alert a blocked write is.
97
- */
98
- function serializeForCopy(value) {
99
- return stringifyJson(value) ?? String(value);
100
- }
101
- /**
102
- * A child's identity for the open-state map. Each segment is percent-encoded, so a
103
- * key that itself contains the separator cannot collide with a different path.
104
- */
105
- function childPath(parent, name) {
106
- const segment = encodeURIComponent(name);
107
- return parent === '' ? segment : `${parent}/${segment}`;
108
- }
109
- function initialBaseline(defaultExpanded) {
110
- if (defaultExpanded === true)
111
- return 'expanded';
112
- if (defaultExpanded === false)
113
- return 'collapsed';
114
- return 'depth';
115
- }
116
- /**
117
- * The set of paths EXPAND-ALL auto-opens: a breadth-first sweep that opens each
118
- * container in turn — spending its visible child count against a shared node budget
119
- * and enqueuing that page's own container children — skipping any node whose page
120
- * would overspend {@link AUTO_EXPAND_NODE_BUDGET} or that sits past {@link MAX_AUTO_DEPTH}.
121
- * Only a bounded window of a huge payload is materialized, so this stays cheap even
122
- * when the data is enormous; the paths it omits stay collapsed and open on a click.
123
- */
124
- function expandedOpenPaths(root) {
125
- const open = new Set();
126
- if (!isContainer(root))
127
- return open;
128
- let budget = AUTO_EXPAND_NODE_BUDGET;
129
- const queue = [
130
- { value: root, path: '', depth: 0 },
131
- ];
132
- while (queue.length > 0) {
133
- const node = queue.shift();
134
- if (node === undefined)
135
- break;
136
- if (node.depth >= MAX_AUTO_DEPTH)
137
- continue;
138
- const shown = Math.min(PAGE_SIZE, containerCount(node.value));
139
- // Skip when the budget can't seat a whole page (a later, smaller node may still fit).
140
- if (shown > budget)
141
- continue;
142
- budget -= shown;
143
- open.add(node.path);
144
- for (const [name, childValue] of sliceEntries(node.value, shown)) {
145
- if (isContainer(childValue)) {
146
- queue.push({ value: childValue, path: childPath(node.path, name), depth: node.depth + 1 });
147
- }
148
- }
149
- }
150
- return open;
151
- }
152
- /**
153
- * Whether a node is open, from the baseline and the reader's own toggles. An
154
- * explicit toggle always wins; otherwise the baseline decides — the depth-guarded
155
- * default opens through {@link AUTO_EXPAND_DEPTH}, expand-all opens the budgeted
156
- * breadth-first set, collapse-all opens nothing.
157
- */
158
- function computeOpen(baseline, overrides, expandedPaths, path, depth) {
159
- const override = overrides.get(path);
160
- if (override !== undefined)
161
- return override;
162
- if (baseline === 'expanded')
163
- return expandedPaths?.has(path) ?? false;
164
- if (baseline === 'collapsed')
165
- return false;
166
- return depth <= AUTO_EXPAND_DEPTH;
167
- }
168
- const JsonTreeContext = createContext(null);
169
- /** The shared tree state; a subcomponent outside a `JsonTree` is a wiring error. */
170
- function useJsonTreeContext() {
171
- const context = useContext(JsonTreeContext);
172
- if (context === null) {
173
- throw new Error('JsonTree subcomponents must be rendered inside a JsonTree.');
174
- }
175
- return context;
176
- }
177
- /**
178
- * One nesting level's indent: the child block insets and draws its own guide
179
- * rail. The depth is expressed by the DOM nesting, so each level repeats this
180
- * single step rather than computing an absolute offset.
181
- */
182
- const childrenStyle = {
183
- paddingLeft: 'var(--tai-space-4)',
184
- marginLeft: 'var(--tai-space-1)',
185
- borderLeft: '1px solid var(--tai-color-decor)',
186
- };
187
- /** A `<summary>` is a click target; browsers do not style it as one by default. */
188
- const summaryStyle = {
189
- display: 'flex',
190
- alignItems: 'center',
191
- gap: 'var(--tai-space-2)',
192
- cursor: 'pointer',
193
- };
194
- /** The copy control sits at the far end of a disclosure's row. */
195
- const nodeCopyStyle = { marginLeft: 'auto' };
196
- /**
197
- * The per-node copy button's geometry: borrows `tai-icon-btn` for the focus ring,
198
- * muted ink and hover, then shrinks to the code rhythm so the row stays dense.
199
- */
200
- const nodeCopyButtonStyle = {
201
- width: 'auto',
202
- height: 'auto',
203
- padding: 'var(--tai-space-1)',
204
- };
205
- const showMoreStyle = { marginTop: 'var(--tai-space-1)' };
206
- /** The syntax class for a primitive's type; anything outside JSON reads as muted. */
207
- function primitiveClass(value) {
208
- if (typeof value === 'string')
209
- return 'tai-syntax-string';
210
- if (typeof value === 'number' || typeof value === 'bigint')
211
- return 'tai-syntax-number';
212
- if (typeof value === 'boolean')
213
- return 'tai-syntax-bool';
214
- if (value === null || value === undefined)
215
- return 'tai-syntax-null';
216
- return 'tai-muted';
217
- }
218
- /**
219
- * A copy control that writes its value to the clipboard and shows a transient
220
- * confirmed state. The write itself lives on the tree context, so a refusal is
221
- * reported ONCE — as the tree's shared alert — rather than inline at each of the
222
- * many buttons a large payload carries.
223
- */
224
- function CopyButton({ value, label, variant }) {
225
- const { copy } = useJsonTreeContext();
226
- const [copied, setCopied] = useState(false);
227
- const resetTimer = useRef(null);
228
- // The write is async, so a copy can be in flight when the button unmounts (a dialog
229
- // holding the tree closes on the same click); checked before the resolution sets state.
230
- const mounted = useRef(true);
231
- useEffect(() => {
232
- mounted.current = true;
233
- return () => {
234
- mounted.current = false;
235
- if (resetTimer.current !== null)
236
- clearTimeout(resetTimer.current);
237
- };
238
- }, []);
239
- const handleClick = (event) => {
240
- // Inside a `<summary>` a click both toggles the disclosure natively and reaches
241
- // the summary's own toggle handler; neither should fire for a copy.
242
- event.preventDefault();
243
- event.stopPropagation();
244
- void copy(value).then((ok) => {
245
- if (!ok || !mounted.current)
246
- return;
247
- setCopied(true);
248
- if (resetTimer.current !== null)
249
- clearTimeout(resetTimer.current);
250
- resetTimer.current = setTimeout(() => {
251
- if (mounted.current)
252
- setCopied(false);
253
- }, COPIED_RESET_MS);
254
- });
255
- };
256
- if (variant === 'text') {
257
- return (_jsxs("button", { type: "button", className: "tai-btn tai-btn-ghost", onClick: handleClick, children: [copied ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {}), copied ? COPIED_LABEL : label] }));
258
- }
259
- return (_jsx("button", { type: "button", className: "tai-icon-btn", style: { ...nodeCopyStyle, ...nodeCopyButtonStyle }, "aria-label": copied ? COPIED_LABEL : label, onClick: handleClick, children: copied ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {}) }));
260
- }
261
- /** A container's child count, without materializing its entries. */
262
- function containerCount(value) {
263
- if (Array.isArray(value))
264
- return value.length;
265
- if (isRecord(value))
266
- return Object.keys(value).length;
267
- throw new Error('containerCount expects an array or a record.');
268
- }
269
- /**
270
- * The first `end` entries of a container, arrays keyed by index and objects by
271
- * key. Only the visible window is materialized, so a million-element array's
272
- * children never all exist at once.
273
- */
274
- function sliceEntries(value, end) {
275
- if (Array.isArray(value)) {
276
- return value.slice(0, end).map((item, index) => [String(index), item]);
277
- }
278
- // Slice the keys before reading values, so only the visible window is materialized.
279
- if (isRecord(value))
280
- return Object.keys(value)
281
- .slice(0, end)
282
- .map((key) => [key, value[key]]);
283
- throw new Error('sliceEntries expects an array or a record.');
284
- }
285
- /** One container's summary text: its kind and its child count. */
286
- function containerSummary(value, count) {
287
- return Array.isArray(value) ? `Array(${String(count)})` : `Object(${String(count)})`;
288
- }
289
- /**
290
- * The visible slice of a container's children, plus a "show more" control while
291
- * any remain. Rendered ONLY when the node is open, so a collapsed container costs
292
- * nothing and the page count follows how far the reader has opened it.
293
- */
294
- function NodeChildren({ value, count, depth, path, }) {
295
- const { pageSize } = useJsonTreeContext();
296
- const [visible, setVisible] = useState(pageSize);
297
- const shownCount = Math.min(visible, count);
298
- const shown = sliceEntries(value, shownCount);
299
- const remaining = count - shownCount;
300
- return (_jsxs("div", { style: childrenStyle, children: [shown.map(([childName, childValue]) => (_jsx(JsonNode, { name: childName, value: childValue, depth: depth + 1, path: childPath(path, childName) }, childName))), remaining > 0 ? (_jsxs("button", { type: "button", className: "tai-btn tai-btn-ghost", style: showMoreStyle, onClick: () => {
301
- setVisible((current) => current + pageSize);
302
- }, children: ["Show ", String(Math.min(remaining, pageSize)), " more"] })) : null] }));
303
- }
304
- function JsonNode({ name, value, depth, path }) {
305
- const { isOpen, setOpen } = useJsonTreeContext();
306
- if (isContainer(value)) {
307
- const count = containerCount(value);
308
- const open = isOpen(path, depth);
309
- const summary = containerSummary(value, count);
310
- const handleToggle = (event) => {
311
- // The disclosure is state-driven: cancel the browser's own toggle so the two
312
- // never diverge, then record the reader's intent.
313
- event.preventDefault();
314
- setOpen(path, !open);
315
- };
316
- return (_jsxs("details", { open: open, children: [_jsxs("summary", { style: summaryStyle, onClick: handleToggle, children: [name !== undefined ? _jsxs("span", { className: "tai-syntax-key", children: [name, ": "] }) : null, _jsx("span", { className: "tai-muted", children: summary }), depth > 0 ? (_jsx(CopyButton, { value: value, variant: "icon", label: name !== undefined ? `Copy ${name}` : COPY_LABEL })) : null] }), open ? _jsx(NodeChildren, { value: value, count: count, depth: depth, path: path }) : null] }));
317
- }
318
- return (_jsxs("div", { children: [name !== undefined ? _jsxs("span", { className: "tai-syntax-key", children: [name, ": "] }) : null, _jsx("span", { className: primitiveClass(value), children: primitiveText(value) })] }));
319
- }
320
32
  export function JsonTree({ data, defaultExpanded, label }) {
321
33
  const [baseline, setBaseline] = useState(() => initialBaseline(defaultExpanded));
322
34
  const [overrides, setOverrides] = useState(() => new Map());
@@ -1 +1 @@
1
- {"version":3,"file":"json-tree.js","sourceRoot":"","sources":["../../src/components/json-tree.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,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G,GACvC,IACF,GACmB,CAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Formatting a JSON value for display and for the clipboard: the inline primitive
3
+ * text and its syntax class, the clipboard serialization, and the copy-failure
4
+ * messages.
5
+ */
6
+ /** Shown when the browser offers no clipboard at all (any non-secure context). */
7
+ export declare const NO_CLIPBOARD = "This browser will not write to the clipboard here. Select the value and copy it by hand.";
8
+ /** Shown when the write, or the value's serialization, is offered and refused. */
9
+ export declare function copyFailed(reason: unknown): string;
10
+ export declare function primitiveText(value: unknown): string;
11
+ /** The syntax class for a primitive's type; anything outside JSON reads as muted. */
12
+ export declare function primitiveClass(value: unknown): string;
13
+ /**
14
+ * The value's pretty JSON for the clipboard. A value JSON cannot represent (a
15
+ * function, a bare `undefined`) has no JSON, so its readable form is copied
16
+ * rather than an empty string. A value JSON REFUSES (a `bigint`) throws here, and
17
+ * the caller renders that as the same visible alert a blocked write is.
18
+ */
19
+ export declare function serializeForCopy(value: unknown): string;
20
+ //# sourceMappingURL=json-value-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-value-format.d.ts","sourceRoot":"","sources":["../../src/components/json-value-format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kFAAkF;AAClF,eAAO,MAAM,YAAY,6FACmE,CAAC;AAE7F,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAGlD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBpD;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMrD;AAYD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Formatting a JSON value for display and for the clipboard: the inline primitive
3
+ * text and its syntax class, the clipboard serialization, and the copy-failure
4
+ * messages.
5
+ */
6
+ /** Shown when the browser offers no clipboard at all (any non-secure context). */
7
+ export const NO_CLIPBOARD = 'This browser will not write to the clipboard here. Select the value and copy it by hand.';
8
+ /** Shown when the write, or the value's serialization, is offered and refused. */
9
+ export function copyFailed(reason) {
10
+ const detail = reason instanceof Error ? reason.message : String(reason);
11
+ return `Copy failed: ${detail}.`;
12
+ }
13
+ export function primitiveText(value) {
14
+ if (value === null)
15
+ return 'null';
16
+ switch (typeof value) {
17
+ case 'undefined':
18
+ return 'undefined';
19
+ case 'string':
20
+ return `"${value}"`;
21
+ case 'number':
22
+ case 'bigint':
23
+ case 'boolean':
24
+ return String(value);
25
+ case 'symbol':
26
+ return value.toString();
27
+ case 'function':
28
+ return '[Function]';
29
+ default:
30
+ return '[object]';
31
+ }
32
+ }
33
+ /** The syntax class for a primitive's type; anything outside JSON reads as muted. */
34
+ export function primitiveClass(value) {
35
+ if (typeof value === 'string')
36
+ return 'tai-syntax-string';
37
+ if (typeof value === 'number' || typeof value === 'bigint')
38
+ return 'tai-syntax-number';
39
+ if (typeof value === 'boolean')
40
+ return 'tai-syntax-bool';
41
+ if (value === null || value === undefined)
42
+ return 'tai-syntax-null';
43
+ return 'tai-muted';
44
+ }
45
+ /**
46
+ * `JSON.stringify` is TYPED to always return `string`, but a value it cannot
47
+ * represent (a function, a bare `undefined`) yields `undefined` at runtime. This
48
+ * boundary admits the absence the standard-library overload denies, so the guard
49
+ * below is a real check rather than a cast around one.
50
+ */
51
+ function stringifyJson(value) {
52
+ return JSON.stringify(value, null, 2);
53
+ }
54
+ /**
55
+ * The value's pretty JSON for the clipboard. A value JSON cannot represent (a
56
+ * function, a bare `undefined`) has no JSON, so its readable form is copied
57
+ * rather than an empty string. A value JSON REFUSES (a `bigint`) throws here, and
58
+ * the caller renders that as the same visible alert a blocked write is.
59
+ */
60
+ export function serializeForCopy(value) {
61
+ return stringifyJson(value) ?? String(value);
62
+ }
63
+ //# sourceMappingURL=json-value-format.js.map
@@ -0,0 +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pE,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The block grammar for `Markdown`: folds markdown source into an ordered list of
3
+ * blocks. Pure and total — any string parses, and text that matches no block
4
+ * construct becomes a paragraph rather than being discarded.
5
+ */
6
+ /** The heading levels ATX syntax can express, `#` through `######`. */
7
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
8
+ /** A parsed block. Inline markup inside `text` is resolved at render time. */
9
+ export type MarkdownBlock = {
10
+ readonly type: 'heading';
11
+ readonly level: HeadingLevel;
12
+ readonly text: string;
13
+ } | {
14
+ readonly type: 'paragraph';
15
+ readonly text: string;
16
+ } | {
17
+ readonly type: 'code';
18
+ readonly language: string | undefined;
19
+ readonly code: string;
20
+ } | {
21
+ readonly type: 'list';
22
+ readonly ordered: boolean;
23
+ readonly items: readonly string[];
24
+ /** The first item's number on an ordered list, so the render can offset `<ol start>`. */
25
+ readonly start?: number;
26
+ } | {
27
+ readonly type: 'blockquote';
28
+ readonly children: readonly MarkdownBlock[];
29
+ } | {
30
+ readonly type: 'thematicBreak';
31
+ };
32
+ /**
33
+ * Folds markdown source into an ordered list of blocks. Pure and total: any
34
+ * string parses, and text that matches no block construct becomes a paragraph
35
+ * rather than being discarded.
36
+ */
37
+ export declare function parseMarkdown(markdown: string): MarkdownBlock[];
38
+ //# sourceMappingURL=markdown-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-blocks.d.ts","sourceRoot":"","sources":["../../src/components/markdown-blocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvF;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAuKvC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,CAG/D"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The block grammar for `Markdown`: folds markdown source into an ordered list of
3
+ * blocks. Pure and total — any string parses, and text that matches no block
4
+ * construct becomes a paragraph rather than being discarded.
5
+ */
6
+ const BLANK = /^[ \t]*$/;
7
+ /** A fence opener: three-or-more backticks or tildes, then an info string. */
8
+ const FENCE_OPEN = /^[ \t]{0,3}(`{3,}|~{3,})[ \t]*(.*)$/;
9
+ /**
10
+ * An ATX heading: 1–6 hashes, a required space, then text. A closing hash run is
11
+ * stripped only when whitespace separates it from the content, so `# C#` keeps
12
+ * its literal `C#`.
13
+ */
14
+ const HEADING = /^[ \t]{0,3}(#{1,6})[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
15
+ /** A thematic break: three-or-more `-`, `*` or `_`, spaces allowed between. */
16
+ const THEMATIC_BREAK = /^[ \t]{0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/;
17
+ /** A blockquote line: a `>` marker and its (optionally space-prefixed) content. */
18
+ const BLOCKQUOTE = /^[ \t]{0,3}>[ \t]?(.*)$/;
19
+ /** An unordered list item: a `-`, `*` or `+` bullet, a space, then content. */
20
+ const UNORDERED_ITEM = /^[ \t]*[-*+][ \t]+(.*)$/;
21
+ /** An ordered list item: a start number, a `.` or `)` delimiter, a space, then content. */
22
+ const ORDERED_ITEM = /^[ \t]*(\d{1,9})[.)][ \t]+(.*)$/;
23
+ /** True when a line starts a block that interrupts an open paragraph. */
24
+ function startsBlock(line) {
25
+ return (FENCE_OPEN.test(line) ||
26
+ HEADING.test(line) ||
27
+ THEMATIC_BREAK.test(line) ||
28
+ BLOCKQUOTE.test(line) ||
29
+ UNORDERED_ITEM.test(line) ||
30
+ ORDERED_ITEM.test(line));
31
+ }
32
+ /**
33
+ * The `closer` for an open fence: the same marker character, at least as long as
34
+ * the opener, alone on its line. A source that never closes its fence takes the
35
+ * rest of the document as code — the same run-to-end rule CommonMark applies —
36
+ * rather than silently dropping the block.
37
+ */
38
+ function fenceCloser(marker) {
39
+ const char = marker.startsWith('`') ? '`' : '~';
40
+ return new RegExp(`^[ \\t]{0,3}${char}{${String(marker.length)},}[ \\t]*$`);
41
+ }
42
+ /** A fenced code block; runs to its closing fence or the end of the document. */
43
+ function parseFence(lines, i) {
44
+ const fence = FENCE_OPEN.exec(lines[i] ?? '');
45
+ if (fence === null)
46
+ return null;
47
+ const closer = fenceCloser(fence[1] ?? '');
48
+ const info = (fence[2] ?? '').trim();
49
+ const body = [];
50
+ let j = i + 1;
51
+ for (; j < lines.length; j += 1) {
52
+ const next = lines[j] ?? '';
53
+ if (closer.test(next))
54
+ break;
55
+ body.push(next);
56
+ }
57
+ // Step past the closing fence when one is present; at end-of-document there is
58
+ // nothing to step past.
59
+ if (j < lines.length)
60
+ j += 1;
61
+ return {
62
+ block: { type: 'code', language: info.length > 0 ? info : undefined, code: body.join('\n') },
63
+ next: j,
64
+ };
65
+ }
66
+ /** An ATX heading on a single line. */
67
+ function parseHeading(lines, i) {
68
+ const heading = HEADING.exec(lines[i] ?? '');
69
+ if (heading === null)
70
+ return null;
71
+ return {
72
+ block: {
73
+ type: 'heading',
74
+ level: (heading[1] ?? '').length,
75
+ text: heading[2] ?? '',
76
+ },
77
+ next: i + 1,
78
+ };
79
+ }
80
+ /** A thematic break on a single line. */
81
+ function parseThematicBreak(lines, i) {
82
+ if (!THEMATIC_BREAK.test(lines[i] ?? ''))
83
+ return null;
84
+ return { block: { type: 'thematicBreak' }, next: i + 1 };
85
+ }
86
+ /** A blockquote: the run of `>`-marked lines, parsed recursively as its own blocks. */
87
+ function parseBlockquote(lines, i) {
88
+ if (!BLOCKQUOTE.test(lines[i] ?? ''))
89
+ return null;
90
+ const inner = [];
91
+ let j = i;
92
+ for (; j < lines.length; j += 1) {
93
+ const quoted = BLOCKQUOTE.exec(lines[j] ?? '');
94
+ if (quoted === null)
95
+ break;
96
+ inner.push(quoted[1] ?? '');
97
+ }
98
+ return { block: { type: 'blockquote', children: parseBlocks(inner) }, next: j };
99
+ }
100
+ /** An ordered or unordered list: the run of item lines sharing the leading marker. */
101
+ function parseList(lines, i) {
102
+ const line = lines[i] ?? '';
103
+ const unordered = UNORDERED_ITEM.exec(line);
104
+ const ordered = unordered === null ? ORDERED_ITEM.exec(line) : null;
105
+ if (unordered === null && ordered === null)
106
+ return null;
107
+ const pattern = ordered !== null ? ORDERED_ITEM : UNORDERED_ITEM;
108
+ // An ordered item's content is its second group, behind the start number; an
109
+ // unordered item's content is its first.
110
+ const textGroup = ordered !== null ? 2 : 1;
111
+ const items = [];
112
+ let j = i;
113
+ for (; j < lines.length; j += 1) {
114
+ const item = pattern.exec(lines[j] ?? '');
115
+ if (item === null)
116
+ break;
117
+ items.push(item[textGroup] ?? '');
118
+ }
119
+ const block = ordered !== null
120
+ ? { type: 'list', ordered: true, items, start: Number(ordered[1] ?? '1') }
121
+ : { type: 'list', ordered: false, items };
122
+ return { block, next: j };
123
+ }
124
+ /**
125
+ * A paragraph: this line and the following lines up to a blank line or the start
126
+ * of another block. The total fallback — always succeeds. Soft line breaks are
127
+ * kept as newlines.
128
+ */
129
+ function parseParagraph(lines, i) {
130
+ const paragraph = [lines[i] ?? ''];
131
+ let j = i + 1;
132
+ for (; j < lines.length; j += 1) {
133
+ const next = lines[j] ?? '';
134
+ if (BLANK.test(next) || startsBlock(next))
135
+ break;
136
+ paragraph.push(next);
137
+ }
138
+ return { block: { type: 'paragraph', text: paragraph.join('\n') }, next: j };
139
+ }
140
+ function parseBlocks(lines) {
141
+ const blocks = [];
142
+ let i = 0;
143
+ while (i < lines.length) {
144
+ if (BLANK.test(lines[i] ?? '')) {
145
+ i += 1;
146
+ continue;
147
+ }
148
+ const step = parseFence(lines, i) ??
149
+ parseHeading(lines, i) ??
150
+ parseThematicBreak(lines, i) ??
151
+ parseBlockquote(lines, i) ??
152
+ parseList(lines, i) ??
153
+ parseParagraph(lines, i);
154
+ blocks.push(step.block);
155
+ i = step.next;
156
+ }
157
+ return blocks;
158
+ }
159
+ /**
160
+ * Folds markdown source into an ordered list of blocks. Pure and total: any
161
+ * string parses, and text that matches no block construct becomes a paragraph
162
+ * rather than being discarded.
163
+ */
164
+ export function parseMarkdown(markdown) {
165
+ const lines = markdown.replace(/\r\n?/g, '\n').split('\n');
166
+ return parseBlocks(lines);
167
+ }
168
+ //# sourceMappingURL=markdown-blocks.js.map