@3plate/graph-core 0.1.6 → 0.1.9
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 +529 -234
- package/dist/index.d.cts +66 -4
- package/dist/index.d.ts +66 -4
- package/dist/index.js +528 -234
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -11,11 +11,24 @@ type Dims = {
|
|
|
11
11
|
|
|
12
12
|
type MarkerType = 'arrow' | 'circle' | 'diamond' | 'bar' | 'none';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Ingestion source configuration.
|
|
16
|
+
* Used to connect to an external data source for graph updates.
|
|
17
|
+
*/
|
|
18
|
+
type IngestionConfig = {
|
|
19
|
+
type: 'websocket';
|
|
20
|
+
url: string;
|
|
21
|
+
reconnectMs?: number;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'file';
|
|
24
|
+
url: string;
|
|
25
|
+
intervalMs?: number;
|
|
26
|
+
};
|
|
14
27
|
/**
|
|
15
28
|
* Arguments to the API constructor.
|
|
16
29
|
*
|
|
17
|
-
* The caller can specify nodes and edges, or
|
|
18
|
-
* but not
|
|
30
|
+
* The caller can specify nodes and edges, history, or ingestion config,
|
|
31
|
+
* but not multiple.
|
|
19
32
|
*
|
|
20
33
|
* The root element ID is required.
|
|
21
34
|
*/
|
|
@@ -28,6 +41,8 @@ type APIArguments<N, E> = {
|
|
|
28
41
|
edges?: E[];
|
|
29
42
|
/** Initial history */
|
|
30
43
|
history?: Update<N, E>[];
|
|
44
|
+
/** Ingestion source configuration */
|
|
45
|
+
ingestion?: IngestionConfig;
|
|
31
46
|
/** Events */
|
|
32
47
|
events?: EventsOptions<N, E>;
|
|
33
48
|
/** Root element ID */
|
|
@@ -75,6 +90,8 @@ type GraphOptions = {
|
|
|
75
90
|
* Events that can be handled by the user.
|
|
76
91
|
*/
|
|
77
92
|
type EventsOptions<N, E> = {
|
|
93
|
+
/** Called when the API has finished initializing */
|
|
94
|
+
onInit?: () => void;
|
|
78
95
|
/** Called when a node is clicked */
|
|
79
96
|
nodeClick?: (node: N) => void;
|
|
80
97
|
/** Called when an edge is clicked */
|
|
@@ -368,11 +385,19 @@ declare class API<N, E> {
|
|
|
368
385
|
private nextNodeId;
|
|
369
386
|
private nextEdgeId;
|
|
370
387
|
private events;
|
|
371
|
-
private
|
|
388
|
+
private ingest?;
|
|
389
|
+
private ingestionSource?;
|
|
390
|
+
private ingestionConfig?;
|
|
391
|
+
private prevProps;
|
|
392
|
+
root: string;
|
|
372
393
|
constructor(args: APIArguments<N, E>);
|
|
373
394
|
reset(): void;
|
|
374
395
|
/** Initialize the API */
|
|
375
396
|
init(): Promise<void>;
|
|
397
|
+
/** Connect to the configured ingestion source */
|
|
398
|
+
private connectIngestion;
|
|
399
|
+
/** Disconnect from the ingestion source */
|
|
400
|
+
private disconnectIngestion;
|
|
376
401
|
private applyHistory;
|
|
377
402
|
/** Current history index (0-based) */
|
|
378
403
|
getHistoryIndex(): number;
|
|
@@ -436,6 +461,30 @@ declare class API<N, E> {
|
|
|
436
461
|
handleAddEdge(data: EditEdgeProps): Promise<void>;
|
|
437
462
|
handleDeleteNode(id: NodeId): Promise<void>;
|
|
438
463
|
handleDeleteEdge(id: EdgeId): Promise<void>;
|
|
464
|
+
/** Update theme and type styles dynamically */
|
|
465
|
+
updateStyles(options: {
|
|
466
|
+
theme?: ThemeVars;
|
|
467
|
+
nodeTypes?: Record<string, ThemeVars>;
|
|
468
|
+
edgeTypes?: Record<string, ThemeVars>;
|
|
469
|
+
}): void;
|
|
470
|
+
/** Update color mode without recreating the canvas */
|
|
471
|
+
setColorMode(colorMode: 'light' | 'dark' | 'system'): void;
|
|
472
|
+
/**
|
|
473
|
+
* Apply prop changes by diffing against previously applied props.
|
|
474
|
+
* This is a convenience method for framework wrappers that centralizes
|
|
475
|
+
* the logic for detecting and applying changes to nodes, edges, history, and options.
|
|
476
|
+
* The API stores the previous props internally, so you just pass the new props.
|
|
477
|
+
*
|
|
478
|
+
* @param props - The new props to apply
|
|
479
|
+
*/
|
|
480
|
+
applyProps(props: {
|
|
481
|
+
nodes?: N[];
|
|
482
|
+
edges?: E[];
|
|
483
|
+
history?: Update<N, E>[];
|
|
484
|
+
options?: APIOptions<N, E>;
|
|
485
|
+
}): void;
|
|
486
|
+
/** Cleanup resources when the graph is destroyed */
|
|
487
|
+
destroy(): void;
|
|
439
488
|
}
|
|
440
489
|
|
|
441
490
|
type SnapshotMessage<N, E> = {
|
|
@@ -575,6 +624,7 @@ declare class Playground {
|
|
|
575
624
|
private options;
|
|
576
625
|
private rootElement;
|
|
577
626
|
private currentExample;
|
|
627
|
+
private examples;
|
|
578
628
|
private currentGraph;
|
|
579
629
|
private ingest;
|
|
580
630
|
private isEditable;
|
|
@@ -619,8 +669,20 @@ declare class Playground {
|
|
|
619
669
|
private handleChangeConnection;
|
|
620
670
|
private handleOpenFolder;
|
|
621
671
|
private handleCloseFolder;
|
|
672
|
+
/**
|
|
673
|
+
* Add or update an example
|
|
674
|
+
*/
|
|
675
|
+
addExample(key: string, example: Example): void;
|
|
676
|
+
/**
|
|
677
|
+
* Remove an example
|
|
678
|
+
*/
|
|
679
|
+
removeExample(key: string): void;
|
|
680
|
+
/**
|
|
681
|
+
* Update the example list in the DOM
|
|
682
|
+
*/
|
|
683
|
+
private updateExampleList;
|
|
622
684
|
}
|
|
623
685
|
|
|
624
686
|
declare function graph<N, E>(args?: APIArguments<N, E>): Promise<API<N, E>>;
|
|
625
687
|
|
|
626
|
-
export { type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, FileSystemSource, type HistoryMessage, Ingest, type IngestMessage, Playground, type PlaygroundOptions, type SnapshotMessage, type UpdateMessage, WebSocketSource, graph as default, graph };
|
|
688
|
+
export { API, type APIArguments, type APIOptions, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, FileSystemSource, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, Playground, type PlaygroundOptions, type SnapshotMessage, type Update, type UpdateMessage, Updater, WebSocketSource, graph as default, graph };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,24 @@ type Dims = {
|
|
|
11
11
|
|
|
12
12
|
type MarkerType = 'arrow' | 'circle' | 'diamond' | 'bar' | 'none';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Ingestion source configuration.
|
|
16
|
+
* Used to connect to an external data source for graph updates.
|
|
17
|
+
*/
|
|
18
|
+
type IngestionConfig = {
|
|
19
|
+
type: 'websocket';
|
|
20
|
+
url: string;
|
|
21
|
+
reconnectMs?: number;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'file';
|
|
24
|
+
url: string;
|
|
25
|
+
intervalMs?: number;
|
|
26
|
+
};
|
|
14
27
|
/**
|
|
15
28
|
* Arguments to the API constructor.
|
|
16
29
|
*
|
|
17
|
-
* The caller can specify nodes and edges, or
|
|
18
|
-
* but not
|
|
30
|
+
* The caller can specify nodes and edges, history, or ingestion config,
|
|
31
|
+
* but not multiple.
|
|
19
32
|
*
|
|
20
33
|
* The root element ID is required.
|
|
21
34
|
*/
|
|
@@ -28,6 +41,8 @@ type APIArguments<N, E> = {
|
|
|
28
41
|
edges?: E[];
|
|
29
42
|
/** Initial history */
|
|
30
43
|
history?: Update<N, E>[];
|
|
44
|
+
/** Ingestion source configuration */
|
|
45
|
+
ingestion?: IngestionConfig;
|
|
31
46
|
/** Events */
|
|
32
47
|
events?: EventsOptions<N, E>;
|
|
33
48
|
/** Root element ID */
|
|
@@ -75,6 +90,8 @@ type GraphOptions = {
|
|
|
75
90
|
* Events that can be handled by the user.
|
|
76
91
|
*/
|
|
77
92
|
type EventsOptions<N, E> = {
|
|
93
|
+
/** Called when the API has finished initializing */
|
|
94
|
+
onInit?: () => void;
|
|
78
95
|
/** Called when a node is clicked */
|
|
79
96
|
nodeClick?: (node: N) => void;
|
|
80
97
|
/** Called when an edge is clicked */
|
|
@@ -368,11 +385,19 @@ declare class API<N, E> {
|
|
|
368
385
|
private nextNodeId;
|
|
369
386
|
private nextEdgeId;
|
|
370
387
|
private events;
|
|
371
|
-
private
|
|
388
|
+
private ingest?;
|
|
389
|
+
private ingestionSource?;
|
|
390
|
+
private ingestionConfig?;
|
|
391
|
+
private prevProps;
|
|
392
|
+
root: string;
|
|
372
393
|
constructor(args: APIArguments<N, E>);
|
|
373
394
|
reset(): void;
|
|
374
395
|
/** Initialize the API */
|
|
375
396
|
init(): Promise<void>;
|
|
397
|
+
/** Connect to the configured ingestion source */
|
|
398
|
+
private connectIngestion;
|
|
399
|
+
/** Disconnect from the ingestion source */
|
|
400
|
+
private disconnectIngestion;
|
|
376
401
|
private applyHistory;
|
|
377
402
|
/** Current history index (0-based) */
|
|
378
403
|
getHistoryIndex(): number;
|
|
@@ -436,6 +461,30 @@ declare class API<N, E> {
|
|
|
436
461
|
handleAddEdge(data: EditEdgeProps): Promise<void>;
|
|
437
462
|
handleDeleteNode(id: NodeId): Promise<void>;
|
|
438
463
|
handleDeleteEdge(id: EdgeId): Promise<void>;
|
|
464
|
+
/** Update theme and type styles dynamically */
|
|
465
|
+
updateStyles(options: {
|
|
466
|
+
theme?: ThemeVars;
|
|
467
|
+
nodeTypes?: Record<string, ThemeVars>;
|
|
468
|
+
edgeTypes?: Record<string, ThemeVars>;
|
|
469
|
+
}): void;
|
|
470
|
+
/** Update color mode without recreating the canvas */
|
|
471
|
+
setColorMode(colorMode: 'light' | 'dark' | 'system'): void;
|
|
472
|
+
/**
|
|
473
|
+
* Apply prop changes by diffing against previously applied props.
|
|
474
|
+
* This is a convenience method for framework wrappers that centralizes
|
|
475
|
+
* the logic for detecting and applying changes to nodes, edges, history, and options.
|
|
476
|
+
* The API stores the previous props internally, so you just pass the new props.
|
|
477
|
+
*
|
|
478
|
+
* @param props - The new props to apply
|
|
479
|
+
*/
|
|
480
|
+
applyProps(props: {
|
|
481
|
+
nodes?: N[];
|
|
482
|
+
edges?: E[];
|
|
483
|
+
history?: Update<N, E>[];
|
|
484
|
+
options?: APIOptions<N, E>;
|
|
485
|
+
}): void;
|
|
486
|
+
/** Cleanup resources when the graph is destroyed */
|
|
487
|
+
destroy(): void;
|
|
439
488
|
}
|
|
440
489
|
|
|
441
490
|
type SnapshotMessage<N, E> = {
|
|
@@ -575,6 +624,7 @@ declare class Playground {
|
|
|
575
624
|
private options;
|
|
576
625
|
private rootElement;
|
|
577
626
|
private currentExample;
|
|
627
|
+
private examples;
|
|
578
628
|
private currentGraph;
|
|
579
629
|
private ingest;
|
|
580
630
|
private isEditable;
|
|
@@ -619,8 +669,20 @@ declare class Playground {
|
|
|
619
669
|
private handleChangeConnection;
|
|
620
670
|
private handleOpenFolder;
|
|
621
671
|
private handleCloseFolder;
|
|
672
|
+
/**
|
|
673
|
+
* Add or update an example
|
|
674
|
+
*/
|
|
675
|
+
addExample(key: string, example: Example): void;
|
|
676
|
+
/**
|
|
677
|
+
* Remove an example
|
|
678
|
+
*/
|
|
679
|
+
removeExample(key: string): void;
|
|
680
|
+
/**
|
|
681
|
+
* Update the example list in the DOM
|
|
682
|
+
*/
|
|
683
|
+
private updateExampleList;
|
|
622
684
|
}
|
|
623
685
|
|
|
624
686
|
declare function graph<N, E>(args?: APIArguments<N, E>): Promise<API<N, E>>;
|
|
625
687
|
|
|
626
|
-
export { type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, FileSystemSource, type HistoryMessage, Ingest, type IngestMessage, Playground, type PlaygroundOptions, type SnapshotMessage, type UpdateMessage, WebSocketSource, graph as default, graph };
|
|
688
|
+
export { API, type APIArguments, type APIOptions, type EventsOptions, type Example, type ExampleEdge, type ExampleNode, type ExampleOptions, FileSource, FileSystemSource, type HistoryMessage, Ingest, type IngestMessage, type IngestionConfig, Playground, type PlaygroundOptions, type SnapshotMessage, type Update, type UpdateMessage, Updater, WebSocketSource, graph as default, graph };
|