@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
package/README.md
CHANGED
|
@@ -1,3 +1,194 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AVIS Engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-free canvas/scene engine with optional native React and React Flow
|
|
4
|
+
compatibility adapters. ESM only. **Private beta**, published to the GitHub
|
|
5
|
+
Packages of the org `avis-ui` as `@avis-ui/engine` (never to npmjs; the
|
|
6
|
+
source keeps `private: true` as a guard).
|
|
7
|
+
|
|
8
|
+
## Install (members of the org avis-ui)
|
|
9
|
+
|
|
10
|
+
1. Join the GitHub org `avis-ui` (ask the owner).
|
|
11
|
+
2. Make a GitHub token (classic) with `read:packages`.
|
|
12
|
+
3. Beside your `package.json`, an `.npmrc` (keep the token out of git):
|
|
13
|
+
|
|
14
|
+
```ini
|
|
15
|
+
@avis-ui:registry=https://npm.pkg.github.com
|
|
16
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
4. Install it under the name the prototype's code imports:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install "@avis-studio/engine@npm:@avis-ui/engine@0.1.0-beta.1"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then `import … from "@avis-studio/engine/react/canvas"` works as in the
|
|
26
|
+
prototype. A local tarball (`npm run engine:pack`) installs the same way:
|
|
27
|
+
`npm install /path/to/avis-studio-engine-0.1.0-beta.1.tgz`.
|
|
28
|
+
|
|
29
|
+
| Import | Contents |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `@avis-studio/engine` | Core, scene, commands/history, vanilla SDK, kernel loader |
|
|
32
|
+
| `@avis-studio/engine/react` | Native React canvas, elements and hooks |
|
|
33
|
+
| `@avis-studio/engine/react/canvas` | The graph canvas API under AVIS names (`GraphCanvas`, `useGraph`, `useGraphSelect`, `useNodeBox`, `HandleSide`, `NodeOverlay`…), with `mountNode` / `mountEdges` |
|
|
34
|
+
| `@avis-studio/engine/react/flow` | The same API under React Flow's names |
|
|
35
|
+
| `@avis-studio/engine/sync` | Backend-neutral coalescing save queue with failure recovery |
|
|
36
|
+
| `@avis-studio/engine/react/flow/style.css` | Flow stylesheet; import once in the application |
|
|
37
|
+
|
|
38
|
+
The core has **zero runtime dependencies**. Node 20+ can import it without a DOM;
|
|
39
|
+
rendering and `createAvis` require a browser. The package targets ES2023 browsers.
|
|
40
|
+
Type declarations support TypeScript's NodeNext and Bundler module resolution.
|
|
41
|
+
CommonJS `require` and private `dist/*` imports are not supported entrypoints.
|
|
42
|
+
|
|
43
|
+
## Vanilla
|
|
44
|
+
|
|
45
|
+
Create `theme.ts` (or pass your application's equivalent token CSS):
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
export const tokens = [`:root {
|
|
49
|
+
--spacing: 4px; --radius-lg: 8px; --text-lg: 18px; --text-lg--line-height: 1.5; --font-sans: Arial;
|
|
50
|
+
--color-background: #f5f5f5; --color-card: #fff; --color-border: #ddd;
|
|
51
|
+
--color-foreground: #111; --color-muted-foreground: #737373;
|
|
52
|
+
--color-muted: #e6e6e6; --color-ring: #007bff; --color-destructive: #ef4444;
|
|
53
|
+
}`]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then mount the canvas:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { createAvis } from "@avis-studio/engine"
|
|
60
|
+
import { tokens } from "./theme.js"
|
|
61
|
+
|
|
62
|
+
const avis = await createAvis({ container: "#editor", renderer: "canvas2d", tokens })
|
|
63
|
+
const id = avis.createNode({
|
|
64
|
+
className: "flex flex-col gap-2 p-4 bg-card rounded-lg text-foreground",
|
|
65
|
+
text: "Hello AVIS",
|
|
66
|
+
position: { x: 80, y: 80 },
|
|
67
|
+
size: { width: 240, height: 120 },
|
|
68
|
+
})
|
|
69
|
+
avis.selection.select([id])
|
|
70
|
+
// Dispose when the editor unmounts:
|
|
71
|
+
// avis.dispose()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Give the container an explicit height. Pass your theme's CSS token sources to
|
|
75
|
+
enable styled content (the example includes minimal tokens). Styled nodes use the engine's supported
|
|
76
|
+
class subset; they do not implement the browser's full CSS layout engine.
|
|
77
|
+
|
|
78
|
+
## React
|
|
79
|
+
|
|
80
|
+
Install both optional peers when using either React adapter:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm install react@^19 react-dom@^19
|
|
84
|
+
npm install -D @types/react@^19 @types/react-dom@^19
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
React 19 is the supported peer major; the package verification records the exact
|
|
88
|
+
versions tested. Optional peers let vanilla projects install without React.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { AvisCanvas, Frame, Text } from "@avis-studio/engine/react"
|
|
92
|
+
import { tokens } from "./theme.js"
|
|
93
|
+
|
|
94
|
+
export function Editor() {
|
|
95
|
+
return (
|
|
96
|
+
<AvisCanvas style={{ height: 480 }} options={{ tokens }}>
|
|
97
|
+
<Frame className="p-4 bg-card rounded-lg text-foreground" position={{ x: 80, y: 80 }} size={{ width: 240, height: 120 }}>
|
|
98
|
+
<Text className="text-lg">Hello AVIS</Text>
|
|
99
|
+
</Frame>
|
|
100
|
+
</AvisCanvas>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For Flow:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { ReactFlow, Background, Controls } from "@avis-studio/engine/react/flow"
|
|
109
|
+
import "@avis-studio/engine/react/flow/style.css"
|
|
110
|
+
|
|
111
|
+
export function FlowEditor() {
|
|
112
|
+
return (
|
|
113
|
+
<div style={{ height: 480 }}>
|
|
114
|
+
<ReactFlow defaultNodes={[{ id: "hello", position: { x: 80, y: 80 }, data: { label: "Hello AVIS" } }]}>
|
|
115
|
+
<Background />
|
|
116
|
+
<Controls />
|
|
117
|
+
</ReactFlow>
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The Flow entry is an implementation of the familiar API, **not a promise of full
|
|
124
|
+
behavioral parity**. Audited reconnection, viewport, resize and dataflow cases
|
|
125
|
+
have regression coverage; full prop/default combinations and some popup/painter behavior
|
|
126
|
+
remain outside that evidence. The app's custom media nodes, UI kit, registry
|
|
127
|
+
and CLI are not included in this package.
|
|
128
|
+
|
|
129
|
+
## Connect a backend
|
|
130
|
+
|
|
131
|
+
The host supplies transport, authentication, schema validation and revision/conflict
|
|
132
|
+
policy. The SDK never embeds AVIS credentials or calls generation APIs.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { createSaveQueue } from "@avis-studio/engine/sync"
|
|
136
|
+
import type { ReactFlowJsonObject } from "@avis-studio/engine/react/flow"
|
|
137
|
+
|
|
138
|
+
export function autosave(save: (graph: ReactFlowJsonObject) => Promise<void>) {
|
|
139
|
+
return createSaveQueue({ save, debounceMs: 800 })
|
|
140
|
+
}
|
|
141
|
+
// After a graph edit: queue.enqueue({ nodes, edges, viewport }).
|
|
142
|
+
// Before leaving the route: await queue.flush().
|
|
143
|
+
// On failure: queue.getSnapshot().pending retains the latest value; flush retries.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Writes run one at a time. An old acknowledgement cannot clear a newer edit.
|
|
147
|
+
`subscribe` / `getSnapshot` work with React's `useSyncExternalStore` or plain JS.
|
|
148
|
+
`pause(error)` retains a draft without sending it; `resume()` schedules it again.
|
|
149
|
+
`dispose()` cancels scheduled work/subscriptions and ignores a late acknowledgement;
|
|
150
|
+
it cannot reverse a server commit. Enqueued values must be treated as immutable.
|
|
151
|
+
The queue holds drafts in memory only: it does not promise recovery after a browser crash.
|
|
152
|
+
Before disposing, let the host retain/export pending data or obtain an explicit discard.
|
|
153
|
+
|
|
154
|
+
The AVIS prototype now uses this queue and the **compiled package** through its
|
|
155
|
+
local file dependency. `npm install` and the normal dev/build/typecheck/test
|
|
156
|
+
commands build the SDK automatically. Tracked kernel assets allow a clean checkout
|
|
157
|
+
to build without Rust. Rust/wasm-pack are needed only to regenerate kernels with
|
|
158
|
+
`npm run engine:wasm`; source/asset digests detect stale prebuilts.
|
|
159
|
+
|
|
160
|
+
## WASM
|
|
161
|
+
|
|
162
|
+
Prebuilt glue and kernels ship with the package; consumers do not need Rust.
|
|
163
|
+
`createAvis` loads them by default. `loadKernels()` reports `source: "wasm"` when
|
|
164
|
+
loading succeeds and falls back to `"reference"` otherwise. Bundlers must serve
|
|
165
|
+
the `.wasm` asset resolved relative to the included glue module; Vite production
|
|
166
|
+
consumers are covered by the package smoke check.
|
|
167
|
+
|
|
168
|
+
## Build and verify (inside the AVIS repository)
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
npm run engine:pack
|
|
172
|
+
npm run engine:pack:check
|
|
173
|
+
npm run engine:pack:browser
|
|
174
|
+
npm run engine:release:check
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The tarball and its file manifest go into ignored `packages/avis-engine/release/`.
|
|
178
|
+
`prepack` rebuilds and checks output on direct `npm pack` too. The verification
|
|
179
|
+
installs the tarball into separate vanilla and React projects, checks types and
|
|
180
|
+
builds production browser bundles without repository aliases.
|
|
181
|
+
|
|
182
|
+
`engine:pack:browser` also starts production previews on ports 5481/5482, runs
|
|
183
|
+
Chrome smoke checks at 1440×900 and closes those previews. It requires Python
|
|
184
|
+
Playwright and Chrome. Set `AVIS_ENGINE_PYTHON=/path/to/python` if needed.
|
|
185
|
+
It also checks reconnect, resize, viewport, touch and keyboard behavior on an
|
|
186
|
+
installed Flow consumer. Logs/screenshots stay in temporary directories;
|
|
187
|
+
`AVIS_ENGINE_CHECK_OUTPUT` selects a directory outside the repository.
|
|
188
|
+
`engine:release:check` runs both-app types, unit tests, local SQL tests, lint and
|
|
189
|
+
the package/browser checks; `release/verification.json` records results and
|
|
190
|
+
the verified tarball integrity. It never publishes or deploys anything.
|
|
191
|
+
|
|
192
|
+
Publication, licensing for AVIS-owned code and removal of the private guard are
|
|
193
|
+
separate release decisions. Existing third-party MIT notices are included in
|
|
194
|
+
`THIRD_PARTY_NOTICES.md` and the ported API's `LICENSE` file.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
AVIS Engine includes algorithms, React Flow compatibility code, declarations
|
|
4
|
+
and stylesheet derived from @xyflow/system and @xyflow/react 12.12.0.
|
|
5
|
+
Source: https://github.com/xyflow/xyflow
|
|
6
|
+
|
|
7
|
+
The notices below cover these portions; they do not license the whole AVIS Engine.
|
|
8
|
+
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2019-2025 webkid GmbH
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Disposable } from "../core/disposable.js";
|
|
2
|
+
import type { Engine } from "../core/engine.js";
|
|
3
|
+
import { EventBus } from "../core/event-bus.js";
|
|
4
|
+
import type { Plugin } from "../core/plugin.js";
|
|
5
|
+
import { type KeyInput } from "../interaction/controller.js";
|
|
6
|
+
import { SemanticRegistry } from "./semantics.js";
|
|
7
|
+
export type FocusDirection = "left" | "right" | "up" | "down";
|
|
8
|
+
export type FocusEvents = {
|
|
9
|
+
/** Focus moved (null: left the canvas's nodes). */
|
|
10
|
+
focus: {
|
|
11
|
+
id: string | null;
|
|
12
|
+
source: "keyboard" | "pointer" | "program";
|
|
13
|
+
};
|
|
14
|
+
/** Edit the node's text (the DOM text field opens). */
|
|
15
|
+
edit: {
|
|
16
|
+
id: string;
|
|
17
|
+
prop: string;
|
|
18
|
+
};
|
|
19
|
+
/** Go into the node's controls (the DOM layer focuses the first). */
|
|
20
|
+
enter: {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
/** Focus should leave the canvas (Tab past the last node). */
|
|
24
|
+
exit: {
|
|
25
|
+
direction: "forward" | "backward";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type FocusScope = {
|
|
29
|
+
id: string;
|
|
30
|
+
restore: string | null;
|
|
31
|
+
};
|
|
32
|
+
export type FocusManager = {
|
|
33
|
+
readonly events: EventBus<FocusEvents>;
|
|
34
|
+
readonly semantics: SemanticRegistry;
|
|
35
|
+
current(): string | null;
|
|
36
|
+
focus(id: string | null, options?: {
|
|
37
|
+
source?: FocusEvents["focus"]["source"];
|
|
38
|
+
reveal?: boolean;
|
|
39
|
+
}): void;
|
|
40
|
+
/** Nodes in reading order (visible ones). */
|
|
41
|
+
order(): string[];
|
|
42
|
+
next(): string | null;
|
|
43
|
+
previous(): string | null;
|
|
44
|
+
/** The nearest node in a direction from the focused one. */
|
|
45
|
+
move(direction: FocusDirection): string | null;
|
|
46
|
+
/** Brings a node into view with a margin (screen px). */
|
|
47
|
+
reveal(id: string, margin?: number): void;
|
|
48
|
+
announce(message: string): void;
|
|
49
|
+
pushScope(id: string): FocusScope;
|
|
50
|
+
popScope(id: string): void;
|
|
51
|
+
handleKey(input: KeyInput): boolean;
|
|
52
|
+
};
|
|
53
|
+
export declare const FocusKey: import("../index.js").ServiceKey<FocusManager>;
|
|
54
|
+
export declare function createFocusManager(engine: Engine, semantics?: SemanticRegistry): FocusManager & Disposable;
|
|
55
|
+
/**
|
|
56
|
+
* Focus as an engine service. With the interaction plugin, its keys run
|
|
57
|
+
* before the built-in keyboard behaviour; selection changes and deletions
|
|
58
|
+
* are announced; a tap focuses the node (React Flow focuses a clicked node).
|
|
59
|
+
*/
|
|
60
|
+
export declare function a11yPlugin(semantics?: SemanticRegistry): Plugin<Engine>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { EventBus } from "../core/event-bus.js";
|
|
2
|
+
import { serviceKey } from "../core/services.js";
|
|
3
|
+
import { InteractionKey } from "../interaction/controller.js";
|
|
4
|
+
import { SemanticRegistry } from "./semantics.js";
|
|
5
|
+
export const FocusKey = serviceKey("focus");
|
|
6
|
+
export function createFocusManager(engine, semantics = new SemanticRegistry()) {
|
|
7
|
+
const events = new EventBus();
|
|
8
|
+
const scopes = [];
|
|
9
|
+
const current = () => engine.store.get().a11y.logicalFocusId;
|
|
10
|
+
const hidden = (id) => {
|
|
11
|
+
let node = engine.scene.get(id);
|
|
12
|
+
while (node) {
|
|
13
|
+
if (!node.record.visible)
|
|
14
|
+
return true;
|
|
15
|
+
node = node.parent ?? undefined;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
const order = () => [...engine.scene.walk()].map((node) => node.id).filter((id) => !hidden(id) && semantics.describe(engine, id));
|
|
20
|
+
const reveal = (id, margin = 48) => {
|
|
21
|
+
const node = engine.scene.get(id);
|
|
22
|
+
const { size, camera } = engine.store.get().viewport;
|
|
23
|
+
if (!node || !size.width)
|
|
24
|
+
return;
|
|
25
|
+
const b = node.worldBounds;
|
|
26
|
+
const min = engine.viewport.toScreen({ x: b.minX, y: b.minY });
|
|
27
|
+
const max = engine.viewport.toScreen({ x: b.maxX, y: b.maxY });
|
|
28
|
+
let dx = 0;
|
|
29
|
+
let dy = 0;
|
|
30
|
+
if (max.x - min.x > size.width - 2 * margin)
|
|
31
|
+
dx = size.width / 2 - (min.x + max.x) / 2;
|
|
32
|
+
else if (min.x < margin)
|
|
33
|
+
dx = margin - min.x;
|
|
34
|
+
else if (max.x > size.width - margin)
|
|
35
|
+
dx = size.width - margin - max.x;
|
|
36
|
+
if (max.y - min.y > size.height - 2 * margin)
|
|
37
|
+
dy = size.height / 2 - (min.y + max.y) / 2;
|
|
38
|
+
else if (min.y < margin)
|
|
39
|
+
dy = margin - min.y;
|
|
40
|
+
else if (max.y > size.height - margin)
|
|
41
|
+
dy = size.height - margin - max.y;
|
|
42
|
+
if (dx || dy)
|
|
43
|
+
engine.viewport.setCamera({ x: camera.x + dx, y: camera.y + dy });
|
|
44
|
+
};
|
|
45
|
+
const focus = (id, options = {}) => {
|
|
46
|
+
const source = options.source ?? "program";
|
|
47
|
+
if (id && !engine.store.get().document.nodes[id])
|
|
48
|
+
return;
|
|
49
|
+
if (current() !== id)
|
|
50
|
+
engine.store.set("a11y", { logicalFocusId: id });
|
|
51
|
+
if (id && (options.reveal ?? source === "keyboard"))
|
|
52
|
+
reveal(id);
|
|
53
|
+
events.emit("focus", { id, source });
|
|
54
|
+
};
|
|
55
|
+
const step = (delta) => {
|
|
56
|
+
const ids = order();
|
|
57
|
+
if (!ids.length)
|
|
58
|
+
return null;
|
|
59
|
+
const at = current() ? ids.indexOf(current()) : -1;
|
|
60
|
+
const next = at < 0 ? (delta > 0 ? 0 : ids.length - 1) : at + delta;
|
|
61
|
+
if (next < 0 || next >= ids.length) {
|
|
62
|
+
events.emit("exit", { direction: delta > 0 ? "forward" : "backward" });
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
focus(ids[next], { source: "keyboard" });
|
|
66
|
+
return ids[next];
|
|
67
|
+
};
|
|
68
|
+
const move = (direction) => {
|
|
69
|
+
const from = current() ? engine.scene.get(current()) : null;
|
|
70
|
+
if (!from)
|
|
71
|
+
return step(1);
|
|
72
|
+
const centre = (b) => ({
|
|
73
|
+
x: (b.minX + b.maxX) / 2,
|
|
74
|
+
y: (b.minY + b.maxY) / 2,
|
|
75
|
+
});
|
|
76
|
+
const s = from.worldBounds;
|
|
77
|
+
const start = centre(s);
|
|
78
|
+
let best = null;
|
|
79
|
+
let fallback = null;
|
|
80
|
+
// Its own frames and children aren't neighbours.
|
|
81
|
+
const related = new Set([from.id, ...[...engine.scene.ancestors(from.id)].map((n) => n.id)]);
|
|
82
|
+
const inside = (id) => [...engine.scene.ancestors(id)].some((n) => n.id === from.id);
|
|
83
|
+
const gap = (a0, a1, b0, b1) => Math.max(0, b0 - a1, a0 - b1);
|
|
84
|
+
for (const id of order()) {
|
|
85
|
+
if (related.has(id) || inside(id))
|
|
86
|
+
continue;
|
|
87
|
+
const c = engine.scene.get(id).worldBounds;
|
|
88
|
+
// Past the edge in that direction, as the browser's spatial navigation.
|
|
89
|
+
const along = direction === "right" ? c.minX - s.maxX : direction === "left" ? s.minX - c.maxX : direction === "down" ? c.minY - s.maxY : s.minY - c.maxY;
|
|
90
|
+
const across = direction === "left" || direction === "right" ? gap(s.minY, s.maxY, c.minY, c.maxY) : gap(s.minX, s.maxX, c.minX, c.maxX);
|
|
91
|
+
if (along >= -1) {
|
|
92
|
+
const score = Math.max(0, along) + across * 2;
|
|
93
|
+
if (!best || score < best.score)
|
|
94
|
+
best = { id, score };
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// Overlapping boxes: by centres, when nothing lies fully past the edge.
|
|
98
|
+
const m = centre(c);
|
|
99
|
+
const ahead = direction === "right" ? m.x - start.x : direction === "left" ? start.x - m.x : direction === "down" ? m.y - start.y : start.y - m.y;
|
|
100
|
+
if (ahead <= 0)
|
|
101
|
+
continue;
|
|
102
|
+
const side = direction === "left" || direction === "right" ? Math.abs(m.y - start.y) : Math.abs(m.x - start.x);
|
|
103
|
+
const score = ahead + side * 2;
|
|
104
|
+
if (!fallback || score < fallback.score)
|
|
105
|
+
fallback = { id, score };
|
|
106
|
+
}
|
|
107
|
+
best ??= fallback;
|
|
108
|
+
if (best)
|
|
109
|
+
focus(best.id, { source: "keyboard" });
|
|
110
|
+
return best?.id ?? null;
|
|
111
|
+
};
|
|
112
|
+
const announce = (message) => {
|
|
113
|
+
const list = engine.store.get().a11y.announcements;
|
|
114
|
+
engine.store.set("a11y", { announcements: [...list.slice(-4), message] });
|
|
115
|
+
};
|
|
116
|
+
const manager = {
|
|
117
|
+
events,
|
|
118
|
+
semantics,
|
|
119
|
+
current,
|
|
120
|
+
focus,
|
|
121
|
+
order,
|
|
122
|
+
next: () => step(1),
|
|
123
|
+
previous: () => step(-1),
|
|
124
|
+
move,
|
|
125
|
+
reveal,
|
|
126
|
+
announce,
|
|
127
|
+
pushScope(id) {
|
|
128
|
+
const scope = { id, restore: current() };
|
|
129
|
+
scopes.push(scope);
|
|
130
|
+
return scope;
|
|
131
|
+
},
|
|
132
|
+
popScope(id) {
|
|
133
|
+
const index = scopes.findIndex((scope) => scope.id === id);
|
|
134
|
+
if (index < 0)
|
|
135
|
+
return;
|
|
136
|
+
const [scope] = scopes.splice(index, 1);
|
|
137
|
+
if (scope.restore && engine.store.get().document.nodes[scope.restore])
|
|
138
|
+
focus(scope.restore);
|
|
139
|
+
},
|
|
140
|
+
handleKey(input) {
|
|
141
|
+
if (input.typing)
|
|
142
|
+
return false;
|
|
143
|
+
const id = current();
|
|
144
|
+
if (input.key === "Tab" && !input.metaKey && !input.ctrlKey && !input.altKey) {
|
|
145
|
+
return (input.shiftKey ? step(-1) : step(1)) !== null;
|
|
146
|
+
}
|
|
147
|
+
if (input.altKey && input.key.startsWith("Arrow")) {
|
|
148
|
+
const direction = input.key.slice(5).toLowerCase();
|
|
149
|
+
return move(direction) !== null;
|
|
150
|
+
}
|
|
151
|
+
if (!id)
|
|
152
|
+
return false;
|
|
153
|
+
const described = semantics.describe(engine, id);
|
|
154
|
+
if (input.key === "F2" || (input.key === "Enter" && described?.selected && described.editable)) {
|
|
155
|
+
if (!described?.editable)
|
|
156
|
+
return false;
|
|
157
|
+
events.emit("edit", { id, prop: described.editable.prop });
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (input.key === "Enter" || input.key === " ") {
|
|
161
|
+
// React Flow: Enter or Space selects the focused node.
|
|
162
|
+
const { selectedIds } = engine.store.get().interaction;
|
|
163
|
+
const multi = input.metaKey || input.ctrlKey;
|
|
164
|
+
if (!selectedIds.includes(id)) {
|
|
165
|
+
engine.store.set("interaction", {
|
|
166
|
+
selectedIds: multi ? [...selectedIds, id] : [id],
|
|
167
|
+
...(multi ? {} : { selectedRelationIds: [] }),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (input.key === "Enter") {
|
|
171
|
+
events.emit("enter", { id });
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
},
|
|
177
|
+
dispose() {
|
|
178
|
+
events.clear();
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
return manager;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Focus as an engine service. With the interaction plugin, its keys run
|
|
185
|
+
* before the built-in keyboard behaviour; selection changes and deletions
|
|
186
|
+
* are announced; a tap focuses the node (React Flow focuses a clicked node).
|
|
187
|
+
*/
|
|
188
|
+
export function a11yPlugin(semantics) {
|
|
189
|
+
return {
|
|
190
|
+
name: "a11y",
|
|
191
|
+
dependsOn: ["interaction"],
|
|
192
|
+
setup({ engine, track }) {
|
|
193
|
+
const manager = track(createFocusManager(engine, semantics));
|
|
194
|
+
track(engine.services.register(FocusKey, manager));
|
|
195
|
+
const controller = engine.services.get(InteractionKey);
|
|
196
|
+
track(controller.prependKeyHandler((input) => manager.handleKey(input)));
|
|
197
|
+
track(controller.events.on("node:tap", ({ id }) => manager.focus(id, { source: "pointer" })));
|
|
198
|
+
track(controller.events.on("pane:tap", () => manager.focus(null, { source: "pointer" })));
|
|
199
|
+
track(controller.events.on("node:doubletap", ({ id }) => {
|
|
200
|
+
const editable = manager.semantics.describe(engine, id)?.editable;
|
|
201
|
+
if (editable)
|
|
202
|
+
manager.events.emit("edit", { id, prop: editable.prop });
|
|
203
|
+
}));
|
|
204
|
+
// Announcements: the selection, and a focused node that went away.
|
|
205
|
+
track(engine.store.subscribe((state) => state.interaction.selectedIds, (ids, previous) => {
|
|
206
|
+
if (ids.length === previous.length && ids.every((id, i) => id === previous[i]))
|
|
207
|
+
return;
|
|
208
|
+
if (ids.length === 1)
|
|
209
|
+
manager.announce(`Selected ${manager.semantics.describe(engine, ids[0])?.name ?? "1 node"}`);
|
|
210
|
+
else if (ids.length > 1)
|
|
211
|
+
manager.announce(`Selected ${ids.length} nodes`);
|
|
212
|
+
else if (previous.length)
|
|
213
|
+
manager.announce("Selection cleared");
|
|
214
|
+
}));
|
|
215
|
+
track(engine.store.subscribe((state) => state.document.nodes, (nodes) => {
|
|
216
|
+
const id = manager.current();
|
|
217
|
+
if (id && !nodes[id])
|
|
218
|
+
manager.focus(null);
|
|
219
|
+
}));
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Disposable } from "../core/disposable.js";
|
|
2
|
+
import type { Engine } from "../core/engine.js";
|
|
3
|
+
import type { NodeRecord } from "../scene/record.js";
|
|
4
|
+
import type { UIElement } from "../render/ui.js";
|
|
5
|
+
export type Semantics = {
|
|
6
|
+
role: string;
|
|
7
|
+
roleDescription?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Text a user can edit in place (F2 or Enter, or a double click). */
|
|
13
|
+
editable?: {
|
|
14
|
+
prop: string;
|
|
15
|
+
} | null;
|
|
16
|
+
};
|
|
17
|
+
/** Controls inside a styled node (elements with a role). */
|
|
18
|
+
export type ControlSemantics = {
|
|
19
|
+
path: number[];
|
|
20
|
+
role: string;
|
|
21
|
+
name: string;
|
|
22
|
+
action?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type SemanticsResolver = (record: NodeRecord, engine: Engine) => Partial<Semantics> | null;
|
|
26
|
+
/** The text of a styled element tree, in reading order. */
|
|
27
|
+
export declare function elementText(element: UIElement | undefined): string;
|
|
28
|
+
/** Controls (elements with a role) of a styled node, with their tree paths. */
|
|
29
|
+
export declare function controlsOf(record: NodeRecord): ControlSemantics[];
|
|
30
|
+
export declare class SemanticRegistry {
|
|
31
|
+
private resolvers;
|
|
32
|
+
register(type: string, resolver: SemanticsResolver): Disposable;
|
|
33
|
+
/** A node's semantics; null when it has none (it is skipped). */
|
|
34
|
+
describe(engine: Engine, id: string): Semantics | null;
|
|
35
|
+
/** A relation's name: React Flow's "Edge from A to B". */
|
|
36
|
+
describeRelation(engine: Engine, id: string): Semantics | null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const text = (value) => (typeof value === "string" ? value.trim() : "");
|
|
2
|
+
/** The text of a styled element tree, in reading order. */
|
|
3
|
+
export function elementText(element) {
|
|
4
|
+
if (!element)
|
|
5
|
+
return "";
|
|
6
|
+
if (element.ariaLabel)
|
|
7
|
+
return element.ariaLabel;
|
|
8
|
+
return [element.text ?? "", ...(element.children ?? []).map(elementText)].filter(Boolean).join(" ").trim();
|
|
9
|
+
}
|
|
10
|
+
/** Controls (elements with a role) of a styled node, with their tree paths. */
|
|
11
|
+
export function controlsOf(record) {
|
|
12
|
+
const root = record.props.root;
|
|
13
|
+
const out = [];
|
|
14
|
+
const visit = (element, path) => {
|
|
15
|
+
if (element.role && path.length) {
|
|
16
|
+
out.push({ path, role: element.role, name: elementText(element), action: element.action, disabled: element.disabled });
|
|
17
|
+
}
|
|
18
|
+
element.children?.forEach((child, i) => visit(child, [...path, i]));
|
|
19
|
+
};
|
|
20
|
+
if (root)
|
|
21
|
+
visit(root, []);
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
const DEFAULTS = {
|
|
25
|
+
text: (record) => ({ name: text(record.props.text) || "Empty text", editable: { prop: "text" } }),
|
|
26
|
+
image: (record) => ({ role: "img", roleDescription: undefined, name: text(record.props.alt) || "Image" }),
|
|
27
|
+
frame: (record) => ({ roleDescription: "group", name: text(record.props.title) || "Group" }),
|
|
28
|
+
ui: (record) => {
|
|
29
|
+
const root = record.props.root;
|
|
30
|
+
// The first line of text names it (a title), the rest describes it.
|
|
31
|
+
const first = root?.ariaLabel ?? firstText(root);
|
|
32
|
+
return { name: first || "Card", description: elementText(root) };
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
function firstText(element) {
|
|
36
|
+
if (!element)
|
|
37
|
+
return "";
|
|
38
|
+
if (element.text)
|
|
39
|
+
return element.text;
|
|
40
|
+
for (const child of element.children ?? []) {
|
|
41
|
+
const found = firstText(child);
|
|
42
|
+
if (found)
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
export class SemanticRegistry {
|
|
48
|
+
resolvers = new Map(Object.entries(DEFAULTS));
|
|
49
|
+
register(type, resolver) {
|
|
50
|
+
this.resolvers.set(type, resolver);
|
|
51
|
+
return { dispose: () => void (this.resolvers.get(type) === resolver && this.resolvers.delete(type)) };
|
|
52
|
+
}
|
|
53
|
+
/** A node's semantics; null when it has none (it is skipped). */
|
|
54
|
+
describe(engine, id) {
|
|
55
|
+
const record = engine.store.get().document.nodes[id];
|
|
56
|
+
if (!record)
|
|
57
|
+
return null;
|
|
58
|
+
const own = this.resolvers.get(record.type)?.(record, engine);
|
|
59
|
+
if (own === null)
|
|
60
|
+
return null;
|
|
61
|
+
const { props } = record;
|
|
62
|
+
const name = text(props.title) || text(props.label) || text(props.name) || `${record.type} node`;
|
|
63
|
+
const { interaction, style } = engine.store.get();
|
|
64
|
+
return {
|
|
65
|
+
role: "group",
|
|
66
|
+
roleDescription: "node",
|
|
67
|
+
name,
|
|
68
|
+
selected: interaction.selectedIds.includes(id),
|
|
69
|
+
disabled: style.nodeStates[id]?.includes("disabled") ?? false,
|
|
70
|
+
editable: null,
|
|
71
|
+
...own,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** A relation's name: React Flow's "Edge from A to B". */
|
|
75
|
+
describeRelation(engine, id) {
|
|
76
|
+
const relation = engine.store.get().document.relations[id];
|
|
77
|
+
if (!relation)
|
|
78
|
+
return null;
|
|
79
|
+
const source = this.describe(engine, relation.source.nodeId)?.name ?? relation.source.nodeId;
|
|
80
|
+
const target = this.describe(engine, relation.target.nodeId)?.name ?? relation.target.nodeId;
|
|
81
|
+
return {
|
|
82
|
+
role: "group",
|
|
83
|
+
roleDescription: "edge",
|
|
84
|
+
name: `Edge from ${source} to ${target}`,
|
|
85
|
+
selected: engine.store.get().interaction.selectedRelationIds.includes(id),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|