@oh-just-another/state 0.61.0 → 0.63.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 +89 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/actions/registry.js +1 -1
- package/dist/actions/registry.js.map +1 -1
- package/dist/constants.d.ts +179 -12
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +150 -12
- package/dist/constants.js.map +1 -1
- package/dist/editor/animation-scene.d.ts.map +1 -1
- package/dist/editor/animation-scene.js +27 -39
- package/dist/editor/animation-scene.js.map +1 -1
- package/dist/editor/animation.js +1 -1
- package/dist/editor/animation.js.map +1 -1
- package/dist/editor/applies/arrange-units.d.ts +24 -0
- package/dist/editor/applies/arrange-units.d.ts.map +1 -0
- package/dist/editor/applies/arrange-units.js +56 -0
- package/dist/editor/applies/arrange-units.js.map +1 -0
- package/dist/editor/applies/arrange.d.ts +16 -15
- package/dist/editor/applies/arrange.d.ts.map +1 -1
- package/dist/editor/applies/arrange.js +33 -48
- package/dist/editor/applies/arrange.js.map +1 -1
- package/dist/editor/applies/create.d.ts +16 -10
- package/dist/editor/applies/create.d.ts.map +1 -1
- package/dist/editor/applies/create.js +32 -12
- package/dist/editor/applies/create.js.map +1 -1
- package/dist/editor/applies/edge.d.ts +1 -1
- package/dist/editor/applies/edge.d.ts.map +1 -1
- package/dist/editor/applies/object-snap.d.ts +87 -0
- package/dist/editor/applies/object-snap.d.ts.map +1 -0
- package/dist/editor/applies/object-snap.js +198 -0
- package/dist/editor/applies/object-snap.js.map +1 -0
- package/dist/editor/applies/resize.d.ts +1 -1
- package/dist/editor/applies/resize.d.ts.map +1 -1
- package/dist/editor/applies/resize.js +6 -4
- package/dist/editor/applies/resize.js.map +1 -1
- package/dist/editor/applies/selection.d.ts +5 -5
- package/dist/editor/applies/selection.d.ts.map +1 -1
- package/dist/editor/applies/selection.js +15 -7
- package/dist/editor/applies/selection.js.map +1 -1
- package/dist/editor/applies/snap-grid.d.ts +1 -1
- package/dist/editor/applies/snap-grid.d.ts.map +1 -1
- package/dist/editor/container-ops.d.ts +1 -1
- package/dist/editor/container-ops.d.ts.map +1 -1
- package/dist/{editor-events.d.ts → editor/editor-events.d.ts} +2 -2
- package/dist/editor/editor-events.d.ts.map +1 -0
- package/dist/{editor-events.js.map → editor/editor-events.js.map} +1 -1
- package/dist/editor/event-fanout.d.ts +3 -3
- package/dist/editor/event-fanout.d.ts.map +1 -1
- package/dist/editor/gesture-tx.d.ts +1 -1
- package/dist/editor/gesture-tx.d.ts.map +1 -1
- package/dist/editor/hit-test.d.ts +5 -3
- package/dist/editor/hit-test.d.ts.map +1 -1
- package/dist/editor/hit-test.js +18 -10
- package/dist/editor/hit-test.js.map +1 -1
- package/dist/editor/interaction-state.d.ts +29 -2
- package/dist/editor/interaction-state.d.ts.map +1 -1
- package/dist/editor/interaction-state.js +34 -0
- package/dist/editor/interaction-state.js.map +1 -1
- package/dist/editor/link-handle-drag.d.ts +1 -1
- package/dist/editor/link-handle-drag.d.ts.map +1 -1
- package/dist/editor/link-handle-drag.js +1 -1
- package/dist/editor/link-handle-drag.js.map +1 -1
- package/dist/editor/pointer-binding.d.ts.map +1 -1
- package/dist/editor/pointer-binding.js +86 -24
- package/dist/editor/pointer-binding.js.map +1 -1
- package/dist/editor/public/arrange-group.d.ts +6 -5
- package/dist/editor/public/arrange-group.d.ts.map +1 -1
- package/dist/editor/public/arrange-group.js +39 -23
- package/dist/editor/public/arrange-group.js.map +1 -1
- package/dist/editor/public/clipboard.d.ts +1 -1
- package/dist/editor/public/clipboard.d.ts.map +1 -1
- package/dist/editor/public/clipboard.js +2 -2
- package/dist/editor/public/clipboard.js.map +1 -1
- package/dist/editor/public/cursor.js +1 -1
- package/dist/editor/public/cursor.js.map +1 -1
- package/dist/editor/public/eraser.js +1 -1
- package/dist/editor/public/eraser.js.map +1 -1
- package/dist/editor/public/image-insert.d.ts.map +1 -1
- package/dist/editor/public/image-insert.js +4 -1
- package/dist/editor/public/image-insert.js.map +1 -1
- package/dist/editor/public/label-seed.d.ts +12 -0
- package/dist/editor/public/label-seed.d.ts.map +1 -0
- package/dist/editor/public/label-seed.js +20 -0
- package/dist/editor/public/label-seed.js.map +1 -0
- package/dist/editor/public/layers.d.ts +1 -1
- package/dist/editor/public/layers.d.ts.map +1 -1
- package/dist/editor/public/placement.d.ts +6 -1
- package/dist/editor/public/placement.d.ts.map +1 -1
- package/dist/editor/public/placement.js +47 -17
- package/dist/editor/public/placement.js.map +1 -1
- package/dist/editor/public/selection-ops.d.ts +1 -1
- package/dist/editor/public/selection-ops.d.ts.map +1 -1
- package/dist/editor/public/selection-ops.js +31 -2
- package/dist/editor/public/selection-ops.js.map +1 -1
- package/dist/editor/public/stroke-eraser-coverage.js +1 -1
- package/dist/editor/public/stroke-eraser-coverage.js.map +1 -1
- package/dist/editor/public/stroke-eraser.js +1 -1
- package/dist/editor/public/stroke-eraser.js.map +1 -1
- package/dist/editor/public/text-edit.d.ts +4 -2
- package/dist/editor/public/text-edit.d.ts.map +1 -1
- package/dist/editor/public/text-edit.js +8 -4
- package/dist/editor/public/text-edit.js.map +1 -1
- package/dist/editor/public/tool-ops.d.ts +10 -7
- package/dist/editor/public/tool-ops.d.ts.map +1 -1
- package/dist/editor/public/tool-ops.js +141 -14
- package/dist/editor/public/tool-ops.js.map +1 -1
- package/dist/editor/public/zoom-pan.d.ts +10 -1
- package/dist/editor/public/zoom-pan.d.ts.map +1 -1
- package/dist/editor/public/zoom-pan.js +49 -0
- package/dist/editor/public/zoom-pan.js.map +1 -1
- package/dist/editor/render-orchestrator.d.ts +17 -11
- package/dist/editor/render-orchestrator.d.ts.map +1 -1
- package/dist/editor/render-orchestrator.js +45 -31
- package/dist/editor/render-orchestrator.js.map +1 -1
- package/dist/editor/resize-helpers.d.ts +1 -1
- package/dist/editor/resize-helpers.d.ts.map +1 -1
- package/dist/editor/shape-traits.d.ts +1 -1
- package/dist/editor/shape-traits.d.ts.map +1 -1
- package/dist/editor/shape-traits.js +1 -1
- package/dist/editor/shape-traits.js.map +1 -1
- package/dist/editor/text-edit.d.ts +24 -11
- package/dist/editor/text-edit.d.ts.map +1 -1
- package/dist/editor/text-edit.js +225 -45
- package/dist/editor/text-edit.js.map +1 -1
- package/dist/editor.d.ts +306 -18
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +1233 -67
- package/dist/editor.js.map +1 -1
- package/dist/features/built-in-handlers.d.ts.map +1 -0
- package/dist/{built-in-handlers.js → features/built-in-handlers.js} +7 -1
- package/dist/features/built-in-handlers.js.map +1 -0
- package/dist/{clipboard.d.ts → features/clipboard.d.ts} +14 -0
- package/dist/features/clipboard.d.ts.map +1 -0
- package/dist/{clipboard.js → features/clipboard.js} +1 -1
- package/dist/features/clipboard.js.map +1 -0
- package/dist/{file-drop.d.ts → features/file-drop.d.ts} +20 -1
- package/dist/features/file-drop.d.ts.map +1 -0
- package/dist/{file-drop.js → features/file-drop.js} +47 -19
- package/dist/features/file-drop.js.map +1 -0
- package/dist/features/insert-scene.d.ts +19 -0
- package/dist/features/insert-scene.d.ts.map +1 -0
- package/dist/features/insert-scene.js +145 -0
- package/dist/features/insert-scene.js.map +1 -0
- package/dist/features/search.d.ts.map +1 -0
- package/dist/features/search.js.map +1 -0
- package/dist/helpers/auto-compact.d.ts.map +1 -0
- package/dist/{auto-compact.js → helpers/auto-compact.js} +1 -1
- package/dist/helpers/auto-compact.js.map +1 -0
- package/dist/helpers/auto-layout-scheduler.d.ts.map +1 -0
- package/dist/helpers/auto-layout-scheduler.js.map +1 -0
- package/dist/helpers/frame-helpers.d.ts.map +1 -0
- package/dist/helpers/frame-helpers.js.map +1 -0
- package/dist/helpers/group-helpers.d.ts.map +1 -0
- package/dist/helpers/group-helpers.js.map +1 -0
- package/dist/helpers/util.d.ts.map +1 -0
- package/dist/helpers/util.js.map +1 -0
- package/dist/index.d.ts +23 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/input/dom-events.d.ts.map +1 -0
- package/dist/input/dom-events.js.map +1 -0
- package/dist/{hotkeys-binding.d.ts → input/hotkeys-binding.d.ts} +2 -2
- package/dist/input/hotkeys-binding.d.ts.map +1 -0
- package/dist/{hotkeys-binding.js → input/hotkeys-binding.js} +1 -1
- package/dist/input/hotkeys-binding.js.map +1 -0
- package/dist/input/platform.d.ts.map +1 -0
- package/dist/input/platform.js.map +1 -0
- package/dist/{handle.d.ts → interaction/handle.d.ts} +1 -1
- package/dist/interaction/handle.d.ts.map +1 -0
- package/dist/{handle.js → interaction/handle.js} +1 -1
- package/dist/interaction/handle.js.map +1 -0
- package/dist/interaction/interactive.d.ts.map +1 -0
- package/dist/interaction/interactive.js.map +1 -0
- package/dist/interaction/machine.d.ts.map +1 -0
- package/dist/interaction/machine.js.map +1 -0
- package/dist/interaction/modes.d.ts.map +1 -0
- package/dist/interaction/modes.js.map +1 -0
- package/dist/render/animation-tick.d.ts.map +1 -0
- package/dist/render/animation-tick.js.map +1 -0
- package/dist/{overlay.d.ts → render/overlay.d.ts} +42 -38
- package/dist/render/overlay.d.ts.map +1 -0
- package/dist/{overlay.js → render/overlay.js} +180 -65
- package/dist/render/overlay.js.map +1 -0
- package/dist/selection/link-selection.d.ts.map +1 -0
- package/dist/{link-selection.js → selection/link-selection.js} +1 -1
- package/dist/selection/link-selection.js.map +1 -0
- package/dist/selection/selection.d.ts.map +1 -0
- package/dist/{selection.js → selection/selection.js} +1 -1
- package/dist/selection/selection.js.map +1 -0
- package/package.json +5 -5
- package/dist/animation-tick.d.ts.map +0 -1
- package/dist/animation-tick.js.map +0 -1
- package/dist/auto-compact.d.ts.map +0 -1
- package/dist/auto-compact.js.map +0 -1
- package/dist/auto-layout-scheduler.d.ts.map +0 -1
- package/dist/auto-layout-scheduler.js.map +0 -1
- package/dist/built-in-handlers.d.ts.map +0 -1
- package/dist/built-in-handlers.js.map +0 -1
- package/dist/clipboard.d.ts.map +0 -1
- package/dist/clipboard.js.map +0 -1
- package/dist/dom-events.d.ts.map +0 -1
- package/dist/dom-events.js.map +0 -1
- package/dist/editor-events.d.ts.map +0 -1
- package/dist/file-drop.d.ts.map +0 -1
- package/dist/file-drop.js.map +0 -1
- package/dist/frame-helpers.d.ts.map +0 -1
- package/dist/frame-helpers.js.map +0 -1
- package/dist/group-helpers.d.ts.map +0 -1
- package/dist/group-helpers.js.map +0 -1
- package/dist/handle.d.ts.map +0 -1
- package/dist/handle.js.map +0 -1
- package/dist/hotkeys-binding.d.ts.map +0 -1
- package/dist/hotkeys-binding.js.map +0 -1
- package/dist/interactive.d.ts.map +0 -1
- package/dist/interactive.js.map +0 -1
- package/dist/link-selection.d.ts.map +0 -1
- package/dist/link-selection.js.map +0 -1
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js.map +0 -1
- package/dist/modes.d.ts.map +0 -1
- package/dist/modes.js.map +0 -1
- package/dist/overlay.d.ts.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/selection.d.ts.map +0 -1
- package/dist/selection.js.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js.map +0 -1
- /package/dist/{editor-events.js → editor/editor-events.js} +0 -0
- /package/dist/{built-in-handlers.d.ts → features/built-in-handlers.d.ts} +0 -0
- /package/dist/{search.d.ts → features/search.d.ts} +0 -0
- /package/dist/{search.js → features/search.js} +0 -0
- /package/dist/{auto-compact.d.ts → helpers/auto-compact.d.ts} +0 -0
- /package/dist/{auto-layout-scheduler.d.ts → helpers/auto-layout-scheduler.d.ts} +0 -0
- /package/dist/{auto-layout-scheduler.js → helpers/auto-layout-scheduler.js} +0 -0
- /package/dist/{frame-helpers.d.ts → helpers/frame-helpers.d.ts} +0 -0
- /package/dist/{frame-helpers.js → helpers/frame-helpers.js} +0 -0
- /package/dist/{group-helpers.d.ts → helpers/group-helpers.d.ts} +0 -0
- /package/dist/{group-helpers.js → helpers/group-helpers.js} +0 -0
- /package/dist/{util.d.ts → helpers/util.d.ts} +0 -0
- /package/dist/{util.js → helpers/util.js} +0 -0
- /package/dist/{dom-events.d.ts → input/dom-events.d.ts} +0 -0
- /package/dist/{dom-events.js → input/dom-events.js} +0 -0
- /package/dist/{platform.d.ts → input/platform.d.ts} +0 -0
- /package/dist/{platform.js → input/platform.js} +0 -0
- /package/dist/{interactive.d.ts → interaction/interactive.d.ts} +0 -0
- /package/dist/{interactive.js → interaction/interactive.js} +0 -0
- /package/dist/{machine.d.ts → interaction/machine.d.ts} +0 -0
- /package/dist/{machine.js → interaction/machine.js} +0 -0
- /package/dist/{modes.d.ts → interaction/modes.d.ts} +0 -0
- /package/dist/{modes.js → interaction/modes.js} +0 -0
- /package/dist/{animation-tick.d.ts → render/animation-tick.d.ts} +0 -0
- /package/dist/{animation-tick.js → render/animation-tick.js} +0 -0
- /package/dist/{link-selection.d.ts → selection/link-selection.d.ts} +0 -0
- /package/dist/{selection.d.ts → selection/selection.d.ts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { bounds as B } from "@oh-just-another/math";
|
|
2
|
-
import { apply, getBinaryFile, getElementWorldBounds, isImage } from "@oh-just-another/scene";
|
|
2
|
+
import { apply, getBinaryFile, getElementWorldBounds, isImage, sniffBinaryFileMime, } from "@oh-just-another/scene";
|
|
3
|
+
import { isDrawableImageSource } from "@oh-just-another/renderer-core";
|
|
3
4
|
import { HEAVY_GIF_BYTES } from "../constants.js";
|
|
4
5
|
import { hasAnimatedElement } from "./public/image-insert.js";
|
|
5
|
-
import { createHiddenLoopingVideo } from "../built-in-handlers.js";
|
|
6
|
+
import { createHiddenLoopingVideo } from "../features/built-in-handlers.js";
|
|
6
7
|
/**
|
|
7
8
|
* True when at least one animated shape's world AABB intersects the current
|
|
8
9
|
* viewport. Drives viewport-culling of the animation tick — off-screen GIFs
|
|
@@ -69,38 +70,6 @@ export const rehydrateAnimatedImages = (editor) => {
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
|
-
/**
|
|
73
|
-
* DOM/bitmap constructors that `ctx.drawImage` / `gl.texImage2D` accept as a
|
|
74
|
-
* live image source. Probed by name so a missing global (SSR / worker) is a
|
|
75
|
-
* plain "not live" rather than a throw.
|
|
76
|
-
*/
|
|
77
|
-
const DRAWABLE_CTOR_NAMES = [
|
|
78
|
-
"HTMLImageElement",
|
|
79
|
-
"HTMLCanvasElement",
|
|
80
|
-
"HTMLVideoElement",
|
|
81
|
-
"ImageBitmap",
|
|
82
|
-
"OffscreenCanvas",
|
|
83
|
-
"SVGImageElement",
|
|
84
|
-
"VideoFrame",
|
|
85
|
-
];
|
|
86
|
-
/**
|
|
87
|
-
* True when `value` is a live, drawable image handle (not a `{}` left behind
|
|
88
|
-
* by a serialised `<img>` nor an absent handle). A freshly inserted image
|
|
89
|
-
* already carries one, so rehydration can skip it.
|
|
90
|
-
*/
|
|
91
|
-
const isLiveImageHandle = (value) => {
|
|
92
|
-
if (typeof value !== "object" || value === null)
|
|
93
|
-
return false;
|
|
94
|
-
const g = globalThis;
|
|
95
|
-
for (const name of DRAWABLE_CTOR_NAMES) {
|
|
96
|
-
const ctor = g[name];
|
|
97
|
-
if (typeof ctor === "function" &&
|
|
98
|
-
value instanceof ctor) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
};
|
|
104
73
|
/**
|
|
105
74
|
* Decode raw image bytes into a live drawable handle. Prefers `ImageBitmap`
|
|
106
75
|
* (every backend draws it, incl. the OffscreenCanvas worker); falls back to a
|
|
@@ -191,14 +160,27 @@ export const rehydrateStaticImages = async (editor) => {
|
|
|
191
160
|
continue;
|
|
192
161
|
if (shape.animationKind)
|
|
193
162
|
continue; // animated path rebuilds via animationData
|
|
194
|
-
if (
|
|
163
|
+
if (isDrawableImageSource(shape.metadata?.image))
|
|
195
164
|
continue; // freshly inserted — already live
|
|
196
165
|
if (!shape.fileId)
|
|
197
166
|
continue;
|
|
198
167
|
const file = getBinaryFile(editor._scene, shape.fileId);
|
|
199
|
-
if (!file)
|
|
168
|
+
if (!file) {
|
|
169
|
+
// Dangling fileId: the renderer skips this shape silently on the
|
|
170
|
+
// promise of rehydration, so a missing Scene.files entry must be
|
|
171
|
+
// reported here or the blank shape is unexplained.
|
|
172
|
+
console.warn(`[state] could not rehydrate image handle: element ${shape.id} points at ` +
|
|
173
|
+
`fileId "${shape.fileId}" but Scene.files has no such entry — ` +
|
|
174
|
+
"the shape will render blank.");
|
|
200
175
|
continue;
|
|
201
|
-
|
|
176
|
+
}
|
|
177
|
+
// Generic mime (empty File.type at drop time in older scenes) can't
|
|
178
|
+
// route image-vs-video decoding — recover the real type from the
|
|
179
|
+
// leading magic bytes.
|
|
180
|
+
const mime = file.mime === "application/octet-stream"
|
|
181
|
+
? (sniffBinaryFileMime(file.data) ?? file.mime)
|
|
182
|
+
: file.mime;
|
|
183
|
+
targets.push({ id: shape.id, data: file.data, mime });
|
|
202
184
|
}
|
|
203
185
|
if (targets.length === 0)
|
|
204
186
|
return;
|
|
@@ -207,14 +189,20 @@ export const rehydrateStaticImages = async (editor) => {
|
|
|
207
189
|
const handle = target.mime.startsWith("video/")
|
|
208
190
|
? await rehydrateVideoHandle(target.data, target.mime)
|
|
209
191
|
: await decodeImageHandle(target.data, target.mime);
|
|
210
|
-
if (!handle)
|
|
192
|
+
if (!handle) {
|
|
193
|
+
// Silent skip would leave the shape permanently blank (the renderer's
|
|
194
|
+
// "dead-blob-url" warning with no follow-up) — say why instead.
|
|
195
|
+
console.warn(`[state] could not rehydrate image handle from Scene.files ` +
|
|
196
|
+
`(element ${target.id}, mime "${target.mime}", ${target.data.byteLength} bytes) — ` +
|
|
197
|
+
"decode/loadedmetadata failed; the shape will render blank.");
|
|
211
198
|
continue;
|
|
199
|
+
}
|
|
212
200
|
// The scene may have mutated while decoding — re-read the current shape
|
|
213
201
|
// and skip if it vanished or already regained a live handle.
|
|
214
202
|
const shape = editor._scene.elements.get(target.id);
|
|
215
203
|
if (!shape || !isImage(shape))
|
|
216
204
|
continue;
|
|
217
|
-
if (
|
|
205
|
+
if (isDrawableImageSource(shape.metadata?.image))
|
|
218
206
|
continue;
|
|
219
207
|
editor._scene = apply(editor._scene, {
|
|
220
208
|
kind: "element",
|
|
@@ -1 +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,
|
|
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,EACL,KAAK,EACL,aAAa,EACb,qBAAqB,EACrB,OAAO,EACP,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAG5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAc,EAAW,EAAE;IACnE,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC,CAAC,mCAAmC;IAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE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,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"}
|
package/dist/editor/animation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationTick } from "../animation-tick.js";
|
|
1
|
+
import { AnimationTick } from "../render/animation-tick.js";
|
|
2
2
|
import { ANIMATION_MAX_INTERVAL_MS, ANIMATION_MIN_INTERVAL_MS, ANIMATION_COST_FACTOR, } from "../constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Owns the GIF/animation tick lifecycle: an adaptive render-cost throttle and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/editor/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/editor/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,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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Q,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,24 @@
|
|
|
1
|
+
import { type Element, type Patch, type Scene } from "@oh-just-another/scene";
|
|
2
|
+
import type { Bounds, ElementId } from "@oh-just-another/types";
|
|
3
|
+
/**
|
|
4
|
+
* One "thing" a multi-element command arranges: a selection root plus
|
|
5
|
+
* everything it carries. A plain shape is a unit of itself; a selected
|
|
6
|
+
* group is ONE unit — its whole subtree moves together and its footprint
|
|
7
|
+
* is the union of the descendants (the group shell has no geometry).
|
|
8
|
+
* Descendants whose ancestor is also selected are folded into that unit
|
|
9
|
+
* instead of being arranged twice.
|
|
10
|
+
*/
|
|
11
|
+
export interface ArrangeUnit {
|
|
12
|
+
readonly root: Element;
|
|
13
|
+
/** The root and its descendants (group shells included, so they move too). */
|
|
14
|
+
readonly members: readonly Element[];
|
|
15
|
+
/** World AABB of the unit's visible members. */
|
|
16
|
+
readonly bounds: Bounds;
|
|
17
|
+
}
|
|
18
|
+
/** Build the arrange units of `selection` (units without geometry are dropped). */
|
|
19
|
+
export declare const arrangeUnits: (scene: Scene, selection: Iterable<ElementId>) => ArrangeUnit[];
|
|
20
|
+
/** Translate every member of `unit` by `(dx, dy)` — one patch per member. */
|
|
21
|
+
export declare const translateUnit: (unit: ArrangeUnit, dx: number, dy: number) => Patch[];
|
|
22
|
+
/** World AABB enclosing every unit (assumes `units` is non-empty). */
|
|
23
|
+
export declare const unitsBounds: (units: readonly ArrangeUnit[]) => Bounds;
|
|
24
|
+
//# sourceMappingURL=arrange-units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrange-units.d.ts","sourceRoot":"","sources":["../../../src/editor/applies/arrange-units.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,CAAC;IACrC,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAsBD,mFAAmF;AACnF,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,EAAE,WAAW,QAAQ,CAAC,SAAS,CAAC,KAAG,WAAW,EAetF,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,aAAa,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,KAAK,EAQ9E,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,WAAW,GAAI,OAAO,SAAS,WAAW,EAAE,KAAG,MACI,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { bounds as B } from "@oh-just-another/math";
|
|
2
|
+
import { getDescendantsOf, getElement, getElementWorldBounds, isGroup, } from "@oh-just-another/scene";
|
|
3
|
+
/** Selection roots: selected elements with no selected ancestor. */
|
|
4
|
+
const roots = (scene, selection) => {
|
|
5
|
+
const out = [];
|
|
6
|
+
for (const id of selection) {
|
|
7
|
+
const shape = getElement(scene, id);
|
|
8
|
+
if (!shape)
|
|
9
|
+
continue;
|
|
10
|
+
let cursor = shape;
|
|
11
|
+
let covered = false;
|
|
12
|
+
for (let i = 0; cursor?.parentId && i < 64; i++) {
|
|
13
|
+
if (selection.has(cursor.parentId)) {
|
|
14
|
+
covered = true;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
cursor = getElement(scene, cursor.parentId);
|
|
18
|
+
}
|
|
19
|
+
if (!covered)
|
|
20
|
+
out.push(shape);
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
};
|
|
24
|
+
/** Build the arrange units of `selection` (units without geometry are dropped). */
|
|
25
|
+
export const arrangeUnits = (scene, selection) => {
|
|
26
|
+
const ids = selection instanceof Set ? selection : new Set(selection);
|
|
27
|
+
const units = [];
|
|
28
|
+
for (const root of roots(scene, ids)) {
|
|
29
|
+
// `getDescendantsOf` returns the root itself plus its subtree.
|
|
30
|
+
const members = isGroup(root) ? getDescendantsOf(scene, root.id) : [root];
|
|
31
|
+
let bounds = null;
|
|
32
|
+
for (const m of members) {
|
|
33
|
+
if (isGroup(m))
|
|
34
|
+
continue;
|
|
35
|
+
const b = getElementWorldBounds(m);
|
|
36
|
+
bounds = bounds ? B.union(bounds, b) : b;
|
|
37
|
+
}
|
|
38
|
+
if (bounds)
|
|
39
|
+
units.push({ root, members, bounds });
|
|
40
|
+
}
|
|
41
|
+
return units;
|
|
42
|
+
};
|
|
43
|
+
/** Translate every member of `unit` by `(dx, dy)` — one patch per member. */
|
|
44
|
+
export const translateUnit = (unit, dx, dy) => {
|
|
45
|
+
if (dx === 0 && dy === 0)
|
|
46
|
+
return [];
|
|
47
|
+
return unit.members.map((el) => ({
|
|
48
|
+
kind: "element",
|
|
49
|
+
id: el.id,
|
|
50
|
+
before: el,
|
|
51
|
+
after: { ...el, position: { x: el.position.x + dx, y: el.position.y + dy } },
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
/** World AABB enclosing every unit (assumes `units` is non-empty). */
|
|
55
|
+
export const unitsBounds = (units) => units.map((u) => u.bounds).reduce((acc, b) => B.union(acc, b));
|
|
56
|
+
//# sourceMappingURL=arrange-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrange-units.js","sourceRoot":"","sources":["../../../src/editor/applies/arrange-units.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,OAAO,GAIR,MAAM,wBAAwB,CAAC;AAmBhC,oEAAoE;AACpE,MAAM,KAAK,GAAG,CAAC,KAAY,EAAE,SAAiC,EAAa,EAAE;IAC3E,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,IAAI,MAAM,GAAwB,KAAK,CAAC;QACxC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACnC,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM;YACR,CAAC;YACD,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,OAAO;YAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,mFAA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QAC/B,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,EAAE,CAAC,EAAE;QACT,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE;KAC7E,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA6B,EAAU,EAAE,CACnE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -11,27 +11,28 @@ export type RotateOrigin = ReadonlyMap<ElementId, {
|
|
|
11
11
|
rotation: number;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
|
-
* Pure: mirror
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* Pure: mirror the selection about its combined centre on the given axis.
|
|
15
|
+
* Every visible member of every unit (a selected group mirrors as a whole:
|
|
16
|
+
* its descendants reflect about the shared centre) has its position
|
|
17
|
+
* reflected across the centre and its scale sign flipped on that axis, so
|
|
18
|
+
* the content mirrors in place; size is unchanged. Mirroring a single
|
|
19
|
+
* element flips it about its own centre. Edges bound to the moved elements
|
|
20
|
+
* re-route from their endpoints; free links are left untouched.
|
|
20
21
|
*/
|
|
21
22
|
export declare const computeFlipPatches: (scene: Scene, ids: Iterable<ElementId>, axis: FlipAxis) => Patch[];
|
|
22
23
|
/**
|
|
23
|
-
* Pure: align every
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* Pure: align every unit of the selection (a selected group counts as one
|
|
25
|
+
* unit and moves as a whole) to the given edge / centre line of the
|
|
26
|
+
* combined bounding box (e.g. `left` moves each unit so its left edge meets
|
|
27
|
+
* the box's left edge; `h-center` lines up horizontal centres). Only the
|
|
28
|
+
* relevant axis moves; sizes are unchanged. A no-op below two units.
|
|
28
29
|
*/
|
|
29
30
|
export declare const computeAlignPatches: (scene: Scene, ids: Iterable<ElementId>, edge: AlignEdge) => Patch[];
|
|
30
31
|
/**
|
|
31
|
-
* Pure: evenly space the selection along the given axis so the gaps
|
|
32
|
-
* adjacent
|
|
33
|
-
* shift to balance the gaps (accounting for
|
|
34
|
-
* three
|
|
32
|
+
* Pure: evenly space the selection's units along the given axis so the gaps
|
|
33
|
+
* between adjacent units are equal (a selected group is one unit). The
|
|
34
|
+
* outermost two stay put; the rest shift to balance the gaps (accounting for
|
|
35
|
+
* differing sizes). A no-op below three units.
|
|
35
36
|
*/
|
|
36
37
|
export declare const computeDistributePatches: (scene: Scene, ids: Iterable<ElementId>, axis: DistributeAxis) => Patch[];
|
|
37
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrange.d.ts","sourceRoot":"","sources":["../../../src/editor/applies/arrange.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"arrange.d.ts","sourceRoot":"","sources":["../../../src/editor/applies/arrange.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAU,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGtE,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;AAMxF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,QAAQ,KACb,KAAK,EAyBP,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,SAAS,KACd,KAAK,EAiCP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,KAAK,EACZ,KAAK,QAAQ,CAAC,SAAS,CAAC,EACxB,MAAM,cAAc,KACnB,KAAK,EA4BP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,KAAK,EACZ,QAAQ,YAAY,EACpB,OAAO,IAAI,EACX,OAAO,MAAM,KACZ,KAAK,EAiBP,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,eAAe,GAAI,UAAU,SAAS,OAAO,EAAE,KAAG,IAG9D,CAAC"}
|
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
import { bounds as B } from "@oh-just-another/math";
|
|
2
|
-
import { getElement, getElementWorldBounds, } from "@oh-just-another/scene";
|
|
3
|
-
|
|
4
|
-
const collect = (scene, ids) => {
|
|
5
|
-
const out = [];
|
|
6
|
-
for (const id of ids) {
|
|
7
|
-
const el = getElement(scene, id);
|
|
8
|
-
if (el)
|
|
9
|
-
out.push(el);
|
|
10
|
-
}
|
|
11
|
-
return out;
|
|
12
|
-
};
|
|
2
|
+
import { getElement, getElementWorldBounds, isGroup, } from "@oh-just-another/scene";
|
|
3
|
+
import { arrangeUnits, translateUnit, unitsBounds } from "./arrange-units.js";
|
|
13
4
|
/** World-space AABB enclosing every element in `elements` (assumed non-empty). */
|
|
14
5
|
const enclosingBounds = (elements) => elements.map((el) => getElementWorldBounds(el)).reduce((acc, b) => B.union(acc, b));
|
|
15
6
|
/**
|
|
16
|
-
* Pure: mirror
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
7
|
+
* Pure: mirror the selection about its combined centre on the given axis.
|
|
8
|
+
* Every visible member of every unit (a selected group mirrors as a whole:
|
|
9
|
+
* its descendants reflect about the shared centre) has its position
|
|
10
|
+
* reflected across the centre and its scale sign flipped on that axis, so
|
|
11
|
+
* the content mirrors in place; size is unchanged. Mirroring a single
|
|
12
|
+
* element flips it about its own centre. Edges bound to the moved elements
|
|
13
|
+
* re-route from their endpoints; free links are left untouched.
|
|
22
14
|
*/
|
|
23
15
|
export const computeFlipPatches = (scene, ids, axis) => {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
16
|
+
const units = arrangeUnits(scene, ids);
|
|
17
|
+
if (units.length === 0)
|
|
26
18
|
return [];
|
|
27
|
-
const box =
|
|
19
|
+
const box = unitsBounds(units);
|
|
28
20
|
const cx = box.x + box.width / 2;
|
|
29
21
|
const cy = box.y + box.height / 2;
|
|
30
22
|
const horizontal = axis === "horizontal";
|
|
31
23
|
const patches = [];
|
|
24
|
+
const elements = units.flatMap((u) => u.members).filter((el) => !isGroup(el));
|
|
32
25
|
for (const el of elements) {
|
|
33
26
|
const after = horizontal
|
|
34
27
|
? {
|
|
@@ -46,20 +39,20 @@ export const computeFlipPatches = (scene, ids, axis) => {
|
|
|
46
39
|
return patches;
|
|
47
40
|
};
|
|
48
41
|
/**
|
|
49
|
-
* Pure: align every
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
42
|
+
* Pure: align every unit of the selection (a selected group counts as one
|
|
43
|
+
* unit and moves as a whole) to the given edge / centre line of the
|
|
44
|
+
* combined bounding box (e.g. `left` moves each unit so its left edge meets
|
|
45
|
+
* the box's left edge; `h-center` lines up horizontal centres). Only the
|
|
46
|
+
* relevant axis moves; sizes are unchanged. A no-op below two units.
|
|
54
47
|
*/
|
|
55
48
|
export const computeAlignPatches = (scene, ids, edge) => {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
49
|
+
const units = arrangeUnits(scene, ids);
|
|
50
|
+
if (units.length < 2)
|
|
58
51
|
return [];
|
|
59
|
-
const box =
|
|
52
|
+
const box = unitsBounds(units);
|
|
60
53
|
const patches = [];
|
|
61
|
-
for (const
|
|
62
|
-
const b =
|
|
54
|
+
for (const unit of units) {
|
|
55
|
+
const b = unit.bounds;
|
|
63
56
|
let dx = 0;
|
|
64
57
|
let dy = 0;
|
|
65
58
|
switch (edge) {
|
|
@@ -82,28 +75,25 @@ export const computeAlignPatches = (scene, ids, edge) => {
|
|
|
82
75
|
dy = box.y + box.height / 2 - (b.y + b.height / 2);
|
|
83
76
|
break;
|
|
84
77
|
}
|
|
85
|
-
|
|
86
|
-
continue;
|
|
87
|
-
const after = { ...el, position: { x: el.position.x + dx, y: el.position.y + dy } };
|
|
88
|
-
patches.push({ kind: "element", id: el.id, before: el, after });
|
|
78
|
+
patches.push(...translateUnit(unit, dx, dy));
|
|
89
79
|
}
|
|
90
80
|
return patches;
|
|
91
81
|
};
|
|
92
82
|
/**
|
|
93
|
-
* Pure: evenly space the selection along the given axis so the gaps
|
|
94
|
-
* adjacent
|
|
95
|
-
* shift to balance the gaps (accounting for
|
|
96
|
-
* three
|
|
83
|
+
* Pure: evenly space the selection's units along the given axis so the gaps
|
|
84
|
+
* between adjacent units are equal (a selected group is one unit). The
|
|
85
|
+
* outermost two stay put; the rest shift to balance the gaps (accounting for
|
|
86
|
+
* differing sizes). A no-op below three units.
|
|
97
87
|
*/
|
|
98
88
|
export const computeDistributePatches = (scene, ids, axis) => {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
89
|
+
const units = arrangeUnits(scene, ids);
|
|
90
|
+
if (units.length < 3)
|
|
101
91
|
return [];
|
|
102
92
|
const horizontal = axis === "horizontal";
|
|
103
93
|
const start = (b) => (horizontal ? b.x : b.y);
|
|
104
94
|
const size = (b) => (horizontal ? b.width : b.height);
|
|
105
|
-
const sorted =
|
|
106
|
-
.map((
|
|
95
|
+
const sorted = units
|
|
96
|
+
.map((unit) => ({ unit, b: unit.bounds }))
|
|
107
97
|
.sort((p, q) => start(p.b) - start(q.b));
|
|
108
98
|
const first = sorted[0];
|
|
109
99
|
const last = sorted[sorted.length - 1];
|
|
@@ -119,12 +109,7 @@ export const computeDistributePatches = (scene, ids, axis) => {
|
|
|
119
109
|
if (!p)
|
|
120
110
|
continue;
|
|
121
111
|
const delta = cursor - start(p.b);
|
|
122
|
-
|
|
123
|
-
const after = horizontal
|
|
124
|
-
? { ...p.el, position: { x: p.el.position.x + delta, y: p.el.position.y } }
|
|
125
|
-
: { ...p.el, position: { x: p.el.position.x, y: p.el.position.y + delta } };
|
|
126
|
-
patches.push({ kind: "element", id: p.el.id, before: p.el, after });
|
|
127
|
-
}
|
|
112
|
+
patches.push(...translateUnit(p.unit, horizontal ? delta : 0, horizontal ? 0 : delta));
|
|
128
113
|
cursor += size(p.b) + gap;
|
|
129
114
|
}
|
|
130
115
|
return patches;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrange.js","sourceRoot":"","sources":["../../../src/editor/applies/arrange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,UAAU,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"arrange.js","sourceRoot":"","sources":["../../../src/editor/applies/arrange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,uBA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 -1,14 +1,20 @@
|
|
|
1
1
|
import { type Link, type LinkEndpoint, type Scene, type Element, type Patch } from "@oh-just-another/scene";
|
|
2
2
|
import type { Bounds, LinkId, LayerId, ElementId, Vec2 } from "@oh-just-another/types";
|
|
3
|
+
export declare const buildElementForCreate: (scene: Scene, kind: "rect" | "ellipse" | "frame" | "diamond" | "triangle", bounds: Bounds, id: ElementId, layerId: LayerId, nextFrameName: () => string) => Element;
|
|
3
4
|
/**
|
|
4
|
-
* Build the `
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
5
|
+
* Build the `Link` object for a CREATE_EDGE emit. Endpoints are
|
|
6
|
+
* pre-resolved (snapped) by the caller — we just compose them with the
|
|
7
|
+
* layer / order / style boilerplate.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Per-draw overrides for new connectors (the "Shapes and lines" line
|
|
11
|
+
* presets): routing and the end arrowhead (`null` = no arrowhead).
|
|
12
|
+
* Omitted fields fall back to the defaults.
|
|
10
13
|
*/
|
|
11
|
-
export
|
|
14
|
+
export interface LinkCreateOverrides {
|
|
15
|
+
readonly routing?: "straight" | "orthogonal";
|
|
16
|
+
readonly arrowheadTo?: "triangle" | null;
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* Build the throwaway `Link` for the live draw-edge connector preview.
|
|
14
20
|
* Same default object as {@link buildLinkForCreate} (so the dragged preview is
|
|
@@ -21,7 +27,7 @@ export declare const buildEdgePreviewLink: (scene: Scene, preview: {
|
|
|
21
27
|
readonly from: Vec2;
|
|
22
28
|
readonly to: Vec2;
|
|
23
29
|
readonly points?: readonly Vec2[];
|
|
24
|
-
}, id: LinkId, layerId: LayerId) => Link;
|
|
30
|
+
}, id: LinkId, layerId: LayerId, overrides?: LinkCreateOverrides) => Link;
|
|
25
31
|
/**
|
|
26
32
|
* Composite helper for `applyCreate` — builds the shape and runs
|
|
27
33
|
* `addElement` against the scene. Returns the scene + patch so the
|
|
@@ -31,7 +37,7 @@ export declare const buildEdgePreviewLink: (scene: Scene, preview: {
|
|
|
31
37
|
* `width` / `height`; the parameter is kept on the signature only
|
|
32
38
|
* to document intent at the call site.
|
|
33
39
|
*/
|
|
34
|
-
export declare const computeCreateElement: (scene: Scene, kind: "rect" | "ellipse" | "frame", bounds: Bounds, id: ElementId, layerId: LayerId, nextFrameName: () => string) => {
|
|
40
|
+
export declare const computeCreateElement: (scene: Scene, kind: "rect" | "ellipse" | "frame" | "diamond" | "triangle", bounds: Bounds, id: ElementId, layerId: LayerId, nextFrameName: () => string) => {
|
|
35
41
|
readonly scene: Scene;
|
|
36
42
|
readonly patch: Patch;
|
|
37
43
|
readonly elementId: ElementId;
|
|
@@ -42,7 +48,7 @@ export declare const computeCreateElement: (scene: Scene, kind: "rect" | "ellips
|
|
|
42
48
|
* to the snap engine in Editor); pre-resolved `from`/`to` are
|
|
43
49
|
* threaded in as parameters.
|
|
44
50
|
*/
|
|
45
|
-
export declare const computeCreateLink: (scene: Scene, from: LinkEndpoint, to: LinkEndpoint, id: LinkId, layerId: LayerId) => {
|
|
51
|
+
export declare const computeCreateLink: (scene: Scene, from: LinkEndpoint, to: LinkEndpoint, id: LinkId, layerId: LayerId, overrides?: LinkCreateOverrides) => {
|
|
46
52
|
readonly scene: Scene;
|
|
47
53
|
readonly patch: Patch;
|
|
48
54
|
readonly linkId: LinkId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/editor/applies/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"create.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