@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.20
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 +1096 -0
- package/dist/api/Raph.d.ts +59 -190
- package/dist/api/RaphFacadeSession.d.ts +90 -0
- package/dist/api/RaphReactivityInstance.d.ts +72 -0
- package/dist/api/errors.d.ts +9 -4
- package/dist/api/types.d.ts +162 -17
- package/dist/core-CyilRD7s.js +1055 -0
- package/dist/core-ugchZNqC.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -366
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +306 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +149 -0
- package/dist/debug/api/errors.cjs +1 -1
- package/dist/debug/api/errors.js +10 -7
- package/dist/debug/path/DataPath.cjs +1 -0
- package/dist/debug/path/{data-path.js → DataPath.js} +151 -180
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +258 -207
- package/dist/debug/path/data-path.utils.cjs +1 -0
- package/dist/debug/path/data-path.utils.js +56 -0
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
- package/dist/debug/path/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
- package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
- package/dist/debug/path/derived/derived-strategy.types.js +1 -0
- package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
- package/dist/debug/path/meta/meta.types.cjs +1 -0
- package/dist/debug/path/meta/meta.types.js +1 -0
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
- package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
- package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
- package/dist/debug/path/storage/data-adapter.types.js +1 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +478 -306
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +280 -0
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +798 -519
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
- package/dist/debug/runtime/errors.cjs +1 -1
- package/dist/debug/runtime/errors.js +6 -3
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +206 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +101 -0
- package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
- package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
- package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -0
- package/dist/entrypoints/machine.d.ts +5 -0
- package/dist/entrypoints/path.d.ts +14 -0
- package/dist/entrypoints/reactivity.d.ts +1 -0
- package/dist/entrypoints/runtime.d.ts +17 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -38
- package/dist/machine/compiler.d.ts +71 -0
- package/dist/machine/core.d.ts +50 -0
- package/dist/machine/persistence.d.ts +5 -0
- package/dist/machine/runtime.d.ts +4 -0
- package/dist/machine/testing.d.ts +43 -0
- package/dist/machine/types.d.ts +155 -0
- package/dist/machine-testing.cjs +1 -0
- package/dist/machine-testing.js +188 -0
- package/dist/machine.cjs +1 -0
- package/dist/machine.js +837 -0
- package/dist/main.d.ts +20 -0
- package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
- package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
- package/dist/path/RaphKernel.d.ts +13 -10
- package/dist/path/data-path.types.d.ts +34 -0
- package/dist/path/data-path.utils.d.ts +9 -0
- package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
- package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +12 -0
- package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
- package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
- package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
- package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
- package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
- package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
- package/dist/path/path.types.d.ts +3 -2
- package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
- package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
- package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
- package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
- package/dist/path/storage/data-adapter.types.d.ts +17 -0
- package/dist/path.cjs +1 -1
- package/dist/path.js +16 -16
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +46 -38
- package/dist/reactivity/engine.d.ts +17 -3
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/types.d.ts +25 -0
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +12 -12
- package/dist/runtime/RaphRuntime.d.ts +132 -192
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
- package/dist/runtime/ownership/RaphNode.d.ts +40 -0
- package/dist/runtime/ownership/RaphScope.d.ts +38 -0
- package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
- package/dist/runtime/ownership/parentGraph.d.ts +3 -0
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +92 -0
- package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
- package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
- package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +68 -35
- package/ReadMe.md +0 -153
- package/dist/api/public.d.ts +0 -22
- package/dist/debug/api/public.cjs +0 -1
- package/dist/debug/api/public.js +0 -40
- package/dist/debug/path/AdapterPathStore.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/public.cjs +0 -1
- package/dist/debug/path/public.js +0 -18
- package/dist/debug/runtime/PathHandle.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphNode.cjs +0 -1
- package/dist/debug/runtime/RaphNode.js +0 -143
- package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
- package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
- package/dist/debug/runtime/RaphScope.cjs +0 -1
- package/dist/debug/runtime/RaphScope.js +0 -64
- package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
- package/dist/debug/runtime/RuntimeReactivity.js +0 -154
- package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
- package/dist/debug/runtime/RuntimeWatch.js +0 -71
- package/dist/debug/runtime/public.cjs +0 -1
- package/dist/debug/runtime/public.js +0 -18
- package/dist/path/public.d.ts +0 -14
- package/dist/runtime/RaphDebug.d.ts +0 -32
- package/dist/runtime/RaphNode.d.ts +0 -68
- package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
- package/dist/runtime/RaphScope.d.ts +0 -50
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
- /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
- /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
- /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
- /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
- /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
- /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
- /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
- /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
- /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
- /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
- /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
- /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
- /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
- /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
- /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
- /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
- /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
- /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
- /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
- /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
- /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var A = (l, e, s) => e in l ? D(l, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : l[e] = s;
|
|
3
|
+
var d = (l, e, s) => A(l, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { RaphPhaseProcessError as g, RaphDisposedError as P } from "../errors.js";
|
|
5
|
+
const m = Object.freeze([]), q = Object.freeze({ now: 0, delta: 0, elapsed: 0, frame: 0 }), x = 1e4, K = 1e4, O = Symbol("RaphPhaseTaskRecord");
|
|
6
|
+
class R {
|
|
7
|
+
constructor(e, s, t, i = () => !1, n) {
|
|
8
|
+
d(this, "_phases", []);
|
|
9
|
+
d(this, "_phaseByName", /* @__PURE__ */ new Map());
|
|
10
|
+
d(this, "_phaseBindings", /* @__PURE__ */ new Map());
|
|
11
|
+
d(this, "_queues", /* @__PURE__ */ new Map());
|
|
12
|
+
d(this, "_deferred", /* @__PURE__ */ new Set());
|
|
13
|
+
d(this, "_idleWaiters", /* @__PURE__ */ new Set());
|
|
14
|
+
d(this, "_taskSequence", 0);
|
|
15
|
+
d(this, "_scheduled", !1);
|
|
16
|
+
d(this, "_scheduleToken", 0);
|
|
17
|
+
d(this, "_frameHandle");
|
|
18
|
+
d(this, "_frameHandleKind");
|
|
19
|
+
d(this, "_configurationLocked", !1);
|
|
20
|
+
d(this, "_running", !1);
|
|
21
|
+
d(this, "_disposed", !1);
|
|
22
|
+
d(this, "_firstFrameAt");
|
|
23
|
+
d(this, "_lastFrameAt");
|
|
24
|
+
d(this, "_frameNumber", 0);
|
|
25
|
+
d(this, "_frame", q);
|
|
26
|
+
this._scheduler = e, this._runUntracked = s, this._resolveCause = t, this._deferSync = i, this._tracePhase = n;
|
|
27
|
+
}
|
|
28
|
+
get frame() {
|
|
29
|
+
return this._frame;
|
|
30
|
+
}
|
|
31
|
+
get phases() {
|
|
32
|
+
return this._phases.map((e) => e.phase);
|
|
33
|
+
}
|
|
34
|
+
definePhases(e) {
|
|
35
|
+
if (this._assertAlive(), this._configurationLocked || this._firstFrameAt !== void 0)
|
|
36
|
+
throw new Error("[Raph] Cannot redefine phases after phase pipeline execution has started.");
|
|
37
|
+
const s = /* @__PURE__ */ new Map(), t = [];
|
|
38
|
+
for (const i of e) {
|
|
39
|
+
const n = i.name.trim();
|
|
40
|
+
if (!n)
|
|
41
|
+
throw new Error("[Raph] Phase name must not be empty.");
|
|
42
|
+
if (s.has(n))
|
|
43
|
+
throw new Error(`[Raph] Duplicate phase name "${n}".`);
|
|
44
|
+
if (i.process !== void 0 && typeof i.process != "function")
|
|
45
|
+
throw new TypeError(`[Raph] Phase "${n}" process must be a function.`);
|
|
46
|
+
const a = Object.freeze({
|
|
47
|
+
name: n,
|
|
48
|
+
...i.process === void 0 ? {} : { process: i.process }
|
|
49
|
+
}), r = { index: t.length, phase: a };
|
|
50
|
+
t.push(r), s.set(n, r);
|
|
51
|
+
}
|
|
52
|
+
this._assertRetainedPhases(s), this._phases = t, this._phaseByName = s;
|
|
53
|
+
}
|
|
54
|
+
addPhase(e) {
|
|
55
|
+
this.definePhases([...this.phases, e]);
|
|
56
|
+
}
|
|
57
|
+
clearPhases() {
|
|
58
|
+
this.definePhases([]);
|
|
59
|
+
}
|
|
60
|
+
requirePhase(e) {
|
|
61
|
+
if (this._assertAlive(), !this._phaseByName.has(e))
|
|
62
|
+
throw new Error(`[Raph] Phase "${e}" is not defined.`);
|
|
63
|
+
}
|
|
64
|
+
bindTask(e, s, t, i, n) {
|
|
65
|
+
const a = e.trim();
|
|
66
|
+
if (this.requirePhase(a), !Number.isFinite(i))
|
|
67
|
+
throw new TypeError("[Raph] Effect priority must be finite.");
|
|
68
|
+
this._phaseBindings.set(a, (this._phaseBindings.get(a) ?? 0) + 1);
|
|
69
|
+
const r = {}, h = this._createTask(r);
|
|
70
|
+
Object.assign(r, {
|
|
71
|
+
active: !0,
|
|
72
|
+
paused: !1,
|
|
73
|
+
pending: !1,
|
|
74
|
+
deferred: !1,
|
|
75
|
+
inDelivery: !1,
|
|
76
|
+
discardAcknowledged: !1,
|
|
77
|
+
requested: !1,
|
|
78
|
+
resolution: "unresolved",
|
|
79
|
+
deferCount: 0,
|
|
80
|
+
sequence: 0,
|
|
81
|
+
phase: a,
|
|
82
|
+
priority: i,
|
|
83
|
+
consumerOwner: s,
|
|
84
|
+
effect: t,
|
|
85
|
+
runner: n,
|
|
86
|
+
task: h,
|
|
87
|
+
deliveryCauses: m,
|
|
88
|
+
frame: q
|
|
89
|
+
});
|
|
90
|
+
const f = {
|
|
91
|
+
dependencyOwner: s,
|
|
92
|
+
allowScheduleDuringRun: !0,
|
|
93
|
+
task: h,
|
|
94
|
+
notify: (o) => {
|
|
95
|
+
const _ = this._resolveCause(o);
|
|
96
|
+
if (_ !== void 0) {
|
|
97
|
+
const c = _.kind === "structure" ? _.source : o;
|
|
98
|
+
this._appendCause(r, _, c);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
schedule: () => this._queue(r),
|
|
102
|
+
enqueue: (o, _ = o.source, c = !0) => {
|
|
103
|
+
this._appendCause(r, o, _), this._queue(r, c);
|
|
104
|
+
},
|
|
105
|
+
pause: () => this._pauseTask(r),
|
|
106
|
+
resume: () => this._resumeTask(r),
|
|
107
|
+
dispose: () => this._disposeTask(r)
|
|
108
|
+
};
|
|
109
|
+
return r.binding = f, f;
|
|
110
|
+
}
|
|
111
|
+
request() {
|
|
112
|
+
this._assertAlive(), this._hasQueued() && this._schedule();
|
|
113
|
+
}
|
|
114
|
+
afterFlush() {
|
|
115
|
+
return this._assertAlive(), !this._running && !this._scheduled && !this._hasPending() ? Promise.resolve() : new Promise((e, s) => {
|
|
116
|
+
this._idleWaiters.add({ reject: s, resolve: e });
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
flush() {
|
|
120
|
+
var n, a, r;
|
|
121
|
+
if (this._assertAlive(), this._cancelScheduled(), this._running)
|
|
122
|
+
return;
|
|
123
|
+
if (!this._hasQueued() && this._deferred.size !== 0 && this._activateDeferred(), !this._hasQueued()) {
|
|
124
|
+
this._settleIdleWaiters(void 0, !1);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this._configurationLocked = !0, this._running = !0;
|
|
128
|
+
const e = [], s = this._nextFrame();
|
|
129
|
+
let t = 0;
|
|
130
|
+
try {
|
|
131
|
+
for (; this._hasQueued(); ) {
|
|
132
|
+
if (++t > x) {
|
|
133
|
+
const h = this._describeQueued();
|
|
134
|
+
this._cancelAllQueued(!0, e), e.push(new Error(`[Raph] Phase flush exceeded 10000 passes.${h ? ` Pending: ${h}.` : ""}`));
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
for (const h of this._phases) {
|
|
138
|
+
if (this._disposed)
|
|
139
|
+
break;
|
|
140
|
+
const f = this._takePhase(h.phase.name);
|
|
141
|
+
if (f.length === 0)
|
|
142
|
+
continue;
|
|
143
|
+
const o = e.length;
|
|
144
|
+
(n = this._tracePhase) == null || n.call(this, h.phase.name, "start");
|
|
145
|
+
let _ = 0, c = !0, p;
|
|
146
|
+
for (const u of f) {
|
|
147
|
+
if (u.pending = !1, !u.active || u.consumerOwner.disposed) {
|
|
148
|
+
this._disposeTask(u);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
this._beginDelivery(u, s), p !== void 0 && (u.priority > p.priority || u.priority === p.priority && u.sequence < p.sequence) && (c = !1), p = u, f[_++] = u;
|
|
152
|
+
}
|
|
153
|
+
if (f.length = _, f.length === 0)
|
|
154
|
+
continue;
|
|
155
|
+
c || f.sort(T);
|
|
156
|
+
const k = h.phase.process;
|
|
157
|
+
if (k === void 0)
|
|
158
|
+
for (const u of f)
|
|
159
|
+
try {
|
|
160
|
+
this._runDelivery(u);
|
|
161
|
+
} catch (v) {
|
|
162
|
+
e.push(v);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const u = [];
|
|
166
|
+
for (const w of f)
|
|
167
|
+
u.push(w.task);
|
|
168
|
+
const v = Object.freeze({
|
|
169
|
+
phase: h.phase.name,
|
|
170
|
+
frame: s,
|
|
171
|
+
tasks: Object.freeze(u)
|
|
172
|
+
});
|
|
173
|
+
try {
|
|
174
|
+
this._runUntracked(() => k(v));
|
|
175
|
+
} catch (w) {
|
|
176
|
+
e.push(w);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
let y = 0;
|
|
180
|
+
for (const u of f) {
|
|
181
|
+
if (u.resolution === "unresolved") {
|
|
182
|
+
y++;
|
|
183
|
+
try {
|
|
184
|
+
this._deferDelivery(u);
|
|
185
|
+
} catch (v) {
|
|
186
|
+
u.resolution = "cancel", this._acknowledgeDiscard(u, !0, e), e.push(v);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
this._finishDelivery(u);
|
|
191
|
+
} catch (v) {
|
|
192
|
+
u.resolution !== "run" && this._acknowledgeDiscard(u, !0, e), u.resolution = "cancel", u.inDelivery = !1, u.deliveryFirstCauseKey = void 0, u.deliveryExtraCauseKeys = void 0, u.deliveryCauses = m, e.push(v);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
y !== 0 && e.push(new g(
|
|
196
|
+
`[Raph] Phase "${h.phase.name}" left ${y} task(s) unresolved; they were deferred.`
|
|
197
|
+
)), e.length === o ? (a = this._tracePhase) == null || a.call(this, h.phase.name, "end") : (r = this._tracePhase) == null || r.call(
|
|
198
|
+
this,
|
|
199
|
+
h.phase.name,
|
|
200
|
+
"error",
|
|
201
|
+
e[e.length - 1]
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} catch (h) {
|
|
206
|
+
e.push(h), this._cancelAllQueued(!0, e), this._cancelAllDeferred(!0, e);
|
|
207
|
+
} finally {
|
|
208
|
+
this._running = !1;
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
this._deferred.size !== 0 && this._scheduleDeferredTurn();
|
|
212
|
+
} catch (h) {
|
|
213
|
+
e.push(h);
|
|
214
|
+
}
|
|
215
|
+
const i = e.length === 1 ? e[0] : e.length > 1 ? new AggregateError(e, "[Raph] Multiple phase tasks failed.") : void 0;
|
|
216
|
+
if (i !== void 0)
|
|
217
|
+
throw this._settleIdleWaiters(i, !0), i;
|
|
218
|
+
this._settleIdleWaiters(void 0, !1);
|
|
219
|
+
}
|
|
220
|
+
dispose() {
|
|
221
|
+
if (this._disposed)
|
|
222
|
+
return;
|
|
223
|
+
this._disposed = !0, this._cancelScheduled(), this._cancelAllQueued(!1);
|
|
224
|
+
const e = [...this._deferred];
|
|
225
|
+
this._cancelAllDeferred(!1);
|
|
226
|
+
for (const t of e)
|
|
227
|
+
t.active = !1;
|
|
228
|
+
this._phaseBindings.clear(), this._phases = [], this._phaseByName.clear();
|
|
229
|
+
const s = new P("[Raph] Phase pipeline is disposed.");
|
|
230
|
+
this._settleIdleWaiters(s, !0);
|
|
231
|
+
}
|
|
232
|
+
_debugPending() {
|
|
233
|
+
return this._scheduled || this._running || this._hasPending();
|
|
234
|
+
}
|
|
235
|
+
_describeQueued() {
|
|
236
|
+
var s;
|
|
237
|
+
const e = [];
|
|
238
|
+
for (const t of this._phases) {
|
|
239
|
+
const i = ((s = this._queues.get(t.phase.name)) == null ? void 0 : s.filter((a) => a.active && !a.consumerOwner.disposed)) ?? [];
|
|
240
|
+
if (i.length === 0)
|
|
241
|
+
continue;
|
|
242
|
+
const n = i.slice(0, 3).map((a) => {
|
|
243
|
+
var c, p;
|
|
244
|
+
const r = a.consumerOwner.node, h = r === void 0 ? void 0 : r.componentId, f = r === void 0 ? a.consumerOwner.id : `${a.consumerOwner.id}/${r.constructor.name}/${r.type}${typeof h == "string" ? `/${h}` : ""}`, o = (p = (c = a.firstCause) == null ? void 0 : c.sourceOwner) == null ? void 0 : p.node, _ = o === void 0 ? "" : `<=${o.id}/${o.constructor.name}`;
|
|
245
|
+
return `${f}${a.firstCause ? `:${a.firstCause.kind}${_}` : ""}`;
|
|
246
|
+
}).join(", ");
|
|
247
|
+
e.push(`${t.phase.name}=${i.length}${n ? ` [${n}]` : ""}`);
|
|
248
|
+
}
|
|
249
|
+
return e.join("; ");
|
|
250
|
+
}
|
|
251
|
+
_createTask(e) {
|
|
252
|
+
const s = {
|
|
253
|
+
get phase() {
|
|
254
|
+
return e.phase;
|
|
255
|
+
},
|
|
256
|
+
get consumerOwner() {
|
|
257
|
+
return e.consumerOwner;
|
|
258
|
+
},
|
|
259
|
+
get effect() {
|
|
260
|
+
return e.effect;
|
|
261
|
+
},
|
|
262
|
+
get causes() {
|
|
263
|
+
return e.deliveryCauses;
|
|
264
|
+
},
|
|
265
|
+
get frame() {
|
|
266
|
+
return e.frame;
|
|
267
|
+
},
|
|
268
|
+
get priority() {
|
|
269
|
+
return e.priority;
|
|
270
|
+
},
|
|
271
|
+
get sequence() {
|
|
272
|
+
return e.sequence;
|
|
273
|
+
},
|
|
274
|
+
run: () => this._runDelivery(e),
|
|
275
|
+
defer: () => this._deferDelivery(e),
|
|
276
|
+
cancel: () => this._cancelDelivery(e)
|
|
277
|
+
};
|
|
278
|
+
return Object.defineProperty(s, O, { value: e }), Object.freeze(s);
|
|
279
|
+
}
|
|
280
|
+
_beginDelivery(e, s) {
|
|
281
|
+
e.pending = !1, e.inDelivery = !0, e.discardAcknowledged = !1, e.requested = !1, e.resolution = "unresolved", e.frame = s;
|
|
282
|
+
const t = e.firstCause;
|
|
283
|
+
if (t === void 0) {
|
|
284
|
+
e.deliveryFirstCauseKey = void 0, e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = m;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const i = e.extraCauses;
|
|
288
|
+
if (e.deliveryFirstCauseKey = e.firstCauseKey, e.firstCause = void 0, e.firstCauseKey = void 0, e.extraCauses = void 0, i === void 0 || i.size === 0) {
|
|
289
|
+
e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = Object.freeze([t]);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
e.deliveryExtraCauseKeys = Object.freeze([...i.keys()]), e.deliveryCauses = Object.freeze([t, ...i.values()]);
|
|
293
|
+
}
|
|
294
|
+
_runDelivery(e) {
|
|
295
|
+
if (!e.active || e.paused || e.consumerOwner.disposed) {
|
|
296
|
+
e.resolution = "cancel";
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this._assertDelivery(e), e.resolution = "run", e.deferCount = 0, this._runUntracked(e.runner);
|
|
300
|
+
}
|
|
301
|
+
_deferDelivery(e) {
|
|
302
|
+
if (!e.active || e.paused || e.consumerOwner.disposed) {
|
|
303
|
+
e.resolution = "cancel";
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (this._assertDelivery(e), e.resolution = "defer", ++e.deferCount > K) {
|
|
307
|
+
e.resolution = "cancel";
|
|
308
|
+
const s = [];
|
|
309
|
+
throw this._acknowledgeDiscard(e, !0, s), s.length !== 0 ? new AggregateError(
|
|
310
|
+
[new g(
|
|
311
|
+
`[Raph] Phase task in "${e.phase}" exceeded 10000 deferred deliveries.`
|
|
312
|
+
), ...s],
|
|
313
|
+
"[Raph] Phase task defer limit and recovery failed."
|
|
314
|
+
) : new g(
|
|
315
|
+
`[Raph] Phase task in "${e.phase}" exceeded 10000 deferred deliveries.`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
_cancelDelivery(e) {
|
|
320
|
+
if (!e.active || e.consumerOwner.disposed) {
|
|
321
|
+
e.resolution = "cancel";
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
this._assertDelivery(e);
|
|
325
|
+
const s = [];
|
|
326
|
+
if (this._acknowledgeDiscard(e, !1, s), s.length !== 0)
|
|
327
|
+
throw s.length === 1 ? s[0] : new AggregateError(s, "[Raph] Phase task cancellation failed.");
|
|
328
|
+
e.discardAcknowledged && (e.requested = C(e)), e.resolution = "cancel", e.deferCount = 0;
|
|
329
|
+
}
|
|
330
|
+
_finishDelivery(e) {
|
|
331
|
+
var t;
|
|
332
|
+
if (!e.inDelivery)
|
|
333
|
+
return;
|
|
334
|
+
const s = e.resolution;
|
|
335
|
+
if (e.inDelivery = !1, !e.active || e.consumerOwner.disposed) {
|
|
336
|
+
e.deliveryFirstCauseKey = void 0, e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = m;
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (e.paused) {
|
|
340
|
+
s !== "run" && !(s === "cancel" && e.discardAcknowledged) && (this._restoreDeliveryCausesBeforePending(e), e.requested = !0), e.deliveryFirstCauseKey = void 0, e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = m;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (s === "defer" && (this._restoreDeliveryCausesBeforePending(e), e.deferred = !0, this._deferred.add(e)), e.deliveryFirstCauseKey = void 0, e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = m, s !== "defer" && (e.requested || C(e))) {
|
|
344
|
+
const i = (t = e.binding) == null ? void 0 : t.rearmPending;
|
|
345
|
+
i === void 0 ? this._queue(e) : i();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
_appendCause(e, s, t) {
|
|
349
|
+
if (!e.active)
|
|
350
|
+
return;
|
|
351
|
+
const i = e.firstCause;
|
|
352
|
+
if (i === void 0) {
|
|
353
|
+
e.firstCause = s, e.firstCauseKey = t;
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (e.firstCauseKey === t) {
|
|
357
|
+
e.firstCause = b(i, s);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const n = e.extraCauses ?? (e.extraCauses = /* @__PURE__ */ new Map()), a = n.get(t);
|
|
361
|
+
n.set(t, a === void 0 ? s : b(a, s));
|
|
362
|
+
}
|
|
363
|
+
_queue(e, s = !0) {
|
|
364
|
+
if (!e.active || e.consumerOwner.disposed || this._disposed)
|
|
365
|
+
return;
|
|
366
|
+
if (e.paused) {
|
|
367
|
+
e.requested = !0;
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (e.inDelivery) {
|
|
371
|
+
e.requested = !0;
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (e.pending) {
|
|
375
|
+
s && this._schedule();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (e.deferred)
|
|
379
|
+
return;
|
|
380
|
+
e.discardAcknowledged = !1, e.pending = !0, e.sequence = this._taskSequence++;
|
|
381
|
+
let t = this._queues.get(e.phase);
|
|
382
|
+
t === void 0 && (t = [], this._queues.set(e.phase, t)), t.push(e), s && this._schedule();
|
|
383
|
+
}
|
|
384
|
+
_disposeTask(e) {
|
|
385
|
+
var i;
|
|
386
|
+
if (!e.active)
|
|
387
|
+
return;
|
|
388
|
+
e.active = !1, e.binding !== void 0 && (delete e.binding.cancelPending, delete e.binding.rearmPending, delete e.binding.abort, delete e.binding), e.pending = !1, e.deferred = !1, e.inDelivery && (e.resolution = "cancel"), e.firstCause = void 0, e.firstCauseKey = void 0, (i = e.extraCauses) == null || i.clear(), e.extraCauses = void 0, e.deliveryFirstCauseKey = void 0, e.deliveryExtraCauseKeys = void 0, e.deliveryCauses = m, this._deferred.delete(e);
|
|
389
|
+
const s = this._queues.get(e.phase);
|
|
390
|
+
if (s !== void 0) {
|
|
391
|
+
const n = s.indexOf(e);
|
|
392
|
+
n >= 0 && s.splice(n, 1), s.length === 0 && this._queues.delete(e.phase);
|
|
393
|
+
}
|
|
394
|
+
const t = (this._phaseBindings.get(e.phase) ?? 1) - 1;
|
|
395
|
+
t === 0 ? this._phaseBindings.delete(e.phase) : this._phaseBindings.set(e.phase, t), this._hasPending() || this._cancelScheduled(), this._settleIdleWaiters(void 0, !1);
|
|
396
|
+
}
|
|
397
|
+
_pauseTask(e) {
|
|
398
|
+
if (!e.active || e.paused)
|
|
399
|
+
return;
|
|
400
|
+
e.paused = !0, e.requested = e.requested || e.pending || e.deferred || e.inDelivery && e.resolution !== "run" && !(e.resolution === "cancel" && e.discardAcknowledged), e.pending = !1, e.deferred && (e.deferred = !1, this._deferred.delete(e));
|
|
401
|
+
const s = this._queues.get(e.phase);
|
|
402
|
+
if (s !== void 0) {
|
|
403
|
+
const t = s.indexOf(e);
|
|
404
|
+
t >= 0 && s.splice(t, 1), s.length === 0 && this._queues.delete(e.phase);
|
|
405
|
+
}
|
|
406
|
+
this._hasPending() || this._cancelScheduled(), this._settleIdleWaiters(void 0, !1);
|
|
407
|
+
}
|
|
408
|
+
_resumeTask(e) {
|
|
409
|
+
!e.active || !e.paused || e.consumerOwner.disposed || (e.paused = !1, (e.requested || C(e)) && (e.requested = !1, this._queue(e)));
|
|
410
|
+
}
|
|
411
|
+
_restoreDeliveryCausesBeforePending(e) {
|
|
412
|
+
const s = e.deliveryCauses;
|
|
413
|
+
if (s.length === 0)
|
|
414
|
+
return;
|
|
415
|
+
const t = e.firstCause, i = e.firstCauseKey, n = e.extraCauses;
|
|
416
|
+
e.firstCause = void 0, e.firstCauseKey = void 0, e.extraCauses = void 0, this._appendCause(e, s[0], e.deliveryFirstCauseKey);
|
|
417
|
+
const a = e.deliveryExtraCauseKeys;
|
|
418
|
+
for (let r = 1; r < s.length; r++)
|
|
419
|
+
this._appendCause(e, s[r], a[r - 1]);
|
|
420
|
+
if (t !== void 0 && (this._appendCause(e, t, i), n !== void 0))
|
|
421
|
+
for (const [r, h] of n)
|
|
422
|
+
this._appendCause(e, h, r);
|
|
423
|
+
}
|
|
424
|
+
_takePhase(e) {
|
|
425
|
+
const s = this._queues.get(e);
|
|
426
|
+
return s === void 0 ? [] : (this._queues.delete(e), s);
|
|
427
|
+
}
|
|
428
|
+
_schedule() {
|
|
429
|
+
if (this._running || this._scheduled || this._disposed)
|
|
430
|
+
return;
|
|
431
|
+
if (this._scheduler === "sync") {
|
|
432
|
+
if (this._deferSync())
|
|
433
|
+
return;
|
|
434
|
+
this.flush();
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
this._scheduled = !0;
|
|
438
|
+
const e = ++this._scheduleToken, s = () => {
|
|
439
|
+
this._disposed || !this._scheduled || e !== this._scheduleToken || (this._scheduled = !1, this._frameHandle = void 0, this._frameHandleKind = void 0, this.flush());
|
|
440
|
+
};
|
|
441
|
+
if (this._scheduler === "microtask") {
|
|
442
|
+
queueMicrotask(s);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
typeof globalThis.requestAnimationFrame == "function" ? (this._frameHandleKind = "animation-frame", this._frameHandle = globalThis.requestAnimationFrame(s)) : (this._frameHandleKind = "timeout", this._frameHandle = setTimeout(s, 16));
|
|
446
|
+
}
|
|
447
|
+
_scheduleDeferredTurn() {
|
|
448
|
+
if (this._scheduled || this._disposed)
|
|
449
|
+
return;
|
|
450
|
+
this._scheduled = !0;
|
|
451
|
+
const e = ++this._scheduleToken, s = () => {
|
|
452
|
+
this._disposed || !this._scheduled || e !== this._scheduleToken || (this._scheduled = !1, this._frameHandle = void 0, this._frameHandleKind = void 0, this._activateDeferred(), this._hasQueued() ? this.flush() : this._settleIdleWaiters(void 0, !1));
|
|
453
|
+
};
|
|
454
|
+
this._scheduler === "animationFrame" ? typeof globalThis.requestAnimationFrame == "function" ? (this._frameHandleKind = "animation-frame", this._frameHandle = globalThis.requestAnimationFrame(s)) : (this._frameHandleKind = "timeout", this._frameHandle = setTimeout(s, 16)) : queueMicrotask(s);
|
|
455
|
+
}
|
|
456
|
+
_cancelScheduled() {
|
|
457
|
+
var e;
|
|
458
|
+
this._scheduled && (this._scheduled = !1, this._scheduleToken++, this._frameHandleKind === "animation-frame" && this._frameHandle !== void 0 ? (e = globalThis.cancelAnimationFrame) == null || e.call(globalThis, this._frameHandle) : this._frameHandleKind === "timeout" && this._frameHandle !== void 0 && clearTimeout(this._frameHandle), this._frameHandle = void 0, this._frameHandleKind = void 0);
|
|
459
|
+
}
|
|
460
|
+
_activateDeferred() {
|
|
461
|
+
const e = [...this._deferred];
|
|
462
|
+
this._deferred.clear();
|
|
463
|
+
for (const s of e)
|
|
464
|
+
s.deferred = !1, this._queue(s, !1);
|
|
465
|
+
}
|
|
466
|
+
_nextFrame() {
|
|
467
|
+
var t;
|
|
468
|
+
const e = ((t = globalThis.performance) == null ? void 0 : t.now()) ?? Date.now();
|
|
469
|
+
if (this._firstFrameAt === void 0 || this._lastFrameAt === void 0)
|
|
470
|
+
return this._firstFrameAt = e, this._lastFrameAt = e, this._frame = Object.freeze({ now: e, delta: 0, elapsed: 0, frame: 0 });
|
|
471
|
+
this._frameNumber++;
|
|
472
|
+
const s = Object.freeze({
|
|
473
|
+
now: e,
|
|
474
|
+
delta: Math.min(Math.max(e - this._lastFrameAt, 0), 100),
|
|
475
|
+
elapsed: Math.max(e - this._firstFrameAt, 0),
|
|
476
|
+
frame: this._frameNumber
|
|
477
|
+
});
|
|
478
|
+
return this._lastFrameAt = e, this._frame = s;
|
|
479
|
+
}
|
|
480
|
+
_assertRetainedPhases(e) {
|
|
481
|
+
for (const s of this._phaseBindings.keys())
|
|
482
|
+
if (!e.has(s))
|
|
483
|
+
throw new Error(`[Raph] Cannot remove phase "${s}" while it is still bound.`);
|
|
484
|
+
for (const s of this._queues.keys())
|
|
485
|
+
if (!e.has(s))
|
|
486
|
+
throw new Error(`[Raph] Cannot remove phase "${s}" while it has pending work.`);
|
|
487
|
+
}
|
|
488
|
+
_assertDelivery(e) {
|
|
489
|
+
if (!e.active || !e.inDelivery || e.resolution !== "unresolved")
|
|
490
|
+
throw new g("[Raph] Phase task delivery is already resolved.");
|
|
491
|
+
}
|
|
492
|
+
_hasQueued() {
|
|
493
|
+
for (const e of this._queues.values())
|
|
494
|
+
if (e.some((s) => s.active && s.pending))
|
|
495
|
+
return !0;
|
|
496
|
+
return !1;
|
|
497
|
+
}
|
|
498
|
+
_hasPending() {
|
|
499
|
+
return this._hasQueued() || this._deferred.size !== 0;
|
|
500
|
+
}
|
|
501
|
+
_cancelAllQueued(e, s = []) {
|
|
502
|
+
const t = /* @__PURE__ */ new Set();
|
|
503
|
+
for (const i of this._queues.values())
|
|
504
|
+
for (const n of i)
|
|
505
|
+
t.add(n);
|
|
506
|
+
this._queues.clear();
|
|
507
|
+
for (const i of t)
|
|
508
|
+
i.pending = !1, e && this._acknowledgeDiscard(i, !0, s), this._clearPendingDelivery(i);
|
|
509
|
+
}
|
|
510
|
+
_cancelAllDeferred(e, s = []) {
|
|
511
|
+
const t = [...this._deferred];
|
|
512
|
+
this._deferred.clear();
|
|
513
|
+
for (const i of t)
|
|
514
|
+
i.deferred = !1, e && this._acknowledgeDiscard(i, !0, s), this._clearPendingDelivery(i);
|
|
515
|
+
}
|
|
516
|
+
_acknowledgeDiscard(e, s, t) {
|
|
517
|
+
if (e.discardAcknowledged)
|
|
518
|
+
return;
|
|
519
|
+
const i = e.binding, n = i == null ? void 0 : i.cancelPending;
|
|
520
|
+
if (n === void 0) {
|
|
521
|
+
e.discardAcknowledged = !0;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
if (n()) {
|
|
526
|
+
e.discardAcknowledged = !0;
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (!s) {
|
|
530
|
+
t.push(new g(
|
|
531
|
+
`[Raph] Initial effect delivery in "${e.phase}" cannot be cancelled before dependency collection.`
|
|
532
|
+
));
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const a = i == null ? void 0 : i.abort;
|
|
536
|
+
if (a === void 0) {
|
|
537
|
+
t.push(new g(
|
|
538
|
+
`[Raph] Initial effect delivery in "${e.phase}" could not be aborted safely.`
|
|
539
|
+
));
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
a(), e.discardAcknowledged = !0;
|
|
543
|
+
} catch (a) {
|
|
544
|
+
t.push(a);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
_clearPendingDelivery(e) {
|
|
548
|
+
var s;
|
|
549
|
+
e.requested = !1, e.firstCause = void 0, e.firstCauseKey = void 0, (s = e.extraCauses) == null || s.clear(), e.extraCauses = void 0;
|
|
550
|
+
}
|
|
551
|
+
_settleIdleWaiters(e, s) {
|
|
552
|
+
if (!s && (this._running || this._scheduled || this._hasPending()))
|
|
553
|
+
return;
|
|
554
|
+
const t = [...this._idleWaiters];
|
|
555
|
+
this._idleWaiters.clear();
|
|
556
|
+
for (const i of t)
|
|
557
|
+
e === void 0 ? i.resolve() : i.reject(e);
|
|
558
|
+
}
|
|
559
|
+
_assertAlive() {
|
|
560
|
+
if (this._disposed)
|
|
561
|
+
throw new P("[Raph] Phase pipeline is disposed.");
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function T(l, e) {
|
|
565
|
+
return e.priority - l.priority || l.sequence - e.sequence;
|
|
566
|
+
}
|
|
567
|
+
function C(l) {
|
|
568
|
+
return l.firstCause !== void 0;
|
|
569
|
+
}
|
|
570
|
+
function b(l, e) {
|
|
571
|
+
const s = l.events === void 0 ? e.events : e.events === void 0 ? l.events : Object.freeze([...l.events, ...e.events]), t = l.structure === void 0 ? e.structure : e.structure === void 0 ? l.structure : Object.freeze({
|
|
572
|
+
node: e.structure.node,
|
|
573
|
+
oldParent: l.structure.oldParent,
|
|
574
|
+
oldIndex: l.structure.oldIndex,
|
|
575
|
+
newParent: e.structure.newParent,
|
|
576
|
+
newIndex: e.structure.newIndex
|
|
577
|
+
});
|
|
578
|
+
return Object.freeze({
|
|
579
|
+
...e,
|
|
580
|
+
previous: l.previous,
|
|
581
|
+
...s === void 0 ? {} : { events: s },
|
|
582
|
+
...t === void 0 ? {} : { structure: t }
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
export {
|
|
586
|
+
R as RaphPhasePipeline
|
|
587
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(o,r){const i=r.direction??"parents-first",s=o.map(n=>{const t=r.node(n);return{node:t,path:t==null?void 0:k(t),task:n}}),e=l(s);return s.sort((n,t)=>{if(n.path===void 0||t.path===void 0)return n.path!==t.path?n.path===void 0?1:-1:t.task.priority-n.task.priority||n.task.sequence-t.task.sequence;const c=d(n.path,t.path,e,i==="children-first");return c!==0?c:t.task.priority-n.task.priority||n.task.sequence-t.task.sequence}),s.map(n=>n.task)}function d(o,r,i,s){if(o[o.length-1]===r[r.length-1])return 0;let e=0;const n=Math.min(o.length,r.length);for(;e<n&&o[e]===r[e];)e++;if(e===o.length)return s?1:-1;if(e===r.length)return s?-1:1;const t=o[e],c=r[e];if(t.priority!==c.priority)return c.priority-t.priority;const a=i.get(t),p=i.get(c);return a!==void 0&&p!==void 0?a-p:t.id.localeCompare(c.id)}function l(o){const r=new Set;for(const s of o){const e=s.path;if(e!==void 0)for(let n=0;n+1<e.length;n++)r.add(e[n])}const i=new Map;for(const s of r){const e=s.children;for(let n=0;n<e.length;n++)i.set(e[n],n)}return i}function k(o){const r=[];for(let i=o;i!==null;i=i.parent)r.push(i);return r.reverse(),r}exports.orderPhaseTasks=u;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function k(o, r) {
|
|
2
|
+
const i = r.direction ?? "parents-first", s = o.map((n) => {
|
|
3
|
+
const t = r.node(n);
|
|
4
|
+
return { node: t, path: t == null ? void 0 : l(t), task: n };
|
|
5
|
+
}), e = d(s);
|
|
6
|
+
return s.sort((n, t) => {
|
|
7
|
+
if (n.path === void 0 || t.path === void 0)
|
|
8
|
+
return n.path !== t.path ? n.path === void 0 ? 1 : -1 : t.task.priority - n.task.priority || n.task.sequence - t.task.sequence;
|
|
9
|
+
const c = u(
|
|
10
|
+
n.path,
|
|
11
|
+
t.path,
|
|
12
|
+
e,
|
|
13
|
+
i === "children-first"
|
|
14
|
+
);
|
|
15
|
+
return c !== 0 ? c : t.task.priority - n.task.priority || n.task.sequence - t.task.sequence;
|
|
16
|
+
}), s.map((n) => n.task);
|
|
17
|
+
}
|
|
18
|
+
function u(o, r, i, s) {
|
|
19
|
+
if (o[o.length - 1] === r[r.length - 1])
|
|
20
|
+
return 0;
|
|
21
|
+
let e = 0;
|
|
22
|
+
const n = Math.min(o.length, r.length);
|
|
23
|
+
for (; e < n && o[e] === r[e]; )
|
|
24
|
+
e++;
|
|
25
|
+
if (e === o.length)
|
|
26
|
+
return s ? 1 : -1;
|
|
27
|
+
if (e === r.length)
|
|
28
|
+
return s ? -1 : 1;
|
|
29
|
+
const t = o[e], c = r[e];
|
|
30
|
+
if (t.priority !== c.priority)
|
|
31
|
+
return c.priority - t.priority;
|
|
32
|
+
const a = i.get(t), p = i.get(c);
|
|
33
|
+
return a !== void 0 && p !== void 0 ? a - p : t.id.localeCompare(c.id);
|
|
34
|
+
}
|
|
35
|
+
function d(o) {
|
|
36
|
+
const r = /* @__PURE__ */ new Set();
|
|
37
|
+
for (const s of o) {
|
|
38
|
+
const e = s.path;
|
|
39
|
+
if (e !== void 0)
|
|
40
|
+
for (let n = 0; n + 1 < e.length; n++)
|
|
41
|
+
r.add(e[n]);
|
|
42
|
+
}
|
|
43
|
+
const i = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const s of r) {
|
|
45
|
+
const e = s.children;
|
|
46
|
+
for (let n = 0; n < e.length; n++)
|
|
47
|
+
i.set(e[n], n);
|
|
48
|
+
}
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
function l(o) {
|
|
52
|
+
const r = [];
|
|
53
|
+
for (let i = o; i !== null; i = i.parent)
|
|
54
|
+
r.push(i);
|
|
55
|
+
return r.reverse(), r;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
k as orderPhaseTasks
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var u=(a,s,t)=>s in a?p(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var i=(a,s,t)=>u(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../path/data-path.utils.cjs"),f=require("../errors.cjs"),w=require("../ownership/throwDisposalErrors.cjs");class A{constructor(s,t,h,r,e,o,n,d,v,c,l){i(this,"path");i(this,"options");i(this,"_revision");i(this,"_disposeRevision");i(this,"_isTracking");i(this,"_store");i(this,"_release");i(this,"_masks");i(this,"_assertOwnerAlive");i(this,"_assertTrackedRead");i(this,"_assertWriteAllowed");i(this,"_runWrite");i(this,"_notifyEvents");i(this,"_hasRevisionSubscribers");i(this,"_stop");i(this,"_activationLeases",0);i(this,"_trackedActivation",!1);i(this,"_disposed",!1);const _=e._ownedSignal(0,c);this._store=s,this._revision=_.source,this._disposeRevision=_.dispose,this._isTracking=e._isTracking,this.path=t.canonical,this.options=h,this._release=r,this._masks=k.pathRelationMasks(t),this._assertOwnerAlive=o,this._assertTrackedRead=n,this._assertWriteAllowed=d,this._runWrite=v,this._notifyEvents=l,this._hasRevisionSubscribers=_.hasSubscribers}get disposed(){return this._disposed}get(){var s;return this._assertAlive(),(s=this._assertTrackedRead)==null||s.call(this),this._isTracking()?this._readTracked():this._store.peek(this.path)}peek(){return this._assertAlive(),this._store.peek(this.path)}set(s){var t;this._assertAlive(),(t=this._assertWriteAllowed)==null||t.call(this),this._write(()=>this._store.set(this.path,s))}merge(s){var t;this._assertAlive(),(t=this._assertWriteAllowed)==null||t.call(this),this._write(()=>this._store.merge(this.path,s))}delete(){var s;this._assertAlive(),(s=this._assertWriteAllowed)==null||s.call(this),this._write(()=>this._store.delete(this.path))}has(){return this._assertAlive(),this._store.has(this.path)}dispose(){if(this._disposed)return;const s=this._runWrite;s===void 0?this._disposeNow():s(()=>this._disposeNow())}_disposeNow(){if(this._disposed)return;this._disposed=!0;const s=[],t=this._stop;this._stop=void 0;const h=this._disposeRevision;this._disposeRevision=void 0;const r=this._release;this._release=void 0,this._revision=void 0,this._isTracking=void 0,this._store=void 0,this._assertOwnerAlive=void 0,this._assertTrackedRead=void 0,this._assertWriteAllowed=void 0,this._runWrite=void 0,this._notifyEvents=void 0,this._hasRevisionSubscribers=void 0,this._activationLeases=0,this._trackedActivation=!1;try{t==null||t()}catch(e){s.push(e)}try{h==null||h()}catch(e){s.push(e)}try{r==null||r(this)}catch(e){s.push(e)}w.throwDisposalErrors(s,`[Raph] Path handle "${this.path}" disposal failed.`)}_getTracked(){var s;return this._assertAlive(),(s=this._assertTrackedRead)==null||s.call(this),this._readTracked()}_activate(){this._assertAlive(),this._activationLeases++;try{this._observe()}catch(t){throw this._activationLeases--,t}let s=!0;return()=>{s&&(s=!1,this._activationLeases!==0&&this._activationLeases--,this._releaseObserverIfIdle())}}_readTracked(){return this._trackedActivation=!0,this._observe(),this._revision.get(),this._store.get(this.path)}_observe(){this._stop??(this._stop=this._store.watch(this._masks,s=>{const t=()=>{var e,o;if(this._disposed)return;const r=this._revision;r!==void 0&&((o=this._notifyEvents)==null||o.call(this,s,((e=this._hasRevisionSubscribers)==null?void 0:e.call(this))??!1),!(this._disposed||this._revision!==r)&&r.set(r.peek()+1))},h=this._runWrite;h===void 0?t():h(t)}))}_releaseObserverIfIdle(){if(this._disposed||this._trackedActivation||this._activationLeases!==0)return;const s=this._stop;this._stop=void 0,s==null||s()}_write(s){const t=this._runWrite;t===void 0?s():t(s)}_assertAlive(){var s;if(this._disposed)throw new f.RaphDisposedError(`[Raph] Path handle "${this.path}" is disposed.`);(s=this._assertOwnerAlive)==null||s.call(this)}}exports.PathHandle=A;
|