@oh-just-another/state 0.58.0 → 0.60.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 +158 -0
- package/README.md +78 -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 +32 -1
- package/dist/actions/actionClipboard.js.map +1 -1
- package/dist/actions/actionKeyboard.d.ts.map +1 -1
- package/dist/actions/actionKeyboard.js +77 -9
- package/dist/actions/actionKeyboard.js.map +1 -1
- package/dist/actions/actionMode.d.ts +4 -0
- package/dist/actions/actionMode.d.ts.map +1 -1
- package/dist/actions/actionMode.js +54 -0
- package/dist/actions/actionMode.js.map +1 -1
- package/dist/actions/actionSelection.d.ts.map +1 -1
- package/dist/actions/actionSelection.js +1 -0
- package/dist/actions/actionSelection.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.d.ts +6 -0
- package/dist/actions/actionView.d.ts.map +1 -1
- package/dist/actions/actionView.js +20 -2
- package/dist/actions/actionView.js.map +1 -1
- package/dist/actions/actionZoom.d.ts.map +1 -1
- package/dist/actions/actionZoom.js +5 -0
- package/dist/actions/actionZoom.js.map +1 -1
- package/dist/actions/index.d.ts +6 -4
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +6 -4
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/registry.d.ts.map +1 -1
- package/dist/actions/registry.js +17 -0
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/types.d.ts +10 -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/clipboard.d.ts +0 -14
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +1 -1
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +208 -41
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +210 -25
- package/dist/constants.js.map +1 -1
- package/dist/dom-events.d.ts +8 -2
- 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 +36 -0
- package/dist/editor/animation-scene.d.ts.map +1 -0
- package/dist/editor/animation-scene.js +194 -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/create.d.ts +0 -6
- package/dist/editor/applies/create.d.ts.map +1 -1
- package/dist/editor/applies/create.js +1 -1
- package/dist/editor/applies/create.js.map +1 -1
- 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/link-move.d.ts +0 -8
- package/dist/editor/applies/link-move.d.ts.map +1 -1
- package/dist/editor/applies/link-move.js +1 -1
- package/dist/editor/applies/link-move.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/interaction-state.d.ts +184 -0
- package/dist/editor/interaction-state.d.ts.map +1 -0
- package/dist/editor/interaction-state.js +139 -0
- package/dist/editor/interaction-state.js.map +1 -0
- package/dist/editor/link-handle-drag.d.ts +152 -0
- package/dist/editor/link-handle-drag.d.ts.map +1 -0
- package/dist/editor/link-handle-drag.js +300 -0
- package/dist/editor/link-handle-drag.js.map +1 -0
- 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 +9 -11
- package/dist/editor/pointer-binding.d.ts.map +1 -1
- package/dist/editor/pointer-binding.js +1191 -890
- 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/brush.d.ts +31 -12
- package/dist/editor/public/brush.d.ts.map +1 -1
- package/dist/editor/public/brush.js +66 -17
- package/dist/editor/public/brush.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 +29 -0
- package/dist/editor/public/cursor.d.ts.map +1 -0
- package/dist/editor/public/cursor.js +146 -0
- package/dist/editor/public/cursor.js.map +1 -0
- package/dist/editor/public/eraser.d.ts +55 -0
- package/dist/editor/public/eraser.d.ts.map +1 -0
- package/dist/editor/public/eraser.js +65 -0
- package/dist/editor/public/eraser.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/laser.d.ts +38 -0
- package/dist/editor/public/laser.d.ts.map +1 -0
- package/dist/editor/public/laser.js +42 -0
- package/dist/editor/public/laser.js.map +1 -0
- 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 +193 -2
- package/dist/editor/public/placement.js.map +1 -1
- package/dist/editor/public/selection-ops.d.ts +35 -1
- package/dist/editor/public/selection-ops.d.ts.map +1 -1
- package/dist/editor/public/selection-ops.js +97 -2
- package/dist/editor/public/selection-ops.js.map +1 -1
- package/dist/editor/public/stroke-eraser-coverage.d.ts +37 -0
- package/dist/editor/public/stroke-eraser-coverage.d.ts.map +1 -0
- package/dist/editor/public/stroke-eraser-coverage.js +168 -0
- package/dist/editor/public/stroke-eraser-coverage.js.map +1 -0
- package/dist/editor/public/stroke-eraser.d.ts +50 -0
- package/dist/editor/public/stroke-eraser.d.ts.map +1 -0
- package/dist/editor/public/stroke-eraser.js +176 -0
- package/dist/editor/public/stroke-eraser.js.map +1 -0
- package/dist/editor/public/stroke-smoothing.d.ts +21 -0
- package/dist/editor/public/stroke-smoothing.d.ts.map +1 -0
- package/dist/editor/public/stroke-smoothing.js +37 -0
- package/dist/editor/public/stroke-smoothing.js.map +1 -0
- 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/tool-ops.d.ts +130 -0
- package/dist/editor/public/tool-ops.d.ts.map +1 -0
- package/dist/editor/public/tool-ops.js +392 -0
- package/dist/editor/public/tool-ops.js.map +1 -0
- package/dist/editor/public/z-order.d.ts +1 -12
- package/dist/editor/public/z-order.d.ts.map +1 -1
- package/dist/editor/public/z-order.js +5 -5
- package/dist/editor/public/z-order.js.map +1 -1
- package/dist/editor/public/zoom-pan.d.ts +15 -4
- package/dist/editor/public/zoom-pan.d.ts.map +1 -1
- package/dist/editor/public/zoom-pan.js +39 -7
- package/dist/editor/public/zoom-pan.js.map +1 -1
- package/dist/editor/render-orchestrator.d.ts +177 -5
- package/dist/editor/render-orchestrator.d.ts.map +1 -1
- package/dist/editor/render-orchestrator.js +519 -358
- 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/text-edit.d.ts +136 -0
- package/dist/editor/text-edit.d.ts.map +1 -0
- package/dist/editor/text-edit.js +328 -0
- package/dist/editor/text-edit.js.map +1 -0
- 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 +603 -346
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +1843 -1630
- 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 +59 -6
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +99 -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 +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- 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/modes.d.ts +15 -1
- package/dist/modes.d.ts.map +1 -1
- package/dist/modes.js.map +1 -1
- package/dist/overlay.d.ts +92 -6
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +582 -125
- package/dist/overlay.js.map +1 -1
- package/dist/search.d.ts +37 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +45 -0
- package/dist/search.js.map +1 -0
- 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.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,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AC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC;;;;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;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC"}
|
package/dist/dom-events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KeyboardEventData,
|
|
1
|
+
import type { KeyboardEventData, PointerEventData, WheelEventData } from "@oh-just-another/types";
|
|
2
2
|
/**
|
|
3
3
|
* Translate a browser `PointerEvent` into a domain `PointerEventData`. The
|
|
4
4
|
* point is expressed in the host element's local CSS-pixel coordinate space
|
|
@@ -9,5 +9,11 @@ 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
|
-
|
|
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;
|
|
13
19
|
//# 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,
|
|
1
|
+
{"version":3,"file":"dom-events.d.ts","sourceRoot":"","sources":["../src/dom-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,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"}
|
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":"
|
|
1
|
+
{"version":3,"file":"dom-events.js","sourceRoot":"","sources":["../src/dom-events.ts"],"names":[],"mappings":"AASA;;;;;;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,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AAC;IAC3B,OAAO,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC;AAC/F,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,EAKpB,EAAa,EAAE,CAAC,CAAC;IAChB,KAAK,EAAE,EAAE,CAAC,QAAQ;IAClB,IAAI,EAAE,EAAE,CAAC,OAAO;IAChB,GAAG,EAAE,EAAE,CAAC,MAAM;IACd,IAAI,EAAE,EAAE,CAAC,OAAO;CACjB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,GAAW,EAAe,EAAE;IACjD,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,GAAG,KAAK,OAAO;QAAE,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,36 @@
|
|
|
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
|
+
/**
|
|
22
|
+
* Restore live image handles for *static* image shapes after a scene load.
|
|
23
|
+
*
|
|
24
|
+
* A live `<img>` / `ImageBitmap` in `metadata.image` does not survive
|
|
25
|
+
* serialisation (the serializer drops it) and the shape's `src` is a dead
|
|
26
|
+
* `blob:` URL once the page reloads — so a restored static image has no
|
|
27
|
+
* drawable handle and the renderer skips it (the "dead-blob-url" warning).
|
|
28
|
+
* The bytes still live in `Scene.files` via `fileId`, so decode them back into
|
|
29
|
+
* a live handle and re-attach it to `metadata.image` before the next paint.
|
|
30
|
+
*
|
|
31
|
+
* Async (decode is async) and applied directly to `_scene` with no history
|
|
32
|
+
* entry — a transient runtime handle, not user data. Repaints once when done.
|
|
33
|
+
* Animated shapes are handled by {@link rehydrateAnimatedImages}.
|
|
34
|
+
*/
|
|
35
|
+
export declare const rehydrateStaticImages: (editor: Editor) => Promise<void>;
|
|
36
|
+
//# 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;AA6EF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAgCxE,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
/**
|
|
72
|
+
* DOM/bitmap constructors that `ctx.drawImage` / `gl.texImage2D` accept as a
|
|
73
|
+
* live image source. Probed by name so a missing global (SSR / worker) is a
|
|
74
|
+
* plain "not live" rather than a throw.
|
|
75
|
+
*/
|
|
76
|
+
const DRAWABLE_CTOR_NAMES = [
|
|
77
|
+
"HTMLImageElement",
|
|
78
|
+
"HTMLCanvasElement",
|
|
79
|
+
"HTMLVideoElement",
|
|
80
|
+
"ImageBitmap",
|
|
81
|
+
"OffscreenCanvas",
|
|
82
|
+
"SVGImageElement",
|
|
83
|
+
"VideoFrame",
|
|
84
|
+
];
|
|
85
|
+
/**
|
|
86
|
+
* True when `value` is a live, drawable image handle (not a `{}` left behind
|
|
87
|
+
* by a serialised `<img>` nor an absent handle). A freshly inserted image
|
|
88
|
+
* already carries one, so rehydration can skip it.
|
|
89
|
+
*/
|
|
90
|
+
const isLiveImageHandle = (value) => {
|
|
91
|
+
if (typeof value !== "object" || value === null)
|
|
92
|
+
return false;
|
|
93
|
+
const g = globalThis;
|
|
94
|
+
for (const name of DRAWABLE_CTOR_NAMES) {
|
|
95
|
+
const ctor = g[name];
|
|
96
|
+
if (typeof ctor === "function" &&
|
|
97
|
+
value instanceof ctor) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Decode raw image bytes into a live drawable handle. Prefers `ImageBitmap`
|
|
105
|
+
* (every backend draws it, incl. the OffscreenCanvas worker); falls back to a
|
|
106
|
+
* decoded `<img>` via an object-URL where `createImageBitmap` is unavailable.
|
|
107
|
+
* Resolves `null` when neither path works (SSR / decode failure).
|
|
108
|
+
*/
|
|
109
|
+
const decodeImageHandle = async (data, mime) => {
|
|
110
|
+
if (typeof Blob === "undefined")
|
|
111
|
+
return null;
|
|
112
|
+
const blob = new Blob([data], { type: mime || "application/octet-stream" });
|
|
113
|
+
if (typeof createImageBitmap === "function") {
|
|
114
|
+
try {
|
|
115
|
+
return await createImageBitmap(blob);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
/* fall through to the <img> path (e.g. some SVGs) */
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (typeof Image !== "undefined" &&
|
|
122
|
+
typeof URL !== "undefined" &&
|
|
123
|
+
typeof URL.createObjectURL === "function") {
|
|
124
|
+
const url = URL.createObjectURL(blob);
|
|
125
|
+
return new Promise((resolve) => {
|
|
126
|
+
const img = new Image();
|
|
127
|
+
img.onload = () => {
|
|
128
|
+
resolve(img);
|
|
129
|
+
};
|
|
130
|
+
img.onerror = () => {
|
|
131
|
+
URL.revokeObjectURL(url);
|
|
132
|
+
resolve(null);
|
|
133
|
+
};
|
|
134
|
+
img.src = url;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Restore live image handles for *static* image shapes after a scene load.
|
|
141
|
+
*
|
|
142
|
+
* A live `<img>` / `ImageBitmap` in `metadata.image` does not survive
|
|
143
|
+
* serialisation (the serializer drops it) and the shape's `src` is a dead
|
|
144
|
+
* `blob:` URL once the page reloads — so a restored static image has no
|
|
145
|
+
* drawable handle and the renderer skips it (the "dead-blob-url" warning).
|
|
146
|
+
* The bytes still live in `Scene.files` via `fileId`, so decode them back into
|
|
147
|
+
* a live handle and re-attach it to `metadata.image` before the next paint.
|
|
148
|
+
*
|
|
149
|
+
* Async (decode is async) and applied directly to `_scene` with no history
|
|
150
|
+
* entry — a transient runtime handle, not user data. Repaints once when done.
|
|
151
|
+
* Animated shapes are handled by {@link rehydrateAnimatedImages}.
|
|
152
|
+
*/
|
|
153
|
+
export const rehydrateStaticImages = async (editor) => {
|
|
154
|
+
const targets = [];
|
|
155
|
+
for (const shape of editor._scene.elements.values()) {
|
|
156
|
+
if (!isImage(shape))
|
|
157
|
+
continue;
|
|
158
|
+
if (shape.animationKind)
|
|
159
|
+
continue; // animated path rebuilds via animationData
|
|
160
|
+
if (isLiveImageHandle(shape.metadata?.image))
|
|
161
|
+
continue; // freshly inserted — already live
|
|
162
|
+
if (!shape.fileId)
|
|
163
|
+
continue;
|
|
164
|
+
const file = getBinaryFile(editor._scene, shape.fileId);
|
|
165
|
+
if (!file)
|
|
166
|
+
continue;
|
|
167
|
+
targets.push({ id: shape.id, data: file.data, mime: file.mime });
|
|
168
|
+
}
|
|
169
|
+
if (targets.length === 0)
|
|
170
|
+
return;
|
|
171
|
+
let changed = false;
|
|
172
|
+
for (const target of targets) {
|
|
173
|
+
const handle = await decodeImageHandle(target.data, target.mime);
|
|
174
|
+
if (!handle)
|
|
175
|
+
continue;
|
|
176
|
+
// The scene may have mutated while decoding — re-read the current shape
|
|
177
|
+
// and skip if it vanished or already regained a live handle.
|
|
178
|
+
const shape = editor._scene.elements.get(target.id);
|
|
179
|
+
if (!shape || !isImage(shape))
|
|
180
|
+
continue;
|
|
181
|
+
if (isLiveImageHandle(shape.metadata?.image))
|
|
182
|
+
continue;
|
|
183
|
+
editor._scene = apply(editor._scene, {
|
|
184
|
+
kind: "element",
|
|
185
|
+
id: shape.id,
|
|
186
|
+
before: shape,
|
|
187
|
+
after: { ...shape, metadata: { ...shape.metadata, image: handle } },
|
|
188
|
+
});
|
|
189
|
+
changed = true;
|
|
190
|
+
}
|
|
191
|
+
if (changed)
|
|
192
|
+
editor.forceRender();
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=animation-scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-scene.js","sourceRoot":"","sources":["../../src/editor/animation-scene.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D;;;;GAIG;AACH,MAAM,CAAC,MAAM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CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,SAAS;QACxC,IAAI,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;YAAE,SAAS;QACvD,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;YACnC,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;SACpE,CAAC,CAAC;QACH,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,OAAO;QAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
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,CAAC;IACpB,gFAAgF;IACxE,UAAU,GAAG,CAAC,CAAC;IAEvB,gEAAgE;IAC/C,kBAAkB,GAAG,GAAS,EAAE;QAC/C,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAO;QAC5C,IAAI,QAAQ,CAAC,MAAM;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;;YACjC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC;YAC5B,yEAAyE;YACzE,wEAAwE;YACxE,0EAA0E;YAC1E,wCAAwC;YACxC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE;YACvD,MAAM,EAAE,GAAG,EAAE;gBACX,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEO,MAAM;QACZ,2EAA2E;QAC3E,yEAAyE;QACzE,iEAA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C;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,CAA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