@raphy-js/raph 1.0.1-dev.26 → 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.
- package/README.md +100 -0
- package/dist/api/Raph.d.ts +15 -15
- package/dist/api/RaphFacadeSession.d.ts +4 -4
- package/dist/api/RaphReactivityInstance.d.ts +4 -4
- package/dist/api/types.d.ts +11 -11
- package/dist/compact.cjs +1 -0
- package/dist/compact.js +4 -0
- package/dist/debug/reactivity/engine-core.cjs +1 -0
- package/dist/debug/reactivity/engine-core.js +1760 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +25 -1689
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +604 -167
- package/dist/debug/runtime/RaphCompactExecutionRuntime.cjs +1 -0
- package/dist/debug/runtime/RaphCompactExecutionRuntime.js +9 -0
- package/dist/debug/runtime/RaphExecutionRuntime.cjs +1 -0
- package/dist/debug/runtime/RaphExecutionRuntime.js +11 -0
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +115 -1176
- package/dist/debug/runtime/RaphRuntimeBase.cjs +1 -0
- package/dist/debug/runtime/RaphRuntimeBase.js +941 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +72 -66
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +11 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +12 -12
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +361 -242
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +23 -22
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphSelector.js +111 -90
- package/dist/debug/runtime/reactivity/RuntimeObjectSupport.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeObjectSupport.js +11 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +118 -103
- package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.js +12 -0
- package/dist/entrypoints/compact.d.ts +2 -0
- package/dist/entrypoints/execution.d.ts +2 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -2
- package/dist/entrypoints/machine.d.ts +5 -5
- package/dist/entrypoints/observable.d.ts +4 -0
- package/dist/entrypoints/path.d.ts +14 -14
- package/dist/entrypoints/reactivity.d.ts +1 -1
- package/dist/entrypoints/runtime.d.ts +19 -18
- package/dist/execution.cjs +1 -0
- package/dist/execution.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +23 -21
- package/dist/machine/compiler.d.ts +1 -1
- package/dist/machine/core.d.ts +2 -2
- package/dist/machine/persistence.d.ts +1 -1
- package/dist/machine/runtime.d.ts +3 -3
- package/dist/machine/testing.d.ts +1 -1
- package/dist/machine/types.d.ts +3 -3
- package/dist/main.d.ts +19 -19
- package/dist/observable/buffer.d.ts +6 -0
- package/dist/observable/class-admin.d.ts +63 -0
- package/dist/observable/class-plan.d.ts +46 -0
- package/dist/observable/classes.d.ts +10 -0
- package/dist/observable/context.d.ts +73 -0
- package/dist/observable/native.d.ts +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/types.d.ts +60 -0
- package/dist/observable.cjs +1 -0
- package/dist/observable.js +1187 -0
- package/dist/path/DataPath.d.ts +2 -2
- package/dist/path/PathRouter.d.ts +1 -1
- package/dist/path/RaphKernel.d.ts +6 -6
- package/dist/path/data-path.types.d.ts +1 -1
- package/dist/path/data-path.utils.d.ts +2 -2
- package/dist/path/derived/DerivedRegistry.d.ts +3 -3
- package/dist/path/derived/RaphDerivedHandle.d.ts +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +1 -1
- package/dist/path/derived/derived-collection.utils.d.ts +3 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +1 -1
- package/dist/path/meta/MetaController.d.ts +5 -5
- package/dist/path/meta/RaphMeta.d.ts +3 -3
- package/dist/path/meta/RaphMetaStore.d.ts +1 -1
- package/dist/path/meta/meta.types.d.ts +2 -2
- package/dist/path/path.types.d.ts +2 -2
- package/dist/path/pathSegmentKey.d.ts +1 -1
- package/dist/path/storage/AdapterPathStore.d.ts +2 -2
- package/dist/path/storage/DefaultDataAdapter.d.ts +2 -2
- package/dist/path/storage/PathEventHub.d.ts +1 -1
- package/dist/path/storage/PathStore.d.ts +2 -2
- package/dist/path/storage/data-adapter.types.d.ts +1 -1
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +23 -21
- package/dist/reactivity/engine-core.d.ts +600 -0
- package/dist/reactivity/engine.d.ts +6 -550
- package/dist/reactivity/reactive-object.d.ts +143 -2
- package/dist/reactivity/scope.d.ts +7 -6
- package/dist/reactivity/types.d.ts +9 -12
- package/dist/reactivity/watch.d.ts +1 -1
- package/dist/runtime/RaphCompactExecutionRuntime.d.ts +7 -0
- package/dist/runtime/RaphExecutionRuntime.d.ts +6 -0
- package/dist/runtime/RaphRuntime.d.ts +19 -403
- package/dist/runtime/RaphRuntimeBase.d.ts +194 -0
- package/dist/runtime/diagnostics/RaphDebug.d.ts +8 -5
- package/dist/runtime/errors.d.ts +1 -1
- package/dist/runtime/ownership/RaphEffectScope.d.ts +13 -12
- package/dist/runtime/ownership/RaphNode.d.ts +28 -21
- package/dist/runtime/ownership/RaphScope.d.ts +32 -19
- package/dist/runtime/ownership/parent-graph.types.d.ts +1 -1
- package/dist/runtime/ownership/parentGraph.d.ts +2 -2
- package/dist/runtime/phases/RaphFrameLoop.d.ts +1 -1
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +80 -29
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +21 -21
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +3 -3
- package/dist/runtime/phases/orderPhaseTasks.d.ts +4 -2
- package/dist/runtime/phases/phase.types.d.ts +36 -35
- package/dist/runtime/reactivity/PathHandle.d.ts +5 -5
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +7 -7
- package/dist/runtime/reactivity/RaphSelector.d.ts +27 -6
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +40 -39
- package/dist/runtime/reactivity/RuntimeObjectSupport.d.ts +9 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +27 -19
- package/dist/runtime/reactivity/RuntimeSelectorSupport.d.ts +10 -0
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +1 -1
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +1 -1
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +3 -3
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +13 -11
- package/package.json +22 -62
|
@@ -1,163 +1,36 @@
|
|
|
1
|
-
import { parseDataPath as
|
|
2
|
-
import { DataPath as
|
|
3
|
-
import { RaphMeta as
|
|
4
|
-
import { RaphKernel as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import { RaphFrameLoop as z } from "./phases/RaphFrameLoop.js";
|
|
14
|
-
import { RaphPhasePipeline as j } from "./phases/RaphPhasePipeline.js";
|
|
15
|
-
import { TASK_ACTIVE as E, TASK_TASKLESS as U, GROUP_NODES as k, TASK_PENDING as C, TASK_REQUESTED as K } from "./phases/RaphPhaseTaskRecord.js";
|
|
16
|
-
import { createPhaseWatch as V } from "./phases/RaphPhaseWatch.js";
|
|
17
|
-
import { enqueueSweeper as Y, dequeueSweeper as P, postponeFirstSweeper as Q } from "./reactivity/disposal-sweep.utils.js";
|
|
18
|
-
import { PathHandle as X } from "./reactivity/PathHandle.js";
|
|
19
|
-
import { RaphMetaSource as J } from "./reactivity/RaphMetaSource.js";
|
|
20
|
-
import { RaphWorkGraph as Z } from "./reactivity/RaphWorkGraph.js";
|
|
21
|
-
import { RuntimeReactivity as ee } from "./reactivity/RuntimeReactivity.js";
|
|
22
|
-
const y = Object.freeze({}), I = 2 ** 32 - 1 - k;
|
|
23
|
-
class T {
|
|
24
|
-
static _runtimeCounter = 0;
|
|
25
|
-
mode = "runtime";
|
|
26
|
-
configuration;
|
|
27
|
-
rootScope;
|
|
28
|
-
root;
|
|
29
|
-
frameTick;
|
|
30
|
-
_reactivity;
|
|
31
|
-
_signalLifecycle;
|
|
32
|
-
_workGraph;
|
|
33
|
-
// Записываемый frame signal; наружу выдаётся только его read-only wrapper.
|
|
34
|
-
_frameTickSignal;
|
|
35
|
-
_pathHandles;
|
|
36
|
-
_meta;
|
|
37
|
-
_phases;
|
|
38
|
-
_frameLoop;
|
|
39
|
-
_debug;
|
|
40
|
-
_debugController;
|
|
41
|
-
_parentGraph;
|
|
42
|
-
// Владельцы вне списков детей в порядке регистрации: plain scopes и nodes
|
|
43
|
-
// без parent. Node с parent сюда не входит: её достигает обход детей, поэтому
|
|
44
|
-
// её создание и освобождение не стоят операции с Set.
|
|
45
|
-
_topOwners = /* @__PURE__ */ new Set();
|
|
46
|
-
// Число владельцев, зарегистрированных за всё время жизни Runtime; оно же —
|
|
47
|
-
// порядковый номер последнего из них.
|
|
48
|
-
_ownerRegistrations = 0;
|
|
49
|
-
// Runtime освободил владельцев и живых больше не числит.
|
|
50
|
-
_ownersReleased = !1;
|
|
51
|
-
_batchDepth = 0;
|
|
52
|
-
_mutationDepth = 0;
|
|
53
|
-
_kernelBatchDepth = 0;
|
|
54
|
-
_ownerDisposalDepth = 0;
|
|
55
|
-
// Node, чей dispose открыл границу освобождения, на месте глубины этой
|
|
56
|
-
// границы; у границы, открытой не node, место пусто. Node, вышедшая из списка
|
|
57
|
-
// parent до конца своего dispose, остаётся перечислимой только отсюда.
|
|
58
|
-
_disposingNodes = [];
|
|
59
|
-
// Число владельцев, освобождённых за всё время жизни Runtime.
|
|
60
|
-
_ownerDisposals = 0;
|
|
61
|
-
// Очередь участников уборки после освобождения владельцев, ближайший срок в
|
|
62
|
-
// начале, и число освобождений, при котором этот срок наступает; без
|
|
63
|
-
// участников поле пусто и срок не наступает.
|
|
64
|
-
_disposalSweepers;
|
|
65
|
-
_nextDisposalSweep = Number.POSITIVE_INFINITY;
|
|
66
|
-
_actionDepth = 0;
|
|
67
|
-
_actionCounter = 0;
|
|
68
|
-
_traceCauseStack = [];
|
|
69
|
-
_phaseTraceOperations;
|
|
70
|
-
_executionRequested = !1;
|
|
71
|
-
_disposed = !1;
|
|
72
|
-
_disposedListeners = /* @__PURE__ */ new Set();
|
|
1
|
+
import { parseDataPath as g } from "../path/data-path.utils.js";
|
|
2
|
+
import { DataPath as m } from "../path/DataPath.js";
|
|
3
|
+
import { RaphMeta as b } from "../path/meta/RaphMeta.js";
|
|
4
|
+
import { RaphKernel as k } from "../path/RaphKernel.js";
|
|
5
|
+
import { RaphDebugController as w, createOwnerSnapshot as l, createOwnerTree as u } from "./diagnostics/RaphDebug.js";
|
|
6
|
+
import { RaphNode as _ } from "./ownership/RaphNode.js";
|
|
7
|
+
import { RaphRuntimeBase as v, resolveRuntimeConfiguration as R } from "./RaphRuntimeBase.js";
|
|
8
|
+
import { PathHandle as S } from "./reactivity/PathHandle.js";
|
|
9
|
+
import { RaphMetaSource as D } from "./reactivity/RaphMetaSource.js";
|
|
10
|
+
import { RUNTIME_OBJECT_SUPPORT as y } from "./reactivity/RuntimeObjectSupport.js";
|
|
11
|
+
import { RUNTIME_SELECTOR_SUPPORT as O } from "./reactivity/RuntimeSelectorSupport.js";
|
|
12
|
+
class x extends v {
|
|
73
13
|
constructor(e = {}) {
|
|
74
|
-
const t = e
|
|
75
|
-
|
|
76
|
-
throw new Error(`[Raph] Unsupported scheduler "${String(i)}".`);
|
|
77
|
-
const o = e.kernel ?? new G({ id: `${t}-kernel` });
|
|
78
|
-
this.configuration = Object.freeze({
|
|
79
|
-
adaptiveDependencyIndex: s,
|
|
14
|
+
const t = R(e), r = e.kernel ?? new k({ id: `${t.id}-kernel` }), s = Object.freeze({
|
|
15
|
+
...t,
|
|
80
16
|
...e.debug === void 0 ? {} : { debug: e.debug },
|
|
81
|
-
|
|
82
|
-
kernel: o,
|
|
83
|
-
enforceActions: r,
|
|
84
|
-
scheduler: i
|
|
85
|
-
}), this._debugController = new M(e.debug);
|
|
86
|
-
const a = `[Raph] Runtime "${t}" is disposed.`;
|
|
87
|
-
this._signalLifecycle = {
|
|
88
|
-
owner: this,
|
|
89
|
-
assertDependencyAllowed: (h, u) => {
|
|
90
|
-
this._assertImplicitDependency(h, u);
|
|
91
|
-
},
|
|
92
|
-
...r ? { assertWriteAllowed: () => this._assertWriteAllowed() } : {},
|
|
93
|
-
throwDisposed: () => {
|
|
94
|
-
throw new A(a);
|
|
95
|
-
},
|
|
96
|
-
throwCrossRuntime: (h) => this._throwCrossRuntime(h)
|
|
97
|
-
}, this._reactivity = new ee(this._signalLifecycle, { adaptiveDependencyIndex: s }), this._workGraph = new Z(this), o._attachRuntime(this), this.rootScope = new O(`${t}:root-scope`, this), this.root = new v(null, { id: `${t}:root` }, this), q(this._reactivity, {
|
|
98
|
-
owner: this,
|
|
99
|
-
assertRead: () => {
|
|
100
|
-
this._assertAlive();
|
|
101
|
-
const h = this._reactivity.getActiveOwner();
|
|
102
|
-
h !== void 0 && h !== this && this._throwCrossRuntime(h);
|
|
103
|
-
const u = this._reactivity.getActiveConsumerOwner();
|
|
104
|
-
u !== void 0 && this._assertImplicitDependency(this.rootScope, u);
|
|
105
|
-
},
|
|
106
|
-
assertWrite: () => this._assertWriteAllowed(),
|
|
107
|
-
runWrite: (h) => this._runWrite(h),
|
|
108
|
-
throwForeign: (h) => {
|
|
109
|
-
throw h instanceof T && this._throwCrossRuntime(h), new b(
|
|
110
|
-
"[Raph] Reactive object belongs to another reactivity engine."
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
const n = this._reactivity.signalForOwner(0, this.rootScope, "frame", !1);
|
|
115
|
-
this._frameTickSignal = n, this.frameTick = this._workGraph.attachProducer(n, {
|
|
116
|
-
get: () => n.get(),
|
|
117
|
-
peek: () => n.peek()
|
|
17
|
+
kernel: r
|
|
118
18
|
});
|
|
19
|
+
super(s, void 0, y, O), this._debugController = new w(e.debug, this, this._syncPhaseTrace), r._attachRuntime(this);
|
|
119
20
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Возвращает внутренний WorkGraph для optional execution layers.
|
|
126
|
-
*
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
_getWorkGraph() {
|
|
130
|
-
return this._workGraph;
|
|
131
|
-
}
|
|
132
|
-
get id() {
|
|
133
|
-
return this.configuration.id;
|
|
134
|
-
}
|
|
21
|
+
_pathHandles;
|
|
22
|
+
_meta;
|
|
23
|
+
_debug;
|
|
135
24
|
get kernel() {
|
|
136
25
|
return this.configuration.kernel;
|
|
137
26
|
}
|
|
138
|
-
get disposed() {
|
|
139
|
-
return this._disposed;
|
|
140
|
-
}
|
|
141
|
-
get graph() {
|
|
142
|
-
return this._parentGraph ??= $();
|
|
143
|
-
}
|
|
144
|
-
get loopEnabled() {
|
|
145
|
-
return this._frameLoop?.running ?? !1;
|
|
146
|
-
}
|
|
147
|
-
get frame() {
|
|
148
|
-
return this._phases?.frame ?? { now: 0, delta: 0, elapsed: 0, frame: 0 };
|
|
149
|
-
}
|
|
150
|
-
get phases() {
|
|
151
|
-
return this._phases?.phases ?? [];
|
|
152
|
-
}
|
|
153
|
-
/** Runtime metadata facade intentionally excludes unphased watch(). */
|
|
154
27
|
get meta() {
|
|
155
28
|
if (this._assertAlive(), this._meta !== void 0)
|
|
156
29
|
return this._meta;
|
|
157
|
-
const e = new
|
|
30
|
+
const e = new b(this.kernel, {
|
|
158
31
|
assertReadable: () => this._assertAlive(),
|
|
159
32
|
assertWritable: () => this._assertWriteAllowed(),
|
|
160
|
-
runWrite: (t,
|
|
33
|
+
runWrite: (t, r) => this._runWrite(t, r)
|
|
161
34
|
});
|
|
162
35
|
return this._meta = Object.freeze({
|
|
163
36
|
delete: e.delete.bind(e),
|
|
@@ -179,241 +52,45 @@ class T {
|
|
|
179
52
|
machines: this._debugController.machines
|
|
180
53
|
});
|
|
181
54
|
}
|
|
182
|
-
signal(e, t = this.rootScope) {
|
|
183
|
-
return this._assertOwnerRuntime(t), this._reactivity.signalForOwner(e, t);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Creates a deep reactive Proxy owned by this Runtime root scope.
|
|
187
|
-
* Property dependencies use the intrusive graph directly and intentionally
|
|
188
|
-
* do not create per-property WorkGraph producers or phase causes.
|
|
189
|
-
*/
|
|
190
|
-
reactive(e) {
|
|
191
|
-
return this._assertAlive(), this._reactivity.reactive(e);
|
|
192
|
-
}
|
|
193
|
-
computed(e, t = this.rootScope) {
|
|
194
|
-
this._assertOwnerRuntime(t);
|
|
195
|
-
const s = this._workGraph.createProducer(t), r = typeof e == "function" ? e : e.get, i = this._reactivity.computedForOwner(
|
|
196
|
-
() => this._runTracked(t, r),
|
|
197
|
-
t,
|
|
198
|
-
this._workGraph.producerHooks(s)
|
|
199
|
-
);
|
|
200
|
-
if (this._workGraph.setProducerActivation(s, () => {
|
|
201
|
-
i.peek();
|
|
202
|
-
}), typeof e == "function")
|
|
203
|
-
return this._workGraph.attachProducer(s, i);
|
|
204
|
-
const o = this._attachWritableComputed(i, e.set, t);
|
|
205
|
-
return this._workGraph.attachProducer(s, o);
|
|
206
|
-
}
|
|
207
|
-
/** Low-level adapter form. Prefer consumer.effect(). */
|
|
208
|
-
effect(e, t, s, r = y) {
|
|
209
|
-
return te(
|
|
210
|
-
this._effectRegistration(e, t, s, r)
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Регистрирует один implicit phase effect. Возвращаемая регистрация является
|
|
215
|
-
* записью binding: она одновременно ресурс владельца, задача engine и элемент
|
|
216
|
-
* очереди pipeline, поэтому на effect больше ничего не выделяется. Тело
|
|
217
|
-
* записи engine у всех bindings графа одно — `RuntimeReactivity._phaseBody`:
|
|
218
|
-
* свой binding оно находит через engine, а не через собственную closure.
|
|
219
|
-
*
|
|
220
|
-
* При `taskless` тело вызывается без task: запись получает `TASK_TASKLESS`,
|
|
221
|
-
* общее тело не читает `record.task`, и frozen facade этого binding не
|
|
222
|
-
* создаётся, пока его не запросит `process` своей phase. Режим — бит поля
|
|
223
|
-
* `state`: запись от него не растёт.
|
|
224
|
-
*
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
_effectRegistration(e, t, s, r = y, i = !1, o = !1, a, n) {
|
|
228
|
-
this._assertOwnerRuntime(e);
|
|
229
|
-
const h = this._execution, u = this._validatePhaseBinding(h, t, s, r), c = h.bindTask(u, e, s, r.priority ?? 0);
|
|
230
|
-
o && (c.state = E | U);
|
|
231
|
-
const d = this._reactivity, _ = r.initial === "sync", l = _ && this.configuration.scheduler !== f.Sync;
|
|
232
|
-
let g = "Effect registration and cleanup failed.", w = !1;
|
|
233
|
-
try {
|
|
234
|
-
i && c.pause();
|
|
235
|
-
const R = d._allocateTaskEffect(d._phaseBody, c);
|
|
236
|
-
if (c.node = R, l && h._queue(c, !1), w = !0, d._requestTaskEffect(R, !l), n?.())
|
|
237
|
-
return c.dispose(), c;
|
|
238
|
-
w = !1, g = "[Raph] Resource registration and cleanup failed.", (c.state & E) !== 0 && c.node !== void 0 ? e._adoptRecord(c) : (e._assertAlive(), c.dispose()), g = "[Raph] Phase effect registration and rollback failed.", w = !0, _ ? this.flush() : this._requestExecution(), n?.() && c.dispose();
|
|
239
|
-
} catch (R) {
|
|
240
|
-
this._rollbackRegistration(
|
|
241
|
-
c,
|
|
242
|
-
R,
|
|
243
|
-
g,
|
|
244
|
-
w ? a : void 0
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
return c;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Регистрирует группу из `count` implicit phase effects на одной записи
|
|
251
|
-
* binding. Каждый slot получает собственную запись графа engine, то есть
|
|
252
|
-
* собственный набор зависимостей и собственный признак invalidation, а
|
|
253
|
-
* запись binding и её место в очереди phase и в списке ресурсов владельца у
|
|
254
|
-
* группы одни. Тело записи engine у slots то же, что у всех bindings графа.
|
|
255
|
-
* Возвращаемая регистрация — эта запись; она же handle группы.
|
|
256
|
-
*
|
|
257
|
-
* Регистрация ничего не исполняет: каждый slot запускает `_startGroupSlot`.
|
|
258
|
-
* Запись входит в список владельца сразу, поэтому владелец освобождает
|
|
259
|
-
* группу после ресурсов, которые зарегистрируют тела её slots.
|
|
260
|
-
*
|
|
261
|
-
* @internal
|
|
262
|
-
*/
|
|
263
|
-
_effectGroupRegistration(e, t, s, r, i, o = y, a = !1) {
|
|
264
|
-
this._assertOwnerRuntime(e);
|
|
265
|
-
const n = this._execution, h = r, u = this._validatePhaseBinding(n, t, h, o);
|
|
266
|
-
if (!Number.isInteger(s) || s < 1)
|
|
267
|
-
throw new RangeError("[Raph] Effect group slot count must be a positive integer.");
|
|
268
|
-
if (s > I)
|
|
269
|
-
throw new RangeError(`[Raph] Effect group slot count must not exceed ${I}.`);
|
|
270
|
-
const c = n.bindGroup(u, e, h, i, s, o.priority ?? 0);
|
|
271
|
-
try {
|
|
272
|
-
a && c.pause();
|
|
273
|
-
const d = c.group, _ = this._reactivity, l = _._phaseBody, g = k + s;
|
|
274
|
-
for (let w = k; w < g; w++)
|
|
275
|
-
d[w] = _._allocateTaskEffect(l, c);
|
|
276
|
-
e._adoptRecord(c);
|
|
277
|
-
} catch (d) {
|
|
278
|
-
this._rollbackRegistration(c, d, "[Raph] Resource registration and cleanup failed.");
|
|
279
|
-
}
|
|
280
|
-
return c;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Запускает один slot группы: планирует его запись графа, ставит запись
|
|
284
|
-
* группы в очередь и, при `initial: 'sync'`, выполняет flush. Шаги те же, что
|
|
285
|
-
* у регистрации одиночного implicit effect после создания его записи.
|
|
286
|
-
*
|
|
287
|
-
* Сбой внутри вызова останавливает только этот slot и бросается вызывающему,
|
|
288
|
-
* как сбой первой доставки откатывает регистрацию одиночного binding; группа
|
|
289
|
-
* и остальные её slots остаются. Группа, у которой остановлен последний slot,
|
|
290
|
-
* освобождается.
|
|
291
|
-
*
|
|
292
|
-
* Запуск на освобождённом владельце бросает `RaphDisposedError`, как
|
|
293
|
-
* `bindEffect()`: и когда владелец освобождён до вызова, и когда его
|
|
294
|
-
* освободила первая доставка внутри вызова, при любом scheduler. Молчит
|
|
295
|
-
* только запуск slot группы, освобождённой при живом владельце.
|
|
296
|
-
*
|
|
297
|
-
* @internal
|
|
298
|
-
*/
|
|
299
|
-
_startGroupSlot(e, t, s, r) {
|
|
300
|
-
const i = e.group;
|
|
301
|
-
if (i === void 0) {
|
|
302
|
-
e.consumerOwner._assertAlive();
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const o = t >= 0 ? i[k + t] : void 0;
|
|
306
|
-
if (o === void 0)
|
|
307
|
-
throw new RangeError(`[Raph] Effect group has no slot ${String(t)}.`);
|
|
308
|
-
if (s !== "scheduled" && s !== "sync")
|
|
309
|
-
throw new TypeError(`[Raph] Unsupported effect initial mode "${String(s)}".`);
|
|
310
|
-
if (o === null || o.firstDep !== null)
|
|
311
|
-
return;
|
|
312
|
-
const a = e.phaseState.pipeline, n = s === "sync", h = n && this.configuration.scheduler !== f.Sync;
|
|
313
|
-
let u = !1;
|
|
314
|
-
try {
|
|
315
|
-
u = !0, this._reactivity._requestTaskEffect(o, !1), h ? e.state & C || a._queue(e, !1) : e.schedule(), u = !1, e.state & (C | K) || e.consumerOwner._assertAlive(), n ? a._running ? this._executionRequested = !1 : (u = !0, this.flush(), u = !1, e.state & E || e.consumerOwner._assertAlive()) : (u = !0, this._requestExecution());
|
|
316
|
-
} catch (c) {
|
|
317
|
-
let d = c;
|
|
318
|
-
try {
|
|
319
|
-
this._reactivity._disposeTaskEffect(o);
|
|
320
|
-
} catch (_) {
|
|
321
|
-
d = new AggregateError(
|
|
322
|
-
[c, _],
|
|
323
|
-
"[Raph] Phase effect registration and rollback failed."
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
throw u && r !== void 0 && r(d), d;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
/** Low-level adapter form. Prefer consumer.watch(). */
|
|
330
|
-
watch(e, t, s, r, i = y) {
|
|
331
|
-
const o = this._watchRegistration(e, t, s, r, i).watch;
|
|
332
|
-
return o === void 0 ? re : se(o);
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Регистрирует один explicit phase watch. Возвращаемая запись binding является
|
|
336
|
-
* pausable-регистрацией и одновременно ресурсом владельца этого watch.
|
|
337
|
-
*
|
|
338
|
-
* @internal
|
|
339
|
-
*/
|
|
340
|
-
_watchRegistration(e, t, s, r, i = y, o = !1, a, n) {
|
|
341
|
-
this._assertOwnerRuntime(e);
|
|
342
|
-
const h = this._execution, u = this._validatePhaseBinding(h, s, r, i, !0);
|
|
343
|
-
this._workGraph.assertSubscriptionAllowed(e, t);
|
|
344
|
-
const c = h.bindTask(u, e, r, i.priority ?? 0), d = V((l) => this._runUntracked(l), c);
|
|
345
|
-
c.watch = d, o && c.pause();
|
|
346
|
-
try {
|
|
347
|
-
if (d.source = this._workGraph.subscribe(
|
|
348
|
-
t,
|
|
349
|
-
i.include,
|
|
350
|
-
(l, g, w) => d.record?.enqueue(l, g, w)
|
|
351
|
-
), n?.())
|
|
352
|
-
return c.dispose(), c;
|
|
353
|
-
} catch (l) {
|
|
354
|
-
throw c.dispose(), l;
|
|
355
|
-
}
|
|
356
|
-
try {
|
|
357
|
-
e._adoptRecord(c);
|
|
358
|
-
} catch (l) {
|
|
359
|
-
this._rollbackRegistration(c, l, "[Raph] Resource registration and cleanup failed.");
|
|
360
|
-
}
|
|
361
|
-
const _ = i.initial ?? "scheduled";
|
|
362
|
-
try {
|
|
363
|
-
_ !== "none" && c.schedule(), _ === "sync" && this.flush(), n?.() && c.dispose();
|
|
364
|
-
} catch (l) {
|
|
365
|
-
this._rollbackRegistration(
|
|
366
|
-
c,
|
|
367
|
-
l,
|
|
368
|
-
"[Raph] Phase watch registration and rollback failed.",
|
|
369
|
-
a
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
return c;
|
|
373
|
-
}
|
|
374
|
-
aggregate(e, t) {
|
|
375
|
-
return this._assertOwnerRuntime(e), this._workGraph.createAggregate(e, t);
|
|
376
|
-
}
|
|
377
|
-
/** Creates a lazy root-owned metadata event source for phase watches. */
|
|
378
55
|
metaSource(e, t = {}) {
|
|
379
|
-
this._assertAlive(),
|
|
380
|
-
const
|
|
56
|
+
this._assertAlive(), P(e, t);
|
|
57
|
+
const r = this._workGraph.createProducer(this.rootScope, "path"), s = this._workGraph.producerHooks(r).onDispose, a = D._create(
|
|
381
58
|
this.rootScope,
|
|
382
59
|
e,
|
|
383
60
|
t,
|
|
384
61
|
() => this.kernel._watchMeta(
|
|
385
|
-
|
|
386
|
-
({ events:
|
|
387
|
-
|
|
388
|
-
(
|
|
389
|
-
|
|
62
|
+
a.masks,
|
|
63
|
+
({ events: i }) => this._workGraph.notifyProducerEvents(r, i, !1),
|
|
64
|
+
a.options,
|
|
65
|
+
(i) => {
|
|
66
|
+
i && this._execution.request();
|
|
390
67
|
}
|
|
391
68
|
),
|
|
392
|
-
() =>
|
|
69
|
+
() => s(!1)
|
|
393
70
|
);
|
|
394
|
-
|
|
71
|
+
a._bindOwner(this.rootScope._adoptResource(() => a._disposeOwned()));
|
|
395
72
|
try {
|
|
396
|
-
return this._workGraph.setProducerActivation(
|
|
397
|
-
} catch (
|
|
73
|
+
return this._workGraph.setProducerActivation(r, () => a._activate(), !0), this._workGraph.attachProducer(r, a), a;
|
|
74
|
+
} catch (i) {
|
|
398
75
|
try {
|
|
399
|
-
|
|
400
|
-
} catch (
|
|
76
|
+
a.dispose();
|
|
77
|
+
} catch (n) {
|
|
401
78
|
throw new AggregateError(
|
|
402
|
-
[
|
|
79
|
+
[i, n],
|
|
403
80
|
"[Raph] Meta source activation and rollback failed."
|
|
404
81
|
);
|
|
405
82
|
}
|
|
406
|
-
throw
|
|
83
|
+
throw i;
|
|
407
84
|
}
|
|
408
85
|
}
|
|
409
86
|
path(e, t = {}) {
|
|
410
87
|
this._assertAlive();
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
return
|
|
414
|
-
const
|
|
88
|
+
const r = g(e, t), s = this._pathHandles ??= /* @__PURE__ */ new Map(), a = s.get(r.canonical);
|
|
89
|
+
if (a !== void 0)
|
|
90
|
+
return a;
|
|
91
|
+
const i = this._workGraph.createProducer(this.rootScope, "path"), n = this._workGraph.producerHooks(i), o = new S(
|
|
415
92
|
this.kernel,
|
|
416
|
-
|
|
93
|
+
r,
|
|
417
94
|
t,
|
|
418
95
|
(h) => this._releasePathHandle(h),
|
|
419
96
|
this._reactivity,
|
|
@@ -421,28 +98,28 @@ class T {
|
|
|
421
98
|
() => this._assertTrackedRead(),
|
|
422
99
|
this.configuration.enforceActions ? () => this._assertWriteAllowed() : void 0,
|
|
423
100
|
(h) => this._runWrite(h),
|
|
424
|
-
{ token:
|
|
425
|
-
({ events: h },
|
|
101
|
+
{ token: i, onDispose: n.onDispose },
|
|
102
|
+
({ events: h }, c) => this._workGraph.notifyProducerEvents(i, h, !0, c)
|
|
426
103
|
);
|
|
427
104
|
try {
|
|
428
|
-
return this._workGraph.setProducerActivation(
|
|
105
|
+
return this._workGraph.setProducerActivation(i, () => o._activate(), !0), this._workGraph.attachProducer(i, o), s.set(r.canonical, o), o;
|
|
429
106
|
} catch (h) {
|
|
430
|
-
let
|
|
107
|
+
let c, p = !1;
|
|
431
108
|
try {
|
|
432
|
-
|
|
433
|
-
} catch (
|
|
434
|
-
|
|
109
|
+
o.dispose();
|
|
110
|
+
} catch (f) {
|
|
111
|
+
p = !0, c = f;
|
|
435
112
|
}
|
|
436
|
-
throw
|
|
437
|
-
[h,
|
|
113
|
+
throw s.size === 0 && this._pathHandles === s && (this._pathHandles = void 0), p ? new AggregateError(
|
|
114
|
+
[h, c],
|
|
438
115
|
"[Raph] Path source activation and rollback failed."
|
|
439
116
|
) : h;
|
|
440
117
|
}
|
|
441
118
|
}
|
|
442
119
|
get(e, t) {
|
|
443
120
|
this._assertTrackedRead();
|
|
444
|
-
const
|
|
445
|
-
return this._reactivity._isTracking() ? this.path(
|
|
121
|
+
const r = e ?? "";
|
|
122
|
+
return this._reactivity._isTracking() ? this.path(r, t)._getTracked() : this.kernel.get(r, t);
|
|
446
123
|
}
|
|
447
124
|
peek(e, t) {
|
|
448
125
|
return this._assertAlive(), this.kernel.peek(e ?? "", t);
|
|
@@ -450,558 +127,25 @@ class T {
|
|
|
450
127
|
has(e, t) {
|
|
451
128
|
return this._assertAlive(), this.kernel.has(e, t);
|
|
452
129
|
}
|
|
453
|
-
set(e, t,
|
|
454
|
-
this._assertWriteAllowed(), this._runWrite(() => this.kernel.set(e, t,
|
|
130
|
+
set(e, t, r) {
|
|
131
|
+
this._assertWriteAllowed(), this._runWrite(() => this.kernel.set(e, t, r));
|
|
455
132
|
}
|
|
456
|
-
merge(e, t,
|
|
457
|
-
this._assertWriteAllowed(), this._runWrite(() => this.kernel.merge(e, t,
|
|
133
|
+
merge(e, t, r) {
|
|
134
|
+
this._assertWriteAllowed(), this._runWrite(() => this.kernel.merge(e, t, r));
|
|
458
135
|
}
|
|
459
136
|
delete(e, t) {
|
|
460
137
|
this._assertWriteAllowed(), this._runWrite(() => this.kernel.delete(e, t));
|
|
461
138
|
}
|
|
462
|
-
batch(e) {
|
|
463
|
-
return this._batch(e, !0);
|
|
464
|
-
}
|
|
465
|
-
/** Batches an internal reactive-only commit without opening an unused Kernel boundary. @internal */
|
|
466
|
-
_batchReactive(e) {
|
|
467
|
-
return this._batch(e, !1);
|
|
468
|
-
}
|
|
469
|
-
_batch(e, t) {
|
|
470
|
-
this._assertAlive(), this._batchDepth++;
|
|
471
|
-
let s, r, i = !1;
|
|
472
|
-
try {
|
|
473
|
-
s = this._reactivity.batch(() => t ? this.kernel.batch(e) : e());
|
|
474
|
-
} catch (o) {
|
|
475
|
-
i = !0, r = o;
|
|
476
|
-
}
|
|
477
|
-
return this._closeBatch(i, r), s;
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Закрывает один уровень batch: внешний уровень очищает transient causes и
|
|
481
|
-
* запускает фазы. Бросает ошибку операции, ошибки закрытия либо все вместе;
|
|
482
|
-
* после успешной операции и закрытия возвращает управление.
|
|
483
|
-
*/
|
|
484
|
-
_closeBatch(e, t) {
|
|
485
|
-
if (this._batchDepth--, this._executionBoundaryOpen()) {
|
|
486
|
-
if (e)
|
|
487
|
-
throw t;
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
const s = this._finishExecutionBoundary();
|
|
491
|
-
if (e)
|
|
492
|
-
throw s !== void 0 ? new AggregateError(
|
|
493
|
-
[t, ...s],
|
|
494
|
-
"[Raph] Batch and scheduled phase execution failed."
|
|
495
|
-
) : t;
|
|
496
|
-
s !== void 0 && m(s, "[Raph] Batch phase execution failed.");
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Исполняет тело action: `batch(() => _runUntracked(() => operation(...args)))`
|
|
500
|
-
* без closures и без промежуточных вызовов слоёв. Runtime, который один
|
|
501
|
-
* владеет своим Kernel без derived handles, metadata watchers и adapter,
|
|
502
|
-
* открывает границы reactive batch, Kernel и path batch явными вызовами и
|
|
503
|
-
* закрывает их в том же порядке и с теми же ошибками, что вложенные
|
|
504
|
-
* `batch()` этих слоёв. В любом другом состоянии исполняется сам `batch()`.
|
|
505
|
-
*/
|
|
506
|
-
_applyBatch(e, t) {
|
|
507
|
-
this._assertAlive();
|
|
508
|
-
const s = this.kernel, r = s._openSoleRuntimeBatch(this);
|
|
509
|
-
if (r === void 0)
|
|
510
|
-
return this._batch(() => this._runUntracked(() => e(...t)), !0);
|
|
511
|
-
const i = this._reactivity;
|
|
512
|
-
this._batchDepth++, i._startBatch();
|
|
513
|
-
let o, a, n = !1;
|
|
514
|
-
try {
|
|
515
|
-
o = i._applyUntrackedWithOwner(e, t);
|
|
516
|
-
} catch (h) {
|
|
517
|
-
n = !0, a = h;
|
|
518
|
-
}
|
|
519
|
-
try {
|
|
520
|
-
s._closeSoleRuntimeBatch(this, r, n, a);
|
|
521
|
-
} catch (h) {
|
|
522
|
-
n = !0, a = h;
|
|
523
|
-
}
|
|
524
|
-
try {
|
|
525
|
-
i._endBatch();
|
|
526
|
-
} catch (h) {
|
|
527
|
-
a = n ? new AggregateError([a, h], "Batch operation and effect queue processing failed.") : h, n = !0;
|
|
528
|
-
}
|
|
529
|
-
return this._closeBatch(n, a), o;
|
|
530
|
-
}
|
|
531
|
-
action(e, t, s) {
|
|
532
|
-
const r = typeof e == "function" ? e : t, i = typeof e == "function" ? t instanceof O ? t : this.rootScope : s ?? this.rootScope, o = typeof e == "string" ? e : `action#${++this._actionCounter}`;
|
|
533
|
-
if (this._assertOwnerRuntime(i), typeof r != "function")
|
|
534
|
-
throw new TypeError("[Raph] Action operation must be a function.");
|
|
535
|
-
if (!o.trim())
|
|
536
|
-
throw new Error("[Raph] Action name must not be empty.");
|
|
537
|
-
return (...a) => {
|
|
538
|
-
i._assertAlive();
|
|
539
|
-
const n = this._debugController, h = this._traceCauseStack, u = n.nextOperationId("action"), d = (h.length === 0 ? void 0 : h[h.length - 1]) ?? u;
|
|
540
|
-
n.traces("action") && n.record({
|
|
541
|
-
...d === void 0 ? {} : { causeId: d },
|
|
542
|
-
kind: "action",
|
|
543
|
-
name: o,
|
|
544
|
-
...u === void 0 ? {} : { operationId: u },
|
|
545
|
-
status: "start"
|
|
546
|
-
}), d !== void 0 && h.push(d), this._actionDepth++;
|
|
547
|
-
try {
|
|
548
|
-
const _ = this._applyBatch(r, a);
|
|
549
|
-
return n.traces("action") && n.record({
|
|
550
|
-
...d === void 0 ? {} : { causeId: d },
|
|
551
|
-
kind: "action",
|
|
552
|
-
name: o,
|
|
553
|
-
...u === void 0 ? {} : { operationId: u },
|
|
554
|
-
status: "end"
|
|
555
|
-
}), _;
|
|
556
|
-
} catch (_) {
|
|
557
|
-
throw this._debugController.record({
|
|
558
|
-
...d === void 0 ? {} : { causeId: d },
|
|
559
|
-
details: { message: x(_) },
|
|
560
|
-
kind: "action",
|
|
561
|
-
name: o,
|
|
562
|
-
...u === void 0 ? {} : { operationId: u },
|
|
563
|
-
status: "error"
|
|
564
|
-
}), this._debugController.record({
|
|
565
|
-
...d === void 0 ? {} : { causeId: d },
|
|
566
|
-
details: { message: x(_) },
|
|
567
|
-
kind: "error",
|
|
568
|
-
name: `action:${o}`,
|
|
569
|
-
...u === void 0 ? {} : { operationId: u },
|
|
570
|
-
status: "error"
|
|
571
|
-
}), _;
|
|
572
|
-
} finally {
|
|
573
|
-
this._actionDepth--, d !== void 0 && h.pop();
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
untracked(e) {
|
|
578
|
-
return this._assertAlive(), this._runUntracked(e);
|
|
579
|
-
}
|
|
580
|
-
scope(e) {
|
|
581
|
-
return this._assertAlive(), new O(e, this);
|
|
582
|
-
}
|
|
583
|
-
node(e, t) {
|
|
584
|
-
this._assertAlive(), this._enterWrite();
|
|
585
|
-
let s;
|
|
586
|
-
try {
|
|
587
|
-
s = this._createCommittedNode(e, t);
|
|
588
|
-
} catch (r) {
|
|
589
|
-
throw this._failWrite(r);
|
|
590
|
-
}
|
|
591
|
-
return this._exitWrite(), s._assertAlive(), s;
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Создаёт provisional node, выполняет setup и публикует результат; при ошибке
|
|
595
|
-
* setup откатывает node до выхода из границы mutation.
|
|
596
|
-
*/
|
|
597
|
-
_createCommittedNode(e, t) {
|
|
598
|
-
const s = e.parent ?? this.root, r = H(s, e, this);
|
|
599
|
-
try {
|
|
600
|
-
const i = t?.(r);
|
|
601
|
-
return r._assertAlive(), s._assertAlive(), r._setApi(i), r._publishCreation(), r;
|
|
602
|
-
} catch (i) {
|
|
603
|
-
try {
|
|
604
|
-
r.dispose();
|
|
605
|
-
} catch (o) {
|
|
606
|
-
throw new AggregateError([i, o], `[Raph] Node "${r.id}" setup and cleanup failed.`);
|
|
607
|
-
}
|
|
608
|
-
throw i;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
getNode(e) {
|
|
612
|
-
return this._assertAlive(), this.root._findNode(e);
|
|
613
|
-
}
|
|
614
|
-
definePhases(e) {
|
|
615
|
-
this._execution.definePhases(e);
|
|
616
|
-
}
|
|
617
|
-
addPhase(e) {
|
|
618
|
-
this._execution.addPhase(e);
|
|
619
|
-
}
|
|
620
|
-
clearPhases() {
|
|
621
|
-
this._assertAlive(), this._phases?.clearPhases();
|
|
622
|
-
}
|
|
623
|
-
requestExecution() {
|
|
624
|
-
this._assertAlive(), this._phases?.request();
|
|
625
|
-
}
|
|
626
|
-
flush() {
|
|
627
|
-
this._assertAlive(), this._executionRequested = !1, this._phases?.flush();
|
|
628
|
-
}
|
|
629
|
-
afterFlush() {
|
|
630
|
-
return this._assertAlive(), this._phases?.afterFlush() ?? Promise.resolve();
|
|
631
|
-
}
|
|
632
|
-
acquireLoop(e) {
|
|
633
|
-
return this._assertAlive(), this._clock.acquire(e);
|
|
634
|
-
}
|
|
635
|
-
startLoop() {
|
|
636
|
-
this._assertAlive(), this._clock.start();
|
|
637
|
-
}
|
|
638
|
-
stopLoop() {
|
|
639
|
-
this._frameLoop?.stop();
|
|
640
|
-
}
|
|
641
139
|
derive(e) {
|
|
642
140
|
this._assertAlive();
|
|
643
|
-
const t = e.compute,
|
|
141
|
+
const t = e.compute, r = this.kernel.derive({
|
|
644
142
|
...e,
|
|
645
|
-
compute: (
|
|
646
|
-
});
|
|
647
|
-
return this._own(() => s.dispose(), this.rootScope), s;
|
|
648
|
-
}
|
|
649
|
-
dispose() {
|
|
650
|
-
if (this._disposed)
|
|
651
|
-
return;
|
|
652
|
-
this._disposed = !0, this._executionRequested = !1, this._signalLifecycle.owner = void 0;
|
|
653
|
-
const e = [];
|
|
654
|
-
try {
|
|
655
|
-
this._frameLoop?.dispose();
|
|
656
|
-
} catch (a) {
|
|
657
|
-
e.push(a);
|
|
658
|
-
}
|
|
659
|
-
this._frameLoop = void 0;
|
|
660
|
-
try {
|
|
661
|
-
this._phases?.dispose();
|
|
662
|
-
} catch (a) {
|
|
663
|
-
e.push(a);
|
|
664
|
-
}
|
|
665
|
-
this._phases = void 0;
|
|
666
|
-
try {
|
|
667
|
-
this.root.dispose();
|
|
668
|
-
} catch (a) {
|
|
669
|
-
e.push(a);
|
|
670
|
-
}
|
|
671
|
-
const t = this._collectOwners().sort(ie);
|
|
672
|
-
for (const a of t)
|
|
673
|
-
if (!(a === this.root || a === this.rootScope || a.disposed))
|
|
674
|
-
try {
|
|
675
|
-
a.dispose();
|
|
676
|
-
} catch (n) {
|
|
677
|
-
e.push(n);
|
|
678
|
-
}
|
|
679
|
-
try {
|
|
680
|
-
this.rootScope.dispose();
|
|
681
|
-
} catch (a) {
|
|
682
|
-
e.push(a);
|
|
683
|
-
}
|
|
684
|
-
const s = `[Raph] Runtime "${this.id}" is disposed.`, r = () => {
|
|
685
|
-
throw new A(s);
|
|
686
|
-
};
|
|
687
|
-
try {
|
|
688
|
-
L(this._reactivity, {
|
|
689
|
-
assertRead: r,
|
|
690
|
-
assertWrite: r,
|
|
691
|
-
throwForeign: r
|
|
692
|
-
});
|
|
693
|
-
} catch (a) {
|
|
694
|
-
e.push(a);
|
|
695
|
-
}
|
|
696
|
-
this._topOwners.clear(), this._ownersReleased = !0, this._meta = void 0;
|
|
697
|
-
const i = this._pathHandles;
|
|
698
|
-
if (this._pathHandles = void 0, i !== void 0) {
|
|
699
|
-
for (const a of i.values())
|
|
700
|
-
try {
|
|
701
|
-
a.dispose();
|
|
702
|
-
} catch (n) {
|
|
703
|
-
e.push(n);
|
|
704
|
-
}
|
|
705
|
-
i.clear();
|
|
706
|
-
}
|
|
707
|
-
try {
|
|
708
|
-
this._workGraph.dispose();
|
|
709
|
-
} catch (a) {
|
|
710
|
-
e.push(a);
|
|
711
|
-
}
|
|
712
|
-
try {
|
|
713
|
-
this.kernel._detachRuntime(this);
|
|
714
|
-
} catch (a) {
|
|
715
|
-
e.push(a);
|
|
716
|
-
}
|
|
717
|
-
const o = [...this._disposedListeners];
|
|
718
|
-
this._disposedListeners.clear();
|
|
719
|
-
for (const a of o)
|
|
720
|
-
try {
|
|
721
|
-
a();
|
|
722
|
-
} catch (n) {
|
|
723
|
-
e.push(n);
|
|
724
|
-
}
|
|
725
|
-
m(e, `[Raph] Runtime "${this.id}" disposal failed.`);
|
|
726
|
-
}
|
|
727
|
-
/** @internal */
|
|
728
|
-
_onDisposed(e) {
|
|
729
|
-
return this._disposed ? (e(), () => {
|
|
730
|
-
}) : (this._disposedListeners.add(e), () => {
|
|
731
|
-
this._disposedListeners.delete(e);
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
/** @internal */
|
|
735
|
-
_notifyNodeStructure(e, t, s, r) {
|
|
736
|
-
if (!this._workGraph._hasStructuralDemand(e)) {
|
|
737
|
-
this._touchMutationBoundary();
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
this._runNodeMutation(() => {
|
|
741
|
-
this._workGraph.notifyNode(e, "structure", { structure: t, oldAncestors: s, newAncestors: r });
|
|
143
|
+
compute: (s) => this._runUntracked(() => t(s))
|
|
742
144
|
});
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Сообщает, может ли structural publication этой node дойти до подписчика;
|
|
746
|
-
* `false` позволяет не строить structure cause и списки ancestors.
|
|
747
|
-
*
|
|
748
|
-
* @internal
|
|
749
|
-
*/
|
|
750
|
-
_hasNodeStructureDemand(e) {
|
|
751
|
-
return this._workGraph._hasStructuralDemand(e);
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* Сообщает, есть ли у Runtime хотя бы один подписчик на node: runtime-,
|
|
755
|
-
* subtree- или self-watcher. Пока он есть, node поддерживает выданный массив
|
|
756
|
-
* детей на месте, потому что structure cause берёт из него индексы.
|
|
757
|
-
*
|
|
758
|
-
* @internal
|
|
759
|
-
*/
|
|
760
|
-
_hasNodeSubscribers() {
|
|
761
|
-
return this._workGraph._hasNodeSubscribers();
|
|
762
|
-
}
|
|
763
|
-
/** @internal */
|
|
764
|
-
_notifyNodeTouch(e, t) {
|
|
765
|
-
this._runNodeMutation(() => this._workGraph.notifyNode(e, "touch", { metadata: t }));
|
|
766
|
-
}
|
|
767
|
-
/** @internal */
|
|
768
|
-
_assertNodeReparentAllowed(e, t) {
|
|
769
|
-
this._workGraph.assertReparentAllowed(e, t);
|
|
770
|
-
}
|
|
771
|
-
/** @internal */
|
|
772
|
-
_releaseNode(e) {
|
|
773
|
-
this._workGraph.releaseNode(e);
|
|
774
|
-
}
|
|
775
|
-
/** @internal */
|
|
776
|
-
_runNodeMutation(e) {
|
|
777
|
-
return this._runWrite(e);
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Выполняет границу пустой node mutation без аллокаций: эквивалент
|
|
781
|
-
* `_runWrite(noop)` с тем же запросом исполнения и flush на внешней границе.
|
|
782
|
-
*
|
|
783
|
-
* @internal
|
|
784
|
-
*/
|
|
785
|
-
_touchMutationBoundary() {
|
|
786
|
-
if (this.configuration.scheduler === f.Sync && (this._executionRequested = !0), this._executionBoundaryOpen())
|
|
787
|
-
return;
|
|
788
|
-
const e = this._finishExecutionBoundary();
|
|
789
|
-
e !== void 0 && m(e, "[Raph] Mutation phase execution failed.");
|
|
790
|
-
}
|
|
791
|
-
/** @internal */
|
|
792
|
-
_runPhaseTransition(e) {
|
|
793
|
-
return this._runWrite(e, !1);
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Открывает границу освобождения. `node` передаёт только dispose самой node:
|
|
797
|
-
* Runtime помнит её до парного `_endOwnerDisposal`.
|
|
798
|
-
*
|
|
799
|
-
* @internal
|
|
800
|
-
*/
|
|
801
|
-
_beginOwnerDisposal(e) {
|
|
802
|
-
this._disposingNodes[this._ownerDisposalDepth++] = e;
|
|
803
|
-
}
|
|
804
|
-
/** @internal */
|
|
805
|
-
_endOwnerDisposal() {
|
|
806
|
-
const e = this._ownerDisposalDepth;
|
|
807
|
-
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());
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* Возвращает число владельцев, освобождённых этим Runtime за всё время.
|
|
811
|
-
*
|
|
812
|
-
* @internal
|
|
813
|
-
*/
|
|
814
|
-
_ownerDisposalCount() {
|
|
815
|
-
return this._ownerDisposals;
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* Подключает участника уборки: Runtime вызовет его на первой внешней границе
|
|
819
|
-
* освобождения, к которой число освобождённых владельцев достигнет `due`.
|
|
820
|
-
* Подключённый участник остаётся в очереди, пока сам не откажется от
|
|
821
|
-
* следующего срока либо не будет отключён.
|
|
822
|
-
*
|
|
823
|
-
* @internal
|
|
824
|
-
*/
|
|
825
|
-
_addDisposalSweeper(e, t) {
|
|
826
|
-
const s = this._disposalSweepers;
|
|
827
|
-
if (s === void 0) {
|
|
828
|
-
e._sweepSlot = 0, e._sweepDue = t, this._disposalSweepers = [e], this._nextDisposalSweep = t;
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
Y(s, e, t), this._nextDisposalSweep = s[0]._sweepDue;
|
|
832
|
-
}
|
|
833
|
-
/**
|
|
834
|
-
* Отключает участника уборки; отключение неизвестного участника безопасно.
|
|
835
|
-
*
|
|
836
|
-
* @internal
|
|
837
|
-
*/
|
|
838
|
-
_removeDisposalSweeper(e) {
|
|
839
|
-
const t = this._disposalSweepers;
|
|
840
|
-
t === void 0 || !P(t, e) || (t.length === 0 ? (this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY) : this._nextDisposalSweep = t[0]._sweepDue);
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Вызывает участников уборки, чей срок подошёл, и назначает ближайший
|
|
844
|
-
* следующий срок. Участник, чей срок не подошёл, вызова не получает:
|
|
845
|
-
* освобождение владельца стоит участникам работы, только когда подходит их
|
|
846
|
-
* собственный срок.
|
|
847
|
-
*/
|
|
848
|
-
_sweepAfterDisposals() {
|
|
849
|
-
const e = this._disposalSweepers;
|
|
850
|
-
if (e === void 0)
|
|
851
|
-
return;
|
|
852
|
-
const t = this._ownerDisposals;
|
|
853
|
-
if (e.length === 1) {
|
|
854
|
-
const s = e[0], r = s._afterOwnerDisposals(t);
|
|
855
|
-
r > t ? (s._sweepDue = r, this._nextDisposalSweep = r) : (s._sweepSlot = -1, this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
for (let s = e[0]; s._sweepDue <= t; s = e[0]) {
|
|
859
|
-
const r = s._afterOwnerDisposals(t);
|
|
860
|
-
if (r > t)
|
|
861
|
-
Q(e, r);
|
|
862
|
-
else if (P(e, s), e.length === 0) {
|
|
863
|
-
this._disposalSweepers = void 0, this._nextDisposalSweep = Number.POSITIVE_INFINITY;
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
this._nextDisposalSweep = e[0]._sweepDue;
|
|
868
|
-
}
|
|
869
|
-
/** @internal */
|
|
870
|
-
_ownerDisposalActive() {
|
|
871
|
-
return this._ownerDisposalDepth !== 0;
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Учитывает нового владельца и возвращает его порядковый номер регистрации.
|
|
875
|
-
* Plain scope сразу входит в набор владельцев вне списков детей; node входит
|
|
876
|
-
* в него сама через `_addTopOwner`, и только если у неё нет parent.
|
|
877
|
-
*
|
|
878
|
-
* @internal
|
|
879
|
-
*/
|
|
880
|
-
_registerOwner(e) {
|
|
881
|
-
return this._assertAlive(), e._isNode || this._topOwners.add(e), ++this._ownerRegistrations;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Снимает владельца с учёта. Plain scope выходит и из набора владельцев вне
|
|
885
|
-
* списков детей; node без parent выходит из него сама через
|
|
886
|
-
* `_removeTopOwner`, а node с parent в нём не состоит.
|
|
887
|
-
*
|
|
888
|
-
* @internal
|
|
889
|
-
*/
|
|
890
|
-
_unregisterOwner(e) {
|
|
891
|
-
e._isNode || this._topOwners.delete(e), this._ownerDisposals++;
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Вносит node без parent в набор владельцев вне списков детей.
|
|
895
|
-
*
|
|
896
|
-
* @internal
|
|
897
|
-
*/
|
|
898
|
-
_addTopOwner(e) {
|
|
899
|
-
this._topOwners.add(e);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Убирает node из набора владельцев вне списков детей: она освобождена либо
|
|
903
|
-
* получила parent. Повторный вызов и вызов после освобождения Runtime
|
|
904
|
-
* безопасны.
|
|
905
|
-
*
|
|
906
|
-
* @internal
|
|
907
|
-
*/
|
|
908
|
-
_removeTopOwner(e) {
|
|
909
|
-
this._topOwners.delete(e);
|
|
910
|
-
}
|
|
911
|
-
/** @internal */
|
|
912
|
-
_assertOwnerRuntime(e) {
|
|
913
|
-
if (this._assertAlive(), e.runtime !== this)
|
|
914
|
-
throw new b("[Raph] Owner belongs to another runtime.");
|
|
915
|
-
e._assertAlive();
|
|
916
|
-
}
|
|
917
|
-
/** @internal */
|
|
918
|
-
_beginKernelBatch() {
|
|
919
|
-
this._disposed || this._kernelBatchDepth++;
|
|
920
|
-
}
|
|
921
|
-
/** @internal */
|
|
922
|
-
_endKernelBatch() {
|
|
923
|
-
this._kernelBatchDepth !== 0 && (this._kernelBatchDepth--, this._clearTransientCausesIfSettled(), this._disposed || this._requestExecution());
|
|
924
|
-
}
|
|
925
|
-
/** Регистрирует read-only diagnostics projection optional Machine. @internal */
|
|
926
|
-
_registerMachineDebug(e) {
|
|
927
|
-
return this._assertAlive(), this._debugController.registerMachine(e);
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Проверяет optional diagnostic identity без создания public facade.
|
|
931
|
-
*
|
|
932
|
-
* @internal
|
|
933
|
-
*/
|
|
934
|
-
_hasMachineDebug(e) {
|
|
935
|
-
return this._debugController.hasMachine(e);
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* Проверяет optional trace path без выделения operation ID.
|
|
939
|
-
*
|
|
940
|
-
* @internal
|
|
941
|
-
*/
|
|
942
|
-
_traces(e) {
|
|
943
|
-
return this._debugController.traces(e);
|
|
944
|
-
}
|
|
945
|
-
/** Возвращает наследуемый cause для optional execution layers. @internal */
|
|
946
|
-
_currentTraceCauseId() {
|
|
947
|
-
return this._traceCauseStack.at(-1);
|
|
948
|
-
}
|
|
949
|
-
/** Выдаёт operation id только на активном trace path. @internal */
|
|
950
|
-
_nextTraceOperation(e) {
|
|
951
|
-
return this._debugController.nextOperationId(e);
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Проверяет, должен ли untracked work изолировать reactive или Runtime owner context.
|
|
955
|
-
*
|
|
956
|
-
* @internal
|
|
957
|
-
*/
|
|
958
|
-
_hasActiveReactiveContext() {
|
|
959
|
-
return this._assertAlive(), this._reactivity.hasActiveContext();
|
|
960
|
-
}
|
|
961
|
-
/** Записывает optional trace event без machine dependency. @internal */
|
|
962
|
-
_recordTrace(e) {
|
|
963
|
-
this._debugController.record(e);
|
|
964
|
-
}
|
|
965
|
-
/** Наследует cause через outputs/tasks optional execution layers. @internal */
|
|
966
|
-
_runWithTraceCause(e, t) {
|
|
967
|
-
if (e === void 0)
|
|
968
|
-
return t();
|
|
969
|
-
this._traceCauseStack.push(e);
|
|
970
|
-
try {
|
|
971
|
-
return t();
|
|
972
|
-
} finally {
|
|
973
|
-
this._traceCauseStack.pop();
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Выполняет единственную проверку binding: pipeline доверяет её результату.
|
|
978
|
-
*/
|
|
979
|
-
_validatePhaseBinding(e, t, s, r, i = !1) {
|
|
980
|
-
if (typeof s != "function")
|
|
981
|
-
throw new TypeError("[Raph] Phase callback must be a function.");
|
|
982
|
-
const o = e.resolvePhase(t), a = r.priority ?? 0;
|
|
983
|
-
if (!Number.isFinite(a))
|
|
984
|
-
throw new TypeError("[Raph] Effect priority must be finite.");
|
|
985
|
-
const n = r.initial ?? "scheduled";
|
|
986
|
-
if (n !== "scheduled" && n !== "sync" && !(i && n === "none"))
|
|
987
|
-
throw new TypeError(`[Raph] Unsupported effect initial mode "${String(n)}".`);
|
|
988
|
-
return o;
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* Освобождает binding, регистрация которого не удалась, и повторно бросает
|
|
992
|
-
* причину сбоя; ошибка самого освобождения присоединяется к ней.
|
|
993
|
-
*/
|
|
994
|
-
_rollbackRegistration(e, t, s, r) {
|
|
995
|
-
let i = t;
|
|
996
|
-
try {
|
|
997
|
-
e.dispose();
|
|
998
|
-
} catch (o) {
|
|
999
|
-
i = new AggregateError([t, o], s);
|
|
1000
|
-
}
|
|
1001
|
-
throw r !== void 0 && r(i), i;
|
|
145
|
+
return this._own(() => r.dispose(), this.rootScope), r;
|
|
1002
146
|
}
|
|
1003
147
|
_createDebugSnapshot() {
|
|
1004
|
-
const e = this._frameLoop?._debugState() ?? { running: !1, manual: !1, leases: 0 }, t = [...this._topOwners].filter((
|
|
148
|
+
const e = this._frameLoop?._debugState() ?? { running: !1, manual: !1, leases: 0 }, t = [...this._topOwners].filter((r) => r !== this.rootScope && !(r instanceof _)).map(l);
|
|
1005
149
|
return Object.freeze({
|
|
1006
150
|
id: this.id,
|
|
1007
151
|
disposed: this._disposed,
|
|
@@ -1010,9 +154,9 @@ class T {
|
|
|
1010
154
|
kernelBatchDepth: this._kernelBatchDepth,
|
|
1011
155
|
owners: this._liveOwnerCount(),
|
|
1012
156
|
pathHandles: this._pathHandles?.size ?? 0,
|
|
1013
|
-
rootScope:
|
|
157
|
+
rootScope: l(this.rootScope),
|
|
1014
158
|
scopes: Object.freeze(t),
|
|
1015
|
-
root:
|
|
159
|
+
root: l(this.root),
|
|
1016
160
|
frameLoop: Object.freeze(e),
|
|
1017
161
|
actionDepth: this._actionDepth,
|
|
1018
162
|
machines: this._debugController.machineCount,
|
|
@@ -1021,9 +165,9 @@ class T {
|
|
|
1021
165
|
}
|
|
1022
166
|
_createDebugTree() {
|
|
1023
167
|
const e = this._debugController.machineTreeNodesByOwner(), t = [
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
...[...this._topOwners].filter((
|
|
168
|
+
u(this.rootScope, e),
|
|
169
|
+
u(this.root, e),
|
|
170
|
+
...[...this._topOwners].filter((r) => r !== this.rootScope && r !== this.root && !(r instanceof _)).map((r) => u(r, e))
|
|
1027
171
|
];
|
|
1028
172
|
return Object.freeze({
|
|
1029
173
|
children: Object.freeze(t),
|
|
@@ -1035,15 +179,15 @@ class T {
|
|
|
1035
179
|
_createDebugStats() {
|
|
1036
180
|
const e = this._liveOwnerCount();
|
|
1037
181
|
let t = 0;
|
|
1038
|
-
const
|
|
182
|
+
const r = { resources: 0, sources: 0 };
|
|
1039
183
|
if (!this._ownersReleased) {
|
|
1040
|
-
const
|
|
1041
|
-
for (const
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1044
|
-
for (let
|
|
1045
|
-
const
|
|
1046
|
-
|
|
184
|
+
const s = this._topOwners;
|
|
185
|
+
for (const n of s)
|
|
186
|
+
n._isNode ? n._countSubtree(r) : (t++, r.resources += n._debugResourceCount(), r.sources += n._debugSourceCount());
|
|
187
|
+
const a = this._disposingNodes, i = this._ownerDisposalDepth;
|
|
188
|
+
for (let n = 0; n < i; n++) {
|
|
189
|
+
const o = a[n];
|
|
190
|
+
o === void 0 || o._isLinked() || s.has(o) || o._countSubtree(r);
|
|
1047
191
|
}
|
|
1048
192
|
}
|
|
1049
193
|
return Object.freeze({
|
|
@@ -1054,279 +198,74 @@ class T {
|
|
|
1054
198
|
owners: e,
|
|
1055
199
|
pathHandles: this._pathHandles?.size ?? 0,
|
|
1056
200
|
pending: !this._disposed && (this._executionRequested || (this._phases?._debugPending() ?? !1)),
|
|
1057
|
-
resources:
|
|
201
|
+
resources: r.resources,
|
|
1058
202
|
scopes: t,
|
|
1059
|
-
sources:
|
|
203
|
+
sources: r.sources,
|
|
1060
204
|
traceEvents: this._debugController.traceSize
|
|
1061
205
|
});
|
|
1062
206
|
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Возвращает число владельцев, которых Runtime числит живыми: зарегистрированных
|
|
1065
|
-
* и ещё не снятых с учёта. После освобождения Runtime их нет.
|
|
1066
|
-
*/
|
|
1067
|
-
_liveOwnerCount() {
|
|
1068
|
-
return this._ownersReleased ? 0 : this._ownerRegistrations - this._ownerDisposals;
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Собирает всех владельцев, которых Runtime числит живыми. Владельцы вне
|
|
1072
|
-
* списков детей идут в порядке регистрации, каждый — вместе с потомками по
|
|
1073
|
-
* спискам детей. Node, чей dispose ещё исполняется, из списка parent уже
|
|
1074
|
-
* вышла либо потеряла parent, который сбросил свой список: её и оставшихся
|
|
1075
|
-
* у неё детей добавляют места границ освобождения.
|
|
1076
|
-
*/
|
|
1077
|
-
_collectOwners() {
|
|
1078
|
-
const e = [];
|
|
1079
|
-
if (this._ownersReleased)
|
|
1080
|
-
return e;
|
|
1081
|
-
const t = this._topOwners;
|
|
1082
|
-
for (const i of t)
|
|
1083
|
-
e.push(i), i._isNode && i._collectDescendants(e);
|
|
1084
|
-
const s = this._disposingNodes, r = this._ownerDisposalDepth;
|
|
1085
|
-
for (let i = 0; i < r; i++) {
|
|
1086
|
-
const o = s[i];
|
|
1087
|
-
o === void 0 || o._isLinked() || t.has(o) || (e.push(o), o._collectDescendants(e));
|
|
1088
|
-
}
|
|
1089
|
-
return e;
|
|
1090
|
-
}
|
|
1091
207
|
_releasePathHandle(e) {
|
|
1092
208
|
const t = this._pathHandles;
|
|
1093
209
|
t?.get(e.path) === e && (t.delete(e.path), t.size === 0 && (this._pathHandles = void 0));
|
|
1094
210
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
},
|
|
1104
|
-
(e, t, s) => {
|
|
1105
|
-
if (this._phaseTraceOperations === void 0 && !this._debugController.traces("phase"))
|
|
1106
|
-
return;
|
|
1107
|
-
let r;
|
|
1108
|
-
t === "start" ? (r = this._debugController.nextOperationId("phase"), r !== void 0 && (this._phaseTraceOperations ??= /* @__PURE__ */ new Map()).set(e, r)) : (r = this._phaseTraceOperations?.get(e), this._phaseTraceOperations?.delete(e), this._phaseTraceOperations?.size === 0 && (this._phaseTraceOperations = void 0)), this._debugController.record({
|
|
1109
|
-
...r === void 0 ? {} : { causeId: r },
|
|
1110
|
-
...s === void 0 ? {} : { details: { message: x(s) } },
|
|
1111
|
-
kind: "phase",
|
|
1112
|
-
name: e,
|
|
1113
|
-
...r === void 0 ? {} : { operationId: r },
|
|
1114
|
-
status: t
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
);
|
|
1118
|
-
}
|
|
1119
|
-
get _clock() {
|
|
1120
|
-
return this._frameLoop ??= new z(() => this._tickFrameLoop());
|
|
1121
|
-
}
|
|
1122
|
-
_tickFrameLoop() {
|
|
1123
|
-
this._disposed || this._setFrameTick(this._frameTickSignal.peek() + 1);
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Записывает frame signal в собственной границе записи, минуя политику
|
|
1127
|
-
* actions: кадр продвигает сам Runtime.
|
|
1128
|
-
*/
|
|
1129
|
-
_setFrameTick(e) {
|
|
1130
|
-
this._enterWrite();
|
|
211
|
+
_applyBatch(e, t, r) {
|
|
212
|
+
this._assertAlive();
|
|
213
|
+
const s = this.kernel, a = s._openSoleRuntimeBatch(this);
|
|
214
|
+
if (a === void 0)
|
|
215
|
+
return this._batch(() => this._runUntracked(() => Reflect.apply(e, r, t)), !0);
|
|
216
|
+
const i = this._reactivity;
|
|
217
|
+
this._batchDepth++, i._startBatch();
|
|
218
|
+
let n, o, h = !1;
|
|
1131
219
|
try {
|
|
1132
|
-
|
|
1133
|
-
} catch (
|
|
1134
|
-
|
|
220
|
+
n = i._applyUntrackedWithOwner(e, t, r);
|
|
221
|
+
} catch (c) {
|
|
222
|
+
h = !0, o = c;
|
|
1135
223
|
}
|
|
1136
|
-
this._exitWrite();
|
|
1137
|
-
}
|
|
1138
|
-
_attachWritableComputed(e, t, s) {
|
|
1139
|
-
let r = t;
|
|
1140
|
-
this._own(() => {
|
|
1141
|
-
r = void 0;
|
|
1142
|
-
}, s);
|
|
1143
|
-
const i = e;
|
|
1144
|
-
return i.set = (o) => {
|
|
1145
|
-
s._assertAlive(), this._assertWriteAllowed(), this._runWrite(() => r(o));
|
|
1146
|
-
}, i;
|
|
1147
|
-
}
|
|
1148
|
-
_own(e, t) {
|
|
1149
224
|
try {
|
|
1150
|
-
|
|
1151
|
-
} catch (
|
|
1152
|
-
|
|
1153
|
-
e();
|
|
1154
|
-
} catch (r) {
|
|
1155
|
-
throw new AggregateError([s, r], "[Raph] Resource registration and cleanup failed.");
|
|
1156
|
-
}
|
|
1157
|
-
throw s;
|
|
225
|
+
s._closeSoleRuntimeBatch(this, a, h, o);
|
|
226
|
+
} catch (c) {
|
|
227
|
+
h = !0, o = c;
|
|
1158
228
|
}
|
|
1159
|
-
}
|
|
1160
|
-
_runTracked(e, t) {
|
|
1161
|
-
return this._reactivity.runWithOwner(this._signalLifecycle, e, t);
|
|
1162
|
-
}
|
|
1163
|
-
_runUntracked(e) {
|
|
1164
|
-
return this._reactivity.untrackedWithOwner(e);
|
|
1165
|
-
}
|
|
1166
|
-
_runWrite(e, t = !0) {
|
|
1167
|
-
t && this.configuration.scheduler === f.Sync && (this._executionRequested = !0), this._mutationDepth++;
|
|
1168
|
-
let s, r, i = !1;
|
|
1169
229
|
try {
|
|
1170
|
-
|
|
1171
|
-
} catch (
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
if (this._mutationDepth--, this._executionBoundaryOpen()) {
|
|
1175
|
-
if (i)
|
|
1176
|
-
throw r;
|
|
1177
|
-
return s;
|
|
230
|
+
i._endBatch();
|
|
231
|
+
} catch (c) {
|
|
232
|
+
o = h ? new AggregateError([o, c], "Batch operation and effect queue processing failed.") : c, h = !0;
|
|
1178
233
|
}
|
|
1179
|
-
|
|
1180
|
-
if (i)
|
|
1181
|
-
throw o !== void 0 ? new AggregateError(
|
|
1182
|
-
[r, ...o],
|
|
1183
|
-
"[Raph] Mutation and scheduled phase execution failed."
|
|
1184
|
-
) : r;
|
|
1185
|
-
return o !== void 0 && m(o, "[Raph] Mutation phase execution failed."), s;
|
|
234
|
+
return this._closeBatch(h, o), n;
|
|
1186
235
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
*
|
|
1190
|
-
* @internal
|
|
1191
|
-
*/
|
|
1192
|
-
_enterWrite() {
|
|
1193
|
-
this.configuration.scheduler === f.Sync && (this._executionRequested = !0), this._mutationDepth++;
|
|
1194
|
-
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Закрывает успешную запись, открытую `_enterWrite`; внешняя граница очищает
|
|
1197
|
-
* transient causes и запускает фазы с теми же ошибками, что и `_runWrite`.
|
|
1198
|
-
*
|
|
1199
|
-
* @internal
|
|
1200
|
-
*/
|
|
1201
|
-
_exitWrite() {
|
|
1202
|
-
if (this._mutationDepth--, this._executionBoundaryOpen())
|
|
1203
|
-
return;
|
|
1204
|
-
const e = this._finishExecutionBoundary();
|
|
1205
|
-
e !== void 0 && m(e, "[Raph] Mutation phase execution failed.");
|
|
1206
|
-
}
|
|
1207
|
-
/**
|
|
1208
|
-
* Закрывает запись после ошибки операции и возвращает ошибку для throw:
|
|
1209
|
-
* исходную либо AggregateError, если упало и закрытие внешней границы.
|
|
1210
|
-
*
|
|
1211
|
-
* @internal
|
|
1212
|
-
*/
|
|
1213
|
-
_failWrite(e) {
|
|
1214
|
-
if (this._mutationDepth--, this._executionBoundaryOpen())
|
|
1215
|
-
return e;
|
|
1216
|
-
const t = this._finishExecutionBoundary();
|
|
1217
|
-
return t === void 0 ? e : new AggregateError(
|
|
1218
|
-
[e, ...t],
|
|
1219
|
-
"[Raph] Mutation and scheduled phase execution failed."
|
|
1220
|
-
);
|
|
236
|
+
_runDataBatch(e) {
|
|
237
|
+
return this.kernel.batch(e);
|
|
1221
238
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
try {
|
|
1234
|
-
this._clearTransientCausesIfSettled();
|
|
1235
|
-
} catch (t) {
|
|
1236
|
-
e = [t];
|
|
239
|
+
_disposeDataSources(e) {
|
|
240
|
+
this._meta = void 0;
|
|
241
|
+
const t = this._pathHandles;
|
|
242
|
+
if (this._pathHandles = void 0, t !== void 0) {
|
|
243
|
+
for (const r of t.values())
|
|
244
|
+
try {
|
|
245
|
+
r.dispose();
|
|
246
|
+
} catch (s) {
|
|
247
|
+
e.push(s);
|
|
248
|
+
}
|
|
249
|
+
t.clear();
|
|
1237
250
|
}
|
|
251
|
+
}
|
|
252
|
+
_detachDataPlane(e) {
|
|
1238
253
|
try {
|
|
1239
|
-
this.
|
|
254
|
+
this.kernel._detachRuntime(this);
|
|
1240
255
|
} catch (t) {
|
|
1241
|
-
e
|
|
256
|
+
e.push(t);
|
|
1242
257
|
}
|
|
1243
|
-
return e;
|
|
1244
|
-
}
|
|
1245
|
-
_clearTransientCausesIfSettled() {
|
|
1246
|
-
this._mutationDepth === 0 && this._batchDepth === 0 && this._kernelBatchDepth === 0 && this._ownerDisposalDepth === 0 && !this._reactivity._isFlushingEffects() && this._workGraph.clearTransientCauses();
|
|
1247
|
-
}
|
|
1248
|
-
_requestExecution() {
|
|
1249
|
-
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());
|
|
1250
|
-
}
|
|
1251
|
-
_assertTrackedRead() {
|
|
1252
|
-
this._assertAlive();
|
|
1253
|
-
const e = this._reactivity.getActiveOwner();
|
|
1254
|
-
e !== void 0 && e !== this && this._throwCrossRuntime(e);
|
|
1255
|
-
const t = this._reactivity.getActiveConsumerOwner();
|
|
1256
|
-
t !== void 0 && this._assertImplicitDependency(this.rootScope, t);
|
|
1257
|
-
}
|
|
1258
|
-
/**
|
|
1259
|
-
* Проверяет tracked read из optional owned source.
|
|
1260
|
-
*
|
|
1261
|
-
* @internal
|
|
1262
|
-
*/
|
|
1263
|
-
_assertSourceReadable(e) {
|
|
1264
|
-
this._assertAlive();
|
|
1265
|
-
const t = this._reactivity.getActiveOwner();
|
|
1266
|
-
t !== void 0 && t !== this && this._throwCrossRuntime(t);
|
|
1267
|
-
const s = this._reactivity.getActiveConsumerOwner();
|
|
1268
|
-
s !== void 0 && this._assertImplicitDependency(e, s), e._assertAlive();
|
|
1269
|
-
}
|
|
1270
|
-
_assertImplicitDependency(e, t) {
|
|
1271
|
-
if (e.runtime !== this || t.runtime !== this)
|
|
1272
|
-
throw new b("[Raph] Implicit dependency crosses runtime boundaries.");
|
|
1273
|
-
if (!(e === this.rootScope || e === t)) {
|
|
1274
|
-
if (e instanceof v && t instanceof v) {
|
|
1275
|
-
for (let s = t.parent; s !== null; s = s.parent)
|
|
1276
|
-
if (s === e)
|
|
1277
|
-
return;
|
|
1278
|
-
}
|
|
1279
|
-
throw new Error(
|
|
1280
|
-
`[Raph] Implicit dependency from "${t.id}" to "${e.id}" is not allowed; use watch().`
|
|
1281
|
-
);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
_assertWriteAllowed() {
|
|
1285
|
-
if (this._assertAlive(), this.configuration.enforceActions && this._batchDepth === 0)
|
|
1286
|
-
throw new F("[Raph] Writes are allowed only inside action() or batch().");
|
|
1287
|
-
}
|
|
1288
|
-
_throwCrossRuntime(e) {
|
|
1289
|
-
throw new b(
|
|
1290
|
-
`[Raph] Runtime "${this.id}" cannot be tracked by runtime "${e.id}".`
|
|
1291
|
-
);
|
|
1292
|
-
}
|
|
1293
|
-
_assertAlive() {
|
|
1294
|
-
if (this._disposed)
|
|
1295
|
-
throw new A(`[Raph] Runtime "${this.id}" is disposed.`);
|
|
1296
258
|
}
|
|
1297
259
|
}
|
|
1298
|
-
function
|
|
1299
|
-
|
|
1300
|
-
return () => {
|
|
1301
|
-
const t = e;
|
|
1302
|
-
t !== void 0 && (e = void 0, t.dispose());
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
function se(p) {
|
|
1306
|
-
return () => {
|
|
1307
|
-
p.record?.dispose();
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
function re() {
|
|
1311
|
-
}
|
|
1312
|
-
function ie(p, e) {
|
|
1313
|
-
return e._order - p._order;
|
|
1314
|
-
}
|
|
1315
|
-
function oe(p) {
|
|
1316
|
-
return p === f.Sync || p === f.Microtask || p === f.AnimationFrame;
|
|
1317
|
-
}
|
|
1318
|
-
function ae(p, e) {
|
|
1319
|
-
const t = Array.isArray(p) ? p : [p];
|
|
260
|
+
function P(d, e) {
|
|
261
|
+
const t = Array.isArray(d) ? d : [d];
|
|
1320
262
|
if (t.length === 0)
|
|
1321
263
|
throw new TypeError("[RaphMeta] watch requires at least one mask.");
|
|
1322
264
|
if (e.namespace !== void 0 && !e.namespace.trim())
|
|
1323
265
|
throw new Error("[RaphMeta] namespace must not be empty.");
|
|
1324
|
-
for (const
|
|
1325
|
-
|
|
1326
|
-
}
|
|
1327
|
-
function x(p) {
|
|
1328
|
-
return p instanceof Error ? p.message : String(p);
|
|
266
|
+
for (const r of t)
|
|
267
|
+
m.from(r, e)._asMask();
|
|
1329
268
|
}
|
|
1330
269
|
export {
|
|
1331
|
-
|
|
270
|
+
x as RaphRuntime
|
|
1332
271
|
};
|