@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,6 @@
|
|
|
1
|
+
/** Floats per quad instance (7 vec4). */
|
|
2
|
+
export declare const QUAD_FLOATS = 28;
|
|
3
|
+
export declare const QUAD_VERTEX = "#version 300 es\nlayout(location = 0) in vec2 a_corner;\nlayout(location = 1) in vec4 a_m0; // a, b, c, d (local \u2192 device px)\nlayout(location = 2) in vec4 a_m1; // e, f, offset x, offset y\nlayout(location = 3) in vec4 a_box; // w, h, radius, stroke width\nlayout(location = 4) in vec4 a_fill;\nlayout(location = 5) in vec4 a_stroke;\nlayout(location = 6) in vec4 a_uv; // u0, v0, u1, v1\nlayout(location = 7) in vec4 a_mode; // mode (0 box, 1 image, 2 text, 3 shadow), edge margin\nuniform vec2 u_resolution;\nout vec2 v_local;\nflat out vec4 v_box;\nflat out vec4 v_fill;\nflat out vec4 v_stroke;\nout vec2 v_uv;\nflat out vec4 v_uvRect;\nflat out float v_mode;\nvoid main() {\n vec2 size = a_box.xy;\n // One device px of margin for the antialiased edge.\n float scale = max(length(a_m0.xy), 1e-6);\n vec2 margin = vec2(max(1.0 / scale, a_mode.y));\n vec2 local = mix(-margin, size + margin, a_corner);\n vec2 p = a_m1.zw + local;\n vec2 device = vec2(a_m0.x * p.x + a_m0.z * p.y + a_m1.x, a_m0.y * p.x + a_m0.w * p.y + a_m1.y);\n vec2 clip = device / u_resolution * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n v_local = local;\n v_box = a_box;\n v_fill = a_fill;\n v_stroke = a_stroke;\n v_uv = mix(a_uv.xy, a_uv.zw, local / max(size, vec2(1e-6)));\n v_uvRect = vec4(min(a_uv.xy, a_uv.zw), max(a_uv.xy, a_uv.zw));\n v_mode = a_mode.x;\n}";
|
|
4
|
+
export declare const QUAD_FRAGMENT = "#version 300 es\nprecision highp float;\nin vec2 v_local;\nflat in vec4 v_box;\nflat in vec4 v_fill;\nflat in vec4 v_stroke;\nin vec2 v_uv;\nflat in vec4 v_uvRect;\nflat in float v_mode;\nuniform sampler2D u_texture;\nout vec4 color;\n// Abramowitz\u2013Stegun erf, enough for a Gaussian-blurred edge.\nfloat erf(float x) {\n float s = sign(x);\n float a = abs(x);\n float t = 1.0 / (1.0 + 0.3275911 * a);\n float y = 1.0 - (((((1.061405429 * t - 1.453152027) * t) + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * exp(-a * a);\n return s * y;\n}\nfloat roundedBox(vec2 p, vec2 halfSize, float r) {\n vec2 q = abs(p) - halfSize + r;\n return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;\n}\nvoid main() {\n vec2 halfSize = v_box.xy * 0.5;\n float radius = min(v_box.z, min(halfSize.x, halfSize.y));\n float d = roundedBox(v_local - halfSize, halfSize, radius);\n float aa = max(fwidth(d), 1e-4);\n float inside = clamp(0.5 - d / aa, 0.0, 1.0);\n if (v_mode < 0.5) {\n float sw = v_box.w;\n float inner = sw > 0.0 ? clamp(0.5 - (d + sw) / aa, 0.0, 1.0) : inside;\n vec4 fill = vec4(v_fill.rgb * v_fill.a, v_fill.a) * inner;\n vec4 stroke = vec4(v_stroke.rgb * v_stroke.a, v_stroke.a) * (inside - inner);\n color = fill + stroke;\n } else if (v_mode > 2.5) {\n // A shadow: the box's edge blurred by a Gaussian (sigma = blur / 2).\n float sigma = v_box.w * 0.5;\n float coverage = sigma > 0.0 ? 0.5 - 0.5 * erf(d / (sigma * 1.41421356)) : inside;\n color = vec4(v_fill.rgb * v_fill.a, v_fill.a) * coverage;\n } else if (v_mode < 1.5) {\n // The edge margin samples past the crop: hold it at the crop.\n vec2 uv = clamp(v_uv, v_uvRect.xy, v_uvRect.zw);\n color = texture(u_texture, uv) * v_fill.a * inside;\n } else {\n float a = texture(u_texture, clamp(v_uv, v_uvRect.xy, v_uvRect.zw)).a;\n color = vec4(v_fill.rgb * v_fill.a, v_fill.a) * a * inside;\n }\n if (color.a <= 0.0) discard;\n}";
|
|
5
|
+
export declare const MESH_VERTEX = "#version 300 es\nlayout(location = 0) in vec2 a_position;\nlayout(location = 1) in vec4 a_color;\nuniform vec2 u_resolution;\nuniform vec4 u_camera; // x, y, zoom, dpr\nout vec4 v_color;\nvoid main() {\n vec2 device = (a_position * u_camera.z + u_camera.xy) * u_camera.w;\n vec2 clip = device / u_resolution * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n v_color = vec4(a_color.rgb * a_color.a, a_color.a);\n}";
|
|
6
|
+
export declare const MESH_FRAGMENT = "#version 300 es\nprecision highp float;\nin vec4 v_color;\nout vec4 color;\nvoid main() {\n color = v_color;\n}";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WebGL2 shaders. One instanced quad program draws boxes, images and text
|
|
3
|
+
* runs: a rounded-box signed distance gives antialiased fills, inside
|
|
4
|
+
* strokes and corner masks. A mesh program draws curves' triangles.
|
|
5
|
+
* Colours are premultiplied (blend ONE, ONE_MINUS_SRC_ALPHA).
|
|
6
|
+
*/
|
|
7
|
+
/** Floats per quad instance (7 vec4). */
|
|
8
|
+
export const QUAD_FLOATS = 28;
|
|
9
|
+
export const QUAD_VERTEX = `#version 300 es
|
|
10
|
+
layout(location = 0) in vec2 a_corner;
|
|
11
|
+
layout(location = 1) in vec4 a_m0; // a, b, c, d (local → device px)
|
|
12
|
+
layout(location = 2) in vec4 a_m1; // e, f, offset x, offset y
|
|
13
|
+
layout(location = 3) in vec4 a_box; // w, h, radius, stroke width
|
|
14
|
+
layout(location = 4) in vec4 a_fill;
|
|
15
|
+
layout(location = 5) in vec4 a_stroke;
|
|
16
|
+
layout(location = 6) in vec4 a_uv; // u0, v0, u1, v1
|
|
17
|
+
layout(location = 7) in vec4 a_mode; // mode (0 box, 1 image, 2 text, 3 shadow), edge margin
|
|
18
|
+
uniform vec2 u_resolution;
|
|
19
|
+
out vec2 v_local;
|
|
20
|
+
flat out vec4 v_box;
|
|
21
|
+
flat out vec4 v_fill;
|
|
22
|
+
flat out vec4 v_stroke;
|
|
23
|
+
out vec2 v_uv;
|
|
24
|
+
flat out vec4 v_uvRect;
|
|
25
|
+
flat out float v_mode;
|
|
26
|
+
void main() {
|
|
27
|
+
vec2 size = a_box.xy;
|
|
28
|
+
// One device px of margin for the antialiased edge.
|
|
29
|
+
float scale = max(length(a_m0.xy), 1e-6);
|
|
30
|
+
vec2 margin = vec2(max(1.0 / scale, a_mode.y));
|
|
31
|
+
vec2 local = mix(-margin, size + margin, a_corner);
|
|
32
|
+
vec2 p = a_m1.zw + local;
|
|
33
|
+
vec2 device = vec2(a_m0.x * p.x + a_m0.z * p.y + a_m1.x, a_m0.y * p.x + a_m0.w * p.y + a_m1.y);
|
|
34
|
+
vec2 clip = device / u_resolution * 2.0 - 1.0;
|
|
35
|
+
gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
|
|
36
|
+
v_local = local;
|
|
37
|
+
v_box = a_box;
|
|
38
|
+
v_fill = a_fill;
|
|
39
|
+
v_stroke = a_stroke;
|
|
40
|
+
v_uv = mix(a_uv.xy, a_uv.zw, local / max(size, vec2(1e-6)));
|
|
41
|
+
v_uvRect = vec4(min(a_uv.xy, a_uv.zw), max(a_uv.xy, a_uv.zw));
|
|
42
|
+
v_mode = a_mode.x;
|
|
43
|
+
}`;
|
|
44
|
+
export const QUAD_FRAGMENT = `#version 300 es
|
|
45
|
+
precision highp float;
|
|
46
|
+
in vec2 v_local;
|
|
47
|
+
flat in vec4 v_box;
|
|
48
|
+
flat in vec4 v_fill;
|
|
49
|
+
flat in vec4 v_stroke;
|
|
50
|
+
in vec2 v_uv;
|
|
51
|
+
flat in vec4 v_uvRect;
|
|
52
|
+
flat in float v_mode;
|
|
53
|
+
uniform sampler2D u_texture;
|
|
54
|
+
out vec4 color;
|
|
55
|
+
// Abramowitz–Stegun erf, enough for a Gaussian-blurred edge.
|
|
56
|
+
float erf(float x) {
|
|
57
|
+
float s = sign(x);
|
|
58
|
+
float a = abs(x);
|
|
59
|
+
float t = 1.0 / (1.0 + 0.3275911 * a);
|
|
60
|
+
float y = 1.0 - (((((1.061405429 * t - 1.453152027) * t) + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * exp(-a * a);
|
|
61
|
+
return s * y;
|
|
62
|
+
}
|
|
63
|
+
float roundedBox(vec2 p, vec2 halfSize, float r) {
|
|
64
|
+
vec2 q = abs(p) - halfSize + r;
|
|
65
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
|
66
|
+
}
|
|
67
|
+
void main() {
|
|
68
|
+
vec2 halfSize = v_box.xy * 0.5;
|
|
69
|
+
float radius = min(v_box.z, min(halfSize.x, halfSize.y));
|
|
70
|
+
float d = roundedBox(v_local - halfSize, halfSize, radius);
|
|
71
|
+
float aa = max(fwidth(d), 1e-4);
|
|
72
|
+
float inside = clamp(0.5 - d / aa, 0.0, 1.0);
|
|
73
|
+
if (v_mode < 0.5) {
|
|
74
|
+
float sw = v_box.w;
|
|
75
|
+
float inner = sw > 0.0 ? clamp(0.5 - (d + sw) / aa, 0.0, 1.0) : inside;
|
|
76
|
+
vec4 fill = vec4(v_fill.rgb * v_fill.a, v_fill.a) * inner;
|
|
77
|
+
vec4 stroke = vec4(v_stroke.rgb * v_stroke.a, v_stroke.a) * (inside - inner);
|
|
78
|
+
color = fill + stroke;
|
|
79
|
+
} else if (v_mode > 2.5) {
|
|
80
|
+
// A shadow: the box's edge blurred by a Gaussian (sigma = blur / 2).
|
|
81
|
+
float sigma = v_box.w * 0.5;
|
|
82
|
+
float coverage = sigma > 0.0 ? 0.5 - 0.5 * erf(d / (sigma * 1.41421356)) : inside;
|
|
83
|
+
color = vec4(v_fill.rgb * v_fill.a, v_fill.a) * coverage;
|
|
84
|
+
} else if (v_mode < 1.5) {
|
|
85
|
+
// The edge margin samples past the crop: hold it at the crop.
|
|
86
|
+
vec2 uv = clamp(v_uv, v_uvRect.xy, v_uvRect.zw);
|
|
87
|
+
color = texture(u_texture, uv) * v_fill.a * inside;
|
|
88
|
+
} else {
|
|
89
|
+
float a = texture(u_texture, clamp(v_uv, v_uvRect.xy, v_uvRect.zw)).a;
|
|
90
|
+
color = vec4(v_fill.rgb * v_fill.a, v_fill.a) * a * inside;
|
|
91
|
+
}
|
|
92
|
+
if (color.a <= 0.0) discard;
|
|
93
|
+
}`;
|
|
94
|
+
export const MESH_VERTEX = `#version 300 es
|
|
95
|
+
layout(location = 0) in vec2 a_position;
|
|
96
|
+
layout(location = 1) in vec4 a_color;
|
|
97
|
+
uniform vec2 u_resolution;
|
|
98
|
+
uniform vec4 u_camera; // x, y, zoom, dpr
|
|
99
|
+
out vec4 v_color;
|
|
100
|
+
void main() {
|
|
101
|
+
vec2 device = (a_position * u_camera.z + u_camera.xy) * u_camera.w;
|
|
102
|
+
vec2 clip = device / u_resolution * 2.0 - 1.0;
|
|
103
|
+
gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
|
|
104
|
+
v_color = vec4(a_color.rgb * a_color.a, a_color.a);
|
|
105
|
+
}`;
|
|
106
|
+
export const MESH_FRAGMENT = `#version 300 es
|
|
107
|
+
precision highp float;
|
|
108
|
+
in vec4 v_color;
|
|
109
|
+
out vec4 color;
|
|
110
|
+
void main() {
|
|
111
|
+
color = v_color;
|
|
112
|
+
}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const groupType: import("./schema.js").NodeType<{}>;
|
|
2
|
+
export declare const frameType: import("./schema.js").NodeType<{
|
|
3
|
+
title: string;
|
|
4
|
+
clip: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const rectType: import("./schema.js").NodeType<{
|
|
7
|
+
fill: string;
|
|
8
|
+
radius: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const textType: import("./schema.js").NodeType<{
|
|
11
|
+
text: string;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const imageType: import("./schema.js").NodeType<{
|
|
15
|
+
src: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A node whose type the engine doesn't know (a newer document, a missing
|
|
19
|
+
* plugin): kept with what it held, never dropped.
|
|
20
|
+
*/
|
|
21
|
+
export declare const unknownType: import("./schema.js").NodeType<{
|
|
22
|
+
originalType: string;
|
|
23
|
+
payload: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const BUILTIN_TYPES: import("./schema.js").NodeType<{}>[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { error } from "../core/diagnostics.js";
|
|
2
|
+
import { defineNodeType } from "./schema.js";
|
|
3
|
+
const isString = (value) => typeof value === "string";
|
|
4
|
+
export const groupType = defineNodeType({
|
|
5
|
+
type: "group",
|
|
6
|
+
version: 1,
|
|
7
|
+
canHaveChildren: true,
|
|
8
|
+
defaults: () => ({}),
|
|
9
|
+
});
|
|
10
|
+
export const frameType = defineNodeType({
|
|
11
|
+
type: "frame",
|
|
12
|
+
version: 1,
|
|
13
|
+
canHaveChildren: true,
|
|
14
|
+
defaults: () => ({ title: "", clip: true }),
|
|
15
|
+
validate: (props) => isString(props.title)
|
|
16
|
+
? []
|
|
17
|
+
: [error("frame.title", "A frame's title is a string")],
|
|
18
|
+
});
|
|
19
|
+
export const rectType = defineNodeType({
|
|
20
|
+
type: "rect",
|
|
21
|
+
version: 1,
|
|
22
|
+
defaults: () => ({ fill: "", radius: 0 }),
|
|
23
|
+
validate: (props) => typeof props.radius === "number" && props.radius >= 0
|
|
24
|
+
? []
|
|
25
|
+
: [error("rect.radius", "A rect's radius is a number ≥ 0")],
|
|
26
|
+
});
|
|
27
|
+
export const textType = defineNodeType({
|
|
28
|
+
type: "text",
|
|
29
|
+
version: 1,
|
|
30
|
+
defaults: () => ({ text: "", fontSize: 14 }),
|
|
31
|
+
validate: (props) => isString(props.text)
|
|
32
|
+
? []
|
|
33
|
+
: [error("text.text", "A text node's text is a string")],
|
|
34
|
+
});
|
|
35
|
+
export const imageType = defineNodeType({
|
|
36
|
+
type: "image",
|
|
37
|
+
version: 1,
|
|
38
|
+
defaults: () => ({ src: "" }),
|
|
39
|
+
validate: (props) => isString(props.src)
|
|
40
|
+
? []
|
|
41
|
+
: [error("image.src", "An image's src is a string")],
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* A node whose type the engine doesn't know (a newer document, a missing
|
|
45
|
+
* plugin): kept with what it held, never dropped.
|
|
46
|
+
*/
|
|
47
|
+
export const unknownType = defineNodeType({
|
|
48
|
+
type: "unknown",
|
|
49
|
+
version: 1,
|
|
50
|
+
canHaveChildren: true,
|
|
51
|
+
defaults: () => ({ originalType: "", payload: null }),
|
|
52
|
+
});
|
|
53
|
+
export const BUILTIN_TYPES = [
|
|
54
|
+
groupType,
|
|
55
|
+
frameType,
|
|
56
|
+
rectType,
|
|
57
|
+
textType,
|
|
58
|
+
imageType,
|
|
59
|
+
unknownType,
|
|
60
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What of a scene node must be computed again. */
|
|
2
|
+
export declare const Dirty: {
|
|
3
|
+
readonly None: 0;
|
|
4
|
+
readonly Transform: number;
|
|
5
|
+
readonly Bounds: number;
|
|
6
|
+
readonly Props: number;
|
|
7
|
+
readonly Children: number;
|
|
8
|
+
readonly Style: number;
|
|
9
|
+
};
|
|
10
|
+
export type DirtyFlags = number;
|
|
11
|
+
export declare const ALL_DIRTY: number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What of a scene node must be computed again. */
|
|
2
|
+
export const Dirty = {
|
|
3
|
+
None: 0,
|
|
4
|
+
Transform: 1 << 0,
|
|
5
|
+
Bounds: 1 << 1,
|
|
6
|
+
Props: 1 << 2,
|
|
7
|
+
Children: 1 << 3,
|
|
8
|
+
Style: 1 << 4,
|
|
9
|
+
};
|
|
10
|
+
export const ALL_DIRTY = Dirty.Transform | Dirty.Bounds | Dirty.Props | Dirty.Children | Dirty.Style;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { NodeId, RelationId } from "../core/ids.js";
|
|
2
|
+
import type { TRS } from "../geometry/matrix.js";
|
|
3
|
+
export type Transform = TRS;
|
|
4
|
+
export type Size = {
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
};
|
|
8
|
+
export type NodeRecord<Props = Record<string, unknown>> = {
|
|
9
|
+
id: NodeId;
|
|
10
|
+
type: string;
|
|
11
|
+
/** The schema version its props follow (migrations). */
|
|
12
|
+
typeVersion: number;
|
|
13
|
+
parentId: NodeId | null;
|
|
14
|
+
childIds: NodeId[];
|
|
15
|
+
/** In its parent's space. */
|
|
16
|
+
transform: Transform;
|
|
17
|
+
size: Size;
|
|
18
|
+
props: Props;
|
|
19
|
+
visible: boolean;
|
|
20
|
+
locked: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type RelationEnd = {
|
|
23
|
+
nodeId: NodeId;
|
|
24
|
+
anchor: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type RelationRecord = {
|
|
27
|
+
id: RelationId;
|
|
28
|
+
kind: "connection";
|
|
29
|
+
source: RelationEnd;
|
|
30
|
+
target: RelationEnd;
|
|
31
|
+
props: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
export type DocumentState = {
|
|
34
|
+
nodes: Readonly<Record<string, NodeRecord>>;
|
|
35
|
+
relations: Readonly<Record<string, RelationRecord>>;
|
|
36
|
+
/** Top-level nodes, back to front. */
|
|
37
|
+
rootIds: readonly NodeId[];
|
|
38
|
+
};
|
|
39
|
+
export declare const emptyDocument: () => DocumentState;
|
|
40
|
+
export declare const IDENTITY_TRANSFORM: Transform;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { NodeId } from "../core/ids.js";
|
|
2
|
+
import { type Bounds } from "../geometry/bounds.js";
|
|
3
|
+
import { type Mat2D } from "../geometry/matrix.js";
|
|
4
|
+
import { type DirtyFlags } from "./dirty.js";
|
|
5
|
+
import type { DocumentState, NodeRecord, Size, Transform } from "./record.js";
|
|
6
|
+
export type SceneNode = {
|
|
7
|
+
readonly id: NodeId;
|
|
8
|
+
record: NodeRecord;
|
|
9
|
+
parent: SceneNode | null;
|
|
10
|
+
children: SceneNode[];
|
|
11
|
+
/** Its transform (with any preview) as a matrix, in its parent's space. */
|
|
12
|
+
local: Mat2D;
|
|
13
|
+
world: Mat2D;
|
|
14
|
+
/** Its own box, in world space. */
|
|
15
|
+
worldBounds: Bounds;
|
|
16
|
+
/** Its box and its subtree's, in world space. */
|
|
17
|
+
subtreeBounds: Bounds;
|
|
18
|
+
dirty: DirtyFlags;
|
|
19
|
+
};
|
|
20
|
+
export type Preview = Readonly<Record<string, Partial<Transform>>>;
|
|
21
|
+
/** What an update did: the nodes it touched, or a rebuild (all new nodes). */
|
|
22
|
+
export type SceneChange = {
|
|
23
|
+
rebuilt: boolean;
|
|
24
|
+
touched: readonly SceneNode[];
|
|
25
|
+
};
|
|
26
|
+
export declare class SceneGraph {
|
|
27
|
+
private nodes;
|
|
28
|
+
private roots;
|
|
29
|
+
private preview;
|
|
30
|
+
private previewSize;
|
|
31
|
+
private pending;
|
|
32
|
+
private rebuilt;
|
|
33
|
+
private listeners;
|
|
34
|
+
private document;
|
|
35
|
+
constructor(document: DocumentState);
|
|
36
|
+
get size(): number;
|
|
37
|
+
get rootNodes(): readonly SceneNode[];
|
|
38
|
+
get(id: string): SceneNode | undefined;
|
|
39
|
+
/** Every node, parents before children, back to front. */
|
|
40
|
+
walk(from?: readonly SceneNode[]): Generator<SceneNode>;
|
|
41
|
+
ancestors(id: string): Generator<SceneNode>;
|
|
42
|
+
/** Nodes whose own box meets `bounds` (a linear scan; Phase 3 indexes). */
|
|
43
|
+
nodesInBounds(bounds: Bounds): SceneNode[];
|
|
44
|
+
/** The document changed: mark what it touched. */
|
|
45
|
+
setDocument(document: DocumentState, changedIds?: Iterable<string>): void;
|
|
46
|
+
/** Interaction previews over the document (they never write it). */
|
|
47
|
+
setPreview(preview: Preview, sizes?: Readonly<Record<string, Size>>): void;
|
|
48
|
+
/** Brings matrices and bounds up to date; returns the nodes it touched. */
|
|
49
|
+
update(): SceneNode[];
|
|
50
|
+
/** Called after each update (renderers keep their indexes with it). */
|
|
51
|
+
onUpdate(listener: (change: SceneChange) => void): {
|
|
52
|
+
dispose: () => undefined;
|
|
53
|
+
};
|
|
54
|
+
/** A node's size, with a resize preview over it. */
|
|
55
|
+
sizeOf(node: SceneNode): Size;
|
|
56
|
+
private markSubtree;
|
|
57
|
+
private rebuild;
|
|
58
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { EMPTY_BOUNDS, fromRect, transformBounds, union, intersects, } from "../geometry/bounds.js";
|
|
2
|
+
import { fromTRS, identity, multiply } from "../geometry/matrix.js";
|
|
3
|
+
import { Dirty, ALL_DIRTY } from "./dirty.js";
|
|
4
|
+
export class SceneGraph {
|
|
5
|
+
nodes = new Map();
|
|
6
|
+
roots = [];
|
|
7
|
+
preview = {};
|
|
8
|
+
previewSize = {};
|
|
9
|
+
pending = true;
|
|
10
|
+
rebuilt = true;
|
|
11
|
+
listeners = new Set();
|
|
12
|
+
document;
|
|
13
|
+
constructor(document) {
|
|
14
|
+
this.document = document;
|
|
15
|
+
this.rebuild();
|
|
16
|
+
}
|
|
17
|
+
get size() {
|
|
18
|
+
return this.nodes.size;
|
|
19
|
+
}
|
|
20
|
+
get rootNodes() {
|
|
21
|
+
this.update();
|
|
22
|
+
return this.roots;
|
|
23
|
+
}
|
|
24
|
+
get(id) {
|
|
25
|
+
this.update();
|
|
26
|
+
return this.nodes.get(id);
|
|
27
|
+
}
|
|
28
|
+
/** Every node, parents before children, back to front. */
|
|
29
|
+
*walk(from = this.rootNodes) {
|
|
30
|
+
for (const node of from) {
|
|
31
|
+
yield node;
|
|
32
|
+
yield* this.walk(node.children);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
*ancestors(id) {
|
|
36
|
+
let node = this.get(id)?.parent ?? null;
|
|
37
|
+
while (node) {
|
|
38
|
+
yield node;
|
|
39
|
+
node = node.parent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Nodes whose own box meets `bounds` (a linear scan; Phase 3 indexes). */
|
|
43
|
+
nodesInBounds(bounds) {
|
|
44
|
+
this.update();
|
|
45
|
+
return [...this.walk()].filter((node) => intersects(node.worldBounds, bounds));
|
|
46
|
+
}
|
|
47
|
+
/** The document changed: mark what it touched. */
|
|
48
|
+
setDocument(document, changedIds) {
|
|
49
|
+
const previous = this.document;
|
|
50
|
+
this.document = document;
|
|
51
|
+
if (!changedIds || previous.rootIds !== document.rootIds) {
|
|
52
|
+
this.rebuild();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const id of changedIds) {
|
|
56
|
+
const record = document.nodes[id];
|
|
57
|
+
const node = this.nodes.get(id);
|
|
58
|
+
// Added, removed or moved between parents: the structure changed.
|
|
59
|
+
if (!record ||
|
|
60
|
+
!node ||
|
|
61
|
+
node.record.parentId !== record.parentId ||
|
|
62
|
+
node.record.childIds !== record.childIds) {
|
|
63
|
+
this.rebuild();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const moved = node.record.transform !== record.transform ||
|
|
67
|
+
node.record.size !== record.size;
|
|
68
|
+
node.record = record;
|
|
69
|
+
if (moved)
|
|
70
|
+
this.markSubtree(node, Dirty.Transform | Dirty.Bounds);
|
|
71
|
+
else
|
|
72
|
+
node.dirty |= Dirty.Props | Dirty.Style;
|
|
73
|
+
}
|
|
74
|
+
this.pending = true;
|
|
75
|
+
}
|
|
76
|
+
/** Interaction previews over the document (they never write it). */
|
|
77
|
+
setPreview(preview, sizes = {}) {
|
|
78
|
+
const ids = new Set([
|
|
79
|
+
...Object.keys(this.preview),
|
|
80
|
+
...Object.keys(preview),
|
|
81
|
+
...Object.keys(this.previewSize),
|
|
82
|
+
...Object.keys(sizes),
|
|
83
|
+
]);
|
|
84
|
+
this.preview = preview;
|
|
85
|
+
this.previewSize = sizes;
|
|
86
|
+
for (const id of ids) {
|
|
87
|
+
const node = this.nodes.get(id);
|
|
88
|
+
if (node)
|
|
89
|
+
this.markSubtree(node, Dirty.Transform | Dirty.Bounds);
|
|
90
|
+
}
|
|
91
|
+
this.pending = true;
|
|
92
|
+
}
|
|
93
|
+
/** Brings matrices and bounds up to date; returns the nodes it touched. */
|
|
94
|
+
update() {
|
|
95
|
+
if (!this.pending)
|
|
96
|
+
return [];
|
|
97
|
+
this.pending = false;
|
|
98
|
+
const touched = [];
|
|
99
|
+
const visit = (node, parentWorld, parentMoved) => {
|
|
100
|
+
const moved = parentMoved || (node.dirty & Dirty.Transform) !== 0;
|
|
101
|
+
if (moved) {
|
|
102
|
+
const transform = { ...node.record.transform, ...this.preview[node.id] };
|
|
103
|
+
node.local = fromTRS(transform);
|
|
104
|
+
node.world = multiply(new Float64Array(6), parentWorld, node.local);
|
|
105
|
+
const size = this.sizeOf(node);
|
|
106
|
+
node.worldBounds = transformBounds(fromRect(0, 0, size.w, size.h), node.world);
|
|
107
|
+
}
|
|
108
|
+
let subtree = node.worldBounds;
|
|
109
|
+
for (const child of node.children) {
|
|
110
|
+
visit(child, node.world, moved);
|
|
111
|
+
subtree = union(subtree, child.subtreeBounds);
|
|
112
|
+
}
|
|
113
|
+
node.subtreeBounds = subtree;
|
|
114
|
+
if (node.dirty || moved)
|
|
115
|
+
touched.push(node);
|
|
116
|
+
node.dirty = Dirty.None;
|
|
117
|
+
};
|
|
118
|
+
for (const root of this.roots)
|
|
119
|
+
visit(root, identity(), false);
|
|
120
|
+
const change = { rebuilt: this.rebuilt, touched };
|
|
121
|
+
this.rebuilt = false;
|
|
122
|
+
for (const listener of this.listeners)
|
|
123
|
+
listener(change);
|
|
124
|
+
return touched;
|
|
125
|
+
}
|
|
126
|
+
/** Called after each update (renderers keep their indexes with it). */
|
|
127
|
+
onUpdate(listener) {
|
|
128
|
+
this.listeners.add(listener);
|
|
129
|
+
return { dispose: () => void this.listeners.delete(listener) };
|
|
130
|
+
}
|
|
131
|
+
/** A node's size, with a resize preview over it. */
|
|
132
|
+
sizeOf(node) {
|
|
133
|
+
return this.previewSize[node.id] ?? node.record.size;
|
|
134
|
+
}
|
|
135
|
+
markSubtree(node, flags) {
|
|
136
|
+
node.dirty |= flags;
|
|
137
|
+
for (const child of node.children)
|
|
138
|
+
this.markSubtree(child, flags);
|
|
139
|
+
// Bounds dirtiness goes up: the ancestors' subtree boxes change.
|
|
140
|
+
let parent = node.parent;
|
|
141
|
+
while (parent) {
|
|
142
|
+
parent.dirty |= Dirty.Bounds;
|
|
143
|
+
parent = parent.parent;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
rebuild() {
|
|
147
|
+
this.nodes = new Map();
|
|
148
|
+
const build = (id, parent) => {
|
|
149
|
+
const record = this.document.nodes[id];
|
|
150
|
+
if (!record)
|
|
151
|
+
return null;
|
|
152
|
+
const node = {
|
|
153
|
+
id: record.id,
|
|
154
|
+
record,
|
|
155
|
+
parent,
|
|
156
|
+
children: [],
|
|
157
|
+
local: identity(),
|
|
158
|
+
world: identity(),
|
|
159
|
+
worldBounds: EMPTY_BOUNDS,
|
|
160
|
+
subtreeBounds: EMPTY_BOUNDS,
|
|
161
|
+
dirty: ALL_DIRTY,
|
|
162
|
+
};
|
|
163
|
+
this.nodes.set(id, node);
|
|
164
|
+
for (const childId of record.childIds) {
|
|
165
|
+
const child = build(childId, node);
|
|
166
|
+
if (child)
|
|
167
|
+
node.children.push(child);
|
|
168
|
+
}
|
|
169
|
+
return node;
|
|
170
|
+
};
|
|
171
|
+
this.roots = this.document.rootIds.flatMap((id) => {
|
|
172
|
+
const node = build(id, null);
|
|
173
|
+
return node ? [node] : [];
|
|
174
|
+
});
|
|
175
|
+
this.pending = true;
|
|
176
|
+
this.rebuilt = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Diagnostic } from "../core/diagnostics.js";
|
|
2
|
+
import type { AnchorBox } from "../geometry/anchors.js";
|
|
3
|
+
import type { NodeRecord } from "./record.js";
|
|
4
|
+
export type NodeType<Props = Record<string, unknown>> = {
|
|
5
|
+
type: string;
|
|
6
|
+
version: number;
|
|
7
|
+
defaults(): Props;
|
|
8
|
+
validate?(props: Props): Diagnostic[];
|
|
9
|
+
canHaveChildren?: boolean;
|
|
10
|
+
/** May a relation start and end on the same node? */
|
|
11
|
+
allowSelfConnection?: boolean;
|
|
12
|
+
anchors?(record: NodeRecord<Props>): AnchorBox[];
|
|
13
|
+
/** Props saved by an older version, brought to `version`. */
|
|
14
|
+
migrate?(props: Record<string, unknown>, fromVersion: number): Props;
|
|
15
|
+
};
|
|
16
|
+
export declare const defineNodeType: <Props extends Record<string, unknown>>(type: NodeType<Props>) => NodeType<Props>;
|
|
17
|
+
export declare class SchemaRegistry {
|
|
18
|
+
private types;
|
|
19
|
+
register(type: NodeType): {
|
|
20
|
+
dispose: () => undefined;
|
|
21
|
+
};
|
|
22
|
+
get(type: string): NodeType | undefined;
|
|
23
|
+
has(type: string): boolean;
|
|
24
|
+
/** Errors for a type that doesn't exist or props it refuses. */
|
|
25
|
+
validate(type: string, props: Record<string, unknown>): Diagnostic[];
|
|
26
|
+
anchors(record: NodeRecord): AnchorBox[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Node types: their default props, validation, anchors and migrations
|
|
3
|
+
* (LeaferJS's registered UI classes, as data).
|
|
4
|
+
*/
|
|
5
|
+
import { error } from "../core/diagnostics.js";
|
|
6
|
+
export const defineNodeType = (type) => type;
|
|
7
|
+
export class SchemaRegistry {
|
|
8
|
+
types = new Map();
|
|
9
|
+
register(type) {
|
|
10
|
+
if (this.types.has(type.type)) {
|
|
11
|
+
throw new Error(`Node type "${type.type}" is already registered`);
|
|
12
|
+
}
|
|
13
|
+
this.types.set(type.type, type);
|
|
14
|
+
return { dispose: () => void this.types.delete(type.type) };
|
|
15
|
+
}
|
|
16
|
+
get(type) {
|
|
17
|
+
return this.types.get(type);
|
|
18
|
+
}
|
|
19
|
+
has(type) {
|
|
20
|
+
return this.types.has(type);
|
|
21
|
+
}
|
|
22
|
+
/** Errors for a type that doesn't exist or props it refuses. */
|
|
23
|
+
validate(type, props) {
|
|
24
|
+
const schema = this.types.get(type);
|
|
25
|
+
if (!schema)
|
|
26
|
+
return [error("node.unknown-type", `Unknown node type "${type}"`)];
|
|
27
|
+
return schema.validate?.(props) ?? [];
|
|
28
|
+
}
|
|
29
|
+
anchors(record) {
|
|
30
|
+
return this.types.get(record.type)?.anchors?.(record) ?? [];
|
|
31
|
+
}
|
|
32
|
+
}
|