@vibefield/puppeteer-views 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 +21 -0
  2. package/dist/bar/InstrumentBar.d.ts +81 -0
  3. package/dist/bar/InstrumentBar.d.ts.map +1 -0
  4. package/dist/bar/InstrumentBar.js +86 -0
  5. package/dist/bar/InstrumentBar.js.map +1 -0
  6. package/dist/bar/ProfileTabs.d.ts +24 -0
  7. package/dist/bar/ProfileTabs.d.ts.map +1 -0
  8. package/dist/bar/ProfileTabs.js +141 -0
  9. package/dist/bar/ProfileTabs.js.map +1 -0
  10. package/dist/chrome/ChromeBoundary.d.ts +60 -0
  11. package/dist/chrome/ChromeBoundary.d.ts.map +1 -0
  12. package/dist/chrome/ChromeBoundary.js +70 -0
  13. package/dist/chrome/ChromeBoundary.js.map +1 -0
  14. package/dist/chrome/stage.d.ts +8 -0
  15. package/dist/chrome/stage.d.ts.map +1 -0
  16. package/dist/chrome/stage.js +8 -0
  17. package/dist/chrome/stage.js.map +1 -0
  18. package/dist/colour/pane-colours.d.ts +21 -0
  19. package/dist/colour/pane-colours.d.ts.map +1 -0
  20. package/dist/colour/pane-colours.js +25 -0
  21. package/dist/colour/pane-colours.js.map +1 -0
  22. package/dist/colour/project-tint.d.ts +23 -0
  23. package/dist/colour/project-tint.d.ts.map +1 -0
  24. package/dist/colour/project-tint.js +100 -0
  25. package/dist/colour/project-tint.js.map +1 -0
  26. package/dist/deck/DeckFrames.d.ts +71 -0
  27. package/dist/deck/DeckFrames.d.ts.map +1 -0
  28. package/dist/deck/DeckFrames.js +50 -0
  29. package/dist/deck/DeckFrames.js.map +1 -0
  30. package/dist/deck/PaneFrame.d.ts +80 -0
  31. package/dist/deck/PaneFrame.d.ts.map +1 -0
  32. package/dist/deck/PaneFrame.js +118 -0
  33. package/dist/deck/PaneFrame.js.map +1 -0
  34. package/dist/deck/completed-agent-panes.d.ts +24 -0
  35. package/dist/deck/completed-agent-panes.d.ts.map +1 -0
  36. package/dist/deck/completed-agent-panes.js +72 -0
  37. package/dist/deck/completed-agent-panes.js.map +1 -0
  38. package/dist/deck/deck-zoom.d.ts +40 -0
  39. package/dist/deck/deck-zoom.d.ts.map +1 -0
  40. package/dist/deck/deck-zoom.js +200 -0
  41. package/dist/deck/deck-zoom.js.map +1 -0
  42. package/dist/deck/index.d.ts +8 -0
  43. package/dist/deck/index.d.ts.map +1 -0
  44. package/dist/deck/index.js +13 -0
  45. package/dist/deck/index.js.map +1 -0
  46. package/dist/deck/pane-elements.d.ts +24 -0
  47. package/dist/deck/pane-elements.d.ts.map +1 -0
  48. package/dist/deck/pane-elements.js +73 -0
  49. package/dist/deck/pane-elements.js.map +1 -0
  50. package/dist/deck/pane-frame.d.ts +88 -0
  51. package/dist/deck/pane-frame.d.ts.map +1 -0
  52. package/dist/deck/pane-frame.js +51 -0
  53. package/dist/deck/pane-frame.js.map +1 -0
  54. package/dist/deck/unused-pane-sessions.d.ts +24 -0
  55. package/dist/deck/unused-pane-sessions.d.ts.map +1 -0
  56. package/dist/deck/unused-pane-sessions.js +75 -0
  57. package/dist/deck/unused-pane-sessions.js.map +1 -0
  58. package/dist/deck/use-deck-zoom.d.ts +10 -0
  59. package/dist/deck/use-deck-zoom.d.ts.map +1 -0
  60. package/dist/deck/use-deck-zoom.js +31 -0
  61. package/dist/deck/use-deck-zoom.js.map +1 -0
  62. package/dist/find/FindSheet.d.ts +23 -0
  63. package/dist/find/FindSheet.d.ts.map +1 -0
  64. package/dist/find/FindSheet.js +197 -0
  65. package/dist/find/FindSheet.js.map +1 -0
  66. package/dist/find/find-agent.d.ts +35 -0
  67. package/dist/find/find-agent.d.ts.map +1 -0
  68. package/dist/find/find-agent.js +2 -0
  69. package/dist/find/find-agent.js.map +1 -0
  70. package/dist/find/find-model.d.ts +93 -0
  71. package/dist/find/find-model.d.ts.map +1 -0
  72. package/dist/find/find-model.js +372 -0
  73. package/dist/find/find-model.js.map +1 -0
  74. package/dist/find/history-port.d.ts +78 -0
  75. package/dist/find/history-port.d.ts.map +1 -0
  76. package/dist/find/history-port.js +9 -0
  77. package/dist/find/history-port.js.map +1 -0
  78. package/dist/icons/ServiceMark.d.ts +32 -0
  79. package/dist/icons/ServiceMark.d.ts.map +1 -0
  80. package/dist/icons/ServiceMark.js +57 -0
  81. package/dist/icons/ServiceMark.js.map +1 -0
  82. package/dist/icons/profile-glyph-suggest.d.ts +8 -0
  83. package/dist/icons/profile-glyph-suggest.d.ts.map +1 -0
  84. package/dist/icons/profile-glyph-suggest.js +42 -0
  85. package/dist/icons/profile-glyph-suggest.js.map +1 -0
  86. package/dist/icons/service-marks.d.ts +5 -0
  87. package/dist/icons/service-marks.d.ts.map +1 -0
  88. package/dist/icons/service-marks.js +81 -0
  89. package/dist/icons/service-marks.js.map +1 -0
  90. package/dist/index.d.ts +60 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +86 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/lab/lab-clock.d.ts +11 -0
  95. package/dist/lab/lab-clock.d.ts.map +1 -0
  96. package/dist/lab/lab-clock.js +48 -0
  97. package/dist/lab/lab-clock.js.map +1 -0
  98. package/dist/lab/lab-model.d.ts +10 -0
  99. package/dist/lab/lab-model.d.ts.map +1 -0
  100. package/dist/lab/lab-model.js +146 -0
  101. package/dist/lab/lab-model.js.map +1 -0
  102. package/dist/lab/lab-stage.d.ts +72 -0
  103. package/dist/lab/lab-stage.d.ts.map +1 -0
  104. package/dist/lab/lab-stage.js +201 -0
  105. package/dist/lab/lab-stage.js.map +1 -0
  106. package/dist/lab/lab-world.d.ts +33 -0
  107. package/dist/lab/lab-world.d.ts.map +1 -0
  108. package/dist/lab/lab-world.js +394 -0
  109. package/dist/lab/lab-world.js.map +1 -0
  110. package/dist/lab/view-lab.css +98 -0
  111. package/dist/launcher/DeckLaunchers.d.ts +92 -0
  112. package/dist/launcher/DeckLaunchers.d.ts.map +1 -0
  113. package/dist/launcher/DeckLaunchers.js +377 -0
  114. package/dist/launcher/DeckLaunchers.js.map +1 -0
  115. package/dist/launcher/PaneLaunch.d.ts +50 -0
  116. package/dist/launcher/PaneLaunch.d.ts.map +1 -0
  117. package/dist/launcher/PaneLaunch.js +318 -0
  118. package/dist/launcher/PaneLaunch.js.map +1 -0
  119. package/dist/launcher/PaneLaunchChrome.d.ts +49 -0
  120. package/dist/launcher/PaneLaunchChrome.d.ts.map +1 -0
  121. package/dist/launcher/PaneLaunchChrome.js +32 -0
  122. package/dist/launcher/PaneLaunchChrome.js.map +1 -0
  123. package/dist/launcher/PaneLauncher.d.ts +97 -0
  124. package/dist/launcher/PaneLauncher.d.ts.map +1 -0
  125. package/dist/launcher/PaneLauncher.js +349 -0
  126. package/dist/launcher/PaneLauncher.js.map +1 -0
  127. package/dist/launcher/PaneLauncherChrome.d.ts +97 -0
  128. package/dist/launcher/PaneLauncherChrome.d.ts.map +1 -0
  129. package/dist/launcher/PaneLauncherChrome.js +131 -0
  130. package/dist/launcher/PaneLauncherChrome.js.map +1 -0
  131. package/dist/launcher/index.d.ts +9 -0
  132. package/dist/launcher/index.d.ts.map +1 -0
  133. package/dist/launcher/index.js +16 -0
  134. package/dist/launcher/index.js.map +1 -0
  135. package/dist/launcher/launch-model.d.ts +162 -0
  136. package/dist/launcher/launch-model.d.ts.map +1 -0
  137. package/dist/launcher/launch-model.js +169 -0
  138. package/dist/launcher/launch-model.js.map +1 -0
  139. package/dist/launcher/launcher-model.d.ts +268 -0
  140. package/dist/launcher/launcher-model.d.ts.map +1 -0
  141. package/dist/launcher/launcher-model.js +443 -0
  142. package/dist/launcher/launcher-model.js.map +1 -0
  143. package/dist/launcher/launcher-port.d.ts +115 -0
  144. package/dist/launcher/launcher-port.d.ts.map +1 -0
  145. package/dist/launcher/launcher-port.js +12 -0
  146. package/dist/launcher/launcher-port.js.map +1 -0
  147. package/dist/monitor/agent-status.d.ts +13 -0
  148. package/dist/monitor/agent-status.d.ts.map +1 -0
  149. package/dist/monitor/agent-status.js +5 -0
  150. package/dist/monitor/agent-status.js.map +1 -0
  151. package/dist/monitor/agents.d.ts +6 -0
  152. package/dist/monitor/agents.d.ts.map +1 -0
  153. package/dist/monitor/agents.js +21 -0
  154. package/dist/monitor/agents.js.map +1 -0
  155. package/dist/monitor/cost-format.d.ts +3 -0
  156. package/dist/monitor/cost-format.d.ts.map +1 -0
  157. package/dist/monitor/cost-format.js +12 -0
  158. package/dist/monitor/cost-format.js.map +1 -0
  159. package/dist/monitor/folder-name.d.ts +3 -0
  160. package/dist/monitor/folder-name.d.ts.map +1 -0
  161. package/dist/monitor/folder-name.js +6 -0
  162. package/dist/monitor/folder-name.js.map +1 -0
  163. package/dist/monitor/palette.d.ts +94 -0
  164. package/dist/monitor/palette.d.ts.map +1 -0
  165. package/dist/monitor/palette.js +157 -0
  166. package/dist/monitor/palette.js.map +1 -0
  167. package/dist/monitor/parameters.d.ts +33 -0
  168. package/dist/monitor/parameters.d.ts.map +1 -0
  169. package/dist/monitor/parameters.js +53 -0
  170. package/dist/monitor/parameters.js.map +1 -0
  171. package/dist/monitor/recede.d.ts +14 -0
  172. package/dist/monitor/recede.d.ts.map +1 -0
  173. package/dist/monitor/recede.js +35 -0
  174. package/dist/monitor/recede.js.map +1 -0
  175. package/dist/monitor/registry.d.ts +14 -0
  176. package/dist/monitor/registry.d.ts.map +1 -0
  177. package/dist/monitor/registry.js +36 -0
  178. package/dist/monitor/registry.js.map +1 -0
  179. package/dist/monitor/remote-write.d.ts +16 -0
  180. package/dist/monitor/remote-write.d.ts.map +1 -0
  181. package/dist/monitor/remote-write.js +21 -0
  182. package/dist/monitor/remote-write.js.map +1 -0
  183. package/dist/monitor/types.d.ts +205 -0
  184. package/dist/monitor/types.d.ts.map +1 -0
  185. package/dist/monitor/types.js +2 -0
  186. package/dist/monitor/types.js.map +1 -0
  187. package/dist/styles/bar.css +396 -0
  188. package/dist/styles/deck-frame.css +439 -0
  189. package/dist/styles/deck-zoom.css +70 -0
  190. package/dist/styles/find-sheet.css +270 -0
  191. package/dist/styles/pane-launcher.css +955 -0
  192. package/dist/styles/usage.css +368 -0
  193. package/dist/styles/views.css +12 -0
  194. package/dist/usage/UsageColumn.d.ts +8 -0
  195. package/dist/usage/UsageColumn.d.ts.map +1 -0
  196. package/dist/usage/UsageColumn.js +133 -0
  197. package/dist/usage/UsageColumn.js.map +1 -0
  198. package/dist/usage/account-usage-port.d.ts +12 -0
  199. package/dist/usage/account-usage-port.d.ts.map +1 -0
  200. package/dist/usage/account-usage-port.js +2 -0
  201. package/dist/usage/account-usage-port.js.map +1 -0
  202. package/dist/usage/account-usage.d.ts +86 -0
  203. package/dist/usage/account-usage.d.ts.map +1 -0
  204. package/dist/usage/account-usage.js +262 -0
  205. package/dist/usage/account-usage.js.map +1 -0
  206. package/dist/views/list/AgentList.d.ts +4 -0
  207. package/dist/views/list/AgentList.d.ts.map +1 -0
  208. package/dist/views/list/AgentList.js +101 -0
  209. package/dist/views/list/AgentList.js.map +1 -0
  210. package/dist/views/list/ListSpawnMenu.d.ts +20 -0
  211. package/dist/views/list/ListSpawnMenu.d.ts.map +1 -0
  212. package/dist/views/list/ListSpawnMenu.js +143 -0
  213. package/dist/views/list/ListSpawnMenu.js.map +1 -0
  214. package/dist/views/list/index.d.ts +8 -0
  215. package/dist/views/list/index.d.ts.map +1 -0
  216. package/dist/views/list/index.js +43 -0
  217. package/dist/views/list/index.js.map +1 -0
  218. package/dist/views/list/lab/main.d.ts +2 -0
  219. package/dist/views/list/lab/main.d.ts.map +1 -0
  220. package/dist/views/list/lab/main.js +25 -0
  221. package/dist/views/list/lab/main.js.map +1 -0
  222. package/dist/views/list/list-parameters.d.ts +9 -0
  223. package/dist/views/list/list-parameters.d.ts.map +1 -0
  224. package/dist/views/list/list-parameters.js +27 -0
  225. package/dist/views/list/list-parameters.js.map +1 -0
  226. package/dist/views/list/list.css +387 -0
  227. package/dist/views/rain/RainView.d.ts +4 -0
  228. package/dist/views/rain/RainView.d.ts.map +1 -0
  229. package/dist/views/rain/RainView.js +282 -0
  230. package/dist/views/rain/RainView.js.map +1 -0
  231. package/dist/views/rain/index.d.ts +8 -0
  232. package/dist/views/rain/index.d.ts.map +1 -0
  233. package/dist/views/rain/index.js +53 -0
  234. package/dist/views/rain/index.js.map +1 -0
  235. package/dist/views/rain/lab/main.d.ts +2 -0
  236. package/dist/views/rain/lab/main.d.ts.map +1 -0
  237. package/dist/views/rain/lab/main.js +26 -0
  238. package/dist/views/rain/lab/main.js.map +1 -0
  239. package/dist/views/rain/rain-parameters.d.ts +15 -0
  240. package/dist/views/rain/rain-parameters.d.ts.map +1 -0
  241. package/dist/views/rain/rain-parameters.js +52 -0
  242. package/dist/views/rain/rain-parameters.js.map +1 -0
  243. package/dist/views/rain/rain-streams.d.ts +44 -0
  244. package/dist/views/rain/rain-streams.d.ts.map +1 -0
  245. package/dist/views/rain/rain-streams.js +101 -0
  246. package/dist/views/rain/rain-streams.js.map +1 -0
  247. package/dist/views/rain/rain.css +200 -0
  248. package/dist/views/spend/SpendView.d.ts +30 -0
  249. package/dist/views/spend/SpendView.d.ts.map +1 -0
  250. package/dist/views/spend/SpendView.js +645 -0
  251. package/dist/views/spend/SpendView.js.map +1 -0
  252. package/dist/views/spend/index.d.ts +8 -0
  253. package/dist/views/spend/index.d.ts.map +1 -0
  254. package/dist/views/spend/index.js +54 -0
  255. package/dist/views/spend/index.js.map +1 -0
  256. package/dist/views/spend/lab/main.d.ts +2 -0
  257. package/dist/views/spend/lab/main.d.ts.map +1 -0
  258. package/dist/views/spend/lab/main.js +237 -0
  259. package/dist/views/spend/lab/main.js.map +1 -0
  260. package/dist/views/spend/lab/spend-fixtures.d.ts +72 -0
  261. package/dist/views/spend/lab/spend-fixtures.d.ts.map +1 -0
  262. package/dist/views/spend/lab/spend-fixtures.js +412 -0
  263. package/dist/views/spend/lab/spend-fixtures.js.map +1 -0
  264. package/dist/views/spend/spend-ink.d.ts +18 -0
  265. package/dist/views/spend/spend-ink.d.ts.map +1 -0
  266. package/dist/views/spend/spend-ink.js +50 -0
  267. package/dist/views/spend/spend-ink.js.map +1 -0
  268. package/dist/views/spend/spend-list.d.ts +48 -0
  269. package/dist/views/spend/spend-list.d.ts.map +1 -0
  270. package/dist/views/spend/spend-list.js +93 -0
  271. package/dist/views/spend/spend-list.js.map +1 -0
  272. package/dist/views/spend/spend-paint.d.ts +88 -0
  273. package/dist/views/spend/spend-paint.d.ts.map +1 -0
  274. package/dist/views/spend/spend-paint.js +225 -0
  275. package/dist/views/spend/spend-paint.js.map +1 -0
  276. package/dist/views/spend/spend-parameters.d.ts +11 -0
  277. package/dist/views/spend/spend-parameters.d.ts.map +1 -0
  278. package/dist/views/spend/spend-parameters.js +27 -0
  279. package/dist/views/spend/spend-parameters.js.map +1 -0
  280. package/dist/views/spend/spend-scale.d.ts +43 -0
  281. package/dist/views/spend/spend-scale.d.ts.map +1 -0
  282. package/dist/views/spend/spend-scale.js +71 -0
  283. package/dist/views/spend/spend-scale.js.map +1 -0
  284. package/dist/views/spend/spend-series.d.ts +91 -0
  285. package/dist/views/spend/spend-series.d.ts.map +1 -0
  286. package/dist/views/spend/spend-series.js +212 -0
  287. package/dist/views/spend/spend-series.js.map +1 -0
  288. package/dist/views/spend/spend-words.d.ts +82 -0
  289. package/dist/views/spend/spend-words.d.ts.map +1 -0
  290. package/dist/views/spend/spend-words.js +164 -0
  291. package/dist/views/spend/spend-words.js.map +1 -0
  292. package/dist/views/spend/spend.css +585 -0
  293. package/dist/views/swarm/AgentSwarm.d.ts +4 -0
  294. package/dist/views/swarm/AgentSwarm.d.ts.map +1 -0
  295. package/dist/views/swarm/AgentSwarm.js +969 -0
  296. package/dist/views/swarm/AgentSwarm.js.map +1 -0
  297. package/dist/views/swarm/bloom/SpawnBloom.d.ts +26 -0
  298. package/dist/views/swarm/bloom/SpawnBloom.d.ts.map +1 -0
  299. package/dist/views/swarm/bloom/SpawnBloom.js +332 -0
  300. package/dist/views/swarm/bloom/SpawnBloom.js.map +1 -0
  301. package/dist/views/swarm/bloom/birth.d.ts +70 -0
  302. package/dist/views/swarm/bloom/birth.d.ts.map +1 -0
  303. package/dist/views/swarm/bloom/birth.js +89 -0
  304. package/dist/views/swarm/bloom/birth.js.map +1 -0
  305. package/dist/views/swarm/bloom/canvas-measure.d.ts +11 -0
  306. package/dist/views/swarm/bloom/canvas-measure.d.ts.map +1 -0
  307. package/dist/views/swarm/bloom/canvas-measure.js +37 -0
  308. package/dist/views/swarm/bloom/canvas-measure.js.map +1 -0
  309. package/dist/views/swarm/bloom/constants.d.ts +93 -0
  310. package/dist/views/swarm/bloom/constants.d.ts.map +1 -0
  311. package/dist/views/swarm/bloom/constants.js +94 -0
  312. package/dist/views/swarm/bloom/constants.js.map +1 -0
  313. package/dist/views/swarm/bloom/field-frame.d.ts +69 -0
  314. package/dist/views/swarm/bloom/field-frame.d.ts.map +1 -0
  315. package/dist/views/swarm/bloom/field-frame.js +104 -0
  316. package/dist/views/swarm/bloom/field-frame.js.map +1 -0
  317. package/dist/views/swarm/bloom/geometry.d.ts +187 -0
  318. package/dist/views/swarm/bloom/geometry.d.ts.map +1 -0
  319. package/dist/views/swarm/bloom/geometry.js +379 -0
  320. package/dist/views/swarm/bloom/geometry.js.map +1 -0
  321. package/dist/views/swarm/bloom/index.d.ts +8 -0
  322. package/dist/views/swarm/bloom/index.d.ts.map +1 -0
  323. package/dist/views/swarm/bloom/index.js +13 -0
  324. package/dist/views/swarm/bloom/index.js.map +1 -0
  325. package/dist/views/swarm/bloom/menu.d.ts +5 -0
  326. package/dist/views/swarm/bloom/menu.d.ts.map +1 -0
  327. package/dist/views/swarm/bloom/menu.js +14 -0
  328. package/dist/views/swarm/bloom/menu.js.map +1 -0
  329. package/dist/views/swarm/bloom/model.d.ts +255 -0
  330. package/dist/views/swarm/bloom/model.d.ts.map +1 -0
  331. package/dist/views/swarm/bloom/model.js +678 -0
  332. package/dist/views/swarm/bloom/model.js.map +1 -0
  333. package/dist/views/swarm/bloom/scenarios.d.ts +7 -0
  334. package/dist/views/swarm/bloom/scenarios.d.ts.map +1 -0
  335. package/dist/views/swarm/bloom/scenarios.js +57 -0
  336. package/dist/views/swarm/bloom/scenarios.js.map +1 -0
  337. package/dist/views/swarm/bloom/spawn-bloom.css +407 -0
  338. package/dist/views/swarm/bloom/targeting.d.ts +60 -0
  339. package/dist/views/swarm/bloom/targeting.d.ts.map +1 -0
  340. package/dist/views/swarm/bloom/targeting.js +74 -0
  341. package/dist/views/swarm/bloom/targeting.js.map +1 -0
  342. package/dist/views/swarm/bloom/use-spawn-bloom.d.ts +100 -0
  343. package/dist/views/swarm/bloom/use-spawn-bloom.d.ts.map +1 -0
  344. package/dist/views/swarm/bloom/use-spawn-bloom.js +333 -0
  345. package/dist/views/swarm/bloom/use-spawn-bloom.js.map +1 -0
  346. package/dist/views/swarm/bloom/words.d.ts +73 -0
  347. package/dist/views/swarm/bloom/words.d.ts.map +1 -0
  348. package/dist/views/swarm/bloom/words.js +195 -0
  349. package/dist/views/swarm/bloom/words.js.map +1 -0
  350. package/dist/views/swarm/body-id.d.ts +13 -0
  351. package/dist/views/swarm/body-id.d.ts.map +1 -0
  352. package/dist/views/swarm/body-id.js +12 -0
  353. package/dist/views/swarm/body-id.js.map +1 -0
  354. package/dist/views/swarm/bubble-model.d.ts +128 -0
  355. package/dist/views/swarm/bubble-model.d.ts.map +1 -0
  356. package/dist/views/swarm/bubble-model.js +421 -0
  357. package/dist/views/swarm/bubble-model.js.map +1 -0
  358. package/dist/views/swarm/gpu/frame-layout.d.ts +52 -0
  359. package/dist/views/swarm/gpu/frame-layout.d.ts.map +1 -0
  360. package/dist/views/swarm/gpu/frame-layout.js +122 -0
  361. package/dist/views/swarm/gpu/frame-layout.js.map +1 -0
  362. package/dist/views/swarm/gpu/glyph-atlas.d.ts +63 -0
  363. package/dist/views/swarm/gpu/glyph-atlas.d.ts.map +1 -0
  364. package/dist/views/swarm/gpu/glyph-atlas.js +207 -0
  365. package/dist/views/swarm/gpu/glyph-atlas.js.map +1 -0
  366. package/dist/views/swarm/gpu/profile-icons.d.ts +4 -0
  367. package/dist/views/swarm/gpu/profile-icons.d.ts.map +1 -0
  368. package/dist/views/swarm/gpu/profile-icons.js +18 -0
  369. package/dist/views/swarm/gpu/profile-icons.js.map +1 -0
  370. package/dist/views/swarm/gpu/shaders/body.wgsl.d.ts +3 -0
  371. package/dist/views/swarm/gpu/shaders/body.wgsl.d.ts.map +1 -0
  372. package/dist/views/swarm/gpu/shaders/body.wgsl.js +162 -0
  373. package/dist/views/swarm/gpu/shaders/body.wgsl.js.map +1 -0
  374. package/dist/views/swarm/gpu/shaders/common.wgsl.d.ts +3 -0
  375. package/dist/views/swarm/gpu/shaders/common.wgsl.d.ts.map +1 -0
  376. package/dist/views/swarm/gpu/shaders/common.wgsl.js +171 -0
  377. package/dist/views/swarm/gpu/shaders/common.wgsl.js.map +1 -0
  378. package/dist/views/swarm/gpu/shaders/erase.wgsl.d.ts +3 -0
  379. package/dist/views/swarm/gpu/shaders/erase.wgsl.d.ts.map +1 -0
  380. package/dist/views/swarm/gpu/shaders/erase.wgsl.js +61 -0
  381. package/dist/views/swarm/gpu/shaders/erase.wgsl.js.map +1 -0
  382. package/dist/views/swarm/gpu/shaders/field.wgsl.d.ts +3 -0
  383. package/dist/views/swarm/gpu/shaders/field.wgsl.d.ts.map +1 -0
  384. package/dist/views/swarm/gpu/shaders/field.wgsl.js +47 -0
  385. package/dist/views/swarm/gpu/shaders/field.wgsl.js.map +1 -0
  386. package/dist/views/swarm/gpu/shaders/glow.wgsl.d.ts +3 -0
  387. package/dist/views/swarm/gpu/shaders/glow.wgsl.d.ts.map +1 -0
  388. package/dist/views/swarm/gpu/shaders/glow.wgsl.js +39 -0
  389. package/dist/views/swarm/gpu/shaders/glow.wgsl.js.map +1 -0
  390. package/dist/views/swarm/gpu/shaders/hub.wgsl.d.ts +3 -0
  391. package/dist/views/swarm/gpu/shaders/hub.wgsl.d.ts.map +1 -0
  392. package/dist/views/swarm/gpu/shaders/hub.wgsl.js +48 -0
  393. package/dist/views/swarm/gpu/shaders/hub.wgsl.js.map +1 -0
  394. package/dist/views/swarm/gpu/shaders/shadow.wgsl.d.ts +3 -0
  395. package/dist/views/swarm/gpu/shaders/shadow.wgsl.d.ts.map +1 -0
  396. package/dist/views/swarm/gpu/shaders/shadow.wgsl.js +37 -0
  397. package/dist/views/swarm/gpu/shaders/shadow.wgsl.js.map +1 -0
  398. package/dist/views/swarm/gpu/shaders/text.wgsl.d.ts +3 -0
  399. package/dist/views/swarm/gpu/shaders/text.wgsl.d.ts.map +1 -0
  400. package/dist/views/swarm/gpu/shaders/text.wgsl.js +51 -0
  401. package/dist/views/swarm/gpu/shaders/text.wgsl.js.map +1 -0
  402. package/dist/views/swarm/gpu/swarm-renderer.d.ts +155 -0
  403. package/dist/views/swarm/gpu/swarm-renderer.d.ts.map +1 -0
  404. package/dist/views/swarm/gpu/swarm-renderer.js +696 -0
  405. package/dist/views/swarm/gpu/swarm-renderer.js.map +1 -0
  406. package/dist/views/swarm/index.d.ts +9 -0
  407. package/dist/views/swarm/index.d.ts.map +1 -0
  408. package/dist/views/swarm/index.js +40 -0
  409. package/dist/views/swarm/index.js.map +1 -0
  410. package/dist/views/swarm/lab/fixtures.d.ts +148 -0
  411. package/dist/views/swarm/lab/fixtures.d.ts.map +1 -0
  412. package/dist/views/swarm/lab/fixtures.js +821 -0
  413. package/dist/views/swarm/lab/fixtures.js.map +1 -0
  414. package/dist/views/swarm/lab/lab.css +315 -0
  415. package/dist/views/swarm/lab/main.d.ts +2 -0
  416. package/dist/views/swarm/lab/main.d.ts.map +1 -0
  417. package/dist/views/swarm/lab/main.js +474 -0
  418. package/dist/views/swarm/lab/main.js.map +1 -0
  419. package/dist/views/swarm/physics/driver.d.ts +23 -0
  420. package/dist/views/swarm/physics/driver.d.ts.map +1 -0
  421. package/dist/views/swarm/physics/driver.js +68 -0
  422. package/dist/views/swarm/physics/driver.js.map +1 -0
  423. package/dist/views/swarm/physics/frame.d.ts +28 -0
  424. package/dist/views/swarm/physics/frame.d.ts.map +1 -0
  425. package/dist/views/swarm/physics/frame.js +47 -0
  426. package/dist/views/swarm/physics/frame.js.map +1 -0
  427. package/dist/views/swarm/physics/host.d.ts +28 -0
  428. package/dist/views/swarm/physics/host.d.ts.map +1 -0
  429. package/dist/views/swarm/physics/host.js +168 -0
  430. package/dist/views/swarm/physics/host.js.map +1 -0
  431. package/dist/views/swarm/physics/index.d.ts +6 -0
  432. package/dist/views/swarm/physics/index.d.ts.map +1 -0
  433. package/dist/views/swarm/physics/index.js +14 -0
  434. package/dist/views/swarm/physics/index.js.map +1 -0
  435. package/dist/views/swarm/physics/inline-driver.d.ts +27 -0
  436. package/dist/views/swarm/physics/inline-driver.d.ts.map +1 -0
  437. package/dist/views/swarm/physics/inline-driver.js +37 -0
  438. package/dist/views/swarm/physics/inline-driver.js.map +1 -0
  439. package/dist/views/swarm/physics/protocol.d.ts +125 -0
  440. package/dist/views/swarm/physics/protocol.d.ts.map +1 -0
  441. package/dist/views/swarm/physics/protocol.js +4 -0
  442. package/dist/views/swarm/physics/protocol.js.map +1 -0
  443. package/dist/views/swarm/physics/spawn-clamp.d.ts +11 -0
  444. package/dist/views/swarm/physics/spawn-clamp.d.ts.map +1 -0
  445. package/dist/views/swarm/physics/spawn-clamp.js +15 -0
  446. package/dist/views/swarm/physics/spawn-clamp.js.map +1 -0
  447. package/dist/views/swarm/physics/swarm-physics.worker.d.ts +2 -0
  448. package/dist/views/swarm/physics/swarm-physics.worker.d.ts.map +1 -0
  449. package/dist/views/swarm/physics/swarm-physics.worker.js +66 -0
  450. package/dist/views/swarm/physics/swarm-physics.worker.js.map +1 -0
  451. package/dist/views/swarm/physics/world.d.ts +174 -0
  452. package/dist/views/swarm/physics/world.d.ts.map +1 -0
  453. package/dist/views/swarm/physics/world.js +454 -0
  454. package/dist/views/swarm/physics/world.js.map +1 -0
  455. package/dist/views/swarm/swarm-parameters.d.ts +50 -0
  456. package/dist/views/swarm/swarm-parameters.d.ts.map +1 -0
  457. package/dist/views/swarm/swarm-parameters.js +103 -0
  458. package/dist/views/swarm/swarm-parameters.js.map +1 -0
  459. package/dist/views/swarm/swarm-theme.d.ts +5 -0
  460. package/dist/views/swarm/swarm-theme.d.ts.map +1 -0
  461. package/dist/views/swarm/swarm-theme.js +63 -0
  462. package/dist/views/swarm/swarm-theme.js.map +1 -0
  463. package/dist/views/swarm/swarm.css +136 -0
  464. package/dist/views/swarm/text-layout.d.ts +72 -0
  465. package/dist/views/swarm/text-layout.d.ts.map +1 -0
  466. package/dist/views/swarm/text-layout.js +76 -0
  467. package/dist/views/swarm/text-layout.js.map +1 -0
  468. package/dist/views/swarm/weight.d.ts +44 -0
  469. package/dist/views/swarm/weight.d.ts.map +1 -0
  470. package/dist/views/swarm/weight.js +57 -0
  471. package/dist/views/swarm/weight.js.map +1 -0
  472. package/dist/views/timeline/TimelineView.d.ts +9 -0
  473. package/dist/views/timeline/TimelineView.d.ts.map +1 -0
  474. package/dist/views/timeline/TimelineView.js +889 -0
  475. package/dist/views/timeline/TimelineView.js.map +1 -0
  476. package/dist/views/timeline/index.d.ts +11 -0
  477. package/dist/views/timeline/index.d.ts.map +1 -0
  478. package/dist/views/timeline/index.js +63 -0
  479. package/dist/views/timeline/index.js.map +1 -0
  480. package/dist/views/timeline/lab/main.d.ts +2 -0
  481. package/dist/views/timeline/lab/main.d.ts.map +1 -0
  482. package/dist/views/timeline/lab/main.js +114 -0
  483. package/dist/views/timeline/lab/main.js.map +1 -0
  484. package/dist/views/timeline/lab/timeline-fixtures.d.ts +31 -0
  485. package/dist/views/timeline/lab/timeline-fixtures.d.ts.map +1 -0
  486. package/dist/views/timeline/lab/timeline-fixtures.js +337 -0
  487. package/dist/views/timeline/lab/timeline-fixtures.js.map +1 -0
  488. package/dist/views/timeline/pulse-map.d.ts +63 -0
  489. package/dist/views/timeline/pulse-map.d.ts.map +1 -0
  490. package/dist/views/timeline/pulse-map.js +162 -0
  491. package/dist/views/timeline/pulse-map.js.map +1 -0
  492. package/dist/views/timeline/timeline-inks.d.ts +28 -0
  493. package/dist/views/timeline/timeline-inks.d.ts.map +1 -0
  494. package/dist/views/timeline/timeline-inks.js +35 -0
  495. package/dist/views/timeline/timeline-inks.js.map +1 -0
  496. package/dist/views/timeline/timeline-lanes.d.ts +139 -0
  497. package/dist/views/timeline/timeline-lanes.d.ts.map +1 -0
  498. package/dist/views/timeline/timeline-lanes.js +240 -0
  499. package/dist/views/timeline/timeline-lanes.js.map +1 -0
  500. package/dist/views/timeline/timeline-paint.d.ts +39 -0
  501. package/dist/views/timeline/timeline-paint.d.ts.map +1 -0
  502. package/dist/views/timeline/timeline-paint.js +242 -0
  503. package/dist/views/timeline/timeline-paint.js.map +1 -0
  504. package/dist/views/timeline/timeline-parameters.d.ts +11 -0
  505. package/dist/views/timeline/timeline-parameters.d.ts.map +1 -0
  506. package/dist/views/timeline/timeline-parameters.js +27 -0
  507. package/dist/views/timeline/timeline-parameters.js.map +1 -0
  508. package/dist/views/timeline/timeline-scale.d.ts +73 -0
  509. package/dist/views/timeline/timeline-scale.d.ts.map +1 -0
  510. package/dist/views/timeline/timeline-scale.js +152 -0
  511. package/dist/views/timeline/timeline-scale.js.map +1 -0
  512. package/dist/views/timeline/timeline-words.d.ts +46 -0
  513. package/dist/views/timeline/timeline-words.d.ts.map +1 -0
  514. package/dist/views/timeline/timeline-words.js +132 -0
  515. package/dist/views/timeline/timeline-words.js.map +1 -0
  516. package/dist/views/timeline/timeline.css +875 -0
  517. package/dist/views/timeline/wake-geometry.d.ts +88 -0
  518. package/dist/views/timeline/wake-geometry.d.ts.map +1 -0
  519. package/dist/views/timeline/wake-geometry.js +243 -0
  520. package/dist/views/timeline/wake-geometry.js.map +1 -0
  521. package/package.json +78 -3
  522. package/README.md +0 -3
@@ -0,0 +1,969 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState, } from 'react';
3
+ import { approachRecede, createMotionLoop, everyReceded, recedeTarget, resolveCssColor, } from '@vibefield/puppeteer-view-sdk/toolkit';
4
+ import { birthAgent, birthOf, birthOverdue, birthRow, profileLineFor } from './bloom/birth.js';
5
+ import { BLOOM } from './bloom/constants.js';
6
+ import { arrivalFrom, bloomFieldMemory, departure, stepBloomField, stepLit, veiledOpacity, } from './bloom/field-frame.js';
7
+ import { SpawnBloom } from './bloom/SpawnBloom.js';
8
+ import { useSpawnBloom } from './bloom/use-spawn-bloom.js';
9
+ import { bodyIdOf } from './body-id.js';
10
+ import { bubbleModel, workingShares } from './bubble-model.js';
11
+ import { createSwarmRenderer, MAX_CLEARINGS, } from './gpu/swarm-renderer.js';
12
+ import { createSwarmPhysicsDriver } from './physics/driver.js';
13
+ import { readSwarmFrame } from './physics/frame.js';
14
+ import { PHYSICS_HZ_FLOOR } from './physics/world.js';
15
+ import { normalizeSwarmParameters } from './swarm-parameters.js';
16
+ import { resolveSwarmTheme } from './swarm-theme.js';
17
+ const LONG_PRESS_DURATION_MS = 520;
18
+ const LONG_PRESS_MOVE_TOLERANCE = 8;
19
+ const SPAWN_DURATION_MS = 720;
20
+ /** Critically damped: about 90% of a size change lands within 300ms. */
21
+ const RADIUS_SPRING_OMEGA = 16;
22
+ const GRID_PITCH = 24;
23
+ /** The burn rate moves on its own: models are refreshed on this cadence even when nothing else changed. */
24
+ const MODEL_REFRESH_MS = 1000;
25
+ const STATUS_RANK = { idle: 0, working: 1, blocked: 2 };
26
+ /** The signifier (SB §2.11): a pointer still this long over empty ground is told what a hold does… */
27
+ const SIGNIFIER_STILL_MS = 1200;
28
+ /** …the first this-many times per page load. */
29
+ const SIGNIFIER_TIMES = 3;
30
+ /** A still pointer may wander this far. */
31
+ const SIGNIFIER_SLOP = 3;
32
+ let signifiersShown = 0;
33
+ /** Whether the element has the keyboard's focus ring (a click's focus does not). */
34
+ function focusVisible(element) {
35
+ try {
36
+ return element.matches(':focus-visible');
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /** The physics' half of the panel's parameters. The rest describe how a body LOOKS. */
43
+ function physicsParameters(swarm) {
44
+ return {
45
+ gravityPull: swarm.gravityPull,
46
+ restitution: swarm.restitution,
47
+ frictionAir: swarm.frictionAir,
48
+ physicsHz: swarm.physicsHz,
49
+ };
50
+ }
51
+ /** The arrival curve: 0 → 1.2 → 0.96 → 1.035 → 1 over 720ms. */
52
+ function arrival(elapsedMs) {
53
+ const t = elapsedMs / SPAWN_DURATION_MS;
54
+ if (t >= 1)
55
+ return { scale: 1, opacity: 1 };
56
+ if (t <= 0)
57
+ return { scale: 0, opacity: 0 };
58
+ const outQuint = (u) => 1 - (1 - u) ** 5;
59
+ const outQuad = (u) => 1 - (1 - u) ** 2;
60
+ const inOut = (u) => (u < 0.5 ? 2 * u * u : 1 - (-2 * u + 2) ** 2 / 2);
61
+ if (t < 0.52) {
62
+ const u = outQuint(t / 0.52);
63
+ return { scale: 1.2 * u, opacity: u };
64
+ }
65
+ if (t < 0.72)
66
+ return { scale: 1.2 + (0.96 - 1.2) * outQuint((t - 0.52) / 0.2), opacity: 1 };
67
+ if (t < 0.88)
68
+ return { scale: 0.96 + (1.035 - 0.96) * outQuad((t - 0.72) / 0.16), opacity: 1 };
69
+ return { scale: 1.035 + (1 - 1.035) * inOut((t - 0.88) / 0.12), opacity: 1 };
70
+ }
71
+ /**
72
+ * One body per spatial identity, the seam's rule: when two rows wear the same
73
+ * one (a launched agent's first state can arrive while the fresh shell it takes
74
+ * over is still in its pane), the earlier row in the model's order (agents
75
+ * first) speaks for it and the other is not drawn. The same list when nothing
76
+ * is dropped, so an unchanged model costs nothing.
77
+ */
78
+ function drawnRows(rows) {
79
+ const bodies = new Set();
80
+ let dropped = false;
81
+ const kept = [];
82
+ for (const row of rows) {
83
+ const id = bodyIdOf(row);
84
+ if (bodies.has(id)) {
85
+ dropped = true;
86
+ continue;
87
+ }
88
+ bodies.add(id);
89
+ kept.push(row);
90
+ }
91
+ return dropped ? kept : rows;
92
+ }
93
+ /** The host has measured its chrome: a stage with no size is one not measured yet. */
94
+ function measured(stage) {
95
+ return stage.width > 0 && stage.height > 0;
96
+ }
97
+ export function AgentSwarm({ input, commands }) {
98
+ const { model, theme, stage, parameters, capabilities } = input;
99
+ const palette = theme.tokens;
100
+ const spawnMenu = capabilities.spawn;
101
+ /** Motion is the host's switch and the person's preference together (MV-W4): off, the field holds still. */
102
+ const motionOn = theme.animations && !theme.reducedMotion;
103
+ const swarm = useMemo(() => normalizeSwarmParameters(parameters), [parameters]);
104
+ const agents = useMemo(() => drawnRows(model.agents), [model.agents]);
105
+ const containerRef = useRef(null);
106
+ const canvasRef = useRef(null);
107
+ const driverRef = useRef(undefined);
108
+ /** Index → id for the frames arriving now, and the generation it belongs to. */
109
+ const tableRef = useRef({ generation: -1, ids: [] });
110
+ /** The last two solved positions per body: the two ends of the blend. */
111
+ const statesRef = useRef(new Map());
112
+ const visualsRef = useRef(new Map());
113
+ /** When this terminal's foreground job was first seen, per body. */
114
+ const runningSinceRef = useRef(new Map());
115
+ /** When the newest frame landed, in this thread's clock. */
116
+ const frameAtRef = useRef(null);
117
+ const rendererRef = useRef(undefined);
118
+ const parametersRef = useRef(swarm);
119
+ const agentsRef = useRef(agents);
120
+ /** Which bodies the host has receded, and whether that is all of them; read by the render loop. */
121
+ const recedeRef = useRef({ ids: new Set(), every: false });
122
+ const modelsRef = useRef({ byId: new Map(), at: 0, agents: [] });
123
+ const themeRef = useRef(undefined);
124
+ const colourCacheRef = useRef(new Map());
125
+ const orderRef = useRef([]);
126
+ const arrivalCounterRef = useRef(0);
127
+ const dragRef = useRef(undefined);
128
+ const holdRef = useRef(undefined);
129
+ const holdTimerRef = useRef(undefined);
130
+ const focusedIdRef = useRef(undefined);
131
+ const hoveredIdRef = useRef(undefined);
132
+ const [hovered, setHovered] = useState(undefined);
133
+ const [cursor, setCursor] = useState('default');
134
+ const [failure, setFailure] = useState(undefined);
135
+ const newTerminalRef = useRef(null);
136
+ /** The keys door is focused from the keyboard: its echo shows where the bloom will open. */
137
+ const [newTerminalFocus, setNewTerminalFocus] = useState(false);
138
+ /** The signifier under a still pointer, and the stillness it waits on. */
139
+ const [signifier, setSignifier] = useState(undefined);
140
+ const signifierStillRef = useRef(undefined);
141
+ /** The field under a bloom — the veil, what it lights, its clearings — eased across frames. */
142
+ const fieldMemoryRef = useRef(bloomFieldMemory());
143
+ /** Births on their way: drawn where the person let go until the host's row takes over. */
144
+ const birthsRef = useRef([]);
145
+ const birthSeqRef = useRef(0);
146
+ const spawnMenuRef = useRef(spawnMenu);
147
+ spawnMenuRef.current = spawnMenu;
148
+ /** The stage as the host measured it last (MV-D19): the chrome's rectangles the physics keeps bodies off. */
149
+ const stageRef = useRef(stage);
150
+ stageRef.current = stage;
151
+ const motionRef = useRef(motionOn);
152
+ motionRef.current = motionOn;
153
+ const switchesRef = useRef({ animations: theme.animations, reducedMotion: theme.reducedMotion });
154
+ switchesRef.current = { animations: theme.animations, reducedMotion: theme.reducedMotion };
155
+ /** The ramp a bare terminal wears, for a birth's body. */
156
+ const neutralRef = useRef(palette.neutral);
157
+ neutralRef.current = palette.neutral;
158
+ const commandsRef = useRef(commands);
159
+ commandsRef.current = commands;
160
+ /** Where the keyboard's focus stands, from the view's own focus events (MV-W2); the bloom asks. */
161
+ const focusRef = useRef('none');
162
+ const loopRef = useRef(null);
163
+ /** Draws the field once where it stands: what a stopped loop shows. Set by the render effect. */
164
+ const stillDrawRef = useRef(null);
165
+ /** Re-reads the motion switches into the loop and the physics. Set by the render effect. */
166
+ const motionSyncRef = useRef(null);
167
+ /** Posts the physics' first world once the stage is measured. Set by the render effect. */
168
+ const initRef = useRef(null);
169
+ const initialisedRef = useRef(false);
170
+ /** The stage whose obstacles the physics holds. */
171
+ const stageSentRef = useRef(undefined);
172
+ // The spawn bloom (SB): with a spawn menu, a completed hold opens it instead of
173
+ // creating at once; without one, the hold creates at once as it always has.
174
+ const bloom = useSpawnBloom(spawnMenu, {
175
+ container: containerRef,
176
+ readChrome: () => stageRef.current.obstacles,
177
+ bodies: () => orderRef.current.map((body) => ({
178
+ x: body.x,
179
+ y: body.y,
180
+ r: body.radius,
181
+ scale: body.scale,
182
+ agent: agentById(body.model.id),
183
+ })),
184
+ idleRadius: () => parametersRef.current.radiusIdle,
185
+ motion: () => motionRef.current,
186
+ focus: () => focusRef.current,
187
+ createAt: (position, target) => target ? commandsRef.current.create(position, target) : commandsRef.current.create(position),
188
+ born: (choice, answer) => {
189
+ birthSeqRef.current += 1;
190
+ const record = {
191
+ birth: birthOf({
192
+ id: `spawn-bloom-birth-${birthSeqRef.current}`,
193
+ choice,
194
+ menu: spawnMenuRef.current,
195
+ idleRadius: parametersRef.current.radiusIdle,
196
+ field: {
197
+ width: containerRef.current?.clientWidth ?? 0,
198
+ height: containerRef.current?.clientHeight ?? 0,
199
+ },
200
+ now: performance.now(),
201
+ nowMs: Date.now(),
202
+ rows: agentsRef.current,
203
+ }),
204
+ seed: Math.random() * Math.PI * 2,
205
+ };
206
+ birthsRef.current = [...birthsRef.current, record];
207
+ // The host's answer starts the wait for its row; a refusal gives the birth up at once.
208
+ const settle = (patch) => {
209
+ if (birthsRef.current.includes(record))
210
+ record.birth = { ...record.birth, ...patch };
211
+ };
212
+ answer.then(({ opened }) => settle(opened ? { answeredAt: performance.now() } : { failedAt: performance.now() }), () => settle({ failedAt: performance.now() }));
213
+ },
214
+ });
215
+ const bloomRef = useRef(bloom);
216
+ bloomRef.current = bloom;
217
+ const blooming = bloom.state !== null && bloom.state.closed === null;
218
+ /** A bloom held open, or the keys door's, has the keyboard: the host's own keys stand aside (`report`). */
219
+ const holdsKeys = blooming && (bloom.state?.mode === 'keys' || bloom.state?.mode === 'sticky');
220
+ const keysHeldRef = useRef(false);
221
+ useEffect(() => {
222
+ agentsRef.current = agents;
223
+ recedeRef.current = {
224
+ ids: new Set(agents.filter((agent) => agent.receded).map(bodyIdOf)),
225
+ every: everyReceded(agents),
226
+ };
227
+ }, [agents]);
228
+ useEffect(() => {
229
+ parametersRef.current = swarm;
230
+ modelsRef.current.at = 0;
231
+ driverRef.current?.post({ type: 'updateParameters', parameters: physicsParameters(swarm) });
232
+ }, [swarm]);
233
+ // The palette arrives as CSS; the GPU wants numbers. Resolved here, once per
234
+ // theme, in the container's own cascade so any syntax the tokens use resolves.
235
+ useEffect(() => {
236
+ themeRef.current = resolveSwarmTheme(palette.swarm, containerRef.current ?? undefined, swarm);
237
+ colourCacheRef.current.clear();
238
+ // The chroma and the two grounds are resolved into the theme rather than sent
239
+ // as uniforms, so moving one of those three has to re-resolve it. The rest of
240
+ // the glow travels in the frame and needs nothing here — and naming them
241
+ // keeps a slider drag from clearing the colour cache every frame.
242
+ }, [palette, swarm.stateChroma, swarm.stateGroundDark, swarm.stateGroundLight]);
243
+ useEffect(() => {
244
+ if (keysHeldRef.current === holdsKeys)
245
+ return;
246
+ keysHeldRef.current = holdsKeys;
247
+ commands.report({ keysHeld: holdsKeys });
248
+ }, [commands, holdsKeys]);
249
+ const cancelHold = () => {
250
+ if (holdTimerRef.current !== undefined)
251
+ clearTimeout(holdTimerRef.current);
252
+ holdTimerRef.current = undefined;
253
+ holdRef.current = undefined;
254
+ };
255
+ useEffect(() => () => {
256
+ if (holdTimerRef.current !== undefined)
257
+ clearTimeout(holdTimerRef.current);
258
+ if (signifierStillRef.current)
259
+ clearTimeout(signifierStillRef.current.timer);
260
+ }, []);
261
+ /** The signifier: a pointer still over empty ground (`at`) learns what a hold does, the first
262
+ * few times per page load; any other place, or none, puts it away. Only with a spawn menu. */
263
+ const watchStill = (at) => {
264
+ const still = signifierStillRef.current;
265
+ if (still && at && Math.hypot(at.x - still.x, at.y - still.y) <= SIGNIFIER_SLOP)
266
+ return;
267
+ if (still)
268
+ clearTimeout(still.timer);
269
+ signifierStillRef.current = undefined;
270
+ setSignifier(undefined);
271
+ if (!at || !spawnMenu || signifiersShown >= SIGNIFIER_TIMES)
272
+ return;
273
+ const timer = setTimeout(() => {
274
+ if (signifiersShown >= SIGNIFIER_TIMES || holdRef.current || dragRef.current || bloomRef.current.isOpen())
275
+ return;
276
+ signifiersShown += 1;
277
+ setSignifier(at);
278
+ }, SIGNIFIER_STILL_MS);
279
+ signifierStillRef.current = { timer, x: at.x, y: at.y };
280
+ };
281
+ // The renderer: created once the canvas exists, rebuilt if the device is lost. What is
282
+ // drawing is reported, never written on the DOM for a host to read (W5).
283
+ useEffect(() => {
284
+ const canvas = canvasRef.current;
285
+ if (!canvas)
286
+ return;
287
+ let alive = true;
288
+ let current;
289
+ const start = async () => {
290
+ const result = await createSwarmRenderer(canvas);
291
+ if (!alive) {
292
+ if (result.ok)
293
+ result.renderer.destroy();
294
+ return;
295
+ }
296
+ if (!result.ok) {
297
+ setFailure(result.reason);
298
+ commandsRef.current.report({ renderer: 'unavailable' });
299
+ return;
300
+ }
301
+ current = result.renderer;
302
+ rendererRef.current = current;
303
+ setFailure(undefined);
304
+ commandsRef.current.report({ renderer: 'webgpu' });
305
+ const container = containerRef.current;
306
+ if (container)
307
+ current.resize(container.clientWidth, container.clientHeight, window.devicePixelRatio || 1);
308
+ void current.lost.then((info) => {
309
+ if (!alive || rendererRef.current !== current)
310
+ return;
311
+ console.warn('[swarm] WebGPU device lost, rebuilding', info.message);
312
+ rendererRef.current = undefined;
313
+ void start();
314
+ });
315
+ };
316
+ void start();
317
+ return () => {
318
+ alive = false;
319
+ rendererRef.current = undefined;
320
+ current?.destroy();
321
+ };
322
+ }, []);
323
+ /** A terminal born under a profile of the desktop you sit at names it, when there is more than one (SB §2.10). */
324
+ const terminalProfile = (agent) => agent.kind === 'agent' || !agent.device.self ? undefined : profileLineFor(spawnMenuRef.current, agent.profileSet);
325
+ // A new tree can change which terminals name their profile.
326
+ useEffect(() => {
327
+ modelsRef.current.at = 0;
328
+ }, [spawnMenu]);
329
+ /** The models every body draws from, rebuilt when the rows change or the clock says so. */
330
+ const refreshModels = (now) => {
331
+ const models = modelsRef.current;
332
+ const nowMs = Date.now();
333
+ const byId = new Map();
334
+ const shares = workingShares(agentsRef.current);
335
+ for (const agent of agentsRef.current) {
336
+ const runningSince = runningSinceRef.current.get(bodyIdOf(agent));
337
+ const profile = terminalProfile(agent);
338
+ byId.set(bodyIdOf(agent), bubbleModel({
339
+ agent,
340
+ parameters: parametersRef.current,
341
+ nowMs,
342
+ unread: agent.unread,
343
+ workingShare: shares.get(agent.id) ?? 0,
344
+ ...(runningSince === undefined ? {} : { runningSinceMs: runningSince }),
345
+ ...(profile ? { profile } : {}),
346
+ }));
347
+ }
348
+ models.byId = byId;
349
+ models.at = now;
350
+ models.agents = agentsRef.current;
351
+ };
352
+ /** The agents as the physics needs them: a body, the size to grow toward, where a creation gesture happened. */
353
+ const agentSpecs = () => agentsRef.current.map((agent) => {
354
+ const id = bodyIdOf(agent);
355
+ const model = modelsRef.current.byId.get(id);
356
+ const spec = { id, radius: model?.radius ?? parametersRef.current.radiusIdle };
357
+ if (agent.spawnHint)
358
+ spec.spawnHint = agent.spawnHint;
359
+ return spec;
360
+ });
361
+ useEffect(() => {
362
+ const container = containerRef.current;
363
+ if (!container)
364
+ return;
365
+ const applyTable = (event) => {
366
+ tableRef.current = { generation: event.generation, ids: event.ids };
367
+ const living = new Set(event.ids);
368
+ for (const id of [...statesRef.current.keys()]) {
369
+ if (living.has(id))
370
+ continue;
371
+ statesRef.current.delete(id);
372
+ visualsRef.current.delete(id);
373
+ if (dragRef.current?.id === id)
374
+ dragRef.current = undefined;
375
+ }
376
+ };
377
+ // The view's own physics (MV-D7): in the worker it brings, or in this thread where none can load.
378
+ const driver = createSwarmPhysicsDriver({
379
+ onEvent: (event) => {
380
+ if (event.type === 'idTable')
381
+ applyTable(event);
382
+ },
383
+ onFrame: (frame) => {
384
+ // READ, THEN RELEASE, and never the other way round: handing the buffer
385
+ // back transfers it, which detaches this thread's view of it, and a
386
+ // detached array reads as empty rather than throwing.
387
+ if (readSwarmFrame(frame, tableRef.current, statesRef.current))
388
+ frameAtRef.current = performance.now();
389
+ driver.post({ type: 'releaseFrame', buffer: frame }, [frame.buffer]);
390
+ },
391
+ onDemote: (reason) => console.warn('[swarm] the physics run in this thread:', reason),
392
+ onError: (detail) => console.warn('[swarm] the physics worker failed:', detail),
393
+ });
394
+ driverRef.current = driver;
395
+ // Where the simulation runs, to the host: `worker` or `inline`, and a demotion as it happens.
396
+ const stopMode = driver.observeMode((physics) => commandsRef.current.report({ physics }));
397
+ refreshModels(performance.now());
398
+ // The first world waits for a measured stage: a spawn keeps clear of the
399
+ // chrome (MV-D19), so the chrome's rectangles must be known when bodies are
400
+ // placed. The host measures within a frame of mounting the view; the stage
401
+ // effect below posts the world the moment they arrive.
402
+ const init = () => {
403
+ if (initialisedRef.current || !measured(stageRef.current))
404
+ return;
405
+ initialisedRef.current = true;
406
+ stageSentRef.current = stageRef.current;
407
+ driver.post({
408
+ type: 'init',
409
+ agents: agentSpecs(),
410
+ parameters: physicsParameters(parametersRef.current),
411
+ bounds: { width: container.clientWidth, height: container.clientHeight },
412
+ obstacles: stageRef.current.obstacles,
413
+ reducedMotion: switchesRef.current.reducedMotion,
414
+ });
415
+ };
416
+ initRef.current = init;
417
+ init();
418
+ let width = container.clientWidth;
419
+ let height = container.clientHeight;
420
+ const updateBounds = () => {
421
+ width = container.clientWidth;
422
+ height = container.clientHeight;
423
+ rendererRef.current?.resize(width, height, window.devicePixelRatio || 1);
424
+ driver.post({ type: 'updateBounds', bounds: { width, height } });
425
+ };
426
+ const resizeObserver = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(updateBounds);
427
+ resizeObserver?.observe(container);
428
+ const accentOf = (value) => {
429
+ const cached = colourCacheRef.current.get(value);
430
+ if (cached)
431
+ return cached;
432
+ const resolved = resolveCssColor(value, container);
433
+ colourCacheRef.current.set(value, resolved);
434
+ return resolved;
435
+ };
436
+ let dpr = window.devicePixelRatio || 1;
437
+ const started = performance.now();
438
+ const render = (time, deltaMs) => {
439
+ // The inline physics advance in the frame they are drawn in; a worker keeps its own clock.
440
+ driver.pump(time);
441
+ const delta = Math.min(1000 / 30, Math.max(1000 / 120, deltaMs));
442
+ const currentParameters = parametersRef.current;
443
+ const nextDpr = window.devicePixelRatio || 1;
444
+ if (nextDpr !== dpr) {
445
+ dpr = nextDpr;
446
+ rendererRef.current?.resize(width, height, dpr);
447
+ }
448
+ const models = modelsRef.current;
449
+ if (models.agents !== agentsRef.current || time - models.at >= MODEL_REFRESH_MS)
450
+ refreshModels(time);
451
+ // Age of the newest frame as a fraction of a step: the blend runs 0 → 1
452
+ // across the interval before the next one is due and holds at 1 if it
453
+ // is late, rather than extrapolating.
454
+ const stepMs = 1000 / Math.max(PHYSICS_HZ_FLOOR, currentParameters.physicsHz);
455
+ const arrivedAt = frameAtRef.current;
456
+ const alpha = arrivedAt === null ? 1 : Math.min(1, Math.max(0, (time - arrivedAt) / stepMs));
457
+ const dt = delta / 1000;
458
+ const renderer = rendererRef.current;
459
+ const theme = themeRef.current;
460
+ const motion = motionRef.current;
461
+ const focused = focusedIdRef.current;
462
+ const recede = recedeRef.current;
463
+ // The field under a bloom (SB §2.8): the veil, what the bloom lights above it, the clearings.
464
+ const bloomField = bloomRef.current.field();
465
+ const field = stepBloomField(fieldMemoryRef.current, {
466
+ state: bloomField.state,
467
+ closedAt: bloomField.closedAt,
468
+ now: time,
469
+ dtMs: delta,
470
+ reduced: !motion,
471
+ });
472
+ const rows = field.veil > 0 || fieldMemoryRef.current.lit.size > 0
473
+ ? new Map(agentsRef.current.map((agent) => [bodyIdOf(agent), agent]))
474
+ : undefined;
475
+ // A birth whose row has arrived: the row takes over where the birth stood.
476
+ const takeovers = new Map();
477
+ for (const record of birthsRef.current) {
478
+ const row = birthRow(record.birth, agentsRef.current);
479
+ if (row)
480
+ takeovers.set(bodyIdOf(row), record);
481
+ }
482
+ const bodies = [];
483
+ for (const [id, state] of statesRef.current) {
484
+ const model = models.byId.get(id);
485
+ if (!model)
486
+ continue;
487
+ // A receded body stays in the physics and only fades: the host is
488
+ // showing another group, and this one keeps its place for when it returns.
489
+ const recedeTo = recedeTarget(recede.ids.has(id), recede.every);
490
+ let visual = visualsRef.current.get(id);
491
+ if (!visual) {
492
+ arrivalCounterRef.current += 1;
493
+ // The host's row for a birth continues the birth's own arrival: no second one.
494
+ const born = takeovers.get(id);
495
+ visual = {
496
+ visualRadius: model.radius,
497
+ visualVelocity: 0,
498
+ spawnedAt: born ? born.birth.bornAt : time,
499
+ seed: born ? born.seed : Math.random() * Math.PI * 2,
500
+ arrival: arrivalCounterRef.current,
501
+ recede: recedeTo,
502
+ ...(born ? { from: born.birth.from, aboveUntil: born.birth.bornAt + SPAWN_DURATION_MS + 400 } : {}),
503
+ };
504
+ visualsRef.current.set(id, visual);
505
+ if (born)
506
+ birthsRef.current = birthsRef.current.filter((record) => record !== born);
507
+ }
508
+ visual.recede = motion ? approachRecede(visual.recede, recedeTo, delta) : recedeTo;
509
+ if (motion) {
510
+ // The visual radius follows the model's on a critically damped spring;
511
+ // the physics body already jumped (the frame carries its radius).
512
+ const displacement = visual.visualRadius - model.radius;
513
+ visual.visualVelocity +=
514
+ (-RADIUS_SPRING_OMEGA * RADIUS_SPRING_OMEGA * displacement -
515
+ 2 * RADIUS_SPRING_OMEGA * visual.visualVelocity) *
516
+ dt;
517
+ visual.visualRadius += visual.visualVelocity * dt;
518
+ if (Math.abs(visual.visualRadius - model.radius) < 0.01 && Math.abs(visual.visualVelocity) < 0.01) {
519
+ visual.visualRadius = model.radius;
520
+ visual.visualVelocity = 0;
521
+ }
522
+ }
523
+ else {
524
+ // Still: a body is drawn at its size, with no spring to run.
525
+ visual.visualRadius = model.radius;
526
+ visual.visualVelocity = 0;
527
+ }
528
+ const landing = motion
529
+ ? visual.from
530
+ ? arrivalFrom(time - visual.spawnedAt, visual.from, SPAWN_DURATION_MS)
531
+ : arrival(time - visual.spawnedAt)
532
+ : { scale: 1, opacity: 1 };
533
+ // Being born, it is drawn above the clearings and under no veil; the rest of the
534
+ // field recedes under the veil but for what the bloom points at.
535
+ const above = visual.aboveUntil !== undefined && time < visual.aboveUntil;
536
+ let opacity = landing.opacity * visual.recede;
537
+ if (rows && !above) {
538
+ const row = rows.get(id);
539
+ const lit = stepLit(fieldMemoryRef.current, id, row ? field.lit(row) : false, delta, !motion);
540
+ opacity = veiledOpacity(opacity, field.veil, lit);
541
+ }
542
+ bodies.push({
543
+ model,
544
+ x: state.previousX + (state.x - state.previousX) * alpha,
545
+ y: state.previousY + (state.y - state.previousY) * alpha,
546
+ radius: visual.visualRadius,
547
+ scale: landing.scale,
548
+ opacity,
549
+ focus: focused === id,
550
+ seed: visual.seed,
551
+ accent: accentOf(model.accent),
552
+ ...(model.linked ? { link: accentOf(model.linked) } : {}),
553
+ ...(above ? { aboveClearings: true } : {}),
554
+ });
555
+ }
556
+ bodies.sort((left, right) => {
557
+ const rank = STATUS_RANK[left.model.appearance] - STATUS_RANK[right.model.appearance];
558
+ if (rank !== 0)
559
+ return rank;
560
+ return ((visualsRef.current.get(left.model.id)?.arrival ?? 0) - (visualsRef.current.get(right.model.id)?.arrival ?? 0));
561
+ });
562
+ orderRef.current = bodies;
563
+ // Births on their way: hollow where the person let go, above the clearings, their model
564
+ // rebuilt every frame so OPENING lands the moment the quiet runs out; given up, they shrink away.
565
+ const births = [];
566
+ birthsRef.current = birthsRef.current.filter((record) => {
567
+ if (birthOverdue(record.birth, time))
568
+ record.birth = { ...record.birth, failedAt: time };
569
+ const birth = record.birth;
570
+ if (birth.failedAt !== null && time - birth.failedAt >= BLOOM.retract)
571
+ return false;
572
+ const model = bubbleModel({
573
+ agent: birthAgent(birth, neutralRef.current),
574
+ parameters: currentParameters,
575
+ nowMs: Date.now(),
576
+ unread: false,
577
+ workingShare: 0,
578
+ opening: { sinceMs: birth.sinceMs, on: birth.on },
579
+ ...(birth.profile ? { profile: birth.profile } : {}),
580
+ });
581
+ const land = motion
582
+ ? arrivalFrom(time - birth.bornAt, birth.from, SPAWN_DURATION_MS)
583
+ : { scale: 1, opacity: 1 };
584
+ const gone = birth.failedAt === null
585
+ ? { scale: 1, opacity: 1 }
586
+ : motion
587
+ ? departure(time - birth.failedAt)
588
+ : { scale: 0, opacity: 0 };
589
+ births.push({
590
+ model,
591
+ x: birth.drawAt.x,
592
+ y: birth.drawAt.y,
593
+ radius: model.radius,
594
+ scale: land.scale * gone.scale,
595
+ opacity: land.opacity * gone.opacity,
596
+ focus: false,
597
+ seed: record.seed,
598
+ accent: accentOf(model.accent),
599
+ aboveClearings: true,
600
+ });
601
+ return true;
602
+ });
603
+ if (!renderer || !theme)
604
+ return;
605
+ const hold = holdRef.current;
606
+ // The spawn bloom's hub: the hold ring kept at full size while the bloom is open.
607
+ const hub = hold ? undefined : bloomRef.current.hub(time);
608
+ renderer.render({
609
+ time: (time - started) / 1000,
610
+ motion,
611
+ fillOpacity: currentParameters.bubbleFillOpacity,
612
+ gridPitch: GRID_PITCH,
613
+ glow: {
614
+ reach: currentParameters.glowReach,
615
+ strength: currentParameters.glowStrength,
616
+ breath: currentParameters.glowBreath,
617
+ },
618
+ stateGlow: {
619
+ inner: currentParameters.stateGlowInner,
620
+ full: currentParameters.stateGlowFull,
621
+ strength: currentParameters.stateGlowStrength,
622
+ count: currentParameters.stateWaveCount,
623
+ speed: currentParameters.stateWaveSpeed,
624
+ depth: currentParameters.stateWaveDepth,
625
+ },
626
+ theme,
627
+ bodies: births.length > 0 ? [...bodies, ...births] : bodies,
628
+ ...(field.veil > 0 ? { veil: field.veil } : {}),
629
+ ...(field.clearings.length > 0
630
+ ? {
631
+ clearings: field.clearings
632
+ .slice(0, MAX_CLEARINGS)
633
+ .map((cleared) => ({ ...cleared.clearing, opacity: cleared.opacity })),
634
+ }
635
+ : {}),
636
+ ...(hold
637
+ ? { hold: { x: hold.x, y: hold.y, progress: (time - hold.startedAt) / LONG_PRESS_DURATION_MS } }
638
+ : hub
639
+ ? { hold: hub }
640
+ : {}),
641
+ });
642
+ };
643
+ // The toolkit's loop: the display's frames while motion is on, no frame at all while it is off (MV-W4). The
644
+ // physics pause with it and start again fresh, so the time held still is never stepped through.
645
+ const loop = createMotionLoop(render, switchesRef.current);
646
+ loopRef.current = loop;
647
+ let running = loop.running;
648
+ if (!running)
649
+ driver.post({ type: 'pause' });
650
+ const syncMotion = () => {
651
+ loop.update(switchesRef.current);
652
+ if (loop.running === running)
653
+ return;
654
+ running = loop.running;
655
+ driver.post({ type: running ? 'resume' : 'pause' });
656
+ };
657
+ const still = () => {
658
+ if (!loop.running)
659
+ render(performance.now(), 0);
660
+ };
661
+ motionSyncRef.current = () => {
662
+ syncMotion();
663
+ still();
664
+ };
665
+ stillDrawRef.current = still;
666
+ return () => {
667
+ loop.dispose();
668
+ loopRef.current = null;
669
+ stillDrawRef.current = null;
670
+ motionSyncRef.current = null;
671
+ initRef.current = null;
672
+ resizeObserver?.disconnect();
673
+ statesRef.current.clear();
674
+ visualsRef.current.clear();
675
+ orderRef.current = [];
676
+ // Both halves, in order: the host tears its engine down and stops its
677
+ // timer, then the thread (if any) goes. A closed stage runs no physics.
678
+ driver.post({ type: 'dispose' });
679
+ stopMode();
680
+ driver.dispose();
681
+ driverRef.current = undefined;
682
+ frameAtRef.current = null;
683
+ tableRef.current = { generation: -1, ids: [] };
684
+ initialisedRef.current = false;
685
+ stageSentRef.current = undefined;
686
+ };
687
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- the driver, the loop and the renderer live for the stage's life
688
+ }, []);
689
+ useEffect(() => {
690
+ const nowMs = Date.now();
691
+ const ids = new Set(agents.map(bodyIdOf));
692
+ for (const id of [...runningSinceRef.current.keys()])
693
+ if (!ids.has(id))
694
+ runningSinceRef.current.delete(id);
695
+ const shares = workingShares(agents);
696
+ for (const agent of agents) {
697
+ const id = bodyIdOf(agent);
698
+ const model = bubbleModel({
699
+ agent,
700
+ parameters: swarm,
701
+ nowMs,
702
+ unread: agent.unread,
703
+ workingShare: shares.get(agent.id) ?? 0,
704
+ });
705
+ // The clock starts at the first sight of a foreground job and survives
706
+ // an `unknown` observation; only the shell's idle prompt, or an agent
707
+ // claiming the terminal, stops it.
708
+ if (model.state === 'terminal-running') {
709
+ if (!runningSinceRef.current.has(id))
710
+ runningSinceRef.current.set(id, nowMs);
711
+ }
712
+ else if (agent.kind === 'agent' || agent.activity?.kind !== 'unknown') {
713
+ runningSinceRef.current.delete(id);
714
+ }
715
+ }
716
+ modelsRef.current.at = 0;
717
+ refreshModels(performance.now());
718
+ driverRef.current?.post({ type: 'updateAgents', agents: agentSpecs() });
719
+ }, [agents, swarm]);
720
+ // The host's chrome moved (MV-D19): the physics keep bodies off its new rectangles. Until the stage is
721
+ // measured, this is where the first world waits.
722
+ useEffect(() => {
723
+ const driver = driverRef.current;
724
+ if (!driver)
725
+ return;
726
+ if (!initialisedRef.current) {
727
+ initRef.current?.();
728
+ return;
729
+ }
730
+ if (stageSentRef.current === stage)
731
+ return;
732
+ stageSentRef.current = stage;
733
+ driver.post({ type: 'updateObstacles', obstacles: stage.obstacles });
734
+ }, [stage]);
735
+ // The host's animations switch and the reduced-motion preference start or stop the loop (and the physics with
736
+ // it); stopped, every change the field shows is drawn once where it stands.
737
+ useEffect(() => {
738
+ motionSyncRef.current?.();
739
+ }, [theme.animations, theme.reducedMotion]);
740
+ useEffect(() => {
741
+ if (loopRef.current && !loopRef.current.running)
742
+ stillDrawRef.current?.();
743
+ }, [agents, palette, swarm, stage, spawnMenu]);
744
+ const localPoint = (event) => {
745
+ const bounds = containerRef.current?.getBoundingClientRect();
746
+ if (!bounds)
747
+ return undefined;
748
+ return { x: event.clientX - bounds.left, y: event.clientY - bounds.top };
749
+ };
750
+ /** The topmost body under the point, in draw order. */
751
+ const hitTest = (x, y) => {
752
+ const order = orderRef.current;
753
+ for (let index = order.length - 1; index >= 0; index -= 1) {
754
+ const candidate = order[index];
755
+ if (Math.hypot(x - candidate.x, y - candidate.y) <= candidate.radius * candidate.scale)
756
+ return candidate;
757
+ }
758
+ return undefined;
759
+ };
760
+ const agentById = (id) => agentsRef.current.find((agent) => bodyIdOf(agent) === id);
761
+ const endDrag = () => {
762
+ const drag = dragRef.current;
763
+ if (!drag)
764
+ return;
765
+ driverRef.current?.post({ type: 'dragEnd', id: drag.id });
766
+ dragRef.current = undefined;
767
+ };
768
+ const updateHover = (id, x, y) => {
769
+ if (id === hoveredIdRef.current) {
770
+ if (id)
771
+ setHovered((current) => (current ? { ...current, x, y } : current));
772
+ return;
773
+ }
774
+ hoveredIdRef.current = id;
775
+ const agent = id ? agentById(id) : undefined;
776
+ setHovered(agent ? { agent, x, y } : undefined);
777
+ setCursor(agent ? 'grab' : 'default');
778
+ };
779
+ const onPointerDown = (event) => {
780
+ watchStill(undefined);
781
+ // A bloom held open takes the press: a primary click commits, any other button puts it away.
782
+ if (bloom.pointerDown(event, localPoint(event)))
783
+ return;
784
+ if (event.button !== 0)
785
+ return;
786
+ const point = localPoint(event);
787
+ if (!point)
788
+ return;
789
+ cancelHold();
790
+ const hit = hitTest(point.x, point.y);
791
+ if (hit) {
792
+ endDrag();
793
+ driverRef.current?.post({ type: 'dragStart', id: hit.model.id, point });
794
+ dragRef.current = {
795
+ id: hit.model.id,
796
+ pointerId: event.pointerId,
797
+ startX: point.x,
798
+ startY: point.y,
799
+ dragged: false,
800
+ };
801
+ event.currentTarget.setPointerCapture(event.pointerId);
802
+ setCursor('grabbing');
803
+ setHovered(undefined);
804
+ event.preventDefault();
805
+ return;
806
+ }
807
+ // Empty field: hold to create a terminal here.
808
+ const hold = {
809
+ pointerId: event.pointerId,
810
+ clientX: event.clientX,
811
+ clientY: event.clientY,
812
+ x: point.x,
813
+ y: point.y,
814
+ startedAt: performance.now(),
815
+ };
816
+ holdRef.current = hold;
817
+ event.currentTarget.setPointerCapture(event.pointerId);
818
+ holdTimerRef.current = setTimeout(() => {
819
+ if (holdRef.current !== hold)
820
+ return;
821
+ holdTimerRef.current = undefined;
822
+ holdRef.current = undefined;
823
+ // With a spawn menu the hold blooms and keeps the pointer; without one it creates here, now.
824
+ bloomRef.current.held({ x: hold.x, y: hold.y }, hold.pointerId);
825
+ }, LONG_PRESS_DURATION_MS);
826
+ };
827
+ const onPointerMove = (event) => {
828
+ const point = localPoint(event);
829
+ if (!point)
830
+ return;
831
+ const drag = dragRef.current;
832
+ if (drag && drag.pointerId === event.pointerId) {
833
+ if (Math.hypot(point.x - drag.startX, point.y - drag.startY) >= 5)
834
+ drag.dragged = true;
835
+ driverRef.current?.post({ type: 'dragMove', id: drag.id, point });
836
+ return;
837
+ }
838
+ if (bloom.pointerMove(event, point))
839
+ return;
840
+ const hold = holdRef.current;
841
+ if (hold && hold.pointerId === event.pointerId) {
842
+ if (Math.hypot(event.clientX - hold.clientX, event.clientY - hold.clientY) > LONG_PRESS_MOVE_TOLERANCE)
843
+ cancelHold();
844
+ return;
845
+ }
846
+ const hit = hitTest(point.x, point.y);
847
+ updateHover(hit?.model.id, point.x, point.y);
848
+ watchStill(hit ? undefined : point);
849
+ };
850
+ const onPointerUp = (event) => {
851
+ const point = localPoint(event);
852
+ // A hold's bloom commits where it is let go.
853
+ if (bloom.pointerUp(event, point)) {
854
+ if (event.currentTarget.hasPointerCapture(event.pointerId))
855
+ event.currentTarget.releasePointerCapture(event.pointerId);
856
+ return;
857
+ }
858
+ const drag = dragRef.current;
859
+ if (drag && drag.pointerId === event.pointerId) {
860
+ if (point)
861
+ driverRef.current?.post({ type: 'dragMove', id: drag.id, point });
862
+ const wasDragged = drag.dragged;
863
+ const id = drag.id;
864
+ endDrag();
865
+ if (!wasDragged) {
866
+ const agent = agentById(id);
867
+ if (agent)
868
+ commands.select(agent.id);
869
+ driverRef.current?.post({ type: 'nudge', id });
870
+ }
871
+ setCursor(point && hitTest(point.x, point.y) ? 'grab' : 'default');
872
+ }
873
+ if (holdRef.current?.pointerId === event.pointerId)
874
+ cancelHold();
875
+ if (event.currentTarget.hasPointerCapture(event.pointerId))
876
+ event.currentTarget.releasePointerCapture(event.pointerId);
877
+ };
878
+ const onPointerCancel = (event) => {
879
+ bloom.pointerCancel(event);
880
+ if (dragRef.current?.pointerId === event.pointerId)
881
+ endDrag();
882
+ if (holdRef.current?.pointerId === event.pointerId)
883
+ cancelHold();
884
+ setCursor('default');
885
+ };
886
+ const onPointerLeave = () => {
887
+ watchStill(undefined);
888
+ if (dragRef.current)
889
+ return;
890
+ updateHover(undefined, 0, 0);
891
+ };
892
+ /** A secondary click on empty ground holds a bloom open (SB-D12); on an open one, puts it away. */
893
+ const onContextMenu = (event) => {
894
+ if (!spawnMenu)
895
+ return;
896
+ watchStill(undefined);
897
+ const point = localPoint(event);
898
+ const blocked = !point || !!dragRef.current || !!hitTest(point.x, point.y);
899
+ if (!blocked && !bloom.isOpen())
900
+ cancelHold();
901
+ bloom.contextMenu(event, point, blocked);
902
+ };
903
+ // Where the keyboard's focus stands, from the view's own focus events (MV-W2): the bloom's menu, the field
904
+ // itself, one of the view's controls, or beyond the view (somewhere, or nowhere the view can see).
905
+ const onFocus = (event) => {
906
+ const target = event.target;
907
+ const menu = bloom.menuRef.current;
908
+ if (menu && (target === menu || menu.contains(target))) {
909
+ focusRef.current = 'menu';
910
+ bloom.focusEntered(event.relatedTarget);
911
+ }
912
+ else {
913
+ focusRef.current = target === event.currentTarget ? 'field' : 'control';
914
+ }
915
+ };
916
+ const onBlur = (event) => {
917
+ const next = event.relatedTarget;
918
+ if (next instanceof Node && event.currentTarget.contains(next))
919
+ return;
920
+ focusRef.current = next ? 'outside' : 'none';
921
+ };
922
+ /** The field is focusable (MV-D8) so a hold's ⎋ is heard here, on the view, never on the window. */
923
+ const onKeyDown = (event) => {
924
+ bloom.fieldKeyDown(event);
925
+ };
926
+ const modelFor = (agent) => {
927
+ const known = modelsRef.current.byId.get(bodyIdOf(agent));
928
+ if (known)
929
+ return known;
930
+ const profile = terminalProfile(agent);
931
+ return bubbleModel({
932
+ agent,
933
+ parameters: swarm,
934
+ nowMs: Date.now(),
935
+ unread: agent.unread,
936
+ workingShare: workingShares(agentsRef.current).get(agent.id) ?? 0,
937
+ ...(profile ? { profile } : {}),
938
+ });
939
+ };
940
+ // The view's own properties (L18): the two palette colours its stylesheets draw with — the monitor's ground
941
+ // behind the bloom's words and the signifier's halo, and the orange of the bloom's waiting dot.
942
+ const style = {
943
+ cursor,
944
+ '--mv-swarm-orange': palette.swarm.orange,
945
+ };
946
+ const className = [
947
+ 'vf-monitor-swarm',
948
+ blooming ? 'is-blooming' : '',
949
+ theme.scheme === 'dark' ? 'is-dark' : '',
950
+ motionOn ? '' : 'is-still',
951
+ ]
952
+ .filter(Boolean)
953
+ .join(' ');
954
+ return (_jsxs("section", { ref: containerRef, className: className, style: style, tabIndex: -1, "aria-label": "Running agent status field", onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerCancel, onLostPointerCapture: (event) => bloom.pointerCancel(event), onPointerLeave: onPointerLeave, onContextMenu: spawnMenu ? onContextMenu : undefined, children: [_jsx("canvas", { ref: canvasRef, className: "vf-monitor-swarm-canvas", "aria-hidden": "true" }), failure ? (_jsxs("div", { className: "vf-monitor-swarm-empty", role: "status", children: [_jsx("span", { children: "WEBGPU UNAVAILABLE" }), _jsx("small", { children: failure })] })) : agents.length === 0 ? (_jsxs("div", { className: "vf-monitor-swarm-empty", children: [_jsx("span", { children: "NO ACTIVE AGENTS" }), _jsx("small", { children: "Launch an agent from a terminal pane." }), spawnMenu ? _jsx("small", { children: "Hold empty ground for a terminal." }) : null] })) : null, spawnMenu ? (_jsx(SpawnBloom, { state: bloom.state, reduced: bloom.reduced, menuRef: bloom.menuRef, onKeyDown: bloom.onKeyDown, onBlur: bloom.onBlur })) : null, signifier && !blooming ? (_jsx("span", { className: "vf-monitor-swarm-signifier", style: { left: signifier.x, top: signifier.y }, "aria-hidden": "true", children: "Hold for a terminal" })) : null, newTerminalFocus && !blooming ? (
955
+ // The keys door has the keyboard: say so where its bloom will open.
956
+ _jsx("span", { className: "vf-monitor-swarm-new-echo", "aria-hidden": "true", children: "\uFF0B New terminal\u2026" })) : null, hovered ? (_jsx("span", { className: "vf-monitor-swarm-tooltip", style: { left: hovered.x, top: hovered.y }, role: "tooltip", "aria-hidden": "true", children: modelFor(hovered.agent).title })) : null, _jsxs("ul", { className: "vf-monitor-swarm-list", "aria-label": "Agents", children: [spawnMenu ? (
957
+ // The keys door (SB §2.11): a bloom at the field's middle with the keyboard in it.
958
+ _jsx("li", { children: _jsx("button", { ref: newTerminalRef, type: "button", "aria-haspopup": "menu", "aria-expanded": blooming && bloom.state?.mode === 'keys', "data-swarm-new-terminal": "", onFocus: (event) => setNewTerminalFocus(focusVisible(event.currentTarget)), onBlur: () => setNewTerminalFocus(false), onClick: () => bloom.openKeys(newTerminalRef.current), children: "\uFF0B New terminal\u2026" }) })) : null, agents.map((agent) => {
959
+ const model = modelFor(agent);
960
+ const bodyId = bodyIdOf(agent);
961
+ return (_jsx("li", { children: _jsx("button", { type: "button", "aria-label": model.ariaLabel, "aria-current": agent.active ? 'true' : undefined, "data-agent-bubble-id": bodyId, "data-agent-bubble-status": agent.status, "data-agent-bubble-visual": model.state, "data-agent-bubble-source": !agent.device.self ? 'remote' : agent.kind === 'agent' ? 'agent' : 'terminal', "data-agent-bubble-receded": agent.receded ? 'true' : undefined, onFocus: () => {
962
+ focusedIdRef.current = bodyId;
963
+ }, onBlur: () => {
964
+ if (focusedIdRef.current === bodyId)
965
+ focusedIdRef.current = undefined;
966
+ }, onClick: () => commands.select(agent.id), children: model.title }) }, bodyId));
967
+ })] })] }));
968
+ }
969
+ //# sourceMappingURL=AgentSwarm.js.map