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