@weasel-js/core 1.9.3 → 1.10.0
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 +1106 -0
- package/README.md +7 -5
- package/dist/WeaselProvider.js +5 -7
- package/dist/WeaselProvider.js.map +1 -1
- package/dist/affordances/composeAffordanceLayer.js +91 -93
- package/dist/affordances/composeAffordanceLayer.js.map +1 -1
- package/dist/affordances/cornerResize.js +27 -18
- package/dist/affordances/cornerResize.js.map +1 -1
- package/dist/affordances/hitAffordanceRegions.js +65 -104
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/affordances/rotationHandle.js +22 -21
- package/dist/affordances/rotationHandle.js.map +1 -1
- package/dist/animation/behaviors/coast.js +21 -0
- package/dist/animation/behaviors/coast.js.map +1 -0
- package/dist/animation/behaviors/coastByWrite.js +107 -0
- package/dist/animation/behaviors/coastByWrite.js.map +1 -0
- package/dist/animation/behaviors/coastOnTargets.js +94 -0
- package/dist/animation/behaviors/coastOnTargets.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +38 -88
- package/dist/animation/behaviors/momentum.js.map +1 -1
- package/dist/animation/clipTargets.js +12 -0
- package/dist/animation/clipTargets.js.map +1 -0
- package/dist/animation/index.js +15 -20
- package/dist/animation/poseHelpers.js +112 -33
- package/dist/animation/poseHelpers.js.map +1 -1
- package/dist/animation/poseTarget.js +115 -0
- package/dist/animation/poseTarget.js.map +1 -0
- package/dist/animation/reflow.js +113 -83
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/rewind.js +66 -0
- package/dist/animation/rewind.js.map +1 -0
- package/dist/animation/rig/bindRig.js +85 -53
- package/dist/animation/rig/bindRig.js.map +1 -1
- package/dist/animation/rig/rigNode.js +93 -0
- package/dist/animation/rig/rigNode.js.map +1 -0
- package/dist/animation/rig/rigSeat.js +26 -0
- package/dist/animation/rig/rigSeat.js.map +1 -0
- package/dist/animation/rig/skinBinding.js +56 -0
- package/dist/animation/rig/skinBinding.js.map +1 -0
- package/dist/animation/rig/useRig.js +31 -16
- package/dist/animation/rig/useRig.js.map +1 -1
- package/dist/animation/wrappers/animateLifecycle.js +32 -24
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
- package/dist/animation/wrappers/animateOnSetPose.js +31 -29
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
- package/dist/animation/wrappers/instantPose.js +13 -0
- package/dist/animation/wrappers/instantPose.js.map +1 -0
- package/dist/animation/writtenPoseTarget.js +33 -0
- package/dist/animation/writtenPoseTarget.js.map +1 -0
- package/dist/{autoPoseDescriptor-vCdt55xm.d.ts → autoPoseDescriptor-DHg5KqaJ.d.ts} +1 -1
- package/dist/barrel/canvas.js +31 -0
- package/dist/barrel/chrome.js +16 -0
- package/dist/barrel/input.js +18 -0
- package/dist/barrel/interactions.js +38 -0
- package/dist/barrel/paint.js +11 -0
- package/dist/barrel/paths.js +12 -0
- package/dist/barrel/renderer.js +14 -0
- package/dist/barrel/routing.js +57 -0
- package/dist/barrel/scene.js +37 -0
- package/dist/barrel/text.js +9 -0
- package/dist/barrel/viewport.js +42 -0
- package/dist/canvas/Canvas.js +280 -559
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +147 -167
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/CursorCoordsHud.js +53 -49
- package/dist/canvas/CursorCoordsHud.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +40 -51
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/ModalityHud.js.map +1 -1
- package/dist/canvas/NodeShape.js +55 -374
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/PickHud.js +50 -47
- package/dist/canvas/PickHud.js.map +1 -1
- package/dist/canvas/SceneCanvas/DevHuds.js +40 -0
- package/dist/canvas/SceneCanvas/DevHuds.js.map +1 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +126 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +27 -31
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +64 -0
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/coordTrace.js +46 -0
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +138 -85
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +74 -43
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/isDev.js +12 -0
- package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +31 -34
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
- package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
- package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
- package/dist/canvas/SceneCanvas/props.js +39 -0
- package/dist/canvas/SceneCanvas/props.js.map +1 -0
- package/dist/canvas/SceneCanvas/toolRegistry.js +23 -0
- package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +6 -1
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinTools.js +21 -0
- package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasCamera.js +38 -0
- package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +20 -0
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js +16 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasTools.js +67 -0
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +29 -29
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useHeldModifiers.js +20 -0
- package/dist/canvas/SceneCanvas/useHeldModifiers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useNodeAtPoint.js +26 -0
- package/dist/canvas/SceneCanvas/useNodeAtPoint.js.map +1 -0
- package/dist/canvas/SceneCanvas/useNodeKinds.js +26 -0
- package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +48 -48
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +47 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +66 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneChrome.js +59 -0
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js +23 -0
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +74 -78
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSlotLayers.js +37 -0
- package/dist/canvas/SceneCanvas/useSceneSlotLayers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js +38 -0
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewLayerGate.js +20 -0
- package/dist/canvas/SceneCanvas/useViewLayerGate.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +9 -1
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -1
- package/dist/canvas/SceneCanvas/worldPointAt.js +9 -0
- package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +311 -969
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +42 -46
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/adapterDerivedPath.js +26 -0
- package/dist/canvas/adapterDerivedPath.js.map +1 -0
- package/dist/canvas/affordanceAt.js +11 -1
- package/dist/canvas/affordanceAt.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js +111 -0
- package/dist/canvas/buildSceneLayer.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +16 -19
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/canvasRenderer.js +67 -55
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/colorOverrides.js.map +1 -1
- package/dist/canvas/defaultDrawOne.js +12 -12
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/areaSelect.js +4 -4
- package/dist/canvas/deps/areaSelect.js.map +1 -1
- package/dist/canvas/deps/changes.js +13 -0
- package/dist/canvas/deps/changes.js.map +1 -0
- package/dist/canvas/deps/debug.js.map +1 -1
- package/dist/canvas/deps/editAnchors.js +38 -57
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/geometryProjection.js.map +1 -1
- package/dist/canvas/deps/hitTestArea.js +31 -26
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +130 -91
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/lassoSelect.js +5 -5
- package/dist/canvas/deps/lassoSelect.js.map +1 -1
- package/dist/canvas/deps/poseDescriptor.js +1 -1
- package/dist/canvas/deps/poseDescriptor.js.map +1 -1
- package/dist/canvas/deps/resizePolicy.js.map +1 -1
- package/dist/canvas/deps/slice.js +26 -26
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/deps/textEdit.js +6 -5
- package/dist/canvas/deps/textEdit.js.map +1 -1
- package/dist/canvas/deps/view.js.map +1 -1
- package/dist/canvas/derivedPath.js +47 -22
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/drawEnvelope.js +8 -4
- package/dist/canvas/drawEnvelope.js.map +1 -1
- package/dist/canvas/getNodeAtPoint.js +4 -8
- package/dist/canvas/getNodeAtPoint.js.map +1 -1
- package/dist/canvas/hud.module.js +1 -1
- package/dist/canvas/hud.module.js.map +1 -1
- package/dist/canvas/insertPreviewExtent.js.map +1 -1
- package/dist/canvas/kitRequirements.js +2 -2
- package/dist/canvas/kitRequirements.js.map +1 -1
- package/dist/canvas/layerOrder.js +13 -6
- package/dist/canvas/layerOrder.js.map +1 -1
- package/dist/canvas/layerSlots.js +6 -1
- package/dist/canvas/layerSlots.js.map +1 -1
- package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/imagePainter.js +87 -0
- package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/memo.js +9 -0
- package/dist/canvas/nodeShapes/memo.js.map +1 -0
- package/dist/canvas/nodeShapes/nodePaint.js +68 -0
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
- package/dist/canvas/nodeShapes/pathPainter.js +39 -0
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/poseBox.js +20 -0
- package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/shapePainter.js +72 -0
- package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/textPainter.js +55 -0
- package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/paintCull.js +11 -14
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/{features/cursor → canvas}/paintedCursorLayer.js +2 -2
- package/dist/canvas/paintedCursorLayer.js.map +1 -0
- package/dist/canvas/pickWalk.js +59 -68
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/planeClips.js +18 -19
- package/dist/canvas/planeClips.js.map +1 -1
- package/dist/canvas/poseCascade.js +41 -0
- package/dist/canvas/poseCascade.js.map +1 -0
- package/dist/canvas/poseRotation.js +9 -23
- package/dist/canvas/poseRotation.js.map +1 -1
- package/dist/canvas/rasterReadback.js +22 -0
- package/dist/canvas/rasterReadback.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +11 -11
- package/dist/canvas/renderDebugSnapshot.js.map +1 -1
- package/dist/canvas/renderNeeds.js +3 -3
- package/dist/canvas/renderNeeds.js.map +1 -1
- package/dist/canvas/renderSceneToPixels.js +64 -81
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +68 -214
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +112 -0
- package/dist/canvas/sceneClipboard.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +4 -4
- package/dist/canvas/sceneLayerPaint.js.map +1 -1
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +39 -39
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/slopsDebugLayer.js +4 -4
- package/dist/canvas/slopsDebugLayer.js.map +1 -1
- package/dist/canvas/surface.module.js +6 -0
- package/dist/canvas/surface.module.js.map +1 -0
- package/dist/canvas/surfaceBox.js +16 -0
- package/dist/canvas/surfaceBox.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +26 -6
- package/dist/canvas/useCanvasRenderer.js.map +1 -1
- package/dist/canvas/useCanvasSurface.js +31 -0
- package/dist/canvas/useCanvasSurface.js.map +1 -0
- package/dist/canvas/useCanvasView.js +67 -0
- package/dist/canvas/useCanvasView.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +39 -31
- package/dist/canvas/useFrameLoop.js.map +1 -1
- package/dist/canvas/useHostAnchor.js +35 -33
- package/dist/canvas/useHostAnchor.js.map +1 -1
- package/dist/canvas/useLateContentRedraw.js +8 -8
- package/dist/canvas/useLateContentRedraw.js.map +1 -1
- package/dist/canvas/useSceneLayerList.js +11 -0
- package/dist/canvas/useSceneLayerList.js.map +1 -0
- package/dist/canvas/useSurfaceInput.js +42 -0
- package/dist/canvas/useSurfaceInput.js.map +1 -0
- package/dist/canvas/useToolCursor.js +29 -0
- package/dist/canvas/useToolCursor.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +46 -85
- package/dist/canvas/useViewHelpers.js.map +1 -1
- package/dist/canvas/viewInputs.js.map +1 -1
- package/dist/canvas/viewRegistry.js +25 -27
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/canvas/watchElementMove.js +43 -0
- package/dist/canvas/watchElementMove.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -1
- package/dist/clipboard.d.ts +16 -19
- package/dist/{types-B_9g6hMM.d.ts → clone-2a5hVbBd.d.ts} +123 -74
- package/dist/clone.d.ts +4 -7
- package/dist/clone.js +0 -2
- package/dist/core/device/index.js +5 -4
- package/dist/core/device/targets.js.map +1 -1
- package/dist/core/device/useDeviceProfile.js +38 -44
- package/dist/core/device/useDeviceProfile.js.map +1 -1
- package/dist/core/device/watchDevicePixelRatio.js +17 -0
- package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
- package/dist/{interactions/actions/resize → core/geometry}/autoPoseDescriptor.js +8 -7
- package/dist/core/geometry/autoPoseDescriptor.js.map +1 -0
- package/dist/core/geometry/pathPoseDescriptor.js +88 -0
- package/dist/core/geometry/pathPoseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +68 -19
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/regionHit.js +31 -34
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/geometry/targetFrame.js +94 -0
- package/dist/core/geometry/targetFrame.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +30 -29
- package/dist/core/geometry/unionBounds.js.map +1 -1
- package/dist/core/isPlainObject.js +2 -11
- package/dist/core/layers/backgroundFill.js +31 -0
- package/dist/core/layers/backgroundFill.js.map +1 -0
- package/dist/{features/groups → core/layers}/children.js +1 -1
- package/dist/core/layers/children.js.map +1 -0
- package/dist/core/layers/gateLayer.js +13 -0
- package/dist/core/layers/gateLayer.js.map +1 -0
- package/dist/core/layers/layerGroup.js +40 -0
- package/dist/core/layers/layerGroup.js.map +1 -0
- package/dist/core/layers/render.js +50 -76
- package/dist/core/layers/render.js.map +1 -1
- package/dist/core/ops/arrange.js +1 -0
- package/dist/core/ops/arrange.js.map +1 -1
- package/dist/core/ops/create.js +10 -5
- package/dist/core/ops/create.js.map +1 -1
- package/dist/core/ops/createHistory.js +9 -9
- package/dist/core/ops/createHistory.js.map +1 -1
- package/dist/core/ops/delete.js +12 -24
- package/dist/core/ops/delete.js.map +1 -1
- package/dist/core/ops/reorder/index.js +43 -40
- package/dist/core/ops/reorder/index.js.map +1 -1
- package/dist/core/ops/reorder/setChildOrder.js +34 -0
- package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
- package/dist/core/paint/meshKind.js +16 -0
- package/dist/core/paint/meshKind.js.map +1 -0
- package/dist/{features/meshPaint/lazyKind.js → core/paint/meshKindLazy.js} +282 -105
- package/dist/core/paint/meshKindLazy.js.map +1 -0
- package/dist/core/paint/paintKindEntry.js +8 -0
- package/dist/core/paint/paintKindEntry.js.map +1 -0
- package/dist/core/paint/paintKinds.js +144 -0
- package/dist/core/paint/paintKinds.js.map +1 -0
- package/dist/core/paint/registerMesh.js +7 -0
- package/dist/core/paint/registerMesh.js.map +1 -0
- package/dist/core/scene/NodeProperties.js.map +1 -1
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/appliedLog.js +37 -0
- package/dist/core/scene/appliedLog.js.map +1 -0
- package/dist/core/scene/arrivalWindow.js +102 -0
- package/dist/core/scene/arrivalWindow.js.map +1 -0
- package/dist/core/scene/boundOps.js +40 -0
- package/dist/core/scene/boundOps.js.map +1 -0
- package/dist/core/scene/composeFrame.js +9 -6
- package/dist/core/scene/composeFrame.js.map +1 -1
- package/dist/{features/groups → core/scene}/composePose.js +18 -18
- package/dist/core/scene/composePose.js.map +1 -0
- package/dist/core/scene/depMemo.js +31 -6
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/derivedPath.js +19 -20
- package/dist/core/scene/derivedPath.js.map +1 -1
- package/dist/core/scene/editMode.js +26 -0
- package/dist/core/scene/editMode.js.map +1 -0
- package/dist/core/scene/effectivePose.js +38 -39
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +98 -0
- package/dist/core/scene/fieldEdits.js.map +1 -0
- package/dist/core/scene/historyFacade.js +130 -0
- package/dist/core/scene/historyFacade.js.map +1 -0
- package/dist/core/scene/historyForm.js +6 -0
- package/dist/core/scene/historyForm.js.map +1 -0
- package/dist/core/scene/kitOps.js +185 -0
- package/dist/core/scene/kitOps.js.map +1 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layerStack.js +131 -0
- package/dist/core/scene/layerStack.js.map +1 -0
- package/dist/core/scene/layoutPass.js +58 -59
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/lockGuard.js +37 -0
- package/dist/core/scene/lockGuard.js.map +1 -0
- package/dist/{features/groups → core/scene}/nestedHit.js +3 -3
- package/dist/core/scene/nestedHit.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +10 -11
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +45 -19
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/nodeStore.js +127 -0
- package/dist/core/scene/nodeStore.js.map +1 -0
- package/dist/core/scene/notifier.js +37 -0
- package/dist/core/scene/notifier.js.map +1 -0
- package/dist/core/scene/opTable.js +50 -0
- package/dist/core/scene/opTable.js.map +1 -0
- package/dist/core/scene/outerOps.js +66 -0
- package/dist/core/scene/outerOps.js.map +1 -0
- package/dist/core/scene/poseFeed.js +38 -38
- package/dist/core/scene/poseFeed.js.map +1 -1
- package/dist/core/scene/poseHold.js +39 -0
- package/dist/core/scene/poseHold.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +44 -40
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/poseSnapshot.js.map +1 -1
- package/dist/core/scene/reconcileSpecs.js +3 -2
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/recorder.js +86 -0
- package/dist/core/scene/recorder.js.map +1 -0
- package/dist/core/scene/renderOrder.js +84 -0
- package/dist/core/scene/renderOrder.js.map +1 -0
- package/dist/core/scene/scene.js +80 -1266
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneEdits.js +58 -0
- package/dist/core/scene/sceneEdits.js.map +1 -0
- package/dist/core/scene/sceneMutators.js +49 -0
- package/dist/core/scene/sceneMutators.js.map +1 -0
- package/dist/core/scene/scenePoseAdapter.js +16 -0
- package/dist/core/scene/scenePoseAdapter.js.map +1 -0
- package/dist/core/scene/sceneRecording.js +90 -0
- package/dist/core/scene/sceneRecording.js.map +1 -0
- package/dist/core/scene/sceneSelection.js +28 -0
- package/dist/core/scene/sceneSelection.js.map +1 -0
- package/dist/core/scene/sceneState.js +49 -0
- package/dist/core/scene/sceneState.js.map +1 -0
- package/dist/core/scene/serialization.js +71 -0
- package/dist/core/scene/serialization.js.map +1 -0
- package/dist/core/scene/staleReplay.js +51 -0
- package/dist/core/scene/staleReplay.js.map +1 -0
- package/dist/core/scene/statedFields.js +9 -0
- package/dist/core/scene/statedFields.js.map +1 -0
- package/dist/core/scene/treeEdits.js +127 -0
- package/dist/core/scene/treeEdits.js.map +1 -0
- package/dist/core/scene/treeOrder.js +13 -0
- package/dist/core/scene/treeOrder.js.map +1 -0
- package/dist/core/scene/treeReads.js +26 -0
- package/dist/core/scene/treeReads.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/{features/groups → core/scene}/unionOfChildren.js +3 -3
- package/dist/core/scene/unionOfChildren.js.map +1 -0
- package/dist/core/scene/unitScopes.js +13 -0
- package/dist/core/scene/unitScopes.js.map +1 -0
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/core/selection/readOnlySelection.js +32 -0
- package/dist/core/selection/readOnlySelection.js.map +1 -0
- package/dist/core/selection/usePublishSceneSelection.js +26 -0
- package/dist/core/selection/usePublishSceneSelection.js.map +1 -0
- package/dist/core/selection/useSelection.js +34 -25
- package/dist/core/selection/useSelection.js.map +1 -1
- package/dist/core/shapeKinds.js.map +1 -1
- package/dist/core/stylus/stylus.js.map +1 -1
- package/dist/core/stylus/usePointerStylus.js.map +1 -1
- package/dist/core/usePaintKinds.js +1 -1
- package/dist/core/usePaintKinds.js.map +1 -1
- package/dist/core/viewport/clientToWorld.js.map +1 -1
- package/dist/core/viewport/fitViewToBounds.js.map +1 -1
- package/dist/core/viewport/parallax.js.map +1 -1
- package/dist/core/viewport/screenSlop.js +11 -11
- package/dist/core/viewport/screenSlop.js.map +1 -1
- package/dist/core/viewport/useCanvasSize.js.map +1 -1
- package/dist/core/viewport/useDecayLoop.js +8 -8
- package/dist/core/viewport/useDecayLoop.js.map +1 -1
- package/dist/core/viewport/useNodeOverlayFrame.js +84 -0
- package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +102 -43
- package/dist/core/viewport/useViewAnimation.js.map +1 -1
- package/dist/core/viewport/view.js +9 -9
- package/dist/core/viewport/view.js.map +1 -1
- package/dist/core/viewport/wheelHandler.js.map +1 -1
- package/dist/core/viewport/zoomBounds.js +10 -8
- package/dist/core/viewport/zoomBounds.js.map +1 -1
- package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-BEshc4z3.d.ts} +11 -24
- package/dist/debug/createDebugOverlayLayer.js +97 -97
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/createDebugSink.js.map +1 -1
- package/dist/debug/flag.js +2 -41
- package/dist/debug/frameStats.js.map +1 -1
- package/dist/debug/useDebugSink.js +52 -0
- package/dist/debug/useDebugSink.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -1
- package/dist/features/chrome-caps/conditions.js.map +1 -1
- package/dist/features/chrome-caps/defaults.js.map +1 -1
- package/dist/features/chrome-caps/resolve.js.map +1 -1
- package/dist/features/chrome-caps/useChromeCaps.js +54 -0
- package/dist/features/chrome-caps/useChromeCaps.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +22 -17
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +28 -19
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/ingestion/imageHandler.js +21 -24
- package/dist/features/ingestion/imageHandler.js.map +1 -1
- package/dist/features/ingestion/openFilePicker.js.map +1 -1
- package/dist/features/ingestion/placement.js +16 -0
- package/dist/features/ingestion/placement.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +7 -7
- package/dist/features/ingestion/svgHandler.js +5 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -1
- package/dist/features/ingestion/textHandler.js +28 -0
- package/dist/features/ingestion/textHandler.js.map +1 -0
- package/dist/features/ingestion/useCanvasIngestion.js +48 -0
- package/dist/features/ingestion/useCanvasIngestion.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +22 -14
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
- package/dist/features/longPress/longPressFeedback.js.map +1 -1
- package/dist/features/modes/modeLayers.js +7 -7
- package/dist/features/modes/modeLayers.js.map +1 -1
- package/dist/features/paths/editablePath.js +47 -0
- package/dist/features/paths/editablePath.js.map +1 -0
- package/dist/features/paths/index.js +9 -14
- package/dist/features/paths/pathEditState.js +41 -0
- package/dist/features/paths/pathEditState.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +36 -38
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -1
- package/dist/features/paths/pathLayer.js +3 -2
- package/dist/features/paths/pathLayer.js.map +1 -1
- package/dist/features/paths/penPreviewLayer.js +86 -88
- package/dist/features/paths/penPreviewLayer.js.map +1 -1
- package/dist/features/paths/usePathEdit.js +34 -0
- package/dist/features/paths/usePathEdit.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +44 -52
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/selection/overlay.js +171 -179
- package/dist/features/selection/overlay.js.map +1 -1
- package/dist/features/text/index.js +6 -0
- package/dist/features/text/textLayer.js +1 -1
- package/dist/features/text/textLayer.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +100 -93
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/viewports/viewportLayer.js +25 -36
- package/dist/features/viewports/viewportLayer.js.map +1 -1
- package/dist/index.d.ts +8473 -9141
- package/dist/index.js +269 -307
- package/dist/input/keyState.js +38 -39
- package/dist/input/keyState.js.map +1 -1
- package/dist/input/useKeyModifiers.js +11 -0
- package/dist/input/useKeyModifiers.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -1
- package/dist/interactions/actions/{defaults/align.js → align/action.js} +18 -20
- package/dist/interactions/actions/align/action.js.map +1 -0
- package/dist/interactions/actions/align/align.js +20 -20
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/action.js +65 -0
- package/dist/interactions/actions/booleans/action.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +69 -78
- package/dist/interactions/actions/booleans/booleans.js.map +1 -1
- package/dist/interactions/actions/booleans/operands.js +40 -0
- package/dist/interactions/actions/booleans/operands.js.map +1 -0
- package/dist/interactions/actions/booleans/pieces.js +45 -0
- package/dist/interactions/actions/booleans/pieces.js.map +1 -0
- package/dist/interactions/actions/booleans/placement.js +24 -0
- package/dist/interactions/actions/booleans/placement.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +11 -9
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -1
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -1
- package/dist/interactions/actions/{defaults/clipboard.js → clipboard/action.js} +31 -15
- package/dist/interactions/actions/clipboard/action.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +44 -42
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
- package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
- package/dist/interactions/actions/clone/action.js +98 -0
- package/dist/interactions/actions/clone/action.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors.js +52 -0
- package/dist/interactions/actions/clone/behaviors.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +7 -32
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +60 -84
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/areaSelect.js +35 -38
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/copySubtree.js +40 -0
- package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +13 -53
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +40 -50
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +24 -1
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -1
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +39 -1
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +44 -38
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +11 -12
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +40 -69
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
- package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/reorder.js +2 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/setFill.js +14 -8
- package/dist/interactions/actions/defaults/setFill.js.map +1 -1
- package/dist/interactions/actions/defaults/setFillOpacity.js +7 -4
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -1
- package/dist/interactions/actions/defaults/setStroke.js +12 -12
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
- package/dist/interactions/actions/defaults/sliceOps.js +8 -10
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -1
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
- package/dist/interactions/actions/distribute/action.js +66 -0
- package/dist/interactions/actions/distribute/action.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +11 -11
- package/dist/interactions/actions/distribute/distribute.js.map +1 -1
- package/dist/interactions/actions/{defaults/editAnchors.js → edit-anchors/action.js} +7 -9
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +30 -27
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +124 -0
- package/dist/interactions/actions/flip/action.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +30 -17
- package/dist/interactions/actions/flip/helpers.js.map +1 -1
- package/dist/interactions/actions/gestureFrames.js +18 -0
- package/dist/interactions/actions/gestureFrames.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +47 -20
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
- package/dist/interactions/actions/hitSelection.js +8 -0
- package/dist/interactions/actions/hitSelection.js.map +1 -0
- package/dist/interactions/actions/insert/action.js +72 -0
- package/dist/interactions/actions/insert/action.js.map +1 -0
- package/dist/interactions/actions/insert/commit.js +28 -0
- package/dist/interactions/actions/insert/commit.js.map +1 -0
- package/dist/interactions/actions/insert/extras.js +65 -0
- package/dist/interactions/actions/insert/extras.js.map +1 -0
- package/dist/interactions/actions/insert/frame.js +48 -0
- package/dist/interactions/actions/insert/frame.js.map +1 -0
- package/dist/interactions/actions/insert/geometry.js +35 -0
- package/dist/interactions/actions/insert/geometry.js.map +1 -0
- package/dist/interactions/actions/insert/rotateAction.js +21 -0
- package/dist/interactions/actions/insert/rotateAction.js.map +1 -0
- package/dist/interactions/actions/insert/session.js +59 -0
- package/dist/interactions/actions/insert/session.js.map +1 -0
- package/dist/interactions/actions/insert/shape.js +34 -0
- package/dist/interactions/actions/insert/shape.js.map +1 -0
- package/dist/interactions/actions/lasso-select/action.js +143 -0
- package/dist/interactions/actions/lasso-select/action.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
- package/dist/interactions/actions/move/action.js +87 -0
- package/dist/interactions/actions/move/action.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/layoutDrop.js +51 -0
- package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js +15 -0
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +39 -27
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/capture.js +99 -0
- package/dist/interactions/actions/move/capture.js.map +1 -0
- package/dist/interactions/actions/move/commit/index.js +41 -0
- package/dist/interactions/actions/move/commit/index.js.map +1 -0
- package/dist/interactions/actions/move/commit/layoutDrop.js +44 -0
- package/dist/interactions/actions/move/commit/layoutDrop.js.map +1 -0
- package/dist/interactions/actions/move/commit/layoutRelease.js +100 -0
- package/dist/interactions/actions/move/commit/layoutRelease.js.map +1 -0
- package/dist/interactions/actions/move/commit/rebase.js +18 -0
- package/dist/interactions/actions/move/commit/rebase.js.map +1 -0
- package/dist/interactions/actions/move/commit/reparent.js +65 -0
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -0
- package/dist/interactions/actions/move/delta.js +51 -0
- package/dist/interactions/actions/move/delta.js.map +1 -0
- package/dist/interactions/actions/move/frame.js +59 -0
- package/dist/interactions/actions/move/frame.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +22 -30
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
- package/dist/interactions/actions/move/landedDescendants.js +33 -0
- package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
- package/dist/interactions/actions/move/layout/container.js +94 -0
- package/dist/interactions/actions/move/layout/container.js.map +1 -0
- package/dist/interactions/actions/move/layout/dragged.js +58 -0
- package/dist/interactions/actions/move/layout/dragged.js.map +1 -0
- package/dist/interactions/actions/move/layout/dropPass.js +122 -0
- package/dist/interactions/actions/move/layout/dropPass.js.map +1 -0
- package/dist/interactions/actions/move/layout/exits.js +38 -0
- package/dist/interactions/actions/move/layout/exits.js.map +1 -0
- package/dist/interactions/actions/move/layout/glide.js +48 -0
- package/dist/interactions/actions/move/layout/glide.js.map +1 -0
- package/dist/interactions/actions/move/session.js +63 -0
- package/dist/interactions/actions/move/session.js.map +1 -0
- package/dist/interactions/actions/move/translate.js +61 -0
- package/dist/interactions/actions/move/translate.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +16 -63
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlinesAction.js +51 -0
- package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -0
- package/dist/interactions/actions/outlines/outlineStroke.js +72 -0
- package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -0
- package/dist/interactions/actions/outlines/outlineStrokeAction.js +37 -0
- package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -0
- package/dist/interactions/actions/outlines/replaceWithPaths.js +54 -0
- package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -0
- package/dist/interactions/actions/outlines/strokeRegion.js +27 -0
- package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -0
- package/dist/interactions/actions/planeInput.js.map +1 -1
- package/dist/interactions/actions/pointerState.js +12 -0
- package/dist/interactions/actions/pointerState.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +16 -4
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
- package/dist/interactions/actions/poseFrame.js +25 -20
- package/dist/interactions/actions/poseFrame.js.map +1 -1
- package/dist/interactions/actions/resize/action.js +55 -0
- package/dist/interactions/actions/resize/action.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -1
- package/dist/interactions/actions/resize/boxFrame.js +16 -0
- package/dist/interactions/actions/resize/boxFrame.js.map +1 -0
- package/dist/interactions/actions/resize/capture.js +85 -0
- package/dist/interactions/actions/resize/capture.js.map +1 -0
- package/dist/interactions/actions/resize/commit.js +69 -0
- package/dist/interactions/actions/resize/commit.js.map +1 -0
- package/dist/interactions/actions/resize/frame.js +74 -0
- package/dist/interactions/actions/resize/frame.js.map +1 -0
- package/dist/interactions/actions/resize/pointSnap.js +111 -0
- package/dist/interactions/actions/resize/pointSnap.js.map +1 -0
- package/dist/interactions/actions/resize/ruleBounds.js +9 -0
- package/dist/interactions/actions/resize/ruleBounds.js.map +1 -0
- package/dist/interactions/actions/resize/session.js +49 -0
- package/dist/interactions/actions/resize/session.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -1
- package/dist/interactions/actions/resolvePreviews.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +56 -0
- package/dist/interactions/actions/rotate/action.js.map +1 -0
- package/dist/interactions/actions/rotate/behaviors/index.js +7 -0
- package/dist/interactions/actions/rotate/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/rotate/behaviors/snapRotation.js +12 -0
- package/dist/interactions/actions/rotate/behaviors/snapRotation.js.map +1 -0
- package/dist/interactions/actions/rotate/commit.js +40 -0
- package/dist/interactions/actions/rotate/commit.js.map +1 -0
- package/dist/interactions/actions/rotate/frame.js +65 -0
- package/dist/interactions/actions/rotate/frame.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +12 -12
- package/dist/interactions/actions/rotate/handle.js.map +1 -1
- package/dist/interactions/actions/rotate/session.js +92 -0
- package/dist/interactions/actions/rotate/session.js.map +1 -0
- package/dist/interactions/actions/selectionSubtree.js +69 -0
- package/dist/interactions/actions/selectionSubtree.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -1
- package/dist/interactions/actions/useStandardActions.js +87 -78
- package/dist/interactions/actions/useStandardActions.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
- package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +62 -41
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
- package/dist/interactions/gestures/shared/originProjection.js +1 -1
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -1
- package/dist/interactions/gestures/shared/screenTolerance.js +8 -2
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
- package/dist/interactions/gestures/shared/snap.js.map +1 -1
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
- package/dist/layout/arrivals.js +20 -23
- package/dist/layout/arrivals.js.map +1 -1
- package/dist/math-CYUjoyyU.d.ts +33 -0
- package/dist/math.d.ts +5 -3
- package/dist/math.js +6 -6
- package/dist/mesh.d.ts +4 -268
- package/dist/mesh.js +3 -7
- package/dist/move.d.ts +14 -11
- package/dist/{originProjection-DEklpDc_.d.ts → originProjection-PPT88jZv.d.ts} +1 -1
- package/dist/patterns-builtin.d.ts +1 -118
- package/dist/patterns-builtin.js +2 -3
- package/dist/{poseDescriptor-D-OH-tu5.d.ts → poseDescriptor-Bqk-11Rl.d.ts} +26 -36
- package/dist/renderer.d.ts +1 -91
- package/dist/renderer.js +2 -18
- package/dist/resize.d.ts +10 -22
- package/dist/resize.js +6 -6
- package/dist/style.css +1 -1
- package/dist/test-hook/install.js +12 -6
- package/dist/test-hook/install.js.map +1 -1
- package/dist/test-hook/useTestHook.js +22 -0
- package/dist/test-hook/useTestHook.js.map +1 -0
- package/dist/test-seams-D0pyV3pR.d.ts +149 -0
- package/dist/test-seams.d.ts +4 -4
- package/dist/test-seams.js +2 -2
- package/dist/tools/builtin/bone/boneActions.js +130 -0
- package/dist/tools/builtin/bone/boneActions.js.map +1 -0
- package/dist/tools/builtin/bone/boneOverlay.js +58 -0
- package/dist/tools/builtin/bone/boneOverlay.js.map +1 -0
- package/dist/tools/builtin/bone/placedRig.js +24 -0
- package/dist/tools/builtin/bone/placedRig.js.map +1 -0
- package/dist/tools/builtin/bone/rigEditState.js +21 -0
- package/dist/tools/builtin/bone/rigEditState.js.map +1 -0
- package/dist/tools/builtin/bone/useBoneTool.js +98 -0
- package/dist/tools/builtin/bone/useBoneTool.js.map +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/hand/useHandTool.js +1 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
- package/dist/tools/builtin/image/useImageTool.js.map +1 -1
- package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +1 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +198 -150
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +36 -0
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +25 -24
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +42 -67
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/shared/pointerFollower.js +17 -0
- package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +72 -82
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +22 -16
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +9 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/tools/builtin/weight/useWeightTool.js +77 -0
- package/dist/tools/builtin/weight/useWeightTool.js.map +1 -0
- package/dist/tools/builtin/weight/weightActions.js +112 -0
- package/dist/tools/builtin/weight/weightActions.js.map +1 -0
- package/dist/tools/builtin/weight/weightOverlay.js +61 -0
- package/dist/tools/builtin/weight/weightOverlay.js.map +1 -0
- package/dist/tools/overlayBinding.js.map +1 -1
- package/dist/tools/useKeybindings.js +12 -22
- package/dist/tools/useKeybindings.js.map +1 -1
- package/dist/{types-A37hYkeR.d.ts → types-CIKDwlsP.d.ts} +113 -169
- package/dist/util/color.js +3 -3
- package/dist/util/color.js.map +1 -1
- package/dist/util/paint.js +1 -1
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +28 -21
- package/dist/animation/colorHelpers.js +0 -135
- package/dist/animation/colorHelpers.js.map +0 -1
- package/dist/animation/colorRegistry.js +0 -37
- package/dist/animation/colorRegistry.js.map +0 -1
- package/dist/animation/engine/axes.js +0 -36
- package/dist/animation/engine/axes.js.map +0 -1
- package/dist/animation/engine/codec.js +0 -170
- package/dist/animation/engine/codec.js.map +0 -1
- package/dist/animation/engine/integrator.js +0 -12
- package/dist/animation/engine/integrator.js.map +0 -1
- package/dist/animation/loop.js +0 -62
- package/dist/animation/loop.js.map +0 -1
- package/dist/animation/observe.js +0 -23
- package/dist/animation/observe.js.map +0 -1
- package/dist/animation/rig/blendPoses.js +0 -43
- package/dist/animation/rig/blendPoses.js.map +0 -1
- package/dist/animation/rig/mirrorPose.js +0 -19
- package/dist/animation/rig/mirrorPose.js.map +0 -1
- package/dist/animation/rig/resolveSkeleton.js +0 -33
- package/dist/animation/rig/resolveSkeleton.js.map +0 -1
- package/dist/animation/rig/solveIk.js +0 -103
- package/dist/animation/rig/solveIk.js.map +0 -1
- package/dist/animation/rig/types.js +0 -12
- package/dist/animation/rig/types.js.map +0 -1
- package/dist/animation/slew.js +0 -27
- package/dist/animation/slew.js.map +0 -1
- package/dist/animation/stagger.js +0 -138
- package/dist/animation/stagger.js.map +0 -1
- package/dist/animation/timeline/booking.js +0 -106
- package/dist/animation/timeline/booking.js.map +0 -1
- package/dist/animation/timeline/createTimeline.js +0 -116
- package/dist/animation/timeline/createTimeline.js.map +0 -1
- package/dist/animation/timeline/sampleTrack.js +0 -71
- package/dist/animation/timeline/sampleTrack.js.map +0 -1
- package/dist/animation/useAnimator.js +0 -378
- package/dist/animation/useAnimator.js.map +0 -1
- package/dist/builtins-C-VgUlWI.d.ts +0 -4514
- package/dist/canvas/MinimapCanvas.js +0 -139
- package/dist/canvas/MinimapCanvas.js.map +0 -1
- package/dist/canvas/deps/poseComposition.js +0 -11
- package/dist/canvas/deps/poseComposition.js.map +0 -1
- package/dist/canvas/minimapMath.js +0 -80
- package/dist/canvas/minimapMath.js.map +0 -1
- package/dist/canvas/toolPreview.js +0 -39
- package/dist/canvas/toolPreview.js.map +0 -1
- package/dist/core/adapters/arrayAdapter.js +0 -85
- package/dist/core/adapters/arrayAdapter.js.map +0 -1
- package/dist/core/adapters/useArrayAdapter.js +0 -13
- package/dist/core/adapters/useArrayAdapter.js.map +0 -1
- package/dist/core/fillInPoseFrame.js +0 -102
- package/dist/core/fillInPoseFrame.js.map +0 -1
- package/dist/core/geometry/poseRotation.js +0 -58
- package/dist/core/geometry/poseRotation.js.map +0 -1
- package/dist/core/gradient.js +0 -136
- package/dist/core/gradient.js.map +0 -1
- package/dist/core/isPlainObject.js.map +0 -1
- package/dist/core/markerInset.js +0 -24
- package/dist/core/markerInset.js.map +0 -1
- package/dist/core/mixed.js +0 -6
- package/dist/core/mixed.js.map +0 -1
- package/dist/core/paintKinds.js +0 -156
- package/dist/core/paintKinds.js.map +0 -1
- package/dist/core/strokeMarkerShapes.js +0 -139
- package/dist/core/strokeMarkerShapes.js.map +0 -1
- package/dist/core/strokeMarkers.js +0 -28
- package/dist/core/strokeMarkers.js.map +0 -1
- package/dist/core/viewport/meanScale.js +0 -8
- package/dist/core/viewport/meanScale.js.map +0 -1
- package/dist/core/viewport/pxExtent.js +0 -42
- package/dist/core/viewport/pxExtent.js.map +0 -1
- package/dist/debug/flag.js.map +0 -1
- package/dist/features/cursor/paintedCursorLayer.js.map +0 -1
- package/dist/features/focus/gateLayer.js +0 -14
- package/dist/features/focus/gateLayer.js.map +0 -1
- package/dist/features/focus/useCanvasFocus.js +0 -29
- package/dist/features/focus/useCanvasFocus.js.map +0 -1
- package/dist/features/groups/children.js.map +0 -1
- package/dist/features/groups/composePose.js.map +0 -1
- package/dist/features/groups/nestedHit.js.map +0 -1
- package/dist/features/groups/unionOfChildren.js.map +0 -1
- package/dist/features/images/imageCache.js +0 -94
- package/dist/features/images/imageCache.js.map +0 -1
- package/dist/features/ingestion/index.js +0 -8
- package/dist/features/meshPaint/bake.js +0 -79
- package/dist/features/meshPaint/bake.js.map +0 -1
- package/dist/features/meshPaint/bakeCache.js +0 -59
- package/dist/features/meshPaint/bakeCache.js.map +0 -1
- package/dist/features/meshPaint/handles.js +0 -86
- package/dist/features/meshPaint/handles.js.map +0 -1
- package/dist/features/meshPaint/lazyKind.js.map +0 -1
- package/dist/features/meshPaint/meshPaint.js +0 -236
- package/dist/features/meshPaint/meshPaint.js.map +0 -1
- package/dist/features/meshPaint/meshShader.js +0 -6
- package/dist/features/meshPaint/meshShader.js.map +0 -1
- package/dist/features/meshPaint/register.js +0 -7
- package/dist/features/meshPaint/register.js.map +0 -1
- package/dist/features/meshPaint/surface.js +0 -110
- package/dist/features/meshPaint/surface.js.map +0 -1
- package/dist/features/minimap/actions.js +0 -53
- package/dist/features/minimap/actions.js.map +0 -1
- package/dist/features/minimap/createMinimapContribution.js +0 -96
- package/dist/features/minimap/createMinimapContribution.js.map +0 -1
- package/dist/features/minimap/layers.js +0 -103
- package/dist/features/minimap/layers.js.map +0 -1
- package/dist/features/overlays/useNodeOverlayFrame.js +0 -103
- package/dist/features/overlays/useNodeOverlayFrame.js.map +0 -1
- package/dist/features/parallax/createParallaxLayer.js +0 -26
- package/dist/features/parallax/createParallaxLayer.js.map +0 -1
- package/dist/features/parallax/createParallaxPlane.js +0 -26
- package/dist/features/parallax/createParallaxPlane.js.map +0 -1
- package/dist/features/paths/anchorEdits.js +0 -156
- package/dist/features/paths/anchorEdits.js.map +0 -1
- package/dist/features/paths/anchors.js +0 -154
- package/dist/features/paths/anchors.js.map +0 -1
- package/dist/features/paths/booleans.js +0 -2
- package/dist/features/paths/markerCommands.js +0 -148
- package/dist/features/paths/markerCommands.js.map +0 -1
- package/dist/features/paths/markerSites.js +0 -59
- package/dist/features/paths/markerSites.js.map +0 -1
- package/dist/features/paths/markers.js +0 -95
- package/dist/features/paths/markers.js.map +0 -1
- package/dist/features/paths/nearestAnchor.js +0 -36
- package/dist/features/paths/nearestAnchor.js.map +0 -1
- package/dist/features/paths/pathInWorld.js +0 -41
- package/dist/features/paths/pathInWorld.js.map +0 -1
- package/dist/features/paths/poseDescriptor.js +0 -39
- package/dist/features/paths/poseDescriptor.js.map +0 -1
- package/dist/features/paths/tessellate/dash.js +0 -52
- package/dist/features/paths/tessellate/dash.js.map +0 -1
- package/dist/features/paths/tessellate/insets.js +0 -32
- package/dist/features/paths/tessellate/insets.js.map +0 -1
- package/dist/features/paths/tessellate/metric.js +0 -72
- package/dist/features/paths/tessellate/metric.js.map +0 -1
- package/dist/features/paths/tessellate/stroke.js +0 -170
- package/dist/features/paths/tessellate/stroke.js.map +0 -1
- package/dist/features/paths/tessellate/vertexWidths.js +0 -32
- package/dist/features/paths/tessellate/vertexWidths.js.map +0 -1
- package/dist/features/patterns/index.js +0 -23
- package/dist/features/patterns/index.js.map +0 -1
- package/dist/features/patterns/patterns-builtin.js +0 -38
- package/dist/features/patterns/patterns-builtin.js.map +0 -1
- package/dist/features/patterns/resolveSpec.js +0 -57
- package/dist/features/patterns/resolveSpec.js.map +0 -1
- package/dist/features/patterns/tileGeometry.js +0 -158
- package/dist/features/patterns/tileGeometry.js.map +0 -1
- package/dist/features/pointer/PointerContext.js +0 -45
- package/dist/features/pointer/PointerContext.js.map +0 -1
- package/dist/features/selection/SelectionContext.js +0 -46
- package/dist/features/selection/SelectionContext.js.map +0 -1
- package/dist/features/simulation/createSimulation.js +0 -61
- package/dist/features/simulation/createSimulation.js.map +0 -1
- package/dist/features/simulation/types.js +0 -6
- package/dist/features/simulation/types.js.map +0 -1
- package/dist/features/simulation/useSimulation.js +0 -74
- package/dist/features/simulation/useSimulation.js.map +0 -1
- package/dist/features/text/domRuns.js +0 -258
- package/dist/features/text/domRuns.js.map +0 -1
- package/dist/features/text/fitTextPose.js +0 -38
- package/dist/features/text/fitTextPose.js.map +0 -1
- package/dist/features/text/hitTest.js +0 -45
- package/dist/features/text/hitTest.js.map +0 -1
- package/dist/features/text/renderLabel.js +0 -14
- package/dist/features/text/renderLabel.js.map +0 -1
- package/dist/features/text/runs/effectiveRangeStyle.js +0 -66
- package/dist/features/text/runs/effectiveRangeStyle.js.map +0 -1
- package/dist/features/text/runs/flagRange.js +0 -53
- package/dist/features/text/runs/flagRange.js.map +0 -1
- package/dist/features/text/runs/rangeStyle.js +0 -135
- package/dist/features/text/runs/rangeStyle.js.map +0 -1
- package/dist/features/text/textCommand.js +0 -59
- package/dist/features/text/textCommand.js.map +0 -1
- package/dist/features/text/textToPath.js +0 -181
- package/dist/features/text/textToPath.js.map +0 -1
- package/dist/features/text/useTextEdit.js +0 -467
- package/dist/features/text/useTextEdit.js.map +0 -1
- package/dist/features/tiling/createTiledLayer.js +0 -63
- package/dist/features/tiling/createTiledLayer.js.map +0 -1
- package/dist/features/tiling/tiledProject.js +0 -14
- package/dist/features/tiling/tiledProject.js.map +0 -1
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +0 -26
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +0 -1
- package/dist/interactions/actions/defaults/align.js.map +0 -1
- package/dist/interactions/actions/defaults/booleans.js +0 -52
- package/dist/interactions/actions/defaults/booleans.js.map +0 -1
- package/dist/interactions/actions/defaults/clipboard.js.map +0 -1
- package/dist/interactions/actions/defaults/clone.js +0 -107
- package/dist/interactions/actions/defaults/clone.js.map +0 -1
- package/dist/interactions/actions/defaults/createOutlines.js +0 -47
- package/dist/interactions/actions/defaults/createOutlines.js.map +0 -1
- package/dist/interactions/actions/defaults/distribute.js +0 -66
- package/dist/interactions/actions/defaults/distribute.js.map +0 -1
- package/dist/interactions/actions/defaults/editAnchors.js.map +0 -1
- package/dist/interactions/actions/defaults/flip.js +0 -119
- package/dist/interactions/actions/defaults/flip.js.map +0 -1
- package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
- package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
- package/dist/interactions/actions/defaults/insert.js +0 -288
- package/dist/interactions/actions/defaults/insert.js.map +0 -1
- package/dist/interactions/actions/defaults/lassoSelect.js +0 -156
- package/dist/interactions/actions/defaults/lassoSelect.js.map +0 -1
- package/dist/interactions/actions/defaults/move.js +0 -760
- package/dist/interactions/actions/defaults/move.js.map +0 -1
- package/dist/interactions/actions/defaults/resize.js +0 -335
- package/dist/interactions/actions/defaults/resize.js.map +0 -1
- package/dist/interactions/actions/defaults/rotate.js +0 -184
- package/dist/interactions/actions/defaults/rotate.js.map +0 -1
- package/dist/interactions/actions/previewOverrides.js +0 -25
- package/dist/interactions/actions/previewOverrides.js.map +0 -1
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +0 -1
- package/dist/math-Drrw4ewZ.d.ts +0 -160
- package/dist/registerProgram-BMZRDgrh.d.ts +0 -197
- package/dist/renderer/DrawCommand.js +0 -6
- package/dist/renderer/DrawCommand.js.map +0 -1
- package/dist/renderer/WeaselRenderer.js +0 -331
- package/dist/renderer/WeaselRenderer.js.map +0 -1
- package/dist/renderer/batchClip.js +0 -46
- package/dist/renderer/batchClip.js.map +0 -1
- package/dist/renderer/cache/GLImageCache.js +0 -64
- package/dist/renderer/cache/GLImageCache.js.map +0 -1
- package/dist/renderer/cache/GLMeshCache.js +0 -102
- package/dist/renderer/cache/GLMeshCache.js.map +0 -1
- package/dist/renderer/cache/GLTextureCache.js +0 -51
- package/dist/renderer/cache/GLTextureCache.js.map +0 -1
- package/dist/renderer/cache/GradientRampAtlas.js +0 -82
- package/dist/renderer/cache/GradientRampAtlas.js.map +0 -1
- package/dist/renderer/cache/cache.js +0 -13
- package/dist/renderer/cache/cache.js.map +0 -1
- package/dist/renderer/cache/markerCommandCache.js +0 -63
- package/dist/renderer/cache/markerCommandCache.js.map +0 -1
- package/dist/renderer/cache/outlineMeshCache.js +0 -15
- package/dist/renderer/cache/outlineMeshCache.js.map +0 -1
- package/dist/renderer/cache/outlineStrokeMeshCache.js +0 -36
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +0 -1
- package/dist/renderer/cache/strokeMeshCache.js +0 -55
- package/dist/renderer/cache/strokeMeshCache.js.map +0 -1
- package/dist/renderer/cullDrawCommands.js +0 -90
- package/dist/renderer/cullDrawCommands.js.map +0 -1
- package/dist/renderer/draw.js +0 -1135
- package/dist/renderer/draw.js.map +0 -1
- package/dist/renderer/drawBatch.js +0 -198
- package/dist/renderer/drawBatch.js.map +0 -1
- package/dist/renderer/effects/EffectTargets.js +0 -45
- package/dist/renderer/effects/EffectTargets.js.map +0 -1
- package/dist/renderer/effects/builtins.js +0 -31
- package/dist/renderer/effects/builtins.js.map +0 -1
- package/dist/renderer/effects/composite.js +0 -9
- package/dist/renderer/effects/composite.js.map +0 -1
- package/dist/renderer/effects/effectPrelude.js +0 -10
- package/dist/renderer/effects/effectPrelude.js.map +0 -1
- package/dist/renderer/effects/types.js +0 -10
- package/dist/renderer/effects/types.js.map +0 -1
- package/dist/renderer/glyphOutlineMesh.js +0 -67
- package/dist/renderer/glyphOutlineMesh.js.map +0 -1
- package/dist/renderer/index.js +0 -19
- package/dist/renderer/math/color.js +0 -341
- package/dist/renderer/math/color.js.map +0 -1
- package/dist/renderer/math/mat3.js +0 -76
- package/dist/renderer/math/mat3.js.map +0 -1
- package/dist/renderer/math/patternSpace.js +0 -22
- package/dist/renderer/math/patternSpace.js.map +0 -1
- package/dist/renderer/math/viewToMat3.js +0 -19
- package/dist/renderer/math/viewToMat3.js.map +0 -1
- package/dist/renderer/paintResources.js +0 -18
- package/dist/renderer/paintResources.js.map +0 -1
- package/dist/renderer/paintScratch.js +0 -37
- package/dist/renderer/paintScratch.js.map +0 -1
- package/dist/renderer/shaders/ShaderProgram.js +0 -74
- package/dist/renderer/shaders/ShaderProgram.js.map +0 -1
- package/dist/renderer/shaders/batchFill.js +0 -119
- package/dist/renderer/shaders/batchFill.js.map +0 -1
- package/dist/renderer/shaders/customPrelude.js +0 -34
- package/dist/renderer/shaders/customPrelude.js.map +0 -1
- package/dist/renderer/shaders/extractUniformNames.js +0 -184
- package/dist/renderer/shaders/extractUniformNames.js.map +0 -1
- package/dist/renderer/shaders/glyphPaint.js +0 -61
- package/dist/renderer/shaders/glyphPaint.js.map +0 -1
- package/dist/renderer/shaders/gradFill.js +0 -30
- package/dist/renderer/shaders/gradFill.js.map +0 -1
- package/dist/renderer/shaders/imageFill.js +0 -14
- package/dist/renderer/shaders/imageFill.js.map +0 -1
- package/dist/renderer/shaders/pathFill.js +0 -13
- package/dist/renderer/shaders/pathFill.js.map +0 -1
- package/dist/renderer/shaders/patternFill.js +0 -24
- package/dist/renderer/shaders/patternFill.js.map +0 -1
- package/dist/renderer/shaders/registerProgram.js +0 -18
- package/dist/renderer/shaders/registerProgram.js.map +0 -1
- package/dist/renderer/spriteSheet.js +0 -14
- package/dist/renderer/spriteSheet.js.map +0 -1
- package/dist/renderer/state/GroupState.js +0 -77
- package/dist/renderer/state/GroupState.js.map +0 -1
- package/dist/renderer/strokeLengths.js +0 -50
- package/dist/renderer/strokeLengths.js.map +0 -1
- package/dist/renderer/syntheticItalic.js +0 -6
- package/dist/renderer/syntheticItalic.js.map +0 -1
- package/dist/renderer/textures/registerTexture.js +0 -14
- package/dist/renderer/textures/registerTexture.js.map +0 -1
- package/dist/scheduling/useVisibleRaf.js +0 -69
- package/dist/scheduling/useVisibleRaf.js.map +0 -1
- package/dist/test-seams-CuIxe0xY.d.ts +0 -356
- package/dist/tools/prefs.js +0 -62
- package/dist/tools/prefs.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePenTool.js","names":["p","PenIcon","freshScratch","resetScratch","anchorCount","s","n","sp","buildPath","all","subpaths","trailing","anchorsToPath","usePenTool","options","scratchRef","useRef","optsRef","useLatest","forceRender","useReducer","x","commitContinuation","useCallback","cont","drawn","edit","added","addedClosed","pathToAnchors","reverseAnchors","set","next","samePath","commit","deps","allClosed","path","pose","id","joinable","hit","scene","commitJoin","current","other","otherSet","tail","joined","joint","out","sameNode","rest","i","label","ops","keptId","node","createInsertOp","createDeleteOp","applyOps","defaultCommitAdapter","pickUpEndpoint","scratch","radius","scale","viewScale","nearestPathAnchor","pathsNear","wx","wy","h","original","picked","reversed","snap","fn","placeAt","y","withinCloseRadius","withinPxRadius","ax","ay","actions","useMemo","p","params","first","join","ActionDisabledReason","origin","ctx","pickedUp","joinHit","linked","applyOutHandle","sm","moveCtx","se","reason","endCtx","defineTool","cursorFor","createElement","anchor","to","target","dx","dy","shift","c","constrainTo45","area","view","e","pxExtent","px","ids","a","b"],"sources":["../../../../src/tools/builtin/pen/usePenTool.ts"],"sourcesContent":["import { useCallback, useMemo, useReducer, useRef, createElement } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { defineTool } from '../../overlayBinding';\nimport type { Tool } from '../../overlayBinding';\nimport type { ToolPrefGroup } from '../../prefs';\nimport type { Action } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport type { ActionDeps, InvocationCtx } from '@weasel-js/routing';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport { pxExtent, withinPxRadius } from 'core/viewport/pxExtent';\nimport { PenIcon } from '../../../icons';\nimport type { PolygonPath } from '@weasel-js/geom';\nimport { anchorsToPath, pathToAnchors } from 'features/paths/anchors';\nimport { nearestPathAnchor, reverseAnchors, type PathAnchorHit } from 'features/paths/nearestAnchor';\nimport type { Op } from 'core/ops/types';\nimport { createInsertOp } from 'core/ops/create';\nimport { createDeleteOp } from 'core/ops/delete';\nimport { defaultCommitAdapter } from 'interactions/actions/defaultCommitAdapter';\nimport { constrainTo45 } from '../../../util/constrainTo45';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/**\n * In-progress pen anchor. A click places a corner, with no handles. A drag\n * sets `outHandle` to the drag point and `inHandle` to its mirror through\n * the anchor, which shapes the segment coming into it.\n */\nexport interface PenAnchor {\n x: number;\n y: number;\n outHandle?: { x: number; y: number };\n inHandle?: { x: number; y: number };\n /** True once Alt is held during the placement drag: from then on the\n * in-handle stays where it is, and an anchor dragged with Alt down from\n * the start gets none. */\n altBroken?: boolean;\n}\n\n/** One in-progress subpath of the pen tool: its anchors so far, and whether\n * the user has closed it. */\nexport interface PenSubpath {\n anchors: PenAnchor[]; // LOCAL PenAnchor — in-progress\n closed: boolean;\n}\n\n/**\n * Mutable scratch shared across pen-tool gestures. The hook keeps a stable\n * reference to a single instance and `initScratch` returns it on every call,\n * so click-by-click state survives gesture boundaries and the preview layer\n * can read the same object.\n *\n * ## The pen draws paths; it does not reshape them\n *\n * It draws new nodes, and extends an existing node's open subpath from one\n * of its ends (see `continuing`). Reshaping an existing path is anchor\n * editing: double-click a path to\n * enter edit mode, then use the `editAnchors` / `insertPathAnchor` /\n * `nudgeAnchors` / `deleteAnchors` / `marqueeAnchors` / `cutPathAtAnchor`\n * Actions.\n *\n * The pen used to carry a second, private implementation of all of that,\n * with its own scratch mode, hit-test override, overlay, and undo\n * plumbing. It was reachable only through a `getPathObj` option whose\n * contract required `pose.kind` to be `'polygon'` or `'rect'` — which no\n * kit-created node has, including the ones the pen itself creates. So it\n * was dead in every consumer while shadowing the live implementation, and\n * the two had drifted. Its geometry now lives in\n * `features/paths/anchorEdits.ts`, driven by those Actions.\n */\nexport interface PenScratch {\n finishedSubpaths: PenSubpath[];\n current: PenSubpath | null;\n cursor: { x: number; y: number } | null;\n draggingHandleAt: number | null;\n closeHintActive: boolean;\n /** Set while the pen is extending an existing node's open subpath rather\n * than drawing a new node. `current` then starts as that subpath (turned\n * around when it was picked up by its first anchor), and the commit\n * writes back into the node. */\n continuing: PenContinuation | null;\n}\n\n/** Which existing subpath the pen picked up, and the node's path as it was. */\nexport interface PenContinuation {\n id: string;\n /** Index of the picked-up subpath within `original`. */\n sub: number;\n /** True when it was picked up by its first anchor, so `current` runs\n * backwards and is turned around again on commit. */\n reversed: boolean;\n /** The node's path in world coords at pick-up. */\n original: PolygonPath;\n}\n\n/** Options for `usePenTool`: how a finished path becomes a pose, where it is\n * inserted, and when a closed subpath commits. */\nexport interface UsePenToolOptions<TPose> {\n /** Wrap a finished PolygonPath in the consumer's pose type. */\n wrapPath: (path: PolygonPath, opts: { closed: boolean }) => TPose;\n /** Insert + select adapter. */\n adapter: {\n addNode: (pose: TPose) => string;\n setSelection: (ids: string[]) => void;\n /** Build, without inserting, the node `addNode` would insert for `pose`,\n * so the pen can put it in a larger op batch — a new path finished on\n * another open path's endpoint is inserted and the other path deleted\n * in one undo step. Without it, that click only places an anchor. */\n makeNode?: (pose: TPose) => { id: string };\n };\n /** Auto-select the new object after commit. Default `true`. */\n autoSelect?: boolean;\n /** When true (default), clicking the first anchor to close a subpath\n * commits immediately — the closed region renders with its fill right\n * away. When false, the closed subpath stays in scratch so the user can\n * start another subpath; commit then fires on Enter / tool-switch /\n * ⌘-click / double-click, producing a compound path. */\n autoCommitOnClose?: boolean;\n /** Screen-px hit radius for \"click first anchor to close\". Default `8`.\n * Measured as a screen-space circle, so it stays round under non-uniform\n * zoom; aligns with `useSelectTool.handleHitRadius`. */\n closeHitRadius?: number;\n /** Screen-px radius within which a placed anchor lands exactly on an\n * existing path's anchor. Default `8`; `0` turns it off. Takes precedence\n * over `snapPoint`, which applies only when no anchor is in range. */\n anchorSnapRadius?: number;\n /** Optional point snapper applied to every world-space coordinate the\n * pen records or previews — anchor positions (corner clicks, smooth-\n * drag base point), the rubber-band cursor, and the outgoing-handle\n * target. Receives raw world coords; returns snapped world coords.\n * Wire to `gridSnapStrategy`-style spacing via the consumer:\n *\n * snapPoint: (p) => ({\n * x: Math.round(p.x / SPACING) * SPACING,\n * y: Math.round(p.y / SPACING) * SPACING,\n * })\n *\n * Pen state (anchor handles, etc.) is computed AFTER snapping so the\n * visible geometry stays grid-aligned. */\n snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };\n}\n\nfunction freshScratch(): PenScratch {\n return {\n finishedSubpaths: [],\n current: null,\n cursor: null,\n draggingHandleAt: null,\n closeHintActive: false,\n continuing: null,\n };\n}\n\nfunction resetScratch(s: PenScratch): void {\n s.finishedSubpaths = [];\n s.current = null;\n s.cursor = null;\n s.draggingHandleAt = null;\n s.closeHintActive = false;\n s.continuing = null;\n}\n\n/** Total anchors across finished subpaths plus the in-progress one. */\nfunction anchorCount(s: PenScratch): number {\n return (s.current ? s.current.anchors.length : 0)\n + s.finishedSubpaths.reduce((n, sp) => n + sp.anchors.length, 0);\n}\n\n/** Build a PolygonPath from the pen's accumulated subpaths, by the same\n * rule as any anchor set: segment A→B is a cubic through A's out-handle and\n * B's in-handle when either exists, else a line. */\nfunction buildPath(\n subpaths: PenSubpath[],\n trailing: PenSubpath | null,\n): PolygonPath {\n const all = [...subpaths];\n if (trailing && trailing.anchors.length > 0) all.push(trailing);\n return anchorsToPath(all.map((sp) => sp.anchors), all.map((sp) => sp.closed));\n}\n\n/**\n * Active-slot Tool: click + drag to build a `PolygonPath` Illustrator-style.\n *\n * State machine: Idle / Drawing / BetweenSubpaths (see design doc).\n * Click places a corner anchor; click-drag places an anchor with an\n * outgoing bezier handle; click-the-first-anchor closes the subpath; Enter\n * open-finishes; Esc discards; tool-switch commits if ≥2 anchors else\n * discards. Shift constrains the placement-drag handle to 0/45/90/135°;\n * Alt during drag breaks the handle mirror for the next segment.\n *\n * Reshaping an existing path is not this tool's job — see {@link PenScratch}.\n */\nexport function usePenTool<TPose>(\n options: UsePenToolOptions<TPose>,\n): Tool<PenScratch> {\n const { wrapPath, adapter, autoSelect = true, autoCommitOnClose = true, closeHitRadius = 8, anchorSnapRadius = 8, snapPoint } = options;\n\n // Persistent scratch: single ref reused across gestures so multi-click\n // state survives the dispatcher's per-gesture initScratch contract.\n const scratchRef = useRef<PenScratch | null>(null);\n if (scratchRef.current === null) scratchRef.current = freshScratch();\n\n // Latest options stashed so handlers see fresh values without rebuilding\n // the Tool record (which would lose scratch identity in the dispatcher).\n const optsRef = useLatest({ wrapPath, adapter, autoSelect, autoCommitOnClose, closeHitRadius, anchorSnapRadius, snapPoint });\n\n // Scratch is a mutable ref (so click-by-click state survives the\n // dispatcher's per-gesture initScratch contract). Mutations alone don't\n // trigger React re-renders, so Canvas never re-paints and the preview\n // layer stays invisible until something else (e.g. commit) bumps host\n // state. Force a render after every scratch mutation so the host's\n // <Canvas layers={{...}}> literal gets a new identity and the paint\n // useEffect fires. Pull the trigger via ref so the memoized Tool record\n // doesn't need to rebuild.\n const [, forceRender] = useReducer((x: number) => x + 1, 0);\n\n // Geometry helpers shared by the actions below. They read `optsRef` so a\n // re-render with new options is visible without rebuilding the actions\n // (which would lose the scratch identity `penPreviewLayer` reads through\n // `Tool.initScratch`).\n\n /** Write the pen's subpaths back into the node it picked up: the first\n * replaces the subpath it continued, any later ones are appended. Skips\n * the write when nothing changed, so an empty pick-up leaves no undo\n * entry. */\n const commitContinuation = useCallback(\n (s: PenScratch, trailing: PenSubpath | null, edit: EditAnchorsDep | undefined): void => {\n const cont = s.continuing!;\n const drawn = [...s.finishedSubpaths, ...(trailing ? [trailing] : [])];\n if (!edit || drawn.length === 0) return;\n const { anchors: added, closed: addedClosed } = pathToAnchors(buildPath(drawn, null));\n if (cont.reversed) added[0] = reverseAnchors(added[0]);\n const set = pathToAnchors(cont.original);\n set.anchors.splice(cont.sub, 1, added[0]);\n set.closed.splice(cont.sub, 1, addedClosed[0]);\n set.anchors.push(...added.slice(1));\n set.closed.push(...addedClosed.slice(1));\n const next: PolygonPath = { ...anchorsToPath(set.anchors, set.closed), fillRule: cont.original.fillRule };\n if (samePath(next, cont.original)) return;\n edit.applyEdit(cont.id, next, 'Continue path');\n if (optsRef.current.autoSelect) optsRef.current.adapter.setSelection([cont.id]);\n },\n [optsRef],\n );\n\n const commit = useCallback((s: PenScratch, deps: ActionDeps): void => {\n const trailing = s.current && s.current.anchors.length > 0 ? s.current : null;\n if (s.continuing) {\n commitContinuation(s, trailing, deps.editAnchors);\n resetScratch(s);\n return;\n }\n if (s.finishedSubpaths.length === 0 && !trailing) return;\n const allClosed =\n s.finishedSubpaths.every((sp) => sp.closed) &&\n (trailing === null || trailing.closed);\n const path = buildPath(s.finishedSubpaths, trailing);\n const pose = optsRef.current.wrapPath(path, { closed: allClosed });\n const id = optsRef.current.adapter.addNode(pose);\n if (optsRef.current.autoSelect) optsRef.current.adapter.setSelection([id]);\n resetScratch(s);\n }, [commitContinuation, optsRef]);\n\n /** Whether an anchor about to land on `hit` finishes the path by joining\n * onto another open subpath. Its own continued subpath never counts —\n * reaching that one's far end is a close. Declines when the deps can't\n * commit the join as one op batch. */\n const joinable = useCallback((s: PenScratch, deps: ActionDeps, hit: PathAnchorHit | null): hit is PathAnchorHit => {\n if (!hit || hit.end === null || !s.current || s.current.anchors.length === 0) return false;\n const cont = s.continuing;\n if (cont && hit.id === cont.id && hit.sub === cont.sub) return false;\n const scene = deps.scene;\n if (!scene && !deps.applyOps) return false;\n if (!(cont ? deps.editAnchors?.editOps : optsRef.current.adapter.makeNode)) return false;\n return cont?.id === hit.id || scene?.get(hit.id as never) !== undefined;\n }, [optsRef]);\n\n /** Finish the path onto `hit`, the endpoint its last anchor was just placed\n * on: the other subpath's anchors follow on from it, turned around when\n * `hit` is its last anchor, and its node is deleted. The path being drawn\n * keeps its identity — a continued node keeps its id and style, and a new\n * path is minted the way any pen path is. One op batch, so one undo. */\n const commitJoin = useCallback((s: PenScratch, deps: ActionDeps, hit: PathAnchorHit): void => {\n const edit = deps.editAnchors!;\n const scene = deps.scene;\n const current = s.current!;\n const { anchors: added, closed: addedClosed } = pathToAnchors(buildPath([...s.finishedSubpaths, current], null));\n\n const other = edit.getEditablePath(hit.id) as PolygonPath;\n const otherSet = pathToAnchors(other);\n const tail = hit.end === 'last' ? reverseAnchors(otherSet.anchors[hit.sub]) : otherSet.anchors[hit.sub];\n const joined = added[added.length - 1];\n const joint = joined[joined.length - 1];\n const out = current.anchors[current.anchors.length - 1].outHandle ?? tail[0].outHandle;\n if (out) joint.outHandle = { ...out };\n joined.push(...tail.slice(1));\n\n const cont = s.continuing;\n const sameNode = cont?.id === hit.id;\n const rest = sameNode ? { anchors: [], closed: [] } : {\n anchors: otherSet.anchors.filter((_, i) => i !== hit.sub),\n closed: otherSet.closed.filter((_, i) => i !== hit.sub),\n };\n const label = 'Join paths';\n const ops: Op[] = [];\n let keptId: string;\n if (cont) {\n if (cont.reversed) added[0] = reverseAnchors(added[0]);\n const set = pathToAnchors(cont.original);\n set.anchors.splice(cont.sub, 1, added[0]);\n set.closed.splice(cont.sub, 1, addedClosed[0]);\n set.anchors.push(...added.slice(1), ...rest.anchors);\n set.closed.push(...addedClosed.slice(1), ...rest.closed);\n if (sameNode) {\n set.anchors.splice(hit.sub, 1);\n set.closed.splice(hit.sub, 1);\n }\n const next: PolygonPath = { ...anchorsToPath(set.anchors, set.closed), fillRule: cont.original.fillRule };\n ops.push(...edit.editOps!(cont.id, next, label));\n keptId = cont.id;\n } else {\n const path = anchorsToPath([...added, ...rest.anchors], [...addedClosed, ...rest.closed]);\n const node = optsRef.current.adapter.makeNode!(optsRef.current.wrapPath(path, { closed: false }));\n ops.push(createInsertOp({ node }));\n keptId = node.id;\n }\n if (!sameNode) ops.push(createDeleteOp({ node: scene!.get(hit.id as never) as { id: string } }));\n\n const applyOps = deps.applyOps;\n if (applyOps) applyOps(ops, label);\n else scene!.applyBatch(ops, label, defaultCommitAdapter(scene!));\n if (optsRef.current.autoSelect) optsRef.current.adapter.setSelection([keptId]);\n resetScratch(s);\n }, [optsRef]);\n\n /** From idle, a press on an open subpath's end anchor picks that subpath\n * up: it becomes `current`, turned so the pressed end is last. Returns\n * whether it did. */\n const pickUpEndpoint = useCallback((deps: ActionDeps, wx: number, wy: number): boolean => {\n const scratch = scratchRef.current!;\n if (scratch.current || scratch.finishedSubpaths.length > 0) return false;\n const radius = optsRef.current.closeHitRadius;\n const scale = viewScale(deps);\n const hit = nearestPathAnchor(pathsNear(deps, wx, wy, radius), { x: wx, y: wy }, radius, scale, (h) => h.end !== null);\n if (!hit) return false;\n const original = deps.editAnchors!.getEditablePath(hit.id) as PolygonPath;\n const picked = pathToAnchors(original).anchors[hit.sub];\n const reversed = hit.end === 'first' && picked.length > 1;\n scratch.current = { anchors: reversed ? reverseAnchors(picked) : picked, closed: false };\n scratch.continuing = { id: hit.id, sub: hit.sub, reversed, original };\n return true;\n }, [optsRef]);\n\n const snap = useCallback((x: number, y: number): { x: number; y: number } => {\n const fn = optsRef.current.snapPoint;\n return fn ? fn({ x, y }) : { x, y };\n }, [optsRef]);\n\n /** Where an anchor pressed at `(x, y)` lands: on an existing path's anchor\n * when one is within `anchorSnapRadius`, else wherever `snapPoint` puts it.\n * `hit` names the anchor it snapped to. */\n const placeAt = useCallback((deps: ActionDeps, x: number, y: number): { x: number; y: number; hit: PathAnchorHit | null } => {\n const radius = optsRef.current.anchorSnapRadius;\n if (radius > 0) {\n const hit = nearestPathAnchor(pathsNear(deps, x, y, radius), { x, y }, radius, viewScale(deps));\n if (hit) return { x: hit.x, y: hit.y, hit };\n }\n return { ...snap(x, y), hit: null };\n }, [snap, optsRef]);\n\n /** Is a world point within the close-hit radius of `(ax, ay)`? Measured as a\n * screen-space circle, so the zone stays round under non-uniform zoom. */\n const withinCloseRadius = useCallback(\n (deps: ActionDeps, ax: number, ay: number, wx: number, wy: number): boolean => {\n return withinPxRadius(ax - wx, ay - wy, optsRef.current.closeHitRadius, viewScale(deps));\n },\n [optsRef],\n );\n\n /**\n * Actions the pen owns, registered by `useToolActions` from inside the\n * ActionsProvider — see `ToolDef.actions`.\n *\n * They close over `scratchRef`, which is why the pen needs no `Selector`\n * exposing tool scratch to the action layer: the state never leaves the\n * hook. `useMemo([])` keeps their identity stable for the same reason\n * `scratchRef` is a ref — the preview layer reads that one object.\n */\n const actions = useMemo<Action[]>(() => {\n const s = () => scratchRef.current!;\n\n return [\n {\n id: 'pen.placeAnchor',\n label: 'Pen — place anchor',\n eligible: { capability: 'creates-paths' },\n requires: ['view', 'areaSelect', 'editAnchors', 'scene', 'applyOps'],\n invoker: {\n timing: 'immediate' as const,\n run: (deps, params) => {\n const p = params as { pressX?: number; pressY?: number } | undefined;\n if (p?.pressX === undefined || p.pressY === undefined) return;\n // The press point, not the release: a click may drift up to the\n // drag threshold, and an anchor should land where you put the\n // pointer down. Snapping happens here rather than at press time\n // so the snapped value is what the geometry records.\n if (pickUpEndpoint(deps, p.pressX, p.pressY)) {\n forceRender();\n return;\n }\n const { x: wx, y: wy, hit } = placeAt(deps, p.pressX, p.pressY);\n const scratch = s();\n\n // Close-on-first-anchor (>= 3 anchors). With `autoCommitOnClose`\n // on (default) this commits right away so the closed region\n // renders with its fill — Illustrator-style. With it off the\n // closed subpath stays in scratch for compound-path builds and\n // commits on Enter / tool switch.\n if (scratch.current && scratch.current.anchors.length >= 3) {\n const first = scratch.current.anchors[0];\n if (withinCloseRadius(deps, first.x, first.y, wx, wy)) {\n scratch.current.closed = true;\n scratch.finishedSubpaths.push(scratch.current);\n scratch.current = null;\n scratch.closeHintActive = false;\n if (optsRef.current.autoCommitOnClose) commit(scratch, deps);\n forceRender();\n return;\n }\n }\n\n const join = joinable(scratch, deps, hit);\n // Otherwise: append a corner anchor, starting a subpath if needed.\n if (!scratch.current) scratch.current = { anchors: [], closed: false };\n scratch.current.anchors.push({ x: wx, y: wy });\n if (join) commitJoin(scratch, deps, hit);\n forceRender();\n },\n },\n },\n\n {\n id: 'pen.finishOpen',\n label: 'Pen — finish open path',\n eligible: { capability: 'creates-paths' },\n requires: ['editAnchors'],\n // Needs an actual path to commit. Declining also lets the gesture\n // fall through: a ⌘-click with fewer than two anchors reaches the\n // plain-click binding and places an anchor instead.\n enabled: () => (anchorCount(s()) >= 2 ? true : ActionDisabledReason.NotApplicable),\n invoker: {\n timing: 'immediate' as const,\n run: (deps, params) => {\n const scratch = s();\n const p = params as { viaDoubleClick?: boolean } | undefined;\n\n // A double click arrives AFTER both of its clicks, so the second\n // one has already appended an anchor. Undo exactly that before\n // committing: pop it, and drop the subpath entirely if it was the\n // only anchor in it (which happens when the FIRST click closed a\n // subpath and the second started a fresh one). The net effect\n // matches the pen's old private 300ms detector — one anchor\n // placed, path finished — while using the dispatcher's single\n // definition of a double click.\n //\n // No position check is needed: the anchor to drop is by\n // construction the one the second click just appended.\n if (p?.viaDoubleClick && scratch.current) {\n scratch.current.anchors.pop();\n if (scratch.current.anchors.length === 0) scratch.current = null;\n }\n\n commit(scratch, deps);\n forceRender();\n },\n },\n },\n\n {\n id: 'pen.dragHandle',\n label: 'Pen — drag out a bezier handle',\n eligible: { capability: 'creates-paths' },\n requires: ['view', 'areaSelect', 'editAnchors', 'scene', 'applyOps'],\n invoker: {\n timing: 'ongoing' as const,\n start: (ctx: InvocationCtx) => {\n const scratch = s();\n // `drag.start` is the pointerdown position — the dispatcher\n // buffers the press and releases it at the drag threshold, so the\n // anchor lands where the user pressed rather than where the\n // threshold happened to be crossed.\n const origin = ctx.drag?.start ?? ctx.world;\n // Dragging from an open path's end picks the path up and pulls\n // that end's own handle rather than placing a new anchor on it.\n const pickedUp = pickUpEndpoint(ctx.deps, origin.x, origin.y);\n // Dragging on another open path's endpoint joins onto it once\n // the handle is set.\n let joinHit: PathAnchorHit | null = null;\n if (!pickedUp) {\n const { x: ax, y: ay, hit } = placeAt(ctx.deps, origin.x, origin.y);\n if (joinable(scratch, ctx.deps, hit)) joinHit = hit;\n if (!scratch.current) scratch.current = { anchors: [], closed: false };\n scratch.current.anchors.push({ x: ax, y: ay });\n }\n scratch.draggingHandleAt = scratch.current!.anchors.length - 1;\n if (ctx.modifiers.alt) {\n scratch.current!.anchors[scratch.draggingHandleAt].altBroken = true;\n }\n // A picked-up endpoint's in-handle belongs to the existing\n // segment into it, which the pen does not reshape.\n const linked = !pickedUp;\n applyOutHandle(scratch, ctx.world, ctx.modifiers.shift, linked, optsRef.current.snapPoint);\n forceRender();\n\n return {\n onMove: (moveCtx: InvocationCtx) => {\n const sm = s();\n if (sm.draggingHandleAt === null) return;\n if (moveCtx.modifiers.alt && sm.current) {\n sm.current.anchors[sm.draggingHandleAt].altBroken = true;\n }\n applyOutHandle(sm, moveCtx.world, moveCtx.modifiers.shift, linked, optsRef.current.snapPoint);\n forceRender();\n },\n onEnd: (endCtx: InvocationCtx, reason: 'commit' | 'cancel') => {\n const se = s();\n if (reason === 'cancel') {\n // `start` appended the anchor (or picked a path up); a\n // cancel (pointercancel is the reachable one — Escape and a\n // tool switch both reset the whole scratch first) has to\n // take it back out.\n if (pickedUp) {\n resetScratch(se);\n } else if (se.current && se.draggingHandleAt === se.current.anchors.length - 1) {\n se.current.anchors.pop();\n if (se.current.anchors.length === 0) se.current = null;\n }\n se.draggingHandleAt = null;\n forceRender();\n return;\n }\n if (se.draggingHandleAt !== null) {\n if (endCtx.modifiers.alt && se.current) {\n se.current.anchors[se.draggingHandleAt].altBroken = true;\n }\n applyOutHandle(se, endCtx.world, endCtx.modifiers.shift, linked, optsRef.current.snapPoint);\n se.draggingHandleAt = null;\n }\n if (joinHit && se.current) commitJoin(se, ctx.deps, joinHit);\n forceRender();\n },\n };\n },\n },\n },\n\n {\n id: 'pen.finish',\n label: 'Pen — finish path',\n eligible: { capability: 'creates-paths' },\n requires: ['editAnchors'],\n enabled: () => (anchorCount(s()) > 0 ? true : ActionDisabledReason.NotApplicable),\n invoker: {\n timing: 'immediate' as const,\n run: (deps) => {\n commit(s(), deps);\n forceRender();\n },\n },\n },\n\n {\n id: 'pen.cancel',\n label: 'Pen — discard path',\n eligible: { capability: 'creates-paths' },\n // Declining with nothing drawn is what keeps Escape's first-match\n // ladder intact: an empty pen passes the key to `escape`, which goes\n // on to clear the selection / return to the default tool.\n enabled: () => {\n const scratch = s();\n return scratch.current !== null || scratch.finishedSubpaths.length > 0\n ? true\n : ActionDisabledReason.NotApplicable;\n },\n invoker: {\n timing: 'immediate' as const,\n run: () => {\n resetScratch(s());\n forceRender();\n },\n },\n },\n ];\n }, [commit, placeAt, withinCloseRadius, pickUpEndpoint, joinable, commitJoin, optsRef]);\n\n return useMemo(() => {\n return defineTool<PenScratch>({\n id: 'pen',\n capabilities: ['creates-paths'],\n hookName: 'usePenTool',\n // Reads the tool's own ref rather than a scratch handed in by a\n // dispatcher — the pen owns this state and nothing else needs it.\n cursor: () =>\n scratchRef.current?.closeHintActive\n ? 'pointer'\n : cursorFor('pen', { fallback: 'crosshair' }),\n presentation: {\n label: 'Pen',\n icon: createElement(PenIcon),\n group: 'draw',\n },\n // Persistent-ref scratch. `penPreviewLayer` reads the in-progress path\n // by calling `Tool.initScratch()` and getting this same object back, so\n // the identity is load-bearing.\n initScratch: () => scratchRef.current!,\n actions,\n\n onDeactivate: () => {\n // Anything still in scratch is by definition incomplete — the user\n // hasn't closed it (close-on-first-anchor), open-finished it\n // (cmd-click), or pressed Enter. Switching tools mid-path should\n // discard, not auto-commit a stub polyline that the user didn't\n // ask for. Mirrors Escape's behavior so \"stop drawing\" is\n // consistent across exits.\n resetScratch(scratchRef.current!);\n forceRender();\n },\n\n bindings: [\n // Plain click places an anchor; ⌘/Ctrl-click open-finishes\n // (Illustrator). Strict modifier matching keeps the two apart, and\n // `mod` resolves to meta on mac / ctrl elsewhere — the tool-route\n // grammar's modifier matcher accepted either key on either platform.\n { spec: { kind: 'click' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.placeAnchor' },\n { spec: { kind: 'click' as const, mods: { mod: true, shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.finishOpen' },\n // Double-click on the last anchor also open-finishes. This used to be\n // a private 300ms/radius check inside the click route — a fourth\n // double-click detector in a codebase that had just collapsed three\n // into one (audit 3.3).\n {\n spec: { kind: 'doubleClick' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } },\n actionId: 'pen.finishOpen',\n opts: { params: { viaDoubleClick: true } },\n },\n { spec: { kind: 'drag' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.dragHandle' },\n { spec: { kind: 'key' as const, key: 'Enter' }, actionId: 'pen.finish' },\n { spec: { kind: 'key' as const, key: 'Escape' }, actionId: 'pen.cancel' },\n ],\n });\n }, [actions]);\n}\n\nusePenTool.prefs = {\n name: 'Pen',\n description: 'Pen-tool behavior.',\n children: {\n autoCommitOnClose: {\n kind: 'boolean',\n name: 'Auto-commit pen on close',\n description: \"When you click the pen tool's first anchor to close a region, commit immediately so it renders with its fill. Off: keep the path in preview until you press Enter (lets you build a compound path from multiple closed subpaths).\",\n default: true,\n },\n },\n} satisfies ToolPrefGroup;\n\n/** Point the anchor's outgoing handle at `target`, optionally snapped and\n * optionally constrained to 45° steps. When `linked` and not Alt-broken,\n * the in-handle follows as its mirror through the anchor. */\nfunction applyOutHandle<S extends PenScratch>(\n s: S,\n target: { x: number; y: number },\n shift: boolean,\n linked: boolean,\n snap?: (p: { x: number; y: number }) => { x: number; y: number },\n): void {\n if (s.current === null || s.draggingHandleAt === null) return;\n const anchor = s.current.anchors[s.draggingHandleAt];\n const to = snap ? snap(target) : target;\n let dx = to.x - anchor.x;\n let dy = to.y - anchor.y;\n if (shift) {\n const c = constrainTo45(dx, dy);\n dx = c.dx;\n dy = c.dy;\n }\n anchor.outHandle = { x: anchor.x + dx, y: anchor.y + dy };\n if (linked && !anchor.altBroken) anchor.inHandle = { x: anchor.x - dx, y: anchor.y - dy };\n}\n\nfunction viewScale(deps: ActionDeps): { x: number; y: number } {\n return deps.view?.get().scale ?? { x: 1, y: 1 };\n}\n\n/** Existing editable paths, world coords, with ink within `px` screen\n * pixels of `(wx, wy)` — front-to-back, as the area query returns them.\n * Empty when the host publishes no `areaSelect` or `editAnchors` dep. */\nfunction pathsNear(\n deps: ActionDeps,\n wx: number,\n wy: number,\n px: number,\n): Array<{ id: string; path: PolygonPath }> {\n const area = deps.areaSelect;\n const edit = deps.editAnchors;\n if (!area || !edit) return [];\n const view = deps.view;\n const e = pxExtent(px, viewScale(deps));\n const ids = area.hitTestArea({ x: wx - e.x, y: wy - e.y, width: 2 * e.x, height: 2 * e.y }, view);\n const out: Array<{ id: string; path: PolygonPath }> = [];\n for (const id of ids) {\n const path = edit.getEditablePath(id) as PolygonPath | null;\n if (path?.kind === 'polygon') out.push({ id, path });\n }\n return out;\n}\n\nfunction samePath(a: PolygonPath, b: PolygonPath): boolean {\n if (a.commands.length !== b.commands.length || a.coords.length !== b.coords.length) return false;\n for (let i = 0; i < a.commands.length; i++) if (a.commands[i] !== b.commands[i]) return false;\n for (let i = 0; i < a.coords.length; i++) if (a.coords[i] !== b.coords[i]) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4IA,SAASE,IAA2B;CAClC,OAAO;EACL,kBAAkB,CAAC;EACnB,SAAS;EACT,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;EACjB,YAAY;CACd;AACF;AAEA,SAASC,EAAa,GAAqB;CAMzC,AALA,EAAE,mBAAmB,CAAC,GACtB,EAAE,UAAU,MACZ,EAAE,SAAS,MACX,EAAE,mBAAmB,MACrB,EAAE,kBAAkB,IACpB,EAAE,aAAa;AACjB;AAGA,SAASC,EAAY,GAAuB;CAC1C,QAAQC,EAAE,UAAUA,EAAE,QAAQ,QAAQ,SAAS,KAC3CA,EAAE,iBAAiB,QAAQ,GAAG,MAAOC,IAAIC,EAAG,QAAQ,QAAQ,CAAC;AACnE;AAKA,SAASC,EACP,GACA,GACa;CACb,IAAMC,IAAM,CAAC,GAAGC,CAAQ;CAExB,OADIC,KAAYA,EAAS,QAAQ,SAAS,KAAGF,EAAI,KAAKE,CAAQ,GACvDC,EAAcH,EAAI,KAAK,MAAOF,EAAG,OAAO,GAAGE,EAAI,KAAK,MAAOF,EAAG,MAAM,CAAC;AAC9E;AAcA,SAAgBM,EACd,GACkB;CAClB,IAAM,EAAE,aAAU,YAAS,gBAAa,IAAM,uBAAoB,IAAM,oBAAiB,GAAG,sBAAmB,GAAG,iBAAcC,GAI1HC,IAAaC,EAA0B,IAAI;CACjD,AAAID,EAAW,YAAY,SAAM,EAAW,UAAUb,EAAa;CAInE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IAAOX,EAAK,gBAAgBa,CAAE;EACpC,AAAIF,GAAM,SAAS,aAAWa,EAAI,KAAK;GAAE;GAAI;EAAK,CAAC;CACrD;CACA,OAAOA;AACT;AAEA,SAASjB,EAAS,GAAgB,GAAyB;CACzD,IAAIqF,EAAE,SAAS,WAAWC,EAAE,SAAS,UAAUD,EAAE,OAAO,WAAWC,EAAE,OAAO,QAAQ,OAAO;CAC3F,KAAK,IAAIlE,IAAI,GAAGA,IAAIiE,EAAE,SAAS,QAAQ,KAAK,IAAIA,EAAE,SAASjE,OAAOkE,EAAE,SAASlE,IAAI,OAAO;CACxF,KAAK,IAAIA,IAAI,GAAGA,IAAIiE,EAAE,OAAO,QAAQ,KAAK,IAAIA,EAAE,OAAOjE,OAAOkE,EAAE,OAAOlE,IAAI,OAAO;CAClF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"usePenTool.js","names":["p","PenIcon","freshScratch","resetScratch","anchorCount","s","n","sp","buildPath","all","subpaths","trailing","anchorsToPath","usePenTool","options","scratchRef","useRef","optsRef","useLatest","forceRender","useReducer","x","overlay","useState","createPenPreviewLayer","commitContinuation","useCallback","edit","deps","cont","drawn","added","addedClosed","pathToAnchors","reverseAnchors","set","next","samePath","asNodeId","commit","open","allClosed","path","id","boundsOfPath","joinable","hit","scene","commitJoin","current","other","otherSet","tail","joined","joint","out","sameNode","rest","i","label","ops","keptId","built","createDeleteOp","applyOps","defaultCommitAdapter","pickUpEndpoint","scratch","radius","scale","viewScale","nearestPathAnchor","pathsNear","wx","wy","h","original","picked","reversed","snap","fn","placeAt","y","withinCloseRadius","withinPxRadius","ax","ay","trail","useMemo","view","follower","createPointerFollower","track","at","first","actions","p","params","join","ActionDisabledReason","origin","ctx","pickedUp","joinHit","linked","applyOutHandle","sm","moveCtx","se","reason","endCtx","defineTool","cursorFor","createElement","anchor","to","target","dx","dy","shift","c","constrainTo45","area","e","pxExtent","px","ids","a","b"],"sources":["../../../../src/tools/builtin/pen/usePenTool.ts"],"sourcesContent":["import { useCallback, useMemo, useReducer, useRef, useState, createElement } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { PrefGroup } from '@weasel-js/prefs';\nimport { defineTool } from '../../overlayBinding';\nimport type { Tool } from '../../overlayBinding';\nimport type { Action } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport type { ActionDeps, InvocationCtx } from '@weasel-js/routing';\nimport { asNodeId } from 'core/scene/types';\nimport { pxExtent, withinPxRadius, nearestPathAnchor, reverseAnchors, type PathAnchorHit } from '@weasel-js/geom';\nimport { PenIcon } from '../../../icons';\nimport { boundsOfPath, type PolygonPath, anchorsToPath, pathToAnchors } from '@weasel-js/geom';\nimport { createPenPreviewLayer } from 'features/paths/penPreviewLayer';\nimport type { Op } from 'core/ops/types';\nimport { createDeleteOp } from 'core/ops/delete';\nimport { defaultCommitAdapter } from 'interactions/actions/defaultCommitAdapter';\nimport { constrainTo45 } from '../../../util/constrainTo45';\nimport { cursorFor } from '@weasel-js/cursor';\nimport { createPointerFollower } from '../shared/pointerFollower';\n\n/**\n * In-progress pen anchor. A click places a corner, with no handles. A drag\n * sets `outHandle` to the drag point and `inHandle` to its mirror through\n * the anchor, which shapes the segment coming into it.\n */\nexport interface PenAnchor {\n x: number;\n y: number;\n outHandle?: { x: number; y: number };\n inHandle?: { x: number; y: number };\n /** True once Alt is held during the placement drag: from then on the\n * in-handle stays where it is, and an anchor dragged with Alt down from\n * the start gets none. */\n altBroken?: boolean;\n}\n\n/** One in-progress subpath of the pen tool: its anchors so far, and whether\n * the user has closed it. */\nexport interface PenSubpath {\n anchors: PenAnchor[]; // LOCAL PenAnchor — in-progress\n closed: boolean;\n}\n\n/**\n * Mutable state shared across pen-tool gestures. The hook keeps a single\n * instance for its life and changes it in place, so click-by-click state\n * survives gesture boundaries and the tool's preview overlay reads the same\n * object.\n *\n * The pen draws new nodes, and extends an existing node's open subpath from\n * one of its ends (see `continuing`). Reshaping an existing path is anchor\n * editing: double-click a path to enter edit mode.\n */\nexport interface PenScratch {\n finishedSubpaths: PenSubpath[];\n current: PenSubpath | null;\n cursor: { x: number; y: number } | null;\n draggingHandleAt: number | null;\n closeHintActive: boolean;\n /** Set while the pen is extending an existing node's open subpath rather\n * than drawing a new node. `current` then starts as that subpath (turned\n * around when it was picked up by its first anchor), and the commit\n * writes back into the node. */\n continuing: PenContinuation | null;\n}\n\n/** Which existing subpath the pen picked up, and the node's path as it was. */\nexport interface PenContinuation {\n id: string;\n /** Index of the picked-up subpath within `original`. */\n sub: number;\n /** True when it was picked up by its first anchor, so `current` runs\n * backwards and is turned around again on commit. */\n reversed: boolean;\n /** The node's path in world coords at pick-up. */\n original: PolygonPath;\n}\n\n/** Options for `usePenTool`: when a closed subpath commits, and how anchors\n * snap. A finished path is inserted through the `insert` dep as kind\n * `'path'`, the route every shape tool takes, so a consumer shapes the node\n * by overriding that dep. */\nexport interface UsePenToolOptions {\n /** Auto-select the new object after commit. Default `true`. */\n autoSelect?: boolean;\n /** When true (default), clicking the first anchor to close a subpath\n * commits immediately — the closed region renders with its fill right\n * away. When false, the closed subpath stays in scratch so the user can\n * start another subpath; commit then fires on Enter / ⌘-click /\n * double-click, producing a compound path. Switching tools first discards\n * it, as Escape does. */\n autoCommitOnClose?: boolean;\n /** Screen-px hit radius for \"click first anchor to close\". Default `8`.\n * Measured as a screen-space circle, so it stays round under non-uniform\n * zoom; aligns with `useSelectTool.handleHitRadius`. */\n closeHitRadius?: number;\n /** Screen-px radius within which a placed anchor lands exactly on an\n * existing path's anchor. Default `8`; `0` turns it off. Takes precedence\n * over `snapPoint`, which applies only when no anchor is in range. */\n anchorSnapRadius?: number;\n /** Optional point snapper applied to every world-space coordinate the\n * pen records or previews — anchor positions (corner clicks, smooth-\n * drag base point), the rubber-band cursor, and the outgoing-handle\n * target. Receives raw world coords; returns snapped world coords.\n * Pen state (anchor handles, etc.) is computed AFTER snapping so the\n * visible geometry stays grid-aligned. */\n snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };\n}\n\nfunction freshScratch(): PenScratch {\n return {\n finishedSubpaths: [],\n current: null,\n cursor: null,\n draggingHandleAt: null,\n closeHintActive: false,\n continuing: null,\n };\n}\n\nfunction resetScratch(s: PenScratch): void {\n s.finishedSubpaths = [];\n s.current = null;\n s.cursor = null;\n s.draggingHandleAt = null;\n s.closeHintActive = false;\n s.continuing = null;\n}\n\n/** Total anchors across finished subpaths plus the in-progress one. */\nfunction anchorCount(s: PenScratch): number {\n return (s.current ? s.current.anchors.length : 0)\n + s.finishedSubpaths.reduce((n, sp) => n + sp.anchors.length, 0);\n}\n\n/** Build a PolygonPath from the pen's accumulated subpaths, by the same\n * rule as any anchor set: segment A→B is a cubic through A's out-handle and\n * B's in-handle when either exists, else a line. */\nfunction buildPath(\n subpaths: PenSubpath[],\n trailing: PenSubpath | null,\n): PolygonPath {\n const all = [...subpaths];\n if (trailing && trailing.anchors.length > 0) all.push(trailing);\n return anchorsToPath(all.map((sp) => sp.anchors), all.map((sp) => sp.closed));\n}\n\n/**\n * Active-slot Tool: click + drag to build a `PolygonPath` Illustrator-style.\n *\n * Click places a corner anchor; click-drag places an anchor with an\n * outgoing bezier handle; click-the-first-anchor closes the subpath; Enter\n * open-finishes; Esc discards, and so does a tool switch. Shift constrains the placement-drag handle to 0/45/90/135°;\n * Alt during drag breaks the handle mirror for the next segment.\n *\n * Reshaping an existing path is not this tool's job — see {@link PenScratch}.\n */\nexport function usePenTool(\n options: UsePenToolOptions = {},\n): Tool {\n const { autoSelect = true, autoCommitOnClose = true, closeHitRadius = 8, anchorSnapRadius = 8, snapPoint } = options;\n\n const scratchRef = useRef<PenScratch | null>(null);\n if (scratchRef.current === null) scratchRef.current = freshScratch();\n\n // Latest options stashed so handlers see fresh values without rebuilding\n // the Tool record.\n const optsRef = useLatest({ autoSelect, autoCommitOnClose, closeHitRadius, anchorSnapRadius, snapPoint });\n\n // Scratch mutations alone don't trigger React re-renders, so the preview\n // layer would not repaint. Force a render after every scratch mutation.\n const [, forceRender] = useReducer((x: number) => x + 1, 0);\n const [overlay] = useState(() => createPenPreviewLayer({ state: scratchRef.current! }));\n\n /** Write the pen's subpaths back into the node it picked up: the first\n * replaces the subpath it continued, any later ones are appended. Skips\n * the write when nothing changed, so an empty pick-up leaves no undo\n * entry. */\n const commitContinuation = useCallback(\n (s: PenScratch, trailing: PenSubpath | null, deps: ActionDeps): void => {\n const edit = deps.editAnchors;\n const cont = s.continuing!;\n const drawn = [...s.finishedSubpaths, ...(trailing ? [trailing] : [])];\n if (!edit || drawn.length === 0) return;\n const { anchors: added, closed: addedClosed } = pathToAnchors(buildPath(drawn, null));\n if (cont.reversed) added[0] = reverseAnchors(added[0]);\n const set = pathToAnchors(cont.original);\n set.anchors.splice(cont.sub, 1, added[0]);\n set.closed.splice(cont.sub, 1, addedClosed[0]);\n set.anchors.push(...added.slice(1));\n set.closed.push(...addedClosed.slice(1));\n const next = anchorsToPath(set.anchors, set.closed, cont.original);\n if (samePath(next, cont.original)) return;\n edit.applyEdit(cont.id, next, 'Continue path');\n if (optsRef.current.autoSelect) deps.selection?.set([asNodeId(cont.id)]);\n },\n [optsRef],\n );\n\n const commit = useCallback((s: PenScratch, deps: ActionDeps): void => {\n const trailing = s.current && s.current.anchors.length > 0 ? s.current : null;\n if (s.continuing) {\n commitContinuation(s, trailing, deps);\n resetScratch(s);\n return;\n }\n // One anchor draws nothing; committing it would leave an invisible node.\n const open = trailing && trailing.anchors.length >= 2 ? trailing : null;\n if (s.finishedSubpaths.length === 0 && !open) {\n resetScratch(s);\n return;\n }\n const allClosed =\n s.finishedSubpaths.every((sp) => sp.closed) &&\n (open === null || open.closed);\n const path = buildPath(s.finishedSubpaths, open);\n const id = deps.insert?.commit(boundsOfPath(path), { kind: 'path', path, closed: allClosed }) ?? null;\n if (id !== null && optsRef.current.autoSelect) deps.selection?.set([id]);\n resetScratch(s);\n }, [commitContinuation, optsRef]);\n\n /** Whether an anchor about to land on `hit` finishes the path by joining\n * onto another open subpath. Its own continued subpath never counts —\n * reaching that one's far end is a close. Declines when the deps can't\n * commit the join as one op batch. */\n const joinable = useCallback((s: PenScratch, deps: ActionDeps, hit: PathAnchorHit | null): hit is PathAnchorHit => {\n if (!hit || hit.end === null || !s.current || s.current.anchors.length === 0) return false;\n const cont = s.continuing;\n if (cont && hit.id === cont.id && hit.sub === cont.sub) return false;\n const scene = deps.scene;\n if (!scene && !deps.applyOps) return false;\n if (!(cont ? deps.editAnchors?.editOps : deps.insert?.build)) return false;\n return cont?.id === hit.id || scene?.get(hit.id as never) !== undefined;\n }, []);\n\n /** Finish the path onto `hit`, the endpoint its last anchor was just placed\n * on: the other subpath's anchors follow on from it, turned around when\n * `hit` is its last anchor, and its node is deleted. The path being drawn\n * keeps its identity — a continued node keeps its id and style, and a new\n * path is minted the way any pen path is. One op batch, so one undo. */\n const commitJoin = useCallback((s: PenScratch, deps: ActionDeps, hit: PathAnchorHit): void => {\n const edit = deps.editAnchors!;\n const scene = deps.scene;\n const current = s.current!;\n const { anchors: added, closed: addedClosed } = pathToAnchors(buildPath([...s.finishedSubpaths, current], null));\n\n const other = edit.getEditablePath(hit.id) as PolygonPath;\n const otherSet = pathToAnchors(other);\n const tail = hit.end === 'last' ? reverseAnchors(otherSet.anchors[hit.sub]) : otherSet.anchors[hit.sub];\n const joined = added[added.length - 1];\n const joint = joined[joined.length - 1];\n const out = current.anchors[current.anchors.length - 1].outHandle ?? tail[0].outHandle;\n if (out) joint.outHandle = { ...out };\n joined.push(...tail.slice(1));\n\n const cont = s.continuing;\n const sameNode = cont?.id === hit.id;\n const rest = sameNode ? { anchors: [], closed: [] } : {\n anchors: otherSet.anchors.filter((_, i) => i !== hit.sub),\n closed: otherSet.closed.filter((_, i) => i !== hit.sub),\n };\n const label = 'Join paths';\n const ops: Op[] = [];\n let keptId: string;\n if (cont) {\n if (cont.reversed) added[0] = reverseAnchors(added[0]);\n const set = pathToAnchors(cont.original);\n set.anchors.splice(cont.sub, 1, added[0]);\n set.closed.splice(cont.sub, 1, addedClosed[0]);\n set.anchors.push(...added.slice(1), ...rest.anchors);\n set.closed.push(...addedClosed.slice(1), ...rest.closed);\n if (sameNode) {\n set.anchors.splice(hit.sub, 1);\n set.closed.splice(hit.sub, 1);\n }\n const next = anchorsToPath(set.anchors, set.closed, cont.original);\n ops.push(...edit.editOps!(cont.id, next, label));\n keptId = cont.id;\n } else {\n const path = anchorsToPath([...added, ...rest.anchors], [...addedClosed, ...rest.closed]);\n const built = deps.insert!.build!(boundsOfPath(path), { kind: 'path', path, closed: false });\n if (built === null) return;\n ops.push(...built.ops);\n keptId = built.id;\n }\n if (!sameNode) ops.push(createDeleteOp({ node: scene!.get(hit.id as never) as { id: string } }));\n\n const applyOps = deps.applyOps;\n if (applyOps) applyOps(ops, label);\n else scene!.applyBatch(ops, label, defaultCommitAdapter(scene!));\n if (optsRef.current.autoSelect) deps.selection?.set([asNodeId(keptId)]);\n resetScratch(s);\n }, [optsRef]);\n\n /** From idle, a press on an open subpath's end anchor picks that subpath\n * up: it becomes `current`, turned so the pressed end is last. Returns\n * whether it did. */\n const pickUpEndpoint = useCallback((deps: ActionDeps, wx: number, wy: number): boolean => {\n const scratch = scratchRef.current!;\n if (scratch.current || scratch.finishedSubpaths.length > 0) return false;\n const radius = optsRef.current.closeHitRadius;\n const scale = viewScale(deps);\n const hit = nearestPathAnchor(pathsNear(deps, wx, wy, radius), { x: wx, y: wy }, radius, scale, (h) => h.end !== null);\n if (!hit) return false;\n const original = deps.editAnchors!.getEditablePath(hit.id) as PolygonPath;\n const picked = pathToAnchors(original).anchors[hit.sub];\n const reversed = hit.end === 'first' && picked.length > 1;\n scratch.current = { anchors: reversed ? reverseAnchors(picked) : picked, closed: false };\n scratch.continuing = { id: hit.id, sub: hit.sub, reversed, original };\n return true;\n }, [optsRef]);\n\n const snap = useCallback((x: number, y: number): { x: number; y: number } => {\n const fn = optsRef.current.snapPoint;\n return fn ? fn({ x, y }) : { x, y };\n }, [optsRef]);\n\n /** Where an anchor pressed at `(x, y)` lands: on an existing path's anchor\n * when one is within `anchorSnapRadius`, else wherever `snapPoint` puts it.\n * `hit` names the anchor it snapped to. */\n const placeAt = useCallback((deps: ActionDeps, x: number, y: number): { x: number; y: number; hit: PathAnchorHit | null } => {\n const radius = optsRef.current.anchorSnapRadius;\n if (radius > 0) {\n const hit = nearestPathAnchor(pathsNear(deps, x, y, radius), { x, y }, radius, viewScale(deps));\n if (hit) return { x: hit.x, y: hit.y, hit };\n }\n return { ...snap(x, y), hit: null };\n }, [snap, optsRef]);\n\n /** Is a world point within the close-hit radius of `(ax, ay)`? Measured as a\n * screen-space circle, so the zone stays round under non-uniform zoom. */\n const withinCloseRadius = useCallback(\n (deps: ActionDeps, ax: number, ay: number, wx: number, wy: number): boolean => {\n return withinPxRadius(ax - wx, ay - wy, optsRef.current.closeHitRadius, viewScale(deps));\n },\n [optsRef],\n );\n\n // The rubber band and the close hint trail the `pointer` dep while a path is\n // in progress. `view` is the camera of the deps last followed through.\n const trail = useMemo(() => {\n let view: ActionDeps['view'];\n const follower = createPointerFollower(() => track());\n const track = (): void => {\n const s = scratchRef.current!;\n if (!s.current && s.finishedSubpaths.length === 0) follower.unfollow();\n const at = s.current ? follower.pointer()?.get() ?? null : null;\n s.cursor = at ? snap(at.worldX, at.worldY) : null;\n const first = s.current && s.current.anchors.length >= 3 ? s.current.anchors[0] : null;\n s.closeHintActive = first !== null && s.cursor !== null && withinPxRadius(\n first.x - s.cursor.x, first.y - s.cursor.y,\n optsRef.current.closeHitRadius, view?.get().scale ?? { x: 1, y: 1 },\n );\n forceRender();\n };\n return {\n /** Repaint after a scratch change. */\n refresh: track,\n /** The same, following `deps`' pointer from here on. */\n update(deps: ActionDeps): void {\n view = deps.view;\n follower.follow(deps.pointer);\n track();\n },\n stop(): void {\n follower.unfollow();\n forceRender();\n },\n };\n }, [snap, optsRef]);\n\n /**\n * Actions the pen owns, registered by `useToolActions` from inside the\n * ActionsProvider — see `ToolDef.actions`. They close over `scratchRef`,\n * so the state never leaves the hook.\n */\n const actions = useMemo<Action[]>(() => {\n const s = () => scratchRef.current!;\n\n return [\n {\n id: 'pen.placeAnchor',\n label: 'Pen — place anchor',\n eligible: { capability: 'creates-paths' },\n requires: ['view', 'pointer', 'areaSelect', 'editAnchors', 'scene', 'applyOps', 'insert', 'selection'],\n invoker: {\n timing: 'immediate' as const,\n run: (deps, params) => {\n const p = params as { pressX?: number; pressY?: number } | undefined;\n if (p?.pressX === undefined || p.pressY === undefined) return;\n // The press point, not the release: a click may drift up to the\n // drag threshold.\n if (pickUpEndpoint(deps, p.pressX, p.pressY)) {\n trail.update(deps);\n return;\n }\n const { x: wx, y: wy, hit } = placeAt(deps, p.pressX, p.pressY);\n const scratch = s();\n\n // Close-on-first-anchor (>= 3 anchors). With `autoCommitOnClose`\n // off the closed subpath stays in scratch for compound-path builds.\n if (scratch.current && scratch.current.anchors.length >= 3) {\n const first = scratch.current.anchors[0];\n if (withinCloseRadius(deps, first.x, first.y, wx, wy)) {\n scratch.current.closed = true;\n scratch.finishedSubpaths.push(scratch.current);\n scratch.current = null;\n scratch.closeHintActive = false;\n if (optsRef.current.autoCommitOnClose) commit(scratch, deps);\n trail.update(deps);\n return;\n }\n }\n\n const join = joinable(scratch, deps, hit);\n // Otherwise: append a corner anchor, starting a subpath if needed.\n if (!scratch.current) scratch.current = { anchors: [], closed: false };\n scratch.current.anchors.push({ x: wx, y: wy });\n if (join) commitJoin(scratch, deps, hit);\n trail.update(deps);\n },\n },\n },\n\n {\n id: 'pen.finishOpen',\n label: 'Pen — finish open path',\n eligible: { capability: 'creates-paths' },\n requires: ['editAnchors', 'insert', 'selection'],\n // Needs an actual path to commit. Declining also lets the gesture\n // fall through: a ⌘-click with fewer than two anchors reaches the\n // plain-click binding and places an anchor instead.\n enabled: () => (anchorCount(s()) >= 2 ? true : ActionDisabledReason.NotApplicable),\n invoker: {\n timing: 'immediate' as const,\n run: (deps, params) => {\n const scratch = s();\n const p = params as { viaDoubleClick?: boolean } | undefined;\n\n // A double click arrives AFTER both of its clicks, so the second\n // one has already appended an anchor. Undo exactly that before\n // committing: pop it, and drop the subpath entirely if it was the\n // only anchor in it (which happens when the FIRST click closed a\n // subpath and the second started a fresh one).\n if (p?.viaDoubleClick && scratch.current) {\n scratch.current.anchors.pop();\n if (scratch.current.anchors.length === 0) scratch.current = null;\n }\n\n commit(scratch, deps);\n trail.refresh();\n },\n },\n },\n\n {\n id: 'pen.dragHandle',\n label: 'Pen — drag out a bezier handle',\n eligible: { capability: 'creates-paths' },\n requires: ['view', 'pointer', 'areaSelect', 'editAnchors', 'scene', 'applyOps', 'insert', 'selection'],\n invoker: {\n timing: 'ongoing' as const,\n start: (ctx: InvocationCtx) => {\n const scratch = s();\n // `drag.start` is the pointerdown position, so the anchor lands\n // where the user pressed rather than where the drag threshold\n // happened to be crossed.\n const origin = ctx.drag?.start ?? ctx.world;\n // Dragging from an open path's end picks the path up and pulls\n // that end's own handle rather than placing a new anchor on it.\n const pickedUp = pickUpEndpoint(ctx.deps, origin.x, origin.y);\n // Dragging on another open path's endpoint joins onto it once\n // the handle is set.\n let joinHit: PathAnchorHit | null = null;\n if (!pickedUp) {\n const { x: ax, y: ay, hit } = placeAt(ctx.deps, origin.x, origin.y);\n if (joinable(scratch, ctx.deps, hit)) joinHit = hit;\n if (!scratch.current) scratch.current = { anchors: [], closed: false };\n scratch.current.anchors.push({ x: ax, y: ay });\n }\n scratch.draggingHandleAt = scratch.current!.anchors.length - 1;\n if (ctx.modifiers.alt) {\n scratch.current!.anchors[scratch.draggingHandleAt].altBroken = true;\n }\n // A picked-up endpoint's in-handle belongs to the existing\n // segment into it, which the pen does not reshape.\n const linked = !pickedUp;\n applyOutHandle(scratch, ctx.world, ctx.modifiers.shift, linked, optsRef.current.snapPoint);\n trail.update(ctx.deps);\n\n return {\n onMove: (moveCtx: InvocationCtx) => {\n const sm = s();\n if (sm.draggingHandleAt === null) return;\n if (moveCtx.modifiers.alt && sm.current) {\n sm.current.anchors[sm.draggingHandleAt].altBroken = true;\n }\n applyOutHandle(sm, moveCtx.world, moveCtx.modifiers.shift, linked, optsRef.current.snapPoint);\n forceRender();\n },\n onEnd: (endCtx: InvocationCtx, reason: 'commit' | 'cancel') => {\n const se = s();\n if (reason === 'cancel') {\n // `start` appended the anchor (or picked a path up); a\n // cancel has to take it back out.\n if (pickedUp) {\n resetScratch(se);\n } else if (se.current && se.draggingHandleAt === se.current.anchors.length - 1) {\n se.current.anchors.pop();\n if (se.current.anchors.length === 0) se.current = null;\n }\n se.draggingHandleAt = null;\n trail.refresh();\n return;\n }\n if (se.draggingHandleAt !== null) {\n if (endCtx.modifiers.alt && se.current) {\n se.current.anchors[se.draggingHandleAt].altBroken = true;\n }\n applyOutHandle(se, endCtx.world, endCtx.modifiers.shift, linked, optsRef.current.snapPoint);\n se.draggingHandleAt = null;\n }\n if (joinHit && se.current) commitJoin(se, ctx.deps, joinHit);\n trail.refresh();\n },\n };\n },\n },\n },\n\n {\n id: 'pen.finish',\n label: 'Pen — finish path',\n eligible: { capability: 'creates-paths' },\n requires: ['editAnchors', 'insert', 'selection'],\n enabled: () => (anchorCount(s()) > 0 ? true : ActionDisabledReason.NotApplicable),\n invoker: {\n timing: 'immediate' as const,\n run: (deps) => {\n commit(s(), deps);\n trail.refresh();\n },\n },\n },\n\n {\n id: 'pen.cancel',\n label: 'Pen — discard path',\n eligible: { capability: 'creates-paths' },\n // Declining with nothing drawn is what keeps Escape's first-match\n // ladder intact: an empty pen passes the key to `escape`, which goes\n // on to clear the selection / return to the default tool.\n enabled: () => {\n const scratch = s();\n return scratch.current !== null || scratch.finishedSubpaths.length > 0\n ? true\n : ActionDisabledReason.NotApplicable;\n },\n invoker: {\n timing: 'immediate' as const,\n run: () => {\n resetScratch(s());\n trail.refresh();\n },\n },\n },\n ];\n }, [commit, placeAt, withinCloseRadius, pickUpEndpoint, joinable, commitJoin, optsRef, trail, forceRender]);\n\n return useMemo(() => {\n return defineTool({\n id: 'pen',\n keybinding: { key: 'P' },\n capabilities: ['creates-paths'],\n hookName: 'usePenTool',\n cursor: () =>\n scratchRef.current?.closeHintActive\n ? 'pointer'\n : cursorFor('pen', { fallback: 'crosshair' }),\n presentation: {\n label: 'Pen',\n icon: createElement(PenIcon),\n group: 'draw',\n },\n actions,\n overlay,\n overlayPosition: 'before-selection',\n\n onDeactivate: () => {\n // Anything still in scratch is incomplete. Switching tools mid-path\n // discards it, as Escape does, rather than committing a stub polyline.\n resetScratch(scratchRef.current!);\n trail.stop();\n },\n\n bindings: [\n // Plain click places an anchor; ⌘/Ctrl-click open-finishes. Strict\n // modifier matching keeps the two apart.\n { spec: { kind: 'click' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.placeAnchor' },\n { spec: { kind: 'click' as const, mods: { mod: true, shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.finishOpen' },\n // Double-click on the last anchor also open-finishes.\n {\n spec: { kind: 'doubleClick' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } },\n actionId: 'pen.finishOpen',\n opts: { params: { viaDoubleClick: true } },\n },\n { spec: { kind: 'drag' as const, mods: { shift: 'optional' as const, alt: 'optional' as const } }, actionId: 'pen.dragHandle' },\n { spec: { kind: 'key' as const, key: 'Enter' }, actionId: 'pen.finish' },\n { spec: { kind: 'key' as const, key: 'Escape' }, actionId: 'pen.cancel' },\n ],\n });\n }, [actions, trail, overlay]);\n}\n\nusePenTool.prefs = {\n name: 'Pen',\n description: 'Pen-tool behavior.',\n children: {\n autoCommitOnClose: {\n kind: 'boolean',\n name: 'Auto-commit pen on close',\n description: \"When you click the pen tool's first anchor to close a region, commit immediately so it renders with its fill. Off: keep the path in preview until you press Enter (lets you build a compound path from multiple closed subpaths).\",\n default: true,\n },\n },\n} satisfies PrefGroup;\n\n/** Point the anchor's outgoing handle at `target`, optionally snapped and\n * optionally constrained to 45° steps. When `linked` and not Alt-broken,\n * the in-handle follows as its mirror through the anchor. */\nfunction applyOutHandle<S extends PenScratch>(\n s: S,\n target: { x: number; y: number },\n shift: boolean,\n linked: boolean,\n snap?: (p: { x: number; y: number }) => { x: number; y: number },\n): void {\n if (s.current === null || s.draggingHandleAt === null) return;\n const anchor = s.current.anchors[s.draggingHandleAt];\n const to = snap ? snap(target) : target;\n let dx = to.x - anchor.x;\n let dy = to.y - anchor.y;\n if (shift) {\n const c = constrainTo45(dx, dy);\n dx = c.dx;\n dy = c.dy;\n }\n anchor.outHandle = { x: anchor.x + dx, y: anchor.y + dy };\n if (linked && !anchor.altBroken) anchor.inHandle = { x: anchor.x - dx, y: anchor.y - dy };\n}\n\nfunction viewScale(deps: ActionDeps): { x: number; y: number } {\n return deps.view?.get().scale ?? { x: 1, y: 1 };\n}\n\n/** Existing editable paths, world coords, with ink within `px` screen\n * pixels of `(wx, wy)` — front-to-back, as the area query returns them.\n * Empty when the host publishes no `areaSelect` or `editAnchors` dep. */\nfunction pathsNear(\n deps: ActionDeps,\n wx: number,\n wy: number,\n px: number,\n): Array<{ id: string; path: PolygonPath }> {\n const area = deps.areaSelect;\n const edit = deps.editAnchors;\n if (!area || !edit) return [];\n const view = deps.view;\n const e = pxExtent(px, viewScale(deps));\n const ids = area.hitTestArea({ x: wx - e.x, y: wy - e.y, width: 2 * e.x, height: 2 * e.y }, view);\n const out: Array<{ id: string; path: PolygonPath }> = [];\n for (const id of ids) {\n const path = edit.getEditablePath(id) as PolygonPath | null;\n if (path?.kind === 'polygon') out.push({ id, path });\n }\n return out;\n}\n\nfunction samePath(a: PolygonPath, b: PolygonPath): boolean {\n if (a.commands.length !== b.commands.length || a.coords.length !== b.coords.length) return false;\n for (let i = 0; i < a.commands.length; i++) if (a.commands[i] !== b.commands[i]) return false;\n for (let i = 0; i < a.coords.length; i++) if (a.coords[i] !== b.coords[i]) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;AA6GA,SAASE,IAA2B;CAClC,OAAO;EACL,kBAAkB,CAAC;EACnB,SAAS;EACT,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;EACjB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,EAAE,OAAOtE,IAAI,OAAO;CAClF,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePencilTool.js","names":["PencilIcon","usePencilTool","options","useMemo","defineTool","cursorFor","insertBindingBehaviors","behaviors"],"sources":["../../../../src/tools/builtin/pencil/usePencilTool.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { PencilIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/** A single pointer sample captured during a freehand pencil stroke.\n *\n * `pressure` / `tiltX` / `tiltY` come straight from the underlying\n * `PointerEvent
|
|
1
|
+
{"version":3,"file":"usePencilTool.js","names":["PencilIcon","usePencilTool","options","useMemo","defineTool","cursorFor","insertBindingBehaviors","behaviors"],"sources":["../../../../src/tools/builtin/pencil/usePencilTool.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { PencilIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/** A single pointer sample captured during a freehand pencil stroke.\n *\n * `pressure` / `tiltX` / `tiltY` come straight from the underlying\n * `PointerEvent`. Mouse and ordinary touch report `pressure: 0.5` while a\n * button is held, `0` otherwise (per the Pointer Events spec), so a consumer\n * that wants stylus-only modulation should gate on `pointerType` — the kit\n * exposes `usePointerStylus()` for that.\n *\n * The samples reach the `insert` dep as the `pencil` insert extras'\n * `samples`; a consumer that wants pressure-driven `Stroke.vertexWidths`\n * reads it off them in its own `insert` dep (`useDepSource('insert', …)`).\n */\nexport interface PencilPoint {\n x: number;\n y: number;\n /** 0..1. Absent when the originating event carried no pressure. */\n pressure?: number;\n /** Degrees, ±90. Zero for mouse/touch. */\n tiltX?: number;\n /** Degrees, ±90. Zero for mouse/touch. */\n tiltY?: number;\n}\n\n/**\n * Freehand pencil tool. The `drag` binding routes to `insertAction`,\n * which accumulates the pointer trail and commits it as\n * `{ kind: 'pencil', samples }`. The kit's default `insert` dep runs\n * `schneiderFit` over the samples to produce a cubic-Bezier path.\n */\nexport function usePencilTool(options: InsertToolOptions = {}): Tool {\n const { behaviors } = options;\n return useMemo(\n () =>\n defineTool({\n id: 'pencil',\n keybinding: { key: 'N' },\n capabilities: ['creates-paths'],\n hookName: 'usePencilTool',\n cursor: cursorFor('pencil', { fallback: 'crosshair' }),\n presentation: {\n label: 'Pencil',\n group: 'draw',\n icon: <PencilIcon />,\n },\n bindings: [\n {\n spec: { kind: 'drag', target: 'empty' },\n actionId: 'insert',\n opts: { params: { kind: 'pencil' } , ...insertBindingBehaviors(behaviors) },\n },\n ],\n }),\n [behaviors],\n );\n}\n"],"mappings":";;;;;;;AAoCA,SAAgBC,EAAc,IAA6B,CAAC,GAAS;CACnE,IAAM,EAAE,iBAAcC;CACtB,OAAOC,QAEHC,EAAW;EACT,IAAI;EACJ,YAAY,EAAE,KAAK,IAAI;EACvB,cAAc,CAAC,eAAe;EAC9B,UAAU;EACV,QAAQC,EAAU,UAAU,EAAE,UAAU,YAAY,CAAC;EACrD,cAAc;GACZ,OAAO;GACP,OAAO;GACP,MAAM,kBAACL,GAAD,CAAa,CAAA;EACrB;EACA,UAAU,CACR;GACE,MAAM;IAAE,MAAM;IAAQ,QAAQ;GAAQ;GACtC,UAAU;GACV,MAAM;IAAE,QAAQ,EAAE,MAAM,SAAS;IAAI,GAAGM,EAAuBC,CAAS;GAAE;EAC5E,CACF;CACF,CAAC,GACH,CAACA,CAAS,CACZ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickTopMostHit.js","names":["pickTopMostHit","ids","candidates","getParent","adapter","set","dropped","id","p","depth","filtered","pickHighestZ","compareZ","best","i","getZIndex","bestZ","zOf","z"],"sources":["../../../src/tools/builtin/pickTopMostHit.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"pickTopMostHit.js","names":["pickTopMostHit","ids","candidates","getParent","adapter","set","dropped","id","p","depth","filtered","pickHighestZ","compareZ","best","i","getZIndex","bestZ","zOf","z"],"sources":["../../../src/tools/builtin/pickTopMostHit.ts"],"sourcesContent":["/** The signals `pickTopMostHit` ranks a hit list by. All optional. */\nexport interface PickTopMostHitAdapter {\n getParent?: (id: string) => string | null;\n /** Paint depth of `id`; higher draws later, so higher wins a hit. Ids the\n * adapter doesn't know sort below every id it does. */\n getZIndex?: (id: string) => number | null | undefined;\n /** Full ordering, for scenes whose depth isn't a number (a path through a\n * tree, say). Negative when `a` paints below `b`. Takes precedence over\n * `getZIndex` when both are present. */\n compareZ?: (a: string, b: string) => number;\n}\n\n/** Reduce a set of hit ids to the single one a click should act on: drop any\n * id that is an ancestor of another in the set, then take the topmost of what\n * remains. A child beats its own ancestor regardless of what z the two report.\n *\n * With no z signal the LAST id wins: scenes walked forward come back\n * bottom-first by convention. A caller that z-sorts topmost-first and exposes\n * neither z hook should resolve before calling. */\nexport function pickTopMostHit(\n ids: readonly string[],\n adapter: PickTopMostHitAdapter | undefined | null,\n): string | null {\n if (ids.length === 0) return null;\n if (ids.length === 1) return ids[0];\n\n let candidates = ids;\n\n const getParent = adapter?.getParent;\n if (typeof getParent === 'function') {\n const set = new Set(ids);\n const dropped = new Set<string>();\n for (const id of ids) {\n let p: string | null = getParent(id);\n // Cap walk to avoid pathological cycles in malformed adapters.\n let depth = 0;\n while (p != null && depth++ < 10_000) {\n if (set.has(p)) dropped.add(p);\n p = getParent(p);\n }\n }\n if (dropped.size > 0) {\n const filtered = ids.filter((id) => !dropped.has(id));\n // A pathological adapter (cyclic `getParent`) can drop everything;\n // keep the original array rather than answering null.\n if (filtered.length === 1) return filtered[0];\n if (filtered.length > 1) candidates = filtered;\n }\n }\n\n return pickHighestZ(candidates, adapter);\n}\n\n/** Highest-z survivor, or the last one when the adapter exposes no z signal.\n * Scanning forward and taking strictly-greater makes the array's own order\n * the tiebreaker, so equal-z ids resolve the same way as no-z ones. */\nfunction pickHighestZ(\n ids: readonly string[],\n adapter: PickTopMostHitAdapter | undefined | null,\n): string {\n const compareZ = adapter?.compareZ;\n if (typeof compareZ === 'function') {\n let best = ids[0];\n for (let i = 1; i < ids.length; i++) {\n if (compareZ(ids[i], best) >= 0) best = ids[i];\n }\n return best;\n }\n\n const getZIndex = adapter?.getZIndex;\n if (typeof getZIndex === 'function') {\n let best = ids[0];\n let bestZ = zOf(getZIndex, best);\n for (let i = 1; i < ids.length; i++) {\n const z = zOf(getZIndex, ids[i]);\n if (z >= bestZ) { best = ids[i]; bestZ = z; }\n }\n return best;\n }\n\n return ids[ids.length - 1];\n}\n\nfunction zOf(getZIndex: (id: string) => number | null | undefined, id: string): number {\n const z = getZIndex(id);\n return typeof z === 'number' && Number.isFinite(z) ? z : -Infinity;\n}\n"],"mappings":";AAmBA,SAAgBA,EACd,GACA,GACe;CACf,IAAIC,EAAI,WAAW,GAAG,OAAO;CAC7B,IAAIA,EAAI,WAAW,GAAG,OAAOA,EAAI;CAEjC,IAAIC,IAAaD,GAEXE,IAAYC,GAAS;CAC3B,IAAI,OAAOD,KAAc,YAAY;EACnC,IAAME,IAAM,IAAI,IAAIJ,CAAG,GACjBK,oBAAU,IAAI,IAAY;EAChC,KAAK,IAAMC,KAAMN,GAAK;GACpB,IAAIO,IAAmBL,EAAUI,CAAE,GAE/BE,IAAQ;GACZ,OAAOD,KAAK,QAAQ,MAAU,MAE5B,AADIH,EAAI,IAAIG,CAAC,KAAGF,EAAQ,IAAIE,CAAC,GAC7B,IAAIL,EAAUK,CAAC;EAEnB;EACA,IAAIF,EAAQ,OAAO,GAAG;GACpB,IAAMI,IAAWT,EAAI,QAAQ,MAAO,CAACK,EAAQ,IAAIC,CAAE,CAAC;GAGpD,IAAIG,EAAS,WAAW,GAAG,OAAOA,EAAS;GAC3C,AAAIA,EAAS,SAAS,MAAG,IAAaA;EACxC;CACF;CAEA,OAAOC,EAAaT,GAAYE,CAAO;AACzC;AAKA,SAASO,EACP,GACA,GACQ;CACR,IAAMC,IAAWR,GAAS;CAC1B,IAAI,OAAOQ,KAAa,YAAY;EAClC,IAAIC,IAAOZ,EAAI;EACf,KAAK,IAAIa,IAAI,GAAGA,IAAIb,EAAI,QAAQ,KAC9B,AAAIW,EAASX,EAAIa,IAAID,CAAI,KAAK,MAAG,IAAOZ,EAAIa;EAE9C,OAAOD;CACT;CAEA,IAAME,IAAYX,GAAS;CAC3B,IAAI,OAAOW,KAAc,YAAY;EACnC,IAAIF,IAAOZ,EAAI,IACXe,IAAQC,EAAIF,GAAWF,CAAI;EAC/B,KAAK,IAAIC,IAAI,GAAGA,IAAIb,EAAI,QAAQ,KAAK;GACnC,IAAMiB,IAAID,EAAIF,GAAWd,EAAIa,EAAE;GAC/B,AAAII,KAAKF,MAAS,IAAOf,EAAIa,IAAI,IAAQI;EAC3C;EACA,OAAOL;CACT;CAEA,OAAOZ,EAAIA,EAAI,SAAS;AAC1B;AAEA,SAASgB,EAAI,GAAsD,GAAoB;CACrF,IAAMC,IAAIH,EAAUR,CAAE;CACtB,OAAO,OAAOW,KAAM,YAAY,OAAO,SAASA,CAAC,IAAIA,IAAI;AAC3D"}
|
|
@@ -7,25 +7,26 @@ import { cursorFor as c } from "@weasel-js/cursor";
|
|
|
7
7
|
//#region src/tools/builtin/polygon/usePolygonTool.tsx
|
|
8
8
|
var l = 3, u = 32;
|
|
9
9
|
function d(d = {}) {
|
|
10
|
-
let { sides: f = 6,
|
|
10
|
+
let { sides: f = 6, label: p = "Polygon", behaviors: m } = d, h = a(f), [, g] = o(0), _ = r(() => g((e) => e + 1), []), v = i(() => ({
|
|
11
11
|
id: "polygon.adjustSides",
|
|
12
12
|
label: "Polygon — adjust sides",
|
|
13
13
|
invoker: {
|
|
14
14
|
timing: "immediate",
|
|
15
15
|
run: (e, t) => {
|
|
16
16
|
let n = t, r = n?.delta ?? (n?.deltaY !== void 0 && n.deltaY !== 0 ? n.deltaY > 0 ? 1 : -1 : 0);
|
|
17
|
-
r !== 0 && (
|
|
17
|
+
r !== 0 && (h.current = r > 0 ? Math.min(u, h.current + 1) : Math.max(l, h.current - 1), _());
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
}), [
|
|
20
|
+
}), [_]);
|
|
21
21
|
return i(() => e({
|
|
22
22
|
id: "polygon",
|
|
23
|
+
keybinding: { key: "G" },
|
|
23
24
|
capabilities: ["creates-shapes"],
|
|
24
25
|
hookName: "usePolygonTool",
|
|
25
26
|
cursor: c("crosshairPolygon", { fallback: "crosshair" }),
|
|
26
|
-
actions: [
|
|
27
|
+
actions: [v],
|
|
27
28
|
presentation: {
|
|
28
|
-
label:
|
|
29
|
+
label: p,
|
|
29
30
|
group: "shape",
|
|
30
31
|
icon: /* @__PURE__ */ s(t, {})
|
|
31
32
|
},
|
|
@@ -36,9 +37,9 @@ function d(d = {}) {
|
|
|
36
37
|
opts: {
|
|
37
38
|
params: () => ({
|
|
38
39
|
kind: "polygon",
|
|
39
|
-
sides:
|
|
40
|
+
sides: h.current
|
|
40
41
|
}),
|
|
41
|
-
...n(
|
|
42
|
+
...n(m)
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
{
|
|
@@ -73,7 +74,11 @@ function d(d = {}) {
|
|
|
73
74
|
opts: { params: { delta: -1 } }
|
|
74
75
|
}
|
|
75
76
|
]
|
|
76
|
-
}), [
|
|
77
|
+
}), [
|
|
78
|
+
v,
|
|
79
|
+
m,
|
|
80
|
+
p
|
|
81
|
+
]);
|
|
77
82
|
}
|
|
78
83
|
//#endregion
|
|
79
84
|
export { d as usePolygonTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePolygonTool.js","names":["PolygonIcon","MIN_SIDES","MAX_SIDES","usePolygonTool","initialSides","options","sidesRef","useRef","setSidesTick","useState","bumpSides","useCallback","n","adjustSidesAction","useMemo","p","params","step","defineTool","cursorFor","insertBindingBehaviors","behaviors"],"sources":["../../../../src/tools/builtin/polygon/usePolygonTool.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { PolygonIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport type { Action } from '@weasel-js/routing';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/** A point in world coordinates. */\nexport interface PolygonPoint { x: number; y: number }\n\n/** Options for `usePolygonTool`. */\nexport interface UsePolygonToolOptions extends InsertToolOptions {\n label?: string;\n /** Initial side count. Side count persists across gestures\n * (Illustrator convention) and is adjustable mid-drag via\n * ArrowUp/Down or wheel (range 3–32). */\n sides?: number;\n}\n\nconst MIN_SIDES = 3;\nconst MAX_SIDES = 32;\n\n/**\n * Drag-from-center polygon tool. Pointerdown sets center; drag\n * determines radius + rotation; release commits via `insertAction` (the\n * kit's standard insert dep, sourced by `<SceneCanvas>`). Side count\n * defaults to 6, adjustable mid-gesture via ArrowUp/Down or wheel.\n *\n * The live preview is painted by the dispatcher overlay layer reading\n * `insertAction.overlay()` — the action returns `{ kind:'insertPreview',\n * shape:'polygon', bounds, extras: { sides, ... } }`. Consumers wanting\n * a custom polygon node shape override the `insert` dep.\n */\nexport function usePolygonTool<TNode extends { id: string } = { id: string }>(\n options: UsePolygonToolOptions = {},\n): Tool
|
|
1
|
+
{"version":3,"file":"usePolygonTool.js","names":["PolygonIcon","MIN_SIDES","MAX_SIDES","usePolygonTool","initialSides","options","sidesRef","useRef","setSidesTick","useState","bumpSides","useCallback","n","adjustSidesAction","useMemo","p","params","step","defineTool","cursorFor","insertBindingBehaviors","behaviors","label"],"sources":["../../../../src/tools/builtin/polygon/usePolygonTool.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { PolygonIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport type { Action } from '@weasel-js/routing';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/** A point in world coordinates. */\nexport interface PolygonPoint { x: number; y: number }\n\n/** Options for `usePolygonTool`. */\nexport interface UsePolygonToolOptions extends InsertToolOptions {\n label?: string;\n /** Initial side count. Side count persists across gestures\n * (Illustrator convention) and is adjustable mid-drag via\n * ArrowUp/Down or wheel (range 3–32). */\n sides?: number;\n}\n\nconst MIN_SIDES = 3;\nconst MAX_SIDES = 32;\n\n/**\n * Drag-from-center polygon tool. Pointerdown sets center; drag\n * determines radius + rotation; release commits via `insertAction` (the\n * kit's standard insert dep, sourced by `<SceneCanvas>`). Side count\n * defaults to 6, adjustable mid-gesture via ArrowUp/Down or wheel.\n *\n * The live preview is painted by the dispatcher overlay layer reading\n * `insertAction.overlay()` — the action returns `{ kind:'insertPreview',\n * shape:'polygon', bounds, extras: { sides, ... } }`. Consumers wanting\n * a custom polygon node shape override the `insert` dep.\n */\nexport function usePolygonTool<TNode extends { id: string } = { id: string }>(\n options: UsePolygonToolOptions = {},\n): Tool {\n const { sides: initialSides = 6, label = 'Polygon', behaviors } = options;\n // Side count in a ref so keyDown / wheel mutations are visible\n // synchronously to the insert binding's thunked params (re-resolved\n // every frame for the live preview and at commit time). A useState\n // tick alongside forces a render so the dispatcher overlay layer\n // repaints when the count changes between pointer events.\n const sidesRef = useRef(initialSides);\n const [, setSidesTick] = useState(0);\n const bumpSides = useCallback(() => setSidesTick((n) => n + 1), []);\n\n // Wheel-to-adjust-sides action. Bound to `[engaged] wheel` so it only\n // fires while a polygon insert drag is in flight — outside that window\n // wheel falls through to ambient viewport.pan/zoom. The action's run\n // body reads the dispatcher-injected wheel delta from params.\n const adjustSidesAction = useMemo<Action>(\n () => ({\n id: 'polygon.adjustSides',\n label: 'Polygon — adjust sides',\n invoker: {\n timing: 'immediate' as const,\n run: (_deps, params) => {\n const p = params as { deltaY?: number; delta?: number } | undefined;\n // `delta` comes from the ArrowUp/ArrowDown key bindings; `deltaY`\n // is the dispatcher-injected wheel delta. Wheel \"up\" (deltaY > 0\n // under Mac natural scrolling / page-scrolls-up gesture) adds a\n // side; wheel \"down\" removes one. Matches the user's mental model:\n // scroll up = more.\n const step = p?.delta ?? (p?.deltaY !== undefined && p.deltaY !== 0\n ? (p.deltaY > 0 ? 1 : -1)\n : 0);\n if (step === 0) return;\n sidesRef.current = step > 0\n ? Math.min(MAX_SIDES, sidesRef.current + 1)\n : Math.max(MIN_SIDES, sidesRef.current - 1);\n bumpSides();\n },\n },\n }),\n [bumpSides],\n );\n\n // `TNode` is retained for source-compat with callers that previously\n // threaded a node-record type through; the tool no longer mints nodes\n // (insertAction does), so the parameter has no runtime effect.\n void ({} as TNode);\n\n return useMemo(\n () =>\n defineTool({\n id: 'polygon',\n keybinding: { key: 'G' },\n capabilities: ['creates-shapes'],\n hookName: 'usePolygonTool',\n cursor: cursorFor('crosshairPolygon', { fallback: 'crosshair' }),\n // Registered by <ToolActionsMounter>, inside the ActionsProvider —\n // see `ToolDef.actions` for why the hook can't register it itself.\n actions: [adjustSidesAction],\n presentation: {\n label,\n group: 'shape',\n icon: <PolygonIcon />,\n },\n bindings: [\n // Default = drag from corner, consistent with rect/ellipse.\n // The dispatcher overlay paints an anchorPoint dot at the\n // click so the radial shape reads as anchored even though no\n // polygon vertex sits at the AABB corner. Alt held flips to\n // center mode (insertAction reads live modifier state).\n {\n spec: { kind: 'drag' },\n actionId: 'insert',\n // Thunked params re-evaluated at commit time (and on every\n // overlay() call for live preview) so mid-gesture\n // ArrowUp/Down/wheel side-count changes flow through both\n // the ghost and the committed geometry.\n opts: {\n params: () => ({\n kind: 'polygon',\n sides: sidesRef.current,\n }),\n ...insertBindingBehaviors(behaviors),\n },\n },\n // Wheel-during-drag → adjust side count. Phase-gated to\n // `engaged` so wheel while the tool is idle still falls\n // through to ambient viewport.pan / viewport.zoom.\n {\n spec: { kind: 'wheel', phase: 'engaged' },\n actionId: 'polygon.adjustSides',\n },\n // Shift+wheel during engaged drag → rotate the in-flight\n // shape in place. Strict modifier matching means this\n // doesn't conflict with the unmodified wheel binding above.\n {\n spec: { kind: 'wheel', phase: 'engaged', mods: { shift: true } },\n actionId: 'insert.adjustRotation',\n },\n // ArrowUp/Down → adjust side count. These were phase-table\n // `initial.keyDown` routes, which put them on the OTHER dispatch\n // pipeline: the tool route claimed the key but its `claim()` never\n // reached the DOM as preventDefault/stopPropagation, so `nudge.up`\n // matched the same keypress on the interactions dispatcher and\n // moved the selection at the same time (audit §4 — derived there,\n // reproduced and now covered by a smoke test). As active-scope\n // bindings they out-prioritize ambient `nudge.*` and the\n // dispatcher's first-match-wins settles it.\n {\n spec: { kind: 'key', key: 'ArrowUp' },\n actionId: 'polygon.adjustSides',\n opts: { params: { delta: 1 } },\n },\n {\n spec: { kind: 'key', key: 'ArrowDown' },\n actionId: 'polygon.adjustSides',\n opts: { params: { delta: -1 } },\n },\n ],\n }),\n [adjustSidesAction, behaviors, label],\n );\n}\n"],"mappings":";;;;;;;AAoBA,IAAMC,IAAY,GACZC,IAAY;AAalB,SAAgBC,EACd,IAAiC,CAAC,GAC5B;CACN,IAAM,EAAE,OAAOC,IAAe,GAAG,WAAQ,WAAW,iBAAcC,GAM5DC,IAAWC,EAAOH,CAAY,GAC9B,GAAGI,KAAgBC,EAAS,CAAC,GAC7BC,IAAYC,QAAkBH,GAAc,MAAMI,IAAI,CAAC,GAAG,CAAC,CAAC,GAM5DC,IAAoBC,SACjB;EACL,IAAI;EACJ,OAAO;EACP,SAAS;GACP,QAAQ;GACR,MAAM,GAAO,MAAW;IACtB,IAAMC,IAAIC,GAMJC,IAAOF,GAAG,UAAUA,GAAG,WAAW,KAAA,KAAaA,EAAE,WAAW,IAC7DA,EAAE,SAAS,IAAI,IAAI,KACpB;IACJ,AAAIE,MAAS,MACb,EAAS,UAAUA,IAAO,IACtB,KAAK,IAAIf,GAAWI,EAAS,UAAU,CAAC,IACxC,KAAK,IAAIL,GAAWK,EAAS,UAAU,CAAC,GAC5CI,EAAU;GACZ;EACF;CACF,IACA,CAACA,CAAS,CACZ;CAOA,OAAOI,QAEHI,EAAW;EACT,IAAI;EACJ,YAAY,EAAE,KAAK,IAAI;EACvB,cAAc,CAAC,gBAAgB;EAC/B,UAAU;EACV,QAAQC,EAAU,oBAAoB,EAAE,UAAU,YAAY,CAAC;EAG/D,SAAS,CAACN,CAAiB;EAC3B,cAAc;GACZ;GACA,OAAO;GACP,MAAM,kBAACb,GAAD,CAAc,CAAA;EACtB;EACA,UAAU;GAMR;IACE,MAAM,EAAE,MAAM,OAAO;IACrB,UAAU;IAKV,MAAM;KACJ,eAAe;MACb,MAAM;MACN,OAAOM,EAAS;KAClB;KACA,GAAGc,EAAuBC,CAAS;IACrC;GACF;GAIA;IACE,MAAM;KAAE,MAAM;KAAS,OAAO;IAAU;IACxC,UAAU;GACZ;GAIA;IACE,MAAM;KAAE,MAAM;KAAS,OAAO;KAAW,MAAM,EAAE,OAAO,GAAK;IAAE;IAC/D,UAAU;GACZ;GAUA;IACE,MAAM;KAAE,MAAM;KAAO,KAAK;IAAU;IACpC,UAAU;IACV,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;GAC/B;GACA;IACE,MAAM;KAAE,MAAM;KAAO,KAAK;IAAY;IACtC,UAAU;IACV,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;GAChC;EACF;CACF,CAAC,GACH;EAACR;EAAmBQ;EAAWC;CAAK,CACtC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRectTool.js","names":["RectIcon","useRectTool","options","useMemo","defineTool","cursorFor","createElement","insertBindingBehaviors","behaviors"],"sources":["../../../../src/tools/builtin/rect/useRectTool.ts"],"sourcesContent":["import { useMemo, createElement } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { RectIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/**\n * Drag-to-draw rectangle tool.\n *\n * The
|
|
1
|
+
{"version":3,"file":"useRectTool.js","names":["RectIcon","useRectTool","options","useMemo","defineTool","cursorFor","createElement","insertBindingBehaviors","behaviors"],"sources":["../../../../src/tools/builtin/rect/useRectTool.ts"],"sourcesContent":["import { useMemo, createElement } from 'react';\nimport { defineTool } from '../../overlayBinding';\nimport { RectIcon } from '../../../icons';\nimport type { Tool } from '../../overlayBinding';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport { cursorFor } from '@weasel-js/cursor';\n\n/**\n * Drag-to-draw rectangle tool.\n *\n * The `drag` binding routes to `insertAction`, which owns the live preview\n * and commits via the `insert` dep on release. Consumers wanting a custom\n * node factory override the dep (`useDepSource('insert', …)`) rather than\n * the tool. Grid snapping comes from the `snap` dep.\n */\nexport function useRectTool(options: InsertToolOptions = {}): Tool {\n const { behaviors } = options;\n return useMemo(\n () =>\n defineTool({\n id: 'rect',\n keybinding: { key: 'R' },\n capabilities: ['creates-shapes'],\n hookName: 'useRectTool',\n cursor: cursorFor('crosshairRect', { fallback: 'crosshair' }),\n presentation: {\n label: 'Rectangle',\n icon: createElement(RectIcon),\n group: 'shape',\n },\n // Single binding: insertAction toggles corner ⇄ center on live Alt\n // state, so Alt can be engaged mid-drag.\n bindings: [\n {\n spec: { kind: 'drag' },\n actionId: 'insert',\n opts: { params: { kind: 'rect' } , ...insertBindingBehaviors(behaviors) },\n },\n ],\n }),\n [behaviors],\n );\n}\n"],"mappings":";;;;;;AAeA,SAAgBC,EAAY,IAA6B,CAAC,GAAS;CACjE,IAAM,EAAE,iBAAcC;CACtB,OAAOC,QAEHC,EAAW;EACT,IAAI;EACJ,YAAY,EAAE,KAAK,IAAI;EACvB,cAAc,CAAC,gBAAgB;EAC/B,UAAU;EACV,QAAQC,EAAU,iBAAiB,EAAE,UAAU,YAAY,CAAC;EAC5D,cAAc;GACZ,OAAO;GACP,MAAMC,EAAcN,CAAQ;GAC5B,OAAO;EACT;EAGA,UAAU,CACR;GACE,MAAM,EAAE,MAAM,OAAO;GACrB,UAAU;GACV,MAAM;IAAE,QAAQ,EAAE,MAAM,OAAO;IAAI,GAAGO,EAAuBC,CAAS;GAAE;EAC1E,CACF;CACF,CAAC,GACH,CAACA,CAAS,CACZ;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toPlane as e } from "../../../core/viewport/parallax.js";
|
|
2
|
+
import { poseDescriptorForNode as t } from "../../../core/geometry/poseDescriptor.js";
|
|
3
|
+
import { shapeCoversPoint as n } from "../../../canvas/NodeShape.js";
|
|
4
|
+
import { ownClipOf as r } from "../../../canvas/pickWalk.js";
|
|
5
|
+
import { boundsOfPath as i, meanScale as a, pathContainsPoint as o } from "@weasel-js/geom";
|
|
6
|
+
//#region src/tools/builtin/select/adapterPointQuery.ts
|
|
7
|
+
function s(s, c) {
|
|
8
|
+
let l = (u, d, f) => ({
|
|
9
|
+
hits: (e, a, l) => {
|
|
10
|
+
let p = l ? i(l) : t(s, e).getBounds(a);
|
|
11
|
+
if (e.kind !== "container") {
|
|
12
|
+
let t = c || l ? f : 0;
|
|
13
|
+
return u >= p.x - t && u <= p.x + p.width + t && d >= p.y - t && d <= p.y + p.height + t ? !c || n(e, a, u, d, {
|
|
14
|
+
tolerance: f,
|
|
15
|
+
derivedPath: l
|
|
16
|
+
}) : !1;
|
|
17
|
+
}
|
|
18
|
+
if (!(u >= p.x && u <= p.x + p.width && d >= p.y && d <= p.y + p.height)) return !1;
|
|
19
|
+
let m = r(e, a, l);
|
|
20
|
+
return m === null || o(m, u, d);
|
|
21
|
+
},
|
|
22
|
+
clipAdmits: (e) => o(e, u, d),
|
|
23
|
+
inPlane: (t) => {
|
|
24
|
+
let n = e(t, {
|
|
25
|
+
x: u,
|
|
26
|
+
y: d
|
|
27
|
+
});
|
|
28
|
+
return l(n.x, n.y, f * a(t.scale));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return l;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { s as adapterPointQuery };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=adapterPointQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapterPointQuery.js","names":["adapterPointQuery","pointQuery","b","derived","boundsOfPath","poseDescriptorForNode","d","node","pose","slop","preciseLeaves","t","px","py","shapeCoversPoint","own","ownClipOf","pathContainsPoint","clip","p","toPlane","m","meanScale"],"sources":["../../../../src/tools/builtin/select/adapterPointQuery.ts"],"sourcesContent":["import { boundsOfPath, meanScale, pathContainsPoint } from '@weasel-js/geom';\nimport { shapeCoversPoint } from 'canvas/NodeShape';\nimport { ownClipOf, type PickQuery } from 'canvas/pickWalk';\nimport { poseDescriptorForNode, type PoseDescriptor } from 'core/geometry/poseDescriptor';\nimport type { Node } from 'core/scene/types';\nimport { toPlane } from 'core/viewport/parallax';\n\n/**\n * The point query `useSelectTool`'s default `pickEvery` asks of a bare adapter:\n * a point at (px, py) with `t` world units of slop. AABB first (cheap), then\n * the painter's ink when `preciseLeaves` asks for it and it is available. A\n * painter with no `silhouette` — or one that returns null, as `kit:text` does\n * for an empty node — keeps the AABB answer.\n *\n * The AABB pre-filter is grown by the slop: a shape's outline, and the slop\n * around it, reach outside the shape's own bounds.\n *\n * A node that derives its path is tested against that path's box: its own pose\n * is a placeholder, and the box of a straight route has no area to land in\n * without the slop.\n */\nexport function adapterPointQuery<TPose>(\n d: PoseDescriptor<TPose>,\n preciseLeaves: boolean,\n): (px: number, py: number, t: number) => PickQuery<TPose> {\n const pointQuery = (px: number, py: number, t: number): PickQuery<TPose> => ({\n hits: (node, pose, derived) => {\n const b = derived ? boundsOfPath(derived) : poseDescriptorForNode(d, node).getBounds(pose);\n if (node.kind !== 'container') {\n const slop = preciseLeaves || derived ? t : 0;\n if (!(px >= b.x - slop && px <= b.x + b.width + slop\n && py >= b.y - slop && py <= b.y + b.height + slop)) {\n return false;\n }\n if (!preciseLeaves) return true;\n return shapeCoversPoint(\n node as Node<unknown, string, TPose>, pose, px, py, { tolerance: t, derivedPath: derived },\n );\n }\n // A container's own clip *is* its hit shape — it is picked where it\n // paints, and it paints only inside its clip. Ancestor clips are the\n // walk's business; this one is not.\n const inAabb = px >= b.x && px <= b.x + b.width\n && py >= b.y && py <= b.y + b.height;\n if (!inAabb) return false;\n const own = ownClipOf(node, pose, derived);\n return own === null || pathContainsPoint(own, px, py);\n },\n clipAdmits: (clip) => pathContainsPoint(clip, px, py),\n inPlane: (m) => {\n const p = toPlane(m, { x: px, y: py });\n return pointQuery(p.x, p.y, t * meanScale(m.scale));\n },\n });\n return pointQuery;\n}\n"],"mappings":";;;;;;AAqBA,SAAgBA,EACd,GACA,GACyD;CACzD,IAAMC,KAAc,GAAY,GAAY,OAAiC;EAC3E,OAAO,GAAM,GAAM,MAAY;GAC7B,IAAMC,IAAIC,IAAUC,EAAaD,CAAO,IAAIE,EAAsBC,GAAGC,CAAI,CAAC,CAAC,UAAUC,CAAI;GACzF,IAAID,EAAK,SAAS,aAAa;IAC7B,IAAME,IAAOC,KAAiBP,IAAUQ,IAAI;IAM5C,OALMC,KAAMV,EAAE,IAAIO,KAAQG,KAAMV,EAAE,IAAIA,EAAE,QAAQO,KACvCI,KAAMX,EAAE,IAAIO,KAAQI,KAAMX,EAAE,IAAIA,EAAE,SAASO,IAGpD,CAAKC,KACEI,EACLP,GAAsCC,GAAMI,GAAIC,GAAI;KAAE,WAAWF;KAAG,aAAaR;IAAQ,CAC3F,IALS;GAMX;GAMA,IAAI,EAFWS,KAAMV,EAAE,KAAKU,KAAMV,EAAE,IAAIA,EAAE,SACrCW,KAAMX,EAAE,KAAKW,KAAMX,EAAE,IAAIA,EAAE,SACnB,OAAO;GACpB,IAAMa,IAAMC,EAAUT,GAAMC,GAAML,CAAO;GACzC,OAAOY,MAAQ,QAAQE,EAAkBF,GAAKH,GAAIC,CAAE;EACtD;EACA,aAAa,MAASI,EAAkBC,GAAMN,GAAIC,CAAE;EACpD,UAAU,MAAM;GACd,IAAMM,IAAIC,EAAQC,GAAG;IAAE,GAAGT;IAAI,GAAGC;GAAG,CAAC;GACrC,OAAOZ,EAAWkB,EAAE,GAAGA,EAAE,GAAGR,IAAIW,EAAUD,EAAE,KAAK,CAAC;EACpD;CACF;CACA,OAAOpB;AACT"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { gestureLifecycleParams as e } from "../../../interactions/actions/gestureLifecycle.js";
|
|
2
2
|
import { isAnchorOrControl as t, isResizeHandle as n, isRotateHandle as r } from "@weasel-js/routing";
|
|
3
|
+
import { hitPredicate as i } from "@weasel-js/gestures";
|
|
3
4
|
//#region src/tools/builtin/select/selectionContributions.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
5
|
+
var a = "selection.move", o = "selection.transform", s = "selection.resize", c = "selection.rotate";
|
|
6
|
+
function l(n = {}) {
|
|
6
7
|
let r = (() => {
|
|
7
8
|
let t = n.move ?? {}, r = e({
|
|
8
9
|
...t,
|
|
@@ -35,7 +36,7 @@ function c(n = {}) {
|
|
|
35
36
|
{
|
|
36
37
|
spec: {
|
|
37
38
|
kind: "drag",
|
|
38
|
-
target: { kindOf: (e, n) => n === "selected-body" && !t(e) }
|
|
39
|
+
target: { kindOf: i((e, n) => n === "selected-body" && !t(e)) }
|
|
39
40
|
},
|
|
40
41
|
actionId: "move",
|
|
41
42
|
...r
|
|
@@ -50,7 +51,7 @@ function c(n = {}) {
|
|
|
50
51
|
}
|
|
51
52
|
];
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function u() {
|
|
54
55
|
return [{
|
|
55
56
|
spec: {
|
|
56
57
|
kind: "drag",
|
|
@@ -59,7 +60,7 @@ function l() {
|
|
|
59
60
|
actionId: "resize"
|
|
60
61
|
}];
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
+
function d(t = {}) {
|
|
63
64
|
let n = t.rotate ?? {}, i = e({
|
|
64
65
|
...n,
|
|
65
66
|
label: n.rotateLabel
|
|
@@ -67,7 +68,7 @@ function u(t = {}) {
|
|
|
67
68
|
n.pivot && (i.pivot = n.pivot);
|
|
68
69
|
let a = {
|
|
69
70
|
...Object.keys(i).length > 0 ? { params: i } : {},
|
|
70
|
-
...n.behaviors
|
|
71
|
+
...n.behaviors === void 0 ? {} : { behaviors: n.behaviors }
|
|
71
72
|
};
|
|
72
73
|
return [{
|
|
73
74
|
spec: {
|
|
@@ -78,52 +79,52 @@ function u(t = {}) {
|
|
|
78
79
|
...Object.keys(a).length > 0 ? { opts: a } : {}
|
|
79
80
|
}];
|
|
80
81
|
}
|
|
81
|
-
function d(e = {}) {
|
|
82
|
-
return [...l(), ...u(e)];
|
|
83
|
-
}
|
|
84
82
|
function f(e = {}) {
|
|
85
|
-
return
|
|
86
|
-
id: i,
|
|
87
|
-
eligibility: { always: !0 },
|
|
88
|
-
bindings: c(e)
|
|
89
|
-
};
|
|
83
|
+
return [...u(), ...d(e)];
|
|
90
84
|
}
|
|
91
85
|
function p(e = {}) {
|
|
92
86
|
return {
|
|
93
87
|
id: a,
|
|
94
88
|
eligibility: { always: !0 },
|
|
95
|
-
bindings:
|
|
89
|
+
bindings: l(e)
|
|
96
90
|
};
|
|
97
91
|
}
|
|
98
|
-
function m() {
|
|
92
|
+
function m(e = {}) {
|
|
99
93
|
return {
|
|
100
94
|
id: o,
|
|
101
95
|
eligibility: { always: !0 },
|
|
102
|
-
bindings:
|
|
96
|
+
bindings: f(e)
|
|
103
97
|
};
|
|
104
98
|
}
|
|
105
|
-
function h(
|
|
99
|
+
function h() {
|
|
106
100
|
return {
|
|
107
101
|
id: s,
|
|
108
102
|
eligibility: { always: !0 },
|
|
109
|
-
bindings: u(
|
|
103
|
+
bindings: u()
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function g(e = {}) {
|
|
107
|
+
return {
|
|
108
|
+
id: c,
|
|
109
|
+
eligibility: { always: !0 },
|
|
110
|
+
bindings: d(e)
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
|
-
var
|
|
113
|
-
function
|
|
113
|
+
var _ = "selection.areaSelect", v = i((e, t) => e == null && t === "empty"), y = i((e, t) => e == null && t !== "empty");
|
|
114
|
+
function b() {
|
|
114
115
|
return {
|
|
115
|
-
id:
|
|
116
|
+
id: _,
|
|
116
117
|
eligibility: { always: !0 },
|
|
117
118
|
bindings: [{
|
|
118
119
|
spec: {
|
|
119
120
|
kind: "drag",
|
|
120
|
-
target: { kindOf:
|
|
121
|
+
target: { kindOf: v }
|
|
121
122
|
},
|
|
122
123
|
actionId: "areaSelect"
|
|
123
124
|
}]
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
127
|
//#endregion
|
|
127
|
-
export {
|
|
128
|
+
export { _ as AREA_SELECT_ID, a as SELECTION_MOVE_ID, s as SELECTION_RESIZE_ID, c as SELECTION_ROTATE_ID, o as SELECTION_TRANSFORM_ID, b as areaSelectContribution, y as onBody, v as onEmptyCanvas, l as selectionMoveBindings, p as selectionMoveContribution, u as selectionResizeBindings, h as selectionResizeContribution, d as selectionRotateBindings, g as selectionRotateContribution, f as selectionTransformBindings, m as selectionTransformContribution };
|
|
128
129
|
|
|
129
130
|
//# sourceMappingURL=selectionContributions.js.map
|