@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,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The engine kernel (spec §3.1): it owns the store, the scene, the schemas,
|
|
3
|
+
* the commands and the history, runs plugins in dependency order and
|
|
4
|
+
* releases everything on dispose. No framework, no renderer.
|
|
5
|
+
*/
|
|
6
|
+
import { applyPatches, BUILTIN_COMMANDS, CommandRegistry, DocumentDraft, History, Transaction, TransactionAbort, touchedNodeIds, } from "../commands/index.js";
|
|
7
|
+
import { EMPTY_BOUNDS, isEmpty, union } from "../geometry/bounds.js";
|
|
8
|
+
import { screenToWorld, worldToScreen, } from "../geometry/spaces.js";
|
|
9
|
+
import { BUILTIN_TYPES } from "../scene/builtins.js";
|
|
10
|
+
import { SceneGraph } from "../scene/scene-graph.js";
|
|
11
|
+
import { SchemaRegistry } from "../scene/schema.js";
|
|
12
|
+
import { deserialize, serialize, stableStringify, } from "../serialization/index.js";
|
|
13
|
+
import { commitDocument, createStore, } from "../state/store.js";
|
|
14
|
+
import { error, DiagnosticsSink } from "./diagnostics.js";
|
|
15
|
+
import { DisposableStack, toDisposable } from "./disposable.js";
|
|
16
|
+
import { EventBus } from "./event-bus.js";
|
|
17
|
+
import { randomIds } from "./ids.js";
|
|
18
|
+
import { orderPlugins } from "./plugin.js";
|
|
19
|
+
import { ServiceRegistry } from "./services.js";
|
|
20
|
+
const clampZoom = (viewport, zoom) => Math.min(viewport.maxZoom, Math.max(viewport.minZoom, zoom));
|
|
21
|
+
export class EngineDisposed extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("The engine was disposed");
|
|
24
|
+
this.name = "EngineDisposed";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function createEngine(options = {}) {
|
|
28
|
+
const stack = new DisposableStack();
|
|
29
|
+
const diagnostics = new DiagnosticsSink();
|
|
30
|
+
const bus = new EventBus();
|
|
31
|
+
const services = new ServiceRegistry();
|
|
32
|
+
const schemas = new SchemaRegistry();
|
|
33
|
+
const commandRegistry = new CommandRegistry();
|
|
34
|
+
const history = new History(options.history);
|
|
35
|
+
const ids = options.ids ?? randomIds;
|
|
36
|
+
const store = createStore();
|
|
37
|
+
const scene = new SceneGraph(store.get().document);
|
|
38
|
+
const installed = new Set();
|
|
39
|
+
let disposed = false;
|
|
40
|
+
for (const type of [...BUILTIN_TYPES, ...(options.schemas ?? [])]) {
|
|
41
|
+
schemas.register(type);
|
|
42
|
+
}
|
|
43
|
+
for (const command of BUILTIN_COMMANDS) {
|
|
44
|
+
commandRegistry.register(command);
|
|
45
|
+
}
|
|
46
|
+
stack.use(diagnostics.subscribe((diagnostic) => bus.emit("diagnostic", diagnostic)));
|
|
47
|
+
// Previews (a node being dragged) reach the scene, never the document.
|
|
48
|
+
stack.use(store.subscribe((state) => [state.interaction.preview, state.interaction.previewSize], ([preview, sizes]) => scene.setPreview(preview, sizes)));
|
|
49
|
+
const alive = () => {
|
|
50
|
+
if (disposed)
|
|
51
|
+
throw new EngineDisposed();
|
|
52
|
+
};
|
|
53
|
+
const emitHistory = () => bus.emit("history:change", {
|
|
54
|
+
canUndo: history.canUndo,
|
|
55
|
+
canRedo: history.canRedo,
|
|
56
|
+
});
|
|
57
|
+
/** Writes committed patches: store, scene, history, listeners. */
|
|
58
|
+
function commit(document, patches, label, options) {
|
|
59
|
+
store.batch(() => {
|
|
60
|
+
commitDocument(store, document);
|
|
61
|
+
scene.setDocument(document, touchedNodeIds(patches));
|
|
62
|
+
});
|
|
63
|
+
if (options.record !== false) {
|
|
64
|
+
history.record({
|
|
65
|
+
label,
|
|
66
|
+
patches,
|
|
67
|
+
mergeKey: options.mergeKey,
|
|
68
|
+
time: history.now(),
|
|
69
|
+
});
|
|
70
|
+
emitHistory();
|
|
71
|
+
}
|
|
72
|
+
bus.emit("document:change", {
|
|
73
|
+
patches,
|
|
74
|
+
origin: options.origin ?? "user",
|
|
75
|
+
label,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function transact(label, run, options = {}) {
|
|
79
|
+
alive();
|
|
80
|
+
const draft = new DocumentDraft(store.get().document);
|
|
81
|
+
const tx = new Transaction(draft, commandRegistry, { schemas, ids });
|
|
82
|
+
let value;
|
|
83
|
+
try {
|
|
84
|
+
value = run(tx);
|
|
85
|
+
}
|
|
86
|
+
catch (thrown) {
|
|
87
|
+
// Nothing was written: the draft is dropped.
|
|
88
|
+
if (thrown instanceof TransactionAbort) {
|
|
89
|
+
thrown.diagnostics.forEach((diagnostic) => diagnostics.report(diagnostic));
|
|
90
|
+
return { ok: false, diagnostics: thrown.diagnostics };
|
|
91
|
+
}
|
|
92
|
+
diagnostics.report(error("transaction.exception", `"${label}" failed: ${String(thrown)}`, {
|
|
93
|
+
data: thrown,
|
|
94
|
+
}));
|
|
95
|
+
throw thrown;
|
|
96
|
+
}
|
|
97
|
+
const patches = draft.patches;
|
|
98
|
+
if (patches.length)
|
|
99
|
+
commit(draft.toDocument(), patches, label, options);
|
|
100
|
+
tx.warnings.forEach((warning) => diagnostics.report(warning));
|
|
101
|
+
return { ok: true, value, patches, warnings: tx.warnings };
|
|
102
|
+
}
|
|
103
|
+
/** Applies patches as they are (undo, redo): no validation, no history. */
|
|
104
|
+
function replay(patches, origin) {
|
|
105
|
+
const document = applyPatches(store.get().document, patches);
|
|
106
|
+
commit(document, patches, origin, { origin, record: false });
|
|
107
|
+
}
|
|
108
|
+
const engine = {
|
|
109
|
+
store,
|
|
110
|
+
scene,
|
|
111
|
+
schemas,
|
|
112
|
+
services,
|
|
113
|
+
diagnostics,
|
|
114
|
+
bus,
|
|
115
|
+
transact,
|
|
116
|
+
/** Changes inside make one history entry and one notification. */
|
|
117
|
+
batch(label, run) {
|
|
118
|
+
alive();
|
|
119
|
+
history.beginGroup(label);
|
|
120
|
+
try {
|
|
121
|
+
return store.batch(run);
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
history.endGroup();
|
|
125
|
+
emitHistory();
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
commands: {
|
|
129
|
+
execute(id, params, options) {
|
|
130
|
+
return transact(id, (tx) => tx.run(id, params), options);
|
|
131
|
+
},
|
|
132
|
+
register(command) {
|
|
133
|
+
alive();
|
|
134
|
+
return commandRegistry.register(command);
|
|
135
|
+
},
|
|
136
|
+
has: (id) => commandRegistry.has(id),
|
|
137
|
+
get ids() {
|
|
138
|
+
return commandRegistry.ids;
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
history: {
|
|
142
|
+
undo() {
|
|
143
|
+
alive();
|
|
144
|
+
const patches = history.undo();
|
|
145
|
+
if (patches)
|
|
146
|
+
replay(patches, "undo");
|
|
147
|
+
emitHistory();
|
|
148
|
+
return Boolean(patches);
|
|
149
|
+
},
|
|
150
|
+
redo() {
|
|
151
|
+
alive();
|
|
152
|
+
const patches = history.redo();
|
|
153
|
+
if (patches)
|
|
154
|
+
replay(patches, "redo");
|
|
155
|
+
emitHistory();
|
|
156
|
+
return Boolean(patches);
|
|
157
|
+
},
|
|
158
|
+
get canUndo() {
|
|
159
|
+
return history.canUndo;
|
|
160
|
+
},
|
|
161
|
+
get canRedo() {
|
|
162
|
+
return history.canRedo;
|
|
163
|
+
},
|
|
164
|
+
get size() {
|
|
165
|
+
return history.size;
|
|
166
|
+
},
|
|
167
|
+
clear() {
|
|
168
|
+
history.clear();
|
|
169
|
+
emitHistory();
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
/** Creates a node (the `node.create` command); returns its id. */
|
|
173
|
+
createNode(params) {
|
|
174
|
+
const result = engine.commands.execute("node.create", params);
|
|
175
|
+
if (!result.ok) {
|
|
176
|
+
throw new Error(result.diagnostics.map((diagnostic) => diagnostic.message).join("; "));
|
|
177
|
+
}
|
|
178
|
+
return result.value;
|
|
179
|
+
},
|
|
180
|
+
selection: {
|
|
181
|
+
get: () => store.get().interaction.selectedIds,
|
|
182
|
+
select(ids) {
|
|
183
|
+
alive();
|
|
184
|
+
store.set("interaction", { selectedIds: [...ids] });
|
|
185
|
+
},
|
|
186
|
+
clear() {
|
|
187
|
+
store.set("interaction", { selectedIds: [] });
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
viewport: {
|
|
191
|
+
get: () => store.get().viewport,
|
|
192
|
+
setCamera(camera) {
|
|
193
|
+
alive();
|
|
194
|
+
store.set("viewport", (viewport) => ({
|
|
195
|
+
...viewport,
|
|
196
|
+
camera: {
|
|
197
|
+
...viewport.camera,
|
|
198
|
+
...camera,
|
|
199
|
+
zoom: clampZoom(viewport, camera.zoom ?? viewport.camera.zoom),
|
|
200
|
+
},
|
|
201
|
+
}));
|
|
202
|
+
},
|
|
203
|
+
zoomAt(screen, zoom) {
|
|
204
|
+
alive();
|
|
205
|
+
const { camera } = store.get().viewport;
|
|
206
|
+
const world = screenToWorld(camera, screen);
|
|
207
|
+
const next = clampZoom(store.get().viewport, zoom);
|
|
208
|
+
engine.viewport.setCamera({
|
|
209
|
+
zoom: next,
|
|
210
|
+
x: screen.x - world.x * next,
|
|
211
|
+
y: screen.y - world.y * next,
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
zoomTo(zoom) {
|
|
215
|
+
const { size } = store.get().viewport;
|
|
216
|
+
engine.viewport.zoomAt({ x: size.width / 2, y: size.height / 2 }, zoom);
|
|
217
|
+
},
|
|
218
|
+
fitView(options = {}) {
|
|
219
|
+
alive();
|
|
220
|
+
let box = EMPTY_BOUNDS;
|
|
221
|
+
const ids = options.ids ? new Set(options.ids) : null;
|
|
222
|
+
for (const node of scene.walk()) {
|
|
223
|
+
if (ids ? ids.has(node.id) : !node.parent)
|
|
224
|
+
box = union(box, node.subtreeBounds);
|
|
225
|
+
}
|
|
226
|
+
const { size } = store.get().viewport;
|
|
227
|
+
if (isEmpty(box) || !size.width || !size.height)
|
|
228
|
+
return false;
|
|
229
|
+
const padding = options.padding ?? 0.1;
|
|
230
|
+
const width = (box.maxX - box.minX) * (1 + padding * 2) || 1;
|
|
231
|
+
const height = (box.maxY - box.minY) * (1 + padding * 2) || 1;
|
|
232
|
+
const zoom = clampZoom(store.get().viewport, Math.min(size.width / width, size.height / height, options.maxZoom ?? Infinity));
|
|
233
|
+
engine.viewport.setCamera({
|
|
234
|
+
zoom,
|
|
235
|
+
x: size.width / 2 - ((box.minX + box.maxX) / 2) * zoom,
|
|
236
|
+
y: size.height / 2 - ((box.minY + box.maxY) / 2) * zoom,
|
|
237
|
+
});
|
|
238
|
+
return true;
|
|
239
|
+
},
|
|
240
|
+
toWorld: (screen) => screenToWorld(store.get().viewport.camera, screen),
|
|
241
|
+
toScreen: (world) => worldToScreen(store.get().viewport.camera, world),
|
|
242
|
+
panBy(dx, dy) {
|
|
243
|
+
alive();
|
|
244
|
+
store.set("viewport", (viewport) => ({
|
|
245
|
+
...viewport,
|
|
246
|
+
camera: {
|
|
247
|
+
...viewport.camera,
|
|
248
|
+
x: viewport.camera.x + dx,
|
|
249
|
+
y: viewport.camera.y + dy,
|
|
250
|
+
},
|
|
251
|
+
}));
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
/** The document in its saved form. */
|
|
255
|
+
serialize(meta) {
|
|
256
|
+
return serialize(store.get().document, meta);
|
|
257
|
+
},
|
|
258
|
+
toJSON(meta) {
|
|
259
|
+
return stableStringify(serialize(store.get().document, meta));
|
|
260
|
+
},
|
|
261
|
+
/** Replaces the document with a saved one; the history starts over. */
|
|
262
|
+
load(input) {
|
|
263
|
+
alive();
|
|
264
|
+
const { document, diagnostics: found } = deserialize(input, schemas);
|
|
265
|
+
found.forEach((diagnostic) => diagnostics.report(diagnostic));
|
|
266
|
+
if (found.some((diagnostic) => diagnostic.level === "error")) {
|
|
267
|
+
return { ok: false, diagnostics: found };
|
|
268
|
+
}
|
|
269
|
+
const result = engine.commands.execute("document.load", { document }, {
|
|
270
|
+
origin: "load",
|
|
271
|
+
record: false,
|
|
272
|
+
});
|
|
273
|
+
history.clear();
|
|
274
|
+
emitHistory();
|
|
275
|
+
return result.ok
|
|
276
|
+
? { ok: true, diagnostics: found }
|
|
277
|
+
: { ok: false, diagnostics: [...found, ...result.diagnostics] };
|
|
278
|
+
},
|
|
279
|
+
/** Installs a plugin (and the ones it depends on, if given). */
|
|
280
|
+
use(...plugins) {
|
|
281
|
+
alive();
|
|
282
|
+
const { order, diagnostics: found } = orderPlugins(plugins, installed);
|
|
283
|
+
found.forEach((diagnostic) => diagnostics.report(diagnostic));
|
|
284
|
+
for (const plugin of order) {
|
|
285
|
+
if (installed.has(plugin.name))
|
|
286
|
+
continue;
|
|
287
|
+
const own = new DisposableStack();
|
|
288
|
+
own.use(toDisposable(plugin.setup({
|
|
289
|
+
engine,
|
|
290
|
+
track: (cleanup) => own.use(cleanup),
|
|
291
|
+
})));
|
|
292
|
+
installed.add(plugin.name);
|
|
293
|
+
stack.use(() => {
|
|
294
|
+
own.dispose();
|
|
295
|
+
installed.delete(plugin.name);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return engine;
|
|
299
|
+
},
|
|
300
|
+
get plugins() {
|
|
301
|
+
return [...installed];
|
|
302
|
+
},
|
|
303
|
+
get disposed() {
|
|
304
|
+
return disposed;
|
|
305
|
+
},
|
|
306
|
+
/** Releases plugins (in reverse), listeners and state. */
|
|
307
|
+
dispose() {
|
|
308
|
+
if (disposed)
|
|
309
|
+
return;
|
|
310
|
+
bus.emit("dispose", undefined);
|
|
311
|
+
try {
|
|
312
|
+
stack.dispose();
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
disposed = true;
|
|
316
|
+
bus.clear();
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
if (options.plugins?.length)
|
|
321
|
+
engine.use(...options.plugins);
|
|
322
|
+
return engine;
|
|
323
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Disposable } from "./disposable.js";
|
|
2
|
+
/** A typed event bus: `on` returns a Disposable. */
|
|
3
|
+
export declare class EventBus<Events extends Record<string, unknown>> {
|
|
4
|
+
private listeners;
|
|
5
|
+
on<K extends keyof Events>(type: K, listener: (payload: Events[K]) => void): Disposable;
|
|
6
|
+
emit<K extends keyof Events>(type: K, payload: Events[K]): void;
|
|
7
|
+
/** Listeners still registered (leak checks). */
|
|
8
|
+
get size(): number;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A typed event bus: `on` returns a Disposable. */
|
|
2
|
+
export class EventBus {
|
|
3
|
+
listeners = new Map();
|
|
4
|
+
on(type, listener) {
|
|
5
|
+
let set = this.listeners.get(type);
|
|
6
|
+
if (!set) {
|
|
7
|
+
set = new Set();
|
|
8
|
+
this.listeners.set(type, set);
|
|
9
|
+
}
|
|
10
|
+
set.add(listener);
|
|
11
|
+
return {
|
|
12
|
+
dispose: () => {
|
|
13
|
+
set.delete(listener);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
emit(type, payload) {
|
|
18
|
+
for (const listener of [...(this.listeners.get(type) ?? [])]) {
|
|
19
|
+
;
|
|
20
|
+
listener(payload);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Listeners still registered (leak checks). */
|
|
24
|
+
get size() {
|
|
25
|
+
let count = 0;
|
|
26
|
+
for (const set of this.listeners.values())
|
|
27
|
+
count += set.size;
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.listeners.clear();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const brand: unique symbol;
|
|
2
|
+
type Branded<T, B extends string> = T & {
|
|
3
|
+
readonly [brand]?: B;
|
|
4
|
+
};
|
|
5
|
+
/** A node's stable identity, the same in every renderer. */
|
|
6
|
+
export type NodeId = Branded<string, "NodeId">;
|
|
7
|
+
/** A relation's (a graph connection's) identity. */
|
|
8
|
+
export type RelationId = Branded<string, "RelationId">;
|
|
9
|
+
export type IdFactory = (kind: "node" | "relation") => string;
|
|
10
|
+
export declare const randomIds: IdFactory;
|
|
11
|
+
/** Predictable ids (tests, fixtures). */
|
|
12
|
+
export declare function sequentialIds(prefix?: string): IdFactory;
|
|
13
|
+
export {};
|
package/dist/core/ids.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const randomIds = (kind) => `${kind === "node" ? "n" : "r"}_${crypto.randomUUID()}`;
|
|
2
|
+
/** Predictable ids (tests, fixtures). */
|
|
3
|
+
export function sequentialIds(prefix = "") {
|
|
4
|
+
let next = 1;
|
|
5
|
+
return (kind) => `${prefix}${kind === "node" ? "n" : "r"}${next++}`;
|
|
6
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Cleanup, Disposable } from "./disposable.js";
|
|
2
|
+
import { type Diagnostic } from "./diagnostics.js";
|
|
3
|
+
export type PluginContext<E> = {
|
|
4
|
+
engine: E;
|
|
5
|
+
/** Released with the plugin. */
|
|
6
|
+
track<T extends Cleanup>(cleanup: T): T;
|
|
7
|
+
};
|
|
8
|
+
export type Plugin<E> = {
|
|
9
|
+
name: string;
|
|
10
|
+
dependsOn?: string[];
|
|
11
|
+
setup(context: PluginContext<E>): Cleanup | Disposable;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Plugins in dependency order. A missing dependency or a cycle leaves the
|
|
15
|
+
* plugins involved out, with a diagnostic.
|
|
16
|
+
*/
|
|
17
|
+
export declare function orderPlugins<E>(plugins: readonly Plugin<E>[], installed?: ReadonlySet<string>): {
|
|
18
|
+
order: Plugin<E>[];
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { error } from "./diagnostics.js";
|
|
2
|
+
/**
|
|
3
|
+
* Plugins in dependency order. A missing dependency or a cycle leaves the
|
|
4
|
+
* plugins involved out, with a diagnostic.
|
|
5
|
+
*/
|
|
6
|
+
export function orderPlugins(plugins, installed = new Set()) {
|
|
7
|
+
const byName = new Map(plugins.map((plugin) => [plugin.name, plugin]));
|
|
8
|
+
const order = [];
|
|
9
|
+
const diagnostics = [];
|
|
10
|
+
const state = new Map();
|
|
11
|
+
const visit = (plugin, path) => {
|
|
12
|
+
const seen = state.get(plugin.name);
|
|
13
|
+
if (seen === "done")
|
|
14
|
+
return true;
|
|
15
|
+
if (seen === "failed")
|
|
16
|
+
return false;
|
|
17
|
+
if (seen === "visiting") {
|
|
18
|
+
diagnostics.push(error("plugin.cycle", `Plugin dependency cycle: ${[...path, plugin.name].join(" → ")}`, {
|
|
19
|
+
source: plugin.name,
|
|
20
|
+
}));
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
state.set(plugin.name, "visiting");
|
|
24
|
+
for (const name of plugin.dependsOn ?? []) {
|
|
25
|
+
if (installed.has(name))
|
|
26
|
+
continue;
|
|
27
|
+
const dependency = byName.get(name);
|
|
28
|
+
if (!dependency) {
|
|
29
|
+
diagnostics.push(error("plugin.missing-dependency", `Plugin "${plugin.name}" needs "${name}"`, {
|
|
30
|
+
source: plugin.name,
|
|
31
|
+
}));
|
|
32
|
+
state.set(plugin.name, "failed");
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (!visit(dependency, [...path, plugin.name])) {
|
|
36
|
+
state.set(plugin.name, "failed");
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
state.set(plugin.name, "done");
|
|
41
|
+
order.push(plugin);
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
44
|
+
for (const plugin of plugins)
|
|
45
|
+
visit(plugin, []);
|
|
46
|
+
return { order, diagnostics };
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A typed key for a service (a renderer, a spatial index, a clock). */
|
|
2
|
+
export type ServiceKey<T> = {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly __type?: T;
|
|
5
|
+
};
|
|
6
|
+
export declare const serviceKey: <T>(name: string) => ServiceKey<T>;
|
|
7
|
+
export declare class ServiceRegistry {
|
|
8
|
+
private services;
|
|
9
|
+
register<T>(key: ServiceKey<T>, service: T): {
|
|
10
|
+
dispose: () => undefined;
|
|
11
|
+
};
|
|
12
|
+
get<T>(key: ServiceKey<T>): T;
|
|
13
|
+
has(key: ServiceKey<unknown>): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const serviceKey = (name) => ({ name });
|
|
2
|
+
export class ServiceRegistry {
|
|
3
|
+
services = new Map();
|
|
4
|
+
register(key, service) {
|
|
5
|
+
if (this.services.has(key)) {
|
|
6
|
+
throw new Error(`Service "${key.name}" is already registered`);
|
|
7
|
+
}
|
|
8
|
+
this.services.set(key, service);
|
|
9
|
+
return { dispose: () => void this.services.delete(key) };
|
|
10
|
+
}
|
|
11
|
+
get(key) {
|
|
12
|
+
if (!this.services.has(key)) {
|
|
13
|
+
throw new Error(`Service "${key.name}" is not registered`);
|
|
14
|
+
}
|
|
15
|
+
return this.services.get(key);
|
|
16
|
+
}
|
|
17
|
+
has(key) {
|
|
18
|
+
return this.services.has(key);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./panel.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Disposable } from "../core/disposable.js";
|
|
2
|
+
import type { Engine } from "../core/engine.js";
|
|
3
|
+
import type { Renderer } from "../render/renderer.js";
|
|
4
|
+
import type { StyleEngine } from "../style/style-engine.js";
|
|
5
|
+
export type DevtoolsTarget = {
|
|
6
|
+
engine: Engine;
|
|
7
|
+
renderer?: Renderer;
|
|
8
|
+
style?: StyleEngine | null;
|
|
9
|
+
};
|
|
10
|
+
export type Devtools = Disposable & {
|
|
11
|
+
readonly element: HTMLElement;
|
|
12
|
+
toggle(open?: boolean): void;
|
|
13
|
+
snapshot(): DevtoolsSnapshot;
|
|
14
|
+
};
|
|
15
|
+
export type DevtoolsSnapshot = {
|
|
16
|
+
frame: {
|
|
17
|
+
p50: number;
|
|
18
|
+
p95: number;
|
|
19
|
+
drawCalls: number;
|
|
20
|
+
visible: string;
|
|
21
|
+
cacheHits: number;
|
|
22
|
+
backend: string;
|
|
23
|
+
} | null;
|
|
24
|
+
scene: Record<string, number>;
|
|
25
|
+
relations: number;
|
|
26
|
+
selection: string[];
|
|
27
|
+
focus: string | null;
|
|
28
|
+
history: {
|
|
29
|
+
size: number;
|
|
30
|
+
canUndo: boolean;
|
|
31
|
+
canRedo: boolean;
|
|
32
|
+
};
|
|
33
|
+
diagnostics: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare function snapshotOf({ engine, renderer, style }: DevtoolsTarget, rendererDiagnostics?: string[]): DevtoolsSnapshot;
|
|
36
|
+
export declare function attachDevtools(target: DevtoolsTarget, options: {
|
|
37
|
+
root: HTMLElement;
|
|
38
|
+
open?: boolean;
|
|
39
|
+
}): Devtools;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export function snapshotOf({ engine, renderer, style }, rendererDiagnostics = []) {
|
|
2
|
+
const { document, interaction, a11y } = engine.store.get();
|
|
3
|
+
const scene = {};
|
|
4
|
+
for (const record of Object.values(document.nodes))
|
|
5
|
+
scene[record.type] = (scene[record.type] ?? 0) + 1;
|
|
6
|
+
const last = renderer?.lastFrame;
|
|
7
|
+
const perf = renderer?.perf();
|
|
8
|
+
return {
|
|
9
|
+
frame: last && perf
|
|
10
|
+
? {
|
|
11
|
+
p50: perf.p50,
|
|
12
|
+
p95: perf.p95,
|
|
13
|
+
drawCalls: last.gpu.drawCalls,
|
|
14
|
+
visible: `${last.visibleNodes}/${last.nodes}`,
|
|
15
|
+
cacheHits: last.cacheHits,
|
|
16
|
+
backend: last.backend,
|
|
17
|
+
}
|
|
18
|
+
: null,
|
|
19
|
+
scene,
|
|
20
|
+
relations: Object.keys(document.relations).length,
|
|
21
|
+
selection: [...interaction.selectedIds],
|
|
22
|
+
focus: a11y.logicalFocusId,
|
|
23
|
+
history: { size: engine.history.size, canUndo: engine.history.canUndo, canRedo: engine.history.canRedo },
|
|
24
|
+
diagnostics: [
|
|
25
|
+
...engine.diagnostics.all.map((d) => `${d.code}: ${d.message}`),
|
|
26
|
+
...(style?.diagnostics ?? []).map((d) => `${d.code}: ${d.message}`),
|
|
27
|
+
...rendererDiagnostics,
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function attachDevtools(target, options) {
|
|
32
|
+
const doc = options.root.ownerDocument;
|
|
33
|
+
const panel = doc.createElement("aside");
|
|
34
|
+
panel.setAttribute("aria-label", "AVIS devtools");
|
|
35
|
+
panel.dataset.avisDevtools = "";
|
|
36
|
+
panel.style.cssText = [
|
|
37
|
+
"position:absolute;left:8px;bottom:8px;z-index:20;max-width:360px;max-height:60%;overflow:auto",
|
|
38
|
+
"padding:8px 10px;border-radius:8px;background:rgba(17,17,17,0.88);color:#f5f5f5",
|
|
39
|
+
"font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;pointer-events:auto",
|
|
40
|
+
].join(";");
|
|
41
|
+
options.root.append(panel);
|
|
42
|
+
const rendererDiagnostics = [];
|
|
43
|
+
const offDiagnostic = target.renderer?.events.on("diagnostic", (d) => rendererDiagnostics.push(`${d.code}: ${d.message}`));
|
|
44
|
+
let open = options.open ?? false;
|
|
45
|
+
let last = 0;
|
|
46
|
+
let timer = null;
|
|
47
|
+
const render = () => {
|
|
48
|
+
timer = null;
|
|
49
|
+
last = Date.now();
|
|
50
|
+
panel.style.display = open ? "block" : "none";
|
|
51
|
+
if (!open)
|
|
52
|
+
return;
|
|
53
|
+
const s = snapshotOf(target, rendererDiagnostics);
|
|
54
|
+
const lines = [
|
|
55
|
+
"AVIS devtools (Ctrl+Shift+D)",
|
|
56
|
+
s.frame
|
|
57
|
+
? `frame ${s.frame.backend} p50 ${s.frame.p50.toFixed(2)} ms · p95 ${s.frame.p95.toFixed(2)} ms · ${s.frame.drawCalls} draws · ${s.frame.visible} visible · ${s.frame.cacheHits} cached`
|
|
58
|
+
: "frame (no renderer)",
|
|
59
|
+
`scene ${Object.entries(s.scene).map(([type, n]) => `${type} ${n}`).join(" · ")} · relations ${s.relations}`,
|
|
60
|
+
`select ${s.selection.length ? s.selection.slice(0, 8).join(", ") + (s.selection.length > 8 ? " …" : "") : "—"}`,
|
|
61
|
+
`focus ${s.focus ?? "—"}`,
|
|
62
|
+
`history ${s.history.size} steps${s.history.canUndo ? " · undo" : ""}${s.history.canRedo ? " · redo" : ""}`,
|
|
63
|
+
`issues ${s.diagnostics.length ? "\n " + s.diagnostics.slice(-8).join("\n ") : "none"}`,
|
|
64
|
+
];
|
|
65
|
+
panel.textContent = lines.join("\n");
|
|
66
|
+
};
|
|
67
|
+
const schedule = () => {
|
|
68
|
+
if (timer)
|
|
69
|
+
return;
|
|
70
|
+
timer = setTimeout(render, Math.max(0, 250 - (Date.now() - last)));
|
|
71
|
+
};
|
|
72
|
+
const subscription = target.engine.store.subscribe((state) => state, schedule);
|
|
73
|
+
const offFrame = target.renderer?.events.on("frame", schedule);
|
|
74
|
+
const onKey = (event) => {
|
|
75
|
+
if (event.key.toLowerCase() === "d" && event.ctrlKey && event.shiftKey) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
toggle();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
doc.addEventListener("keydown", onKey);
|
|
81
|
+
const toggle = (next) => {
|
|
82
|
+
open = next ?? !open;
|
|
83
|
+
render();
|
|
84
|
+
};
|
|
85
|
+
render();
|
|
86
|
+
return {
|
|
87
|
+
element: panel,
|
|
88
|
+
toggle,
|
|
89
|
+
snapshot: () => snapshotOf(target, rendererDiagnostics),
|
|
90
|
+
dispose() {
|
|
91
|
+
if (timer)
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
subscription.dispose();
|
|
94
|
+
offFrame?.dispose();
|
|
95
|
+
offDiagnostic?.dispose();
|
|
96
|
+
doc.removeEventListener("keydown", onKey);
|
|
97
|
+
panel.remove();
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|