@affino/diagram-core 0.5.0 → 0.8.1
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/README.md +30 -0
- package/dist/DiagramEngine.d.ts +16 -2
- package/dist/DiagramEngine.d.ts.map +1 -1
- package/dist/DiagramEngine.js +644 -86
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction.d.ts +10 -1
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +165 -17
- package/dist/internal/DiagramSceneStore.d.ts.map +1 -1
- package/dist/internal/DiagramSceneStore.js +4 -0
- package/dist/internal/DiagramSpatialIndex.d.ts +4 -0
- package/dist/internal/DiagramSpatialIndex.d.ts.map +1 -1
- package/dist/internal/DiagramSpatialIndex.js +17 -0
- package/dist/internal/model.d.ts +4 -0
- package/dist/internal/model.d.ts.map +1 -1
- package/dist/types.d.ts +75 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DiagramEngine, createDiagramEngine, deserializeScene, serializeScene } from "./DiagramEngine.js";
|
|
1
|
+
export { DiagramEngine, createDiagramEngine, deserializeScene, deserializeDiagramDocument, serializeScene } from "./DiagramEngine.js";
|
|
2
2
|
export { DiagramInteractionController, createDiagramInteractionController } from "./interaction.js";
|
|
3
3
|
export { UniformGridIndex } from "./spatialIndex.js";
|
|
4
4
|
export { screenToWorld, worldToScreen, zoomViewportAt, zoomViewportCentered } from "./viewport.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACrI,OAAO,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,MAAM,kBAAkB,CAAA;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAClG,cAAc,eAAe,CAAA;AAC7B,mBAAmB,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DiagramEngine, createDiagramEngine, deserializeScene, serializeScene } from "./DiagramEngine.js";
|
|
1
|
+
export { DiagramEngine, createDiagramEngine, deserializeScene, deserializeDiagramDocument, serializeScene } from "./DiagramEngine.js";
|
|
2
2
|
export { DiagramInteractionController, createDiagramInteractionController } from "./interaction.js";
|
|
3
3
|
export { UniformGridIndex } from "./spatialIndex.js";
|
|
4
4
|
export { screenToWorld, worldToScreen, zoomViewportAt, zoomViewportCentered } from "./viewport.js";
|
package/dist/interaction.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DiagramEngine } from "./DiagramEngine.js";
|
|
2
|
-
import type { DiagramId, DiagramGeometry, DiagramInteractionSnapshot, DiagramInteractionTool, DiagramMarqueeMode, DiagramPointerEvent, DiagramResizeHandle } from "./types.js";
|
|
2
|
+
import type { DiagramId, DiagramGeometry, DiagramInteractionSnapOptions, DiagramInteractionSnapshot, DiagramInteractionTool, DiagramMarqueeMode, DiagramPointerEvent, DiagramResizeHandle } from "./types.js";
|
|
3
3
|
type ScheduleFrame = (callback: () => void) => void;
|
|
4
4
|
export type DiagramInteractionOptions = Readonly<{
|
|
5
5
|
scheduleFrame?: ScheduleFrame;
|
|
6
6
|
marqueeMode?: DiagramMarqueeMode;
|
|
7
|
+
snap?: DiagramInteractionSnapOptions;
|
|
7
8
|
}>;
|
|
8
9
|
export declare class DiagramInteractionController {
|
|
9
10
|
private readonly engine;
|
|
@@ -20,6 +21,12 @@ export declare class DiagramInteractionController {
|
|
|
20
21
|
private resizeStartRotation;
|
|
21
22
|
private resizePreview;
|
|
22
23
|
private resizePreviewEntries;
|
|
24
|
+
private edgeEndpointId;
|
|
25
|
+
private edgeEndpointKind;
|
|
26
|
+
private edgeEndpointStart;
|
|
27
|
+
private edgeEndpointPreview;
|
|
28
|
+
private dragSelectionIds;
|
|
29
|
+
private snapGuides;
|
|
23
30
|
private framePending;
|
|
24
31
|
private pendingMoveCount;
|
|
25
32
|
private commitCount;
|
|
@@ -27,10 +34,12 @@ export declare class DiagramInteractionController {
|
|
|
27
34
|
private gestureHistoryId;
|
|
28
35
|
private readonly scheduleFrame;
|
|
29
36
|
private readonly marqueeMode;
|
|
37
|
+
private readonly snapOptions;
|
|
30
38
|
constructor(engine: DiagramEngine, options?: DiagramInteractionOptions);
|
|
31
39
|
setTool(tool: DiagramInteractionTool): void;
|
|
32
40
|
pointerDown(event: DiagramPointerEvent): void;
|
|
33
41
|
beginResizeHandle(ownerId: DiagramId, handle: DiagramResizeHandle, event: DiagramPointerEvent): boolean;
|
|
42
|
+
beginEdgeEndpointHandle(ownerId: DiagramId, endpoint: "source" | "target", event: DiagramPointerEvent): boolean;
|
|
34
43
|
beginResizeSelectionHandle(handle: DiagramResizeHandle, event: DiagramPointerEvent): boolean;
|
|
35
44
|
pointerMove(event: DiagramPointerEvent): void;
|
|
36
45
|
pointerUp(event: DiagramPointerEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../src/interaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,0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3B,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,YAAY;CAuBrB;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,yBAA8B,GAAG,4BAA4B,CAE/I"}
|
package/dist/interaction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createEntityGeometry } from "./geometry.js";
|
|
1
|
+
import { createEntityGeometry, inflateRect, rectFromPoints as boundsFromPoints } from "./geometry.js";
|
|
2
2
|
export class DiagramInteractionController {
|
|
3
3
|
constructor(engine, options = {}) {
|
|
4
|
-
var _a, _b;
|
|
4
|
+
var _a, _b, _c;
|
|
5
5
|
Object.defineProperty(this, "engine", {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
configurable: true,
|
|
@@ -86,6 +86,42 @@ export class DiagramInteractionController {
|
|
|
86
86
|
writable: true,
|
|
87
87
|
value: Object.freeze([])
|
|
88
88
|
});
|
|
89
|
+
Object.defineProperty(this, "edgeEndpointId", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: null
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(this, "edgeEndpointKind", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
value: null
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(this, "edgeEndpointStart", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
configurable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
value: null
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(this, "edgeEndpointPreview", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
configurable: true,
|
|
110
|
+
writable: true,
|
|
111
|
+
value: null
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(this, "dragSelectionIds", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: true,
|
|
117
|
+
value: Object.freeze([])
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(this, "snapGuides", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
configurable: true,
|
|
122
|
+
writable: true,
|
|
123
|
+
value: Object.freeze([])
|
|
124
|
+
});
|
|
89
125
|
Object.defineProperty(this, "framePending", {
|
|
90
126
|
enumerable: true,
|
|
91
127
|
configurable: true,
|
|
@@ -128,31 +164,54 @@ export class DiagramInteractionController {
|
|
|
128
164
|
writable: true,
|
|
129
165
|
value: void 0
|
|
130
166
|
});
|
|
167
|
+
Object.defineProperty(this, "snapOptions", {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
configurable: true,
|
|
170
|
+
writable: true,
|
|
171
|
+
value: void 0
|
|
172
|
+
});
|
|
131
173
|
this.scheduleFrame = (_a = options.scheduleFrame) !== null && _a !== void 0 ? _a : defaultScheduleFrame;
|
|
132
174
|
this.marqueeMode = (_b = options.marqueeMode) !== null && _b !== void 0 ? _b : "contain";
|
|
175
|
+
this.snapOptions = (_c = options.snap) !== null && _c !== void 0 ? _c : {};
|
|
133
176
|
}
|
|
134
177
|
setTool(tool) {
|
|
135
178
|
this.cancel();
|
|
136
179
|
this.tool = tool;
|
|
137
180
|
}
|
|
138
181
|
pointerDown(event) {
|
|
182
|
+
var _a;
|
|
139
183
|
this.gestureGeneration += 1;
|
|
140
184
|
this.activePointer = event;
|
|
141
185
|
this.startPoint = event.point;
|
|
142
186
|
this.latestPoint = event.point;
|
|
143
187
|
this.previewDelta = null;
|
|
144
188
|
this.marquee = null;
|
|
189
|
+
this.snapGuides = Object.freeze([]);
|
|
145
190
|
if (this.tool === "select") {
|
|
146
191
|
const hit = this.engine.hitTest(event.point, { radius: 2 });
|
|
147
192
|
if (hit) {
|
|
193
|
+
let targetId = hit.id;
|
|
194
|
+
if (hit.kind === "port") {
|
|
195
|
+
const port = this.engine.getScene().entities.portsById.get(hit.id);
|
|
196
|
+
targetId = (_a = port === null || port === void 0 ? void 0 : port.nodeId) !== null && _a !== void 0 ? _a : "";
|
|
197
|
+
if (!targetId || !this.engine.canMove([targetId])) {
|
|
198
|
+
this.tool = "select";
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
148
202
|
const selection = this.engine.getScene().selection;
|
|
149
203
|
if (event.shiftKey) {
|
|
150
|
-
this.engine.dispatch({ type: "setSelection", selection: { ids: [
|
|
204
|
+
this.engine.dispatch({ type: "setSelection", selection: { ids: [targetId], primaryId: targetId }, mode: "toggle" });
|
|
151
205
|
}
|
|
152
|
-
else if (!selection.ids.includes(
|
|
153
|
-
this.engine.dispatch({ type: "setSelection", selection: { ids: [
|
|
206
|
+
else if (!selection.ids.includes(targetId)) {
|
|
207
|
+
this.engine.dispatch({ type: "setSelection", selection: { ids: [targetId], primaryId: targetId } });
|
|
154
208
|
}
|
|
155
|
-
|
|
209
|
+
const nextSelection = this.engine.getScene().selection;
|
|
210
|
+
this.dragSelectionIds = Object.freeze(nextSelection.ids.filter((id) => {
|
|
211
|
+
const geometry = this.engine.getGeometrySnapshot(id);
|
|
212
|
+
return geometry && geometry.kind !== "port" && this.engine.canMove([id]);
|
|
213
|
+
}));
|
|
214
|
+
this.tool = this.dragSelectionIds.length && nextSelection.ids.includes(targetId) ? "drag-selection" : "select";
|
|
156
215
|
}
|
|
157
216
|
else {
|
|
158
217
|
this.engine.dispatch({ type: "setSelection", selection: { ids: [], primaryId: null } });
|
|
@@ -177,6 +236,22 @@ export class DiagramInteractionController {
|
|
|
177
236
|
this.resizeStartRotation = (_b = geometry.rotation) !== null && _b !== void 0 ? _b : 0;
|
|
178
237
|
return true;
|
|
179
238
|
}
|
|
239
|
+
beginEdgeEndpointHandle(ownerId, endpoint, event) {
|
|
240
|
+
var _a;
|
|
241
|
+
const geometry = this.engine.getGeometrySnapshot(ownerId);
|
|
242
|
+
if (!geometry || geometry.kind !== "edge" || !((_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length))
|
|
243
|
+
return false;
|
|
244
|
+
const point = endpoint === "source" ? geometry.path[0] : geometry.path[geometry.path.length - 1];
|
|
245
|
+
this.cancel();
|
|
246
|
+
this.tool = "drag-edge-endpoint";
|
|
247
|
+
this.activePointer = event;
|
|
248
|
+
this.startPoint = event.point;
|
|
249
|
+
this.latestPoint = event.point;
|
|
250
|
+
this.edgeEndpointId = ownerId;
|
|
251
|
+
this.edgeEndpointKind = endpoint;
|
|
252
|
+
this.edgeEndpointStart = point;
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
180
255
|
beginResizeSelectionHandle(handle, event) {
|
|
181
256
|
const ids = this.engine.getScene().selection.ids.filter((id) => {
|
|
182
257
|
const geometry = this.engine.getGeometrySnapshot(id);
|
|
@@ -217,7 +292,7 @@ export class DiagramInteractionController {
|
|
|
217
292
|
}
|
|
218
293
|
}
|
|
219
294
|
pointerUp(event) {
|
|
220
|
-
var _a, _b, _c, _d;
|
|
295
|
+
var _a, _b, _c, _d, _e, _f;
|
|
221
296
|
if (!this.activePointer || this.activePointer.id !== event.id) {
|
|
222
297
|
return;
|
|
223
298
|
}
|
|
@@ -225,7 +300,7 @@ export class DiagramInteractionController {
|
|
|
225
300
|
this.flushPointerMove();
|
|
226
301
|
if (this.tool === "drag-selection" && this.previewDelta) {
|
|
227
302
|
const selection = this.engine.getScene().selection;
|
|
228
|
-
this.engine.dispatch({ type: "moveEntities", ids:
|
|
303
|
+
this.engine.dispatch({ type: "moveEntities", ids: this.dragSelectionIds, delta: this.previewDelta, historyKey: `drag:${(_a = selection.primaryId) !== null && _a !== void 0 ? _a : "selection"}:${++this.gestureHistoryId}` });
|
|
229
304
|
this.commitCount += 1;
|
|
230
305
|
}
|
|
231
306
|
if (this.tool === "pan" && this.previewDelta) {
|
|
@@ -237,13 +312,18 @@ export class DiagramInteractionController {
|
|
|
237
312
|
this.engine.dispatch({ type: "resizeEntities", entries: this.resizePreviewEntries, historyKey: `resize:${(_c = (_b = this.resizePreview) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "selection"}:${++this.gestureHistoryId}` });
|
|
238
313
|
this.commitCount += 1;
|
|
239
314
|
}
|
|
315
|
+
if (this.tool === "drag-edge-endpoint" && this.edgeEndpointId && this.edgeEndpointKind && this.edgeEndpointPreview
|
|
316
|
+
&& (this.edgeEndpointPreview.x !== ((_d = this.edgeEndpointStart) === null || _d === void 0 ? void 0 : _d.x) || this.edgeEndpointPreview.y !== ((_e = this.edgeEndpointStart) === null || _e === void 0 ? void 0 : _e.y))) {
|
|
317
|
+
this.engine.dispatch({ type: "moveEdgeEndpoint", id: this.edgeEndpointId, endpoint: this.edgeEndpointKind, point: this.edgeEndpointPreview });
|
|
318
|
+
this.commitCount += 1;
|
|
319
|
+
}
|
|
240
320
|
if (this.tool === "marquee" && this.marquee) {
|
|
241
321
|
const ids = this.getMarqueeSelectionIds(this.marquee);
|
|
242
|
-
this.engine.dispatch({ type: "setSelection", selection: { ids, primaryId: (
|
|
322
|
+
this.engine.dispatch({ type: "setSelection", selection: { ids, primaryId: (_f = ids[0]) !== null && _f !== void 0 ? _f : null }, mode: this.activePointer.shiftKey ? "add" : "replace" });
|
|
243
323
|
this.commitCount += 1;
|
|
244
324
|
}
|
|
245
325
|
this.clearGesture();
|
|
246
|
-
if (this.tool === "drag-selection" || this.tool === "marquee" || this.tool === "resize-selection") {
|
|
326
|
+
if (this.tool === "drag-selection" || this.tool === "marquee" || this.tool === "resize-selection" || this.tool === "drag-edge-endpoint") {
|
|
247
327
|
this.tool = "select";
|
|
248
328
|
}
|
|
249
329
|
}
|
|
@@ -253,19 +333,56 @@ export class DiagramInteractionController {
|
|
|
253
333
|
}
|
|
254
334
|
/** Returns the renderer-ready geometry for the active move preview. */
|
|
255
335
|
getPreviewGeometry(id) {
|
|
256
|
-
var _a, _b;
|
|
336
|
+
var _a, _b, _c, _d;
|
|
257
337
|
const geometry = this.engine.getGeometrySnapshot(id);
|
|
258
|
-
if (
|
|
338
|
+
if ((geometry === null || geometry === void 0 ? void 0 : geometry.kind) === "edge" && ((_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length) && this.edgeEndpointId === id && this.edgeEndpointKind && this.edgeEndpointPreview) {
|
|
339
|
+
const path = geometry.path.map((point, index) => {
|
|
340
|
+
const isEndpoint = this.edgeEndpointKind === "source" ? index === 0 : index === geometry.path.length - 1;
|
|
341
|
+
return isEndpoint ? this.edgeEndpointPreview : point;
|
|
342
|
+
});
|
|
343
|
+
const bounds = boundsFromPoints(path);
|
|
344
|
+
return Object.freeze({ ...geometry, path: Object.freeze(path), bounds, hitBounds: inflateRect(bounds, 6) });
|
|
345
|
+
}
|
|
346
|
+
if (!geometry || this.tool !== "drag-selection" || !this.previewDelta)
|
|
259
347
|
return geometry;
|
|
348
|
+
const scene = this.engine.getScene();
|
|
349
|
+
const edge = scene.entities.edgesById.get(id);
|
|
350
|
+
if (geometry.kind === "edge" && edge) {
|
|
351
|
+
const delta = this.previewDelta;
|
|
352
|
+
const moved = new Set(this.dragSelectionIds);
|
|
353
|
+
const endpointMoves = (endpoint) => {
|
|
354
|
+
var _a, _b;
|
|
355
|
+
return endpoint.kind === "point"
|
|
356
|
+
? moved.has(id)
|
|
357
|
+
: endpoint.kind === "node"
|
|
358
|
+
? moved.has(endpoint.nodeId)
|
|
359
|
+
: moved.has((_b = (_a = scene.entities.portsById.get(endpoint.portId)) === null || _a === void 0 ? void 0 : _a.nodeId) !== null && _b !== void 0 ? _b : "");
|
|
360
|
+
};
|
|
361
|
+
const path = (_b = geometry.path) === null || _b === void 0 ? void 0 : _b.map((point, index) => {
|
|
362
|
+
var _a, _b;
|
|
363
|
+
const isSource = index === 0;
|
|
364
|
+
const isTarget = index === ((_b = (_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1;
|
|
365
|
+
const move = isSource ? endpointMoves(edge.source) : isTarget ? endpointMoves(edge.target) : moved.has(id);
|
|
366
|
+
return move ? { x: point.x + delta.x, y: point.y + delta.y } : point;
|
|
367
|
+
});
|
|
368
|
+
if (path === null || path === void 0 ? void 0 : path.length) {
|
|
369
|
+
const changed = path.some((point, index) => { var _a; return point !== ((_a = geometry.path) === null || _a === void 0 ? void 0 : _a[index]); });
|
|
370
|
+
if (!changed)
|
|
371
|
+
return geometry;
|
|
372
|
+
const bounds = boundsFromPoints(path);
|
|
373
|
+
return Object.freeze({ ...geometry, path: Object.freeze(path), bounds, hitBounds: inflateRect(bounds, 6) });
|
|
374
|
+
}
|
|
260
375
|
}
|
|
376
|
+
if (!this.dragSelectionIds.includes(id))
|
|
377
|
+
return geometry;
|
|
261
378
|
const move = (point) => ({ x: point.x + this.previewDelta.x, y: point.y + this.previewDelta.y });
|
|
262
379
|
return Object.freeze({
|
|
263
380
|
...geometry,
|
|
264
381
|
bounds: { ...geometry.bounds, x: geometry.bounds.x + this.previewDelta.x, y: geometry.bounds.y + this.previewDelta.y },
|
|
265
382
|
hitBounds: { ...geometry.hitBounds, x: geometry.hitBounds.x + this.previewDelta.x, y: geometry.hitBounds.y + this.previewDelta.y },
|
|
266
383
|
unrotatedBounds: geometry.unrotatedBounds ? { ...geometry.unrotatedBounds, x: geometry.unrotatedBounds.x + this.previewDelta.x, y: geometry.unrotatedBounds.y + this.previewDelta.y } : undefined,
|
|
267
|
-
corners: (
|
|
268
|
-
path: (
|
|
384
|
+
corners: (_c = geometry.corners) === null || _c === void 0 ? void 0 : _c.map(move),
|
|
385
|
+
path: (_d = geometry.path) === null || _d === void 0 ? void 0 : _d.map(move),
|
|
269
386
|
point: geometry.point ? move(geometry.point) : undefined,
|
|
270
387
|
});
|
|
271
388
|
}
|
|
@@ -276,6 +393,10 @@ export class DiagramInteractionController {
|
|
|
276
393
|
previewDelta: this.previewDelta,
|
|
277
394
|
resizePreview: this.resizePreview,
|
|
278
395
|
resizePreviewEntries: this.resizePreviewEntries,
|
|
396
|
+
edgeEndpointPreview: this.edgeEndpointId && this.edgeEndpointKind && this.edgeEndpointPreview
|
|
397
|
+
? { id: this.edgeEndpointId, endpoint: this.edgeEndpointKind, point: this.edgeEndpointPreview }
|
|
398
|
+
: null,
|
|
399
|
+
snapGuides: this.snapGuides,
|
|
279
400
|
marquee: this.marquee,
|
|
280
401
|
};
|
|
281
402
|
}
|
|
@@ -286,19 +407,40 @@ export class DiagramInteractionController {
|
|
|
286
407
|
return this.commitCount;
|
|
287
408
|
}
|
|
288
409
|
flushPointerMove() {
|
|
289
|
-
var _a;
|
|
410
|
+
var _a, _b, _c, _d, _e;
|
|
290
411
|
this.framePending = false;
|
|
291
412
|
if (!this.startPoint || !this.latestPoint) {
|
|
292
413
|
return;
|
|
293
414
|
}
|
|
294
415
|
const delta = { x: this.latestPoint.x - this.startPoint.x, y: this.latestPoint.y - this.startPoint.y };
|
|
295
416
|
if (this.tool === "drag-selection" || this.tool === "pan") {
|
|
296
|
-
this.
|
|
417
|
+
if (this.tool === "drag-selection" && this.snapOptions.enabled !== false) {
|
|
418
|
+
const viewport = this.engine.getScene().viewport;
|
|
419
|
+
const zoom = viewport.zoom > 0 ? viewport.zoom : 1;
|
|
420
|
+
const selection = this.engine.getScene().selection;
|
|
421
|
+
const snapped = this.engine.snapTranslation({ ...selection, ids: this.dragSelectionIds, primaryId: this.dragSelectionIds.includes((_a = selection.primaryId) !== null && _a !== void 0 ? _a : "") ? selection.primaryId : (_b = this.dragSelectionIds[0]) !== null && _b !== void 0 ? _b : null }, delta, {
|
|
422
|
+
radius: ((_c = this.snapOptions.tolerancePx) !== null && _c !== void 0 ? _c : 6) / zoom,
|
|
423
|
+
gridSize: this.snapOptions.gridSize,
|
|
424
|
+
snapToPorts: this.snapOptions.snapToPorts,
|
|
425
|
+
snapToAlignment: this.snapOptions.snapToAlignment,
|
|
426
|
+
snapToEqualSpacing: (_d = this.snapOptions.snapToEqualSpacing) !== null && _d !== void 0 ? _d : true,
|
|
427
|
+
});
|
|
428
|
+
this.previewDelta = snapped.point;
|
|
429
|
+
this.snapGuides = snapped.guides;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this.previewDelta = delta;
|
|
433
|
+
this.snapGuides = Object.freeze([]);
|
|
434
|
+
}
|
|
297
435
|
return;
|
|
298
436
|
}
|
|
299
437
|
if (this.tool === "resize-selection") {
|
|
300
438
|
this.resizePreviewEntries = this.createResizePreviewEntries(delta);
|
|
301
|
-
this.resizePreview = (
|
|
439
|
+
this.resizePreview = (_e = this.resizePreviewEntries[0]) !== null && _e !== void 0 ? _e : null;
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (this.tool === "drag-edge-endpoint") {
|
|
443
|
+
this.edgeEndpointPreview = this.latestPoint;
|
|
302
444
|
return;
|
|
303
445
|
}
|
|
304
446
|
if (this.tool === "marquee") {
|
|
@@ -402,6 +544,12 @@ export class DiagramInteractionController {
|
|
|
402
544
|
this.resizeStartRotation = 0;
|
|
403
545
|
this.resizePreview = null;
|
|
404
546
|
this.resizePreviewEntries = Object.freeze([]);
|
|
547
|
+
this.dragSelectionIds = Object.freeze([]);
|
|
548
|
+
this.snapGuides = Object.freeze([]);
|
|
549
|
+
this.edgeEndpointId = null;
|
|
550
|
+
this.edgeEndpointKind = null;
|
|
551
|
+
this.edgeEndpointStart = null;
|
|
552
|
+
this.edgeEndpointPreview = null;
|
|
405
553
|
this.framePending = false;
|
|
406
554
|
this.pendingMoveCount = 0;
|
|
407
555
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramSceneStore.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramSceneStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAoB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEjI,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAA;AAIhE,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiC;IACnE,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"DiagramSceneStore.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramSceneStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAoB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEjI,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAA;AAIhE,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiC;IACnE,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,UAAU,CAKjB;gBAEW,YAAY,GAAE,iBAAsB;IAKhD,WAAW,IAAI,YAAY;IAI3B,aAAa,IAAI,aAAa;IAI9B,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI;IAazF,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG;QAAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE;IAUnE,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,iBAAiB;CAO1B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,CA8B3E"}
|
|
@@ -32,6 +32,7 @@ export class DiagramSceneStore {
|
|
|
32
32
|
writable: true,
|
|
33
33
|
value: {
|
|
34
34
|
revision: 0,
|
|
35
|
+
documentRevision: 0,
|
|
35
36
|
changedIds: createReadonlySet([]),
|
|
36
37
|
invalidatedIds: createReadonlySet([]),
|
|
37
38
|
}
|
|
@@ -49,6 +50,7 @@ export class DiagramSceneStore {
|
|
|
49
50
|
this.snapshot = this.createSnapshot(changedIds);
|
|
50
51
|
this.lastChange = {
|
|
51
52
|
revision: this.state.revision,
|
|
53
|
+
documentRevision: this.state.documentRevision,
|
|
52
54
|
changedIds: createReadonlySet(changedIds),
|
|
53
55
|
invalidatedIds: createReadonlySet(invalidatedIds),
|
|
54
56
|
};
|
|
@@ -120,6 +122,8 @@ export function createInternalState(input) {
|
|
|
120
122
|
selection: normalizeSelection(input.selection),
|
|
121
123
|
viewport: { ...DEFAULT_VIEWPORT, ...input.viewport },
|
|
122
124
|
revision: 0,
|
|
125
|
+
documentRevision: 0,
|
|
126
|
+
orderRevision: 0,
|
|
123
127
|
versions: new Map(ids.map((id) => [id, 0])),
|
|
124
128
|
};
|
|
125
129
|
}
|
|
@@ -4,6 +4,10 @@ export declare class DiagramSpatialIndex {
|
|
|
4
4
|
private hitBoundsIndex;
|
|
5
5
|
private portIndex;
|
|
6
6
|
private dirty;
|
|
7
|
+
private rebuildCount;
|
|
8
|
+
private updateCount;
|
|
9
|
+
getRebuildCount(): number;
|
|
10
|
+
getUpdateCount(): number;
|
|
7
11
|
markDirty(): void;
|
|
8
12
|
ensure(rebuild: () => ReadonlyArray<DiagramGeometry>): void;
|
|
9
13
|
update(geometries: ReadonlyArray<DiagramGeometry>, removedIds?: ReadonlyArray<DiagramId>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramSpatialIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE1E,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,KAAK,CAAO;
|
|
1
|
+
{"version":3,"file":"DiagramSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramSpatialIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE1E,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,WAAW,CAAI;IAEvB,eAAe,IAAI,MAAM;IACzB,cAAc,IAAI,MAAM;IAExB,SAAS,IAAI,IAAI;IAIjB,MAAM,CAAC,OAAO,EAAE,MAAM,aAAa,CAAC,eAAe,CAAC,GAAG,IAAI;IAY3D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,UAAU,GAAE,aAAa,CAAC,SAAS,CAAM,GAAG,IAAI;IAenG,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE;IAI9C,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE;IAI1C,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE;CAG7C"}
|
|
@@ -25,7 +25,21 @@ export class DiagramSpatialIndex {
|
|
|
25
25
|
writable: true,
|
|
26
26
|
value: true
|
|
27
27
|
});
|
|
28
|
+
Object.defineProperty(this, "rebuildCount", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: 0
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "updateCount", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: 0
|
|
39
|
+
});
|
|
28
40
|
}
|
|
41
|
+
getRebuildCount() { return this.rebuildCount; }
|
|
42
|
+
getUpdateCount() { return this.updateCount; }
|
|
29
43
|
markDirty() {
|
|
30
44
|
this.dirty = true;
|
|
31
45
|
}
|
|
@@ -37,6 +51,7 @@ export class DiagramSpatialIndex {
|
|
|
37
51
|
this.visualBoundsIndex.rebuild(geometries);
|
|
38
52
|
this.hitBoundsIndex.rebuild(geometries, true);
|
|
39
53
|
this.portIndex.rebuild(geometries.filter((geometry) => geometry.kind === "port"), true);
|
|
54
|
+
this.rebuildCount += 1;
|
|
40
55
|
this.dirty = false;
|
|
41
56
|
}
|
|
42
57
|
update(geometries, removedIds = []) {
|
|
@@ -44,12 +59,14 @@ export class DiagramSpatialIndex {
|
|
|
44
59
|
this.visualBoundsIndex.rebuild(geometries);
|
|
45
60
|
this.hitBoundsIndex.rebuild(geometries, true);
|
|
46
61
|
this.portIndex.rebuild(geometries.filter((geometry) => geometry.kind === "port"), true);
|
|
62
|
+
this.rebuildCount += 1;
|
|
47
63
|
this.dirty = false;
|
|
48
64
|
return;
|
|
49
65
|
}
|
|
50
66
|
this.visualBoundsIndex.update(geometries, false, removedIds);
|
|
51
67
|
this.hitBoundsIndex.update(geometries, true, removedIds);
|
|
52
68
|
this.portIndex.update(geometries.filter((geometry) => geometry.kind === "port"), true, removedIds);
|
|
69
|
+
this.updateCount += 1;
|
|
53
70
|
}
|
|
54
71
|
queryVisible(bounds) {
|
|
55
72
|
return this.visualBoundsIndex.query(bounds);
|
package/dist/internal/model.d.ts
CHANGED
|
@@ -18,12 +18,16 @@ export type InternalState = {
|
|
|
18
18
|
selection: DiagramSelection;
|
|
19
19
|
viewport: DiagramViewport;
|
|
20
20
|
revision: number;
|
|
21
|
+
documentRevision: number;
|
|
22
|
+
orderRevision: number;
|
|
21
23
|
versions: Map<DiagramId, number>;
|
|
22
24
|
};
|
|
23
25
|
export type Patch = {
|
|
24
26
|
apply: (state: InternalState) => Set<DiagramId>;
|
|
25
27
|
inverse: Patch;
|
|
26
28
|
steps?: ReadonlyArray<Patch>;
|
|
29
|
+
documentChanged?: boolean;
|
|
30
|
+
orderChanged?: boolean;
|
|
27
31
|
};
|
|
28
32
|
export type HistoryEnt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AAC,SAAS,CAAC,CAAA;IAC/C,OAAO,EAAE,KAAK,CAAA;IACd,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,KAAK,CAAA;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,eAAe,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAC1B,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,eAA6E,CAAA;AAC5G,eAAO,MAAM,eAAe,EAAE,gBAA6E,CAAA;AAE3G,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -133,6 +133,9 @@ export type DiagramDiagnostics = Readonly<{
|
|
|
133
133
|
entityQueryCount: number;
|
|
134
134
|
hitTestCount: number;
|
|
135
135
|
geometryRecomputeCount: number;
|
|
136
|
+
spatialIndexRebuildCount: number;
|
|
137
|
+
spatialIndexUpdateCount: number;
|
|
138
|
+
dependencyIndexRebuildCount: number;
|
|
136
139
|
lastCommandMs: number;
|
|
137
140
|
undoDepth: number;
|
|
138
141
|
redoDepth: number;
|
|
@@ -175,6 +178,15 @@ export type SerializedDiagramScene = Readonly<{
|
|
|
175
178
|
selection: DiagramSelection;
|
|
176
179
|
viewport: DiagramViewport;
|
|
177
180
|
}>;
|
|
181
|
+
export type DiagramDocument = Readonly<{
|
|
182
|
+
format: "affino-diagram";
|
|
183
|
+
version: 1;
|
|
184
|
+
content: Readonly<Omit<SerializedDiagramScene, "selection" | "viewport">>;
|
|
185
|
+
view?: Readonly<{
|
|
186
|
+
viewport?: DiagramViewport;
|
|
187
|
+
selection?: DiagramSelection;
|
|
188
|
+
}>;
|
|
189
|
+
}>;
|
|
178
190
|
export type DiagramGeometry = Readonly<{
|
|
179
191
|
id: DiagramId;
|
|
180
192
|
kind: DiagramEntityKind;
|
|
@@ -197,11 +209,30 @@ export type DiagramHit = Readonly<{
|
|
|
197
209
|
}>;
|
|
198
210
|
export type DiagramChange = Readonly<{
|
|
199
211
|
revision: number;
|
|
212
|
+
documentRevision: number;
|
|
200
213
|
changedIds: ReadonlySet<DiagramId>;
|
|
201
214
|
invalidatedIds: ReadonlySet<DiagramId>;
|
|
202
215
|
}>;
|
|
203
216
|
export type DiagramSubscriber = (scene: DiagramScene, change: DiagramChange) => void;
|
|
204
217
|
export type DiagramCommand = Readonly<{
|
|
218
|
+
type: "createNode";
|
|
219
|
+
node: DiagramNode;
|
|
220
|
+
historyKey?: string;
|
|
221
|
+
}> | Readonly<{
|
|
222
|
+
type: "createPort";
|
|
223
|
+
port: DiagramPort;
|
|
224
|
+
historyKey?: string;
|
|
225
|
+
}> | Readonly<{
|
|
226
|
+
type: "deleteEntities";
|
|
227
|
+
ids: ReadonlyArray<DiagramId>;
|
|
228
|
+
historyKey?: string;
|
|
229
|
+
}> | Readonly<{
|
|
230
|
+
type: "reconnectEdgeEndpoint";
|
|
231
|
+
id: DiagramId;
|
|
232
|
+
endpoint: "source" | "target";
|
|
233
|
+
connection: DiagramEdgeEndpoint;
|
|
234
|
+
historyKey?: string;
|
|
235
|
+
}> | Readonly<{
|
|
205
236
|
type: "updateEntities";
|
|
206
237
|
updates: ReadonlyArray<DiagramEntityUpdate>;
|
|
207
238
|
historyKey?: string;
|
|
@@ -327,7 +358,20 @@ export type DiagramCommandResult = Readonly<{
|
|
|
327
358
|
changed: boolean;
|
|
328
359
|
revision: number;
|
|
329
360
|
}>;
|
|
330
|
-
export type
|
|
361
|
+
export type DiagramBatchFailureReason = "revision-mismatch" | "invalid-command" | "unsupported-command";
|
|
362
|
+
export type DiagramBatchResult = Readonly<{
|
|
363
|
+
ok: boolean;
|
|
364
|
+
changed: boolean;
|
|
365
|
+
revision: number;
|
|
366
|
+
documentRevision: number;
|
|
367
|
+
failedCommandIndex: number | null;
|
|
368
|
+
reason: DiagramBatchFailureReason | null;
|
|
369
|
+
affectedIds: ReadonlyArray<DiagramId>;
|
|
370
|
+
}>;
|
|
371
|
+
export type DiagramBatchOptions = Readonly<{
|
|
372
|
+
expectedRevision?: number;
|
|
373
|
+
}>;
|
|
374
|
+
export type DiagramInteractionTool = "pan" | "select" | "marquee" | "drag-selection" | "resize-selection" | "drag-edge-endpoint" | "connect-edge" | "edit-text";
|
|
331
375
|
export type DiagramResizeHandle = "nw" | "ne" | "se" | "sw";
|
|
332
376
|
export type DiagramPointerEvent = Readonly<{
|
|
333
377
|
id: number;
|
|
@@ -341,11 +385,21 @@ export type DiagramInteractionSnapshot = Readonly<{
|
|
|
341
385
|
previewDelta: DiagramPoint | null;
|
|
342
386
|
resizePreview: DiagramResizeEntry | null;
|
|
343
387
|
resizePreviewEntries: ReadonlyArray<DiagramResizeEntry>;
|
|
388
|
+
edgeEndpointPreview: DiagramEdgeEndpointPreview | null;
|
|
389
|
+
snapGuides: ReadonlyArray<DiagramSnapGuide>;
|
|
344
390
|
marquee: DiagramRect | null;
|
|
345
391
|
}>;
|
|
392
|
+
export type DiagramEdgeEndpointPreview = Readonly<{
|
|
393
|
+
id: DiagramId;
|
|
394
|
+
endpoint: "source" | "target";
|
|
395
|
+
point: DiagramPoint;
|
|
396
|
+
}>;
|
|
346
397
|
export type DiagramSnapContext = Readonly<{
|
|
347
398
|
gridSize?: number;
|
|
348
399
|
radius?: number;
|
|
400
|
+
snapToPorts?: boolean;
|
|
401
|
+
snapToAlignment?: boolean;
|
|
402
|
+
snapToEqualSpacing?: boolean;
|
|
349
403
|
excludeIds?: ReadonlySet<DiagramId>;
|
|
350
404
|
angleConstraint?: number;
|
|
351
405
|
custom?: (point: DiagramPoint) => DiagramPoint | null;
|
|
@@ -353,6 +407,25 @@ export type DiagramSnapContext = Readonly<{
|
|
|
353
407
|
export type DiagramSnapResult = Readonly<{
|
|
354
408
|
point: DiagramPoint;
|
|
355
409
|
snapped: boolean;
|
|
356
|
-
source: "grid" | "port" | "alignment" | "angle" | "custom" | null;
|
|
410
|
+
source: "grid" | "port" | "alignment" | "equal-spacing" | "angle" | "custom" | null;
|
|
411
|
+
}>;
|
|
412
|
+
export type DiagramTranslationSnapResult = DiagramSnapResult & Readonly<{
|
|
413
|
+
guides: ReadonlyArray<DiagramSnapGuide>;
|
|
414
|
+
}>;
|
|
415
|
+
export type DiagramSnapGuide = Readonly<{
|
|
416
|
+
kind: "alignment" | "equal-spacing";
|
|
417
|
+
axis: "x" | "y";
|
|
418
|
+
start: DiagramPoint;
|
|
419
|
+
end: DiagramPoint;
|
|
420
|
+
}>;
|
|
421
|
+
export type DiagramInteractionSnapOptions = Readonly<{
|
|
422
|
+
enabled?: boolean;
|
|
423
|
+
/** Pointer tolerance in screen pixels. Converted to world units using the current zoom. */
|
|
424
|
+
tolerancePx?: number;
|
|
425
|
+
/** Grid spacing in world units. Omit to disable grid snapping. */
|
|
426
|
+
gridSize?: number;
|
|
427
|
+
snapToPorts?: boolean;
|
|
428
|
+
snapToAlignment?: boolean;
|
|
429
|
+
snapToEqualSpacing?: boolean;
|
|
357
430
|
}>;
|
|
358
431
|
//# sourceMappingURL=types.d.ts.map
|