@3plate/graph-core 0.1.10 → 0.1.14

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/dist/index.d.cts CHANGED
@@ -12,6 +12,87 @@ type Dims = {
12
12
 
13
13
  type MarkerType = 'arrow' | 'circle' | 'diamond' | 'bar' | 'none';
14
14
 
15
+ type SnapshotMessage<N, E> = {
16
+ type: 'snapshot';
17
+ nodes: N[];
18
+ edges: E[];
19
+ description?: string;
20
+ };
21
+ type UpdateMessage<N, E> = {
22
+ type: 'update';
23
+ description?: string;
24
+ } & Update<N, E>;
25
+ type HistoryMessage<N, E> = {
26
+ type: 'history';
27
+ history: Update<N, E>[];
28
+ };
29
+ type IngestMessage<N, E> = SnapshotMessage<N, E> | UpdateMessage<N, E> | HistoryMessage<N, E>;
30
+ /**
31
+ * Ingest class handles applying ingest messages to an API instance.
32
+ * This is the core ingestion functionality, separate from UI concerns.
33
+ */
34
+ declare class Ingest<N, E> {
35
+ api: API<N, E>;
36
+ constructor(api: API<N, E>);
37
+ /**
38
+ * Apply an incoming ingest message to the API.
39
+ * - snapshot: rebuild state from nodes/edges (clears prior history)
40
+ * - update: apply incremental update
41
+ * - history: initialize from a set of updates (clears prior history)
42
+ */
43
+ apply(msg: IngestMessage<N, E>): Promise<void>;
44
+ }
45
+
46
+ type WebSocketStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
47
+ type WebSocketStatusListener = (status: WebSocketStatus, detail?: any) => void;
48
+ type WebSocketSourceArgs<N, E> = {
49
+ url: string;
50
+ onMessage: (msg: IngestMessage<N, E>) => void;
51
+ onStatus?: WebSocketStatusListener;
52
+ reconnectMs?: number;
53
+ };
54
+ declare class WebSocketSource<N, E> {
55
+ private url;
56
+ private ws;
57
+ private onMessage;
58
+ private onStatus?;
59
+ private reconnectMs;
60
+ private closedByUser;
61
+ private connectStartTime;
62
+ private totalTimeoutMs;
63
+ private totalTimeoutTimer;
64
+ constructor(args: WebSocketSourceArgs<N, E>);
65
+ connect(): void;
66
+ disconnect(): void;
67
+ private startTotalTimeout;
68
+ private clearTotalTimeout;
69
+ private open;
70
+ }
71
+
72
+ type FileStatus = 'idle' | 'opened' | 'reading' | 'error' | 'closed';
73
+ type FileStatusListener = (status: FileStatus, detail?: any) => void;
74
+ type FileSourceArgs<N, E> = {
75
+ url: string;
76
+ onMessage: (msg: IngestMessage<N, E>) => void;
77
+ onStatus?: FileStatusListener;
78
+ intervalMs?: number;
79
+ };
80
+ declare class FileSource<N, E> {
81
+ private url;
82
+ private onMessage;
83
+ private onStatus?;
84
+ private timer;
85
+ private lastETag;
86
+ private lastContent;
87
+ private intervalMs;
88
+ private closed;
89
+ constructor(args: FileSourceArgs<N, E>);
90
+ connect(): Promise<void>;
91
+ close(): void;
92
+ private startPolling;
93
+ private poll;
94
+ }
95
+
15
96
  /** WebSocket ingestion configuration */
16
97
  type WebSocketIngestionConfig = {
17
98
  type: 'websocket';
@@ -19,12 +100,8 @@ type WebSocketIngestionConfig = {
19
100
  url: string;
20
101
  /** Reconnect interval in milliseconds */
21
102
  reconnectMs?: number;
22
- /** Callback when the WebSocket connection is established */
23
- onConnect?: () => void;
24
- /** Callback when the WebSocket connection is closed */
25
- onDisconnect?: () => void;
26
- /** Callback when the WebSocket connection encounters an error */
27
- onError?: (error: Error) => void;
103
+ /** Status listener */
104
+ onStatus?: WebSocketStatusListener;
28
105
  };
29
106
  /** File ingestion configuration */
30
107
  type FileIngestionConfig = {
@@ -33,6 +110,8 @@ type FileIngestionConfig = {
33
110
  url: string;
34
111
  /** Polling interval in milliseconds */
35
112
  intervalMs?: number;
113
+ /** Status listener */
114
+ onStatus?: FileStatusListener;
36
115
  };
37
116
  /**
38
117
  * Ingestion source configuration.
@@ -421,7 +500,7 @@ declare class API<N, E> {
421
500
  /** Toggle canvas editable mode without re-creating the graph */
422
501
  setEditable(editable: boolean): void;
423
502
  /** Replace entire history (clears prior) */
424
- replaceHistory(frames: Update<N, E>[]): Promise<void>;
503
+ replaceHistory(history: Update<N, E>[]): Promise<void>;
425
504
  /** Rebuild from snapshot (nodes/edges) */
426
505
  replaceSnapshot(nodes: N[], edges: E[], description?: string): Promise<void>;
427
506
  private get graph();
@@ -502,68 +581,11 @@ declare class API<N, E> {
502
581
  destroy(): void;
503
582
  }
504
583
 
505
- type SnapshotMessage<N, E> = {
506
- type: 'snapshot';
507
- nodes: N[];
508
- edges: E[];
509
- description?: string;
510
- };
511
- type UpdateMessage<N, E> = {
512
- type: 'update';
513
- description?: string;
514
- } & Update<N, E>;
515
- type HistoryMessage<N, E> = {
516
- type: 'history';
517
- frames: Update<N, E>[];
518
- };
519
- type IngestMessage<N, E> = SnapshotMessage<N, E> | UpdateMessage<N, E> | HistoryMessage<N, E>;
520
- /**
521
- * Ingest class handles applying ingest messages to an API instance.
522
- * This is the core ingestion functionality, separate from UI concerns.
523
- */
524
- declare class Ingest<N, E> {
525
- api: API<N, E>;
526
- constructor(api: API<N, E>);
527
- /**
528
- * Apply an incoming ingest message to the API.
529
- * - snapshot: rebuild state from nodes/edges (clears prior history)
530
- * - update: apply incremental update
531
- * - history: initialize from a set of frames (clears prior history)
532
- */
533
- apply(msg: IngestMessage<N, E>): Promise<void>;
534
- }
535
-
536
- type WebSocketStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
537
- type WebSocketStatusListener = (status: WebSocketStatus, detail?: any) => void;
538
- type WebSocketSourceArgs<N, E> = {
539
- url: string;
540
- onMessage: (msg: IngestMessage<N, E>) => void;
541
- onStatus?: WebSocketStatusListener;
542
- reconnectMs?: number;
543
- };
544
- declare class WebSocketSource<N, E> {
545
- private url;
546
- private ws;
547
- private onMessage;
548
- private onStatus?;
549
- private reconnectMs;
550
- private closedByUser;
551
- private connectStartTime;
552
- private totalTimeoutMs;
553
- private totalTimeoutTimer;
554
- constructor(args: WebSocketSourceArgs<N, E>);
555
- connect(): void;
556
- disconnect(): void;
557
- private startTotalTimeout;
558
- private clearTotalTimeout;
559
- private open;
560
- }
561
-
562
- type StatusListener$1 = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
584
+ type StatusListener = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
563
585
  type FileSystemSourceArgs<N, E> = {
564
586
  filename: string;
565
587
  onMessage: (msg: IngestMessage<N, E>) => void;
566
- onStatus?: StatusListener$1;
588
+ onStatus?: StatusListener;
567
589
  intervalMs?: number;
568
590
  };
569
591
  declare class FileSystemSource<N, E> {
@@ -581,29 +603,6 @@ declare class FileSystemSource<N, E> {
581
603
  private readNewLines;
582
604
  }
583
605
 
584
- type StatusListener = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
585
- type FileSourceArgs<N, E> = {
586
- url: string;
587
- onMessage: (msg: IngestMessage<N, E>) => void;
588
- onStatus?: StatusListener;
589
- intervalMs?: number;
590
- };
591
- declare class FileSource<N, E> {
592
- private url;
593
- private onMessage;
594
- private onStatus?;
595
- private timer;
596
- private lastETag;
597
- private lastContent;
598
- private intervalMs;
599
- private closed;
600
- constructor(args: FileSourceArgs<N, E>);
601
- connect(): Promise<void>;
602
- close(): void;
603
- private startPolling;
604
- private poll;
605
- }
606
-
607
606
  /**
608
607
  * Types for the Playground component
609
608
  */
@@ -719,4 +718,4 @@ declare class Playground {
719
718
 
720
719
  declare function graph<N, E>(args?: APIArguments<N, E>): Promise<API<N, E>>;
721
720
 
722
- export { API, type APIArguments, type APIOptions, type CanvasTheme, type ColorMode, type EdgeProps, type EdgeTheme, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, type FileSourceArgs, FileSystemSource, type FileSystemSourceArgs, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, type NewEdge, type NewNode, type NodeAlign, type NodeProps, type NodeTheme, type Orientation, Playground, type PlaygroundOptions, type PortProps, type PortStyle, type PortTheme, type RenderNode, type SnapshotMessage, type ThemeVars, type Update, type UpdateMessage, Updater, WebSocketSource, type WebSocketSourceArgs, type WebSocketStatus, type WebSocketStatusListener, graph as default, graph };
721
+ export { API, type APIArguments, type APIOptions, type CanvasTheme, type ColorMode, type EdgeProps, type EdgeTheme, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, type FileSourceArgs, type FileStatus, type FileStatusListener, FileSystemSource, type FileSystemSourceArgs, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, type NewEdge, type NewNode, type NodeAlign, type NodeProps, type NodeTheme, type Orientation, Playground, type PlaygroundOptions, type PortProps, type PortStyle, type PortTheme, type RenderNode, type SnapshotMessage, type ThemeVars, type Update, type UpdateMessage, Updater, WebSocketSource, type WebSocketSourceArgs, type WebSocketStatus, type WebSocketStatusListener, graph as default, graph };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,87 @@ type Dims = {
12
12
 
13
13
  type MarkerType = 'arrow' | 'circle' | 'diamond' | 'bar' | 'none';
14
14
 
15
+ type SnapshotMessage<N, E> = {
16
+ type: 'snapshot';
17
+ nodes: N[];
18
+ edges: E[];
19
+ description?: string;
20
+ };
21
+ type UpdateMessage<N, E> = {
22
+ type: 'update';
23
+ description?: string;
24
+ } & Update<N, E>;
25
+ type HistoryMessage<N, E> = {
26
+ type: 'history';
27
+ history: Update<N, E>[];
28
+ };
29
+ type IngestMessage<N, E> = SnapshotMessage<N, E> | UpdateMessage<N, E> | HistoryMessage<N, E>;
30
+ /**
31
+ * Ingest class handles applying ingest messages to an API instance.
32
+ * This is the core ingestion functionality, separate from UI concerns.
33
+ */
34
+ declare class Ingest<N, E> {
35
+ api: API<N, E>;
36
+ constructor(api: API<N, E>);
37
+ /**
38
+ * Apply an incoming ingest message to the API.
39
+ * - snapshot: rebuild state from nodes/edges (clears prior history)
40
+ * - update: apply incremental update
41
+ * - history: initialize from a set of updates (clears prior history)
42
+ */
43
+ apply(msg: IngestMessage<N, E>): Promise<void>;
44
+ }
45
+
46
+ type WebSocketStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
47
+ type WebSocketStatusListener = (status: WebSocketStatus, detail?: any) => void;
48
+ type WebSocketSourceArgs<N, E> = {
49
+ url: string;
50
+ onMessage: (msg: IngestMessage<N, E>) => void;
51
+ onStatus?: WebSocketStatusListener;
52
+ reconnectMs?: number;
53
+ };
54
+ declare class WebSocketSource<N, E> {
55
+ private url;
56
+ private ws;
57
+ private onMessage;
58
+ private onStatus?;
59
+ private reconnectMs;
60
+ private closedByUser;
61
+ private connectStartTime;
62
+ private totalTimeoutMs;
63
+ private totalTimeoutTimer;
64
+ constructor(args: WebSocketSourceArgs<N, E>);
65
+ connect(): void;
66
+ disconnect(): void;
67
+ private startTotalTimeout;
68
+ private clearTotalTimeout;
69
+ private open;
70
+ }
71
+
72
+ type FileStatus = 'idle' | 'opened' | 'reading' | 'error' | 'closed';
73
+ type FileStatusListener = (status: FileStatus, detail?: any) => void;
74
+ type FileSourceArgs<N, E> = {
75
+ url: string;
76
+ onMessage: (msg: IngestMessage<N, E>) => void;
77
+ onStatus?: FileStatusListener;
78
+ intervalMs?: number;
79
+ };
80
+ declare class FileSource<N, E> {
81
+ private url;
82
+ private onMessage;
83
+ private onStatus?;
84
+ private timer;
85
+ private lastETag;
86
+ private lastContent;
87
+ private intervalMs;
88
+ private closed;
89
+ constructor(args: FileSourceArgs<N, E>);
90
+ connect(): Promise<void>;
91
+ close(): void;
92
+ private startPolling;
93
+ private poll;
94
+ }
95
+
15
96
  /** WebSocket ingestion configuration */
16
97
  type WebSocketIngestionConfig = {
17
98
  type: 'websocket';
@@ -19,12 +100,8 @@ type WebSocketIngestionConfig = {
19
100
  url: string;
20
101
  /** Reconnect interval in milliseconds */
21
102
  reconnectMs?: number;
22
- /** Callback when the WebSocket connection is established */
23
- onConnect?: () => void;
24
- /** Callback when the WebSocket connection is closed */
25
- onDisconnect?: () => void;
26
- /** Callback when the WebSocket connection encounters an error */
27
- onError?: (error: Error) => void;
103
+ /** Status listener */
104
+ onStatus?: WebSocketStatusListener;
28
105
  };
29
106
  /** File ingestion configuration */
30
107
  type FileIngestionConfig = {
@@ -33,6 +110,8 @@ type FileIngestionConfig = {
33
110
  url: string;
34
111
  /** Polling interval in milliseconds */
35
112
  intervalMs?: number;
113
+ /** Status listener */
114
+ onStatus?: FileStatusListener;
36
115
  };
37
116
  /**
38
117
  * Ingestion source configuration.
@@ -421,7 +500,7 @@ declare class API<N, E> {
421
500
  /** Toggle canvas editable mode without re-creating the graph */
422
501
  setEditable(editable: boolean): void;
423
502
  /** Replace entire history (clears prior) */
424
- replaceHistory(frames: Update<N, E>[]): Promise<void>;
503
+ replaceHistory(history: Update<N, E>[]): Promise<void>;
425
504
  /** Rebuild from snapshot (nodes/edges) */
426
505
  replaceSnapshot(nodes: N[], edges: E[], description?: string): Promise<void>;
427
506
  private get graph();
@@ -502,68 +581,11 @@ declare class API<N, E> {
502
581
  destroy(): void;
503
582
  }
504
583
 
505
- type SnapshotMessage<N, E> = {
506
- type: 'snapshot';
507
- nodes: N[];
508
- edges: E[];
509
- description?: string;
510
- };
511
- type UpdateMessage<N, E> = {
512
- type: 'update';
513
- description?: string;
514
- } & Update<N, E>;
515
- type HistoryMessage<N, E> = {
516
- type: 'history';
517
- frames: Update<N, E>[];
518
- };
519
- type IngestMessage<N, E> = SnapshotMessage<N, E> | UpdateMessage<N, E> | HistoryMessage<N, E>;
520
- /**
521
- * Ingest class handles applying ingest messages to an API instance.
522
- * This is the core ingestion functionality, separate from UI concerns.
523
- */
524
- declare class Ingest<N, E> {
525
- api: API<N, E>;
526
- constructor(api: API<N, E>);
527
- /**
528
- * Apply an incoming ingest message to the API.
529
- * - snapshot: rebuild state from nodes/edges (clears prior history)
530
- * - update: apply incremental update
531
- * - history: initialize from a set of frames (clears prior history)
532
- */
533
- apply(msg: IngestMessage<N, E>): Promise<void>;
534
- }
535
-
536
- type WebSocketStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
537
- type WebSocketStatusListener = (status: WebSocketStatus, detail?: any) => void;
538
- type WebSocketSourceArgs<N, E> = {
539
- url: string;
540
- onMessage: (msg: IngestMessage<N, E>) => void;
541
- onStatus?: WebSocketStatusListener;
542
- reconnectMs?: number;
543
- };
544
- declare class WebSocketSource<N, E> {
545
- private url;
546
- private ws;
547
- private onMessage;
548
- private onStatus?;
549
- private reconnectMs;
550
- private closedByUser;
551
- private connectStartTime;
552
- private totalTimeoutMs;
553
- private totalTimeoutTimer;
554
- constructor(args: WebSocketSourceArgs<N, E>);
555
- connect(): void;
556
- disconnect(): void;
557
- private startTotalTimeout;
558
- private clearTotalTimeout;
559
- private open;
560
- }
561
-
562
- type StatusListener$1 = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
584
+ type StatusListener = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
563
585
  type FileSystemSourceArgs<N, E> = {
564
586
  filename: string;
565
587
  onMessage: (msg: IngestMessage<N, E>) => void;
566
- onStatus?: StatusListener$1;
588
+ onStatus?: StatusListener;
567
589
  intervalMs?: number;
568
590
  };
569
591
  declare class FileSystemSource<N, E> {
@@ -581,29 +603,6 @@ declare class FileSystemSource<N, E> {
581
603
  private readNewLines;
582
604
  }
583
605
 
584
- type StatusListener = (status: 'idle' | 'opened' | 'reading' | 'error' | 'closed', detail?: any) => void;
585
- type FileSourceArgs<N, E> = {
586
- url: string;
587
- onMessage: (msg: IngestMessage<N, E>) => void;
588
- onStatus?: StatusListener;
589
- intervalMs?: number;
590
- };
591
- declare class FileSource<N, E> {
592
- private url;
593
- private onMessage;
594
- private onStatus?;
595
- private timer;
596
- private lastETag;
597
- private lastContent;
598
- private intervalMs;
599
- private closed;
600
- constructor(args: FileSourceArgs<N, E>);
601
- connect(): Promise<void>;
602
- close(): void;
603
- private startPolling;
604
- private poll;
605
- }
606
-
607
606
  /**
608
607
  * Types for the Playground component
609
608
  */
@@ -719,4 +718,4 @@ declare class Playground {
719
718
 
720
719
  declare function graph<N, E>(args?: APIArguments<N, E>): Promise<API<N, E>>;
721
720
 
722
- export { API, type APIArguments, type APIOptions, type CanvasTheme, type ColorMode, type EdgeProps, type EdgeTheme, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, type FileSourceArgs, FileSystemSource, type FileSystemSourceArgs, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, type NewEdge, type NewNode, type NodeAlign, type NodeProps, type NodeTheme, type Orientation, Playground, type PlaygroundOptions, type PortProps, type PortStyle, type PortTheme, type RenderNode, type SnapshotMessage, type ThemeVars, type Update, type UpdateMessage, Updater, WebSocketSource, type WebSocketSourceArgs, type WebSocketStatus, type WebSocketStatusListener, graph as default, graph };
721
+ export { API, type APIArguments, type APIOptions, type CanvasTheme, type ColorMode, type EdgeProps, type EdgeTheme, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, type FileSourceArgs, type FileStatus, type FileStatusListener, FileSystemSource, type FileSystemSourceArgs, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, type NewEdge, type NewNode, type NodeAlign, type NodeProps, type NodeTheme, type Orientation, Playground, type PlaygroundOptions, type PortProps, type PortStyle, type PortTheme, type RenderNode, type SnapshotMessage, type ThemeVars, type Update, type UpdateMessage, Updater, WebSocketSource, type WebSocketSourceArgs, type WebSocketStatus, type WebSocketStatusListener, graph as default, graph };