@3plate/graph-core 0.1.10 → 0.1.12
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.cjs +6 -6
- package/dist/index.d.cts +89 -90
- package/dist/index.d.ts +89 -90
- package/dist/index.js +6 -6
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -3678,7 +3678,7 @@ var Ingest = class {
|
|
|
3678
3678
|
* Apply an incoming ingest message to the API.
|
|
3679
3679
|
* - snapshot: rebuild state from nodes/edges (clears prior history)
|
|
3680
3680
|
* - update: apply incremental update
|
|
3681
|
-
* - history: initialize from a set of
|
|
3681
|
+
* - history: initialize from a set of updates (clears prior history)
|
|
3682
3682
|
*/
|
|
3683
3683
|
async apply(msg) {
|
|
3684
3684
|
switch (msg.type) {
|
|
@@ -3699,7 +3699,7 @@ var Ingest = class {
|
|
|
3699
3699
|
break;
|
|
3700
3700
|
}
|
|
3701
3701
|
case "history": {
|
|
3702
|
-
await this.api.replaceHistory(msg.
|
|
3702
|
+
await this.api.replaceHistory(msg.history);
|
|
3703
3703
|
break;
|
|
3704
3704
|
}
|
|
3705
3705
|
}
|
|
@@ -4073,9 +4073,9 @@ var API = class {
|
|
|
4073
4073
|
this.canvas.editMode.editable = editable;
|
|
4074
4074
|
}
|
|
4075
4075
|
/** Replace entire history (clears prior) */
|
|
4076
|
-
async replaceHistory(
|
|
4076
|
+
async replaceHistory(history) {
|
|
4077
4077
|
this.reset();
|
|
4078
|
-
this.history =
|
|
4078
|
+
this.history = history;
|
|
4079
4079
|
await this.applyHistory();
|
|
4080
4080
|
}
|
|
4081
4081
|
/** Rebuild from snapshot (nodes/edges) */
|
|
@@ -4542,8 +4542,8 @@ var API = class {
|
|
|
4542
4542
|
}
|
|
4543
4543
|
} else if (prev.history && isHistoryPrefix(prev.history, props.history)) {
|
|
4544
4544
|
const prevLength = prev.history.length;
|
|
4545
|
-
const
|
|
4546
|
-
for (const frame of
|
|
4545
|
+
const newUpdates = props.history.slice(prevLength);
|
|
4546
|
+
for (const frame of newUpdates) {
|
|
4547
4547
|
this.update((u) => {
|
|
4548
4548
|
if (frame.addNodes) u.addNodes(...frame.addNodes);
|
|
4549
4549
|
if (frame.removeNodes) u.deleteNodes(...frame.removeNodes);
|
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
|
-
/**
|
|
23
|
-
|
|
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(
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
23
|
-
|
|
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(
|
|
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
|
|
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
|
|
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.js
CHANGED
|
@@ -3635,7 +3635,7 @@ var Ingest = class {
|
|
|
3635
3635
|
* Apply an incoming ingest message to the API.
|
|
3636
3636
|
* - snapshot: rebuild state from nodes/edges (clears prior history)
|
|
3637
3637
|
* - update: apply incremental update
|
|
3638
|
-
* - history: initialize from a set of
|
|
3638
|
+
* - history: initialize from a set of updates (clears prior history)
|
|
3639
3639
|
*/
|
|
3640
3640
|
async apply(msg) {
|
|
3641
3641
|
switch (msg.type) {
|
|
@@ -3656,7 +3656,7 @@ var Ingest = class {
|
|
|
3656
3656
|
break;
|
|
3657
3657
|
}
|
|
3658
3658
|
case "history": {
|
|
3659
|
-
await this.api.replaceHistory(msg.
|
|
3659
|
+
await this.api.replaceHistory(msg.history);
|
|
3660
3660
|
break;
|
|
3661
3661
|
}
|
|
3662
3662
|
}
|
|
@@ -4030,9 +4030,9 @@ var API = class {
|
|
|
4030
4030
|
this.canvas.editMode.editable = editable;
|
|
4031
4031
|
}
|
|
4032
4032
|
/** Replace entire history (clears prior) */
|
|
4033
|
-
async replaceHistory(
|
|
4033
|
+
async replaceHistory(history) {
|
|
4034
4034
|
this.reset();
|
|
4035
|
-
this.history =
|
|
4035
|
+
this.history = history;
|
|
4036
4036
|
await this.applyHistory();
|
|
4037
4037
|
}
|
|
4038
4038
|
/** Rebuild from snapshot (nodes/edges) */
|
|
@@ -4499,8 +4499,8 @@ var API = class {
|
|
|
4499
4499
|
}
|
|
4500
4500
|
} else if (prev.history && isHistoryPrefix(prev.history, props.history)) {
|
|
4501
4501
|
const prevLength = prev.history.length;
|
|
4502
|
-
const
|
|
4503
|
-
for (const frame of
|
|
4502
|
+
const newUpdates = props.history.slice(prevLength);
|
|
4503
|
+
for (const frame of newUpdates) {
|
|
4504
4504
|
this.update((u) => {
|
|
4505
4505
|
if (frame.addNodes) u.addNodes(...frame.addNodes);
|
|
4506
4506
|
if (frame.removeNodes) u.deleteNodes(...frame.removeNodes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3plate/graph-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
"url": "https://github.com/3plt/graph",
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
|
-
"main": "./dist/index.
|
|
12
|
-
"module": "./dist/index.
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
15
16
|
"source": "./src/index.ts",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
"files": [
|