@dxos/app-graph 0.8.4-main.c85a9c8dae → 0.8.4-main.d05673bc65

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 +1 @@
1
- {"inputs":{"src/atoms.ts":{"bytes":2433,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true}],"format":"esm"},"src/node.ts":{"bytes":9295,"imports":[],"format":"esm"},"src/util.ts":{"bytes":6181,"imports":[{"path":"src/node.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"src/graph.ts":{"bytes":125283,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","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":"src/node.ts","kind":"import-statement","original":"./node"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/node-matcher.ts":{"bytes":24097,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/node.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"src/graph-builder.ts":{"bytes":81364,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"main-thread-scheduling","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":"src/node-matcher.ts","kind":"import-statement","original":"./node-matcher"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":1468,"imports":[{"path":"src/atoms.ts","kind":"import-statement","original":"./atoms"},{"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"},{"path":"src/node-matcher.ts","kind":"import-statement","original":"./node-matcher"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":131873},"dist/lib/browser/index.mjs":{"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","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-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"main-thread-scheduling","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["CreateAtom","Graph","GraphBuilder","Node","NodeMatcher"],"entryPoint":"src/index.ts","inputs":{"src/atoms.ts":{"bytesInOutput":481},"src/index.ts":{"bytesInOutput":0},"src/graph.ts":{"bytesInOutput":27229},"src/node.ts":{"bytesInOutput":1418},"src/util.ts":{"bytesInOutput":884},"src/graph-builder.ts":{"bytesInOutput":16871},"src/node-matcher.ts":{"bytesInOutput":1682}},"bytes":49096}}}
1
+ {"inputs":{"src/atoms.ts":{"bytes":2433,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true}],"format":"esm"},"src/node.ts":{"bytes":9423,"imports":[],"format":"esm"},"src/util.ts":{"bytes":8277,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/node.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"src/graph.ts":{"bytes":126760,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","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":"src/node.ts","kind":"import-statement","original":"./node"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/node-matcher.ts":{"bytes":24097,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/node.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"src/graph-builder.ts":{"bytes":85800,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"main-thread-scheduling","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":"src/node-matcher.ts","kind":"import-statement","original":"./node-matcher"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":1468,"imports":[{"path":"src/atoms.ts","kind":"import-statement","original":"./atoms"},{"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"},{"path":"src/node-matcher.ts","kind":"import-statement","original":"./node-matcher"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":135666},"dist/lib/browser/index.mjs":{"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","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":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"main-thread-scheduling","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["CreateAtom","Graph","GraphBuilder","Node","NodeMatcher"],"entryPoint":"src/index.ts","inputs":{"src/atoms.ts":{"bytesInOutput":481},"src/index.ts":{"bytesInOutput":0},"src/graph.ts":{"bytesInOutput":27679},"src/node.ts":{"bytesInOutput":1422},"src/util.ts":{"bytesInOutput":1424},"src/graph-builder.ts":{"bytesInOutput":18045},"src/node-matcher.ts":{"bytesInOutput":1682}},"bytes":51264}}}
@@ -60,7 +60,7 @@ import * as Pipeable from "effect/Pipeable";
60
60
  import * as Record from "effect/Record";
61
61
  import { Event, Trigger } from "@dxos/async";
62
62
  import { todo } from "@dxos/debug";
63
- import { invariant } from "@dxos/invariant";
63
+ import { invariant as invariant2 } from "@dxos/invariant";
64
64
  import { log } from "@dxos/log";
65
65
  import { isNonNullable } from "@dxos/util";
66
66
 
@@ -81,9 +81,9 @@ __export(node_exports, {
81
81
  relation: () => relation
82
82
  });
83
83
  var RootId = "root";
84
- var RootType = "dxos.org/type/GraphRoot";
85
- var ActionType = "dxos.org/type/GraphAction";
86
- var ActionGroupType = "dxos.org/type/GraphActionGroup";
84
+ var RootType = "org.dxos.type.graph-root";
85
+ var ActionType = "org.dxos.type.graph-action";
86
+ var ActionGroupType = "org.dxos.type.graph-action-group";
87
87
  var relation = (kind, direction = "outbound") => ({
88
88
  kind,
89
89
  direction
@@ -97,9 +97,12 @@ var isActionGroup = (data) => isGraphNode(data) ? data.data === actionGroupSymbo
97
97
  var isActionLike = (data) => isAction(data) || isActionGroup(data);
98
98
 
99
99
  // src/util.ts
100
+ import { invariant } from "@dxos/invariant";
101
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-graph/src/util.ts";
100
102
  var Separators = {
101
103
  primary: "",
102
- secondary: ""
104
+ secondary: "",
105
+ path: "/"
103
106
  };
104
107
  var normalizeRelation = (relation2) => relation2 == null ? childRelation() : typeof relation2 === "string" ? relation(relation2) : relation2;
105
108
  var shallowEqual = (a, b) => {
@@ -121,14 +124,26 @@ var nodeArgsUnchanged = (prev, next) => {
121
124
  return prevNode.id === nextNode.id && prevNode.type === nextNode.type && shallowEqual(prevNode.data, nextNode.data) && shallowEqual(prevNode.properties, nextNode.properties);
122
125
  });
123
126
  };
127
+ var qualifyId = (parentId, segmentId) => `${parentId}${Separators.path}${segmentId}`;
128
+ var validateSegmentId = (id) => {
129
+ invariant(!id.includes(Separators.path), `Node segment ID must not contain '${Separators.path}': ${id}`, {
130
+ F: __dxlog_file,
131
+ L: 70,
132
+ S: void 0,
133
+ A: [
134
+ "!id.includes(Separators.path)",
135
+ "`Node segment ID must not contain '${Separators.path}': ${id}`"
136
+ ]
137
+ });
138
+ };
124
139
 
125
140
  // src/graph.ts
126
- var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph.ts";
141
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph.ts";
127
142
  var graphSymbol = /* @__PURE__ */ Symbol("graph");
128
143
  var getGraph = (node) => {
129
144
  const graph = node[graphSymbol];
130
- invariant(graph, "Node is not associated with a graph.", {
131
- F: __dxlog_file,
145
+ invariant2(graph, "Node is not associated with a graph.", {
146
+ F: __dxlog_file2,
132
147
  L: 33,
133
148
  S: void 0,
134
149
  A: [
@@ -174,8 +189,8 @@ var GraphImpl = class {
174
189
  _nodeOrThrow = Atom2.family((id) => {
175
190
  return Atom2.make((get2) => {
176
191
  const node = get2(this._node(id));
177
- invariant(Option.isSome(node), `Node not available: ${id}`, {
178
- F: __dxlog_file,
192
+ invariant2(Option.isSome(node), `Node not available: ${id}`, {
193
+ F: __dxlog_file2,
179
194
  L: 172,
180
195
  S: this,
181
196
  A: [
@@ -194,6 +209,9 @@ var GraphImpl = class {
194
209
  // TODO(wittjosiah): Atom feature request, support for something akin to `ComplexMap` to allow for complex arguments.
195
210
  _connections = Atom2.family((key) => {
196
211
  return Atom2.make((get2) => {
212
+ if (!key || key.indexOf(Separators.primary) <= 0) {
213
+ return [];
214
+ }
197
215
  const { id, relation: relation2 } = relationFromConnectionKey(key);
198
216
  const edges = get2(this._edges(id));
199
217
  return (edges[relationKey(relation2)] ?? []).map((id2) => get2(this._node(id2))).filter(Option.isSome).map((o) => o.value);
@@ -201,6 +219,9 @@ var GraphImpl = class {
201
219
  });
202
220
  _actions = Atom2.family((id) => {
203
221
  return Atom2.make((get2) => {
222
+ if (!id) {
223
+ return [];
224
+ }
204
225
  return get2(this._connections(connectionKey(id, actionRelation())));
205
226
  }).pipe(Atom2.withLabel(`graph:actions:${id}`));
206
227
  });
@@ -346,9 +367,9 @@ function getConnections(graphOrId, idOrRelation, relation2) {
346
367
  } else {
347
368
  const graph = graphOrId;
348
369
  const id = idOrRelation;
349
- invariant(relation2 !== void 0, "Relation is required.", {
350
- F: __dxlog_file,
351
- L: 440,
370
+ invariant2(relation2 !== void 0, "Relation is required.", {
371
+ F: __dxlog_file2,
372
+ L: 446,
352
373
  S: this,
353
374
  A: [
354
375
  "relation !== undefined",
@@ -398,14 +419,25 @@ var traverseImpl = (graph, options, path = []) => {
398
419
  if (shouldContinue === false) {
399
420
  return;
400
421
  }
401
- Object.values(getConnections(graph, source, relation2)).forEach((child) => traverseImpl(graph, {
402
- source: child.id,
403
- relation: relation2,
404
- visitor
405
- }, [
406
- ...path,
407
- source
408
- ]));
422
+ const relations = Array.isArray(relation2) ? relation2 : [
423
+ relation2
424
+ ];
425
+ const seen = /* @__PURE__ */ new Set();
426
+ for (const rel of relations) {
427
+ for (const connected of getConnections(graph, source, rel)) {
428
+ if (!seen.has(connected.id)) {
429
+ seen.add(connected.id);
430
+ traverseImpl(graph, {
431
+ source: connected.id,
432
+ relation: relation2,
433
+ visitor
434
+ }, [
435
+ ...path,
436
+ source
437
+ ]);
438
+ }
439
+ }
440
+ }
409
441
  };
410
442
  function traverse(graphOrOptions, optionsOrPath, path) {
411
443
  if (typeof graphOrOptions === "object" && "visitor" in graphOrOptions) {
@@ -481,8 +513,8 @@ var initializeImpl = async (graph, id) => {
481
513
  id,
482
514
  initialized
483
515
  }, {
484
- F: __dxlog_file,
485
- L: 655,
516
+ F: __dxlog_file2,
517
+ L: 668,
486
518
  S: void 0,
487
519
  C: (f, a) => f(...a)
488
520
  });
@@ -512,8 +544,8 @@ var expandImpl = (graph, id, relation2) => {
512
544
  key,
513
545
  deferred: true
514
546
  }, {
515
- F: __dxlog_file,
516
- L: 701,
547
+ F: __dxlog_file2,
548
+ L: 714,
517
549
  S: void 0,
518
550
  C: (f, a) => f(...a)
519
551
  });
@@ -524,8 +556,8 @@ var expandImpl = (graph, id, relation2) => {
524
556
  key,
525
557
  expanded
526
558
  }, {
527
- F: __dxlog_file,
528
- L: 706,
559
+ F: __dxlog_file2,
560
+ L: 719,
529
561
  S: void 0,
530
562
  C: (f, a) => f(...a)
531
563
  });
@@ -543,9 +575,9 @@ function expand(graphOrId, idOrRelation, relation2) {
543
575
  } else {
544
576
  const graph = graphOrId;
545
577
  const id = idOrRelation;
546
- invariant(relation2 !== void 0, "Relation is required.", {
547
- F: __dxlog_file,
548
- L: 742,
578
+ invariant2(relation2 !== void 0, "Relation is required.", {
579
+ F: __dxlog_file2,
580
+ L: 755,
549
581
  S: this,
550
582
  A: [
551
583
  "relation !== undefined",
@@ -621,8 +653,8 @@ var addNodeImpl = (graph, nodeArg) => {
621
653
  dataChanged,
622
654
  propertiesChanged
623
655
  }, {
624
- F: __dxlog_file,
625
- L: 864,
656
+ F: __dxlog_file2,
657
+ L: 877,
626
658
  S: void 0,
627
659
  C: (f, a) => f(...a)
628
660
  });
@@ -633,8 +665,8 @@ var addNodeImpl = (graph, nodeArg) => {
633
665
  data,
634
666
  properties
635
667
  }, {
636
- F: __dxlog_file,
637
- L: 871,
668
+ F: __dxlog_file2,
669
+ L: 884,
638
670
  S: void 0,
639
671
  C: (f, a) => f(...a)
640
672
  });
@@ -662,8 +694,8 @@ var addNodeImpl = (graph, nodeArg) => {
662
694
  data,
663
695
  properties
664
696
  }, {
665
- F: __dxlog_file,
666
- L: 884,
697
+ F: __dxlog_file2,
698
+ L: 897,
667
699
  S: void 0,
668
700
  C: (f, a) => f(...a)
669
701
  });
@@ -809,8 +841,8 @@ var addEdgeImpl = (graph, edgeArg) => {
809
841
  target: edgeArg.target,
810
842
  relation: relationId
811
843
  }, {
812
- F: __dxlog_file,
813
- L: 1068,
844
+ F: __dxlog_file2,
845
+ L: 1081,
814
846
  S: void 0,
815
847
  C: (f, a) => f(...a)
816
848
  });
@@ -831,8 +863,8 @@ var addEdgeImpl = (graph, edgeArg) => {
831
863
  target: edgeArg.target,
832
864
  relation: inverseId
833
865
  }, {
834
- F: __dxlog_file,
835
- L: 1076,
866
+ F: __dxlog_file2,
867
+ L: 1089,
836
868
  S: void 0,
837
869
  C: (f, a) => f(...a)
838
870
  });
@@ -935,9 +967,9 @@ var relationKey = (relation2) => {
935
967
  };
936
968
  var relationFromKey = (encoded) => {
937
969
  const separatorIndex = encoded.lastIndexOf(Separators.secondary);
938
- invariant(separatorIndex > 0 && separatorIndex < encoded.length - 1, `Invalid relation key: ${encoded}`, {
939
- F: __dxlog_file,
940
- L: 1221,
970
+ invariant2(separatorIndex > 0 && separatorIndex < encoded.length - 1, `Invalid relation key: ${encoded}`, {
971
+ F: __dxlog_file2,
972
+ L: 1234,
941
973
  S: void 0,
942
974
  A: [
943
975
  "separatorIndex > 0 && separatorIndex < encoded.length - 1",
@@ -946,9 +978,9 @@ var relationFromKey = (encoded) => {
946
978
  });
947
979
  const kind = encoded.slice(0, separatorIndex);
948
980
  const directionRaw = encoded.slice(separatorIndex + 1);
949
- invariant(directionRaw === "outbound" || directionRaw === "inbound", `Invalid relation direction: ${directionRaw}`, {
950
- F: __dxlog_file,
951
- L: 1224,
981
+ invariant2(directionRaw === "outbound" || directionRaw === "inbound", `Invalid relation direction: ${directionRaw}`, {
982
+ F: __dxlog_file2,
983
+ L: 1237,
952
984
  S: void 0,
953
985
  A: [
954
986
  "directionRaw === 'outbound' || directionRaw === 'inbound'",
@@ -960,9 +992,9 @@ var relationFromKey = (encoded) => {
960
992
  var connectionKey = (id, relation2) => `${id}${Separators.primary}${relationKey(relation2)}`;
961
993
  var relationFromConnectionKey = (key) => {
962
994
  const separatorIndex = key.indexOf(Separators.primary);
963
- invariant(separatorIndex > 0 && separatorIndex < key.length - 1, `Invalid connection key: ${key}`, {
964
- F: __dxlog_file,
965
- L: 1233,
995
+ invariant2(separatorIndex > 0 && separatorIndex < key.length - 1, `Invalid connection key: ${key}`, {
996
+ F: __dxlog_file2,
997
+ L: 1246,
966
998
  S: void 0,
967
999
  A: [
968
1000
  "separatorIndex > 0 && separatorIndex < key.length - 1",
@@ -1051,7 +1083,7 @@ var whenEchoObjectMatches = (node) => Obj.isObject(node.data) ? Option2.some(nod
1051
1083
  var whenNot = (matcher) => (node) => Option2.isNone(matcher(node)) ? Option2.some(node) : Option2.none();
1052
1084
 
1053
1085
  // src/graph-builder.ts
1054
- var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph-builder.ts";
1086
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-graph/src/graph-builder.ts";
1055
1087
  var GraphBuilderTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-graph/GraphBuilder");
1056
1088
  var GraphBuilderImpl = class {
1057
1089
  [GraphBuilderTypeId] = GraphBuilderTypeId;
@@ -1059,15 +1091,25 @@ var GraphBuilderImpl = class {
1059
1091
  return Pipeable2.pipeArguments(this, arguments);
1060
1092
  }
1061
1093
  // TODO(wittjosiah): Use Context.
1094
+ /** Active subscriptions keyed by composite ID, cleaned up on node removal. */
1062
1095
  _subscriptions = /* @__PURE__ */ new Map();
1096
+ /** Connector updates pending flush, keyed by connector key. */
1063
1097
  _dirtyConnectors = /* @__PURE__ */ new Map();
1098
+ /** Last-flushed node IDs per connector key, used for edge removal on update. */
1064
1099
  _connectorPrevious = /* @__PURE__ */ new Map();
1100
+ /** Last-flushed node args per connector key, used for change detection. */
1065
1101
  _connectorPreviousArgs = /* @__PURE__ */ new Map();
1102
+ /** Whether a dirty-flush task is already scheduled. */
1066
1103
  _flushScheduled = false;
1104
+ /** Resolves when the current flush completes. */
1067
1105
  _flushPromise = Promise.resolve();
1106
+ /** Registered builder extensions keyed by extension ID. */
1068
1107
  _extensions = Atom3.make(Record2.empty()).pipe(Atom3.keepAlive, Atom3.withLabel("graph-builder:extensions"));
1108
+ /** Triggers signalling that a node's resolver has fired at least once. */
1069
1109
  _initialized = {};
1110
+ /** Shared atom registry for reactive subscriptions. */
1070
1111
  _registry;
1112
+ /** Backing graph with internal accessors for node atoms and construction. */
1071
1113
  _graph;
1072
1114
  constructor({ registry, ...params } = {}) {
1073
1115
  this._registry = registry ?? Registry2.make();
@@ -1160,8 +1202,8 @@ var GraphBuilderImpl = class {
1160
1202
  relation: relation2,
1161
1203
  registry: getDebugName(this._registry)
1162
1204
  }, {
1163
- F: __dxlog_file2,
1164
- L: 251,
1205
+ F: __dxlog_file3,
1206
+ L: 261,
1165
1207
  S: this,
1166
1208
  C: (f, a) => f(...a)
1167
1209
  });
@@ -1173,7 +1215,8 @@ var GraphBuilderImpl = class {
1173
1215
  _expandRelation(id, relation2) {
1174
1216
  const key = connectorKey(id, relation2);
1175
1217
  const connectors = this._connectors(key);
1176
- const cancel = this._registry.subscribe(connectors, (nodes) => {
1218
+ const cancel = this._registry.subscribe(connectors, (rawNodes) => {
1219
+ const nodes = qualifyNodeArgs(id)(rawNodes);
1177
1220
  const previous = this._connectorPrevious.get(key) ?? [];
1178
1221
  const ids = nodes.map((n) => n.id);
1179
1222
  if (ids.length === previous.length && ids.every((nodeId, idx) => nodeId === previous[idx])) {
@@ -1187,8 +1230,8 @@ var GraphBuilderImpl = class {
1187
1230
  relation: relation2,
1188
1231
  ids
1189
1232
  }, {
1190
- F: __dxlog_file2,
1191
- L: 277,
1233
+ F: __dxlog_file3,
1234
+ L: 288,
1192
1235
  S: this,
1193
1236
  C: (f, a) => f(...a)
1194
1237
  });
@@ -1207,8 +1250,8 @@ var GraphBuilderImpl = class {
1207
1250
  log2("onInitialize", {
1208
1251
  id
1209
1252
  }, {
1210
- F: __dxlog_file2,
1211
- L: 289,
1253
+ F: __dxlog_file3,
1254
+ L: 300,
1212
1255
  S: this,
1213
1256
  C: (f, a) => f(...a)
1214
1257
  });
@@ -1217,9 +1260,14 @@ var GraphBuilderImpl = class {
1217
1260
  const trigger = this._initialized[id];
1218
1261
  Option3.match(node, {
1219
1262
  onSome: (node2) => {
1220
- addNodes(this._graph, [
1221
- node2
1222
- ]);
1263
+ const connectorOwned = [
1264
+ ...this._connectorPrevious.values()
1265
+ ].some((ids) => ids.includes(id));
1266
+ if (!connectorOwned) {
1267
+ addNodes(this._graph, [
1268
+ node2
1269
+ ]);
1270
+ }
1223
1271
  trigger?.wake();
1224
1272
  },
1225
1273
  onNone: () => {
@@ -1307,7 +1355,7 @@ var exploreImpl = async (builder, options, path = []) => {
1307
1355
  if (shouldContinue === false) {
1308
1356
  return;
1309
1357
  }
1310
- const nodes = Object.values(internal._registry.get(internal._extensions)).filter((extension) => relationKey(extension.relation ?? "child") === relationKey(relation2)).map((extension) => extension.connector).filter(isNonNullable2).flatMap((connector) => registry.get(connector(internal._graph.node(source))));
1358
+ const nodes = Function2.pipe(internal._registry.get(internal._extensions), Record2.values, Array2.map((extension) => extension.connector), Array2.filter(isNonNullable2), Array2.flatMap((connector) => registry.get(connector(internal._graph.node(source)))), qualifyNodeArgs(source));
1311
1359
  await Promise.all(nodes.map((nodeArg) => {
1312
1360
  registry.set(internal._graph._node(nodeArg.id), internal._graph._constructNode(nodeArg));
1313
1361
  return exploreImpl(builder, {
@@ -1379,8 +1427,8 @@ var createExtensionRaw = (extension) => {
1379
1427
  node,
1380
1428
  error
1381
1429
  }, {
1382
- F: __dxlog_file2,
1383
- L: 579,
1430
+ F: __dxlog_file3,
1431
+ L: 596,
1384
1432
  S: void 0,
1385
1433
  C: (f, a) => f(...a)
1386
1434
  });
@@ -1405,8 +1453,8 @@ var createExtensionRaw = (extension) => {
1405
1453
  node,
1406
1454
  error
1407
1455
  }, {
1408
- F: __dxlog_file2,
1409
- L: 600,
1456
+ F: __dxlog_file3,
1457
+ L: 617,
1410
1458
  S: void 0,
1411
1459
  C: (f, a) => f(...a)
1412
1460
  });
@@ -1430,8 +1478,8 @@ var createExtensionRaw = (extension) => {
1430
1478
  node,
1431
1479
  error
1432
1480
  }, {
1433
- F: __dxlog_file2,
1434
- L: 617,
1481
+ F: __dxlog_file3,
1482
+ L: 634,
1435
1483
  S: void 0,
1436
1484
  C: (f, a) => f(...a)
1437
1485
  });
@@ -1447,8 +1495,8 @@ var runEffectSyncWithFallback = (effect, context2, extensionId, fallback) => {
1447
1495
  extension: extensionId,
1448
1496
  error
1449
1497
  }, {
1450
- F: __dxlog_file2,
1451
- L: 660,
1498
+ F: __dxlog_file3,
1499
+ L: 677,
1452
1500
  S: void 0,
1453
1501
  C: (f, a) => f(...a)
1454
1502
  });
@@ -1490,6 +1538,15 @@ var createTypeExtension = (options) => {
1490
1538
  position
1491
1539
  });
1492
1540
  };
1541
+ var qualifyNodeArgs = (parentId) => (nodes) => nodes.map((node) => {
1542
+ validateSegmentId(node.id);
1543
+ const qualified = qualifyId(parentId, node.id);
1544
+ return {
1545
+ ...node,
1546
+ id: qualified,
1547
+ nodes: node.nodes ? qualifyNodeArgs(qualified)(node.nodes) : void 0
1548
+ };
1549
+ });
1493
1550
  var connectorKey = (id, relation2) => `${id}${Separators.primary}${relationKey(relation2)}`;
1494
1551
  var relationFromConnectorKey = (key) => {
1495
1552
  const separatorIndex = key.indexOf(Separators.primary);