@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,91 @@
|
|
|
1
|
+
import type { NodeId, RelationId } from "../core/ids.js";
|
|
2
|
+
import type { AnchorBox } from "../geometry/anchors.js";
|
|
3
|
+
import type { Bounds } from "../geometry/bounds.js";
|
|
4
|
+
import type { Camera, WorldPoint } from "../geometry/spaces.js";
|
|
5
|
+
import { type DocumentState, type Transform } from "../scene/record.js";
|
|
6
|
+
export type ViewportState = {
|
|
7
|
+
camera: Camera;
|
|
8
|
+
/** The canvas's size in CSS pixels. */
|
|
9
|
+
size: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
dpr: number;
|
|
14
|
+
minZoom: number;
|
|
15
|
+
maxZoom: number;
|
|
16
|
+
};
|
|
17
|
+
/** A connection being dragged from an anchor (xyflow's connection state). */
|
|
18
|
+
export type ConnectionPreview = {
|
|
19
|
+
from: {
|
|
20
|
+
nodeId: NodeId;
|
|
21
|
+
anchor: AnchorBox;
|
|
22
|
+
point: WorldPoint;
|
|
23
|
+
};
|
|
24
|
+
/** The pointer, or the anchor it snapped to. */
|
|
25
|
+
to: WorldPoint;
|
|
26
|
+
/** The anchor within reach, if any, and whether a connection to it is valid. */
|
|
27
|
+
target: {
|
|
28
|
+
nodeId: NodeId;
|
|
29
|
+
anchor: AnchorBox;
|
|
30
|
+
valid: boolean;
|
|
31
|
+
} | null;
|
|
32
|
+
};
|
|
33
|
+
export type Tool = "select" | "hand";
|
|
34
|
+
export type InteractionState = {
|
|
35
|
+
tool: Tool;
|
|
36
|
+
hoveredId: NodeId | null;
|
|
37
|
+
hoveredRelationId: RelationId | null;
|
|
38
|
+
selectedIds: readonly NodeId[];
|
|
39
|
+
selectedRelationIds: readonly RelationId[];
|
|
40
|
+
/** The gesture under way (drag, marquee, connect, pan…), if any. */
|
|
41
|
+
gesture: string | null;
|
|
42
|
+
/** Transforms shown while a gesture runs; a command commits them. */
|
|
43
|
+
preview: Readonly<Record<string, Partial<Transform>>>;
|
|
44
|
+
/** Sizes shown while a resize runs. */
|
|
45
|
+
previewSize: Readonly<Record<string, {
|
|
46
|
+
w: number;
|
|
47
|
+
h: number;
|
|
48
|
+
}>>;
|
|
49
|
+
/** The selection box, in world units. */
|
|
50
|
+
marquee: Bounds | null;
|
|
51
|
+
connection: ConnectionPreview | null;
|
|
52
|
+
/** What the pointer would do here (the platform shows it). */
|
|
53
|
+
cursor: string;
|
|
54
|
+
};
|
|
55
|
+
export type A11yState = {
|
|
56
|
+
/** The node the keyboard is on (logical focus). */
|
|
57
|
+
logicalFocusId: NodeId | null;
|
|
58
|
+
/** The DOM element that has the browser's focus, mirrored. */
|
|
59
|
+
domFocusId: string | null;
|
|
60
|
+
announcements: readonly string[];
|
|
61
|
+
};
|
|
62
|
+
export type StyleState = {
|
|
63
|
+
theme: "light" | "dark";
|
|
64
|
+
tokenVersion: number;
|
|
65
|
+
/** Per node: its states for state variants (hover, selected…). */
|
|
66
|
+
nodeStates: Readonly<Record<string, readonly string[]>>;
|
|
67
|
+
};
|
|
68
|
+
export type EngineState = {
|
|
69
|
+
document: DocumentState;
|
|
70
|
+
viewport: ViewportState;
|
|
71
|
+
interaction: InteractionState;
|
|
72
|
+
a11y: A11yState;
|
|
73
|
+
style: StyleState;
|
|
74
|
+
};
|
|
75
|
+
export type MutableScope = Exclude<keyof EngineState, "document">;
|
|
76
|
+
export declare const initialState: () => EngineState;
|
|
77
|
+
export type Store = {
|
|
78
|
+
get(): EngineState;
|
|
79
|
+
set<K extends MutableScope>(scope: K, update: Partial<EngineState[K]> | ((current: EngineState[K]) => EngineState[K])): void;
|
|
80
|
+
subscribe<T>(selector: (state: EngineState) => T, listener: (value: T, previous: T) => void, options?: {
|
|
81
|
+
equals?: (a: T, b: T) => boolean;
|
|
82
|
+
fireImmediately?: boolean;
|
|
83
|
+
}): {
|
|
84
|
+
dispose(): void;
|
|
85
|
+
};
|
|
86
|
+
/** Changes inside notify once, at the end. */
|
|
87
|
+
batch<T>(run: () => T): T;
|
|
88
|
+
};
|
|
89
|
+
/** The command path's way to write the document (internal). */
|
|
90
|
+
export declare function commitDocument(store: Store, document: DocumentState): void;
|
|
91
|
+
export declare function createStore(initial?: EngineState): Store;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { emptyDocument, } from "../scene/record.js";
|
|
2
|
+
import { shallowEqual } from "./selector.js";
|
|
3
|
+
export const initialState = () => ({
|
|
4
|
+
document: emptyDocument(),
|
|
5
|
+
viewport: {
|
|
6
|
+
camera: { x: 0, y: 0, zoom: 1 },
|
|
7
|
+
size: { width: 0, height: 0 },
|
|
8
|
+
dpr: 1,
|
|
9
|
+
minZoom: 0.1,
|
|
10
|
+
maxZoom: 4,
|
|
11
|
+
},
|
|
12
|
+
interaction: {
|
|
13
|
+
tool: "select",
|
|
14
|
+
hoveredId: null,
|
|
15
|
+
hoveredRelationId: null,
|
|
16
|
+
selectedIds: [],
|
|
17
|
+
selectedRelationIds: [],
|
|
18
|
+
gesture: null,
|
|
19
|
+
preview: {},
|
|
20
|
+
previewSize: {},
|
|
21
|
+
marquee: null,
|
|
22
|
+
connection: null,
|
|
23
|
+
cursor: "default",
|
|
24
|
+
},
|
|
25
|
+
a11y: { logicalFocusId: null, domFocusId: null, announcements: [] },
|
|
26
|
+
style: { theme: "light", tokenVersion: 0, nodeStates: {} },
|
|
27
|
+
});
|
|
28
|
+
const writers = new WeakMap();
|
|
29
|
+
/** The command path's way to write the document (internal). */
|
|
30
|
+
export function commitDocument(store, document) {
|
|
31
|
+
const write = writers.get(store);
|
|
32
|
+
if (!write)
|
|
33
|
+
throw new Error("Not an engine store");
|
|
34
|
+
write(document);
|
|
35
|
+
}
|
|
36
|
+
export function createStore(initial = initialState()) {
|
|
37
|
+
let state = initial;
|
|
38
|
+
const subscriptions = new Set();
|
|
39
|
+
let depth = 0;
|
|
40
|
+
let changed = false;
|
|
41
|
+
const notify = () => {
|
|
42
|
+
if (depth > 0) {
|
|
43
|
+
changed = true;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
changed = false;
|
|
47
|
+
for (const subscription of [...subscriptions]) {
|
|
48
|
+
if (!subscriptions.has(subscription))
|
|
49
|
+
continue;
|
|
50
|
+
const next = subscription.selector(state);
|
|
51
|
+
if (subscription.equals(subscription.value, next))
|
|
52
|
+
continue;
|
|
53
|
+
const previous = subscription.value;
|
|
54
|
+
subscription.value = next;
|
|
55
|
+
subscription.listener(next, previous);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const store = {
|
|
59
|
+
get: () => state,
|
|
60
|
+
set(scope, update) {
|
|
61
|
+
const current = state[scope];
|
|
62
|
+
const next = typeof update === "function"
|
|
63
|
+
? update(current)
|
|
64
|
+
: { ...current, ...update };
|
|
65
|
+
if (shallowEqual(current, next))
|
|
66
|
+
return;
|
|
67
|
+
state = { ...state, [scope]: next };
|
|
68
|
+
notify();
|
|
69
|
+
},
|
|
70
|
+
subscribe(selector, listener, options = {}) {
|
|
71
|
+
const subscription = {
|
|
72
|
+
selector,
|
|
73
|
+
listener: listener,
|
|
74
|
+
equals: (options.equals ?? shallowEqual),
|
|
75
|
+
value: selector(state),
|
|
76
|
+
};
|
|
77
|
+
subscriptions.add(subscription);
|
|
78
|
+
if (options.fireImmediately) {
|
|
79
|
+
listener(subscription.value, subscription.value);
|
|
80
|
+
}
|
|
81
|
+
return { dispose: () => void subscriptions.delete(subscription) };
|
|
82
|
+
},
|
|
83
|
+
batch(run) {
|
|
84
|
+
depth++;
|
|
85
|
+
try {
|
|
86
|
+
return run();
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
depth--;
|
|
90
|
+
if (depth === 0 && changed)
|
|
91
|
+
notify();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
writers.set(store, (document) => {
|
|
96
|
+
if (document === state.document)
|
|
97
|
+
return;
|
|
98
|
+
state = { ...state, document };
|
|
99
|
+
notify();
|
|
100
|
+
});
|
|
101
|
+
return store;
|
|
102
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Rgba } from "../render/color.js";
|
|
2
|
+
import type { CompiledRule, Condition, Decl, StyleProp } from "./utilities.js";
|
|
3
|
+
import type { ThemeMode, TokenRegistry } from "./tokens.js";
|
|
4
|
+
import { type Shadow } from "./values.js";
|
|
5
|
+
export type StyleSize = number | {
|
|
6
|
+
percent: number;
|
|
7
|
+
} | "auto";
|
|
8
|
+
export type ComputedStyle = {
|
|
9
|
+
display: "flex" | "grid" | "block" | "none";
|
|
10
|
+
flexDirection: "row" | "column";
|
|
11
|
+
flexWrap: boolean;
|
|
12
|
+
alignItems: "start" | "center" | "end" | "stretch" | "baseline";
|
|
13
|
+
alignSelf: "auto" | "start" | "center" | "end" | "stretch" | "baseline";
|
|
14
|
+
justifyContent: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
15
|
+
gapX: number;
|
|
16
|
+
gapY: number;
|
|
17
|
+
gridCols: number;
|
|
18
|
+
colSpan: number;
|
|
19
|
+
padding: [number, number, number, number];
|
|
20
|
+
margin: [number, number, number, number];
|
|
21
|
+
/** Auto margins (top, right, bottom, left) take the free space in flex. */
|
|
22
|
+
marginAuto: [boolean, boolean, boolean, boolean];
|
|
23
|
+
width: StyleSize;
|
|
24
|
+
height: StyleSize;
|
|
25
|
+
minWidth: StyleSize;
|
|
26
|
+
minHeight: StyleSize;
|
|
27
|
+
maxWidth: StyleSize;
|
|
28
|
+
maxHeight: StyleSize;
|
|
29
|
+
grow: number;
|
|
30
|
+
shrink: number;
|
|
31
|
+
basis: StyleSize;
|
|
32
|
+
position: "relative" | "absolute";
|
|
33
|
+
inset: [StyleSize, StyleSize, StyleSize, StyleSize];
|
|
34
|
+
background: Rgba | null;
|
|
35
|
+
color: Rgba;
|
|
36
|
+
borderWidth: number;
|
|
37
|
+
borderColor: Rgba;
|
|
38
|
+
radius: number;
|
|
39
|
+
opacity: number;
|
|
40
|
+
shadows: Shadow[];
|
|
41
|
+
ring: {
|
|
42
|
+
width: number;
|
|
43
|
+
color: Rgba;
|
|
44
|
+
} | null;
|
|
45
|
+
fontFamily: string;
|
|
46
|
+
fontSize: number;
|
|
47
|
+
fontWeight: number;
|
|
48
|
+
/** px */
|
|
49
|
+
lineHeight: number;
|
|
50
|
+
/** px */
|
|
51
|
+
letterSpacing: number;
|
|
52
|
+
textAlign: "left" | "center" | "right";
|
|
53
|
+
truncate: boolean;
|
|
54
|
+
lineClamp: number;
|
|
55
|
+
overflowHidden: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** What state variants test (the Behavior Engine's state for the element). */
|
|
58
|
+
export type ElementState = {
|
|
59
|
+
hover?: boolean;
|
|
60
|
+
active?: boolean;
|
|
61
|
+
focus?: boolean;
|
|
62
|
+
focusVisible?: boolean;
|
|
63
|
+
focusWithin?: boolean;
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** data-* (and aria-*) attributes: `selected`, `dragging`, `state`… */
|
|
66
|
+
data?: Readonly<Record<string, string | boolean | undefined>>;
|
|
67
|
+
/** The group's state, for `group-hover:` and `group-data-[…]:` (the node's). */
|
|
68
|
+
group?: Omit<ElementState, "group">;
|
|
69
|
+
};
|
|
70
|
+
export type ComputeContext = {
|
|
71
|
+
tokens: TokenRegistry;
|
|
72
|
+
mode: ThemeMode;
|
|
73
|
+
parent?: ComputedStyle | null;
|
|
74
|
+
report?: (diagnostic: {
|
|
75
|
+
code: string;
|
|
76
|
+
message: string;
|
|
77
|
+
}) => void;
|
|
78
|
+
};
|
|
79
|
+
export declare function matches(condition: Condition, state: ElementState, mode: ThemeMode): boolean;
|
|
80
|
+
/** The engine defaults (Tailwind's preflight, shadcn's base layer). */
|
|
81
|
+
export declare function defaultStyle(ctx: ComputeContext): ComputedStyle;
|
|
82
|
+
/** The declarations that win, per property, in precedence order. */
|
|
83
|
+
export declare function winningDecls(rules: readonly CompiledRule[], state: ElementState, mode: ThemeMode): Map<StyleProp, Decl>;
|
|
84
|
+
export declare function computeStyle(rules: readonly CompiledRule[], state: ElementState, ctx: ComputeContext, explicit?: Partial<ComputedStyle>, overrides?: Partial<ComputedStyle>): ComputedStyle;
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { withOpacity } from "./values.js";
|
|
2
|
+
const INHERITED = ["color", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign"];
|
|
3
|
+
export function matches(condition, state, mode) {
|
|
4
|
+
if (condition.kind !== "mode" && condition.group) {
|
|
5
|
+
return matches({ ...condition, group: false }, state.group ?? {}, mode);
|
|
6
|
+
}
|
|
7
|
+
switch (condition.kind) {
|
|
8
|
+
case "mode":
|
|
9
|
+
return condition.mode === mode;
|
|
10
|
+
case "state":
|
|
11
|
+
return Boolean({
|
|
12
|
+
hover: state.hover,
|
|
13
|
+
active: state.active,
|
|
14
|
+
focus: state.focus,
|
|
15
|
+
"focus-visible": state.focusVisible,
|
|
16
|
+
"focus-within": state.focusWithin || state.focus,
|
|
17
|
+
disabled: state.disabled,
|
|
18
|
+
}[condition.name]);
|
|
19
|
+
case "data": {
|
|
20
|
+
const value = state.data?.[condition.key];
|
|
21
|
+
if (value === undefined || value === false)
|
|
22
|
+
return condition.value === "false" && value === false;
|
|
23
|
+
return condition.value === null || String(value) === condition.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The engine defaults (Tailwind's preflight, shadcn's base layer). */
|
|
28
|
+
export function defaultStyle(ctx) {
|
|
29
|
+
const { tokens, mode } = ctx;
|
|
30
|
+
const fontSize = 16;
|
|
31
|
+
return {
|
|
32
|
+
display: "block",
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
flexWrap: false,
|
|
35
|
+
alignItems: "stretch",
|
|
36
|
+
alignSelf: "auto",
|
|
37
|
+
justifyContent: "start",
|
|
38
|
+
gapX: 0,
|
|
39
|
+
gapY: 0,
|
|
40
|
+
gridCols: 1,
|
|
41
|
+
colSpan: 1,
|
|
42
|
+
padding: [0, 0, 0, 0],
|
|
43
|
+
margin: [0, 0, 0, 0],
|
|
44
|
+
marginAuto: [false, false, false, false],
|
|
45
|
+
width: "auto",
|
|
46
|
+
height: "auto",
|
|
47
|
+
minWidth: 0,
|
|
48
|
+
minHeight: 0,
|
|
49
|
+
maxWidth: "auto",
|
|
50
|
+
maxHeight: "auto",
|
|
51
|
+
grow: 0,
|
|
52
|
+
shrink: 1,
|
|
53
|
+
basis: "auto",
|
|
54
|
+
position: "relative",
|
|
55
|
+
inset: ["auto", "auto", "auto", "auto"],
|
|
56
|
+
background: null,
|
|
57
|
+
color: tokens.color("var(--color-foreground, #000)", mode) ?? [0, 0, 0, 1],
|
|
58
|
+
borderWidth: 0,
|
|
59
|
+
borderColor: tokens.color("var(--color-border, #e5e5e5)", mode) ?? [0.9, 0.9, 0.9, 1],
|
|
60
|
+
radius: 0,
|
|
61
|
+
opacity: 1,
|
|
62
|
+
shadows: [],
|
|
63
|
+
ring: null,
|
|
64
|
+
fontFamily: tokens.resolve("var(--font-sans, system-ui, sans-serif)", mode) ?? "system-ui, sans-serif",
|
|
65
|
+
fontSize,
|
|
66
|
+
fontWeight: 400,
|
|
67
|
+
lineHeight: fontSize * 1.5,
|
|
68
|
+
letterSpacing: 0,
|
|
69
|
+
textAlign: "left",
|
|
70
|
+
truncate: false,
|
|
71
|
+
lineClamp: 0,
|
|
72
|
+
overflowHidden: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** The declarations that win, per property, in precedence order. */
|
|
76
|
+
export function winningDecls(rules, state, mode) {
|
|
77
|
+
const winners = new Map();
|
|
78
|
+
const apply = (rule) => {
|
|
79
|
+
for (const decl of rule.decls)
|
|
80
|
+
winners.set(decl.prop, decl);
|
|
81
|
+
};
|
|
82
|
+
for (const rule of rules)
|
|
83
|
+
if (!rule.conditions.length)
|
|
84
|
+
apply(rule);
|
|
85
|
+
for (const rule of rules) {
|
|
86
|
+
if (rule.conditions.length && rule.conditions.every((c) => matches(c, state, mode)))
|
|
87
|
+
apply(rule);
|
|
88
|
+
}
|
|
89
|
+
return winners;
|
|
90
|
+
}
|
|
91
|
+
export function computeStyle(rules, state, ctx, explicit, overrides) {
|
|
92
|
+
const { tokens, mode } = ctx;
|
|
93
|
+
const style = defaultStyle(ctx);
|
|
94
|
+
if (ctx.parent)
|
|
95
|
+
for (const key of INHERITED)
|
|
96
|
+
style[key] = ctx.parent[key];
|
|
97
|
+
const winners = winningDecls(rules, state, mode);
|
|
98
|
+
const fail = (decl) => ctx.report?.({ code: "style.value", message: `Can't resolve ${decl.prop}: ${decl.value} in ${mode}` });
|
|
99
|
+
const length = (decl, options = {}) => {
|
|
100
|
+
const value = tokens.length(decl.value, mode, options);
|
|
101
|
+
if (value === null)
|
|
102
|
+
fail(decl);
|
|
103
|
+
return value;
|
|
104
|
+
};
|
|
105
|
+
const size = (decl) => {
|
|
106
|
+
if (decl.value === "auto")
|
|
107
|
+
return "auto";
|
|
108
|
+
if (/^-?[\d.]+%$/.test(decl.value.trim()))
|
|
109
|
+
return { percent: parseFloat(decl.value) };
|
|
110
|
+
return length(decl);
|
|
111
|
+
};
|
|
112
|
+
const colorOf = (decl) => {
|
|
113
|
+
if (decl.value === "currentcolor")
|
|
114
|
+
return style.color;
|
|
115
|
+
const value = tokens.color(decl.value, mode);
|
|
116
|
+
if (!value) {
|
|
117
|
+
fail(decl);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return decl.alpha === undefined ? value : withOpacity(value, decl.alpha);
|
|
121
|
+
};
|
|
122
|
+
const get = (prop) => winners.get(prop);
|
|
123
|
+
// Font size first: em values (tracking) and line heights depend on it.
|
|
124
|
+
const fontSize = get("fontSize");
|
|
125
|
+
if (fontSize)
|
|
126
|
+
style.fontSize = length(fontSize) ?? style.fontSize;
|
|
127
|
+
const lineHeight = get("lineHeight");
|
|
128
|
+
if (lineHeight) {
|
|
129
|
+
const resolved = tokens.resolve(lineHeight.value, mode);
|
|
130
|
+
const unitless = resolved !== null && !/(px|rem|em|%)/.test(resolved);
|
|
131
|
+
const value = unitless ? tokens.number(lineHeight.value, mode) : length(lineHeight);
|
|
132
|
+
if (value !== null)
|
|
133
|
+
style.lineHeight = unitless ? value * style.fontSize : value;
|
|
134
|
+
}
|
|
135
|
+
else if (fontSize) {
|
|
136
|
+
style.lineHeight = style.fontSize * 1.5;
|
|
137
|
+
}
|
|
138
|
+
// Colour before currentcolor users.
|
|
139
|
+
const textColor = get("color");
|
|
140
|
+
if (textColor)
|
|
141
|
+
style.color = colorOf(textColor) ?? style.color;
|
|
142
|
+
for (const [prop, decl] of winners) {
|
|
143
|
+
switch (prop) {
|
|
144
|
+
case "fontSize":
|
|
145
|
+
case "lineHeight":
|
|
146
|
+
case "color":
|
|
147
|
+
break;
|
|
148
|
+
case "display":
|
|
149
|
+
style.display = decl.value;
|
|
150
|
+
break;
|
|
151
|
+
case "flexDirection":
|
|
152
|
+
style.flexDirection = decl.value;
|
|
153
|
+
break;
|
|
154
|
+
case "flexWrap":
|
|
155
|
+
style.flexWrap = decl.value === "wrap";
|
|
156
|
+
break;
|
|
157
|
+
case "alignItems":
|
|
158
|
+
style.alignItems = decl.value;
|
|
159
|
+
break;
|
|
160
|
+
case "alignSelf":
|
|
161
|
+
style.alignSelf = decl.value;
|
|
162
|
+
break;
|
|
163
|
+
case "justifyContent":
|
|
164
|
+
style.justifyContent = decl.value;
|
|
165
|
+
break;
|
|
166
|
+
case "gapX":
|
|
167
|
+
case "gapY":
|
|
168
|
+
case "borderWidth":
|
|
169
|
+
case "radius":
|
|
170
|
+
case "ringWidth":
|
|
171
|
+
{
|
|
172
|
+
const value = length(decl);
|
|
173
|
+
if (value === null)
|
|
174
|
+
break;
|
|
175
|
+
if (prop === "ringWidth")
|
|
176
|
+
style.ring = { width: value, color: style.ring?.color ?? colorOf({ prop, value: "var(--color-ring, currentcolor)" }) ?? style.color };
|
|
177
|
+
else
|
|
178
|
+
style[prop] = value;
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case "ringColor": {
|
|
182
|
+
const value = colorOf(decl);
|
|
183
|
+
if (value)
|
|
184
|
+
style.ring = { width: style.ring?.width ?? 0, color: value };
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case "paddingTop":
|
|
188
|
+
case "paddingRight":
|
|
189
|
+
case "paddingBottom":
|
|
190
|
+
case "paddingLeft":
|
|
191
|
+
case "marginTop":
|
|
192
|
+
case "marginRight":
|
|
193
|
+
case "marginBottom":
|
|
194
|
+
case "marginLeft": {
|
|
195
|
+
const side = ["Top", "Right", "Bottom", "Left"].findIndex((name) => prop.endsWith(name));
|
|
196
|
+
if (prop.startsWith("margin")) {
|
|
197
|
+
style.marginAuto = [...style.marginAuto];
|
|
198
|
+
style.marginAuto[side] = decl.value === "auto";
|
|
199
|
+
}
|
|
200
|
+
const value = decl.value === "auto" ? 0 : length(decl);
|
|
201
|
+
if (value === null)
|
|
202
|
+
break;
|
|
203
|
+
if (prop.startsWith("padding")) {
|
|
204
|
+
style.padding = [...style.padding];
|
|
205
|
+
style.padding[side] = value;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
style.margin = [...style.margin];
|
|
209
|
+
style.margin[side] = value;
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case "width":
|
|
214
|
+
case "height":
|
|
215
|
+
case "minWidth":
|
|
216
|
+
case "minHeight":
|
|
217
|
+
case "maxWidth":
|
|
218
|
+
case "maxHeight":
|
|
219
|
+
case "basis": {
|
|
220
|
+
const value = size(decl);
|
|
221
|
+
if (value !== null)
|
|
222
|
+
style[prop] = value;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case "top":
|
|
226
|
+
case "right":
|
|
227
|
+
case "bottom":
|
|
228
|
+
case "left": {
|
|
229
|
+
const value = size(decl);
|
|
230
|
+
if (value !== null)
|
|
231
|
+
style.inset[["top", "right", "bottom", "left"].indexOf(prop)] = value;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case "position":
|
|
235
|
+
style.position = decl.value;
|
|
236
|
+
break;
|
|
237
|
+
case "gridCols":
|
|
238
|
+
case "colSpan":
|
|
239
|
+
case "grow":
|
|
240
|
+
case "shrink":
|
|
241
|
+
case "lineClamp":
|
|
242
|
+
style[prop] = Number(decl.value);
|
|
243
|
+
break;
|
|
244
|
+
case "opacity":
|
|
245
|
+
style.opacity = Number(decl.value);
|
|
246
|
+
break;
|
|
247
|
+
case "background":
|
|
248
|
+
style.background = colorOf(decl);
|
|
249
|
+
break;
|
|
250
|
+
case "borderColor":
|
|
251
|
+
style.borderColor = colorOf(decl) ?? style.borderColor;
|
|
252
|
+
break;
|
|
253
|
+
case "shadow": {
|
|
254
|
+
const value = tokens.shadows(decl.value, mode);
|
|
255
|
+
if (value)
|
|
256
|
+
style.shadows = value;
|
|
257
|
+
else
|
|
258
|
+
fail(decl);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case "fontFamily":
|
|
262
|
+
style.fontFamily = tokens.resolve(decl.value, mode) ?? style.fontFamily;
|
|
263
|
+
break;
|
|
264
|
+
case "fontWeight": {
|
|
265
|
+
const value = tokens.number(decl.value, mode);
|
|
266
|
+
if (value !== null)
|
|
267
|
+
style.fontWeight = value;
|
|
268
|
+
else
|
|
269
|
+
fail(decl);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case "letterSpacing": {
|
|
273
|
+
const value = length(decl, { fontSize: style.fontSize });
|
|
274
|
+
if (value !== null)
|
|
275
|
+
style.letterSpacing = value;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case "textAlign":
|
|
279
|
+
style.textAlign = decl.value;
|
|
280
|
+
break;
|
|
281
|
+
case "truncate":
|
|
282
|
+
style.truncate = true;
|
|
283
|
+
break;
|
|
284
|
+
case "overflow":
|
|
285
|
+
style.overflowHidden = decl.value === "hidden";
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (style.ring && style.ring.width <= 0)
|
|
290
|
+
style.ring = null;
|
|
291
|
+
if (explicit)
|
|
292
|
+
Object.assign(style, explicit);
|
|
293
|
+
if (overrides)
|
|
294
|
+
Object.assign(style, overrides);
|
|
295
|
+
return style;
|
|
296
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// AVIS Engine · style — Phase 4: tokens from CSS, the utility compiler,
|
|
2
|
+
// computed styles, variants and the styling engine (docs/avis-engine/STYLING.md).
|
|
3
|
+
export * from "./values.js";
|
|
4
|
+
export * from "./tokens.js";
|
|
5
|
+
export * from "./utilities.js";
|
|
6
|
+
export * from "./computed.js";
|
|
7
|
+
export * from "./variants.js";
|
|
8
|
+
export * from "./style-engine.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Engine } from "../core/engine.js";
|
|
2
|
+
import type { Plugin } from "../core/plugin.js";
|
|
3
|
+
import { type ComputedStyle, type ElementState } from "./computed.js";
|
|
4
|
+
import type { ThemeMode, TokenRegistry } from "./tokens.js";
|
|
5
|
+
import { type CompiledRule } from "./utilities.js";
|
|
6
|
+
export type StyleDiagnostic = {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export type StyleEngine = {
|
|
12
|
+
readonly tokens: TokenRegistry;
|
|
13
|
+
mode(): ThemeMode;
|
|
14
|
+
setMode(mode: ThemeMode): void;
|
|
15
|
+
compile(classes: string): readonly CompiledRule[];
|
|
16
|
+
compute(classes: string, state?: ElementState, options?: {
|
|
17
|
+
parent?: ComputedStyle | null;
|
|
18
|
+
style?: Partial<ComputedStyle>;
|
|
19
|
+
overrides?: Partial<ComputedStyle>;
|
|
20
|
+
}): ComputedStyle;
|
|
21
|
+
/** Each problem once: unsupported utilities and variants, unresolved tokens. */
|
|
22
|
+
readonly diagnostics: readonly StyleDiagnostic[];
|
|
23
|
+
/** Changes when the mode or tokens change (paint caches key on it). */
|
|
24
|
+
version(): string;
|
|
25
|
+
};
|
|
26
|
+
export declare const StyleKey: import("../index.js").ServiceKey<StyleEngine>;
|
|
27
|
+
export declare function createStyleEngine(tokens: TokenRegistry, options?: {
|
|
28
|
+
mode?: () => ThemeMode;
|
|
29
|
+
setMode?: (mode: ThemeMode) => void;
|
|
30
|
+
maxCache?: number;
|
|
31
|
+
}): StyleEngine;
|
|
32
|
+
/** The styling engine on an engine: its mode is the store's `style.theme`. */
|
|
33
|
+
export declare function stylePlugin(tokens: TokenRegistry, initialMode?: ThemeMode): Plugin<Engine>;
|