@sixb/app 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/fleetio.ico +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- 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/background/background-card.d.ts +10 -0
- package/dist/agent/background/background-card.d.ts.map +1 -0
- package/dist/agent/background/background-tool-row.d.ts +9 -0
- package/dist/agent/background/background-tool-row.d.ts.map +1 -0
- package/dist/agent/background/context.d.ts +23 -0
- package/dist/agent/background/context.d.ts.map +1 -0
- package/dist/agent/background/interpret.d.ts +116 -0
- package/dist/agent/background/interpret.d.ts.map +1 -0
- package/dist/agent/bash/bash-tool-view.d.ts.map +1 -1
- package/dist/agent/bash/interpret.d.ts +4 -0
- package/dist/agent/bash/interpret.d.ts.map +1 -1
- package/dist/agent/components/composer-menu.d.ts +3 -1
- package/dist/agent/components/composer-menu.d.ts.map +1 -1
- package/dist/agent/components/composer-place.d.ts +13 -0
- package/dist/agent/components/composer-place.d.ts.map +1 -0
- package/dist/agent/components/composer.d.ts +23 -1
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/computer-place.d.ts +3 -1
- package/dist/agent/components/computer-place.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/components/transcript.d.ts +6 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/components/web-fetch-tool-view.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/child-parts.d.ts +2 -0
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- 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 +24 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-new-thread-place.d.ts +70 -0
- package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-lists.d.ts +40 -0
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +74 -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 +126 -0
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/observed-conversation.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/agent/utils/web-fetch.d.ts +33 -1
- package/dist/agent/utils/web-fetch.d.ts.map +1 -1
- package/dist/agent/utils/web-search.d.ts +14 -2
- package/dist/agent/utils/web-search.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-fw2bm6dq.js → chunk-001c4gnk.js} +8086 -3870
- 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-j9653e83.js → chunk-fwb9mxwm.js} +1 -1
- package/dist/{chunk-km25essq.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/shared.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 +2 -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 +8195 -4841
- package/dist/pages.js.map +58 -49
- 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/activity-label.ts +6 -2
- 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/agent.css +18 -0
- package/src/agent/artifact-card.tsx +84 -16
- package/src/agent/artifact-panel.tsx +63 -43
- package/src/agent/background/background-card.tsx +308 -0
- package/src/agent/background/background-tool-row.tsx +58 -0
- package/src/agent/background/context.ts +26 -0
- package/src/agent/background/interpret.ts +356 -0
- package/src/agent/bash/bash-tool-view.tsx +9 -4
- package/src/agent/bash/interpret.ts +21 -3
- package/src/agent/components/agent-message-body.tsx +1 -1
- package/src/agent/components/composer-menu.tsx +4 -1
- package/src/agent/components/composer-place.tsx +168 -0
- package/src/agent/components/composer.tsx +101 -3
- package/src/agent/components/computer-place.tsx +18 -1
- 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/components/transcript.tsx +33 -1
- package/src/agent/components/web-fetch-tool-view.tsx +94 -29
- package/src/agent/composer-insertion.ts +36 -0
- package/src/agent/delegation/child-parts.tsx +1 -1
- package/src/agent/hooks/use-agent-conversation.ts +101 -8
- package/src/agent/hooks/use-new-thread-place.ts +294 -0
- package/src/agent/i18n/en.ts +70 -3
- package/src/agent/i18n/fr.ts +70 -3
- package/src/agent/observed-conversation.tsx +3 -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 +29 -11
- package/src/agent/types.ts +4 -0
- package/src/agent/utils/web-fetch.ts +89 -10
- package/src/agent/utils/web-search.ts +67 -28
- 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/shared.tsx +1 -0
- 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 +2 -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 +17 -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-4mprsd2n.js.map +0 -10
- package/dist/chunk-fw2bm6dq.js.map +0 -182
- package/dist/chunk-zxthr2q5.js +0 -1487
- package/dist/chunk-zxthr2q5.js.map +0 -18
- /package/dist/{chunk-j9653e83.js.map → chunk-fwb9mxwm.js.map} +0 -0
- /package/dist/{chunk-km25essq.js.map → chunk-kes4ygmz.js.map} +0 -0
- /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENT_AWARENESS_FIELD,
|
|
3
|
+
type ArtifactAgentPresence,
|
|
4
|
+
type ArtifactLiveUser,
|
|
5
|
+
USER_AWARENESS_FIELD,
|
|
6
|
+
} from "@sixb/core/artifacts/live"
|
|
7
|
+
import { useCallback, useSyncExternalStore } from "react"
|
|
8
|
+
import type { LiveArtifact } from "./session"
|
|
9
|
+
|
|
10
|
+
// Who is on a live artifact, from its awareness: each connection's state, which the server stamps
|
|
11
|
+
// with who the person is (`user`), and the server's own, which says which boards an Agent turn is
|
|
12
|
+
// changing. A connection says itself what it has selected.
|
|
13
|
+
|
|
14
|
+
/** The awareness field a connection selects items in, by id. */
|
|
15
|
+
export const SELECTION_FIELD = "selection"
|
|
16
|
+
|
|
17
|
+
/** Someone on the artifact, from one of their connections: a person may have several. */
|
|
18
|
+
export interface LivePeer {
|
|
19
|
+
readonly clientId: number
|
|
20
|
+
readonly user: ArtifactLiveUser
|
|
21
|
+
/** The items they have selected. */
|
|
22
|
+
readonly selection: readonly string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LivePresence {
|
|
26
|
+
/** Everyone else's connections, in the order they came. */
|
|
27
|
+
readonly peers: readonly LivePeer[]
|
|
28
|
+
/** The people among them, once each, for the avatars. */
|
|
29
|
+
readonly people: readonly ArtifactLiveUser[]
|
|
30
|
+
/** The Agent's turns at work, and the boards each is changing. */
|
|
31
|
+
readonly agents: readonly ArtifactAgentPresence[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const NOBODY: LivePresence = { peers: [], people: [], agents: [] }
|
|
35
|
+
|
|
36
|
+
const presences = new WeakMap<
|
|
37
|
+
LiveArtifact,
|
|
38
|
+
{ value: LivePresence; readonly listeners: Set<() => void> }
|
|
39
|
+
>()
|
|
40
|
+
|
|
41
|
+
/** The presence of a live artifact, read again whenever its awareness changes. */
|
|
42
|
+
function presenceOf(artifact: LiveArtifact) {
|
|
43
|
+
let entry = presences.get(artifact)
|
|
44
|
+
if (entry) return entry
|
|
45
|
+
|
|
46
|
+
const created = { value: readPresence(artifact), listeners: new Set<() => void>() }
|
|
47
|
+
artifact.awareness.on("change", () => {
|
|
48
|
+
created.value = readPresence(artifact)
|
|
49
|
+
for (const listener of created.listeners) listener()
|
|
50
|
+
})
|
|
51
|
+
entry = created
|
|
52
|
+
presences.set(artifact, entry)
|
|
53
|
+
return entry
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readPresence(artifact: LiveArtifact): LivePresence {
|
|
57
|
+
const own = artifact.doc.clientID
|
|
58
|
+
const peers: LivePeer[] = []
|
|
59
|
+
const agents: ArtifactAgentPresence[] = []
|
|
60
|
+
for (const [clientId, state] of artifact.awareness.getStates()) {
|
|
61
|
+
if (clientId === own) continue
|
|
62
|
+
|
|
63
|
+
agents.push(...agentsOf(state[AGENT_AWARENESS_FIELD]))
|
|
64
|
+
const user = userOf(state[USER_AWARENESS_FIELD])
|
|
65
|
+
if (!user) continue
|
|
66
|
+
|
|
67
|
+
const selection = state[SELECTION_FIELD]
|
|
68
|
+
peers.push({
|
|
69
|
+
clientId,
|
|
70
|
+
user,
|
|
71
|
+
selection: Array.isArray(selection)
|
|
72
|
+
? selection.filter((id): id is string => typeof id === "string")
|
|
73
|
+
: [],
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
if (peers.length === 0 && agents.length === 0) return NOBODY
|
|
77
|
+
|
|
78
|
+
const self = artifact.getState().user?.id
|
|
79
|
+
const people = new Map<string, ArtifactLiveUser>()
|
|
80
|
+
for (const peer of peers) {
|
|
81
|
+
if (peer.user.id !== self && !people.has(peer.user.id)) people.set(peer.user.id, peer.user)
|
|
82
|
+
}
|
|
83
|
+
return { peers, people: [...people.values()], agents }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* What a person on the artifact is called: the name the server gives them, else "Guest" for a
|
|
88
|
+
* shared link's visitor who gave none, and "Team member" for a member without a profile name.
|
|
89
|
+
*/
|
|
90
|
+
export function livePersonName(
|
|
91
|
+
user: ArtifactLiveUser,
|
|
92
|
+
labels: { readonly guest: string; readonly teamMember: string }
|
|
93
|
+
): string {
|
|
94
|
+
return user.name || (user.guest ? labels.guest : labels.teamMember)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function userOf(value: unknown): ArtifactLiveUser | null {
|
|
98
|
+
if (typeof value !== "object" || value === null) return null
|
|
99
|
+
const { id, name, color, guest } = value as Record<string, unknown>
|
|
100
|
+
if (typeof id !== "string" || typeof name !== "string" || typeof color !== "string") return null
|
|
101
|
+
return { id, name, color, ...(guest === true ? { guest } : {}) }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function agentsOf(value: unknown): ArtifactAgentPresence[] {
|
|
105
|
+
if (!Array.isArray(value)) return []
|
|
106
|
+
return value.flatMap((entry) => {
|
|
107
|
+
if (typeof entry !== "object" || entry === null) return []
|
|
108
|
+
const { runId, boards } = entry as Record<string, unknown>
|
|
109
|
+
if (typeof runId !== "string" || !Array.isArray(boards)) return []
|
|
110
|
+
return [{ runId, boards: boards.filter((id): id is string => typeof id === "string") }]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const noSubscription = () => () => {}
|
|
115
|
+
|
|
116
|
+
/** Who else is on a live artifact, and what the Agent is changing, as it changes. */
|
|
117
|
+
export function useLivePresence(artifact: LiveArtifact | null): LivePresence {
|
|
118
|
+
const subscribe = useCallback(
|
|
119
|
+
(listener: () => void) => {
|
|
120
|
+
if (!artifact) return noSubscription()
|
|
121
|
+
const entry = presenceOf(artifact)
|
|
122
|
+
entry.listeners.add(listener)
|
|
123
|
+
return () => {
|
|
124
|
+
entry.listeners.delete(listener)
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
[artifact]
|
|
128
|
+
)
|
|
129
|
+
return useSyncExternalStore(
|
|
130
|
+
subscribe,
|
|
131
|
+
() => (artifact ? presenceOf(artifact).value : NOBODY),
|
|
132
|
+
() => NOBODY
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Says to the others what this reader has selected. */
|
|
137
|
+
export function shareSelection(artifact: LiveArtifact, ids: readonly string[]): void {
|
|
138
|
+
const current = artifact.awareness.getLocalState()?.[SELECTION_FIELD]
|
|
139
|
+
if (
|
|
140
|
+
Array.isArray(current) &&
|
|
141
|
+
current.length === ids.length &&
|
|
142
|
+
current.every((id, index) => id === ids[index])
|
|
143
|
+
) {
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
artifact.awareness.setLocalStateField(SELECTION_FIELD, [...ids])
|
|
147
|
+
}
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { type ArtifactLiveSocket, createArtifactLiveSocket } from "@sixb/client/artifact-live"
|
|
2
|
+
import {
|
|
3
|
+
type ArtifactLiveAccess,
|
|
4
|
+
type ArtifactLiveClientMessage,
|
|
5
|
+
type ArtifactLiveLeftReason,
|
|
6
|
+
type ArtifactLiveSaveState,
|
|
7
|
+
type ArtifactLiveServerMessage,
|
|
8
|
+
type ArtifactLiveUser,
|
|
9
|
+
decodeLiveData,
|
|
10
|
+
encodeLiveData,
|
|
11
|
+
liveSync,
|
|
12
|
+
} from "@sixb/core/artifacts/live"
|
|
13
|
+
import * as decoding from "lib0/decoding"
|
|
14
|
+
import * as encoding from "lib0/encoding"
|
|
15
|
+
import * as awarenessProtocol from "y-protocols/awareness"
|
|
16
|
+
import * as syncProtocol from "y-protocols/sync"
|
|
17
|
+
import * as Y from "yjs"
|
|
18
|
+
import { SELECTION_FIELD } from "./presence"
|
|
19
|
+
|
|
20
|
+
// The artifacts a page holds live, over one `/ws/artifacts` socket. Each keeps its Yjs document
|
|
21
|
+
// and its awareness for as long as a view holds it, across reconnects: a reconnect joins again
|
|
22
|
+
// and sends sync step 1, and the server's own step 1 brings back what changed here meanwhile.
|
|
23
|
+
//
|
|
24
|
+
// socket ── connected ──▶ join each artifact ── joined ──▶ sync step 1, own awareness
|
|
25
|
+
// ◀── sync / awareness, applied as FROM_SERVER (never sent back)
|
|
26
|
+
// ──▶ the document's own updates, and its awareness, as they happen
|
|
27
|
+
|
|
28
|
+
/** The origin of what the server sent: applied, never sent back. */
|
|
29
|
+
export const FROM_SERVER = Symbol("sixb-live-server")
|
|
30
|
+
|
|
31
|
+
/** How long an artifact no view holds stays joined, so a view that remounts finds it as it was. */
|
|
32
|
+
const LINGER_MS = 3_000
|
|
33
|
+
|
|
34
|
+
/** Whether the socket is up: `connecting` until the first connection, `offline` between two. */
|
|
35
|
+
export type LiveConnection = "connecting" | "online" | "offline"
|
|
36
|
+
|
|
37
|
+
/** What the server says of the document's write-back, as the last `status` said it. */
|
|
38
|
+
export interface LiveSave {
|
|
39
|
+
readonly state: ArtifactLiveSaveState
|
|
40
|
+
readonly revision: number
|
|
41
|
+
readonly error?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface LiveArtifactState {
|
|
45
|
+
readonly connection: LiveConnection
|
|
46
|
+
/** What the connection may do, once joined; null before. */
|
|
47
|
+
readonly access: ArtifactLiveAccess | null
|
|
48
|
+
/** The document holds the artifact: the server's sync step 2 reached it once. */
|
|
49
|
+
readonly synced: boolean
|
|
50
|
+
readonly save: LiveSave | null
|
|
51
|
+
/** Changes made here that the server has not said it took: sent offline, or not saved yet. */
|
|
52
|
+
readonly pending: boolean
|
|
53
|
+
/** Who this connection is to the others, as `joined` said. */
|
|
54
|
+
readonly user: ArtifactLiveUser | null
|
|
55
|
+
/** Why the page no longer holds the artifact live; null while it does. */
|
|
56
|
+
readonly left: ArtifactLiveLeftReason | null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const INITIAL: LiveArtifactState = {
|
|
60
|
+
connection: "connecting",
|
|
61
|
+
access: null,
|
|
62
|
+
synced: false,
|
|
63
|
+
save: null,
|
|
64
|
+
pending: false,
|
|
65
|
+
user: null,
|
|
66
|
+
left: null,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Changes a copy of an artifact's document kept, and whose they are. */
|
|
70
|
+
export interface KeptChanges {
|
|
71
|
+
/** Where they are kept: one key per copy of the document, so two tabs keep their own. */
|
|
72
|
+
readonly key: string
|
|
73
|
+
/** Who made them, as `joined` named them. */
|
|
74
|
+
readonly userId: string
|
|
75
|
+
readonly update: Uint8Array
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Where a page keeps the changes made to an artifact that the server has not said it saved, so a
|
|
80
|
+
* reload, or a tab closed during an outage, does not lose them: the next copy of the document,
|
|
81
|
+
* opened by the same person with the right to edit, merges them in and sends them with its sync.
|
|
82
|
+
*/
|
|
83
|
+
export interface LiveKeeper {
|
|
84
|
+
/** Every copy's changes kept for an artifact. */
|
|
85
|
+
list(artifactId: string): KeptChanges[]
|
|
86
|
+
write(changes: KeptChanges): void
|
|
87
|
+
remove(key: string): void
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The key one copy of an artifact's document keeps its changes under. */
|
|
91
|
+
export function keptChangesKey(artifactId: string, clientId: number): string {
|
|
92
|
+
return `${keptPrefix(artifactId)}${clientId}`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const keptPrefix = (artifactId: string) => `sixb.live.unsaved.${artifactId}.`
|
|
96
|
+
|
|
97
|
+
/** The browser's local storage, which a private window or a full disk may refuse: then nothing. */
|
|
98
|
+
export const browserKeeper: LiveKeeper = {
|
|
99
|
+
list(artifactId) {
|
|
100
|
+
const prefix = keptPrefix(artifactId)
|
|
101
|
+
const kept: KeptChanges[] = []
|
|
102
|
+
try {
|
|
103
|
+
const storage = globalThis.localStorage
|
|
104
|
+
if (!storage) return []
|
|
105
|
+
for (let index = 0; index < storage.length; index += 1) {
|
|
106
|
+
const key = storage.key(index)
|
|
107
|
+
if (!key?.startsWith(prefix)) continue
|
|
108
|
+
const changes = readKept(key, storage.getItem(key))
|
|
109
|
+
if (changes) kept.push(changes)
|
|
110
|
+
else storage.removeItem(key)
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
// Nothing can be read back.
|
|
114
|
+
}
|
|
115
|
+
return kept
|
|
116
|
+
},
|
|
117
|
+
write({ key, userId, update }) {
|
|
118
|
+
try {
|
|
119
|
+
globalThis.localStorage?.setItem(
|
|
120
|
+
key,
|
|
121
|
+
JSON.stringify({ user: userId, update: encodeLiveData(update) })
|
|
122
|
+
)
|
|
123
|
+
} catch {
|
|
124
|
+
// Kept in the document while the page lasts.
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
remove(key) {
|
|
128
|
+
try {
|
|
129
|
+
globalThis.localStorage?.removeItem(key)
|
|
130
|
+
} catch {
|
|
131
|
+
// Nothing was kept.
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function readKept(key: string, value: string | null): KeptChanges | null {
|
|
137
|
+
if (!value) return null
|
|
138
|
+
try {
|
|
139
|
+
const { user, update } = JSON.parse(value) as { user?: unknown; update?: unknown }
|
|
140
|
+
const bytes = typeof update === "string" ? decodeLiveData(update) : null
|
|
141
|
+
return typeof user === "string" && bytes ? { key, userId: user, update: bytes } : null
|
|
142
|
+
} catch {
|
|
143
|
+
return null
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Whether a snapshot of what was written covers `update`: what it inserts, by its clocks, and
|
|
149
|
+
* what it deletes, by the snapshot's delete set. A change that only deletes moves no clock.
|
|
150
|
+
*/
|
|
151
|
+
function covers(written: Y.Snapshot, update: Uint8Array): boolean {
|
|
152
|
+
const made = Y.decodeStateVector(Y.encodeStateVectorFromUpdate(update))
|
|
153
|
+
for (const [client, clock] of made) {
|
|
154
|
+
if ((written.sv.get(client) ?? 0) < clock) return false
|
|
155
|
+
}
|
|
156
|
+
for (const [client, ranges] of Y.decodeUpdate(update).ds.clients) {
|
|
157
|
+
for (const { clock, len } of ranges) {
|
|
158
|
+
for (let offset = 0; offset < len; offset += 1) {
|
|
159
|
+
if (!Y.isDeleted(written.ds, Y.createID(client, clock + offset))) return false
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return true
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** A snapshot from the server; null for one that does not read. */
|
|
167
|
+
function readSnapshot(data: string): Y.Snapshot | null {
|
|
168
|
+
const bytes = decodeLiveData(data)
|
|
169
|
+
if (!bytes) return null
|
|
170
|
+
try {
|
|
171
|
+
return Y.decodeSnapshot(bytes)
|
|
172
|
+
} catch {
|
|
173
|
+
return null
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The origin of changes taken back from the keeper: this page's own, sent as any other. */
|
|
178
|
+
const KEPT = Symbol("sixb-live-kept")
|
|
179
|
+
|
|
180
|
+
/** One artifact a page holds live: its document, its awareness, and what the server says. */
|
|
181
|
+
export class LiveArtifact {
|
|
182
|
+
readonly doc = new Y.Doc()
|
|
183
|
+
readonly awareness = new awarenessProtocol.Awareness(this.doc)
|
|
184
|
+
private state: LiveArtifactState = INITIAL
|
|
185
|
+
private readonly listeners = new Set<() => void>()
|
|
186
|
+
private joined = false
|
|
187
|
+
/** What this page changed that the server has not said it saved, merged into one update. */
|
|
188
|
+
private unsaved: Uint8Array | null = null
|
|
189
|
+
/** Where this copy keeps them. */
|
|
190
|
+
private readonly key: string
|
|
191
|
+
/** Other copies' kept changes merged in, by key: forgotten here once the server wrote them. */
|
|
192
|
+
private readonly merged = new Map<string, Uint8Array>()
|
|
193
|
+
|
|
194
|
+
constructor(
|
|
195
|
+
readonly artifactId: string,
|
|
196
|
+
private readonly send: (message: ArtifactLiveClientMessage) => boolean,
|
|
197
|
+
private readonly keeper: LiveKeeper = browserKeeper
|
|
198
|
+
) {
|
|
199
|
+
this.doc.on("update", this.onUpdate)
|
|
200
|
+
this.awareness.on("update", this.onAwareness)
|
|
201
|
+
// Others take a state only past its first clock, which the empty one starts at: one set now
|
|
202
|
+
// is the first they see.
|
|
203
|
+
this.awareness.setLocalStateField(SELECTION_FIELD, [])
|
|
204
|
+
this.key = keptChangesKey(artifactId, this.doc.clientID)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** What this page changed that the server has not said it saved. */
|
|
208
|
+
get hasUnsaved(): boolean {
|
|
209
|
+
return this.unsaved !== null
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getState = (): LiveArtifactState => this.state
|
|
213
|
+
|
|
214
|
+
subscribe = (listener: () => void): (() => void) => {
|
|
215
|
+
this.listeners.add(listener)
|
|
216
|
+
return () => this.listeners.delete(listener)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The socket is ready: join, or join again after a reconnect. */
|
|
220
|
+
connected(): void {
|
|
221
|
+
if (this.state.left) return
|
|
222
|
+
this.joined = false
|
|
223
|
+
this.send({ type: "join", artifactId: this.artifactId })
|
|
224
|
+
this.update({ connection: "online" })
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The socket closed: others' presence goes with it, until they are heard of again. */
|
|
228
|
+
disconnected(): void {
|
|
229
|
+
this.joined = false
|
|
230
|
+
const others = [...this.awareness.getStates().keys()].filter(
|
|
231
|
+
(client) => client !== this.doc.clientID
|
|
232
|
+
)
|
|
233
|
+
awarenessProtocol.removeAwarenessStates(this.awareness, others, FROM_SERVER)
|
|
234
|
+
if (this.state.connection !== "connecting") this.update({ connection: "offline" })
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
receive(message: ArtifactLiveServerMessage): void {
|
|
238
|
+
switch (message.type) {
|
|
239
|
+
case "joined": {
|
|
240
|
+
this.joined = true
|
|
241
|
+
this.update({ access: message.access, user: message.user, left: null })
|
|
242
|
+
|
|
243
|
+
const step1 = encoding.createEncoder()
|
|
244
|
+
syncProtocol.writeSyncStep1(step1, this.doc)
|
|
245
|
+
this.sendSync(encoding.toUint8Array(step1))
|
|
246
|
+
this.sendAwareness([this.doc.clientID])
|
|
247
|
+
this.takeKept(message.user.id, message.access)
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
case "sync": {
|
|
251
|
+
const bytes = decodeLiveData(message.data)
|
|
252
|
+
if (!bytes) return
|
|
253
|
+
|
|
254
|
+
const reply = encoding.createEncoder()
|
|
255
|
+
const type = syncProtocol.readSyncMessage(
|
|
256
|
+
decoding.createDecoder(bytes),
|
|
257
|
+
reply,
|
|
258
|
+
this.doc,
|
|
259
|
+
FROM_SERVER
|
|
260
|
+
)
|
|
261
|
+
if (encoding.length(reply) > 0) this.sendSync(encoding.toUint8Array(reply))
|
|
262
|
+
if (type === syncProtocol.messageYjsSyncStep2 && !this.state.synced) {
|
|
263
|
+
this.update({ synced: true })
|
|
264
|
+
}
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
case "awareness": {
|
|
268
|
+
const bytes = decodeLiveData(message.data)
|
|
269
|
+
if (bytes) awarenessProtocol.applyAwarenessUpdate(this.awareness, bytes, FROM_SERVER)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
case "status": {
|
|
273
|
+
const { state, revision, error } = message
|
|
274
|
+
const written = message.snapshot ? readSnapshot(message.snapshot) : null
|
|
275
|
+
if (written) this.forget(written)
|
|
276
|
+
this.update({
|
|
277
|
+
save: { state, revision, ...(error ? { error } : {}) },
|
|
278
|
+
pending: state !== "saved",
|
|
279
|
+
})
|
|
280
|
+
return
|
|
281
|
+
}
|
|
282
|
+
case "access":
|
|
283
|
+
this.update({ access: message.access })
|
|
284
|
+
return
|
|
285
|
+
case "left":
|
|
286
|
+
this.joined = false
|
|
287
|
+
if (message.reason !== "left") this.forget(null)
|
|
288
|
+
this.update({ left: message.reason })
|
|
289
|
+
return
|
|
290
|
+
case "error":
|
|
291
|
+
console.warn(`[SixbApp] Live artifact '${this.artifactId}': ${message.message}`)
|
|
292
|
+
return
|
|
293
|
+
default:
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Stops holding the artifact: the server is told, and the document freed. */
|
|
299
|
+
destroy(): void {
|
|
300
|
+
awarenessProtocol.removeAwarenessStates(this.awareness, [this.doc.clientID], "local")
|
|
301
|
+
if (this.joined) this.send({ type: "leave", artifactId: this.artifactId })
|
|
302
|
+
this.joined = false
|
|
303
|
+
this.doc.off("update", this.onUpdate)
|
|
304
|
+
this.awareness.off("update", this.onAwareness)
|
|
305
|
+
this.awareness.destroy()
|
|
306
|
+
this.doc.destroy()
|
|
307
|
+
this.listeners.clear()
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private onUpdate = (update: Uint8Array, origin: unknown): void => {
|
|
311
|
+
if (origin === FROM_SERVER) return
|
|
312
|
+
|
|
313
|
+
// A change made offline, or by a watcher, waits: the next join's sync takes it.
|
|
314
|
+
if (this.joined && this.state.access === "edit") {
|
|
315
|
+
const message = encoding.createEncoder()
|
|
316
|
+
syncProtocol.writeUpdate(message, update)
|
|
317
|
+
this.sendSync(encoding.toUint8Array(message))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
this.unsaved = this.unsaved ? Y.mergeUpdates([this.unsaved, update]) : update
|
|
321
|
+
this.keep()
|
|
322
|
+
if (!this.state.pending) this.update({ pending: true })
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** Keeps what this page changed, as its person's: not before `joined` says who they are. */
|
|
326
|
+
private keep(): void {
|
|
327
|
+
const user = this.state.user
|
|
328
|
+
if (!user || !this.unsaved) return
|
|
329
|
+
this.keeper.write({ key: this.key, userId: user.id, update: this.unsaved })
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Merges in what earlier copies of the document kept for this person, once the server says
|
|
334
|
+
* who they are and that they may edit: each waits in the document for what it was made on, and
|
|
335
|
+
* is sent with this copy's own changes. Another person's are never read; this person's, once
|
|
336
|
+
* they may only watch, are dropped.
|
|
337
|
+
*/
|
|
338
|
+
private takeKept(userId: string, access: ArtifactLiveAccess): void {
|
|
339
|
+
for (const kept of this.keeper.list(this.artifactId)) {
|
|
340
|
+
if (kept.key === this.key || kept.userId !== userId) continue
|
|
341
|
+
if (access !== "edit") {
|
|
342
|
+
this.keeper.remove(kept.key)
|
|
343
|
+
continue
|
|
344
|
+
}
|
|
345
|
+
try {
|
|
346
|
+
Y.applyUpdate(this.doc, kept.update, KEPT)
|
|
347
|
+
this.merged.set(kept.key, kept.update)
|
|
348
|
+
} catch {
|
|
349
|
+
this.keeper.remove(kept.key)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
this.keep()
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Forgets what the server wrote back, as its snapshot says, here and in the copies merged in,
|
|
357
|
+
* and keeps the rest whole: a change sent while the server was writing is not in what it wrote.
|
|
358
|
+
* Null when the artifact is gone: nothing is kept.
|
|
359
|
+
*/
|
|
360
|
+
private forget(written: Y.Snapshot | null): void {
|
|
361
|
+
if (written && this.unsaved && !covers(written, this.unsaved)) {
|
|
362
|
+
this.keep()
|
|
363
|
+
} else {
|
|
364
|
+
this.unsaved = null
|
|
365
|
+
this.keeper.remove(this.key)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
for (const [key, update] of this.merged) {
|
|
369
|
+
if (written && !covers(written, update)) continue
|
|
370
|
+
this.keeper.remove(key)
|
|
371
|
+
this.merged.delete(key)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private onAwareness = (
|
|
376
|
+
changes: { added: number[]; updated: number[]; removed: number[] },
|
|
377
|
+
origin: unknown
|
|
378
|
+
): void => {
|
|
379
|
+
if (origin === FROM_SERVER || !this.joined) return
|
|
380
|
+
|
|
381
|
+
const own = [...changes.added, ...changes.updated, ...changes.removed].filter(
|
|
382
|
+
(client) => client === this.doc.clientID
|
|
383
|
+
)
|
|
384
|
+
if (own.length > 0) this.sendAwareness(own)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
private sendSync(bytes: Uint8Array): void {
|
|
388
|
+
for (const message of liveSync(this.artifactId, bytes)) this.send(message)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
private sendAwareness(clients: readonly number[]): void {
|
|
392
|
+
const update = awarenessProtocol.encodeAwarenessUpdate(this.awareness, [...clients])
|
|
393
|
+
this.send({ type: "awareness", artifactId: this.artifactId, data: encodeLiveData(update) })
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private update(patch: Partial<LiveArtifactState>): void {
|
|
397
|
+
this.state = { ...this.state, ...patch }
|
|
398
|
+
for (const listener of this.listeners) listener()
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Opens the socket a hub speaks through: `createArtifactLiveSocket`, or a test's. */
|
|
403
|
+
export type LiveSocketFactory = (handlers: {
|
|
404
|
+
readonly onConnected: () => void
|
|
405
|
+
readonly onMessage: (message: ArtifactLiveServerMessage) => void
|
|
406
|
+
readonly onClosed: () => void
|
|
407
|
+
}) => ArtifactLiveSocket
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The artifacts a page holds live, over one socket opened with the first and closed with the
|
|
411
|
+
* last. Views acquire an artifact and release it; one no view holds for {@link LINGER_MS} leaves.
|
|
412
|
+
*/
|
|
413
|
+
export class LiveHub {
|
|
414
|
+
private socket: ArtifactLiveSocket | null = null
|
|
415
|
+
private online = false
|
|
416
|
+
private readonly held = new Map<
|
|
417
|
+
string,
|
|
418
|
+
{ readonly artifact: LiveArtifact; holders: number; linger?: ReturnType<typeof setTimeout> }
|
|
419
|
+
>()
|
|
420
|
+
|
|
421
|
+
constructor(
|
|
422
|
+
private readonly open: LiveSocketFactory = openLiveSocket,
|
|
423
|
+
private readonly keeper: LiveKeeper = browserKeeper
|
|
424
|
+
) {}
|
|
425
|
+
|
|
426
|
+
acquire(artifactId: string): LiveArtifact {
|
|
427
|
+
const entry = this.held.get(artifactId)
|
|
428
|
+
if (entry) {
|
|
429
|
+
entry.holders += 1
|
|
430
|
+
if (entry.linger) clearTimeout(entry.linger)
|
|
431
|
+
entry.linger = undefined
|
|
432
|
+
return entry.artifact
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const artifact = new LiveArtifact(
|
|
436
|
+
artifactId,
|
|
437
|
+
(message) => this.socket?.send(message) ?? false,
|
|
438
|
+
this.keeper
|
|
439
|
+
)
|
|
440
|
+
this.held.set(artifactId, { artifact, holders: 1 })
|
|
441
|
+
if (!this.socket) this.connect()
|
|
442
|
+
else if (this.online) artifact.connected()
|
|
443
|
+
return artifact
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
release(artifact: LiveArtifact): void {
|
|
447
|
+
const entry = this.held.get(artifact.artifactId)
|
|
448
|
+
if (!entry || entry.artifact !== artifact) return
|
|
449
|
+
|
|
450
|
+
entry.holders -= 1
|
|
451
|
+
if (entry.holders > 0) return
|
|
452
|
+
|
|
453
|
+
this.linger(entry)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Leaves an artifact no view holds after {@link LINGER_MS}, once the server wrote what this
|
|
458
|
+
* page changed in it: changes made offline, or whose view went away before they were saved,
|
|
459
|
+
* wait in it for the next connection, and a view that comes back finds them. What others
|
|
460
|
+
* changed is not this page's to wait for.
|
|
461
|
+
*/
|
|
462
|
+
private linger(entry: {
|
|
463
|
+
readonly artifact: LiveArtifact
|
|
464
|
+
linger?: ReturnType<typeof setTimeout>
|
|
465
|
+
}) {
|
|
466
|
+
const { artifact } = entry
|
|
467
|
+
entry.linger = setTimeout(() => {
|
|
468
|
+
if (artifact.hasUnsaved && !artifact.getState().left) {
|
|
469
|
+
this.linger(entry)
|
|
470
|
+
return
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
this.held.delete(artifact.artifactId)
|
|
474
|
+
artifact.destroy()
|
|
475
|
+
if (this.held.size === 0) this.disconnect()
|
|
476
|
+
}, LINGER_MS)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
private connect(): void {
|
|
480
|
+
this.socket = this.open({
|
|
481
|
+
onConnected: () => {
|
|
482
|
+
this.online = true
|
|
483
|
+
for (const { artifact } of this.held.values()) artifact.connected()
|
|
484
|
+
},
|
|
485
|
+
onMessage: (message) => {
|
|
486
|
+
const artifactId = "artifactId" in message ? message.artifactId : undefined
|
|
487
|
+
const artifact = artifactId ? this.held.get(artifactId)?.artifact : undefined
|
|
488
|
+
if (artifact) artifact.receive(message)
|
|
489
|
+
else if (message.type === "error")
|
|
490
|
+
console.warn(`[SixbApp] Live artifacts: ${message.message}`)
|
|
491
|
+
},
|
|
492
|
+
onClosed: () => {
|
|
493
|
+
this.online = false
|
|
494
|
+
for (const { artifact } of this.held.values()) artifact.disconnected()
|
|
495
|
+
},
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
private disconnect(): void {
|
|
500
|
+
this.socket?.close()
|
|
501
|
+
this.socket = null
|
|
502
|
+
this.online = false
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function openLiveSocket(handlers: Parameters<LiveSocketFactory>[0]): ArtifactLiveSocket {
|
|
507
|
+
let connected = false
|
|
508
|
+
return createArtifactLiveSocket({
|
|
509
|
+
onConnected: () => {
|
|
510
|
+
connected = true
|
|
511
|
+
handlers.onConnected()
|
|
512
|
+
},
|
|
513
|
+
onMessage: handlers.onMessage,
|
|
514
|
+
onStateChange: (state) => {
|
|
515
|
+
if (state.connected || !connected) return
|
|
516
|
+
connected = false
|
|
517
|
+
handlers.onClosed()
|
|
518
|
+
},
|
|
519
|
+
})
|
|
520
|
+
}
|