@weasel-js/core 0.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +381 -0
  2. package/LICENSE +21 -0
  3. package/README.md +144 -0
  4. package/dist/DrawCommand-Dl0bXNfS.d.ts +500 -0
  5. package/dist/chunk-775XXAHR.js +216 -0
  6. package/dist/chunk-775XXAHR.js.map +1 -0
  7. package/dist/chunk-7V6JEOXE.js +27754 -0
  8. package/dist/chunk-7V6JEOXE.js.map +1 -0
  9. package/dist/chunk-AM6ARSPN.js +517 -0
  10. package/dist/chunk-AM6ARSPN.js.map +1 -0
  11. package/dist/chunk-BGGZ4CVF.js +248 -0
  12. package/dist/chunk-BGGZ4CVF.js.map +1 -0
  13. package/dist/chunk-BHVYVFGV.js +29 -0
  14. package/dist/chunk-BHVYVFGV.js.map +1 -0
  15. package/dist/chunk-CQNKCG34.js +831 -0
  16. package/dist/chunk-CQNKCG34.js.map +1 -0
  17. package/dist/chunk-GVCNT7UH.js +47 -0
  18. package/dist/chunk-GVCNT7UH.js.map +1 -0
  19. package/dist/chunk-PZ5AY32C.js +9 -0
  20. package/dist/chunk-PZ5AY32C.js.map +1 -0
  21. package/dist/chunk-UGFFCMQP.js +28 -0
  22. package/dist/chunk-UGFFCMQP.js.map +1 -0
  23. package/dist/chunk-VOVKONXA.js +103 -0
  24. package/dist/chunk-VOVKONXA.js.map +1 -0
  25. package/dist/chunk-Y52N27PF.js +39 -0
  26. package/dist/chunk-Y52N27PF.js.map +1 -0
  27. package/dist/clipboard.d.ts +91 -0
  28. package/dist/clipboard.js +6 -0
  29. package/dist/clipboard.js.map +1 -0
  30. package/dist/clone.d.ts +8 -0
  31. package/dist/clone.js +6 -0
  32. package/dist/clone.js.map +1 -0
  33. package/dist/fitViewToBounds-evGsnR8Q.d.ts +62 -0
  34. package/dist/grid-Cf87knjU.d.ts +153 -0
  35. package/dist/index-DZBYMsHI.d.ts +1555 -0
  36. package/dist/index.css +121 -0
  37. package/dist/index.css.map +1 -0
  38. package/dist/index.d.ts +10200 -0
  39. package/dist/index.js +13 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/insert.d.ts +33 -0
  42. package/dist/insert.js +81 -0
  43. package/dist/insert.js.map +1 -0
  44. package/dist/move.d.ts +69 -0
  45. package/dist/move.js +145 -0
  46. package/dist/move.js.map +1 -0
  47. package/dist/options-BPPBWMa7.d.ts +64 -0
  48. package/dist/patterns-builtin.d.ts +55 -0
  49. package/dist/patterns-builtin.js +100 -0
  50. package/dist/patterns-builtin.js.map +1 -0
  51. package/dist/pointSnapToGrid-D7s7QmOF.d.ts +185 -0
  52. package/dist/registerFont-CP-wCsrz.d.ts +109 -0
  53. package/dist/registerTexture-BzHTLhD9.d.ts +25 -0
  54. package/dist/renderer.css +121 -0
  55. package/dist/renderer.css.map +1 -0
  56. package/dist/renderer.d.ts +376 -0
  57. package/dist/renderer.js +13 -0
  58. package/dist/renderer.js.map +1 -0
  59. package/dist/resize.d.ts +78 -0
  60. package/dist/resize.js +5 -0
  61. package/dist/resize.js.map +1 -0
  62. package/dist/routing.css +35 -0
  63. package/dist/routing.css.map +1 -0
  64. package/dist/routing.d.ts +14 -0
  65. package/dist/routing.js +4 -0
  66. package/dist/routing.js.map +1 -0
  67. package/dist/types-B6MMiodD.d.ts +59 -0
  68. package/dist/types-BJ8_cyT7.d.ts +130 -0
  69. package/dist/types-B_-khFM0.d.ts +331 -0
  70. package/dist/types-BjUi2vA-.d.ts +355 -0
  71. package/dist/types-Cpb4hii1.d.ts +445 -0
  72. package/dist/types-D2tTKEU0.d.ts +18 -0
  73. package/dist/view-DSQgxBJB.d.ts +63 -0
  74. package/package.json +96 -0
@@ -0,0 +1,248 @@
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, meanScale } from './chunk-CQNKCG34.js';
2
+
3
+ // src/interactions/actions/resize/behaviors/clampMinSize.ts
4
+ function clampMinSize(args) {
5
+ const { minWidth, minHeight } = args;
6
+ return {
7
+ onMove(_ctx, { pose, anchor }) {
8
+ let { x, y, width, height } = pose;
9
+ let changed = false;
10
+ if (anchor.x !== "free" && width < minWidth) {
11
+ if (anchor.x === "min") {
12
+ width = minWidth;
13
+ } else {
14
+ const right = x + width;
15
+ x = right - minWidth;
16
+ width = minWidth;
17
+ }
18
+ changed = true;
19
+ }
20
+ if (anchor.y !== "free" && height < minHeight) {
21
+ if (anchor.y === "min") {
22
+ height = minHeight;
23
+ } else {
24
+ const bottom = y + height;
25
+ y = bottom - minHeight;
26
+ height = minHeight;
27
+ }
28
+ changed = true;
29
+ }
30
+ if (!changed) return;
31
+ return { pose: { ...pose, x, y, width, height } };
32
+ }
33
+ };
34
+ }
35
+
36
+ // src/interactions/actions/resize/behaviors/lockAspect.ts
37
+ function lockAspectWithModifier(opts = {}) {
38
+ const { key = "shift" } = opts;
39
+ return {
40
+ onMove(ctx, { pose, anchor }) {
41
+ if (!ctx.modifiers[key]) return;
42
+ const origin = ctx.origin.get(ctx.draggedIds[0]);
43
+ if (!origin) return;
44
+ if (origin.width === 0 || origin.height === 0) return;
45
+ const ratio = origin.width / origin.height;
46
+ const dw = pose.width - origin.width;
47
+ const dh = pose.height - origin.height;
48
+ let nw;
49
+ let nh;
50
+ if (anchor.x === "free" && anchor.y === "free") {
51
+ return;
52
+ } else if (anchor.x === "free") {
53
+ nh = pose.height;
54
+ nw = nh * ratio;
55
+ if (nw < 0) nw = -nw;
56
+ } else if (anchor.y === "free") {
57
+ nw = pose.width;
58
+ nh = nw / ratio;
59
+ if (nh < 0) nh = -nh;
60
+ } else {
61
+ if (Math.abs(dw) >= Math.abs(dh)) {
62
+ nw = pose.width;
63
+ nh = Math.abs(nw) / ratio * Math.sign(pose.height || 1);
64
+ } else {
65
+ nh = pose.height;
66
+ nw = Math.abs(nh) * ratio * Math.sign(pose.width || 1);
67
+ }
68
+ }
69
+ let nx = pose.x;
70
+ let ny = pose.y;
71
+ if (anchor.x === "min") {
72
+ nx = origin.x;
73
+ } else if (anchor.x === "max") {
74
+ nx = origin.x + origin.width - nw;
75
+ } else {
76
+ nx = origin.x + origin.width / 2 - nw / 2;
77
+ }
78
+ if (anchor.y === "min") {
79
+ ny = origin.y;
80
+ } else if (anchor.y === "max") {
81
+ ny = origin.y + origin.height - nh;
82
+ } else {
83
+ ny = origin.y + origin.height / 2 - nh / 2;
84
+ }
85
+ return {
86
+ pose: { ...pose, x: nx, y: ny, width: nw, height: nh }
87
+ };
88
+ }
89
+ };
90
+ }
91
+
92
+ // src/interactions/actions/resize/behaviors/snapToGrid.ts
93
+ function snapToGrid(args) {
94
+ const { spacing, bypassKey, suspendBelowDim = true } = args;
95
+ const round = (v) => Math.round(v / spacing) * spacing;
96
+ return {
97
+ onMove(ctx, { pose, anchor }) {
98
+ if (bypassKey && ctx.modifiers[bypassKey]) return;
99
+ const origin = ctx.origin.get(ctx.draggedIds[0]);
100
+ const subX = suspendBelowDim && origin.width < spacing;
101
+ const subY = suspendBelowDim && origin.height < spacing;
102
+ let { x, y, width, height } = pose;
103
+ let changed = false;
104
+ if (anchor.x !== "free" && !subX) {
105
+ if (anchor.x === "min") {
106
+ const east = round(x + width);
107
+ width = east - x;
108
+ } else {
109
+ const right = origin.x + origin.width;
110
+ const newX = round(x);
111
+ width = right - newX;
112
+ x = newX;
113
+ }
114
+ changed = true;
115
+ }
116
+ if (anchor.y !== "free" && !subY) {
117
+ if (anchor.y === "min") {
118
+ const south = round(y + height);
119
+ height = south - y;
120
+ } else {
121
+ const bottom = origin.y + origin.height;
122
+ const newY = round(y);
123
+ height = bottom - newY;
124
+ y = newY;
125
+ }
126
+ changed = true;
127
+ }
128
+ if (!changed) return;
129
+ return { pose: { ...pose, x, y, width, height } };
130
+ }
131
+ };
132
+ }
133
+
134
+ // src/interactions/actions/resize/behaviors/snapToGuides.ts
135
+ function snapToGuides(args) {
136
+ const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;
137
+ const getView = args.getView;
138
+ const bypassKey = args.bypassKey;
139
+ return {
140
+ onMove(ctx, { pose, anchor }) {
141
+ if (bypassKey && ctx.modifiers[bypassKey]) return;
142
+ const guides = args.getGuides();
143
+ if (guides.length === 0) return;
144
+ const worldTolerance = getView ? tolerance / Math.max(1e-9, meanScale(getView().scale)) : tolerance;
145
+ let { x, y, width, height } = pose;
146
+ let changed = false;
147
+ if (anchor.x !== "free") {
148
+ const movingX = anchor.x === "min" ? x + width : x;
149
+ let bestD = 0;
150
+ let bestAbs = Infinity;
151
+ for (const g of guides) {
152
+ if (g.axis !== "x") continue;
153
+ const d = g.offset - movingX;
154
+ const ad = Math.abs(d);
155
+ if (ad <= worldTolerance && ad < bestAbs) {
156
+ bestAbs = ad;
157
+ bestD = d;
158
+ }
159
+ }
160
+ if (bestAbs !== Infinity && bestD !== 0) {
161
+ if (anchor.x === "min") {
162
+ width = width + bestD;
163
+ } else {
164
+ x = x + bestD;
165
+ width = width - bestD;
166
+ }
167
+ changed = true;
168
+ }
169
+ }
170
+ if (anchor.y !== "free") {
171
+ const movingY = anchor.y === "min" ? y + height : y;
172
+ let bestD = 0;
173
+ let bestAbs = Infinity;
174
+ for (const g of guides) {
175
+ if (g.axis !== "y") continue;
176
+ const d = g.offset - movingY;
177
+ const ad = Math.abs(d);
178
+ if (ad <= worldTolerance && ad < bestAbs) {
179
+ bestAbs = ad;
180
+ bestD = d;
181
+ }
182
+ }
183
+ if (bestAbs !== Infinity && bestD !== 0) {
184
+ if (anchor.y === "min") {
185
+ height = height + bestD;
186
+ } else {
187
+ y = y + bestD;
188
+ height = height - bestD;
189
+ }
190
+ changed = true;
191
+ }
192
+ }
193
+ if (!changed) return;
194
+ return { pose: { ...pose, x, y, width, height } };
195
+ }
196
+ };
197
+ }
198
+
199
+ // src/interactions/actions/resize/behaviors/pointSnapToGrid.ts
200
+ function pointSnapToGrid(args) {
201
+ const { spacing, frame = "dragged-corner", bypassKey } = args;
202
+ const round = (v) => Math.round(v / spacing) * spacing;
203
+ return {
204
+ id: `pointSnapToGrid:${frame}`,
205
+ onMove(ctx) {
206
+ if (bypassKey && ctx.modifiers[bypassKey]) return null;
207
+ const src = frame === "dragged-corner" ? ctx.draggedCorner : frame === "fixed-corner" ? ctx.fixedCorner : frame === "center" ? ctx.center : ctx.origin;
208
+ if (!src) return null;
209
+ return { frame, worldX: round(src.worldX), worldY: round(src.worldY) };
210
+ }
211
+ };
212
+ }
213
+
214
+ // src/interactions/actions/resize/behaviors/index.ts
215
+ var DEFAULT_RESIZE_BEHAVIORS = Object.freeze([lockAspectWithModifier()]);
216
+
217
+ // src/interactions/actions/resize/cornerHandles.ts
218
+ var CORNER_ANCHORS = [
219
+ { xEdge: "min", yEdge: "min", anchor: { x: "max", y: "max" }, kind: "handle:top-left", tag: "min-min" },
220
+ { xEdge: "max", yEdge: "min", anchor: { x: "min", y: "max" }, kind: "handle:top-right", tag: "max-min" },
221
+ { xEdge: "min", yEdge: "max", anchor: { x: "max", y: "min" }, kind: "handle:bottom-left", tag: "min-max" },
222
+ { xEdge: "max", yEdge: "max", anchor: { x: "min", y: "min" }, kind: "handle:bottom-right", tag: "max-max" }
223
+ ];
224
+ function cornerPoint(bounds, entry) {
225
+ return {
226
+ x: entry.xEdge === "max" ? bounds.x + bounds.width : bounds.x,
227
+ y: entry.yEdge === "max" ? bounds.y + bounds.height : bounds.y
228
+ };
229
+ }
230
+ function cornerResizeHandles(bounds) {
231
+ return CORNER_ANCHORS.map((c) => {
232
+ const p = cornerPoint(bounds, c);
233
+ return { cx: p.x, cy: p.y, anchor: c.anchor };
234
+ });
235
+ }
236
+ function hitCornerHandle(handle, px, py, radius) {
237
+ return Math.abs(px - handle.cx) <= radius && Math.abs(py - handle.cy) <= radius;
238
+ }
239
+ function fixedCornerOf(bounds, anchor) {
240
+ return {
241
+ x: anchor.x === "max" ? bounds.x + bounds.width : bounds.x,
242
+ y: anchor.y === "max" ? bounds.y + bounds.height : bounds.y
243
+ };
244
+ }
245
+
246
+ export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides };
247
+ //# sourceMappingURL=chunk-BGGZ4CVF.js.map
248
+ //# sourceMappingURL=chunk-BGGZ4CVF.js.map
@@ -0,0 +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":";;;AAEO,SAAS,aAAuC,IAAA,EAG3B;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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AAI,CAAA,CAAE,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA,EAAG,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO;AAAA,EAC9C,CAAC,CAAA;AACH;AAIO,SAAS,eAAA,CACd,MAAA,EACA,EAAA,EACA,EAAA,EACA,MAAA,EACS;AACT,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,EAAA,GAAK,MAAA,CAAO,EAAE,CAAA,IAAK,MAAA,IAC9B,IAAA,CAAK,GAAA,CAAI,EAAA,GAAK,MAAA,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-BGGZ4CVF.js","sourcesContent":["import type { BoundsConstraint, ResizePose } from '../../../gestures/types';\n\nexport function clampMinSize<TPose extends ResizePose>(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 ResizePose,\n} from '../../../gestures/types';\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 ResizePose>(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 ResizePose | 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 ResizePose,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\nexport function snapToGrid<TPose extends ResizePose>(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 ResizePose,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { meanScale } from 'core/viewport/meanScale';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\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 ResizePose>(\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 const worldTolerance = getView\n ? tolerance / Math.max(1e-9, meanScale(getView().scale))\n : 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 <= worldTolerance && 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 <= worldTolerance && 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 ResizePose,\n} from '../../../gestures/types';\n\nexport function pointSnapToGrid<TPose extends ResizePose>(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, ResizePose } from '../../../gestures/types';\nimport { lockAspectWithModifier } from './lockAspect';\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<ResizePose>[] =\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"]}
@@ -0,0 +1,29 @@
1
+ import { registerOpFactory } from './chunk-GVCNT7UH.js';
2
+
3
+ // src/core/ops/select.ts
4
+ function createSetSelectionOp(args) {
5
+ const { from, to, label } = args;
6
+ return {
7
+ name: "setSelection",
8
+ args: { from, to, label },
9
+ label,
10
+ apply(adapter) {
11
+ adapter.setSelection([...to]);
12
+ if (sequenceEqual(from, to)) return false;
13
+ return void 0;
14
+ },
15
+ invert() {
16
+ return createSetSelectionOp({ from: to, to: from, label });
17
+ }
18
+ };
19
+ }
20
+ registerOpFactory("setSelection", (args) => createSetSelectionOp(args));
21
+ function sequenceEqual(a, b) {
22
+ if (a.length !== b.length) return false;
23
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
24
+ return true;
25
+ }
26
+
27
+ export { createSetSelectionOp };
28
+ //# sourceMappingURL=chunk-BHVYVFGV.js.map
29
+ //# sourceMappingURL=chunk-BHVYVFGV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/ops/select.ts"],"names":[],"mappings":";;;AAgBO,SAAS,qBAAqB,IAAA,EAA4B;AAC/D,EAAA,MAAM,EAAE,IAAA,EAAM,EAAA,EAAI,KAAA,EAAM,GAAI,IAAA;AAC5B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,cAAA;AAAA,IACN,IAAA,EAAM,EAAE,IAAA,EAAM,EAAA,EAAI,KAAA,EAAM;AAAA,IACxB,KAAA;AAAA,IACA,MAAM,OAAA,EAAS;AAMb,MAAC,OAAA,CAA6B,YAAA,CAAa,CAAC,GAAG,EAAE,CAAC,CAAA;AAClD,MAAA,IAAI,aAAA,CAAc,IAAA,EAAM,EAAE,CAAA,EAAG,OAAO,KAAA;AACpC,MAAA,OAAO,MAAA;AAAA,IACT,CAAA;AAAA,IACA,MAAA,GAAS;AACP,MAAA,OAAO,qBAAqB,EAAE,IAAA,EAAM,IAAI,EAAA,EAAI,IAAA,EAAM,OAAO,CAAA;AAAA,IAC3D;AAAA,GACF;AACF;AAEA,iBAAA,CAAoC,cAAA,EAAgB,CAAC,IAAA,KAAS,oBAAA,CAAqB,IAAI,CAAC,CAAA;AAExF,SAAS,aAAA,CAAc,GAAsB,CAAA,EAA+B;AAC1E,EAAA,IAAI,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,EAAQ,OAAO,KAAA;AAClC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,CAAE,MAAA,EAAQ,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAC,CAAA,KAAM,CAAA,CAAE,CAAC,GAAG,OAAO,KAAA;AAC7D,EAAA,OAAO,IAAA;AACT","file":"chunk-BHVYVFGV.js","sourcesContent":["import type { NodeId } from '../scene/types';\nimport type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface SelectionAdapter {\n setSelection(ids: NodeId[]): void;\n}\n\n/** @internal */\ninterface SetSelectionArgs {\n from: readonly NodeId[];\n to: readonly NodeId[];\n label?: string;\n}\n\n/** Op: replace the current selection with `to`; inverts back to `from`. */\nexport function createSetSelectionOp(args: SetSelectionArgs): Op {\n const { from, to, label } = args;\n return {\n name: 'setSelection',\n args: { from, to, label },\n label,\n apply(adapter) {\n // Always call setSelection so consumers that inspect op behavior\n // (tests, overlays) see a consistent \"this op writes `to`\" signal.\n // When from and to are sequence-equal, additionally report a no-op\n // to history so the entry can be skipped from the undo stack.\n // setSelection with the same value is idempotent.\n (adapter as SelectionAdapter).setSelection([...to]);\n if (sequenceEqual(from, to)) return false;\n return undefined;\n },\n invert() {\n return createSetSelectionOp({ from: to, to: from, label });\n },\n };\n}\n\nregisterOpFactory<SetSelectionArgs>('setSelection', (args) => createSetSelectionOp(args));\n\nfunction sequenceEqual(a: readonly NodeId[], b: readonly NodeId[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n"]}