@weasel-js/core 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +427 -0
- package/README.md +1 -1
- package/dist/animation/index.js +3 -3
- package/dist/animation/rig/bindRig.js +1 -1
- package/dist/animation/rig/rigNode.js.map +1 -1
- package/dist/barrel/canvas.js +7 -3
- package/dist/barrel/interactions.js +5 -4
- package/dist/barrel/paths.js +3 -3
- package/dist/barrel/renderer.js +3 -2
- package/dist/barrel/routing.js +6 -11
- package/dist/barrel/scene.js +8 -5
- package/dist/barrel/viewport.js +4 -3
- package/dist/canvas/Canvas.js +3 -1
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js +17 -3
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
- package/dist/canvas/SceneCanvas/builtinToolSets.js +30 -0
- package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js +1 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
- package/dist/canvas/SceneCanvas/coordTrace.js +5 -16
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +5 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +45 -5
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js +1 -11
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/toolRegistry.js +8 -4
- package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -1
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +1 -11
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinTools.js +2 -9
- package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js +93 -0
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js +7 -2
- package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasTools.js +8 -8
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useNodeKinds.js +1 -1
- package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +13 -2
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +1 -3
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneChrome.js +6 -7
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +5 -3
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useScenePicking.js +2 -3
- package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +2 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +3 -4
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +16 -14
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SurfaceCanvas.js +5 -22
- package/dist/canvas/SurfaceCanvas.js.map +1 -1
- package/dist/canvas/canvasRenderer.js +9 -5
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/contextAttributes.js +14 -0
- package/dist/canvas/contextAttributes.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +9 -113
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/insert.js +4 -2
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/pathEditCommits.js +193 -0
- package/dist/canvas/deps/pathEditCommits.js.map +1 -0
- package/dist/canvas/deps/snap.js +12 -9
- package/dist/canvas/deps/snap.js.map +1 -1
- package/dist/canvas/deps/transformFollowers.js +20 -0
- package/dist/canvas/deps/transformFollowers.js.map +1 -0
- package/dist/canvas/derivedPath.js +20 -1
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/drawnBounds.js +29 -3
- package/dist/canvas/drawnBounds.js.map +1 -1
- package/dist/canvas/nodeShapes/derivedPainter.js +9 -1
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/pathPainter.js +3 -2
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/shapePainter.js +1 -1
- package/dist/canvas/overlayRoleStrokes.js +12 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/pathOverlay.js +27 -7
- package/dist/canvas/pathOverlay.js.map +1 -1
- package/dist/canvas/renderDebugSnapshot.js +1 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -1
- package/dist/canvas/renderSceneToPixels.js +6 -5
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/useCanvasPaint.js +2 -1
- package/dist/canvas/useCanvasPaint.js.map +1 -1
- package/dist/canvas/useInFlightBounds.js +52 -0
- package/dist/canvas/useInFlightBounds.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +7 -9
- package/dist/canvas/useViewHelpers.js.map +1 -1
- package/dist/clipboard.d.ts +3 -2
- package/dist/{clone-DZDrfIlU.d.ts → clone-C3e0OTuF.d.ts} +8 -21
- package/dist/clone.d.ts +4 -3
- package/dist/core/geometry/autoPoseDescriptor.js +1 -1
- package/dist/core/ops/setDependsOn.js +37 -0
- package/dist/core/ops/setDependsOn.js.map +1 -0
- package/dist/core/ops/writtenBy.js +53 -0
- package/dist/core/ops/writtenBy.js.map +1 -0
- package/dist/core/pages/fitViewToPage.js +12 -1
- package/dist/core/pages/fitViewToPage.js.map +1 -1
- package/dist/core/pages/pageEdits.js +164 -0
- package/dist/core/pages/pageEdits.js.map +1 -0
- package/dist/core/pages/pages.js +30 -1
- package/dist/core/pages/pages.js.map +1 -1
- package/dist/core/scene/NodeRouting.js +8 -3
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/arrivalWindow.js.map +1 -1
- package/dist/core/scene/carryDescendants.js +51 -0
- package/dist/core/scene/carryDescendants.js.map +1 -0
- package/dist/core/scene/docValues.js +57 -0
- package/dist/core/scene/docValues.js.map +1 -0
- package/dist/core/scene/editPass.js +111 -0
- package/dist/core/scene/editPass.js.map +1 -0
- package/dist/core/scene/effectivePose.js +7 -1
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +4 -1
- package/dist/core/scene/fieldEdits.js.map +1 -1
- package/dist/core/scene/historyFacade.js +1 -0
- package/dist/core/scene/historyFacade.js.map +1 -1
- package/dist/core/scene/layoutPass.js +28 -3
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/recorder.js +28 -19
- package/dist/core/scene/recorder.js.map +1 -1
- package/dist/core/scene/scene.js +15 -9
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneChanges.js +13 -0
- package/dist/core/scene/sceneChanges.js.map +1 -0
- package/dist/core/scene/sceneEdits.js +8 -1
- package/dist/core/scene/sceneEdits.js.map +1 -1
- package/dist/core/scene/sceneMutators.js +1 -0
- package/dist/core/scene/sceneMutators.js.map +1 -1
- package/dist/core/scene/sceneRecording.js +20 -3
- package/dist/core/scene/sceneRecording.js.map +1 -1
- package/dist/core/scene/sceneSelection.js +4 -1
- package/dist/core/scene/sceneSelection.js.map +1 -1
- package/dist/core/scene/sceneState.js +11 -5
- package/dist/core/scene/sceneState.js.map +1 -1
- package/dist/core/scene/serialization.js +5 -3
- package/dist/core/scene/serialization.js.map +1 -1
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/unitScopes.js +19 -1
- package/dist/core/scene/unitScopes.js.map +1 -1
- package/dist/core/selection/usePublishSceneSelection.js +6 -12
- package/dist/core/selection/usePublishSceneSelection.js.map +1 -1
- package/dist/core/shapeKinds.js +25 -11
- package/dist/core/shapeKinds.js.map +1 -1
- package/dist/{cornerHandles-Camw_yeu.d.ts → cornerHandles-BHuoMs1o.d.ts} +1 -1
- package/dist/debug/createDebugOverlayLayer.js +16 -111
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/createDebugSink.js +2 -1
- package/dist/debug/createDebugSink.js.map +1 -1
- package/dist/debug/defaultTheme.js +4 -2
- package/dist/debug/defaultTheme.js.map +1 -1
- package/dist/debug/features.js +17 -0
- package/dist/debug/features.js.map +1 -0
- package/dist/debug/overlayPanels.js +117 -0
- package/dist/debug/overlayPanels.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +4 -13
- package/dist/debug/parseDebugFlags.js.map +1 -1
- package/dist/{depSchema-Cgfu_G9s.d.ts → depSchema-BpZNOv7q.d.ts} +114 -892
- package/dist/devtools/handlers.js +112 -0
- package/dist/devtools/handlers.js.map +1 -0
- package/dist/devtools/history.js +71 -0
- package/dist/devtools/history.js.map +1 -0
- package/dist/devtools/hook.js +74 -0
- package/dist/devtools/hook.js.map +1 -0
- package/dist/devtools/label.js +25 -0
- package/dist/devtools/label.js.map +1 -0
- package/dist/devtools/notices.js +58 -0
- package/dist/devtools/notices.js.map +1 -0
- package/dist/devtools/protocol.js +7 -0
- package/dist/devtools/protocol.js.map +1 -0
- package/dist/devtools/registry.js +90 -0
- package/dist/devtools/registry.js.map +1 -0
- package/dist/devtools/root.js +80 -0
- package/dist/devtools/root.js.map +1 -0
- package/dist/devtools/serialize.js +86 -0
- package/dist/devtools/serialize.js.map +1 -0
- package/dist/devtools/session.js +111 -0
- package/dist/devtools/session.js.map +1 -0
- package/dist/devtools/transport.js +67 -0
- package/dist/devtools/transport.js.map +1 -0
- package/dist/devtools/useDevtoolsRoot.js +81 -0
- package/dist/devtools/useDevtoolsRoot.js.map +1 -0
- package/dist/devtools-protocol.d.ts +435 -0
- package/dist/devtools-protocol.js +7 -0
- package/dist/devtools.d.ts +8 -0
- package/dist/devtools.js +12 -0
- package/dist/devtools.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +16 -10
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +25 -2
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/measure/measureCommands.js +7 -5
- package/dist/features/measure/measureCommands.js.map +1 -1
- package/dist/features/paths/index.js +2 -2
- package/dist/features/paths/pathEditExtension.js.map +1 -1
- package/dist/features/paths/pathSnap/pathSnapSource.js +5 -5
- package/dist/features/paths/pathSnap/pathSnapSource.js.map +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js +10 -3
- package/dist/features/paths/pathSnap/sceneIndex.js.map +1 -1
- package/dist/features/selection/selectionPose.js +4 -1
- package/dist/features/selection/selectionPose.js.map +1 -1
- package/dist/features/snap/gather.js +9 -1
- package/dist/features/snap/gather.js.map +1 -1
- package/dist/features/snap/lazySession.js +17 -0
- package/dist/features/snap/lazySession.js.map +1 -0
- package/dist/features/snap/marks.js.map +1 -1
- package/dist/features/snap/probes2d.js +27 -19
- package/dist/features/snap/probes2d.js.map +1 -1
- package/dist/features/snap/readoutLayer.js.map +1 -1
- package/dist/features/snap/roles.js +2 -1
- package/dist/features/snap/roles.js.map +1 -1
- package/dist/features/snap/rotationSource.js +25 -8
- package/dist/features/snap/rotationSource.js.map +1 -1
- package/dist/features/snap/sceneSession2d.js +6 -4
- package/dist/features/snap/sceneSession2d.js.map +1 -1
- package/dist/features/snap/session2d.js +37 -23
- package/dist/features/snap/session2d.js.map +1 -1
- package/dist/features/snap/spanSnap.js +5 -2
- package/dist/features/snap/spanSnap.js.map +1 -1
- package/dist/icons.table.js +1 -1
- package/dist/icons.table.js.map +1 -1
- package/dist/icons.table.json +0 -10
- package/dist/index.d.ts +701 -696
- package/dist/index.js +35 -29
- package/dist/interactions/actions/align/action.js +6 -4
- package/dist/interactions/actions/align/action.js.map +1 -1
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/action.js +7 -1
- package/dist/interactions/actions/booleans/action.js.map +1 -1
- package/dist/interactions/actions/clone/action.js +1 -1
- package/dist/interactions/actions/clone/behaviors.js +4 -4
- package/dist/interactions/actions/clone/behaviors.js.map +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
- package/dist/interactions/actions/defaults/createPaintAction.js +1 -1
- package/dist/interactions/actions/defaults/delete.js +48 -39
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +1 -1
- package/dist/interactions/actions/defaults/group.js +2 -2
- package/dist/interactions/actions/defaults/ingest.js +7 -5
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +13 -38
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/distribute/action.js +6 -4
- package/dist/interactions/actions/distribute/action.js.map +1 -1
- package/dist/interactions/actions/drawnBoxes.js +2 -1
- package/dist/interactions/actions/drawnBoxes.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/action.js +3 -6
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/preview.js +41 -8
- package/dist/interactions/actions/edit-anchors/preview.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +6 -4
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/gestureLifecycle.js +5 -2
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +1 -2
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/commit.js +1 -1
- package/dist/interactions/actions/insert/parent.js +11 -0
- package/dist/interactions/actions/insert/parent.js.map +1 -0
- package/dist/interactions/actions/insert/placeAction.js +7 -2
- package/dist/interactions/actions/insert/placeAction.js.map +1 -1
- package/dist/interactions/actions/insert/session.js +5 -1
- package/dist/interactions/actions/insert/session.js.map +1 -1
- package/dist/interactions/actions/move/action.js +8 -4
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/layoutDrop.js +0 -1
- package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +1 -1
- package/dist/interactions/actions/move/capture.js +1 -1
- package/dist/interactions/actions/move/commit/index.js +0 -2
- package/dist/interactions/actions/move/commit/index.js.map +1 -1
- package/dist/interactions/actions/move/commit/layoutDrop.js +2 -2
- package/dist/interactions/actions/move/commit/layoutRelease.js +2 -2
- package/dist/interactions/actions/move/commit/reparent.js +11 -5
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
- package/dist/interactions/actions/move/frame.js +4 -10
- package/dist/interactions/actions/move/frame.js.map +1 -1
- package/dist/interactions/actions/move/landedDescendants.js +20 -17
- package/dist/interactions/actions/move/landedDescendants.js.map +1 -1
- package/dist/interactions/actions/move/layout/container.js +2 -1
- package/dist/interactions/actions/move/layout/container.js.map +1 -1
- package/dist/interactions/actions/move/layout/dragged.js +1 -1
- package/dist/interactions/actions/move/layout/dropPass.js +18 -1
- package/dist/interactions/actions/move/layout/dropPass.js.map +1 -1
- package/dist/interactions/actions/move/layout/exits.js +5 -5
- package/dist/interactions/actions/move/layout/exits.js.map +1 -1
- package/dist/interactions/actions/move/session.js +14 -3
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/move/translate.js +8 -37
- package/dist/interactions/actions/move/translate.js.map +1 -1
- package/dist/interactions/actions/moveNodes.js +87 -0
- package/dist/interactions/actions/moveNodes.js.map +1 -0
- package/dist/interactions/actions/planeInput.js.map +1 -1
- package/dist/interactions/actions/resize/action.js +83 -72
- package/dist/interactions/actions/resize/action.js.map +1 -1
- package/dist/interactions/actions/resize/commit.js +2 -1
- package/dist/interactions/actions/resize/commit.js.map +1 -1
- package/dist/interactions/actions/resize/session.js +2 -0
- package/dist/interactions/actions/resize/session.js.map +1 -1
- package/dist/interactions/actions/resolvePreviews.js +3 -3
- package/dist/interactions/actions/resolvePreviews.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +7 -4
- package/dist/interactions/actions/rotate/action.js.map +1 -1
- package/dist/interactions/actions/rotate/commit.js +2 -1
- package/dist/interactions/actions/rotate/commit.js.map +1 -1
- package/dist/interactions/actions/rotate/session.js +2 -0
- package/dist/interactions/actions/rotate/session.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +13 -2
- package/dist/interactions/actions/selectionSubtree.js.map +1 -1
- package/dist/interactions/actions/testUtils.js.map +1 -1
- package/dist/interactions/actions/transform-again/action.js +5 -6
- package/dist/interactions/actions/transform-again/action.js.map +1 -1
- package/dist/interactions/actions/transformFinish.js +106 -0
- package/dist/interactions/actions/transformFinish.js.map +1 -0
- package/dist/kitSettingsSchema.js +0 -4
- package/dist/kitSettingsSchema.js.map +1 -1
- package/dist/move.d.ts +5 -4
- package/dist/{options-p9GZMXbY.d.ts → options-DBxEryYq.d.ts} +1 -1
- package/dist/resize.d.ts +4 -3
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +2 -2
- package/dist/test-hook/createTestHook.js +1 -1
- package/dist/test-hook/createTestHook.js.map +1 -1
- package/dist/test-hook/useTestHook.js +2 -1
- package/dist/test-hook/useTestHook.js.map +1 -1
- package/dist/test-seams.d.ts +9 -5
- package/dist/tools/builtin/pen/penHandle.js +3 -5
- package/dist/tools/builtin/pen/penHandle.js.map +1 -1
- package/dist/tools/index.js +26 -0
- package/dist/{types-CHVXGfYm.d.ts → types-7puAuVD2.d.ts} +3 -262
- package/dist/types-BN9hbdMI.d.ts +184 -0
- package/dist/types-CniVctmk.d.ts +949 -0
- package/dist/types-oFeQ5VjV.d.ts +264 -0
- package/dist/version.js +1 -1
- package/package.json +35 -25
- package/dist/canvas/SceneCanvas/useBuiltinRigTools.js +0 -65
- package/dist/canvas/SceneCanvas/useBuiltinRigTools.js.map +0 -1
- package/dist/tools/builtin/bone/boneActions.js +0 -156
- package/dist/tools/builtin/bone/boneActions.js.map +0 -1
- package/dist/tools/builtin/bone/boneOverlay.js +0 -71
- package/dist/tools/builtin/bone/boneOverlay.js.map +0 -1
- package/dist/tools/builtin/bone/placedRig.js +0 -28
- package/dist/tools/builtin/bone/placedRig.js.map +0 -1
- package/dist/tools/builtin/bone/rigEditState.js +0 -30
- package/dist/tools/builtin/bone/rigEditState.js.map +0 -1
- package/dist/tools/builtin/bone/useBoneTool.js +0 -125
- package/dist/tools/builtin/bone/useBoneTool.js.map +0 -1
- package/dist/tools/builtin/weight/useWeightTool.js +0 -101
- package/dist/tools/builtin/weight/useWeightTool.js.map +0 -1
- package/dist/tools/builtin/weight/weightActions.js +0 -140
- package/dist/tools/builtin/weight/weightActions.js.map +0 -1
- package/dist/tools/builtin/weight/weightOverlay.js +0 -78
- package/dist/tools/builtin/weight/weightOverlay.js.map +0 -1
|
@@ -59,8 +59,7 @@ var insertAction = inPlane({
|
|
|
59
59
|
const live = ctx.deps.insertLive;
|
|
60
60
|
if (live) live.gesture = gesture;
|
|
61
61
|
const scene = ctx.deps.scene;
|
|
62
|
-
const
|
|
63
|
-
const copies = scene ? copiesWithin(scene, into, scenePaintedPoseOf(scene)) : [];
|
|
62
|
+
const copies = scene ? copiesWithin(scene, session.parent, scenePaintedPoseOf(scene)) : [];
|
|
64
63
|
return {
|
|
65
64
|
kind: "insert",
|
|
66
65
|
onMove(moveCtx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/insert/action.ts"],"sourcesContent":["import type { Action
|
|
1
|
+
{"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/insert/action.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { InvocationCtx, OngoingHandle, BindingOpts, OngoingOverlay } from '@weasel-js/routing';\nimport { resolveParams } from '@weasel-js/routing';\nimport { shapeKindInfo } from 'core/shapeKinds';\nimport type { KitInsertShape } from 'core/shapeKinds';\nimport { SNAP_ROLES } from 'features/snap/roles';\nimport { runBehaviorSettled } from '../gestureLifecycle';\nimport { inPlane, insertLayer } from '../planeInput';\nimport { copiesWithin } from 'canvas/copiesAbove';\nimport { scenePaintedPoseOf } from 'canvas/derivedPath';\nimport { cancelInsert, commitInsert } from './commit';\nimport { carryStart, nextFrame } from './frame';\nimport type { InsertLiveGesture } from './live';\nimport { beginInsert } from './session';\nimport { insertKind, insertShape } from './shape';\n\n/**\n * Drag-to-insert. The node `kind` is read from `opts.params.kind`.\n *\n * The drag's start and current point snap through the `snap` dep's `point`\n * sessions (never freehand pencil samples). While `snap.constrain` (Shift) is\n * held, a line's end stays on the 15° line through the snapped start nearest\n * the pointer, and lands where that line meets a target. Behaviors from the\n * binding's `opts.behaviors` (`InsertBehavior[]`) run over the two points\n * after that; on release the first answer wins (`null` aborts, `Op[]` commits\n * in place of the insert).\n *\n * The new node has no scene id until commit, so the live preview is the\n * `overlay()` surface with `kind: 'insertPreview'`. A consumer-defined kind\n * the kit cannot draw skips the preview and still commits on release.\n */\nexport const insertAction: Action & { requires: string[] } = inPlane({\n id: 'insert',\n label: 'Insert',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n modifierRoles: SNAP_ROLES,\n requires: ['insert', 'insertLive', 'insertInto', 'selection', 'snap', 'textEdit', 'scene', 'applyOps', 'view', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const begun = beginInsert(ctx, opts);\n if (!begun) return {};\n const { session, readers } = begun;\n let frame = begun.frame;\n const gesture: InsertLiveGesture = { open: true, userRotation: 0, repositioning: false };\n const live = ctx.deps.insertLive;\n if (live) live.gesture = gesture;\n // Where the shape will land decides the copies it will be drawn in.\n const scene = ctx.deps.scene;\n const copies = scene ? copiesWithin(scene, session.parent, scenePaintedPoseOf(scene)) : [];\n\n return {\n kind: 'insert',\n onMove(moveCtx: InvocationCtx): void {\n if (gesture.repositioning) carryStart(session, frame.pointer, moveCtx.world, moveCtx);\n frame = nextFrame(session, readers, frame, moveCtx);\n },\n overlay(): OngoingOverlay | null {\n if (!gesture.open) return null;\n // Resolve params on every overlay() so thunked params (polygon\n // sides ticking via ArrowUp mid-drag) reflect in the live preview.\n const resolved = resolveParams(session.opts?.params);\n if (!shapeKindInfo(insertKind(resolved))?.insertPreview) return null;\n const { bounds, extras, start } = insertShape(resolved, frame, frame.points, gesture.userRotation);\n return {\n kind: 'insertPreview',\n shape: extras.kind as KitInsertShape,\n bounds,\n extras,\n // Anchor dot at the click point: radial shapes have no vertex\n // there, and in center mode it marks the growth axis.\n anchorPoint: { x: start.x, y: start.y },\n ...(copies.length > 0 ? { copies } : {}),\n };\n },\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n gesture.open = false;\n if (live?.gesture === gesture) live.gesture = null;\n let committed = false;\n try {\n if (reason === 'cancel') cancelInsert(session);\n else committed = commitInsert(session, frame, endCtx.drag?.points ?? frame.points, gesture.userRotation);\n } finally {\n session.snap.close();\n runBehaviorSettled(session.behaviors, session.gestureCtx, committed);\n }\n },\n };\n },\n },\n /** Insert needs no selection; anything but `true` blocks dispatcher-routed inserts. */\n enabled: () => true as const,\n}, insertLayer);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,eAAgD,QAAQ;CACnE,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,eAAe;CACf,UAAU;EAAC;EAAU;EAAc;EAAc;EAAa;EAAQ;EAAY;EAAS;EAAY;EAAQ;CAAa;CAC5H,SAAS;EACP,QAAQ;EACR,MAAM,KAAoB,MAAmC;GAC3D,MAAM,QAAQ,YAAY,KAAK,IAAI;GACnC,IAAI,CAAC,OAAO,OAAO,CAAC;GACpB,MAAM,EAAE,SAAS,YAAY;GAC7B,IAAI,QAAQ,MAAM;GAClB,MAAM,UAA6B;IAAE,MAAM;IAAM,cAAc;IAAG,eAAe;GAAM;GACvF,MAAM,OAAO,IAAI,KAAK;GACtB,IAAI,MAAM,KAAK,UAAU;GAEzB,MAAM,QAAQ,IAAI,KAAK;GACvB,MAAM,SAAS,QAAQ,aAAa,OAAO,QAAQ,QAAQ,mBAAmB,KAAK,CAAC,IAAI,CAAC;GAEzF,OAAO;IACL,MAAM;IACN,OAAO,SAA8B;KACnC,IAAI,QAAQ,eAAe,WAAW,SAAS,MAAM,SAAS,QAAQ,OAAO,OAAO;KACpF,QAAQ,UAAU,SAAS,SAAS,OAAO,OAAO;IACpD;IACA,UAAiC;KAC/B,IAAI,CAAC,QAAQ,MAAM,OAAO;KAG1B,MAAM,WAAW,cAAc,QAAQ,MAAM,MAAM;KACnD,IAAI,CAAC,cAAc,WAAW,QAAQ,CAAC,CAAC,EAAE,eAAe,OAAO;KAChE,MAAM,EAAE,QAAQ,QAAQ,UAAU,YAAY,UAAU,OAAO,MAAM,QAAQ,QAAQ,YAAY;KACjG,OAAO;MACL,MAAM;MACN,OAAO,OAAO;MACd;MACA;MAGA,aAAa;OAAE,GAAG,MAAM;OAAG,GAAG,MAAM;MAAE;MACtC,GAAI,OAAO,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC;KACxC;IACF;IACA,MAAM,QAAuB,QAAmC;KAC9D,QAAQ,OAAO;KACf,IAAI,MAAM,YAAY,SAAS,KAAK,UAAU;KAC9C,IAAI,YAAY;KAChB,IAAI;MACF,IAAI,WAAW,UAAU,aAAa,OAAO;WACxC,YAAY,aAAa,SAAS,OAAO,OAAO,MAAM,UAAU,MAAM,QAAQ,QAAQ,YAAY;KACzG,UAAU;MACR,QAAQ,KAAK,MAAM;MACnB,mBAAmB,QAAQ,WAAW,QAAQ,YAAY,SAAS;KACrE;IACF;GACF;EACF;CACF;;CAEA,eAAe;AACjB,GAAG,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { commitGestureOps, readGestureLifecycle, reduceBehaviorEnd, runBehaviorCancel } from "../gestureLifecycle.js";
|
|
2
1
|
import { defaultCommitAdapter } from "../defaultCommitAdapter.js";
|
|
2
|
+
import { commitGestureOps, readGestureLifecycle, reduceBehaviorEnd, runBehaviorCancel } from "../gestureLifecycle.js";
|
|
3
3
|
import { shapeKindInfo } from "../../../core/shapeKinds.js";
|
|
4
4
|
import { insertShape, isCommittableExtent } from "./shape.js";
|
|
5
5
|
import { resolveParams } from "@weasel-js/routing";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/interactions/actions/insert/parent.ts
|
|
2
|
+
/** The container an insert lands in: the one the `insertInto` dep's `into`
|
|
3
|
+
* names, or null, the top of the tree, when it names no container. */
|
|
4
|
+
function insertParent(scene, into) {
|
|
5
|
+
if (into == null || !scene) return null;
|
|
6
|
+
return scene.get(into)?.kind === "container" ? into : null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { insertParent };
|
|
11
|
+
//# sourceMappingURL=parent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent.js","names":[],"sources":["../../../../src/interactions/actions/insert/parent.ts"],"sourcesContent":["import type { NodeId } from 'core/scene/types';\n\n/** What finding an insert's container reads of a scene. A `Scene` satisfies it. */\ninterface ContainerReader {\n get(id: NodeId): { kind: string } | undefined;\n}\n\n/** The container an insert lands in: the one the `insertInto` dep's `into`\n * names, or null, the top of the tree, when it names no container. */\nexport function insertParent(scene: ContainerReader | undefined, into: string | null | undefined): NodeId | null {\n if (into == null || !scene) return null;\n return scene.get(into as NodeId)?.kind === 'container' ? (into as NodeId) : null;\n}\n"],"mappings":";;;AASA,SAAgB,aAAa,OAAoC,MAAgD;CAC/G,IAAI,QAAQ,QAAQ,CAAC,OAAO,OAAO;CACnC,OAAO,MAAM,IAAI,IAAc,CAAC,EAAE,SAAS,cAAe,OAAkB;AAC9E"}
|
|
@@ -3,6 +3,7 @@ import { SNAP_ROLES, snapMods } from "../../../features/snap/roles.js";
|
|
|
3
3
|
import { minSizeOf } from "../../../core/scene/minSize.js";
|
|
4
4
|
import { insertKind } from "./shape.js";
|
|
5
5
|
import { enterInsertedText } from "./commit.js";
|
|
6
|
+
import { insertParent } from "./parent.js";
|
|
6
7
|
|
|
7
8
|
//#region src/interactions/actions/insert/placeAction.ts
|
|
8
9
|
/** What the dispatcher lays under an immediate action's params for a click. */
|
|
@@ -41,9 +42,11 @@ var placeAction = inPlane({
|
|
|
41
42
|
modifierRoles: SNAP_ROLES,
|
|
42
43
|
requires: [
|
|
43
44
|
"insert",
|
|
45
|
+
"insertInto",
|
|
44
46
|
"selection",
|
|
45
47
|
"snap",
|
|
46
|
-
"textEdit"
|
|
48
|
+
"textEdit",
|
|
49
|
+
"scene"
|
|
47
50
|
],
|
|
48
51
|
invoker: {
|
|
49
52
|
timing: "immediate",
|
|
@@ -60,12 +63,14 @@ var placeAction = inPlane({
|
|
|
60
63
|
if (!dep || !size || typeof x !== "number" || typeof y !== "number") return;
|
|
61
64
|
if (!(size.width > 0 && size.height > 0)) return;
|
|
62
65
|
deps.selection?.clear();
|
|
66
|
+
const parent = insertParent(deps.scene, deps.insertInto?.get());
|
|
63
67
|
const snap = deps.snap?.begin({
|
|
64
68
|
gesture: "point",
|
|
65
69
|
press: {
|
|
66
70
|
x,
|
|
67
71
|
y
|
|
68
|
-
}
|
|
72
|
+
},
|
|
73
|
+
...parent === null ? {} : { parent }
|
|
69
74
|
});
|
|
70
75
|
const mods = snapMods({ modifiers: params?.["mods"] ?? NO_KEYS });
|
|
71
76
|
const at = snap ? snap.at({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeAction.js","names":[],"sources":["../../../../src/interactions/actions/insert/placeAction.ts"],"sourcesContent":["import type { Action, ActionDeps, ModifierState } from '@weasel-js/routing';\nimport { SNAP_ROLES, snapMods } from 'features/snap/roles';\nimport type { InsertExtras } from '../depSchema';\nimport { inPlane, insertLayer } from '../planeInput';\nimport { enterInsertedText } from './commit';\nimport { insertKind } from './shape';\nimport { minSizeOf } from 'core/scene/minSize';\n\n/** What the dispatcher lays under an immediate action's params for a click. */\nconst CLICK_FIELDS = ['worldX', 'worldY', 'pressX', 'pressY', 'affordance', 'mods'] as const;\n\nconst NO_KEYS: ModifierState = { alt: false, ctrl: false, meta: false, shift: false };\n\n/**\n * Click-to-insert: the companion to `insertAction` for a click, which draws\n * no box. It commits a node of `params.kind` at `params.size`, centered on the\n * click, snapped through a `point` session of the `snap` dep unless the\n * click held `snap.suspend` (Ctrl), and commits\n * through the same `insert` dep a drag commits through. The rest of the\n * binding's params are the insert's extras, as a drag's are.\n *\n * A `minSize` in the params floors the size, and goes on to the node.\n *\n * A binding with no `size` places nothing: the kind's extent is the tool's to\n * name, and a click has none of its own.\n */\nexport const placeAction: Action & { requires: string[] } = inPlane({\n id: 'place',\n label: 'Place',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n modifierRoles: SNAP_ROLES,\n requires: ['insert', 'selection', 'snap', 'textEdit'],\n invoker: {\n timing: 'immediate',\n run(deps: ActionDeps, params?: Record<string, unknown>): void {\n const dep = deps.insert;\n const asked = params?.['size'] as { width: number; height: number } | undefined;\n const min = minSizeOf(params);\n const size = asked && min\n ? { width: Math.max(asked.width, min.width), height: Math.max(asked.height, min.height) }\n : asked;\n const x = params?.['worldX'];\n const y = params?.['worldY'];\n if (!dep || !size || typeof x !== 'number' || typeof y !== 'number') return;\n if (!(size.width > 0 && size.height > 0)) return;\n\n deps.selection?.clear();\n const snap = deps.snap?.begin({ gesture: 'point', press: { x, y } });\n const mods = snapMods({ modifiers: (params?.['mods'] as ModifierState | undefined) ?? NO_KEYS });\n const at = snap ? snap.at({ x, y }, mods).point : { x, y };\n snap?.end();\n const extras: Record<string, unknown> = { ...params, kind: insertKind(params) };\n for (const k of [...CLICK_FIELDS, 'size']) delete extras[k];\n const bounds = { x: at.x - size.width / 2, y: at.y - size.height / 2, width: size.width, height: size.height };\n const ends = { start: at, end: { x: at.x + size.width / 2, y: at.y + size.height / 2 }, fromCenter: true };\n const id = dep.commit(bounds, extras as InsertExtras, ends);\n enterInsertedText(deps.textEdit, id === null ? null : String(id), extras.kind as string);\n },\n },\n /** Like `insert`, needs no selection. */\n enabled: () => true as const,\n}, insertLayer);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"placeAction.js","names":[],"sources":["../../../../src/interactions/actions/insert/placeAction.ts"],"sourcesContent":["import type { Action, ActionDeps, ModifierState } from '@weasel-js/routing';\nimport { SNAP_ROLES, snapMods } from 'features/snap/roles';\nimport type { InsertExtras } from '../depSchema';\nimport { inPlane, insertLayer } from '../planeInput';\nimport { enterInsertedText } from './commit';\nimport { insertParent } from './parent';\nimport { insertKind } from './shape';\nimport { minSizeOf } from 'core/scene/minSize';\n\n/** What the dispatcher lays under an immediate action's params for a click. */\nconst CLICK_FIELDS = ['worldX', 'worldY', 'pressX', 'pressY', 'affordance', 'mods'] as const;\n\nconst NO_KEYS: ModifierState = { alt: false, ctrl: false, meta: false, shift: false };\n\n/**\n * Click-to-insert: the companion to `insertAction` for a click, which draws\n * no box. It commits a node of `params.kind` at `params.size`, centered on the\n * click, snapped through a `point` session of the `snap` dep unless the\n * click held `snap.suspend` (Ctrl), and commits\n * through the same `insert` dep a drag commits through. The rest of the\n * binding's params are the insert's extras, as a drag's are.\n *\n * A `minSize` in the params floors the size, and goes on to the node.\n *\n * A binding with no `size` places nothing: the kind's extent is the tool's to\n * name, and a click has none of its own.\n */\nexport const placeAction: Action & { requires: string[] } = inPlane({\n id: 'place',\n label: 'Place',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n modifierRoles: SNAP_ROLES,\n requires: ['insert', 'insertInto', 'selection', 'snap', 'textEdit', 'scene'],\n invoker: {\n timing: 'immediate',\n run(deps: ActionDeps, params?: Record<string, unknown>): void {\n const dep = deps.insert;\n const asked = params?.['size'] as { width: number; height: number } | undefined;\n const min = minSizeOf(params);\n const size = asked && min\n ? { width: Math.max(asked.width, min.width), height: Math.max(asked.height, min.height) }\n : asked;\n const x = params?.['worldX'];\n const y = params?.['worldY'];\n if (!dep || !size || typeof x !== 'number' || typeof y !== 'number') return;\n if (!(size.width > 0 && size.height > 0)) return;\n\n deps.selection?.clear();\n const parent = insertParent(deps.scene, deps.insertInto?.get());\n const snap = deps.snap?.begin({ gesture: 'point', press: { x, y }, ...(parent === null ? {} : { parent }) });\n const mods = snapMods({ modifiers: (params?.['mods'] as ModifierState | undefined) ?? NO_KEYS });\n const at = snap ? snap.at({ x, y }, mods).point : { x, y };\n snap?.end();\n const extras: Record<string, unknown> = { ...params, kind: insertKind(params) };\n for (const k of [...CLICK_FIELDS, 'size']) delete extras[k];\n const bounds = { x: at.x - size.width / 2, y: at.y - size.height / 2, width: size.width, height: size.height };\n const ends = { start: at, end: { x: at.x + size.width / 2, y: at.y + size.height / 2 }, fromCenter: true };\n const id = dep.commit(bounds, extras as InsertExtras, ends);\n enterInsertedText(deps.textEdit, id === null ? null : String(id), extras.kind as string);\n },\n },\n /** Like `insert`, needs no selection. */\n enabled: () => true as const,\n}, insertLayer);\n"],"mappings":";;;;;;;;;AAUA,IAAM,eAAe;CAAC;CAAU;CAAU;CAAU;CAAU;CAAc;AAAM;AAElF,IAAM,UAAyB;CAAE,KAAK;CAAO,MAAM;CAAO,MAAM;CAAO,OAAO;AAAM;;;;;;;;;;;;;;AAepF,IAAa,cAA+C,QAAQ;CAClE,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,eAAe;CACf,UAAU;EAAC;EAAU;EAAc;EAAa;EAAQ;EAAY;CAAO;CAC3E,SAAS;EACP,QAAQ;EACR,IAAI,MAAkB,QAAwC;GAC5D,MAAM,MAAM,KAAK;GACjB,MAAM,QAAQ,SAAS;GACvB,MAAM,MAAM,UAAU,MAAM;GAC5B,MAAM,OAAO,SAAS,MAClB;IAAE,OAAO,KAAK,IAAI,MAAM,OAAO,IAAI,KAAK;IAAG,QAAQ,KAAK,IAAI,MAAM,QAAQ,IAAI,MAAM;GAAE,IACtF;GACJ,MAAM,IAAI,SAAS;GACnB,MAAM,IAAI,SAAS;GACnB,IAAI,CAAC,OAAO,CAAC,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;GACrE,IAAI,EAAE,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI;GAE1C,KAAK,WAAW,MAAM;GACtB,MAAM,SAAS,aAAa,KAAK,OAAO,KAAK,YAAY,IAAI,CAAC;GAC9D,MAAM,OAAO,KAAK,MAAM,MAAM;IAAE,SAAS;IAAS,OAAO;KAAE;KAAG;IAAE;IAAG,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,OAAO;GAAG,CAAC;GAC3G,MAAM,OAAO,SAAS,EAAE,WAAY,SAAS,WAAyC,QAAQ,CAAC;GAC/F,MAAM,KAAK,OAAO,KAAK,GAAG;IAAE;IAAG;GAAE,GAAG,IAAI,CAAC,CAAC,QAAQ;IAAE;IAAG;GAAE;GACzD,MAAM,IAAI;GACV,MAAM,SAAkC;IAAE,GAAG;IAAQ,MAAM,WAAW,MAAM;GAAE;GAC9E,KAAK,MAAM,KAAK,CAAC,GAAG,cAAc,MAAM,GAAG,OAAO,OAAO;GACzD,MAAM,SAAS;IAAE,GAAG,GAAG,IAAI,KAAK,QAAQ;IAAG,GAAG,GAAG,IAAI,KAAK,SAAS;IAAG,OAAO,KAAK;IAAO,QAAQ,KAAK;GAAO;GAC7G,MAAM,OAAO;IAAE,OAAO;IAAI,KAAK;KAAE,GAAG,GAAG,IAAI,KAAK,QAAQ;KAAG,GAAG,GAAG,IAAI,KAAK,SAAS;IAAE;IAAG,YAAY;GAAK;GACzG,MAAM,KAAK,IAAI,OAAO,QAAQ,QAAwB,IAAI;GAC1D,kBAAkB,KAAK,UAAU,OAAO,OAAO,OAAO,OAAO,EAAE,GAAG,OAAO,IAAc;EACzF;CACF;;CAEA,eAAe;AACjB,GAAG,WAAW"}
|
|
@@ -3,6 +3,7 @@ import { pointerStateOf } from "../pointerState.js";
|
|
|
3
3
|
import { SNAP_ANGLE_STEP, snapMods } from "../../../features/snap/roles.js";
|
|
4
4
|
import { insertKind } from "./shape.js";
|
|
5
5
|
import { spanSnap } from "../../../features/snap/spanSnap.js";
|
|
6
|
+
import { insertParent } from "./parent.js";
|
|
6
7
|
import { resolveParams } from "@weasel-js/routing";
|
|
7
8
|
|
|
8
9
|
//#region src/interactions/actions/insert/session.ts
|
|
@@ -17,7 +18,9 @@ function beginInsert(ctx, opts) {
|
|
|
17
18
|
const selection = ctx.deps.selection;
|
|
18
19
|
const priorSelection = selection ? [...selection.get()] : [];
|
|
19
20
|
if (selection && priorSelection.length > 0) selection.clear();
|
|
20
|
-
const
|
|
21
|
+
const parent = insertParent(ctx.deps.scene, ctx.deps.insertInto?.get());
|
|
22
|
+
const constrain = () => insertKind(resolveParams(opts?.params)) === "line" ? { step: SNAP_ANGLE_STEP } : void 0;
|
|
23
|
+
const snap = spanSnap(ctx.deps.snap, constrain, parent === null ? {} : { parent });
|
|
21
24
|
const behaviors = opts?.behaviors ?? [];
|
|
22
25
|
const readers = gestureReaders(ctx.deps);
|
|
23
26
|
const origin = snap.start({
|
|
@@ -51,6 +54,7 @@ function beginInsert(ctx, opts) {
|
|
|
51
54
|
behaviors,
|
|
52
55
|
gestureCtx,
|
|
53
56
|
scene: ctx.deps.scene,
|
|
57
|
+
parent,
|
|
54
58
|
applyOps: ctx.deps.applyOps,
|
|
55
59
|
selection
|
|
56
60
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":[],"sources":["../../../../src/interactions/actions/insert/session.ts"],"sourcesContent":["import type { BindingOpts, DragSample, InvocationCtx } from '@weasel-js/routing';\nimport { resolveParams } from '@weasel-js/routing';\nimport { SNAP_ANGLE_STEP, snapMods } from 'features/snap/roles';\nimport { spanSnap, type SpanSnap } from 'features/snap/spanSnap';\nimport { pointerStateOf } from '../pointerState';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { gestureReaders, type GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { GestureContext, InsertBehavior, InsertPoint } from '../../gestures/types';\nimport type { InsertDep, TextEditDep } from '../depSchema';\nimport { insertKind } from './shape';\n\n/** The key an insert's single gesture point rides under in the behaviors'\n * `draggedIds` / `origin` / `current` — insert has no node id yet. */\nexport const GESTURE_KEY = 'gesture';\n\n/** What an insert captured at press. Nothing here changes during the drag.\n * The deps are captured because the dispatcher builds the deps bag once, on\n * `start`: every later pump event carries `deps: {}`. */\nexport interface InsertSession {\n readonly dep: InsertDep;\n /** For the text kind's drop-into-the-caret step. */\n readonly textEdit: TextEditDep | undefined;\n /** Snaps the drag's start and current point, so the live preview and the\n * committed geometry agree. Freehand pencil samples are deliberately NOT\n * snapped — a grid-quantized freehand trail is a staircase, not a stroke. */\n readonly snap: SpanSnap;\n /** The active binding's opts — re-resolved on every read so thunked\n * params see the latest tool state (e.g. polygon `sides` after ArrowUp). */\n readonly opts: BindingOpts | undefined;\n /** What was selected before the draw cleared it, to put back on cancel. */\n readonly priorSelection: readonly NodeId[];\n /** Behaviors from `opts.behaviors`; empty when none were bound. */\n readonly behaviors: readonly InsertBehavior<unknown>[];\n /** Reused gesture context handed to behaviors. Its `origin` holds the\n * start point under {@link GESTURE_KEY}, after `onStart` shaped it. */\n readonly gestureCtx: GestureContext<unknown>;\n /** For committing a behavior's `Op[]`. */\n readonly scene: Scene<unknown, string, unknown> | undefined;\n readonly applyOps: ((ops: Op[], label: string) => void) | undefined;\n readonly selection: SelectionApi | undefined;\n}\n\n/** What the latest pump event left. Replaced, not mutated, by the next. */\nexport interface InsertFrame {\n /** The raw (unsnapped) pointer in world space. */\n readonly pointer: InsertPoint;\n /** Pointer trail accumulated by the dispatcher in world space; pencil-kind\n * commits read it. */\n readonly points: ReadonlyArray<DragSample> | null;\n /** Alt inverts the binding's nominal `originMode` (corner ⇄ center), so\n * pressing or releasing it mid-drag flips the preview and the commit\n * without the dispatcher re-routing to another binding. */\n readonly altHeld: boolean;\n /** The endpoints after the snap session and the behaviors. */\n readonly shaped: { start: InsertPoint; current: InsertPoint };\n}\n\n/** Capture an insert at press. Null with no `insert` dep. Clears the\n * selection and runs each behavior's `onStart`. */\nexport function beginInsert(\n ctx: InvocationCtx,\n opts: BindingOpts | undefined,\n): { session: InsertSession; readers: GestureReaders; frame: InsertFrame } | null {\n const dep = ctx.deps.insert;\n if (!dep) return null;\n\n // Starting a draw retires any prior selection — the lingering halo\n // around an unrelated node while the user is drawing a new shape is\n // just visual noise, and it primes the UX bug where a drag that\n // continues over the selected node would otherwise drive the move\n // action via fall-through. The clear is unconditional: the user has\n // committed to \"I'm making a new thing\" by engaging a creation tool.\n const selection = ctx.deps.selection;\n const priorSelection = selection ? [...selection.get()] : [];\n if (selection && priorSelection.length > 0) {\n selection.clear();\n }\n\n const
|
|
1
|
+
{"version":3,"file":"session.js","names":[],"sources":["../../../../src/interactions/actions/insert/session.ts"],"sourcesContent":["import type { BindingOpts, DragSample, InvocationCtx } from '@weasel-js/routing';\nimport { resolveParams } from '@weasel-js/routing';\nimport { SNAP_ANGLE_STEP, snapMods } from 'features/snap/roles';\nimport { spanSnap, type SpanSnap } from 'features/snap/spanSnap';\nimport { pointerStateOf } from '../pointerState';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { gestureReaders, type GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { GestureContext, InsertBehavior, InsertPoint } from '../../gestures/types';\nimport type { InsertDep, TextEditDep } from '../depSchema';\nimport { insertParent } from './parent';\nimport { insertKind } from './shape';\n\n/** The key an insert's single gesture point rides under in the behaviors'\n * `draggedIds` / `origin` / `current` — insert has no node id yet. */\nexport const GESTURE_KEY = 'gesture';\n\n/** What an insert captured at press. Nothing here changes during the drag.\n * The deps are captured because the dispatcher builds the deps bag once, on\n * `start`: every later pump event carries `deps: {}`. */\nexport interface InsertSession {\n readonly dep: InsertDep;\n /** For the text kind's drop-into-the-caret step. */\n readonly textEdit: TextEditDep | undefined;\n /** Snaps the drag's start and current point, so the live preview and the\n * committed geometry agree. Freehand pencil samples are deliberately NOT\n * snapped — a grid-quantized freehand trail is a staircase, not a stroke. */\n readonly snap: SpanSnap;\n /** The active binding's opts — re-resolved on every read so thunked\n * params see the latest tool state (e.g. polygon `sides` after ArrowUp). */\n readonly opts: BindingOpts | undefined;\n /** What was selected before the draw cleared it, to put back on cancel. */\n readonly priorSelection: readonly NodeId[];\n /** Behaviors from `opts.behaviors`; empty when none were bound. */\n readonly behaviors: readonly InsertBehavior<unknown>[];\n /** Reused gesture context handed to behaviors. Its `origin` holds the\n * start point under {@link GESTURE_KEY}, after `onStart` shaped it. */\n readonly gestureCtx: GestureContext<unknown>;\n /** For committing a behavior's `Op[]`. */\n readonly scene: Scene<unknown, string, unknown> | undefined;\n /** The container the node lands in; null for the top of the tree. */\n readonly parent: NodeId | null;\n readonly applyOps: ((ops: Op[], label: string) => void) | undefined;\n readonly selection: SelectionApi | undefined;\n}\n\n/** What the latest pump event left. Replaced, not mutated, by the next. */\nexport interface InsertFrame {\n /** The raw (unsnapped) pointer in world space. */\n readonly pointer: InsertPoint;\n /** Pointer trail accumulated by the dispatcher in world space; pencil-kind\n * commits read it. */\n readonly points: ReadonlyArray<DragSample> | null;\n /** Alt inverts the binding's nominal `originMode` (corner ⇄ center), so\n * pressing or releasing it mid-drag flips the preview and the commit\n * without the dispatcher re-routing to another binding. */\n readonly altHeld: boolean;\n /** The endpoints after the snap session and the behaviors. */\n readonly shaped: { start: InsertPoint; current: InsertPoint };\n}\n\n/** Capture an insert at press. Null with no `insert` dep. Clears the\n * selection and runs each behavior's `onStart`. */\nexport function beginInsert(\n ctx: InvocationCtx,\n opts: BindingOpts | undefined,\n): { session: InsertSession; readers: GestureReaders; frame: InsertFrame } | null {\n const dep = ctx.deps.insert;\n if (!dep) return null;\n\n // Starting a draw retires any prior selection — the lingering halo\n // around an unrelated node while the user is drawing a new shape is\n // just visual noise, and it primes the UX bug where a drag that\n // continues over the selected node would otherwise drive the move\n // action via fall-through. The clear is unconditional: the user has\n // committed to \"I'm making a new thing\" by engaging a creation tool.\n const selection = ctx.deps.selection;\n const priorSelection = selection ? [...selection.get()] : [];\n if (selection && priorSelection.length > 0) {\n selection.clear();\n }\n\n const parent = insertParent(ctx.deps.scene, ctx.deps.insertInto?.get());\n const constrain = () => (insertKind(resolveParams(opts?.params)) === 'line' ? { step: SNAP_ANGLE_STEP } : undefined);\n const snap = spanSnap(ctx.deps.snap, constrain, parent === null ? {} : { parent });\n const behaviors = (opts?.behaviors ?? []) as InsertBehavior<unknown>[];\n const readers = gestureReaders(ctx.deps);\n const origin = snap.start({ x: ctx.world.x, y: ctx.world.y }, snapMods(ctx)).point;\n const gestureCtx: GestureContext<unknown> = {\n draggedIds: [GESTURE_KEY],\n origin: new Map<string, unknown>([[GESTURE_KEY, origin]]),\n current: new Map<string, unknown>([[GESTURE_KEY, origin]]),\n snap: null,\n modifiers: { ...ctx.modifiers },\n pointer: pointerStateOf(ctx.world, ctx),\n view: readers.view(),\n plane: readers.plane(),\n kitSettings: readers.kitSettings,\n // No node exists to adapt until commit; insert behaviors read points.\n adapter: undefined as unknown as GestureContext<unknown>['adapter'],\n scratch: {},\n };\n for (const b of behaviors) b.onStart?.(gestureCtx);\n // A snap target in range outranks a behavior's own snapping.\n if (snap.startHeld()) gestureCtx.origin.set(GESTURE_KEY, origin);\n const startPoint = gestureCtx.origin.get(GESTURE_KEY) as InsertPoint;\n snap.anchor(startPoint);\n\n const session: InsertSession = {\n dep,\n textEdit: ctx.deps.textEdit,\n snap,\n opts,\n priorSelection,\n behaviors,\n gestureCtx,\n scene: ctx.deps.scene,\n parent,\n applyOps: ctx.deps.applyOps,\n selection,\n };\n const frame: InsertFrame = {\n pointer: { x: ctx.world.x, y: ctx.world.y },\n points: ctx.drag?.points ?? null,\n altHeld: ctx.modifiers.alt,\n shaped: { start: startPoint, current: startPoint },\n };\n return { session, readers, frame };\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAa,cAAc;;;AAgD3B,SAAgB,YACd,KACA,MACgF;CAChF,MAAM,MAAM,IAAI,KAAK;CACrB,IAAI,CAAC,KAAK,OAAO;CAQjB,MAAM,YAAY,IAAI,KAAK;CAC3B,MAAM,iBAAiB,YAAY,CAAC,GAAG,UAAU,IAAI,CAAC,IAAI,CAAC;CAC3D,IAAI,aAAa,eAAe,SAAS,GACvC,UAAU,MAAM;CAGlB,MAAM,SAAS,aAAa,IAAI,KAAK,OAAO,IAAI,KAAK,YAAY,IAAI,CAAC;CACtE,MAAM,kBAAmB,WAAW,cAAc,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,MAAM,gBAAgB,IAAI;CAC1G,MAAM,OAAO,SAAS,IAAI,KAAK,MAAM,WAAW,WAAW,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;CACjF,MAAM,YAAa,MAAM,aAAa,CAAC;CACvC,MAAM,UAAU,eAAe,IAAI,IAAI;CACvC,MAAM,SAAS,KAAK,MAAM;EAAE,GAAG,IAAI,MAAM;EAAG,GAAG,IAAI,MAAM;CAAE,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;CAC7E,MAAM,aAAsC;EAC1C,YAAY,CAAC,WAAW;EACxB,wBAAQ,IAAI,IAAqB,CAAC,CAAC,aAAa,MAAM,CAAC,CAAC;EACxD,yBAAS,IAAI,IAAqB,CAAC,CAAC,aAAa,MAAM,CAAC,CAAC;EACzD,MAAM;EACN,WAAW,EAAE,GAAG,IAAI,UAAU;EAC9B,SAAS,eAAe,IAAI,OAAO,GAAG;EACtC,MAAM,QAAQ,KAAK;EACnB,OAAO,QAAQ,MAAM;EACrB,aAAa,QAAQ;EAErB,SAAS;EACT,SAAS,CAAC;CACZ;CACA,KAAK,MAAM,KAAK,WAAW,EAAE,UAAU,UAAU;CAEjD,IAAI,KAAK,UAAU,GAAG,WAAW,OAAO,IAAI,aAAa,MAAM;CAC/D,MAAM,aAAa,WAAW,OAAO,IAAI,WAAW;CACpD,KAAK,OAAO,UAAU;CAqBtB,OAAO;EAAE;GAlBP;GACA,UAAU,IAAI,KAAK;GACnB;GACA;GACA;GACA;GACA;GACA,OAAO,IAAI,KAAK;GAChB;GACA,UAAU,IAAI,KAAK;GACnB;EAQO;EAAS;EAAS;GALzB,SAAS;IAAE,GAAG,IAAI,MAAM;IAAG,GAAG,IAAI,MAAM;GAAE;GAC1C,QAAQ,IAAI,MAAM,UAAU;GAC5B,SAAS,IAAI,UAAU;GACvB,QAAQ;IAAE,OAAO;IAAY,SAAS;GAAW;EAExB;CAAM;AACnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { transformPreview } from "../transformFinish.js";
|
|
1
2
|
import { closeGesture, runBehaviorCancel } from "../gestureLifecycle.js";
|
|
2
3
|
import { inPlane, selectionLayer } from "../planeInput.js";
|
|
3
4
|
import { beginMove } from "./session.js";
|
|
@@ -40,10 +41,12 @@ var moveAction = inPlane({
|
|
|
40
41
|
"applyOps",
|
|
41
42
|
"geometryProjection",
|
|
42
43
|
"nodeAtPoint",
|
|
44
|
+
"canDropInto",
|
|
43
45
|
"view",
|
|
44
46
|
"boundsIncludeStroke",
|
|
45
47
|
"kitSettings",
|
|
46
|
-
"snap"
|
|
48
|
+
"snap",
|
|
49
|
+
"transformFollowers"
|
|
47
50
|
],
|
|
48
51
|
invoker: {
|
|
49
52
|
timing: "ongoing",
|
|
@@ -61,6 +64,7 @@ var moveAction = inPlane({
|
|
|
61
64
|
const { session, readers } = begun;
|
|
62
65
|
const subject = [...ctx.deps.selection?.get() ?? []];
|
|
63
66
|
const hold = session.scene.overrides.hold();
|
|
67
|
+
const preview = transformPreview(ctx.deps, session.scene, () => frame.previews);
|
|
64
68
|
let engaged = null;
|
|
65
69
|
return {
|
|
66
70
|
kind: "move",
|
|
@@ -79,7 +83,7 @@ var moveAction = inPlane({
|
|
|
79
83
|
}
|
|
80
84
|
engaged = moveCtx.world;
|
|
81
85
|
frame = nextFrame(session, readers, moveCtx);
|
|
82
|
-
hold.set(
|
|
86
|
+
hold.set(preview.poses());
|
|
83
87
|
},
|
|
84
88
|
onEnd(endCtx, reason) {
|
|
85
89
|
let committed = false;
|
|
@@ -106,8 +110,8 @@ var moveAction = inPlane({
|
|
|
106
110
|
}, committed);
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
|
-
previewIds:
|
|
110
|
-
|
|
113
|
+
previewIds: preview.previewIds,
|
|
114
|
+
previewData: preview.previewData,
|
|
111
115
|
previewOpaqueIds: () => frame.opaque.size === 0 ? null : frame.opaque
|
|
112
116
|
};
|
|
113
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/move/action.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { InvocationCtx, OngoingHandle, BindingOpts } from '@weasel-js/routing';\nimport {
|
|
1
|
+
{"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/move/action.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { InvocationCtx, OngoingHandle, BindingOpts } from '@weasel-js/routing';\nimport { transformPreview } from '../transformFinish';\nimport { pastDragThreshold } from '@weasel-js/routing';\nimport { closeGesture, runBehaviorCancel } from '../gestureLifecycle';\nimport { inPlane, selectionLayer } from '../planeInput';\nimport { beginMove, type MoveFrame, type ReparentOnDrop } from './session';\nimport { nextFrame } from './frame';\nimport { commitMove } from './commit';\nimport { recordTransform } from '../transform-again/memory';\nimport { SNAP_ROLES } from 'features/snap/roles';\nexport type { ReparentOnDrop };\n\n/**\n * Drag-translates the selection.\n *\n * Each frame's poses go to the scene's ephemeral override table, not the\n * document: `Scene.setPose` records an undo entry per call, and the overrides\n * are what let a node deriving its geometry from a dragged one follow the\n * drag. Release commits one batch — at most one undo entry, none when the\n * binding's params make it transient — and cancel drops the overrides.\n *\n * Behaviors from the binding's `opts.behaviors` fold into each frame; on\n * release the first non-`undefined` answer wins (`Op[]` commits, `null`\n * aborts). `beginMove` appends the action's own two: a layout drop and\n * reparent-on-drop.\n */\nexport const moveAction: Action & { requires: string[] } = inPlane({\n id: 'move',\n label: 'Move',\n // No hover `cursor`: pointing at a node shouldn't preemptively promise a move.\n activeCursor: 'move',\n // Ambient default targets `selected-body`, not a bare `{ kind: 'drag' }`,\n // which catches every drag in ambient scope and bleeds the move into\n // drawing-tool gestures wherever the higher-priority active match falls\n // through.\n defaultBinding: { kind: 'drag', target: 'selected-body' },\n eligible: { capability: 'transforms-selection' },\n modifierRoles: SNAP_ROLES,\n requires: ['selection', 'scene', 'poseDescriptor', 'layout', 'applyOps', 'geometryProjection', 'nodeAtPoint', 'canDropInto', 'view', 'boundsIncludeStroke', 'kitSettings', 'snap', 'transformFollowers'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n let frame: MoveFrame = { delta: { dx: 0, dy: 0 }, previews: new Map(), opaque: new Set() };\n const begun = beginMove(ctx, opts, () => frame);\n if (!begun) return {};\n const { session, readers } = begun;\n const subject = [...(ctx.deps.selection?.get() ?? [])] as string[];\n const hold = session.scene.overrides.hold();\n const preview = transformPreview(ctx.deps, session.scene, () => frame.previews);\n // Where the last move put the pointer, once the drag has passed its\n // threshold; null until then.\n let engaged: { x: number; y: number } | null = null;\n return {\n kind: 'move',\n onMove(moveCtx: InvocationCtx): void {\n if (!moveCtx.drag) return;\n if (!engaged) {\n const s = moveCtx.drag.screenDelta;\n if (s && !pastDragThreshold({ clientX: 0, clientY: 0 }, { clientX: s.x, clientY: s.y }, session.dragThresholdPx)) return;\n session.lifecycle.start(session.ids as unknown as string[]);\n }\n engaged = moveCtx.world;\n frame = nextFrame(session, readers, moveCtx);\n hold.set(preview.poses());\n },\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n let committed = false;\n try {\n // A press that never traveled `dragThresholdPx` was never a move:\n // its behaviors started, so they are canceled, not asked to commit.\n if (reason === 'commit' && engaged) {\n committed = commitMove({\n session,\n delta: frame.delta,\n at: endCtx.drag ? endCtx.world : engaged,\n });\n if (committed) recordTransform(session.scene, { kind: 'translate', ...frame.delta }, subject);\n } else runBehaviorCancel(session.behaviors, session.gestureCtx);\n } finally {\n session.snap?.end();\n // After the commit, so no frame can paint the pre-drag pose between\n // the override going away and the document catching up.\n closeGesture({ hold, previews: frame.previews, behaviors: session.behaviors, ctx: session.gestureCtx, lifecycle: session.lifecycle }, committed);\n }\n },\n previewIds: preview.previewIds,\n previewData: preview.previewData,\n previewOpaqueIds: () => (frame.opaque.size === 0 ? null : frame.opaque),\n };\n },\n },\n /**\n * Always enabled: the dispatcher treats anything `!== true` as \"fall\n * through to the next-best match\", so a disabled reason here loses every\n * drag-on-selected-body to a lower-specificity binding (a shape tool's\n * insert drag).\n */\n enabled: () => true,\n}, selectionLayer);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,aAA8C,QAAQ;CACjE,IAAI;CACJ,OAAO;CAEP,cAAc;CAKd,gBAAgB;EAAE,MAAM;EAAQ,QAAQ;CAAgB;CACxD,UAAU,EAAE,YAAY,uBAAuB;CAC/C,eAAe;CACf,UAAU;EAAC;EAAa;EAAS;EAAkB;EAAU;EAAY;EAAsB;EAAe;EAAe;EAAQ;EAAuB;EAAe;EAAQ;CAAoB;CACvM,SAAS;EACP,QAAQ;EACR,MAAM,KAAoB,MAAmC;GAC3D,IAAI,QAAmB;IAAE,OAAO;KAAE,IAAI;KAAG,IAAI;IAAE;IAAG,0BAAU,IAAI,IAAI;IAAG,wBAAQ,IAAI,IAAI;GAAE;GACzF,MAAM,QAAQ,UAAU,KAAK,YAAY,KAAK;GAC9C,IAAI,CAAC,OAAO,OAAO,CAAC;GACpB,MAAM,EAAE,SAAS,YAAY;GAC7B,MAAM,UAAU,CAAC,GAAI,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,CAAE;GACrD,MAAM,OAAO,QAAQ,MAAM,UAAU,KAAK;GAC1C,MAAM,UAAU,iBAAiB,IAAI,MAAM,QAAQ,aAAa,MAAM,QAAQ;GAG9E,IAAI,UAA2C;GAC/C,OAAO;IACL,MAAM;IACN,OAAO,SAA8B;KACnC,IAAI,CAAC,QAAQ,MAAM;KACnB,IAAI,CAAC,SAAS;MACZ,MAAM,IAAI,QAAQ,KAAK;MACvB,IAAI,KAAK,CAAC,kBAAkB;OAAE,SAAS;OAAG,SAAS;MAAE,GAAG;OAAE,SAAS,EAAE;OAAG,SAAS,EAAE;MAAE,GAAG,QAAQ,eAAe,GAAG;MAClH,QAAQ,UAAU,MAAM,QAAQ,GAA0B;KAC5D;KACA,UAAU,QAAQ;KAClB,QAAQ,UAAU,SAAS,SAAS,OAAO;KAC3C,KAAK,IAAI,QAAQ,MAAM,CAAC;IAC1B;IACA,MAAM,QAAuB,QAAmC;KAC9D,IAAI,YAAY;KAChB,IAAI;MAGF,IAAI,WAAW,YAAY,SAAS;OAClC,YAAY,WAAW;QACrB;QACA,OAAO,MAAM;QACb,IAAI,OAAO,OAAO,OAAO,QAAQ;OACnC,CAAC;OACD,IAAI,WAAW,gBAAgB,QAAQ,OAAO;QAAE,MAAM;QAAa,GAAG,MAAM;OAAM,GAAG,OAAO;MAC9F,OAAO,kBAAkB,QAAQ,WAAW,QAAQ,UAAU;KAChE,UAAU;MACR,QAAQ,MAAM,IAAI;MAGlB,aAAa;OAAE;OAAM,UAAU,MAAM;OAAU,WAAW,QAAQ;OAAW,KAAK,QAAQ;OAAY,WAAW,QAAQ;MAAU,GAAG,SAAS;KACjJ;IACF;IACA,YAAY,QAAQ;IACpB,aAAa,QAAQ;IACrB,wBAAyB,MAAM,OAAO,SAAS,IAAI,OAAO,MAAM;GAClE;EACF;CACF;;;;;;;CAOA,eAAe;AACjB,GAAG,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layoutDrop.js","names":[],"sources":["../../../../../src/interactions/actions/move/behaviors/layoutDrop.ts"],"sourcesContent":["import type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport type { BehaviorResult, MoveBehavior } from '../../../gestures/types';\nimport { layoutDropOps } from '../commit/layoutDrop';\nimport { layoutReleaseOps } from '../commit/layoutRelease';\nimport { runDropPass } from '../layout/dropPass';\nimport { landReleased, releasedPoses, stepGlide, type Released } from '../layout/glide';\nimport type { DropPass } from '../layout/types';\nimport type { MoveGesture } from '../session';\n\n/**\n * The move behavior that drops the selection into the layout container under\n * it. Each move it resolves the drop and shows the siblings making room; on\n * release it answers with the container's `commitDrop`, or, outside every\n * container, with what the source layouts' `releaseDrop` and the exits decide.\n *\n * Built by the move action for one drag, after the binding's own behaviors, and\n * only when the `layout` dep is present.\n */\nexport function layoutDrop(move: MoveGesture): MoveBehavior<unknown> {\n // This frame's pass; reset by every move, a throwing one included.\n let drop: DropPass | null = null;\n const gliding = new Set<NodeId>();\n let released: Map<NodeId, Released> | null = null;\n // Before the commit: where each dragged id is shown as the gesture closes.\n const noteReleased = (): void => {\n const session = move.session();\n if (session.layout?.reflow) released = releasedPoses(session, move.frame().previews);\n };\n\n return {\n onMove(ctx, proposed): BehaviorResult<unknown> | void {\n drop = null;\n
|
|
1
|
+
{"version":3,"file":"layoutDrop.js","names":[],"sources":["../../../../../src/interactions/actions/move/behaviors/layoutDrop.ts"],"sourcesContent":["import type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport type { BehaviorResult, MoveBehavior } from '../../../gestures/types';\nimport { layoutDropOps } from '../commit/layoutDrop';\nimport { layoutReleaseOps } from '../commit/layoutRelease';\nimport { runDropPass } from '../layout/dropPass';\nimport { landReleased, releasedPoses, stepGlide, type Released } from '../layout/glide';\nimport type { DropPass } from '../layout/types';\nimport type { MoveGesture } from '../session';\n\n/**\n * The move behavior that drops the selection into the layout container under\n * it. Each move it resolves the drop and shows the siblings making room; on\n * release it answers with the container's `commitDrop`, or, outside every\n * container, with what the source layouts' `releaseDrop` and the exits decide.\n *\n * Built by the move action for one drag, after the binding's own behaviors, and\n * only when the `layout` dep is present.\n */\nexport function layoutDrop(move: MoveGesture): MoveBehavior<unknown> {\n // This frame's pass; reset by every move, a throwing one included.\n let drop: DropPass | null = null;\n const gliding = new Set<NodeId>();\n let released: Map<NodeId, Released> | null = null;\n // Before the commit: where each dragged id is shown as the gesture closes.\n const noteReleased = (): void => {\n const session = move.session();\n if (session.layout?.reflow) released = releasedPoses(session, move.frame().previews);\n };\n\n return {\n onMove(ctx, proposed): BehaviorResult<unknown> | void {\n drop = null;\n const session = move.session();\n drop = runDropPass(\n session,\n { dx: proposed.dx, dy: proposed.dy },\n { x: ctx.pointer.worldX, y: ctx.pointer.worldY },\n );\n const opaque = drop?.pass?.reflowIds;\n const reflow = session.layout?.reflow;\n if (!reflow) return { poses: drop?.reflow, opaque };\n stepGlide(reflow, gliding, drop?.reflow ?? new Map());\n return { opaque };\n },\n\n onEnd(_ctx, end): Op[] | null | void {\n noteReleased();\n if (end.answered) return;\n const session = move.session();\n const { delta } = move.frame();\n // No-op if no movement (sub-threshold drag or zero delta).\n if (delta.dx === 0 && delta.dy === 0) return;\n // A drop or a release that claims the selection and writes nothing\n // commits nothing: the translate must not run in its place.\n const orAbort = (ops: Op[]): Op[] | null => (ops.length > 0 ? ops : null);\n // Layout drop commit — takes precedence over reparent-on-drop when a\n // layout container accepted the drag this gesture. One placement per\n // dragged child, replayed in the order the preview resolved them.\n // TODO: geometryProjection for drop-reflow — left pose-only because the\n // reflow distributes per-child poses with no single global delta; not\n // exercised by the geometry contract gate.\n if (drop?.pass) return orAbort(layoutDropOps(session, drop.pass));\n const release = layoutReleaseOps(session, delta, drop?.dropCenter ?? null);\n return release === undefined ? undefined : orAbort(release);\n },\n\n onCancel: noteReleased,\n\n onSettled(): void {\n const session = move.session();\n const reflow = session.layout?.reflow;\n // After the commit: each glide settles onto the pose the document now\n // holds, or back home on a cancel — the dragged ids from where they\n // were let go.\n if (reflow) {\n for (const id of gliding) reflow.settle(id as string);\n landReleased(session, reflow, released ?? new Map());\n }\n gliding.clear();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,WAAW,MAA0C;CAEnE,IAAI,OAAwB;CAC5B,MAAM,0BAAU,IAAI,IAAY;CAChC,IAAI,WAAyC;CAE7C,MAAM,qBAA2B;EAC/B,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,QAAQ,QAAQ,QAAQ,WAAW,cAAc,SAAS,KAAK,MAAM,CAAC,CAAC,QAAQ;CACrF;CAEA,OAAO;EACL,OAAO,KAAK,UAA0C;GACpD,OAAO;GACP,MAAM,UAAU,KAAK,QAAQ;GAC7B,OAAO,YACL,SACA;IAAE,IAAI,SAAS;IAAI,IAAI,SAAS;GAAG,GACnC;IAAE,GAAG,IAAI,QAAQ;IAAQ,GAAG,IAAI,QAAQ;GAAO,CACjD;GACA,MAAM,SAAS,MAAM,MAAM;GAC3B,MAAM,SAAS,QAAQ,QAAQ;GAC/B,IAAI,CAAC,QAAQ,OAAO;IAAE,OAAO,MAAM;IAAQ;GAAO;GAClD,UAAU,QAAQ,SAAS,MAAM,0BAAU,IAAI,IAAI,CAAC;GACpD,OAAO,EAAE,OAAO;EAClB;EAEA,MAAM,MAAM,KAAyB;GACnC,aAAa;GACb,IAAI,IAAI,UAAU;GAClB,MAAM,UAAU,KAAK,QAAQ;GAC7B,MAAM,EAAE,UAAU,KAAK,MAAM;GAE7B,IAAI,MAAM,OAAO,KAAK,MAAM,OAAO,GAAG;GAGtC,MAAM,WAAW,QAA4B,IAAI,SAAS,IAAI,MAAM;GAOpE,IAAI,MAAM,MAAM,OAAO,QAAQ,cAAc,SAAS,KAAK,IAAI,CAAC;GAChE,MAAM,UAAU,iBAAiB,SAAS,OAAO,MAAM,cAAc,IAAI;GACzE,OAAO,YAAY,SAAY,SAAY,QAAQ,OAAO;EAC5D;EAEA,UAAU;EAEV,YAAkB;GAChB,MAAM,UAAU,KAAK,QAAQ;GAC7B,MAAM,SAAS,QAAQ,QAAQ;GAI/B,IAAI,QAAQ;IACV,KAAK,MAAM,MAAM,SAAS,OAAO,OAAO,EAAY;IACpD,aAAa,SAAS,QAAQ,4BAAY,IAAI,IAAI,CAAC;GACrD;GACA,QAAQ,MAAM;EAChB;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
2
1
|
import { createTransformOp } from "../../../../core/ops/transform.js";
|
|
2
|
+
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
3
3
|
import { getScratch, scratchKey, setScratch } from "@weasel-js/routing";
|
|
4
4
|
|
|
5
5
|
//#region src/interactions/actions/move/behaviors/snapToContainer.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toPlane } from "../../../core/viewport/parallax.js";
|
|
2
2
|
import { composeWorldPose, composesFrames, frameAtOrAbove } from "../../../core/scene/composeFrame.js";
|
|
3
3
|
import { effectivePose } from "../../../core/scene/effectivePose.js";
|
|
4
|
+
import { scenePoseAdapter } from "../../../core/scene/scenePoseAdapter.js";
|
|
4
5
|
import { scenePoseFrame } from "../poseFrame.js";
|
|
5
6
|
import { poseDescriptorOf } from "../poseDescriptorDep.js";
|
|
6
7
|
import { invertPlane, planeOf } from "../planeInput.js";
|
|
7
8
|
import { translateTargets } from "../selectionSubtree.js";
|
|
8
|
-
import { scenePoseAdapter } from "../../../core/scene/scenePoseAdapter.js";
|
|
9
9
|
import { catchGliding } from "./layout/glide.js";
|
|
10
10
|
import { pointerStateOf } from "../pointerState.js";
|
|
11
11
|
import { sceneGestureFrames } from "../gestureFrames.js";
|
|
@@ -25,8 +25,6 @@ function commitMove(input) {
|
|
|
25
25
|
scene: session.scene,
|
|
26
26
|
projection: session.projection,
|
|
27
27
|
startPoses: session.startPoses,
|
|
28
|
-
carried: session.carried,
|
|
29
|
-
roots: session.ids,
|
|
30
28
|
label: session.lifecycle.label
|
|
31
29
|
}, ops);
|
|
32
30
|
return commitGestureOps(session, session.lifecycle, [...ops, ...followers]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/interactions/actions/move/commit/index.ts"],"sourcesContent":["import type { Op } from 'core/ops/types';\nimport { commitGestureOps, reduceBehaviorEnd } from '../../gestureLifecycle';\nimport { draggedStoredPose } from '../delta';\nimport { landedDescendantOps } from '../landedDescendants';\nimport type { MoveSession } from '../session';\nimport { rootTranslateOps, translateOps } from '../translate';\n\nexport interface CommitInput {\n session: MoveSession;\n delta: { dx: number; dy: number };\n /** Where the pointer was let go, or the last move's point when the end carried none. */\n at: { x: number; y: number };\n}\n\n/** What the behaviors answer for the commit: ops, `null` to abort, or\n * `undefined` when every one of them leaves it to the default translate. */\nfunction endBehaviors(\n session: MoveSession,\n delta: { dx: number; dy: number },\n at: { x: number; y: number },\n): Op[] | null | undefined {\n const { dx, dy } = delta;\n const gctx = session.gestureCtx;\n for (const [id, ori] of session.startPoses) {\n gctx.current.set(id as string, draggedStoredPose(session, id, ori, dx, dy));\n }\n return reduceBehaviorEnd(session.behaviors, gctx, {\n translateOps: (ids) => rootTranslateOps(session, ids, delta),\n pointer: at,\n });\n}\n\n/** Commit the drag. Returns whether anything reached the document: false\n * when there was nothing to write, or a container refused what it was sent. */\nexport function commitMove(input: CommitInput): boolean {\n const { session, at } = input;\n // Apply the final delta as a single batch → one undo entry.\n const { dx, dy } = input.delta;\n const commitOps = (ops: Op[]): boolean => {\n const followers = landedDescendantOps(\n {\n scene: session.scene,\n projection: session.projection,\n startPoses: session.startPoses,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/interactions/actions/move/commit/index.ts"],"sourcesContent":["import type { Op } from 'core/ops/types';\nimport { commitGestureOps, reduceBehaviorEnd } from '../../gestureLifecycle';\nimport { draggedStoredPose } from '../delta';\nimport { landedDescendantOps } from '../landedDescendants';\nimport type { MoveSession } from '../session';\nimport { rootTranslateOps, translateOps } from '../translate';\n\nexport interface CommitInput {\n session: MoveSession;\n delta: { dx: number; dy: number };\n /** Where the pointer was let go, or the last move's point when the end carried none. */\n at: { x: number; y: number };\n}\n\n/** What the behaviors answer for the commit: ops, `null` to abort, or\n * `undefined` when every one of them leaves it to the default translate. */\nfunction endBehaviors(\n session: MoveSession,\n delta: { dx: number; dy: number },\n at: { x: number; y: number },\n): Op[] | null | undefined {\n const { dx, dy } = delta;\n const gctx = session.gestureCtx;\n for (const [id, ori] of session.startPoses) {\n gctx.current.set(id as string, draggedStoredPose(session, id, ori, dx, dy));\n }\n return reduceBehaviorEnd(session.behaviors, gctx, {\n translateOps: (ids) => rootTranslateOps(session, ids, delta),\n pointer: at,\n });\n}\n\n/** Commit the drag. Returns whether anything reached the document: false\n * when there was nothing to write, or a container refused what it was sent. */\nexport function commitMove(input: CommitInput): boolean {\n const { session, at } = input;\n // Apply the final delta as a single batch → one undo entry.\n const { dx, dy } = input.delta;\n const commitOps = (ops: Op[]): boolean => {\n const followers = landedDescendantOps(\n {\n scene: session.scene,\n projection: session.projection,\n startPoses: session.startPoses,\n label: session.lifecycle.label,\n },\n ops,\n );\n return commitGestureOps(session, session.lifecycle, [...ops, ...followers]);\n };\n\n // Behavior pipeline owns the commit if any behavior returns non-undefined.\n const answer = endBehaviors(session, { dx, dy }, at);\n if (answer === null) return false; // abort (e.g. snap-back)\n if (answer !== undefined) return commitOps(answer);\n\n // No-op if no movement (sub-threshold drag or zero delta).\n if (dx === 0 && dy === 0) return false;\n\n // No behavior claimed it — translate-only commit, emitted as transform ops\n // so it routes through the consumer `applyOps` hook (consumer history)\n // when present, else the scene's own history. Under scene v1's\n // absolute-pose semantics every node stores world coords\n // independently, so a container drag must explicitly re-stamp every\n // cascaded descendant by the same dx/dy — otherwise children stay at\n // their old absolute positions (visually they snap to the\n // container's former location).\n // Translate the data-held geometry by the same (dx,dy). Opt-in via\n // the geometryProjection seam; a no-op when the dep is absent.\n const ops = translateOps(session, [...session.ids, ...session.cascadeIds], { dx, dy });\n return ops.length > 0 && commitOps(ops);\n}\n"],"mappings":";;;;;;;;AAgBA,SAAS,aACP,SACA,OACA,IACyB;CACzB,MAAM,EAAE,IAAI,OAAO;CACnB,MAAM,OAAO,QAAQ;CACrB,KAAK,MAAM,CAAC,IAAI,QAAQ,QAAQ,YAC9B,KAAK,QAAQ,IAAI,IAAc,kBAAkB,SAAS,IAAI,KAAK,IAAI,EAAE,CAAC;CAE5E,OAAO,kBAAkB,QAAQ,WAAW,MAAM;EAChD,eAAe,QAAQ,iBAAiB,SAAS,KAAK,KAAK;EAC3D,SAAS;CACX,CAAC;AACH;;;AAIA,SAAgB,WAAW,OAA6B;CACtD,MAAM,EAAE,SAAS,OAAO;CAExB,MAAM,EAAE,IAAI,OAAO,MAAM;CACzB,MAAM,aAAa,QAAuB;EACxC,MAAM,YAAY,oBAChB;GACE,OAAO,QAAQ;GACf,YAAY,QAAQ;GACpB,YAAY,QAAQ;GACpB,OAAO,QAAQ,UAAU;EAC3B,GACA,GACF;EACA,OAAO,iBAAiB,SAAS,QAAQ,WAAW,CAAC,GAAG,KAAK,GAAG,SAAS,CAAC;CAC5E;CAGA,MAAM,SAAS,aAAa,SAAS;EAAE;EAAI;CAAG,GAAG,EAAE;CACnD,IAAI,WAAW,MAAM,OAAO;CAC5B,IAAI,WAAW,QAAW,OAAO,UAAU,MAAM;CAGjD,IAAI,OAAO,KAAK,OAAO,GAAG,OAAO;CAYjC,MAAM,MAAM,aAAa,SAAS,CAAC,GAAG,QAAQ,KAAK,GAAG,QAAQ,UAAU,GAAG;EAAE;EAAI;CAAG,CAAC;CACrF,OAAO,IAAI,SAAS,KAAK,UAAU,GAAG;AACxC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { rebaseLocalPose } from "../../../../core/scene/composeFrame.js";
|
|
2
|
+
import { scenePoseAdapter } from "../../../../core/scene/scenePoseAdapter.js";
|
|
2
3
|
import { asNodeId } from "../../../../core/scene/types.js";
|
|
3
|
-
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
4
4
|
import { createTransformOp } from "../../../../core/ops/transform.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
6
6
|
import { rebaseTransformOp } from "./rebase.js";
|
|
7
7
|
|
|
8
8
|
//#region src/interactions/actions/move/commit/layoutDrop.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { composeWorldPose, rebaseLocalPose } from "../../../../core/scene/composeFrame.js";
|
|
2
|
+
import { scenePoseAdapter } from "../../../../core/scene/scenePoseAdapter.js";
|
|
2
3
|
import { asNodeId } from "../../../../core/scene/types.js";
|
|
3
|
-
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
4
4
|
import { createTransformOp } from "../../../../core/ops/transform.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
6
6
|
import { rebaseTransformOp } from "./rebase.js";
|
|
7
7
|
import { draggedWorldPose, grabbedPoseAdapter } from "../delta.js";
|
|
8
8
|
import { groupBySourceContainer } from "../layout/dropPass.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { planeToPlane } from "../../../../core/viewport/parallax.js";
|
|
2
2
|
import { rebaseLocalPose } from "../../../../core/scene/composeFrame.js";
|
|
3
|
+
import { scenePoseAdapter } from "../../../../core/scene/scenePoseAdapter.js";
|
|
3
4
|
import { carryPose, planeOf } from "../../planeInput.js";
|
|
4
|
-
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
5
5
|
import { createTransformOp } from "../../../../core/ops/transform.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createReparentOp } from "../../../../core/ops/reparent.js";
|
|
7
7
|
import { draggedWorldPose, grabbedPoseAdapter } from "../delta.js";
|
|
8
8
|
import { translateOps } from "../translate.js";
|
|
9
9
|
import { createSetLayerOp } from "../../../../core/ops/setLayer.js";
|
|
@@ -19,15 +19,21 @@ function resolveDropTarget(session, at) {
|
|
|
19
19
|
if (!hit) return null;
|
|
20
20
|
const hitNode = session.scene.get(hit);
|
|
21
21
|
if (!hitNode) return null;
|
|
22
|
-
if (hitNode.kind === "container") return {
|
|
22
|
+
if (hitNode.kind === "container" && session.admits(hit)) return {
|
|
23
23
|
newParent: hit,
|
|
24
24
|
newLayer: hitNode.layer,
|
|
25
25
|
hitSibling: null
|
|
26
26
|
};
|
|
27
|
+
let newParent = hitNode.parent;
|
|
28
|
+
let hitSibling = hit;
|
|
29
|
+
while (newParent !== null && !session.admits(newParent)) {
|
|
30
|
+
hitSibling = newParent;
|
|
31
|
+
newParent = session.scene.get(newParent)?.parent ?? null;
|
|
32
|
+
}
|
|
27
33
|
return {
|
|
28
|
-
newParent
|
|
34
|
+
newParent,
|
|
29
35
|
newLayer: hitNode.layer,
|
|
30
|
-
hitSibling
|
|
36
|
+
hitSibling
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
/** Reparent and reposition each moved root as ops, keeping the world pose the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reparent.js","names":[],"sources":["../../../../../src/interactions/actions/move/commit/reparent.ts"],"sourcesContent":["import { createReparentOp } from 'core/ops/reparent';\nimport { createSetLayerOp } from 'core/ops/setLayer';\nimport { createTransformOp } from 'core/ops/transform';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport { planeToPlane } from 'core/viewport/parallax';\nimport { rebaseLocalPose } from 'core/scene/composePose';\nimport { scenePoseAdapter } from 'core/scene/scenePoseAdapter';\nimport { carryPose, planeOf } from '../../planeInput';\nimport { draggedWorldPose, grabbedPoseAdapter } from '../delta';\nimport type { MoveSession, ReparentOnDrop } from '../session';\nimport { translateOps } from '../translate';\n\n/** Resolved drop target — the new parent + layer + (for `'above'` mode)\n * the hit sibling whose z-order position the moved node should land\n * immediately above. `newParent === null` means \"land at the layer\n * root\" (top-level node of `newLayer`). */\nexport interface DropTarget {\n newParent: NodeId | null;\n newLayer: string;\n hitSibling: NodeId | null;\n}\n\n/** Walk the hit chain to find the appropriate drop target. Returns\n * `null` when no reparent should happen (drop on empty canvas, or the\n * only hits are the moved subtree itself). */\nexport function resolveDropTarget(\n session: MoveSession,\n at: { x: number; y: number },\n): DropTarget | null {\n const dep = session.nodeAtPoint;\n if (!dep) return null;\n\n // Exclude moved roots + their descendants. Otherwise we'd happily\n // reparent a node into itself (or under one of its own children).\n const exclude = new Set<NodeId>([...session.ids, ...session.cascadeIds]);\n const hit = dep(at, exclude);\n if (!hit) return null;\n\n const hitNode = session.scene.get(hit);\n if (!hitNode) return null;\n\n // Containers act as drop-INTO targets; leaves act as drop-NEXT-TO\n // targets (parent = leaf's parent). When the leaf has no parent\n // (top-level under a layer), `newParent === null` and the moved\n // subtree lands at the layer root.\n if (hitNode.kind === 'container') {\n return { newParent: hit, newLayer: hitNode.layer, hitSibling: null };\n }\n
|
|
1
|
+
{"version":3,"file":"reparent.js","names":[],"sources":["../../../../../src/interactions/actions/move/commit/reparent.ts"],"sourcesContent":["import { createReparentOp } from 'core/ops/reparent';\nimport { createSetLayerOp } from 'core/ops/setLayer';\nimport { createTransformOp } from 'core/ops/transform';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport { planeToPlane } from 'core/viewport/parallax';\nimport { rebaseLocalPose } from 'core/scene/composePose';\nimport { scenePoseAdapter } from 'core/scene/scenePoseAdapter';\nimport { carryPose, planeOf } from '../../planeInput';\nimport { draggedWorldPose, grabbedPoseAdapter } from '../delta';\nimport type { MoveSession, ReparentOnDrop } from '../session';\nimport { translateOps } from '../translate';\n\n/** Resolved drop target — the new parent + layer + (for `'above'` mode)\n * the hit sibling whose z-order position the moved node should land\n * immediately above. `newParent === null` means \"land at the layer\n * root\" (top-level node of `newLayer`). */\nexport interface DropTarget {\n newParent: NodeId | null;\n newLayer: string;\n hitSibling: NodeId | null;\n}\n\n/** Walk the hit chain to find the appropriate drop target. Returns\n * `null` when no reparent should happen (drop on empty canvas, or the\n * only hits are the moved subtree itself). */\nexport function resolveDropTarget(\n session: MoveSession,\n at: { x: number; y: number },\n): DropTarget | null {\n const dep = session.nodeAtPoint;\n if (!dep) return null;\n\n // Exclude moved roots + their descendants. Otherwise we'd happily\n // reparent a node into itself (or under one of its own children).\n const exclude = new Set<NodeId>([...session.ids, ...session.cascadeIds]);\n const hit = dep(at, exclude);\n if (!hit) return null;\n\n const hitNode = session.scene.get(hit);\n if (!hitNode) return null;\n\n // Containers act as drop-INTO targets; leaves act as drop-NEXT-TO\n // targets (parent = leaf's parent). When the leaf has no parent\n // (top-level under a layer), `newParent === null` and the moved\n // subtree lands at the layer root.\n if (hitNode.kind === 'container' && session.admits(hit)) {\n return { newParent: hit, newLayer: hitNode.layer, hitSibling: null };\n }\n // A container `canDropInto` refuses is a sibling to land beside, inside\n // the nearest container around it that admits the drop.\n let newParent = hitNode.parent;\n let hitSibling: NodeId = hit;\n while (newParent !== null && !session.admits(newParent)) {\n hitSibling = newParent;\n newParent = session.scene.get(newParent)?.parent ?? null;\n }\n return { newParent, newLayer: hitNode.layer, hitSibling };\n}\n\n/** Reparent and reposition each moved root as ops, keeping the world pose the\n * drag showed, then the ops that bring uncarried descendants along. */\nexport function reparentOps(\n session: MoveSession,\n target: DropTarget,\n mode: ReparentOnDrop,\n delta: { dx: number; dy: number },\n): Op[] {\n const { scene, pc, view } = session;\n const adapter = scenePoseAdapter(scene);\n const label = session.lifecycle.label;\n const ops: Op[] = [];\n // The destination's children as each op will find them: an earlier root's\n // landing shifts where a later one goes.\n const siblings = [...(target.newParent === null ? scene.roots : scene.childrenOf(target.newParent))];\n for (const id of session.ids) {\n if (!session.startPoses.has(id)) continue;\n const node = scene.get(id)!;\n const crossing = node.layer !== target.newLayer;\n const world = carryPose(\n session.descriptorOf(id),\n draggedWorldPose(session, grabbedPoseAdapter(session, adapter), id, delta),\n crossing ? planeToPlane(planeOf(view, node.layer), planeOf(view, target.newLayer)) : null,\n );\n const to = rebaseLocalPose(adapter, world, target.newParent as string | null, pc.compose, pc.decompose);\n\n let from = node.parent as string | null;\n if (crossing) {\n // The scene refuses a layer change on a node whose parent is on another layer.\n if (from !== null) {\n ops.push(createReparentOp({\n id: id as string, fromParentId: from, toParentId: null, label, coalesceKey: `reparent:${id}:orphan`,\n }));\n from = null;\n }\n ops.push(createSetLayerOp({ id: id as string, from: node.layer, to: target.newLayer, label }));\n }\n\n const was = siblings.indexOf(id);\n if (was >= 0) siblings.splice(was, 1);\n const hit = mode === 'above' && target.hitSibling\n ? siblings.indexOf(target.hitSibling)\n : -1;\n const toIndex = hit >= 0 ? hit + 1 : undefined;\n if (toIndex === undefined) siblings.push(id);\n else siblings.splice(toIndex, 0, id);\n\n ops.push(createReparentOp({\n id: id as string, fromParentId: from, toParentId: target.newParent as string | null, toIndex, label,\n }));\n ops.push(createTransformOp<unknown>({ id: id as string, from: node.pose, to, label }));\n }\n return [...ops, ...translateOps(session, session.cascadeIds, delta)];\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,SAAgB,kBACd,SACA,IACmB;CACnB,MAAM,MAAM,QAAQ;CACpB,IAAI,CAAC,KAAK,OAAO;CAKjB,MAAM,MAAM,IAAI,oBAAI,IADA,IAAY,CAAC,GAAG,QAAQ,KAAK,GAAG,QAAQ,UAAU,CAClD,CAAO;CAC3B,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,UAAU,QAAQ,MAAM,IAAI,GAAG;CACrC,IAAI,CAAC,SAAS,OAAO;CAMrB,IAAI,QAAQ,SAAS,eAAe,QAAQ,OAAO,GAAG,GACpD,OAAO;EAAE,WAAW;EAAK,UAAU,QAAQ;EAAO,YAAY;CAAK;CAIrE,IAAI,YAAY,QAAQ;CACxB,IAAI,aAAqB;CACzB,OAAO,cAAc,QAAQ,CAAC,QAAQ,OAAO,SAAS,GAAG;EACvD,aAAa;EACb,YAAY,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,UAAU;CACtD;CACA,OAAO;EAAE;EAAW,UAAU,QAAQ;EAAO;CAAW;AAC1D;;;AAIA,SAAgB,YACd,SACA,QACA,MACA,OACM;CACN,MAAM,EAAE,OAAO,IAAI,SAAS;CAC5B,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,QAAQ,QAAQ,UAAU;CAChC,MAAM,MAAY,CAAC;CAGnB,MAAM,WAAW,CAAC,GAAI,OAAO,cAAc,OAAO,MAAM,QAAQ,MAAM,WAAW,OAAO,SAAS,CAAE;CACnG,KAAK,MAAM,MAAM,QAAQ,KAAK;EAC5B,IAAI,CAAC,QAAQ,WAAW,IAAI,EAAE,GAAG;EACjC,MAAM,OAAO,MAAM,IAAI,EAAE;EACzB,MAAM,WAAW,KAAK,UAAU,OAAO;EACvC,MAAM,QAAQ,UACZ,QAAQ,aAAa,EAAE,GACvB,iBAAiB,SAAS,mBAAmB,SAAS,OAAO,GAAG,IAAI,KAAK,GACzE,WAAW,aAAa,QAAQ,MAAM,KAAK,KAAK,GAAG,QAAQ,MAAM,OAAO,QAAQ,CAAC,IAAI,IACvF;EACA,MAAM,KAAK,gBAAgB,SAAS,OAAO,OAAO,WAA4B,GAAG,SAAS,GAAG,SAAS;EAEtG,IAAI,OAAO,KAAK;EAChB,IAAI,UAAU;GAEZ,IAAI,SAAS,MAAM;IACjB,IAAI,KAAK,iBAAiB;KACpB;KAAc,cAAc;KAAM,YAAY;KAAM;KAAO,aAAa,YAAY,GAAG;IAC7F,CAAC,CAAC;IACF,OAAO;GACT;GACA,IAAI,KAAK,iBAAiB;IAAM;IAAc,MAAM,KAAK;IAAO,IAAI,OAAO;IAAU;GAAM,CAAC,CAAC;EAC/F;EAEA,MAAM,MAAM,SAAS,QAAQ,EAAE;EAC/B,IAAI,OAAO,GAAG,SAAS,OAAO,KAAK,CAAC;EACpC,MAAM,MAAM,SAAS,WAAW,OAAO,aACnC,SAAS,QAAQ,OAAO,UAAU,IAClC;EACJ,MAAM,UAAU,OAAO,IAAI,MAAM,IAAI;EACrC,IAAI,YAAY,QAAW,SAAS,KAAK,EAAE;OACtC,SAAS,OAAO,SAAS,GAAG,EAAE;EAEnC,IAAI,KAAK,iBAAiB;GACpB;GAAc,cAAc;GAAM,YAAY,OAAO;GAA4B;GAAS;EAChG,CAAC,CAAC;EACF,IAAI,KAAK,kBAA2B;GAAM;GAAc,MAAM,KAAK;GAAM;GAAI;EAAM,CAAC,CAAC;CACvF;CACA,OAAO,CAAC,GAAG,KAAK,GAAG,aAAa,SAAS,QAAQ,YAAY,KAAK,CAAC;AACrE"}
|
|
@@ -3,9 +3,7 @@ import { pointerStateOf } from "../pointerState.js";
|
|
|
3
3
|
import { snapMods } from "../../../features/snap/roles.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interactions/actions/move/frame.ts
|
|
6
|
-
function foldBehaviors(session, readers, moveCtx,
|
|
7
|
-
let dx = dx0;
|
|
8
|
-
let dy = dy0;
|
|
6
|
+
function foldBehaviors(session, readers, moveCtx, dx, dy) {
|
|
9
7
|
const posed = /* @__PURE__ */ new Map();
|
|
10
8
|
const opaque = /* @__PURE__ */ new Set();
|
|
11
9
|
const gctx = session.gestureCtx;
|
|
@@ -24,16 +22,12 @@ function foldBehaviors(session, readers, moveCtx, dx0, dy0) {
|
|
|
24
22
|
if (!r) continue;
|
|
25
23
|
if (r.poses) for (const [id, pose] of r.poses) posed.set(id, pose);
|
|
26
24
|
if (r.opaque) for (const id of r.opaque) opaque.add(id);
|
|
27
|
-
if (r.transform
|
|
25
|
+
if (r.transform) transform = r.transform;
|
|
28
26
|
if (r.snap !== void 0) gctx.snap = r.snap;
|
|
29
27
|
}
|
|
30
|
-
if (transform.kind === "translate") {
|
|
31
|
-
dx = transform.dx;
|
|
32
|
-
dy = transform.dy;
|
|
33
|
-
}
|
|
34
28
|
return {
|
|
35
|
-
dx,
|
|
36
|
-
dy,
|
|
29
|
+
dx: transform.dx,
|
|
30
|
+
dy: transform.dy,
|
|
37
31
|
posed,
|
|
38
32
|
opaque
|
|
39
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","names":[],"sources":["../../../../src/interactions/actions/move/frame.ts"],"sourcesContent":["import type { InvocationCtx } from '@weasel-js/routing';\nimport { pointerStateOf } from '../pointerState';\nimport type { NodeId } from 'core/scene/types';\nimport type { GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { BehaviorResult, GroupTransform } from '../../gestures/types';\nimport { draggedStoredPose } from './delta';\nimport { snapMods } from 'features/snap/roles';\nimport type { MoveFrame, MoveSession } from './session';\n\nfunction foldBehaviors(\n session: MoveSession,\n readers: GestureReaders,\n moveCtx: InvocationCtx,\n
|
|
1
|
+
{"version":3,"file":"frame.js","names":[],"sources":["../../../../src/interactions/actions/move/frame.ts"],"sourcesContent":["import type { InvocationCtx } from '@weasel-js/routing';\nimport { pointerStateOf } from '../pointerState';\nimport type { NodeId } from 'core/scene/types';\nimport type { GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { BehaviorResult, GroupTransform } from '../../gestures/types';\nimport { draggedStoredPose } from './delta';\nimport { snapMods } from 'features/snap/roles';\nimport type { MoveFrame, MoveSession } from './session';\n\nfunction foldBehaviors(\n session: MoveSession,\n readers: GestureReaders,\n moveCtx: InvocationCtx,\n dx: number,\n dy: number,\n): { dx: number; dy: number; posed: Map<NodeId, unknown>; opaque: Set<NodeId> } {\n const posed = new Map<NodeId, unknown>();\n const opaque = new Set<NodeId>();\n const gctx = session.gestureCtx;\n gctx.modifiers = { ...moveCtx.modifiers };\n gctx.pointer = pointerStateOf(moveCtx.drag!.current, moveCtx);\n gctx.view = readers.view();\n gctx.plane = readers.plane();\n // `current` is pre-populated from the raw cursor delta BEFORE\n // any behavior shapes `transform`. Unlike `onEnd`, it is NOT\n // refreshed after each behavior runs — so onMove behaviors\n // should derive position from `origin` + the `proposed`\n // GroupTransform arg, NOT from `ctx.current` (which reflects\n // the unmodified delta at this frame's start).\n for (const [id, ori] of session.startPoses) {\n gctx.current.set(id as string, draggedStoredPose(session, id, ori, dx, dy));\n }\n let transform: GroupTransform = { kind: 'translate', dx, dy };\n for (const b of session.behaviors) {\n const r: BehaviorResult<unknown> | void = b.onMove?.(gctx, transform);\n if (!r) continue;\n if (r.poses) for (const [id, pose] of r.poses) posed.set(id as NodeId, pose);\n if (r.opaque) for (const id of r.opaque) opaque.add(id as NodeId);\n if (r.transform) transform = r.transform;\n if (r.snap !== undefined) gctx.snap = r.snap;\n }\n return { dx: transform.dx, dy: transform.dy, posed, opaque };\n}\n\n/** The pointer's delta, moved so the subject lands on what the snap session\n * holds it to. */\nfunction snapDelta(session: MoveSession, moveCtx: InvocationCtx): { dx: number; dy: number } {\n const d = moveCtx.drag!.delta;\n if (!session.snap) return { dx: d.x, dy: d.y };\n const { press } = session;\n const out = session.snap.at({ x: press.x + d.x, y: press.y + d.y }, snapMods(moveCtx));\n return { dx: out.point.x - press.x, dy: out.point.y - press.y };\n}\n\n/** One move's delta and previews: the pointer's delta as the behaviors shaped\n * it, every displaced id's stored pose under it, and whatever else the\n * behaviors posed. */\nexport function nextFrame(session: MoveSession, readers: GestureReaders, moveCtx: InvocationCtx): MoveFrame {\n const snapped = snapDelta(session, moveCtx);\n const { dx, dy, posed, opaque } = foldBehaviors(session, readers, moveCtx, snapped.dx, snapped.dy);\n\n // The delta stays in the frame — no scene writes, no history entries.\n const delta = { dx, dy };\n // Every displaced id's pose (roots + cascade), published to the scene's\n // overrides by the action.\n const previews = new Map<NodeId, unknown>();\n for (const [id, ori] of session.startPoses) {\n const dragged = draggedStoredPose(session, id, ori, dx, dy);\n previews.set(id, session.carried.has(id) ? dragged : posed.get(id) ?? dragged);\n }\n for (const [id, pose] of posed) if (!session.startPoses.has(id)) previews.set(id, pose);\n return { delta, previews, opaque };\n}\n"],"mappings":";;;;;AASA,SAAS,cACP,SACA,SACA,SACA,IACA,IAC8E;CAC9E,MAAM,wBAAQ,IAAI,IAAqB;CACvC,MAAM,yBAAS,IAAI,IAAY;CAC/B,MAAM,OAAO,QAAQ;CACrB,KAAK,YAAY,EAAE,GAAG,QAAQ,UAAU;CACxC,KAAK,UAAU,eAAe,QAAQ,KAAM,SAAS,OAAO;CAC5D,KAAK,OAAO,QAAQ,KAAK;CACzB,KAAK,QAAQ,QAAQ,MAAM;CAO3B,KAAK,MAAM,CAAC,IAAI,QAAQ,QAAQ,YAC9B,KAAK,QAAQ,IAAI,IAAc,kBAAkB,SAAS,IAAI,KAAK,IAAI,EAAE,CAAC;CAE5E,IAAI,YAA4B;EAAE,MAAM;EAAa;EAAI;CAAG;CAC5D,KAAK,MAAM,KAAK,QAAQ,WAAW;EACjC,MAAM,IAAoC,EAAE,SAAS,MAAM,SAAS;EACpE,IAAI,CAAC,GAAG;EACR,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,OAAO,MAAM,IAAI,IAAc,IAAI;EAC3E,IAAI,EAAE,QAAQ,KAAK,MAAM,MAAM,EAAE,QAAQ,OAAO,IAAI,EAAY;EAChE,IAAI,EAAE,WAAW,YAAY,EAAE;EAC/B,IAAI,EAAE,SAAS,QAAW,KAAK,OAAO,EAAE;CAC1C;CACA,OAAO;EAAE,IAAI,UAAU;EAAI,IAAI,UAAU;EAAI;EAAO;CAAO;AAC7D;;;AAIA,SAAS,UAAU,SAAsB,SAAoD;CAC3F,MAAM,IAAI,QAAQ,KAAM;CACxB,IAAI,CAAC,QAAQ,MAAM,OAAO;EAAE,IAAI,EAAE;EAAG,IAAI,EAAE;CAAE;CAC7C,MAAM,EAAE,UAAU;CAClB,MAAM,MAAM,QAAQ,KAAK,GAAG;EAAE,GAAG,MAAM,IAAI,EAAE;EAAG,GAAG,MAAM,IAAI,EAAE;CAAE,GAAG,SAAS,OAAO,CAAC;CACrF,OAAO;EAAE,IAAI,IAAI,MAAM,IAAI,MAAM;EAAG,IAAI,IAAI,MAAM,IAAI,MAAM;CAAE;AAChE;;;;AAKA,SAAgB,UAAU,SAAsB,SAAyB,SAAmC;CAC1G,MAAM,UAAU,UAAU,SAAS,OAAO;CAC1C,MAAM,EAAE,IAAI,IAAI,OAAO,WAAW,cAAc,SAAS,SAAS,SAAS,QAAQ,IAAI,QAAQ,EAAE;CAGjG,MAAM,QAAQ;EAAE;EAAI;CAAG;CAGvB,MAAM,2BAAW,IAAI,IAAqB;CAC1C,KAAK,MAAM,CAAC,IAAI,QAAQ,QAAQ,YAAY;EAC1C,MAAM,UAAU,kBAAkB,SAAS,IAAI,KAAK,IAAI,EAAE;EAC1D,SAAS,IAAI,IAAI,QAAQ,QAAQ,IAAI,EAAE,IAAI,UAAU,MAAM,IAAI,EAAE,KAAK,OAAO;CAC/E;CACA,KAAK,MAAM,CAAC,IAAI,SAAS,OAAO,IAAI,CAAC,QAAQ,WAAW,IAAI,EAAE,GAAG,SAAS,IAAI,IAAI,IAAI;CACtF,OAAO;EAAE;EAAO;EAAU;CAAO;AACnC"}
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { translatePoseViaDescriptor } from "../../../core/geometry/poseDescriptor.js";
|
|
2
|
-
import {
|
|
2
|
+
import { carriedDescendants, sceneCarrySource } from "../../../core/scene/carryDescendants.js";
|
|
3
3
|
import { createTransformOp } from "../../../core/ops/transform.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interactions/actions/move/landedDescendants.ts
|
|
6
6
|
/**
|
|
7
|
-
* Ops that bring
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Ops that bring along the descendants of every node `ops` transforms. A
|
|
8
|
+
* layout drop or a behavior places a dragged root somewhere the drag delta
|
|
9
|
+
* does not describe, and a layout shifts siblings to make room, so each
|
|
10
|
+
* descendant moves by its nearest transformed ancestor's landed pose less
|
|
11
|
+
* that ancestor's start pose. A descendant `ops` already writes, or that a
|
|
11
12
|
* moving frame carries, is left alone.
|
|
12
13
|
*/
|
|
13
14
|
function landedDescendantOps(input, ops) {
|
|
14
|
-
const { scene, projection, startPoses,
|
|
15
|
+
const { scene, projection, startPoses, label } = input;
|
|
15
16
|
const landed = /* @__PURE__ */ new Map();
|
|
16
17
|
for (const op of ops) {
|
|
17
18
|
if (op.name !== "transform") continue;
|
|
18
19
|
const a = op.args;
|
|
19
|
-
|
|
20
|
+
const id = a.id;
|
|
21
|
+
landed.set(id, {
|
|
22
|
+
from: landed.get(id)?.from ?? startPoses.get(id) ?? a.from,
|
|
23
|
+
to: a.to
|
|
24
|
+
});
|
|
20
25
|
}
|
|
26
|
+
const source = sceneCarrySource(scene);
|
|
21
27
|
const out = [];
|
|
22
|
-
for (const root of
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
if (to === void 0 || start === void 0) continue;
|
|
26
|
-
const a = projection.getBounds(start);
|
|
28
|
+
for (const [root, { from, to }] of landed) {
|
|
29
|
+
if (from === void 0 || to === void 0) continue;
|
|
30
|
+
const a = projection.getBounds(from);
|
|
27
31
|
const b = projection.getBounds(to);
|
|
28
32
|
const dx = b.x - a.x;
|
|
29
33
|
const dy = b.y - a.y;
|
|
30
34
|
if (dx === 0 && dy === 0) continue;
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
const carried = carriedDescendants(source, root, (pose) => translatePoseViaDescriptor(pose, dx, dy, projection), (id) => landed.has(id));
|
|
36
|
+
for (const [id, pose] of carried) {
|
|
33
37
|
const node = scene.get(id);
|
|
34
|
-
if (
|
|
35
|
-
out.push(createTransformOp({
|
|
38
|
+
if (node) out.push(createTransformOp({
|
|
36
39
|
id,
|
|
37
40
|
from: node.pose,
|
|
38
|
-
to:
|
|
41
|
+
to: pose,
|
|
39
42
|
label
|
|
40
43
|
}));
|
|
41
44
|
}
|