@pravosleva/reactive-engine 2.7.1 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/core/core.d.ts +89 -203
  2. package/dist/core/core.d.ts.map +1 -1
  3. package/dist/core/core.global.d.ts +64 -8
  4. package/dist/core/core.global.d.ts.map +1 -1
  5. package/dist/core/core.logger.d.ts +2 -0
  6. package/dist/core/core.logger.d.ts.map +1 -1
  7. package/dist/core/core.method.reactive.d.ts +2 -4
  8. package/dist/core/core.method.reactive.d.ts.map +1 -1
  9. package/dist/core/core.method.resource.d.ts +3 -11
  10. package/dist/core/core.method.resource.d.ts.map +1 -1
  11. package/dist/core/types.d.ts +1 -0
  12. package/dist/core/types.d.ts.map +1 -1
  13. package/dist/core.global.mjs +31 -4
  14. package/dist/core.global.mjs.map +1 -1
  15. package/dist/core.logger.mjs +49 -2
  16. package/dist/core.logger.mjs.map +1 -1
  17. package/dist/core.method.reactive.mjs +73 -30
  18. package/dist/core.method.reactive.mjs.map +1 -1
  19. package/dist/core.method.resource.mjs +122 -138
  20. package/dist/core.method.resource.mjs.map +1 -1
  21. package/dist/core.mjs +379 -150
  22. package/dist/core.mjs.map +1 -1
  23. package/dist/index.mjs +12 -12
  24. package/dist/index2.mjs +5 -5
  25. package/dist/react/hooks/useReactiveSubscription.mjs +13 -13
  26. package/dist/react/hooks/useReactiveSubscription.mjs.map +1 -1
  27. package/dist/react/hooks/useReactiveValue.d.ts +0 -4
  28. package/dist/react/hooks/useReactiveValue.d.ts.map +1 -1
  29. package/dist/react/hooks/useReactiveValue.mjs +24 -9
  30. package/dist/react/hooks/useReactiveValue.mjs.map +1 -1
  31. package/dist/reactive-engine.umd.js +2 -2
  32. package/dist/reactive-engine.umd.js.map +1 -1
  33. package/package.json +4 -2
  34. package/dist/core.method.computed.mjs +0 -167
  35. package/dist/core.method.computed.mjs.map +0 -1
  36. package/dist/core.method.effect.mjs +0 -120
  37. package/dist/core.method.effect.mjs.map +0 -1
  38. package/dist/core.method.signal.mjs +0 -106
  39. package/dist/core.method.signal.mjs.map +0 -1
  40. package/dist/core.method.untrack.mjs +0 -14
  41. package/dist/core.method.untrack.mjs.map +0 -1
  42. package/dist/utils/getExtractedValues.mjs +0 -24
  43. package/dist/utils/getExtractedValues.mjs.map +0 -1
package/dist/core.mjs CHANGED
@@ -1,90 +1,261 @@
1
- import { createComputed as e } from "./core.method.computed.mjs";
2
- import { createSignal as t } from "./core.method.signal.mjs";
3
- import { executeUntrack as n } from "./core.method.untrack.mjs";
4
- import { createReactive as r } from "./core.method.reactive.mjs";
5
- import { createEffect as i } from "./core.method.effect.mjs";
6
- import { ReactiveDebounceLogger as a } from "./core.logger.mjs";
7
- import { createResource as o } from "./core.method.resource.mjs";
1
+ import { ReactiveDebounceLogger as e, queueLog as t } from "./core.logger.mjs";
2
+ import { createReactive as n } from "./core.method.reactive.mjs";
3
+ import { createResource as r } from "./core.method.resource.mjs";
8
4
  //#region src/core/core.ts
9
- var s = {
10
- signal: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
11
- computed: "background: #42b883; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
12
- effect: "background: #e01e5a; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
13
- batch: "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
14
- resource: "background: #d97706; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
15
- reactive: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;"
16
- }, c = null;
17
- function l(e) {
18
- if (e === null) return "null";
19
- if (e === void 0) return "undefined";
20
- if (typeof e == "object") try {
21
- return JSON.stringify(e);
22
- } catch {
23
- return "[Cyclic Object or Layer]";
24
- }
25
- return String(e);
26
- }
27
- function u(e, t, n) {
28
- c || (c = {
29
- id: Math.random().toString(36).substring(2, 9),
30
- pendingLogQueue: [],
31
- isFlushing: !1
32
- }, queueMicrotask(() => d())), c.pendingLogQueue.push({
33
- type: e,
34
- label: t,
35
- from: n?.from,
36
- to: n?.to,
37
- payload: n?.payload,
38
- timestamp: Date.now()
39
- });
40
- }
41
- function d() {
42
- if (!c || c.isFlushing) return;
43
- c.isFlushing = !0;
44
- let e = c.pendingLogQueue;
45
- if (e.length === 0) {
46
- c = null;
47
- return;
48
- }
49
- console.groupCollapsed(`%cREACTIVE TRANSACTION%c [id: ${c.id}] (${e.length} operations)`, "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;", "color: #888; font-weight: normal;");
50
- for (let t of e) {
51
- let e = s[t.type], n = t.from !== void 0 || t.to !== void 0, r = `%c${t.type.toUpperCase()}%c ${t.label}`;
52
- n && (t.from ? r += ` ${l(t.from)} → ${l(t.to)}` : r += ` (${l(t.to)})`), t.payload === void 0 ? console.log(r, e, "color: inherit;") : (console.groupCollapsed(r, e, "color: inherit;"), console.log("Payload:", t.payload), console.groupEnd());
53
- }
54
- console.groupEnd(), c = null;
55
- }
56
- var f = class {
57
- frameworkPrefix = "core";
58
- logger;
59
- epoch = 0;
5
+ var i = class {
6
+ source = null;
7
+ target = null;
8
+ nextSubscriber = null;
9
+ prevSubscriber = null;
10
+ nextDependency = null;
11
+ prevDependency = null;
12
+ version = 0;
13
+ clear() {
14
+ this.source = null, this.target = null, this.nextSubscriber = null, this.prevSubscriber = null, this.nextDependency = null, this.prevDependency = null, this.version = 0;
15
+ }
16
+ }, a = class {
17
+ static pool = [];
18
+ static size = 0;
19
+ static maxPoolSize = 1e5;
20
+ static acquire(e, t) {
21
+ if (this.size > 0) {
22
+ this.size--;
23
+ let n = this.pool[this.size];
24
+ return this.pool[this.size] = null, n.source = e, n.target = t, n;
25
+ }
26
+ let n = new i();
27
+ return n.source = e, n.target = t, n;
28
+ }
29
+ static release(e) {
30
+ this.size < this.maxPoolSize && (e.clear(), this.pool[this.size] = e, this.size++);
31
+ }
32
+ }, o = class {
33
+ id;
34
+ type;
35
+ version = 0;
36
+ state = 0;
37
+ depth = 0;
38
+ subscribersHead = null;
39
+ subscribersTail = null;
40
+ dependenciesHead = null;
41
+ dependenciesTail = null;
42
+ _value;
43
+ _prevValue;
44
+ fn = null;
45
+ cleanups = /* @__PURE__ */ new Set();
46
+ isDisposed = !1;
47
+ ownedEffects = /* @__PURE__ */ new Set();
48
+ wrapper = null;
49
+ engine = null;
50
+ constructor(e, t, n) {
51
+ this.type = e, this.id = t, this._value = n, this._prevValue = n;
52
+ }
53
+ get subscribers() {
54
+ let e = /* @__PURE__ */ new Set(), t = this.subscribersHead;
55
+ for (; t !== null;) t.target && e.add(t.target), t = t.nextSubscriber;
56
+ return e;
57
+ }
58
+ get dependencies() {
59
+ let e = /* @__PURE__ */ new Set(), t = this.dependenciesHead;
60
+ for (; t !== null;) t.source && e.add(t.source), t = t.nextDependency;
61
+ return e;
62
+ }
63
+ }, s = class {
64
+ buckets = [];
65
+ maxDepth = -1;
66
+ schedule(e) {
67
+ let t = e.depth;
68
+ this.buckets[t] || (this.buckets[t] = []), this.buckets[t].includes(e) || (this.buckets[t].push(e), t > this.maxDepth && (this.maxDepth = t));
69
+ }
70
+ clearAll() {
71
+ for (let e = 0; e <= this.maxDepth; e++) {
72
+ let t = this.buckets[e];
73
+ if (t) {
74
+ for (let e of t) e.state = 0;
75
+ this.buckets[e] = [];
76
+ }
77
+ }
78
+ this.maxDepth = -1;
79
+ }
80
+ flush(e) {
81
+ let t = e.activeConsumer;
82
+ try {
83
+ let t = 0;
84
+ for (; t <= this.maxDepth;) {
85
+ let n = this.buckets[t];
86
+ if (!n || n.length === 0) {
87
+ t++;
88
+ continue;
89
+ }
90
+ this.buckets[t] = [], n.sort((e, t) => t.depth - e.depth);
91
+ for (let t of n) if (!(t.isDisposed || t.state === 0) && (t.state === 1 && (e.checkNeedsUpdate(t) ? t.state = 2 : t.state = 0), t.state === 2)) try {
92
+ e.runEffectNode(t);
93
+ } catch (e) {
94
+ throw this.clearAll(), e;
95
+ }
96
+ let r = !1;
97
+ for (let e = 0; e <= this.maxDepth; e++) if (this.buckets[e] && this.buckets[e].length > 0) {
98
+ t = e, r = !0;
99
+ break;
100
+ }
101
+ r || t++;
102
+ }
103
+ } finally {
104
+ e.activeConsumer = t, this.maxDepth = -1;
105
+ }
106
+ }
107
+ }, c = class {
60
108
  activeConsumer = null;
61
109
  batchDepth = 0;
62
- subscriberId = 0;
63
- pendingEffects = [];
64
- maxPendingDepth = 0;
110
+ batchedSignals = [];
111
+ batchInitialValues = /* @__PURE__ */ new Map();
65
112
  computedCache = /* @__PURE__ */ new WeakMap();
66
- diRegistry = /* @__PURE__ */ new Map();
67
- diCache = /* @__PURE__ */ new Map();
113
+ logger;
68
114
  proxyCache = /* @__PURE__ */ new WeakMap();
69
115
  proxyTargets = /* @__PURE__ */ new WeakSet();
70
116
  reactiveSignals = /* @__PURE__ */ new WeakMap();
117
+ scheduler = new s();
118
+ currentOwner = null;
119
+ effectIdCounter = 0;
120
+ diRegistry = /* @__PURE__ */ new Map();
121
+ diCache = /* @__PURE__ */ new Map();
71
122
  cycleDetectionStack = /* @__PURE__ */ new Set();
72
- batchedSignals = /* @__PURE__ */ new Set();
73
- activeOwner = null;
74
- activeCleanupNode = null;
75
- pendingCleanups = /* @__PURE__ */ new Set();
76
- queueCleanup(e) {
77
- this.pendingCleanups.add(e);
78
- }
79
123
  constructor(e) {
80
124
  this.logger = e?.logger || { isEnabled: !1 };
81
125
  }
82
- scheduleEffect(e) {
83
- let t = e.depth || 0;
84
- this.pendingEffects[t] || (this.pendingEffects[t] = /* @__PURE__ */ new Set()), this.pendingEffects[t].add(e), t > this.maxPendingDepth && (this.maxPendingDepth = t);
126
+ log(n) {
127
+ !this.logger || !this.logger.isEnabled || e.processLog(this.logger, t, n);
128
+ }
129
+ signal(e, t) {
130
+ let n = typeof t == "string" ? t : t?.name || "signal", r = typeof t == "object" ? t?.validate : void 0, i = typeof t == "object" ? t?.isInternalCoreSignal : !1, a = new o("signal", n, e);
131
+ a.engine = this;
132
+ let s = this;
133
+ this.log({
134
+ type: "signal",
135
+ label: n,
136
+ details: { to: e },
137
+ isInternalCoreSignal: i
138
+ });
139
+ let c = {
140
+ _node: a,
141
+ _engine: this,
142
+ get value() {
143
+ return s.activeConsumer && s.trackNode(a, s.activeConsumer), a._value;
144
+ },
145
+ set value(e) {
146
+ if (r) {
147
+ let t = r(e);
148
+ if (t === !1 || typeof t == "string") {
149
+ console.error(`[Validation Error] Invalid value supplied to signal "${n}": ${t}`);
150
+ return;
151
+ }
152
+ }
153
+ let t = typeof e == "object" && !!e;
154
+ if (Object.is(a._value, e) && !t) return;
155
+ let o = a._value;
156
+ a._prevValue = o, s.batchDepth > 0 && !s.batchInitialValues.has(a) && s.batchInitialValues.set(a, {
157
+ value: o,
158
+ version: a.version
159
+ }), a._value = e, a.version++, s.log({
160
+ type: "signal",
161
+ label: n,
162
+ details: {
163
+ from: o,
164
+ to: e
165
+ },
166
+ isInternalCoreSignal: i
167
+ }), s.notifySubscribers(a, 2), s.batchDepth > 0 ? s.batchedSignals.includes(a) || s.batchedSignals.push(a) : s.flushEffects();
168
+ },
169
+ get valueWithoutTracking() {
170
+ return a._value;
171
+ },
172
+ subscribe(e) {
173
+ return s.effect(() => {
174
+ e(c.value);
175
+ });
176
+ },
177
+ destroy() {
178
+ s.disposeNode(a);
179
+ }
180
+ };
181
+ return a.wrapper = c, c;
182
+ }
183
+ notifySubscribers(e, t) {
184
+ let n = e.subscribersHead;
185
+ for (; n !== null;) {
186
+ let e = n.target;
187
+ if (e === this.activeConsumer) {
188
+ n = n.nextSubscriber;
189
+ continue;
190
+ }
191
+ e.state < t && (e.state = t, e.type === "effect" ? this.scheduler.schedule(e) : this.notifySubscribers(e, 1)), n = n.nextSubscriber;
192
+ }
193
+ }
194
+ computed(e, t) {
195
+ let n = new o("computed", t || "computed");
196
+ n.engine = this, n.fn = e, n.state = 2;
197
+ let r = this, i = {
198
+ _node: n,
199
+ _engine: this,
200
+ get value() {
201
+ return n.state === 1 && (r.checkNeedsUpdate(n) ? n.state = 2 : n.state = 0), n.state === 2 && (n._value, r.evaluateComputed(n)), r.activeConsumer && r.trackNode(n, r.activeConsumer), n._value;
202
+ },
203
+ get valueWithoutTracking() {
204
+ return n._value;
205
+ },
206
+ subscribe(e) {
207
+ return r.effect(() => {
208
+ e(i.value);
209
+ });
210
+ },
211
+ destroy() {
212
+ r.disposeNode(n);
213
+ },
214
+ _isDirty() {
215
+ return n.state === 2;
216
+ },
217
+ get dependencies() {
218
+ let e = /* @__PURE__ */ new Set(), t = n.dependenciesHead;
219
+ for (; t !== null;) t.source && t.source.wrapper && e.add(t.source.wrapper), t = t.nextDependency;
220
+ return e;
221
+ }
222
+ };
223
+ return n.wrapper = i, this.batchDepth === 0 && this.computedCache.set(e, i), i;
224
+ }
225
+ effect(e, t) {
226
+ let n = t || "effect", r = new o("effect", n);
227
+ r.state = 2, r.depth = this.currentOwner ? this.currentOwner.depth + 1 : 0, r.wrapper = {
228
+ id: ++this.effectIdCounter,
229
+ run: () => {
230
+ this.runEffectNode(r);
231
+ },
232
+ markDirty: () => {
233
+ r.state = 2, this.scheduler.schedule(r);
234
+ },
235
+ cleanups: r.cleanups,
236
+ label: n,
237
+ get isDirty() {
238
+ return r.state === 2;
239
+ },
240
+ get isDisposed() {
241
+ return r.isDisposed;
242
+ },
243
+ _node: r
244
+ }, r.fn = () => {
245
+ this.log({
246
+ type: "effect",
247
+ label: n
248
+ });
249
+ let t = e();
250
+ typeof t == "function" && r.cleanups.add(t);
251
+ }, this.currentOwner && this.currentOwner.ownedEffects.add(r), this.runEffectNode(r);
252
+ let i = () => {
253
+ this.disposeNode(r);
254
+ };
255
+ return i._node = r, i;
85
256
  }
86
- queueLog(e, t, n) {
87
- u(e, t, n);
257
+ resource(e, t, n) {
258
+ return r(this, e, t, n);
88
259
  }
89
260
  batch(e) {
90
261
  this.batchDepth++;
@@ -92,79 +263,148 @@ var f = class {
92
263
  return e();
93
264
  } finally {
94
265
  if (this.batchDepth--, this.batchDepth === 0) {
95
- if (this.batchedSignals.size > 0) {
96
- for (let e of this.batchedSignals) e._flushBatch && e._flushBatch();
97
- this.batchedSignals.clear();
266
+ for (let e of this.batchedSignals) {
267
+ let t = this.batchInitialValues.get(e), n = e._value !== null && typeof e._value == "object";
268
+ t && !n && Object.is(e._value, t.value) && (e.version = t.version, this.resetCleanState(e));
98
269
  }
99
- this.flushEffects();
270
+ this.batchedSignals = [], this.batchInitialValues.clear(), this.flushEffects();
100
271
  }
101
272
  }
102
273
  }
103
- flushEffects() {
104
- if (this.batchDepth > 0) return;
105
- let e = this.activeConsumer;
274
+ resetCleanState(e) {
275
+ let t = e.subscribersHead;
276
+ for (; t !== null;) {
277
+ let e = t.target;
278
+ e.state > 0 && !this.checkNeedsUpdate(e) && (e.state = 0, this.resetCleanState(e)), t = t.nextSubscriber;
279
+ }
280
+ }
281
+ untrack(e) {
282
+ let t = this.activeConsumer;
283
+ this.activeConsumer = null;
106
284
  try {
107
- for (let e = 0; e <= this.maxPendingDepth; e++) {
108
- let t = this.pendingEffects[e];
109
- if (!t || t.size === 0) continue;
110
- let n = Array.from(t);
111
- t.clear();
112
- for (let t of n) if (!t.isDisposed && t.isDirty) {
113
- if (t.dependencies && t.dependencies.size > 0) {
114
- let e = !1;
115
- for (let n of t.dependencies) {
116
- let r = n._node || n;
117
- r.type === "computed" && r.state > 0 && r.update && r.update(), t.depVersions && t.depVersions.get(n) !== r.version && (e = !0);
118
- }
119
- if (!e && t.dependencies.size > 0) {
120
- t.isDirty = !1;
121
- continue;
122
- }
123
- }
124
- try {
125
- t.run();
126
- } catch (t) {
127
- for (let t = e; t <= this.maxPendingDepth; t++) {
128
- let e = this.pendingEffects[t];
129
- if (e) {
130
- for (let t of e) t.isDirty = !1;
131
- e.clear();
132
- }
133
- }
134
- throw this.maxPendingDepth = 0, t;
135
- }
136
- }
137
- if (e > 0) {
138
- let t = !1;
139
- for (let n = 0; n < e; n++) if (this.pendingEffects[n] && this.pendingEffects[n].size > 0) {
140
- t = !0;
141
- break;
142
- }
143
- t && (e = -1);
144
- }
145
- }
146
- this.maxPendingDepth = 0;
285
+ return e();
147
286
  } finally {
148
- this.activeConsumer = e;
287
+ this.activeConsumer = t;
149
288
  }
150
289
  }
151
- log(e) {
152
- !this.logger || !this.logger.isEnabled || a.processLog(this.logger, u, e);
290
+ flushEffects() {
291
+ this.batchDepth === 0 && this.scheduler.flush(this);
153
292
  }
154
- signal(e, n) {
155
- return t(this, e, n);
293
+ trackNode(e, t) {
294
+ let n = t.dependenciesHead;
295
+ for (; n !== null;) {
296
+ if (n.source === e) {
297
+ n.version = e.version;
298
+ return;
299
+ }
300
+ n = n.nextDependency;
301
+ }
302
+ let r = a.acquire(e, t);
303
+ r.version = e.version, t.depth <= e.depth && (t.depth = e.depth + 1), e.subscribersTail === null ? (e.subscribersHead = r, e.subscribersTail = r) : (e.subscribersTail.nextSubscriber = r, r.prevSubscriber = e.subscribersTail, e.subscribersTail = r), t.dependenciesTail === null ? (t.dependenciesHead = r, t.dependenciesTail = r) : (t.dependenciesTail.nextDependency = r, r.prevDependency = t.dependenciesTail, t.dependenciesTail = r);
156
304
  }
157
- computed(t, n) {
158
- return e(this, t, n);
305
+ unlinkDependencies(e, t = !1) {
306
+ let n = e.dependenciesHead;
307
+ for (e.dependenciesHead = null, e.dependenciesTail = null; n !== null;) {
308
+ let r = n.nextDependency, i = n.source;
309
+ n.prevSubscriber === null ? i.subscribersHead = n.nextSubscriber : n.prevSubscriber.nextSubscriber = n.nextSubscriber, n.nextSubscriber === null ? i.subscribersTail = n.prevSubscriber : n.nextSubscriber.prevSubscriber = n.prevSubscriber, a.release(n), t && e.isDisposed && e.type === "computed" && i.type === "computed" && i.subscribersHead === null && this.disposeNode(i), n = r;
310
+ }
159
311
  }
160
- effect(e, t) {
161
- return i(this, e, t);
312
+ checkNeedsUpdate(e) {
313
+ let t = e.dependenciesHead;
314
+ for (; t !== null;) {
315
+ let e = t.source;
316
+ if (e.state === 1 && (this.checkNeedsUpdate(e) ? e.state = 2 : e.state = 0), e.state === 2 && this.evaluateComputed(e), t.version !== e.version) return t.version = e.version, !0;
317
+ t = t.nextDependency;
318
+ }
319
+ return !1;
162
320
  }
163
- untrack(e) {
164
- return n(this, e);
321
+ evaluateComputed(e) {
322
+ if (e.ownedEffects.size > 0) {
323
+ let t = Array.from(e.ownedEffects);
324
+ e.ownedEffects.clear();
325
+ for (let e of t) this.disposeNode(e);
326
+ }
327
+ this.unlinkDependencies(e, !1);
328
+ let t = this.activeConsumer, n = this.currentOwner;
329
+ this.activeConsumer = e, this.currentOwner = e;
330
+ let r = e._value;
331
+ try {
332
+ let t = e.fn();
333
+ Object.is(e._value, t) || (e._value = t, e.version++), e.state = 0, this.log({
334
+ type: "computed",
335
+ label: e.id,
336
+ details: {
337
+ from: r,
338
+ to: e._value
339
+ }
340
+ });
341
+ } finally {
342
+ this.activeConsumer = t, this.currentOwner = n;
343
+ }
344
+ }
345
+ executeCleanups(e) {
346
+ if (e.cleanups.size === 0) return;
347
+ let t = Array.from(e.cleanups);
348
+ e.cleanups.clear();
349
+ let n = null;
350
+ for (let e of t) try {
351
+ this.untrack(() => e());
352
+ } catch (e) {
353
+ n === null && (n = e);
354
+ }
355
+ if (n !== null) throw n;
356
+ }
357
+ runEffectNode(e) {
358
+ if (e.isDisposed) return;
359
+ if (e.ownedEffects.size > 0) {
360
+ let t = Array.from(e.ownedEffects);
361
+ e.ownedEffects.clear();
362
+ for (let e of t) this.disposeNode(e);
363
+ }
364
+ try {
365
+ this.executeCleanups(e);
366
+ } catch (t) {
367
+ throw e.state = 0, t;
368
+ }
369
+ this.unlinkDependencies(e, !1);
370
+ let t = this.activeConsumer, n = this.currentOwner;
371
+ this.activeConsumer = e, this.currentOwner = e;
372
+ try {
373
+ e.fn(), e.state = 0;
374
+ } finally {
375
+ this.activeConsumer = t, this.currentOwner = n, e.isDisposed && this.unlinkDependencies(e, !0);
376
+ }
377
+ }
378
+ disposeNode(e) {
379
+ if (e.isDisposed) return;
380
+ if (e.isDisposed = !0, e.state = 0, e.ownedEffects.size > 0) {
381
+ let t = Array.from(e.ownedEffects);
382
+ e.ownedEffects.clear();
383
+ for (let e of t) this.disposeNode(e);
384
+ }
385
+ try {
386
+ this.executeCleanups(e);
387
+ } catch {}
388
+ this.unlinkDependencies(e, !0);
389
+ let t = e.subscribersHead;
390
+ for (e.subscribersHead = null, e.subscribersTail = null; t !== null;) {
391
+ let e = t.nextSubscriber, n = t.target;
392
+ n && (t.prevDependency === null ? n.dependenciesHead = t.nextDependency : t.prevDependency.nextDependency = t.nextDependency, t.nextDependency === null ? n.dependenciesTail = t.prevDependency : t.nextDependency.prevDependency = t.prevDependency), a.release(t), t = e;
393
+ }
165
394
  }
166
395
  reactive(e, t) {
167
- return r(this, e, t);
396
+ return n(this, e, t);
397
+ }
398
+ delay(e, t) {
399
+ return new Promise((n, r) => {
400
+ if (t.aborted) return r(new DOMException("Aborted", "AbortError"));
401
+ let i = setTimeout(() => {
402
+ t.removeEventListener("abort", a), n();
403
+ }, e), a = () => {
404
+ clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
405
+ };
406
+ t.addEventListener("abort", a, { once: !0 });
407
+ });
168
408
  }
169
409
  provide(e, t) {
170
410
  this.diRegistry.set(e, t), this.diCache.delete(e);
@@ -200,22 +440,11 @@ var f = class {
200
440
  this.cycleDetectionStack.delete(e);
201
441
  }
202
442
  }
203
- delay(e, t) {
204
- return new Promise((n, r) => {
205
- if (t.aborted) return r(new DOMException("Aborted", "AbortError"));
206
- let i = setTimeout(() => {
207
- t.removeEventListener("abort", a), n();
208
- }, e), a = () => {
209
- clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
210
- };
211
- t.addEventListener("abort", a, { once: !0 });
212
- });
213
- }
214
- resource(e, t, n) {
215
- return o(this, e, t, n);
216
- }
217
- };
443
+ }, l = new c();
444
+ function u() {
445
+ l = new c();
446
+ }
218
447
  //#endregion
219
- export { f as ReactiveEngine, f as ReactiveEngineAutomatic, f as ReactiveEngineCore, d as flushLogs, u as queueLog };
448
+ export { s as EffectScheduler, a as LinkPool, i as NodeLink, c as ReactiveEngine, c as ReactiveEngineAutomatic, c as ReactiveEngineCore, o as ReactiveNode, l as currentEngineInstance, u as resetGlobalReactiveEngine };
220
449
 
221
450
  //# sourceMappingURL=core.mjs.map