@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,589 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Reads a piece of DOM into a display list (types.ts) from what the browser
|
|
3
|
+
* computed: boxes (fills, gradients, per-side borders, shadows and rings,
|
|
4
|
+
* outlines), `::before`/`::after` boxes, images, video frames, canvases,
|
|
5
|
+
* inline SVG (turned as the DOM turns it), text lines as the browser wrapped
|
|
6
|
+
* them, form fields' values and placeholders, and, for a node being edited,
|
|
7
|
+
* the caret, the selection and an IME composition. No library knowledge: any
|
|
8
|
+
* UI kit that renders DOM paints the same way.
|
|
9
|
+
*/
|
|
10
|
+
import { backdropBlurOf, clipRect, clipsContent, clipsFor, isTransparent, maskHole, maskLayers, paddingClip, parseGradients, parseShadows, pseudoText, pushClip, radiiOf, wrapWords } from "./css.js";
|
|
11
|
+
import { fieldText, fontMetrics, fontsSettled, textLines, textWidth, transformText } from "./text.js";
|
|
12
|
+
const NO_CLIPS = [];
|
|
13
|
+
/** An op's whole footprint: its rect, and the shadows and outline a box paints outside it. */
|
|
14
|
+
function extentOf(op) {
|
|
15
|
+
let extent = op.rect;
|
|
16
|
+
if (op.kind === "box") {
|
|
17
|
+
for (const s of op.shadows ?? []) {
|
|
18
|
+
if (s.inset)
|
|
19
|
+
continue;
|
|
20
|
+
const by = s.spread + s.blur;
|
|
21
|
+
extent = union(extent, { x: op.rect.x + s.x - by, y: op.rect.y + s.y - by, w: op.rect.w + by * 2, h: op.rect.h + by * 2 });
|
|
22
|
+
}
|
|
23
|
+
if (op.outline) {
|
|
24
|
+
const by = op.outline.offset + op.outline.width;
|
|
25
|
+
extent = union(extent, { x: op.rect.x - by, y: op.rect.y - by, w: op.rect.w + by * 2, h: op.rect.h + by * 2 });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return extent;
|
|
29
|
+
}
|
|
30
|
+
const IMAGE_CACHE = new Map();
|
|
31
|
+
function image(url) {
|
|
32
|
+
let img = IMAGE_CACHE.get(url);
|
|
33
|
+
if (!img) {
|
|
34
|
+
img = new Image();
|
|
35
|
+
img.decoding = "async";
|
|
36
|
+
img.src = url;
|
|
37
|
+
IMAGE_CACHE.set(url, img);
|
|
38
|
+
}
|
|
39
|
+
return img;
|
|
40
|
+
}
|
|
41
|
+
/** An image a loader already holds, ready to draw; null while it loads. */
|
|
42
|
+
export function loadedImage(url) {
|
|
43
|
+
const img = image(url);
|
|
44
|
+
return img.complete && img.naturalWidth > 0 ? img : null;
|
|
45
|
+
}
|
|
46
|
+
/** An inline SVG as an image of itself, with its computed colour for `currentColor`. */
|
|
47
|
+
function svgUrl(element, color, rect) {
|
|
48
|
+
const clone = element.cloneNode(true);
|
|
49
|
+
clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
50
|
+
clone.setAttribute("width", String(rect.w));
|
|
51
|
+
clone.setAttribute("height", String(rect.h));
|
|
52
|
+
clone.style.color = color;
|
|
53
|
+
clone.style.transform = "";
|
|
54
|
+
clone.style.rotate = "";
|
|
55
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(clone))}`;
|
|
56
|
+
}
|
|
57
|
+
function union(a, b) {
|
|
58
|
+
if (!a)
|
|
59
|
+
return { ...b };
|
|
60
|
+
const x = Math.min(a.x, b.x);
|
|
61
|
+
const y = Math.min(a.y, b.y);
|
|
62
|
+
return { x, y, w: Math.max(a.x + a.w, b.x + b.w) - x, h: Math.max(a.y + a.h, b.y + b.h) - y };
|
|
63
|
+
}
|
|
64
|
+
/** The rotation of an element's own transform and `rotate`, in radians (0 for none). */
|
|
65
|
+
function rotationOf(style) {
|
|
66
|
+
const own = /^(-?[\d.]+)deg$/.exec(style.rotate ?? "");
|
|
67
|
+
const turn = own ? (parseFloat(own[1]) * Math.PI) / 180 : 0;
|
|
68
|
+
const m = /matrix\(([^)]+)\)/.exec(style.transform ?? "");
|
|
69
|
+
if (!m)
|
|
70
|
+
return turn;
|
|
71
|
+
const [a, b] = m[1].split(",").map((v) => parseFloat(v));
|
|
72
|
+
return turn + Math.atan2(b, a);
|
|
73
|
+
}
|
|
74
|
+
/** A turned image's own box: its screen rect is the turned box's bounds (wider, at an angle). */
|
|
75
|
+
function turnedRect(rect, style, rotation) {
|
|
76
|
+
if (!rotation)
|
|
77
|
+
return rect;
|
|
78
|
+
const w = parseFloat(style.width);
|
|
79
|
+
const h = parseFloat(style.height);
|
|
80
|
+
if (!(w > 0) || !(h > 0))
|
|
81
|
+
return rect;
|
|
82
|
+
return { x: rect.x + (rect.w - w) / 2, y: rect.y + (rect.h - h) / 2, w, h };
|
|
83
|
+
}
|
|
84
|
+
const TEXT_FIELD = /^(text|search|email|url|tel|password|number|)$/;
|
|
85
|
+
/** IME compositions in progress, per field (recorded by the DOM watcher). */
|
|
86
|
+
const compositions = new WeakMap();
|
|
87
|
+
export function setComposition(element, value) {
|
|
88
|
+
if (value)
|
|
89
|
+
compositions.set(element, value);
|
|
90
|
+
else
|
|
91
|
+
compositions.delete(element);
|
|
92
|
+
}
|
|
93
|
+
function borders(style) {
|
|
94
|
+
const side = (s) => {
|
|
95
|
+
const st = style[`border${s}Style`];
|
|
96
|
+
const width = st === "none" || st === "hidden" ? 0 : parseFloat(style[`border${s}Width`]) || 0;
|
|
97
|
+
return { width, color: style[`border${s}Color`], style: st };
|
|
98
|
+
};
|
|
99
|
+
return [side("Top"), side("Right"), side("Bottom"), side("Left")];
|
|
100
|
+
}
|
|
101
|
+
/** Border widths, top/right/bottom/left (a hidden or absent border is 0). */
|
|
102
|
+
function borderWidths(style) {
|
|
103
|
+
const width = (s) => {
|
|
104
|
+
const st = style[`border${s}Style`];
|
|
105
|
+
return st === "none" || st === "hidden" ? 0 : parseFloat(style[`border${s}Width`]) || 0;
|
|
106
|
+
};
|
|
107
|
+
return [width("Top"), width("Right"), width("Bottom"), width("Left")];
|
|
108
|
+
}
|
|
109
|
+
const dashOf = (style, width) => (style === "dashed" ? [width * 3, width * 2] : style === "dotted" ? [width, width] : undefined);
|
|
110
|
+
export function collectPaint(root, options = {}) {
|
|
111
|
+
const zoom = options.zoom ?? 1;
|
|
112
|
+
const origin = root.getBoundingClientRect();
|
|
113
|
+
const ops = [];
|
|
114
|
+
/** Where ops go: the root's list, or a masked element's own (a group). */
|
|
115
|
+
let target = ops;
|
|
116
|
+
let bounds = null;
|
|
117
|
+
let pending = false;
|
|
118
|
+
const ignoreVisibility = options.ignoreVisibility;
|
|
119
|
+
/** With a hook, the app follows what is missing; without, the paint is pending. */
|
|
120
|
+
const imageOf = (url) => (options.image ? options.image(url) : loadedImage(url));
|
|
121
|
+
const missed = (hook) => {
|
|
122
|
+
if (!hook)
|
|
123
|
+
pending = true;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* A screen rect in the root's layout units, on whole CSS pixels: the
|
|
127
|
+
* browser paints boxes, images and text lines pixel-snapped in layout
|
|
128
|
+
* space (Chromium's pixel-snapped rects: edges rounded, half up), so a box
|
|
129
|
+
* laid out at y = 90.5 shows at 91. Without it a node laid out at half
|
|
130
|
+
* pixels paints half a pixel off its UI. (`snap: false` keeps them exact.)
|
|
131
|
+
*/
|
|
132
|
+
const snap = options.snap === false ? (v) => v : (v) => Math.round(v + 1e-3);
|
|
133
|
+
const toLocal = (rect) => {
|
|
134
|
+
const x = snap((rect.left - origin.left) / zoom);
|
|
135
|
+
const y = snap((rect.top - origin.top) / zoom);
|
|
136
|
+
return {
|
|
137
|
+
x,
|
|
138
|
+
y,
|
|
139
|
+
w: snap((rect.left + rect.width - origin.left) / zoom) - x,
|
|
140
|
+
h: snap((rect.top + rect.height - origin.top) / zoom) - y,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Adds an op inside its clips: only the clips that cut it are kept on it
|
|
145
|
+
* (most ops sit wholly inside theirs), an op they hide entirely is left
|
|
146
|
+
* out, and the bounds take only what shows (shadows and outlines too).
|
|
147
|
+
*/
|
|
148
|
+
const push = (op, clips = NO_CLIPS) => {
|
|
149
|
+
// Shadows and outlines paint outside the box: keep them in the bounds (bitmaps).
|
|
150
|
+
const extent = extentOf(op);
|
|
151
|
+
const cutting = clipsFor(clips, extent);
|
|
152
|
+
const visible = clipRect(extent, cutting);
|
|
153
|
+
if (!visible)
|
|
154
|
+
return;
|
|
155
|
+
if (cutting)
|
|
156
|
+
op.clips = cutting;
|
|
157
|
+
target.push(op);
|
|
158
|
+
bounds = union(bounds, visible);
|
|
159
|
+
};
|
|
160
|
+
/** The box painting of an element or pseudo-element: shadows, fill, gradients, borders, outline. */
|
|
161
|
+
const paintBox = (style, rect, alpha, clip) => {
|
|
162
|
+
const radii = radiiOf(style, rect);
|
|
163
|
+
const fill = isTransparent(style.backgroundColor) ? undefined : style.backgroundColor;
|
|
164
|
+
const gradients = parseGradients(style.backgroundImage, rect, style.backgroundSize).reverse();
|
|
165
|
+
// Only DOM screen rects need division by zoom. Computed CSS lengths already
|
|
166
|
+
// describe the untransformed node, just like fonts and corner radii.
|
|
167
|
+
const sides = borders(style);
|
|
168
|
+
const visibleSides = sides.filter((s) => s.width > 0 && !isTransparent(s.color));
|
|
169
|
+
const uniform = visibleSides.length === 4 && sides.every((s) => s.width === sides[0].width && s.color === sides[0].color && s.style === sides[0].style);
|
|
170
|
+
const shadows = parseShadows(style.boxShadow);
|
|
171
|
+
const outlineWidth = style.outlineStyle === "none" ? 0 : parseFloat(style.outlineWidth) || 0;
|
|
172
|
+
const outline = outlineWidth > 0 && !isTransparent(style.outlineColor)
|
|
173
|
+
? { width: outlineWidth, color: style.outlineColor, offset: (parseFloat(style.outlineOffset) || 0), style: style.outlineStyle }
|
|
174
|
+
: undefined;
|
|
175
|
+
if (!fill && !gradients.length && !visibleSides.length && !shadows.length && !outline)
|
|
176
|
+
return radii;
|
|
177
|
+
// A mask that leaves only a ring (an animated border): cut out its inner box.
|
|
178
|
+
const ms = style;
|
|
179
|
+
const maskImage = style.maskImage || ms.webkitMaskImage || "";
|
|
180
|
+
const holeBox = maskHole({
|
|
181
|
+
image: maskImage,
|
|
182
|
+
clip: style.maskClip || ms.webkitMaskClip || "",
|
|
183
|
+
composite: style.maskComposite || ms.webkitMaskComposite || "",
|
|
184
|
+
});
|
|
185
|
+
let hole;
|
|
186
|
+
if (holeBox) {
|
|
187
|
+
const widths = borderWidths(style);
|
|
188
|
+
hole = paddingClip(rect, radii, widths);
|
|
189
|
+
if (holeBox === "content-box") {
|
|
190
|
+
const padding = [style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft].map((v) => parseFloat(v) || 0);
|
|
191
|
+
hole = paddingClip(hole, hole.radii, padding);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
push({
|
|
195
|
+
kind: "box",
|
|
196
|
+
rect,
|
|
197
|
+
radii,
|
|
198
|
+
fill,
|
|
199
|
+
gradients: gradients.length ? gradients : undefined,
|
|
200
|
+
stroke: uniform ? sides[0].color : undefined,
|
|
201
|
+
strokeWidth: uniform ? sides[0].width : undefined,
|
|
202
|
+
dash: uniform ? dashOf(sides[0].style, sides[0].width) : undefined,
|
|
203
|
+
sides: !uniform && visibleSides.length ? sides : undefined,
|
|
204
|
+
shadows: shadows.length ? shadows : undefined,
|
|
205
|
+
outline,
|
|
206
|
+
hole,
|
|
207
|
+
backdropBlur: backdropBlurOf(style.backdropFilter) || undefined,
|
|
208
|
+
alpha,
|
|
209
|
+
}, clip);
|
|
210
|
+
return radii;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* A `::before`/`::after`: an absolutely placed one paints its box (it has
|
|
214
|
+
* no DOM rect to read), and any text its `content` generates (a literal or
|
|
215
|
+
* `attr()`, e.g. an empty editor's placeholder) paints in its own font and
|
|
216
|
+
* colour. In-flow text has no rect either: it is set at the start of the
|
|
217
|
+
* element's content box (by its `text-align`), wrapped to its width.
|
|
218
|
+
*/
|
|
219
|
+
const pseudo = (element, es, which, box, alpha, clip) => {
|
|
220
|
+
const ps = getComputedStyle(element, which);
|
|
221
|
+
if (ps.content === "none" || ps.content === "normal" || ps.display === "none")
|
|
222
|
+
return;
|
|
223
|
+
const opacity = alpha * (parseFloat(ps.opacity) || 0);
|
|
224
|
+
if (opacity <= 0.01 || (!ignoreVisibility && ps.visibility !== "visible"))
|
|
225
|
+
return;
|
|
226
|
+
const text = transformText(pseudoText(ps.content, (name) => element.getAttribute(name)) ?? "", ps.textTransform).trim();
|
|
227
|
+
const bl = parseFloat(es.borderLeftWidth) || 0;
|
|
228
|
+
const bt = parseFloat(es.borderTopWidth) || 0;
|
|
229
|
+
const pw = box.w - bl - (parseFloat(es.borderRightWidth) || 0);
|
|
230
|
+
const ph = box.h - bt - (parseFloat(es.borderBottomWidth) || 0);
|
|
231
|
+
if (ps.position !== "absolute" && ps.position !== "fixed") {
|
|
232
|
+
if (!text)
|
|
233
|
+
return;
|
|
234
|
+
const pl = parseFloat(es.paddingLeft) || 0;
|
|
235
|
+
const pt = parseFloat(es.paddingTop) || 0;
|
|
236
|
+
const content = { x: box.x + bl + pl, y: box.y + bt + pt, w: Math.max(0, pw - pl - (parseFloat(es.paddingRight) || 0)) };
|
|
237
|
+
// An `::after` follows what the element holds: right of its last line.
|
|
238
|
+
if (which === "::after") {
|
|
239
|
+
const range = document.createRange();
|
|
240
|
+
range.selectNodeContents(element);
|
|
241
|
+
const rects = range.getClientRects();
|
|
242
|
+
const last = rects[rects.length - 1];
|
|
243
|
+
if (last && (last.width > 0 || last.height > 0)) {
|
|
244
|
+
const end = toLocal(last);
|
|
245
|
+
// One line (no width: it isn't wrapped).
|
|
246
|
+
pseudoLines(text, ps, { x: end.x + end.w, y: end.y, w: 0 }, "left", opacity, clip);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
pseudoLines(text, ps, content, es.textAlign, opacity, clip);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const len = (v, size) => (v === "auto" ? NaN : v.endsWith("%") ? (parseFloat(v) / 100) * size : parseFloat(v));
|
|
254
|
+
const left = len(ps.left, pw);
|
|
255
|
+
const right = len(ps.right, pw);
|
|
256
|
+
const top = len(ps.top, ph);
|
|
257
|
+
const bottom = len(ps.bottom, ph);
|
|
258
|
+
let width = len(ps.width, pw);
|
|
259
|
+
let height = len(ps.height, ph);
|
|
260
|
+
if (!Number.isFinite(width))
|
|
261
|
+
width = Number.isFinite(left) && Number.isFinite(right) ? pw - left - right : NaN;
|
|
262
|
+
if (!Number.isFinite(height))
|
|
263
|
+
height = Number.isFinite(top) && Number.isFinite(bottom) ? ph - top - bottom : NaN;
|
|
264
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0)
|
|
265
|
+
return;
|
|
266
|
+
const x = Number.isFinite(left) ? left : Number.isFinite(right) ? pw - right - width : 0;
|
|
267
|
+
const y = Number.isFinite(top) ? top : Number.isFinite(bottom) ? ph - bottom - height : 0;
|
|
268
|
+
const rect = { x: box.x + bl + x, y: box.y + bt + y, w: width, h: height };
|
|
269
|
+
paintBox(ps, rect, opacity, clip);
|
|
270
|
+
if (text) {
|
|
271
|
+
const inset = (side) => (parseFloat(ps[`border${side}Width`]) || 0) + (parseFloat(ps[`padding${side}`]) || 0);
|
|
272
|
+
pseudoLines(text, ps, { x: rect.x + inset("Left"), y: rect.y + inset("Top"), w: Math.max(0, rect.w - inset("Left") - inset("Right")) }, ps.textAlign, opacity, clip);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
/** Generated text laid in lines from a content box's top-left corner. */
|
|
276
|
+
const pseudoLines = (text, ps, content, align, alpha, clip) => {
|
|
277
|
+
const font = ps.font || `${ps.fontStyle} ${ps.fontWeight} ${ps.fontSize} ${ps.fontFamily}`;
|
|
278
|
+
const size = parseFloat(ps.fontSize) || 14;
|
|
279
|
+
const { ascent, descent } = fontMetrics(font, size);
|
|
280
|
+
const lineHeight = ps.lineHeight === "normal" ? ascent + descent : ps.lineHeight.endsWith("px") ? parseFloat(ps.lineHeight) : (parseFloat(ps.lineHeight) || 1.2) * size;
|
|
281
|
+
const spacing = ps.letterSpacing !== "normal" ? ps.letterSpacing : undefined;
|
|
282
|
+
const measure = (line) => textWidth(line, font, spacing ?? "0px");
|
|
283
|
+
const wraps = !/^(nowrap|pre)$/.test(ps.whiteSpace) && content.w > 0;
|
|
284
|
+
const lines = wraps ? wrapWords(text, content.w, measure) : [text];
|
|
285
|
+
lines.forEach((line, index) => {
|
|
286
|
+
const w = measure(line);
|
|
287
|
+
const x = align === "center" ? content.x + (content.w - w) / 2 : align === "right" || align === "end" ? content.x + content.w - w : content.x;
|
|
288
|
+
pushLocalText(line, { x, y: content.y + index * lineHeight, w, h: lineHeight }, ps, alpha, clip);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
const pushImage = (rect, radii, source, w, h, fit, alpha, clip, rotate = 0) => push({ kind: "image", rect, radii, source, sourceWidth: w, sourceHeight: h, fit, alpha, rotate: rotate || undefined }, clip);
|
|
292
|
+
// Text is snapped vertically only (the browser places glyphs at subpixel x).
|
|
293
|
+
const pushText = (text, screen, style, alpha, clip, color = style.color) => {
|
|
294
|
+
const local = toLocal(screen);
|
|
295
|
+
const x = (screen.left - origin.left) / zoom;
|
|
296
|
+
pushLocalText(text, { ...local, x, w: (screen.left + screen.width - origin.left) / zoom - x }, style, alpha, clip, color);
|
|
297
|
+
};
|
|
298
|
+
/** A line of text in local units (`rect` its content area, as tall as its line box). */
|
|
299
|
+
const pushLocalText = (text, rect, style, alpha, clip, color = style.color) => {
|
|
300
|
+
if (!text)
|
|
301
|
+
return;
|
|
302
|
+
if (!fontsSettled(document.fonts?.status))
|
|
303
|
+
pending = true;
|
|
304
|
+
const font = style.font || `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
|
|
305
|
+
const { ascent, descent } = fontMetrics(font, parseFloat(style.fontSize) || 14);
|
|
306
|
+
// The content area is ascent + descent tall; centre the font's box in it.
|
|
307
|
+
const baseline = (rect.h - ascent - descent) / 2 + ascent;
|
|
308
|
+
const decoration = style.textDecorationLine;
|
|
309
|
+
const underline = decoration.includes("underline")
|
|
310
|
+
? { y: baseline + 2, thickness: Math.max(1, parseFloat(style.textDecorationThickness) || 1), color: isTransparent(style.textDecorationColor) ? color : style.textDecorationColor }
|
|
311
|
+
: undefined;
|
|
312
|
+
push({
|
|
313
|
+
kind: "text",
|
|
314
|
+
rect,
|
|
315
|
+
text,
|
|
316
|
+
font,
|
|
317
|
+
color,
|
|
318
|
+
baseline,
|
|
319
|
+
letterSpacing: style.letterSpacing !== "normal" ? style.letterSpacing : undefined,
|
|
320
|
+
underline,
|
|
321
|
+
alpha,
|
|
322
|
+
}, clip);
|
|
323
|
+
};
|
|
324
|
+
const visitField = (field, style, rect, radii, alpha, clip) => {
|
|
325
|
+
if (field instanceof HTMLInputElement && !TEXT_FIELD.test(field.type))
|
|
326
|
+
return;
|
|
327
|
+
const value = field.value;
|
|
328
|
+
const placeholder = !value && field.placeholder;
|
|
329
|
+
const text = value ? (field instanceof HTMLInputElement && field.type === "password" ? "•".repeat(value.length) : value) : placeholder || "";
|
|
330
|
+
const bl = parseFloat(style.borderLeftWidth) || 0;
|
|
331
|
+
const bt = parseFloat(style.borderTopWidth) || 0;
|
|
332
|
+
// A field clips its text to its padding box, inside its own clips.
|
|
333
|
+
const inner = pushClip(clip, paddingClip(rect, radii, [bt, parseFloat(style.borderRightWidth) || 0, parseFloat(style.borderBottomWidth) || 0, bl]));
|
|
334
|
+
const laid = fieldText(field, text);
|
|
335
|
+
const focused = options.editing && document.activeElement === field;
|
|
336
|
+
if (focused && field.selectionStart !== null && field.selectionEnd !== null && field.selectionStart !== field.selectionEnd && value) {
|
|
337
|
+
const color = selectionColor(field);
|
|
338
|
+
for (const r of laid.range(field.selectionStart, field.selectionEnd))
|
|
339
|
+
push({ kind: "highlight", rect: toLocal(r), color, alpha }, inner);
|
|
340
|
+
}
|
|
341
|
+
const color = placeholder ? getComputedStyle(field, "::placeholder").color : style.color;
|
|
342
|
+
for (const line of laid.lines)
|
|
343
|
+
pushText(transformText(line.text, style.textTransform), line.rect, style, alpha, inner, color);
|
|
344
|
+
const composing = compositions.get(field);
|
|
345
|
+
if (focused && composing && value) {
|
|
346
|
+
for (const r of laid.range(composing.start, composing.end)) {
|
|
347
|
+
const local = toLocal(r);
|
|
348
|
+
push({ kind: "highlight", rect: { x: local.x, y: local.y + local.h - 1.5 / zoom, w: local.w, h: 1.5 / zoom }, color: style.color, alpha }, inner);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (focused && options.caretOn !== false && field.selectionStart === field.selectionEnd && field.selectionStart !== null) {
|
|
352
|
+
const at = value ? field.selectionStart : 0;
|
|
353
|
+
for (const r of laid.range(at, at))
|
|
354
|
+
push({ kind: "caret", rect: toLocal(new DOMRect(r.left, r.top, zoom, r.height)), color: caretColor(style), alpha }, inner);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* An element that is painted as one (CSS group opacity, a mask other than a
|
|
359
|
+
* border ring): it and what it holds become a group, drawn together on a
|
|
360
|
+
* layer, then masked and faded as a whole. A half-transparent button whose
|
|
361
|
+
* text sits on its fill fades as one, as the browser shows it, not as a
|
|
362
|
+
* faded fill under faded text.
|
|
363
|
+
*/
|
|
364
|
+
const visit = (element, alpha, clip) => {
|
|
365
|
+
if (!(element instanceof HTMLElement) || (options.skip && element.matches(options.skip)))
|
|
366
|
+
return visitElement(element, alpha, clip);
|
|
367
|
+
const style = getComputedStyle(element);
|
|
368
|
+
if (style.display === "none")
|
|
369
|
+
return;
|
|
370
|
+
const own = parseFloat(style.opacity);
|
|
371
|
+
const fades = own > 0.01 && own < 0.99 && element.childElementCount + element.childNodes.length > 0;
|
|
372
|
+
const ms = style;
|
|
373
|
+
const image = style.maskImage || ms.webkitMaskImage || "";
|
|
374
|
+
const composite = style.maskComposite || ms.webkitMaskComposite || "";
|
|
375
|
+
let masks = null;
|
|
376
|
+
let rect = null;
|
|
377
|
+
if (image && image !== "none" && !maskHole({ image, clip: style.maskClip || ms.webkitMaskClip || "", composite })) {
|
|
378
|
+
rect = toLocal(element.getBoundingClientRect());
|
|
379
|
+
masks = rect.w > 0 && rect.h > 0 ? maskLayers({ image, composite, size: style.maskSize }, rect) : null;
|
|
380
|
+
}
|
|
381
|
+
if (!masks && !fades)
|
|
382
|
+
return visitElement(element, alpha, clip);
|
|
383
|
+
rect ??= toLocal(element.getBoundingClientRect());
|
|
384
|
+
const outer = target;
|
|
385
|
+
const inner = [];
|
|
386
|
+
target = inner;
|
|
387
|
+
try {
|
|
388
|
+
// Its own opacity goes on the group, not on each thing it holds.
|
|
389
|
+
visitElement(element, fades ? 1 : alpha, clip, fades);
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
target = outer;
|
|
393
|
+
}
|
|
394
|
+
const groupAlpha = fades ? alpha * own : 1;
|
|
395
|
+
// One op (or none) needs no layer: faded by itself.
|
|
396
|
+
if (!masks && inner.length <= 1) {
|
|
397
|
+
for (const op of inner)
|
|
398
|
+
target.push({ ...op, alpha: op.alpha * groupAlpha });
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (!inner.length)
|
|
402
|
+
return;
|
|
403
|
+
// Masked: its own box (CSS masks clip to it). Only faded: all it holds,
|
|
404
|
+
// children painted outside its box included.
|
|
405
|
+
const area = masks ? rect : inner.reduce((all, op) => union(all, extentOf(op)), extentOf(inner[0]));
|
|
406
|
+
push({ kind: "group", rect: area, ops: inner, masks: masks ?? [], alpha: groupAlpha }, clip);
|
|
407
|
+
};
|
|
408
|
+
const visitElement = (element, alpha, clip, ownOpacityApplied = false) => {
|
|
409
|
+
if (options.skip && element.matches(options.skip))
|
|
410
|
+
return;
|
|
411
|
+
if (element.dataset?.avisPaintMirror !== undefined)
|
|
412
|
+
return;
|
|
413
|
+
const style = getComputedStyle(element);
|
|
414
|
+
if (style.display === "none")
|
|
415
|
+
return;
|
|
416
|
+
const opacity = ownOpacityApplied ? alpha : alpha * (parseFloat(style.opacity) || 0);
|
|
417
|
+
if (opacity <= 0.01)
|
|
418
|
+
return;
|
|
419
|
+
const hidden = !ignoreVisibility && style.visibility !== "visible";
|
|
420
|
+
const rect = toLocal(element.getBoundingClientRect());
|
|
421
|
+
if (rect.w <= 0 || rect.h <= 0) {
|
|
422
|
+
const clipsAll = style.display !== "contents" && clipsContent(style);
|
|
423
|
+
if (!clipsAll)
|
|
424
|
+
visitChildren(element, style, opacity, clip);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (element instanceof SVGElement) {
|
|
428
|
+
if (!(element instanceof SVGSVGElement) || hidden)
|
|
429
|
+
return;
|
|
430
|
+
const rotation = rotationOf(style);
|
|
431
|
+
const box = turnedRect(rect, style, rotation);
|
|
432
|
+
const img = loadedImage(svgUrl(element, style.color, box));
|
|
433
|
+
if (!img) {
|
|
434
|
+
pending = true;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
pushImage(box, [0, 0, 0, 0], img, img.naturalWidth, img.naturalHeight, "fill", opacity, clip, rotation);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const radii = hidden ? radiiOf(style, rect) : paintBox(style, rect, opacity, clip);
|
|
441
|
+
if (!hidden)
|
|
442
|
+
pseudo(element, style, "::before", rect, opacity, clip);
|
|
443
|
+
if (!hidden) {
|
|
444
|
+
const url = /url\(["']?(.*?)["']?\)/.exec(style.backgroundImage)?.[1];
|
|
445
|
+
if (url && !/gradient\(/.test(style.backgroundImage.split("url(")[0] ?? "")) {
|
|
446
|
+
const img = imageOf(url);
|
|
447
|
+
if (img)
|
|
448
|
+
pushImage(rect, radii, img, img.naturalWidth, img.naturalHeight, style.backgroundSize === "contain" ? "contain" : "cover", opacity, clip);
|
|
449
|
+
else
|
|
450
|
+
missed(options.image);
|
|
451
|
+
}
|
|
452
|
+
if (element instanceof HTMLImageElement) {
|
|
453
|
+
const src = element.currentSrc || element.src;
|
|
454
|
+
const img = element.complete && element.naturalWidth > 0 ? element : src ? imageOf(src) : null;
|
|
455
|
+
const rotation = rotationOf(style);
|
|
456
|
+
if (img)
|
|
457
|
+
pushImage(turnedRect(rect, style, rotation), radii, img, img.naturalWidth, img.naturalHeight, style.objectFit, opacity, clip, rotation);
|
|
458
|
+
else if (src)
|
|
459
|
+
missed(options.image);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (element instanceof HTMLVideoElement) {
|
|
463
|
+
const src = element.currentSrc || element.src;
|
|
464
|
+
if (element.readyState >= 2 && element.videoWidth > 0)
|
|
465
|
+
pushImage(rect, radii, element, element.videoWidth, element.videoHeight, style.objectFit, opacity, clip);
|
|
466
|
+
else if (element.poster) {
|
|
467
|
+
const poster = imageOf(element.poster);
|
|
468
|
+
if (poster)
|
|
469
|
+
pushImage(rect, radii, poster, poster.naturalWidth, poster.naturalHeight, style.objectFit, opacity, clip);
|
|
470
|
+
else
|
|
471
|
+
missed(options.image);
|
|
472
|
+
}
|
|
473
|
+
else if (src) {
|
|
474
|
+
const frame = options.videoFrame?.(src);
|
|
475
|
+
if (frame) {
|
|
476
|
+
const f = frame;
|
|
477
|
+
pushImage(rect, radii, frame, f.width, f.height, style.objectFit, opacity, clip);
|
|
478
|
+
}
|
|
479
|
+
else
|
|
480
|
+
missed(options.videoFrame);
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (element instanceof HTMLCanvasElement) {
|
|
485
|
+
if (element.width > 0 && element.height > 0)
|
|
486
|
+
pushImage(rect, radii, element, element.width, element.height, "fill", opacity, clip);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
490
|
+
visitField(element, style, rect, radii, opacity, clip);
|
|
491
|
+
pseudo(element, style, "::after", rect, opacity, clip);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
if (element instanceof HTMLSelectElement) {
|
|
495
|
+
const option = element.selectedOptions[0];
|
|
496
|
+
if (option) {
|
|
497
|
+
const laid = fieldText(element, option.text);
|
|
498
|
+
for (const line of laid.lines)
|
|
499
|
+
pushText(line.text, line.rect, style, opacity, clip);
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// An overflow box clips its children to its padding box, with its inner
|
|
505
|
+
// radii, inside whatever clips it (a stack: nested boxes all cut).
|
|
506
|
+
const childClip = clipsContent(style) ? pushClip(clip, paddingClip(rect, radii, borderWidths(style))) : clip;
|
|
507
|
+
visitChildren(element, style, opacity, childClip, hidden);
|
|
508
|
+
if (!hidden)
|
|
509
|
+
pseudo(element, style, "::after", rect, opacity, clip);
|
|
510
|
+
};
|
|
511
|
+
function visitChildren(element, style, opacity, childClip, hidden = false) {
|
|
512
|
+
// CSS painting order, simplified: negative z-index, then the flow (DOM
|
|
513
|
+
// order), then positioned children with z auto/0, then positive z-index.
|
|
514
|
+
const layers = [];
|
|
515
|
+
let order = 0;
|
|
516
|
+
for (const child of element.childNodes) {
|
|
517
|
+
let z = 0;
|
|
518
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
519
|
+
const cs = getComputedStyle(child);
|
|
520
|
+
const positioned = cs.position !== "static";
|
|
521
|
+
const zi = parseInt(cs.zIndex, 10);
|
|
522
|
+
z = positioned ? (Number.isFinite(zi) ? (zi < 0 ? -1e6 + zi : zi === 0 ? 0.5 : 1 + zi) : 0.5) : 0;
|
|
523
|
+
}
|
|
524
|
+
layers.push({ z, order: order++, node: child });
|
|
525
|
+
}
|
|
526
|
+
layers.sort((a, b) => a.z - b.z || a.order - b.order);
|
|
527
|
+
for (const { node: child } of layers) {
|
|
528
|
+
if (child.nodeType === Node.ELEMENT_NODE)
|
|
529
|
+
visit(child, opacity, childClip);
|
|
530
|
+
else if (!hidden && child.nodeType === Node.TEXT_NODE) {
|
|
531
|
+
const node = child;
|
|
532
|
+
if (!node.data.trim())
|
|
533
|
+
continue;
|
|
534
|
+
const lines = textLines(node, style.whiteSpace);
|
|
535
|
+
const ellipsis = style.textOverflow === "ellipsis" && style.overflowX !== "visible";
|
|
536
|
+
const limit = ellipsis ? element.getBoundingClientRect().right - ((parseFloat(style.paddingRight) || 0) + (parseFloat(style.borderRightWidth) || 0)) * zoom : Infinity;
|
|
537
|
+
for (const line of lines) {
|
|
538
|
+
let text = transformText(line.text, style.textTransform);
|
|
539
|
+
let rect = line.rect;
|
|
540
|
+
if (rect.right > limit + 0.5) {
|
|
541
|
+
const font = style.font;
|
|
542
|
+
const room = (limit - rect.left) / 1;
|
|
543
|
+
const dots = "…";
|
|
544
|
+
while (text.length && textWidth(text + dots, font, style.letterSpacing) * zoom > room)
|
|
545
|
+
text = text.slice(0, -1);
|
|
546
|
+
text = text.trimEnd() + dots;
|
|
547
|
+
rect = new DOMRect(rect.left, rect.top, room, rect.height);
|
|
548
|
+
}
|
|
549
|
+
pushText(text, rect, style, opacity, childClip);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
for (const child of options.only ?? root.children)
|
|
555
|
+
visit(child, 1, NO_CLIPS);
|
|
556
|
+
// The page's own selection and caret in contenteditable or text (a node being edited).
|
|
557
|
+
if (options.editing) {
|
|
558
|
+
const selection = document.getSelection();
|
|
559
|
+
const range = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
|
|
560
|
+
const active = document.activeElement;
|
|
561
|
+
const inside = range && root.contains(range.commonAncestorContainer) && !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
|
|
562
|
+
if (range && inside) {
|
|
563
|
+
const host = range.startContainer.nodeType === Node.ELEMENT_NODE ? range.startContainer : range.startContainer.parentElement;
|
|
564
|
+
const style = host ? getComputedStyle(host) : null;
|
|
565
|
+
if (!range.collapsed) {
|
|
566
|
+
const color = host ? selectionColor(host) : "Highlight";
|
|
567
|
+
for (const r of range.getClientRects())
|
|
568
|
+
push({ kind: "highlight", rect: toLocal(r), color, alpha: 1 });
|
|
569
|
+
}
|
|
570
|
+
else if (style && options.caretOn !== false && host?.isContentEditable) {
|
|
571
|
+
const rects = range.getClientRects();
|
|
572
|
+
const r = rects[0] ?? host.getBoundingClientRect();
|
|
573
|
+
const lineHeight = parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.3;
|
|
574
|
+
push({ kind: "caret", rect: toLocal(new DOMRect(r.left, r.top, 1, r.height || lineHeight)), color: caretColor(style), alpha: 1 });
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return { ops, bounds: bounds ?? { x: 0, y: 0, w: 0, h: 0 }, pending };
|
|
579
|
+
}
|
|
580
|
+
/** The colour of text selected in this element (`::selection`, else the system's). */
|
|
581
|
+
function selectionColor(element) {
|
|
582
|
+
const color = getComputedStyle(element, "::selection").backgroundColor;
|
|
583
|
+
return isTransparent(color) ? "rgba(0, 117, 255, 0.3)" : color;
|
|
584
|
+
}
|
|
585
|
+
/** The caret colour as the browser would draw it (`caret-color: auto` is the text colour). */
|
|
586
|
+
function caretColor(style) {
|
|
587
|
+
const value = style.getPropertyValue("--avis-caret-color").trim() || style.caretColor;
|
|
588
|
+
return !value || value === "auto" || isTransparent(value) ? style.color : value;
|
|
589
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Gradient, MaskLayer, PaintClip, PaintRect, Radii, Shadow } from "./types.js";
|
|
2
|
+
/** A CSS colour that paints nothing (zero alpha; not just a zero last channel). */
|
|
3
|
+
export declare function isTransparent(color: string): boolean;
|
|
4
|
+
/** A computed radius ("12px", "50%", "12px 8px") in px for a box this size. */
|
|
5
|
+
export declare function parseRadius(value: string, size: number): number;
|
|
6
|
+
export declare function radiiOf(style: CSSStyleDeclaration, rect: PaintRect): Radii;
|
|
7
|
+
/** Splits a comma list at the top level (not inside parentheses). */
|
|
8
|
+
export declare function splitTop(value: string, separator?: string): string[];
|
|
9
|
+
/** `box-shadow` as computed: "rgb(…) 0px 1px 2px 0px, inset …". */
|
|
10
|
+
export declare function parseShadows(value: string): Shadow[];
|
|
11
|
+
/** One layer of `background-image` if it is a gradient, for a box this size. */
|
|
12
|
+
export declare function parseGradient(value: string, rect: PaintRect): Gradient | null;
|
|
13
|
+
/**
|
|
14
|
+
* Every gradient layer of a `background-image`, topmost first as CSS lists
|
|
15
|
+
* them; a layer with a `background-size` of its own is a tile that repeats.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseGradients(value: string, rect: PaintRect, size?: string): Gradient[];
|
|
18
|
+
/** The blur of a `backdrop-filter`, in px (0 for none). */
|
|
19
|
+
export declare function backdropBlurOf(value: string | undefined): number;
|
|
20
|
+
/** A mask of one gradient over the whole box (a segmented meter), or null for none or any other. */
|
|
21
|
+
export declare function maskGradient(image: string, rect: PaintRect): Gradient | null;
|
|
22
|
+
/** A colour's alpha (1 when it has none). */
|
|
23
|
+
export declare function alphaOf(color: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* A `mask-image` of gradient layers over the element's border box, with
|
|
26
|
+
* their `mask-composite`. Null when there is none, when it keeps
|
|
27
|
+
* everything, or for what the painter doesn't read (images, sized or placed
|
|
28
|
+
* layers): it then paints unmasked.
|
|
29
|
+
*/
|
|
30
|
+
export declare function maskLayers(mask: {
|
|
31
|
+
image: string;
|
|
32
|
+
composite: string;
|
|
33
|
+
size?: string;
|
|
34
|
+
position?: string;
|
|
35
|
+
}, rect: PaintRect): MaskLayer[] | null;
|
|
36
|
+
/** Whether an element clips what it holds: overflow other than visible, or paint containment. */
|
|
37
|
+
export declare function clipsContent(style: {
|
|
38
|
+
overflowX: string;
|
|
39
|
+
overflowY: string;
|
|
40
|
+
contain?: string;
|
|
41
|
+
}): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The clip an overflow box puts on its children: its padding box (the border
|
|
44
|
+
* box less the border widths, top/right/bottom/left) with the inner radii
|
|
45
|
+
* (each corner's radius less the wider of its two borders), as CSS clips.
|
|
46
|
+
*/
|
|
47
|
+
export declare function paddingClip(rect: PaintRect, radii: Radii, borders: [number, number, number, number]): PaintClip;
|
|
48
|
+
/** Whether a point lies inside a rounded rect (with half a pixel's slack). */
|
|
49
|
+
export declare function pointInClip(clip: PaintClip, x: number, y: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a rect lies wholly inside a rounded clip: its four corners do (a
|
|
52
|
+
* rounded rect is convex, so the rect between them does too). Such a clip
|
|
53
|
+
* changes nothing for it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function clipContains(clip: PaintClip, rect: PaintRect): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The clip stack (outermost first) with a nested overflow box's clip added:
|
|
58
|
+
* an outer clip that wholly holds the new one is dropped, since it can no
|
|
59
|
+
* longer cut anything inside.
|
|
60
|
+
*/
|
|
61
|
+
export declare function pushClip(stack: readonly PaintClip[], clip: PaintClip): PaintClip[];
|
|
62
|
+
/** The clips of a stack that cut a rect (the others hold it whole); undefined when none do. */
|
|
63
|
+
export declare function clipsFor(stack: readonly PaintClip[], rect: PaintRect): PaintClip[] | undefined;
|
|
64
|
+
/** The part of a rect a clip stack leaves visible (axis-aligned), or null when none is. */
|
|
65
|
+
export declare function clipRect(rect: PaintRect, clips: readonly PaintClip[] | undefined): PaintRect | null;
|
|
66
|
+
/**
|
|
67
|
+
* The text a `::before`/`::after` shows, from its computed `content`:
|
|
68
|
+
* strings and `attr(name)` joined (an attribute read through `attr`),
|
|
69
|
+
* quotes, counters and images left out, the alt text after "/" ignored.
|
|
70
|
+
* Null when it generates no box (`none`, `normal`).
|
|
71
|
+
*/
|
|
72
|
+
export declare function pseudoText(content: string, attr: (name: string) => string | null): string | null;
|
|
73
|
+
/** Words laid in lines no wider than `width`, as `white-space: normal` wraps them. */
|
|
74
|
+
export declare function wrapWords(text: string, width: number, measure: (text: string) => number): string[];
|
|
75
|
+
/**
|
|
76
|
+
* The box a mask cuts out of its element, for the one mask the painter
|
|
77
|
+
* reads: two solid layers, one clipped to the content (or padding) box, the
|
|
78
|
+
* other to the border box, excluded from each other, which leaves only a
|
|
79
|
+
* ring (an animated border such as `border-beam`). Null for no mask or any
|
|
80
|
+
* other (painted as if unmasked).
|
|
81
|
+
*/
|
|
82
|
+
export declare function maskHole(mask: {
|
|
83
|
+
image: string;
|
|
84
|
+
clip: string;
|
|
85
|
+
composite: string;
|
|
86
|
+
}): "content-box" | "padding-box" | null;
|