@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.
- package/dist/agent/agent-chat.d.ts +9 -2
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts +9 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/agent-surface.d.ts.map +1 -1
- package/dist/agent/artifact-card.d.ts +3 -1
- package/dist/agent/artifact-card.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +7 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/components/composer-place.d.ts +3 -1
- package/dist/agent/components/composer-place.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +20 -1
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-chips.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/conversation-panel.d.ts +3 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +3 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
- package/dist/agent/composer-insertion.d.ts +24 -0
- package/dist/agent/composer-insertion.d.ts.map +1 -0
- package/dist/agent/delegation/use-children.d.ts +5 -5
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-new-thread-place.d.ts +39 -17
- package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +14 -0
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +20 -0
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +8 -2
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
- package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
- package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
- package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/types.d.ts +3 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/artifacts/artifact-page.d.ts.map +1 -1
- package/dist/artifacts/artifact-viewer.d.ts +16 -0
- package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
- package/dist/artifacts/card-details.d.ts +1 -1
- package/dist/artifacts/card-details.d.ts.map +1 -1
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/comments-context.d.ts +48 -0
- package/dist/artifacts/comments-context.d.ts.map +1 -0
- package/dist/artifacts/edit-session.d.ts +6 -6
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame.d.ts +10 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/guest-badge.d.ts +8 -0
- package/dist/artifacts/guest-badge.d.ts.map +1 -0
- package/dist/artifacts/held-artifact.d.ts +19 -0
- package/dist/artifacts/held-artifact.d.ts.map +1 -0
- package/dist/artifacts/holders.d.ts +10 -0
- package/dist/artifacts/holders.d.ts.map +1 -0
- package/dist/artifacts/live/boards.d.ts +15 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -0
- package/dist/artifacts/live/canvas.d.ts +79 -0
- package/dist/artifacts/live/canvas.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +29 -0
- package/dist/artifacts/live/header.d.ts.map +1 -0
- package/dist/artifacts/live/hooks.d.ts +21 -0
- package/dist/artifacts/live/hooks.d.ts.map +1 -0
- package/dist/artifacts/live/presence.d.ts +32 -0
- package/dist/artifacts/live/presence.d.ts.map +1 -0
- package/dist/artifacts/live/session.d.ts +130 -0
- package/dist/artifacts/live/session.d.ts.map +1 -0
- package/dist/artifacts/live/view.d.ts +28 -0
- package/dist/artifacts/live/view.d.ts.map +1 -0
- package/dist/artifacts/messages.d.ts +424 -14
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/page-queries.d.ts +2 -2
- package/dist/artifacts/page-queries.d.ts.map +1 -1
- package/dist/artifacts/page-state.d.ts.map +1 -1
- package/dist/artifacts/publish-edit.d.ts +24 -14
- package/dist/artifacts/publish-edit.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +490 -9
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
- package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +43 -0
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
- package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
- package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/board.d.ts +64 -19
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +13 -4
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
- package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
- package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
- package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +40 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
- package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
- package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
- package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
- package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
- package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
- package/dist/artifacts/version-menu.d.ts +19 -0
- package/dist/artifacts/version-menu.d.ts.map +1 -0
- package/dist/artifacts/view-context.d.ts +43 -0
- package/dist/artifacts/view-context.d.ts.map +1 -0
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/build.d.ts +5 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/{chunk-ytadd0b5.js → chunk-001c4gnk.js} +6871 -3756
- package/dist/chunk-001c4gnk.js.map +204 -0
- package/dist/chunk-00wggsst.js +7 -0
- package/dist/chunk-00wggsst.js.map +10 -0
- package/dist/chunk-5crvhjp2.js +4704 -0
- package/dist/chunk-5crvhjp2.js.map +28 -0
- package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
- package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
- package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
- package/dist/chunk-fg6thecb.js.map +10 -0
- package/dist/{chunk-j8g956dt.js → chunk-fwb9mxwm.js} +1 -1
- package/dist/{chunk-7fj9cfkw.js → chunk-kes4ygmz.js} +1 -1
- package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
- package/dist/codegen.d.ts.map +1 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +930 -309
- package/dist/index.js.map +15 -10
- package/dist/locale-messages.d.ts +12 -0
- package/dist/locale-messages.d.ts.map +1 -1
- package/dist/locale.d.ts +12 -0
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +1 -1
- package/dist/metadata.d.ts +8 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/pages/console/action-run.d.ts.map +1 -1
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/datasets.d.ts.map +1 -1
- package/dist/pages/console/data/lake-health.d.ts +3 -0
- package/dist/pages/console/data/lake-health.d.ts.map +1 -0
- package/dist/pages/console/data/messages.d.ts +98 -2
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/pipelines.d.ts.map +1 -1
- package/dist/pages/console/data/projections.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
- package/dist/pages/console/ontology/actions.d.ts.map +1 -1
- package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
- package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
- package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
- package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
- package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
- package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
- package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
- package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
- package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
- package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
- package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
- package/dist/pages/console/ontology/objects.d.ts.map +1 -1
- package/dist/pages/console/ontology/rules.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
- package/dist/pages/console/skeletons.d.ts +30 -0
- package/dist/pages/console/skeletons.d.ts.map +1 -0
- package/dist/pages/console/workflow-run.d.ts.map +1 -1
- package/dist/pages/section-page.d.ts +11 -1
- package/dist/pages/section-page.d.ts.map +1 -1
- package/dist/pages/section-ui.d.ts +25 -3
- package/dist/pages/section-ui.d.ts.map +1 -1
- package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
- package/dist/pages/settings/activity/connections.d.ts.map +1 -1
- package/dist/pages/settings/activity/page.d.ts.map +1 -1
- package/dist/pages/settings/activity/thread.d.ts.map +1 -1
- package/dist/pages/settings/activity/timeline.d.ts +2 -0
- package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
- package/dist/pages/settings/controls.d.ts +4 -0
- package/dist/pages/settings/controls.d.ts.map +1 -1
- package/dist/pages/settings/members.d.ts.map +1 -1
- package/dist/pages/settings/memory-history.d.ts +2 -0
- package/dist/pages/settings/memory-history.d.ts.map +1 -1
- package/dist/pages/settings/memory.d.ts.map +1 -1
- package/dist/pages/settings/service-accounts.d.ts.map +1 -1
- package/dist/pages/settings/sessions.d.ts.map +1 -1
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/limits.d.ts.map +1 -1
- package/dist/pages/settings/usage/messages.d.ts +0 -2
- package/dist/pages/settings/usage/messages.d.ts.map +1 -1
- package/dist/pages/settings/usage/runs.d.ts +8 -2
- package/dist/pages/settings/usage/runs.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +5 -0
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages/values.d.ts +6 -0
- package/dist/pages/values.d.ts.map +1 -1
- package/dist/pages.d.ts +4 -0
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +8188 -4841
- package/dist/pages.js.map +56 -47
- package/dist/sections/catalog.d.ts.map +1 -1
- package/dist/sections/sections.d.ts.map +1 -1
- package/dist/server.js +294 -23
- package/dist/server.js.map +8 -7
- package/dist/service-worker.d.ts +39 -0
- package/dist/service-worker.d.ts.map +1 -0
- package/dist/shared-session.d.ts +25 -0
- package/dist/shared-session.d.ts.map +1 -0
- package/dist/shell/app-return.d.ts +35 -0
- package/dist/shell/app-return.d.ts.map +1 -0
- package/dist/shell/app-shell.d.ts +1 -1
- package/dist/shell/app-shell.d.ts.map +1 -1
- package/dist/shell/nav-items.d.ts +2 -0
- package/dist/shell/nav-items.d.ts.map +1 -1
- package/dist/shell/phone/back.d.ts +6 -0
- package/dist/shell/phone/back.d.ts.map +1 -0
- package/dist/shell/phone/launch.d.ts +7 -0
- package/dist/shell/phone/launch.d.ts.map +1 -0
- package/dist/shell/phone/more-sheet.d.ts +36 -0
- package/dist/shell/phone/more-sheet.d.ts.map +1 -0
- package/dist/shell/phone/phone-foundations.d.ts +9 -0
- package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
- package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
- package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
- package/dist/shell/phone/routes.d.ts +12 -0
- package/dist/shell/phone/routes.d.ts.map +1 -0
- package/dist/shell/phone/screen-motion.d.ts +11 -0
- package/dist/shell/phone/screen-motion.d.ts.map +1 -0
- package/dist/shell/phone/scroll-restoration.d.ts +7 -0
- package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
- package/dist/shell/phone/startup-image.d.ts +17 -0
- package/dist/shell/phone/startup-image.d.ts.map +1 -0
- package/dist/shell/phone/tab-bar.d.ts +14 -0
- package/dist/shell/phone/tab-bar.d.ts.map +1 -0
- package/dist/shell/phone/top-bar.d.ts +24 -0
- package/dist/shell/phone/top-bar.d.ts.map +1 -0
- package/dist/shell/search-command.d.ts +3 -1
- package/dist/shell/search-command.d.ts.map +1 -1
- package/dist/shell/user-menu.d.ts +2 -0
- package/dist/shell/user-menu.d.ts.map +1 -1
- package/package.json +8 -5
- package/src/agent/agent-chat.tsx +51 -8
- package/src/agent/agent-panel.tsx +12 -0
- package/src/agent/agent-surface.tsx +4 -0
- package/src/agent/artifact-card.tsx +84 -16
- package/src/agent/artifact-panel.tsx +63 -43
- package/src/agent/components/agent-message-body.tsx +1 -1
- package/src/agent/components/composer-place.tsx +77 -53
- package/src/agent/components/composer.tsx +92 -7
- package/src/agent/components/context-chips.tsx +72 -2
- package/src/agent/components/conversation-panel.tsx +3 -2
- package/src/agent/components/message-parts.tsx +6 -1
- package/src/agent/components/thread-artifacts-menu.tsx +22 -5
- package/src/agent/composer-insertion.ts +36 -0
- package/src/agent/hooks/use-agent-conversation.ts +41 -10
- package/src/agent/hooks/use-new-thread-place.ts +149 -25
- package/src/agent/i18n/en.ts +14 -0
- package/src/agent/i18n/fr.ts +12 -0
- package/src/agent/publish-artifact/interpret.ts +27 -5
- package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
- package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/tool-views/built-in.tsx +3 -0
- package/src/agent/types.ts +4 -0
- package/src/artifacts/artifact-page.tsx +42 -17
- package/src/artifacts/artifact-viewer.tsx +56 -0
- package/src/artifacts/artifacts.css +80 -0
- package/src/artifacts/card-details.ts +2 -2
- package/src/artifacts/card-preview.tsx +17 -3
- package/src/artifacts/comments-context.ts +125 -0
- package/src/artifacts/edit-session.tsx +6 -6
- package/src/artifacts/file-source.ts +10 -3
- package/src/artifacts/frame.tsx +50 -12
- package/src/artifacts/gallery.tsx +9 -11
- package/src/artifacts/guest-badge.tsx +21 -0
- package/src/artifacts/held-artifact.tsx +241 -0
- package/src/artifacts/holders.tsx +170 -0
- package/src/artifacts/live/boards.ts +95 -0
- package/src/artifacts/live/canvas.ts +402 -0
- package/src/artifacts/live/header.tsx +137 -0
- package/src/artifacts/live/hooks.ts +94 -0
- package/src/artifacts/live/presence.ts +147 -0
- package/src/artifacts/live/session.ts +520 -0
- package/src/artifacts/live/view.ts +81 -0
- package/src/artifacts/messages.ts +415 -24
- package/src/artifacts/page-queries.ts +2 -3
- package/src/artifacts/page-state.ts +16 -7
- package/src/artifacts/publish-edit.ts +50 -22
- package/src/artifacts/queries.ts +108 -10
- package/src/artifacts/references/references.tsx +6 -9
- package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
- package/src/artifacts/renderers/canvas/board-editor.tsx +817 -0
- package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
- package/src/artifacts/renderers/canvas/board-source.ts +110 -0
- package/src/artifacts/renderers/canvas/board.tsx +309 -33
- package/src/artifacts/renderers/canvas/canvas.tsx +387 -72
- package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
- package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
- package/src/artifacts/renderers/canvas/comments.ts +225 -0
- package/src/artifacts/renderers/canvas/draft.ts +41 -50
- package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
- package/src/artifacts/renderers/canvas/focus.tsx +175 -24
- package/src/artifacts/renderers/canvas/items.tsx +179 -52
- package/src/artifacts/renderers/canvas/layout.ts +99 -47
- package/src/artifacts/renderers/canvas/presence.tsx +184 -0
- package/src/artifacts/renderers/canvas/previews.ts +127 -0
- package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
- package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
- package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
- package/src/artifacts/renderers/slides/slides.tsx +1 -1
- package/src/artifacts/version-menu.tsx +438 -0
- package/src/artifacts/view-context.ts +102 -0
- package/src/artifacts/viewer.tsx +205 -147
- package/src/build.ts +96 -11
- package/src/codegen.ts +83 -5
- package/src/createCustomApp.ts +20 -7
- package/src/index.ts +12 -0
- package/src/locale-messages.ts +24 -0
- package/src/metadata.ts +12 -0
- package/src/pages/console/action-run.tsx +20 -0
- package/src/pages/console/data/connectors.tsx +27 -3
- package/src/pages/console/data/datasets.tsx +30 -1
- package/src/pages/console/data/lake-health.tsx +299 -0
- package/src/pages/console/data/messages.ts +143 -2
- package/src/pages/console/data/pipelines.tsx +91 -3
- package/src/pages/console/data/projections.tsx +23 -4
- package/src/pages/console/data/syncs.tsx +39 -2
- package/src/pages/console/ontology/action-runs.tsx +8 -2
- package/src/pages/console/ontology/actions.tsx +39 -15
- package/src/pages/console/ontology/components/action-button.tsx +10 -0
- package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
- package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
- package/src/pages/console/ontology/lib/action-params.ts +10 -0
- package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
- package/src/pages/console/ontology/object-page.tsx +2 -0
- package/src/pages/console/ontology/object-type.tsx +73 -14
- package/src/pages/console/ontology/object-types.tsx +56 -7
- package/src/pages/console/ontology/objects.tsx +167 -19
- package/src/pages/console/ontology/rules.tsx +186 -30
- package/src/pages/console/ontology/workflow.tsx +130 -74
- package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
- package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
- package/src/pages/console/ontology/workflows.tsx +34 -21
- package/src/pages/console/skeletons.tsx +99 -0
- package/src/pages/console/workflow-run.tsx +20 -0
- package/src/pages/section-page.tsx +37 -7
- package/src/pages/section-ui.tsx +96 -13
- package/src/pages/settings/activity/calendar.tsx +13 -6
- package/src/pages/settings/activity/connections.tsx +26 -9
- package/src/pages/settings/activity/page.tsx +31 -4
- package/src/pages/settings/activity/thread.tsx +32 -18
- package/src/pages/settings/activity/timeline.tsx +39 -0
- package/src/pages/settings/controls.tsx +19 -1
- package/src/pages/settings/developers.tsx +2 -2
- package/src/pages/settings/members.tsx +42 -9
- package/src/pages/settings/memory-history.tsx +76 -10
- package/src/pages/settings/memory.tsx +47 -5
- package/src/pages/settings/service-accounts.tsx +7 -2
- package/src/pages/settings/sessions.tsx +6 -2
- package/src/pages/settings/usage/breakdown.tsx +62 -2
- package/src/pages/settings/usage/limits.tsx +45 -3
- package/src/pages/settings/usage/messages.ts +0 -2
- package/src/pages/settings/usage/page.tsx +99 -52
- package/src/pages/settings/usage/runs.tsx +105 -8
- package/src/pages/settings/usage/spend-chart.tsx +79 -45
- package/src/pages/settings/usage/spend-model.ts +16 -0
- package/src/pages/values.tsx +72 -6
- package/src/pages.ts +4 -0
- package/src/sections/catalog.ts +6 -0
- package/src/sections/sections.tsx +2 -0
- package/src/service-worker.ts +176 -0
- package/src/shared-session.ts +73 -0
- package/src/shell/app-return.ts +115 -0
- package/src/shell/app-shell.tsx +125 -27
- package/src/shell/nav-items.tsx +2 -0
- package/src/shell/phone/back.ts +16 -0
- package/src/shell/phone/launch.ts +6 -0
- package/src/shell/phone/more-sheet.tsx +249 -0
- package/src/shell/phone/phone-foundations.tsx +43 -0
- package/src/shell/phone/phone.css +660 -0
- package/src/shell/phone/pull-to-refresh.tsx +201 -0
- package/src/shell/phone/routes.ts +34 -0
- package/src/shell/phone/screen-motion.ts +292 -0
- package/src/shell/phone/scroll-restoration.tsx +70 -0
- package/src/shell/phone/startup-image.ts +119 -0
- package/src/shell/phone/tab-bar.tsx +95 -0
- package/src/shell/phone/top-bar.tsx +195 -0
- package/src/shell/search-command.tsx +30 -14
- package/src/shell/user-menu.tsx +2 -1
- package/dist/chunk-4j3c3p72.js +0 -1487
- package/dist/chunk-4j3c3p72.js.map +0 -18
- package/dist/chunk-4mprsd2n.js.map +0 -10
- package/dist/chunk-ytadd0b5.js.map +0 -188
- /package/dist/{chunk-j8g956dt.js.map → chunk-fwb9mxwm.js.map} +0 -0
- /package/dist/{chunk-7fj9cfkw.js.map → chunk-kes4ygmz.js.map} +0 -0
- /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { ListArtifactHoldersResponse } from "@sixb/client"
|
|
2
|
+
import { listArtifactHoldersOptions, listObjectTypesOptions } from "@sixb/client/hooks"
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuLabel,
|
|
8
|
+
DropdownMenuTrigger,
|
|
9
|
+
} from "@sixb/ui/components"
|
|
10
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
11
|
+
import { useQuery } from "@tanstack/react-query"
|
|
12
|
+
import { Box, ChevronDown } from "lucide-react"
|
|
13
|
+
import type { ReactNode } from "react"
|
|
14
|
+
import { Link } from "react-router-dom"
|
|
15
|
+
import { humanizeIdentifier } from "../pages/console/ontology/lib/labels"
|
|
16
|
+
import { objectHref } from "../pages/routes"
|
|
17
|
+
import { useSharedGuest } from "../shared-session"
|
|
18
|
+
import { useArtifactMessages } from "./messages"
|
|
19
|
+
|
|
20
|
+
type Holder = ListArtifactHoldersResponse["holders"][number]
|
|
21
|
+
|
|
22
|
+
/** Who holds an artifact changes rarely, and only by an edit to an object. */
|
|
23
|
+
const HOLDERS_STALE_MS = 60_000
|
|
24
|
+
|
|
25
|
+
const PILL =
|
|
26
|
+
"inline-flex h-6 max-w-[14rem] min-w-0 shrink items-center gap-1.5 rounded-full border border-border/80 bg-card pr-2 pl-1.5 text-xs font-medium text-muted-foreground shadow-[0_1px_1px_rgb(0_0_0/0.03)] outline-none transition-colors hover:border-border hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:border-border data-[state=open]:text-foreground"
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The objects an artifact belongs to, beside its title: the one that holds it, as a pill that opens
|
|
30
|
+
* its page, or the first of several with the others a click away. A narrow header, as a phone's,
|
|
31
|
+
* keeps the title's room: the pill is its icon, which lists them. Only those the reader can see
|
|
32
|
+
* are listed; an artifact no object holds, for this reader, shows nothing.
|
|
33
|
+
*/
|
|
34
|
+
export function ArtifactHolders({ artifactId }: { readonly artifactId: string }) {
|
|
35
|
+
const messages = useArtifactMessages().viewer
|
|
36
|
+
const { data } = useQuery({
|
|
37
|
+
...listArtifactHoldersOptions({ path: { artifactId } }),
|
|
38
|
+
staleTime: HOLDERS_STALE_MS,
|
|
39
|
+
retry: false,
|
|
40
|
+
})
|
|
41
|
+
const label = useHolderLabel()
|
|
42
|
+
const guest = useSharedGuest() !== null
|
|
43
|
+
|
|
44
|
+
const holders = data?.holders ?? []
|
|
45
|
+
const [first] = holders
|
|
46
|
+
if (!first) return null
|
|
47
|
+
|
|
48
|
+
const others = holders.length - 1 + (data?.hasMore ? 1 : 0)
|
|
49
|
+
const named =
|
|
50
|
+
others === 0
|
|
51
|
+
? `${messages.belongsTo} ${label(first)}`
|
|
52
|
+
: messages.belongsToMany(holders.length, data?.hasMore ?? false)
|
|
53
|
+
|
|
54
|
+
// A shared link's guest reads the objects their link shares, not the app's pages about them:
|
|
55
|
+
// the pill says what holds the artifact, and goes nowhere.
|
|
56
|
+
if (guest) {
|
|
57
|
+
return (
|
|
58
|
+
<span title={named} aria-label={named} className={cn(PILL, "hover:border-border/80")}>
|
|
59
|
+
<ObjectIcon />
|
|
60
|
+
<span className="hidden truncate @md:inline">{label(first)}</span>
|
|
61
|
+
{others > 0 ? (
|
|
62
|
+
<span className="hidden shrink-0 tabular-nums @md:inline">
|
|
63
|
+
{messages.andMore(others)}
|
|
64
|
+
</span>
|
|
65
|
+
) : null}
|
|
66
|
+
</span>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const wide =
|
|
71
|
+
others === 0 ? (
|
|
72
|
+
<Link
|
|
73
|
+
to={objectHref(first.objectTypeId, first.primaryId)}
|
|
74
|
+
title={named}
|
|
75
|
+
aria-label={named}
|
|
76
|
+
className={PILL}
|
|
77
|
+
>
|
|
78
|
+
<ObjectIcon />
|
|
79
|
+
<span className="truncate">{label(first)}</span>
|
|
80
|
+
</Link>
|
|
81
|
+
) : (
|
|
82
|
+
<HolderMenu holders={holders} label={label} named={named} className={PILL}>
|
|
83
|
+
<ObjectIcon />
|
|
84
|
+
<span className="truncate">{label(first)}</span>
|
|
85
|
+
<span className="shrink-0 tabular-nums">{messages.andMore(others)}</span>
|
|
86
|
+
<ChevronDown className="size-3 shrink-0 opacity-70" aria-hidden="true" />
|
|
87
|
+
</HolderMenu>
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<span className="hidden min-w-0 @md:contents">{wide}</span>
|
|
93
|
+
<span className="contents @md:hidden">
|
|
94
|
+
<HolderMenu
|
|
95
|
+
holders={holders}
|
|
96
|
+
label={label}
|
|
97
|
+
named={named}
|
|
98
|
+
className={cn(PILL, "w-6 shrink-0 justify-center px-0")}
|
|
99
|
+
>
|
|
100
|
+
<ObjectIcon />
|
|
101
|
+
</HolderMenu>
|
|
102
|
+
</span>
|
|
103
|
+
</>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function ObjectIcon() {
|
|
108
|
+
return (
|
|
109
|
+
<Box className="size-3 shrink-0 text-emerald-600 dark:text-emerald-400" aria-hidden="true" />
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The holders as a menu, each opening its object's page. */
|
|
114
|
+
function HolderMenu({
|
|
115
|
+
holders,
|
|
116
|
+
label,
|
|
117
|
+
named,
|
|
118
|
+
className,
|
|
119
|
+
children,
|
|
120
|
+
}: {
|
|
121
|
+
readonly holders: readonly Holder[]
|
|
122
|
+
readonly label: (holder: Holder) => string
|
|
123
|
+
/** What the trigger says to assistive technology, and on hover. */
|
|
124
|
+
readonly named: string
|
|
125
|
+
readonly className: string
|
|
126
|
+
readonly children: ReactNode
|
|
127
|
+
}) {
|
|
128
|
+
const messages = useArtifactMessages().viewer
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<DropdownMenu>
|
|
132
|
+
<DropdownMenuTrigger aria-label={named} title={named} className={className}>
|
|
133
|
+
{children}
|
|
134
|
+
</DropdownMenuTrigger>
|
|
135
|
+
|
|
136
|
+
<DropdownMenuContent align="start" className="w-72 max-w-[calc(100vw-1.5rem)]">
|
|
137
|
+
<DropdownMenuLabel>{messages.belongsTo}</DropdownMenuLabel>
|
|
138
|
+
{holders.map((holder) => (
|
|
139
|
+
<DropdownMenuItem
|
|
140
|
+
key={`${holder.objectTypeId}:${holder.primaryId}:${holder.propertyId}`}
|
|
141
|
+
asChild
|
|
142
|
+
className="gap-2.5"
|
|
143
|
+
>
|
|
144
|
+
<Link to={objectHref(holder.objectTypeId, holder.primaryId)}>
|
|
145
|
+
<Box className="size-4 text-emerald-600 dark:text-emerald-400" />
|
|
146
|
+
<span className="min-w-0 flex-1 truncate">{label(holder)}</span>
|
|
147
|
+
</Link>
|
|
148
|
+
</DropdownMenuItem>
|
|
149
|
+
))}
|
|
150
|
+
</DropdownMenuContent>
|
|
151
|
+
</DropdownMenu>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* How a holder reads: the object's title and the property that holds the artifact, as
|
|
157
|
+
* "NLM-23077 · Onboarding plan". An object whose type has no title reads as its type and key.
|
|
158
|
+
*/
|
|
159
|
+
function useHolderLabel(): (holder: Holder) => string {
|
|
160
|
+
const types = useQuery({ ...listObjectTypesOptions(), staleTime: HOLDERS_STALE_MS, retry: false })
|
|
161
|
+
|
|
162
|
+
return (holder) => {
|
|
163
|
+
const type = types.data?.find((candidate) => candidate.id === holder.objectTypeId)
|
|
164
|
+
const property = type?.properties.find((candidate) => candidate.id === holder.propertyId)
|
|
165
|
+
const object =
|
|
166
|
+
holder.title ?? `${type?.name ?? humanizeIdentifier(holder.objectTypeId)} ${holder.primaryId}`
|
|
167
|
+
|
|
168
|
+
return [object, humanizeIdentifier(property?.name || holder.propertyId)].join(" · ")
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { LIVE_FILES } from "@sixb/core/artifacts/live"
|
|
2
|
+
import type { FileRef } from "@sixb/core/blob-storage"
|
|
3
|
+
import { useCallback, useMemo, useSyncExternalStore } from "react"
|
|
4
|
+
import * as Y from "yjs"
|
|
5
|
+
import type { LiveArtifact } from "./session"
|
|
6
|
+
|
|
7
|
+
// A board's page as the live document holds it, read as it changes: someone typing in it, the
|
|
8
|
+
// Agent writing it, or the whole file replaced.
|
|
9
|
+
|
|
10
|
+
/** A board's page in the document now; null when the document holds none at that path as text. */
|
|
11
|
+
export function liveBoardSource(doc: Y.Doc, path: string): string | null {
|
|
12
|
+
const entry = doc.getMap<unknown>(LIVE_FILES).get(path)
|
|
13
|
+
return entry instanceof Y.Text ? entry.toString() : null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The files the document holds as stored bytes, by path: the pictures a board may show. */
|
|
17
|
+
export function liveStoredFiles(doc: Y.Doc): ReadonlyMap<string, FileRef> {
|
|
18
|
+
const files = new Map<string, FileRef>()
|
|
19
|
+
doc.getMap<unknown>(LIVE_FILES).forEach((entry, path) => {
|
|
20
|
+
if (entry instanceof Y.Text || entry instanceof Y.Map) return
|
|
21
|
+
if (isFileRef(entry)) files.set(path, entry)
|
|
22
|
+
})
|
|
23
|
+
return files
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isFileRef(value: unknown): value is FileRef {
|
|
27
|
+
return (
|
|
28
|
+
typeof value === "object" &&
|
|
29
|
+
value !== null &&
|
|
30
|
+
typeof (value as { blobId?: unknown }).blobId === "string"
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Follows a board's page in a live artifact's document: the text it holds now, read again as it
|
|
36
|
+
* changes, and when the file at its path is replaced. Null without a document, or a page there.
|
|
37
|
+
*/
|
|
38
|
+
export function useLiveBoardSource(live: LiveArtifact | null, path: string): string | null {
|
|
39
|
+
const subscribe = useCallback(
|
|
40
|
+
(listener: () => void) => {
|
|
41
|
+
if (!live) return () => {}
|
|
42
|
+
|
|
43
|
+
const files = live.doc.getMap<unknown>(LIVE_FILES)
|
|
44
|
+
let text: Y.Text | null = null
|
|
45
|
+
const follow = () => {
|
|
46
|
+
text?.unobserve(listener)
|
|
47
|
+
const entry = files.get(path)
|
|
48
|
+
text = entry instanceof Y.Text ? entry : null
|
|
49
|
+
text?.observe(listener)
|
|
50
|
+
}
|
|
51
|
+
const onFiles = (event: Y.YMapEvent<unknown>) => {
|
|
52
|
+
if (!event.keysChanged.has(path)) return
|
|
53
|
+
follow()
|
|
54
|
+
listener()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
follow()
|
|
58
|
+
files.observe(onFiles)
|
|
59
|
+
return () => {
|
|
60
|
+
files.unobserve(onFiles)
|
|
61
|
+
text?.unobserve(listener)
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[live, path]
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return useSyncExternalStore(
|
|
68
|
+
subscribe,
|
|
69
|
+
() => (live ? liveBoardSource(live.doc, path) : null),
|
|
70
|
+
() => null
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Follows the files a live artifact's document holds as stored bytes, as they are added. */
|
|
75
|
+
export function useLiveStoredFiles(live: LiveArtifact | null): ReadonlyMap<string, FileRef> {
|
|
76
|
+
const subscribe = useCallback(
|
|
77
|
+
(listener: () => void) => {
|
|
78
|
+
if (!live) return () => {}
|
|
79
|
+
const files = live.doc.getMap<unknown>(LIVE_FILES)
|
|
80
|
+
files.observe(listener)
|
|
81
|
+
return () => files.unobserve(listener)
|
|
82
|
+
},
|
|
83
|
+
[live]
|
|
84
|
+
)
|
|
85
|
+
const snapshot = useCallback(() => (live ? storedFilesKey(live.doc) : ""), [live])
|
|
86
|
+
const key = useSyncExternalStore(subscribe, snapshot, () => "")
|
|
87
|
+
|
|
88
|
+
// The key stands for the files: the map is read again only when it changes.
|
|
89
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: read again as the key changes.
|
|
90
|
+
return useMemo(() => (live ? liveStoredFiles(live.doc) : new Map()), [live, key])
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function storedFilesKey(doc: Y.Doc): string {
|
|
94
|
+
return [...liveStoredFiles(doc)].map(([path, ref]) => `${path}:${ref.digest}`).join("\n")
|
|
95
|
+
}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { CANVAS_FILE, type Canvas, type CanvasItem } from "@sixb/core/artifacts"
|
|
2
|
+
import {
|
|
3
|
+
applyBoardEditToText,
|
|
4
|
+
type BoardEdit,
|
|
5
|
+
canvasItemMap,
|
|
6
|
+
canvasItemObject,
|
|
7
|
+
documentCanvas,
|
|
8
|
+
LIVE_FILES,
|
|
9
|
+
mergeCanvasItem,
|
|
10
|
+
} from "@sixb/core/artifacts/live"
|
|
11
|
+
import type { FileRef } from "@sixb/core/blob-storage"
|
|
12
|
+
import * as Y from "yjs"
|
|
13
|
+
import type { CanvasChange } from "../renderers/canvas/draft"
|
|
14
|
+
import type { LiveArtifact } from "./session"
|
|
15
|
+
|
|
16
|
+
// A canvas as its live document holds it, read as the board draws it and changed as the board
|
|
17
|
+
// edits it.
|
|
18
|
+
//
|
|
19
|
+
// Reading: the canvas is kept as one `Canvas`, rebuilt as the document changes, in which an item
|
|
20
|
+
// nobody changed is the same object as before. The board draws an item again only when its object
|
|
21
|
+
// changes, so a change someone makes to one note draws that note, not the canvas. What others
|
|
22
|
+
// change is taken in at most once a frame, however fast it comes: the board draws once for all of
|
|
23
|
+
// it. This reader's own changes are taken in at once, with whatever waits.
|
|
24
|
+
//
|
|
25
|
+
// Writing: an edit stays a `CanvasChange`, one function from a canvas to the next, as the draft
|
|
26
|
+
// had it. What it changed is written into the document, key by key and word by word, in one
|
|
27
|
+
// transaction under this canvas's own origin: only those are this reader's to undo. An edit to
|
|
28
|
+
// what a board shows is a change to the board's page, its `Y.Text`, under the same origin, so the
|
|
29
|
+
// same undo takes it back.
|
|
30
|
+
|
|
31
|
+
/** The item types the board draws: anything else in a document is left out. */
|
|
32
|
+
const ITEM_TYPES: ReadonlySet<string> = new Set<CanvasItem["type"]>([
|
|
33
|
+
"board",
|
|
34
|
+
"section",
|
|
35
|
+
"note",
|
|
36
|
+
"text",
|
|
37
|
+
"shape",
|
|
38
|
+
"embed",
|
|
39
|
+
"arrow",
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
/** The origin of a file an edit adds: kept whatever the reader undoes. */
|
|
43
|
+
const KEPT_FILES = Symbol("sixb-live-kept-files")
|
|
44
|
+
|
|
45
|
+
/** How long changes made one after the other are one step for undo, as typing a word is. */
|
|
46
|
+
const UNDO_CAPTURE_MS = 400
|
|
47
|
+
|
|
48
|
+
/** Runs `run` before the next frame is drawn; a timer standing for one where there are none. */
|
|
49
|
+
function requestFrame(run: () => void): () => void {
|
|
50
|
+
if (typeof requestAnimationFrame === "function") {
|
|
51
|
+
const frame = requestAnimationFrame(run)
|
|
52
|
+
return () => cancelAnimationFrame(frame)
|
|
53
|
+
}
|
|
54
|
+
const timer = setTimeout(run, 16)
|
|
55
|
+
return () => clearTimeout(timer)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type ItemMap = Y.Map<unknown>
|
|
59
|
+
|
|
60
|
+
const EMPTY: Canvas = { items: [] }
|
|
61
|
+
|
|
62
|
+
export class LiveCanvas {
|
|
63
|
+
private canvas: Canvas = EMPTY
|
|
64
|
+
private readonly cache = new Map<string, { readonly map: ItemMap; item: CanvasItem }>()
|
|
65
|
+
private structure: ReturnType<typeof documentCanvas> = null
|
|
66
|
+
private undoManager: Y.UndoManager | null = null
|
|
67
|
+
private readonly listeners = new Set<() => void>()
|
|
68
|
+
private history = { undo: false, redo: false }
|
|
69
|
+
/** A drag is under way: everything it changes is one step, however long it pauses. */
|
|
70
|
+
private dragging = false
|
|
71
|
+
/** The items others changed that wait for the next frame to be read again. */
|
|
72
|
+
private pending: Set<string> | null = null
|
|
73
|
+
private cancelFrame: (() => void) | null = null
|
|
74
|
+
/** The canvas the board was last told of. */
|
|
75
|
+
private announced: Canvas | null = null
|
|
76
|
+
/** The origin of this reader's own changes: the only ones its undo takes back. */
|
|
77
|
+
readonly origin = Symbol("sixb-live-canvas")
|
|
78
|
+
|
|
79
|
+
constructor(private readonly doc: Y.Doc) {
|
|
80
|
+
doc.getMap<unknown>(LIVE_FILES).observe(this.onFiles)
|
|
81
|
+
this.bind()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The canvas now, or null while the document holds none: not synced yet, or not a canvas. What
|
|
86
|
+
* waits for the next frame is read in first, so whoever reads it never reads behind.
|
|
87
|
+
*/
|
|
88
|
+
getCanvas = (): Canvas | null => {
|
|
89
|
+
this.readPending()
|
|
90
|
+
return this.structure ? this.canvas : null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getHistory = (): { readonly undo: boolean; readonly redo: boolean } => this.history
|
|
94
|
+
|
|
95
|
+
subscribe = (listener: () => void): (() => void) => {
|
|
96
|
+
this.listeners.add(listener)
|
|
97
|
+
return () => this.listeners.delete(listener)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Makes an edit, as one step of this reader's undo; one that changes nothing writes nothing. */
|
|
101
|
+
apply(change: CanvasChange): void {
|
|
102
|
+
if (!this.structure) return
|
|
103
|
+
|
|
104
|
+
this.readPending()
|
|
105
|
+
const before = this.canvas
|
|
106
|
+
const after = change(before)
|
|
107
|
+
if (after === before) return
|
|
108
|
+
|
|
109
|
+
const { items, order } = this.structure
|
|
110
|
+
this.doc.transact(() => write(items, order, before, after), this.origin)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Makes an edit to a board's page, worked out from what it holds now, as one step of this
|
|
115
|
+
* reader's undo, with the files it needs added first: an image's picture, which undo leaves in
|
|
116
|
+
* place. False when the document holds no such page; `make` throws when the edit no longer
|
|
117
|
+
* applies.
|
|
118
|
+
*/
|
|
119
|
+
editBoard(
|
|
120
|
+
path: string,
|
|
121
|
+
make: (source: string) => BoardEdit,
|
|
122
|
+
files: Readonly<Record<string, FileRef>> = {}
|
|
123
|
+
): boolean {
|
|
124
|
+
const map = this.doc.getMap<unknown>(LIVE_FILES)
|
|
125
|
+
const text = map.get(path)
|
|
126
|
+
if (!(text instanceof Y.Text)) return false
|
|
127
|
+
|
|
128
|
+
const edit = make(text.toString())
|
|
129
|
+
if (edit.length === 0 && Object.keys(files).length === 0) return true
|
|
130
|
+
|
|
131
|
+
// A file joins the canvas for good, outside this reader's undo: undoing the edit puts the
|
|
132
|
+
// page back as it was, and leaves the file to anyone who shows it since.
|
|
133
|
+
if (Object.keys(files).length > 0) {
|
|
134
|
+
this.doc.transact(() => {
|
|
135
|
+
for (const [file, ref] of Object.entries(files)) map.set(file, ref)
|
|
136
|
+
}, KEPT_FILES)
|
|
137
|
+
}
|
|
138
|
+
applyBoardEditToText(text, edit, this.origin)
|
|
139
|
+
return true
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
undo(): void {
|
|
143
|
+
this.undoManager?.undo()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
redo(): void {
|
|
147
|
+
this.undoManager?.redo()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Ends the undo step being made: what comes next, such as a new drag, is a step of its own. */
|
|
151
|
+
stopCapturing(): void {
|
|
152
|
+
this.undoManager?.stopCapturing()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A drag starts: what it changes, until it ends, is one step for undo. */
|
|
156
|
+
startDrag(): void {
|
|
157
|
+
this.stopCapturing()
|
|
158
|
+
this.dragging = true
|
|
159
|
+
if (this.undoManager) this.undoManager.captureTimeout = Number.POSITIVE_INFINITY
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The drag ended: the next change is a step of its own. */
|
|
163
|
+
endDrag(): void {
|
|
164
|
+
this.dragging = false
|
|
165
|
+
if (this.undoManager) this.undoManager.captureTimeout = UNDO_CAPTURE_MS
|
|
166
|
+
this.stopCapturing()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
destroy(): void {
|
|
170
|
+
this.cancelFrame?.()
|
|
171
|
+
this.cancelFrame = null
|
|
172
|
+
this.pending = null
|
|
173
|
+
this.doc.getMap<unknown>(LIVE_FILES).unobserve(this.onFiles)
|
|
174
|
+
this.unbind()
|
|
175
|
+
this.listeners.clear()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ── Reading ─────────────────────────────────────────────────────────
|
|
179
|
+
|
|
180
|
+
/** Follows the canvas's structure: it is replaced when someone writes `canvas.json` whole. */
|
|
181
|
+
private onFiles = (event: Y.YMapEvent<unknown>): void => {
|
|
182
|
+
if (event.keysChanged.has(CANVAS_FILE)) this.bind()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private bind(): void {
|
|
186
|
+
this.cancelFrame?.()
|
|
187
|
+
this.cancelFrame = null
|
|
188
|
+
this.pending = null
|
|
189
|
+
this.unbind()
|
|
190
|
+
this.structure = documentCanvas(this.doc)
|
|
191
|
+
this.cache.clear()
|
|
192
|
+
if (this.structure) {
|
|
193
|
+
this.structure.items.observeDeep(this.onItems)
|
|
194
|
+
this.structure.order.observe(this.onOrder)
|
|
195
|
+
// The files hold the canvas's structure and its boards' pages: this reader's changes to any
|
|
196
|
+
// of them are theirs to undo.
|
|
197
|
+
this.undoManager = new Y.UndoManager(this.doc.getMap<unknown>(LIVE_FILES), {
|
|
198
|
+
trackedOrigins: new Set([this.origin]),
|
|
199
|
+
captureTimeout: this.dragging ? Number.POSITIVE_INFINITY : UNDO_CAPTURE_MS,
|
|
200
|
+
})
|
|
201
|
+
this.undoManager.on("stack-item-added", this.onHistory)
|
|
202
|
+
this.undoManager.on("stack-item-popped", this.onHistory)
|
|
203
|
+
this.undoManager.on("stack-cleared", this.onHistory)
|
|
204
|
+
}
|
|
205
|
+
this.rebuild(null)
|
|
206
|
+
this.announce()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private unbind(): void {
|
|
210
|
+
if (this.structure) {
|
|
211
|
+
this.structure.items.unobserveDeep(this.onItems)
|
|
212
|
+
this.structure.order.unobserve(this.onOrder)
|
|
213
|
+
}
|
|
214
|
+
this.undoManager?.destroy()
|
|
215
|
+
this.undoManager = null
|
|
216
|
+
this.onHistory()
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private onItems = (
|
|
220
|
+
events: Y.YEvent<Y.AbstractType<unknown>>[],
|
|
221
|
+
transaction: Y.Transaction
|
|
222
|
+
): void => {
|
|
223
|
+
const changed = new Set<string>()
|
|
224
|
+
for (const event of events) {
|
|
225
|
+
// The items map itself: items added or deleted; else a change inside one item, its path
|
|
226
|
+
// starting at its id.
|
|
227
|
+
if (event.path.length === 0) {
|
|
228
|
+
for (const key of event.changes.keys.keys()) changed.add(key)
|
|
229
|
+
} else {
|
|
230
|
+
const id = event.path[0]
|
|
231
|
+
if (typeof id === "string") changed.add(id)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this.taken(changed, transaction)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private onOrder = (_event: Y.YEvent<Y.Array<string>>, transaction: Y.Transaction): void =>
|
|
238
|
+
this.taken(new Set(), transaction)
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Reads again what a change touched, and tells the board: at once for this reader's own, with
|
|
242
|
+
* whatever waits; at the next frame for the others', all of a frame's changes at once.
|
|
243
|
+
*/
|
|
244
|
+
private taken(changed: ReadonlySet<string>, transaction: Y.Transaction): void {
|
|
245
|
+
const pending = this.pending ?? new Set<string>()
|
|
246
|
+
for (const id of changed) pending.add(id)
|
|
247
|
+
this.pending = pending
|
|
248
|
+
|
|
249
|
+
const own = transaction.origin === this.origin || transaction.origin === this.undoManager
|
|
250
|
+
if (own) {
|
|
251
|
+
this.cancelFrame?.()
|
|
252
|
+
this.cancelFrame = null
|
|
253
|
+
this.readPending()
|
|
254
|
+
this.announce()
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
this.cancelFrame ??= requestFrame(() => {
|
|
258
|
+
this.cancelFrame = null
|
|
259
|
+
this.readPending()
|
|
260
|
+
this.announce()
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Reads again the items that wait, without telling anyone: a read can come while React draws. */
|
|
265
|
+
private readPending(): void {
|
|
266
|
+
const pending = this.pending
|
|
267
|
+
if (!pending) return
|
|
268
|
+
|
|
269
|
+
this.pending = null
|
|
270
|
+
this.rebuild(pending)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Tells the board of the canvas, once it is another. */
|
|
274
|
+
private announce(): void {
|
|
275
|
+
if (this.announced === this.canvas) return
|
|
276
|
+
this.announced = this.canvas
|
|
277
|
+
this.notify()
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private onHistory = (): void => {
|
|
281
|
+
const next = {
|
|
282
|
+
undo: (this.undoManager?.undoStack.length ?? 0) > 0,
|
|
283
|
+
redo: (this.undoManager?.redoStack.length ?? 0) > 0,
|
|
284
|
+
}
|
|
285
|
+
if (next.undo === this.history.undo && next.redo === this.history.redo) return
|
|
286
|
+
this.history = next
|
|
287
|
+
this.notify()
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The canvas again, its items in order, then any the order misses, and without an arrow whose
|
|
292
|
+
* item someone deleted meanwhile, as `canvas.json` is written. Only the items in `changed` are
|
|
293
|
+
* read again, all of them when it is null.
|
|
294
|
+
*/
|
|
295
|
+
private rebuild(changed: ReadonlySet<string> | null): void {
|
|
296
|
+
const structure = this.structure
|
|
297
|
+
if (!structure) {
|
|
298
|
+
this.canvas = EMPTY
|
|
299
|
+
return
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const { items, order } = structure
|
|
303
|
+
const ids: string[] = []
|
|
304
|
+
const seen = new Set<string>()
|
|
305
|
+
for (const id of [...order.toArray(), ...[...items.keys()].sort()]) {
|
|
306
|
+
if (seen.has(id) || !items.has(id)) continue
|
|
307
|
+
seen.add(id)
|
|
308
|
+
ids.push(id)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const next: CanvasItem[] = []
|
|
312
|
+
for (const id of ids) {
|
|
313
|
+
const map = items.get(id) as ItemMap
|
|
314
|
+
const cached = this.cache.get(id)
|
|
315
|
+
if (cached && cached.map === map && changed !== null && !changed.has(id)) {
|
|
316
|
+
next.push(cached.item)
|
|
317
|
+
continue
|
|
318
|
+
}
|
|
319
|
+
const item = readItem(map)
|
|
320
|
+
if (!item) continue
|
|
321
|
+
this.cache.set(id, { map, item })
|
|
322
|
+
next.push(item)
|
|
323
|
+
}
|
|
324
|
+
for (const id of this.cache.keys()) {
|
|
325
|
+
if (!seen.has(id)) this.cache.delete(id)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const kept = next.filter(
|
|
329
|
+
(item) => item.type !== "arrow" || (joined(item.from, seen) && joined(item.to, seen))
|
|
330
|
+
)
|
|
331
|
+
const same =
|
|
332
|
+
kept.length === this.canvas.items.length &&
|
|
333
|
+
kept.every((item, index) => item === this.canvas.items[index])
|
|
334
|
+
if (same && this.canvas !== EMPTY) return
|
|
335
|
+
|
|
336
|
+
this.canvas = { items: kept }
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private notify(): void {
|
|
340
|
+
for (const listener of this.listeners) listener()
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function joined(end: unknown, ids: ReadonlySet<string>): boolean {
|
|
345
|
+
return typeof end !== "string" || ids.has(end)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** An item as the board reads it; null for one that is not an item of a known type. */
|
|
349
|
+
function readItem(map: ItemMap): CanvasItem | null {
|
|
350
|
+
const item = canvasItemObject(map)
|
|
351
|
+
if (typeof item.id !== "string" || typeof item.type !== "string" || !ITEM_TYPES.has(item.type)) {
|
|
352
|
+
return null
|
|
353
|
+
}
|
|
354
|
+
return item as unknown as CanvasItem
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ── Writing ─────────────────────────────────────────────────────────────
|
|
358
|
+
|
|
359
|
+
/** Writes into the structure what changed from `before` to `after`. */
|
|
360
|
+
function write(items: Y.Map<ItemMap>, order: Y.Array<string>, before: Canvas, after: Canvas): void {
|
|
361
|
+
const previous = new Map(before.items.map((item) => [item.id, item]))
|
|
362
|
+
const next = new Set<string>()
|
|
363
|
+
|
|
364
|
+
for (const item of after.items) {
|
|
365
|
+
next.add(item.id)
|
|
366
|
+
const was = previous.get(item.id)
|
|
367
|
+
if (was === item) continue
|
|
368
|
+
|
|
369
|
+
const map = items.get(item.id)
|
|
370
|
+
if (!was || !map) {
|
|
371
|
+
items.set(item.id, canvasItemMap(item))
|
|
372
|
+
continue
|
|
373
|
+
}
|
|
374
|
+
// The item as this reader last read it is what the document holds: its words go as edits.
|
|
375
|
+
mergeCanvasItem(map, was, item)
|
|
376
|
+
}
|
|
377
|
+
for (const id of previous.keys()) {
|
|
378
|
+
if (!next.has(id)) items.delete(id)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// An edit adds at the end and removes anywhere: the order follows, someone else's additions kept.
|
|
382
|
+
const ids = order.toArray()
|
|
383
|
+
for (let index = ids.length - 1; index >= 0; index -= 1) {
|
|
384
|
+
const id = ids[index] as string
|
|
385
|
+
if (previous.has(id) && !next.has(id)) order.delete(index, 1)
|
|
386
|
+
}
|
|
387
|
+
const ordered = new Set(order.toArray())
|
|
388
|
+
const added = after.items.map((item) => item.id).filter((id) => !ordered.has(id))
|
|
389
|
+
if (added.length > 0) order.push(added)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const canvases = new WeakMap<LiveArtifact, LiveCanvas>()
|
|
393
|
+
|
|
394
|
+
/** The canvas of a live artifact, one per artifact, so the board and the header share its undo. */
|
|
395
|
+
export function liveCanvasOf(artifact: LiveArtifact): LiveCanvas {
|
|
396
|
+
let canvas = canvases.get(artifact)
|
|
397
|
+
if (!canvas) {
|
|
398
|
+
canvas = new LiveCanvas(artifact.doc)
|
|
399
|
+
canvases.set(artifact, canvas)
|
|
400
|
+
}
|
|
401
|
+
return canvas
|
|
402
|
+
}
|