@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,16 +1,11 @@
1
- var p = Object.defineProperty;
2
- var _ = (n, e, t) => e in n ? p(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var h = (n, e, t) => _(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { pathSegmentKey as m } from "../pathSegmentKey.js";
5
- function f() {
1
+ import { pathSegmentKey as u } from "../pathSegmentKey.js";
2
+ function d() {
6
3
  return { children: /* @__PURE__ */ new Map(), namespaces: /* @__PURE__ */ new Map(), path: void 0 };
7
4
  }
8
- class v {
9
- constructor() {
10
- // Хранят metadata tree и точное число записанных namespaces.
11
- h(this, "_root", f());
12
- h(this, "size", 0);
13
- }
5
+ class m {
6
+ // Хранят metadata tree и точное число записанных namespaces.
7
+ _root = d();
8
+ size = 0;
14
9
  /**
15
10
  * Возвращает значение по пути без создания отсутствующих данных.
16
11
  */
@@ -38,9 +33,9 @@ class v {
38
33
  */
39
34
  merge(e, t, r) {
40
35
  const s = this.get(e, t);
41
- if (l(s) && l(r)) {
36
+ if (f(s) && f(r)) {
42
37
  for (const i of Object.keys(r))
43
- g(s, i, r[i]);
38
+ p(s, i, r[i]);
44
39
  return;
45
40
  }
46
41
  this.set(e, t, r);
@@ -49,8 +44,7 @@ class v {
49
44
  * Удаляет namespace либо все metadata указанного owner.
50
45
  */
51
46
  delete(e, t) {
52
- var i;
53
- const r = this._findStack(e), s = (i = r.at(-1)) == null ? void 0 : i.node;
47
+ const r = this._findStack(e), s = r.at(-1)?.node;
54
48
  if (s === void 0)
55
49
  return !1;
56
50
  if (t === void 0) {
@@ -73,16 +67,16 @@ class v {
73
67
  return this.clear();
74
68
  let r = this._root;
75
69
  for (let c = 0; c < t.length - 1; c++) {
76
- const d = r.children.get(t[c]);
77
- if (d === void 0)
70
+ const a = r.children.get(t[c]);
71
+ if (a === void 0)
78
72
  return [];
79
- r = d;
73
+ r = a;
80
74
  }
81
75
  const s = r.children.get(t.at(-1));
82
76
  if (s === void 0)
83
77
  return [];
84
- const i = a(s);
85
- return this.size -= u(s), r.children.delete(t.at(-1)), i;
78
+ const i = h(s);
79
+ return this.size -= l(s), r.children.delete(t.at(-1)), i;
86
80
  }
87
81
  /**
88
82
  * Удаляет metadata, владельцы которой отсутствуют в data tree.
@@ -98,7 +92,7 @@ class v {
98
92
  * Полностью очищает metadata storage.
99
93
  */
100
94
  clear() {
101
- const e = a(this._root);
95
+ const e = h(this._root);
102
96
  return this._root.children.clear(), this._root.namespaces.clear(), this._root.path = void 0, this.size = 0, e;
103
97
  }
104
98
  _find(e) {
@@ -115,7 +109,7 @@ class v {
115
109
  let t = this._root;
116
110
  for (const r of o(e)) {
117
111
  let s = t.children.get(r);
118
- s === void 0 && (s = f(), t.children.set(r, s)), t = s;
112
+ s === void 0 && (s = d(), t.children.set(r, s)), t = s;
119
113
  }
120
114
  return t;
121
115
  }
@@ -147,27 +141,27 @@ class v {
147
141
  }
148
142
  }
149
143
  function o(n) {
150
- return n.segments().map(m);
144
+ return n.segments().map(u);
151
145
  }
152
- function a(n) {
146
+ function h(n) {
153
147
  const e = n.path !== void 0 && n.namespaces.size !== 0 ? [n.path] : [];
154
148
  for (const t of n.children.values())
155
- e.push(...a(t));
149
+ e.push(...h(t));
156
150
  return e;
157
151
  }
158
- function u(n) {
152
+ function l(n) {
159
153
  let e = n.namespaces.size;
160
154
  for (const t of n.children.values())
161
- e += u(t);
155
+ e += l(t);
162
156
  return e;
163
157
  }
164
- function l(n) {
158
+ function f(n) {
165
159
  if (typeof n != "object" || n === null || Array.isArray(n))
166
160
  return !1;
167
161
  const e = Object.getPrototypeOf(n);
168
162
  return e === Object.prototype || e === null;
169
163
  }
170
- function g(n, e, t) {
164
+ function p(n, e, t) {
171
165
  if (e !== "__proto__") {
172
166
  n[e] = t;
173
167
  return;
@@ -180,5 +174,5 @@ function g(n, e, t) {
180
174
  });
181
175
  }
182
176
  export {
183
- v as RaphMetaStore
177
+ m as RaphMetaStore
184
178
  };
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var l=(r,t,e)=>t in r?p(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var d=(r,t,e)=>l(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../data-path.utils.cjs"),_=require("./PathEventHub.cjs");class b{constructor(t){d(this,"_eventHub",new _.PathEventHub("[Raph] Adapter batch and publication failed."));this._adapter=t}get(t,e){const a=i.parseDataPath(t,e);return this._adapter.get(a.canonical)}peek(t,e){return this.get(t,e)}has(t,e){var n,s;const a=i.parseDataPath(t,e);return((s=(n=this._adapter).has)==null?void 0:s.call(n,a.canonical))??u(this._adapter.root(),a.segments)}set(t,e,a){const n=i.parseDataPath(t,a),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0;this._adapter.set(n.canonical,e),this._eventHub.record({kind:"set",path:n.canonical,previous:s,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}merge(t,e,a){const n=i.parseDataPath(t,a),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0,c=o(s)&&o(e)?f(s):s;this._adapter.merge(n.canonical,e),this._eventHub.record({kind:"merge",path:n.canonical,previous:c,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}delete(t,e){var c,h;const a=i.parseDataPath(t,e);if(!(((h=(c=this._adapter).has)==null?void 0:h.call(c,a.canonical))??u(this._adapter.root(),a.segments)))return;const s=this._eventHub.hasWatchers?this._adapter.get(a.canonical):void 0;this._adapter.delete(a.canonical),this._eventHub.record({kind:"delete",path:a.canonical,previous:s,value:void 0})}batch(t){return this._eventHub.batch(t)}watch(t,e){return this._eventHub.watch(t,e)}}function u(r,t){let e=r;for(const a of t)if(a.kind==="key"){if(!v(e)||!Object.hasOwn(e,a.key))return!1;e=e[a.key]}else if(a.kind==="index"){if(!Array.isArray(e)||!Object.hasOwn(e,a.index))return!1;e=e[a.index]}else{if(!Array.isArray(e))return!1;const n=e.findIndex(s=>o(s)&&Object.hasOwn(s,a.key)&&Object.is(s[a.key],a.value));if(n===-1)return!1;e=e[n]}return!0}function f(r){const t=Object.create(Object.getPrototypeOf(r));for(const e of Object.keys(r))e==="__proto__"?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:r[e],writable:!0}):t[e]=r[e];return t}function o(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function v(r){return Array.isArray(r)||o(r)}exports.AdapterPathStore=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../data-path.utils.cjs"),d=require("./PathEventHub.cjs");class u{constructor(a){this._adapter=a}_eventHub=new d.PathEventHub("[Raph] Adapter batch and publication failed.");get(a,e){const t=i.parseDataPath(a,e);return this._adapter.get(t.canonical)}peek(a,e){return this.get(a,e)}has(a,e){const t=i.parseDataPath(a,e);return this._adapter.has?.(t.canonical)??o(this._adapter.root(),t.segments)}set(a,e,t){const n=i.parseDataPath(a,t),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0;this._adapter.set(n.canonical,e),this._eventHub.record({kind:"set",path:n.canonical,previous:s,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}merge(a,e,t){const n=i.parseDataPath(a,t),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0,h=c(s)&&c(e)?p(s):s;this._adapter.merge(n.canonical,e),this._eventHub.record({kind:"merge",path:n.canonical,previous:h,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}delete(a,e){const t=i.parseDataPath(a,e);if(!(this._adapter.has?.(t.canonical)??o(this._adapter.root(),t.segments)))return;const s=this._eventHub.hasWatchers?this._adapter.get(t.canonical):void 0;this._adapter.delete(t.canonical),this._eventHub.record({kind:"delete",path:t.canonical,previous:s,value:void 0})}batch(a){return this._eventHub.batch(a)}watch(a,e){return this._eventHub.watch(a,e)}}function o(r,a){let e=r;for(const t of a)if(t.kind==="key"){if(!l(e)||!Object.hasOwn(e,t.key))return!1;e=e[t.key]}else if(t.kind==="index"){if(!Array.isArray(e)||!Object.hasOwn(e,t.index))return!1;e=e[t.index]}else{if(!Array.isArray(e))return!1;const n=e.findIndex(s=>c(s)&&Object.hasOwn(s,t.key)&&Object.is(s[t.key],t.value));if(n===-1)return!1;e=e[n]}return!0}function p(r){const a=Object.create(Object.getPrototypeOf(r));for(const e of Object.keys(r))e==="__proto__"?Object.defineProperty(a,e,{configurable:!0,enumerable:!0,value:r[e],writable:!0}):a[e]=r[e];return a}function c(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function l(r){return Array.isArray(r)||c(r)}exports.AdapterPathStore=u;
@@ -1,45 +1,41 @@
1
- var p = Object.defineProperty;
2
- var l = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var d = (r, t, e) => l(r, typeof t != "symbol" ? t + "" : t, e);
4
1
  import { parseDataPath as i } from "../data-path.utils.js";
5
- import { PathEventHub as _ } from "./PathEventHub.js";
6
- class k {
2
+ import { PathEventHub as d } from "./PathEventHub.js";
3
+ class b {
7
4
  /**
8
5
  * Связывает внешний DataAdapter с path events и watchers Kernel.
9
6
  */
10
- constructor(t) {
11
- // Публикует изменения внешнего adapter через общий path event lifecycle.
12
- d(this, "_eventHub", new _(
13
- "[Raph] Adapter batch and publication failed."
14
- ));
15
- this._adapter = t;
7
+ constructor(a) {
8
+ this._adapter = a;
16
9
  }
10
+ // Публикует изменения внешнего adapter через общий path event lifecycle.
11
+ _eventHub = new d(
12
+ "[Raph] Adapter batch and publication failed."
13
+ );
17
14
  /**
18
15
  * Возвращает значение по пути без создания отсутствующих данных.
19
16
  */
20
- get(t, e) {
21
- const a = i(t, e);
22
- return this._adapter.get(a.canonical);
17
+ get(a, e) {
18
+ const t = i(a, e);
19
+ return this._adapter.get(t.canonical);
23
20
  }
24
21
  /**
25
22
  * Читает значение по пути без регистрации реактивной зависимости.
26
23
  */
27
- peek(t, e) {
28
- return this.get(t, e);
24
+ peek(a, e) {
25
+ return this.get(a, e);
29
26
  }
30
27
  /**
31
28
  * Проверяет наличие значения по указанному пути.
32
29
  */
33
- has(t, e) {
34
- var n, s;
35
- const a = i(t, e);
36
- return ((s = (n = this._adapter).has) == null ? void 0 : s.call(n, a.canonical)) ?? u(this._adapter.root(), a.segments);
30
+ has(a, e) {
31
+ const t = i(a, e);
32
+ return this._adapter.has?.(t.canonical) ?? o(this._adapter.root(), t.segments);
37
33
  }
38
34
  /**
39
35
  * Записывает значение и публикует соответствующее изменение.
40
36
  */
41
- set(t, e, a) {
42
- const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0;
37
+ set(a, e, t) {
38
+ const n = i(a, t), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0;
43
39
  this._adapter.set(n.canonical, e), this._eventHub.record({
44
40
  kind: "set",
45
41
  path: n.canonical,
@@ -50,27 +46,26 @@ class k {
50
46
  /**
51
47
  * Объединяет значение по пути и публикует соответствующее изменение.
52
48
  */
53
- merge(t, e, a) {
54
- const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0, c = o(s) && o(e) ? b(s) : s;
49
+ merge(a, e, t) {
50
+ const n = i(a, t), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0, h = c(s) && c(e) ? u(s) : s;
55
51
  this._adapter.merge(n.canonical, e), this._eventHub.record({
56
52
  kind: "merge",
57
53
  path: n.canonical,
58
- previous: c,
54
+ previous: h,
59
55
  value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
60
56
  });
61
57
  }
62
58
  /**
63
59
  * Удаляет значение по пути и публикует изменение при наличии данных.
64
60
  */
65
- delete(t, e) {
66
- var c, h;
67
- const a = i(t, e);
68
- if (!(((h = (c = this._adapter).has) == null ? void 0 : h.call(c, a.canonical)) ?? u(this._adapter.root(), a.segments)))
61
+ delete(a, e) {
62
+ const t = i(a, e);
63
+ if (!(this._adapter.has?.(t.canonical) ?? o(this._adapter.root(), t.segments)))
69
64
  return;
70
- const s = this._eventHub.hasWatchers ? this._adapter.get(a.canonical) : void 0;
71
- this._adapter.delete(a.canonical), this._eventHub.record({
65
+ const s = this._eventHub.hasWatchers ? this._adapter.get(t.canonical) : void 0;
66
+ this._adapter.delete(t.canonical), this._eventHub.record({
72
67
  kind: "delete",
73
- path: a.canonical,
68
+ path: t.canonical,
74
69
  previous: s,
75
70
  value: void 0
76
71
  });
@@ -78,32 +73,32 @@ class k {
78
73
  /**
79
74
  * Выполняет операцию в общей синхронной batch boundary.
80
75
  */
81
- batch(t) {
82
- return this._eventHub.batch(t);
76
+ batch(a) {
77
+ return this._eventHub.batch(a);
83
78
  }
84
79
  /**
85
80
  * Подписывает callback на подходящие изменения и возвращает disposer.
86
81
  */
87
- watch(t, e) {
88
- return this._eventHub.watch(t, e);
82
+ watch(a, e) {
83
+ return this._eventHub.watch(a, e);
89
84
  }
90
85
  }
91
- function u(r, t) {
86
+ function o(r, a) {
92
87
  let e = r;
93
- for (const a of t)
94
- if (a.kind === "key") {
95
- if (!f(e) || !Object.hasOwn(e, a.key))
88
+ for (const t of a)
89
+ if (t.kind === "key") {
90
+ if (!p(e) || !Object.hasOwn(e, t.key))
96
91
  return !1;
97
- e = e[a.key];
98
- } else if (a.kind === "index") {
99
- if (!Array.isArray(e) || !Object.hasOwn(e, a.index))
92
+ e = e[t.key];
93
+ } else if (t.kind === "index") {
94
+ if (!Array.isArray(e) || !Object.hasOwn(e, t.index))
100
95
  return !1;
101
- e = e[a.index];
96
+ e = e[t.index];
102
97
  } else {
103
98
  if (!Array.isArray(e))
104
99
  return !1;
105
100
  const n = e.findIndex(
106
- (s) => o(s) && Object.hasOwn(s, a.key) && Object.is(s[a.key], a.value)
101
+ (s) => c(s) && Object.hasOwn(s, t.key) && Object.is(s[t.key], t.value)
107
102
  );
108
103
  if (n === -1)
109
104
  return !1;
@@ -111,23 +106,23 @@ function u(r, t) {
111
106
  }
112
107
  return !0;
113
108
  }
114
- function b(r) {
115
- const t = Object.create(Object.getPrototypeOf(r));
109
+ function u(r) {
110
+ const a = Object.create(Object.getPrototypeOf(r));
116
111
  for (const e of Object.keys(r))
117
- e === "__proto__" ? Object.defineProperty(t, e, {
112
+ e === "__proto__" ? Object.defineProperty(a, e, {
118
113
  configurable: !0,
119
114
  enumerable: !0,
120
115
  value: r[e],
121
116
  writable: !0
122
- }) : t[e] = r[e];
123
- return t;
117
+ }) : a[e] = r[e];
118
+ return a;
124
119
  }
125
- function o(r) {
120
+ function c(r) {
126
121
  return typeof r == "object" && r !== null && !Array.isArray(r);
127
122
  }
128
- function f(r) {
129
- return Array.isArray(r) || o(r);
123
+ function p(r) {
124
+ return Array.isArray(r) || c(r);
130
125
  }
131
126
  export {
132
- k as AdapterPathStore
127
+ b as AdapterPathStore
133
128
  };
@@ -1 +1 @@
1
- "use strict";var j=Object.defineProperty;var S=(o,e,t)=>e in o?j(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var y=(o,e,t)=>S(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../data-path.utils.cjs"),C=require("./createDataDraft.cjs");class g{constructor(e=p(),t={}){y(this,"_root");y(this,"_options");y(this,"_indexes");this._root=x(e),this._options={arrayDelete:t.arrayDelete??"unset",autoCreate:t.autoCreate??!0,indexEnabled:t.indexEnabled??!0,indexStrategy:t.indexStrategy??"eager-all-keys"}}root(){return this._root}fork(){const e=new g({},this._options);return e._root=C.createDataDraft(this._root,t=>{var r;return(r=e._indexes)==null?void 0:r.delete(t)}).root,e}replaceRoot(e){this._root=x(e),this._indexes=void 0}options(e){e.arrayDelete!==void 0&&(this._options.arrayDelete=e.arrayDelete),e.autoCreate!==void 0&&(this._options.autoCreate=e.autoCreate),e.indexEnabled!==void 0&&(this._options.indexEnabled=e.indexEnabled),e.indexStrategy!==void 0&&(this._options.indexStrategy=e.indexStrategy),this._indexes=void 0}get(e,t){return this._read(h.parseDataPath(e,t)).value}has(e,t){return this._read(h.parseDataPath(e,t)).exists}set(e,t,r){const i=h.parseDataPath(e,r);if(i.segments.length===0){this.replaceRoot(x(t));return}let s=this._root,n;for(let a=0;a<i.segments.length-1;a++){const d=i.segments[a],c=i.segments[a+1],l=this._readOrCreateChild(s,d,c,i.canonical);s=l.value,n=l.indexedParent}this._writeSegment(s,i.segments[i.segments.length-1],t,i.canonical,n)}merge(e,t,r){const i=this.get(e,r);if(f(i)&&f(t)){for(const s of Object.keys(t))b(i,s,t[s]);this._indexes=void 0;return}this.set(e,t,r)}delete(e,t){const r=h.parseDataPath(e,t);if(r.segments.length===0){this._root=p(),this._indexes=void 0;return}let i=this._root;for(let n=0;n<r.segments.length-1;n++){if(!u(i))return;i=this._readSegment(i,r.segments[n])}if(!u(i))return;const s=r.segments[r.segments.length-1];if(s.kind==="key")delete i[s.key];else if(s.kind==="index"){if(!Array.isArray(i))return;this._options.arrayDelete==="splice"?i.splice(s.index,1):delete i[s.index]}else{if(!Array.isArray(i))return;const n=this._findSelector(i,s.key,s.value);if(n===-1)return;this._options.arrayDelete==="splice"?i.splice(n,1):delete i[n]}this._indexes=void 0}indexOf(e,t){const r=h.parseDataPath(e,t);let i=this._root;for(let s=0;s<r.segments.length;s++){const n=r.segments[s],a=s===r.segments.length-1;if(n.kind==="key"){if(!u(i)||!Object.hasOwn(i,n.key))return-1;i=i[n.key];continue}if(!Array.isArray(i))return-1;if(n.kind==="index"){if(!Object.hasOwn(i,n.index))return-1;if(a)return n.index;i=i[n.index];continue}const d=this._findSelector(i,n.key,n.value);if(d===-1)return-1;if(a)return d;i=i[d]}return-1}_read(e){let t=this._root;for(const r of e.segments)if(r.kind==="key"){if(!u(t)||!Object.hasOwn(t,r.key))return{exists:!1,value:void 0};t=t[r.key]}else if(r.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,r.index))return{exists:!1,value:void 0};t=t[r.index]}else{if(!Array.isArray(t))return{exists:!1,value:void 0};const i=this._findSelector(t,r.key,r.value);if(i===-1)return{exists:!1,value:void 0};t=t[i]}return{exists:!0,value:t}}_readSegment(e,t){if(t.kind==="key")return Object.hasOwn(e,t.key)?e[t.key]:void 0;if(!Array.isArray(e))return;if(t.kind==="index")return e[t.index];const r=this._findSelector(e,t.key,t.value);return r===-1?void 0:e[r]}_readOrCreateChild(e,t,r,i){if(t.kind==="key"){let n=e[t.key];if(!Object.hasOwn(e,t.key)||n===void 0){if(!this._options.autoCreate)throw _(i);n=v(r),b(e,t.key,n)}return{value:k(n,i)}}if(!Array.isArray(e))throw w(i);if(t.kind==="index"){let n=e[t.index];if(!Object.hasOwn(e,t.index)||n===void 0){if(!this._options.autoCreate)throw _(i);n=v(r),e[t.index]=n}return{value:k(n,i),indexedParent:{array:e,index:t.index}}}let s=this._findSelector(e,t.key,t.value);if(s===-1){if(!this._options.autoCreate)throw _(i);const n=Object.create(null);n[t.key]=t.value,e.push(n),s=e.length-1,this._invalidateArray(e)}return{value:k(e[s],i),indexedParent:{array:e,index:s}}}_writeSegment(e,t,r,i,s){if(t.kind==="key"){b(e,t.key,r),s!==void 0&&s.array[s.index]===e&&this._invalidateIndexKey(s.array,t.key);return}if(!Array.isArray(e))throw w(i);if(t.kind==="index"){e[t.index]=r,this._invalidateArray(e);return}if(!f(r))throw new TypeError(`[Raph] New selector target at "${i}" must be an object.`);if(Object.hasOwn(r,t.key)&&!Object.is(r[t.key],t.value))throw new TypeError(`[Raph] Selector target at "${i}" has a conflicting key.`);const n=this._findSelector(e,t.key,t.value);if(n===-1&&!this._options.autoCreate)throw _(i);const a=Object.hasOwn(r,t.key)?r:{...r,[t.key]:t.value};n===-1?e.push(a):e[n]=a,this._invalidateArray(e)}_invalidateArray(e){var t;(t=this._indexes)==null||t.delete(e)}_invalidateIndexKey(e,t){var i;const r=(i=this._indexes)==null?void 0:i.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._indexes.delete(e))}_findSelector(e,t,r){var d;if(!this._options.indexEnabled)return O(e,t,r);const i=(d=this._indexes)==null?void 0:d.get(e);let s=i==null?void 0:i.get(t);s===void 0&&(s=this._createIndex(e,t));const n=s.get(r);if(n!==void 0&&f(e[n])&&Object.is(e[n][t],r))return n;const a=O(e,t,r);return a===-1?s.delete(r):s.set(r,a),a}_createIndex(e,t){const r=this._indexes??(this._indexes=new WeakMap);let i=r.get(e);if(i===void 0&&(i=new Map,r.set(e,i)),this._options.indexStrategy==="eager-all-keys")for(let n=0;n<e.length;n++){const a=e[n];if(f(a))for(const d of Object.keys(a)){const c=a[d];if(!A(c))continue;let l=i.get(d);l===void 0&&(l=new Map,i.set(d,l)),l.has(c)||l.set(c,n)}}let s=i.get(t);if(s!==void 0)return s;s=new Map;for(let n=0;n<e.length;n++){const a=e[n];if(!f(a))continue;const d=a[t];A(d)&&!s.has(d)&&s.set(d,n)}return i.set(t,s),s}}function O(o,e,t){for(let r=0;r<o.length;r++){const i=o[r];if(f(i)&&Object.hasOwn(i,e)&&Object.is(i[e],t))return r}return-1}function v(o){return o.kind==="index"||o.kind==="selector"?[]:p()}function p(){return Object.create(null)}function x(o){if(u(o))return o;throw new TypeError("[Raph] Root value must be an object or array.")}function k(o,e){if(u(o))return o;throw w(e)}function f(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function u(o){return Array.isArray(o)||f(o)}function A(o){return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}function b(o,e,t){if(e==="__proto__"){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}o[e]=t}function w(o){return new TypeError(`[Raph] Cannot traverse non-container data at "${o}".`)}function _(o){return new Error(`[Raph] Cannot create missing container at "${o}" (autoCreate=false).`)}exports.DefaultDataAdapter=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../data-path.utils.cjs"),A=require("./createDataDraft.cjs");class w{_root;_options;_indexes;constructor(e=b(),t={}){this._root=_(e),this._options={arrayDelete:t.arrayDelete??"unset",autoCreate:t.autoCreate??!0,indexEnabled:t.indexEnabled??!0,indexStrategy:t.indexStrategy??"eager-all-keys"}}root(){return this._root}fork(){const e=new w({},this._options);return e._root=A.createDataDraft(this._root,t=>e._indexes?.delete(t)).root,e}replaceRoot(e){this._root=_(e),this._indexes=void 0}options(e){e.arrayDelete!==void 0&&(this._options.arrayDelete=e.arrayDelete),e.autoCreate!==void 0&&(this._options.autoCreate=e.autoCreate),e.indexEnabled!==void 0&&(this._options.indexEnabled=e.indexEnabled),e.indexStrategy!==void 0&&(this._options.indexStrategy=e.indexStrategy),this._indexes=void 0}get(e,t){return this._read(h.parseDataPath(e,t)).value}has(e,t){return this._read(h.parseDataPath(e,t)).exists}set(e,t,r){const i=h.parseDataPath(e,r);if(i.segments.length===0){this.replaceRoot(_(t));return}let s=this._root,n;for(let a=0;a<i.segments.length-1;a++){const d=i.segments[a],c=i.segments[a+1],l=this._readOrCreateChild(s,d,c,i.canonical);s=l.value,n=l.indexedParent}this._writeSegment(s,i.segments[i.segments.length-1],t,i.canonical,n)}merge(e,t,r){const i=this.get(e,r);if(f(i)&&f(t)){for(const s of Object.keys(t))k(i,s,t[s]);this._indexes=void 0;return}this.set(e,t,r)}delete(e,t){const r=h.parseDataPath(e,t);if(r.segments.length===0){this._root=b(),this._indexes=void 0;return}let i=this._root;for(let n=0;n<r.segments.length-1;n++){if(!u(i))return;i=this._readSegment(i,r.segments[n])}if(!u(i))return;const s=r.segments[r.segments.length-1];if(s.kind==="key")delete i[s.key];else if(s.kind==="index"){if(!Array.isArray(i))return;this._options.arrayDelete==="splice"?i.splice(s.index,1):delete i[s.index]}else{if(!Array.isArray(i))return;const n=this._findSelector(i,s.key,s.value);if(n===-1)return;this._options.arrayDelete==="splice"?i.splice(n,1):delete i[n]}this._indexes=void 0}indexOf(e,t){const r=h.parseDataPath(e,t);let i=this._root;for(let s=0;s<r.segments.length;s++){const n=r.segments[s],a=s===r.segments.length-1;if(n.kind==="key"){if(!u(i)||!Object.hasOwn(i,n.key))return-1;i=i[n.key];continue}if(!Array.isArray(i))return-1;if(n.kind==="index"){if(!Object.hasOwn(i,n.index))return-1;if(a)return n.index;i=i[n.index];continue}const d=this._findSelector(i,n.key,n.value);if(d===-1)return-1;if(a)return d;i=i[d]}return-1}_read(e){let t=this._root;for(const r of e.segments)if(r.kind==="key"){if(!u(t)||!Object.hasOwn(t,r.key))return{exists:!1,value:void 0};t=t[r.key]}else if(r.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,r.index))return{exists:!1,value:void 0};t=t[r.index]}else{if(!Array.isArray(t))return{exists:!1,value:void 0};const i=this._findSelector(t,r.key,r.value);if(i===-1)return{exists:!1,value:void 0};t=t[i]}return{exists:!0,value:t}}_readSegment(e,t){if(t.kind==="key")return Object.hasOwn(e,t.key)?e[t.key]:void 0;if(!Array.isArray(e))return;if(t.kind==="index")return e[t.index];const r=this._findSelector(e,t.key,t.value);return r===-1?void 0:e[r]}_readOrCreateChild(e,t,r,i){if(t.kind==="key"){let n=e[t.key];if(!Object.hasOwn(e,t.key)||n===void 0){if(!this._options.autoCreate)throw y(i);n=O(r),k(e,t.key,n)}return{value:x(n,i)}}if(!Array.isArray(e))throw p(i);if(t.kind==="index"){let n=e[t.index];if(!Object.hasOwn(e,t.index)||n===void 0){if(!this._options.autoCreate)throw y(i);n=O(r),e[t.index]=n}return{value:x(n,i),indexedParent:{array:e,index:t.index}}}let s=this._findSelector(e,t.key,t.value);if(s===-1){if(!this._options.autoCreate)throw y(i);const n=Object.create(null);n[t.key]=t.value,e.push(n),s=e.length-1,this._invalidateArray(e)}return{value:x(e[s],i),indexedParent:{array:e,index:s}}}_writeSegment(e,t,r,i,s){if(t.kind==="key"){k(e,t.key,r),s!==void 0&&s.array[s.index]===e&&this._invalidateIndexKey(s.array,t.key);return}if(!Array.isArray(e))throw p(i);if(t.kind==="index"){e[t.index]=r,this._invalidateArray(e);return}if(!f(r))throw new TypeError(`[Raph] New selector target at "${i}" must be an object.`);if(Object.hasOwn(r,t.key)&&!Object.is(r[t.key],t.value))throw new TypeError(`[Raph] Selector target at "${i}" has a conflicting key.`);const n=this._findSelector(e,t.key,t.value);if(n===-1&&!this._options.autoCreate)throw y(i);const a=Object.hasOwn(r,t.key)?r:{...r,[t.key]:t.value};n===-1?e.push(a):e[n]=a,this._invalidateArray(e)}_invalidateArray(e){this._indexes?.delete(e)}_invalidateIndexKey(e,t){const r=this._indexes?.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._indexes.delete(e))}_findSelector(e,t,r){if(!this._options.indexEnabled)return g(e,t,r);let s=this._indexes?.get(e)?.get(t);s===void 0&&(s=this._createIndex(e,t));const n=s.get(r);if(n!==void 0&&f(e[n])&&Object.is(e[n][t],r))return n;const a=g(e,t,r);return a===-1?s.delete(r):s.set(r,a),a}_createIndex(e,t){const r=this._indexes??=new WeakMap;let i=r.get(e);if(i===void 0&&(i=new Map,r.set(e,i)),this._options.indexStrategy==="eager-all-keys")for(let n=0;n<e.length;n++){const a=e[n];if(f(a))for(const d of Object.keys(a)){const c=a[d];if(!v(c))continue;let l=i.get(d);l===void 0&&(l=new Map,i.set(d,l)),l.has(c)||l.set(c,n)}}let s=i.get(t);if(s!==void 0)return s;s=new Map;for(let n=0;n<e.length;n++){const a=e[n];if(!f(a))continue;const d=a[t];v(d)&&!s.has(d)&&s.set(d,n)}return i.set(t,s),s}}function g(o,e,t){for(let r=0;r<o.length;r++){const i=o[r];if(f(i)&&Object.hasOwn(i,e)&&Object.is(i[e],t))return r}return-1}function O(o){return o.kind==="index"||o.kind==="selector"?[]:b()}function b(){return Object.create(null)}function _(o){if(u(o))return o;throw new TypeError("[Raph] Root value must be an object or array.")}function x(o,e){if(u(o))return o;throw p(e)}function f(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function u(o){return Array.isArray(o)||f(o)}function v(o){return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}function k(o,e,t){if(e==="__proto__"){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}o[e]=t}function p(o){return new TypeError(`[Raph] Cannot traverse non-container data at "${o}".`)}function y(o){return new Error(`[Raph] Cannot create missing container at "${o}" (autoCreate=false).`)}exports.DefaultDataAdapter=w;
@@ -1,18 +1,15 @@
1
- var j = Object.defineProperty;
2
- var C = (o, e, t) => e in o ? j(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var y = (o, e, t) => C(o, typeof e != "symbol" ? e + "" : e, t);
4
1
  import { parseDataPath as h } from "../data-path.utils.js";
5
- import { createDataDraft as S } from "./createDataDraft.js";
6
- class A {
2
+ import { createDataDraft as A } from "./createDataDraft.js";
3
+ class v {
4
+ // Хранят root, нормализованные опции и ленивые selector indexes.
5
+ _root;
6
+ _options;
7
+ _indexes;
7
8
  /**
8
9
  * Создаёт in-memory adapter с заданным начальным root и опциями.
9
10
  */
10
- constructor(e = w(), t = {}) {
11
- // Хранят root, нормализованные опции и ленивые selector indexes.
12
- y(this, "_root");
13
- y(this, "_options");
14
- y(this, "_indexes");
15
- this._root = _(e), this._options = {
11
+ constructor(e = b(), t = {}) {
12
+ this._root = x(e), this._options = {
16
13
  arrayDelete: t.arrayDelete ?? "unset",
17
14
  autoCreate: t.autoCreate ?? !0,
18
15
  indexEnabled: t.indexEnabled ?? !0,
@@ -29,17 +26,14 @@ class A {
29
26
  * Создаёт изолированную copy-on-write проекцию для синхронной проверки mutation.
30
27
  */
31
28
  fork() {
32
- const e = new A({}, this._options);
33
- return e._root = S(this._root, (t) => {
34
- var r;
35
- return (r = e._indexes) == null ? void 0 : r.delete(t);
36
- }).root, e;
29
+ const e = new v({}, this._options);
30
+ return e._root = A(this._root, (t) => e._indexes?.delete(t)).root, e;
37
31
  }
38
32
  /**
39
33
  * Заменяет корневой объект без path-level публикации.
40
34
  */
41
35
  replaceRoot(e) {
42
- this._root = _(e), this._indexes = void 0;
36
+ this._root = x(e), this._indexes = void 0;
43
37
  }
44
38
  /**
45
39
  * Обновляет изменяемые опции adapter и сбрасывает построенные indexes.
@@ -65,7 +59,7 @@ class A {
65
59
  set(e, t, r) {
66
60
  const i = h(e, r);
67
61
  if (i.segments.length === 0) {
68
- this.replaceRoot(_(t));
62
+ this.replaceRoot(x(t));
69
63
  return;
70
64
  }
71
65
  let s = this._root, n;
@@ -88,7 +82,7 @@ class A {
88
82
  const i = this.get(e, r);
89
83
  if (f(i) && f(t)) {
90
84
  for (const s of Object.keys(t))
91
- b(i, s, t[s]);
85
+ k(i, s, t[s]);
92
86
  this._indexes = void 0;
93
87
  return;
94
88
  }
@@ -100,7 +94,7 @@ class A {
100
94
  delete(e, t) {
101
95
  const r = h(e, t);
102
96
  if (r.segments.length === 0) {
103
- this._root = w(), this._indexes = void 0;
97
+ this._root = b(), this._indexes = void 0;
104
98
  return;
105
99
  }
106
100
  let i = this._root;
@@ -197,44 +191,44 @@ class A {
197
191
  let n = e[t.key];
198
192
  if (!Object.hasOwn(e, t.key) || n === void 0) {
199
193
  if (!this._options.autoCreate)
200
- throw x(i);
201
- n = g(r), b(e, t.key, n);
194
+ throw y(i);
195
+ n = p(r), k(e, t.key, n);
202
196
  }
203
- return { value: k(n, i) };
197
+ return { value: _(n, i) };
204
198
  }
205
199
  if (!Array.isArray(e))
206
- throw O(i);
200
+ throw w(i);
207
201
  if (t.kind === "index") {
208
202
  let n = e[t.index];
209
203
  if (!Object.hasOwn(e, t.index) || n === void 0) {
210
204
  if (!this._options.autoCreate)
211
- throw x(i);
212
- n = g(r), e[t.index] = n;
205
+ throw y(i);
206
+ n = p(r), e[t.index] = n;
213
207
  }
214
208
  return {
215
- value: k(n, i),
209
+ value: _(n, i),
216
210
  indexedParent: { array: e, index: t.index }
217
211
  };
218
212
  }
219
213
  let s = this._findSelector(e, t.key, t.value);
220
214
  if (s === -1) {
221
215
  if (!this._options.autoCreate)
222
- throw x(i);
216
+ throw y(i);
223
217
  const n = /* @__PURE__ */ Object.create(null);
224
218
  n[t.key] = t.value, e.push(n), s = e.length - 1, this._invalidateArray(e);
225
219
  }
226
220
  return {
227
- value: k(e[s], i),
221
+ value: _(e[s], i),
228
222
  indexedParent: { array: e, index: s }
229
223
  };
230
224
  }
231
225
  _writeSegment(e, t, r, i, s) {
232
226
  if (t.kind === "key") {
233
- b(e, t.key, r), s !== void 0 && s.array[s.index] === e && this._invalidateIndexKey(s.array, t.key);
227
+ k(e, t.key, r), s !== void 0 && s.array[s.index] === e && this._invalidateIndexKey(s.array, t.key);
234
228
  return;
235
229
  }
236
230
  if (!Array.isArray(e))
237
- throw O(i);
231
+ throw w(i);
238
232
  if (t.kind === "index") {
239
233
  e[t.index] = r, this._invalidateArray(e);
240
234
  return;
@@ -245,34 +239,30 @@ class A {
245
239
  throw new TypeError(`[Raph] Selector target at "${i}" has a conflicting key.`);
246
240
  const n = this._findSelector(e, t.key, t.value);
247
241
  if (n === -1 && !this._options.autoCreate)
248
- throw x(i);
242
+ throw y(i);
249
243
  const d = Object.hasOwn(r, t.key) ? r : { ...r, [t.key]: t.value };
250
244
  n === -1 ? e.push(d) : e[n] = d, this._invalidateArray(e);
251
245
  }
252
246
  _invalidateArray(e) {
253
- var t;
254
- (t = this._indexes) == null || t.delete(e);
247
+ this._indexes?.delete(e);
255
248
  }
256
249
  _invalidateIndexKey(e, t) {
257
- var i;
258
- const r = (i = this._indexes) == null ? void 0 : i.get(e);
250
+ const r = this._indexes?.get(e);
259
251
  r !== void 0 && (r.delete(t), r.size === 0 && this._indexes.delete(e));
260
252
  }
261
253
  _findSelector(e, t, r) {
262
- var a;
263
254
  if (!this._options.indexEnabled)
264
- return p(e, t, r);
265
- const i = (a = this._indexes) == null ? void 0 : a.get(e);
266
- let s = i == null ? void 0 : i.get(t);
255
+ return O(e, t, r);
256
+ let s = this._indexes?.get(e)?.get(t);
267
257
  s === void 0 && (s = this._createIndex(e, t));
268
258
  const n = s.get(r);
269
259
  if (n !== void 0 && f(e[n]) && Object.is(e[n][t], r))
270
260
  return n;
271
- const d = p(e, t, r);
261
+ const d = O(e, t, r);
272
262
  return d === -1 ? s.delete(r) : s.set(r, d), d;
273
263
  }
274
264
  _createIndex(e, t) {
275
- const r = this._indexes ?? (this._indexes = /* @__PURE__ */ new WeakMap());
265
+ const r = this._indexes ??= /* @__PURE__ */ new WeakMap();
276
266
  let i = r.get(e);
277
267
  if (i === void 0 && (i = /* @__PURE__ */ new Map(), r.set(e, i)), this._options.indexStrategy === "eager-all-keys")
278
268
  for (let n = 0; n < e.length; n++) {
@@ -280,7 +270,7 @@ class A {
280
270
  if (f(d))
281
271
  for (const a of Object.keys(d)) {
282
272
  const c = d[a];
283
- if (!v(c))
273
+ if (!g(c))
284
274
  continue;
285
275
  let l = i.get(a);
286
276
  l === void 0 && (l = /* @__PURE__ */ new Map(), i.set(a, l)), l.has(c) || l.set(c, n);
@@ -295,12 +285,12 @@ class A {
295
285
  if (!f(d))
296
286
  continue;
297
287
  const a = d[t];
298
- v(a) && !s.has(a) && s.set(a, n);
288
+ g(a) && !s.has(a) && s.set(a, n);
299
289
  }
300
290
  return i.set(t, s), s;
301
291
  }
302
292
  }
303
- function p(o, e, t) {
293
+ function O(o, e, t) {
304
294
  for (let r = 0; r < o.length; r++) {
305
295
  const i = o[r];
306
296
  if (f(i) && Object.hasOwn(i, e) && Object.is(i[e], t))
@@ -308,21 +298,21 @@ function p(o, e, t) {
308
298
  }
309
299
  return -1;
310
300
  }
311
- function g(o) {
312
- return o.kind === "index" || o.kind === "selector" ? [] : w();
301
+ function p(o) {
302
+ return o.kind === "index" || o.kind === "selector" ? [] : b();
313
303
  }
314
- function w() {
304
+ function b() {
315
305
  return /* @__PURE__ */ Object.create(null);
316
306
  }
317
- function _(o) {
307
+ function x(o) {
318
308
  if (u(o))
319
309
  return o;
320
310
  throw new TypeError("[Raph] Root value must be an object or array.");
321
311
  }
322
- function k(o, e) {
312
+ function _(o, e) {
323
313
  if (u(o))
324
314
  return o;
325
- throw O(e);
315
+ throw w(e);
326
316
  }
327
317
  function f(o) {
328
318
  return typeof o == "object" && o !== null && !Array.isArray(o);
@@ -330,10 +320,10 @@ function f(o) {
330
320
  function u(o) {
331
321
  return Array.isArray(o) || f(o);
332
322
  }
333
- function v(o) {
323
+ function g(o) {
334
324
  return o === null || typeof o == "string" || typeof o == "number" || typeof o == "boolean";
335
325
  }
336
- function b(o, e, t) {
326
+ function k(o, e, t) {
337
327
  if (e === "__proto__") {
338
328
  Object.defineProperty(o, e, {
339
329
  configurable: !0,
@@ -345,12 +335,12 @@ function b(o, e, t) {
345
335
  }
346
336
  o[e] = t;
347
337
  }
348
- function O(o) {
338
+ function w(o) {
349
339
  return new TypeError(`[Raph] Cannot traverse non-container data at "${o}".`);
350
340
  }
351
- function x(o) {
341
+ function y(o) {
352
342
  return new Error(`[Raph] Cannot create missing container at "${o}" (autoCreate=false).`);
353
343
  }
354
344
  export {
355
- A as DefaultDataAdapter
345
+ v as DefaultDataAdapter
356
346
  };
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var f=(n,t,e)=>t in n?_(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var c=(n,t,e)=>f(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../data-path.utils.cjs"),g=require("../PathRouter.cjs");class b{constructor(t){c(this,"_router");c(this,"_events");c(this,"_batchDepth",0);c(this,"_watcherCount",0);c(this,"_publishing",!1);this._batchErrorMessage=t}get hasWatchers(){return this._watcherCount!==0}get events(){return this._events}get router(){return this._router}get watcherCount(){return this._watcherCount}record(t){this._watcherCount!==0&&((this._events??(this._events=[])).push(t),this._batchDepth===0&&!this._publishing&&this._publish())}batch(t){var o;let e=!1,a,i=!1,h,s;this._batchDepth++;try{s=t()}catch(r){e=!0,a=r}finally{if(this._batchDepth--,this._batchDepth===0&&((o=this._events)!=null&&o.length))try{this._publish()}catch(r){i=!0,h=r}}if(e&&i)throw new AggregateError([a,h],this._batchErrorMessage);if(e)throw a;if(i)throw h;return s}watch(t,e){const a=Array.isArray(t)?t:[t];if(a.length===0)throw new TypeError("[Raph] Path watch requires at least one mask.");const i=new Map;for(const r of a){const u=p.parsePathMask(r);i.set(u.canonical,u)}const h={active:!0,callback:e},s=this._router??(this._router=new g.PathRouter),o=[...i.values()].map(r=>s.add(r,h));return this._watcherCount++,v(()=>{h.active=!1,h.callback=void 0;for(const r of o)r();this._watcherCount--,this._watcherCount===0&&(this._router=void 0)})}_publish(){const t=this._events;if(t===void 0||t.length===0||this._publishing)return;const e=[];this._publishing=!0;try{for(;t.length!==0;){const a=t.splice(0),i=this._router;if(i===void 0)continue;const h=new Map;for(const s of a){const o=p.parseDataPath(s.path),r=o.segments.length===0?i.matchAll():i.match(o.segments);for(const u of r){const l=h.get(u);l===void 0?h.set(u,[s]):l.push(s)}}for(const[s,o]of h)if(!(!s.active||s.callback===void 0))try{s.callback({events:o})}catch(r){e.push(r)}}}finally{this._publishing=!1}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Multiple path watchers failed.")}}function v(n){let t=n;return()=>{const e=t;t=void 0,e==null||e()}}exports.PathEventHub=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../data-path.utils.cjs"),p=require("../PathRouter.cjs");class _{constructor(t){this._batchErrorMessage=t}_router;_events;_batchDepth=0;_watcherCount=0;_publishing=!1;get hasWatchers(){return this._watcherCount!==0}get events(){return this._events}get router(){return this._router}get watcherCount(){return this._watcherCount}record(t){this._watcherCount!==0&&((this._events??=[]).push(t),this._batchDepth===0&&!this._publishing&&this._publish())}batch(t){let e=!1,s,r;this._batchDepth++;try{r=t()}catch(h){e=!0,s=h}return this._closeBatch(e,s),r}_openBatch(){this._batchDepth++}_closeBatch(t,e){let s=!1,r;if(this._batchDepth--,this._batchDepth===0&&this._events?.length)try{this._publish()}catch(h){s=!0,r=h}if(t&&s)throw new AggregateError([e,r],this._batchErrorMessage);if(t)throw e;if(s)throw r}watch(t,e){const s=Array.isArray(t)?t:[t];if(s.length===0)throw new TypeError("[Raph] Path watch requires at least one mask.");const r=new Map;for(const o of s){const a=l.parsePathMask(o);r.set(a.canonical,a)}const h={active:!0,callback:e},i=this._router??=new p.PathRouter,n=[...r.values()].map(o=>i.add(o,h));return this._watcherCount++,f(()=>{h.active=!1,h.callback=void 0;for(const o of n)o();this._watcherCount--,this._watcherCount===0&&(this._router=void 0)})}_publish(){const t=this._events;if(t===void 0||t.length===0||this._publishing)return;const e=[];this._publishing=!0;try{for(;t.length!==0;){const s=t.splice(0),r=this._router;if(r===void 0)continue;const h=new Map;for(const i of s){const n=l.parseDataPath(i.path),o=n.segments.length===0?r.matchAll():r.match(n.segments);for(const a of o){const u=h.get(a);u===void 0?h.set(a,[i]):u.push(i)}}for(const[i,n]of h)if(!(!i.active||i.callback===void 0))try{i.callback({events:n})}catch(o){e.push(o)}}}finally{this._publishing=!1}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Multiple path watchers failed.")}}function f(c){let t=c;return()=>{const e=t;t=void 0,e?.()}}exports.PathEventHub=_;