@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +46 -47
- package/dist/debug/api/RaphFacadeSession.cjs +1 -1
- package/dist/debug/api/RaphFacadeSession.js +85 -89
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
- package/dist/debug/api/RaphReactivityInstance.js +27 -30
- package/dist/debug/path/DataPath.cjs +1 -1
- package/dist/debug/path/DataPath.js +198 -202
- package/dist/debug/path/PathRouter.cjs +1 -1
- package/dist/debug/path/PathRouter.js +44 -50
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +257 -228
- package/dist/debug/path/data-path.utils.cjs +1 -1
- package/dist/debug/path/data-path.utils.js +41 -41
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
- package/dist/debug/path/derived/DerivedRegistry.js +52 -66
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
- package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
- package/dist/debug/path/derived/derived-collection.utils.js +70 -70
- package/dist/debug/path/meta/MetaController.cjs +1 -1
- package/dist/debug/path/meta/MetaController.js +57 -65
- package/dist/debug/path/meta/RaphMeta.cjs +1 -1
- package/dist/debug/path/meta/RaphMeta.js +26 -32
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
- package/dist/debug/path/meta/RaphMetaStore.js +24 -30
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
- package/dist/debug/path/storage/AdapterPathStore.js +49 -54
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
- package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
- package/dist/debug/path/storage/PathEventHub.cjs +1 -1
- package/dist/debug/path/storage/PathEventHub.js +74 -61
- package/dist/debug/path/storage/PathStore.cjs +1 -1
- package/dist/debug/path/storage/PathStore.js +89 -99
- package/dist/debug/path/storage/createDataDraft.cjs +1 -1
- package/dist/debug/path/storage/createDataDraft.js +24 -28
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +787 -392
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +81 -96
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +764 -411
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +595 -136
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +203 -68
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
- package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
- package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/entrypoints/runtime.d.ts +2 -1
- package/dist/machine-testing.cjs +1 -1
- package/dist/machine-testing.js +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +216 -231
- package/dist/path/RaphKernel.d.ts +24 -0
- package/dist/path/storage/PathEventHub.d.ts +14 -0
- package/dist/path/storage/PathStore.d.ts +4 -4
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +177 -4
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/runtime/RaphRuntime.d.ts +236 -17
- package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
- package/dist/runtime/ownership/RaphNode.d.ts +276 -6
- package/dist/runtime/ownership/RaphScope.d.ts +144 -14
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/phase.types.d.ts +83 -4
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
- package/package.json +9 -1
- package/dist/core-ugchZNqC.cjs +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { RaphKernel as R } from "../path/RaphKernel.js";
|
|
2
|
+
import { RaphSchedulerType as p } from "../runtime/phases/phase.types.js";
|
|
3
|
+
import { RaphRuntime as l } from "../runtime/RaphRuntime.js";
|
|
4
|
+
import { RaphDefaultInstanceError as A, RaphConfigurationError as i, RaphCapabilityError as _, RaphFacadeDisposedError as D } from "./errors.js";
|
|
5
|
+
import { RaphReactivityInstance as w } from "./RaphReactivityInstance.js";
|
|
6
|
+
class f {
|
|
7
|
+
static _runtimeCounter = 0;
|
|
8
|
+
static _reactivityCounter = 0;
|
|
9
|
+
_instances = /* @__PURE__ */ new Map();
|
|
10
|
+
_instanceOrder = [];
|
|
11
|
+
_defaultInstance;
|
|
12
|
+
_disposed = !1;
|
|
10
13
|
constructor() {
|
|
11
|
-
c(this, "_instances", /* @__PURE__ */ new Map());
|
|
12
|
-
c(this, "_instanceOrder", []);
|
|
13
|
-
c(this, "_defaultInstance");
|
|
14
|
-
c(this, "_disposed", !1);
|
|
15
14
|
}
|
|
16
15
|
// ---------------------------------------------
|
|
17
16
|
// PUBLIC API
|
|
@@ -20,17 +19,17 @@ const d = class d {
|
|
|
20
19
|
* Валидирует всю конфигурацию до construction и атомарно создаёт session.
|
|
21
20
|
*/
|
|
22
21
|
static create(e) {
|
|
23
|
-
const t =
|
|
22
|
+
const t = x(e), n = new f(), r = [];
|
|
24
23
|
try {
|
|
25
24
|
for (const a of t) {
|
|
26
|
-
const o =
|
|
27
|
-
|
|
25
|
+
const o = n._construct(a);
|
|
26
|
+
n._register(o), a.default && (n._defaultInstance = o);
|
|
28
27
|
}
|
|
29
|
-
return
|
|
28
|
+
return n;
|
|
30
29
|
} catch (a) {
|
|
31
30
|
r.push(a);
|
|
32
31
|
try {
|
|
33
|
-
|
|
32
|
+
n.dispose();
|
|
34
33
|
} catch (o) {
|
|
35
34
|
o instanceof AggregateError ? r.push(...o.errors) : r.push(o);
|
|
36
35
|
}
|
|
@@ -47,8 +46,7 @@ const d = class d {
|
|
|
47
46
|
* Возвращает ID default instance без создания fallback.
|
|
48
47
|
*/
|
|
49
48
|
get defaultInstanceId() {
|
|
50
|
-
|
|
51
|
-
return (e = this._defaultInstance) == null ? void 0 : e.id;
|
|
49
|
+
return this._defaultInstance?.id;
|
|
52
50
|
}
|
|
53
51
|
/**
|
|
54
52
|
* Возвращает default либо явно адресованный instance.
|
|
@@ -56,10 +54,10 @@ const d = class d {
|
|
|
56
54
|
instance(e) {
|
|
57
55
|
if (this._assertActive(), e === void 0) {
|
|
58
56
|
if (this._defaultInstance === void 0)
|
|
59
|
-
throw new
|
|
57
|
+
throw new A("[Raph] Facade session has no default instance.");
|
|
60
58
|
return this._defaultInstance;
|
|
61
59
|
}
|
|
62
|
-
|
|
60
|
+
c(e);
|
|
63
61
|
const t = this._instances.get(e);
|
|
64
62
|
if (t === void 0)
|
|
65
63
|
throw new i(`[Raph] Instance "${e}" is not registered.`);
|
|
@@ -69,7 +67,7 @@ const d = class d {
|
|
|
69
67
|
* Читает registry без ошибки для неизвестного ID.
|
|
70
68
|
*/
|
|
71
69
|
getInstance(e) {
|
|
72
|
-
return this._assertActive(),
|
|
70
|
+
return this._assertActive(), c(e), this._instances.get(e);
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* Проверяет наличие managed instance.
|
|
@@ -82,8 +80,8 @@ const d = class d {
|
|
|
82
80
|
*/
|
|
83
81
|
runtime(e) {
|
|
84
82
|
const t = this.instance(e);
|
|
85
|
-
if (!(t instanceof
|
|
86
|
-
throw new
|
|
83
|
+
if (!(t instanceof l))
|
|
84
|
+
throw new _(
|
|
87
85
|
`[Raph] Instance "${t.id}" uses reactivity mode and has no Runtime capabilities.`
|
|
88
86
|
);
|
|
89
87
|
return t;
|
|
@@ -93,8 +91,8 @@ const d = class d {
|
|
|
93
91
|
*/
|
|
94
92
|
reactivity(e) {
|
|
95
93
|
const t = this.instance(e);
|
|
96
|
-
if (!(t instanceof
|
|
97
|
-
throw new
|
|
94
|
+
if (!(t instanceof w))
|
|
95
|
+
throw new _(
|
|
98
96
|
`[Raph] Instance "${t.id}" uses runtime mode and is not a pure reactivity instance.`
|
|
99
97
|
);
|
|
100
98
|
return t;
|
|
@@ -105,9 +103,9 @@ const d = class d {
|
|
|
105
103
|
createRuntime(e = {}) {
|
|
106
104
|
this._assertActive();
|
|
107
105
|
const t = e.id ?? this._generateId("runtime");
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
return this._register(
|
|
106
|
+
c(t), this._assertFreeId(t);
|
|
107
|
+
const n = new l({ ...e, id: t });
|
|
108
|
+
return this._register(n), n;
|
|
111
109
|
}
|
|
112
110
|
/**
|
|
113
111
|
* Создаёт managed pure-reactivity instance без изменения default pointer.
|
|
@@ -115,13 +113,13 @@ const d = class d {
|
|
|
115
113
|
createReactivity(e = {}) {
|
|
116
114
|
this._assertActive();
|
|
117
115
|
const t = e.id ?? this._generateId("reactivity");
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
return this._register(
|
|
116
|
+
c(t), this._assertFreeId(t);
|
|
117
|
+
const n = new w(t, e);
|
|
118
|
+
return this._register(n), n;
|
|
121
119
|
}
|
|
122
120
|
/** Создаёт unmanaged Kernel, сохраняя generation-bound lifecycle check. */
|
|
123
121
|
createKernel(e = {}) {
|
|
124
|
-
return this._assertActive(), new
|
|
122
|
+
return this._assertActive(), new R(e);
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* Освобождает managed instance и сразу удаляет его из registry.
|
|
@@ -140,9 +138,9 @@ const d = class d {
|
|
|
140
138
|
const e = [...this._instanceOrder].reverse();
|
|
141
139
|
this._instances.clear(), this._instanceOrder.length = 0, this._defaultInstance = void 0;
|
|
142
140
|
const t = [];
|
|
143
|
-
for (const
|
|
141
|
+
for (const n of e)
|
|
144
142
|
try {
|
|
145
|
-
|
|
143
|
+
n.dispose();
|
|
146
144
|
} catch (r) {
|
|
147
145
|
t.push(r);
|
|
148
146
|
}
|
|
@@ -160,11 +158,11 @@ const d = class d {
|
|
|
160
158
|
_construct(e) {
|
|
161
159
|
if (e.mode === "reactivity") {
|
|
162
160
|
const r = e.config;
|
|
163
|
-
return new
|
|
161
|
+
return new w(e.id, {
|
|
164
162
|
...r.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: r.adaptiveDependencyIndex }
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
|
-
const t = e.config,
|
|
165
|
+
const t = e.config, n = new l({
|
|
168
166
|
...t.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: t.adaptiveDependencyIndex },
|
|
169
167
|
...t.debug === void 0 ? {} : { debug: t.debug },
|
|
170
168
|
...t.enforceActions === void 0 ? {} : { enforceActions: t.enforceActions },
|
|
@@ -173,10 +171,10 @@ const d = class d {
|
|
|
173
171
|
id: e.id
|
|
174
172
|
});
|
|
175
173
|
try {
|
|
176
|
-
return t.phases !== void 0 &&
|
|
174
|
+
return t.phases !== void 0 && n.definePhases(t.phases), n;
|
|
177
175
|
} catch (r) {
|
|
178
176
|
try {
|
|
179
|
-
|
|
177
|
+
n.dispose();
|
|
180
178
|
} catch (a) {
|
|
181
179
|
throw new AggregateError(
|
|
182
180
|
[r, a],
|
|
@@ -206,7 +204,7 @@ const d = class d {
|
|
|
206
204
|
_generateId(e) {
|
|
207
205
|
let t;
|
|
208
206
|
do
|
|
209
|
-
t = e === "runtime" ? `runtime-${
|
|
207
|
+
t = e === "runtime" ? `runtime-${f._runtimeCounter++}` : `reactivity-${f._reactivityCounter++}`;
|
|
210
208
|
while (this._instances.has(t));
|
|
211
209
|
return t;
|
|
212
210
|
}
|
|
@@ -222,85 +220,83 @@ const d = class d {
|
|
|
222
220
|
*/
|
|
223
221
|
_assertActive() {
|
|
224
222
|
if (this._disposed)
|
|
225
|
-
throw new
|
|
223
|
+
throw new D("[Raph] Facade session is disposed.");
|
|
226
224
|
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
function j(n) {
|
|
231
|
-
if (typeof n != "object" || n === null || Array.isArray(n))
|
|
225
|
+
}
|
|
226
|
+
function x(s) {
|
|
227
|
+
if (typeof s != "object" || s === null || Array.isArray(s))
|
|
232
228
|
throw new i("[Raph] Configure options must be an object.");
|
|
233
|
-
if (Object.hasOwn(
|
|
234
|
-
|
|
235
|
-
const r =
|
|
229
|
+
if (Object.hasOwn(s, "instances")) {
|
|
230
|
+
y(s, /* @__PURE__ */ new Set(["instances"]), "configure");
|
|
231
|
+
const r = s.instances;
|
|
236
232
|
if (typeof r != "object" || r === null || Array.isArray(r))
|
|
237
233
|
throw new i("[Raph] instances must be an object.");
|
|
238
234
|
const a = [], o = /* @__PURE__ */ new Set();
|
|
239
|
-
let
|
|
240
|
-
for (const [
|
|
241
|
-
if (typeof
|
|
242
|
-
throw new i(`[Raph] Instance definition "${
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
if (h
|
|
247
|
-
throw new i(`[Raph] Resolved instance id "${
|
|
248
|
-
o.add(
|
|
249
|
-
const
|
|
250
|
-
|
|
235
|
+
let v = 0;
|
|
236
|
+
for (const [g, u] of Object.entries(r)) {
|
|
237
|
+
if (typeof u != "object" || u === null || Array.isArray(u))
|
|
238
|
+
throw new i(`[Raph] Instance definition "${g}" must be an object.`);
|
|
239
|
+
const d = u;
|
|
240
|
+
I(d, !0);
|
|
241
|
+
const h = d.id ?? g;
|
|
242
|
+
if (c(h), o.has(h))
|
|
243
|
+
throw new i(`[Raph] Resolved instance id "${h}" is duplicated.`);
|
|
244
|
+
o.add(h);
|
|
245
|
+
const m = d.default === !0;
|
|
246
|
+
m && v++, a.push({ config: d, default: m, id: h, mode: d.mode });
|
|
251
247
|
}
|
|
252
|
-
if (
|
|
248
|
+
if (v > 1)
|
|
253
249
|
throw new i("[Raph] Exactly one instance may declare default: true.");
|
|
254
250
|
return a;
|
|
255
251
|
}
|
|
256
|
-
const e =
|
|
257
|
-
|
|
258
|
-
const t = e.mode ?? "runtime",
|
|
259
|
-
return
|
|
252
|
+
const e = s;
|
|
253
|
+
I(e, !1);
|
|
254
|
+
const t = e.mode ?? "runtime", n = e.id ?? "default";
|
|
255
|
+
return c(n), [{ config: e, default: !0, id: n, mode: t }];
|
|
260
256
|
}
|
|
261
|
-
function
|
|
262
|
-
const t =
|
|
257
|
+
function I(s, e) {
|
|
258
|
+
const t = s.mode ?? (e ? void 0 : "runtime");
|
|
263
259
|
if (t !== "runtime" && t !== "reactivity")
|
|
264
260
|
throw new i(
|
|
265
261
|
e ? "[Raph] Every instances entry must declare mode." : "[Raph] Unsupported instance mode."
|
|
266
262
|
);
|
|
267
263
|
if (t === "reactivity") {
|
|
268
|
-
if (
|
|
264
|
+
if (y(s, new Set(e ? ["adaptiveDependencyIndex", "default", "id", "mode"] : ["adaptiveDependencyIndex", "id", "mode"]), "reactivity instance"), b(s.adaptiveDependencyIndex), e && s.default !== void 0 && typeof s.default != "boolean")
|
|
269
265
|
throw new i("[Raph] default must be boolean.");
|
|
270
266
|
return;
|
|
271
267
|
}
|
|
272
|
-
if (
|
|
268
|
+
if (y(s, new Set(e ? ["adaptiveDependencyIndex", "debug", "default", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"] : ["adaptiveDependencyIndex", "debug", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"]), "runtime instance"), b(s.adaptiveDependencyIndex), e && s.default !== void 0 && typeof s.default != "boolean")
|
|
273
269
|
throw new i("[Raph] default must be boolean.");
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
270
|
+
const n = s;
|
|
271
|
+
if (n.enforceActions !== void 0 && typeof n.enforceActions != "boolean")
|
|
276
272
|
throw new i("[Raph] enforceActions must be boolean.");
|
|
277
|
-
if (
|
|
273
|
+
if (n.kernel !== void 0 && !(n.kernel instanceof R))
|
|
278
274
|
throw new i("[Raph] kernel must be a RaphKernel instance.");
|
|
279
|
-
if (
|
|
275
|
+
if (n.phases !== void 0 && !Array.isArray(n.phases))
|
|
280
276
|
throw new i("[Raph] phases must be an array.");
|
|
281
|
-
if (
|
|
282
|
-
throw new i(`[Raph] Unsupported scheduler "${String(
|
|
283
|
-
if (
|
|
277
|
+
if (n.scheduler !== void 0 && !k(n.scheduler))
|
|
278
|
+
throw new i(`[Raph] Unsupported scheduler "${String(n.scheduler)}".`);
|
|
279
|
+
if (n.debug !== void 0 && (typeof n.debug != "object" || n.debug === null))
|
|
284
280
|
throw new i("[Raph] debug must be an object.");
|
|
285
281
|
}
|
|
286
|
-
function
|
|
287
|
-
if (
|
|
282
|
+
function b(s) {
|
|
283
|
+
if (s !== void 0 && typeof s != "boolean")
|
|
288
284
|
throw new i("[Raph] adaptiveDependencyIndex must be boolean.");
|
|
289
285
|
}
|
|
290
|
-
function
|
|
291
|
-
for (const
|
|
292
|
-
if (!e.has(
|
|
293
|
-
throw new i(`[Raph] Unsupported ${t} option "${
|
|
286
|
+
function y(s, e, t) {
|
|
287
|
+
for (const n of Object.keys(s))
|
|
288
|
+
if (!e.has(n))
|
|
289
|
+
throw new i(`[Raph] Unsupported ${t} option "${n}".`);
|
|
294
290
|
}
|
|
295
|
-
function
|
|
296
|
-
if (typeof
|
|
291
|
+
function c(s) {
|
|
292
|
+
if (typeof s != "string" || s.length === 0 || s.trim() !== s)
|
|
297
293
|
throw new i(
|
|
298
294
|
"[Raph] Instance id must be a non-empty string without surrounding whitespace."
|
|
299
295
|
);
|
|
300
296
|
}
|
|
301
|
-
function
|
|
302
|
-
return
|
|
297
|
+
function k(s) {
|
|
298
|
+
return s === p.Sync || s === p.Microtask || s === p.AnimationFrame;
|
|
303
299
|
}
|
|
304
300
|
export {
|
|
305
|
-
|
|
301
|
+
f as RaphFacadeSession
|
|
306
302
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../reactivity/engine.cjs"),r=require("../reactivity/reactive-object.cjs"),a=require("../reactivity/scope.cjs"),o=require("../runtime/errors.cjs");class h{constructor(e,t={}){this.id=e,this.engine=new c.RaphReactivity({adaptiveDependencyIndex:t.adaptiveDependencyIndex??!1}),this.rootScope=new a.ScopeNode(this.engine),r.configureReactiveObjectPolicy(this.engine,{owner:this,assertRead:()=>this._assertAlive(),assertWrite:()=>this._assertAlive(),throwForeign:()=>{throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.")}})}mode="reactivity";engine;rootScope;_disposed=!1;_disposedListeners=new Set;get disposed(){return this._disposed}signal(e){return this._assertAlive(),this.rootScope.signal(e)}reactive(e){return this._assertAlive(),this.engine.reactive(e)}computed(e){return this._assertAlive(),typeof e=="function"?this.rootScope.computed(e):this.rootScope.computed(e)}effect(e){return this._assertAlive(),this.rootScope.effect(e)}watch(e,t,i){return this._assertAlive(),this.rootScope.watch(e,t,i)}batch(e){return this._assertAlive(),this.engine.batch(e)}untracked(e){return this._assertAlive(),this.engine.untracked(e)}scope(){this._assertAlive();const e=this.engine.scope();return this.rootScope.own(()=>e.dispose()),e}dispose(){if(this._disposed)return;this._disposed=!0;const e=[];try{this.rootScope.dispose()}catch(s){e.push(s)}const t=()=>{throw new o.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)};try{r.disposeReactiveObjectContext(this.engine,{assertRead:t,assertWrite:t,throwForeign:t})}catch(s){e.push(s)}const i=[...this._disposedListeners];this._disposedListeners.clear();for(const s of i)try{s()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,`[Raph] Reactivity instance "${this.id}" disposal failed.`)}_onDisposed(e){return this._disposed?(e(),()=>{}):(this._disposedListeners.add(e),()=>{this._disposedListeners.delete(e)})}_assertAlive(){if(this._disposed)throw new o.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)}}exports.RaphReactivityInstance=h;
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { ScopeNode as l } from "../reactivity/scope.js";
|
|
7
|
-
import { RaphDisposedError as n } from "../runtime/errors.js";
|
|
8
|
-
class R {
|
|
1
|
+
import { RaphReactivity as n } from "../reactivity/engine.js";
|
|
2
|
+
import { configureReactiveObjectPolicy as h, disposeReactiveObjectContext as a } from "../reactivity/reactive-object.js";
|
|
3
|
+
import { ScopeNode as c } from "../reactivity/scope.js";
|
|
4
|
+
import { RaphDisposedError as r } from "../runtime/errors.js";
|
|
5
|
+
class u {
|
|
9
6
|
/**
|
|
10
7
|
* Создаёт изолированный graph с общим lifecycle owner.
|
|
11
8
|
*/
|
|
12
9
|
constructor(e, t = {}) {
|
|
13
|
-
|
|
14
|
-
i(this, "engine");
|
|
15
|
-
i(this, "rootScope");
|
|
16
|
-
i(this, "_disposed", !1);
|
|
17
|
-
i(this, "_disposedListeners", /* @__PURE__ */ new Set());
|
|
18
|
-
this.id = e, this.engine = new d({
|
|
10
|
+
this.id = e, this.engine = new n({
|
|
19
11
|
adaptiveDependencyIndex: t.adaptiveDependencyIndex ?? !1
|
|
20
|
-
}), this.rootScope = new
|
|
12
|
+
}), this.rootScope = new c(this.engine), h(this.engine, {
|
|
21
13
|
owner: this,
|
|
22
14
|
assertRead: () => this._assertAlive(),
|
|
23
15
|
assertWrite: () => this._assertAlive(),
|
|
@@ -26,6 +18,11 @@ class R {
|
|
|
26
18
|
}
|
|
27
19
|
});
|
|
28
20
|
}
|
|
21
|
+
mode = "reactivity";
|
|
22
|
+
engine;
|
|
23
|
+
rootScope;
|
|
24
|
+
_disposed = !1;
|
|
25
|
+
_disposedListeners = /* @__PURE__ */ new Set();
|
|
29
26
|
// ---------------------------------------------
|
|
30
27
|
// PUBLIC API
|
|
31
28
|
// ---------------------------------------------
|
|
@@ -59,8 +56,8 @@ class R {
|
|
|
59
56
|
/**
|
|
60
57
|
* Создаёт value watch в root scope instance.
|
|
61
58
|
*/
|
|
62
|
-
watch(e, t,
|
|
63
|
-
return this._assertAlive(), this.rootScope.watch(e, t,
|
|
59
|
+
watch(e, t, i) {
|
|
60
|
+
return this._assertAlive(), this.rootScope.watch(e, t, i);
|
|
64
61
|
}
|
|
65
62
|
/**
|
|
66
63
|
* Группирует propagation одного reactive graph.
|
|
@@ -92,28 +89,28 @@ class R {
|
|
|
92
89
|
const e = [];
|
|
93
90
|
try {
|
|
94
91
|
this.rootScope.dispose();
|
|
95
|
-
} catch (
|
|
96
|
-
e.push(
|
|
92
|
+
} catch (s) {
|
|
93
|
+
e.push(s);
|
|
97
94
|
}
|
|
98
95
|
const t = () => {
|
|
99
|
-
throw new
|
|
96
|
+
throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
|
|
100
97
|
};
|
|
101
98
|
try {
|
|
102
|
-
|
|
99
|
+
a(this.engine, {
|
|
103
100
|
assertRead: t,
|
|
104
101
|
assertWrite: t,
|
|
105
102
|
throwForeign: t
|
|
106
103
|
});
|
|
107
|
-
} catch (
|
|
108
|
-
e.push(
|
|
104
|
+
} catch (s) {
|
|
105
|
+
e.push(s);
|
|
109
106
|
}
|
|
110
|
-
const
|
|
107
|
+
const i = [...this._disposedListeners];
|
|
111
108
|
this._disposedListeners.clear();
|
|
112
|
-
for (const
|
|
109
|
+
for (const s of i)
|
|
113
110
|
try {
|
|
114
|
-
|
|
115
|
-
} catch (
|
|
116
|
-
e.push(
|
|
111
|
+
s();
|
|
112
|
+
} catch (o) {
|
|
113
|
+
e.push(o);
|
|
117
114
|
}
|
|
118
115
|
if (e.length === 1)
|
|
119
116
|
throw e[0];
|
|
@@ -141,9 +138,9 @@ class R {
|
|
|
141
138
|
*/
|
|
142
139
|
_assertAlive() {
|
|
143
140
|
if (this._disposed)
|
|
144
|
-
throw new
|
|
141
|
+
throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
export {
|
|
148
|
-
|
|
145
|
+
u as RaphReactivityInstance
|
|
149
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=2e4;class u{static _cache;_canonical;_segments;_exact;_mask;constructor(e,n){this._canonical=e,this._segments=Object.freeze(n.map(i=>Object.freeze({...i})))}static from(e,n){return e instanceof u?e:typeof e=="string"?this.fromString(e,n):this.fromPlain(e)}static fromString(e,n){const i=g(e,n?.vars,!0,n?.wildcardDynamic===!0,!0),s=this._cache??=new Map,r=s.get(i.canonical);if(r!==void 0)return r;s.size>=_&&s.clear();const a=new u(i.canonical,i.segments);return s.set(i.canonical,a),a}static fromPlain(e){const i=(Array.isArray(e.segs)?e.segs:[]).map(N);return new u(m(i),i)}static _parseExactString(e,n){const i=g(e,n?.vars,!1,!1,!0);return{canonical:i.canonical,segments:i.segments}}static _parseMaskString(e){const n=g(e,void 0,!0,!1,!0);for(let r=0;r<n.segments.length-1;r++){const a=n.segments[r];if(a.kind==="wildcard"&&!a.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${e}".`)}const i=n.segments[n.segments.length-1],s=i?.kind==="wildcard"&&!i.indexed;return{canonical:n.canonical,deep:s,segments:s?n.segments.slice(0,-1):n.segments}}static _renderSegments(e){return m(e)}toPlain(){return{segs:this._segments.map(e=>e.kind==="key"?{t:"key",k:e.key}:e.kind==="index"?{t:"idx",i:e.index}:e.kind==="selector"?{t:"param",pk:e.key,pv:e.value}:{t:"wc",indexed:e.indexed}),deepOnTail:b(this._segments)}}toStringPath(){return this._canonical}toString(){return this._canonical}segments(){return this._segments}static match(e,n){const i=this.from(e)._segments,s=this.from(n)._segments;let r=0;for(;r<i.length;r++){const a=i[r];if(a.kind==="wildcard"&&!a.indexed&&r===i.length-1)return!0;const c=s[r];if(c===void 0||!A(a,c))return!1}return r===s.length}_asExact(){for(const e of this._segments)if(e.kind==="wildcard")throw w(this._canonical);return this._exact??={canonical:this._canonical,segments:this._segments}}_asMask(){for(let n=0;n<this._segments.length-1;n++){const i=this._segments[n];if(i.kind==="wildcard"&&!i.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${this._canonical}".`)}const e=b(this._segments);return this._mask??={canonical:this._canonical,deep:e,segments:e?this._segments.slice(0,-1):this._segments}}}function g(t,e,n,i=!1,s=!1){const r=t.trim();if(r.length===0){if(s)return{canonical:"",segments:[]};throw new TypeError("[Raph] Data path must not be empty.")}const a=[];let c=0,o=!0;for(;c<r.length;){const y=r[c];if(y==="."){if(o)throw l(t);o=!0,c++;continue}if(y==="["){const x=$(r,c);a.push(v(r.slice(c+1,x),e,n,i)),c=x+1,o=!1;continue}if(!o)throw l(t);let d=c;for(;d<r.length&&r[d]!=="."&&r[d]!=="[";)d++;const f=r.slice(c,d).trim();if(f.length===0)throw l(t);if(f==="*"){if(!n)throw w(t);a.push({kind:"wildcard",indexed:!1})}else i&&f.startsWith("$")&&!h(f.slice(1),e)?a.push({kind:"wildcard",indexed:!1}):a.push({kind:"key",key:P(f,e)});c=d,o=!1}if(o||a.length===0)throw l(t);return{canonical:m(a),segments:a}}function $(t,e){let n,i=1;for(let s=e+1;s<t.length;s++){const r=t[s];if(r==="\\"){s++;continue}if(n!==void 0){r===n&&(n=void 0);continue}if(r==='"'||r==="'"){n=r;continue}if(r==="["){i++;continue}if(r==="]"&&--i===0)return s}throw l(t)}function v(t,e,n,i){const s=t.trim();if(s==="*"){if(!n)throw w(`[${t}]`);return{kind:"wildcard",indexed:!0}}if(/^\d+$/.test(s))return{kind:"index",index:Number(s)};if(/^\$[A-Z_$][\w$]*$/i.test(s)){if(i&&!h(s.slice(1),e))return{kind:"wildcard",indexed:!0};const o=p(s.slice(1),e);if(!Number.isInteger(o)||o<0)throw new TypeError(`[Raph] Index variable "${s}" must be a non-negative integer.`);return{kind:"index",index:o}}const r=S(s);if(r===-1)throw l(`[${t}]`);const a=s.slice(0,r).trim(),c=s.slice(r+1).trim();if(!a||!c)throw l(`[${t}]`);return i&&R(c,e)?{kind:"wildcard",indexed:!0}:{kind:"selector",key:a,value:E(c,e)}}function S(t){let e;for(let n=0;n<t.length;n++){const i=t[n];if(i==="\\"){n++;continue}if(e!==void 0){i===e&&(e=void 0);continue}if(i==='"'||i==="'")e=i;else if(i==="=")return n}return-1}function E(t,e){if(/^\$[A-Z_$][\w$]*$/i.test(t)){const n=p(t.slice(1),e);if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return n;throw new TypeError(`[Raph] Selector variable "${t}" must be scalar.`)}if(t[0]==='"'||t[0]==="'")return T(t);if(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t)){const n=Number(t);if(Number.isFinite(n))return n}return t==="true"?!0:t==="false"?!1:t==="null"?null:t}function T(t){const e=t[0];if(t.length<2||t[t.length-1]!==e)throw l(t);if(e==='"')try{const i=JSON.parse(t);if(typeof i=="string")return i}catch{throw l(t)}let n="";for(let i=1;i<t.length-1;i++){const s=t[i];if(s==="\\"){if(i++,i>=t.length-1)throw l(t);n+=t[i]}else n+=s}return n}function P(t,e){if(!t.startsWith("$"))return t;const n=p(t.slice(1),e);if(typeof n!="string"&&typeof n!="number")throw new TypeError(`[Raph] Key variable "${t}" must be a string or number.`);const i=String(n);if(!i||i.includes(".")||i.includes("[")||i.includes("]"))throw new TypeError(`[Raph] Key variable "${t}" contains path syntax.`);return i}function p(t,e){if(!h(t,e))throw new TypeError(`[Raph] Missing path variable "${t}".`);return e[t]}function h(t,e){return e!==void 0&&Object.hasOwn(e,t)}function R(t,e){for(const n of t.matchAll(/\$([A-Z_$][\w$]*)/gi))if(!h(n[1],e))return!0;return!1}function N(t){if(typeof t!="object"||t===null)throw k();const e=t;if(e.t==="key"&&typeof e.k=="string")return{kind:"key",key:e.k};if(e.t==="idx"&&typeof e.i=="number"&&Number.isInteger(e.i)&&e.i>=0)return{kind:"index",index:e.i};if(e.t==="wc")return{kind:"wildcard",indexed:e.indexed===!0};if(e.t==="param"&&typeof e.pk=="string"&&O(e.pv))return{kind:"selector",key:e.pk,value:e.pv};throw k()}function O(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function b(t){const e=t[t.length-1];return e?.kind==="wildcard"&&!e.indexed}function A(t,e){return t.kind==="wildcard"?!t.indexed||e.kind==="index"||e.kind==="selector":t.kind!==e.kind?!1:t.kind==="key"?t.key===e.key:t.kind==="index"?t.index===e.index:t.key===e.key&&Object.is(t.value,e.value)}function m(t){let e="";for(const n of t)n.kind==="key"?e+=e?`.${n.key}`:n.key:n.kind==="index"?e+=`[${n.index}]`:n.kind==="selector"?e+=`[${n.key}=${I(n.value)}]`:e+=n.indexed?"[*]":e?".*":"*";return e}function I(t){return typeof t=="string"?JSON.stringify(t):String(t)}function l(t){return new TypeError(`[Raph] Invalid data path "${t}".`)}function k(){return new TypeError("[Raph] Invalid plain DataPath representation.")}function w(t){return new TypeError(`[Raph] Wildcard is only allowed in watch masks: "${t}".`)}exports.DataPath=u;
|