@dxos/app-graph 0.8.4-main.e098934 → 0.8.4-main.ead640a
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 +52 -47
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +52 -47
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/graph-builder.d.ts +1 -1
- package/dist/types/src/graph-builder.d.ts.map +1 -1
- package/dist/types/src/graph.d.ts +1 -1
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/stories/EchoGraph.stories.d.ts +0 -1
- package/dist/types/src/stories/EchoGraph.stories.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -31
- package/src/graph-builder.test.ts +8 -7
- package/src/graph-builder.ts +6 -3
- package/src/graph.test.ts +1 -1
- package/src/graph.ts +5 -3
- package/src/signals-integration.test.ts +6 -6
- package/src/stories/EchoGraph.stories.tsx +7 -8
- package/src/testing.ts +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/graph.ts
|
|
2
2
|
import { Registry, Rx } from "@effect-rx/rx-react";
|
|
3
|
-
import
|
|
3
|
+
import * as Function from "effect/Function";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Record from "effect/Record";
|
|
4
6
|
import { Event, Trigger } from "@dxos/async";
|
|
5
7
|
import { todo } from "@dxos/debug";
|
|
6
8
|
import { invariant } from "@dxos/invariant";
|
|
@@ -25,7 +27,7 @@ var getGraph = (node) => {
|
|
|
25
27
|
const graph = node[graphSymbol];
|
|
26
28
|
invariant(graph, "Node is not associated with a graph.", {
|
|
27
29
|
F: __dxlog_file,
|
|
28
|
-
L:
|
|
30
|
+
L: 27,
|
|
29
31
|
S: void 0,
|
|
30
32
|
A: [
|
|
31
33
|
"graph",
|
|
@@ -85,7 +87,7 @@ var Graph = class {
|
|
|
85
87
|
initialized
|
|
86
88
|
}, {
|
|
87
89
|
F: __dxlog_file,
|
|
88
|
-
L:
|
|
90
|
+
L: 386,
|
|
89
91
|
S: this,
|
|
90
92
|
C: (f, a) => f(...a)
|
|
91
93
|
});
|
|
@@ -102,7 +104,7 @@ var Graph = class {
|
|
|
102
104
|
expanded
|
|
103
105
|
}, {
|
|
104
106
|
F: __dxlog_file,
|
|
105
|
-
L:
|
|
107
|
+
L: 396,
|
|
106
108
|
S: this,
|
|
107
109
|
C: (f, a) => f(...a)
|
|
108
110
|
});
|
|
@@ -132,7 +134,7 @@ var Graph = class {
|
|
|
132
134
|
propertiesChanged
|
|
133
135
|
}, {
|
|
134
136
|
F: __dxlog_file,
|
|
135
|
-
L:
|
|
137
|
+
L: 418,
|
|
136
138
|
S: this,
|
|
137
139
|
C: (f, a) => f(...a)
|
|
138
140
|
});
|
|
@@ -144,7 +146,7 @@ var Graph = class {
|
|
|
144
146
|
properties
|
|
145
147
|
}, {
|
|
146
148
|
F: __dxlog_file,
|
|
147
|
-
L:
|
|
149
|
+
L: 420,
|
|
148
150
|
S: this,
|
|
149
151
|
C: (f, a) => f(...a)
|
|
150
152
|
});
|
|
@@ -172,7 +174,7 @@ var Graph = class {
|
|
|
172
174
|
properties
|
|
173
175
|
}, {
|
|
174
176
|
F: __dxlog_file,
|
|
175
|
-
L:
|
|
177
|
+
L: 427,
|
|
176
178
|
S: this,
|
|
177
179
|
C: (f, a) => f(...a)
|
|
178
180
|
});
|
|
@@ -243,7 +245,7 @@ var Graph = class {
|
|
|
243
245
|
target: edgeArg.target
|
|
244
246
|
}, {
|
|
245
247
|
F: __dxlog_file,
|
|
246
|
-
L:
|
|
248
|
+
L: 482,
|
|
247
249
|
S: this,
|
|
248
250
|
C: (f, a) => f(...a)
|
|
249
251
|
});
|
|
@@ -263,7 +265,7 @@ var Graph = class {
|
|
|
263
265
|
target: edgeArg.target
|
|
264
266
|
}, {
|
|
265
267
|
F: __dxlog_file,
|
|
266
|
-
L:
|
|
268
|
+
L: 489,
|
|
267
269
|
S: this,
|
|
268
270
|
C: (f, a) => f(...a)
|
|
269
271
|
});
|
|
@@ -346,7 +348,7 @@ var Graph = class {
|
|
|
346
348
|
]));
|
|
347
349
|
}
|
|
348
350
|
getPath({ source = "root", target }) {
|
|
349
|
-
return pipe(this.getNode(source), Option.flatMap((node) => {
|
|
351
|
+
return Function.pipe(this.getNode(source), Option.flatMap((node) => {
|
|
350
352
|
let found = Option.none();
|
|
351
353
|
this.traverse({
|
|
352
354
|
source: node.id,
|
|
@@ -412,11 +414,11 @@ var Graph = class {
|
|
|
412
414
|
return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:node:${id}`));
|
|
413
415
|
}));
|
|
414
416
|
_define_property(this, "_nodeOrThrow", Rx.family((id) => {
|
|
415
|
-
return Rx.make((
|
|
416
|
-
const node =
|
|
417
|
+
return Rx.make((get2) => {
|
|
418
|
+
const node = get2(this._node(id));
|
|
417
419
|
invariant(Option.isSome(node), `Node not available: ${id}`, {
|
|
418
420
|
F: __dxlog_file,
|
|
419
|
-
L:
|
|
421
|
+
L: 254,
|
|
420
422
|
S: this,
|
|
421
423
|
A: [
|
|
422
424
|
"Option.isSome(node)",
|
|
@@ -434,23 +436,23 @@ var Graph = class {
|
|
|
434
436
|
return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:edges:${id}`));
|
|
435
437
|
}));
|
|
436
438
|
_define_property(this, "_connections", Rx.family((key) => {
|
|
437
|
-
return Rx.make((
|
|
439
|
+
return Rx.make((get2) => {
|
|
438
440
|
const [id, relation] = key.split("$");
|
|
439
|
-
const edges2 =
|
|
440
|
-
return edges2[relation].map((id2) =>
|
|
441
|
+
const edges2 = get2(this._edges(id));
|
|
442
|
+
return edges2[relation].map((id2) => get2(this._node(id2))).filter(Option.isSome).map((o) => o.value);
|
|
441
443
|
}).pipe(Rx.withLabel(`graph:connections:${key}`));
|
|
442
444
|
}));
|
|
443
445
|
_define_property(this, "_actions", Rx.family((id) => {
|
|
444
|
-
return Rx.make((
|
|
445
|
-
return
|
|
446
|
+
return Rx.make((get2) => {
|
|
447
|
+
return get2(this._connections(`${id}$outbound`)).filter((node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE);
|
|
446
448
|
}).pipe(Rx.withLabel(`graph:actions:${id}`));
|
|
447
449
|
}));
|
|
448
450
|
_define_property(this, "_json", Rx.family((id) => {
|
|
449
|
-
return Rx.make((
|
|
451
|
+
return Rx.make((get2) => {
|
|
450
452
|
const toJSON = (node, seen = []) => {
|
|
451
|
-
const nodes2 =
|
|
453
|
+
const nodes2 = get2(this.connections(node.id));
|
|
452
454
|
const obj = {
|
|
453
|
-
id: node.id
|
|
455
|
+
id: node.id,
|
|
454
456
|
type: node.type
|
|
455
457
|
};
|
|
456
458
|
if (node.properties.label) {
|
|
@@ -467,7 +469,7 @@ var Graph = class {
|
|
|
467
469
|
}
|
|
468
470
|
return obj;
|
|
469
471
|
};
|
|
470
|
-
const root =
|
|
472
|
+
const root = get2(this.nodeOrThrow(id));
|
|
471
473
|
return toJSON(root);
|
|
472
474
|
}).pipe(Rx.withLabel(`graph:json:${id}`));
|
|
473
475
|
}));
|
|
@@ -491,7 +493,10 @@ var Graph = class {
|
|
|
491
493
|
// src/graph-builder.ts
|
|
492
494
|
import { Registry as Registry2, Rx as Rx2 } from "@effect-rx/rx-react";
|
|
493
495
|
import { effect } from "@preact/signals-core";
|
|
494
|
-
import
|
|
496
|
+
import * as Array from "effect/Array";
|
|
497
|
+
import * as Function2 from "effect/Function";
|
|
498
|
+
import * as Option2 from "effect/Option";
|
|
499
|
+
import * as Record2 from "effect/Record";
|
|
495
500
|
import { log as log2 } from "@dxos/log";
|
|
496
501
|
import { byPosition, getDebugName, isNode, isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
497
502
|
|
|
@@ -534,16 +539,16 @@ var createExtension = (extension) => {
|
|
|
534
539
|
id: getId("connector"),
|
|
535
540
|
position,
|
|
536
541
|
relation,
|
|
537
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
542
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
538
543
|
try {
|
|
539
|
-
return
|
|
544
|
+
return get2(connector(node));
|
|
540
545
|
} catch {
|
|
541
546
|
log2.warn("Error in connector", {
|
|
542
547
|
id: getId("connector"),
|
|
543
548
|
node
|
|
544
549
|
}, {
|
|
545
550
|
F: __dxlog_file2,
|
|
546
|
-
L:
|
|
551
|
+
L: 112,
|
|
547
552
|
S: void 0,
|
|
548
553
|
C: (f, a) => f(...a)
|
|
549
554
|
});
|
|
@@ -555,9 +560,9 @@ var createExtension = (extension) => {
|
|
|
555
560
|
id: getId("actionGroups"),
|
|
556
561
|
position,
|
|
557
562
|
relation: "outbound",
|
|
558
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
563
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
559
564
|
try {
|
|
560
|
-
return
|
|
565
|
+
return get2(actionGroups(node)).map((arg) => ({
|
|
561
566
|
...arg,
|
|
562
567
|
data: actionGroupSymbol,
|
|
563
568
|
type: ACTION_GROUP_TYPE
|
|
@@ -568,7 +573,7 @@ var createExtension = (extension) => {
|
|
|
568
573
|
node
|
|
569
574
|
}, {
|
|
570
575
|
F: __dxlog_file2,
|
|
571
|
-
L:
|
|
576
|
+
L: 133,
|
|
572
577
|
S: void 0,
|
|
573
578
|
C: (f, a) => f(...a)
|
|
574
579
|
});
|
|
@@ -580,9 +585,9 @@ var createExtension = (extension) => {
|
|
|
580
585
|
id: getId("actions"),
|
|
581
586
|
position,
|
|
582
587
|
relation: "outbound",
|
|
583
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
588
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
584
589
|
try {
|
|
585
|
-
return
|
|
590
|
+
return get2(actions(node)).map((arg) => ({
|
|
586
591
|
...arg,
|
|
587
592
|
type: ACTION_TYPE
|
|
588
593
|
}));
|
|
@@ -592,7 +597,7 @@ var createExtension = (extension) => {
|
|
|
592
597
|
node
|
|
593
598
|
}, {
|
|
594
599
|
F: __dxlog_file2,
|
|
595
|
-
L:
|
|
600
|
+
L: 150,
|
|
596
601
|
S: void 0,
|
|
597
602
|
C: (f, a) => f(...a)
|
|
598
603
|
});
|
|
@@ -692,7 +697,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
692
697
|
registry: getDebugName(this._registry)
|
|
693
698
|
}, {
|
|
694
699
|
F: __dxlog_file2,
|
|
695
|
-
L:
|
|
700
|
+
L: 327,
|
|
696
701
|
S: this,
|
|
697
702
|
C: (f, a) => f(...a)
|
|
698
703
|
});
|
|
@@ -709,7 +714,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
709
714
|
removed
|
|
710
715
|
}, {
|
|
711
716
|
F: __dxlog_file2,
|
|
712
|
-
L:
|
|
717
|
+
L: 338,
|
|
713
718
|
S: this,
|
|
714
719
|
C: (f, a) => f(...a)
|
|
715
720
|
});
|
|
@@ -746,7 +751,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
746
751
|
id
|
|
747
752
|
}, {
|
|
748
753
|
F: __dxlog_file2,
|
|
749
|
-
L:
|
|
754
|
+
L: 375,
|
|
750
755
|
S: this,
|
|
751
756
|
C: (f, a) => f(...a)
|
|
752
757
|
});
|
|
@@ -783,23 +788,23 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
783
788
|
_define_property2(this, "_registry", void 0);
|
|
784
789
|
_define_property2(this, "_graph", void 0);
|
|
785
790
|
_define_property2(this, "_resolvers", Rx2.family((id) => {
|
|
786
|
-
return Rx2.make((
|
|
787
|
-
return
|
|
791
|
+
return Rx2.make((get2) => {
|
|
792
|
+
return Function2.pipe(get2(this._extensions), Record2.values, Array.sortBy(byPosition), Array.map(({ resolver }) => resolver), Array.filter(isNonNullable2), Array.map((resolver) => get2(resolver(id))), Array.filter(isNonNullable2), Array.head);
|
|
788
793
|
});
|
|
789
794
|
}));
|
|
790
795
|
_define_property2(this, "_connectors", Rx2.family((key) => {
|
|
791
|
-
return Rx2.make((
|
|
796
|
+
return Rx2.make((get2) => {
|
|
792
797
|
const [id, relation] = key.split("+");
|
|
793
798
|
const node = this._graph.node(id);
|
|
794
|
-
return
|
|
795
|
-
|
|
799
|
+
return Function2.pipe(
|
|
800
|
+
get2(this._extensions),
|
|
796
801
|
Record2.values,
|
|
797
802
|
// TODO(wittjosiah): Sort on write rather than read.
|
|
798
803
|
Array.sortBy(byPosition),
|
|
799
804
|
Array.filter(({ relation: _relation = "outbound" }) => _relation === relation),
|
|
800
805
|
Array.map(({ connector }) => connector?.(node)),
|
|
801
806
|
Array.filter(isNonNullable2),
|
|
802
|
-
Array.flatMap((result) =>
|
|
807
|
+
Array.flatMap((result) => get2(result))
|
|
803
808
|
);
|
|
804
809
|
}).pipe(Rx2.withLabel(`graph-builder:connectors:${key}`));
|
|
805
810
|
}));
|
|
@@ -814,18 +819,18 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
814
819
|
}
|
|
815
820
|
};
|
|
816
821
|
var rxFromSignal = (cb) => {
|
|
817
|
-
return Rx2.make((
|
|
822
|
+
return Rx2.make((get2) => {
|
|
818
823
|
const dispose = effect(() => {
|
|
819
|
-
|
|
824
|
+
get2.setSelf(cb());
|
|
820
825
|
});
|
|
821
|
-
|
|
826
|
+
get2.addFinalizer(() => dispose());
|
|
822
827
|
return cb();
|
|
823
828
|
});
|
|
824
829
|
};
|
|
825
830
|
var observableFamily = Rx2.family((observable) => {
|
|
826
|
-
return Rx2.make((
|
|
827
|
-
const subscription = observable.subscribe((value) =>
|
|
828
|
-
|
|
831
|
+
return Rx2.make((get2) => {
|
|
832
|
+
const subscription = observable.subscribe((value) => get2.setSelf(value));
|
|
833
|
+
get2.addFinalizer(() => subscription.unsubscribe());
|
|
829
834
|
return observable.get();
|
|
830
835
|
});
|
|
831
836
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/graph.ts", "../../../src/graph-builder.ts", "../../../src/node.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Registry, Rx } from '@effect-rx/rx-react';\nimport { Option, Record, pipe } from 'effect';\n\nimport { Event, Trigger } from '@dxos/async';\nimport { todo } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { type MakeOptional, isNonNullable } from '@dxos/util';\n\nimport { type Action, type ActionGroup, type Node, type NodeArg, type Relation } from './node';\n\nconst graphSymbol = Symbol('graph');\ntype DeepWriteable<T> = { -readonly [K in keyof T]: T[K] extends object ? DeepWriteable<T[K]> : T[K] };\ntype NodeInternal = DeepWriteable<Node> & { [graphSymbol]: Graph };\n\n/**\n * Get the Graph a Node is currently associated with.\n */\nexport const getGraph = (node: Node): Graph => {\n const graph = (node as NodeInternal)[graphSymbol];\n invariant(graph, 'Node is not associated with a graph.');\n return graph;\n};\n\nexport const ROOT_ID = 'root';\nexport const ROOT_TYPE = 'dxos.org/type/GraphRoot';\nexport const ACTION_TYPE = 'dxos.org/type/GraphAction';\nexport const ACTION_GROUP_TYPE = 'dxos.org/type/GraphActionGroup';\n\nexport type GraphTraversalOptions = {\n /**\n * A callback which is called for each node visited during traversal.\n *\n * If the callback returns `false`, traversal is stops recursing.\n */\n visitor: (node: Node, path: string[]) => boolean | void;\n\n /**\n * The node to start traversing from.\n *\n * @default ROOT_ID\n */\n source?: string;\n\n /**\n * The relation to traverse graph edges.\n *\n * @default 'outbound'\n */\n relation?: Relation;\n};\n\nexport type GraphParams = {\n registry?: Registry.Registry;\n nodes?: MakeOptional<Node, 'data' | 'cacheable'>[];\n edges?: Record<string, Edges>;\n onExpand?: Graph['_onExpand'];\n onInitialize?: Graph['_onInitialize'];\n onRemoveNode?: Graph['_onRemoveNode'];\n};\n\nexport type Edge = { source: string; target: string };\nexport type Edges = { inbound: string[]; outbound: string[] };\n\nexport interface ReadableGraph {\n /**\n * Event emitted when a node is changed.\n */\n onNodeChanged: Event<{ id: string; node: Option.Option<Node> }>;\n\n /**\n * Convert the graph to a JSON object.\n */\n toJSON(id?: string): object;\n\n json(id?: string): Rx.Rx<any>;\n\n /**\n * Get the rx key for the node with the given id.\n */\n node(id: string): Rx.Rx<Option.Option<Node>>;\n\n /**\n * Get the rx key for the node with the given id.\n */\n nodeOrThrow(id: string): Rx.Rx<Node>;\n\n /**\n * Get the rx key for the connections of the node with the given id.\n */\n connections(id: string, relation?: Relation): Rx.Rx<Node[]>;\n\n /**\n * Get the rx key for the actions of the node with the given id.\n */\n actions(id: string): Rx.Rx<(Action | ActionGroup)[]>;\n\n /**\n * Get the rx key for the edges of the node with the given id.\n */\n edges(id: string): Rx.Rx<Edges>;\n\n /**\n * Alias for `getNodeOrThrow(ROOT_ID)`.\n */\n get root(): Node;\n\n /**\n * Get the node with the given id from the graph's registry.\n */\n getNode(id: string): Option.Option<Node>;\n\n /**\n * Get the node with the given id from the graph's registry.\n *\n * @throws If the node is Option.none().\n */\n getNodeOrThrow(id: string): Node;\n\n /**\n * Get all nodes connected to the node with the given id by the given relation from the graph's registry.\n */\n getConnections(id: string, relation?: Relation): Node[];\n\n /**\n * Get all actions connected to the node with the given id from the graph's registry.\n */\n getActions(id: string): Node[];\n\n /**\n * Get the edges from the node with the given id from the graph's registry.\n */\n getEdges(id: string): Edges;\n\n /**\n * Recursive depth-first traversal of the graph.\n *\n * @param options.node The node to start traversing from.\n * @param options.relation The relation to traverse graph edges.\n * @param options.visitor A callback which is called for each node visited during traversal.\n */\n traverse(options: GraphTraversalOptions, path?: string[]): void;\n\n /**\n * Get the path between two nodes in the graph.\n */\n getPath(params: { source?: string; target: string }): Option.Option<string[]>;\n\n /**\n * Wait for the path between two nodes in the graph to be established.\n */\n waitForPath(\n params: { source?: string; target: string },\n options?: { timeout?: number; interval?: number },\n ): Promise<string[]>;\n}\n\nexport interface ExpandableGraph extends ReadableGraph {\n /**\n * Initialize a node in the graph.\n *\n * Fires the `onInitialize` callback to provide initial data for a node.\n */\n initialize(id: string): Promise<void>;\n\n /**\n * Expand a node in the graph.\n *\n * Fires the `onExpand` callback to add connections to the node.\n */\n expand(id: string, relation?: Relation): void;\n\n /**\n * Sort the edges of the node with the given id.\n */\n sortEdges(id: string, relation: Relation, order: string[]): void;\n}\n\nexport interface WritableGraph extends ExpandableGraph {\n /**\n * Add nodes to the graph.\n */\n addNodes(nodes: NodeArg<any, Record<string, any>>[]): void;\n\n /**\n * Add a node to the graph.\n */\n addNode(node: NodeArg<any, Record<string, any>>): void;\n\n /**\n * Remove nodes from the graph.\n */\n removeNodes(ids: string[], edges?: boolean): void;\n\n /**\n * Remove a node from the graph.\n */\n removeNode(id: string, edges?: boolean): void;\n\n /**\n * Add edges to the graph.\n */\n addEdges(edges: Edge[]): void;\n\n /**\n * Add an edge to the graph.\n */\n addEdge(edge: Edge): void;\n\n /**\n * Remove edges from the graph.\n */\n removeEdges(edges: Edge[], removeOrphans?: boolean): void;\n\n /**\n * Remove an edge from the graph.\n */\n removeEdge(edge: Edge, removeOrphans?: boolean): void;\n}\n\n/**\n * The Graph represents the user interface information architecture of the application constructed via plugins.\n */\nexport class Graph implements WritableGraph {\n readonly onNodeChanged = new Event<{ id: string; node: Option.Option<Node> }>();\n\n private readonly _onExpand?: (id: string, relation: Relation) => void;\n private readonly _onInitialize?: (id: string) => Promise<void>;\n private readonly _onRemoveNode?: (id: string) => void;\n\n private readonly _registry: Registry.Registry;\n private readonly _expanded = Record.empty<string, boolean>();\n private readonly _initialized = Record.empty<string, boolean>();\n private readonly _initialEdges = Record.empty<string, Edges>();\n private readonly _initialNodes = Record.fromEntries([\n [ROOT_ID, this._constructNode({ id: ROOT_ID, type: ROOT_TYPE, data: null, properties: {} })],\n ]);\n\n /** @internal */\n readonly _node = Rx.family<string, Rx.Writable<Option.Option<Node>>>((id) => {\n const initial = Option.flatten(Record.get(this._initialNodes, id));\n return Rx.make<Option.Option<Node>>(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:node:${id}`));\n });\n\n private readonly _nodeOrThrow = Rx.family<string, Rx.Rx<Node>>((id) => {\n return Rx.make((get) => {\n const node = get(this._node(id));\n invariant(Option.isSome(node), `Node not available: ${id}`);\n return node.value;\n });\n });\n\n private readonly _edges = Rx.family<string, Rx.Writable<Edges>>((id) => {\n const initial = Record.get(this._initialEdges, id).pipe(Option.getOrElse(() => ({ inbound: [], outbound: [] })));\n return Rx.make<Edges>(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:edges:${id}`));\n });\n\n // NOTE: Currently the argument to the family needs to be referentially stable for the rx to be referentially stable.\n // TODO(wittjosiah): Rx feature request, support for something akin to `ComplexMap` to allow for complex arguments.\n private readonly _connections = Rx.family<string, Rx.Rx<Node[]>>((key) => {\n return Rx.make((get) => {\n const [id, relation] = key.split('$');\n const edges = get(this._edges(id));\n return edges[relation as Relation]\n .map((id) => get(this._node(id)))\n .filter(Option.isSome)\n .map((o) => o.value);\n }).pipe(Rx.withLabel(`graph:connections:${key}`));\n });\n\n private readonly _actions = Rx.family<string, Rx.Rx<(Action | ActionGroup)[]>>((id) => {\n return Rx.make((get) => {\n return get(this._connections(`${id}$outbound`)).filter(\n (node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE,\n );\n }).pipe(Rx.withLabel(`graph:actions:${id}`));\n });\n\n private readonly _json = Rx.family<string, Rx.Rx<any>>((id) => {\n return Rx.make((get) => {\n const toJSON = (node: Node, seen: string[] = []): any => {\n const nodes = get(this.connections(node.id));\n const obj: Record<string, any> = {\n id: node.id.length > 32 ? `${node.id.slice(0, 32)}...` : node.id,\n type: node.type,\n };\n if (node.properties.label) {\n obj.label = node.properties.label;\n }\n if (nodes.length) {\n obj.nodes = nodes\n .map((n) => {\n // Break cycles.\n const nextSeen = [...seen, node.id];\n return nextSeen.includes(n.id) ? undefined : toJSON(n, nextSeen);\n })\n .filter(isNonNullable);\n }\n return obj;\n };\n\n const root = get(this.nodeOrThrow(id));\n return toJSON(root);\n }).pipe(Rx.withLabel(`graph:json:${id}`));\n });\n\n constructor({ registry, nodes, edges, onInitialize, onExpand, onRemoveNode }: GraphParams = {}) {\n this._registry = registry ?? Registry.make();\n this._onInitialize = onInitialize;\n this._onExpand = onExpand;\n this._onRemoveNode = onRemoveNode;\n\n if (nodes) {\n nodes.forEach((node) => {\n Record.set(this._initialNodes, node.id, this._constructNode(node));\n });\n }\n\n if (edges) {\n Object.entries(edges).forEach(([source, edges]) => {\n Record.set(this._initialEdges, source, edges);\n });\n }\n }\n\n toJSON(id = ROOT_ID) {\n return this._registry.get(this._json(id));\n }\n\n json(id = ROOT_ID) {\n return this._json(id);\n }\n\n node(id: string): Rx.Rx<Option.Option<Node>> {\n return this._node(id);\n }\n\n nodeOrThrow(id: string): Rx.Rx<Node> {\n return this._nodeOrThrow(id);\n }\n\n connections(id: string, relation: Relation = 'outbound'): Rx.Rx<Node[]> {\n return this._connections(`${id}$${relation}`);\n }\n\n actions(id: string) {\n return this._actions(id);\n }\n\n edges(id: string): Rx.Rx<Edges> {\n return this._edges(id);\n }\n\n get root() {\n return this.getNodeOrThrow(ROOT_ID);\n }\n\n getNode(id: string): Option.Option<Node> {\n return this._registry.get(this.node(id));\n }\n\n getNodeOrThrow(id: string): Node {\n return this._registry.get(this.nodeOrThrow(id));\n }\n\n getConnections(id: string, relation: Relation = 'outbound'): Node[] {\n return this._registry.get(this.connections(id, relation));\n }\n\n getActions(id: string): Node[] {\n return this._registry.get(this.actions(id));\n }\n\n getEdges(id: string): Edges {\n return this._registry.get(this.edges(id));\n }\n\n async initialize(id: string) {\n const initialized = Record.get(this._initialized, id).pipe(Option.getOrElse(() => false));\n log('initialize', { id, initialized });\n if (!initialized) {\n await this._onInitialize?.(id);\n Record.set(this._initialized, id, true);\n }\n }\n\n expand(id: string, relation: Relation = 'outbound'): void {\n const key = `${id}$${relation}`;\n const expanded = Record.get(this._expanded, key).pipe(Option.getOrElse(() => false));\n log('expand', { key, expanded });\n if (!expanded) {\n this._onExpand?.(id, relation);\n Record.set(this._expanded, key, true);\n }\n }\n\n addNodes(nodes: NodeArg<any, Record<string, any>>[]): void {\n Rx.batch(() => {\n nodes.map((node) => this.addNode(node));\n });\n }\n\n addNode({ nodes, edges, ...nodeArg }: NodeArg<any, Record<string, any>>): void {\n const { id, type, data = null, properties = {} } = nodeArg;\n const nodeRx = this._node(id);\n const node = this._registry.get(nodeRx);\n Option.match(node, {\n onSome: (node) => {\n const typeChanged = node.type !== type;\n const dataChanged = node.data !== data;\n const propertiesChanged = Object.keys(properties).some((key) => node.properties[key] !== properties[key]);\n log('existing node', { id, typeChanged, dataChanged, propertiesChanged });\n if (typeChanged || dataChanged || propertiesChanged) {\n log('updating node', { id, type, data, properties });\n const newNode = Option.some({ ...node, type, data, properties: { ...node.properties, ...properties } });\n this._registry.set(nodeRx, newNode);\n this.onNodeChanged.emit({ id, node: newNode });\n }\n },\n onNone: () => {\n log('new node', { id, type, data, properties });\n const newNode = this._constructNode({ id, type, data, properties });\n this._registry.set(nodeRx, newNode);\n this.onNodeChanged.emit({ id, node: newNode });\n },\n });\n\n if (nodes) {\n // Rx.batch(() => {\n this.addNodes(nodes);\n const _edges = nodes.map((node) => ({ source: id, target: node.id }));\n this.addEdges(_edges);\n // });\n }\n\n if (edges) {\n todo();\n }\n }\n\n removeNodes(ids: string[], edges = false): void {\n Rx.batch(() => {\n ids.map((id) => this.removeNode(id, edges));\n });\n }\n\n removeNode(id: string, edges = false): void {\n const nodeRx = this._node(id);\n // TODO(wittjosiah): Is there a way to mark these rx values for garbage collection?\n this._registry.set(nodeRx, Option.none());\n this.onNodeChanged.emit({ id, node: Option.none() });\n // TODO(wittjosiah): Reset expanded and initialized flags?\n\n if (edges) {\n const { inbound, outbound } = this._registry.get(this._edges(id));\n const edges = [\n ...inbound.map((source) => ({ source, target: id })),\n ...outbound.map((target) => ({ source: id, target })),\n ];\n this.removeEdges(edges);\n }\n\n this._onRemoveNode?.(id);\n }\n\n addEdges(edges: Edge[]): void {\n Rx.batch(() => {\n edges.map((edge) => this.addEdge(edge));\n });\n }\n\n addEdge(edgeArg: Edge): void {\n const sourceRx = this._edges(edgeArg.source);\n const source = this._registry.get(sourceRx);\n if (!source.outbound.includes(edgeArg.target)) {\n log('add outbound edge', { source: edgeArg.source, target: edgeArg.target });\n this._registry.set(sourceRx, { inbound: source.inbound, outbound: [...source.outbound, edgeArg.target] });\n }\n\n const targetRx = this._edges(edgeArg.target);\n const target = this._registry.get(targetRx);\n if (!target.inbound.includes(edgeArg.source)) {\n log('add inbound edge', { source: edgeArg.source, target: edgeArg.target });\n this._registry.set(targetRx, { inbound: [...target.inbound, edgeArg.source], outbound: target.outbound });\n }\n }\n\n removeEdges(edges: Edge[], removeOrphans = false): void {\n Rx.batch(() => {\n edges.map((edge) => this.removeEdge(edge, removeOrphans));\n });\n }\n\n removeEdge(edgeArg: Edge, removeOrphans = false): void {\n const sourceRx = this._edges(edgeArg.source);\n const source = this._registry.get(sourceRx);\n if (source.outbound.includes(edgeArg.target)) {\n this._registry.set(sourceRx, {\n inbound: source.inbound,\n outbound: source.outbound.filter((id) => id !== edgeArg.target),\n });\n }\n\n const targetRx = this._edges(edgeArg.target);\n const target = this._registry.get(targetRx);\n if (target.inbound.includes(edgeArg.source)) {\n this._registry.set(targetRx, {\n inbound: target.inbound.filter((id) => id !== edgeArg.source),\n outbound: target.outbound,\n });\n }\n\n if (removeOrphans) {\n const source = this._registry.get(sourceRx);\n const target = this._registry.get(targetRx);\n if (source.outbound.length === 0 && source.inbound.length === 0 && edgeArg.source !== ROOT_ID) {\n this.removeNodes([edgeArg.source]);\n }\n if (target.outbound.length === 0 && target.inbound.length === 0 && edgeArg.target !== ROOT_ID) {\n this.removeNodes([edgeArg.target]);\n }\n }\n }\n\n sortEdges(id: string, relation: Relation, order: string[]): void {\n const edgesRx = this._edges(id);\n const edges = this._registry.get(edgesRx);\n const unsorted = edges[relation].filter((id) => !order.includes(id)) ?? [];\n const sorted = order.filter((id) => edges[relation].includes(id)) ?? [];\n edges[relation].splice(0, edges[relation].length, ...[...sorted, ...unsorted]);\n this._registry.set(edgesRx, edges);\n }\n\n traverse({ visitor, source = ROOT_ID, relation = 'outbound' }: GraphTraversalOptions, path: string[] = []): void {\n // Break cycles.\n if (path.includes(source)) {\n return;\n }\n\n const node = this.getNodeOrThrow(source);\n const shouldContinue = visitor(node, [...path, source]);\n if (shouldContinue === false) {\n return;\n }\n\n Object.values(this.getConnections(source, relation)).forEach((child) =>\n this.traverse({ source: child.id, relation, visitor }, [...path, source]),\n );\n }\n\n getPath({ source = 'root', target }: { source?: string; target: string }): Option.Option<string[]> {\n return pipe(\n this.getNode(source),\n Option.flatMap((node) => {\n let found: Option.Option<string[]> = Option.none();\n this.traverse({\n source: node.id,\n visitor: (node, path) => {\n if (Option.isSome(found)) {\n return false;\n }\n\n if (node.id === target) {\n found = Option.some(path);\n }\n },\n });\n\n return found;\n }),\n );\n }\n\n async waitForPath(\n params: { source?: string; target: string },\n { timeout = 5_000, interval = 500 }: { timeout?: number; interval?: number } = {},\n ): Promise<string[]> {\n const path = this.getPath(params);\n if (Option.isSome(path)) {\n return path.value;\n }\n\n const trigger = new Trigger<string[]>();\n const i = setInterval(() => {\n const path = this.getPath(params);\n if (Option.isSome(path)) {\n trigger.wake(path.value);\n }\n }, interval);\n\n return trigger.wait({ timeout }).finally(() => clearInterval(i));\n }\n\n /** @internal */\n _constructNode(node: NodeArg<any>): Option.Option<Node> {\n return Option.some({ [graphSymbol]: this, data: null, properties: {}, ...node });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Registry, Rx } from '@effect-rx/rx-react';\nimport { effect } from '@preact/signals-core';\nimport { Array, Option, Record, pipe } from 'effect';\n\nimport { type CleanupFn, type MulticastObservable, type Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { type MaybePromise, type Position, byPosition, getDebugName, isNode, isNonNullable } from '@dxos/util';\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE, type ExpandableGraph, Graph, type GraphParams, ROOT_ID } from './graph';\nimport { type ActionData, type Node, type NodeArg, type Relation, actionGroupSymbol } from './node';\n\n/**\n * Graph builder extension for adding nodes to the graph based on a node id.\n */\nexport type ResolverExtension = (id: string) => Rx.Rx<NodeArg<any> | null>;\n\n/**\n * Graph builder extension for adding nodes to the graph based on a connection to an existing node.\n *\n * @param params.node The existing node the returned nodes will be connected to.\n */\nexport type ConnectorExtension = (node: Rx.Rx<Option.Option<Node>>) => Rx.Rx<NodeArg<any>[]>;\n\n/**\n * Constrained case of the connector extension for more easily adding actions to the graph.\n */\nexport type ActionsExtension = (\n node: Rx.Rx<Option.Option<Node>>,\n) => Rx.Rx<Omit<NodeArg<ActionData>, 'type' | 'nodes' | 'edges'>[]>;\n\n/**\n * Constrained case of the connector extension for more easily adding action groups to the graph.\n */\nexport type ActionGroupsExtension = (\n node: Rx.Rx<Option.Option<Node>>,\n) => Rx.Rx<Omit<NodeArg<typeof actionGroupSymbol>, 'type' | 'data' | 'nodes' | 'edges'>[]>;\n\n/**\n * A graph builder extension is used to add nodes to the graph.\n *\n * @param params.id The unique id of the extension.\n * @param params.relation The relation the graph is being expanded from the existing node.\n * @param params.position Affects the order the extensions are processed in.\n * @param params.resolver A function to add nodes to the graph based on just the node id.\n * @param params.connector A function to add nodes to the graph based on a connection to an existing node.\n * @param params.actions A function to add actions to the graph based on a connection to an existing node.\n * @param params.actionGroups A function to add action groups to the graph based on a connection to an existing node.\n */\nexport type CreateExtensionOptions = {\n id: string;\n relation?: Relation;\n position?: Position;\n resolver?: ResolverExtension;\n connector?: ConnectorExtension;\n actions?: ActionsExtension;\n actionGroups?: ActionGroupsExtension;\n};\n\n/**\n * Create a graph builder extension.\n */\nexport const createExtension = (extension: CreateExtensionOptions): BuilderExtension[] => {\n const {\n id,\n position = 'static',\n relation = 'outbound',\n resolver: _resolver,\n connector: _connector,\n actions: _actions,\n actionGroups: _actionGroups,\n } = extension;\n const getId = (key: string) => `${id}/${key}`;\n\n const resolver =\n _resolver && Rx.family((id: string) => _resolver(id).pipe(Rx.withLabel(`graph-builder:_resolver:${id}`)));\n\n const connector =\n _connector &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) =>\n _connector(node).pipe(Rx.withLabel(`graph-builder:_connector:${id}`)),\n );\n\n const actionGroups =\n _actionGroups &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) =>\n _actionGroups(node).pipe(Rx.withLabel(`graph-builder:_actionGroups:${id}`)),\n );\n\n const actions =\n _actions &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) => _actions(node).pipe(Rx.withLabel(`graph-builder:_actions:${id}`)));\n\n return [\n resolver ? { id: getId('resolver'), position, resolver } : undefined,\n connector\n ? ({\n id: getId('connector'),\n position,\n relation,\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(connector(node));\n } catch {\n log.warn('Error in connector', { id: getId('connector'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n actionGroups\n ? ({\n id: getId('actionGroups'),\n position,\n relation: 'outbound',\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(actionGroups(node)).map((arg) => ({\n ...arg,\n data: actionGroupSymbol,\n type: ACTION_GROUP_TYPE,\n }));\n } catch {\n log.warn('Error in actionGroups', { id: getId('actionGroups'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:actionGroups:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n actions\n ? ({\n id: getId('actions'),\n position,\n relation: 'outbound',\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(actions(node)).map((arg) => ({ ...arg, type: ACTION_TYPE }));\n } catch {\n log.warn('Error in actions', { id: getId('actions'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:actions:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n ].filter(isNonNullable);\n};\n\nexport type GraphBuilderTraverseOptions = {\n visitor: (node: Node, path: string[]) => MaybePromise<boolean | void>;\n registry?: Registry.Registry;\n source?: string;\n relation?: Relation;\n};\n\nexport type BuilderExtension = Readonly<{\n id: string;\n position: Position;\n relation?: Relation; // Only for connector.\n resolver?: ResolverExtension;\n connector?: (node: Rx.Rx<Option.Option<Node>>) => Rx.Rx<NodeArg<any>[]>;\n}>;\n\nexport type BuilderExtensions = BuilderExtension | BuilderExtension[] | BuilderExtensions[];\n\nexport const flattenExtensions = (extension: BuilderExtensions, acc: BuilderExtension[] = []): BuilderExtension[] => {\n if (Array.isArray(extension)) {\n return [...acc, ...extension.flatMap((ext) => flattenExtensions(ext, acc))];\n } else {\n return [...acc, extension];\n }\n};\n\n/**\n * The builder provides an extensible way to compose the construction of the graph.\n */\n// TODO(wittjosiah): Add api for setting subscription set and/or radius.\n// Should unsubscribe from nodes that are not in the set/radius.\n// Should track LRU nodes that are not in the set/radius and remove them beyond a certain threshold.\nexport class GraphBuilder {\n // TODO(wittjosiah): Use Context.\n private readonly _subscriptions = new Map<string, CleanupFn>();\n private readonly _extensions = Rx.make(Record.empty<string, BuilderExtension>()).pipe(\n Rx.keepAlive,\n Rx.withLabel('graph-builder:extensions'),\n );\n private readonly _initialized: Record<string, Trigger> = {};\n private readonly _registry: Registry.Registry;\n private readonly _graph: Graph;\n\n constructor({ registry, ...params }: Pick<GraphParams, 'registry' | 'nodes' | 'edges'> = {}) {\n this._registry = registry ?? Registry.make();\n this._graph = new Graph({\n ...params,\n registry: this._registry,\n onExpand: (id, relation) => this._onExpand(id, relation),\n onInitialize: (id) => this._onInitialize(id),\n onRemoveNode: (id) => this._onRemoveNode(id),\n });\n }\n\n static from(pickle?: string, registry?: Registry.Registry): GraphBuilder {\n if (!pickle) {\n return new GraphBuilder({ registry });\n }\n\n const { nodes, edges } = JSON.parse(pickle);\n return new GraphBuilder({ nodes, edges, registry });\n }\n\n get graph(): ExpandableGraph {\n return this._graph;\n }\n\n get extensions() {\n return this._extensions;\n }\n\n addExtension(extensions: BuilderExtensions): GraphBuilder {\n flattenExtensions(extensions).forEach((extension) => {\n const extensions = this._registry.get(this._extensions);\n this._registry.set(this._extensions, Record.set(extensions, extension.id, extension));\n });\n return this;\n }\n\n removeExtension(id: string): GraphBuilder {\n const extensions = this._registry.get(this._extensions);\n this._registry.set(this._extensions, Record.remove(extensions, id));\n return this;\n }\n\n async explore(\n // TODO(wittjosiah): Currently defaulting to new registry.\n // Currently unsure about how to handle nodes which are expanded in the background.\n // This seems like a good place to start.\n { registry = Registry.make(), source = ROOT_ID, relation = 'outbound', visitor }: GraphBuilderTraverseOptions,\n path: string[] = [],\n ): Promise<void> {\n // Break cycles.\n if (path.includes(source)) {\n return;\n }\n\n // TODO(wittjosiah): This is a workaround for esm not working in the test runner.\n // Switching to vitest is blocked by having node esm versions of echo-schema & echo-signals.\n if (!isNode()) {\n const { yieldOrContinue } = await import('main-thread-scheduling');\n await yieldOrContinue('idle');\n }\n\n const node = registry.get(this._graph.nodeOrThrow(source));\n const shouldContinue = await visitor(node, [...path, node.id]);\n if (shouldContinue === false) {\n return;\n }\n\n const nodes = Object.values(this._registry.get(this._extensions))\n .filter((extension) => relation === (extension.relation ?? 'outbound'))\n .map((extension) => extension.connector)\n .filter(isNonNullable)\n .flatMap((connector) => registry.get(connector(this._graph.node(source))));\n\n await Promise.all(\n nodes.map((nodeArg) => {\n registry.set(this._graph._node(nodeArg.id), this._graph._constructNode(nodeArg));\n return this.explore({ registry, source: nodeArg.id, relation, visitor }, [...path, node.id]);\n }),\n );\n\n if (registry !== this._registry) {\n registry.reset();\n registry.dispose();\n }\n }\n\n destroy(): void {\n this._subscriptions.forEach((unsubscribe) => unsubscribe());\n this._subscriptions.clear();\n }\n\n private readonly _resolvers = Rx.family<string, Rx.Rx<Option.Option<NodeArg<any>>>>((id) => {\n return Rx.make((get) => {\n return pipe(\n get(this._extensions),\n Record.values,\n Array.sortBy(byPosition),\n Array.map(({ resolver }) => resolver),\n Array.filter(isNonNullable),\n Array.map((resolver) => get(resolver(id))),\n Array.filter(isNonNullable),\n Array.head,\n );\n });\n });\n\n private readonly _connectors = Rx.family<string, Rx.Rx<NodeArg<any>[]>>((key) => {\n return Rx.make((get) => {\n const [id, relation] = key.split('+');\n const node = this._graph.node(id);\n\n return pipe(\n get(this._extensions),\n Record.values,\n // TODO(wittjosiah): Sort on write rather than read.\n Array.sortBy(byPosition),\n Array.filter(({ relation: _relation = 'outbound' }) => _relation === relation),\n Array.map(({ connector }) => connector?.(node)),\n Array.filter(isNonNullable),\n Array.flatMap((result) => get(result)),\n );\n }).pipe(Rx.withLabel(`graph-builder:connectors:${key}`));\n });\n\n private _onExpand(id: string, relation: Relation): void {\n log('onExpand', { id, relation, registry: getDebugName(this._registry) });\n const connectors = this._connectors(`${id}+${relation}`);\n\n let previous: string[] = [];\n const cancel = this._registry.subscribe(\n connectors,\n (nodes) => {\n const ids = nodes.map((n) => n.id);\n const removed = previous.filter((id) => !ids.includes(id));\n previous = ids;\n\n log('update', { id, relation, ids, removed });\n const update = () => {\n Rx.batch(() => {\n this._graph.removeEdges(\n removed.map((target) => ({ source: id, target })),\n true,\n );\n this._graph.addNodes(nodes);\n this._graph.addEdges(\n nodes.map((node) =>\n relation === 'outbound' ? { source: id, target: node.id } : { source: node.id, target: id },\n ),\n );\n this._graph.sortEdges(\n id,\n relation,\n nodes.map(({ id }) => id),\n );\n });\n };\n\n // TODO(wittjosiah): Remove `requestAnimationFrame` once we have a better solution.\n // This is a workaround to avoid a race condition where the graph is updated during React render.\n if (typeof requestAnimationFrame === 'function') {\n requestAnimationFrame(update);\n } else {\n update();\n }\n },\n { immediate: true },\n );\n\n this._subscriptions.set(id, cancel);\n }\n\n // TODO(wittjosiah): If the same node is added by a connector, the resolver should probably cancel itself?\n private async _onInitialize(id: string) {\n log('onInitialize', { id });\n const resolver = this._resolvers(id);\n\n const cancel = this._registry.subscribe(\n resolver,\n (node) => {\n const trigger = this._initialized[id];\n Option.match(node, {\n onSome: (node) => {\n this._graph.addNodes([node]);\n trigger?.wake();\n },\n onNone: () => {\n trigger?.wake();\n this._graph.removeNodes([id]);\n },\n });\n },\n { immediate: true },\n );\n\n this._subscriptions.set(id, cancel);\n }\n\n private _onRemoveNode(id: string): void {\n this._subscriptions.get(id)?.();\n this._subscriptions.delete(id);\n }\n}\n\n/**\n * Creates an Rx.Rx<T> from a callback which accesses signals.\n * Will return a new rx instance each time.\n */\nexport const rxFromSignal = <T>(cb: () => T): Rx.Rx<T> => {\n return Rx.make((get) => {\n const dispose = effect(() => {\n get.setSelf(cb());\n });\n\n get.addFinalizer(() => dispose());\n\n return cb();\n });\n};\n\nconst observableFamily = Rx.family((observable: MulticastObservable<any>) => {\n return Rx.make((get) => {\n const subscription = observable.subscribe((value) => get.setSelf(value));\n\n get.addFinalizer(() => subscription.unsubscribe());\n\n return observable.get();\n });\n});\n\n/**\n * Creates an Rx.Rx<T> from a MulticastObservable<T>\n * Will return the same rx instance for the same observable.\n */\nexport const rxFromObservable = <T>(observable: MulticastObservable<T>): Rx.Rx<T> => {\n return observableFamily(observable) as Rx.Rx<T>;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type MakeOptional, type MaybePromise } from '@dxos/util';\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE } from './graph';\n\n/**\n * Represents a node in the graph.\n */\n// TODO(wittjosiah): Use Effect Schema.\n// TODO(burdon): Rename GraphNode. Node is already in the global namespace.\nexport type Node<TData = any, TProperties extends Record<string, any> = Record<string, any>> = Readonly<{\n /**\n * Globally unique ID.\n */\n // TODO(burdon): Allow string array, which is concatenated.\n id: string;\n\n /**\n * Typename of the data the node represents.\n */\n type: string;\n\n /**\n * Keys in of the properties which should be cached.\n * If defined, the node will be included in the cache.\n * If undefined, the node will not be included in the cache.\n */\n cacheable?: string[];\n\n /**\n * Properties of the node relevant to displaying the node.\n */\n properties: Readonly<TProperties>;\n\n /**\n * Data the node represents.\n */\n // TODO(burdon): Type system (e.g., minimally provide identifier string vs. TypedObject vs. Graph mixin type system)?\n // type field would prevent convoluted sniffing of object properties. And allow direct pass-through for ECHO TypedObjects.\n data: TData;\n}>;\n\nexport type NodeFilter<TData = any, TProperties extends Record<string, any> = Record<string, any>> = (\n node: Node<unknown, Record<string, any>>,\n connectedNode: Node,\n) => node is Node<TData, TProperties>;\n\nexport type Relation = 'outbound' | 'inbound';\n\nexport const isGraphNode = (data: unknown): data is Node =>\n data && typeof data === 'object' && 'id' in data && 'properties' in data && data.properties\n ? typeof data.properties === 'object' && 'data' in data\n : false;\n\nexport type NodeArg<TData, TProperties extends Record<string, any> = Record<string, any>> = MakeOptional<\n Node<TData, TProperties>,\n 'data' | 'properties' | 'cacheable'\n> & {\n /** Will automatically add nodes with an edge from this node to each. */\n nodes?: NodeArg<unknown>[];\n\n /** Will automatically add specified edges. */\n edges?: [string, Relation][];\n};\n\n//\n// Actions\n//\n\nexport type InvokeParams = {\n /** Node the invoked action is connected to. */\n parent?: Node;\n\n caller?: string;\n};\n\nexport type ActionData = (params?: InvokeParams) => MaybePromise<void>;\n\nexport type Action<TProperties extends Record<string, any> = Record<string, any>> = Readonly<\n Omit<Node<ActionData, TProperties>, 'properties'> & {\n properties: Readonly<TProperties>;\n }\n>;\n\nexport const isAction = (data: unknown): data is Action =>\n isGraphNode(data) ? typeof data.data === 'function' && data.type === ACTION_TYPE : false;\n\nexport const actionGroupSymbol = Symbol('ActionGroup');\n\nexport type ActionGroup<TProperties extends Record<string, any> = Record<string, any>> = Readonly<\n Omit<Node<typeof actionGroupSymbol, TProperties>, 'properties'> & {\n properties: Readonly<TProperties>;\n }\n>;\n\nexport const isActionGroup = (data: unknown): data is ActionGroup =>\n isGraphNode(data) ? data.data === actionGroupSymbol && data.type === ACTION_GROUP_TYPE : false;\n\nexport type ActionLike = Action | ActionGroup;\n\nexport const isActionLike = (data: un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AAAA;QAAAA;MAElC,CAAA,EAAG3G,KAAKF,IAAGG,UAAU,4BAA4BJ,GAAAA,EAAK,CAAA;IACxD,CAAA,CAAA;AAzHE,SAAKwC,YAAYX,YAAYiB,UAASvC,KAAI;AAC1C,SAAK4B,SAAS,IAAI4E,MAAM;MACtB,GAAGX;MACHvE,UAAU,KAAKW;MACfwE,UAAU,CAAC5H,IAAIE,aAAa,KAAK+E,UAAUjF,IAAIE,QAAAA;MAC/C2H,cAAc,CAAC7H,OAAO,KAAKoG,cAAcpG,EAAAA;MACzC8H,cAAc,CAAC9H,OAAO,KAAK8G,cAAc9G,EAAAA;IAC3C,CAAA;EACF;AAgMF;AAMO,IAAM+H,eAAe,CAAIC,OAAAA;AAC9B,SAAOnH,IAAGM,KAAK,CAACC,QAAAA;AACd,UAAMwD,UAAUqD,OAAO,MAAA;AACrB7G,UAAI8G,QAAQF,GAAAA,CAAAA;IACd,CAAA;AAEA5G,QAAI+G,aAAa,MAAMvD,QAAAA,CAAAA;AAEvB,WAAOoD,GAAAA;EACT,CAAA;AACF;AAEA,IAAMI,mBAAmBvH,IAAGC,OAAO,CAACuH,eAAAA;AAClC,SAAOxH,IAAGM,KAAK,CAACC,QAAAA;AACd,UAAMkH,eAAeD,WAAW9C,UAAU,CAACgD,UAAUnH,IAAI8G,QAAQK,KAAAA,CAAAA;AAEjEnH,QAAI+G,aAAa,MAAMG,aAAavD,YAAW,CAAA;AAE/C,WAAOsD,WAAWjH,IAAG;EACvB,CAAA;AACF,CAAA;AAMO,IAAMoH,mBAAmB,CAAIH,eAAAA;AAClC,SAAOD,iBAAiBC,UAAAA;AAC1B;",
|
|
6
|
-
"names": ["Registry", "Rx", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Registry, Rx } from '@effect-rx/rx-react';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Record from 'effect/Record';\n\nimport { Event, Trigger } from '@dxos/async';\nimport { todo } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { type MakeOptional, isNonNullable } from '@dxos/util';\n\nimport { type Action, type ActionGroup, type Node, type NodeArg, type Relation } from './node';\n\nconst graphSymbol = Symbol('graph');\ntype DeepWriteable<T> = { -readonly [K in keyof T]: T[K] extends object ? DeepWriteable<T[K]> : T[K] };\ntype NodeInternal = DeepWriteable<Node> & { [graphSymbol]: Graph };\n\n/**\n * Get the Graph a Node is currently associated with.\n */\nexport const getGraph = (node: Node): Graph => {\n const graph = (node as NodeInternal)[graphSymbol];\n invariant(graph, 'Node is not associated with a graph.');\n return graph;\n};\n\nexport const ROOT_ID = 'root';\nexport const ROOT_TYPE = 'dxos.org/type/GraphRoot';\nexport const ACTION_TYPE = 'dxos.org/type/GraphAction';\nexport const ACTION_GROUP_TYPE = 'dxos.org/type/GraphActionGroup';\n\nexport type GraphTraversalOptions = {\n /**\n * A callback which is called for each node visited during traversal.\n *\n * If the callback returns `false`, traversal is stops recursing.\n */\n visitor: (node: Node, path: string[]) => boolean | void;\n\n /**\n * The node to start traversing from.\n *\n * @default ROOT_ID\n */\n source?: string;\n\n /**\n * The relation to traverse graph edges.\n *\n * @default 'outbound'\n */\n relation?: Relation;\n};\n\nexport type GraphParams = {\n registry?: Registry.Registry;\n nodes?: MakeOptional<Node, 'data' | 'cacheable'>[];\n edges?: Record<string, Edges>;\n onExpand?: Graph['_onExpand'];\n onInitialize?: Graph['_onInitialize'];\n onRemoveNode?: Graph['_onRemoveNode'];\n};\n\nexport type Edge = { source: string; target: string };\nexport type Edges = { inbound: string[]; outbound: string[] };\n\nexport interface ReadableGraph {\n /**\n * Event emitted when a node is changed.\n */\n onNodeChanged: Event<{ id: string; node: Option.Option<Node> }>;\n\n /**\n * Convert the graph to a JSON object.\n */\n toJSON(id?: string): object;\n\n json(id?: string): Rx.Rx<any>;\n\n /**\n * Get the rx key for the node with the given id.\n */\n node(id: string): Rx.Rx<Option.Option<Node>>;\n\n /**\n * Get the rx key for the node with the given id.\n */\n nodeOrThrow(id: string): Rx.Rx<Node>;\n\n /**\n * Get the rx key for the connections of the node with the given id.\n */\n connections(id: string, relation?: Relation): Rx.Rx<Node[]>;\n\n /**\n * Get the rx key for the actions of the node with the given id.\n */\n actions(id: string): Rx.Rx<(Action | ActionGroup)[]>;\n\n /**\n * Get the rx key for the edges of the node with the given id.\n */\n edges(id: string): Rx.Rx<Edges>;\n\n /**\n * Alias for `getNodeOrThrow(ROOT_ID)`.\n */\n get root(): Node;\n\n /**\n * Get the node with the given id from the graph's registry.\n */\n getNode(id: string): Option.Option<Node>;\n\n /**\n * Get the node with the given id from the graph's registry.\n *\n * @throws If the node is Option.none().\n */\n getNodeOrThrow(id: string): Node;\n\n /**\n * Get all nodes connected to the node with the given id by the given relation from the graph's registry.\n */\n getConnections(id: string, relation?: Relation): Node[];\n\n /**\n * Get all actions connected to the node with the given id from the graph's registry.\n */\n getActions(id: string): Node[];\n\n /**\n * Get the edges from the node with the given id from the graph's registry.\n */\n getEdges(id: string): Edges;\n\n /**\n * Recursive depth-first traversal of the graph.\n *\n * @param options.node The node to start traversing from.\n * @param options.relation The relation to traverse graph edges.\n * @param options.visitor A callback which is called for each node visited during traversal.\n */\n traverse(options: GraphTraversalOptions, path?: string[]): void;\n\n /**\n * Get the path between two nodes in the graph.\n */\n getPath(params: { source?: string; target: string }): Option.Option<string[]>;\n\n /**\n * Wait for the path between two nodes in the graph to be established.\n */\n waitForPath(\n params: { source?: string; target: string },\n options?: { timeout?: number; interval?: number },\n ): Promise<string[]>;\n}\n\nexport interface ExpandableGraph extends ReadableGraph {\n /**\n * Initialize a node in the graph.\n *\n * Fires the `onInitialize` callback to provide initial data for a node.\n */\n initialize(id: string): Promise<void>;\n\n /**\n * Expand a node in the graph.\n *\n * Fires the `onExpand` callback to add connections to the node.\n */\n expand(id: string, relation?: Relation): void;\n\n /**\n * Sort the edges of the node with the given id.\n */\n sortEdges(id: string, relation: Relation, order: string[]): void;\n}\n\nexport interface WritableGraph extends ExpandableGraph {\n /**\n * Add nodes to the graph.\n */\n addNodes(nodes: NodeArg<any, Record<string, any>>[]): void;\n\n /**\n * Add a node to the graph.\n */\n addNode(node: NodeArg<any, Record<string, any>>): void;\n\n /**\n * Remove nodes from the graph.\n */\n removeNodes(ids: string[], edges?: boolean): void;\n\n /**\n * Remove a node from the graph.\n */\n removeNode(id: string, edges?: boolean): void;\n\n /**\n * Add edges to the graph.\n */\n addEdges(edges: Edge[]): void;\n\n /**\n * Add an edge to the graph.\n */\n addEdge(edge: Edge): void;\n\n /**\n * Remove edges from the graph.\n */\n removeEdges(edges: Edge[], removeOrphans?: boolean): void;\n\n /**\n * Remove an edge from the graph.\n */\n removeEdge(edge: Edge, removeOrphans?: boolean): void;\n}\n\n/**\n * The Graph represents the user interface information architecture of the application constructed via plugins.\n */\nexport class Graph implements WritableGraph {\n readonly onNodeChanged = new Event<{ id: string; node: Option.Option<Node> }>();\n\n private readonly _onExpand?: (id: string, relation: Relation) => void;\n private readonly _onInitialize?: (id: string) => Promise<void>;\n private readonly _onRemoveNode?: (id: string) => void;\n\n private readonly _registry: Registry.Registry;\n private readonly _expanded = Record.empty<string, boolean>();\n private readonly _initialized = Record.empty<string, boolean>();\n private readonly _initialEdges = Record.empty<string, Edges>();\n private readonly _initialNodes = Record.fromEntries([\n [ROOT_ID, this._constructNode({ id: ROOT_ID, type: ROOT_TYPE, data: null, properties: {} })],\n ]);\n\n /** @internal */\n readonly _node = Rx.family<string, Rx.Writable<Option.Option<Node>>>((id) => {\n const initial = Option.flatten(Record.get(this._initialNodes, id));\n return Rx.make<Option.Option<Node>>(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:node:${id}`));\n });\n\n private readonly _nodeOrThrow = Rx.family<string, Rx.Rx<Node>>((id) => {\n return Rx.make((get) => {\n const node = get(this._node(id));\n invariant(Option.isSome(node), `Node not available: ${id}`);\n return node.value;\n });\n });\n\n private readonly _edges = Rx.family<string, Rx.Writable<Edges>>((id) => {\n const initial = Record.get(this._initialEdges, id).pipe(Option.getOrElse(() => ({ inbound: [], outbound: [] })));\n return Rx.make<Edges>(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:edges:${id}`));\n });\n\n // NOTE: Currently the argument to the family needs to be referentially stable for the rx to be referentially stable.\n // TODO(wittjosiah): Rx feature request, support for something akin to `ComplexMap` to allow for complex arguments.\n private readonly _connections = Rx.family<string, Rx.Rx<Node[]>>((key) => {\n return Rx.make((get) => {\n const [id, relation] = key.split('$');\n const edges = get(this._edges(id));\n return edges[relation as Relation]\n .map((id) => get(this._node(id)))\n .filter(Option.isSome)\n .map((o) => o.value);\n }).pipe(Rx.withLabel(`graph:connections:${key}`));\n });\n\n private readonly _actions = Rx.family<string, Rx.Rx<(Action | ActionGroup)[]>>((id) => {\n return Rx.make((get) => {\n return get(this._connections(`${id}$outbound`)).filter(\n (node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE,\n );\n }).pipe(Rx.withLabel(`graph:actions:${id}`));\n });\n\n private readonly _json = Rx.family<string, Rx.Rx<any>>((id) => {\n return Rx.make((get) => {\n const toJSON = (node: Node, seen: string[] = []): any => {\n const nodes = get(this.connections(node.id));\n const obj: Record<string, any> = {\n id: node.id,\n type: node.type,\n };\n if (node.properties.label) {\n obj.label = node.properties.label;\n }\n if (nodes.length) {\n obj.nodes = nodes\n .map((n) => {\n // Break cycles.\n const nextSeen = [...seen, node.id];\n return nextSeen.includes(n.id) ? undefined : toJSON(n, nextSeen);\n })\n .filter(isNonNullable);\n }\n return obj;\n };\n\n const root = get(this.nodeOrThrow(id));\n return toJSON(root);\n }).pipe(Rx.withLabel(`graph:json:${id}`));\n });\n\n constructor({ registry, nodes, edges, onInitialize, onExpand, onRemoveNode }: GraphParams = {}) {\n this._registry = registry ?? Registry.make();\n this._onInitialize = onInitialize;\n this._onExpand = onExpand;\n this._onRemoveNode = onRemoveNode;\n\n if (nodes) {\n nodes.forEach((node) => {\n Record.set(this._initialNodes, node.id, this._constructNode(node));\n });\n }\n\n if (edges) {\n Object.entries(edges).forEach(([source, edges]) => {\n Record.set(this._initialEdges, source, edges);\n });\n }\n }\n\n toJSON(id = ROOT_ID) {\n return this._registry.get(this._json(id));\n }\n\n json(id = ROOT_ID) {\n return this._json(id);\n }\n\n node(id: string): Rx.Rx<Option.Option<Node>> {\n return this._node(id);\n }\n\n nodeOrThrow(id: string): Rx.Rx<Node> {\n return this._nodeOrThrow(id);\n }\n\n connections(id: string, relation: Relation = 'outbound'): Rx.Rx<Node[]> {\n return this._connections(`${id}$${relation}`);\n }\n\n actions(id: string) {\n return this._actions(id);\n }\n\n edges(id: string): Rx.Rx<Edges> {\n return this._edges(id);\n }\n\n get root() {\n return this.getNodeOrThrow(ROOT_ID);\n }\n\n getNode(id: string): Option.Option<Node> {\n return this._registry.get(this.node(id));\n }\n\n getNodeOrThrow(id: string): Node {\n return this._registry.get(this.nodeOrThrow(id));\n }\n\n getConnections(id: string, relation: Relation = 'outbound'): Node[] {\n return this._registry.get(this.connections(id, relation));\n }\n\n getActions(id: string): Node[] {\n return this._registry.get(this.actions(id));\n }\n\n getEdges(id: string): Edges {\n return this._registry.get(this.edges(id));\n }\n\n async initialize(id: string) {\n const initialized = Record.get(this._initialized, id).pipe(Option.getOrElse(() => false));\n log('initialize', { id, initialized });\n if (!initialized) {\n await this._onInitialize?.(id);\n Record.set(this._initialized, id, true);\n }\n }\n\n expand(id: string, relation: Relation = 'outbound'): void {\n const key = `${id}$${relation}`;\n const expanded = Record.get(this._expanded, key).pipe(Option.getOrElse(() => false));\n log('expand', { key, expanded });\n if (!expanded) {\n this._onExpand?.(id, relation);\n Record.set(this._expanded, key, true);\n }\n }\n\n addNodes(nodes: NodeArg<any, Record<string, any>>[]): void {\n Rx.batch(() => {\n nodes.map((node) => this.addNode(node));\n });\n }\n\n addNode({ nodes, edges, ...nodeArg }: NodeArg<any, Record<string, any>>): void {\n const { id, type, data = null, properties = {} } = nodeArg;\n const nodeRx = this._node(id);\n const node = this._registry.get(nodeRx);\n Option.match(node, {\n onSome: (node) => {\n const typeChanged = node.type !== type;\n const dataChanged = node.data !== data;\n const propertiesChanged = Object.keys(properties).some((key) => node.properties[key] !== properties[key]);\n log('existing node', { id, typeChanged, dataChanged, propertiesChanged });\n if (typeChanged || dataChanged || propertiesChanged) {\n log('updating node', { id, type, data, properties });\n const newNode = Option.some({ ...node, type, data, properties: { ...node.properties, ...properties } });\n this._registry.set(nodeRx, newNode);\n this.onNodeChanged.emit({ id, node: newNode });\n }\n },\n onNone: () => {\n log('new node', { id, type, data, properties });\n const newNode = this._constructNode({ id, type, data, properties });\n this._registry.set(nodeRx, newNode);\n this.onNodeChanged.emit({ id, node: newNode });\n },\n });\n\n if (nodes) {\n // Rx.batch(() => {\n this.addNodes(nodes);\n const _edges = nodes.map((node) => ({ source: id, target: node.id }));\n this.addEdges(_edges);\n // });\n }\n\n if (edges) {\n todo();\n }\n }\n\n removeNodes(ids: string[], edges = false): void {\n Rx.batch(() => {\n ids.map((id) => this.removeNode(id, edges));\n });\n }\n\n removeNode(id: string, edges = false): void {\n const nodeRx = this._node(id);\n // TODO(wittjosiah): Is there a way to mark these rx values for garbage collection?\n this._registry.set(nodeRx, Option.none());\n this.onNodeChanged.emit({ id, node: Option.none() });\n // TODO(wittjosiah): Reset expanded and initialized flags?\n\n if (edges) {\n const { inbound, outbound } = this._registry.get(this._edges(id));\n const edges = [\n ...inbound.map((source) => ({ source, target: id })),\n ...outbound.map((target) => ({ source: id, target })),\n ];\n this.removeEdges(edges);\n }\n\n this._onRemoveNode?.(id);\n }\n\n addEdges(edges: Edge[]): void {\n Rx.batch(() => {\n edges.map((edge) => this.addEdge(edge));\n });\n }\n\n addEdge(edgeArg: Edge): void {\n const sourceRx = this._edges(edgeArg.source);\n const source = this._registry.get(sourceRx);\n if (!source.outbound.includes(edgeArg.target)) {\n log('add outbound edge', { source: edgeArg.source, target: edgeArg.target });\n this._registry.set(sourceRx, { inbound: source.inbound, outbound: [...source.outbound, edgeArg.target] });\n }\n\n const targetRx = this._edges(edgeArg.target);\n const target = this._registry.get(targetRx);\n if (!target.inbound.includes(edgeArg.source)) {\n log('add inbound edge', { source: edgeArg.source, target: edgeArg.target });\n this._registry.set(targetRx, { inbound: [...target.inbound, edgeArg.source], outbound: target.outbound });\n }\n }\n\n removeEdges(edges: Edge[], removeOrphans = false): void {\n Rx.batch(() => {\n edges.map((edge) => this.removeEdge(edge, removeOrphans));\n });\n }\n\n removeEdge(edgeArg: Edge, removeOrphans = false): void {\n const sourceRx = this._edges(edgeArg.source);\n const source = this._registry.get(sourceRx);\n if (source.outbound.includes(edgeArg.target)) {\n this._registry.set(sourceRx, {\n inbound: source.inbound,\n outbound: source.outbound.filter((id) => id !== edgeArg.target),\n });\n }\n\n const targetRx = this._edges(edgeArg.target);\n const target = this._registry.get(targetRx);\n if (target.inbound.includes(edgeArg.source)) {\n this._registry.set(targetRx, {\n inbound: target.inbound.filter((id) => id !== edgeArg.source),\n outbound: target.outbound,\n });\n }\n\n if (removeOrphans) {\n const source = this._registry.get(sourceRx);\n const target = this._registry.get(targetRx);\n if (source.outbound.length === 0 && source.inbound.length === 0 && edgeArg.source !== ROOT_ID) {\n this.removeNodes([edgeArg.source]);\n }\n if (target.outbound.length === 0 && target.inbound.length === 0 && edgeArg.target !== ROOT_ID) {\n this.removeNodes([edgeArg.target]);\n }\n }\n }\n\n sortEdges(id: string, relation: Relation, order: string[]): void {\n const edgesRx = this._edges(id);\n const edges = this._registry.get(edgesRx);\n const unsorted = edges[relation].filter((id) => !order.includes(id)) ?? [];\n const sorted = order.filter((id) => edges[relation].includes(id)) ?? [];\n edges[relation].splice(0, edges[relation].length, ...[...sorted, ...unsorted]);\n this._registry.set(edgesRx, edges);\n }\n\n traverse({ visitor, source = ROOT_ID, relation = 'outbound' }: GraphTraversalOptions, path: string[] = []): void {\n // Break cycles.\n if (path.includes(source)) {\n return;\n }\n\n const node = this.getNodeOrThrow(source);\n const shouldContinue = visitor(node, [...path, source]);\n if (shouldContinue === false) {\n return;\n }\n\n Object.values(this.getConnections(source, relation)).forEach((child) =>\n this.traverse({ source: child.id, relation, visitor }, [...path, source]),\n );\n }\n\n getPath({ source = 'root', target }: { source?: string; target: string }): Option.Option<string[]> {\n return Function.pipe(\n this.getNode(source),\n Option.flatMap((node) => {\n let found: Option.Option<string[]> = Option.none();\n this.traverse({\n source: node.id,\n visitor: (node, path) => {\n if (Option.isSome(found)) {\n return false;\n }\n\n if (node.id === target) {\n found = Option.some(path);\n }\n },\n });\n\n return found;\n }),\n );\n }\n\n async waitForPath(\n params: { source?: string; target: string },\n { timeout = 5_000, interval = 500 }: { timeout?: number; interval?: number } = {},\n ): Promise<string[]> {\n const path = this.getPath(params);\n if (Option.isSome(path)) {\n return path.value;\n }\n\n const trigger = new Trigger<string[]>();\n const i = setInterval(() => {\n const path = this.getPath(params);\n if (Option.isSome(path)) {\n trigger.wake(path.value);\n }\n }, interval);\n\n return trigger.wait({ timeout }).finally(() => clearInterval(i));\n }\n\n /** @internal */\n _constructNode(node: NodeArg<any>): Option.Option<Node> {\n return Option.some({ [graphSymbol]: this, data: null, properties: {}, ...node });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Registry, Rx } from '@effect-rx/rx-react';\nimport { effect } from '@preact/signals-core';\nimport * as Array from 'effect/Array';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Record from 'effect/Record';\n\nimport { type CleanupFn, type MulticastObservable, type Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { type MaybePromise, type Position, byPosition, getDebugName, isNode, isNonNullable } from '@dxos/util';\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE, type ExpandableGraph, Graph, type GraphParams, ROOT_ID } from './graph';\nimport { type ActionData, type Node, type NodeArg, type Relation, actionGroupSymbol } from './node';\n\n/**\n * Graph builder extension for adding nodes to the graph based on a node id.\n */\nexport type ResolverExtension = (id: string) => Rx.Rx<NodeArg<any> | null>;\n\n/**\n * Graph builder extension for adding nodes to the graph based on a connection to an existing node.\n *\n * @param params.node The existing node the returned nodes will be connected to.\n */\nexport type ConnectorExtension = (node: Rx.Rx<Option.Option<Node>>) => Rx.Rx<NodeArg<any>[]>;\n\n/**\n * Constrained case of the connector extension for more easily adding actions to the graph.\n */\nexport type ActionsExtension = (\n node: Rx.Rx<Option.Option<Node>>,\n) => Rx.Rx<Omit<NodeArg<ActionData>, 'type' | 'nodes' | 'edges'>[]>;\n\n/**\n * Constrained case of the connector extension for more easily adding action groups to the graph.\n */\nexport type ActionGroupsExtension = (\n node: Rx.Rx<Option.Option<Node>>,\n) => Rx.Rx<Omit<NodeArg<typeof actionGroupSymbol>, 'type' | 'data' | 'nodes' | 'edges'>[]>;\n\n/**\n * A graph builder extension is used to add nodes to the graph.\n *\n * @param params.id The unique id of the extension.\n * @param params.relation The relation the graph is being expanded from the existing node.\n * @param params.position Affects the order the extensions are processed in.\n * @param params.resolver A function to add nodes to the graph based on just the node id.\n * @param params.connector A function to add nodes to the graph based on a connection to an existing node.\n * @param params.actions A function to add actions to the graph based on a connection to an existing node.\n * @param params.actionGroups A function to add action groups to the graph based on a connection to an existing node.\n */\nexport type CreateExtensionOptions = {\n id: string;\n relation?: Relation;\n position?: Position;\n resolver?: ResolverExtension;\n connector?: ConnectorExtension;\n actions?: ActionsExtension;\n actionGroups?: ActionGroupsExtension;\n};\n\n/**\n * Create a graph builder extension.\n */\nexport const createExtension = (extension: CreateExtensionOptions): BuilderExtension[] => {\n const {\n id,\n position = 'static',\n relation = 'outbound',\n resolver: _resolver,\n connector: _connector,\n actions: _actions,\n actionGroups: _actionGroups,\n } = extension;\n const getId = (key: string) => `${id}/${key}`;\n\n const resolver =\n _resolver && Rx.family((id: string) => _resolver(id).pipe(Rx.withLabel(`graph-builder:_resolver:${id}`)));\n\n const connector =\n _connector &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) =>\n _connector(node).pipe(Rx.withLabel(`graph-builder:_connector:${id}`)),\n );\n\n const actionGroups =\n _actionGroups &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) =>\n _actionGroups(node).pipe(Rx.withLabel(`graph-builder:_actionGroups:${id}`)),\n );\n\n const actions =\n _actions &&\n Rx.family((node: Rx.Rx<Option.Option<Node>>) => _actions(node).pipe(Rx.withLabel(`graph-builder:_actions:${id}`)));\n\n return [\n resolver ? { id: getId('resolver'), position, resolver } : undefined,\n connector\n ? ({\n id: getId('connector'),\n position,\n relation,\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(connector(node));\n } catch {\n log.warn('Error in connector', { id: getId('connector'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n actionGroups\n ? ({\n id: getId('actionGroups'),\n position,\n relation: 'outbound',\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(actionGroups(node)).map((arg) => ({\n ...arg,\n data: actionGroupSymbol,\n type: ACTION_GROUP_TYPE,\n }));\n } catch {\n log.warn('Error in actionGroups', { id: getId('actionGroups'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:actionGroups:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n actions\n ? ({\n id: getId('actions'),\n position,\n relation: 'outbound',\n connector: Rx.family((node) =>\n Rx.make((get) => {\n try {\n return get(actions(node)).map((arg) => ({ ...arg, type: ACTION_TYPE }));\n } catch {\n log.warn('Error in actions', { id: getId('actions'), node });\n return [];\n }\n }).pipe(Rx.withLabel(`graph-builder:connector:actions:${id}`)),\n ),\n } satisfies BuilderExtension)\n : undefined,\n ].filter(isNonNullable);\n};\n\nexport type GraphBuilderTraverseOptions = {\n visitor: (node: Node, path: string[]) => MaybePromise<boolean | void>;\n registry?: Registry.Registry;\n source?: string;\n relation?: Relation;\n};\n\nexport type BuilderExtension = Readonly<{\n id: string;\n position: Position;\n relation?: Relation; // Only for connector.\n resolver?: ResolverExtension;\n connector?: (node: Rx.Rx<Option.Option<Node>>) => Rx.Rx<NodeArg<any>[]>;\n}>;\n\nexport type BuilderExtensions = BuilderExtension | BuilderExtension[] | BuilderExtensions[];\n\nexport const flattenExtensions = (extension: BuilderExtensions, acc: BuilderExtension[] = []): BuilderExtension[] => {\n if (Array.isArray(extension)) {\n return [...acc, ...extension.flatMap((ext) => flattenExtensions(ext, acc))];\n } else {\n return [...acc, extension];\n }\n};\n\n/**\n * The builder provides an extensible way to compose the construction of the graph.\n */\n// TODO(wittjosiah): Add api for setting subscription set and/or radius.\n// Should unsubscribe from nodes that are not in the set/radius.\n// Should track LRU nodes that are not in the set/radius and remove them beyond a certain threshold.\nexport class GraphBuilder {\n // TODO(wittjosiah): Use Context.\n private readonly _subscriptions = new Map<string, CleanupFn>();\n private readonly _extensions = Rx.make(Record.empty<string, BuilderExtension>()).pipe(\n Rx.keepAlive,\n Rx.withLabel('graph-builder:extensions'),\n );\n private readonly _initialized: Record<string, Trigger> = {};\n private readonly _registry: Registry.Registry;\n private readonly _graph: Graph;\n\n constructor({ registry, ...params }: Pick<GraphParams, 'registry' | 'nodes' | 'edges'> = {}) {\n this._registry = registry ?? Registry.make();\n this._graph = new Graph({\n ...params,\n registry: this._registry,\n onExpand: (id, relation) => this._onExpand(id, relation),\n onInitialize: (id) => this._onInitialize(id),\n onRemoveNode: (id) => this._onRemoveNode(id),\n });\n }\n\n static from(pickle?: string, registry?: Registry.Registry): GraphBuilder {\n if (!pickle) {\n return new GraphBuilder({ registry });\n }\n\n const { nodes, edges } = JSON.parse(pickle);\n return new GraphBuilder({ nodes, edges, registry });\n }\n\n get graph(): ExpandableGraph {\n return this._graph;\n }\n\n get extensions() {\n return this._extensions;\n }\n\n addExtension(extensions: BuilderExtensions): GraphBuilder {\n flattenExtensions(extensions).forEach((extension) => {\n const extensions = this._registry.get(this._extensions);\n this._registry.set(this._extensions, Record.set(extensions, extension.id, extension));\n });\n return this;\n }\n\n removeExtension(id: string): GraphBuilder {\n const extensions = this._registry.get(this._extensions);\n this._registry.set(this._extensions, Record.remove(extensions, id));\n return this;\n }\n\n async explore(\n // TODO(wittjosiah): Currently defaulting to new registry.\n // Currently unsure about how to handle nodes which are expanded in the background.\n // This seems like a good place to start.\n { registry = Registry.make(), source = ROOT_ID, relation = 'outbound', visitor }: GraphBuilderTraverseOptions,\n path: string[] = [],\n ): Promise<void> {\n // Break cycles.\n if (path.includes(source)) {\n return;\n }\n\n // TODO(wittjosiah): This is a workaround for esm not working in the test runner.\n // Switching to vitest is blocked by having node esm versions of echo-schema & echo-signals.\n if (!isNode()) {\n const { yieldOrContinue } = await import('main-thread-scheduling');\n await yieldOrContinue('idle');\n }\n\n const node = registry.get(this._graph.nodeOrThrow(source));\n const shouldContinue = await visitor(node, [...path, node.id]);\n if (shouldContinue === false) {\n return;\n }\n\n const nodes = Object.values(this._registry.get(this._extensions))\n .filter((extension) => relation === (extension.relation ?? 'outbound'))\n .map((extension) => extension.connector)\n .filter(isNonNullable)\n .flatMap((connector) => registry.get(connector(this._graph.node(source))));\n\n await Promise.all(\n nodes.map((nodeArg) => {\n registry.set(this._graph._node(nodeArg.id), this._graph._constructNode(nodeArg));\n return this.explore({ registry, source: nodeArg.id, relation, visitor }, [...path, node.id]);\n }),\n );\n\n if (registry !== this._registry) {\n registry.reset();\n registry.dispose();\n }\n }\n\n destroy(): void {\n this._subscriptions.forEach((unsubscribe) => unsubscribe());\n this._subscriptions.clear();\n }\n\n private readonly _resolvers = Rx.family<string, Rx.Rx<Option.Option<NodeArg<any>>>>((id) => {\n return Rx.make((get) => {\n return Function.pipe(\n get(this._extensions),\n Record.values,\n Array.sortBy(byPosition),\n Array.map(({ resolver }) => resolver),\n Array.filter(isNonNullable),\n Array.map((resolver) => get(resolver(id))),\n Array.filter(isNonNullable),\n Array.head,\n );\n });\n });\n\n private readonly _connectors = Rx.family<string, Rx.Rx<NodeArg<any>[]>>((key) => {\n return Rx.make((get) => {\n const [id, relation] = key.split('+');\n const node = this._graph.node(id);\n\n return Function.pipe(\n get(this._extensions),\n Record.values,\n // TODO(wittjosiah): Sort on write rather than read.\n Array.sortBy(byPosition),\n Array.filter(({ relation: _relation = 'outbound' }) => _relation === relation),\n Array.map(({ connector }) => connector?.(node)),\n Array.filter(isNonNullable),\n Array.flatMap((result) => get(result)),\n );\n }).pipe(Rx.withLabel(`graph-builder:connectors:${key}`));\n });\n\n private _onExpand(id: string, relation: Relation): void {\n log('onExpand', { id, relation, registry: getDebugName(this._registry) });\n const connectors = this._connectors(`${id}+${relation}`);\n\n let previous: string[] = [];\n const cancel = this._registry.subscribe(\n connectors,\n (nodes) => {\n const ids = nodes.map((n) => n.id);\n const removed = previous.filter((id) => !ids.includes(id));\n previous = ids;\n\n log('update', { id, relation, ids, removed });\n const update = () => {\n Rx.batch(() => {\n this._graph.removeEdges(\n removed.map((target) => ({ source: id, target })),\n true,\n );\n this._graph.addNodes(nodes);\n this._graph.addEdges(\n nodes.map((node) =>\n relation === 'outbound' ? { source: id, target: node.id } : { source: node.id, target: id },\n ),\n );\n this._graph.sortEdges(\n id,\n relation,\n nodes.map(({ id }) => id),\n );\n });\n };\n\n // TODO(wittjosiah): Remove `requestAnimationFrame` once we have a better solution.\n // This is a workaround to avoid a race condition where the graph is updated during React render.\n if (typeof requestAnimationFrame === 'function') {\n requestAnimationFrame(update);\n } else {\n update();\n }\n },\n { immediate: true },\n );\n\n this._subscriptions.set(id, cancel);\n }\n\n // TODO(wittjosiah): If the same node is added by a connector, the resolver should probably cancel itself?\n private async _onInitialize(id: string) {\n log('onInitialize', { id });\n const resolver = this._resolvers(id);\n\n const cancel = this._registry.subscribe(\n resolver,\n (node) => {\n const trigger = this._initialized[id];\n Option.match(node, {\n onSome: (node) => {\n this._graph.addNodes([node]);\n trigger?.wake();\n },\n onNone: () => {\n trigger?.wake();\n this._graph.removeNodes([id]);\n },\n });\n },\n { immediate: true },\n );\n\n this._subscriptions.set(id, cancel);\n }\n\n private _onRemoveNode(id: string): void {\n this._subscriptions.get(id)?.();\n this._subscriptions.delete(id);\n }\n}\n\n/**\n * Creates an Rx.Rx<T> from a callback which accesses signals.\n * Will return a new rx instance each time.\n */\nexport const rxFromSignal = <T>(cb: () => T): Rx.Rx<T> => {\n return Rx.make((get) => {\n const dispose = effect(() => {\n get.setSelf(cb());\n });\n\n get.addFinalizer(() => dispose());\n\n return cb();\n });\n};\n\nconst observableFamily = Rx.family((observable: MulticastObservable<any>) => {\n return Rx.make((get) => {\n const subscription = observable.subscribe((value) => get.setSelf(value));\n\n get.addFinalizer(() => subscription.unsubscribe());\n\n return observable.get();\n });\n});\n\n/**\n * Creates an Rx.Rx<T> from a MulticastObservable<T>\n * Will return the same rx instance for the same observable.\n */\nexport const rxFromObservable = <T>(observable: MulticastObservable<T>): Rx.Rx<T> => {\n return observableFamily(observable) as Rx.Rx<T>;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type MakeOptional, type MaybePromise } from '@dxos/util';\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE } from './graph';\n\n/**\n * Represents a node in the graph.\n */\n// TODO(wittjosiah): Use Effect Schema.\n// TODO(burdon): Rename GraphNode. Node is already in the global namespace.\nexport type Node<TData = any, TProperties extends Record<string, any> = Record<string, any>> = Readonly<{\n /**\n * Globally unique ID.\n */\n // TODO(burdon): Allow string array, which is concatenated.\n id: string;\n\n /**\n * Typename of the data the node represents.\n */\n type: string;\n\n /**\n * Keys in of the properties which should be cached.\n * If defined, the node will be included in the cache.\n * If undefined, the node will not be included in the cache.\n */\n cacheable?: string[];\n\n /**\n * Properties of the node relevant to displaying the node.\n */\n properties: Readonly<TProperties>;\n\n /**\n * Data the node represents.\n */\n // TODO(burdon): Type system (e.g., minimally provide identifier string vs. TypedObject vs. Graph mixin type system)?\n // type field would prevent convoluted sniffing of object properties. And allow direct pass-through for ECHO TypedObjects.\n data: TData;\n}>;\n\nexport type NodeFilter<TData = any, TProperties extends Record<string, any> = Record<string, any>> = (\n node: Node<unknown, Record<string, any>>,\n connectedNode: Node,\n) => node is Node<TData, TProperties>;\n\nexport type Relation = 'outbound' | 'inbound';\n\nexport const isGraphNode = (data: unknown): data is Node =>\n data && typeof data === 'object' && 'id' in data && 'properties' in data && data.properties\n ? typeof data.properties === 'object' && 'data' in data\n : false;\n\nexport type NodeArg<TData, TProperties extends Record<string, any> = Record<string, any>> = MakeOptional<\n Node<TData, TProperties>,\n 'data' | 'properties' | 'cacheable'\n> & {\n /** Will automatically add nodes with an edge from this node to each. */\n nodes?: NodeArg<unknown>[];\n\n /** Will automatically add specified edges. */\n edges?: [string, Relation][];\n};\n\n//\n// Actions\n//\n\nexport type InvokeParams = {\n /** Node the invoked action is connected to. */\n parent?: Node;\n\n caller?: string;\n};\n\nexport type ActionData = (params?: InvokeParams) => MaybePromise<void>;\n\nexport type Action<TProperties extends Record<string, any> = Record<string, any>> = Readonly<\n Omit<Node<ActionData, TProperties>, 'properties'> & {\n properties: Readonly<TProperties>;\n }\n>;\n\nexport const isAction = (data: unknown): data is Action =>\n isGraphNode(data) ? typeof data.data === 'function' && data.type === ACTION_TYPE : false;\n\nexport const actionGroupSymbol = Symbol('ActionGroup');\n\nexport type ActionGroup<TProperties extends Record<string, any> = Record<string, any>> = Readonly<\n Omit<Node<typeof actionGroupSymbol, TProperties>, 'properties'> & {\n properties: Readonly<TProperties>;\n }\n>;\n\nexport const isActionGroup = (data: unknown): data is ActionGroup =>\n isGraphNode(data) ? data.data === actionGroupSymbol && data.type === ACTION_GROUP_TYPE : false;\n\nexport type ActionLike = Action | ActionGroup;\n\nexport const isActionLike = (data: unknown): data is Action | ActionGroup => isAction(data) || isActionGroup(data);\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,UAAUC,UAAU;AAC7B,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,OAAOC,eAAe;AAC/B,SAASC,YAAY;AACrB,SAASC,iBAAiB;AAC1B,SAASC,WAAW;AACpB,SAA4BC,qBAAqB;;;;;;;;;;;;;;;A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AA;EACT,CAAA;AACF;AAEA,IAAMI,mBAAmBrH,IAAGC,OAAO,CAACqH,eAAAA;AAClC,SAAOtH,IAAGM,KAAK,CAACC,SAAAA;AACd,UAAMgH,eAAeD,WAAW9C,UAAU,CAACgD,UAAUjH,KAAI4G,QAAQK,KAAAA,CAAAA;AAEjEjH,IAAAA,KAAI6G,aAAa,MAAMG,aAAavD,YAAW,CAAA;AAE/C,WAAOsD,WAAW/G,IAAG;EACvB,CAAA;AACF,CAAA;AAMO,IAAMkH,mBAAmB,CAAIH,eAAAA;AAClC,SAAOD,iBAAiBC,UAAAA;AAC1B;",
|
|
6
|
+
"names": ["Registry", "Rx", "Function", "Option", "Record", "Event", "Trigger", "todo", "invariant", "log", "isNonNullable", "graphSymbol", "Symbol", "getGraph", "node", "graph", "ROOT_ID", "ROOT_TYPE", "ACTION_TYPE", "ACTION_GROUP_TYPE", "Graph", "toJSON", "id", "_registry", "get", "_json", "json", "_node", "nodeOrThrow", "_nodeOrThrow", "connections", "relation", "_connections", "actions", "_actions", "edges", "_edges", "root", "getNodeOrThrow", "getNode", "getConnections", "getActions", "getEdges", "initialize", "initialized", "_initialized", "pipe", "getOrElse", "_onInitialize", "set", "expand", "key", "expanded", "_expanded", "_onExpand", "addNodes", "nodes", "batch", "map", "addNode", "nodeArg", "type", "data", "properties", "nodeRx", "match", "onSome", "typeChanged", "dataChanged", "propertiesChanged", "Object", "keys", "some", "newNode", "onNodeChanged", "emit", "onNone", "_constructNode", "source", "target", "addEdges", "removeNodes", "ids", "removeNode", "none", "inbound", "outbound", "removeEdges", "_onRemoveNode", "edge", "addEdge", "edgeArg", "sourceRx", "includes", "targetRx", "removeOrphans", "removeEdge", "filter", "length", "sortEdges", "order", "edgesRx", "unsorted", "sorted", "splice", "traverse", "visitor", "path", "shouldContinue", "values", "forEach", "child", "getPath", "flatMap", "found", "isSome", "waitForPath", "params", "timeout", "interval", "value", "trigger", "i", "setInterval", "wake", "wait", "finally", "clearInterval", "registry", "onInitialize", "onExpand", "onRemoveNode", "empty", "_initialEdges", "_initialNodes", "fromEntries", "family", "initial", "flatten", "make", "keepAlive", "withLabel", "split", "o", "seen", "obj", "label", "n", "nextSeen", "undefined", "entries", "Registry", "Rx", "effect", "Array", "Function", "Option", "Record", "log", "byPosition", "getDebugName", "isNode", "isNonNullable", "isGraphNode", "data", "properties", "isAction", "type", "ACTION_TYPE", "actionGroupSymbol", "Symbol", "isActionGroup", "ACTION_GROUP_TYPE", "isActionLike", "createExtension", "extension", "id", "position", "relation", "resolver", "_resolver", "connector", "_connector", "actions", "_actions", "actionGroups", "_actionGroups", "getId", "key", "Rx", "family", "pipe", "withLabel", "node", "undefined", "make", "get", "log", "warn", "map", "arg", "data", "actionGroupSymbol", "type", "ACTION_GROUP_TYPE", "ACTION_TYPE", "filter", "isNonNullable", "flattenExtensions", "acc", "isArray", "flatMap", "ext", "GraphBuilder", "from", "pickle", "registry", "nodes", "edges", "JSON", "parse", "graph", "_graph", "extensions", "_extensions", "addExtension", "forEach", "_registry", "set", "removeExtension", "remove", "explore", "Registry", "source", "ROOT_ID", "visitor", "path", "includes", "isNode", "yieldOrContinue", "nodeOrThrow", "shouldContinue", "Object", "values", "Promise", "all", "nodeArg", "_node", "_constructNode", "reset", "dispose", "destroy", "_subscriptions", "unsubscribe", "clear", "_onExpand", "getDebugName", "connectors", "_connectors", "previous", "cancel", "subscribe", "ids", "n", "removed", "update", "batch", "removeEdges", "target", "addNodes", "addEdges", "sortEdges", "requestAnimationFrame", "immediate", "_onInitialize", "_resolvers", "trigger", "_initialized", "Option", "match", "onSome", "wake", "onNone", "removeNodes", "_onRemoveNode", "delete", "params", "_define_property", "Map", "empty", "keepAlive", "sortBy", "byPosition", "head", "split", "_relation", "result", "Graph", "onExpand", "onInitialize", "onRemoveNode", "rxFromSignal", "cb", "effect", "setSelf", "addFinalizer", "observableFamily", "observable", "subscription", "value", "rxFromObservable"]
|
|
7
7
|
}
|