@oh-just-another/state 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/README.md +76 -27
- package/dist/.tsbuildinfo +1 -1
- package/dist/actions/actionArrange.d.ts +13 -0
- package/dist/actions/actionArrange.d.ts.map +1 -0
- package/dist/actions/actionArrange.js +130 -0
- package/dist/actions/actionArrange.js.map +1 -0
- package/dist/actions/actionClipboard.d.ts +2 -0
- package/dist/actions/actionClipboard.d.ts.map +1 -1
- package/dist/actions/actionClipboard.js +27 -1
- package/dist/actions/actionClipboard.js.map +1 -1
- package/dist/actions/actionText.d.ts +5 -0
- package/dist/actions/actionText.d.ts.map +1 -0
- package/dist/actions/actionText.js +37 -0
- package/dist/actions/actionText.js.map +1 -0
- package/dist/actions/actionView.js +1 -1
- package/dist/actions/index.d.ts +3 -1
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +3 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/registry.d.ts.map +1 -1
- package/dist/actions/registry.js +4 -0
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/types.d.ts +1 -1
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/actions/types.js.map +1 -1
- package/dist/auto-layout-scheduler.d.ts +1 -3
- package/dist/auto-layout-scheduler.d.ts.map +1 -1
- package/dist/auto-layout-scheduler.js +1 -2
- package/dist/auto-layout-scheduler.js.map +1 -1
- package/dist/built-in-handlers.d.ts.map +1 -1
- package/dist/built-in-handlers.js +14 -1
- package/dist/built-in-handlers.js.map +1 -1
- package/dist/constants.d.ts +48 -23
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +48 -23
- package/dist/constants.js.map +1 -1
- package/dist/dom-events.d.ts +7 -0
- package/dist/dom-events.d.ts.map +1 -1
- package/dist/dom-events.js +12 -0
- package/dist/dom-events.js.map +1 -1
- package/dist/editor/animation-scene.d.ts +21 -0
- package/dist/editor/animation-scene.d.ts.map +1 -0
- package/dist/editor/animation-scene.js +71 -0
- package/dist/editor/animation-scene.js.map +1 -0
- package/dist/editor/animation.d.ts +43 -0
- package/dist/editor/animation.d.ts.map +1 -0
- package/dist/editor/animation.js +80 -0
- package/dist/editor/animation.js.map +1 -0
- package/dist/editor/applies/arrange.d.ts +46 -0
- package/dist/editor/applies/arrange.d.ts.map +1 -0
- package/dist/editor/applies/arrange.js +162 -0
- package/dist/editor/applies/arrange.js.map +1 -0
- package/dist/editor/applies/edge.d.ts +8 -1
- package/dist/editor/applies/edge.d.ts.map +1 -1
- package/dist/editor/applies/edge.js +31 -1
- package/dist/editor/applies/edge.js.map +1 -1
- package/dist/editor/applies/move.d.ts +6 -0
- package/dist/editor/applies/move.d.ts.map +1 -1
- package/dist/editor/applies/move.js +6 -0
- package/dist/editor/applies/move.js.map +1 -1
- package/dist/editor/applies/resize.d.ts +26 -5
- package/dist/editor/applies/resize.d.ts.map +1 -1
- package/dist/editor/applies/resize.js +91 -13
- package/dist/editor/applies/resize.js.map +1 -1
- package/dist/editor/caret-blink.d.ts +18 -0
- package/dist/editor/caret-blink.d.ts.map +1 -0
- package/dist/editor/caret-blink.js +42 -0
- package/dist/editor/caret-blink.js.map +1 -0
- package/dist/editor/container-ops.d.ts.map +1 -1
- package/dist/editor/container-ops.js +2 -2
- package/dist/editor/container-ops.js.map +1 -1
- package/dist/editor/dirty-rect.d.ts +23 -0
- package/dist/editor/dirty-rect.d.ts.map +1 -0
- package/dist/editor/dirty-rect.js +115 -0
- package/dist/editor/dirty-rect.js.map +1 -0
- package/dist/editor/gif-playback.d.ts +45 -0
- package/dist/editor/gif-playback.d.ts.map +1 -0
- package/dist/editor/gif-playback.js +125 -0
- package/dist/editor/gif-playback.js.map +1 -0
- package/dist/editor/hit-test.d.ts +3 -3
- package/dist/editor/hit-test.d.ts.map +1 -1
- package/dist/editor/hit-test.js +40 -15
- package/dist/editor/hit-test.js.map +1 -1
- package/dist/editor/long-press.d.ts.map +1 -1
- package/dist/editor/long-press.js +2 -2
- package/dist/editor/long-press.js.map +1 -1
- package/dist/editor/pinch.d.ts.map +1 -1
- package/dist/editor/pinch.js +6 -6
- package/dist/editor/pinch.js.map +1 -1
- package/dist/editor/pointer-binding.d.ts.map +1 -1
- package/dist/editor/pointer-binding.js +42 -25
- package/dist/editor/pointer-binding.js.map +1 -1
- package/dist/editor/public/arrange-group.d.ts +3 -9
- package/dist/editor/public/arrange-group.d.ts.map +1 -1
- package/dist/editor/public/arrange-group.js +4 -6
- package/dist/editor/public/arrange-group.js.map +1 -1
- package/dist/editor/public/clipboard.d.ts +2 -4
- package/dist/editor/public/clipboard.d.ts.map +1 -1
- package/dist/editor/public/clipboard.js +2 -4
- package/dist/editor/public/clipboard.js.map +1 -1
- package/dist/editor/public/cursor.d.ts +43 -0
- package/dist/editor/public/cursor.d.ts.map +1 -0
- package/dist/editor/public/cursor.js +135 -0
- package/dist/editor/public/cursor.js.map +1 -0
- package/dist/editor/public/frame-name.d.ts +20 -0
- package/dist/editor/public/frame-name.d.ts.map +1 -0
- package/dist/editor/public/frame-name.js +54 -0
- package/dist/editor/public/frame-name.js.map +1 -0
- package/dist/editor/public/image-insert.d.ts +1 -1
- package/dist/editor/public/image-insert.d.ts.map +1 -1
- package/dist/editor/public/layers.d.ts.map +1 -1
- package/dist/editor/public/layers.js +2 -2
- package/dist/editor/public/layers.js.map +1 -1
- package/dist/editor/public/link.d.ts +11 -2
- package/dist/editor/public/link.d.ts.map +1 -1
- package/dist/editor/public/link.js +70 -2
- package/dist/editor/public/link.js.map +1 -1
- package/dist/editor/public/placement.d.ts +60 -2
- package/dist/editor/public/placement.d.ts.map +1 -1
- package/dist/editor/public/placement.js +185 -2
- package/dist/editor/public/placement.js.map +1 -1
- package/dist/editor/public/selection-ops.d.ts +23 -1
- package/dist/editor/public/selection-ops.d.ts.map +1 -1
- package/dist/editor/public/selection-ops.js +79 -2
- package/dist/editor/public/selection-ops.js.map +1 -1
- package/dist/editor/public/text-edit.d.ts +1 -10
- package/dist/editor/public/text-edit.d.ts.map +1 -1
- package/dist/editor/public/text-edit.js +2 -16
- package/dist/editor/public/text-edit.js.map +1 -1
- package/dist/editor/public/z-order.d.ts.map +1 -1
- package/dist/editor/public/z-order.js +4 -4
- package/dist/editor/public/z-order.js.map +1 -1
- package/dist/editor/public/zoom-pan.d.ts +6 -4
- package/dist/editor/public/zoom-pan.d.ts.map +1 -1
- package/dist/editor/public/zoom-pan.js +8 -7
- package/dist/editor/public/zoom-pan.js.map +1 -1
- package/dist/editor/render-orchestrator.d.ts.map +1 -1
- package/dist/editor/render-orchestrator.js +4 -9
- package/dist/editor/render-orchestrator.js.map +1 -1
- package/dist/editor/resize-helpers.d.ts +21 -5
- package/dist/editor/resize-helpers.d.ts.map +1 -1
- package/dist/editor/resize-helpers.js +59 -19
- package/dist/editor/resize-helpers.js.map +1 -1
- package/dist/editor/viewport-helpers.d.ts.map +1 -1
- package/dist/editor/viewport-helpers.js +3 -3
- package/dist/editor/viewport-helpers.js.map +1 -1
- package/dist/editor-events.d.ts +1 -1
- package/dist/editor-events.d.ts.map +1 -1
- package/dist/editor.d.ts +125 -133
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +351 -989
- package/dist/editor.js.map +1 -1
- package/dist/file-drop.d.ts.map +1 -1
- package/dist/file-drop.js +1 -2
- package/dist/file-drop.js.map +1 -1
- package/dist/frame-helpers.d.ts.map +1 -1
- package/dist/frame-helpers.js +5 -5
- package/dist/frame-helpers.js.map +1 -1
- package/dist/group-helpers.d.ts.map +1 -1
- package/dist/group-helpers.js +4 -4
- package/dist/group-helpers.js.map +1 -1
- package/dist/handle.d.ts +61 -6
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +105 -7
- package/dist/handle.js.map +1 -1
- package/dist/hotkeys-binding.d.ts +26 -0
- package/dist/hotkeys-binding.d.ts.map +1 -0
- package/dist/hotkeys-binding.js +35 -0
- package/dist/hotkeys-binding.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/link-selection.d.ts +3 -5
- package/dist/link-selection.d.ts.map +1 -1
- package/dist/link-selection.js +3 -12
- package/dist/link-selection.js.map +1 -1
- package/dist/machine.d.ts +27 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +38 -0
- package/dist/machine.js.map +1 -1
- package/dist/overlay.d.ts +1 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -36
- package/dist/overlay.js.map +1 -1
- package/dist/selection.d.ts.map +1 -1
- package/dist/selection.js +2 -10
- package/dist/selection.js.map +1 -1
- package/dist/util.d.ts +8 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +17 -0
- package/dist/util.js.map +1 -0
- package/package.json +7 -7
package/dist/constants.js
CHANGED
|
@@ -46,6 +46,23 @@ export const HANDLE_OUTSET = 3;
|
|
|
46
46
|
* eating the body-move target on small shapes).
|
|
47
47
|
*/
|
|
48
48
|
export const HANDLE_HIT_SLOP = 11;
|
|
49
|
+
/**
|
|
50
|
+
* Screen-pixel gap between the shape's rotate anchor (default bottom-left
|
|
51
|
+
* corner) and the rotate grip that floats just outside it. Far enough to clear
|
|
52
|
+
* the corner resize handle. Range: 20–32.
|
|
53
|
+
*/
|
|
54
|
+
export const ROTATE_HANDLE_OFFSET = 26;
|
|
55
|
+
/**
|
|
56
|
+
* Screen-pixel radius of the rotate grip's circular-arrow glyph (a clockwise
|
|
57
|
+
* rotate icon). Slightly larger than `HANDLE_SIZE` so the icon reads as an
|
|
58
|
+
* affordance, not a plain resize dot. Range: 6–9.
|
|
59
|
+
*/
|
|
60
|
+
export const ROTATE_ICON_RADIUS = 7;
|
|
61
|
+
/**
|
|
62
|
+
* Angle step (radians) the rotate gesture snaps to while Shift is held — 15°
|
|
63
|
+
* (π/12), the common increment for diagram alignment. Range: π/24–π/6.
|
|
64
|
+
*/
|
|
65
|
+
export const ROTATE_SNAP_RADIANS = Math.PI / 12;
|
|
49
66
|
/**
|
|
50
67
|
* Screen-pixel hit-test slop for grabbing an edge endpoint handle.
|
|
51
68
|
* Larger than `LINK_ENDPOINT_HANDLE_DRAW_RADIUS` so the handle is
|
|
@@ -71,12 +88,6 @@ export const LINK_MIDPOINT_HANDLE_DRAW_RADIUS = 4;
|
|
|
71
88
|
* delete". Kept near the handle hit radius. Range: 8–16.
|
|
72
89
|
*/
|
|
73
90
|
export const WAYPOINT_COLLAPSE_RADIUS = 12;
|
|
74
|
-
/**
|
|
75
|
-
* Upper bound on how many candidate obstacles the A*-based "route around
|
|
76
|
-
* shapes" command will consider. Above this the command bails (returns the
|
|
77
|
-
* link unchanged) rather than spending the A* cost. Range: 100–1000.
|
|
78
|
-
*/
|
|
79
|
-
export const AUTO_ROUTE_MAX_OBSTACLES = 400;
|
|
80
91
|
/**
|
|
81
92
|
* Screen-pixel tolerance for edge hit-testing. Cursors within this
|
|
82
93
|
* distance of an edge polyline segment register a hit. Should stay
|
|
@@ -94,13 +105,6 @@ export const LINK_HIT_THRESHOLD = 9;
|
|
|
94
105
|
* thickness. Range: 3–8.
|
|
95
106
|
*/
|
|
96
107
|
export const SELECTION_HALO_PEEK_PX = 4;
|
|
97
|
-
/**
|
|
98
|
-
* Screen-pixel radius of the inactive port dot rendered on a hovered
|
|
99
|
-
* shape in draw-edge mode. `PORT_DOT_ACTIVE_RADIUS` is used for the
|
|
100
|
-
* snap target so the user sees which one will catch.
|
|
101
|
-
*/
|
|
102
|
-
export const PORT_DOT_RADIUS = 3.5;
|
|
103
|
-
export const PORT_DOT_ACTIVE_RADIUS = 5;
|
|
104
108
|
/**
|
|
105
109
|
* Connection anchors.
|
|
106
110
|
*
|
|
@@ -205,11 +209,7 @@ export const ANCHOR_CLICK_NEW_ELEMENT_GAP = 40;
|
|
|
205
209
|
*
|
|
206
210
|
* Shared opacities; per-category colours below so different hit-target kinds
|
|
207
211
|
* are visually distinguishable (point vs edge vs body vs container vs frame).
|
|
208
|
-
* Kept generic (`DEBUG_HIT_ZONE_FILL`/`STROKE`) as the alias for the
|
|
209
|
-
* resize-handle category and any uncoloured fallback.
|
|
210
212
|
*/
|
|
211
|
-
export const DEBUG_HIT_ZONE_FILL = "#e8118c";
|
|
212
|
-
export const DEBUG_HIT_ZONE_STROKE = "#e8118c";
|
|
213
213
|
export const DEBUG_HIT_ZONE_FILL_OPACITY = 0.16;
|
|
214
214
|
export const DEBUG_HIT_ZONE_STROKE_OPACITY = 0.7;
|
|
215
215
|
/**
|
|
@@ -277,8 +277,7 @@ export const PEER_CURSOR_BROADCAST_INTERVAL_MS = 33;
|
|
|
277
277
|
* programmatic button-style zoom (`Editor.zoomIn` / `zoomOut`).
|
|
278
278
|
* `1.6 = +60% per call` — punchy single-step zoom.
|
|
279
279
|
* - `WHEEL_ZOOM_MAX_STEP` / `WHEEL_ZOOM_SPEED` — wheel-zoom
|
|
280
|
-
* normalisation
|
|
281
|
-
* Per event:
|
|
280
|
+
* normalisation. Per event:
|
|
282
281
|
*
|
|
283
282
|
* delta = clamp(|deltaY|, WHEEL_ZOOM_MAX_STEP) * sign(deltaY)
|
|
284
283
|
* factor = 1 − (delta * WHEEL_ZOOM_SPEED) / 100
|
|
@@ -494,14 +493,10 @@ export const GIF_AUTOSTOP_MS = 30_000;
|
|
|
494
493
|
* - `TEXT_DEFAULT_FONT_SIZE` — initial font size in world units.
|
|
495
494
|
* - `TEXT_DEFAULT_FONT_FAMILY` — initial font stack.
|
|
496
495
|
* - `TEXT_DEFAULT_FILL` — initial text colour (near-black).
|
|
497
|
-
* - `TEXT_FONT_SIZE_MIN` / `TEXT_FONT_SIZE_MAX` — clamp range for the
|
|
498
|
-
* font-size control in the contextual panel.
|
|
499
496
|
*/
|
|
500
497
|
export const TEXT_DEFAULT_FONT_SIZE = 24;
|
|
501
498
|
export const TEXT_DEFAULT_FONT_FAMILY = "system-ui, sans-serif";
|
|
502
499
|
export const TEXT_DEFAULT_FILL = "#1a1a1a";
|
|
503
|
-
export const TEXT_FONT_SIZE_MIN = 8;
|
|
504
|
-
export const TEXT_FONT_SIZE_MAX = 256;
|
|
505
500
|
/**
|
|
506
501
|
* In-canvas text editing.
|
|
507
502
|
*
|
|
@@ -534,4 +529,34 @@ export const TEXT_SELECTION_FILL = "#1a73e8";
|
|
|
534
529
|
export const TEXT_SELECTION_OPACITY = 0.25;
|
|
535
530
|
export const TEXT_CARET_WIDTH_PX = 1.5;
|
|
536
531
|
export const TEXT_RESIZE_MIN_FONT_SIZE = 4;
|
|
532
|
+
/**
|
|
533
|
+
* Multiplicative step for the increase/decrease-font-size shortcuts: each
|
|
534
|
+
* press scales the current size by this factor (min ±1 px so small sizes still
|
|
535
|
+
* move), clamped to {@link TEXT_RESIZE_MIN_FONT_SIZE}…{@link TEXT_MAX_FONT_SIZE}.
|
|
536
|
+
* 1.1 ≈ a gentle 10 % step. Range: 1.05–1.5.
|
|
537
|
+
*/
|
|
538
|
+
export const TEXT_FONT_SIZE_STEP = 1.1;
|
|
539
|
+
/**
|
|
540
|
+
* Upper clamp (world px) for font size — matches the property panel's slider
|
|
541
|
+
* ceiling so the keyboard and the panel agree on the maximum.
|
|
542
|
+
*/
|
|
543
|
+
export const TEXT_MAX_FONT_SIZE = 256;
|
|
544
|
+
/**
|
|
545
|
+
* Paused-GIF chip drawn in a shape's top-left corner — signals a GIF the
|
|
546
|
+
* user can click / hover to resume. Dimensions in screen px; the scrim is
|
|
547
|
+
* a translucent black so the "gif" label stays legible over any artwork.
|
|
548
|
+
*/
|
|
549
|
+
export const GIF_BADGE_W = 30;
|
|
550
|
+
export const GIF_BADGE_H = 16;
|
|
551
|
+
export const GIF_BADGE_PAD = 4;
|
|
552
|
+
export const GIF_BADGE_RADIUS = 4;
|
|
553
|
+
export const GIF_BADGE_BG_COLOR = "rgba(0,0,0,0.65)";
|
|
554
|
+
/**
|
|
555
|
+
* Padlock badge at a selected locked element's top-right corner. `SIZE` is
|
|
556
|
+
* the icon edge in screen px; the body uses the accent colour, the keyhole
|
|
557
|
+
* a contrasting fill.
|
|
558
|
+
*/
|
|
559
|
+
export const LOCK_BADGE_SIZE = 16;
|
|
560
|
+
export const LOCK_BADGE_COLOR = "#1a73e8";
|
|
561
|
+
export const LOCK_BADGE_KEYHOLE_COLOR = "#fff";
|
|
537
562
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB,YAAY,CAAC;AAE9D,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAmB,UAAU,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB,YAAY,CAAC;AAE9D,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAmB,UAAU,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAE7B;;;;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;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC"}
|
package/dist/dom-events.d.ts
CHANGED
|
@@ -9,5 +9,12 @@ import type { KeyboardEventData, KeyPhase, PointerEventData, WheelEventData } fr
|
|
|
9
9
|
export declare const fromPointerEvent: (ev: PointerEvent, host: HTMLElement) => PointerEventData;
|
|
10
10
|
export declare const fromKeyboardEvent: (ev: KeyboardEvent) => KeyboardEventData;
|
|
11
11
|
export declare const fromWheelEvent: (ev: WheelEvent, host: HTMLElement) => WheelEventData;
|
|
12
|
+
/**
|
|
13
|
+
* True when the event is aimed at an editable element — a text field,
|
|
14
|
+
* `<select>`, or any `contenteditable` host. Global keyboard / pointer
|
|
15
|
+
* handlers (hotkeys, Space-pan, snap-suppress modifier tracking) must bail
|
|
16
|
+
* when this is true so the user's typing isn't hijacked by canvas shortcuts.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isEditableTarget: (target: EventTarget | null) => boolean;
|
|
12
19
|
export type { KeyPhase };
|
|
13
20
|
//# sourceMappingURL=dom-events.d.ts.map
|
package/dist/dom-events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-events.d.ts","sourceRoot":"","sources":["../src/dom-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,QAAQ,EAER,gBAAgB,EAGhB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,YAAY,EAAE,MAAM,WAAW,KAAG,gBAWtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,IAAI,aAAa,KAAG,iBAOpD,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,IAAI,UAAU,EAAE,MAAM,WAAW,KAAG,cAUlE,CAAC;AAuCF,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"dom-events.d.ts","sourceRoot":"","sources":["../src/dom-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,QAAQ,EAER,gBAAgB,EAGhB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,YAAY,EAAE,MAAM,WAAW,KAAG,gBAWtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,IAAI,aAAa,KAAG,iBAOpD,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,IAAI,UAAU,EAAE,MAAM,WAAW,KAAG,cAUlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,WAAW,GAAG,IAAI,KAAG,OAI7D,CAAC;AAuCF,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/dom-events.js
CHANGED
|
@@ -36,6 +36,18 @@ export const fromWheelEvent = (ev, host) => {
|
|
|
36
36
|
timestamp: ev.timeStamp,
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* True when the event is aimed at an editable element — a text field,
|
|
41
|
+
* `<select>`, or any `contenteditable` host. Global keyboard / pointer
|
|
42
|
+
* handlers (hotkeys, Space-pan, snap-suppress modifier tracking) must bail
|
|
43
|
+
* when this is true so the user's typing isn't hijacked by canvas shortcuts.
|
|
44
|
+
*/
|
|
45
|
+
export const isEditableTarget = (target) => {
|
|
46
|
+
if (!(target instanceof HTMLElement))
|
|
47
|
+
return false;
|
|
48
|
+
const tag = target.tagName;
|
|
49
|
+
return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable;
|
|
50
|
+
};
|
|
39
51
|
const toModifiers = (ev) => ({
|
|
40
52
|
shift: ev.shiftKey,
|
|
41
53
|
ctrl: ev.ctrlKey,
|
package/dist/dom-events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-events.js","sourceRoot":"","sources":["../src/dom-events.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAgB,EAAE,IAAiB,EAAoB,EAAE;IACxF,MAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC,WAAW,CAAC;QACnC,KAAK,EAAE,cAAc,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9B,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE;QAC9D,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;QAC1B,SAAS,EAAE,EAAE,CAAC,SAAS;QACvB,SAAS,EAAE,EAAE,CAAC,SAAS;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAiB,EAAqB,EAAE,CAAC,CAAC;IAC1E,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;IAC5C,GAAG,EAAE,EAAE,CAAC,GAAG;IACX,IAAI,EAAE,EAAE,CAAC,IAAI;IACb,SAAS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AE,OAAO,OAAO,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,GAAW,EAAgB,EAAE;IACnD,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,aAAa;YAChB,OAAO,MAAM,CAAC;QAChB,KAAK,aAAa;YAChB,OAAO,MAAM,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,IAAI,CAAC;QACd,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc;YACjB,OAAO,OAAO,CAAC;QACjB,KAAK,cAAc;YACjB,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from "../editor.js";
|
|
2
|
+
/**
|
|
3
|
+
* True when at least one animated shape's world AABB intersects the current
|
|
4
|
+
* viewport. Drives viewport-culling of the animation tick — off-screen GIFs
|
|
5
|
+
* don't burn decode / render cost.
|
|
6
|
+
*/
|
|
7
|
+
export declare const hasVisibleAnimatedElement: (editor: Editor) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Freeze heavy GIFs after `GIF_AUTOSTOP_MS` of continuous play (light GIFs loop
|
|
10
|
+
* forever). Collects the heavy ids by payload size and hands them to the
|
|
11
|
+
* playback controller. Called from the tick before each animation render.
|
|
12
|
+
*/
|
|
13
|
+
export declare const autoStopHeavyGifs: (editor: Editor) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Restore transient `animationData` for animated image shapes after a scene
|
|
16
|
+
* load: the raw bytes don't survive serialisation but persist in `Scene.files`
|
|
17
|
+
* via `fileId`, so copy them back so the animation adapter can produce frames.
|
|
18
|
+
* Applied directly to `_scene` (no history entry — internal rehydration).
|
|
19
|
+
*/
|
|
20
|
+
export declare const rehydrateAnimatedImages: (editor: Editor) => void;
|
|
21
|
+
//# sourceMappingURL=animation-scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-scene.d.ts","sourceRoot":"","sources":["../../src/editor/animation-scene.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,OAS1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,IAWlD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,IAgBxD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { bounds as B } from "@oh-just-another/math";
|
|
2
|
+
import { apply, getBinaryFile, getElementWorldBounds, isImage } from "@oh-just-another/scene";
|
|
3
|
+
import { HEAVY_GIF_BYTES } from "../constants.js";
|
|
4
|
+
import { hasAnimatedElement } from "./public/image-insert.js";
|
|
5
|
+
/**
|
|
6
|
+
* True when at least one animated shape's world AABB intersects the current
|
|
7
|
+
* viewport. Drives viewport-culling of the animation tick — off-screen GIFs
|
|
8
|
+
* don't burn decode / render cost.
|
|
9
|
+
*/
|
|
10
|
+
export const hasVisibleAnimatedElement = (editor) => {
|
|
11
|
+
if (!hasAnimatedElement(editor._scene))
|
|
12
|
+
return false;
|
|
13
|
+
const viewport = editor.computeViewportWorld();
|
|
14
|
+
if (!viewport)
|
|
15
|
+
return true; // no viewport yet — don't suppress
|
|
16
|
+
for (const shape of editor._scene.elements.values()) {
|
|
17
|
+
if (shape.metadata?.animated !== true)
|
|
18
|
+
continue;
|
|
19
|
+
if (B.intersects(getElementWorldBounds(shape), viewport))
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Freeze heavy GIFs after `GIF_AUTOSTOP_MS` of continuous play (light GIFs loop
|
|
26
|
+
* forever). Collects the heavy ids by payload size and hands them to the
|
|
27
|
+
* playback controller. Called from the tick before each animation render.
|
|
28
|
+
*/
|
|
29
|
+
export const autoStopHeavyGifs = (editor) => {
|
|
30
|
+
const heavyIds = [];
|
|
31
|
+
for (const shape of editor._scene.elements.values()) {
|
|
32
|
+
if (!isImage(shape))
|
|
33
|
+
continue;
|
|
34
|
+
if (!shape.animationKind)
|
|
35
|
+
continue;
|
|
36
|
+
const heavy = shape.animationData instanceof ArrayBuffer &&
|
|
37
|
+
shape.animationData.byteLength > HEAVY_GIF_BYTES;
|
|
38
|
+
if (heavy)
|
|
39
|
+
heavyIds.push(shape.id);
|
|
40
|
+
}
|
|
41
|
+
editor.gifPlayback.autoStopHeavy(heavyIds);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Restore transient `animationData` for animated image shapes after a scene
|
|
45
|
+
* load: the raw bytes don't survive serialisation but persist in `Scene.files`
|
|
46
|
+
* via `fileId`, so copy them back so the animation adapter can produce frames.
|
|
47
|
+
* Applied directly to `_scene` (no history entry — internal rehydration).
|
|
48
|
+
*/
|
|
49
|
+
export const rehydrateAnimatedImages = (editor) => {
|
|
50
|
+
for (const shape of editor._scene.elements.values()) {
|
|
51
|
+
if (!isImage(shape))
|
|
52
|
+
continue;
|
|
53
|
+
if (!shape.animationKind)
|
|
54
|
+
continue;
|
|
55
|
+
editor.gifPlayback.ensure(shape.id);
|
|
56
|
+
if (!shape.fileId)
|
|
57
|
+
continue;
|
|
58
|
+
if (shape.animationData instanceof ArrayBuffer)
|
|
59
|
+
continue; // already live
|
|
60
|
+
const file = getBinaryFile(editor._scene, shape.fileId);
|
|
61
|
+
if (!file)
|
|
62
|
+
continue;
|
|
63
|
+
editor._scene = apply(editor._scene, {
|
|
64
|
+
kind: "element",
|
|
65
|
+
id: shape.id,
|
|
66
|
+
before: shape,
|
|
67
|
+
after: { ...shape, animationData: file.data },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL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
|
+
/**
|
|
2
|
+
* Editor capabilities the animation tick needs. Keeps the controller off the
|
|
3
|
+
* god-class: scene-coupled work (visibility test, auto-stop, repaint) is
|
|
4
|
+
* delegated back to the Editor through this narrow interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface AnimationHost {
|
|
7
|
+
/** True while an animated shape is on-screen (drives the tick + culling). */
|
|
8
|
+
hasVisibleAnimatedElement(): boolean;
|
|
9
|
+
/** Freeze heavy GIFs that have played long enough. */
|
|
10
|
+
autoStopHeavyGifs(): void;
|
|
11
|
+
/** Force a full repaint — the adapter advanced the GIF frame. */
|
|
12
|
+
forceAnimationRepaint(): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Owns the GIF/animation tick lifecycle: an adaptive render-cost throttle and
|
|
16
|
+
* visibility-based pause/resume. Runs while any shape carries
|
|
17
|
+
* `metadata.animated` and an animated shape is on-screen; self-terminates
|
|
18
|
+
* otherwise (the underlying `AnimationTick` checks `isAnimated` each frame).
|
|
19
|
+
*/
|
|
20
|
+
export declare class AnimationController {
|
|
21
|
+
private readonly host;
|
|
22
|
+
private readonly tick;
|
|
23
|
+
/** EMA of animation-tick render cost (ms) — drives the adaptive throttle. */
|
|
24
|
+
private costEma;
|
|
25
|
+
/** Wall-clock of the last animation-tick render — for the interval throttle. */
|
|
26
|
+
private lastTickMs;
|
|
27
|
+
/** Bound `visibilitychange` handler — pause/resume the tick. */
|
|
28
|
+
private readonly onVisibilityChange;
|
|
29
|
+
constructor(host: AnimationHost);
|
|
30
|
+
private onTick;
|
|
31
|
+
/** Register the document visibility listener (browser host only). */
|
|
32
|
+
attach(): void;
|
|
33
|
+
/** Stop the tick and unregister the listener. */
|
|
34
|
+
detach(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Re-arm the tick after a change that may have brought an animated shape into
|
|
37
|
+
* (or out of) view — pan / zoom / scene edit. `AnimationTick.start()` no-ops
|
|
38
|
+
* when already running or when not animated, so this is cheap to call from
|
|
39
|
+
* `notify()`.
|
|
40
|
+
*/
|
|
41
|
+
maybe(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/editor/animation.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,yBAAyB,IAAI,OAAO,CAAC;IACrC,sDAAsD;IACtD,iBAAiB,IAAI,IAAI,CAAC;IAC1B,iEAAiE;IACjE,qBAAqB,IAAI,IAAI,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAclB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAbjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;IACrC,6EAA6E;IAC7E,OAAO,CAAC,OAAO,CAAK;IACpB,gFAAgF;IAChF,OAAO,CAAC,UAAU,CAAK;IAEvB,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAIjC;gBAE2B,IAAI,EAAE,aAAa;IAahD,OAAO,CAAC,MAAM;IAqBd,qEAAqE;IACrE,MAAM,IAAI,IAAI;IAMd,iDAAiD;IACjD,MAAM,IAAI,IAAI;IAOd;;;;;OAKG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AnimationTick } from "../animation-tick.js";
|
|
2
|
+
import { ANIMATION_MAX_INTERVAL_MS, ANIMATION_MIN_INTERVAL_MS, ANIMATION_COST_FACTOR, } from "../constants.js";
|
|
3
|
+
/**
|
|
4
|
+
* Owns the GIF/animation tick lifecycle: an adaptive render-cost throttle and
|
|
5
|
+
* visibility-based pause/resume. Runs while any shape carries
|
|
6
|
+
* `metadata.animated` and an animated shape is on-screen; self-terminates
|
|
7
|
+
* otherwise (the underlying `AnimationTick` checks `isAnimated` each frame).
|
|
8
|
+
*/
|
|
9
|
+
export class AnimationController {
|
|
10
|
+
host;
|
|
11
|
+
tick;
|
|
12
|
+
/** EMA of animation-tick render cost (ms) — drives the adaptive throttle. */
|
|
13
|
+
costEma = 0;
|
|
14
|
+
/** Wall-clock of the last animation-tick render — for the interval throttle. */
|
|
15
|
+
lastTickMs = 0;
|
|
16
|
+
/** Bound `visibilitychange` handler — pause/resume the tick. */
|
|
17
|
+
onVisibilityChange = () => {
|
|
18
|
+
if (typeof document === "undefined")
|
|
19
|
+
return;
|
|
20
|
+
if (document.hidden)
|
|
21
|
+
this.tick.stop();
|
|
22
|
+
else
|
|
23
|
+
this.maybe();
|
|
24
|
+
};
|
|
25
|
+
constructor(host) {
|
|
26
|
+
this.host = host;
|
|
27
|
+
this.tick = new AnimationTick({
|
|
28
|
+
// Keep ticking only while an animated shape is actually on-screen. Frame
|
|
29
|
+
// selection is wall-clock-based, so when the GIF scrolls back into view
|
|
30
|
+
// the tick resumes on the correct frame. Re-armed on viewport changes via
|
|
31
|
+
// `maybe()` in the editor's `notify()`.
|
|
32
|
+
isAnimated: () => this.host.hasVisibleAnimatedElement(),
|
|
33
|
+
onTick: () => {
|
|
34
|
+
this.onTick();
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
onTick() {
|
|
39
|
+
// Adaptive throttle — skip this rAF if an animation frame was rendered too
|
|
40
|
+
// recently. The target interval grows with the measured render cost so a
|
|
41
|
+
// heavy scene drops GIF fps instead of blowing the frame budget.
|
|
42
|
+
const now = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
43
|
+
const target = Math.min(ANIMATION_MAX_INTERVAL_MS, Math.max(ANIMATION_MIN_INTERVAL_MS, this.costEma * ANIMATION_COST_FACTOR));
|
|
44
|
+
if (now - this.lastTickMs < target)
|
|
45
|
+
return;
|
|
46
|
+
this.lastTickMs = now;
|
|
47
|
+
// Freeze heavy GIFs that have played long enough.
|
|
48
|
+
this.host.autoStopHeavyGifs();
|
|
49
|
+
// Force a full re-render: the scene reference hasn't changed, but the
|
|
50
|
+
// animation adapter advanced the GIF frame.
|
|
51
|
+
this.host.forceAnimationRepaint();
|
|
52
|
+
const cost = (typeof performance !== "undefined" ? performance.now() : Date.now()) - now;
|
|
53
|
+
// EMA so a single spike doesn't overreact; decays back when load drops.
|
|
54
|
+
this.costEma = this.costEma * 0.8 + cost * 0.2;
|
|
55
|
+
}
|
|
56
|
+
/** Register the document visibility listener (browser host only). */
|
|
57
|
+
attach() {
|
|
58
|
+
if (typeof document !== "undefined") {
|
|
59
|
+
document.addEventListener("visibilitychange", this.onVisibilityChange);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Stop the tick and unregister the listener. */
|
|
63
|
+
detach() {
|
|
64
|
+
this.tick.stop();
|
|
65
|
+
if (typeof document !== "undefined") {
|
|
66
|
+
document.removeEventListener("visibilitychange", this.onVisibilityChange);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Re-arm the tick after a change that may have brought an animated shape into
|
|
71
|
+
* (or out of) view — pan / zoom / scene edit. `AnimationTick.start()` no-ops
|
|
72
|
+
* when already running or when not animated, so this is cheap to call from
|
|
73
|
+
* `notify()`.
|
|
74
|
+
*/
|
|
75
|
+
maybe() {
|
|
76
|
+
if (this.host.hasVisibleAnimatedElement())
|
|
77
|
+
this.tick.start();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/editor/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAgBzB;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAcD;IAbZ,IAAI,CAAgB;IACrC,6EAA6E;IACrE,OAAO,GAAG,CAAC,CAA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C,MAAM,IAAI,GAAG,CAAC,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;QACzF,wEAAwE;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;IACjD,CAAC;IAED,qEAAqE;IACrE,MAAM;QACJ,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACjB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Element, type Patch, type Scene } from "@oh-just-another/scene";
|
|
2
|
+
import type { ElementId, Vec2 } from "@oh-just-another/types";
|
|
3
|
+
export type FlipAxis = "horizontal" | "vertical";
|
|
4
|
+
/** Which edge / centre line the selection aligns to within its bounding box. */
|
|
5
|
+
export type AlignEdge = "left" | "h-center" | "right" | "top" | "v-center" | "bottom";
|
|
6
|
+
/** Axis along which the selection is evenly distributed. */
|
|
7
|
+
export type DistributeAxis = "horizontal" | "vertical";
|
|
8
|
+
/** Press-time snapshot for a rotate gesture: each element's pristine pose. */
|
|
9
|
+
export type RotateOrigin = ReadonlyMap<ElementId, {
|
|
10
|
+
position: Vec2;
|
|
11
|
+
rotation: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Pure: mirror every selected element about the combined selection's centre on
|
|
15
|
+
* the given axis. Each element's position reflects across the centre and its
|
|
16
|
+
* scale sign flips on that axis, so the content mirrors in place; size is
|
|
17
|
+
* unchanged. Mirroring a single element flips it about its own centre. Edges
|
|
18
|
+
* bound to the moved elements re-route from their endpoints; free links are
|
|
19
|
+
* left untouched.
|
|
20
|
+
*/
|
|
21
|
+
export declare const computeFlipPatches: (scene: Scene, ids: Iterable<ElementId>, axis: FlipAxis) => Patch[];
|
|
22
|
+
/**
|
|
23
|
+
* Pure: align every selected element to the given edge / centre line of the
|
|
24
|
+
* combined selection's bounding box (e.g. `left` moves each shape so its left
|
|
25
|
+
* edge meets the box's left edge; `h-center` lines up horizontal centres).
|
|
26
|
+
* Only the relevant axis moves; sizes are unchanged. A no-op below two
|
|
27
|
+
* elements.
|
|
28
|
+
*/
|
|
29
|
+
export declare const computeAlignPatches: (scene: Scene, ids: Iterable<ElementId>, edge: AlignEdge) => Patch[];
|
|
30
|
+
/**
|
|
31
|
+
* Pure: evenly space the selection along the given axis so the gaps between
|
|
32
|
+
* adjacent elements are equal. The outermost two elements stay put; the rest
|
|
33
|
+
* shift to balance the gaps (accounting for differing sizes). A no-op below
|
|
34
|
+
* three elements.
|
|
35
|
+
*/
|
|
36
|
+
export declare const computeDistributePatches: (scene: Scene, ids: Iterable<ElementId>, axis: DistributeAxis) => Patch[];
|
|
37
|
+
/**
|
|
38
|
+
* Pure: rotate the snapshotted elements by `delta` radians about `pivot`. Each
|
|
39
|
+
* element orbits the pivot (its `position` rotates around it) and its own
|
|
40
|
+
* `rotation` advances by `delta`, so the whole selection turns rigidly. Driven
|
|
41
|
+
* from a press-time {@link RotateOrigin} so the cumulative angle never drifts.
|
|
42
|
+
*/
|
|
43
|
+
export declare const computeRotatePatches: (scene: Scene, origin: RotateOrigin, pivot: Vec2, delta: number) => Patch[];
|
|
44
|
+
/** Centre of the world AABB enclosing `elements` — the natural rotation pivot. */
|
|
45
|
+
export declare const selectionCenter: (elements: readonly Element[]) => Vec2;
|
|
46
|
+
//# sourceMappingURL=arrange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrange.d.ts","sourceRoot":"","sources":["../../../src/editor/applies/arrange.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAU,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjD,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtF,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,EAAE;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAgBxF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,QAAQ,KACb,KAAK,EAwBP,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,SAAS,KACd,KAAK,EAmCP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,c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