@vibefield/rosetta-room 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/README.md +247 -2
  2. package/dist/HistoryRoom.d.ts +98 -0
  3. package/dist/HistoryRoom.js +440 -0
  4. package/dist/TranscriptReader.d.ts +22 -0
  5. package/dist/TranscriptReader.js +72 -0
  6. package/dist/components/ColdStart.d.ts +4 -0
  7. package/dist/components/ColdStart.js +5 -0
  8. package/dist/components/FilterChips.d.ts +4 -0
  9. package/dist/components/FilterChips.js +5 -0
  10. package/dist/components/HostAct.d.ts +9 -0
  11. package/dist/components/HostAct.js +16 -0
  12. package/dist/components/HostMenu.d.ts +41 -0
  13. package/dist/components/HostMenu.js +216 -0
  14. package/dist/components/IngestStatus.d.ts +4 -0
  15. package/dist/components/IngestStatus.js +20 -0
  16. package/dist/components/ListActivityNotice.d.ts +5 -0
  17. package/dist/components/ListActivityNotice.js +4 -0
  18. package/dist/components/ListSections.d.ts +20 -0
  19. package/dist/components/ListSections.js +39 -0
  20. package/dist/components/RenameHeading.d.ts +9 -0
  21. package/dist/components/RenameHeading.js +75 -0
  22. package/dist/components/SearchStrip.d.ts +5 -0
  23. package/dist/components/SearchStrip.js +8 -0
  24. package/dist/components/SummaryMetrics.d.ts +13 -0
  25. package/dist/components/SummaryMetrics.js +9 -0
  26. package/dist/components/SummaryPanels.d.ts +35 -0
  27. package/dist/components/SummaryPanels.js +117 -0
  28. package/dist/components/Transcript.d.ts +46 -0
  29. package/dist/components/Transcript.js +358 -0
  30. package/dist/components/charts/ActivityChartDetail.d.ts +13 -0
  31. package/dist/components/charts/ActivityChartDetail.js +78 -0
  32. package/dist/components/charts/CalendarHeatmap.d.ts +16 -0
  33. package/dist/components/charts/CalendarHeatmap.js +55 -0
  34. package/dist/components/charts/DayActivityChart.d.ts +8 -0
  35. package/dist/components/charts/DayActivityChart.js +71 -0
  36. package/dist/components/charts/ModelsChartDetail.d.ts +7 -0
  37. package/dist/components/charts/ModelsChartDetail.js +19 -0
  38. package/dist/components/charts/ProjectChartDialog.d.ts +19 -0
  39. package/dist/components/charts/ProjectChartDialog.js +39 -0
  40. package/dist/components/charts/Streamgraph.d.ts +16 -0
  41. package/dist/components/charts/Streamgraph.js +94 -0
  42. package/dist/components/charts/Treemap.d.ts +26 -0
  43. package/dist/components/charts/Treemap.js +81 -0
  44. package/dist/components/charts/index.d.ts +9 -0
  45. package/dist/components/charts/index.js +4 -0
  46. package/dist/components/charts/streamgraph-layout.d.ts +23 -0
  47. package/dist/components/charts/streamgraph-layout.js +114 -0
  48. package/dist/components/charts/treemap-layout.d.ts +32 -0
  49. package/dist/components/charts/treemap-layout.js +140 -0
  50. package/dist/components/charts/types.d.ts +65 -0
  51. package/dist/components/charts/types.js +8 -0
  52. package/dist/components/file-viewer/FileViewerBrowsers.d.ts +10 -0
  53. package/dist/components/file-viewer/FileViewerBrowsers.js +65 -0
  54. package/dist/components/file-viewer/FileViewerDialog.d.ts +33 -0
  55. package/dist/components/file-viewer/FileViewerDialog.js +82 -0
  56. package/dist/components/file-viewer/FileViewerHeader.d.ts +26 -0
  57. package/dist/components/file-viewer/FileViewerHeader.js +17 -0
  58. package/dist/components/file-viewer/ImageGalleryDialog.d.ts +14 -0
  59. package/dist/components/file-viewer/ImageGalleryDialog.js +98 -0
  60. package/dist/components/file-viewer/diff/index.d.ts +2 -0
  61. package/dist/components/file-viewer/diff/index.js +2 -0
  62. package/dist/components/file-viewer/diff/parse.d.ts +2 -0
  63. package/dist/components/file-viewer/diff/parse.js +164 -0
  64. package/dist/components/file-viewer/diff/types.d.ts +44 -0
  65. package/dist/components/file-viewer/diff/types.js +7 -0
  66. package/dist/components/file-viewer/gallery-source.d.ts +11 -0
  67. package/dist/components/file-viewer/gallery-source.js +75 -0
  68. package/dist/components/file-viewer/image-resource.d.ts +19 -0
  69. package/dist/components/file-viewer/image-resource.js +60 -0
  70. package/dist/components/file-viewer/index.d.ts +5 -0
  71. package/dist/components/file-viewer/index.js +8 -0
  72. package/dist/components/file-viewer/markdown/blocks.d.ts +2 -0
  73. package/dist/components/file-viewer/markdown/blocks.js +277 -0
  74. package/dist/components/file-viewer/markdown/index.d.ts +4 -0
  75. package/dist/components/file-viewer/markdown/index.js +35 -0
  76. package/dist/components/file-viewer/markdown/inline.d.ts +10 -0
  77. package/dist/components/file-viewer/markdown/inline.js +178 -0
  78. package/dist/components/file-viewer/markdown/render.d.ts +9 -0
  79. package/dist/components/file-viewer/markdown/render.js +78 -0
  80. package/dist/components/file-viewer/markdown/types.d.ts +57 -0
  81. package/dist/components/file-viewer/markdown/types.js +11 -0
  82. package/dist/components/file-viewer/minimap/CodeMinimap.d.ts +10 -0
  83. package/dist/components/file-viewer/minimap/CodeMinimap.js +296 -0
  84. package/dist/components/file-viewer/minimap/layout.d.ts +60 -0
  85. package/dist/components/file-viewer/minimap/layout.js +117 -0
  86. package/dist/components/file-viewer/minimap/palette.d.ts +2 -0
  87. package/dist/components/file-viewer/minimap/palette.js +73 -0
  88. package/dist/components/file-viewer/minimap/raster.d.ts +19 -0
  89. package/dist/components/file-viewer/minimap/raster.js +122 -0
  90. package/dist/components/file-viewer/registry.d.ts +25 -0
  91. package/dist/components/file-viewer/registry.js +182 -0
  92. package/dist/components/file-viewer/syntax/grammars.d.ts +16 -0
  93. package/dist/components/file-viewer/syntax/grammars.js +221 -0
  94. package/dist/components/file-viewer/syntax/index.d.ts +8 -0
  95. package/dist/components/file-viewer/syntax/index.js +9 -0
  96. package/dist/components/file-viewer/syntax/languages.d.ts +14 -0
  97. package/dist/components/file-viewer/syntax/languages.js +115 -0
  98. package/dist/components/file-viewer/syntax/tokenize-config.d.ts +2 -0
  99. package/dist/components/file-viewer/syntax/tokenize-config.js +132 -0
  100. package/dist/components/file-viewer/syntax/tokenize-css.d.ts +2 -0
  101. package/dist/components/file-viewer/syntax/tokenize-css.js +169 -0
  102. package/dist/components/file-viewer/syntax/tokenize-markup.d.ts +2 -0
  103. package/dist/components/file-viewer/syntax/tokenize-markup.js +124 -0
  104. package/dist/components/file-viewer/syntax/tokenize.d.ts +9 -0
  105. package/dist/components/file-viewer/syntax/tokenize.js +289 -0
  106. package/dist/components/file-viewer/syntax/types.d.ts +74 -0
  107. package/dist/components/file-viewer/syntax/types.js +13 -0
  108. package/dist/components/file-viewer/types.d.ts +111 -0
  109. package/dist/components/file-viewer/types.js +8 -0
  110. package/dist/components/file-viewer/use-file-content.d.ts +26 -0
  111. package/dist/components/file-viewer/use-file-content.js +144 -0
  112. package/dist/components/file-viewer/views/BinaryView.d.ts +2 -0
  113. package/dist/components/file-viewer/views/BinaryView.js +34 -0
  114. package/dist/components/file-viewer/views/CodeView.d.ts +2 -0
  115. package/dist/components/file-viewer/views/CodeView.js +46 -0
  116. package/dist/components/file-viewer/views/DiffBody.d.ts +7 -0
  117. package/dist/components/file-viewer/views/DiffBody.js +77 -0
  118. package/dist/components/file-viewer/views/DiffView.d.ts +2 -0
  119. package/dist/components/file-viewer/views/DiffView.js +11 -0
  120. package/dist/components/file-viewer/views/ImageView.d.ts +9 -0
  121. package/dist/components/file-viewer/views/ImageView.js +28 -0
  122. package/dist/components/file-viewer/views/MarkdownView.d.ts +9 -0
  123. package/dist/components/file-viewer/views/MarkdownView.js +20 -0
  124. package/dist/components/file-viewer/views/SvgView.d.ts +9 -0
  125. package/dist/components/file-viewer/views/SvgView.js +10 -0
  126. package/dist/components/git/ChangeTree.d.ts +20 -0
  127. package/dist/components/git/ChangeTree.js +35 -0
  128. package/dist/components/git/CommitViewer.d.ts +12 -0
  129. package/dist/components/git/CommitViewer.js +85 -0
  130. package/dist/components/git/GitChanges.d.ts +17 -0
  131. package/dist/components/git/GitChanges.js +70 -0
  132. package/dist/components/git/GitHistory.d.ts +9 -0
  133. package/dist/components/git/GitHistory.js +58 -0
  134. package/dist/components/git/co-author.d.ts +14 -0
  135. package/dist/components/git/co-author.js +55 -0
  136. package/dist/components/git/git-file-source.d.ts +18 -0
  137. package/dist/components/git/git-file-source.js +53 -0
  138. package/dist/components/git/git-host.d.ts +24 -0
  139. package/dist/components/git/git-host.js +130 -0
  140. package/dist/components/git/index.d.ts +10 -0
  141. package/dist/components/git/index.js +12 -0
  142. package/dist/components/git/path-tree.d.ts +23 -0
  143. package/dist/components/git/path-tree.js +73 -0
  144. package/dist/components/git/session-files.d.ts +9 -0
  145. package/dist/components/git/session-files.js +50 -0
  146. package/dist/components/git/types.d.ts +92 -0
  147. package/dist/components/git/types.js +9 -0
  148. package/dist/components/projects/ProjectActivitySparkline.d.ts +6 -0
  149. package/dist/components/projects/ProjectActivitySparkline.js +12 -0
  150. package/dist/components/projects/ProjectList.d.ts +25 -0
  151. package/dist/components/projects/ProjectList.js +43 -0
  152. package/dist/components/projects/ProjectListItem.d.ts +19 -0
  153. package/dist/components/projects/ProjectListItem.js +78 -0
  154. package/dist/components/projects/ProjectsColumn.d.ts +19 -0
  155. package/dist/components/projects/ProjectsColumn.js +36 -0
  156. package/dist/components/projects/index.d.ts +8 -0
  157. package/dist/components/projects/index.js +4 -0
  158. package/dist/components/search/MatchStepper.d.ts +9 -0
  159. package/dist/components/search/MatchStepper.js +14 -0
  160. package/dist/components/search/SearchLauncher.d.ts +12 -0
  161. package/dist/components/search/SearchLauncher.js +13 -0
  162. package/dist/components/search/SearchSheet.d.ts +29 -0
  163. package/dist/components/search/SearchSheet.js +230 -0
  164. package/dist/components/search/index.d.ts +8 -0
  165. package/dist/components/search/index.js +4 -0
  166. package/dist/components/search/shortcut.d.ts +25 -0
  167. package/dist/components/search/shortcut.js +32 -0
  168. package/dist/components/sessions/SessionList.d.ts +24 -0
  169. package/dist/components/sessions/SessionList.js +76 -0
  170. package/dist/components/sessions/SessionListItem.d.ts +13 -0
  171. package/dist/components/sessions/SessionListItem.js +58 -0
  172. package/dist/components/sessions/SessionsColumn.d.ts +26 -0
  173. package/dist/components/sessions/SessionsColumn.js +32 -0
  174. package/dist/components/sessions/index.d.ts +9 -0
  175. package/dist/components/sessions/index.js +4 -0
  176. package/dist/components/sessions/session-display.d.ts +8 -0
  177. package/dist/components/sessions/session-display.js +18 -0
  178. package/dist/components/sessions/types.d.ts +7 -0
  179. package/dist/components/sessions/types.js +1 -0
  180. package/dist/components/transcript/Activity.d.ts +45 -0
  181. package/dist/components/transcript/Activity.js +75 -0
  182. package/dist/components/transcript/Anchor.d.ts +8 -0
  183. package/dist/components/transcript/Anchor.js +23 -0
  184. package/dist/components/transcript/Attachments.d.ts +21 -0
  185. package/dist/components/transcript/Attachments.js +138 -0
  186. package/dist/components/transcript/AuthoredMessage.d.ts +19 -0
  187. package/dist/components/transcript/AuthoredMessage.js +17 -0
  188. package/dist/components/transcript/Compaction.d.ts +9 -0
  189. package/dist/components/transcript/Compaction.js +50 -0
  190. package/dist/components/transcript/DayPill.d.ts +38 -0
  191. package/dist/components/transcript/DayPill.js +68 -0
  192. package/dist/components/transcript/Document.d.ts +32 -0
  193. package/dist/components/transcript/Document.js +503 -0
  194. package/dist/components/transcript/Favicon.d.ts +32 -0
  195. package/dist/components/transcript/Favicon.js +71 -0
  196. package/dist/components/transcript/HeadOfDocument.d.ts +19 -0
  197. package/dist/components/transcript/HeadOfDocument.js +44 -0
  198. package/dist/components/transcript/Ledger.d.ts +53 -0
  199. package/dist/components/transcript/Ledger.js +182 -0
  200. package/dist/components/transcript/LineDetail.d.ts +24 -0
  201. package/dist/components/transcript/LineDetail.js +81 -0
  202. package/dist/components/transcript/Marker.d.ts +33 -0
  203. package/dist/components/transcript/Marker.js +21 -0
  204. package/dist/components/transcript/MessagePreview.d.ts +12 -0
  205. package/dist/components/transcript/MessagePreview.js +58 -0
  206. package/dist/components/transcript/Prompt.d.ts +20 -0
  207. package/dist/components/transcript/Prompt.js +55 -0
  208. package/dist/components/transcript/Prose.d.ts +19 -0
  209. package/dist/components/transcript/Prose.js +109 -0
  210. package/dist/components/transcript/ReceiptPill.d.ts +10 -0
  211. package/dist/components/transcript/ReceiptPill.js +10 -0
  212. package/dist/components/transcript/ResponseHead.d.ts +9 -0
  213. package/dist/components/transcript/ResponseHead.js +36 -0
  214. package/dist/components/transcript/Subthread.d.ts +19 -0
  215. package/dist/components/transcript/Subthread.js +96 -0
  216. package/dist/components/transcript/Team.d.ts +53 -0
  217. package/dist/components/transcript/Team.js +185 -0
  218. package/dist/components/transcript/Thinking.d.ts +24 -0
  219. package/dist/components/transcript/Thinking.js +50 -0
  220. package/dist/components/transcript/TimelineMeta.d.ts +9 -0
  221. package/dist/components/transcript/TimelineMeta.js +161 -0
  222. package/dist/components/transcript/TranscriptLoading.d.ts +10 -0
  223. package/dist/components/transcript/TranscriptLoading.js +10 -0
  224. package/dist/components/transcript/WebDetail.d.ts +8 -0
  225. package/dist/components/transcript/WebDetail.js +29 -0
  226. package/dist/components/transcript/Workflow.d.ts +12 -0
  227. package/dist/components/transcript/Workflow.js +208 -0
  228. package/dist/components/transcript/activity-plan.d.ts +84 -0
  229. package/dist/components/transcript/activity-plan.js +209 -0
  230. package/dist/components/transcript/attachment-file-source.d.ts +23 -0
  231. package/dist/components/transcript/attachment-file-source.js +103 -0
  232. package/dist/components/transcript/attachment-gallery.d.ts +12 -0
  233. package/dist/components/transcript/attachment-gallery.js +33 -0
  234. package/dist/components/transcript/detail-parts.d.ts +50 -0
  235. package/dist/components/transcript/detail-parts.js +295 -0
  236. package/dist/components/transcript/disclosure-state.d.ts +6 -0
  237. package/dist/components/transcript/disclosure-state.js +32 -0
  238. package/dist/components/transcript/disclosure-store.d.ts +8 -0
  239. package/dist/components/transcript/disclosure-store.js +31 -0
  240. package/dist/components/transcript/document-model.d.ts +15 -0
  241. package/dist/components/transcript/document-model.js +104 -0
  242. package/dist/components/transcript/document-plan.d.ts +28 -0
  243. package/dist/components/transcript/document-plan.js +145 -0
  244. package/dist/components/transcript/fold-preference.d.ts +17 -0
  245. package/dist/components/transcript/fold-preference.js +63 -0
  246. package/dist/components/transcript/glyphs.d.ts +15 -0
  247. package/dist/components/transcript/glyphs.js +47 -0
  248. package/dist/components/transcript/index.d.ts +23 -0
  249. package/dist/components/transcript/index.js +22 -0
  250. package/dist/components/transcript/message-file-source.d.ts +15 -0
  251. package/dist/components/transcript/message-file-source.js +31 -0
  252. package/dist/components/transcript/message-preview.d.ts +9 -0
  253. package/dist/components/transcript/message-preview.js +46 -0
  254. package/dist/components/transcript/read-file-source.d.ts +7 -0
  255. package/dist/components/transcript/read-file-source.js +34 -0
  256. package/dist/components/transcript/reader-context.d.ts +13 -0
  257. package/dist/components/transcript/reader-context.js +55 -0
  258. package/dist/components/transcript/reading-identity.d.ts +2 -0
  259. package/dist/components/transcript/reading-identity.js +52 -0
  260. package/dist/components/transcript/scroll-to-row.d.ts +2 -0
  261. package/dist/components/transcript/scroll-to-row.js +13 -0
  262. package/dist/components/transcript/thread-index.d.ts +14 -0
  263. package/dist/components/transcript/thread-index.js +40 -0
  264. package/dist/components/transcript/thread-navigation.d.ts +5 -0
  265. package/dist/components/transcript/thread-navigation.js +3 -0
  266. package/dist/components/transcript/timeline-meta-file-source.d.ts +6 -0
  267. package/dist/components/transcript/timeline-meta-file-source.js +55 -0
  268. package/dist/components/transcript/timeline-meta-state.d.ts +12 -0
  269. package/dist/components/transcript/timeline-meta-state.js +24 -0
  270. package/dist/components/ui/ColumnHeading.d.ts +27 -0
  271. package/dist/components/ui/ColumnHeading.js +7 -0
  272. package/dist/components/ui/ConfirmDialog.d.ts +14 -0
  273. package/dist/components/ui/ConfirmDialog.js +22 -0
  274. package/dist/components/ui/DialogShell.d.ts +18 -0
  275. package/dist/components/ui/DialogShell.js +40 -0
  276. package/dist/components/ui/EmptyState.d.ts +10 -0
  277. package/dist/components/ui/EmptyState.js +6 -0
  278. package/dist/components/ui/ListSummaryHeader.d.ts +9 -0
  279. package/dist/components/ui/ListSummaryHeader.js +6 -0
  280. package/dist/components/ui/ListToolbar.d.ts +6 -0
  281. package/dist/components/ui/ListToolbar.js +5 -0
  282. package/dist/components/ui/ResultGroupHeader.d.ts +9 -0
  283. package/dist/components/ui/ResultGroupHeader.js +5 -0
  284. package/dist/components/ui/SegmentedControl.d.ts +16 -0
  285. package/dist/components/ui/SegmentedControl.js +9 -0
  286. package/dist/components/ui/SummaryMetric.d.ts +13 -0
  287. package/dist/components/ui/SummaryMetric.js +10 -0
  288. package/dist/components/ui/Veil.d.ts +7 -0
  289. package/dist/components/ui/Veil.js +5 -0
  290. package/dist/components/ui/index.d.ts +20 -0
  291. package/dist/components/ui/index.js +10 -0
  292. package/dist/components/worktree/WorktreeColumn.d.ts +22 -0
  293. package/dist/components/worktree/WorktreeColumn.js +170 -0
  294. package/dist/components/worktree/WorktreeFileTree.d.ts +19 -0
  295. package/dist/components/worktree/WorktreeFileTree.js +60 -0
  296. package/dist/components/worktree/WorktreeHeader.d.ts +32 -0
  297. package/dist/components/worktree/WorktreeHeader.js +81 -0
  298. package/dist/components/worktree/WorktreeList.d.ts +8 -0
  299. package/dist/components/worktree/WorktreeList.js +12 -0
  300. package/dist/components/worktree/index.d.ts +12 -0
  301. package/dist/components/worktree/index.js +7 -0
  302. package/dist/components/worktree/types.d.ts +17 -0
  303. package/dist/components/worktree/types.js +3 -0
  304. package/dist/components/worktree/use-worktree-guest.d.ts +21 -0
  305. package/dist/components/worktree/use-worktree-guest.js +92 -0
  306. package/dist/components/worktree/worktree-file-commands.d.ts +19 -0
  307. package/dist/components/worktree/worktree-file-commands.js +112 -0
  308. package/dist/components/worktree/worktree-file-source.d.ts +15 -0
  309. package/dist/components/worktree/worktree-file-source.js +75 -0
  310. package/dist/components/worktree/worktree-host.d.ts +31 -0
  311. package/dist/components/worktree/worktree-host.js +242 -0
  312. package/dist/fixtures/index.d.ts +24 -0
  313. package/dist/fixtures/index.js +292 -0
  314. package/dist/host-inputs.d.ts +231 -0
  315. package/dist/host-inputs.js +35 -0
  316. package/dist/index.d.ts +18 -0
  317. package/dist/index.js +14 -0
  318. package/dist/lib/activity-details.d.ts +23 -0
  319. package/dist/lib/activity-details.js +78 -0
  320. package/dist/lib/activity-order.d.ts +32 -0
  321. package/dist/lib/activity-order.js +86 -0
  322. package/dist/lib/agent-paths.d.ts +6 -0
  323. package/dist/lib/agent-paths.js +19 -0
  324. package/dist/lib/agents.d.ts +15 -0
  325. package/dist/lib/agents.js +60 -0
  326. package/dist/lib/catalog-status.d.ts +3 -0
  327. package/dist/lib/catalog-status.js +10 -0
  328. package/dist/lib/chart-data.d.ts +14 -0
  329. package/dist/lib/chart-data.js +151 -0
  330. package/dist/lib/day-activity.d.ts +21 -0
  331. package/dist/lib/day-activity.js +56 -0
  332. package/dist/lib/format.d.ts +24 -0
  333. package/dist/lib/format.js +116 -0
  334. package/dist/lib/hooks.d.ts +118 -0
  335. package/dist/lib/hooks.js +608 -0
  336. package/dist/lib/icons.d.ts +21 -0
  337. package/dist/lib/icons.js +49 -0
  338. package/dist/lib/image-media.d.ts +6 -0
  339. package/dist/lib/image-media.js +30 -0
  340. package/dist/lib/ingest-activity.d.ts +50 -0
  341. package/dist/lib/ingest-activity.js +151 -0
  342. package/dist/lib/ingest.d.ts +25 -0
  343. package/dist/lib/ingest.js +70 -0
  344. package/dist/lib/model-labels.d.ts +5 -0
  345. package/dist/lib/model-labels.js +28 -0
  346. package/dist/lib/model.d.ts +73 -0
  347. package/dist/lib/model.js +141 -0
  348. package/dist/lib/motion.d.ts +13 -0
  349. package/dist/lib/motion.js +80 -0
  350. package/dist/lib/room-storage.d.ts +13 -0
  351. package/dist/lib/room-storage.js +40 -0
  352. package/dist/lib/search-results.d.ts +27 -0
  353. package/dist/lib/search-results.js +83 -0
  354. package/dist/lib/search-sheet.d.ts +119 -0
  355. package/dist/lib/search-sheet.js +282 -0
  356. package/dist/lib/sections.d.ts +19 -0
  357. package/dist/lib/sections.js +36 -0
  358. package/dist/lib/session-activity.d.ts +5 -0
  359. package/dist/lib/session-activity.js +15 -0
  360. package/dist/lib/session-leases.d.ts +15 -0
  361. package/dist/lib/session-leases.js +61 -0
  362. package/dist/lib/spend.d.ts +42 -0
  363. package/dist/lib/spend.js +112 -0
  364. package/dist/lib/tint.d.ts +9 -0
  365. package/dist/lib/tint.js +53 -0
  366. package/dist/lib/transcript/collaboration.d.ts +97 -0
  367. package/dist/lib/transcript/collaboration.js +423 -0
  368. package/dist/lib/transcript/families.d.ts +212 -0
  369. package/dist/lib/transcript/families.js +906 -0
  370. package/dist/lib/transcript/favicons.d.ts +54 -0
  371. package/dist/lib/transcript/favicons.js +183 -0
  372. package/dist/lib/transcript/head-of-document.d.ts +27 -0
  373. package/dist/lib/transcript/head-of-document.js +274 -0
  374. package/dist/lib/transcript/head-state.d.ts +182 -0
  375. package/dist/lib/transcript/head-state.js +305 -0
  376. package/dist/lib/transcript/history-window.d.ts +13 -0
  377. package/dist/lib/transcript/history-window.js +52 -0
  378. package/dist/lib/transcript/images.d.ts +8 -0
  379. package/dist/lib/transcript/images.js +60 -0
  380. package/dist/lib/transcript/index.d.ts +15 -0
  381. package/dist/lib/transcript/index.js +8 -0
  382. package/dist/lib/transcript/ledger.d.ts +143 -0
  383. package/dist/lib/transcript/ledger.js +513 -0
  384. package/dist/lib/transcript/protocol.d.ts +23 -0
  385. package/dist/lib/transcript/protocol.js +1 -0
  386. package/dist/lib/transcript/sittings.d.ts +75 -0
  387. package/dist/lib/transcript/sittings.js +147 -0
  388. package/dist/lib/transcript/tail-scroll.d.ts +36 -0
  389. package/dist/lib/transcript/tail-scroll.js +167 -0
  390. package/dist/lib/transcript/tail-state.d.ts +17 -0
  391. package/dist/lib/transcript/tail-state.js +30 -0
  392. package/dist/lib/transcript/turns.d.ts +192 -0
  393. package/dist/lib/transcript/turns.js +576 -0
  394. package/dist/lib/transcript/use-transcript-opening.d.ts +12 -0
  395. package/dist/lib/transcript/use-transcript-opening.js +31 -0
  396. package/dist/lib/transcript/use-transcript-tail.d.ts +25 -0
  397. package/dist/lib/transcript/use-transcript-tail.js +158 -0
  398. package/dist/lib/transcript/vocabulary.d.ts +119 -0
  399. package/dist/lib/transcript/vocabulary.js +293 -0
  400. package/dist/lib/transcript/web-address.d.ts +6 -0
  401. package/dist/lib/transcript/web-address.js +18 -0
  402. package/dist/lib/transcript/workflow.d.ts +31 -0
  403. package/dist/lib/transcript/workflow.js +133 -0
  404. package/dist/lib/use-activity-order.d.ts +2 -0
  405. package/dist/lib/use-activity-order.js +23 -0
  406. package/dist/lib/use-day-usage.d.ts +8 -0
  407. package/dist/lib/use-day-usage.js +31 -0
  408. package/dist/lib/use-deferred-list-order.d.ts +26 -0
  409. package/dist/lib/use-deferred-list-order.js +142 -0
  410. package/dist/lib/use-ingest-activity.d.ts +2 -0
  411. package/dist/lib/use-ingest-activity.js +49 -0
  412. package/dist/lib/use-list-motion.d.ts +4 -0
  413. package/dist/lib/use-list-motion.js +67 -0
  414. package/dist/ports.d.ts +222 -0
  415. package/dist/ports.js +3 -0
  416. package/dist/room-context.d.ts +60 -0
  417. package/dist/room-context.js +87 -0
  418. package/dist/styles/activity-chart.css +127 -0
  419. package/dist/styles/attachments.css +29 -0
  420. package/dist/styles/favicon.css +73 -0
  421. package/dist/styles/history-room.css +18 -0
  422. package/dist/styles/host-inputs.css +250 -0
  423. package/dist/styles/image-gallery.css +30 -0
  424. package/dist/styles/ingest.css +51 -0
  425. package/dist/styles/message-preview.css +34 -0
  426. package/dist/styles/models-chart.css +66 -0
  427. package/dist/styles/project-chart.css +19 -0
  428. package/dist/styles/reader.css +33 -0
  429. package/dist/styles/room.css +1411 -0
  430. package/dist/styles/search.css +252 -0
  431. package/dist/styles/transcript-activity.css +70 -0
  432. package/dist/styles/transcript-head.css +220 -0
  433. package/dist/styles/transcript-loading.css +57 -0
  434. package/dist/styles/transcript.css +1226 -0
  435. package/package.json +61 -4
@@ -0,0 +1,115 @@
1
+ // Which language a file is in, and what to call it.
2
+ //
3
+ // Extension only — never content sniffing. A viewer that guesses the language
4
+ // from the bytes is right most of the time and confidently wrong the rest,
5
+ // and the name it prints is the reader's only way to tell which happened. The
6
+ // file name is a claim its author made; this table just reads it.
7
+ import * as grammars from "./grammars.js";
8
+ import { tokenize } from "./tokenize.js";
9
+ import { tokenizeConfig } from "./tokenize-config.js";
10
+ import { tokenizeCss } from "./tokenize-css.js";
11
+ import { tokenizeMarkup } from "./tokenize-markup.js";
12
+ const withGrammar = (id, label, grammar) => ({
13
+ id,
14
+ label,
15
+ tokenize: (text) => tokenize(text, grammar),
16
+ });
17
+ const language = (id, label, run) => ({
18
+ id,
19
+ label,
20
+ tokenize: run,
21
+ });
22
+ export const PLAIN_TEXT = withGrammar("text", "Text", grammars.plain);
23
+ const TYPESCRIPT = withGrammar("typescript", "TypeScript", grammars.typescript);
24
+ const JAVASCRIPT = withGrammar("javascript", "JavaScript", grammars.typescript);
25
+ const RUST = withGrammar("rust", "Rust", grammars.rust);
26
+ const PYTHON = withGrammar("python", "Python", grammars.python);
27
+ const GO = withGrammar("go", "Go", grammars.go);
28
+ const C = withGrammar("c", "C", grammars.c);
29
+ const CPP = withGrammar("cpp", "C++", grammars.c);
30
+ const JAVA = withGrammar("java", "Java", grammars.java);
31
+ const KOTLIN = withGrammar("kotlin", "Kotlin", grammars.java);
32
+ const SWIFT = withGrammar("swift", "Swift", grammars.swift);
33
+ const RUBY = withGrammar("ruby", "Ruby", grammars.ruby);
34
+ const PHP = withGrammar("php", "PHP", grammars.php);
35
+ const SHELL = withGrammar("shell", "Shell", grammars.shell);
36
+ const SQL = withGrammar("sql", "SQL", grammars.sql);
37
+ const LUA = withGrammar("lua", "Lua", grammars.lua);
38
+ const JSON_LANG = withGrammar("json", "JSON", grammars.json);
39
+ const CSS = language("css", "CSS", tokenizeCss);
40
+ const SCSS = language("scss", "SCSS", tokenizeCss);
41
+ const HTML = language("html", "HTML", tokenizeMarkup);
42
+ const XML = language("xml", "XML", tokenizeMarkup);
43
+ const SVG = language("svg", "SVG", tokenizeMarkup);
44
+ const YAML = language("yaml", "YAML", tokenizeConfig);
45
+ const TOML = language("toml", "TOML", tokenizeConfig);
46
+ const INI = language("ini", "INI", tokenizeConfig);
47
+ /** Markdown read as its own source: the renderer is the markdown view, and
48
+ * this is what the `source` switch drops back to. */
49
+ const MARKDOWN = language("markdown", "Markdown", (text) => tokenize(text, grammars.plain));
50
+ const BY_EXTENSION = new Map([
51
+ ["ts", TYPESCRIPT], ["tsx", TYPESCRIPT], ["mts", TYPESCRIPT], ["cts", TYPESCRIPT],
52
+ ["js", JAVASCRIPT], ["jsx", JAVASCRIPT], ["mjs", JAVASCRIPT], ["cjs", JAVASCRIPT],
53
+ ["rs", RUST],
54
+ ["py", PYTHON], ["pyi", PYTHON], ["pyw", PYTHON],
55
+ ["go", GO],
56
+ ["c", C], ["h", C],
57
+ ["cc", CPP], ["cpp", CPP], ["cxx", CPP], ["hpp", CPP], ["hh", CPP], ["hxx", CPP],
58
+ ["java", JAVA],
59
+ ["kt", KOTLIN], ["kts", KOTLIN],
60
+ ["swift", SWIFT],
61
+ ["rb", RUBY], ["rake", RUBY], ["gemspec", RUBY],
62
+ ["php", PHP],
63
+ ["sh", SHELL], ["bash", SHELL], ["zsh", SHELL], ["fish", SHELL], ["ksh", SHELL],
64
+ ["sql", SQL],
65
+ ["lua", LUA],
66
+ ["json", JSON_LANG], ["jsonc", JSON_LANG], ["json5", JSON_LANG], ["webmanifest", JSON_LANG],
67
+ ["css", CSS],
68
+ ["scss", SCSS], ["sass", SCSS], ["less", SCSS],
69
+ ["html", HTML], ["htm", HTML], ["vue", HTML], ["svelte", HTML],
70
+ ["xml", XML], ["xsl", XML], ["xsd", XML], ["plist", XML], ["storyboard", XML], ["xib", XML],
71
+ ["svg", SVG],
72
+ ["yaml", YAML], ["yml", YAML],
73
+ ["toml", TOML], ["lock", TOML],
74
+ ["ini", INI], ["cfg", INI], ["conf", INI], ["properties", INI], ["editorconfig", INI],
75
+ ["md", MARKDOWN], ["markdown", MARKDOWN], ["mdx", MARKDOWN],
76
+ ["txt", PLAIN_TEXT], ["log", PLAIN_TEXT], ["csv", PLAIN_TEXT], ["tsv", PLAIN_TEXT],
77
+ ]);
78
+ /** Files whose name carries the language and whose extension does not. */
79
+ const BY_NAME = new Map([
80
+ ["Makefile", language("make", "Makefile", (text) => tokenize(text, grammars.shell))],
81
+ ["Dockerfile", language("dockerfile", "Dockerfile", (text) => tokenize(text, grammars.shell))],
82
+ ["Gemfile", RUBY],
83
+ ["Rakefile", RUBY],
84
+ ["Podfile", RUBY],
85
+ ["Cargo.lock", TOML],
86
+ [".gitignore", language("gitignore", "Ignore rules", (text) => tokenize(text, grammars.shell))],
87
+ [".gitattributes", PLAIN_TEXT],
88
+ [".npmrc", INI],
89
+ [".env", SHELL],
90
+ ["LICENSE", PLAIN_TEXT],
91
+ ]);
92
+ /** The last dot-segment of a name, lowercased. `""` when there is no dot. */
93
+ export function extensionOf(name) {
94
+ const dot = name.lastIndexOf(".");
95
+ return dot <= 0 ? "" : name.slice(dot + 1).toLowerCase();
96
+ }
97
+ /** The language a file name claims, or `null` when no entry matches — which
98
+ * is a different answer from "plain text", and the caller decides what to do
99
+ * with the difference. */
100
+ export function languageFor(name) {
101
+ const byName = BY_NAME.get(name);
102
+ if (byName !== undefined)
103
+ return byName;
104
+ // `.env.local`, `.eslintrc.json` — the leading dot is part of the name, so
105
+ // the extension search has to start after it.
106
+ const stem = name.startsWith(".") ? name.slice(1) : name;
107
+ const dot = stem.indexOf(".");
108
+ if (dot !== -1) {
109
+ const byPrefix = BY_NAME.get(`.${stem.slice(0, dot)}`);
110
+ if (byPrefix !== undefined && BY_EXTENSION.get(extensionOf(name)) === undefined) {
111
+ return byPrefix;
112
+ }
113
+ }
114
+ return BY_EXTENSION.get(extensionOf(name)) ?? null;
115
+ }
@@ -0,0 +1,2 @@
1
+ import type { Token } from "./types.js";
2
+ export declare function tokenizeConfig(text: string): readonly Token[];
@@ -0,0 +1,132 @@
1
+ // YAML, TOML and INI. These are line-shaped languages: what a token means
2
+ // depends on where it sits in its line and almost never on the line before,
3
+ // so the lexer is a per-line reader rather than a character machine.
4
+ //
5
+ // The one exception is YAML's block scalar (`key: |`), whose body is prose
6
+ // that must not be lexed as config. That is carried across lines by
7
+ // indentation, which is the only state this file keeps.
8
+ const KEY = /(?:"[^"\n]*"|'[^'\n]*'|\[\[?[^\]\n]*\]\]?|[A-Za-z0-9_.$/-]+)(?=[ \t]*[:=])/y;
9
+ const SECTION = /\[\[?[^\]\n]*\]\]?/y;
10
+ const STRING = /"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:[^"\\\n]|\\.)*"|'[^'\n]*'/y;
11
+ const NUMBER = /[+-]?(?:0[xXbBoO][0-9a-fA-F_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)/y;
12
+ const DATE = /\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?/y;
13
+ const ANCHOR = /[&*][A-Za-z0-9_-]+/y;
14
+ const WORD = /[A-Za-z_][A-Za-z0-9_.-]*/y;
15
+ const CONSTANTS = new Set([
16
+ "true", "false", "null", "yes", "no", "on", "off", "True", "False", "Null", "None",
17
+ "TRUE", "FALSE", "NULL", "~",
18
+ ]);
19
+ export function tokenizeConfig(text) {
20
+ const out = [];
21
+ const push = (kind, value) => {
22
+ if (value.length > 0)
23
+ out.push({ kind, text: value });
24
+ };
25
+ /** Indentation of the block scalar currently being consumed as prose, or
26
+ * null when there is none. */
27
+ let literalIndent = null;
28
+ const lines = text.split("\n");
29
+ lines.forEach((line, lineIndex) => {
30
+ if (lineIndex > 0)
31
+ push("plain", "\n");
32
+ const indent = line.length - line.trimStart().length;
33
+ if (literalIndent !== null) {
34
+ if (line.trim() === "" || indent > literalIndent) {
35
+ push("string", line);
36
+ return;
37
+ }
38
+ literalIndent = null;
39
+ }
40
+ let index = 0;
41
+ const match = (pattern) => {
42
+ pattern.lastIndex = index;
43
+ const found = pattern.exec(line);
44
+ return found === null ? null : found[0];
45
+ };
46
+ const emit = (kind, value) => {
47
+ push(kind, value);
48
+ index += value.length;
49
+ };
50
+ const skipSpace = () => {
51
+ const space = match(/[ \t]+/y);
52
+ if (space !== null)
53
+ emit("plain", space);
54
+ };
55
+ skipSpace();
56
+ if (index >= line.length) {
57
+ push("plain", line.slice(index));
58
+ return;
59
+ }
60
+ if (line[index] === "#" || line[index] === ";") {
61
+ emit("comment", line.slice(index));
62
+ return;
63
+ }
64
+ // A list item is a marker plus a value — or plus a key, for a list of
65
+ // tables, which is why this falls through rather than returning.
66
+ while (line[index] === "-" && (line[index + 1] === " " || index + 1 === line.length)) {
67
+ emit("operator", "-");
68
+ skipSpace();
69
+ }
70
+ const section = line[index] === "[" ? match(SECTION) : null;
71
+ if (section !== null) {
72
+ emit("type", section);
73
+ skipSpace();
74
+ if (line[index] === "#" || line[index] === ";")
75
+ emit("comment", line.slice(index));
76
+ return;
77
+ }
78
+ const key = match(KEY);
79
+ if (key !== null) {
80
+ emit("property", key);
81
+ skipSpace();
82
+ emit("operator", line[index] ?? "");
83
+ skipSpace();
84
+ }
85
+ // Whatever is left of the line is a value.
86
+ while (index < line.length) {
87
+ const char = line[index];
88
+ if (char === "#" && (index === 0 || /[ \t]/.test(line[index - 1] ?? " "))) {
89
+ emit("comment", line.slice(index));
90
+ break;
91
+ }
92
+ if (/[ \t]/.test(char)) {
93
+ skipSpace();
94
+ continue;
95
+ }
96
+ if ((char === "|" || char === ">") && index === line.length - 1) {
97
+ emit("operator", char);
98
+ literalIndent = indent;
99
+ break;
100
+ }
101
+ if (char === '"' || char === "'") {
102
+ const string = match(STRING);
103
+ emit("string", string ?? line.slice(index));
104
+ continue;
105
+ }
106
+ if (char === "&" || char === "*") {
107
+ const anchor = match(ANCHOR);
108
+ if (anchor !== null) {
109
+ emit("type", anchor);
110
+ continue;
111
+ }
112
+ }
113
+ const date = match(DATE);
114
+ if (date !== null) {
115
+ emit("number", date);
116
+ continue;
117
+ }
118
+ const number = match(NUMBER);
119
+ if (number !== null) {
120
+ emit("number", number);
121
+ continue;
122
+ }
123
+ const word = match(WORD);
124
+ if (word !== null) {
125
+ emit(CONSTANTS.has(word) ? "constant" : "plain", word);
126
+ continue;
127
+ }
128
+ emit(CONSTANTS.has(char) ? "constant" : "operator", char);
129
+ }
130
+ });
131
+ return out;
132
+ }
@@ -0,0 +1,2 @@
1
+ import type { Token } from "./types.js";
2
+ export declare function tokenizeCss(text: string): readonly Token[];
@@ -0,0 +1,169 @@
1
+ // CSS, SCSS and Less. A stylesheet has three worlds rather than one — the
2
+ // selector, the property, the value — and the same identifier means a
3
+ // different thing in each. So the lexer carries the one bit of state that
4
+ // tells them apart: whether it is inside a block, and whether it is past the
5
+ // colon.
6
+ const IDENTIFIER = /-{0,2}[A-Za-z_][A-Za-z0-9_-]*/y;
7
+ const AT_RULE = /@[A-Za-z-]+/y;
8
+ const HEX = /#[0-9a-fA-F]{3,8}\b/y;
9
+ const NUMBER = /[+-]?(?:\d+\.?\d*|\.\d+)(?:%|[a-zA-Z]+)?/y;
10
+ const VARIABLE = /[$@][A-Za-z_][A-Za-z0-9_-]*/y;
11
+ const PSEUDO = /::?[A-Za-z-][A-Za-z0-9_-]*/y;
12
+ const ID_SELECTOR = /#[A-Za-z_-][A-Za-z0-9_-]*/y;
13
+ const CLASS_SELECTOR = /\.[A-Za-z_-][A-Za-z0-9_-]*/y;
14
+ const WHITESPACE = /[ \t\r\n]+/y;
15
+ /** Values the language names, as opposed to values an author invents. */
16
+ const VALUE_CONSTANTS = new Set([
17
+ "auto", "inherit", "initial", "unset", "none", "revert", "currentColor", "transparent",
18
+ "true", "false", "important",
19
+ ]);
20
+ export function tokenizeCss(text) {
21
+ const out = [];
22
+ let index = 0;
23
+ let depth = 0;
24
+ /** Past the `:` of a declaration, where identifiers are values. */
25
+ let inValue = false;
26
+ const push = (kind, value) => {
27
+ if (value.length === 0)
28
+ return;
29
+ out.push({ kind, text: value });
30
+ index += value.length;
31
+ };
32
+ const match = (pattern) => {
33
+ pattern.lastIndex = index;
34
+ const found = pattern.exec(text);
35
+ return found === null ? null : found[0];
36
+ };
37
+ const through = (from, closer) => {
38
+ const at = text.indexOf(closer, from);
39
+ return at === -1 ? text.slice(index) : text.slice(index, at + closer.length);
40
+ };
41
+ const peekNonSpace = (from) => {
42
+ let i = from;
43
+ while (i < text.length && /[ \t\r\n]/.test(text[i]))
44
+ i += 1;
45
+ return text[i] ?? "";
46
+ };
47
+ while (index < text.length) {
48
+ const char = text[index];
49
+ if (/[ \t\r\n]/.test(char)) {
50
+ push("plain", match(WHITESPACE) ?? char);
51
+ continue;
52
+ }
53
+ if (text.startsWith("/*", index)) {
54
+ push("comment", through(index + 2, "*/"));
55
+ continue;
56
+ }
57
+ // SCSS and Less only; plain CSS has no line comment, and a file that
58
+ // uses one is not plain CSS.
59
+ if (text.startsWith("//", index)) {
60
+ const end = text.indexOf("\n", index);
61
+ push("comment", text.slice(index, end === -1 ? text.length : end));
62
+ continue;
63
+ }
64
+ if (char === '"' || char === "'") {
65
+ push("string", through(index + 1, char));
66
+ continue;
67
+ }
68
+ if (char === "{") {
69
+ push("operator", "{");
70
+ depth += 1;
71
+ inValue = false;
72
+ continue;
73
+ }
74
+ if (char === "}") {
75
+ push("operator", "}");
76
+ depth = Math.max(0, depth - 1);
77
+ inValue = false;
78
+ continue;
79
+ }
80
+ if (char === ";") {
81
+ push("operator", ";");
82
+ inValue = false;
83
+ continue;
84
+ }
85
+ if (char === ":") {
86
+ // Inside a block a colon opens a value; in a selector it opens a
87
+ // pseudo-class, which is part of the name rather than a separator.
88
+ if (depth > 0 && !inValue) {
89
+ push("operator", ":");
90
+ inValue = true;
91
+ continue;
92
+ }
93
+ const pseudo = match(PSEUDO);
94
+ push(pseudo === null ? "operator" : "constant", pseudo ?? ":");
95
+ continue;
96
+ }
97
+ // A Less variable is a VALUE, so it is the value position that tells it
98
+ // apart from an at-rule — not the nesting depth, which reads SCSS's
99
+ // nested `@media` as a variable.
100
+ if (char === "$" || (char === "@" && inValue)) {
101
+ const variable = match(VARIABLE);
102
+ if (variable !== null) {
103
+ push("constant", variable);
104
+ continue;
105
+ }
106
+ }
107
+ if (char === "@") {
108
+ const atRule = match(AT_RULE);
109
+ if (atRule !== null) {
110
+ push("keyword", atRule);
111
+ continue;
112
+ }
113
+ }
114
+ if (char === "!") {
115
+ const bang = match(/![ \t]*[a-z]+/y);
116
+ if (bang !== null) {
117
+ push("keyword", bang);
118
+ continue;
119
+ }
120
+ }
121
+ if (char === "#") {
122
+ const hex = match(HEX);
123
+ if (hex !== null) {
124
+ push("number", hex);
125
+ continue;
126
+ }
127
+ // Not a colour, so an id selector.
128
+ const id = match(ID_SELECTOR);
129
+ push(id === null ? "operator" : "type", id ?? "#");
130
+ continue;
131
+ }
132
+ if (char === ".") {
133
+ const className = match(CLASS_SELECTOR);
134
+ if (className !== null) {
135
+ push("type", className);
136
+ continue;
137
+ }
138
+ }
139
+ // `-4px` is one negative length, not an operator and a length. `--x` and
140
+ // `-webkit-` are not numbers, and the digit test is what separates them.
141
+ if (/[0-9]/.test(char) ||
142
+ ((char === "." || char === "-") && /[0-9.]/.test(text[index + 1] ?? ""))) {
143
+ const number = match(NUMBER);
144
+ if (number !== null) {
145
+ push("number", number);
146
+ continue;
147
+ }
148
+ }
149
+ const word = match(IDENTIFIER);
150
+ if (word !== null) {
151
+ const next = peekNonSpace(index + word.length);
152
+ let kind;
153
+ if (next === "(")
154
+ kind = "function";
155
+ else if (word.startsWith("--"))
156
+ kind = "property";
157
+ else if (inValue)
158
+ kind = VALUE_CONSTANTS.has(word) ? "constant" : "plain";
159
+ else if (depth > 0)
160
+ kind = "property";
161
+ else
162
+ kind = "tag";
163
+ push(kind, word);
164
+ continue;
165
+ }
166
+ push("operator", char);
167
+ }
168
+ return out;
169
+ }
@@ -0,0 +1,2 @@
1
+ import type { Token } from "./types.js";
2
+ export declare function tokenizeMarkup(text: string): readonly Token[];
@@ -0,0 +1,124 @@
1
+ // HTML, XML and SVG. Markup is not the C family wearing different keywords —
2
+ // it has two alternating worlds, text and tag, and a table-driven lexer that
3
+ // pretends otherwise paints attribute values as identifiers.
4
+ //
5
+ // A tag name takes the `tag` kind and an attribute name takes `property`,
6
+ // which share their accents with `keyword` and an object key. They are the
7
+ // same two roles in another syntax, and the room should not teach a reader
8
+ // two palettes for one idea.
9
+ const TAG_NAME = /[A-Za-z_][A-Za-z0-9_:.-]*/y;
10
+ /** Plain `href`, and the framework spellings a real page is full of:
11
+ * `v-if`, `:class`, `@click`, `#ref`, `[prop]`, `(click)`. */
12
+ const ATTRIBUTE_NAME = /[A-Za-z_@:#$[(][-A-Za-z0-9_@:.$\])]*/y;
13
+ const ENTITY = /&[a-zA-Z][a-zA-Z0-9]*;|&#[0-9]+;|&#x[0-9a-fA-F]+;/y;
14
+ /** Elements whose body is another language, not markup. */
15
+ const RAW_TEXT = new Set(["script", "style"]);
16
+ export function tokenizeMarkup(text) {
17
+ const out = [];
18
+ let index = 0;
19
+ const push = (kind, value) => {
20
+ if (value.length === 0)
21
+ return;
22
+ out.push({ kind, text: value });
23
+ index += value.length;
24
+ };
25
+ /** Everything up to `end`, or the rest of the file when it never arrives. */
26
+ const through = (from, closer) => {
27
+ const at = text.indexOf(closer, from);
28
+ return at === -1 ? text.slice(index) : text.slice(index, at + closer.length);
29
+ };
30
+ const match = (pattern) => {
31
+ pattern.lastIndex = index;
32
+ const found = pattern.exec(text);
33
+ return found === null ? null : found[0];
34
+ };
35
+ /** Where `<script>`'s body ends. Lowercased lazily: most files have no raw
36
+ * text in them and should not pay for a second copy of themselves. */
37
+ let lowered = null;
38
+ const rawTextEnd = (from, tag) => {
39
+ lowered ??= text.toLowerCase();
40
+ const at = lowered.indexOf(`</${tag.toLowerCase()}`, from);
41
+ return at === -1 ? text.length : at;
42
+ };
43
+ /** A quoted attribute value, stopped at the end of the line when the quote
44
+ * never closes. Losing a wrapped value is a smaller wrong than one typo
45
+ * painting the rest of the document as a string — which is the same trade
46
+ * the generic tokenizer already makes for a single-line literal. */
47
+ const attributeValue = (quote) => {
48
+ const raw = through(index + 1, quote);
49
+ const newline = raw.indexOf("\n");
50
+ return newline === -1 ? raw : raw.slice(0, newline);
51
+ };
52
+ while (index < text.length) {
53
+ if (text.startsWith("<!--", index)) {
54
+ push("comment", through(index + 4, "-->"));
55
+ continue;
56
+ }
57
+ if (text.startsWith("<![CDATA[", index)) {
58
+ push("string", through(index + 9, "]]>"));
59
+ continue;
60
+ }
61
+ if (text.startsWith("<!", index) || text.startsWith("<?", index)) {
62
+ push("keyword", through(index + 2, ">"));
63
+ continue;
64
+ }
65
+ if (text[index] === "<") {
66
+ const closing = text.startsWith("</", index);
67
+ push("operator", closing ? "</" : "<");
68
+ const name = match(TAG_NAME);
69
+ if (name !== null)
70
+ push("tag", name);
71
+ // Inside the tag until `>`: attribute, `=`, value, repeat.
72
+ while (index < text.length && text[index] !== ">") {
73
+ const char = text[index];
74
+ if (char === " " || char === "\t" || char === "\n" || char === "\r") {
75
+ push("plain", match(/[ \t\r\n]+/y) ?? char);
76
+ continue;
77
+ }
78
+ if (char === "/") {
79
+ push("operator", "/");
80
+ continue;
81
+ }
82
+ if (char === "=") {
83
+ push("operator", "=");
84
+ continue;
85
+ }
86
+ if (char === '"' || char === "'") {
87
+ push("string", attributeValue(char));
88
+ continue;
89
+ }
90
+ const attribute = match(ATTRIBUTE_NAME);
91
+ if (attribute !== null) {
92
+ push("property", attribute);
93
+ continue;
94
+ }
95
+ // An unquoted value, or something this lexer has no name for.
96
+ push("plain", char);
97
+ }
98
+ if (index < text.length) {
99
+ // `<br/>` closed itself; `<div>` did not. The character before the
100
+ // `>` is the whole difference.
101
+ const selfClosing = text[index - 1] === "/";
102
+ push("operator", ">");
103
+ // A `<script>` body is JavaScript, and `if (a < b)` inside it is not
104
+ // the start of a tag. Lexing it as markup used to swallow everything
105
+ // to the next `>` — including the `</script>` that ends the element.
106
+ if (!closing && !selfClosing && name !== null && RAW_TEXT.has(name.toLowerCase())) {
107
+ push("plain", text.slice(index, rawTextEnd(index, name)));
108
+ }
109
+ }
110
+ continue;
111
+ }
112
+ const entity = match(ENTITY);
113
+ if (entity !== null) {
114
+ push("constant", entity);
115
+ continue;
116
+ }
117
+ // Text content, in one run up to the next markup character.
118
+ const next = text.indexOf("<", index + 1);
119
+ const ampersand = text.indexOf("&", index + 1);
120
+ const stop = [next, ampersand].filter((at) => at !== -1).sort((a, b) => a - b)[0] ?? text.length;
121
+ push("plain", text.slice(index, Math.max(stop, index + 1)));
122
+ }
123
+ return out;
124
+ }
@@ -0,0 +1,9 @@
1
+ import type { Grammar, Token, TokenLine } from "./types.js";
2
+ export declare function tokenize(text: string, grammar: Grammar): readonly Token[];
3
+ /**
4
+ * Cut a token stream into lines. Tokens that span newlines — block comments,
5
+ * template literals, docstrings — are split, and each piece keeps its kind,
6
+ * which is the whole reason tokenizing runs over the file rather than over
7
+ * each line in turn.
8
+ */
9
+ export declare function splitLines(tokens: readonly Token[]): readonly TokenLine[];