@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) 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-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -366
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -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/{data-path.js → DataPath.js} +151 -180
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +258 -207
  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/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
  27. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  28. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
  29. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  30. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  31. package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
  32. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
  33. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  34. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
  35. package/dist/debug/path/meta/meta.types.cjs +1 -0
  36. package/dist/debug/path/meta/meta.types.js +1 -0
  37. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  38. package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
  39. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  40. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
  41. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  42. package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
  43. package/dist/debug/path/storage/PathStore.cjs +1 -0
  44. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
  45. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  46. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  47. package/dist/debug/reactivity/engine.cjs +1 -1
  48. package/dist/debug/reactivity/engine.js +478 -306
  49. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  50. package/dist/debug/reactivity/reactive-object.js +280 -0
  51. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  52. package/dist/debug/runtime/RaphRuntime.js +798 -519
  53. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  54. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  55. package/dist/debug/runtime/errors.cjs +1 -1
  56. package/dist/debug/runtime/errors.js +6 -3
  57. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  58. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  59. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  60. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  61. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  62. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  63. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  64. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  65. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  67. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  68. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  69. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  70. package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
  71. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  79. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  81. package/dist/entrypoints/machine-testing.d.ts +2 -0
  82. package/dist/entrypoints/machine.d.ts +5 -0
  83. package/dist/entrypoints/path.d.ts +14 -0
  84. package/dist/entrypoints/reactivity.d.ts +1 -0
  85. package/dist/entrypoints/runtime.d.ts +17 -0
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +46 -38
  88. package/dist/machine/compiler.d.ts +71 -0
  89. package/dist/machine/core.d.ts +50 -0
  90. package/dist/machine/persistence.d.ts +5 -0
  91. package/dist/machine/runtime.d.ts +4 -0
  92. package/dist/machine/testing.d.ts +43 -0
  93. package/dist/machine/types.d.ts +155 -0
  94. package/dist/machine-testing.cjs +1 -0
  95. package/dist/machine-testing.js +188 -0
  96. package/dist/machine.cjs +1 -0
  97. package/dist/machine.js +837 -0
  98. package/dist/main.d.ts +20 -0
  99. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  100. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  101. package/dist/path/RaphKernel.d.ts +13 -10
  102. package/dist/path/data-path.types.d.ts +34 -0
  103. package/dist/path/data-path.utils.d.ts +9 -0
  104. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  105. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  106. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  107. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  108. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  109. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  110. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  111. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  112. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  113. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  114. package/dist/path/path.types.d.ts +3 -2
  115. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  116. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  117. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  118. package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
  119. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
  120. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  121. package/dist/path.cjs +1 -1
  122. package/dist/path.js +16 -16
  123. package/dist/raph.cjs +1 -1
  124. package/dist/raph.js +46 -38
  125. package/dist/reactivity/engine.d.ts +17 -3
  126. package/dist/reactivity/reactive-object.d.ts +36 -0
  127. package/dist/reactivity/types.d.ts +25 -0
  128. package/dist/reactivity.cjs +1 -1
  129. package/dist/reactivity.js +12 -12
  130. package/dist/runtime/RaphRuntime.d.ts +132 -192
  131. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  132. package/dist/runtime/errors.d.ts +5 -0
  133. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  134. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  135. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  136. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  137. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  138. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  139. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  140. package/dist/runtime/phases/phase.types.d.ts +92 -0
  141. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  142. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  143. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  144. package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
  145. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
  146. package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
  147. package/dist/runtime.cjs +1 -1
  148. package/dist/runtime.js +21 -16
  149. package/package.json +68 -35
  150. package/ReadMe.md +0 -153
  151. package/dist/api/public.d.ts +0 -22
  152. package/dist/debug/api/public.cjs +0 -1
  153. package/dist/debug/api/public.js +0 -40
  154. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  155. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  156. package/dist/debug/path/PathEventHub.cjs +0 -1
  157. package/dist/debug/path/PathStore.cjs +0 -1
  158. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  159. package/dist/debug/path/data-adapter.cjs +0 -1
  160. package/dist/debug/path/data-path.cjs +0 -1
  161. package/dist/debug/path/derived-collection.cjs +0 -1
  162. package/dist/debug/path/path-router.cjs +0 -1
  163. package/dist/debug/path/public.cjs +0 -1
  164. package/dist/debug/path/public.js +0 -18
  165. package/dist/debug/runtime/PathHandle.cjs +0 -1
  166. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  167. package/dist/debug/runtime/RaphDebug.js +0 -15
  168. package/dist/debug/runtime/RaphNode.cjs +0 -1
  169. package/dist/debug/runtime/RaphNode.js +0 -143
  170. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  171. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  172. package/dist/debug/runtime/RaphScope.cjs +0 -1
  173. package/dist/debug/runtime/RaphScope.js +0 -64
  174. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  175. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  176. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  177. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  178. package/dist/debug/runtime/public.cjs +0 -1
  179. package/dist/debug/runtime/public.js +0 -18
  180. package/dist/path/public.d.ts +0 -14
  181. package/dist/runtime/RaphDebug.d.ts +0 -32
  182. package/dist/runtime/RaphNode.d.ts +0 -68
  183. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  184. package/dist/runtime/RaphScope.d.ts +0 -50
  185. package/dist/runtime/phase.types.d.ts +0 -49
  186. package/dist/runtime/public.d.ts +0 -13
  187. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  188. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  189. /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
  190. /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
  191. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  192. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  193. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  194. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  195. /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
  196. /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
  197. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  198. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  199. /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
  200. /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
  201. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  202. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  203. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  204. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  205. /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
  206. /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
  207. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  208. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  209. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  210. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  211. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./DataPath.cjs"),f=2e4;let n,s;function u(e,t){if(!(t!=null&&t.vars)){const r=n==null?void 0:n.get(e);if(r!==void 0)return r}if(typeof e!="string")return g(e,t);const a=c.DataPath._parseExactString(e,t);if(!(t!=null&&t.vars)){const r=n??(n=new Map);r.size>=f&&r.clear(),r.set(e,a)}return a}function i(e){const t=s==null?void 0:s.get(e);if(t!==void 0)return t;if(typeof e!="string")return h(e);const a=c.DataPath._parseMaskString(e),r=s??(s=new Map);return r.size>=f&&r.clear(),r.set(e,a),a}function l(e){if(e.segments.length===0)return["*"];const t=[`${e.canonical}.*`];for(let a=1;a<e.segments.length;a++)t.push(c.DataPath._renderSegments(e.segments.slice(0,a)));return t}function g(e,t){const a=c.DataPath.from(e,t)._asExact();if(e instanceof c.DataPath&&!(t!=null&&t.vars)){const r=n??(n=new Map);r.size>=f&&r.clear(),r.set(e,a)}return a}function h(e){const t=c.DataPath.from(e)._asMask();if(e instanceof c.DataPath){const a=s??(s=new Map);a.size>=f&&a.clear(),a.set(e,t)}return t}exports.parseDataPath=u;exports.parsePathMask=i;exports.pathRelationMasks=l;
@@ -0,0 +1,56 @@
1
+ import { DataPath as n } from "./DataPath.js";
2
+ const f = 2e4;
3
+ let a, s;
4
+ function g(e, r) {
5
+ if (!(r != null && r.vars)) {
6
+ const c = a == null ? void 0 : a.get(e);
7
+ if (c !== void 0)
8
+ return c;
9
+ }
10
+ if (typeof e != "string")
11
+ return i(e, r);
12
+ const t = n._parseExactString(e, r);
13
+ if (!(r != null && r.vars)) {
14
+ const c = a ?? (a = /* @__PURE__ */ new Map());
15
+ c.size >= f && c.clear(), c.set(e, t);
16
+ }
17
+ return t;
18
+ }
19
+ function M(e) {
20
+ const r = s == null ? void 0 : s.get(e);
21
+ if (r !== void 0)
22
+ return r;
23
+ if (typeof e != "string")
24
+ return u(e);
25
+ const t = n._parseMaskString(e), c = s ?? (s = /* @__PURE__ */ new Map());
26
+ return c.size >= f && c.clear(), c.set(e, t), t;
27
+ }
28
+ function d(e) {
29
+ if (e.segments.length === 0)
30
+ return ["*"];
31
+ const r = [`${e.canonical}.*`];
32
+ for (let t = 1; t < e.segments.length; t++)
33
+ r.push(n._renderSegments(e.segments.slice(0, t)));
34
+ return r;
35
+ }
36
+ function i(e, r) {
37
+ const t = n.from(e, r)._asExact();
38
+ if (e instanceof n && !(r != null && r.vars)) {
39
+ const c = a ?? (a = /* @__PURE__ */ new Map());
40
+ c.size >= f && c.clear(), c.set(e, t);
41
+ }
42
+ return t;
43
+ }
44
+ function u(e) {
45
+ const r = n.from(e)._asMask();
46
+ if (e instanceof n) {
47
+ const t = s ?? (s = /* @__PURE__ */ new Map());
48
+ t.size >= f && t.clear(), t.set(e, r);
49
+ }
50
+ return r;
51
+ }
52
+ export {
53
+ g as parseDataPath,
54
+ M as parsePathMask,
55
+ d as pathRelationMasks
56
+ };
@@ -0,0 +1 @@
1
+ "use strict";var h=Object.defineProperty;var _=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../data-path.utils.cjs"),u=require("../PathRouter.cjs"),f=require("./derived-collection.utils.cjs"),g=2e4;class v{constructor(){d(this,"_router");d(this,"_handles");d(this,"_matches");d(this,"_pending");d(this,"_collections");d(this,"_counter",0)}get size(){var e;return((e=this._handles)==null?void 0:e.size)??0}get pending(){return this._pending}nextId(){return`derived-${this._counter++}`}has(e){var t;return((t=this._handles)==null?void 0:t.has(e))??!1}values(){var e;return((e=this._handles)==null?void 0:e.values())??[][Symbol.iterator]()}state(e){var t;return(t=this._collections)==null?void 0:t.get(e)}register(e,t,i){(this._handles??(this._handles=new Map)).set(e.id,e),i!==void 0&&(this._collections??(this._collections=new Map)).set(e,{from:t,kind:i.kind,key:i.key,initialized:!1,full:!0,keys:new Set,sourceIndex:void 0,targetIndex:void 0});const n=this._router??(this._router=new u.PathRouter);this._matches=void 0,e._attachRoutes(l.pathRelationMasks(t).map(s=>n.add(l.parsePathMask(s),e)))}remove(e){var i,o,n;const t=this._handles;(t==null?void 0:t.get(e.id))===e&&(t.delete(e.id),e._detachRoutes(),this._matches=void 0,(i=this._pending)==null||i.delete(e),(o=this._collections)==null||o.delete(e),((n=this._collections)==null?void 0:n.size)===0&&(this._collections=void 0),t.size===0&&(this._handles=void 0,this._router=void 0,this._pending=void 0))}queue(e){var o;const t=this._matching(e);if(t.length===0)return;const i=this._pending??(this._pending=new Set);for(const n of t){if(n.paused||n.disposed)continue;const s=(o=this._collections)==null?void 0:o.get(n);if(s!==void 0&&s.initialized&&!s.full){const c=f.collectionMutationImpact(s.from,s.key,e);c.kind==="full"?(s.full=!0,s.keys.clear()):s.keys.add(c.key)}i.add(n)}}queueReplacement(e,t){var n;const i=this._matching(e);if(i.length===0)return;const o=this._pending??(this._pending=new Set);for(const s of i){if(s.paused||s.disposed)continue;const c=(n=this._collections)==null?void 0:n.get(s);if(c!==void 0&&c.initialized&&!c.full&&c.from.canonical===e.canonical)for(const a of t)c.keys.add(a);else c!==void 0&&(c.full=!0,c.keys.clear());o.add(s)}}clearPendingIfEmpty(){var e;((e=this._pending)==null?void 0:e.size)===0&&(this._pending=void 0)}dispose(){if(this._handles!==void 0)for(const e of this._handles.values())e._disposeFromKernel();this._handles=void 0,this._router=void 0,this._matches=void 0,this._pending=void 0,this._collections=void 0}_matching(e){var n;const t=this._router;if(t===void 0)return[];let i=(n=this._matches)==null?void 0:n.get(e.canonical);if(i!==void 0)return i;i=[...e.segments.length===0?t.matchAll():t.match(e.segments)];const o=this._matches??(this._matches=new Map);return o.size>=g&&o.clear(),o.set(e.canonical,i),i}}exports.DerivedRegistry=v;
@@ -1,9 +1,9 @@
1
1
  var a = Object.defineProperty;
2
2
  var h = (l, e, t) => e in l ? a(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
3
  var d = (l, e, t) => h(l, typeof e != "symbol" ? e + "" : e, t);
4
- import { pathRelationMasks as _, parsePathMask as u } from "./data-path.js";
5
- import { collectionMutationImpact as f } from "./derived-collection.js";
6
- import { PathRouter as m } from "./path-router.js";
4
+ import { pathRelationMasks as _, parsePathMask as u } from "../data-path.utils.js";
5
+ import { PathRouter as f } from "../PathRouter.js";
6
+ import { collectionMutationImpact as m } from "./derived-collection.utils.js";
7
7
  const g = 2e4;
8
8
  class z {
9
9
  constructor() {
@@ -70,7 +70,7 @@ class z {
70
70
  sourceIndex: void 0,
71
71
  targetIndex: void 0
72
72
  });
73
- const n = this._router ?? (this._router = new m());
73
+ const n = this._router ?? (this._router = new f());
74
74
  this._matches = void 0, e._attachRoutes(_(t).map(
75
75
  (s) => n.add(u(s), e)
76
76
  ));
@@ -97,7 +97,7 @@ class z {
97
97
  continue;
98
98
  const s = (o = this._collections) == null ? void 0 : o.get(n);
99
99
  if (s !== void 0 && s.initialized && !s.full) {
100
- const c = f(s.from, s.key, e);
100
+ const c = m(s.from, s.key, e);
101
101
  c.kind === "full" ? (s.full = !0, s.keys.clear()) : s.keys.add(c.key);
102
102
  }
103
103
  i.add(n);
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../data-path.utils.cjs");function m(e,t,i){if(i.segments.length<=e.segments.length)return{kind:"full"};for(let o=0;o<e.segments.length;o++)if(!$(e.segments[o],i.segments[o]))return{kind:"full"};const r=i.segments[e.segments.length];if((r==null?void 0:r.kind)!=="selector"||r.key!==t||typeof r.value!="string"&&typeof r.value!="number")return{kind:"full"};const n=i.segments[e.segments.length+1];return(n==null?void 0:n.kind)==="key"&&n.key===t?{kind:"full"}:{kind:"key",key:r.value}}function k(e,t,i){const r=p.parseDataPath(e).canonical,n=typeof i=="number"?String(i):JSON.stringify(i);return`${r}[${t}=${n}]`}function g(e,t,i,r){if(!Array.isArray(i)||!Array.isArray(r))throw f(e,"requires array source and output");if(i.length!==r.length)throw f(e,"must preserve collection cardinality");const n=a(i,t,"source"),o=a(r,t,"output");for(let s=0;s<n.length;s++)if(n[s]!==o[s])throw f(e,"must preserve key order")}function h(e,t,i,r){if(!Array.isArray(r))throw f(e,"incremental compute must return an array");if(i.length!==r.length)throw f(e,"incremental compute must preserve cardinality");const n=a(r,t,"output");for(let o=0;o<i.length;o++)if(i[o]!==n[o])throw f(e,"incremental compute must preserve key order")}function w(e,t,i,r){if(!Array.isArray(i)||!Array.isArray(r))throw u(e,"requires array source and output");d(e,"output must be an ordered subset of source",a(i,t,"source"),a(r,t,"output"))}function b(e,t,i,r){if(!Array.isArray(r))throw u(e,"incremental compute must return an array");d(e,"incremental output must be an ordered subset of input",i,a(r,t,"output"))}function a(e,t,i){const r=new Set,n=[];for(let o=0;o<e.length;o++){if(!(o in e)){n.push(void 0);continue}const s=e[o];if(!y(s))throw new TypeError(`[Raph] ${i} collection items must be objects.`);const c=s[t];if(typeof c!="string"&&typeof c!="number")throw new TypeError(`[Raph] ${i} item key "${t}" must be a string or number.`);if(r.has(c))throw new TypeError(`[Raph] Duplicate ${i} key: "${String(c)}".`);r.add(c),n.push(c)}return n}function A(e,t,i){const r=a(e,t,i),n=new Map;for(let o=0;o<r.length;o++){const s=r[o];s!==void 0&&n.set(s,o)}return n}function x(e,t,i,r){for(const n of r){const o=i.get(n);if(o===void 0)return!0;const s=e[o];if(!y(s)||s[t]!==n)return!0}return!1}function f(e,t){return new TypeError(`[Raph] collectionByKey derived "${e}" ${t}.`)}function u(e,t){return new TypeError(`[Raph] filterByKey derived "${e}" ${t}.`)}function E(e){return l(e,new WeakMap)}function d(e,t,i,r){const n=new Map;for(let s=0;s<i.length;s++){const c=i[s];c!==void 0&&n.set(c,s)}let o=-1;for(const s of r){if(s===void 0)continue;const c=n.get(s);if(c===void 0||c<=o)throw u(e,t);o=c}}function l(e,t){if(e===null||typeof e!="object")return e;const i=t.get(e);if(i!==void 0)return i;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const n=new Map;t.set(e,n);for(const[o,s]of e)n.set(l(o,t),l(s,t));return n}if(e instanceof Set){const n=new Set;t.set(e,n);for(const o of e)n.add(l(o,t));return n}if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return structuredClone(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(let o=0;o<e.length;o++)o in e&&(n[o]=l(e[o],t));return n}const r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(const n of Reflect.ownKeys(e))r[n]=l(e[n],t);return r}function $(e,t){return e.kind!==t.kind?!1:e.kind==="key"&&t.kind==="key"?e.key===t.key:e.kind==="index"&&t.kind==="index"?e.index===t.index:e.kind==="selector"&&t.kind==="selector"&&e.key===t.key&&Object.is(e.value,t.value)}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}exports.cloneMaterializedValue=E;exports.collectionError=f;exports.collectionIndex=A;exports.collectionKeys=a;exports.collectionMutationImpact=m;exports.filterError=u;exports.indexesAreStale=x;exports.keyedPath=k;exports.validateFullCollection=g;exports.validateFullFilter=w;exports.validateIncrementalCollection=h;exports.validateIncrementalFilter=b;
@@ -1,4 +1,4 @@
1
- import { parseDataPath as p } from "./data-path.js";
1
+ import { parseDataPath as p } from "../data-path.utils.js";
2
2
  function g(e, t, i) {
3
3
  if (i.segments.length <= e.segments.length)
4
4
  return { kind: "full" };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var p=(d,e,t)=>e in d?v(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var l=(d,e,t)=>p(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./data-path.cjs"),g=require("./path-router.cjs"),m=require("./RaphMeta.cjs"),_=require("./RaphMetaStore.cjs");class b{constructor(e,t,r){l(this,"_facade");l(this,"_store");l(this,"_router");l(this,"_pending");l(this,"_publishing",!1);l(this,"_watcherCount",0);l(this,"_deferredWatcherCount",0);this._kernel=e,this._ownerExists=t,this._publicationDeferred=r}get facade(){return this._facade??(this._facade=new m.RaphMeta(this._kernel))}get size(){var e;return((e=this._store)==null?void 0:e.size)??0}get hasWatchers(){return this._router!==void 0}get hasDeferredWatchers(){return this._deferredWatcherCount!==0}get(e,t){var r;return(r=this._store)==null?void 0:r.get(e,t)}has(e,t){var r;return((r=this._store)==null?void 0:r.has(e,t))??!1}set(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).set(e,t,r),this.record("set",e,t,"explicit",i)}merge(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).merge(e,t,r),this.record("merge",e,t,"explicit",i)}delete(e,t,r){var i;return(i=this._store)!=null&&i.delete(e,t)?(this.record("delete",e,t??null,"explicit",r),!0):!1}deleteSubtree(e,t){const r=this._store;if(r!==void 0)for(const i of r.deleteSubtree(e))this.record("delete",i,null,t)}pruneMissing(e,t){const r=this._store;if(r===void 0||r.size===0)return;const n=e.segments().findIndex(s=>s.kind==="index"||s.kind==="selector"),c=n===-1?e:f.DataPath.fromPlain({segs:e.toPlain().segs.slice(0,n)});for(const s of r.pruneMissing(c,o=>this._ownerExists(o)))this.record("delete",s,null,t)}watch(e,t,r={},i){const n=Array.isArray(e)?e:[e];if(n.length===0)throw new TypeError("[RaphMeta] watch requires at least one mask.");const c=new Map;for(const a of n){const u=f.DataPath.from(a,r)._asMask();c.set(u.canonical,u)}const s={active:!0,callback:t,afterPublish:i,...r.namespace===void 0?{}:{namespace:r.namespace}},o=this._router??(this._router=new g.PathRouter),h=[...c.values()].map(a=>o.add(a,s));return this._watcherCount++,i!==void 0&&this._deferredWatcherCount++,w(()=>{s.active=!1,s.callback=void 0,s.afterPublish=void 0;for(const a of h)a();this._watcherCount--,i!==void 0&&this._deferredWatcherCount--,this._watcherCount===0&&(this._router=void 0)})}record(e,t,r,i,n){(this._pending??(this._pending=[])).push({event:{kind:e,path:t,namespace:r,cause:i},invalidate:(n==null?void 0:n.invalidate)??!0}),!this._publicationDeferred()&&!this._publishing&&this.publish()}publish(){const e=this._pending;if(e===void 0||e.length===0||this._publishing)return;const t=[],r=new Map;this._publishing=!0;try{for(;e.length!==0;){const i=e.splice(0),n=this._router;if(n===void 0)continue;const c=new Map;for(const s of i){const o=s.event;for(const h of n.match(o.path._asExact().segments)){if(h.namespace!==void 0&&o.namespace!==null&&h.namespace!==o.namespace)continue;const a=c.get(h);a===void 0?c.set(h,{events:[o],invalidate:s.invalidate}):(a.events.push(o),s.invalidate&&(a.invalidate=!0))}}for(const[s,o]of c){if(!s.active||s.callback===void 0)continue;const h=s.afterPublish;h!==void 0&&r.set(h,(r.get(h)??!1)||o.invalidate);try{s.callback({events:o.events})}catch(a){t.push(a)}}}}finally{this._publishing=!1}for(const[i,n]of r)try{i(n)}catch(c){t.push(c)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[RaphMeta] Multiple watchers failed.")}dispose(){var e;(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}}function w(d){let e=d;return()=>{const t=e;e=void 0,t==null||t()}}exports.MetaController=b;
1
+ "use strict";var v=Object.defineProperty;var p=(d,e,t)=>e in d?v(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var l=(d,e,t)=>p(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../DataPath.cjs"),g=require("../PathRouter.cjs"),m=require("./RaphMeta.cjs"),_=require("./RaphMetaStore.cjs");class b{constructor(e,t,r){l(this,"_facade");l(this,"_store");l(this,"_router");l(this,"_pending");l(this,"_publishing",!1);l(this,"_watcherCount",0);l(this,"_deferredWatcherCount",0);this._kernel=e,this._ownerExists=t,this._publicationDeferred=r}get facade(){return this._facade??(this._facade=new m.RaphMeta(this._kernel))}get size(){var e;return((e=this._store)==null?void 0:e.size)??0}get hasWatchers(){return this._router!==void 0}get hasDeferredWatchers(){return this._deferredWatcherCount!==0}get(e,t){var r;return(r=this._store)==null?void 0:r.get(e,t)}has(e,t){var r;return((r=this._store)==null?void 0:r.has(e,t))??!1}set(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).set(e,t,r),this.record("set",e,t,"explicit",i)}merge(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).merge(e,t,r),this.record("merge",e,t,"explicit",i)}delete(e,t,r){var i;return(i=this._store)!=null&&i.delete(e,t)?(this.record("delete",e,t??null,"explicit",r),!0):!1}deleteSubtree(e,t){const r=this._store;if(r!==void 0)for(const i of r.deleteSubtree(e))this.record("delete",i,null,t)}pruneMissing(e,t){const r=this._store;if(r===void 0||r.size===0)return;const n=e.segments().findIndex(s=>s.kind==="index"||s.kind==="selector"),c=n===-1?e:f.DataPath.fromPlain({segs:e.toPlain().segs.slice(0,n)});for(const s of r.pruneMissing(c,o=>this._ownerExists(o)))this.record("delete",s,null,t)}watch(e,t,r={},i){const n=Array.isArray(e)?e:[e];if(n.length===0)throw new TypeError("[RaphMeta] watch requires at least one mask.");const c=new Map;for(const a of n){const u=f.DataPath.from(a,r)._asMask();c.set(u.canonical,u)}const s={active:!0,callback:t,afterPublish:i,...r.namespace===void 0?{}:{namespace:r.namespace}},o=this._router??(this._router=new g.PathRouter),h=[...c.values()].map(a=>o.add(a,s));return this._watcherCount++,i!==void 0&&this._deferredWatcherCount++,w(()=>{s.active=!1,s.callback=void 0,s.afterPublish=void 0;for(const a of h)a();this._watcherCount--,i!==void 0&&this._deferredWatcherCount--,this._watcherCount===0&&(this._router=void 0)})}record(e,t,r,i,n){(this._pending??(this._pending=[])).push({event:{kind:e,path:t,namespace:r,cause:i},invalidate:(n==null?void 0:n.invalidate)??!0}),!this._publicationDeferred()&&!this._publishing&&this.publish()}publish(){const e=this._pending;if(e===void 0||e.length===0||this._publishing)return;const t=[],r=new Map;this._publishing=!0;try{for(;e.length!==0;){const i=e.splice(0),n=this._router;if(n===void 0)continue;const c=new Map;for(const s of i){const o=s.event;for(const h of n.match(o.path._asExact().segments)){if(h.namespace!==void 0&&o.namespace!==null&&h.namespace!==o.namespace)continue;const a=c.get(h);a===void 0?c.set(h,{events:[o],invalidate:s.invalidate}):(a.events.push(o),s.invalidate&&(a.invalidate=!0))}}for(const[s,o]of c){if(!s.active||s.callback===void 0)continue;const h=s.afterPublish;h!==void 0&&r.set(h,(r.get(h)??!1)||o.invalidate);try{s.callback({events:o.events})}catch(a){t.push(a)}}}}finally{this._publishing=!1}for(const[i,n]of r)try{i(n)}catch(c){t.push(c)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[RaphMeta] Multiple watchers failed.")}dispose(){var e;(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}}function w(d){let e=d;return()=>{const t=e;e=void 0,t==null||t()}}exports.MetaController=b;
@@ -1,8 +1,8 @@
1
1
  var v = Object.defineProperty;
2
2
  var p = (d, e, t) => e in d ? v(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
3
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";
4
+ import { DataPath as f } from "../DataPath.js";
5
+ import { PathRouter as g } from "../PathRouter.js";
6
6
  import { RaphMeta as m } from "./RaphMeta.js";
7
7
  import { RaphMetaStore as _ } from "./RaphMetaStore.js";
8
8
  class k {
@@ -130,7 +130,7 @@ class k {
130
130
  });
131
131
  }
132
132
  /**
133
- * Добавляет событие в текущую transaction либо публикует его сразу.
133
+ * Добавляет событие в текущую batch либо публикует его сразу.
134
134
  */
135
135
  record(e, t, r, i, o) {
136
136
  (this._pending ?? (this._pending = [])).push({
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var _=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>_(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../pathSegmentKey.cjs");function d(){return{children:new Map,namespaces:new Map,path:void 0}}class g{constructor(){a(this,"_root",d());a(this,"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(l(s)&&l(r)){for(const i of Object.keys(r))y(s,i,r[i]);return}this.set(e,t,r)}delete(e,t){var i;const r=this._findStack(e),s=(i=r.at(-1))==null?void 0:i.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 u=r.children.get(t[c]);if(u===void 0)return[];r=u}const s=r.children.get(t.at(-1));if(s===void 0)return[];const i=h(s);return this.size-=f(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=h(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=d(),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(m.pathSegmentKey)}function h(n){const e=n.path!==void 0&&n.namespaces.size!==0?[n.path]:[];for(const t of n.children.values())e.push(...h(t));return e}function f(n){let e=n.namespaces.size;for(const t of n.children.values())e+=f(t);return e}function l(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function y(n,e,t){if(e!=="__proto__"){n[e]=t;return}Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}exports.RaphMetaStore=g;
@@ -1,7 +1,7 @@
1
1
  var p = Object.defineProperty;
2
2
  var _ = (n, e, t) => e in n ? p(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var h = (n, e, t) => _(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { pathSegmentKey as m } from "./segment-key.js";
4
+ import { pathSegmentKey as m } from "../pathSegmentKey.js";
5
5
  function f() {
6
6
  return { children: /* @__PURE__ */ new Map(), namespaces: /* @__PURE__ */ new Map(), path: void 0 };
7
7
  }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -0,0 +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,7 +1,7 @@
1
1
  var p = Object.defineProperty;
2
2
  var l = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var d = (r, t, e) => l(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { parseDataPath as i } from "./data-path.js";
4
+ import { parseDataPath as i } from "../data-path.utils.js";
5
5
  import { PathEventHub as _ } from "./PathEventHub.js";
6
6
  class k {
7
7
  /**
@@ -10,7 +10,7 @@ class k {
10
10
  constructor(t) {
11
11
  // Публикует изменения внешнего adapter через общий path event lifecycle.
12
12
  d(this, "_eventHub", new _(
13
- "[Raph] Adapter transaction and publication failed."
13
+ "[Raph] Adapter batch and publication failed."
14
14
  ));
15
15
  this._adapter = t;
16
16
  }
@@ -51,7 +51,7 @@ class k {
51
51
  * Объединяет значение по пути и публикует соответствующее изменение.
52
52
  */
53
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) ? f(s) : s;
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;
55
55
  this._adapter.merge(n.canonical, e), this._eventHub.record({
56
56
  kind: "merge",
57
57
  path: n.canonical,
@@ -76,10 +76,10 @@ class k {
76
76
  });
77
77
  }
78
78
  /**
79
- * Выполняет операцию в общей синхронной transaction boundary.
79
+ * Выполняет операцию в общей синхронной batch boundary.
80
80
  */
81
- transaction(t) {
82
- return this._eventHub.transaction(t);
81
+ batch(t) {
82
+ return this._eventHub.batch(t);
83
83
  }
84
84
  /**
85
85
  * Подписывает callback на подходящие изменения и возвращает disposer.
@@ -92,7 +92,7 @@ function u(r, t) {
92
92
  let e = r;
93
93
  for (const a of t)
94
94
  if (a.kind === "key") {
95
- if (!b(e) || !Object.hasOwn(e, a.key))
95
+ if (!f(e) || !Object.hasOwn(e, a.key))
96
96
  return !1;
97
97
  e = e[a.key];
98
98
  } else if (a.kind === "index") {
@@ -111,7 +111,7 @@ function u(r, t) {
111
111
  }
112
112
  return !0;
113
113
  }
114
- function f(r) {
114
+ function b(r) {
115
115
  const t = Object.create(Object.getPrototypeOf(r));
116
116
  for (const e of Object.keys(r))
117
117
  e === "__proto__" ? Object.defineProperty(t, e, {
@@ -125,7 +125,7 @@ function f(r) {
125
125
  function o(r) {
126
126
  return typeof r == "object" && r !== null && !Array.isArray(r);
127
127
  }
128
- function b(r) {
128
+ function f(r) {
129
129
  return Array.isArray(r) || o(r);
130
130
  }
131
131
  export {
@@ -0,0 +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,8 +1,8 @@
1
1
  var j = Object.defineProperty;
2
2
  var C = (o, e, t) => e in o ? j(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var y = (o, e, t) => C(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { createDataDraft as S } from "./data-draft.js";
5
- import { parseDataPath as h } from "./data-path.js";
4
+ import { parseDataPath as h } from "../data-path.utils.js";
5
+ import { createDataDraft as S } from "./createDataDraft.js";
6
6
  class A {
7
7
  /**
8
8
  * Создаёт in-memory adapter с заданным начальным root и опциями.
@@ -0,0 +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,21 +1,21 @@
1
1
  var p = Object.defineProperty;
2
- var f = (a, t, e) => t in a ? p(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var c = (a, t, e) => f(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { parsePathMask as _, parseDataPath as g } from "./data-path.js";
5
- import { PathRouter as v } from "./path-router.js";
2
+ var f = (n, t, e) => t in n ? p(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var c = (n, t, e) => f(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { parsePathMask as _, parseDataPath as g } from "../data-path.utils.js";
5
+ import { PathRouter as b } from "../PathRouter.js";
6
6
  class y {
7
7
  /**
8
- * Создаёт общий transaction и publication boundary для path store.
8
+ * Создаёт общий batch и publication boundary для path store.
9
9
  */
10
10
  constructor(t) {
11
11
  // Хранят ленивый routing и текущий batch path events.
12
12
  c(this, "_router");
13
13
  c(this, "_events");
14
- // Защищают границы transaction, reentrant publication и snapshot requirements.
15
- c(this, "_transactionDepth", 0);
14
+ // Защищают границы batch, reentrant publication и snapshot requirements.
15
+ c(this, "_batchDepth", 0);
16
16
  c(this, "_watcherCount", 0);
17
17
  c(this, "_publishing", !1);
18
- this._transactionErrorMessage = t;
18
+ this._batchErrorMessage = t;
19
19
  }
20
20
  /**
21
21
  * Показывает, есть ли watchers, ради которых нужно сохранять значения событий.
@@ -24,7 +24,7 @@ class y {
24
24
  return this._watcherCount !== 0;
25
25
  }
26
26
  /**
27
- * Возвращает накопленные события текущей transaction.
27
+ * Возвращает накопленные события текущей batch.
28
28
  * @internal
29
29
  */
30
30
  get events() {
@@ -45,24 +45,24 @@ class y {
45
45
  return this._watcherCount;
46
46
  }
47
47
  /**
48
- * Добавляет событие в текущую transaction либо публикует его сразу.
48
+ * Добавляет событие в текущую batch либо публикует его сразу.
49
49
  */
50
50
  record(t) {
51
- this._watcherCount !== 0 && ((this._events ?? (this._events = [])).push(t), this._transactionDepth === 0 && !this._publishing && this._publish());
51
+ this._watcherCount !== 0 && ((this._events ?? (this._events = [])).push(t), this._batchDepth === 0 && !this._publishing && this._publish());
52
52
  }
53
53
  /**
54
- * Выполняет операцию в общей синхронной transaction boundary.
54
+ * Выполняет операцию в общей синхронной batch boundary.
55
55
  */
56
- transaction(t) {
57
- var n;
58
- let e = !1, h, o = !1, i, s;
59
- this._transactionDepth++;
56
+ batch(t) {
57
+ var h;
58
+ let e = !1, a, o = !1, i, s;
59
+ this._batchDepth++;
60
60
  try {
61
61
  s = t();
62
62
  } catch (r) {
63
- e = !0, h = r;
63
+ e = !0, a = r;
64
64
  } finally {
65
- if (this._transactionDepth--, this._transactionDepth === 0 && ((n = this._events) != null && n.length))
65
+ if (this._batchDepth--, this._batchDepth === 0 && ((h = this._events) != null && h.length))
66
66
  try {
67
67
  this._publish();
68
68
  } catch (r) {
@@ -71,11 +71,11 @@ class y {
71
71
  }
72
72
  if (e && o)
73
73
  throw new AggregateError(
74
- [h, i],
75
- this._transactionErrorMessage
74
+ [a, i],
75
+ this._batchErrorMessage
76
76
  );
77
77
  if (e)
78
- throw h;
78
+ throw a;
79
79
  if (o)
80
80
  throw i;
81
81
  return s;
@@ -84,18 +84,18 @@ class y {
84
84
  * Подписывает callback на подходящие изменения и возвращает disposer.
85
85
  */
86
86
  watch(t, e) {
87
- const h = Array.isArray(t) ? t : [t];
88
- if (h.length === 0)
87
+ const a = Array.isArray(t) ? t : [t];
88
+ if (a.length === 0)
89
89
  throw new TypeError("[Raph] Path watch requires at least one mask.");
90
90
  const o = /* @__PURE__ */ new Map();
91
- for (const r of h) {
91
+ for (const r of a) {
92
92
  const u = _(r);
93
93
  o.set(u.canonical, u);
94
94
  }
95
- const i = { active: !0, callback: e }, s = this._router ?? (this._router = new v()), n = [...o.values()].map((r) => s.add(r, i));
96
- return this._watcherCount++, w(() => {
95
+ const i = { active: !0, callback: e }, s = this._router ?? (this._router = new b()), h = [...o.values()].map((r) => s.add(r, i));
96
+ return this._watcherCount++, v(() => {
97
97
  i.active = !1, i.callback = void 0;
98
- for (const r of n)
98
+ for (const r of h)
99
99
  r();
100
100
  this._watcherCount--, this._watcherCount === 0 && (this._router = void 0);
101
101
  });
@@ -108,21 +108,21 @@ class y {
108
108
  this._publishing = !0;
109
109
  try {
110
110
  for (; t.length !== 0; ) {
111
- const h = t.splice(0), o = this._router;
111
+ const a = t.splice(0), o = this._router;
112
112
  if (o === void 0)
113
113
  continue;
114
114
  const i = /* @__PURE__ */ new Map();
115
- for (const s of h) {
116
- const n = g(s.path), r = n.segments.length === 0 ? o.matchAll() : o.match(n.segments);
115
+ for (const s of a) {
116
+ const h = g(s.path), r = h.segments.length === 0 ? o.matchAll() : o.match(h.segments);
117
117
  for (const u of r) {
118
118
  const l = i.get(u);
119
119
  l === void 0 ? i.set(u, [s]) : l.push(s);
120
120
  }
121
121
  }
122
- for (const [s, n] of i)
122
+ for (const [s, h] of i)
123
123
  if (!(!s.active || s.callback === void 0))
124
124
  try {
125
- s.callback({ events: n });
125
+ s.callback({ events: h });
126
126
  } catch (r) {
127
127
  e.push(r);
128
128
  }
@@ -136,8 +136,8 @@ class y {
136
136
  throw new AggregateError(e, "[Raph] Multiple path watchers failed.");
137
137
  }
138
138
  }
139
- function w(a) {
140
- let t = a;
139
+ function v(n) {
140
+ let t = n;
141
141
  return () => {
142
142
  const e = t;
143
143
  t = void 0, e == null || e();
@@ -0,0 +1 @@
1
+ "use strict";var R=Object.defineProperty;var P=(r,e,t)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var v=(r,e,t)=>P(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../data-path.utils.cjs"),H=require("./PathEventHub.cjs"),u=new WeakMap;class m{constructor(){v(this,"_root");v(this,"_eventHub",new H.PathEventHub("[Raph] Path batch and publication failed."))}get _router(){return this._eventHub.router}get _events(){return this._eventHub.events}get _watcherCount(){return this._eventHub.watcherCount}get(e,t){const n=f.parseDataPath(e,t),o=this._root;if(o!==void 0)return h(o,n.segments).value}peek(e,t){return this.get(e,t)}has(e,t){const n=f.parseDataPath(e,t),o=this._root;return o!==void 0&&h(o,n.segments).exists}set(e,t,n){const o=f.parseDataPath(e,n);if(o.segments.length===0){this._setRoot(t);return}const s=this._eventHub.hasWatchers,i=s?h(this._root,o.segments).value:void 0;if(this._root??(this._root=Object.create(null)),w(this._root,o,t),!s)return;const c=h(this._root,o.segments).value;this._eventHub.record({kind:"set",path:o.canonical,previous:i,value:c})}merge(e,t,n){const o=f.parseDataPath(e,n);if(o.segments.length===0){this._mergeRoot(t);return}const s=this._eventHub.hasWatchers,i=h(this._root,o.segments).value,c=s&&a(i)&&a(t)?A(i):i;if(a(i)&&a(t)){p(this._root,o.segments);for(const g of Object.keys(t))l(i,g,t[g])}else this._root??(this._root=Object.create(null)),w(this._root,o,t);if(!s)return;const d=h(this._root,o.segments).value;this._eventHub.record({kind:"merge",path:o.canonical,previous:c,value:d})}delete(e,t){const n=f.parseDataPath(e,t);if(n.segments.length===0){this._deleteRoot();return}const o=h(this._root,n.segments);!o.exists||this._root===void 0||(p(this._root,n.segments),E(this._root,n),this._eventHub.hasWatchers&&this._eventHub.record({kind:"delete",path:n.canonical,previous:o.value,value:void 0}))}batch(e){return this._eventHub.batch(e)}watch(e,t){return this._eventHub.watch(e,t)}_setRoot(e){const t=x(e),n=this._root;this._root=t,this._recordRootEvent("set",n,t)}_mergeRoot(e){const t=this._root,n=this._eventHub.hasWatchers&&a(t)&&a(e)?A(t):t;if(a(t)&&a(e))for(const o of Object.keys(e))l(t,o,e[o]);else this._root=x(e);this._recordRootEvent("merge",n,this._root)}_deleteRoot(){const e=this._root;e!==void 0&&(this._root=D(),this._recordRootEvent("delete",e,void 0))}_recordRootEvent(e,t,n){this._eventHub.record({kind:e,path:"",previous:t,value:n})}}function h(r,e){let t=r;for(const n of e)if(n.kind==="key"){if(!b(t)||!Object.hasOwn(t,n.key))return{exists:!1,value:void 0};t=t[n.key]}else if(n.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,n.index))return{exists:!1,value:void 0};t=t[n.index]}else{if(!Array.isArray(t))return{exists:!1,value:void 0};const o=_(t,n.key,n.value);if(o===-1)return{exists:!1,value:void 0};t=t[o]}return{exists:!0,value:t}}function p(r,e){let t=r;for(const n of e){if(!b(t))return;const o=j(t,n);Array.isArray(t)&&u.delete(t),t=o}}function w(r,e,t){let n=r,o;for(let i=0;i<e.segments.length-1;i++){const c=e.segments[i],d=e.segments[i+1];c.kind==="selector"&&Array.isArray(n)&&(o=n),c.kind==="index"&&Array.isArray(n)&&(o=n),n=C(n,c,d,e.canonical)}const s=e.segments[e.segments.length-1];if(S(n,s,t,e.canonical),s.kind==="key"&&o!==void 0){const i=u.get(o);i==null||i.delete(s.key),(i==null?void 0:i.size)===0&&u.delete(o)}}function E(r,e){let t=r;for(let s=0;s<e.segments.length-1;s++){const i=e.segments[s],c=j(t,i);if(!b(c))return;t=c}const n=e.segments[e.segments.length-1];if(n.kind==="key"){delete t[n.key];return}if(!Array.isArray(t))return;if(n.kind==="index"){u.delete(t),delete t[n.index];return}const o=_(t,n.key,n.value);o!==-1&&(u.delete(t),delete t[o])}function j(r,e){if(e.kind==="key")return Object.hasOwn(r,e.key)?r[e.key]:void 0;if(!Array.isArray(r))return;if(e.kind==="index")return r[e.index];const t=_(r,e.key,e.value);return t===-1?void 0:r[t]}function C(r,e,t,n){if(e.kind==="key"){const s=r;let i=s[e.key];return(!Object.hasOwn(s,e.key)||i===void 0)&&(i=O(t),l(s,e.key,i)),k(i,n)}if(e.kind==="index"){if(!Array.isArray(r))throw y(n);let s=r[e.index];return(!Object.hasOwn(r,e.index)||s===void 0)&&(u.delete(r),s=O(t),r[e.index]=s),k(s,n)}if(!Array.isArray(r))throw y(n);let o=_(r,e.key,e.value);if(o===-1){u.delete(r);const s=Object.create(null);s[e.key]=e.value,r.push(s),o=r.length-1}return k(r[o],n)}function S(r,e,t,n){if(e.kind==="key"){l(r,e.key,t);return}if(e.kind==="index"){if(!Array.isArray(r))throw y(n);u.delete(r),r[e.index]=t;return}if(!Array.isArray(r))throw y(n);const o=_(r,e.key,e.value);if(o!==-1){u.delete(r),r[o]=t;return}if(!a(t))throw new TypeError(`[Raph] New selector target at "${n}" must be an object.`);const s=t[e.key];if(Object.hasOwn(t,e.key)&&!Object.is(s,e.value))throw new TypeError(`[Raph] Selector target at "${n}" has a conflicting key.`);u.delete(r),r.push(Object.hasOwn(t,e.key)?t:{...t,[e.key]:e.value})}function O(r){return r.kind==="index"||r.kind==="selector"?[]:Object.create(null)}function D(){return Object.create(null)}function x(r){if(b(r))return r;throw new TypeError("[Raph] Root value must be an object or array.")}function k(r,e){if(b(r))return r;throw y(e)}function _(r,e,t){let n=u.get(r);const o=n==null?void 0:n.get(e);if(o)return o.get(t)??-1;const s=new Map;for(let i=0;i<r.length;i++){const c=r[i];if(a(c)&&Object.hasOwn(c,e)){const d=c[e];(d===null||typeof d=="string"||typeof d=="number"||typeof d=="boolean")&&!s.has(d)&&s.set(d,i)}}return n||(n=new Map,u.set(r,n)),n.set(e,s),s.get(t)??-1}function l(r,e,t){if(e==="__proto__"){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}r[e]=t}function A(r){const e=Object.create(Object.getPrototypeOf(r));for(const t of Object.keys(r))l(e,t,r[t]);return e}function a(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function b(r){return Array.isArray(r)||a(r)}function y(r){return new TypeError(`[Raph] Cannot traverse non-container data at "${r}".`)}exports.PathStore=m;