@weasel-js/core 1.9.2 → 1.9.4
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 +393 -0
- package/README.md +2 -2
- package/dist/WeaselProvider.js +5 -5
- package/dist/affordances/composeAffordanceLayer.js +10 -20
- package/dist/affordances/composeAffordanceLayer.js.map +1 -1
- package/dist/affordances/cornerResize.js +25 -17
- package/dist/affordances/cornerResize.js.map +1 -1
- package/dist/affordances/hitAffordanceRegions.js +27 -20
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/rotationHandle.js +18 -18
- package/dist/affordances/rotationHandle.js.map +1 -1
- package/dist/animation/behaviors/momentum.js +93 -55
- package/dist/animation/behaviors/momentum.js.map +1 -1
- package/dist/animation/loop.js +10 -12
- package/dist/animation/loop.js.map +1 -1
- package/dist/animation/reflow.js +8 -8
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/stagger.js +64 -56
- package/dist/animation/stagger.js.map +1 -1
- package/dist/animation/timeline/booking.js +62 -54
- package/dist/animation/timeline/booking.js.map +1 -1
- package/dist/animation/timeline/createTimeline.js +85 -76
- package/dist/animation/timeline/createTimeline.js.map +1 -1
- package/dist/animation/timeline/sampleTrack.js +13 -5
- package/dist/animation/timeline/sampleTrack.js.map +1 -1
- package/dist/animation/useAnimator.js +45 -35
- package/dist/animation/useAnimator.js.map +1 -1
- package/dist/animation/wrappers/animateLifecycle.js +31 -24
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
- package/dist/animation/wrappers/animateOnSetPose.js +28 -26
- 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/{poseDescriptor-D-OH-tu5.d.ts → autoPoseDescriptor-Ct7yqivU.d.ts} +28 -3
- package/dist/barrel/chrome.js +16 -0
- package/dist/barrel/input.js +19 -0
- package/dist/barrel/interactions.js +42 -0
- package/dist/barrel/paint.js +18 -0
- package/dist/barrel/paths.js +19 -0
- package/dist/barrel/renderer.js +20 -0
- package/dist/barrel/routing.js +51 -0
- package/dist/barrel/text.js +18 -0
- package/dist/barrel/viewport.js +52 -0
- package/dist/builtins-DPcdghtB.d.ts +1223 -0
- package/dist/canvas/Canvas.js +363 -448
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +164 -165
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/CursorCoordsHud.js +37 -32
- package/dist/canvas/CursorCoordsHud.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +49 -43
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/MinimapCanvas.js +26 -25
- package/dist/canvas/MinimapCanvas.js.map +1 -1
- package/dist/canvas/NodeShape.js +59 -377
- 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/GestureDispatcherMounter.js +167 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +13 -13
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +67 -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 +10 -0
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +146 -92
- 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/features.js +1 -0
- 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 +29 -28
- 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 +38 -0
- package/dist/canvas/SceneCanvas/props.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +46 -48
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +33 -33
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +534 -788
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +45 -43
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js +91 -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 +68 -52
- package/dist/canvas/canvasRenderer.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/editAnchors.js +28 -28
- package/dist/canvas/deps/insert.js +119 -91
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/slice.js +46 -45
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/deps/textEdit.js +10 -9
- package/dist/canvas/deps/textEdit.js.map +1 -1
- package/dist/canvas/derivedPath.js +46 -23
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/getNodeAtPoint.js +7 -7
- 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/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/minimapMath.js +12 -10
- package/dist/canvas/minimapMath.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 +57 -0
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
- package/dist/canvas/nodeShapes/pathPainter.js +38 -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 +10 -11
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/canvas/pickWalk.js +52 -63
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/poseRotation.js +11 -23
- package/dist/canvas/poseRotation.js.map +1 -1
- package/dist/canvas/renderDebugSnapshot.js +5 -5
- package/dist/canvas/renderSceneToPixels.js +3 -1
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +66 -148
- 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/sceneSlotWiring.js +4 -4
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +39 -40
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/useCanvasRenderer.js +14 -6
- package/dist/canvas/useCanvasRenderer.js.map +1 -1
- package/dist/canvas/useCanvasView.js +58 -0
- package/dist/canvas/useCanvasView.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +35 -26
- package/dist/canvas/useFrameLoop.js.map +1 -1
- package/dist/canvas/useSceneLayerList.js +21 -0
- package/dist/canvas/useSceneLayerList.js.map +1 -0
- package/dist/clipboard.d.ts +10 -6
- package/dist/clone.d.ts +4 -3
- package/dist/core/adapters/arrayAdapter.js +48 -39
- package/dist/core/adapters/arrayAdapter.js.map +1 -1
- package/dist/core/device/index.js +5 -4
- 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/core/fillInPoseFrame.js.map +1 -1
- package/dist/core/geometry/poseDescriptor.js +21 -19
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/poseFrame.js +44 -0
- package/dist/core/geometry/poseFrame.js.map +1 -0
- package/dist/core/geometry/poseRotation.js.map +1 -1
- package/dist/core/geometry/regionHit.js +9 -10
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/geometry/unionBounds.js +31 -29
- package/dist/core/geometry/unionBounds.js.map +1 -1
- package/dist/core/isPlainObject.js +2 -11
- 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/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/paintKinds.js +5 -5
- package/dist/core/paintKinds.js.map +1 -1
- package/dist/core/scene/NodeProperties.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 +101 -0
- package/dist/core/scene/arrivalWindow.js.map +1 -0
- package/dist/core/scene/derivedPath.js.map +1 -1
- package/dist/core/scene/historyFacade.js +84 -0
- package/dist/core/scene/historyFacade.js.map +1 -0
- package/dist/core/scene/kitOps.js +173 -0
- package/dist/core/scene/kitOps.js.map +1 -0
- package/dist/core/scene/layerStack.js +38 -0
- package/dist/core/scene/layerStack.js.map +1 -0
- package/dist/core/scene/lockGuard.js +37 -0
- package/dist/core/scene/lockGuard.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +5 -6
- 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 +126 -0
- package/dist/core/scene/nodeStore.js.map +1 -0
- package/dist/core/scene/pickability.js +6 -0
- package/dist/core/scene/pickability.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/poseOverrides.js +34 -38
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/renderOrder.js +84 -0
- package/dist/core/scene/renderOrder.js.map +1 -0
- package/dist/core/scene/scene.js +289 -866
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/serialization.js +68 -0
- package/dist/core/scene/serialization.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/types.js.map +1 -1
- package/dist/core/viewport/meanScale.js +1 -1
- package/dist/core/viewport/meanScale.js.map +1 -1
- package/dist/core/viewport/view.js +12 -12
- package/dist/core/viewport/view.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-CtCb8a3G.d.ts} +1 -1
- package/dist/debug/createDebugOverlayLayer.js +14 -14
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/flag.js +2 -41
- package/dist/features/chrome-caps/useHoverTracking.js +22 -17
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/focus/gateLayer.js +3 -4
- package/dist/features/focus/gateLayer.js.map +1 -1
- package/dist/features/images/imageCache.js +19 -9
- package/dist/features/images/imageCache.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +14 -11
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/ingestion/index.js +1 -1
- package/dist/features/ingestion/registerKitHandlers.js +7 -7
- package/dist/features/ingestion/weaselJsonHandler.js +17 -14
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
- package/dist/features/meshPaint/lazyKind.js +201 -35
- package/dist/features/meshPaint/lazyKind.js.map +1 -1
- package/dist/features/meshPaint/meshPaint.js +82 -79
- package/dist/features/meshPaint/meshPaint.js.map +1 -1
- package/dist/features/minimap/createMinimapContribution.js +42 -42
- package/dist/features/minimap/layers.js +44 -62
- package/dist/features/minimap/layers.js.map +1 -1
- package/dist/features/parallax/createParallaxPlane.js +10 -14
- package/dist/features/parallax/createParallaxPlane.js.map +1 -1
- package/dist/features/paths/anchorEdits.js +19 -8
- package/dist/features/paths/anchorEdits.js.map +1 -1
- package/dist/features/paths/anchors.js +31 -26
- package/dist/features/paths/anchors.js.map +1 -1
- package/dist/features/paths/booleans.js +2 -2
- package/dist/features/paths/index.js +13 -11
- package/dist/features/paths/markerCommands.js +37 -36
- package/dist/features/paths/markerCommands.js.map +1 -1
- package/dist/features/paths/pathInWorld.js +19 -19
- package/dist/features/paths/pathInWorld.js.map +1 -1
- package/dist/features/paths/pathLayer.js.map +1 -1
- package/dist/features/paths/strokeToPath.js +40 -0
- package/dist/features/paths/strokeToPath.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -1
- package/dist/features/patterns/commandPaint.js +18 -0
- package/dist/features/patterns/commandPaint.js.map +1 -0
- package/dist/features/patterns/index.js +5 -17
- package/dist/features/patterns/index.js.map +1 -1
- package/dist/features/patterns/rasterizeTile.js +17 -0
- package/dist/features/patterns/rasterizeTile.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +52 -44
- package/dist/features/patterns/resolveSpec.js.map +1 -1
- package/dist/features/poseRun/usePoseRun.js +8 -3
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/selection/SelectionContext.js +5 -0
- package/dist/features/selection/SelectionContext.js.map +1 -1
- package/dist/features/selection/overlay.js +18 -18
- package/dist/features/selection/overlay.js.map +1 -1
- package/dist/features/text/domOffsets.js +82 -0
- package/dist/features/text/domOffsets.js.map +1 -0
- package/dist/features/text/domRuns.js +103 -131
- package/dist/features/text/domRuns.js.map +1 -1
- package/dist/features/text/hitTest.js +5 -2
- package/dist/features/text/hitTest.js.map +1 -1
- package/dist/features/text/isTextData.js +8 -0
- package/dist/features/text/isTextData.js.map +1 -0
- package/dist/features/text/overlayDirection.js +15 -0
- package/dist/features/text/overlayDirection.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +32 -34
- package/dist/features/text/runs/rangeStyle.js.map +1 -1
- package/dist/features/text/textCommand.js +34 -33
- package/dist/features/text/textCommand.js.map +1 -1
- package/dist/features/text/textToPath.js +40 -40
- package/dist/features/text/textToPath.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +76 -82
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/text/useTextEdit.js +184 -160
- package/dist/features/text/useTextEdit.js.map +1 -1
- package/dist/features/tiling/createTiledLayer.js +24 -22
- package/dist/features/tiling/createTiledLayer.js.map +1 -1
- package/dist/index.d.ts +11010 -7700
- package/dist/index.js +316 -309
- package/dist/input/keyState.js +42 -43
- 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/align/align.js +8 -8
- package/dist/interactions/actions/clipboard/clipboardOps.js +34 -32
- 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/behaviors/cloneByAltDrag.js.map +1 -1
- package/dist/interactions/actions/defaultCommitAdapter.js +20 -18
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
- package/dist/interactions/actions/defaults/align.js +9 -10
- package/dist/interactions/actions/defaults/align.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +59 -81
- 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/clipboard.js +26 -10
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
- package/dist/interactions/actions/defaults/clone.js +44 -60
- package/dist/interactions/actions/defaults/clone.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/distribute.js +14 -13
- package/dist/interactions/actions/defaults/distribute.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +17 -57
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/editAnchors.js +18 -18
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/flip.js +52 -46
- package/dist/interactions/actions/defaults/flip.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +43 -48
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +35 -33
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insert.js +50 -51
- package/dist/interactions/actions/defaults/insert.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -7
- package/dist/interactions/actions/defaults/lassoSelect.js +67 -70
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/move.js +267 -249
- package/dist/interactions/actions/defaults/move.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +40 -68
- 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/reorder.js +2 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/resize.js +104 -98
- package/dist/interactions/actions/defaults/resize.js.map +1 -1
- package/dist/interactions/actions/defaults/rotate.js +111 -110
- package/dist/interactions/actions/defaults/rotate.js.map +1 -1
- package/dist/interactions/actions/defaults/setFill.js +7 -7
- package/dist/interactions/actions/defaults/setFillOpacity.js +4 -4
- package/dist/interactions/actions/defaults/setStroke.js +12 -12
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
- package/dist/interactions/actions/defaults/sliceOps.js +19 -19
- package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/geometry.js +28 -23
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
- package/dist/interactions/actions/flip/helpers.js +30 -17
- package/dist/interactions/actions/flip/helpers.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/lasso-select/behaviors/selectFromLasso.js +14 -18
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
- 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 +32 -21
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/gestureAdapter.js +32 -15
- 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/outlines/createOutlines.js +18 -18
- package/dist/interactions/actions/poseDescriptorDep.js +16 -4
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
- package/dist/interactions/actions/poseFrame.js +11 -6
- package/dist/interactions/actions/poseFrame.js.map +1 -1
- package/dist/interactions/actions/previewOverrides.js +5 -5
- package/dist/interactions/actions/previewOverrides.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +69 -0
- package/dist/interactions/actions/selectionSubtree.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +66 -62
- 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 +8 -6
- package/dist/interactions/gestures/pointerDrag/pointerDrag.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/{math-Drrw4ewZ.d.ts → math-J-ACHyEg.d.ts} +1 -2
- package/dist/math.d.ts +2 -3
- package/dist/move.d.ts +12 -11
- package/dist/{originProjection-DEklpDc_.d.ts → originProjection-gHnOup4e.d.ts} +1 -1
- package/dist/{registerProgram-BMZRDgrh.d.ts → registerProgram-T9S_PfAX.d.ts} +18 -7
- package/dist/renderer/DrawCommand.js.map +1 -1
- package/dist/renderer/WeaselRenderer.js +75 -73
- package/dist/renderer/WeaselRenderer.js.map +1 -1
- package/dist/renderer/cache/GLImageCache.js +15 -5
- package/dist/renderer/cache/GLImageCache.js.map +1 -1
- package/dist/renderer/cache/GLMeshCache.js +23 -23
- package/dist/renderer/cache/GLMeshCache.js.map +1 -1
- package/dist/renderer/cache/GLTextureCache.js +18 -1
- package/dist/renderer/cache/GLTextureCache.js.map +1 -1
- package/dist/renderer/cache/cache.js.map +1 -1
- package/dist/renderer/cache/markerCommandCache.js.map +1 -1
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
- package/dist/renderer/cullDrawCommands.js +11 -11
- package/dist/renderer/draw/batch.js +133 -0
- package/dist/renderer/draw/batch.js.map +1 -0
- package/dist/renderer/draw/clip.js +89 -0
- package/dist/renderer/draw/clip.js.map +1 -0
- package/dist/renderer/draw/customShader.js +230 -0
- package/dist/renderer/draw/customShader.js.map +1 -0
- package/dist/renderer/draw/drawTriangles.js +8 -0
- package/dist/renderer/draw/drawTriangles.js.map +1 -0
- package/dist/renderer/draw/effects.js +28 -0
- package/dist/renderer/draw/effects.js.map +1 -0
- package/dist/renderer/draw/flushBatch.js +35 -0
- package/dist/renderer/draw/flushBatch.js.map +1 -0
- package/dist/renderer/draw/gradient.js +90 -0
- package/dist/renderer/draw/gradient.js.map +1 -0
- package/dist/renderer/draw/image.js +38 -0
- package/dist/renderer/draw/image.js.map +1 -0
- package/dist/renderer/draw/mesh.js +16 -0
- package/dist/renderer/draw/mesh.js.map +1 -0
- package/dist/renderer/draw/paintBind.js +70 -0
- package/dist/renderer/draw/paintBind.js.map +1 -0
- package/dist/renderer/draw/pathPaint.js +142 -0
- package/dist/renderer/draw/pathPaint.js.map +1 -0
- package/dist/renderer/draw/scratchPass.js +83 -0
- package/dist/renderer/draw/scratchPass.js.map +1 -0
- package/dist/renderer/draw/stencil.js +28 -0
- package/dist/renderer/draw/stencil.js.map +1 -0
- package/dist/renderer/draw/text.js +167 -0
- package/dist/renderer/draw/text.js.map +1 -0
- package/dist/renderer/draw/uniforms.js +77 -0
- package/dist/renderer/draw/uniforms.js.map +1 -0
- package/dist/renderer/draw.js +60 -1116
- package/dist/renderer/draw.js.map +1 -1
- package/dist/renderer/effects/EffectTargets.js +3 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -1
- package/dist/renderer/effects/composite.js +7 -5
- package/dist/renderer/effects/composite.js.map +1 -1
- package/dist/renderer/index.js +18 -17
- package/dist/renderer/math/color.js +63 -83
- package/dist/renderer/math/color.js.map +1 -1
- package/dist/renderer/math/mat3.js +15 -11
- package/dist/renderer/math/mat3.js.map +1 -1
- package/dist/renderer/math/viewToMat3.js +1 -1
- package/dist/renderer/math/viewToMat3.js.map +1 -1
- package/dist/renderer/shaders/ShaderProgram.js +13 -13
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -1
- package/dist/renderer/shaders/glyphPaint.js +3 -3
- package/dist/renderer/shaders/glyphPaint.js.map +1 -1
- package/dist/renderer/shaders/gradFill.js +2 -1
- package/dist/renderer/shaders/gradFill.js.map +1 -1
- package/dist/renderer/shaders/pathFill.js +2 -1
- package/dist/renderer/shaders/pathFill.js.map +1 -1
- package/dist/renderer/shaders/patternFill.js +2 -1
- package/dist/renderer/shaders/patternFill.js.map +1 -1
- package/dist/renderer/shaders/registerProgram.js.map +1 -1
- package/dist/renderer/strokeLengths.js.map +1 -1
- package/dist/renderer/textures/registerTexture.js +25 -5
- package/dist/renderer/textures/registerTexture.js.map +1 -1
- package/dist/renderer.d.ts +16 -15
- package/dist/renderer.js +17 -16
- package/dist/resize.d.ts +5 -6
- package/dist/resize.js +5 -5
- 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-seams-CuIxe0xY.d.ts → test-seams-DM2B87-g.d.ts} +4 -4
- package/dist/test-seams.d.ts +2 -2
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.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/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 +153 -103
- 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/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/selectionContributions.js +24 -23
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +51 -48
- 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 +49 -54
- 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 +13 -2
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/tools/useKeybindings.js +14 -30
- package/dist/tools/useKeybindings.js.map +1 -1
- package/dist/{types-B_9g6hMM.d.ts → types-B4iJRHC3.d.ts} +5 -1
- package/dist/{types-A37hYkeR.d.ts → types-k-5Oqh-U.d.ts} +31 -7
- package/dist/util/color.js +3 -3
- package/dist/util/color.js.map +1 -1
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -18
- package/dist/autoPoseDescriptor-vCdt55xm.d.ts +0 -27
- package/dist/builtins-C-VgUlWI.d.ts +0 -4514
- package/dist/core/isPlainObject.js.map +0 -1
- package/dist/debug/flag.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/renderer/shaders/imageFill.js +0 -14
- package/dist/renderer/shaders/imageFill.js.map +0 -1
- package/dist/tools/prefs.js +0 -47
- package/dist/tools/prefs.js.map +0 -1
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { KIT_SHAPE_KINDS as e } from "../../core/shapeKinds.js";
|
|
2
|
+
import { isTextData as t } from "../../features/text/isTextData.js";
|
|
2
3
|
//#region src/canvas/SceneCanvas/defaultNodeRouting.ts
|
|
3
|
-
function
|
|
4
|
+
function n(e) {
|
|
4
5
|
return typeof e == "object" && !!e;
|
|
5
6
|
}
|
|
6
|
-
var
|
|
7
|
+
var r = e.map((e) => ({
|
|
7
8
|
name: e,
|
|
8
|
-
matches: (
|
|
9
|
-
})),
|
|
9
|
+
matches: (t) => n(t) && t.kind === e
|
|
10
|
+
})), i = [
|
|
10
11
|
{
|
|
11
12
|
name: "text",
|
|
12
|
-
matches:
|
|
13
|
+
matches: t
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
16
|
name: "path",
|
|
16
|
-
matches: (e) =>
|
|
17
|
+
matches: (e) => n(e) && e.path != null
|
|
17
18
|
},
|
|
18
19
|
{
|
|
19
20
|
name: "image",
|
|
20
|
-
matches: (e) =>
|
|
21
|
+
matches: (e) => n(e) && e.image != null
|
|
21
22
|
}
|
|
22
23
|
];
|
|
23
24
|
//#endregion
|
|
24
|
-
export {
|
|
25
|
+
export { r as defaultNodeRouting, i as inferredNodeRouting };
|
|
25
26
|
|
|
26
27
|
//# sourceMappingURL=defaultNodeRouting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultNodeRouting.js","names":["isObj","d","defaultNodeRouting","KIT_SHAPE_KINDS","data","name","inferredNodeRouting"],"sources":["../../../src/canvas/SceneCanvas/defaultNodeRouting.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\n\nfunction isObj(d: unknown): d is Record<string, unknown> {\n return typeof d === 'object' && d !== null;\n}\n\n/**\n * Default routing-trait classifiers covering the kit's built-in shape\n * tools (`KIT_SHAPE_KINDS`). Each entry matches `data.kind === '<name>'`\n * — the convention demos use when they explicitly tag scene data with a\n * routing-kind string. The routing trait's default values happen to\n * mirror the shape trait's by name; the two traits remain independent\n * — a consumer can register routing kinds that have no matching shape\n * painter (e.g. `'group'`, `'sticky-note'`).\n *\n * Lives in the canvas layer (next to the builtin shape tools it mirrors)\n * rather than `core/scene`: the generic routing machinery (`NodeRouting`)\n * is core, but this default *population* depends on the canvas-layer\n * `KIT_SHAPE_KINDS`, so `core` must not own it.\n *\n * Consumers using the kit's standard data shape spread\n * `defaultNodeRouting` into their `<SceneCanvas routing={...}>` prop;\n * consumers whose data carries no `kind` field but follows the kit's\n * common shapes (`{ path }`, `{ text }`, `{ image }`) should prefer\n * `inferredNodeRouting` below, which SceneCanvas applies automatically\n * when `routing` is unset.\n *\n * In lockstep with `KIT_SHAPE_KINDS` by construction (derived via `.map`).\n */\nexport const defaultNodeRouting: readonly NodeRoutingEntry[] = KIT_SHAPE_KINDS.map(\n (name) => ({\n name,\n matches: (data) =>\n isObj(data) &&\n (data as { kind?: unknown }).kind === name,\n }),\n);\n\n/**\n * Shape-inferred routing-trait classifiers used when a consumer doesn't\n * pass `routing` to `<SceneCanvas>`. Produces semantic kinds based on\n * data-shape hints rather than an explicit `data.kind` tag:\n *\n * - `'text'` when `data.text` is a string (`text-edit` mode entry)\n * - `'path'` when `data.path` is present (`path-edit` mode entry)\n * - `'image'` when `data.image` is present\n *\n * Order matters: `'text'` beats `'path'` so an SVG-imported text node\n * carrying a fallback `path` routes to text-edit. Consumers wanting\n * different precedence pass their own `routing` array.\n *\n * Without this default the kind classifier is undefined when\n * `routing` is unset and every hit comes back as `kind: 'unknown'`,\n * silently breaking `Hit.kind`-based routing (e.g. modality's\n * `dispatchDoubleClickEntry`).\n */\nexport const inferredNodeRouting: readonly NodeRoutingEntry[] = [\n { name: 'text', matches:
|
|
1
|
+
{"version":3,"file":"defaultNodeRouting.js","names":["isObj","d","defaultNodeRouting","KIT_SHAPE_KINDS","data","name","inferredNodeRouting","isTextData"],"sources":["../../../src/canvas/SceneCanvas/defaultNodeRouting.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\nimport { isTextData } from 'features/text/isTextData';\n\nfunction isObj(d: unknown): d is Record<string, unknown> {\n return typeof d === 'object' && d !== null;\n}\n\n/**\n * Default routing-trait classifiers covering the kit's built-in shape\n * tools (`KIT_SHAPE_KINDS`). Each entry matches `data.kind === '<name>'`\n * — the convention demos use when they explicitly tag scene data with a\n * routing-kind string. The routing trait's default values happen to\n * mirror the shape trait's by name; the two traits remain independent\n * — a consumer can register routing kinds that have no matching shape\n * painter (e.g. `'group'`, `'sticky-note'`).\n *\n * Lives in the canvas layer (next to the builtin shape tools it mirrors)\n * rather than `core/scene`: the generic routing machinery (`NodeRouting`)\n * is core, but this default *population* depends on the canvas-layer\n * `KIT_SHAPE_KINDS`, so `core` must not own it.\n *\n * Consumers using the kit's standard data shape spread\n * `defaultNodeRouting` into their `<SceneCanvas routing={...}>` prop;\n * consumers whose data carries no `kind` field but follows the kit's\n * common shapes (`{ path }`, `{ text }`, `{ image }`) should prefer\n * `inferredNodeRouting` below, which SceneCanvas applies automatically\n * when `routing` is unset.\n *\n * In lockstep with `KIT_SHAPE_KINDS` by construction (derived via `.map`).\n */\nexport const defaultNodeRouting: readonly NodeRoutingEntry[] = KIT_SHAPE_KINDS.map(\n (name) => ({\n name,\n matches: (data) =>\n isObj(data) &&\n (data as { kind?: unknown }).kind === name,\n }),\n);\n\n/**\n * Shape-inferred routing-trait classifiers used when a consumer doesn't\n * pass `routing` to `<SceneCanvas>`. Produces semantic kinds based on\n * data-shape hints rather than an explicit `data.kind` tag:\n *\n * - `'text'` when `data.text` is a string (`text-edit` mode entry)\n * - `'path'` when `data.path` is present (`path-edit` mode entry)\n * - `'image'` when `data.image` is present\n *\n * Order matters: `'text'` beats `'path'` so an SVG-imported text node\n * carrying a fallback `path` routes to text-edit. Consumers wanting\n * different precedence pass their own `routing` array.\n *\n * Without this default the kind classifier is undefined when\n * `routing` is unset and every hit comes back as `kind: 'unknown'`,\n * silently breaking `Hit.kind`-based routing (e.g. modality's\n * `dispatchDoubleClickEntry`).\n */\nexport const inferredNodeRouting: readonly NodeRoutingEntry[] = [\n { name: 'text', matches: isTextData },\n { name: 'path', matches: (d) => isObj(d) && d.path != null },\n { name: 'image', matches: (d) => isObj(d) && d.image != null },\n];\n"],"mappings":";;;AAIA,SAASA,EAAM,GAA0C;CACvD,OAAO,OAAOC,KAAM,cAAYA;AAClC;AAyBA,IAAaC,IAAkDC,EAAgB,KAC5E,OAAU;CACT;CACA,UAAU,MACRH,EAAMI,CAAI,KACTA,EAA4B,SAASC;AAC1C,EACF,GAoBaC,IAAmD;CAC9D;EAAE,MAAM;EAAQ,SAASC;CAAW;CACpC;EAAE,MAAM;EAAQ,UAAU,MAAMP,EAAMC,CAAC,KAAKA,EAAE,QAAQ;CAAK;CAC3D;EAAE,MAAM;EAAS,UAAU,MAAMD,EAAMC,CAAC,KAAKA,EAAE,SAAS;CAAK;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","names":["SCENE_CANVAS_FEATURES","COMPOSITE_FEATURES","FEATURE_ACTION_IDS","TOOL_DRIVEN_ACTION_IDS","resolveFeatures","out","f","features","b","opts","featureActionIds","ids","id"],"sources":["../../../src/canvas/SceneCanvas/features.ts"],"sourcesContent":["/**\n * The behavior presets `<SceneCanvas features>` composes. A bare canvas renders\n * its scene and keeps a selection nothing sets; every behavior beyond that is\n * turned on by naming a preset here.\n */\n\n/** A preset that names one behavior and abbreviates nothing. */\nexport type BaseFeature =\n | 'view'\n | 'select'\n | 'outline'\n | 'move'\n | 'resize'\n | 'rotate'\n | 'edit'\n | 'arrange'\n | 'paths'\n | 'ingest';\n\n/** A preset that abbreviates others: `pick` is `select` + `outline`,\n * `transform` is `resize` + `rotate`, and `draw` is every base preset. */\nexport type CompositeFeature = 'pick' | 'transform' | 'draw';\n\n/** A behavior preset for `<SceneCanvas features>`. */\nexport type Feature = BaseFeature | CompositeFeature;\n\n/** Every preset `<SceneCanvas features>` accepts, each composite after the\n * presets it names. */\nexport const SCENE_CANVAS_FEATURES: readonly Feature[] = [\n 'view', 'select', 'outline', 'pick', 'move', 'resize', 'rotate', 'transform',\n 'edit', 'arrange', 'paths', 'ingest', 'draw',\n];\n\nconst BASE_FEATURES: readonly BaseFeature[] = [\n 'view', 'select', 'outline', 'move', 'resize', 'rotate', 'edit', 'arrange', 'paths', 'ingest',\n];\n\n/** The base presets each composite preset turns on. */\nexport const COMPOSITE_FEATURES: Readonly<Record<CompositeFeature, readonly BaseFeature[]>> = {\n pick: ['select', 'outline'],\n transform: ['resize', 'rotate'],\n draw: BASE_FEATURES,\n};\n\n/**\n * The kit-standard actions each preset registers.\n *\n * Every id `useStandardActions` knows appears under exactly one preset, except\n * the ones in {@link TOOL_DRIVEN_ACTION_IDS}. `move`, `resize` and `rotate`\n * also bring the ambient bindings that route drags to their actions, `select`\n * brings the select tool, and `outline`, `resize` and `rotate` bring their\n * selection chrome; this table is only the registration half.\n */\nexport const FEATURE_ACTION_IDS: Readonly<Record<BaseFeature, readonly string[]>> = {\n view: ['viewport.dragPan', 'viewport.pinchZoom'],\n select: ['areaSelect', 'clearSelection', 'lassoSelect'],\n outline: [],\n move: ['move', 'clone'],\n resize: ['resize'],\n rotate: ['rotate'],\n edit: [\n 'escape', 'cancelGesture', 'selectAll', 'duplicate', 'delete',\n 'group', 'ungroup', 'undo', 'redo',\n 'nudge.up', 'nudge.down', 'nudge.left', 'nudge.right',\n 'clipboard.cut', 'clipboard.copy', 'clipboard.paste',\n 'setFill', 'setStroke', 'setFillOpacity', 'setStrokeOpacity',\n ],\n arrange: [\n 'flip',\n 'reorder.forward', 'reorder.backward',\n 'align.left', 'align.centerX', 'align.right',\n 'align.top', 'align.centerY', 'align.bottom',\n 'distribute.horizontal', 'distribute.vertical',\n ],\n paths: [\n 'pathfinder.union', 'pathfinder.subtract', 'pathfinder.intersect',\n 'pathfinder.exclude', 'pathfinder.divide', 'pathfinder.crop', 'createOutlines',\n 'editAnchors', 'enterPathEdit', 'exitPathEdit', 'insertPathAnchor',\n 'nudgeAnchors.up', 'nudgeAnchors.down', 'nudgeAnchors.left', 'nudgeAnchors.right',\n 'deleteAnchors', 'cutPathAtAnchor', 'marqueeAnchors', 'selectAnchor',\n ],\n ingest: ['ingest'],\n};\n\n/**\n * Kit-standard actions no preset registers: they belong to the tools that bind\n * them. A canvas registers each one whenever a tool it carries names it in a\n * binding — `insert` with any shape tool, `enterTextEdit` with the text tool.\n */\nexport const TOOL_DRIVEN_ACTION_IDS: readonly string[] = ['insert', 'insert.adjustRotation', 'enterTextEdit'];\n\n/**\n * The base presets a canvas runs with: `features` with every composite\n * expanded, plus `view` whenever the canvas was handed a `viewport` config,\n * since that prop only configures what `view` turns on.\n */\nexport function resolveFeatures(\n features: readonly Feature[] | undefined,\n opts: { viewport?: boolean } = {},\n): ReadonlySet<BaseFeature> {\n const out = new Set<BaseFeature>();\n for (const f of features ?? []) {\n if (f in COMPOSITE_FEATURES) {\n for (const b of COMPOSITE_FEATURES[f as CompositeFeature]) out.add(b);\n } else {\n out.add(f as BaseFeature);\n }\n }\n if (opts.viewport) out.add('view');\n return out;\n}\n\n/** The kit-standard action ids the given presets register. */\nexport function featureActionIds(features: ReadonlySet<BaseFeature>): Set<string> {\n const ids = new Set<string>();\n for (const f of features) for (const id of FEATURE_ACTION_IDS[f]) ids.add(id);\n return ids;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features.js","names":["SCENE_CANVAS_FEATURES","COMPOSITE_FEATURES","FEATURE_ACTION_IDS","TOOL_DRIVEN_ACTION_IDS","resolveFeatures","out","f","features","b","opts","featureActionIds","ids","id"],"sources":["../../../src/canvas/SceneCanvas/features.ts"],"sourcesContent":["/**\n * The behavior presets `<SceneCanvas features>` composes. A bare canvas renders\n * its scene and keeps a selection nothing sets; every behavior beyond that is\n * turned on by naming a preset here.\n *\n * A preset is not one of the `packages/core/src/features/<name>/` source\n * directories that `docs/taxonomy.md` calls a feature; the two share a word\n * and nothing else.\n */\n\n/** A preset that names one behavior and abbreviates nothing. */\nexport type BaseFeature =\n | 'view'\n | 'select'\n | 'outline'\n | 'move'\n | 'resize'\n | 'rotate'\n | 'edit'\n | 'arrange'\n | 'paths'\n | 'ingest';\n\n/** A preset that abbreviates others: `pick` is `select` + `outline`,\n * `transform` is `resize` + `rotate`, and `draw` is every base preset. */\nexport type CompositeFeature = 'pick' | 'transform' | 'draw';\n\n/** A behavior preset for `<SceneCanvas features>`. */\nexport type Feature = BaseFeature | CompositeFeature;\n\n/** Every preset `<SceneCanvas features>` accepts, each composite after the\n * presets it names. */\nexport const SCENE_CANVAS_FEATURES: readonly Feature[] = [\n 'view', 'select', 'outline', 'pick', 'move', 'resize', 'rotate', 'transform',\n 'edit', 'arrange', 'paths', 'ingest', 'draw',\n];\n\nconst BASE_FEATURES: readonly BaseFeature[] = [\n 'view', 'select', 'outline', 'move', 'resize', 'rotate', 'edit', 'arrange', 'paths', 'ingest',\n];\n\n/** The base presets each composite preset turns on. */\nexport const COMPOSITE_FEATURES: Readonly<Record<CompositeFeature, readonly BaseFeature[]>> = {\n pick: ['select', 'outline'],\n transform: ['resize', 'rotate'],\n draw: BASE_FEATURES,\n};\n\n/**\n * The kit-standard actions each preset registers.\n *\n * Every id `useStandardActions` knows appears under exactly one preset, except\n * the ones in {@link TOOL_DRIVEN_ACTION_IDS}. `move`, `resize` and `rotate`\n * also bring the ambient bindings that route drags to their actions, `select`\n * brings the select tool, and `outline`, `resize` and `rotate` bring their\n * selection chrome; this table is only the registration half.\n *\n * Cmd/Ctrl+V arrives as a DOM `paste` event, and two presets answer it.\n * `edit` brings `clipboard.pasteEvent`, which pastes nodes a kit canvas\n * copied and nothing else; `ingest` brings `ingest`, which takes those plus\n * images, SVG, files, consumer content handlers, and every OS drop. With both\n * on, `ingest` answers alone: `useStandardActions` holds\n * `clipboard.pasteEvent` back wherever `ingest` is registered.\n */\nexport const FEATURE_ACTION_IDS: Readonly<Record<BaseFeature, readonly string[]>> = {\n view: ['viewport.dragPan', 'viewport.pinchZoom'],\n select: ['areaSelect', 'clearSelection', 'lassoSelect'],\n outline: [],\n move: ['move', 'clone'],\n resize: ['resize'],\n rotate: ['rotate'],\n edit: [\n 'escape', 'cancelGesture', 'selectAll', 'duplicate', 'delete',\n 'group', 'ungroup', 'undo', 'redo',\n 'nudge.up', 'nudge.down', 'nudge.left', 'nudge.right',\n 'clipboard.cut', 'clipboard.copy', 'clipboard.paste', 'clipboard.pasteEvent',\n 'setFill', 'setStroke', 'setFillOpacity', 'setStrokeOpacity',\n ],\n arrange: [\n 'flip',\n 'reorder.forward', 'reorder.backward',\n 'align.left', 'align.centerX', 'align.right',\n 'align.top', 'align.centerY', 'align.bottom',\n 'distribute.horizontal', 'distribute.vertical',\n ],\n paths: [\n 'pathfinder.union', 'pathfinder.subtract', 'pathfinder.intersect',\n 'pathfinder.exclude', 'pathfinder.divide', 'pathfinder.crop', 'createOutlines',\n 'editAnchors', 'enterPathEdit', 'exitPathEdit', 'insertPathAnchor',\n 'nudgeAnchors.up', 'nudgeAnchors.down', 'nudgeAnchors.left', 'nudgeAnchors.right',\n 'deleteAnchors', 'cutPathAtAnchor', 'marqueeAnchors', 'selectAnchor',\n ],\n ingest: ['ingest'],\n};\n\n/**\n * Kit-standard actions no preset registers: they belong to the tools that bind\n * them. A canvas registers each one whenever a tool it carries names it in a\n * binding — `insert` with any shape tool, `enterTextEdit` with the text tool.\n */\nexport const TOOL_DRIVEN_ACTION_IDS: readonly string[] = ['insert', 'insert.adjustRotation', 'enterTextEdit'];\n\n/**\n * The base presets a canvas runs with: `features` with every composite\n * expanded, plus `view` whenever the canvas was handed a `viewport` config,\n * since that prop only configures what `view` turns on.\n */\nexport function resolveFeatures(\n features: readonly Feature[] | undefined,\n opts: { viewport?: boolean } = {},\n): ReadonlySet<BaseFeature> {\n const out = new Set<BaseFeature>();\n for (const f of features ?? []) {\n if (f in COMPOSITE_FEATURES) {\n for (const b of COMPOSITE_FEATURES[f as CompositeFeature]) out.add(b);\n } else {\n out.add(f as BaseFeature);\n }\n }\n if (opts.viewport) out.add('view');\n return out;\n}\n\n/** The kit-standard action ids the given presets register. */\nexport function featureActionIds(features: ReadonlySet<BaseFeature>): Set<string> {\n const ids = new Set<string>();\n for (const f of features) for (const id of FEATURE_ACTION_IDS[f]) ids.add(id);\n return ids;\n}\n"],"mappings":";AAgCA,IAAaA,IAA4C;CACvD;CAAQ;CAAU;CAAW;CAAQ;CAAQ;CAAU;CAAU;CACjE;CAAQ;CAAW;CAAS;CAAU;AACxC,GAOaC,IAAiF;CAC5F,MAAM,CAAC,UAAU,SAAS;CAC1B,WAAW,CAAC,UAAU,QAAQ;CAC9B,MAAM;EAPN;EAAQ;EAAU;EAAW;EAAQ;EAAU;EAAU;EAAQ;EAAW;EAAS;CAO/E;AACR,GAkBaC,IAAuE;CAClF,MAAM,CAAC,oBAAoB,oBAAoB;CAC/C,QAAQ;EAAC;EAAc;EAAkB;CAAa;CACtD,SAAS,CAAC;CACV,MAAM,CAAC,QAAQ,OAAO;CACtB,QAAQ,CAAC,QAAQ;CACjB,QAAQ,CAAC,QAAQ;CACjB,MAAM;EACJ;EAAU;EAAiB;EAAa;EAAa;EACrD;EAAS;EAAW;EAAQ;EAC5B;EAAY;EAAc;EAAc;EACxC;EAAiB;EAAkB;EAAmB;EACtD;EAAW;EAAa;EAAkB;CAC5C;CACA,SAAS;EACP;EACA;EAAmB;EACnB;EAAc;EAAiB;EAC/B;EAAa;EAAiB;EAC9B;EAAyB;CAC3B;CACA,OAAO;EACL;EAAoB;EAAuB;EAC3C;EAAsB;EAAqB;EAAmB;EAC9D;EAAe;EAAiB;EAAgB;EAChD;EAAmB;EAAqB;EAAqB;EAC7D;EAAiB;EAAmB;EAAkB;CACxD;CACA,QAAQ,CAAC,QAAQ;AACnB,GAOaC,IAA4C;CAAC;CAAU;CAAyB;AAAe;AAO5G,SAAgBC,EACd,GACA,IAA+B,CAAC,GACN;CAC1B,IAAMC,oBAAM,IAAI,IAAiB;CACjC,KAAK,IAAMC,KAAKC,KAAY,CAAC,GAC3B,IAAID,KAAKL,GACP,KAAK,IAAMO,KAAKP,EAAmBK,IAAwB,EAAI,IAAIE,CAAC;MAEpE,EAAI,IAAIF,CAAgB;CAI5B,OADIG,EAAK,YAAUJ,EAAI,IAAI,MAAM,GAC1BA;AACT;AAGA,SAAgBK,EAAiB,GAAiD;CAChF,IAAMC,oBAAM,IAAI,IAAY;CAC5B,KAAK,IAAML,KAAKC,GAAU,KAAK,IAAMK,KAAMV,EAAmBI,IAAI,EAAI,IAAIM,CAAE;CAC5E,OAAOD;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDev.js","names":["IS_DEV"],"sources":["../../../src/canvas/SceneCanvas/isDev.ts"],"sourcesContent":["\nexport const IS_DEV: boolean = (() => {\n try {\n return Boolean((import.meta as unknown as { env?: { DEV?: boolean } }).env?.DEV);\n } catch {\n return false;\n }\n})();\n"],"mappings":";AACA,IAAaA,WAAyB;CACpC,IAAI;EACF,OAAO,CAAA;CACT,QAAQ;EACN,OAAO;CACT;AACF,EAAA,CAAG"}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AUTO_POSE_DESCRIPTOR as
|
|
3
|
-
import { hasSlop as
|
|
4
|
-
import { applyToPoint as
|
|
1
|
+
import { poseFrameInverseOf as e, poseFrameOf as t, poseLinearOf as n } from "../../core/geometry/poseFrame.js";
|
|
2
|
+
import { AUTO_POSE_DESCRIPTOR as r, isPathLike as i } from "../../interactions/actions/resize/autoPoseDescriptor.js";
|
|
3
|
+
import { hasSlop as a, slopForStrokeHit as o } from "../../core/viewport/screenSlop.js";
|
|
4
|
+
import { applyToPoint as s, pointInPath as c, strokeHitTest as l } from "@weasel-js/geom";
|
|
5
5
|
//#region src/canvas/SceneCanvas/poseGeometry.ts
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function u(e, t = r) {
|
|
7
|
+
return t.getBounds(e);
|
|
8
8
|
}
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
return
|
|
9
|
+
var d = 4;
|
|
10
|
+
function f(e, t, n, i, a = r) {
|
|
11
|
+
return m(e, t, n, i, a, 0);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
let l = c ===
|
|
15
|
-
if (l)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
13
|
+
function p(n, i, a, o, c = r) {
|
|
14
|
+
let l = c === r ? n : h(n, c);
|
|
15
|
+
if (!t(l)) return m(n, i, a, o, c, 0);
|
|
16
|
+
let u = e(l);
|
|
17
|
+
if (!u) return !1;
|
|
18
|
+
let [d, f] = s(u, i, a);
|
|
19
|
+
return m(n, d, f, o, c, l.rotation ?? 0);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
let p =
|
|
23
|
-
if (p) return
|
|
24
|
-
let _ =
|
|
21
|
+
function m(e, t, n, r, s, f) {
|
|
22
|
+
let p = i(e), m = r === void 0 ? p ? d : 0 : typeof r == "number" ? r : r.reach ?? 0, h = typeof r == "object" ? r : void 0, { opts: g } = o(h, f);
|
|
23
|
+
if (p) return c(e, t, n) ? !0 : l(e, t, n, m, g);
|
|
24
|
+
let _ = u(e, s), v = {
|
|
25
25
|
kind: "rect",
|
|
26
26
|
x: _.x - m,
|
|
27
27
|
y: _.y - m,
|
|
28
28
|
width: _.width + 2 * m,
|
|
29
29
|
height: _.height + 2 * m
|
|
30
30
|
};
|
|
31
|
-
return
|
|
31
|
+
return c(v, t, n) ? !0 : a(h) && l(v, t, n, 0, g);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let n = t.getRotation?.(e) ?? 0;
|
|
35
|
-
if (!n) return null;
|
|
33
|
+
function h(e, t) {
|
|
36
34
|
let r = t.getBounds(e);
|
|
37
35
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
x: r.x,
|
|
37
|
+
y: r.y,
|
|
38
|
+
width: r.width,
|
|
39
|
+
height: r.height,
|
|
40
|
+
rotation: t.getRotation?.(e) ?? 0,
|
|
41
|
+
transform: n(e) ?? void 0
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
|
-
export {
|
|
45
|
+
export { u as aabbOfPose, i as isPathLike, f as poseContains, p as poseContainsRotated };
|
|
45
46
|
|
|
46
47
|
//# sourceMappingURL=poseGeometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poseGeometry.js","names":["aabbOfPose","AUTO_POSE_DESCRIPTOR","descriptor","pose","DEFAULT_PATH_STROKE_SLOP","poseContains","containsInFrame","wx","wy","tolerance","poseContainsRotated","
|
|
1
|
+
{"version":3,"file":"poseGeometry.js","names":["aabbOfPose","AUTO_POSE_DESCRIPTOR","descriptor","pose","DEFAULT_PATH_STROKE_SLOP","poseContains","containsInFrame","wx","wy","tolerance","poseContainsRotated","framed","framedBounds","poseFrameOf","back","poseFrameInverseOf","lx","ly","applyToPoint","pathLike","isPathLike","reach","screen","slopForStrokeHit","rotation","pointInPath","x","y","strokeHitTest","opts","b","grown","hasSlop","poseLinearOf"],"sources":["../../../src/canvas/SceneCanvas/poseGeometry.ts"],"sourcesContent":["/**\n * Pose-shape helpers shared by `<SceneCanvas>` internals.\n *\n * Every bounds read goes through a `PoseDescriptor`, defaulting to\n * `AUTO_POSE_DESCRIPTOR` (path descriptor for `{kind:'polygon'|'rect'}` poses,\n * rect descriptor for everything else). Used by hit-test, marquee and bounds\n * extraction, so a consumer-supplied descriptor reaches all three.\n */\nimport type { Bounds } from 'tools/builtin/select';\nimport { applyToPoint, pointInPath, strokeHitTest } from '@weasel-js/geom';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { AUTO_POSE_DESCRIPTOR, isPathLike } from 'interactions/actions/resize/autoPoseDescriptor';\nimport { poseFrameInverseOf, poseFrameOf, poseLinearOf } from 'core/geometry/poseFrame';\nimport { hasSlop, slopForStrokeHit, type ScreenSlop } from 'core/viewport/screenSlop';\n\nexport { isPathLike };\n\nexport function aabbOfPose<TPose>(\n pose: TPose,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n): Bounds {\n return descriptor.getBounds(pose);\n}\n\n/** Screen-px slop applied to the stroke-distance hit-test for paths. Catches\n * fingertip-imprecision around thin lines / curves without depending on the\n * stroke's actual rendered width (which the hit-test layer doesn't know). */\nconst DEFAULT_PATH_STROKE_SLOP = 4;\n\n/** A containment slop: `reach` world units the caller knows the ink extends\n * past the pose (a stroke's outward half-width), then `px`/`scale` of screen\n * slop measured from there. */\nexport interface PoseSlop extends ScreenSlop {\n reach?: number;\n}\n\n/**\n * @param tolerance - Grab slop. A number is **world** units and grows the\n * AABB test and the path stroke-distance test alike; a {@link PoseSlop}\n * is measured on screen, from `reach` world units out. Defaults to\n * {@link DEFAULT_PATH_STROKE_SLOP} for path-like poses (the historical\n * fixed slop) and to `0` for rect poses, whose edges were never fuzzy.\n */\nexport function poseContains<TPose>(\n pose: TPose,\n wx: number,\n wy: number,\n tolerance?: number | PoseSlop,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n): boolean {\n return containsInFrame(pose, wx, wy, tolerance, descriptor, 0);\n}\n\n/**\n * Containment for `<SceneCanvas>`'s default `pickEvery`. When the pose has a\n * frame (`poseFrameOf`: a rotation, a `transform`, or both), takes the query\n * point back through it and tests in the pose's own box frame, mirroring the\n * renderer's wrap so the click target matches the drawn shape. This covers\n * rect-shaped poses and `kind:'rect'`/polygon poses that carry an AABB. A pose\n * with no frame tests directly, and one whose `transform` is singular draws\n * nothing and contains nothing.\n *\n * Rotation comes from the descriptor when one is supplied, and otherwise from\n * `pose.rotation`, the convention the renderer reads. A world `tolerance` is\n * measured in the pose's own frame, so a `transform` stretches it with the\n * node.\n */\nexport function poseContainsRotated<TPose>(\n pose: TPose,\n wx: number,\n wy: number,\n tolerance?: number | PoseSlop,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n): boolean {\n const framed = descriptor === AUTO_POSE_DESCRIPTOR ? pose : framedBounds(pose, descriptor);\n if (!poseFrameOf(framed)) return containsInFrame(pose, wx, wy, tolerance, descriptor, 0);\n const back = poseFrameInverseOf(framed);\n if (!back) return false;\n const [lx, ly] = applyToPoint(back, wx, wy);\n const rotation = (framed as { rotation?: number }).rotation ?? 0;\n return containsInFrame(pose, lx, ly, tolerance, descriptor, rotation);\n}\n\n/** `(x, y)` is in the pose's own frame, which reaches world by `rotation`. */\nfunction containsInFrame<TPose>(\n pose: TPose,\n x: number,\n y: number,\n tolerance: number | PoseSlop | undefined,\n descriptor: PoseDescriptor<unknown>,\n rotation: number,\n): boolean {\n const pathLike = isPathLike(pose);\n const reach = tolerance === undefined\n ? (pathLike ? DEFAULT_PATH_STROKE_SLOP : 0)\n : typeof tolerance === 'number' ? tolerance : (tolerance.reach ?? 0);\n const screen = typeof tolerance === 'object' ? tolerance : undefined;\n const { opts } = slopForStrokeHit(screen, rotation);\n if (pathLike) {\n // Precise inside-filled-region OR within-stroke-slop. Replaces the old\n // \"AABB-conservative-fallback\" path that returned true anywhere inside\n // the path's bounding box (which over-picked on open / non-convex paths).\n if (pointInPath(pose, x, y)) return true;\n return strokeHitTest(pose, x, y, reach, opts);\n }\n const b = aabbOfPose(pose, descriptor);\n // `reach` is the caller's budget for being at least as generous as whatever\n // refinement follows: the stroke's outward reach, which this function\n // cannot see. Grown square, so it contains the round band the refinement\n // tests.\n const grown = {\n kind: 'rect' as const,\n x: b.x - reach, y: b.y - reach, width: b.width + 2 * reach, height: b.height + 2 * reach,\n };\n if (pointInPath(grown, x, y)) return true;\n return hasSlop(screen) && strokeHitTest(grown, x, y, 0, opts);\n}\n\n/** The box, rotation, and `transform` a descriptor-read pose is drawn in. */\nfunction framedBounds<TPose>(pose: TPose, descriptor: PoseDescriptor<unknown>): unknown {\n const b = descriptor.getBounds(pose);\n return {\n x: b.x, y: b.y, width: b.width, height: b.height,\n rotation: descriptor.getRotation?.(pose) ?? 0,\n transform: poseLinearOf(pose) ?? undefined,\n };\n}\n"],"mappings":";;;;;AAiBA,SAAgBA,EACd,GACA,IAAsCC,GAC9B;CACR,OAAOC,EAAW,UAAUC,CAAI;AAClC;AAKA,IAAMC,IAA2B;AAgBjC,SAAgBC,EACd,GACA,GACA,GACA,GACA,IAAsCJ,GAC7B;CACT,OAAOK,EAAgBH,GAAMI,GAAIC,GAAIC,GAAWP,GAAY,CAAC;AAC/D;AAgBA,SAAgBQ,EACd,GACA,GACA,GACA,GACA,IAAsCT,GAC7B;CACT,IAAMU,IAAST,MAAeD,IAAuBE,IAAOS,EAAaT,GAAMD,CAAU;CACzF,IAAI,CAACW,EAAYF,CAAM,GAAG,OAAOL,EAAgBH,GAAMI,GAAIC,GAAIC,GAAWP,GAAY,CAAC;CACvF,IAAMY,IAAOC,EAAmBJ,CAAM;CACtC,IAAI,CAACG,GAAM,OAAO;CAClB,IAAM,CAACE,GAAIC,KAAMC,EAAaJ,GAAMP,GAAIC,CAAE;CAE1C,OAAOF,EAAgBH,GAAMa,GAAIC,GAAIR,GAAWP,GAD9BS,EAAiC,YAAY,CACK;AACtE;AAGA,SAASL,EACP,GACA,GACA,GACA,GACA,GACA,GACS;CACT,IAAMa,IAAWC,EAAWjB,CAAI,GAC1BkB,IAAQZ,MAAc,KAAA,IACvBU,IAAWf,IAA2B,IACvC,OAAOK,KAAc,WAAWA,IAAaA,EAAU,SAAS,GAC9Da,IAAS,OAAOb,KAAc,WAAWA,IAAY,KAAA,GACrD,EAAE,YAASc,EAAiBD,GAAQE,CAAQ;CAClD,IAAIL,GAKF,OADIM,EAAYtB,GAAMuB,GAAGC,CAAC,IAAU,KAC7BC,EAAczB,GAAMuB,GAAGC,GAAGN,GAAOQ,CAAI;CAE9C,IAAMC,IAAI9B,EAAWG,GAAMD,CAAU,GAK/B6B,IAAQ;EACZ,MAAM;EACN,GAAGD,EAAE,IAAIT;EAAO,GAAGS,EAAE,IAAIT;EAAO,OAAOS,EAAE,QAAQ,IAAIT;EAAO,QAAQS,EAAE,SAAS,IAAIT;CACrF;CAEA,OADII,EAAYM,GAAOL,GAAGC,CAAC,IAAU,KAC9BK,EAAQV,CAAM,KAAKM,EAAcG,GAAOL,GAAGC,GAAG,GAAGE,CAAI;AAC9D;AAGA,SAASjB,EAAoB,GAAa,GAA8C;CACtF,IAAMkB,IAAI5B,EAAW,UAAUC,CAAI;CACnC,OAAO;EACL,GAAG2B,EAAE;EAAG,GAAGA,EAAE;EAAG,OAAOA,EAAE;EAAO,QAAQA,EAAE;EAC1C,UAAU5B,EAAW,cAAcC,CAAI,KAAK;EAC5C,WAAW8B,EAAa9B,CAAI,KAAK,KAAA;CACnC;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resizePolicyOptions as e, useResizePolicy as t } from "../deps/resizePolicy.js";
|
|
2
|
+
import { useGeometryProjection as n } from "../deps/geometryProjection.js";
|
|
3
|
+
//#region src/canvas/SceneCanvas/poseRegistrars.tsx
|
|
4
|
+
function r({ options: n }) {
|
|
5
|
+
return t(e(n)), null;
|
|
6
|
+
}
|
|
7
|
+
function i({ projection: e }) {
|
|
8
|
+
return n(e), null;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { i as GeometryProjectionRegistrar, r as ResizePolicyRegistrar };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=poseRegistrars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poseRegistrars.js","names":["ResizePolicyRegistrar","useResizePolicy","resizePolicyOptions","options","GeometryProjectionRegistrar","useGeometryProjection","projection"],"sources":["../../../src/canvas/SceneCanvas/poseRegistrars.tsx"],"sourcesContent":["import type { GeometryProjection } from 'interactions/actions/geometryProjection';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport {\n resizePolicyOptions,\n useGeometryProjection,\n useResizePolicy\n} from '../deps';\n\n/** Subcomponent so we can conditionally render (and thus conditionally\n * call) `useResizePolicy`. See parent's comment for why this\n * must be gated rather than always-on. */\nexport function ResizePolicyRegistrar({\n options,\n}: {\n options: UseResizeOptions<unknown>;\n}) {\n useResizePolicy<unknown>(resizePolicyOptions(options));\n return null;\n}\n\n/** Subcomponent so we can conditionally render (and thus conditionally\n * call) `useGeometryProjection`. Mirrors `ResizePolicyRegistrar` — the\n * conditional mount ensures the dep is registered only when the consumer\n * supplies a projection, so absent → dep undefined → actions stay pose-only. */\nexport function GeometryProjectionRegistrar({\n projection,\n}: {\n projection: GeometryProjection;\n}) {\n useGeometryProjection(projection);\n return null;\n}\n"],"mappings":";;;AAWA,SAAgBA,EAAsB,EACpC,cAGC;CAED,OADAC,EAAyBC,EAAoBC,CAAO,CAAC,GAC9C;AACT;AAMA,SAAgBC,EAA4B,EAC1C,iBAGC;CAED,OADAC,EAAsBC,CAAU,GACzB;AACT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HANDLE_BASE_PX as e, targetSizesPx as t } from "../../core/device/targets.js";
|
|
2
|
+
import { defaultDrawOne as n, defaultPaintBounds as r, paintBoundsFor as i } from "../defaultDrawOne.js";
|
|
3
|
+
import { KIT_SHAPE_KINDS as a } from "../../core/shapeKinds.js";
|
|
4
|
+
import "@weasel-js/routing/react";
|
|
5
|
+
//#region src/canvas/SceneCanvas/props.ts
|
|
6
|
+
var o = e;
|
|
7
|
+
function s(e, a = 1) {
|
|
8
|
+
let o = {
|
|
9
|
+
scene: {
|
|
10
|
+
drawOne: n,
|
|
11
|
+
paintBounds: r
|
|
12
|
+
},
|
|
13
|
+
selectionOverlay: { handles: { size: t(a).handle } }
|
|
14
|
+
};
|
|
15
|
+
if (!e) return o;
|
|
16
|
+
let s = { ...e };
|
|
17
|
+
if (!("scene" in e)) s.scene = o.scene;
|
|
18
|
+
else if (e.scene === null) s.scene = null;
|
|
19
|
+
else {
|
|
20
|
+
let t = {
|
|
21
|
+
...o.scene,
|
|
22
|
+
...e.scene
|
|
23
|
+
};
|
|
24
|
+
s.scene = e.scene && "paintBounds" in e.scene ? t : {
|
|
25
|
+
...t,
|
|
26
|
+
paintBounds: i(t.drawOne)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return s.selectionOverlay = "selectionOverlay" in e ? e.selectionOverlay === null ? null : {
|
|
30
|
+
...o.selectionOverlay,
|
|
31
|
+
...e.selectionOverlay
|
|
32
|
+
} : o.selectionOverlay, s;
|
|
33
|
+
}
|
|
34
|
+
var c = ["select", "hand"], l = [...c, ...a];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { l as BUILTIN_TOOL_IDS, o as DEFAULT_HANDLE_SIZE, c as NON_SHAPE_BUILTIN_TOOLS, s as mergeLayersWithDefaults };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","names":["DEFAULT_HANDLE_SIZE","HANDLE_BASE_PX","mergeLayersWithDefaults","defaults","defaultDrawOne","defaultPaintBounds","targetSizesPx","targetScale","user","result","scene","paintBoundsFor","NON_SHAPE_BUILTIN_TOOLS","BUILTIN_TOOL_IDS","KIT_SHAPE_KINDS"],"sources":["../../../src/canvas/SceneCanvas/props.ts"],"sourcesContent":["import type { ModeRegistry } from '@weasel-js/modes';\nimport type { FillStyle } from '@weasel-js/paint';\nimport type { ActionsProp } from '@weasel-js/routing';\nimport { Yoke } from '@weasel-js/routing/react';\nimport type { PasteOmission } from 'core/adapters/types';\nimport type { Op } from 'core/ops/types';\nimport type { Node, NodeId, Scene, SerializedScene } from 'core/scene/types';\nimport type { SelectionApi, UseSelectionOptions } from 'core/selection/useSelection';\nimport type { BuiltinShapeToolId } from 'core/shapeKinds';\nimport { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nimport type { PanBounds } from 'core/viewport/useDecayLoop';\nimport type { View } from 'core/viewport/view';\nimport type {\n ContentHandlerEntry\n} from 'features/ingestion';\nimport type { PinchZoomOptions } from 'interactions/actions/defaults/pinchZoom';\nimport type { WheelPanOptions } from 'interactions/actions/defaults/viewportWheelPan';\nimport type { ViewportZoomAnimateOptions, ViewportZoomOptions } from 'interactions/actions/defaults/viewportZoom';\nimport type { SvgIngestOptions } from 'interactions/actions/depSchema';\nimport type { GeometryProjection } from 'interactions/actions/geometryProjection';\nimport type { UseMoveOptions } from 'interactions/actions/move/options';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport type { UseRotateOptions } from 'interactions/actions/rotate/options';\nimport type { SnapStrategy } from 'interactions/gestures/types';\nimport type { ReactNode } from 'react';\nimport type { Bounds } from 'tools/builtin/select';\nimport type { Animator } from '../../animation/types';\nimport { HANDLE_BASE_PX, targetSizesPx } from '../../core/device/targets';\nimport type { DeviceProfile } from '../../core/device/types';\nimport type { NodeRoutingEntry } from '../../core/scene/NodeRouting';\nimport type { DebugConfig } from '../../debug/types';\nimport type { LayoutDropTargetMode, ReflowTransition } from '../../layout/types';\nimport type { DrawCommand, ShaderProgramHandle } from '../../renderer';\nimport type { AnyTool } from '../../tools/overlayBinding';\nimport type { ToolsApi } from '../../tools/overlayBinding';\nimport type { CanvasProps, LayersMap, SceneSlotConfig } from '../Canvas';\nimport type { CanvasViewProps } from '../CanvasView';\nimport { defaultDrawOne, defaultPaintBounds, paintBoundsFor } from '../defaultDrawOne';\nimport type {\n InsertNodeFactory,\n InsertPaint\n} from '../deps';\nimport type { SceneToAdapterOptions } from '../sceneAdapter';\nimport type { SurfaceContribution } from '../surfaceContribution';\nimport type {\n Feature\n} from './features';\nimport type { BuiltinToolOptions } from './useBuiltinShapeTools';\nimport type { VersionCheck } from './useContributionRoles';\n\n/**\n * Minimal adapter surface the legacy bridge factories need for delete /\n * duplicate / group / ungroup. Extracted from `SceneCanvasAdapter` to avoid\n * threading the full generic type through `StandardActionsRegistrar` (which is\n * non-generic). The actual adapter supplied is always a `SceneCanvasAdapter`\n * so the cast is safe.\n */\nexport interface BridgeAdapter {\n applyOps(ops: Op[], label?: string): void;\n insertNode(node: { id: string; [k: string]: unknown }): void;\n removeNode(id: string): void;\n setSelection(ids: string[]): void;\n}\n\n/** Default size in CSS pixels for selection corner-handles AND their\n * hit-test radius, at `targetScale = 1`. Used by the SceneCanvas defaults;\n * consumers override via `selectTool.handleHitRadius` or\n * `layers.selectionOverlay.handles.size`.\n *\n * Deliberately unscaled: consumers reading this constant keep getting the\n * number they always got. Kit-internal use sites multiply by\n * `DeviceProfile.targetScale`. */\nexport const DEFAULT_HANDLE_SIZE = HANDLE_BASE_PX;\n\n// ---------------------------------------------------------------------------\n// Dev-only coord trace\n// ---------------------------------------------------------------------------\n\n/**\n * `import.meta.env.DEV`, read through a cast rather than off a typed\n * `ImportMeta`. Core must not depend on a bundler's ambient augmentation\n * (`vite/client`) to compile — until core moved into `packages/core/`, two\n * call sites below read `import.meta.env` bare and only type-checked because\n * `apps/site/vite-env.d.ts` leaked its `/// <reference types=\"vite/client\" />`\n * into the shared root-tsconfig program. Isolating core's build surfaced it.\n * Mirrors the same cast in dispatcher.ts and buildDeps.ts.\n */\n/** `<SceneCanvas longPress>`. */\nexport interface SceneCanvasLongPress {\n /**\n * Shown while a long-press is held and some binding would fire on it.\n * Default: a ring that fills around the press point\n * (`createLongPressFeedbackContribution()`), static under\n * `prefers-reduced-motion`. `false` shows nothing; a contribution replaces\n * it, reading the `longPress` dep. Installed beside `ambient`, so under a\n * `tools` takeover add it to your own `useTools` call instead.\n */\n feedback?: boolean | SurfaceContribution;\n /** Default true. A long-press some binding handled pulses\n * `navigator.vibrate` briefly, for touch and pen, where the API exists. */\n haptics?: boolean;\n /** Hold time in ms. Default `LONG_PRESS_MS` (500). */\n duration?: number;\n}\n\n/** `<SceneCanvas layers>`: a {@link LayersMap} whose scene slot may be partial,\n * since the defaults fill in whatever it leaves out. */\nexport type SceneCanvasLayers<TNode extends { id: string }, TPose> = LayersMap<\n TNode,\n TPose,\n Partial<SceneSlotConfig<TNode, TPose>>\n>;\n\n/** Deep-merge user-supplied `layers` with kit defaults. Slots the user\n * doesn't mention get filled with defaults; slots explicitly set to\n * `null` are dropped (the existing \"disable this slot\" convention).\n * Partial slot configs (e.g. `{ scene: { drawOne: customFn } }`) are\n * shallow-spread on top of the default slot config.\n *\n * `targetScale` comes from the resolved {@link DeviceProfile}. It is a\n * parameter rather than a read because this function is module-scope and\n * the profile is a hook value; the caller inside the component passes it. */\nexport function mergeLayersWithDefaults<TData, TLayer extends string, TPose>(\n user: SceneCanvasLayers<Node<TData, TLayer, TPose>, TPose> | undefined,\n targetScale = 1,\n): LayersMap<Node<TData, TLayer, TPose>, TPose> {\n const defaults = {\n scene: {\n drawOne: defaultDrawOne as (\n node: Node<TData, TLayer, TPose>,\n pose: TPose,\n ) => DrawCommand[],\n paintBounds: defaultPaintBounds<TData, TLayer, TPose>,\n },\n selectionOverlay: { handles: { size: targetSizesPx(targetScale).handle } },\n };\n\n if (!user) return defaults as LayersMap<Node<TData, TLayer, TPose>, TPose>;\n\n // Start from a shallow copy of the user map so unknown slots pass through.\n const result = { ...user } as LayersMap<Node<TData, TLayer, TPose>, TPose>;\n\n if (!('scene' in user)) {\n result.scene = defaults.scene;\n } else if (user.scene === null) {\n result.scene = null;\n } else {\n const scene = { ...defaults.scene, ...user.scene };\n result.scene = user.scene && 'paintBounds' in user.scene\n ? scene\n : { ...scene, paintBounds: paintBoundsFor<TData, TLayer, TPose>(scene.drawOne) };\n }\n\n if (!('selectionOverlay' in user)) {\n result.selectionOverlay = defaults.selectionOverlay;\n } else if (user.selectionOverlay === null) {\n result.selectionOverlay = null;\n } else {\n result.selectionOverlay = { ...defaults.selectionOverlay, ...user.selectionOverlay };\n }\n\n return result;\n}\n\n/** Built-in tool ids SceneCanvas knows how to mount when no `tools` prop\n * is supplied, via `defaultTools`. */\nexport type BuiltinToolId = 'select' | 'hand' | BuiltinShapeToolId;\n\n/** Built-in tool ids that aren't shape tools — the ones with no entry in\n * the `core/shapeKinds` table. */\nexport const NON_SHAPE_BUILTIN_TOOLS: readonly Exclude<BuiltinToolId, BuiltinShapeToolId>[] = ['select', 'hand'];\n\n/** Every built-in tool id, shape tools included. */\nexport const BUILTIN_TOOL_IDS: readonly BuiltinToolId[] = [...NON_SHAPE_BUILTIN_TOOLS, ...KIT_SHAPE_KINDS];\n\n/** Minimal hit descriptor passed to `onDoubleClick`. Contains the fields\n * modality dispatch needs; extends as the kit's `Hit` type evolves. */\nexport interface SceneCanvasHit {\n id: string;\n kind: string;\n}\n\n/** Props for `<SceneCanvas>`. A scene is the only thing it needs. With nothing\n * else it renders that scene and keeps a selection no input sets; `features`\n * turns behavior on by preset, and the rest configures what those turn on. */\nexport type SceneCanvasProps<TData, TLayer extends string, TPose> =\n Omit<\n CanvasProps<Node<TData, TLayer, TPose>, TPose>,\n | 'adapter'\n | 'moveOptions' | 'resizeOptions' | 'rotateOptions'\n | 'snap' | 'pickEvery' | 'boundsOf' | 'handleHitRadius'\n | 'selection' | 'selectionOptions' | 'tools'\n | 'layers' // stripped so we can re-add as optional below\n | 'onBackgroundClick' // SceneCanvas synthesizes this; not a consumer prop\n | 'getIsVisible' // SceneCanvas synthesizes this from chromeVisibility\n | 'contentVersion' // SceneCanvas wires this to the scene's own version\n | 'layerVisibility' | 'layerOrder' // re-declared below: they gate picking here too\n | 'debug' // re-declared below with SceneCanvas's own `slops`\n >\n & {\n /** A `Scene` (typically from `useScene`) — or a `SerializedScene`\n * JSON object, which SceneCanvas bakes into a Scene internally on\n * first render. The serialized form is read once; subsequent\n * changes to the prop are ignored. Pass a `key` prop on\n * `<SceneCanvas>` to force a fresh canvas from updated JSON.\n *\n * The accepted JSON shape is intentionally relaxed (`version:\n * number` rather than `1` literal) so a `import json from './x.json'`\n * result satisfies the type without an `as` cast — Vite infers\n * number-literal types as `number` from JSON, which the strict\n * `SerializedScene<…>` would reject. */\n scene:\n | Scene<TData, TLayer, TPose>\n | SerializedScene<TData, TLayer, TPose>\n | { version: number; systemLayers?: ReadonlyArray<{ id: string }>; nodes: ReadonlyArray<unknown> };\n\n /** Layer configuration. When omitted, SceneCanvas applies kit defaults\n * (a scene slot that paints `node.data.fill` rects + a default\n * selection overlay). A partial scene or selection-overlay config is\n * spread over that slot's defaults; pass `slot: null` to suppress a\n * default explicitly. */\n layers?: SceneCanvasLayers<Node<TData, TLayer, TPose>, TPose>;\n\n /** Layout strategies keyed by container node id (or a resolver), for\n * containers whose scene node declares none (`ContainerNode.layout`\n * wins). Applied to a drag and to every other change to their children,\n * through the scene's layout pass. */\n layouts?: SceneToAdapterOptions<TData, TLayer, TPose>['layouts'];\n\n /** Which layout container a drag lands in when several contain the drop\n * point — the innermost (default), the topmost in paint order, or only\n * containers whose strategy declares a `dropRegion`. Decides both the\n * drag-time reflow preview and the commit. */\n layoutDropTarget?: LayoutDropTargetMode;\n\n /** Carries the siblings a layout reflow displaces to their slots over time\n * instead of snapping them — `useAnimatedReflow` builds one. Covers a\n * drag's reflow and every one the scene records (an insert, delete,\n * reorder or resize inside a laid-out container). Absent or `null`,\n * they snap. */\n reflowTransition?: ReflowTransition<TPose> | null;\n\n /** How a child's stored pose folds into its parent's frame. Omit for the\n * absolute-pose model, where a container groups its children but imposes\n * no transform. Pass `RIGID_POSE_COMPOSITION` to make a container's pose\n * a frame, so rotating it rotates its contents and moving it carries them\n * without touching their poses. */\n poseComposition?: SceneToAdapterOptions<TData, TLayer, TPose>['poseComposition'];\n\n /**\n * Optional consumer seam for eager geometry sync: lets pose-transform\n * actions (move, resize, nudge, flip — NOT rotate) also rewrite a node's\n * data-held geometry. Given a node and the affine `m` applied to its pose,\n * `transform(node, m)` returns updated `data` (geometry mapped by `m`) or\n * `null` for nodes with no data-held geometry.\n *\n * Strictly opt-in: when absent, the kit emits only the pose op and leaves\n * `data` untouched. Consumers wire this via `geometryProjection={myProjection}`.\n *\n * @see GeometryProjection\n */\n geometryProjection?: GeometryProjection;\n\n /**\n * Routing-trait classifiers — list of `NodeRoutingEntry` entries. The kit\n * constructs a `NodeRouting` registry per-`<SceneCanvas>` from this prop,\n * then uses the resulting classifier to derive each hit's `kind` when\n * building `getNodeAtPoint`. Tool routing tables (e.g.\n * `{ target: 'rect', actionId: 'move' }`) match against the produced\n * kind strings.\n *\n * Pass `defaultNodeRouting` to pick up the kit's built-in shape kinds\n * (rect, ellipse, polygon, …) for `data: { kind: '<shape>' }` nodes.\n * Spread additional entries for consumer-defined kinds.\n *\n * See `docs/superpowers/specs/2026-05-24-node-traits-reframe-design.md`.\n *\n * **Memoize the `routing` value.** The kit memoizes the registry on the\n * prop's reference identity. Passing a fresh array each render\n * (e.g. `routing={[...defaultNodeRouting, custom]}` inline) rebuilds the\n * registry and cascades into a new adapter, churning gesture state.\n * Define the list as a module-level constant, or wrap it in `useMemo`.\n * (`defaultNodeRouting` alone is a stable module-level constant; spreading\n * it with extras is what needs the memo.)\n */\n routing?: readonly NodeRoutingEntry[];\n\n /** How to read and rewrite this scene's poses. Every built-in action,\n * the selection chrome and picking read it. Default `AUTO_POSE_DESCRIPTOR`\n * (rect poses and `Path` poses). */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n // --- Geometry: hit-test + bounds overrides consumed by the internal\n // `useSelectTool`. Ignored if the consumer passes their own `tools`. ---\n geometry?: {\n /** Hit-test override. Return the topmost id, the full back-to-front hit\n * stack (`string[]`), or `null` for empty space. The stack form lets a\n * consumer with domain overlap ordering (e.g. children over their\n * container) feed the kit's `pickTopMostHit` the true order instead of\n * pre-collapsing to one id. Matches `Canvas`'s `pickEvery` shape. */\n pickEvery?: (worldX: number, worldY: number) => string | string[] | null;\n boundsOf?: (id: string) => Bounds | null;\n /**\n * What \"the pointer is on this node\" means for the default body-pick.\n *\n * - `'pose'` — the node's pose rect, rotation honored. What every\n * consumer got before `'shape'` existed, and now the opt-out.\n * - `'shape'` (default) — the pose rect as a pre-filter, then the ink the painter\n * actually lays down: its silhouette (`findShapeSilhouette`) filled\n * or not per the painter's `ink`, plus its outline widened by the\n * stroke half-width and `pickTolerancePx`. A click in the concave\n * notch of a star, in the corner outside an ellipse, or in the blank\n * half of a text box falls through to whatever is beneath; a click on\n * the thin outline of an unfilled shape hits it.\n *\n * Painters with no silhouette are unaffected — they keep the pose-rect\n * answer either way, so this can never make a node unreachable.\n *\n * Ignored when `pickEvery` is supplied: that override owns the test.\n */\n picking?: 'pose' | 'shape';\n /**\n * Grab slop around a shape's outline, in **screen** pixels. Default 4.\n *\n * Screen pixels rather than world units so the target keeps its\n * apparent size at any zoom. It widens the outline test under\n * `picking: 'shape'` (a 1px hairline is otherwise a half-world-unit\n * target, which is unhittable), and it grows the pose-rect pre-filter\n * so those outline hits survive it. Set `0` for exact geometry.\n */\n pickTolerancePx?: number;\n };\n\n // --- Selection options. `pickBest` and `handleHitRadius` configure the\n // internal select tool, and are ignored under a `tools` takeover;\n // `move`, `snap`, `resize` and `rotate` configure the `move`,\n // `resize` and `rotate` presets, and apply either way. ---\n selectTool?: {\n move?: UseMoveOptions<TPose>;\n resize?: UseResizeOptions<TPose>;\n /** Rotation options, or `false` to disable rotation entirely — drops the\n * `rotate` action AND hides the selection rotation-handle chrome, so a\n * consumer whose objects don't rotate (e.g. a floor-plan / garden\n * editor) opts out with a single switch instead of pairing\n * `actions={{ rotate: null }}` with a `chromeVisibility` override. */\n rotate?: UseRotateOptions<TPose> | false;\n snap?: SnapStrategy<TPose>;\n handleHitRadius?: number;\n /** Override the body-pick used on click/pointerdown. Alt-aware: receives\n * the live alt state + current selection so consumers can implement\n * alt-cycling through an overlapping stack. Default: top-most hit\n * (alt ignored). */\n pickBest?: (worldX: number, worldY: number, alt: boolean, sel: readonly string[]) => string | null;\n };\n\n // --- Insert tool: when `create` is supplied, the synthesized adapter\n // exposes `commitInsert` and inserted objects are added as leaves on\n // `layer` (default `'default'`). ---\n insertTool?: {\n create: SceneToAdapterOptions<TData, TLayer, TPose>['commitInsert'];\n layer?: TLayer;\n };\n\n /** Consumer node factories for the `insert` action, keyed by tool `kind`.\n * Each factory receives the drag AABB + tool `extras` and returns the\n * node's `data` (in this canvas's own data shape) plus an optional `pose`.\n * A factory for a kit kind (`rect`, `line`, …) replaces the kit's default\n * `{ path, fill }` node for that kind; a factory for a novel kind (e.g.\n * `text`) adds insert support the kit doesn't ship. The dep supplies id,\n * layer, and the undoable op. Return `null` to reject an insert. */\n insertNodeFactories?: Record<string, InsertNodeFactory>;\n\n /** The fill and stroke a kit-built shape is inserted with, by tool `kind`\n * and insert count; the kit keeps the geometry. Default\n * `paletteInsertPaint`, the kit palette in turn. A kind with a factory in\n * `insertNodeFactories` is not asked. */\n insertPaint?: InsertPaint;\n\n /** External-content ingestion (OS drop / clipboard paste / picker).\n * `handlers` are consumer content handlers registered for this canvas's\n * lifetime (priority 0 by default — they beat the kit's `image/*` /\n * `image/svg+xml` handlers at -100/-90). `resolveSrc` overrides the\n * image handler's `data:`-URI embed (e.g. upload to an asset store,\n * return the URL). `svg.unpack` makes the kit SVG handler parse dropped\n * SVG files into native scene nodes instead of keeping each one a\n * single embedded-image node.\n * `clipboard` configures the kit weasel-JSON paste handler: enabled by\n * default (pastes of weasel clipboard payloads re-materialize through\n * this canvas's adapter); `reviver` restores JSON-unfriendly values the\n * copying side encoded via `jsonReplacer` (typed arrays etc.);\n * `enabled: false` opts the canvas out — but note the kit handler\n * still consumes weasel-matching items at match time; on a disabled\n * canvas it declines inert (a dwarn, nothing ingested) rather than\n * falling through. Only items that never match (non-weasel text)\n * flow on to other handlers.\n * `clipboard` also governs Cmd/Ctrl+V under the `edit` preset; the rest\n * takes the `ingest` preset.\n * Memoize `handlers` (useState/useMemo/module const) — an inline array\n * literal re-registers the handlers on every render. The same applies\n * to `clipboard.reviver`: an inline function identity-churns the\n * memoized clipboard ctx each render (harmless but wasteful). */\n ingestion?: {\n handlers?: ContentHandlerEntry[];\n resolveSrc?: (file: File) => Promise<string>;\n svg?: SvgIngestOptions;\n clipboard?: {\n reviver?: (key: string, value: unknown) => unknown;\n enabled?: boolean;\n /** Called when a paste left copied nodes out, with each one and the\n * reason. `useClipboardOps` takes the same callback as\n * `onPasteOmitted` for a paste from its own in-memory copy. */\n onOmitted?: (omitted: PasteOmission[]) => void;\n };\n };\n\n // --- Selection ---\n selection?: SelectionApi;\n selectionOptions?: UseSelectionOptions;\n\n /**\n * `false` stops the canvas writing the selection: no click, marquee,\n * lasso, action or tool, and no op committed through the adapter it hands\n * its tools. The consumer's own `SelectionApi` — the `selection` prop, or\n * `useSelection({ scene })` — still writes, and the canvas draws what it\n * holds. Undo and redo still restore the selection each history entry\n * recorded. Default `true`.\n *\n * Click policy (whether shift-click extends) is the selection's `mode`:\n * `useSelection({ mode: 'multi' })`, or `selectionOptions={{ mode: 'multi' }}`\n * for the selection the canvas builds itself.\n */\n selectable?: boolean;\n\n /**\n * Behavior presets to turn on, composable in any combination. A canvas\n * with none renders its scene and keeps a selection (the `selection` API\n * works) that no input sets: no tools, no standard actions or their keys,\n * no clipboard, no drop or paste, and no selection chrome. The dispatcher\n * is still mounted, so bindings a consumer adds work.\n *\n * - `view` — wheel pan and zoom, pinch, the zoom keys, and the hand tool\n * (H, or hold Space). Passing `viewport` implies it.\n * - `select` — the select tool, as the initial active tool and Escape's\n * return target: click to pick, drag on empty to marquee, click on empty\n * to clear.\n * - `outline` — the selection outline, whichever tool sets the selection.\n * - `pick` — `select` and `outline`.\n * - `move` — drag a body to move it, Alt-drag to clone it. Ambient, so it\n * runs under any tool that does not claim the drag.\n * - `resize` — resize handles, drawn and bound.\n * - `rotate` — the rotation handle, drawn and bound.\n * - `transform` — `resize` and `rotate`.\n * - `edit` — undo/redo, delete, duplicate, group/ungroup, nudge,\n * select-all, Escape, cancel-gesture, cut/copy/paste, fill and stroke,\n * and their keys. Cmd/Ctrl+V pastes nodes a kit canvas copied, from\n * this tab or another, and nothing else.\n * - `arrange` — align, distribute, reorder, flip.\n * - `paths` — pathfinder operations, path-edit entry and anchor editing.\n * - `ingest` — dropped and pasted content: images, SVG, files, and\n * whatever `ingestion.handlers` accept, on Cmd/Ctrl+V or an OS drop.\n * - `draw` — all of the above.\n *\n * Tools add the actions they bind — a shape tool brings `insert` — so\n * `defaultTools` composes with any preset. `actions` then adds, overrides\n * or removes on top of what the presets registered.\n */\n features?: readonly Feature[];\n\n // --- Tools: extend, override, or take over ---\n /** Extra tools or overrides keyed by id, or a full `ToolsApi` takeover.\n *\n * **Patch form** (`Record<string, AnyTool | true | false>`): merged\n * into the built-in registry on top of whatever `defaultTools` and\n * `features` already selected.\n * - `true` pulls in the built-in for this id (`'pen'`, `'lasso'`,\n * `'hand'`, …), the same as listing it in `defaultTools`. Unknown\n * built-in ids warn in dev and are ignored.\n * - `AnyTool` adds a new id or replaces an existing one\n * (dev-only warning on replace).\n * - `false` omits a bundled tool entirely.\n * Auto-wiring (keybindings, dispatcher, action registry) still runs.\n *\n * **Takeover form** (`ToolsApi`): the internal registry is bypassed and\n * this `tools` value is forwarded to Canvas as-is — the consumer owns\n * active-slot management, and `pick`'s select tool is theirs to supply.\n * Every other preset still applies. Keybindings are still auto-wired\n * against the supplied registry; pass `enableKeybindings={false}` to opt\n * out. */\n tools?: ToolsApi | Record<string, AnyTool | true | false>;\n\n /**\n * Auto-wire keyboard shortcuts. Default `true`. When `false`, SceneCanvas\n * still mounts its tools but routes no keyboard input to them: it neither\n * subscribes the legacy `useKeybindings` hook (tool hotkeys) nor lets the\n * gesture dispatcher attach its `keydown`/`keyup` listeners (modern\n * keyboard-bound actions like delete / escape / nudge). Pointer, wheel, and\n * contextmenu interactions are unaffected. Leaves the consumer free to call\n * `useKeybindings(tools, { ... })` themselves (e.g. with `disable`,\n * `overrides`, or `defaultTool`).\n */\n enableKeybindings?: boolean;\n\n /**\n * Take the keyboard on mount, as a press in the canvas would. A key that\n * reaches the page goes to the canvas the user last pressed or scrolled\n * in, and to no canvas before the first such interaction, so a canvas in a\n * side panel does not take Space from a page that wants it. An app whose\n * canvas is the page sets this so its shortcuts work before the first\n * click. Default `false`.\n */\n claimKeys?: boolean;\n\n /**\n * Auto-mount the gesture dispatcher (`useGestureDispatcher`) inside\n * `<SceneCanvas>`. Default `true`. When `false`, the dispatcher is not\n * wired — useful in tests or demos that drive actions through alternative\n * mechanisms, or that want to call `useGestureDispatcher` themselves.\n *\n * The dispatcher reads registered actions' `defaultBinding` fields and\n * routes matching window keydown / canvas pointer / wheel events to the\n * corresponding `invoker.run` (or `invoker.start` for ongoing gestures).\n */\n enableGestureDispatcher?: boolean;\n\n /**\n * Called once after SceneCanvas constructs (or receives) its\n * `ToolsApi`. Useful for introspection — e.g. the toolkit-builder\n * dev surface walks `tools.registry` to render the live route table.\n * Fires with the consumer-supplied `tools` prop when present, or with\n * the internally-synthesized one otherwise.\n */\n onToolsCreated?: (tools: ToolsApi) => void;\n\n /**\n * Built-in tools SceneCanvas registers in its internal `useTools`, on top\n * of the ones presets bring (`select` from `pick`, `hand` from `view`).\n * Default: none. Each tool also registers the kit actions it binds, so\n * `['rect']` brings `insert`. Ignored when the consumer supplies their own\n * `tools` prop.\n */\n defaultTools?: readonly BuiltinToolId[];\n\n /** Per-tool option overrides for the built-in shape/lasso/clone tools.\n * Each entry is a narrow subset of the underlying hook's options\n * surface — `lasso.mode`, `clone.cloneSelection`, etc. */\n toolOptions?: BuiltinToolOptions;\n\n /** Initial active-slot tool id. Default: `'select'` when it is\n * registered, otherwise none — a canvas can run on ambient bindings\n * alone. Must be one of the registered tools. The lasso demo starts with\n * `initialActiveTool=\"lasso\"`. Ignored when the consumer supplies their\n * own `tools` prop. */\n initialActiveTool?: string;\n\n /** Always-on entries to register alongside the internal tools — every one\n * a `SurfaceContribution`, whose views, deps, overlay, bindings, actions\n * and `attach` all install from this one list, and uninstall when the\n * entry leaves it. A tool is a contribution too, so one can go here. If\n * you supply your own `tools` prop, this is ignored — wire `ambient`\n * through your own `useTools` call instead. */\n ambient?: readonly SurfaceContribution[];\n\n /** What an entry's `requires` does when the running kit does not meet\n * it: `'warn'` (the default) logs in development, `'strict'` throws,\n * `'off'` skips the check. */\n versionCheck?: VersionCheck;\n\n /** Touch and pen long-press: its hold time, its haptic, and the\n * feedback shown while it is held. */\n longPress?: SceneCanvasLongPress;\n\n /** Configures the `view` preset, and implies it: passing this turns\n * `view` on.\n *\n * - `inertia` and `animatedZoom` are opt-in: pass `true` for defaults or\n * an object to tune. Omitted means off.\n * - `pan` (wheel pan), `zoom` (Cmd+wheel + Cmd+=/-/0) and `pinchZoom`\n * (two-finger pinch) are on under `view`; pass `false` to disable one.\n * All three are wired by registering the kit's `viewport.*` action\n * descriptors with the actions registry — disabling via the `actions`\n * prop (`actions: { 'viewport.wheelPan': null }`) also works and runs\n * after this.\n *\n * Without `view`, none of them are wired. */\n viewport?: {\n inertia?: boolean | { friction?: number; minSpeed?: number; boundary?: 'stop' | 'bounce' | 'spring'; bounds?: PanBounds };\n /** Two-finger pinch zoom. `true`/omitted = on with the kit's 0.1–8\n * clamp; `false` disables. An object sets the scale clamp. */\n pinchZoom?: boolean | PinchZoomOptions;\n /** Glide Cmd+=/-/0 instead of jumping. `true` uses the kit defaults\n * (250 ms, ease-out-cubic); a {@link ViewportZoomAnimateOptions} tunes\n * duration, easing, interpolator and the reset-branch duration. Wheel\n * and pinch are unaffected — their input already samples every frame. */\n animatedZoom?: boolean | ViewportZoomAnimateOptions;\n /** Wheel pan. `true`/omitted = on; `false` disables; an object locks the\n * axis (`{ axis: 'x' }`) so a single-axis viewport needs no commit clamp. */\n pan?: boolean | WheelPanOptions;\n /** Wheel/keyboard zoom. `true`/omitted = default Cmd+wheel zoom with the\n * kit's 0.1–8 clamp; `false` disables. Pass a {@link ViewportZoomOptions}\n * object to bind zoom to plain wheel (`wheel: 'plain'`, pair with\n * `pan: false`) and/or set `min`/`max` scale clamps. */\n zoom?: boolean | ViewportZoomOptions;\n /** Callback invoked by Cmd-0 (`viewport.zoom` action's `reset` branch).\n * When supplied, replaces the default reset-to-identity behavior —\n * consumers typically refit the document page into the workspace via\n * `fitViewToBounds`. Return the target `View` to let the kit animate\n * there when `animatedZoom` is on; return nothing to dispatch it\n * yourself, which is what a controlled canvas does. */\n recenter?: () => View | void;\n };\n\n /**\n * @experimental\n * Override / disable / extend the default action set. Resolution rules:\n * see `docs/superpowers/specs/2026-05-09-actions-registry-design.md` §D.\n * Pass `null` to disable all defaults.\n */\n actions?: ActionsProp;\n\n /**\n * @experimental\n * Inputs the kit can't synthesize on its own — currently `cloneNode`\n * for the `duplicate` default. When omitted, the `duplicate` default is\n * silently dropped from the registered set.\n */\n /** @deprecated unused after legacy-bridge removal; will be deleted */\n actionDefaults?: {\n cloneNode?: (id: NodeId, offset: { dx: number; dy: number }) => { id: NodeId };\n /** Per-clone offset for the duplicate default. Default {dx:8,dy:8}. */\n duplicateOffset?: { dx: number; dy: number };\n /** Base nudge step. Default 1. */\n nudgeStep?: number;\n /** Shifted nudge step. Default 10. */\n nudgeShiftStep?: number;\n };\n\n /**\n * @experimental\n * Optional resolver: given a scene node, return a short human-readable\n * \"kind\" label (e.g. `'rectangle'`, `'path'`, `'sticky note'`). When\n * supplied, the kit publishes per-id kinds into any surrounding\n * `<SelectionContextProvider>` so non-canvas UI (palette, status bar)\n * can render type-aware copy. Return `undefined` to skip an entry.\n *\n * Default behavior when omitted: containers report `'group'`, paths\n * (poses with a `kind` property) report `'path'`, everything else is\n * left unlabelled.\n */\n describeKind?: (node: Node<TData, TLayer, TPose>) => string | undefined;\n\n /**\n * Optional animator to bind for per-frame redraws. When supplied,\n * SceneCanvas subscribes to `animator.onTick` and requests a redraw on\n * every active animation frame, and paints `animator.colorOverrides`\n * onto the scene's nodes: the kit's path and shape painters apply them,\n * and a custom `drawOne` receives them as `ctx.vertexColors`. Scene\n * mutations trigger repaints automatically, but `colorOverrides` writes\n * do not.\n *\n * Omit when no animation channel touches the render pipeline; idle\n * frames don't cost anything if no animations are active (the animator's\n * subscriber list stays quiet).\n */\n animator?: Animator;\n\n /**\n * Extra views on this canvas: each is a camera over a rect of the same\n * surface, drawn through one GL context, with input routed to it. The flat\n * `view` / `onViewChange` props above stay the canvas's own camera — view\n * zero — and are unaffected by anything declared here.\n *\n * Order is paint and hit order, low to high. Each entry is a\n * `<CanvasView>`; mounting one as a child is the same declaration, and\n * children land after every entry here.\n */\n views?: readonly CanvasViewProps[];\n\n /**\n * Children rendered alongside the canvas, inside its input scope (e.g.\n * shortcuts overlays, probes).\n */\n children?: ReactNode;\n\n /**\n * A yoke to join, from `useYoke()`: canvases on one yoke share the\n * active tool, the gesture in flight and history. Omitted, this canvas\n * keeps its own.\n */\n yoke?: Yoke;\n\n /**\n * Chrome-caps visibility overrides, keyed by chrome id (`selection.outline`,\n * `selection.rotation-handle`, `gesture.marquee`, …). Each entry is a\n * composable {@link Condition} built from the\n * `cond()` builder. Merged on top of the kit's `defaultVisibilityRules`;\n * unspecified ids fall through to the defaults.\n *\n * Set an id to `never` to suppress a chrome element entirely (also\n * unhittable). Set to `always` to force-show. Mix `cond(...)` chains\n * (e.g. `selectionIs(1).and(focused).andNot(gesturing)`) for the in-\n * between cases.\n */\n chromeVisibility?: import('features/chrome-caps').VisibilityRules;\n\n /**\n * The app's mode registry (`createModeRegistry` in `@weasel-js/modes`).\n * The canvas reads the active mode from it to gate chrome, tool\n * activation and the dispatcher's eligibility filter, repaints when it\n * switches, and hands every registered mode to the dev-time route-conflict\n * check. Omitted, the canvas behaves as the kit's normal mode and nothing\n * revokes anchor editing.\n */\n modes?: ModeRegistry;\n\n /**\n * Override detected device facts. Merged over what `matchMedia` reports;\n * `targetScale` is re-derived from the merged `coarsePointer` unless you\n * override it explicitly.\n *\n * Reach for this in three cases: tests that need a coarse profile without\n * stubbing `matchMedia`, demos that want to show touch-sized chrome on a\n * desktop, and hybrid devices where the media query guesses wrong.\n */\n device?: Partial<DeviceProfile>;\n\n /**\n * Optional live focus getter for chrome-caps' `focused` ctx field.\n * SceneCanvas does not own focus state by default — wire this when\n * your visibility rules read the `focused` atom (e.g. the kit's\n * default `selection.rotation-handle` rule requires focus). Omit\n * to default `focused` to `true` (rule fires regardless of focus).\n */\n getFocused?: () => boolean;\n\n /**\n * Custom shader programs to compile on the renderer. Forwarded directly\n * to `<Canvas shaders={...} />`. See `CanvasProps.shaders` for details.\n */\n shaders?: ShaderProgramHandle[];\n\n /**\n * Flatness tolerance for curve tessellation, in world units. Forwarded\n * directly to `<Canvas flattenTolerance={...} />`. See\n * `CanvasProps.flattenTolerance` for details.\n */\n flattenTolerance?: number;\n\n /**\n * FillStyle applied to the full canvas behind the scene. Accepts the kit's\n * `FillStyle` union (solid / pattern / linear-gradient / radial-gradient /\n * conic-gradient) so consumers don't have to author a background node\n * just to colorize the canvas. Rendered as a screen-space layer slotted\n * before `'scene'` — independent of pan / zoom.\n */\n backgroundFill?: FillStyle;\n /**\n * Dev HUD: when true, mounts a fixed-position widget in the top-left\n * of the viewport showing live cursor coords in both viewport\n * (client) and canvas (world) frames. Useful for diagnosing pointer-\n * coord drift / pan-zoom misalignment without instrumenting events.\n */\n cursorCoordsHud?: boolean;\n /**\n * Dev HUD: when true, mounts a fixed-position widget just below the\n * cursor-coords HUD listing the ids returned by `pickEvery(world)`\n * under the cursor. Useful for diagnosing hit-test order and\n * container/leaf overlap during select-tool work.\n */\n pickHud?: boolean;\n /**\n * The debug overlay: `<Canvas debug>`'s config, plus `slops: true` for\n * translucent halos at every affordance hit zone. `false` turns it off;\n * absent reads `?debug=…` from the URL, as `<Canvas>` does.\n */\n debug?: (DebugConfig & { slops?: boolean }) | false;\n /**\n * Dev HUD: when true (or object), mounts a fixed-position widget below\n * the pick HUD showing the active modality mode, active-slot tool, and\n * hotkey stack. Pass `{ modeId }` to populate the mode line.\n */\n modalityHud?: boolean | { modeId?: string };\n\n /**\n * Optional per-id alpha multiplier for the scene-render slot. When\n * supplied, each node's draw output is wrapped in a `GroupDrawCommand`\n * with the returned alpha so the renderer applies the multiplier.\n * Values equal to 1 are a no-op (no wrapper emitted). Typical use:\n * scoping-dim integration dims non-active nodes during a mode transition.\n *\n * Defaults to `() => 1` (no effect).\n */\n alphaFor?: (id: string) => number;\n\n /**\n * Show or hide render layers in this canvas's own view, by id — the map\n * `<Canvas>` takes. Each scene layer paints as its own render layer, keyed\n * `scene:<layerId>`, so `{ 'scene:guides': false }` hides one scene layer\n * here and nowhere else.\n *\n * A layer hidden this way is gone from this view: it does not paint, and a\n * click, a marquee or Cmd+A here passes over it. Another view of the same\n * scene — a `<CanvasView>`, a second canvas, a minimap — still shows it and\n * can still take it. It applies on top of the scene's own\n * `LayerRecord.visible` and cannot show a layer the scene hides.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order for this view, by render-layer id, bottom first. A listed\n * order is the whole list: a scene layer left out of it is neither painted\n * nor picked here. See `CanvasProps.layerOrder`.\n */\n layerOrder?: string[];\n\n /**\n * Optional per-id pointer-interactivity predicate. When supplied, ids\n * for which the predicate returns `false` are excluded from hit-test\n * results — `getNodeAtPoint` returns null for those positions.\n * Typical use: scoping-dim integration suppresses pointer events for\n * non-active nodes during a mode transition.\n *\n * Defaults to `() => true` (all nodes are interactive).\n */\n isPointerInteractive?: (id: string) => boolean;\n\n /**\n * Called when the user double-clicks the canvas. Receives the hit node\n * (id + kind) at the double-click position, or `null` when the click\n * lands on empty canvas. Wired internally via a `dblclick` listener on\n * the canvas element so it doesn't interfere with the pointer-gesture\n * pipeline.\n *\n * Typical use: modality dispatch — enter path-edit on a path node,\n * isolation on a group, text-edit on a text node.\n */\n onDoubleClick?: (hit: SceneCanvasHit | null) => void;\n /** Called on every click — a press and release without a drag — with the\n * node under it, or `null` on empty canvas. Fires after the click's own\n * behavior, so a pick it made is already in the selection, and fires\n * again on a node that was already picked. */\n onClick?: (hit: SceneCanvasHit | null) => void;\n };\n"],"mappings":";;;;;AAyEA,IAAaA,IAAsBC;AAkDnC,SAAgBC,EACd,GACA,IAAc,GACgC;CAC9C,IAAMC,IAAW;EACf,OAAO;GACL,SAASC;GAIT,aAAaC;EACf;EACA,kBAAkB,EAAE,SAAS,EAAE,MAAMC,EAAcC,CAAW,CAAC,CAAC,OAAO,EAAE;CAC3E;CAEA,IAAI,CAACC,GAAM,OAAOL;CAGlB,IAAMM,IAAS,EAAE,GAAGD,EAAK;CAEzB,IAAI,EAAE,WAAWA,IACf,EAAO,QAAQL,EAAS;MACnB,IAAIK,EAAK,UAAU,MACxB,EAAO,QAAQ;MACV;EACL,IAAME,IAAQ;GAAE,GAAGP,EAAS;GAAO,GAAGK,EAAK;EAAM;EACjD,EAAO,QAAQA,EAAK,SAAS,iBAAiBA,EAAK,QAC/CE,IACA;GAAE,GAAGA;GAAO,aAAaC,EAAqCD,EAAM,OAAO;EAAE;CACnF;CAUA,OARA,AACED,EAAO,mBADH,sBAAsBD,IAEjBA,EAAK,qBAAqB,OACT,OAEA;EAAE,GAAGL,EAAS;EAAkB,GAAGK,EAAK;CAAiB,IAJzDL,EAAS,kBAO9BM;AACT;AAQA,IAAaG,IAAiF,CAAC,UAAU,MAAM,GAGlGC,IAA6C,CAAC,GAAGD,GAAyB,GAAGE,CAAe"}
|
|
@@ -1,70 +1,29 @@
|
|
|
1
|
-
import { asNodeId as e } from "../../core/scene/types.js";
|
|
2
1
|
import "../../core/shapeKinds.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { usePencilTool as f } from "../../tools/builtin/pencil/usePencilTool.js";
|
|
13
|
-
import { boundsOfPath as p } from "@weasel-js/geom";
|
|
14
|
-
import { useRef as m } from "react";
|
|
2
|
+
import { useTextTool as e } from "../../tools/builtin/text/useTextTool.js";
|
|
3
|
+
import { usePenTool as t } from "../../tools/builtin/pen/usePenTool.js";
|
|
4
|
+
import { useRectTool as n } from "../../tools/builtin/rect/useRectTool.js";
|
|
5
|
+
import { useEllipseTool as r } from "../../tools/builtin/ellipse/useEllipseTool.js";
|
|
6
|
+
import { useLineTool as i } from "../../tools/builtin/line/useLineTool.js";
|
|
7
|
+
import { useLassoTool as a } from "../../tools/builtin/lasso/useLassoTool.js";
|
|
8
|
+
import { usePolygonTool as o } from "../../tools/builtin/polygon/usePolygonTool.js";
|
|
9
|
+
import { useStarTool as s } from "../../tools/builtin/star/useStarTool.js";
|
|
10
|
+
import { usePencilTool as c } from "../../tools/builtin/pencil/usePencilTool.js";
|
|
15
11
|
//#region src/canvas/SceneCanvas/useBuiltinShapeTools.tsx
|
|
16
|
-
function
|
|
17
|
-
let {
|
|
18
|
-
id: e,
|
|
19
|
-
kind: "leaf",
|
|
20
|
-
layer: S(),
|
|
21
|
-
pose: t,
|
|
22
|
-
data: n,
|
|
23
|
-
parent: null
|
|
24
|
-
}), w = v?.snapPoint, T = v?.insert ?? {}, E = o(T), D = s(T), O = c(T), k = u(T), A = d(T), j = f(T), M = (e) => {
|
|
25
|
-
let t = b("pn"), i = x();
|
|
26
|
-
return C(t, e.bounds, {
|
|
27
|
-
path: e.path,
|
|
28
|
-
fill: e.closed ? n(x()) : null,
|
|
29
|
-
stroke: r(i, 2)
|
|
30
|
-
});
|
|
31
|
-
};
|
|
12
|
+
function l(l = {}) {
|
|
13
|
+
let { options: u } = l, d = u?.snapPoint, f = u?.insert ?? {}, p = n(f), m = r(f), h = i(f), g = o(f), _ = s(f), v = c(f);
|
|
32
14
|
return {
|
|
33
|
-
rect:
|
|
34
|
-
ellipse:
|
|
35
|
-
line:
|
|
36
|
-
polygon:
|
|
37
|
-
star:
|
|
38
|
-
pen:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
path: e,
|
|
44
|
-
closed: t,
|
|
45
|
-
bounds: {
|
|
46
|
-
x: n.x,
|
|
47
|
-
y: n.y,
|
|
48
|
-
width: n.width,
|
|
49
|
-
height: n.height
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
adapter: {
|
|
54
|
-
addNode: (e) => {
|
|
55
|
-
let t = M(e);
|
|
56
|
-
return _.insertNode(t), String(t.id);
|
|
57
|
-
},
|
|
58
|
-
makeNode: (e) => M(e),
|
|
59
|
-
setSelection: (e) => _.setSelection(e)
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
pencil: j,
|
|
63
|
-
lasso: l(_, v?.lasso ?? {}),
|
|
64
|
-
text: i(T)
|
|
15
|
+
rect: p,
|
|
16
|
+
ellipse: m,
|
|
17
|
+
line: h,
|
|
18
|
+
polygon: g,
|
|
19
|
+
star: _,
|
|
20
|
+
pen: t({ snapPoint: d }),
|
|
21
|
+
pencil: v,
|
|
22
|
+
lasso: a(u?.lasso ?? {}),
|
|
23
|
+
text: e(f)
|
|
65
24
|
};
|
|
66
25
|
}
|
|
67
26
|
//#endregion
|
|
68
|
-
export {
|
|
27
|
+
export { l as useBuiltinShapeTools };
|
|
69
28
|
|
|
70
29
|
//# sourceMappingURL=useBuiltinShapeTools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuiltinShapeTools.js","names":["useBuiltinShapeTools","args","
|
|
1
|
+
{"version":3,"file":"useBuiltinShapeTools.js","names":["useBuiltinShapeTools","args","snapPoint","options","insert","rect","useRectTool","ellipse","useEllipseTool","line","useLineTool","polygon","usePolygonTool","star","useStarTool","pencil","usePencilTool","usePenTool","useLassoTool","useTextTool"],"sources":["../../../src/canvas/SceneCanvas/useBuiltinShapeTools.tsx"],"sourcesContent":["/**\n * Shape-tool synthesis for `<SceneCanvas>` — calls the kit's per-shape tool\n * hooks; the `insert` dep mints each tool's node. Lets consumers opt into\n * a complete drawing toolset via `<SceneCanvas defaultTools={['rect', 'ellipse']}>`\n * without writing per-tool factory code.\n *\n * All hooks are always called (React rules of hooks) — `<SceneCanvas>` only\n * registers the ones requested via `defaultTools`.\n */\nimport { useEllipseTool } from 'tools/builtin/ellipse/useEllipseTool';\nimport { useLassoTool } from 'tools/builtin/lasso/useLassoTool';\nimport { useLineTool } from 'tools/builtin/line/useLineTool';\nimport { usePencilTool } from 'tools/builtin/pencil/usePencilTool';\nimport { usePenTool } from 'tools/builtin/pen/usePenTool';\nimport { usePolygonTool } from 'tools/builtin/polygon/usePolygonTool';\nimport { useRectTool } from 'tools/builtin/rect/useRectTool';\nimport { useStarTool } from 'tools/builtin/star/useStarTool';\nimport { useTextTool } from 'tools/builtin/text/useTextTool';\nimport type { AnyTool } from 'tools/overlayBinding';\nimport type { InsertToolOptions } from 'tools/builtin/shared/insertToolOptions';\nimport type { LassoHitMode } from 'core/adapters/types';\nimport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\n/** Per-tool option overrides for the built-in shape/lasso tools.\n * Each entry is a narrow subset of the underlying hook's options surface\n * — just the knobs that need consumer control under the bundle pattern. */\nexport interface BuiltinToolOptions {\n lasso?: { mode?: LassoHitMode };\n /** Insert-action options for every drag-to-insert tool (rect / ellipse /\n * line / polygon / star / pencil / text): `behaviors` become each insert\n * binding's `opts.behaviors`, the way `selectTool.move.behaviors` do for\n * move. */\n insert?: InsertToolOptions;\n /** Snap world-space points to the active grid (or any other snap target).\n *\n * Registered as the `snap` dep, which `insertAction` applies to the\n * drag start and current point — so the live preview and the committed\n * geometry agree — and which the pen tool reads for its own anchor\n * placement. Covers every drag-to-insert tool (rect / ellipse / line /\n * polygon / star / text); freehand pencil samples are deliberately left\n * unsnapped. */\n snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };\n}\n\n// `BuiltinShapeToolId` / `KIT_SHAPE_KINDS` derive from the `core/shapeKinds`\n// table, a dependency-free module, so barrel-reachable code can reach them\n// without entering this file's `@weasel-js/core` self-import cycle.\n// Re-exported here so existing importers of this module keep working.\nexport { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nexport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\nexport interface UseBuiltinShapeToolsArgs {\n /** Per-tool option overrides (lasso mode, etc.). */\n options?: BuiltinToolOptions;\n}\n\nexport type BuiltinShapeTools = Record<BuiltinShapeToolId, AnyTool>;\n\n/** Synthesize the full shape-tool registry. Hooks always run; consumers\n * decide via `wants(...)` which to register with `useTools`. */\nexport function useBuiltinShapeTools(args: UseBuiltinShapeToolsArgs = {}): BuiltinShapeTools {\n const { options } = args;\n\n const snapPoint = options?.snapPoint;\n // Every tool here is a declarative shell: the `insert` dep\n // (`useInsertDepSource`) mints the node, so a consumer wanting its own node\n // shape overrides the dep, not the tool.\n const insert = options?.insert ?? {};\n const rect = useRectTool(insert);\n const ellipse = useEllipseTool(insert);\n const line = useLineTool(insert);\n const polygon = usePolygonTool(insert);\n const star = useStarTool(insert);\n const pencil = usePencilTool(insert);\n const pen = usePenTool({ snapPoint });\n const lasso = useLassoTool(options?.lasso ?? {});\n const text = useTextTool(insert);\n return { rect, ellipse, line, polygon, star, pen, pencil, lasso, text };\n}\n"],"mappings":";;;;;;;;;;;AA4DA,SAAgBA,EAAqB,IAAiC,CAAC,GAAsB;CAC3F,IAAM,EAAE,eAAYC,GAEdC,IAAYC,GAAS,WAIrBC,IAASD,GAAS,UAAU,CAAC,GAC7BE,IAAOC,EAAYF,CAAM,GACzBG,IAAUC,EAAeJ,CAAM,GAC/BK,IAAOC,EAAYN,CAAM,GACzBO,IAAUC,EAAeR,CAAM,GAC/BS,IAAOC,EAAYV,CAAM,GACzBW,IAASC,EAAcZ,CAAM;CAInC,OAAO;EAAE;EAAM;EAAS;EAAM;EAAS;EAAM,KAHjCa,EAAW,EAAE,aAAU,CAGU;EAAK;EAAQ,OAF5CC,EAAaf,GAAS,SAAS,CAAC,CAEY;EAAO,MADpDgB,EAAYf,CACwC;CAAK;AACxE"}
|