@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +9 -1
  107. package/dist/core-ugchZNqC.cjs +0 -1
@@ -1,22 +1,19 @@
1
- var p = Object.defineProperty;
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
- class y {
1
+ import { parsePathMask as l, parseDataPath as p } from "../data-path.utils.js";
2
+ import { PathRouter as _ } from "../PathRouter.js";
3
+ class v {
7
4
  /**
8
5
  * Создаёт общий batch и publication boundary для path store.
9
6
  */
10
7
  constructor(t) {
11
- // Хранят ленивый routing и текущий batch path events.
12
- c(this, "_router");
13
- c(this, "_events");
14
- // Защищают границы batch, reentrant publication и snapshot requirements.
15
- c(this, "_batchDepth", 0);
16
- c(this, "_watcherCount", 0);
17
- c(this, "_publishing", !1);
18
8
  this._batchErrorMessage = t;
19
9
  }
10
+ // Хранят ленивый routing и текущий batch path events.
11
+ _router;
12
+ _events;
13
+ // Защищают границы batch, reentrant publication и snapshot requirements.
14
+ _batchDepth = 0;
15
+ _watcherCount = 0;
16
+ _publishing = !1;
20
17
  /**
21
18
  * Показывает, есть ли watchers, ради которых нужно сохранять значения событий.
22
19
  */
@@ -48,55 +45,71 @@ class y {
48
45
  * Добавляет событие в текущую batch либо публикует его сразу.
49
46
  */
50
47
  record(t) {
51
- this._watcherCount !== 0 && ((this._events ?? (this._events = [])).push(t), this._batchDepth === 0 && !this._publishing && this._publish());
48
+ this._watcherCount !== 0 && ((this._events ??= []).push(t), this._batchDepth === 0 && !this._publishing && this._publish());
52
49
  }
53
50
  /**
54
51
  * Выполняет операцию в общей синхронной batch boundary.
55
52
  */
56
53
  batch(t) {
57
- var h;
58
- let e = !1, a, o = !1, i, s;
54
+ let e = !1, s, r;
59
55
  this._batchDepth++;
60
56
  try {
61
- s = t();
62
- } catch (r) {
63
- e = !0, a = r;
64
- } finally {
65
- if (this._batchDepth--, this._batchDepth === 0 && ((h = this._events) != null && h.length))
66
- try {
67
- this._publish();
68
- } catch (r) {
69
- o = !0, i = r;
70
- }
57
+ r = t();
58
+ } catch (h) {
59
+ e = !0, s = h;
71
60
  }
72
- if (e && o)
61
+ return this._closeBatch(e, s), r;
62
+ }
63
+ /**
64
+ * Открывает batch boundary без closure операции: вызывающий сам исполняет
65
+ * операцию и закрывает boundary через `_closeBatch()`.
66
+ * @internal
67
+ */
68
+ _openBatch() {
69
+ this._batchDepth++;
70
+ }
71
+ /**
72
+ * Закрывает один уровень batch boundary: на внешнем уровне публикует
73
+ * накопленные события. Бросает то же, что `batch()`: ошибку операции, ошибку
74
+ * публикации либо обе в AggregateError; после успешной операции и публикации
75
+ * возвращает управление.
76
+ * @internal
77
+ */
78
+ _closeBatch(t, e) {
79
+ let s = !1, r;
80
+ if (this._batchDepth--, this._batchDepth === 0 && this._events?.length)
81
+ try {
82
+ this._publish();
83
+ } catch (h) {
84
+ s = !0, r = h;
85
+ }
86
+ if (t && s)
73
87
  throw new AggregateError(
74
- [a, i],
88
+ [e, r],
75
89
  this._batchErrorMessage
76
90
  );
77
- if (e)
78
- throw a;
79
- if (o)
80
- throw i;
81
- return s;
91
+ if (t)
92
+ throw e;
93
+ if (s)
94
+ throw r;
82
95
  }
83
96
  /**
84
97
  * Подписывает callback на подходящие изменения и возвращает disposer.
85
98
  */
86
99
  watch(t, e) {
87
- const a = Array.isArray(t) ? t : [t];
88
- if (a.length === 0)
100
+ const s = Array.isArray(t) ? t : [t];
101
+ if (s.length === 0)
89
102
  throw new TypeError("[Raph] Path watch requires at least one mask.");
90
- const o = /* @__PURE__ */ new Map();
91
- for (const r of a) {
92
- const u = _(r);
93
- o.set(u.canonical, u);
103
+ const r = /* @__PURE__ */ new Map();
104
+ for (const o of s) {
105
+ const a = l(o);
106
+ r.set(a.canonical, a);
94
107
  }
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
- i.active = !1, i.callback = void 0;
98
- for (const r of h)
99
- r();
108
+ const h = { active: !0, callback: e }, i = this._router ??= new _(), n = [...r.values()].map((o) => i.add(o, h));
109
+ return this._watcherCount++, f(() => {
110
+ h.active = !1, h.callback = void 0;
111
+ for (const o of n)
112
+ o();
100
113
  this._watcherCount--, this._watcherCount === 0 && (this._router = void 0);
101
114
  });
102
115
  }
@@ -108,23 +121,23 @@ class y {
108
121
  this._publishing = !0;
109
122
  try {
110
123
  for (; t.length !== 0; ) {
111
- const a = t.splice(0), o = this._router;
112
- if (o === void 0)
124
+ const s = t.splice(0), r = this._router;
125
+ if (r === void 0)
113
126
  continue;
114
- const i = /* @__PURE__ */ new Map();
115
- for (const s of a) {
116
- const h = g(s.path), r = h.segments.length === 0 ? o.matchAll() : o.match(h.segments);
117
- for (const u of r) {
118
- const l = i.get(u);
119
- l === void 0 ? i.set(u, [s]) : l.push(s);
127
+ const h = /* @__PURE__ */ new Map();
128
+ for (const i of s) {
129
+ const n = p(i.path), o = n.segments.length === 0 ? r.matchAll() : r.match(n.segments);
130
+ for (const a of o) {
131
+ const u = h.get(a);
132
+ u === void 0 ? h.set(a, [i]) : u.push(i);
120
133
  }
121
134
  }
122
- for (const [s, h] of i)
123
- if (!(!s.active || s.callback === void 0))
135
+ for (const [i, n] of h)
136
+ if (!(!i.active || i.callback === void 0))
124
137
  try {
125
- s.callback({ events: h });
126
- } catch (r) {
127
- e.push(r);
138
+ i.callback({ events: n });
139
+ } catch (o) {
140
+ e.push(o);
128
141
  }
129
142
  }
130
143
  } finally {
@@ -136,13 +149,13 @@ class y {
136
149
  throw new AggregateError(e, "[Raph] Multiple path watchers failed.");
137
150
  }
138
151
  }
139
- function v(n) {
140
- let t = n;
152
+ function f(c) {
153
+ let t = c;
141
154
  return () => {
142
155
  const e = t;
143
- t = void 0, e == null || e();
156
+ t = void 0, e?.();
144
157
  };
145
158
  }
146
159
  export {
147
- y as PathEventHub
160
+ v as PathEventHub
148
161
  };
@@ -1 +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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../data-path.utils.cjs"),j=require("./PathEventHub.cjs"),d=new WeakMap;class R{_root;_eventHub=new j.PathEventHub("[Raph] Path batch and publication failed.");get _batchHub(){return this._eventHub}get(e,t){const n=f.parseDataPath(e,t),s=this._root;if(s!==void 0)return h(s,n.segments).value}peek(e,t){return this.get(e,t)}has(e,t){const n=f.parseDataPath(e,t),s=this._root;return s!==void 0&&h(s,n.segments).exists}set(e,t,n){const s=f.parseDataPath(e,n);if(s.segments.length===0){this._setRoot(t);return}const o=this._eventHub.hasWatchers,i=o?h(this._root,s.segments).value:void 0;if(this._root??=Object.create(null),p(this._root,s,t),!o)return;const c=h(this._root,s.segments).value;this._eventHub.record({kind:"set",path:s.canonical,previous:i,value:c})}merge(e,t,n){const s=f.parseDataPath(e,n);if(s.segments.length===0){this._mergeRoot(t);return}const o=this._eventHub.hasWatchers,i=h(this._root,s.segments).value,c=o&&u(i)&&u(t)?O(i):i;if(u(i)&&u(t)){g(this._root,s.segments);for(const v of Object.keys(t))l(i,v,t[v])}else this._root??=Object.create(null),p(this._root,s,t);if(!o)return;const a=h(this._root,s.segments).value;this._eventHub.record({kind:"merge",path:s.canonical,previous:c,value:a})}delete(e,t){const n=f.parseDataPath(e,t);if(n.segments.length===0){this._deleteRoot();return}const s=h(this._root,n.segments);!s.exists||this._root===void 0||(g(this._root,n.segments),P(this._root,n),this._eventHub.hasWatchers&&this._eventHub.record({kind:"delete",path:n.canonical,previous:s.value,value:void 0}))}batch(e){return this._eventHub.batch(e)}watch(e,t){return this._eventHub.watch(e,t)}_setRoot(e){const t=w(e),n=this._root;this._root=t,this._recordRootEvent("set",n,t)}_mergeRoot(e){const t=this._root,n=this._eventHub.hasWatchers&&u(t)&&u(e)?O(t):t;if(u(t)&&u(e))for(const s of Object.keys(e))l(t,s,e[s]);else this._root=w(e);this._recordRootEvent("merge",n,this._root)}_deleteRoot(){const e=this._root;e!==void 0&&(this._root=E(),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(!_(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 s=b(t,n.key,n.value);if(s===-1)return{exists:!1,value:void 0};t=t[s]}return{exists:!0,value:t}}function g(r,e){let t=r;for(const n of e){if(!_(t))return;const s=A(t,n);Array.isArray(t)&&d.delete(t),t=s}}function p(r,e,t){let n=r,s;for(let i=0;i<e.segments.length-1;i++){const c=e.segments[i],a=e.segments[i+1];c.kind==="selector"&&Array.isArray(n)&&(s=n),c.kind==="index"&&Array.isArray(n)&&(s=n),n=H(n,c,a,e.canonical)}const o=e.segments[e.segments.length-1];if(m(n,o,t,e.canonical),o.kind==="key"&&s!==void 0){const i=d.get(s);i?.delete(o.key),i?.size===0&&d.delete(s)}}function P(r,e){let t=r;for(let o=0;o<e.segments.length-1;o++){const i=e.segments[o],c=A(t,i);if(!_(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"){d.delete(t),delete t[n.index];return}const s=b(t,n.key,n.value);s!==-1&&(d.delete(t),delete t[s])}function A(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=b(r,e.key,e.value);return t===-1?void 0:r[t]}function H(r,e,t,n){if(e.kind==="key"){const o=r;let i=o[e.key];return(!Object.hasOwn(o,e.key)||i===void 0)&&(i=x(t),l(o,e.key,i)),k(i,n)}if(e.kind==="index"){if(!Array.isArray(r))throw y(n);let o=r[e.index];return(!Object.hasOwn(r,e.index)||o===void 0)&&(d.delete(r),o=x(t),r[e.index]=o),k(o,n)}if(!Array.isArray(r))throw y(n);let s=b(r,e.key,e.value);if(s===-1){d.delete(r);const o=Object.create(null);o[e.key]=e.value,r.push(o),s=r.length-1}return k(r[s],n)}function m(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);d.delete(r),r[e.index]=t;return}if(!Array.isArray(r))throw y(n);const s=b(r,e.key,e.value);if(s!==-1){d.delete(r),r[s]=t;return}if(!u(t))throw new TypeError(`[Raph] New selector target at "${n}" must be an object.`);const o=t[e.key];if(Object.hasOwn(t,e.key)&&!Object.is(o,e.value))throw new TypeError(`[Raph] Selector target at "${n}" has a conflicting key.`);d.delete(r),r.push(Object.hasOwn(t,e.key)?t:{...t,[e.key]:e.value})}function x(r){return r.kind==="index"||r.kind==="selector"?[]:Object.create(null)}function E(){return Object.create(null)}function w(r){if(_(r))return r;throw new TypeError("[Raph] Root value must be an object or array.")}function k(r,e){if(_(r))return r;throw y(e)}function b(r,e,t){let n=d.get(r);const s=n?.get(e);if(s)return s.get(t)??-1;const o=new Map;for(let i=0;i<r.length;i++){const c=r[i];if(u(c)&&Object.hasOwn(c,e)){const a=c[e];(a===null||typeof a=="string"||typeof a=="number"||typeof a=="boolean")&&!o.has(a)&&o.set(a,i)}}return n||(n=new Map,d.set(r,n)),n.set(e,o),o.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 O(r){const e=Object.create(Object.getPrototypeOf(r));for(const t of Object.keys(r))l(e,t,r[t]);return e}function u(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function _(r){return Array.isArray(r)||u(r)}function y(r){return new TypeError(`[Raph] Cannot traverse non-container data at "${r}".`)}exports.PathStore=R;
@@ -1,37 +1,27 @@
1
- var R = Object.defineProperty;
2
- var m = (r, e, t) => e in r ? R(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var k = (r, e, t) => m(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { parseDataPath as h } from "../data-path.utils.js";
5
- import { PathEventHub as H } from "./PathEventHub.js";
6
- const u = /* @__PURE__ */ new WeakMap();
7
- class $ {
8
- constructor() {
9
- // Владеют path data и независимым event lifecycle этого store.
10
- k(this, "_root");
11
- k(this, "_eventHub", new H(
12
- "[Raph] Path batch and publication failed."
13
- ));
14
- }
1
+ import { parseDataPath as a } from "../data-path.utils.js";
2
+ import { PathEventHub as j } from "./PathEventHub.js";
3
+ const d = /* @__PURE__ */ new WeakMap();
4
+ class S {
5
+ // Владеют path data и независимым event lifecycle этого store.
6
+ _root;
7
+ _eventHub = new j(
8
+ "[Raph] Path batch and publication failed."
9
+ );
15
10
  /**
16
- * Возвращает внутренний router для диагностического контракта Kernel.
11
+ * Возвращает владельца batch boundary этого store: Kernel открывает и
12
+ * закрывает её без closure операции.
17
13
  * @internal
18
14
  */
19
- get _router() {
20
- return this._eventHub.router;
21
- }
22
- get _events() {
23
- return this._eventHub.events;
24
- }
25
- get _watcherCount() {
26
- return this._eventHub.watcherCount;
15
+ get _batchHub() {
16
+ return this._eventHub;
27
17
  }
28
18
  /**
29
19
  * Возвращает значение по пути без создания отсутствующих данных.
30
20
  */
31
21
  get(e, t) {
32
- const n = h(e, t), o = this._root;
22
+ const n = a(e, t), o = this._root;
33
23
  if (o !== void 0)
34
- return a(o, n.segments).value;
24
+ return l(o, n.segments).value;
35
25
  }
36
26
  /**
37
27
  * Читает значение по пути без регистрации реактивной зависимости.
@@ -43,22 +33,22 @@ class $ {
43
33
  * Проверяет наличие значения по указанному пути.
44
34
  */
45
35
  has(e, t) {
46
- const n = h(e, t), o = this._root;
47
- return o !== void 0 && a(o, n.segments).exists;
36
+ const n = a(e, t), o = this._root;
37
+ return o !== void 0 && l(o, n.segments).exists;
48
38
  }
49
39
  /**
50
40
  * Записывает значение и публикует соответствующее изменение.
51
41
  */
52
42
  set(e, t, n) {
53
- const o = h(e, n);
43
+ const o = a(e, n);
54
44
  if (o.segments.length === 0) {
55
45
  this._setRoot(t);
56
46
  return;
57
47
  }
58
- const s = this._eventHub.hasWatchers, i = s ? a(this._root, o.segments).value : void 0;
59
- if (this._root ?? (this._root = /* @__PURE__ */ Object.create(null)), O(this._root, o, t), !s)
48
+ const s = this._eventHub.hasWatchers, i = s ? l(this._root, o.segments).value : void 0;
49
+ if (this._root ??= /* @__PURE__ */ Object.create(null), w(this._root, o, t), !s)
60
50
  return;
61
- const c = a(this._root, o.segments).value;
51
+ const c = l(this._root, o.segments).value;
62
52
  this._eventHub.record({
63
53
  kind: "set",
64
54
  path: o.canonical,
@@ -70,21 +60,21 @@ class $ {
70
60
  * Объединяет значение по пути и публикует соответствующее изменение.
71
61
  */
72
62
  merge(e, t, n) {
73
- const o = h(e, n);
63
+ const o = a(e, n);
74
64
  if (o.segments.length === 0) {
75
65
  this._mergeRoot(t);
76
66
  return;
77
67
  }
78
- const s = this._eventHub.hasWatchers, i = a(this._root, o.segments).value, c = s && d(i) && d(t) ? A(i) : i;
79
- if (d(i) && d(t)) {
80
- g(this._root, o.segments);
81
- for (const w of Object.keys(t))
82
- l(i, w, t[w]);
68
+ const s = this._eventHub.hasWatchers, i = l(this._root, o.segments).value, c = s && u(i) && u(t) ? p(i) : i;
69
+ if (u(i) && u(t)) {
70
+ x(this._root, o.segments);
71
+ for (const v of Object.keys(t))
72
+ h(i, v, t[v]);
83
73
  } else
84
- this._root ?? (this._root = /* @__PURE__ */ Object.create(null)), O(this._root, o, t);
74
+ this._root ??= /* @__PURE__ */ Object.create(null), w(this._root, o, t);
85
75
  if (!s)
86
76
  return;
87
- const f = a(this._root, o.segments).value;
77
+ const f = l(this._root, o.segments).value;
88
78
  this._eventHub.record({
89
79
  kind: "merge",
90
80
  path: o.canonical,
@@ -96,13 +86,13 @@ class $ {
96
86
  * Удаляет значение по пути и публикует изменение при наличии данных.
97
87
  */
98
88
  delete(e, t) {
99
- const n = h(e, t);
89
+ const n = a(e, t);
100
90
  if (n.segments.length === 0) {
101
91
  this._deleteRoot();
102
92
  return;
103
93
  }
104
- const o = a(this._root, n.segments);
105
- !o.exists || this._root === void 0 || (g(this._root, n.segments), E(this._root, n), this._eventHub.hasWatchers && this._eventHub.record({
94
+ const o = l(this._root, n.segments);
95
+ !o.exists || this._root === void 0 || (x(this._root, n.segments), R(this._root, n), this._eventHub.hasWatchers && this._eventHub.record({
106
96
  kind: "delete",
107
97
  path: n.canonical,
108
98
  previous: o.value,
@@ -122,31 +112,31 @@ class $ {
122
112
  return this._eventHub.watch(e, t);
123
113
  }
124
114
  _setRoot(e) {
125
- const t = x(e), n = this._root;
115
+ const t = g(e), n = this._root;
126
116
  this._root = t, this._recordRootEvent("set", n, t);
127
117
  }
128
118
  _mergeRoot(e) {
129
- const t = this._root, n = this._eventHub.hasWatchers && d(t) && d(e) ? A(t) : t;
130
- if (d(t) && d(e))
119
+ const t = this._root, n = this._eventHub.hasWatchers && u(t) && u(e) ? p(t) : t;
120
+ if (u(t) && u(e))
131
121
  for (const o of Object.keys(e))
132
- l(t, o, e[o]);
122
+ h(t, o, e[o]);
133
123
  else
134
- this._root = x(e);
124
+ this._root = g(e);
135
125
  this._recordRootEvent("merge", n, this._root);
136
126
  }
137
127
  _deleteRoot() {
138
128
  const e = this._root;
139
- e !== void 0 && (this._root = S(), this._recordRootEvent("delete", e, void 0));
129
+ e !== void 0 && (this._root = E(), this._recordRootEvent("delete", e, void 0));
140
130
  }
141
131
  _recordRootEvent(e, t, n) {
142
132
  this._eventHub.record({ kind: e, path: "", previous: t, value: n });
143
133
  }
144
134
  }
145
- function a(r, e) {
135
+ function l(r, e) {
146
136
  let t = r;
147
137
  for (const n of e)
148
138
  if (n.kind === "key") {
149
- if (!b(t) || !Object.hasOwn(t, n.key))
139
+ if (!_(t) || !Object.hasOwn(t, n.key))
150
140
  return { exists: !1, value: void 0 };
151
141
  t = t[n.key];
152
142
  } else if (n.kind === "index") {
@@ -156,39 +146,39 @@ function a(r, e) {
156
146
  } else {
157
147
  if (!Array.isArray(t))
158
148
  return { exists: !1, value: void 0 };
159
- const o = _(t, n.key, n.value);
149
+ const o = b(t, n.key, n.value);
160
150
  if (o === -1)
161
151
  return { exists: !1, value: void 0 };
162
152
  t = t[o];
163
153
  }
164
154
  return { exists: !0, value: t };
165
155
  }
166
- function g(r, e) {
156
+ function x(r, e) {
167
157
  let t = r;
168
158
  for (const n of e) {
169
- if (!b(t))
159
+ if (!_(t))
170
160
  return;
171
- const o = j(t, n);
172
- Array.isArray(t) && u.delete(t), t = o;
161
+ const o = A(t, n);
162
+ Array.isArray(t) && d.delete(t), t = o;
173
163
  }
174
164
  }
175
- function O(r, e, t) {
165
+ function w(r, e, t) {
176
166
  let n = r, o;
177
167
  for (let i = 0; i < e.segments.length - 1; i++) {
178
168
  const c = e.segments[i], f = e.segments[i + 1];
179
- c.kind === "selector" && Array.isArray(n) && (o = n), c.kind === "index" && Array.isArray(n) && (o = n), n = P(n, c, f, e.canonical);
169
+ c.kind === "selector" && Array.isArray(n) && (o = n), c.kind === "index" && Array.isArray(n) && (o = n), n = m(n, c, f, e.canonical);
180
170
  }
181
171
  const s = e.segments[e.segments.length - 1];
182
- if (C(n, s, t, e.canonical), s.kind === "key" && o !== void 0) {
183
- const i = u.get(o);
184
- i == null || i.delete(s.key), (i == null ? void 0 : i.size) === 0 && u.delete(o);
172
+ if (H(n, s, t, e.canonical), s.kind === "key" && o !== void 0) {
173
+ const i = d.get(o);
174
+ i?.delete(s.key), i?.size === 0 && d.delete(o);
185
175
  }
186
176
  }
187
- function E(r, e) {
177
+ function R(r, e) {
188
178
  let t = r;
189
179
  for (let s = 0; s < e.segments.length - 1; s++) {
190
- const i = e.segments[s], c = j(t, i);
191
- if (!b(c))
180
+ const i = e.segments[s], c = A(t, i);
181
+ if (!_(c))
192
182
  return;
193
183
  t = c;
194
184
  }
@@ -200,101 +190,101 @@ function E(r, e) {
200
190
  if (!Array.isArray(t))
201
191
  return;
202
192
  if (n.kind === "index") {
203
- u.delete(t), delete t[n.index];
193
+ d.delete(t), delete t[n.index];
204
194
  return;
205
195
  }
206
- const o = _(t, n.key, n.value);
207
- o !== -1 && (u.delete(t), delete t[o]);
196
+ const o = b(t, n.key, n.value);
197
+ o !== -1 && (d.delete(t), delete t[o]);
208
198
  }
209
- function j(r, e) {
199
+ function A(r, e) {
210
200
  if (e.kind === "key")
211
201
  return Object.hasOwn(r, e.key) ? r[e.key] : void 0;
212
202
  if (!Array.isArray(r))
213
203
  return;
214
204
  if (e.kind === "index")
215
205
  return r[e.index];
216
- const t = _(r, e.key, e.value);
206
+ const t = b(r, e.key, e.value);
217
207
  return t === -1 ? void 0 : r[t];
218
208
  }
219
- function P(r, e, t, n) {
209
+ function m(r, e, t, n) {
220
210
  if (e.kind === "key") {
221
211
  const s = r;
222
212
  let i = s[e.key];
223
- return (!Object.hasOwn(s, e.key) || i === void 0) && (i = p(t), l(s, e.key, i)), v(i, n);
213
+ return (!Object.hasOwn(s, e.key) || i === void 0) && (i = O(t), h(s, e.key, i)), k(i, n);
224
214
  }
225
215
  if (e.kind === "index") {
226
216
  if (!Array.isArray(r))
227
217
  throw y(n);
228
218
  let s = r[e.index];
229
- return (!Object.hasOwn(r, e.index) || s === void 0) && (u.delete(r), s = p(t), r[e.index] = s), v(s, n);
219
+ return (!Object.hasOwn(r, e.index) || s === void 0) && (d.delete(r), s = O(t), r[e.index] = s), k(s, n);
230
220
  }
231
221
  if (!Array.isArray(r))
232
222
  throw y(n);
233
- let o = _(r, e.key, e.value);
223
+ let o = b(r, e.key, e.value);
234
224
  if (o === -1) {
235
- u.delete(r);
225
+ d.delete(r);
236
226
  const s = /* @__PURE__ */ Object.create(null);
237
227
  s[e.key] = e.value, r.push(s), o = r.length - 1;
238
228
  }
239
- return v(r[o], n);
229
+ return k(r[o], n);
240
230
  }
241
- function C(r, e, t, n) {
231
+ function H(r, e, t, n) {
242
232
  if (e.kind === "key") {
243
- l(r, e.key, t);
233
+ h(r, e.key, t);
244
234
  return;
245
235
  }
246
236
  if (e.kind === "index") {
247
237
  if (!Array.isArray(r))
248
238
  throw y(n);
249
- u.delete(r), r[e.index] = t;
239
+ d.delete(r), r[e.index] = t;
250
240
  return;
251
241
  }
252
242
  if (!Array.isArray(r))
253
243
  throw y(n);
254
- const o = _(r, e.key, e.value);
244
+ const o = b(r, e.key, e.value);
255
245
  if (o !== -1) {
256
- u.delete(r), r[o] = t;
246
+ d.delete(r), r[o] = t;
257
247
  return;
258
248
  }
259
- if (!d(t))
249
+ if (!u(t))
260
250
  throw new TypeError(`[Raph] New selector target at "${n}" must be an object.`);
261
251
  const s = t[e.key];
262
252
  if (Object.hasOwn(t, e.key) && !Object.is(s, e.value))
263
253
  throw new TypeError(`[Raph] Selector target at "${n}" has a conflicting key.`);
264
- u.delete(r), r.push(Object.hasOwn(t, e.key) ? t : { ...t, [e.key]: e.value });
254
+ d.delete(r), r.push(Object.hasOwn(t, e.key) ? t : { ...t, [e.key]: e.value });
265
255
  }
266
- function p(r) {
256
+ function O(r) {
267
257
  return r.kind === "index" || r.kind === "selector" ? [] : /* @__PURE__ */ Object.create(null);
268
258
  }
269
- function S() {
259
+ function E() {
270
260
  return /* @__PURE__ */ Object.create(null);
271
261
  }
272
- function x(r) {
273
- if (b(r))
262
+ function g(r) {
263
+ if (_(r))
274
264
  return r;
275
265
  throw new TypeError("[Raph] Root value must be an object or array.");
276
266
  }
277
- function v(r, e) {
278
- if (b(r))
267
+ function k(r, e) {
268
+ if (_(r))
279
269
  return r;
280
270
  throw y(e);
281
271
  }
282
- function _(r, e, t) {
283
- let n = u.get(r);
284
- const o = n == null ? void 0 : n.get(e);
272
+ function b(r, e, t) {
273
+ let n = d.get(r);
274
+ const o = n?.get(e);
285
275
  if (o)
286
276
  return o.get(t) ?? -1;
287
277
  const s = /* @__PURE__ */ new Map();
288
278
  for (let i = 0; i < r.length; i++) {
289
279
  const c = r[i];
290
- if (d(c) && Object.hasOwn(c, e)) {
280
+ if (u(c) && Object.hasOwn(c, e)) {
291
281
  const f = c[e];
292
282
  (f === null || typeof f == "string" || typeof f == "number" || typeof f == "boolean") && !s.has(f) && s.set(f, i);
293
283
  }
294
284
  }
295
- return n || (n = /* @__PURE__ */ new Map(), u.set(r, n)), n.set(e, s), s.get(t) ?? -1;
285
+ return n || (n = /* @__PURE__ */ new Map(), d.set(r, n)), n.set(e, s), s.get(t) ?? -1;
296
286
  }
297
- function l(r, e, t) {
287
+ function h(r, e, t) {
298
288
  if (e === "__proto__") {
299
289
  Object.defineProperty(r, e, {
300
290
  configurable: !0,
@@ -306,21 +296,21 @@ function l(r, e, t) {
306
296
  }
307
297
  r[e] = t;
308
298
  }
309
- function A(r) {
299
+ function p(r) {
310
300
  const e = Object.create(Object.getPrototypeOf(r));
311
301
  for (const t of Object.keys(r))
312
- l(e, t, r[t]);
302
+ h(e, t, r[t]);
313
303
  return e;
314
304
  }
315
- function d(r) {
305
+ function u(r) {
316
306
  return typeof r == "object" && r !== null && !Array.isArray(r);
317
307
  }
318
- function b(r) {
319
- return Array.isArray(r) || d(r);
308
+ function _(r) {
309
+ return Array.isArray(r) || u(r);
320
310
  }
321
311
  function y(r) {
322
312
  return new TypeError(`[Raph] Cannot traverse non-container data at "${r}".`);
323
313
  }
324
314
  export {
325
- $ as PathStore
315
+ S as PathStore
326
316
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(S,x){const m=new WeakMap,v=new WeakMap,b=(n,u,s=new Set)=>{if(!s.has(n)){s.add(n),n.changed.add(u),Array.isArray(n.source)&&x(n.proxy);for(const[c,l]of n.parents)for(const r of l)b(c,r,s)}},w=(n,u,s)=>{if(!n||typeof n!="object")return n;const c=Object.getPrototypeOf(n);let l=v.get(n)??m.get(n);if(!l){const r=n,g=Array.isArray(r),d=g?[]:Object.create(c);g&&(d.length=r.length),l={source:r,proxy:null,values:new Map,removed:new Set,changed:new Set,parents:new Map};const t=l,O=a=>!t.removed.has(a)&&(t.values.has(a)||Reflect.has(r,a)),i=a=>t.removed.has(a)?void 0:t.values.has(a)?t.values.get(a):Reflect.get(r,a);t.proxy=new Proxy(d,{get:(a,e)=>w(i(e),t,e),has:(a,e)=>O(e),set:(a,e,f)=>{if(g&&e==="length"){const o=Number(f);if(!Number.isInteger(o)||o<0||o>4294967295)throw new RangeError("Invalid array length");for(let h=o;h<Number(i("length"));h++)t.removed.add(String(h)),t.values.delete(String(h));d.length=o}else if(g&&typeof e=="string"&&/^(?:0|[1-9]\d*)$/.test(e)){const o=Number(e);o<4294967295&&o>=Number(i("length"))&&(t.values.set("length",o+1),d.length=o+1)}return t.values.set(e,f),t.removed.delete(e),b(t,e),!0},deleteProperty:(a,e)=>g&&e==="length"?!1:(t.values.delete(e),t.removed.add(e),b(t,e),!0),ownKeys:()=>[...new Set([...Reflect.ownKeys(r),...t.values.keys()])].filter(a=>!t.removed.has(a)),getOwnPropertyDescriptor:(a,e)=>{if(g&&e==="length")return{value:i(e),writable:!0,enumerable:!1,configurable:!1};const f=Object.getOwnPropertyDescriptor(r,e);if(!(t.removed.has(e)||!f&&!t.values.has(e)))return{value:w(i(e),t,e),writable:!0,enumerable:(f==null?void 0:f.enumerable)??!0,configurable:!0}}}),m.set(r,t),v.set(t.proxy,t)}if(u&&s!==void 0){let r=l.parents.get(u);r||(r=new Set,l.parents.set(u,r)),r.add(s)}return l.proxy};return{root:w(S),unchangedArray(n,u){const s=v.get(n);if(!s)return null;for(const c of s.changed){if(s.values.has(c)||s.removed.has(c))return null;const l=m.get(s.source[c]);if(l!=null&&l.changed.has(u))return null}return s.source}}}exports.createDataDraft=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(S,x){const w=new WeakMap,m=new WeakMap,v=(n,u,s=new Set)=>{if(!s.has(n)){s.add(n),n.changed.add(u),Array.isArray(n.source)&&x(n.proxy);for(const[c,l]of n.parents)for(const r of l)v(c,r,s)}},b=(n,u,s)=>{if(!n||typeof n!="object")return n;const c=Object.getPrototypeOf(n);let l=m.get(n)??w.get(n);if(!l){const r=n,f=Array.isArray(r),d=f?[]:Object.create(c);f&&(d.length=r.length),l={source:r,proxy:null,values:new Map,removed:new Set,changed:new Set,parents:new Map};const t=l,O=a=>!t.removed.has(a)&&(t.values.has(a)||Reflect.has(r,a)),g=a=>t.removed.has(a)?void 0:t.values.has(a)?t.values.get(a):Reflect.get(r,a);t.proxy=new Proxy(d,{get:(a,e)=>b(g(e),t,e),has:(a,e)=>O(e),set:(a,e,i)=>{if(f&&e==="length"){const o=Number(i);if(!Number.isInteger(o)||o<0||o>4294967295)throw new RangeError("Invalid array length");for(let h=o;h<Number(g("length"));h++)t.removed.add(String(h)),t.values.delete(String(h));d.length=o}else if(f&&typeof e=="string"&&/^(?:0|[1-9]\d*)$/.test(e)){const o=Number(e);o<4294967295&&o>=Number(g("length"))&&(t.values.set("length",o+1),d.length=o+1)}return t.values.set(e,i),t.removed.delete(e),v(t,e),!0},deleteProperty:(a,e)=>f&&e==="length"?!1:(t.values.delete(e),t.removed.add(e),v(t,e),!0),ownKeys:()=>[...new Set([...Reflect.ownKeys(r),...t.values.keys()])].filter(a=>!t.removed.has(a)),getOwnPropertyDescriptor:(a,e)=>{if(f&&e==="length")return{value:g(e),writable:!0,enumerable:!1,configurable:!1};const i=Object.getOwnPropertyDescriptor(r,e);if(!(t.removed.has(e)||!i&&!t.values.has(e)))return{value:b(g(e),t,e),writable:!0,enumerable:i?.enumerable??!0,configurable:!0}}}),w.set(r,t),m.set(t.proxy,t)}if(u&&s!==void 0){let r=l.parents.get(u);r||(r=new Set,l.parents.set(u,r)),r.add(s)}return l.proxy};return{root:b(S),unchangedArray(n,u){const s=m.get(n);if(!s)return null;for(const c of s.changed)if(s.values.has(c)||s.removed.has(c)||w.get(s.source[c])?.changed.has(u))return null;return s.source}}}exports.createDataDraft=y;