@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
|
@@ -1,26 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var B = (c, e, t) => e in c ? P(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
|
+
var b = (c, e, t) => B(c, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { reactiveObject as G } from "./reactive-object.js";
|
|
5
|
+
import { appendScopeChild as z, ScopeNode as M, throwScopeErrors as F, detachScopeChild as K } from "./scope.js";
|
|
6
|
+
import { watchWithReactivity as Y } from "./watch.js";
|
|
7
|
+
const w = 1, p = 2, C = 4, D = 8, T = 16, y = 32, x = 64, W = 128, m = 256, v = 512, E = w | p, R = 16, X = 2;
|
|
8
|
+
function N(c) {
|
|
9
|
+
c.dependencyLookupDebt === void 0 && c.dependencyIndex === void 0 || (c.dependencyIndex = void 0, c.dependencyLookupDebt = void 0, c.dependencyLookupSearches = void 0);
|
|
10
|
+
}
|
|
11
|
+
function q(c, e) {
|
|
12
|
+
if (e <= R || c.flags & W || c.dependencyIndex !== void 0)
|
|
13
|
+
return;
|
|
14
|
+
const t = (c.dependencyLookupSearches ?? 0) + 1, i = (c.dependencyLookupDebt ?? 0) + e;
|
|
15
|
+
if (c.dependencyLookupSearches = t, c.dependencyLookupDebt = i, t < X || i < c.depCount)
|
|
16
|
+
return;
|
|
17
|
+
const s = /* @__PURE__ */ new Map();
|
|
18
|
+
for (let n = c.firstDep; n !== null; n = n.nextDep)
|
|
19
|
+
s.set(n.dep, n);
|
|
20
|
+
c.dependencyIndex = s, c.dependencyLookupDebt = void 0, c.dependencyLookupSearches = void 0;
|
|
21
|
+
}
|
|
22
|
+
function j(c, e, t) {
|
|
23
|
+
var a;
|
|
24
|
+
const i = c.firstSub;
|
|
25
|
+
if (i === null)
|
|
10
26
|
return;
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
if (i === c.lastSub)
|
|
28
|
+
return i.sub === e ? i : void 0;
|
|
29
|
+
const s = c.subSearchCursor ?? i;
|
|
30
|
+
let n = 1;
|
|
31
|
+
if (s.sub === e)
|
|
32
|
+
return c.subSearchCursor = s.nextSub ?? i, s;
|
|
33
|
+
if (t) {
|
|
34
|
+
const r = (a = e.dependencyIndex) == null ? void 0 : a.get(c);
|
|
35
|
+
if (r !== void 0)
|
|
36
|
+
return c.subSearchCursor = r.nextSub ?? i, r;
|
|
37
|
+
if (e.dependencyIndex !== void 0)
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let l = s.nextSub ?? i;
|
|
41
|
+
for (; l !== s; ) {
|
|
42
|
+
if (++n, l.sub === e)
|
|
43
|
+
return c.subSearchCursor = l.nextSub ?? i, t && q(e, n), l;
|
|
44
|
+
l = l.nextSub ?? i;
|
|
21
45
|
}
|
|
46
|
+
t && q(e, n);
|
|
22
47
|
}
|
|
23
|
-
class
|
|
48
|
+
class U {
|
|
24
49
|
/**
|
|
25
50
|
* Выбирает политику исполнения и сохраняет совместимость извлечённых методов.
|
|
26
51
|
* Тела методов находятся на прототипе; bind() выполняется только при создании
|
|
@@ -28,41 +53,43 @@ class y {
|
|
|
28
53
|
* @param options Необязательная внешняя политика эффектов.
|
|
29
54
|
*/
|
|
30
55
|
constructor(e = {}) {
|
|
56
|
+
// Opt-in стратегия длинного slow path; не добавляет policy field каждой ноде.
|
|
57
|
+
b(this, "adaptiveDependencyIndex");
|
|
31
58
|
// Потребитель текущего синхронного чтения; null отключает отслеживание.
|
|
32
|
-
|
|
59
|
+
b(this, "activeSub", null);
|
|
33
60
|
// Глубина вложенных синхронных границ группировки.
|
|
34
|
-
|
|
61
|
+
b(this, "batchDepth", 0);
|
|
35
62
|
// Индекс следующего элемента внутренней очереди эффектов.
|
|
36
|
-
|
|
63
|
+
b(this, "effectReadIndex", 0);
|
|
37
64
|
// Позиция добавления элемента в текущем проходе очереди.
|
|
38
|
-
|
|
65
|
+
b(this, "effectWriteIndex", 0);
|
|
39
66
|
// Граница активного префикса переиспользуемого стека invalidation.
|
|
40
|
-
|
|
67
|
+
b(this, "invalidationDepth", 0);
|
|
41
68
|
// Граница активного префикса стека проверки зависимостей.
|
|
42
|
-
|
|
69
|
+
b(this, "dependencyDepth", 0);
|
|
43
70
|
// Защита внутренней очереди от вложенного повторного прохода.
|
|
44
|
-
|
|
71
|
+
b(this, "flushingEffects", !1);
|
|
45
72
|
// Переиспользуемый буфер очереди; прочитанная ячейка сразу освобождает ссылку.
|
|
46
|
-
|
|
73
|
+
b(this, "effectQueue", new Array(16).fill(void 0));
|
|
47
74
|
// Переиспользуемый стек распространения invalidation; исходный способ выделения сохранён.
|
|
48
|
-
|
|
75
|
+
b(this, "invalidationStack", new Array(512).fill(null));
|
|
49
76
|
// Переиспользуемый стек проверки зависимостей с защитой активного вложенного префикса.
|
|
50
|
-
|
|
77
|
+
b(this, "dependencyStack", []);
|
|
51
78
|
// Общие адаптеры receiver для handles этого экземпляра.
|
|
52
79
|
// Создаются один раз, чтобы computed не хранил дополнительную ссылку на движок
|
|
53
80
|
// и не выделял отдельные get/peek closures на каждый источник.
|
|
54
|
-
|
|
81
|
+
b(this, "handleReaders", this.createHandleReaders());
|
|
55
82
|
// Выбранная внешняя политика; у синхронного экземпляра отсутствует.
|
|
56
|
-
|
|
83
|
+
b(this, "effectScheduler");
|
|
57
84
|
// Прямой обработчик очереди, выбранный один раз при создании экземпляра.
|
|
58
|
-
|
|
85
|
+
b(this, "flushEffects");
|
|
59
86
|
/**
|
|
60
87
|
* Синхронная регистрация эффекта для Runtime и watch независимо от внешней политики.
|
|
61
88
|
* Это связанная ссылка на реализацию effect(), а не делегирующая функция.
|
|
62
89
|
* @internal
|
|
63
90
|
*/
|
|
64
|
-
|
|
65
|
-
this.effectScheduler = e.effectScheduler, this._effectImmediate = this.effect.bind(this), this.signal = this.signal.bind(this), this.computed = this.computed.bind(this), this.watch = this.watch.bind(this), this.batch = this.batch.bind(this), this.untracked = this.untracked.bind(this), this.scope = this.scope.bind(this), this._signalAccess = this._signalAccess.bind(this), this._computedAccess = this._computedAccess.bind(this), this._ownedSignal = this._ownedSignal.bind(this), this._ownedComputed = this._ownedComputed.bind(this), this._isTracking = this._isTracking.bind(this), this._isFlushingEffects = this._isFlushingEffects.bind(this), this._startBatch = this._startBatch.bind(this), this._endBatch = this._endBatch.bind(this), this.effect = this.effectScheduler === void 0 ? this._effectImmediate : this.createScheduledEffect.bind(this), this.flushEffects = this.effectScheduler === void 0 ? this.flushSyncEffects : this.flushExternalEffects;
|
|
91
|
+
b(this, "_effectImmediate");
|
|
92
|
+
this.adaptiveDependencyIndex = e.adaptiveDependencyIndex ?? !1, this.effectScheduler = e.effectScheduler, this._effectImmediate = this.effect.bind(this), this.signal = this.signal.bind(this), this.computed = this.computed.bind(this), this.reactive = this.reactive.bind(this), this.watch = this.watch.bind(this), this.batch = this.batch.bind(this), this.untracked = this.untracked.bind(this), this.scope = this.scope.bind(this), this._signalAccess = this._signalAccess.bind(this), this._computedAccess = this._computedAccess.bind(this), this._ownedSignal = this._ownedSignal.bind(this), this._ownedComputed = this._ownedComputed.bind(this), this._isTracking = this._isTracking.bind(this), this._isFlushingEffects = this._isFlushingEffects.bind(this), this._startBatch = this._startBatch.bind(this), this._endBatch = this._endBatch.bind(this), this.effect = this.effectScheduler === void 0 ? this._effectImmediate : this.createScheduledEffect.bind(this), this.flushEffects = this.effectScheduler === void 0 ? this.flushSyncEffects : this.flushExternalEffects;
|
|
66
93
|
}
|
|
67
94
|
// ---------------------------------------------
|
|
68
95
|
// PUBLIC API
|
|
@@ -75,21 +102,21 @@ class y {
|
|
|
75
102
|
signal(e) {
|
|
76
103
|
let t = e, i;
|
|
77
104
|
const s = () => {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
return this.readSignalValue(
|
|
81
|
-
const
|
|
82
|
-
return
|
|
105
|
+
const l = i;
|
|
106
|
+
if (l !== void 0)
|
|
107
|
+
return this.readSignalValue(l);
|
|
108
|
+
const a = this.activeSub;
|
|
109
|
+
return a === null || (i = this.materializeSignal(
|
|
83
110
|
t,
|
|
84
|
-
|
|
111
|
+
a
|
|
85
112
|
)), t;
|
|
86
|
-
}, n = (
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
this.writeSignalValue(
|
|
113
|
+
}, n = (l) => {
|
|
114
|
+
const a = i;
|
|
115
|
+
if (a !== void 0) {
|
|
116
|
+
this.writeSignalValue(a, l);
|
|
90
117
|
return;
|
|
91
118
|
}
|
|
92
|
-
t !==
|
|
119
|
+
t !== l && (t = l);
|
|
93
120
|
};
|
|
94
121
|
return {
|
|
95
122
|
get: s,
|
|
@@ -97,6 +124,13 @@ class y {
|
|
|
97
124
|
set: n
|
|
98
125
|
};
|
|
99
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Возвращает стабильный глубокий Proxy для plain object или array.
|
|
129
|
+
* Object context и per-property sources создаются лениво внутри этого engine.
|
|
130
|
+
*/
|
|
131
|
+
reactive(e) {
|
|
132
|
+
return G(this, e, () => this.createReactivePropertySourceBridge());
|
|
133
|
+
}
|
|
100
134
|
computed(e) {
|
|
101
135
|
if (typeof e == "function")
|
|
102
136
|
return this.createComputedHandle(e);
|
|
@@ -113,17 +147,17 @@ class y {
|
|
|
113
147
|
* @param onStop Однократная окончательная очистка, независимая от повторных запусков.
|
|
114
148
|
*/
|
|
115
149
|
effect(e, t) {
|
|
116
|
-
const i = this.allocateGraphRecord(void 0, e,
|
|
150
|
+
const i = this.allocateGraphRecord(void 0, e, p | w | y);
|
|
117
151
|
t !== void 0 && (i.onStop = t);
|
|
118
152
|
const s = this.activeSub;
|
|
119
|
-
s !== null && s.flags &
|
|
153
|
+
s !== null && s.flags & y && z(s, i);
|
|
120
154
|
try {
|
|
121
155
|
this.executeEffect(i);
|
|
122
156
|
} catch (n) {
|
|
123
157
|
try {
|
|
124
158
|
this.disposeEffect(i);
|
|
125
|
-
} catch (
|
|
126
|
-
throw new AggregateError([n,
|
|
159
|
+
} catch (l) {
|
|
160
|
+
throw new AggregateError([n, l], "Effect registration and cleanup failed.");
|
|
127
161
|
}
|
|
128
162
|
throw n;
|
|
129
163
|
}
|
|
@@ -133,7 +167,7 @@ class y {
|
|
|
133
167
|
* Наблюдает за источниками; callback и cleanup не создают зависимостей.
|
|
134
168
|
*/
|
|
135
169
|
watch(e, t, i) {
|
|
136
|
-
return
|
|
170
|
+
return Y(this.effect, this.untracked, e, t, i);
|
|
137
171
|
}
|
|
138
172
|
/**
|
|
139
173
|
* Группирует синхронные записи и обрабатывает эффекты после внешней границы.
|
|
@@ -179,7 +213,7 @@ class y {
|
|
|
179
213
|
* Создаёт владельца ресурсов в текущем графе без Runtime и фаз.
|
|
180
214
|
*/
|
|
181
215
|
scope() {
|
|
182
|
-
return new
|
|
216
|
+
return new M(this);
|
|
183
217
|
}
|
|
184
218
|
// ---------------------------------------------
|
|
185
219
|
// PRIVATE
|
|
@@ -201,6 +235,26 @@ class y {
|
|
|
201
235
|
cachedValue: e
|
|
202
236
|
};
|
|
203
237
|
}
|
|
238
|
+
/** Creates a narrow Proxy adapter over the existing intrusive graph. */
|
|
239
|
+
createReactivePropertySourceBridge() {
|
|
240
|
+
return {
|
|
241
|
+
batch: this.batch,
|
|
242
|
+
create: () => {
|
|
243
|
+
if (this.activeSub === null)
|
|
244
|
+
throw new Error("[Raph] Reactive property source requires a tracked read.");
|
|
245
|
+
return { firstSub: null, lastSub: null };
|
|
246
|
+
},
|
|
247
|
+
isTracking: this._isTracking,
|
|
248
|
+
track: (e) => {
|
|
249
|
+
const t = this.activeSub;
|
|
250
|
+
t !== null && this.trackDependency(e, t);
|
|
251
|
+
},
|
|
252
|
+
trigger: (e) => {
|
|
253
|
+
const t = e.firstSub;
|
|
254
|
+
t !== null && (this.propagateInvalidation(t), !this.batchDepth && this.effectReadIndex !== this.effectWriteIndex && this.flushEffects());
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
204
258
|
/**
|
|
205
259
|
* Материализует signal в графе при первом отслеживаемом чтении
|
|
206
260
|
* и связывает его с активным потребителем.
|
|
@@ -208,24 +262,25 @@ class y {
|
|
|
208
262
|
* До этого момента signal может хранить значение только в замыкании
|
|
209
263
|
* и вообще не создавать `ReactiveNode`.
|
|
210
264
|
*/
|
|
211
|
-
materializeSignal(e, t) {
|
|
212
|
-
const
|
|
265
|
+
materializeSignal(e, t, i) {
|
|
266
|
+
const s = this.allocateGraphRecord(
|
|
213
267
|
e,
|
|
214
268
|
void 0,
|
|
215
269
|
0
|
|
216
270
|
);
|
|
217
|
-
return t.flags &
|
|
271
|
+
return i !== void 0 && (s.sourceHooks = i, s.flags |= v), t.flags & W ? this.appendInitialDependency(s, t) : this.trackDependency(s, t), s;
|
|
218
272
|
}
|
|
219
273
|
/**
|
|
220
274
|
* Создаёт минимальный handle computed без преждевременного выделения полей графа.
|
|
221
275
|
* Первый get() материализует запись на этом же объекте и заменяет метод чтения.
|
|
222
276
|
*/
|
|
223
|
-
createComputedHandle(e) {
|
|
224
|
-
|
|
277
|
+
createComputedHandle(e, t) {
|
|
278
|
+
const i = {
|
|
225
279
|
evaluate: e,
|
|
226
280
|
get: this.handleReaders.initializeComputed,
|
|
227
281
|
peek: this.handleReaders.peek
|
|
228
282
|
};
|
|
283
|
+
return t !== void 0 && (i.sourceHooks = t), i;
|
|
229
284
|
}
|
|
230
285
|
/**
|
|
231
286
|
* Создаёт эффект с одной постоянной задачей внешнего scheduler.
|
|
@@ -235,39 +290,43 @@ class y {
|
|
|
235
290
|
* @param onStop Однократная окончательная очистка.
|
|
236
291
|
*/
|
|
237
292
|
createScheduledEffect(e, t) {
|
|
238
|
-
const i = this.allocateGraphRecord(void 0, e,
|
|
293
|
+
const i = this.allocateGraphRecord(void 0, e, p | w | y);
|
|
294
|
+
let s = !1;
|
|
239
295
|
t !== void 0 && (i.onStop = t);
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
if (!(!(i.flags &
|
|
244
|
-
i.flags &= ~
|
|
296
|
+
const n = this.activeSub;
|
|
297
|
+
n !== null && n.flags & y && z(n, i);
|
|
298
|
+
const l = () => {
|
|
299
|
+
if (!(!(i.flags & x) || i.evaluate === void 0)) {
|
|
300
|
+
i.flags &= ~x, s = !0;
|
|
245
301
|
try {
|
|
246
302
|
this.executeEffect(i);
|
|
247
|
-
} catch (
|
|
303
|
+
} catch (a) {
|
|
248
304
|
if (!this.batchDepth && this.effectReadIndex !== this.effectWriteIndex)
|
|
249
305
|
try {
|
|
250
306
|
this.flushEffects();
|
|
251
|
-
} catch (
|
|
307
|
+
} catch (r) {
|
|
252
308
|
throw new AggregateError(
|
|
253
|
-
[
|
|
309
|
+
[a, r],
|
|
254
310
|
"Effect execution and queue processing failed."
|
|
255
311
|
);
|
|
256
312
|
}
|
|
257
|
-
throw
|
|
313
|
+
throw a;
|
|
258
314
|
}
|
|
259
315
|
!this.batchDepth && this.effectReadIndex !== this.effectWriteIndex && this.flushEffects();
|
|
260
316
|
}
|
|
261
317
|
};
|
|
262
318
|
try {
|
|
263
|
-
|
|
264
|
-
|
|
319
|
+
const a = this.effectScheduler.bind(l);
|
|
320
|
+
a.cancelPending = () => i.evaluate === void 0 || !s ? !1 : (this.settleCancelledDependencies(i), i.flags &= ~(x | E | C), !this.batchDepth && this.effectReadIndex !== this.effectWriteIndex && this.flushEffects(), !0), a.rearmPending = () => {
|
|
321
|
+
i.evaluate !== void 0 && (i.flags |= p | x, a.schedule());
|
|
322
|
+
}, i.effectTask = a, this.requestEffectTask(i);
|
|
323
|
+
} catch (a) {
|
|
265
324
|
try {
|
|
266
325
|
this.disposeEffect(i);
|
|
267
|
-
} catch (
|
|
268
|
-
throw new AggregateError([
|
|
326
|
+
} catch (r) {
|
|
327
|
+
throw new AggregateError([a, r], "Effect registration and cleanup failed.");
|
|
269
328
|
}
|
|
270
|
-
throw
|
|
329
|
+
throw a;
|
|
271
330
|
}
|
|
272
331
|
return !this.batchDepth && this.effectReadIndex !== this.effectWriteIndex && this.flushEffects(), () => this.disposeEffect(i);
|
|
273
332
|
}
|
|
@@ -278,7 +337,7 @@ class y {
|
|
|
278
337
|
readSignalValue(e) {
|
|
279
338
|
const t = this.activeSub;
|
|
280
339
|
let i = null;
|
|
281
|
-
return t !== null && (i = this.trackDependency(e, t)), e.flags &
|
|
340
|
+
return t !== null && (i = this.trackDependency(e, t)), e.flags & p && this.commitSignalValue(e, i), e.cachedValue;
|
|
282
341
|
}
|
|
283
342
|
/**
|
|
284
343
|
* Записывает новое значение или откладывает его фиксацию до чтения в batch.
|
|
@@ -286,19 +345,19 @@ class y {
|
|
|
286
345
|
* Без batch и внешней политики очередь эффектов завершается до возврата из set().
|
|
287
346
|
*/
|
|
288
347
|
writeSignalValue(e, t) {
|
|
289
|
-
if (e.flags &
|
|
290
|
-
const s = !!(e.flags &
|
|
291
|
-
if ((e.flags &
|
|
348
|
+
if (e.flags & p || this.batchDepth) {
|
|
349
|
+
const s = !!(e.flags & p);
|
|
350
|
+
if ((e.flags & p ? e.pendingValue : e.cachedValue) === t)
|
|
292
351
|
return;
|
|
293
352
|
if (e.pendingValue = t, e.cachedValue === t)
|
|
294
|
-
e.flags &= ~
|
|
353
|
+
e.flags &= ~p, e.pendingAuthor = void 0;
|
|
295
354
|
else {
|
|
296
|
-
e.flags |=
|
|
297
|
-
const
|
|
298
|
-
s ? e.pendingAuthor !==
|
|
355
|
+
e.flags |= p;
|
|
356
|
+
const a = this.activeSub !== null && this.activeSub.flags & D ? this.activeSub : null;
|
|
357
|
+
s ? e.pendingAuthor !== a && (e.pendingAuthor = null) : e.pendingAuthor = a;
|
|
299
358
|
}
|
|
300
|
-
const
|
|
301
|
-
|
|
359
|
+
const l = e.firstSub;
|
|
360
|
+
l != null && (!s || this.activeSub !== null && this.activeSub.flags & D || e.flags & v) && this.propagateInvalidation(l, !0);
|
|
302
361
|
return;
|
|
303
362
|
}
|
|
304
363
|
if (e.cachedValue === t)
|
|
@@ -313,10 +372,13 @@ class y {
|
|
|
313
372
|
* связь с активным потребителем, чтобы тот мог восстановиться при изменении источника.
|
|
314
373
|
*/
|
|
315
374
|
readComputedValue(e) {
|
|
316
|
-
const t = e.flags, i = t & (
|
|
375
|
+
const t = e.flags, i = t & (T | E | m), s = i === 0 ? e.cachedValue : i & T ? this.evaluateFirstValue(e) : this.refreshComputedValue(e, t);
|
|
376
|
+
if (e.evaluate === void 0)
|
|
377
|
+
return s;
|
|
378
|
+
const n = this.activeSub;
|
|
317
379
|
if (n !== null) {
|
|
318
|
-
const
|
|
319
|
-
n.flags &
|
|
380
|
+
const l = n.tailDep;
|
|
381
|
+
n.flags & W ? (l === null || l.dep !== e) && this.appendInitialDependency(e, n) : this.trackDependency(e, n);
|
|
320
382
|
}
|
|
321
383
|
return s;
|
|
322
384
|
}
|
|
@@ -326,30 +388,31 @@ class y {
|
|
|
326
388
|
* Уже прочитанные зависимости сохраняются для последующего уведомления.
|
|
327
389
|
*/
|
|
328
390
|
evaluateFirstValue(e) {
|
|
329
|
-
e.flags
|
|
330
|
-
|
|
391
|
+
const t = e.flags & v, i = e.evaluate;
|
|
392
|
+
e.flags = t | D | W;
|
|
393
|
+
const s = this.activeSub;
|
|
331
394
|
this.activeSub = e;
|
|
332
395
|
try {
|
|
333
|
-
const
|
|
334
|
-
return e.cachedValue =
|
|
335
|
-
} catch (
|
|
336
|
-
throw e.flags =
|
|
396
|
+
const n = i();
|
|
397
|
+
return e.evaluate !== i ? (e.cachedValue = void 0, e.flags = 0, n) : (e.cachedValue = n, e.flags = t | (e.flags & C ? p : 0), n);
|
|
398
|
+
} catch (n) {
|
|
399
|
+
throw e.evaluate !== i ? (e.cachedValue = void 0, e.flags = 0, n) : (e.flags = t | m, s !== null && this.trackDependency(e, s), n);
|
|
337
400
|
} finally {
|
|
338
|
-
this.activeSub =
|
|
401
|
+
this.activeSub = s;
|
|
339
402
|
}
|
|
340
403
|
}
|
|
341
404
|
/**
|
|
342
405
|
* Актуализирует computed: выполняет прямой пересчёт либо проверяет зависимости.
|
|
343
406
|
* После ошибки getter разрешён повторный пересчёт даже без новой записи источника.
|
|
344
407
|
*/
|
|
345
|
-
refreshComputedValue(e, t) {
|
|
408
|
+
refreshComputedValue(e, t, i = null) {
|
|
346
409
|
try {
|
|
347
|
-
if (t & (
|
|
348
|
-
return this.recomputeValue(e) || (e.flags &= ~
|
|
349
|
-
const
|
|
350
|
-
return (
|
|
351
|
-
} catch (
|
|
352
|
-
throw this.activeSub !== null && this.trackDependency(e, this.activeSub),
|
|
410
|
+
if (t & (p | C | m))
|
|
411
|
+
return this.recomputeValue(e, i) || (e.flags &= ~E), e.cachedValue;
|
|
412
|
+
const s = e.firstDep;
|
|
413
|
+
return (s === null || !this.refreshDependencies(e, s) || !this.recomputeValue(e, i)) && (e.flags &= ~E), e.cachedValue;
|
|
414
|
+
} catch (s) {
|
|
415
|
+
throw this.activeSub !== null && this.trackDependency(e, this.activeSub), s;
|
|
353
416
|
}
|
|
354
417
|
}
|
|
355
418
|
/**
|
|
@@ -359,7 +422,7 @@ class y {
|
|
|
359
422
|
*/
|
|
360
423
|
commitSignalValue(e, t) {
|
|
361
424
|
const i = e.cachedValue;
|
|
362
|
-
e.cachedValue = e.pendingValue, e.flags &= ~
|
|
425
|
+
e.cachedValue = e.pendingValue, e.flags &= ~p;
|
|
363
426
|
const s = e.pendingAuthor;
|
|
364
427
|
return e.pendingAuthor = void 0, i === e.cachedValue ? !1 : (e.firstSub !== null && this.confirmSubUpdates(e.firstSub, t, s ?? null), !0);
|
|
365
428
|
}
|
|
@@ -382,33 +445,33 @@ class y {
|
|
|
382
445
|
* Существующую связь перемещает или переиспользует; новую создаёт только при необходимости.
|
|
383
446
|
*/
|
|
384
447
|
reconcileDependency(e, t, i, s) {
|
|
385
|
-
if (t.depCount <=
|
|
386
|
-
for (let
|
|
387
|
-
if (
|
|
388
|
-
return this.reorderDependency(t,
|
|
389
|
-
for (let
|
|
390
|
-
if (
|
|
391
|
-
return
|
|
448
|
+
if (t.depCount <= R) {
|
|
449
|
+
for (let r = s; r !== null; r = r.nextDep)
|
|
450
|
+
if (r.dep === e)
|
|
451
|
+
return this.reorderDependency(t, r, i), t.tailDep = r, r;
|
|
452
|
+
for (let r = i; r !== null; r = r.prevDep)
|
|
453
|
+
if (r.dep === e)
|
|
454
|
+
return r;
|
|
392
455
|
return s !== null ? (t.tailDep = this.reuseDepLink(s, e), s) : t.tailDep = this.insertDependency(e, t, i);
|
|
393
456
|
}
|
|
394
|
-
let n = 0,
|
|
395
|
-
for (;
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
return this.reorderDependency(t,
|
|
399
|
-
|
|
457
|
+
let n = 0, l = s;
|
|
458
|
+
for (; l !== null && n < R; ) {
|
|
459
|
+
const r = l;
|
|
460
|
+
if (r.dep === e)
|
|
461
|
+
return this.reorderDependency(t, r, i), t.tailDep = r, r;
|
|
462
|
+
l = r.nextDep, ++n;
|
|
400
463
|
}
|
|
401
|
-
let
|
|
402
|
-
for (;
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
406
|
-
|
|
464
|
+
let a = i;
|
|
465
|
+
for (; a !== null && n < R; ) {
|
|
466
|
+
const r = a;
|
|
467
|
+
if (r.dep === e)
|
|
468
|
+
return r;
|
|
469
|
+
a = r.prevDep, ++n;
|
|
407
470
|
}
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
return this.reorderDependency(t,
|
|
471
|
+
if (l !== null || a !== null) {
|
|
472
|
+
const r = j(e, t, this.adaptiveDependencyIndex);
|
|
473
|
+
if (r !== void 0)
|
|
474
|
+
return this.reorderDependency(t, r, i), t.tailDep = r, r;
|
|
412
475
|
}
|
|
413
476
|
return s !== null ? (t.tailDep = this.reuseDepLink(s, e), s) : t.tailDep = this.insertDependency(e, t, i);
|
|
414
477
|
}
|
|
@@ -418,6 +481,7 @@ class y {
|
|
|
418
481
|
* Связь одновременно включается в список потребителей производителя.
|
|
419
482
|
*/
|
|
420
483
|
appendInitialDependency(e, t) {
|
|
484
|
+
var l;
|
|
421
485
|
const i = t.tailDep, s = e.lastSub, n = {
|
|
422
486
|
dep: e,
|
|
423
487
|
sub: t,
|
|
@@ -426,13 +490,14 @@ class y {
|
|
|
426
490
|
prevDep: i,
|
|
427
491
|
nextDep: null
|
|
428
492
|
};
|
|
429
|
-
return s === null ? e.firstSub = n : s.nextSub = n, e.lastSub = n, i === null ? t.firstDep = n : i.nextDep = n, t.tailDep = n, ++t.depCount, n;
|
|
493
|
+
return s === null ? e.firstSub = n : s.nextSub = n, e.lastSub = n, i === null ? t.firstDep = n : i.nextDep = n, t.tailDep = n, ++t.depCount, (l = t.dependencyIndex) == null || l.set(e, n), e.flags & v && this.attachDependencyCleanup(n), n;
|
|
430
494
|
}
|
|
431
495
|
/**
|
|
432
496
|
* Вставляет связь после заданного курсора зависимостей потребителя.
|
|
433
497
|
* Сохраняет ещё не прочитанный хвост списка и увеличивает dependencyCount.
|
|
434
498
|
*/
|
|
435
499
|
insertDependency(e, t, i) {
|
|
500
|
+
var a;
|
|
436
501
|
const s = e.lastSub, n = {
|
|
437
502
|
dep: e,
|
|
438
503
|
sub: t,
|
|
@@ -442,17 +507,18 @@ class y {
|
|
|
442
507
|
nextDep: null
|
|
443
508
|
};
|
|
444
509
|
s === null ? e.firstSub = n : s.nextSub = n, e.lastSub = n;
|
|
445
|
-
const
|
|
446
|
-
return n.nextDep =
|
|
510
|
+
const l = i === null ? t.firstDep : i.nextDep;
|
|
511
|
+
return n.nextDep = l, l !== null && (l.prevDep = n), i === null ? t.firstDep = n : i.nextDep = n, ++t.depCount, (a = t.dependencyIndex) == null || a.set(e, n), e.flags & v && this.attachDependencyCleanup(n), n;
|
|
447
512
|
}
|
|
448
513
|
/**
|
|
449
514
|
* Переназначает существующую связь другому производителю.
|
|
450
515
|
* Положение в списке зависимостей потребителя и число его связей сохраняются.
|
|
451
516
|
*/
|
|
452
517
|
reuseDepLink(e, t) {
|
|
518
|
+
const i = e.sub.dependencyIndex;
|
|
453
519
|
this.detachSubLink(e);
|
|
454
|
-
const
|
|
455
|
-
return e.dep = t, e.prevSub =
|
|
520
|
+
const s = t.lastSub;
|
|
521
|
+
return e.dep = t, e.prevSub = s, e.nextSub = null, s === null ? t.firstSub = e : s.nextSub = e, t.lastSub = e, i == null || i.set(t, e), t.flags & v && this.attachDependencyCleanup(e), e;
|
|
456
522
|
}
|
|
457
523
|
/**
|
|
458
524
|
* Перемещает существующую зависимость после курсора текущего чтения.
|
|
@@ -463,8 +529,8 @@ class y {
|
|
|
463
529
|
return;
|
|
464
530
|
const s = t.prevDep, n = t.nextDep;
|
|
465
531
|
s === null ? e.firstDep = n : s.nextDep = n, n !== null && (n.prevDep = s);
|
|
466
|
-
const
|
|
467
|
-
t.prevDep = i, t.nextDep =
|
|
532
|
+
const l = i === null ? e.firstDep : i.nextDep;
|
|
533
|
+
t.prevDep = i, t.nextDep = l, l !== null && (l.prevDep = t), i === null ? e.firstDep = t : i.nextDep = t;
|
|
468
534
|
}
|
|
469
535
|
/**
|
|
470
536
|
* Удаляет непрочитанный хвост зависимостей завершившегося запуска.
|
|
@@ -474,11 +540,13 @@ class y {
|
|
|
474
540
|
pruneUnreadDependencies(e) {
|
|
475
541
|
const t = e.tailDep;
|
|
476
542
|
let i = t === null ? e.firstDep : t.nextDep;
|
|
477
|
-
if (i !== null)
|
|
543
|
+
if (i !== null) {
|
|
478
544
|
for (t === null ? e.firstDep = null : t.nextDep = null; i !== null; ) {
|
|
479
545
|
const s = i.nextDep;
|
|
480
546
|
this.detachSubLink(i), --e.depCount, i = s;
|
|
481
547
|
}
|
|
548
|
+
e.depCount <= R && N(e);
|
|
549
|
+
}
|
|
482
550
|
}
|
|
483
551
|
/**
|
|
484
552
|
* Удаляет связь только из списка потребителей производителя.
|
|
@@ -486,20 +554,43 @@ class y {
|
|
|
486
554
|
* Также исправляет курсор поиска, если он указывал на удаляемую связь.
|
|
487
555
|
*/
|
|
488
556
|
detachSubLink(e) {
|
|
557
|
+
var t;
|
|
558
|
+
if ((t = e.sub.dependencyIndex) == null || t.delete(e.dep), e.dep.flags & v) {
|
|
559
|
+
const i = e.dependencyCleanup;
|
|
560
|
+
e.dependencyCleanup = void 0, i == null || i();
|
|
561
|
+
}
|
|
489
562
|
e.dep.subSearchCursor === e && (e.dep.subSearchCursor = e.nextSub ?? (e.dep.firstSub === e ? void 0 : e.dep.firstSub ?? void 0)), e.prevSub === null ? e.dep.firstSub = e.nextSub : e.prevSub.nextSub = e.nextSub, e.nextSub === null ? e.dep.lastSub = e.prevSub : e.nextSub.prevSub = e.prevSub;
|
|
490
563
|
}
|
|
564
|
+
/** Connects Runtime ownership metadata only for edges whose producer opted in. */
|
|
565
|
+
attachDependencyCleanup(e) {
|
|
566
|
+
var n, l;
|
|
567
|
+
const t = e.dep.sourceHooks, i = t == null ? void 0 : t.onDependency;
|
|
568
|
+
if (i === void 0)
|
|
569
|
+
return;
|
|
570
|
+
const s = ((n = e.sub.sourceHooks) == null ? void 0 : n.dependencyOwner) ?? ((l = e.sub.effectTask) == null ? void 0 : l.dependencyOwner);
|
|
571
|
+
s !== void 0 && (e.dependencyCleanup = i(s));
|
|
572
|
+
}
|
|
491
573
|
/**
|
|
492
574
|
* Отсоединяет owned-источник сразу с обеих сторон каждой связи.
|
|
493
575
|
* Вызывается на границе lifetime, а не при обычных чтениях и записях.
|
|
494
576
|
* Переводит ожидавших проверку потребителей к повторному вычислению при необходимости.
|
|
495
577
|
*/
|
|
496
578
|
releaseSourceSubs(e) {
|
|
579
|
+
if (!(e.flags & v)) {
|
|
580
|
+
let i = e.firstSub;
|
|
581
|
+
for (; i != null; ) {
|
|
582
|
+
const s = i.nextSub, n = i.sub;
|
|
583
|
+
this.detachDependencyLink(i), this.detachSubLink(i);
|
|
584
|
+
const l = n.flags;
|
|
585
|
+
(l & (E | D)) === w && (n.flags = l & ~w | p, l & y && this.enqueueEffect(n, e)), i = s;
|
|
586
|
+
}
|
|
587
|
+
e.firstSub = e.lastSub = null, e.subSearchCursor = void 0;
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
497
590
|
let t = e.firstSub;
|
|
498
591
|
for (; t != null; ) {
|
|
499
|
-
const i = t.nextSub
|
|
500
|
-
this.detachDependencyLink(t), this.detachSubLink(t);
|
|
501
|
-
const n = s.flags;
|
|
502
|
-
(n & (g | h)) === d && (s.flags = n & ~d | f, n & o && this.enqueueEffect(s)), t = i;
|
|
592
|
+
const i = t.nextSub;
|
|
593
|
+
this.detachDependencyLink(t), this.detachSubLink(t), t = i;
|
|
503
594
|
}
|
|
504
595
|
e.firstSub = e.lastSub = null, e.subSearchCursor = void 0;
|
|
505
596
|
}
|
|
@@ -510,14 +601,16 @@ class y {
|
|
|
510
601
|
*/
|
|
511
602
|
detachDependencyLink(e) {
|
|
512
603
|
const t = e.sub, i = e.prevDep, s = e.nextDep;
|
|
513
|
-
i === null ? t.firstDep = s : i.nextDep = s, s !== null && (s.prevDep = i), t.tailDep === e && (t.tailDep = i), --t.depCount;
|
|
604
|
+
i === null ? t.firstDep = s : i.nextDep = s, s !== null && (s.prevDep = i), t.tailDep === e && (t.tailDep = i), --t.depCount, t.depCount <= R && N(t);
|
|
514
605
|
}
|
|
515
606
|
/**
|
|
516
607
|
* Добавляет эффект во внутреннюю очередь один раз до обработки текущей записи.
|
|
517
608
|
* Флаг SCHEDULED предотвращает повторное добавление без создания task-объекта.
|
|
518
609
|
*/
|
|
519
|
-
enqueueEffect(e) {
|
|
520
|
-
|
|
610
|
+
enqueueEffect(e, t) {
|
|
611
|
+
var s, n;
|
|
612
|
+
const i = t !== void 0 && t.flags & v ? t.sourceHooks.token : void 0;
|
|
613
|
+
i !== void 0 && ((n = (s = e.effectTask) == null ? void 0 : s.notify) == null || n.call(s, i)), !(e.flags & x) && (e.flags |= x, this.effectQueue[this.effectWriteIndex] = e, ++this.effectWriteIndex);
|
|
521
614
|
}
|
|
522
615
|
/**
|
|
523
616
|
* Распространяет invalidation от непосредственных к транзитивным потребителям.
|
|
@@ -525,28 +618,42 @@ class y {
|
|
|
525
618
|
* не выполняет. Непосредственное и потенциальное изменения отмечает разными флагами.
|
|
526
619
|
*/
|
|
527
620
|
propagateInvalidation(e, t = !1) {
|
|
621
|
+
var n, l, a, r, h, g, u, o, I, _, A, O, Q;
|
|
528
622
|
const i = this.invalidationDepth;
|
|
529
623
|
let s = i;
|
|
530
|
-
for (let
|
|
531
|
-
const
|
|
532
|
-
let
|
|
533
|
-
|
|
624
|
+
for (let d = e; d !== null; d = d.nextSub) {
|
|
625
|
+
const f = d.sub, S = f.flags;
|
|
626
|
+
let k = 0;
|
|
627
|
+
if (S & (E | D) ? S & D ? k = this.invalidateReadDependency(d, f, S) : !t && !(S & p) && (f.flags = S & ~w | p) : (k = S & ~C | (t ? w : p), f.flags = k), k === 0) {
|
|
628
|
+
if (S & y && S & x) {
|
|
629
|
+
const L = d.dep.flags & v ? d.dep.sourceHooks.token : void 0;
|
|
630
|
+
L !== void 0 && ((l = (n = f.effectTask) == null ? void 0 : n.notify) == null || l.call(n, L));
|
|
631
|
+
} else f.flags & v && ((r = (a = f.sourceHooks).onInvalidate) == null || r.call(a, f.firstSub !== null), f.firstSub !== null && (this.invalidationStack[s++] = f.firstSub));
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
k & y ? (!(k & D) || ((h = f.effectTask) == null ? void 0 : h.allowScheduleDuringRun) === !0) && this.enqueueEffect(f, d.dep) : (!(S & E) && f.flags & v && ((u = (g = f.sourceHooks).onInvalidate) == null || u.call(g, f.firstSub !== null)), f.firstSub !== null && (this.invalidationStack[s++] = f.firstSub));
|
|
534
635
|
}
|
|
535
636
|
for (; s !== i; ) {
|
|
536
|
-
let
|
|
537
|
-
|
|
538
|
-
const
|
|
539
|
-
let
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
637
|
+
let d = this.invalidationStack[--s];
|
|
638
|
+
do {
|
|
639
|
+
const f = d.sub, S = f.flags;
|
|
640
|
+
let k = 0;
|
|
641
|
+
if (S & (E | D) ? S & D && (k = this.invalidateReadDependency(d, f, S)) : (k = S & ~C | w, f.flags = k), k === 0) {
|
|
642
|
+
if (S & y && S & x) {
|
|
643
|
+
const L = d.dep.flags & v ? d.dep.sourceHooks.token : void 0;
|
|
644
|
+
L !== void 0 && ((I = (o = f.effectTask) == null ? void 0 : o.notify) == null || I.call(o, L));
|
|
645
|
+
} else if (f.flags & v && ((A = (_ = f.sourceHooks).onInvalidate) == null || A.call(_, f.firstSub !== null), f.firstSub !== null)) {
|
|
646
|
+
d.nextSub !== null && (this.invalidationStack[s++] = d.nextSub), d = f.firstSub;
|
|
545
647
|
continue;
|
|
546
648
|
}
|
|
649
|
+
} else if (k & y)
|
|
650
|
+
this.enqueueEffect(f, d.dep);
|
|
651
|
+
else if (!(S & E) && f.flags & v && ((Q = (O = f.sourceHooks).onInvalidate) == null || Q.call(O, f.firstSub !== null)), f.firstSub !== null) {
|
|
652
|
+
d.nextSub !== null && (this.invalidationStack[s++] = d.nextSub), d = f.firstSub;
|
|
653
|
+
continue;
|
|
547
654
|
}
|
|
548
|
-
|
|
549
|
-
}
|
|
655
|
+
d = d.nextSub;
|
|
656
|
+
} while (d !== null);
|
|
550
657
|
}
|
|
551
658
|
this.invalidationDepth = i;
|
|
552
659
|
}
|
|
@@ -560,11 +667,11 @@ class y {
|
|
|
560
667
|
if (s === null)
|
|
561
668
|
return 0;
|
|
562
669
|
if (e !== s) {
|
|
563
|
-
for (let
|
|
564
|
-
if (
|
|
670
|
+
for (let l = e.prevDep; l !== null; l = l.prevDep)
|
|
671
|
+
if (l === s)
|
|
565
672
|
return 0;
|
|
566
673
|
}
|
|
567
|
-
const n = i |
|
|
674
|
+
const n = i | C | w;
|
|
568
675
|
return t.flags = n, n;
|
|
569
676
|
}
|
|
570
677
|
/**
|
|
@@ -573,11 +680,12 @@ class y {
|
|
|
573
680
|
* текущую связь и автора записи.
|
|
574
681
|
*/
|
|
575
682
|
confirmSubUpdates(e, t, i = null) {
|
|
576
|
-
|
|
577
|
-
|
|
683
|
+
var s, n;
|
|
684
|
+
for (let l = e; l !== null; l = l.nextSub) {
|
|
685
|
+
if (l === t || l.sub === i)
|
|
578
686
|
continue;
|
|
579
|
-
const
|
|
580
|
-
r &
|
|
687
|
+
const a = l.sub, r = a.flags;
|
|
688
|
+
r & p || (a.flags = r & ~w | p, r & y ? this.enqueueEffect(a, l.dep) : r & E || a.flags & v && ((n = (s = a.sourceHooks).onInvalidate) == null || n.call(s, a.firstSub !== null)));
|
|
581
689
|
}
|
|
582
690
|
}
|
|
583
691
|
/**
|
|
@@ -590,22 +698,24 @@ class y {
|
|
|
590
698
|
recomputeValue(e, t = null) {
|
|
591
699
|
const i = e.evaluate;
|
|
592
700
|
e.tailDep = null;
|
|
593
|
-
const s = e.flags & ~
|
|
701
|
+
const s = e.flags & ~C | D;
|
|
594
702
|
e.flags = s;
|
|
595
703
|
const n = this.activeSub;
|
|
596
704
|
this.activeSub = e;
|
|
597
|
-
let
|
|
705
|
+
let l;
|
|
598
706
|
try {
|
|
599
|
-
|
|
600
|
-
} catch (
|
|
601
|
-
throw this.restoreComputedFailure(e, t),
|
|
707
|
+
l = i();
|
|
708
|
+
} catch (u) {
|
|
709
|
+
throw e.evaluate !== i ? (e.cachedValue = void 0, e.flags = 0, u) : (this.restoreComputedFailure(e, t), u);
|
|
602
710
|
} finally {
|
|
603
711
|
this.activeSub = n;
|
|
604
712
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
|
|
713
|
+
if (e.evaluate !== i)
|
|
714
|
+
return e.cachedValue = void 0, e.flags = 0, !1;
|
|
715
|
+
const a = e.flags & C, r = s & -268, h = e.tailDep;
|
|
716
|
+
(h === null ? e.firstDep : h.nextDep) !== null && this.pruneUnreadDependencies(e);
|
|
717
|
+
const g = e.cachedValue;
|
|
718
|
+
return e.cachedValue = l, e.flags = s & v | (a ? p : r), g === l ? !1 : (e.firstSub !== null && this.confirmSubUpdates(e.firstSub, t), !0);
|
|
609
719
|
}
|
|
610
720
|
/**
|
|
611
721
|
* Восстанавливает связи и состояния после неудачного getter.
|
|
@@ -613,7 +723,7 @@ class y {
|
|
|
613
723
|
* Потребитель исключаемой связи мог уже покинуть активный префикс стека.
|
|
614
724
|
*/
|
|
615
725
|
restoreComputedFailure(e, t) {
|
|
616
|
-
e.flags = e.flags & -144 |
|
|
726
|
+
e.flags = e.flags & -144 | m, this.pruneUnreadDependencies(e), t !== null && this.restoreFailedDependency(t.sub);
|
|
617
727
|
}
|
|
618
728
|
/**
|
|
619
729
|
* Итеративно проверяет зависимые computed и pending-сигналы перед запуском потребителя.
|
|
@@ -632,6 +742,13 @@ class y {
|
|
|
632
742
|
throw this.dependencyDepth = i, this.dependencyStack.length = i, s;
|
|
633
743
|
}
|
|
634
744
|
}
|
|
745
|
+
/** Settles every direct dependency so a cancelled external delivery can be re-armed. */
|
|
746
|
+
settleCancelledDependencies(e) {
|
|
747
|
+
for (let t = e.firstDep; t !== null; t = t.nextDep) {
|
|
748
|
+
const i = t.dep, s = i.flags;
|
|
749
|
+
s & (T | E | m) && (i.evaluate === void 0 ? s & p && this.commitSignalValue(i, t) : this.refreshComputedValue(i, s, t));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
635
752
|
/**
|
|
636
753
|
* Выполняет исходный итеративный обход зависимостей без обработки ошибок внутри цикла.
|
|
637
754
|
* Перед пользовательским вычислением публикует активную высоту стека; оболочка
|
|
@@ -641,18 +758,18 @@ class y {
|
|
|
641
758
|
const i = this.dependencyDepth;
|
|
642
759
|
let s = i, n = !1;
|
|
643
760
|
e: for (; ; ) {
|
|
644
|
-
if (e.flags &
|
|
761
|
+
if (e.flags & p)
|
|
645
762
|
n = !0;
|
|
646
763
|
else {
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
649
|
-
this.dependencyDepth = s, n =
|
|
650
|
-
else if (
|
|
651
|
-
if (
|
|
652
|
-
this.dependencyStack[s++] = t, e =
|
|
764
|
+
const l = t.dep, a = l.flags;
|
|
765
|
+
if (a & (p | m))
|
|
766
|
+
this.dependencyDepth = s, n = l.evaluate === void 0 ? this.commitSignalValue(l, t) : this.recomputeValue(l, t);
|
|
767
|
+
else if (a & w) {
|
|
768
|
+
if (l.firstDep !== null) {
|
|
769
|
+
this.dependencyStack[s++] = t, e = l, t = l.firstDep;
|
|
653
770
|
continue e;
|
|
654
771
|
}
|
|
655
|
-
this.dependencyDepth = s, n = this.recomputeValue(
|
|
772
|
+
this.dependencyDepth = s, n = this.recomputeValue(l, t);
|
|
656
773
|
} else
|
|
657
774
|
n = !1;
|
|
658
775
|
}
|
|
@@ -663,10 +780,10 @@ class y {
|
|
|
663
780
|
if (n) {
|
|
664
781
|
for (; s !== i; ) {
|
|
665
782
|
this.dependencyDepth = --s;
|
|
666
|
-
const
|
|
667
|
-
if (n = this.recomputeValue(e,
|
|
668
|
-
if (
|
|
669
|
-
t =
|
|
783
|
+
const l = this.dependencyStack[s];
|
|
784
|
+
if (n = this.recomputeValue(e, l), e = l.sub, !n) {
|
|
785
|
+
if (l.nextDep !== null) {
|
|
786
|
+
t = l.nextDep;
|
|
670
787
|
continue e;
|
|
671
788
|
}
|
|
672
789
|
break;
|
|
@@ -677,13 +794,13 @@ class y {
|
|
|
677
794
|
}
|
|
678
795
|
for (; s !== i; ) {
|
|
679
796
|
this.dependencyDepth = --s;
|
|
680
|
-
const
|
|
681
|
-
if (e.flags &= ~
|
|
682
|
-
t =
|
|
797
|
+
const l = this.dependencyStack[s];
|
|
798
|
+
if (e.flags &= ~w, e = l.sub, l.nextDep !== null) {
|
|
799
|
+
t = l.nextDep;
|
|
683
800
|
continue e;
|
|
684
801
|
}
|
|
685
802
|
}
|
|
686
|
-
return e.flags &= ~
|
|
803
|
+
return e.flags &= ~w, this.dependencyDepth = i, !1;
|
|
687
804
|
}
|
|
688
805
|
}
|
|
689
806
|
/**
|
|
@@ -692,7 +809,7 @@ class y {
|
|
|
692
809
|
* для следующей invalidation. Вызывается только на ошибочном пути.
|
|
693
810
|
*/
|
|
694
811
|
restoreFailedDependency(e) {
|
|
695
|
-
e.flags &= -16, e.flags &
|
|
812
|
+
e.flags &= -16, e.flags & y || (e.flags |= m);
|
|
696
813
|
}
|
|
697
814
|
/**
|
|
698
815
|
* Проверяет необходимость запуска, очищает прошлые ресурсы и выполняет тело эффекта.
|
|
@@ -703,70 +820,70 @@ class y {
|
|
|
703
820
|
*/
|
|
704
821
|
executeEffect(e) {
|
|
705
822
|
const t = e.flags;
|
|
706
|
-
if (!(t &
|
|
823
|
+
if (!(t & E))
|
|
707
824
|
return;
|
|
708
|
-
if (!(t & (
|
|
709
|
-
const
|
|
825
|
+
if (!(t & (p | C))) {
|
|
826
|
+
const h = e.firstDep;
|
|
710
827
|
try {
|
|
711
|
-
if (
|
|
712
|
-
e.flags &= ~
|
|
828
|
+
if (h === null || !this.refreshDependencies(e, h)) {
|
|
829
|
+
e.flags &= ~E;
|
|
713
830
|
return;
|
|
714
831
|
}
|
|
715
|
-
} catch (
|
|
716
|
-
throw e.flags &= -80,
|
|
832
|
+
} catch (g) {
|
|
833
|
+
throw e.flags &= -80, g;
|
|
717
834
|
}
|
|
718
835
|
}
|
|
719
836
|
const i = e.evaluate;
|
|
720
837
|
if (i === void 0) {
|
|
721
|
-
e.flags &= ~
|
|
838
|
+
e.flags &= ~E;
|
|
722
839
|
return;
|
|
723
840
|
}
|
|
724
841
|
let s;
|
|
725
842
|
if (e.scopeLastChild !== void 0)
|
|
726
843
|
try {
|
|
727
844
|
this.disposeNestedEffects(e);
|
|
728
|
-
} catch (
|
|
729
|
-
s = [
|
|
845
|
+
} catch (h) {
|
|
846
|
+
s = [h];
|
|
730
847
|
}
|
|
731
848
|
const n = typeof e.cachedValue == "function" ? e.cachedValue : void 0;
|
|
732
|
-
if (e.cachedValue = void 0, e.flags &= ~
|
|
849
|
+
if (e.cachedValue = void 0, e.flags &= ~C, n !== void 0)
|
|
733
850
|
try {
|
|
734
851
|
this.untracked(n);
|
|
735
|
-
} catch (
|
|
736
|
-
s ?? (s = []), s.push(
|
|
852
|
+
} catch (h) {
|
|
853
|
+
s ?? (s = []), s.push(h);
|
|
737
854
|
}
|
|
738
855
|
if (s !== void 0) {
|
|
739
856
|
try {
|
|
740
857
|
this.disposeEffect(e);
|
|
741
|
-
} catch (
|
|
742
|
-
s.push(
|
|
858
|
+
} catch (h) {
|
|
859
|
+
s.push(h);
|
|
743
860
|
}
|
|
744
|
-
|
|
861
|
+
F(s, "Effect cleanup failed.");
|
|
745
862
|
}
|
|
746
863
|
if (e.evaluate === void 0)
|
|
747
864
|
return;
|
|
748
|
-
e.tailDep = null, e.flags = e.flags & ~
|
|
749
|
-
const
|
|
865
|
+
e.tailDep = null, e.flags = e.flags & ~C | D;
|
|
866
|
+
const l = this.activeSub;
|
|
750
867
|
this.activeSub = e;
|
|
751
|
-
let
|
|
868
|
+
let a;
|
|
752
869
|
try {
|
|
753
|
-
|
|
754
|
-
} catch (
|
|
755
|
-
this.activeSub =
|
|
870
|
+
a = i();
|
|
871
|
+
} catch (h) {
|
|
872
|
+
this.activeSub = l, e.flags &= ~D, this.failEffectRun(e, h, s);
|
|
756
873
|
} finally {
|
|
757
|
-
this.activeSub =
|
|
874
|
+
this.activeSub = l, e.flags &= ~D;
|
|
758
875
|
}
|
|
759
|
-
const
|
|
760
|
-
if ((
|
|
876
|
+
const r = e.tailDep;
|
|
877
|
+
if ((r === null ? e.firstDep : r.nextDep) !== null && this.pruneUnreadDependencies(e), typeof a == "function")
|
|
761
878
|
if (e.evaluate === void 0)
|
|
762
879
|
try {
|
|
763
|
-
this.untracked(
|
|
764
|
-
} catch (
|
|
765
|
-
s ?? (s = []), s.push(
|
|
880
|
+
this.untracked(a);
|
|
881
|
+
} catch (h) {
|
|
882
|
+
s ?? (s = []), s.push(h);
|
|
766
883
|
}
|
|
767
884
|
else
|
|
768
|
-
e.cachedValue =
|
|
769
|
-
e.flags &
|
|
885
|
+
e.cachedValue = a;
|
|
886
|
+
e.flags & x ? e.flags = e.flags & -7 | w : e.flags &= -8;
|
|
770
887
|
}
|
|
771
888
|
/**
|
|
772
889
|
* Завершает неудачный запуск эффекта, не затрагивая успешный путь исполнения.
|
|
@@ -789,12 +906,12 @@ class y {
|
|
|
789
906
|
* Путь не проверяет наличие внешней задачи у каждого узла.
|
|
790
907
|
*/
|
|
791
908
|
flushSyncEffects() {
|
|
792
|
-
if (!(this.flushingEffects || this.activeSub !== null && (this.activeSub.flags & (
|
|
909
|
+
if (!(this.flushingEffects || this.activeSub !== null && (this.activeSub.flags & (y | D)) === (y | D))) {
|
|
793
910
|
this.flushingEffects = !0;
|
|
794
911
|
try {
|
|
795
912
|
for (; this.effectReadIndex !== this.effectWriteIndex; ) {
|
|
796
913
|
const e = this.effectReadIndex, t = this.effectQueue[e];
|
|
797
|
-
this.effectQueue[e] = void 0, ++this.effectReadIndex, t.flags &= ~
|
|
914
|
+
this.effectQueue[e] = void 0, ++this.effectReadIndex, t.flags &= ~x, this.executeEffect(t);
|
|
798
915
|
}
|
|
799
916
|
} catch (e) {
|
|
800
917
|
this.drainQueueAfterError(e, !1);
|
|
@@ -809,12 +926,14 @@ class y {
|
|
|
809
926
|
* Ошибка одного элемента не оставляет необработанные записи со старым SCHEDULED.
|
|
810
927
|
*/
|
|
811
928
|
flushExternalEffects() {
|
|
812
|
-
if (!(this.flushingEffects || this.activeSub !== null && (this.activeSub.flags & (
|
|
929
|
+
if (!(this.flushingEffects || this.activeSub !== null && (this.activeSub.flags & (y | D)) === (y | D))) {
|
|
813
930
|
this.flushingEffects = !0;
|
|
814
931
|
try {
|
|
815
932
|
for (; this.effectReadIndex !== this.effectWriteIndex; ) {
|
|
816
933
|
const e = this.effectReadIndex, t = this.effectQueue[e];
|
|
817
|
-
this.effectQueue[e] = void 0, ++this.effectReadIndex
|
|
934
|
+
this.effectQueue[e] = void 0, ++this.effectReadIndex;
|
|
935
|
+
const i = t.effectTask;
|
|
936
|
+
i === void 0 ? (t.flags &= ~x, this.executeEffect(t)) : t.evaluate !== void 0 ? this.scheduleEffectTask(t, i) : t.flags &= ~x;
|
|
818
937
|
}
|
|
819
938
|
} catch (e) {
|
|
820
939
|
this.drainQueueAfterError(e, !0);
|
|
@@ -832,11 +951,12 @@ class y {
|
|
|
832
951
|
const i = [e];
|
|
833
952
|
for (; this.effectReadIndex !== this.effectWriteIndex; ) {
|
|
834
953
|
const s = this.effectReadIndex++, n = this.effectQueue[s];
|
|
835
|
-
this.effectQueue[s] = void 0
|
|
954
|
+
this.effectQueue[s] = void 0;
|
|
836
955
|
try {
|
|
837
|
-
t
|
|
838
|
-
|
|
839
|
-
|
|
956
|
+
const l = t ? n.effectTask : void 0;
|
|
957
|
+
l !== void 0 && n.evaluate !== void 0 ? this.scheduleEffectTask(n, l) : (n.flags &= ~x, this.executeEffect(n));
|
|
958
|
+
} catch (l) {
|
|
959
|
+
i.push(l);
|
|
840
960
|
}
|
|
841
961
|
}
|
|
842
962
|
throw i.length === 1 ? e : new AggregateError(i, "Effect queue processing failed.");
|
|
@@ -848,13 +968,14 @@ class y {
|
|
|
848
968
|
*/
|
|
849
969
|
requestEffectTask(e) {
|
|
850
970
|
const t = e.effectTask;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
971
|
+
t === void 0 || e.evaluate === void 0 || (e.flags |= x, this.scheduleEffectTask(e, t));
|
|
972
|
+
}
|
|
973
|
+
// Передаёт уже запланированный эффект его постоянной внешней задаче.
|
|
974
|
+
scheduleEffectTask(e, t) {
|
|
975
|
+
try {
|
|
976
|
+
t.schedule();
|
|
977
|
+
} catch (i) {
|
|
978
|
+
throw e.flags &= -72, i;
|
|
858
979
|
}
|
|
859
980
|
}
|
|
860
981
|
/**
|
|
@@ -866,39 +987,40 @@ class y {
|
|
|
866
987
|
disposeEffect(e) {
|
|
867
988
|
if (e.evaluate === void 0)
|
|
868
989
|
return;
|
|
990
|
+
this.activeSub === e && (this.activeSub = null);
|
|
869
991
|
const t = e.effectTask, i = e.onStop, s = typeof e.cachedValue == "function" ? e.cachedValue : void 0;
|
|
870
|
-
e.evaluate = void 0, e.flags = 0, e.cachedValue = void 0, e.effectTask = void 0, i !== void 0 && (e.onStop = void 0),
|
|
992
|
+
e.evaluate = void 0, e.flags = 0, e.cachedValue = void 0, e.effectTask = void 0, i !== void 0 && (e.onStop = void 0), K(e);
|
|
871
993
|
let n = e.firstDep;
|
|
872
994
|
for (; n !== null; ) {
|
|
873
|
-
const
|
|
874
|
-
this.detachSubLink(n), n =
|
|
995
|
+
const a = n.nextDep;
|
|
996
|
+
this.detachSubLink(n), n = a;
|
|
875
997
|
}
|
|
876
|
-
e.firstDep = e.tailDep = null, e.depCount = 0;
|
|
877
|
-
let
|
|
998
|
+
e.firstDep = e.tailDep = null, e.depCount = 0, N(e);
|
|
999
|
+
let l;
|
|
878
1000
|
if (t !== void 0)
|
|
879
1001
|
try {
|
|
880
1002
|
t.dispose();
|
|
881
|
-
} catch (
|
|
882
|
-
|
|
1003
|
+
} catch (a) {
|
|
1004
|
+
l = [a];
|
|
883
1005
|
}
|
|
884
1006
|
try {
|
|
885
1007
|
this.disposeNestedEffects(e);
|
|
886
|
-
} catch (
|
|
887
|
-
|
|
1008
|
+
} catch (a) {
|
|
1009
|
+
l ?? (l = []), l.push(a);
|
|
888
1010
|
}
|
|
889
1011
|
if (s !== void 0)
|
|
890
1012
|
try {
|
|
891
1013
|
this.untracked(s);
|
|
892
|
-
} catch (
|
|
893
|
-
|
|
1014
|
+
} catch (a) {
|
|
1015
|
+
l ?? (l = []), l.push(a);
|
|
894
1016
|
}
|
|
895
1017
|
if (i !== void 0)
|
|
896
1018
|
try {
|
|
897
1019
|
this.untracked(i);
|
|
898
|
-
} catch (
|
|
899
|
-
|
|
1020
|
+
} catch (a) {
|
|
1021
|
+
l ?? (l = []), l.push(a);
|
|
900
1022
|
}
|
|
901
|
-
this.invalidationStack.length = this.invalidationDepth, this.dependencyStack.length = this.dependencyDepth,
|
|
1023
|
+
this.invalidationStack.length = this.invalidationDepth, this.dependencyStack.length = this.dependencyDepth, l !== void 0 && F(l, "Effect disposal failed.");
|
|
902
1024
|
}
|
|
903
1025
|
/**
|
|
904
1026
|
* Останавливает все вложенные эффекты в обратном порядке регистрации.
|
|
@@ -913,14 +1035,14 @@ class y {
|
|
|
913
1035
|
} catch (i) {
|
|
914
1036
|
t ?? (t = []), t.push(i);
|
|
915
1037
|
}
|
|
916
|
-
t !== void 0 &&
|
|
1038
|
+
t !== void 0 && F(t, "Nested effect disposal failed.");
|
|
917
1039
|
}
|
|
918
1040
|
/**
|
|
919
1041
|
* Задаёт обязательные поля графа перед первым вычислением.
|
|
920
1042
|
* Вызывается только для нематериализованного handle; getter и контекст сохраняются.
|
|
921
1043
|
*/
|
|
922
1044
|
static materializeComputed(e) {
|
|
923
|
-
e.flags =
|
|
1045
|
+
e.flags = T | (e.sourceHooks === void 0 ? 0 : v), e.firstSub = null, e.lastSub = null, e.firstDep = null, e.tailDep = null, e.depCount = 0, e.cachedValue = void 0;
|
|
924
1046
|
}
|
|
925
1047
|
/**
|
|
926
1048
|
* Связывает два разных receiver: движок-владелец и читаемый handle.
|
|
@@ -938,14 +1060,14 @@ class y {
|
|
|
938
1060
|
*/
|
|
939
1061
|
initializeComputed() {
|
|
940
1062
|
const i = this;
|
|
941
|
-
return
|
|
1063
|
+
return U.materializeComputed(i), this.get = t, e.readComputedValue(i);
|
|
942
1064
|
},
|
|
943
1065
|
/**
|
|
944
1066
|
* Материализует raw computed, сохраняя извлечение read после первого вызова.
|
|
945
1067
|
*/
|
|
946
1068
|
initializeRaw() {
|
|
947
1069
|
const i = this;
|
|
948
|
-
|
|
1070
|
+
U.materializeComputed(i);
|
|
949
1071
|
const s = () => e.readComputedValue(i);
|
|
950
1072
|
return this.read = s, s();
|
|
951
1073
|
},
|
|
@@ -983,17 +1105,17 @@ class y {
|
|
|
983
1105
|
_signalAccess(e) {
|
|
984
1106
|
const t = this;
|
|
985
1107
|
let i = e, s;
|
|
986
|
-
function n(
|
|
1108
|
+
function n(l) {
|
|
987
1109
|
if (arguments.length !== 0) {
|
|
988
|
-
const
|
|
989
|
-
|
|
1110
|
+
const h = s;
|
|
1111
|
+
h !== void 0 ? t.writeSignalValue(h, l) : i !== l && (i = l);
|
|
990
1112
|
return;
|
|
991
1113
|
}
|
|
992
|
-
const
|
|
993
|
-
if (
|
|
994
|
-
return t.readSignalValue(
|
|
995
|
-
const
|
|
996
|
-
return
|
|
1114
|
+
const a = s;
|
|
1115
|
+
if (a !== void 0)
|
|
1116
|
+
return t.readSignalValue(a);
|
|
1117
|
+
const r = t.activeSub;
|
|
1118
|
+
return r === null || (s = t.materializeSignal(i, r)), i;
|
|
997
1119
|
}
|
|
998
1120
|
return {
|
|
999
1121
|
read: n,
|
|
@@ -1019,66 +1141,115 @@ class y {
|
|
|
1019
1141
|
*
|
|
1020
1142
|
* @internal
|
|
1021
1143
|
*/
|
|
1022
|
-
_ownedSignal(e) {
|
|
1023
|
-
const
|
|
1024
|
-
let
|
|
1025
|
-
const
|
|
1026
|
-
const u =
|
|
1144
|
+
_ownedSignal(e, t) {
|
|
1145
|
+
const i = this;
|
|
1146
|
+
let s = e, n, l = !1;
|
|
1147
|
+
const a = () => {
|
|
1148
|
+
const u = n;
|
|
1027
1149
|
if (u !== void 0)
|
|
1028
1150
|
return this.readSignalValue(u);
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1151
|
+
const o = this.activeSub;
|
|
1152
|
+
if (o === null)
|
|
1153
|
+
return s;
|
|
1154
|
+
const I = s;
|
|
1155
|
+
return n = this.materializeSignal(
|
|
1156
|
+
I,
|
|
1157
|
+
o,
|
|
1158
|
+
t
|
|
1159
|
+
), s = void 0, I;
|
|
1160
|
+
}, r = t === void 0 ? (u) => {
|
|
1161
|
+
const o = n;
|
|
1162
|
+
o !== void 0 ? this.writeSignalValue(o, u) : s !== u && (s = u);
|
|
1163
|
+
} : (u) => {
|
|
1164
|
+
var I, _;
|
|
1165
|
+
const o = n;
|
|
1166
|
+
if (o !== void 0) {
|
|
1167
|
+
const A = o.flags & p ? o.pendingValue : o.cachedValue;
|
|
1168
|
+
A !== u && ((I = t.onChange) == null || I.call(t, A, u, o.firstSub !== null)), this.writeSignalValue(o, u);
|
|
1038
1169
|
return;
|
|
1039
1170
|
}
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
return {
|
|
1171
|
+
s !== u && ((_ = t.onChange) == null || _.call(t, s, u, !1), s = u);
|
|
1172
|
+
}, g = {
|
|
1043
1173
|
source: {
|
|
1044
|
-
get:
|
|
1174
|
+
get: a,
|
|
1045
1175
|
peek: this.handleReaders.peek,
|
|
1046
|
-
set:
|
|
1176
|
+
set: r
|
|
1047
1177
|
},
|
|
1048
1178
|
/**
|
|
1049
1179
|
* Освобождает источник и отсоединяет его от реактивного графа.
|
|
1050
1180
|
*/
|
|
1051
1181
|
dispose() {
|
|
1052
|
-
|
|
1182
|
+
var o;
|
|
1183
|
+
if (l)
|
|
1184
|
+
return !0;
|
|
1185
|
+
l = !0, s = void 0;
|
|
1186
|
+
let u;
|
|
1187
|
+
try {
|
|
1188
|
+
(o = t == null ? void 0 : t.onDispose) == null || o.call(t, (n == null ? void 0 : n.firstSub) != null);
|
|
1189
|
+
} catch (I) {
|
|
1190
|
+
(u ?? (u = [])).push(I);
|
|
1191
|
+
}
|
|
1192
|
+
if (n !== void 0) {
|
|
1193
|
+
try {
|
|
1194
|
+
i.releaseSourceSubs(n);
|
|
1195
|
+
} catch (I) {
|
|
1196
|
+
(u ?? (u = [])).push(I);
|
|
1197
|
+
}
|
|
1198
|
+
n.cachedValue = void 0, n.pendingValue = void 0, n.pendingAuthor = void 0, n.flags = 0;
|
|
1199
|
+
}
|
|
1200
|
+
if (n = void 0, (u == null ? void 0 : u.length) === 1)
|
|
1201
|
+
throw u[0];
|
|
1202
|
+
if (u !== void 0 && u.length > 1)
|
|
1203
|
+
throw new AggregateError(u, "Owned signal disposal failed.");
|
|
1204
|
+
return !0;
|
|
1053
1205
|
}
|
|
1054
1206
|
};
|
|
1207
|
+
return t !== void 0 && (g.hasSubscribers = () => (n == null ? void 0 : n.firstSub) != null), g;
|
|
1055
1208
|
}
|
|
1056
1209
|
/**
|
|
1057
1210
|
* Создаёт ленивый computed с финализатором исходящих и входящих связей.
|
|
1058
1211
|
* Финализатор работает и до первого вычисления, не материализуя узел ради очистки.
|
|
1059
1212
|
* @internal
|
|
1060
1213
|
*/
|
|
1061
|
-
_ownedComputed(e) {
|
|
1062
|
-
const
|
|
1063
|
-
let
|
|
1064
|
-
|
|
1065
|
-
source:
|
|
1214
|
+
_ownedComputed(e, t) {
|
|
1215
|
+
const i = this, s = this.createComputedHandle(e, t);
|
|
1216
|
+
let n = !1;
|
|
1217
|
+
const l = {
|
|
1218
|
+
source: s,
|
|
1066
1219
|
/**
|
|
1067
1220
|
* Отсоединяет принадлежащий источник и освобождает его ссылки.
|
|
1068
1221
|
* Повторный вызов возвращает true без повторной очистки.
|
|
1069
1222
|
*/
|
|
1070
1223
|
dispose() {
|
|
1071
|
-
|
|
1224
|
+
var h;
|
|
1225
|
+
if (n)
|
|
1072
1226
|
return !0;
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1227
|
+
n = !0, i.activeSub === s && (i.activeSub = null);
|
|
1228
|
+
const a = [];
|
|
1229
|
+
try {
|
|
1230
|
+
(h = t == null ? void 0 : t.onDispose) == null || h.call(t, s.firstSub != null);
|
|
1231
|
+
} catch (g) {
|
|
1232
|
+
a.push(g);
|
|
1233
|
+
}
|
|
1234
|
+
if (s.flags !== void 0)
|
|
1235
|
+
try {
|
|
1236
|
+
i.releaseSourceSubs(s);
|
|
1237
|
+
} catch (g) {
|
|
1238
|
+
a.push(g);
|
|
1239
|
+
}
|
|
1240
|
+
let r = s.firstDep;
|
|
1241
|
+
for (; r != null; ) {
|
|
1242
|
+
const g = r.nextDep;
|
|
1243
|
+
i.detachSubLink(r), r = g;
|
|
1078
1244
|
}
|
|
1079
|
-
|
|
1245
|
+
if (s.firstDep = s.tailDep = null, s.depCount = 0, N(s), s.evaluate = void 0, s.cachedValue = void 0, s.flags = 0, a.length === 1)
|
|
1246
|
+
throw a[0];
|
|
1247
|
+
if (a.length > 1)
|
|
1248
|
+
throw new AggregateError(a, "Owned computed disposal failed.");
|
|
1249
|
+
return !0;
|
|
1080
1250
|
}
|
|
1081
1251
|
};
|
|
1252
|
+
return t !== void 0 && (l.hasSubscribers = () => s.firstSub != null), l;
|
|
1082
1253
|
}
|
|
1083
1254
|
/**
|
|
1084
1255
|
* Открывает вложенную синхронную границу группировки.
|
|
@@ -1111,23 +1282,24 @@ class y {
|
|
|
1111
1282
|
return this.flushingEffects;
|
|
1112
1283
|
}
|
|
1113
1284
|
}
|
|
1114
|
-
let
|
|
1115
|
-
function
|
|
1116
|
-
return
|
|
1285
|
+
let Z;
|
|
1286
|
+
function V() {
|
|
1287
|
+
return Z ?? (Z = new U());
|
|
1117
1288
|
}
|
|
1118
|
-
const
|
|
1119
|
-
function
|
|
1120
|
-
return
|
|
1289
|
+
const te = (c) => V().signal(c), ie = (c) => V().reactive(c);
|
|
1290
|
+
function se(c) {
|
|
1291
|
+
return V().computed(c);
|
|
1121
1292
|
}
|
|
1122
|
-
const
|
|
1293
|
+
const ne = (c, e) => V().effect(c, e), le = (c, e, t) => V().watch(c, e, t), ae = (c) => V().batch(c), re = (c) => V().untracked(c), ce = () => V().scope();
|
|
1123
1294
|
export {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1295
|
+
U as RaphReactivity,
|
|
1296
|
+
M as ScopeNode,
|
|
1297
|
+
ae as batch,
|
|
1298
|
+
se as computed,
|
|
1299
|
+
ne as effect,
|
|
1300
|
+
ie as reactive,
|
|
1301
|
+
ce as scope,
|
|
1302
|
+
te as signal,
|
|
1303
|
+
re as untracked,
|
|
1304
|
+
le as watch
|
|
1133
1305
|
};
|