@sixb/app 0.2.1 → 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 (422) hide show
  1. package/dist/agent/agent-chat.d.ts +9 -2
  2. package/dist/agent/agent-chat.d.ts.map +1 -1
  3. package/dist/agent/agent-panel.d.ts +9 -1
  4. package/dist/agent/agent-panel.d.ts.map +1 -1
  5. package/dist/agent/agent-surface.d.ts.map +1 -1
  6. package/dist/agent/artifact-card.d.ts +3 -1
  7. package/dist/agent/artifact-card.d.ts.map +1 -1
  8. package/dist/agent/artifact-panel.d.ts +7 -1
  9. package/dist/agent/artifact-panel.d.ts.map +1 -1
  10. package/dist/agent/components/composer-place.d.ts +3 -1
  11. package/dist/agent/components/composer-place.d.ts.map +1 -1
  12. package/dist/agent/components/composer.d.ts +20 -1
  13. package/dist/agent/components/composer.d.ts.map +1 -1
  14. package/dist/agent/components/context-chips.d.ts.map +1 -1
  15. package/dist/agent/components/context-meter.d.ts +1 -1
  16. package/dist/agent/components/conversation-panel.d.ts +3 -1
  17. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  18. package/dist/agent/components/message-parts.d.ts +3 -1
  19. package/dist/agent/components/message-parts.d.ts.map +1 -1
  20. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
  21. package/dist/agent/composer-insertion.d.ts +24 -0
  22. package/dist/agent/composer-insertion.d.ts.map +1 -0
  23. package/dist/agent/delegation/use-children.d.ts +5 -5
  24. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  25. package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
  26. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  27. package/dist/agent/hooks/use-new-thread-place.d.ts +39 -17
  28. package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -1
  29. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  30. package/dist/agent/i18n/en.d.ts +14 -0
  31. package/dist/agent/i18n/en.d.ts.map +1 -1
  32. package/dist/agent/i18n/fr.d.ts.map +1 -1
  33. package/dist/agent/i18n/index.d.ts +20 -0
  34. package/dist/agent/i18n/index.d.ts.map +1 -1
  35. package/dist/agent/publish-artifact/interpret.d.ts +8 -2
  36. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  37. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
  38. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
  39. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
  40. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
  41. package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
  42. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
  43. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  44. package/dist/agent/types.d.ts +3 -1
  45. package/dist/agent/types.d.ts.map +1 -1
  46. package/dist/artifacts/artifact-page.d.ts.map +1 -1
  47. package/dist/artifacts/artifact-viewer.d.ts +16 -0
  48. package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
  49. package/dist/artifacts/card-details.d.ts +1 -1
  50. package/dist/artifacts/card-details.d.ts.map +1 -1
  51. package/dist/artifacts/card-preview.d.ts.map +1 -1
  52. package/dist/artifacts/comments-context.d.ts +48 -0
  53. package/dist/artifacts/comments-context.d.ts.map +1 -0
  54. package/dist/artifacts/edit-session.d.ts +6 -6
  55. package/dist/artifacts/edit-session.d.ts.map +1 -1
  56. package/dist/artifacts/file-source.d.ts.map +1 -1
  57. package/dist/artifacts/frame.d.ts +10 -2
  58. package/dist/artifacts/frame.d.ts.map +1 -1
  59. package/dist/artifacts/guest-badge.d.ts +8 -0
  60. package/dist/artifacts/guest-badge.d.ts.map +1 -0
  61. package/dist/artifacts/held-artifact.d.ts +19 -0
  62. package/dist/artifacts/held-artifact.d.ts.map +1 -0
  63. package/dist/artifacts/holders.d.ts +10 -0
  64. package/dist/artifacts/holders.d.ts.map +1 -0
  65. package/dist/artifacts/live/boards.d.ts +15 -0
  66. package/dist/artifacts/live/boards.d.ts.map +1 -0
  67. package/dist/artifacts/live/canvas.d.ts +79 -0
  68. package/dist/artifacts/live/canvas.d.ts.map +1 -0
  69. package/dist/artifacts/live/header.d.ts +29 -0
  70. package/dist/artifacts/live/header.d.ts.map +1 -0
  71. package/dist/artifacts/live/hooks.d.ts +21 -0
  72. package/dist/artifacts/live/hooks.d.ts.map +1 -0
  73. package/dist/artifacts/live/presence.d.ts +32 -0
  74. package/dist/artifacts/live/presence.d.ts.map +1 -0
  75. package/dist/artifacts/live/session.d.ts +130 -0
  76. package/dist/artifacts/live/session.d.ts.map +1 -0
  77. package/dist/artifacts/live/view.d.ts +28 -0
  78. package/dist/artifacts/live/view.d.ts.map +1 -0
  79. package/dist/artifacts/messages.d.ts +424 -14
  80. package/dist/artifacts/messages.d.ts.map +1 -1
  81. package/dist/artifacts/page-queries.d.ts +2 -2
  82. package/dist/artifacts/page-queries.d.ts.map +1 -1
  83. package/dist/artifacts/page-state.d.ts.map +1 -1
  84. package/dist/artifacts/publish-edit.d.ts +24 -14
  85. package/dist/artifacts/publish-edit.d.ts.map +1 -1
  86. package/dist/artifacts/queries.d.ts +490 -9
  87. package/dist/artifacts/queries.d.ts.map +1 -1
  88. package/dist/artifacts/references/references.d.ts.map +1 -1
  89. package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
  90. package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
  91. package/dist/artifacts/renderers/canvas/board-editor.d.ts +43 -0
  92. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
  93. package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
  94. package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
  95. package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
  96. package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
  97. package/dist/artifacts/renderers/canvas/board.d.ts +64 -19
  98. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  99. package/dist/artifacts/renderers/canvas/canvas.d.ts +13 -4
  100. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  101. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
  102. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
  103. package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
  104. package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
  105. package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
  106. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
  107. package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
  108. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
  109. package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
  110. package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
  111. package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
  112. package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
  113. package/dist/artifacts/renderers/canvas/focus.d.ts +40 -5
  114. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  115. package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
  116. package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
  117. package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
  118. package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
  119. package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
  120. package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
  121. package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
  122. package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
  123. package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
  124. package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
  125. package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
  126. package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
  127. package/dist/artifacts/version-menu.d.ts +19 -0
  128. package/dist/artifacts/version-menu.d.ts.map +1 -0
  129. package/dist/artifacts/view-context.d.ts +43 -0
  130. package/dist/artifacts/view-context.d.ts.map +1 -0
  131. package/dist/artifacts/viewer.d.ts.map +1 -1
  132. package/dist/build.d.ts +5 -0
  133. package/dist/build.d.ts.map +1 -1
  134. package/dist/{chunk-ytadd0b5.js → chunk-001c4gnk.js} +6871 -3756
  135. package/dist/chunk-001c4gnk.js.map +204 -0
  136. package/dist/chunk-00wggsst.js +7 -0
  137. package/dist/chunk-00wggsst.js.map +10 -0
  138. package/dist/chunk-5crvhjp2.js +4704 -0
  139. package/dist/chunk-5crvhjp2.js.map +28 -0
  140. package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
  141. package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
  142. package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
  143. package/dist/chunk-fg6thecb.js.map +10 -0
  144. package/dist/{chunk-j8g956dt.js → chunk-fwb9mxwm.js} +1 -1
  145. package/dist/{chunk-7fj9cfkw.js → chunk-kes4ygmz.js} +1 -1
  146. package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
  147. package/dist/codegen.d.ts.map +1 -1
  148. package/dist/createCustomApp.d.ts.map +1 -1
  149. package/dist/index.d.ts +7 -1
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +930 -309
  152. package/dist/index.js.map +15 -10
  153. package/dist/locale-messages.d.ts +12 -0
  154. package/dist/locale-messages.d.ts.map +1 -1
  155. package/dist/locale.d.ts +12 -0
  156. package/dist/locale.d.ts.map +1 -1
  157. package/dist/locale.js +1 -1
  158. package/dist/metadata.d.ts +8 -0
  159. package/dist/metadata.d.ts.map +1 -1
  160. package/dist/pages/console/action-run.d.ts.map +1 -1
  161. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  162. package/dist/pages/console/data/datasets.d.ts.map +1 -1
  163. package/dist/pages/console/data/lake-health.d.ts +3 -0
  164. package/dist/pages/console/data/lake-health.d.ts.map +1 -0
  165. package/dist/pages/console/data/messages.d.ts +98 -2
  166. package/dist/pages/console/data/messages.d.ts.map +1 -1
  167. package/dist/pages/console/data/pipelines.d.ts.map +1 -1
  168. package/dist/pages/console/data/projections.d.ts.map +1 -1
  169. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  170. package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
  171. package/dist/pages/console/ontology/actions.d.ts.map +1 -1
  172. package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
  173. package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
  174. package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
  175. package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
  176. package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
  177. package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
  178. package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
  179. package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
  180. package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
  181. package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
  182. package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
  183. package/dist/pages/console/ontology/objects.d.ts.map +1 -1
  184. package/dist/pages/console/ontology/rules.d.ts.map +1 -1
  185. package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
  186. package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
  187. package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
  188. package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
  189. package/dist/pages/console/skeletons.d.ts +30 -0
  190. package/dist/pages/console/skeletons.d.ts.map +1 -0
  191. package/dist/pages/console/workflow-run.d.ts.map +1 -1
  192. package/dist/pages/section-page.d.ts +11 -1
  193. package/dist/pages/section-page.d.ts.map +1 -1
  194. package/dist/pages/section-ui.d.ts +25 -3
  195. package/dist/pages/section-ui.d.ts.map +1 -1
  196. package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
  197. package/dist/pages/settings/activity/connections.d.ts.map +1 -1
  198. package/dist/pages/settings/activity/page.d.ts.map +1 -1
  199. package/dist/pages/settings/activity/thread.d.ts.map +1 -1
  200. package/dist/pages/settings/activity/timeline.d.ts +2 -0
  201. package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
  202. package/dist/pages/settings/controls.d.ts +4 -0
  203. package/dist/pages/settings/controls.d.ts.map +1 -1
  204. package/dist/pages/settings/members.d.ts.map +1 -1
  205. package/dist/pages/settings/memory-history.d.ts +2 -0
  206. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  207. package/dist/pages/settings/memory.d.ts.map +1 -1
  208. package/dist/pages/settings/service-accounts.d.ts.map +1 -1
  209. package/dist/pages/settings/sessions.d.ts.map +1 -1
  210. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  211. package/dist/pages/settings/usage/limits.d.ts.map +1 -1
  212. package/dist/pages/settings/usage/messages.d.ts +0 -2
  213. package/dist/pages/settings/usage/messages.d.ts.map +1 -1
  214. package/dist/pages/settings/usage/runs.d.ts +8 -2
  215. package/dist/pages/settings/usage/runs.d.ts.map +1 -1
  216. package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
  217. package/dist/pages/settings/usage/spend-model.d.ts +5 -0
  218. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  219. package/dist/pages/values.d.ts +6 -0
  220. package/dist/pages/values.d.ts.map +1 -1
  221. package/dist/pages.d.ts +4 -0
  222. package/dist/pages.d.ts.map +1 -1
  223. package/dist/pages.js +8188 -4841
  224. package/dist/pages.js.map +56 -47
  225. package/dist/sections/catalog.d.ts.map +1 -1
  226. package/dist/sections/sections.d.ts.map +1 -1
  227. package/dist/server.js +294 -23
  228. package/dist/server.js.map +8 -7
  229. package/dist/service-worker.d.ts +39 -0
  230. package/dist/service-worker.d.ts.map +1 -0
  231. package/dist/shared-session.d.ts +25 -0
  232. package/dist/shared-session.d.ts.map +1 -0
  233. package/dist/shell/app-return.d.ts +35 -0
  234. package/dist/shell/app-return.d.ts.map +1 -0
  235. package/dist/shell/app-shell.d.ts +1 -1
  236. package/dist/shell/app-shell.d.ts.map +1 -1
  237. package/dist/shell/nav-items.d.ts +2 -0
  238. package/dist/shell/nav-items.d.ts.map +1 -1
  239. package/dist/shell/phone/back.d.ts +6 -0
  240. package/dist/shell/phone/back.d.ts.map +1 -0
  241. package/dist/shell/phone/launch.d.ts +7 -0
  242. package/dist/shell/phone/launch.d.ts.map +1 -0
  243. package/dist/shell/phone/more-sheet.d.ts +36 -0
  244. package/dist/shell/phone/more-sheet.d.ts.map +1 -0
  245. package/dist/shell/phone/phone-foundations.d.ts +9 -0
  246. package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
  247. package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
  248. package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
  249. package/dist/shell/phone/routes.d.ts +12 -0
  250. package/dist/shell/phone/routes.d.ts.map +1 -0
  251. package/dist/shell/phone/screen-motion.d.ts +11 -0
  252. package/dist/shell/phone/screen-motion.d.ts.map +1 -0
  253. package/dist/shell/phone/scroll-restoration.d.ts +7 -0
  254. package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
  255. package/dist/shell/phone/startup-image.d.ts +17 -0
  256. package/dist/shell/phone/startup-image.d.ts.map +1 -0
  257. package/dist/shell/phone/tab-bar.d.ts +14 -0
  258. package/dist/shell/phone/tab-bar.d.ts.map +1 -0
  259. package/dist/shell/phone/top-bar.d.ts +24 -0
  260. package/dist/shell/phone/top-bar.d.ts.map +1 -0
  261. package/dist/shell/search-command.d.ts +3 -1
  262. package/dist/shell/search-command.d.ts.map +1 -1
  263. package/dist/shell/user-menu.d.ts +2 -0
  264. package/dist/shell/user-menu.d.ts.map +1 -1
  265. package/package.json +8 -5
  266. package/src/agent/agent-chat.tsx +51 -8
  267. package/src/agent/agent-panel.tsx +12 -0
  268. package/src/agent/agent-surface.tsx +4 -0
  269. package/src/agent/artifact-card.tsx +84 -16
  270. package/src/agent/artifact-panel.tsx +63 -43
  271. package/src/agent/components/agent-message-body.tsx +1 -1
  272. package/src/agent/components/composer-place.tsx +77 -53
  273. package/src/agent/components/composer.tsx +92 -7
  274. package/src/agent/components/context-chips.tsx +72 -2
  275. package/src/agent/components/conversation-panel.tsx +3 -2
  276. package/src/agent/components/message-parts.tsx +6 -1
  277. package/src/agent/components/thread-artifacts-menu.tsx +22 -5
  278. package/src/agent/composer-insertion.ts +36 -0
  279. package/src/agent/hooks/use-agent-conversation.ts +41 -10
  280. package/src/agent/hooks/use-new-thread-place.ts +149 -25
  281. package/src/agent/i18n/en.ts +14 -0
  282. package/src/agent/i18n/fr.ts +12 -0
  283. package/src/agent/publish-artifact/interpret.ts +27 -5
  284. package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
  285. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
  286. package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
  287. package/src/agent/react-router.tsx +2 -2
  288. package/src/agent/tool-views/built-in.tsx +3 -0
  289. package/src/agent/types.ts +4 -0
  290. package/src/artifacts/artifact-page.tsx +42 -17
  291. package/src/artifacts/artifact-viewer.tsx +56 -0
  292. package/src/artifacts/artifacts.css +80 -0
  293. package/src/artifacts/card-details.ts +2 -2
  294. package/src/artifacts/card-preview.tsx +17 -3
  295. package/src/artifacts/comments-context.ts +125 -0
  296. package/src/artifacts/edit-session.tsx +6 -6
  297. package/src/artifacts/file-source.ts +10 -3
  298. package/src/artifacts/frame.tsx +50 -12
  299. package/src/artifacts/gallery.tsx +9 -11
  300. package/src/artifacts/guest-badge.tsx +21 -0
  301. package/src/artifacts/held-artifact.tsx +241 -0
  302. package/src/artifacts/holders.tsx +170 -0
  303. package/src/artifacts/live/boards.ts +95 -0
  304. package/src/artifacts/live/canvas.ts +402 -0
  305. package/src/artifacts/live/header.tsx +137 -0
  306. package/src/artifacts/live/hooks.ts +94 -0
  307. package/src/artifacts/live/presence.ts +147 -0
  308. package/src/artifacts/live/session.ts +520 -0
  309. package/src/artifacts/live/view.ts +81 -0
  310. package/src/artifacts/messages.ts +415 -24
  311. package/src/artifacts/page-queries.ts +2 -3
  312. package/src/artifacts/page-state.ts +16 -7
  313. package/src/artifacts/publish-edit.ts +50 -22
  314. package/src/artifacts/queries.ts +108 -10
  315. package/src/artifacts/references/references.tsx +6 -9
  316. package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
  317. package/src/artifacts/renderers/canvas/board-editor.tsx +817 -0
  318. package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
  319. package/src/artifacts/renderers/canvas/board-source.ts +110 -0
  320. package/src/artifacts/renderers/canvas/board.tsx +309 -33
  321. package/src/artifacts/renderers/canvas/canvas.tsx +387 -72
  322. package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
  323. package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
  324. package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
  325. package/src/artifacts/renderers/canvas/comments.ts +225 -0
  326. package/src/artifacts/renderers/canvas/draft.ts +41 -50
  327. package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
  328. package/src/artifacts/renderers/canvas/focus.tsx +175 -24
  329. package/src/artifacts/renderers/canvas/items.tsx +179 -52
  330. package/src/artifacts/renderers/canvas/layout.ts +99 -47
  331. package/src/artifacts/renderers/canvas/presence.tsx +184 -0
  332. package/src/artifacts/renderers/canvas/previews.ts +127 -0
  333. package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
  334. package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
  335. package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
  336. package/src/artifacts/renderers/slides/slides.tsx +1 -1
  337. package/src/artifacts/version-menu.tsx +438 -0
  338. package/src/artifacts/view-context.ts +102 -0
  339. package/src/artifacts/viewer.tsx +205 -147
  340. package/src/build.ts +96 -11
  341. package/src/codegen.ts +83 -5
  342. package/src/createCustomApp.ts +20 -7
  343. package/src/index.ts +12 -0
  344. package/src/locale-messages.ts +24 -0
  345. package/src/metadata.ts +12 -0
  346. package/src/pages/console/action-run.tsx +20 -0
  347. package/src/pages/console/data/connectors.tsx +27 -3
  348. package/src/pages/console/data/datasets.tsx +30 -1
  349. package/src/pages/console/data/lake-health.tsx +299 -0
  350. package/src/pages/console/data/messages.ts +143 -2
  351. package/src/pages/console/data/pipelines.tsx +91 -3
  352. package/src/pages/console/data/projections.tsx +23 -4
  353. package/src/pages/console/data/syncs.tsx +39 -2
  354. package/src/pages/console/ontology/action-runs.tsx +8 -2
  355. package/src/pages/console/ontology/actions.tsx +39 -15
  356. package/src/pages/console/ontology/components/action-button.tsx +10 -0
  357. package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
  358. package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
  359. package/src/pages/console/ontology/lib/action-params.ts +10 -0
  360. package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
  361. package/src/pages/console/ontology/object-page.tsx +2 -0
  362. package/src/pages/console/ontology/object-type.tsx +73 -14
  363. package/src/pages/console/ontology/object-types.tsx +56 -7
  364. package/src/pages/console/ontology/objects.tsx +167 -19
  365. package/src/pages/console/ontology/rules.tsx +186 -30
  366. package/src/pages/console/ontology/workflow.tsx +130 -74
  367. package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
  368. package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
  369. package/src/pages/console/ontology/workflows.tsx +34 -21
  370. package/src/pages/console/skeletons.tsx +99 -0
  371. package/src/pages/console/workflow-run.tsx +20 -0
  372. package/src/pages/section-page.tsx +37 -7
  373. package/src/pages/section-ui.tsx +96 -13
  374. package/src/pages/settings/activity/calendar.tsx +13 -6
  375. package/src/pages/settings/activity/connections.tsx +26 -9
  376. package/src/pages/settings/activity/page.tsx +31 -4
  377. package/src/pages/settings/activity/thread.tsx +32 -18
  378. package/src/pages/settings/activity/timeline.tsx +39 -0
  379. package/src/pages/settings/controls.tsx +19 -1
  380. package/src/pages/settings/developers.tsx +2 -2
  381. package/src/pages/settings/members.tsx +42 -9
  382. package/src/pages/settings/memory-history.tsx +76 -10
  383. package/src/pages/settings/memory.tsx +47 -5
  384. package/src/pages/settings/service-accounts.tsx +7 -2
  385. package/src/pages/settings/sessions.tsx +6 -2
  386. package/src/pages/settings/usage/breakdown.tsx +62 -2
  387. package/src/pages/settings/usage/limits.tsx +45 -3
  388. package/src/pages/settings/usage/messages.ts +0 -2
  389. package/src/pages/settings/usage/page.tsx +99 -52
  390. package/src/pages/settings/usage/runs.tsx +105 -8
  391. package/src/pages/settings/usage/spend-chart.tsx +79 -45
  392. package/src/pages/settings/usage/spend-model.ts +16 -0
  393. package/src/pages/values.tsx +72 -6
  394. package/src/pages.ts +4 -0
  395. package/src/sections/catalog.ts +6 -0
  396. package/src/sections/sections.tsx +2 -0
  397. package/src/service-worker.ts +176 -0
  398. package/src/shared-session.ts +73 -0
  399. package/src/shell/app-return.ts +115 -0
  400. package/src/shell/app-shell.tsx +125 -27
  401. package/src/shell/nav-items.tsx +2 -0
  402. package/src/shell/phone/back.ts +16 -0
  403. package/src/shell/phone/launch.ts +6 -0
  404. package/src/shell/phone/more-sheet.tsx +249 -0
  405. package/src/shell/phone/phone-foundations.tsx +43 -0
  406. package/src/shell/phone/phone.css +660 -0
  407. package/src/shell/phone/pull-to-refresh.tsx +201 -0
  408. package/src/shell/phone/routes.ts +34 -0
  409. package/src/shell/phone/screen-motion.ts +292 -0
  410. package/src/shell/phone/scroll-restoration.tsx +70 -0
  411. package/src/shell/phone/startup-image.ts +119 -0
  412. package/src/shell/phone/tab-bar.tsx +95 -0
  413. package/src/shell/phone/top-bar.tsx +195 -0
  414. package/src/shell/search-command.tsx +30 -14
  415. package/src/shell/user-menu.tsx +2 -1
  416. package/dist/chunk-4j3c3p72.js +0 -1487
  417. package/dist/chunk-4j3c3p72.js.map +0 -18
  418. package/dist/chunk-4mprsd2n.js.map +0 -10
  419. package/dist/chunk-ytadd0b5.js.map +0 -188
  420. /package/dist/{chunk-j8g956dt.js.map → chunk-fwb9mxwm.js.map} +0 -0
  421. /package/dist/{chunk-7fj9cfkw.js.map → chunk-kes4ygmz.js.map} +0 -0
  422. /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
@@ -0,0 +1,201 @@
1
+ import { isIOS, PHONE_QUERY } from "@sixb/ui/components"
2
+ import { useQueryClient } from "@tanstack/react-query"
3
+ import { type CSSProperties, useEffect, useRef } from "react"
4
+ import { appScroller } from "./routes"
5
+
6
+ // How far the page travels, after resistance, before a release refreshes, and where it rests
7
+ // while the refresh runs.
8
+ const TRIGGER = 72
9
+ const REST = 56
10
+ const MAX_PULL = 140
11
+ const MIN_SPIN_MS = 650
12
+ const TICKS = 8
13
+ const SETTLE = "transform 380ms cubic-bezier(0.32, 0.72, 0, 1), opacity 240ms ease"
14
+
15
+ /**
16
+ * Pull down at the top of any page to refresh what it shows, as native lists do. Installed web
17
+ * apps lose the browser's own pull-to-refresh, so this restores it for the app's data: the page
18
+ * follows the finger with a rubber band, the activity indicator draws its ticks in the gap under
19
+ * the top bar as the pull arms, and every query on screen refetches without reloading the app.
20
+ * An element that owns vertical drags opts out with `data-no-pull-refresh`.
21
+ */
22
+ export function PullToRefresh() {
23
+ const queryClient = useQueryClient()
24
+ const indicator = useRef<HTMLDivElement>(null)
25
+
26
+ useEffect(() => {
27
+ const phone = window.matchMedia(PHONE_QUERY)
28
+ const element = indicator.current
29
+ if (!element) return
30
+
31
+ let scroller: HTMLElement | null = null
32
+ let content: HTMLElement[] = []
33
+ let startY = 0
34
+ let startX = 0
35
+ let pull = 0
36
+ let pulling = false
37
+ let refreshing = false
38
+
39
+ const move = (distance: number, transition: string) => {
40
+ for (const child of content) {
41
+ child.style.transition = transition
42
+ child.style.transform = distance > 0 ? `translate3d(0, ${distance}px, 0)` : ""
43
+ }
44
+ element.style.transition = transition
45
+ element.style.transform = `translate3d(-50%, ${Math.max(0, distance / 2 - 14)}px, 0)`
46
+ }
47
+
48
+ const show = (distance: number) => {
49
+ move(distance, "none")
50
+ const progress = Math.min(distance / TRIGGER, 1)
51
+ element.style.setProperty("--pull-progress", String(progress))
52
+ element.style.opacity = String(Math.min(distance / 28, 1))
53
+ element.toggleAttribute("data-armed", distance >= TRIGGER)
54
+ }
55
+
56
+ const hide = () => {
57
+ move(0, SETTLE)
58
+ element.style.opacity = "0"
59
+ element.removeAttribute("data-armed")
60
+ element.removeAttribute("data-refreshing")
61
+ const settled = content
62
+ window.setTimeout(() => {
63
+ for (const child of settled) child.style.transition = ""
64
+ }, 400)
65
+ }
66
+
67
+ // Moves are only blocked while a pull may start, so every other scroll starts without waiting
68
+ // on script.
69
+ const track = (page: HTMLElement | null) => {
70
+ if (page && !scroller) document.addEventListener("touchmove", onMove, { passive: false })
71
+ if (!page && scroller) document.removeEventListener("touchmove", onMove)
72
+ scroller = page
73
+ }
74
+
75
+ const onStart = (event: TouchEvent) => {
76
+ track(null)
77
+ if (!phone.matches || refreshing || event.touches.length !== 1) return
78
+ const target = event.target instanceof Element ? event.target : null
79
+ const page = appScroller()
80
+ if (!target || !page || !page.contains(target)) return
81
+ if (
82
+ target.closest(
83
+ '[role="dialog"], [data-no-pull-refresh], input, textarea, [contenteditable="true"]'
84
+ )
85
+ )
86
+ return
87
+ if (scrolledAbove(target, page)) return
88
+ track(page)
89
+ startY = event.touches[0].clientY
90
+ startX = event.touches[0].clientX
91
+ pulling = false
92
+ }
93
+
94
+ const onMove = (event: TouchEvent) => {
95
+ if (!scroller) return
96
+ const touch = event.touches[0]
97
+ const dy = touch.clientY - startY
98
+ if (!pulling) {
99
+ if (Math.abs(touch.clientX - startX) > Math.abs(dy) || dy < 0) return track(null)
100
+ if (dy < 6) return
101
+ pulling = true
102
+ content = [...scroller.children].filter(
103
+ (child): child is HTMLElement => child instanceof HTMLElement
104
+ )
105
+ }
106
+ event.preventDefault()
107
+ // Resistance grows with distance, as a rubber band does.
108
+ const travel = dy - 6
109
+ pull = Math.min(MAX_PULL, travel * 0.55 - Math.max(0, travel - TRIGGER * 1.6) * 0.18)
110
+ show(Math.max(0, pull))
111
+ }
112
+
113
+ const onEnd = async () => {
114
+ const wasPulling = scroller !== null && pulling
115
+ track(null)
116
+ if (!wasPulling) return
117
+ pulling = false
118
+ if (pull < TRIGGER) {
119
+ hide()
120
+ return
121
+ }
122
+ refreshing = true
123
+ haptic()
124
+ move(REST, SETTLE)
125
+ element.style.setProperty("--pull-progress", "1")
126
+ element.setAttribute("data-refreshing", "")
127
+ const started = performance.now()
128
+ try {
129
+ await queryClient.refetchQueries({ type: "active" })
130
+ } finally {
131
+ const wait = MIN_SPIN_MS - (performance.now() - started)
132
+ if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait))
133
+ refreshing = false
134
+ hide()
135
+ }
136
+ }
137
+
138
+ document.addEventListener("touchstart", onStart, { passive: true })
139
+ document.addEventListener("touchend", onEnd)
140
+ document.addEventListener("touchcancel", onEnd)
141
+ return () => {
142
+ track(null)
143
+ document.removeEventListener("touchstart", onStart)
144
+ document.removeEventListener("touchend", onEnd)
145
+ document.removeEventListener("touchcancel", onEnd)
146
+ for (const child of content) {
147
+ child.style.transition = ""
148
+ child.style.transform = ""
149
+ }
150
+ }
151
+ }, [queryClient])
152
+
153
+ return (
154
+ <div ref={indicator} className="pull-refresh" aria-hidden="true">
155
+ <svg viewBox="0 0 28 28" className="pull-refresh-spinner">
156
+ {Array.from({ length: TICKS }, (_, tick) => (
157
+ <line
158
+ key={tick}
159
+ x1="14"
160
+ y1="3.5"
161
+ x2="14"
162
+ y2="8.5"
163
+ transform={`rotate(${tick * (360 / TICKS)} 14 14)`}
164
+ style={{ "--tick": tick } as CSSProperties}
165
+ />
166
+ ))}
167
+ </svg>
168
+ </div>
169
+ )
170
+ }
171
+
172
+ /** Whether the page, or a pane between it and the touch, is scrolled away from its top. */
173
+ function scrolledAbove(target: Element, page: HTMLElement): boolean {
174
+ for (let node: Element | null = target; node; node = node.parentElement) {
175
+ if (node.scrollTop > 0) return true
176
+ if (node === page) return false
177
+ }
178
+ return false
179
+ }
180
+
181
+ /**
182
+ * A light tap of the Taptic Engine where the platform allows a web page one, else nothing. iOS has
183
+ * no vibration API for the web, but toggling a native switch plays the system's selection haptic,
184
+ * including one toggled through its label from script while a touch is being handled.
185
+ */
186
+ function haptic(): void {
187
+ if (isIOS()) {
188
+ const label = document.createElement("label")
189
+ label.ariaHidden = "true"
190
+ label.style.display = "none"
191
+ const input = document.createElement("input")
192
+ input.type = "checkbox"
193
+ input.setAttribute("switch", "")
194
+ label.append(input)
195
+ document.head.append(label)
196
+ label.click()
197
+ label.remove()
198
+ return
199
+ }
200
+ navigator.vibrate?.(8)
201
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Where a screen sits in a phone's navigation, read from its address alone: `/quotes` is a
3
+ * top-level screen, `/quotes/q-1` a record pushed on it, and its first segment is its section.
4
+ */
5
+
6
+ /** The page's scroll container, which the shell marks with `data-app-scroll`. */
7
+ export function appScroller(): HTMLElement | null {
8
+ return document.querySelector<HTMLElement>("[data-app-scroll]")
9
+ }
10
+
11
+ export function normalizePath(pathname: string): string {
12
+ return pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname
13
+ }
14
+
15
+ /** A top-level screen, such as Home or a list: it shows its title, never a back button. */
16
+ export function isRootPath(pathname: string): boolean {
17
+ return normalizePath(pathname).split("/").filter(Boolean).length <= 1
18
+ }
19
+
20
+ /** The section a screen belongs to: its first segment, or "" for Home. */
21
+ export function sectionOf(pathname: string): string {
22
+ return normalizePath(pathname).split("/")[1] ?? ""
23
+ }
24
+
25
+ /** The screen above this one: the address without its last segment. */
26
+ export function parentPath(pathname: string): string {
27
+ return normalizePath(pathname).replace(/\/[^/]+$/, "") || "/"
28
+ }
29
+
30
+ /** This history entry's place in the app's history, as the router counts it. */
31
+ export function historyIndex(state: unknown = window.history.state): number {
32
+ const index = (state as { idx?: unknown } | null)?.idx
33
+ return typeof index === "number" ? index : 0
34
+ }
@@ -0,0 +1,292 @@
1
+ import { PHONE_QUERY } from "@sixb/ui/components"
2
+ import { appScroller, historyIndex, isRootPath, normalizePath, sectionOf } from "./routes"
3
+
4
+ /*
5
+ * Native screen transitions on a phone.
6
+ *
7
+ * React swaps a page's content in place, so the screen being left is gone before anything can
8
+ * move. Native navigation keeps both on screen: a pushed screen slides in over the current one,
9
+ * which drifts left and dims; Back does the reverse. So the moment the router changes the URL,
10
+ * before React renders the next page, the current screen is copied into an inert "ghost" laid
11
+ * exactly over it. Once the next page has rendered, the two move together and the ghost is
12
+ * dropped.
13
+ *
14
+ * The back swipe is iOS's own in the installed app, as in Safari: it animates the change itself, so
15
+ * a Back it drives is not animated again.
16
+ */
17
+
18
+ type ScreenMotion = "push" | "pop"
19
+
20
+ const DURATION_MS = 480
21
+ const EASING = "cubic-bezier(0.32, 0.72, 0, 1)"
22
+ // How far the screen underneath sits to the left, as a share of the width.
23
+ const PARALLAX = 0.3
24
+ // A copy larger than this costs more than the transition is worth.
25
+ const MAX_NODES = 6000
26
+ const ID_REFERENCES =
27
+ '[fill^="url"], [stroke^="url"], [clip-path], [mask], [filter], [marker-start], [marker-mid], [marker-end], [style*="url("], [href^="#"], [*|href^="#"]'
28
+
29
+ interface Pending {
30
+ readonly motion: ScreenMotion
31
+ readonly ghost: HTMLElement
32
+ // The address it was copied for; a different one committing means it no longer applies.
33
+ readonly to: string
34
+ }
35
+
36
+ let pending: Pending | null = null
37
+ let lastPath = "/"
38
+ let lastIndex = 0
39
+ let stopCurrent: (() => void) | null = null
40
+ let copies = 0
41
+
42
+ /**
43
+ * Watch the router's history calls so the screen can be copied before React replaces it.
44
+ * Returns the function that stops watching.
45
+ */
46
+ export function watchScreenChanges(): () => void {
47
+ lastPath = normalizePath(window.location.pathname)
48
+ lastIndex = historyIndex()
49
+ const history = window.history
50
+ const pushState = history.pushState
51
+ const replaceState = history.replaceState
52
+
53
+ // Going up to a screen above, such as a tab's first screen or a record after saving its form,
54
+ // moves back the way Back does, even when it is a new history entry.
55
+ history.pushState = function (this: History, ...args: Parameters<History["pushState"]>) {
56
+ const to = targetPath(args[2])
57
+ prepare(to, goesUp(lastPath, to) ? "pop" : "push")
58
+ pushState.apply(this, args)
59
+ }
60
+ history.replaceState = function (this: History, ...args: Parameters<History["replaceState"]>) {
61
+ const to = targetPath(args[2])
62
+ if (to !== lastPath && goesUp(lastPath, to)) prepare(to, "pop")
63
+ replaceState.apply(this, args)
64
+ }
65
+
66
+ // Capturing, so the copy is taken before the router reacts to Back. A Back the system animated
67
+ // itself, as iOS's back swipe does, is not animated again.
68
+ const onPopState = (event: PopStateEvent) => {
69
+ if (event.hasUAVisualTransition) {
70
+ clearPending()
71
+ return
72
+ }
73
+ const index = historyIndex()
74
+ prepare(normalizePath(window.location.pathname), index < lastIndex ? "pop" : "push")
75
+ }
76
+ window.addEventListener("popstate", onPopState, true)
77
+
78
+ return () => {
79
+ history.pushState = pushState
80
+ history.replaceState = replaceState
81
+ window.removeEventListener("popstate", onPopState, true)
82
+ // A screen without the shell, such as a print view, unmounts this; nothing carries over.
83
+ settleScreenMotion()
84
+ clearPending()
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Called once the next page has rendered, before the browser paints it: moves the screens. Reads
90
+ * the address itself, as the history calls it watches carry it, router basename and all.
91
+ */
92
+ export function runScreenMotion(): void {
93
+ const to = normalizePath(window.location.pathname)
94
+ lastPath = to
95
+ lastIndex = historyIndex()
96
+
97
+ const current = pending
98
+ pending = null
99
+ if (!current) return
100
+ const scroller = appScroller()
101
+ if (current.to !== to || !scroller || !scroller.parentElement) {
102
+ current.ghost.remove()
103
+ return
104
+ }
105
+
106
+ slide(scroller, current.ghost, current.motion, () => current.ghost.remove())
107
+ }
108
+
109
+ /**
110
+ * Lay a screen copy under or over the page scroller, at the scroller's own scroll position, with
111
+ * the dimming layer between them.
112
+ */
113
+ function mountGhost(
114
+ ghost: HTMLElement,
115
+ scroller: HTMLElement,
116
+ place: "under" | "over"
117
+ ): { readonly dim: HTMLElement; readonly remove: () => void } {
118
+ const parent = scroller.parentElement as HTMLElement
119
+ const dim = document.createElement("div")
120
+ dim.className = "screen-dim"
121
+ dim.setAttribute("aria-hidden", "true")
122
+ scroller.dataset.screenMoving = place === "under" ? "over" : "under"
123
+ // Over the scroller alone: its parent can also hold a panel beside it, such as the agent dock.
124
+ const box = `top:${scroller.offsetTop}px;left:${scroller.offsetLeft}px;width:${scroller.offsetWidth}px;height:${scroller.offsetHeight}px`
125
+ dim.style.cssText = box
126
+ ghost.style.cssText += `;${box}`
127
+ parent.append(dim)
128
+ ghost.dataset.place = place
129
+ parent.append(ghost)
130
+ ghost.scrollTop = Number(ghost.dataset.scrollTop ?? 0)
131
+ return {
132
+ dim,
133
+ remove: () => {
134
+ dim.remove()
135
+ ghost.remove()
136
+ delete scroller.dataset.screenMoving
137
+ },
138
+ }
139
+ }
140
+
141
+ /** End any transition still running, leaving the current screen in place. */
142
+ function settleScreenMotion(): void {
143
+ stopCurrent?.()
144
+ stopCurrent = null
145
+ }
146
+
147
+ function clearPending() {
148
+ pending?.ghost.remove()
149
+ pending = null
150
+ }
151
+
152
+ function prepare(to: string, motion: ScreenMotion) {
153
+ settleScreenMotion()
154
+ clearPending()
155
+ if (!movesScreen(lastPath, to)) return
156
+ const scroller = appScroller()
157
+ if (!scroller || !scroller.parentElement) return
158
+ const ghost = copyScreen(scroller)
159
+ if (!ghost) return
160
+ pending = { motion, ghost, to }
161
+ }
162
+
163
+ /**
164
+ * Screens within a section push and pop. Moving between sections, or between top-level screens,
165
+ * swaps in place, as switching tabs does natively.
166
+ */
167
+ function movesScreen(from: string, to: string): boolean {
168
+ if (from === to) return false
169
+ if (!window.matchMedia(PHONE_QUERY).matches) return false
170
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return false
171
+ if (sectionOf(from) !== sectionOf(to)) return false
172
+ if (isRootPath(from) && isRootPath(to)) return false
173
+ return true
174
+ }
175
+
176
+ /** Whether `to` sits above `from`: a top-level screen, or a parent address. */
177
+ function goesUp(from: string, to: string): boolean {
178
+ return (isRootPath(to) && !isRootPath(from)) || from.startsWith(`${to === "/" ? "" : to}/`)
179
+ }
180
+
181
+ function copyScreen(scroller: HTMLElement): HTMLElement | null {
182
+ if (scroller.getElementsByTagName("*").length > MAX_NODES) return null
183
+ const ghost = scroller.cloneNode(true) as HTMLElement
184
+ // Keeps the scroller's own styles; lookups find the real scroller first, as it comes first.
185
+ ghost.dataset.appScroll = "ghost"
186
+ ghost.removeAttribute("data-screen-moving")
187
+ const style = getComputedStyle(scroller)
188
+ ghost.style.paddingTop = style.paddingTop
189
+ ghost.style.paddingBottom = style.paddingBottom
190
+ ghost.removeAttribute("id")
191
+ ghost.classList.add("screen-ghost")
192
+ ghost.setAttribute("aria-hidden", "true")
193
+ ghost.inert = true
194
+ ghost.dataset.scrollTop = String(scroller.scrollTop)
195
+
196
+ // Copies of frames and media would load again; a canvas copies blank, so paint it in.
197
+ for (const media of ghost.querySelectorAll("iframe, video, audio, object, embed")) {
198
+ const stand = document.createElement("div")
199
+ stand.className = (media as HTMLElement).className
200
+ stand.style.cssText = (media as HTMLElement).style.cssText
201
+ media.replaceWith(stand)
202
+ }
203
+ const sources = scroller.querySelectorAll("canvas")
204
+ ghost.querySelectorAll("canvas").forEach((canvas, index) => {
205
+ const source = sources[index]
206
+ if (!source || source.width === 0 || source.height === 0) return
207
+ try {
208
+ canvas.getContext("2d")?.drawImage(source, 0, 0)
209
+ } catch {
210
+ // A tainted or WebGL canvas stays blank in the copy.
211
+ }
212
+ })
213
+ renameIds(ghost)
214
+ return ghost
215
+ }
216
+
217
+ /**
218
+ * Ids must stay unique on the page, so the copy's get a suffix, and what points at them inside
219
+ * it, such as a chart's gradient fill, follows.
220
+ */
221
+ function renameIds(ghost: HTMLElement) {
222
+ const suffix = `-screen-${++copies}`
223
+ const renamed = new Set<string>()
224
+ for (const element of ghost.querySelectorAll("[id]")) {
225
+ renamed.add(element.id)
226
+ element.id += suffix
227
+ }
228
+ if (!renamed.size) return
229
+ const reference = /url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/g
230
+ const follow = (value: string) =>
231
+ value.replace(reference, (match, quote: string, id: string) =>
232
+ renamed.has(id) ? `url(${quote}#${id}${suffix}${quote})` : match
233
+ )
234
+ // Only what can point at an id: an SVG paint, clip, mask or filter, a style, or a local href.
235
+ for (const element of ghost.querySelectorAll(ID_REFERENCES)) {
236
+ for (const { name, value } of [...element.attributes]) {
237
+ if (value.includes("url(")) {
238
+ element.setAttribute(name, follow(value))
239
+ } else if (
240
+ (name === "href" || name === "xlink:href") &&
241
+ value.startsWith("#") &&
242
+ renamed.has(value.slice(1))
243
+ ) {
244
+ element.setAttribute(name, `${value}${suffix}`)
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ function slide(scroller: HTMLElement, ghost: HTMLElement, motion: ScreenMotion, done: () => void) {
251
+ const width = scroller.offsetWidth
252
+ const { dim, remove } = mountGhost(ghost, scroller, motion === "push" ? "under" : "over")
253
+ const timing: KeyframeAnimationOptions = { duration: DURATION_MS, easing: EASING }
254
+ const away = `translate3d(${-width * PARALLAX}px, 0, 0)`
255
+ const off = `translate3d(${width}px, 0, 0)`
256
+ const still = "translate3d(0, 0, 0)"
257
+
258
+ const animations =
259
+ motion === "push"
260
+ ? [
261
+ scroller.animate({ transform: [off, still] }, timing),
262
+ ghost.animate({ transform: [still, away] }, timing),
263
+ dim.animate({ opacity: [0, 1] }, timing),
264
+ ]
265
+ : [
266
+ scroller.animate({ transform: [away, still] }, timing),
267
+ ghost.animate({ transform: [still, off] }, timing),
268
+ dim.animate({ opacity: [1, 0] }, timing),
269
+ ]
270
+
271
+ let finished = false
272
+ const finish = () => {
273
+ if (finished) return
274
+ finished = true
275
+ for (const animation of animations) animation.cancel()
276
+ remove()
277
+ done()
278
+ if (stopCurrent === finish) stopCurrent = null
279
+ }
280
+ void Promise.all(animations.map((animation) => animation.finished)).then(finish, finish)
281
+ // A new navigation mid-flight ends this one at once.
282
+ stopCurrent = finish
283
+ }
284
+
285
+ function targetPath(url: string | URL | null | undefined): string {
286
+ if (url == null) return lastPath
287
+ try {
288
+ return normalizePath(new URL(String(url), window.location.href).pathname)
289
+ } catch {
290
+ return lastPath
291
+ }
292
+ }
@@ -0,0 +1,70 @@
1
+ import { useEffect, useLayoutEffect, useRef } from "react"
2
+ import { useLocation, useNavigationType } from "react-router-dom"
3
+ import { appScroller } from "./routes"
4
+
5
+ // Data can take a moment to arrive; until the page is tall enough the saved position can't apply.
6
+ const RESTORE_WINDOW_MS = 1500
7
+
8
+ /**
9
+ * The app scrolls inside one container that stays mounted between pages, so the browser can't
10
+ * manage its position. A new screen starts at the top; Back comes back to where the screen was
11
+ * left. Changing only the query string, such as a filter, keeps the position.
12
+ */
13
+ export function ScrollRestoration() {
14
+ const location = useLocation()
15
+ const navigationType = useNavigationType()
16
+ const positions = useRef(new Map<string, number>())
17
+ const previousPath = useRef(location.pathname)
18
+
19
+ useEffect(() => {
20
+ const scroller = appScroller()
21
+ if (!scroller) return
22
+ const key = location.key
23
+ const path = location.pathname + location.search
24
+ const save = () => {
25
+ // The next screen resets the scroller before this listener is gone; that isn't this screen.
26
+ if (window.location.pathname + window.location.search !== path) return
27
+ positions.current.set(key, scroller.scrollTop)
28
+ }
29
+ scroller.addEventListener("scroll", save, { passive: true })
30
+ return () => scroller.removeEventListener("scroll", save)
31
+ }, [location.key, location.pathname, location.search])
32
+
33
+ // biome-ignore lint/correctness/useExhaustiveDependencies: runs once per navigation, keyed by it.
34
+ useLayoutEffect(() => {
35
+ const scroller = appScroller()
36
+ const samePath = previousPath.current === location.pathname
37
+ previousPath.current = location.pathname
38
+ if (!scroller || (navigationType !== "POP" && samePath)) return
39
+
40
+ const target = navigationType === "POP" ? (positions.current.get(location.key) ?? 0) : 0
41
+ scroller.scrollTop = target
42
+ if (target === 0) return
43
+
44
+ let frame = 0
45
+ let interrupted = false
46
+ const started = performance.now()
47
+ const interrupt = () => {
48
+ interrupted = true
49
+ }
50
+ const retry = () => {
51
+ if (interrupted) return
52
+ if (scroller.scrollHeight - scroller.clientHeight >= target) {
53
+ scroller.scrollTop = target
54
+ return
55
+ }
56
+ if (performance.now() - started < RESTORE_WINDOW_MS) frame = requestAnimationFrame(retry)
57
+ }
58
+ scroller.addEventListener("touchstart", interrupt, { passive: true })
59
+ scroller.addEventListener("wheel", interrupt, { passive: true })
60
+ frame = requestAnimationFrame(retry)
61
+
62
+ return () => {
63
+ cancelAnimationFrame(frame)
64
+ scroller.removeEventListener("touchstart", interrupt)
65
+ scroller.removeEventListener("wheel", interrupt)
66
+ }
67
+ }, [location.key])
68
+
69
+ return null
70
+ }