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

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 (127) hide show
  1. package/README.md +100 -0
  2. package/dist/api/Raph.d.ts +15 -15
  3. package/dist/api/RaphFacadeSession.d.ts +4 -4
  4. package/dist/api/RaphReactivityInstance.d.ts +4 -4
  5. package/dist/api/types.d.ts +11 -11
  6. package/dist/compact.cjs +1 -0
  7. package/dist/compact.js +4 -0
  8. package/dist/debug/reactivity/engine-core.cjs +1 -0
  9. package/dist/debug/reactivity/engine-core.js +1760 -0
  10. package/dist/debug/reactivity/engine.cjs +1 -1
  11. package/dist/debug/reactivity/engine.js +25 -1689
  12. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  13. package/dist/debug/reactivity/reactive-object.js +604 -167
  14. package/dist/debug/runtime/RaphCompactExecutionRuntime.cjs +1 -0
  15. package/dist/debug/runtime/RaphCompactExecutionRuntime.js +9 -0
  16. package/dist/debug/runtime/RaphExecutionRuntime.cjs +1 -0
  17. package/dist/debug/runtime/RaphExecutionRuntime.js +11 -0
  18. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  19. package/dist/debug/runtime/RaphRuntime.js +115 -1176
  20. package/dist/debug/runtime/RaphRuntimeBase.cjs +1 -0
  21. package/dist/debug/runtime/RaphRuntimeBase.js +941 -0
  22. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  23. package/dist/debug/runtime/diagnostics/RaphDebug.js +72 -66
  24. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  25. package/dist/debug/runtime/ownership/RaphNode.js +11 -0
  26. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  27. package/dist/debug/runtime/ownership/RaphScope.js +12 -12
  28. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  29. package/dist/debug/runtime/phases/RaphPhasePipeline.js +361 -242
  30. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -1
  31. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +23 -22
  32. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -1
  33. package/dist/debug/runtime/reactivity/RaphSelector.js +111 -90
  34. package/dist/debug/runtime/reactivity/RuntimeObjectSupport.cjs +1 -0
  35. package/dist/debug/runtime/reactivity/RuntimeObjectSupport.js +11 -0
  36. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  37. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +118 -103
  38. package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.cjs +1 -0
  39. package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.js +12 -0
  40. package/dist/entrypoints/compact.d.ts +2 -0
  41. package/dist/entrypoints/execution.d.ts +2 -0
  42. package/dist/entrypoints/machine-testing.d.ts +2 -2
  43. package/dist/entrypoints/machine.d.ts +5 -5
  44. package/dist/entrypoints/observable.d.ts +4 -0
  45. package/dist/entrypoints/path.d.ts +14 -14
  46. package/dist/entrypoints/reactivity.d.ts +1 -1
  47. package/dist/entrypoints/runtime.d.ts +19 -18
  48. package/dist/execution.cjs +1 -0
  49. package/dist/execution.js +4 -0
  50. package/dist/index.cjs +1 -1
  51. package/dist/index.js +23 -21
  52. package/dist/machine/compiler.d.ts +1 -1
  53. package/dist/machine/core.d.ts +2 -2
  54. package/dist/machine/persistence.d.ts +1 -1
  55. package/dist/machine/runtime.d.ts +3 -3
  56. package/dist/machine/testing.d.ts +1 -1
  57. package/dist/machine/types.d.ts +3 -3
  58. package/dist/main.d.ts +19 -19
  59. package/dist/observable/buffer.d.ts +6 -0
  60. package/dist/observable/class-admin.d.ts +63 -0
  61. package/dist/observable/class-plan.d.ts +46 -0
  62. package/dist/observable/classes.d.ts +10 -0
  63. package/dist/observable/context.d.ts +73 -0
  64. package/dist/observable/native.d.ts +2 -0
  65. package/dist/observable/observable.d.ts +13 -0
  66. package/dist/observable/types.d.ts +60 -0
  67. package/dist/observable.cjs +1 -0
  68. package/dist/observable.js +1187 -0
  69. package/dist/path/DataPath.d.ts +2 -2
  70. package/dist/path/PathRouter.d.ts +1 -1
  71. package/dist/path/RaphKernel.d.ts +6 -6
  72. package/dist/path/data-path.types.d.ts +1 -1
  73. package/dist/path/data-path.utils.d.ts +2 -2
  74. package/dist/path/derived/DerivedRegistry.d.ts +3 -3
  75. package/dist/path/derived/RaphDerivedHandle.d.ts +3 -3
  76. package/dist/path/derived/derived-collection.types.d.ts +1 -1
  77. package/dist/path/derived/derived-collection.utils.d.ts +3 -3
  78. package/dist/path/derived/derived-strategy.utils.d.ts +1 -1
  79. package/dist/path/meta/MetaController.d.ts +5 -5
  80. package/dist/path/meta/RaphMeta.d.ts +3 -3
  81. package/dist/path/meta/RaphMetaStore.d.ts +1 -1
  82. package/dist/path/meta/meta.types.d.ts +2 -2
  83. package/dist/path/path.types.d.ts +2 -2
  84. package/dist/path/pathSegmentKey.d.ts +1 -1
  85. package/dist/path/storage/AdapterPathStore.d.ts +2 -2
  86. package/dist/path/storage/DefaultDataAdapter.d.ts +2 -2
  87. package/dist/path/storage/PathEventHub.d.ts +1 -1
  88. package/dist/path/storage/PathStore.d.ts +2 -2
  89. package/dist/path/storage/data-adapter.types.d.ts +1 -1
  90. package/dist/raph.cjs +1 -1
  91. package/dist/raph.js +23 -21
  92. package/dist/reactivity/engine-core.d.ts +600 -0
  93. package/dist/reactivity/engine.d.ts +6 -550
  94. package/dist/reactivity/reactive-object.d.ts +143 -2
  95. package/dist/reactivity/scope.d.ts +7 -6
  96. package/dist/reactivity/types.d.ts +9 -12
  97. package/dist/reactivity/watch.d.ts +1 -1
  98. package/dist/runtime/RaphCompactExecutionRuntime.d.ts +7 -0
  99. package/dist/runtime/RaphExecutionRuntime.d.ts +6 -0
  100. package/dist/runtime/RaphRuntime.d.ts +19 -403
  101. package/dist/runtime/RaphRuntimeBase.d.ts +194 -0
  102. package/dist/runtime/diagnostics/RaphDebug.d.ts +8 -5
  103. package/dist/runtime/errors.d.ts +1 -1
  104. package/dist/runtime/ownership/RaphEffectScope.d.ts +13 -12
  105. package/dist/runtime/ownership/RaphNode.d.ts +28 -21
  106. package/dist/runtime/ownership/RaphScope.d.ts +32 -19
  107. package/dist/runtime/ownership/parent-graph.types.d.ts +1 -1
  108. package/dist/runtime/ownership/parentGraph.d.ts +2 -2
  109. package/dist/runtime/phases/RaphFrameLoop.d.ts +1 -1
  110. package/dist/runtime/phases/RaphPhasePipeline.d.ts +80 -29
  111. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +21 -21
  112. package/dist/runtime/phases/RaphPhaseWatch.d.ts +3 -3
  113. package/dist/runtime/phases/orderPhaseTasks.d.ts +4 -2
  114. package/dist/runtime/phases/phase.types.d.ts +36 -35
  115. package/dist/runtime/reactivity/PathHandle.d.ts +5 -5
  116. package/dist/runtime/reactivity/RaphMetaSource.d.ts +7 -7
  117. package/dist/runtime/reactivity/RaphSelector.d.ts +27 -6
  118. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +40 -39
  119. package/dist/runtime/reactivity/RuntimeObjectSupport.d.ts +9 -0
  120. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +27 -19
  121. package/dist/runtime/reactivity/RuntimeSelectorSupport.d.ts +10 -0
  122. package/dist/runtime/reactivity/RuntimeWatch.d.ts +1 -1
  123. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +1 -1
  124. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +3 -3
  125. package/dist/runtime.cjs +1 -1
  126. package/dist/runtime.js +13 -11
  127. package/package.json +22 -62
@@ -0,0 +1,941 @@
1
+ import { RaphDisposedError as O, RaphCrossRuntimeError as g, RaphActionError as L } from "./errors.js";
2
+ import { parentGraph as j } from "./ownership/parentGraph.js";
3
+ import { RaphNode as F, createProvisionalNode as M } from "./ownership/RaphNode.js";
4
+ import { RaphScope as T } from "./ownership/RaphScope.js";
5
+ import { throwDisposalErrors as R } from "./ownership/throwDisposalErrors.js";
6
+ import { RaphSchedulerType as f } from "./phases/phase.types.js";
7
+ import { RaphFrameLoop as $ } from "./phases/RaphFrameLoop.js";
8
+ import { RaphPhasePipeline as U } from "./phases/RaphPhasePipeline.js";
9
+ import { RaphPhaseTaskRecord as K, TASK_ACTIVE as x, TASK_TASKLESS as z, GROUP_NODES as D, TASK_PENDING as C, TASK_REQUESTED as V } from "./phases/RaphPhaseTaskRecord.js";
10
+ import { createPhaseWatch as Y } from "./phases/RaphPhaseWatch.js";
11
+ import { enqueueSweeper as H, dequeueSweeper as I, postponeFirstSweeper as Q } from "./reactivity/disposal-sweep.utils.js";
12
+ import { RaphWorkGraph as X } from "./reactivity/RaphWorkGraph.js";
13
+ import { RuntimeReactivity as J } from "./reactivity/RuntimeReactivity.js";
14
+ let Z = 0;
15
+ function ve(_) {
16
+ const e = _.id ?? `runtime-${Z++}`, t = _.adaptiveDependencyIndex ?? !1, s = _.enforceActions ?? !1, i = _.scheduler ?? f.Sync;
17
+ if (!ie(i))
18
+ throw new Error(`[Raph] Unsupported scheduler "${String(i)}".`);
19
+ return Object.freeze({ id: e, adaptiveDependencyIndex: t, enforceActions: s, scheduler: i });
20
+ }
21
+ const m = Object.freeze({}), N = 2 ** 32 - 1 - D, k = /* @__PURE__ */ new Set();
22
+ let P = !1;
23
+ function B() {
24
+ let _ = 0, e;
25
+ for (const s of k) {
26
+ const i = s.deref();
27
+ if (i === void 0 || i.disposed) {
28
+ k.delete(s);
29
+ continue;
30
+ }
31
+ _++, e = i;
32
+ }
33
+ const t = _ > 1;
34
+ if (t !== P) {
35
+ if (!t && e !== void 0) {
36
+ const s = e._getReactivity();
37
+ if (s.getActiveOwner() !== void 0 || s.getActiveConsumerOwner() !== void 0)
38
+ return;
39
+ }
40
+ P = t;
41
+ for (const s of k)
42
+ s.deref()?._applyObjectReadPolicy(t);
43
+ }
44
+ }
45
+ class W {
46
+ reactiveObjects;
47
+ selectors;
48
+ _reactiveObjects;
49
+ mode = "runtime";
50
+ configuration;
51
+ rootScope;
52
+ root;
53
+ frameTick;
54
+ _reactivity;
55
+ _signalLifecycle;
56
+ _workGraph;
57
+ _frameTickSignal;
58
+ _phases;
59
+ _frameLoop;
60
+ _debugController;
61
+ _parentGraph;
62
+ _topOwners = /* @__PURE__ */ new Set();
63
+ _ownerRegistrations = 0;
64
+ _ownersReleased = !1;
65
+ _batchDepth = 0;
66
+ _mutationDepth = 0;
67
+ _kernelBatchDepth = 0;
68
+ _ownerDisposalDepth = 0;
69
+ _disposingNodes = [];
70
+ _ownerDisposals = 0;
71
+ _disposalSweepers;
72
+ _nextDisposalSweep = Number.POSITIVE_INFINITY;
73
+ _actionDepth = 0;
74
+ _actionCounter = 0;
75
+ _traceCauseStack = [];
76
+ _phaseTraceOperations;
77
+ _executionRequested = !1;
78
+ _disposed = !1;
79
+ _disposedListeners = /* @__PURE__ */ new Set();
80
+ _checkedObjectPolicy;
81
+ _fastObjectPolicy;
82
+ constructor(e, t, s, i) {
83
+ const { id: o, adaptiveDependencyIndex: r, enforceActions: c } = e;
84
+ this.configuration = e, this.reactiveObjects = s !== void 0, this.selectors = i !== void 0, this._reactiveObjects = s, this._debugController = t;
85
+ const n = `[Raph] Runtime "${o}" is disposed.`;
86
+ if (this._signalLifecycle = {
87
+ owner: this,
88
+ assertDependencyAllowed: (h, a) => {
89
+ this._assertImplicitDependency(h, a);
90
+ },
91
+ ...c ? { assertWriteAllowed: () => this._assertWriteAllowed() } : {},
92
+ throwDisposed: () => {
93
+ throw new O(n);
94
+ },
95
+ throwCrossRuntime: (h) => this._throwCrossRuntime(h)
96
+ }, this._reactivity = new J(this._signalLifecycle, { adaptiveDependencyIndex: r }, i), this._workGraph = new X(this), this.rootScope = new T(`${o}:root-scope`, this), this.root = new F(null, { id: `${o}:root` }, this), s !== void 0) {
97
+ const h = () => this._assertWriteAllowed(), a = (l) => this._runWrite(l), p = (l) => {
98
+ throw l instanceof W && this._throwCrossRuntime(l), new g(
99
+ "[Raph] Reactive object belongs to another reactivity engine."
100
+ );
101
+ };
102
+ this._checkedObjectPolicy = Object.freeze({
103
+ owner: this,
104
+ assertRead: () => this._assertTrackedRead(),
105
+ assertWrite: h,
106
+ runWrite: a,
107
+ writeBoundary: this,
108
+ throwForeign: p
109
+ }), this._fastObjectPolicy = Object.freeze({
110
+ owner: this,
111
+ assertRead: void 0,
112
+ assertWrite: h,
113
+ runWrite: a,
114
+ writeBoundary: this,
115
+ throwForeign: p
116
+ });
117
+ }
118
+ k.add(new WeakRef(this)), B(), this._applyObjectReadPolicy(P);
119
+ const u = this._reactivity.signalForOwner(0, this.rootScope, "frame", !1);
120
+ this._frameTickSignal = u, this.frameTick = this._workGraph.attachProducer(u, {
121
+ get: () => u.get(),
122
+ peek: () => u.peek()
123
+ });
124
+ }
125
+ _getReactivity() {
126
+ return this._reactivity;
127
+ }
128
+ _getWorkGraph() {
129
+ return this._workGraph;
130
+ }
131
+ get id() {
132
+ return this.configuration.id;
133
+ }
134
+ get disposed() {
135
+ return this._disposed;
136
+ }
137
+ get graph() {
138
+ return this._parentGraph ??= j();
139
+ }
140
+ get loopEnabled() {
141
+ return this._frameLoop?.running ?? !1;
142
+ }
143
+ get frame() {
144
+ return this._phases?.frame ?? { now: 0, delta: 0, elapsed: 0, frame: 0 };
145
+ }
146
+ get phases() {
147
+ return this._phases?.phases ?? [];
148
+ }
149
+ signal(e, t = this.rootScope) {
150
+ return this._assertOwnerRuntime(t), this._reactivity.signalForOwner(e, t);
151
+ }
152
+ reactive(e) {
153
+ if (this._assertAlive(), this._reactiveObjects === void 0)
154
+ throw new TypeError("[Raph] Reactive objects require the full execution profile.");
155
+ return this._reactiveObjects.reactive(this._reactivity, e);
156
+ }
157
+ computed(e, t = this.rootScope) {
158
+ this._assertOwnerRuntime(t);
159
+ const s = this._workGraph.createProducer(t), i = typeof e == "function" ? e : e.get, o = this._reactivity.computedForOwner(
160
+ () => this._runTracked(t, i),
161
+ t,
162
+ this._workGraph.producerHooks(s)
163
+ );
164
+ if (this._workGraph.setProducerActivation(s, () => {
165
+ o.peek();
166
+ }), typeof e == "function")
167
+ return this._workGraph.attachProducer(s, o);
168
+ const r = this._attachWritableComputed(o, e.set, t);
169
+ return this._workGraph.attachProducer(s, r);
170
+ }
171
+ effect(e, t, s, i = m) {
172
+ return ee(
173
+ this._effectRegistration(e, t, s, i)
174
+ );
175
+ }
176
+ _effectRegistration(e, t, s, i = m, o = !1, r = !1, c, n) {
177
+ this._disposed || e.runtime !== this ? this._assertOwnerRuntime(e) : e._assertAlive();
178
+ const u = this._phases ?? this._execution;
179
+ if (typeof s != "function")
180
+ throw new TypeError("[Raph] Phase callback must be a function.");
181
+ const h = u._resolvedState, a = h !== void 0 && t === u._resolvedInput ? h : u.resolvePhase(t), p = i.priority ?? 0;
182
+ if (!Number.isFinite(p))
183
+ throw new TypeError("[Raph] Effect priority must be finite.");
184
+ const l = i.initial ?? "scheduled";
185
+ if (l !== "scheduled" && l !== "sync")
186
+ throw new TypeError(`[Raph] Unsupported effect initial mode "${String(l)}".`);
187
+ a.bindings++;
188
+ const d = new K(a, i.priority ?? 0, e, s);
189
+ r && (d.state = x | z);
190
+ const w = this._reactivity, v = i.initial === "sync", S = v && this.configuration.scheduler !== f.Sync;
191
+ let A = "Effect registration and cleanup failed.", b = !1;
192
+ try {
193
+ o && d.pause();
194
+ const y = w._allocateTaskEffect(w._phaseBody, d);
195
+ if (d.node = y, S && u._queue(d, !1), b = !0, !S && !o && !w._isBatching() && u._canDeliverFirst(d)) {
196
+ w._requestTaskEffect(y, !1);
197
+ try {
198
+ u._deliverFirst(d);
199
+ } catch (G) {
200
+ w._failTaskEffectSchedule(y, G);
201
+ }
202
+ } else
203
+ w._requestTaskEffect(y, !S);
204
+ if (n?.())
205
+ return d.dispose(), d;
206
+ b = !1, A = "[Raph] Resource registration and cleanup failed.", (d.state & x) !== 0 && d.node !== void 0 ? e._adoptRecord(d) : (e._assertAlive(), d.dispose()), A = "[Raph] Phase effect registration and rollback failed.", b = !0, v ? u._running ? this._executionRequested = !1 : (this._disposed && this._assertAlive(), this._executionRequested = !1, u.flush()) : this._requestExecution(), n?.() && d.dispose();
207
+ } catch (y) {
208
+ this._rollbackRegistration(
209
+ d,
210
+ y,
211
+ A,
212
+ b ? c : void 0
213
+ );
214
+ }
215
+ return d;
216
+ }
217
+ _effectGroupRegistration(e, t, s, i, o, r = m, c = !1) {
218
+ this._assertOwnerRuntime(e);
219
+ const n = this._execution, u = i, h = this._validatePhaseBinding(n, t, u, r);
220
+ if (!Number.isInteger(s) || s < 1)
221
+ throw new RangeError("[Raph] Effect group slot count must be a positive integer.");
222
+ if (s > N)
223
+ throw new RangeError(`[Raph] Effect group slot count must not exceed ${N}.`);
224
+ const a = n.bindGroup(h, e, u, o, s, r.priority ?? 0);
225
+ try {
226
+ c && a.pause();
227
+ const p = a.group, l = this._reactivity, d = l._phaseBody, w = D + s;
228
+ for (let v = D; v < w; v++)
229
+ p[v] = l._allocateTaskEffect(d, a);
230
+ e._adoptRecord(a);
231
+ } catch (p) {
232
+ this._rollbackRegistration(a, p, "[Raph] Resource registration and cleanup failed.");
233
+ }
234
+ return a;
235
+ }
236
+ _startGroupSlot(e, t, s, i) {
237
+ const o = e.group;
238
+ if (o === void 0) {
239
+ e.consumerOwner._assertAlive();
240
+ return;
241
+ }
242
+ const r = t >= 0 ? o[D + t] : void 0;
243
+ if (r === void 0)
244
+ throw new RangeError(`[Raph] Effect group has no slot ${String(t)}.`);
245
+ if (s !== "scheduled" && s !== "sync")
246
+ throw new TypeError(`[Raph] Unsupported effect initial mode "${String(s)}".`);
247
+ if (r === null || r.firstDep !== null)
248
+ return;
249
+ const c = e.phaseState.pipeline, n = s === "sync", u = n && this.configuration.scheduler !== f.Sync;
250
+ let h = !1;
251
+ try {
252
+ h = !0, this._reactivity._requestTaskEffect(r, !1), u ? e.state & C || c._queue(e, !1) : e.schedule(), h = !1, e.state & (C | V) || e.consumerOwner._assertAlive(), n ? c._running ? this._executionRequested = !1 : (h = !0, this.flush(), h = !1, e.state & x || e.consumerOwner._assertAlive()) : (h = !0, this._requestExecution());
253
+ } catch (a) {
254
+ let p = a;
255
+ try {
256
+ this._reactivity._disposeTaskEffect(r);
257
+ } catch (l) {
258
+ p = new AggregateError(
259
+ [a, l],
260
+ "[Raph] Phase effect registration and rollback failed."
261
+ );
262
+ }
263
+ throw h && i !== void 0 && i(p), p;
264
+ }
265
+ }
266
+ watch(e, t, s, i, o = m) {
267
+ const r = this._watchRegistration(e, t, s, i, o).watch;
268
+ return r === void 0 ? q : te(r);
269
+ }
270
+ _watchRegistration(e, t, s, i, o = m, r = !1, c, n) {
271
+ this._assertOwnerRuntime(e);
272
+ const u = this._execution, h = this._validatePhaseBinding(u, s, i, o, !0);
273
+ this._workGraph.assertSubscriptionAllowed(e, t);
274
+ const a = u.bindTask(h, e, i, o.priority ?? 0), p = Y((d) => this._runUntracked(d), a);
275
+ a.watch = p, r && a.pause();
276
+ try {
277
+ if (p.source = this._workGraph.subscribe(
278
+ t,
279
+ o.include,
280
+ (d, w, v) => p.record?.enqueue(d, w, v)
281
+ ), n?.())
282
+ return a.dispose(), a;
283
+ } catch (d) {
284
+ throw a.dispose(), d;
285
+ }
286
+ try {
287
+ e._adoptRecord(a);
288
+ } catch (d) {
289
+ this._rollbackRegistration(a, d, "[Raph] Resource registration and cleanup failed.");
290
+ }
291
+ const l = o.initial ?? "scheduled";
292
+ try {
293
+ l !== "none" && a.schedule(), l === "sync" && this.flush(), n?.() && a.dispose();
294
+ } catch (d) {
295
+ this._rollbackRegistration(
296
+ a,
297
+ d,
298
+ "[Raph] Phase watch registration and rollback failed.",
299
+ c
300
+ );
301
+ }
302
+ return a;
303
+ }
304
+ aggregate(e, t) {
305
+ return this._assertOwnerRuntime(e), this._workGraph.createAggregate(e, t);
306
+ }
307
+ batch(e) {
308
+ return this._batch(e, !0);
309
+ }
310
+ _batchReactive(e) {
311
+ return this._batch(e, !1);
312
+ }
313
+ _batch(e, t) {
314
+ this._assertAlive(), this._batchDepth++;
315
+ let s, i, o = !1;
316
+ try {
317
+ s = this._reactivity.batch(() => t ? this._runDataBatch(e) : e());
318
+ } catch (r) {
319
+ o = !0, i = r;
320
+ }
321
+ return this._closeBatch(o, i), s;
322
+ }
323
+ _closeBatch(e, t) {
324
+ if (this._batchDepth--, this._executionBoundaryOpen()) {
325
+ if (e)
326
+ throw t;
327
+ return;
328
+ }
329
+ const s = this._finishExecutionBoundary();
330
+ if (e)
331
+ throw s !== void 0 ? new AggregateError(
332
+ [t, ...s],
333
+ "[Raph] Batch and scheduled phase execution failed."
334
+ ) : t;
335
+ s !== void 0 && R(s, "[Raph] Batch phase execution failed.");
336
+ }
337
+ _applyBatch(e, t, s) {
338
+ this._assertAlive();
339
+ const i = this._reactivity;
340
+ this._batchDepth++, i._startBatch();
341
+ let o, r, c = !1;
342
+ try {
343
+ o = i._applyUntrackedWithOwner(e, t, s);
344
+ } catch (n) {
345
+ c = !0, r = n;
346
+ }
347
+ try {
348
+ i._endBatch();
349
+ } catch (n) {
350
+ r = c ? new AggregateError([r, n], "Batch operation and effect queue processing failed.") : n, c = !0;
351
+ }
352
+ return this._closeBatch(c, r), o;
353
+ }
354
+ action(e, t, s) {
355
+ const i = typeof e == "function" ? e : t, o = typeof e == "function" ? t instanceof T ? t : this.rootScope : s ?? this.rootScope, r = typeof e == "string" ? e : `action#${++this._actionCounter}`;
356
+ if (this._assertOwnerRuntime(o), typeof i != "function")
357
+ throw new TypeError("[Raph] Action operation must be a function.");
358
+ if (!r.trim())
359
+ throw new Error("[Raph] Action name must not be empty.");
360
+ return (...c) => this._invokeAction(r, o, i, c);
361
+ }
362
+ /**
363
+ * Общее исполнение public action и class methods, без второго массива аргументов.
364
+ * @internal
365
+ */
366
+ _invokeAction(e, t, s, i, o) {
367
+ t._assertAlive();
368
+ const r = this._debugController, c = this._traceCauseStack, n = r?.nextOperationId("action"), h = (c.length === 0 ? void 0 : c[c.length - 1]) ?? n;
369
+ n !== void 0 && r?.record({
370
+ ...h === void 0 ? {} : { causeId: h },
371
+ kind: "action",
372
+ name: e,
373
+ ...n === void 0 ? {} : { operationId: n },
374
+ status: "start"
375
+ }), h !== void 0 && c.push(h), this._actionDepth++;
376
+ try {
377
+ const a = this._applyBatch(s, i, o);
378
+ return r?.traces("action") && r?.record({
379
+ ...h === void 0 ? {} : { causeId: h },
380
+ kind: "action",
381
+ name: e,
382
+ ...n === void 0 ? {} : { operationId: n },
383
+ status: "end"
384
+ }), a;
385
+ } catch (a) {
386
+ throw this._debugController?.record({
387
+ ...h === void 0 ? {} : { causeId: h },
388
+ details: { message: E(a) },
389
+ kind: "action",
390
+ name: e,
391
+ ...n === void 0 ? {} : { operationId: n },
392
+ status: "error"
393
+ }), this._debugController?.record({
394
+ ...h === void 0 ? {} : { causeId: h },
395
+ details: { message: E(a) },
396
+ kind: "error",
397
+ name: `action:${e}`,
398
+ ...n === void 0 ? {} : { operationId: n },
399
+ status: "error"
400
+ }), a;
401
+ } finally {
402
+ this._actionDepth--, h !== void 0 && c.pop();
403
+ }
404
+ }
405
+ untracked(e) {
406
+ return this._assertAlive(), this._runUntracked(e);
407
+ }
408
+ /**
409
+ * Выполняет операцию вне owner context и сообщает, было ли в ней отслеживаемое
410
+ * чтение. Ни одной зависимости операция не оставляет. Renderer так проверяет,
411
+ * что значение зависит только от переданных данных и не требует effect.
412
+ * @internal
413
+ */
414
+ _probeReads(e) {
415
+ return this._assertAlive(), this._reactivity._probeReadsWithOwner(e);
416
+ }
417
+ scope(e) {
418
+ return this._assertAlive(), new T(e, this);
419
+ }
420
+ node(e, t) {
421
+ this._assertAlive(), this._enterWrite();
422
+ let s;
423
+ try {
424
+ s = this._createCommittedNode(e, t);
425
+ } catch (i) {
426
+ throw this._failWrite(i);
427
+ }
428
+ return this._exitWrite(), s._assertAlive(), s;
429
+ }
430
+ _createCommittedNode(e, t) {
431
+ const s = e.parent ?? this.root, i = M(s, e, this);
432
+ try {
433
+ const o = t?.(i);
434
+ return i._assertAlive(), s._assertAlive(), i._setApi(o), i._publishCreation(), i;
435
+ } catch (o) {
436
+ try {
437
+ i.dispose();
438
+ } catch (r) {
439
+ throw new AggregateError([o, r], `[Raph] Node "${i.id}" setup and cleanup failed.`);
440
+ }
441
+ throw o;
442
+ }
443
+ }
444
+ getNode(e) {
445
+ return this._assertAlive(), this.root._findNode(e);
446
+ }
447
+ definePhases(e) {
448
+ this._execution.definePhases(e);
449
+ }
450
+ addPhase(e) {
451
+ this._execution.addPhase(e);
452
+ }
453
+ clearPhases() {
454
+ this._assertAlive(), this._phases?.clearPhases();
455
+ }
456
+ requestExecution() {
457
+ this._assertAlive(), this._phases?.request();
458
+ }
459
+ flush() {
460
+ this._assertAlive(), this._executionRequested = !1, this._phases?.flush();
461
+ }
462
+ afterFlush() {
463
+ return this._assertAlive(), this._phases?.afterFlush() ?? Promise.resolve();
464
+ }
465
+ acquireLoop(e) {
466
+ return this._assertAlive(), this._clock.acquire(e);
467
+ }
468
+ startLoop() {
469
+ this._assertAlive(), this._clock.start();
470
+ }
471
+ stopLoop() {
472
+ this._frameLoop?.stop();
473
+ }
474
+ dispose() {
475
+ if (this._disposed)
476
+ return;
477
+ this._disposed = !0, this._checkedObjectPolicy !== void 0 && this._reactiveObjects?.configure(this._reactivity, this._checkedObjectPolicy), B(), this._executionRequested = !1, this._signalLifecycle.owner = void 0;
478
+ const e = [];
479
+ try {
480
+ this._frameLoop?.dispose();
481
+ } catch (r) {
482
+ e.push(r);
483
+ }
484
+ this._frameLoop = void 0;
485
+ try {
486
+ this._phases?.dispose();
487
+ } catch (r) {
488
+ e.push(r);
489
+ }
490
+ this._phases = void 0;
491
+ try {
492
+ this.root.dispose();
493
+ } catch (r) {
494
+ e.push(r);
495
+ }
496
+ const t = this._collectOwners().sort(se);
497
+ for (const r of t)
498
+ if (!(r === this.root || r === this.rootScope || r.disposed))
499
+ try {
500
+ r.dispose();
501
+ } catch (c) {
502
+ e.push(c);
503
+ }
504
+ try {
505
+ this.rootScope.dispose();
506
+ } catch (r) {
507
+ e.push(r);
508
+ }
509
+ const s = `[Raph] Runtime "${this.id}" is disposed.`, i = () => {
510
+ throw new O(s);
511
+ };
512
+ try {
513
+ this._reactiveObjects?.dispose(this._reactivity, {
514
+ assertRead: i,
515
+ assertWrite: i,
516
+ throwForeign: i
517
+ });
518
+ } catch (r) {
519
+ e.push(r);
520
+ }
521
+ this._topOwners.clear(), this._ownersReleased = !0, this._disposeDataSources(e);
522
+ try {
523
+ this._workGraph.dispose();
524
+ } catch (r) {
525
+ e.push(r);
526
+ }
527
+ this._detachDataPlane(e);
528
+ const o = [...this._disposedListeners];
529
+ this._disposedListeners.clear();
530
+ for (const r of o)
531
+ try {
532
+ r();
533
+ } catch (c) {
534
+ e.push(c);
535
+ }
536
+ R(e, `[Raph] Runtime "${this.id}" disposal failed.`);
537
+ }
538
+ _onDisposed(e) {
539
+ return this._disposed ? (e(), () => {
540
+ }) : (this._disposedListeners.add(e), () => {
541
+ this._disposedListeners.delete(e);
542
+ });
543
+ }
544
+ _notifyNodeStructure(e, t, s, i) {
545
+ if (!this._workGraph._hasStructuralDemand(e)) {
546
+ this._touchMutationBoundary();
547
+ return;
548
+ }
549
+ this._runNodeMutation(() => {
550
+ this._workGraph.notifyNode(e, "structure", { structure: t, oldAncestors: s, newAncestors: i });
551
+ });
552
+ }
553
+ _hasNodeStructureDemand(e) {
554
+ return this._workGraph._hasStructuralDemand(e);
555
+ }
556
+ _hasNodeSubscribers() {
557
+ return this._workGraph._hasNodeSubscribers();
558
+ }
559
+ _notifyNodeTouch(e, t) {
560
+ this._runNodeMutation(() => this._workGraph.notifyNode(e, "touch", { metadata: t }));
561
+ }
562
+ _assertNodeReparentAllowed(e, t) {
563
+ this._workGraph.assertReparentAllowed(e, t);
564
+ }
565
+ _releaseNode(e) {
566
+ this._workGraph.releaseNode(e);
567
+ }
568
+ _runNodeMutation(e) {
569
+ return this._runWrite(e);
570
+ }
571
+ _touchMutationBoundary() {
572
+ if (this.configuration.scheduler === f.Sync && (this._executionRequested = !0), this._executionBoundaryOpen())
573
+ return;
574
+ const e = this._finishExecutionBoundary();
575
+ e !== void 0 && R(e, "[Raph] Mutation phase execution failed.");
576
+ }
577
+ _runPhaseTransition(e) {
578
+ return this._runWrite(e, !1);
579
+ }
580
+ _beginOwnerDisposal(e) {
581
+ this._disposingNodes[this._ownerDisposalDepth++] = e;
582
+ }
583
+ _endOwnerDisposal() {
584
+ const e = this._ownerDisposalDepth;
585
+ e !== 0 && (this._ownerDisposalDepth = e - 1, this._disposingNodes[e - 1] = void 0, this._ownerDisposals >= this._nextDisposalSweep && e === 1 && this._sweepAfterDisposals(), this._clearTransientCausesIfSettled(), this._disposed || this._requestExecution());
586
+ }
587
+ _ownerDisposalCount() {
588
+ return this._ownerDisposals;
589
+ }
590
+ _addDisposalSweeper(e, t) {
591
+ const s = this._disposalSweepers;
592
+ if (s === void 0) {
593
+ e._sweepSlot = 0, e._sweepDue = t, this._disposalSweepers = [e], this._nextDisposalSweep = t;
594
+ return;
595
+ }
596
+ H(s, e, t), this._nextDisposalSweep = s[0]._sweepDue;
597
+ }
598
+ _removeDisposalSweeper(e) {
599
+ const t = this._disposalSweepers;
600
+ t === void 0 || !I(t, e) || (t.length === 0 ? (this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY) : this._nextDisposalSweep = t[0]._sweepDue);
601
+ }
602
+ _sweepAfterDisposals() {
603
+ const e = this._disposalSweepers;
604
+ if (e === void 0)
605
+ return;
606
+ const t = this._ownerDisposals;
607
+ if (e.length === 1) {
608
+ const s = e[0], i = s._afterOwnerDisposals(t);
609
+ i > t ? (s._sweepDue = i, this._nextDisposalSweep = i) : (s._sweepSlot = -1, this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY);
610
+ return;
611
+ }
612
+ for (let s = e[0]; s._sweepDue <= t; s = e[0]) {
613
+ const i = s._afterOwnerDisposals(t);
614
+ if (i > t)
615
+ Q(e, i);
616
+ else if (I(e, s), e.length === 0) {
617
+ this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY;
618
+ return;
619
+ }
620
+ }
621
+ this._nextDisposalSweep = e[0]._sweepDue;
622
+ }
623
+ _ownerDisposalActive() {
624
+ return this._ownerDisposalDepth !== 0;
625
+ }
626
+ _registerOwner(e) {
627
+ return this._assertAlive(), e._isNode || this._topOwners.add(e), ++this._ownerRegistrations;
628
+ }
629
+ _unregisterOwner(e) {
630
+ e._isNode || this._topOwners.delete(e), this._ownerDisposals++;
631
+ }
632
+ _addTopOwner(e) {
633
+ this._topOwners.add(e);
634
+ }
635
+ _removeTopOwner(e) {
636
+ this._topOwners.delete(e);
637
+ }
638
+ _assertOwnerRuntime(e) {
639
+ if (this._assertAlive(), e.runtime !== this)
640
+ throw new g("[Raph] Owner belongs to another runtime.");
641
+ e._assertAlive();
642
+ }
643
+ _beginKernelBatch() {
644
+ this._disposed || this._kernelBatchDepth++;
645
+ }
646
+ _endKernelBatch() {
647
+ this._kernelBatchDepth !== 0 && (this._kernelBatchDepth--, this._clearTransientCausesIfSettled(), this._disposed || this._requestExecution());
648
+ }
649
+ _registerMachineDebug(e) {
650
+ return this._assertAlive(), this._debugController?.registerMachine(e) ?? q;
651
+ }
652
+ _hasMachineDebug(e) {
653
+ return this._debugController?.hasMachine(e) ?? !1;
654
+ }
655
+ _traces(e) {
656
+ return this._debugController?.traces(e) ?? !1;
657
+ }
658
+ _currentTraceCauseId() {
659
+ return this._traceCauseStack.at(-1);
660
+ }
661
+ _nextTraceOperation(e) {
662
+ return this._debugController?.nextOperationId(e);
663
+ }
664
+ _hasActiveReactiveContext() {
665
+ return this._assertAlive(), this._reactivity.hasActiveContext();
666
+ }
667
+ _recordTrace(e) {
668
+ this._debugController?.record(e);
669
+ }
670
+ _runWithTraceCause(e, t) {
671
+ if (e === void 0)
672
+ return t();
673
+ this._traceCauseStack.push(e);
674
+ try {
675
+ return t();
676
+ } finally {
677
+ this._traceCauseStack.pop();
678
+ }
679
+ }
680
+ _validatePhaseBinding(e, t, s, i, o = !1) {
681
+ if (typeof s != "function")
682
+ throw new TypeError("[Raph] Phase callback must be a function.");
683
+ const r = e.resolvePhase(t), c = i.priority ?? 0;
684
+ if (!Number.isFinite(c))
685
+ throw new TypeError("[Raph] Effect priority must be finite.");
686
+ const n = i.initial ?? "scheduled";
687
+ if (n !== "scheduled" && n !== "sync" && !(o && n === "none"))
688
+ throw new TypeError(`[Raph] Unsupported effect initial mode "${String(n)}".`);
689
+ return r;
690
+ }
691
+ _rollbackRegistration(e, t, s, i) {
692
+ let o = t;
693
+ try {
694
+ e.dispose();
695
+ } catch (r) {
696
+ o = new AggregateError([t, r], s);
697
+ }
698
+ throw i !== void 0 && i(o), o;
699
+ }
700
+ _liveOwnerCount() {
701
+ return this._ownersReleased ? 0 : this._ownerRegistrations - this._ownerDisposals;
702
+ }
703
+ _collectOwners() {
704
+ const e = [];
705
+ if (this._ownersReleased)
706
+ return e;
707
+ const t = this._topOwners;
708
+ for (const o of t)
709
+ e.push(o), o._isNode && o._collectDescendants(e);
710
+ const s = this._disposingNodes, i = this._ownerDisposalDepth;
711
+ for (let o = 0; o < i; o++) {
712
+ const r = s[o];
713
+ r === void 0 || r._isLinked() || t.has(r) || (e.push(r), r._collectDescendants(e));
714
+ }
715
+ return e;
716
+ }
717
+ get _execution() {
718
+ return this._assertAlive(), this._phases !== void 0 ? this._phases : (this._phases = new U(
719
+ this.configuration.scheduler,
720
+ this._reactivity,
721
+ (e) => this._workGraph.causeForToken(e),
722
+ () => {
723
+ const e = this._mutationDepth !== 0 || this._batchDepth !== 0 || this._kernelBatchDepth !== 0 || this._ownerDisposalDepth !== 0 || this._reactivity._isFlushingEffects();
724
+ return e && this.configuration.scheduler === f.Sync && (this._executionRequested = !0), e;
725
+ }
726
+ ), this._syncPhaseTrace(), this._phases);
727
+ }
728
+ _phaseTraceListener;
729
+ _syncPhaseTrace() {
730
+ if (this._phases === void 0)
731
+ return;
732
+ const t = this._phaseTraceOperations !== void 0 || this._debugController?.traces("phase") ? this._phaseTraceListener ??= this._tracePhase.bind(this) : void 0;
733
+ this._phases._setPhaseTrace(t);
734
+ }
735
+ _tracePhase(e, t, s) {
736
+ if (this._phaseTraceOperations === void 0 && !this._debugController?.traces("phase"))
737
+ return;
738
+ let i;
739
+ t === "start" ? (i = this._debugController?.nextOperationId("phase"), i !== void 0 && (this._phaseTraceOperations ??= /* @__PURE__ */ new Map()).set(e, i)) : (i = this._phaseTraceOperations?.get(e), this._phaseTraceOperations?.delete(e), this._phaseTraceOperations?.size === 0 && (this._phaseTraceOperations = void 0)), this._debugController?.record({
740
+ ...i === void 0 ? {} : { causeId: i },
741
+ ...s === void 0 ? {} : { details: { message: E(s) } },
742
+ kind: "phase",
743
+ name: e,
744
+ ...i === void 0 ? {} : { operationId: i },
745
+ status: t
746
+ }), this._phaseTraceOperations === void 0 && !this._debugController?.traces("phase") && this._phases?._setPhaseTrace(void 0);
747
+ }
748
+ get _clock() {
749
+ return this._frameLoop ??= new $(() => this._tickFrameLoop());
750
+ }
751
+ _tickFrameLoop() {
752
+ this._disposed || this._setFrameTick(this._frameTickSignal.peek() + 1);
753
+ }
754
+ _setFrameTick(e) {
755
+ this._enterWrite();
756
+ try {
757
+ this._frameTickSignal._writeInBoundary(e);
758
+ } catch (t) {
759
+ throw this._failWrite(t);
760
+ }
761
+ this._exitWrite();
762
+ }
763
+ _attachWritableComputed(e, t, s) {
764
+ let i = t;
765
+ this._own(() => {
766
+ i = void 0;
767
+ }, s);
768
+ const o = e;
769
+ return o.set = (r) => {
770
+ s._assertAlive(), this._assertWriteAllowed(), this._runWrite(() => i(r));
771
+ }, o;
772
+ }
773
+ _own(e, t) {
774
+ try {
775
+ return t._adoptResource(e);
776
+ } catch (s) {
777
+ try {
778
+ e();
779
+ } catch (i) {
780
+ throw new AggregateError([s, i], "[Raph] Resource registration and cleanup failed.");
781
+ }
782
+ throw s;
783
+ }
784
+ }
785
+ _runTracked(e, t) {
786
+ return this._reactivity.runWithOwner(this._signalLifecycle, e, t);
787
+ }
788
+ _runUntracked(e) {
789
+ return this._reactivity.untrackedWithOwner(e);
790
+ }
791
+ _runWrite(e, t = !0) {
792
+ t && this.configuration.scheduler === f.Sync && (this._executionRequested = !0), this._mutationDepth++;
793
+ let s, i, o = !1;
794
+ try {
795
+ s = e();
796
+ } catch (c) {
797
+ o = !0, i = c;
798
+ }
799
+ if (this._mutationDepth--, this._executionBoundaryOpen()) {
800
+ if (o)
801
+ throw i;
802
+ return s;
803
+ }
804
+ const r = this._finishExecutionBoundary();
805
+ if (o)
806
+ throw r !== void 0 ? new AggregateError(
807
+ [i, ...r],
808
+ "[Raph] Mutation and scheduled phase execution failed."
809
+ ) : i;
810
+ return r !== void 0 && R(r, "[Raph] Mutation phase execution failed."), s;
811
+ }
812
+ /** @internal */
813
+ _isWriteBatchOpen() {
814
+ return this._batchDepth !== 0 && this._reactivity._isBatching();
815
+ }
816
+ // Raph Top-1: граница записи сама не запрашивает flush. Работу, поставленную
817
+ // внутри неё, запрос отмечает через _deferSync pipeline; при закрытии внешней
818
+ // границы flush выполняется только если у pipeline есть ожидающая работа.
819
+ // Запись внутри batch, action или другой открытой границы проверяет ожидающую
820
+ // работу при своём закрытии: внешняя граница, закрываясь, доставляет и
821
+ // отложенные через defer() задачи, поставленные до этой записи.
822
+ _enterWrite() {
823
+ this._mutationDepth++;
824
+ }
825
+ _exitWrite() {
826
+ if (this._mutationDepth--, this._requestPendingExecution(), this._executionBoundaryOpen())
827
+ return;
828
+ const e = this._finishExecutionBoundary();
829
+ e !== void 0 && R(e, "[Raph] Mutation phase execution failed.");
830
+ }
831
+ _failWrite(e) {
832
+ if (this._mutationDepth--, this._requestPendingExecution(), this._executionBoundaryOpen())
833
+ return e;
834
+ const t = this._finishExecutionBoundary();
835
+ return t === void 0 ? e : new AggregateError(
836
+ [e, ...t],
837
+ "[Raph] Mutation and scheduled phase execution failed."
838
+ );
839
+ }
840
+ _requestPendingExecution() {
841
+ !this._executionRequested && this.configuration.scheduler === f.Sync && this._phases?._hasPendingWork() === !0 && (this._executionRequested = !0);
842
+ }
843
+ _executionBoundaryOpen() {
844
+ return this._mutationDepth !== 0 || this._batchDepth !== 0 || this._kernelBatchDepth !== 0 || this._ownerDisposalDepth !== 0;
845
+ }
846
+ _finishExecutionBoundary() {
847
+ let e;
848
+ try {
849
+ this._clearTransientCausesIfSettled();
850
+ } catch (t) {
851
+ e = [t];
852
+ }
853
+ try {
854
+ this._requestExecution();
855
+ } catch (t) {
856
+ e === void 0 ? e = [t] : e.push(t);
857
+ }
858
+ return e;
859
+ }
860
+ _clearTransientCausesIfSettled() {
861
+ this._mutationDepth === 0 && this._batchDepth === 0 && this._kernelBatchDepth === 0 && this._ownerDisposalDepth === 0 && !this._reactivity._isFlushingEffects() && this._workGraph.clearTransientCauses();
862
+ }
863
+ _requestExecution() {
864
+ this._disposed || this.configuration.scheduler !== f.Sync || this._mutationDepth !== 0 || this._batchDepth !== 0 || this._kernelBatchDepth !== 0 || this._ownerDisposalDepth !== 0 || this._reactivity._isFlushingEffects() || this._executionRequested && (this._executionRequested = !1, this._phases?.flush());
865
+ }
866
+ /** @internal */
867
+ _applyObjectReadPolicy(e) {
868
+ this._disposed || this._checkedObjectPolicy === void 0 || this._reactiveObjects?.configure(this._reactivity, e ? this._checkedObjectPolicy : this._fastObjectPolicy);
869
+ }
870
+ _assertTrackedRead() {
871
+ this._assertAlive();
872
+ const e = this._reactivity.getActiveOwner();
873
+ if (e !== void 0 && e !== this && this._throwCrossRuntime(e), e === void 0) {
874
+ const t = this._reactivity.getActiveConsumerOwner();
875
+ if (t !== void 0 && t.runtime !== this)
876
+ throw new g("[Raph] Implicit dependency crosses runtime boundaries.");
877
+ }
878
+ }
879
+ _assertSourceReadable(e) {
880
+ this._assertAlive();
881
+ const t = this._reactivity.getActiveOwner();
882
+ t !== void 0 && t !== this && this._throwCrossRuntime(t);
883
+ const s = this._reactivity.getActiveConsumerOwner();
884
+ s !== void 0 && this._assertImplicitDependency(e, s), e._assertAlive();
885
+ }
886
+ _assertImplicitDependency(e, t) {
887
+ if (e.runtime !== this || t.runtime !== this)
888
+ throw new g("[Raph] Implicit dependency crosses runtime boundaries.");
889
+ if (!(e === this.rootScope || e === t) && !(e._isNode && t._isNode && t._hasAncestor(e)))
890
+ throw new Error(
891
+ `[Raph] Implicit dependency from "${t.id}" to "${e.id}" is not allowed; use watch().`
892
+ );
893
+ }
894
+ _assertWriteAllowed() {
895
+ if (this._assertAlive(), this.configuration.enforceActions && this._batchDepth === 0)
896
+ throw new L("[Raph] Writes are allowed only inside action() or batch().");
897
+ }
898
+ _throwCrossRuntime(e) {
899
+ throw new g(
900
+ `[Raph] Runtime "${this.id}" cannot be tracked by runtime "${e.id}".`
901
+ );
902
+ }
903
+ _assertAlive() {
904
+ if (this._disposed)
905
+ throw new O(`[Raph] Runtime "${this.id}" is disposed.`);
906
+ }
907
+ _runDataBatch(e) {
908
+ return e();
909
+ }
910
+ _disposeDataSources(e) {
911
+ }
912
+ _detachDataPlane(e) {
913
+ }
914
+ }
915
+ function ee(_) {
916
+ let e = _;
917
+ return () => {
918
+ const t = e;
919
+ t !== void 0 && (e = void 0, t.dispose());
920
+ };
921
+ }
922
+ function te(_) {
923
+ return () => {
924
+ _.record?.dispose();
925
+ };
926
+ }
927
+ function q() {
928
+ }
929
+ function se(_, e) {
930
+ return e._order - _._order;
931
+ }
932
+ function ie(_) {
933
+ return _ === f.Sync || _ === f.Microtask || _ === f.AnimationFrame;
934
+ }
935
+ function E(_) {
936
+ return _ instanceof Error ? _.message : String(_);
937
+ }
938
+ export {
939
+ W as RaphRuntimeBase,
940
+ ve as resolveRuntimeConfiguration
941
+ };