@3plate/graph-angular 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.d.mts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +168 -0
- package/dist/index.mjs +152 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
import { OnInit, OnDestroy, OnChanges, ElementRef, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { Update, IngestionConfig, APIArguments, API, PlaygroundOptions, Playground } from '@3plate/graph-core';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Angular Graph component for @3plate/graph
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare class GraphComponent<N = any, E = any> implements OnInit, OnDestroy, OnChanges {
|
|
9
|
+
rootRef: ElementRef<HTMLDivElement>;
|
|
10
|
+
/** Initial nodes */
|
|
11
|
+
nodes?: N[];
|
|
12
|
+
/** Initial edges */
|
|
13
|
+
edges?: E[];
|
|
14
|
+
/** Initial history */
|
|
15
|
+
history?: Update<N, E>[];
|
|
16
|
+
/** Ingestion source configuration (alternative to nodes/edges/history) */
|
|
17
|
+
ingestion?: IngestionConfig;
|
|
18
|
+
/** Options */
|
|
19
|
+
options?: APIArguments<N, E>['options'];
|
|
20
|
+
/** Events */
|
|
21
|
+
events?: APIArguments<N, E>['events'];
|
|
22
|
+
private api;
|
|
23
|
+
private rootId;
|
|
24
|
+
ngOnInit(): Promise<void>;
|
|
25
|
+
ngOnDestroy(): void;
|
|
26
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
27
|
+
/** Get the underlying API instance */
|
|
28
|
+
getApi(): API<N, E> | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Angular Playground component for @3plate/graph
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
declare class PlaygroundComponent implements OnInit, OnDestroy {
|
|
36
|
+
rootRef: ElementRef<HTMLDivElement>;
|
|
37
|
+
/** Examples to display in the playground */
|
|
38
|
+
examples: PlaygroundOptions['examples'];
|
|
39
|
+
/** Default example key */
|
|
40
|
+
defaultExample?: string;
|
|
41
|
+
private playground;
|
|
42
|
+
private rootId;
|
|
43
|
+
ngOnInit(): Promise<void>;
|
|
44
|
+
ngOnDestroy(): void;
|
|
45
|
+
/** Get the underlying Playground instance */
|
|
46
|
+
getPlayground(): Playground | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { GraphComponent, PlaygroundComponent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
import { OnInit, OnDestroy, OnChanges, ElementRef, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { Update, IngestionConfig, APIArguments, API, PlaygroundOptions, Playground } from '@3plate/graph-core';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Angular Graph component for @3plate/graph
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare class GraphComponent<N = any, E = any> implements OnInit, OnDestroy, OnChanges {
|
|
9
|
+
rootRef: ElementRef<HTMLDivElement>;
|
|
10
|
+
/** Initial nodes */
|
|
11
|
+
nodes?: N[];
|
|
12
|
+
/** Initial edges */
|
|
13
|
+
edges?: E[];
|
|
14
|
+
/** Initial history */
|
|
15
|
+
history?: Update<N, E>[];
|
|
16
|
+
/** Ingestion source configuration (alternative to nodes/edges/history) */
|
|
17
|
+
ingestion?: IngestionConfig;
|
|
18
|
+
/** Options */
|
|
19
|
+
options?: APIArguments<N, E>['options'];
|
|
20
|
+
/** Events */
|
|
21
|
+
events?: APIArguments<N, E>['events'];
|
|
22
|
+
private api;
|
|
23
|
+
private rootId;
|
|
24
|
+
ngOnInit(): Promise<void>;
|
|
25
|
+
ngOnDestroy(): void;
|
|
26
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
27
|
+
/** Get the underlying API instance */
|
|
28
|
+
getApi(): API<N, E> | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Angular Playground component for @3plate/graph
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
declare class PlaygroundComponent implements OnInit, OnDestroy {
|
|
36
|
+
rootRef: ElementRef<HTMLDivElement>;
|
|
37
|
+
/** Examples to display in the playground */
|
|
38
|
+
examples: PlaygroundOptions['examples'];
|
|
39
|
+
/** Default example key */
|
|
40
|
+
defaultExample?: string;
|
|
41
|
+
private playground;
|
|
42
|
+
private rootId;
|
|
43
|
+
ngOnInit(): Promise<void>;
|
|
44
|
+
ngOnDestroy(): void;
|
|
45
|
+
/** Get the underlying Playground instance */
|
|
46
|
+
getPlayground(): Playground | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { GraphComponent, PlaygroundComponent };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,169 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result) __defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/index.ts
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
GraphComponent: () => GraphComponent,
|
|
32
|
+
PlaygroundComponent: () => PlaygroundComponent
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
|
|
36
|
+
// src/graph.component.ts
|
|
37
|
+
var import_core = require("@angular/core");
|
|
38
|
+
var import_graph_core = require("@3plate/graph-core");
|
|
39
|
+
var GraphComponent = class {
|
|
40
|
+
rootRef;
|
|
41
|
+
nodes;
|
|
42
|
+
edges;
|
|
43
|
+
history;
|
|
44
|
+
ingestion;
|
|
45
|
+
options;
|
|
46
|
+
events;
|
|
47
|
+
api = null;
|
|
48
|
+
rootId = `graph-${Math.random().toString(36).slice(2, 11)}`;
|
|
49
|
+
async ngOnInit() {
|
|
50
|
+
if (!this.rootRef?.nativeElement) return;
|
|
51
|
+
this.rootRef.nativeElement.id = this.rootId;
|
|
52
|
+
this.api = await (0, import_graph_core.graph)({
|
|
53
|
+
root: this.rootId,
|
|
54
|
+
nodes: this.nodes,
|
|
55
|
+
edges: this.edges,
|
|
56
|
+
history: this.history,
|
|
57
|
+
ingestion: this.ingestion,
|
|
58
|
+
options: this.options,
|
|
59
|
+
events: this.events
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
ngOnDestroy() {
|
|
63
|
+
if (this.api) {
|
|
64
|
+
this.api.destroy();
|
|
65
|
+
this.api = null;
|
|
66
|
+
}
|
|
67
|
+
if (this.rootRef?.nativeElement) {
|
|
68
|
+
const canvas = this.rootRef.nativeElement.querySelector("canvas, svg");
|
|
69
|
+
if (canvas) {
|
|
70
|
+
canvas.remove();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ngOnChanges(changes) {
|
|
75
|
+
if (!this.api) return;
|
|
76
|
+
if (changes["nodes"] || changes["edges"] || changes["history"] || changes["options"]) {
|
|
77
|
+
this.api.applyProps({
|
|
78
|
+
nodes: this.nodes,
|
|
79
|
+
edges: this.edges,
|
|
80
|
+
history: this.history,
|
|
81
|
+
options: this.options
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Get the underlying API instance */
|
|
86
|
+
getApi() {
|
|
87
|
+
return this.api;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
__decorateClass([
|
|
91
|
+
(0, import_core.ViewChild)("root", { static: true })
|
|
92
|
+
], GraphComponent.prototype, "rootRef", 2);
|
|
93
|
+
__decorateClass([
|
|
94
|
+
(0, import_core.Input)()
|
|
95
|
+
], GraphComponent.prototype, "nodes", 2);
|
|
96
|
+
__decorateClass([
|
|
97
|
+
(0, import_core.Input)()
|
|
98
|
+
], GraphComponent.prototype, "edges", 2);
|
|
99
|
+
__decorateClass([
|
|
100
|
+
(0, import_core.Input)()
|
|
101
|
+
], GraphComponent.prototype, "history", 2);
|
|
102
|
+
__decorateClass([
|
|
103
|
+
(0, import_core.Input)()
|
|
104
|
+
], GraphComponent.prototype, "ingestion", 2);
|
|
105
|
+
__decorateClass([
|
|
106
|
+
(0, import_core.Input)()
|
|
107
|
+
], GraphComponent.prototype, "options", 2);
|
|
108
|
+
__decorateClass([
|
|
109
|
+
(0, import_core.Input)()
|
|
110
|
+
], GraphComponent.prototype, "events", 2);
|
|
111
|
+
GraphComponent = __decorateClass([
|
|
112
|
+
(0, import_core.Component)({
|
|
113
|
+
selector: "g3p-graph",
|
|
114
|
+
standalone: true,
|
|
115
|
+
template: '<div #root style="width: 100%; height: 100%"></div>'
|
|
116
|
+
})
|
|
117
|
+
], GraphComponent);
|
|
118
|
+
|
|
119
|
+
// src/playground.component.ts
|
|
120
|
+
var import_core2 = require("@angular/core");
|
|
121
|
+
var import_graph_core2 = require("@3plate/graph-core");
|
|
122
|
+
var PlaygroundComponent = class {
|
|
123
|
+
rootRef;
|
|
124
|
+
examples = {};
|
|
125
|
+
defaultExample;
|
|
126
|
+
playground = null;
|
|
127
|
+
rootId = `playground-${Math.random().toString(36).slice(2, 11)}`;
|
|
128
|
+
async ngOnInit() {
|
|
129
|
+
if (!this.rootRef?.nativeElement) return;
|
|
130
|
+
this.rootRef.nativeElement.id = this.rootId;
|
|
131
|
+
this.playground = new import_graph_core2.Playground({
|
|
132
|
+
root: this.rootId,
|
|
133
|
+
examples: this.examples,
|
|
134
|
+
defaultExample: this.defaultExample
|
|
135
|
+
});
|
|
136
|
+
await this.playground.init();
|
|
137
|
+
}
|
|
138
|
+
ngOnDestroy() {
|
|
139
|
+
this.playground = null;
|
|
140
|
+
if (this.rootRef?.nativeElement) {
|
|
141
|
+
this.rootRef.nativeElement.innerHTML = "";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Get the underlying Playground instance */
|
|
145
|
+
getPlayground() {
|
|
146
|
+
return this.playground;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
__decorateClass([
|
|
150
|
+
(0, import_core2.ViewChild)("root", { static: true })
|
|
151
|
+
], PlaygroundComponent.prototype, "rootRef", 2);
|
|
152
|
+
__decorateClass([
|
|
153
|
+
(0, import_core2.Input)()
|
|
154
|
+
], PlaygroundComponent.prototype, "examples", 2);
|
|
155
|
+
__decorateClass([
|
|
156
|
+
(0, import_core2.Input)()
|
|
157
|
+
], PlaygroundComponent.prototype, "defaultExample", 2);
|
|
158
|
+
PlaygroundComponent = __decorateClass([
|
|
159
|
+
(0, import_core2.Component)({
|
|
160
|
+
selector: "g3p-playground",
|
|
161
|
+
standalone: true,
|
|
162
|
+
template: '<div #root style="width: 100%; height: 100%"></div>'
|
|
163
|
+
})
|
|
164
|
+
], PlaygroundComponent);
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
GraphComponent,
|
|
168
|
+
PlaygroundComponent
|
|
169
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/graph.component.ts
|
|
13
|
+
import {
|
|
14
|
+
Component,
|
|
15
|
+
Input,
|
|
16
|
+
ViewChild
|
|
17
|
+
} from "@angular/core";
|
|
18
|
+
import { graph } from "@3plate/graph-core";
|
|
19
|
+
var GraphComponent = class {
|
|
20
|
+
rootRef;
|
|
21
|
+
nodes;
|
|
22
|
+
edges;
|
|
23
|
+
history;
|
|
24
|
+
ingestion;
|
|
25
|
+
options;
|
|
26
|
+
events;
|
|
27
|
+
api = null;
|
|
28
|
+
rootId = `graph-${Math.random().toString(36).slice(2, 11)}`;
|
|
29
|
+
async ngOnInit() {
|
|
30
|
+
if (!this.rootRef?.nativeElement) return;
|
|
31
|
+
this.rootRef.nativeElement.id = this.rootId;
|
|
32
|
+
this.api = await graph({
|
|
33
|
+
root: this.rootId,
|
|
34
|
+
nodes: this.nodes,
|
|
35
|
+
edges: this.edges,
|
|
36
|
+
history: this.history,
|
|
37
|
+
ingestion: this.ingestion,
|
|
38
|
+
options: this.options,
|
|
39
|
+
events: this.events
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
ngOnDestroy() {
|
|
43
|
+
if (this.api) {
|
|
44
|
+
this.api.destroy();
|
|
45
|
+
this.api = null;
|
|
46
|
+
}
|
|
47
|
+
if (this.rootRef?.nativeElement) {
|
|
48
|
+
const canvas = this.rootRef.nativeElement.querySelector("canvas, svg");
|
|
49
|
+
if (canvas) {
|
|
50
|
+
canvas.remove();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
ngOnChanges(changes) {
|
|
55
|
+
if (!this.api) return;
|
|
56
|
+
if (changes["nodes"] || changes["edges"] || changes["history"] || changes["options"]) {
|
|
57
|
+
this.api.applyProps({
|
|
58
|
+
nodes: this.nodes,
|
|
59
|
+
edges: this.edges,
|
|
60
|
+
history: this.history,
|
|
61
|
+
options: this.options
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Get the underlying API instance */
|
|
66
|
+
getApi() {
|
|
67
|
+
return this.api;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
__decorateClass([
|
|
71
|
+
ViewChild("root", { static: true })
|
|
72
|
+
], GraphComponent.prototype, "rootRef", 2);
|
|
73
|
+
__decorateClass([
|
|
74
|
+
Input()
|
|
75
|
+
], GraphComponent.prototype, "nodes", 2);
|
|
76
|
+
__decorateClass([
|
|
77
|
+
Input()
|
|
78
|
+
], GraphComponent.prototype, "edges", 2);
|
|
79
|
+
__decorateClass([
|
|
80
|
+
Input()
|
|
81
|
+
], GraphComponent.prototype, "history", 2);
|
|
82
|
+
__decorateClass([
|
|
83
|
+
Input()
|
|
84
|
+
], GraphComponent.prototype, "ingestion", 2);
|
|
85
|
+
__decorateClass([
|
|
86
|
+
Input()
|
|
87
|
+
], GraphComponent.prototype, "options", 2);
|
|
88
|
+
__decorateClass([
|
|
89
|
+
Input()
|
|
90
|
+
], GraphComponent.prototype, "events", 2);
|
|
91
|
+
GraphComponent = __decorateClass([
|
|
92
|
+
Component({
|
|
93
|
+
selector: "g3p-graph",
|
|
94
|
+
standalone: true,
|
|
95
|
+
template: '<div #root style="width: 100%; height: 100%"></div>'
|
|
96
|
+
})
|
|
97
|
+
], GraphComponent);
|
|
98
|
+
|
|
99
|
+
// src/playground.component.ts
|
|
100
|
+
import {
|
|
101
|
+
Component as Component2,
|
|
102
|
+
Input as Input2,
|
|
103
|
+
ViewChild as ViewChild2
|
|
104
|
+
} from "@angular/core";
|
|
105
|
+
import { Playground as PlaygroundClass } from "@3plate/graph-core";
|
|
106
|
+
var PlaygroundComponent = class {
|
|
107
|
+
rootRef;
|
|
108
|
+
examples = {};
|
|
109
|
+
defaultExample;
|
|
110
|
+
playground = null;
|
|
111
|
+
rootId = `playground-${Math.random().toString(36).slice(2, 11)}`;
|
|
112
|
+
async ngOnInit() {
|
|
113
|
+
if (!this.rootRef?.nativeElement) return;
|
|
114
|
+
this.rootRef.nativeElement.id = this.rootId;
|
|
115
|
+
this.playground = new PlaygroundClass({
|
|
116
|
+
root: this.rootId,
|
|
117
|
+
examples: this.examples,
|
|
118
|
+
defaultExample: this.defaultExample
|
|
119
|
+
});
|
|
120
|
+
await this.playground.init();
|
|
121
|
+
}
|
|
122
|
+
ngOnDestroy() {
|
|
123
|
+
this.playground = null;
|
|
124
|
+
if (this.rootRef?.nativeElement) {
|
|
125
|
+
this.rootRef.nativeElement.innerHTML = "";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Get the underlying Playground instance */
|
|
129
|
+
getPlayground() {
|
|
130
|
+
return this.playground;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
__decorateClass([
|
|
134
|
+
ViewChild2("root", { static: true })
|
|
135
|
+
], PlaygroundComponent.prototype, "rootRef", 2);
|
|
136
|
+
__decorateClass([
|
|
137
|
+
Input2()
|
|
138
|
+
], PlaygroundComponent.prototype, "examples", 2);
|
|
139
|
+
__decorateClass([
|
|
140
|
+
Input2()
|
|
141
|
+
], PlaygroundComponent.prototype, "defaultExample", 2);
|
|
142
|
+
PlaygroundComponent = __decorateClass([
|
|
143
|
+
Component2({
|
|
144
|
+
selector: "g3p-playground",
|
|
145
|
+
standalone: true,
|
|
146
|
+
template: '<div #root style="width: 100%; height: 100%"></div>'
|
|
147
|
+
})
|
|
148
|
+
], PlaygroundComponent);
|
|
149
|
+
export {
|
|
150
|
+
GraphComponent,
|
|
151
|
+
PlaygroundComponent
|
|
152
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3plate/graph-angular",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@angular/core": "^19.0.0 || ^21.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@3plate/graph-core": "0.1.
|
|
23
|
+
"@3plate/graph-core": "0.1.9"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@angular/core": "^21.0.1",
|