@weasel-js/core 1.11.1 → 1.13.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +275 -0
- package/dist/WeaselProvider.js +1 -1
- package/dist/affordances/pathAnchors.js +10 -6
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/animation/poseTarget.js +46 -15
- package/dist/animation/poseTarget.js.map +1 -1
- package/dist/animation/poseTransition.js +3 -3
- package/dist/animation/poseTransition.js.map +1 -1
- package/dist/animation/reflow.js +3 -6
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/rig/bindRig.js +2 -2
- package/dist/animation/rig/bindRig.js.map +1 -1
- package/dist/animation/rig/skinBinding.js +2 -2
- package/dist/animation/rig/skinBinding.js.map +1 -1
- package/dist/barrel/canvas.js +5 -1
- package/dist/barrel/chrome.js +3 -1
- package/dist/barrel/paint.js +4 -4
- package/dist/barrel/paths.js +9 -4
- package/dist/barrel/renderer.js +3 -2
- package/dist/barrel/routing.js +4 -4
- package/dist/barrel/scene.js +7 -1
- package/dist/barrel/text.js +2 -2
- package/dist/barrel/viewport.js +6 -2
- package/dist/canvas/Canvas.js +2 -1
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +23 -34
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/ModalityHud.js +1 -1
- package/dist/canvas/NodeShape.js +5 -1
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js +2 -0
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
- package/dist/canvas/SceneCanvas/SurfaceDeclarations.js +23 -0
- package/dist/canvas/SceneCanvas/SurfaceDeclarations.js.map +1 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js +2 -1
- package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +2 -2
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/scenePointQuery.js +27 -5
- package/dist/canvas/SceneCanvas/scenePointQuery.js.map +1 -1
- package/dist/canvas/SceneCanvas/useActionTunings.js +6 -1
- package/dist/canvas/SceneCanvas/useActionTunings.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js +1 -0
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasTools.js +10 -2
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +25 -19
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +9 -3
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +17 -2
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +2 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +19 -4
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useScenePicking.js +31 -6
- package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +4 -5
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +7 -4
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +30 -12
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/ViewMarker.js +35 -0
- package/dist/canvas/ViewMarker.js.map +1 -0
- package/dist/canvas/accentColor.js +26 -3
- package/dist/canvas/accentColor.js.map +1 -1
- package/dist/canvas/buildSceneTree.js +14 -20
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/copiesAbove.js +1 -1
- package/dist/canvas/copiesAbove.js.map +1 -1
- package/dist/canvas/defaultDrawOne.js +11 -6
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/areaSelect.js +5 -2
- package/dist/canvas/deps/areaSelect.js.map +1 -1
- package/dist/canvas/deps/booleans.js +3 -2
- package/dist/canvas/deps/booleans.js.map +1 -1
- package/dist/canvas/deps/enteredGroup.js +81 -0
- package/dist/canvas/deps/enteredGroup.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +28 -16
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +10 -38
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/insertSite.js +39 -0
- package/dist/canvas/deps/insertSite.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +6 -3
- package/dist/canvas/deps/lassoSelect.js.map +1 -1
- package/dist/canvas/deps/pathEditCommits.js +3 -7
- package/dist/canvas/deps/pathEditCommits.js.map +1 -1
- package/dist/canvas/deps/pathLeaf.js +1 -1
- package/dist/canvas/deps/pathLeaf.js.map +1 -1
- package/dist/canvas/deps/slice.js +2 -1
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/derivedPath.js +14 -6
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/doubleClickTarget.js +9 -11
- package/dist/canvas/doubleClickTarget.js.map +1 -1
- package/dist/canvas/drawnBounds.js +26 -9
- package/dist/canvas/drawnBounds.js.map +1 -1
- package/dist/canvas/inheritedPaints.js +55 -0
- package/dist/canvas/inheritedPaints.js.map +1 -0
- package/dist/canvas/nodeShapes/derivedPainter.js +15 -16
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/nodePaint.js +7 -34
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -1
- package/dist/canvas/nodeShapes/pathPainter.js +7 -7
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/rectFallbackPainter.js +4 -5
- package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/shapePainter.js +9 -9
- package/dist/canvas/nodeShapes/shapePainter.js.map +1 -1
- package/dist/canvas/nodeShapes/textPainter.js +13 -12
- package/dist/canvas/nodeShapes/textPainter.js.map +1 -1
- package/dist/canvas/ownClip.js +24 -0
- package/dist/canvas/ownClip.js.map +1 -0
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/canvas/pickIndex/nodeBroadBox.js +86 -0
- package/dist/canvas/pickIndex/nodeBroadBox.js.map +1 -0
- package/dist/canvas/pickIndex/scenePickIndex.js +208 -0
- package/dist/canvas/pickIndex/scenePickIndex.js.map +1 -0
- package/dist/canvas/pickReach.js +3 -3
- package/dist/canvas/pickReach.js.map +1 -1
- package/dist/canvas/pickWalk.js +17 -91
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/poseCascade.js +1 -1
- package/dist/canvas/poseCascade.js.map +1 -1
- package/dist/canvas/publishPreviews.js +97 -0
- package/dist/canvas/publishPreviews.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +1 -1
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +7 -5
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +17 -10
- package/dist/canvas/sceneClipboard.js.map +1 -1
- package/dist/canvas/scenePickReads.js +37 -0
- package/dist/canvas/scenePickReads.js.map +1 -0
- package/dist/canvas/scenePickSource.js +74 -0
- package/dist/canvas/scenePickSource.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +9 -3
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +9 -4
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/shownNodes.js +15 -0
- package/dist/canvas/shownNodes.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +12 -8
- package/dist/canvas/surfaceContribution.js.map +1 -1
- package/dist/canvas/useCanvasView.js +4 -2
- package/dist/canvas/useCanvasView.js.map +1 -1
- package/dist/canvas/useLayerStack.js +6 -2
- package/dist/canvas/useLayerStack.js.map +1 -1
- package/dist/canvas/useSceneAdapter.js +5 -3
- package/dist/canvas/useSceneAdapter.js.map +1 -1
- package/dist/canvas/useViewAim.js +121 -0
- package/dist/canvas/useViewAim.js.map +1 -0
- package/dist/canvas/useViewNesting.js +3 -2
- package/dist/canvas/useViewNesting.js.map +1 -1
- package/dist/canvas/useViewRegistrySurface.js +4 -2
- package/dist/canvas/useViewRegistrySurface.js.map +1 -1
- package/dist/canvas/viewMarkers.js +63 -0
- package/dist/canvas/viewMarkers.js.map +1 -0
- package/dist/canvas/viewRegistry.js +27 -1
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/clipboard.d.ts +2 -2
- package/dist/{clone-C3e0OTuF.d.ts → clone-qb2e1F5p.d.ts} +2 -2
- package/dist/clone.d.ts +3 -3
- package/dist/core/isPlainObject.js +2 -2
- package/dist/core/layers/layerGroup.js.map +1 -1
- package/dist/core/pages/pageEdits.js +2 -3
- package/dist/core/pages/pageEdits.js.map +1 -1
- package/dist/core/paint/meshKindLazy.js +59 -2
- package/dist/core/paint/meshKindLazy.js.map +1 -1
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/arrivalWindow.js +1 -1
- package/dist/core/scene/arrivalWindow.js.map +1 -1
- package/dist/core/scene/clipNothing.js +10 -0
- package/dist/core/scene/clipNothing.js.map +1 -0
- package/dist/core/scene/declaredFieldSetters.js +44 -0
- package/dist/core/scene/declaredFieldSetters.js.map +1 -0
- package/dist/core/scene/depMemo.js +14 -3
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/dependents.js +9 -1
- package/dist/core/scene/dependents.js.map +1 -1
- package/dist/core/scene/derivedParts.js +10 -11
- package/dist/core/scene/derivedParts.js.map +1 -1
- package/dist/core/scene/documentOf.js +43 -0
- package/dist/core/scene/documentOf.js.map +1 -0
- package/dist/core/scene/effectivePose.js +44 -15
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +17 -14
- package/dist/core/scene/fieldEdits.js.map +1 -1
- package/dist/core/scene/fontReads.js +37 -0
- package/dist/core/scene/fontReads.js.map +1 -0
- package/dist/core/scene/historyForm.js +4 -4
- package/dist/core/scene/historyForm.js.map +1 -1
- package/dist/core/scene/inheritedPaint.js +97 -0
- package/dist/core/scene/inheritedPaint.js.map +1 -0
- package/dist/core/scene/kitOps.js +3 -23
- package/dist/core/scene/kitOps.js.map +1 -1
- package/dist/core/scene/kitRegistry.js +5 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layoutPass.js +1 -2
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/nodeAsShown.js +72 -0
- package/dist/core/scene/nodeAsShown.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +2 -10
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +21 -8
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/nodeStore.js +2 -4
- package/dist/core/scene/nodeStore.js.map +1 -1
- package/dist/core/scene/pathEffects/blend.js.map +1 -1
- package/dist/core/scene/pathEffects/derive.js +10 -4
- package/dist/core/scene/pathEffects/derive.js.map +1 -1
- package/dist/core/scene/pathEffects/effects.js +3 -1
- package/dist/core/scene/pathEffects/effects.js.map +1 -1
- package/dist/core/scene/pathEffects/foundHidden.js +35 -0
- package/dist/core/scene/pathEffects/foundHidden.js.map +1 -0
- package/dist/core/scene/pathEffects/textAlong.js +95 -0
- package/dist/core/scene/pathEffects/textAlong.js.map +1 -0
- package/dist/core/scene/plyStacks.js +89 -0
- package/dist/core/scene/plyStacks.js.map +1 -0
- package/dist/core/scene/poseHold.js +42 -24
- package/dist/core/scene/poseHold.js.map +1 -1
- package/dist/core/scene/poseOverrides.js +35 -38
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/posePlies.js +59 -0
- package/dist/core/scene/posePlies.js.map +1 -0
- package/dist/core/scene/reconcileSpecs.js +6 -15
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/renderOrder.js +10 -4
- package/dist/core/scene/renderOrder.js.map +1 -1
- package/dist/core/scene/sameValue.js +17 -0
- package/dist/core/scene/sameValue.js.map +1 -0
- package/dist/core/scene/scene.js +3 -3
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneEdits.js +8 -0
- package/dist/core/scene/sceneEdits.js.map +1 -1
- package/dist/core/scene/sceneState.js +1 -2
- package/dist/core/scene/sceneState.js.map +1 -1
- package/dist/core/scene/serialization.js +45 -9
- package/dist/core/scene/serialization.js.map +1 -1
- package/dist/core/scene/staleReplay.js +5 -2
- package/dist/core/scene/staleReplay.js.map +1 -1
- package/dist/core/scene/statedFields.js +4 -2
- package/dist/core/scene/statedFields.js.map +1 -1
- package/dist/core/scene/treeEdits.js +2 -4
- package/dist/core/scene/treeEdits.js.map +1 -1
- package/dist/core/scene/treeOrder.js +3 -1
- package/dist/core/scene/treeOrder.js.map +1 -1
- package/dist/core/scene/treeReads.js +1 -2
- package/dist/core/scene/treeReads.js.map +1 -1
- package/dist/core/scene/treeShape.js +13 -0
- package/dist/core/scene/treeShape.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/useScene.js +1 -1
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/{cornerHandles-BHuoMs1o.d.ts → cornerHandles-CNCb7aTY.d.ts} +3 -2
- package/dist/{depSchema-BpZNOv7q.d.ts → depSchema-B1RS-IJx.d.ts} +39 -18
- package/dist/devtools/handlers.js +1 -1
- package/dist/devtools/handlers.js.map +1 -1
- package/dist/devtools/protocol.js.map +1 -1
- package/dist/devtools/registry.js +4 -4
- package/dist/devtools/registry.js.map +1 -1
- package/dist/devtools-protocol.d.ts +4 -3
- package/dist/devtools.d.ts +3 -2
- package/dist/features/measure/measureContribution.js +4 -2
- package/dist/features/measure/measureContribution.js.map +1 -1
- package/dist/features/measure/measureHit.js +5 -3
- package/dist/features/measure/measureHit.js.map +1 -1
- package/dist/features/measure/measurement.js +1 -1
- package/dist/features/measure/measurement.js.map +1 -1
- package/dist/features/modes/modeLayers.js +14 -7
- package/dist/features/modes/modeLayers.js.map +1 -1
- package/dist/features/modes/modeTriggers.js +10 -6
- package/dist/features/modes/modeTriggers.js.map +1 -1
- package/dist/features/pathEffects/effectSources.js +69 -0
- package/dist/features/pathEffects/effectSources.js.map +1 -0
- package/dist/features/pathEffects/readSource.js +18 -2
- package/dist/features/pathEffects/readSource.js.map +1 -1
- package/dist/features/pathEffects/textItems.js +53 -0
- package/dist/features/pathEffects/textItems.js.map +1 -0
- package/dist/features/pathEffects/useEffectSourcesLayer.js +53 -0
- package/dist/features/pathEffects/useEffectSourcesLayer.js.map +1 -0
- package/dist/features/paths/editablePath.js +1 -1
- package/dist/features/paths/editablePath.js.map +1 -1
- package/dist/features/paths/pathEditState.js +5 -2
- package/dist/features/paths/pathEditState.js.map +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js.map +1 -1
- package/dist/features/selection/enteredGroupFrame.js +65 -0
- package/dist/features/selection/enteredGroupFrame.js.map +1 -0
- package/dist/features/selection/enteredGroupScope.js +44 -0
- package/dist/features/selection/enteredGroupScope.js.map +1 -0
- package/dist/features/text/sceneTextDrafts.js +64 -0
- package/dist/features/text/sceneTextDrafts.js.map +1 -0
- package/dist/features/text/textHitAt.js +34 -3
- package/dist/features/text/textHitAt.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +23 -19
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/viewports/aim.js +105 -0
- package/dist/features/viewports/aim.js.map +1 -0
- package/dist/features/viewports/viewMarker.js +82 -0
- package/dist/features/viewports/viewMarker.js.map +1 -0
- package/dist/features/viewports/viewMarkerDrag.js +55 -0
- package/dist/features/viewports/viewMarkerDrag.js.map +1 -0
- package/dist/index.d.ts +709 -258
- package/dist/index.js +33 -12
- package/dist/interactions/actions/admitsChild.js +11 -0
- package/dist/interactions/actions/admitsChild.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +2 -1
- package/dist/interactions/actions/booleans/booleans.js.map +1 -1
- package/dist/interactions/actions/booleans/operands.js +6 -5
- package/dist/interactions/actions/booleans/operands.js.map +1 -1
- package/dist/interactions/actions/clipboard/action.js +27 -17
- package/dist/interactions/actions/clipboard/action.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +44 -23
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorJoin.js +12 -6
- package/dist/interactions/actions/defaults/anchorJoin.js.map +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js +7 -4
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
- package/dist/interactions/actions/defaults/cancelGesture.js +11 -8
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
- package/dist/interactions/actions/defaults/contextMenu.js +33 -11
- package/dist/interactions/actions/defaults/contextMenu.js.map +1 -1
- package/dist/interactions/actions/defaults/createPaintAction.js +5 -2
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js +28 -14
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +11 -8
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterGroup.js +88 -0
- package/dist/interactions/actions/defaults/enterGroup.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +20 -10
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/escape.js +11 -8
- package/dist/interactions/actions/defaults/escape.js.map +1 -1
- package/dist/interactions/actions/defaults/exitPathEdit.js +7 -4
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +26 -20
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +10 -4
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -4
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +8 -2
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/pathEditTools.js +11 -8
- package/dist/interactions/actions/defaults/pathEditTools.js.map +1 -1
- package/dist/interactions/actions/defaults/pinchZoom.js +7 -4
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/reorder.js +24 -6
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/selectAll.js +15 -8
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -1
- package/dist/interactions/actions/defaults/selectDeep.js +35 -0
- package/dist/interactions/actions/defaults/selectDeep.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +7 -3
- package/dist/interactions/actions/defaults/setFill.js.map +1 -1
- package/dist/interactions/actions/defaults/setFillOpacity.js +1 -1
- package/dist/interactions/actions/defaults/setStroke.js +12 -11
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +1 -1
- package/dist/interactions/actions/defaults/toolActivate.js +7 -1
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
- package/dist/interactions/actions/defaults/toolResetToDefault.js +7 -4
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
- package/dist/interactions/actions/defaults/undoRedo.js +19 -13
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportWheelPan.js +16 -7
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportZoom.js +24 -6
- package/dist/interactions/actions/defaults/viewportZoom.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 +7 -4
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +8 -2
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +1 -0
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/parent.js +7 -5
- package/dist/interactions/actions/insert/parent.js.map +1 -1
- package/dist/interactions/actions/insert/placeAction.js +3 -2
- package/dist/interactions/actions/insert/placeAction.js.map +1 -1
- package/dist/interactions/actions/insert/repositionAction.js +2 -1
- package/dist/interactions/actions/insert/repositionAction.js.map +1 -1
- package/dist/interactions/actions/insert/session.js +2 -2
- package/dist/interactions/actions/insert/session.js.map +1 -1
- package/dist/interactions/actions/move/action.js +7 -4
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/commit/reparent.js +1 -1
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
- package/dist/interactions/actions/move/gestureAdapter.js +6 -7
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
- package/dist/interactions/actions/move/layout/exits.js +1 -1
- package/dist/interactions/actions/move/layout/exits.js.map +1 -1
- package/dist/interactions/actions/move/session.js +4 -4
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlinesAction.js +8 -5
- package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -1
- package/dist/interactions/actions/outlines/outlineStroke.js +5 -3
- package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -1
- package/dist/interactions/actions/pathCommands/cutJoin.js +8 -5
- package/dist/interactions/actions/pathCommands/cutJoin.js.map +1 -1
- package/dist/interactions/actions/pathCommands/pathNodes.js +14 -5
- package/dist/interactions/actions/pathCommands/pathNodes.js.map +1 -1
- package/dist/interactions/actions/resize/cornerHandles.js +2 -1
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +12 -7
- package/dist/interactions/actions/selectionSubtree.js.map +1 -1
- package/dist/interactions/actions/transform-again/action.js +8 -5
- package/dist/interactions/actions/transform-again/action.js.map +1 -1
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +14 -2
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
- package/dist/json.d.ts +4 -0
- package/dist/json.js +3 -0
- package/dist/kitSettingsSchema.js +8 -1
- package/dist/kitSettingsSchema.js.map +1 -1
- package/dist/{math-CrJULaZI.d.ts → math-C_elShP_.d.ts} +7 -1
- package/dist/math.d.ts +1 -1
- package/dist/math.js +2 -1
- package/dist/move.d.ts +4 -4
- package/dist/{options-DBxEryYq.d.ts → options-ClEm3SEl.d.ts} +1 -1
- package/dist/resize.d.ts +4 -4
- package/dist/test-seams.d.ts +6 -6
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +2 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/hand/dragPanContribution.js +4 -1
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -1
- package/dist/tools/builtin/hand/useHandTool.js +7 -4
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
- package/dist/tools/builtin/image/useImageTool.js +1 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -1
- package/dist/tools/builtin/lasso/useLassoTool.js +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +1 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/measure/useMeasureTool.js +12 -5
- package/dist/tools/builtin/measure/useMeasureTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +14 -6
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +13 -4
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/pressTarget.js +22 -0
- package/dist/tools/builtin/pressTarget.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +6 -5
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -1
- package/dist/tools/builtin/select/collapseDeferred.js +40 -0
- package/dist/tools/builtin/select/collapseDeferred.js.map +1 -0
- package/dist/tools/builtin/select/groupEntry.js +82 -0
- package/dist/tools/builtin/select/groupEntry.js.map +1 -0
- package/dist/tools/builtin/select/pressDecision.js +32 -0
- package/dist/tools/builtin/select/pressDecision.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +22 -13
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +74 -55
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/slice/useSliceTool.js +22 -8
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +13 -4
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/sticky/stickyNode.js +4 -1
- package/dist/tools/builtin/sticky/stickyNode.js.map +1 -1
- package/dist/tools/builtin/sticky/useStickyTool.js +10 -5
- package/dist/tools/builtin/sticky/useStickyTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +3 -1
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/{types-7puAuVD2.d.ts → types-49uYJN3j.d.ts} +1 -1
- package/dist/{types-CniVctmk.d.ts → types-BEdRIhNc.d.ts} +272 -109
- package/dist/{types-oFeQ5VjV.d.ts → types-p2alu-R1.d.ts} +1 -1
- package/dist/util/paint.js +1 -3
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +29 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositionAction.js","names":[],"sources":["../../../../src/interactions/actions/insert/repositionAction.ts"],"sourcesContent":["import { heldKeySpec, type Action, type GestureBinding } from '@weasel-js/routing';\nimport type { InsertLiveGesture } from './live';\n\n/**\n * Companion to `insertAction`: while its key is held, dragging moves the\n * shape being drawn instead of resizing it; letting go resumes resizing from\n * where the shape now sits. No-op when no insert is in flight.\n */\nexport const insertRepositionAction: Action = {\n id: 'insert.reposition',\n label: 'Insert — reposition',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n invoker: {\n timing: 'ongoing',\n start: (ctx) => {\n const gesture = ctx.deps.insertLive?.gesture as InsertLiveGesture | null | undefined;\n if (!gesture || !gesture.open) return {};\n gesture.repositioning = true;\n return {\n kind: 'insert.reposition',\n onEnd: () => { gesture.repositioning = false; },\n };\n },\n },\n requires: ['insertLive'],\n};\n\n/**\n * The binding a shape-drawing tool adds so holding Space mid-draw repositions\n * the shape. Gated to the tool's own engaged phase, so Space between drags is\n * left to the offhand hand tool. Shift and Alt may be down with it, so a\n * constrained or from-center draw can be moved without letting go of them.\n */\nexport const INSERT_REPOSITION_BINDING: GestureBinding = {\n spec: { ...heldKeySpec(' '), phase: 'engaged' },\n actionId: 'insert.reposition',\n};\n"],"mappings":";;;;;;;;AAQA,IAAa,yBAAiC;CAC5C,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,SAAS;EACP,QAAQ;EACR,QAAQ,QAAQ;GACd,MAAM,UAAU,IAAI,KAAK,YAAY;GACrC,IAAI,CAAC,WAAW,CAAC,QAAQ,MAAM,OAAO,CAAC;GACvC,QAAQ,gBAAgB;GACxB,OAAO;IACL,MAAM;IACN,aAAa;KAAE,QAAQ,gBAAgB;IAAO;GAChD;EACF;CACF;CACA,UAAU,CAAC,YAAY;AACzB;;;;;;;AAQA,IAAa,4BAA4C;CACvD,MAAM;EAAE,GAAG,YAAY,GAAG;EAAG,OAAO;CAAU;CAC9C,UAAU;
|
|
1
|
+
{"version":3,"file":"repositionAction.js","names":[],"sources":["../../../../src/interactions/actions/insert/repositionAction.ts"],"sourcesContent":["import { heldKeySpec, type Action, type GestureBinding } from '@weasel-js/routing';\nimport type { InsertLiveGesture } from './live';\n\n/**\n * Companion to `insertAction`: while its key is held, dragging moves the\n * shape being drawn instead of resizing it; letting go resumes resizing from\n * where the shape now sits. No-op when no insert is in flight.\n */\nexport const insertRepositionAction: Action = {\n id: 'insert.reposition',\n label: 'Insert — reposition',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n invoker: {\n timing: 'ongoing',\n start: (ctx) => {\n const gesture = ctx.deps.insertLive?.gesture as InsertLiveGesture | null | undefined;\n if (!gesture || !gesture.open) return {};\n gesture.repositioning = true;\n return {\n kind: 'insert.reposition',\n onEnd: () => { gesture.repositioning = false; },\n };\n },\n },\n requires: ['insertLive'],\n};\n\n/**\n * The binding a shape-drawing tool adds so holding Space mid-draw repositions\n * the shape. Gated to the tool's own engaged phase, so Space between drags is\n * left to the offhand hand tool. Shift and Alt may be down with it, so a\n * constrained or from-center draw can be moved without letting go of them.\n */\nexport const INSERT_REPOSITION_BINDING: GestureBinding = {\n spec: { ...heldKeySpec(' '), phase: 'engaged' },\n actionId: 'insert.reposition',\n opts: { id: 'insert.reposition.held' },\n};\n"],"mappings":";;;;;;;;AAQA,IAAa,yBAAiC;CAC5C,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,SAAS;EACP,QAAQ;EACR,QAAQ,QAAQ;GACd,MAAM,UAAU,IAAI,KAAK,YAAY;GACrC,IAAI,CAAC,WAAW,CAAC,QAAQ,MAAM,OAAO,CAAC;GACvC,QAAQ,gBAAgB;GACxB,OAAO;IACL,MAAM;IACN,aAAa;KAAE,QAAQ,gBAAgB;IAAO;GAChD;EACF;CACF;CACA,UAAU,CAAC,YAAY;AACzB;;;;;;;AAQA,IAAa,4BAA4C;CACvD,MAAM;EAAE,GAAG,YAAY,GAAG;EAAG,OAAO;CAAU;CAC9C,UAAU;CACV,MAAM,EAAE,IAAI,yBAAyB;AACvC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { insertParent } from "./parent.js";
|
|
1
2
|
import { gestureReaders } from "../../gestures/shared/screenTolerance.js";
|
|
2
3
|
import { pointerStateOf } from "../pointerState.js";
|
|
3
4
|
import { SNAP_ANGLE_STEP, snapMods } from "../../../features/snap/roles.js";
|
|
4
5
|
import { insertKind } from "./shape.js";
|
|
5
6
|
import { spanSnap } from "../../../features/snap/spanSnap.js";
|
|
6
|
-
import { insertParent } from "./parent.js";
|
|
7
7
|
import { resolveParams } from "@weasel-js/routing";
|
|
8
8
|
|
|
9
9
|
//#region src/interactions/actions/insert/session.ts
|
|
@@ -18,7 +18,7 @@ function beginInsert(ctx, opts) {
|
|
|
18
18
|
const selection = ctx.deps.selection;
|
|
19
19
|
const priorSelection = selection ? [...selection.get()] : [];
|
|
20
20
|
if (selection && priorSelection.length > 0) selection.clear();
|
|
21
|
-
const parent = insertParent(ctx.deps.scene, ctx.deps.insertInto?.get());
|
|
21
|
+
const parent = insertParent(ctx.deps.scene, ctx.deps.insertInto?.get(), ctx.deps.canDropInto);
|
|
22
22
|
const constrain = () => insertKind(resolveParams(opts?.params)) === "line" ? { step: SNAP_ANGLE_STEP } : void 0;
|
|
23
23
|
const snap = spanSnap(ctx.deps.snap, constrain, parent === null ? {} : { parent });
|
|
24
24
|
const behaviors = opts?.behaviors ?? [];
|
|
@@ -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 { 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,
|
|
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(), ctx.deps.canDropInto);\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,aA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AC5B,SAAS,IAAI,UAAU;GACvB,QAAQ;IAAE,OAAO;IAAY,SAAS;GAAW;EAExB;CAAM;AACnC"}
|
|
@@ -27,10 +27,13 @@ var moveAction = inPlane({
|
|
|
27
27
|
id: "move",
|
|
28
28
|
label: "Move",
|
|
29
29
|
activeCursor: "move",
|
|
30
|
-
defaultBinding: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
defaultBinding: [{
|
|
31
|
+
spec: {
|
|
32
|
+
kind: "drag",
|
|
33
|
+
target: "selected-body"
|
|
34
|
+
},
|
|
35
|
+
opts: { id: "move.drag" }
|
|
36
|
+
}],
|
|
34
37
|
eligible: { capability: "transforms-selection" },
|
|
35
38
|
modifierRoles: SNAP_ROLES,
|
|
36
39
|
requires: [
|
|
@@ -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 { 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;
|
|
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: [{ spec: { kind: 'drag', target: 'selected-body' }, opts: { id: 'move.drag' } }],\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,CAAC;EAAE,MAAM;GAAE,MAAM;GAAQ,QAAQ;EAAgB;EAAG,MAAM,EAAE,IAAI,YAAY;CAAE,CAAC;CAC/F,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,SA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cAAc"}
|
|
@@ -19,7 +19,7 @@ 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 (
|
|
22
|
+
if (session.admits(hit)) return {
|
|
23
23
|
newParent: hit,
|
|
24
24
|
newLayer: hitNode.layer,
|
|
25
25
|
hitSibling: null
|
|
@@ -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 //
|
|
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 // A node that admits the drop is a drop-INTO target; any other is a\n // drop-NEXT-TO target (parent = its parent). When it has no parent\n // (top-level under a layer), `newParent === null` and the moved\n // subtree lands at the layer root.\n if (session.admits(hit)) {\n return { newParent: hit, newLayer: hitNode.layer, hitSibling: null };\n }\n // A node that refuses the drop is a sibling to land beside, inside\n // the nearest ancestor that admits it.\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 [...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AK,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"}
|
|
@@ -16,16 +16,15 @@ function moveGestureAdapter(scene, commit, selection) {
|
|
|
16
16
|
for (const [id, pose] of poses) {
|
|
17
17
|
const nodeId = asNodeId(id);
|
|
18
18
|
const mine = previews.get(id);
|
|
19
|
-
const installed = mine !== void 0 && overrides.get(nodeId) === mine;
|
|
20
19
|
if (pose === null) {
|
|
21
20
|
previews.delete(id);
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
else {
|
|
25
|
-
const entry = { pose };
|
|
26
|
-
previews.set(id, entry);
|
|
27
|
-
overrides.set(nodeId, entry);
|
|
21
|
+
if (mine !== void 0) overrides.clear(nodeId, mine);
|
|
22
|
+
continue;
|
|
28
23
|
}
|
|
24
|
+
const entry = mine ?? { pose };
|
|
25
|
+
entry.pose = pose;
|
|
26
|
+
previews.set(id, entry);
|
|
27
|
+
if (!overrides.has(nodeId, entry)) overrides.set(nodeId, entry);
|
|
29
28
|
}
|
|
30
29
|
overrides.commit();
|
|
31
30
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestureAdapter.js","names":[],"sources":["../../../../src/interactions/actions/move/gestureAdapter.ts"],"sourcesContent":["/**\n * The scene-backed adapter the move behavior pipeline reads and commits\n * through: the default actions' commit adapter, plus what a behavior needs\n * while the gesture runs and after it ends (`previewPoses`, `poseTarget`, and\n * an `applyOps` of its own).\n */\nimport type { Op } from 'core/ops/types';\nimport type { Node, PoseOverride, Scene } from 'core/scene/types';\nimport { asNodeId } from 'core/scene/types';\nimport type { MoveAdapter } from 'core/adapters/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { scenePoseTarget } from '../../../animation/poseTarget';\nimport { defaultCommitAdapter } from '../defaultCommitAdapter';\n\nexport type MoveGestureAdapter<TPose> = MoveAdapter<Node<unknown, string, TPose>, TPose>\n & ReturnType<typeof defaultCommitAdapter<TPose>>\n & { previewPoses(poses: ReadonlyMap<string, TPose | null>): void };\n\n/** `commit` is how a behavior's own `applyOps` batch lands; the returned\n * adapter is passed back so the ops apply through it. Left out, the adapter\n * has no `applyOps`. `selection` is as `defaultCommitAdapter` takes it. */\nexport function moveGestureAdapter<TPose>(\n scene: Scene<unknown, string, TPose>,\n commit?: (ops: Op[], label: string, adapter: MoveGestureAdapter<TPose>) => void,\n selection?: SelectionApi['adapterMethods'],\n): MoveGestureAdapter<TPose> {\n const previews = new Map<string, PoseOverride<TPose>>();\n const adapter: MoveGestureAdapter<TPose> = {\n ...defaultCommitAdapter(scene, selection),\n ...(commit ? { applyOps: (ops: Op[], label: string) => commit(ops, label, adapter) } : {}),\n previewPoses: (poses) => {\n const { overrides } = scene;\n for (const [id, pose] of poses) {\n const nodeId = asNodeId(id);\n const mine = previews.get(id);\n
|
|
1
|
+
{"version":3,"file":"gestureAdapter.js","names":[],"sources":["../../../../src/interactions/actions/move/gestureAdapter.ts"],"sourcesContent":["/**\n * The scene-backed adapter the move behavior pipeline reads and commits\n * through: the default actions' commit adapter, plus what a behavior needs\n * while the gesture runs and after it ends (`previewPoses`, `poseTarget`, and\n * an `applyOps` of its own).\n */\nimport type { Op } from 'core/ops/types';\nimport type { Node, PoseOverride, Scene } from 'core/scene/types';\nimport { asNodeId } from 'core/scene/types';\nimport type { MoveAdapter } from 'core/adapters/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { scenePoseTarget } from '../../../animation/poseTarget';\nimport { defaultCommitAdapter } from '../defaultCommitAdapter';\n\nexport type MoveGestureAdapter<TPose> = MoveAdapter<Node<unknown, string, TPose>, TPose>\n & ReturnType<typeof defaultCommitAdapter<TPose>>\n & { previewPoses(poses: ReadonlyMap<string, TPose | null>): void };\n\n/** `commit` is how a behavior's own `applyOps` batch lands; the returned\n * adapter is passed back so the ops apply through it. Left out, the adapter\n * has no `applyOps`. `selection` is as `defaultCommitAdapter` takes it. */\nexport function moveGestureAdapter<TPose>(\n scene: Scene<unknown, string, TPose>,\n commit?: (ops: Op[], label: string, adapter: MoveGestureAdapter<TPose>) => void,\n selection?: SelectionApi['adapterMethods'],\n): MoveGestureAdapter<TPose> {\n const previews = new Map<string, PoseOverride<TPose>>();\n const adapter: MoveGestureAdapter<TPose> = {\n ...defaultCommitAdapter(scene, selection),\n ...(commit ? { applyOps: (ops: Op[], label: string) => commit(ops, label, adapter) } : {}),\n previewPoses: (poses) => {\n const { overrides } = scene;\n for (const [id, pose] of poses) {\n const nodeId = asNodeId(id);\n const mine = previews.get(id);\n if (pose === null) {\n previews.delete(id);\n if (mine !== undefined) overrides.clear(nodeId, mine);\n continue;\n }\n const entry = mine ?? { pose };\n entry.pose = pose;\n previews.set(id, entry);\n // Back where it stood if the table dropped it: the node went and came back.\n if (!overrides.has(nodeId, entry)) overrides.set(nodeId, entry);\n }\n overrides.commit();\n },\n poseTarget: (id, descriptor) => scenePoseTarget(scene, id, descriptor),\n };\n return adapter;\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,mBACd,OACA,QACA,WAC2B;CAC3B,MAAM,2BAAW,IAAI,IAAiC;CACtD,MAAM,UAAqC;EACzC,GAAG,qBAAqB,OAAO,SAAS;EACxC,GAAI,SAAS,EAAE,WAAW,KAAW,UAAkB,OAAO,KAAK,OAAO,OAAO,EAAE,IAAI,CAAC;EACxF,eAAe,UAAU;GACvB,MAAM,EAAE,cAAc;GACtB,KAAK,MAAM,CAAC,IAAI,SAAS,OAAO;IAC9B,MAAM,SAAS,SAAS,EAAE;IAC1B,MAAM,OAAO,SAAS,IAAI,EAAE;IAC5B,IAAI,SAAS,MAAM;KACjB,SAAS,OAAO,EAAE;KAClB,IAAI,SAAS,QAAW,UAAU,MAAM,QAAQ,IAAI;KACpD;IACF;IACA,MAAM,QAAQ,QAAQ,EAAE,KAAK;IAC7B,MAAM,OAAO;IACb,SAAS,IAAI,IAAI,KAAK;IAEtB,IAAI,CAAC,UAAU,IAAI,QAAQ,KAAK,GAAG,UAAU,IAAI,QAAQ,KAAK;GAChE;GACA,UAAU,OAAO;EACnB;EACA,aAAa,IAAI,eAAe,gBAAgB,OAAO,IAAI,UAAU;CACvE;CACA,OAAO;AACT"}
|
|
@@ -38,7 +38,7 @@ function resolveLayoutExits(session, dropCenter, ids) {
|
|
|
38
38
|
for (const id of parentId === null ? scene.roots : scene.childrenOf(parentId)) {
|
|
39
39
|
if (excluded.has(id)) continue;
|
|
40
40
|
const node = scene.get(id);
|
|
41
|
-
if (!node
|
|
41
|
+
if (!node) continue;
|
|
42
42
|
if (node.layer === layer && depth >= bestDepth && layoutDep.getLayout(id) === null && holds(id, null) && session.admits(id)) {
|
|
43
43
|
best = id;
|
|
44
44
|
bestDepth = depth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exits.js","names":[],"sources":["../../../../../src/interactions/actions/move/layout/exits.ts"],"sourcesContent":["import type { NodeId } from 'core/scene/types';\nimport { poseDescriptorForNode } from 'core/geometry/poseDescriptor';\nimport { toPlane } from 'core/viewport/parallax';\nimport { composeWorldPose } from 'core/scene/composePose';\nimport { scenePoseAdapter } from 'core/scene/scenePoseAdapter';\nimport type { LayoutStrategy } from '../../../../layout/types';\nimport { planeOf } from '../../planeInput';\nimport type { MoveSession } from '../session';\nimport { pointInBounds } from './container';\n\n/** Where each dragged root that leaves its layout container on release lands.\n * A root leaves when the drop center falls outside the body of the layout\n * container holding it, and lands under the innermost plain container beneath\n * the drop that admits it (`canDropInto`) — a layout container there has\n * already declined it — or at the top level of its layer. A root whose parent\n * has no layout is not this pass's to move; `reparentOnDrop` decides for those. */\nexport function resolveLayoutExits(\n session: MoveSession, dropCenter: { x: number; y: number } | null, ids: Iterable<NodeId>,\n): Map<NodeId, NodeId | null> {\n const out = new Map<NodeId, NodeId | null>();\n const layoutDep = session.layout;\n const center = dropCenter;\n if (!layoutDep || !center) return out;\n const { scene, pc, projection: d } = session;\n const poseAdapter = scenePoseAdapter(scene);\n const excluded = new Set<NodeId>([...session.ids, ...session.cascadeIds]);\n const holds = (id: NodeId, layout: LayoutStrategy<unknown> | null): boolean => {\n const node = scene.get(id)!;\n const plane = planeOf(session.view, node.layer);\n const at = plane ? toPlane(plane, center) : center;\n const pose = composeWorldPose(poseAdapter, id as string, pc.compose);\n if (layout?.contains) return layout.contains(pose, at);\n const b = poseDescriptorForNode(d, node).getBounds(pose);\n return pointInBounds(b, at);\n };\n const landings = new Map<string, NodeId | null>();\n const landingOn = (layer: string): NodeId | null => {\n if (landings.has(layer)) return landings.get(layer)!;\n // Deepest wins; among equals, the later sibling (painted over the other).\n let best: NodeId | null = null;\n let bestDepth = -1;\n const walk = (parentId: NodeId | null, depth: number): void => {\n for (const id of parentId === null ? scene.roots : scene.childrenOf(parentId)) {\n if (excluded.has(id)) continue;\n const node = scene.get(id);\n if (!node
|
|
1
|
+
{"version":3,"file":"exits.js","names":[],"sources":["../../../../../src/interactions/actions/move/layout/exits.ts"],"sourcesContent":["import type { NodeId } from 'core/scene/types';\nimport { poseDescriptorForNode } from 'core/geometry/poseDescriptor';\nimport { toPlane } from 'core/viewport/parallax';\nimport { composeWorldPose } from 'core/scene/composePose';\nimport { scenePoseAdapter } from 'core/scene/scenePoseAdapter';\nimport type { LayoutStrategy } from '../../../../layout/types';\nimport { planeOf } from '../../planeInput';\nimport type { MoveSession } from '../session';\nimport { pointInBounds } from './container';\n\n/** Where each dragged root that leaves its layout container on release lands.\n * A root leaves when the drop center falls outside the body of the layout\n * container holding it, and lands under the innermost plain container beneath\n * the drop that admits it (`canDropInto`) — a layout container there has\n * already declined it — or at the top level of its layer. A root whose parent\n * has no layout is not this pass's to move; `reparentOnDrop` decides for those. */\nexport function resolveLayoutExits(\n session: MoveSession, dropCenter: { x: number; y: number } | null, ids: Iterable<NodeId>,\n): Map<NodeId, NodeId | null> {\n const out = new Map<NodeId, NodeId | null>();\n const layoutDep = session.layout;\n const center = dropCenter;\n if (!layoutDep || !center) return out;\n const { scene, pc, projection: d } = session;\n const poseAdapter = scenePoseAdapter(scene);\n const excluded = new Set<NodeId>([...session.ids, ...session.cascadeIds]);\n const holds = (id: NodeId, layout: LayoutStrategy<unknown> | null): boolean => {\n const node = scene.get(id)!;\n const plane = planeOf(session.view, node.layer);\n const at = plane ? toPlane(plane, center) : center;\n const pose = composeWorldPose(poseAdapter, id as string, pc.compose);\n if (layout?.contains) return layout.contains(pose, at);\n const b = poseDescriptorForNode(d, node).getBounds(pose);\n return pointInBounds(b, at);\n };\n const landings = new Map<string, NodeId | null>();\n const landingOn = (layer: string): NodeId | null => {\n if (landings.has(layer)) return landings.get(layer)!;\n // Deepest wins; among equals, the later sibling (painted over the other).\n let best: NodeId | null = null;\n let bestDepth = -1;\n const walk = (parentId: NodeId | null, depth: number): void => {\n for (const id of parentId === null ? scene.roots : scene.childrenOf(parentId)) {\n if (excluded.has(id)) continue;\n const node = scene.get(id);\n if (!node) continue;\n if (node.layer === layer && depth >= bestDepth\n && layoutDep.getLayout(id as string) === null && holds(id, null) && session.admits(id)) {\n best = id;\n bestDepth = depth;\n }\n walk(id, depth + 1);\n }\n };\n walk(null, 0);\n landings.set(layer, best);\n return best;\n };\n for (const id of ids) {\n const node = scene.get(id);\n const parent = node?.parent ?? null;\n if (!node || parent === null) continue;\n const layout = layoutDep.getLayout(parent as string);\n if (!layout || holds(parent, layout)) continue;\n out.set(id, landingOn(node.layer));\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAgB,mBACd,SAAsB,YAA6C,KACvC;CAC5B,MAAM,sBAAM,IAAI,IAA2B;CAC3C,MAAM,YAAY,QAAQ;CAC1B,MAAM,SAAS;CACf,IAAI,CAAC,aAAa,CAAC,QAAQ,OAAO;CAClC,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM;CACrC,MAAM,cAAc,iBAAiB,KAAK;CAC1C,MAAM,2BAAW,IAAI,IAAY,CAAC,GAAG,QAAQ,KAAK,GAAG,QAAQ,UAAU,CAAC;CACxE,MAAM,SAAS,IAAY,WAAoD;EAC7E,MAAM,OAAO,MAAM,IAAI,EAAE;EACzB,MAAM,QAAQ,QAAQ,QAAQ,MAAM,KAAK,KAAK;EAC9C,MAAM,KAAK,QAAQ,QAAQ,OAAO,MAAM,IAAI;EAC5C,MAAM,OAAO,iBAAiB,aAAa,IAAc,GAAG,OAAO;EACnE,IAAI,QAAQ,UAAU,OAAO,OAAO,SAAS,MAAM,EAAE;EACrD,MAAM,IAAI,sBAAsB,GAAG,IAAI,CAAC,CAAC,UAAU,IAAI;EACvD,OAAO,cAAc,GAAG,EAAE;CAC5B;CACA,MAAM,2BAAW,IAAI,IAA2B;CAChD,MAAM,aAAa,UAAiC;EAClD,IAAI,SAAS,IAAI,KAAK,GAAG,OAAO,SAAS,IAAI,KAAK;EAElD,IAAI,OAAsB;EAC1B,IAAI,YAAY;EAChB,MAAM,QAAQ,UAAyB,UAAwB;GAC7D,KAAK,MAAM,MAAM,aAAa,OAAO,MAAM,QAAQ,MAAM,WAAW,QAAQ,GAAG;IAC7E,IAAI,SAAS,IAAI,EAAE,GAAG;IACtB,MAAM,OAAO,MAAM,IAAI,EAAE;IACzB,IAAI,CAAC,MAAM;IACX,IAAI,KAAK,UAAU,SAAS,SAAS,aAChC,UAAU,UAAU,EAAY,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,QAAQ,OAAO,EAAE,GAAG;KACxF,OAAO;KACP,YAAY;IACd;IACA,KAAK,IAAI,QAAQ,CAAC;GACpB;EACF;EACA,KAAK,MAAM,CAAC;EACZ,SAAS,IAAI,OAAO,IAAI;EACxB,OAAO;CACT;CACA,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,OAAO,MAAM,IAAI,EAAE;EACzB,MAAM,SAAS,MAAM,UAAU;EAC/B,IAAI,CAAC,QAAQ,WAAW,MAAM;EAC9B,MAAM,SAAS,UAAU,UAAU,MAAgB;EACnD,IAAI,CAAC,UAAU,MAAM,QAAQ,MAAM,GAAG;EACtC,IAAI,IAAI,IAAI,UAAU,KAAK,KAAK,CAAC;CACnC;CACA,OAAO;AACT"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { admitsChild } from "../admitsChild.js";
|
|
1
2
|
import { nodeDescriptors, poseDescriptorOf } from "../poseDescriptorDep.js";
|
|
2
3
|
import { transformFinisher } from "../transformFinish.js";
|
|
3
4
|
import { commitGestureOps, readGestureLifecycle } from "../gestureLifecycle.js";
|
|
@@ -11,10 +12,9 @@ import { lazySnapSession } from "../../../features/snap/lazySession.js";
|
|
|
11
12
|
import { DRAG_THRESHOLD_PX, isPathEditPart, resolveParams } from "@weasel-js/routing";
|
|
12
13
|
|
|
13
14
|
//#region src/interactions/actions/move/session.ts
|
|
14
|
-
function admitsOf(canDropInto, ids) {
|
|
15
|
-
if (canDropInto === void 0) return () => true;
|
|
15
|
+
function admitsOf(canDropInto, ids, scene) {
|
|
16
16
|
const roots = ids;
|
|
17
|
-
return (parent) =>
|
|
17
|
+
return (parent) => admitsChild(scene, parent, roots, canDropInto);
|
|
18
18
|
}
|
|
19
19
|
/** Capture a drag at press. Null when there is nothing to move. Runs each
|
|
20
20
|
* behavior's `onStart`. `frame` reads the drag's latest frame, for the
|
|
@@ -81,7 +81,7 @@ function beginMove(ctx, opts, frame) {
|
|
|
81
81
|
geometryProjection,
|
|
82
82
|
lifecycle,
|
|
83
83
|
nodeAtPoint: ctx.deps.nodeAtPoint,
|
|
84
|
-
admits: admitsOf(ctx.deps.canDropInto, ids),
|
|
84
|
+
admits: admitsOf(ctx.deps.canDropInto, ids, scene),
|
|
85
85
|
reparentOnDrop: () => resolveParams(opts?.params)?.["reparentOnDrop"] ?? "off",
|
|
86
86
|
dragThresholdPx,
|
|
87
87
|
snap: lazySnapSession(ctx.deps.snap, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":[],"sources":["../../../../src/interactions/actions/move/session.ts"],"sourcesContent":["import type { BindingOpts, InvocationCtx } from '@weasel-js/routing';\nimport { DRAG_THRESHOLD_PX, isPathEditPart, resolveParams } from '@weasel-js/routing';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { PoseDescriptor } from 'core/geometry/poseDescriptor';\nimport type { PoseComposition } from 'core/scene/composePose';\nimport { gestureReaders, type GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { GestureContext, MoveBehavior } from '../../gestures/types';\nimport type { CanDropIntoDep, LayoutDep, NodeAtPointDep } from '../depSchema';\nimport type { GeometryProjection } from '../geometryProjection';\nimport { commitGestureOps, readGestureLifecycle, type GestureLifecycle } from '../gestureLifecycle';\nimport { transformFinisher, type TransformFinisher } from '../transformFinish';\nimport { nodeDescriptors, poseDescriptorOf } from '../poseDescriptorDep';\nimport { moveSources } from '../selectionSubtree';\nimport { layoutDrop } from './behaviors/layoutDrop';\nimport { reparentOnDrop } from './behaviors/reparentOnDrop';\nimport { buildGestureContext, captureFrames, capturePlaneRefs, captureStartPoses } from './capture';\nimport { moveGestureAdapter, type MoveGestureAdapter } from './gestureAdapter';\nimport type { SnapSession } from '../snapDep';\nimport { lazySnapSession } from 'features/snap/lazySession';\n\n/** Allowed values for the `reparentOnDrop` binding param. `'off'` (the\n * default) preserves the legacy translate-only commit. `'top'` lands the\n * moved node at the top of the container under the cursor. `'above'`\n * lands it immediately above the hit sibling in z-order (falls back to\n * `'top'` semantics when the hit is itself a container or when the hit\n * and moved node share no parent). */\nexport type ReparentOnDrop = 'off' | 'top' | 'above';\n\n/** What a move captured at press. Nothing here changes during the drag. */\nexport interface MoveSession {\n readonly scene: Scene<unknown, string, unknown>;\n /** The drag roots. */\n readonly ids: readonly NodeId[];\n /** Descendants of the roots, previewed along with them. */\n readonly cascadeIds: readonly NodeId[];\n /** Start pose of every root and descendant. */\n readonly startPoses: ReadonlyMap<NodeId, unknown>;\n /** Ids whose frame is itself moving, so they ride it and are not translated. */\n readonly carried: ReadonlySet<NodeId>;\n /** For each moved id stored under a frame: its world pose and the frame's, at press. */\n readonly frames: ReadonlyMap<NodeId, { world: unknown; frameWorld: unknown }>;\n /** Ids grabbed mid-glide, with how far the pose shown stood from the document's. */\n readonly caught: ReadonlyMap<NodeId, { dx: number; dy: number }>;\n /** Per layer on another plane than the edited one: a point of its first root, in both. */\n readonly planeRefs: ReadonlyMap<string, { own: { x: number; y: number }; edited: { x: number; y: number } }>;\n readonly view: unknown;\n readonly projection: PoseDescriptor<unknown>;\n readonly descriptorOf: (id: NodeId | string) => PoseDescriptor<unknown>;\n readonly pc: PoseComposition<unknown>;\n /** The binding's behaviors, then the ones the action adds: a layout drop\n * when the `layout` dep is present, and reparent-on-drop. */\n readonly behaviors: readonly MoveBehavior<unknown>[];\n /** Reused across the drag; behaviors mutate its `scratch`. */\n readonly gestureCtx: GestureContext<unknown>;\n readonly adapter: MoveGestureAdapter<unknown>;\n readonly layout: LayoutDep | undefined;\n readonly applyOps?: (ops: Op[], label: string) => void;\n /** Finishes the committed batch with the other nodes that change with it. */\n readonly finish?: TransformFinisher;\n readonly geometryProjection?: GeometryProjection;\n readonly lifecycle: GestureLifecycle;\n readonly nodeAtPoint: NodeAtPointDep | undefined;\n /** Whether a container admits the dragged roots; every one does when absent. */\n readonly admits: (parent: NodeId) => boolean;\n /** Read at release: a binding's params may be a thunk. */\n readonly reparentOnDrop: () => ReparentOnDrop;\n readonly dragThresholdPx: number;\n /** The drag's snapping, begun once the drag passes its threshold; null\n * with no `snap` dep. */\n readonly snap: SnapSession | null;\n /** The press, in the coordinates the drag's delta is measured in. */\n readonly press: { x: number; y: number };\n}\n\n/** What one `onMove` produced. Replaced, not mutated, by the next. */\nexport interface MoveFrame {\n readonly delta: { dx: number; dy: number };\n /** Stored-frame pose of every displaced id, roots and descendants, and of\n * any other id a behavior posed. */\n readonly previews: Map<NodeId, unknown>;\n /** Ids the behaviors asked to have painted at full opacity. */\n readonly opaque: ReadonlySet<NodeId>;\n}\n\n/** What the behaviors the action builds itself read of the drag they belong\n * to. Neither is readable from `onStart`, which runs before the session\n * exists. */\nexport interface MoveGesture {\n session(): MoveSession;\n /** The latest frame: the previous one while an `onMove` is running. */\n frame(): MoveFrame;\n}\n\nfunction admitsOf(\n canDropInto: CanDropIntoDep | undefined,\n ids: readonly NodeId[],\n): (parent: NodeId) => boolean {\n if (canDropInto === undefined) return () => true;\n const roots = ids as readonly string[];\n return (parent) => canDropInto(parent as string, roots);\n}\n\n/** Capture a drag at press. Null when there is nothing to move. Runs each\n * behavior's `onStart`. `frame` reads the drag's latest frame, for the\n * behaviors appended to the binding's own. */\nexport function beginMove(\n ctx: InvocationCtx,\n opts: BindingOpts | undefined,\n frame: () => MoveFrame,\n): { session: MoveSession; readers: GestureReaders } | null {\n const selection = ctx.deps.selection;\n const scene = ctx.deps.scene;\n const projection = poseDescriptorOf(ctx.deps.poseDescriptor);\n const layout = ctx.deps.layout;\n const applyOps = ctx.deps.applyOps;\n const geometryProjection = ctx.deps.geometryProjection;\n const finish = transformFinisher(ctx.deps);\n\n if (!selection || !scene) return null;\n const pc = scene.composition;\n // Anchors, segments, and balance grips sit on the selected body, and this binding ties the\n // path-edit drags' on specificity; with no mode registry to filter move out, declining is what\n // lets them through.\n if (isPathEditPart(ctx.drag?.affordance)) return null;\n\n const params = resolveParams(opts?.params);\n const expandIds = params?.['expandIds'] as ((ids: string[]) => string[]) | undefined;\n const selected = [...selection.get()] as string[];\n const ids = moveSources(scene, expandIds ? expandIds(selected) : selected) as NodeId[];\n if (ids.length === 0) return null;\n\n const reflow = layout?.reflow ?? null;\n const { startPoses, cascadeIds, caught } = captureStartPoses(scene, ids, reflow, projection);\n const { carried, frames } = captureFrames(scene, ids, startPoses);\n\n // Everything a move does beyond translating is a behavior: the binding's\n // own, then the layout drop, then reparent-on-drop. On release the first to\n // answer owns the commit, so each preempts the ones after it.\n const gesture: MoveGesture = { session: () => session, frame };\n const behaviors: MoveBehavior<unknown>[] = [\n ...((opts?.behaviors ?? []) as MoveBehavior<unknown>[]),\n ...(layout ? [layoutDrop(gesture)] : []),\n reparentOnDrop(gesture),\n ];\n const dragThresholdPx = (params?.['dragThresholdPx'] as number | undefined)\n ?? ctx.deps.kitSettings?.get('gestures.dragPx') ?? DRAG_THRESHOLD_PX;\n const lifecycle = readGestureLifecycle(params, 'Move', behaviors);\n // A behavior that commits after the gesture has ended, a coast coming to\n // rest, lands its batch the way the gesture's own commit does.\n const adapter = moveGestureAdapter<unknown>(scene, (ops, _label, through) =>\n commitGestureOps({ scene, applyOps, adapter: through, finish }, lifecycle, ops), selection.adapterMethods);\n const readers = gestureReaders(ctx.deps);\n const gestureCtx = buildGestureContext(ctx, scene, ids, startPoses, adapter, readers);\n for (const b of behaviors) b.onStart?.(gestureCtx);\n\n const press = ctx.drag?.start ?? ctx.world;\n const session: MoveSession = {\n startPoses,\n ids,\n cascadeIds,\n carried,\n frames,\n scene,\n view: ctx.deps.view,\n planeRefs: capturePlaneRefs(scene, ids, ctx.deps.view, frames, startPoses, projection),\n caught,\n projection,\n descriptorOf: nodeDescriptors(scene, projection),\n behaviors,\n gestureCtx,\n adapter,\n layout,\n pc,\n applyOps,\n finish,\n geometryProjection,\n lifecycle,\n nodeAtPoint: ctx.deps.nodeAtPoint,\n admits: admitsOf(ctx.deps.canDropInto, ids),\n reparentOnDrop: () => (resolveParams(opts?.params)?.['reparentOnDrop'] as ReparentOnDrop | undefined) ?? 'off',\n dragThresholdPx,\n snap: lazySnapSession(ctx.deps.snap, { gesture: 'move', ids, press, constrain: 'axis' }),\n press,\n };\n return { session, readers };\n}\n"],"mappings":";;;;;;;;;;;;;AA8FA,SAAS,SACP,aACA,KAC6B;CAC7B,IAAI,gBAAgB,QAAW,aAAa;CAC5C,MAAM,QAAQ;CACd,QAAQ,WAAW,YAAY,QAAkB,KAAK;AACxD;;;;AAKA,SAAgB,UACd,KACA,MACA,OAC0D;CAC1D,MAAM,YAAY,IAAI,KAAK;CAC3B,MAAM,QAAQ,IAAI,KAAK;CACvB,MAAM,aAAa,iBAAiB,IAAI,KAAK,cAAc;CAC3D,MAAM,SAAS,IAAI,KAAK;CACxB,MAAM,WAAW,IAAI,KAAK;CAC1B,MAAM,qBAAqB,IAAI,KAAK;CACpC,MAAM,SAAS,kBAAkB,IAAI,IAAI;CAEzC,IAAI,CAAC,aAAa,CAAC,OAAO,OAAO;CACjC,MAAM,KAAK,MAAM;CAIjB,IAAI,eAAe,IAAI,MAAM,UAAU,GAAG,OAAO;CAEjD,MAAM,SAAS,cAAc,MAAM,MAAM;CACzC,MAAM,YAAY,SAAS;CAC3B,MAAM,WAAW,CAAC,GAAG,UAAU,IAAI,CAAC;CACpC,MAAM,MAAM,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B,IAAI,KAAK,MAAM;GAAE,SAAS;GAAQ;GAAK;GAAO,WAAW;EAAO,CAAC;EACvF;CACF;CACA,OAAO;EAAE;EAAS;CAAQ;AAC5B"}
|
|
1
|
+
{"version":3,"file":"session.js","names":[],"sources":["../../../../src/interactions/actions/move/session.ts"],"sourcesContent":["import type { BindingOpts, InvocationCtx } from '@weasel-js/routing';\nimport { DRAG_THRESHOLD_PX, isPathEditPart, resolveParams } from '@weasel-js/routing';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { PoseDescriptor } from 'core/geometry/poseDescriptor';\nimport type { PoseComposition } from 'core/scene/composePose';\nimport { gestureReaders, type GestureReaders } from '../../gestures/shared/screenTolerance';\nimport type { GestureContext, MoveBehavior } from '../../gestures/types';\nimport type { CanDropIntoDep, LayoutDep, NodeAtPointDep } from '../depSchema';\nimport { admitsChild } from '../admitsChild';\nimport type { GeometryProjection } from '../geometryProjection';\nimport { commitGestureOps, readGestureLifecycle, type GestureLifecycle } from '../gestureLifecycle';\nimport { transformFinisher, type TransformFinisher } from '../transformFinish';\nimport { nodeDescriptors, poseDescriptorOf } from '../poseDescriptorDep';\nimport { moveSources } from '../selectionSubtree';\nimport { layoutDrop } from './behaviors/layoutDrop';\nimport { reparentOnDrop } from './behaviors/reparentOnDrop';\nimport { buildGestureContext, captureFrames, capturePlaneRefs, captureStartPoses } from './capture';\nimport { moveGestureAdapter, type MoveGestureAdapter } from './gestureAdapter';\nimport type { SnapSession } from '../snapDep';\nimport { lazySnapSession } from 'features/snap/lazySession';\n\n/** Allowed values for the `reparentOnDrop` binding param. `'off'` (the\n * default) preserves the legacy translate-only commit. `'top'` lands the\n * moved node at the top of the container under the cursor. `'above'`\n * lands it immediately above the hit sibling in z-order (falls back to\n * `'top'` semantics when the hit is itself a container or when the hit\n * and moved node share no parent). */\nexport type ReparentOnDrop = 'off' | 'top' | 'above';\n\n/** What a move captured at press. Nothing here changes during the drag. */\nexport interface MoveSession {\n readonly scene: Scene<unknown, string, unknown>;\n /** The drag roots. */\n readonly ids: readonly NodeId[];\n /** Descendants of the roots, previewed along with them. */\n readonly cascadeIds: readonly NodeId[];\n /** Start pose of every root and descendant. */\n readonly startPoses: ReadonlyMap<NodeId, unknown>;\n /** Ids whose frame is itself moving, so they ride it and are not translated. */\n readonly carried: ReadonlySet<NodeId>;\n /** For each moved id stored under a frame: its world pose and the frame's, at press. */\n readonly frames: ReadonlyMap<NodeId, { world: unknown; frameWorld: unknown }>;\n /** Ids grabbed mid-glide, with how far the pose shown stood from the document's. */\n readonly caught: ReadonlyMap<NodeId, { dx: number; dy: number }>;\n /** Per layer on another plane than the edited one: a point of its first root, in both. */\n readonly planeRefs: ReadonlyMap<string, { own: { x: number; y: number }; edited: { x: number; y: number } }>;\n readonly view: unknown;\n readonly projection: PoseDescriptor<unknown>;\n readonly descriptorOf: (id: NodeId | string) => PoseDescriptor<unknown>;\n readonly pc: PoseComposition<unknown>;\n /** The binding's behaviors, then the ones the action adds: a layout drop\n * when the `layout` dep is present, and reparent-on-drop. */\n readonly behaviors: readonly MoveBehavior<unknown>[];\n /** Reused across the drag; behaviors mutate its `scratch`. */\n readonly gestureCtx: GestureContext<unknown>;\n readonly adapter: MoveGestureAdapter<unknown>;\n readonly layout: LayoutDep | undefined;\n readonly applyOps?: (ops: Op[], label: string) => void;\n /** Finishes the committed batch with the other nodes that change with it. */\n readonly finish?: TransformFinisher;\n readonly geometryProjection?: GeometryProjection;\n readonly lifecycle: GestureLifecycle;\n readonly nodeAtPoint: NodeAtPointDep | undefined;\n /** Whether a node admits the dragged roots; with no `canDropInto`, a group does and a mark does not. */\n readonly admits: (parent: NodeId) => boolean;\n /** Read at release: a binding's params may be a thunk. */\n readonly reparentOnDrop: () => ReparentOnDrop;\n readonly dragThresholdPx: number;\n /** The drag's snapping, begun once the drag passes its threshold; null\n * with no `snap` dep. */\n readonly snap: SnapSession | null;\n /** The press, in the coordinates the drag's delta is measured in. */\n readonly press: { x: number; y: number };\n}\n\n/** What one `onMove` produced. Replaced, not mutated, by the next. */\nexport interface MoveFrame {\n readonly delta: { dx: number; dy: number };\n /** Stored-frame pose of every displaced id, roots and descendants, and of\n * any other id a behavior posed. */\n readonly previews: Map<NodeId, unknown>;\n /** Ids the behaviors asked to have painted at full opacity. */\n readonly opaque: ReadonlySet<NodeId>;\n}\n\n/** What the behaviors the action builds itself read of the drag they belong\n * to. Neither is readable from `onStart`, which runs before the session\n * exists. */\nexport interface MoveGesture {\n session(): MoveSession;\n /** The latest frame: the previous one while an `onMove` is running. */\n frame(): MoveFrame;\n}\n\nfunction admitsOf(\n canDropInto: CanDropIntoDep | undefined,\n ids: readonly NodeId[],\n scene: { get(id: NodeId): { kind: string } | undefined },\n): (parent: NodeId) => boolean {\n const roots = ids as readonly string[];\n return (parent) => admitsChild(scene, parent, roots, canDropInto);\n}\n\n/** Capture a drag at press. Null when there is nothing to move. Runs each\n * behavior's `onStart`. `frame` reads the drag's latest frame, for the\n * behaviors appended to the binding's own. */\nexport function beginMove(\n ctx: InvocationCtx,\n opts: BindingOpts | undefined,\n frame: () => MoveFrame,\n): { session: MoveSession; readers: GestureReaders } | null {\n const selection = ctx.deps.selection;\n const scene = ctx.deps.scene;\n const projection = poseDescriptorOf(ctx.deps.poseDescriptor);\n const layout = ctx.deps.layout;\n const applyOps = ctx.deps.applyOps;\n const geometryProjection = ctx.deps.geometryProjection;\n const finish = transformFinisher(ctx.deps);\n\n if (!selection || !scene) return null;\n const pc = scene.composition;\n // Anchors, segments, and balance grips sit on the selected body, and this binding ties the\n // path-edit drags' on specificity; with no mode registry to filter move out, declining is what\n // lets them through.\n if (isPathEditPart(ctx.drag?.affordance)) return null;\n\n const params = resolveParams(opts?.params);\n const expandIds = params?.['expandIds'] as ((ids: string[]) => string[]) | undefined;\n const selected = [...selection.get()] as string[];\n const ids = moveSources(scene, expandIds ? expandIds(selected) : selected) as NodeId[];\n if (ids.length === 0) return null;\n\n const reflow = layout?.reflow ?? null;\n const { startPoses, cascadeIds, caught } = captureStartPoses(scene, ids, reflow, projection);\n const { carried, frames } = captureFrames(scene, ids, startPoses);\n\n // Everything a move does beyond translating is a behavior: the binding's\n // own, then the layout drop, then reparent-on-drop. On release the first to\n // answer owns the commit, so each preempts the ones after it.\n const gesture: MoveGesture = { session: () => session, frame };\n const behaviors: MoveBehavior<unknown>[] = [\n ...((opts?.behaviors ?? []) as MoveBehavior<unknown>[]),\n ...(layout ? [layoutDrop(gesture)] : []),\n reparentOnDrop(gesture),\n ];\n const dragThresholdPx = (params?.['dragThresholdPx'] as number | undefined)\n ?? ctx.deps.kitSettings?.get('gestures.dragPx') ?? DRAG_THRESHOLD_PX;\n const lifecycle = readGestureLifecycle(params, 'Move', behaviors);\n // A behavior that commits after the gesture has ended, a coast coming to\n // rest, lands its batch the way the gesture's own commit does.\n const adapter = moveGestureAdapter<unknown>(scene, (ops, _label, through) =>\n commitGestureOps({ scene, applyOps, adapter: through, finish }, lifecycle, ops), selection.adapterMethods);\n const readers = gestureReaders(ctx.deps);\n const gestureCtx = buildGestureContext(ctx, scene, ids, startPoses, adapter, readers);\n for (const b of behaviors) b.onStart?.(gestureCtx);\n\n const press = ctx.drag?.start ?? ctx.world;\n const session: MoveSession = {\n startPoses,\n ids,\n cascadeIds,\n carried,\n frames,\n scene,\n view: ctx.deps.view,\n planeRefs: capturePlaneRefs(scene, ids, ctx.deps.view, frames, startPoses, projection),\n caught,\n projection,\n descriptorOf: nodeDescriptors(scene, projection),\n behaviors,\n gestureCtx,\n adapter,\n layout,\n pc,\n applyOps,\n finish,\n geometryProjection,\n lifecycle,\n nodeAtPoint: ctx.deps.nodeAtPoint,\n admits: admitsOf(ctx.deps.canDropInto, ids, scene),\n reparentOnDrop: () => (resolveParams(opts?.params)?.['reparentOnDrop'] as ReparentOnDrop | undefined) ?? 'off',\n dragThresholdPx,\n snap: lazySnapSession(ctx.deps.snap, { gesture: 'move', ids, press, constrain: 'axis' }),\n press,\n };\n return { session, readers };\n}\n"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QAAQ,YAC/D,iBAAiB;EAAE;EAAO;EAAU,SAAS;EAAS;CAAO,GAAG,WAAW,GAAG,GAAG,UAAU,cAAc;CAC3G,MAAM,UAAU,eAAe,IAAI,IAAI;CACvC,MAAM,aAAa,oBAAoB,KAAK,OAAO,KAAK,YAAY,SAAS,OAAO;CACpF,KAAK,MAAM,KAAK,WAAW,EAAE,UAAU,UAAU;CAEjD,MAAM,QAAQ,IAAI,MAAM,SAAS,IAAI;CACrC,MAAM,UAAuB;EAC3B;EACA;EACA;EACA;EACA;EACA;EACA,MAAM,IAAI,KAAK;EACf,WAAW,iBAAiB,OAAO,KAAK,IAAI,KAAK,MAAM,QAAQ,YAAY,UAAU;EACrF;EACA;EACA,cAAc,gBAAgB,OAAO,UAAU;EAC/C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,IAAI,KAAK;EACtB,QAAQ,SAAS,IAAI,KAAK,aAAa,KAAK,KAAK;EACjD,sBAAuB,cAAc,MAAM,MAAM,CAAC,GAAG,qBAAoD;EACzG;EACA,MAAM,gBAAgB,IAAI,KAAK,MAAM;GAAE,SAAS;GAAQ;GAAK;GAAO,WAAW;EAAO,CAAC;EACvF;CACF;CACA,OAAO;EAAE;EAAS;CAAQ;AAC5B"}
|
|
@@ -36,11 +36,14 @@ var createOutlinesAction = {
|
|
|
36
36
|
label: "Create Outlines",
|
|
37
37
|
icon: /* @icon */ "core:createOutlines",
|
|
38
38
|
group: "text",
|
|
39
|
-
defaultBinding: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
defaultBinding: [{
|
|
40
|
+
spec: {
|
|
41
|
+
kind: "key",
|
|
42
|
+
key: "Enter",
|
|
43
|
+
mods: { mod: true }
|
|
44
|
+
},
|
|
45
|
+
opts: { id: "createOutlines.key" }
|
|
46
|
+
}],
|
|
44
47
|
eligible: { capability: "creates-shapes" },
|
|
45
48
|
requires: ["selection", "createOutlinesAdapter"],
|
|
46
49
|
invoker: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOutlinesAction.js","names":[],"sources":["../../../../src/interactions/actions/outlines/createOutlinesAction.tsx"],"sourcesContent":["import type { Action, ImmediateInvoker } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport type { NodeId } from 'core/scene/types';\nimport { loadTextOutlines, type TextNodeSource, type TextOutlinesError } from '@weasel-js/text';\nimport {\n applyCreateOutlines, type CreateOutlinesAdapter, type CreateOutlinesResult,\n} from './createOutlines';\nimport { icon } from '../../../icons.gen';\n\n/** What an outline conversion answers when a text face had no outlines. */\ntype OutlinesFailure = { kind: 'failed'; error: TextOutlinesError };\n\n/**\n * Run `apply`, an outline conversion of `adapter`'s selection, waiting first\n * for any face whose outlines are registered but not yet loaded — a face is\n * parsed on first use, so the first conversion in a session would otherwise\n * fail. Warns under `tag` with the reason when the selection still cannot be\n * converted.\n */\nexport async function withTextOutlines<R extends { kind: string } | OutlinesFailure>(\n adapter: CreateOutlinesAdapter,\n apply: () => R,\n tag: string,\n): Promise<R> {\n const failure = (r: R): TextOutlinesError | null => (r.kind === 'failed' ? (r as OutlinesFailure).error : null);\n let result = apply();\n if (failure(result)?.reason === 'outlines-loading') {\n const texts = [...adapter.getSelection()]\n .map((id) => adapter.getTextSource(id as NodeId))\n .filter((t): t is TextNodeSource => t !== undefined);\n await Promise.all(texts.map((t) => loadTextOutlines(t.data)));\n result = apply();\n }\n const error = failure(result);\n if (error) console.warn(`[${tag}] ${error.message}`);\n return result;\n}\n\n/** {@link applyCreateOutlines} through {@link withTextOutlines}. */\nexport function runCreateOutlines(adapter: CreateOutlinesAdapter): Promise<CreateOutlinesResult> {\n return withTextOutlines(adapter, () => applyCreateOutlines(adapter), 'createOutlines');\n}\n\n/**\n * Static descriptor for Create Outlines: replace the selected\n * text nodes with path nodes carrying their glyph outlines. Reads the\n * `createOutlinesAdapter` dep, published with `useCreateOutlinesAdapter`.\n */\nexport const createOutlinesAction: Action = {\n id: 'createOutlines',\n label: 'Create Outlines',\n icon: icon('createOutlines'),\n group: 'text',\n // Affinity's Convert to Curves; Illustrator's Mod+Shift+O is Chrome's bookmark manager.\n defaultBinding: { kind: 'key', key: 'Enter', mods: { mod: true } },\n eligible: { capability: 'creates-shapes' },\n requires: ['selection', 'createOutlinesAdapter'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const adapter = deps.createOutlinesAdapter;\n if (adapter) void runCreateOutlines(adapter);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => {\n const ids = deps?.selection?.get() ?? [];\n if (ids.length === 0) return ActionDisabledReason.SelectionRequired;\n const adapter = deps?.createOutlinesAdapter;\n return adapter && ids.some((id) => adapter.getTextSource(id) !== undefined)\n ? true\n : ActionDisabledReason.NotApplicable;\n },\n};\n"],"mappings":";;;;;;;;;;;;AAmBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CACY;AACZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoC,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA;AAC1G,CAA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AA,CAAA,CAAA,CAAA,CAAA;AAC3B,CAAA;AACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"createOutlinesAction.js","names":[],"sources":["../../../../src/interactions/actions/outlines/createOutlinesAction.tsx"],"sourcesContent":["import type { Action, ImmediateInvoker } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport type { NodeId } from 'core/scene/types';\nimport { loadTextOutlines, type TextNodeSource, type TextOutlinesError } from '@weasel-js/text';\nimport {\n applyCreateOutlines, type CreateOutlinesAdapter, type CreateOutlinesResult,\n} from './createOutlines';\nimport { icon } from '../../../icons.gen';\n\n/** What an outline conversion answers when a text face had no outlines. */\ntype OutlinesFailure = { kind: 'failed'; error: TextOutlinesError };\n\n/**\n * Run `apply`, an outline conversion of `adapter`'s selection, waiting first\n * for any face whose outlines are registered but not yet loaded — a face is\n * parsed on first use, so the first conversion in a session would otherwise\n * fail. Warns under `tag` with the reason when the selection still cannot be\n * converted.\n */\nexport async function withTextOutlines<R extends { kind: string } | OutlinesFailure>(\n adapter: CreateOutlinesAdapter,\n apply: () => R,\n tag: string,\n): Promise<R> {\n const failure = (r: R): TextOutlinesError | null => (r.kind === 'failed' ? (r as OutlinesFailure).error : null);\n let result = apply();\n if (failure(result)?.reason === 'outlines-loading') {\n const texts = [...adapter.getSelection()]\n .map((id) => adapter.getTextSource(id as NodeId))\n .filter((t): t is TextNodeSource => t !== undefined);\n await Promise.all(texts.map((t) => loadTextOutlines(t.data)));\n result = apply();\n }\n const error = failure(result);\n if (error) console.warn(`[${tag}] ${error.message}`);\n return result;\n}\n\n/** {@link applyCreateOutlines} through {@link withTextOutlines}. */\nexport function runCreateOutlines(adapter: CreateOutlinesAdapter): Promise<CreateOutlinesResult> {\n return withTextOutlines(adapter, () => applyCreateOutlines(adapter), 'createOutlines');\n}\n\n/**\n * Static descriptor for Create Outlines: replace the selected\n * text nodes with path nodes carrying their glyph outlines. Reads the\n * `createOutlinesAdapter` dep, published with `useCreateOutlinesAdapter`.\n */\nexport const createOutlinesAction: Action = {\n id: 'createOutlines',\n label: 'Create Outlines',\n icon: icon('createOutlines'),\n group: 'text',\n // Affinity's Convert to Curves; Illustrator's Mod+Shift+O is Chrome's bookmark manager.\n defaultBinding: [{ spec: { kind: 'key', key: 'Enter', mods: { mod: true } }, opts: { id: 'createOutlines.key' } }],\n eligible: { capability: 'creates-shapes' },\n requires: ['selection', 'createOutlinesAdapter'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const adapter = deps.createOutlinesAdapter;\n if (adapter) void runCreateOutlines(adapter);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => {\n const ids = deps?.selection?.get() ?? [];\n if (ids.length === 0) return ActionDisabledReason.SelectionRequired;\n const adapter = deps?.createOutlinesAdapter;\n return adapter && ids.some((id) => adapter.getTextSource(id) !== undefined)\n ? true\n : ActionDisabledReason.NotApplicable;\n },\n};\n"],"mappings":";;;;;;;;;;;;AAmBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CACY;AACZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoC,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CACtE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAC3B,CAAA;AACF,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { strokeRegion } from "./strokeRegion.js";
|
|
2
2
|
import { replaceWithPaths } from "./replaceWithPaths.js";
|
|
3
|
+
import { resolveFill, resolveStroke } from "@weasel-js/paint";
|
|
3
4
|
import { TextOutlinesError, textToPathsByPaint } from "@weasel-js/text";
|
|
4
5
|
|
|
5
6
|
//#region src/interactions/actions/outlines/outlineStroke.ts
|
|
@@ -44,7 +45,8 @@ function applyOutlineStroke(adapter, opts = {}) {
|
|
|
44
45
|
const paths = [];
|
|
45
46
|
let outlined = false;
|
|
46
47
|
for (const { path, fill, stroke } of paintedPaths(adapter, id)) {
|
|
47
|
-
const
|
|
48
|
+
const painted = resolveStroke(stroke);
|
|
49
|
+
const outline = painted === null ? null : strokeRegion(path, painted, frame, opts);
|
|
48
50
|
if (!outline || outline.commands.length === 0) {
|
|
49
51
|
paths.push(stroke ? {
|
|
50
52
|
path,
|
|
@@ -57,13 +59,13 @@ function applyOutlineStroke(adapter, opts = {}) {
|
|
|
57
59
|
continue;
|
|
58
60
|
}
|
|
59
61
|
outlined = true;
|
|
60
|
-
if (fill !== null) paths.push({
|
|
62
|
+
if (resolveFill(fill) !== null) paths.push({
|
|
61
63
|
path,
|
|
62
64
|
fill
|
|
63
65
|
});
|
|
64
66
|
paths.push({
|
|
65
67
|
path: outline,
|
|
66
|
-
fill: { paint:
|
|
68
|
+
fill: { paint: painted.paint }
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
if (outlined) converted.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlineStroke.js","names":[],"sources":["../../../../src/interactions/actions/outlines/outlineStroke.ts"],"sourcesContent":["/**\n * Outline Stroke: replace each selected stroked path, or stroked text, with\n * the region its stroke covers, as a path filled in the stroke's paint. A node\n * that is also filled keeps its fill as a path of its own underneath. One\n * undoable batch; the replacement takes the node's slot.\n */\nimport { textToPathsByPaint, TextOutlinesError, type TextNodeSource } from '@weasel-js/text';\nimport type { NodeId } from 'core/scene/types';\nimport type { CreateOutlinesAdapter } from './createOutlines';\nimport { replaceWithPaths, type PaintedPath } from './replaceWithPaths';\nimport { strokeRegion, type StrokeRegionOptions } from './strokeRegion';\n\n/** Outcome of {@link applyOutlineStroke}. */\nexport type OutlineStrokeResult =\n /** `resultIds` are what replaced the stroked nodes at their level — a\n * path, a container, or a run of flat paths each — and are now selected in\n * their place. */\n | { kind: 'applied'; resultIds: string[] }\n /** Nothing selected is a path or text with a stroke that has width. */\n | { kind: 'noop'; reason: 'no-stroke' }\n /** Some selected stroked text has no outline geometry; nothing was changed. */\n | { kind: 'failed'; reason: 'text-outlines'; error: TextOutlinesError };\n\n/** Whether a text node wears a stroke anywhere: its own, or a run's. */\nexport function textIsStroked(text: TextNodeSource | undefined): boolean {\n return text != null && (text.data.stroke != null || !!text.data.runs?.some((r) => r.stroke != null));\n}\n\n/** What the adapter knows of `id` as painted world paths: a path node's one,\n * or a text node's glyphs by paint. Throws as `textToPathsByPaint` does. */\nfunction paintedPaths(adapter: CreateOutlinesAdapter, id: NodeId): PaintedPath[] {\n const path = adapter.getWorldPath?.(id);\n if (path) {\n const paint = adapter.getPaint?.(id);\n return paint ? [{ path, ...paint }] : [];\n }\n const text = adapter.getTextSource(id);\n // Text with no stroke stays text: its outlines are not read, so a face\n // without them fails only the text this would convert.\n if (!text || !textIsStroked(text)) return [];\n return textToPathsByPaint(text.data, text.pose);\n}\n\n/**\n * Outline the stroke of every stroked path and stroked text in the selection,\n * as one batch labeled \"Outline Stroke\". Other selected nodes are left alone\n * and stay selected. Each stroke is outlined in the frame it is drawn in: see\n * {@link strokeRegion}. All or nothing: if a stroked text's face cannot\n * supply outlines the scene is untouched and the error comes back.\n */\nexport function applyOutlineStroke(\n adapter: CreateOutlinesAdapter,\n opts: StrokeRegionOptions = {},\n): OutlineStrokeResult {\n const sel = [...adapter.getSelection()] as NodeId[];\n const converted: { id: NodeId; paths: PaintedPath[] }[] = [];\n try {\n for (const id of sel) {\n const frame = adapter.getStrokeFrame?.(id);\n const paths: PaintedPath[] = [];\n let outlined = false;\n for (const { path, fill, stroke } of paintedPaths(adapter, id)) {\n const
|
|
1
|
+
{"version":3,"file":"outlineStroke.js","names":[],"sources":["../../../../src/interactions/actions/outlines/outlineStroke.ts"],"sourcesContent":["/**\n * Outline Stroke: replace each selected stroked path, or stroked text, with\n * the region its stroke covers, as a path filled in the stroke's paint. A node\n * that is also filled keeps its fill as a path of its own underneath. One\n * undoable batch; the replacement takes the node's slot.\n */\nimport { textToPathsByPaint, TextOutlinesError, type TextNodeSource } from '@weasel-js/text';\nimport { resolveFill, resolveStroke } from '@weasel-js/paint';\nimport type { NodeId } from 'core/scene/types';\nimport type { CreateOutlinesAdapter } from './createOutlines';\nimport { replaceWithPaths, type PaintedPath } from './replaceWithPaths';\nimport { strokeRegion, type StrokeRegionOptions } from './strokeRegion';\n\n/** Outcome of {@link applyOutlineStroke}. */\nexport type OutlineStrokeResult =\n /** `resultIds` are what replaced the stroked nodes at their level — a\n * path, a container, or a run of flat paths each — and are now selected in\n * their place. */\n | { kind: 'applied'; resultIds: string[] }\n /** Nothing selected is a path or text with a stroke that has width. */\n | { kind: 'noop'; reason: 'no-stroke' }\n /** Some selected stroked text has no outline geometry; nothing was changed. */\n | { kind: 'failed'; reason: 'text-outlines'; error: TextOutlinesError };\n\n/** Whether a text node wears a stroke anywhere: its own, or a run's. */\nexport function textIsStroked(text: TextNodeSource | undefined): boolean {\n return text != null && (text.data.stroke != null || !!text.data.runs?.some((r) => r.stroke != null));\n}\n\n/** What the adapter knows of `id` as painted world paths: a path node's one,\n * or a text node's glyphs by paint. Throws as `textToPathsByPaint` does. */\nfunction paintedPaths(adapter: CreateOutlinesAdapter, id: NodeId): PaintedPath[] {\n const path = adapter.getWorldPath?.(id);\n if (path) {\n const paint = adapter.getPaint?.(id);\n return paint ? [{ path, ...paint }] : [];\n }\n const text = adapter.getTextSource(id);\n // Text with no stroke stays text: its outlines are not read, so a face\n // without them fails only the text this would convert.\n if (!text || !textIsStroked(text)) return [];\n return textToPathsByPaint(text.data, text.pose);\n}\n\n/**\n * Outline the stroke of every stroked path and stroked text in the selection,\n * as one batch labeled \"Outline Stroke\". Other selected nodes are left alone\n * and stay selected. Each stroke is outlined in the frame it is drawn in: see\n * {@link strokeRegion}. All or nothing: if a stroked text's face cannot\n * supply outlines the scene is untouched and the error comes back.\n */\nexport function applyOutlineStroke(\n adapter: CreateOutlinesAdapter,\n opts: StrokeRegionOptions = {},\n): OutlineStrokeResult {\n const sel = [...adapter.getSelection()] as NodeId[];\n const converted: { id: NodeId; paths: PaintedPath[] }[] = [];\n try {\n for (const id of sel) {\n const frame = adapter.getStrokeFrame?.(id);\n const paths: PaintedPath[] = [];\n let outlined = false;\n for (const { path, fill, stroke } of paintedPaths(adapter, id)) {\n const painted = resolveStroke(stroke);\n const outline = painted === null ? null : strokeRegion(path, painted, frame, opts);\n if (!outline || outline.commands.length === 0) {\n paths.push(stroke ? { path, fill, stroke } : { path, fill });\n continue;\n }\n outlined = true;\n if (resolveFill(fill) !== null) paths.push({ path, fill });\n paths.push({ path: outline, fill: { paint: painted!.paint } });\n }\n if (outlined) converted.push({ id, paths });\n }\n } catch (err) {\n if (err instanceof TextOutlinesError) return { kind: 'failed', reason: 'text-outlines', error: err };\n throw err;\n }\n if (converted.length === 0) return { kind: 'noop', reason: 'no-stroke' };\n const replaced = replaceWithPaths(adapter, sel, converted, 'Outline Stroke');\n return { kind: 'applied', resultIds: converted.flatMap((c) => replaced.get(c.id)!) };\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,SAAgB,cAAc,MAA2C;CACvE,OAAO,QAAQ,SAAS,KAAK,KAAK,UAAU,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM,MAAM,MAAM,EAAE,UAAU,IAAI;AACpG;;;AAIA,SAAS,aAAa,SAAgC,IAA2B;CAC/E,MAAM,OAAO,QAAQ,eAAe,EAAE;CACtC,IAAI,MAAM;EACR,MAAM,QAAQ,QAAQ,WAAW,EAAE;EACnC,OAAO,QAAQ,CAAC;GAAE;GAAM,GAAG;EAAM,CAAC,IAAI,CAAC;CACzC;CACA,MAAM,OAAO,QAAQ,cAAc,EAAE;CAGrC,IAAI,CAAC,QAAQ,CAAC,cAAc,IAAI,GAAG,OAAO,CAAC;CAC3C,OAAO,mBAAmB,KAAK,MAAM,KAAK,IAAI;AAChD;;;;;;;;AASA,SAAgB,mBACd,SACA,OAA4B,CAAC,GACR;CACrB,MAAM,MAAM,CAAC,GAAG,QAAQ,aAAa,CAAC;CACtC,MAAM,YAAoD,CAAC;CAC3D,IAAI;EACF,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,QAAQ,QAAQ,iBAAiB,EAAE;GACzC,MAAM,QAAuB,CAAC;GAC9B,IAAI,WAAW;GACf,KAAK,MAAM,EAAE,MAAM,MAAM,YAAY,aAAa,SAAS,EAAE,GAAG;IAC9D,MAAM,UAAU,cAAc,MAAM;IACpC,MAAM,UAAU,YAAY,OAAO,OAAO,aAAa,MAAM,SAAS,OAAO,IAAI;IACjF,IAAI,CAAC,WAAW,QAAQ,SAAS,WAAW,GAAG;KAC7C,MAAM,KAAK,SAAS;MAAE;MAAM;MAAM;KAAO,IAAI;MAAE;MAAM;KAAK,CAAC;KAC3D;IACF;IACA,WAAW;IACX,IAAI,YAAY,IAAI,MAAM,MAAM,MAAM,KAAK;KAAE;KAAM;IAAK,CAAC;IACzD,MAAM,KAAK;KAAE,MAAM;KAAS,MAAM,EAAE,OAAO,QAAS,MAAM;IAAE,CAAC;GAC/D;GACA,IAAI,UAAU,UAAU,KAAK;IAAE;IAAI;GAAM,CAAC;EAC5C;CACF,SAAS,KAAK;EACZ,IAAI,eAAe,mBAAmB,OAAO;GAAE,MAAM;GAAU,QAAQ;GAAiB,OAAO;EAAI;EACnG,MAAM;CACR;CACA,IAAI,UAAU,WAAW,GAAG,OAAO;EAAE,MAAM;EAAQ,QAAQ;CAAY;CACvE,MAAM,WAAW,iBAAiB,SAAS,KAAK,WAAW,gBAAgB;CAC3E,OAAO;EAAE,MAAM;EAAW,WAAW,UAAU,SAAS,MAAM,SAAS,IAAI,EAAE,EAAE,CAAE;CAAE;AACrF"}
|
|
@@ -137,11 +137,14 @@ var joinPathsAction = joinPathsCommand({
|
|
|
137
137
|
id: "joinPaths",
|
|
138
138
|
label: "Join",
|
|
139
139
|
icon: /* @icon */ "core:join",
|
|
140
|
-
defaultBinding: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
defaultBinding: [{
|
|
141
|
+
spec: {
|
|
142
|
+
kind: "key",
|
|
143
|
+
key: "j",
|
|
144
|
+
mods: { mod: true }
|
|
145
|
+
},
|
|
146
|
+
opts: { id: "joinPaths.key" }
|
|
147
|
+
}]
|
|
145
148
|
}, () => ({}));
|
|
146
149
|
|
|
147
150
|
//#endregion
|