@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,122 @@
|
|
|
1
|
+
import type { AnchorBox } from "../geometry/anchors.js";
|
|
2
|
+
export type CanvasTarget = {
|
|
3
|
+
kind: "pane";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "node";
|
|
6
|
+
id: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "handle";
|
|
9
|
+
nodeId: string;
|
|
10
|
+
handle: AnchorBox;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "control";
|
|
13
|
+
nodeId: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "edge";
|
|
16
|
+
id: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "edge-cut";
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
/** A selected node's resize corner or rotation handle. */
|
|
22
|
+
| {
|
|
23
|
+
kind: "transform";
|
|
24
|
+
nodeId: string;
|
|
25
|
+
handle: TransformHandle;
|
|
26
|
+
};
|
|
27
|
+
export type TransformHandle = "nw" | "ne" | "se" | "sw" | "rotate";
|
|
28
|
+
export type CanvasTargetKind = CanvasTarget["kind"];
|
|
29
|
+
export declare const PANE: CanvasTarget;
|
|
30
|
+
/** A target's identity (two picks of the same thing match). */
|
|
31
|
+
export declare function targetKey(target: CanvasTarget): string;
|
|
32
|
+
/** The node a target belongs to, if any. */
|
|
33
|
+
export declare function targetNodeId(target: CanvasTarget): string | null;
|
|
34
|
+
export declare const PointerEvent: {
|
|
35
|
+
readonly DOWN: "pointer.down";
|
|
36
|
+
readonly MOVE: "pointer.move";
|
|
37
|
+
readonly UP: "pointer.up";
|
|
38
|
+
readonly OVER: "pointer.over";
|
|
39
|
+
readonly OUT: "pointer.out";
|
|
40
|
+
readonly ENTER: "pointer.enter";
|
|
41
|
+
readonly LEAVE: "pointer.leave";
|
|
42
|
+
readonly TAP: "tap";
|
|
43
|
+
readonly DOUBLE_TAP: "double_tap";
|
|
44
|
+
readonly LONG_PRESS: "long_press";
|
|
45
|
+
readonly MENU: "pointer.menu";
|
|
46
|
+
};
|
|
47
|
+
export declare const DragEvent: {
|
|
48
|
+
readonly START: "drag.start";
|
|
49
|
+
readonly DRAG: "drag";
|
|
50
|
+
readonly END: "drag.end";
|
|
51
|
+
readonly ENTER: "drag.enter";
|
|
52
|
+
readonly LEAVE: "drag.leave";
|
|
53
|
+
readonly OVER: "drag.over";
|
|
54
|
+
readonly OUT: "drag.out";
|
|
55
|
+
readonly DROP: "drop";
|
|
56
|
+
};
|
|
57
|
+
export type CanvasEventType = (typeof PointerEvent)[keyof typeof PointerEvent] | (typeof DragEvent)[keyof typeof DragEvent];
|
|
58
|
+
/** What the engine knows of the browser event under a canvas event. */
|
|
59
|
+
export type PointerInput = {
|
|
60
|
+
clientX: number;
|
|
61
|
+
clientY: number;
|
|
62
|
+
button: number;
|
|
63
|
+
buttons: number;
|
|
64
|
+
shiftKey: boolean;
|
|
65
|
+
metaKey: boolean;
|
|
66
|
+
ctrlKey: boolean;
|
|
67
|
+
altKey: boolean;
|
|
68
|
+
pointerType: string;
|
|
69
|
+
/** The browser event, for handlers that take one (React Flow's). */
|
|
70
|
+
origin: MouseEvent;
|
|
71
|
+
};
|
|
72
|
+
export declare const EventPhase: {
|
|
73
|
+
readonly Capture: 1;
|
|
74
|
+
readonly Target: 2;
|
|
75
|
+
readonly Bubble: 3;
|
|
76
|
+
};
|
|
77
|
+
export type EventPhase = (typeof EventPhase)[keyof typeof EventPhase];
|
|
78
|
+
export declare class CanvasEvent {
|
|
79
|
+
readonly type: CanvasEventType;
|
|
80
|
+
readonly target: CanvasTarget;
|
|
81
|
+
/** From the target out to the pane. */
|
|
82
|
+
readonly path: CanvasTarget[];
|
|
83
|
+
readonly input: PointerInput;
|
|
84
|
+
current: CanvasTarget;
|
|
85
|
+
phase: EventPhase;
|
|
86
|
+
isStop: boolean;
|
|
87
|
+
isStopNow: boolean;
|
|
88
|
+
isStopDefault: boolean;
|
|
89
|
+
isGestureCancelled: boolean;
|
|
90
|
+
constructor(type: CanvasEventType, target: CanvasTarget, path: CanvasTarget[], input: PointerInput);
|
|
91
|
+
get clientX(): number;
|
|
92
|
+
get clientY(): number;
|
|
93
|
+
get origin(): MouseEvent;
|
|
94
|
+
get shiftKey(): boolean;
|
|
95
|
+
get metaKey(): boolean;
|
|
96
|
+
get ctrlKey(): boolean;
|
|
97
|
+
get altKey(): boolean;
|
|
98
|
+
/** No listener on a further target hears it. */
|
|
99
|
+
stop(): void;
|
|
100
|
+
/** No further listener hears it, not even on this target. */
|
|
101
|
+
stopNow(): void;
|
|
102
|
+
/** The browser's default action doesn't happen. */
|
|
103
|
+
stopDefault(): void;
|
|
104
|
+
/** On a press: a listener took it; it becomes no tap and no drag. */
|
|
105
|
+
cancelGesture(): void;
|
|
106
|
+
}
|
|
107
|
+
export declare class CanvasDragEvent extends CanvasEvent {
|
|
108
|
+
/** Screen px since the last drag event. */
|
|
109
|
+
readonly moveX: number;
|
|
110
|
+
readonly moveY: number;
|
|
111
|
+
/** Screen px since the press. */
|
|
112
|
+
readonly totalX: number;
|
|
113
|
+
readonly totalY: number;
|
|
114
|
+
/** A drag end that is a cancel (the pointer was taken, Escape, blur). */
|
|
115
|
+
readonly cancelled: boolean;
|
|
116
|
+
constructor(type: CanvasEventType, target: CanvasTarget, path: CanvasTarget[], input: PointerInput, move: {
|
|
117
|
+
moveX: number;
|
|
118
|
+
moveY: number;
|
|
119
|
+
totalX: number;
|
|
120
|
+
totalY: number;
|
|
121
|
+
}, cancelled?: boolean);
|
|
122
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export const PANE = { kind: "pane" };
|
|
2
|
+
/** A target's identity (two picks of the same thing match). */
|
|
3
|
+
export function targetKey(target) {
|
|
4
|
+
switch (target.kind) {
|
|
5
|
+
case "pane":
|
|
6
|
+
return "pane";
|
|
7
|
+
case "node":
|
|
8
|
+
return `node:${target.id}`;
|
|
9
|
+
case "handle":
|
|
10
|
+
return `handle:${target.nodeId}:${target.handle.type}:${target.handle.id ?? ""}`;
|
|
11
|
+
case "control":
|
|
12
|
+
return `control:${target.nodeId}`;
|
|
13
|
+
case "edge":
|
|
14
|
+
return `edge:${target.id}`;
|
|
15
|
+
case "edge-cut":
|
|
16
|
+
return `edge-cut:${target.id}`;
|
|
17
|
+
case "transform":
|
|
18
|
+
return `transform:${target.nodeId}:${target.handle}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The node a target belongs to, if any. */
|
|
22
|
+
export function targetNodeId(target) {
|
|
23
|
+
if (target.kind === "node")
|
|
24
|
+
return target.id;
|
|
25
|
+
if (target.kind === "handle" || target.kind === "control" || target.kind === "transform") {
|
|
26
|
+
return target.nodeId;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export const PointerEvent = {
|
|
31
|
+
DOWN: "pointer.down",
|
|
32
|
+
MOVE: "pointer.move",
|
|
33
|
+
UP: "pointer.up",
|
|
34
|
+
OVER: "pointer.over",
|
|
35
|
+
OUT: "pointer.out",
|
|
36
|
+
ENTER: "pointer.enter",
|
|
37
|
+
LEAVE: "pointer.leave",
|
|
38
|
+
TAP: "tap",
|
|
39
|
+
DOUBLE_TAP: "double_tap",
|
|
40
|
+
LONG_PRESS: "long_press",
|
|
41
|
+
MENU: "pointer.menu",
|
|
42
|
+
};
|
|
43
|
+
export const DragEvent = {
|
|
44
|
+
START: "drag.start",
|
|
45
|
+
DRAG: "drag",
|
|
46
|
+
END: "drag.end",
|
|
47
|
+
ENTER: "drag.enter",
|
|
48
|
+
LEAVE: "drag.leave",
|
|
49
|
+
OVER: "drag.over",
|
|
50
|
+
OUT: "drag.out",
|
|
51
|
+
DROP: "drop",
|
|
52
|
+
};
|
|
53
|
+
export const EventPhase = { Capture: 1, Target: 2, Bubble: 3 };
|
|
54
|
+
export class CanvasEvent {
|
|
55
|
+
type;
|
|
56
|
+
target;
|
|
57
|
+
/** From the target out to the pane. */
|
|
58
|
+
path;
|
|
59
|
+
input;
|
|
60
|
+
current;
|
|
61
|
+
phase = EventPhase.Target;
|
|
62
|
+
isStop = false;
|
|
63
|
+
isStopNow = false;
|
|
64
|
+
isStopDefault = false;
|
|
65
|
+
isGestureCancelled = false;
|
|
66
|
+
constructor(type, target, path, input) {
|
|
67
|
+
this.type = type;
|
|
68
|
+
this.target = target;
|
|
69
|
+
this.path = path;
|
|
70
|
+
this.current = target;
|
|
71
|
+
this.input = input;
|
|
72
|
+
}
|
|
73
|
+
get clientX() {
|
|
74
|
+
return this.input.clientX;
|
|
75
|
+
}
|
|
76
|
+
get clientY() {
|
|
77
|
+
return this.input.clientY;
|
|
78
|
+
}
|
|
79
|
+
get origin() {
|
|
80
|
+
return this.input.origin;
|
|
81
|
+
}
|
|
82
|
+
get shiftKey() {
|
|
83
|
+
return this.input.shiftKey;
|
|
84
|
+
}
|
|
85
|
+
get metaKey() {
|
|
86
|
+
return this.input.metaKey;
|
|
87
|
+
}
|
|
88
|
+
get ctrlKey() {
|
|
89
|
+
return this.input.ctrlKey;
|
|
90
|
+
}
|
|
91
|
+
get altKey() {
|
|
92
|
+
return this.input.altKey;
|
|
93
|
+
}
|
|
94
|
+
/** No listener on a further target hears it. */
|
|
95
|
+
stop() {
|
|
96
|
+
this.isStop = true;
|
|
97
|
+
}
|
|
98
|
+
/** No further listener hears it, not even on this target. */
|
|
99
|
+
stopNow() {
|
|
100
|
+
this.isStop = true;
|
|
101
|
+
this.isStopNow = true;
|
|
102
|
+
}
|
|
103
|
+
/** The browser's default action doesn't happen. */
|
|
104
|
+
stopDefault() {
|
|
105
|
+
this.isStopDefault = true;
|
|
106
|
+
this.input.origin.preventDefault();
|
|
107
|
+
}
|
|
108
|
+
/** On a press: a listener took it; it becomes no tap and no drag. */
|
|
109
|
+
cancelGesture() {
|
|
110
|
+
this.isGestureCancelled = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export class CanvasDragEvent extends CanvasEvent {
|
|
114
|
+
/** Screen px since the last drag event. */
|
|
115
|
+
moveX;
|
|
116
|
+
moveY;
|
|
117
|
+
/** Screen px since the press. */
|
|
118
|
+
totalX;
|
|
119
|
+
totalY;
|
|
120
|
+
/** A drag end that is a cancel (the pointer was taken, Escape, blur). */
|
|
121
|
+
cancelled;
|
|
122
|
+
constructor(type, target, path, input, move, cancelled = false) {
|
|
123
|
+
super(type, target, path, input);
|
|
124
|
+
this.cancelled = cancelled;
|
|
125
|
+
this.moveX = move.moveX;
|
|
126
|
+
this.moveY = move.moveY;
|
|
127
|
+
this.totalX = move.totalX;
|
|
128
|
+
this.totalY = move.totalY;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CanvasEvent, type CanvasEventType, type CanvasTargetKind } from "./event.js";
|
|
2
|
+
export type CanvasListener<E extends CanvasEvent = CanvasEvent> = (event: E) => void;
|
|
3
|
+
export type CanvasListenerOptions = {
|
|
4
|
+
capture?: boolean;
|
|
5
|
+
once?: boolean;
|
|
6
|
+
/** Only while the event is at targets of these kinds. */
|
|
7
|
+
on?: CanvasTargetKind | CanvasTargetKind[];
|
|
8
|
+
};
|
|
9
|
+
export type CanvasListenerId = number;
|
|
10
|
+
export declare class CanvasEventer {
|
|
11
|
+
private items;
|
|
12
|
+
private nextId;
|
|
13
|
+
/** Adds a listener; returns its id, for `off_`. */
|
|
14
|
+
on<E extends CanvasEvent = CanvasEvent>(type: CanvasEventType | CanvasEventType[], listener: CanvasListener<E>, options?: CanvasListenerOptions): CanvasListenerId;
|
|
15
|
+
once<E extends CanvasEvent = CanvasEvent>(type: CanvasEventType | CanvasEventType[], listener: CanvasListener<E>, options?: Omit<CanvasListenerOptions, "once">): number;
|
|
16
|
+
/** Removes listeners: by type and listener, by type, or all. */
|
|
17
|
+
off(type?: CanvasEventType, listener?: CanvasListener): void;
|
|
18
|
+
/** Removes the listeners added under these ids. */
|
|
19
|
+
off_(ids: CanvasListenerId | CanvasListenerId[]): void;
|
|
20
|
+
hasEvent(type: CanvasEventType): boolean;
|
|
21
|
+
/** Sends an event along its path; returns it (to read its flags). */
|
|
22
|
+
emit<E extends CanvasEvent>(event: E): E;
|
|
23
|
+
private run;
|
|
24
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Listeners for the engine's events (LeaferJS's `Eventer`: on, off, once,
|
|
3
|
+
* on_/off_ with ids), and their dispatch along an event's path: capture
|
|
4
|
+
* listeners from the pane in to the target, then bubble listeners from the
|
|
5
|
+
* target out to the pane. A listener can be limited to some kinds of target
|
|
6
|
+
* (`on: "node"`); it hears the event while `current` is of that kind.
|
|
7
|
+
*/
|
|
8
|
+
import { EventPhase, } from "./event.js";
|
|
9
|
+
export class CanvasEventer {
|
|
10
|
+
items = [];
|
|
11
|
+
nextId = 1;
|
|
12
|
+
/** Adds a listener; returns its id, for `off_`. */
|
|
13
|
+
on(type, listener, options = {}) {
|
|
14
|
+
const id = this.nextId++;
|
|
15
|
+
const kinds = options.on
|
|
16
|
+
? new Set(Array.isArray(options.on) ? options.on : [options.on])
|
|
17
|
+
: null;
|
|
18
|
+
for (const each of Array.isArray(type) ? type : [type]) {
|
|
19
|
+
this.items.push({
|
|
20
|
+
id,
|
|
21
|
+
type: each,
|
|
22
|
+
listener: listener,
|
|
23
|
+
capture: Boolean(options.capture),
|
|
24
|
+
once: Boolean(options.once),
|
|
25
|
+
kinds,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return id;
|
|
29
|
+
}
|
|
30
|
+
once(type, listener, options = {}) {
|
|
31
|
+
return this.on(type, listener, { ...options, once: true });
|
|
32
|
+
}
|
|
33
|
+
/** Removes listeners: by type and listener, by type, or all. */
|
|
34
|
+
off(type, listener) {
|
|
35
|
+
this.items = this.items.filter((item) => (type !== undefined && item.type !== type) ||
|
|
36
|
+
(listener !== undefined && item.listener !== listener));
|
|
37
|
+
}
|
|
38
|
+
/** Removes the listeners added under these ids. */
|
|
39
|
+
off_(ids) {
|
|
40
|
+
const remove = new Set(Array.isArray(ids) ? ids : [ids]);
|
|
41
|
+
this.items = this.items.filter((item) => !remove.has(item.id));
|
|
42
|
+
}
|
|
43
|
+
hasEvent(type) {
|
|
44
|
+
return this.items.some((item) => item.type === type);
|
|
45
|
+
}
|
|
46
|
+
/** Sends an event along its path; returns it (to read its flags). */
|
|
47
|
+
emit(event) {
|
|
48
|
+
const listeners = this.items.filter((item) => item.type === event.type);
|
|
49
|
+
if (!listeners.length)
|
|
50
|
+
return event;
|
|
51
|
+
const { path } = event;
|
|
52
|
+
// Capture: from the pane in to the target.
|
|
53
|
+
for (let index = path.length - 1; index >= 0; index--) {
|
|
54
|
+
event.current = path[index];
|
|
55
|
+
event.phase = index === 0 ? EventPhase.Target : EventPhase.Capture;
|
|
56
|
+
this.run(listeners, event, true);
|
|
57
|
+
if (event.isStop)
|
|
58
|
+
return event;
|
|
59
|
+
}
|
|
60
|
+
// Bubble: from the target out to the pane.
|
|
61
|
+
for (let index = 0; index < path.length; index++) {
|
|
62
|
+
event.current = path[index];
|
|
63
|
+
event.phase = index === 0 ? EventPhase.Target : EventPhase.Bubble;
|
|
64
|
+
this.run(listeners, event, false);
|
|
65
|
+
if (event.isStop)
|
|
66
|
+
return event;
|
|
67
|
+
}
|
|
68
|
+
return event;
|
|
69
|
+
}
|
|
70
|
+
run(listeners, event, capture) {
|
|
71
|
+
for (const item of listeners) {
|
|
72
|
+
if (item.capture !== capture)
|
|
73
|
+
continue;
|
|
74
|
+
if (item.kinds && !item.kinds.has(event.current.kind))
|
|
75
|
+
continue;
|
|
76
|
+
if (item.once)
|
|
77
|
+
this.items = this.items.filter((each) => each !== item);
|
|
78
|
+
item.listener(event);
|
|
79
|
+
if (event.isStopNow)
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CanvasEvent, type CanvasTarget, type PointerInput } from "./event.js";
|
|
2
|
+
import type { CanvasEventer } from "./eventer.js";
|
|
3
|
+
export type InteractionConfig = {
|
|
4
|
+
/** The target under a point, and its path out to the pane. */
|
|
5
|
+
pick: (input: PointerInput) => {
|
|
6
|
+
target: CanvasTarget;
|
|
7
|
+
path: CanvasTarget[];
|
|
8
|
+
};
|
|
9
|
+
/** Screen px a press on this target must travel to become a drag. */
|
|
10
|
+
dragDistance: (target: CanvasTarget) => number;
|
|
11
|
+
/** How long a still press takes to be a long press, ms. */
|
|
12
|
+
longPressTime?: number;
|
|
13
|
+
setTimer?: (run: () => void, ms: number) => unknown;
|
|
14
|
+
clearTimer?: (timer: unknown) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare class CanvasInteraction {
|
|
17
|
+
private press;
|
|
18
|
+
private hover;
|
|
19
|
+
private readonly config;
|
|
20
|
+
private readonly eventer;
|
|
21
|
+
constructor(eventer: CanvasEventer, config: InteractionConfig);
|
|
22
|
+
/** Whether a press is being tracked (a tap or a drag may follow). */
|
|
23
|
+
get pressing(): boolean;
|
|
24
|
+
get dragging(): boolean;
|
|
25
|
+
get hovered(): CanvasTarget | null;
|
|
26
|
+
private send;
|
|
27
|
+
private sendDrag;
|
|
28
|
+
/** Over/out on the target, enter/leave on each path entry that changes. */
|
|
29
|
+
private moveHover;
|
|
30
|
+
down(input: PointerInput): CanvasEvent;
|
|
31
|
+
move(input: PointerInput): CanvasEvent | null;
|
|
32
|
+
up(input: PointerInput): CanvasEvent;
|
|
33
|
+
/** The browser took the pointer (or the window lost it): a release. */
|
|
34
|
+
cancel(input: PointerInput): void;
|
|
35
|
+
/** A right-click (the menu). */
|
|
36
|
+
menu(input: PointerInput): CanvasEvent;
|
|
37
|
+
/** A double-click (the browser's, so it keeps its own timing). */
|
|
38
|
+
doubleTap(input: PointerInput): CanvasEvent;
|
|
39
|
+
/** The pointer left the canvas. */
|
|
40
|
+
leave(input: PointerInput): void;
|
|
41
|
+
private updateHover;
|
|
42
|
+
private cancelPress;
|
|
43
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Turns the browser's pointer input into the engine's events (LeaferJS's
|
|
3
|
+
* `Interaction`): it hit-tests each point (`pick`), keeps the hovered target
|
|
4
|
+
* (over/out on it, enter/leave on each target of its path that changes),
|
|
5
|
+
* tells a tap from a drag (past `dragDistance` of the pressed target), a
|
|
6
|
+
* long press (held still), and sends drag over/enter/leave/drop to what the
|
|
7
|
+
* pointer passes while dragging. No DOM: the hook feeds it.
|
|
8
|
+
*/
|
|
9
|
+
import { CanvasDragEvent, CanvasEvent, DragEvent, PointerEvent, targetKey, } from "./event.js";
|
|
10
|
+
export class CanvasInteraction {
|
|
11
|
+
press = null;
|
|
12
|
+
hover = null;
|
|
13
|
+
config;
|
|
14
|
+
eventer;
|
|
15
|
+
constructor(eventer, config) {
|
|
16
|
+
this.eventer = eventer;
|
|
17
|
+
this.config = {
|
|
18
|
+
longPressTime: 800,
|
|
19
|
+
setTimer: (run, ms) => setTimeout(run, ms),
|
|
20
|
+
clearTimer: (timer) => clearTimeout(timer),
|
|
21
|
+
...config,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Whether a press is being tracked (a tap or a drag may follow). */
|
|
25
|
+
get pressing() {
|
|
26
|
+
return Boolean(this.press && !this.press.cancelled);
|
|
27
|
+
}
|
|
28
|
+
get dragging() {
|
|
29
|
+
return Boolean(this.press?.dragging);
|
|
30
|
+
}
|
|
31
|
+
get hovered() {
|
|
32
|
+
return this.hover?.target ?? null;
|
|
33
|
+
}
|
|
34
|
+
send(type, hit, input) {
|
|
35
|
+
return this.eventer.emit(new CanvasEvent(type, hit.target, hit.path, input));
|
|
36
|
+
}
|
|
37
|
+
sendDrag(type, press, input, cancelled = false) {
|
|
38
|
+
const move = {
|
|
39
|
+
moveX: input.clientX - press.last.clientX,
|
|
40
|
+
moveY: input.clientY - press.last.clientY,
|
|
41
|
+
totalX: input.clientX - press.start.clientX,
|
|
42
|
+
totalY: input.clientY - press.start.clientY,
|
|
43
|
+
};
|
|
44
|
+
return this.eventer.emit(new CanvasDragEvent(type, press.target, press.path, input, move, cancelled));
|
|
45
|
+
}
|
|
46
|
+
/** Over/out on the target, enter/leave on each path entry that changes. */
|
|
47
|
+
moveHover(next, input, types, current) {
|
|
48
|
+
const before = current;
|
|
49
|
+
if (before && next && targetKey(before.target) === targetKey(next.target)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const nextKeys = new Set(next?.path.map(targetKey));
|
|
53
|
+
const beforeKeys = new Set(before?.path.map(targetKey));
|
|
54
|
+
if (before) {
|
|
55
|
+
this.send(types.out, before, input);
|
|
56
|
+
// Leave: each target of the old path not in the new one, innermost
|
|
57
|
+
// first; it doesn't bubble.
|
|
58
|
+
for (const item of before.path) {
|
|
59
|
+
if (nextKeys.has(targetKey(item)))
|
|
60
|
+
continue;
|
|
61
|
+
this.send(types.leave, { target: item, path: [item] }, input);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (next) {
|
|
65
|
+
this.send(types.over, next, input);
|
|
66
|
+
const entering = next.path.filter((item) => !beforeKeys.has(targetKey(item)));
|
|
67
|
+
// Enter: outermost first.
|
|
68
|
+
for (const item of entering.reverse()) {
|
|
69
|
+
this.send(types.enter, { target: item, path: [item] }, input);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
down(input) {
|
|
75
|
+
this.cancelPress();
|
|
76
|
+
const hit = this.config.pick(input);
|
|
77
|
+
// Hover follows the pointer to where it pressed (touch has no hover).
|
|
78
|
+
this.updateHover(hit, input);
|
|
79
|
+
const event = this.send(PointerEvent.DOWN, hit, input);
|
|
80
|
+
const press = {
|
|
81
|
+
...hit,
|
|
82
|
+
start: input,
|
|
83
|
+
last: input,
|
|
84
|
+
dragging: false,
|
|
85
|
+
cancelled: event.isGestureCancelled,
|
|
86
|
+
longPressed: false,
|
|
87
|
+
timer: null,
|
|
88
|
+
dragOver: null,
|
|
89
|
+
};
|
|
90
|
+
this.press = press;
|
|
91
|
+
if (!press.cancelled) {
|
|
92
|
+
press.timer = this.config.setTimer(() => {
|
|
93
|
+
if (this.press !== press || press.dragging || press.cancelled)
|
|
94
|
+
return;
|
|
95
|
+
press.longPressed = true;
|
|
96
|
+
this.send(PointerEvent.LONG_PRESS, press, press.last);
|
|
97
|
+
}, this.config.longPressTime);
|
|
98
|
+
}
|
|
99
|
+
return event;
|
|
100
|
+
}
|
|
101
|
+
move(input) {
|
|
102
|
+
const press = this.press;
|
|
103
|
+
if (!press || press.cancelled) {
|
|
104
|
+
const hit = this.config.pick(input);
|
|
105
|
+
this.updateHover(hit, input);
|
|
106
|
+
return this.send(PointerEvent.MOVE, hit, input);
|
|
107
|
+
}
|
|
108
|
+
if (!press.dragging) {
|
|
109
|
+
const distance = Math.hypot(input.clientX - press.start.clientX, input.clientY - press.start.clientY);
|
|
110
|
+
if (distance <= this.config.dragDistance(press.target)) {
|
|
111
|
+
press.last = input;
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
press.dragging = true;
|
|
115
|
+
this.config.clearTimer(press.timer);
|
|
116
|
+
const started = this.sendDrag(DragEvent.START, press, input);
|
|
117
|
+
press.last = input;
|
|
118
|
+
if (started.isGestureCancelled)
|
|
119
|
+
press.cancelled = true;
|
|
120
|
+
return started;
|
|
121
|
+
}
|
|
122
|
+
const event = this.sendDrag(DragEvent.DRAG, press, input);
|
|
123
|
+
press.last = input;
|
|
124
|
+
// What the pointer passes while dragging (a connection's target).
|
|
125
|
+
const hit = this.config.pick(input);
|
|
126
|
+
this.moveHover(hit, input, {
|
|
127
|
+
over: DragEvent.OVER,
|
|
128
|
+
out: DragEvent.OUT,
|
|
129
|
+
enter: DragEvent.ENTER,
|
|
130
|
+
leave: DragEvent.LEAVE,
|
|
131
|
+
}, press.dragOver);
|
|
132
|
+
press.dragOver = hit;
|
|
133
|
+
return event;
|
|
134
|
+
}
|
|
135
|
+
up(input) {
|
|
136
|
+
const press = this.press;
|
|
137
|
+
this.press = null;
|
|
138
|
+
const hit = this.config.pick(input);
|
|
139
|
+
const event = this.send(PointerEvent.UP, hit, input);
|
|
140
|
+
if (!press)
|
|
141
|
+
return event;
|
|
142
|
+
this.config.clearTimer(press.timer);
|
|
143
|
+
if (press.cancelled)
|
|
144
|
+
return event;
|
|
145
|
+
if (press.dragging) {
|
|
146
|
+
this.send(DragEvent.DROP, hit, input);
|
|
147
|
+
this.sendDrag(DragEvent.END, press, input);
|
|
148
|
+
this.updateHover(hit, input);
|
|
149
|
+
return event;
|
|
150
|
+
}
|
|
151
|
+
if (press.longPressed)
|
|
152
|
+
return event;
|
|
153
|
+
// A tap goes to what both the press and the release were on (the DOM's
|
|
154
|
+
// click: their nearest common target).
|
|
155
|
+
const upKeys = new Set(hit.path.map(targetKey));
|
|
156
|
+
const index = press.path.findIndex((item) => upKeys.has(targetKey(item)));
|
|
157
|
+
if (index >= 0) {
|
|
158
|
+
const path = press.path.slice(index);
|
|
159
|
+
this.send(PointerEvent.TAP, { target: path[0], path }, input);
|
|
160
|
+
}
|
|
161
|
+
return event;
|
|
162
|
+
}
|
|
163
|
+
/** The browser took the pointer (or the window lost it): a release. */
|
|
164
|
+
cancel(input) {
|
|
165
|
+
const press = this.press;
|
|
166
|
+
this.press = null;
|
|
167
|
+
if (!press)
|
|
168
|
+
return;
|
|
169
|
+
this.config.clearTimer(press.timer);
|
|
170
|
+
if (press.dragging && !press.cancelled) {
|
|
171
|
+
this.sendDrag(DragEvent.END, press, input, true);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** A right-click (the menu). */
|
|
175
|
+
menu(input) {
|
|
176
|
+
return this.send(PointerEvent.MENU, this.config.pick(input), input);
|
|
177
|
+
}
|
|
178
|
+
/** A double-click (the browser's, so it keeps its own timing). */
|
|
179
|
+
doubleTap(input) {
|
|
180
|
+
return this.send(PointerEvent.DOUBLE_TAP, this.config.pick(input), input);
|
|
181
|
+
}
|
|
182
|
+
/** The pointer left the canvas. */
|
|
183
|
+
leave(input) {
|
|
184
|
+
if (this.press)
|
|
185
|
+
return;
|
|
186
|
+
this.updateHover(null, input);
|
|
187
|
+
}
|
|
188
|
+
updateHover(hit, input) {
|
|
189
|
+
const changed = this.moveHover(hit, input, {
|
|
190
|
+
over: PointerEvent.OVER,
|
|
191
|
+
out: PointerEvent.OUT,
|
|
192
|
+
enter: PointerEvent.ENTER,
|
|
193
|
+
leave: PointerEvent.LEAVE,
|
|
194
|
+
}, this.hover);
|
|
195
|
+
if (changed || !hit)
|
|
196
|
+
this.hover = hit;
|
|
197
|
+
}
|
|
198
|
+
cancelPress() {
|
|
199
|
+
if (this.press)
|
|
200
|
+
this.config.clearTimer(this.press.timer);
|
|
201
|
+
this.press = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Vec2 } from "./vec2.js";
|
|
2
|
+
export type AnchorSide = "left" | "right" | "top" | "bottom";
|
|
3
|
+
export type AnchorBox = {
|
|
4
|
+
/** Null for a node's only anchor of its type. */
|
|
5
|
+
id: string | null;
|
|
6
|
+
type: "source" | "target";
|
|
7
|
+
side: AnchorSide;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
};
|
|
13
|
+
/** Where a relation leaves or reaches an anchor (React Flow's rule). */
|
|
14
|
+
export declare function anchorPoint(anchor: Pick<AnchorBox, "side" | "x" | "y" | "w" | "h">): Vec2;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Where a relation leaves or reaches an anchor (React Flow's rule). */
|
|
2
|
+
export function anchorPoint(anchor) {
|
|
3
|
+
switch (anchor.side) {
|
|
4
|
+
case "left":
|
|
5
|
+
return { x: anchor.x, y: anchor.y + anchor.h / 2 };
|
|
6
|
+
case "right":
|
|
7
|
+
return { x: anchor.x + anchor.w, y: anchor.y + anchor.h / 2 };
|
|
8
|
+
case "top":
|
|
9
|
+
return { x: anchor.x + anchor.w / 2, y: anchor.y };
|
|
10
|
+
default:
|
|
11
|
+
return { x: anchor.x + anchor.w / 2, y: anchor.y + anchor.h };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Mat2D } from "./matrix.js";
|
|
2
|
+
/** An axis-aligned box. */
|
|
3
|
+
export type Bounds = {
|
|
4
|
+
minX: number;
|
|
5
|
+
minY: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
maxY: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const EMPTY_BOUNDS: Bounds;
|
|
10
|
+
export declare function fromRect(x: number, y: number, w: number, h: number): Bounds;
|
|
11
|
+
export declare const isEmpty: (b: Bounds) => boolean;
|
|
12
|
+
export declare function union(a: Bounds, b: Bounds): Bounds;
|
|
13
|
+
export declare function intersects(a: Bounds, b: Bounds): boolean;
|
|
14
|
+
export declare function contains(b: Bounds, x: number, y: number): boolean;
|
|
15
|
+
/** The box around a box after a transform (its four corners). */
|
|
16
|
+
export declare function transformBounds(b: Bounds, m: Mat2D): Bounds;
|