@avis-studio/engine 0.0.0-stage → 0.1.0-beta.1
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 +193 -2
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/a11y/focus.d.ts +60 -0
- package/dist/a11y/focus.js +222 -0
- package/dist/a11y/index.d.ts +2 -0
- package/dist/a11y/index.js +4 -0
- package/dist/a11y/semantics.d.ts +37 -0
- package/dist/a11y/semantics.js +88 -0
- package/dist/commands/builtins.d.ts +88 -0
- package/dist/commands/builtins.js +362 -0
- package/dist/commands/command.d.ts +23 -0
- package/dist/commands/command.js +20 -0
- package/dist/commands/draft.d.ts +33 -0
- package/dist/commands/draft.js +96 -0
- package/dist/commands/history.d.ts +34 -0
- package/dist/commands/history.js +80 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/patch.d.ts +24 -0
- package/dist/commands/patch.js +44 -0
- package/dist/commands/transaction.d.ts +16 -0
- package/dist/commands/transaction.js +39 -0
- package/dist/core/diagnostics.d.ts +23 -0
- package/dist/core/diagnostics.js +23 -0
- package/dist/core/disposable.d.ts +14 -0
- package/dist/core/disposable.js +51 -0
- package/dist/core/engine.d.ts +108 -0
- package/dist/core/engine.js +323 -0
- package/dist/core/event-bus.d.ts +10 -0
- package/dist/core/event-bus.js +33 -0
- package/dist/core/ids.d.ts +13 -0
- package/dist/core/ids.js +6 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +7 -0
- package/dist/core/plugin.d.ts +20 -0
- package/dist/core/plugin.js +47 -0
- package/dist/core/services.d.ts +14 -0
- package/dist/core/services.js +20 -0
- package/dist/devtools/index.d.ts +1 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/panel.d.ts +39 -0
- package/dist/devtools/panel.js +100 -0
- package/dist/dom/a11y-layer.d.ts +32 -0
- package/dist/dom/a11y-layer.js +358 -0
- package/dist/dom/anchor.d.ts +34 -0
- package/dist/dom/anchor.js +35 -0
- package/dist/dom/index.d.ts +6 -0
- package/dist/dom/index.js +8 -0
- package/dist/dom/menu.d.ts +24 -0
- package/dist/dom/menu.js +122 -0
- package/dist/dom/overlays.d.ts +29 -0
- package/dist/dom/overlays.js +82 -0
- package/dist/dom/paint/collect.d.ts +8 -0
- package/dist/dom/paint/collect.js +589 -0
- package/dist/dom/paint/css.d.ts +86 -0
- package/dist/dom/paint/css.js +526 -0
- package/dist/dom/paint/draw.d.ts +16 -0
- package/dist/dom/paint/draw.js +413 -0
- package/dist/dom/paint/ghost.d.ts +2 -0
- package/dist/dom/paint/ghost.js +8 -0
- package/dist/dom/paint/index.d.ts +6 -0
- package/dist/dom/paint/index.js +9 -0
- package/dist/dom/paint/text.d.ts +26 -0
- package/dist/dom/paint/text.js +209 -0
- package/dist/dom/paint/types.d.ts +174 -0
- package/dist/dom/paint/types.js +7 -0
- package/dist/dom/paint/watch.d.ts +10 -0
- package/dist/dom/paint/watch.js +109 -0
- package/dist/dom/position.d.ts +37 -0
- package/dist/dom/position.js +125 -0
- package/dist/dom/text-editor.d.ts +27 -0
- package/dist/dom/text-editor.js +128 -0
- package/dist/events/event.d.ts +122 -0
- package/dist/events/event.js +130 -0
- package/dist/events/eventer.d.ts +24 -0
- package/dist/events/eventer.js +83 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +3 -0
- package/dist/events/interaction.d.ts +43 -0
- package/dist/events/interaction.js +203 -0
- package/dist/geometry/anchors.d.ts +14 -0
- package/dist/geometry/anchors.js +13 -0
- package/dist/geometry/bounds.d.ts +16 -0
- package/dist/geometry/bounds.js +42 -0
- package/dist/geometry/curves.d.ts +39 -0
- package/dist/geometry/curves.js +68 -0
- package/dist/geometry/index.d.ts +6 -0
- package/dist/geometry/index.js +6 -0
- package/dist/geometry/matrix.d.ts +22 -0
- package/dist/geometry/matrix.js +56 -0
- package/dist/geometry/spaces.d.ts +22 -0
- package/dist/geometry/spaces.js +28 -0
- package/dist/geometry/vec2.d.ts +12 -0
- package/dist/geometry/vec2.js +10 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +22 -0
- package/dist/interaction/behaviors.d.ts +10 -0
- package/dist/interaction/behaviors.js +744 -0
- package/dist/interaction/controller.d.ts +180 -0
- package/dist/interaction/controller.js +269 -0
- package/dist/interaction/hit-test.d.ts +45 -0
- package/dist/interaction/hit-test.js +119 -0
- package/dist/interaction/index.d.ts +4 -0
- package/dist/interaction/index.js +7 -0
- package/dist/interaction/web-input.d.ts +13 -0
- package/dist/interaction/web-input.js +172 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +2 -0
- package/dist/layout/layout.d.ts +27 -0
- package/dist/layout/layout.js +266 -0
- package/dist/react/canvas/graph.d.ts +83 -0
- package/dist/react/canvas/graph.js +89 -0
- package/dist/react/canvas/hooks.d.ts +42 -0
- package/dist/react/canvas/hooks.js +78 -0
- package/dist/react/canvas/index.d.ts +35 -0
- package/dist/react/canvas/index.js +8 -0
- package/dist/react/components.d.ts +55 -0
- package/dist/react/components.js +197 -0
- package/dist/react/context.d.ts +4 -0
- package/dist/react/context.js +9 -0
- package/dist/react/flow/api/LICENSE +21 -0
- package/dist/react/flow/api/externals.d.ts +12 -0
- package/dist/react/flow/api/react/additional-components/Background/Background.d.ts +7 -0
- package/dist/react/flow/api/react/additional-components/Background/Patterns.d.ts +17 -0
- package/dist/react/flow/api/react/additional-components/Background/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/Background/types.d.ts +25 -0
- package/dist/react/flow/api/react/additional-components/Controls/ControlButton.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/Controls/Controls.d.ts +7 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/FitView.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Lock.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Minus.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Plus.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Unlock.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/Controls/types.d.ts +20 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/EdgeToolbar.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/types.d.ts +6 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMap.d.ts +8 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNode.d.ts +4 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNodes.d.ts +5 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/types.d.ts +44 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizer.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/types.d.ts +32 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbar.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbarPortal.d.ts +4 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/types.d.ts +9 -0
- package/dist/react/flow/api/react/additional-components/index.d.ts +6 -0
- package/dist/react/flow/api/react/components/A11yDescriptions/index.d.ts +7 -0
- package/dist/react/flow/api/react/components/Attribution/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/BatchProvider/index.d.ts +10 -0
- package/dist/react/flow/api/react/components/BatchProvider/types.d.ts +6 -0
- package/dist/react/flow/api/react/components/BatchProvider/useQueue.d.ts +2 -0
- package/dist/react/flow/api/react/components/ConnectionLine/index.d.ts +11 -0
- package/dist/react/flow/api/react/components/EdgeLabelRenderer/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +14 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/utils.d.ts +11 -0
- package/dist/react/flow/api/react/components/Edges/BaseEdge.d.ts +2 -0
- package/dist/react/flow/api/react/components/Edges/BezierEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/EdgeAnchor.d.ts +13 -0
- package/dist/react/flow/api/react/components/Edges/EdgeText.d.ts +7 -0
- package/dist/react/flow/api/react/components/Edges/SimpleBezierEdge.d.ts +20 -0
- package/dist/react/flow/api/react/components/Edges/SmoothStepEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/StepEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/StraightEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/Handle/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/NodeWrapper/index.d.ts +4 -0
- package/dist/react/flow/api/react/components/NodeWrapper/useNodeObserver.d.ts +7 -0
- package/dist/react/flow/api/react/components/NodeWrapper/utils.d.ts +8 -0
- package/dist/react/flow/api/react/components/Nodes/DefaultNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/GroupNode.d.ts +1 -0
- package/dist/react/flow/api/react/components/Nodes/InputNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/OutputNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/utils.d.ts +12 -0
- package/dist/react/flow/api/react/components/NodesSelection/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/Panel/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/ReactFlowProvider/index.d.ts +20 -0
- package/dist/react/flow/api/react/components/SelectionListener/index.d.ts +6 -0
- package/dist/react/flow/api/react/components/StoreUpdater/index.d.ts +67 -0
- package/dist/react/flow/api/react/components/UserSelection/index.d.ts +1 -0
- package/dist/react/flow/api/react/components/ViewportPortal/index.d.ts +4 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/MarkerDefinitions.d.ts +9 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/MarkerSymbols.d.ts +8 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/index.d.ts +12 -0
- package/dist/react/flow/api/react/container/FlowRenderer/index.d.ts +13 -0
- package/dist/react/flow/api/react/container/GraphView/index.d.ts +10 -0
- package/dist/react/flow/api/react/container/GraphView/useNodeOrEdgeTypesWarning.d.ts +3 -0
- package/dist/react/flow/api/react/container/GraphView/useStylesLoadedWarning.d.ts +1 -0
- package/dist/react/flow/api/react/container/NodeRenderer/index.d.ts +9 -0
- package/dist/react/flow/api/react/container/NodeRenderer/useResizeObserver.d.ts +1 -0
- package/dist/react/flow/api/react/container/Pane/index.d.ts +10 -0
- package/dist/react/flow/api/react/container/ReactFlow/Wrapper.d.ts +19 -0
- package/dist/react/flow/api/react/container/ReactFlow/index.d.ts +3 -0
- package/dist/react/flow/api/react/container/ReactFlow/init-values.d.ts +3 -0
- package/dist/react/flow/api/react/container/Viewport/index.d.ts +6 -0
- package/dist/react/flow/api/react/container/ZoomPane/index.d.ts +7 -0
- package/dist/react/flow/api/react/contexts/HandleConfigContext.d.ts +11 -0
- package/dist/react/flow/api/react/contexts/NodeIdContext.d.ts +5 -0
- package/dist/react/flow/api/react/contexts/StoreContext.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useColorModeClass.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useConnection.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useDrag.d.ts +12 -0
- package/dist/react/flow/api/react/hooks/useEdges.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useGlobalKeyHandler.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useHandleConnections.d.ts +10 -0
- package/dist/react/flow/api/react/hooks/useInternalNode.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useKeyPress.d.ts +7 -0
- package/dist/react/flow/api/react/hooks/useMoveSelectedNodes.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useNodeConnections.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useNodes.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useNodesData.d.ts +4 -0
- package/dist/react/flow/api/react/hooks/useNodesEdgesState.d.ts +12 -0
- package/dist/react/flow/api/react/hooks/useNodesInitialized.d.ts +4 -0
- package/dist/react/flow/api/react/hooks/useOnEdgesChangeMiddleware.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useOnInitHandler.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useOnNodesChangeMiddleware.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useOnSelectionChange.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useOnViewportChange.d.ts +7 -0
- package/dist/react/flow/api/react/hooks/useReactFlow.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useResizeHandler.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useStore.d.ts +8 -0
- package/dist/react/flow/api/react/hooks/useUpdateNodeInternals.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useViewport.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useViewportHelper.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useViewportSync.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useVisibleEdgeIds.d.ts +1 -0
- package/dist/react/flow/api/react/hooks/useVisibleNodeIds.d.ts +1 -0
- package/dist/react/flow/api/react/index.d.ts +41 -0
- package/dist/react/flow/api/react/store/index.d.ts +18 -0
- package/dist/react/flow/api/react/store/initialState.d.ts +18 -0
- package/dist/react/flow/api/react/styles/utils.d.ts +2 -0
- package/dist/react/flow/api/react/types/component-props.d.ts +127 -0
- package/dist/react/flow/api/react/types/edges.d.ts +111 -0
- package/dist/react/flow/api/react/types/general.d.ts +53 -0
- package/dist/react/flow/api/react/types/index.d.ts +6 -0
- package/dist/react/flow/api/react/types/instance.d.ts +64 -0
- package/dist/react/flow/api/react/types/nodes.d.ts +41 -0
- package/dist/react/flow/api/react/types/store.d.ts +114 -0
- package/dist/react/flow/api/react/utils/changes.d.ts +15 -0
- package/dist/react/flow/api/react/utils/edges.d.ts +3 -0
- package/dist/react/flow/api/react/utils/general.d.ts +5 -0
- package/dist/react/flow/api/react/utils/index.d.ts +3 -0
- package/dist/react/flow/api/system/constants.d.ts +43 -0
- package/dist/react/flow/api/system/index.d.ts +8 -0
- package/dist/react/flow/api/system/types/changes.d.ts +48 -0
- package/dist/react/flow/api/system/types/edges.d.ts +72 -0
- package/dist/react/flow/api/system/types/general.d.ts +175 -0
- package/dist/react/flow/api/system/types/handles.d.ts +21 -0
- package/dist/react/flow/api/system/types/index.d.ts +7 -0
- package/dist/react/flow/api/system/types/nodes.d.ts +89 -0
- package/dist/react/flow/api/system/types/panzoom.d.ts +58 -0
- package/dist/react/flow/api/system/types/utils.d.ts +46 -0
- package/dist/react/flow/api/system/utils/attribution.d.ts +1 -0
- package/dist/react/flow/api/system/utils/connections.d.ts +4 -0
- package/dist/react/flow/api/system/utils/dom.d.ts +20 -0
- package/dist/react/flow/api/system/utils/edge-toolbar.d.ts +1 -0
- package/dist/react/flow/api/system/utils/edges/bezier-edge.d.ts +40 -0
- package/dist/react/flow/api/system/utils/edges/general.d.ts +44 -0
- package/dist/react/flow/api/system/utils/edges/index.d.ts +5 -0
- package/dist/react/flow/api/system/utils/edges/positions.d.ts +16 -0
- package/dist/react/flow/api/system/utils/edges/smoothstep-edge.d.ts +21 -0
- package/dist/react/flow/api/system/utils/edges/straight-edge.d.ts +13 -0
- package/dist/react/flow/api/system/utils/general.d.ts +56 -0
- package/dist/react/flow/api/system/utils/graph.d.ts +45 -0
- package/dist/react/flow/api/system/utils/index.d.ts +12 -0
- package/dist/react/flow/api/system/utils/marker.d.ts +8 -0
- package/dist/react/flow/api/system/utils/node-toolbar.d.ts +2 -0
- package/dist/react/flow/api/system/utils/shallow-node-data.d.ts +4 -0
- package/dist/react/flow/api/system/utils/store.d.ts +33 -0
- package/dist/react/flow/api/system/utils/types.d.ts +7 -0
- package/dist/react/flow/api/system/xydrag/XYDrag.d.ts +56 -0
- package/dist/react/flow/api/system/xydrag/index.d.ts +1 -0
- package/dist/react/flow/api/system/xydrag/utils.d.ts +22 -0
- package/dist/react/flow/api/system/xyhandle/XYHandle.d.ts +2 -0
- package/dist/react/flow/api/system/xyhandle/index.d.ts +1 -0
- package/dist/react/flow/api/system/xyhandle/types.d.ts +49 -0
- package/dist/react/flow/api/system/xyhandle/utils.d.ts +9 -0
- package/dist/react/flow/api/system/xyminimap/index.d.ts +27 -0
- package/dist/react/flow/api/system/xypanzoom/XYPanZoom.d.ts +11 -0
- package/dist/react/flow/api/system/xypanzoom/eventhandler.d.ts +45 -0
- package/dist/react/flow/api/system/xypanzoom/filter.d.ts +15 -0
- package/dist/react/flow/api/system/xypanzoom/index.d.ts +1 -0
- package/dist/react/flow/api/system/xypanzoom/utils.d.ts +8 -0
- package/dist/react/flow/api/system/xyresizer/XYResizer.d.ts +51 -0
- package/dist/react/flow/api/system/xyresizer/index.d.ts +2 -0
- package/dist/react/flow/api/system/xyresizer/types.d.ts +26 -0
- package/dist/react/flow/api/system/xyresizer/utils.d.ts +41 -0
- package/dist/react/flow/components.d.ts +148 -0
- package/dist/react/flow/components.js +526 -0
- package/dist/react/flow/configuration.d.ts +6 -0
- package/dist/react/flow/configuration.js +27 -0
- package/dist/react/flow/drag.d.ts +14 -0
- package/dist/react/flow/drag.js +273 -0
- package/dist/react/flow/extras.d.ts +155 -0
- package/dist/react/flow/extras.js +317 -0
- package/dist/react/flow/handle.d.ts +21 -0
- package/dist/react/flow/handle.js +149 -0
- package/dist/react/flow/hooks.d.ts +47 -0
- package/dist/react/flow/hooks.js +131 -0
- package/dist/react/flow/index.d.ts +78 -0
- package/dist/react/flow/index.js +73 -0
- package/dist/react/flow/queries.d.ts +20 -0
- package/dist/react/flow/queries.js +30 -0
- package/dist/react/flow/react-flow.d.ts +73 -0
- package/dist/react/flow/react-flow.js +1445 -0
- package/dist/react/flow/resize.d.ts +30 -0
- package/dist/react/flow/resize.js +49 -0
- package/dist/react/flow/store.d.ts +412 -0
- package/dist/react/flow/store.js +713 -0
- package/dist/react/flow/style.css +630 -0
- package/dist/react/flow/style.css.d.ts +2 -0
- package/dist/react/flow/system.d.ts +146 -0
- package/dist/react/flow/system.js +300 -0
- package/dist/react/flow/types.d.ts +131 -0
- package/dist/react/flow/types.js +1 -0
- package/dist/react/flow/utils.d.ts +77 -0
- package/dist/react/flow/utils.js +285 -0
- package/dist/react/hooks.d.ts +14 -0
- package/dist/react/hooks.js +44 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +5 -0
- package/dist/render/backend.d.ts +26 -0
- package/dist/render/backend.js +5 -0
- package/dist/render/canvas2d/backend.d.ts +7 -0
- package/dist/render/canvas2d/backend.js +122 -0
- package/dist/render/canvas2d/index.d.ts +1 -0
- package/dist/render/canvas2d/index.js +2 -0
- package/dist/render/color.d.ts +9 -0
- package/dist/render/color.js +69 -0
- package/dist/render/commands.d.ts +69 -0
- package/dist/render/commands.js +1 -0
- package/dist/render/display-list.d.ts +65 -0
- package/dist/render/display-list.js +316 -0
- package/dist/render/images.d.ts +35 -0
- package/dist/render/images.js +83 -0
- package/dist/render/index.d.ts +14 -0
- package/dist/render/index.js +16 -0
- package/dist/render/painters.d.ts +35 -0
- package/dist/render/painters.js +109 -0
- package/dist/render/renderer.d.ts +70 -0
- package/dist/render/renderer.js +162 -0
- package/dist/render/scene-index.d.ts +21 -0
- package/dist/render/scene-index.js +64 -0
- package/dist/render/text.d.ts +8 -0
- package/dist/render/text.js +100 -0
- package/dist/render/theme.d.ts +21 -0
- package/dist/render/theme.js +33 -0
- package/dist/render/ui.d.ts +63 -0
- package/dist/render/ui.js +188 -0
- package/dist/render/webgl2/atlas.d.ts +36 -0
- package/dist/render/webgl2/atlas.js +93 -0
- package/dist/render/webgl2/backend.d.ts +19 -0
- package/dist/render/webgl2/backend.js +338 -0
- package/dist/render/webgl2/index.d.ts +2 -0
- package/dist/render/webgl2/index.js +3 -0
- package/dist/render/webgl2/shaders.d.ts +6 -0
- package/dist/render/webgl2/shaders.js +112 -0
- package/dist/render/webgpu/index.d.ts +1 -0
- package/dist/render/webgpu/index.js +3 -0
- package/dist/scene/builtins.d.ts +25 -0
- package/dist/scene/builtins.js +60 -0
- package/dist/scene/dirty.d.ts +11 -0
- package/dist/scene/dirty.js +10 -0
- package/dist/scene/index.d.ts +5 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/record.d.ts +40 -0
- package/dist/scene/record.js +12 -0
- package/dist/scene/scene-graph.d.ts +58 -0
- package/dist/scene/scene-graph.js +178 -0
- package/dist/scene/schema.d.ts +27 -0
- package/dist/scene/schema.js +32 -0
- package/dist/sdk/create-avis.d.ts +109 -0
- package/dist/sdk/create-avis.js +162 -0
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.js +2 -0
- package/dist/serialization/format.d.ts +46 -0
- package/dist/serialization/format.js +20 -0
- package/dist/serialization/index.d.ts +3 -0
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/migrate.d.ts +7 -0
- package/dist/serialization/migrate.js +54 -0
- package/dist/serialization/serialize.d.ts +10 -0
- package/dist/serialization/serialize.js +114 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/index.js +2 -0
- package/dist/state/selector.d.ts +6 -0
- package/dist/state/selector.js +29 -0
- package/dist/state/store.d.ts +91 -0
- package/dist/state/store.js +102 -0
- package/dist/style/computed.d.ts +84 -0
- package/dist/style/computed.js +296 -0
- package/dist/style/index.d.ts +6 -0
- package/dist/style/index.js +8 -0
- package/dist/style/style-engine.d.ts +33 -0
- package/dist/style/style-engine.js +113 -0
- package/dist/style/tokens.d.ts +49 -0
- package/dist/style/tokens.js +142 -0
- package/dist/style/utilities.d.ts +34 -0
- package/dist/style/utilities.js +341 -0
- package/dist/style/values.d.ts +30 -0
- package/dist/style/values.js +361 -0
- package/dist/style/variants.d.ts +38 -0
- package/dist/style/variants.js +55 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +1 -0
- package/dist/sync/save-queue.d.ts +24 -0
- package/dist/sync/save-queue.js +88 -0
- package/dist/wasm/index.d.ts +2 -0
- package/dist/wasm/index.js +2 -0
- package/dist/wasm/load.d.ts +7 -0
- package/dist/wasm/load.js +47 -0
- package/dist/wasm/pkg/avis_engine_wasm.d.ts +84 -0
- package/dist/wasm/pkg/avis_engine_wasm.js +339 -0
- package/dist/wasm/pkg/avis_engine_wasm_bg.wasm +0 -0
- package/dist/wasm/reference.d.ts +38 -0
- package/dist/wasm/reference.js +174 -0
- package/package.json +76 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NodeId, RelationId } from "../core/ids.js";
|
|
2
|
+
import { type Mat2D } from "../geometry/matrix.js";
|
|
3
|
+
import type { Vec2 } from "../geometry/vec2.js";
|
|
4
|
+
import { type DocumentState, type Size, type Transform } from "../scene/record.js";
|
|
5
|
+
import type { DocumentView } from "./draft.js";
|
|
6
|
+
/** A node's world matrix, from its ancestors in the document. */
|
|
7
|
+
export declare function worldMatrixOf(document: DocumentView, id: string): Mat2D;
|
|
8
|
+
export type CreateNodeParams = {
|
|
9
|
+
id?: NodeId;
|
|
10
|
+
type: string;
|
|
11
|
+
parentId?: NodeId | null;
|
|
12
|
+
index?: number;
|
|
13
|
+
transform?: Partial<Transform>;
|
|
14
|
+
size?: Partial<Size>;
|
|
15
|
+
props?: Record<string, unknown>;
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
locked?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const createNode: import("./command.js").Command<CreateNodeParams, NodeId>;
|
|
20
|
+
export type UpdateNodeParams = {
|
|
21
|
+
id: NodeId;
|
|
22
|
+
props?: Record<string, unknown>;
|
|
23
|
+
visible?: boolean;
|
|
24
|
+
locked?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const updateNode: import("./command.js").Command<UpdateNodeParams, void>;
|
|
27
|
+
export type MoveNodeParams = {
|
|
28
|
+
/** One node, or several moved by the same delta. */
|
|
29
|
+
id?: NodeId;
|
|
30
|
+
ids?: NodeId[];
|
|
31
|
+
/** By this much, in each node's parent space… */
|
|
32
|
+
delta?: Vec2;
|
|
33
|
+
/** …or to this position (one node). */
|
|
34
|
+
position?: Vec2;
|
|
35
|
+
};
|
|
36
|
+
export declare const moveNode: import("./command.js").Command<MoveNodeParams, void>;
|
|
37
|
+
export declare const resizeNode: import("./command.js").Command<{
|
|
38
|
+
id: NodeId;
|
|
39
|
+
size: Size;
|
|
40
|
+
}, void>;
|
|
41
|
+
export type TransformNodeParams = {
|
|
42
|
+
id: NodeId;
|
|
43
|
+
transform?: Partial<Transform>;
|
|
44
|
+
size?: Size;
|
|
45
|
+
};
|
|
46
|
+
/** Sets a node's transform and size at once (a resize or a rotation). */
|
|
47
|
+
export declare const transformNode: import("./command.js").Command<TransformNodeParams, void>;
|
|
48
|
+
export type ReparentParams = {
|
|
49
|
+
id: NodeId;
|
|
50
|
+
parentId: NodeId | null;
|
|
51
|
+
index?: number;
|
|
52
|
+
};
|
|
53
|
+
/** Moves a node to another parent, keeping where it is in the world. */
|
|
54
|
+
export declare const reparentNode: import("./command.js").Command<ReparentParams, void>;
|
|
55
|
+
/** Deletes nodes with their subtrees and every relation touching them. */
|
|
56
|
+
export declare const deleteNodes: import("./command.js").Command<{
|
|
57
|
+
ids: NodeId[];
|
|
58
|
+
}, void>;
|
|
59
|
+
export type ConnectParams = {
|
|
60
|
+
id?: RelationId;
|
|
61
|
+
source: {
|
|
62
|
+
nodeId: NodeId;
|
|
63
|
+
anchor?: string | null;
|
|
64
|
+
};
|
|
65
|
+
target: {
|
|
66
|
+
nodeId: NodeId;
|
|
67
|
+
anchor?: string | null;
|
|
68
|
+
};
|
|
69
|
+
props?: Record<string, unknown>;
|
|
70
|
+
};
|
|
71
|
+
export declare const connect: import("./command.js").Command<ConnectParams, RelationId>;
|
|
72
|
+
export declare const disconnect: import("./command.js").Command<{
|
|
73
|
+
id: RelationId;
|
|
74
|
+
}, void>;
|
|
75
|
+
/** Replaces the whole document (loading); history is cleared by the engine. */
|
|
76
|
+
export declare const loadDocument: import("./command.js").Command<{
|
|
77
|
+
document: DocumentState;
|
|
78
|
+
}, void>;
|
|
79
|
+
export declare const BUILTIN_COMMANDS: (import("./command.js").Command<CreateNodeParams, NodeId> | import("./command.js").Command<UpdateNodeParams, void> | import("./command.js").Command<MoveNodeParams, void> | import("./command.js").Command<{
|
|
80
|
+
id: NodeId;
|
|
81
|
+
size: Size;
|
|
82
|
+
}, void> | import("./command.js").Command<TransformNodeParams, void> | import("./command.js").Command<ReparentParams, void> | import("./command.js").Command<{
|
|
83
|
+
ids: NodeId[];
|
|
84
|
+
}, void> | import("./command.js").Command<ConnectParams, RelationId> | import("./command.js").Command<{
|
|
85
|
+
id: RelationId;
|
|
86
|
+
}, void> | import("./command.js").Command<{
|
|
87
|
+
document: DocumentState;
|
|
88
|
+
}, void>)[];
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The built-in document commands. Each validates against the document as it
|
|
3
|
+
* stands in the transaction; graph connections are relations (node id +
|
|
4
|
+
* anchor), never parent and child.
|
|
5
|
+
*/
|
|
6
|
+
import { error } from "../core/diagnostics.js";
|
|
7
|
+
import { decompose, fromTRS, identity, invert, multiply, } from "../geometry/matrix.js";
|
|
8
|
+
import { IDENTITY_TRANSFORM, } from "../scene/record.js";
|
|
9
|
+
import { defineCommand } from "./command.js";
|
|
10
|
+
// ---- helpers ------------------------------------------------------------
|
|
11
|
+
const missing = (id) => error("node.missing", `No node "${id}"`, { data: { id } });
|
|
12
|
+
/** A node's world matrix, from its ancestors in the document. */
|
|
13
|
+
export function worldMatrixOf(document, id) {
|
|
14
|
+
const record = document.node(id);
|
|
15
|
+
if (!record)
|
|
16
|
+
return identity();
|
|
17
|
+
const local = fromTRS(record.transform);
|
|
18
|
+
if (!record.parentId)
|
|
19
|
+
return local;
|
|
20
|
+
return multiply(new Float64Array(6), worldMatrixOf(document, record.parentId), local);
|
|
21
|
+
}
|
|
22
|
+
function isDescendant(document, id, ancestorId) {
|
|
23
|
+
let current = document.node(id)?.parentId ?? null;
|
|
24
|
+
while (current) {
|
|
25
|
+
if (current === ancestorId)
|
|
26
|
+
return true;
|
|
27
|
+
current = document.node(current)?.parentId ?? null;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function insertAt(list, item, index) {
|
|
32
|
+
const next = [...list];
|
|
33
|
+
next.splice(index === undefined
|
|
34
|
+
? next.length
|
|
35
|
+
: Math.max(0, Math.min(index, next.length)), 0, item);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
function detach(draft, record) {
|
|
39
|
+
if (record.parentId) {
|
|
40
|
+
const parent = draft.node(record.parentId);
|
|
41
|
+
if (parent) {
|
|
42
|
+
draft.putNode({
|
|
43
|
+
...parent,
|
|
44
|
+
childIds: parent.childIds.filter((id) => id !== record.id),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
draft.setRootIds(draft.rootIds.filter((id) => id !== record.id));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function attach(draft, id, parentId, index) {
|
|
53
|
+
if (parentId) {
|
|
54
|
+
const parent = draft.node(parentId);
|
|
55
|
+
draft.putNode({ ...parent, childIds: insertAt(parent.childIds, id, index) });
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
draft.setRootIds(insertAt(draft.rootIds, id, index));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function checkParent(document, context, parentId) {
|
|
62
|
+
if (!parentId)
|
|
63
|
+
return [];
|
|
64
|
+
const parent = document.node(parentId);
|
|
65
|
+
if (!parent)
|
|
66
|
+
return [missing(parentId)];
|
|
67
|
+
if (!context.schemas.get(parent.type)?.canHaveChildren) {
|
|
68
|
+
return [
|
|
69
|
+
error("node.no-children", `A "${parent.type}" node can't have children`),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
export const createNode = defineCommand({
|
|
75
|
+
id: "node.create",
|
|
76
|
+
validate(params, document, context) {
|
|
77
|
+
const schema = context.schemas.get(params.type);
|
|
78
|
+
if (!schema)
|
|
79
|
+
return [error("node.unknown-type", `Unknown node type "${params.type}"`)];
|
|
80
|
+
if (params.id && document.node(params.id)) {
|
|
81
|
+
return [error("node.duplicate-id", `A node "${params.id}" exists`)];
|
|
82
|
+
}
|
|
83
|
+
return [
|
|
84
|
+
...checkParent(document, context, params.parentId),
|
|
85
|
+
...(schema.validate?.({ ...schema.defaults(), ...params.props }) ?? []),
|
|
86
|
+
];
|
|
87
|
+
},
|
|
88
|
+
run(params, draft, context) {
|
|
89
|
+
const schema = context.schemas.get(params.type);
|
|
90
|
+
const id = (params.id ?? context.ids("node"));
|
|
91
|
+
draft.putNode({
|
|
92
|
+
id,
|
|
93
|
+
type: params.type,
|
|
94
|
+
typeVersion: schema.version,
|
|
95
|
+
parentId: params.parentId ?? null,
|
|
96
|
+
childIds: [],
|
|
97
|
+
transform: { ...IDENTITY_TRANSFORM, ...params.transform },
|
|
98
|
+
size: { w: 0, h: 0, ...params.size },
|
|
99
|
+
props: { ...schema.defaults(), ...params.props },
|
|
100
|
+
visible: params.visible ?? true,
|
|
101
|
+
locked: params.locked ?? false,
|
|
102
|
+
});
|
|
103
|
+
attach(draft, id, params.parentId ?? null, params.index);
|
|
104
|
+
return id;
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
export const updateNode = defineCommand({
|
|
108
|
+
id: "node.update",
|
|
109
|
+
validate(params, document, context) {
|
|
110
|
+
const record = document.node(params.id);
|
|
111
|
+
if (!record)
|
|
112
|
+
return [missing(params.id)];
|
|
113
|
+
return params.props
|
|
114
|
+
? context.schemas.validate(record.type, {
|
|
115
|
+
...record.props,
|
|
116
|
+
...params.props,
|
|
117
|
+
})
|
|
118
|
+
: [];
|
|
119
|
+
},
|
|
120
|
+
run(params, draft) {
|
|
121
|
+
const record = draft.node(params.id);
|
|
122
|
+
draft.putNode({
|
|
123
|
+
...record,
|
|
124
|
+
props: params.props ? { ...record.props, ...params.props } : record.props,
|
|
125
|
+
visible: params.visible ?? record.visible,
|
|
126
|
+
locked: params.locked ?? record.locked,
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
export const moveNode = defineCommand({
|
|
131
|
+
id: "node.move",
|
|
132
|
+
validate(params, document) {
|
|
133
|
+
const ids = params.ids ?? (params.id ? [params.id] : []);
|
|
134
|
+
if (!ids.length)
|
|
135
|
+
return [error("node.move.none", "No node to move")];
|
|
136
|
+
if (!params.delta === !params.position) {
|
|
137
|
+
return [error("node.move.how", "Give either a delta or a position")];
|
|
138
|
+
}
|
|
139
|
+
if (params.position && ids.length > 1) {
|
|
140
|
+
return [error("node.move.position", "A position moves one node")];
|
|
141
|
+
}
|
|
142
|
+
return ids.flatMap((id) => {
|
|
143
|
+
const record = document.node(id);
|
|
144
|
+
if (!record)
|
|
145
|
+
return [missing(id)];
|
|
146
|
+
return record.locked
|
|
147
|
+
? [error("node.locked", `Node "${id}" is locked`)]
|
|
148
|
+
: [];
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
run(params, draft) {
|
|
152
|
+
for (const id of params.ids ?? [params.id]) {
|
|
153
|
+
const record = draft.node(id);
|
|
154
|
+
const x = params.position
|
|
155
|
+
? params.position.x
|
|
156
|
+
: record.transform.x + params.delta.x;
|
|
157
|
+
const y = params.position
|
|
158
|
+
? params.position.y
|
|
159
|
+
: record.transform.y + params.delta.y;
|
|
160
|
+
if (x === record.transform.x && y === record.transform.y)
|
|
161
|
+
continue;
|
|
162
|
+
draft.putNode({ ...record, transform: { ...record.transform, x, y } });
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
export const resizeNode = defineCommand({
|
|
167
|
+
id: "node.resize",
|
|
168
|
+
validate(params, document) {
|
|
169
|
+
const record = document.node(params.id);
|
|
170
|
+
if (!record)
|
|
171
|
+
return [missing(params.id)];
|
|
172
|
+
if (!(params.size.w >= 0 && params.size.h >= 0)) {
|
|
173
|
+
return [error("node.size", "A size is two numbers ≥ 0")];
|
|
174
|
+
}
|
|
175
|
+
return record.locked
|
|
176
|
+
? [error("node.locked", `Node "${params.id}" is locked`)]
|
|
177
|
+
: [];
|
|
178
|
+
},
|
|
179
|
+
run(params, draft) {
|
|
180
|
+
const record = draft.node(params.id);
|
|
181
|
+
draft.putNode({ ...record, size: { ...params.size } });
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
/** Sets a node's transform and size at once (a resize or a rotation). */
|
|
185
|
+
export const transformNode = defineCommand({
|
|
186
|
+
id: "node.transform",
|
|
187
|
+
validate(params, document) {
|
|
188
|
+
const record = document.node(params.id);
|
|
189
|
+
if (!record)
|
|
190
|
+
return [missing(params.id)];
|
|
191
|
+
if (record.locked)
|
|
192
|
+
return [error("node.locked", `Node "${params.id}" is locked`)];
|
|
193
|
+
if (params.size && !(params.size.w >= 0 && params.size.h >= 0)) {
|
|
194
|
+
return [error("node.size", "A size is two numbers ≥ 0")];
|
|
195
|
+
}
|
|
196
|
+
return [];
|
|
197
|
+
},
|
|
198
|
+
run(params, draft) {
|
|
199
|
+
const record = draft.node(params.id);
|
|
200
|
+
draft.putNode({
|
|
201
|
+
...record,
|
|
202
|
+
transform: { ...record.transform, ...params.transform },
|
|
203
|
+
size: params.size ? { ...params.size } : record.size,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
/** Moves a node to another parent, keeping where it is in the world. */
|
|
208
|
+
export const reparentNode = defineCommand({
|
|
209
|
+
id: "node.reparent",
|
|
210
|
+
validate(params, document, context) {
|
|
211
|
+
if (!document.node(params.id))
|
|
212
|
+
return [missing(params.id)];
|
|
213
|
+
if (params.parentId === params.id ||
|
|
214
|
+
(params.parentId && isDescendant(document, params.parentId, params.id))) {
|
|
215
|
+
return [error("node.reparent.cycle", "A node can't go inside itself")];
|
|
216
|
+
}
|
|
217
|
+
return checkParent(document, context, params.parentId);
|
|
218
|
+
},
|
|
219
|
+
run(params, draft) {
|
|
220
|
+
const record = draft.node(params.id);
|
|
221
|
+
const world = worldMatrixOf(draft, params.id);
|
|
222
|
+
const parentWorld = params.parentId
|
|
223
|
+
? worldMatrixOf(draft, params.parentId)
|
|
224
|
+
: identity();
|
|
225
|
+
const inverse = invert(parentWorld) ?? identity();
|
|
226
|
+
const transform = decompose(multiply(new Float64Array(6), inverse, world));
|
|
227
|
+
detach(draft, record);
|
|
228
|
+
draft.putNode({
|
|
229
|
+
...draft.node(params.id),
|
|
230
|
+
parentId: params.parentId,
|
|
231
|
+
transform,
|
|
232
|
+
});
|
|
233
|
+
attach(draft, params.id, params.parentId, params.index);
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
/** Deletes nodes with their subtrees and every relation touching them. */
|
|
237
|
+
export const deleteNodes = defineCommand({
|
|
238
|
+
id: "node.delete",
|
|
239
|
+
validate(params, document) {
|
|
240
|
+
return params.ids.flatMap((id) => (document.node(id) ? [] : [missing(id)]));
|
|
241
|
+
},
|
|
242
|
+
run(params, draft) {
|
|
243
|
+
const doomed = new Set();
|
|
244
|
+
const collect = (id) => {
|
|
245
|
+
if (doomed.has(id))
|
|
246
|
+
return;
|
|
247
|
+
doomed.add(id);
|
|
248
|
+
for (const child of draft.node(id)?.childIds ?? [])
|
|
249
|
+
collect(child);
|
|
250
|
+
};
|
|
251
|
+
params.ids.forEach(collect);
|
|
252
|
+
for (const relationId of draft.relationIds()) {
|
|
253
|
+
const relation = draft.relation(relationId);
|
|
254
|
+
if (doomed.has(relation.source.nodeId) ||
|
|
255
|
+
doomed.has(relation.target.nodeId)) {
|
|
256
|
+
draft.deleteRelation(relationId);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Detach the top of each deleted subtree from what survives.
|
|
260
|
+
for (const id of params.ids) {
|
|
261
|
+
const record = draft.node(id);
|
|
262
|
+
if (record && !(record.parentId && doomed.has(record.parentId)))
|
|
263
|
+
detach(draft, record);
|
|
264
|
+
}
|
|
265
|
+
for (const id of doomed)
|
|
266
|
+
draft.deleteNode(id);
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
function checkEnd(document, context, end, type) {
|
|
270
|
+
const record = document.node(end.nodeId);
|
|
271
|
+
if (!record)
|
|
272
|
+
return [missing(end.nodeId)];
|
|
273
|
+
if (end.anchor == null)
|
|
274
|
+
return [];
|
|
275
|
+
const anchors = context.schemas
|
|
276
|
+
.anchors(record)
|
|
277
|
+
.filter((anchor) => anchor.type === type);
|
|
278
|
+
return anchors.some((anchor) => anchor.id === end.anchor)
|
|
279
|
+
? []
|
|
280
|
+
: [
|
|
281
|
+
error("relation.anchor", `Node "${end.nodeId}" has no ${type} anchor "${end.anchor}"`),
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
export const connect = defineCommand({
|
|
285
|
+
id: "relation.connect",
|
|
286
|
+
validate(params, document, context) {
|
|
287
|
+
if (params.id && document.relation(params.id)) {
|
|
288
|
+
return [
|
|
289
|
+
error("relation.duplicate-id", `A relation "${params.id}" exists`),
|
|
290
|
+
];
|
|
291
|
+
}
|
|
292
|
+
const diagnostics = [
|
|
293
|
+
...checkEnd(document, context, params.source, "source"),
|
|
294
|
+
...checkEnd(document, context, params.target, "target"),
|
|
295
|
+
];
|
|
296
|
+
if (!diagnostics.length && params.source.nodeId === params.target.nodeId) {
|
|
297
|
+
const record = document.node(params.source.nodeId);
|
|
298
|
+
if (!context.schemas.get(record.type)?.allowSelfConnection) {
|
|
299
|
+
diagnostics.push(error("relation.self", "A node can't connect to itself"));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return diagnostics;
|
|
303
|
+
},
|
|
304
|
+
run(params, draft, context) {
|
|
305
|
+
const id = (params.id ?? context.ids("relation"));
|
|
306
|
+
const end = (value) => ({
|
|
307
|
+
nodeId: value.nodeId,
|
|
308
|
+
anchor: value.anchor ?? null,
|
|
309
|
+
});
|
|
310
|
+
const relation = {
|
|
311
|
+
id,
|
|
312
|
+
kind: "connection",
|
|
313
|
+
source: end(params.source),
|
|
314
|
+
target: end(params.target),
|
|
315
|
+
props: { ...params.props },
|
|
316
|
+
};
|
|
317
|
+
draft.putRelation(relation);
|
|
318
|
+
return id;
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
export const disconnect = defineCommand({
|
|
322
|
+
id: "relation.disconnect",
|
|
323
|
+
validate: (params, document) => document.relation(params.id)
|
|
324
|
+
? []
|
|
325
|
+
: [error("relation.missing", `No relation "${params.id}"`)],
|
|
326
|
+
run(params, draft) {
|
|
327
|
+
draft.deleteRelation(params.id);
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
// ---- document -----------------------------------------------------------
|
|
331
|
+
/** Replaces the whole document (loading); history is cleared by the engine. */
|
|
332
|
+
export const loadDocument = defineCommand({
|
|
333
|
+
id: "document.load",
|
|
334
|
+
validate(params, _document, context) {
|
|
335
|
+
return Object.values(params.document.nodes).flatMap((record) => context.schemas.has(record.type)
|
|
336
|
+
? []
|
|
337
|
+
: [error("node.unknown-type", `Unknown node type "${record.type}"`)]);
|
|
338
|
+
},
|
|
339
|
+
run(params, draft) {
|
|
340
|
+
for (const id of draft.relationIds())
|
|
341
|
+
draft.deleteRelation(id);
|
|
342
|
+
for (const id of draft.nodeIds())
|
|
343
|
+
draft.deleteNode(id);
|
|
344
|
+
for (const record of Object.values(params.document.nodes))
|
|
345
|
+
draft.putNode(record);
|
|
346
|
+
for (const relation of Object.values(params.document.relations))
|
|
347
|
+
draft.putRelation(relation);
|
|
348
|
+
draft.setRootIds(params.document.rootIds);
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
export const BUILTIN_COMMANDS = [
|
|
352
|
+
createNode,
|
|
353
|
+
updateNode,
|
|
354
|
+
moveNode,
|
|
355
|
+
resizeNode,
|
|
356
|
+
transformNode,
|
|
357
|
+
reparentNode,
|
|
358
|
+
deleteNodes,
|
|
359
|
+
connect,
|
|
360
|
+
disconnect,
|
|
361
|
+
loadDocument,
|
|
362
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Diagnostic } from "../core/diagnostics.js";
|
|
2
|
+
import type { IdFactory } from "../core/ids.js";
|
|
3
|
+
import type { SchemaRegistry } from "../scene/schema.js";
|
|
4
|
+
import type { DocumentDraft, DocumentView } from "./draft.js";
|
|
5
|
+
export type CommandContext = {
|
|
6
|
+
schemas: SchemaRegistry;
|
|
7
|
+
ids: IdFactory;
|
|
8
|
+
};
|
|
9
|
+
export type Command<P = unknown, R = unknown> = {
|
|
10
|
+
id: string;
|
|
11
|
+
validate?(params: P, document: DocumentView, context: CommandContext): Diagnostic[];
|
|
12
|
+
run(params: P, draft: DocumentDraft, context: CommandContext): R;
|
|
13
|
+
};
|
|
14
|
+
export declare const defineCommand: <P, R = void>(command: Command<P, R>) => Command<P, R>;
|
|
15
|
+
export declare class CommandRegistry {
|
|
16
|
+
private commands;
|
|
17
|
+
register<P, R>(command: Command<P, R>): {
|
|
18
|
+
dispose: () => undefined;
|
|
19
|
+
};
|
|
20
|
+
get(id: string): Command<unknown, unknown> | undefined;
|
|
21
|
+
has(id: string): boolean;
|
|
22
|
+
get ids(): string[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const defineCommand = (command) => command;
|
|
2
|
+
export class CommandRegistry {
|
|
3
|
+
commands = new Map();
|
|
4
|
+
register(command) {
|
|
5
|
+
if (this.commands.has(command.id)) {
|
|
6
|
+
throw new Error(`Command "${command.id}" is already registered`);
|
|
7
|
+
}
|
|
8
|
+
this.commands.set(command.id, command);
|
|
9
|
+
return { dispose: () => void this.commands.delete(command.id) };
|
|
10
|
+
}
|
|
11
|
+
get(id) {
|
|
12
|
+
return this.commands.get(id);
|
|
13
|
+
}
|
|
14
|
+
has(id) {
|
|
15
|
+
return this.commands.has(id);
|
|
16
|
+
}
|
|
17
|
+
get ids() {
|
|
18
|
+
return [...this.commands.keys()];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NodeId } from "../core/ids.js";
|
|
2
|
+
import type { DocumentState, NodeRecord, RelationRecord } from "../scene/record.js";
|
|
3
|
+
import type { Patch } from "./patch.js";
|
|
4
|
+
/** Reading a document (the committed one or a draft). */
|
|
5
|
+
export type DocumentView = {
|
|
6
|
+
node(id: string): NodeRecord | undefined;
|
|
7
|
+
relation(id: string): RelationRecord | undefined;
|
|
8
|
+
readonly rootIds: readonly NodeId[];
|
|
9
|
+
nodeIds(): string[];
|
|
10
|
+
relationIds(): string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function viewOf(document: DocumentState): DocumentView;
|
|
13
|
+
export declare class DocumentDraft implements DocumentView {
|
|
14
|
+
readonly patches: Patch[];
|
|
15
|
+
private nodes;
|
|
16
|
+
private relations;
|
|
17
|
+
private roots;
|
|
18
|
+
private ownsNodes;
|
|
19
|
+
private ownsRelations;
|
|
20
|
+
private readonly base;
|
|
21
|
+
constructor(base: DocumentState);
|
|
22
|
+
node(id: string): NodeRecord;
|
|
23
|
+
relation(id: string): RelationRecord;
|
|
24
|
+
get rootIds(): readonly NodeId[];
|
|
25
|
+
nodeIds(): string[];
|
|
26
|
+
relationIds(): string[];
|
|
27
|
+
putNode(record: NodeRecord): void;
|
|
28
|
+
deleteNode(id: string): void;
|
|
29
|
+
putRelation(record: RelationRecord): void;
|
|
30
|
+
deleteRelation(id: string): void;
|
|
31
|
+
setRootIds(ids: readonly NodeId[]): void;
|
|
32
|
+
toDocument(): DocumentState;
|
|
33
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export function viewOf(document) {
|
|
2
|
+
return {
|
|
3
|
+
node: (id) => document.nodes[id],
|
|
4
|
+
relation: (id) => document.relations[id],
|
|
5
|
+
rootIds: document.rootIds,
|
|
6
|
+
nodeIds: () => Object.keys(document.nodes),
|
|
7
|
+
relationIds: () => Object.keys(document.relations),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export class DocumentDraft {
|
|
11
|
+
patches = [];
|
|
12
|
+
nodes;
|
|
13
|
+
relations;
|
|
14
|
+
roots;
|
|
15
|
+
ownsNodes = false;
|
|
16
|
+
ownsRelations = false;
|
|
17
|
+
base;
|
|
18
|
+
constructor(base) {
|
|
19
|
+
this.base = base;
|
|
20
|
+
this.nodes = base.nodes;
|
|
21
|
+
this.relations = base.relations;
|
|
22
|
+
this.roots = base.rootIds;
|
|
23
|
+
}
|
|
24
|
+
node(id) {
|
|
25
|
+
return this.nodes[id];
|
|
26
|
+
}
|
|
27
|
+
relation(id) {
|
|
28
|
+
return this.relations[id];
|
|
29
|
+
}
|
|
30
|
+
get rootIds() {
|
|
31
|
+
return this.roots;
|
|
32
|
+
}
|
|
33
|
+
nodeIds() {
|
|
34
|
+
return Object.keys(this.nodes);
|
|
35
|
+
}
|
|
36
|
+
relationIds() {
|
|
37
|
+
return Object.keys(this.relations);
|
|
38
|
+
}
|
|
39
|
+
putNode(record) {
|
|
40
|
+
if (!this.ownsNodes) {
|
|
41
|
+
this.nodes = { ...this.nodes };
|
|
42
|
+
this.ownsNodes = true;
|
|
43
|
+
}
|
|
44
|
+
const before = this.nodes[record.id];
|
|
45
|
+
const after = Object.freeze(record);
|
|
46
|
+
this.nodes[record.id] = after;
|
|
47
|
+
this.patches.push({ collection: "nodes", id: record.id, before, after });
|
|
48
|
+
}
|
|
49
|
+
deleteNode(id) {
|
|
50
|
+
const before = this.nodes[id];
|
|
51
|
+
if (!before)
|
|
52
|
+
return;
|
|
53
|
+
if (!this.ownsNodes) {
|
|
54
|
+
this.nodes = { ...this.nodes };
|
|
55
|
+
this.ownsNodes = true;
|
|
56
|
+
}
|
|
57
|
+
delete this.nodes[id];
|
|
58
|
+
this.patches.push({ collection: "nodes", id, before });
|
|
59
|
+
}
|
|
60
|
+
putRelation(record) {
|
|
61
|
+
if (!this.ownsRelations) {
|
|
62
|
+
this.relations = { ...this.relations };
|
|
63
|
+
this.ownsRelations = true;
|
|
64
|
+
}
|
|
65
|
+
const before = this.relations[record.id];
|
|
66
|
+
const after = Object.freeze(record);
|
|
67
|
+
this.relations[record.id] = after;
|
|
68
|
+
this.patches.push({ collection: "relations", id: record.id, before, after });
|
|
69
|
+
}
|
|
70
|
+
deleteRelation(id) {
|
|
71
|
+
const before = this.relations[id];
|
|
72
|
+
if (!before)
|
|
73
|
+
return;
|
|
74
|
+
if (!this.ownsRelations) {
|
|
75
|
+
this.relations = { ...this.relations };
|
|
76
|
+
this.ownsRelations = true;
|
|
77
|
+
}
|
|
78
|
+
delete this.relations[id];
|
|
79
|
+
this.patches.push({ collection: "relations", id, before });
|
|
80
|
+
}
|
|
81
|
+
setRootIds(ids) {
|
|
82
|
+
const before = this.roots;
|
|
83
|
+
this.roots = Object.freeze([...ids]);
|
|
84
|
+
this.patches.push({
|
|
85
|
+
collection: "roots",
|
|
86
|
+
id: "roots",
|
|
87
|
+
before,
|
|
88
|
+
after: this.roots,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
toDocument() {
|
|
92
|
+
if (!this.patches.length)
|
|
93
|
+
return this.base;
|
|
94
|
+
return { nodes: this.nodes, relations: this.relations, rootIds: this.roots };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Patch } from "./patch.js";
|
|
2
|
+
export type HistoryEntry = {
|
|
3
|
+
label: string;
|
|
4
|
+
patches: Patch[];
|
|
5
|
+
mergeKey?: string;
|
|
6
|
+
time: number;
|
|
7
|
+
};
|
|
8
|
+
export type HistoryOptions = {
|
|
9
|
+
capacity?: number;
|
|
10
|
+
/** ms within which entries with the same merge key merge. */
|
|
11
|
+
mergeWindow?: number;
|
|
12
|
+
now?: () => number;
|
|
13
|
+
};
|
|
14
|
+
export declare class History {
|
|
15
|
+
private entries;
|
|
16
|
+
private index;
|
|
17
|
+
private group;
|
|
18
|
+
private depth;
|
|
19
|
+
private readonly capacity;
|
|
20
|
+
private readonly mergeWindow;
|
|
21
|
+
readonly now: () => number;
|
|
22
|
+
constructor(options?: HistoryOptions);
|
|
23
|
+
get canUndo(): boolean;
|
|
24
|
+
get canRedo(): boolean;
|
|
25
|
+
get size(): number;
|
|
26
|
+
record(entry: HistoryEntry): void;
|
|
27
|
+
/** Everything recorded inside becomes one entry. */
|
|
28
|
+
beginGroup(label: string): void;
|
|
29
|
+
endGroup(): void;
|
|
30
|
+
/** The patches that undo the last entry (and move back one), or null. */
|
|
31
|
+
undo(): Patch[] | null;
|
|
32
|
+
redo(): Patch[] | null;
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|