@oh-just-another/scene 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 +13 -0
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/a11y.d.ts +23 -0
- package/dist/a11y.d.ts.map +1 -0
- package/dist/a11y.js +37 -0
- package/dist/a11y.js.map +1 -0
- package/dist/anchors.d.ts +120 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +322 -0
- package/dist/anchors.js.map +1 -0
- package/dist/annotation-geometry.d.ts +11 -0
- package/dist/annotation-geometry.d.ts.map +1 -0
- package/dist/annotation-geometry.js +19 -0
- package/dist/annotation-geometry.js.map +1 -0
- package/dist/annotation.d.ts +32 -0
- package/dist/annotation.d.ts.map +1 -0
- package/dist/annotation.js +2 -0
- package/dist/annotation.js.map +1 -0
- package/dist/constants.d.ts +186 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +186 -0
- package/dist/constants.js.map +1 -0
- package/dist/container.d.ts +112 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +227 -0
- package/dist/container.js.map +1 -0
- package/dist/diff.d.ts +22 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +18 -0
- package/dist/diff.js.map +1 -0
- package/dist/edge-curve.d.ts +37 -0
- package/dist/edge-curve.d.ts.map +1 -0
- package/dist/edge-curve.js +72 -0
- package/dist/edge-curve.js.map +1 -0
- package/dist/edge-geometry.d.ts +96 -0
- package/dist/edge-geometry.d.ts.map +1 -0
- package/dist/edge-geometry.js +467 -0
- package/dist/edge-geometry.js.map +1 -0
- package/dist/edge.d.ts +206 -0
- package/dist/edge.d.ts.map +1 -0
- package/dist/edge.js +2 -0
- package/dist/edge.js.map +1 -0
- package/dist/elbow-link.d.ts +23 -0
- package/dist/elbow-link.d.ts.map +1 -0
- package/dist/elbow-link.js +419 -0
- package/dist/elbow-link.js.map +1 -0
- package/dist/elbow-router.d.ts +20 -0
- package/dist/elbow-router.d.ts.map +1 -0
- package/dist/elbow-router.js +218 -0
- package/dist/elbow-router.js.map +1 -0
- package/dist/file.d.ts +41 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +13 -0
- package/dist/file.js.map +1 -0
- package/dist/heading.d.ts +42 -0
- package/dist/heading.d.ts.map +1 -0
- package/dist/heading.js +77 -0
- package/dist/heading.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/layer.d.ts +18 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +2 -0
- package/dist/layer.js.map +1 -0
- package/dist/layout-registry.d.ts +35 -0
- package/dist/layout-registry.d.ts.map +1 -0
- package/dist/layout-registry.js +13 -0
- package/dist/layout-registry.js.map +1 -0
- package/dist/layout.d.ts +128 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +453 -0
- package/dist/layout.js.map +1 -0
- package/dist/operations.d.ts +32 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +105 -0
- package/dist/operations.js.map +1 -0
- package/dist/outline.d.ts +36 -0
- package/dist/outline.d.ts.map +1 -0
- package/dist/outline.js +129 -0
- package/dist/outline.js.map +1 -0
- package/dist/patch.d.ts +57 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +47 -0
- package/dist/patch.js.map +1 -0
- package/dist/queries.d.ts +115 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +403 -0
- package/dist/queries.js.map +1 -0
- package/dist/render-bounds.d.ts +36 -0
- package/dist/render-bounds.d.ts.map +1 -0
- package/dist/render-bounds.js +36 -0
- package/dist/render-bounds.js.map +1 -0
- package/dist/scene.d.ts +80 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +129 -0
- package/dist/scene.js.map +1 -0
- package/dist/shape.d.ts +306 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +192 -0
- package/dist/shape.js.map +1 -0
- package/dist/snap.d.ts +88 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +128 -0
- package/dist/snap.js.map +1 -0
- package/dist/spatial.d.ts +38 -0
- package/dist/spatial.d.ts.map +1 -0
- package/dist/spatial.js +95 -0
- package/dist/spatial.js.map +1 -0
- package/dist/style.d.ts +87 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +43 -0
- package/dist/style.js.map +1 -0
- package/dist/text-measure.d.ts +29 -0
- package/dist/text-measure.d.ts.map +1 -0
- package/dist/text-measure.js +8 -0
- package/dist/text-measure.js.map +1 -0
- package/dist/three-way-merge.d.ts +59 -0
- package/dist/three-way-merge.d.ts.map +1 -0
- package/dist/three-way-merge.js +108 -0
- package/dist/three-way-merge.js.map +1 -0
- package/dist/viewport.d.ts +78 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +62 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-registry.js","sourceRoot":"","sources":["../src/layout-registry.ts"],"names":[],"mappings":"AAsCA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAI,KAAyB,EAAQ,EAAE;IACvE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAA+B,EAAE;IAChF,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAA+B,EAAE,CACzE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAErB,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAsB,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC"}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { ElementId, Vec2 } from "@oh-just-another/types";
|
|
2
|
+
import type { Scene } from "./scene.js";
|
|
3
|
+
import { type Element } from "./shape.js";
|
|
4
|
+
import { type Patch } from "./patch.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pure layout function. Computes new positions for a subset of shapes
|
|
7
|
+
* and returns a single batched patch (or null when nothing changed).
|
|
8
|
+
*
|
|
9
|
+
* Built-in layouts: `gridLayout`, `stackLayout`. Hosts can register
|
|
10
|
+
* their own via the same signature; integrate with `Editor` through
|
|
11
|
+
* a custom command.
|
|
12
|
+
*/
|
|
13
|
+
export interface LayoutSpec {
|
|
14
|
+
readonly shapeIds: readonly ElementId[];
|
|
15
|
+
readonly origin?: Vec2;
|
|
16
|
+
}
|
|
17
|
+
export type LayoutFn<S extends LayoutSpec = LayoutSpec> = (scene: Scene, spec: S) => Patch | null;
|
|
18
|
+
export interface GridLayoutSpec extends LayoutSpec {
|
|
19
|
+
readonly cols: number;
|
|
20
|
+
/** Cell gap, world units. */
|
|
21
|
+
readonly gap?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Position shapes on a regular grid. Each cell size = max shape
|
|
25
|
+
* width/height in its column/row + gap. Stable order: by `shape.order`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const gridLayout: LayoutFn<GridLayoutSpec>;
|
|
28
|
+
export interface StackLayoutSpec extends LayoutSpec {
|
|
29
|
+
readonly direction: "horizontal" | "vertical";
|
|
30
|
+
readonly gap?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Position shapes top-to-bottom or left-to-right without wrapping. */
|
|
33
|
+
export declare const stackLayout: LayoutFn<StackLayoutSpec>;
|
|
34
|
+
export interface WrapLayoutSpec extends LayoutSpec {
|
|
35
|
+
/** Inner width to wrap within (the container's drop-zone width). */
|
|
36
|
+
readonly innerWidth: number;
|
|
37
|
+
readonly gap?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Position children in a wrapping flow (see {@link packWrap}). Children keep
|
|
41
|
+
* their own size; the container is expected to grow vertically to fit the rows
|
|
42
|
+
* (handled by the host's container auto-grow / resize clamp).
|
|
43
|
+
*/
|
|
44
|
+
export declare const wrapLayout: LayoutFn<WrapLayoutSpec>;
|
|
45
|
+
/**
|
|
46
|
+
* Measure a wrap container's children at a hypothetical `innerWidth` WITHOUT
|
|
47
|
+
* moving anything — used by the resize clamp / scheduler to know the minimum
|
|
48
|
+
* width (widest child) and the wrapped content height (so the container can
|
|
49
|
+
* grow down). Returns `null` when the parent has no children.
|
|
50
|
+
*/
|
|
51
|
+
export declare const measureWrap: (scene: Scene, parentId: ElementId, innerWidth: number) => {
|
|
52
|
+
readonly widest: number;
|
|
53
|
+
readonly contentWidth: number;
|
|
54
|
+
readonly contentHeight: number;
|
|
55
|
+
} | null;
|
|
56
|
+
/**
|
|
57
|
+
* Convenience: list all shape ids in a layer in z-order, suitable
|
|
58
|
+
* as `LayoutSpec.shapeIds`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const allElementsInLayer: (scene: Scene, layerId: Scene["layers"] extends ReadonlyMap<infer K, unknown> ? K : never) => readonly ElementId[];
|
|
61
|
+
/**
|
|
62
|
+
* Declarative auto-layout spec stored on a parent shape's
|
|
63
|
+
* `metadata.autoLayout`. Children of the parent (via `parentId`)
|
|
64
|
+
* are arranged whenever the children set changes — see
|
|
65
|
+
* `Editor.runLayout` for the host-side hook.
|
|
66
|
+
*
|
|
67
|
+
* Adding more layout kinds (tree, radial) means widening this union
|
|
68
|
+
* and matching it in `runAutoLayout`. Hosts can ignore the union and
|
|
69
|
+
* call `gridLayout` / `stackLayout` directly with custom spec.
|
|
70
|
+
*/
|
|
71
|
+
export type AutoLayoutSpec = {
|
|
72
|
+
readonly kind: "grid";
|
|
73
|
+
readonly cols: number;
|
|
74
|
+
readonly gap?: number;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "stack";
|
|
77
|
+
readonly direction: "horizontal" | "vertical";
|
|
78
|
+
readonly gap?: number;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: "wrap";
|
|
81
|
+
readonly gap?: number;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "tree";
|
|
84
|
+
/** Vertical distance between successive depth levels. Default 80. */
|
|
85
|
+
readonly ranksep?: number;
|
|
86
|
+
/** Horizontal distance between siblings. Default 24. */
|
|
87
|
+
readonly nodesep?: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Parse and validate the `metadata.autoLayout` field on a shape.
|
|
91
|
+
* Returns `null` when the shape has no auto-layout configured or the
|
|
92
|
+
* stored payload doesn't match a known kind / required fields are
|
|
93
|
+
* missing. Callers should treat `null` as "not an auto-layout
|
|
94
|
+
* container — leave its children alone".
|
|
95
|
+
*/
|
|
96
|
+
export declare const getAutoLayoutSpec: (shape: Element) => AutoLayoutSpec | null;
|
|
97
|
+
/**
|
|
98
|
+
* Run the parent shape's declared auto-layout against its direct
|
|
99
|
+
* children. Returns a batched patch (or `null` when nothing
|
|
100
|
+
* changed). Anchoring rules:
|
|
101
|
+
*
|
|
102
|
+
* 1. If the parent has a container spec with a `dropZone`, the
|
|
103
|
+
* layout origin is the top-left of that drop-zone in world
|
|
104
|
+
* coords (parent.position + spec.dropZone.x/y). Children land
|
|
105
|
+
* inside the visible drop area, not overlapping the parent's
|
|
106
|
+
* title / chrome / border.
|
|
107
|
+
* 2. Otherwise the origin falls back to `parent.position`.
|
|
108
|
+
*/
|
|
109
|
+
export declare const runAutoLayout: (scene: Scene, parentId: ElementId) => Patch | null;
|
|
110
|
+
export interface TreeLayoutSpec extends LayoutSpec {
|
|
111
|
+
/** Vertical distance between successive depth levels. */
|
|
112
|
+
readonly ranksep?: number;
|
|
113
|
+
/** Horizontal distance between siblings. */
|
|
114
|
+
readonly nodesep?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Reingold-Tilford-style top-down tree layout. Each id in
|
|
118
|
+
* `spec.shapeIds` is treated as a root; the algorithm walks
|
|
119
|
+
* `parentId` *downward* via `getChildrenOf` (so a deeper subtree
|
|
120
|
+
* lives entirely under one of the roots). Each level is stacked
|
|
121
|
+
* vertically by `ranksep`; siblings within a level are spaced by
|
|
122
|
+
* `nodesep`. Each subtree is centred above its children.
|
|
123
|
+
*
|
|
124
|
+
* Implementation: standard two-pass walk (bottom-up subtree-width
|
|
125
|
+
* computation, then top-down x-placement).
|
|
126
|
+
*/
|
|
127
|
+
export declare const treeLayout: LayoutFn<TreeLayoutSpec>;
|
|
128
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAGjE,OAAO,EAAS,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AA+B/C;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,KAAK,GAAG,IAAI,CAAC;AAElG,MAAM,WAAW,cAAe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I,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,UAAU,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAChG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEN;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,cAAc,GAAG,IA2CnE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,EAAE,UAAU,SAAS,KAAG,KAAK,GAAG,IA4DzE,CAAC;AAIF,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,yDAAyD;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,cAAc,CAiG/C,CAAC"}
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { getDropZoneWorld } from "./container.js";
|
|
2
|
+
import { getElementLocalBounds } from "./shape.js";
|
|
3
|
+
import { getElement, getElementsInLayer } from "./queries.js";
|
|
4
|
+
import { updateElement } from "./operations.js";
|
|
5
|
+
import { batch } from "./patch.js";
|
|
6
|
+
import { getLayoutKind } from "./layout-registry.js";
|
|
7
|
+
const req = (v) => {
|
|
8
|
+
if (v === undefined)
|
|
9
|
+
throw new Error("packages/scene: index out of range");
|
|
10
|
+
return v;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Visual width / height of a shape in its OWN frame (no `position`,
|
|
14
|
+
* yes `scale`). Uses the registered bounder so polygon / path /
|
|
15
|
+
* freedraw shapes report their actual AABB — `shape.width` /
|
|
16
|
+
* `shape.height` only exist on rectangle / ellipse / image / text
|
|
17
|
+
* and reading them directly would return `undefined` for the
|
|
18
|
+
* others, collapsing the layout stride to `0` and stacking every
|
|
19
|
+
* polygon at the same point. Returns `(0, 0)` if no bounder is
|
|
20
|
+
* registered for the type (kept defensive — the layout falls back
|
|
21
|
+
* to gap-only spacing rather than throwing).
|
|
22
|
+
*/
|
|
23
|
+
const shapeAdvanceSize = (shape) => {
|
|
24
|
+
try {
|
|
25
|
+
const local = getElementLocalBounds(shape);
|
|
26
|
+
return {
|
|
27
|
+
width: local.width * Math.abs(shape.scale.x),
|
|
28
|
+
height: local.height * Math.abs(shape.scale.y),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return { width: 0, height: 0 };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Position shapes on a regular grid. Each cell size = max shape
|
|
37
|
+
* width/height in its column/row + gap. Stable order: by `shape.order`.
|
|
38
|
+
*/
|
|
39
|
+
export const gridLayout = (scene, spec) => {
|
|
40
|
+
if (spec.shapeIds.length === 0 || spec.cols < 1)
|
|
41
|
+
return null;
|
|
42
|
+
const gap = spec.gap ?? 16;
|
|
43
|
+
const origin = spec.origin ?? { x: 0, y: 0 };
|
|
44
|
+
const shapes = [];
|
|
45
|
+
for (const id of spec.shapeIds) {
|
|
46
|
+
const s = getElement(scene, id);
|
|
47
|
+
if (s)
|
|
48
|
+
shapes.push(s);
|
|
49
|
+
}
|
|
50
|
+
shapes.sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0));
|
|
51
|
+
const sizes = shapes.map(shapeAdvanceSize);
|
|
52
|
+
const cellW = sizes.reduce((m, s) => Math.max(m, s.width), 0);
|
|
53
|
+
const cellH = sizes.reduce((m, s) => Math.max(m, s.height), 0);
|
|
54
|
+
const stride = { x: cellW + gap, y: cellH + gap };
|
|
55
|
+
const patches = [];
|
|
56
|
+
let working = scene;
|
|
57
|
+
shapes.forEach((shape, i) => {
|
|
58
|
+
const col = i % spec.cols;
|
|
59
|
+
const row = Math.floor(i / spec.cols);
|
|
60
|
+
const target = { x: origin.x + col * stride.x, y: origin.y + row * stride.y };
|
|
61
|
+
if (shape.position.x === target.x && shape.position.y === target.y)
|
|
62
|
+
return;
|
|
63
|
+
const r = updateElement(working, shape.id, (s) => ({ ...s, position: target }));
|
|
64
|
+
working = r.scene;
|
|
65
|
+
patches.push(r.patch);
|
|
66
|
+
});
|
|
67
|
+
if (patches.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
return batch(patches);
|
|
70
|
+
};
|
|
71
|
+
/** Position shapes top-to-bottom or left-to-right without wrapping. */
|
|
72
|
+
export const stackLayout = (scene, spec) => {
|
|
73
|
+
if (spec.shapeIds.length === 0)
|
|
74
|
+
return null;
|
|
75
|
+
const gap = spec.gap ?? 16;
|
|
76
|
+
const origin = spec.origin ?? { x: 0, y: 0 };
|
|
77
|
+
const shapes = [];
|
|
78
|
+
for (const id of spec.shapeIds) {
|
|
79
|
+
const s = getElement(scene, id);
|
|
80
|
+
if (s)
|
|
81
|
+
shapes.push(s);
|
|
82
|
+
}
|
|
83
|
+
shapes.sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0));
|
|
84
|
+
const patches = [];
|
|
85
|
+
let working = scene;
|
|
86
|
+
let cursor = { x: origin.x, y: origin.y };
|
|
87
|
+
for (const shape of shapes) {
|
|
88
|
+
const { width: w, height: h } = shapeAdvanceSize(shape);
|
|
89
|
+
if (shape.position.x !== cursor.x || shape.position.y !== cursor.y) {
|
|
90
|
+
const target = cursor;
|
|
91
|
+
const r = updateElement(working, shape.id, (s) => ({ ...s, position: target }));
|
|
92
|
+
working = r.scene;
|
|
93
|
+
patches.push(r.patch);
|
|
94
|
+
}
|
|
95
|
+
if (spec.direction === "horizontal")
|
|
96
|
+
cursor = { x: cursor.x + w + gap, y: cursor.y };
|
|
97
|
+
else
|
|
98
|
+
cursor = { x: cursor.x, y: cursor.y + h + gap };
|
|
99
|
+
}
|
|
100
|
+
if (patches.length === 0)
|
|
101
|
+
return null;
|
|
102
|
+
return batch(patches);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Greedy flex-wrap packing (CSS `flex-wrap: wrap`, `inline-block` flow):
|
|
106
|
+
* children keep their own size and flow left→right; the next child that would
|
|
107
|
+
* overrun `innerWidth` starts a new row. Row height = tallest child in the row;
|
|
108
|
+
* rows are top-aligned and stack downward. A child wider than `innerWidth` gets
|
|
109
|
+
* its own row (overflows — that's what bounds the minimum width). Pure.
|
|
110
|
+
*/
|
|
111
|
+
const packWrap = (sizes, gap, innerWidth, origin) => {
|
|
112
|
+
const placements = [];
|
|
113
|
+
let cursorX = origin.x;
|
|
114
|
+
let cursorY = origin.y;
|
|
115
|
+
let rowH = 0;
|
|
116
|
+
let widest = 0;
|
|
117
|
+
let maxRowW = 0;
|
|
118
|
+
let firstInRow = true;
|
|
119
|
+
for (const s of sizes) {
|
|
120
|
+
widest = Math.max(widest, s.w);
|
|
121
|
+
if (!firstInRow && cursorX - origin.x + s.w > innerWidth + 1e-6) {
|
|
122
|
+
// Wrap: close the current row, start a new one below.
|
|
123
|
+
maxRowW = Math.max(maxRowW, cursorX - gap - origin.x);
|
|
124
|
+
cursorX = origin.x;
|
|
125
|
+
cursorY += rowH + gap;
|
|
126
|
+
rowH = 0;
|
|
127
|
+
firstInRow = true;
|
|
128
|
+
}
|
|
129
|
+
placements.push({ id: s.id, x: cursorX, y: cursorY }); // top-aligned
|
|
130
|
+
cursorX += s.w + gap;
|
|
131
|
+
rowH = Math.max(rowH, s.h);
|
|
132
|
+
firstInRow = false;
|
|
133
|
+
}
|
|
134
|
+
maxRowW = Math.max(maxRowW, cursorX - gap - origin.x);
|
|
135
|
+
return {
|
|
136
|
+
placements,
|
|
137
|
+
widest,
|
|
138
|
+
contentWidth: Math.max(0, maxRowW),
|
|
139
|
+
contentHeight: cursorY + rowH - origin.y,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/** Ordered (by `order`) children of `parentId` with their advance sizes. */
|
|
143
|
+
const childSizes = (scene, ids) => {
|
|
144
|
+
const shapes = [];
|
|
145
|
+
for (const id of ids) {
|
|
146
|
+
const s = getElement(scene, id);
|
|
147
|
+
if (s)
|
|
148
|
+
shapes.push(s);
|
|
149
|
+
}
|
|
150
|
+
shapes.sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0));
|
|
151
|
+
return shapes.map((s) => {
|
|
152
|
+
const sz = shapeAdvanceSize(s);
|
|
153
|
+
return { id: s.id, w: sz.width, h: sz.height };
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Position children in a wrapping flow (see {@link packWrap}). Children keep
|
|
158
|
+
* their own size; the container is expected to grow vertically to fit the rows
|
|
159
|
+
* (handled by the host's container auto-grow / resize clamp).
|
|
160
|
+
*/
|
|
161
|
+
export const wrapLayout = (scene, spec) => {
|
|
162
|
+
if (spec.shapeIds.length === 0)
|
|
163
|
+
return null;
|
|
164
|
+
const gap = spec.gap ?? 16;
|
|
165
|
+
const origin = spec.origin ?? { x: 0, y: 0 };
|
|
166
|
+
const sizes = childSizes(scene, spec.shapeIds);
|
|
167
|
+
const { placements } = packWrap(sizes, gap, spec.innerWidth, origin);
|
|
168
|
+
const patches = [];
|
|
169
|
+
let working = scene;
|
|
170
|
+
for (const p of placements) {
|
|
171
|
+
const shape = getElement(working, p.id);
|
|
172
|
+
if (!shape)
|
|
173
|
+
continue;
|
|
174
|
+
if (shape.position.x === p.x && shape.position.y === p.y)
|
|
175
|
+
continue;
|
|
176
|
+
const r = updateElement(working, p.id, (s) => ({ ...s, position: { x: p.x, y: p.y } }));
|
|
177
|
+
working = r.scene;
|
|
178
|
+
patches.push(r.patch);
|
|
179
|
+
}
|
|
180
|
+
if (patches.length === 0)
|
|
181
|
+
return null;
|
|
182
|
+
return batch(patches);
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Measure a wrap container's children at a hypothetical `innerWidth` WITHOUT
|
|
186
|
+
* moving anything — used by the resize clamp / scheduler to know the minimum
|
|
187
|
+
* width (widest child) and the wrapped content height (so the container can
|
|
188
|
+
* grow down). Returns `null` when the parent has no children.
|
|
189
|
+
*/
|
|
190
|
+
export const measureWrap = (scene, parentId, innerWidth) => {
|
|
191
|
+
const ids = [];
|
|
192
|
+
for (const s of scene.elements.values()) {
|
|
193
|
+
if (s.parentId === parentId)
|
|
194
|
+
ids.push(s.id);
|
|
195
|
+
}
|
|
196
|
+
if (ids.length === 0)
|
|
197
|
+
return null;
|
|
198
|
+
const sizes = childSizes(scene, ids);
|
|
199
|
+
const parent = getElement(scene, parentId);
|
|
200
|
+
const gap = (parent ? getAutoLayoutSpec(parent) : null)?.gap ?? 16;
|
|
201
|
+
const m = packWrap(sizes, gap, innerWidth, { x: 0, y: 0 });
|
|
202
|
+
return { widest: m.widest, contentWidth: m.contentWidth, contentHeight: m.contentHeight };
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Convenience: list all shape ids in a layer in z-order, suitable
|
|
206
|
+
* as `LayoutSpec.shapeIds`.
|
|
207
|
+
*/
|
|
208
|
+
export const allElementsInLayer = (scene, layerId) => getElementsInLayer(scene, layerId).map((s) => s.id);
|
|
209
|
+
/**
|
|
210
|
+
* Parse and validate the `metadata.autoLayout` field on a shape.
|
|
211
|
+
* Returns `null` when the shape has no auto-layout configured or the
|
|
212
|
+
* stored payload doesn't match a known kind / required fields are
|
|
213
|
+
* missing. Callers should treat `null` as "not an auto-layout
|
|
214
|
+
* container — leave its children alone".
|
|
215
|
+
*/
|
|
216
|
+
export const getAutoLayoutSpec = (shape) => {
|
|
217
|
+
const m = shape.metadata?.autoLayout;
|
|
218
|
+
if (!m || typeof m !== "object")
|
|
219
|
+
return null;
|
|
220
|
+
const raw = m;
|
|
221
|
+
if (raw.kind === "grid") {
|
|
222
|
+
if (typeof raw.cols !== "number" || raw.cols < 1)
|
|
223
|
+
return null;
|
|
224
|
+
return {
|
|
225
|
+
kind: "grid",
|
|
226
|
+
cols: raw.cols,
|
|
227
|
+
...(typeof raw.gap === "number" ? { gap: raw.gap } : {}),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (raw.kind === "stack") {
|
|
231
|
+
if (raw.direction !== "horizontal" && raw.direction !== "vertical")
|
|
232
|
+
return null;
|
|
233
|
+
return {
|
|
234
|
+
kind: "stack",
|
|
235
|
+
direction: raw.direction,
|
|
236
|
+
...(typeof raw.gap === "number" ? { gap: raw.gap } : {}),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (raw.kind === "wrap") {
|
|
240
|
+
return { kind: "wrap", ...(typeof raw.gap === "number" ? { gap: raw.gap } : {}) };
|
|
241
|
+
}
|
|
242
|
+
if (raw.kind === "tree") {
|
|
243
|
+
const treeRaw = m;
|
|
244
|
+
return {
|
|
245
|
+
kind: "tree",
|
|
246
|
+
...(typeof treeRaw.ranksep === "number" ? { ranksep: treeRaw.ranksep } : {}),
|
|
247
|
+
...(typeof treeRaw.nodesep === "number" ? { nodesep: treeRaw.nodesep } : {}),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
// Plugin kinds — consult the registry. Returns an opaque-typed
|
|
251
|
+
// spec; `runAutoLayout` re-resolves the entry and dispatches.
|
|
252
|
+
if (typeof raw.kind === "string") {
|
|
253
|
+
const entry = getLayoutKind(raw.kind);
|
|
254
|
+
if (entry) {
|
|
255
|
+
const parsed = entry.parse(m);
|
|
256
|
+
if (parsed !== null) {
|
|
257
|
+
return { ...parsed, kind: raw.kind };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Run the parent shape's declared auto-layout against its direct
|
|
265
|
+
* children. Returns a batched patch (or `null` when nothing
|
|
266
|
+
* changed). Anchoring rules:
|
|
267
|
+
*
|
|
268
|
+
* 1. If the parent has a container spec with a `dropZone`, the
|
|
269
|
+
* layout origin is the top-left of that drop-zone in world
|
|
270
|
+
* coords (parent.position + spec.dropZone.x/y). Children land
|
|
271
|
+
* inside the visible drop area, not overlapping the parent's
|
|
272
|
+
* title / chrome / border.
|
|
273
|
+
* 2. Otherwise the origin falls back to `parent.position`.
|
|
274
|
+
*/
|
|
275
|
+
export const runAutoLayout = (scene, parentId) => {
|
|
276
|
+
const parent = getElement(scene, parentId);
|
|
277
|
+
if (!parent)
|
|
278
|
+
return null;
|
|
279
|
+
const spec = getAutoLayoutSpec(parent);
|
|
280
|
+
if (!spec)
|
|
281
|
+
return null;
|
|
282
|
+
const children = [];
|
|
283
|
+
for (const s of scene.elements.values()) {
|
|
284
|
+
if (s.parentId === parentId)
|
|
285
|
+
children.push(s.id);
|
|
286
|
+
}
|
|
287
|
+
if (children.length === 0)
|
|
288
|
+
return null;
|
|
289
|
+
const dropZone = getDropZoneWorld(parent);
|
|
290
|
+
const origin = dropZone
|
|
291
|
+
? { x: dropZone.x, y: dropZone.y }
|
|
292
|
+
: parent.position;
|
|
293
|
+
if (spec.kind === "grid") {
|
|
294
|
+
return gridLayout(scene, {
|
|
295
|
+
shapeIds: children,
|
|
296
|
+
origin,
|
|
297
|
+
cols: spec.cols,
|
|
298
|
+
...(spec.gap !== undefined ? { gap: spec.gap } : {}),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
if (spec.kind === "stack") {
|
|
302
|
+
return stackLayout(scene, {
|
|
303
|
+
shapeIds: children,
|
|
304
|
+
origin,
|
|
305
|
+
direction: spec.direction,
|
|
306
|
+
...(spec.gap !== undefined ? { gap: spec.gap } : {}),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (spec.kind === "wrap") {
|
|
310
|
+
// Wrap within the drop-zone width; children flow + wrap, the container
|
|
311
|
+
// grows DOWN to fit new rows (via the host's auto-grow / resize clamp).
|
|
312
|
+
const innerWidth = dropZone ? dropZone.width : Number.POSITIVE_INFINITY;
|
|
313
|
+
return wrapLayout(scene, {
|
|
314
|
+
shapeIds: children,
|
|
315
|
+
origin,
|
|
316
|
+
innerWidth,
|
|
317
|
+
...(spec.gap !== undefined ? { gap: spec.gap } : {}),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- closed union narrows to "tree", but plugin kinds exist at runtime and must fall through to the registry below.
|
|
321
|
+
if (spec.kind === "tree") {
|
|
322
|
+
return treeLayout(scene, {
|
|
323
|
+
shapeIds: children,
|
|
324
|
+
origin,
|
|
325
|
+
...(spec.ranksep !== undefined ? { ranksep: spec.ranksep } : {}),
|
|
326
|
+
...(spec.nodesep !== undefined ? { nodesep: spec.nodesep } : {}),
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// Plugin kinds — TS narrowed `spec` to `never` after exhausting
|
|
330
|
+
// the closed union, so cast back to `{ kind }` to ask the
|
|
331
|
+
// registry. Hosts can register layouts like "radial" without
|
|
332
|
+
// editing the closed `AutoLayoutSpec` union.
|
|
333
|
+
const pluginSpec = spec;
|
|
334
|
+
const entry = getLayoutKind(pluginSpec.kind);
|
|
335
|
+
if (entry) {
|
|
336
|
+
return entry.run(scene, parentId, children, origin, pluginSpec);
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Reingold-Tilford-style top-down tree layout. Each id in
|
|
342
|
+
* `spec.shapeIds` is treated as a root; the algorithm walks
|
|
343
|
+
* `parentId` *downward* via `getChildrenOf` (so a deeper subtree
|
|
344
|
+
* lives entirely under one of the roots). Each level is stacked
|
|
345
|
+
* vertically by `ranksep`; siblings within a level are spaced by
|
|
346
|
+
* `nodesep`. Each subtree is centred above its children.
|
|
347
|
+
*
|
|
348
|
+
* Implementation: standard two-pass walk (bottom-up subtree-width
|
|
349
|
+
* computation, then top-down x-placement).
|
|
350
|
+
*/
|
|
351
|
+
export const treeLayout = (scene, spec) => {
|
|
352
|
+
if (spec.shapeIds.length === 0)
|
|
353
|
+
return null;
|
|
354
|
+
const ranksep = spec.ranksep ?? 80;
|
|
355
|
+
const nodesep = spec.nodesep ?? 24;
|
|
356
|
+
const origin = spec.origin ?? { x: 0, y: 0 };
|
|
357
|
+
// Build a child-of map filtered to shapes that exist.
|
|
358
|
+
const childrenOf = (id) => {
|
|
359
|
+
const out = [];
|
|
360
|
+
for (const s of scene.elements.values()) {
|
|
361
|
+
if (s.parentId === id)
|
|
362
|
+
out.push(s);
|
|
363
|
+
}
|
|
364
|
+
out.sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0));
|
|
365
|
+
return out;
|
|
366
|
+
};
|
|
367
|
+
// Subtree-width / height memo.
|
|
368
|
+
const widthOf = new Map();
|
|
369
|
+
const heightOf = new Map();
|
|
370
|
+
// Use the registered bounder (via shapeAdvanceSize) so polygon /
|
|
371
|
+
// path / freedraw shapes report their real AABB; reading
|
|
372
|
+
// `shape.width` directly returns `undefined` for them and would
|
|
373
|
+
// collapse every non-rectangle/ellipse node to a zero-sized box.
|
|
374
|
+
const shapeWidth = (s) => shapeAdvanceSize(s).width;
|
|
375
|
+
const shapeHeight = (s) => shapeAdvanceSize(s).height;
|
|
376
|
+
const measure = (id) => {
|
|
377
|
+
const cachedW = widthOf.get(id);
|
|
378
|
+
const cachedH = heightOf.get(id);
|
|
379
|
+
if (cachedW !== undefined && cachedH !== undefined)
|
|
380
|
+
return { w: cachedW, h: cachedH };
|
|
381
|
+
const shape = getElement(scene, id);
|
|
382
|
+
if (!shape) {
|
|
383
|
+
widthOf.set(id, 0);
|
|
384
|
+
heightOf.set(id, 0);
|
|
385
|
+
return { w: 0, h: 0 };
|
|
386
|
+
}
|
|
387
|
+
const selfW = shapeWidth(shape);
|
|
388
|
+
const selfH = shapeHeight(shape);
|
|
389
|
+
const kids = childrenOf(id);
|
|
390
|
+
if (kids.length === 0) {
|
|
391
|
+
widthOf.set(id, selfW);
|
|
392
|
+
heightOf.set(id, selfH);
|
|
393
|
+
return { w: selfW, h: selfH };
|
|
394
|
+
}
|
|
395
|
+
let kidsW = 0;
|
|
396
|
+
let kidsH = 0;
|
|
397
|
+
for (let i = 0; i < kids.length; i++) {
|
|
398
|
+
const m = measure(req(kids[i]).id);
|
|
399
|
+
kidsW += m.w;
|
|
400
|
+
if (i > 0)
|
|
401
|
+
kidsW += nodesep;
|
|
402
|
+
if (m.h > kidsH)
|
|
403
|
+
kidsH = m.h;
|
|
404
|
+
}
|
|
405
|
+
const w = Math.max(selfW, kidsW);
|
|
406
|
+
const h = selfH + ranksep + kidsH;
|
|
407
|
+
widthOf.set(id, w);
|
|
408
|
+
heightOf.set(id, h);
|
|
409
|
+
return { w, h };
|
|
410
|
+
};
|
|
411
|
+
// Pass 1: measure every requested root.
|
|
412
|
+
for (const id of spec.shapeIds)
|
|
413
|
+
measure(id);
|
|
414
|
+
// Pass 2: place. Roots are laid out left-to-right under origin.y;
|
|
415
|
+
// each subtree centres its root above its children band.
|
|
416
|
+
const patches = [];
|
|
417
|
+
let working = scene;
|
|
418
|
+
const place = (id, leftX, topY) => {
|
|
419
|
+
const shape = getElement(working, id);
|
|
420
|
+
if (!shape)
|
|
421
|
+
return;
|
|
422
|
+
const m = measure(id);
|
|
423
|
+
const selfW = shapeWidth(shape);
|
|
424
|
+
const selfH = shapeHeight(shape);
|
|
425
|
+
const target = {
|
|
426
|
+
x: leftX + (m.w - selfW) / 2,
|
|
427
|
+
y: topY,
|
|
428
|
+
};
|
|
429
|
+
if (shape.position.x !== target.x || shape.position.y !== target.y) {
|
|
430
|
+
const r = updateElement(working, id, (s) => ({ ...s, position: target }));
|
|
431
|
+
working = r.scene;
|
|
432
|
+
patches.push(r.patch);
|
|
433
|
+
}
|
|
434
|
+
const kids = childrenOf(id);
|
|
435
|
+
if (kids.length === 0)
|
|
436
|
+
return;
|
|
437
|
+
let cursorX = leftX;
|
|
438
|
+
const kidsY = topY + selfH + ranksep;
|
|
439
|
+
for (const kid of kids) {
|
|
440
|
+
place(kid.id, cursorX, kidsY);
|
|
441
|
+
cursorX += measure(kid.id).w + nodesep;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
let rootsX = origin.x;
|
|
445
|
+
for (const id of spec.shapeIds) {
|
|
446
|
+
place(id, rootsX, origin.y);
|
|
447
|
+
rootsX += measure(id).w + nodesep;
|
|
448
|
+
}
|
|
449
|
+
if (patches.length === 0)
|
|
450
|
+
return null;
|
|
451
|
+
return batch(patches);
|
|
452
|
+
};
|
|
453
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAgB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAwB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,GAAG,GAAG,CAAI,CAAgB,EAAK,EAAE;IACrC,IAAI,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC3E,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF;;;;;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G,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;IACF,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IACtB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/B,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AnnotationId, LinkId, LayerId, ElementId, Vec2 } from "@oh-just-another/types";
|
|
2
|
+
import type { Annotation } from "./annotation.js";
|
|
3
|
+
import type { Link } from "./edge.js";
|
|
4
|
+
import type { Layer } from "./layer.js";
|
|
5
|
+
import type { Patch } from "./patch.js";
|
|
6
|
+
import { type Scene } from "./scene.js";
|
|
7
|
+
import type { Element } from "./shape.js";
|
|
8
|
+
import type { Viewport } from "./viewport.js";
|
|
9
|
+
/**
|
|
10
|
+
* Every mutating operation returns the pair `{ scene, patch }`. The patch is
|
|
11
|
+
* what history / collab persist; applying `invert(patch)` to the result returns
|
|
12
|
+
* exactly the input scene.
|
|
13
|
+
*/
|
|
14
|
+
export interface OperationResult {
|
|
15
|
+
readonly scene: Scene;
|
|
16
|
+
readonly patch: Patch;
|
|
17
|
+
}
|
|
18
|
+
export declare const addElement: (scene: Scene, shape: Element) => OperationResult;
|
|
19
|
+
export declare const removeElement: (scene: Scene, id: ElementId) => OperationResult;
|
|
20
|
+
export declare const updateElement: (scene: Scene, id: ElementId, update: (shape: Element) => Element) => OperationResult;
|
|
21
|
+
export declare const moveElement: (scene: Scene, id: ElementId, to: Vec2) => OperationResult;
|
|
22
|
+
export declare const addLink: (scene: Scene, edge: Link) => OperationResult;
|
|
23
|
+
export declare const removeLink: (scene: Scene, id: LinkId) => OperationResult;
|
|
24
|
+
export declare const updateLink: (scene: Scene, id: LinkId, update: (edge: Link) => Link) => OperationResult;
|
|
25
|
+
export declare const addLayer: (scene: Scene, layer: Layer) => OperationResult;
|
|
26
|
+
export declare const removeLayer: (scene: Scene, id: LayerId) => OperationResult;
|
|
27
|
+
export declare const updateLayer: (scene: Scene, id: LayerId, update: (layer: Layer) => Layer) => OperationResult;
|
|
28
|
+
export declare const addAnnotation: (scene: Scene, annotation: Annotation) => OperationResult;
|
|
29
|
+
export declare const removeAnnotation: (scene: Scene, id: AnnotationId) => OperationResult;
|
|
30
|
+
export declare const updateAnnotation: (scene: Scene, id: AnnotationId, update: (annotation: Annotation) => Annotation) => OperationResult;
|
|
31
|
+
export declare const setViewport: (scene: Scene, viewport: Viewport) => OperationResult;
|
|
32
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAS,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GA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