@oh-just-another/state 0.57.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 +18 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/actions/actionClipboard.d.ts +6 -0
- package/dist/actions/actionClipboard.d.ts.map +1 -0
- package/dist/actions/actionClipboard.js +26 -0
- package/dist/actions/actionClipboard.js.map +1 -0
- package/dist/actions/actionGrouping.d.ts +5 -0
- package/dist/actions/actionGrouping.d.ts.map +1 -0
- package/dist/actions/actionGrouping.js +26 -0
- package/dist/actions/actionGrouping.js.map +1 -0
- package/dist/actions/actionHistory.d.ts +5 -0
- package/dist/actions/actionHistory.d.ts.map +1 -0
- package/dist/actions/actionHistory.js +25 -0
- package/dist/actions/actionHistory.js.map +1 -0
- package/dist/actions/actionKeyboard.d.ts +3 -0
- package/dist/actions/actionKeyboard.d.ts.map +1 -0
- package/dist/actions/actionKeyboard.js +130 -0
- package/dist/actions/actionKeyboard.js.map +1 -0
- package/dist/actions/actionLayout.d.ts +3 -0
- package/dist/actions/actionLayout.d.ts.map +1 -0
- package/dist/actions/actionLayout.js +65 -0
- package/dist/actions/actionLayout.js.map +1 -0
- package/dist/actions/actionMode.d.ts +13 -0
- package/dist/actions/actionMode.d.ts.map +1 -0
- package/dist/actions/actionMode.js +116 -0
- package/dist/actions/actionMode.js.map +1 -0
- package/dist/actions/actionSelection.d.ts +9 -0
- package/dist/actions/actionSelection.d.ts.map +1 -0
- package/dist/actions/actionSelection.js +57 -0
- package/dist/actions/actionSelection.js.map +1 -0
- package/dist/actions/actionView.d.ts +7 -0
- package/dist/actions/actionView.d.ts.map +1 -0
- package/dist/actions/actionView.js +14 -0
- package/dist/actions/actionView.js.map +1 -0
- package/dist/actions/actionZOrder.d.ts +7 -0
- package/dist/actions/actionZOrder.d.ts.map +1 -0
- package/dist/actions/actionZOrder.js +42 -0
- package/dist/actions/actionZOrder.js.map +1 -0
- package/dist/actions/actionZoom.d.ts +8 -0
- package/dist/actions/actionZoom.d.ts.map +1 -0
- package/dist/actions/actionZoom.js +61 -0
- package/dist/actions/actionZoom.js.map +1 -0
- package/dist/actions/index.d.ts +12 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +11 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/registry.d.ts +68 -0
- package/dist/actions/registry.d.ts.map +1 -0
- package/dist/actions/registry.js +300 -0
- package/dist/actions/registry.js.map +1 -0
- package/dist/actions/types.d.ts +103 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +10 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/animation-tick.d.ts +28 -0
- package/dist/animation-tick.d.ts.map +1 -0
- package/dist/animation-tick.js +50 -0
- package/dist/animation-tick.js.map +1 -0
- package/dist/auto-compact.d.ts +27 -0
- package/dist/auto-compact.d.ts.map +1 -0
- package/dist/auto-compact.js +46 -0
- package/dist/auto-compact.js.map +1 -0
- package/dist/auto-layout-scheduler.d.ts +50 -0
- package/dist/auto-layout-scheduler.d.ts.map +1 -0
- package/dist/auto-layout-scheduler.js +94 -0
- package/dist/auto-layout-scheduler.js.map +1 -0
- package/dist/built-in-handlers.d.ts +24 -0
- package/dist/built-in-handlers.d.ts.map +1 -0
- package/dist/built-in-handlers.js +210 -0
- package/dist/built-in-handlers.js.map +1 -0
- package/dist/clipboard.d.ts +51 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +105 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/constants.d.ts +544 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +537 -0
- package/dist/constants.js.map +1 -0
- package/dist/dom-events.d.ts +13 -0
- package/dist/dom-events.d.ts.map +1 -0
- package/dist/dom-events.js +70 -0
- package/dist/dom-events.js.map +1 -0
- package/dist/editor/anchor-points.d.ts +22 -0
- package/dist/editor/anchor-points.d.ts.map +1 -0
- package/dist/editor/anchor-points.js +28 -0
- package/dist/editor/anchor-points.js.map +1 -0
- package/dist/editor/applies/create.d.ts +60 -0
- package/dist/editor/applies/create.d.ts.map +1 -0
- package/dist/editor/applies/create.js +107 -0
- package/dist/editor/applies/create.js.map +1 -0
- package/dist/editor/applies/edge.d.ts +32 -0
- package/dist/editor/applies/edge.d.ts.map +1 -0
- package/dist/editor/applies/edge.js +44 -0
- package/dist/editor/applies/edge.js.map +1 -0
- package/dist/editor/applies/link-move.d.ts +53 -0
- package/dist/editor/applies/link-move.d.ts.map +1 -0
- package/dist/editor/applies/link-move.js +160 -0
- package/dist/editor/applies/link-move.js.map +1 -0
- package/dist/editor/applies/move.d.ts +38 -0
- package/dist/editor/applies/move.d.ts.map +1 -0
- package/dist/editor/applies/move.js +83 -0
- package/dist/editor/applies/move.js.map +1 -0
- package/dist/editor/applies/resize.d.ts +68 -0
- package/dist/editor/applies/resize.d.ts.map +1 -0
- package/dist/editor/applies/resize.js +199 -0
- package/dist/editor/applies/resize.js.map +1 -0
- package/dist/editor/applies/selection.d.ts +34 -0
- package/dist/editor/applies/selection.d.ts.map +1 -0
- package/dist/editor/applies/selection.js +65 -0
- package/dist/editor/applies/selection.js.map +1 -0
- package/dist/editor/applies/snap-grid.d.ts +45 -0
- package/dist/editor/applies/snap-grid.d.ts.map +1 -0
- package/dist/editor/applies/snap-grid.js +90 -0
- package/dist/editor/applies/snap-grid.js.map +1 -0
- package/dist/editor/container-ops.d.ts +74 -0
- package/dist/editor/container-ops.d.ts.map +1 -0
- package/dist/editor/container-ops.js +262 -0
- package/dist/editor/container-ops.js.map +1 -0
- package/dist/editor/event-fanout.d.ts +48 -0
- package/dist/editor/event-fanout.d.ts.map +1 -0
- package/dist/editor/event-fanout.js +53 -0
- package/dist/editor/event-fanout.js.map +1 -0
- package/dist/editor/gesture-tx.d.ts +77 -0
- package/dist/editor/gesture-tx.d.ts.map +1 -0
- package/dist/editor/gesture-tx.js +93 -0
- package/dist/editor/gesture-tx.js.map +1 -0
- package/dist/editor/hit-test.d.ts +178 -0
- package/dist/editor/hit-test.d.ts.map +1 -0
- package/dist/editor/hit-test.js +460 -0
- package/dist/editor/hit-test.js.map +1 -0
- package/dist/editor/long-press.d.ts +34 -0
- package/dist/editor/long-press.d.ts.map +1 -0
- package/dist/editor/long-press.js +58 -0
- package/dist/editor/long-press.js.map +1 -0
- package/dist/editor/pinch.d.ts +37 -0
- package/dist/editor/pinch.d.ts.map +1 -0
- package/dist/editor/pinch.js +90 -0
- package/dist/editor/pinch.js.map +1 -0
- package/dist/editor/pointer-binding.d.ts +18 -0
- package/dist/editor/pointer-binding.d.ts.map +1 -0
- package/dist/editor/pointer-binding.js +1087 -0
- package/dist/editor/pointer-binding.js.map +1 -0
- package/dist/editor/public/annotations.d.ts +54 -0
- package/dist/editor/public/annotations.d.ts.map +1 -0
- package/dist/editor/public/annotations.js +106 -0
- package/dist/editor/public/annotations.js.map +1 -0
- package/dist/editor/public/arrange-group.d.ts +81 -0
- package/dist/editor/public/arrange-group.d.ts.map +1 -0
- package/dist/editor/public/arrange-group.js +193 -0
- package/dist/editor/public/arrange-group.js.map +1 -0
- package/dist/editor/public/brush.d.ts +33 -0
- package/dist/editor/public/brush.d.ts.map +1 -0
- package/dist/editor/public/brush.js +54 -0
- package/dist/editor/public/brush.js.map +1 -0
- package/dist/editor/public/clipboard.d.ts +31 -0
- package/dist/editor/public/clipboard.d.ts.map +1 -0
- package/dist/editor/public/clipboard.js +35 -0
- package/dist/editor/public/clipboard.js.map +1 -0
- package/dist/editor/public/image-insert.d.ts +30 -0
- package/dist/editor/public/image-insert.d.ts.map +1 -0
- package/dist/editor/public/image-insert.js +57 -0
- package/dist/editor/public/image-insert.js.map +1 -0
- package/dist/editor/public/layers.d.ts +56 -0
- package/dist/editor/public/layers.d.ts.map +1 -0
- package/dist/editor/public/layers.js +104 -0
- package/dist/editor/public/layers.js.map +1 -0
- package/dist/editor/public/link.d.ts +25 -0
- package/dist/editor/public/link.d.ts.map +1 -0
- package/dist/editor/public/link.js +74 -0
- package/dist/editor/public/link.js.map +1 -0
- package/dist/editor/public/placement.d.ts +60 -0
- package/dist/editor/public/placement.d.ts.map +1 -0
- package/dist/editor/public/placement.js +111 -0
- package/dist/editor/public/placement.js.map +1 -0
- package/dist/editor/public/selection-ops.d.ts +78 -0
- package/dist/editor/public/selection-ops.d.ts.map +1 -0
- package/dist/editor/public/selection-ops.js +226 -0
- package/dist/editor/public/selection-ops.js.map +1 -0
- package/dist/editor/public/text-edit.d.ts +17 -0
- package/dist/editor/public/text-edit.d.ts.map +1 -0
- package/dist/editor/public/text-edit.js +28 -0
- package/dist/editor/public/text-edit.js.map +1 -0
- package/dist/editor/public/z-order.d.ts +47 -0
- package/dist/editor/public/z-order.d.ts.map +1 -0
- package/dist/editor/public/z-order.js +151 -0
- package/dist/editor/public/z-order.js.map +1 -0
- package/dist/editor/public/zoom-pan.d.ts +44 -0
- package/dist/editor/public/zoom-pan.d.ts.map +1 -0
- package/dist/editor/public/zoom-pan.js +116 -0
- package/dist/editor/public/zoom-pan.js.map +1 -0
- package/dist/editor/render-orchestrator.d.ts +11 -0
- package/dist/editor/render-orchestrator.d.ts.map +1 -0
- package/dist/editor/render-orchestrator.js +473 -0
- package/dist/editor/render-orchestrator.js.map +1 -0
- package/dist/editor/resize-helpers.d.ts +30 -0
- package/dist/editor/resize-helpers.d.ts.map +1 -0
- package/dist/editor/resize-helpers.js +121 -0
- package/dist/editor/resize-helpers.js.map +1 -0
- package/dist/editor/shape-filters.d.ts +11 -0
- package/dist/editor/shape-filters.d.ts.map +1 -0
- package/dist/editor/shape-filters.js +19 -0
- package/dist/editor/shape-filters.js.map +1 -0
- package/dist/editor/shape-traits.d.ts +16 -0
- package/dist/editor/shape-traits.d.ts.map +1 -0
- package/dist/editor/shape-traits.js +29 -0
- package/dist/editor/shape-traits.js.map +1 -0
- package/dist/editor/viewport-helpers.d.ts +24 -0
- package/dist/editor/viewport-helpers.d.ts.map +1 -0
- package/dist/editor/viewport-helpers.js +63 -0
- package/dist/editor/viewport-helpers.js.map +1 -0
- package/dist/editor-events.d.ts +33 -0
- package/dist/editor-events.d.ts.map +1 -0
- package/dist/editor-events.js +2 -0
- package/dist/editor-events.js.map +1 -0
- package/dist/editor.d.ts +1841 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +4803 -0
- package/dist/editor.js.map +1 -0
- package/dist/file-drop.d.ts +99 -0
- package/dist/file-drop.d.ts.map +1 -0
- package/dist/file-drop.js +198 -0
- package/dist/file-drop.js.map +1 -0
- package/dist/frame-helpers.d.ts +30 -0
- package/dist/frame-helpers.d.ts.map +1 -0
- package/dist/frame-helpers.js +105 -0
- package/dist/frame-helpers.js.map +1 -0
- package/dist/group-helpers.d.ts +39 -0
- package/dist/group-helpers.d.ts.map +1 -0
- package/dist/group-helpers.js +116 -0
- package/dist/group-helpers.js.map +1 -0
- package/dist/handle.d.ts +73 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +184 -0
- package/dist/handle.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.d.ts +21 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +11 -0
- package/dist/interactive.js.map +1 -0
- package/dist/link-selection.d.ts +21 -0
- package/dist/link-selection.d.ts.map +1 -0
- package/dist/link-selection.js +37 -0
- package/dist/link-selection.js.map +1 -0
- package/dist/machine.d.ts +322 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +568 -0
- package/dist/machine.js.map +1 -0
- package/dist/modes.d.ts +24 -0
- package/dist/modes.d.ts.map +1 -0
- package/dist/modes.js +2 -0
- package/dist/modes.js.map +1 -0
- package/dist/overlay.d.ts +262 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +673 -0
- package/dist/overlay.js.map +1 -0
- package/dist/platform.d.ts +70 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +115 -0
- package/dist/platform.js.map +1 -0
- package/dist/selection.d.ts +18 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +31 -0
- package/dist/selection.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Bounds, Vec2 } from "@oh-just-another/types";
|
|
2
|
+
import type { HandleId } from "../handle.js";
|
|
3
|
+
/**
|
|
4
|
+
* Equivalent to `handle.resizeBounds` for the case where the shape's local
|
|
5
|
+
* AABB starts at (0, 0) — applies the delta directly to the world bounds
|
|
6
|
+
* captured at press-down. Duplicated from `handle.ts` to avoid a circular
|
|
7
|
+
* import.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resizeFromHandle: (b: Bounds, handle: HandleId, delta: Vec2) => Bounds;
|
|
10
|
+
export interface ResizeConstraints {
|
|
11
|
+
readonly minWidth?: number;
|
|
12
|
+
readonly minHeight?: number;
|
|
13
|
+
readonly maxWidth?: number;
|
|
14
|
+
readonly maxHeight?: number;
|
|
15
|
+
readonly noFlip?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Apply min/max + no-flip constraints to a freshly-computed `raw` bounds.
|
|
19
|
+
*
|
|
20
|
+
* The constraints anchor on the edge opposite the dragged handle — dragging
|
|
21
|
+
* `se` keeps `(original.x, original.y)` fixed and adjusts width/height;
|
|
22
|
+
* dragging `nw` keeps the bottom-right corner. This matches the visual
|
|
23
|
+
* expectation that the opposite edge stays put.
|
|
24
|
+
*
|
|
25
|
+
* `noFlip` forces width/height to stay non-negative (or above `minWidth` /
|
|
26
|
+
* `minHeight` if set). Without it, dragging past the opposite edge mirrors
|
|
27
|
+
* the shape, which `bounds.normalize` then resolves.
|
|
28
|
+
*/
|
|
29
|
+
export declare const applyResizeConstraints: (original: Bounds, raw: Bounds, handle: HandleId, constraints: ResizeConstraints) => Bounds;
|
|
30
|
+
//# sourceMappingURL=resize-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-helpers.d.ts","sourceRoot":"","sources":["../../src/editor/resize-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,MAAM,EAAE,QAAQ,QAAQ,EAAE,OAAO,IAAI,KAAG,MA0C3E,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAOD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,EAChB,KAAK,MAAM,EACX,QAAQ,QAAQ,EAChB,aAAa,iBAAiB,KAC7B,MAkDF,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { bounds as B } from "@oh-just-another/math";
|
|
2
|
+
/**
|
|
3
|
+
* Equivalent to `handle.resizeBounds` for the case where the shape's local
|
|
4
|
+
* AABB starts at (0, 0) — applies the delta directly to the world bounds
|
|
5
|
+
* captured at press-down. Duplicated from `handle.ts` to avoid a circular
|
|
6
|
+
* import.
|
|
7
|
+
*/
|
|
8
|
+
export const resizeFromHandle = (b, handle, delta) => {
|
|
9
|
+
let x = b.x;
|
|
10
|
+
let y = b.y;
|
|
11
|
+
let width = b.width;
|
|
12
|
+
let height = b.height;
|
|
13
|
+
switch (handle) {
|
|
14
|
+
case "nw":
|
|
15
|
+
x += delta.x;
|
|
16
|
+
y += delta.y;
|
|
17
|
+
width -= delta.x;
|
|
18
|
+
height -= delta.y;
|
|
19
|
+
break;
|
|
20
|
+
case "n":
|
|
21
|
+
y += delta.y;
|
|
22
|
+
height -= delta.y;
|
|
23
|
+
break;
|
|
24
|
+
case "ne":
|
|
25
|
+
y += delta.y;
|
|
26
|
+
width += delta.x;
|
|
27
|
+
height -= delta.y;
|
|
28
|
+
break;
|
|
29
|
+
case "e":
|
|
30
|
+
width += delta.x;
|
|
31
|
+
break;
|
|
32
|
+
case "se":
|
|
33
|
+
width += delta.x;
|
|
34
|
+
height += delta.y;
|
|
35
|
+
break;
|
|
36
|
+
case "s":
|
|
37
|
+
height += delta.y;
|
|
38
|
+
break;
|
|
39
|
+
case "sw":
|
|
40
|
+
x += delta.x;
|
|
41
|
+
width -= delta.x;
|
|
42
|
+
height += delta.y;
|
|
43
|
+
break;
|
|
44
|
+
case "w":
|
|
45
|
+
x += delta.x;
|
|
46
|
+
width -= delta.x;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return { x, y, width, height };
|
|
50
|
+
};
|
|
51
|
+
const handleAffectsLeft = (h) => h === "nw" || h === "w" || h === "sw";
|
|
52
|
+
const handleAffectsRight = (h) => h === "ne" || h === "e" || h === "se";
|
|
53
|
+
const handleAffectsTop = (h) => h === "nw" || h === "n" || h === "ne";
|
|
54
|
+
const handleAffectsBottom = (h) => h === "sw" || h === "s" || h === "se";
|
|
55
|
+
/**
|
|
56
|
+
* Apply min/max + no-flip constraints to a freshly-computed `raw` bounds.
|
|
57
|
+
*
|
|
58
|
+
* The constraints anchor on the edge opposite the dragged handle — dragging
|
|
59
|
+
* `se` keeps `(original.x, original.y)` fixed and adjusts width/height;
|
|
60
|
+
* dragging `nw` keeps the bottom-right corner. This matches the visual
|
|
61
|
+
* expectation that the opposite edge stays put.
|
|
62
|
+
*
|
|
63
|
+
* `noFlip` forces width/height to stay non-negative (or above `minWidth` /
|
|
64
|
+
* `minHeight` if set). Without it, dragging past the opposite edge mirrors
|
|
65
|
+
* the shape, which `bounds.normalize` then resolves.
|
|
66
|
+
*/
|
|
67
|
+
export const applyResizeConstraints = (original, raw, handle, constraints) => {
|
|
68
|
+
const minW = constraints.noFlip ? (constraints.minWidth ?? 0) : constraints.minWidth;
|
|
69
|
+
const minH = constraints.noFlip ? (constraints.minHeight ?? 0) : constraints.minHeight;
|
|
70
|
+
const maxW = constraints.maxWidth;
|
|
71
|
+
const maxH = constraints.maxHeight;
|
|
72
|
+
const clamp = (v, lo, hi) => {
|
|
73
|
+
let r = v;
|
|
74
|
+
if (lo !== undefined && r < lo)
|
|
75
|
+
r = lo;
|
|
76
|
+
if (hi !== undefined && r > hi)
|
|
77
|
+
r = hi;
|
|
78
|
+
return r;
|
|
79
|
+
};
|
|
80
|
+
const left = handleAffectsLeft(handle);
|
|
81
|
+
const right = handleAffectsRight(handle);
|
|
82
|
+
const top = handleAffectsTop(handle);
|
|
83
|
+
const bottom = handleAffectsBottom(handle);
|
|
84
|
+
let x = raw.x;
|
|
85
|
+
let width = raw.width;
|
|
86
|
+
if (constraints.noFlip) {
|
|
87
|
+
width = clamp(width, minW, maxW);
|
|
88
|
+
}
|
|
89
|
+
else if (maxW !== undefined && Math.abs(width) > maxW) {
|
|
90
|
+
width = width < 0 ? -maxW : maxW;
|
|
91
|
+
}
|
|
92
|
+
else if (minW !== undefined && Math.abs(width) < minW && width !== 0) {
|
|
93
|
+
width = width < 0 ? -minW : minW;
|
|
94
|
+
}
|
|
95
|
+
if (left && !right) {
|
|
96
|
+
x = original.x + original.width - width;
|
|
97
|
+
}
|
|
98
|
+
else if (right && !left) {
|
|
99
|
+
x = original.x;
|
|
100
|
+
}
|
|
101
|
+
let y = raw.y;
|
|
102
|
+
let height = raw.height;
|
|
103
|
+
if (constraints.noFlip) {
|
|
104
|
+
height = clamp(height, minH, maxH);
|
|
105
|
+
}
|
|
106
|
+
else if (maxH !== undefined && Math.abs(height) > maxH) {
|
|
107
|
+
height = height < 0 ? -maxH : maxH;
|
|
108
|
+
}
|
|
109
|
+
else if (minH !== undefined && Math.abs(height) < minH && height !== 0) {
|
|
110
|
+
height = height < 0 ? -minH : minH;
|
|
111
|
+
}
|
|
112
|
+
if (top && !bottom) {
|
|
113
|
+
y = original.y + original.height - height;
|
|
114
|
+
}
|
|
115
|
+
else if (bottom && !top) {
|
|
116
|
+
y = original.y;
|
|
117
|
+
}
|
|
118
|
+
const out = { x, y, width, height };
|
|
119
|
+
return constraints.noFlip ? out : B.normalize(out);
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=resize-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-helpers.js","sourceRoot":"","sources":["../../src/editor/resize-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAIpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAE,MAAgB,EAAE,KAAW,EAAU,EAAE;IACnF,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACZ,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACZ,IAAI,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACpB,IAAI,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACb,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACb,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,GAAG;YACN,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,IAAI;YACP,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACb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I,MAAM,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnB,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;IAC5C,CAAC;SAAM,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ElementId } from "@oh-just-another/types";
|
|
2
|
+
import { type Scene } from "@oh-just-another/scene";
|
|
3
|
+
/**
|
|
4
|
+
* Collect every shape that should be hidden this frame due to its own
|
|
5
|
+
* `hidden` flag or that of any ancestor via `parentId`. Returns `undefined`
|
|
6
|
+
* when nothing is hidden, keeping the `RenderSceneOptions` payload empty in
|
|
7
|
+
* the common case so the renderer's hot loop can skip the `has()` check
|
|
8
|
+
* entirely.
|
|
9
|
+
*/
|
|
10
|
+
export declare const computeHiddenElements: (scene: Scene) => ReadonlySet<ElementId> | undefined;
|
|
11
|
+
//# sourceMappingURL=shape-filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-filters.d.ts","sourceRoot":"","sources":["../../src/editor/shape-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,KAAK,KAAG,WAAW,CAAC,SAAS,CAAC,GAAG,SAS7E,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isElementHidden } from "@oh-just-another/scene";
|
|
2
|
+
/**
|
|
3
|
+
* Collect every shape that should be hidden this frame due to its own
|
|
4
|
+
* `hidden` flag or that of any ancestor via `parentId`. Returns `undefined`
|
|
5
|
+
* when nothing is hidden, keeping the `RenderSceneOptions` payload empty in
|
|
6
|
+
* the common case so the renderer's hot loop can skip the `has()` check
|
|
7
|
+
* entirely.
|
|
8
|
+
*/
|
|
9
|
+
export const computeHiddenElements = (scene) => {
|
|
10
|
+
let out = null;
|
|
11
|
+
for (const s of scene.elements.values()) {
|
|
12
|
+
if (isElementHidden(scene, s)) {
|
|
13
|
+
out ??= new Set();
|
|
14
|
+
out.add(s.id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return out ?? undefined;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=shape-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-filters.js","sourceRoot":"","sources":["../../src/editor/shape-filters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAc,MAAM,wBAAwB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAsC,EAAE;IACxF,IAAI,GAAG,GAA0B,IAAI,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,IAAI,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;YAC9B,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;YAClB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,IAAI,SAAS,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Element, ElementBase } from "@oh-just-another/scene";
|
|
2
|
+
import { type HandleId } from "../handle.js";
|
|
3
|
+
/**
|
|
4
|
+
* True when the shape's geometry is parametrised by `width` / `height` fields
|
|
5
|
+
* the editor can rewrite directly during a resize. Anything else (paths,
|
|
6
|
+
* polygons, brush strokes, text, groups) has to ride the `scale` multiplier
|
|
7
|
+
* instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const hasWidthHeight: (s: Element) => s is Element & {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const isResizable: (shape: ElementBase) => boolean;
|
|
14
|
+
/** Which handles a resizable shape offers. All 8 for every type. */
|
|
15
|
+
export declare const resizeHandlesFor: (_shape: ElementBase) => readonly HandleId[];
|
|
16
|
+
//# sourceMappingURL=shape-traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-traits.d.ts","sourceRoot":"","sources":["../../src/editor/shape-traits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAKtE,CAAC;AAgBrB,eAAO,MAAM,WAAW,GAAI,OAAO,WAAW,KAAG,OAA0C,CAAC;AAE5F,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,GAAI,QAAQ,WAAW,KAAG,SAAS,QAAQ,EAAiB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ALL_HANDLES } from "../handle.js";
|
|
2
|
+
/**
|
|
3
|
+
* True when the shape's geometry is parametrised by `width` / `height` fields
|
|
4
|
+
* the editor can rewrite directly during a resize. Anything else (paths,
|
|
5
|
+
* polygons, brush strokes, text, groups) has to ride the `scale` multiplier
|
|
6
|
+
* instead.
|
|
7
|
+
*/
|
|
8
|
+
export const hasWidthHeight = (s) => s.type === "rectangle" ||
|
|
9
|
+
s.type === "ellipse" ||
|
|
10
|
+
s.type === "image" ||
|
|
11
|
+
s.type === "template" ||
|
|
12
|
+
s.type === "frame";
|
|
13
|
+
/**
|
|
14
|
+
* Element types that expose interactive resize handles (single-selection
|
|
15
|
+
* chrome + handle hit-test). Lives in this neutral traits module so the
|
|
16
|
+
* selection overlay, the hit-test, and the debug hit-zone viz share one
|
|
17
|
+
* predicate without importing each other.
|
|
18
|
+
*/
|
|
19
|
+
const RESIZABLE_TYPES = new Set([
|
|
20
|
+
"rectangle",
|
|
21
|
+
"ellipse",
|
|
22
|
+
"template",
|
|
23
|
+
"text",
|
|
24
|
+
"frame",
|
|
25
|
+
]);
|
|
26
|
+
export const isResizable = (shape) => RESIZABLE_TYPES.has(shape.type);
|
|
27
|
+
/** Which handles a resizable shape offers. All 8 for every type. */
|
|
28
|
+
export const resizeHandlesFor = (_shape) => ALL_HANDLES;
|
|
29
|
+
//# sourceMappingURL=shape-traits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-traits.js","sourceRoot":"","sources":["../../src/editor/shape-traits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAU,EAAoD,EAAE,CAC7F,CAAC,CAAC,IAAI,KAAK,WAAW;IACtB,CAAC,CAAC,IAAI,KAAK,SAAS;IACpB,CAAC,CAAC,IAAI,KAAK,OAAO;IAClB,CAAC,CAAC,IAAI,KAAK,UAAU;IACrB,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;AAErB;;;;;GAKG;AACH,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACnD,WAAW;IACX,SAAS;IACT,UAAU;IACV,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAkB,EAAW,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAE5F,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAuB,EAAE,CAAC,WAAW,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Bounds, ElementId } from "@oh-just-another/types";
|
|
2
|
+
import { type Scene } from "@oh-just-another/scene";
|
|
3
|
+
/**
|
|
4
|
+
* World-space AABB of the screen viewport, inflated by ~10% so a slow pan
|
|
5
|
+
* does not flicker shapes near the edge. Returns `null` until the host has
|
|
6
|
+
* resized the viewport at least once (size is 0×0). Depends only on
|
|
7
|
+
* `scene.viewport`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const computeViewportWorld: (scene: Scene) => Bounds | null;
|
|
10
|
+
/**
|
|
11
|
+
* Union of every direct/indirect descendant's world AABB. `null` for empty
|
|
12
|
+
* groups (the only failure mode — every leaf has bounds). Used to derive an
|
|
13
|
+
* effective bbox for a group shape since `getElementWorldBounds(group)`
|
|
14
|
+
* returns nothing intrinsic.
|
|
15
|
+
*/
|
|
16
|
+
export declare const groupChildrenUnion: (scene: Scene, groupId: ElementId) => Bounds | null;
|
|
17
|
+
/**
|
|
18
|
+
* Combined world-space AABB of every currently selected shape. Returns `null`
|
|
19
|
+
* when the selection is empty or none of its members resolve to a valid
|
|
20
|
+
* shape. Group shapes carry no intrinsic geometry, so substitute their
|
|
21
|
+
* `groupChildrenUnion`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const combinedSelectionBounds: (scene: Scene, selection: Iterable<ElementId>) => Bounds | null;
|
|
24
|
+
//# sourceMappingURL=viewport-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport-helpers.d.ts","sourceRoot":"","sources":["../../src/editor/viewport-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAIL,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAGhC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,KAAK,KAAG,MAAM,GAAG,IAc5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,KAAK,EAAE,SAAS,SAAS,KAAG,MAAM,GAAG,IAU9E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,KAAK,EACZ,WAAW,QAAQ,CAAC,SAAS,CAAC,KAC7B,MAAM,GAAG,IAUX,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { bounds as B, matrix } from "@oh-just-another/math";
|
|
2
|
+
import { getScreenToWorld, getElement, getElementWorldBounds, } from "@oh-just-another/scene";
|
|
3
|
+
import { VIEWPORT_CULL_PADDING_RATIO } from "../constants.js";
|
|
4
|
+
/**
|
|
5
|
+
* World-space AABB of the screen viewport, inflated by ~10% so a slow pan
|
|
6
|
+
* does not flicker shapes near the edge. Returns `null` until the host has
|
|
7
|
+
* resized the viewport at least once (size is 0×0). Depends only on
|
|
8
|
+
* `scene.viewport`.
|
|
9
|
+
*/
|
|
10
|
+
export const computeViewportWorld = (scene) => {
|
|
11
|
+
const vp = scene.viewport;
|
|
12
|
+
const w = vp.size.width;
|
|
13
|
+
const h = vp.size.height;
|
|
14
|
+
if (w <= 0 || h <= 0)
|
|
15
|
+
return null;
|
|
16
|
+
const s2w = getScreenToWorld(vp);
|
|
17
|
+
const corners = [
|
|
18
|
+
matrix.applyToPoint(s2w, { x: 0, y: 0 }),
|
|
19
|
+
matrix.applyToPoint(s2w, { x: w, y: 0 }),
|
|
20
|
+
matrix.applyToPoint(s2w, { x: 0, y: h }),
|
|
21
|
+
matrix.applyToPoint(s2w, { x: w, y: h }),
|
|
22
|
+
];
|
|
23
|
+
const bb = B.fromPoints(corners);
|
|
24
|
+
return B.expand(bb, Math.max(bb.width, bb.height) * VIEWPORT_CULL_PADDING_RATIO);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Union of every direct/indirect descendant's world AABB. `null` for empty
|
|
28
|
+
* groups (the only failure mode — every leaf has bounds). Used to derive an
|
|
29
|
+
* effective bbox for a group shape since `getElementWorldBounds(group)`
|
|
30
|
+
* returns nothing intrinsic.
|
|
31
|
+
*/
|
|
32
|
+
export const groupChildrenUnion = (scene, groupId) => {
|
|
33
|
+
let acc = null;
|
|
34
|
+
for (const s of scene.elements.values()) {
|
|
35
|
+
if (s.parentId !== groupId)
|
|
36
|
+
continue;
|
|
37
|
+
const inner = s.type === "group" ? groupChildrenUnion(scene, s.id) : getElementWorldBounds(s);
|
|
38
|
+
if (!inner)
|
|
39
|
+
continue;
|
|
40
|
+
acc = acc ? B.union(acc, inner) : inner;
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Combined world-space AABB of every currently selected shape. Returns `null`
|
|
46
|
+
* when the selection is empty or none of its members resolve to a valid
|
|
47
|
+
* shape. Group shapes carry no intrinsic geometry, so substitute their
|
|
48
|
+
* `groupChildrenUnion`.
|
|
49
|
+
*/
|
|
50
|
+
export const combinedSelectionBounds = (scene, selection) => {
|
|
51
|
+
let acc = null;
|
|
52
|
+
for (const id of selection) {
|
|
53
|
+
const s = getElement(scene, id);
|
|
54
|
+
if (!s)
|
|
55
|
+
continue;
|
|
56
|
+
const b = s.type === "group" ? groupChildrenUnion(scene, s.id) : getElementWorldBounds(s);
|
|
57
|
+
if (!b)
|
|
58
|
+
continue;
|
|
59
|
+
acc = acc ? B.union(acc, b) : b;
|
|
60
|
+
}
|
|
61
|
+
return acc;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=viewport-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport-helpers.js","sourceRoot":"","sources":["../../src/editor/viewport-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,qBAAqB,GAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAY,EAAiB,EAAE;IAClE,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;IACxB,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;IACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG;QACd,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC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AAI,KAAK,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,CAAC;YAAE,SAAS;QACjB,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Scene } from "@oh-just-another/scene";
|
|
2
|
+
import type * as Selection from "./selection.js";
|
|
3
|
+
import type { Mode } from "./modes.js";
|
|
4
|
+
/**
|
|
5
|
+
* Typed event surface for `Editor`. Each event has a focused payload so
|
|
6
|
+
* subscribers listen only to what they care about — `useMode` re-renders
|
|
7
|
+
* on `mode` only, `useHistory` on `history`, etc. The umbrella `change`
|
|
8
|
+
* event keeps the `editor.subscribe(fn)` contract: anything that fires a
|
|
9
|
+
* specific event also fires `change` so coarse-grained listeners still
|
|
10
|
+
* wake up exactly once per logical update.
|
|
11
|
+
*/
|
|
12
|
+
export interface EditorEvents {
|
|
13
|
+
/**
|
|
14
|
+
* Coarse-grained "something observable changed". Fired exactly
|
|
15
|
+
* once per `notify()`, after all specific events. Use when you
|
|
16
|
+
* subscribe to several slices and don't want a per-slice fan-out.
|
|
17
|
+
*/
|
|
18
|
+
change: () => void;
|
|
19
|
+
/** Active interaction mode flipped (select → draw-rect etc.). */
|
|
20
|
+
mode: (mode: Mode) => void;
|
|
21
|
+
/** Selection set changed (added, removed, replaced). */
|
|
22
|
+
selection: (selection: Selection.Selection) => void;
|
|
23
|
+
/** Scene identity changed (any patch applied through the model). */
|
|
24
|
+
scene: (scene: Scene) => void;
|
|
25
|
+
/** Undo/redo availability flipped (push, undo, redo, clear). */
|
|
26
|
+
history: (state: {
|
|
27
|
+
readonly canUndo: boolean;
|
|
28
|
+
readonly canRedo: boolean;
|
|
29
|
+
}) => void;
|
|
30
|
+
/** Viewport (zoom / pan / size / gridSize / gridStyle) changed. */
|
|
31
|
+
viewport: (scene: Scene) => void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=editor-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-events.d.ts","sourceRoot":"","sources":["../src/editor-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iEAAiE;IACjE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,wDAAwD;IACxD,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,KAAK,IAAI,CAAC;IACpD,oEAAoE;IACpE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,gEAAgE;IAChE,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACnF,mEAAmE;IACnE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-events.js","sourceRoot":"","sources":["../src/editor-events.ts"],"names":[],"mappings":""}
|