@atmos.build/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/components/alert-dialog.d.ts +14 -0
- package/dist/components/alert-dialog.js +40 -0
- package/dist/components/at-search.d.ts +35 -0
- package/dist/components/at-search.js +57 -0
- package/dist/components/attachment-thumbnail-stack.d.ts +13 -0
- package/dist/components/attachment-thumbnail-stack.js +23 -0
- package/dist/components/audio-preview.d.ts +33 -0
- package/dist/components/audio-preview.js +176 -0
- package/dist/components/avatar-uploader.d.ts +29 -0
- package/dist/components/avatar-uploader.js +67 -0
- package/dist/components/avatar.d.ts +12 -0
- package/dist/components/avatar.js +38 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/button-group.d.ts +12 -0
- package/dist/components/button-group.js +29 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +42 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +154 -0
- package/dist/components/channel-list.d.ts +33 -0
- package/dist/components/channel-list.js +40 -0
- package/dist/components/charts/area-chart.d.ts +2 -0
- package/dist/components/charts/area-chart.js +5 -0
- package/dist/components/charts/bar-chart.d.ts +2 -0
- package/dist/components/charts/bar-chart.js +58 -0
- package/dist/components/charts/colors.d.ts +2 -0
- package/dist/components/charts/colors.js +42 -0
- package/dist/components/charts/hover.d.ts +20 -0
- package/dist/components/charts/hover.js +31 -0
- package/dist/components/charts/index.d.ts +10 -0
- package/dist/components/charts/index.js +9 -0
- package/dist/components/charts/layout.d.ts +35 -0
- package/dist/components/charts/layout.js +101 -0
- package/dist/components/charts/legend.d.ts +6 -0
- package/dist/components/charts/legend.js +7 -0
- package/dist/components/charts/line-area-chart.d.ts +4 -0
- package/dist/components/charts/line-area-chart.js +86 -0
- package/dist/components/charts/line-chart.d.ts +2 -0
- package/dist/components/charts/line-chart.js +5 -0
- package/dist/components/charts/pie-chart.d.ts +2 -0
- package/dist/components/charts/pie-chart.js +22 -0
- package/dist/components/charts/radar-chart.d.ts +2 -0
- package/dist/components/charts/radar-chart.js +29 -0
- package/dist/components/charts/radial-chart.d.ts +2 -0
- package/dist/components/charts/radial-chart.js +19 -0
- package/dist/components/charts/scatter-chart.d.ts +2 -0
- package/dist/components/charts/scatter-chart.js +16 -0
- package/dist/components/charts/story-data.d.ts +24 -0
- package/dist/components/charts/story-data.js +48 -0
- package/dist/components/charts/types.d.ts +43 -0
- package/dist/components/charts/types.js +1 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/chip.d.ts +25 -0
- package/dist/components/chip.js +36 -0
- package/dist/components/code-editor-theme.d.ts +19 -0
- package/dist/components/code-editor-theme.js +100 -0
- package/dist/components/collapsible-section-header.d.ts +82 -0
- package/dist/components/collapsible-section-header.js +82 -0
- package/dist/components/collection-view/collection-view-group-settings.d.ts +73 -0
- package/dist/components/collection-view/collection-view-group-settings.js +55 -0
- package/dist/components/collection-view/collection-view-settings.d.ts +115 -0
- package/dist/components/collection-view/collection-view-settings.js +146 -0
- package/dist/components/collection-view/collection-view.d.ts +87 -0
- package/dist/components/collection-view/collection-view.js +95 -0
- package/dist/components/collection-view/index.d.ts +6 -0
- package/dist/components/collection-view/index.js +6 -0
- package/dist/components/collection-view/use-collection-detail-navigation.d.ts +11 -0
- package/dist/components/collection-view/use-collection-detail-navigation.js +12 -0
- package/dist/components/collection-view/use-collection-escape.d.ts +9 -0
- package/dist/components/collection-view/use-collection-escape.js +20 -0
- package/dist/components/collection-view/use-collection-selection.d.ts +42 -0
- package/dist/components/collection-view/use-collection-selection.js +203 -0
- package/dist/components/color-picker.d.ts +18 -0
- package/dist/components/color-picker.js +77 -0
- package/dist/components/color-swatch-list.d.ts +16 -0
- package/dist/components/color-swatch-list.js +60 -0
- package/dist/components/combobox/combobox.d.ts +4 -0
- package/dist/components/combobox/combobox.js +70 -0
- package/dist/components/combobox/compound.d.ts +68 -0
- package/dist/components/combobox/compound.js +151 -0
- package/dist/components/combobox/context.d.ts +34 -0
- package/dist/components/combobox/context.js +123 -0
- package/dist/components/combobox/create-step.d.ts +12 -0
- package/dist/components/combobox/create-step.js +8 -0
- package/dist/components/combobox/index.d.ts +10 -0
- package/dist/components/combobox/index.js +5 -0
- package/dist/components/combobox/inline-create-form.d.ts +24 -0
- package/dist/components/combobox/inline-create-form.js +43 -0
- package/dist/components/combobox/types.d.ts +57 -0
- package/dist/components/combobox/types.js +10 -0
- package/dist/components/command.d.ts +35 -0
- package/dist/components/command.js +76 -0
- package/dist/components/comment-pin.d.ts +13 -0
- package/dist/components/comment-pin.js +33 -0
- package/dist/components/confidence-meter.d.ts +11 -0
- package/dist/components/confidence-meter.js +24 -0
- package/dist/components/context-menu.d.ts +31 -0
- package/dist/components/context-menu.js +54 -0
- package/dist/components/copy-button.d.ts +12 -0
- package/dist/components/copy-button.js +32 -0
- package/dist/components/date-picker.d.ts +29 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/date-tile.d.ts +11 -0
- package/dist/components/date-tile.js +16 -0
- package/dist/components/date-time-picker.d.ts +25 -0
- package/dist/components/date-time-picker.js +153 -0
- package/dist/components/detail-breadcrumb-utils.d.ts +2 -0
- package/dist/components/detail-breadcrumb-utils.js +18 -0
- package/dist/components/detail-nav-bar.d.ts +28 -0
- package/dist/components/detail-nav-bar.js +28 -0
- package/dist/components/detail-top-bar.d.ts +49 -0
- package/dist/components/detail-top-bar.js +41 -0
- package/dist/components/dialog.d.ts +22 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dropdown-menu.d.ts +29 -0
- package/dist/components/dropdown-menu.js +52 -0
- package/dist/components/editable-doc-title.d.ts +17 -0
- package/dist/components/editable-doc-title.js +147 -0
- package/dist/components/empty-state.d.ts +12 -0
- package/dist/components/empty-state.js +6 -0
- package/dist/components/filter-condition-editor.d.ts +18 -0
- package/dist/components/filter-condition-editor.js +102 -0
- package/dist/components/form-dialog.d.ts +30 -0
- package/dist/components/form-dialog.js +52 -0
- package/dist/components/formula-editor.d.ts +18 -0
- package/dist/components/formula-editor.js +154 -0
- package/dist/components/hover-card.d.ts +52 -0
- package/dist/components/hover-card.js +51 -0
- package/dist/components/icon-button.d.ts +15 -0
- package/dist/components/icon-button.js +18 -0
- package/dist/components/inline-alert.d.ts +11 -0
- package/dist/components/inline-alert.js +17 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +7 -0
- package/dist/components/kanban-board.d.ts +27 -0
- package/dist/components/kanban-board.js +145 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +9 -0
- package/dist/components/markdown-editor/index.d.ts +4 -0
- package/dist/components/markdown-editor/index.js +2 -0
- package/dist/components/markdown-editor/markdown-editor.d.ts +16 -0
- package/dist/components/markdown-editor/markdown-editor.js +53 -0
- package/dist/components/markdown-editor/serialize.d.ts +12 -0
- package/dist/components/markdown-editor/serialize.js +122 -0
- package/dist/components/markdown-editor/vim.d.ts +8 -0
- package/dist/components/markdown-editor/vim.js +394 -0
- package/dist/components/metric-grid.d.ts +41 -0
- package/dist/components/metric-grid.js +39 -0
- package/dist/components/microphone-priority.d.ts +29 -0
- package/dist/components/microphone-priority.js +15 -0
- package/dist/components/middle-truncate.d.ts +6 -0
- package/dist/components/middle-truncate.js +15 -0
- package/dist/components/multi-combobox.d.ts +48 -0
- package/dist/components/multi-combobox.js +221 -0
- package/dist/components/naut-avatar-engine.d.ts +83 -0
- package/dist/components/naut-avatar-engine.js +803 -0
- package/dist/components/naut-avatar.d.ts +31 -0
- package/dist/components/naut-avatar.js +108 -0
- package/dist/components/navigable-list.d.ts +4 -0
- package/dist/components/navigable-list.js +20 -0
- package/dist/components/note-icon-picker.d.ts +20 -0
- package/dist/components/note-icon-picker.js +84 -0
- package/dist/components/note-icon.d.ts +690 -0
- package/dist/components/note-icon.js +353 -0
- package/dist/components/note-row.d.ts +33 -0
- package/dist/components/note-row.js +29 -0
- package/dist/components/overlapping-dots.d.ts +10 -0
- package/dist/components/overlapping-dots.js +13 -0
- package/dist/components/overview-card.d.ts +12 -0
- package/dist/components/overview-card.js +9 -0
- package/dist/components/panel-header.d.ts +8 -0
- package/dist/components/panel-header.js +6 -0
- package/dist/components/panel-section-states.d.ts +9 -0
- package/dist/components/panel-section-states.js +10 -0
- package/dist/components/person-avatar.d.ts +10 -0
- package/dist/components/person-avatar.js +23 -0
- package/dist/components/photo-avatar.d.ts +11 -0
- package/dist/components/photo-avatar.js +24 -0
- package/dist/components/picker-field.d.ts +23 -0
- package/dist/components/picker-field.js +24 -0
- package/dist/components/popover-stack.d.ts +26 -0
- package/dist/components/popover-stack.js +89 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +31 -0
- package/dist/components/portal-login-barrier.d.ts +12 -0
- package/dist/components/portal-login-barrier.js +41 -0
- package/dist/components/presence-dot.d.ts +8 -0
- package/dist/components/presence-dot.js +15 -0
- package/dist/components/presence-overlay.d.ts +27 -0
- package/dist/components/presence-overlay.js +34 -0
- package/dist/components/property-list.d.ts +64 -0
- package/dist/components/property-list.js +313 -0
- package/dist/components/property-panel.d.ts +54 -0
- package/dist/components/property-panel.js +87 -0
- package/dist/components/property-selector.d.ts +36 -0
- package/dist/components/property-selector.js +141 -0
- package/dist/components/provenance-chip.d.ts +12 -0
- package/dist/components/provenance-chip.js +17 -0
- package/dist/components/qr-code.d.ts +13 -0
- package/dist/components/qr-code.js +42 -0
- package/dist/components/qr-encode.d.ts +2 -0
- package/dist/components/qr-encode.js +469 -0
- package/dist/components/quantity-stepper.d.ts +25 -0
- package/dist/components/quantity-stepper.js +43 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/rename-dialog.d.ts +19 -0
- package/dist/components/rename-dialog.js +35 -0
- package/dist/components/row-surface.d.ts +1 -0
- package/dist/components/row-surface.js +5 -0
- package/dist/components/row-trailing.d.ts +30 -0
- package/dist/components/row-trailing.js +59 -0
- package/dist/components/run-status-badge.d.ts +16 -0
- package/dist/components/run-status-badge.js +43 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +39 -0
- package/dist/components/selectable-card.d.ts +33 -0
- package/dist/components/selectable-card.js +66 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +8 -0
- package/dist/components/settings-dialog-shell.d.ts +46 -0
- package/dist/components/settings-dialog-shell.js +48 -0
- package/dist/components/shimmer-text.d.ts +8 -0
- package/dist/components/shimmer-text.js +26 -0
- package/dist/components/side-panel-tokens.d.ts +27 -0
- package/dist/components/side-panel-tokens.js +26 -0
- package/dist/components/side-panel.d.ts +94 -0
- package/dist/components/side-panel.js +106 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/sortable.d.ts +65 -0
- package/dist/components/sortable.js +110 -0
- package/dist/components/spec-strip.d.ts +18 -0
- package/dist/components/spec-strip.js +15 -0
- package/dist/components/speech-playback.d.ts +25 -0
- package/dist/components/speech-playback.js +35 -0
- package/dist/components/sql-editor.d.ts +13 -0
- package/dist/components/sql-editor.js +228 -0
- package/dist/components/stat-tile.d.ts +7 -0
- package/dist/components/stat-tile.js +6 -0
- package/dist/components/status-badge.d.ts +17 -0
- package/dist/components/status-badge.js +8 -0
- package/dist/components/status-tone.d.ts +9 -0
- package/dist/components/status-tone.js +10 -0
- package/dist/components/sticky-header-fade.d.ts +8 -0
- package/dist/components/sticky-header-fade.js +11 -0
- package/dist/components/swatch-button.d.ts +14 -0
- package/dist/components/swatch-button.js +25 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/system-load/index.d.ts +6 -0
- package/dist/components/system-load/index.js +6 -0
- package/dist/components/system-load/load-block.d.ts +20 -0
- package/dist/components/system-load/load-block.js +23 -0
- package/dist/components/system-load/load-grid.d.ts +16 -0
- package/dist/components/system-load/load-grid.js +23 -0
- package/dist/components/system-load/load-meter.d.ts +25 -0
- package/dist/components/system-load/load-meter.js +29 -0
- package/dist/components/system-load/load-tone.d.ts +21 -0
- package/dist/components/system-load/load-tone.js +29 -0
- package/dist/components/system-load/meter-row.d.ts +31 -0
- package/dist/components/system-load/meter-row.js +29 -0
- package/dist/components/system-load/resource-meter.d.ts +19 -0
- package/dist/components/system-load/resource-meter.js +15 -0
- package/dist/components/tab-title-bar.d.ts +12 -0
- package/dist/components/tab-title-bar.js +9 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +29 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +97 -0
- package/dist/components/template-chip-input.d.ts +36 -0
- package/dist/components/template-chip-input.js +271 -0
- package/dist/components/template-input.d.ts +24 -0
- package/dist/components/template-input.js +57 -0
- package/dist/components/terminal-spinner.d.ts +11 -0
- package/dist/components/terminal-spinner.js +48 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/time-column.d.ts +24 -0
- package/dist/components/time-column.js +60 -0
- package/dist/components/timestamped-transcript.d.ts +38 -0
- package/dist/components/timestamped-transcript.js +29 -0
- package/dist/components/timezone-picker.d.ts +22 -0
- package/dist/components/timezone-picker.js +60 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +29 -0
- package/dist/components/transcription-overlay.d.ts +47 -0
- package/dist/components/transcription-overlay.js +30 -0
- package/dist/components/usage-bar.d.ts +17 -0
- package/dist/components/usage-bar.js +26 -0
- package/dist/components/view-query-bar.d.ts +13 -0
- package/dist/components/view-query-bar.js +13 -0
- package/dist/components/view-query-controls.d.ts +159 -0
- package/dist/components/view-query-controls.js +109 -0
- package/dist/components/view-save-menu.d.ts +20 -0
- package/dist/components/view-save-menu.js +13 -0
- package/dist/components/view-sort-editor.d.ts +40 -0
- package/dist/components/view-sort-editor.js +47 -0
- package/dist/components/voice-line.d.ts +37 -0
- package/dist/components/voice-line.js +293 -0
- package/dist/components/weekly-schedule-editor.d.ts +15 -0
- package/dist/components/weekly-schedule-editor.js +28 -0
- package/dist/flow/canvas/canvas-frame.d.ts +160 -0
- package/dist/flow/canvas/canvas-frame.js +521 -0
- package/dist/flow/canvas/collaborator-layer.d.ts +12 -0
- package/dist/flow/canvas/collaborator-layer.js +43 -0
- package/dist/flow/canvas/connector-edge.d.ts +22 -0
- package/dist/flow/canvas/connector-edge.js +61 -0
- package/dist/flow/canvas/editor-context.d.ts +23 -0
- package/dist/flow/canvas/editor-context.js +6 -0
- package/dist/flow/canvas/graph-core.d.ts +60 -0
- package/dist/flow/canvas/graph-core.js +296 -0
- package/dist/flow/canvas/minimap-sticky-overlay.d.ts +4 -0
- package/dist/flow/canvas/minimap-sticky-overlay.js +45 -0
- package/dist/flow/canvas/node-card.d.ts +46 -0
- package/dist/flow/canvas/node-card.js +56 -0
- package/dist/flow/canvas/node-library.d.ts +40 -0
- package/dist/flow/canvas/node-library.js +54 -0
- package/dist/flow/canvas/sticky-notes.d.ts +25 -0
- package/dist/flow/canvas/sticky-notes.js +101 -0
- package/dist/flow/collaborative-graph-presence.d.ts +28 -0
- package/dist/flow/collaborative-graph-presence.js +55 -0
- package/dist/flow/collaborative-graph-sync.d.ts +40 -0
- package/dist/flow/collaborative-graph-sync.js +127 -0
- package/dist/flow/editor/adapter.d.ts +64 -0
- package/dist/flow/editor/adapter.js +1 -0
- package/dist/flow/editor/command-registry.d.ts +10 -0
- package/dist/flow/editor/command-registry.js +35 -0
- package/dist/flow/editor/dag-canvas.d.ts +18 -0
- package/dist/flow/editor/dag-canvas.js +33 -0
- package/dist/flow/editor/flow-editor.d.ts +54 -0
- package/dist/flow/editor/flow-editor.js +199 -0
- package/dist/flow/editor/issues-popover.d.ts +11 -0
- package/dist/flow/editor/issues-popover.js +70 -0
- package/dist/flow/editor/library-rail.d.ts +19 -0
- package/dist/flow/editor/library-rail.js +25 -0
- package/dist/flow/editor/make-controller.d.ts +18 -0
- package/dist/flow/editor/make-controller.js +44 -0
- package/dist/flow/editor/node-chip.d.ts +2 -0
- package/dist/flow/editor/node-chip.js +16 -0
- package/dist/flow/editor/save-publish-bar.d.ts +27 -0
- package/dist/flow/editor/save-publish-bar.js +14 -0
- package/dist/flow/editor/settings-dialog.d.ts +11 -0
- package/dist/flow/editor/settings-dialog.js +11 -0
- package/dist/flow/editor/settings-shell.d.ts +21 -0
- package/dist/flow/editor/settings-shell.js +20 -0
- package/dist/flow/editor/side-rail.d.ts +22 -0
- package/dist/flow/editor/side-rail.js +15 -0
- package/dist/flow/editor/use-dag-editor.d.ts +94 -0
- package/dist/flow/editor/use-dag-editor.js +502 -0
- package/dist/flow/index.d.ts +25 -0
- package/dist/flow/index.js +25 -0
- package/dist/flow/presence-motion.d.ts +10 -0
- package/dist/flow/presence-motion.js +88 -0
- package/dist/flow/styles.css +1 -0
- package/dist/flow/use-collaborative-graph.d.ts +61 -0
- package/dist/flow/use-collaborative-graph.js +396 -0
- package/dist/flow/use-debounced-value.d.ts +1 -0
- package/dist/flow/use-debounced-value.js +10 -0
- package/dist/hooks/use-detail-nav.d.ts +11 -0
- package/dist/hooks/use-detail-nav.js +49 -0
- package/dist/hooks/use-flush-on-hide.d.ts +1 -0
- package/dist/hooks/use-flush-on-hide.js +21 -0
- package/dist/hooks/use-media-query.d.ts +1 -0
- package/dist/hooks/use-media-query.js +20 -0
- package/dist/hooks/use-virtualizer.d.ts +1 -0
- package/dist/hooks/use-virtualizer.js +1 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +139 -0
- package/dist/lib/brand-style.d.ts +6 -0
- package/dist/lib/brand-style.js +16 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/composited-glint.d.ts +7 -0
- package/dist/lib/composited-glint.js +98 -0
- package/dist/lib/date-time-format.d.ts +2 -0
- package/dist/lib/date-time-format.js +21 -0
- package/dist/lib/disclosure-state.d.ts +11 -0
- package/dist/lib/disclosure-state.js +22 -0
- package/dist/lib/label-swatches.d.ts +10 -0
- package/dist/lib/label-swatches.js +24 -0
- package/dist/lib/local-ui-state.d.ts +10 -0
- package/dist/lib/local-ui-state.js +95 -0
- package/dist/lib/parse-loose-datetime.d.ts +1 -0
- package/dist/lib/parse-loose-datetime.js +180 -0
- package/dist/lib/parse-loose-time.d.ts +6 -0
- package/dist/lib/parse-loose-time.js +53 -0
- package/dist/lib/parse-loose.d.ts +1 -0
- package/dist/lib/parse-loose.js +170 -0
- package/dist/lib/react-19-jsx.d.ts +8 -0
- package/dist/lib/react-19-jsx.js +1 -0
- package/dist/lib/view-chrome.d.ts +5 -0
- package/dist/lib/view-chrome.js +5 -0
- package/dist/lib/view-query/config.d.ts +26 -0
- package/dist/lib/view-query/config.js +162 -0
- package/dist/lib/view-query/evaluate.d.ts +11 -0
- package/dist/lib/view-query/evaluate.js +196 -0
- package/dist/lib/view-query/group-order.d.ts +25 -0
- package/dist/lib/view-query/group-order.js +49 -0
- package/dist/lib/view-query/index.d.ts +6 -0
- package/dist/lib/view-query/index.js +6 -0
- package/dist/lib/view-query/model.d.ts +34 -0
- package/dist/lib/view-query/model.js +88 -0
- package/dist/lib/view-query/sort.d.ts +7 -0
- package/dist/lib/view-query/sort.js +30 -0
- package/dist/lib/view-query/types.d.ts +70 -0
- package/dist/lib/view-query/types.js +12 -0
- package/dist/lib/weekly-schedule.d.ts +8 -0
- package/dist/lib/weekly-schedule.js +10 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/index.js +3 -0
- package/dist/mcp-app/shadcn.css +629 -0
- package/dist/mcp-app/styles.css +72 -0
- package/dist/mcp-app/theme.d.ts +2 -0
- package/dist/mcp-app/theme.js +62 -0
- package/dist/mcp-app/use-atmos-mcp-app.d.ts +109 -0
- package/dist/mcp-app/use-atmos-mcp-app.js +30 -0
- package/dist/mcp-app/vite.d.ts +7 -0
- package/dist/mcp-app/vite.js +30 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.js +7 -0
- package/dist/tokens/semantic.css +110 -0
- package/dist/tokens/tokens.css +195 -0
- package/package.json +98 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
const smoothingMs = 55;
|
|
4
|
+
const coastAfterMs = 70;
|
|
5
|
+
const coastForMs = 280;
|
|
6
|
+
const maxCoastMs = 160;
|
|
7
|
+
export function useSmoothedFlowPoints(targets) {
|
|
8
|
+
const statesRef = useRef(new Map());
|
|
9
|
+
const frameRef = useRef(null);
|
|
10
|
+
const [points, setPoints] = useState(() => new Map());
|
|
11
|
+
const publish = useCallback(() => {
|
|
12
|
+
const next = new Map();
|
|
13
|
+
for (const [id, state] of statesRef.current)
|
|
14
|
+
next.set(id, { ...state.current });
|
|
15
|
+
setPoints(next);
|
|
16
|
+
}, []);
|
|
17
|
+
const start = useCallback(() => {
|
|
18
|
+
if (frameRef.current !== null || typeof requestAnimationFrame === 'undefined')
|
|
19
|
+
return;
|
|
20
|
+
const tick = (now) => {
|
|
21
|
+
frameRef.current = null;
|
|
22
|
+
let active = false;
|
|
23
|
+
for (const state of statesRef.current.values()) {
|
|
24
|
+
const frameDeltaMs = Math.max(0, now - state.lastFrameAt);
|
|
25
|
+
state.lastFrameAt = now;
|
|
26
|
+
const sinceTargetMs = Math.max(0, now - state.lastTargetAt);
|
|
27
|
+
const coastMs = Math.min(maxCoastMs, Math.max(0, sinceTargetMs - coastAfterMs));
|
|
28
|
+
const decay = sinceTargetMs >= coastAfterMs + coastForMs ? 0 : 1 - coastMs / maxCoastMs;
|
|
29
|
+
const predicted = sinceTargetMs <= coastAfterMs
|
|
30
|
+
? state.target
|
|
31
|
+
: {
|
|
32
|
+
x: state.target.x + state.velocity.x * (coastMs / 1000) * decay,
|
|
33
|
+
y: state.target.y + state.velocity.y * (coastMs / 1000) * decay,
|
|
34
|
+
};
|
|
35
|
+
const alpha = 1 - Math.exp(-frameDeltaMs / smoothingMs);
|
|
36
|
+
state.current = {
|
|
37
|
+
x: state.current.x + (predicted.x - state.current.x) * alpha,
|
|
38
|
+
y: state.current.y + (predicted.y - state.current.y) * alpha,
|
|
39
|
+
};
|
|
40
|
+
if (Math.hypot(predicted.x - state.current.x, predicted.y - state.current.y) > 0.25 ||
|
|
41
|
+
sinceTargetMs < coastAfterMs + coastForMs)
|
|
42
|
+
active = true;
|
|
43
|
+
}
|
|
44
|
+
publish();
|
|
45
|
+
if (active)
|
|
46
|
+
frameRef.current = requestAnimationFrame(tick);
|
|
47
|
+
};
|
|
48
|
+
frameRef.current = requestAnimationFrame(tick);
|
|
49
|
+
}, [publish]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const now = typeof performance === 'undefined' ? Date.now() : performance.now();
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
for (const target of targets) {
|
|
54
|
+
if (!target.point)
|
|
55
|
+
continue;
|
|
56
|
+
seen.add(target.id);
|
|
57
|
+
const state = statesRef.current.get(target.id);
|
|
58
|
+
if (!state) {
|
|
59
|
+
statesRef.current.set(target.id, {
|
|
60
|
+
current: { ...target.point },
|
|
61
|
+
target: { ...target.point },
|
|
62
|
+
velocity: { x: 0, y: 0 },
|
|
63
|
+
lastTargetAt: now,
|
|
64
|
+
lastFrameAt: now,
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const elapsedSeconds = Math.max(0.016, (now - state.lastTargetAt) / 1000);
|
|
69
|
+
state.velocity = {
|
|
70
|
+
x: (target.point.x - state.target.x) / elapsedSeconds,
|
|
71
|
+
y: (target.point.y - state.target.y) / elapsedSeconds,
|
|
72
|
+
};
|
|
73
|
+
state.target = { ...target.point };
|
|
74
|
+
state.lastTargetAt = now;
|
|
75
|
+
}
|
|
76
|
+
for (const id of statesRef.current.keys()) {
|
|
77
|
+
if (!seen.has(id))
|
|
78
|
+
statesRef.current.delete(id);
|
|
79
|
+
}
|
|
80
|
+
start();
|
|
81
|
+
return () => {
|
|
82
|
+
if (frameRef.current !== null && typeof cancelAnimationFrame !== 'undefined')
|
|
83
|
+
cancelAnimationFrame(frameRef.current);
|
|
84
|
+
frameRef.current = null;
|
|
85
|
+
};
|
|
86
|
+
}, [publish, start, targets]);
|
|
87
|
+
return points;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'reactflow/dist/style.css';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Edge, Node } from 'reactflow';
|
|
2
|
+
import { type CollaborativeGraphPatch, type CollaborativeGraphSnapshot, type CollaborativeYDoc } from './collaborative-graph-sync.js';
|
|
3
|
+
import { type CollaborativeConnectionStatus, type CollaborativeGraphDrag, type CollaborativeGraphPeer } from './collaborative-graph-presence.js';
|
|
4
|
+
import type { RemoteGraphPhase } from './editor/use-dag-editor.js';
|
|
5
|
+
export interface CollaborativeGraphSurface {
|
|
6
|
+
readonly status: CollaborativeConnectionStatus;
|
|
7
|
+
readonly synced: boolean;
|
|
8
|
+
readonly document: unknown;
|
|
9
|
+
readonly peers: readonly {
|
|
10
|
+
connectionId: string;
|
|
11
|
+
state: unknown;
|
|
12
|
+
}[];
|
|
13
|
+
readonly updatePresence: (patch: Readonly<Record<string, unknown>>) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface CollaborativeGraphVersion {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly local: string;
|
|
18
|
+
readonly shouldUseRemote: (remote: string | null, local: string) => boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface CollaborativeGraphMetadata<TMetadata> {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
readonly value: TMetadata;
|
|
23
|
+
readonly serialize: (value: TMetadata) => string;
|
|
24
|
+
readonly coerce: (value: unknown) => TMetadata;
|
|
25
|
+
readonly onRemoteChange: (value: TMetadata) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface CollaborativeGraphOptions<TNodeData, TEdgeData, TMetadata = never> {
|
|
28
|
+
readonly enabled: boolean;
|
|
29
|
+
readonly surface: CollaborativeGraphSurface | null;
|
|
30
|
+
readonly nodes: Node<TNodeData>[];
|
|
31
|
+
readonly edges: Edge<TEdgeData>[];
|
|
32
|
+
readonly selectedNodeIds: string[];
|
|
33
|
+
readonly mapNames: {
|
|
34
|
+
nodes: string;
|
|
35
|
+
edges: string;
|
|
36
|
+
};
|
|
37
|
+
readonly stateMapName?: string;
|
|
38
|
+
readonly version?: CollaborativeGraphVersion;
|
|
39
|
+
readonly metadata?: CollaborativeGraphMetadata<TMetadata>;
|
|
40
|
+
readonly applyRemoteGraph: (snapshot: CollaborativeGraphSnapshot<TNodeData, TEdgeData>, phase: RemoteGraphPhase) => void;
|
|
41
|
+
readonly applyRemotePatch: (patch: CollaborativeGraphPatch<TNodeData, TEdgeData>, phase: RemoteGraphPhase) => void;
|
|
42
|
+
readonly graphWriteDelayMs?: number;
|
|
43
|
+
readonly deferGraphWriteUntilIdle?: boolean;
|
|
44
|
+
readonly pointerThrottleMs?: number;
|
|
45
|
+
readonly statusGraceMs?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface CollaborativeGraphState {
|
|
48
|
+
readonly status: CollaborativeConnectionStatus;
|
|
49
|
+
readonly collaborators: CollaborativeGraphPeer[];
|
|
50
|
+
readonly publishPointer: (pointer: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
} | null) => void;
|
|
54
|
+
readonly publishDrag: (drag: CollaborativeGraphDrag | null) => void;
|
|
55
|
+
}
|
|
56
|
+
export declare function useCollaborativeGraph<TNodeData, TEdgeData, TMetadata = never>(options: CollaborativeGraphOptions<TNodeData, TEdgeData, TMetadata>): CollaborativeGraphState;
|
|
57
|
+
export declare function readCollaborativeGraph<TNodeData, TEdgeData>(doc: CollaborativeYDoc, mapNames: {
|
|
58
|
+
nodes: string;
|
|
59
|
+
edges: string;
|
|
60
|
+
}): CollaborativeGraphSnapshot<TNodeData, TEdgeData>;
|
|
61
|
+
export declare function coerceCollaborativeGraph<TNodeData, TEdgeData>(value: unknown): CollaborativeGraphSnapshot<TNodeData, TEdgeData> | undefined;
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { collaborativeEdgeKey, collaborativePatchFromMapEvent, coerceCollaborativeEdge, coerceCollaborativeNode, createCollaborativeCollectionHashes, resetCollaborativeGraphHashes, serializeCollaborativeEdge, serializeCollaborativeNode, writeCollaborativeGraph, } from './collaborative-graph-sync.js';
|
|
4
|
+
import { parseCollaborativeGraphPeer, } from './collaborative-graph-presence.js';
|
|
5
|
+
const GRAPH_INITIALIZED_KEY = 'atmos.graph.initialized';
|
|
6
|
+
export function useCollaborativeGraph(options) {
|
|
7
|
+
const { enabled, surface, nodes, edges, selectedNodeIds, mapNames, stateMapName, version, metadata, applyRemoteGraph, applyRemotePatch, graphWriteDelayMs = 0, deferGraphWriteUntilIdle = false, pointerThrottleMs = 0, statusGraceMs = 0, } = options;
|
|
8
|
+
const nodesMapName = mapNames.nodes;
|
|
9
|
+
const edgesMapName = mapNames.edges;
|
|
10
|
+
const [status, setStatusState] = useState('connecting');
|
|
11
|
+
const rawStatusRef = useRef('connecting');
|
|
12
|
+
const statusTimerRef = useRef(null);
|
|
13
|
+
const docRef = useRef(null);
|
|
14
|
+
const surfaceRef = useRef(null);
|
|
15
|
+
const graphRef = useRef({ nodes, edges });
|
|
16
|
+
const metadataRef = useRef(metadata);
|
|
17
|
+
const versionRef = useRef(version);
|
|
18
|
+
const selectedNodeIdsRef = useRef(selectedNodeIds);
|
|
19
|
+
const applyRemoteGraphRef = useRef(applyRemoteGraph);
|
|
20
|
+
const applyRemotePatchRef = useRef(applyRemotePatch);
|
|
21
|
+
const applyingRemoteRef = useRef(false);
|
|
22
|
+
const applyingLocalRef = useRef(false);
|
|
23
|
+
const bootstrappedRef = useRef(false);
|
|
24
|
+
const graphWriteTimerRef = useRef(null);
|
|
25
|
+
const graphIdleWriteRef = useRef(null);
|
|
26
|
+
const pointerTimerRef = useRef(null);
|
|
27
|
+
const pendingPointerRef = useRef(null);
|
|
28
|
+
const dragTimerRef = useRef(null);
|
|
29
|
+
const pendingDragRef = useRef(null);
|
|
30
|
+
const hashesRef = useRef(createCollaborativeCollectionHashes());
|
|
31
|
+
const lastGraphRef = useRef('');
|
|
32
|
+
const lastMetadataRef = useRef('');
|
|
33
|
+
const committedVersionRef = useRef(null);
|
|
34
|
+
const setStatus = useCallback((next) => {
|
|
35
|
+
rawStatusRef.current = next;
|
|
36
|
+
if (next === 'connected' || statusGraceMs === 0) {
|
|
37
|
+
if (statusTimerRef.current)
|
|
38
|
+
clearTimeout(statusTimerRef.current);
|
|
39
|
+
statusTimerRef.current = null;
|
|
40
|
+
setStatusState(next);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (statusTimerRef.current)
|
|
44
|
+
return;
|
|
45
|
+
statusTimerRef.current = setTimeout(() => {
|
|
46
|
+
statusTimerRef.current = null;
|
|
47
|
+
setStatusState(rawStatusRef.current);
|
|
48
|
+
}, statusGraceMs);
|
|
49
|
+
}, [statusGraceMs]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
graphRef.current = { nodes, edges };
|
|
52
|
+
metadataRef.current = metadata;
|
|
53
|
+
versionRef.current = version;
|
|
54
|
+
selectedNodeIdsRef.current = selectedNodeIds;
|
|
55
|
+
applyRemoteGraphRef.current = applyRemoteGraph;
|
|
56
|
+
applyRemotePatchRef.current = applyRemotePatch;
|
|
57
|
+
surfaceRef.current = surface;
|
|
58
|
+
}, [
|
|
59
|
+
applyRemoteGraph,
|
|
60
|
+
applyRemotePatch,
|
|
61
|
+
edges,
|
|
62
|
+
metadata,
|
|
63
|
+
nodes,
|
|
64
|
+
selectedNodeIds,
|
|
65
|
+
surface,
|
|
66
|
+
version,
|
|
67
|
+
]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const timer = setTimeout(() => setStatus(surface?.status ?? 'connecting'), 0);
|
|
70
|
+
return () => clearTimeout(timer);
|
|
71
|
+
}, [setStatus, surface?.status]);
|
|
72
|
+
useEffect(() => () => {
|
|
73
|
+
if (statusTimerRef.current)
|
|
74
|
+
clearTimeout(statusTimerRef.current);
|
|
75
|
+
}, []);
|
|
76
|
+
const collaborators = useMemo(() => (surface?.peers ?? [])
|
|
77
|
+
.map((peer) => parseCollaborativeGraphPeer(peer.connectionId, peer.state))
|
|
78
|
+
.filter((peer) => peer !== null), [surface?.peers]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const activeSurface = surfaceRef.current;
|
|
81
|
+
if (!enabled || !activeSurface?.synced)
|
|
82
|
+
return;
|
|
83
|
+
const activeVersion = versionRef.current;
|
|
84
|
+
const doc = activeSurface.document;
|
|
85
|
+
const activeMapNames = { nodes: nodesMapName, edges: edgesMapName };
|
|
86
|
+
const nodesMap = doc.getMap(nodesMapName);
|
|
87
|
+
const edgesMap = doc.getMap(edgesMapName);
|
|
88
|
+
const resolvedStateMapName = stateMapName ?? `${nodesMapName}.state`;
|
|
89
|
+
const stateMap = doc.getMap(resolvedStateMapName);
|
|
90
|
+
const hashes = createCollaborativeCollectionHashes();
|
|
91
|
+
const initialGraph = collaborativeSnapshot(graphRef.current);
|
|
92
|
+
const initialSerialized = JSON.stringify(initialGraph);
|
|
93
|
+
const initialMetadata = metadataRef.current;
|
|
94
|
+
const initialMetadataSerialized = initialMetadata
|
|
95
|
+
? initialMetadata.serialize(initialMetadata.value)
|
|
96
|
+
: '';
|
|
97
|
+
docRef.current = doc;
|
|
98
|
+
hashesRef.current = hashes;
|
|
99
|
+
bootstrappedRef.current = false;
|
|
100
|
+
lastGraphRef.current = '';
|
|
101
|
+
lastMetadataRef.current = initialMetadataSerialized;
|
|
102
|
+
committedVersionRef.current = activeVersion?.local ?? null;
|
|
103
|
+
activeSurface.updatePresence({
|
|
104
|
+
pointer: null,
|
|
105
|
+
selectedNodeIds: selectedNodeIdsRef.current,
|
|
106
|
+
drag: null,
|
|
107
|
+
});
|
|
108
|
+
const applyGraph = (snapshot, phase) => {
|
|
109
|
+
const serialized = JSON.stringify(snapshot);
|
|
110
|
+
if (serialized === lastGraphRef.current)
|
|
111
|
+
return;
|
|
112
|
+
applyingRemoteRef.current = true;
|
|
113
|
+
lastGraphRef.current = serialized;
|
|
114
|
+
resetCollaborativeGraphHashes(snapshot, hashes);
|
|
115
|
+
applyRemoteGraphRef.current(snapshot, phase);
|
|
116
|
+
queueMicrotask(() => {
|
|
117
|
+
applyingRemoteRef.current = false;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const applyPatch = (patch, phase) => {
|
|
121
|
+
if (!collaborativePatchHasChanges(patch))
|
|
122
|
+
return;
|
|
123
|
+
applyingRemoteRef.current = true;
|
|
124
|
+
applyRemotePatchRef.current(patch, phase);
|
|
125
|
+
queueMicrotask(() => {
|
|
126
|
+
applyingRemoteRef.current = false;
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const applyMetadata = (value) => {
|
|
130
|
+
const current = metadataRef.current;
|
|
131
|
+
if (!current)
|
|
132
|
+
return;
|
|
133
|
+
const next = current.coerce(value);
|
|
134
|
+
const serialized = current.serialize(next);
|
|
135
|
+
if (serialized === lastMetadataRef.current)
|
|
136
|
+
return;
|
|
137
|
+
applyingRemoteRef.current = true;
|
|
138
|
+
lastMetadataRef.current = serialized;
|
|
139
|
+
current.onRemoteChange(next);
|
|
140
|
+
queueMicrotask(() => {
|
|
141
|
+
applyingRemoteRef.current = false;
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const onNodesUpdate = (event) => {
|
|
145
|
+
if (applyingLocalRef.current)
|
|
146
|
+
return;
|
|
147
|
+
applyPatch({
|
|
148
|
+
nodes: collaborativePatchFromMapEvent(event, nodesMap, hashes.nodes, (coerceCollaborativeNode), (node) => node.id),
|
|
149
|
+
}, 'peer');
|
|
150
|
+
};
|
|
151
|
+
const onEdgesUpdate = (event) => {
|
|
152
|
+
if (applyingLocalRef.current)
|
|
153
|
+
return;
|
|
154
|
+
applyPatch({
|
|
155
|
+
edges: collaborativePatchFromMapEvent(event, edgesMap, hashes.edges, (coerceCollaborativeEdge), collaborativeEdgeKey),
|
|
156
|
+
}, 'peer');
|
|
157
|
+
};
|
|
158
|
+
const onStateUpdate = (event) => {
|
|
159
|
+
if (applyingLocalRef.current || !stateMap)
|
|
160
|
+
return;
|
|
161
|
+
const currentMetadata = metadataRef.current;
|
|
162
|
+
if (currentMetadata && event.keysChanged.has(currentMetadata.key)) {
|
|
163
|
+
applyMetadata(stateMap.get(currentMetadata.key));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
nodesMap.observe(onNodesUpdate);
|
|
167
|
+
edgesMap.observe(onEdgesUpdate);
|
|
168
|
+
stateMap?.observe(onStateUpdate);
|
|
169
|
+
const remoteGraph = readCollaborativeGraph(doc, activeMapNames);
|
|
170
|
+
const remoteInitialized = stateMap.get(GRAPH_INITIALIZED_KEY) === true;
|
|
171
|
+
const remoteVersion = activeVersion && stateMap ? collaborativeString(stateMap.get(activeVersion.key)) : null;
|
|
172
|
+
const useRemote = Boolean(remoteInitialized &&
|
|
173
|
+
(activeVersion ? activeVersion.shouldUseRemote(remoteVersion, activeVersion.local) : true));
|
|
174
|
+
if (useRemote) {
|
|
175
|
+
const remoteSerialized = JSON.stringify(remoteGraph);
|
|
176
|
+
if (remoteSerialized !== initialSerialized) {
|
|
177
|
+
applyGraph(remoteGraph, 'bootstrap');
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
lastGraphRef.current = remoteSerialized;
|
|
181
|
+
resetCollaborativeGraphHashes(remoteGraph, hashes);
|
|
182
|
+
}
|
|
183
|
+
const currentMetadata = metadataRef.current;
|
|
184
|
+
if (currentMetadata && stateMap)
|
|
185
|
+
applyMetadata(stateMap.get(currentMetadata.key));
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
lastGraphRef.current = initialSerialized;
|
|
189
|
+
doc.transact(() => {
|
|
190
|
+
applyingLocalRef.current = true;
|
|
191
|
+
writeCollaborativeGraph(doc, initialGraph, activeMapNames, hashes);
|
|
192
|
+
if (stateMap.get(GRAPH_INITIALIZED_KEY) !== true) {
|
|
193
|
+
stateMap.set(GRAPH_INITIALIZED_KEY, true);
|
|
194
|
+
}
|
|
195
|
+
if (activeVersion)
|
|
196
|
+
stateMap.set(activeVersion.key, activeVersion.local);
|
|
197
|
+
const currentMetadata = metadataRef.current;
|
|
198
|
+
if (currentMetadata)
|
|
199
|
+
stateMap.set(currentMetadata.key, currentMetadata.value);
|
|
200
|
+
});
|
|
201
|
+
queueMicrotask(() => {
|
|
202
|
+
applyingLocalRef.current = false;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
bootstrappedRef.current = true;
|
|
206
|
+
return () => {
|
|
207
|
+
if (graphWriteTimerRef.current)
|
|
208
|
+
clearTimeout(graphWriteTimerRef.current);
|
|
209
|
+
if (graphIdleWriteRef.current)
|
|
210
|
+
cancelCollaborativeIdle(graphIdleWriteRef.current);
|
|
211
|
+
if (pointerTimerRef.current)
|
|
212
|
+
clearTimeout(pointerTimerRef.current);
|
|
213
|
+
if (dragTimerRef.current)
|
|
214
|
+
clearTimeout(dragTimerRef.current);
|
|
215
|
+
nodesMap.unobserve(onNodesUpdate);
|
|
216
|
+
edgesMap.unobserve(onEdgesUpdate);
|
|
217
|
+
stateMap?.unobserve(onStateUpdate);
|
|
218
|
+
docRef.current = null;
|
|
219
|
+
bootstrappedRef.current = false;
|
|
220
|
+
};
|
|
221
|
+
}, [
|
|
222
|
+
enabled,
|
|
223
|
+
edgesMapName,
|
|
224
|
+
nodesMapName,
|
|
225
|
+
stateMapName,
|
|
226
|
+
surface?.document,
|
|
227
|
+
surface?.synced,
|
|
228
|
+
surface?.updatePresence,
|
|
229
|
+
]);
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
const doc = docRef.current;
|
|
232
|
+
if (!doc || !bootstrappedRef.current || applyingRemoteRef.current)
|
|
233
|
+
return;
|
|
234
|
+
const resolvedStateMapName = stateMapName ?? `${nodesMapName}.state`;
|
|
235
|
+
const stateMap = doc.getMap(resolvedStateMapName);
|
|
236
|
+
const currentVersion = versionRef.current;
|
|
237
|
+
const activeMapNames = { nodes: nodesMapName, edges: edgesMapName };
|
|
238
|
+
const versionChanged = currentVersion && committedVersionRef.current !== currentVersion.local;
|
|
239
|
+
const write = () => {
|
|
240
|
+
const currentDoc = docRef.current;
|
|
241
|
+
if (!currentDoc || applyingRemoteRef.current)
|
|
242
|
+
return;
|
|
243
|
+
currentDoc.transact(() => {
|
|
244
|
+
applyingLocalRef.current = true;
|
|
245
|
+
writeCollaborativeGraph(currentDoc, graphRef.current, activeMapNames, hashesRef.current);
|
|
246
|
+
if (stateMap.get(GRAPH_INITIALIZED_KEY) !== true) {
|
|
247
|
+
stateMap.set(GRAPH_INITIALIZED_KEY, true);
|
|
248
|
+
}
|
|
249
|
+
if (versionChanged && currentVersion) {
|
|
250
|
+
stateMap.set(currentVersion.key, currentVersion.local);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
if (versionChanged && currentVersion)
|
|
254
|
+
committedVersionRef.current = currentVersion.local;
|
|
255
|
+
queueMicrotask(() => {
|
|
256
|
+
applyingLocalRef.current = false;
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
if (versionChanged || graphWriteDelayMs === 0) {
|
|
260
|
+
write();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (graphWriteTimerRef.current)
|
|
264
|
+
clearTimeout(graphWriteTimerRef.current);
|
|
265
|
+
if (graphIdleWriteRef.current)
|
|
266
|
+
cancelCollaborativeIdle(graphIdleWriteRef.current);
|
|
267
|
+
graphWriteTimerRef.current = setTimeout(() => {
|
|
268
|
+
graphWriteTimerRef.current = null;
|
|
269
|
+
if (deferGraphWriteUntilIdle) {
|
|
270
|
+
graphIdleWriteRef.current = scheduleCollaborativeIdle(() => {
|
|
271
|
+
graphIdleWriteRef.current = null;
|
|
272
|
+
write();
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
write();
|
|
277
|
+
}
|
|
278
|
+
}, graphWriteDelayMs);
|
|
279
|
+
}, [
|
|
280
|
+
deferGraphWriteUntilIdle,
|
|
281
|
+
edges,
|
|
282
|
+
graphWriteDelayMs,
|
|
283
|
+
edgesMapName,
|
|
284
|
+
nodesMapName,
|
|
285
|
+
nodes,
|
|
286
|
+
stateMapName,
|
|
287
|
+
version?.key,
|
|
288
|
+
version?.local,
|
|
289
|
+
]);
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
const doc = docRef.current;
|
|
292
|
+
if (!doc || !stateMapName || !metadata || !bootstrappedRef.current || applyingRemoteRef.current)
|
|
293
|
+
return;
|
|
294
|
+
const serialized = metadata.serialize(metadata.value);
|
|
295
|
+
if (serialized === lastMetadataRef.current)
|
|
296
|
+
return;
|
|
297
|
+
lastMetadataRef.current = serialized;
|
|
298
|
+
doc.transact(() => {
|
|
299
|
+
applyingLocalRef.current = true;
|
|
300
|
+
doc.getMap(stateMapName).set(metadata.key, metadata.value);
|
|
301
|
+
});
|
|
302
|
+
queueMicrotask(() => {
|
|
303
|
+
applyingLocalRef.current = false;
|
|
304
|
+
});
|
|
305
|
+
}, [metadata, stateMapName]);
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
surfaceRef.current?.updatePresence({ selectedNodeIds });
|
|
308
|
+
}, [selectedNodeIds]);
|
|
309
|
+
const publishPointer = useCallback((pointer) => {
|
|
310
|
+
pendingPointerRef.current = pointer;
|
|
311
|
+
if (pointerThrottleMs === 0) {
|
|
312
|
+
surfaceRef.current?.updatePresence({ pointer });
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (pointerTimerRef.current)
|
|
316
|
+
return;
|
|
317
|
+
pointerTimerRef.current = setTimeout(() => {
|
|
318
|
+
pointerTimerRef.current = null;
|
|
319
|
+
surfaceRef.current?.updatePresence({ pointer: pendingPointerRef.current });
|
|
320
|
+
}, pointerThrottleMs);
|
|
321
|
+
}, [pointerThrottleMs]);
|
|
322
|
+
const publishDrag = useCallback((drag) => {
|
|
323
|
+
pendingDragRef.current = drag;
|
|
324
|
+
// Drag end (null) must land immediately so a stale ghost never lingers.
|
|
325
|
+
if (drag === null || pointerThrottleMs === 0) {
|
|
326
|
+
if (dragTimerRef.current) {
|
|
327
|
+
clearTimeout(dragTimerRef.current);
|
|
328
|
+
dragTimerRef.current = null;
|
|
329
|
+
}
|
|
330
|
+
surfaceRef.current?.updatePresence({ drag });
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (dragTimerRef.current)
|
|
334
|
+
return;
|
|
335
|
+
dragTimerRef.current = setTimeout(() => {
|
|
336
|
+
dragTimerRef.current = null;
|
|
337
|
+
surfaceRef.current?.updatePresence({ drag: pendingDragRef.current });
|
|
338
|
+
}, pointerThrottleMs);
|
|
339
|
+
}, [pointerThrottleMs]);
|
|
340
|
+
return { status, collaborators, publishPointer, publishDrag };
|
|
341
|
+
}
|
|
342
|
+
export function readCollaborativeGraph(doc, mapNames) {
|
|
343
|
+
const nodesMap = doc.getMap(mapNames.nodes);
|
|
344
|
+
const edgesMap = doc.getMap(mapNames.edges);
|
|
345
|
+
return (coerceCollaborativeGraph({
|
|
346
|
+
nodes: Array.from(nodesMap.values()),
|
|
347
|
+
edges: Array.from(edgesMap.values()),
|
|
348
|
+
}) ?? { nodes: [], edges: [] });
|
|
349
|
+
}
|
|
350
|
+
export function coerceCollaborativeGraph(value) {
|
|
351
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
352
|
+
return undefined;
|
|
353
|
+
const record = value;
|
|
354
|
+
if (!Array.isArray(record.nodes) || !Array.isArray(record.edges))
|
|
355
|
+
return undefined;
|
|
356
|
+
return {
|
|
357
|
+
nodes: record.nodes
|
|
358
|
+
.map((coerceCollaborativeNode))
|
|
359
|
+
.filter((node) => node !== null),
|
|
360
|
+
edges: record.edges
|
|
361
|
+
.map((coerceCollaborativeEdge))
|
|
362
|
+
.filter((edge) => edge !== null),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function collaborativeSnapshot(graph) {
|
|
366
|
+
return {
|
|
367
|
+
nodes: graph.nodes.map(serializeCollaborativeNode),
|
|
368
|
+
edges: graph.edges.map(serializeCollaborativeEdge),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function collaborativePatchHasChanges(patch) {
|
|
372
|
+
return Boolean(patch.nodes?.upsert?.length ||
|
|
373
|
+
patch.nodes?.deleteIds?.length ||
|
|
374
|
+
patch.edges?.upsert?.length ||
|
|
375
|
+
patch.edges?.deleteIds?.length);
|
|
376
|
+
}
|
|
377
|
+
function collaborativeString(value) {
|
|
378
|
+
return typeof value === 'string' && value.trim() ? value : null;
|
|
379
|
+
}
|
|
380
|
+
function scheduleCollaborativeIdle(callback) {
|
|
381
|
+
if (typeof window !== 'undefined' && 'requestIdleCallback' in window) {
|
|
382
|
+
const request = window
|
|
383
|
+
.requestIdleCallback;
|
|
384
|
+
return { kind: 'idle', id: request(callback) };
|
|
385
|
+
}
|
|
386
|
+
return { kind: 'timer', id: setTimeout(callback, 0) };
|
|
387
|
+
}
|
|
388
|
+
function cancelCollaborativeIdle(handle) {
|
|
389
|
+
if (handle.kind === 'idle' && typeof window !== 'undefined' && 'cancelIdleCallback' in window) {
|
|
390
|
+
;
|
|
391
|
+
window.cancelIdleCallback(handle.id);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (handle.kind === 'timer')
|
|
395
|
+
clearTimeout(handle.id);
|
|
396
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDebouncedValue<T>(value: T, delay?: number): T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export function useDebouncedValue(value, delay = 200) {
|
|
4
|
+
const [debounced, setDebounced] = useState(value);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const id = window.setTimeout(() => setDebounced(value), delay);
|
|
7
|
+
return () => window.clearTimeout(id);
|
|
8
|
+
}, [delay, value]);
|
|
9
|
+
return debounced;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DetailNavIntent = 'next' | 'previous' | 'back';
|
|
2
|
+
export interface DetailNavOptions {
|
|
3
|
+
onNext?: () => void;
|
|
4
|
+
onPrevious?: () => void;
|
|
5
|
+
onBack?: () => void;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
isActive?: () => boolean;
|
|
8
|
+
backEscapesFrom?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function matchDetailNavIntent(event: KeyboardEvent): DetailNavIntent | null;
|
|
11
|
+
export declare function useDetailNav(options: DetailNavOptions): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
const TYPING_TARGET_SELECTOR = 'input, textarea, [contenteditable="true"], .ProseMirror, [role="dialog"], [role="listbox"], [data-slot="popover-content"]';
|
|
4
|
+
export function matchDetailNavIntent(event) {
|
|
5
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey)
|
|
6
|
+
return null;
|
|
7
|
+
switch (event.key) {
|
|
8
|
+
case 'j':
|
|
9
|
+
case 'ArrowDown':
|
|
10
|
+
return 'next';
|
|
11
|
+
case 'k':
|
|
12
|
+
case 'ArrowUp':
|
|
13
|
+
return 'previous';
|
|
14
|
+
case 'Escape':
|
|
15
|
+
return 'back';
|
|
16
|
+
default:
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function useDetailNav(options) {
|
|
21
|
+
const enabled = options.enabled !== false;
|
|
22
|
+
const latest = useRef(options);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
latest.current = options;
|
|
25
|
+
});
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!enabled || typeof document === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
const onKeyDown = (event) => {
|
|
30
|
+
const { onNext, onPrevious, onBack, isActive, backEscapesFrom } = latest.current;
|
|
31
|
+
if (isActive && !isActive())
|
|
32
|
+
return;
|
|
33
|
+
const intent = matchDetailNavIntent(event);
|
|
34
|
+
if (!intent)
|
|
35
|
+
return;
|
|
36
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
37
|
+
const escapesFromTyping = Boolean(intent === 'back' && backEscapesFrom && target?.closest(backEscapesFrom));
|
|
38
|
+
if (!escapesFromTyping && target?.closest(TYPING_TARGET_SELECTOR))
|
|
39
|
+
return;
|
|
40
|
+
const handler = intent === 'next' ? onNext : intent === 'previous' ? onPrevious : onBack;
|
|
41
|
+
if (!handler)
|
|
42
|
+
return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
handler();
|
|
45
|
+
};
|
|
46
|
+
document.addEventListener('keydown', onKeyDown);
|
|
47
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
48
|
+
}, [enabled]);
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFlushOnHide(flush: () => void): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
export function useFlushOnHide(flush) {
|
|
4
|
+
const flushRef = useRef(flush);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
flushRef.current = flush;
|
|
7
|
+
});
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const onPageHide = () => flushRef.current();
|
|
10
|
+
const onVisibility = () => {
|
|
11
|
+
if (document.visibilityState === 'hidden')
|
|
12
|
+
flushRef.current();
|
|
13
|
+
};
|
|
14
|
+
window.addEventListener('pagehide', onPageHide);
|
|
15
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
16
|
+
return () => {
|
|
17
|
+
window.removeEventListener('pagehide', onPageHide);
|
|
18
|
+
document.removeEventListener('visibilitychange', onVisibility);
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useSyncExternalStore } from 'react';
|
|
2
|
+
function matches(query) {
|
|
3
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
4
|
+
return false;
|
|
5
|
+
return window.matchMedia(query).matches;
|
|
6
|
+
}
|
|
7
|
+
export function useMediaQuery(query) {
|
|
8
|
+
const subscribe = useCallback((onChange) => {
|
|
9
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
10
|
+
return () => { };
|
|
11
|
+
const mql = window.matchMedia(query);
|
|
12
|
+
if (typeof mql.addEventListener === 'function') {
|
|
13
|
+
mql.addEventListener('change', onChange);
|
|
14
|
+
return () => mql.removeEventListener('change', onChange);
|
|
15
|
+
}
|
|
16
|
+
mql.addListener(onChange);
|
|
17
|
+
return () => mql.removeListener(onChange);
|
|
18
|
+
}, [query]);
|
|
19
|
+
return useSyncExternalStore(subscribe, () => matches(query), () => false);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVirtualizer, type ReactVirtualizerOptions, type VirtualItem, type Virtualizer, } from '@tanstack/react-virtual';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVirtualizer, } from '@tanstack/react-virtual';
|