@inhuman.tools/quickdraw 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (522) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +101 -2
  3. package/aurora.vert +168 -0
  4. package/dist/bench/host.d.ts +62 -0
  5. package/dist/bench/host.d.ts.map +1 -0
  6. package/dist/bench/host.js +77 -0
  7. package/dist/bench/host.js.map +1 -0
  8. package/dist/bench/main.d.ts +6 -0
  9. package/dist/bench/main.d.ts.map +1 -0
  10. package/dist/bench/main.js +118 -0
  11. package/dist/bench/main.js.map +1 -0
  12. package/dist/bench/model.d.ts +36 -0
  13. package/dist/bench/model.d.ts.map +1 -0
  14. package/dist/bench/model.js +112 -0
  15. package/dist/bench/model.js.map +1 -0
  16. package/dist/bench/tea.d.ts +14 -0
  17. package/dist/bench/tea.d.ts.map +1 -0
  18. package/dist/bench/tea.js +6 -0
  19. package/dist/bench/tea.js.map +1 -0
  20. package/dist/bench/view.d.ts +9 -0
  21. package/dist/bench/view.d.ts.map +1 -0
  22. package/dist/bench/view.js +88 -0
  23. package/dist/bench/view.js.map +1 -0
  24. package/dist/bench/worker.d.ts +6 -0
  25. package/dist/bench/worker.d.ts.map +1 -0
  26. package/dist/bench/worker.js +46 -0
  27. package/dist/bench/worker.js.map +1 -0
  28. package/dist/buffer/bgfx-mark.d.ts +32 -0
  29. package/dist/buffer/bgfx-mark.d.ts.map +1 -0
  30. package/dist/buffer/bgfx-mark.js +43 -0
  31. package/dist/buffer/bgfx-mark.js.map +1 -0
  32. package/dist/buffer/index.d.ts +191 -0
  33. package/dist/buffer/index.d.ts.map +1 -0
  34. package/dist/buffer/index.js +353 -0
  35. package/dist/buffer/index.js.map +1 -0
  36. package/dist/capabilities/env.d.ts +23 -0
  37. package/dist/capabilities/env.d.ts.map +1 -0
  38. package/dist/capabilities/env.js +35 -0
  39. package/dist/capabilities/env.js.map +1 -0
  40. package/dist/capabilities/index.d.ts +13 -0
  41. package/dist/capabilities/index.d.ts.map +1 -0
  42. package/dist/capabilities/index.js +13 -0
  43. package/dist/capabilities/index.js.map +1 -0
  44. package/dist/capabilities/parse.d.ts +41 -0
  45. package/dist/capabilities/parse.d.ts.map +1 -0
  46. package/dist/capabilities/parse.js +86 -0
  47. package/dist/capabilities/parse.js.map +1 -0
  48. package/dist/capabilities/probe.d.ts +37 -0
  49. package/dist/capabilities/probe.d.ts.map +1 -0
  50. package/dist/capabilities/probe.js +75 -0
  51. package/dist/capabilities/probe.js.map +1 -0
  52. package/dist/capabilities/sequences.d.ts +33 -0
  53. package/dist/capabilities/sequences.d.ts.map +1 -0
  54. package/dist/capabilities/sequences.js +36 -0
  55. package/dist/capabilities/sequences.js.map +1 -0
  56. package/dist/capabilities/types.d.ts +25 -0
  57. package/dist/capabilities/types.d.ts.map +1 -0
  58. package/dist/capabilities/types.js +5 -0
  59. package/dist/capabilities/types.js.map +1 -0
  60. package/dist/index.d.ts +11 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +11 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/input/decode.d.ts +167 -0
  65. package/dist/input/decode.d.ts.map +1 -0
  66. package/dist/input/decode.js +825 -0
  67. package/dist/input/decode.js.map +1 -0
  68. package/dist/input/draft.d.ts +85 -0
  69. package/dist/input/draft.d.ts.map +1 -0
  70. package/dist/input/draft.js +276 -0
  71. package/dist/input/draft.js.map +1 -0
  72. package/dist/input/index.d.ts +3 -0
  73. package/dist/input/index.d.ts.map +1 -0
  74. package/dist/input/index.js +3 -0
  75. package/dist/input/index.js.map +1 -0
  76. package/dist/input/prompt-blocks.d.ts +58 -0
  77. package/dist/input/prompt-blocks.d.ts.map +1 -0
  78. package/dist/input/prompt-blocks.js +48 -0
  79. package/dist/input/prompt-blocks.js.map +1 -0
  80. package/dist/input/rich-draft.d.ts +46 -0
  81. package/dist/input/rich-draft.d.ts.map +1 -0
  82. package/dist/input/rich-draft.js +391 -0
  83. package/dist/input/rich-draft.js.map +1 -0
  84. package/dist/input/rich-hit.d.ts +17 -0
  85. package/dist/input/rich-hit.d.ts.map +1 -0
  86. package/dist/input/rich-hit.js +89 -0
  87. package/dist/input/rich-hit.js.map +1 -0
  88. package/dist/input/rich-intake.d.ts +16 -0
  89. package/dist/input/rich-intake.d.ts.map +1 -0
  90. package/dist/input/rich-intake.js +22 -0
  91. package/dist/input/rich-intake.js.map +1 -0
  92. package/dist/input/rich-paint.d.ts +13 -0
  93. package/dist/input/rich-paint.d.ts.map +1 -0
  94. package/dist/input/rich-paint.js +18 -0
  95. package/dist/input/rich-paint.js.map +1 -0
  96. package/dist/internals/bgfx/index.d.ts +17 -0
  97. package/dist/internals/bgfx/index.d.ts.map +1 -0
  98. package/dist/internals/bgfx/index.js +17 -0
  99. package/dist/internals/bgfx/index.js.map +1 -0
  100. package/dist/internals/bgfx/materialize.d.ts +31 -0
  101. package/dist/internals/bgfx/materialize.d.ts.map +1 -0
  102. package/dist/internals/bgfx/materialize.js +117 -0
  103. package/dist/internals/bgfx/materialize.js.map +1 -0
  104. package/dist/internals/bgfx/opacity.d.ts +37 -0
  105. package/dist/internals/bgfx/opacity.d.ts.map +1 -0
  106. package/dist/internals/bgfx/opacity.js +76 -0
  107. package/dist/internals/bgfx/opacity.js.map +1 -0
  108. package/dist/internals/bgfx/registry.d.ts +13 -0
  109. package/dist/internals/bgfx/registry.d.ts.map +1 -0
  110. package/dist/internals/bgfx/registry.js +24 -0
  111. package/dist/internals/bgfx/registry.js.map +1 -0
  112. package/dist/internals/bgfx/sab-layout.d.ts +61 -0
  113. package/dist/internals/bgfx/sab-layout.d.ts.map +1 -0
  114. package/dist/internals/bgfx/sab-layout.js +107 -0
  115. package/dist/internals/bgfx/sab-layout.js.map +1 -0
  116. package/dist/internals/bgfx/shader-frame-host.d.ts +22 -0
  117. package/dist/internals/bgfx/shader-frame-host.d.ts.map +1 -0
  118. package/dist/internals/bgfx/shader-frame-host.js +165 -0
  119. package/dist/internals/bgfx/shader-frame-host.js.map +1 -0
  120. package/dist/internals/bgfx/shadertoy-catalog.d.ts +41 -0
  121. package/dist/internals/bgfx/shadertoy-catalog.d.ts.map +1 -0
  122. package/dist/internals/bgfx/shadertoy-catalog.js +200 -0
  123. package/dist/internals/bgfx/shadertoy-catalog.js.map +1 -0
  124. package/dist/internals/bgfx/shadertoy-gl.d.ts +38 -0
  125. package/dist/internals/bgfx/shadertoy-gl.d.ts.map +1 -0
  126. package/dist/internals/bgfx/shadertoy-gl.js +283 -0
  127. package/dist/internals/bgfx/shadertoy-gl.js.map +1 -0
  128. package/dist/internals/bgfx/types.d.ts +51 -0
  129. package/dist/internals/bgfx/types.d.ts.map +1 -0
  130. package/dist/internals/bgfx/types.js +14 -0
  131. package/dist/internals/bgfx/types.js.map +1 -0
  132. package/dist/internals/bgfx-worker.d.ts +6 -0
  133. package/dist/internals/bgfx-worker.d.ts.map +1 -0
  134. package/dist/internals/bgfx-worker.js +131 -0
  135. package/dist/internals/bgfx-worker.js.map +1 -0
  136. package/dist/layout/birth.d.ts +77 -0
  137. package/dist/layout/birth.d.ts.map +1 -0
  138. package/dist/layout/birth.js +148 -0
  139. package/dist/layout/birth.js.map +1 -0
  140. package/dist/layout/children.d.ts +5 -0
  141. package/dist/layout/children.d.ts.map +1 -0
  142. package/dist/layout/children.js +19 -0
  143. package/dist/layout/children.js.map +1 -0
  144. package/dist/layout/chrome_frame.d.ts +254 -0
  145. package/dist/layout/chrome_frame.d.ts.map +1 -0
  146. package/dist/layout/chrome_frame.js +1080 -0
  147. package/dist/layout/chrome_frame.js.map +1 -0
  148. package/dist/layout/chrome_mask.d.ts +40 -0
  149. package/dist/layout/chrome_mask.d.ts.map +1 -0
  150. package/dist/layout/chrome_mask.js +150 -0
  151. package/dist/layout/chrome_mask.js.map +1 -0
  152. package/dist/layout/engine.d.ts +49 -0
  153. package/dist/layout/engine.d.ts.map +1 -0
  154. package/dist/layout/engine.js +1269 -0
  155. package/dist/layout/engine.js.map +1 -0
  156. package/dist/layout/flex.d.ts +36 -0
  157. package/dist/layout/flex.d.ts.map +1 -0
  158. package/dist/layout/flex.js +111 -0
  159. package/dist/layout/flex.js.map +1 -0
  160. package/dist/layout/grid.d.ts +36 -0
  161. package/dist/layout/grid.d.ts.map +1 -0
  162. package/dist/layout/grid.js +126 -0
  163. package/dist/layout/grid.js.map +1 -0
  164. package/dist/layout/index.d.ts +30 -0
  165. package/dist/layout/index.d.ts.map +1 -0
  166. package/dist/layout/index.js +30 -0
  167. package/dist/layout/index.js.map +1 -0
  168. package/dist/layout/indication.d.ts +34 -0
  169. package/dist/layout/indication.d.ts.map +1 -0
  170. package/dist/layout/indication.js +68 -0
  171. package/dist/layout/indication.js.map +1 -0
  172. package/dist/layout/length.d.ts +18 -0
  173. package/dist/layout/length.d.ts.map +1 -0
  174. package/dist/layout/length.js +24 -0
  175. package/dist/layout/length.js.map +1 -0
  176. package/dist/layout/live_paint.d.ts +145 -0
  177. package/dist/layout/live_paint.d.ts.map +1 -0
  178. package/dist/layout/live_paint.js +255 -0
  179. package/dist/layout/live_paint.js.map +1 -0
  180. package/dist/layout/markdown.d.ts +22 -0
  181. package/dist/layout/markdown.d.ts.map +1 -0
  182. package/dist/layout/markdown.js +167 -0
  183. package/dist/layout/markdown.js.map +1 -0
  184. package/dist/layout/measure.d.ts +46 -0
  185. package/dist/layout/measure.d.ts.map +1 -0
  186. package/dist/layout/measure.js +307 -0
  187. package/dist/layout/measure.js.map +1 -0
  188. package/dist/layout/paint-hotkey.d.ts +45 -0
  189. package/dist/layout/paint-hotkey.d.ts.map +1 -0
  190. package/dist/layout/paint-hotkey.js +152 -0
  191. package/dist/layout/paint-hotkey.js.map +1 -0
  192. package/dist/layout/paint.d.ts +25 -0
  193. package/dist/layout/paint.d.ts.map +1 -0
  194. package/dist/layout/paint.js +189 -0
  195. package/dist/layout/paint.js.map +1 -0
  196. package/dist/layout/paint_theme.d.ts +85 -0
  197. package/dist/layout/paint_theme.d.ts.map +1 -0
  198. package/dist/layout/paint_theme.js +76 -0
  199. package/dist/layout/paint_theme.js.map +1 -0
  200. package/dist/layout/progress.d.ts +31 -0
  201. package/dist/layout/progress.d.ts.map +1 -0
  202. package/dist/layout/progress.js +83 -0
  203. package/dist/layout/progress.js.map +1 -0
  204. package/dist/layout/selection.d.ts +136 -0
  205. package/dist/layout/selection.d.ts.map +1 -0
  206. package/dist/layout/selection.js +312 -0
  207. package/dist/layout/selection.js.map +1 -0
  208. package/dist/layout/selection_gesture.d.ts +88 -0
  209. package/dist/layout/selection_gesture.d.ts.map +1 -0
  210. package/dist/layout/selection_gesture.js +239 -0
  211. package/dist/layout/selection_gesture.js.map +1 -0
  212. package/dist/layout/selection_paint.d.ts +47 -0
  213. package/dist/layout/selection_paint.d.ts.map +1 -0
  214. package/dist/layout/selection_paint.js +320 -0
  215. package/dist/layout/selection_paint.js.map +1 -0
  216. package/dist/layout/serialize.d.ts +49 -0
  217. package/dist/layout/serialize.d.ts.map +1 -0
  218. package/dist/layout/serialize.js +437 -0
  219. package/dist/layout/serialize.js.map +1 -0
  220. package/dist/layout/squeeze.d.ts +58 -0
  221. package/dist/layout/squeeze.d.ts.map +1 -0
  222. package/dist/layout/squeeze.js +239 -0
  223. package/dist/layout/squeeze.js.map +1 -0
  224. package/dist/layout/text.d.ts +44 -0
  225. package/dist/layout/text.d.ts.map +1 -0
  226. package/dist/layout/text.js +230 -0
  227. package/dist/layout/text.js.map +1 -0
  228. package/dist/layout/theme_store.d.ts +21 -0
  229. package/dist/layout/theme_store.d.ts.map +1 -0
  230. package/dist/layout/theme_store.js +133 -0
  231. package/dist/layout/theme_store.js.map +1 -0
  232. package/dist/layout/types.d.ts +564 -0
  233. package/dist/layout/types.d.ts.map +1 -0
  234. package/dist/layout/types.js +2 -0
  235. package/dist/layout/types.js.map +1 -0
  236. package/dist/layout/visual_draft.d.ts +60 -0
  237. package/dist/layout/visual_draft.d.ts.map +1 -0
  238. package/dist/layout/visual_draft.js +199 -0
  239. package/dist/layout/visual_draft.js.map +1 -0
  240. package/dist/lexicon/color.d.ts +22 -0
  241. package/dist/lexicon/color.d.ts.map +1 -0
  242. package/dist/lexicon/color.js +6 -0
  243. package/dist/lexicon/color.js.map +1 -0
  244. package/dist/lexicon/index.d.ts +15 -0
  245. package/dist/lexicon/index.d.ts.map +1 -0
  246. package/dist/lexicon/index.js +15 -0
  247. package/dist/lexicon/index.js.map +1 -0
  248. package/dist/lexicon/prominence.d.ts +46 -0
  249. package/dist/lexicon/prominence.d.ts.map +1 -0
  250. package/dist/lexicon/prominence.js +73 -0
  251. package/dist/lexicon/prominence.js.map +1 -0
  252. package/dist/lexicon/quarantine.d.ts +21 -0
  253. package/dist/lexicon/quarantine.d.ts.map +1 -0
  254. package/dist/lexicon/quarantine.js +15 -0
  255. package/dist/lexicon/quarantine.js.map +1 -0
  256. package/dist/lexicon/roles.d.ts +37 -0
  257. package/dist/lexicon/roles.d.ts.map +1 -0
  258. package/dist/lexicon/roles.js +52 -0
  259. package/dist/lexicon/roles.js.map +1 -0
  260. package/dist/lexicon/tiers.d.ts +18 -0
  261. package/dist/lexicon/tiers.d.ts.map +1 -0
  262. package/dist/lexicon/tiers.js +17 -0
  263. package/dist/lexicon/tiers.js.map +1 -0
  264. package/dist/measure/index.d.ts +43 -0
  265. package/dist/measure/index.d.ts.map +1 -0
  266. package/dist/measure/index.js +120 -0
  267. package/dist/measure/index.js.map +1 -0
  268. package/dist/render.d.ts +72 -0
  269. package/dist/render.d.ts.map +1 -0
  270. package/dist/render.js +164 -0
  271. package/dist/render.js.map +1 -0
  272. package/dist/runtime/agents_keys.d.ts +8 -0
  273. package/dist/runtime/agents_keys.d.ts.map +1 -0
  274. package/dist/runtime/agents_keys.js +24 -0
  275. package/dist/runtime/agents_keys.js.map +1 -0
  276. package/dist/runtime/agents_peek.d.ts +44 -0
  277. package/dist/runtime/agents_peek.d.ts.map +1 -0
  278. package/dist/runtime/agents_peek.js +96 -0
  279. package/dist/runtime/agents_peek.js.map +1 -0
  280. package/dist/runtime/agents_preview.d.ts +27 -0
  281. package/dist/runtime/agents_preview.d.ts.map +1 -0
  282. package/dist/runtime/agents_preview.js +122 -0
  283. package/dist/runtime/agents_preview.js.map +1 -0
  284. package/dist/runtime/box_bus.d.ts +144 -0
  285. package/dist/runtime/box_bus.d.ts.map +1 -0
  286. package/dist/runtime/box_bus.js +74 -0
  287. package/dist/runtime/box_bus.js.map +1 -0
  288. package/dist/runtime/clipboard-image.d.ts +20 -0
  289. package/dist/runtime/clipboard-image.d.ts.map +1 -0
  290. package/dist/runtime/clipboard-image.js +62 -0
  291. package/dist/runtime/clipboard-image.js.map +1 -0
  292. package/dist/runtime/copy_toast.d.ts +46 -0
  293. package/dist/runtime/copy_toast.d.ts.map +1 -0
  294. package/dist/runtime/copy_toast.js +117 -0
  295. package/dist/runtime/copy_toast.js.map +1 -0
  296. package/dist/runtime/echo.d.ts +41 -0
  297. package/dist/runtime/echo.d.ts.map +1 -0
  298. package/dist/runtime/echo.js +112 -0
  299. package/dist/runtime/echo.js.map +1 -0
  300. package/dist/runtime/frame.d.ts +79 -0
  301. package/dist/runtime/frame.d.ts.map +1 -0
  302. package/dist/runtime/frame.js +258 -0
  303. package/dist/runtime/frame.js.map +1 -0
  304. package/dist/runtime/index.d.ts +16 -0
  305. package/dist/runtime/index.d.ts.map +1 -0
  306. package/dist/runtime/index.js +16 -0
  307. package/dist/runtime/index.js.map +1 -0
  308. package/dist/runtime/key_buffer.d.ts +19 -0
  309. package/dist/runtime/key_buffer.d.ts.map +1 -0
  310. package/dist/runtime/key_buffer.js +24 -0
  311. package/dist/runtime/key_buffer.js.map +1 -0
  312. package/dist/runtime/keys.d.ts +66 -0
  313. package/dist/runtime/keys.d.ts.map +1 -0
  314. package/dist/runtime/keys.js +220 -0
  315. package/dist/runtime/keys.js.map +1 -0
  316. package/dist/runtime/paint_snapshot.d.ts +9 -0
  317. package/dist/runtime/paint_snapshot.d.ts.map +1 -0
  318. package/dist/runtime/paint_snapshot.js +8 -0
  319. package/dist/runtime/paint_snapshot.js.map +1 -0
  320. package/dist/runtime/paint_source.d.ts +266 -0
  321. package/dist/runtime/paint_source.d.ts.map +1 -0
  322. package/dist/runtime/paint_source.js +532 -0
  323. package/dist/runtime/paint_source.js.map +1 -0
  324. package/dist/runtime/present_loop.d.ts +11 -0
  325. package/dist/runtime/present_loop.d.ts.map +1 -0
  326. package/dist/runtime/present_loop.js +46 -0
  327. package/dist/runtime/present_loop.js.map +1 -0
  328. package/dist/runtime/present_profile.d.ts +58 -0
  329. package/dist/runtime/present_profile.d.ts.map +1 -0
  330. package/dist/runtime/present_profile.js +130 -0
  331. package/dist/runtime/present_profile.js.map +1 -0
  332. package/dist/runtime/raster.d.ts +24 -0
  333. package/dist/runtime/raster.d.ts.map +1 -0
  334. package/dist/runtime/raster.js +43 -0
  335. package/dist/runtime/raster.js.map +1 -0
  336. package/dist/runtime/renderer.d.ts +151 -0
  337. package/dist/runtime/renderer.d.ts.map +1 -0
  338. package/dist/runtime/renderer.js +1607 -0
  339. package/dist/runtime/renderer.js.map +1 -0
  340. package/dist/runtime/screenshot.d.ts +9 -0
  341. package/dist/runtime/screenshot.d.ts.map +1 -0
  342. package/dist/runtime/screenshot.js +111 -0
  343. package/dist/runtime/screenshot.js.map +1 -0
  344. package/dist/runtime/selection_host.d.ts +41 -0
  345. package/dist/runtime/selection_host.d.ts.map +1 -0
  346. package/dist/runtime/selection_host.js +190 -0
  347. package/dist/runtime/selection_host.js.map +1 -0
  348. package/dist/runtime/stderr_hold.d.ts +16 -0
  349. package/dist/runtime/stderr_hold.d.ts.map +1 -0
  350. package/dist/runtime/stderr_hold.js +23 -0
  351. package/dist/runtime/stderr_hold.js.map +1 -0
  352. package/dist/runtime/thought_birth.d.ts +25 -0
  353. package/dist/runtime/thought_birth.d.ts.map +1 -0
  354. package/dist/runtime/thought_birth.js +122 -0
  355. package/dist/runtime/thought_birth.js.map +1 -0
  356. package/dist/runtime/thought_collapsed.d.ts +35 -0
  357. package/dist/runtime/thought_collapsed.d.ts.map +1 -0
  358. package/dist/runtime/thought_collapsed.js +94 -0
  359. package/dist/runtime/thought_collapsed.js.map +1 -0
  360. package/dist/runtime/tty.d.ts +58 -0
  361. package/dist/runtime/tty.d.ts.map +1 -0
  362. package/dist/runtime/tty.js +130 -0
  363. package/dist/runtime/tty.js.map +1 -0
  364. package/dist/theme/ansi16.d.ts +34 -0
  365. package/dist/theme/ansi16.d.ts.map +1 -0
  366. package/dist/theme/ansi16.js +181 -0
  367. package/dist/theme/ansi16.js.map +1 -0
  368. package/dist/theme/ansi256.d.ts +15 -0
  369. package/dist/theme/ansi256.d.ts.map +1 -0
  370. package/dist/theme/ansi256.js +94 -0
  371. package/dist/theme/ansi256.js.map +1 -0
  372. package/dist/theme/ground.d.ts +8 -0
  373. package/dist/theme/ground.d.ts.map +1 -0
  374. package/dist/theme/ground.js +11 -0
  375. package/dist/theme/ground.js.map +1 -0
  376. package/dist/theme/index.d.ts +10 -0
  377. package/dist/theme/index.d.ts.map +1 -0
  378. package/dist/theme/index.js +10 -0
  379. package/dist/theme/index.js.map +1 -0
  380. package/dist/theme/region.d.ts +42 -0
  381. package/dist/theme/region.d.ts.map +1 -0
  382. package/dist/theme/region.js +105 -0
  383. package/dist/theme/region.js.map +1 -0
  384. package/dist/theme/resolver.d.ts +126 -0
  385. package/dist/theme/resolver.d.ts.map +1 -0
  386. package/dist/theme/resolver.js +366 -0
  387. package/dist/theme/resolver.js.map +1 -0
  388. package/dist/theme/salience.d.ts +90 -0
  389. package/dist/theme/salience.d.ts.map +1 -0
  390. package/dist/theme/salience.js +208 -0
  391. package/dist/theme/salience.js.map +1 -0
  392. package/dist/theme/seeds.d.ts +113 -0
  393. package/dist/theme/seeds.d.ts.map +1 -0
  394. package/dist/theme/seeds.js +52 -0
  395. package/dist/theme/seeds.js.map +1 -0
  396. package/dist/theme/selection.d.ts +94 -0
  397. package/dist/theme/selection.d.ts.map +1 -0
  398. package/dist/theme/selection.js +135 -0
  399. package/dist/theme/selection.js.map +1 -0
  400. package/dist/theme/theme.d.ts +41 -0
  401. package/dist/theme/theme.d.ts.map +1 -0
  402. package/dist/theme/theme.js +34 -0
  403. package/dist/theme/theme.js.map +1 -0
  404. package/dist/widgets/composer-caret.d.ts +47 -0
  405. package/dist/widgets/composer-caret.d.ts.map +1 -0
  406. package/dist/widgets/composer-caret.js +90 -0
  407. package/dist/widgets/composer-caret.js.map +1 -0
  408. package/dist/widgets/composer-click.d.ts +30 -0
  409. package/dist/widgets/composer-click.d.ts.map +1 -0
  410. package/dist/widgets/composer-click.js +89 -0
  411. package/dist/widgets/composer-click.js.map +1 -0
  412. package/dist/widgets/composer-command.d.ts +64 -0
  413. package/dist/widgets/composer-command.d.ts.map +1 -0
  414. package/dist/widgets/composer-command.js +127 -0
  415. package/dist/widgets/composer-command.js.map +1 -0
  416. package/dist/widgets/composer-frame.d.ts +74 -0
  417. package/dist/widgets/composer-frame.d.ts.map +1 -0
  418. package/dist/widgets/composer-frame.js +284 -0
  419. package/dist/widgets/composer-frame.js.map +1 -0
  420. package/dist/widgets/composer-picker.d.ts +89 -0
  421. package/dist/widgets/composer-picker.d.ts.map +1 -0
  422. package/dist/widgets/composer-picker.js +240 -0
  423. package/dist/widgets/composer-picker.js.map +1 -0
  424. package/dist/widgets/diff.d.ts +11 -0
  425. package/dist/widgets/diff.d.ts.map +1 -0
  426. package/dist/widgets/diff.js +19 -0
  427. package/dist/widgets/diff.js.map +1 -0
  428. package/dist/widgets/expand.d.ts +28 -0
  429. package/dist/widgets/expand.d.ts.map +1 -0
  430. package/dist/widgets/expand.js +94 -0
  431. package/dist/widgets/expand.js.map +1 -0
  432. package/dist/widgets/index.d.ts +126 -0
  433. package/dist/widgets/index.d.ts.map +1 -0
  434. package/dist/widgets/index.js +455 -0
  435. package/dist/widgets/index.js.map +1 -0
  436. package/dist/widgets/internals/arrival-lang.d.ts +88 -0
  437. package/dist/widgets/internals/arrival-lang.d.ts.map +1 -0
  438. package/dist/widgets/internals/arrival-lang.js +211 -0
  439. package/dist/widgets/internals/arrival-lang.js.map +1 -0
  440. package/dist/widgets/internals/diff-expand.d.ts +93 -0
  441. package/dist/widgets/internals/diff-expand.d.ts.map +1 -0
  442. package/dist/widgets/internals/diff-expand.js +1106 -0
  443. package/dist/widgets/internals/diff-expand.js.map +1 -0
  444. package/dist/widgets/internals/embedded-syntax.d.ts +62 -0
  445. package/dist/widgets/internals/embedded-syntax.d.ts.map +1 -0
  446. package/dist/widgets/internals/embedded-syntax.js +465 -0
  447. package/dist/widgets/internals/embedded-syntax.js.map +1 -0
  448. package/dist/widgets/internals/markdown-expand.d.ts +57 -0
  449. package/dist/widgets/internals/markdown-expand.d.ts.map +1 -0
  450. package/dist/widgets/internals/markdown-expand.js +980 -0
  451. package/dist/widgets/internals/markdown-expand.js.map +1 -0
  452. package/dist/widgets/internals/overlay-syntax.d.ts +24 -0
  453. package/dist/widgets/internals/overlay-syntax.d.ts.map +1 -0
  454. package/dist/widgets/internals/overlay-syntax.js +90 -0
  455. package/dist/widgets/internals/overlay-syntax.js.map +1 -0
  456. package/dist/widgets/internals/pierre-parse/cleanLastNewline.d.ts +6 -0
  457. package/dist/widgets/internals/pierre-parse/cleanLastNewline.d.ts.map +1 -0
  458. package/dist/widgets/internals/pierre-parse/cleanLastNewline.js +8 -0
  459. package/dist/widgets/internals/pierre-parse/cleanLastNewline.js.map +1 -0
  460. package/dist/widgets/internals/pierre-parse/constants.d.ts +13 -0
  461. package/dist/widgets/internals/pierre-parse/constants.d.ts.map +1 -0
  462. package/dist/widgets/internals/pierre-parse/constants.js +13 -0
  463. package/dist/widgets/internals/pierre-parse/constants.js.map +1 -0
  464. package/dist/widgets/internals/pierre-parse/detachString.d.ts +3 -0
  465. package/dist/widgets/internals/pierre-parse/detachString.d.ts.map +1 -0
  466. package/dist/widgets/internals/pierre-parse/detachString.js +24 -0
  467. package/dist/widgets/internals/pierre-parse/detachString.js.map +1 -0
  468. package/dist/widgets/internals/pierre-parse/index.d.ts +8 -0
  469. package/dist/widgets/internals/pierre-parse/index.d.ts.map +1 -0
  470. package/dist/widgets/internals/pierre-parse/index.js +8 -0
  471. package/dist/widgets/internals/pierre-parse/index.js.map +1 -0
  472. package/dist/widgets/internals/pierre-parse/parseDiffFromFile.d.ts +15 -0
  473. package/dist/widgets/internals/pierre-parse/parseDiffFromFile.d.ts.map +1 -0
  474. package/dist/widgets/internals/pierre-parse/parseDiffFromFile.js +39 -0
  475. package/dist/widgets/internals/pierre-parse/parseDiffFromFile.js.map +1 -0
  476. package/dist/widgets/internals/pierre-parse/parsePatchFiles.d.ts +11 -0
  477. package/dist/widgets/internals/pierre-parse/parsePatchFiles.d.ts.map +1 -0
  478. package/dist/widgets/internals/pierre-parse/parsePatchFiles.js +621 -0
  479. package/dist/widgets/internals/pierre-parse/parsePatchFiles.js.map +1 -0
  480. package/dist/widgets/internals/pierre-parse/types.d.ts +73 -0
  481. package/dist/widgets/internals/pierre-parse/types.d.ts.map +1 -0
  482. package/dist/widgets/internals/pierre-parse/types.js +7 -0
  483. package/dist/widgets/internals/pierre-parse/types.js.map +1 -0
  484. package/dist/widgets/internals/syntax.d.ts +55 -0
  485. package/dist/widgets/internals/syntax.d.ts.map +1 -0
  486. package/dist/widgets/internals/syntax.js +261 -0
  487. package/dist/widgets/internals/syntax.js.map +1 -0
  488. package/dist/widgets/markdown.d.ts +14 -0
  489. package/dist/widgets/markdown.d.ts.map +1 -0
  490. package/dist/widgets/markdown.js +9 -0
  491. package/dist/widgets/markdown.js.map +1 -0
  492. package/dist/widgets/shadow-stream.d.ts +88 -0
  493. package/dist/widgets/shadow-stream.d.ts.map +1 -0
  494. package/dist/widgets/shadow-stream.js +359 -0
  495. package/dist/widgets/shadow-stream.js.map +1 -0
  496. package/dist/widgets/speech.d.ts +36 -0
  497. package/dist/widgets/speech.d.ts.map +1 -0
  498. package/dist/widgets/speech.js +238 -0
  499. package/dist/widgets/speech.js.map +1 -0
  500. package/dist/widgets/stream-birth.d.ts +13 -0
  501. package/dist/widgets/stream-birth.d.ts.map +1 -0
  502. package/dist/widgets/stream-birth.js +70 -0
  503. package/dist/widgets/stream-birth.js.map +1 -0
  504. package/dist/widgets/syntax-boot.d.ts +25 -0
  505. package/dist/widgets/syntax-boot.d.ts.map +1 -0
  506. package/dist/widgets/syntax-boot.js +181 -0
  507. package/dist/widgets/syntax-boot.js.map +1 -0
  508. package/dist/widgets/text.d.ts +16 -0
  509. package/dist/widgets/text.d.ts.map +1 -0
  510. package/dist/widgets/text.js +14 -0
  511. package/dist/widgets/text.js.map +1 -0
  512. package/dist/widgets/transcript.d.ts +44 -0
  513. package/dist/widgets/transcript.d.ts.map +1 -0
  514. package/dist/widgets/transcript.js +106 -0
  515. package/dist/widgets/transcript.js.map +1 -0
  516. package/doom.vert +1840 -0
  517. package/fonts/DejaVuSans.ttf +0 -0
  518. package/fonts/DejaVuSansMono.ttf +0 -0
  519. package/fonts/LICENSE-DejaVu.txt +187 -0
  520. package/fonts/README.md +6 -0
  521. package/gradient.vert +75 -0
  522. package/package.json +147 -3
@@ -0,0 +1,825 @@
1
+ /**
2
+ * The single decoder — raw terminal bytes to `InputEvent`s.
3
+ *
4
+ * Extracted from `widgets/surface`, whose remaining half still imports the
5
+ * deprecated kernel. Everything here is pure: no sockets, no timers, no state
6
+ * beyond the `pending` string a caller threads back in. That purity is the
7
+ * reason the package exists — a decoder that a host must build the kernel to
8
+ * use is a decoder every host is tempted to reimplement, and F12 (two decoders
9
+ * disagreeing about a split escape sequence) is what reimplementation cost the
10
+ * last tree.
11
+ *
12
+ * The one environment read is `QD_NO_LAYOUT_TABLE`, the non-Latin layout
13
+ * ladder's kill switch — table and the kitty flag-4 base-layout-key
14
+ * precision layer above it both — read live so a caller can toggle it per
15
+ * call.
16
+ */
17
+ import { parseOscColorPayload } from "../capabilities/parse.js";
18
+ function parseMod(n) {
19
+ const bits = Math.max(0, (n ?? 1) - 1);
20
+ return {
21
+ shift: (bits & 1) !== 0,
22
+ alt: (bits & 2) !== 0,
23
+ ctrl: (bits & 4) !== 0,
24
+ // super (8) | hyper (16) | kitty-meta (32) — all "host command" class
25
+ meta: (bits & (8 | 16 | 32)) !== 0,
26
+ capsLock: (bits & 64) !== 0,
27
+ };
28
+ }
29
+ /**
30
+ * Letter chords: Ctrl keeps full readline map; Super/Cmd alone is macOS-native
31
+ * undo/redo/select-all (never Cmd+C → quit, never steal system copy).
32
+ */
33
+ function letterChord(keycode, mod) {
34
+ const key = keycode >= 65 && keycode <= 90 ? keycode + 32 : keycode;
35
+ if (key < 97 || key > 122)
36
+ return null;
37
+ if (mod.meta && !mod.ctrl) {
38
+ if (key === 97)
39
+ return { type: "select_all" };
40
+ if (key === 111)
41
+ return { type: "ctrl_o" };
42
+ if (key === 122)
43
+ return mod.shift ? { type: "redo" } : { type: "undo" };
44
+ if (key === 121)
45
+ return { type: "redo" };
46
+ return null;
47
+ }
48
+ if (mod.ctrl)
49
+ return ctrlLetter(key, mod);
50
+ return null;
51
+ }
52
+ /**
53
+ * Kitty keyboard-protocol functional keys 57442–57452 we persist as `mod`:
54
+ * LEFT/RIGHT Control, Super, Meta (even ids). Not an inclusive range —
55
+ * Shift/Alt/Hyper occupy the gaps; `key >= 57442 && key <= 57452` would
56
+ * persist those as chrome `mod` too.
57
+ */
58
+ function kittyPersistMod(key) {
59
+ return key === 57_442 || key === 57_444 || key === 57_446 || key === 57_448 || key === 57_450 || key === 57_452;
60
+ }
61
+ /**
62
+ * Flag-16 associated text (`CSI … ; mod ; code[:code…] u`). Control
63
+ * codepoints are rejected — the spec forbids them in this field.
64
+ */
65
+ function parseAssociatedText(field) {
66
+ if (field === undefined || field === "")
67
+ return null;
68
+ const cps = [];
69
+ for (const part of field.split(":")) {
70
+ if (part === "")
71
+ return null;
72
+ const n = Number(part);
73
+ if (!Number.isFinite(n) || n < 0x20 || n === 0x7f || (n >= 0x80 && n <= 0x9f)) {
74
+ return null;
75
+ }
76
+ cps.push(n);
77
+ }
78
+ if (cps.length === 0)
79
+ return null;
80
+ try {
81
+ return String.fromCodePoint(...cps);
82
+ }
83
+ catch {
84
+ return null;
85
+ }
86
+ }
87
+ function isCasedLetter(ch) {
88
+ return ch.toLowerCase() !== ch.toUpperCase();
89
+ }
90
+ /**
91
+ * Insert glyph from an unshifted CSI-u identity. Associated text (flag 16)
92
+ * wins — it is the OS glyph (Caps, layout, dead keys). Else: letters use
93
+ * shift XOR Caps; Shift on punctuation uses the flag-4 shifted subfield.
94
+ */
95
+ function resolveGlyph(main, mod, keyField) {
96
+ let ch;
97
+ try {
98
+ ch = String.fromCodePoint(main);
99
+ }
100
+ catch {
101
+ return null;
102
+ }
103
+ const cased = isCasedLetter(ch);
104
+ const caps = cased && mod.capsLock;
105
+ const wantShift = mod.shift !== caps;
106
+ if (!wantShift)
107
+ return ch;
108
+ const shifted = keyField?.shifted;
109
+ if (shifted !== undefined && shifted !== main) {
110
+ try {
111
+ return String.fromCodePoint(shifted);
112
+ }
113
+ catch {
114
+ return ch;
115
+ }
116
+ }
117
+ if (cased) {
118
+ const upper = ch.toUpperCase();
119
+ if ([...upper].length === 1)
120
+ return upper;
121
+ }
122
+ return ch;
123
+ }
124
+ /** Printable CSI-u / modifyOtherKeys body when report-all-keys is on. */
125
+ function csiPrintable(key, mod, keyField, associated) {
126
+ if (mod.ctrl || mod.alt || mod.meta)
127
+ return null;
128
+ if (associated != null && associated !== "")
129
+ return { type: "char", ch: associated };
130
+ if (key === 9)
131
+ return tabFamily(mod);
132
+ if (key < 32 || key === 127)
133
+ return null;
134
+ // Kitty flag 8 reports functional keys (modifiers, F-keys, media) as BMP
135
+ // PUA (U+E000–U+F8FF). LEFT_ALT is 57443 — inserting it, then repeating
136
+ // it, floods the draft and the composer grows like a scroll.
137
+ if (key >= 0xe0_00 && key <= 0xf8_ff)
138
+ return null;
139
+ const glyph = resolveGlyph(key, mod, keyField);
140
+ if (glyph === null)
141
+ return null;
142
+ return { type: "char", ch: glyph };
143
+ }
144
+ function arrowFromFinal(final, mod) {
145
+ const base = final === "A" || final === "a"
146
+ ? "up"
147
+ : final === "B" || final === "b"
148
+ ? "down"
149
+ : final === "C" || final === "c"
150
+ ? "right"
151
+ : final === "D" || final === "d"
152
+ ? "left"
153
+ : final === "H" || final === "h"
154
+ ? "home"
155
+ : final === "F" || final === "f"
156
+ ? "end"
157
+ : null;
158
+ if (!base)
159
+ return null;
160
+ // Word / line motions from modifiers (macOS terminals + xterm).
161
+ // Shift is orthogonal: it marks "extend selection" without changing the motion.
162
+ const select = mod.shift || undefined;
163
+ if (base === "left") {
164
+ if (mod.meta || (mod.ctrl && !mod.alt))
165
+ return { type: "home", select };
166
+ if (mod.alt)
167
+ return { type: "word_left", select };
168
+ return { type: "left", select };
169
+ }
170
+ if (base === "right") {
171
+ if (mod.meta || (mod.ctrl && !mod.alt))
172
+ return { type: "end", select };
173
+ if (mod.alt)
174
+ return { type: "word_right", select };
175
+ return { type: "right", select };
176
+ }
177
+ if (base === "home" || base === "end" || base === "up" || base === "down") {
178
+ return { type: base, select };
179
+ }
180
+ return { type: base };
181
+ }
182
+ /** First decimal of a CSI field (strip kitty `:subfields`). */
183
+ function csiFieldMain(field) {
184
+ if (field === undefined || field === "")
185
+ return undefined;
186
+ const main = field.split(":")[0];
187
+ if (main === "")
188
+ return undefined;
189
+ const n = Number(main);
190
+ return Number.isFinite(n) ? n : undefined;
191
+ }
192
+ /** Event type subfield of modifiers (`mod:type`) — 3 = release. */
193
+ function csiEventType(field) {
194
+ if (!field)
195
+ return 1;
196
+ const parts = field.split(":");
197
+ if (parts.length < 2 || parts[1] === "")
198
+ return 1;
199
+ const t = Number(parts[1]);
200
+ return Number.isFinite(t) ? t : 1;
201
+ }
202
+ function truthyMods(mod) {
203
+ return {
204
+ ...(mod.shift ? { shift: true } : {}),
205
+ ...(mod.alt ? { alt: true } : {}),
206
+ ...(mod.ctrl ? { ctrl: true } : {}),
207
+ ...(mod.meta ? { meta: true } : {}),
208
+ };
209
+ }
210
+ /** CSI / modifyOtherKeys Enter keeps modifiers. C0 newline fallbacks stay `shift_enter`. */
211
+ function enterFamily(mod) {
212
+ return { type: "enter", ...truthyMods(mod) };
213
+ }
214
+ function escFamily(mod) {
215
+ return { type: "esc", ...truthyMods(mod) };
216
+ }
217
+ function tabFamily(mod) {
218
+ return mod.shift ? { type: "shift_tab" } : { type: "tab" };
219
+ }
220
+ function backspaceFamily(mod) {
221
+ if (mod.meta)
222
+ return { type: "kill_to_start" };
223
+ if (mod.alt)
224
+ return { type: "word_backspace" };
225
+ return { type: "backspace" };
226
+ }
227
+ /**
228
+ * Map Ctrl(+Shift)/Meta+letter from CSI-u keycode (lowercase codepoint).
229
+ * `mod` carries shift so Ctrl+Shift+Z is redo rather than undo.
230
+ */
231
+ function ctrlLetter(keycode, mod) {
232
+ switch (keycode) {
233
+ case 99:
234
+ return { type: "ctrl_c" };
235
+ case 120:
236
+ return { type: "ctrl_x" };
237
+ case 111:
238
+ return { type: "ctrl_o" };
239
+ case 118:
240
+ return { type: "ctrl_v" };
241
+ case 97:
242
+ return { type: "home" };
243
+ case 101:
244
+ return { type: "end" };
245
+ case 117:
246
+ return { type: "kill_to_start" };
247
+ case 107:
248
+ return { type: "kill_to_end" };
249
+ case 119:
250
+ return { type: "word_backspace" };
251
+ case 100:
252
+ return { type: "delete" };
253
+ case 106:
254
+ return { type: "shift_enter" };
255
+ case 109:
256
+ // CSI-u 109 is Ctrl+M, not C0 CR. Enter preserves modifiers.
257
+ return { type: "enter" };
258
+ case 122:
259
+ return mod.shift ? { type: "redo" } : { type: "undo" };
260
+ case 121:
261
+ return { type: "redo" };
262
+ default:
263
+ return null;
264
+ }
265
+ }
266
+ // ── Non-Latin keyboard layouts (physical-key translation, Ctrl/Alt only) ────
267
+ /**
268
+ * CSI-u reports the codepoint the OS layout actually produces, not the
269
+ * physical key pressed. On a Cyrillic (ЙЦУКЕН) layout, Ctrl+С sends the
270
+ * codepoint for Cyrillic "с" (CSI 1089;5u) — not Latin "c" — so the Latin
271
+ * gate below (`key >= 97 && key <= 122`) never matches and the shortcut is
272
+ * silently dropped. This table maps each non-Latin letter to the Latin key
273
+ * sitting under the same finger, so Ctrl/Alt shortcuts work regardless of
274
+ * the active layout.
275
+ *
276
+ * One Record per layout, keyed by name — a new layout is a new entry here,
277
+ * not a new branch (see NON_LATIN_LAYOUTS / physicalLatinKeycode below).
278
+ *
279
+ * This table stays load-bearing even where kitty progressive-enhancement
280
+ * flag 4 (report alternate keys) is negotiated: flag 4 reaches only a
281
+ * minority of sessions (no multiplexer forwards it, several terminals never
282
+ * request it, and iTerm2 requests it but drops the field on exactly the
283
+ * layouts that need it — see baseLayoutKeycode). Flag 4's base-layout key
284
+ * is a precision upgrade layered above this table, never a replacement for
285
+ * it — see physicalLatinKeycode's precedence order.
286
+ */
287
+ const RU_YCUKEN = {
288
+ й: "q",
289
+ ц: "w",
290
+ у: "e",
291
+ к: "r",
292
+ е: "t",
293
+ н: "y",
294
+ г: "u",
295
+ ш: "i",
296
+ щ: "o",
297
+ з: "p",
298
+ х: "[",
299
+ ъ: "]",
300
+ ф: "a",
301
+ ы: "s",
302
+ в: "d",
303
+ а: "f",
304
+ п: "g",
305
+ р: "h",
306
+ о: "j",
307
+ л: "k",
308
+ д: "l",
309
+ ж: ";",
310
+ э: "'",
311
+ я: "z",
312
+ ч: "x",
313
+ с: "c",
314
+ м: "v",
315
+ и: "b",
316
+ т: "n",
317
+ ь: "m",
318
+ б: ",",
319
+ ю: ".",
320
+ ё: "`",
321
+ };
322
+ /** Add a layout by adding an entry here — no code changes needed elsewhere. */
323
+ const NON_LATIN_LAYOUTS = {
324
+ ru_yciken: RU_YCUKEN,
325
+ };
326
+ /**
327
+ * Flattened codepoint → Latin-key codepoint, built once from
328
+ * NON_LATIN_LAYOUTS. Both cases of every letter map to the same lowercase
329
+ * Latin target (`.toUpperCase()` derives the uppercase entry) since
330
+ * downstream matching (ctrlLetter, etc.) only looks at lowercase 97-122.
331
+ */
332
+ const LAYOUT_CODEPOINTS = (() => {
333
+ const m = new Map();
334
+ for (const table of Object.values(NON_LATIN_LAYOUTS)) {
335
+ for (const [ch, latin] of Object.entries(table)) {
336
+ const latinCode = latin.codePointAt(0);
337
+ m.set(ch.codePointAt(0), latinCode);
338
+ const upper = ch.toUpperCase();
339
+ if (upper !== ch)
340
+ m.set(upper.codePointAt(0), latinCode);
341
+ }
342
+ }
343
+ return m;
344
+ })();
345
+ function parseKittyKeyField(field) {
346
+ if (field === undefined || field === "")
347
+ return undefined;
348
+ const subs = field.split(":");
349
+ const main = Number(subs[0]);
350
+ if (!Number.isFinite(main))
351
+ return undefined;
352
+ const toNum = (s) => {
353
+ if (s === undefined || s === "")
354
+ return undefined;
355
+ const n = Number(s);
356
+ return Number.isFinite(n) ? n : undefined;
357
+ };
358
+ return { main, shifted: toNum(subs[1]), base: toNum(subs[2]) };
359
+ }
360
+ /**
361
+ * Precision layer above the static layout table: the kitty flag-4
362
+ * base-layout-key subfield, when present and the emitter looks conformant.
363
+ *
364
+ * Two failure shapes this guards against, both researched and binding (do
365
+ * not re-derive):
366
+ * - **Absence is normal, not an error.** No multiplexer forwards flag 4;
367
+ * most terminals never requested it; iTerm2 requests it but derives the
368
+ * subfield from the *current* layout with modifiers stripped, so on a
369
+ * Cyrillic layout it emits nothing for exactly the keys that need it.
370
+ * Absence always falls through — to the static table, silently.
371
+ * - **`main == shifted` marks a nonconformant emitter.** A terminal that
372
+ * echoes the same codepoint for both subfields isn't computing the
373
+ * shifted variant at all, so its base-layout claim can't be trusted
374
+ * either — fall through to the table rather than act on a fabricated
375
+ * value. (Only rejects when a shifted subfield is actually present;
376
+ * subfield 1 being merely absent is the ordinary case above, not this
377
+ * one.)
378
+ *
379
+ * Never branch on negotiated capabilities (a terminal can echo flags it
380
+ * doesn't honor) — only on this field's actual shape.
381
+ */
382
+ function baseLayoutKeycode(keyField) {
383
+ if (keyField?.base === undefined)
384
+ return null;
385
+ if (keyField.shifted !== undefined && keyField.shifted === keyField.main)
386
+ return null;
387
+ return keyField.base;
388
+ }
389
+ /**
390
+ * Resolve the physical Latin keycode for a Ctrl/Alt/Meta chord, in
391
+ * precedence order: base-layout key (flag 4, when present and sane) →
392
+ * static layout table → raw codepoint. NEVER applies without ctrl/alt/meta
393
+ * — bare typing (no modifier) always passes `rawKey` through untouched, so
394
+ * normal composing on a Cyrillic/etc. layout reaches the composer exactly
395
+ * as typed. QD_NO_LAYOUT_TABLE=1 disables the whole ladder (base-layout key
396
+ * included, not just the table) — read live, not cached, so callers/tests
397
+ * can toggle it per-call.
398
+ */
399
+ function physicalLatinKeycode(rawKey, keyField, mod) {
400
+ // Ctrl/Alt/Super(Cmd) chords need the physical Latin key under the finger.
401
+ if (!mod.ctrl && !mod.alt && !mod.meta)
402
+ return rawKey;
403
+ if (process.env.QD_NO_LAYOUT_TABLE === "1")
404
+ return rawKey;
405
+ const base = baseLayoutKeycode(keyField);
406
+ if (base !== null)
407
+ return base;
408
+ return LAYOUT_CODEPOINTS.get(rawKey) ?? rawKey;
409
+ }
410
+ /**
411
+ * Decode CSI params + final byte.
412
+ * Covers: arrows, ~ editing keys, kitty/fixterms CSI u, xterm modifyOtherKeys (27;mod;key~).
413
+ */
414
+ function mapCsi(params, final) {
415
+ if (final === "n" && (params === "?997;1" || params === "?997;2"))
416
+ return { type: "theme_changed" };
417
+ const parts = params.length > 0 ? params.split(";") : [];
418
+ const p0 = csiFieldMain(parts[0]);
419
+ const p1 = csiFieldMain(parts[1]);
420
+ const p2 = csiFieldMain(parts[2]);
421
+ const eventType = csiEventType(parts[1] ?? parts[0]);
422
+ // Persist-modifier release must reach chrome; other releases stay silent.
423
+ if (eventType === 3) {
424
+ if (final === "u" && kittyPersistMod(csiFieldMain(parts[0]) ?? 0)) {
425
+ return { type: "mod", persist: true, down: false };
426
+ }
427
+ return null;
428
+ }
429
+ // Focus report (?1004h): bare CSI I / CSI O only — not CSI 1;2I etc.
430
+ if (final === "I" && parts.length === 0)
431
+ return { type: "focus_in" };
432
+ if (final === "O" && parts.length === 0)
433
+ return { type: "focus_out" };
434
+ // SGR mouse: CSI < btn ; col ; row M (press) / m (release)
435
+ // Wheel: button 64 = up, 65 = down (bit 6 set). Keep full code.
436
+ if ((final === "M" || final === "m") && params.startsWith("<")) {
437
+ const fields = params.slice(1).split(";");
438
+ const btn = Number(fields[0]);
439
+ const col = Number(fields[1]);
440
+ const row = Number(fields[2]);
441
+ if (Number.isFinite(btn) && Number.isFinite(col) && Number.isFinite(row) && col >= 1 && row >= 1) {
442
+ return {
443
+ type: "mouse",
444
+ button: Math.floor(btn),
445
+ col: Math.floor(col),
446
+ row: Math.floor(row),
447
+ release: final === "m",
448
+ };
449
+ }
450
+ return null;
451
+ }
452
+ // Cursor / editing keys: CSI A–D / H / F, optionally CSI 1;<mod>A–D
453
+ if ("ABCDHFf".includes(final)) {
454
+ if (parts.length >= 2)
455
+ return arrowFromFinal(final, parseMod(p1));
456
+ if (parts.length === 1 && p0 !== undefined && p0 > 1 && p0 < 20) {
457
+ return arrowFromFinal(final, parseMod(p0));
458
+ }
459
+ return arrowFromFinal(final, parseMod(1));
460
+ }
461
+ // Kitty / fixterms CSI u: CSI <keycode>[;mod] u
462
+ // Shift+Enter: CSI 13;2u · Ctrl+C: CSI 99;5u · Cmd+Z: CSI 122;9u (super)
463
+ if (final === "u") {
464
+ const keyField = parseKittyKeyField(parts[0]);
465
+ const rawKey = keyField?.main ?? p0 ?? 0;
466
+ const mod = parseMod(p1 ?? 1);
467
+ // Non-Latin layout (e.g. ЙЦУКЕН Ctrl+С = CSI 1089;5u) → physical Latin
468
+ // key before any of the matching below — see physicalLatinKeycode.
469
+ // Precedence: flag-4 base-layout key (keyField.base) → static table →
470
+ // raw codepoint.
471
+ const key = physicalLatinKeycode(rawKey, keyField, mod);
472
+ const associated = parseAssociatedText(parts[2]);
473
+ if (kittyPersistMod(rawKey))
474
+ return { type: "mod", persist: true, down: true };
475
+ if (key === 13)
476
+ return enterFamily(mod);
477
+ if (key === 27)
478
+ return escFamily(mod);
479
+ if (key === 127)
480
+ return backspaceFamily(mod);
481
+ if (key === 9)
482
+ return tabFamily(mod);
483
+ // Ctrl+letter (full map) or Super/Cmd+Z/Y (undo/redo only).
484
+ const chord = letterChord(key, mod);
485
+ if (chord)
486
+ return chord;
487
+ // report_all_keys: plain / shift-only letters arrive as CSI-u too.
488
+ // Identity stays unshifted (`key` / `rawKey`); insert uses associated
489
+ // text, then shifted subfield, then shift XOR Caps on letters.
490
+ return csiPrintable(rawKey, mod, keyField, associated);
491
+ }
492
+ // ~ family: CSI n~ · CSI n;<mod>~ · CSI 27;<mod>;<key>~ (modifyOtherKeys)
493
+ if (final === "~") {
494
+ // xterm modifyOtherKeys: CSI 27 ; <mod> ; <keycode> ~
495
+ if (p0 === 27 && p2 !== undefined) {
496
+ const mod = parseMod(p1);
497
+ const key = p2;
498
+ if (key === 13)
499
+ return enterFamily(mod);
500
+ if (key === 27)
501
+ return escFamily(mod);
502
+ if (key === 127 || key === 8)
503
+ return backspaceFamily(mod);
504
+ const chord = letterChord(key, mod);
505
+ if (chord)
506
+ return chord;
507
+ return csiPrintable(key, mod);
508
+ }
509
+ const code = p0 ?? 0;
510
+ const mod = parseMod(p1);
511
+ const PAGE_UP = 5;
512
+ const PAGE_DOWN = 6;
513
+ const ENTER = 13;
514
+ switch (code) {
515
+ case 1:
516
+ case 7:
517
+ return mod.alt ? { type: "word_left" } : { type: "home" };
518
+ case 4:
519
+ case 8:
520
+ return mod.alt ? { type: "word_right" } : { type: "end" };
521
+ case 3:
522
+ return { type: "delete" };
523
+ case PAGE_UP:
524
+ return { type: "page_up" };
525
+ case PAGE_DOWN:
526
+ return { type: "page_down" };
527
+ case ENTER:
528
+ return enterFamily(mod);
529
+ case 200:
530
+ case 201:
531
+ // Bracketed paste markers handled in consumeKeys (need body)
532
+ return null;
533
+ default:
534
+ return null;
535
+ }
536
+ }
537
+ const BACK_TAB = "Z";
538
+ if (final === BACK_TAB)
539
+ return { type: "shift_tab" };
540
+ return null;
541
+ }
542
+ export function normalizePaste(text) {
543
+ let t = text.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
544
+ // Leading vs trailing: strip leading *blank lines* only (first content
545
+ // line keeps indent for the dedent pass). Trailing strips newlines +
546
+ // spaces/tabs at end of paste.
547
+ t = t.replace(/^(?:[ \t]*\n)+/u, "").replace(/[\n \t]+$/u, "");
548
+ if (!t)
549
+ return "";
550
+ const lines = t.split("\n");
551
+ let minIndent = null;
552
+ for (const line of lines) {
553
+ if (/^[ \t]*$/.test(line))
554
+ continue; // blank / whitespace-only: ignore
555
+ const m = /^[ \t]*/.exec(line);
556
+ const n = m ? m[0].length : 0;
557
+ if (minIndent === null || n < minIndent)
558
+ minIndent = n;
559
+ }
560
+ if (minIndent !== null && minIndent > 0) {
561
+ return lines
562
+ .map((line) => {
563
+ if (/^[ \t]*$/.test(line))
564
+ return "";
565
+ return line.slice(minIndent);
566
+ })
567
+ .join("\n");
568
+ }
569
+ return t;
570
+ }
571
+ /**
572
+ * Max OSC body length (bytes after `ESC ]`) before an unterminated sequence is
573
+ * abandoned. Capability replies (OSC 10/11 rgb, …) are tens of bytes; without
574
+ * this bound a lone malformed `ESC ]…` with no BEL/ST holds every subsequent
575
+ * keystroke in `pending` forever (unlike lone-ESC, which the host can flush).
576
+ * Fail-safe: drop the runaway OSC prefix and resume decoding at the bound.
577
+ */
578
+ export const MAX_OSC_BODY = 512;
579
+ // Ctrl-Z in raw mode → undo, never SIGTSTP.
580
+ // macOS TTY: readline C0 stands in for Cmd-* (Ctrl-U = Cmd-Backspace).
581
+ // Ctrl-D always emits `delete` (forward-delete). Cooked EOT/EOF is not this path.
582
+ const C0_EVENTS = {
583
+ 0x01: { type: "home" },
584
+ 0x04: { type: "delete" },
585
+ 0x05: { type: "end" },
586
+ 0x0b: { type: "kill_to_end" },
587
+ 0x0f: { type: "ctrl_o" },
588
+ 0x15: { type: "kill_to_start" },
589
+ 0x16: { type: "ctrl_v" },
590
+ 0x17: { type: "word_backspace" },
591
+ 0x18: { type: "ctrl_x" },
592
+ 0x19: { type: "redo" },
593
+ 0x1a: { type: "undo" },
594
+ };
595
+ /**
596
+ * Stream-friendly raw stdin → InputEvents.
597
+ * Incomplete ESC/CSI at the end is returned in `pending` (never inserted as text).
598
+ */
599
+ function pushOscGround(out, body) {
600
+ if (!body.startsWith("11;"))
601
+ return;
602
+ const rgb = parseOscColorPayload(body.slice(3));
603
+ if (rgb)
604
+ out.push({ type: "osc_ground", rgb });
605
+ }
606
+ export function consumeKeys(raw, pending = "") {
607
+ const s = pending + raw;
608
+ const out = [];
609
+ let i = 0;
610
+ while (i < s.length) {
611
+ const ch = s[i];
612
+ const code = s.charCodeAt(i);
613
+ // ESC / CSI / SS3 / meta
614
+ if (ch === "\u001B") {
615
+ if (i + 1 >= s.length) {
616
+ // Lone ESC at end of buffer — could be a real Esc keypress, or the
617
+ // first byte of a CSI/SS3 sequence split across stdin chunks (arrow
618
+ // keys arrive split under load: "\x1b" then "[C"). consumeKeys can
619
+ // never tell those apart from the bytes alone, so it always holds —
620
+ // resolving the ambiguity after a short quiet window is the HOST's
621
+ // job (see flushPendingEsc). [F12]
622
+ return { events: out, pending: s.slice(i) };
623
+ }
624
+ const n1 = s[i + 1];
625
+ // OSC: ESC ] … BEL | ST (ESC \). Capability probes (OSC 11 ground, OSC 10
626
+ // fg, OSC 52 replies if any host echoes them) land on stdin; without this
627
+ // branch, ESC+] is treated as meta+']' (two bytes swallowed) and the
628
+ // payload `11;rgb:…` is typed into the draft.
629
+ if (n1 === "]") {
630
+ let j = i + 2;
631
+ const bodyStart = j;
632
+ while (j < s.length) {
633
+ // Bound: abandon runaway / unterminated OSC and resume decoding.
634
+ if (j - bodyStart >= MAX_OSC_BODY) {
635
+ i = j;
636
+ break;
637
+ }
638
+ const c = s[j];
639
+ // BEL terminator
640
+ if (c === "\u0007") {
641
+ pushOscGround(out, s.slice(bodyStart, j));
642
+ i = j + 1;
643
+ break;
644
+ }
645
+ // ST terminator: ESC \
646
+ if (c === "\u001B" && j + 1 < s.length && s[j + 1] === "\\") {
647
+ pushOscGround(out, s.slice(bodyStart, j));
648
+ i = j + 2;
649
+ break;
650
+ }
651
+ // Nested ESC without ST — hold (could be incomplete ST)
652
+ if (c === "\u001B") {
653
+ // Still respect the body bound if the held OSC is already huge.
654
+ if (j - bodyStart >= MAX_OSC_BODY) {
655
+ i = j;
656
+ break;
657
+ }
658
+ return { events: out, pending: s.slice(i) };
659
+ }
660
+ j++;
661
+ }
662
+ if (j >= s.length) {
663
+ // incomplete OSC under the body bound — wait for BEL/ST
664
+ if (j - bodyStart >= MAX_OSC_BODY) {
665
+ // body already maxed with no terminator: drop it, clear pending
666
+ i = j;
667
+ continue;
668
+ }
669
+ return { events: out, pending: s.slice(i) };
670
+ }
671
+ continue;
672
+ }
673
+ if (n1 === "[") {
674
+ let j = i + 2;
675
+ while (j < s.length) {
676
+ const c = s.charCodeAt(j);
677
+ // final byte of CSI: 0x40–0x7E
678
+ if (c >= 0x40 && c <= 0x7e) {
679
+ const params = s.slice(i + 2, j);
680
+ const final = s[j];
681
+ // Bracketed paste: CSI 200~ … body … CSI 201~
682
+ if (final === "~" && csiFieldMain(params.split(";")[0]) === 200) {
683
+ const bodyStart = j + 1;
684
+ const endMark = "\u001B[201~";
685
+ const endAt = s.indexOf(endMark, bodyStart);
686
+ if (endAt === -1) {
687
+ return { events: out, pending: s.slice(i) };
688
+ }
689
+ const text = normalizePaste(s.slice(bodyStart, endAt));
690
+ if (text.length > 0)
691
+ out.push({ type: "paste", text });
692
+ i = endAt + endMark.length;
693
+ break;
694
+ }
695
+ // Stray paste-end
696
+ if (final === "~" && csiFieldMain(params.split(";")[0]) === 201) {
697
+ i = j + 1;
698
+ break;
699
+ }
700
+ const ev = mapCsi(params, final);
701
+ if (ev)
702
+ out.push(ev);
703
+ // else swallow unknown CSI (never inject residue as chars)
704
+ i = j + 1;
705
+ break;
706
+ }
707
+ // param/intermediate bytes: 0x20–0x3F (includes digits ; : < = > ?)
708
+ if (c < 0x20 || c > 0x3f) {
709
+ // malformed — drop ESC and continue
710
+ i += 1;
711
+ break;
712
+ }
713
+ j++;
714
+ }
715
+ if (j >= s.length) {
716
+ // incomplete CSI
717
+ return { events: out, pending: s.slice(i) };
718
+ }
719
+ continue;
720
+ }
721
+ // SS3: ESC O A|B|C|D|H|F
722
+ if (n1 === "O") {
723
+ if (i + 2 >= s.length)
724
+ return { events: out, pending: s.slice(i) };
725
+ const f = s[i + 2];
726
+ const ev = arrowFromFinal(f, {
727
+ shift: false,
728
+ alt: false,
729
+ ctrl: false,
730
+ meta: false,
731
+ capsLock: false,
732
+ });
733
+ if (ev)
734
+ out.push(ev);
735
+ i += 3;
736
+ continue;
737
+ }
738
+ // Meta/Alt + key (common on macOS Option-as-Meta)
739
+ if (n1 === "\u007F" || n1 === "\b") {
740
+ out.push({ type: "word_backspace" });
741
+ i += 2;
742
+ continue;
743
+ }
744
+ // Alt+Enter → newline (Terminal.app Option-as-Meta workaround for Shift+Enter)
745
+ if (n1 === "\r" || n1 === "\n") {
746
+ out.push({ type: "shift_enter" });
747
+ i += 2;
748
+ continue;
749
+ }
750
+ if (n1 === "b" || n1 === "B") {
751
+ out.push({ type: "word_left" });
752
+ i += 2;
753
+ continue;
754
+ }
755
+ if (n1 === "f" || n1 === "F") {
756
+ out.push({ type: "word_right" });
757
+ i += 2;
758
+ continue;
759
+ }
760
+ // Unknown meta+printable — swallow pair (never inject ESC residue as text)
761
+ if (n1 >= " " && n1 !== "\u007F") {
762
+ i += 2;
763
+ continue;
764
+ }
765
+ out.push({ type: "esc" });
766
+ i += 1;
767
+ continue;
768
+ }
769
+ // Ctrl-J (LF) → shift_enter: portable Shift+Enter. CR → enter; CRLF is one submit.
770
+ if (ch === "\r") {
771
+ out.push({ type: "enter" });
772
+ i += s[i + 1] === "\n" ? 2 : 1;
773
+ continue;
774
+ }
775
+ if (ch === "\n") {
776
+ out.push({ type: "shift_enter" });
777
+ i += 1;
778
+ continue;
779
+ }
780
+ if (ch === "\u007F" || ch === "\b") {
781
+ out.push({ type: "backspace" });
782
+ i += 1;
783
+ continue;
784
+ }
785
+ if (ch === "\u0003") {
786
+ out.push({ type: "ctrl_c" });
787
+ i += 1;
788
+ continue;
789
+ }
790
+ const c0 = C0_EVENTS[code];
791
+ if (c0) {
792
+ out.push({ ...c0 });
793
+ i += 1;
794
+ continue;
795
+ }
796
+ if (ch === "\t") {
797
+ out.push({ type: "tab" });
798
+ i += 1;
799
+ continue;
800
+ }
801
+ if (ch >= " ") {
802
+ out.push({ type: "char", ch });
803
+ i += 1;
804
+ continue;
805
+ }
806
+ // Other C0 — ignore (never surface as unknown text)
807
+ i += 1;
808
+ }
809
+ return { events: out.length > 0 ? out : [], pending: "" };
810
+ }
811
+ /**
812
+ * Resolve a held ESC after the host's short quiet-window timeout elapses
813
+ * with no further bytes. consumeKeys never does this itself — it cannot
814
+ * distinguish "no more bytes are coming" from "more are about to arrive" —
815
+ * so the timer belongs to the host (main.ts / storybook's main.ts both use
816
+ * ~30ms). Only a bare "\x1b" tail resolves; any other pending shape
817
+ * (incomplete CSI, empty) is returned untouched — it still needs more bytes,
818
+ * or there was nothing pending to begin with.
819
+ */
820
+ export function flushPendingEsc(pending) {
821
+ if (pending === "\u001B")
822
+ return { events: [{ type: "esc" }], pending: "" };
823
+ return { events: [], pending };
824
+ }
825
+ //# sourceMappingURL=decode.js.map