@weasel-js/core 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +937 -2202
- package/README.md +118 -75
- package/dist/{autoPoseDescriptor-DF1SnnSx.d.ts → autoPoseDescriptor-CvjflWJK.d.ts} +29 -26
- package/dist/{chunk-2VXGHUVL.js → chunk-BDWAA634.js} +4 -22
- package/dist/chunk-BDWAA634.js.map +1 -0
- package/dist/{chunk-R3AWPTLZ.js → chunk-MG7OXCAI.js} +2760 -4491
- package/dist/chunk-MG7OXCAI.js.map +1 -0
- package/dist/{chunk-PRGBGMH3.js → chunk-MQI4PIX3.js} +3 -3
- package/dist/chunk-MQI4PIX3.js.map +1 -0
- package/dist/{chunk-WPM42WJP.js → chunk-UCPV7JXC.js} +201 -256
- package/dist/chunk-UCPV7JXC.js.map +1 -0
- package/dist/clipboard.d.ts +2 -3
- package/dist/clone.d.ts +3 -2
- package/dist/depSchema-nMqj_qTM.d.ts +3490 -0
- package/dist/{grid-0Pbn5B2C.d.ts → grid-BrIa38gG.d.ts} +7 -10
- package/dist/index.d.ts +1996 -1229
- package/dist/index.js +4 -5
- package/dist/insert.d.ts +4 -4
- package/dist/insert.js +1 -1
- package/dist/move.d.ts +5 -6
- package/dist/move.js +3 -6
- package/dist/move.js.map +1 -1
- package/dist/{options-DbYLImvq.d.ts → options-BDyCnrp8.d.ts} +3 -2
- package/dist/poseDescriptor-CGOgIgf8.d.ts +134 -0
- package/dist/renderer.d.ts +10 -4
- package/dist/renderer.js +4 -5
- package/dist/resize.d.ts +10 -12
- package/dist/resize.js +2 -2
- package/dist/routing.d.ts +1 -142
- package/dist/routing.js +1 -1
- package/dist/routing.js.map +1 -1
- package/dist/{types-ei3UMl9R.d.ts → types-DMyo7dnM.d.ts} +12 -41
- package/dist/{types-DEALFt5F.d.ts → types-DtjCJA5r.d.ts} +9 -3
- package/package.json +13 -10
- package/dist/DrawCommand-CD-ug3d9.d.ts +0 -332
- package/dist/builtins-BXFBXegF.d.ts +0 -840
- package/dist/chunk-2VXGHUVL.js.map +0 -1
- package/dist/chunk-BL65SHCX.js +0 -573
- package/dist/chunk-BL65SHCX.js.map +0 -1
- package/dist/chunk-PRGBGMH3.js.map +0 -1
- package/dist/chunk-R3AWPTLZ.js.map +0 -1
- package/dist/chunk-WPM42WJP.js.map +0 -1
- package/dist/geometry-6fCNhAux.d.ts +0 -114
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/registry-BY-wI9gm.d.ts +0 -4003
- package/dist/types-BHK2dkMu.d.ts +0 -172
- package/dist/types-bcc7jcUy.d.ts +0 -594
- package/dist/view-DSQgxBJB.d.ts +0 -63
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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,
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
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_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, 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, 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, aabbCenter, actionBindings, actionIs, actionShortcuts, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, asPaint, 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, composeRigidPose, 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, createPoseFeed, createPoseOverrides, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createSimulation, createTextLayer, createVelocityTracker, createViewResolver, createViewportLayer, cubicBezierEasing, 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, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, 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, isPatternSpec, 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, 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, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointAlongPath, pointInRotatedRect, pointInTextPose, poseRotationOf, prefUnit, 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, resolveOverlays, resolveParams, resolvePatternSpec, resolvePreviews, resolveRuns, resolveSkeleton, resolveStrokeWidth, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sampleTrack, sceneFromJSON, sceneNodeClientRect, sceneSelectionStore, sceneToAdapter, scopeBindings, scratchKey, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, setScratch, shapeCoversPoint, sliceAction, snapPoint, solid, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, strokeDashStyleOf, strokeInsets, strokeOf, strokeWith, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textCommandFromPose, textCommandFromRuns, textLineBoxes, textPoseLayoutInput, tileGrid, 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, useKeybindings, useLassoTool, useLineTool, useNodeOverlayFrame, useOptionalActiveToolContext, useOptionalDepRegistry, usePenTool, usePencilTool, usePinchGesture, usePointerStylus, usePolygonTool, usePoseCompositionDepSource, usePoseDescriptorDepSource, usePoseRun, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useVisibleRaf, verticalAlignOffset, viewToMat3, viewToTransform, viewZoom, viewportDragPanAction, viewportWheelPanAction, viewportZoomAction, viewportsAt, vignette, wheelPan, wheelZoom, wheelZoomFactor, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-MG7OXCAI.js';
|
|
2
|
+
export { createReparentOp, createTransformOp, snap } from './chunk-BDWAA634.js';
|
|
3
|
+
export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-MQI4PIX3.js';
|
|
4
|
+
export { ANGLE_RADIANS, 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, axisAlignedBounds, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, isPathLike, isRectPose, linePath, pathCommandCoordCount, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, polylineFromPoints, poseDescriptorForNode, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, translatePoseViaDescriptor, unionAABB, unionBounds, visualBoundsViaDescriptor, withinPxBox, withinPxRadius } from './chunk-UCPV7JXC.js';
|
|
6
5
|
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
6
|
export { cloneByAltDrag } from './chunk-D4AAWR64.js';
|
|
8
7
|
export { createSetSelectionOp } from './chunk-DOBSZOPR.js';
|
package/dist/insert.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { U as UseInsertOptions } from './options-
|
|
2
|
-
import {
|
|
1
|
+
export { U as UseInsertOptions } from './options-BDyCnrp8.js';
|
|
2
|
+
import { I as InsertBehavior } from './types-DMyo7dnM.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-
|
|
6
|
+
import './types-DtjCJA5r.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
package/dist/move.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { O as OriginProjection } from './grid-
|
|
2
|
-
export { U as UseMoveOptions } from './grid-
|
|
3
|
-
import { M as
|
|
4
|
-
import {
|
|
1
|
+
import { O as OriginProjection } from './grid-BrIa38gG.js';
|
|
2
|
+
export { U as UseMoveOptions } from './grid-BrIa38gG.js';
|
|
3
|
+
import { M as MoveBehavior } from './types-DMyo7dnM.js';
|
|
4
|
+
import { ModifierState, View } from '@weasel-js/routing';
|
|
5
|
+
import { S as SnapTarget } from './types-DtjCJA5r.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,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-
|
|
1
|
+
import { snap, createTransformOp, createReparentOp } from './chunk-BDWAA634.js';
|
|
2
|
+
import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-UCPV7JXC.js';
|
|
3
3
|
import { createDeleteOp } from './chunk-4RJP2N2L.js';
|
|
4
|
+
import { scratchKey, getScratch, setScratch } from '@weasel-js/routing';
|
|
4
5
|
|
|
5
6
|
// src/interactions/actions/move/behaviors/snapToGrid.ts
|
|
6
7
|
function snapToGrid(args) {
|
|
7
8
|
return snap(gridSnapStrategy(args.spacing), { bypassKey: args.bypassKey });
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
// src/interactions/actions/move/behaviors/snapToContainer.ts
|
|
11
10
|
var STATE = scratchKey("snapToContainer");
|
|
12
11
|
function getState(ctx) {
|
|
13
12
|
let s = getScratch(ctx.scratch, STATE);
|
|
@@ -84,8 +83,6 @@ function snapToContainer(args) {
|
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
// src/interactions/actions/move/behaviors/snapBackOrDelete.ts
|
|
89
86
|
var SNAPSHOTS = scratchKey("snapBackOrDelete.snapshots");
|
|
90
87
|
var INDEXES = scratchKey("snapBackOrDelete.indexes");
|
|
91
88
|
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,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,GAA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AAI,EAAA,CAAG,CAAA;AACrB,MAAA,MAAM,MAAA,GAAS,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA,IAAM,EAAA;AACpC,MAAA,IAAI,MAAA,EAAQ;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;AAIA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,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 '../../../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,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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A,CAAG,CAAA,GAAI,EAAA,CAAG,CAAA;AACrB,MAAA,MAAM,MAAA,GAAS,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA,IAAM,EAAA;AACpC,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,IAAI,kBAAkB,QAAA,EAAU;AAC9B,QAAA,MAAM,SAAA,GAAYC,UAAAA,CAAW,GAAA,CAAI,OAAA,EAAS,SAAS,CAAA;AACnD,QAAA,MAAM,OAAA,GAAUA,UAAAA,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;AAIA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,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
|
|
2
|
+
import { I as InsertBehavior } from './types-DMyo7dnM.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:
|
|
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
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Bounds } from '@weasel-js/routing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Path data model. Vector-graphics primitive used kit-wide as the canonical
|
|
5
|
+
* shape (replacing per-shape ad-hoc poses). SVG-style command stream so we
|
|
6
|
+
* cover lines, polygons, beziers, and multi-contour shapes (think the inner
|
|
7
|
+
* hole of an "O") under one type.
|
|
8
|
+
*
|
|
9
|
+
* Storage: command codes in a `Uint8Array`, parameters in a `Float32Array`.
|
|
10
|
+
* Each command consumes a fixed number of float coords from the parameter
|
|
11
|
+
* array; the parser walks both arrays in lockstep. This keeps interaction
|
|
12
|
+
* hot loops monomorphic and keeps GC pressure low under heavy edits.
|
|
13
|
+
*
|
|
14
|
+
* Two path subtypes are distinguished at the type level so common-case
|
|
15
|
+
* machinery (selection AABBs, area-select intersection, hit-testing rect
|
|
16
|
+
* silhouettes) can short-circuit on `RectPath` without paying the polygon
|
|
17
|
+
* kernel cost. Polymorphic kernels accept either via the `Path` union and
|
|
18
|
+
* dispatch on `kind`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Fill rule used by polygon path hit-testing and `ctx.fill()`. */
|
|
22
|
+
type PathFillRule = 'nonzero' | 'evenodd';
|
|
23
|
+
/**
|
|
24
|
+
* Polygon path with arbitrary contours and optional bezier segments.
|
|
25
|
+
* Multi-contour: each `M` opens a new subpath; `Z` closes the current one.
|
|
26
|
+
* Open subpaths (no `Z`) render as polylines and don't contribute to fills.
|
|
27
|
+
*/
|
|
28
|
+
interface PolygonPath {
|
|
29
|
+
kind: 'polygon';
|
|
30
|
+
commands: Uint8Array;
|
|
31
|
+
coords: Float32Array;
|
|
32
|
+
fillRule: PathFillRule;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Axis-aligned rectangle. Fast path for the (very common) case where the
|
|
36
|
+
* shape is just a rect — preserves O(1) bounds and hit-test, avoids the
|
|
37
|
+
* polygon kernel entirely. Promote to `PolygonPath` only when the shape
|
|
38
|
+
* grows beyond what a rect can express.
|
|
39
|
+
*/
|
|
40
|
+
interface RectPath {
|
|
41
|
+
kind: 'rect';
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
}
|
|
47
|
+
/** Canonical path shape — either an axis-aligned rect (fast path) or a polygon command stream. */
|
|
48
|
+
type Path = PolygonPath | RectPath;
|
|
49
|
+
|
|
50
|
+
/** `Bounds` with a required rotation angle (radians). Pivot is the AABB
|
|
51
|
+
* center of the unrotated `{x, y, width, height}`. */
|
|
52
|
+
interface RotatedPose extends Bounds {
|
|
53
|
+
rotation: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bridges arbitrary `TPose` shapes into the resize hook's bounds-driven math.
|
|
57
|
+
* The hook reads bounds via `getBounds`, runs anchor-relative math on those
|
|
58
|
+
* bounds, then asks `remapBounds` to project the result back into TPose.
|
|
59
|
+
*
|
|
60
|
+
* `remapBounds(pose, src, dst)` is a single operation that subsumes both
|
|
61
|
+
* "set my own AABB to dst" (single-leaf resize) and "scale me as a leaf
|
|
62
|
+
* inside parent's src→dst rect" (group resize) — they're the same affine
|
|
63
|
+
* map. For rect-shaped poses the default geometry interprets the pose as
|
|
64
|
+
* its own bounds; for Path or polygon poses the consumer supplies a
|
|
65
|
+
* projection that knows how to read and rewrite the underlying geometry.
|
|
66
|
+
*/
|
|
67
|
+
interface PoseDescriptor<TPose, TNode = unknown> {
|
|
68
|
+
getBounds(pose: TPose): Bounds;
|
|
69
|
+
remapBounds(pose: TPose, src: Bounds, dst: Bounds): TPose;
|
|
70
|
+
/** A pose occupying `bounds`, of the same kind as `template`. Unlike
|
|
71
|
+
* `remapBounds`, the result carries none of the template's shape. */
|
|
72
|
+
fromBounds(bounds: Bounds, template: TPose): TPose;
|
|
73
|
+
/** Translate the pose by (dx, dy). Optional — when omitted, callers fall
|
|
74
|
+
* back to a translation derived from `remapBounds` (origin shifted, no
|
|
75
|
+
* scale). Path-shaped poses should provide this for performance. */
|
|
76
|
+
translate?(pose: TPose, dx: number, dy: number): TPose;
|
|
77
|
+
/** True iff any portion of the pose's geometry intersects `rect`. Optional
|
|
78
|
+
* — when omitted, area-select and similar callers test against `getBounds`
|
|
79
|
+
* AABB (looser, but correct for axis-aligned rect poses). */
|
|
80
|
+
intersectsRect?(pose: TPose, rect: Bounds): boolean;
|
|
81
|
+
/** Interpolate between two poses. Optional — animation helpers fall back to
|
|
82
|
+
* rect-shape lerp when omitted (which fails for non-rect poses). */
|
|
83
|
+
lerp?(a: TPose, b: TPose, t: number): TPose;
|
|
84
|
+
/** Read the pose's rotation in radians. Pivot is the AABB center
|
|
85
|
+
* (`getBounds(pose)` center). Default 0 when omitted — descriptor
|
|
86
|
+
* declares "this pose has no rotation." When supplied and non-zero,
|
|
87
|
+
* `useResize` projects the drag delta into the leaf's local frame,
|
|
88
|
+
* runs anchor math there, and translates the resulting pose so the
|
|
89
|
+
* diagonally opposite world-space corner is pinned. */
|
|
90
|
+
getRotation?(pose: TPose): number;
|
|
91
|
+
/** True iff this pose shape can carry a rotation. Consulted by the
|
|
92
|
+
* rotation affordance to decide whether to render the rotate cursor /
|
|
93
|
+
* drag-band over a selection. When omitted, the kit assumes `true` for
|
|
94
|
+
* back-compat — descriptors whose poses lack `x/y/width/height/rotation`
|
|
95
|
+
* fields (e.g. polygon Paths) should return `false` so the affordance
|
|
96
|
+
* hides instead of exposing a non-functional rotate cursor. */
|
|
97
|
+
supportsRotation?(pose: TPose): boolean;
|
|
98
|
+
/** Write a rotation (radians) into the pose, bounds unchanged. Absent means
|
|
99
|
+
* the pose cannot carry one, and the rotate action leaves it alone. */
|
|
100
|
+
withRotation?(pose: TPose, rotation: number): TPose;
|
|
101
|
+
/**
|
|
102
|
+
* A descriptor specialized to one node. Every other method here sees only
|
|
103
|
+
* the pose, so shapes sharing a pose type — a sphere and a box both posed by
|
|
104
|
+
* position/rotation/scale — are indistinguishable to them. Implement this to
|
|
105
|
+
* read `node.data` once and hand back a descriptor that knows which shape it
|
|
106
|
+
* is describing.
|
|
107
|
+
*
|
|
108
|
+
* Callers reach it through {@link poseDescriptorForNode}, at whichever site
|
|
109
|
+
* holds the node; the specialized descriptor then travels into the bounds and
|
|
110
|
+
* hit-test helpers in place of this one. Sites with only an id keep using the
|
|
111
|
+
* unspecialized descriptor, which is why this is optional on both ends.
|
|
112
|
+
*/
|
|
113
|
+
forNode?(node: TNode): PoseDescriptor<TPose, TNode>;
|
|
114
|
+
}
|
|
115
|
+
/** The descriptor `node` should be read through: its own specialization when
|
|
116
|
+
* it declares one, and otherwise the descriptor unchanged. */
|
|
117
|
+
declare function poseDescriptorForNode<TPose, TNode>(descriptor: PoseDescriptor<TPose, TNode>, node: TNode): PoseDescriptor<TPose, TNode>;
|
|
118
|
+
/** Identity geometry for `TPose extends Bounds`. Treats the pose as its
|
|
119
|
+
* own bounds and remaps via affine scale against `src`/`dst`. */
|
|
120
|
+
declare const RECT_POSE_DESCRIPTOR: PoseDescriptor<Bounds>;
|
|
121
|
+
/** Identity geometry for `RotatedPose`. Inherits rect-shape projection
|
|
122
|
+
* from `RECT_POSE_DESCRIPTOR` (the `RotatedPose extends Bounds`
|
|
123
|
+
* subtype lets the rect descriptor's methods apply directly; `remapBounds`
|
|
124
|
+
* preserves the `rotation` field via `...p` spread). Adds `getRotation` so
|
|
125
|
+
* `useResize` knows to take the rotation-aware math path. */
|
|
126
|
+
declare const ROTATED_POSE_DESCRIPTOR: PoseDescriptor<RotatedPose>;
|
|
127
|
+
/** The pose's visual bounds: its frame expanded to cover the rotated
|
|
128
|
+
* rectangle, so a turned shape reports the extent of its ink. */
|
|
129
|
+
declare function visualBoundsViaDescriptor<TPose>(pose: TPose, geometry: PoseDescriptor<TPose>): Bounds;
|
|
130
|
+
/** Translate through `geometry.translate`, or via `remapBounds` onto a shifted
|
|
131
|
+
* copy of the pose's own bounds when the descriptor has none. */
|
|
132
|
+
declare function translatePoseViaDescriptor<TPose>(pose: TPose, dx: number, dy: number, geometry: PoseDescriptor<TPose>): TPose;
|
|
133
|
+
|
|
134
|
+
export { type PoseDescriptor as P, RECT_POSE_DESCRIPTOR as R, type Path as a, ROTATED_POSE_DESCRIPTOR as b, type PolygonPath as c, type RotatedPose as d, type PathFillRule as e, type RectPath as f, poseDescriptorForNode as p, translatePoseViaDescriptor as t, visualBoundsViaDescriptor as v };
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { M as Mesh } from './
|
|
2
|
-
export { I as IDENTITY_COLOR_MATRIX, a as ImageMinification, R as RenderTarget, S as ShaderCompileError,
|
|
3
|
-
|
|
4
|
-
import { P as Path } from './path-JEV2c5If.js';
|
|
1
|
+
import { M as Mesh } from './depSchema-nMqj_qTM.js';
|
|
2
|
+
export { D as DrawCommand, E as Effect, G as GroupDrawCommand, I as IDENTITY_COLOR_MATRIX, a as ImageDrawCommand, b as ImageMinification, c as Mat3, P as PathDrawCommand, R as RenderTarget, S as SPRITE_STRIDE, d as ShaderCompileError, e as ShaderDrawCommand, f as ShaderProgramHandle, g as ShaderUniform, h as SolidPaint, i as SpriteSheet, j as SpritesDrawCommand, k as StrokeOptions, T as TextDrawCommand, V as ViewLike, W as WeaselRenderer, l as WeaselRendererOptions, m as blur, n as buildGradientRamp, o as frameRect, p as mat3, r as registerEffect, q as registerProgram, t as tessellateStroke, v as viewToMat3, s as vignette } from './depSchema-nMqj_qTM.js';
|
|
3
|
+
import { a as Path } from './poseDescriptor-CGOgIgf8.js';
|
|
5
4
|
export { canQueryLocalFonts, enableLocalFontOutlines, hasFontOutlines, isCanvasFont, listFontOutlines, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, subscribeGlyphReady, unregisterCanvasFont, unregisterFontOutlines } from '@weasel-js/font';
|
|
6
5
|
import { TextureHandle } from '@weasel-js/paint';
|
|
7
6
|
export { TextureHandle } from '@weasel-js/paint';
|
|
8
7
|
import '@weasel-js/text';
|
|
8
|
+
import '@weasel-js/history';
|
|
9
|
+
import '@weasel-js/routing';
|
|
10
|
+
import './types-DtjCJA5r.js';
|
|
11
|
+
import 'react';
|
|
12
|
+
import '@weasel-js/routing/react';
|
|
13
|
+
import './types-DMyo7dnM.js';
|
|
14
|
+
import '@weasel-js/geom';
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* registerTexture — accepts an image source, assigns an opaque id, stores in
|
package/dist/renderer.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export { EFFECT_KIT_UNIFORMS, EFFECT_VERT_SRC, IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, SPRITE_STRIDE, ShaderCompileError, WeaselRenderer, blur, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, frameRect, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerEffect, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3, vignette } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-WPM42WJP.js';
|
|
1
|
+
export { EFFECT_KIT_UNIFORMS, EFFECT_VERT_SRC, IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, SPRITE_STRIDE, ShaderCompileError, WeaselRenderer, blur, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, frameRect, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerEffect, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3, vignette } from './chunk-MG7OXCAI.js';
|
|
2
|
+
import './chunk-BDWAA634.js';
|
|
3
|
+
import './chunk-MQI4PIX3.js';
|
|
4
|
+
import './chunk-UCPV7JXC.js';
|
|
6
5
|
import './chunk-T3UQ3F6R.js';
|
|
7
6
|
import './chunk-D4AAWR64.js';
|
|
8
7
|
import './chunk-DOBSZOPR.js';
|
package/dist/resize.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
export { A as AUTO_POSE_DESCRIPTOR, C as CORNER_ANCHORS, a as CornerAnchor, b as CornerHandle, U as UseResizeOptions, c as cornerPoint, d as cornerResizeHandles, f as fixedCornerOf, h as hitCornerHandle, i as isPathLike, p as pointSnapToGrid } from './autoPoseDescriptor-
|
|
2
|
-
export { P as
|
|
3
|
-
import {
|
|
1
|
+
export { A as AUTO_POSE_DESCRIPTOR, C as CORNER_ANCHORS, a as CornerAnchor, b as CornerHandle, U as UseResizeOptions, c as cornerPoint, d as cornerResizeHandles, f as fixedCornerOf, h as hitCornerHandle, i as isPathLike, e as isRectPose, p as pointSnapToGrid } from './autoPoseDescriptor-CvjflWJK.js';
|
|
2
|
+
export { P as PoseDescriptor, R as RECT_POSE_DESCRIPTOR, b as ROTATED_POSE_DESCRIPTOR, p as poseDescriptorForNode } from './poseDescriptor-CGOgIgf8.js';
|
|
3
|
+
import { B as BoundsConstraint } from './types-DMyo7dnM.js';
|
|
4
|
+
import { Bounds, ModifierState, View } from '@weasel-js/routing';
|
|
4
5
|
import { G as Guide } from './types-D2tTKEU0.js';
|
|
5
|
-
import { V as View } from './view-DSQgxBJB.js';
|
|
6
|
-
import './types-BHK2dkMu.js';
|
|
7
|
-
import './path-JEV2c5If.js';
|
|
8
6
|
import '@weasel-js/history';
|
|
9
|
-
import './types-
|
|
7
|
+
import './types-DtjCJA5r.js';
|
|
10
8
|
|
|
11
9
|
/** Resize constraint that stops a node shrinking past a minimum. The anchored
|
|
12
10
|
* edge stays put, so clamping pushes the dragged edge back rather than moving
|
|
13
11
|
* the node. */
|
|
14
|
-
declare function clampMinSize<TPose extends
|
|
12
|
+
declare function clampMinSize<TPose extends Bounds>(args: {
|
|
15
13
|
minWidth: number;
|
|
16
14
|
minHeight: number;
|
|
17
15
|
}): BoundsConstraint<TPose>;
|
|
@@ -38,7 +36,7 @@ type ModKey$2 = keyof ModifierState;
|
|
|
38
36
|
* anchoring at the origin's top edge (`y` stays at `origin.y`). Symmetric
|
|
39
37
|
* for `n` / `s`.
|
|
40
38
|
*/
|
|
41
|
-
declare function lockAspectWithModifier<TPose extends
|
|
39
|
+
declare function lockAspectWithModifier<TPose extends Bounds>(opts?: {
|
|
42
40
|
key?: ModKey$2;
|
|
43
41
|
}): BoundsConstraint<TPose>;
|
|
44
42
|
|
|
@@ -47,7 +45,7 @@ type ModKey$1 = keyof ModifierState;
|
|
|
47
45
|
* anchored ones where they are. By default a node already smaller than one
|
|
48
46
|
* grid cell on an axis is left unsnapped on that axis, so it stays resizable
|
|
49
47
|
* at sub-grid sizes. */
|
|
50
|
-
declare function snapToGrid<TPose extends
|
|
48
|
+
declare function snapToGrid<TPose extends Bounds>(args: {
|
|
51
49
|
spacing: number;
|
|
52
50
|
bypassKey?: ModKey$1;
|
|
53
51
|
suspendBelowDim?: boolean;
|
|
@@ -75,12 +73,12 @@ interface SnapToGuidesResizeArgs {
|
|
|
75
73
|
* edge — east when `anchor.x === 'min'` (west pinned), west when `'max'`.
|
|
76
74
|
* Likewise on Y for horizontal guides.
|
|
77
75
|
*/
|
|
78
|
-
declare function snapToGuides<TPose extends
|
|
76
|
+
declare function snapToGuides<TPose extends Bounds>(args: SnapToGuidesResizeArgs): BoundsConstraint<TPose>;
|
|
79
77
|
|
|
80
78
|
/** The kit's standard resize behaviors, applied when a consumer doesn't
|
|
81
79
|
* supply its own list: shift-drag locks the start pose's aspect ratio.
|
|
82
80
|
* Pass an explicit `behaviors: []` to opt out. Stateless, so one shared
|
|
83
81
|
* frozen instance is safe across every gesture. */
|
|
84
|
-
declare const DEFAULT_RESIZE_BEHAVIORS: readonly BoundsConstraint<
|
|
82
|
+
declare const DEFAULT_RESIZE_BEHAVIORS: readonly BoundsConstraint<Bounds>[];
|
|
85
83
|
|
|
86
84
|
export { DEFAULT_RESIZE_BEHAVIORS, clampMinSize, lockAspectWithModifier, snapToGrid, snapToGuides };
|
package/dist/resize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides } from './chunk-
|
|
2
|
-
export { AUTO_POSE_DESCRIPTOR, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, isPathLike } from './chunk-
|
|
1
|
+
export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides } from './chunk-MQI4PIX3.js';
|
|
2
|
+
export { AUTO_POSE_DESCRIPTOR, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, isPathLike, isRectPose, poseDescriptorForNode } from './chunk-UCPV7JXC.js';
|
|
3
3
|
//# sourceMappingURL=resize.js.map
|
|
4
4
|
//# sourceMappingURL=resize.js.map
|
package/dist/routing.d.ts
CHANGED
|
@@ -1,142 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { ChannelRef, DescribeRouteOptions, GESTURE_DESCRIPTORS, GestureArgSpec, GestureDescriptor, GestureName, ModRequirement, ModifierKey, ParsedModifiers, ParsedRoute, PhaseAtom, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, RouteDescriptionPart, RouteFieldName, RouteTermLabel, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute } from '@weasel-js/gestures';
|
|
3
|
-
import { T as Tool } from './registry-BY-wI9gm.js';
|
|
4
|
-
import './types-bcc7jcUy.js';
|
|
5
|
-
import '@weasel-js/history';
|
|
6
|
-
import './path-JEV2c5If.js';
|
|
7
|
-
import './types-ei3UMl9R.js';
|
|
8
|
-
import './types-DEALFt5F.js';
|
|
9
|
-
import './view-DSQgxBJB.js';
|
|
10
|
-
import '@weasel-js/modes';
|
|
11
|
-
import 'react';
|
|
12
|
-
import './DrawCommand-CD-ug3d9.js';
|
|
13
|
-
import '@weasel-js/paint';
|
|
14
|
-
import '@weasel-js/text';
|
|
15
|
-
import './geometry-6fCNhAux.js';
|
|
16
|
-
import '@weasel-js/cursor';
|
|
17
|
-
import 'react/jsx-runtime';
|
|
18
|
-
import './types-BHK2dkMu.js';
|
|
19
|
-
import '@weasel-js/geom';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* One row in the route registry — a single `GestureBinding` on one tool,
|
|
23
|
-
* flattened into the route grammar's vocabulary so the inspector, the
|
|
24
|
-
* conflict checker, and `describeRoute` can all read the same shape.
|
|
25
|
-
*
|
|
26
|
-
* Multiple rows can share (gesture, arg, target, modifiers) if different tools
|
|
27
|
-
* declare them; consumers walk the list and group client-side.
|
|
28
|
-
*/
|
|
29
|
-
interface RegistryEntry {
|
|
30
|
-
toolId: string;
|
|
31
|
-
/** Which phase the binding's `phase` spec restricts it to. `'any'` when it
|
|
32
|
-
* declares none, declares `'*'`, or declares an atom list whose atoms
|
|
33
|
-
* don't agree on one phase — such a binding fires in either phase, and
|
|
34
|
-
* reporting it as `'initial'` made it collide with genuinely-initial
|
|
35
|
-
* bindings in `findConflicts`' bucket key. */
|
|
36
|
-
phase: 'initial' | 'engaged' | 'any';
|
|
37
|
-
/** Structured v3 modifier requirements. Empty object = "no modifiers
|
|
38
|
-
* held" (the strict default). */
|
|
39
|
-
modifiers: ParsedModifiers;
|
|
40
|
-
gesture: GestureName;
|
|
41
|
-
/** Resolved arg value for arg-bearing gestures (wheel direction,
|
|
42
|
-
* key name, multiTouchTap fingers). Undefined for gestures whose
|
|
43
|
-
* descriptor has no `arg`. */
|
|
44
|
-
arg: string | undefined;
|
|
45
|
-
/** Target class for hit-testing gestures. `undefined` when the descriptor
|
|
46
|
-
* has `hasTarget: false` or the spec declares no target;
|
|
47
|
-
* {@link PREDICATE_TARGET} when the spec uses a `kindOf` predicate, which
|
|
48
|
-
* the route grammar has no notation for. */
|
|
49
|
-
target: string | undefined;
|
|
50
|
-
/** The action this binding fires. */
|
|
51
|
-
actionId: string;
|
|
52
|
-
/** The `GestureSpec` this row was flattened from, by reference. Reflection
|
|
53
|
-
* consumers that need something the grammar doesn't capture — the
|
|
54
|
-
* specificity tuple, a `kindOf` predicate identity — read it here rather
|
|
55
|
-
* than re-walking `Tool.bindings`. */
|
|
56
|
-
spec: GestureSpec;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Stand-in target for a `{ kindOf }` predicate spec.
|
|
60
|
-
*
|
|
61
|
-
* The route grammar can name target *classes* (`empty`, `selected-body`,
|
|
62
|
-
* `kind:rect`) but not arbitrary predicates, so three distinct select-tool
|
|
63
|
-
* bindings all render as this one token. Narrowing it would mean giving the
|
|
64
|
-
* grammar a way to describe a function, which is a real design question and
|
|
65
|
-
* not one this reflection layer should answer by inventing syntax.
|
|
66
|
-
*/
|
|
67
|
-
declare const PREDICATE_TARGET = "predicate";
|
|
68
|
-
/**
|
|
69
|
-
* Flatten every tool's `bindings` into route-registry rows.
|
|
70
|
-
*
|
|
71
|
-
* This was `buildActionRegistry`, and it walked `ToolDef.initial` /
|
|
72
|
-
* `.engaged` phase tables — the grammar that no longer exists. It was also
|
|
73
|
-
* blind to `Tool.bindings` the entire time the two lived side by side, which
|
|
74
|
-
* is why the inspector under-reported select by more than half. The rename
|
|
75
|
-
* fixes a second thing: it never had anything to do with the Actions
|
|
76
|
-
* Registry, and reading `buildActionRegistry` next to `ActionsRegistry`
|
|
77
|
-
* suggested otherwise.
|
|
78
|
-
*/
|
|
79
|
-
declare function buildRouteRegistry(tools: readonly Tool<unknown>[]): RegistryEntry[];
|
|
80
|
-
/** The route-grammar gesture a `GestureSpec.kind` routes as, or `undefined`
|
|
81
|
-
* for kinds the grammar has no name for. */
|
|
82
|
-
declare function routeGestureForSpecKind(kind: GestureSpec['kind']): GestureName | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Every route string one `GestureSpec` declares, in route-grammar notation.
|
|
85
|
-
*
|
|
86
|
-
* One string per arg alternative — a spec bound to `['ArrowUp','ArrowDown']`
|
|
87
|
-
* yields two routes, because each is separately conflictable and separately
|
|
88
|
-
* readable. Returns `[]` for spec kinds the grammar can't name.
|
|
89
|
-
*
|
|
90
|
-
* This is the display counterpart to {@link buildRouteRegistry}: same
|
|
91
|
-
* projection of a spec onto the grammar, rendered as text instead of as a
|
|
92
|
-
* conflict-checkable row.
|
|
93
|
-
*/
|
|
94
|
-
declare function routesForSpec(spec: GestureSpec): readonly string[];
|
|
95
|
-
|
|
96
|
-
/** Two or more tools declare the same exact (phase, gesture, arg, target,
|
|
97
|
-
* modifiers) tuple — the dispatcher's slot precedence picks one
|
|
98
|
-
* arbitrarily (well, deterministically by slot order, but the author
|
|
99
|
-
* probably didn't intend the duplication). */
|
|
100
|
-
interface Conflict {
|
|
101
|
-
phase: 'initial' | 'engaged' | 'any';
|
|
102
|
-
gesture: GestureName;
|
|
103
|
-
arg: string | undefined;
|
|
104
|
-
target: string | undefined;
|
|
105
|
-
modifiers: ParsedModifiers;
|
|
106
|
-
/** All tool ids that registered the same tuple. At least 2 by
|
|
107
|
-
* construction. Order matches the input tools[] order. */
|
|
108
|
-
toolIds: string[];
|
|
109
|
-
}
|
|
110
|
-
/** Detect exact-tuple overlaps across a tool registration set.
|
|
111
|
-
*
|
|
112
|
-
* Intentionally NOT flagged:
|
|
113
|
-
* - Broad vs. narrow targets (e.g. an untargeted `click` alongside
|
|
114
|
-
* `click` on `empty`) — the dispatcher's specificity ordering resolves
|
|
115
|
-
* those cleanly, and the broad one is usually the intended fallback.
|
|
116
|
-
* - Different modifier requirements on the same target — they fire on
|
|
117
|
-
* different inputs.
|
|
118
|
-
* - A binding whose action declines via `enabled()` so a lower-priority
|
|
119
|
-
* one can take the gesture. Detecting that intent would mean evaluating
|
|
120
|
-
* the action; consumers can suppress known-intentional compositions in
|
|
121
|
-
* their UI layer.
|
|
122
|
-
*
|
|
123
|
-
* - Two `{ kindOf }` predicate targets. The route grammar renders every
|
|
124
|
-
* predicate as the single token {@link PREDICATE_TARGET}, so bucketing on
|
|
125
|
-
* the rendered target alone reported select's `resize` / `rotate` / `move`
|
|
126
|
-
* drags — three genuinely different predicates — as a three-way conflict.
|
|
127
|
-
* Predicate entries bucket by function identity instead, which means two
|
|
128
|
-
* *separately written but equivalent* predicates go unflagged. That's the
|
|
129
|
-
* right way to be wrong here: this check has to be silent when nothing is
|
|
130
|
-
* wrong or nobody will keep it on.
|
|
131
|
-
*
|
|
132
|
-
* Note that two bindings sharing a tuple on the SAME tool are now possible
|
|
133
|
-
* (bindings are an array, where phase tables were objects with unique
|
|
134
|
-
* keys) — so a conflict may name one tool twice.
|
|
135
|
-
*
|
|
136
|
-
* This is the raw same-tuple detector. Feeding it a whole tool *registry*
|
|
137
|
-
* over-reports, because registry tools take turns in the active slot and
|
|
138
|
-
* can't collide with each other — see {@link findScopedConflicts}.
|
|
139
|
-
*/
|
|
140
|
-
declare function findConflicts(tools: readonly Tool<unknown>[]): Conflict[];
|
|
141
|
-
|
|
142
|
-
export { type Conflict, PREDICATE_TARGET, type RegistryEntry, buildRouteRegistry, findConflicts, routeGestureForSpecKind, routesForSpec };
|
|
1
|
+
export { ChannelRef, Conflict, DescribeRouteOptions, GESTURE_DESCRIPTORS, GestureArgSpec, GestureDescriptor, GestureName, ModRequirement, ModifierKey, PREDICATE_TARGET, ParsedModifiers, ParsedRoute, PhaseAtom, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, RegistryEntry, RouteDescriptionPart, RouteFieldName, RouteTermLabel, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute, reportRouteConflicts, routeGestureForSpecKind, routesForSpec } from '@weasel-js/routing';
|
package/dist/routing.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { GESTURE_DESCRIPTORS, PREDICATE_TARGET, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute, routeGestureForSpecKind, routesForSpec } from '
|
|
1
|
+
export { GESTURE_DESCRIPTORS, PREDICATE_TARGET, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute, reportRouteConflicts, routeGestureForSpecKind, routesForSpec } from '@weasel-js/routing';
|
|
2
2
|
//# sourceMappingURL=routing.js.map
|
|
3
3
|
//# sourceMappingURL=routing.js.map
|
package/dist/routing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"routing.js"}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"routing.js","sourcesContent":[]}
|