@dxos/graph 0.8.2-staging.7ac8446 → 0.8.2
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/lib/browser/index.mjs +139 -98
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +137 -94
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +139 -98
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model.d.ts +32 -37
- package/dist/types/src/model.d.ts.map +1 -1
- package/dist/types/src/selection.d.ts +22 -0
- package/dist/types/src/selection.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +35 -36
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +0 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -18
- package/src/index.ts +1 -0
- package/src/model.test.ts +78 -10
- package/src/model.ts +72 -21
- package/src/selection.ts +70 -0
- package/src/types.ts +39 -29
- package/src/util.ts +0 -47
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// packages/common/graph/src/model.ts
|
|
4
|
+
import { effect } from "@preact/signals-core";
|
|
4
5
|
import { inspectCustom } from "@dxos/debug";
|
|
5
6
|
import { failedInvariant, invariant as invariant2 } from "@dxos/invariant";
|
|
6
|
-
import {
|
|
7
|
-
import { isNotFalsy, removeBy
|
|
7
|
+
import { live } from "@dxos/live-object";
|
|
8
|
+
import { isNotFalsy, removeBy } from "@dxos/util";
|
|
8
9
|
|
|
9
10
|
// packages/common/graph/src/util.ts
|
|
10
|
-
import { FormatEnum } from "@dxos/echo-schema";
|
|
11
11
|
import { invariant } from "@dxos/invariant";
|
|
12
|
-
import { getSchema, create } from "@dxos/live-object";
|
|
13
|
-
import { log } from "@dxos/log";
|
|
14
|
-
import { getSchemaProperties } from "@dxos/schema";
|
|
15
|
-
|
|
16
|
-
// packages/common/graph/src/types.ts
|
|
17
|
-
import { S } from "@dxos/echo-schema";
|
|
18
|
-
var BaseGraphNode = S.Struct({
|
|
19
|
-
id: S.String,
|
|
20
|
-
type: S.optional(S.String),
|
|
21
|
-
data: S.optional(S.Any)
|
|
22
|
-
});
|
|
23
|
-
var BaseGraphEdge = S.Struct({
|
|
24
|
-
id: S.String,
|
|
25
|
-
type: S.optional(S.String),
|
|
26
|
-
data: S.optional(S.Any),
|
|
27
|
-
source: S.String,
|
|
28
|
-
target: S.String
|
|
29
|
-
});
|
|
30
|
-
var ExtendableBaseGraphNode = S.extend(BaseGraphNode, S.Struct({}, {
|
|
31
|
-
key: S.String,
|
|
32
|
-
value: S.Any
|
|
33
|
-
}));
|
|
34
|
-
var Graph = S.Struct({
|
|
35
|
-
id: S.optional(S.String),
|
|
36
|
-
nodes: S.mutable(S.Array(ExtendableBaseGraphNode)),
|
|
37
|
-
edges: S.mutable(S.Array(BaseGraphEdge))
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// packages/common/graph/src/util.ts
|
|
41
12
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/graph/src/util.ts";
|
|
42
13
|
var KEY_REGEX = /\w+/;
|
|
43
14
|
var createEdgeId = ({ source, target, relation }) => {
|
|
44
15
|
invariant(source.match(KEY_REGEX), `invalid source: ${source}`, {
|
|
45
16
|
F: __dxlog_file,
|
|
46
|
-
L:
|
|
17
|
+
L: 13,
|
|
47
18
|
S: void 0,
|
|
48
19
|
A: [
|
|
49
20
|
"source.match(KEY_REGEX)",
|
|
@@ -52,7 +23,7 @@ var createEdgeId = ({ source, target, relation }) => {
|
|
|
52
23
|
});
|
|
53
24
|
invariant(target.match(KEY_REGEX), `invalid target: ${target}`, {
|
|
54
25
|
F: __dxlog_file,
|
|
55
|
-
L:
|
|
26
|
+
L: 14,
|
|
56
27
|
S: void 0,
|
|
57
28
|
A: [
|
|
58
29
|
"target.match(KEY_REGEX)",
|
|
@@ -69,7 +40,7 @@ var parseEdgeId = (id) => {
|
|
|
69
40
|
const [source, relation, target] = id.split("_");
|
|
70
41
|
invariant(source.length && target.length, void 0, {
|
|
71
42
|
F: __dxlog_file,
|
|
72
|
-
L:
|
|
43
|
+
L: 20,
|
|
73
44
|
S: void 0,
|
|
74
45
|
A: [
|
|
75
46
|
"source.length && target.length",
|
|
@@ -82,57 +53,12 @@ var parseEdgeId = (id) => {
|
|
|
82
53
|
target
|
|
83
54
|
};
|
|
84
55
|
};
|
|
85
|
-
var createGraph = (objects) => {
|
|
86
|
-
const graph = new GraphModel(create(Graph, {
|
|
87
|
-
nodes: [],
|
|
88
|
-
edges: []
|
|
89
|
-
}));
|
|
90
|
-
objects.forEach((object) => {
|
|
91
|
-
graph.addNode({
|
|
92
|
-
id: object.id,
|
|
93
|
-
type: object.typename,
|
|
94
|
-
data: object
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
objects.forEach((object) => {
|
|
98
|
-
const schema = getSchema(object);
|
|
99
|
-
if (!schema) {
|
|
100
|
-
log.info("no schema for object", {
|
|
101
|
-
id: object.id.slice(0, 8)
|
|
102
|
-
}, {
|
|
103
|
-
F: __dxlog_file,
|
|
104
|
-
L: 48,
|
|
105
|
-
S: void 0,
|
|
106
|
-
C: (f, a) => f(...a)
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
for (const prop of getSchemaProperties(schema.ast, object)) {
|
|
111
|
-
if (prop.format === FormatEnum.Ref) {
|
|
112
|
-
const source = object;
|
|
113
|
-
const target = object[prop.name]?.target;
|
|
114
|
-
if (target) {
|
|
115
|
-
graph.addEdge({
|
|
116
|
-
id: createEdgeId({
|
|
117
|
-
source: source.id,
|
|
118
|
-
target: target.id,
|
|
119
|
-
relation: String(prop.name)
|
|
120
|
-
}),
|
|
121
|
-
source: source.id,
|
|
122
|
-
target: target.id
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return graph;
|
|
129
|
-
};
|
|
130
56
|
|
|
131
57
|
// packages/common/graph/src/model.ts
|
|
132
58
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/graph/src/model.ts";
|
|
133
59
|
var ReadonlyGraphModel = class {
|
|
134
60
|
/**
|
|
135
|
-
* NOTE: Pass in simple Graph or
|
|
61
|
+
* NOTE: Pass in simple Graph or Live.
|
|
136
62
|
*/
|
|
137
63
|
constructor(graph) {
|
|
138
64
|
this._graph = graph ?? {
|
|
@@ -146,16 +72,11 @@ var ReadonlyGraphModel = class {
|
|
|
146
72
|
/**
|
|
147
73
|
* Return stable sorted JSON representation of graph.
|
|
148
74
|
*/
|
|
149
|
-
// TODO(burdon): Create separate toJson method with computed signal.
|
|
150
75
|
toJSON() {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
id,
|
|
156
|
-
nodes,
|
|
157
|
-
edges
|
|
158
|
-
});
|
|
76
|
+
return {
|
|
77
|
+
nodes: this.nodes.length,
|
|
78
|
+
edges: this.edges.length
|
|
79
|
+
};
|
|
159
80
|
}
|
|
160
81
|
get graph() {
|
|
161
82
|
return this._graph;
|
|
@@ -231,7 +152,7 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
231
152
|
addNode(node) {
|
|
232
153
|
invariant2(node.id, "ID is required", {
|
|
233
154
|
F: __dxlog_file2,
|
|
234
|
-
L:
|
|
155
|
+
L: 157,
|
|
235
156
|
S: this,
|
|
236
157
|
A: [
|
|
237
158
|
"node.id",
|
|
@@ -240,7 +161,7 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
240
161
|
});
|
|
241
162
|
invariant2(!this.findNode(node.id), `node already exists: ${node.id}`, {
|
|
242
163
|
F: __dxlog_file2,
|
|
243
|
-
L:
|
|
164
|
+
L: 158,
|
|
244
165
|
S: this,
|
|
245
166
|
A: [
|
|
246
167
|
"!this.findNode(node.id)",
|
|
@@ -256,7 +177,7 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
256
177
|
addEdge(edge) {
|
|
257
178
|
invariant2(edge.source, void 0, {
|
|
258
179
|
F: __dxlog_file2,
|
|
259
|
-
L:
|
|
180
|
+
L: 168,
|
|
260
181
|
S: this,
|
|
261
182
|
A: [
|
|
262
183
|
"edge.source",
|
|
@@ -265,7 +186,7 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
265
186
|
});
|
|
266
187
|
invariant2(edge.target, void 0, {
|
|
267
188
|
F: __dxlog_file2,
|
|
268
|
-
L:
|
|
189
|
+
L: 169,
|
|
269
190
|
S: this,
|
|
270
191
|
A: [
|
|
271
192
|
"edge.target",
|
|
@@ -280,7 +201,7 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
280
201
|
}
|
|
281
202
|
invariant2(!this.findNode(edge.id), void 0, {
|
|
282
203
|
F: __dxlog_file2,
|
|
283
|
-
L:
|
|
204
|
+
L: 174,
|
|
284
205
|
S: this,
|
|
285
206
|
A: [
|
|
286
207
|
"!this.findNode(edge.id!)",
|
|
@@ -294,8 +215,8 @@ var AbstractGraphModel = class extends ReadonlyGraphModel {
|
|
|
294
215
|
return edges.map((edge) => this.addEdge(edge));
|
|
295
216
|
}
|
|
296
217
|
removeNode(id) {
|
|
297
|
-
const nodes = removeBy(this._graph.nodes, (node) => node.id === id);
|
|
298
218
|
const edges = removeBy(this._graph.edges, (edge) => edge.source === id || edge.target === id);
|
|
219
|
+
const nodes = removeBy(this._graph.nodes, (node) => node.id === id);
|
|
299
220
|
return this.copy({
|
|
300
221
|
nodes,
|
|
301
222
|
edges
|
|
@@ -359,12 +280,130 @@ var GraphModel = class _GraphModel extends AbstractGraphModel {
|
|
|
359
280
|
});
|
|
360
281
|
}
|
|
361
282
|
};
|
|
283
|
+
var subscribe = (model, cb, fire = false) => {
|
|
284
|
+
if (fire) {
|
|
285
|
+
cb(model, model.graph);
|
|
286
|
+
}
|
|
287
|
+
return effect(() => {
|
|
288
|
+
cb(model, model.graph);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
var ReactiveGraphModel = class _ReactiveGraphModel extends GraphModel {
|
|
292
|
+
constructor(graph) {
|
|
293
|
+
super(live({
|
|
294
|
+
nodes: graph?.nodes ?? [],
|
|
295
|
+
edges: graph?.edges ?? []
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
copy(graph) {
|
|
299
|
+
return new _ReactiveGraphModel(graph);
|
|
300
|
+
}
|
|
301
|
+
subscribe(cb, fire = false) {
|
|
302
|
+
return subscribe(this, cb, fire);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
362
305
|
var GraphBuilder = class extends AbstractGraphBuilder {
|
|
363
306
|
call(cb) {
|
|
364
307
|
cb(this);
|
|
365
308
|
return this;
|
|
366
309
|
}
|
|
367
310
|
};
|
|
311
|
+
|
|
312
|
+
// packages/common/graph/src/selection.ts
|
|
313
|
+
import { computed, signal } from "@preact/signals-core";
|
|
314
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
315
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/graph/src/selection.ts";
|
|
316
|
+
var SelectionModel = class {
|
|
317
|
+
constructor(_singleSelect = false) {
|
|
318
|
+
this._singleSelect = _singleSelect;
|
|
319
|
+
this._selected = signal(/* @__PURE__ */ new Set());
|
|
320
|
+
this._selectedIds = computed(() => Array.from(this._selected.value.values()));
|
|
321
|
+
}
|
|
322
|
+
toJSON() {
|
|
323
|
+
return {
|
|
324
|
+
selected: Array.from(this._selected.value.values())
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
get size() {
|
|
328
|
+
return this._selected.value.size;
|
|
329
|
+
}
|
|
330
|
+
get selected() {
|
|
331
|
+
return this._selectedIds;
|
|
332
|
+
}
|
|
333
|
+
contains(id) {
|
|
334
|
+
return this._selected.value.has(id);
|
|
335
|
+
}
|
|
336
|
+
clear() {
|
|
337
|
+
this._selected.value = /* @__PURE__ */ new Set();
|
|
338
|
+
}
|
|
339
|
+
add(id) {
|
|
340
|
+
invariant3(id, void 0, {
|
|
341
|
+
F: __dxlog_file3,
|
|
342
|
+
L: 41,
|
|
343
|
+
S: this,
|
|
344
|
+
A: [
|
|
345
|
+
"id",
|
|
346
|
+
""
|
|
347
|
+
]
|
|
348
|
+
});
|
|
349
|
+
this._selected.value = new Set(this._singleSelect ? [
|
|
350
|
+
id
|
|
351
|
+
] : [
|
|
352
|
+
...Array.from(this._selected.value.values()),
|
|
353
|
+
id
|
|
354
|
+
]);
|
|
355
|
+
}
|
|
356
|
+
remove(id) {
|
|
357
|
+
invariant3(id, void 0, {
|
|
358
|
+
F: __dxlog_file3,
|
|
359
|
+
L: 48,
|
|
360
|
+
S: this,
|
|
361
|
+
A: [
|
|
362
|
+
"id",
|
|
363
|
+
""
|
|
364
|
+
]
|
|
365
|
+
});
|
|
366
|
+
this._selected.value = new Set(Array.from(this._selected.value.values()).filter((_id) => _id !== id));
|
|
367
|
+
}
|
|
368
|
+
// TODO(burdon): Handle single select.
|
|
369
|
+
setSelected(ids, shift = false) {
|
|
370
|
+
this._selected.value = /* @__PURE__ */ new Set([
|
|
371
|
+
...shift ? Array.from(this._selected.value.values()) : [],
|
|
372
|
+
...ids
|
|
373
|
+
]);
|
|
374
|
+
}
|
|
375
|
+
toggleSelected(ids, shift = false) {
|
|
376
|
+
const set = new Set(shift ? Array.from(this._selected.value.values()) : void 0);
|
|
377
|
+
ids.forEach((id) => {
|
|
378
|
+
if (this._selected.value.has(id)) {
|
|
379
|
+
set.delete(id);
|
|
380
|
+
} else {
|
|
381
|
+
set.add(id);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
this._selected.value = set;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// packages/common/graph/src/types.ts
|
|
389
|
+
import { Schema } from "effect";
|
|
390
|
+
var BaseGraphNode = Schema.Struct({
|
|
391
|
+
id: Schema.String,
|
|
392
|
+
type: Schema.optional(Schema.String),
|
|
393
|
+
data: Schema.optional(Schema.Any)
|
|
394
|
+
});
|
|
395
|
+
var BaseGraphEdge = Schema.Struct({
|
|
396
|
+
id: Schema.String,
|
|
397
|
+
type: Schema.optional(Schema.String),
|
|
398
|
+
source: Schema.String,
|
|
399
|
+
target: Schema.String,
|
|
400
|
+
data: Schema.optional(Schema.Any)
|
|
401
|
+
});
|
|
402
|
+
var Graph = Schema.Struct({
|
|
403
|
+
id: Schema.optional(Schema.String),
|
|
404
|
+
nodes: Schema.mutable(Schema.Array(BaseGraphNode)),
|
|
405
|
+
edges: Schema.mutable(Schema.Array(BaseGraphEdge))
|
|
406
|
+
});
|
|
368
407
|
export {
|
|
369
408
|
AbstractGraphBuilder,
|
|
370
409
|
AbstractGraphModel,
|
|
@@ -373,9 +412,11 @@ export {
|
|
|
373
412
|
Graph,
|
|
374
413
|
GraphBuilder,
|
|
375
414
|
GraphModel,
|
|
415
|
+
ReactiveGraphModel,
|
|
376
416
|
ReadonlyGraphModel,
|
|
417
|
+
SelectionModel,
|
|
377
418
|
createEdgeId,
|
|
378
|
-
|
|
379
|
-
|
|
419
|
+
parseEdgeId,
|
|
420
|
+
subscribe
|
|
380
421
|
};
|
|
381
422
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/model.ts", "../../../src/util.ts", "../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { inspectCustom } from '@dxos/debug';\nimport { failedInvariant, invariant } from '@dxos/invariant';\nimport { getSnapshot } from '@dxos/live-object';\nimport { type MakeOptional, isNotFalsy, removeBy, stripUndefined } from '@dxos/util';\n\nimport { type Graph, type GraphNode, type GraphEdge, type BaseGraphNode, type BaseGraphEdge } from './types';\nimport { createEdgeId } from './util';\n\n/**\n * Wrapper class contains reactive nodes and edges.\n */\nexport class ReadonlyGraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> {\n protected readonly _graph: Graph;\n\n /**\n * NOTE: Pass in simple Graph or ReactiveObject.\n */\n constructor(graph?: Graph) {\n this._graph = graph ?? { nodes: [], edges: [] };\n }\n\n [inspectCustom]() {\n return this.toJSON();\n }\n\n /**\n * Return stable sorted JSON representation of graph.\n */\n // TODO(burdon): Create separate toJson method with computed signal.\n toJSON() {\n const { id, nodes, edges } = getSnapshot(this._graph);\n nodes.sort(({ id: a }, { id: b }) => a.localeCompare(b));\n edges.sort(({ id: a }, { id: b }) => a.localeCompare(b));\n return stripUndefined({ id, nodes, edges });\n }\n\n get graph(): Graph {\n return this._graph;\n }\n\n get nodes(): Node[] {\n return this._graph.nodes as Node[];\n }\n\n get edges(): Edge[] {\n return this._graph.edges as Edge[];\n }\n\n //\n // Nodes\n //\n\n findNode(id: string): Node | undefined {\n return this.nodes.find((node) => node.id === id);\n }\n\n getNode(id: string): Node {\n return this.findNode(id) ?? failedInvariant();\n }\n\n filterNodes({ type }: Partial<GraphNode> = {}): Node[] {\n return this.nodes.filter((node) => !type || type === node.type);\n }\n\n //\n // Edges\n //\n\n findEdge(id: string): Edge | undefined {\n return this.edges.find((edge) => edge.id === id);\n }\n\n getEdge(id: string): Edge {\n return this.findEdge(id) ?? failedInvariant();\n }\n\n filterEdges({ type, source, target }: Partial<GraphEdge> = {}): Edge[] {\n return this.edges.filter(\n (edge) =>\n (!type || type === edge.type) && (!source || source === edge.source) && (!target || target === edge.target),\n );\n }\n\n //\n // Traverse\n //\n\n traverse(root: Node): Node[] {\n return this._traverse(root);\n }\n\n private _traverse(root: Node, visited: Set<string> = new Set()): Node[] {\n if (visited.has(root.id)) {\n return [];\n }\n\n visited.add(root.id);\n const targets = this.filterEdges({ source: root.id })\n .map((edge) => this.getNode(edge.target))\n .filter(isNotFalsy);\n\n return [root, ...targets.flatMap((target) => this._traverse(target, visited))];\n }\n}\n\n/**\n * Typed wrapper.\n */\nexport abstract class AbstractGraphModel<\n Node extends BaseGraphNode,\n Edge extends BaseGraphEdge,\n Model extends AbstractGraphModel<Node, Edge, Model, Builder>,\n Builder extends AbstractGraphBuilder<Node, Edge, Model>,\n> extends ReadonlyGraphModel<Node, Edge> {\n /**\n * Allows chaining.\n */\n abstract get builder(): Builder;\n\n /**\n * Shallow copy of provided graph.\n */\n abstract copy(graph?: Partial<Graph>): Model;\n\n clear(): this {\n this._graph.nodes.length = 0;\n this._graph.edges.length = 0;\n return this;\n }\n\n addGraph(graph: Model): this {\n this.addNodes(graph.nodes);\n this.addEdges(graph.edges);\n return this;\n }\n\n addGraphs(graphs: Model[]): this {\n graphs.forEach((graph) => {\n this.addNodes(graph.nodes);\n this.addEdges(graph.edges);\n });\n return this;\n }\n\n addNode(node: Node): Node {\n invariant(node.id, 'ID is required');\n invariant(!this.findNode(node.id), `node already exists: ${node.id}`);\n this._graph.nodes.push(node);\n return node;\n }\n\n addNodes(nodes: Node[]): Node[] {\n return nodes.map((node) => this.addNode(node));\n }\n\n addEdge(edge: MakeOptional<Edge, 'id'>): Edge {\n invariant(edge.source);\n invariant(edge.target);\n if (!edge.id) {\n // TODO(burdon): Generate random id.\n edge = { id: createEdgeId(edge), ...edge };\n }\n invariant(!this.findNode(edge.id!));\n this._graph.edges.push(edge as Edge);\n return edge as Edge;\n }\n\n addEdges(edges: Edge[]): Edge[] {\n return edges.map((edge) => this.addEdge(edge));\n }\n\n removeNode(id: string): Model {\n const nodes = removeBy<Node>(this._graph.nodes as Node[], (node) => node.id === id);\n const edges = removeBy<Edge>(this._graph.edges as Edge[], (edge) => edge.source === id || edge.target === id);\n return this.copy({ nodes, edges });\n }\n\n removeNodes(ids: string[]): Model {\n const graphs = ids.map((id) => this.removeNode(id));\n return this.copy().addGraphs(graphs);\n }\n\n removeEdge(id: string): Model {\n const edges = removeBy<Edge>(this._graph.edges as Edge[], (edge) => edge.id === id);\n return this.copy({ nodes: [], edges });\n }\n\n removeEdges(ids: string[]): Model {\n const graphs = ids.map((id) => this.removeEdge(id));\n return this.copy().addGraphs(graphs);\n }\n}\n\n/**\n * Chainable wrapper\n */\nexport abstract class AbstractGraphBuilder<\n Node extends BaseGraphNode,\n Edge extends BaseGraphEdge,\n Model extends GraphModel<Node, Edge>,\n> {\n constructor(protected readonly _model: Model) {}\n\n get model(): Model {\n return this._model;\n }\n\n call(cb: (builder: this) => void): this {\n cb(this);\n return this;\n }\n\n getNode(id: string): Node {\n return this.model.getNode(id);\n }\n\n addNode(node: Node): this {\n this._model.addNode(node);\n return this;\n }\n\n addEdge(edge: MakeOptional<Edge, 'id'>): this {\n this._model.addEdge(edge);\n return this;\n }\n\n addNodes(nodes: Node[]): this {\n this._model.addNodes(nodes);\n return this;\n }\n\n addEdges(edges: Edge[]): this {\n this._model.addEdges(edges);\n return this;\n }\n}\n\nexport class GraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> extends AbstractGraphModel<Node, Edge, GraphModel<Node, Edge>, GraphBuilder<Node, Edge>> {\n override get builder() {\n return new GraphBuilder<Node, Edge>(this);\n }\n\n override copy(graph?: Partial<Graph>) {\n return new GraphModel<Node, Edge>({ nodes: graph?.nodes ?? [], edges: graph?.edges ?? [] });\n }\n}\n\nexport class GraphBuilder<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> extends AbstractGraphBuilder<Node, Edge, GraphModel<Node, Edge>> {\n override call(cb: (builder: this) => void) {\n cb(this);\n return this;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { FormatEnum } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { getSchema, create } from '@dxos/live-object';\nimport { log } from '@dxos/log';\nimport { getSchemaProperties } from '@dxos/schema';\n\nimport { GraphModel } from './model';\nimport { Graph, type GraphNode } from './types';\n\nconst KEY_REGEX = /\\w+/;\n\n// NOTE: The `relation` is different from the `type`.\ntype EdgeMeta = { source: string; target: string; relation?: string };\n\nexport const createEdgeId = ({ source, target, relation }: EdgeMeta) => {\n invariant(source.match(KEY_REGEX), `invalid source: ${source}`);\n invariant(target.match(KEY_REGEX), `invalid target: ${target}`);\n return [source, relation, target].join('_');\n};\n\nexport const parseEdgeId = (id: string): EdgeMeta => {\n const [source, relation, target] = id.split('_');\n invariant(source.length && target.length);\n return { source, relation: relation.length ? relation : undefined, target };\n};\n\n/**\n * Creates a new reactive graph from a set of ECHO objects.\n * References are mapped onto graph edges.\n */\nexport const createGraph = (objects: ReactiveEchoObject<any>[]): GraphModel<GraphNode<ReactiveEchoObject<any>>> => {\n const graph = new GraphModel<GraphNode<ReactiveEchoObject<any>>>(create(Graph, { nodes: [], edges: [] }));\n\n // Map objects.\n objects.forEach((object) => {\n graph.addNode({ id: object.id, type: object.typename, data: object });\n });\n\n // Find references.\n objects.forEach((object) => {\n const schema = getSchema(object);\n if (!schema) {\n log.info('no schema for object', { id: object.id.slice(0, 8) });\n return;\n }\n\n // Parse schema to follow referenced objects.\n for (const prop of getSchemaProperties(schema.ast, object)) {\n if (prop.format === FormatEnum.Ref) {\n const source = object;\n const target = object[prop.name]?.target;\n if (target) {\n graph.addEdge({\n id: createEdgeId({ source: source.id, target: target.id, relation: String(prop.name) }),\n source: source.id,\n target: target.id,\n });\n }\n }\n }\n });\n\n return graph;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\nimport { type Specialize } from '@dxos/util';\n\nexport const BaseGraphNode = S.Struct({\n id: S.String,\n type: S.optional(S.String),\n data: S.optional(S.Any),\n});\n\n/** Raw base type. */\nexport type BaseGraphNode = S.Schema.Type<typeof BaseGraphNode>;\n\n/** Typed node data. */\nexport type GraphNode<Data = any, Optional extends boolean = false> = Specialize<\n BaseGraphNode,\n Optional extends true ? { data?: Data } : { data: Data }\n>;\n\nexport declare namespace GraphNode {\n export type Optional<T = any> = GraphNode<T, true>;\n}\n\nexport const BaseGraphEdge = S.Struct({\n id: S.String,\n type: S.optional(S.String),\n data: S.optional(S.Any),\n source: S.String,\n target: S.String,\n});\n\n/** Raw base type. */\nexport type BaseGraphEdge = S.Schema.Type<typeof BaseGraphEdge>;\n\n/** Typed edge data. */\nexport type GraphEdge<Data = any, Optional extends boolean = false> = Specialize<\n BaseGraphEdge,\n Optional extends true ? { data?: Data } : { data: Data }\n>;\n\nexport declare namespace GraphEdge {\n export type Optional<T = any> = GraphEdge<T, true>;\n}\n\n/**\n * Allows any additional properties on graph nodes.\n */\nconst ExtendableBaseGraphNode = S.extend(BaseGraphNode, S.Struct({}, { key: S.String, value: S.Any }));\n\n/**\n * Generic graph.\n */\nexport const Graph = S.Struct({\n id: S.optional(S.String),\n nodes: S.mutable(S.Array(ExtendableBaseGraphNode)),\n edges: S.mutable(S.Array(BaseGraphEdge)),\n});\n\nexport type Graph = S.Schema.Type<typeof Graph>;\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,qBAAqB;AAC9B,SAASC,iBAAiBC,aAAAA,kBAAiB;AAC3C,
|
|
6
|
-
"names": ["inspectCustom", "failedInvariant", "invariant", "
|
|
3
|
+
"sources": ["../../../src/model.ts", "../../../src/util.ts", "../../../src/selection.ts", "../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\n\nimport { inspectCustom } from '@dxos/debug';\nimport { failedInvariant, invariant } from '@dxos/invariant';\nimport { type Live, live } from '@dxos/live-object';\nimport { type MakeOptional, isNotFalsy, removeBy } from '@dxos/util';\n\nimport { type BaseGraphEdge, type BaseGraphNode, type Graph, type GraphEdge, type GraphNode } from './types';\nimport { createEdgeId } from './util';\n\n/**\n * Readonly Graph wrapper.\n */\nexport class ReadonlyGraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> {\n protected readonly _graph: Graph;\n\n /**\n * NOTE: Pass in simple Graph or Live.\n */\n constructor(graph?: Graph) {\n this._graph = graph ?? {\n nodes: [],\n edges: [],\n };\n }\n\n [inspectCustom]() {\n return this.toJSON();\n }\n\n /**\n * Return stable sorted JSON representation of graph.\n */\n toJSON() {\n return {\n nodes: this.nodes.length,\n edges: this.edges.length,\n };\n }\n\n get graph(): Graph {\n return this._graph;\n }\n\n get nodes(): Node[] {\n return this._graph.nodes as Node[];\n }\n\n get edges(): Edge[] {\n return this._graph.edges as Edge[];\n }\n\n //\n // Nodes\n //\n\n findNode(id: string): Node | undefined {\n return this.nodes.find((node) => node.id === id);\n }\n\n getNode(id: string): Node {\n return this.findNode(id) ?? failedInvariant();\n }\n\n filterNodes({ type }: Partial<GraphNode.Any> = {}): Node[] {\n return this.nodes.filter((node) => !type || type === node.type);\n }\n\n //\n // Edges\n //\n\n findEdge(id: string): Edge | undefined {\n return this.edges.find((edge) => edge.id === id);\n }\n\n getEdge(id: string): Edge {\n return this.findEdge(id) ?? failedInvariant();\n }\n\n filterEdges({ type, source, target }: Partial<GraphEdge> = {}): Edge[] {\n return this.edges.filter(\n (edge) =>\n (!type || type === edge.type) && (!source || source === edge.source) && (!target || target === edge.target),\n );\n }\n\n //\n // Traverse\n //\n\n traverse(root: Node): Node[] {\n return this._traverse(root);\n }\n\n private _traverse(root: Node, visited: Set<string> = new Set()): Node[] {\n if (visited.has(root.id)) {\n return [];\n }\n\n visited.add(root.id);\n const targets = this.filterEdges({ source: root.id })\n .map((edge) => this.getNode(edge.target))\n .filter(isNotFalsy);\n\n return [root, ...targets.flatMap((target) => this._traverse(target, visited))];\n }\n}\n\n/**\n * Mutable Graph wrapper.\n */\nexport abstract class AbstractGraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n Model extends AbstractGraphModel<Node, Edge, Model, Builder> = any,\n Builder extends AbstractGraphBuilder<Node, Edge, Model> = AbstractGraphBuilder<Node, Edge, Model>,\n> extends ReadonlyGraphModel<Node, Edge> {\n /**\n * Allows chaining.\n */\n abstract get builder(): Builder;\n\n /**\n * Shallow copy of provided graph.\n */\n abstract copy(graph?: Partial<Graph>): Model;\n\n clear(): this {\n this._graph.nodes.length = 0;\n this._graph.edges.length = 0;\n return this;\n }\n\n addGraph(graph: Model): this {\n this.addNodes(graph.nodes);\n this.addEdges(graph.edges);\n return this;\n }\n\n addGraphs(graphs: Model[]): this {\n graphs.forEach((graph) => {\n this.addNodes(graph.nodes);\n this.addEdges(graph.edges);\n });\n return this;\n }\n\n addNode(node: Node): Node {\n invariant(node.id, 'ID is required');\n invariant(!this.findNode(node.id), `node already exists: ${node.id}`);\n this._graph.nodes.push(node);\n return node;\n }\n\n addNodes(nodes: Node[]): Node[] {\n return nodes.map((node) => this.addNode(node));\n }\n\n addEdge(edge: MakeOptional<Edge, 'id'>): Edge {\n invariant(edge.source);\n invariant(edge.target);\n if (!edge.id) {\n // TODO(burdon): Generate random id.\n edge = { id: createEdgeId(edge), ...edge };\n }\n invariant(!this.findNode(edge.id!));\n this._graph.edges.push(edge as Edge);\n return edge as Edge;\n }\n\n addEdges(edges: Edge[]): Edge[] {\n return edges.map((edge) => this.addEdge(edge));\n }\n\n removeNode(id: string): Model {\n const edges = removeBy<Edge>(this._graph.edges as Edge[], (edge) => edge.source === id || edge.target === id);\n const nodes = removeBy<Node>(this._graph.nodes as Node[], (node) => node.id === id);\n return this.copy({ nodes, edges });\n }\n\n removeNodes(ids: string[]): Model {\n const graphs = ids.map((id) => this.removeNode(id));\n return this.copy().addGraphs(graphs);\n }\n\n removeEdge(id: string): Model {\n const edges = removeBy<Edge>(this._graph.edges as Edge[], (edge) => edge.id === id);\n return this.copy({ nodes: [], edges });\n }\n\n removeEdges(ids: string[]): Model {\n const graphs = ids.map((id) => this.removeEdge(id));\n return this.copy().addGraphs(graphs);\n }\n}\n\n/**\n * Chainable builder wrapper\n */\nexport abstract class AbstractGraphBuilder<\n Node extends BaseGraphNode,\n Edge extends BaseGraphEdge,\n Model extends GraphModel<Node, Edge>,\n> {\n constructor(protected readonly _model: Model) {}\n\n get model(): Model {\n return this._model;\n }\n\n call(cb: (builder: this) => void): this {\n cb(this);\n return this;\n }\n\n getNode(id: string): Node {\n return this.model.getNode(id);\n }\n\n addNode(node: Node): this {\n this._model.addNode(node);\n return this;\n }\n\n addEdge(edge: MakeOptional<Edge, 'id'>): this {\n this._model.addEdge(edge);\n return this;\n }\n\n addNodes(nodes: Node[]): this {\n this._model.addNodes(nodes);\n return this;\n }\n\n addEdges(edges: Edge[]): this {\n this._model.addEdges(edges);\n return this;\n }\n}\n\n/**\n * Basic model.\n */\nexport class GraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> extends AbstractGraphModel<Node, Edge, GraphModel<Node, Edge>, GraphBuilder<Node, Edge>> {\n override get builder() {\n return new GraphBuilder<Node, Edge>(this);\n }\n\n override copy(graph?: Partial<Graph>): GraphModel<Node, Edge> {\n return new GraphModel<Node, Edge>({ nodes: graph?.nodes ?? [], edges: graph?.edges ?? [] });\n }\n}\n\nexport type GraphModelSubscription = (model: GraphModel, graph: Live<Graph>) => void;\n\n/**\n * Subscription.\n * NOTE: Requires `registerSignalsRuntime` to be called.\n */\nexport const subscribe = (model: GraphModel, cb: GraphModelSubscription, fire = false) => {\n if (fire) {\n cb(model, model.graph);\n }\n\n return effect(() => {\n cb(model, model.graph); // TODO(burdon): This won't work unless model.graph is reactive.\n });\n};\n\n/**\n * Basic reactive model.\n */\nexport class ReactiveGraphModel<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> extends GraphModel<Node, Edge> {\n constructor(graph?: Partial<Graph>) {\n super(\n live({\n nodes: graph?.nodes ?? [],\n edges: graph?.edges ?? [],\n }),\n );\n }\n\n override copy(graph?: Partial<Graph>): ReactiveGraphModel<Node, Edge> {\n return new ReactiveGraphModel<Node, Edge>(graph);\n }\n\n subscribe(cb: GraphModelSubscription, fire = false): () => void {\n return subscribe(this, cb, fire);\n }\n}\n\n/**\n * Basic builder.\n */\nexport class GraphBuilder<\n Node extends BaseGraphNode = BaseGraphNode,\n Edge extends BaseGraphEdge = BaseGraphEdge,\n> extends AbstractGraphBuilder<Node, Edge, GraphModel<Node, Edge>> {\n override call(cb: (builder: this) => void): this {\n cb(this);\n return this;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\n\nconst KEY_REGEX = /\\w+/;\n\n// NOTE: The `relation` is different from the `type`.\ntype EdgeMeta = { source: string; target: string; relation?: string };\n\nexport const createEdgeId = ({ source, target, relation }: EdgeMeta) => {\n invariant(source.match(KEY_REGEX), `invalid source: ${source}`);\n invariant(target.match(KEY_REGEX), `invalid target: ${target}`);\n return [source, relation, target].join('_');\n};\n\nexport const parseEdgeId = (id: string): EdgeMeta => {\n const [source, relation, target] = id.split('_');\n invariant(source.length && target.length);\n return { source, relation: relation.length ? relation : undefined, target };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { computed, signal, type ReadonlySignal, type Signal } from '@preact/signals-core';\n\nimport { invariant } from '@dxos/invariant';\n\n/**\n * Reactive selection model.\n */\nexport class SelectionModel {\n private readonly _selected: Signal<Set<string>> = signal(new Set<string>());\n private readonly _selectedIds = computed(() => Array.from(this._selected.value.values()));\n\n constructor(private readonly _singleSelect: boolean = false) {}\n\n toJSON(): { selected: string[] } {\n return {\n selected: Array.from(this._selected.value.values()),\n };\n }\n\n get size(): number {\n return this._selected.value.size;\n }\n\n get selected(): ReadonlySignal<string[]> {\n return this._selectedIds;\n }\n\n contains(id: string): boolean {\n return this._selected.value.has(id);\n }\n\n clear(): void {\n this._selected.value = new Set();\n }\n\n add(id: string): void {\n invariant(id);\n this._selected.value = new Set<string>(\n this._singleSelect ? [id] : [...Array.from(this._selected.value.values()), id],\n );\n }\n\n remove(id: string): void {\n invariant(id);\n this._selected.value = new Set<string>(Array.from(this._selected.value.values()).filter((_id) => _id !== id));\n }\n\n // TODO(burdon): Handle single select.\n\n setSelected(ids: string[], shift = false): void {\n this._selected.value = new Set([...(shift ? Array.from(this._selected.value.values()) : []), ...ids]);\n }\n\n toggleSelected(ids: string[], shift = false): void {\n const set = new Set<string>(shift ? Array.from(this._selected.value.values()) : undefined);\n ids.forEach((id) => {\n if (this._selected.value.has(id)) {\n set.delete(id);\n } else {\n set.add(id);\n }\n });\n\n this._selected.value = set;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { type Specialize } from '@dxos/util';\n\n//\n// Node\n//\n\n// TODO(burdon): Make type extensible (i.e., not dependent on `data` property)?\nexport const BaseGraphNode = Schema.Struct({\n id: Schema.String,\n type: Schema.optional(Schema.String),\n data: Schema.optional(Schema.Any),\n});\n\n/** Raw base type. */\nexport type BaseGraphNode = Schema.Schema.Type<typeof BaseGraphNode>;\n\n/** Typed node data. */\ntype GraphNode<Data = any, Optional extends boolean = false> = Specialize<\n BaseGraphNode,\n Optional extends true ? { data?: Data } : { data: Data }\n>;\n\nexport declare namespace GraphNode {\n export type Any = GraphNode<any, true>;\n export type Optional<Data = any> = GraphNode<Data, true>;\n export type Required<Data = any> = GraphNode<Data, false>;\n}\n\n//\n// Edge\n//\n\nexport const BaseGraphEdge = Schema.Struct({\n id: Schema.String,\n type: Schema.optional(Schema.String),\n source: Schema.String,\n target: Schema.String,\n data: Schema.optional(Schema.Any),\n});\n\n/** Raw base type. */\nexport type BaseGraphEdge = Schema.Schema.Type<typeof BaseGraphEdge>;\n\n/** Typed edge data. */\nexport type GraphEdge<Data = any, Optional extends boolean = false> = Specialize<\n BaseGraphEdge,\n Optional extends true ? { data?: Data } : { data: Data }\n>;\n\nexport declare namespace GraphEdge {\n export type Any = GraphEdge<any, true>;\n export type Optional<Data = any> = GraphEdge<Data, true>;\n export type Required<Data = any> = GraphEdge<Data, false>;\n}\n\n//\n// Graph\n//\n\nexport const Graph = Schema.Struct({\n id: Schema.optional(Schema.String),\n nodes: Schema.mutable(Schema.Array(BaseGraphNode)),\n edges: Schema.mutable(Schema.Array(BaseGraphEdge)),\n});\n\nexport type Graph = Schema.Schema.Type<typeof Graph>;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiBC,aAAAA,kBAAiB;AAC3C,SAAoBC,YAAY;AAChC,SAA4BC,YAAYC,gBAAgB;;;ACLxD,SAASC,iBAAiB;;AAE1B,IAAMC,YAAY;AAKX,IAAMC,eAAe,CAAC,EAAEC,QAAQC,QAAQC,SAAQ,MAAY;AACjEL,YAAUG,OAAOG,MAAML,SAAAA,GAAY,mBAAmBE,MAAAA,IAAQ;;;;;;;;;AAC9DH,YAAUI,OAAOE,MAAML,SAAAA,GAAY,mBAAmBG,MAAAA,IAAQ;;;;;;;;;AAC9D,SAAO;IAACD;IAAQE;IAAUD;IAAQG,KAAK,GAAA;AACzC;AAEO,IAAMC,cAAc,CAACC,OAAAA;AAC1B,QAAM,CAACN,QAAQE,UAAUD,MAAAA,IAAUK,GAAGC,MAAM,GAAA;AAC5CV,YAAUG,OAAOQ,UAAUP,OAAOO,QAAM,QAAA;;;;;;;;;AACxC,SAAO;IAAER;IAAQE,UAAUA,SAASM,SAASN,WAAWO;IAAWR;EAAO;AAC5E;;;;ADJO,IAAMS,qBAAN,MAAMA;;;;EASX,YAAYC,OAAe;AACzB,SAAKC,SAASD,SAAS;MACrBE,OAAO,CAAA;MACPC,OAAO,CAAA;IACT;EACF;EAEA,CAACC,aAAAA,IAAiB;AAChB,WAAO,KAAKC,OAAM;EACpB;;;;EAKAA,SA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KAAKJ,UAAUK,MAAMC,OAAM,CAAA,IAAMiB,MAAAA;AAChFJ,QAAIK,QAAQ,CAACb,OAAAA;AACX,UAAI,KAAKX,UAAUK,MAAMO,IAAID,EAAAA,GAAK;AAChCW,YAAIG,OAAOd,EAAAA;MACb,OAAO;AACLW,YAAIR,IAAIH,EAAAA;MACV;IACF,CAAA;AAEA,SAAKX,UAAUK,QAAQiB;EACzB;AACF;;;ACjEA,SAASI,cAAc;AAShB,IAAMC,gBAAgBC,OAAOC,OAAO;EACzCC,IAAIF,OAAOG;EACXC,MAAMJ,OAAOK,SAASL,OAAOG,MAAM;EACnCG,MAAMN,OAAOK,SAASL,OAAOO,GAAG;AAClC,CAAA;AAqBO,IAAMC,gBAAgBR,OAAOC,OAAO;EACzCC,IAAIF,OAAOG;EACXC,MAAMJ,OAAOK,SAASL,OAAOG,MAAM;EACnCM,QAAQT,OAAOG;EACfO,QAAQV,OAAOG;EACfG,MAAMN,OAAOK,SAASL,OAAOO,GAAG;AAClC,CAAA;AAqBO,IAAMI,QAAQX,OAAOC,OAAO;EACjCC,IAAIF,OAAOK,SAASL,OAAOG,MAAM;EACjCS,OAAOZ,OAAOa,QAAQb,OAAOc,MAAMf,aAAAA,CAAAA;EACnCgB,OAAOf,OAAOa,QAAQb,OAAOc,MAAMN,aAAAA,CAAAA;AACrC,CAAA;",
|
|
6
|
+
"names": ["effect", "inspectCustom", "failedInvariant", "invariant", "live", "isNotFalsy", "removeBy", "invariant", "KEY_REGEX", "createEdgeId", "source", "target", "relation", "match", "join", "parseEdgeId", "id", "split", "length", "undefined", "ReadonlyGraphModel", "graph", "_graph", "nodes", "edges", "inspectCustom", "toJSON", "length", "findNode", "id", "find", "node", "getNode", "failedInvariant", "filterNodes", "type", "filter", "findEdge", "edge", "getEdge", "filterEdges", "source", "target", "traverse", "root", "_traverse", "visited", "Set", "has", "add", "targets", "map", "isNotFalsy", "flatMap", "AbstractGraphModel", "clear", "addGraph", "addNodes", "addEdges", "addGraphs", "graphs", "forEach", "addNode", "invariant", "push", "addEdge", "createEdgeId", "removeNode", "removeBy", "copy", "removeNodes", "ids", "removeEdge", "removeEdges", "AbstractGraphBuilder", "_model", "model", "call", "cb", "GraphModel", "builder", "GraphBuilder", "subscribe", "fire", "effect", "ReactiveGraphModel", "live", "computed", "signal", "invariant", "SelectionModel", "_singleSelect", "_selected", "Set", "_selectedIds", "Array", "from", "value", "values", "toJSON", "selected", "size", "contains", "id", "has", "clear", "add", "remove", "filter", "_id", "setSelected", "ids", "shift", "toggleSelected", "set", "undefined", "forEach", "delete", "Schema", "BaseGraphNode", "Schema", "Struct", "id", "String", "type", "optional", "data", "Any", "BaseGraphEdge", "source", "target", "Graph", "nodes", "mutable", "Array", "edges"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/common/graph/src/
|
|
1
|
+
{"inputs":{"packages/common/graph/src/util.ts":{"bytes":3270,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/common/graph/src/model.ts":{"bytes":25676,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/graph/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/common/graph/src/selection.ts":{"bytes":7405,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/common/graph/src/types.ts":{"bytes":4619,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/common/graph/src/index.ts":{"bytes":704,"imports":[{"path":"packages/common/graph/src/model.ts","kind":"import-statement","original":"./model"},{"path":"packages/common/graph/src/selection.ts","kind":"import-statement","original":"./selection"},{"path":"packages/common/graph/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/common/graph/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/common/graph/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20776},"packages/common/graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AbstractGraphBuilder","AbstractGraphModel","BaseGraphEdge","BaseGraphNode","Graph","GraphBuilder","GraphModel","ReactiveGraphModel","ReadonlyGraphModel","SelectionModel","createEdgeId","parseEdgeId","subscribe"],"entryPoint":"packages/common/graph/src/index.ts","inputs":{"packages/common/graph/src/model.ts":{"bytesInOutput":5705},"packages/common/graph/src/util.ts":{"bytesInOutput":1027},"packages/common/graph/src/index.ts":{"bytesInOutput":0},"packages/common/graph/src/selection.ts":{"bytesInOutput":1875},"packages/common/graph/src/types.ts":{"bytesInOutput":534}},"bytes":9702}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
@@ -1,58 +1,33 @@
|
|
|
1
1
|
import { inspectCustom } from '@dxos/debug';
|
|
2
|
+
import { type Live } from '@dxos/live-object';
|
|
2
3
|
import { type MakeOptional } from '@dxos/util';
|
|
3
|
-
import { type
|
|
4
|
+
import { type BaseGraphEdge, type BaseGraphNode, type Graph, type GraphEdge, type GraphNode } from './types';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* Readonly Graph wrapper.
|
|
6
7
|
*/
|
|
7
8
|
export declare class ReadonlyGraphModel<Node extends BaseGraphNode = BaseGraphNode, Edge extends BaseGraphEdge = BaseGraphEdge> {
|
|
8
9
|
protected readonly _graph: Graph;
|
|
9
10
|
/**
|
|
10
|
-
* NOTE: Pass in simple Graph or
|
|
11
|
+
* NOTE: Pass in simple Graph or Live.
|
|
11
12
|
*/
|
|
12
13
|
constructor(graph?: Graph);
|
|
13
14
|
[inspectCustom](): {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly type?: string | undefined;
|
|
18
|
-
readonly data?: any;
|
|
19
|
-
} & {
|
|
20
|
-
readonly [x: string]: any;
|
|
21
|
-
})[];
|
|
22
|
-
edges: {
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly type?: string | undefined;
|
|
25
|
-
readonly data?: any;
|
|
26
|
-
readonly source: string;
|
|
27
|
-
readonly target: string;
|
|
28
|
-
}[];
|
|
15
|
+
nodes: number;
|
|
16
|
+
edges: number;
|
|
29
17
|
};
|
|
30
18
|
/**
|
|
31
19
|
* Return stable sorted JSON representation of graph.
|
|
32
20
|
*/
|
|
33
21
|
toJSON(): {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly type?: string | undefined;
|
|
38
|
-
readonly data?: any;
|
|
39
|
-
} & {
|
|
40
|
-
readonly [x: string]: any;
|
|
41
|
-
})[];
|
|
42
|
-
edges: {
|
|
43
|
-
readonly id: string;
|
|
44
|
-
readonly type?: string | undefined;
|
|
45
|
-
readonly data?: any;
|
|
46
|
-
readonly source: string;
|
|
47
|
-
readonly target: string;
|
|
48
|
-
}[];
|
|
22
|
+
nodes: number;
|
|
23
|
+
edges: number;
|
|
49
24
|
};
|
|
50
25
|
get graph(): Graph;
|
|
51
26
|
get nodes(): Node[];
|
|
52
27
|
get edges(): Edge[];
|
|
53
28
|
findNode(id: string): Node | undefined;
|
|
54
29
|
getNode(id: string): Node;
|
|
55
|
-
filterNodes({ type }?: Partial<GraphNode>): Node[];
|
|
30
|
+
filterNodes({ type }?: Partial<GraphNode.Any>): Node[];
|
|
56
31
|
findEdge(id: string): Edge | undefined;
|
|
57
32
|
getEdge(id: string): Edge;
|
|
58
33
|
filterEdges({ type, source, target }?: Partial<GraphEdge>): Edge[];
|
|
@@ -60,9 +35,9 @@ export declare class ReadonlyGraphModel<Node extends BaseGraphNode = BaseGraphNo
|
|
|
60
35
|
private _traverse;
|
|
61
36
|
}
|
|
62
37
|
/**
|
|
63
|
-
*
|
|
38
|
+
* Mutable Graph wrapper.
|
|
64
39
|
*/
|
|
65
|
-
export declare abstract class AbstractGraphModel<Node extends BaseGraphNode, Edge extends BaseGraphEdge, Model extends AbstractGraphModel<Node, Edge, Model, Builder
|
|
40
|
+
export declare abstract class AbstractGraphModel<Node extends BaseGraphNode = BaseGraphNode, Edge extends BaseGraphEdge = BaseGraphEdge, Model extends AbstractGraphModel<Node, Edge, Model, Builder> = any, Builder extends AbstractGraphBuilder<Node, Edge, Model> = AbstractGraphBuilder<Node, Edge, Model>> extends ReadonlyGraphModel<Node, Edge> {
|
|
66
41
|
/**
|
|
67
42
|
* Allows chaining.
|
|
68
43
|
*/
|
|
@@ -84,7 +59,7 @@ export declare abstract class AbstractGraphModel<Node extends BaseGraphNode, Edg
|
|
|
84
59
|
removeEdges(ids: string[]): Model;
|
|
85
60
|
}
|
|
86
61
|
/**
|
|
87
|
-
* Chainable wrapper
|
|
62
|
+
* Chainable builder wrapper
|
|
88
63
|
*/
|
|
89
64
|
export declare abstract class AbstractGraphBuilder<Node extends BaseGraphNode, Edge extends BaseGraphEdge, Model extends GraphModel<Node, Edge>> {
|
|
90
65
|
protected readonly _model: Model;
|
|
@@ -97,10 +72,30 @@ export declare abstract class AbstractGraphBuilder<Node extends BaseGraphNode, E
|
|
|
97
72
|
addNodes(nodes: Node[]): this;
|
|
98
73
|
addEdges(edges: Edge[]): this;
|
|
99
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Basic model.
|
|
77
|
+
*/
|
|
100
78
|
export declare class GraphModel<Node extends BaseGraphNode = BaseGraphNode, Edge extends BaseGraphEdge = BaseGraphEdge> extends AbstractGraphModel<Node, Edge, GraphModel<Node, Edge>, GraphBuilder<Node, Edge>> {
|
|
101
79
|
get builder(): GraphBuilder<Node, Edge>;
|
|
102
80
|
copy(graph?: Partial<Graph>): GraphModel<Node, Edge>;
|
|
103
81
|
}
|
|
82
|
+
export type GraphModelSubscription = (model: GraphModel, graph: Live<Graph>) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Subscription.
|
|
85
|
+
* NOTE: Requires `registerSignalsRuntime` to be called.
|
|
86
|
+
*/
|
|
87
|
+
export declare const subscribe: (model: GraphModel, cb: GraphModelSubscription, fire?: boolean) => () => void;
|
|
88
|
+
/**
|
|
89
|
+
* Basic reactive model.
|
|
90
|
+
*/
|
|
91
|
+
export declare class ReactiveGraphModel<Node extends BaseGraphNode = BaseGraphNode, Edge extends BaseGraphEdge = BaseGraphEdge> extends GraphModel<Node, Edge> {
|
|
92
|
+
constructor(graph?: Partial<Graph>);
|
|
93
|
+
copy(graph?: Partial<Graph>): ReactiveGraphModel<Node, Edge>;
|
|
94
|
+
subscribe(cb: GraphModelSubscription, fire?: boolean): () => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Basic builder.
|
|
98
|
+
*/
|
|
104
99
|
export declare class GraphBuilder<Node extends BaseGraphNode = BaseGraphNode, Edge extends BaseGraphEdge = BaseGraphEdge> extends AbstractGraphBuilder<Node, Edge, GraphModel<Node, Edge>> {
|
|
105
100
|
call(cb: (builder: this) => void): this;
|
|
106
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/model.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,KAAK,IAAI,EAAQ,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAG7G;;GAEG;AACH,qBAAa,kBAAkB,CAC7B,IAAI,SAAS,aAAa,GAAG,aAAa,EAC1C,IAAI,SAAS,aAAa,GAAG,aAAa;IAE1C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAEjC;;OAEG;gBACS,KAAK,CAAC,EAAE,KAAK;IAOzB,CAAC,aAAa,CAAC;;;;IAIf;;OAEG;IACH,MAAM;;;;IAON,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAMD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAItC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIzB,WAAW,CAAC,EAAE,IAAI,EAAE,GAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAM,GAAG,IAAI,EAAE;IAQ1D,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAItC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIzB,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAA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