@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.
- 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,20 +1,28 @@
|
|
|
1
|
-
import { RaphPhaseProcessError as
|
|
2
|
-
import { throwDisposalErrors as
|
|
3
|
-
import { EMPTY_FRAME as
|
|
4
|
-
class
|
|
1
|
+
import { RaphPhaseProcessError as K, RaphDisposedError as H } from "../errors.js";
|
|
2
|
+
import { throwDisposalErrors as Q } from "../ownership/throwDisposalErrors.js";
|
|
3
|
+
import { EMPTY_FRAME as V, RaphPhaseTaskRecord as W, GROUP_NODES as k, GROUP_CONTEXT as X, GROUP_CURSOR as L, TASK_ACTIVE as _, TASK_TASKLESS as Y, TASK_PAUSED as P, TASK_IN_DELIVERY as p, TASK_PENDING as g, TASK_DEFERRED as T, TASK_DISCARD_ACKNOWLEDGED as y, TASK_CAUSES_DELIVERED as w, TASK_RESOLUTION as D, TASK_RUN as q, TASK_CANCEL as m, TASK_UNRESOLVED as J, TASK_EXECUTED as U, TASK_REQUESTED as C, TASK_DEFER as j } from "./RaphPhaseTaskRecord.js";
|
|
4
|
+
class Z {
|
|
5
5
|
constructor(e, t) {
|
|
6
|
-
this.name = e, this.pipeline = t, this.queue = [], this.spare = [], this.bindings = 0;
|
|
6
|
+
this.name = e, this.pipeline = t, this.first = void 0, this.queue = [], this.spare = [], this.bindings = 0;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
class
|
|
9
|
+
const ee = 1e4, te = 1e4, B = g | y | C | D | w, x = _ | P, N = p | D;
|
|
10
|
+
class re {
|
|
11
11
|
constructor(e, t, s, i = () => !1, a) {
|
|
12
12
|
this._scheduler = e, this._reactivity = t, this._resolveCause = s, this._deferSync = i, this._tracePhase = a;
|
|
13
|
+
const n = globalThis.performance;
|
|
14
|
+
this._now = n === void 0 ? Date.now : n.now.bind(n);
|
|
13
15
|
}
|
|
14
16
|
_phases = [];
|
|
15
17
|
_phaseByName = /* @__PURE__ */ new Map();
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Последнее разрешённое имя phase в том виде, в каком его передал вызывающий,
|
|
20
|
+
* и его состояние. Регистрация binding читает этот кэш сама, без вызова
|
|
21
|
+
* resolvePhase().
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
17
24
|
_resolvedInput;
|
|
25
|
+
/** @internal */
|
|
18
26
|
_resolvedState;
|
|
19
27
|
// Число записей во всех живых очередях.
|
|
20
28
|
_queuedCount = 0;
|
|
@@ -36,18 +44,53 @@ class te {
|
|
|
36
44
|
// значением доставка группы пропускает, не обращаясь к engine.
|
|
37
45
|
_idleSlotFlags = -1;
|
|
38
46
|
_disposed = !1;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
// Отметки времени всегда числовые; первый кадр определяется счётчиком.
|
|
48
|
+
_firstFrameAt = Number.NaN;
|
|
49
|
+
_lastFrameAt = Number.NaN;
|
|
50
|
+
_frameNumber = -1;
|
|
51
|
+
_frame = V;
|
|
52
|
+
_publicFrames = !1;
|
|
53
|
+
// Raph Top-1: пока ни один frame не прочитан, flush не вызывает clock и не
|
|
54
|
+
// создаёт снимок; true значит, что текущий flush ещё не получил свой frame.
|
|
55
|
+
_frameStale = !1;
|
|
56
|
+
// Снимок, который получили доставки до первого чтения, и кадр, которым его
|
|
57
|
+
// заменило первое чтение: все такие доставки видят этот кадр.
|
|
58
|
+
_unmeasuredFrame;
|
|
59
|
+
_firstReadFrame;
|
|
60
|
+
_readPublicFrame = this._exposeCurrentFrame;
|
|
61
|
+
_now;
|
|
62
|
+
/** @internal */
|
|
63
|
+
_setPhaseTrace(e) {
|
|
64
|
+
this._tracePhase = e;
|
|
65
|
+
}
|
|
43
66
|
get frame() {
|
|
67
|
+
return this._readPublicFrame();
|
|
68
|
+
}
|
|
69
|
+
_readCurrentFrame() {
|
|
44
70
|
return this._frame;
|
|
45
71
|
}
|
|
72
|
+
_exposeCurrentFrame() {
|
|
73
|
+
return this._exposeFrame(this._frame);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Доставка может удерживать ещё не опубликованный снимок.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
_frameForDelivery() {
|
|
80
|
+
return this._frame;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Первое чтение включает заморозку всех последующих кадров.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
_exposeFrame(e) {
|
|
87
|
+
return this._publicFrames || (this._frameStale && (this._unmeasuredFrame = this._frame, this._materializeFrame(), this._firstReadFrame = this._frame), this._publicFrames = !0, Object.freeze(this._frame), this._readPublicFrame = this._readCurrentFrame), e === this._unmeasuredFrame ? this._firstReadFrame : e === this._frame ? e : Object.freeze(e);
|
|
88
|
+
}
|
|
46
89
|
get phases() {
|
|
47
90
|
return this._phases.map((e) => e.phase);
|
|
48
91
|
}
|
|
49
92
|
definePhases(e) {
|
|
50
|
-
if (this._assertAlive(), this._configurationLocked || this.
|
|
93
|
+
if (this._assertAlive(), this._configurationLocked || this._frameNumber !== -1)
|
|
51
94
|
throw new Error("[Raph] Cannot redefine phases after phase pipeline execution has started.");
|
|
52
95
|
const t = this._phaseByName, s = /* @__PURE__ */ new Map(), i = [];
|
|
53
96
|
for (const a of e) {
|
|
@@ -58,15 +101,15 @@ class te {
|
|
|
58
101
|
throw new Error(`[Raph] Duplicate phase name "${n}".`);
|
|
59
102
|
if (a.process !== void 0 && typeof a.process != "function")
|
|
60
103
|
throw new TypeError(`[Raph] Phase "${n}" process must be a function.`);
|
|
61
|
-
const
|
|
104
|
+
const r = Object.freeze({
|
|
62
105
|
name: n,
|
|
63
106
|
...a.process === void 0 ? {} : { process: a.process }
|
|
64
|
-
}),
|
|
107
|
+
}), h = {
|
|
65
108
|
index: i.length,
|
|
66
|
-
phase:
|
|
67
|
-
state: t.get(n)?.state ?? new
|
|
109
|
+
phase: r,
|
|
110
|
+
state: t.get(n)?.state ?? new Z(n, this)
|
|
68
111
|
};
|
|
69
|
-
i.push(
|
|
112
|
+
i.push(h), s.set(n, h);
|
|
70
113
|
}
|
|
71
114
|
this._assertRetainedPhases(s), this._phases = i, this._phaseByName = s, this._resolvedInput = void 0, this._resolvedState = void 0;
|
|
72
115
|
}
|
|
@@ -101,7 +144,7 @@ class te {
|
|
|
101
144
|
* (`node`) или watch lifecycle (`watch`).
|
|
102
145
|
*/
|
|
103
146
|
bindTask(e, t, s, i) {
|
|
104
|
-
return e.bindings++, new
|
|
147
|
+
return e.bindings++, new W(e, i, t, s);
|
|
105
148
|
}
|
|
106
149
|
/**
|
|
107
150
|
* Создаёт постоянную запись группы из `count` slots: одна запись binding и
|
|
@@ -116,10 +159,10 @@ class te {
|
|
|
116
159
|
* `TASK_TASKLESS`: вместо task тело получает поле `group`.
|
|
117
160
|
*/
|
|
118
161
|
bindGroup(e, t, s, i, a, n) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
return
|
|
162
|
+
const r = new Array(k + a);
|
|
163
|
+
r[X] = i, r[L] = 0, e.bindings++;
|
|
164
|
+
const h = new W(e, n, t, s);
|
|
165
|
+
return h.state = _ | Y, h.group = r, h;
|
|
123
166
|
}
|
|
124
167
|
request() {
|
|
125
168
|
this._assertAlive(), this._queuedCount !== 0 && this._schedule();
|
|
@@ -130,107 +173,158 @@ class te {
|
|
|
130
173
|
});
|
|
131
174
|
}
|
|
132
175
|
flush() {
|
|
133
|
-
if (this._assertAlive(), this._cancelScheduled(), this._running)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
176
|
+
if (this._assertAlive(), this._scheduled && this._cancelScheduled(), !this._running) {
|
|
177
|
+
if (this._queuedCount === 0 && this._deferred.size !== 0 && this._activateDeferred(), this._queuedCount === 0) {
|
|
178
|
+
this._settleIdleWaiters(void 0, !1);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this._configurationLocked = !0, this._running = !0, this._drain(this._publicFrames ? this._nextFrame() : this._skipFrame());
|
|
138
182
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Raph Top-1: первая доставка нового binding в простаивающем sync pipeline.
|
|
186
|
+
* Запись встаёт в очередь так же, как через `_queue()`, и разбирается тем же
|
|
187
|
+
* проходом flush, но без цепочки engine schedule → `_schedule()` → пролог
|
|
188
|
+
* flush. False значит, что pipeline не простаивает: тогда вызывающий
|
|
189
|
+
* планирует запись обычным путём.
|
|
190
|
+
*
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
_canDeliverFirst(e) {
|
|
194
|
+
return !(this._scheduler !== "sync" || this._running || this._scheduled || this._disposed || this._queuedCount !== 0 || this._deferred.size !== 0 || (e.state & (P | p | g | T)) !== 0 || !(e.state & _) || e.consumerOwner.disposed || this._deferSync());
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Выполняет первую доставку после положительного `_canDeliverFirst()`.
|
|
198
|
+
*
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
_deliverFirst(e) {
|
|
202
|
+
e.state = e.state & ~y | g, e.sequence = this._taskSequence++, e.phaseState.first = e, this._queuedCount++, this._configurationLocked = !0, this._running = !0, this._drain(this._publicFrames ? this._nextFrame() : this._skipFrame());
|
|
203
|
+
}
|
|
204
|
+
/** Основной проход flush: `_running` уже выставлен, frame выбран. */
|
|
205
|
+
_drain(e) {
|
|
206
|
+
let t, s = 0, i;
|
|
142
207
|
try {
|
|
143
208
|
for (; this._queuedCount !== 0; ) {
|
|
144
|
-
if (++s >
|
|
209
|
+
if (++s > ee) {
|
|
145
210
|
const n = this._describeQueued();
|
|
146
|
-
this._cancelAllQueued(!0,
|
|
211
|
+
this._cancelAllQueued(!0, t ??= []), t.push(new Error(`[Raph] Phase flush exceeded 10000 passes.${n ? ` Pending: ${n}.` : ""}`));
|
|
147
212
|
break;
|
|
148
213
|
}
|
|
149
|
-
|
|
214
|
+
const a = this._phases;
|
|
215
|
+
for (let n = 0; n < a.length; n++) {
|
|
216
|
+
const r = a[n];
|
|
150
217
|
if (this._disposed)
|
|
151
218
|
break;
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
219
|
+
const h = r.state, l = h.first;
|
|
220
|
+
if (l === void 0)
|
|
154
221
|
continue;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
222
|
+
const d = h.queue;
|
|
223
|
+
h.first = void 0;
|
|
224
|
+
const v = d.length === 0 && r.phase.process === void 0;
|
|
225
|
+
v || (h.queue = h.spare, h.spare = i = d), this._queuedCount -= d.length + 1;
|
|
226
|
+
const E = t?.length ?? 0;
|
|
227
|
+
if (this._tracePhase?.(r.phase.name, "start"), v) {
|
|
228
|
+
const u = l, o = u.state;
|
|
229
|
+
if (!(o & _) || u.consumerOwner._disposed) {
|
|
230
|
+
u.state = o & ~g, this._disposeTask(u), i = void 0;
|
|
163
231
|
continue;
|
|
164
232
|
}
|
|
165
|
-
|
|
233
|
+
const c = o & ~B | p;
|
|
234
|
+
u.state = u.firstCause === void 0 ? c : c | w, u.facade !== void 0 && (u.frame = e);
|
|
235
|
+
try {
|
|
236
|
+
u.group !== void 0 && (t ??= []), this._runDelivery(u, t);
|
|
237
|
+
} catch (F) {
|
|
238
|
+
(t ??= []).push(F);
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
this._finishDelivery(u);
|
|
242
|
+
} catch (F) {
|
|
243
|
+
(u.state & D) !== q && this._acknowledgeDiscard(u, !0, t ??= []), u.state = (u.state | m) & ~p, S(u), t ??= [], t.push(F);
|
|
244
|
+
}
|
|
245
|
+
i = void 0, (t?.length ?? 0) === E ? this._tracePhase?.(r.phase.name, "end") : this._tracePhase?.(r.phase.name, "error", t[t.length - 1]);
|
|
246
|
+
continue;
|
|
166
247
|
}
|
|
167
|
-
|
|
248
|
+
d.unshift(l), t ??= [];
|
|
249
|
+
let b = 0, A = !0, R;
|
|
250
|
+
for (let u = 0; u < d.length; u++) {
|
|
251
|
+
const o = d[u], c = o.state;
|
|
252
|
+
if (!(c & _) || o.consumerOwner._disposed) {
|
|
253
|
+
o.state = c & ~g, this._disposeTask(o);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const F = c & ~B | p;
|
|
257
|
+
o.state = o.firstCause === void 0 ? F : F | w, o.facade !== void 0 && (o.frame = e), R !== void 0 && (o.priority > R.priority || o.priority === R.priority && o.sequence < R.sequence) && (A = !1), R = o, d[b++] = o;
|
|
258
|
+
}
|
|
259
|
+
if (d.length = b, d.length === 0) {
|
|
168
260
|
i = void 0;
|
|
169
261
|
continue;
|
|
170
262
|
}
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
for (
|
|
263
|
+
A || d.sort(se);
|
|
264
|
+
const z = r.phase.process;
|
|
265
|
+
if (z === void 0)
|
|
266
|
+
for (let u = 0; u < d.length; u++)
|
|
175
267
|
try {
|
|
176
|
-
this._runDelivery(u,
|
|
177
|
-
} catch (
|
|
178
|
-
|
|
268
|
+
this._runDelivery(d[u], t);
|
|
269
|
+
} catch (o) {
|
|
270
|
+
t.push(o);
|
|
179
271
|
}
|
|
180
272
|
else {
|
|
181
273
|
const u = [];
|
|
182
|
-
for (
|
|
183
|
-
u.push(
|
|
184
|
-
const
|
|
185
|
-
phase:
|
|
186
|
-
frame:
|
|
274
|
+
for (let c = 0; c < d.length; c++)
|
|
275
|
+
u.push(d[c].task);
|
|
276
|
+
const o = Object.freeze({
|
|
277
|
+
phase: r.phase.name,
|
|
278
|
+
frame: this.frame,
|
|
187
279
|
tasks: Object.freeze(u)
|
|
188
280
|
});
|
|
189
281
|
try {
|
|
190
|
-
this._reactivity.untrackedWithOwner(() =>
|
|
191
|
-
} catch (
|
|
192
|
-
|
|
282
|
+
this._reactivity.untrackedWithOwner(() => z(o));
|
|
283
|
+
} catch (c) {
|
|
284
|
+
t.push(c);
|
|
193
285
|
}
|
|
194
286
|
}
|
|
195
|
-
let
|
|
196
|
-
for (
|
|
197
|
-
|
|
198
|
-
|
|
287
|
+
let O = 0;
|
|
288
|
+
for (let u = 0; u < d.length; u++) {
|
|
289
|
+
const o = d[u];
|
|
290
|
+
if ((o.state & D) === J) {
|
|
291
|
+
O++;
|
|
199
292
|
try {
|
|
200
|
-
this._deferDelivery(
|
|
201
|
-
} catch (
|
|
202
|
-
|
|
293
|
+
this._deferDelivery(o);
|
|
294
|
+
} catch (c) {
|
|
295
|
+
o.state |= m, this._acknowledgeDiscard(o, !0, t), t.push(c);
|
|
203
296
|
}
|
|
204
297
|
}
|
|
205
298
|
try {
|
|
206
|
-
this._finishDelivery(
|
|
207
|
-
} catch (
|
|
208
|
-
(
|
|
299
|
+
this._finishDelivery(o);
|
|
300
|
+
} catch (c) {
|
|
301
|
+
(o.state & D) !== q && this._acknowledgeDiscard(o, !0, t), o.state = (o.state | m) & ~p, S(o), t.push(c);
|
|
209
302
|
}
|
|
210
303
|
}
|
|
211
|
-
|
|
212
|
-
`[Raph] Phase "${
|
|
213
|
-
)),
|
|
214
|
-
|
|
304
|
+
d.length = 0, i = void 0, O !== 0 && t.push(new K(
|
|
305
|
+
`[Raph] Phase "${r.phase.name}" left ${O} task(s) unresolved; they were deferred.`
|
|
306
|
+
)), t.length === E ? this._tracePhase?.(r.phase.name, "end") : this._tracePhase?.(
|
|
307
|
+
r.phase.name,
|
|
215
308
|
"error",
|
|
216
|
-
|
|
309
|
+
t[t.length - 1]
|
|
217
310
|
);
|
|
218
311
|
}
|
|
219
312
|
}
|
|
220
|
-
} catch (
|
|
221
|
-
|
|
313
|
+
} catch (a) {
|
|
314
|
+
(t ??= []).push(a), i !== void 0 && (i.length = 0), this._cancelAllQueued(!0, t), this._cancelAllDeferred(!0, t);
|
|
222
315
|
} finally {
|
|
223
316
|
this._running = !1;
|
|
224
317
|
}
|
|
225
318
|
try {
|
|
226
319
|
this._deferred.size !== 0 && this._scheduleDeferredTurn();
|
|
227
|
-
} catch (
|
|
228
|
-
|
|
320
|
+
} catch (a) {
|
|
321
|
+
(t ??= []).push(a);
|
|
229
322
|
}
|
|
230
|
-
|
|
231
|
-
|
|
323
|
+
if (t !== void 0 && t.length !== 0) {
|
|
324
|
+
const a = t.length === 1 ? t[0] : new AggregateError(t, "[Raph] Multiple phase tasks failed.");
|
|
232
325
|
throw this._settleIdleWaiters(a, !0), a;
|
|
233
|
-
|
|
326
|
+
}
|
|
327
|
+
this._idleWaiters.size !== 0 && this._settleIdleWaiters(void 0, !1);
|
|
234
328
|
}
|
|
235
329
|
dispose() {
|
|
236
330
|
if (this._disposed)
|
|
@@ -239,9 +333,9 @@ class te {
|
|
|
239
333
|
const e = [...this._deferred];
|
|
240
334
|
this._cancelAllDeferred(!1);
|
|
241
335
|
for (const s of e)
|
|
242
|
-
s.state &= ~
|
|
336
|
+
s.state &= ~_;
|
|
243
337
|
this._phases = [], this._phaseByName.clear(), this._resolvedInput = void 0, this._resolvedState = void 0;
|
|
244
|
-
const t = new
|
|
338
|
+
const t = new H("[Raph] Phase pipeline is disposed.");
|
|
245
339
|
this._settleIdleWaiters(t, !0);
|
|
246
340
|
}
|
|
247
341
|
_debugPending() {
|
|
@@ -250,34 +344,19 @@ class te {
|
|
|
250
344
|
_describeQueued() {
|
|
251
345
|
const e = [];
|
|
252
346
|
for (const t of this._phases) {
|
|
253
|
-
const s = t.state.queue.filter(
|
|
254
|
-
(
|
|
347
|
+
const s = t.state.first, i = (s === void 0 ? [] : [s, ...t.state.queue]).filter(
|
|
348
|
+
(n) => (n.state & _) !== 0 && !n.consumerOwner.disposed
|
|
255
349
|
);
|
|
256
|
-
if (
|
|
350
|
+
if (i.length === 0)
|
|
257
351
|
continue;
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
return `${
|
|
352
|
+
const a = i.slice(0, 3).map((n) => {
|
|
353
|
+
const r = n.consumerOwner.node, h = r === void 0 ? void 0 : r.componentId, l = r === void 0 ? n.consumerOwner.id : `${n.consumerOwner.id}/${r.constructor.name}/${r.type}${typeof h == "string" ? `/${h}` : ""}`, d = n.firstCause?.sourceOwner?.node, v = d === void 0 ? "" : `<=${d.id}/${d.constructor.name}`;
|
|
354
|
+
return `${l}${n.firstCause ? `:${n.firstCause.kind}${v}` : ""}`;
|
|
261
355
|
}).join(", ");
|
|
262
|
-
e.push(`${t.phase.name}=${
|
|
356
|
+
e.push(`${t.phase.name}=${i.length}${a ? ` [${a}]` : ""}`);
|
|
263
357
|
}
|
|
264
358
|
return e.join("; ");
|
|
265
359
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Открывает доставку одной записью `state`. Накопленные причины остаются на
|
|
268
|
-
* своих местах и становятся причинами доставки под TASK_CAUSES_DELIVERED:
|
|
269
|
-
* ничего не копируется, а массив для `task.causes` строится, только если его
|
|
270
|
-
* прочитают. Frame доставки получает только запись с facade: без facade его
|
|
271
|
-
* нечем прочитать, а запись ссылки на новый frame в каждую доставленную
|
|
272
|
-
* запись стоит write barrier.
|
|
273
|
-
*
|
|
274
|
-
* Запись попадает сюда только из живой очереди, а в ней нет записей с
|
|
275
|
-
* открытой доставкой, поэтому причин прошлой доставки здесь не бывает.
|
|
276
|
-
*/
|
|
277
|
-
_beginDelivery(e, t) {
|
|
278
|
-
const s = e.state & -1893 | p;
|
|
279
|
-
e.state = e.firstCause === void 0 ? s : s | k, e.facade !== void 0 && (e.frame = t);
|
|
280
|
-
}
|
|
281
360
|
/**
|
|
282
361
|
* Исполняет открытую доставку binding. `failures` передаёт default runner:
|
|
283
362
|
* группа складывает туда сбой каждого slot отдельно. Без него сбои slots
|
|
@@ -288,67 +367,67 @@ class te {
|
|
|
288
367
|
*/
|
|
289
368
|
_runDelivery(e, t) {
|
|
290
369
|
const s = e.state;
|
|
291
|
-
if ((s &
|
|
370
|
+
if ((s & x) !== _ || e.consumerOwner._disposed) {
|
|
292
371
|
e.state = s | m;
|
|
293
372
|
return;
|
|
294
373
|
}
|
|
295
|
-
(s &
|
|
374
|
+
(s & N) !== p && $(), e.state = s | q;
|
|
296
375
|
const i = e.detail;
|
|
297
376
|
i !== void 0 && (i.deferCount = 0);
|
|
298
377
|
const a = this._reactivity, n = e.node;
|
|
299
378
|
if (n !== void 0) {
|
|
300
|
-
a._beginTaskEffectRun(n) && (e.state |=
|
|
379
|
+
a._beginTaskEffectRun(n) && (e.state |= U, a._runTaskEffectUntracked(n));
|
|
301
380
|
return;
|
|
302
381
|
}
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
382
|
+
const r = e.group;
|
|
383
|
+
if (r === void 0) {
|
|
384
|
+
const v = e.watch;
|
|
385
|
+
v !== void 0 && a.untrackedWithOwner(v.deliver);
|
|
307
386
|
return;
|
|
308
387
|
}
|
|
309
|
-
const
|
|
310
|
-
let
|
|
311
|
-
for (let
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
388
|
+
const h = r.length;
|
|
389
|
+
let l = this._idleSlotFlags, d;
|
|
390
|
+
for (let v = k; v < h; v++) {
|
|
391
|
+
const E = r[v];
|
|
392
|
+
if (E === null || E.flags === l)
|
|
314
393
|
continue;
|
|
315
|
-
if (!a._beginTaskEffectRun(
|
|
316
|
-
|
|
394
|
+
if (!a._beginTaskEffectRun(E)) {
|
|
395
|
+
E.evaluate !== void 0 && (this._idleSlotFlags = l = E.flags);
|
|
317
396
|
continue;
|
|
318
397
|
}
|
|
319
|
-
|
|
398
|
+
r[L] = v - k;
|
|
320
399
|
try {
|
|
321
|
-
a._runTaskEffectUntracked(
|
|
322
|
-
} catch (
|
|
323
|
-
t !== void 0 ? t.push(
|
|
400
|
+
a._runTaskEffectUntracked(E);
|
|
401
|
+
} catch (A) {
|
|
402
|
+
t !== void 0 ? t.push(A) : (d ??= []).push(A);
|
|
324
403
|
}
|
|
325
|
-
const
|
|
326
|
-
if (!(
|
|
404
|
+
const b = e.state;
|
|
405
|
+
if (!(b & _))
|
|
327
406
|
break;
|
|
328
|
-
if (
|
|
329
|
-
|
|
407
|
+
if (b & P) {
|
|
408
|
+
v + 1 < h && (this._restoreDeliveryCausesBeforePending(e), e.state |= C);
|
|
330
409
|
break;
|
|
331
410
|
}
|
|
332
411
|
}
|
|
333
|
-
if (
|
|
334
|
-
throw
|
|
412
|
+
if (d !== void 0)
|
|
413
|
+
throw d.length === 1 ? d[0] : new AggregateError(d, "[Raph] Effect group delivery failed.");
|
|
335
414
|
}
|
|
336
415
|
/** @internal */
|
|
337
416
|
_deferDelivery(e) {
|
|
338
417
|
const t = e.state;
|
|
339
|
-
if ((t &
|
|
418
|
+
if ((t & x) !== _ || e.consumerOwner.disposed) {
|
|
340
419
|
e.state = t | m;
|
|
341
420
|
return;
|
|
342
421
|
}
|
|
343
|
-
if ((t &
|
|
422
|
+
if ((t & N) !== p && $(), e.state = t | j, ++e.detailed().deferCount > te) {
|
|
344
423
|
e.state |= m;
|
|
345
424
|
const s = [];
|
|
346
425
|
throw this._acknowledgeDiscard(e, !0, s), s.length !== 0 ? new AggregateError(
|
|
347
|
-
[new
|
|
426
|
+
[new K(
|
|
348
427
|
`[Raph] Phase task in "${e.phase}" exceeded 10000 deferred deliveries.`
|
|
349
428
|
), ...s],
|
|
350
429
|
"[Raph] Phase task defer limit and recovery failed."
|
|
351
|
-
) : new
|
|
430
|
+
) : new K(
|
|
352
431
|
`[Raph] Phase task in "${e.phase}" exceeded 10000 deferred deliveries.`
|
|
353
432
|
);
|
|
354
433
|
}
|
|
@@ -356,16 +435,16 @@ class te {
|
|
|
356
435
|
/** @internal */
|
|
357
436
|
_cancelDelivery(e) {
|
|
358
437
|
const t = e.state;
|
|
359
|
-
if (!(t &
|
|
438
|
+
if (!(t & _) || e.consumerOwner.disposed) {
|
|
360
439
|
e.state = t | m;
|
|
361
440
|
return;
|
|
362
441
|
}
|
|
363
|
-
(t &
|
|
442
|
+
(t & N) !== p && $();
|
|
364
443
|
const s = [];
|
|
365
444
|
if (this._acknowledgeDiscard(e, !1, s), s.length !== 0)
|
|
366
445
|
throw s.length === 1 ? s[0] : new AggregateError(s, "[Raph] Phase task cancellation failed.");
|
|
367
446
|
let i = e.state | m;
|
|
368
|
-
i &
|
|
447
|
+
i & y && (i = I(e) ? i | C : i & ~C), e.state = i;
|
|
369
448
|
const a = e.detail;
|
|
370
449
|
a !== void 0 && (a.deferCount = 0);
|
|
371
450
|
}
|
|
@@ -373,20 +452,20 @@ class te {
|
|
|
373
452
|
const t = e.state;
|
|
374
453
|
if (!(t & p))
|
|
375
454
|
return;
|
|
376
|
-
const s = t &
|
|
377
|
-
if (e.state = t & ~p, !(t &
|
|
455
|
+
const s = t & D;
|
|
456
|
+
if (e.state = t & ~p, !(t & _) || e.consumerOwner._disposed) {
|
|
378
457
|
S(e);
|
|
379
458
|
return;
|
|
380
459
|
}
|
|
381
|
-
if (t &
|
|
382
|
-
s !== q && !(s === m && (t &
|
|
460
|
+
if (t & P) {
|
|
461
|
+
s !== q && !(s === m && (t & y) !== 0) && (this._restoreDeliveryCausesBeforePending(e), e.state |= C), S(e);
|
|
383
462
|
return;
|
|
384
463
|
}
|
|
385
|
-
if (s ===
|
|
386
|
-
this._restoreDeliveryCausesBeforePending(e), e.state |=
|
|
464
|
+
if (s === j) {
|
|
465
|
+
this._restoreDeliveryCausesBeforePending(e), e.state |= T, this._deferred.add(e), S(e);
|
|
387
466
|
return;
|
|
388
467
|
}
|
|
389
|
-
if (S(e), (e.state &
|
|
468
|
+
if (((e.state & w) !== 0 || e.detail !== void 0) && S(e), (e.state & C) !== 0 || e.firstCause !== void 0) {
|
|
390
469
|
const i = e.node;
|
|
391
470
|
if (i !== void 0)
|
|
392
471
|
this._reactivity._rearmTaskEffect(i);
|
|
@@ -413,7 +492,7 @@ class te {
|
|
|
413
492
|
*/
|
|
414
493
|
_rearmGroup(e) {
|
|
415
494
|
const t = this._reactivity;
|
|
416
|
-
for (let s =
|
|
495
|
+
for (let s = k; s < e.length; s++) {
|
|
417
496
|
const i = e[s];
|
|
418
497
|
i !== null && i.firstDep !== null && t._beginTaskEffectRun(i) && t._rearmTaskEffect(i);
|
|
419
498
|
}
|
|
@@ -429,20 +508,20 @@ class te {
|
|
|
429
508
|
/** @internal */
|
|
430
509
|
_appendCause(e, t, s) {
|
|
431
510
|
const i = e.state;
|
|
432
|
-
if (!(i &
|
|
511
|
+
if (!(i & _))
|
|
433
512
|
return;
|
|
434
|
-
i &
|
|
513
|
+
i & w && this._splitDeliveredCauses(e);
|
|
435
514
|
const a = e.firstCause;
|
|
436
515
|
if (a === void 0) {
|
|
437
516
|
e.firstCause = t, e.firstCauseKey = s;
|
|
438
517
|
return;
|
|
439
518
|
}
|
|
440
519
|
if (e.firstCauseKey === s) {
|
|
441
|
-
e.firstCause =
|
|
520
|
+
e.firstCause = G(a, t);
|
|
442
521
|
return;
|
|
443
522
|
}
|
|
444
|
-
const n = e.detailed().extraCauses ??= /* @__PURE__ */ new Map(),
|
|
445
|
-
n.set(s,
|
|
523
|
+
const n = e.detailed().extraCauses ??= /* @__PURE__ */ new Map(), r = n.get(s);
|
|
524
|
+
n.set(s, r === void 0 ? t : G(r, t));
|
|
446
525
|
}
|
|
447
526
|
/**
|
|
448
527
|
* Переносит причины открытой доставки с места ожидающих в detail, без
|
|
@@ -452,32 +531,36 @@ class te {
|
|
|
452
531
|
*/
|
|
453
532
|
_splitDeliveredCauses(e) {
|
|
454
533
|
const t = e.detailed(), s = t.extraCauses;
|
|
455
|
-
t.deliveryFirstCause = e.firstCause, t.deliveryFirstCauseKey = e.firstCauseKey, t.deliveryExtraCauses = s === void 0 || s.size === 0 ? void 0 : s, t.extraCauses = void 0, e.firstCause = void 0, e.firstCauseKey = void 0, e.state &= ~
|
|
534
|
+
t.deliveryFirstCause = e.firstCause, t.deliveryFirstCauseKey = e.firstCauseKey, t.deliveryExtraCauses = s === void 0 || s.size === 0 ? void 0 : s, t.extraCauses = void 0, e.firstCause = void 0, e.firstCauseKey = void 0, e.state &= ~w;
|
|
456
535
|
}
|
|
457
536
|
/** @internal */
|
|
458
537
|
_queue(e, t = !0) {
|
|
459
538
|
const s = e.state;
|
|
460
|
-
if (!(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (s & w) {
|
|
466
|
-
t && this._schedule();
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
s & E || (e.state = s & ~C | w, e.sequence = this._taskSequence++, e.phaseState.queue.push(e), this._queuedCount++, t && this._schedule());
|
|
539
|
+
if (!(s & _) || e.consumerOwner._disposed || this._disposed)
|
|
540
|
+
return;
|
|
541
|
+
if (s & (P | p)) {
|
|
542
|
+
e.state = s | C;
|
|
543
|
+
return;
|
|
470
544
|
}
|
|
545
|
+
if (s & g) {
|
|
546
|
+
t && this._schedule();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (s & T)
|
|
550
|
+
return;
|
|
551
|
+
e.state = s & ~y | g, e.sequence = this._taskSequence++;
|
|
552
|
+
const i = e.phaseState;
|
|
553
|
+
i.first === void 0 ? i.first = e : i.queue.push(e), this._queuedCount++, t && this._schedule();
|
|
471
554
|
}
|
|
472
555
|
/** @internal */
|
|
473
556
|
_disposeTask(e) {
|
|
474
557
|
const t = e.state;
|
|
475
|
-
if (!(t &
|
|
558
|
+
if (!(t & _))
|
|
476
559
|
return;
|
|
477
560
|
const s = t & -270;
|
|
478
561
|
e.state = t & p ? s | m : s, e.firstCause = void 0, e.firstCauseKey = void 0;
|
|
479
562
|
const i = e.detail;
|
|
480
|
-
i !== void 0 && (i.extraCauses?.clear(), i.extraCauses = void 0,
|
|
563
|
+
i !== void 0 && (i.extraCauses?.clear(), i.extraCauses = void 0, M(i)), t & T && this._deferred.delete(e), t & g && this._unqueue(e), e.phaseState.bindings--, this._scheduled && this._queuedCount === 0 && this._deferred.size === 0 && this._cancelScheduled(), this._idleWaiters.size !== 0 && this._settleIdleWaiters(void 0, !1);
|
|
481
564
|
}
|
|
482
565
|
/**
|
|
483
566
|
* Полностью освобождает один binding; каждый шаг идемпотентен, поэтому
|
|
@@ -500,9 +583,13 @@ class te {
|
|
|
500
583
|
return;
|
|
501
584
|
}
|
|
502
585
|
const i = e.watch;
|
|
503
|
-
i !== void 0 && (e.watch = void 0,
|
|
586
|
+
i !== void 0 && (e.watch = void 0, this._stopPhaseWatch(e, i));
|
|
504
587
|
}
|
|
505
|
-
this._disposeTask(e);
|
|
588
|
+
e.state & _ && this._disposeTask(e);
|
|
589
|
+
}
|
|
590
|
+
/** Callback создаётся только на пути explicit watch после очистки record.watch. */
|
|
591
|
+
_stopPhaseWatch(e, t) {
|
|
592
|
+
t.stop(() => this._releaseWatch(e, t));
|
|
506
593
|
}
|
|
507
594
|
/**
|
|
508
595
|
* Убирает из состояния группы slots, записи графа которых уже остановлены, и
|
|
@@ -523,7 +610,7 @@ class te {
|
|
|
523
610
|
*/
|
|
524
611
|
_forgetStoppedSlots(e) {
|
|
525
612
|
let t = !1, s = !1;
|
|
526
|
-
for (let i =
|
|
613
|
+
for (let i = k; i < e.length; i++) {
|
|
527
614
|
const a = e[i];
|
|
528
615
|
a != null && (a.evaluate === void 0 ? (e[i] = null, t = !0) : s = !0);
|
|
529
616
|
}
|
|
@@ -549,13 +636,13 @@ class te {
|
|
|
549
636
|
_disposeGroup(e, t) {
|
|
550
637
|
const s = this._reactivity;
|
|
551
638
|
let i;
|
|
552
|
-
for (let a = t.length - 1; a >=
|
|
639
|
+
for (let a = t.length - 1; a >= k; a--) {
|
|
553
640
|
const n = t[a];
|
|
554
641
|
if (n != null)
|
|
555
642
|
try {
|
|
556
643
|
s._disposeTaskEffect(n);
|
|
557
|
-
} catch (
|
|
558
|
-
(i ??= []).push(
|
|
644
|
+
} catch (r) {
|
|
645
|
+
(i ??= []).push(r);
|
|
559
646
|
}
|
|
560
647
|
}
|
|
561
648
|
try {
|
|
@@ -582,28 +669,33 @@ class te {
|
|
|
582
669
|
} catch (a) {
|
|
583
670
|
s.push(a);
|
|
584
671
|
}
|
|
585
|
-
|
|
672
|
+
Q(s, "[Raph] Phase watch disposal failed.");
|
|
586
673
|
}
|
|
587
674
|
/** @internal */
|
|
588
675
|
_pauseTask(e) {
|
|
589
676
|
const t = e.state;
|
|
590
|
-
if ((t &
|
|
677
|
+
if ((t & x) !== _)
|
|
591
678
|
return;
|
|
592
|
-
const s = t &
|
|
593
|
-
e.state = (t & (
|
|
679
|
+
const s = t & D, i = (t | P) & -13;
|
|
680
|
+
e.state = (t & (g | T)) !== 0 || (t & p) !== 0 && s !== q && !(s === m && (t & y) !== 0) ? i | C : i, t & T && this._deferred.delete(e), t & g && this._unqueue(e), this._hasPending() || this._cancelScheduled(), this._settleIdleWaiters(void 0, !1);
|
|
594
681
|
}
|
|
595
682
|
/**
|
|
596
683
|
* Убирает ожидающую запись из живой очереди её phase. Запись, которую flush
|
|
597
684
|
* уже забрал на разбор, в живой очереди не находится и счётчик не меняет.
|
|
598
685
|
*/
|
|
599
686
|
_unqueue(e) {
|
|
600
|
-
const t = e.phaseState
|
|
601
|
-
|
|
687
|
+
const t = e.phaseState, s = t.queue;
|
|
688
|
+
if (t.first === e) {
|
|
689
|
+
t.first = s.shift(), this._queuedCount--;
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const i = s.indexOf(e);
|
|
693
|
+
i >= 0 && (s.splice(i, 1), this._queuedCount--);
|
|
602
694
|
}
|
|
603
695
|
/** @internal */
|
|
604
696
|
_resumeTask(e) {
|
|
605
697
|
const t = e.state;
|
|
606
|
-
(t &
|
|
698
|
+
(t & x) !== x || e.consumerOwner.disposed || ((t & C) !== 0 || I(e) ? (e.state = t & -67, this._queue(e)) : e.state = t & ~P);
|
|
607
699
|
}
|
|
608
700
|
/**
|
|
609
701
|
* Возвращает причины открытой доставки в ожидающие, впереди причин, которые
|
|
@@ -612,7 +704,7 @@ class te {
|
|
|
612
704
|
* отделяются от ожидающих.
|
|
613
705
|
*/
|
|
614
706
|
_restoreDeliveryCausesBeforePending(e) {
|
|
615
|
-
e.state &
|
|
707
|
+
e.state & w && this._splitDeliveredCauses(e);
|
|
616
708
|
const t = e.detail;
|
|
617
709
|
if (t === void 0)
|
|
618
710
|
return;
|
|
@@ -621,13 +713,13 @@ class te {
|
|
|
621
713
|
return;
|
|
622
714
|
const i = e.firstCause, a = e.firstCauseKey, n = t.extraCauses;
|
|
623
715
|
e.firstCause = void 0, e.firstCauseKey = void 0, t.extraCauses = void 0, this._appendCause(e, s, t.deliveryFirstCauseKey);
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
for (const [
|
|
627
|
-
this._appendCause(e,
|
|
716
|
+
const r = t.deliveryExtraCauses;
|
|
717
|
+
if (r !== void 0)
|
|
718
|
+
for (const [h, l] of r)
|
|
719
|
+
this._appendCause(e, l, h);
|
|
628
720
|
if (i !== void 0 && (this._appendCause(e, i, a), n !== void 0))
|
|
629
|
-
for (const [
|
|
630
|
-
this._appendCause(e,
|
|
721
|
+
for (const [h, l] of n)
|
|
722
|
+
this._appendCause(e, l, h);
|
|
631
723
|
}
|
|
632
724
|
_schedule() {
|
|
633
725
|
if (this._running || this._scheduled || this._disposed)
|
|
@@ -664,20 +756,36 @@ class te {
|
|
|
664
756
|
const e = [...this._deferred];
|
|
665
757
|
this._deferred.clear();
|
|
666
758
|
for (const t of e)
|
|
667
|
-
t.state &= ~
|
|
759
|
+
t.state &= ~T, this._queue(t, !1);
|
|
760
|
+
}
|
|
761
|
+
/** Flush без читателей frame: только номер кадра, без clock и снимка. */
|
|
762
|
+
_skipFrame() {
|
|
763
|
+
return this._frameNumber++, this._frameStale = !0, this._frame;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Вычисляет текущий кадр при первом чтении. История до него не записывалась,
|
|
767
|
+
* поэтому кадр считается первым измеренным: delta и elapsed равны нулю.
|
|
768
|
+
*/
|
|
769
|
+
_materializeFrame() {
|
|
770
|
+
const e = this._now();
|
|
771
|
+
this._frameStale = !1, this._firstFrameAt = e, this._lastFrameAt = e, this._frame = { now: e, delta: 0, elapsed: 0, frame: this._frameNumber };
|
|
668
772
|
}
|
|
669
773
|
_nextFrame() {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
774
|
+
this._frameStale = !1;
|
|
775
|
+
const e = this._now();
|
|
776
|
+
if (this._frameNumber === -1) {
|
|
777
|
+
this._firstFrameAt = e, this._lastFrameAt = e, this._frameNumber = 0;
|
|
778
|
+
const s = { now: e, delta: 0, elapsed: 0, frame: 0 };
|
|
779
|
+
return this._frame = this._publicFrames ? Object.freeze(s) : s;
|
|
780
|
+
}
|
|
673
781
|
this._frameNumber++;
|
|
674
|
-
const t =
|
|
782
|
+
const t = {
|
|
675
783
|
now: e,
|
|
676
784
|
delta: Math.min(Math.max(e - this._lastFrameAt, 0), 100),
|
|
677
785
|
elapsed: Math.max(e - this._firstFrameAt, 0),
|
|
678
786
|
frame: this._frameNumber
|
|
679
|
-
}
|
|
680
|
-
return this._lastFrameAt = e, this._frame = t;
|
|
787
|
+
};
|
|
788
|
+
return this._lastFrameAt = e, this._frame = this._publicFrames ? Object.freeze(t) : t;
|
|
681
789
|
}
|
|
682
790
|
_assertRetainedPhases(e) {
|
|
683
791
|
for (const t of this._phases) {
|
|
@@ -687,56 +795,67 @@ class te {
|
|
|
687
795
|
}
|
|
688
796
|
for (const t of this._phases) {
|
|
689
797
|
const s = t.state;
|
|
690
|
-
if (s.
|
|
798
|
+
if (s.first !== void 0 && !e.has(s.name))
|
|
691
799
|
throw new Error(`[Raph] Cannot remove phase "${s.name}" while it has pending work.`);
|
|
692
800
|
}
|
|
693
801
|
}
|
|
694
802
|
_hasPending() {
|
|
695
803
|
return this._queuedCount !== 0 || this._deferred.size !== 0;
|
|
696
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* Есть ли то, что изменит flush(): очередь, отложенные записи, запланированный
|
|
807
|
+
* turn или ожидающие afterFlush(). Без этого flush() ничего не делает.
|
|
808
|
+
*
|
|
809
|
+
* @internal
|
|
810
|
+
*/
|
|
811
|
+
_hasPendingWork() {
|
|
812
|
+
return this._queuedCount !== 0 || this._deferred.size !== 0 || this._scheduled || this._idleWaiters.size !== 0;
|
|
813
|
+
}
|
|
697
814
|
_cancelAllQueued(e, t = []) {
|
|
698
815
|
if (this._queuedCount === 0)
|
|
699
816
|
return;
|
|
700
817
|
const s = [];
|
|
701
818
|
for (const i of this._phases) {
|
|
702
|
-
const a = i.state
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
819
|
+
const a = i.state;
|
|
820
|
+
a.first !== void 0 && (s.push(a.first), a.first = void 0);
|
|
821
|
+
const n = a.queue;
|
|
822
|
+
for (const r of n)
|
|
823
|
+
s.push(r);
|
|
824
|
+
n.length = 0;
|
|
706
825
|
}
|
|
707
826
|
this._queuedCount = 0;
|
|
708
827
|
for (const i of s)
|
|
709
|
-
i.state &= ~
|
|
828
|
+
i.state &= ~g, e && this._acknowledgeDiscard(i, !0, t), this._clearPendingDelivery(i);
|
|
710
829
|
}
|
|
711
830
|
_cancelAllDeferred(e, t = []) {
|
|
712
831
|
const s = [...this._deferred];
|
|
713
832
|
this._deferred.clear();
|
|
714
833
|
for (const i of s)
|
|
715
|
-
i.state &= ~
|
|
834
|
+
i.state &= ~T, e && this._acknowledgeDiscard(i, !0, t), this._clearPendingDelivery(i);
|
|
716
835
|
}
|
|
717
836
|
_acknowledgeDiscard(e, t, s) {
|
|
718
837
|
const i = e.state;
|
|
719
|
-
if (i &
|
|
838
|
+
if (i & y)
|
|
720
839
|
return;
|
|
721
840
|
const a = e.node, n = e.group;
|
|
722
|
-
if (a === void 0 && n === void 0 || !(i &
|
|
723
|
-
e.state = i |
|
|
841
|
+
if (a === void 0 && n === void 0 || !(i & _)) {
|
|
842
|
+
e.state = i | y;
|
|
724
843
|
return;
|
|
725
844
|
}
|
|
726
845
|
try {
|
|
727
|
-
if (a !== void 0 ? (i &
|
|
728
|
-
e.state |=
|
|
846
|
+
if (a !== void 0 ? (i & U) !== 0 && this._reactivity._cancelTaskEffect(a) : this._cancelGroup(e, n, t)) {
|
|
847
|
+
e.state |= y;
|
|
729
848
|
return;
|
|
730
849
|
}
|
|
731
850
|
if (!t) {
|
|
732
|
-
s.push(new
|
|
851
|
+
s.push(new K(
|
|
733
852
|
`[Raph] Initial effect delivery in "${e.phase}" cannot be cancelled before dependency collection.`
|
|
734
853
|
));
|
|
735
854
|
return;
|
|
736
855
|
}
|
|
737
|
-
e.dispose(), e.state |=
|
|
738
|
-
} catch (
|
|
739
|
-
s.push(
|
|
856
|
+
e.dispose(), e.state |= y;
|
|
857
|
+
} catch (r) {
|
|
858
|
+
s.push(r);
|
|
740
859
|
}
|
|
741
860
|
}
|
|
742
861
|
/**
|
|
@@ -763,33 +882,33 @@ class te {
|
|
|
763
882
|
_cancelGroup(e, t, s) {
|
|
764
883
|
const i = this._reactivity;
|
|
765
884
|
let a = !1;
|
|
766
|
-
for (let
|
|
767
|
-
const
|
|
768
|
-
|
|
885
|
+
for (let h = k; h < t.length; h++) {
|
|
886
|
+
const l = t[h];
|
|
887
|
+
l === null || l.firstDep !== null || !i._beginTaskEffectRun(l) || (s ? i._disposeTaskEffect(l) : (i._requestTaskEffect(l, !1), a = !0));
|
|
769
888
|
}
|
|
770
889
|
if (a)
|
|
771
890
|
return !1;
|
|
772
|
-
const n = !s &&
|
|
773
|
-
let
|
|
774
|
-
for (let
|
|
775
|
-
const
|
|
776
|
-
if (
|
|
891
|
+
const n = !s && I(e);
|
|
892
|
+
let r = !1;
|
|
893
|
+
for (let h = k; h < t.length; h++) {
|
|
894
|
+
const l = t[h];
|
|
895
|
+
if (l === null)
|
|
777
896
|
continue;
|
|
778
|
-
if (
|
|
779
|
-
|
|
897
|
+
if (l.firstDep === null) {
|
|
898
|
+
r = r || l.evaluate !== void 0;
|
|
780
899
|
continue;
|
|
781
900
|
}
|
|
782
|
-
const
|
|
783
|
-
i._cancelTaskEffect(
|
|
901
|
+
const d = n && i._beginTaskEffectRun(l);
|
|
902
|
+
i._cancelTaskEffect(l) && (r = !0, d && i._rearmTaskEffect(l));
|
|
784
903
|
}
|
|
785
|
-
return
|
|
904
|
+
return r;
|
|
786
905
|
}
|
|
787
906
|
/**
|
|
788
907
|
* Сбрасывает ожидающую работу записи, снятой с очереди либо из отложенных.
|
|
789
908
|
* Такая запись не находится в доставке, поэтому её причины ожидающие.
|
|
790
909
|
*/
|
|
791
910
|
_clearPendingDelivery(e) {
|
|
792
|
-
e.state &= ~
|
|
911
|
+
e.state &= ~C, e.firstCause = void 0, e.firstCauseKey = void 0;
|
|
793
912
|
const t = e.detail;
|
|
794
913
|
t !== void 0 && (t.extraCauses?.clear(), t.extraCauses = void 0);
|
|
795
914
|
}
|
|
@@ -804,45 +923,45 @@ class te {
|
|
|
804
923
|
}
|
|
805
924
|
_assertAlive() {
|
|
806
925
|
if (this._disposed)
|
|
807
|
-
throw new
|
|
926
|
+
throw new H("[Raph] Phase pipeline is disposed.");
|
|
808
927
|
}
|
|
809
928
|
}
|
|
810
|
-
function
|
|
811
|
-
return e.priority -
|
|
929
|
+
function se(f, e) {
|
|
930
|
+
return e.priority - f.priority || f.sequence - e.sequence;
|
|
812
931
|
}
|
|
813
|
-
function
|
|
814
|
-
return
|
|
932
|
+
function I(f) {
|
|
933
|
+
return f.firstCause !== void 0 && !(f.state & w);
|
|
815
934
|
}
|
|
816
|
-
function S(
|
|
817
|
-
const e =
|
|
818
|
-
if (e &
|
|
819
|
-
|
|
935
|
+
function S(f) {
|
|
936
|
+
const e = f.state, t = f.detail;
|
|
937
|
+
if (e & w) {
|
|
938
|
+
f.state = e & ~w, f.firstCause = void 0, f.firstCauseKey = void 0, t !== void 0 && (t.extraCauses = void 0, t.deliveryCauses = void 0);
|
|
820
939
|
return;
|
|
821
940
|
}
|
|
822
|
-
t !== void 0 && t.deliveryFirstCause !== void 0 &&
|
|
941
|
+
t !== void 0 && t.deliveryFirstCause !== void 0 && M(t);
|
|
823
942
|
}
|
|
824
|
-
function
|
|
825
|
-
|
|
943
|
+
function M(f) {
|
|
944
|
+
f.deliveryFirstCause = void 0, f.deliveryFirstCauseKey = void 0, f.deliveryExtraCauses = void 0, f.deliveryCauses = void 0;
|
|
826
945
|
}
|
|
827
|
-
function
|
|
828
|
-
throw new
|
|
946
|
+
function $() {
|
|
947
|
+
throw new K("[Raph] Phase task delivery is already resolved.");
|
|
829
948
|
}
|
|
830
|
-
function
|
|
831
|
-
const t =
|
|
949
|
+
function G(f, e) {
|
|
950
|
+
const t = f.events === void 0 ? e.events : e.events === void 0 ? f.events : Object.freeze([...f.events, ...e.events]), s = f.structure === void 0 ? e.structure : e.structure === void 0 ? f.structure : Object.freeze({
|
|
832
951
|
node: e.structure.node,
|
|
833
|
-
oldParent:
|
|
834
|
-
oldIndex:
|
|
952
|
+
oldParent: f.structure.oldParent,
|
|
953
|
+
oldIndex: f.structure.oldIndex,
|
|
835
954
|
newParent: e.structure.newParent,
|
|
836
955
|
newIndex: e.structure.newIndex
|
|
837
956
|
});
|
|
838
957
|
return Object.freeze({
|
|
839
958
|
...e,
|
|
840
|
-
previous:
|
|
959
|
+
previous: f.previous,
|
|
841
960
|
...t === void 0 ? {} : { events: t },
|
|
842
961
|
...s === void 0 ? {} : { structure: s }
|
|
843
962
|
});
|
|
844
963
|
}
|
|
845
964
|
export {
|
|
846
|
-
|
|
847
|
-
|
|
965
|
+
re as RaphPhasePipeline,
|
|
966
|
+
Z as RaphPhaseState
|
|
848
967
|
};
|