@weasel-js/core 1.0.2 → 1.0.3

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 (50) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/{DrawCommand-DCmiNkBj.d.ts → DrawCommand-BbPrSTra.d.ts} +24 -0
  3. package/dist/{chunk-Z3KNFTTS.js → chunk-3JYFAQIB.js} +3 -3
  4. package/dist/chunk-3JYFAQIB.js.map +1 -0
  5. package/dist/{chunk-UB6A6L77.js → chunk-3KGMJMOS.js} +3 -3
  6. package/dist/{chunk-UB6A6L77.js.map → chunk-3KGMJMOS.js.map} +1 -1
  7. package/dist/{chunk-IO5Z75X4.js → chunk-HGF5X6MZ.js} +2 -2
  8. package/dist/chunk-HGF5X6MZ.js.map +1 -0
  9. package/dist/{chunk-775XXAHR.js → chunk-JOSUVS6C.js} +2 -2
  10. package/dist/{chunk-775XXAHR.js.map → chunk-JOSUVS6C.js.map} +1 -1
  11. package/dist/{chunk-PI56ORHE.js → chunk-SMCZRSYB.js} +88 -59
  12. package/dist/chunk-SMCZRSYB.js.map +1 -0
  13. package/dist/{chunk-W2WB4352.js → chunk-TR3HZN34.js} +2 -2
  14. package/dist/chunk-TR3HZN34.js.map +1 -0
  15. package/dist/{chunk-6SHZHXXR.js → chunk-U45SODC2.js} +2 -2
  16. package/dist/{chunk-6SHZHXXR.js.map → chunk-U45SODC2.js.map} +1 -1
  17. package/dist/clipboard.d.ts +5 -2
  18. package/dist/clipboard.js +1 -1
  19. package/dist/clone.d.ts +2 -2
  20. package/dist/{geometry-CnISZ11w.d.ts → geometry-5X6TrAkX.d.ts} +1 -1
  21. package/dist/{grid-CBiLBnyc.d.ts → grid-sfilv5HP.d.ts} +7 -2
  22. package/dist/index.d.ts +546 -20
  23. package/dist/index.js +7 -7
  24. package/dist/insert.d.ts +6 -3
  25. package/dist/insert.js +1 -1
  26. package/dist/insert.js.map +1 -1
  27. package/dist/move.d.ts +26 -5
  28. package/dist/move.js +2 -2
  29. package/dist/move.js.map +1 -1
  30. package/dist/{options-DoOvx50U.d.ts → options-CbsIgQci.d.ts} +3 -1
  31. package/dist/patterns-builtin.d.ts +8 -0
  32. package/dist/patterns-builtin.js +1 -1
  33. package/dist/{pointSnapToGrid-Bj4r_lEQ.d.ts → pointSnapToGrid-C3wowsQy.d.ts} +9 -3
  34. package/dist/{registry-BQL4oyTg.d.ts → registry-CxnkXbG8.d.ts} +90 -6
  35. package/dist/renderer.d.ts +25 -4
  36. package/dist/renderer.js +7 -7
  37. package/dist/resize.d.ts +12 -5
  38. package/dist/resize.js +2 -2
  39. package/dist/routing.d.ts +7 -7
  40. package/dist/routing.js +1 -1
  41. package/dist/{types-Dtxe7jTS.d.ts → types-BHK2dkMu.d.ts} +23 -0
  42. package/dist/{types-Ct4n0Z38.d.ts → types-ByZxoD6P.d.ts} +1 -1
  43. package/dist/{types-Ch0Goo-j.d.ts → types-DpQ0cWYC.d.ts} +20 -0
  44. package/dist/{types-Kh_osAq9.d.ts → types-vqxpCFVp.d.ts} +31 -0
  45. package/dist/{viewToMat3-BvaWCN99.d.ts → viewToMat3-CQW_YqDw.d.ts} +1 -1
  46. package/package.json +6 -6
  47. package/dist/chunk-IO5Z75X4.js.map +0 -1
  48. package/dist/chunk-PI56ORHE.js.map +0 -1
  49. package/dist/chunk-W2WB4352.js.map +0 -1
  50. package/dist/chunk-Z3KNFTTS.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, 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_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, 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_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyHitExistingGate, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, 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, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, 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, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, isPatternSpec, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, liveScope, makeViewportZoomAction, markdownToRuns, 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, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveDeviceProfile, resolveFillPattern, resolvePatternSpec, resolveRuns, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sceneFromJSON, sceneNodeClientRect, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, 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, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, viewportsAt, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-PI56ORHE.js';
2
- export { ActionDisabledReason, ActionsProvider, DepRegistryProvider, evaluateEnabled, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-W2WB4352.js';
3
- export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-UB6A6L77.js';
4
- export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-Z3KNFTTS.js';
5
- export { 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, linePath, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius } from './chunk-6SHZHXXR.js';
6
- export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-775XXAHR.js';
1
+ export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, 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_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, 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_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyHitExistingGate, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, 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, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, 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, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, isPatternSpec, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, liveScope, makeViewportZoomAction, markdownToRuns, 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, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveDeviceProfile, resolveFillPattern, resolvePatternSpec, resolveRuns, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sceneFromJSON, sceneNodeClientRect, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, 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, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, viewportsAt, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-SMCZRSYB.js';
2
+ export { ActionDisabledReason, ActionsProvider, DepRegistryProvider, evaluateEnabled, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-TR3HZN34.js';
3
+ export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-3KGMJMOS.js';
4
+ export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-3JYFAQIB.js';
5
+ export { 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, linePath, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius } from './chunk-U45SODC2.js';
6
+ export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-JOSUVS6C.js';
7
7
  export { cloneByAltDrag } from './chunk-UGFFCMQP.js';
8
8
  export { createSetSelectionOp } from './chunk-BHVYVFGV.js';
9
9
  export { createDeleteOp, createInsertOp, rebuildOp, registerOpFactory } from './chunk-GVCNT7UH.js';
10
- export { createTilePattern } from './chunk-IO5Z75X4.js';
10
+ export { createTilePattern } from './chunk-HGF5X6MZ.js';
11
11
  //# sourceMappingURL=index.js.map
12
12
  //# sourceMappingURL=index.js.map
package/dist/insert.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- export { U as UseInsertOptions } from './options-DoOvx50U.js';
2
- import { M as ModifierState, I as InsertBehavior } from './types-Ct4n0Z38.js';
1
+ export { U as UseInsertOptions } from './options-CbsIgQci.js';
2
+ import { M as ModifierState, I as InsertBehavior } from './types-ByZxoD6P.js';
3
3
  import { G as Guide } from './types-D2tTKEU0.js';
4
4
  import { V as View } from './view-DSQgxBJB.js';
5
5
  import '@weasel-js/history';
6
- import './types-Ch0Goo-j.js';
6
+ import './types-DpQ0cWYC.js';
7
7
 
8
8
  type ModKey$1 = keyof ModifierState;
9
+ /** Insert behavior that rounds the insertion point to a grid, so a shape
10
+ * drawn freehand lands on grid intersections. Hold `bypassKey` to place
11
+ * freely. */
9
12
  declare function snapToGrid<TPose>(args: {
10
13
  spacing: number;
11
14
  bypassKey?: ModKey$1;
package/dist/insert.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-6SHZHXXR.js';
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-U45SODC2.js';
2
2
 
3
3
  // src/interactions/actions/insert/behaviors/snapToGrid.ts
4
4
  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":";;;AAQO,SAAS,WAAkB,IAAA,EAGR;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAU,GAAI,IAAA;AAC/B,EAAA,MAAM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E,KAAK,CAAA,GAAI,EAAE,CAAA,EAAG,SAAA,EAAW,GAAG,SAAA,EAAU;AAEhF,EAAA,OAAO;AAAA,IACL,QAAQ,GAAA,EAAK;AACX,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,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\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,SA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AAA,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"]}
package/dist/move.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- import { O as OriginProjection } from './grid-CBiLBnyc.js';
2
- export { U as UseMoveOptions } from './grid-CBiLBnyc.js';
3
- import { M as ModifierState, b as MoveBehavior } from './types-Ct4n0Z38.js';
4
- import { S as SnapTarget } from './types-Ch0Goo-j.js';
1
+ import { O as OriginProjection } from './grid-sfilv5HP.js';
2
+ export { U as UseMoveOptions } from './grid-sfilv5HP.js';
3
+ import { M as ModifierState, b as MoveBehavior } from './types-ByZxoD6P.js';
4
+ import { S as SnapTarget } from './types-DpQ0cWYC.js';
5
5
  import { G as Guide } from './types-D2tTKEU0.js';
6
6
  import { V as View } from './view-DSQgxBJB.js';
7
- import './types-Dtxe7jTS.js';
7
+ import './types-BHK2dkMu.js';
8
8
  import '@weasel-js/history';
9
9
 
10
10
  type ModKey$1 = keyof ModifierState;
11
+ /** Move behavior that snaps the dragged pose's origin to a grid. Hold
12
+ * `bypassKey` to drag freely. */
11
13
  declare function snapToGrid<TPose extends {
12
14
  x: number;
13
15
  y: number;
@@ -16,6 +18,14 @@ declare function snapToGrid<TPose extends {
16
18
  bypassKey?: ModKey$1;
17
19
  }): MoveBehavior<TPose>;
18
20
 
21
+ /**
22
+ * Move behavior that drops the dragged node into a container it hovers over
23
+ * for `dwellMs`, reparenting it and taking the pose the container's layout
24
+ * assigns.
25
+ *
26
+ * The dwell is what keeps a drag that merely passes over a container from
27
+ * being captured by it.
28
+ */
19
29
  declare function snapToContainer<TPose>(args: {
20
30
  dwellMs: number;
21
31
  findTarget: (draggedId: string, worldX: number, worldY: number) => SnapTarget<TPose> | null;
@@ -24,6 +34,13 @@ declare function snapToContainer<TPose>(args: {
24
34
  reparentLabel?: string;
25
35
  }): MoveBehavior<TPose>;
26
36
 
37
+ /**
38
+ * Move behavior for a drag that is only meaningful near where it started:
39
+ * release inside `radius` and the node returns to its original pose; release
40
+ * outside it and the node either springs back anyway or is deleted, per
41
+ * `onFreeRelease`. A deletion is recorded as an undoable op with paint order
42
+ * preserved.
43
+ */
27
44
  declare function snapBackOrDelete<TPose extends {
28
45
  x: number;
29
46
  y: number;
@@ -32,6 +49,8 @@ declare function snapBackOrDelete<TPose extends {
32
49
  onFreeRelease: 'snap-back' | 'delete';
33
50
  deleteLabel?: string;
34
51
  }): MoveBehavior<TPose>;
52
+ /** As above, for a `TPose` that is not a rect: `origin` tells the behavior how
53
+ * to read and write the pose's origin. */
35
54
  declare function snapBackOrDelete<TPose>(args: {
36
55
  radius: number;
37
56
  onFreeRelease: 'snap-back' | 'delete';
@@ -62,6 +81,8 @@ declare function snapToGuides<TPose extends {
62
81
  x: number;
63
82
  y: number;
64
83
  }>(args: Omit<SnapToGuidesMoveArgs<TPose>, 'origin'>): MoveBehavior<TPose>;
84
+ /** As above, for a `TPose` that is not a rect: `origin` tells the behavior how
85
+ * to read and write the pose's origin. */
65
86
  declare function snapToGuides<TPose>(args: SnapToGuidesMoveArgs<TPose> & {
66
87
  origin: OriginProjection<TPose>;
67
88
  }): MoveBehavior<TPose>;
package/dist/move.js CHANGED
@@ -1,5 +1,5 @@
1
- import { scratchKey, snap, createTransformOp, createReparentOp, getScratch, setScratch } from './chunk-UB6A6L77.js';
2
- import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-6SHZHXXR.js';
1
+ import { scratchKey, snap, createTransformOp, createReparentOp, getScratch, setScratch } from './chunk-3KGMJMOS.js';
2
+ import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-U45SODC2.js';
3
3
  import { createDeleteOp } from './chunk-GVCNT7UH.js';
4
4
 
5
5
  // src/interactions/actions/move/behaviors/snapToGrid.ts
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":";;;;;AAMO,SAAS,WAAmD,IAAA,EAG3C;AACtB,EAAA,OAAO,IAAA,CAAK,iBAAwB,IAAA,CAAK,OAAO,GAAG,EAAE,SAAA,EAAW,IAAA,CAAK,SAAA,EAAW,CAAA;AAClF;;;ACMA,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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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\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\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\nexport function snapBackOrDelete<TPose extends { x: number; y: number }>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n}): MoveBehavior<TPose>;\nexport function snapBackOrDelete<TPose>(args: {\n radius: number;\n onFreeRelease: 'snap-back' | 'delete';\n deleteLabel?: string;\n origin: OriginProjection<TPose>;\n}): MoveBehavior<TPose>;\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 return;\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>;\nexport function snapToGuides<TPose>(\n args: SnapToGuidesMoveArgs<TPose> & { origin: OriginProjection<TPose> },\n): MoveBehavior<TPose>;\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"],"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,IAAA,EAAM,eAAe,IAAA,EAAK;AACrE,IAAA,UAAA,CAAW,GAAA,CAAI,OAAA,EAAS,KAAA,EAAO,CAAuB,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,CAAA;AACT;AAEA,SAAS,WAAkB,CAAA,EAAqB;AAC9C,EAAA,IAAI,CAAA,CAAE,iBAAiB,IAAA,EAAM;AAC3B,IAAA,YAAA,CAAa,EAAE,YAAY,CAAA;AAC3B,IAAA,CAAA,CAAE,YAAA,GAAe,IAAA;AAAA,EACnB;AACA,EAAA,CAAA,CAAE,eAAA,GAAkB,IAAA;AACtB;AAUO,SAAS,gBAAuB,IAAA,EAUf;AACtB,EAAA,MAAM,EAAE,SAAS,UAAA,EAAY,SAAA,EAAW,YAAY,MAAA,EAAQ,aAAA,GAAgB,qBAAoB,GAAI,IAAA;AAEpG,EAAA,OAAO;AAAA,IACL,MAAA,CAAO,KAAK,SAAA,EAAW;AACrB,MAAA,MAAM,CAAA,GAAI,SAAgB,GAAG,CAAA;A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Q;AACV,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,IAAI,kBAAkB,QAAA,EAAU;AAC9B,QAAA,MAAM,SAAA,GAAY,UAAA,CAAW,GAAA,CAAI,OAAA,EAAS,SAAS,CAAA;AACnD,QAAA,MAAM,OAAA,GAAU,UAAA,CAAW,GAAA,CAAI,OAAA,EAAS,OAAO,CAAA;AAC/C,QAAA,MAAM,MAAM,SAAA,EAAW,GAAA,CAAI,EAAE,CAAA,IAAK,EAAE,EAAA,EAAG;AACvC,QAAA,MAAM,KAAA,GAAQ,OAAA,EAAS,GAAA,CAAI,EAAE,CAAA,IAAK,EAAA;AAClC,QAAA,MAAM,GAAA,GAAY,CAAC,cAAA,CAAe,EAAE,IAAA,EAAM,KAAK,KAAA,EAAO,WAAA,EAAa,KAAA,EAAO,CAAC,CAAA;AAC3E,QAAA,OAAO,GAAA;AAAA,MACT;AACA,MAAA;AAAA,IACF;AAAA,GACF;AACF;;;AC9CO,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 return;\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,5 @@
1
1
  import { Op } from '@weasel-js/history';
2
- import { I as InsertBehavior, R as ResizePose } from './types-Ct4n0Z38.js';
2
+ import { I as InsertBehavior, R as ResizePose } from './types-ByZxoD6P.js';
3
3
 
4
4
  /** Option surface for the `insert` action.
5
5
  *
@@ -8,6 +8,8 @@ import { I as InsertBehavior, R as ResizePose } from './types-Ct4n0Z38.js';
8
8
  * Consumers should import from here directly; `insert.ts` re-exports the
9
9
  * same symbol for back-compat. */
10
10
 
11
+ /** Options for the `insert` action: what the drag bounds become, what a click
12
+ * with no drag does, and the behaviors that shape the pose along the way. */
11
13
  interface UseInsertOptions<TPose, TNode extends {
12
14
  id: string;
13
15
  } = {
@@ -9,6 +9,7 @@ import { T as TilePatternSpec, a as TextureHandle } from './paint-types-CnLIzqq1
9
9
  * serializer would let the raster and vector forms drift apart silently.
10
10
  */
11
11
 
12
+ /** One primitive within a pattern tile, in tile-local coordinates. */
12
13
  type TileShape = {
13
14
  kind: 'line';
14
15
  x1: number;
@@ -46,6 +47,9 @@ interface TileGeometry {
46
47
  }
47
48
  /** Defaults per tile kind, matching each factory's signature. */
48
49
  declare function tileSize(spec: TilePatternSpec): number;
50
+ /** Resolve a pattern spec to the shapes that make up one tile. Consumers that
51
+ * want to draw a pattern swatch themselves — a picker, an SVG export — read
52
+ * this rather than rasterizing a texture. */
49
53
  declare function tileGeometry(spec: TilePatternSpec): TileGeometry;
50
54
  /** Draw a tile's shapes to a 2D context — the raster half of the pair. */
51
55
  declare function drawTileShapes(oc: CanvasRenderingContext2D, geometry: TileGeometry): void;
@@ -74,6 +78,7 @@ interface HatchParams {
74
78
  size?: number;
75
79
  lineWidth?: number;
76
80
  }
81
+ /** Build a diagonal-hatch pattern texture. */
77
82
  declare function hatch(params: HatchParams): TextureHandle | null;
78
83
  /** Diagonal hatch in both directions. */
79
84
  interface CrosshatchParams {
@@ -81,6 +86,7 @@ interface CrosshatchParams {
81
86
  size?: number;
82
87
  lineWidth?: number;
83
88
  }
89
+ /** Build a crosshatch pattern texture. */
84
90
  declare function crosshatch(params: CrosshatchParams): TextureHandle | null;
85
91
  /** Regular grid of filled dots. */
86
92
  interface DotsParams {
@@ -88,6 +94,7 @@ interface DotsParams {
88
94
  size?: number;
89
95
  radius?: number;
90
96
  }
97
+ /** Build a dot-grid pattern texture. */
91
98
  declare function dots(params: DotsParams): TextureHandle | null;
92
99
  /**
93
100
  * Random scatter of small ellipses on top of a solid background. Driven by a
@@ -105,6 +112,7 @@ interface ChunksParams {
105
112
  chunkSize?: number;
106
113
  seed?: number;
107
114
  }
115
+ /** Build a seeded random-scatter pattern texture. */
108
116
  declare function chunks(params: ChunksParams): TextureHandle | null;
109
117
 
110
118
  export { type ChunksParams, type CrosshatchParams, type DotsParams, type HatchParams, type TileGeometry, type TileShape, chunks, crosshatch, dots, drawTileShapes, hatch, tileGeometry, tileSize };
@@ -1,3 +1,3 @@
1
- export { chunks, crosshatch, dots, drawTileShapes, hatch, tileGeometry, tileSize } from './chunk-IO5Z75X4.js';
1
+ export { chunks, crosshatch, dots, drawTileShapes, hatch, tileGeometry, tileSize } from './chunk-HGF5X6MZ.js';
2
2
  //# sourceMappingURL=patterns-builtin.js.map
3
3
  //# sourceMappingURL=patterns-builtin.js.map
@@ -1,6 +1,6 @@
1
- import { c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior, d as PointSnapFrame, M as ModifierState } from './types-Ct4n0Z38.js';
2
- import { B as Bounds, P as PoseProjection } from './geometry-CnISZ11w.js';
3
- import { D as DebugSink } from './types-Dtxe7jTS.js';
1
+ import { c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior, d as PointSnapFrame, M as ModifierState } from './types-ByZxoD6P.js';
2
+ import { B as Bounds, P as PoseProjection } from './geometry-5X6TrAkX.js';
3
+ import { D as DebugSink } from './types-BHK2dkMu.js';
4
4
 
5
5
  /** Corner resize-handle: world-space center plus the anchor that pins the opposite corner during resize. */
6
6
  interface CornerHandle {
@@ -71,6 +71,8 @@ declare function fixedCornerOf(bounds: Bounds, anchor: ResizeAnchor): {
71
71
  * Consumers should import from here directly; `resize.ts` re-exports the
72
72
  * same symbol for back-compat. */
73
73
 
74
+ /** Options for the `resize` action: how the pose projects to and from a
75
+ * bounding box, and the constraints applied to that box during the drag. */
74
76
  interface UseResizeOptions<TPose> {
75
77
  /** Behaviors are rect-typed: they read/write `{x,y,width,height}`. When
76
78
  * `TPose` is non-rect, pass `geometry` to project pose↔bounds; behaviors
@@ -125,6 +127,10 @@ interface UseResizeOptions<TPose> {
125
127
  resizable?: (id: string) => boolean;
126
128
  }
127
129
 
130
+ /** Resize behavior that snaps one reference point of the resize — the dragged
131
+ * corner, the fixed corner, or the center, per `frame` — to a grid, moving
132
+ * the whole pose by the same delta. Unlike the bounds-level `snapToGrid`,
133
+ * this preserves the node's dimensions. */
128
134
  declare function pointSnapToGrid<TPose extends ResizePose>(args: {
129
135
  spacing: number;
130
136
  frame?: PointSnapFrame;
@@ -1,18 +1,18 @@
1
- import { N as NodeId, R as RectPose, S as Scene } from './types-Kh_osAq9.js';
2
- import { M as ModifierState, A as ActionBehavior, c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior } from './types-Ct4n0Z38.js';
1
+ import { N as NodeId, R as RectPose, S as Scene } from './types-vqxpCFVp.js';
2
+ import { M as ModifierState, A as ActionBehavior, c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior } from './types-ByZxoD6P.js';
3
3
  import { V as View } from './view-DSQgxBJB.js';
4
4
  import { CapabilityTag } from '@weasel-js/modes';
5
5
  import * as React from 'react';
6
6
  import { MutableRefObject, ReactNode, ReactElement } from 'react';
7
7
  import { GestureSpec, IngestItem, InputEvent } from '@weasel-js/gestures';
8
- import { B as Bounds, P as PoseProjection } from './geometry-CnISZ11w.js';
8
+ import { B as Bounds, P as PoseProjection } from './geometry-5X6TrAkX.js';
9
9
  import { F as FillStyle, S as Stroke } from './paint-types-CnLIzqq1.js';
10
- import { D as DrawCommand } from './DrawCommand-DCmiNkBj.js';
10
+ import { D as DrawCommand } from './DrawCommand-BbPrSTra.js';
11
11
  import * as react_jsx_runtime from 'react/jsx-runtime';
12
12
  import { P as Path } from './path-B6MMiodD.js';
13
13
  import { Op, History } from '@weasel-js/history';
14
- import { L as LayoutStrategy, I as InsertAdapter } from './types-Ch0Goo-j.js';
15
- import { D as DebugSink } from './types-Dtxe7jTS.js';
14
+ import { L as LayoutStrategy, I as InsertAdapter } from './types-DpQ0cWYC.js';
15
+ import { D as DebugSink } from './types-BHK2dkMu.js';
16
16
  import { Mat3 } from '@weasel-js/geom';
17
17
 
18
18
  /**
@@ -455,6 +455,8 @@ interface RuleCtx {
455
455
  * an absent profile is behavior-preserving by construction. */
456
456
  readonly device?: DeviceProfile;
457
457
  }
458
+ /** The live state a `RuleCtx` is assembled from — the chrome context plus
459
+ * what the active mode allows. */
458
460
  interface BuildRuleCtxArgs {
459
461
  focused: boolean;
460
462
  selection: readonly NodeId[];
@@ -475,6 +477,8 @@ interface BuildRuleCtxArgs {
475
477
  /** Optional — omitted means {@link DEFAULT_DEVICE_PROFILE}. */
476
478
  device?: DeviceProfile;
477
479
  }
480
+ /** Gather the current canvas and mode state into the context that action
481
+ * eligibility and chrome-visibility rules are evaluated against. */
478
482
  declare function buildRuleCtx(args: BuildRuleCtxArgs): RuleCtx;
479
483
 
480
484
  /**
@@ -535,6 +539,7 @@ type Rule = Selector | {
535
539
  };
536
540
  /** Constant rules. Kept here so they have a single source. */
537
541
  declare const ALWAYS: Rule;
542
+ /** A rule that never passes. `any` of nothing is false. */
538
543
  declare const NEVER: Rule;
539
544
  /**
540
545
  * Render a {@link Rule} as a short human-readable string, for inspectors and
@@ -551,6 +556,8 @@ declare const NEVER: Rule;
551
556
  * on a cyclic value and renders the `when` arm as a useless `{}`.
552
557
  */
553
558
  declare function describeRule(rule: Rule): string;
559
+ /** Evaluate a rule against a context. Pure, and cheap enough to run per
560
+ * frame for every piece of chrome. */
554
561
  declare function evaluate(rule: Rule, ctx: RuleCtx): boolean;
555
562
 
556
563
  /**
@@ -1008,6 +1015,9 @@ type Invoker = ImmediateInvoker | OngoingInvoker;
1008
1015
  * See `docs/superpowers/specs/2026-05-16-registry-unification-design.md`.
1009
1016
  */
1010
1017
 
1018
+ /** An interaction: a gesture spec composed with the id of the action it
1019
+ * invokes. Tools declare arrays of these; the dispatcher matches an incoming
1020
+ * input event against them and runs the winner's action. */
1011
1021
  interface GestureBinding {
1012
1022
  spec: GestureSpec;
1013
1023
  actionId: string;
@@ -1169,6 +1179,15 @@ type BooleanOpResult = {
1169
1179
  kind: 'noop';
1170
1180
  reason: 'no-paths' | 'too-few-for-subtract' | 'empty-result';
1171
1181
  };
1182
+ /**
1183
+ * Run one Boolean operation over the selected paths and commit the result as a
1184
+ * single undoable batch.
1185
+ *
1186
+ * Operands are ordered back-to-front, which is what makes `subtract` mean
1187
+ * "everything in front removed from the backmost shape". Returns without
1188
+ * mutating anything when the selection holds no paths, or too few for the
1189
+ * requested operation.
1190
+ */
1172
1191
  declare function applyBooleanOp(adapter: BooleansAdapter, op: BooleanOp): BooleanOpResult;
1173
1192
 
1174
1193
  /**
@@ -1291,6 +1310,9 @@ interface IngestCtx {
1291
1310
  /** Full action-deps bag, for consumer handlers that need more. */
1292
1311
  deps: ActionDeps;
1293
1312
  }
1313
+ /** A handler for content arriving by paste, drop or file picker. Handlers are
1314
+ * matched by MIME glob or predicate and run highest-priority first; the kit's
1315
+ * own register at a low priority so a consumer's handler wins by default. */
1294
1316
  interface ContentHandlerEntry {
1295
1317
  /** Stable identifier — used for unregistration and debugging
1296
1318
  * (`'kit:image'`, `'app:csv'`). */
@@ -1357,6 +1379,9 @@ declare function PointerContextProvider({ children }: {
1357
1379
  * no provider is in scope. */
1358
1380
  declare function usePointerContext(): PointerContextValue | null;
1359
1381
 
1382
+ /** Which tool is active, plus the stack of tools temporarily held active by a
1383
+ * hotkey (space-for-hand and the like). The dispatcher reads this to decide
1384
+ * whose bindings are in scope. */
1360
1385
  interface ActiveToolContextValue {
1361
1386
  active: string;
1362
1387
  hotkeyStack: string[];
@@ -1364,11 +1389,15 @@ interface ActiveToolContextValue {
1364
1389
  pushHotkey(id: string): void;
1365
1390
  popHotkey(): void;
1366
1391
  }
1392
+ /** Props for `<ActiveToolContextProvider>`. */
1367
1393
  interface ActiveToolContextProviderProps {
1368
1394
  children: ReactNode;
1369
1395
  initialActive?: string;
1370
1396
  }
1397
+ /** Provides active-tool state for a canvas. `<SceneCanvas>` mounts one. */
1371
1398
  declare function ActiveToolContextProvider({ children, initialActive, }: ActiveToolContextProviderProps): react_jsx_runtime.JSX.Element;
1399
+ /** The active-tool state in scope. Throws outside a provider; use
1400
+ * `useActiveToolContextOptional` where one is not guaranteed. */
1372
1401
  declare function useActiveToolContext(): ActiveToolContextValue;
1373
1402
  /**
1374
1403
  * Like `useActiveToolContext`, but returns `null` when no
@@ -1600,6 +1629,8 @@ type NodeAtPointDep = (point: {
1600
1629
  x: number;
1601
1630
  y: number;
1602
1631
  }, exclude?: Iterable<NodeId>) => NodeId | null;
1632
+ /** What an area-selecting action needs: a way to ask what a region covers,
1633
+ * and a way to read and replace the selection. */
1603
1634
  interface AreaSelectDep {
1604
1635
  /** Return ids of all scene nodes whose AABB overlaps `bounds`. */
1605
1636
  hitTestArea(bounds: {
@@ -1938,6 +1969,14 @@ interface ResizePolicy<TPose> {
1938
1969
  interface LayoutDep {
1939
1970
  getLayout(containerId: string): LayoutStrategy<unknown> | null;
1940
1971
  }
1972
+ /**
1973
+ * The names an action may declare in `requires`, and what each resolves to.
1974
+ *
1975
+ * This is the whole vocabulary of things an action can reach — selection,
1976
+ * scene, view, history, and the rest. Consumers add their own entries by
1977
+ * augmenting the interface (`declare module '@weasel-js/core'`), which is what
1978
+ * makes a custom dep name type-check in `requires` and in the deps bag.
1979
+ */
1941
1980
  interface DepSchema {
1942
1981
  /** Kit selection state — ids of currently selected nodes. */
1943
1982
  selection: SelectionApi;
@@ -2124,13 +2163,19 @@ interface DepSchema {
2124
2163
  */
2125
2164
  type DepName = keyof DepSchema;
2126
2165
 
2166
+ /** Holds the live sources an action's declared dependencies resolve to.
2167
+ * Sources are thunks, read at invocation time, so an action never captures
2168
+ * stale state. */
2127
2169
  interface DepRegistry {
2128
2170
  register<K extends DepName>(name: K, source: () => DepSchema[K]): () => void;
2129
2171
  get<K extends DepName>(name: K): DepSchema[K] | undefined;
2130
2172
  }
2173
+ /** Provides the dep registry for a canvas. `<SceneCanvas>` mounts one; a
2174
+ * consumer registering its own dep sources must be inside it. */
2131
2175
  declare function DepRegistryProvider({ children }: {
2132
2176
  children: ReactNode;
2133
2177
  }): react_jsx_runtime.JSX.Element;
2178
+ /** The dep registry in scope. Throws outside a `<DepRegistryProvider>`. */
2134
2179
  declare function useDepRegistry(): DepRegistry;
2135
2180
  /**
2136
2181
  * Like `useDepRegistry`, but returns `null` when no `<DepRegistryProvider>` is
@@ -2207,6 +2252,15 @@ interface ToolKeybinding {
2207
2252
  */
2208
2253
  shift?: boolean | 'optional';
2209
2254
  }
2255
+ /**
2256
+ * What a tool declares.
2257
+ *
2258
+ * A tool is a declarative shell, not an event handler: it names the gestures
2259
+ * it responds to and, for each, the action to invoke. The dispatcher owns the
2260
+ * gesture, and the action owns the preview and the commit — so a tool
2261
+ * definition is mostly `bindings`, plus presentation and any actions the tool
2262
+ * itself introduces.
2263
+ */
2210
2264
  interface ToolDef<TScratch = void> {
2211
2265
  id: string;
2212
2266
  /** Capability tags for modality eligibility. Forwarded onto `Tool.capabilities`. */
@@ -2411,7 +2465,11 @@ type AnyTool = Tool<any>;
2411
2465
  * binding-scope / matchBest logic on top.
2412
2466
  */
2413
2467
 
2468
+ /** Where a binding came from, which is also its priority: a held hotkey beats
2469
+ * the active tool, which beats bindings that are always in scope. */
2414
2470
  type BindingScope = 'ambient' | 'active' | 'hotkey';
2471
+ /** A binding paired with where it came from, ready to be matched against an
2472
+ * event. */
2415
2473
  interface ScopedBinding {
2416
2474
  binding: GestureBinding;
2417
2475
  scope: BindingScope;
@@ -2420,6 +2478,7 @@ interface ScopedBinding {
2420
2478
  * Action with no owning tool. */
2421
2479
  ownerToolId: string | null;
2422
2480
  }
2481
+ /** The binding that won a match. */
2423
2482
  interface MatchResult {
2424
2483
  binding: GestureBinding;
2425
2484
  scope: BindingScope;
@@ -2479,6 +2538,11 @@ declare function specificity(spec: GestureSpec): readonly [number, number, numbe
2479
2538
  * the misconfiguration at dev time.
2480
2539
  */
2481
2540
 
2541
+ /** Everything the dispatcher must consult to route one input event: the
2542
+ * registered actions and their deps, which tool is active, which hotkeys are
2543
+ * held, and — optionally — the chrome state that action eligibility rules are
2544
+ * evaluated against. Rebuilt per event rather than held, so the dispatcher
2545
+ * itself stays stateless apart from in-flight gestures. */
2482
2546
  interface DispatcherContext {
2483
2547
  /** All registered actions; the dispatcher walks `.defaultBinding` for ambient bindings. */
2484
2548
  actions: ActionsRegistry;
@@ -2584,6 +2648,15 @@ interface ResolveAllOptions {
2584
2648
  */
2585
2649
  evaluateShadowed?: boolean;
2586
2650
  }
2651
+ /**
2652
+ * Routes input events to actions.
2653
+ *
2654
+ * For each event it assembles the bindings in scope (hotkey, then active tool,
2655
+ * then ambient), matches them in specificity order, filters by eligibility and
2656
+ * each action's `enabled` gate, and invokes the first survivor. Ongoing
2657
+ * actions — anything that runs across a drag — are kept in flight here and
2658
+ * pumped with subsequent moves until the gesture ends.
2659
+ */
2587
2660
  interface Dispatcher {
2588
2661
  /**
2589
2662
  * Route an input event through the binding pipeline. Returns `'handled'`
@@ -2720,6 +2793,8 @@ interface Dispatcher {
2720
2793
  */
2721
2794
  beginUiOngoing(actionId: string, deps: ActionDeps, params?: Record<string, unknown>): UiOngoingControl | null;
2722
2795
  }
2796
+ /** Build a dispatcher. `getAction` overrides how action ids are resolved;
2797
+ * by default the `DispatcherContext`'s registry is used. */
2723
2798
  declare function createDispatcher(opts?: {
2724
2799
  getAction?: (id: string) => Action | undefined;
2725
2800
  }): Dispatcher;
@@ -2873,6 +2948,7 @@ declare const ActionDisabledReason: {
2873
2948
  /** Sentinel: the predicate threw. Surfaced by `evaluateEnabled`'s catch. */
2874
2949
  readonly PredicateThrew: "predicate-threw";
2875
2950
  };
2951
+ /** Why an action is unavailable right now. */
2876
2952
  type ActionDisabledReason = (typeof ActionDisabledReason)[keyof typeof ActionDisabledReason];
2877
2953
  /**
2878
2954
  * @experimental
@@ -2882,6 +2958,14 @@ interface ActionEnabledResult {
2882
2958
  enabled: boolean;
2883
2959
  reason?: ActionDisabledReason;
2884
2960
  }
2961
+ /**
2962
+ * @experimental
2963
+ * Safely evaluate an action's `enabled` predicate. Returns `{enabled: true}`
2964
+ * when no predicate is supplied. Catches throws and treats them as disabled
2965
+ * with reason `'(predicate threw)'`. In dev mode, warns once per action id
2966
+ * when a single call exceeds 4ms (single frame at 240fps — generous; real
2967
+ * predicates should be sub-millisecond).
2968
+ */
2885
2969
  declare function evaluateEnabled(action: Action, deps?: ActionDeps): ActionEnabledResult;
2886
2970
  /**
2887
2971
  * @experimental