@stocksharp/diagram 0.2.3 → 0.3.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.
Files changed (67) hide show
  1. package/dist/esm/canvas-renderer.js +28 -22
  2. package/dist/esm/canvas-renderer.js.map +1 -1
  3. package/dist/esm/core/action-registry.js +24 -0
  4. package/dist/esm/core/action-registry.js.map +1 -1
  5. package/dist/esm/core/document.js +85 -28
  6. package/dist/esm/core/document.js.map +1 -1
  7. package/dist/esm/core/json.js +17 -0
  8. package/dist/esm/core/json.js.map +1 -0
  9. package/dist/esm/core/model.js +4 -0
  10. package/dist/esm/core/model.js.map +1 -1
  11. package/dist/esm/core/state.js +16 -2
  12. package/dist/esm/core/state.js.map +1 -1
  13. package/dist/esm/diagram/catalog.js +17 -5
  14. package/dist/esm/diagram/catalog.js.map +1 -1
  15. package/dist/esm/diagram/event-emitter.js +10 -0
  16. package/dist/esm/diagram/event-emitter.js.map +1 -1
  17. package/dist/esm/diagram/stocksharp-diagram.js +58 -56
  18. package/dist/esm/diagram/stocksharp-diagram.js.map +1 -1
  19. package/dist/esm/diagram/types.js +2 -1
  20. package/dist/esm/diagram/types.js.map +1 -1
  21. package/dist/esm/embed.js +121 -38
  22. package/dist/esm/embed.js.map +1 -1
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/ssdiagram.js +297 -145
  26. package/dist/ssdiagram.js.map +4 -4
  27. package/dist/types/canvas-renderer.d.ts +3 -5
  28. package/dist/types/canvas-renderer.d.ts.map +1 -1
  29. package/dist/types/core/action-registry.d.ts +7 -0
  30. package/dist/types/core/action-registry.d.ts.map +1 -1
  31. package/dist/types/core/document.d.ts.map +1 -1
  32. package/dist/types/core/json.d.ts +11 -0
  33. package/dist/types/core/json.d.ts.map +1 -0
  34. package/dist/types/core/model.d.ts +10 -1
  35. package/dist/types/core/model.d.ts.map +1 -1
  36. package/dist/types/core/state.d.ts +24 -1
  37. package/dist/types/core/state.d.ts.map +1 -1
  38. package/dist/types/diagram/api.d.ts +6 -6
  39. package/dist/types/diagram/api.d.ts.map +1 -1
  40. package/dist/types/diagram/catalog.d.ts +2 -1
  41. package/dist/types/diagram/catalog.d.ts.map +1 -1
  42. package/dist/types/diagram/event-emitter.d.ts +6 -1
  43. package/dist/types/diagram/event-emitter.d.ts.map +1 -1
  44. package/dist/types/diagram/palette.d.ts +1 -1
  45. package/dist/types/diagram/palette.d.ts.map +1 -1
  46. package/dist/types/diagram/stocksharp-diagram.d.ts +29 -22
  47. package/dist/types/diagram/stocksharp-diagram.d.ts.map +1 -1
  48. package/dist/types/diagram/types.d.ts +4 -4
  49. package/dist/types/diagram/types.d.ts.map +1 -1
  50. package/dist/types/embed.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +3 -3
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/package.json +2 -2
  54. package/src/canvas-renderer.ts +26 -24
  55. package/src/core/action-registry.ts +25 -0
  56. package/src/core/document.ts +91 -31
  57. package/src/core/json.ts +16 -0
  58. package/src/core/model.ts +14 -1
  59. package/src/core/state.ts +41 -3
  60. package/src/diagram/api.ts +6 -5
  61. package/src/diagram/catalog.ts +18 -6
  62. package/src/diagram/event-emitter.ts +12 -1
  63. package/src/diagram/palette.ts +1 -1
  64. package/src/diagram/stocksharp-diagram.ts +79 -76
  65. package/src/diagram/types.ts +6 -5
  66. package/src/embed.ts +140 -39
  67. package/src/index.ts +4 -0
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from './event-emitter.js';
2
2
  import { Node, NodeInit, PortType, PortTypeInit } from './types.js';
3
3
 
4
- export interface CatalogEvents extends Record<string, unknown> {
4
+ export interface CatalogEvents {
5
5
  portTypesChanged: PortType[];
6
6
  nodeTypesChanged: Node[];
7
7
  }
@@ -35,21 +35,33 @@ export class StockSharpCatalog extends EventEmitter<CatalogEvents> {
35
35
  // imported node ("Element type is missing from the palette"). Node.id
36
36
  // keeps its original casing so save/load round-trips unchanged.
37
37
  addNodeType(node: Node | NodeInit): void {
38
- const n = node instanceof Node ? node : new Node(node);
38
+ // Copied on the way in as well as on the way out: otherwise the caller
39
+ // keeps a handle on the stored definition and can edit it afterwards.
40
+ // The clone covers the init branch too -- Node's constructor keeps the
41
+ // caller's Port instances and parameters array as they are.
42
+ const n = (node instanceof Node ? node : new Node(node)).clone();
39
43
  this.nodeTypes.set(n.id.toLowerCase(), n);
40
- this.emit('nodeTypesChanged', this.getNodeTypes());
44
+ this.emitNodeTypesChanged();
41
45
  }
42
46
 
43
47
  removeNodeType(id: string): void {
44
48
  this.nodeTypes.delete(id.toLowerCase());
45
- this.emit('nodeTypesChanged', this.getNodeTypes());
49
+ this.emitNodeTypesChanged();
46
50
  }
47
51
 
48
52
  getNodeType(id: string): Node | null {
49
- return this.nodeTypes.get(id.toLowerCase()) ?? null;
53
+ return this.nodeTypes.get(id.toLowerCase())?.clone() ?? null;
50
54
  }
51
55
 
52
56
  getNodeTypes(): Node[] {
53
- return Array.from(this.nodeTypes.values());
57
+ return Array.from(this.nodeTypes.values(), (node) => node.clone());
58
+ }
59
+
60
+ // Node definitions are mutable, so the payload has to be a copy of each one.
61
+ // Building a catalog is a loop of addNodeType calls, which would make that
62
+ // quadratic; skipping it while nobody listens keeps catalog construction --
63
+ // where no subscriber exists yet -- as cheap as it was.
64
+ private emitNodeTypesChanged(): void {
65
+ if (this.hasHandlers('nodeTypesChanged')) this.emit('nodeTypesChanged', this.getNodeTypes());
54
66
  }
55
67
  }
@@ -1,6 +1,9 @@
1
1
  export type EventHandler<T> = (payload: T) => void;
2
2
 
3
- export class EventEmitter<TEvents extends Record<string, unknown>> {
3
+ // TEvents is constrained to object rather than Record<string, unknown>: the
4
+ // latter forces every event map to carry a string index signature, which
5
+ // collapses keyof TEvents to string and lets any misspelled name compile.
6
+ export class EventEmitter<TEvents extends object> {
4
7
  private readonly handlers = new Map<keyof TEvents, Set<EventHandler<unknown>>>();
5
8
 
6
9
  on<K extends keyof TEvents>(event: K, handler: EventHandler<TEvents[K]>): () => void {
@@ -38,6 +41,14 @@ export class EventEmitter<TEvents extends Record<string, unknown>> {
38
41
  }
39
42
  }
40
43
 
44
+ /**
45
+ * Whether anyone is listening. Lets a subject skip building a payload that
46
+ * is expensive to produce and that nothing would read.
47
+ */
48
+ protected hasHandlers<K extends keyof TEvents>(event: K): boolean {
49
+ return (this.handlers.get(event)?.size ?? 0) > 0;
50
+ }
51
+
41
52
  protected clearEventHandlers(): void {
42
53
  this.handlers.clear();
43
54
  }
@@ -22,7 +22,7 @@ export interface PaletteContextMenuPayload extends PaletteNodePayload {
22
22
  y: number;
23
23
  }
24
24
 
25
- export interface PaletteEvents extends Record<string, unknown> {
25
+ export interface PaletteEvents {
26
26
  selectionChanged: PaletteSelectionChangedPayload;
27
27
  nodeActivated: PaletteNodePayload;
28
28
  contextMenuRequested: PaletteContextMenuPayload;
@@ -6,7 +6,7 @@ import {
6
6
  parseDiagramViewState,
7
7
  serializeDiagramViewState,
8
8
  } from '../core/view-state.js';
9
- import type { DiagramDocument } from '../core/model.js';
9
+ import type { DiagramDocument, PortDynamicMode } from '../core/model.js';
10
10
  import { DiagramActionRegistry } from '../core/action-registry.js';
11
11
  import type {
12
12
  DiagramGlobalErrorKind,
@@ -14,6 +14,7 @@ import type {
14
14
  DiagramPortRuntimeState,
15
15
  DiagramRuntimeState,
16
16
  DiagramSelection,
17
+ DiagramSnapshot,
17
18
  DiagramViewState,
18
19
  } from '../core/state.js';
19
20
  import {
@@ -77,7 +78,6 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
77
78
  private fullscreen = false;
78
79
  private fullscreenButtonVisible = true;
79
80
  private fullscreenLabels: DiagramFullscreenLabels = { enter: 'Enter fullscreen', exit: 'Exit fullscreen' };
80
- private linkValidator: LinkValidator | null = null;
81
81
  private readonly contextActions = new DiagramActionRegistry<ContextCommand, ContextActionContext>();
82
82
 
83
83
  constructor(options: DiagramOptions) {
@@ -105,7 +105,6 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
105
105
  }
106
106
 
107
107
  setLinkValidator(validator: LinkValidator | null): void {
108
- this.linkValidator = validator;
109
108
  this.canvas.setLinkValidator(validator === null ? null : ({ fromNode, fromPort, toNode, toPort }) => validator({
110
109
  fromNode: this.fromCanvasNode(fromNode),
111
110
  fromPort: this.fromCanvasPort(fromPort),
@@ -178,7 +177,7 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
178
177
  this.canvas.setGridSnap(enabled, size);
179
178
  }
180
179
 
181
- getGridSnap(): DiagramGridSettings {
180
+ getGridSnap(): DiagramSnapshot<DiagramGridSettings> {
182
181
  return this.canvas.getGridSnap();
183
182
  }
184
183
 
@@ -202,29 +201,33 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
202
201
  this.canvas.removeLink(this.toCanvasLink(link));
203
202
  }
204
203
 
205
- addPort(nodeId: string, direction: PortDirection, port: Port): void {
206
- this.canvas.addPort(nodeId, direction, this.toCanvasPort(port));
204
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
205
+ addPort(nodeId: string, direction: PortDirection, port: Port): boolean {
206
+ return this.canvas.addPort(nodeId, direction, this.toCanvasPort(port));
207
207
  }
208
208
 
209
- removePort(nodeId: string, direction: PortDirection, portId: string): void {
210
- this.canvas.removePort(nodeId, direction, portId);
209
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
210
+ removePort(nodeId: string, direction: PortDirection, portId: string): boolean {
211
+ return this.canvas.removePort(nodeId, direction, portId);
211
212
  }
212
213
 
213
- updatePortType(nodeId: string, direction: PortDirection, portId: string, type: string): void {
214
- this.canvas.updatePortType(nodeId, direction, portId, type);
214
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
215
+ updatePortType(nodeId: string, direction: PortDirection, portId: string, type: string): boolean {
216
+ return this.canvas.updatePortType(nodeId, direction, portId, type);
215
217
  }
216
218
 
217
219
  updatePort(nodeId: string, direction: PortDirection, portId: string, patch: PortUpdate): boolean {
218
220
  return this.canvas.updatePort(nodeId, direction, portId, patch);
219
221
  }
220
222
 
223
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
221
224
  setNodePorts(
222
225
  nodeId: string,
223
- inPorts: ReadonlyArray<{ key: string; name: string; description: string; type: string; maxLinks: number; availableTypes?: string[]; isDynamic?: boolean; dynamicMode?: string }>,
224
- outPorts: ReadonlyArray<{ key: string; name: string; description: string; type: string; maxLinks: number; availableTypes?: string[]; isDynamic?: boolean; dynamicMode?: string }>,
225
- ): void {
226
+ inPorts: ReadonlyArray<{ key: string; name: string; description: string; type: string; maxLinks: number; availableTypes?: string[]; isDynamic?: boolean; dynamicMode?: PortDynamicMode }>,
227
+ outPorts: ReadonlyArray<{ key: string; name: string; description: string; type: string; maxLinks: number; availableTypes?: string[]; isDynamic?: boolean; dynamicMode?: PortDynamicMode }>,
228
+ ): boolean {
226
229
  const current = this.canvas.findNode(nodeId);
227
- if (current === undefined) return;
230
+ if (current === undefined) return false;
228
231
  const convert = (port: typeof inPorts[number]): CanvasPortInit => ({
229
232
  id: port.key,
230
233
  name: port.name,
@@ -243,15 +246,17 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
243
246
  for (const sibling of current.outPorts.filter((port) => port.isSibling)) {
244
247
  if (!nextOut.some((port) => port.id === sibling.id)) nextOut.push(sibling.toInit());
245
248
  }
246
- this.canvas.setNodePorts(nodeId, nextIn, nextOut);
249
+ return this.canvas.setNodePorts(nodeId, nextIn, nextOut);
247
250
  }
248
251
 
249
- updateNode(nodeId: string, patch: { name?: string; description?: string; color?: string; border?: string }): void {
250
- this.canvas.updateNode(nodeId, patch);
252
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
253
+ updateNode(nodeId: string, patch: { name?: string; description?: string; color?: string; border?: string }): boolean {
254
+ return this.canvas.updateNode(nodeId, patch);
251
255
  }
252
256
 
253
- setNodeMessage(nodeId: string, message: string): void {
254
- this.canvas.updateNode(nodeId, { message });
257
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
258
+ setNodeMessage(nodeId: string, message: string): boolean {
259
+ return this.canvas.updateNode(nodeId, { message });
255
260
  }
256
261
 
257
262
  setNodeError(nodeId: string, message: string, options: NodeErrorOptions = {}): boolean {
@@ -262,11 +267,11 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
262
267
  return this.canvas.clearNodeError(nodeId, kind);
263
268
  }
264
269
 
265
- getRuntimeState(): DiagramRuntimeState {
270
+ getRuntimeState(): DiagramSnapshot<DiagramRuntimeState> {
266
271
  return this.canvas.getRuntimeState();
267
272
  }
268
273
 
269
- setRuntimeState(state: DiagramRuntimeState): void {
274
+ setRuntimeState(state: DiagramSnapshot<DiagramRuntimeState>): void {
270
275
  this.canvas.setRuntimeState(state);
271
276
  }
272
277
 
@@ -291,12 +296,14 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
291
296
  this.canvas.setGlobalError(message, kind);
292
297
  }
293
298
 
294
- setNodeParamValue(nodeId: string, paramName: string, value: string | undefined): void {
295
- this.canvas.setNodeParamValue(nodeId, paramName, value);
299
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
300
+ setNodeParamValue(nodeId: string, paramName: string, value: string | undefined): boolean {
301
+ return this.canvas.setNodeParamValue(nodeId, paramName, value);
296
302
  }
297
303
 
298
- setNodeName(nodeId: string, value: string): void {
299
- this.canvas.updateNode(nodeId, { name: value });
304
+ /** False when nothing changed: no such node or port, or the edit was a no-op. */
305
+ setNodeName(nodeId: string, value: string): boolean {
306
+ return this.canvas.updateNode(nodeId, { name: value });
300
307
  }
301
308
 
302
309
  /** Groups host-driven document edits into one undo/redo operation. */
@@ -312,7 +319,7 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
312
319
  this.canvas.setReadOnly(readonly);
313
320
  }
314
321
 
315
- getInteractionPermissions(): DiagramInteractionPermissions {
322
+ getInteractionPermissions(): DiagramSnapshot<DiagramInteractionPermissions> {
316
323
  return this.canvas.getInteractionPermissions();
317
324
  }
318
325
 
@@ -341,11 +348,11 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
341
348
  this.canvas.setZoom(scale);
342
349
  }
343
350
 
344
- getViewState(): DiagramViewState {
351
+ getViewState(): DiagramSnapshot<DiagramViewState> {
345
352
  return this.canvas.getViewState();
346
353
  }
347
354
 
348
- setViewState(state: DiagramViewState): void {
355
+ setViewState(state: DiagramSnapshot<DiagramViewState>): void {
349
356
  this.canvas.setViewState(state);
350
357
  this.overviewContainer?.classList.toggle('hidden', !state.overviewVisible);
351
358
  }
@@ -365,7 +372,7 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
365
372
  return this.canvas.takeScreenshot(options);
366
373
  }
367
374
 
368
- getSelection(): DiagramSelection {
375
+ getSelection(): DiagramSnapshot<DiagramSelection> {
369
376
  return this.canvas.getSelection();
370
377
  }
371
378
 
@@ -400,12 +407,12 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
400
407
  }
401
408
 
402
409
  /** Text of the fullscreen button, for a host that renders in another language. */
403
- setFullscreenLabels(labels: DiagramFullscreenLabels): void {
410
+ setFullscreenLabels(labels: DiagramSnapshot<DiagramFullscreenLabels>): void {
404
411
  this.fullscreenLabels = labels;
405
412
  this.updateFullscreenButton();
406
413
  }
407
414
 
408
- getFullscreenLabels(): DiagramFullscreenLabels {
415
+ getFullscreenLabels(): DiagramSnapshot<DiagramFullscreenLabels> {
409
416
  return { ...this.fullscreenLabels };
410
417
  }
411
418
 
@@ -760,51 +767,47 @@ export class StockSharpDiagram extends EventEmitter<DiagramEvents> {
760
767
 
761
768
  private registerContextActions(): void {
762
769
  const permissions = () => this.canvas.getInteractionPermissions();
763
- this.contextActions.register({
764
- id: 'undo',
765
- canExecute: () => this.canUndo(),
766
- execute: () => this.undo(),
767
- });
768
- this.contextActions.register({
769
- id: 'redo',
770
- canExecute: () => this.canRedo(),
771
- execute: () => this.redo(),
772
- });
773
- this.contextActions.register({
774
- id: 'cut',
775
- canExecute: ({ nodes }) => nodes.length > 0 && permissions().copy && permissions().deleteSelection,
776
- execute: () => this.cutSelection(),
777
- });
778
- this.contextActions.register({
779
- id: 'copy',
780
- canExecute: ({ nodes }) => nodes.length > 0 && permissions().copy,
781
- execute: () => this.copySelection(),
782
- });
783
- this.contextActions.register({
784
- id: 'paste',
785
- canExecute: () => this.canvas.hasClipboard() && permissions().paste,
786
- execute: () => this.pasteSelection(),
787
- });
788
- this.contextActions.register({
789
- id: 'open',
790
- canExecute: ({ nodes }) => nodes.length === 1 && nodes[0].openAction.length > 0,
791
- execute: ({ nodes }) => this.emit('nodeOpen', { nodes }),
792
- });
793
- this.contextActions.register({
794
- id: 'delete',
795
- canExecute: ({ selection }) => permissions().deleteSelection
796
- && (selection.nodeIds.length > 0 || selection.linkIds.length > 0),
797
- execute: () => this.canvas.deleteSelection(),
798
- });
799
- this.contextActions.register({
800
- id: 'properties',
801
- canExecute: ({ nodes }) => nodes.length > 0,
802
- execute: ({ nodes }) => this.emit('nodeProperties', { nodes }),
803
- });
804
- this.contextActions.register({
805
- id: 'help',
806
- canExecute: ({ nodes }) => this.helpEnabled && nodes.length > 0,
807
- execute: ({ nodes }) => this.emit('nodeHelp', { nodes }),
770
+ // Keyed by ContextCommand, so a command added to the union without an
771
+ // entry here fails to compile rather than quietly missing from the menu.
772
+ // Key order is menu order.
773
+ this.contextActions.registerAll({
774
+ undo: {
775
+ canExecute: () => this.canUndo(),
776
+ execute: () => this.undo(),
777
+ },
778
+ redo: {
779
+ canExecute: () => this.canRedo(),
780
+ execute: () => this.redo(),
781
+ },
782
+ cut: {
783
+ canExecute: ({ nodes }) => nodes.length > 0 && permissions().copy && permissions().deleteSelection,
784
+ execute: () => this.cutSelection(),
785
+ },
786
+ copy: {
787
+ canExecute: ({ nodes }) => nodes.length > 0 && permissions().copy,
788
+ execute: () => this.copySelection(),
789
+ },
790
+ paste: {
791
+ canExecute: () => this.canvas.hasClipboard() && permissions().paste,
792
+ execute: () => this.pasteSelection(),
793
+ },
794
+ open: {
795
+ canExecute: ({ nodes }) => nodes.length === 1 && nodes[0].openAction.length > 0,
796
+ execute: ({ nodes }) => this.emit('nodeOpen', { nodes }),
797
+ },
798
+ delete: {
799
+ canExecute: ({ selection }) => permissions().deleteSelection
800
+ && (selection.nodeIds.length > 0 || selection.linkIds.length > 0),
801
+ execute: () => this.canvas.deleteSelection(),
802
+ },
803
+ properties: {
804
+ canExecute: ({ nodes }) => nodes.length > 0,
805
+ execute: ({ nodes }) => this.emit('nodeProperties', { nodes }),
806
+ },
807
+ help: {
808
+ canExecute: ({ nodes }) => this.helpEnabled && nodes.length > 0,
809
+ execute: ({ nodes }) => this.emit('nodeHelp', { nodes }),
810
+ },
808
811
  });
809
812
  }
810
813
 
@@ -1,4 +1,5 @@
1
- import type { JsonObject } from '../core/model.js';
1
+ import { toPortDynamicMode } from '../core/model.js';
2
+ import type { JsonObject, PortDynamicMode } from '../core/model.js';
2
3
 
3
4
  // Core data model — node/port catalog (palette) and the live diagram (DiagramNode + Link).
4
5
 
@@ -29,7 +30,7 @@ export interface PortInit {
29
30
  /// True when this port can be added/removed at runtime on a node.
30
31
  isDynamic?: boolean;
31
32
  /// "" / "manual" / "onConnect" — see PalettePortDto.dynamicMode docs.
32
- dynamicMode?: string;
33
+ dynamicMode?: PortDynamicMode;
33
34
  /// True when this port was spawned by the grow-on-connect pipeline.
34
35
  /// Distinguishes anchor + runtime siblings on save (only siblings are
35
36
  /// persisted in the diagram blob; anchors come from the palette schema).
@@ -47,7 +48,7 @@ export class Port {
47
48
  maxLinks: number;
48
49
  availableTypes: string[];
49
50
  isDynamic: boolean;
50
- dynamicMode: string;
51
+ dynamicMode: PortDynamicMode;
51
52
  isSibling: boolean;
52
53
 
53
54
  constructor(init: PortInit) {
@@ -58,7 +59,7 @@ export class Port {
58
59
  this.maxLinks = typeof init.maxLinks === 'number' ? init.maxLinks : 0;
59
60
  this.availableTypes = init.availableTypes ?? [];
60
61
  this.isDynamic = init.isDynamic ?? false;
61
- this.dynamicMode = init.dynamicMode ?? '';
62
+ this.dynamicMode = toPortDynamicMode(init.dynamicMode);
62
63
  this.isSibling = init.isSibling ?? false;
63
64
  }
64
65
 
@@ -268,7 +269,7 @@ export interface PortData {
268
269
  /// the anchor port spawns a sibling
269
270
  /// on each link drop and the link is rerouted to the sibling.
270
271
  isDynamic?: boolean;
271
- dynamicMode?: string;
272
+ dynamicMode?: PortDynamicMode;
272
273
  /// True when this port was spawned by the dynamic-growth pipeline rather
273
274
  /// than declared on the palette element. Persists in the diagram blob so
274
275
  /// reload restores the same set of sibling sockets.