@dxos/app-graph 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // src/graph.ts
4
- import { Registry, Rx } from "@effect-rx/rx-react";
4
+ import { Atom, Registry } from "@effect-atom/atom-react";
5
5
  import * as Function from "effect/Function";
6
6
  import * as Option from "effect/Option";
7
7
  import * as Record from "effect/Record";
@@ -10,26 +10,13 @@ import { todo } from "@dxos/debug";
10
10
  import { invariant } from "@dxos/invariant";
11
11
  import { log } from "@dxos/log";
12
12
  import { isNonNullable } from "@dxos/util";
13
- function _define_property(obj, key, value) {
14
- if (key in obj) {
15
- Object.defineProperty(obj, key, {
16
- value,
17
- enumerable: true,
18
- configurable: true,
19
- writable: true
20
- });
21
- } else {
22
- obj[key] = value;
23
- }
24
- return obj;
25
- }
26
13
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph.ts";
27
14
  var graphSymbol = Symbol("graph");
28
15
  var getGraph = (node) => {
29
16
  const graph = node[graphSymbol];
30
17
  invariant(graph, "Node is not associated with a graph.", {
31
18
  F: __dxlog_file,
32
- L: 27,
19
+ L: 29,
33
20
  S: void 0,
34
21
  A: [
35
22
  "graph",
@@ -43,6 +30,108 @@ var ROOT_TYPE = "dxos.org/type/GraphRoot";
43
30
  var ACTION_TYPE = "dxos.org/type/GraphAction";
44
31
  var ACTION_GROUP_TYPE = "dxos.org/type/GraphActionGroup";
45
32
  var Graph = class {
33
+ onNodeChanged = new Event();
34
+ _onExpand;
35
+ _onInitialize;
36
+ _onRemoveNode;
37
+ _registry;
38
+ _expanded = Record.empty();
39
+ _initialized = Record.empty();
40
+ _initialEdges = Record.empty();
41
+ _initialNodes = Record.fromEntries([
42
+ [
43
+ ROOT_ID,
44
+ this._constructNode({
45
+ id: ROOT_ID,
46
+ type: ROOT_TYPE,
47
+ data: null,
48
+ properties: {}
49
+ })
50
+ ]
51
+ ]);
52
+ /** @internal */
53
+ _node = Atom.family((id) => {
54
+ const initial = Option.flatten(Record.get(this._initialNodes, id));
55
+ return Atom.make(initial).pipe(Atom.keepAlive, Atom.withLabel(`graph:node:${id}`));
56
+ });
57
+ _nodeOrThrow = Atom.family((id) => {
58
+ return Atom.make((get2) => {
59
+ const node = get2(this._node(id));
60
+ invariant(Option.isSome(node), `Node not available: ${id}`, {
61
+ F: __dxlog_file,
62
+ L: 267,
63
+ S: this,
64
+ A: [
65
+ "Option.isSome(node)",
66
+ "`Node not available: ${id}`"
67
+ ]
68
+ });
69
+ return node.value;
70
+ });
71
+ });
72
+ _edges = Atom.family((id) => {
73
+ const initial = Record.get(this._initialEdges, id).pipe(Option.getOrElse(() => ({
74
+ inbound: [],
75
+ outbound: []
76
+ })));
77
+ return Atom.make(initial).pipe(Atom.keepAlive, Atom.withLabel(`graph:edges:${id}`));
78
+ });
79
+ // NOTE: Currently the argument to the family needs to be referentially stable for the atom to be referentially stable.
80
+ // TODO(wittjosiah): Atom feature request, support for something akin to `ComplexMap` to allow for complex arguments.
81
+ _connections = Atom.family((key) => {
82
+ return Atom.make((get2) => {
83
+ const [id, relation] = key.split("$");
84
+ const edges = get2(this._edges(id));
85
+ return edges[relation].map((id2) => get2(this._node(id2))).filter(Option.isSome).map((o) => o.value);
86
+ }).pipe(Atom.withLabel(`graph:connections:${key}`));
87
+ });
88
+ _actions = Atom.family((id) => {
89
+ return Atom.make((get2) => {
90
+ return get2(this._connections(`${id}$outbound`)).filter((node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE);
91
+ }).pipe(Atom.withLabel(`graph:actions:${id}`));
92
+ });
93
+ _json = Atom.family((id) => {
94
+ return Atom.make((get2) => {
95
+ const toJSON = (node, seen = []) => {
96
+ const nodes = get2(this.connections(node.id));
97
+ const obj = {
98
+ id: node.id,
99
+ type: node.type
100
+ };
101
+ if (node.properties.label) {
102
+ obj.label = node.properties.label;
103
+ }
104
+ if (nodes.length) {
105
+ obj.nodes = nodes.map((n) => {
106
+ const nextSeen = [
107
+ ...seen,
108
+ node.id
109
+ ];
110
+ return nextSeen.includes(n.id) ? void 0 : toJSON(n, nextSeen);
111
+ }).filter(isNonNullable);
112
+ }
113
+ return obj;
114
+ };
115
+ const root = get2(this.nodeOrThrow(id));
116
+ return toJSON(root);
117
+ }).pipe(Atom.withLabel(`graph:json:${id}`));
118
+ });
119
+ constructor({ registry, nodes, edges, onInitialize, onExpand, onRemoveNode } = {}) {
120
+ this._registry = registry ?? Registry.make();
121
+ this._onInitialize = onInitialize;
122
+ this._onExpand = onExpand;
123
+ this._onRemoveNode = onRemoveNode;
124
+ if (nodes) {
125
+ nodes.forEach((node) => {
126
+ Record.set(this._initialNodes, node.id, this._constructNode(node));
127
+ });
128
+ }
129
+ if (edges) {
130
+ Object.entries(edges).forEach(([source, edges2]) => {
131
+ Record.set(this._initialEdges, source, edges2);
132
+ });
133
+ }
134
+ }
46
135
  toJSON(id = ROOT_ID) {
47
136
  return this._registry.get(this._json(id));
48
137
  }
@@ -89,7 +178,7 @@ var Graph = class {
89
178
  initialized
90
179
  }, {
91
180
  F: __dxlog_file,
92
- L: 386,
181
+ L: 399,
93
182
  S: this,
94
183
  C: (f, a) => f(...a)
95
184
  });
@@ -106,7 +195,7 @@ var Graph = class {
106
195
  expanded
107
196
  }, {
108
197
  F: __dxlog_file,
109
- L: 396,
198
+ L: 409,
110
199
  S: this,
111
200
  C: (f, a) => f(...a)
112
201
  });
@@ -116,14 +205,14 @@ var Graph = class {
116
205
  }
117
206
  }
118
207
  addNodes(nodes) {
119
- Rx.batch(() => {
208
+ Atom.batch(() => {
120
209
  nodes.map((node) => this.addNode(node));
121
210
  });
122
211
  }
123
212
  addNode({ nodes, edges, ...nodeArg }) {
124
213
  const { id, type, data = null, properties = {} } = nodeArg;
125
- const nodeRx = this._node(id);
126
- const node = this._registry.get(nodeRx);
214
+ const nodeAtom = this._node(id);
215
+ const node = this._registry.get(nodeAtom);
127
216
  Option.match(node, {
128
217
  onSome: (node2) => {
129
218
  const typeChanged = node2.type !== type;
@@ -136,7 +225,7 @@ var Graph = class {
136
225
  propertiesChanged
137
226
  }, {
138
227
  F: __dxlog_file,
139
- L: 418,
228
+ L: 431,
140
229
  S: this,
141
230
  C: (f, a) => f(...a)
142
231
  });
@@ -148,7 +237,7 @@ var Graph = class {
148
237
  properties
149
238
  }, {
150
239
  F: __dxlog_file,
151
- L: 420,
240
+ L: 438,
152
241
  S: this,
153
242
  C: (f, a) => f(...a)
154
243
  });
@@ -161,7 +250,7 @@ var Graph = class {
161
250
  ...properties
162
251
  }
163
252
  });
164
- this._registry.set(nodeRx, newNode);
253
+ this._registry.set(nodeAtom, newNode);
165
254
  this.onNodeChanged.emit({
166
255
  id,
167
256
  node: newNode
@@ -176,7 +265,7 @@ var Graph = class {
176
265
  properties
177
266
  }, {
178
267
  F: __dxlog_file,
179
- L: 427,
268
+ L: 450,
180
269
  S: this,
181
270
  C: (f, a) => f(...a)
182
271
  });
@@ -186,7 +275,7 @@ var Graph = class {
186
275
  data,
187
276
  properties
188
277
  });
189
- this._registry.set(nodeRx, newNode);
278
+ this._registry.set(nodeAtom, newNode);
190
279
  this.onNodeChanged.emit({
191
280
  id,
192
281
  node: newNode
@@ -206,13 +295,13 @@ var Graph = class {
206
295
  }
207
296
  }
208
297
  removeNodes(ids, edges = false) {
209
- Rx.batch(() => {
298
+ Atom.batch(() => {
210
299
  ids.map((id) => this.removeNode(id, edges));
211
300
  });
212
301
  }
213
302
  removeNode(id, edges = false) {
214
- const nodeRx = this._node(id);
215
- this._registry.set(nodeRx, Option.none());
303
+ const nodeAtom = this._node(id);
304
+ this._registry.set(nodeAtom, Option.none());
216
305
  this.onNodeChanged.emit({
217
306
  id,
218
307
  node: Option.none()
@@ -234,24 +323,24 @@ var Graph = class {
234
323
  this._onRemoveNode?.(id);
235
324
  }
236
325
  addEdges(edges) {
237
- Rx.batch(() => {
326
+ Atom.batch(() => {
238
327
  edges.map((edge) => this.addEdge(edge));
239
328
  });
240
329
  }
241
330
  addEdge(edgeArg) {
242
- const sourceRx = this._edges(edgeArg.source);
243
- const source = this._registry.get(sourceRx);
331
+ const sourceAtom = this._edges(edgeArg.source);
332
+ const source = this._registry.get(sourceAtom);
244
333
  if (!source.outbound.includes(edgeArg.target)) {
245
334
  log("add outbound edge", {
246
335
  source: edgeArg.source,
247
336
  target: edgeArg.target
248
337
  }, {
249
338
  F: __dxlog_file,
250
- L: 482,
339
+ L: 505,
251
340
  S: this,
252
341
  C: (f, a) => f(...a)
253
342
  });
254
- this._registry.set(sourceRx, {
343
+ this._registry.set(sourceAtom, {
255
344
  inbound: source.inbound,
256
345
  outbound: [
257
346
  ...source.outbound,
@@ -259,19 +348,19 @@ var Graph = class {
259
348
  ]
260
349
  });
261
350
  }
262
- const targetRx = this._edges(edgeArg.target);
263
- const target = this._registry.get(targetRx);
351
+ const targetAtom = this._edges(edgeArg.target);
352
+ const target = this._registry.get(targetAtom);
264
353
  if (!target.inbound.includes(edgeArg.source)) {
265
354
  log("add inbound edge", {
266
355
  source: edgeArg.source,
267
356
  target: edgeArg.target
268
357
  }, {
269
358
  F: __dxlog_file,
270
- L: 489,
359
+ L: 518,
271
360
  S: this,
272
361
  C: (f, a) => f(...a)
273
362
  });
274
- this._registry.set(targetRx, {
363
+ this._registry.set(targetAtom, {
275
364
  inbound: [
276
365
  ...target.inbound,
277
366
  edgeArg.source
@@ -281,30 +370,30 @@ var Graph = class {
281
370
  }
282
371
  }
283
372
  removeEdges(edges, removeOrphans = false) {
284
- Rx.batch(() => {
373
+ Atom.batch(() => {
285
374
  edges.map((edge) => this.removeEdge(edge, removeOrphans));
286
375
  });
287
376
  }
288
377
  removeEdge(edgeArg, removeOrphans = false) {
289
- const sourceRx = this._edges(edgeArg.source);
290
- const source = this._registry.get(sourceRx);
378
+ const sourceAtom = this._edges(edgeArg.source);
379
+ const source = this._registry.get(sourceAtom);
291
380
  if (source.outbound.includes(edgeArg.target)) {
292
- this._registry.set(sourceRx, {
381
+ this._registry.set(sourceAtom, {
293
382
  inbound: source.inbound,
294
383
  outbound: source.outbound.filter((id) => id !== edgeArg.target)
295
384
  });
296
385
  }
297
- const targetRx = this._edges(edgeArg.target);
298
- const target = this._registry.get(targetRx);
386
+ const targetAtom = this._edges(edgeArg.target);
387
+ const target = this._registry.get(targetAtom);
299
388
  if (target.inbound.includes(edgeArg.source)) {
300
- this._registry.set(targetRx, {
389
+ this._registry.set(targetAtom, {
301
390
  inbound: target.inbound.filter((id) => id !== edgeArg.source),
302
391
  outbound: target.outbound
303
392
  });
304
393
  }
305
394
  if (removeOrphans) {
306
- const source2 = this._registry.get(sourceRx);
307
- const target2 = this._registry.get(targetRx);
395
+ const source2 = this._registry.get(sourceAtom);
396
+ const target2 = this._registry.get(targetAtom);
308
397
  if (source2.outbound.length === 0 && source2.inbound.length === 0 && edgeArg.source !== ROOT_ID) {
309
398
  this.removeNodes([
310
399
  edgeArg.source
@@ -318,15 +407,15 @@ var Graph = class {
318
407
  }
319
408
  }
320
409
  sortEdges(id, relation, order) {
321
- const edgesRx = this._edges(id);
322
- const edges = this._registry.get(edgesRx);
410
+ const edgesAtom = this._edges(id);
411
+ const edges = this._registry.get(edgesAtom);
323
412
  const unsorted = edges[relation].filter((id2) => !order.includes(id2)) ?? [];
324
413
  const sorted = order.filter((id2) => edges[relation].includes(id2)) ?? [];
325
414
  edges[relation].splice(0, edges[relation].length, ...[
326
415
  ...sorted,
327
416
  ...unsorted
328
417
  ]);
329
- this._registry.set(edgesRx, edges);
418
+ this._registry.set(edgesAtom, edges);
330
419
  }
331
420
  traverse({ visitor, source = ROOT_ID, relation = "outbound" }, path = []) {
332
421
  if (path.includes(source)) {
@@ -391,109 +480,10 @@ var Graph = class {
391
480
  ...node
392
481
  });
393
482
  }
394
- constructor({ registry, nodes, edges, onInitialize, onExpand, onRemoveNode } = {}) {
395
- _define_property(this, "onNodeChanged", new Event());
396
- _define_property(this, "_onExpand", void 0);
397
- _define_property(this, "_onInitialize", void 0);
398
- _define_property(this, "_onRemoveNode", void 0);
399
- _define_property(this, "_registry", void 0);
400
- _define_property(this, "_expanded", Record.empty());
401
- _define_property(this, "_initialized", Record.empty());
402
- _define_property(this, "_initialEdges", Record.empty());
403
- _define_property(this, "_initialNodes", Record.fromEntries([
404
- [
405
- ROOT_ID,
406
- this._constructNode({
407
- id: ROOT_ID,
408
- type: ROOT_TYPE,
409
- data: null,
410
- properties: {}
411
- })
412
- ]
413
- ]));
414
- _define_property(this, "_node", Rx.family((id) => {
415
- const initial = Option.flatten(Record.get(this._initialNodes, id));
416
- return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:node:${id}`));
417
- }));
418
- _define_property(this, "_nodeOrThrow", Rx.family((id) => {
419
- return Rx.make((get2) => {
420
- const node = get2(this._node(id));
421
- invariant(Option.isSome(node), `Node not available: ${id}`, {
422
- F: __dxlog_file,
423
- L: 254,
424
- S: this,
425
- A: [
426
- "Option.isSome(node)",
427
- "`Node not available: ${id}`"
428
- ]
429
- });
430
- return node.value;
431
- });
432
- }));
433
- _define_property(this, "_edges", Rx.family((id) => {
434
- const initial = Record.get(this._initialEdges, id).pipe(Option.getOrElse(() => ({
435
- inbound: [],
436
- outbound: []
437
- })));
438
- return Rx.make(initial).pipe(Rx.keepAlive, Rx.withLabel(`graph:edges:${id}`));
439
- }));
440
- _define_property(this, "_connections", Rx.family((key) => {
441
- return Rx.make((get2) => {
442
- const [id, relation] = key.split("$");
443
- const edges2 = get2(this._edges(id));
444
- return edges2[relation].map((id2) => get2(this._node(id2))).filter(Option.isSome).map((o) => o.value);
445
- }).pipe(Rx.withLabel(`graph:connections:${key}`));
446
- }));
447
- _define_property(this, "_actions", Rx.family((id) => {
448
- return Rx.make((get2) => {
449
- return get2(this._connections(`${id}$outbound`)).filter((node) => node.type === ACTION_TYPE || node.type === ACTION_GROUP_TYPE);
450
- }).pipe(Rx.withLabel(`graph:actions:${id}`));
451
- }));
452
- _define_property(this, "_json", Rx.family((id) => {
453
- return Rx.make((get2) => {
454
- const toJSON = (node, seen = []) => {
455
- const nodes2 = get2(this.connections(node.id));
456
- const obj = {
457
- id: node.id.length > 32 ? `${node.id.slice(0, 32)}...` : node.id,
458
- type: node.type
459
- };
460
- if (node.properties.label) {
461
- obj.label = node.properties.label;
462
- }
463
- if (nodes2.length) {
464
- obj.nodes = nodes2.map((n) => {
465
- const nextSeen = [
466
- ...seen,
467
- node.id
468
- ];
469
- return nextSeen.includes(n.id) ? void 0 : toJSON(n, nextSeen);
470
- }).filter(isNonNullable);
471
- }
472
- return obj;
473
- };
474
- const root = get2(this.nodeOrThrow(id));
475
- return toJSON(root);
476
- }).pipe(Rx.withLabel(`graph:json:${id}`));
477
- }));
478
- this._registry = registry ?? Registry.make();
479
- this._onInitialize = onInitialize;
480
- this._onExpand = onExpand;
481
- this._onRemoveNode = onRemoveNode;
482
- if (nodes) {
483
- nodes.forEach((node) => {
484
- Record.set(this._initialNodes, node.id, this._constructNode(node));
485
- });
486
- }
487
- if (edges) {
488
- Object.entries(edges).forEach(([source, edges2]) => {
489
- Record.set(this._initialEdges, source, edges2);
490
- });
491
- }
492
- }
493
483
  };
494
484
 
495
485
  // src/graph-builder.ts
496
- import { Registry as Registry2, Rx as Rx2 } from "@effect-rx/rx-react";
486
+ import { Atom as Atom2, Registry as Registry2 } from "@effect-atom/atom-react";
497
487
  import { effect } from "@preact/signals-core";
498
488
  import * as Array from "effect/Array";
499
489
  import * as Function2 from "effect/Function";
@@ -510,27 +500,14 @@ var isActionGroup = (data) => isGraphNode(data) ? data.data === actionGroupSymbo
510
500
  var isActionLike = (data) => isAction(data) || isActionGroup(data);
511
501
 
512
502
  // src/graph-builder.ts
513
- function _define_property2(obj, key, value) {
514
- if (key in obj) {
515
- Object.defineProperty(obj, key, {
516
- value,
517
- enumerable: true,
518
- configurable: true,
519
- writable: true
520
- });
521
- } else {
522
- obj[key] = value;
523
- }
524
- return obj;
525
- }
526
503
  var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph-builder.ts";
527
504
  var createExtension = (extension) => {
528
505
  const { id, position = "static", relation = "outbound", resolver: _resolver, connector: _connector, actions: _actions, actionGroups: _actionGroups } = extension;
529
506
  const getId = (key) => `${id}/${key}`;
530
- const resolver = _resolver && Rx2.family((id2) => _resolver(id2).pipe(Rx2.withLabel(`graph-builder:_resolver:${id2}`)));
531
- const connector = _connector && Rx2.family((node) => _connector(node).pipe(Rx2.withLabel(`graph-builder:_connector:${id}`)));
532
- const actionGroups = _actionGroups && Rx2.family((node) => _actionGroups(node).pipe(Rx2.withLabel(`graph-builder:_actionGroups:${id}`)));
533
- const actions = _actions && Rx2.family((node) => _actions(node).pipe(Rx2.withLabel(`graph-builder:_actions:${id}`)));
507
+ const resolver = _resolver && Atom2.family((id2) => _resolver(id2).pipe(Atom2.withLabel(`graph-builder:_resolver:${id2}`)));
508
+ const connector = _connector && Atom2.family((node) => _connector(node).pipe(Atom2.withLabel(`graph-builder:_connector:${id}`)));
509
+ const actionGroups = _actionGroups && Atom2.family((node) => _actionGroups(node).pipe(Atom2.withLabel(`graph-builder:_actionGroups:${id}`)));
510
+ const actions = _actions && Atom2.family((node) => _actions(node).pipe(Atom2.withLabel(`graph-builder:_actions:${id}`)));
534
511
  return [
535
512
  resolver ? {
536
513
  id: getId("resolver"),
@@ -541,7 +518,7 @@ var createExtension = (extension) => {
541
518
  id: getId("connector"),
542
519
  position,
543
520
  relation,
544
- connector: Rx2.family((node) => Rx2.make((get2) => {
521
+ connector: Atom2.family((node) => Atom2.make((get2) => {
545
522
  try {
546
523
  return get2(connector(node));
547
524
  } catch {
@@ -550,19 +527,19 @@ var createExtension = (extension) => {
550
527
  node
551
528
  }, {
552
529
  F: __dxlog_file2,
553
- L: 112,
530
+ L: 114,
554
531
  S: void 0,
555
532
  C: (f, a) => f(...a)
556
533
  });
557
534
  return [];
558
535
  }
559
- }).pipe(Rx2.withLabel(`graph-builder:connector:${id}`)))
536
+ }).pipe(Atom2.withLabel(`graph-builder:connector:${id}`)))
560
537
  } : void 0,
561
538
  actionGroups ? {
562
539
  id: getId("actionGroups"),
563
540
  position,
564
541
  relation: "outbound",
565
- connector: Rx2.family((node) => Rx2.make((get2) => {
542
+ connector: Atom2.family((node) => Atom2.make((get2) => {
566
543
  try {
567
544
  return get2(actionGroups(node)).map((arg) => ({
568
545
  ...arg,
@@ -575,19 +552,19 @@ var createExtension = (extension) => {
575
552
  node
576
553
  }, {
577
554
  F: __dxlog_file2,
578
- L: 133,
555
+ L: 135,
579
556
  S: void 0,
580
557
  C: (f, a) => f(...a)
581
558
  });
582
559
  return [];
583
560
  }
584
- }).pipe(Rx2.withLabel(`graph-builder:connector:actionGroups:${id}`)))
561
+ }).pipe(Atom2.withLabel(`graph-builder:connector:actionGroups:${id}`)))
585
562
  } : void 0,
586
563
  actions ? {
587
564
  id: getId("actions"),
588
565
  position,
589
566
  relation: "outbound",
590
- connector: Rx2.family((node) => Rx2.make((get2) => {
567
+ connector: Atom2.family((node) => Atom2.make((get2) => {
591
568
  try {
592
569
  return get2(actions(node)).map((arg) => ({
593
570
  ...arg,
@@ -599,13 +576,13 @@ var createExtension = (extension) => {
599
576
  node
600
577
  }, {
601
578
  F: __dxlog_file2,
602
- L: 150,
579
+ L: 152,
603
580
  S: void 0,
604
581
  C: (f, a) => f(...a)
605
582
  });
606
583
  return [];
607
584
  }
608
- }).pipe(Rx2.withLabel(`graph-builder:connector:actions:${id}`)))
585
+ }).pipe(Atom2.withLabel(`graph-builder:connector:actions:${id}`)))
609
586
  } : void 0
610
587
  ].filter(isNonNullable2);
611
588
  };
@@ -623,6 +600,22 @@ var flattenExtensions = (extension, acc = []) => {
623
600
  }
624
601
  };
625
602
  var GraphBuilder = class _GraphBuilder {
603
+ // TODO(wittjosiah): Use Context.
604
+ _subscriptions = /* @__PURE__ */ new Map();
605
+ _extensions = Atom2.make(Record2.empty()).pipe(Atom2.keepAlive, Atom2.withLabel("graph-builder:extensions"));
606
+ _initialized = {};
607
+ _registry;
608
+ _graph;
609
+ constructor({ registry, ...params } = {}) {
610
+ this._registry = registry ?? Registry2.make();
611
+ this._graph = new Graph({
612
+ ...params,
613
+ registry: this._registry,
614
+ onExpand: (id, relation) => this._onExpand(id, relation),
615
+ onInitialize: (id) => this._onInitialize(id),
616
+ onRemoveNode: (id) => this._onRemoveNode(id)
617
+ });
618
+ }
626
619
  static from(pickle, registry) {
627
620
  if (!pickle) {
628
621
  return new _GraphBuilder({
@@ -692,6 +685,27 @@ var GraphBuilder = class _GraphBuilder {
692
685
  this._subscriptions.forEach((unsubscribe) => unsubscribe());
693
686
  this._subscriptions.clear();
694
687
  }
688
+ _resolvers = Atom2.family((id) => {
689
+ return Atom2.make((get2) => {
690
+ 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);
691
+ });
692
+ });
693
+ _connectors = Atom2.family((key) => {
694
+ return Atom2.make((get2) => {
695
+ const [id, relation] = key.split("+");
696
+ const node = this._graph.node(id);
697
+ return Function2.pipe(
698
+ get2(this._extensions),
699
+ Record2.values,
700
+ // TODO(wittjosiah): Sort on write rather than read.
701
+ Array.sortBy(byPosition),
702
+ Array.filter(({ relation: _relation = "outbound" }) => _relation === relation),
703
+ Array.map(({ connector }) => connector?.(node)),
704
+ Array.filter(isNonNullable2),
705
+ Array.flatMap((result) => get2(result))
706
+ );
707
+ }).pipe(Atom2.withLabel(`graph-builder:connectors:${key}`));
708
+ });
695
709
  _onExpand(id, relation) {
696
710
  log2("onExpand", {
697
711
  id,
@@ -699,7 +713,7 @@ var GraphBuilder = class _GraphBuilder {
699
713
  registry: getDebugName(this._registry)
700
714
  }, {
701
715
  F: __dxlog_file2,
702
- L: 327,
716
+ L: 329,
703
717
  S: this,
704
718
  C: (f, a) => f(...a)
705
719
  });
@@ -716,12 +730,12 @@ var GraphBuilder = class _GraphBuilder {
716
730
  removed
717
731
  }, {
718
732
  F: __dxlog_file2,
719
- L: 338,
733
+ L: 340,
720
734
  S: this,
721
735
  C: (f, a) => f(...a)
722
736
  });
723
737
  const update = () => {
724
- Rx2.batch(() => {
738
+ Atom2.batch(() => {
725
739
  this._graph.removeEdges(removed.map((target) => ({
726
740
  source: id,
727
741
  target
@@ -753,7 +767,7 @@ var GraphBuilder = class _GraphBuilder {
753
767
  id
754
768
  }, {
755
769
  F: __dxlog_file2,
756
- L: 375,
770
+ L: 377,
757
771
  S: this,
758
772
  C: (f, a) => f(...a)
759
773
  });
@@ -783,45 +797,9 @@ var GraphBuilder = class _GraphBuilder {
783
797
  this._subscriptions.get(id)?.();
784
798
  this._subscriptions.delete(id);
785
799
  }
786
- constructor({ registry, ...params } = {}) {
787
- _define_property2(this, "_subscriptions", /* @__PURE__ */ new Map());
788
- _define_property2(this, "_extensions", Rx2.make(Record2.empty()).pipe(Rx2.keepAlive, Rx2.withLabel("graph-builder:extensions")));
789
- _define_property2(this, "_initialized", {});
790
- _define_property2(this, "_registry", void 0);
791
- _define_property2(this, "_graph", void 0);
792
- _define_property2(this, "_resolvers", Rx2.family((id) => {
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);
795
- });
796
- }));
797
- _define_property2(this, "_connectors", Rx2.family((key) => {
798
- return Rx2.make((get2) => {
799
- const [id, relation] = key.split("+");
800
- const node = this._graph.node(id);
801
- return Function2.pipe(
802
- get2(this._extensions),
803
- Record2.values,
804
- // TODO(wittjosiah): Sort on write rather than read.
805
- Array.sortBy(byPosition),
806
- Array.filter(({ relation: _relation = "outbound" }) => _relation === relation),
807
- Array.map(({ connector }) => connector?.(node)),
808
- Array.filter(isNonNullable2),
809
- Array.flatMap((result) => get2(result))
810
- );
811
- }).pipe(Rx2.withLabel(`graph-builder:connectors:${key}`));
812
- }));
813
- this._registry = registry ?? Registry2.make();
814
- this._graph = new Graph({
815
- ...params,
816
- registry: this._registry,
817
- onExpand: (id, relation) => this._onExpand(id, relation),
818
- onInitialize: (id) => this._onInitialize(id),
819
- onRemoveNode: (id) => this._onRemoveNode(id)
820
- });
821
- }
822
800
  };
823
- var rxFromSignal = (cb) => {
824
- return Rx2.make((get2) => {
801
+ var atomFromSignal = (cb) => {
802
+ return Atom2.make((get2) => {
825
803
  const dispose = effect(() => {
826
804
  get2.setSelf(cb());
827
805
  });
@@ -829,14 +807,14 @@ var rxFromSignal = (cb) => {
829
807
  return cb();
830
808
  });
831
809
  };
832
- var observableFamily = Rx2.family((observable) => {
833
- return Rx2.make((get2) => {
810
+ var observableFamily = Atom2.family((observable) => {
811
+ return Atom2.make((get2) => {
834
812
  const subscription = observable.subscribe((value) => get2.setSelf(value));
835
813
  get2.addFinalizer(() => subscription.unsubscribe());
836
814
  return observable.get();
837
815
  });
838
816
  });
839
- var rxFromObservable = (observable) => {
817
+ var atomFromObservable = (observable) => {
840
818
  return observableFamily(observable);
841
819
  };
842
820
  export {
@@ -847,14 +825,14 @@ export {
847
825
  ROOT_ID,
848
826
  ROOT_TYPE,
849
827
  actionGroupSymbol,
828
+ atomFromObservable,
829
+ atomFromSignal,
850
830
  createExtension,
851
831
  flattenExtensions,
852
832
  getGraph,
853
833
  isAction,
854
834
  isActionGroup,
855
835
  isActionLike,
856
- isGraphNode,
857
- rxFromObservable,
858
- rxFromSignal
836
+ isGraphNode
859
837
  };
860
838
  //# sourceMappingURL=index.mjs.map