@weasel-js/core 1.5.1 → 1.6.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +273 -0
  2. package/dist/{autoPoseDescriptor-Dr6CwNZK.d.ts → autoPoseDescriptor-_XOyF7t4.d.ts} +2 -1
  3. package/dist/{chunk-P6MGECVO.js → chunk-44EWMJV2.js} +3 -3
  4. package/dist/{chunk-P6MGECVO.js.map → chunk-44EWMJV2.js.map} +1 -1
  5. package/dist/{chunk-XXQ6FLCJ.js → chunk-H6N2JSZ3.js} +3 -3
  6. package/dist/{chunk-XXQ6FLCJ.js.map → chunk-H6N2JSZ3.js.map} +1 -1
  7. package/dist/{chunk-HAGOFNP5.js → chunk-HPFJUUTF.js} +25 -20
  8. package/dist/chunk-HPFJUUTF.js.map +1 -0
  9. package/dist/{chunk-3LPQ2XZG.js → chunk-L5YNZYEG.js} +8 -13
  10. package/dist/chunk-L5YNZYEG.js.map +1 -0
  11. package/dist/{chunk-LXJDWBEL.js → chunk-PNNZSYRD.js} +2 -2
  12. package/dist/{chunk-LXJDWBEL.js.map → chunk-PNNZSYRD.js.map} +1 -1
  13. package/dist/{chunk-GREL4MVO.js → chunk-THCSDHII.js} +2084 -1344
  14. package/dist/chunk-THCSDHII.js.map +1 -0
  15. package/dist/clipboard.d.ts +2 -1
  16. package/dist/clone.d.ts +3 -2
  17. package/dist/{depSchema-BubKMv-2.d.ts → depSchema-BhgZc0-Q.d.ts} +79 -55
  18. package/dist/{grid-Z_Af3vTl.d.ts → grid-Dx2gQbNv.d.ts} +22 -6
  19. package/dist/index.d.ts +374 -92
  20. package/dist/index.js +6 -6
  21. package/dist/insert.d.ts +4 -3
  22. package/dist/insert.js +2 -2
  23. package/dist/{math-E3rZn4bR.d.ts → math-DRa6HBBs.d.ts} +7 -21
  24. package/dist/math.d.ts +5 -4
  25. package/dist/math.js +2 -2
  26. package/dist/move.d.ts +5 -4
  27. package/dist/move.js +3 -3
  28. package/dist/{options-BPcmwYk7.d.ts → options-CzjxFoYZ.d.ts} +1 -1
  29. package/dist/path-JEV2c5If.d.ts +48 -0
  30. package/dist/{pointSnapToGrid-CgcK2R_I.d.ts → pointSnapToGrid-7mCcm6qG.d.ts} +1 -1
  31. package/dist/{poseDescriptor-PgfVKfa0.d.ts → poseDescriptor-rZa9W5hJ.d.ts} +1 -48
  32. package/dist/renderer.d.ts +8 -7
  33. package/dist/renderer.js +6 -6
  34. package/dist/resize.d.ts +6 -5
  35. package/dist/resize.js +3 -3
  36. package/dist/{types-BdaK9PcP.d.ts → types-CxC8P6W0.d.ts} +27 -1
  37. package/dist/{types-BHGdrOcu.d.ts → types-D_74YlWs.d.ts} +1 -1
  38. package/package.json +10 -10
  39. package/dist/chunk-3LPQ2XZG.js.map +0 -1
  40. package/dist/chunk-GREL4MVO.js.map +0 -1
  41. package/dist/chunk-HAGOFNP5.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,278 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 16c0da2: Kit actions can now fill a whole editor toolbar from the registry.
8
+
9
+ - `Action.variants` lists the separate things a parametric action does, each with its own label and params. `flip` declares Flip Horizontal and Flip Vertical; `reorder.forward` and `reorder.backward` declare their one-step and all-the-way forms. `actionItems(action)` expands an action into the entries a bar, menu or palette shows: one per variant, or the action itself. An action without an immediate invoker gets none, because `trigger` cannot start a drag.
10
+ - `actionShortcuts(action, params)` returns only the shortcuts whose binding passes those params, so each variant shows its own key.
11
+ - `ActionBar` renders one button per entry and triggers it with that entry's params. `icons` and `labels` are now keyed by entry key (`flip:y`, `reorder.forward:extreme`), which is still the action id for an action without variants. `enabled` is evaluated with the deps the action declares in `requires`, not a fixed set of six, and a tooltip without a `shortcut` override now shows the binding's key.
12
+ - New groups: `history` (undo, redo), `clipboard` (cut, copy, paste), `edit` (duplicate, delete), `structure` (group, ungroup) and `flip`.
13
+ - New `clipboard.paste` action, which calls the `clipboard` dep's `paste()`. It has no key binding, because Cmd/Ctrl+V already arrives as a paste event.
14
+ - `enabled` now follows the current state: undo and redo follow the history stacks, `delete` and `group` need a selection, `ungroup` needs a selected container, and `clipboard.paste` needs a non-empty clipboard. `delete`, `group` and `ungroup` used to report enabled unconditionally.
15
+ - Align actions now register left, center, right, top, middle, bottom.
16
+ - `buildDepsFromRequires` is re-exported from `@weasel-js/core`.
17
+ - b8ebef6: The eight glyphs the align and distribute actions ship are now exported from `@weasel-js/core` and re-exported from `@weasel-js/ui`, beside the Pathfinder and edit-action icons: `AlignLeftIcon`, `AlignCenterXIcon`, `AlignRightIcon`, `AlignTopIcon`, `AlignCenterYIcon`, `AlignBottomIcon`, `DistributeHorizontalIcon` and `DistributeVerticalIcon`. They are the same components the actions draw, so a consumer can render one outside an `<ActionBar>` without authoring its own.
18
+ - c373af4: Color ramps can interpolate in OKLab, HSL, sRGB and linear sRGB as well as OKLCH. `@weasel-js/ui` adds `colorRamp(from, to, steps, options)` and `rampColor(from, to, t, options)`, whose `space` option picks the space (default `'oklch'`), `hue` picks the shorter or longer arc in the polar spaces, and `chroma` applies a `ChromaCurve` after interpolation in any space. Underneath, `@weasel-js/paint` (re-exported from core) adds `interpolateSrgb` with the `ColorInterpolationSpace` and `HueInterpolation` types, plus float-precision `srgbToLinear`, `linearToSrgb`, `linearSrgbToOklab`, `oklabToLinearSrgb`, `srgbToHsl` and `hslToSrgb`. The forge story `ui/Color/ColorRamp` shows the same endpoints ramped in each space.
19
+ - bfe6a4f: `contrastLineColor(background, strength)` derives a line color that reads against an arbitrary background — a grid or a rule drawn over a page whose color the document picks, where theme tokens follow the chrome instead. It moves the background `strength` in OKLab lightness away from its nearer end, darker over light and lighter over dark, keeping its hue, so dark and tinted pages get lines that show. Re-exported from `@weasel-js/core`.
20
+ - 6857b4d: `DEFAULT_PALETTE` is now a `Palette` of five named sRGB entries rather than a `string[]`, which breaks any code indexing it as an array. `cycleFill(seq, palette?, fallback?)` gives the `seq`th entry as hex, wrapping, and is what the built-in shape tools and the `insert` dep now call. `@weasel-js/paint` gains `hexToColorLiteral` for `#rrggbb` and `#rrggbbaa`.
21
+ - bbaefca: Under a composing `poseComposition`, a container whose pose derives from its children (`dependsOn: 'children'` with a `derivePose`, as `groupAction` mints under the default strategy) is now an envelope rather than a frame: its children are stored in the same frame it is, and the render walk, `getWorldPose`, picking and the actions' world/local conversions pass over it. Before, its derived pose was folded in as the children's frame, which moved every child by its own offset. `unionOfChildren` needs no change and is right under any strategy. `definesFrame(node)` is exported, and `PoseAdapter` takes an optional `definesFrame(id)` so a hand-built adapter can say the same to `composeWorldPose` and `rebaseLocalPose`. Nothing changes without a composing strategy.
22
+
23
+ `moveAction`'s translate-only drag and commit are now right under a composing strategy. Dragging a frame container no longer also translates its descendants, which moved them twice; they ride the frame. A node stored under a turned frame now moves the way the pointer went, instead of by the world drag applied in its frame's rotated axes.
24
+
25
+ Copy and paste now keep a container's `dependsOn: 'children'` and `derivePose`, so a pasted group still tracks its members, under any strategy. Under a composing strategy, `snapshotSelection` also captures in world coordinates any node whose frame is not part of the copy, and `commitPaste` no longer offsets nodes inside a pasted frame a second time.
26
+ - 0cf6a0d: The clipboard, duplicate, group, ungroup, reorder and flip actions now ship their own icons, so `<ActionBar group="clipboard" />` and its siblings draw glyphs with no `icons` map. Each reorder and flip variant carries its own glyph (Bring Forward / Bring to Front, Send Backward / Send to Back, Flip Horizontal / Flip Vertical). The twelve glyphs are exported from `@weasel-js/core` and `@weasel-js/ui` as `CutIcon`, `CopyIcon`, `PasteIcon`, `DuplicateIcon`, `GroupIcon`, `UngroupIcon`, `BringForwardIcon`, `BringToFrontIcon`, `SendBackwardIcon`, `SendToBackIcon`, `FlipXIcon` and `FlipYIcon`, in the same 20×20 `currentColor` register as the Pathfinder icons. An `icons` entry still overrides them.
27
+ - 811abcd: A registered program's struct uniforms now get locations. `uniform Light
28
+ u_lights[2];` is looked up as `u_lights[0].pos`, `u_lights[0].r` and so on,
29
+ nested structs and array members included; before, only the bare name was
30
+ looked up, so every write to a struct member was dropped, with a warning only
31
+ in development.
32
+
33
+ Array sizes written as a `#define`, a top-level `const int`, a small integer
34
+ expression over those, or on the type (`uniform float[2] u_t;`) now resolve;
35
+ before, such a uniform got no locations at all. Uniforms inside comments are no
36
+ longer looked up.
37
+
38
+ A program recompiled after a restored WebGL context now looks up the uniforms
39
+ its own vertex shader declares, as `registerProgram` already did.
40
+ - 7c53d1a: The undo, redo and delete actions now ship their own icons, so `<ActionBar group="history" />` and `<ActionBar group="edit" />` draw glyphs with no `icons` map. `UndoIcon`, `RedoIcon` and `DeleteIcon` move into `@weasel-js/core`, which the actions need them in; `@weasel-js/ui` re-exports them under the same names with the same props, and `<Icon name="undo" />` draws the same glyph. Core also exports `ACTION_GLYPHS`, the three glyphs' SVG markup, which `ICON_PATHS` now points at.
41
+ - 5345efb: A `kit:image` node can crop and mirror its bitmap. `data.image` takes an
42
+ optional `source` — the part of the bitmap to draw into the pose rect, as
43
+ fractions of the bitmap's width and height — and optional `flipX` / `flipY`,
44
+ which mirror the drawn region within the rect without moving it. The painter
45
+ hands both to the renderer's existing `ImageDrawCommand` fields, so hit-testing
46
+ and the silhouette are unchanged. Existing image data draws as before.
47
+
48
+ `svgNodesToKitDrafts` now carries an `SvgImageNode`'s source rect and flips onto
49
+ `data.image` instead of dropping them, and the new `svgImageFromKit(image, pose)`
50
+ writes a `kit:image` leaf back as an `SvgImageNode`, so a cropped or flipped
51
+ image survives SVG → scene → SVG.
52
+ - 87fd8a8: Choose which layout container a drag lands in when several contain the drop point. `<SceneCanvas layoutDropTarget>` takes `'innermost'` (the default, and the behavior until now: the deepest container, ties to the one painted later), `'topmost'` (the container painted last, in the scene's render order across the whole tree) or `'region'` (only containers that declare a drop region). A layout strategy declares one with the new optional `dropRegion(container)`, returning a `Path` or a predicate in the container's local frame; a declared region replaces the container body as its hit area in every mode, and may reach past it. The drag-time reflow preview and the commit follow the same choice. New types: `LayoutDropTargetMode`, `DropRegion`.
53
+ - 6f14f6f: The pen joins paths. Finishing a path by clicking (or dragging on) another open path's endpoint now makes one node: the drawn path's anchors followed by the other path's, turned around when you land on its last anchor, with the other node deleted in the same undo step. The path being drawn keeps its identity — a continued node keeps its id and style, and a new path is minted like any other pen path.
54
+
55
+ Two optional additions make that one op batch: `EditAnchorsDep.editOps(id, worldPath, label)` returns the ops `applyEdit` would commit without applying them, and the pen adapter's `makeNode(pose)` builds the node `addNode` would insert. `<SceneCanvas>` supplies both. Without them the click places an anchor, as before.
56
+ - c1f82e2: The pen's curves now follow the handles you drag. Dragging while placing an anchor gives it an out-handle at the drag point and an in-handle mirrored through it, and each segment runs from its start anchor's out-handle to its end anchor's in-handle — as in Illustrator and Figma. Before, a segment's second control point was the mirror of the *previous* anchor's handle, which sat behind the start of the segment, and a dragged anchor never shaped the segment coming into it. The preview and the committed path both changed.
57
+
58
+ Alt held from the start of the drag leaves the anchor with no in-handle; Alt pressed part-way freezes the in-handle and moves only the out-handle. Dragging the endpoint of a path the pen picked up moves its out-handle only, leaving the existing segment into it alone. `PenAnchor.altBroken` now describes the anchor it is set on, not the one after it.
59
+ - 97561f1: Zoom the canvas on Safari's trackpad pinch
60
+
61
+ Safari reports a trackpad pinch as WebKit `gesturestart` / `gesturechange` /
62
+ `gestureend` events, and nothing listened for them, so the page zoomed instead
63
+ of the canvas. `useGestureDispatcher` now dispatches each `gesturechange` as a
64
+ new `pinch` gesture: `PinchSpec` (`{ kind: 'pinch', direction?: 'in' | 'out' }`),
65
+ `PinchEvent`, route-grammar name `pinch`, and `InvocationCtx.pinch`. Safari's
66
+ cumulative `scale` is turned into a per-sample step, and the focal point is
67
+ canvas-local like a wheel's. A new `pinch` entry in `DispatcherChannels` turns
68
+ the listeners off.
69
+
70
+ `viewport.zoom` binds it. Its wheel and pinch samples now share one path: each
71
+ becomes a scale factor about a focal point, so a pinch sample of 1.1 lands on
72
+ exactly the view a ctrl+wheel `deltaY` of -100 does.
73
+
74
+ Safari can send the same pinch as ctrl+wheel too. While a pinch some binding
75
+ has claimed is live, the dispatcher swallows ctrl+wheel (preventing its
76
+ default, dispatching nothing), so one pinch zooms once. When no binding claims
77
+ the pinch, the gesture events are left to the browser and ctrl+wheel reaches
78
+ its bindings as before.
79
+ - 89926b5: `<SceneCanvas>` now builds its adapter with `useSceneAdapter` and keeps the same adapter across renders unless one of its inputs changes; it used to build a new one on every render. Moving a container still moves its children, now through `sceneToAdapter`'s `cascadeContainerPose` rather than a second copy of that logic.
80
+
81
+ `useSceneAdapter` now passes `poseComposition` through to `sceneToAdapter`. It used to drop it, so the adapter it returned ignored the frame model. The undo entry `cascadeContainerPose` records for a container move is now labeled `move container` rather than `setPose`, the label `<SceneCanvas>` already used.
82
+ - 9f86dec: `<SceneCanvas selectionMode="none">` now blocks every selection write the canvas makes. Before, the adapter it hands its tools could still set the selection, and so could any op batch that selects its result, such as a paste or an ingest. `setSelection` on that adapter, and on the `selection` dep's `adapterMethods`, now does nothing in that mode. The consumer's own `SelectionApi`, passed as the `selection` prop or made with `useSelection({ scene })`, still writes, and the canvas draws what it holds.
83
+
84
+ `defaultCommitAdapter` takes an optional second argument, a `SelectionApi`'s `adapterMethods`. When it is passed, selection reads and writes go through it rather than the scene. Every built-in action now passes its `selection` dep.
85
+
86
+ The `CanvasSelectionMode` docs now say what each mode does. `'single'` is a click rule, not a cap: a marquee, lasso, select-all or paste can still select several nodes.
87
+ - 4074270: `ShapeKindIcon` draws the glyph for a shape kind — the one its insertion tool shows — and falls back to `UnknownIcon` for a kind the kit does not ship. The icon set gains `page` (`PageIcon`), a document page with a folded corner. Core now exports the `ShapeKind` type.
88
+ - debfd5d: An SVG image node (`data:image/svg+xml` source, or a URL ending in `.svg`) now stays sharp under zoom. The image cache re-rasterizes it at the size it is drawn, in power-of-two steps so a zoom gesture does not redraw it every frame, capped at the renderer's maximum texture size and 4096×4096 pixels. The previous raster keeps painting until the new one is ready, and its GL texture is freed when it is replaced. PNG, JPEG and other raster sources are unchanged.
89
+
90
+ New: `getImageBitmap(src, drawnAt?)` takes the size in device pixels an image is about to cover, `NodePaintCtx.pixelScale` carries device pixels per world unit to painters (`defaultDrawOne` fills it from the view and `devicePixelRatio`), and `isVectorImageSrc(src)` reports whether a source is treated as SVG.
91
+ - d975afa: `text-transform` for styled runs and text nodes
92
+
93
+ `StyledRun` and `TextStyle` gain `textTransform: 'none' | 'uppercase' |
94
+ 'lowercase' | 'capitalize'`, with CSS semantics. A run's value overrides the
95
+ node's, and `'none'` on a run turns an inherited transform off. Only what is
96
+ drawn changes: a run's `text` stays as authored, so carets, selections and
97
+ edits still address the source.
98
+
99
+ - Case mapping uses JavaScript's locale-independent full mappings, so `ß`
100
+ uppercases to `SS` and a word-final `Σ` lowercases to `ς`. `capitalize`
101
+ titlecases the first letter of each word (`dž` → `Dž`, `ß` → `Ss`) and leaves
102
+ the rest alone; word starts come from `Intl.Segmenter`, the same boundaries
103
+ browsers use, and are found across run boundaries.
104
+ - `resolveRuns` applies the transform, so `ResolvedRun.text` is the drawn
105
+ text. When a transform changes a length, the run carries `srcMap`: where
106
+ each drawn UTF-16 unit came from in the source. Layout reads each cell's
107
+ `srcIndex` / `srcEnd` off it, so both cells of an uppercased `ß` map to the
108
+ one source character, and `caretIndexAt` treats them as one stop.
109
+ - `transformRunTexts` is exported for callers laying text out themselves;
110
+ `layoutMarkdown` uses it.
111
+ - The range helpers (`applyStyleToRange`, `styleAtRange`,
112
+ `effectiveRangeStyle`) carry the new key, the text tool and the node's
113
+ Character properties offer it as "Case", and the edit overlay shows it with
114
+ CSS `text-transform` on the overlay and on each run span.
115
+ - `@weasel-js/svg` writes it as `style="text-transform:…"` on `<text>` and
116
+ `<tspan>` — it is a CSS property, not an SVG 1.1 presentation attribute — and
117
+ reads it back from either spelling or an ancestor.
118
+ - 62d8d7c: `useOngoingAction(actionId)` lets a UI control — a color picker, a slider, a swatch — drive an ongoing action the way a drag does: `input(params)` opens the action on the first call and moves it on the rest (the live preview), `commit(params?)` ends it as one undo entry, and `cancel()` drops it. A commit with nothing open is a whole edit on its own, which is what a click on a swatch is. An edit still open when the control unmounts or its action id changes is committed. It wraps `ActionsRegistry.begin`, whose begin-or-update-then-end bookkeeping every such control used to hand-roll around a ref; `SceneGradientHandles` now uses it.
119
+ - Updated dependencies [16c0da2]
120
+ - Updated dependencies [c373af4]
121
+ - Updated dependencies [bfe6a4f]
122
+ - Updated dependencies [6857b4d]
123
+ - Updated dependencies [b1c30bc]
124
+ - Updated dependencies [f792755]
125
+ - Updated dependencies [9aa63a1]
126
+ - Updated dependencies [97561f1]
127
+ - Updated dependencies [d975afa]
128
+ - Updated dependencies [62d8d7c]
129
+ - @weasel-js/routing@1.6.0
130
+ - @weasel-js/paint@1.6.0
131
+ - @weasel-js/text@1.6.0
132
+ - @weasel-js/gestures@1.6.0
133
+ - @weasel-js/cursor@1.6.0
134
+ - @weasel-js/font@1.6.0
135
+ - @weasel-js/geom@1.6.0
136
+ - @weasel-js/history@1.6.0
137
+
138
+ ## 1.5.2
139
+
140
+ ### Patch Changes
141
+
142
+ - 1c695cb: `derivePose` now notices a dependency that moved with nothing pushed behind it.
143
+ The memo is keyed on the deriving node's own authored pose, which only changes
144
+ when someone pushes an invalidation — so an ancestor's frame moving, a removal,
145
+ a dependency appearing, or a lookup answering poses of its own all left the
146
+ derived pose stale. It now records what it derived from and re-checks it by
147
+ value on a memo hit, the way `resolveDerivedPath` already did. The compare both
148
+ paths use is shared in `depMemo.ts`.
149
+ - 24a2dae: Close the places where two tiers spelled one concept differently.
150
+
151
+ **A fixed pan bug.** `viewport.dragPan` fell back from `drag.screenDelta` to
152
+ the world `drag.delta` and then divided by the zoom anyway, panning at
153
+ 1/scale² for any event source that supplies no `clientX`/`clientY` — which is
154
+ every synthesized `InputEvent`, since those fields are optional. It now
155
+ reconstructs the client delta exactly, by undoing each end of the world delta
156
+ against the view that produced it.
157
+
158
+ **Breaking, renames.** `ClickEvent`, `DoubleClickEvent` and `ContextMenuEvent`
159
+ carry their world point as `x`/`y`, matching every other kind in `InputEvent`;
160
+ `worldX`/`worldY` are gone, and a consumer who set `x`/`y` no longer silently
161
+ lands at the origin. All three now also carry `clientX`/`clientY`, so a
162
+ context-menu action can finally read `ctx.screen` — the case that surface was
163
+ added for. The renderer's `Mat3` is `GlMat3`, freeing `Mat3` to mean geom's
164
+ affine in a file that imports from both. `translatePolygonInPlace` is
165
+ gone: it was the one sanctioned writer into a committed path's coord buffer,
166
+ documented as overlay-only, and nothing called it. `@weasel-js/font` exports `FontStyle`
167
+ in place of `OutlineFontStyle`. `@weasel-js/labkit` no longer exports
168
+ `useOrbit`, `OrbitView`, `Vec3` or their helpers: `@weasel-js/kernel3d` owns
169
+ the orbit camera and `@weasel-js/geom/3d` owns `Vec3`. `ToolCtx.screenPoint`
170
+ was declared and never written by anything; it is gone.
171
+
172
+ **Breaking, types narrowed.** geom's `Mat3` and `Box` are readonly tuples,
173
+ matching the reason `geom/3d` already gives for its own. `History.entries()`
174
+ returns `readonly` arrays, which is what its docstring always asked callers to
175
+ assume.
176
+
177
+ **One type where there were two.** `@weasel-js/svg`'s `Matrix` is geom's
178
+ `Mat3`, and its duplicate `multiply` is geom's; `SvgStroke.width` is
179
+ `ScreenLength` rather than that union written out again. `kernel3d`'s
180
+ `ViewportRect` is `ScreenBox` — one rectangle spelling instead of `w`/`h`
181
+ beside `width`/`height` eight lines apart. The renderer's `View` is routing's.
182
+ Core's `Vec2` is routing's `Point2`, and `Pt` is gone from the barrel.
183
+
184
+ **Additions.** `oklchDegToHex` / `hexToOklchDeg` / `OklchDeg` in
185
+ `@weasel-js/paint` — the degrees-and-hex form `@weasel-js/ui` and
186
+ `@weasel-js/theme` had each built for themselves. `srgbFloatToOklab`, for
187
+ callers holding 0..1 floats; feeding those to `srgbU8ToOklab` truncated where
188
+ paint's own internal conversion rounds. `mat3.toAffine` / `mat3.fromAffine`
189
+ name the repack between the GL layout and geom's.
190
+
191
+ **Corrections.** `RECT_POSE_DESCRIPTOR` implements `getRotation`, so a pose it
192
+ rotated no longer reports itself unrotated to `useResize` and to diagram's port
193
+ placement. `ToolDef.capabilities` is documented as reaching
194
+ `Tool.eligibility.capabilities`, which is where it actually goes — following
195
+ the old text gave `undefined`, and `eligibleForMode` turns that into a tool
196
+ that vanishes from every mode. `MultitouchEvent.centroid` is documented as
197
+ canvas-local, which is what the dispatcher hands over. `drag.points` is a
198
+ snapshot on `onEnd` rather than the dispatcher's live accumulator.
199
+
200
+ `tsconfig.json` now typechecks `packages/routing`, `cursor`, `bidi` and
201
+ `loupe`, which it had never included.
202
+ - 564deb4: Take typed units past linear factors.
203
+
204
+ A unit table entry is now `number | { factor, offset }`, so a scale that
205
+ disagrees with the base about where zero sits — degC against K — is
206
+ expressible; a bare number stays the shorthand for a pure factor, so every
207
+ existing table reads as it did. `unitScale(system, unit)` is the one reader
208
+ that widens the shorthand and defaults the offset, and `resolveUnit` /
209
+ `formatUnit` both go through it.
210
+
211
+ `parseNumber` reads a compound value: `5ft 3in` is 63in, a leading sign carries
212
+ across every term, and a term with no unit (or a unit the field does not
213
+ accept) leaves the value unreadable rather than half-read. Offsets have no
214
+ meaning in a sum, so a compound value takes pure scales only.
215
+
216
+ `prefUnit` converts through offsets in both directions and now returns a
217
+ `format`, which is what the SelectionPanel slider readout draws — `formatUnit`
218
+ had no callers before this.
219
+ - 8ffd746: State the port-curve rule once, in `@weasel-js/geom`.
220
+
221
+ A routed edge leaves a port along its normal and arrives at the next against
222
+ that port's normal, with the controls reaching 0.4 of the straight-line
223
+ distance. That rule lived inside `@weasel-js/diagram`'s `bezier` router with
224
+ its reach constant module-private, so a 3D consumer had no way to share even
225
+ the number.
226
+
227
+ It is now `portControls` / `portCurvePoints` / `PORT_REACH`, exported from
228
+ both `@weasel-js/geom` and `@weasel-js/geom/3d`. One implementation over loose
229
+ components sits behind both, so the two dimensions cannot disagree: every
230
+ operation in it is closed on the plane z = 0, and a planar problem answered
231
+ through the 3D entry returns the same numbers, not an approximation. Each
232
+ barrel wraps it in its own tier's currency — scalars for 2D, matching
233
+ `cubicEvalAt`, and `Vec3` for 3D.
234
+
235
+ `bezier` is unchanged in behavior; it calls through. `@weasel-js/diagram` now
236
+ declares the `@weasel-js/geom` peer it had been importing without.
237
+
238
+ Also moves `Vec2`'s declaration out of `core/geometry/polygonHitTestRect.ts`,
239
+ a polygon-versus-rect hit-testing helper it had been an incidental local in,
240
+ into `core/geometry/vec2.ts`. No API change — the barrel exports the same
241
+ type from a place you would look for it.
242
+ - 37e8105: Eight character-styling glyphs, and a text tool that declares its own options.
243
+
244
+ `bold`, `italic`, `underline`, `strikethrough`, `overline`, `superscript`,
245
+ `subscript` and `code` join the icon set. The five flags are letterforms
246
+ wearing the treatment they apply, because that is what the controls they label
247
+ replaced.
248
+
249
+ `useTextTool.options` declares the character half of text styling as a
250
+ `ToolPrefGroup`, keyed by `StyledRun` field, so a host reads a `RangeStyle`
251
+ into it and writes a `RunStylePatch` back with no name mapping. `short` moves
252
+ from `ToolPrefBoolean` to every leaf: it is the label any surface too narrow
253
+ for `name` shows, and `name` stays the accessible name.
254
+
255
+ `ToolOptionsBar` labels a bare value box — a number or a string — and leaves
256
+ every other control to say what it is, and it sizes fields and opacity tracks
257
+ for one line rather than for a panel column.
258
+ - 6d79849: Compact a tile grid's resting arrangement in current cell order rather than by
259
+ sorted id. Drops, swaps and occupancy already went by where a child's pose sits,
260
+ so the reflow that ran when a child left the grid re-sorted the survivors and
261
+ undid any earlier swap among them. Children sitting in no cell still sort last,
262
+ by id, so a grid nobody has arranged yet fills the same way it did.
263
+ - Updated dependencies [24a2dae]
264
+ - Updated dependencies [15b798e]
265
+ - Updated dependencies [8ffd746]
266
+ - Updated dependencies [ad6c351]
267
+ - @weasel-js/routing@1.5.2
268
+ - @weasel-js/gestures@1.5.2
269
+ - @weasel-js/geom@1.5.2
270
+ - @weasel-js/paint@1.5.2
271
+ - @weasel-js/font@1.5.2
272
+ - @weasel-js/text@1.5.2
273
+ - @weasel-js/history@1.5.2
274
+ - @weasel-js/cursor@1.5.2
275
+
3
276
  ## 1.5.1
4
277
 
5
278
  ### Patch Changes
@@ -1,4 +1,5 @@
1
- import { P as PoseDescriptor, a as Path } from './poseDescriptor-PgfVKfa0.js';
1
+ import { P as Path } from './path-JEV2c5If.js';
2
+ import { P as PoseDescriptor } from './poseDescriptor-rZa9W5hJ.js';
2
3
 
3
4
  /** True for Path-shaped poses (`{kind: 'polygon' | 'rect'}`). Useful for
4
5
  * callers that need to fork between `pathPoseDescriptor` and
@@ -1,4 +1,4 @@
1
- import { RECT_ORIGIN_PROJECTION } from './chunk-HAGOFNP5.js';
1
+ import { RECT_ORIGIN_PROJECTION } from './chunk-HPFJUUTF.js';
2
2
  import { registerOpFactory, captureSlot, slotFromIndex, resolveSlot } from './chunk-4RJP2N2L.js';
3
3
 
4
4
  // src/core/ops/transform.ts
@@ -124,5 +124,5 @@ function snap(strategy, opts = {}) {
124
124
  }
125
125
 
126
126
  export { createReparentOp, createTransformOp, snap };
127
- //# sourceMappingURL=chunk-P6MGECVO.js.map
128
- //# sourceMappingURL=chunk-P6MGECVO.js.map
127
+ //# sourceMappingURL=chunk-44EWMJV2.js.map
128
+ //# sourceMappingURL=chunk-44EWMJV2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/ops/transform.ts","../src/core/ops/reparent.ts","../src/interactions/gestures/shared/snap.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,kBAAyB,IAAA,EAAgC;AACvE,EAAA,MAAM,EAAE,IAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,GAAc,CAAA,UAAA,EAAa,EAAE,CAAA,CAAA,EAAG,GAAI,IAAA;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,MAAM,EAAE,EAAA,EAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,EAAY;AAAA,IACzC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAM,OAAA,EAAS;AAOb,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I,SAAA,CAAU,SAAS,CAAA,EAAG;AAI3C,MAAA,IAAI,SAAA,CAAU,SAAS,WAAA,EAAa;AACpC,MAAA,MAAM,SAAA,GAAY,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAClC,MAAA,IAAI,cAAc,MAAA,EAAW;AAC7B,MAAA,MAAM,UAAA,GAAa,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,SAAS,CAAA;AAC3C,MAAA,IAAI,eAAe,MAAA,EAAW;AAC9B,MAAA,MAAM,WAAW,IAAA,CAAK,SAAA,CAAU,YAAY,SAAA,CAAU,EAAA,EAAI,UAAU,EAAE,CAAA;AACtE,MAAA,MAAM,OAAA,GAAU,QAAA,CAAS,IAAA,CAAK,QAAA,EAAU,GAAG,CAAA;AAC3C,MAAA,IAAI,YAAY,IAAA,EAAM;AACtB,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,SAAA,CAAU,UAAU,CAAA;AACpC,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA;AACjC,MAAA,OAAO;AAAA,QACL,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,EAAA,CAAG,CAAA,EAAG,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA;AAAE,OACnE;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-P6MGECVO.js","sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface TransformAdapter<TPose> {\n setPose(id: string, pose: TPose): void;\n}\n\n/** @internal */\ninterface TransformArgs<TPose> {\n id: string;\n from: TPose;\n to: TPose;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Op: set an object's pose, inverting back to `from`. `coalesceKey` defaults to\n * `transform:${id}` so successive pose writes to the same node (drag-move,\n * resize, repeated nudges) merge into one undo entry within the history's\n * coalesce window. Pass an explicit key (or a unique one) to opt out. */\nexport function createTransformOp<TPose>(args: TransformArgs<TPose>): Op {\n const { id, from, to, label, coalesceKey = `transform:${id}` } = args;\n return {\n name: 'transform',\n args: { id, from, to, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n // Always call setPose so consumers that inspect op behavior (tests,\n // overlays) see a consistent \"this op writes (id, to)\" signal. When\n // from and to are structurally identical, additionally report a\n // no-op to history so the entry can be skipped from the undo stack.\n // setPose(id, to) is idempotent in this branch — adapters write the\n // same pose they already had.\n (adapter as TransformAdapter<TPose>).setPose(id, to);\n if (poseShallowEqual(from, to)) return false;\n return undefined;\n },\n invert() {\n return createTransformOp<TPose>({ id, from: to, to: from, label, coalesceKey });\n },\n };\n}\n\nregisterOpFactory<TransformArgs<unknown>>('transform', (args) => createTransformOp(args));\n\nfunction poseShallowEqual<TPose>(a: TPose, b: TPose): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n for (const k of ka) {\n if ((a as Record<string, unknown>)[k] !== (b as Record<string, unknown>)[k]) return false;\n }\n return true;\n}\n","import type { Op } from './types';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, resolveSlot, slotFromIndex, type OrderedReader, type Slot } from './slot';\n\ninterface ReparentAdapter extends OrderedReader {\n setParent(id: string, parentId: string | null): void;\n /** Sibling-order write, paired with `getChildren`. Optional: an adapter\n * without both silently ignores slots and appends. */\n setChildOrder?(parentId: string | null, ids: string[]): void;\n}\n\n/** @internal */\ninterface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n /** Sibling ordinal under the old parent. Sugar for `fromSlot: { index }`,\n * and only a seed: `apply` re-observes the node's full slot through the\n * adapter and that observation supersedes this. */\n fromIndex?: number;\n /** Sibling ordinal under the new parent. Sugar for `toSlot: { index }`.\n * Omit to append. */\n toIndex?: number;\n /** Slot under the old parent, anchor included. `invert()` forwards it as\n * the destination slot; without it undo re-parents with no position and\n * the node lands last, quietly changing paint order. */\n fromSlot?: Slot;\n /** Slot under the new parent, anchor included. Omit to append. */\n toSlot?: Slot;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Move `id` to `slot` among `parentId`'s children. No-op when the adapter\n * has no ordering seam, when `id` isn't there, or when it's already in\n * place. */\nfunction placeAt(\n a: ReparentAdapter,\n parentId: string | null,\n id: string,\n slot: Slot,\n): void {\n if (!a.getChildren || !a.setChildOrder) return;\n const current = a.getChildren(parentId);\n const from = current.indexOf(id);\n if (from < 0) return;\n const next = current.slice();\n next.splice(from, 1);\n const resolved = resolveSlot(next, slot);\n const to = resolved === undefined ? next.length : Math.max(0, Math.min(resolved, next.length));\n if (from === to) return;\n next.splice(to, 0, id);\n a.setChildOrder(parentId, next);\n}\n\n/** Present when the caller named a destination at all; `undefined` leaves\n * placement to the adapter. */\nfunction optionalSlot(slot: Slot | undefined, index: number | undefined): Slot | undefined {\n if (slot) return slot;\n return index === undefined ? undefined : slotFromIndex(index);\n}\n\n/**\n * Op: change `id`'s parent and sibling slot, inverting back to the prior\n * parent and slot.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const {\n id, fromParentId, toParentId,\n label = 'Reparent', coalesceKey = `reparent:${id}`,\n } = args;\n let fromSlot = optionalSlot(args.fromSlot, args.fromIndex);\n const toSlot = optionalSlot(args.toSlot, args.toIndex);\n const argsForSerial: ReparentArgs = {\n id, fromParentId, toParentId, fromSlot, toSlot, label, coalesceKey,\n };\n return {\n name: 'reparent',\n args: argsForSerial,\n label,\n coalesceKey,\n apply(adapter) {\n const a = adapter as ReparentAdapter;\n const observed = captureSlot(a, fromParentId, id);\n if (observed) {\n fromSlot = observed;\n argsForSerial.fromSlot = observed;\n }\n a.setParent(id, toParentId);\n if (toSlot) placeAt(a, toParentId, id, toSlot);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n fromSlot: toSlot,\n toSlot: fromSlot,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n","import type { MoveBehavior, ModifierState, SnapStrategy } from '../types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from './strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/**\n * Generic snap behavior factory: wraps a `SnapStrategy` and returns a\n * `MoveBehavior` whose `onMove` returns a uniform `GroupTransform`.\n *\n * Implementation:\n * 1. Compute the primary's proposed pose by applying the gesture's\n * `transform` (translate) to `origin.get(primaryId)`.\n * 2. Call `strategy.snap(proposed)`. If null, no-op.\n * 3. Derive the snapped delta via the `OriginProjection`:\n * dx = origin(snapped).x - origin(originPose).x\n * ...so the gesture applies the same delta to every dragged id.\n *\n * The pose-shape-aware delta extraction lives here — gestures stay pose-shape\n * agnostic. Default projection is `{x, y}`-bearing (rect / path / polygon).\n * Pass `origin` for exotic poses.\n */\nexport function snap<TPose>(\n strategy: SnapStrategy<TPose>,\n opts: { bypassKey?: ModKey; origin?: OriginProjection<TPose> } = {},\n): MoveBehavior<TPose> {\n const { bypassKey } = opts;\n const proj: OriginProjection<TPose> = opts.origin\n ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n return {\n onMove(ctx, transform) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n // The new contract: behaviors see a GroupTransform, not a pose. But\n // strategies still operate on poses. Reconstruct the proposed pose\n // by applying the (translate) transform to the primary's origin.\n if (transform.kind !== 'translate') return;\n const primaryId = ctx.draggedIds[0];\n if (primaryId === undefined) return;\n const originPose = ctx.origin.get(primaryId);\n if (originPose === undefined) return;\n const proposed = proj.translate(originPose, transform.dx, transform.dy);\n const snapped = strategy.snap(proposed, ctx);\n if (snapped === null) return;\n const o0 = proj.getOrigin(originPose);\n const o1 = proj.getOrigin(snapped);\n return {\n transform: { kind: 'translate', dx: o1.x - o0.x, dy: o1.y - o0.y },\n };\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/core/ops/transform.ts","../src/core/ops/reparent.ts","../src/interactions/gestures/shared/snap.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,kBAAyB,IAAA,EAAgC;AACvE,EAAA,MAAM,EAAE,IAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,GAAc,CAAA,UAAA,EAAa,EAAE,CAAA,CAAA,EAAG,GAAI,IAAA;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,MAAM,EAAE,EAAA,EAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,EAAY;AAAA,IACzC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAM,OAAA,EAAS;AAOb,MAAC,OAAA,CAAoC,OAAA,CAAQ,EAAA,EAAI,EAAE,CAAA;AACnD,MAAA,IAAI,gBAAA,CAAiB,IAAA,EAAM,EAAE,CAAA,EAAG,OAAO,KAAA;AACvC,MAAA,OAAO,MAAA;AAAA,IACT,CAAA;AAAA,IACA,MAAA,GAAS;AACP,MAAA,OAAO,iBAAA,CAAyB,EAAE,EAAA,EAAI,IAAA,EAAM,IAAI,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,CAAA;AAAA,IAChF;AAAA,GACF;AACF;AAEA,iBAAA,CAA0C,WAAA,EAAa,CAAC,IAAA,KAAS,iBAAA,CAAkB,IAAI,CAAC,CAAA;AAExF,SAAS,gBAAA,CAAwB,GAAU,CAAA,EAAmB;AAC5D,EAAA,IAAI,CAAA,KAAM,GAAG,OAAO,IAAA;AACpB,EAAA,IAAI,CAAA,KAAM,IAAA,IAAQ,CAAA,KAAM,IAAA,IAAQ,OAAO,MAAM,QAAA,IAAY,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,KAAA;AACvF,EAAA,MAAM,EAAA,GAAK,MAAA,CAAO,IAAA,CAAK,CAAW,CAAA;AAClC,EAAA,MAAM,EAAA,GAAK,MA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AA,CAAG,CAAA,EAAG,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA;AAAE,OACnE;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-44EWMJV2.js","sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface TransformAdapter<TPose> {\n setPose(id: string, pose: TPose): void;\n}\n\n/** @internal */\ninterface TransformArgs<TPose> {\n id: string;\n from: TPose;\n to: TPose;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Op: set an object's pose, inverting back to `from`. `coalesceKey` defaults to\n * `transform:${id}` so successive pose writes to the same node (drag-move,\n * resize, repeated nudges) merge into one undo entry within the history's\n * coalesce window. Pass an explicit key (or a unique one) to opt out. */\nexport function createTransformOp<TPose>(args: TransformArgs<TPose>): Op {\n const { id, from, to, label, coalesceKey = `transform:${id}` } = args;\n return {\n name: 'transform',\n args: { id, from, to, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n // Always call setPose so consumers that inspect op behavior (tests,\n // overlays) see a consistent \"this op writes (id, to)\" signal. When\n // from and to are structurally identical, additionally report a\n // no-op to history so the entry can be skipped from the undo stack.\n // setPose(id, to) is idempotent in this branch — adapters write the\n // same pose they already had.\n (adapter as TransformAdapter<TPose>).setPose(id, to);\n if (poseShallowEqual(from, to)) return false;\n return undefined;\n },\n invert() {\n return createTransformOp<TPose>({ id, from: to, to: from, label, coalesceKey });\n },\n };\n}\n\nregisterOpFactory<TransformArgs<unknown>>('transform', (args) => createTransformOp(args));\n\nfunction poseShallowEqual<TPose>(a: TPose, b: TPose): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n for (const k of ka) {\n if ((a as Record<string, unknown>)[k] !== (b as Record<string, unknown>)[k]) return false;\n }\n return true;\n}\n","import type { Op } from './types';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, resolveSlot, slotFromIndex, type OrderedReader, type Slot } from './slot';\n\ninterface ReparentAdapter extends OrderedReader {\n setParent(id: string, parentId: string | null): void;\n /** Sibling-order write, paired with `getChildren`. Optional: an adapter\n * without both silently ignores slots and appends. */\n setChildOrder?(parentId: string | null, ids: string[]): void;\n}\n\n/** @internal */\ninterface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n /** Sibling ordinal under the old parent. Sugar for `fromSlot: { index }`,\n * and only a seed: `apply` re-observes the node's full slot through the\n * adapter and that observation supersedes this. */\n fromIndex?: number;\n /** Sibling ordinal under the new parent. Sugar for `toSlot: { index }`.\n * Omit to append. */\n toIndex?: number;\n /** Slot under the old parent, anchor included. `invert()` forwards it as\n * the destination slot; without it undo re-parents with no position and\n * the node lands last, quietly changing paint order. */\n fromSlot?: Slot;\n /** Slot under the new parent, anchor included. Omit to append. */\n toSlot?: Slot;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Move `id` to `slot` among `parentId`'s children. No-op when the adapter\n * has no ordering seam, when `id` isn't there, or when it's already in\n * place. */\nfunction placeAt(\n a: ReparentAdapter,\n parentId: string | null,\n id: string,\n slot: Slot,\n): void {\n if (!a.getChildren || !a.setChildOrder) return;\n const current = a.getChildren(parentId);\n const from = current.indexOf(id);\n if (from < 0) return;\n const next = current.slice();\n next.splice(from, 1);\n const resolved = resolveSlot(next, slot);\n const to = resolved === undefined ? next.length : Math.max(0, Math.min(resolved, next.length));\n if (from === to) return;\n next.splice(to, 0, id);\n a.setChildOrder(parentId, next);\n}\n\n/** Present when the caller named a destination at all; `undefined` leaves\n * placement to the adapter. */\nfunction optionalSlot(slot: Slot | undefined, index: number | undefined): Slot | undefined {\n if (slot) return slot;\n return index === undefined ? undefined : slotFromIndex(index);\n}\n\n/**\n * Op: change `id`'s parent and sibling slot, inverting back to the prior\n * parent and slot.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const {\n id, fromParentId, toParentId,\n label = 'Reparent', coalesceKey = `reparent:${id}`,\n } = args;\n let fromSlot = optionalSlot(args.fromSlot, args.fromIndex);\n const toSlot = optionalSlot(args.toSlot, args.toIndex);\n const argsForSerial: ReparentArgs = {\n id, fromParentId, toParentId, fromSlot, toSlot, label, coalesceKey,\n };\n return {\n name: 'reparent',\n args: argsForSerial,\n label,\n coalesceKey,\n apply(adapter) {\n const a = adapter as ReparentAdapter;\n const observed = captureSlot(a, fromParentId, id);\n if (observed) {\n fromSlot = observed;\n argsForSerial.fromSlot = observed;\n }\n a.setParent(id, toParentId);\n if (toSlot) placeAt(a, toParentId, id, toSlot);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n fromSlot: toSlot,\n toSlot: fromSlot,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n","import type { MoveBehavior, ModifierState, SnapStrategy } from '../types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from './strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/**\n * Generic snap behavior factory: wraps a `SnapStrategy` and returns a\n * `MoveBehavior` whose `onMove` returns a uniform `GroupTransform`.\n *\n * Implementation:\n * 1. Compute the primary's proposed pose by applying the gesture's\n * `transform` (translate) to `origin.get(primaryId)`.\n * 2. Call `strategy.snap(proposed)`. If null, no-op.\n * 3. Derive the snapped delta via the `OriginProjection`:\n * dx = origin(snapped).x - origin(originPose).x\n * ...so the gesture applies the same delta to every dragged id.\n *\n * The pose-shape-aware delta extraction lives here — gestures stay pose-shape\n * agnostic. Default projection is `{x, y}`-bearing (rect / path / polygon).\n * Pass `origin` for exotic poses.\n */\nexport function snap<TPose>(\n strategy: SnapStrategy<TPose>,\n opts: { bypassKey?: ModKey; origin?: OriginProjection<TPose> } = {},\n): MoveBehavior<TPose> {\n const { bypassKey } = opts;\n const proj: OriginProjection<TPose> = opts.origin\n ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n return {\n onMove(ctx, transform) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n // The new contract: behaviors see a GroupTransform, not a pose. But\n // strategies still operate on poses. Reconstruct the proposed pose\n // by applying the (translate) transform to the primary's origin.\n if (transform.kind !== 'translate') return;\n const primaryId = ctx.draggedIds[0];\n if (primaryId === undefined) return;\n const originPose = ctx.origin.get(primaryId);\n if (originPose === undefined) return;\n const proposed = proj.translate(originPose, transform.dx, transform.dy);\n const snapped = strategy.snap(proposed, ctx);\n if (snapped === null) return;\n const o0 = proj.getOrigin(originPose);\n const o1 = proj.getOrigin(snapped);\n return {\n transform: { kind: 'translate', dx: o1.x - o0.x, dy: o1.y - o0.y },\n };\n },\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-HAGOFNP5.js';
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-HPFJUUTF.js';
2
2
 
3
3
  // src/interactions/actions/resize/behaviors/clampMinSize.ts
4
4
  function clampMinSize(args) {
@@ -244,5 +244,5 @@ function fixedCornerOf(bounds, anchor) {
244
244
  }
245
245
 
246
246
  export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides };
247
- //# sourceMappingURL=chunk-XXQ6FLCJ.js.map
248
- //# sourceMappingURL=chunk-XXQ6FLCJ.js.map
247
+ //# sourceMappingURL=chunk-H6N2JSZ3.js.map
248
+ //# sourceMappingURL=chunk-H6N2JSZ3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interactions/actions/resize/behaviors/clampMinSize.ts","../src/interactions/actions/resize/behaviors/lockAspect.ts","../src/interactions/actions/resize/behaviors/snapToGrid.ts","../src/interactions/actions/resize/behaviors/snapToGuides.ts","../src/interactions/actions/resize/behaviors/pointSnapToGrid.ts","../src/interactions/actions/resize/behaviors/index.ts","../src/interactions/actions/resize/cornerHandles.ts"],"names":[],"mappings":";;;AAMO,SAAS,aAAmC,IAAA,EAGvB;AAC1B,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,IAAA;AAChC,EAAA,OAAO;AAAA,IACL,MAAA,CAAO,IAAA,EAAM,EAAE,IAAA,EAAM,QAAO,EAAG;AAC7B,MAAA,IAAI,EAAE,CAAA,EAAG,CAAA,EAAG,KAAA,EAAO,QAAO,GAAI,IAAA;AAC9B,MAAA,IAAI,OAAA,GAAU,KAAA;AACd,MAAA,IAAI,MAAA,CAAO,CAAA,KAAM,MAAA,IAAU,KAAA,GAAQ,QAAA,EAAU;AAC3C,QAAA,IAAI,MAAA,CAAO,MAAM,KAAA,EAAO;AAEtB,UAAA,KAAA,GAAQ,QAAA;AAAA,QACV,CAAA,MAAO;AAGL,UAAA,MAAM,QAAQ,CAAA,GAAI,KAAA;AAClB,UAAA,CAAA,GAAI,KAAA,GAAQ,QAAA;AACZ,UAAA,KAAA,GAAQ,QAAA;AAAA,QACV;AACA,QAAA,OAAA,GAAU,IAAA;AAAA,MACZ;AACA,MAAA,IAAI,MAAA,CAAO,CAAA,KAAM,MAAA,IAAU,MAAA,GAAS,SAAA,EAAW;AAC7C,QAAA,IAAI,MAAA,CAAO,MAAM,KAAA,EAAO;AACtB,UAAA,MAAA,GAAS,SAAA;AAAA,QACX,CAAA,MAAO;AACL,UAAA,MAAM,SAAS,CAAA,GAAI,MAAA;AACnB,UAAA,CAAA,GAAI,MAAA,GAAS,SAAA;AACb,UAAA,MAAA,GAAS,SAAA;AAAA,QACX;AACA,QAAA,OAAA,GAAU,IAAA;AAAA,MACZ;AACA,MAAA,IAAI,CAAC,OAAA,EAAS;AACd,MAAA,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA,EAAG,CAAA,EAAG,KAAA,EAAO,MAA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A,CAAO,EAAE,CAAA,IAAK,MAAA;AACnC;AAWO,SAAS,aAAA,CACd,QACA,MAAA,EAC0B;AAC1B,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,OAAO,CAAA,KAAM,KAAA,GAAQ,OAAO,CAAA,GAAI,MAAA,CAAO,QAAQ,MAAA,CAAO,CAAA;AAAA,IACzD,CAAA,EAAG,OAAO,CAAA,KAAM,KAAA,GAAQ,OAAO,CAAA,GAAI,MAAA,CAAO,SAAS,MAAA,CAAO;AAAA,GAC5D;AACF","file":"chunk-XXQ6FLCJ.js","sourcesContent":["import type { BoundsConstraint } from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Resize constraint that stops a node shrinking past a minimum. The anchored\n * edge stays put, so clamping pushes the dragged edge back rather than moving\n * the node. */\nexport function clampMinSize<TPose extends Bounds>(args: {\n minWidth: number;\n minHeight: number;\n}): BoundsConstraint<TPose> {\n const { minWidth, minHeight } = args;\n return {\n onMove(_ctx, { pose, anchor }) {\n let { x, y, width, height } = pose;\n let changed = false;\n if (anchor.x !== 'free' && width < minWidth) {\n if (anchor.x === 'min') {\n // West edge is anchor; east edge was dragged. Hold x; widen to min.\n width = minWidth;\n } else {\n // East edge is anchor at originalRight = x + width. Hold the right;\n // shift x left so width = minWidth.\n const right = x + width;\n x = right - minWidth;\n width = minWidth;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && height < minHeight) {\n if (anchor.y === 'min') {\n height = minHeight;\n } else {\n const bottom = y + height;\n y = bottom - minHeight;\n height = minHeight;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Aspect-ratio lock: drag a corner/edge with `key` (default `'shift'`) held\n * to keep the resized bounds at the start-pose's `width / height` ratio.\n *\n * Strategy:\n * - Compute the proposed deltas in width and height (signed, relative to\n * origin). Whichever axis has the larger absolute delta \"wins\"; the other\n * is recomputed from `(originW / originH) * winnerDelta`.\n * - The opposite corner/edge stays anchored — for the corner case we infer\n * the anchor from the proposed bounds; for an edge handle we resize the\n * orthogonal axis symmetrically around the dragged edge's anchor (the\n * handle's own line stays put, the orthogonal axis grows/shrinks centered\n * on the un-dragged edge — see notes below).\n * - No-op when the modifier is not held, when the origin has zero width or\n * height (no defined ratio), or when the proposed pose hasn't moved.\n *\n * Edge-handle handling: with `anchor.x !== 'free' && anchor.y === 'free'`\n * (an `e` or `w` handle), only the width was driven by the pointer. We pick\n * the new height as `width / ratio` and pin it to the un-dragged y axis by\n * anchoring at the origin's top edge (`y` stays at `origin.y`). Symmetric\n * for `n` / `s`.\n */\nexport function lockAspectWithModifier<TPose extends Bounds>(opts: {\n key?: ModKey;\n} = {}): BoundsConstraint<TPose> {\n const { key = 'shift' } = opts;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (!ctx.modifiers[key]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0]) as Bounds | undefined;\n if (!origin) return;\n if (origin.width === 0 || origin.height === 0) return;\n const ratio = origin.width / origin.height; // w / h\n\n // Signed deltas relative to origin. Negative deltas mean the user has\n // dragged through the anchor and flipped the rect; we preserve sign on\n // the recomputed axis so the flipped quadrant stays consistent.\n const dw = pose.width - origin.width;\n const dh = pose.height - origin.height;\n\n let nw: number;\n let nh: number;\n\n if (anchor.x === 'free' && anchor.y === 'free') {\n // No driven axis — nothing to lock against.\n return;\n } else if (anchor.x === 'free') {\n // Edge handle: n or s. height is driven; width follows.\n nh = pose.height;\n nw = nh * ratio;\n // sign-preserve width if the original height delta caused a flip.\n // (height-driven only; width direction follows ratio absolutely.)\n if (nw < 0) nw = -nw;\n } else if (anchor.y === 'free') {\n // Edge handle: e or w. width is driven; height follows.\n nw = pose.width;\n nh = nw / ratio;\n if (nh < 0) nh = -nh;\n } else {\n // Corner handle. Pick the dominant axis by absolute delta.\n if (Math.abs(dw) >= Math.abs(dh)) {\n nw = pose.width;\n // Match height sign to width sign so the rect stays in the same\n // quadrant the pointer chose.\n nh = (Math.abs(nw) / ratio) * Math.sign(pose.height || 1);\n } else {\n nh = pose.height;\n nw = (Math.abs(nh) * ratio) * Math.sign(pose.width || 1);\n }\n }\n\n // Recompute x/y from the anchor (the un-dragged edge stays pinned).\n let nx = pose.x;\n let ny = pose.y;\n if (anchor.x === 'min') {\n // West edge anchored at origin.x.\n nx = origin.x;\n } else if (anchor.x === 'max') {\n // East edge anchored at origin.x + origin.width.\n nx = origin.x + origin.width - nw;\n } else {\n // Edge handle (n/s): width grew/shrunk via ratio. Center horizontally\n // about the origin's center so the rect stays visually centered on\n // the dragged edge's midline.\n nx = origin.x + origin.width / 2 - nw / 2;\n }\n if (anchor.y === 'min') {\n ny = origin.y;\n } else if (anchor.y === 'max') {\n ny = origin.y + origin.height - nh;\n } else {\n ny = origin.y + origin.height / 2 - nh / 2;\n }\n\n return {\n pose: { ...pose, x: nx, y: ny, width: nw, height: nh },\n };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Resize constraint that snaps the moving edges to a grid, leaving the\n * anchored ones where they are. By default a node already smaller than one\n * grid cell on an axis is left unsnapped on that axis, so it stays resizable\n * at sub-grid sizes. */\nexport function snapToGrid<TPose extends Bounds>(args: {\n spacing: number;\n bypassKey?: ModKey;\n suspendBelowDim?: boolean;\n}): BoundsConstraint<TPose> {\n const { spacing, bypassKey, suspendBelowDim = true } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0])!;\n const subX = suspendBelowDim && origin.width < spacing;\n const subY = suspendBelowDim && origin.height < spacing;\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n if (anchor.x !== 'free' && !subX) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n const east = round(x + width);\n width = east - x;\n } else {\n // West edge moves; east (x+width) stays.\n const right = origin.x + origin.width;\n const newX = round(x);\n width = right - newX;\n x = newX;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && !subY) {\n if (anchor.y === 'min') {\n const south = round(y + height);\n height = south - y;\n } else {\n const bottom = origin.y + origin.height;\n const newY = round(y);\n height = bottom - newY;\n y = newY;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\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';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the resize-flavored `snapToGuides`. */\nexport interface SnapToGuidesResizeArgs {\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\n/**\n * Resize behavior that snaps the active edge of the dragged rect to the\n * nearest guide on the corresponding axis when within `tolerance`. The\n * \"free\" axis is left untouched. The fixed (anchor) edge stays pinned;\n * only the moving edge snaps.\n *\n * On the X axis, vertical guides (`axis: 'x'`) constrain the moving vertical\n * edge — east when `anchor.x === 'min'` (west pinned), west when `'max'`.\n * Likewise on Y for horizontal guides.\n */\nexport function snapToGuides<TPose extends Bounds>(\n args: SnapToGuidesResizeArgs,\n): BoundsConstraint<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const tol = getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n // X-axis: snap the moving vertical edge to the nearest 'x' guide.\n if (anchor.x !== 'free') {\n const movingX = anchor.x === 'min' ? x + width : x;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'x') continue;\n const d = g.offset - movingX;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n width = width + bestD;\n } else {\n // West edge moves; east (x+width) stays.\n x = x + bestD;\n width = width - bestD;\n }\n changed = true;\n }\n }\n\n // Y-axis: snap the moving horizontal edge to the nearest 'y' guide.\n if (anchor.y !== 'free') {\n const movingY = anchor.y === 'min' ? y + height : y;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'y') continue;\n const d = g.offset - movingY;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.y === 'min') {\n height = height + bestD;\n } else {\n y = y + bestD;\n height = height - bestD;\n }\n changed = true;\n }\n }\n\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n PointSnapBehavior,\n PointSnapContext,\n PointSnapFrame,\n PointSnapResult,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Resize behavior that snaps one reference point of the resize — the dragged\n * corner, the fixed corner, or the center, per `frame` — to a grid, moving\n * the whole pose by the same delta. Unlike the bounds-level `snapToGrid`,\n * this preserves the node's dimensions. */\nexport function pointSnapToGrid<TPose extends Bounds>(args: {\n spacing: number;\n frame?: PointSnapFrame;\n bypassKey?: keyof ModifierState;\n}): PointSnapBehavior<TPose> {\n const { spacing, frame = 'dragged-corner', bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n id: `pointSnapToGrid:${frame}`,\n onMove(ctx: PointSnapContext<TPose>): PointSnapResult | null {\n if (bypassKey && ctx.modifiers[bypassKey]) return null;\n const src =\n frame === 'dragged-corner' ? ctx.draggedCorner :\n frame === 'fixed-corner' ? ctx.fixedCorner :\n frame === 'center' ? ctx.center :\n ctx.origin;\n if (!src) return null;\n return { frame, worldX: round(src.worldX), worldY: round(src.worldY) };\n },\n };\n}\n","export { clampMinSize } from './clampMinSize';\nexport { lockAspectWithModifier } from './lockAspect';\nexport { snapToGrid } from './snapToGrid';\n\nimport type { BoundsConstraint } from '../../../gestures/types';\nimport { lockAspectWithModifier } from './lockAspect';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** The kit's standard resize behaviors, applied when a consumer doesn't\n * supply its own list: shift-drag locks the start pose's aspect ratio.\n * Pass an explicit `behaviors: []` to opt out. Stateless, so one shared\n * frozen instance is safe across every gesture. */\nexport const DEFAULT_RESIZE_BEHAVIORS: readonly BoundsConstraint<Bounds>[] =\n Object.freeze([lockAspectWithModifier()]);\nexport { snapToGuides } from './snapToGuides';\nexport { pointSnapToGrid } from './pointSnapToGrid';\n","import type { ResizeAnchor } from '../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Corner resize-handle: world-space center plus the anchor that pins the opposite corner during resize. */\nexport interface CornerHandle {\n cx: number;\n cy: number;\n anchor: ResizeAnchor;\n}\n\n/** Which AABB edge a corner sits on, per axis. `'min'` = the x/y origin\n * edge; `'max'` = the origin + extent edge. */\nexport type CornerEdge = 'min' | 'max';\n\n/** One entry of the canonical 4-corner resize layout. The single source of\n * truth for \"which corner maps to which anchor / handle-kind\". */\nexport interface CornerAnchor {\n /** Which x-edge the corner sits on (`'min'` = left, `'max'` = right). */\n xEdge: CornerEdge;\n /** Which y-edge the corner sits on (`'min'` = top, `'max'` = bottom). */\n yEdge: CornerEdge;\n /** Anchor that pins the diagonally-opposite (fixed) corner. Always the\n * axis-wise opposite of `{xEdge, yEdge}`. */\n anchor: ResizeAnchor;\n /** Affordance/handle discriminator string for this corner. */\n kind: string;\n /** Short positional tag (`'<xEdge>-<yEdge>'`), e.g. `'min-max'`. */\n tag: string;\n}\n\n/**\n * The single ordered corner→anchor table. Order is **load-bearing**: every\n * consumer iterates it in this sequence (TL, TR, BL, BR) so positional\n * meaning (the i-th handle / `kind` / `tag`) stays consistent across the\n * resize-handle affordance, the affordance-hit classifier, and\n * `cornerResizeHandles`. Each corner's `anchor` names the diagonally\n * opposite corner, so dragging the corner scales the box from that fixed\n * point.\n */\nexport const CORNER_ANCHORS: readonly CornerAnchor[] = [\n { xEdge: 'min', yEdge: 'min', anchor: { x: 'max', y: 'max' }, kind: 'handle:top-left', tag: 'min-min' },\n { xEdge: 'max', yEdge: 'min', anchor: { x: 'min', y: 'max' }, kind: 'handle:top-right', tag: 'max-min' },\n { xEdge: 'min', yEdge: 'max', anchor: { x: 'max', y: 'min' }, kind: 'handle:bottom-left', tag: 'min-max' },\n { xEdge: 'max', yEdge: 'max', anchor: { x: 'min', y: 'min' }, kind: 'handle:bottom-right', tag: 'max-max' },\n];\n\n/** Resolve a corner's world-space position for the given bounds. `xEdge`\n * `'max'` → `x + width`; `yEdge` `'max'` → `y + height`. */\nexport function cornerPoint(\n bounds: Bounds,\n entry: Pick<CornerAnchor, 'xEdge' | 'yEdge'>,\n): { x: number; y: number } {\n return {\n x: entry.xEdge === 'max' ? bounds.x + bounds.width : bounds.x,\n y: entry.yEdge === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n\n/** Standard 4-corner resize-handle layout: each corner pins the opposite\n * corner via an anchor of `{x: 'min'|'max', y: 'min'|'max'}` so dragging it\n * scales the box from the fixed opposite corner. Decodes {@link CORNER_ANCHORS}\n * against `bounds`. */\nexport function cornerResizeHandles(bounds: Bounds): CornerHandle[] {\n return CORNER_ANCHORS.map((c) => {\n const p = cornerPoint(bounds, c);\n return { cx: p.x, cy: p.y, anchor: c.anchor };\n });\n}\n\n/** Square hit-test for a handle: returns true if `(px, py)` is within\n * `radius` of the handle center on both axes. */\nexport function hitCornerHandle(\n handle: CornerHandle,\n px: number,\n py: number,\n radius: number,\n): boolean {\n return Math.abs(px - handle.cx) <= radius\n && Math.abs(py - handle.cy) <= radius;\n}\n\n/** The corner that does NOT move under a resize gesture with the given\n * anchor. Used by the rotated-resize math to pin a world-space invariant.\n *\n * Convention: `anchor.x === 'min'` means the min-x (left) edge is the\n * fixed anchor, so the fixed corner sits at `x = bounds.x` (min-x).\n * `anchor.x === 'max'` means the max-x (right) edge is fixed, so the\n * fixed corner sits at `x = bounds.x + bounds.width`. `'free'` on an\n * axis means that axis doesn't move; the fixed coord is the bounds\n * origin on that axis. */\nexport function fixedCornerOf(\n bounds: Bounds,\n anchor: ResizeAnchor,\n): { x: number; y: number } {\n return {\n x: anchor.x === 'max' ? bounds.x + bounds.width : bounds.x,\n y: anchor.y === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/interactions/actions/resize/behaviors/clampMinSize.ts","../src/interactions/actions/resize/behaviors/lockAspect.ts","../src/interactions/actions/resize/behaviors/snapToGrid.ts","../src/interactions/actions/resize/behaviors/snapToGuides.ts","../src/interactions/actions/resize/behaviors/pointSnapToGrid.ts","../src/interactions/actions/resize/behaviors/index.ts","../src/interactions/actions/resize/cornerHandles.ts"],"names":[],"mappings":";;;AAMO,SAAS,aAAmC,IAAA,EAGvB;AAC1B,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,IAAA;AAChC,EAAA,O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AG,OAAO,CAAA,KAAM,KAAA,GAAQ,OAAO,CAAA,GAAI,MAAA,CAAO,SAAS,MAAA,CAAO;AAAA,GAC5D;AACF","file":"chunk-H6N2JSZ3.js","sourcesContent":["import type { BoundsConstraint } from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Resize constraint that stops a node shrinking past a minimum. The anchored\n * edge stays put, so clamping pushes the dragged edge back rather than moving\n * the node. */\nexport function clampMinSize<TPose extends Bounds>(args: {\n minWidth: number;\n minHeight: number;\n}): BoundsConstraint<TPose> {\n const { minWidth, minHeight } = args;\n return {\n onMove(_ctx, { pose, anchor }) {\n let { x, y, width, height } = pose;\n let changed = false;\n if (anchor.x !== 'free' && width < minWidth) {\n if (anchor.x === 'min') {\n // West edge is anchor; east edge was dragged. Hold x; widen to min.\n width = minWidth;\n } else {\n // East edge is anchor at originalRight = x + width. Hold the right;\n // shift x left so width = minWidth.\n const right = x + width;\n x = right - minWidth;\n width = minWidth;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && height < minHeight) {\n if (anchor.y === 'min') {\n height = minHeight;\n } else {\n const bottom = y + height;\n y = bottom - minHeight;\n height = minHeight;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Aspect-ratio lock: drag a corner/edge with `key` (default `'shift'`) held\n * to keep the resized bounds at the start-pose's `width / height` ratio.\n *\n * Strategy:\n * - Compute the proposed deltas in width and height (signed, relative to\n * origin). Whichever axis has the larger absolute delta \"wins\"; the other\n * is recomputed from `(originW / originH) * winnerDelta`.\n * - The opposite corner/edge stays anchored — for the corner case we infer\n * the anchor from the proposed bounds; for an edge handle we resize the\n * orthogonal axis symmetrically around the dragged edge's anchor (the\n * handle's own line stays put, the orthogonal axis grows/shrinks centered\n * on the un-dragged edge — see notes below).\n * - No-op when the modifier is not held, when the origin has zero width or\n * height (no defined ratio), or when the proposed pose hasn't moved.\n *\n * Edge-handle handling: with `anchor.x !== 'free' && anchor.y === 'free'`\n * (an `e` or `w` handle), only the width was driven by the pointer. We pick\n * the new height as `width / ratio` and pin it to the un-dragged y axis by\n * anchoring at the origin's top edge (`y` stays at `origin.y`). Symmetric\n * for `n` / `s`.\n */\nexport function lockAspectWithModifier<TPose extends Bounds>(opts: {\n key?: ModKey;\n} = {}): BoundsConstraint<TPose> {\n const { key = 'shift' } = opts;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (!ctx.modifiers[key]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0]) as Bounds | undefined;\n if (!origin) return;\n if (origin.width === 0 || origin.height === 0) return;\n const ratio = origin.width / origin.height; // w / h\n\n // Signed deltas relative to origin. Negative deltas mean the user has\n // dragged through the anchor and flipped the rect; we preserve sign on\n // the recomputed axis so the flipped quadrant stays consistent.\n const dw = pose.width - origin.width;\n const dh = pose.height - origin.height;\n\n let nw: number;\n let nh: number;\n\n if (anchor.x === 'free' && anchor.y === 'free') {\n // No driven axis — nothing to lock against.\n return;\n } else if (anchor.x === 'free') {\n // Edge handle: n or s. height is driven; width follows.\n nh = pose.height;\n nw = nh * ratio;\n // sign-preserve width if the original height delta caused a flip.\n // (height-driven only; width direction follows ratio absolutely.)\n if (nw < 0) nw = -nw;\n } else if (anchor.y === 'free') {\n // Edge handle: e or w. width is driven; height follows.\n nw = pose.width;\n nh = nw / ratio;\n if (nh < 0) nh = -nh;\n } else {\n // Corner handle. Pick the dominant axis by absolute delta.\n if (Math.abs(dw) >= Math.abs(dh)) {\n nw = pose.width;\n // Match height sign to width sign so the rect stays in the same\n // quadrant the pointer chose.\n nh = (Math.abs(nw) / ratio) * Math.sign(pose.height || 1);\n } else {\n nh = pose.height;\n nw = (Math.abs(nh) * ratio) * Math.sign(pose.width || 1);\n }\n }\n\n // Recompute x/y from the anchor (the un-dragged edge stays pinned).\n let nx = pose.x;\n let ny = pose.y;\n if (anchor.x === 'min') {\n // West edge anchored at origin.x.\n nx = origin.x;\n } else if (anchor.x === 'max') {\n // East edge anchored at origin.x + origin.width.\n nx = origin.x + origin.width - nw;\n } else {\n // Edge handle (n/s): width grew/shrunk via ratio. Center horizontally\n // about the origin's center so the rect stays visually centered on\n // the dragged edge's midline.\n nx = origin.x + origin.width / 2 - nw / 2;\n }\n if (anchor.y === 'min') {\n ny = origin.y;\n } else if (anchor.y === 'max') {\n ny = origin.y + origin.height - nh;\n } else {\n ny = origin.y + origin.height / 2 - nh / 2;\n }\n\n return {\n pose: { ...pose, x: nx, y: ny, width: nw, height: nh },\n };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Resize constraint that snaps the moving edges to a grid, leaving the\n * anchored ones where they are. By default a node already smaller than one\n * grid cell on an axis is left unsnapped on that axis, so it stays resizable\n * at sub-grid sizes. */\nexport function snapToGrid<TPose extends Bounds>(args: {\n spacing: number;\n bypassKey?: ModKey;\n suspendBelowDim?: boolean;\n}): BoundsConstraint<TPose> {\n const { spacing, bypassKey, suspendBelowDim = true } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0])!;\n const subX = suspendBelowDim && origin.width < spacing;\n const subY = suspendBelowDim && origin.height < spacing;\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n if (anchor.x !== 'free' && !subX) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n const east = round(x + width);\n width = east - x;\n } else {\n // West edge moves; east (x+width) stays.\n const right = origin.x + origin.width;\n const newX = round(x);\n width = right - newX;\n x = newX;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && !subY) {\n if (anchor.y === 'min') {\n const south = round(y + height);\n height = south - y;\n } else {\n const bottom = origin.y + origin.height;\n const newY = round(y);\n height = bottom - newY;\n y = newY;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\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';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the resize-flavored `snapToGuides`. */\nexport interface SnapToGuidesResizeArgs {\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\n/**\n * Resize behavior that snaps the active edge of the dragged rect to the\n * nearest guide on the corresponding axis when within `tolerance`. The\n * \"free\" axis is left untouched. The fixed (anchor) edge stays pinned;\n * only the moving edge snaps.\n *\n * On the X axis, vertical guides (`axis: 'x'`) constrain the moving vertical\n * edge — east when `anchor.x === 'min'` (west pinned), west when `'max'`.\n * Likewise on Y for horizontal guides.\n */\nexport function snapToGuides<TPose extends Bounds>(\n args: SnapToGuidesResizeArgs,\n): BoundsConstraint<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const tol = getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n // X-axis: snap the moving vertical edge to the nearest 'x' guide.\n if (anchor.x !== 'free') {\n const movingX = anchor.x === 'min' ? x + width : x;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'x') continue;\n const d = g.offset - movingX;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n width = width + bestD;\n } else {\n // West edge moves; east (x+width) stays.\n x = x + bestD;\n width = width - bestD;\n }\n changed = true;\n }\n }\n\n // Y-axis: snap the moving horizontal edge to the nearest 'y' guide.\n if (anchor.y !== 'free') {\n const movingY = anchor.y === 'min' ? y + height : y;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'y') continue;\n const d = g.offset - movingY;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.y === 'min') {\n height = height + bestD;\n } else {\n y = y + bestD;\n height = height - bestD;\n }\n changed = true;\n }\n }\n\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n PointSnapBehavior,\n PointSnapContext,\n PointSnapFrame,\n PointSnapResult,\n} from '../../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Resize behavior that snaps one reference point of the resize — the dragged\n * corner, the fixed corner, or the center, per `frame` — to a grid, moving\n * the whole pose by the same delta. Unlike the bounds-level `snapToGrid`,\n * this preserves the node's dimensions. */\nexport function pointSnapToGrid<TPose extends Bounds>(args: {\n spacing: number;\n frame?: PointSnapFrame;\n bypassKey?: keyof ModifierState;\n}): PointSnapBehavior<TPose> {\n const { spacing, frame = 'dragged-corner', bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n id: `pointSnapToGrid:${frame}`,\n onMove(ctx: PointSnapContext<TPose>): PointSnapResult | null {\n if (bypassKey && ctx.modifiers[bypassKey]) return null;\n const src =\n frame === 'dragged-corner' ? ctx.draggedCorner :\n frame === 'fixed-corner' ? ctx.fixedCorner :\n frame === 'center' ? ctx.center :\n ctx.origin;\n if (!src) return null;\n return { frame, worldX: round(src.worldX), worldY: round(src.worldY) };\n },\n };\n}\n","export { clampMinSize } from './clampMinSize';\nexport { lockAspectWithModifier } from './lockAspect';\nexport { snapToGrid } from './snapToGrid';\n\nimport type { BoundsConstraint } from '../../../gestures/types';\nimport { lockAspectWithModifier } from './lockAspect';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** The kit's standard resize behaviors, applied when a consumer doesn't\n * supply its own list: shift-drag locks the start pose's aspect ratio.\n * Pass an explicit `behaviors: []` to opt out. Stateless, so one shared\n * frozen instance is safe across every gesture. */\nexport const DEFAULT_RESIZE_BEHAVIORS: readonly BoundsConstraint<Bounds>[] =\n Object.freeze([lockAspectWithModifier()]);\nexport { snapToGuides } from './snapToGuides';\nexport { pointSnapToGrid } from './pointSnapToGrid';\n","import type { ResizeAnchor } from '../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Corner resize-handle: world-space center plus the anchor that pins the opposite corner during resize. */\nexport interface CornerHandle {\n cx: number;\n cy: number;\n anchor: ResizeAnchor;\n}\n\n/** Which AABB edge a corner sits on, per axis. `'min'` = the x/y origin\n * edge; `'max'` = the origin + extent edge. */\nexport type CornerEdge = 'min' | 'max';\n\n/** One entry of the canonical 4-corner resize layout. The single source of\n * truth for \"which corner maps to which anchor / handle-kind\". */\nexport interface CornerAnchor {\n /** Which x-edge the corner sits on (`'min'` = left, `'max'` = right). */\n xEdge: CornerEdge;\n /** Which y-edge the corner sits on (`'min'` = top, `'max'` = bottom). */\n yEdge: CornerEdge;\n /** Anchor that pins the diagonally-opposite (fixed) corner. Always the\n * axis-wise opposite of `{xEdge, yEdge}`. */\n anchor: ResizeAnchor;\n /** Affordance/handle discriminator string for this corner. */\n kind: string;\n /** Short positional tag (`'<xEdge>-<yEdge>'`), e.g. `'min-max'`. */\n tag: string;\n}\n\n/**\n * The single ordered corner→anchor table. Order is **load-bearing**: every\n * consumer iterates it in this sequence (TL, TR, BL, BR) so positional\n * meaning (the i-th handle / `kind` / `tag`) stays consistent across the\n * resize-handle affordance, the affordance-hit classifier, and\n * `cornerResizeHandles`. Each corner's `anchor` names the diagonally\n * opposite corner, so dragging the corner scales the box from that fixed\n * point.\n */\nexport const CORNER_ANCHORS: readonly CornerAnchor[] = [\n { xEdge: 'min', yEdge: 'min', anchor: { x: 'max', y: 'max' }, kind: 'handle:top-left', tag: 'min-min' },\n { xEdge: 'max', yEdge: 'min', anchor: { x: 'min', y: 'max' }, kind: 'handle:top-right', tag: 'max-min' },\n { xEdge: 'min', yEdge: 'max', anchor: { x: 'max', y: 'min' }, kind: 'handle:bottom-left', tag: 'min-max' },\n { xEdge: 'max', yEdge: 'max', anchor: { x: 'min', y: 'min' }, kind: 'handle:bottom-right', tag: 'max-max' },\n];\n\n/** Resolve a corner's world-space position for the given bounds. `xEdge`\n * `'max'` → `x + width`; `yEdge` `'max'` → `y + height`. */\nexport function cornerPoint(\n bounds: Bounds,\n entry: Pick<CornerAnchor, 'xEdge' | 'yEdge'>,\n): { x: number; y: number } {\n return {\n x: entry.xEdge === 'max' ? bounds.x + bounds.width : bounds.x,\n y: entry.yEdge === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n\n/** Standard 4-corner resize-handle layout: each corner pins the opposite\n * corner via an anchor of `{x: 'min'|'max', y: 'min'|'max'}` so dragging it\n * scales the box from the fixed opposite corner. Decodes {@link CORNER_ANCHORS}\n * against `bounds`. */\nexport function cornerResizeHandles(bounds: Bounds): CornerHandle[] {\n return CORNER_ANCHORS.map((c) => {\n const p = cornerPoint(bounds, c);\n return { cx: p.x, cy: p.y, anchor: c.anchor };\n });\n}\n\n/** Square hit-test for a handle: returns true if `(px, py)` is within\n * `radius` of the handle center on both axes. */\nexport function hitCornerHandle(\n handle: CornerHandle,\n px: number,\n py: number,\n radius: number,\n): boolean {\n return Math.abs(px - handle.cx) <= radius\n && Math.abs(py - handle.cy) <= radius;\n}\n\n/** The corner that does NOT move under a resize gesture with the given\n * anchor. Used by the rotated-resize math to pin a world-space invariant.\n *\n * Convention: `anchor.x === 'min'` means the min-x (left) edge is the\n * fixed anchor, so the fixed corner sits at `x = bounds.x` (min-x).\n * `anchor.x === 'max'` means the max-x (right) edge is fixed, so the\n * fixed corner sits at `x = bounds.x + bounds.width`. `'free'` on an\n * axis means that axis doesn't move; the fixed coord is the bounds\n * origin on that axis. */\nexport function fixedCornerOf(\n bounds: Bounds,\n anchor: ResizeAnchor,\n): { x: number; y: number } {\n return {\n x: anchor.x === 'max' ? bounds.x + bounds.width : bounds.x,\n y: anchor.y === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n"]}
@@ -1,6 +1,16 @@
1
- import { isPathLike, translatePath, boundsOfPath } from './chunk-3LPQ2XZG.js';
1
+ import { isPathLike, translatePath, boundsOfPath } from './chunk-L5YNZYEG.js';
2
2
 
3
3
  // src/core/units.ts
4
+ function unitScale(unitSystem, unit) {
5
+ const entry = unitSystem.units[unit];
6
+ if (entry === void 0) {
7
+ const known = Object.keys(unitSystem.units).join(", ") || "(none)";
8
+ throw new Error(
9
+ `unknown unit '${unit}' (system base: '${unitSystem.base}', known units: ${known})`
10
+ );
11
+ }
12
+ return typeof entry === "number" ? { factor: entry, offset: 0 } : { factor: entry.factor, offset: entry.offset ?? 0 };
13
+ }
4
14
  function resolveUnit(v, unitSystem) {
5
15
  if (typeof v === "number") return v;
6
16
  if (!unitSystem) {
@@ -8,32 +18,27 @@ function resolveUnit(v, unitSystem) {
8
18
  `resolveUnit: tagged value { value: ${v.value}, unit: '${v.unit}' } requires a UnitSystem`
9
19
  );
10
20
  }
11
- const factor = unitSystem.units[v.unit];
12
- if (factor === void 0) {
13
- const known = Object.keys(unitSystem.units).join(", ") || "(none)";
14
- throw new Error(
15
- `resolveUnit: unknown unit '${v.unit}' (system base: '${unitSystem.base}', known units: ${known})`
16
- );
17
- }
18
- return v.value * factor;
21
+ const { factor, offset } = scaleOrThrow("resolveUnit", unitSystem, v.unit);
22
+ return v.value * factor + offset;
19
23
  }
20
24
  function formatUnit(baseValue, displayUnit, unitSystem, opts) {
21
- const factor = unitSystem.units[displayUnit];
22
- if (factor === void 0) {
23
- const known = Object.keys(unitSystem.units).join(", ") || "(none)";
24
- throw new Error(
25
- `formatUnit: unknown unit '${displayUnit}' (system base: '${unitSystem.base}', known units: ${known})`
26
- );
27
- }
25
+ const { factor, offset } = scaleOrThrow("formatUnit", unitSystem, displayUnit);
28
26
  const precision = opts?.precision ?? 2;
29
27
  const suffix = opts?.suffix ?? true;
30
- const display = baseValue / factor;
28
+ const display = (baseValue - offset) / factor;
31
29
  let s = display.toFixed(precision);
32
30
  if (s.includes(".")) {
33
31
  s = s.replace(/0+$/, "").replace(/\.$/, "");
34
32
  }
35
33
  return suffix ? `${s}${displayUnit}` : s;
36
34
  }
35
+ function scaleOrThrow(caller, unitSystem, unit) {
36
+ try {
37
+ return unitScale(unitSystem, unit);
38
+ } catch (e) {
39
+ throw new Error(`${caller}: ${e instanceof Error ? e.message : String(e)}`);
40
+ }
41
+ }
37
42
  var IMPERIAL_INCHES = {
38
43
  base: "in",
39
44
  units: { in: 1, ft: 12, yd: 36, mi: 63360 }
@@ -157,6 +162,6 @@ function guideSnapStrategy(getGuides, options = {}) {
157
162
  };
158
163
  }
159
164
 
160
- export { ANGLE_RADIANS, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PIXELS, RECT_ORIGIN_PROJECTION, formatUnit, gridSnapStrategy, guideSnapStrategy, pointToGridCell, pxExtent, resolveUnit, scaleDelta, withinPxBox, withinPxRadius };
161
- //# sourceMappingURL=chunk-HAGOFNP5.js.map
162
- //# sourceMappingURL=chunk-HAGOFNP5.js.map
165
+ export { ANGLE_RADIANS, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PIXELS, RECT_ORIGIN_PROJECTION, formatUnit, gridSnapStrategy, guideSnapStrategy, pointToGridCell, pxExtent, resolveUnit, scaleDelta, unitScale, withinPxBox, withinPxRadius };
166
+ //# sourceMappingURL=chunk-HPFJUUTF.js.map
167
+ //# sourceMappingURL=chunk-HPFJUUTF.js.map