@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.25

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.
Files changed (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +9 -1
  107. package/dist/core-ugchZNqC.cjs +0 -1
@@ -1,27 +1,57 @@
1
- var $ = Object.defineProperty;
2
- var U = (u, e, t) => e in u ? $(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
- var d = (u, e, t) => U(u, typeof e != "symbol" ? e + "" : e, t);
4
- import { RaphDisposedError as A, RaphCrossRuntimeError as H } from "../errors.js";
5
- import { throwDisposalErrors as v } from "../ownership/throwDisposalErrors.js";
6
- const G = Symbol("RaphProducerRecord"), m = /* @__PURE__ */ new WeakMap(), M = Object.freeze([]), C = Object.freeze([]);
7
- class b {
1
+ import { RaphDisposedError as w, RaphCrossRuntimeError as j } from "../errors.js";
2
+ import { throwDisposalErrors as _ } from "../ownership/throwDisposalErrors.js";
3
+ class v {
4
+ constructor(e, t, s) {
5
+ this.owner = e, this.kind = t, this.includeRuntime = s, this.subscribers = void 0, this.memberships = void 0, this.implicitConsumers = void 0, this.source = void 0, this.activate = void 0, this.runtimeActivation = void 0, this.lastCause = void 0, this.transientNext = void 0, this.revision = 0, this.disposed = !1;
6
+ }
7
+ get runtime() {
8
+ return this.owner.runtime;
9
+ }
10
+ /**
11
+ * Тег Object.prototype.toString: `[object RaphProducer]`. По нему инструменты,
12
+ * которые копируют и обходят только plain objects, принимают producer за
13
+ * неделимое значение: тестовый runner не клонирует его вместе со всем графом
14
+ * Runtime перед печатью diff. Accessor лежит на prototype.
15
+ */
16
+ get [Symbol.toStringTag]() {
17
+ return "RaphProducer";
18
+ }
19
+ /**
20
+ * Возвращает компактное описание вместо собственных полей. Поля producer
21
+ * ведут к владельцу, Runtime и графу зависимостей: без этого метода
22
+ * JSON.stringify упирался бы в циклы, а печать значения в логах и в diff
23
+ * неуспешной проверки тестового runner-а обходила бы весь граф Runtime.
24
+ * Метод лежит на prototype и не добавляет producer ни поля, ни closure.
25
+ */
26
+ toJSON() {
27
+ return {
28
+ kind: this.kind,
29
+ owner: this.owner.id,
30
+ revision: this.revision,
31
+ disposed: this.disposed
32
+ };
33
+ }
34
+ }
35
+ v.prototype._isProducer = !0;
36
+ const R = /* @__PURE__ */ new WeakMap(), k = Object.freeze([]), A = Object.freeze([]);
37
+ class p {
8
38
  /** @internal */
9
39
  constructor(e, t) {
10
- d(this, "_sources");
11
- d(this, "_disposed", !1);
12
- d(this, "_releaseOwner");
13
- d(this, "_memberReleases");
14
- d(this, "_firstSubscription");
15
- d(this, "_lastSubscription");
16
- d(this, "_firstDependent");
17
- d(this, "_lastDependent");
18
- d(this, "_revision", 0);
19
- d(this, "_finalCause");
20
- this.owner = e, this._sources = F(t);
40
+ this.owner = e, this._sources = H(t);
21
41
  }
42
+ _sources;
43
+ _disposed = !1;
44
+ _releaseOwner;
45
+ _memberReleases;
46
+ _firstSubscription;
47
+ _lastSubscription;
48
+ _firstDependent;
49
+ _lastDependent;
50
+ _revision = 0;
51
+ _finalCause;
22
52
  /** @internal */
23
53
  static _create(e, t) {
24
- return new b(e, t);
54
+ return new p(e, t);
25
55
  }
26
56
  get runtime() {
27
57
  return this.owner.runtime;
@@ -51,12 +81,12 @@ class b {
51
81
  s.push(i);
52
82
  }
53
83
  }
54
- v(s, "[Raph] Aggregate disposal failed.");
84
+ _(s, "[Raph] Aggregate disposal failed.");
55
85
  }
56
86
  /** @internal */
57
87
  _assertAlive() {
58
88
  if (this._disposed || this.owner.disposed)
59
- throw new A("[Raph] Aggregate is disposed.");
89
+ throw new w("[Raph] Aggregate is disposed.");
60
90
  }
61
91
  /** @internal */
62
92
  _bindOwner(e) {
@@ -70,21 +100,21 @@ class b {
70
100
  _removeMember(e) {
71
101
  if (this._disposed)
72
102
  return;
73
- const t = this._sources.filter((s) => L(s) !== e);
74
- t.length !== this._sources.length && (this._sources = t.length === 0 ? M : Object.freeze(t));
103
+ const t = this._sources.filter((s) => W(s) !== e);
104
+ t.length !== this._sources.length && (this._sources = t.length === 0 ? k : Object.freeze(t));
75
105
  }
76
106
  /** @internal */
77
107
  _disposeOwned() {
78
108
  if (this._disposed)
79
109
  return;
80
110
  this._disposed = !0, this._releaseOwner = void 0;
81
- const e = f(this.owner) && !this.owner._isPublished() ? void 0 : this._disposalCause(), t = [];
111
+ const e = d(this.owner) && !this.owner._isPublished() ? void 0 : this._disposalCause(), t = [];
82
112
  let s = this._firstSubscription;
83
113
  for (this._firstSubscription = this._lastSubscription = void 0; s !== void 0; ) {
84
- const o = s.next, r = s.dispose;
114
+ const o = s.next, u = s.dispose;
85
115
  s.aggregate = void 0, s.dispose = void 0, s.previous = s.next = void 0;
86
116
  try {
87
- r == null || r(e);
117
+ u?.(e);
88
118
  } catch (c) {
89
119
  t.push(c);
90
120
  }
@@ -95,22 +125,22 @@ class b {
95
125
  for (let o = i.length - 1; o >= 0; o--)
96
126
  try {
97
127
  i[o]();
98
- } catch (r) {
99
- t.push(r);
128
+ } catch (u) {
129
+ t.push(u);
100
130
  }
101
- this._sources = M;
102
- let n = this._firstDependent;
103
- for (this._firstDependent = this._lastDependent = void 0; n !== void 0; ) {
104
- const o = n.next, r = n.cleanup;
105
- n.source = void 0, n.cleanup = void 0, n.previous = n.next = void 0;
131
+ this._sources = k;
132
+ let r = this._firstDependent;
133
+ for (this._firstDependent = this._lastDependent = void 0; r !== void 0; ) {
134
+ const o = r.next, u = r.cleanup;
135
+ r.source = void 0, r.cleanup = void 0, r.previous = r.next = void 0;
106
136
  try {
107
- r == null || r();
137
+ u?.();
108
138
  } catch (c) {
109
139
  t.push(c);
110
140
  }
111
- n = o;
141
+ r = o;
112
142
  }
113
- v(t, "[Raph] Aggregate owned cleanup failed.");
143
+ _(t, "[Raph] Aggregate owned cleanup failed.");
114
144
  }
115
145
  /** @internal */
116
146
  _linkSubscription(e) {
@@ -120,7 +150,7 @@ class b {
120
150
  dispose: e,
121
151
  previous: this._lastSubscription
122
152
  };
123
- return this._lastSubscription === void 0 ? this._firstSubscription = t : this._lastSubscription.next = t, this._lastSubscription = t, () => Y(t);
153
+ return this._lastSubscription === void 0 ? this._firstSubscription = t : this._lastSubscription.next = t, this._lastSubscription = t, () => K(t);
124
154
  }
125
155
  /** @internal */
126
156
  _linkDependent(e) {
@@ -132,64 +162,57 @@ class b {
132
162
  }
133
163
  /** @internal */
134
164
  _disposalCause() {
135
- return this._finalCause ?? (this._finalCause = Object.freeze({
165
+ return this._finalCause ??= Object.freeze({
136
166
  kind: "structure",
137
167
  source: this,
138
168
  sourceOwner: this.owner,
139
169
  revision: ++this._revision,
140
170
  metadata: Object.freeze({ disposed: !0 })
141
- }));
171
+ });
142
172
  }
143
173
  /** @internal */
144
174
  _detachSubscription(e) {
145
175
  if (e.aggregate === void 0)
146
176
  return;
147
177
  const t = e.dispose;
148
- e.aggregate = void 0, e.dispose = void 0, e.previous === void 0 ? this._firstSubscription = e.next : e.previous.next = e.next, e.next === void 0 ? this._lastSubscription = e.previous : e.next.previous = e.previous, e.previous = e.next = void 0, t == null || t();
178
+ e.aggregate = void 0, e.dispose = void 0, e.previous === void 0 ? this._firstSubscription = e.next : e.previous.next = e.next, e.next === void 0 ? this._lastSubscription = e.previous : e.next.previous = e.previous, e.previous = e.next = void 0, t?.();
149
179
  }
150
180
  }
151
- class V {
181
+ class G {
152
182
  constructor(e) {
153
- d(this, "_selfSubscribers");
154
- d(this, "_subtreeSubscribers");
155
- d(this, "_runtimeSubscribers");
156
- d(this, "_runtimeSubscriberCount", 0);
157
- d(this, "_runtimeActivationProducers");
158
- d(this, "_nodeMemberships");
159
- d(this, "_nodeRevisions");
160
- d(this, "_nodeTouchKeys");
161
- d(this, "_implicitProducers");
162
- d(this, "_transientProducers");
163
- d(this, "_dispatchDepth", 0);
164
- d(this, "_detachedEdges");
165
- d(this, "_disposed", !1);
166
183
  this._runtime = e;
167
184
  }
185
+ _selfSubscribers;
186
+ _subtreeSubscribers;
187
+ _runtimeSubscribers;
188
+ _runtimeSubscriberCount = 0;
189
+ _runtimeActivationProducers;
190
+ _nodeMemberships;
191
+ _nodeRevisions;
192
+ _nodeTouchKeys;
193
+ _implicitProducers;
194
+ _transientProducers;
195
+ _dispatchDepth = 0;
196
+ _detachedEdges;
197
+ _disposed = !1;
168
198
  createProducer(e, t = "producer", s = {}) {
169
- return this._assertAlive(), {
170
- [G]: !0,
171
- runtime: this._runtime,
172
- owner: e,
173
- kind: t,
174
- includeRuntime: s.includeRuntime ?? !0,
175
- revision: 0,
176
- disposed: !1
177
- };
199
+ return this._assertAlive(), new v(e, t, s.includeRuntime ?? !0);
178
200
  }
179
201
  attachProducer(e, t) {
180
- return e.alias !== void 0 && m.delete(e.alias), e.source = t, e.alias = t, m.set(t, e), t;
202
+ const s = e.source;
203
+ return s !== void 0 && s !== e && R.delete(s), e.source = t, R.set(t, e), t;
181
204
  }
182
205
  setProducerActivation(e, t, s = !1) {
183
206
  if (e.disposed)
184
- throw new A("[Raph] Producer is disposed.");
207
+ throw new w("[Raph] Producer is disposed.");
185
208
  if (e.activate = t, !s)
186
209
  return;
187
- const i = this._runtimeActivationProducers ?? (this._runtimeActivationProducers = /* @__PURE__ */ new Set());
210
+ const i = this._runtimeActivationProducers ??= /* @__PURE__ */ new Set();
188
211
  if (i.add(e), this._runtimeSubscriberCount !== 0)
189
212
  try {
190
- e.runtimeActivation = D(t());
191
- } catch (n) {
192
- throw i.delete(e), i.size === 0 && (this._runtimeActivationProducers = void 0), n;
213
+ e.runtimeActivation = x(t());
214
+ } catch (r) {
215
+ throw i.delete(e), i.size === 0 && (this._runtimeActivationProducers = void 0), r;
193
216
  }
194
217
  }
195
218
  producerHooks(e) {
@@ -212,9 +235,20 @@ class V {
212
235
  onDispose: (t) => this._disposeProducer(e, t)
213
236
  };
214
237
  }
238
+ /**
239
+ * Возвращает последнюю причину producer, который engine назвал своим token.
240
+ * Token чужого Runtime и значение, не являющееся producer, причины не имеют.
241
+ *
242
+ * Метод вызывается на каждое уведомление implicit consumer, поэтому producer
243
+ * распознаётся prototype-брендом, а Runtime читается у владельца напрямую:
244
+ * без `instanceof` и без accessor.
245
+ */
215
246
  causeForToken(e) {
216
- if (!(!E(e) || e.runtime !== this._runtime))
217
- return e.lastCause;
247
+ if (typeof e != "object" || e === null)
248
+ return;
249
+ const t = e;
250
+ if (!(t._isProducer !== !0 || t.owner.runtime !== this._runtime))
251
+ return t.lastCause;
218
252
  }
219
253
  /** Clears mutation-local payloads after engine propagation consumed them. */
220
254
  clearTransientCauses() {
@@ -224,69 +258,124 @@ class V {
224
258
  e.transientNext = void 0, e.lastCause = void 0, e = t;
225
259
  }
226
260
  }
227
- notifyProducer(e, t, s, i, n = !0, o = !1, r = !1) {
228
- var a, h;
229
- if (this._disposed || e.disposed || e.source === void 0 || f(e.owner) && !e.owner._isPublished() || !r && i === void 0 && e.lastCause !== void 0)
261
+ notifyProducer(e, t, s, i, r = !0, o = !1, u = !1) {
262
+ if (this._disposed || e.disposed || e.source === void 0 || d(e.owner) && !e.owner._isPublished() || !u && i === void 0 && e.lastCause !== void 0)
230
263
  return;
231
- if (!o && ((a = e.subscribers) == null ? void 0 : a.first) === void 0 && (!e.includeRuntime || ((h = this._runtimeSubscribers) == null ? void 0 : h.first) === void 0)) {
232
- this._dispatchProducerLazily(e, t, s, i, n, r);
264
+ if (!o && e.subscribers?.first === void 0 && (!e.includeRuntime || this._runtimeSubscribers?.first === void 0)) {
265
+ this._dispatchProducerLazily(e, t, s, i, r, u);
233
266
  return;
234
267
  }
235
- const c = Object.freeze({
268
+ const c = u && i === void 0 ? y(
269
+ e.kind,
270
+ e.source,
271
+ e.owner,
272
+ ++e.revision,
273
+ t,
274
+ s
275
+ ) : {
236
276
  kind: e.kind,
237
277
  source: e.source,
238
278
  sourceOwner: e.owner,
239
279
  revision: ++e.revision,
240
- ...r ? { previous: t, value: s } : {},
280
+ ...u ? { previous: t, value: s } : {},
241
281
  ...i === void 0 ? {} : { events: Object.freeze([...i]) }
242
- });
243
- this._setTransientCause(e, c), this._dispatchProducer(e, c, n);
282
+ };
283
+ this._setTransientCause(e, c), this._dispatchProducer(e, c, r);
284
+ }
285
+ /**
286
+ * Публикует запись значения producer: форма `notifyProducer()` для причины с
287
+ * `previous` и `value`, без events и с планированием. Так свою запись
288
+ * публикует Runtime signal.
289
+ *
290
+ * Причина создаётся при тех же условиях и с теми же полями. Отличие в цене:
291
+ * у producer с implicit consumers, на который не подписан ни один watch, ни
292
+ * его node, ни поддерево, ни Runtime, причину получают только consumers через
293
+ * `causeForToken()`. Тогда обход подписчиков не начинается: запись не строит
294
+ * массив предков и не выполняет ни одного вызова на каждого из них.
295
+ *
296
+ * @internal
297
+ */
298
+ _notifyValueWrite(e, t, s, i) {
299
+ const r = e.source;
300
+ if (this._disposed || e.disposed || r === void 0)
301
+ return;
302
+ const o = e.owner;
303
+ if (o._isNode && !o._isPublished())
304
+ return;
305
+ const u = e.subscribers;
306
+ if (!i && u?.first === void 0 && (!e.includeRuntime || this._runtimeSubscribers?.first === void 0)) {
307
+ this._dispatchProducerLazily(e, t, s, void 0, !0, !0);
308
+ return;
309
+ }
310
+ const c = y(e.kind, r, o, ++e.revision, t, s);
311
+ e.lastCause === void 0 && (e.transientNext = this._transientProducers, this._transientProducers = e), e.lastCause = c, !(u === void 0 && this._selfSubscribers === void 0 && this._subtreeSubscribers === void 0 && this._runtimeSubscribers === void 0) && this._dispatchProducer(e, c, !0);
244
312
  }
245
313
  notifyProducerEvents(e, t, s = !0, i = !1) {
246
- var o, r;
247
- if (this._disposed || e.disposed || e.source === void 0 || f(e.owner) && !e.owner._isPublished())
314
+ if (this._disposed || e.disposed || e.source === void 0 || d(e.owner) && !e.owner._isPublished())
248
315
  return;
249
- if (!i && ((o = e.subscribers) == null ? void 0 : o.first) === void 0 && (!e.includeRuntime || ((r = this._runtimeSubscribers) == null ? void 0 : r.first) === void 0)) {
316
+ if (!i && e.subscribers?.first === void 0 && (!e.includeRuntime || this._runtimeSubscribers?.first === void 0)) {
250
317
  this._dispatchProducerLazily(e, void 0, void 0, t, s, !1);
251
318
  return;
252
319
  }
253
- const n = Object.freeze({
320
+ const r = {
254
321
  kind: e.kind,
255
322
  source: e.source,
256
323
  sourceOwner: e.owner,
257
324
  revision: ++e.revision,
258
325
  events: Object.freeze([...t])
259
- });
260
- this._setTransientCause(e, n), this._dispatchProducer(e, n, s);
326
+ };
327
+ this._setTransientCause(e, r), this._dispatchProducer(e, r, s);
328
+ }
329
+ /**
330
+ * Дешёвая предварительная проверка structural publication: `false` означает,
331
+ * что `notifyNode` для этой node вернётся до создания cause и без побочных
332
+ * эффектов. `true` консервативен и ведёт на полный путь.
333
+ *
334
+ * @internal
335
+ */
336
+ _hasStructuralDemand(e) {
337
+ if (this._runtimeSubscribers !== void 0 || this._subtreeSubscribers !== void 0)
338
+ return !0;
339
+ const t = this._selfSubscribers;
340
+ return t !== void 0 && t.has(e);
341
+ }
342
+ /**
343
+ * Сообщает, есть ли хотя бы один runtime-, subtree- или self-подписчик.
344
+ * `true` означает, что `_hasStructuralDemand` может вернуть `true` для
345
+ * какой-то node этого Runtime.
346
+ *
347
+ * @internal
348
+ */
349
+ _hasNodeSubscribers() {
350
+ return this._runtimeSubscribers !== void 0 || this._subtreeSubscribers !== void 0 || this._selfSubscribers !== void 0;
261
351
  }
262
352
  notifyNode(e, t, s = {}) {
263
- var l, _, p, O, g, z;
264
- if (this._disposed || !e._isPublished() || ((l = this._runtimeSubscribers) == null ? void 0 : l.first) === void 0 && ((p = (_ = this._selfSubscribers) == null ? void 0 : _.get(e)) == null ? void 0 : p.first) === void 0 && this._subtreeSubscribers === void 0)
353
+ if (this._disposed || !e._isPublished() || this._runtimeSubscribers?.first === void 0 && this._selfSubscribers?.get(e)?.first === void 0 && this._subtreeSubscribers === void 0)
265
354
  return;
266
- const i = s.oldAncestors === void 0 && s.newAncestors === void 0 ? this._subtreeSubscribers === void 0 ? C : k(e) : void 0, n = s.oldAncestors ?? i ?? C, o = s.newAncestors ?? i ?? C;
267
- if (!this._nodeHasDemand(e, n, o))
355
+ const i = s.oldAncestors === void 0 && s.newAncestors === void 0 ? this._subtreeSubscribers === void 0 ? A : P(e) : void 0, r = s.oldAncestors ?? i ?? A, o = s.newAncestors ?? i ?? A;
356
+ if (!this._nodeHasDemand(e, r, o))
268
357
  return;
269
- const r = this._nodeRevisions ?? (this._nodeRevisions = /* @__PURE__ */ new WeakMap()), c = (r.get(e) ?? 0) + 1;
270
- r.set(e, c);
271
- const a = Object.freeze({
358
+ const u = this._nodeRevisions ??= /* @__PURE__ */ new WeakMap(), c = (u.get(e) ?? 0) + 1;
359
+ u.set(e, c);
360
+ const a = {
272
361
  kind: t,
273
362
  source: e,
274
363
  sourceOwner: e,
275
364
  revision: c,
276
365
  ...s.metadata === void 0 ? {} : { metadata: s.metadata },
277
366
  ...s.structure === void 0 ? {} : { structure: Object.freeze({ ...s.structure }) }
278
- }), h = t === "structure" ? e : this._nodeTouchKey(e);
279
- if (this._dispatch((O = this._selfSubscribers) == null ? void 0 : O.get(e), a, h), i !== void 0)
280
- for (const R of i)
281
- this._dispatch((g = this._subtreeSubscribers) == null ? void 0 : g.get(R), a, h);
367
+ }, h = t === "structure" ? e : this._nodeTouchKey(e);
368
+ if (this._dispatch(this._selfSubscribers?.get(e), a, h), i !== void 0)
369
+ for (const f of i)
370
+ this._dispatch(this._subtreeSubscribers?.get(f), a, h);
282
371
  else {
283
- const R = /* @__PURE__ */ new Set();
284
- for (const y of n)
285
- R.add(y);
286
- for (const y of o)
287
- R.add(y);
288
- for (const y of R)
289
- this._dispatch((z = this._subtreeSubscribers) == null ? void 0 : z.get(y), a, h);
372
+ const f = /* @__PURE__ */ new Set();
373
+ for (const l of r)
374
+ f.add(l);
375
+ for (const l of o)
376
+ f.add(l);
377
+ for (const l of f)
378
+ this._dispatch(this._subtreeSubscribers?.get(l), a, h);
290
379
  }
291
380
  this._dispatch(this._runtimeSubscribers, a, h);
292
381
  }
@@ -296,37 +385,37 @@ class V {
296
385
  this._validateAggregateSources(t, /* @__PURE__ */ new Set());
297
386
  for (const o of t)
298
387
  this._assertSourceVisibleTo(e, o, /* @__PURE__ */ new Set());
299
- const s = b._create(e, t), i = [], n = /* @__PURE__ */ new Set();
388
+ const s = p._create(e, t), i = [], r = /* @__PURE__ */ new Set();
300
389
  try {
301
390
  for (const o of s.sources) {
302
- const r = L(o);
303
- if (r === void 0 || n.has(r))
391
+ const u = W(o);
392
+ if (u === void 0 || r.has(u))
304
393
  continue;
305
- n.add(r);
306
- const c = this._linkSourceCleanup(o, () => s._removeMember(r));
394
+ r.add(u);
395
+ const c = this._linkSourceCleanup(o, () => s._removeMember(u));
307
396
  c !== void 0 && i.push(c);
308
397
  }
309
398
  return s._bindMembers(i), s._bindOwner(e._adoptResource(() => s._disposeOwned())), s;
310
399
  } catch (o) {
311
- const r = [];
400
+ const u = [];
312
401
  for (let c = i.length - 1; c >= 0; c--)
313
402
  try {
314
403
  i[c]();
315
404
  } catch (a) {
316
- r.push(a);
405
+ u.push(a);
317
406
  }
318
- throw r.length !== 0 ? new AggregateError(
319
- [o, ...r],
407
+ throw u.length !== 0 ? new AggregateError(
408
+ [o, ...u],
320
409
  "[Raph] Aggregate registration and rollback failed."
321
410
  ) : o;
322
411
  }
323
412
  }
324
413
  subscribe(e, t, s) {
325
414
  this._assertAlive();
326
- const i = [], n = /* @__PURE__ */ new WeakMap();
415
+ const i = [], r = /* @__PURE__ */ new WeakMap();
327
416
  try {
328
- this._subscribeOne(e, t, s, i, n, /* @__PURE__ */ new Set());
329
- } catch (r) {
417
+ this._subscribeOne(e, t, s, i, r, /* @__PURE__ */ new Set());
418
+ } catch (u) {
330
419
  const c = [];
331
420
  for (let a = i.length - 1; a >= 0; a--)
332
421
  try {
@@ -335,180 +424,218 @@ class V {
335
424
  c.push(h);
336
425
  }
337
426
  throw c.length !== 0 ? new AggregateError(
338
- [r, ...c],
427
+ [u, ...c],
339
428
  "[Raph] Granular subscription registration and rollback failed."
340
- ) : r;
429
+ ) : u;
341
430
  }
342
431
  let o = !0;
343
432
  return () => {
344
433
  if (!o)
345
434
  return;
346
435
  o = !1;
347
- const r = [];
436
+ const u = [];
348
437
  for (let c = i.length - 1; c >= 0; c--)
349
438
  try {
350
439
  i[c]();
351
440
  } catch (a) {
352
- r.push(a);
441
+ u.push(a);
353
442
  }
354
- v(r, "[Raph] Granular subscription disposal failed.");
443
+ _(u, "[Raph] Granular subscription disposal failed.");
355
444
  };
356
445
  }
357
446
  assertSubscriptionAllowed(e, t) {
358
447
  this._assertOwner(e), this._assertSourceVisibleTo(e, t, /* @__PURE__ */ new Set());
359
448
  }
360
- /** Rejects a move that would make an existing implicit reactive edge illegal. */
449
+ /**
450
+ * Rejects a move that would make an existing implicit reactive edge illegal.
451
+ *
452
+ * Рёбра от producers с отдельной записью (computed, machine) берутся из
453
+ * учёта `implicitConsumers`. Рёбра от Runtime signals нигде не учитываются:
454
+ * они читаются из графа в момент проверки.
455
+ */
361
456
  assertReparentAllowed(e, t) {
362
457
  const s = this._implicitProducers;
363
458
  if (s !== void 0)
364
459
  for (const i of s) {
365
- const n = i.owner;
366
- if (!f(n))
460
+ const r = i.owner;
461
+ if (!d(r))
367
462
  continue;
368
463
  const o = i.implicitConsumers;
369
- if (o !== void 0) {
370
- for (const r of o.keys())
371
- if (j(r, e) && !j(n, e) && !K(n, t))
372
- throw new Error(
373
- `[Raph] Cannot reparent "${e.id}": implicit dependency from "${r.id}" to "${n.id}" would become invalid; use watch().`
374
- );
375
- }
464
+ if (o !== void 0)
465
+ for (const u of o.keys())
466
+ E(u, e) && (E(r, e) || L(r, t) || T(e, u, r));
376
467
  }
468
+ this._assertSignalEdgesAllowReparent(e, t);
469
+ }
470
+ /**
471
+ * Проверяет живые implicit-рёбра от Runtime signals. Implicit-чтение
472
+ * разрешено только у собственного владельца, его предков и root scope,
473
+ * поэтому внешний для переносимого поддерева источник всегда принадлежит
474
+ * прежнему предку `node`. Предок, который остаётся предком нового parent,
475
+ * сохраняет все свои рёбра законными. Остаются предки от прежнего parent до
476
+ * ближайшего общего с новым parent, не включая его: перенос запрещён, если
477
+ * signal такого предка читает потребитель из переносимого поддерева.
478
+ *
479
+ * Посылка о прежнем предке держится на проверке самого чтения: Runtime
480
+ * signal отклоняет implicit-чтение чужого владельца и тогда, когда общий
481
+ * контекст владельца снят untracked-работой другого Runtime, а потребитель
482
+ * этого Runtime остался активным (assertReadable в RuntimeReactivity).
483
+ *
484
+ * Цена переноса. Перенос под прежнего parent и перенос корня дерева
485
+ * проверки не требуют. Иначе для каждого покидаемого предка обходится весь
486
+ * список его источников (не-signals пропускаются за один шаг), а у каждого
487
+ * signal с записью графа — список его потребителей до первого потребителя
488
+ * из переносимого поддерева. Итого O(покидаемые предки × их источники +
489
+ * потребители их signals), без аллокаций. Цена не зависит от того, сколько
490
+ * рёбер между nodes есть в остальном Runtime, но растёт с числом источников
491
+ * и потребителей у покидаемых предков, даже когда их signals читает только
492
+ * сам владелец: перенос из-под parent с тысячей signals обходит всю тысячу.
493
+ * Прежний учёт рёбер стоил наоборот: ничего для таких signals и обход всех
494
+ * producers Runtime с рёбрами между nodes вместе с их потребителями, где бы
495
+ * в дереве они ни находились.
496
+ */
497
+ _assertSignalEdgesAllowReparent(e, t) {
498
+ const s = e.parent;
499
+ if (s === null)
500
+ return;
501
+ const i = $(s, t);
502
+ if (i === s)
503
+ return;
504
+ const r = this._runtime._getReactivity();
505
+ for (let o = s; o !== null && o !== i; o = o.parent) {
506
+ const u = r._findSignalConsumerOwner(o, I, e);
507
+ u !== void 0 && T(e, u, o);
508
+ }
377
509
  }
378
510
  releaseNode(e) {
379
- var s, i;
380
511
  this._releaseGranule(this._selfSubscribers, e), this._releaseGranule(this._subtreeSubscribers, e);
381
- const t = (s = this._nodeMemberships) == null ? void 0 : s.get(e);
512
+ const t = this._nodeMemberships?.get(e);
382
513
  if (t !== void 0) {
383
514
  this._nodeMemberships.delete(e);
384
515
  try {
385
516
  this._releaseCleanupList(t);
386
517
  } finally {
387
- ((i = this._nodeMemberships) == null ? void 0 : i.size) === 0 && (this._nodeMemberships = void 0);
518
+ this._nodeMemberships?.size === 0 && (this._nodeMemberships = void 0);
388
519
  }
389
520
  }
390
521
  }
391
522
  dispose() {
392
- var t;
393
523
  if (this._disposed)
394
524
  return;
395
525
  this._disposed = !0;
396
526
  const e = [];
397
527
  if (this.clearTransientCauses(), this._implicitProducers !== void 0) {
398
- for (const s of this._implicitProducers)
399
- s.implicitConsumers = void 0;
528
+ for (const t of this._implicitProducers)
529
+ t.implicitConsumers = void 0;
400
530
  this._implicitProducers.clear(), this._implicitProducers = void 0;
401
531
  }
402
532
  try {
403
533
  this._releaseRuntimeActivations();
404
- } catch (s) {
405
- e.push(s);
534
+ } catch (t) {
535
+ e.push(t);
406
536
  }
407
- if ((t = this._runtimeActivationProducers) == null || t.clear(), this._runtimeActivationProducers = void 0, this._runtimeSubscriberCount = 0, this._selfSubscribers !== void 0)
408
- for (const s of [...this._selfSubscribers.keys()])
409
- this._releaseGranule(this._selfSubscribers, s);
537
+ if (this._runtimeActivationProducers?.clear(), this._runtimeActivationProducers = void 0, this._runtimeSubscriberCount = 0, this._selfSubscribers !== void 0)
538
+ for (const t of [...this._selfSubscribers.keys()])
539
+ this._releaseGranule(this._selfSubscribers, t);
410
540
  if (this._subtreeSubscribers !== void 0)
411
- for (const s of [...this._subtreeSubscribers.keys()])
412
- this._releaseGranule(this._subtreeSubscribers, s);
541
+ for (const t of [...this._subtreeSubscribers.keys()])
542
+ this._releaseGranule(this._subtreeSubscribers, t);
413
543
  if (this._nodeMemberships !== void 0) {
414
- for (const s of this._nodeMemberships.values())
415
- this._releaseCleanupList(s, !1);
544
+ for (const t of this._nodeMemberships.values())
545
+ this._releaseCleanupList(t, !1);
416
546
  this._nodeMemberships.clear(), this._nodeMemberships = void 0;
417
547
  }
418
548
  if (this._runtimeSubscribers !== void 0) {
419
549
  try {
420
550
  this._releaseWorkList(this._runtimeSubscribers);
421
- } catch (s) {
422
- e.push(s);
551
+ } catch (t) {
552
+ e.push(t);
423
553
  }
424
554
  this._runtimeSubscribers = void 0;
425
555
  }
426
- v(e, "[Raph] Work graph disposal failed.");
556
+ _(e, "[Raph] Work graph disposal failed.");
427
557
  }
558
+ /**
559
+ * Освобождает producer: публикует финальную structural cause при спросе и
560
+ * снимает его подписчиков, memberships и регистрацию. Вызывается hook-ом
561
+ * onDispose owned-источника и самим Runtime signal.
562
+ *
563
+ * @internal
564
+ */
428
565
  _disposeProducer(e, t = !1) {
429
- var r, c;
430
566
  if (e.disposed)
431
567
  return;
432
- const s = e.source, i = !f(e.owner) || e.owner._isPublished();
433
- let n;
568
+ const s = e.source, i = !d(e.owner) || e.owner._isPublished();
569
+ let r;
434
570
  if (s !== void 0 && i && (t || this._producerHasDemand(e))) {
435
- const a = Object.freeze({
571
+ const c = {
436
572
  kind: "structure",
437
573
  source: s,
438
574
  sourceOwner: e.owner,
439
575
  revision: ++e.revision,
440
576
  metadata: Object.freeze({ disposed: !0 })
441
- });
442
- this._setTransientCause(e, a);
577
+ };
578
+ this._setTransientCause(e, c);
579
+ const a = s === e ? c : s;
443
580
  try {
444
- this._dispatchProducer(e, a, !0, s);
581
+ this._dispatchProducer(e, c, !0, a);
445
582
  } catch (h) {
446
- (n ?? (n = [])).push(h);
583
+ (r ??= []).push(h);
447
584
  }
448
585
  }
449
586
  e.disposed = !0;
450
587
  const o = e.runtimeActivation;
451
- e.runtimeActivation = void 0, (r = this._runtimeActivationProducers) == null || r.delete(e), ((c = this._runtimeActivationProducers) == null ? void 0 : c.size) === 0 && (this._runtimeActivationProducers = void 0);
588
+ e.runtimeActivation = void 0, this._runtimeActivationProducers?.delete(e), this._runtimeActivationProducers?.size === 0 && (this._runtimeActivationProducers = void 0);
452
589
  try {
453
- o == null || o();
454
- } catch (a) {
455
- (n ?? (n = [])).push(a);
590
+ o?.();
591
+ } catch (c) {
592
+ (r ??= []).push(c);
456
593
  }
457
594
  if (e.memberships !== void 0) {
458
595
  try {
459
596
  this._releaseCleanupList(e.memberships);
460
- } catch (a) {
461
- (n ?? (n = [])).push(a);
597
+ } catch (c) {
598
+ (r ??= []).push(c);
462
599
  }
463
600
  e.memberships = void 0;
464
601
  }
465
- if (e.alias !== void 0 && m.delete(e.alias), e.alias = void 0, e.subscribers !== void 0)
602
+ const u = e.source;
603
+ if (u !== void 0 && u !== e && R.delete(u), e.subscribers !== void 0)
466
604
  try {
467
605
  this._releaseWorkList(e.subscribers);
468
- } catch (a) {
469
- (n ?? (n = [])).push(a);
606
+ } catch (c) {
607
+ (r ??= []).push(c);
470
608
  } finally {
471
609
  e.subscribers = void 0;
472
610
  }
473
- e.activate = void 0, e.source = void 0, n !== void 0 && v(n, "[Raph] Runtime producer disposal failed.");
611
+ e.activate = void 0, e.source = void 0, r !== void 0 && _(r, "[Raph] Runtime producer disposal failed.");
474
612
  }
475
613
  _dispatchProducer(e, t, s = !0, i = e) {
476
- var o, r;
477
614
  this._dispatch(e.subscribers, t, i, s);
478
- const n = e.owner;
479
- if (f(n)) {
480
- this._dispatch((o = this._selfSubscribers) == null ? void 0 : o.get(n), t, i, s);
481
- for (const c of k(n))
482
- this._dispatch((r = this._subtreeSubscribers) == null ? void 0 : r.get(c), t, i, s);
483
- }
615
+ const r = e.owner;
616
+ if (d(r) && (this._dispatch(this._selfSubscribers?.get(r), t, i, s), this._subtreeSubscribers !== void 0))
617
+ for (const o of P(r))
618
+ this._dispatch(this._subtreeSubscribers?.get(o), t, i, s);
484
619
  e.includeRuntime && this._dispatch(this._runtimeSubscribers, t, i, s);
485
620
  }
486
- _dispatchProducerLazily(e, t, s, i, n, o) {
487
- var h;
488
- const r = e.owner;
621
+ _dispatchProducerLazily(e, t, s, i, r, o) {
622
+ const u = e.owner;
489
623
  let c;
490
- if (f(r)) {
491
- const l = (h = this._selfSubscribers) == null ? void 0 : h.get(r);
492
- (l == null ? void 0 : l.first) !== void 0 && (c = this._createProducerCause(e, t, s, i, o), this._dispatch(l, c, e, n));
493
- const _ = this._subtreeSubscribers;
494
- if (_ !== void 0)
495
- for (let p = r; p !== null; ) {
496
- const O = p.parent, g = _.get(p);
497
- (g == null ? void 0 : g.first) !== void 0 && (c ?? (c = this._createProducerCause(e, t, s, i, o)), this._dispatch(g, c, e, n)), p = O;
624
+ if (d(u)) {
625
+ const h = this._selfSubscribers?.get(u);
626
+ h?.first !== void 0 && (c = this._createProducerCause(e, t, s, i, o), this._dispatch(h, c, e, r));
627
+ const f = this._subtreeSubscribers;
628
+ if (f !== void 0)
629
+ for (let l = u; l !== null; ) {
630
+ const N = l.parent, O = f.get(l);
631
+ O?.first !== void 0 && (c ??= this._createProducerCause(e, t, s, i, o), this._dispatch(O, c, e, r)), l = N;
498
632
  }
499
633
  }
500
634
  const a = e.includeRuntime ? this._runtimeSubscribers : void 0;
501
- (a == null ? void 0 : a.first) !== void 0 && (c ?? (c = this._createProducerCause(e, t, s, i, o)), this._dispatch(a, c, e, n));
635
+ a?.first !== void 0 && (c ??= this._createProducerCause(e, t, s, i, o), this._dispatch(a, c, e, r));
502
636
  }
503
- _createProducerCause(e, t, s, i, n) {
504
- const o = ++e.revision, r = Object.freeze(n ? i === void 0 ? {
505
- kind: e.kind,
506
- source: e.source,
507
- sourceOwner: e.owner,
508
- revision: o,
509
- previous: t,
510
- value: s
511
- } : {
637
+ _createProducerCause(e, t, s, i, r) {
638
+ const o = ++e.revision, u = r ? i === void 0 ? y(e.kind, e.source, e.owner, o, t, s) : {
512
639
  kind: e.kind,
513
640
  source: e.source,
514
641
  sourceOwner: e.owner,
@@ -527,29 +654,28 @@ class V {
527
654
  sourceOwner: e.owner,
528
655
  revision: o,
529
656
  events: Object.freeze([...i])
530
- });
531
- return this._setTransientCause(e, r), r;
657
+ };
658
+ return this._setTransientCause(e, u), u;
532
659
  }
533
660
  _retainRuntimeSubscriber() {
534
- var s;
535
661
  if (this._runtimeSubscriberCount++, this._runtimeSubscriberCount !== 1)
536
662
  return;
537
663
  const e = [], t = [];
538
664
  try {
539
- for (const i of this._runtimeActivationProducers ?? [])
540
- i.disposed || i.runtimeActivation !== void 0 || (i.runtimeActivation = D((s = i.activate) == null ? void 0 : s.call(i)), e.push(i));
665
+ for (const s of this._runtimeActivationProducers ?? [])
666
+ s.disposed || s.runtimeActivation !== void 0 || (s.runtimeActivation = x(s.activate?.()), e.push(s));
541
667
  return;
542
- } catch (i) {
543
- t.push(i);
668
+ } catch (s) {
669
+ t.push(s);
544
670
  }
545
671
  this._runtimeSubscriberCount = 0;
546
- for (let i = e.length - 1; i >= 0; i--) {
547
- const n = e[i], o = n.runtimeActivation;
548
- n.runtimeActivation = void 0;
672
+ for (let s = e.length - 1; s >= 0; s--) {
673
+ const i = e[s], r = i.runtimeActivation;
674
+ i.runtimeActivation = void 0;
549
675
  try {
550
- o == null || o();
551
- } catch (r) {
552
- t.push(r);
676
+ r?.();
677
+ } catch (o) {
678
+ t.push(o);
553
679
  }
554
680
  }
555
681
  throw t.length === 1 ? t[0] : new AggregateError(t, "[Raph] Runtime granule activation failed and rollback was incomplete.");
@@ -563,46 +689,53 @@ class V {
563
689
  const s = t.runtimeActivation;
564
690
  t.runtimeActivation = void 0;
565
691
  try {
566
- s == null || s();
692
+ s?.();
567
693
  } catch (i) {
568
694
  e.push(i);
569
695
  }
570
696
  }
571
- v(e, "[Raph] Runtime granule activation cleanup failed.");
697
+ _(e, "[Raph] Runtime granule activation cleanup failed.");
572
698
  }
699
+ /**
700
+ * Учитывает одно фактическое implicit-ребро графа от producer к consumer
701
+ * owner и возвращает его точное снятие. Вызывается hook-ом onDependency
702
+ * producers с отдельной записью; Runtime signal этого hook не имеет, и его
703
+ * рёбра проверка reparent читает прямо из графа.
704
+ *
705
+ * @internal
706
+ */
573
707
  _linkImplicitDependency(e, t) {
574
708
  const s = e.owner, i = t;
575
- if (e.disposed || i.runtime !== this._runtime || !f(s) || !f(i) || s === i)
709
+ if (e.disposed || i.runtime !== this._runtime || !d(s) || !d(i) || s === i)
576
710
  return;
577
- const n = e.implicitConsumers ?? (e.implicitConsumers = /* @__PURE__ */ new Map());
578
- n.set(i, (n.get(i) ?? 0) + 1), (this._implicitProducers ?? (this._implicitProducers = /* @__PURE__ */ new Set())).add(e);
579
- let r = !0;
711
+ const r = e.implicitConsumers ??= /* @__PURE__ */ new Map();
712
+ r.set(i, (r.get(i) ?? 0) + 1), (this._implicitProducers ??= /* @__PURE__ */ new Set()).add(e);
713
+ let u = !0;
580
714
  return () => {
581
- var a, h, l;
582
- if (!r)
715
+ if (!u)
583
716
  return;
584
- r = !1;
585
- const c = (a = e.implicitConsumers) == null ? void 0 : a.get(i);
717
+ u = !1;
718
+ const c = e.implicitConsumers?.get(i);
586
719
  if (c !== void 0) {
587
720
  if (c > 1) {
588
721
  e.implicitConsumers.set(i, c - 1);
589
722
  return;
590
723
  }
591
- e.implicitConsumers.delete(i), e.implicitConsumers.size === 0 && (e.implicitConsumers = void 0, (h = this._implicitProducers) == null || h.delete(e), ((l = this._implicitProducers) == null ? void 0 : l.size) === 0 && (this._implicitProducers = void 0));
724
+ e.implicitConsumers.delete(i), e.implicitConsumers.size === 0 && (e.implicitConsumers = void 0, this._implicitProducers?.delete(e), this._implicitProducers?.size === 0 && (this._implicitProducers = void 0));
592
725
  }
593
726
  };
594
727
  }
595
- _subscribeOne(e, t, s, i, n, o) {
596
- if (t !== void 0 && !f(e))
728
+ _subscribeOne(e, t, s, i, r, o) {
729
+ if (t !== void 0 && !d(e))
597
730
  throw new TypeError("[Raph] watch include applies only to a bare RaphNode source.");
598
- if (e instanceof b) {
731
+ if (e instanceof p) {
599
732
  if (e._assertAlive(), this._assertRuntime(e.runtime), o.has(e))
600
733
  throw new TypeError("[Raph] Aggregate sources cannot contain a cycle.");
601
734
  o.add(e);
602
- const r = [];
735
+ const u = [];
603
736
  try {
604
737
  for (const c of e.sources)
605
- this._subscribeOne(c, void 0, s, r, n, o);
738
+ this._subscribeOne(c, void 0, s, u, r, o);
606
739
  i.push(e._linkSubscription((c) => {
607
740
  const a = [];
608
741
  if (c !== void 0)
@@ -611,21 +744,21 @@ class V {
611
744
  } catch (h) {
612
745
  a.push(h);
613
746
  }
614
- for (let h = r.length - 1; h >= 0; h--)
747
+ for (let h = u.length - 1; h >= 0; h--)
615
748
  try {
616
- r[h]();
617
- } catch (l) {
618
- a.push(l);
749
+ u[h]();
750
+ } catch (f) {
751
+ a.push(f);
619
752
  }
620
- v(a, "[Raph] Aggregate member subscription disposal failed.");
753
+ _(a, "[Raph] Aggregate member subscription disposal failed.");
621
754
  }));
622
755
  } catch (c) {
623
756
  const a = [];
624
- for (let h = r.length - 1; h >= 0; h--)
757
+ for (let h = u.length - 1; h >= 0; h--)
625
758
  try {
626
- r[h]();
627
- } catch (l) {
628
- a.push(l);
759
+ u[h]();
760
+ } catch (f) {
761
+ a.push(f);
629
762
  }
630
763
  throw o.delete(e), a.length !== 0 ? new AggregateError(
631
764
  [c, ...a],
@@ -635,50 +768,47 @@ class V {
635
768
  o.delete(e);
636
769
  return;
637
770
  }
638
- if (S(e)) {
639
- this._subscribeNode(e.source, e.include, s, i, n);
771
+ if (m(e)) {
772
+ this._subscribeNode(e.source, e.include, s, i, r);
640
773
  return;
641
774
  }
642
- if (f(e)) {
643
- this._subscribeNode(e, t ?? "self", s, i, n);
775
+ if (d(e)) {
776
+ this._subscribeNode(e, t ?? "self", s, i, r);
644
777
  return;
645
778
  }
646
- if (P(e)) {
647
- this._assertRuntime(e), i.push(x(n, e, () => {
648
- const r = this._runtimeSubscribers ?? (this._runtimeSubscribers = {}), c = { kind: "runtime", sink: s, source: e };
649
- this._appendWorkEdge(r, c);
779
+ if (g(e)) {
780
+ this._assertRuntime(e), i.push(C(r, e, () => {
781
+ const u = this._runtimeSubscribers ??= {}, c = { kind: "runtime", sink: s, source: e };
782
+ this._appendWorkEdge(u, c);
650
783
  try {
651
784
  this._retainRuntimeSubscriber();
652
785
  } catch (a) {
653
- throw c.source = void 0, this._detachWorkEdge(r, c), r.first === void 0 && (this._runtimeSubscribers = void 0), a;
786
+ throw c.source = void 0, this._detachWorkEdge(u, c), u.first === void 0 && (this._runtimeSubscribers = void 0), a;
654
787
  }
655
788
  return () => {
656
- var a;
657
- c.source !== void 0 && (c.source = void 0, this._detachWorkEdge(this._runtimeSubscribers, c), ((a = this._runtimeSubscribers) == null ? void 0 : a.first) === void 0 && (this._runtimeSubscribers = void 0), this._releaseRuntimeSubscriber());
789
+ c.source !== void 0 && (c.source = void 0, this._detachWorkEdge(this._runtimeSubscribers, c), this._runtimeSubscribers?.first === void 0 && (this._runtimeSubscribers = void 0), this._releaseRuntimeSubscriber());
658
790
  };
659
791
  }));
660
792
  return;
661
793
  }
662
- if (w(e)) {
663
- const r = m.get(e);
664
- if (r !== void 0) {
665
- if (this._assertRuntime(r.runtime), r.disposed)
666
- throw new A("[Raph] Producer is disposed.");
667
- i.push(x(n, r, () => {
668
- var h;
669
- const c = r.subscribers ?? (r.subscribers = {}), a = { kind: "producer", sink: s, source: r };
794
+ if (b(e)) {
795
+ const u = S(e);
796
+ if (u !== void 0) {
797
+ if (this._assertRuntime(u.runtime), u.disposed)
798
+ throw new w("[Raph] Producer is disposed.");
799
+ i.push(C(r, u, () => {
800
+ const c = u.subscribers ??= {}, a = { kind: "producer", sink: s, source: u };
670
801
  this._appendWorkEdge(c, a);
671
802
  try {
672
- a.activationRelease = D((h = r.activate) == null ? void 0 : h.call(r));
673
- } catch (l) {
674
- throw a.source = void 0, this._detachWorkEdge(c, a), c.first === void 0 && (r.subscribers = void 0), l;
803
+ a.activationRelease = x(u.activate?.());
804
+ } catch (h) {
805
+ throw a.source = void 0, this._detachWorkEdge(c, a), c.first === void 0 && (u.subscribers = void 0), h;
675
806
  }
676
807
  return () => {
677
- var p;
678
- const l = a.activationRelease;
808
+ const h = a.activationRelease;
679
809
  a.activationRelease = void 0;
680
- const _ = a.source;
681
- E(_) && (a.source = void 0, this._detachWorkEdge(_.subscribers, a), ((p = _.subscribers) == null ? void 0 : p.first) === void 0 && (_.subscribers = void 0)), l == null || l();
810
+ const f = a.source;
811
+ f instanceof v && (a.source = void 0, this._detachWorkEdge(f.subscribers, a), f.subscribers?.first === void 0 && (f.subscribers = void 0)), h?.();
682
812
  };
683
813
  }));
684
814
  return;
@@ -686,14 +816,14 @@ class V {
686
816
  }
687
817
  throw new TypeError("[Raph] Unsupported or ownerless granular watch source.");
688
818
  }
689
- _subscribeNode(e, t, s, i, n) {
819
+ _subscribeNode(e, t, s, i, r) {
690
820
  if (this._assertRuntime(e.runtime), e._assertAlive(), t !== "self" && t !== "subtree")
691
821
  throw new TypeError(`[Raph] Unsupported node include mode "${String(t)}".`);
692
822
  const o = t === "self" ? e : e._subtreeSourceIdentity;
693
- i.push(x(n, o, () => {
694
- const r = t === "self" ? this._selfSubscribers ?? (this._selfSubscribers = /* @__PURE__ */ new Map()) : this._subtreeSubscribers ?? (this._subtreeSubscribers = /* @__PURE__ */ new Map());
695
- let c = r.get(e);
696
- c === void 0 && (c = {}, r.set(e, c));
823
+ i.push(C(r, o, () => {
824
+ const u = t === "self" ? this._selfSubscribers ??= /* @__PURE__ */ new Map() : this._subtreeSubscribers ??= /* @__PURE__ */ new Map();
825
+ let c = u.get(e);
826
+ c === void 0 && (c = {}, u.set(e, c));
697
827
  const a = { kind: t, sink: s, source: e };
698
828
  return this._appendWorkEdge(c, a), this._createNodeEdgeRelease(a);
699
829
  }));
@@ -701,132 +831,131 @@ class V {
701
831
  _createNodeEdgeRelease(e) {
702
832
  return () => {
703
833
  const t = e.source;
704
- if (!f(t))
834
+ if (!d(t))
705
835
  return;
706
836
  e.source = void 0;
707
- const s = e.kind === "self" ? this._selfSubscribers : this._subtreeSubscribers, i = s == null ? void 0 : s.get(t);
708
- this._detachWorkEdge(i, e), (i == null ? void 0 : i.first) === void 0 && (s == null || s.delete(t), (s == null ? void 0 : s.size) === 0 && (e.kind === "self" ? this._selfSubscribers = void 0 : this._subtreeSubscribers = void 0));
837
+ const s = e.kind === "self" ? this._selfSubscribers : this._subtreeSubscribers, i = s?.get(t);
838
+ this._detachWorkEdge(i, e), i?.first === void 0 && (s?.delete(t), s?.size === 0 && (e.kind === "self" ? this._selfSubscribers = void 0 : this._subtreeSubscribers = void 0));
709
839
  };
710
840
  }
711
841
  _linkSourceCleanup(e, t) {
712
- const s = I(e);
842
+ const s = U(e);
713
843
  if (s === void 0)
714
844
  return;
715
845
  const i = { cleanup: t, source: s };
716
- if (E(s)) {
717
- const n = s.memberships ?? (s.memberships = {});
718
- W(n, i);
719
- } else if (s instanceof b)
846
+ if (s instanceof v) {
847
+ const r = s.memberships ??= {};
848
+ z(r, i);
849
+ } else if (s instanceof p)
720
850
  s._linkDependent(i);
721
851
  else {
722
- const n = this._nodeMemberships ?? (this._nodeMemberships = /* @__PURE__ */ new Map());
723
- let o = n.get(s);
724
- o === void 0 && (o = {}, n.set(s, o)), W(o, i);
852
+ const r = this._nodeMemberships ??= /* @__PURE__ */ new Map();
853
+ let o = r.get(s);
854
+ o === void 0 && (o = {}, r.set(s, o)), z(o, i);
725
855
  }
726
856
  return () => this._detachCleanupEdge(i);
727
857
  }
728
858
  _detachCleanupEdge(e) {
729
- var i, n, o, r;
730
859
  const t = e.source;
731
860
  if (t === void 0)
732
861
  return;
733
- if (e.source = void 0, e.cleanup = void 0, E(t)) {
734
- N(t.memberships, e), ((i = t.memberships) == null ? void 0 : i.first) === void 0 && (t.memberships = void 0);
862
+ if (e.source = void 0, e.cleanup = void 0, t instanceof v) {
863
+ M(t.memberships, e), t.memberships?.first === void 0 && (t.memberships = void 0);
735
864
  return;
736
865
  }
737
- if (t instanceof b) {
866
+ if (t instanceof p) {
738
867
  t._detachDependent(e);
739
868
  return;
740
869
  }
741
- const s = (n = this._nodeMemberships) == null ? void 0 : n.get(t);
742
- N(s, e), (s == null ? void 0 : s.first) === void 0 && ((o = this._nodeMemberships) == null || o.delete(t), ((r = this._nodeMemberships) == null ? void 0 : r.size) === 0 && (this._nodeMemberships = void 0));
870
+ const s = this._nodeMemberships?.get(t);
871
+ M(s, e), s?.first === void 0 && (this._nodeMemberships?.delete(t), this._nodeMemberships?.size === 0 && (this._nodeMemberships = void 0));
743
872
  }
744
873
  _releaseCleanupList(e, t = !0) {
745
874
  let s = e.first;
746
875
  e.first = e.last = void 0;
747
876
  const i = [];
748
877
  for (; s !== void 0; ) {
749
- const n = s.next, o = s.cleanup;
878
+ const r = s.next, o = s.cleanup;
750
879
  if (s.source = void 0, s.cleanup = void 0, s.previous = s.next = void 0, t)
751
880
  try {
752
- o == null || o();
753
- } catch (r) {
754
- i.push(r);
881
+ o?.();
882
+ } catch (u) {
883
+ i.push(u);
755
884
  }
756
- s = n;
885
+ s = r;
757
886
  }
758
- v(i, "[Raph] Aggregate membership cleanup failed.");
887
+ _(i, "[Raph] Aggregate membership cleanup failed.");
759
888
  }
760
889
  _validateAggregateSources(e, t) {
761
890
  for (const s of e) {
762
891
  if (Array.isArray(s))
763
892
  throw new TypeError("[Raph] Nested source arrays are not supported; create a named aggregate.");
764
- if (s instanceof b) {
893
+ if (s instanceof p) {
765
894
  if (s._assertAlive(), this._assertRuntime(s.runtime), t.has(s))
766
895
  throw new TypeError("[Raph] Aggregate sources cannot contain a cycle.");
767
896
  t.add(s), this._validateAggregateSources(s.sources, t), t.delete(s);
768
- } else if (S(s)) {
897
+ } else if (m(s)) {
769
898
  if (this._assertRuntime(s.source.runtime), s.source._assertAlive(), s.include !== "self" && s.include !== "subtree")
770
899
  throw new TypeError(`[Raph] Unsupported node include mode "${String(s.include)}".`);
771
- } else if (f(s))
900
+ } else if (d(s))
772
901
  this._assertRuntime(s.runtime), s._assertAlive();
773
- else if (P(s))
902
+ else if (g(s))
774
903
  this._assertRuntime(s);
775
- else if (w(s)) {
776
- const i = m.get(s);
904
+ else if (b(s)) {
905
+ const i = S(s);
777
906
  if (i === void 0 || i.disposed)
778
- throw new A("[Raph] Aggregate producer is disposed or ownerless.");
907
+ throw new w("[Raph] Aggregate producer is disposed or ownerless.");
779
908
  this._assertRuntime(i.runtime);
780
909
  } else
781
910
  throw new TypeError("[Raph] Unsupported aggregate source.");
782
911
  }
783
912
  }
784
913
  _assertSourceVisibleTo(e, t, s) {
785
- if (t instanceof b) {
914
+ if (t instanceof p) {
786
915
  if (this._assertProvisionalOwnerAccess(e, t.owner), s.has(t))
787
916
  return;
788
917
  s.add(t);
789
- for (const n of t.sources)
790
- this._assertSourceVisibleTo(e, n, s);
918
+ for (const r of t.sources)
919
+ this._assertSourceVisibleTo(e, r, s);
791
920
  s.delete(t);
792
921
  return;
793
922
  }
794
- if (S(t)) {
923
+ if (m(t)) {
795
924
  this._assertProvisionalOwnerAccess(e, t.source);
796
925
  return;
797
926
  }
798
- if (f(t)) {
927
+ if (d(t)) {
799
928
  this._assertProvisionalOwnerAccess(e, t);
800
929
  return;
801
930
  }
802
- if (P(t) || !w(t))
931
+ if (g(t) || !b(t))
803
932
  return;
804
- const i = m.get(t);
933
+ const i = S(t);
805
934
  i !== void 0 && this._assertProvisionalOwnerAccess(e, i.owner);
806
935
  }
807
936
  _assertProvisionalOwnerAccess(e, t) {
808
- if (!(!f(t) || t._isPublished()) && !(f(e) && !e._isPublished() && T(e) === T(t)))
937
+ if (!(!d(t) || t._isPublished()) && !(d(e) && !e._isPublished() && D(e) === D(t)))
809
938
  throw new Error(
810
939
  `[Raph] Owner "${e.id}" cannot subscribe to provisional source owner "${t.id}".`
811
940
  );
812
941
  }
813
942
  _dispatch(e, t, s, i = !0) {
814
- let n = e == null ? void 0 : e.first;
815
- if (n === void 0)
943
+ let r = e?.first;
944
+ if (r === void 0)
816
945
  return;
817
946
  const o = e.last;
818
947
  this._dispatchDepth++;
819
948
  try {
820
- for (; n !== void 0; ) {
821
- const r = n.next;
822
- if (n.source !== void 0 && n.sink(t, s, i), n === o)
949
+ for (; r !== void 0; ) {
950
+ const u = r.next;
951
+ if (r.source !== void 0 && r.sink(t, s, i), r === o)
823
952
  break;
824
- n = r;
953
+ r = u;
825
954
  }
826
955
  } finally {
827
956
  if (--this._dispatchDepth === 0 && this._detachedEdges !== void 0) {
828
- for (const r of this._detachedEdges)
829
- r.previous = r.next = void 0;
957
+ for (const u of this._detachedEdges)
958
+ u.previous = u.next = void 0;
830
959
  this._detachedEdges = void 0;
831
960
  }
832
961
  }
@@ -835,64 +964,62 @@ class V {
835
964
  t.previous = e.last, e.last === void 0 ? e.first = t : e.last.next = t, e.last = t;
836
965
  }
837
966
  _detachWorkEdge(e, t) {
838
- e !== void 0 && (t.previous === void 0 ? e.first = t.next : t.previous.next = t.next, t.next === void 0 ? e.last = t.previous : t.next.previous = t.previous, this._dispatchDepth === 0 ? t.previous = t.next = void 0 : (this._detachedEdges ?? (this._detachedEdges = [])).push(t));
967
+ e !== void 0 && (t.previous === void 0 ? e.first = t.next : t.previous.next = t.next, t.next === void 0 ? e.last = t.previous : t.next.previous = t.previous, this._dispatchDepth === 0 ? t.previous = t.next = void 0 : (this._detachedEdges ??= []).push(t));
839
968
  }
840
969
  _releaseWorkList(e) {
841
970
  let t = e.first;
842
971
  const s = [];
843
972
  for (; t !== void 0; ) {
844
- const i = t.next, n = t.activationRelease;
973
+ const i = t.next, r = t.activationRelease;
845
974
  t.activationRelease = void 0, t.source = void 0, this._detachWorkEdge(e, t);
846
975
  try {
847
- n == null || n();
976
+ r?.();
848
977
  } catch (o) {
849
978
  s.push(o);
850
979
  }
851
980
  t = i;
852
981
  }
853
- v(s, "[Raph] Granular source activation cleanup failed.");
982
+ _(s, "[Raph] Granular source activation cleanup failed.");
854
983
  }
855
984
  _releaseGranule(e, t) {
856
- const s = e == null ? void 0 : e.get(t);
985
+ const s = e?.get(t);
857
986
  s !== void 0 && (e.delete(t), this._releaseWorkList(s), e.size === 0 && (e === this._selfSubscribers && (this._selfSubscribers = void 0), e === this._subtreeSubscribers && (this._subtreeSubscribers = void 0)));
858
987
  }
859
988
  _setTransientCause(e, t) {
860
989
  e.lastCause === void 0 && (e.transientNext = this._transientProducers, this._transientProducers = e), e.lastCause = t;
861
990
  }
862
991
  _producerHasDemand(e) {
863
- var s, i, n, o, r;
864
- if (f(e.owner) && !e.owner._isPublished())
992
+ if (d(e.owner) && !e.owner._isPublished())
865
993
  return !1;
866
- if (((s = e.subscribers) == null ? void 0 : s.first) !== void 0 || e.includeRuntime && ((i = this._runtimeSubscribers) == null ? void 0 : i.first) !== void 0)
994
+ if (e.subscribers?.first !== void 0 || e.includeRuntime && this._runtimeSubscribers?.first !== void 0)
867
995
  return !0;
868
996
  const t = e.owner;
869
- if (!f(t))
997
+ if (!d(t))
870
998
  return !1;
871
- if (((o = (n = this._selfSubscribers) == null ? void 0 : n.get(t)) == null ? void 0 : o.first) !== void 0)
999
+ if (this._selfSubscribers?.get(t)?.first !== void 0)
872
1000
  return !0;
873
1001
  if (this._subtreeSubscribers === void 0)
874
1002
  return !1;
875
- for (const c of k(t))
876
- if (((r = this._subtreeSubscribers.get(c)) == null ? void 0 : r.first) !== void 0)
1003
+ for (const s of P(t))
1004
+ if (this._subtreeSubscribers.get(s)?.first !== void 0)
877
1005
  return !0;
878
1006
  return !1;
879
1007
  }
880
1008
  _nodeTouchKey(e) {
881
- const t = this._nodeTouchKeys ?? (this._nodeTouchKeys = /* @__PURE__ */ new WeakMap());
1009
+ const t = this._nodeTouchKeys ??= /* @__PURE__ */ new WeakMap();
882
1010
  let s = t.get(e);
883
1011
  return s === void 0 && (s = Object.freeze({}), t.set(e, s)), s;
884
1012
  }
885
1013
  _nodeHasDemand(e, t, s) {
886
- var i, n, o, r, c;
887
- if (((i = this._runtimeSubscribers) == null ? void 0 : i.first) !== void 0 || ((o = (n = this._selfSubscribers) == null ? void 0 : n.get(e)) == null ? void 0 : o.first) !== void 0)
1014
+ if (this._runtimeSubscribers?.first !== void 0 || this._selfSubscribers?.get(e)?.first !== void 0)
888
1015
  return !0;
889
1016
  if (this._subtreeSubscribers === void 0)
890
1017
  return !1;
891
- for (const a of t)
892
- if (((r = this._subtreeSubscribers.get(a)) == null ? void 0 : r.first) !== void 0)
1018
+ for (const i of t)
1019
+ if (this._subtreeSubscribers.get(i)?.first !== void 0)
893
1020
  return !0;
894
- for (const a of s)
895
- if (((c = this._subtreeSubscribers.get(a)) == null ? void 0 : c.first) !== void 0)
1021
+ for (const i of s)
1022
+ if (this._subtreeSubscribers.get(i)?.first !== void 0)
896
1023
  return !0;
897
1024
  return !1;
898
1025
  }
@@ -901,95 +1028,130 @@ class V {
901
1028
  }
902
1029
  _assertRuntime(e) {
903
1030
  if (e !== this._runtime)
904
- throw new H("[Raph] Granular source belongs to another runtime.");
1031
+ throw new j("[Raph] Granular source belongs to another runtime.");
905
1032
  }
906
1033
  _assertAlive() {
907
1034
  if (this._disposed)
908
- throw new A("[Raph] Work graph is disposed.");
1035
+ throw new w("[Raph] Work graph is disposed.");
909
1036
  }
910
1037
  }
911
- function T(u) {
912
- let e = u;
1038
+ function D(n) {
1039
+ let e = n;
913
1040
  for (; e.parent !== null && !e.parent._isPublished(); )
914
1041
  e = e.parent;
915
1042
  return e;
916
1043
  }
917
- function k(u) {
1044
+ function P(n) {
918
1045
  const e = [];
919
- for (let t = u; t !== null; t = t.parent)
1046
+ for (let t = n; t !== null; t = t.parent)
920
1047
  e.push(t);
921
1048
  return e;
922
1049
  }
923
- function j(u, e) {
924
- for (let t = u; t !== null; t = t.parent)
1050
+ function E(n, e) {
1051
+ for (let t = n; t !== null; t = t.parent)
925
1052
  if (t === e)
926
1053
  return !0;
927
1054
  return !1;
928
1055
  }
929
- function K(u, e) {
1056
+ function L(n, e) {
930
1057
  for (let t = e; t !== null; t = t.parent)
931
- if (t === u)
1058
+ if (t === n)
932
1059
  return !0;
933
1060
  return !1;
934
1061
  }
935
- function F(u) {
936
- return Object.freeze(u.map((e) => S(e) ? Object.freeze({ source: e.source, include: e.include }) : e));
1062
+ function I(n, e) {
1063
+ return d(n) && E(n, e);
1064
+ }
1065
+ function $(n, e) {
1066
+ let t = 0;
1067
+ for (let o = n.parent; o !== null; o = o.parent)
1068
+ t++;
1069
+ let s = 0;
1070
+ for (let o = e.parent; o !== null; o = o.parent)
1071
+ s++;
1072
+ let i = n, r = e;
1073
+ for (; t > s; t--)
1074
+ i = i.parent;
1075
+ for (; s > t; s--)
1076
+ r = r.parent;
1077
+ for (; i !== r; )
1078
+ i = i.parent, r = r.parent;
1079
+ return i;
1080
+ }
1081
+ function T(n, e, t) {
1082
+ throw new Error(
1083
+ `[Raph] Cannot reparent "${n.id}": implicit dependency from "${e.id}" to "${t.id}" would become invalid; use watch().`
1084
+ );
1085
+ }
1086
+ function H(n) {
1087
+ return Object.freeze(n.map((e) => m(e) ? Object.freeze({ source: e.source, include: e.include }) : e));
1088
+ }
1089
+ G._valueCauseShapeAnchor = y(
1090
+ "producer",
1091
+ void 0,
1092
+ void 0,
1093
+ 0,
1094
+ void 0,
1095
+ void 0
1096
+ );
1097
+ function y(n, e, t, s, i, r) {
1098
+ return { kind: n, source: e, sourceOwner: t, revision: s, previous: i, value: r };
937
1099
  }
938
- function L(u) {
939
- return u instanceof b ? u : S(u) ? u.source : f(u) || P(u) ? u : w(u) ? m.get(u) : void 0;
1100
+ function W(n) {
1101
+ return n instanceof p ? n : m(n) ? n.source : d(n) || g(n) ? n : b(n) ? S(n) : void 0;
940
1102
  }
941
- function I(u) {
942
- if (u instanceof b)
943
- return u;
944
- if (S(u))
945
- return u.source;
946
- if (f(u))
947
- return u;
948
- if (!P(u))
949
- return w(u) ? m.get(u) : void 0;
1103
+ function U(n) {
1104
+ if (n instanceof p)
1105
+ return n;
1106
+ if (m(n))
1107
+ return n.source;
1108
+ if (d(n))
1109
+ return n;
1110
+ if (!g(n))
1111
+ return b(n) ? S(n) : void 0;
950
1112
  }
951
- function W(u, e) {
952
- e.previous = u.last, u.last === void 0 ? u.first = e : u.last.next = e, u.last = e;
1113
+ function z(n, e) {
1114
+ e.previous = n.last, n.last === void 0 ? n.first = e : n.last.next = e, n.last = e;
953
1115
  }
954
- function Y(u) {
955
- var e;
956
- (e = u.aggregate) == null || e._detachSubscription(u);
1116
+ function K(n) {
1117
+ n.aggregate?._detachSubscription(n);
957
1118
  }
958
- function N(u, e) {
959
- u !== void 0 && (e.previous === void 0 ? u.first = e.next : e.previous.next = e.next, e.next === void 0 ? u.last = e.previous : e.next.previous = e.previous, e.previous = e.next = void 0);
1119
+ function M(n, e) {
1120
+ n !== void 0 && (e.previous === void 0 ? n.first = e.next : e.previous.next = e.next, e.next === void 0 ? n.last = e.previous : e.next.previous = e.previous, e.previous = e.next = void 0);
960
1121
  }
961
- function x(u, e, t) {
962
- let s = u.get(e);
963
- s === void 0 && (s = { count: 0, dispose: t() }, u.set(e, s)), s.count++;
1122
+ function C(n, e, t) {
1123
+ let s = n.get(e);
1124
+ s === void 0 && (s = { count: 0, dispose: t() }, n.set(e, s)), s.count++;
964
1125
  let i = !0;
965
1126
  return () => {
966
1127
  if (!i || (i = !1, --s.count !== 0))
967
1128
  return;
968
- const n = s.dispose;
969
- s.dispose = q, n();
1129
+ const r = s.dispose;
1130
+ s.dispose = F, r();
970
1131
  };
971
1132
  }
972
- function q() {
1133
+ function F() {
973
1134
  }
974
- function D(u) {
975
- return typeof u == "function" ? u : void 0;
1135
+ function x(n) {
1136
+ return typeof n == "function" ? n : void 0;
976
1137
  }
977
- function E(u) {
978
- return typeof u == "object" && u !== null && u[G] === !0;
1138
+ function S(n) {
1139
+ return n instanceof v ? n.source === n ? n : void 0 : R.get(n);
979
1140
  }
980
- function S(u) {
981
- return w(u) && "source" in u && f(u.source) && "include" in u;
1141
+ function m(n) {
1142
+ return b(n) && "source" in n && d(n.source) && "include" in n;
982
1143
  }
983
- function f(u) {
984
- return w(u) && "_subtreeSourceIdentity" in u && "runtime" in u && "children" in u;
1144
+ function d(n) {
1145
+ return b(n) && n._isNode === !0;
985
1146
  }
986
- function P(u) {
987
- return w(u) && "rootScope" in u && "definePhases" in u && "configuration" in u;
1147
+ function g(n) {
1148
+ return b(n) && "rootScope" in n && "definePhases" in n && "configuration" in n;
988
1149
  }
989
- function w(u) {
990
- return typeof u == "object" && u !== null;
1150
+ function b(n) {
1151
+ return typeof n == "object" && n !== null;
991
1152
  }
992
1153
  export {
993
- b as RaphAggregate,
994
- V as RaphWorkGraph
1154
+ p as RaphAggregate,
1155
+ v as RaphProducer,
1156
+ G as RaphWorkGraph
995
1157
  };