@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,526 @@
|
|
|
1
|
+
/** A CSS colour that paints nothing (zero alpha; not just a zero last channel). */
|
|
2
|
+
export function isTransparent(color) {
|
|
3
|
+
const value = color.trim().toLowerCase();
|
|
4
|
+
if (value === "" || value === "transparent" || value === "none")
|
|
5
|
+
return true;
|
|
6
|
+
// "… / 0)" or "… / 0%)": modern syntax with an alpha.
|
|
7
|
+
const slash = /\/\s*([\d.]+)(%?)\s*\)$/.exec(value);
|
|
8
|
+
if (slash)
|
|
9
|
+
return parseFloat(slash[1]) === 0;
|
|
10
|
+
// rgba(r, g, b, 0) / hsla(h, s, l, 0): the fourth comma-separated value.
|
|
11
|
+
const legacy = /^(?:rgba?|hsla?)\(([^)]*)\)$/.exec(value);
|
|
12
|
+
if (legacy) {
|
|
13
|
+
const parts = legacy[1].split(",");
|
|
14
|
+
return parts.length === 4 && parseFloat(parts[3]) === 0;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
/** A computed radius ("12px", "50%", "12px 8px") in px for a box this size. */
|
|
19
|
+
export function parseRadius(value, size) {
|
|
20
|
+
const first = value.trim().split(/\s+/)[0] ?? "0";
|
|
21
|
+
const number = parseFloat(first);
|
|
22
|
+
if (!Number.isFinite(number))
|
|
23
|
+
return 0;
|
|
24
|
+
return first.endsWith("%") ? (number / 100) * size : number;
|
|
25
|
+
}
|
|
26
|
+
export function radiiOf(style, rect) {
|
|
27
|
+
const size = Math.min(rect.w, rect.h);
|
|
28
|
+
const limit = size / 2;
|
|
29
|
+
return [
|
|
30
|
+
Math.min(limit, parseRadius(style.borderTopLeftRadius, size)),
|
|
31
|
+
Math.min(limit, parseRadius(style.borderTopRightRadius, size)),
|
|
32
|
+
Math.min(limit, parseRadius(style.borderBottomRightRadius, size)),
|
|
33
|
+
Math.min(limit, parseRadius(style.borderBottomLeftRadius, size)),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/** Splits a comma list at the top level (not inside parentheses). */
|
|
37
|
+
export function splitTop(value, separator = ",") {
|
|
38
|
+
const out = [];
|
|
39
|
+
let depth = 0;
|
|
40
|
+
let start = 0;
|
|
41
|
+
for (let i = 0; i < value.length; i++) {
|
|
42
|
+
const c = value[i];
|
|
43
|
+
if (c === "(")
|
|
44
|
+
depth++;
|
|
45
|
+
else if (c === ")")
|
|
46
|
+
depth--;
|
|
47
|
+
else if (c === separator && depth === 0) {
|
|
48
|
+
out.push(value.slice(start, i).trim());
|
|
49
|
+
start = i + 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const last = value.slice(start).trim();
|
|
53
|
+
if (last)
|
|
54
|
+
out.push(last);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
const COLOR = /(rgba?\([^)]*\)|hsla?\([^)]*\)|oklch\([^)]*\)|oklab\([^)]*\)|lab\([^)]*\)|lch\([^)]*\)|color\([^)]*\)|#[0-9a-f]{3,8}\b|transparent|currentcolor|[a-z]+)/i;
|
|
58
|
+
/** `box-shadow` as computed: "rgb(…) 0px 1px 2px 0px, inset …". */
|
|
59
|
+
export function parseShadows(value) {
|
|
60
|
+
if (!value || value === "none")
|
|
61
|
+
return [];
|
|
62
|
+
const out = [];
|
|
63
|
+
for (const part of splitTop(value)) {
|
|
64
|
+
const inset = /\binset\b/.test(part);
|
|
65
|
+
const color = COLOR.exec(part.replace(/\binset\b/, ""))?.[1] ?? "black";
|
|
66
|
+
const lengths = part
|
|
67
|
+
.replace(color, " ")
|
|
68
|
+
.replace(/\binset\b/, " ")
|
|
69
|
+
.trim()
|
|
70
|
+
.split(/\s+/)
|
|
71
|
+
.map((v) => parseFloat(v))
|
|
72
|
+
.filter((v) => Number.isFinite(v));
|
|
73
|
+
const [x = 0, y = 0, blur = 0, spread = 0] = lengths;
|
|
74
|
+
if (isTransparent(color))
|
|
75
|
+
continue;
|
|
76
|
+
out.push({ inset, x, y, blur, spread, color });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/** A colour stop's position as a share of the gradient: "25%", "4px", "70deg", "calc(3% - 2px)". */
|
|
81
|
+
function stopAt(token, length) {
|
|
82
|
+
const part = (value, unit) => {
|
|
83
|
+
const n = parseFloat(value.replace(/\s+/g, ""));
|
|
84
|
+
if (unit === "%")
|
|
85
|
+
return n / 100;
|
|
86
|
+
if (unit === "px")
|
|
87
|
+
return n / (length || 1);
|
|
88
|
+
if (unit === "deg")
|
|
89
|
+
return n / 360;
|
|
90
|
+
if (unit === "turn")
|
|
91
|
+
return n;
|
|
92
|
+
if (unit === "rad")
|
|
93
|
+
return n / (2 * Math.PI);
|
|
94
|
+
if (unit === "grad")
|
|
95
|
+
return n / 400;
|
|
96
|
+
return n === 0 ? 0 : NaN;
|
|
97
|
+
};
|
|
98
|
+
if (token.startsWith("calc(")) {
|
|
99
|
+
let sum = 0;
|
|
100
|
+
for (const m of token.slice(5, -1).matchAll(/([+-]?\s*[\d.]+)(%|px|deg|turn|grad|rad)/g))
|
|
101
|
+
sum += part(m[1], m[2]);
|
|
102
|
+
return sum;
|
|
103
|
+
}
|
|
104
|
+
const m = /^(-?[\d.]+)(%|px|deg|turn|grad|rad)?$/.exec(token);
|
|
105
|
+
return m ? part(m[1], m[2] ?? "") : NaN;
|
|
106
|
+
}
|
|
107
|
+
function stopsOf(parts, length, repeating = false) {
|
|
108
|
+
const raw = parts.map((part) => {
|
|
109
|
+
const color = COLOR.exec(part)?.[1] ?? "transparent";
|
|
110
|
+
const rest = part.replace(color, " ").trim().match(/calc\([^)]*\)|\S+/g) ?? [];
|
|
111
|
+
const at = rest.map((v) => stopAt(v, length));
|
|
112
|
+
return { color, at: at.filter((v) => Number.isFinite(v)) };
|
|
113
|
+
});
|
|
114
|
+
// Each colour may have 0, 1 or 2 positions; missing ones spread evenly.
|
|
115
|
+
const flat = [];
|
|
116
|
+
for (const stop of raw) {
|
|
117
|
+
if (!stop.at.length)
|
|
118
|
+
flat.push({ color: stop.color, at: null });
|
|
119
|
+
for (const at of stop.at)
|
|
120
|
+
flat.push({ color: stop.color, at });
|
|
121
|
+
}
|
|
122
|
+
if (!flat.length)
|
|
123
|
+
return [];
|
|
124
|
+
if (flat[0].at === null)
|
|
125
|
+
flat[0].at = 0;
|
|
126
|
+
if (flat[flat.length - 1].at === null)
|
|
127
|
+
flat[flat.length - 1].at = 1;
|
|
128
|
+
for (let i = 1; i < flat.length; i++) {
|
|
129
|
+
if (flat[i].at !== null) {
|
|
130
|
+
flat[i].at = Math.max(flat[i].at, flat[i - 1].at ?? 0);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
let j = i;
|
|
134
|
+
while (flat[j].at === null)
|
|
135
|
+
j++;
|
|
136
|
+
const from = flat[i - 1].at;
|
|
137
|
+
const to = flat[j].at;
|
|
138
|
+
for (let k = i; k < j; k++)
|
|
139
|
+
flat[k].at = from + ((to - from) * (k - i + 1)) / (j - i + 1);
|
|
140
|
+
}
|
|
141
|
+
const stops = flat.map((s) => ({ color: s.color, at: s.at }));
|
|
142
|
+
const period = stops[stops.length - 1].at - stops[0].at;
|
|
143
|
+
if (repeating && period > 0.001 && stops[stops.length - 1].at < 1) {
|
|
144
|
+
// Canvas gradients don't repeat: the run of stops, again and again.
|
|
145
|
+
const run = [...stops];
|
|
146
|
+
for (let turn = 1; stops[stops.length - 1].at < 1; turn++) {
|
|
147
|
+
for (const s of run)
|
|
148
|
+
stops.push({ color: s.color, at: s.at + period * turn });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const kept = stops.filter((s, i) => s.at <= 1 || (stops[i - 1]?.at ?? 0) < 1);
|
|
152
|
+
return kept.map((s) => ({ color: s.color, at: Math.min(1, Math.max(0, s.at)) }));
|
|
153
|
+
}
|
|
154
|
+
const SIDES = { top: 0, right: 90, bottom: 180, left: 270 };
|
|
155
|
+
/** One layer of `background-image` if it is a gradient, for a box this size. */
|
|
156
|
+
export function parseGradient(value, rect) {
|
|
157
|
+
const match = /^(repeating-)?(linear|radial|conic)-gradient\((.*)\)$/s.exec(value.trim());
|
|
158
|
+
if (!match)
|
|
159
|
+
return null;
|
|
160
|
+
const [, repeating, kind, body] = match;
|
|
161
|
+
const parts = splitTop(body);
|
|
162
|
+
if (kind === "linear") {
|
|
163
|
+
let angle = 180;
|
|
164
|
+
const first = parts[0] ?? "";
|
|
165
|
+
if (/^-?[\d.]+(deg|turn|rad|grad)$/.test(first)) {
|
|
166
|
+
const n = parseFloat(first);
|
|
167
|
+
angle = first.endsWith("turn") ? n * 360 : first.endsWith("rad") ? (n * 180) / Math.PI : first.endsWith("grad") ? n * 0.9 : n;
|
|
168
|
+
parts.shift();
|
|
169
|
+
}
|
|
170
|
+
else if (first.startsWith("to ")) {
|
|
171
|
+
const words = first.slice(3).trim().split(/\s+/);
|
|
172
|
+
if (words.length === 1)
|
|
173
|
+
angle = SIDES[words[0]] ?? 180;
|
|
174
|
+
else {
|
|
175
|
+
// "to top right": the angle that makes the corner's diagonal perpendicular.
|
|
176
|
+
const dx = words.includes("right") ? 1 : -1;
|
|
177
|
+
const dy = words.includes("bottom") ? 1 : -1;
|
|
178
|
+
angle = (Math.atan2(dx * rect.h, -dy * rect.w) * 180) / Math.PI;
|
|
179
|
+
}
|
|
180
|
+
parts.shift();
|
|
181
|
+
}
|
|
182
|
+
else if (/^in /.test(first)) {
|
|
183
|
+
parts.shift();
|
|
184
|
+
}
|
|
185
|
+
const rad = (angle * Math.PI) / 180;
|
|
186
|
+
const length = Math.abs(rect.w * Math.sin(rad)) + Math.abs(rect.h * Math.cos(rad));
|
|
187
|
+
return { kind: "linear", angle, stops: stopsOf(parts, length, Boolean(repeating)), repeating: Boolean(repeating) };
|
|
188
|
+
}
|
|
189
|
+
if (kind === "radial") {
|
|
190
|
+
let cx = rect.w / 2;
|
|
191
|
+
let cy = rect.h / 2;
|
|
192
|
+
let rx = Math.hypot(rect.w / 2, rect.h / 2);
|
|
193
|
+
let ry = rx;
|
|
194
|
+
const head = parts[0] ?? "";
|
|
195
|
+
if (!COLOR.test(head.split(/\s+/)[0]) || /\bat\b|circle|ellipse|closest|farthest/.test(head)) {
|
|
196
|
+
parts.shift();
|
|
197
|
+
const at = /\bat\s+(\S+)(?:\s+(\S+))?/.exec(head);
|
|
198
|
+
const pos = (v, size) => (!v || v === "center" ? size / 2 : v === "left" || v === "top" ? 0 : v === "right" || v === "bottom" ? size : v.endsWith("%") ? (parseFloat(v) / 100) * size : parseFloat(v));
|
|
199
|
+
if (at) {
|
|
200
|
+
cx = pos(at[1], rect.w);
|
|
201
|
+
cy = pos(at[2] ?? "center", rect.h);
|
|
202
|
+
}
|
|
203
|
+
const far = Math.hypot(Math.max(cx, rect.w - cx), Math.max(cy, rect.h - cy));
|
|
204
|
+
const near = Math.min(cx, rect.w - cx, cy, rect.h - cy);
|
|
205
|
+
rx = ry = /closest-side|closest-corner/.test(head) ? near : far;
|
|
206
|
+
if (/ellipse/.test(head) || !/circle/.test(head)) {
|
|
207
|
+
rx = Math.max(cx, rect.w - cx) * Math.SQRT2;
|
|
208
|
+
ry = Math.max(cy, rect.h - cy) * Math.SQRT2;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { kind: "radial", cx, cy, rx, ry, stops: stopsOf(parts, rx) };
|
|
212
|
+
}
|
|
213
|
+
let from = 0;
|
|
214
|
+
let cx = rect.w / 2;
|
|
215
|
+
let cy = rect.h / 2;
|
|
216
|
+
const head = parts[0] ?? "";
|
|
217
|
+
if (/^from |^at /.test(head)) {
|
|
218
|
+
parts.shift();
|
|
219
|
+
const f = /from\s+(-?[\d.]+)(deg|turn)/.exec(head);
|
|
220
|
+
if (f)
|
|
221
|
+
from = f[2] === "turn" ? parseFloat(f[1]) * 360 : parseFloat(f[1]);
|
|
222
|
+
const at = /at\s+(\S+)\s+(\S+)/.exec(head);
|
|
223
|
+
if (at) {
|
|
224
|
+
cx = at[1].endsWith("%") ? (parseFloat(at[1]) / 100) * rect.w : parseFloat(at[1]);
|
|
225
|
+
cy = at[2].endsWith("%") ? (parseFloat(at[2]) / 100) * rect.h : parseFloat(at[2]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return { kind: "conic", cx, cy, from, stops: stopsOf(parts, 1) };
|
|
229
|
+
}
|
|
230
|
+
/** A layer's `background-size` in px ("16px 16px", "50% auto"), or null when it covers its box. */
|
|
231
|
+
function tileOf(size, rect) {
|
|
232
|
+
const [w = "auto", h = "auto"] = (size ?? "").trim().split(/\s+/);
|
|
233
|
+
const px = (v, whole) => (v.endsWith("%") ? (parseFloat(v) / 100) * whole : v.endsWith("px") ? parseFloat(v) : whole);
|
|
234
|
+
const tile = { w: px(w, rect.w), h: px(h, rect.h) };
|
|
235
|
+
if (!(tile.w > 0) || !(tile.h > 0) || (tile.w >= rect.w && tile.h >= rect.h))
|
|
236
|
+
return null;
|
|
237
|
+
return tile;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Every gradient layer of a `background-image`, topmost first as CSS lists
|
|
241
|
+
* them; a layer with a `background-size` of its own is a tile that repeats.
|
|
242
|
+
*/
|
|
243
|
+
export function parseGradients(value, rect, size = "auto") {
|
|
244
|
+
if (!value || value === "none")
|
|
245
|
+
return [];
|
|
246
|
+
const sizes = splitTop(size);
|
|
247
|
+
return splitTop(value)
|
|
248
|
+
.map((layer, index) => {
|
|
249
|
+
const tile = tileOf(sizes[index % sizes.length], rect);
|
|
250
|
+
const g = parseGradient(layer, tile ? { x: 0, y: 0, ...tile } : rect);
|
|
251
|
+
return g && tile ? { ...g, tile } : g;
|
|
252
|
+
})
|
|
253
|
+
.filter((g) => g !== null);
|
|
254
|
+
}
|
|
255
|
+
/** The blur of a `backdrop-filter`, in px (0 for none). */
|
|
256
|
+
export function backdropBlurOf(value) {
|
|
257
|
+
return parseFloat(/\bblur\(([\d.]+)px\)/.exec(value ?? "")?.[1] ?? "0") || 0;
|
|
258
|
+
}
|
|
259
|
+
/** A mask of one gradient over the whole box (a segmented meter), or null for none or any other. */
|
|
260
|
+
export function maskGradient(image, rect) {
|
|
261
|
+
if (!image || image === "none")
|
|
262
|
+
return null;
|
|
263
|
+
const layers = splitTop(image);
|
|
264
|
+
return layers.length === 1 ? parseGradient(layers[0], rect) : null;
|
|
265
|
+
}
|
|
266
|
+
/** A colour's alpha (1 when it has none). */
|
|
267
|
+
export function alphaOf(color) {
|
|
268
|
+
const value = color.trim().toLowerCase();
|
|
269
|
+
if (isTransparent(value))
|
|
270
|
+
return 0;
|
|
271
|
+
const slash = /\/\s*([\d.]+)(%?)\s*\)$/.exec(value);
|
|
272
|
+
if (slash)
|
|
273
|
+
return parseFloat(slash[1]) / (slash[2] ? 100 : 1);
|
|
274
|
+
const legacy = /^(?:rgba|hsla)\(([^)]*)\)$/.exec(value);
|
|
275
|
+
if (legacy) {
|
|
276
|
+
const parts = legacy[1].split(",");
|
|
277
|
+
if (parts.length === 4)
|
|
278
|
+
return parseFloat(parts[3]);
|
|
279
|
+
}
|
|
280
|
+
return 1;
|
|
281
|
+
}
|
|
282
|
+
/** Whether a mask layer keeps everything (opaque all the way, as an idle scroll fade is). */
|
|
283
|
+
function keepsAll(g) {
|
|
284
|
+
// Transparent only from its very end: a stop that isn't opaque, reached
|
|
285
|
+
// from inside the box, fades (or cuts) part of it.
|
|
286
|
+
return g.stops.every((s, i) => alphaOf(s.color) >= 0.999 || (i > 0 && g.stops[i - 1].at >= 0.999));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A `mask-image` of gradient layers over the element's border box, with
|
|
290
|
+
* their `mask-composite`. Null when there is none, when it keeps
|
|
291
|
+
* everything, or for what the painter doesn't read (images, sized or placed
|
|
292
|
+
* layers): it then paints unmasked.
|
|
293
|
+
*/
|
|
294
|
+
export function maskLayers(mask, rect) {
|
|
295
|
+
if (!mask.image || mask.image === "none")
|
|
296
|
+
return null;
|
|
297
|
+
const sizes = splitTop(mask.size ?? "auto");
|
|
298
|
+
if (sizes.some((size) => size !== "auto"))
|
|
299
|
+
return null;
|
|
300
|
+
const composites = splitTop(mask.composite || "add");
|
|
301
|
+
const layers = [];
|
|
302
|
+
for (const [index, layer] of splitTop(mask.image).entries()) {
|
|
303
|
+
const gradient = parseGradient(layer, rect);
|
|
304
|
+
if (!gradient)
|
|
305
|
+
return null;
|
|
306
|
+
const composite = composites[index % composites.length];
|
|
307
|
+
layers.push({ gradient, composite: ["add", "subtract", "intersect", "exclude"].includes(composite) ? composite : "add" });
|
|
308
|
+
}
|
|
309
|
+
const add = layers.every((l) => l.composite === "add");
|
|
310
|
+
// Intersected layers that keep everything change nothing (and added ones,
|
|
311
|
+
// when one keeps everything).
|
|
312
|
+
if (add ? layers.some((l) => keepsAll(l.gradient)) : layers.every((l) => keepsAll(l.gradient)))
|
|
313
|
+
return null;
|
|
314
|
+
return layers;
|
|
315
|
+
}
|
|
316
|
+
// ---- clipping -----------------------------------------------------------------------
|
|
317
|
+
/** Whether an element clips what it holds: overflow other than visible, or paint containment. */
|
|
318
|
+
export function clipsContent(style) {
|
|
319
|
+
if (style.overflowX !== "visible" || style.overflowY !== "visible")
|
|
320
|
+
return true;
|
|
321
|
+
const contain = style.contain ?? "";
|
|
322
|
+
return /\b(paint|strict|content)\b/.test(contain);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The clip an overflow box puts on its children: its padding box (the border
|
|
326
|
+
* box less the border widths, top/right/bottom/left) with the inner radii
|
|
327
|
+
* (each corner's radius less the wider of its two borders), as CSS clips.
|
|
328
|
+
*/
|
|
329
|
+
export function paddingClip(rect, radii, borders) {
|
|
330
|
+
const [top, right, bottom, left] = borders;
|
|
331
|
+
const inner = (r, a, b) => Math.max(0, r - Math.max(a, b));
|
|
332
|
+
return {
|
|
333
|
+
x: rect.x + left,
|
|
334
|
+
y: rect.y + top,
|
|
335
|
+
w: Math.max(0, rect.w - left - right),
|
|
336
|
+
h: Math.max(0, rect.h - top - bottom),
|
|
337
|
+
radii: [inner(radii[0], top, left), inner(radii[1], top, right), inner(radii[2], bottom, right), inner(radii[3], bottom, left)],
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const EPSILON = 0.5;
|
|
341
|
+
/** Whether a point lies inside a rounded rect (with half a pixel's slack). */
|
|
342
|
+
export function pointInClip(clip, x, y) {
|
|
343
|
+
if (x < clip.x - EPSILON || y < clip.y - EPSILON || x > clip.x + clip.w + EPSILON || y > clip.y + clip.h + EPSILON)
|
|
344
|
+
return false;
|
|
345
|
+
const limit = Math.min(clip.w, clip.h) / 2;
|
|
346
|
+
const corner = (r, cx, cy, inX, inY) => {
|
|
347
|
+
const radius = Math.min(limit, r);
|
|
348
|
+
if (radius <= 0 || !inX || !inY)
|
|
349
|
+
return true;
|
|
350
|
+
return Math.hypot(x - cx, y - cy) <= radius + EPSILON;
|
|
351
|
+
};
|
|
352
|
+
const [tl, tr, br, bl] = clip.radii;
|
|
353
|
+
const left = clip.x;
|
|
354
|
+
const top = clip.y;
|
|
355
|
+
const right = clip.x + clip.w;
|
|
356
|
+
const bottom = clip.y + clip.h;
|
|
357
|
+
return (corner(tl, left + tl, top + tl, x < left + tl, y < top + tl) &&
|
|
358
|
+
corner(tr, right - tr, top + tr, x > right - tr, y < top + tr) &&
|
|
359
|
+
corner(br, right - br, bottom - br, x > right - br, y > bottom - br) &&
|
|
360
|
+
corner(bl, left + bl, bottom - bl, x < left + bl, y > bottom - bl));
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Whether a rect lies wholly inside a rounded clip: its four corners do (a
|
|
364
|
+
* rounded rect is convex, so the rect between them does too). Such a clip
|
|
365
|
+
* changes nothing for it.
|
|
366
|
+
*/
|
|
367
|
+
export function clipContains(clip, rect) {
|
|
368
|
+
return (pointInClip(clip, rect.x, rect.y) &&
|
|
369
|
+
pointInClip(clip, rect.x + rect.w, rect.y) &&
|
|
370
|
+
pointInClip(clip, rect.x + rect.w, rect.y + rect.h) &&
|
|
371
|
+
pointInClip(clip, rect.x, rect.y + rect.h));
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The clip stack (outermost first) with a nested overflow box's clip added:
|
|
375
|
+
* an outer clip that wholly holds the new one is dropped, since it can no
|
|
376
|
+
* longer cut anything inside.
|
|
377
|
+
*/
|
|
378
|
+
export function pushClip(stack, clip) {
|
|
379
|
+
return [...stack.filter((outer) => !clipContains(outer, clip)), clip];
|
|
380
|
+
}
|
|
381
|
+
/** The clips of a stack that cut a rect (the others hold it whole); undefined when none do. */
|
|
382
|
+
export function clipsFor(stack, rect) {
|
|
383
|
+
if (!stack.length)
|
|
384
|
+
return undefined;
|
|
385
|
+
const cutting = stack.filter((clip) => !clipContains(clip, rect));
|
|
386
|
+
return cutting.length ? cutting : undefined;
|
|
387
|
+
}
|
|
388
|
+
/** The part of a rect a clip stack leaves visible (axis-aligned), or null when none is. */
|
|
389
|
+
export function clipRect(rect, clips) {
|
|
390
|
+
let x0 = rect.x;
|
|
391
|
+
let y0 = rect.y;
|
|
392
|
+
let x1 = rect.x + rect.w;
|
|
393
|
+
let y1 = rect.y + rect.h;
|
|
394
|
+
for (const clip of clips ?? []) {
|
|
395
|
+
x0 = Math.max(x0, clip.x);
|
|
396
|
+
y0 = Math.max(y0, clip.y);
|
|
397
|
+
x1 = Math.min(x1, clip.x + clip.w);
|
|
398
|
+
y1 = Math.min(y1, clip.y + clip.h);
|
|
399
|
+
}
|
|
400
|
+
if (x1 <= x0 || y1 <= y0)
|
|
401
|
+
return null;
|
|
402
|
+
return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
|
|
403
|
+
}
|
|
404
|
+
// ---- generated content ----------------------------------------------------------------
|
|
405
|
+
/** A CSS string's escapes ("\201C ", "\"") resolved. */
|
|
406
|
+
function unescapeCss(value) {
|
|
407
|
+
return value.replace(/\\([0-9a-f]{1,6})\s?|\\(.)/gis, (_, hex, char) => {
|
|
408
|
+
if (hex) {
|
|
409
|
+
const code = parseInt(hex, 16);
|
|
410
|
+
return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : "�";
|
|
411
|
+
}
|
|
412
|
+
return char === "\n" ? "" : (char ?? "");
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The text a `::before`/`::after` shows, from its computed `content`:
|
|
417
|
+
* strings and `attr(name)` joined (an attribute read through `attr`),
|
|
418
|
+
* quotes, counters and images left out, the alt text after "/" ignored.
|
|
419
|
+
* Null when it generates no box (`none`, `normal`).
|
|
420
|
+
*/
|
|
421
|
+
export function pseudoText(content, attr) {
|
|
422
|
+
const value = content.trim();
|
|
423
|
+
if (!value || value === "none" || value === "normal")
|
|
424
|
+
return null;
|
|
425
|
+
let out = "";
|
|
426
|
+
let i = 0;
|
|
427
|
+
while (i < value.length) {
|
|
428
|
+
const c = value[i];
|
|
429
|
+
if (c === '"' || c === "'") {
|
|
430
|
+
let j = i + 1;
|
|
431
|
+
let raw = "";
|
|
432
|
+
while (j < value.length && value[j] !== c) {
|
|
433
|
+
if (value[j] === "\\" && j + 1 < value.length) {
|
|
434
|
+
raw += value[j] + value[j + 1];
|
|
435
|
+
j += 2;
|
|
436
|
+
}
|
|
437
|
+
else
|
|
438
|
+
raw += value[j++];
|
|
439
|
+
}
|
|
440
|
+
out += unescapeCss(raw);
|
|
441
|
+
i = j + 1;
|
|
442
|
+
}
|
|
443
|
+
else if (c === "/") {
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
else if (/\s/.test(c)) {
|
|
447
|
+
i++;
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
const fn = /^([a-z-]+)\(/i.exec(value.slice(i));
|
|
451
|
+
if (fn) {
|
|
452
|
+
// A function: find its closing parenthesis.
|
|
453
|
+
let depth = 0;
|
|
454
|
+
let j = i + fn[1].length;
|
|
455
|
+
for (; j < value.length; j++) {
|
|
456
|
+
if (value[j] === "(")
|
|
457
|
+
depth++;
|
|
458
|
+
else if (value[j] === ")" && --depth === 0)
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
const args = value.slice(i + fn[1].length + 1, j).trim();
|
|
462
|
+
if (fn[1].toLowerCase() === "attr") {
|
|
463
|
+
const name = args.split(/[\s,]/)[0]?.trim();
|
|
464
|
+
if (name)
|
|
465
|
+
out += attr(name) ?? "";
|
|
466
|
+
}
|
|
467
|
+
i = j + 1;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
// A keyword (open-quote, no-close-quote…): paints no text here.
|
|
471
|
+
const word = /^\S+/.exec(value.slice(i))?.[0] ?? c;
|
|
472
|
+
i += word.length;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return out;
|
|
477
|
+
}
|
|
478
|
+
/** Words laid in lines no wider than `width`, as `white-space: normal` wraps them. */
|
|
479
|
+
export function wrapWords(text, width, measure) {
|
|
480
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
481
|
+
const lines = [];
|
|
482
|
+
let line = "";
|
|
483
|
+
for (const word of words) {
|
|
484
|
+
const next = line ? `${line} ${word}` : word;
|
|
485
|
+
if (line && measure(next) > width + EPSILON) {
|
|
486
|
+
lines.push(line);
|
|
487
|
+
line = word;
|
|
488
|
+
}
|
|
489
|
+
else
|
|
490
|
+
line = next;
|
|
491
|
+
}
|
|
492
|
+
if (line)
|
|
493
|
+
lines.push(line);
|
|
494
|
+
return lines;
|
|
495
|
+
}
|
|
496
|
+
// ---- masks ----------------------------------------------------------------------------
|
|
497
|
+
/** Whether a mask layer is solid (a gradient of one opaque colour: "linear-gradient(#000 0 0)"). */
|
|
498
|
+
function solidLayer(layer) {
|
|
499
|
+
const g = parseGradient(layer, { x: 0, y: 0, w: 1, h: 1 });
|
|
500
|
+
if (!g || !g.stops.length)
|
|
501
|
+
return false;
|
|
502
|
+
return g.stops.every((s) => !isTransparent(s.color) && s.color === g.stops[0].color);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The box a mask cuts out of its element, for the one mask the painter
|
|
506
|
+
* reads: two solid layers, one clipped to the content (or padding) box, the
|
|
507
|
+
* other to the border box, excluded from each other, which leaves only a
|
|
508
|
+
* ring (an animated border such as `border-beam`). Null for no mask or any
|
|
509
|
+
* other (painted as if unmasked).
|
|
510
|
+
*/
|
|
511
|
+
export function maskHole(mask) {
|
|
512
|
+
if (!mask.image || mask.image === "none")
|
|
513
|
+
return null;
|
|
514
|
+
const layers = splitTop(mask.image);
|
|
515
|
+
if (layers.length !== 2 || !layers.every(solidLayer))
|
|
516
|
+
return null;
|
|
517
|
+
const composite = splitTop(mask.composite)[0] ?? "";
|
|
518
|
+
if (composite !== "exclude" && composite !== "xor")
|
|
519
|
+
return null;
|
|
520
|
+
const clips = splitTop(mask.clip || "border-box");
|
|
521
|
+
const of = (i) => clips[i] ?? clips[clips.length - 1] ?? "border-box";
|
|
522
|
+
const pair = [of(0), of(1)];
|
|
523
|
+
const outer = pair.filter((c) => c === "border-box" || c === "no-clip").length;
|
|
524
|
+
const inner = pair.find((c) => c === "content-box" || c === "padding-box");
|
|
525
|
+
return outer === 1 && inner ? inner : null;
|
|
526
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NodePaint, PaintClip, PaintRect, Radii } from "./types.js";
|
|
2
|
+
/** A rect path with per-corner radii (clamped so they fit). */
|
|
3
|
+
export declare function roundRectPath(context: CanvasRenderingContext2D, rect: PaintRect, radii: Radii): void;
|
|
4
|
+
/** Where an image lands in its box, by `object-fit`. */
|
|
5
|
+
export declare function fitImage(fit: string, box: PaintRect, width: number, height: number): PaintRect;
|
|
6
|
+
/** Narrows the current clip to a rounded rect (clips nest: each one intersects). */
|
|
7
|
+
export declare function clipTo(context: CanvasRenderingContext2D, clip: PaintClip): void;
|
|
8
|
+
/** Draws a display list as vectors, in its own units. */
|
|
9
|
+
export declare function drawPaint(context: CanvasRenderingContext2D, paint: NodePaint): void;
|
|
10
|
+
/**
|
|
11
|
+
* The bitmap scale for a zoom: rounded up to a power of two, so a node is
|
|
12
|
+
* re-rasterised only when the zoom crosses a bucket.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rasterScale(zoom: number, pixelRatio?: number): number;
|
|
15
|
+
/** Rasterises a display list at `scale` (bitmap px per unit). */
|
|
16
|
+
export declare function rasterizePaint(paint: NodePaint, scale: number): HTMLCanvasElement;
|