@weasel-js/core 1.4.4 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +1295 -2197
  2. package/README.md +118 -75
  3. package/dist/autoPoseDescriptor-Dr6CwNZK.d.ts +26 -0
  4. package/dist/{chunk-WPM42WJP.js → chunk-3LPQ2XZG.js} +196 -406
  5. package/dist/chunk-3LPQ2XZG.js.map +1 -0
  6. package/dist/{chunk-R3AWPTLZ.js → chunk-GREL4MVO.js} +7593 -8533
  7. package/dist/chunk-GREL4MVO.js.map +1 -0
  8. package/dist/chunk-HAGOFNP5.js +162 -0
  9. package/dist/chunk-HAGOFNP5.js.map +1 -0
  10. package/dist/chunk-LXJDWBEL.js +318 -0
  11. package/dist/chunk-LXJDWBEL.js.map +1 -0
  12. package/dist/{chunk-2VXGHUVL.js → chunk-P6MGECVO.js} +4 -22
  13. package/dist/chunk-P6MGECVO.js.map +1 -0
  14. package/dist/{chunk-PRGBGMH3.js → chunk-XXQ6FLCJ.js} +3 -3
  15. package/dist/chunk-XXQ6FLCJ.js.map +1 -0
  16. package/dist/clipboard.d.ts +2 -3
  17. package/dist/clone.d.ts +3 -2
  18. package/dist/depSchema-BubKMv-2.d.ts +3479 -0
  19. package/dist/{grid-0Pbn5B2C.d.ts → grid-Z_Af3vTl.d.ts} +7 -10
  20. package/dist/index.d.ts +2588 -1556
  21. package/dist/index.js +6 -5
  22. package/dist/insert.d.ts +4 -4
  23. package/dist/insert.js +2 -1
  24. package/dist/insert.js.map +1 -1
  25. package/dist/math-E3rZn4bR.d.ts +282 -0
  26. package/dist/math.d.ts +5 -0
  27. package/dist/math.js +4 -0
  28. package/dist/math.js.map +1 -0
  29. package/dist/move.d.ts +5 -6
  30. package/dist/move.js +4 -6
  31. package/dist/move.js.map +1 -1
  32. package/dist/{options-DbYLImvq.d.ts → options-BPcmwYk7.d.ts} +3 -2
  33. package/dist/{autoPoseDescriptor-DF1SnnSx.d.ts → pointSnapToGrid-CgcK2R_I.d.ts} +11 -32
  34. package/dist/poseDescriptor-PgfVKfa0.d.ts +134 -0
  35. package/dist/renderer.d.ts +9 -4
  36. package/dist/renderer.js +6 -5
  37. package/dist/resize.d.ts +11 -12
  38. package/dist/resize.js +3 -2
  39. package/dist/routing.d.ts +1 -142
  40. package/dist/routing.js +1 -1
  41. package/dist/routing.js.map +1 -1
  42. package/dist/{types-ei3UMl9R.d.ts → types-BHGdrOcu.d.ts} +12 -41
  43. package/dist/{types-DEALFt5F.d.ts → types-BdaK9PcP.d.ts} +10 -4
  44. package/package.json +17 -10
  45. package/dist/DrawCommand-CD-ug3d9.d.ts +0 -332
  46. package/dist/builtins-BXFBXegF.d.ts +0 -840
  47. package/dist/chunk-2VXGHUVL.js.map +0 -1
  48. package/dist/chunk-BL65SHCX.js +0 -573
  49. package/dist/chunk-BL65SHCX.js.map +0 -1
  50. package/dist/chunk-PRGBGMH3.js.map +0 -1
  51. package/dist/chunk-R3AWPTLZ.js.map +0 -1
  52. package/dist/chunk-WPM42WJP.js.map +0 -1
  53. package/dist/geometry-6fCNhAux.d.ts +0 -114
  54. package/dist/path-JEV2c5If.d.ts +0 -48
  55. package/dist/registry-BY-wI9gm.d.ts +0 -4003
  56. package/dist/types-BHK2dkMu.d.ts +0 -172
  57. package/dist/types-bcc7jcUy.d.ts +0 -594
  58. package/dist/view-DSQgxBJB.d.ts +0 -63
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, ArrowIcon, BUILTIN_MARKERS, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, CanvasView, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_DEBUG_STROKES, DEFAULT_DEBUG_THEME, DEFAULT_DEVICE_PROFILE, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_MAX_ZOOM, DEFAULT_MIN_ZOOM, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DEFAULT_VELOCITY_DECAY, DepRegistryProviderIfRoot, DeviceProfileProvider, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HANDLE_BASE_PX, HandIcon, IDENTITY_JOINT, IDENTITY_POSE_COMPOSITION, ImageIcon, IntersectIcon, KIT_SHAPE_KINDS, KIT_STANDARD_ACTION_IDS, LassoIcon, LineIcon, MARKDOWN_RUN_GRAMMAR, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PAINTED_CURSOR_LAYER_ID, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SCRIPT_METRICS, SPRING_PRESETS, SPRITE_STRIDE, STROKE_DASH_RATIOS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TOOL_PREF_KINDS, TextIcon, UNION_OF_CHILDREN, UnionIcon, UnknownIcon, VERSION, VIEW_ANIMATION_KEY, WHEEL_ZOOM_STEP, WeaselProvider, _resetMarkersForTests, _resetPaintKindsForTests, aabbCenter, actionIs, actionShortcuts, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, asPaint, axisAlignedBounds, bakeCursor, bezierCubic, bezierQuadratic, blendPoses, blur, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, cachedLayoutRuns, canBringForward, canHover, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, clampView, clearSelectionAction, clientToCanvas, clipboardCopyAction, clipboardCutAction, cloneAction, coarsePointer, composeAffordanceLayer, composePath, composeRectPose, composeSelectionPose, composeWorldPose, computeFitView, computeFitViewport, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createPaintedCursorLayer, createPaintedCursorState, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createPoseOverrides, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createSimulation, createTextLayer, createVelocityTracker, createViewResolver, createViewportLayer, cubicBezierEasing, cursorFor, cycleVertexColors, dashForStrokeStyle, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deriveAlignmentGuides, deriveParallaxView, derivedDepOf, derivedPose, describeRule, documentPose, domPositionToCharOffset, domToRuns, drawLayers, drawOneLayer, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, effectivePose, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, frameRect, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getMarker, getNodeShapes, getPaintKind, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hostAnchorCss, hostAnchorRect, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, interpolateView, isBuiltinToolPref, isCanvasFont2 as isCanvasFont, isEditableTarget, isGradientFill, isLayerPainted, isLayerVisible, isPatternSpec, keySpecShortcut, lassoSelectAction, layoutMarkdown, layoutRuns, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, listMarkers, listPaintKinds, liveScope, makePinchZoomAction, makeViewportWheelPanAction, makeViewportZoomAction, markdownToRuns, markerDrawCommands, markerInset, markerKeyOf, markerSites, mat3, matchAlignment, matchesKeyBinding, meanScale, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, mergeContributions, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, nodeHasFlag, none, normalizeHex, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, openPointerSession, or, outlineStatus2 as outlineStatus, paintAlpha, paintKindOf, paintWithAlpha, paintWithColor, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointAlongPath, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerEffect, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerMarker, registerNodeShape, registerPaintKind, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveAlign, resolveColor, resolveCursor, resolveCursorTier, resolveDeviceProfile, resolveEasing, resolveFillPattern, resolveMarkerSize, resolveParams, resolvePatternSpec, resolveRuns, resolveSkeleton, resolveStrokeWidth, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sampleTrack, sceneFromJSON, sceneNodeClientRect, sceneSelectionStore, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solid, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, strokeDashStyleOf, strokeInsets, strokeOf, strokeWith, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textCommandFromRuns, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, trimPolyline, tweenPose, tweenVertexColors, unionAABB, unionBounds, unionBoundsPath, unionOfChildren, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDeviceProfile, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHostAnchor, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useNodeOverlayFrame, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePointerStylus, usePolygonTool, usePoseRun, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useVisibleRaf, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportWheelPanAction, viewportZoomAction, viewportsAt, vignette, visualBoundsViaDescriptor, wheelPan, wheelZoom, wheelZoomFactor, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-R3AWPTLZ.js';
2
- export { ActionDisabledReason, ActionsProvider, ActionsScope, DepRegistryProvider, actionBindings, evaluateEnabled, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-BL65SHCX.js';
3
- export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-2VXGHUVL.js';
4
- export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-PRGBGMH3.js';
5
- export { AUTO_POSE_DESCRIPTOR, DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, isPathLike, linePath, pathCommandCoordCount, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, polylineFromPoints, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius } from './chunk-WPM42WJP.js';
1
+ export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionDisabledReason, ActionsProvider, ActionsProviderIfRoot, ActionsScope, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, ArrowIcon, BUILTIN_MARKERS, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, CanvasView, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALLOWED_CAPABILITIES, DEFAULT_DEBUG_STROKES, DEFAULT_DEBUG_THEME, DEFAULT_DEVICE_PROFILE, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_MAX_ZOOM, DEFAULT_MIN_ZOOM, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DepRegistryProvider, DepRegistryProviderIfRoot, DeviceProfileProvider, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HANDLE_BASE_PX, HandIcon, IDENTITY_JOINT, IDENTITY_POSE_COMPOSITION, ImageIcon, IntersectIcon, KIT_SHAPE_KINDS, KIT_STANDARD_ACTION_IDS, LassoIcon, LineIcon, MARKDOWN_RUN_GRAMMAR, MESH_BAKE_SIZE, MESH_GRADIENT_KIND, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PAINTED_CURSOR_LAYER_ID, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_POSE_COMPOSITION, RIGID_POSE_COMPOSITION, ROTATION_HANDLE_BASE_PX, RectIcon, SCRIPT_METRICS, SPRING_PRESETS, SPRITE_STRIDE, STROKE_DASH_RATIOS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TOOL_PREF_KINDS, TextIcon, UNION_OF_CHILDREN, UnionIcon, UnknownIcon, VERSION, VIEW_ANIMATION_KEY, WHEEL_ZOOM_STEP, WeaselProvider, ZOOM_FLOOR, _resetMarkersForTests, _resetPaintKindsForTests, actionBindings, actionIs, actionShortcuts, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, asPaint, bakeCursor, bakeMesh, bezierCubic, bezierQuadratic, bindRig, blendPoses, blur, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, cachedLayoutRuns, canBringForward, canHover, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, circlePath, clampView, clearSelectionAction, clientToCanvas, clipboardCopyAction, clipboardCutAction, cloneAction, coarsePointer, composeAffordanceLayer, composePath, composeRectPose, composeRigidPose, composeSelectionPose, composeWorldPose, computeFitView, computeFitViewport, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, cornerWeights, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createKeyState, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createPaintedCursorLayer, createPaintedCursorState, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createPoseFeed, createPoseOverrides, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createSlew, createTextLayer, createTiledLayer, createVelocityTracker, createViewResolver, createViewportLayer, cubicBezierEasing, cullDrawCommands, cursorFor, cycleVertexColors, dashForStrokeStyle, decomposePath, decomposeRectPose, decomposeRigidPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deleteScratch, deriveAlignmentGuides, deriveParallaxView, derivedDepOf, derivedPose, describeRule, documentPose, domPositionToCharOffset, domToRuns, drawLayers, drawOneLayer, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, effectivePose, effectiveRangeStyle, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evalPatch, evaluate, evaluateEnabled, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, flattenPreviews, focused, fontString, forEachCoalesced, frameRect, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getMarker, getNodeShapes, getPaintKind, getScratch, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hostAnchorCss, hostAnchorRect, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, insertPreviewExtent, interpolateView, isBuiltinToolPref, isCanvasFont2 as isCanvasFont, isEditableTarget, isGradientFill, isLayerPainted, isLayerVisible, isMeshGradientFill, isPatternSpec, isTensorPatch, isValidPatch, keySpecShortcut, lassoSelectAction, layoutMarkdown, layoutRuns, layoutTextPose, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, listMarkers, listPaintKinds, liveScope, makePinchZoomAction, makeViewportWheelPanAction, makeViewportZoomAction, markdownToRuns, markerDrawCommands, markerInset, markerKeyOf, markerSites, mat3, matchAlignment, matchesKeyBinding, meanScale, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, mergeContributions, meshBounds, meshGradientXml, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, nodeHasFlag, none, normalizeHex, normalizeView, normalizeZoom, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, openPointerSession, or, outlineStatus2 as outlineStatus, paintAlpha, paintKindOf, paintWithAlpha, paintWithColor, parseColor, parseColorToRgba255, parseDebugFlags, patchBounds, patchCorner, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInTextPose, poseRotationOf, prefUnit, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectMarkerPath, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerEffect, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerMarker, registerNodeShape, registerPaintKind, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveAlign, resolveColor, resolveCursor, resolveCursorTier, resolveDeviceProfile, resolveEasing, resolveFillPattern, resolveMarkerSize, resolveOverlays, resolveParams, resolvePatternSpec, resolvePreviews, resolveRuns, resolveScreenLength, resolveSkeleton, resolveStrokeWidth, resolveTextStyle, resolveVisibility, rgbaToHex, rigidRigApply, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotationDegreesUnit, rotationHandle, roundRectPath, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sampleTrack, sceneFromJSON, sceneNodeClientRect, sceneSelectionStore, sceneToAdapter, scopeBindings, scratchKey, screenToWorld, seedMeshPatch, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, setScratch, shapeCoversPoint, slewToward, sliceAction, snapPoint, solid, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, squarePath, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, strokeDashStyleOf, strokeInsets, strokeOf, strokeWith, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textCommandFromPose, textCommandFromRuns, textLineBoxes, textPoseLayoutInput, tileGrid, tiledProject, toHex8, toRuns, translateRectPose, trimPolyline, tweenPose, tweenVertexColors, unionBoundsPath, unionOfChildren, unionOfChildrenVia, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useAction, useActionsRegistry, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDepRegistry, useDepSource, useDeviceProfile, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHostAnchor, useHoverTracking, useImageTool, useKeyState, useKeybindings, useLassoTool, useLineTool, useNodeOverlayFrame, useOptionalActiveToolContext, useOptionalDepRegistry, usePenTool, usePencilTool, usePinchGesture, usePointerStylus, usePolygonTool, usePoseCompositionDepSource, usePoseDescriptorDepSource, usePoseRun, usePublishSelection, useRectTool, useResizePolicy, useRig, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewAnimationOn, useVisibleRaf, verticalAlignOffset, viewToMat3, viewToTransform, viewZoom, viewportDragPanAction, viewportWheelPanAction, viewportZoomAction, viewportsAt, vignette, wheelPan, wheelZoom, wheelZoomFactor, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-GREL4MVO.js';
2
+ export { DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_VELOCITY_DECAY, aabbCenter, createSimulation, pointAlongPath, pointInRotatedRect, rectCorners, rotatePoint, rotatedRectCorners } from './chunk-LXJDWBEL.js';
3
+ export { createReparentOp, createTransformOp, snap } from './chunk-P6MGECVO.js';
4
+ export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-XXQ6FLCJ.js';
5
+ export { ANGLE_RADIANS, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PIXELS, RECT_ORIGIN_PROJECTION, formatUnit, gridSnapStrategy, guideSnapStrategy, pointToGridCell, pxExtent, resolveUnit, scaleDelta, withinPxBox, withinPxRadius } from './chunk-HAGOFNP5.js';
6
+ export { AUTO_POSE_DESCRIPTOR, DEFAULT_FLATTEN_TOLERANCE, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PathBuilder, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, axisAlignedBounds, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, isPathLike, isRectPose, linePath, pathCommandCoordCount, pathPoseDescriptor, pointInPath, polygonFromPoints, polylineFromPoints, poseDescriptorForNode, rectPath, regularPolygonPath, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, translatePoseViaDescriptor, unionAABB, unionBounds, visualBoundsViaDescriptor } from './chunk-3LPQ2XZG.js';
6
7
  export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-T3UQ3F6R.js';
7
8
  export { cloneByAltDrag } from './chunk-D4AAWR64.js';
8
9
  export { createSetSelectionOp } from './chunk-DOBSZOPR.js';
package/dist/insert.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { U as UseInsertOptions } from './options-DbYLImvq.js';
2
- import { M as ModifierState, I as InsertBehavior } from './types-ei3UMl9R.js';
1
+ export { U as UseInsertOptions } from './options-BPcmwYk7.js';
2
+ import { I as InsertBehavior } from './types-BHGdrOcu.js';
3
+ import { ModifierState, View } from '@weasel-js/routing';
3
4
  import { G as Guide } from './types-D2tTKEU0.js';
4
- import { V as View } from './view-DSQgxBJB.js';
5
5
  import '@weasel-js/history';
6
- import './types-DEALFt5F.js';
6
+ import './types-BdaK9PcP.js';
7
7
 
8
8
  type ModKey$1 = keyof ModifierState;
9
9
  /** Insert behavior that rounds the insertion point to a grid, so a shape
package/dist/insert.js CHANGED
@@ -1,4 +1,5 @@
1
- import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-WPM42WJP.js';
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-HAGOFNP5.js';
2
+ import './chunk-3LPQ2XZG.js';
2
3
 
3
4
  // src/interactions/actions/insert/behaviors/snapToGrid.ts
4
5
  function snapToGrid(args) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interactions/actions/insert/behaviors/snapToGrid.ts","../src/interactions/actions/insert/behaviors/snapToGuides.ts"],"names":[],"mappings":";;;AAWO,SAAS,WAAkB,IAAA,EAGR;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAU,GAAI,IAAA;AAC/B,EAAA,MAAM,QAAQ,CAAC,CAAA,KAAc,KAAK,KAAA,CAAM,CAAA,GAAI,OAAO,CAAA,GAAI,OAAA;AACvD,EAAA,OAAO;AAAA,IACL,QAAQ,GAAA,EA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AA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC3B,MAAA,MAAM,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,EAAE,CAAA;AAC3B,MAAA,IAAI,CAAC,CAAA,EAAG;AACR,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,CAAA,EAAG,MAAA,EAAQ,iBAAiB,CAAA;AACtD,MAAA,IAAI,OAAA,EAAS,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,IAAI,OAA2B,CAAA;AAAA,IAC7D,CAAA;AAAA,IACA,MAAA,CAAO,GAAA,EAAK,EAAE,OAAA,EAAQ,EAAG;AACvB,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,iBAAiB,CAAA;AAC5D,MAAA,IAAI,CAAC,OAAA,EAAS;AACd,MAAA,OAAO,EAAE,SAAS,OAAA,EAAQ;AAAA,IAC5B;AAAA,GACF;AACF","file":"insert.js","sourcesContent":["import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\n/** Insert behavior that rounds the insertion point to a grid, so a shape\n * drawn freehand lands on grid intersections. Hold `bypassKey` to place\n * freely. */\nexport function snapToGrid<TPose>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): InsertBehavior<TPose> {\n const { spacing, bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n ctx.origin.set(id, { x: round(o.x), y: round(o.y) } as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n return { current: { x: round(current.x), y: round(current.y) } };\n },\n };\n}\n","import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { pxExtent } from 'core/viewport/pxExtent';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the insert-flavored `snapToGuides`. */\nexport interface SnapToGuidesInsertArgs {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n}\n\nfunction snapPoint(\n p: InsertPoint,\n guides: readonly Guide[],\n tol: { x: number; y: number },\n): InsertPoint | null {\n let bestDx = 0;\n let bestAbsDx = Infinity;\n let bestDy = 0;\n let bestAbsDy = Infinity;\n for (const g of guides) {\n if (g.axis === 'x') {\n const d = g.offset - p.x;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbsDx) {\n bestAbsDx = ad;\n bestDx = d;\n }\n } else {\n const d = g.offset - p.y;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbsDy) {\n bestAbsDy = ad;\n bestDy = d;\n }\n }\n }\n if (bestAbsDx === Infinity && bestAbsDy === Infinity) return null;\n const dx = bestAbsDx === Infinity ? 0 : bestDx;\n const dy = bestAbsDy === Infinity ? 0 : bestDy;\n if (dx === 0 && dy === 0) return null;\n return { x: p.x + dx, y: p.y + dy };\n}\n\n/**\n * Insert behavior that snaps the start anchor (on gesture start) and the\n * live current point (during drag) to the nearest guide on each axis when\n * within `tolerance`. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesInsertArgs,\n): InsertBehavior<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const computeWorldTol = (): { x: number; y: number } =>\n getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n const snapped = snapPoint(o, guides, computeWorldTol());\n if (snapped) ctx.origin.set(id, snapped as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const snapped = snapPoint(current, guides, computeWorldTol());\n if (!snapped) return;\n return { current: snapped };\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/interactions/actions/insert/behaviors/snapToGrid.ts","../src/interactions/actions/insert/behaviors/snapToGuides.ts"],"names":[],"mappings":";;;;AAWO,SAAS,WAAkB,IAAA,EAGR;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAU,GAAI,IAAA;AAC/B,EAAA,MAAM,QAAQ,CAAC,CAAA,KAAc,KAAK,KAAA,CAAM,CAAA,GAAI,OAAO,CAAA,GAAI,OAAA;AACvD,EAAA,OAAO;AAAA,IACL,QAAQ,GAAA,EAAK;AACX,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,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C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC3B,MAAA,MAAM,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,EAAE,CAAA;AAC3B,MAAA,IAAI,CAAC,CAAA,EAAG;AACR,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,CAAA,EAAG,MAAA,EAAQ,iBAAiB,CAAA;AACtD,MAAA,IAAI,OAAA,EAAS,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,IAAI,OAA2B,CAAA;AAAA,IAC7D,CAAA;AAAA,IACA,MAAA,CAAO,GAAA,EAAK,EAAE,OAAA,EAAQ,EAAG;AACvB,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,iBAAiB,CAAA;AAC5D,MAAA,IAAI,CAAC,OAAA,EAAS;AACd,MAAA,OAAO,EAAE,SAAS,OAAA,EAAQ;AAAA,IAC5B;AAAA,GACF;AACF","file":"insert.js","sourcesContent":["import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\n/** Insert behavior that rounds the insertion point to a grid, so a shape\n * drawn freehand lands on grid intersections. Hold `bypassKey` to place\n * freely. */\nexport function snapToGrid<TPose>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): InsertBehavior<TPose> {\n const { spacing, bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n ctx.origin.set(id, { x: round(o.x), y: round(o.y) } as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n return { current: { x: round(current.x), y: round(current.y) } };\n },\n };\n}\n","import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { pxExtent } from 'core/viewport/pxExtent';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the insert-flavored `snapToGuides`. */\nexport interface SnapToGuidesInsertArgs {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n}\n\nfunction snapPoint(\n p: InsertPoint,\n guides: readonly Guide[],\n tol: { x: number; y: number },\n): InsertPoint | null {\n let bestDx = 0;\n let bestAbsDx = Infinity;\n let bestDy = 0;\n let bestAbsDy = Infinity;\n for (const g of guides) {\n if (g.axis === 'x') {\n const d = g.offset - p.x;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbsDx) {\n bestAbsDx = ad;\n bestDx = d;\n }\n } else {\n const d = g.offset - p.y;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbsDy) {\n bestAbsDy = ad;\n bestDy = d;\n }\n }\n }\n if (bestAbsDx === Infinity && bestAbsDy === Infinity) return null;\n const dx = bestAbsDx === Infinity ? 0 : bestDx;\n const dy = bestAbsDy === Infinity ? 0 : bestDy;\n if (dx === 0 && dy === 0) return null;\n return { x: p.x + dx, y: p.y + dy };\n}\n\n/**\n * Insert behavior that snaps the start anchor (on gesture start) and the\n * live current point (during drag) to the nearest guide on each axis when\n * within `tolerance`. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesInsertArgs,\n): InsertBehavior<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const computeWorldTol = (): { x: number; y: number } =>\n getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n const snapped = snapPoint(o, guides, computeWorldTol());\n if (snapped) ctx.origin.set(id, snapped as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const snapped = snapPoint(current, guides, computeWorldTol());\n if (!snapped) return;\n return { current: snapped };\n },\n };\n}\n"]}
@@ -0,0 +1,282 @@
1
+ import { c as PolygonPath, f as PathFillRule, e as RectPath, a as Path, d as RotatedPose } from './poseDescriptor-PgfVKfa0.js';
2
+ import '@weasel-js/geom';
3
+ import './autoPoseDescriptor-Dr6CwNZK.js';
4
+ import { Bounds } from '@weasel-js/routing';
5
+
6
+ /**
7
+ * Minimal node interface for the simulation primitive. Matches d3-force's
8
+ * node shape exactly so d3-force's bundled forces work without translation.
9
+ *
10
+ * Consumers extend this with arbitrary additional fields (id, label, etc.).
11
+ */
12
+ interface SimulationNode {
13
+ x: number;
14
+ y: number;
15
+ vx?: number;
16
+ vy?: number;
17
+ /** Pin x to this value when non-null. The integrator skips x/vx for the node. */
18
+ fx?: number | null;
19
+ fy?: number | null;
20
+ /** Array index, written by `initialize`. Some forces (e.g. forceLink) rely on it. */
21
+ index?: number;
22
+ }
23
+ /**
24
+ * Force protocol — contract-compatible with d3-force. A force is a function
25
+ * called once per tick with the current alpha; it mutates `vx`/`vy` on nodes.
26
+ * Optional `initialize` lets the force compute setup (link indices, etc.).
27
+ */
28
+ interface SimulationForce<TNode extends SimulationNode = SimulationNode> {
29
+ (alpha: number): void;
30
+ initialize?(nodes: TNode[], random?: () => number): void;
31
+ }
32
+ /** Options for `useSimulation`: everything {@link SimulationOptions} carries,
33
+ * plus the loop's own callbacks and clock. */
34
+ interface UseSimulationOptions<TNode extends SimulationNode> extends SimulationOptions<TNode> {
35
+ /** Fired after each integration step. */
36
+ onTick?: (nodes: TNode[]) => void;
37
+ /** Fired once when the sim settles (alpha < alphaMin && alphaTarget === 0). */
38
+ onEnd?: () => void;
39
+ /** Optional rAF injection. Defaults to window.requestAnimationFrame. */
40
+ requestFrame?: (cb: (t: number) => void) => number;
41
+ cancelFrame?: (handle: number) => void;
42
+ }
43
+ /**
44
+ * A force simulation over a set of nodes, with no clock of its own.
45
+ *
46
+ * Each tick applies every force and then integrates velocities, scaled by
47
+ * `alpha` — a temperature that decays toward `alphaTarget` so the layout
48
+ * settles instead of jittering forever. Raise `alphaTarget` to reheat it,
49
+ * which is what a drag does.
50
+ *
51
+ * Nodes are mutated in place; the simulation holds the array, not a copy.
52
+ *
53
+ * Nothing here advances time. {@link Simulation} adds the frame loop; a caller
54
+ * that wants the whole relaxation at once — a layout pass, a pre-warm, a test
55
+ * — drives {@link SimulationCore.tick} itself.
56
+ */
57
+ interface SimulationCore<TNode extends SimulationNode> {
58
+ readonly nodes: TNode[];
59
+ setNodes(nodes: TNode[]): this;
60
+ setForces(forces: SimulationForce<TNode>[]): this;
61
+ alpha(): number;
62
+ alpha(value: number): this;
63
+ alphaTarget(): number;
64
+ alphaTarget(value: number): this;
65
+ alphaDecay(): number;
66
+ alphaDecay(value: number): this;
67
+ alphaMin(): number;
68
+ alphaMin(value: number): this;
69
+ velocityDecay(): number;
70
+ velocityDecay(value: number): this;
71
+ /**
72
+ * Run the tick body synchronously `iterations` times. Does NOT fire
73
+ * onTick or onEnd (matches d3-force). Used for offscreen pre-warm and tests.
74
+ */
75
+ tick(iterations?: number): this;
76
+ isSettled(): boolean;
77
+ }
78
+ /** A {@link SimulationCore} running on a frame loop. */
79
+ interface Simulation<TNode extends SimulationNode> extends SimulationCore<TNode> {
80
+ /** Resume the RAF loop. If alpha < alphaMin, reset alpha to 1. */
81
+ restart(): this;
82
+ /** Cancel the RAF loop. Does not change alpha. */
83
+ stop(): this;
84
+ }
85
+ /** What {@link SimulationCore} needs: the nodes, the forces acting on them,
86
+ * and the cooling schedule. {@link UseSimulationOptions} adds the loop's. */
87
+ interface SimulationOptions<TNode extends SimulationNode> {
88
+ /** Mutable array of nodes. Kit + forces mutate vx/vy/x/y in place. */
89
+ nodes: TNode[];
90
+ /** Forces applied per tick. Each may implement `initialize` for setup. */
91
+ forces?: SimulationForce<TNode>[];
92
+ /** Initial alpha. Default 1. */
93
+ alpha?: number;
94
+ /** Settle threshold. When alpha drops below and alphaTarget is 0, onEnd fires. Default 0.001. */
95
+ alphaMin?: number;
96
+ /** Per-tick decay rate toward alphaTarget. Default 1 - 0.001^(1/300) ≈ 0.0228. */
97
+ alphaDecay?: number;
98
+ /** Target alpha. Set above alphaMin to keep sim warm (e.g. during drag). Default 0. */
99
+ alphaTarget?: number;
100
+ /** Friction multiplier on velocity per tick: vx *= (1 - velocityDecay). Default 0.4. */
101
+ velocityDecay?: number;
102
+ /** Handed to each force's `initialize`. Default `Math.random`; pass a seeded
103
+ * source to make a run reproducible. */
104
+ random?: () => number;
105
+ }
106
+ /** Default alpha decay: such that alpha drops from 1 to alphaMin (0.001) in 300 ticks. */
107
+ declare const DEFAULT_ALPHA_DECAY: number;
108
+ /** Alpha below which a cooling simulation is considered settled. */
109
+ declare const DEFAULT_ALPHA_MIN = 0.001;
110
+ /** Fraction of velocity shed each tick — friction. Higher settles sooner and
111
+ * overshoots less. */
112
+ declare const DEFAULT_VELOCITY_DECAY = 0.4;
113
+
114
+ /**
115
+ * The integrator, with no clock attached.
116
+ *
117
+ * Velocity-Verlet over a pluggable force list, contract-compatible with
118
+ * d3-force so d3's own bundled forces drop in untranslated. Nothing here
119
+ * advances time: `tick()` is the only thing that moves a node, and the caller
120
+ * decides how often to call it. `useSimulation` calls it once a frame; a
121
+ * layout pass calls it a few hundred times in one go and reads the result.
122
+ *
123
+ * Splitting it out is what lets a *pure* function run a relaxation — a React
124
+ * hook cannot, and the alternative was a second integrator drifting away from
125
+ * this one.
126
+ */
127
+
128
+ declare function createSimulation<TNode extends SimulationNode>(opts: SimulationOptions<TNode>): SimulationCore<TNode>;
129
+
130
+ /**
131
+ * Fluent builder for `PolygonPath`. Hides the `Uint8Array` / `Float32Array`
132
+ * encoding behind move/line/curve/close calls and a final `build()`. Use
133
+ * this to construct paths in tests and demos; production callers that need
134
+ * to mutate large paths in place should reach for the raw arrays directly.
135
+ *
136
+ * Numeric capacity grows by doubling — typical for amortized O(1) push.
137
+ *
138
+ * Also exposes `rectPath` / `polygonFromPoints` shortcuts for the common
139
+ * cases. `rectPath` returns the lighter `RectPath` subtype, not a polygon.
140
+ */
141
+
142
+ /** Fluent builder for `PolygonPath`; hides the `Uint8Array`/`Float32Array` encoding behind move/line/curve/close calls. */
143
+ declare class PathBuilder {
144
+ private cmds;
145
+ private xs;
146
+ private fillRule;
147
+ /** Seed a builder with an existing `PolygonPath`. Useful for extending
148
+ * an in-flight path with another segment (e.g. appending a cubic to
149
+ * the end of a curve in response to a user action) without hand-
150
+ * reaching into the `commands` / `coords` typed arrays.
151
+ *
152
+ * ```ts
153
+ * const next = PathBuilder.fromPath(current).curveTo(...).build();
154
+ * ```
155
+ */
156
+ static fromPath(path: PolygonPath): PathBuilder;
157
+ setFillRule(rule: PathFillRule): this;
158
+ moveTo(x: number, y: number): this;
159
+ lineTo(x: number, y: number): this;
160
+ /** Cubic bezier to (x, y) with control points (x1, y1) and (x2, y2). */
161
+ curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this;
162
+ /** Quadratic bezier to (x, y) with control point (x1, y1). */
163
+ quadTo(x1: number, y1: number, x: number, y: number): this;
164
+ close(): this;
165
+ build(): PolygonPath;
166
+ }
167
+ /** Construct a `RectPath` (the fast-path subtype). */
168
+ declare function rectPath(x: number, y: number, width: number, height: number): RectPath;
169
+ /** Build an open polyline from a flat list of points — the same geometry as
170
+ * {@link polygonFromPoints} without the closing edge. A freehand stroke and a
171
+ * measurement line want this; a region wants the closed one. */
172
+ declare function polylineFromPoints(points: readonly {
173
+ x: number;
174
+ y: number;
175
+ }[]): PolygonPath | RectPath;
176
+ /** Build a closed polygon from a flat list of points. */
177
+ declare function polygonFromPoints(points: readonly {
178
+ x: number;
179
+ y: number;
180
+ }[], opts?: {
181
+ fillRule?: PathFillRule;
182
+ }): PolygonPath;
183
+ /** Closed ellipse inscribed in `bounds`, as a 4-cubic-Bezier `PolygonPath`.
184
+ * Matches the geometry `useEllipseTool`'s overlay paints. */
185
+ declare function ellipsePath(bounds: {
186
+ x: number;
187
+ y: number;
188
+ width: number;
189
+ height: number;
190
+ }): PolygonPath;
191
+ /** Closed regular n-gon centered at `center`, circumscribed by `radius`.
192
+ * `rotation` is in radians; default 0 puts the first vertex on the +x axis. */
193
+ declare function regularPolygonPath(center: {
194
+ x: number;
195
+ y: number;
196
+ }, radius: number, sides: number, rotation?: number): PolygonPath;
197
+ /** Closed n-pointed star centered at `center`, alternating `outerRadius` and
198
+ * `innerRadius` (default `outerRadius / 2`). `rotation` is in radians. */
199
+ declare function starPath(center: {
200
+ x: number;
201
+ y: number;
202
+ }, outerRadius: number, points?: number, innerRadius?: number, rotation?: number): PolygonPath;
203
+ /** Open 2-vertex polyline from `a` to `b` — strokeable, not fillable. */
204
+ declare function linePath(a: {
205
+ x: number;
206
+ y: number;
207
+ }, b: {
208
+ x: number;
209
+ y: number;
210
+ }): PolygonPath;
211
+
212
+ /**
213
+ * Polygon-vs-axis-aligned-rect tests. Pure functions; no React/kit deps.
214
+ *
215
+ * `polygon` is a closed polyline given as an ordered vertex array; the
216
+ * closing edge from `polygon[N-1]` to `polygon[0]` is implicit. Even-odd fill
217
+ * rule, and one contour only — a path with holes or curves goes through
218
+ * `pathHitTest`, which reads its `fillRule`.
219
+ */
220
+
221
+ /** A 2D point or vector. */
222
+ interface Vec2 {
223
+ x: number;
224
+ y: number;
225
+ }
226
+
227
+ /**
228
+ * A station along a path: where it is at a fraction of its length, and which
229
+ * way it is heading there.
230
+ *
231
+ * For anything positioned *along* geometry rather than beside it — a label on a
232
+ * routed edge, a tick on a curve, a badge near an arrowhead. Curves are
233
+ * flattened first, so the fraction is arc length along the drawn shape rather
234
+ * than a curve parameter, which is what makes 0.5 look like the middle.
235
+ */
236
+
237
+ interface PathStation {
238
+ point: Vec2;
239
+ /** Unit vector along the path at `point`, pointing toward the end. */
240
+ tangent: Vec2;
241
+ }
242
+ interface PointAlongPathOptions {
243
+ /** Curve flattening tolerance, in world units. Default 0.5. */
244
+ flattenTolerance?: number;
245
+ }
246
+ /**
247
+ * Where `path` is at `t` of its total length, and its heading there.
248
+ *
249
+ * `t` is clamped to 0..1. Subpaths are measured in order and treated as one
250
+ * run, the way a browser measures a whole `<path>`. Returns `null` for a path
251
+ * with no points at all; a path of zero length answers at its single point,
252
+ * heading along +X.
253
+ */
254
+ declare function pointAlongPath(path: Path, t: number, opts?: PointAlongPathOptions): PathStation | null;
255
+
256
+ /** AABB center of an unrotated rect — the canonical rotation pivot. */
257
+ declare function aabbCenter(bounds: Bounds): {
258
+ x: number;
259
+ y: number;
260
+ };
261
+ /** Rotate `(px, py)` by `angle` (radians) around `(cx, cy)`. */
262
+ declare function rotatePoint(px: number, py: number, cx: number, cy: number, angle: number): {
263
+ x: number;
264
+ y: number;
265
+ };
266
+ /** Four corners of an unrotated rect, in TL/TR/BR/BL order. */
267
+ declare function rectCorners(bounds: Bounds): {
268
+ x: number;
269
+ y: number;
270
+ }[];
271
+ /** Four corners of a rotated rect (rotation around AABB center), in
272
+ * TL/TR/BR/BL order. Useful for selection-overlay rendering. */
273
+ declare function rotatedRectCorners(pose: RotatedPose): {
274
+ x: number;
275
+ y: number;
276
+ }[];
277
+ /** Hit-test a world point against a rotated rect (rotation around AABB
278
+ * center). Standard pattern: invert the rotation and AABB-test in the
279
+ * rect's local frame. */
280
+ declare function pointInRotatedRect(pose: RotatedPose, worldX: number, worldY: number): boolean;
281
+
282
+ export { DEFAULT_ALPHA_DECAY as D, PathBuilder as P, type SimulationNode as S, type UseSimulationOptions as U, type Vec2 as V, type Simulation as a, DEFAULT_ALPHA_MIN as b, DEFAULT_VELOCITY_DECAY as c, type PathStation as d, type PointAlongPathOptions as e, type SimulationCore as f, type SimulationForce as g, type SimulationOptions as h, aabbCenter as i, createSimulation as j, ellipsePath as k, linePath as l, pointInRotatedRect as m, polygonFromPoints as n, polylineFromPoints as o, pointAlongPath as p, rectPath as q, rectCorners as r, regularPolygonPath as s, rotatePoint as t, rotatedRectCorners as u, starPath as v };
package/dist/math.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { a as Path, f as PathFillRule, c as PolygonPath, P as PoseDescriptor, e as RectPath, t as translatePoseViaDescriptor } from './poseDescriptor-PgfVKfa0.js';
2
+ export { P as PathBuilder, a as Simulation, f as SimulationCore, g as SimulationForce, S as SimulationNode, h as SimulationOptions, V as Vec2, j as createSimulation, p as pointAlongPath, n as polygonFromPoints, o as polylineFromPoints, q as rectPath, t as rotatePoint } from './math-E3rZn4bR.js';
3
+ export { DEFAULT_FLATTEN_TOLERANCE, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, pathCommandCoordCount } from '@weasel-js/geom';
4
+ export { A as AUTO_POSE_DESCRIPTOR } from './autoPoseDescriptor-Dr6CwNZK.js';
5
+ import '@weasel-js/routing';
package/dist/math.js ADDED
@@ -0,0 +1,4 @@
1
+ export { createSimulation, pointAlongPath, rotatePoint } from './chunk-LXJDWBEL.js';
2
+ export { AUTO_POSE_DESCRIPTOR, DEFAULT_FLATTEN_TOLERANCE, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PathBuilder, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, pathCommandCoordCount, polygonFromPoints, polylineFromPoints, rectPath, translatePoseViaDescriptor } from './chunk-3LPQ2XZG.js';
3
+ //# sourceMappingURL=math.js.map
4
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"math.js"}
package/dist/move.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { O as OriginProjection } from './grid-0Pbn5B2C.js';
2
- export { U as UseMoveOptions } from './grid-0Pbn5B2C.js';
3
- import { M as ModifierState, b as MoveBehavior } from './types-ei3UMl9R.js';
4
- import { S as SnapTarget } from './types-DEALFt5F.js';
1
+ import { O as OriginProjection } from './grid-Z_Af3vTl.js';
2
+ export { U as UseMoveOptions } from './grid-Z_Af3vTl.js';
3
+ import { M as MoveBehavior } from './types-BHGdrOcu.js';
4
+ import { ModifierState, View } from '@weasel-js/routing';
5
+ import { S as SnapTarget } from './types-BdaK9PcP.js';
5
6
  import { G as Guide } from './types-D2tTKEU0.js';
6
- import { V as View } from './view-DSQgxBJB.js';
7
- import './types-BHK2dkMu.js';
8
7
  import '@weasel-js/history';
9
8
 
10
9
  type ModKey$1 = keyof ModifierState;
package/dist/move.js CHANGED
@@ -1,13 +1,13 @@
1
- import { scratchKey, snap, createTransformOp, createReparentOp, getScratch, setScratch } from './chunk-2VXGHUVL.js';
2
- import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-WPM42WJP.js';
1
+ import { snap, createTransformOp, createReparentOp } from './chunk-P6MGECVO.js';
2
+ import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-HAGOFNP5.js';
3
+ import './chunk-3LPQ2XZG.js';
3
4
  import { createDeleteOp } from './chunk-4RJP2N2L.js';
5
+ import { scratchKey, getScratch, setScratch } from '@weasel-js/routing';
4
6
 
5
7
  // src/interactions/actions/move/behaviors/snapToGrid.ts
6
8
  function snapToGrid(args) {
7
9
  return snap(gridSnapStrategy(args.spacing), { bypassKey: args.bypassKey });
8
10
  }
9
-
10
- // src/interactions/actions/move/behaviors/snapToContainer.ts
11
11
  var STATE = scratchKey("snapToContainer");
12
12
  function getState(ctx) {
13
13
  let s = getScratch(ctx.scratch, STATE);
@@ -84,8 +84,6 @@ function snapToContainer(args) {
84
84
  }
85
85
  };
86
86
  }
87
-
88
- // src/interactions/actions/move/behaviors/snapBackOrDelete.ts
89
87
  var SNAPSHOTS = scratchKey("snapBackOrDelete.snapshots");
90
88
  var INDEXES = scratchKey("snapBackOrDelete.indexes");
91
89
  function snapBackOrDelete(args) {
package/dist/move.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interactions/actions/move/behaviors/snapToGrid.ts","../src/interactions/actions/move/behaviors/snapToContainer.ts","../src/interactions/actions/move/behaviors/snapBackOrDelete.ts","../src/interactions/actions/move/behaviors/snapToGuides.ts"],"names":["snap"],"mappings":";;;;;AAQO,SAAS,WAAmD,IAAA,EAG3C;AACtB,EAAA,OAAO,IAAA,CAAK,iBAAwB,IAAA,CAAK,OAAO,GAAG,EAAE,SAAA,EAAW,IAAA,CAAK,SAAA,EAAW,CAAA;AAClF;;;ACIA,IAAM,KAAA,GAAQ,WAA+B,iBAAiB,CAAA;AAE9D,SAAS,SAAgB,GAAA,EAA8C;AACrE,EAAA,IAAI,CAAA,GAAI,UAAA,CAAW,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AACrC,EAAA,IAAI,CAAC,CAAA,EAAG;AACN,IAAA,CAAA,GAAI,EAAE,eAAA,EAAiB,IAAA,EAAM,YAAA,EAAc,I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jDO,SAAS,aACd,IAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,iBAAA,CAAyB,IAAA,CAAK,SAAA,EAAW;AAAA,IACxD,WAAW,IAAA,CAAK,SAAA;AAAA,IAChB,SAAS,IAAA,CAAK,OAAA;AAAA,IACd,QAAQ,IAAA,CAAK;AAAA,GACd,CAAA;AACD,EAAA,OAAO,KAAK,QAAA,EAAU,EAAE,SAAA,EAAW,IAAA,CAAK,WAAW,CAAA;AACrD","file":"move.js","sourcesContent":["import type { ModifierState, MoveBehavior } from '../../../gestures/types';\nimport { snap } from '../../../gestures/shared/snap';\nimport { gridSnapStrategy } from '../../../gestures/shared/strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/** Move behavior that snaps the dragged pose's origin to a grid. Hold\n * `bypassKey` to drag freely. */\nexport function snapToGrid<TPose extends { x: number; y: number }>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): MoveBehavior<TPose> {\n return snap(gridSnapStrategy<TPose>(args.spacing), { bypassKey: args.bypassKey });\n}\n","import { createTransformOp } from 'core/ops/transform';\nimport { createReparentOp } from 'core/ops/reparent';\nimport type { Op } from 'core/ops/types';\nimport type { SnapTarget } from 'core/adapters/types';\nimport type { MoveBehavior, GestureContext } from '../../../gestures/types';\nimport { scratchKey, getScratch, setScratch } from '../../../scratchKey';\n\ninterface SnapState<TPose> {\n pendingTargetId: string | null;\n pendingTimer: ReturnType<typeof setTimeout> | null;\n committedSnap: SnapTarget<TPose> | null;\n}\n\n// The slot is generic over TPose; we keep the unknown-pose key at module\n// scope and project it through `as` at the read site (each consumer call\n// of `snapToContainer<TPose>` is the only writer of its own SnapState\n// instance, so the cast is safe at runtime).\nconst STATE = scratchKey<SnapState<unknown>>('snapToContainer');\n\nfunction getState<TPose>(ctx: GestureContext<TPose>): SnapState<TPose> {\n let s = getScratch(ctx.scratch, STATE) as SnapState<TPose> | undefined;\n if (!s) {\n s = { pendingTargetId: null, pendingTimer: null, committedSnap: null };\n setScratch(ctx.scratch, STATE, s as SnapState<unknown>);\n }\n return s;\n}\n\nfunction clearTimer<TPose>(s: SnapState<TPose>) {\n if (s.pendingTimer !== null) {\n clearTimeout(s.pendingTimer);\n s.pendingTimer = null;\n }\n s.pendingTargetId = null;\n}\n\n/**\n * Move behavior that drops the dragged node into a container it hovers over\n * for `dwellMs`, reparenting it and taking the pose the container's layout\n * assigns.\n *\n * The dwell is what keeps a drag that merely passes over a container from\n * being captured by it.\n */\nexport function snapToContainer<TPose>(args: {\n dwellMs: number;\n findTarget: (\n draggedId: string,\n worldX: number,\n worldY: number,\n ) => SnapTarget<TPose> | null;\n isInstant?: (target: SnapTarget<TPose>) => boolean;\n moveLabel?: string;\n reparentLabel?: string;\n}): MoveBehavior<TPose> {\n const { dwellMs, findTarget, isInstant, moveLabel = 'Move', reparentLabel = 'Move and reparent' } = args;\n\n return {\n onMove(ctx, _proposed) {\n const s = getState<TPose>(ctx);\n const target = findTarget(ctx.draggedIds[0], ctx.pointer.worldX, ctx.pointer.worldY);\n\n if (s.committedSnap) {\n if (target && target.parentId === s.committedSnap.parentId) {\n return { pose: s.committedSnap.slotPose, snap: s.committedSnap };\n }\n s.committedSnap = null;\n }\n\n if (!target) {\n clearTimer(s);\n return;\n }\n\n if (isInstant?.(target)) {\n clearTimer(s);\n s.committedSnap = target;\n return { pose: target.slotPose, snap: target };\n }\n\n if (s.pendingTargetId === target.parentId) {\n return;\n }\n clearTimer(s);\n s.pendingTargetId = target.parentId;\n s.pendingTimer = setTimeout(() => {\n s.committedSnap = target;\n s.pendingTimer = null;\n }, dwellMs);\n return;\n },\n\n onEnd(ctx) {\n const s = getState<TPose>(ctx);\n clearTimer(s);\n const snap = s.committedSnap ?? ctx.snap;\n if (!snap) return;\n const draggedId = ctx.draggedIds[0];\n const oldParent = ctx.adapter.getParent?.(draggedId) ?? null;\n const fromPose = ctx.origin.get(draggedId)!;\n const ops: Op[] = [\n createTransformOp<TPose>({\n id: draggedId,\n from: fromPose,\n to: snap.slotPose,\n label: moveLabel,\n }),\n ];\n if (oldParent !== snap.parentId) {\n ops.push(createReparentOp({\n id: draggedId,\n fromParentId: oldParent,\n toParentId: snap.parentId,\n label: reparentLabel,\n }));\n }\n return ops;\n },\n };\n}\n","import { createDeleteOp } from 'core/ops/delete';\nimport type { Op } from 'core/ops/types';\nimport type { MoveBehavior } from '../../../gestures/types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from '../../../gestures/shared/strategies';\nimport { scratchKey, getScratch, setScratch } from '../../../scratchKey';\n\nconst SNAPSHOTS = scratchKey<Map<string, { id: string }>>('snapBackOrDelete.snapshots');\nconst INDEXES = scratchKey<Map<string, number>>('snapBackOrDelete.indexes');\n\n/**\n * Move behavior for a drag that is only meaningful near where it started:\n * release inside `radius` and the node returns to its original pose; release\n * outside it and the node either springs back anyway or is deleted, per\n * `onFreeRelease`. A deletion is recorded as an undoable op with paint order\n * preserved.\n */\nexport function snapBackOrDelete<TPose extends { x: number; y: number }>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n}): MoveBehavior<TPose>;\n/** As above, for a `TPose` that is not a rect: `origin` tells the behavior how\n * to read and write the pose's origin. */\nexport function snapBackOrDelete<TPose>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n origin: OriginProjection<TPose>;\n}): MoveBehavior<TPose>;\n/** Snap back to the origin pose, or delete, depending on where the drag is\n * released. */\nexport function snapBackOrDelete<TPose>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n origin?: OriginProjection<TPose>;\n}): MoveBehavior<TPose> {\n const { radius, onFreeRelease, deleteLabel = 'Delete' } = args;\n const proj: OriginProjection<TPose> =\n args.origin ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n const r2 = radius * radius;\n\n return {\n onStart(ctx) {\n // Snapshot the dragged objects + their z-indexes at gesture start so\n // delete can undo with paint order intact.\n const snapshots = new Map<string, { id: string }>();\n const indexes = new Map<string, number>();\n const nodes = ctx.adapter.getNodes();\n for (const id of ctx.draggedIds) {\n const obj = ctx.adapter.getNode(id) ?? { id };\n snapshots.set(id, obj);\n indexes.set(id, nodes.findIndex((n) => n.id === id));\n }\n setScratch(ctx.scratch, SNAPSHOTS, snapshots);\n setScratch(ctx.scratch, INDEXES, indexes);\n },\n\n onEnd(ctx) {\n if (ctx.snap) return;\n const id = ctx.draggedIds[0];\n const o0 = proj.getOrigin(ctx.origin.get(id)!);\n const o1 = proj.getOrigin(ctx.current.get(id)!);\n const dx = o1.x - o0.x;\n const dy = o1.y - o0.y;\n const within = dx * dx + dy * dy <= r2;\n if (within) {\n return null;\n }\n if (onFreeRelease === 'delete') {\n const snapshots = getScratch(ctx.scratch, SNAPSHOTS);\n const indexes = getScratch(ctx.scratch, INDEXES);\n const obj = snapshots?.get(id) ?? { id };\n const index = indexes?.get(id) ?? -1;\n const ops: Op[] = [createDeleteOp({ node: obj, label: deleteLabel, index })];\n return ops;\n }\n // `'snap-back'` — abort, same as a release inside the radius. Returning\n // `undefined` would defer to the default translate and leave the node\n // where it was dropped, which is the one thing this policy rules out.\n return null;\n },\n };\n}\n","import type { ModifierState, MoveBehavior } from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport type { OriginProjection } from '../../../gestures/shared/strategies/grid';\nimport { snap } from '../../../gestures/shared/snap';\nimport { guideSnapStrategy } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the move-flavored `snapToGuides`. */\nexport interface SnapToGuidesMoveArgs<TPose> {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n /** Origin projection for non-rect TPose (e.g. Path). */\n origin?: OriginProjection<TPose>;\n}\n\n/**\n * Move behavior that snaps the dragged pose's origin to the nearest world-space\n * guide line within `tolerance`. Closest-guide-per-axis wins; the two axes are\n * considered independently. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose extends { x: number; y: number }>(\n args: Omit<SnapToGuidesMoveArgs<TPose>, 'origin'>,\n): MoveBehavior<TPose>;\n/** As above, for a `TPose` that is not a rect: `origin` tells the behavior how\n * to read and write the pose's origin. */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesMoveArgs<TPose> & { origin: OriginProjection<TPose> },\n): MoveBehavior<TPose>;\n/** Snap the dragged pose's origin to the nearest guide line, per axis. */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesMoveArgs<TPose>,\n): MoveBehavior<TPose> {\n const strategy = guideSnapStrategy<TPose>(args.getGuides, {\n tolerance: args.tolerance,\n getView: args.getView,\n origin: args.origin as OriginProjection<TPose>,\n });\n return snap(strategy, { bypassKey: args.bypassKey });\n}\n"]}
1
+ {"version":3,"sources":["../src/interactions/actions/move/behaviors/snapToGrid.ts","../src/interactions/actions/move/behaviors/snapToContainer.ts","../src/interactions/actions/move/behaviors/snapBackOrDelete.ts","../src/interactions/actions/move/behaviors/snapToGuides.ts"],"names":["snap","scratchKey","setScratch","getScratch"],"mappings":";;;;;;;AAQO,SAAS,WAAmD,IAAA,EAG3C;AACtB,EAAA,OAAO,IAAA,CAAK,iBAAwB,IAAA,CAAK,OAAO,GAAG,EAAE,SAAA,EAAW,IAAA,CAAK,SAAA,EAAW,CAAA;AAClF;ACIA,IAAM,KAAA,GAAQ,WAA+B,iBAAiB,CAAA;AAE9D,SAAS,SAAgB,GAAA,EAA8C;AACrE,EAAA,IAAI,CAAA,GAAI,UAAA,CAAW,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AACrC,EAAA,IAAI,CAAC,CAAA,EAAG;AACN,IAAA,CAAA,GAAI,EAAE,eAAA,EAAiB,IAAA,EAAM,YAAA,EA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GACF;AACF;;;ACjDO,SAAS,aACd,IAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,iBAAA,CAAyB,IAAA,CAAK,SAAA,EAAW;AAAA,IACxD,WAAW,IAAA,CAAK,SAAA;AAAA,IAChB,SAAS,IAAA,CAAK,OAAA;AAAA,IACd,QAAQ,IAAA,CAAK;AAAA,GACd,CAAA;AACD,EAAA,OAAO,KAAK,QAAA,EAAU,EAAE,SAAA,EAAW,IAAA,CAAK,WAAW,CAAA;AACrD","file":"move.js","sourcesContent":["import type { ModifierState, MoveBehavior } from '../../../gestures/types';\nimport { snap } from '../../../gestures/shared/snap';\nimport { gridSnapStrategy } from '../../../gestures/shared/strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/** Move behavior that snaps the dragged pose's origin to a grid. Hold\n * `bypassKey` to drag freely. */\nexport function snapToGrid<TPose extends { x: number; y: number }>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): MoveBehavior<TPose> {\n return snap(gridSnapStrategy<TPose>(args.spacing), { bypassKey: args.bypassKey });\n}\n","import { createTransformOp } from 'core/ops/transform';\nimport { createReparentOp } from 'core/ops/reparent';\nimport type { Op } from 'core/ops/types';\nimport type { SnapTarget } from 'core/adapters/types';\nimport type { MoveBehavior, GestureContext } from '../../../gestures/types';\nimport { scratchKey, getScratch, setScratch } from '@weasel-js/routing';\n\ninterface SnapState<TPose> {\n pendingTargetId: string | null;\n pendingTimer: ReturnType<typeof setTimeout> | null;\n committedSnap: SnapTarget<TPose> | null;\n}\n\n// The slot is generic over TPose; we keep the unknown-pose key at module\n// scope and project it through `as` at the read site (each consumer call\n// of `snapToContainer<TPose>` is the only writer of its own SnapState\n// instance, so the cast is safe at runtime).\nconst STATE = scratchKey<SnapState<unknown>>('snapToContainer');\n\nfunction getState<TPose>(ctx: GestureContext<TPose>): SnapState<TPose> {\n let s = getScratch(ctx.scratch, STATE) as SnapState<TPose> | undefined;\n if (!s) {\n s = { pendingTargetId: null, pendingTimer: null, committedSnap: null };\n setScratch(ctx.scratch, STATE, s as SnapState<unknown>);\n }\n return s;\n}\n\nfunction clearTimer<TPose>(s: SnapState<TPose>) {\n if (s.pendingTimer !== null) {\n clearTimeout(s.pendingTimer);\n s.pendingTimer = null;\n }\n s.pendingTargetId = null;\n}\n\n/**\n * Move behavior that drops the dragged node into a container it hovers over\n * for `dwellMs`, reparenting it and taking the pose the container's layout\n * assigns.\n *\n * The dwell is what keeps a drag that merely passes over a container from\n * being captured by it.\n */\nexport function snapToContainer<TPose>(args: {\n dwellMs: number;\n findTarget: (\n draggedId: string,\n worldX: number,\n worldY: number,\n ) => SnapTarget<TPose> | null;\n isInstant?: (target: SnapTarget<TPose>) => boolean;\n moveLabel?: string;\n reparentLabel?: string;\n}): MoveBehavior<TPose> {\n const { dwellMs, findTarget, isInstant, moveLabel = 'Move', reparentLabel = 'Move and reparent' } = args;\n\n return {\n onMove(ctx, _proposed) {\n const s = getState<TPose>(ctx);\n const target = findTarget(ctx.draggedIds[0], ctx.pointer.worldX, ctx.pointer.worldY);\n\n if (s.committedSnap) {\n if (target && target.parentId === s.committedSnap.parentId) {\n return { pose: s.committedSnap.slotPose, snap: s.committedSnap };\n }\n s.committedSnap = null;\n }\n\n if (!target) {\n clearTimer(s);\n return;\n }\n\n if (isInstant?.(target)) {\n clearTimer(s);\n s.committedSnap = target;\n return { pose: target.slotPose, snap: target };\n }\n\n if (s.pendingTargetId === target.parentId) {\n return;\n }\n clearTimer(s);\n s.pendingTargetId = target.parentId;\n s.pendingTimer = setTimeout(() => {\n s.committedSnap = target;\n s.pendingTimer = null;\n }, dwellMs);\n return;\n },\n\n onEnd(ctx) {\n const s = getState<TPose>(ctx);\n clearTimer(s);\n const snap = s.committedSnap ?? ctx.snap;\n if (!snap) return;\n const draggedId = ctx.draggedIds[0];\n const oldParent = ctx.adapter.getParent?.(draggedId) ?? null;\n const fromPose = ctx.origin.get(draggedId)!;\n const ops: Op[] = [\n createTransformOp<TPose>({\n id: draggedId,\n from: fromPose,\n to: snap.slotPose,\n label: moveLabel,\n }),\n ];\n if (oldParent !== snap.parentId) {\n ops.push(createReparentOp({\n id: draggedId,\n fromParentId: oldParent,\n toParentId: snap.parentId,\n label: reparentLabel,\n }));\n }\n return ops;\n },\n };\n}\n","import { createDeleteOp } from 'core/ops/delete';\nimport type { Op } from 'core/ops/types';\nimport type { MoveBehavior } from '../../../gestures/types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from '../../../gestures/shared/strategies';\nimport { scratchKey, getScratch, setScratch } from '@weasel-js/routing';\n\nconst SNAPSHOTS = scratchKey<Map<string, { id: string }>>('snapBackOrDelete.snapshots');\nconst INDEXES = scratchKey<Map<string, number>>('snapBackOrDelete.indexes');\n\n/**\n * Move behavior for a drag that is only meaningful near where it started:\n * release inside `radius` and the node returns to its original pose; release\n * outside it and the node either springs back anyway or is deleted, per\n * `onFreeRelease`. A deletion is recorded as an undoable op with paint order\n * preserved.\n */\nexport function snapBackOrDelete<TPose extends { x: number; y: number }>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n}): MoveBehavior<TPose>;\n/** As above, for a `TPose` that is not a rect: `origin` tells the behavior how\n * to read and write the pose's origin. */\nexport function snapBackOrDelete<TPose>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n origin: OriginProjection<TPose>;\n}): MoveBehavior<TPose>;\n/** Snap back to the origin pose, or delete, depending on where the drag is\n * released. */\nexport function snapBackOrDelete<TPose>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n origin?: OriginProjection<TPose>;\n}): MoveBehavior<TPose> {\n const { radius, onFreeRelease, deleteLabel = 'Delete' } = args;\n const proj: OriginProjection<TPose> =\n args.origin ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n const r2 = radius * radius;\n\n return {\n onStart(ctx) {\n // Snapshot the dragged objects + their z-indexes at gesture start so\n // delete can undo with paint order intact.\n const snapshots = new Map<string, { id: string }>();\n const indexes = new Map<string, number>();\n const nodes = ctx.adapter.getNodes();\n for (const id of ctx.draggedIds) {\n const obj = ctx.adapter.getNode(id) ?? { id };\n snapshots.set(id, obj);\n indexes.set(id, nodes.findIndex((n) => n.id === id));\n }\n setScratch(ctx.scratch, SNAPSHOTS, snapshots);\n setScratch(ctx.scratch, INDEXES, indexes);\n },\n\n onEnd(ctx) {\n if (ctx.snap) return;\n const id = ctx.draggedIds[0];\n const o0 = proj.getOrigin(ctx.origin.get(id)!);\n const o1 = proj.getOrigin(ctx.current.get(id)!);\n const dx = o1.x - o0.x;\n const dy = o1.y - o0.y;\n const within = dx * dx + dy * dy <= r2;\n if (within) {\n return null;\n }\n if (onFreeRelease === 'delete') {\n const snapshots = getScratch(ctx.scratch, SNAPSHOTS);\n const indexes = getScratch(ctx.scratch, INDEXES);\n const obj = snapshots?.get(id) ?? { id };\n const index = indexes?.get(id) ?? -1;\n const ops: Op[] = [createDeleteOp({ node: obj, label: deleteLabel, index })];\n return ops;\n }\n // `'snap-back'` — abort, same as a release inside the radius. Returning\n // `undefined` would defer to the default translate and leave the node\n // where it was dropped, which is the one thing this policy rules out.\n return null;\n },\n };\n}\n","import type { ModifierState, MoveBehavior } from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport type { OriginProjection } from '../../../gestures/shared/strategies/grid';\nimport { snap } from '../../../gestures/shared/snap';\nimport { guideSnapStrategy } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the move-flavored `snapToGuides`. */\nexport interface SnapToGuidesMoveArgs<TPose> {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n /** Origin projection for non-rect TPose (e.g. Path). */\n origin?: OriginProjection<TPose>;\n}\n\n/**\n * Move behavior that snaps the dragged pose's origin to the nearest world-space\n * guide line within `tolerance`. Closest-guide-per-axis wins; the two axes are\n * considered independently. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose extends { x: number; y: number }>(\n args: Omit<SnapToGuidesMoveArgs<TPose>, 'origin'>,\n): MoveBehavior<TPose>;\n/** As above, for a `TPose` that is not a rect: `origin` tells the behavior how\n * to read and write the pose's origin. */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesMoveArgs<TPose> & { origin: OriginProjection<TPose> },\n): MoveBehavior<TPose>;\n/** Snap the dragged pose's origin to the nearest guide line, per axis. */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesMoveArgs<TPose>,\n): MoveBehavior<TPose> {\n const strategy = guideSnapStrategy<TPose>(args.getGuides, {\n tolerance: args.tolerance,\n getView: args.getView,\n origin: args.origin as OriginProjection<TPose>,\n });\n return snap(strategy, { bypassKey: args.bypassKey });\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { Op } from '@weasel-js/history';
2
- import { I as InsertBehavior, R as ResizePose } from './types-ei3UMl9R.js';
2
+ import { I as InsertBehavior } from './types-BHGdrOcu.js';
3
+ import { Bounds } from '@weasel-js/routing';
3
4
 
4
5
  /** Option surface for the `insert` action.
5
6
  *
@@ -27,7 +28,7 @@ interface UseInsertOptions<TPose, TNode extends {
27
28
  /** Construct the in-flight pose from the drag bounds. Defaults to the
28
29
  * identity cast (treat bounds as TPose). Override for non-rect TPose
29
30
  * (e.g. `(b) => rectPath(b)` or a polygon factory). */
30
- posefromBounds?: (bounds: ResizePose) => TPose;
31
+ posefromBounds?: (bounds: Bounds) => TPose;
31
32
  /** Click / sub-threshold-drag fallback. When provided, a release whose
32
33
  * bounds fall <= minBounds calls `pointInsert(start)` instead of aborting.
33
34
  * Returning null aborts. The created object is dispatched as an InsertOp