@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,35 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { pathRelationMasks as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
class
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var u = (o, s, t) => s in o ? p(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
|
|
3
|
+
var i = (o, s, t) => u(o, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { pathRelationMasks as f } from "../../path/data-path.utils.js";
|
|
5
|
+
import { RaphDisposedError as k } from "../errors.js";
|
|
6
|
+
import { throwDisposalErrors as w } from "../ownership/throwDisposalErrors.js";
|
|
7
|
+
class T {
|
|
8
8
|
/**
|
|
9
9
|
* Создаёт internal path handle и связывает его с runtime lifecycle.
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
constructor(s, t, h,
|
|
12
|
+
constructor(s, t, h, r, e, a, n, d, v, c, l) {
|
|
13
13
|
// Публикуют canonical path и нормализованные параметры handle.
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
i(this, "path");
|
|
15
|
+
i(this, "options");
|
|
16
16
|
// Связывают path revision с runtime reactivity и owning Kernel.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
i(this, "_revision");
|
|
18
|
+
i(this, "_disposeRevision");
|
|
19
|
+
i(this, "_isTracking");
|
|
20
|
+
i(this, "_store");
|
|
21
|
+
i(this, "_release");
|
|
22
|
+
i(this, "_masks");
|
|
23
23
|
// Применяют runtime lifecycle и write policy к операциям handle.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
i(this, "_assertOwnerAlive");
|
|
25
|
+
i(this, "_assertTrackedRead");
|
|
26
|
+
i(this, "_assertWriteAllowed");
|
|
27
|
+
i(this, "_runWrite");
|
|
28
|
+
i(this, "_notifyEvents");
|
|
29
|
+
i(this, "_hasRevisionSubscribers");
|
|
28
30
|
// Хранят активную Kernel subscription и окончательное состояние handle.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
i(this, "_stop");
|
|
32
|
+
i(this, "_activationLeases", 0);
|
|
33
|
+
i(this, "_trackedActivation", !1);
|
|
34
|
+
i(this, "_disposed", !1);
|
|
35
|
+
const _ = e._ownedSignal(0, c);
|
|
36
|
+
this._store = s, this._revision = _.source, this._disposeRevision = _.dispose, this._isTracking = e._isTracking, this.path = t.canonical, this.options = h, this._release = r, this._masks = f(t), this._assertOwnerAlive = a, this._assertTrackedRead = n, this._assertWriteAllowed = d, this._runWrite = v, this._notifyEvents = l, this._hasRevisionSubscribers = _.hasSubscribers;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Показывает, освобождён ли path handle.
|
|
@@ -81,6 +85,12 @@ class R {
|
|
|
81
85
|
* Отсоединяет Kernel subscription и освобождает reactive revision handle.
|
|
82
86
|
*/
|
|
83
87
|
dispose() {
|
|
88
|
+
if (this._disposed)
|
|
89
|
+
return;
|
|
90
|
+
const s = this._runWrite;
|
|
91
|
+
s === void 0 ? this._disposeNow() : s(() => this._disposeNow());
|
|
92
|
+
}
|
|
93
|
+
_disposeNow() {
|
|
84
94
|
if (this._disposed)
|
|
85
95
|
return;
|
|
86
96
|
this._disposed = !0;
|
|
@@ -88,24 +98,24 @@ class R {
|
|
|
88
98
|
this._stop = void 0;
|
|
89
99
|
const h = this._disposeRevision;
|
|
90
100
|
this._disposeRevision = void 0;
|
|
91
|
-
const
|
|
92
|
-
this._release = void 0, this._revision = void 0, this._isTracking = void 0, this._store = void 0, this._assertOwnerAlive = void 0, this._assertTrackedRead = void 0, this._assertWriteAllowed = void 0, this._runWrite = void 0;
|
|
101
|
+
const r = this._release;
|
|
102
|
+
this._release = void 0, this._revision = void 0, this._isTracking = void 0, this._store = void 0, this._assertOwnerAlive = void 0, this._assertTrackedRead = void 0, this._assertWriteAllowed = void 0, this._runWrite = void 0, this._notifyEvents = void 0, this._hasRevisionSubscribers = void 0, this._activationLeases = 0, this._trackedActivation = !1;
|
|
93
103
|
try {
|
|
94
104
|
t == null || t();
|
|
95
|
-
} catch (
|
|
96
|
-
s.push(
|
|
105
|
+
} catch (e) {
|
|
106
|
+
s.push(e);
|
|
97
107
|
}
|
|
98
108
|
try {
|
|
99
109
|
h == null || h();
|
|
100
|
-
} catch (
|
|
101
|
-
s.push(
|
|
110
|
+
} catch (e) {
|
|
111
|
+
s.push(e);
|
|
102
112
|
}
|
|
103
113
|
try {
|
|
104
|
-
|
|
105
|
-
} catch (
|
|
106
|
-
s.push(
|
|
114
|
+
r == null || r(this);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
s.push(e);
|
|
107
117
|
}
|
|
108
|
-
|
|
118
|
+
w(s, `[Raph] Path handle "${this.path}" disposal failed.`);
|
|
109
119
|
}
|
|
110
120
|
/**
|
|
111
121
|
* Читает path с регистрацией runtime reactive dependency.
|
|
@@ -115,14 +125,40 @@ class R {
|
|
|
115
125
|
var s;
|
|
116
126
|
return this._assertAlive(), (s = this._assertTrackedRead) == null || s.call(this), this._readTracked();
|
|
117
127
|
}
|
|
128
|
+
/** Activates the lazy Kernel observer for an explicit granular watch. @internal */
|
|
129
|
+
_activate() {
|
|
130
|
+
this._assertAlive(), this._activationLeases++;
|
|
131
|
+
try {
|
|
132
|
+
this._observe();
|
|
133
|
+
} catch (t) {
|
|
134
|
+
throw this._activationLeases--, t;
|
|
135
|
+
}
|
|
136
|
+
let s = !0;
|
|
137
|
+
return () => {
|
|
138
|
+
s && (s = !1, this._activationLeases !== 0 && this._activationLeases--, this._releaseObserverIfIdle());
|
|
139
|
+
};
|
|
140
|
+
}
|
|
118
141
|
_readTracked() {
|
|
119
|
-
return this._observe(), this._revision.get(), this._store.get(this.path);
|
|
142
|
+
return this._trackedActivation = !0, this._observe(), this._revision.get(), this._store.get(this.path);
|
|
120
143
|
}
|
|
121
144
|
_observe() {
|
|
122
|
-
this._stop ?? (this._stop = this._store.watch(this._masks, () => {
|
|
123
|
-
|
|
145
|
+
this._stop ?? (this._stop = this._store.watch(this._masks, (s) => {
|
|
146
|
+
const t = () => {
|
|
147
|
+
var e, a;
|
|
148
|
+
if (this._disposed)
|
|
149
|
+
return;
|
|
150
|
+
const r = this._revision;
|
|
151
|
+
r !== void 0 && ((a = this._notifyEvents) == null || a.call(this, s, ((e = this._hasRevisionSubscribers) == null ? void 0 : e.call(this)) ?? !1), !(this._disposed || this._revision !== r) && r.set(r.peek() + 1));
|
|
152
|
+
}, h = this._runWrite;
|
|
153
|
+
h === void 0 ? t() : h(t);
|
|
124
154
|
}));
|
|
125
155
|
}
|
|
156
|
+
_releaseObserverIfIdle() {
|
|
157
|
+
if (this._disposed || this._trackedActivation || this._activationLeases !== 0)
|
|
158
|
+
return;
|
|
159
|
+
const s = this._stop;
|
|
160
|
+
this._stop = void 0, s == null || s();
|
|
161
|
+
}
|
|
126
162
|
_write(s) {
|
|
127
163
|
const t = this._runWrite;
|
|
128
164
|
t === void 0 ? s() : t(s);
|
|
@@ -130,10 +166,10 @@ class R {
|
|
|
130
166
|
_assertAlive() {
|
|
131
167
|
var s;
|
|
132
168
|
if (this._disposed)
|
|
133
|
-
throw new
|
|
169
|
+
throw new k(`[Raph] Path handle "${this.path}" is disposed.`);
|
|
134
170
|
(s = this._assertOwnerAlive) == null || s.call(this);
|
|
135
171
|
}
|
|
136
172
|
}
|
|
137
173
|
export {
|
|
138
|
-
|
|
174
|
+
T as PathHandle
|
|
139
175
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var u=(o,e,t)=>e in o?p(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var i=(o,e,t)=>u(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../path/DataPath.cjs"),l=require("../errors.cjs");class h{constructor(e,t,s,r,a){i(this,"masks");i(this,"options");i(this,"_stop");i(this,"_activationLeases",0);i(this,"_disposed",!1);i(this,"_releaseOwner");this.owner=e,this._start=r,this._release=a;const n=Object.freeze({...s,...s.vars===void 0?{}:{vars:Object.freeze({...s.vars})}});this.options=n,this.masks=Array.isArray(t)?Object.freeze(t.map(_=>c.DataPath.from(_,n))):c.DataPath.from(t,n)}static _create(e,t,s,r,a){return new h(e,t,s,r,a)}get runtime(){return this.owner.runtime}get disposed(){return this._disposed}dispose(){if(this._disposed)return;const e=this.runtime,t=!e._ownerDisposalActive();t&&e._beginOwnerDisposal();const s=[];try{const r=this._releaseOwner;r!==void 0?(this._releaseOwner=void 0,r()):this._disposeOwned()}catch(r){s.push(r)}finally{if(t)try{e._endOwnerDisposal()}catch(r){s.push(r)}}if(s.length===1)throw s[0];if(s.length>1)throw new AggregateError(s,"[Raph] Meta source disposal failed.")}_bindOwner(e){this._releaseOwner=e}_disposeOwned(){var t;if(this._disposed)return;this._disposed=!0,this._releaseOwner=void 0;const e=[];try{(t=this._stop)==null||t.call(this)}catch(s){e.push(s)}this._stop=void 0,this._activationLeases=0;try{this._release()}catch(s){e.push(s)}if(this._start=f,this._release=d,e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Meta source disposal failed.")}_activate(){this._assertAlive(),this._activationLeases++;try{this._stop??(this._stop=this._start())}catch(t){throw this._activationLeases--,t}let e=!0;return()=>{if(!e||(e=!1,this._activationLeases!==0&&this._activationLeases--,this._disposed||this._activationLeases!==0))return;const t=this._stop;this._stop=void 0,t==null||t()}}_assertAlive(){if(this._disposed||this.owner.disposed)throw new l.RaphDisposedError("[Raph] Meta source is disposed.")}}function d(){}function f(){return d}exports.RaphMetaSource=h;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var l = (o, e, s) => e in o ? _(o, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[e] = s;
|
|
3
|
+
var i = (o, e, s) => l(o, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { DataPath as h } from "../../path/DataPath.js";
|
|
5
|
+
import { RaphDisposedError as f } from "../errors.js";
|
|
6
|
+
class c {
|
|
7
|
+
/** @internal */
|
|
8
|
+
constructor(e, s, t, r, a) {
|
|
9
|
+
i(this, "masks");
|
|
10
|
+
i(this, "options");
|
|
11
|
+
i(this, "_stop");
|
|
12
|
+
i(this, "_activationLeases", 0);
|
|
13
|
+
i(this, "_disposed", !1);
|
|
14
|
+
i(this, "_releaseOwner");
|
|
15
|
+
this.owner = e, this._start = r, this._release = a;
|
|
16
|
+
const n = Object.freeze({
|
|
17
|
+
...t,
|
|
18
|
+
...t.vars === void 0 ? {} : { vars: Object.freeze({ ...t.vars }) }
|
|
19
|
+
});
|
|
20
|
+
this.options = n, this.masks = Array.isArray(s) ? Object.freeze(s.map((p) => h.from(p, n))) : h.from(s, n);
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
static _create(e, s, t, r, a) {
|
|
24
|
+
return new c(e, s, t, r, a);
|
|
25
|
+
}
|
|
26
|
+
get runtime() {
|
|
27
|
+
return this.owner.runtime;
|
|
28
|
+
}
|
|
29
|
+
get disposed() {
|
|
30
|
+
return this._disposed;
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
if (this._disposed)
|
|
34
|
+
return;
|
|
35
|
+
const e = this.runtime, s = !e._ownerDisposalActive();
|
|
36
|
+
s && e._beginOwnerDisposal();
|
|
37
|
+
const t = [];
|
|
38
|
+
try {
|
|
39
|
+
const r = this._releaseOwner;
|
|
40
|
+
r !== void 0 ? (this._releaseOwner = void 0, r()) : this._disposeOwned();
|
|
41
|
+
} catch (r) {
|
|
42
|
+
t.push(r);
|
|
43
|
+
} finally {
|
|
44
|
+
if (s)
|
|
45
|
+
try {
|
|
46
|
+
e._endOwnerDisposal();
|
|
47
|
+
} catch (r) {
|
|
48
|
+
t.push(r);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (t.length === 1)
|
|
52
|
+
throw t[0];
|
|
53
|
+
if (t.length > 1)
|
|
54
|
+
throw new AggregateError(t, "[Raph] Meta source disposal failed.");
|
|
55
|
+
}
|
|
56
|
+
/** @internal */
|
|
57
|
+
_bindOwner(e) {
|
|
58
|
+
this._releaseOwner = e;
|
|
59
|
+
}
|
|
60
|
+
/** @internal */
|
|
61
|
+
_disposeOwned() {
|
|
62
|
+
var s;
|
|
63
|
+
if (this._disposed)
|
|
64
|
+
return;
|
|
65
|
+
this._disposed = !0, this._releaseOwner = void 0;
|
|
66
|
+
const e = [];
|
|
67
|
+
try {
|
|
68
|
+
(s = this._stop) == null || s.call(this);
|
|
69
|
+
} catch (t) {
|
|
70
|
+
e.push(t);
|
|
71
|
+
}
|
|
72
|
+
this._stop = void 0, this._activationLeases = 0;
|
|
73
|
+
try {
|
|
74
|
+
this._release();
|
|
75
|
+
} catch (t) {
|
|
76
|
+
e.push(t);
|
|
77
|
+
}
|
|
78
|
+
if (this._start = u, this._release = d, e.length === 1)
|
|
79
|
+
throw e[0];
|
|
80
|
+
if (e.length > 1)
|
|
81
|
+
throw new AggregateError(e, "[Raph] Meta source disposal failed.");
|
|
82
|
+
}
|
|
83
|
+
/** @internal */
|
|
84
|
+
_activate() {
|
|
85
|
+
this._assertAlive(), this._activationLeases++;
|
|
86
|
+
try {
|
|
87
|
+
this._stop ?? (this._stop = this._start());
|
|
88
|
+
} catch (s) {
|
|
89
|
+
throw this._activationLeases--, s;
|
|
90
|
+
}
|
|
91
|
+
let e = !0;
|
|
92
|
+
return () => {
|
|
93
|
+
if (!e || (e = !1, this._activationLeases !== 0 && this._activationLeases--, this._disposed || this._activationLeases !== 0))
|
|
94
|
+
return;
|
|
95
|
+
const s = this._stop;
|
|
96
|
+
this._stop = void 0, s == null || s();
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** @internal */
|
|
100
|
+
_assertAlive() {
|
|
101
|
+
if (this._disposed || this.owner.disposed)
|
|
102
|
+
throw new f("[Raph] Meta source is disposed.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function d() {
|
|
106
|
+
}
|
|
107
|
+
function u() {
|
|
108
|
+
return d;
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
c as RaphMetaSource
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var $=Object.defineProperty;var U=(u,e,s)=>e in u?$(u,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[e]=s;var d=(u,e,s)=>U(u,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../errors.cjs"),v=require("../ownership/throwDisposalErrors.cjs"),G=Symbol("RaphProducerRecord"),m=new WeakMap,M=Object.freeze([]),C=Object.freeze([]);class p{constructor(e,s){d(this,"_sources");d(this,"_disposed",!1);d(this,"_releaseOwner");d(this,"_memberReleases");d(this,"_firstSubscription");d(this,"_lastSubscription");d(this,"_firstDependent");d(this,"_lastDependent");d(this,"_revision",0);d(this,"_finalCause");this.owner=e,this._sources=q(s)}static _create(e,s){return new p(e,s)}get runtime(){return this.owner.runtime}get disposed(){return this._disposed}get sources(){return this._sources}dispose(){if(this._disposed)return;const e=this.runtime,s=!e._ownerDisposalActive();s&&e._beginOwnerDisposal();const t=[];try{const i=this._releaseOwner;i!==void 0?(this._releaseOwner=void 0,i()):this._disposeOwned()}catch(i){t.push(i)}finally{if(s)try{e._endOwnerDisposal()}catch(i){t.push(i)}}v.throwDisposalErrors(t,"[Raph] Aggregate disposal failed.")}_assertAlive(){if(this._disposed||this.owner.disposed)throw new S.RaphDisposedError("[Raph] Aggregate is disposed.")}_bindOwner(e){this._releaseOwner=e}_bindMembers(e){this._memberReleases=e.length===0?void 0:e}_removeMember(e){if(this._disposed)return;const s=this._sources.filter(t=>L(t)!==e);s.length!==this._sources.length&&(this._sources=s.length===0?M:Object.freeze(s))}_disposeOwned(){if(this._disposed)return;this._disposed=!0,this._releaseOwner=void 0;const e=f(this.owner)&&!this.owner._isPublished()?void 0:this._disposalCause(),s=[];let t=this._firstSubscription;for(this._firstSubscription=this._lastSubscription=void 0;t!==void 0;){const o=t.next,r=t.dispose;t.aggregate=void 0,t.dispose=void 0,t.previous=t.next=void 0;try{r==null||r(e)}catch(a){s.push(a)}t=o}const i=this._memberReleases;if(this._memberReleases=void 0,i!==void 0)for(let o=i.length-1;o>=0;o--)try{i[o]()}catch(r){s.push(r)}this._sources=M;let n=this._firstDependent;for(this._firstDependent=this._lastDependent=void 0;n!==void 0;){const o=n.next,r=n.cleanup;n.source=void 0,n.cleanup=void 0,n.previous=n.next=void 0;try{r==null||r()}catch(a){s.push(a)}n=o}v.throwDisposalErrors(s,"[Raph] Aggregate owned cleanup failed.")}_linkSubscription(e){this._assertAlive();const s={aggregate:this,dispose:e,previous:this._lastSubscription};return this._lastSubscription===void 0?this._firstSubscription=s:this._lastSubscription.next=s,this._lastSubscription=s,()=>I(s)}_linkDependent(e){e.previous=this._lastDependent,this._lastDependent===void 0?this._firstDependent=e:this._lastDependent.next=e,this._lastDependent=e}_detachDependent(e){e.previous===void 0?this._firstDependent=e.next:e.previous.next=e.next,e.next===void 0?this._lastDependent=e.previous:e.next.previous=e.previous,e.previous=e.next=void 0}_disposalCause(){return this._finalCause??(this._finalCause=Object.freeze({kind:"structure",source:this,sourceOwner:this.owner,revision:++this._revision,metadata:Object.freeze({disposed:!0})}))}_detachSubscription(e){if(e.aggregate===void 0)return;const s=e.dispose;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,s==null||s()}}class H{constructor(e){d(this,"_selfSubscribers");d(this,"_subtreeSubscribers");d(this,"_runtimeSubscribers");d(this,"_runtimeSubscriberCount",0);d(this,"_runtimeActivationProducers");d(this,"_nodeMemberships");d(this,"_nodeRevisions");d(this,"_nodeTouchKeys");d(this,"_implicitProducers");d(this,"_transientProducers");d(this,"_dispatchDepth",0);d(this,"_detachedEdges");d(this,"_disposed",!1);this._runtime=e}createProducer(e,s="producer",t={}){return this._assertAlive(),{[G]:!0,runtime:this._runtime,owner:e,kind:s,includeRuntime:t.includeRuntime??!0,revision:0,disposed:!1}}attachProducer(e,s){return e.alias!==void 0&&m.delete(e.alias),e.source=s,e.alias=s,m.set(s,e),s}setProducerActivation(e,s,t=!1){if(e.disposed)throw new S.RaphDisposedError("[Raph] Producer is disposed.");if(e.activate=s,!t)return;const i=this._runtimeActivationProducers??(this._runtimeActivationProducers=new Set);if(i.add(e),this._runtimeSubscriberCount!==0)try{e.runtimeActivation=x(s())}catch(n){throw i.delete(e),i.size===0&&(this._runtimeActivationProducers=void 0),n}}producerHooks(e){return{token:e,dependencyOwner:e.owner,onDependency:s=>this._linkImplicitDependency(e,s),onChange:(s,t,i)=>{this.notifyProducer(e,s,t,void 0,!0,i,!0)},onInvalidate:s=>this.notifyProducer(e,void 0,void 0,void 0,!0,s,!1),onDispose:s=>this._disposeProducer(e,s)}}causeForToken(e){if(!(!O(e)||e.runtime!==this._runtime))return e.lastCause}clearTransientCauses(){let e=this._transientProducers;for(this._transientProducers=void 0;e!==void 0;){const s=e.transientNext;e.transientNext=void 0,e.lastCause=void 0,e=s}}notifyProducer(e,s,t,i,n=!0,o=!1,r=!1){var c,h;if(this._disposed||e.disposed||e.source===void 0||f(e.owner)&&!e.owner._isPublished()||!r&&i===void 0&&e.lastCause!==void 0)return;if(!o&&((c=e.subscribers)==null?void 0:c.first)===void 0&&(!e.includeRuntime||((h=this._runtimeSubscribers)==null?void 0:h.first)===void 0)){this._dispatchProducerLazily(e,s,t,i,n,r);return}const a=Object.freeze({kind:e.kind,source:e.source,sourceOwner:e.owner,revision:++e.revision,...r?{previous:s,value:t}:{},...i===void 0?{}:{events:Object.freeze([...i])}});this._setTransientCause(e,a),this._dispatchProducer(e,a,n)}notifyProducerEvents(e,s,t=!0,i=!1){var o,r;if(this._disposed||e.disposed||e.source===void 0||f(e.owner)&&!e.owner._isPublished())return;if(!i&&((o=e.subscribers)==null?void 0:o.first)===void 0&&(!e.includeRuntime||((r=this._runtimeSubscribers)==null?void 0:r.first)===void 0)){this._dispatchProducerLazily(e,void 0,void 0,s,t,!1);return}const n=Object.freeze({kind:e.kind,source:e.source,sourceOwner:e.owner,revision:++e.revision,events:Object.freeze([...s])});this._setTransientCause(e,n),this._dispatchProducer(e,n,t)}notifyNode(e,s,t={}){var l,_,b,E,g,z;if(this._disposed||!e._isPublished()||((l=this._runtimeSubscribers)==null?void 0:l.first)===void 0&&((b=(_=this._selfSubscribers)==null?void 0:_.get(e))==null?void 0:b.first)===void 0&&this._subtreeSubscribers===void 0)return;const i=t.oldAncestors===void 0&&t.newAncestors===void 0?this._subtreeSubscribers===void 0?C:D(e):void 0,n=t.oldAncestors??i??C,o=t.newAncestors??i??C;if(!this._nodeHasDemand(e,n,o))return;const r=this._nodeRevisions??(this._nodeRevisions=new WeakMap),a=(r.get(e)??0)+1;r.set(e,a);const c=Object.freeze({kind:s,source:e,sourceOwner:e,revision:a,...t.metadata===void 0?{}:{metadata:t.metadata},...t.structure===void 0?{}:{structure:Object.freeze({...t.structure})}}),h=s==="structure"?e:this._nodeTouchKey(e);if(this._dispatch((E=this._selfSubscribers)==null?void 0:E.get(e),c,h),i!==void 0)for(const y of i)this._dispatch((g=this._subtreeSubscribers)==null?void 0:g.get(y),c,h);else{const y=new Set;for(const A of n)y.add(A);for(const A of o)y.add(A);for(const A of y)this._dispatch((z=this._subtreeSubscribers)==null?void 0:z.get(A),c,h)}this._dispatch(this._runtimeSubscribers,c,h)}createAggregate(e,s){if(this._assertOwner(e),s.length===0)throw new TypeError("[Raph] Aggregate requires at least one source.");this._validateAggregateSources(s,new Set);for(const o of s)this._assertSourceVisibleTo(e,o,new Set);const t=p._create(e,s),i=[],n=new Set;try{for(const o of t.sources){const r=L(o);if(r===void 0||n.has(r))continue;n.add(r);const a=this._linkSourceCleanup(o,()=>t._removeMember(r));a!==void 0&&i.push(a)}return t._bindMembers(i),t._bindOwner(e._adoptResource(()=>t._disposeOwned())),t}catch(o){const r=[];for(let a=i.length-1;a>=0;a--)try{i[a]()}catch(c){r.push(c)}throw r.length!==0?new AggregateError([o,...r],"[Raph] Aggregate registration and rollback failed."):o}}subscribe(e,s,t){this._assertAlive();const i=[],n=new WeakMap;try{this._subscribeOne(e,s,t,i,n,new Set)}catch(r){const a=[];for(let c=i.length-1;c>=0;c--)try{i[c]()}catch(h){a.push(h)}throw a.length!==0?new AggregateError([r,...a],"[Raph] Granular subscription registration and rollback failed."):r}let o=!0;return()=>{if(!o)return;o=!1;const r=[];for(let a=i.length-1;a>=0;a--)try{i[a]()}catch(c){r.push(c)}v.throwDisposalErrors(r,"[Raph] Granular subscription disposal failed.")}}assertSubscriptionAllowed(e,s){this._assertOwner(e),this._assertSourceVisibleTo(e,s,new Set)}assertReparentAllowed(e,s){const t=this._implicitProducers;if(t!==void 0)for(const i of t){const n=i.owner;if(!f(n))continue;const o=i.implicitConsumers;if(o!==void 0){for(const r of o.keys())if(j(r,e)&&!j(n,e)&&!K(n,s))throw new Error(`[Raph] Cannot reparent "${e.id}": implicit dependency from "${r.id}" to "${n.id}" would become invalid; use watch().`)}}}releaseNode(e){var t,i;this._releaseGranule(this._selfSubscribers,e),this._releaseGranule(this._subtreeSubscribers,e);const s=(t=this._nodeMemberships)==null?void 0:t.get(e);if(s!==void 0){this._nodeMemberships.delete(e);try{this._releaseCleanupList(s)}finally{((i=this._nodeMemberships)==null?void 0:i.size)===0&&(this._nodeMemberships=void 0)}}}dispose(){var s;if(this._disposed)return;this._disposed=!0;const e=[];if(this.clearTransientCauses(),this._implicitProducers!==void 0){for(const t of this._implicitProducers)t.implicitConsumers=void 0;this._implicitProducers.clear(),this._implicitProducers=void 0}try{this._releaseRuntimeActivations()}catch(t){e.push(t)}if((s=this._runtimeActivationProducers)==null||s.clear(),this._runtimeActivationProducers=void 0,this._runtimeSubscriberCount=0,this._selfSubscribers!==void 0)for(const t of[...this._selfSubscribers.keys()])this._releaseGranule(this._selfSubscribers,t);if(this._subtreeSubscribers!==void 0)for(const t of[...this._subtreeSubscribers.keys()])this._releaseGranule(this._subtreeSubscribers,t);if(this._nodeMemberships!==void 0){for(const t of this._nodeMemberships.values())this._releaseCleanupList(t,!1);this._nodeMemberships.clear(),this._nodeMemberships=void 0}if(this._runtimeSubscribers!==void 0){try{this._releaseWorkList(this._runtimeSubscribers)}catch(t){e.push(t)}this._runtimeSubscribers=void 0}v.throwDisposalErrors(e,"[Raph] Work graph disposal failed.")}_disposeProducer(e,s=!1){var r,a;if(e.disposed)return;const t=e.source,i=!f(e.owner)||e.owner._isPublished();let n;if(t!==void 0&&i&&(s||this._producerHasDemand(e))){const c=Object.freeze({kind:"structure",source:t,sourceOwner:e.owner,revision:++e.revision,metadata:Object.freeze({disposed:!0})});this._setTransientCause(e,c);try{this._dispatchProducer(e,c,!0,t)}catch(h){(n??(n=[])).push(h)}}e.disposed=!0;const o=e.runtimeActivation;e.runtimeActivation=void 0,(r=this._runtimeActivationProducers)==null||r.delete(e),((a=this._runtimeActivationProducers)==null?void 0:a.size)===0&&(this._runtimeActivationProducers=void 0);try{o==null||o()}catch(c){(n??(n=[])).push(c)}if(e.memberships!==void 0){try{this._releaseCleanupList(e.memberships)}catch(c){(n??(n=[])).push(c)}e.memberships=void 0}if(e.alias!==void 0&&m.delete(e.alias),e.alias=void 0,e.subscribers!==void 0)try{this._releaseWorkList(e.subscribers)}catch(c){(n??(n=[])).push(c)}finally{e.subscribers=void 0}e.activate=void 0,e.source=void 0,n!==void 0&&v.throwDisposalErrors(n,"[Raph] Runtime producer disposal failed.")}_dispatchProducer(e,s,t=!0,i=e){var o,r;this._dispatch(e.subscribers,s,i,t);const n=e.owner;if(f(n)){this._dispatch((o=this._selfSubscribers)==null?void 0:o.get(n),s,i,t);for(const a of D(n))this._dispatch((r=this._subtreeSubscribers)==null?void 0:r.get(a),s,i,t)}e.includeRuntime&&this._dispatch(this._runtimeSubscribers,s,i,t)}_dispatchProducerLazily(e,s,t,i,n,o){var h;const r=e.owner;let a;if(f(r)){const l=(h=this._selfSubscribers)==null?void 0:h.get(r);(l==null?void 0:l.first)!==void 0&&(a=this._createProducerCause(e,s,t,i,o),this._dispatch(l,a,e,n));const _=this._subtreeSubscribers;if(_!==void 0)for(let b=r;b!==null;){const E=b.parent,g=_.get(b);(g==null?void 0:g.first)!==void 0&&(a??(a=this._createProducerCause(e,s,t,i,o)),this._dispatch(g,a,e,n)),b=E}}const c=e.includeRuntime?this._runtimeSubscribers:void 0;(c==null?void 0:c.first)!==void 0&&(a??(a=this._createProducerCause(e,s,t,i,o)),this._dispatch(c,a,e,n))}_createProducerCause(e,s,t,i,n){const o=++e.revision,r=Object.freeze(n?i===void 0?{kind:e.kind,source:e.source,sourceOwner:e.owner,revision:o,previous:s,value:t}:{kind:e.kind,source:e.source,sourceOwner:e.owner,revision:o,previous:s,value:t,events:Object.freeze([...i])}:i===void 0?{kind:e.kind,source:e.source,sourceOwner:e.owner,revision:o}:{kind:e.kind,source:e.source,sourceOwner:e.owner,revision:o,events:Object.freeze([...i])});return this._setTransientCause(e,r),r}_retainRuntimeSubscriber(){var t;if(this._runtimeSubscriberCount++,this._runtimeSubscriberCount!==1)return;const e=[],s=[];try{for(const i of this._runtimeActivationProducers??[])i.disposed||i.runtimeActivation!==void 0||(i.runtimeActivation=x((t=i.activate)==null?void 0:t.call(i)),e.push(i));return}catch(i){s.push(i)}this._runtimeSubscriberCount=0;for(let i=e.length-1;i>=0;i--){const n=e[i],o=n.runtimeActivation;n.runtimeActivation=void 0;try{o==null||o()}catch(r){s.push(r)}}throw s.length===1?s[0]:new AggregateError(s,"[Raph] Runtime granule activation failed and rollback was incomplete.")}_releaseRuntimeSubscriber(){this._runtimeSubscriberCount!==0&&(this._runtimeSubscriberCount--,this._runtimeSubscriberCount===0&&this._releaseRuntimeActivations())}_releaseRuntimeActivations(){const e=[];for(const s of this._runtimeActivationProducers??[]){const t=s.runtimeActivation;s.runtimeActivation=void 0;try{t==null||t()}catch(i){e.push(i)}}v.throwDisposalErrors(e,"[Raph] Runtime granule activation cleanup failed.")}_linkImplicitDependency(e,s){const t=e.owner,i=s;if(e.disposed||i.runtime!==this._runtime||!f(t)||!f(i)||t===i)return;const n=e.implicitConsumers??(e.implicitConsumers=new Map);n.set(i,(n.get(i)??0)+1),(this._implicitProducers??(this._implicitProducers=new Set)).add(e);let r=!0;return()=>{var c,h,l;if(!r)return;r=!1;const a=(c=e.implicitConsumers)==null?void 0:c.get(i);if(a!==void 0){if(a>1){e.implicitConsumers.set(i,a-1);return}e.implicitConsumers.delete(i),e.implicitConsumers.size===0&&(e.implicitConsumers=void 0,(h=this._implicitProducers)==null||h.delete(e),((l=this._implicitProducers)==null?void 0:l.size)===0&&(this._implicitProducers=void 0))}}}_subscribeOne(e,s,t,i,n,o){if(s!==void 0&&!f(e))throw new TypeError("[Raph] watch include applies only to a bare RaphNode source.");if(e instanceof p){if(e._assertAlive(),this._assertRuntime(e.runtime),o.has(e))throw new TypeError("[Raph] Aggregate sources cannot contain a cycle.");o.add(e);const r=[];try{for(const a of e.sources)this._subscribeOne(a,void 0,t,r,n,o);i.push(e._linkSubscription(a=>{const c=[];if(a!==void 0)try{t(a,e,!0)}catch(h){c.push(h)}for(let h=r.length-1;h>=0;h--)try{r[h]()}catch(l){c.push(l)}v.throwDisposalErrors(c,"[Raph] Aggregate member subscription disposal failed.")}))}catch(a){const c=[];for(let h=r.length-1;h>=0;h--)try{r[h]()}catch(l){c.push(l)}throw o.delete(e),c.length!==0?new AggregateError([a,...c],"[Raph] Aggregate subscription registration and rollback failed."):a}o.delete(e);return}if(R(e)){this._subscribeNode(e.source,e.include,t,i,n);return}if(f(e)){this._subscribeNode(e,s??"self",t,i,n);return}if(P(e)){this._assertRuntime(e),i.push(k(n,e,()=>{const r=this._runtimeSubscribers??(this._runtimeSubscribers={}),a={kind:"runtime",sink:t,source:e};this._appendWorkEdge(r,a);try{this._retainRuntimeSubscriber()}catch(c){throw a.source=void 0,this._detachWorkEdge(r,a),r.first===void 0&&(this._runtimeSubscribers=void 0),c}return()=>{var c;a.source!==void 0&&(a.source=void 0,this._detachWorkEdge(this._runtimeSubscribers,a),((c=this._runtimeSubscribers)==null?void 0:c.first)===void 0&&(this._runtimeSubscribers=void 0),this._releaseRuntimeSubscriber())}}));return}if(w(e)){const r=m.get(e);if(r!==void 0){if(this._assertRuntime(r.runtime),r.disposed)throw new S.RaphDisposedError("[Raph] Producer is disposed.");i.push(k(n,r,()=>{var h;const a=r.subscribers??(r.subscribers={}),c={kind:"producer",sink:t,source:r};this._appendWorkEdge(a,c);try{c.activationRelease=x((h=r.activate)==null?void 0:h.call(r))}catch(l){throw c.source=void 0,this._detachWorkEdge(a,c),a.first===void 0&&(r.subscribers=void 0),l}return()=>{var b;const l=c.activationRelease;c.activationRelease=void 0;const _=c.source;O(_)&&(c.source=void 0,this._detachWorkEdge(_.subscribers,c),((b=_.subscribers)==null?void 0:b.first)===void 0&&(_.subscribers=void 0)),l==null||l()}}));return}}throw new TypeError("[Raph] Unsupported or ownerless granular watch source.")}_subscribeNode(e,s,t,i,n){if(this._assertRuntime(e.runtime),e._assertAlive(),s!=="self"&&s!=="subtree")throw new TypeError(`[Raph] Unsupported node include mode "${String(s)}".`);const o=s==="self"?e:e._subtreeSourceIdentity;i.push(k(n,o,()=>{const r=s==="self"?this._selfSubscribers??(this._selfSubscribers=new Map):this._subtreeSubscribers??(this._subtreeSubscribers=new Map);let a=r.get(e);a===void 0&&(a={},r.set(e,a));const c={kind:s,sink:t,source:e};return this._appendWorkEdge(a,c),this._createNodeEdgeRelease(c)}))}_createNodeEdgeRelease(e){return()=>{const s=e.source;if(!f(s))return;e.source=void 0;const t=e.kind==="self"?this._selfSubscribers:this._subtreeSubscribers,i=t==null?void 0:t.get(s);this._detachWorkEdge(i,e),(i==null?void 0:i.first)===void 0&&(t==null||t.delete(s),(t==null?void 0:t.size)===0&&(e.kind==="self"?this._selfSubscribers=void 0:this._subtreeSubscribers=void 0))}}_linkSourceCleanup(e,s){const t=F(e);if(t===void 0)return;const i={cleanup:s,source:t};if(O(t)){const n=t.memberships??(t.memberships={});W(n,i)}else if(t instanceof p)t._linkDependent(i);else{const n=this._nodeMemberships??(this._nodeMemberships=new Map);let o=n.get(t);o===void 0&&(o={},n.set(t,o)),W(o,i)}return()=>this._detachCleanupEdge(i)}_detachCleanupEdge(e){var i,n,o,r;const s=e.source;if(s===void 0)return;if(e.source=void 0,e.cleanup=void 0,O(s)){N(s.memberships,e),((i=s.memberships)==null?void 0:i.first)===void 0&&(s.memberships=void 0);return}if(s instanceof p){s._detachDependent(e);return}const t=(n=this._nodeMemberships)==null?void 0:n.get(s);N(t,e),(t==null?void 0:t.first)===void 0&&((o=this._nodeMemberships)==null||o.delete(s),((r=this._nodeMemberships)==null?void 0:r.size)===0&&(this._nodeMemberships=void 0))}_releaseCleanupList(e,s=!0){let t=e.first;e.first=e.last=void 0;const i=[];for(;t!==void 0;){const n=t.next,o=t.cleanup;if(t.source=void 0,t.cleanup=void 0,t.previous=t.next=void 0,s)try{o==null||o()}catch(r){i.push(r)}t=n}v.throwDisposalErrors(i,"[Raph] Aggregate membership cleanup failed.")}_validateAggregateSources(e,s){for(const t of e){if(Array.isArray(t))throw new TypeError("[Raph] Nested source arrays are not supported; create a named aggregate.");if(t instanceof p){if(t._assertAlive(),this._assertRuntime(t.runtime),s.has(t))throw new TypeError("[Raph] Aggregate sources cannot contain a cycle.");s.add(t),this._validateAggregateSources(t.sources,s),s.delete(t)}else if(R(t)){if(this._assertRuntime(t.source.runtime),t.source._assertAlive(),t.include!=="self"&&t.include!=="subtree")throw new TypeError(`[Raph] Unsupported node include mode "${String(t.include)}".`)}else if(f(t))this._assertRuntime(t.runtime),t._assertAlive();else if(P(t))this._assertRuntime(t);else if(w(t)){const i=m.get(t);if(i===void 0||i.disposed)throw new S.RaphDisposedError("[Raph] Aggregate producer is disposed or ownerless.");this._assertRuntime(i.runtime)}else throw new TypeError("[Raph] Unsupported aggregate source.")}}_assertSourceVisibleTo(e,s,t){if(s instanceof p){if(this._assertProvisionalOwnerAccess(e,s.owner),t.has(s))return;t.add(s);for(const n of s.sources)this._assertSourceVisibleTo(e,n,t);t.delete(s);return}if(R(s)){this._assertProvisionalOwnerAccess(e,s.source);return}if(f(s)){this._assertProvisionalOwnerAccess(e,s);return}if(P(s)||!w(s))return;const i=m.get(s);i!==void 0&&this._assertProvisionalOwnerAccess(e,i.owner)}_assertProvisionalOwnerAccess(e,s){if(!(!f(s)||s._isPublished())&&!(f(e)&&!e._isPublished()&&T(e)===T(s)))throw new Error(`[Raph] Owner "${e.id}" cannot subscribe to provisional source owner "${s.id}".`)}_dispatch(e,s,t,i=!0){let n=e==null?void 0:e.first;if(n===void 0)return;const o=e.last;this._dispatchDepth++;try{for(;n!==void 0;){const r=n.next;if(n.source!==void 0&&n.sink(s,t,i),n===o)break;n=r}}finally{if(--this._dispatchDepth===0&&this._detachedEdges!==void 0){for(const r of this._detachedEdges)r.previous=r.next=void 0;this._detachedEdges=void 0}}}_appendWorkEdge(e,s){s.previous=e.last,e.last===void 0?e.first=s:e.last.next=s,e.last=s}_detachWorkEdge(e,s){e!==void 0&&(s.previous===void 0?e.first=s.next:s.previous.next=s.next,s.next===void 0?e.last=s.previous:s.next.previous=s.previous,this._dispatchDepth===0?s.previous=s.next=void 0:(this._detachedEdges??(this._detachedEdges=[])).push(s))}_releaseWorkList(e){let s=e.first;const t=[];for(;s!==void 0;){const i=s.next,n=s.activationRelease;s.activationRelease=void 0,s.source=void 0,this._detachWorkEdge(e,s);try{n==null||n()}catch(o){t.push(o)}s=i}v.throwDisposalErrors(t,"[Raph] Granular source activation cleanup failed.")}_releaseGranule(e,s){const t=e==null?void 0:e.get(s);t!==void 0&&(e.delete(s),this._releaseWorkList(t),e.size===0&&(e===this._selfSubscribers&&(this._selfSubscribers=void 0),e===this._subtreeSubscribers&&(this._subtreeSubscribers=void 0)))}_setTransientCause(e,s){e.lastCause===void 0&&(e.transientNext=this._transientProducers,this._transientProducers=e),e.lastCause=s}_producerHasDemand(e){var t,i,n,o,r;if(f(e.owner)&&!e.owner._isPublished())return!1;if(((t=e.subscribers)==null?void 0:t.first)!==void 0||e.includeRuntime&&((i=this._runtimeSubscribers)==null?void 0:i.first)!==void 0)return!0;const s=e.owner;if(!f(s))return!1;if(((o=(n=this._selfSubscribers)==null?void 0:n.get(s))==null?void 0:o.first)!==void 0)return!0;if(this._subtreeSubscribers===void 0)return!1;for(const a of D(s))if(((r=this._subtreeSubscribers.get(a))==null?void 0:r.first)!==void 0)return!0;return!1}_nodeTouchKey(e){const s=this._nodeTouchKeys??(this._nodeTouchKeys=new WeakMap);let t=s.get(e);return t===void 0&&(t=Object.freeze({}),s.set(e,t)),t}_nodeHasDemand(e,s,t){var i,n,o,r,a;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)return!0;if(this._subtreeSubscribers===void 0)return!1;for(const c of s)if(((r=this._subtreeSubscribers.get(c))==null?void 0:r.first)!==void 0)return!0;for(const c of t)if(((a=this._subtreeSubscribers.get(c))==null?void 0:a.first)!==void 0)return!0;return!1}_assertOwner(e){this._assertRuntime(e.runtime),e._assertAlive()}_assertRuntime(e){if(e!==this._runtime)throw new S.RaphCrossRuntimeError("[Raph] Granular source belongs to another runtime.")}_assertAlive(){if(this._disposed)throw new S.RaphDisposedError("[Raph] Work graph is disposed.")}}function T(u){let e=u;for(;e.parent!==null&&!e.parent._isPublished();)e=e.parent;return e}function D(u){const e=[];for(let s=u;s!==null;s=s.parent)e.push(s);return e}function j(u,e){for(let s=u;s!==null;s=s.parent)if(s===e)return!0;return!1}function K(u,e){for(let s=e;s!==null;s=s.parent)if(s===u)return!0;return!1}function q(u){return Object.freeze(u.map(e=>R(e)?Object.freeze({source:e.source,include:e.include}):e))}function L(u){return u instanceof p?u:R(u)?u.source:f(u)||P(u)?u:w(u)?m.get(u):void 0}function F(u){if(u instanceof p)return u;if(R(u))return u.source;if(f(u))return u;if(!P(u))return w(u)?m.get(u):void 0}function W(u,e){e.previous=u.last,u.last===void 0?u.first=e:u.last.next=e,u.last=e}function I(u){var e;(e=u.aggregate)==null||e._detachSubscription(u)}function N(u,e){u!==void 0&&(e.previous===void 0?u.first=e.next:e.previous.next=e.next,e.next===void 0?u.last=e.previous:e.next.previous=e.previous,e.previous=e.next=void 0)}function k(u,e,s){let t=u.get(e);t===void 0&&(t={count:0,dispose:s()},u.set(e,t)),t.count++;let i=!0;return()=>{if(!i||(i=!1,--t.count!==0))return;const n=t.dispose;t.dispose=Y,n()}}function Y(){}function x(u){return typeof u=="function"?u:void 0}function O(u){return typeof u=="object"&&u!==null&&u[G]===!0}function R(u){return w(u)&&"source"in u&&f(u.source)&&"include"in u}function f(u){return w(u)&&"_subtreeSourceIdentity"in u&&"runtime"in u&&"children"in u}function P(u){return w(u)&&"rootScope"in u&&"definePhases"in u&&"configuration"in u}function w(u){return typeof u=="object"&&u!==null}exports.RaphAggregate=p;exports.RaphWorkGraph=H;
|