@raphy-js/raph 1.0.0-dev.2 → 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 (246) hide show
  1. package/README.md +1096 -0
  2. package/dist/api/Raph.d.ts +59 -190
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +9 -4
  6. package/dist/api/types.d.ts +162 -17
  7. package/dist/core-CClhT8WR.js +1044 -0
  8. package/dist/core-cPQWYD4K.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -367
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +302 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +146 -0
  15. package/dist/debug/api/errors.cjs +1 -1
  16. package/dist/debug/api/errors.js +10 -7
  17. package/dist/debug/path/DataPath.cjs +1 -0
  18. package/dist/debug/path/DataPath.js +390 -0
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/PathRouter.js +80 -0
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +316 -236
  23. package/dist/debug/path/data-path.utils.cjs +1 -0
  24. package/dist/debug/path/data-path.utils.js +56 -0
  25. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  26. package/dist/debug/path/derived/DerivedRegistry.js +143 -0
  27. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  28. package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
  29. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  30. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
  31. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  32. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  33. package/dist/debug/path/meta/MetaController.cjs +1 -0
  34. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
  35. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  36. package/dist/debug/path/meta/RaphMeta.js +62 -0
  37. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  38. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
  39. package/dist/debug/path/meta/meta.types.cjs +1 -0
  40. package/dist/debug/path/meta/meta.types.js +1 -0
  41. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  42. package/dist/debug/path/storage/AdapterPathStore.js +128 -0
  43. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  44. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
  45. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  46. package/dist/debug/path/storage/PathEventHub.js +161 -0
  47. package/dist/debug/path/storage/PathStore.cjs +1 -0
  48. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
  49. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  50. package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
  51. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  52. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  53. package/dist/debug/reactivity/disposal.cjs +1 -0
  54. package/dist/debug/reactivity/disposal.js +32 -0
  55. package/dist/debug/reactivity/engine.cjs +1 -1
  56. package/dist/debug/reactivity/engine.js +888 -321
  57. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  58. package/dist/debug/reactivity/reactive-object.js +265 -0
  59. package/dist/debug/reactivity/scope.cjs +1 -1
  60. package/dist/debug/reactivity/scope.js +221 -117
  61. package/dist/debug/reactivity/watch.cjs +1 -1
  62. package/dist/debug/reactivity/watch.js +1 -1
  63. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  64. package/dist/debug/runtime/RaphRuntime.js +1134 -502
  65. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  66. package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
  67. package/dist/debug/runtime/errors.cjs +1 -1
  68. package/dist/debug/runtime/errors.js +6 -3
  69. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  70. package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
  71. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  72. package/dist/debug/runtime/ownership/RaphNode.js +665 -0
  73. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  74. package/dist/debug/runtime/ownership/RaphScope.js +236 -0
  75. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  76. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  77. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  78. package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
  79. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  80. package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
  81. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  82. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  83. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  84. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  85. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  86. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  87. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  88. package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
  89. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  90. package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
  91. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  92. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  93. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  94. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
  95. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  96. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
  97. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  98. package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
  99. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  100. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  101. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  103. package/dist/entrypoints/machine-testing.d.ts +2 -0
  104. package/dist/entrypoints/machine.d.ts +5 -0
  105. package/dist/entrypoints/path.d.ts +14 -0
  106. package/dist/entrypoints/reactivity.d.ts +1 -0
  107. package/dist/entrypoints/runtime.d.ts +18 -0
  108. package/dist/index.cjs +1 -1
  109. package/dist/index.js +46 -38
  110. package/dist/machine/compiler.d.ts +71 -0
  111. package/dist/machine/core.d.ts +50 -0
  112. package/dist/machine/persistence.d.ts +5 -0
  113. package/dist/machine/runtime.d.ts +4 -0
  114. package/dist/machine/testing.d.ts +43 -0
  115. package/dist/machine/types.d.ts +155 -0
  116. package/dist/machine-testing.cjs +1 -0
  117. package/dist/machine-testing.js +188 -0
  118. package/dist/machine.cjs +1 -0
  119. package/dist/machine.js +822 -0
  120. package/dist/main.d.ts +20 -0
  121. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  122. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  123. package/dist/path/RaphKernel.d.ts +37 -10
  124. package/dist/path/data-path.types.d.ts +34 -0
  125. package/dist/path/data-path.utils.d.ts +9 -0
  126. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  127. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  128. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  129. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  130. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  131. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  132. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  133. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  134. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  135. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  136. package/dist/path/path.types.d.ts +3 -2
  137. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  138. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  139. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  140. package/dist/path/storage/PathEventHub.d.ts +62 -0
  141. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
  142. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  143. package/dist/path.cjs +1 -1
  144. package/dist/path.js +16 -16
  145. package/dist/raph.cjs +1 -1
  146. package/dist/raph.js +46 -38
  147. package/dist/reactivity/disposal.d.ts +14 -0
  148. package/dist/reactivity/engine.d.ts +193 -6
  149. package/dist/reactivity/reactive-object.d.ts +36 -0
  150. package/dist/reactivity/scope.d.ts +108 -30
  151. package/dist/reactivity/types.d.ts +25 -0
  152. package/dist/reactivity.cjs +1 -1
  153. package/dist/reactivity.js +12 -12
  154. package/dist/runtime/RaphRuntime.d.ts +319 -160
  155. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  156. package/dist/runtime/errors.d.ts +5 -0
  157. package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
  158. package/dist/runtime/ownership/RaphNode.d.ts +310 -0
  159. package/dist/runtime/ownership/RaphScope.d.ts +168 -0
  160. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  161. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  162. package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
  163. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  164. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  165. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  166. package/dist/runtime/phases/phase.types.d.ts +171 -0
  167. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  168. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  169. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  170. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
  171. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
  172. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
  173. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  174. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
  175. package/dist/runtime.cjs +1 -1
  176. package/dist/runtime.js +21 -16
  177. package/package.json +76 -35
  178. package/ReadMe.md +0 -153
  179. package/dist/api/public.d.ts +0 -22
  180. package/dist/debug/api/public.cjs +0 -1
  181. package/dist/debug/api/public.js +0 -40
  182. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  183. package/dist/debug/path/AdapterPathStore.js +0 -133
  184. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  185. package/dist/debug/path/DerivedRegistry.js +0 -157
  186. package/dist/debug/path/MetaController.cjs +0 -1
  187. package/dist/debug/path/PathEventHub.cjs +0 -1
  188. package/dist/debug/path/PathEventHub.js +0 -148
  189. package/dist/debug/path/PathStore.cjs +0 -1
  190. package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
  191. package/dist/debug/path/RaphMeta.cjs +0 -1
  192. package/dist/debug/path/RaphMeta.js +0 -68
  193. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  194. package/dist/debug/path/data-adapter.cjs +0 -1
  195. package/dist/debug/path/data-draft.cjs +0 -1
  196. package/dist/debug/path/data-path.cjs +0 -1
  197. package/dist/debug/path/data-path.js +0 -423
  198. package/dist/debug/path/derived-collection.cjs +0 -1
  199. package/dist/debug/path/path-router.cjs +0 -1
  200. package/dist/debug/path/path-router.js +0 -86
  201. package/dist/debug/path/public.cjs +0 -1
  202. package/dist/debug/path/public.js +0 -18
  203. package/dist/debug/runtime/PathHandle.cjs +0 -1
  204. package/dist/debug/runtime/PathHandle.js +0 -139
  205. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  206. package/dist/debug/runtime/RaphDebug.js +0 -15
  207. package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
  208. package/dist/debug/runtime/RaphNode.cjs +0 -1
  209. package/dist/debug/runtime/RaphNode.js +0 -143
  210. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  211. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  212. package/dist/debug/runtime/RaphScope.cjs +0 -1
  213. package/dist/debug/runtime/RaphScope.js +0 -64
  214. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  215. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  216. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  217. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  218. package/dist/debug/runtime/public.cjs +0 -1
  219. package/dist/debug/runtime/public.js +0 -18
  220. package/dist/path/PathEventHub.d.ts +0 -48
  221. package/dist/path/public.d.ts +0 -14
  222. package/dist/runtime/RaphDebug.d.ts +0 -32
  223. package/dist/runtime/RaphNode.d.ts +0 -68
  224. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  225. package/dist/runtime/RaphScope.d.ts +0 -50
  226. package/dist/runtime/RuntimeReactivity.d.ts +0 -40
  227. package/dist/runtime/phase.types.d.ts +0 -49
  228. package/dist/runtime/public.d.ts +0 -13
  229. package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
  230. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  231. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  232. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  233. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  234. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  235. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  236. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  237. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  238. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  239. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  240. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  241. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  242. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  243. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  244. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  245. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  246. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -1,38 +1,34 @@
1
- var v = Object.defineProperty;
2
- var p = (d, e, t) => e in d ? v(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
3
- var l = (d, e, t) => p(d, typeof e != "symbol" ? e + "" : e, t);
4
- import { DataPath as f } from "./data-path.js";
5
- import { PathRouter as g } from "./path-router.js";
6
- import { RaphMeta as m } from "./RaphMeta.js";
7
- import { RaphMetaStore as _ } from "./RaphMetaStore.js";
8
- class k {
1
+ import { DataPath as u } from "../DataPath.js";
2
+ import { PathRouter as _ } from "../PathRouter.js";
3
+ import { RaphMeta as v } from "./RaphMeta.js";
4
+ import { RaphMetaStore as f } from "./RaphMetaStore.js";
5
+ class C {
9
6
  /**
10
7
  * Создаёт lifecycle-контроллер metadata для одного Kernel.
11
8
  */
12
9
  constructor(e, t, r) {
13
- // Лениво создают metadata facade, storage и routing только при первом использовании.
14
- l(this, "_facade");
15
- l(this, "_store");
16
- l(this, "_router");
17
- l(this, "_pending");
18
- // Управляют reentrant publication и режимами активных watchers.
19
- l(this, "_publishing", !1);
20
- l(this, "_watcherCount", 0);
21
- l(this, "_deferredWatcherCount", 0);
22
10
  this._kernel = e, this._ownerExists = t, this._publicationDeferred = r;
23
11
  }
12
+ // Лениво создают metadata facade, storage и routing только при первом использовании.
13
+ _facade;
14
+ _store;
15
+ _router;
16
+ _pending;
17
+ // Управляют reentrant publication и режимами активных watchers.
18
+ _publishing = !1;
19
+ _watcherCount = 0;
20
+ _deferredWatcherCount = 0;
24
21
  /**
25
22
  * Возвращает metadata facade, принадлежащий контроллеру.
26
23
  */
27
24
  get facade() {
28
- return this._facade ?? (this._facade = new m(this._kernel));
25
+ return this._facade ??= new v(this._kernel);
29
26
  }
30
27
  /**
31
28
  * Возвращает число зарегистрированных записей.
32
29
  */
33
30
  get size() {
34
- var e;
35
- return ((e = this._store) == null ? void 0 : e.size) ?? 0;
31
+ return this._store?.size ?? 0;
36
32
  }
37
33
  /**
38
34
  * Показывает, есть ли активные синхронные metadata/path watchers.
@@ -50,34 +46,31 @@ class k {
50
46
  * Возвращает значение по пути без создания отсутствующих данных.
51
47
  */
52
48
  get(e, t) {
53
- var r;
54
- return (r = this._store) == null ? void 0 : r.get(e, t);
49
+ return this._store?.get(e, t);
55
50
  }
56
51
  /**
57
52
  * Проверяет наличие значения по указанному пути.
58
53
  */
59
54
  has(e, t) {
60
- var r;
61
- return ((r = this._store) == null ? void 0 : r.has(e, t)) ?? !1;
55
+ return this._store?.has(e, t) ?? !1;
62
56
  }
63
57
  /**
64
58
  * Записывает значение и публикует соответствующее изменение.
65
59
  */
66
- set(e, t, r, i) {
67
- (this._store ?? (this._store = new _())).set(e, t, r), this.record("set", e, t, "explicit", i);
60
+ set(e, t, r, s) {
61
+ (this._store ??= new f()).set(e, t, r), this.record("set", e, t, "explicit", s);
68
62
  }
69
63
  /**
70
64
  * Объединяет значение по пути и публикует соответствующее изменение.
71
65
  */
72
- merge(e, t, r, i) {
73
- (this._store ?? (this._store = new _())).merge(e, t, r), this.record("merge", e, t, "explicit", i);
66
+ merge(e, t, r, s) {
67
+ (this._store ??= new f()).merge(e, t, r), this.record("merge", e, t, "explicit", s);
74
68
  }
75
69
  /**
76
70
  * Удаляет значение по пути и публикует изменение при наличии данных.
77
71
  */
78
72
  delete(e, t, r) {
79
- var i;
80
- return (i = this._store) != null && i.delete(e, t) ? (this.record("delete", e, t ?? null, "explicit", r), !0) : !1;
73
+ return this._store?.delete(e, t) ? (this.record("delete", e, t ?? null, "explicit", r), !0) : !1;
81
74
  }
82
75
  /**
83
76
  * Удаляет metadata всего поддерева указанного data-owner.
@@ -85,8 +78,8 @@ class k {
85
78
  deleteSubtree(e, t) {
86
79
  const r = this._store;
87
80
  if (r !== void 0)
88
- for (const i of r.deleteSubtree(e))
89
- this.record("delete", i, null, t);
81
+ for (const s of r.deleteSubtree(e))
82
+ this.record("delete", s, null, t);
90
83
  }
91
84
  /**
92
85
  * Удаляет metadata, владельцы которой отсутствуют в data tree.
@@ -96,46 +89,46 @@ class k {
96
89
  if (r === void 0 || r.size === 0)
97
90
  return;
98
91
  const o = e.segments().findIndex(
99
- (s) => s.kind === "index" || s.kind === "selector"
100
- ), c = o === -1 ? e : f.fromPlain({ segs: e.toPlain().segs.slice(0, o) });
101
- for (const s of r.pruneMissing(
92
+ (i) => i.kind === "index" || i.kind === "selector"
93
+ ), c = o === -1 ? e : u.fromPlain({ segs: e.toPlain().segs.slice(0, o) });
94
+ for (const i of r.pruneMissing(
102
95
  c,
103
96
  (n) => this._ownerExists(n)
104
97
  ))
105
- this.record("delete", s, null, t);
98
+ this.record("delete", i, null, t);
106
99
  }
107
100
  /**
108
101
  * Подписывает callback на подходящие изменения и возвращает disposer.
109
102
  */
110
- watch(e, t, r = {}, i) {
103
+ watch(e, t, r = {}, s) {
111
104
  const o = Array.isArray(e) ? e : [e];
112
105
  if (o.length === 0)
113
106
  throw new TypeError("[RaphMeta] watch requires at least one mask.");
114
107
  const c = /* @__PURE__ */ new Map();
115
108
  for (const a of o) {
116
- const u = f.from(a, r)._asMask();
117
- c.set(u.canonical, u);
109
+ const l = u.from(a, r)._asMask();
110
+ c.set(l.canonical, l);
118
111
  }
119
- const s = {
112
+ const i = {
120
113
  active: !0,
121
114
  callback: t,
122
- afterPublish: i,
115
+ afterPublish: s,
123
116
  ...r.namespace === void 0 ? {} : { namespace: r.namespace }
124
- }, n = this._router ?? (this._router = new g()), h = [...c.values()].map((a) => n.add(a, s));
125
- return this._watcherCount++, i !== void 0 && this._deferredWatcherCount++, w(() => {
126
- s.active = !1, s.callback = void 0, s.afterPublish = void 0;
117
+ }, n = this._router ??= new _(), h = [...c.values()].map((a) => n.add(a, i));
118
+ return this._watcherCount++, s !== void 0 && this._deferredWatcherCount++, p(() => {
119
+ i.active = !1, i.callback = void 0, i.afterPublish = void 0;
127
120
  for (const a of h)
128
121
  a();
129
- this._watcherCount--, i !== void 0 && this._deferredWatcherCount--, this._watcherCount === 0 && (this._router = void 0);
122
+ this._watcherCount--, s !== void 0 && this._deferredWatcherCount--, this._watcherCount === 0 && (this._router = void 0);
130
123
  });
131
124
  }
132
125
  /**
133
- * Добавляет событие в текущую transaction либо публикует его сразу.
126
+ * Добавляет событие в текущую batch либо публикует его сразу.
134
127
  */
135
- record(e, t, r, i, o) {
136
- (this._pending ?? (this._pending = [])).push({
137
- event: { kind: e, path: t, namespace: r, cause: i },
138
- invalidate: (o == null ? void 0 : o.invalidate) ?? !0
128
+ record(e, t, r, s, o) {
129
+ (this._pending ??= []).push({
130
+ event: { kind: e, path: t, namespace: r, cause: s },
131
+ invalidate: o?.invalidate ?? !0
139
132
  }), !this._publicationDeferred() && !this._publishing && this.publish();
140
133
  }
141
134
  /**
@@ -149,32 +142,32 @@ class k {
149
142
  this._publishing = !0;
150
143
  try {
151
144
  for (; e.length !== 0; ) {
152
- const i = e.splice(0), o = this._router;
145
+ const s = e.splice(0), o = this._router;
153
146
  if (o === void 0)
154
147
  continue;
155
148
  const c = /* @__PURE__ */ new Map();
156
- for (const s of i) {
157
- const n = s.event;
149
+ for (const i of s) {
150
+ const n = i.event;
158
151
  for (const h of o.match(n.path._asExact().segments)) {
159
152
  if (h.namespace !== void 0 && n.namespace !== null && h.namespace !== n.namespace)
160
153
  continue;
161
154
  const a = c.get(h);
162
155
  a === void 0 ? c.set(h, {
163
156
  events: [n],
164
- invalidate: s.invalidate
165
- }) : (a.events.push(n), s.invalidate && (a.invalidate = !0));
157
+ invalidate: i.invalidate
158
+ }) : (a.events.push(n), i.invalidate && (a.invalidate = !0));
166
159
  }
167
160
  }
168
- for (const [s, n] of c) {
169
- if (!s.active || s.callback === void 0)
161
+ for (const [i, n] of c) {
162
+ if (!i.active || i.callback === void 0)
170
163
  continue;
171
- const h = s.afterPublish;
164
+ const h = i.afterPublish;
172
165
  h !== void 0 && r.set(
173
166
  h,
174
167
  (r.get(h) ?? !1) || n.invalidate
175
168
  );
176
169
  try {
177
- s.callback({ events: n.events });
170
+ i.callback({ events: n.events });
178
171
  } catch (a) {
179
172
  t.push(a);
180
173
  }
@@ -183,9 +176,9 @@ class k {
183
176
  } finally {
184
177
  this._publishing = !1;
185
178
  }
186
- for (const [i, o] of r)
179
+ for (const [s, o] of r)
187
180
  try {
188
- i(o);
181
+ s(o);
189
182
  } catch (c) {
190
183
  t.push(c);
191
184
  }
@@ -198,17 +191,16 @@ class k {
198
191
  * Очищает metadata storage, subscriptions и pending publication state.
199
192
  */
200
193
  dispose() {
201
- var e;
202
- (e = this._store) == null || e.clear(), this._store = void 0, this._facade = void 0, this._router = void 0, this._pending = void 0, this._watcherCount = 0, this._deferredWatcherCount = 0;
194
+ this._store?.clear(), this._store = void 0, this._facade = void 0, this._router = void 0, this._pending = void 0, this._watcherCount = 0, this._deferredWatcherCount = 0;
203
195
  }
204
196
  }
205
- function w(d) {
197
+ function p(d) {
206
198
  let e = d;
207
199
  return () => {
208
200
  const t = e;
209
- e = void 0, t == null || t();
201
+ e = void 0, t?.();
210
202
  };
211
203
  }
212
204
  export {
213
- k as MetaController
205
+ C as MetaController
214
206
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a{constructor(e,t={}){this._kernel=e,this._binding=t}get(e,t,i){return this._binding.assertReadable?.(),this._kernel.getMeta(e,t,i)}has(e,t,i){return this._binding.assertReadable?.(),this._kernel.hasMeta(e,t,i)}set(e,t,i,r){this._binding.assertWritable?.(),this._write(()=>this._kernel.setMeta(e,t,i,r),r?.invalidate??!0)}merge(e,t,i,r){this._binding.assertWritable?.(),this._write(()=>this._kernel.mergeMeta(e,t,i,r),r?.invalidate??!0)}delete(e,t,i){this._binding.assertWritable?.(),this._write(()=>this._kernel.deleteMeta(e,t,i),i?.invalidate??!0)}watch(e,t,i={}){if(this._binding.assertReadable?.(),this._binding.watch===void 0)throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");return this._binding.watch(e,t,i)}_write(e,t){const i=this._binding.runWrite;i===void 0?e():i(e,t)}}exports.RaphMeta=a;
@@ -0,0 +1,62 @@
1
+ class s {
2
+ /**
3
+ * Создаёт metadata facade поверх указанного Kernel.
4
+ */
5
+ constructor(e, t = {}) {
6
+ this._kernel = e, this._binding = t;
7
+ }
8
+ /**
9
+ * Возвращает значение по пути без создания отсутствующих данных.
10
+ */
11
+ get(e, t, i) {
12
+ return this._binding.assertReadable?.(), this._kernel.getMeta(e, t, i);
13
+ }
14
+ /**
15
+ * Проверяет наличие значения по указанному пути.
16
+ */
17
+ has(e, t, i) {
18
+ return this._binding.assertReadable?.(), this._kernel.hasMeta(e, t, i);
19
+ }
20
+ /**
21
+ * Записывает значение и публикует соответствующее изменение.
22
+ */
23
+ set(e, t, i, r) {
24
+ this._binding.assertWritable?.(), this._write(
25
+ () => this._kernel.setMeta(e, t, i, r),
26
+ r?.invalidate ?? !0
27
+ );
28
+ }
29
+ /**
30
+ * Объединяет значение по пути и публикует соответствующее изменение.
31
+ */
32
+ merge(e, t, i, r) {
33
+ this._binding.assertWritable?.(), this._write(
34
+ () => this._kernel.mergeMeta(e, t, i, r),
35
+ r?.invalidate ?? !0
36
+ );
37
+ }
38
+ /**
39
+ * Удаляет значение по пути и публикует изменение при наличии данных.
40
+ */
41
+ delete(e, t, i) {
42
+ this._binding.assertWritable?.(), this._write(
43
+ () => this._kernel.deleteMeta(e, t, i),
44
+ i?.invalidate ?? !0
45
+ );
46
+ }
47
+ /**
48
+ * Подписывает callback на metadata-изменения и возвращает disposer.
49
+ */
50
+ watch(e, t, i = {}) {
51
+ if (this._binding.assertReadable?.(), this._binding.watch === void 0)
52
+ throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");
53
+ return this._binding.watch(e, t, i);
54
+ }
55
+ _write(e, t) {
56
+ const i = this._binding.runWrite;
57
+ i === void 0 ? e() : i(e, t);
58
+ }
59
+ }
60
+ export {
61
+ s as RaphMeta
62
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../pathSegmentKey.cjs");function u(){return{children:new Map,namespaces:new Map,path:void 0}}class p{_root=u();size=0;get(e,t){const r=this._find(e);if(r!==void 0)return t===void 0?Object.fromEntries(r.namespaces):r.namespaces.get(t)}has(e,t){const r=this._find(e);return r===void 0?!1:t===void 0?r.namespaces.size!==0:r.namespaces.has(t)}set(e,t,r){const s=this._ensure(e);s.namespaces.has(t)||this.size++,s.namespaces.set(t,r),s.path=e}merge(e,t,r){const s=this.get(e,t);if(d(s)&&d(r)){for(const i of Object.keys(r))_(s,i,r[i]);return}this.set(e,t,r)}delete(e,t){const r=this._findStack(e),s=r.at(-1)?.node;if(s===void 0)return!1;if(t===void 0){if(s.namespaces.size===0)return!1;this.size-=s.namespaces.size,s.namespaces.clear()}else{if(!s.namespaces.delete(t))return!1;this.size--}return this._pruneEmpty(r),!0}deleteSubtree(e){const t=o(e);if(t.length===0)return this.clear();let r=this._root;for(let c=0;c<t.length-1;c++){const h=r.children.get(t[c]);if(h===void 0)return[];r=h}const s=r.children.get(t.at(-1));if(s===void 0)return[];const i=a(s);return this.size-=l(s),r.children.delete(t.at(-1)),i}pruneMissing(e,t){const r=this._find(e);if(r===void 0)return[];const s=[];return this._pruneMissingNode(r,t,s),s}clear(){const e=a(this._root);return this._root.children.clear(),this._root.namespaces.clear(),this._root.path=void 0,this.size=0,e}_find(e){let t=this._root;for(const r of o(e)){const s=t.children.get(r);if(s===void 0)return;t=s}return t}_ensure(e){let t=this._root;for(const r of o(e)){let s=t.children.get(r);s===void 0&&(s=u(),t.children.set(r,s)),t=s}return t}_findStack(e){const t=[{key:void 0,node:this._root}];let r=this._root;for(const s of o(e)){const i=r.children.get(s);if(i===void 0)return[];t.push({key:s,node:i}),r=i}return t}_pruneEmpty(e){for(let t=e.length-1;t>0;t--){const r=e[t];if(r.node.namespaces.size!==0||r.node.children.size!==0)return;e[t-1].node.children.delete(r.key)}}_pruneMissingNode(e,t,r){for(const[s,i]of[...e.children])this._pruneMissingNode(i,t,r)&&e.children.delete(s);return e.path!==void 0&&e.namespaces.size!==0&&!t(e.path)&&(this.size-=e.namespaces.size,e.namespaces.clear(),r.push(e.path)),e!==this._root&&e.namespaces.size===0&&e.children.size===0}}function o(n){return n.segments().map(f.pathSegmentKey)}function a(n){const e=n.path!==void 0&&n.namespaces.size!==0?[n.path]:[];for(const t of n.children.values())e.push(...a(t));return e}function l(n){let e=n.namespaces.size;for(const t of n.children.values())e+=l(t);return e}function d(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function _(n,e,t){if(e!=="__proto__"){n[e]=t;return}Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}exports.RaphMetaStore=p;
@@ -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 "./segment-key.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
  };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
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;
@@ -0,0 +1,128 @@
1
+ import { parseDataPath as i } from "../data-path.utils.js";
2
+ import { PathEventHub as d } from "./PathEventHub.js";
3
+ class b {
4
+ /**
5
+ * Связывает внешний DataAdapter с path events и watchers Kernel.
6
+ */
7
+ constructor(a) {
8
+ this._adapter = a;
9
+ }
10
+ // Публикует изменения внешнего adapter через общий path event lifecycle.
11
+ _eventHub = new d(
12
+ "[Raph] Adapter batch and publication failed."
13
+ );
14
+ /**
15
+ * Возвращает значение по пути без создания отсутствующих данных.
16
+ */
17
+ get(a, e) {
18
+ const t = i(a, e);
19
+ return this._adapter.get(t.canonical);
20
+ }
21
+ /**
22
+ * Читает значение по пути без регистрации реактивной зависимости.
23
+ */
24
+ peek(a, e) {
25
+ return this.get(a, e);
26
+ }
27
+ /**
28
+ * Проверяет наличие значения по указанному пути.
29
+ */
30
+ has(a, e) {
31
+ const t = i(a, e);
32
+ return this._adapter.has?.(t.canonical) ?? o(this._adapter.root(), t.segments);
33
+ }
34
+ /**
35
+ * Записывает значение и публикует соответствующее изменение.
36
+ */
37
+ set(a, e, t) {
38
+ const n = i(a, t), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0;
39
+ this._adapter.set(n.canonical, e), this._eventHub.record({
40
+ kind: "set",
41
+ path: n.canonical,
42
+ previous: s,
43
+ value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
44
+ });
45
+ }
46
+ /**
47
+ * Объединяет значение по пути и публикует соответствующее изменение.
48
+ */
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;
51
+ this._adapter.merge(n.canonical, e), this._eventHub.record({
52
+ kind: "merge",
53
+ path: n.canonical,
54
+ previous: h,
55
+ value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
56
+ });
57
+ }
58
+ /**
59
+ * Удаляет значение по пути и публикует изменение при наличии данных.
60
+ */
61
+ delete(a, e) {
62
+ const t = i(a, e);
63
+ if (!(this._adapter.has?.(t.canonical) ?? o(this._adapter.root(), t.segments)))
64
+ return;
65
+ const s = this._eventHub.hasWatchers ? this._adapter.get(t.canonical) : void 0;
66
+ this._adapter.delete(t.canonical), this._eventHub.record({
67
+ kind: "delete",
68
+ path: t.canonical,
69
+ previous: s,
70
+ value: void 0
71
+ });
72
+ }
73
+ /**
74
+ * Выполняет операцию в общей синхронной batch boundary.
75
+ */
76
+ batch(a) {
77
+ return this._eventHub.batch(a);
78
+ }
79
+ /**
80
+ * Подписывает callback на подходящие изменения и возвращает disposer.
81
+ */
82
+ watch(a, e) {
83
+ return this._eventHub.watch(a, e);
84
+ }
85
+ }
86
+ function o(r, a) {
87
+ let e = r;
88
+ for (const t of a)
89
+ if (t.kind === "key") {
90
+ if (!p(e) || !Object.hasOwn(e, t.key))
91
+ return !1;
92
+ e = e[t.key];
93
+ } else if (t.kind === "index") {
94
+ if (!Array.isArray(e) || !Object.hasOwn(e, t.index))
95
+ return !1;
96
+ e = e[t.index];
97
+ } else {
98
+ if (!Array.isArray(e))
99
+ return !1;
100
+ const n = e.findIndex(
101
+ (s) => c(s) && Object.hasOwn(s, t.key) && Object.is(s[t.key], t.value)
102
+ );
103
+ if (n === -1)
104
+ return !1;
105
+ e = e[n];
106
+ }
107
+ return !0;
108
+ }
109
+ function u(r) {
110
+ const a = Object.create(Object.getPrototypeOf(r));
111
+ for (const e of Object.keys(r))
112
+ e === "__proto__" ? Object.defineProperty(a, e, {
113
+ configurable: !0,
114
+ enumerable: !0,
115
+ value: r[e],
116
+ writable: !0
117
+ }) : a[e] = r[e];
118
+ return a;
119
+ }
120
+ function c(r) {
121
+ return typeof r == "object" && r !== null && !Array.isArray(r);
122
+ }
123
+ function p(r) {
124
+ return Array.isArray(r) || c(r);
125
+ }
126
+ export {
127
+ b as AdapterPathStore
128
+ };
@@ -0,0 +1 @@
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;