@dxos/app-graph 0.8.4-main.dedc0f3 → 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 +1 @@
|
|
|
1
|
-
{"inputs":{"src/graph.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/graph.ts":{"bytes":61126,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/node.ts":{"bytes":6276,"imports":[{"path":"src/graph.ts","kind":"import-statement","original":"./graph"}],"format":"esm"},"src/graph-builder.ts":{"bytes":47568,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/graph.ts","kind":"import-statement","original":"./graph"},{"path":"src/node.ts","kind":"import-statement","original":"./node"},{"path":"main-thread-scheduling","kind":"dynamic-import","external":true}],"format":"esm"},"src/index.ts":{"bytes":623,"imports":[{"path":"src/graph.ts","kind":"import-statement","original":"./graph"},{"path":"src/graph-builder.ts","kind":"import-statement","original":"./graph-builder"},{"path":"src/node.ts","kind":"import-statement","original":"./node"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":59724},"dist/lib/browser/index.mjs":{"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"main-thread-scheduling","kind":"dynamic-import","external":true}],"exports":["ACTION_GROUP_TYPE","ACTION_TYPE","Graph","GraphBuilder","ROOT_ID","ROOT_TYPE","actionGroupSymbol","createExtension","flattenExtensions","getGraph","isAction","isActionGroup","isActionLike","isGraphNode","rxFromObservable","rxFromSignal"],"entryPoint":"src/index.ts","inputs":{"src/graph.ts":{"bytesInOutput":13942},"src/index.ts":{"bytesInOutput":0},"src/graph-builder.ts":{"bytesInOutput":10637},"src/node.ts":{"bytesInOutput":541}},"bytes":25502}}}
|
|
@@ -2,7 +2,9 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
|
|
3
3
|
// src/graph.ts
|
|
4
4
|
import { Registry, Rx } from "@effect-rx/rx-react";
|
|
5
|
-
import
|
|
5
|
+
import * as Function from "effect/Function";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Record from "effect/Record";
|
|
6
8
|
import { Event, Trigger } from "@dxos/async";
|
|
7
9
|
import { todo } from "@dxos/debug";
|
|
8
10
|
import { invariant } from "@dxos/invariant";
|
|
@@ -27,7 +29,7 @@ var getGraph = (node) => {
|
|
|
27
29
|
const graph = node[graphSymbol];
|
|
28
30
|
invariant(graph, "Node is not associated with a graph.", {
|
|
29
31
|
F: __dxlog_file,
|
|
30
|
-
L:
|
|
32
|
+
L: 27,
|
|
31
33
|
S: void 0,
|
|
32
34
|
A: [
|
|
33
35
|
"graph",
|
|
@@ -87,7 +89,7 @@ var Graph = class {
|
|
|
87
89
|
initialized
|
|
88
90
|
}, {
|
|
89
91
|
F: __dxlog_file,
|
|
90
|
-
L:
|
|
92
|
+
L: 386,
|
|
91
93
|
S: this,
|
|
92
94
|
C: (f, a) => f(...a)
|
|
93
95
|
});
|
|
@@ -104,7 +106,7 @@ var Graph = class {
|
|
|
104
106
|
expanded
|
|
105
107
|
}, {
|
|
106
108
|
F: __dxlog_file,
|
|
107
|
-
L:
|
|
109
|
+
L: 396,
|
|
108
110
|
S: this,
|
|
109
111
|
C: (f, a) => f(...a)
|
|
110
112
|
});
|
|
@@ -134,7 +136,7 @@ var Graph = class {
|
|
|
134
136
|
propertiesChanged
|
|
135
137
|
}, {
|
|
136
138
|
F: __dxlog_file,
|
|
137
|
-
L:
|
|
139
|
+
L: 418,
|
|
138
140
|
S: this,
|
|
139
141
|
C: (f, a) => f(...a)
|
|
140
142
|
});
|
|
@@ -146,7 +148,7 @@ var Graph = class {
|
|
|
146
148
|
properties
|
|
147
149
|
}, {
|
|
148
150
|
F: __dxlog_file,
|
|
149
|
-
L:
|
|
151
|
+
L: 420,
|
|
150
152
|
S: this,
|
|
151
153
|
C: (f, a) => f(...a)
|
|
152
154
|
});
|
|
@@ -174,7 +176,7 @@ var Graph = class {
|
|
|
174
176
|
properties
|
|
175
177
|
}, {
|
|
176
178
|
F: __dxlog_file,
|
|
177
|
-
L:
|
|
179
|
+
L: 427,
|
|
178
180
|
S: this,
|
|
179
181
|
C: (f, a) => f(...a)
|
|
180
182
|
});
|
|
@@ -245,7 +247,7 @@ var Graph = class {
|
|
|
245
247
|
target: edgeArg.target
|
|
246
248
|
}, {
|
|
247
249
|
F: __dxlog_file,
|
|
248
|
-
L:
|
|
250
|
+
L: 482,
|
|
249
251
|
S: this,
|
|
250
252
|
C: (f, a) => f(...a)
|
|
251
253
|
});
|
|
@@ -265,7 +267,7 @@ var Graph = class {
|
|
|
265
267
|
target: edgeArg.target
|
|
266
268
|
}, {
|
|
267
269
|
F: __dxlog_file,
|
|
268
|
-
L:
|
|
270
|
+
L: 489,
|
|
269
271
|
S: this,
|
|
270
272
|
C: (f, a) => f(...a)
|
|
271
273
|
});
|
|
@@ -348,7 +350,7 @@ var Graph = class {
|
|
|
348
350
|
]));
|
|
349
351
|
}
|
|
350
352
|
getPath({ source = "root", target }) {
|
|
351
|
-
return pipe(this.getNode(source), Option.flatMap((node) => {
|
|
353
|
+
return Function.pipe(this.getNode(source), Option.flatMap((node) => {
|
|
352
354
|
let found = Option.none();
|
|
353
355
|
this.traverse({
|
|
354
356
|
source: node.id,
|
|
@@ -414,11 +416,11 @@ var Graph = class {
|
|
|
414
416
|
return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:node:${id}`));
|
|
415
417
|
}));
|
|
416
418
|
_define_property(this, "_nodeOrThrow", Rx.family((id) => {
|
|
417
|
-
return Rx.make((
|
|
418
|
-
const node =
|
|
419
|
+
return Rx.make((get2) => {
|
|
420
|
+
const node = get2(this._node(id));
|
|
419
421
|
invariant(Option.isSome(node), `Node not available: ${id}`, {
|
|
420
422
|
F: __dxlog_file,
|
|
421
|
-
L:
|
|
423
|
+
L: 254,
|
|
422
424
|
S: this,
|
|
423
425
|
A: [
|
|
424
426
|
"Option.isSome(node)",
|
|
@@ -436,23 +438,23 @@ var Graph = class {
|
|
|
436
438
|
return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:edges:${id}`));
|
|
437
439
|
}));
|
|
438
440
|
_define_property(this, "_connections", Rx.family((key) => {
|
|
439
|
-
return Rx.make((
|
|
441
|
+
return Rx.make((get2) => {
|
|
440
442
|
const [id, relation] = key.split("$");
|
|
441
|
-
const edges2 =
|
|
442
|
-
return edges2[relation].map((id2) =>
|
|
443
|
+
const edges2 = get2(this._edges(id));
|
|
444
|
+
return edges2[relation].map((id2) => get2(this._node(id2))).filter(Option.isSome).map((o) => o.value);
|
|
443
445
|
}).pipe(Rx.withLabel(`graph:connections:${key}`));
|
|
444
446
|
}));
|
|
445
447
|
_define_property(this, "_actions", Rx.family((id) => {
|
|
446
|
-
return Rx.make((
|
|
447
|
-
return
|
|
448
|
+
return Rx.make((get2) => {
|
|
449
|
+
return get2(this._connections(`${id}$outbound`)).filter((node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE);
|
|
448
450
|
}).pipe(Rx.withLabel(`graph:actions:${id}`));
|
|
449
451
|
}));
|
|
450
452
|
_define_property(this, "_json", Rx.family((id) => {
|
|
451
|
-
return Rx.make((
|
|
453
|
+
return Rx.make((get2) => {
|
|
452
454
|
const toJSON = (node, seen = []) => {
|
|
453
|
-
const nodes2 =
|
|
455
|
+
const nodes2 = get2(this.connections(node.id));
|
|
454
456
|
const obj = {
|
|
455
|
-
id: node.id
|
|
457
|
+
id: node.id,
|
|
456
458
|
type: node.type
|
|
457
459
|
};
|
|
458
460
|
if (node.properties.label) {
|
|
@@ -469,7 +471,7 @@ var Graph = class {
|
|
|
469
471
|
}
|
|
470
472
|
return obj;
|
|
471
473
|
};
|
|
472
|
-
const root =
|
|
474
|
+
const root = get2(this.nodeOrThrow(id));
|
|
473
475
|
return toJSON(root);
|
|
474
476
|
}).pipe(Rx.withLabel(`graph:json:${id}`));
|
|
475
477
|
}));
|
|
@@ -493,7 +495,10 @@ var Graph = class {
|
|
|
493
495
|
// src/graph-builder.ts
|
|
494
496
|
import { Registry as Registry2, Rx as Rx2 } from "@effect-rx/rx-react";
|
|
495
497
|
import { effect } from "@preact/signals-core";
|
|
496
|
-
import
|
|
498
|
+
import * as Array from "effect/Array";
|
|
499
|
+
import * as Function2 from "effect/Function";
|
|
500
|
+
import * as Option2 from "effect/Option";
|
|
501
|
+
import * as Record2 from "effect/Record";
|
|
497
502
|
import { log as log2 } from "@dxos/log";
|
|
498
503
|
import { byPosition, getDebugName, isNode, isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
499
504
|
|
|
@@ -536,16 +541,16 @@ var createExtension = (extension) => {
|
|
|
536
541
|
id: getId("connector"),
|
|
537
542
|
position,
|
|
538
543
|
relation,
|
|
539
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
544
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
540
545
|
try {
|
|
541
|
-
return
|
|
546
|
+
return get2(connector(node));
|
|
542
547
|
} catch {
|
|
543
548
|
log2.warn("Error in connector", {
|
|
544
549
|
id: getId("connector"),
|
|
545
550
|
node
|
|
546
551
|
}, {
|
|
547
552
|
F: __dxlog_file2,
|
|
548
|
-
L:
|
|
553
|
+
L: 112,
|
|
549
554
|
S: void 0,
|
|
550
555
|
C: (f, a) => f(...a)
|
|
551
556
|
});
|
|
@@ -557,9 +562,9 @@ var createExtension = (extension) => {
|
|
|
557
562
|
id: getId("actionGroups"),
|
|
558
563
|
position,
|
|
559
564
|
relation: "outbound",
|
|
560
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
565
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
561
566
|
try {
|
|
562
|
-
return
|
|
567
|
+
return get2(actionGroups(node)).map((arg) => ({
|
|
563
568
|
...arg,
|
|
564
569
|
data: actionGroupSymbol,
|
|
565
570
|
type: ACTION_GROUP_TYPE
|
|
@@ -570,7 +575,7 @@ var createExtension = (extension) => {
|
|
|
570
575
|
node
|
|
571
576
|
}, {
|
|
572
577
|
F: __dxlog_file2,
|
|
573
|
-
L:
|
|
578
|
+
L: 133,
|
|
574
579
|
S: void 0,
|
|
575
580
|
C: (f, a) => f(...a)
|
|
576
581
|
});
|
|
@@ -582,9 +587,9 @@ var createExtension = (extension) => {
|
|
|
582
587
|
id: getId("actions"),
|
|
583
588
|
position,
|
|
584
589
|
relation: "outbound",
|
|
585
|
-
connector: Rx2.family((node) => Rx2.make((
|
|
590
|
+
connector: Rx2.family((node) => Rx2.make((get2) => {
|
|
586
591
|
try {
|
|
587
|
-
return
|
|
592
|
+
return get2(actions(node)).map((arg) => ({
|
|
588
593
|
...arg,
|
|
589
594
|
type: ACTION_TYPE
|
|
590
595
|
}));
|
|
@@ -594,7 +599,7 @@ var createExtension = (extension) => {
|
|
|
594
599
|
node
|
|
595
600
|
}, {
|
|
596
601
|
F: __dxlog_file2,
|
|
597
|
-
L:
|
|
602
|
+
L: 150,
|
|
598
603
|
S: void 0,
|
|
599
604
|
C: (f, a) => f(...a)
|
|
600
605
|
});
|
|
@@ -694,7 +699,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
694
699
|
registry: getDebugName(this._registry)
|
|
695
700
|
}, {
|
|
696
701
|
F: __dxlog_file2,
|
|
697
|
-
L:
|
|
702
|
+
L: 327,
|
|
698
703
|
S: this,
|
|
699
704
|
C: (f, a) => f(...a)
|
|
700
705
|
});
|
|
@@ -711,7 +716,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
711
716
|
removed
|
|
712
717
|
}, {
|
|
713
718
|
F: __dxlog_file2,
|
|
714
|
-
L:
|
|
719
|
+
L: 338,
|
|
715
720
|
S: this,
|
|
716
721
|
C: (f, a) => f(...a)
|
|
717
722
|
});
|
|
@@ -748,7 +753,7 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
748
753
|
id
|
|
749
754
|
}, {
|
|
750
755
|
F: __dxlog_file2,
|
|
751
|
-
L:
|
|
756
|
+
L: 375,
|
|
752
757
|
S: this,
|
|
753
758
|
C: (f, a) => f(...a)
|
|
754
759
|
});
|
|
@@ -785,23 +790,23 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
785
790
|
_define_property2(this, "_registry", void 0);
|
|
786
791
|
_define_property2(this, "_graph", void 0);
|
|
787
792
|
_define_property2(this, "_resolvers", Rx2.family((id) => {
|
|
788
|
-
return Rx2.make((
|
|
789
|
-
return
|
|
793
|
+
return Rx2.make((get2) => {
|
|
794
|
+
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);
|
|
790
795
|
});
|
|
791
796
|
}));
|
|
792
797
|
_define_property2(this, "_connectors", Rx2.family((key) => {
|
|
793
|
-
return Rx2.make((
|
|
798
|
+
return Rx2.make((get2) => {
|
|
794
799
|
const [id, relation] = key.split("+");
|
|
795
800
|
const node = this._graph.node(id);
|
|
796
|
-
return
|
|
797
|
-
|
|
801
|
+
return Function2.pipe(
|
|
802
|
+
get2(this._extensions),
|
|
798
803
|
Record2.values,
|
|
799
804
|
// TODO(wittjosiah): Sort on write rather than read.
|
|
800
805
|
Array.sortBy(byPosition),
|
|
801
806
|
Array.filter(({ relation: _relation = "outbound" }) => _relation === relation),
|
|
802
807
|
Array.map(({ connector }) => connector?.(node)),
|
|
803
808
|
Array.filter(isNonNullable2),
|
|
804
|
-
Array.flatMap((result) =>
|
|
809
|
+
Array.flatMap((result) => get2(result))
|
|
805
810
|
);
|
|
806
811
|
}).pipe(Rx2.withLabel(`graph-builder:connectors:${key}`));
|
|
807
812
|
}));
|
|
@@ -816,18 +821,18 @@ var GraphBuilder = class _GraphBuilder {
|
|
|
816
821
|
}
|
|
817
822
|
};
|
|
818
823
|
var rxFromSignal = (cb) => {
|
|
819
|
-
return Rx2.make((
|
|
824
|
+
return Rx2.make((get2) => {
|
|
820
825
|
const dispose = effect(() => {
|
|
821
|
-
|
|
826
|
+
get2.setSelf(cb());
|
|
822
827
|
});
|
|
823
|
-
|
|
828
|
+
get2.addFinalizer(() => dispose());
|
|
824
829
|
return cb();
|
|
825
830
|
});
|
|
826
831
|
};
|
|
827
832
|
var observableFamily = Rx2.family((observable) => {
|
|
828
|
-
return Rx2.make((
|
|
829
|
-
const subscription = observable.subscribe((value) =>
|
|
830
|
-
|
|
833
|
+
return Rx2.make((get2) => {
|
|
834
|
+
const subscription = observable.subscribe((value) => get2.setSelf(value));
|
|
835
|
+
get2.addFinalizer(() => subscription.unsubscribe());
|
|
831
836
|
return observable.get();
|
|
832
837
|
});
|
|
833
838
|
});
|