@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,32 @@
|
|
|
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
|
+
export type AccessibilityLayerOptions = {
|
|
5
|
+
/** A positioned element holding the canvas; the layer fills it. */
|
|
6
|
+
root: HTMLElement;
|
|
7
|
+
/** The canvas element (it keeps its own tab stop for canvas shortcuts). */
|
|
8
|
+
canvas: HTMLElement;
|
|
9
|
+
/** The canvas's accessible name. */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** Read by screen readers on each node (React Flow's default, plus ours). */
|
|
12
|
+
instructions?: string;
|
|
13
|
+
/** Nodes smaller than this on screen (px) aren't mounted, unless focused or selected. */
|
|
14
|
+
minScreenSize?: number;
|
|
15
|
+
};
|
|
16
|
+
export type AccessibilityLayerEvents = {
|
|
17
|
+
/** A control inside a styled node was activated (click, Enter or Space). */
|
|
18
|
+
"control:activate": {
|
|
19
|
+
nodeId: string;
|
|
20
|
+
action: string | undefined;
|
|
21
|
+
path: number[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type AccessibilityLayer = Disposable & {
|
|
25
|
+
readonly element: HTMLElement;
|
|
26
|
+
readonly events: EventBus<AccessibilityLayerEvents>;
|
|
27
|
+
/** The element standing for a node (mounted on demand). */
|
|
28
|
+
elementFor(id: string): HTMLElement | null;
|
|
29
|
+
/** Brings the layer up to date now (it also follows every change). */
|
|
30
|
+
update(): void;
|
|
31
|
+
};
|
|
32
|
+
export declare function attachAccessibilityLayer(engine: Engine, options: AccessibilityLayerOptions): AccessibilityLayer;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { EventBus } from "../core/event-bus.js";
|
|
2
|
+
import { intersects } from "../geometry/bounds.js";
|
|
3
|
+
import { screenToWorld } from "../geometry/spaces.js";
|
|
4
|
+
import { controlsOf } from "../a11y/semantics.js";
|
|
5
|
+
import { FocusKey } from "../a11y/focus.js";
|
|
6
|
+
import { InteractionKey } from "../interaction/controller.js";
|
|
7
|
+
import { layoutUI } from "../render/ui.js";
|
|
8
|
+
import { createTextMeasurer } from "../render/text.js";
|
|
9
|
+
import { StyleKey } from "../style/style-engine.js";
|
|
10
|
+
import { cameraCss, matrixCss } from "./anchor.js";
|
|
11
|
+
const SR_ONLY = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";
|
|
12
|
+
let layers = 0;
|
|
13
|
+
const isTextInput = (target) => {
|
|
14
|
+
const el = target;
|
|
15
|
+
return Boolean(el && (el.isContentEditable || el.tagName === "INPUT" || el.tagName === "TEXTAREA"));
|
|
16
|
+
};
|
|
17
|
+
export function attachAccessibilityLayer(engine, options) {
|
|
18
|
+
const doc = options.root.ownerDocument;
|
|
19
|
+
const focus = engine.services.get(FocusKey);
|
|
20
|
+
const controller = engine.services.has(InteractionKey) ? engine.services.get(InteractionKey) : null;
|
|
21
|
+
const style = engine.services.has(StyleKey) ? engine.services.get(StyleKey) : null;
|
|
22
|
+
const measure = createTextMeasurer();
|
|
23
|
+
const events = new EventBus();
|
|
24
|
+
const uid = `avis-a11y-${++layers}`;
|
|
25
|
+
const cleanups = [];
|
|
26
|
+
const layer = doc.createElement("div");
|
|
27
|
+
layer.dataset.avisA11y = "";
|
|
28
|
+
layer.setAttribute("role", "application");
|
|
29
|
+
layer.setAttribute("aria-roledescription", "canvas");
|
|
30
|
+
layer.setAttribute("aria-label", options.label ?? "Canvas");
|
|
31
|
+
layer.style.cssText = "position:absolute;inset:0;overflow:hidden;pointer-events:none";
|
|
32
|
+
const world = doc.createElement("div");
|
|
33
|
+
world.style.cssText = "position:absolute;left:0;top:0;transform-origin:0 0";
|
|
34
|
+
const description = doc.createElement("div");
|
|
35
|
+
description.id = `${uid}-desc`;
|
|
36
|
+
description.style.display = "none";
|
|
37
|
+
description.textContent =
|
|
38
|
+
options.instructions ??
|
|
39
|
+
"Press enter or space to select a node. Press delete to remove it and escape to cancel. Press tab to move between nodes, alt and an arrow key to go to the nearest node, F2 to edit text.";
|
|
40
|
+
const edges = doc.createElement("div");
|
|
41
|
+
edges.setAttribute("role", "list");
|
|
42
|
+
edges.setAttribute("aria-label", "Edges");
|
|
43
|
+
edges.style.cssText = SR_ONLY;
|
|
44
|
+
const live = doc.createElement("div");
|
|
45
|
+
live.setAttribute("aria-live", "polite");
|
|
46
|
+
live.setAttribute("aria-atomic", "true");
|
|
47
|
+
live.style.cssText = SR_ONLY;
|
|
48
|
+
layer.append(world, edges, description, live);
|
|
49
|
+
options.root.append(layer);
|
|
50
|
+
cleanups.push(() => layer.remove());
|
|
51
|
+
const mounted = new Map();
|
|
52
|
+
let scope = null;
|
|
53
|
+
const keyInput = (event) => ({
|
|
54
|
+
key: event.key,
|
|
55
|
+
metaKey: event.metaKey,
|
|
56
|
+
ctrlKey: event.ctrlKey,
|
|
57
|
+
shiftKey: event.shiftKey,
|
|
58
|
+
altKey: event.altKey,
|
|
59
|
+
typing: isTextInput(event.target),
|
|
60
|
+
});
|
|
61
|
+
const controlElements = (id) => [...(mounted.get(id)?.querySelectorAll("[data-avis-control]") ?? [])].filter((el) => el.getAttribute("aria-disabled") !== "true");
|
|
62
|
+
const leaveScope = () => {
|
|
63
|
+
if (!scope)
|
|
64
|
+
return;
|
|
65
|
+
const id = scope;
|
|
66
|
+
scope = null;
|
|
67
|
+
for (const el of mounted.get(id)?.querySelectorAll("[data-avis-control]") ?? [])
|
|
68
|
+
el.tabIndex = -1;
|
|
69
|
+
focus.popScope(id);
|
|
70
|
+
mounted.get(id)?.focus({ preventScroll: true });
|
|
71
|
+
};
|
|
72
|
+
const enterScope = (id) => {
|
|
73
|
+
const controls = controlElements(id);
|
|
74
|
+
if (!controls.length)
|
|
75
|
+
return;
|
|
76
|
+
scope = id;
|
|
77
|
+
focus.pushScope(id);
|
|
78
|
+
for (const el of controls)
|
|
79
|
+
el.tabIndex = 0;
|
|
80
|
+
controls[0].focus({ preventScroll: true });
|
|
81
|
+
};
|
|
82
|
+
const onNodeKey = (event) => {
|
|
83
|
+
if (event.isComposing)
|
|
84
|
+
return;
|
|
85
|
+
const handled = controller ? controller.keyDown(keyInput(event)) : focus.handleKey(keyInput(event));
|
|
86
|
+
if (handled)
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
};
|
|
89
|
+
const onControlKey = (id) => (event) => {
|
|
90
|
+
const controls = controlElements(id);
|
|
91
|
+
const at = controls.indexOf(event.target);
|
|
92
|
+
if (event.key === "Escape") {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
leaveScope();
|
|
96
|
+
}
|
|
97
|
+
else if (event.key === "Tab" && controls.length) {
|
|
98
|
+
// A focus trap inside the node's controls (Base UI composite).
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
controls[(at + (event.shiftKey ? -1 : 1) + controls.length) % controls.length].focus({ preventScroll: true });
|
|
102
|
+
}
|
|
103
|
+
else if (event.key === "Enter" || event.key === " ") {
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/** Creates or refreshes a node's element. */
|
|
108
|
+
const mount = (id) => {
|
|
109
|
+
const node = engine.scene.get(id);
|
|
110
|
+
const semantics = focus.semantics.describe(engine, id);
|
|
111
|
+
if (!node || !semantics)
|
|
112
|
+
return null;
|
|
113
|
+
let el = mounted.get(id);
|
|
114
|
+
if (!el) {
|
|
115
|
+
el = doc.createElement("div");
|
|
116
|
+
el.dataset.id = id;
|
|
117
|
+
el.style.cssText = "position:absolute;left:0;top:0;transform-origin:0 0;outline-offset:2px";
|
|
118
|
+
el.setAttribute("aria-describedby", description.id);
|
|
119
|
+
el.addEventListener("keydown", onNodeKey);
|
|
120
|
+
el.addEventListener("focus", () => {
|
|
121
|
+
if (focus.current() !== id)
|
|
122
|
+
focus.focus(id, { source: "keyboard" });
|
|
123
|
+
});
|
|
124
|
+
// A screen reader's click selects the node.
|
|
125
|
+
el.addEventListener("click", (event) => {
|
|
126
|
+
if (event.target !== el)
|
|
127
|
+
return;
|
|
128
|
+
engine.store.set("interaction", { selectedIds: [id], selectedRelationIds: [] });
|
|
129
|
+
});
|
|
130
|
+
mounted.set(id, el);
|
|
131
|
+
world.append(el);
|
|
132
|
+
}
|
|
133
|
+
const size = engine.scene.sizeOf(node);
|
|
134
|
+
el.style.width = `${size.w}px`;
|
|
135
|
+
el.style.height = `${size.h}px`;
|
|
136
|
+
el.style.transform = matrixCss(node.world);
|
|
137
|
+
el.setAttribute("role", semantics.role);
|
|
138
|
+
if (semantics.roleDescription)
|
|
139
|
+
el.setAttribute("aria-roledescription", semantics.roleDescription);
|
|
140
|
+
else
|
|
141
|
+
el.removeAttribute("aria-roledescription");
|
|
142
|
+
el.setAttribute("aria-label", semantics.selected ? `${semantics.name}, selected` : semantics.name);
|
|
143
|
+
if (semantics.description && semantics.description !== semantics.name) {
|
|
144
|
+
el.setAttribute("aria-description", semantics.description);
|
|
145
|
+
}
|
|
146
|
+
if (semantics.disabled)
|
|
147
|
+
el.setAttribute("aria-disabled", "true");
|
|
148
|
+
else
|
|
149
|
+
el.removeAttribute("aria-disabled");
|
|
150
|
+
el.dataset.selected = semantics.selected ? "true" : "false";
|
|
151
|
+
mountControls(id, el);
|
|
152
|
+
return el;
|
|
153
|
+
};
|
|
154
|
+
/** Real controls for a styled node's elements with a role. */
|
|
155
|
+
const mountControls = (id, el) => {
|
|
156
|
+
const record = engine.store.get().document.nodes[id];
|
|
157
|
+
const controls = record.type === "ui" ? controlsOf(record) : [];
|
|
158
|
+
const key = JSON.stringify(controls.map((c) => [c.path, c.role, c.name, c.disabled])) + JSON.stringify(record.size);
|
|
159
|
+
if (el.dataset.controls === key)
|
|
160
|
+
return;
|
|
161
|
+
el.dataset.controls = key;
|
|
162
|
+
for (const old of el.querySelectorAll("[data-avis-control]"))
|
|
163
|
+
old.remove();
|
|
164
|
+
if (!controls.length || !style)
|
|
165
|
+
return;
|
|
166
|
+
const node = engine.scene.get(id);
|
|
167
|
+
const { box } = layoutUI(record.props.root, engine.scene.sizeOf(node), {
|
|
168
|
+
hovered: false,
|
|
169
|
+
selected: false,
|
|
170
|
+
dragging: false,
|
|
171
|
+
focused: false,
|
|
172
|
+
states: [],
|
|
173
|
+
}, style, measure);
|
|
174
|
+
for (const control of controls) {
|
|
175
|
+
let b = box;
|
|
176
|
+
let x = 0;
|
|
177
|
+
let y = 0;
|
|
178
|
+
for (const index of control.path) {
|
|
179
|
+
b = b.children[index];
|
|
180
|
+
if (!b)
|
|
181
|
+
break;
|
|
182
|
+
x += b.x;
|
|
183
|
+
y += b.y;
|
|
184
|
+
}
|
|
185
|
+
if (!b)
|
|
186
|
+
continue;
|
|
187
|
+
const tag = control.role === "button" ? "button" : "div";
|
|
188
|
+
const c = doc.createElement(tag);
|
|
189
|
+
c.dataset.avisControl = control.path.join(".");
|
|
190
|
+
if (tag === "button")
|
|
191
|
+
c.type = "button";
|
|
192
|
+
else
|
|
193
|
+
c.setAttribute("role", control.role);
|
|
194
|
+
c.setAttribute("aria-label", control.name);
|
|
195
|
+
if (control.disabled)
|
|
196
|
+
c.setAttribute("aria-disabled", "true");
|
|
197
|
+
c.tabIndex = scope === id ? 0 : -1;
|
|
198
|
+
c.style.cssText = `position:absolute;left:${x}px;top:${y}px;width:${b.w}px;height:${b.h}px;opacity:0;margin:0;padding:0;border:0`;
|
|
199
|
+
c.addEventListener("keydown", onControlKey(id));
|
|
200
|
+
c.addEventListener("focus", () => (c.style.opacity = "1"));
|
|
201
|
+
c.addEventListener("blur", () => (c.style.opacity = "0"));
|
|
202
|
+
c.addEventListener("click", (event) => {
|
|
203
|
+
event.stopPropagation();
|
|
204
|
+
if (control.disabled)
|
|
205
|
+
return;
|
|
206
|
+
events.emit("control:activate", { nodeId: id, action: control.action, path: control.path });
|
|
207
|
+
});
|
|
208
|
+
el.append(c);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const visibleIds = () => {
|
|
212
|
+
const { camera, size } = engine.store.get().viewport;
|
|
213
|
+
const a = screenToWorld(camera, { x: 0, y: 0 });
|
|
214
|
+
const b = screenToWorld(camera, { x: size.width, y: size.height });
|
|
215
|
+
const view = { minX: a.x, minY: a.y, maxX: b.x, maxY: b.y };
|
|
216
|
+
const min = (options.minScreenSize ?? 4) / camera.zoom;
|
|
217
|
+
const out = [];
|
|
218
|
+
for (const node of engine.scene.walk()) {
|
|
219
|
+
const box = node.worldBounds;
|
|
220
|
+
if (!intersects(box, view))
|
|
221
|
+
continue;
|
|
222
|
+
if (box.maxX - box.minX < min && box.maxY - box.minY < min)
|
|
223
|
+
continue;
|
|
224
|
+
out.push(node.id);
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
};
|
|
228
|
+
const update = () => {
|
|
229
|
+
const { interaction, document } = engine.store.get();
|
|
230
|
+
world.style.transform = cameraCss(engine.store.get().viewport.camera);
|
|
231
|
+
const keep = new Set(visibleIds());
|
|
232
|
+
const focused = focus.current();
|
|
233
|
+
const order = focus.order();
|
|
234
|
+
// The focused node, the selection and the first node stay mounted.
|
|
235
|
+
if (focused)
|
|
236
|
+
keep.add(focused);
|
|
237
|
+
for (const id of interaction.selectedIds)
|
|
238
|
+
keep.add(id);
|
|
239
|
+
if (order[0])
|
|
240
|
+
keep.add(order[0]);
|
|
241
|
+
for (const [id, el] of mounted) {
|
|
242
|
+
if (!keep.has(id) || !document.nodes[id]) {
|
|
243
|
+
if (doc.activeElement && el.contains(doc.activeElement))
|
|
244
|
+
continue;
|
|
245
|
+
el.remove();
|
|
246
|
+
mounted.delete(id);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const id of keep)
|
|
250
|
+
mount(id);
|
|
251
|
+
// Elements in reading order (screen readers browse the DOM order).
|
|
252
|
+
const rank = new Map(order.map((id, i) => [id, i]));
|
|
253
|
+
const sorted = [...mounted.keys()].sort((p, q) => (rank.get(p) ?? 0) - (rank.get(q) ?? 0));
|
|
254
|
+
sorted.forEach((id, i) => {
|
|
255
|
+
const el = mounted.get(id);
|
|
256
|
+
if (world.children[i] !== el)
|
|
257
|
+
world.insertBefore(el, world.children[i] ?? null);
|
|
258
|
+
});
|
|
259
|
+
// Roving tabindex: one tab stop for the nodes.
|
|
260
|
+
const stop = focused && mounted.has(focused) ? focused : order[0];
|
|
261
|
+
for (const [id, el] of mounted)
|
|
262
|
+
el.tabIndex = id === stop ? 0 : -1;
|
|
263
|
+
// Edges between mounted nodes, for browsing.
|
|
264
|
+
const items = [];
|
|
265
|
+
for (const relation of Object.values(document.relations)) {
|
|
266
|
+
if (!mounted.has(relation.source.nodeId) && !mounted.has(relation.target.nodeId))
|
|
267
|
+
continue;
|
|
268
|
+
const described = focus.semantics.describeRelation(engine, relation.id);
|
|
269
|
+
if (described)
|
|
270
|
+
items.push(described.name);
|
|
271
|
+
}
|
|
272
|
+
if (edges.dataset.key !== items.join("|")) {
|
|
273
|
+
edges.dataset.key = items.join("|");
|
|
274
|
+
edges.replaceChildren(...items.map((name) => {
|
|
275
|
+
const li = doc.createElement("div");
|
|
276
|
+
li.setAttribute("role", "listitem");
|
|
277
|
+
li.textContent = name;
|
|
278
|
+
return li;
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
let frame = 0;
|
|
283
|
+
const schedule = () => {
|
|
284
|
+
if (frame)
|
|
285
|
+
return;
|
|
286
|
+
const run = () => {
|
|
287
|
+
frame = 0;
|
|
288
|
+
update();
|
|
289
|
+
};
|
|
290
|
+
frame = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(run) : setTimeout(run, 16);
|
|
291
|
+
};
|
|
292
|
+
const subscription = engine.store.subscribe((state) => [state.document, state.viewport, state.interaction.selectedIds, state.a11y.logicalFocusId, state.style], schedule, { equals: (a, b) => a.every((value, i) => value === b[i]) });
|
|
293
|
+
cleanups.push(() => subscription.dispose());
|
|
294
|
+
// Logical focus → DOM focus, only while the DOM focus is already ours.
|
|
295
|
+
const ours = () => {
|
|
296
|
+
const active = doc.activeElement;
|
|
297
|
+
return Boolean(active && (active === options.canvas || layer.contains(active)));
|
|
298
|
+
};
|
|
299
|
+
const focusSub = focus.events.on("focus", ({ id }) => {
|
|
300
|
+
if (scope && scope !== id) {
|
|
301
|
+
scope = null;
|
|
302
|
+
}
|
|
303
|
+
if (!ours())
|
|
304
|
+
return;
|
|
305
|
+
update();
|
|
306
|
+
if (id)
|
|
307
|
+
mounted.get(id)?.focus({ preventScroll: true });
|
|
308
|
+
else
|
|
309
|
+
options.canvas.focus({ preventScroll: true });
|
|
310
|
+
});
|
|
311
|
+
cleanups.push(() => focusSub.dispose());
|
|
312
|
+
const enterSub = focus.events.on("enter", ({ id }) => enterScope(id));
|
|
313
|
+
cleanups.push(() => enterSub.dispose());
|
|
314
|
+
// DOM focus mirror and the live region.
|
|
315
|
+
const onFocusIn = (event) => {
|
|
316
|
+
const target = event.target;
|
|
317
|
+
engine.store.set("a11y", { domFocusId: target.dataset?.id ?? (target === options.canvas ? "canvas" : null) });
|
|
318
|
+
};
|
|
319
|
+
const onFocusOut = () => {
|
|
320
|
+
queueMicrotask(() => {
|
|
321
|
+
if (!ours())
|
|
322
|
+
engine.store.set("a11y", { domFocusId: null });
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
layer.addEventListener("focusin", onFocusIn);
|
|
326
|
+
layer.addEventListener("focusout", onFocusOut);
|
|
327
|
+
options.canvas.addEventListener("focusin", onFocusIn);
|
|
328
|
+
cleanups.push(() => options.canvas.removeEventListener("focusin", onFocusIn));
|
|
329
|
+
const announce = engine.store.subscribe((state) => state.a11y.announcements, (list) => {
|
|
330
|
+
live.textContent = list[list.length - 1] ?? "";
|
|
331
|
+
});
|
|
332
|
+
cleanups.push(() => announce.dispose());
|
|
333
|
+
// A press on the canvas focuses the node it lands on, as React Flow's.
|
|
334
|
+
const onCanvasFocusNode = focus.events.on("focus", ({ id, source }) => {
|
|
335
|
+
if (source !== "pointer" || !id)
|
|
336
|
+
return;
|
|
337
|
+
if (doc.activeElement === options.canvas || layer.contains(doc.activeElement)) {
|
|
338
|
+
update();
|
|
339
|
+
mounted.get(id)?.focus({ preventScroll: true });
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
cleanups.push(() => onCanvasFocusNode.dispose());
|
|
343
|
+
update();
|
|
344
|
+
return {
|
|
345
|
+
element: layer,
|
|
346
|
+
events,
|
|
347
|
+
elementFor: (id) => mounted.get(id) ?? mount(id),
|
|
348
|
+
update,
|
|
349
|
+
dispose() {
|
|
350
|
+
if (frame)
|
|
351
|
+
(typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : clearTimeout)(frame);
|
|
352
|
+
for (const cleanup of cleanups.reverse())
|
|
353
|
+
cleanup();
|
|
354
|
+
events.clear();
|
|
355
|
+
mounted.clear();
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Engine } from "../core/engine.js";
|
|
2
|
+
import type { Mat2D } from "../geometry/matrix.js";
|
|
3
|
+
import type { Camera } from "../geometry/spaces.js";
|
|
4
|
+
import type { Rect } from "./position.js";
|
|
5
|
+
/** The camera as a CSS transform for a world-space layer (origin 0 0). */
|
|
6
|
+
export declare const cameraCss: (camera: Camera) => string;
|
|
7
|
+
/** A node's world matrix as a CSS transform. */
|
|
8
|
+
export declare const matrixCss: (m: Mat2D) => string;
|
|
9
|
+
/** A node's box on screen, relative to the canvas (its axis-aligned bounds). */
|
|
10
|
+
export declare function nodeScreenRect(engine: Engine, id: string): Rect | null;
|
|
11
|
+
type ClientRect = {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
right: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A Floating UI virtual element for a node (or any canvas rect), in client
|
|
23
|
+
* coordinates: `computePosition(virtualElement(engine, id, canvas), floating, …)`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function virtualElement(engine: Engine, target: string | (() => Rect | null), canvas: {
|
|
26
|
+
getBoundingClientRect(): {
|
|
27
|
+
left: number;
|
|
28
|
+
top: number;
|
|
29
|
+
};
|
|
30
|
+
}): {
|
|
31
|
+
contextElement: Element;
|
|
32
|
+
getBoundingClientRect(): ClientRect;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The camera as a CSS transform for a world-space layer (origin 0 0). */
|
|
2
|
+
export const cameraCss = (camera) => `translate(${camera.x}px, ${camera.y}px) scale(${camera.zoom})`;
|
|
3
|
+
/** A node's world matrix as a CSS transform. */
|
|
4
|
+
export const matrixCss = (m) => `matrix(${m[0]}, ${m[1]}, ${m[2]}, ${m[3]}, ${m[4]}, ${m[5]})`;
|
|
5
|
+
/** A node's box on screen, relative to the canvas (its axis-aligned bounds). */
|
|
6
|
+
export function nodeScreenRect(engine, id) {
|
|
7
|
+
const node = engine.scene.get(id);
|
|
8
|
+
if (!node)
|
|
9
|
+
return null;
|
|
10
|
+
const b = node.worldBounds;
|
|
11
|
+
const min = engine.viewport.toScreen({ x: b.minX, y: b.minY });
|
|
12
|
+
const max = engine.viewport.toScreen({ x: b.maxX, y: b.maxY });
|
|
13
|
+
return { x: min.x, y: min.y, width: max.x - min.x, height: max.y - min.y };
|
|
14
|
+
}
|
|
15
|
+
const toClientRect = (r) => ({
|
|
16
|
+
...r,
|
|
17
|
+
top: r.y,
|
|
18
|
+
left: r.x,
|
|
19
|
+
right: r.x + r.width,
|
|
20
|
+
bottom: r.y + r.height,
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* A Floating UI virtual element for a node (or any canvas rect), in client
|
|
24
|
+
* coordinates: `computePosition(virtualElement(engine, id, canvas), floating, …)`.
|
|
25
|
+
*/
|
|
26
|
+
export function virtualElement(engine, target, canvas) {
|
|
27
|
+
return {
|
|
28
|
+
contextElement: canvas,
|
|
29
|
+
getBoundingClientRect() {
|
|
30
|
+
const rect = typeof target === "string" ? nodeScreenRect(engine, target) : target();
|
|
31
|
+
const origin = canvas.getBoundingClientRect();
|
|
32
|
+
return toClientRect(rect ? { ...rect, x: rect.x + origin.left, y: rect.y + origin.top } : { x: origin.left, y: origin.top, width: 0, height: 0 });
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// AVIS Engine · dom — Phase 5: the DOM accessibility tree, anchor
|
|
2
|
+
// positioning, overlays, the native text field and menus.
|
|
3
|
+
export * from "./position.js";
|
|
4
|
+
export * from "./anchor.js";
|
|
5
|
+
export * from "./a11y-layer.js";
|
|
6
|
+
export * from "./overlays.js";
|
|
7
|
+
export * from "./text-editor.js";
|
|
8
|
+
export * from "./menu.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Disposable } from "../core/disposable.js";
|
|
2
|
+
import { type Placement, type Rect } from "./position.js";
|
|
3
|
+
export type MenuItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MenuOptions = {
|
|
10
|
+
/** Where the menu goes (positioned inside it). */
|
|
11
|
+
root: HTMLElement;
|
|
12
|
+
/** The anchor, in `root`'s coordinates (a point for a context menu). */
|
|
13
|
+
anchor: Rect;
|
|
14
|
+
items: readonly MenuItem[];
|
|
15
|
+
label?: string;
|
|
16
|
+
placement?: Placement;
|
|
17
|
+
onSelect(id: string): void;
|
|
18
|
+
onClose?(): void;
|
|
19
|
+
};
|
|
20
|
+
export type MenuHandle = Disposable & {
|
|
21
|
+
readonly element: HTMLElement;
|
|
22
|
+
close(): void;
|
|
23
|
+
};
|
|
24
|
+
export declare function openMenu(options: MenuOptions): MenuHandle;
|
package/dist/dom/menu.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { computePosition } from "./position.js";
|
|
2
|
+
export function openMenu(options) {
|
|
3
|
+
const doc = options.root.ownerDocument;
|
|
4
|
+
const restore = doc.activeElement;
|
|
5
|
+
const menu = doc.createElement("div");
|
|
6
|
+
menu.setAttribute("role", "menu");
|
|
7
|
+
menu.setAttribute("aria-label", options.label ?? "Menu");
|
|
8
|
+
menu.dataset.avisMenu = "";
|
|
9
|
+
menu.tabIndex = -1;
|
|
10
|
+
menu.style.cssText = "position:absolute;left:0;top:0;pointer-events:auto";
|
|
11
|
+
const items = options.items.map((item) => {
|
|
12
|
+
const el = doc.createElement("div");
|
|
13
|
+
el.setAttribute("role", "menuitem");
|
|
14
|
+
el.tabIndex = -1;
|
|
15
|
+
el.dataset.id = item.id;
|
|
16
|
+
el.dataset.avisMenuItem = "";
|
|
17
|
+
if (item.disabled)
|
|
18
|
+
el.setAttribute("aria-disabled", "true");
|
|
19
|
+
const label = doc.createElement("span");
|
|
20
|
+
label.textContent = item.label;
|
|
21
|
+
el.append(label);
|
|
22
|
+
if (item.shortcut) {
|
|
23
|
+
const shortcut = doc.createElement("span");
|
|
24
|
+
shortcut.dataset.shortcut = "";
|
|
25
|
+
shortcut.setAttribute("aria-hidden", "true");
|
|
26
|
+
shortcut.textContent = item.shortcut;
|
|
27
|
+
el.append(shortcut);
|
|
28
|
+
}
|
|
29
|
+
el.addEventListener("click", () => pick(item));
|
|
30
|
+
el.addEventListener("pointermove", () => el.focus({ preventScroll: true }));
|
|
31
|
+
menu.append(el);
|
|
32
|
+
return { item, el };
|
|
33
|
+
});
|
|
34
|
+
options.root.append(menu);
|
|
35
|
+
const rootRect = options.root.getBoundingClientRect();
|
|
36
|
+
const place = computePosition(options.anchor, { width: menu.offsetWidth, height: menu.offsetHeight }, {
|
|
37
|
+
placement: options.placement ?? "bottom-start",
|
|
38
|
+
offset: 4,
|
|
39
|
+
flip: true,
|
|
40
|
+
shift: { padding: 8 },
|
|
41
|
+
boundary: { x: 0, y: 0, width: rootRect.width, height: rootRect.height },
|
|
42
|
+
});
|
|
43
|
+
menu.style.transform = `translate(${Math.round(place.x)}px, ${Math.round(place.y)}px)`;
|
|
44
|
+
const enabled = () => items.filter(({ item }) => !item.disabled);
|
|
45
|
+
const focusAt = (index) => {
|
|
46
|
+
const list = enabled();
|
|
47
|
+
if (!list.length)
|
|
48
|
+
return;
|
|
49
|
+
list[(index + list.length) % list.length].el.focus({ preventScroll: true });
|
|
50
|
+
};
|
|
51
|
+
const current = () => enabled().findIndex(({ el }) => el === doc.activeElement);
|
|
52
|
+
let closed = false;
|
|
53
|
+
const close = (restoreFocus = true) => {
|
|
54
|
+
if (closed)
|
|
55
|
+
return;
|
|
56
|
+
closed = true;
|
|
57
|
+
doc.removeEventListener("pointerdown", onOutside, true);
|
|
58
|
+
menu.remove();
|
|
59
|
+
if (restoreFocus && restore && restore.isConnected)
|
|
60
|
+
restore.focus({ preventScroll: true });
|
|
61
|
+
options.onClose?.();
|
|
62
|
+
};
|
|
63
|
+
function pick(item) {
|
|
64
|
+
if (item.disabled)
|
|
65
|
+
return;
|
|
66
|
+
close();
|
|
67
|
+
options.onSelect(item.id);
|
|
68
|
+
}
|
|
69
|
+
const onOutside = (event) => {
|
|
70
|
+
if (!menu.contains(event.target))
|
|
71
|
+
close(false);
|
|
72
|
+
};
|
|
73
|
+
doc.addEventListener("pointerdown", onOutside, true);
|
|
74
|
+
menu.addEventListener("keydown", (event) => {
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
const at = current();
|
|
77
|
+
switch (event.key) {
|
|
78
|
+
case "ArrowDown":
|
|
79
|
+
focusAt(at + 1);
|
|
80
|
+
break;
|
|
81
|
+
case "ArrowUp":
|
|
82
|
+
focusAt(at < 0 ? -1 : at - 1);
|
|
83
|
+
break;
|
|
84
|
+
case "Home":
|
|
85
|
+
focusAt(0);
|
|
86
|
+
break;
|
|
87
|
+
case "End":
|
|
88
|
+
focusAt(-1);
|
|
89
|
+
break;
|
|
90
|
+
case "Enter":
|
|
91
|
+
case " ": {
|
|
92
|
+
const entry = enabled()[at];
|
|
93
|
+
if (entry)
|
|
94
|
+
pick(entry.item);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "Escape":
|
|
98
|
+
close();
|
|
99
|
+
break;
|
|
100
|
+
case "Tab":
|
|
101
|
+
close();
|
|
102
|
+
return;
|
|
103
|
+
default:
|
|
104
|
+
if (event.key.length === 1 && /\S/.test(event.key)) {
|
|
105
|
+
// Typeahead: the next item starting with the letter.
|
|
106
|
+
const list = enabled();
|
|
107
|
+
const letter = event.key.toLowerCase();
|
|
108
|
+
for (let k = 1; k <= list.length; k++) {
|
|
109
|
+
const entry = list[(at + k) % list.length];
|
|
110
|
+
if (entry.item.label.toLowerCase().startsWith(letter)) {
|
|
111
|
+
entry.el.focus({ preventScroll: true });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
});
|
|
120
|
+
focusAt(0);
|
|
121
|
+
return { element: menu, close: () => close(), dispose: () => close(false) };
|
|
122
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Disposable } from "../core/disposable.js";
|
|
2
|
+
import type { Engine } from "../core/engine.js";
|
|
3
|
+
import { type Placement, type PositionResult, type Rect } from "./position.js";
|
|
4
|
+
export type AnchorOptions = {
|
|
5
|
+
placement?: Placement;
|
|
6
|
+
offset?: number;
|
|
7
|
+
flip?: boolean;
|
|
8
|
+
/** Padding from the canvas edges, px. */
|
|
9
|
+
padding?: number;
|
|
10
|
+
/** False when someone else (React) puts the element in `element` and removes it. */
|
|
11
|
+
append?: boolean;
|
|
12
|
+
/** Called after each placement (the side may have flipped). */
|
|
13
|
+
onPosition?: (result: PositionResult) => void;
|
|
14
|
+
};
|
|
15
|
+
export type AnchorHandle = Disposable & {
|
|
16
|
+
update(): void;
|
|
17
|
+
setTarget(target: string | (() => Rect | null)): void;
|
|
18
|
+
};
|
|
19
|
+
export type OverlayLayer = Disposable & {
|
|
20
|
+
readonly element: HTMLElement;
|
|
21
|
+
/** DOM in world space, transformed with the camera. */
|
|
22
|
+
readonly world: HTMLElement;
|
|
23
|
+
/** Keeps `element` next to a node (or a canvas rect), on screen. */
|
|
24
|
+
anchor(target: string | (() => Rect | null), element: HTMLElement, options?: AnchorOptions): AnchorHandle;
|
|
25
|
+
update(): void;
|
|
26
|
+
};
|
|
27
|
+
export declare function createOverlayLayer(engine: Engine, options: {
|
|
28
|
+
root: HTMLElement;
|
|
29
|
+
}): OverlayLayer;
|