@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,700 +1,979 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var T = (p, e, t) => e in p ? E(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t;
|
|
3
|
+
var u = (p, e, t) => T(p, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { parseDataPath as P } from "../path/data-path.utils.js";
|
|
5
|
+
import { DataPath as x } from "../path/DataPath.js";
|
|
6
|
+
import { RaphMeta as W } from "../path/meta/RaphMeta.js";
|
|
7
|
+
import { RaphKernel as G } from "../path/RaphKernel.js";
|
|
8
|
+
import { configureReactiveObjectPolicy as O, disposeReactiveObjectContext as L } from "../reactivity/reactive-object.js";
|
|
9
|
+
import { RaphDebugController as M, createOwnerSnapshot as b, createOwnerTree as R } from "./diagnostics/RaphDebug.js";
|
|
10
|
+
import { RaphDisposedError as A, RaphCrossRuntimeError as k, RaphActionError as B } from "./errors.js";
|
|
11
|
+
import { parentGraph as F } from "./ownership/parentGraph.js";
|
|
12
|
+
import { RaphNode as g, createProvisionalNode as q } from "./ownership/RaphNode.js";
|
|
13
|
+
import { RaphScope as D } from "./ownership/RaphScope.js";
|
|
14
|
+
import { throwDisposalErrors as y } from "./ownership/throwDisposalErrors.js";
|
|
15
|
+
import { RaphSchedulerType as w } from "./phases/phase.types.js";
|
|
16
|
+
import { RaphFrameLoop as I } from "./phases/RaphFrameLoop.js";
|
|
17
|
+
import { RaphPhasePipeline as H } from "./phases/RaphPhasePipeline.js";
|
|
18
|
+
import { PathHandle as z } from "./reactivity/PathHandle.js";
|
|
19
|
+
import { RaphMetaSource as N } from "./reactivity/RaphMetaSource.js";
|
|
20
|
+
import { RaphWorkGraph as $ } from "./reactivity/RaphWorkGraph.js";
|
|
21
|
+
import { RuntimeReactivity as j } from "./reactivity/RuntimeReactivity.js";
|
|
22
|
+
import { RuntimeWatch as U } from "./reactivity/RuntimeWatch.js";
|
|
20
23
|
const v = class v {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!I(i))
|
|
24
|
+
constructor(e = {}) {
|
|
25
|
+
u(this, "mode", "runtime");
|
|
26
|
+
u(this, "configuration");
|
|
27
|
+
u(this, "rootScope");
|
|
28
|
+
u(this, "root");
|
|
29
|
+
u(this, "frameTick");
|
|
30
|
+
u(this, "_reactivity");
|
|
31
|
+
u(this, "_signalLifecycle");
|
|
32
|
+
u(this, "_workGraph");
|
|
33
|
+
u(this, "_frameTickWritable");
|
|
34
|
+
u(this, "_setFrameTick");
|
|
35
|
+
u(this, "_pathHandles");
|
|
36
|
+
u(this, "_meta");
|
|
37
|
+
u(this, "_phases");
|
|
38
|
+
u(this, "_frameLoop");
|
|
39
|
+
u(this, "_debug");
|
|
40
|
+
u(this, "_debugController");
|
|
41
|
+
u(this, "_parentGraph");
|
|
42
|
+
u(this, "_owners", /* @__PURE__ */ new Set());
|
|
43
|
+
u(this, "_batchDepth", 0);
|
|
44
|
+
u(this, "_mutationDepth", 0);
|
|
45
|
+
u(this, "_kernelBatchDepth", 0);
|
|
46
|
+
u(this, "_ownerDisposalDepth", 0);
|
|
47
|
+
u(this, "_actionDepth", 0);
|
|
48
|
+
u(this, "_actionCounter", 0);
|
|
49
|
+
u(this, "_traceCauseStack", []);
|
|
50
|
+
u(this, "_phaseTraceOperations");
|
|
51
|
+
u(this, "_executionRequested", !1);
|
|
52
|
+
u(this, "_disposed", !1);
|
|
53
|
+
u(this, "_disposedListeners", /* @__PURE__ */ new Set());
|
|
54
|
+
const t = e.id ?? `runtime-${v._runtimeCounter++}`, r = e.adaptiveDependencyIndex ?? !1, s = e.enforceActions ?? !1, i = e.scheduler ?? w.Sync;
|
|
55
|
+
if (!K(i))
|
|
54
56
|
throw new Error(`[Raph] Unsupported scheduler "${String(i)}".`);
|
|
55
|
-
const
|
|
56
|
-
this.configuration = Object.freeze({
|
|
57
|
-
|
|
57
|
+
const o = e.kernel ?? new G({ id: `${t}-kernel` });
|
|
58
|
+
this.configuration = Object.freeze({
|
|
59
|
+
adaptiveDependencyIndex: r,
|
|
60
|
+
...e.debug === void 0 ? {} : { debug: e.debug },
|
|
61
|
+
id: t,
|
|
62
|
+
kernel: o,
|
|
63
|
+
enforceActions: s,
|
|
64
|
+
scheduler: i
|
|
65
|
+
}), this._debugController = new M(e.debug);
|
|
66
|
+
const c = `[Raph] Runtime "${t}" is disposed.`;
|
|
58
67
|
this._signalLifecycle = {
|
|
59
68
|
owner: this,
|
|
60
|
-
runWrite: (
|
|
69
|
+
runWrite: (d) => this._runWrite(d),
|
|
70
|
+
assertDependencyAllowed: (d, l) => {
|
|
71
|
+
this._assertImplicitDependency(d, l);
|
|
72
|
+
},
|
|
61
73
|
...s ? { assertWriteAllowed: () => this._assertWriteAllowed() } : {},
|
|
62
74
|
throwDisposed: () => {
|
|
63
|
-
throw new
|
|
75
|
+
throw new A(c);
|
|
76
|
+
},
|
|
77
|
+
throwCrossRuntime: (d) => this._throwCrossRuntime(d)
|
|
78
|
+
}, this._reactivity = new j(this._signalLifecycle, { adaptiveDependencyIndex: r }), this._workGraph = new $(this), o._attachRuntime(this), this.rootScope = new D(`${t}:root-scope`, this), this.root = new g(null, { id: `${t}:root` }, this), O(this._reactivity, {
|
|
79
|
+
owner: this,
|
|
80
|
+
assertRead: () => {
|
|
81
|
+
this._assertAlive();
|
|
82
|
+
const d = this._reactivity.getActiveOwner();
|
|
83
|
+
d !== void 0 && d !== this && this._throwCrossRuntime(d);
|
|
84
|
+
const l = this._reactivity.getActiveConsumerOwner();
|
|
85
|
+
l !== void 0 && this._assertImplicitDependency(this.rootScope, l);
|
|
64
86
|
},
|
|
65
|
-
|
|
66
|
-
|
|
87
|
+
assertWrite: () => this._assertWriteAllowed(),
|
|
88
|
+
runWrite: (d) => this._runWrite(d),
|
|
89
|
+
throwForeign: (d) => {
|
|
90
|
+
throw d instanceof v && this._throwCrossRuntime(d), new k(
|
|
91
|
+
"[Raph] Reactive object belongs to another reactivity engine."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const n = this._workGraph.createProducer(this.rootScope, "frame", {
|
|
96
|
+
includeRuntime: !1
|
|
97
|
+
});
|
|
98
|
+
let a;
|
|
99
|
+
const h = this._reactivity.signalForOwner(
|
|
100
|
+
0,
|
|
101
|
+
this.rootScope,
|
|
102
|
+
this._workGraph.producerHooks(n),
|
|
103
|
+
(d) => {
|
|
104
|
+
a = d;
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
this._setFrameTick = (d) => this._runWrite(() => a(d)), this._frameTickWritable = h, this.frameTick = this._workGraph.attachProducer(n, {
|
|
108
|
+
get: h.get,
|
|
109
|
+
peek: h.peek
|
|
110
|
+
});
|
|
67
111
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Возвращает внутренний runtime reactivity adapter.
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
112
|
+
/** @internal */
|
|
72
113
|
_getReactivity() {
|
|
73
114
|
return this._reactivity;
|
|
74
115
|
}
|
|
75
116
|
/**
|
|
76
|
-
* Возвращает
|
|
117
|
+
* Возвращает внутренний WorkGraph для optional execution layers.
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
77
120
|
*/
|
|
121
|
+
_getWorkGraph() {
|
|
122
|
+
return this._workGraph;
|
|
123
|
+
}
|
|
78
124
|
get id() {
|
|
79
125
|
return this.configuration.id;
|
|
80
126
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Возвращает data/meta Kernel этого runtime.
|
|
83
|
-
*/
|
|
84
127
|
get kernel() {
|
|
85
128
|
return this.configuration.kernel;
|
|
86
129
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Возвращает лениво созданный runtime-owned metadata facade.
|
|
89
|
-
*/
|
|
90
|
-
get meta() {
|
|
91
|
-
return this._assertAlive(), this._meta ?? (this._meta = new M(this.kernel, {
|
|
92
|
-
assertReadable: () => this._assertAlive(),
|
|
93
|
-
assertWritable: () => this._assertWriteAllowed(),
|
|
94
|
-
runWrite: (t, e) => this._runWrite(t, e),
|
|
95
|
-
watch: (t, e, s) => this._own(
|
|
96
|
-
this._watchMeta(t, e, s),
|
|
97
|
-
this.rootScope
|
|
98
|
-
)
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Показывает, освобождён ли runtime.
|
|
103
|
-
*/
|
|
104
130
|
get disposed() {
|
|
105
131
|
return this._disposed;
|
|
106
132
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Возвращает лениво созданное read-only представление ownership graph.
|
|
109
|
-
*/
|
|
110
133
|
get graph() {
|
|
111
|
-
return this._parentGraph ?? (this._parentGraph =
|
|
134
|
+
return this._parentGraph ?? (this._parentGraph = F());
|
|
112
135
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Показывает, удерживается ли автоматический frame-loop.
|
|
115
|
-
*/
|
|
116
136
|
get loopEnabled() {
|
|
117
|
-
var
|
|
118
|
-
return ((
|
|
137
|
+
var e;
|
|
138
|
+
return ((e = this._frameLoop) == null ? void 0 : e.running) ?? !1;
|
|
119
139
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Возвращает последний frame context runtime pipeline.
|
|
122
|
-
*/
|
|
123
140
|
get frame() {
|
|
124
|
-
var
|
|
125
|
-
return ((
|
|
141
|
+
var e;
|
|
142
|
+
return ((e = this._phases) == null ? void 0 : e.frame) ?? { now: 0, delta: 0, elapsed: 0, frame: 0 };
|
|
126
143
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Возвращает текущее определение runtime phases.
|
|
129
|
-
*/
|
|
130
144
|
get phases() {
|
|
131
|
-
var
|
|
132
|
-
return ((
|
|
145
|
+
var e;
|
|
146
|
+
return ((e = this._phases) == null ? void 0 : e.phases) ?? [];
|
|
147
|
+
}
|
|
148
|
+
/** Runtime metadata facade intentionally excludes unphased watch(). */
|
|
149
|
+
get meta() {
|
|
150
|
+
if (this._assertAlive(), this._meta !== void 0)
|
|
151
|
+
return this._meta;
|
|
152
|
+
const e = new W(this.kernel, {
|
|
153
|
+
assertReadable: () => this._assertAlive(),
|
|
154
|
+
assertWritable: () => this._assertWriteAllowed(),
|
|
155
|
+
runWrite: (t, r) => this._runWrite(t, r)
|
|
156
|
+
});
|
|
157
|
+
return this._meta = Object.freeze({
|
|
158
|
+
delete: e.delete.bind(e),
|
|
159
|
+
get: e.get.bind(e),
|
|
160
|
+
has: e.has.bind(e),
|
|
161
|
+
merge: e.merge.bind(e),
|
|
162
|
+
set: e.set.bind(e)
|
|
163
|
+
});
|
|
133
164
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Формирует диагностический снимок materialized derived registry.
|
|
136
|
-
*/
|
|
137
165
|
getDerivedSnapshot() {
|
|
138
166
|
return this.kernel.getDerivedSnapshot();
|
|
139
167
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Возвращает лениво созданную read-only диагностику runtime и ownership tree.
|
|
142
|
-
*/
|
|
143
168
|
get debug() {
|
|
144
169
|
return this._debug ?? (this._debug = Object.freeze({
|
|
145
170
|
snapshot: () => this._createDebugSnapshot(),
|
|
146
|
-
getTree: () =>
|
|
171
|
+
getTree: () => this._createDebugTree(),
|
|
172
|
+
stats: () => this._createDebugStats(),
|
|
173
|
+
trace: this._debugController.trace,
|
|
174
|
+
machines: this._debugController.machines
|
|
147
175
|
}));
|
|
148
176
|
}
|
|
177
|
+
signal(e, t = this.rootScope) {
|
|
178
|
+
this._assertOwnerRuntime(t);
|
|
179
|
+
const r = this._workGraph.createProducer(t), s = this._reactivity.signalForOwner(
|
|
180
|
+
e,
|
|
181
|
+
t,
|
|
182
|
+
this._workGraph.producerHooks(r)
|
|
183
|
+
);
|
|
184
|
+
return this._workGraph.attachProducer(r, s);
|
|
185
|
+
}
|
|
149
186
|
/**
|
|
150
|
-
*
|
|
187
|
+
* Creates a deep reactive Proxy owned by this Runtime root scope.
|
|
188
|
+
* Property dependencies use the intrusive graph directly and intentionally
|
|
189
|
+
* do not create per-property WorkGraph producers or phase causes.
|
|
151
190
|
*/
|
|
152
|
-
|
|
153
|
-
return this.
|
|
191
|
+
reactive(e) {
|
|
192
|
+
return this._assertAlive(), this._reactivity.reactive(e);
|
|
154
193
|
}
|
|
155
|
-
computed(
|
|
194
|
+
computed(e, t = this.rootScope) {
|
|
195
|
+
this._assertOwnerRuntime(t);
|
|
196
|
+
const r = this._workGraph.createProducer(t), s = typeof e == "function" ? e : e.get, i = this._reactivity.computedForOwner(
|
|
197
|
+
() => this._runTracked(t, s),
|
|
198
|
+
t,
|
|
199
|
+
this._workGraph.producerHooks(r)
|
|
200
|
+
);
|
|
201
|
+
if (this._workGraph.setProducerActivation(r, () => {
|
|
202
|
+
i.peek();
|
|
203
|
+
}), typeof e == "function")
|
|
204
|
+
return this._workGraph.attachProducer(r, i);
|
|
205
|
+
const o = this._attachWritableComputed(i, e.set, t);
|
|
206
|
+
return this._workGraph.attachProducer(r, o);
|
|
207
|
+
}
|
|
208
|
+
/** Low-level adapter form. Prefer consumer.effect(). */
|
|
209
|
+
effect(e, t, r, s = {}) {
|
|
210
|
+
return this._effectRegistration(e, t, r, s).dispose;
|
|
211
|
+
}
|
|
212
|
+
/** @internal */
|
|
213
|
+
_effectRegistration(e, t, r, s = {}, i = !1) {
|
|
156
214
|
this._assertOwnerRuntime(e);
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
215
|
+
const o = this._validatePhaseBinding(t, r, s), c = this._execution, n = s.initial ?? "scheduled";
|
|
216
|
+
let a, h, d = !1;
|
|
217
|
+
const l = this._reactivity.withEffectBinding(
|
|
218
|
+
(f) => {
|
|
219
|
+
const _ = c.bindTask(
|
|
220
|
+
o,
|
|
221
|
+
e,
|
|
222
|
+
r,
|
|
223
|
+
s.priority ?? 0,
|
|
224
|
+
f
|
|
225
|
+
);
|
|
226
|
+
return i && _.pause(), a = _;
|
|
227
|
+
},
|
|
228
|
+
() => this._reactivity.effect(
|
|
229
|
+
() => this._runTracked(e, () => {
|
|
230
|
+
const f = r(a.task);
|
|
231
|
+
return typeof f == "function" ? () => this._runUntracked(f) : f;
|
|
232
|
+
}),
|
|
233
|
+
() => {
|
|
234
|
+
h === void 0 ? d = !0 : h();
|
|
235
|
+
}
|
|
236
|
+
)
|
|
160
237
|
);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const l = c.phaseMode(n) === "always" ? this._frameRevision ?? (this._frameRevision = this._reactivity.signal(!1)) : void 0, w = this._reactivity.withEffectBinding(
|
|
175
|
-
(_) => c.bindEffect(
|
|
176
|
-
n,
|
|
177
|
-
p,
|
|
178
|
-
_,
|
|
179
|
-
o instanceof m ? o : void 0
|
|
180
|
-
),
|
|
181
|
-
u,
|
|
182
|
-
() => this._reactivity.effect(() => (l == null || l.get(), this._runTracked(r)))
|
|
183
|
-
);
|
|
184
|
-
return this._own(w, o);
|
|
238
|
+
h = this._own(l, e), d && h(), a.abort = () => h == null ? void 0 : h();
|
|
239
|
+
try {
|
|
240
|
+
n === "sync" ? this.flush() : this._requestExecution();
|
|
241
|
+
} catch (f) {
|
|
242
|
+
try {
|
|
243
|
+
h();
|
|
244
|
+
} catch (_) {
|
|
245
|
+
throw new AggregateError(
|
|
246
|
+
[f, _],
|
|
247
|
+
"[Raph] Phase effect registration and rollback failed."
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
throw f;
|
|
185
251
|
}
|
|
186
|
-
return
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
252
|
+
return {
|
|
253
|
+
dispose: () => h == null ? void 0 : h(),
|
|
254
|
+
pause: () => a == null ? void 0 : a.pause(),
|
|
255
|
+
resume: () => a == null ? void 0 : a.resume()
|
|
256
|
+
};
|
|
190
257
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
258
|
+
/** Low-level adapter form. Prefer consumer.watch(). */
|
|
259
|
+
watch(e, t, r, s, i = {}) {
|
|
260
|
+
return this._watchRegistration(e, t, r, s, i).dispose;
|
|
261
|
+
}
|
|
262
|
+
/** @internal */
|
|
263
|
+
_watchRegistration(e, t, r, s, i = {}, o = !1) {
|
|
264
|
+
this._assertOwnerRuntime(e);
|
|
265
|
+
const c = this._validatePhaseBinding(r, s, i, !0);
|
|
266
|
+
this._workGraph.assertSubscriptionAllowed(e, t);
|
|
267
|
+
let n;
|
|
268
|
+
const a = new U(
|
|
269
|
+
(_) => this._runUntracked(_),
|
|
270
|
+
() => s(n.task)
|
|
271
|
+
);
|
|
272
|
+
n = this._execution.bindTask(
|
|
273
|
+
c,
|
|
274
|
+
e,
|
|
275
|
+
s,
|
|
276
|
+
i.priority ?? 0,
|
|
277
|
+
a.deliver
|
|
278
|
+
), o && n.pause();
|
|
279
|
+
let h;
|
|
280
|
+
try {
|
|
281
|
+
h = this._workGraph.subscribe(
|
|
196
282
|
t,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
283
|
+
i.include,
|
|
284
|
+
n.enqueue
|
|
285
|
+
);
|
|
286
|
+
} catch (_) {
|
|
287
|
+
throw n.dispose(), _;
|
|
288
|
+
}
|
|
289
|
+
const d = () => a.stop(() => {
|
|
290
|
+
const _ = [];
|
|
291
|
+
try {
|
|
292
|
+
h();
|
|
293
|
+
} catch (m) {
|
|
294
|
+
_.push(m);
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
n.dispose();
|
|
298
|
+
} catch (m) {
|
|
299
|
+
_.push(m);
|
|
300
|
+
}
|
|
301
|
+
y(_, "[Raph] Phase watch disposal failed.");
|
|
302
|
+
}), l = this._own(d, e), f = i.initial ?? "scheduled";
|
|
303
|
+
try {
|
|
304
|
+
f !== "none" && n.schedule(), f === "sync" && this.flush();
|
|
305
|
+
} catch (_) {
|
|
306
|
+
try {
|
|
307
|
+
l();
|
|
308
|
+
} catch (m) {
|
|
309
|
+
throw new AggregateError(
|
|
310
|
+
[_, m],
|
|
311
|
+
"[Raph] Phase watch registration and rollback failed."
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
throw _;
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
dispose: l,
|
|
318
|
+
pause: n.pause,
|
|
319
|
+
resume: n.resume
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
aggregate(e, t) {
|
|
323
|
+
return this._assertOwnerRuntime(e), this._workGraph.createAggregate(e, t);
|
|
324
|
+
}
|
|
325
|
+
/** Creates a lazy root-owned metadata event source for phase watches. */
|
|
326
|
+
metaSource(e, t = {}) {
|
|
327
|
+
this._assertAlive(), J(e, t);
|
|
328
|
+
const r = this._workGraph.createProducer(this.rootScope, "path"), s = this._workGraph.producerHooks(r).onDispose, i = N._create(
|
|
329
|
+
this.rootScope,
|
|
330
|
+
e,
|
|
331
|
+
t,
|
|
332
|
+
() => this.kernel._watchMeta(
|
|
333
|
+
i.masks,
|
|
334
|
+
({ events: o }) => this._workGraph.notifyProducerEvents(r, o, !1),
|
|
335
|
+
i.options,
|
|
336
|
+
(o) => {
|
|
337
|
+
o && this._execution.request();
|
|
338
|
+
}
|
|
200
339
|
),
|
|
201
|
-
|
|
340
|
+
() => s(!1)
|
|
202
341
|
);
|
|
342
|
+
i._bindOwner(this.rootScope._adoptResource(() => i._disposeOwned()));
|
|
343
|
+
try {
|
|
344
|
+
return this._workGraph.setProducerActivation(r, () => i._activate(), !0), this._workGraph.attachProducer(r, i), i;
|
|
345
|
+
} catch (o) {
|
|
346
|
+
try {
|
|
347
|
+
i.dispose();
|
|
348
|
+
} catch (c) {
|
|
349
|
+
throw new AggregateError(
|
|
350
|
+
[o, c],
|
|
351
|
+
"[Raph] Meta source activation and rollback failed."
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
throw o;
|
|
355
|
+
}
|
|
203
356
|
}
|
|
204
|
-
|
|
205
|
-
* Возвращает кешируемый runtime-owned handle canonical path.
|
|
206
|
-
*/
|
|
207
|
-
path(t, e = {}) {
|
|
357
|
+
path(e, t = {}) {
|
|
208
358
|
this._assertAlive();
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
return
|
|
212
|
-
const o = new
|
|
359
|
+
const r = P(e, t), s = this._pathHandles ?? (this._pathHandles = /* @__PURE__ */ new Map()), i = s.get(r.canonical);
|
|
360
|
+
if (i !== void 0)
|
|
361
|
+
return i;
|
|
362
|
+
const o = this._workGraph.createProducer(this.rootScope, "path"), c = this._workGraph.producerHooks(o), n = new z(
|
|
213
363
|
this.kernel,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
(
|
|
364
|
+
r,
|
|
365
|
+
t,
|
|
366
|
+
(a) => this._releasePathHandle(a),
|
|
217
367
|
this._reactivity,
|
|
218
368
|
() => this._assertAlive(),
|
|
219
369
|
() => this._assertTrackedRead(),
|
|
220
370
|
this.configuration.enforceActions ? () => this._assertWriteAllowed() : void 0,
|
|
221
|
-
(
|
|
371
|
+
(a) => this._runWrite(a),
|
|
372
|
+
{ token: o, onDispose: c.onDispose },
|
|
373
|
+
({ events: a }, h) => this._workGraph.notifyProducerEvents(o, a, !0, h)
|
|
222
374
|
);
|
|
223
|
-
|
|
375
|
+
try {
|
|
376
|
+
return this._workGraph.setProducerActivation(o, () => n._activate(), !0), this._workGraph.attachProducer(o, n), s.set(r.canonical, n), n;
|
|
377
|
+
} catch (a) {
|
|
378
|
+
let h, d = !1;
|
|
379
|
+
try {
|
|
380
|
+
n.dispose();
|
|
381
|
+
} catch (l) {
|
|
382
|
+
d = !0, h = l;
|
|
383
|
+
}
|
|
384
|
+
throw s.size === 0 && this._pathHandles === s && (this._pathHandles = void 0), d ? new AggregateError(
|
|
385
|
+
[a, h],
|
|
386
|
+
"[Raph] Path source activation and rollback failed."
|
|
387
|
+
) : a;
|
|
388
|
+
}
|
|
224
389
|
}
|
|
225
|
-
get(
|
|
390
|
+
get(e, t) {
|
|
226
391
|
this._assertTrackedRead();
|
|
227
|
-
const
|
|
228
|
-
return this._reactivity._isTracking() ? this.path(
|
|
392
|
+
const r = e ?? "";
|
|
393
|
+
return this._reactivity._isTracking() ? this.path(r, t)._getTracked() : this.kernel.get(r, t);
|
|
229
394
|
}
|
|
230
|
-
peek(
|
|
231
|
-
return this._assertAlive(), this.kernel.peek(
|
|
395
|
+
peek(e, t) {
|
|
396
|
+
return this._assertAlive(), this.kernel.peek(e ?? "", t);
|
|
232
397
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
*/
|
|
236
|
-
has(t, e) {
|
|
237
|
-
return this._assertAlive(), this.kernel.has(t, e);
|
|
398
|
+
has(e, t) {
|
|
399
|
+
return this._assertAlive(), this.kernel.has(e, t);
|
|
238
400
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
*/
|
|
242
|
-
set(t, e, s) {
|
|
243
|
-
this._assertWriteAllowed(), this._runWrite(() => this.kernel.set(t, e, s));
|
|
401
|
+
set(e, t, r) {
|
|
402
|
+
this._assertWriteAllowed(), this._runWrite(() => this.kernel.set(e, t, r));
|
|
244
403
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
*/
|
|
248
|
-
merge(t, e, s) {
|
|
249
|
-
this._assertWriteAllowed(), this._runWrite(() => this.kernel.merge(t, e, s));
|
|
404
|
+
merge(e, t, r) {
|
|
405
|
+
this._assertWriteAllowed(), this._runWrite(() => this.kernel.merge(e, t, r));
|
|
250
406
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
*/
|
|
254
|
-
delete(t, e) {
|
|
255
|
-
this._assertWriteAllowed(), this._runWrite(() => this.kernel.delete(t, e));
|
|
407
|
+
delete(e, t) {
|
|
408
|
+
this._assertWriteAllowed(), this._runWrite(() => this.kernel.delete(e, t));
|
|
256
409
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
*/
|
|
260
|
-
transaction(t) {
|
|
261
|
-
this._assertAlive(), this._transactionDepth++;
|
|
262
|
-
try {
|
|
263
|
-
return this._reactivity.batch(() => this.kernel.transaction(t));
|
|
264
|
-
} finally {
|
|
265
|
-
this._transactionDepth--, this._requestExecution();
|
|
266
|
-
}
|
|
410
|
+
batch(e) {
|
|
411
|
+
return this._batch(e, !0);
|
|
267
412
|
}
|
|
268
|
-
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
action(t, e, s = this.rootScope) {
|
|
272
|
-
if (this._assertOwnerRuntime(s), !t.trim())
|
|
273
|
-
throw new Error("[Raph] Action name must not be empty.");
|
|
274
|
-
return (...i) => (s._assertAlive(), this.runInAction(t, () => e(...i)));
|
|
413
|
+
/** Batches an internal reactive-only commit without opening an unused Kernel boundary. @internal */
|
|
414
|
+
_batchReactive(e) {
|
|
415
|
+
return this._batch(e, !1);
|
|
275
416
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
runInAction(t, e) {
|
|
280
|
-
this._assertAlive(), this._actionDepth++;
|
|
417
|
+
_batch(e, t) {
|
|
418
|
+
this._assertAlive(), this._batchDepth++;
|
|
419
|
+
let r, s, i = !1;
|
|
281
420
|
try {
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
421
|
+
r = this._reactivity.batch(() => t ? this.kernel.batch(e) : e());
|
|
422
|
+
} catch (c) {
|
|
423
|
+
i = !0, s = c;
|
|
285
424
|
}
|
|
425
|
+
this._batchDepth--;
|
|
426
|
+
const o = this._finishExecutionBoundary();
|
|
427
|
+
if (i)
|
|
428
|
+
throw o.length !== 0 ? new AggregateError(
|
|
429
|
+
[s, ...o],
|
|
430
|
+
"[Raph] Batch and scheduled phase execution failed."
|
|
431
|
+
) : s;
|
|
432
|
+
return y(o, "[Raph] Batch phase execution failed."), r;
|
|
433
|
+
}
|
|
434
|
+
action(e, t, r) {
|
|
435
|
+
const s = typeof e == "function" ? e : t, i = typeof e == "function" ? t instanceof D ? t : this.rootScope : r ?? this.rootScope, o = typeof e == "string" ? e : `action#${++this._actionCounter}`;
|
|
436
|
+
if (this._assertOwnerRuntime(i), typeof s != "function")
|
|
437
|
+
throw new TypeError("[Raph] Action operation must be a function.");
|
|
438
|
+
if (!o.trim())
|
|
439
|
+
throw new Error("[Raph] Action name must not be empty.");
|
|
440
|
+
return (...c) => {
|
|
441
|
+
i._assertAlive();
|
|
442
|
+
const n = this._debugController.nextOperationId("action"), h = this._traceCauseStack.at(-1) ?? n;
|
|
443
|
+
this._debugController.record({
|
|
444
|
+
...h === void 0 ? {} : { causeId: h },
|
|
445
|
+
kind: "action",
|
|
446
|
+
name: o,
|
|
447
|
+
...n === void 0 ? {} : { operationId: n },
|
|
448
|
+
status: "start"
|
|
449
|
+
}), h !== void 0 && this._traceCauseStack.push(h), this._actionDepth++;
|
|
450
|
+
try {
|
|
451
|
+
const d = this.batch(() => this._runUntracked(() => s(...c)));
|
|
452
|
+
return this._debugController.record({
|
|
453
|
+
...h === void 0 ? {} : { causeId: h },
|
|
454
|
+
kind: "action",
|
|
455
|
+
name: o,
|
|
456
|
+
...n === void 0 ? {} : { operationId: n },
|
|
457
|
+
status: "end"
|
|
458
|
+
}), d;
|
|
459
|
+
} catch (d) {
|
|
460
|
+
throw this._debugController.record({
|
|
461
|
+
...h === void 0 ? {} : { causeId: h },
|
|
462
|
+
details: { message: C(d) },
|
|
463
|
+
kind: "action",
|
|
464
|
+
name: o,
|
|
465
|
+
...n === void 0 ? {} : { operationId: n },
|
|
466
|
+
status: "error"
|
|
467
|
+
}), this._debugController.record({
|
|
468
|
+
...h === void 0 ? {} : { causeId: h },
|
|
469
|
+
details: { message: C(d) },
|
|
470
|
+
kind: "error",
|
|
471
|
+
name: `action:${o}`,
|
|
472
|
+
...n === void 0 ? {} : { operationId: n },
|
|
473
|
+
status: "error"
|
|
474
|
+
}), d;
|
|
475
|
+
} finally {
|
|
476
|
+
this._actionDepth--, h !== void 0 && this._traceCauseStack.pop();
|
|
477
|
+
}
|
|
478
|
+
};
|
|
286
479
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
*/
|
|
290
|
-
untracked(t) {
|
|
291
|
-
return this._assertAlive(), this._reactivity.untrackedWithOwner(t);
|
|
480
|
+
untracked(e) {
|
|
481
|
+
return this._assertAlive(), this._runUntracked(e);
|
|
292
482
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*/
|
|
296
|
-
scope(t) {
|
|
297
|
-
return this._assertAlive(), new S(t, this);
|
|
483
|
+
scope(e) {
|
|
484
|
+
return this._assertAlive(), new D(e, this);
|
|
298
485
|
}
|
|
299
|
-
|
|
300
|
-
* Создаёт дочерний execution node.
|
|
301
|
-
*/
|
|
302
|
-
node(t, e) {
|
|
486
|
+
node(e, t) {
|
|
303
487
|
this._assertAlive();
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
return i._setApi(e(i)), i;
|
|
307
|
-
} catch (r) {
|
|
488
|
+
const r = this._runNodeMutation(() => {
|
|
489
|
+
const s = e.parent ?? this.root, i = q(s, e, this);
|
|
308
490
|
try {
|
|
309
|
-
i
|
|
491
|
+
const o = t == null ? void 0 : t(i);
|
|
492
|
+
return i._assertAlive(), s._assertAlive(), i._setApi(o), i._publishCreation(), i;
|
|
310
493
|
} catch (o) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
494
|
+
try {
|
|
495
|
+
i.dispose();
|
|
496
|
+
} catch (c) {
|
|
497
|
+
throw new AggregateError([o, c], `[Raph] Node "${i.id}" setup and cleanup failed.`);
|
|
498
|
+
}
|
|
499
|
+
throw o;
|
|
315
500
|
}
|
|
316
|
-
|
|
317
|
-
|
|
501
|
+
});
|
|
502
|
+
return r._assertAlive(), r;
|
|
318
503
|
}
|
|
319
|
-
|
|
320
|
-
* Находит принадлежащий runtime node по id для диагностики.
|
|
321
|
-
*/
|
|
322
|
-
getNode(t) {
|
|
504
|
+
getNode(e) {
|
|
323
505
|
this._assertAlive();
|
|
324
|
-
const
|
|
325
|
-
for (;
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
return
|
|
329
|
-
|
|
506
|
+
const t = [this.root];
|
|
507
|
+
for (; t.length !== 0; ) {
|
|
508
|
+
const r = t.pop();
|
|
509
|
+
if (r.id === e)
|
|
510
|
+
return r;
|
|
511
|
+
t.push(...r.children);
|
|
330
512
|
}
|
|
331
513
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*/
|
|
335
|
-
definePhases(t) {
|
|
336
|
-
this._execution.definePhases(t);
|
|
514
|
+
definePhases(e) {
|
|
515
|
+
this._execution.definePhases(e);
|
|
337
516
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
*/
|
|
341
|
-
addPhase(t) {
|
|
342
|
-
this._execution.addPhase(t);
|
|
517
|
+
addPhase(e) {
|
|
518
|
+
this._execution.addPhase(e);
|
|
343
519
|
}
|
|
344
|
-
/**
|
|
345
|
-
* Удаляет пользовательские phases до первого выполнения pipeline.
|
|
346
|
-
*/
|
|
347
520
|
clearPhases() {
|
|
348
|
-
var
|
|
349
|
-
this._assertAlive(), (
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Регистрирует path observer в phase pipeline.
|
|
353
|
-
*/
|
|
354
|
-
observeData(t, e, s) {
|
|
355
|
-
return this._assertOwnerRuntime(t), this._own(this._execution.observeData(t, e, s), t);
|
|
521
|
+
var e;
|
|
522
|
+
this._assertAlive(), (e = this._phases) == null || e.clearPhases();
|
|
356
523
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
track(t, e, s = {}) {
|
|
361
|
-
return this._assertOwnerRuntime(t), this._own(this._execution.track(t, e, s), t);
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Помечает node для выполнения в pipeline.
|
|
365
|
-
*/
|
|
366
|
-
invalidateNode(t, e) {
|
|
367
|
-
this._assertOwnerRuntime(t), this._execution.invalidate(t, e);
|
|
524
|
+
requestExecution() {
|
|
525
|
+
var e;
|
|
526
|
+
this._assertAlive(), (e = this._phases) == null || e.request();
|
|
368
527
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Синхронно выполняет все готовые очереди pipeline.
|
|
371
|
-
*/
|
|
372
528
|
flush() {
|
|
373
|
-
var
|
|
374
|
-
this._assertAlive(), this._executionRequested = !1, (
|
|
529
|
+
var e;
|
|
530
|
+
this._assertAlive(), this._executionRequested = !1, (e = this._phases) == null || e.flush();
|
|
375
531
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
532
|
+
afterFlush() {
|
|
533
|
+
var e;
|
|
534
|
+
return this._assertAlive(), ((e = this._phases) == null ? void 0 : e.afterFlush()) ?? Promise.resolve();
|
|
535
|
+
}
|
|
536
|
+
acquireLoop(e) {
|
|
537
|
+
return this._assertAlive(), this._clock.acquire(e);
|
|
381
538
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Запускает manual lease автоматического frame-loop.
|
|
384
|
-
*/
|
|
385
539
|
startLoop() {
|
|
386
540
|
this._assertAlive(), this._clock.start();
|
|
387
541
|
}
|
|
388
|
-
/**
|
|
389
|
-
* Останавливает manual lease автоматического frame-loop.
|
|
390
|
-
*/
|
|
391
542
|
stopLoop() {
|
|
392
|
-
var
|
|
393
|
-
(
|
|
543
|
+
var e;
|
|
544
|
+
(e = this._frameLoop) == null || e.stop();
|
|
394
545
|
}
|
|
395
|
-
|
|
396
|
-
* Создаёт управляемое derived-представление source path в target path.
|
|
397
|
-
*/
|
|
398
|
-
derive(t) {
|
|
546
|
+
derive(e) {
|
|
399
547
|
this._assertAlive();
|
|
400
|
-
const
|
|
401
|
-
...
|
|
402
|
-
compute: (
|
|
548
|
+
const t = e.compute, r = this.kernel.derive({
|
|
549
|
+
...e,
|
|
550
|
+
compute: (s) => this._runUntracked(() => t(s))
|
|
403
551
|
});
|
|
404
|
-
return this._own(() =>
|
|
552
|
+
return this._own(() => r.dispose(), this.rootScope), r;
|
|
405
553
|
}
|
|
406
|
-
/**
|
|
407
|
-
* Освобождает execution graph и отсоединяет runtime от shared Kernel.
|
|
408
|
-
*/
|
|
409
554
|
dispose() {
|
|
410
|
-
var
|
|
555
|
+
var c, n;
|
|
411
556
|
if (this._disposed)
|
|
412
557
|
return;
|
|
413
558
|
this._disposed = !0, this._executionRequested = !1, this._signalLifecycle.owner = void 0;
|
|
414
|
-
const
|
|
559
|
+
const e = [], t = [...this._owners];
|
|
415
560
|
try {
|
|
416
|
-
(
|
|
417
|
-
} catch (
|
|
418
|
-
|
|
561
|
+
(c = this._frameLoop) == null || c.dispose();
|
|
562
|
+
} catch (a) {
|
|
563
|
+
e.push(a);
|
|
419
564
|
}
|
|
420
565
|
this._frameLoop = void 0;
|
|
421
566
|
try {
|
|
422
|
-
(
|
|
423
|
-
} catch (
|
|
424
|
-
|
|
567
|
+
(n = this._phases) == null || n.dispose();
|
|
568
|
+
} catch (a) {
|
|
569
|
+
e.push(a);
|
|
425
570
|
}
|
|
426
571
|
this._phases = void 0;
|
|
427
572
|
try {
|
|
428
573
|
this.root.dispose();
|
|
429
|
-
} catch (
|
|
430
|
-
|
|
574
|
+
} catch (a) {
|
|
575
|
+
e.push(a);
|
|
431
576
|
}
|
|
432
|
-
for (const
|
|
433
|
-
if (!(
|
|
577
|
+
for (const a of t.reverse())
|
|
578
|
+
if (!(a === this.root || a === this.rootScope || a.disposed))
|
|
434
579
|
try {
|
|
435
|
-
|
|
436
|
-
} catch (
|
|
437
|
-
|
|
580
|
+
a.dispose();
|
|
581
|
+
} catch (h) {
|
|
582
|
+
e.push(h);
|
|
438
583
|
}
|
|
439
584
|
try {
|
|
440
585
|
this.rootScope.dispose();
|
|
441
|
-
} catch (
|
|
442
|
-
|
|
586
|
+
} catch (a) {
|
|
587
|
+
e.push(a);
|
|
443
588
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
589
|
+
const r = `[Raph] Runtime "${this.id}" is disposed.`, s = () => {
|
|
590
|
+
throw new A(r);
|
|
591
|
+
};
|
|
592
|
+
try {
|
|
593
|
+
L(this._reactivity, {
|
|
594
|
+
assertRead: s,
|
|
595
|
+
assertWrite: s,
|
|
596
|
+
throwForeign: s
|
|
597
|
+
});
|
|
598
|
+
} catch (a) {
|
|
599
|
+
e.push(a);
|
|
600
|
+
}
|
|
601
|
+
this._owners.clear(), this._meta = void 0;
|
|
602
|
+
const i = this._pathHandles;
|
|
603
|
+
if (this._pathHandles = void 0, i !== void 0) {
|
|
604
|
+
for (const a of i.values())
|
|
448
605
|
try {
|
|
449
|
-
|
|
450
|
-
} catch (
|
|
451
|
-
|
|
606
|
+
a.dispose();
|
|
607
|
+
} catch (h) {
|
|
608
|
+
e.push(h);
|
|
452
609
|
}
|
|
453
|
-
|
|
610
|
+
i.clear();
|
|
611
|
+
}
|
|
612
|
+
try {
|
|
613
|
+
this._workGraph.dispose();
|
|
614
|
+
} catch (a) {
|
|
615
|
+
e.push(a);
|
|
454
616
|
}
|
|
455
617
|
try {
|
|
456
618
|
this.kernel._detachRuntime(this);
|
|
457
|
-
} catch (
|
|
458
|
-
|
|
619
|
+
} catch (a) {
|
|
620
|
+
e.push(a);
|
|
459
621
|
}
|
|
460
|
-
const
|
|
622
|
+
const o = [...this._disposedListeners];
|
|
461
623
|
this._disposedListeners.clear();
|
|
462
|
-
for (const
|
|
624
|
+
for (const a of o)
|
|
463
625
|
try {
|
|
464
|
-
|
|
465
|
-
} catch (
|
|
466
|
-
|
|
626
|
+
a();
|
|
627
|
+
} catch (h) {
|
|
628
|
+
e.push(h);
|
|
467
629
|
}
|
|
468
|
-
|
|
630
|
+
y(e, `[Raph] Runtime "${this.id}" disposal failed.`);
|
|
631
|
+
}
|
|
632
|
+
/** @internal */
|
|
633
|
+
_onDisposed(e) {
|
|
634
|
+
return this._disposed ? (e(), () => {
|
|
635
|
+
}) : (this._disposedListeners.add(e), () => {
|
|
636
|
+
this._disposedListeners.delete(e);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/** @internal */
|
|
640
|
+
_notifyNodeStructure(e, t, r, s) {
|
|
641
|
+
this._runNodeMutation(() => {
|
|
642
|
+
this._workGraph.notifyNode(e, "structure", { structure: t, oldAncestors: r, newAncestors: s });
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
/** @internal */
|
|
646
|
+
_notifyNodeTouch(e, t) {
|
|
647
|
+
this._runNodeMutation(() => this._workGraph.notifyNode(e, "touch", { metadata: t }));
|
|
648
|
+
}
|
|
649
|
+
/** @internal */
|
|
650
|
+
_assertNodeReparentAllowed(e, t) {
|
|
651
|
+
this._workGraph.assertReparentAllowed(e, t);
|
|
652
|
+
}
|
|
653
|
+
/** @internal */
|
|
654
|
+
_releaseNode(e) {
|
|
655
|
+
this._workGraph.releaseNode(e);
|
|
656
|
+
}
|
|
657
|
+
/** @internal */
|
|
658
|
+
_runNodeMutation(e) {
|
|
659
|
+
return this._runWrite(e);
|
|
660
|
+
}
|
|
661
|
+
/** @internal */
|
|
662
|
+
_runPhaseTransition(e) {
|
|
663
|
+
return this._runWrite(e, !1);
|
|
664
|
+
}
|
|
665
|
+
/** @internal */
|
|
666
|
+
_beginOwnerDisposal() {
|
|
667
|
+
this._ownerDisposalDepth++;
|
|
668
|
+
}
|
|
669
|
+
/** @internal */
|
|
670
|
+
_endOwnerDisposal() {
|
|
671
|
+
this._ownerDisposalDepth !== 0 && (this._ownerDisposalDepth--, this._clearTransientCausesIfSettled(), this._disposed || this._requestExecution());
|
|
672
|
+
}
|
|
673
|
+
/** @internal */
|
|
674
|
+
_ownerDisposalActive() {
|
|
675
|
+
return this._ownerDisposalDepth !== 0;
|
|
676
|
+
}
|
|
677
|
+
/** @internal */
|
|
678
|
+
_registerOwner(e) {
|
|
679
|
+
this._assertAlive(), this._owners.add(e);
|
|
680
|
+
}
|
|
681
|
+
/** @internal */
|
|
682
|
+
_unregisterOwner(e) {
|
|
683
|
+
this._owners.delete(e);
|
|
684
|
+
}
|
|
685
|
+
/** @internal */
|
|
686
|
+
_assertOwnerRuntime(e) {
|
|
687
|
+
if (this._assertAlive(), e.runtime !== this)
|
|
688
|
+
throw new k("[Raph] Owner belongs to another runtime.");
|
|
689
|
+
e._assertAlive();
|
|
690
|
+
}
|
|
691
|
+
/** @internal */
|
|
692
|
+
_beginKernelBatch() {
|
|
693
|
+
this._disposed || this._kernelBatchDepth++;
|
|
694
|
+
}
|
|
695
|
+
/** @internal */
|
|
696
|
+
_endKernelBatch() {
|
|
697
|
+
this._kernelBatchDepth !== 0 && (this._kernelBatchDepth--, this._clearTransientCausesIfSettled(), this._disposed || this._requestExecution());
|
|
698
|
+
}
|
|
699
|
+
/** Регистрирует read-only diagnostics projection optional Machine. @internal */
|
|
700
|
+
_registerMachineDebug(e) {
|
|
701
|
+
return this._assertAlive(), this._debugController.registerMachine(e);
|
|
469
702
|
}
|
|
470
703
|
/**
|
|
471
|
-
*
|
|
704
|
+
* Проверяет optional diagnostic identity без создания public facade.
|
|
705
|
+
*
|
|
472
706
|
* @internal
|
|
473
707
|
*/
|
|
474
|
-
|
|
475
|
-
return this.
|
|
476
|
-
}) : (this._disposedListeners.add(t), () => {
|
|
477
|
-
this._disposedListeners.delete(t);
|
|
478
|
-
});
|
|
708
|
+
_hasMachineDebug(e) {
|
|
709
|
+
return this._debugController.hasMachine(e);
|
|
479
710
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Проверяет optional trace path без выделения operation ID.
|
|
713
|
+
*
|
|
714
|
+
* @internal
|
|
715
|
+
*/
|
|
716
|
+
_traces(e) {
|
|
717
|
+
return this._debugController.traces(e);
|
|
718
|
+
}
|
|
719
|
+
/** Возвращает наследуемый cause для optional execution layers. @internal */
|
|
720
|
+
_currentTraceCauseId() {
|
|
721
|
+
return this._traceCauseStack.at(-1);
|
|
722
|
+
}
|
|
723
|
+
/** Выдаёт operation id только на активном trace path. @internal */
|
|
724
|
+
_nextTraceOperation(e) {
|
|
725
|
+
return this._debugController.nextOperationId(e);
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Проверяет, должен ли untracked work изолировать reactive или Runtime owner context.
|
|
729
|
+
*
|
|
730
|
+
* @internal
|
|
731
|
+
*/
|
|
732
|
+
_hasActiveReactiveContext() {
|
|
733
|
+
return this._assertAlive(), this._reactivity.hasActiveContext();
|
|
734
|
+
}
|
|
735
|
+
/** Записывает optional trace event без machine dependency. @internal */
|
|
736
|
+
_recordTrace(e) {
|
|
737
|
+
this._debugController.record(e);
|
|
738
|
+
}
|
|
739
|
+
/** Наследует cause через outputs/tasks optional execution layers. @internal */
|
|
740
|
+
_runWithTraceCause(e, t) {
|
|
741
|
+
if (e === void 0)
|
|
742
|
+
return t();
|
|
743
|
+
this._traceCauseStack.push(e);
|
|
744
|
+
try {
|
|
745
|
+
return t();
|
|
746
|
+
} finally {
|
|
747
|
+
this._traceCauseStack.pop();
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
_validatePhaseBinding(e, t, r, s = !1) {
|
|
751
|
+
if (typeof t != "function")
|
|
752
|
+
throw new TypeError("[Raph] Phase callback must be a function.");
|
|
753
|
+
const i = e.trim();
|
|
754
|
+
this._execution.requirePhase(i);
|
|
755
|
+
const o = r.priority ?? 0;
|
|
756
|
+
if (!Number.isFinite(o))
|
|
757
|
+
throw new TypeError("[Raph] Effect priority must be finite.");
|
|
758
|
+
const c = r.initial ?? "scheduled";
|
|
759
|
+
if (c !== "scheduled" && c !== "sync" && !(s && c === "none"))
|
|
760
|
+
throw new TypeError(`[Raph] Unsupported effect initial mode "${String(c)}".`);
|
|
761
|
+
return i;
|
|
485
762
|
}
|
|
486
763
|
_createDebugSnapshot() {
|
|
487
|
-
var s, i
|
|
488
|
-
const
|
|
764
|
+
var r, s, i;
|
|
765
|
+
const e = ((r = this._frameLoop) == null ? void 0 : r._debugState()) ?? { running: !1, manual: !1, leases: 0 }, t = [...this._owners].filter((o) => o !== this.rootScope && !(o instanceof g)).map(b);
|
|
489
766
|
return Object.freeze({
|
|
490
767
|
id: this.id,
|
|
491
768
|
disposed: this._disposed,
|
|
492
|
-
pending: !this._disposed && (this._executionRequested || (((
|
|
493
|
-
|
|
494
|
-
|
|
769
|
+
pending: !this._disposed && (this._executionRequested || (((s = this._phases) == null ? void 0 : s._debugPending()) ?? !1)),
|
|
770
|
+
batchDepth: this._batchDepth,
|
|
771
|
+
kernelBatchDepth: this._kernelBatchDepth,
|
|
495
772
|
owners: this._owners.size,
|
|
496
|
-
pathHandles: ((
|
|
497
|
-
rootScope:
|
|
498
|
-
scopes: Object.freeze(
|
|
499
|
-
root:
|
|
500
|
-
frameLoop: Object.freeze(
|
|
773
|
+
pathHandles: ((i = this._pathHandles) == null ? void 0 : i.size) ?? 0,
|
|
774
|
+
rootScope: b(this.rootScope),
|
|
775
|
+
scopes: Object.freeze(t),
|
|
776
|
+
root: b(this.root),
|
|
777
|
+
frameLoop: Object.freeze(e),
|
|
778
|
+
actionDepth: this._actionDepth,
|
|
779
|
+
machines: this._debugController.machineCount,
|
|
780
|
+
traceEvents: this._debugController.traceSize
|
|
501
781
|
});
|
|
502
782
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
r.requirePhase(i);
|
|
516
|
-
const o = s.priority ?? 0;
|
|
517
|
-
if (!Number.isFinite(o))
|
|
518
|
-
throw new TypeError("[RaphMeta] watch priority must be finite.");
|
|
519
|
-
const n = r.retainPhase(i), c = new g((_) => this._runUntracked(_));
|
|
520
|
-
let p = [], u;
|
|
521
|
-
const l = () => {
|
|
522
|
-
u = void 0;
|
|
523
|
-
const _ = p;
|
|
524
|
-
p = [], c.deliver(() => e({ events: _ }));
|
|
525
|
-
};
|
|
526
|
-
let w;
|
|
527
|
-
try {
|
|
528
|
-
w = this.kernel._watchMeta(t, ({ events: _ }) => {
|
|
529
|
-
c.stopped || (p.push(..._), u === void 0 && (u = r.queueEffect(i, o, l, !1)));
|
|
530
|
-
}, s, (_) => {
|
|
531
|
-
!c.stopped && _ && u !== void 0 && r.request();
|
|
532
|
-
});
|
|
533
|
-
} catch (_) {
|
|
534
|
-
throw n(), _;
|
|
535
|
-
}
|
|
536
|
-
return () => {
|
|
537
|
-
if (c.stopped)
|
|
538
|
-
return;
|
|
539
|
-
const _ = [];
|
|
540
|
-
try {
|
|
541
|
-
c.stop(w);
|
|
542
|
-
} catch (f) {
|
|
543
|
-
_.push(f);
|
|
544
|
-
}
|
|
545
|
-
try {
|
|
546
|
-
u == null || u();
|
|
547
|
-
} catch (f) {
|
|
548
|
-
_.push(f);
|
|
549
|
-
}
|
|
550
|
-
try {
|
|
551
|
-
n();
|
|
552
|
-
} catch (f) {
|
|
553
|
-
_.push(f);
|
|
554
|
-
}
|
|
555
|
-
u = void 0, p = [], D(_, "[RaphMeta] Phase watch disposal failed.");
|
|
556
|
-
};
|
|
783
|
+
_createDebugTree() {
|
|
784
|
+
const e = this._debugController.machineTreeNodesByOwner(), t = [
|
|
785
|
+
R(this.rootScope, e),
|
|
786
|
+
R(this.root, e),
|
|
787
|
+
...[...this._owners].filter((r) => r !== this.rootScope && r !== this.root && !(r instanceof g)).map((r) => R(r, e))
|
|
788
|
+
];
|
|
789
|
+
return Object.freeze({
|
|
790
|
+
children: Object.freeze(t),
|
|
791
|
+
disposed: this._disposed,
|
|
792
|
+
id: this.id,
|
|
793
|
+
kind: "runtime"
|
|
794
|
+
});
|
|
557
795
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
796
|
+
_createDebugStats() {
|
|
797
|
+
var i, o;
|
|
798
|
+
let e = 0, t = 0, r = 0, s = 0;
|
|
799
|
+
for (const c of this._owners)
|
|
800
|
+
c instanceof g ? e++ : t++, r += c._debugResourceCount(), s += c._debugSourceCount();
|
|
801
|
+
return Object.freeze({
|
|
802
|
+
actors: this._debugController.actorCount,
|
|
803
|
+
machines: this._debugController.machineCount,
|
|
804
|
+
nodes: e,
|
|
805
|
+
owners: this._owners.size,
|
|
806
|
+
pathHandles: ((i = this._pathHandles) == null ? void 0 : i.size) ?? 0,
|
|
807
|
+
pending: !this._disposed && (this._executionRequested || (((o = this._phases) == null ? void 0 : o._debugPending()) ?? !1)),
|
|
808
|
+
resources: r,
|
|
809
|
+
scopes: t,
|
|
810
|
+
sources: s,
|
|
811
|
+
traceEvents: this._debugController.traceSize
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
_releasePathHandle(e) {
|
|
815
|
+
const t = this._pathHandles;
|
|
816
|
+
(t == null ? void 0 : t.get(e.path)) === e && (t.delete(e.path), t.size === 0 && (this._pathHandles = void 0));
|
|
561
817
|
}
|
|
562
818
|
get _execution() {
|
|
563
|
-
return this._assertAlive(), this._phases ?? (this._phases = new
|
|
564
|
-
this.kernel,
|
|
565
|
-
this.root,
|
|
819
|
+
return this._assertAlive(), this._phases ?? (this._phases = new H(
|
|
566
820
|
this.configuration.scheduler,
|
|
567
|
-
(
|
|
821
|
+
(e) => this._runUntracked(e),
|
|
822
|
+
(e) => this._workGraph.causeForToken(e),
|
|
568
823
|
() => {
|
|
569
|
-
const
|
|
570
|
-
return
|
|
824
|
+
const e = this._mutationDepth !== 0 || this._batchDepth !== 0 || this._kernelBatchDepth !== 0 || this._ownerDisposalDepth !== 0 || this._reactivity._isFlushingEffects();
|
|
825
|
+
return e && this.configuration.scheduler === w.Sync && (this._executionRequested = !0), e;
|
|
826
|
+
},
|
|
827
|
+
(e, t, r) => {
|
|
828
|
+
var i, o, c;
|
|
829
|
+
let s;
|
|
830
|
+
t === "start" ? (s = this._debugController.nextOperationId("phase"), s !== void 0 && (this._phaseTraceOperations ?? (this._phaseTraceOperations = /* @__PURE__ */ new Map())).set(e, s)) : (s = (i = this._phaseTraceOperations) == null ? void 0 : i.get(e), (o = this._phaseTraceOperations) == null || o.delete(e), ((c = this._phaseTraceOperations) == null ? void 0 : c.size) === 0 && (this._phaseTraceOperations = void 0)), this._debugController.record({
|
|
831
|
+
...s === void 0 ? {} : { causeId: s },
|
|
832
|
+
...r === void 0 ? {} : { details: { message: C(r) } },
|
|
833
|
+
kind: "phase",
|
|
834
|
+
name: e,
|
|
835
|
+
...s === void 0 ? {} : { operationId: s },
|
|
836
|
+
status: t
|
|
837
|
+
});
|
|
571
838
|
}
|
|
572
839
|
));
|
|
573
840
|
}
|
|
574
841
|
get _clock() {
|
|
575
|
-
return this._frameLoop ?? (this._frameLoop = new
|
|
842
|
+
return this._frameLoop ?? (this._frameLoop = new I(() => this._tickFrameLoop()));
|
|
576
843
|
}
|
|
577
844
|
_tickFrameLoop() {
|
|
578
|
-
|
|
579
|
-
this._disposed || (this._frameRevision !== void 0 && (this._frameRevisionValue = !this._frameRevisionValue, this._frameRevision.set(this._frameRevisionValue)), (t = this._phases) == null || t.requestAlwaysPhases(), this._requestExecution());
|
|
845
|
+
this._disposed || this._setFrameTick(this._frameTickWritable.peek() + 1);
|
|
580
846
|
}
|
|
581
|
-
_attachWritableComputed(
|
|
582
|
-
let
|
|
847
|
+
_attachWritableComputed(e, t, r) {
|
|
848
|
+
let s = t;
|
|
583
849
|
this._own(() => {
|
|
584
|
-
|
|
585
|
-
},
|
|
586
|
-
const
|
|
587
|
-
return
|
|
588
|
-
|
|
589
|
-
},
|
|
590
|
-
}
|
|
591
|
-
_own(
|
|
850
|
+
s = void 0;
|
|
851
|
+
}, r);
|
|
852
|
+
const i = e;
|
|
853
|
+
return i.set = (o) => {
|
|
854
|
+
r._assertAlive(), this._assertWriteAllowed(), this._runWrite(() => s(o));
|
|
855
|
+
}, i;
|
|
856
|
+
}
|
|
857
|
+
_own(e, t) {
|
|
592
858
|
try {
|
|
593
|
-
return
|
|
594
|
-
} catch (
|
|
859
|
+
return t._adoptResource(e);
|
|
860
|
+
} catch (r) {
|
|
595
861
|
try {
|
|
596
|
-
|
|
597
|
-
} catch (
|
|
598
|
-
throw new AggregateError(
|
|
599
|
-
[s, i],
|
|
600
|
-
"[Raph] Resource registration and cleanup failed."
|
|
601
|
-
);
|
|
862
|
+
e();
|
|
863
|
+
} catch (s) {
|
|
864
|
+
throw new AggregateError([r, s], "[Raph] Resource registration and cleanup failed.");
|
|
602
865
|
}
|
|
603
|
-
throw
|
|
866
|
+
throw r;
|
|
604
867
|
}
|
|
605
868
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
* @internal
|
|
609
|
-
*/
|
|
610
|
-
_registerOwner(t) {
|
|
611
|
-
this._assertAlive(), this._owners.add(t);
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Удаляет lifecycle owner из runtime registry.
|
|
615
|
-
* @internal
|
|
616
|
-
*/
|
|
617
|
-
_unregisterOwner(t) {
|
|
618
|
-
this._owners.delete(t);
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Проверяет, что owner принадлежит этому живому runtime.
|
|
622
|
-
* @internal
|
|
623
|
-
*/
|
|
624
|
-
_assertOwnerRuntime(t) {
|
|
625
|
-
if (this._assertAlive(), t.runtime !== this)
|
|
626
|
-
throw new k("[Raph] Owner belongs to another runtime.");
|
|
627
|
-
t._assertAlive();
|
|
869
|
+
_runTracked(e, t) {
|
|
870
|
+
return this._reactivity.runWithOwner(this._signalLifecycle, e, t);
|
|
628
871
|
}
|
|
629
|
-
|
|
630
|
-
return this._reactivity.
|
|
872
|
+
_runUntracked(e) {
|
|
873
|
+
return this._reactivity.untrackedWithOwner(e);
|
|
631
874
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
_runWrite(t, e = !0) {
|
|
636
|
-
e && this.configuration.scheduler === d.Sync && (this._executionRequested = !0), this._mutationDepth++;
|
|
875
|
+
_runWrite(e, t = !0) {
|
|
876
|
+
t && this.configuration.scheduler === w.Sync && (this._executionRequested = !0), this._mutationDepth++;
|
|
877
|
+
let r, s, i = !1;
|
|
637
878
|
try {
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
879
|
+
r = e();
|
|
880
|
+
} catch (c) {
|
|
881
|
+
i = !0, s = c;
|
|
641
882
|
}
|
|
883
|
+
this._mutationDepth--;
|
|
884
|
+
const o = this._finishExecutionBoundary();
|
|
885
|
+
if (i)
|
|
886
|
+
throw o.length !== 0 ? new AggregateError(
|
|
887
|
+
[s, ...o],
|
|
888
|
+
"[Raph] Mutation and scheduled phase execution failed."
|
|
889
|
+
) : s;
|
|
890
|
+
return y(o, "[Raph] Mutation phase execution failed."), r;
|
|
891
|
+
}
|
|
892
|
+
_finishExecutionBoundary() {
|
|
893
|
+
const e = [];
|
|
894
|
+
try {
|
|
895
|
+
this._clearTransientCausesIfSettled();
|
|
896
|
+
} catch (t) {
|
|
897
|
+
e.push(t);
|
|
898
|
+
}
|
|
899
|
+
try {
|
|
900
|
+
this._requestExecution();
|
|
901
|
+
} catch (t) {
|
|
902
|
+
e.push(t);
|
|
903
|
+
}
|
|
904
|
+
return e;
|
|
905
|
+
}
|
|
906
|
+
_clearTransientCausesIfSettled() {
|
|
907
|
+
this._mutationDepth === 0 && this._batchDepth === 0 && this._kernelBatchDepth === 0 && this._ownerDisposalDepth === 0 && !this._reactivity._isFlushingEffects() && this._workGraph.clearTransientCauses();
|
|
642
908
|
}
|
|
643
909
|
_requestExecution() {
|
|
644
|
-
var
|
|
645
|
-
this.configuration.scheduler !==
|
|
910
|
+
var e;
|
|
911
|
+
this._disposed || this.configuration.scheduler !== w.Sync || this._mutationDepth !== 0 || this._batchDepth !== 0 || this._kernelBatchDepth !== 0 || this._ownerDisposalDepth !== 0 || this._reactivity._isFlushingEffects() || this._executionRequested && (this._executionRequested = !1, (e = this._phases) == null || e.flush());
|
|
646
912
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
913
|
+
_assertTrackedRead() {
|
|
914
|
+
this._assertAlive();
|
|
915
|
+
const e = this._reactivity.getActiveOwner();
|
|
916
|
+
e !== void 0 && e !== this && this._throwCrossRuntime(e);
|
|
917
|
+
const t = this._reactivity.getActiveConsumerOwner();
|
|
918
|
+
t !== void 0 && this._assertImplicitDependency(this.rootScope, t);
|
|
653
919
|
}
|
|
654
920
|
/**
|
|
655
|
-
*
|
|
921
|
+
* Проверяет tracked read из optional owned source.
|
|
922
|
+
*
|
|
656
923
|
* @internal
|
|
657
924
|
*/
|
|
658
|
-
|
|
659
|
-
this._kernelTransactionDepth !== 0 && (this._kernelTransactionDepth--, this._disposed || this._requestExecution());
|
|
660
|
-
}
|
|
661
|
-
_assertTrackedRead() {
|
|
925
|
+
_assertSourceReadable(e) {
|
|
662
926
|
this._assertAlive();
|
|
663
927
|
const t = this._reactivity.getActiveOwner();
|
|
664
928
|
t !== void 0 && t !== this && this._throwCrossRuntime(t);
|
|
929
|
+
const r = this._reactivity.getActiveConsumerOwner();
|
|
930
|
+
r !== void 0 && this._assertImplicitDependency(e, r), e._assertAlive();
|
|
931
|
+
}
|
|
932
|
+
_assertImplicitDependency(e, t) {
|
|
933
|
+
if (e.runtime !== this || t.runtime !== this)
|
|
934
|
+
throw new k("[Raph] Implicit dependency crosses runtime boundaries.");
|
|
935
|
+
if (!(e === this.rootScope || e === t)) {
|
|
936
|
+
if (e instanceof g && t instanceof g) {
|
|
937
|
+
for (let r = t.parent; r !== null; r = r.parent)
|
|
938
|
+
if (r === e)
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
throw new Error(
|
|
942
|
+
`[Raph] Implicit dependency from "${t.id}" to "${e.id}" is not allowed; use watch().`
|
|
943
|
+
);
|
|
944
|
+
}
|
|
665
945
|
}
|
|
666
946
|
_assertWriteAllowed() {
|
|
667
|
-
if (this._assertAlive(), this.configuration.enforceActions && this.
|
|
668
|
-
throw new
|
|
669
|
-
"[Raph] Writes are allowed only inside action() or transaction()."
|
|
670
|
-
);
|
|
947
|
+
if (this._assertAlive(), this.configuration.enforceActions && this._batchDepth === 0)
|
|
948
|
+
throw new B("[Raph] Writes are allowed only inside action() or batch().");
|
|
671
949
|
}
|
|
672
|
-
_throwCrossRuntime(
|
|
950
|
+
_throwCrossRuntime(e) {
|
|
673
951
|
throw new k(
|
|
674
|
-
`[Raph] Runtime "${this.id}" cannot be tracked by runtime "${
|
|
952
|
+
`[Raph] Runtime "${this.id}" cannot be tracked by runtime "${e.id}".`
|
|
675
953
|
);
|
|
676
954
|
}
|
|
677
|
-
_throwDisposed() {
|
|
678
|
-
throw new R(`[Raph] Runtime "${this.id}" is disposed.`);
|
|
679
|
-
}
|
|
680
955
|
_assertAlive() {
|
|
681
|
-
this._disposed
|
|
956
|
+
if (this._disposed)
|
|
957
|
+
throw new A(`[Raph] Runtime "${this.id}" is disposed.`);
|
|
682
958
|
}
|
|
683
959
|
};
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return typeof a == "string" || a instanceof A || E(a) ? !0 : Array.isArray(a) && a.every(
|
|
689
|
-
(t) => typeof t == "string" || t instanceof A || E(t)
|
|
690
|
-
);
|
|
960
|
+
u(v, "_runtimeCounter", 0);
|
|
961
|
+
let S = v;
|
|
962
|
+
function K(p) {
|
|
963
|
+
return p === w.Sync || p === w.Microtask || p === w.AnimationFrame;
|
|
691
964
|
}
|
|
692
|
-
function
|
|
693
|
-
|
|
965
|
+
function J(p, e) {
|
|
966
|
+
const t = Array.isArray(p) ? p : [p];
|
|
967
|
+
if (t.length === 0)
|
|
968
|
+
throw new TypeError("[RaphMeta] watch requires at least one mask.");
|
|
969
|
+
if (e.namespace !== void 0 && !e.namespace.trim())
|
|
970
|
+
throw new Error("[RaphMeta] namespace must not be empty.");
|
|
971
|
+
for (const r of t)
|
|
972
|
+
x.from(r, e)._asMask();
|
|
694
973
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
974
|
+
function C(p) {
|
|
975
|
+
return p instanceof Error ? p.message : String(p);
|
|
697
976
|
}
|
|
698
977
|
export {
|
|
699
|
-
|
|
978
|
+
S as RaphRuntime
|
|
700
979
|
};
|