@sixb/app 0.2.0 → 0.2.3

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 (469) hide show
  1. package/assets/connector-icons/README.md +1 -0
  2. package/assets/connector-icons/fleetio.ico +0 -0
  3. package/dist/agent/activity-label.d.ts.map +1 -1
  4. package/dist/agent/agent-chat.d.ts +9 -2
  5. package/dist/agent/agent-chat.d.ts.map +1 -1
  6. package/dist/agent/agent-panel.d.ts +9 -1
  7. package/dist/agent/agent-panel.d.ts.map +1 -1
  8. package/dist/agent/agent-surface.d.ts.map +1 -1
  9. package/dist/agent/artifact-card.d.ts +3 -1
  10. package/dist/agent/artifact-card.d.ts.map +1 -1
  11. package/dist/agent/artifact-panel.d.ts +7 -1
  12. package/dist/agent/artifact-panel.d.ts.map +1 -1
  13. package/dist/agent/background/background-card.d.ts +10 -0
  14. package/dist/agent/background/background-card.d.ts.map +1 -0
  15. package/dist/agent/background/background-tool-row.d.ts +9 -0
  16. package/dist/agent/background/background-tool-row.d.ts.map +1 -0
  17. package/dist/agent/background/context.d.ts +23 -0
  18. package/dist/agent/background/context.d.ts.map +1 -0
  19. package/dist/agent/background/interpret.d.ts +116 -0
  20. package/dist/agent/background/interpret.d.ts.map +1 -0
  21. package/dist/agent/bash/bash-tool-view.d.ts.map +1 -1
  22. package/dist/agent/bash/interpret.d.ts +4 -0
  23. package/dist/agent/bash/interpret.d.ts.map +1 -1
  24. package/dist/agent/components/composer-menu.d.ts +3 -1
  25. package/dist/agent/components/composer-menu.d.ts.map +1 -1
  26. package/dist/agent/components/composer-place.d.ts +13 -0
  27. package/dist/agent/components/composer-place.d.ts.map +1 -0
  28. package/dist/agent/components/composer.d.ts +23 -1
  29. package/dist/agent/components/composer.d.ts.map +1 -1
  30. package/dist/agent/components/computer-place.d.ts +3 -1
  31. package/dist/agent/components/computer-place.d.ts.map +1 -1
  32. package/dist/agent/components/context-chips.d.ts.map +1 -1
  33. package/dist/agent/components/context-meter.d.ts +1 -1
  34. package/dist/agent/components/conversation-panel.d.ts +3 -1
  35. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  36. package/dist/agent/components/message-parts.d.ts +3 -1
  37. package/dist/agent/components/message-parts.d.ts.map +1 -1
  38. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
  39. package/dist/agent/components/transcript.d.ts +6 -0
  40. package/dist/agent/components/transcript.d.ts.map +1 -1
  41. package/dist/agent/components/web-fetch-tool-view.d.ts.map +1 -1
  42. package/dist/agent/composer-insertion.d.ts +24 -0
  43. package/dist/agent/composer-insertion.d.ts.map +1 -0
  44. package/dist/agent/delegation/child-parts.d.ts +2 -0
  45. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  46. package/dist/agent/delegation/use-children.d.ts +5 -5
  47. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  48. package/dist/agent/hooks/use-agent-conversation.d.ts +24 -4
  49. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  50. package/dist/agent/hooks/use-new-thread-place.d.ts +70 -0
  51. package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -0
  52. package/dist/agent/hooks/use-thread-lists.d.ts +40 -0
  53. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  54. package/dist/agent/i18n/en.d.ts +74 -0
  55. package/dist/agent/i18n/en.d.ts.map +1 -1
  56. package/dist/agent/i18n/fr.d.ts.map +1 -1
  57. package/dist/agent/i18n/index.d.ts +126 -0
  58. package/dist/agent/i18n/index.d.ts.map +1 -1
  59. package/dist/agent/observed-conversation.d.ts.map +1 -1
  60. package/dist/agent/publish-artifact/interpret.d.ts +8 -2
  61. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  62. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
  63. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
  64. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
  65. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
  66. package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
  67. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
  68. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  69. package/dist/agent/types.d.ts +3 -1
  70. package/dist/agent/types.d.ts.map +1 -1
  71. package/dist/agent/utils/web-fetch.d.ts +33 -1
  72. package/dist/agent/utils/web-fetch.d.ts.map +1 -1
  73. package/dist/agent/utils/web-search.d.ts +14 -2
  74. package/dist/agent/utils/web-search.d.ts.map +1 -1
  75. package/dist/artifacts/artifact-page.d.ts.map +1 -1
  76. package/dist/artifacts/artifact-viewer.d.ts +16 -0
  77. package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
  78. package/dist/artifacts/card-details.d.ts +1 -1
  79. package/dist/artifacts/card-details.d.ts.map +1 -1
  80. package/dist/artifacts/card-preview.d.ts.map +1 -1
  81. package/dist/artifacts/comments-context.d.ts +48 -0
  82. package/dist/artifacts/comments-context.d.ts.map +1 -0
  83. package/dist/artifacts/edit-session.d.ts +6 -6
  84. package/dist/artifacts/edit-session.d.ts.map +1 -1
  85. package/dist/artifacts/file-source.d.ts.map +1 -1
  86. package/dist/artifacts/frame.d.ts +10 -2
  87. package/dist/artifacts/frame.d.ts.map +1 -1
  88. package/dist/artifacts/guest-badge.d.ts +8 -0
  89. package/dist/artifacts/guest-badge.d.ts.map +1 -0
  90. package/dist/artifacts/held-artifact.d.ts +19 -0
  91. package/dist/artifacts/held-artifact.d.ts.map +1 -0
  92. package/dist/artifacts/holders.d.ts +10 -0
  93. package/dist/artifacts/holders.d.ts.map +1 -0
  94. package/dist/artifacts/live/boards.d.ts +15 -0
  95. package/dist/artifacts/live/boards.d.ts.map +1 -0
  96. package/dist/artifacts/live/canvas.d.ts +79 -0
  97. package/dist/artifacts/live/canvas.d.ts.map +1 -0
  98. package/dist/artifacts/live/header.d.ts +29 -0
  99. package/dist/artifacts/live/header.d.ts.map +1 -0
  100. package/dist/artifacts/live/hooks.d.ts +21 -0
  101. package/dist/artifacts/live/hooks.d.ts.map +1 -0
  102. package/dist/artifacts/live/presence.d.ts +32 -0
  103. package/dist/artifacts/live/presence.d.ts.map +1 -0
  104. package/dist/artifacts/live/session.d.ts +130 -0
  105. package/dist/artifacts/live/session.d.ts.map +1 -0
  106. package/dist/artifacts/live/view.d.ts +28 -0
  107. package/dist/artifacts/live/view.d.ts.map +1 -0
  108. package/dist/artifacts/messages.d.ts +424 -14
  109. package/dist/artifacts/messages.d.ts.map +1 -1
  110. package/dist/artifacts/page-queries.d.ts +2 -2
  111. package/dist/artifacts/page-queries.d.ts.map +1 -1
  112. package/dist/artifacts/page-state.d.ts.map +1 -1
  113. package/dist/artifacts/publish-edit.d.ts +24 -14
  114. package/dist/artifacts/publish-edit.d.ts.map +1 -1
  115. package/dist/artifacts/queries.d.ts +490 -9
  116. package/dist/artifacts/queries.d.ts.map +1 -1
  117. package/dist/artifacts/references/references.d.ts.map +1 -1
  118. package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
  119. package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
  120. package/dist/artifacts/renderers/canvas/board-editor.d.ts +43 -0
  121. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
  122. package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
  123. package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
  124. package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
  125. package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
  126. package/dist/artifacts/renderers/canvas/board.d.ts +64 -19
  127. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  128. package/dist/artifacts/renderers/canvas/canvas.d.ts +13 -4
  129. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  130. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
  131. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
  132. package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
  133. package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
  134. package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
  135. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
  136. package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
  137. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
  138. package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
  139. package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
  140. package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
  141. package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
  142. package/dist/artifacts/renderers/canvas/focus.d.ts +40 -5
  143. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  144. package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
  145. package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
  146. package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
  147. package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
  148. package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
  149. package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
  150. package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
  151. package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
  152. package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
  153. package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
  154. package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
  155. package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
  156. package/dist/artifacts/version-menu.d.ts +19 -0
  157. package/dist/artifacts/version-menu.d.ts.map +1 -0
  158. package/dist/artifacts/view-context.d.ts +43 -0
  159. package/dist/artifacts/view-context.d.ts.map +1 -0
  160. package/dist/artifacts/viewer.d.ts.map +1 -1
  161. package/dist/build.d.ts +5 -0
  162. package/dist/build.d.ts.map +1 -1
  163. package/dist/{chunk-fw2bm6dq.js → chunk-001c4gnk.js} +8086 -3870
  164. package/dist/chunk-001c4gnk.js.map +204 -0
  165. package/dist/chunk-00wggsst.js +7 -0
  166. package/dist/chunk-00wggsst.js.map +10 -0
  167. package/dist/chunk-5crvhjp2.js +4704 -0
  168. package/dist/chunk-5crvhjp2.js.map +28 -0
  169. package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
  170. package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
  171. package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
  172. package/dist/chunk-fg6thecb.js.map +10 -0
  173. package/dist/{chunk-j9653e83.js → chunk-fwb9mxwm.js} +1 -1
  174. package/dist/{chunk-km25essq.js → chunk-kes4ygmz.js} +1 -1
  175. package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
  176. package/dist/codegen.d.ts.map +1 -1
  177. package/dist/createCustomApp.d.ts.map +1 -1
  178. package/dist/index.d.ts +7 -1
  179. package/dist/index.d.ts.map +1 -1
  180. package/dist/index.js +930 -309
  181. package/dist/index.js.map +15 -10
  182. package/dist/locale-messages.d.ts +12 -0
  183. package/dist/locale-messages.d.ts.map +1 -1
  184. package/dist/locale.d.ts +12 -0
  185. package/dist/locale.d.ts.map +1 -1
  186. package/dist/locale.js +1 -1
  187. package/dist/metadata.d.ts +8 -0
  188. package/dist/metadata.d.ts.map +1 -1
  189. package/dist/pages/console/action-run.d.ts.map +1 -1
  190. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  191. package/dist/pages/console/data/datasets.d.ts.map +1 -1
  192. package/dist/pages/console/data/lake-health.d.ts +3 -0
  193. package/dist/pages/console/data/lake-health.d.ts.map +1 -0
  194. package/dist/pages/console/data/messages.d.ts +98 -2
  195. package/dist/pages/console/data/messages.d.ts.map +1 -1
  196. package/dist/pages/console/data/pipelines.d.ts.map +1 -1
  197. package/dist/pages/console/data/projections.d.ts.map +1 -1
  198. package/dist/pages/console/data/shared.d.ts.map +1 -1
  199. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  200. package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
  201. package/dist/pages/console/ontology/actions.d.ts.map +1 -1
  202. package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
  203. package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
  204. package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
  205. package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
  206. package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
  207. package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
  208. package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
  209. package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
  210. package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
  211. package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
  212. package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
  213. package/dist/pages/console/ontology/objects.d.ts.map +1 -1
  214. package/dist/pages/console/ontology/rules.d.ts.map +1 -1
  215. package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
  216. package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
  217. package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
  218. package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
  219. package/dist/pages/console/skeletons.d.ts +30 -0
  220. package/dist/pages/console/skeletons.d.ts.map +1 -0
  221. package/dist/pages/console/workflow-run.d.ts.map +1 -1
  222. package/dist/pages/section-page.d.ts +11 -1
  223. package/dist/pages/section-page.d.ts.map +1 -1
  224. package/dist/pages/section-ui.d.ts +25 -3
  225. package/dist/pages/section-ui.d.ts.map +1 -1
  226. package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
  227. package/dist/pages/settings/activity/connections.d.ts.map +1 -1
  228. package/dist/pages/settings/activity/page.d.ts.map +1 -1
  229. package/dist/pages/settings/activity/thread.d.ts.map +1 -1
  230. package/dist/pages/settings/activity/timeline.d.ts +2 -0
  231. package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
  232. package/dist/pages/settings/controls.d.ts +4 -0
  233. package/dist/pages/settings/controls.d.ts.map +1 -1
  234. package/dist/pages/settings/members.d.ts.map +1 -1
  235. package/dist/pages/settings/memory-history.d.ts +2 -0
  236. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  237. package/dist/pages/settings/memory.d.ts.map +1 -1
  238. package/dist/pages/settings/service-accounts.d.ts.map +1 -1
  239. package/dist/pages/settings/sessions.d.ts.map +1 -1
  240. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  241. package/dist/pages/settings/usage/limits.d.ts.map +1 -1
  242. package/dist/pages/settings/usage/messages.d.ts +2 -2
  243. package/dist/pages/settings/usage/messages.d.ts.map +1 -1
  244. package/dist/pages/settings/usage/runs.d.ts +8 -2
  245. package/dist/pages/settings/usage/runs.d.ts.map +1 -1
  246. package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
  247. package/dist/pages/settings/usage/spend-model.d.ts +5 -0
  248. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  249. package/dist/pages/values.d.ts +6 -0
  250. package/dist/pages/values.d.ts.map +1 -1
  251. package/dist/pages.d.ts +4 -0
  252. package/dist/pages.d.ts.map +1 -1
  253. package/dist/pages.js +8195 -4841
  254. package/dist/pages.js.map +58 -49
  255. package/dist/sections/catalog.d.ts.map +1 -1
  256. package/dist/sections/sections.d.ts.map +1 -1
  257. package/dist/server.js +294 -23
  258. package/dist/server.js.map +8 -7
  259. package/dist/service-worker.d.ts +39 -0
  260. package/dist/service-worker.d.ts.map +1 -0
  261. package/dist/shared-session.d.ts +25 -0
  262. package/dist/shared-session.d.ts.map +1 -0
  263. package/dist/shell/app-return.d.ts +35 -0
  264. package/dist/shell/app-return.d.ts.map +1 -0
  265. package/dist/shell/app-shell.d.ts +1 -1
  266. package/dist/shell/app-shell.d.ts.map +1 -1
  267. package/dist/shell/nav-items.d.ts +2 -0
  268. package/dist/shell/nav-items.d.ts.map +1 -1
  269. package/dist/shell/phone/back.d.ts +6 -0
  270. package/dist/shell/phone/back.d.ts.map +1 -0
  271. package/dist/shell/phone/launch.d.ts +7 -0
  272. package/dist/shell/phone/launch.d.ts.map +1 -0
  273. package/dist/shell/phone/more-sheet.d.ts +36 -0
  274. package/dist/shell/phone/more-sheet.d.ts.map +1 -0
  275. package/dist/shell/phone/phone-foundations.d.ts +9 -0
  276. package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
  277. package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
  278. package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
  279. package/dist/shell/phone/routes.d.ts +12 -0
  280. package/dist/shell/phone/routes.d.ts.map +1 -0
  281. package/dist/shell/phone/screen-motion.d.ts +11 -0
  282. package/dist/shell/phone/screen-motion.d.ts.map +1 -0
  283. package/dist/shell/phone/scroll-restoration.d.ts +7 -0
  284. package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
  285. package/dist/shell/phone/startup-image.d.ts +17 -0
  286. package/dist/shell/phone/startup-image.d.ts.map +1 -0
  287. package/dist/shell/phone/tab-bar.d.ts +14 -0
  288. package/dist/shell/phone/tab-bar.d.ts.map +1 -0
  289. package/dist/shell/phone/top-bar.d.ts +24 -0
  290. package/dist/shell/phone/top-bar.d.ts.map +1 -0
  291. package/dist/shell/search-command.d.ts +3 -1
  292. package/dist/shell/search-command.d.ts.map +1 -1
  293. package/dist/shell/user-menu.d.ts +2 -0
  294. package/dist/shell/user-menu.d.ts.map +1 -1
  295. package/package.json +8 -5
  296. package/src/agent/activity-label.ts +6 -2
  297. package/src/agent/agent-chat.tsx +51 -8
  298. package/src/agent/agent-panel.tsx +12 -0
  299. package/src/agent/agent-surface.tsx +4 -0
  300. package/src/agent/agent.css +18 -0
  301. package/src/agent/artifact-card.tsx +84 -16
  302. package/src/agent/artifact-panel.tsx +63 -43
  303. package/src/agent/background/background-card.tsx +308 -0
  304. package/src/agent/background/background-tool-row.tsx +58 -0
  305. package/src/agent/background/context.ts +26 -0
  306. package/src/agent/background/interpret.ts +356 -0
  307. package/src/agent/bash/bash-tool-view.tsx +9 -4
  308. package/src/agent/bash/interpret.ts +21 -3
  309. package/src/agent/components/agent-message-body.tsx +1 -1
  310. package/src/agent/components/composer-menu.tsx +4 -1
  311. package/src/agent/components/composer-place.tsx +168 -0
  312. package/src/agent/components/composer.tsx +101 -3
  313. package/src/agent/components/computer-place.tsx +18 -1
  314. package/src/agent/components/context-chips.tsx +72 -2
  315. package/src/agent/components/conversation-panel.tsx +3 -2
  316. package/src/agent/components/message-parts.tsx +6 -1
  317. package/src/agent/components/thread-artifacts-menu.tsx +22 -5
  318. package/src/agent/components/transcript.tsx +33 -1
  319. package/src/agent/components/web-fetch-tool-view.tsx +94 -29
  320. package/src/agent/composer-insertion.ts +36 -0
  321. package/src/agent/delegation/child-parts.tsx +1 -1
  322. package/src/agent/hooks/use-agent-conversation.ts +101 -8
  323. package/src/agent/hooks/use-new-thread-place.ts +294 -0
  324. package/src/agent/i18n/en.ts +70 -3
  325. package/src/agent/i18n/fr.ts +70 -3
  326. package/src/agent/observed-conversation.tsx +3 -0
  327. package/src/agent/publish-artifact/interpret.ts +27 -5
  328. package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
  329. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
  330. package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
  331. package/src/agent/react-router.tsx +2 -2
  332. package/src/agent/tool-views/built-in.tsx +29 -11
  333. package/src/agent/types.ts +4 -0
  334. package/src/agent/utils/web-fetch.ts +89 -10
  335. package/src/agent/utils/web-search.ts +67 -28
  336. package/src/artifacts/artifact-page.tsx +42 -17
  337. package/src/artifacts/artifact-viewer.tsx +56 -0
  338. package/src/artifacts/artifacts.css +80 -0
  339. package/src/artifacts/card-details.ts +2 -2
  340. package/src/artifacts/card-preview.tsx +17 -3
  341. package/src/artifacts/comments-context.ts +125 -0
  342. package/src/artifacts/edit-session.tsx +6 -6
  343. package/src/artifacts/file-source.ts +10 -3
  344. package/src/artifacts/frame.tsx +50 -12
  345. package/src/artifacts/gallery.tsx +9 -11
  346. package/src/artifacts/guest-badge.tsx +21 -0
  347. package/src/artifacts/held-artifact.tsx +241 -0
  348. package/src/artifacts/holders.tsx +170 -0
  349. package/src/artifacts/live/boards.ts +95 -0
  350. package/src/artifacts/live/canvas.ts +402 -0
  351. package/src/artifacts/live/header.tsx +137 -0
  352. package/src/artifacts/live/hooks.ts +94 -0
  353. package/src/artifacts/live/presence.ts +147 -0
  354. package/src/artifacts/live/session.ts +520 -0
  355. package/src/artifacts/live/view.ts +81 -0
  356. package/src/artifacts/messages.ts +415 -24
  357. package/src/artifacts/page-queries.ts +2 -3
  358. package/src/artifacts/page-state.ts +16 -7
  359. package/src/artifacts/publish-edit.ts +50 -22
  360. package/src/artifacts/queries.ts +108 -10
  361. package/src/artifacts/references/references.tsx +6 -9
  362. package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
  363. package/src/artifacts/renderers/canvas/board-editor.tsx +817 -0
  364. package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
  365. package/src/artifacts/renderers/canvas/board-source.ts +110 -0
  366. package/src/artifacts/renderers/canvas/board.tsx +309 -33
  367. package/src/artifacts/renderers/canvas/canvas.tsx +387 -72
  368. package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
  369. package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
  370. package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
  371. package/src/artifacts/renderers/canvas/comments.ts +225 -0
  372. package/src/artifacts/renderers/canvas/draft.ts +41 -50
  373. package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
  374. package/src/artifacts/renderers/canvas/focus.tsx +175 -24
  375. package/src/artifacts/renderers/canvas/items.tsx +179 -52
  376. package/src/artifacts/renderers/canvas/layout.ts +99 -47
  377. package/src/artifacts/renderers/canvas/presence.tsx +184 -0
  378. package/src/artifacts/renderers/canvas/previews.ts +127 -0
  379. package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
  380. package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
  381. package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
  382. package/src/artifacts/renderers/slides/slides.tsx +1 -1
  383. package/src/artifacts/version-menu.tsx +438 -0
  384. package/src/artifacts/view-context.ts +102 -0
  385. package/src/artifacts/viewer.tsx +205 -147
  386. package/src/build.ts +96 -11
  387. package/src/codegen.ts +83 -5
  388. package/src/createCustomApp.ts +20 -7
  389. package/src/index.ts +12 -0
  390. package/src/locale-messages.ts +24 -0
  391. package/src/metadata.ts +12 -0
  392. package/src/pages/console/action-run.tsx +20 -0
  393. package/src/pages/console/data/connectors.tsx +27 -3
  394. package/src/pages/console/data/datasets.tsx +30 -1
  395. package/src/pages/console/data/lake-health.tsx +299 -0
  396. package/src/pages/console/data/messages.ts +143 -2
  397. package/src/pages/console/data/pipelines.tsx +91 -3
  398. package/src/pages/console/data/projections.tsx +23 -4
  399. package/src/pages/console/data/shared.tsx +1 -0
  400. package/src/pages/console/data/syncs.tsx +39 -2
  401. package/src/pages/console/ontology/action-runs.tsx +8 -2
  402. package/src/pages/console/ontology/actions.tsx +39 -15
  403. package/src/pages/console/ontology/components/action-button.tsx +10 -0
  404. package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
  405. package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
  406. package/src/pages/console/ontology/lib/action-params.ts +10 -0
  407. package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
  408. package/src/pages/console/ontology/object-page.tsx +2 -0
  409. package/src/pages/console/ontology/object-type.tsx +73 -14
  410. package/src/pages/console/ontology/object-types.tsx +56 -7
  411. package/src/pages/console/ontology/objects.tsx +167 -19
  412. package/src/pages/console/ontology/rules.tsx +186 -30
  413. package/src/pages/console/ontology/workflow.tsx +130 -74
  414. package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
  415. package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
  416. package/src/pages/console/ontology/workflows.tsx +34 -21
  417. package/src/pages/console/skeletons.tsx +99 -0
  418. package/src/pages/console/workflow-run.tsx +20 -0
  419. package/src/pages/section-page.tsx +37 -7
  420. package/src/pages/section-ui.tsx +96 -13
  421. package/src/pages/settings/activity/calendar.tsx +13 -6
  422. package/src/pages/settings/activity/connections.tsx +26 -9
  423. package/src/pages/settings/activity/page.tsx +31 -4
  424. package/src/pages/settings/activity/thread.tsx +32 -18
  425. package/src/pages/settings/activity/timeline.tsx +39 -0
  426. package/src/pages/settings/controls.tsx +19 -1
  427. package/src/pages/settings/developers.tsx +2 -2
  428. package/src/pages/settings/members.tsx +42 -9
  429. package/src/pages/settings/memory-history.tsx +76 -10
  430. package/src/pages/settings/memory.tsx +47 -5
  431. package/src/pages/settings/service-accounts.tsx +7 -2
  432. package/src/pages/settings/sessions.tsx +6 -2
  433. package/src/pages/settings/usage/breakdown.tsx +62 -2
  434. package/src/pages/settings/usage/limits.tsx +45 -3
  435. package/src/pages/settings/usage/messages.ts +2 -2
  436. package/src/pages/settings/usage/page.tsx +99 -52
  437. package/src/pages/settings/usage/runs.tsx +105 -8
  438. package/src/pages/settings/usage/spend-chart.tsx +79 -45
  439. package/src/pages/settings/usage/spend-model.ts +17 -0
  440. package/src/pages/values.tsx +72 -6
  441. package/src/pages.ts +4 -0
  442. package/src/sections/catalog.ts +6 -0
  443. package/src/sections/sections.tsx +2 -0
  444. package/src/service-worker.ts +176 -0
  445. package/src/shared-session.ts +73 -0
  446. package/src/shell/app-return.ts +115 -0
  447. package/src/shell/app-shell.tsx +125 -27
  448. package/src/shell/nav-items.tsx +2 -0
  449. package/src/shell/phone/back.ts +16 -0
  450. package/src/shell/phone/launch.ts +6 -0
  451. package/src/shell/phone/more-sheet.tsx +249 -0
  452. package/src/shell/phone/phone-foundations.tsx +43 -0
  453. package/src/shell/phone/phone.css +660 -0
  454. package/src/shell/phone/pull-to-refresh.tsx +201 -0
  455. package/src/shell/phone/routes.ts +34 -0
  456. package/src/shell/phone/screen-motion.ts +292 -0
  457. package/src/shell/phone/scroll-restoration.tsx +70 -0
  458. package/src/shell/phone/startup-image.ts +119 -0
  459. package/src/shell/phone/tab-bar.tsx +95 -0
  460. package/src/shell/phone/top-bar.tsx +195 -0
  461. package/src/shell/search-command.tsx +30 -14
  462. package/src/shell/user-menu.tsx +2 -1
  463. package/dist/chunk-4mprsd2n.js.map +0 -10
  464. package/dist/chunk-fw2bm6dq.js.map +0 -182
  465. package/dist/chunk-zxthr2q5.js +0 -1487
  466. package/dist/chunk-zxthr2q5.js.map +0 -18
  467. /package/dist/{chunk-j9653e83.js.map → chunk-fwb9mxwm.js.map} +0 -0
  468. /package/dist/{chunk-km25essq.js.map → chunk-kes4ygmz.js.map} +0 -0
  469. /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
@@ -0,0 +1,817 @@
1
+ import { uploadFile } from "@sixb/client"
2
+ import {
3
+ ARTIFACT_LIMITS,
4
+ type CanvasBoard,
5
+ type FrameEditTarget,
6
+ type FrameEvent,
7
+ parseFrameEvent,
8
+ } from "@sixb/core/artifacts"
9
+ import {
10
+ boardFilePath,
11
+ boardFramePatches,
12
+ mergeBoardText,
13
+ setBoardImage,
14
+ setBoardStyle,
15
+ } from "@sixb/core/artifacts/live"
16
+ import type { FileRef } from "@sixb/core/blob-storage"
17
+ import { Popover, PopoverContent, PopoverTrigger } from "@sixb/ui/components"
18
+ import { useLocale } from "@sixb/ui/lib/i18n"
19
+ import { cn } from "@sixb/ui/lib/utils"
20
+ import { Code2, ImageIcon, LoaderCircle, MessageSquarePlus, Paintbrush } from "lucide-react"
21
+ import {
22
+ type ComponentPropsWithoutRef,
23
+ forwardRef,
24
+ type ReactNode,
25
+ useCallback,
26
+ useEffect,
27
+ useLayoutEffect,
28
+ useMemo,
29
+ useRef,
30
+ useState,
31
+ } from "react"
32
+ import { formatFileSize } from "../../file-size"
33
+ import { ArtifactFrame, type ArtifactFrameHandle } from "../../frame"
34
+ import { useLiveBoardSource, useLiveStoredFiles } from "../../live/boards"
35
+ import type { LiveCanvas } from "../../live/canvas"
36
+ import type { LiveArtifact } from "../../live/session"
37
+ import { useArtifactMessages } from "../../messages"
38
+ import { type ArtifactVersion, useFileText, versionFileSource } from "../../queries"
39
+ import { type CanvasImage, ImagePanel, type StyleChange, StylePanel } from "./board-properties"
40
+ import {
41
+ boardAttribute,
42
+ boardInlineStyle,
43
+ boardReferencePath,
44
+ showablePatches,
45
+ } from "./board-source"
46
+ import {
47
+ CommentPin,
48
+ cardPlace,
49
+ DraftCard,
50
+ type DraftPlace,
51
+ type PinPlace,
52
+ pinPoint,
53
+ } from "./comment-pins"
54
+
55
+ // A board opened over the canvas, as its page runs in its frame, and what the reader does on it:
56
+ // read it, edit what it shows, or pick what to comment on.
57
+ //
58
+ // The frame serves the board as a stored version holds it, marked for editing; the live document
59
+ // holds it as everyone is changing it now. The frame is kept at the version it loaded and told,
60
+ // element by element, what changed since (`edit.patch`), so typing goes on under the caret while
61
+ // others change other elements. It loads a newer version only when the elements themselves
62
+ // changed, or a picture it does not hold yet is shown, and then once the stored version holds it.
63
+ //
64
+ // frame ── edit.select ──▶ the element picked, its toolbar (the reader's own click)
65
+ // ── edit.text ───▶ mergeBoardText → the board's Y.Text (only for the element picked)
66
+ // ◀─ edit.patch ── what the document changed since the frame's version
67
+
68
+ /** What edits a board's elements: the live canvas, under the reader's own undo. */
69
+ export type BoardEditor = Pick<LiveCanvas, "editBoard" | "stopCapturing">
70
+
71
+ /** What the reader is doing on an opened board. */
72
+ export type StageMode = "read" | "edit" | "comment"
73
+
74
+ /** An element picked to comment on: where the reader clicked, and what is there. */
75
+ export type CommentPick = Omit<DraftPlace, "board">
76
+
77
+ /** The image file types a board shows, by extension. */
78
+ const IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i
79
+
80
+ /**
81
+ * Follows a board's frame and the live document together: the version it shows, kept until it
82
+ * must move, what it showed last, and the patches that bring it to what the document holds.
83
+ */
84
+ function useBoardFrame({
85
+ version,
86
+ board,
87
+ live,
88
+ }: {
89
+ readonly version: ArtifactVersion
90
+ readonly board: CanvasBoard
91
+ readonly live: LiveArtifact | null
92
+ }) {
93
+ const source = useLiveBoardSource(live, board.file)
94
+ const patching = source !== null
95
+ const [pinned, setPinned] = useState(version)
96
+ const shows = patching ? pinned : version
97
+ const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text
98
+
99
+ const handle = useRef<ArtifactFrameHandle | null>(null)
100
+ /** Each load the frame said it is ready, for what follows to start over. */
101
+ const [loads, setLoads] = useState(0)
102
+ /** What the frame shows now, once patched past its version's page. */
103
+ const shown = useRef<string | null>(null)
104
+ /** Pictures the reader just uploaded, shown from their bytes until a version holds them. */
105
+ const previews = useRef(new Map<string, string>())
106
+ /** The frame must load a newer version: the elements changed, or a picture is missing. */
107
+ const [stale, setStale] = useState(false)
108
+ /**
109
+ * The elements themselves changed: the frame's addresses name other elements than the
110
+ * document's, so nothing is edited through it until it loads a version that has them.
111
+ */
112
+ const [moved, setMoved] = useState(false)
113
+ const [holding, setHolding] = useState(false)
114
+
115
+ const ready = useCallback(() => {
116
+ shown.current = null
117
+ setLoads((count) => count + 1)
118
+ }, [])
119
+
120
+ // What the document holds now, as patches to what the frame shows.
121
+ useEffect(() => {
122
+ if (loads === 0 || stored === undefined || source === null) return
123
+
124
+ const patches = boardFramePatches(shown.current ?? stored, source)
125
+ if (patches === null) {
126
+ setStale(true)
127
+ setMoved(true)
128
+ return
129
+ }
130
+ setMoved(false)
131
+
132
+ const holds = (path: string) => shows.files.some((file) => file.path === path)
133
+ const showable = showablePatches(patches, board.file, holds, previews.current)
134
+ if (showable.waiting) setStale(true)
135
+ shown.current = source
136
+ if (showable.patches.length === 0) return
137
+
138
+ handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {})
139
+ }, [loads, stored, source, shows, board.file])
140
+
141
+ // A stale frame loads the version the viewer has now once it is past the one it shows, and
142
+ // while the reader is not typing in it, unless what they type in is no longer where it was.
143
+ useEffect(() => {
144
+ if (!stale || (holding && !moved) || version.revision <= pinned.revision) return
145
+ setStale(false)
146
+ setPinned(version)
147
+ }, [stale, holding, moved, version, pinned.revision])
148
+
149
+ /** Loads the frame's page again, as what it shows can no longer be patched. */
150
+ const resync = useCallback(() => {
151
+ shown.current = null
152
+ handle.current?.send("reload", {}).catch(() => {})
153
+ }, [])
154
+
155
+ return {
156
+ shows,
157
+ source,
158
+ handle,
159
+ loads,
160
+ ready,
161
+ resync,
162
+ stale,
163
+ moved,
164
+ previews: previews.current,
165
+ hold: setHolding,
166
+ }
167
+ }
168
+
169
+ /**
170
+ * An opened board at its size on screen: its page in its frame, the picture under it until it is
171
+ * ready, comments' pins over it, and, editing, the picked element's tools.
172
+ */
173
+ export function BoardStage({
174
+ version,
175
+ board,
176
+ title,
177
+ scale,
178
+ live,
179
+ canvas,
180
+ mode,
181
+ pins,
182
+ activePin,
183
+ draft,
184
+ fallback,
185
+ failure,
186
+ onPress,
187
+ onPick,
188
+ onOpenPin,
189
+ onSubmitDraft,
190
+ onCancelDraft,
191
+ }: {
192
+ readonly version: ArtifactVersion
193
+ readonly board: CanvasBoard
194
+ readonly title: string
195
+ readonly scale: number
196
+ /** The canvas held live, whose document the board is patched from. */
197
+ readonly live: LiveArtifact | null
198
+ /** The live canvas the reader edits; null while they may not. */
199
+ readonly canvas: BoardEditor | null
200
+ readonly mode: StageMode
201
+ readonly pins: readonly PinPlace[]
202
+ readonly activePin: string | null
203
+ readonly draft: DraftPlace | null
204
+ readonly fallback?: ReactNode
205
+ readonly failure?: ReactNode
206
+ readonly onPress: (text: string) => void
207
+ readonly onPick: (pick: CommentPick) => void
208
+ readonly onOpenPin: (id: string) => void
209
+ readonly onSubmitDraft: (body: string) => Promise<void>
210
+ readonly onCancelDraft: () => void
211
+ }) {
212
+ const messages = useArtifactMessages().canvas
213
+ const frame = useBoardFrame({ version, board, live })
214
+ const editing = mode === "edit" && canvas !== null
215
+ const [selected, setSelected] = useState<FrameEditTarget | null>(null)
216
+ /** What the pointer is over while the reader picks what to comment on. */
217
+ const [hovered, setHovered] = useState<FrameEditTarget | null>(null)
218
+ const commenting = mode === "comment"
219
+ // The element picked, as the event handler reads it: what the frame says the reader typed in is
220
+ // taken only for it, and nothing while the frame's elements are not the document's.
221
+ const picked = useRef<FrameEditTarget | null>(null)
222
+ picked.current = editing ? selected : null
223
+ const moved = useRef(frame.moved)
224
+ moved.current = frame.moved
225
+
226
+ const { hold } = frame
227
+ useEffect(() => {
228
+ hold(editing && selected?.kind === "text")
229
+ }, [hold, editing, selected])
230
+
231
+ // Out of editing, or once the frame's elements no longer match the document's, nothing stays
232
+ // picked: its address may name another element now.
233
+ useEffect(() => {
234
+ if (!editing || frame.moved) {
235
+ picked.current = null
236
+ setSelected(null)
237
+ }
238
+ }, [editing, frame.moved])
239
+
240
+ useEffect(() => {
241
+ if (!commenting || frame.moved) setHovered(null)
242
+ }, [commenting, frame.moved])
243
+
244
+ // A comment written or given up leaves nothing named: a tap on a touch screen hovers with no
245
+ // pointer to leave after it.
246
+ useEffect(() => {
247
+ if (!draft) setHovered(null)
248
+ }, [draft])
249
+
250
+ // Each load of the frame, a port of its own, handed over with its first `edit` request: what
251
+ // editing reports comes through it alone, never through the window, where the board's scripts
252
+ // post too.
253
+ const port = useRef<{ readonly mine: MessagePort; handed: MessagePort | null } | null>(null)
254
+ const onEditRef = useRef<(event: FrameEvent) => void>(() => {})
255
+ useEffect(() => {
256
+ if (frame.loads === 0) return
257
+ const channel = new MessageChannel()
258
+ channel.port1.onmessage = (message: MessageEvent) => {
259
+ const event = parseFrameEvent(message.data)
260
+ if (event?.event.startsWith("edit.")) onEditRef.current(event)
261
+ }
262
+ port.current = { mine: channel.port1, handed: channel.port2 }
263
+ return () => channel.port1.close()
264
+ }, [frame.loads])
265
+
266
+ // The frame picks and types as the mode says, each time it loads; while its elements are not
267
+ // the document's, it does neither.
268
+ const send = frame.handle
269
+ useEffect(() => {
270
+ if (frame.loads === 0) return
271
+ const handed = port.current?.handed
272
+ if (port.current) port.current.handed = null
273
+ send.current
274
+ ?.send(
275
+ "edit",
276
+ { on: mode !== "read" && !frame.moved, typing: editing },
277
+ handed ? [handed] : []
278
+ )
279
+ .catch(() => {})
280
+ }, [frame.loads, frame.moved, mode, editing, send])
281
+
282
+ const point = useCallback(
283
+ (at: { readonly x: number; readonly y: number } | undefined, rect: FrameEditTarget["rect"]) => {
284
+ const x = at?.x ?? rect.x + rect.width
285
+ const y = at?.y ?? rect.y
286
+ return {
287
+ x: Math.min(1, Math.max(0, x / board.w)),
288
+ y: Math.min(1, Math.max(0, y / board.h)),
289
+ }
290
+ },
291
+ [board.w, board.h]
292
+ )
293
+
294
+ const onEvent = useCallback(
295
+ (event: FrameEvent) => {
296
+ if (event.event === "ready") {
297
+ // A page loaded again has nothing picked, and nothing under the pointer.
298
+ picked.current = null
299
+ setSelected(null)
300
+ setHovered(null)
301
+ frame.ready()
302
+ } else if (event.event === "press") {
303
+ onPress(event.params.text)
304
+ }
305
+ },
306
+ [frame, onPress]
307
+ )
308
+
309
+ onEditRef.current = (event: FrameEvent) => {
310
+ if (moved.current) return
311
+
312
+ switch (event.event) {
313
+ case "edit.hover": {
314
+ if (commenting) setHovered(event.params.target)
315
+ return
316
+ }
317
+ case "edit.select": {
318
+ const { target, at } = event.params
319
+ if (commenting) {
320
+ if (!target) return
321
+ setHovered(null)
322
+ const element = target.address ?? target.within ?? undefined
323
+ onPick({
324
+ ...(element ? { element } : {}),
325
+ ...(target.label ? { label: target.label } : {}),
326
+ // The page's body is the whole board, named by its title.
327
+ ...(target.address === "body" ? { anchor: title } : {}),
328
+ point: point(at, target.rect),
329
+ under: Math.min(1, (target.rect.y + target.rect.height) / board.h),
330
+ })
331
+ return
332
+ }
333
+ if (!editing) return
334
+ picked.current = target
335
+ setSelected(target)
336
+ return
337
+ }
338
+ case "edit.text": {
339
+ // Only the words of the element the reader picked, a text, are taken.
340
+ const chosen = picked.current
341
+ const { address, base, text } = event.params
342
+ if (!canvas || chosen?.kind !== "text" || chosen.address !== address) return
343
+
344
+ try {
345
+ canvas.editBoard(board.file, (source) => mergeBoardText(source, address, base, text))
346
+ } catch {
347
+ // The element is no longer text there: the board changed under the reader.
348
+ picked.current = null
349
+ setSelected(null)
350
+ frame.resync()
351
+ }
352
+ return
353
+ }
354
+ default:
355
+ return
356
+ }
357
+ }
358
+
359
+ return (
360
+ <div className="relative size-full">
361
+ <div className="absolute inset-0 overflow-hidden rounded-[inherit]">
362
+ <div
363
+ className="absolute top-0 left-0 origin-top-left"
364
+ style={{ width: board.w, height: board.h, transform: `scale(${scale})` }}
365
+ >
366
+ <ArtifactFrame
367
+ key={board.id}
368
+ version={frame.shows}
369
+ entry={board.file}
370
+ title={messages.boardFrame(title)}
371
+ className="size-full"
372
+ editable
373
+ handle={frame.handle}
374
+ onEvent={onEvent}
375
+ fallback={fallback}
376
+ failure={failure}
377
+ />
378
+ </div>
379
+ </div>
380
+
381
+ <div className="pointer-events-none absolute inset-0" data-board-overlay="">
382
+ {pins.map((pin, index) => {
383
+ const at = pinPoint(pin, pin.point ? 0 : index)
384
+ return (
385
+ <div
386
+ key={pin.id}
387
+ className="absolute"
388
+ style={{ left: at.x * board.w * scale, top: at.y * board.h * scale }}
389
+ >
390
+ <CommentPin
391
+ number={pin.number}
392
+ label={pin.label}
393
+ active={activePin === pin.id}
394
+ resolved={pin.resolved}
395
+ onClick={() => onOpenPin(pin.id)}
396
+ />
397
+ </div>
398
+ )
399
+ })}
400
+
401
+ {commenting && hovered && !draft ? <HoverTag target={hovered} scale={scale} /> : null}
402
+
403
+ {draft ? (
404
+ <div
405
+ className="absolute"
406
+ style={{ left: draft.point.x * board.w * scale, top: draft.point.y * board.h * scale }}
407
+ >
408
+ <CommentPin label={messages.comments.newPin} active resolved={false} draft />
409
+ <div
410
+ className={cn("absolute", draftAbove(draft) ? "bottom-9" : null)}
411
+ style={{
412
+ ...cardPlace(draft.point.x * board.w * scale, board.w * scale),
413
+ // Under what it is about, so the words it points at stay in view.
414
+ ...(draftAbove(draft)
415
+ ? {}
416
+ : {
417
+ top:
418
+ Math.max(
419
+ 0,
420
+ ((draft.under ?? draft.point.y) - draft.point.y) * board.h * scale
421
+ ) + 10,
422
+ }),
423
+ }}
424
+ >
425
+ <DraftCard
426
+ {...(draft.anchor ? { anchor: draft.anchor } : {})}
427
+ onSubmit={onSubmitDraft}
428
+ onCancel={onCancelDraft}
429
+ />
430
+ </div>
431
+ </div>
432
+ ) : null}
433
+
434
+ {editing && selected ? (
435
+ <ElementTools
436
+ key={selected.address ?? "scripted"}
437
+ target={selected}
438
+ scale={scale}
439
+ board={board}
440
+ version={version}
441
+ live={live}
442
+ canvas={canvas}
443
+ source={frame.source}
444
+ previews={frame.previews}
445
+ onComment={() =>
446
+ onPick({
447
+ ...(selected.address !== null
448
+ ? { element: selected.address, label: selected.label }
449
+ : selected.within
450
+ ? { element: selected.within }
451
+ : {}),
452
+ point: point(undefined, selected.rect),
453
+ })
454
+ }
455
+ />
456
+ ) : null}
457
+ </div>
458
+
459
+ {frame.stale ? (
460
+ <span
461
+ role="status"
462
+ className="absolute right-3 bottom-3 flex items-center gap-1.5 rounded-full bg-background/95 px-2.5 py-1 text-xs text-muted-foreground shadow-sm ring-1 ring-border"
463
+ >
464
+ <LoaderCircle className="size-3 animate-spin motion-reduce:animate-none" aria-hidden />
465
+ {messages.edit.updating}
466
+ </span>
467
+ ) : null}
468
+ </div>
469
+ )
470
+ }
471
+
472
+ /**
473
+ * Whether a new comment's card sits above its pin: what it is about runs to the board's foot, and
474
+ * the pin is low enough to leave room over it.
475
+ */
476
+ function draftAbove(draft: DraftPlace): boolean {
477
+ return (draft.under ?? draft.point.y) > 0.7 && draft.point.y > 0.5
478
+ }
479
+
480
+ /**
481
+ * What the reader would comment on, named over it as the pointer moves: its words, or what kind
482
+ * of thing it is, in the blue the frame outlines it in.
483
+ */
484
+ function HoverTag({ target, scale }: { readonly target: FrameEditTarget; readonly scale: number }) {
485
+ const messages = useArtifactMessages().canvas
486
+ const name =
487
+ target.address === "body"
488
+ ? messages.comments.wholeBoard
489
+ : target.label
490
+ ? `“${target.label}”`
491
+ : target.address === null
492
+ ? messages.comments.elsewhere
493
+ : messages.edit.kinds[target.kind]
494
+ const top = target.rect.y * scale
495
+ return (
496
+ <div
497
+ aria-hidden="true"
498
+ className={cn(
499
+ "absolute max-w-64 truncate rounded-md bg-[#0a84ff] px-1.5 py-0.5 text-[11px] leading-4 font-medium text-white shadow-sm",
500
+ // Above the element, or inside its top when it starts at the board's top.
501
+ top < 24 ? "translate-y-1" : "-translate-y-[calc(100%+5px)]"
502
+ )}
503
+ style={{ left: target.rect.x * scale - 3, top }}
504
+ >
505
+ {name}
506
+ </div>
507
+ )
508
+ }
509
+
510
+ /**
511
+ * The picked element's tools, floating above it: what it is, its style, an image's picture, and a
512
+ * comment on it. What a script built says so, and offers a comment.
513
+ */
514
+ function ElementTools({
515
+ target,
516
+ scale,
517
+ board,
518
+ version,
519
+ live,
520
+ canvas,
521
+ source,
522
+ previews,
523
+ onComment,
524
+ }: {
525
+ readonly target: FrameEditTarget
526
+ readonly scale: number
527
+ readonly board: CanvasBoard
528
+ readonly version: ArtifactVersion
529
+ readonly live: LiveArtifact | null
530
+ readonly canvas: BoardEditor
531
+ readonly source: string | null
532
+ readonly previews: Map<string, string>
533
+ readonly onComment: () => void
534
+ }) {
535
+ const messages = useArtifactMessages().canvas
536
+ const rect = target.rect
537
+
538
+ // Over the element's left edge, kept on the stage: on a phone, an element on the right would
539
+ // push the toolbar past it.
540
+ const toolbar = useRef<HTMLDivElement | null>(null)
541
+ const [width, setWidth] = useState(0)
542
+ useLayoutEffect(() => {
543
+ setWidth(toolbar.current?.offsetWidth ?? 0)
544
+ })
545
+ const left = Math.max(4, Math.min(rect.x * scale, board.w * scale - width - 4))
546
+ const above = rect.y * scale >= 44
547
+ const top = above ? rect.y * scale - 40 : (rect.y + rect.height) * scale + 8
548
+
549
+ return (
550
+ <div
551
+ ref={toolbar}
552
+ role="toolbar"
553
+ aria-label={messages.edit.tools}
554
+ data-board-tools=""
555
+ className="pointer-events-auto absolute flex max-w-[calc(100%-8px)] items-center gap-0.5 rounded-xl border border-border bg-background/95 p-1 shadow-[0_1px_2px_rgb(0_0_0/0.08),0_10px_28px_-14px_rgb(0_0_0/0.35)] backdrop-blur motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1"
556
+ style={{ left, top }}
557
+ >
558
+ {target.kind === "scripted" ? (
559
+ <span className="flex min-w-0 items-center gap-2 px-2 text-xs">
560
+ <Code2 className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
561
+ <span className="min-w-0">
562
+ <span className="font-medium text-foreground">{messages.edit.scripted}</span>
563
+ <span className="text-muted-foreground"> · {messages.edit.scriptedHint}</span>
564
+ </span>
565
+ </span>
566
+ ) : (
567
+ <>
568
+ <span className="max-w-40 truncate px-2 text-xs font-medium text-foreground">
569
+ {messages.edit.element(messages.edit.kinds[target.kind], tagOf(target.address))}
570
+ </span>
571
+ <span aria-hidden="true" className="mx-0.5 h-5 w-px bg-border" />
572
+ {target.kind === "image" ? (
573
+ <ImageTool
574
+ address={target.address}
575
+ board={board}
576
+ version={version}
577
+ live={live}
578
+ canvas={canvas}
579
+ source={source}
580
+ previews={previews}
581
+ />
582
+ ) : null}
583
+ <StyleTool
584
+ address={target.address}
585
+ words={target.kind === "text" || target.kind === "box"}
586
+ board={board}
587
+ canvas={canvas}
588
+ source={source}
589
+ />
590
+ </>
591
+ )}
592
+ <span aria-hidden="true" className="mx-0.5 h-5 w-px bg-border" />
593
+ <ToolButton label={messages.toolbar.comment} onClick={onComment}>
594
+ <MessageSquarePlus />
595
+ </ToolButton>
596
+ </div>
597
+ )
598
+ }
599
+
600
+ /** The tag an address ends at: `h1` of `body>main:0>h1:0`. */
601
+ function tagOf(address: string): string {
602
+ return address.split(">").at(-1)?.split(":")[0] ?? ""
603
+ }
604
+
605
+ function StyleTool({
606
+ address,
607
+ words,
608
+ board,
609
+ canvas,
610
+ source,
611
+ }: {
612
+ readonly address: string
613
+ readonly words: boolean
614
+ readonly board: CanvasBoard
615
+ readonly canvas: BoardEditor
616
+ readonly source: string | null
617
+ }) {
618
+ const messages = useArtifactMessages().canvas.edit
619
+ const style = useMemo(
620
+ () => (source === null ? {} : boardInlineStyle(source, address)),
621
+ [source, address]
622
+ )
623
+
624
+ const change = (properties: StyleChange): boolean => {
625
+ try {
626
+ canvas.stopCapturing()
627
+ canvas.editBoard(board.file, (page) => setBoardStyle(page, address, properties))
628
+ canvas.stopCapturing()
629
+ return true
630
+ } catch {
631
+ return false
632
+ }
633
+ }
634
+
635
+ return (
636
+ <Popover modal={false}>
637
+ <PopoverTrigger asChild>
638
+ <ToolButton label={messages.style}>
639
+ <Paintbrush />
640
+ </ToolButton>
641
+ </PopoverTrigger>
642
+ <PopoverContent
643
+ align="start"
644
+ sideOffset={8}
645
+ className="w-auto p-3"
646
+ onOpenAutoFocus={(event) => event.preventDefault()}
647
+ >
648
+ <StylePanel style={style} words={words} onChange={change} />
649
+ </PopoverContent>
650
+ </Popover>
651
+ )
652
+ }
653
+
654
+ function ImageTool({
655
+ address,
656
+ board,
657
+ version,
658
+ live,
659
+ canvas,
660
+ source,
661
+ previews,
662
+ }: {
663
+ readonly address: string
664
+ readonly board: CanvasBoard
665
+ readonly version: ArtifactVersion
666
+ readonly live: LiveArtifact | null
667
+ readonly canvas: BoardEditor
668
+ readonly source: string | null
669
+ readonly previews: Map<string, string>
670
+ }) {
671
+ const messages = useArtifactMessages().canvas.edit
672
+ const locale = useLocale()
673
+ const files = useArtifactMessages()
674
+ const stored = useLiveStoredFiles(live)
675
+ const [uploading, setUploading] = useState(false)
676
+ const [failure, setFailure] = useState<string | null>(null)
677
+
678
+ const src = source === null ? null : boardAttribute(source, address, "src")
679
+ const alt = source === null ? "" : (boardAttribute(source, address, "alt") ?? "")
680
+ const current = src === null ? null : boardReferencePath(board.file, src)
681
+
682
+ // The canvas's pictures: those the version holds, pictured, and those added since.
683
+ const images = useMemo<CanvasImage[]>(() => {
684
+ const listed = new Map<string, CanvasImage>()
685
+ for (const file of version.files) {
686
+ if (!IMAGE_EXTENSIONS.test(file.path)) continue
687
+ const url = versionFileSource(version, file.path)?.inlineUrl
688
+ listed.set(file.path, { path: file.path, ...(url ? { url } : {}) })
689
+ }
690
+ for (const path of stored.keys()) {
691
+ if (IMAGE_EXTENSIONS.test(path) && !listed.has(path)) {
692
+ const preview = previews.get(path)
693
+ listed.set(path, { path, ...(preview ? { url: preview } : {}) })
694
+ }
695
+ }
696
+ return [...listed.values()]
697
+ }, [version, stored, previews])
698
+
699
+ /** Makes an image change; false, saying so, when the element is no longer an image. */
700
+ const change = (image: { readonly src?: string; readonly alt?: string }, files = {}) => {
701
+ try {
702
+ canvas.stopCapturing()
703
+ canvas.editBoard(board.file, (page) => setBoardImage(page, address, image), files)
704
+ canvas.stopCapturing()
705
+ return true
706
+ } catch {
707
+ setFailure(messages.notImage)
708
+ return false
709
+ }
710
+ }
711
+
712
+ // Another picture: the description written for the last one goes with it.
713
+ const show = (path: string, files: Readonly<Record<string, FileRef>> = {}) =>
714
+ change({ src: boardFilePath(board.file, path), alt: "" }, files)
715
+
716
+ /** Uploads a picture and shows it; false, saying why, when it is not shown. */
717
+ const upload = async (file: File): Promise<boolean> => {
718
+ if (file.size > ARTIFACT_LIMITS.maxFileBytes) {
719
+ setFailure(
720
+ messages.tooLarge(formatFileSize(ARTIFACT_LIMITS.maxFileBytes, locale, files.files))
721
+ )
722
+ return false
723
+ }
724
+ setUploading(true)
725
+ setFailure(null)
726
+ try {
727
+ const path = imagePath(board.file, file.name)
728
+ const [ref, preview] = await Promise.all([
729
+ uploadFile(file, { fileName: path.split("/").at(-1) ?? path }),
730
+ // Without a preview, the picture shows once a version holds it.
731
+ dataUrl(file).catch(() => null),
732
+ ])
733
+ if (preview) previews.set(path, preview)
734
+ return show(path, { [path]: ref })
735
+ } catch {
736
+ setFailure(messages.uploadFailed)
737
+ return false
738
+ } finally {
739
+ setUploading(false)
740
+ }
741
+ }
742
+
743
+ return (
744
+ <Popover modal={false}>
745
+ <PopoverTrigger asChild>
746
+ <ToolButton label={messages.replace}>
747
+ <ImageIcon />
748
+ </ToolButton>
749
+ </PopoverTrigger>
750
+ <PopoverContent
751
+ align="start"
752
+ sideOffset={8}
753
+ className="w-auto p-3"
754
+ onOpenAutoFocus={(event) => event.preventDefault()}
755
+ >
756
+ <ImagePanel
757
+ current={current}
758
+ alt={alt}
759
+ images={images}
760
+ uploading={uploading}
761
+ failure={failure}
762
+ onUpload={upload}
763
+ onPick={show}
764
+ onAlt={(text) => {
765
+ change({ alt: text })
766
+ }}
767
+ />
768
+ </PopoverContent>
769
+ </Popover>
770
+ )
771
+ }
772
+
773
+ /**
774
+ * Where an uploaded picture goes: beside the board's page, in `images/`, under its own name made
775
+ * safe and six random letters, so two uploads of one name never meet.
776
+ */
777
+ export function imagePath(board: string, name: string): string {
778
+ const folder = board.split("/").slice(0, -1)
779
+ const extension = /\.([a-z0-9]{1,5})$/i.exec(name)?.[1]?.toLowerCase() ?? "png"
780
+ const stem =
781
+ name
782
+ .replace(/\.[^.]*$/, "")
783
+ .toLowerCase()
784
+ .normalize("NFKD")
785
+ .replace(/[^a-z0-9]+/g, "-")
786
+ .replace(/^-+|-+$/g, "")
787
+ .slice(0, 40) || "image"
788
+ const suffix = Array.from(crypto.getRandomValues(new Uint8Array(6)), (byte) =>
789
+ String.fromCharCode(97 + (byte % 26))
790
+ ).join("")
791
+ return [...folder, "images", `${stem}-${suffix}.${extension}`].join("/")
792
+ }
793
+
794
+ /** A picture's bytes as a `data:` address, which the frame shows before a version holds it. */
795
+ async function dataUrl(file: Blob): Promise<string> {
796
+ const bytes = new Uint8Array(await file.arrayBuffer())
797
+ let binary = ""
798
+ for (let at = 0; at < bytes.length; at += 0x8000) {
799
+ binary += String.fromCharCode(...bytes.subarray(at, at + 0x8000))
800
+ }
801
+ return `data:${file.type || "application/octet-stream"};base64,${btoa(binary)}`
802
+ }
803
+
804
+ const TOOL =
805
+ "flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-muted data-[state=open]:text-foreground [&_svg]:size-4"
806
+
807
+ /** A tool of the element's toolbar; a popover's trigger takes it as its own. */
808
+ const ToolButton = forwardRef<
809
+ HTMLButtonElement,
810
+ ComponentPropsWithoutRef<"button"> & { readonly label: string }
811
+ >(function ToolButton({ label, children, ...props }, ref) {
812
+ return (
813
+ <button ref={ref} type="button" aria-label={label} title={label} className={TOOL} {...props}>
814
+ {children}
815
+ </button>
816
+ )
817
+ })