@weasel-js/core 1.10.0 → 1.10.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/CHANGELOG.md +168 -0
- package/README.md +33 -0
- package/dist/affordances/composeAffordanceLayer.js +21 -21
- package/dist/affordances/composeAffordanceLayer.js.map +1 -1
- package/dist/affordances/hitAffordanceRegions.js +48 -32
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/pathAnchors.js +50 -28
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/affordances/rotateCursor.js +12 -0
- package/dist/affordances/rotateCursor.js.map +1 -0
- package/dist/affordances/rotationHandle.js +40 -43
- package/dist/affordances/rotationHandle.js.map +1 -1
- package/dist/animation/rig/rigNode.js +9 -3
- package/dist/animation/rig/rigNode.js.map +1 -1
- package/dist/animation/rig/rigSeat.js +46 -13
- package/dist/animation/rig/rigSeat.js.map +1 -1
- package/dist/animation/rig/skinBinding.js +22 -14
- package/dist/animation/rig/skinBinding.js.map +1 -1
- package/dist/barrel/canvas.js +29 -28
- package/dist/barrel/interactions.js +33 -32
- package/dist/barrel/paths.js +11 -10
- package/dist/barrel/routing.js +49 -48
- package/dist/barrel/scene.js +10 -10
- package/dist/barrel/viewport.js +24 -21
- package/dist/canvas/Canvas.js +6 -17
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +34 -37
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/CursorCoordsHud.js +3 -3
- package/dist/canvas/CursorCoordsHud.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +3 -3
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +24 -23
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +40 -49
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +297 -259
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +3 -24
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/insertPreviewCommands.js +97 -0
- package/dist/canvas/SceneCanvas/insertPreviewCommands.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/scenePointQuery.js +50 -0
- package/dist/canvas/SceneCanvas/scenePointQuery.js.map +1 -0
- package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js +52 -0
- package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionTunings.js +17 -0
- package/dist/canvas/SceneCanvas/useActionTunings.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasCamera.js +37 -29
- package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +11 -11
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +45 -109
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +49 -41
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +64 -96
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/worldPointAt.js +3 -4
- package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +77 -80
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +3 -3
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/SurfaceCanvas.js +40 -0
- package/dist/canvas/SurfaceCanvas.js.map +1 -0
- package/dist/canvas/adapterDerivedPath.js +13 -13
- package/dist/canvas/adapterDerivedPath.js.map +1 -1
- package/dist/canvas/adapterPickSource.js +34 -0
- package/dist/canvas/adapterPickSource.js.map +1 -0
- package/dist/canvas/affordanceAt.js +1 -1
- package/dist/canvas/affordanceAt.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js.map +1 -1
- package/dist/canvas/buildSceneTree.js +56 -34
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/copiesAbove.js +27 -0
- package/dist/canvas/copiesAbove.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +24 -23
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/editAnchors.js +45 -50
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/hitTestArea.js +30 -15
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +134 -100
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/layout.js +9 -15
- package/dist/canvas/deps/layout.js.map +1 -1
- package/dist/canvas/derivedPath.js +53 -29
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/insertPreviewExtent.js +33 -31
- package/dist/canvas/insertPreviewExtent.js.map +1 -1
- package/dist/canvas/overChildren.js +29 -0
- package/dist/canvas/overChildren.js.map +1 -0
- package/dist/canvas/paintedCursorLayer.js.map +1 -1
- package/dist/canvas/pickReach.js +23 -0
- package/dist/canvas/pickReach.js.map +1 -0
- package/dist/canvas/pickWalk.js +51 -80
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +14 -35
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneSlotWiring.js +11 -10
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +38 -44
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/useCanvasView.js +42 -44
- package/dist/canvas/useCanvasView.js.map +1 -1
- package/dist/canvas/useSceneAdapter.js +22 -0
- package/dist/canvas/useSceneAdapter.js.map +1 -0
- package/dist/canvas/useSurfaceInput.js +13 -16
- package/dist/canvas/useSurfaceInput.js.map +1 -1
- package/dist/canvas/viewRegistry.js +31 -23
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/canvas/wrapNodeOutput.js +7 -2
- package/dist/canvas/wrapNodeOutput.js.map +1 -1
- package/dist/clipboard.d.ts +1 -1
- package/dist/{clone-2a5hVbBd.d.ts → clone-C0eADtS0.d.ts} +13 -13
- package/dist/clone.d.ts +2 -2
- package/dist/core/geometry/poseDescriptor.js +49 -23
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/regionHit.js +2 -2
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/geometry/targetFrame.js.map +1 -1
- package/dist/core/layers/children.js +1 -3
- package/dist/core/layers/children.js.map +1 -1
- package/dist/core/ops/create.js +2 -2
- package/dist/core/ops/create.js.map +1 -1
- package/dist/core/ops/delete.js +19 -23
- package/dist/core/ops/delete.js.map +1 -1
- package/dist/core/ops/reorder/index.js +3 -7
- package/dist/core/ops/reorder/index.js.map +1 -1
- package/dist/core/ops/reorder/setChildOrder.js +2 -4
- package/dist/core/ops/reorder/setChildOrder.js.map +1 -1
- package/dist/core/ops/reparent.js +0 -1
- package/dist/core/ops/reparent.js.map +1 -1
- package/dist/core/ops/slot.js +3 -6
- package/dist/core/ops/slot.js.map +1 -1
- package/dist/core/pages/fitViewToPage.js +15 -0
- package/dist/core/pages/fitViewToPage.js.map +1 -0
- package/dist/core/pages/pages.js +65 -0
- package/dist/core/pages/pages.js.map +1 -0
- package/dist/core/pages/pagesLayer.js +27 -0
- package/dist/core/pages/pagesLayer.js.map +1 -0
- package/dist/core/paint/meshKindLazy.js +2 -2
- package/dist/core/paint/meshKindLazy.js.map +1 -1
- package/dist/core/scene/NodeProperties.js.map +1 -1
- package/dist/core/scene/composeFrame.js.map +1 -1
- package/dist/core/scene/composePose.js +58 -20
- package/dist/core/scene/composePose.js.map +1 -1
- package/dist/core/scene/effectivePose.js +5 -1
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/historyFacade.js +19 -13
- package/dist/core/scene/historyFacade.js.map +1 -1
- package/dist/core/scene/nodeFnFields.js +7 -0
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/outerOps.js +2 -1
- package/dist/core/scene/outerOps.js.map +1 -1
- package/dist/core/scene/reconcileSpecs.js +1 -1
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/sceneRecording.js +2 -1
- package/dist/core/scene/sceneRecording.js.map +1 -1
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/viewport/screenSlop.js.map +1 -1
- package/dist/core/viewport/useDecayLoop.js +28 -30
- package/dist/core/viewport/useDecayLoop.js.map +1 -1
- package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -1
- package/dist/core/viewport/useViewAnimation.js +70 -69
- package/dist/core/viewport/useViewAnimation.js.map +1 -1
- package/dist/core/viewport/view.js +8 -5
- package/dist/core/viewport/view.js.map +1 -1
- package/dist/core/viewport/zoomAt.js +11 -2
- package/dist/core/viewport/zoomAt.js.map +1 -1
- package/dist/{cornerHandles-BEshc4z3.d.ts → cornerHandles-BSKbyuvQ.d.ts} +1 -1
- package/dist/features/paths/editablePath.js +24 -8
- package/dist/features/paths/editablePath.js.map +1 -1
- package/dist/features/paths/index.js +4 -4
- package/dist/features/paths/shapeGenerator.js +89 -0
- package/dist/features/paths/shapeGenerator.js.map +1 -0
- package/dist/features/paths/usePathEdit.js +13 -13
- package/dist/features/poseRun/usePoseRun.js +25 -25
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +82 -64
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/viewports/viewResolver.js +28 -24
- package/dist/features/viewports/viewResolver.js.map +1 -1
- package/dist/icons/SliceIcon.js +24 -0
- package/dist/icons/SliceIcon.js.map +1 -0
- package/dist/index.d.ts +956 -581
- package/dist/index.js +260 -251
- package/dist/interactions/actions/align/align.js +9 -9
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/booleans.js +18 -18
- package/dist/interactions/actions/booleans/booleans.js.map +1 -1
- package/dist/interactions/actions/booleans/operands.js.map +1 -1
- package/dist/interactions/actions/clone/action.js +35 -30
- package/dist/interactions/actions/clone/action.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +56 -59
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorHandles.js +42 -0
- package/dist/interactions/actions/defaults/anchorHandles.js.map +1 -0
- package/dist/interactions/actions/defaults/anchorJoin.js +92 -0
- package/dist/interactions/actions/defaults/anchorJoin.js.map +1 -0
- package/dist/interactions/actions/defaults/bendSegment.js +46 -0
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -0
- package/dist/interactions/actions/defaults/copySubtree.js +1 -1
- package/dist/interactions/actions/defaults/copySubtree.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +32 -17
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterPathEdit.js +19 -7
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/icons/anchorIcons.js +75 -0
- package/dist/interactions/actions/defaults/icons/anchorIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js +35 -8
- package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +16 -31
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +28 -23
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/pinchZoom.js +29 -29
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/segmentUnder.js +22 -0
- package/dist/interactions/actions/defaults/segmentUnder.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportZoom.js +82 -79
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
- package/dist/interactions/actions/distribute/distribute.js +8 -8
- package/dist/interactions/actions/distribute/distribute.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/action.js +58 -55
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/preview.js +26 -0
- package/dist/interactions/actions/edit-anchors/preview.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/symmetry.js +11 -0
- package/dist/interactions/actions/edit-anchors/symmetry.js.map +1 -0
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/geometryProjection.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +37 -30
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/frame.js +9 -2
- package/dist/interactions/actions/insert/frame.js.map +1 -1
- package/dist/interactions/actions/insert/repositionAction.js +31 -0
- package/dist/interactions/actions/insert/repositionAction.js.map +1 -0
- package/dist/interactions/actions/lasso-select/action.js +32 -32
- package/dist/interactions/actions/move/action.js +29 -25
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +12 -6
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/capture.js +32 -23
- package/dist/interactions/actions/move/capture.js.map +1 -1
- package/dist/interactions/actions/move/frame.js +2 -14
- package/dist/interactions/actions/move/frame.js.map +1 -1
- package/dist/interactions/actions/move/session.js +1 -1
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/move/translate.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
- package/dist/interactions/actions/outlines/replaceWithPaths.js +13 -13
- package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -1
- package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -1
- package/dist/interactions/actions/pathCommands/cutJoin.js +102 -0
- package/dist/interactions/actions/pathCommands/cutJoin.js.map +1 -0
- package/dist/interactions/actions/pathCommands/livePathEdit.js +64 -0
- package/dist/interactions/actions/pathCommands/livePathEdit.js.map +1 -0
- package/dist/interactions/actions/pathCommands/pathNodes.js +99 -0
- package/dist/interactions/actions/pathCommands/pathNodes.js.map +1 -0
- package/dist/interactions/actions/pathCommands/simplifyOffset.js +42 -0
- package/dist/interactions/actions/pathCommands/simplifyOffset.js.map +1 -0
- package/dist/interactions/actions/resize/action.js +31 -20
- package/dist/interactions/actions/resize/action.js.map +1 -1
- package/dist/interactions/actions/resize/commit.js.map +1 -1
- package/dist/interactions/actions/resize/frame.js +29 -15
- package/dist/interactions/actions/resize/frame.js.map +1 -1
- package/dist/interactions/actions/resize/replay.js +47 -0
- package/dist/interactions/actions/resize/replay.js.map +1 -0
- package/dist/interactions/actions/resize/session.js +49 -35
- package/dist/interactions/actions/resize/session.js.map +1 -1
- package/dist/interactions/actions/resolveOverlays.js +2 -1
- package/dist/interactions/actions/resolveOverlays.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +40 -25
- package/dist/interactions/actions/rotate/action.js.map +1 -1
- package/dist/interactions/actions/rotate/frame.js +1 -1
- package/dist/interactions/actions/rotate/frame.js.map +1 -1
- package/dist/interactions/actions/rotate/replay.js +22 -0
- package/dist/interactions/actions/rotate/replay.js.map +1 -0
- package/dist/interactions/actions/rotate/session.js +42 -32
- package/dist/interactions/actions/rotate/session.js.map +1 -1
- package/dist/interactions/actions/transform-again/action.js +63 -0
- package/dist/interactions/actions/transform-again/action.js.map +1 -0
- package/dist/interactions/actions/transform-again/memory.js +35 -0
- package/dist/interactions/actions/transform-again/memory.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +101 -83
- package/dist/interactions/actions/useStandardActions.js.map +1 -1
- package/dist/move.d.ts +4 -4
- package/dist/{originProjection-PPT88jZv.d.ts → originProjection-CoNVpITV.d.ts} +1 -1
- package/dist/resize.d.ts +3 -3
- package/dist/style.css +1 -1
- package/dist/tools/builtin/ellipse/useEllipseTool.js +16 -15
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +16 -15
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +111 -111
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pickTopMostHit.js +11 -14
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +17 -15
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/rect/useRectTool.js +15 -14
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +22 -18
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -1
- package/dist/tools/builtin/select/selectionContributions.js +1 -1
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +2 -1
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/slice/useSliceTool.js +42 -40
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +18 -16
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +2 -2
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/{types-CIKDwlsP.d.ts → types-DBbbCy0i.d.ts} +22 -15
- package/dist/version.js +1 -1
- package/package.json +22 -22
- package/dist/canvas/surface.module.js +0 -6
- package/dist/canvas/surface.module.js.map +0 -1
- package/dist/canvas/surfaceBox.js +0 -16
- package/dist/canvas/surfaceBox.js.map +0 -1
- package/dist/layout/arrivals.js +0 -33
- package/dist/layout/arrivals.js.map +0 -1
package/dist/barrel/routing.js
CHANGED
|
@@ -7,51 +7,52 @@ import { resizeAction as u } from "../interactions/actions/resize/action.js";
|
|
|
7
7
|
import { rotateAction as d } from "../interactions/actions/rotate/action.js";
|
|
8
8
|
import { areaSelectAction as f } from "../interactions/actions/defaults/areaSelect.js";
|
|
9
9
|
import { insertAction as p } from "../interactions/actions/insert/action.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
|
|
10
|
+
import { INSERT_REPOSITION_BINDING as m, insertRepositionAction as h } from "../interactions/actions/insert/repositionAction.js";
|
|
11
|
+
import { clearSelectionAction as g } from "../interactions/actions/defaults/clearSelection.js";
|
|
12
|
+
import { cloneAction as _ } from "../interactions/actions/clone/action.js";
|
|
13
|
+
import { viewportDragPanAction as v } from "../interactions/actions/defaults/viewportDragPan.js";
|
|
14
|
+
import { makeViewportZoomAction as y, viewportZoomAction as b } from "../interactions/actions/defaults/viewportZoom.js";
|
|
15
|
+
import { makeViewportWheelPanAction as x, viewportWheelPanAction as S } from "../interactions/actions/defaults/viewportWheelPan.js";
|
|
16
|
+
import { editAnchorsAction as C } from "../interactions/actions/edit-anchors/action.js";
|
|
17
|
+
import { selectFromLasso as w } from "../interactions/actions/lasso-select/behaviors/selectFromLasso.js";
|
|
18
|
+
import { lassoSelectAction as T } from "../interactions/actions/lasso-select/action.js";
|
|
19
|
+
import { sliceAction as E } from "../interactions/actions/defaults/slice.js";
|
|
20
|
+
import { makePinchZoomAction as D, pinchZoomAction as O } from "../interactions/actions/defaults/pinchZoom.js";
|
|
21
|
+
import { clipboardCopyAction as k, clipboardCutAction as A, clipboardPasteAction as j, clipboardPasteEventAction as M } from "../interactions/actions/clipboard/action.js";
|
|
22
|
+
import { enterTextEditAction as N } from "../interactions/actions/defaults/enterTextEdit.js";
|
|
23
|
+
import { KIT_STANDARD_ACTION_IDS as P, useStandardActions as F } from "../interactions/actions/useStandardActions.js";
|
|
24
|
+
import { useResizePolicy as I } from "../canvas/deps/resizePolicy.js";
|
|
25
|
+
import { usePoseDescriptorDepSource as L } from "../canvas/deps/poseDescriptor.js";
|
|
26
|
+
import { computeSliceOps as R } from "../interactions/actions/defaults/sliceOps.js";
|
|
27
|
+
import { useSliceDep as z, useSliceDepSource as B } from "../canvas/deps/slice.js";
|
|
28
|
+
import { defineTool as V, useTools as H } from "../tools/overlayBinding.js";
|
|
29
|
+
import { useKeybindings as U } from "../tools/useKeybindings.js";
|
|
30
|
+
import { pickTopMostHit as W } from "../tools/builtin/pickTopMostHit.js";
|
|
31
|
+
import { AREA_SELECT_ID as G, SELECTION_MOVE_ID as K, SELECTION_RESIZE_ID as q, SELECTION_ROTATE_ID as J, SELECTION_TRANSFORM_ID as Y, areaSelectContribution as X, onEmptyCanvas as Z, selectionMoveBindings as Q, selectionMoveContribution as $, selectionResizeBindings as ee, selectionResizeContribution as te, selectionRotateBindings as ne, selectionRotateContribution as re, selectionTransformBindings as ie, selectionTransformContribution as ae } from "../tools/builtin/select/selectionContributions.js";
|
|
32
|
+
import { useSelectTool as oe } from "../tools/builtin/select/useSelectTool.js";
|
|
33
|
+
import { useHandTool as se } from "../tools/builtin/hand/useHandTool.js";
|
|
34
|
+
import { DRAG_PAN_ID as ce, dragPanContribution as le } from "../tools/builtin/hand/dragPanContribution.js";
|
|
35
|
+
import { useTextTool as ue } from "../tools/builtin/text/useTextTool.js";
|
|
36
|
+
import { placedRig as de } from "../tools/builtin/bone/placedRig.js";
|
|
37
|
+
import { createBoneOverlay as fe } from "../tools/builtin/bone/boneOverlay.js";
|
|
38
|
+
import { createRigEditState as pe } from "../tools/builtin/bone/rigEditState.js";
|
|
39
|
+
import { useBoneTool as me } from "../tools/builtin/bone/useBoneTool.js";
|
|
40
|
+
import { weighedPaths as he } from "../tools/builtin/weight/weightActions.js";
|
|
41
|
+
import { createWeightOverlay as ge } from "../tools/builtin/weight/weightOverlay.js";
|
|
42
|
+
import { useWeightTool as _e } from "../tools/builtin/weight/useWeightTool.js";
|
|
43
|
+
import { usePenTool as ve } from "../tools/builtin/pen/usePenTool.js";
|
|
44
|
+
import { useRectTool as ye } from "../tools/builtin/rect/useRectTool.js";
|
|
45
|
+
import { useEllipseTool as be } from "../tools/builtin/ellipse/useEllipseTool.js";
|
|
46
|
+
import { useImageTool as xe } from "../tools/builtin/image/useImageTool.js";
|
|
47
|
+
import { useEyedropperTool as Se } from "../tools/builtin/eyedropper/useEyedropperTool.js";
|
|
48
|
+
import { useLineTool as Ce } from "../tools/builtin/line/useLineTool.js";
|
|
49
|
+
import { useLassoTool as we } from "../tools/builtin/lasso/useLassoTool.js";
|
|
50
|
+
import { usePolygonTool as Te } from "../tools/builtin/polygon/usePolygonTool.js";
|
|
51
|
+
import { useStarTool as Ee } from "../tools/builtin/star/useStarTool.js";
|
|
52
|
+
import { usePencilTool as De } from "../tools/builtin/pencil/usePencilTool.js";
|
|
53
|
+
import { useSliceTool as Oe } from "../tools/builtin/slice/useSliceTool.js";
|
|
54
|
+
import { useLatest as ke } from "@weasel-js/react";
|
|
55
|
+
import { ActionDisabledReason as Ae, actionBindings as je, actionItems as Me, buildDepsFromRequires as Ne, createDepRegistry as Pe, createDispatcher as Fe, deleteScratch as Ie, evaluateActive as Le, evaluateEnabled as Re, getScratch as ze, heldKeySpec as Be, resolveParams as Ve, scratchKey as He, setScratch as Ue, specificity as We, tuneAction as Ge } from "@weasel-js/routing";
|
|
56
|
+
import { bodyPredicate as Ke, hitPredicate as qe } from "@weasel-js/gestures";
|
|
57
|
+
import { ActionsProvider as Je, ActiveToolContextProvider as Ye, ActiveToolContextProviderIfRoot as Xe, DepRegistryProvider as Ze, InputScope as Qe, Yoke as $e, useAction as et, useActionsRegistry as tt, useActiveToolContext as nt, useDepRegistry as rt, useDepSource as it, useGestureDispatcher as at, useOngoingAction as ot, useOptionalActiveToolContext as st, useOptionalDepRegistry as ct, useYoke as lt } from "@weasel-js/routing/react";
|
|
58
|
+
export { G as AREA_SELECT_ID, Ae as ActionDisabledReason, Je as ActionsProvider, Ye as ActiveToolContextProvider, Xe as ActiveToolContextProviderIfRoot, e as CORNER_ANCHORS, ce as DRAG_PAN_ID, Ze as DepRegistryProvider, m as INSERT_REPOSITION_BINDING, Qe as InputScope, P as KIT_STANDARD_ACTION_IDS, K as SELECTION_MOVE_ID, q as SELECTION_RESIZE_ID, J as SELECTION_ROTATE_ID, Y as SELECTION_TRANSFORM_ID, $e as Yoke, je as actionBindings, Me as actionItems, n as actionShortcuts, f as areaSelectAction, X as areaSelectContribution, Ke as bodyPredicate, Ne as buildDepsFromRequires, g as clearSelectionAction, k as clipboardCopyAction, A as clipboardCutAction, j as clipboardPasteAction, M as clipboardPasteEventAction, _ as cloneAction, R as computeSliceOps, t as cornerPoint, fe as createBoneOverlay, Pe as createDepRegistry, Fe as createDispatcher, pe as createRigEditState, ge as createWeightOverlay, c as defaultCommitAdapter, V as defineTool, Ie as deleteScratch, le as dragPanContribution, C as editAnchorsAction, i as editingLayer, N as enterTextEditAction, Le as evaluateActive, Re as evaluateEnabled, ze as getScratch, Be as heldKeySpec, qe as hitPredicate, a as inPlane, p as insertAction, o as insertLayer, h as insertRepositionAction, r as keySpecShortcut, T as lassoSelectAction, D as makePinchZoomAction, x as makeViewportWheelPanAction, y as makeViewportZoomAction, l as moveAction, Z as onEmptyCanvas, W as pickTopMostHit, O as pinchZoomAction, de as placedRig, u as resizeAction, Ve as resolveParams, d as rotateAction, He as scratchKey, w as selectFromLasso, s as selectionLayer, Q as selectionMoveBindings, $ as selectionMoveContribution, ee as selectionResizeBindings, te as selectionResizeContribution, ne as selectionRotateBindings, re as selectionRotateContribution, ie as selectionTransformBindings, ae as selectionTransformContribution, Ue as setScratch, E as sliceAction, We as specificity, Ge as tuneAction, et as useAction, tt as useActionsRegistry, nt as useActiveToolContext, me as useBoneTool, rt as useDepRegistry, it as useDepSource, be as useEllipseTool, Se as useEyedropperTool, at as useGestureDispatcher, se as useHandTool, xe as useImageTool, U as useKeybindings, we as useLassoTool, ke as useLatest, Ce as useLineTool, ot as useOngoingAction, st as useOptionalActiveToolContext, ct as useOptionalDepRegistry, ve as usePenTool, De as usePencilTool, Te as usePolygonTool, L as usePoseDescriptorDepSource, ye as useRectTool, I as useResizePolicy, oe as useSelectTool, z as useSliceDep, B as useSliceDepSource, Oe as useSliceTool, F as useStandardActions, Ee as useStarTool, ue as useTextTool, H as useTools, _e as useWeightTool, lt as useYoke, v as viewportDragPanAction, S as viewportWheelPanAction, b as viewportZoomAction, he as weighedPaths };
|
package/dist/barrel/scene.js
CHANGED
|
@@ -3,15 +3,15 @@ import { RECT_POSE_COMPOSITION as i, RIGID_POSE_COMPOSITION as a, composeRectPos
|
|
|
3
3
|
import { definesFrame as f, derivedDepOf as p, derivedPose as m, documentPose as h, effectivePose as g } from "../core/scene/effectivePose.js";
|
|
4
4
|
import { axisAlignedBounds as _, unionAABB as v, unionBounds as y } from "../core/geometry/unionBounds.js";
|
|
5
5
|
import { asNodeId as b } from "../core/scene/types.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
6
|
+
import { applyOpsTo as x, dispatchApplyBatch as S } from "../core/applyOps.js";
|
|
7
|
+
import { SceneArrivalRefused as C } from "../core/scene/arrivals.js";
|
|
8
|
+
import { opFactoryRegistry as w, rebuildOp as T, registerOpFactory as E, registeredOpNames as D } from "../core/ops/registry.js";
|
|
9
|
+
import { createReparentOp as O } from "../core/ops/reparent.js";
|
|
10
|
+
import { createTransformOp as k } from "../core/ops/transform.js";
|
|
11
|
+
import { createSetDataOp as A } from "../core/ops/setData.js";
|
|
12
|
+
import { createSetLayerOp as j } from "../core/ops/setLayer.js";
|
|
13
|
+
import { createDeleteOp as M } from "../core/ops/delete.js";
|
|
14
|
+
import { createInsertOp as N } from "../core/ops/create.js";
|
|
15
15
|
import { createSetSelectionOp as P } from "../core/ops/select.js";
|
|
16
16
|
import { UNION_OF_CHILDREN as F, unionOfChildren as I } from "../core/scene/kitRegistry.js";
|
|
17
17
|
import { canBringForward as L, canSendBackward as R } from "../core/ops/reorder/algorithms.js";
|
|
@@ -34,4 +34,4 @@ import { sceneUnitScopes as ne } from "../core/scene/unitScopes.js";
|
|
|
34
34
|
import { createPoseFeed as re } from "../core/scene/poseFeed.js";
|
|
35
35
|
import { MIXED as ie } from "@weasel-js/registry";
|
|
36
36
|
import { swapOp as ae } from "@weasel-js/history";
|
|
37
|
-
export { e as IDENTITY_POSE_COMPOSITION, ie as MIXED, i as RECT_POSE_COMPOSITION, a as RIGID_POSE_COMPOSITION, G as SCENE_HISTORY_FORM,
|
|
37
|
+
export { e as IDENTITY_POSE_COMPOSITION, ie as MIXED, i as RECT_POSE_COMPOSITION, a as RIGID_POSE_COMPOSITION, G as SCENE_HISTORY_FORM, C as SceneArrivalRefused, F as UNION_OF_CHILDREN, x as applyOpsTo, b as asNodeId, _ as axisAlignedBounds, L as canBringForward, R as canSendBackward, o as composeRectPose, s as composeRigidPose, t as composeWorldPose, n as composesFrames, U as createArrangeOp, M as createDeleteOp, W as createHistory, N as createInsertOp, B as createMoveToIndexOp, re as createPoseFeed, H as createPoseOverrides, V as createReorderOp, O as createReparentOp, q as createScene, z as createSetChildOrderOp, A as createSetDataOp, j as createSetLayerOp, X as createSetLayoutOp, Z as createSetPathOp, P as createSetSelectionOp, Y as createSetTextOp, k as createTransformOp, c as decomposeRectPose, l as decomposeRigidPose, f as definesFrame, p as derivedDepOf, m as derivedPose, S as dispatchApplyBatch, h as documentPose, g as effectivePose, Q as nestedHitTester, w as opFactoryRegistry, r as rebaseLocalPose, T as rebuildOp, te as reconcileSpecs, E as registerOpFactory, D as registeredOpNames, J as sceneFromJSON, K as sceneSelectionStore, ne as sceneUnitScopes, ae as swapOp, u as translateRectPose, v as unionAABB, y as unionBounds, I as unionOfChildren, $ as unionOfChildrenVia, ee as useScene, d as worldPoseLookup };
|
package/dist/barrel/viewport.js
CHANGED
|
@@ -19,24 +19,27 @@ import { ANCHOR_HIT_BASE_PX as M, HANDLE_BASE_PX as N, ROTATION_HANDLE_BASE_PX a
|
|
|
19
19
|
import { COARSE_TARGET_SCALE as F, DEFAULT_DEVICE_PROFILE as I, resolveDeviceProfile as L } from "../core/device/index.js";
|
|
20
20
|
import { fitToBounds as R, fitZoom as z } from "../core/viewport/fitToBounds.js";
|
|
21
21
|
import { fitViewToBounds as B } from "../core/viewport/fitViewToBounds.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
|
|
22
|
+
import { adjacentPage as V, layoutPages as H, pageAt as U, pageOfBounds as W, pagesBounds as G } from "../core/pages/pages.js";
|
|
23
|
+
import { pagesLayer as K } from "../core/pages/pagesLayer.js";
|
|
24
|
+
import { fitViewToPage as q } from "../core/pages/fitViewToPage.js";
|
|
25
|
+
import { axisZoomFactor as J, zoomAt as Y } from "../core/viewport/zoomAt.js";
|
|
26
|
+
import { clampView as X } from "../core/viewport/clampView.js";
|
|
27
|
+
import { sceneNodeClientRect as Z } from "../core/viewport/sceneNodeClientRect.js";
|
|
28
|
+
import { computeFitViewport as Q, useAutoCenter as $ } from "../core/viewport/useAutoCenter.js";
|
|
29
|
+
import { WHEEL_ZOOM_STEP as ee, computeWheelAction as te, wheelPan as ne, wheelZoom as re, wheelZoomFactor as ie } from "../core/viewport/wheelHandler.js";
|
|
30
|
+
import { createVelocityTracker as ae } from "../core/viewport/createVelocityTracker.js";
|
|
31
|
+
import { useVelocityTracker as oe } from "../core/viewport/useVelocityTracker.js";
|
|
32
|
+
import { useDecayLoop as se } from "../core/viewport/useDecayLoop.js";
|
|
33
|
+
import { interpolateView as ce } from "../core/viewport/interpolateView.js";
|
|
34
|
+
import { VIEW_ANIMATION_KEY as le, useViewAnimation as ue, useViewAnimationOn as de, viewAxes as fe } from "../core/viewport/useViewAnimation.js";
|
|
35
|
+
import { CanvasView as pe } from "../canvas/CanvasView.js";
|
|
36
|
+
import { SceneViewCanvas as me } from "../canvas/SceneViewCanvas.js";
|
|
37
|
+
import { DrawCanvas as he } from "../canvas/DrawCanvas.js";
|
|
38
|
+
import { FALLBACK_ACCENT as ge, accentColorOf as _e } from "../canvas/accentColor.js";
|
|
39
|
+
import { gateLayer as ve } from "../core/layers/gateLayer.js";
|
|
40
|
+
import { meanScale as ye, pxExtent as be, scaleDelta as xe, screenAngleOf as Se, standoff as Ce, withinPxBox as we, withinPxRadius as Te } from "@weasel-js/geom";
|
|
41
|
+
import { DEFAULT_ALPHA_DECAY as Ee, DEFAULT_ALPHA_MIN as De, DEFAULT_VELOCITY_DECAY as Oe, createSimulation as ke } from "@weasel-js/simulation";
|
|
42
|
+
import { useSimulation as Ae } from "@weasel-js/simulation/react";
|
|
43
|
+
import { useCanvasFocus as je, useFrameClock as Me, useVisibleRaf as Ne } from "@weasel-js/react";
|
|
44
|
+
import { clientToCanvas as Pe } from "@weasel-js/routing";
|
|
45
|
+
export { M as ANCHOR_HIT_BASE_PX, F as COARSE_TARGET_SCALE, pe as CanvasView, Ee as DEFAULT_ALPHA_DECAY, De as DEFAULT_ALPHA_MIN, I as DEFAULT_DEVICE_PROFILE, t as DEFAULT_MAX_ZOOM, n as DEFAULT_MIN_ZOOM, Oe as DEFAULT_VELOCITY_DECAY, b as DeviceProfileProvider, he as DrawCanvas, ge as FALLBACK_ACCENT, N as HANDLE_BASE_PX, P as ROTATION_HANDLE_BASE_PX, me as SceneViewCanvas, e as VERSION, le as VIEW_ANIMATION_KEY, ee as WHEEL_ZOOM_STEP, r as ZOOM_FLOOR, _e as accentColorOf, V as adjacentPage, J as axisZoomFactor, X as clampView, Pe as clientToCanvas, Q as computeFitViewport, te as computeWheelAction, ke as createSimulation, ae as createVelocityTracker, l as createViewResolver, c as createViewportLayer, u as deriveParallaxView, R as fitToBounds, B as fitViewToBounds, q as fitViewToPage, z as fitZoom, d as fromPlane, ve as gateLayer, ce as interpolateView, C as isPlainObject, H as layoutPages, ye as meanScale, a as normalizeView, i as normalizeZoom, U as pageAt, W as pageOfBounds, G as pagesBounds, K as pagesLayer, f as planeMap, p as planeMatrix, m as planeToPlane, be as pxExtent, h as rectFromPlane, g as rectToPlane, L as resolveDeviceProfile, xe as scaleDelta, Z as sceneNodeClientRect, Se as screenAngleOf, T as screenToWorld, D as stableStringify, Ce as standoff, j as startThresholdDrag, _ as toPlane, $ as useAutoCenter, je as useCanvasFocus, S as useCanvasSize, se as useDecayLoop, x as useDeviceProfile, k as useDragHandle, A as useDropZone, Me as useFrameClock, O as useHandleDrag, w as useNodeOverlayFrame, v as usePoseRun, Ae as useSimulation, oe as useVelocityTracker, ue as useViewAnimation, de as useViewAnimationOn, Ne as useVisibleRaf, fe as viewAxes, o as viewToTransform, s as viewZoom, y as watchDevicePixelRatio, ne as wheelPan, re as wheelZoom, ie as wheelZoomFactor, we as withinPxBox, Te as withinPxRadius, E as worldToScreen, Y as zoomAt };
|
package/dist/canvas/Canvas.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useViewHelpers as a } from "./useViewHelpers.js";
|
|
|
6
6
|
import { useOptionalViewRegistry as o } from "./viewRegistry.js";
|
|
7
7
|
import { shaderKeyOf as s } from "./canvasRenderer.js";
|
|
8
8
|
import { useCanvasSurface as c } from "./useCanvasSurface.js";
|
|
9
|
-
import {
|
|
9
|
+
import { SurfaceCanvas as ee } from "./SurfaceCanvas.js";
|
|
10
10
|
import { isCustomEntry as l } from "./layerSlots.js";
|
|
11
11
|
import { composeOrderedLayers as u, placeToolOverlays as d } from "./layerOrder.js";
|
|
12
12
|
import { registerMountedCanvas as f } from "./mountedCanvases.js";
|
|
@@ -169,18 +169,6 @@ function he(m, he) {
|
|
|
169
169
|
j
|
|
170
170
|
]), bt = ce(h((e) => Z?.subscribe(e) ?? (() => {}), [Z]), () => Z?.getVersion() ?? 0, () => 0), xt = x(Q);
|
|
171
171
|
g(() => Z?.attachSurface({
|
|
172
|
-
origin: () => {
|
|
173
|
-
let e = I.current;
|
|
174
|
-
if (!e) return {
|
|
175
|
-
left: 0,
|
|
176
|
-
top: 0
|
|
177
|
-
};
|
|
178
|
-
let t = e.getBoundingClientRect();
|
|
179
|
-
return {
|
|
180
|
-
left: t.left,
|
|
181
|
-
top: t.top
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
172
|
view: () => K.current,
|
|
185
173
|
dims: () => V.current,
|
|
186
174
|
layers: () => xt.current,
|
|
@@ -189,8 +177,8 @@ function he(m, he) {
|
|
|
189
177
|
hitTestExtras: G,
|
|
190
178
|
clientToWorld: Y,
|
|
191
179
|
claimsAbove: (e, t) => {
|
|
192
|
-
let n =
|
|
193
|
-
return G(r, i,
|
|
180
|
+
let n = K.current, r = e / n.scale.x + n.x, i = t / n.scale.y + n.y;
|
|
181
|
+
return G(r, i, n, V.current, B.current) !== null;
|
|
194
182
|
}
|
|
195
183
|
}), [
|
|
196
184
|
Z,
|
|
@@ -314,12 +302,13 @@ function he(m, he) {
|
|
|
314
302
|
onLeave: () => {
|
|
315
303
|
for (let e of $) e.onUncapturedLeave?.();
|
|
316
304
|
}
|
|
317
|
-
}), R ? null : /* @__PURE__ */ le(
|
|
305
|
+
}), R ? null : /* @__PURE__ */ le(ee, {
|
|
318
306
|
ref: He,
|
|
319
307
|
width: S,
|
|
320
308
|
height: C,
|
|
321
309
|
tabIndex: Oe,
|
|
322
|
-
|
|
310
|
+
className: Ee,
|
|
311
|
+
style: De
|
|
323
312
|
});
|
|
324
313
|
}
|
|
325
314
|
var S = m(he);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.js","names":["clientToWorld","clientToWorldHelper","alwaysVisible","NO_SELECTION","NO_LAYER_VISIBILITY","CanvasInner","dprProp","layersMap","clientToWorld$1","geometry","AUTO_POSE_DESCRIPTOR","debugProp","props","debugSink","debugOverlay","useDebugSink","canvasRef","useRef","ownCanvasRef","setOwnCanvas","useCallback","el","detached","paintInto","inputElement","paintTarget","paintTargetRef","useLatest","paintRect","paintRectRef","helpersForLayersRef","dimsRef","gateRef","paintRef","useCanvasSurface","contentVersionRef","contentVersion","paintedVersionRef","getPaintedVersion","extrasVersion","setExtrasVersion","useState","extrasRef","registerLayer","layer","n","hitTestExtrasIn","layers","gate","isVisible","visibility","order","only","isLayerPainted","hit","worldX","worldY","data","view","dims","controlledView","viewState","hitTestExtras","frame","viewRef","clientToWorldRef","toWorld","clientX","clientY","override","clientToWorld","element","registerMountedCanvas","getView","paintedCursor","useMemo","createPaintedCursorState","paintedCursorLayer","createPaintedCursorLayer","requestRedraw","cursorSink","createCursorSink","getSurfaceRect","origin","w","h","ref","subscribeFrame","subscribeBeforePaint","subscribeResume","setView","subscribeView","getDebug","layerCacheRef","viewRegistry","useOptionalViewRegistry","selectedIdsForWiring","selection","viewHelpers","viewChromeState","useViewHelpers","surfaceHelpers","helpersForLayers","backgroundLayer","backgroundFill","createBackgroundFillLayer","standardLayers","slot","entry","isCustomEntry","out","composeOrderedLayers","decorationLayer","tools","placeToolOverlays","viewRegistryVersion","useSyncExternalStore","cb","surfaceLayersRef","c","r","corner","x","y","layersWithDebug","withViews","redraw","offs","off","shaderIdKey","shaderKeyOf","shaders","paintInputsRef","useInsertionEffect","adoptControlled","helpersRef","debugSinkRef","useLayoutEffect","paint","rect","paintLayers","sink","timed","dprIn","paintFlattenTolerance","groups","paintShaders","debugFrame","beginDebugFrame","renderer","lease","vis","spans","commands","drawLayers","viewToMat3","width","height","flattenTolerance","layerVisibility","layerOrder","layerGroups","syncPaint","getIsVisible","useEffect","layerCache","clearSubscribers","useToolCursor","style","useSurfaceInput","autoFocusOnPointerDown","e","surfaceBox","className","Canvas","forwardRef"],"sources":["../../src/canvas/Canvas.tsx"],"sourcesContent":["/**\n * Low-level WebGL surface + viewport primitive. Composes layers into a single GL render pass,\n * applies a view transform, and delivers hover to the layers that ask for it. It routes no\n * gesture: `<SceneCanvas>` mounts the gesture dispatcher on this same element. Canvas owns NO\n * scene-shaped state — selection, picking, kind registry, scene-aware overlays all live in\n * `<SceneCanvas>`, which wraps it.\n *\n * The `layers` prop is a map keyed by slot name, every slot already a layer. Standard slots\n * render at a canonical position; custom entries (any other key, value carrying `.layer`) insert\n * at `after`/`before` an existing slot, defaulting to the top.\n *\n * @internal\n * @deprecated Bare `<Canvas>` is not a supported consumer surface.\n * Use `<SceneCanvas>` instead.\n */\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport type React from 'react';\nimport type { Paint } from '@weasel-js/paint';\nimport { composeOrderedLayers, placeToolOverlays } from './layerOrder';\nimport { STANDARD_SLOTS, isCustomEntry, type CanvasLayers } from './layerSlots';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport { registerMountedCanvas } from './mountedCanvases';\nimport type { GestureSource } from './gestureBounds';\nimport { useViewHelpers } from './useViewHelpers';\nimport { useSurfaceInput } from './useSurfaceInput';\nimport type { CanvasViewState } from './useCanvasView';\nimport { useOptionalViewRegistry } from './viewRegistry';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasHelpers, CanvasSurfaceHelpers, ViewPoseAdapter } from './useViewHelpers';\n\nimport { useLatest } from '@weasel-js/react';\nimport type { View } from 'core/viewport/view';\nimport { clientToWorld as clientToWorldHelper } from 'core/viewport/clientToWorld';\nimport {\n drawLayers, isLayerPainted,\n type Dims, type LayerCommandCache, type LayerGroup, type RedrawSource, type RenderLayer,\n} from 'core/layers/render';\nimport { viewToMat3, type ShaderProgramHandle } from '@weasel-js/renderer';\nimport { createBackgroundFillLayer } from 'core/layers/backgroundFill';\nimport { shaderKeyOf } from './canvasRenderer';\nimport { surfaceBox } from './surfaceBox';\nimport {\n type SelectionApi,\n} from 'core/selection/useSelection';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { CanvasDebugSink, DebugConfig } from '../debug/types';\nimport { beginDebugFrame, useDebugSink } from '../debug/useDebugSink';\n\nconst alwaysVisible = (_id: string): boolean => true;\nimport { createCursorSink, createPaintedCursorState } from '@weasel-js/cursor';\nimport type { PaintedCursorState } from '@weasel-js/cursor';\nimport { useToolCursor } from './useToolCursor';\nimport { createPaintedCursorLayer } from './paintedCursorLayer';\n\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/**\n * Props for `<Canvas>`. Canvas is scene-agnostic: it owns the GL surface, view state, hover\n * delivery, and slot composition, and not gesture dispatch, selection state, picking logic,\n * kind registries, or scene-aware overlays.\n */\nexport interface CanvasProps<TPose = unknown> {\n /** CSS-pixel width. */\n width: number;\n /** CSS-pixel height. */\n height: number;\n\n /** Drawing-buffer density (device pixels per CSS pixel). When omitted the\n * canvas reads `window.devicePixelRatio` per paint. */\n dpr?: number;\n\n /** Flatness tolerance for curve tessellation, in world units. Forwarded to\n * `WeaselRendererOptions.flattenTolerance`. Leave unset for the cached\n * default (`DEFAULT_FLATTEN_TOLERANCE`, 0.5); a scene whose world unit is\n * not a pixel — feet, inches, millimetres — needs a value scaled to its\n * unit or sub-unit curves flatten to a handful of vertices. */\n flattenTolerance?: number;\n\n /** The version of whatever content this canvas draws, sampled at paint time\n * and reported by {@link CanvasExtensionApi.getPaintedVersion}.\n * `<SceneCanvas>` wires this to `scene.getVersion`. Chrome that must not\n * show DOM ahead of pixels compares the two and defers a frame. */\n contentVersion?: () => number;\n\n /** Paint inside the React commit rather than on the next animation frame.\n * Costs a synchronous paint per commit and per redraw request; buys\n * single-commit consistency between React-rendered DOM and canvas pixels.\n * For consumers with DOM chrome pinned to canvas content that cannot\n * tolerate a frame of skew. Live: toggling it switches modes from the next\n * redraw on. A redraw requested from inside a layer's `draw`, or from a\n * `subscribeFrame` callback, still waits for a frame — painting it in place\n * would recurse. */\n syncPaint?: boolean;\n\n /** External state the paint reads that no layer declares — typically what\n * an `alphaFor` consults. Each source is subscribed while mounted and\n * repaints the canvas when it notifies. A layer that reads outside state\n * declares it on `RenderLayer.subscribe` instead. */\n redrawOn?: readonly RedrawSource[];\n\n /** Adapter the pose and bounds lookups on `helpersRef` read. */\n adapter?: ViewPoseAdapter<TPose>;\n\n /** Layer map. See module docstring for slot semantics. */\n layers: CanvasLayers;\n\n /**\n * Current selection state; Canvas owns none of its own and never writes it. When absent,\n * Canvas behaves as if nothing is selected: no selection chrome.\n */\n selection?: SelectionApi;\n\n\n /**\n * How to read and rewrite a pose. Drives the default `boundsOf` fallback and the\n * selection-overlay bounds. Defaults to the rect identity (`AUTO_POSE_DESCRIPTOR`); supply\n * one for a non-rect pose type.\n */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n /**\n * Override for committed bounds lookup, taking precedence over the `poseDescriptor`-derived\n * fallback. Used by the selection overlay, the multi-select union AABB, and\n * `helpersRef.getEffectiveBounds`.\n */\n boundsOf?: (id: string) => Bounds | null;\n /** Bounds of `id` drawn at an in-flight pose — how chrome boxes a preview.\n * Defaults to the `poseDescriptor`'s box of that pose. */\n boundsOfPose?: (id: string, pose: TPose) => Bounds | null;\n /**\n * Custom pointer-to-world coordinate transform, overriding the default canvas-rect\n * calculation. Useful for consumers that apply an additional CSS transform to the canvas\n * element.\n */\n clientToWorld?: (canvas: HTMLElement, cx: number, cy: number) => [number, number];\n\n /**\n * Paint into a caller-owned canvas at a rect on it, instead of an element\n * this component creates. `x`/`y` are the rect's top-left in that canvas's\n * CSS pixels; the rect's size is the existing `width`/`height` props.\n *\n * Requires `inputElement`: with no element of its own there is nowhere for\n * pointer input, focus or the cursor to live, and nothing renders.\n *\n * N canvases can then share one GL context and one buffer.\n */\n paintInto?: { canvas: HTMLCanvasElement | null; x: number; y: number };\n /**\n * The element pointer input, focus and the cursor come from, and the element\n * every client→world conversion measures. Only read alongside `paintInto`;\n * an attached canvas uses the one it renders.\n */\n inputElement?: HTMLElement | null;\n\n /** Class for the `<canvas>` this component renders. Under `paintInto` it\n * renders none, and the input element is the caller's to style. */\n className?: string;\n /** Inline style for the `<canvas>` this component renders; a tool's cursor\n * is merged over it. Not applied under `paintInto`, where only that cursor\n * is written, onto the input element. */\n style?: React.CSSProperties;\n /** Tab order of the `<canvas>` this component renders. Default 0, so the\n * canvas is focusable. Not applied under `paintInto`: whether the input\n * element can take focus is the caller's to decide. */\n tabIndex?: number;\n /** Fired when the element input comes from gains focus: the canvas, or\n * under `paintInto` the `inputElement`. Called with the DOM event. */\n onFocus?: (event: FocusEvent) => void;\n /** Fired when that element loses focus. */\n onBlur?: (event: FocusEvent) => void;\n /**\n * When `true` (default), the canvas element receives focus on `pointerdown` so keyboard\n * events are captured without a separate click-to-focus step. Set to `false` where\n * auto-focus would steal focus from sibling inputs.\n */\n autoFocusOnPointerDown?: boolean;\n\n /** The tool set. Canvas reads the active tool's cursor and its overlays;\n * it dispatches nothing to a tool. */\n tools?: import('../tools/overlayBinding').ToolsApi;\n\n /** The camera this surface looks through, from `useCanvasView`. Whoever\n * made it holds the view props; the surface adopts and announces a\n * controlled view among its own effects, and repaints when one moves. */\n viewState: CanvasViewState;\n /**\n * Mutable ref Canvas writes overlay-aware pose/bounds lookups to on every render. Custom\n * layers can read it from inside their `draw` closure to reflect in-flight gestures\n * (move/resize/rotate) instead of the committed scene; an id outside the active overlay\n * falls back to the adapter.\n */\n helpersRef?: React.MutableRefObject<CanvasHelpers<TPose> | null>;\n\n /**\n * Debug overlay configuration.\n * - `undefined` (default): read `?debug=…` from the URL.\n * - `false`: force off, ignore URL.\n * - `DebugConfig` object: force on with that config, ignore URL.\n *\n * When enabled, the Canvas appends a screen-space `debug-overlay` layer and builds the\n * sink it paints: each paint records into it, and the layer helpers and the ref handle's\n * `getDebug` hand it to whatever else records.\n */\n debug?: DebugConfig | false;\n\n /** Test-only escape hatch: writes the live debug sink to this ref so tests\n * can call `snapshot()` after a render. No effect when debug is off. */\n debugSinkRef?: React.MutableRefObject<CanvasDebugSink | null>;\n\n /**\n * Shader programs to compile before the frame that first draws them; one\n * not named here compiles on that frame. Each handle comes from a\n * module-level `registerProgram()`. The array is read at each paint and\n * registered again when its ids change, so a handle added after mount is\n * picked up. Re-registering one of these ids with new source repaints the\n * canvas, and the renderer recompiles it for that frame.\n */\n shaders?: ShaderProgramHandle[];\n\n /**\n * Preview-pose lookup, so selection chrome tracks the ghost during dispatcher-driven\n * drags. Returns `null` / `undefined` when no preview is in flight.\n */\n previewPoseExtra?: (id: string) => unknown;\n\n /**\n * In-flight gesture state `<Canvas>` can't see for itself. Backs the `getGestureBounds` /\n * `subscribeGestures` / `getGestureVersion` trio on `helpersRef`. Unwired, those three\n * report \"no gesture in flight\" and never fire.\n */\n gestureSource?: GestureSource;\n\n /**\n * Fill for the full canvas surface, drawn as a screen-space layer beneath every other\n * layer, the grid and anything anchored before it included — independent of pan / zoom.\n */\n backgroundFill?: Paint;\n\n /**\n * Mode-owned decoration layer (e.g. path-edit anchor dots). Composed as a `decorationLayer`\n * entry in `layers` with no anchor, which this prop replaces: it paints above every slot\n * and every other custom layer, and beneath a tool's `'top'` overlays. A tool's\n * selection-anchored overlays sit beneath it too while there is selection chrome to anchor\n * them; with that slot empty they fall to the tail and paint above it.\n */\n decorationLayer?: RenderLayer<unknown>;\n\n /**\n * Chrome-caps visibility resolver. Exposed on `helpersForLayers.getIsVisible` so custom\n * layers (notably `composeAffordanceLayer`) can gate paint by chrome id, and threaded into\n * hit-testing so the same gate applies there. Called fresh per draw / per hitTest. Omit to\n * leave every chrome element visible.\n */\n getIsVisible?: () => (id: string) => boolean;\n\n /**\n * Show or hide whole render layers by id. An id absent from the map falls\n * back to the layer's own `defaultVisible`, and a layer marked `alwaysOn`\n * ignores the map entirely.\n *\n * Hiding a layer also stops it claiming pointer events through\n * `hitTestExtras` — a layer nobody can see must not swallow a click.\n *\n * This is `getIsVisible`'s coarser sibling: that one gates individual\n * chrome elements *within* a layer, this one gates the layer.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order, by layer id, bottom first. Omit for the order the layers\n * arrive in.\n *\n * **A listed order is the whole list:** any layer whose id is missing from\n * it is not drawn. Reordering two layers means naming all of them.\n */\n layerOrder?: string[];\n\n /**\n * Runs of consecutive layers that composite as one — the surface for blurring the world\n * while the chrome above it stays sharp. Members are named by layer id. See\n * {@link LayerGroup}.\n */\n layerGroups?: readonly LayerGroup[];\n}\n\n\nconst NO_SELECTION: SelectionApi['current'] = [];\n\nconst NO_LAYER_VISIBILITY: Record<string, boolean> = {};\n\nfunction CanvasInner<TPose>(\n props: CanvasProps<TPose>,\n ref: React.ForwardedRef<CanvasExtensionApi>,\n) {\n const {\n width,\n height,\n dpr: dprProp,\n flattenTolerance,\n contentVersion,\n syncPaint = false,\n redrawOn,\n adapter,\n layers: layersMap,\n selection,\n boundsOf,\n boundsOfPose,\n clientToWorld,\n paintInto,\n inputElement,\n poseDescriptor: geometry = AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>,\n className,\n style,\n tabIndex = 0,\n onFocus,\n onBlur,\n autoFocusOnPointerDown = true,\n helpersRef,\n tools,\n viewState,\n debug: debugProp,\n debugSinkRef,\n shaders,\n previewPoseExtra,\n gestureSource,\n backgroundFill,\n decorationLayer,\n getIsVisible,\n layerVisibility,\n layerOrder,\n layerGroups,\n } = props;\n\n const { sink: debugSink, overlay: debugOverlay, frameStats, getDebug } = useDebugSink(debugProp);\n\n // The element input comes from and every client→world conversion measures: the `<canvas>`\n // this component renders, or under `paintInto` the caller's `inputElement`.\n const canvasRef = useRef<HTMLElement | null>(null);\n // The `<canvas>` this component rendered, if it rendered one. `paint` is the\n // only thing that needs a real canvas, for `getContext`.\n const ownCanvasRef = useRef<HTMLCanvasElement | null>(null);\n // Stable, so a commit does not detach the element: an inline ref is nulled\n // until the layout phase reaches it, and a sync paint asked for before that\n // finds no canvas.\n const setOwnCanvas = useCallback((el: HTMLCanvasElement | null) => {\n ownCanvasRef.current = el;\n canvasRef.current = el;\n }, []);\n const detached = !!paintInto;\n // The detached input element reaches `canvasRef` at commit; the own canvas\n // arrives through `setOwnCanvas`, React's ref callback.\n useInsertionEffect(() => {\n if (detached) canvasRef.current = inputElement ?? null;\n });\n // Where pixels go. Split from `canvasRef` only when detached.\n const paintTarget = detached ? (paintInto.canvas ?? null) : null;\n const paintTargetRef = useLatest(paintTarget);\n const paintRect = detached ? { x: paintInto.x, y: paintInto.y } : null;\n const paintRectRef = useLatest(paintRect);\n\n // Read by `hitTestExtras`, which is built once and must see live values.\n const helpersForLayersRef = useRef<CanvasHelpers<TPose> | null>(null);\n const dimsRef = useLatest({ width, height });\n // Which layers reach the screen, and which chrome within them: asked by the\n // paint and by every hit-test.\n const gateRef = useLatest({ getIsVisible, layerVisibility, layerOrder });\n\n // React does not drive the paint; the frame loop does. The thunk defers to\n // `paint` below, which needs inputs this render has not computed yet.\n const paintRef = useRef<() => boolean>(() => false);\n const { lease, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume } = useCanvasSurface(\n useCallback(() => paintRef.current(), []),\n { syncPaint, target: canvasRef, dpr: dprProp, redrawOn, shaders },\n );\n\n const contentVersionRef = useLatest(contentVersion);\n const paintedVersionRef = useRef(0);\n const getPaintedVersion = useCallback(() => paintedVersionRef.current, []);\n\n // The `layersWithDebug` memo reads `extrasRef.current`, so registration has\n // to bump state to re-run it. Rare (a HUD attaching, a loupe mounting).\n const [extrasVersion, setExtrasVersion] = useState(0);\n const extrasRef = useRef<Set<RenderLayer<unknown>>>(new Set());\n const registerLayer = useCallback((layer: RenderLayer<unknown>) => {\n extrasRef.current.add(layer);\n setExtrasVersion(n => n + 1);\n return () => {\n extrasRef.current.delete(layer);\n setExtrasVersion(n => n + 1);\n };\n }, []);\n\n // Hit-test registered layers topmost-first: registration order is draw order, so the\n // last-registered layer gets first refusal. `<SceneCanvas>` folds this into its\n // `affordanceAt` thunk; Canvas has the layers but not the dispatcher.\n const hitTestExtrasIn = useCallback((\n worldX: number,\n worldY: number,\n view: View,\n dims: Dims,\n data: unknown,\n only?: readonly RenderLayer<unknown>[],\n ) => {\n const layers = [...extrasRef.current].reverse();\n const gate = gateRef.current;\n const isVisible = gate.getIsVisible?.() ?? alwaysVisible;\n const visibility = gate.layerVisibility ?? NO_LAYER_VISIBILITY;\n const order = gate.layerOrder;\n for (const layer of layers) {\n if (!layer.hitTest) continue;\n if (only && !only.includes(layer)) continue;\n if (!isLayerPainted(layer, visibility, order)) continue;\n const hit = layer.hitTest(worldX, worldY, data, view, dims, isVisible);\n if (hit) return { layerId: layer.id, hit };\n }\n return null;\n }, [gateRef]);\n\n const {\n viewRef, controlled: controlledView, setView, getView, subscribeView,\n adoptControlled, announceControlled, clearSubscribers,\n } = viewState;\n\n const hitTestExtras = useCallback((\n worldX: number,\n worldY: number,\n frame?: { view: View; dims: Dims },\n ) => hitTestExtrasIn(\n worldX,\n worldY,\n frame?.view ?? viewRef.current,\n frame?.dims ?? dimsRef.current,\n helpersForLayersRef.current,\n ), [hitTestExtrasIn, dimsRef, viewRef]);\n\n // The one client→world conversion: hover, the view registry and both\n // handles answer with it, so a `clientToWorld` override reaches all of them\n // or none.\n const clientToWorldRef = useLatest(clientToWorld);\n const toWorld = useCallback((clientX: number, clientY: number): [number, number] => {\n const el = canvasRef.current;\n if (!el) return [clientX, clientY];\n const override = clientToWorldRef.current;\n if (override) return override(el, clientX, clientY);\n return clientToWorldHelper(clientX, clientY, el.getBoundingClientRect(), viewRef.current);\n }, [clientToWorldRef, viewRef]);\n\n useLayoutEffect(() => {\n const element = canvasRef.current;\n if (!element) return;\n return registerMountedCanvas({ element, getView });\n }, [detached, inputElement, getView]);\n\n // The painted tier's channel. `<Canvas>` owns it because it owns both ends:\n // the tool cursor that feeds it and the frame loop that has to repaint when\n // it changes. The hover pump reaches it through the ref handle below.\n const paintedCursor = useMemo<PaintedCursorState>(() => createPaintedCursorState(), []);\n const paintedCursorLayer = useMemo(\n () => createPaintedCursorLayer(paintedCursor),\n [paintedCursor],\n );\n // An idle pointermove repaints nothing on its own, so a cursor the compositor\n // is not drawing needs its own pump. The store stays quiet unless something\n // painted is actually on screen.\n useEffect(() => paintedCursor.subscribe(() => { requestRedraw(); }), [paintedCursor, requestRedraw]);\n // The one writer of the input element's `cursor` style: the tool's cursor\n // from here, a hover cursor from the pump, which reaches it through the handle.\n const cursorSink = useMemo(\n () => createCursorSink({ element: () => canvasRef.current, painted: () => paintedCursor }),\n [paintedCursor],\n );\n\n const getSurfaceRect = useCallback(() => {\n const origin = paintRectRef.current;\n const { width: w, height: h } = dimsRef.current;\n return { x: origin?.x ?? 0, y: origin?.y ?? 0, width: w, height: h };\n }, [dimsRef, paintRectRef]);\n\n useImperativeHandle(ref, () => ({\n // Named rather than read off `canvasRef` so the handle rebuilds when a\n // detached surface's input element arrives, which is a render later.\n element: detached ? inputElement ?? null : canvasRef.current,\n surface: detached ? paintInto?.canvas ?? null : ownCanvasRef.current,\n getSurfaceRect,\n clientToWorld: toWorld,\n requestRedraw,\n subscribeFrame,\n subscribeBeforePaint,\n subscribeResume,\n registerLayer,\n hitTestExtras,\n getView,\n setView,\n subscribeView,\n getPaintedVersion,\n paintedCursor,\n cursorSink,\n getDebug,\n }), [canvasRef, ownCanvasRef, detached, inputElement, paintInto?.canvas,\n getSurfaceRect, toWorld, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume,\n registerLayer,\n hitTestExtras, getView, setView, subscribeView, getPaintedVersion,\n paintedCursor, cursorSink, getDebug]);\n\n const layerCacheRef = useRef<LayerCommandCache>(new Map());\n\n // Views registered on this surface — declared as `views` descriptors or\n // mounted as `<CanvasView>` children. Null outside a surface that mounts a\n // registry, which is the single-view case.\n const viewRegistry = useOptionalViewRegistry();\n\n const selectedIdsForWiring = selection?.current ?? NO_SELECTION;\n\n // One view's overlay-aware state. A hook, so N views are N components each\n // calling it once — not a loop in this body.\n const { helpers: viewHelpers, chromeState: viewChromeState } = useViewHelpers<TPose>({\n adapter,\n geometry,\n boundsOf,\n boundsOfPose,\n selection: selectedIdsForWiring,\n gestureSource,\n previewPoseExtra,\n getIsVisible: () => gateRef.current.getIsVisible?.() ?? alwaysVisible,\n });\n\n const surfaceHelpers: CanvasSurfaceHelpers = {\n getDebug: () => debugSink,\n };\n const helpersForLayers: CanvasHelpers<TPose> = { ...viewHelpers, ...surfaceHelpers, viewId: null };\n\n const backgroundLayer = useMemo(\n () => (backgroundFill ? createBackgroundFillLayer(backgroundFill) : undefined),\n [backgroundFill],\n );\n\n const layers = useMemo<RenderLayer<unknown>[]>(() => {\n const standardLayers: Partial<\n Record<(typeof STANDARD_SLOTS)[number], RenderLayer<unknown>>\n > = {};\n for (const slot of ['grid', 'cellHighlight', 'selectionOverlay'] as const) {\n const entry = layersMap[slot];\n if (isCustomEntry(entry)) standardLayers[slot] = entry.layer;\n }\n const out: RenderLayer<unknown>[] = composeOrderedLayers(\n decorationLayer ? { ...layersMap, decorationLayer: { layer: decorationLayer } } : layersMap,\n standardLayers, layersMap.scene?.layers, backgroundLayer,\n );\n if (tools) {\n placeToolOverlays(out, standardLayers.selectionOverlay, tools.getActiveOverlays);\n }\n return out;\n }, [layersMap, tools, backgroundLayer, decorationLayer]);\n\n const viewRegistryVersion = useSyncExternalStore(\n useCallback((cb: () => void) => viewRegistry?.subscribe(cb) ?? (() => {}), [viewRegistry]),\n () => viewRegistry?.getVersion() ?? 0,\n () => 0,\n );\n\n // The stack a view paints through its own camera is this canvas's, before\n // the views themselves are folded in — otherwise a view would contain\n // itself. Published by reference and read at draw time.\n const surfaceLayersRef = useLatest<readonly RenderLayer<unknown>[]>(layers);\n useEffect(() => {\n return viewRegistry?.attachSurface({\n origin: () => {\n const c = canvasRef.current;\n if (!c) return { left: 0, top: 0 };\n const r = c.getBoundingClientRect();\n return { left: r.left, top: r.top };\n },\n view: () => viewRef.current,\n dims: () => dimsRef.current,\n layers: () => surfaceLayersRef.current,\n requestRedraw,\n chromeState: () => helpersForLayersRef.current!.getChromeState(),\n hitTestExtras: hitTestExtrasIn,\n clientToWorld: toWorld,\n claimsAbove: (x, y) => {\n const corner = canvasRef.current?.getBoundingClientRect();\n const [worldX, worldY] = toWorld(x + (corner?.left ?? 0), y + (corner?.top ?? 0));\n return hitTestExtrasIn(worldX, worldY, viewRef.current, dimsRef.current, helpersForLayersRef.current) !== null;\n },\n });\n }, [viewRegistry, canvasRef, requestRedraw, hitTestExtrasIn, dimsRef, surfaceLayersRef, viewRef, toWorld]);\n\n const layersWithDebug = useMemo(() => {\n // Views paint through the surface's own stack, so they sit above it and\n // below both the debug overlay and externally-registered layers.\n const withViews = viewRegistry\n ? [...layers, ...viewRegistry.list().filter((r) => r.paint).map((r) => r.layer as RenderLayer<unknown>)]\n : layers;\n const base = debugOverlay ? [...withViews, debugOverlay] : withViews;\n // The cursor goes last: it is the one thing that is always in front of\n // everything, including a consumer's own registered layers.\n return [...base, ...extrasRef.current, paintedCursorLayer];\n // extrasVersion drives re-reads of extrasRef when layers are registered/detached;\n // viewRegistryVersion does the same for registered views.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layers, debugOverlay, extrasVersion, viewRegistry, viewRegistryVersion,\n paintedCursorLayer]);\n\n useEffect(() => {\n const redraw = (): void => { requestRedraw(); };\n const offs: (() => void)[] = [];\n for (const layer of layersWithDebug) if (layer.subscribe) offs.push(layer.subscribe(redraw));\n return () => { for (const off of offs) off(); };\n }, [layersWithDebug, requestRedraw]);\n\n const shaderIdKey = shaderKeyOf(shaders);\n\n // Everything the paint, hit-testing and the view registry read that a React\n // render owns. `useLatest` and the insertion effect below publish committed\n // renders only, ahead of every layout effect in the commit, any of which may\n // ask for a sync paint.\n const paintInputs = {\n layers: layersWithDebug, width, height, debugSink, frameStats,\n dpr: dprProp, layerGroups, shaders,\n flattenTolerance,\n };\n const paintInputsRef = useLatest(paintInputs);\n useInsertionEffect(() => {\n adoptControlled();\n helpersForLayersRef.current = helpersForLayers;\n if (helpersRef) helpersRef.current = helpersForLayers;\n if (debugSinkRef) debugSinkRef.current = debugSink;\n });\n useLayoutEffect(() => {\n announceControlled();\n });\n\n const paint = useCallback((): boolean => {\n const c = paintTargetRef.current ?? ownCanvasRef.current;\n if (!c) return false;\n const rect = paintRectRef.current;\n const {\n layers: paintLayers, width: w, height: h, debugSink: sink, frameStats: timed,\n dpr: dprIn,\n flattenTolerance: paintFlattenTolerance,\n layerGroups: groups, shaders: paintShaders,\n } = paintInputsRef.current;\n\n const debugFrame = beginDebugFrame(sink, timed, paintLayers);\n\n const renderer = lease.bind(c, { width: w, height: h, dpr: dprIn }, {\n tile: rect,\n flattenTolerance: paintFlattenTolerance,\n shaders: paintShaders,\n });\n // No WebGL2 (jsdom), or a context that is lost for now: nothing to paint.\n if (!renderer) return false;\n\n const view = viewRef.current;\n const { layerVisibility: vis, layerOrder: order } = gateRef.current;\n const spans = debugFrame?.time();\n const commands = drawLayers(\n paintLayers,\n helpersForLayersRef.current,\n vis ?? NO_LAYER_VISIBILITY,\n order,\n view,\n { width: w, height: h },\n layerCacheRef.current,\n undefined,\n groups,\n spans,\n );\n renderer.render(commands, viewToMat3(view), spans ? { spans } : undefined);\n debugFrame?.end(renderer.lastFrameStats());\n paintedVersionRef.current = contentVersionRef.current?.() ?? 0;\n return true;\n }, [contentVersionRef, gateRef, lease, paintInputsRef, paintRectRef, paintTargetRef, viewRef]);\n useInsertionEffect(() => {\n paintRef.current = paint;\n });\n\n // A tripwire, not a list of values this effect uses: every paint input that\n // arrives on a render must appear here, or changing it paints stale.\n // `viewChromeState` stands in for the whole overlay-aware set the layer\n // helpers expose — it re-memoizes on exactly the selection, bounds and\n // preview inputs they read. What moves between renders instead (a scene\n // write, a gesture pump, a late image decode) pushes its own redraw.\n // Layout, not passive, so a `syncPaint` surface lands its pixels in the same\n // commit as the DOM.\n useLayoutEffect(() => {\n requestRedraw();\n }, [layersWithDebug, width, height, debugSink, dprProp, flattenTolerance,\n controlledView?.x, controlledView?.y, controlledView?.scale.x, controlledView?.scale.y,\n layerVisibility, layerOrder, layerGroups, shaderIdKey, syncPaint,\n viewChromeState, getIsVisible, paintTarget, paintRect?.x, paintRect?.y, requestRedraw]);\n\n useEffect(() => {\n const layerCache = layerCacheRef.current;\n return () => {\n layerCache.clear();\n clearSubscribers();\n };\n }, [clearSubscribers]);\n\n useToolCursor(cursorSink, tools, detached ? inputElement : null, style?.cursor);\n\n useSurfaceInput(canvasRef, {\n focusOnPress: autoFocusOnPointerDown,\n onFocus,\n onBlur,\n onHover: (_el, e) => {\n const view = viewRef.current;\n const [worldX, worldY] = toWorld(e.clientX, e.clientY);\n const visibility = layerVisibility ?? NO_LAYER_VISIBILITY;\n // Same gate as `hitTestExtrasIn`: a layer nobody can see takes no input.\n for (const layer of layersWithDebug) {\n if (!layer.onUncapturedMove || !isLayerPainted(layer, visibility, layerOrder)) continue;\n layer.onUncapturedMove(worldX, worldY, e, view, { width, height });\n }\n },\n onLeave: () => {\n for (const layer of layersWithDebug) layer.onUncapturedLeave?.();\n },\n });\n\n if (detached) return null;\n\n return (\n <canvas\n ref={setOwnCanvas}\n width={width}\n height={height}\n tabIndex={tabIndex}\n {...surfaceBox(width, height, className, style)}\n />\n );\n}\n\n/** Forward-ref'd `<canvas>` wrapper. Generic over the pose type, inferred from the\n * `adapter` prop. */\nexport const Canvas = forwardRef(CanvasInner) as <TPose = unknown>(\n props: CanvasProps<TPose> & { ref?: React.ForwardedRef<CanvasExtensionApi> },\n) => ReturnType<typeof CanvasInner>;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAME,MAAiB,MAAyB,IA8O1CC,KAAwC,CAAC,GAEzCC,KAA+C,CAAC;AAEtD,SAASC,GACP,GACA,IACA;CACA,IAAM,EACJ,UACA,WACA,KAAKC,GACL,sBACA,oBACA,gBAAY,IACZ,cACA,aACA,QAAQC,GACR,eACA,cACA,kBACA,eAAAC,IACA,cACA,iBACA,gBAAgBC,KAAWC,GAC3B,eACA,WACA,eAAW,GACX,aACA,YACA,6BAAyB,IACzB,gBACA,UACA,eACA,OAAOC,IACP,kBACA,YACA,sBACA,mBACA,mBACA,oBACA,kBACA,oBACA,eACA,oBACEC,GAEE,EAAE,MAAMC,GAAW,SAASC,GAAc,gBAAY,iBAAaC,GAAaJ,EAAS,GAIzFK,IAAYC,EAA2B,IAAI,GAG3CC,IAAeD,EAAiC,IAAI,GAIpDE,KAAeC,GAAa,MAAiC;EAEjE,AADA,EAAa,UAAUC,GACvB,EAAU,UAAUA;CACtB,GAAG,CAAC,CAAC,GACCC,IAAW,CAAC,CAACC;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C,GAAcvF,IAAYiC,GAAO3F,IAAWE,IAAe,MAAMgJ,IAAO,MAAM,GAE9EC,GAAgBzJ,GAAW;EACzB,cAAc0J;EACd;EACA;EACA,UAAU,GAAK,MAAM;GACnB,IAAMhH,IAAOM,EAAQ,SACf,CAACT,GAAQC,KAAUU,EAAQyG,EAAE,SAASA,EAAE,OAAO,GAC/CzH,IAAa6G,KAAmB3J;GAEtC,KAAK,IAAMwC,KAASgF,GAClB,AAAKhF,EAAM,oBAAqBS,EAAeT,GAAOM,GAAY8G,CAAU,KAC5EpH,EAAM,iBAAiBW,GAAQC,GAAQmH,GAAGjH,GAAM;IAAE;IAAO;GAAO,CAAC;EAErE;EACA,eAAe;GACb,KAAK,IAAMd,KAASgF,GAAiB,EAAM,oBAAoB;EACjE;CACF,CAAC,GAEGtG,IAAiB,OAGnB,mBAAC,UAAD;EACE,KAAKH;EACE;EACC;EACE;EACV,GAAIyJ,GAAWhB,GAAOC,GAAQgB,IAAWL,EAAK;CAC/C,CAAA;AAEL;AAIA,IAAaM,IAASC,EAAW1K,EAAW"}
|
|
1
|
+
{"version":3,"file":"Canvas.js","names":["clientToWorld","clientToWorldHelper","alwaysVisible","NO_SELECTION","NO_LAYER_VISIBILITY","CanvasInner","dprProp","layersMap","clientToWorld$1","geometry","AUTO_POSE_DESCRIPTOR","debugProp","props","debugSink","debugOverlay","useDebugSink","canvasRef","useRef","ownCanvasRef","setOwnCanvas","useCallback","el","detached","paintInto","inputElement","paintTarget","paintTargetRef","useLatest","paintRect","paintRectRef","helpersForLayersRef","dimsRef","gateRef","paintRef","useCanvasSurface","contentVersionRef","contentVersion","paintedVersionRef","getPaintedVersion","extrasVersion","setExtrasVersion","useState","extrasRef","registerLayer","layer","n","hitTestExtrasIn","layers","gate","isVisible","visibility","order","only","isLayerPainted","hit","worldX","worldY","data","view","dims","controlledView","viewState","hitTestExtras","frame","viewRef","clientToWorldRef","toWorld","clientX","clientY","override","clientToWorld","element","registerMountedCanvas","getView","paintedCursor","useMemo","createPaintedCursorState","paintedCursorLayer","createPaintedCursorLayer","requestRedraw","cursorSink","createCursorSink","getSurfaceRect","origin","w","h","ref","subscribeFrame","subscribeBeforePaint","subscribeResume","setView","subscribeView","getDebug","layerCacheRef","viewRegistry","useOptionalViewRegistry","selectedIdsForWiring","selection","viewHelpers","viewChromeState","useViewHelpers","surfaceHelpers","helpersForLayers","backgroundLayer","backgroundFill","createBackgroundFillLayer","standardLayers","slot","entry","isCustomEntry","out","composeOrderedLayers","decorationLayer","tools","placeToolOverlays","viewRegistryVersion","useSyncExternalStore","cb","surfaceLayersRef","x","y","layersWithDebug","withViews","r","redraw","offs","off","shaderIdKey","shaderKeyOf","shaders","paintInputsRef","useInsertionEffect","adoptControlled","helpersRef","debugSinkRef","useLayoutEffect","paint","c","rect","paintLayers","sink","timed","dprIn","paintFlattenTolerance","groups","paintShaders","debugFrame","beginDebugFrame","renderer","lease","vis","spans","commands","drawLayers","viewToMat3","width","height","flattenTolerance","layerVisibility","layerOrder","layerGroups","syncPaint","getIsVisible","useEffect","layerCache","clearSubscribers","useToolCursor","style","useSurfaceInput","autoFocusOnPointerDown","e","SurfaceCanvas","Canvas","forwardRef"],"sources":["../../src/canvas/Canvas.tsx"],"sourcesContent":["/**\n * Low-level WebGL surface + viewport primitive. Composes layers into a single GL render pass,\n * applies a view transform, and delivers hover to the layers that ask for it. It routes no\n * gesture: `<SceneCanvas>` mounts the gesture dispatcher on this same element. Canvas owns NO\n * scene-shaped state — selection, picking, kind registry, scene-aware overlays all live in\n * `<SceneCanvas>`, which wraps it.\n *\n * The `layers` prop is a map keyed by slot name, every slot already a layer. Standard slots\n * render at a canonical position; custom entries (any other key, value carrying `.layer`) insert\n * at `after`/`before` an existing slot, defaulting to the top.\n *\n * @internal\n * @deprecated Bare `<Canvas>` is not a supported consumer surface.\n * Use `<SceneCanvas>` instead.\n */\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport type React from 'react';\nimport type { Paint } from '@weasel-js/paint';\nimport { composeOrderedLayers, placeToolOverlays } from './layerOrder';\nimport { STANDARD_SLOTS, isCustomEntry, type CanvasLayers } from './layerSlots';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport { registerMountedCanvas } from './mountedCanvases';\nimport type { GestureSource } from './gestureBounds';\nimport { useViewHelpers } from './useViewHelpers';\nimport { useSurfaceInput } from './useSurfaceInput';\nimport type { CanvasViewState } from './useCanvasView';\nimport { useOptionalViewRegistry } from './viewRegistry';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasHelpers, CanvasSurfaceHelpers, ViewPoseAdapter } from './useViewHelpers';\n\nimport { useLatest } from '@weasel-js/react';\nimport type { View } from 'core/viewport/view';\nimport { clientToWorld as clientToWorldHelper } from 'core/viewport/clientToWorld';\nimport {\n drawLayers, isLayerPainted,\n type Dims, type LayerCommandCache, type LayerGroup, type RedrawSource, type RenderLayer,\n} from 'core/layers/render';\nimport { viewToMat3, type ShaderProgramHandle } from '@weasel-js/renderer';\nimport { createBackgroundFillLayer } from 'core/layers/backgroundFill';\nimport { shaderKeyOf } from './canvasRenderer';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport {\n type SelectionApi,\n} from 'core/selection/useSelection';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { CanvasDebugSink, DebugConfig } from '../debug/types';\nimport { beginDebugFrame, useDebugSink } from '../debug/useDebugSink';\n\nconst alwaysVisible = (_id: string): boolean => true;\nimport { createCursorSink, createPaintedCursorState } from '@weasel-js/cursor';\nimport type { PaintedCursorState } from '@weasel-js/cursor';\nimport { useToolCursor } from './useToolCursor';\nimport { createPaintedCursorLayer } from './paintedCursorLayer';\n\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/**\n * Props for `<Canvas>`. Canvas is scene-agnostic: it owns the GL surface, view state, hover\n * delivery, and slot composition, and not gesture dispatch, selection state, picking logic,\n * kind registries, or scene-aware overlays.\n */\nexport interface CanvasProps<TPose = unknown> {\n /** CSS-pixel width. */\n width: number;\n /** CSS-pixel height. */\n height: number;\n\n /** Drawing-buffer density (device pixels per CSS pixel). When omitted the\n * canvas reads `window.devicePixelRatio` per paint. */\n dpr?: number;\n\n /** Flatness tolerance for curve tessellation, in world units. Forwarded to\n * `WeaselRendererOptions.flattenTolerance`. Leave unset for the cached\n * default (`DEFAULT_FLATTEN_TOLERANCE`, 0.5); a scene whose world unit is\n * not a pixel — feet, inches, millimetres — needs a value scaled to its\n * unit or sub-unit curves flatten to a handful of vertices. */\n flattenTolerance?: number;\n\n /** The version of whatever content this canvas draws, sampled at paint time\n * and reported by {@link CanvasExtensionApi.getPaintedVersion}.\n * `<SceneCanvas>` wires this to `scene.getVersion`. Chrome that must not\n * show DOM ahead of pixels compares the two and defers a frame. */\n contentVersion?: () => number;\n\n /** Paint inside the React commit rather than on the next animation frame.\n * Costs a synchronous paint per commit and per redraw request; buys\n * single-commit consistency between React-rendered DOM and canvas pixels.\n * For consumers with DOM chrome pinned to canvas content that cannot\n * tolerate a frame of skew. Live: toggling it switches modes from the next\n * redraw on. A redraw requested from inside a layer's `draw`, or from a\n * `subscribeFrame` callback, still waits for a frame — painting it in place\n * would recurse. */\n syncPaint?: boolean;\n\n /** External state the paint reads that no layer declares — typically what\n * an `alphaFor` consults. Each source is subscribed while mounted and\n * repaints the canvas when it notifies. A layer that reads outside state\n * declares it on `RenderLayer.subscribe` instead. */\n redrawOn?: readonly RedrawSource[];\n\n /** Adapter the pose and bounds lookups on `helpersRef` read. */\n adapter?: ViewPoseAdapter<TPose>;\n\n /** Layer map. See module docstring for slot semantics. */\n layers: CanvasLayers;\n\n /**\n * Current selection state; Canvas owns none of its own and never writes it. When absent,\n * Canvas behaves as if nothing is selected: no selection chrome.\n */\n selection?: SelectionApi;\n\n\n /**\n * How to read and rewrite a pose. Drives the default `boundsOf` fallback and the\n * selection-overlay bounds. Defaults to the rect identity (`AUTO_POSE_DESCRIPTOR`); supply\n * one for a non-rect pose type.\n */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n /**\n * Override for committed bounds lookup, taking precedence over the `poseDescriptor`-derived\n * fallback. Used by the selection overlay, the multi-select union AABB, and\n * `helpersRef.getEffectiveBounds`.\n */\n boundsOf?: (id: string) => Bounds | null;\n /** Bounds of `id` drawn at an in-flight pose — how chrome boxes a preview.\n * Defaults to the `poseDescriptor`'s box of that pose. */\n boundsOfPose?: (id: string, pose: TPose) => Bounds | null;\n /**\n * Custom pointer-to-world coordinate transform, overriding the default canvas-rect\n * calculation. Useful for consumers that apply an additional CSS transform to the canvas\n * element.\n */\n clientToWorld?: (canvas: HTMLElement, cx: number, cy: number) => [number, number];\n\n /**\n * Paint into a caller-owned canvas at a rect on it, instead of an element\n * this component creates. `x`/`y` are the rect's top-left in that canvas's\n * CSS pixels; the rect's size is the existing `width`/`height` props.\n *\n * Requires `inputElement`: with no element of its own there is nowhere for\n * pointer input, focus or the cursor to live, and nothing renders.\n *\n * N canvases can then share one GL context and one buffer.\n */\n paintInto?: { canvas: HTMLCanvasElement | null; x: number; y: number };\n /**\n * The element pointer input, focus and the cursor come from, and the element\n * every client→world conversion measures. Only read alongside `paintInto`;\n * an attached canvas uses the one it renders.\n */\n inputElement?: HTMLElement | null;\n\n /** Class for the `<canvas>` this component renders. Under `paintInto` it\n * renders none, and the input element is the caller's to style. */\n className?: string;\n /** Inline style for the `<canvas>` this component renders; a tool's cursor\n * is merged over it. Not applied under `paintInto`, where only that cursor\n * is written, onto the input element. */\n style?: React.CSSProperties;\n /** Tab order of the `<canvas>` this component renders. Default 0, so the\n * canvas is focusable. Not applied under `paintInto`: whether the input\n * element can take focus is the caller's to decide. */\n tabIndex?: number;\n /** Fired when the element input comes from gains focus: the canvas, or\n * under `paintInto` the `inputElement`. Called with the DOM event. */\n onFocus?: (event: FocusEvent) => void;\n /** Fired when that element loses focus. */\n onBlur?: (event: FocusEvent) => void;\n /**\n * When `true` (default), the canvas element receives focus on `pointerdown` so keyboard\n * events are captured without a separate click-to-focus step. Set to `false` where\n * auto-focus would steal focus from sibling inputs.\n */\n autoFocusOnPointerDown?: boolean;\n\n /** The tool set. Canvas reads the active tool's cursor and its overlays;\n * it dispatches nothing to a tool. */\n tools?: import('../tools/overlayBinding').ToolsApi;\n\n /** The camera this surface looks through, from `useCanvasView`. Whoever\n * made it holds the view props; the surface adopts and announces a\n * controlled view among its own effects, and repaints when one moves. */\n viewState: CanvasViewState;\n /**\n * Mutable ref Canvas writes overlay-aware pose/bounds lookups to on every render. Custom\n * layers can read it from inside their `draw` closure to reflect in-flight gestures\n * (move/resize/rotate) instead of the committed scene; an id outside the active overlay\n * falls back to the adapter.\n */\n helpersRef?: React.MutableRefObject<CanvasHelpers<TPose> | null>;\n\n /**\n * Debug overlay configuration.\n * - `undefined` (default): read `?debug=…` from the URL.\n * - `false`: force off, ignore URL.\n * - `DebugConfig` object: force on with that config, ignore URL.\n *\n * When enabled, the Canvas appends a screen-space `debug-overlay` layer and builds the\n * sink it paints: each paint records into it, and the layer helpers and the ref handle's\n * `getDebug` hand it to whatever else records.\n */\n debug?: DebugConfig | false;\n\n /** Test-only escape hatch: writes the live debug sink to this ref so tests\n * can call `snapshot()` after a render. No effect when debug is off. */\n debugSinkRef?: React.MutableRefObject<CanvasDebugSink | null>;\n\n /**\n * Shader programs to compile before the frame that first draws them; one\n * not named here compiles on that frame. Each handle comes from a\n * module-level `registerProgram()`. The array is read at each paint and\n * registered again when its ids change, so a handle added after mount is\n * picked up. Re-registering one of these ids with new source repaints the\n * canvas, and the renderer recompiles it for that frame.\n */\n shaders?: ShaderProgramHandle[];\n\n /**\n * Preview-pose lookup, so selection chrome tracks the ghost during dispatcher-driven\n * drags. Returns `null` / `undefined` when no preview is in flight.\n */\n previewPoseExtra?: (id: string) => unknown;\n\n /**\n * In-flight gesture state `<Canvas>` can't see for itself. Backs the `getGestureBounds` /\n * `subscribeGestures` / `getGestureVersion` trio on `helpersRef`. Unwired, those three\n * report \"no gesture in flight\" and never fire.\n */\n gestureSource?: GestureSource;\n\n /**\n * Fill for the full canvas surface, drawn as a screen-space layer beneath every other\n * layer, the grid and anything anchored before it included — independent of pan / zoom.\n */\n backgroundFill?: Paint;\n\n /**\n * Mode-owned decoration layer (e.g. path-edit anchor dots). Composed as a `decorationLayer`\n * entry in `layers` with no anchor, which this prop replaces: it paints above every slot\n * and every other custom layer, and beneath a tool's `'top'` overlays. A tool's\n * selection-anchored overlays sit beneath it too while there is selection chrome to anchor\n * them; with that slot empty they fall to the tail and paint above it.\n */\n decorationLayer?: RenderLayer<unknown>;\n\n /**\n * Chrome-caps visibility resolver. Exposed on `helpersForLayers.getIsVisible` so custom\n * layers (notably `composeAffordanceLayer`) can gate paint by chrome id, and threaded into\n * hit-testing so the same gate applies there. Called fresh per draw / per hitTest. Omit to\n * leave every chrome element visible.\n */\n getIsVisible?: () => (id: string) => boolean;\n\n /**\n * Show or hide whole render layers by id. An id absent from the map falls\n * back to the layer's own `defaultVisible`, and a layer marked `alwaysOn`\n * ignores the map entirely.\n *\n * Hiding a layer also stops it claiming pointer events through\n * `hitTestExtras` — a layer nobody can see must not swallow a click.\n *\n * This is `getIsVisible`'s coarser sibling: that one gates individual\n * chrome elements *within* a layer, this one gates the layer.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order, by layer id, bottom first. Omit for the order the layers\n * arrive in.\n *\n * **A listed order is the whole list:** any layer whose id is missing from\n * it is not drawn. Reordering two layers means naming all of them.\n */\n layerOrder?: string[];\n\n /**\n * Runs of consecutive layers that composite as one — the surface for blurring the world\n * while the chrome above it stays sharp. Members are named by layer id. See\n * {@link LayerGroup}.\n */\n layerGroups?: readonly LayerGroup[];\n}\n\n\nconst NO_SELECTION: SelectionApi['current'] = [];\n\nconst NO_LAYER_VISIBILITY: Record<string, boolean> = {};\n\nfunction CanvasInner<TPose>(\n props: CanvasProps<TPose>,\n ref: React.ForwardedRef<CanvasExtensionApi>,\n) {\n const {\n width,\n height,\n dpr: dprProp,\n flattenTolerance,\n contentVersion,\n syncPaint = false,\n redrawOn,\n adapter,\n layers: layersMap,\n selection,\n boundsOf,\n boundsOfPose,\n clientToWorld,\n paintInto,\n inputElement,\n poseDescriptor: geometry = AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>,\n className,\n style,\n tabIndex = 0,\n onFocus,\n onBlur,\n autoFocusOnPointerDown = true,\n helpersRef,\n tools,\n viewState,\n debug: debugProp,\n debugSinkRef,\n shaders,\n previewPoseExtra,\n gestureSource,\n backgroundFill,\n decorationLayer,\n getIsVisible,\n layerVisibility,\n layerOrder,\n layerGroups,\n } = props;\n\n const { sink: debugSink, overlay: debugOverlay, frameStats, getDebug } = useDebugSink(debugProp);\n\n // The element input comes from and every client→world conversion measures: the `<canvas>`\n // this component renders, or under `paintInto` the caller's `inputElement`.\n const canvasRef = useRef<HTMLElement | null>(null);\n // The `<canvas>` this component rendered, if it rendered one. `paint` is the\n // only thing that needs a real canvas, for `getContext`.\n const ownCanvasRef = useRef<HTMLCanvasElement | null>(null);\n // Stable, so a commit does not detach the element: an inline ref is nulled\n // until the layout phase reaches it, and a sync paint asked for before that\n // finds no canvas.\n const setOwnCanvas = useCallback((el: HTMLCanvasElement | null) => {\n ownCanvasRef.current = el;\n canvasRef.current = el;\n }, []);\n const detached = !!paintInto;\n // The detached input element reaches `canvasRef` at commit; the own canvas\n // arrives through `setOwnCanvas`, React's ref callback.\n useInsertionEffect(() => {\n if (detached) canvasRef.current = inputElement ?? null;\n });\n // Where pixels go. Split from `canvasRef` only when detached.\n const paintTarget = detached ? (paintInto.canvas ?? null) : null;\n const paintTargetRef = useLatest(paintTarget);\n const paintRect = detached ? { x: paintInto.x, y: paintInto.y } : null;\n const paintRectRef = useLatest(paintRect);\n\n // Read by `hitTestExtras`, which is built once and must see live values.\n const helpersForLayersRef = useRef<CanvasHelpers<TPose> | null>(null);\n const dimsRef = useLatest({ width, height });\n // Which layers reach the screen, and which chrome within them: asked by the\n // paint and by every hit-test.\n const gateRef = useLatest({ getIsVisible, layerVisibility, layerOrder });\n\n // React does not drive the paint; the frame loop does. The thunk defers to\n // `paint` below, which needs inputs this render has not computed yet.\n const paintRef = useRef<() => boolean>(() => false);\n const { lease, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume } = useCanvasSurface(\n useCallback(() => paintRef.current(), []),\n { syncPaint, target: canvasRef, dpr: dprProp, redrawOn, shaders },\n );\n\n const contentVersionRef = useLatest(contentVersion);\n const paintedVersionRef = useRef(0);\n const getPaintedVersion = useCallback(() => paintedVersionRef.current, []);\n\n // The `layersWithDebug` memo reads `extrasRef.current`, so registration has\n // to bump state to re-run it. Rare (a HUD attaching, a loupe mounting).\n const [extrasVersion, setExtrasVersion] = useState(0);\n const extrasRef = useRef<Set<RenderLayer<unknown>>>(new Set());\n const registerLayer = useCallback((layer: RenderLayer<unknown>) => {\n extrasRef.current.add(layer);\n setExtrasVersion(n => n + 1);\n return () => {\n extrasRef.current.delete(layer);\n setExtrasVersion(n => n + 1);\n };\n }, []);\n\n // Hit-test registered layers topmost-first: registration order is draw order, so the\n // last-registered layer gets first refusal. `<SceneCanvas>` folds this into its\n // `affordanceAt` thunk; Canvas has the layers but not the dispatcher.\n const hitTestExtrasIn = useCallback((\n worldX: number,\n worldY: number,\n view: View,\n dims: Dims,\n data: unknown,\n only?: readonly RenderLayer<unknown>[],\n ) => {\n const layers = [...extrasRef.current].reverse();\n const gate = gateRef.current;\n const isVisible = gate.getIsVisible?.() ?? alwaysVisible;\n const visibility = gate.layerVisibility ?? NO_LAYER_VISIBILITY;\n const order = gate.layerOrder;\n for (const layer of layers) {\n if (!layer.hitTest) continue;\n if (only && !only.includes(layer)) continue;\n if (!isLayerPainted(layer, visibility, order)) continue;\n const hit = layer.hitTest(worldX, worldY, data, view, dims, isVisible);\n if (hit) return { layerId: layer.id, hit };\n }\n return null;\n }, [gateRef]);\n\n const {\n viewRef, controlled: controlledView, setView, getView, subscribeView,\n adoptControlled, announceControlled, clearSubscribers,\n } = viewState;\n\n const hitTestExtras = useCallback((\n worldX: number,\n worldY: number,\n frame?: { view: View; dims: Dims },\n ) => hitTestExtrasIn(\n worldX,\n worldY,\n frame?.view ?? viewRef.current,\n frame?.dims ?? dimsRef.current,\n helpersForLayersRef.current,\n ), [hitTestExtrasIn, dimsRef, viewRef]);\n\n // The one client→world conversion: hover, the view registry and both\n // handles answer with it, so a `clientToWorld` override reaches all of them\n // or none.\n const clientToWorldRef = useLatest(clientToWorld);\n const toWorld = useCallback((clientX: number, clientY: number): [number, number] => {\n const el = canvasRef.current;\n if (!el) return [clientX, clientY];\n const override = clientToWorldRef.current;\n if (override) return override(el, clientX, clientY);\n return clientToWorldHelper(clientX, clientY, el.getBoundingClientRect(), viewRef.current);\n }, [clientToWorldRef, viewRef]);\n\n useLayoutEffect(() => {\n const element = canvasRef.current;\n if (!element) return;\n return registerMountedCanvas({ element, getView });\n }, [detached, inputElement, getView]);\n\n // The painted tier's channel. `<Canvas>` owns it because it owns both ends:\n // the tool cursor that feeds it and the frame loop that has to repaint when\n // it changes. The hover pump reaches it through the ref handle below.\n const paintedCursor = useMemo<PaintedCursorState>(() => createPaintedCursorState(), []);\n const paintedCursorLayer = useMemo(\n () => createPaintedCursorLayer(paintedCursor),\n [paintedCursor],\n );\n // An idle pointermove repaints nothing on its own, so a cursor the compositor\n // is not drawing needs its own pump. The store stays quiet unless something\n // painted is actually on screen.\n useEffect(() => paintedCursor.subscribe(() => { requestRedraw(); }), [paintedCursor, requestRedraw]);\n // The one writer of the input element's `cursor` style: the tool's cursor\n // from here, a hover cursor from the pump, which reaches it through the handle.\n const cursorSink = useMemo(\n () => createCursorSink({ element: () => canvasRef.current, painted: () => paintedCursor }),\n [paintedCursor],\n );\n\n const getSurfaceRect = useCallback(() => {\n const origin = paintRectRef.current;\n const { width: w, height: h } = dimsRef.current;\n return { x: origin?.x ?? 0, y: origin?.y ?? 0, width: w, height: h };\n }, [dimsRef, paintRectRef]);\n\n useImperativeHandle(ref, () => ({\n // Named rather than read off `canvasRef` so the handle rebuilds when a\n // detached surface's input element arrives, which is a render later.\n element: detached ? inputElement ?? null : canvasRef.current,\n surface: detached ? paintInto?.canvas ?? null : ownCanvasRef.current,\n getSurfaceRect,\n clientToWorld: toWorld,\n requestRedraw,\n subscribeFrame,\n subscribeBeforePaint,\n subscribeResume,\n registerLayer,\n hitTestExtras,\n getView,\n setView,\n subscribeView,\n getPaintedVersion,\n paintedCursor,\n cursorSink,\n getDebug,\n }), [canvasRef, ownCanvasRef, detached, inputElement, paintInto?.canvas,\n getSurfaceRect, toWorld, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume,\n registerLayer,\n hitTestExtras, getView, setView, subscribeView, getPaintedVersion,\n paintedCursor, cursorSink, getDebug]);\n\n const layerCacheRef = useRef<LayerCommandCache>(new Map());\n\n // Views registered on this surface — declared as `views` descriptors or\n // mounted as `<CanvasView>` children. Null outside a surface that mounts a\n // registry, which is the single-view case.\n const viewRegistry = useOptionalViewRegistry();\n\n const selectedIdsForWiring = selection?.current ?? NO_SELECTION;\n\n // One view's overlay-aware state. A hook, so N views are N components each\n // calling it once — not a loop in this body.\n const { helpers: viewHelpers, chromeState: viewChromeState } = useViewHelpers<TPose>({\n adapter,\n geometry,\n boundsOf,\n boundsOfPose,\n selection: selectedIdsForWiring,\n gestureSource,\n previewPoseExtra,\n getIsVisible: () => gateRef.current.getIsVisible?.() ?? alwaysVisible,\n });\n\n const surfaceHelpers: CanvasSurfaceHelpers = {\n getDebug: () => debugSink,\n };\n const helpersForLayers: CanvasHelpers<TPose> = { ...viewHelpers, ...surfaceHelpers, viewId: null };\n\n const backgroundLayer = useMemo(\n () => (backgroundFill ? createBackgroundFillLayer(backgroundFill) : undefined),\n [backgroundFill],\n );\n\n const layers = useMemo<RenderLayer<unknown>[]>(() => {\n const standardLayers: Partial<\n Record<(typeof STANDARD_SLOTS)[number], RenderLayer<unknown>>\n > = {};\n for (const slot of ['grid', 'cellHighlight', 'selectionOverlay'] as const) {\n const entry = layersMap[slot];\n if (isCustomEntry(entry)) standardLayers[slot] = entry.layer;\n }\n const out: RenderLayer<unknown>[] = composeOrderedLayers(\n decorationLayer ? { ...layersMap, decorationLayer: { layer: decorationLayer } } : layersMap,\n standardLayers, layersMap.scene?.layers, backgroundLayer,\n );\n if (tools) {\n placeToolOverlays(out, standardLayers.selectionOverlay, tools.getActiveOverlays);\n }\n return out;\n }, [layersMap, tools, backgroundLayer, decorationLayer]);\n\n const viewRegistryVersion = useSyncExternalStore(\n useCallback((cb: () => void) => viewRegistry?.subscribe(cb) ?? (() => {}), [viewRegistry]),\n () => viewRegistry?.getVersion() ?? 0,\n () => 0,\n );\n\n // The stack a view paints through its own camera is this canvas's, before\n // the views themselves are folded in — otherwise a view would contain\n // itself. Published by reference and read at draw time.\n const surfaceLayersRef = useLatest<readonly RenderLayer<unknown>[]>(layers);\n useEffect(() => {\n return viewRegistry?.attachSurface({\n view: () => viewRef.current,\n dims: () => dimsRef.current,\n layers: () => surfaceLayersRef.current,\n requestRedraw,\n chromeState: () => helpersForLayersRef.current!.getChromeState(),\n hitTestExtras: hitTestExtrasIn,\n clientToWorld: toWorld,\n claimsAbove: (x, y) => {\n const view = viewRef.current;\n const worldX = x / view.scale.x + view.x;\n const worldY = y / view.scale.y + view.y;\n return hitTestExtrasIn(worldX, worldY, view, dimsRef.current, helpersForLayersRef.current) !== null;\n },\n });\n }, [viewRegistry, canvasRef, requestRedraw, hitTestExtrasIn, dimsRef, surfaceLayersRef, viewRef, toWorld]);\n\n const layersWithDebug = useMemo(() => {\n // Views paint through the surface's own stack, so they sit above it and\n // below both the debug overlay and externally-registered layers.\n const withViews = viewRegistry\n ? [...layers, ...viewRegistry.list().filter((r) => r.paint).map((r) => r.layer as RenderLayer<unknown>)]\n : layers;\n const base = debugOverlay ? [...withViews, debugOverlay] : withViews;\n // The cursor goes last: it is the one thing that is always in front of\n // everything, including a consumer's own registered layers.\n return [...base, ...extrasRef.current, paintedCursorLayer];\n // extrasVersion drives re-reads of extrasRef when layers are registered/detached;\n // viewRegistryVersion does the same for registered views.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layers, debugOverlay, extrasVersion, viewRegistry, viewRegistryVersion,\n paintedCursorLayer]);\n\n useEffect(() => {\n const redraw = (): void => { requestRedraw(); };\n const offs: (() => void)[] = [];\n for (const layer of layersWithDebug) if (layer.subscribe) offs.push(layer.subscribe(redraw));\n return () => { for (const off of offs) off(); };\n }, [layersWithDebug, requestRedraw]);\n\n const shaderIdKey = shaderKeyOf(shaders);\n\n // Everything the paint, hit-testing and the view registry read that a React\n // render owns. `useLatest` and the insertion effect below publish committed\n // renders only, ahead of every layout effect in the commit, any of which may\n // ask for a sync paint.\n const paintInputs = {\n layers: layersWithDebug, width, height, debugSink, frameStats,\n dpr: dprProp, layerGroups, shaders,\n flattenTolerance,\n };\n const paintInputsRef = useLatest(paintInputs);\n useInsertionEffect(() => {\n adoptControlled();\n helpersForLayersRef.current = helpersForLayers;\n if (helpersRef) helpersRef.current = helpersForLayers;\n if (debugSinkRef) debugSinkRef.current = debugSink;\n });\n useLayoutEffect(() => {\n announceControlled();\n });\n\n const paint = useCallback((): boolean => {\n const c = paintTargetRef.current ?? ownCanvasRef.current;\n if (!c) return false;\n const rect = paintRectRef.current;\n const {\n layers: paintLayers, width: w, height: h, debugSink: sink, frameStats: timed,\n dpr: dprIn,\n flattenTolerance: paintFlattenTolerance,\n layerGroups: groups, shaders: paintShaders,\n } = paintInputsRef.current;\n\n const debugFrame = beginDebugFrame(sink, timed, paintLayers);\n\n const renderer = lease.bind(c, { width: w, height: h, dpr: dprIn }, {\n tile: rect,\n flattenTolerance: paintFlattenTolerance,\n shaders: paintShaders,\n });\n // No WebGL2 (jsdom), or a context that is lost for now: nothing to paint.\n if (!renderer) return false;\n\n const view = viewRef.current;\n const { layerVisibility: vis, layerOrder: order } = gateRef.current;\n const spans = debugFrame?.time();\n const commands = drawLayers(\n paintLayers,\n helpersForLayersRef.current,\n vis ?? NO_LAYER_VISIBILITY,\n order,\n view,\n { width: w, height: h },\n layerCacheRef.current,\n undefined,\n groups,\n spans,\n );\n renderer.render(commands, viewToMat3(view), spans ? { spans } : undefined);\n debugFrame?.end(renderer.lastFrameStats());\n paintedVersionRef.current = contentVersionRef.current?.() ?? 0;\n return true;\n }, [contentVersionRef, gateRef, lease, paintInputsRef, paintRectRef, paintTargetRef, viewRef]);\n useInsertionEffect(() => {\n paintRef.current = paint;\n });\n\n // A tripwire, not a list of values this effect uses: every paint input that\n // arrives on a render must appear here, or changing it paints stale.\n // `viewChromeState` stands in for the whole overlay-aware set the layer\n // helpers expose — it re-memoizes on exactly the selection, bounds and\n // preview inputs they read. What moves between renders instead (a scene\n // write, a gesture pump, a late image decode) pushes its own redraw.\n // Layout, not passive, so a `syncPaint` surface lands its pixels in the same\n // commit as the DOM.\n useLayoutEffect(() => {\n requestRedraw();\n }, [layersWithDebug, width, height, debugSink, dprProp, flattenTolerance,\n controlledView?.x, controlledView?.y, controlledView?.scale.x, controlledView?.scale.y,\n layerVisibility, layerOrder, layerGroups, shaderIdKey, syncPaint,\n viewChromeState, getIsVisible, paintTarget, paintRect?.x, paintRect?.y, requestRedraw]);\n\n useEffect(() => {\n const layerCache = layerCacheRef.current;\n return () => {\n layerCache.clear();\n clearSubscribers();\n };\n }, [clearSubscribers]);\n\n useToolCursor(cursorSink, tools, detached ? inputElement : null, style?.cursor);\n\n useSurfaceInput(canvasRef, {\n focusOnPress: autoFocusOnPointerDown,\n onFocus,\n onBlur,\n onHover: (_el, e) => {\n const view = viewRef.current;\n const [worldX, worldY] = toWorld(e.clientX, e.clientY);\n const visibility = layerVisibility ?? NO_LAYER_VISIBILITY;\n // Same gate as `hitTestExtrasIn`: a layer nobody can see takes no input.\n for (const layer of layersWithDebug) {\n if (!layer.onUncapturedMove || !isLayerPainted(layer, visibility, layerOrder)) continue;\n layer.onUncapturedMove(worldX, worldY, e, view, { width, height });\n }\n },\n onLeave: () => {\n for (const layer of layersWithDebug) layer.onUncapturedLeave?.();\n },\n });\n\n if (detached) return null;\n\n return (\n <SurfaceCanvas\n ref={setOwnCanvas}\n width={width}\n height={height}\n tabIndex={tabIndex}\n className={className} style={style}\n />\n );\n}\n\n/** Forward-ref'd `<canvas>` wrapper. Generic over the pose type, inferred from the\n * `adapter` prop. */\nexport const Canvas = forwardRef(CanvasInner) as <TPose = unknown>(\n props: CanvasProps<TPose> & { ref?: React.ForwardedRef<CanvasExtensionApi> },\n) => ReturnType<typeof CanvasInner>;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAME,MAAiB,MAAyB,IA8O1CC,KAAwC,CAAC,GAEzCC,KAA+C,CAAC;AAEtD,SAASC,GACP,GACA,IACA;CACA,IAAM,EACJ,UACA,WACA,KAAKC,GACL,sBACA,oBACA,gBAAY,IACZ,cACA,aACA,QAAQC,GACR,eACA,cACA,kBACA,eAAAC,IACA,cACA,iBACA,gBAAgBC,KAAWC,GAC3B,eACA,WACA,eAAW,GACX,aACA,YACA,6BAAyB,IACzB,gBACA,UACA,eACA,OAAOC,IACP,kBACA,YACA,sBACA,mBACA,mBACA,oBACA,kBACA,oBACA,eACA,oBACEC,GAEE,EAAE,MAAMC,GAAW,SAASC,GAAc,gBAAY,iBAAaC,GAAaJ,EAAS,GAIzFK,IAAYC,EAA2B,IAAI,GAG3CC,IAAeD,EAAiC,IAAI,GAIpDE,KAAeC,GAAa,MAAiC;EAEjE,AADA,EAAa,UAAUC,GACvB,EAAU,UAAUA;CACtB,GAAG,CAAC,CAAC,GACCC,IAAW,CAAC,CAACC;CAGnB,QAAyB;EACvB,AAAID,MAAU,EAAU,UAAUE,KAAgB;CACpD,CAAC;CAED,IAAMC,KAAcH,IAAYC,EAAU,UAAU,OAAQ,MACtDG,KAAiBC,EAAUF,EAAW,GACtCG,KAAYN,IAAW;EAAE,GAAGC,EAAU;EAA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