@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,113 @@
|
|
|
1
|
+
import { serviceKey } from "../core/services.js";
|
|
2
|
+
import { computeStyle } from "./computed.js";
|
|
3
|
+
import { compileClasses } from "./utilities.js";
|
|
4
|
+
export const StyleKey = serviceKey("style");
|
|
5
|
+
const stateKey = (state) => {
|
|
6
|
+
let key = "";
|
|
7
|
+
if (state.hover)
|
|
8
|
+
key += "h";
|
|
9
|
+
if (state.active)
|
|
10
|
+
key += "a";
|
|
11
|
+
if (state.focus)
|
|
12
|
+
key += "f";
|
|
13
|
+
if (state.focusVisible)
|
|
14
|
+
key += "v";
|
|
15
|
+
if (state.focusWithin)
|
|
16
|
+
key += "w";
|
|
17
|
+
if (state.disabled)
|
|
18
|
+
key += "d";
|
|
19
|
+
if (state.data) {
|
|
20
|
+
for (const name of Object.keys(state.data).sort()) {
|
|
21
|
+
const value = state.data[name];
|
|
22
|
+
if (value !== undefined && value !== false)
|
|
23
|
+
key += `|${name}=${value}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (state.group)
|
|
27
|
+
key += `[${stateKey(state.group)}]`;
|
|
28
|
+
return key;
|
|
29
|
+
};
|
|
30
|
+
const parentKeys = new WeakMap();
|
|
31
|
+
let nextParent = 1;
|
|
32
|
+
const parentKey = (parent) => {
|
|
33
|
+
if (!parent)
|
|
34
|
+
return 0;
|
|
35
|
+
let key = parentKeys.get(parent);
|
|
36
|
+
if (!key) {
|
|
37
|
+
key = nextParent++;
|
|
38
|
+
parentKeys.set(parent, key);
|
|
39
|
+
}
|
|
40
|
+
return key;
|
|
41
|
+
};
|
|
42
|
+
export function createStyleEngine(tokens, options = {}) {
|
|
43
|
+
let localMode = "light";
|
|
44
|
+
const getMode = options.mode ?? (() => localMode);
|
|
45
|
+
const setMode = options.setMode ?? ((mode) => void (localMode = mode));
|
|
46
|
+
const compiled = new Map();
|
|
47
|
+
const computed = new Map();
|
|
48
|
+
const diagnostics = [];
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
const report = (diagnostic) => {
|
|
51
|
+
const key = `${diagnostic.code}|${"className" in diagnostic ? diagnostic.className : ""}|${diagnostic.message}`;
|
|
52
|
+
if (seen.has(key))
|
|
53
|
+
return;
|
|
54
|
+
seen.add(key);
|
|
55
|
+
diagnostics.push(diagnostic);
|
|
56
|
+
};
|
|
57
|
+
let tokenVersion = tokens.version;
|
|
58
|
+
const max = options.maxCache ?? 20000;
|
|
59
|
+
const compile = (classes) => {
|
|
60
|
+
let rules = compiled.get(classes);
|
|
61
|
+
if (!rules) {
|
|
62
|
+
rules = compileClasses(classes, report);
|
|
63
|
+
compiled.set(classes, rules);
|
|
64
|
+
}
|
|
65
|
+
return rules;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
tokens,
|
|
69
|
+
mode: getMode,
|
|
70
|
+
setMode,
|
|
71
|
+
compile,
|
|
72
|
+
compute(classes, state = {}, opts = {}) {
|
|
73
|
+
if (tokens.version !== tokenVersion) {
|
|
74
|
+
computed.clear();
|
|
75
|
+
tokenVersion = tokens.version;
|
|
76
|
+
}
|
|
77
|
+
const mode = getMode();
|
|
78
|
+
const cacheable = !opts.style && !opts.overrides;
|
|
79
|
+
const key = `${mode}|${parentKey(opts.parent)}|${stateKey(state)}|${classes}`;
|
|
80
|
+
if (cacheable) {
|
|
81
|
+
const hit = computed.get(key);
|
|
82
|
+
if (hit)
|
|
83
|
+
return hit;
|
|
84
|
+
}
|
|
85
|
+
const style = computeStyle(compile(classes), state, { tokens, mode, parent: opts.parent, report }, opts.style, opts.overrides);
|
|
86
|
+
if (cacheable) {
|
|
87
|
+
if (computed.size > max)
|
|
88
|
+
computed.clear();
|
|
89
|
+
computed.set(key, style);
|
|
90
|
+
}
|
|
91
|
+
return style;
|
|
92
|
+
},
|
|
93
|
+
diagnostics,
|
|
94
|
+
version: () => `${getMode()}:${tokens.version}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** The styling engine on an engine: its mode is the store's `style.theme`. */
|
|
98
|
+
export function stylePlugin(tokens, initialMode) {
|
|
99
|
+
return {
|
|
100
|
+
name: "style",
|
|
101
|
+
setup({ engine, track }) {
|
|
102
|
+
if (initialMode)
|
|
103
|
+
engine.store.set("style", { theme: initialMode });
|
|
104
|
+
const style = createStyleEngine(tokens, {
|
|
105
|
+
mode: () => engine.store.get().style.theme,
|
|
106
|
+
setMode: (mode) => engine.store.set("style", { theme: mode }),
|
|
107
|
+
});
|
|
108
|
+
track(engine.services.register(StyleKey, style));
|
|
109
|
+
// Token changes reach the store, so renderers and the DOM layer hear them.
|
|
110
|
+
track(tokens.onChange(() => engine.store.set("style", (current) => ({ ...current, tokenVersion: tokens.version }))));
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Rgba } from "../render/color.js";
|
|
2
|
+
import { type Shadow } from "./values.js";
|
|
3
|
+
export type ThemeMode = "light" | "dark";
|
|
4
|
+
export type TokenDiagnostic = {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
};
|
|
9
|
+
/** Custom properties in the base and dark blocks of CSS sources, in order. */
|
|
10
|
+
export declare function readTokenCss(sources: readonly string[]): {
|
|
11
|
+
base: Record<string, string>;
|
|
12
|
+
dark: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
export declare class TokenRegistry {
|
|
15
|
+
private base;
|
|
16
|
+
private modes;
|
|
17
|
+
private cache;
|
|
18
|
+
private listeners;
|
|
19
|
+
/** Bumps on every change (computed styles and paints key on it). */
|
|
20
|
+
version: number;
|
|
21
|
+
constructor(base?: Record<string, string>, modes?: Partial<Record<ThemeMode, Record<string, string>>>);
|
|
22
|
+
/** Tokens from CSS sources, in order (later ones win). */
|
|
23
|
+
static fromCss(sources: readonly string[]): TokenRegistry;
|
|
24
|
+
get names(): string[];
|
|
25
|
+
/** The token's own text in a mode (aliases left in). */
|
|
26
|
+
raw(name: string, mode?: ThemeMode): string | undefined;
|
|
27
|
+
has(name: string, mode?: ThemeMode): boolean;
|
|
28
|
+
/** Runtime theme changes: one token, in one mode or the base. */
|
|
29
|
+
set(name: string, value: string, mode?: ThemeMode): void;
|
|
30
|
+
/** Called after every `set`. */
|
|
31
|
+
onChange(listener: () => void): {
|
|
32
|
+
dispose: () => undefined;
|
|
33
|
+
};
|
|
34
|
+
/** Text with every var() resolved for the mode, or null. */
|
|
35
|
+
resolve(text: string, mode?: ThemeMode): string | null;
|
|
36
|
+
private cached;
|
|
37
|
+
color(text: string, mode?: ThemeMode): Rgba | null;
|
|
38
|
+
/** Px; `%` needs `percentOf`, `em` uses `fontSize`. */
|
|
39
|
+
length(text: string, mode?: ThemeMode, options?: {
|
|
40
|
+
fontSize?: number;
|
|
41
|
+
percentOf?: number;
|
|
42
|
+
}): number | null;
|
|
43
|
+
number(text: string, mode?: ThemeMode): number | null;
|
|
44
|
+
shadows(text: string, mode?: ThemeMode): Shadow[] | null;
|
|
45
|
+
/** Every token as a resolved custom property, for DOM components in the mode. */
|
|
46
|
+
cssVariables(mode?: ThemeMode): Record<string, string>;
|
|
47
|
+
/** Tokens that can't be resolved in a mode (missing aliases, cycles). */
|
|
48
|
+
check(mode?: ThemeMode): TokenDiagnostic[];
|
|
49
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { evalColor, evalLength, evalNumber, evalShadows, substituteVars } from "./values.js";
|
|
2
|
+
const SKIPPED_AT_RULES = /^@(media|utility|keyframes|supports|container|font-face|property|custom-variant)\b/;
|
|
3
|
+
/** Custom properties in the base and dark blocks of CSS sources, in order. */
|
|
4
|
+
export function readTokenCss(sources) {
|
|
5
|
+
const base = {};
|
|
6
|
+
const dark = {};
|
|
7
|
+
for (const source of sources) {
|
|
8
|
+
const css = source.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
9
|
+
const stack = [];
|
|
10
|
+
let buffer = "";
|
|
11
|
+
const flush = () => {
|
|
12
|
+
const text = buffer.trim();
|
|
13
|
+
buffer = "";
|
|
14
|
+
const m = /^(--[\w-]+)\s*:\s*([\s\S]*)$/.exec(text);
|
|
15
|
+
if (!m || !stack.length)
|
|
16
|
+
return;
|
|
17
|
+
if (stack.some((selector) => SKIPPED_AT_RULES.test(selector)))
|
|
18
|
+
return;
|
|
19
|
+
const selector = stack[stack.length - 1];
|
|
20
|
+
const selectors = selector.split(",").map((part) => part.trim());
|
|
21
|
+
const value = m[2].replace(/\s+/g, " ").trim();
|
|
22
|
+
if (selector.startsWith("@theme") || selectors.some((part) => part === ":root" || part === ":host")) {
|
|
23
|
+
base[m[1]] = value;
|
|
24
|
+
}
|
|
25
|
+
else if (selectors.includes(".dark")) {
|
|
26
|
+
dark[m[1]] = value;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
let depth = 0;
|
|
30
|
+
for (let i = 0; i < css.length; i++) {
|
|
31
|
+
const c = css[i];
|
|
32
|
+
if (c === "(")
|
|
33
|
+
depth++;
|
|
34
|
+
if (c === ")")
|
|
35
|
+
depth--;
|
|
36
|
+
if (c === "{" && depth === 0) {
|
|
37
|
+
stack.push(buffer.trim());
|
|
38
|
+
buffer = "";
|
|
39
|
+
}
|
|
40
|
+
else if (c === "}" && depth === 0) {
|
|
41
|
+
flush();
|
|
42
|
+
stack.pop();
|
|
43
|
+
}
|
|
44
|
+
else if (c === ";" && depth === 0) {
|
|
45
|
+
flush();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
buffer += c;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { base, dark };
|
|
53
|
+
}
|
|
54
|
+
export class TokenRegistry {
|
|
55
|
+
base;
|
|
56
|
+
modes;
|
|
57
|
+
cache = new Map();
|
|
58
|
+
listeners = new Set();
|
|
59
|
+
/** Bumps on every change (computed styles and paints key on it). */
|
|
60
|
+
version = 0;
|
|
61
|
+
constructor(base = {}, modes = {}) {
|
|
62
|
+
this.base = { ...base };
|
|
63
|
+
this.modes = { light: { ...modes.light }, dark: { ...modes.dark } };
|
|
64
|
+
}
|
|
65
|
+
/** Tokens from CSS sources, in order (later ones win). */
|
|
66
|
+
static fromCss(sources) {
|
|
67
|
+
const { base, dark } = readTokenCss(sources);
|
|
68
|
+
return new TokenRegistry(base, { dark });
|
|
69
|
+
}
|
|
70
|
+
get names() {
|
|
71
|
+
return [...new Set([...Object.keys(this.base), ...Object.keys(this.modes.dark), ...Object.keys(this.modes.light)])];
|
|
72
|
+
}
|
|
73
|
+
/** The token's own text in a mode (aliases left in). */
|
|
74
|
+
raw(name, mode = "light") {
|
|
75
|
+
return this.modes[mode][name] ?? this.base[name];
|
|
76
|
+
}
|
|
77
|
+
has(name, mode = "light") {
|
|
78
|
+
return this.raw(name, mode) !== undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Runtime theme changes: one token, in one mode or the base. */
|
|
81
|
+
set(name, value, mode) {
|
|
82
|
+
if (mode)
|
|
83
|
+
this.modes[mode][name] = value;
|
|
84
|
+
else
|
|
85
|
+
this.base[name] = value;
|
|
86
|
+
this.cache.clear();
|
|
87
|
+
this.version++;
|
|
88
|
+
for (const listener of this.listeners)
|
|
89
|
+
listener();
|
|
90
|
+
}
|
|
91
|
+
/** Called after every `set`. */
|
|
92
|
+
onChange(listener) {
|
|
93
|
+
this.listeners.add(listener);
|
|
94
|
+
return { dispose: () => void this.listeners.delete(listener) };
|
|
95
|
+
}
|
|
96
|
+
/** Text with every var() resolved for the mode, or null. */
|
|
97
|
+
resolve(text, mode = "light") {
|
|
98
|
+
return substituteVars(text, (name) => this.raw(name, mode));
|
|
99
|
+
}
|
|
100
|
+
cached(kind, text, mode, compute) {
|
|
101
|
+
const key = `${kind}|${mode}|${text}`;
|
|
102
|
+
if (this.cache.has(key))
|
|
103
|
+
return this.cache.get(key);
|
|
104
|
+
const resolved = this.resolve(text, mode);
|
|
105
|
+
const value = resolved === null ? null : compute(resolved);
|
|
106
|
+
this.cache.set(key, value);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
color(text, mode = "light") {
|
|
110
|
+
return this.cached("color", text, mode, evalColor);
|
|
111
|
+
}
|
|
112
|
+
/** Px; `%` needs `percentOf`, `em` uses `fontSize`. */
|
|
113
|
+
length(text, mode = "light", options = {}) {
|
|
114
|
+
if (options.percentOf !== undefined || options.fontSize !== undefined) {
|
|
115
|
+
const resolved = this.resolve(text, mode);
|
|
116
|
+
return resolved === null ? null : evalLength(resolved, options);
|
|
117
|
+
}
|
|
118
|
+
return this.cached("length", text, mode, (resolved) => evalLength(resolved));
|
|
119
|
+
}
|
|
120
|
+
number(text, mode = "light") {
|
|
121
|
+
return this.cached("number", text, mode, evalNumber);
|
|
122
|
+
}
|
|
123
|
+
shadows(text, mode = "light") {
|
|
124
|
+
return this.cached("shadows", text, mode, evalShadows);
|
|
125
|
+
}
|
|
126
|
+
/** Every token as a resolved custom property, for DOM components in the mode. */
|
|
127
|
+
cssVariables(mode = "light") {
|
|
128
|
+
const out = {};
|
|
129
|
+
for (const name of this.names) {
|
|
130
|
+
const value = this.resolve(`var(${name})`, mode);
|
|
131
|
+
if (value !== null)
|
|
132
|
+
out[name] = value;
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
/** Tokens that can't be resolved in a mode (missing aliases, cycles). */
|
|
137
|
+
check(mode = "light") {
|
|
138
|
+
return this.names.flatMap((name) => this.resolve(`var(${name})`, mode) === null
|
|
139
|
+
? [{ code: "token.unresolved", message: `Token ${name} can't be resolved in ${mode}`, token: name }]
|
|
140
|
+
: []);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type StyleProp = "display" | "flexDirection" | "flexWrap" | "alignItems" | "alignSelf" | "justifyContent" | "gapX" | "gapY" | "gridCols" | "colSpan" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "width" | "height" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "grow" | "shrink" | "basis" | "position" | "top" | "right" | "bottom" | "left" | "background" | "color" | "borderWidth" | "borderColor" | "radius" | "opacity" | "shadow" | "ringWidth" | "ringColor" | "fontFamily" | "fontSize" | "fontWeight" | "lineHeight" | "letterSpacing" | "textAlign" | "truncate" | "lineClamp" | "overflow";
|
|
2
|
+
/** A value: a keyword, or a CSS expression for the token registry. */
|
|
3
|
+
export type Decl = {
|
|
4
|
+
prop: StyleProp;
|
|
5
|
+
value: string;
|
|
6
|
+
alpha?: number;
|
|
7
|
+
};
|
|
8
|
+
export type Condition = {
|
|
9
|
+
kind: "state";
|
|
10
|
+
name: "hover" | "active" | "focus" | "focus-visible" | "focus-within" | "disabled";
|
|
11
|
+
group?: boolean;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "mode";
|
|
14
|
+
mode: "light" | "dark";
|
|
15
|
+
} | {
|
|
16
|
+
kind: "data";
|
|
17
|
+
key: string;
|
|
18
|
+
value: string | null;
|
|
19
|
+
group?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type CompiledRule = {
|
|
22
|
+
conditions: Condition[];
|
|
23
|
+
decls: Decl[];
|
|
24
|
+
className: string;
|
|
25
|
+
};
|
|
26
|
+
export type CompileDiagnostic = {
|
|
27
|
+
code: "style.unsupported" | "style.variant";
|
|
28
|
+
className: string;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
/** One utility (no variants) → declarations, or null when unsupported. */
|
|
32
|
+
export declare function utility(name: string): Decl[] | null;
|
|
33
|
+
/** Compiles a class string, in order. Unsupported parts go to `report`. */
|
|
34
|
+
export declare function compileClasses(classes: string, report?: (diagnostic: CompileDiagnostic) => void): CompiledRule[];
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The utility compiler (spec §4.2–4.3): class names → declarations with the
|
|
3
|
+
* conditions they need (hover:, dark:, data-[selected=true]:…). Values stay
|
|
4
|
+
* token expressions (`var(--color-primary)`, `calc(var(--spacing) * 4)`),
|
|
5
|
+
* resolved per mode when a style is computed. The supported subset is
|
|
6
|
+
* listed in docs/avis-engine/STYLING.md; anything else is reported once
|
|
7
|
+
* and ignored, never guessed.
|
|
8
|
+
*/
|
|
9
|
+
const SIZES = new Set(["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl", "9xl"]);
|
|
10
|
+
const SHADOWS = new Set(["2xs", "xs", "sm", "md", "lg", "xl", "2xl", "none"]);
|
|
11
|
+
const RADII = new Set(["xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl"]);
|
|
12
|
+
const WEIGHTS = new Set(["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"]);
|
|
13
|
+
const ALIGN = { start: "start", center: "center", end: "end", stretch: "stretch", baseline: "baseline" };
|
|
14
|
+
const JUSTIFY = {
|
|
15
|
+
start: "start",
|
|
16
|
+
center: "center",
|
|
17
|
+
end: "end",
|
|
18
|
+
between: "between",
|
|
19
|
+
around: "around",
|
|
20
|
+
evenly: "evenly",
|
|
21
|
+
};
|
|
22
|
+
const arbitrary = (value) => (/^\[.+\]$/.test(value) ? value.slice(1, -1).replace(/_/g, " ") : null);
|
|
23
|
+
const isNumber = (value) => /^\d+(\.\d+)?$/.test(value);
|
|
24
|
+
/** A spacing value: n × --spacing, px, a fraction, full, auto or [arbitrary]. */
|
|
25
|
+
function spacing(value, allowAuto = false) {
|
|
26
|
+
const raw = arbitrary(value);
|
|
27
|
+
if (raw)
|
|
28
|
+
return raw;
|
|
29
|
+
if (value === "px")
|
|
30
|
+
return "1px";
|
|
31
|
+
if (value === "0")
|
|
32
|
+
return "0px";
|
|
33
|
+
if (isNumber(value))
|
|
34
|
+
return `calc(var(--spacing) * ${value})`;
|
|
35
|
+
if (value === "full")
|
|
36
|
+
return "100%";
|
|
37
|
+
if (/^\d+\/\d+$/.test(value)) {
|
|
38
|
+
const [a, b] = value.split("/").map(Number);
|
|
39
|
+
return `${(a / b) * 100}%`;
|
|
40
|
+
}
|
|
41
|
+
if (allowAuto && value === "auto")
|
|
42
|
+
return "auto";
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
/** A colour with an optional /alpha (`primary/50`, `[#123]/20`). */
|
|
46
|
+
function color(value) {
|
|
47
|
+
const [name, alphaText] = value.includes("/") && !value.startsWith("[") ? value.split("/") : [value, undefined];
|
|
48
|
+
let alpha;
|
|
49
|
+
if (alphaText !== undefined) {
|
|
50
|
+
const raw = arbitrary(alphaText);
|
|
51
|
+
alpha = raw ? parseFloat(raw) : Number(alphaText) / 100;
|
|
52
|
+
if (Number.isNaN(alpha))
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const raw = arbitrary(name);
|
|
56
|
+
if (raw)
|
|
57
|
+
return { value: raw, alpha };
|
|
58
|
+
if (name === "current")
|
|
59
|
+
return { value: "currentcolor", alpha };
|
|
60
|
+
if (name === "transparent")
|
|
61
|
+
return { value: "transparent", alpha };
|
|
62
|
+
if (name === "black" || name === "white")
|
|
63
|
+
return { value: `var(--color-${name}, ${name})`, alpha };
|
|
64
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name))
|
|
65
|
+
return null;
|
|
66
|
+
return { value: `var(--color-${name})`, alpha };
|
|
67
|
+
}
|
|
68
|
+
const sides = (prefix, which, value) => {
|
|
69
|
+
const map = {
|
|
70
|
+
"": ["Top", "Right", "Bottom", "Left"],
|
|
71
|
+
x: ["Left", "Right"],
|
|
72
|
+
y: ["Top", "Bottom"],
|
|
73
|
+
t: ["Top"],
|
|
74
|
+
r: ["Right"],
|
|
75
|
+
b: ["Bottom"],
|
|
76
|
+
l: ["Left"],
|
|
77
|
+
s: ["Left"],
|
|
78
|
+
e: ["Right"],
|
|
79
|
+
};
|
|
80
|
+
return map[which].map((side) => ({ prop: `${prefix}${side}`, value }));
|
|
81
|
+
};
|
|
82
|
+
/** One utility (no variants) → declarations, or null when unsupported. */
|
|
83
|
+
export function utility(name) {
|
|
84
|
+
const negative = name.startsWith("-");
|
|
85
|
+
const base = negative ? name.slice(1) : name;
|
|
86
|
+
const one = (prop, value) => [{ prop, value }];
|
|
87
|
+
const neg = (value) => (value && negative ? `calc(${value} * -1)` : value);
|
|
88
|
+
switch (base) {
|
|
89
|
+
case "flex":
|
|
90
|
+
return one("display", "flex");
|
|
91
|
+
case "grid":
|
|
92
|
+
return one("display", "grid");
|
|
93
|
+
case "block":
|
|
94
|
+
return one("display", "block");
|
|
95
|
+
case "hidden":
|
|
96
|
+
return one("display", "none");
|
|
97
|
+
case "flex-row":
|
|
98
|
+
return one("flexDirection", "row");
|
|
99
|
+
case "flex-col":
|
|
100
|
+
return one("flexDirection", "column");
|
|
101
|
+
case "flex-wrap":
|
|
102
|
+
return one("flexWrap", "wrap");
|
|
103
|
+
case "flex-1":
|
|
104
|
+
return [
|
|
105
|
+
{ prop: "grow", value: "1" },
|
|
106
|
+
{ prop: "shrink", value: "1" },
|
|
107
|
+
{ prop: "basis", value: "0px" },
|
|
108
|
+
];
|
|
109
|
+
case "grow":
|
|
110
|
+
return one("grow", "1");
|
|
111
|
+
case "grow-0":
|
|
112
|
+
return one("grow", "0");
|
|
113
|
+
case "shrink":
|
|
114
|
+
return one("shrink", "1");
|
|
115
|
+
case "shrink-0":
|
|
116
|
+
return one("shrink", "0");
|
|
117
|
+
case "relative":
|
|
118
|
+
return one("position", "relative");
|
|
119
|
+
case "absolute":
|
|
120
|
+
return one("position", "absolute");
|
|
121
|
+
case "border":
|
|
122
|
+
return one("borderWidth", "1px");
|
|
123
|
+
case "rounded":
|
|
124
|
+
return one("radius", "0.25rem");
|
|
125
|
+
case "rounded-none":
|
|
126
|
+
return one("radius", "0px");
|
|
127
|
+
case "rounded-full":
|
|
128
|
+
return one("radius", "9999px");
|
|
129
|
+
case "shadow":
|
|
130
|
+
return one("shadow", "var(--shadow-sm)");
|
|
131
|
+
case "ring":
|
|
132
|
+
return one("ringWidth", "1px");
|
|
133
|
+
case "truncate":
|
|
134
|
+
return one("truncate", "true");
|
|
135
|
+
case "overflow-hidden":
|
|
136
|
+
return one("overflow", "hidden");
|
|
137
|
+
case "text-left":
|
|
138
|
+
case "text-center":
|
|
139
|
+
case "text-right":
|
|
140
|
+
return one("textAlign", base.slice(5));
|
|
141
|
+
}
|
|
142
|
+
let m;
|
|
143
|
+
if ((m = /^(p|m)([xytrblse]?)-(.+)$/.exec(base))) {
|
|
144
|
+
const value = neg(spacing(m[3], m[1] === "m"));
|
|
145
|
+
return value ? sides(m[1] === "p" ? "padding" : "margin", m[2], value) : null;
|
|
146
|
+
}
|
|
147
|
+
if ((m = /^gap(-x|-y)?-(.+)$/.exec(base))) {
|
|
148
|
+
const value = spacing(m[2]);
|
|
149
|
+
if (!value)
|
|
150
|
+
return null;
|
|
151
|
+
return m[1] === "-x" ? one("gapX", value) : m[1] === "-y" ? one("gapY", value) : [
|
|
152
|
+
{ prop: "gapX", value },
|
|
153
|
+
{ prop: "gapY", value },
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
if ((m = /^(w|h|size|min-w|min-h|max-w|max-h|basis)-(.+)$/.exec(base))) {
|
|
157
|
+
const value = spacing(m[2], true) ?? (m[2] === "fit" || m[2] === "min" || m[2] === "max" ? "auto" : null);
|
|
158
|
+
if (!value)
|
|
159
|
+
return null;
|
|
160
|
+
const prop = { w: "width", h: "height", "min-w": "minWidth", "min-h": "minHeight", "max-w": "maxWidth", "max-h": "maxHeight", basis: "basis" }[m[1]];
|
|
161
|
+
return m[1] === "size" ? [{ prop: "width", value }, { prop: "height", value }] : one(prop, value);
|
|
162
|
+
}
|
|
163
|
+
if ((m = /^(inset|inset-x|inset-y|top|right|bottom|left)-(.+)$/.exec(base))) {
|
|
164
|
+
const value = neg(spacing(m[2], true));
|
|
165
|
+
if (!value)
|
|
166
|
+
return null;
|
|
167
|
+
const props = m[1] === "inset" ? ["top", "right", "bottom", "left"] : m[1] === "inset-x" ? ["left", "right"] : m[1] === "inset-y" ? ["top", "bottom"] : [m[1]];
|
|
168
|
+
return props.map((prop) => ({ prop, value }));
|
|
169
|
+
}
|
|
170
|
+
if ((m = /^items-(.+)$/.exec(base)) && ALIGN[m[1]])
|
|
171
|
+
return one("alignItems", ALIGN[m[1]]);
|
|
172
|
+
if ((m = /^self-(.+)$/.exec(base)) && (ALIGN[m[1]] || m[1] === "auto"))
|
|
173
|
+
return one("alignSelf", ALIGN[m[1]] ?? "auto");
|
|
174
|
+
if ((m = /^justify-(.+)$/.exec(base)) && JUSTIFY[m[1]])
|
|
175
|
+
return one("justifyContent", JUSTIFY[m[1]]);
|
|
176
|
+
if ((m = /^grid-cols-(\d+)$/.exec(base)))
|
|
177
|
+
return one("gridCols", m[1]);
|
|
178
|
+
if ((m = /^col-span-(\d+|full)$/.exec(base)))
|
|
179
|
+
return one("colSpan", m[1] === "full" ? "999" : m[1]);
|
|
180
|
+
if ((m = /^opacity-(\d+)$/.exec(base)))
|
|
181
|
+
return one("opacity", String(Number(m[1]) / 100));
|
|
182
|
+
if ((m = /^line-clamp-(\d+)$/.exec(base)))
|
|
183
|
+
return one("lineClamp", m[1]);
|
|
184
|
+
if ((m = /^rounded-(.+)$/.exec(base))) {
|
|
185
|
+
const raw = arbitrary(m[1]);
|
|
186
|
+
if (raw)
|
|
187
|
+
return one("radius", raw);
|
|
188
|
+
return RADII.has(m[1]) ? one("radius", `var(--radius-${m[1]})`) : null;
|
|
189
|
+
}
|
|
190
|
+
if ((m = /^shadow-(.+)$/.exec(base))) {
|
|
191
|
+
return SHADOWS.has(m[1]) ? one("shadow", m[1] === "none" ? "none" : `var(--shadow-${m[1]})`) : null;
|
|
192
|
+
}
|
|
193
|
+
if ((m = /^border-(.+)$/.exec(base))) {
|
|
194
|
+
if (isNumber(m[1]))
|
|
195
|
+
return one("borderWidth", `${m[1]}px`);
|
|
196
|
+
const raw = arbitrary(m[1]);
|
|
197
|
+
if (raw && /^\d/.test(raw))
|
|
198
|
+
return one("borderWidth", raw);
|
|
199
|
+
const c = color(m[1]);
|
|
200
|
+
return c ? [{ prop: "borderColor", ...c }] : null;
|
|
201
|
+
}
|
|
202
|
+
if ((m = /^ring-(.+)$/.exec(base))) {
|
|
203
|
+
if (isNumber(m[1]))
|
|
204
|
+
return one("ringWidth", `${m[1]}px`);
|
|
205
|
+
const c = color(m[1]);
|
|
206
|
+
return c ? [{ prop: "ringColor", ...c }] : null;
|
|
207
|
+
}
|
|
208
|
+
if ((m = /^bg-(.+)$/.exec(base))) {
|
|
209
|
+
const c = color(m[1]);
|
|
210
|
+
return c ? [{ prop: "background", ...c }] : null;
|
|
211
|
+
}
|
|
212
|
+
if ((m = /^text-(.+)$/.exec(base))) {
|
|
213
|
+
const [size, leading] = m[1].split("/");
|
|
214
|
+
if (SIZES.has(size)) {
|
|
215
|
+
const decls = [
|
|
216
|
+
{ prop: "fontSize", value: `var(--text-${size})` },
|
|
217
|
+
{ prop: "lineHeight", value: `var(--text-${size}--line-height)` },
|
|
218
|
+
];
|
|
219
|
+
if (leading) {
|
|
220
|
+
const value = isNumber(leading) ? `calc(var(--spacing) * ${leading})` : `var(--leading-${leading})`;
|
|
221
|
+
decls[1] = { prop: "lineHeight", value };
|
|
222
|
+
}
|
|
223
|
+
return decls;
|
|
224
|
+
}
|
|
225
|
+
const raw = arbitrary(m[1]);
|
|
226
|
+
if (raw && /^\d/.test(raw))
|
|
227
|
+
return one("fontSize", raw);
|
|
228
|
+
const c = color(m[1]);
|
|
229
|
+
return c ? [{ prop: "color", ...c }] : null;
|
|
230
|
+
}
|
|
231
|
+
if ((m = /^font-(.+)$/.exec(base))) {
|
|
232
|
+
if (WEIGHTS.has(m[1]))
|
|
233
|
+
return one("fontWeight", `var(--font-weight-${m[1]})`);
|
|
234
|
+
const raw = arbitrary(m[1]);
|
|
235
|
+
if (raw && isNumber(raw))
|
|
236
|
+
return one("fontWeight", raw);
|
|
237
|
+
if (/^(sans|serif|mono|heading)$/.test(m[1]))
|
|
238
|
+
return one("fontFamily", `var(--font-${m[1]})`);
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if ((m = /^leading-(.+)$/.exec(base))) {
|
|
242
|
+
if (isNumber(m[1]))
|
|
243
|
+
return one("lineHeight", `calc(var(--spacing) * ${m[1]})`);
|
|
244
|
+
const raw = arbitrary(m[1]);
|
|
245
|
+
if (raw)
|
|
246
|
+
return one("lineHeight", raw);
|
|
247
|
+
return /^(none|tight|snug|normal|relaxed|loose)$/.test(m[1])
|
|
248
|
+
? one("lineHeight", m[1] === "none" ? "1" : `var(--leading-${m[1]})`)
|
|
249
|
+
: null;
|
|
250
|
+
}
|
|
251
|
+
if ((m = /^tracking-(.+)$/.exec(base))) {
|
|
252
|
+
const raw = arbitrary(m[1]);
|
|
253
|
+
if (raw)
|
|
254
|
+
return one("letterSpacing", raw);
|
|
255
|
+
return /^(tighter|tight|normal|wide|wider|widest)$/.test(m[1]) ? one("letterSpacing", `var(--tracking-${m[1]})`) : null;
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
/** Splits at ":" outside brackets: `data-[a=b]:hover:bg-x` → 3 parts. */
|
|
260
|
+
function splitVariants(className) {
|
|
261
|
+
const parts = [];
|
|
262
|
+
let depth = 0;
|
|
263
|
+
let start = 0;
|
|
264
|
+
for (let i = 0; i < className.length; i++) {
|
|
265
|
+
const c = className[i];
|
|
266
|
+
if (c === "[")
|
|
267
|
+
depth++;
|
|
268
|
+
else if (c === "]")
|
|
269
|
+
depth--;
|
|
270
|
+
else if (c === ":" && depth === 0) {
|
|
271
|
+
parts.push(className.slice(start, i));
|
|
272
|
+
start = i + 1;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
parts.push(className.slice(start));
|
|
276
|
+
return parts;
|
|
277
|
+
}
|
|
278
|
+
function condition(variant) {
|
|
279
|
+
switch (variant) {
|
|
280
|
+
case "hover":
|
|
281
|
+
return { kind: "state", name: "hover" };
|
|
282
|
+
case "group-hover":
|
|
283
|
+
case "group-focus":
|
|
284
|
+
case "group-active":
|
|
285
|
+
case "group-disabled":
|
|
286
|
+
return { kind: "state", name: variant.slice(6), group: true };
|
|
287
|
+
case "active":
|
|
288
|
+
case "focus":
|
|
289
|
+
case "focus-visible":
|
|
290
|
+
case "focus-within":
|
|
291
|
+
case "disabled":
|
|
292
|
+
return { kind: "state", name: variant };
|
|
293
|
+
case "dark":
|
|
294
|
+
case "light":
|
|
295
|
+
return { kind: "mode", mode: variant };
|
|
296
|
+
}
|
|
297
|
+
let m;
|
|
298
|
+
if ((m = /^group-(data-.+|aria-.+)$/.exec(variant))) {
|
|
299
|
+
const inner = condition(m[1]);
|
|
300
|
+
return inner?.kind === "data" ? { ...inner, group: true } : null;
|
|
301
|
+
}
|
|
302
|
+
if ((m = /^(?:data|aria)-\[([\w-]+)(?:=["']?([^"'\]]*)["']?)?\]$/.exec(variant))) {
|
|
303
|
+
return { kind: "data", key: m[1], value: m[2] ?? null };
|
|
304
|
+
}
|
|
305
|
+
if ((m = /^data-([\w-]+)$/.exec(variant)))
|
|
306
|
+
return { kind: "data", key: m[1], value: null };
|
|
307
|
+
if ((m = /^aria-(selected|checked|disabled|expanded|pressed)$/.exec(variant))) {
|
|
308
|
+
return { kind: "data", key: m[1], value: "true" };
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
/** Compiles a class string, in order. Unsupported parts go to `report`. */
|
|
313
|
+
export function compileClasses(classes, report = () => { }) {
|
|
314
|
+
const rules = [];
|
|
315
|
+
for (const className of classes.split(/\s+/).filter(Boolean)) {
|
|
316
|
+
const parts = splitVariants(className);
|
|
317
|
+
let name = parts.pop();
|
|
318
|
+
if (name.startsWith("!"))
|
|
319
|
+
name = name.slice(1);
|
|
320
|
+
const conditions = [];
|
|
321
|
+
let ok = true;
|
|
322
|
+
for (const variant of parts) {
|
|
323
|
+
const c = condition(variant);
|
|
324
|
+
if (!c) {
|
|
325
|
+
report({ code: "style.variant", className, message: `The variant "${variant}:" isn't supported` });
|
|
326
|
+
ok = false;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
conditions.push(c);
|
|
330
|
+
}
|
|
331
|
+
if (!ok)
|
|
332
|
+
continue;
|
|
333
|
+
const decls = utility(name);
|
|
334
|
+
if (!decls) {
|
|
335
|
+
report({ code: "style.unsupported", className, message: `The utility "${name}" isn't supported` });
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
rules.push({ conditions, decls, className });
|
|
339
|
+
}
|
|
340
|
+
return rules;
|
|
341
|
+
}
|