@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.
Files changed (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +9 -1
  107. package/dist/core-ugchZNqC.cjs +0 -1
@@ -1,17 +1,16 @@
1
- var x = Object.defineProperty;
2
- var k = (n, e, t) => e in n ? x(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var c = (n, e, t) => k(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { RaphKernel as D } from "../path/RaphKernel.js";
5
- import { RaphSchedulerType as l } from "../runtime/phases/phase.types.js";
6
- import { RaphRuntime as w } from "../runtime/RaphRuntime.js";
7
- import { RaphDefaultInstanceError as E, RaphConfigurationError as i, RaphCapabilityError as I, RaphFacadeDisposedError as $ } from "./errors.js";
8
- import { RaphReactivityInstance as y } from "./RaphReactivityInstance.js";
9
- const d = class d {
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 = j(e), s = new d(), r = [];
22
+ const t = x(e), n = new f(), r = [];
24
23
  try {
25
24
  for (const a of t) {
26
- const o = s._construct(a);
27
- s._register(o), a.default && (s._defaultInstance = o);
25
+ const o = n._construct(a);
26
+ n._register(o), a.default && (n._defaultInstance = o);
28
27
  }
29
- return s;
28
+ return n;
30
29
  } catch (a) {
31
30
  r.push(a);
32
31
  try {
33
- s.dispose();
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
- var e;
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 E("[Raph] Facade session has no default instance.");
57
+ throw new A("[Raph] Facade session has no default instance.");
60
58
  return this._defaultInstance;
61
59
  }
62
- h(e);
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(), h(e), this._instances.get(e);
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 w))
86
- throw new I(
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 y))
97
- throw new I(
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
- h(t), this._assertFreeId(t);
109
- const s = new w({ ...e, id: t });
110
- return this._register(s), s;
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
- h(t), this._assertFreeId(t);
119
- const s = new y(t, e);
120
- return this._register(s), s;
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 D(e);
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 s of e)
141
+ for (const n of e)
144
142
  try {
145
- s.dispose();
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 y(e.id, {
161
+ return new w(e.id, {
164
162
  ...r.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: r.adaptiveDependencyIndex }
165
163
  });
166
164
  }
167
- const t = e.config, s = new w({
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 && s.definePhases(t.phases), s;
174
+ return t.phases !== void 0 && n.definePhases(t.phases), n;
177
175
  } catch (r) {
178
176
  try {
179
- s.dispose();
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-${d._runtimeCounter++}` : `reactivity-${d._reactivityCounter++}`;
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 $("[Raph] Facade session is disposed.");
223
+ throw new D("[Raph] Facade session is disposed.");
226
224
  }
227
- };
228
- c(d, "_runtimeCounter", 0), c(d, "_reactivityCounter", 0);
229
- let b = d;
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(n, "instances")) {
234
- v(n, /* @__PURE__ */ new Set(["instances"]), "configure");
235
- const r = n.instances;
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 g = 0;
240
- for (const [m, p] of Object.entries(r)) {
241
- if (typeof p != "object" || p === null || Array.isArray(p))
242
- throw new i(`[Raph] Instance definition "${m}" must be an object.`);
243
- const u = p;
244
- R(u, !0);
245
- const f = u.id ?? m;
246
- if (h(f), o.has(f))
247
- throw new i(`[Raph] Resolved instance id "${f}" is duplicated.`);
248
- o.add(f);
249
- const _ = u.default === !0;
250
- _ && g++, a.push({ config: u, default: _, id: f, mode: u.mode });
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 (g > 1)
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 = n;
257
- R(e, !1);
258
- const t = e.mode ?? "runtime", s = e.id ?? "default";
259
- return h(s), [{ config: e, default: !0, id: s, mode: t }];
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 R(n, e) {
262
- const t = n.mode ?? (e ? void 0 : "runtime");
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 (v(n, new Set(e ? ["adaptiveDependencyIndex", "default", "id", "mode"] : ["adaptiveDependencyIndex", "id", "mode"]), "reactivity instance"), A(n.adaptiveDependencyIndex), e && n.default !== void 0 && typeof n.default != "boolean")
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 (v(n, new Set(e ? ["adaptiveDependencyIndex", "debug", "default", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"] : ["adaptiveDependencyIndex", "debug", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"]), "runtime instance"), A(n.adaptiveDependencyIndex), e && n.default !== void 0 && typeof n.default != "boolean")
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 s = n;
275
- if (s.enforceActions !== void 0 && typeof s.enforceActions != "boolean")
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 (s.kernel !== void 0 && !(s.kernel instanceof D))
273
+ if (n.kernel !== void 0 && !(n.kernel instanceof R))
278
274
  throw new i("[Raph] kernel must be a RaphKernel instance.");
279
- if (s.phases !== void 0 && !Array.isArray(s.phases))
275
+ if (n.phases !== void 0 && !Array.isArray(n.phases))
280
276
  throw new i("[Raph] phases must be an array.");
281
- if (s.scheduler !== void 0 && !O(s.scheduler))
282
- throw new i(`[Raph] Unsupported scheduler "${String(s.scheduler)}".`);
283
- if (s.debug !== void 0 && (typeof s.debug != "object" || s.debug === null))
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 A(n) {
287
- if (n !== void 0 && typeof n != "boolean")
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 v(n, e, t) {
291
- for (const s of Object.keys(n))
292
- if (!e.has(s))
293
- throw new i(`[Raph] Unsupported ${t} option "${s}".`);
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 h(n) {
296
- if (typeof n != "string" || n.length === 0 || n.trim() !== n)
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 O(n) {
302
- return n === l.Sync || n === l.Microtask || n === l.AnimationFrame;
297
+ function k(s) {
298
+ return s === p.Sync || s === p.Microtask || s === p.AnimationFrame;
303
299
  }
304
300
  export {
305
- b as RaphFacadeSession
301
+ f as RaphFacadeSession
306
302
  };
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var d=(s,e,t)=>e in s?h(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>d(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../reactivity/engine.cjs"),n=require("../reactivity/reactive-object.cjs"),u=require("../reactivity/scope.cjs"),c=require("../runtime/errors.cjs");class v{constructor(e,t={}){i(this,"mode","reactivity");i(this,"engine");i(this,"rootScope");i(this,"_disposed",!1);i(this,"_disposedListeners",new Set);this.id=e,this.engine=new p.RaphReactivity({adaptiveDependencyIndex:t.adaptiveDependencyIndex??!1}),this.rootScope=new u.ScopeNode(this.engine),n.configureReactiveObjectPolicy(this.engine,{owner:this,assertRead:()=>this._assertAlive(),assertWrite:()=>this._assertAlive(),throwForeign:()=>{throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.")}})}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,o){return this._assertAlive(),this.rootScope.watch(e,t,o)}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(r){e.push(r)}const t=()=>{throw new c.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)};try{n.disposeReactiveObjectContext(this.engine,{assertRead:t,assertWrite:t,throwForeign:t})}catch(r){e.push(r)}const o=[...this._disposedListeners];this._disposedListeners.clear();for(const r of o)try{r()}catch(a){e.push(a)}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 c.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)}}exports.RaphReactivityInstance=v;
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
- var a = Object.defineProperty;
2
- var c = (s, e, t) => e in s ? a(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var i = (s, e, t) => c(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { RaphReactivity as d } from "../reactivity/engine.js";
5
- import { configureReactiveObjectPolicy as p, disposeReactiveObjectContext as v } from "../reactivity/reactive-object.js";
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
- i(this, "mode", "reactivity");
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 l(this.engine), p(this.engine, {
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, o) {
63
- return this._assertAlive(), this.rootScope.watch(e, t, o);
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 (r) {
96
- e.push(r);
92
+ } catch (s) {
93
+ e.push(s);
97
94
  }
98
95
  const t = () => {
99
- throw new n(`[Raph] Reactivity instance "${this.id}" is disposed.`);
96
+ throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
100
97
  };
101
98
  try {
102
- v(this.engine, {
99
+ a(this.engine, {
103
100
  assertRead: t,
104
101
  assertWrite: t,
105
102
  throwForeign: t
106
103
  });
107
- } catch (r) {
108
- e.push(r);
104
+ } catch (s) {
105
+ e.push(s);
109
106
  }
110
- const o = [...this._disposedListeners];
107
+ const i = [...this._disposedListeners];
111
108
  this._disposedListeners.clear();
112
- for (const r of o)
109
+ for (const s of i)
113
110
  try {
114
- r();
115
- } catch (h) {
116
- e.push(h);
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 n(`[Raph] Reactivity instance "${this.id}" is disposed.`);
141
+ throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
145
142
  }
146
143
  }
147
144
  export {
148
- R as RaphReactivityInstance
145
+ u as RaphReactivityInstance
149
146
  };
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var S=(t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>S(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=2e4,u=class u{constructor(e,n){f(this,"_canonical");f(this,"_segments");f(this,"_exact");f(this,"_mask");this._canonical=e,this._segments=Object.freeze(n.map(r=>Object.freeze({...r})))}static from(e,n){return e instanceof u?e:typeof e=="string"?this.fromString(e,n):this.fromPlain(e)}static fromString(e,n){const r=m(e,n==null?void 0:n.vars,!0,(n==null?void 0:n.wildcardDynamic)===!0,!0),s=this._cache??(this._cache=new Map),i=s.get(r.canonical);if(i!==void 0)return i;s.size>=E&&s.clear();const c=new u(r.canonical,r.segments);return s.set(r.canonical,c),c}static fromPlain(e){const r=(Array.isArray(e.segs)?e.segs:[]).map(M);return new u(y(r),r)}static _parseExactString(e,n){const r=m(e,n==null?void 0:n.vars,!1,!1,!0);return{canonical:r.canonical,segments:r.segments}}static _parseMaskString(e){const n=m(e,void 0,!0,!1,!0);for(let i=0;i<n.segments.length-1;i++){const c=n.segments[i];if(c.kind==="wildcard"&&!c.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${e}".`)}const r=n.segments[n.segments.length-1],s=(r==null?void 0:r.kind)==="wildcard"&&!r.indexed;return{canonical:n.canonical,deep:s,segments:s?n.segments.slice(0,-1):n.segments}}static _renderSegments(e){return y(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:_(this._segments)}}toStringPath(){return this._canonical}toString(){return this._canonical}segments(){return this._segments}static match(e,n){const r=this.from(e)._segments,s=this.from(n)._segments;let i=0;for(;i<r.length;i++){const c=r[i];if(c.kind==="wildcard"&&!c.indexed&&i===r.length-1)return!0;const a=s[i];if(a===void 0||!q(c,a))return!1}return i===s.length}_asExact(){for(const e of this._segments)if(e.kind==="wildcard")throw x(this._canonical);return this._exact??(this._exact={canonical:this._canonical,segments:this._segments})}_asMask(){for(let n=0;n<this._segments.length-1;n++){const r=this._segments[n];if(r.kind==="wildcard"&&!r.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${this._canonical}".`)}const e=_(this._segments);return this._mask??(this._mask={canonical:this._canonical,deep:e,segments:e?this._segments.slice(0,-1):this._segments})}};f(u,"_cache");let w=u;function m(t,e,n,r=!1,s=!1){const i=t.trim();if(i.length===0){if(s)return{canonical:"",segments:[]};throw new TypeError("[Raph] Data path must not be empty.")}const c=[];let a=0,l=!0;for(;a<i.length;){const b=i[a];if(b==="."){if(l)throw d(t);l=!0,a++;continue}if(b==="["){const k=T(i,a);c.push(P(i.slice(a+1,k),e,n,r)),a=k+1,l=!1;continue}if(!l)throw d(t);let o=a;for(;o<i.length&&i[o]!=="."&&i[o]!=="[";)o++;const h=i.slice(a,o).trim();if(h.length===0)throw d(t);if(h==="*"){if(!n)throw x(t);c.push({kind:"wildcard",indexed:!1})}else r&&h.startsWith("$")&&!g(h.slice(1),e)?c.push({kind:"wildcard",indexed:!1}):c.push({kind:"key",key:A(h,e)});a=o,l=!1}if(l||c.length===0)throw d(t);return{canonical:y(c),segments:c}}function T(t,e){let n,r=1;for(let s=e+1;s<t.length;s++){const i=t[s];if(i==="\\"){s++;continue}if(n!==void 0){i===n&&(n=void 0);continue}if(i==='"'||i==="'"){n=i;continue}if(i==="["){r++;continue}if(i==="]"&&--r===0)return s}throw d(t)}function P(t,e,n,r){const s=t.trim();if(s==="*"){if(!n)throw x(`[${t}]`);return{kind:"wildcard",indexed:!0}}if(/^\d+$/.test(s))return{kind:"index",index:Number(s)};if(/^\$[A-Z_$][\w$]*$/i.test(s)){if(r&&!g(s.slice(1),e))return{kind:"wildcard",indexed:!0};const l=p(s.slice(1),e);if(!Number.isInteger(l)||l<0)throw new TypeError(`[Raph] Index variable "${s}" must be a non-negative integer.`);return{kind:"index",index:l}}const i=R(s);if(i===-1)throw d(`[${t}]`);const c=s.slice(0,i).trim(),a=s.slice(i+1).trim();if(!c||!a)throw d(`[${t}]`);return r&&I(a,e)?{kind:"wildcard",indexed:!0}:{kind:"selector",key:c,value:N(a,e)}}function R(t){let e;for(let n=0;n<t.length;n++){const r=t[n];if(r==="\\"){n++;continue}if(e!==void 0){r===e&&(e=void 0);continue}if(r==='"'||r==="'")e=r;else if(r==="=")return n}return-1}function N(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 O(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 O(t){const e=t[0];if(t.length<2||t[t.length-1]!==e)throw d(t);if(e==='"')try{const r=JSON.parse(t);if(typeof r=="string")return r}catch{throw d(t)}let n="";for(let r=1;r<t.length-1;r++){const s=t[r];if(s==="\\"){if(r++,r>=t.length-1)throw d(t);n+=t[r]}else n+=s}return n}function A(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 r=String(n);if(!r||r.includes(".")||r.includes("[")||r.includes("]"))throw new TypeError(`[Raph] Key variable "${t}" contains path syntax.`);return r}function p(t,e){if(!g(t,e))throw new TypeError(`[Raph] Missing path variable "${t}".`);return e[t]}function g(t,e){return e!==void 0&&Object.hasOwn(e,t)}function I(t,e){for(const n of t.matchAll(/\$([A-Z_$][\w$]*)/gi))if(!g(n[1],e))return!0;return!1}function M(t){if(typeof t!="object"||t===null)throw $();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"&&j(e.pv))return{kind:"selector",key:e.pk,value:e.pv};throw $()}function j(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function _(t){const e=t[t.length-1];return(e==null?void 0:e.kind)==="wildcard"&&!e.indexed}function q(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 y(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}=${D(n.value)}]`:e+=n.indexed?"[*]":e?".*":"*";return e}function D(t){return typeof t=="string"?JSON.stringify(t):String(t)}function d(t){return new TypeError(`[Raph] Invalid data path "${t}".`)}function $(){return new TypeError("[Raph] Invalid plain DataPath representation.")}function x(t){return new TypeError(`[Raph] Wildcard is only allowed in watch masks: "${t}".`)}exports.DataPath=w;
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;