@raphy-js/raph 1.0.0-dev.18

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 (186) hide show
  1. package/LICENSE +202 -0
  2. package/dist/api/Raph.d.ts +97 -0
  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 +25 -0
  6. package/dist/api/types.d.ts +170 -0
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -0
  10. package/dist/debug/api/Raph.js +421 -0
  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 -0
  16. package/dist/debug/api/errors.js +17 -0
  17. package/dist/debug/api/types.cjs +1 -0
  18. package/dist/debug/api/types.js +1 -0
  19. package/dist/debug/path/DataPath.cjs +1 -0
  20. package/dist/debug/path/DataPath.js +394 -0
  21. package/dist/debug/path/PathRouter.cjs +1 -0
  22. package/dist/debug/path/PathRouter.js +86 -0
  23. package/dist/debug/path/RaphKernel.cjs +1 -0
  24. package/dist/debug/path/RaphKernel.js +687 -0
  25. package/dist/debug/path/data-path.types.cjs +1 -0
  26. package/dist/debug/path/data-path.types.js +1 -0
  27. package/dist/debug/path/data-path.utils.cjs +1 -0
  28. package/dist/debug/path/data-path.utils.js +56 -0
  29. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  30. package/dist/debug/path/derived/DerivedRegistry.js +157 -0
  31. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  32. package/dist/debug/path/derived/RaphDerivedHandle.js +125 -0
  33. package/dist/debug/path/derived/derived-collection.types.cjs +1 -0
  34. package/dist/debug/path/derived/derived-collection.types.js +1 -0
  35. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  36. package/dist/debug/path/derived/derived-collection.utils.js +179 -0
  37. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  38. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  39. package/dist/debug/path/derived/derived-strategy.utils.cjs +1 -0
  40. package/dist/debug/path/derived/derived-strategy.utils.js +20 -0
  41. package/dist/debug/path/meta/MetaController.cjs +1 -0
  42. package/dist/debug/path/meta/MetaController.js +214 -0
  43. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  44. package/dist/debug/path/meta/RaphMeta.js +68 -0
  45. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  46. package/dist/debug/path/meta/RaphMetaStore.js +184 -0
  47. package/dist/debug/path/meta/meta.types.cjs +1 -0
  48. package/dist/debug/path/meta/meta.types.js +1 -0
  49. package/dist/debug/path/path.types.cjs +1 -0
  50. package/dist/debug/path/path.types.js +1 -0
  51. package/dist/debug/path/pathSegmentKey.cjs +1 -0
  52. package/dist/debug/path/pathSegmentKey.js +12 -0
  53. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  54. package/dist/debug/path/storage/AdapterPathStore.js +133 -0
  55. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  56. package/dist/debug/path/storage/DefaultDataAdapter.js +356 -0
  57. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  58. package/dist/debug/path/storage/PathEventHub.js +148 -0
  59. package/dist/debug/path/storage/PathStore.cjs +1 -0
  60. package/dist/debug/path/storage/PathStore.js +326 -0
  61. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  62. package/dist/debug/path/storage/createDataDraft.js +71 -0
  63. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  64. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  65. package/dist/debug/reactivity/engine.cjs +1 -0
  66. package/dist/debug/reactivity/engine.js +1305 -0
  67. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  68. package/dist/debug/reactivity/reactive-object.js +280 -0
  69. package/dist/debug/reactivity/scope.cjs +1 -0
  70. package/dist/debug/reactivity/scope.js +274 -0
  71. package/dist/debug/reactivity/types.cjs +1 -0
  72. package/dist/debug/reactivity/types.js +1 -0
  73. package/dist/debug/reactivity/watch.cjs +1 -0
  74. package/dist/debug/reactivity/watch.js +64 -0
  75. package/dist/debug/runtime/RaphRuntime.cjs +1 -0
  76. package/dist/debug/runtime/RaphRuntime.js +979 -0
  77. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  78. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  79. package/dist/debug/runtime/errors.cjs +1 -0
  80. package/dist/debug/runtime/errors.js +15 -0
  81. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  82. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  83. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  84. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  85. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  86. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  87. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  88. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  89. package/dist/debug/runtime/ownership/parentGraph.cjs +1 -0
  90. package/dist/debug/runtime/ownership/parentGraph.js +10 -0
  91. package/dist/debug/runtime/ownership/throwDisposalErrors.cjs +1 -0
  92. package/dist/debug/runtime/ownership/throwDisposalErrors.js +9 -0
  93. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  94. package/dist/debug/runtime/phases/RaphFrameLoop.js +106 -0
  95. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  96. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  97. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  98. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  99. package/dist/debug/runtime/phases/phase.types.cjs +1 -0
  100. package/dist/debug/runtime/phases/phase.types.js +8 -0
  101. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/PathHandle.js +175 -0
  103. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  104. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  105. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  106. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  107. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  108. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  109. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  110. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  111. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  112. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  113. package/dist/entrypoints/machine-testing.d.ts +2 -0
  114. package/dist/entrypoints/machine.d.ts +5 -0
  115. package/dist/entrypoints/path.d.ts +14 -0
  116. package/dist/entrypoints/reactivity.d.ts +1 -0
  117. package/dist/entrypoints/runtime.d.ts +17 -0
  118. package/dist/index.cjs +1 -0
  119. package/dist/index.js +48 -0
  120. package/dist/machine/compiler.d.ts +71 -0
  121. package/dist/machine/core.d.ts +50 -0
  122. package/dist/machine/persistence.d.ts +5 -0
  123. package/dist/machine/runtime.d.ts +4 -0
  124. package/dist/machine/testing.d.ts +43 -0
  125. package/dist/machine/types.d.ts +155 -0
  126. package/dist/machine-testing.cjs +1 -0
  127. package/dist/machine-testing.js +188 -0
  128. package/dist/machine.cjs +1 -0
  129. package/dist/machine.js +837 -0
  130. package/dist/main.d.ts +20 -0
  131. package/dist/path/DataPath.d.ts +73 -0
  132. package/dist/path/PathRouter.d.ts +21 -0
  133. package/dist/path/RaphKernel.d.ts +169 -0
  134. package/dist/path/data-path.types.d.ts +34 -0
  135. package/dist/path/data-path.utils.d.ts +9 -0
  136. package/dist/path/derived/DerivedRegistry.d.ts +67 -0
  137. package/dist/path/derived/RaphDerivedHandle.d.ts +97 -0
  138. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  139. package/dist/path/derived/derived-collection.utils.d.ts +20 -0
  140. package/dist/path/derived/derived-strategy.types.d.ts +12 -0
  141. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  142. package/dist/path/meta/MetaController.d.ts +85 -0
  143. package/dist/path/meta/RaphMeta.d.ts +45 -0
  144. package/dist/path/meta/RaphMetaStore.d.ts +45 -0
  145. package/dist/path/meta/meta.types.d.ts +31 -0
  146. package/dist/path/path.types.d.ts +27 -0
  147. package/dist/path/pathSegmentKey.d.ts +2 -0
  148. package/dist/path/storage/AdapterPathStore.d.ts +45 -0
  149. package/dist/path/storage/DefaultDataAdapter.d.ts +63 -0
  150. package/dist/path/storage/PathEventHub.d.ts +48 -0
  151. package/dist/path/storage/PathStore.d.ts +51 -0
  152. package/dist/path/storage/createDataDraft.d.ts +4 -0
  153. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  154. package/dist/path.cjs +1 -0
  155. package/dist/path.js +18 -0
  156. package/dist/raph.cjs +1 -0
  157. package/dist/raph.js +48 -0
  158. package/dist/reactivity/engine.d.ts +393 -0
  159. package/dist/reactivity/reactive-object.d.ts +36 -0
  160. package/dist/reactivity/scope.d.ts +146 -0
  161. package/dist/reactivity/types.d.ts +175 -0
  162. package/dist/reactivity/watch.d.ts +15 -0
  163. package/dist/reactivity.cjs +1 -0
  164. package/dist/reactivity.js +14 -0
  165. package/dist/runtime/RaphRuntime.d.ts +225 -0
  166. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  167. package/dist/runtime/errors.d.ts +21 -0
  168. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  169. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  170. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  171. package/dist/runtime/ownership/parent-graph.types.d.ts +4 -0
  172. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  173. package/dist/runtime/ownership/throwDisposalErrors.d.ts +1 -0
  174. package/dist/runtime/phases/RaphFrameLoop.d.ts +51 -0
  175. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  176. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  177. package/dist/runtime/phases/phase.types.d.ts +92 -0
  178. package/dist/runtime/reactivity/PathHandle.d.ts +80 -0
  179. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  180. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  181. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +45 -0
  182. package/dist/runtime/reactivity/RuntimeWatch.d.ts +34 -0
  183. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +11 -0
  184. package/dist/runtime.cjs +1 -0
  185. package/dist/runtime.js +23 -0
  186. package/package.json +141 -0
@@ -0,0 +1 @@
1
+ "use strict";var A=Object.defineProperty;var M=(s,e,t)=>e in s?A(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var p=(s,e,t)=>M(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=Symbol("raph.reactive-object.identity"),P=new Set(["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"]),g=new WeakMap,l=new WeakMap,w=new WeakMap,D=Object.freeze({}),W=Object.freeze({assertRead:_,assertWrite:_,throwForeign:_});function m(s,e){l.set(s,e)}function S(s,e=W){l.delete(s);const t=g.get(s);t!==void 0&&(g.delete(s),t.dispose(e))}function E(s,e,t){var o;const r=b(e),i=g.get(s);if(r!==void 0){if(r.context===i)return e;const c=l.get(s)??D;throw(o=c.throwForeign)==null||o.call(c,r.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.")}return j(e),(i??C(s,t)).wrap(e)}class I{constructor(e,t){p(this,"_rawToProxy",new WeakMap);p(this,"_rawToTracking",new WeakMap);p(this,"_arrayMethods",new Map);p(this,"_bridge");p(this,"_policy");p(this,"_writeDepth",0);p(this,"_disposed",!1);p(this,"_handler");p(this,"_weakSelf");this._bridge=e,this._policy=t,this._weakSelf=new WeakRef(this),this._handler={defineProperty:(r,i,n)=>this._define(r,i,n),deleteProperty:(r,i)=>this._delete(r,i),get:(r,i,n)=>this._get(r,i,n),has:(r,i)=>this._has(r,i),ownKeys:r=>this._ownKeys(r),set:(r,i,n)=>this._set(r,i,n)}}get owner(){return this._policy.owner}get disposed(){return this._disposed}wrap(e){var o,c,f,h;const t=b(e);if(t!==void 0){if(t.context===this)return e;throw(c=(o=this._policy).throwForeign)==null||c.call(o,t.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.")}j(e);const r=x(e);if(r!==void 0&&r!==this&&!r.disposed)throw(h=(f=this._policy).throwForeign)==null||h.call(f,r.owner),new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");const i=this._rawToProxy.get(e);if(i!==void 0)return i;const n=new Proxy(e,this._handler);return w.set(e,this._weakSelf),this._rawToProxy.set(e,n),n}dispose(e){this._disposed=!0,this._policy=e,this._bridge=void 0,this._rawToProxy=new WeakMap,this._rawToTracking=new WeakMap,this._arrayMethods.clear()}_get(e,t,r){var n,o;if(t===O)return{context:this,raw:e};(o=(n=this._policy).assertRead)==null||o.call(n);const i=Reflect.get(e,t,r);return this._trackValue(e,t),Array.isArray(e)&&P.has(t)&&i===Array.prototype[t]?this._arrayMutator(t):y(i)?this.wrap(i):i}_set(e,t,r){return this._write(()=>{var a,u;const i=this._unwrap(r),n=Object.hasOwn(e,t),o=Reflect.get(e,t,e),c=Array.isArray(e)?e.length:0;if(n&&o===i)return!0;if(!Reflect.set(e,t,i,e))return!1;const h=this._rawToTracking.get(e);return h===void 0||(this._trigger((a=h.valueDeps)==null?void 0:a.get(t)),n||(this._trigger((u=h.hasDeps)==null?void 0:u.get(t)),this._trigger(h.iterateDep)),this._triggerArrayShape(e,t,i,c,h)),!0})}_define(e,t,r){return this._write(()=>{var R,T;const i=Object.hasOwn(e,t),n=Reflect.getOwnPropertyDescriptor(e,t),o=Reflect.get(e,t,e),c=Array.isArray(e)?e.length:0,f="value"in r?{...r,value:this._unwrap(r.value)}:r;if(!Reflect.defineProperty(e,t,f))return!1;const a=this._rawToTracking.get(e);if(a===void 0)return!0;const u=Reflect.getOwnPropertyDescriptor(e,t),v=Reflect.get(e,t,e);return(!i||o!==v||!N(n,u))&&this._trigger((R=a.valueDeps)==null?void 0:R.get(t)),i?(n==null?void 0:n.enumerable)!==(u==null?void 0:u.enumerable)&&this._trigger(a.iterateDep):(this._trigger((T=a.hasDeps)==null?void 0:T.get(t)),this._trigger(a.iterateDep)),this._triggerArrayShape(e,t,v,c,a),!0})}_delete(e,t){return this._write(()=>{var n,o;if(!Object.hasOwn(e,t))return!0;if(!Reflect.deleteProperty(e,t))return!1;const i=this._rawToTracking.get(e);return i!==void 0&&(this._trigger((n=i.valueDeps)==null?void 0:n.get(t)),this._trigger((o=i.hasDeps)==null?void 0:o.get(t)),this._trigger(i.iterateDep)),!0})}_has(e,t){var r,i;return(i=(r=this._policy).assertRead)==null||i.call(r),this._trackHas(e,t),Reflect.has(e,t)}_ownKeys(e){var t,r;return(r=(t=this._policy).assertRead)==null||r.call(t),this._trackIterate(e),Reflect.ownKeys(e)}_arrayMutator(e){const t=this._arrayMethods.get(e);if(t!==void 0)return t;const r=n=>this._write(n),i=function(...n){return r(()=>Reflect.apply(Array.prototype[e],this,n))};return this._arrayMethods.set(e,i),i}_trackValue(e,t){const r=this._requireBridge();if(!r.isTracking())return;const i=this._ensureTracking(e),n=i.valueDeps??(i.valueDeps=new Map);let o=n.get(t);o===void 0&&(o=r.create(),n.set(t,o)),r.track(o)}_trackHas(e,t){const r=this._requireBridge();if(!r.isTracking())return;const i=this._ensureTracking(e),n=i.hasDeps??(i.hasDeps=new Map);let o=n.get(t);o===void 0&&(o=r.create(),n.set(t,o)),r.track(o)}_trackIterate(e){const t=this._requireBridge();if(!t.isTracking())return;const r=this._ensureTracking(e),i=r.iterateDep??(r.iterateDep=t.create());t.track(i)}_ensureTracking(e){let t=this._rawToTracking.get(e);return t===void 0&&(t={},this._rawToTracking.set(e,t)),t}_trigger(e){e!==void 0&&this._requireBridge().trigger(e)}_triggerArrayShape(e,t,r,i,n){var c,f,h;if(!Array.isArray(e))return;if(d(t)&&Number(t)>=i){this._trigger((c=n.valueDeps)==null?void 0:c.get("length"));return}if(t!=="length"||Number(r)>=i)return;const o=Number(r);for(const[a,u]of((f=n.valueDeps)==null?void 0:f.entries())??[])d(a)&&Number(a)>=o&&this._trigger(u);for(const[a,u]of((h=n.hasDeps)==null?void 0:h.entries())??[])d(a)&&Number(a)>=o&&this._trigger(u);this._trigger(n.iterateDep)}_write(e){var r,i;if((i=(r=this._policy).assertWrite)==null||i.call(r),this._writeDepth!==0)return e();const t=()=>{++this._writeDepth;try{return this._requireBridge().batch(e)}finally{--this._writeDepth}};return this._policy.runWrite===void 0?t():this._policy.runWrite(t)}_unwrap(e){var r,i,n,o;const t=b(e);if(t===void 0){if(y(e)){const c=x(e);if(c!==void 0&&c!==this&&!c.disposed)throw(i=(r=this._policy).throwForeign)==null||i.call(r,c.owner),new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.")}return e}if(t.context!==this)throw(o=(n=this._policy).throwForeign)==null||o.call(n,t.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.");return t.raw}_requireBridge(){const e=this._bridge;return e===void 0&&_(),e}}function C(s,e){const t=new I(e(),l.get(s)??D);return g.set(s,t),t}function x(s){const e=w.get(s),t=e==null?void 0:e.deref();return e!==void 0&&t===void 0&&w.delete(s),t}function b(s){if(!(s===null||typeof s!="object"))return Reflect.get(s,O)}function y(s){if(s===null||typeof s!="object")return!1;if(Array.isArray(s))return!0;const e=Object.getPrototypeOf(s);return e===Object.prototype||e===null}function j(s){if(!y(s))throw new TypeError("[Raph] reactive() accepts only plain objects and arrays.")}function d(s){if(typeof s!="string"||s==="")return!1;const e=Number(s);return Number.isInteger(e)&&e>=0&&e<4294967295&&String(e)===s}function N(s,e){return s===e?!0:s===void 0||e===void 0?!1:s.configurable===e.configurable&&s.enumerable===e.enumerable&&s.get===e.get&&s.set===e.set&&s.value===e.value&&s.writable===e.writable}function _(){throw new Error("[Raph] Reactive object owner is disposed.")}exports.configureReactiveObjectPolicy=m;exports.disposeReactiveObjectContext=S;exports.reactiveObject=E;
@@ -0,0 +1,280 @@
1
+ var A = Object.defineProperty;
2
+ var M = (s, e, t) => e in s ? A(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var p = (s, e, t) => M(s, typeof e != "symbol" ? e + "" : e, t);
4
+ const D = Symbol("raph.reactive-object.identity"), P = /* @__PURE__ */ new Set([
5
+ "copyWithin",
6
+ "fill",
7
+ "pop",
8
+ "push",
9
+ "reverse",
10
+ "shift",
11
+ "sort",
12
+ "splice",
13
+ "unshift"
14
+ ]), g = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), O = Object.freeze({}), W = Object.freeze({
15
+ assertRead: f,
16
+ assertWrite: f,
17
+ throwForeign: f
18
+ });
19
+ function N(s, e) {
20
+ l.set(s, e);
21
+ }
22
+ function q(s, e = W) {
23
+ l.delete(s);
24
+ const t = g.get(s);
25
+ t !== void 0 && (g.delete(s), t.dispose(e));
26
+ }
27
+ function B(s, e, t) {
28
+ var o;
29
+ const r = b(e), i = g.get(s);
30
+ if (r !== void 0) {
31
+ if (r.context === i)
32
+ return e;
33
+ const c = l.get(s) ?? O;
34
+ throw (o = c.throwForeign) == null || o.call(c, r.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
35
+ }
36
+ return j(e), (i ?? E(s, t)).wrap(e);
37
+ }
38
+ class m {
39
+ constructor(e, t) {
40
+ p(this, "_rawToProxy", /* @__PURE__ */ new WeakMap());
41
+ p(this, "_rawToTracking", /* @__PURE__ */ new WeakMap());
42
+ p(this, "_arrayMethods", /* @__PURE__ */ new Map());
43
+ p(this, "_bridge");
44
+ p(this, "_policy");
45
+ p(this, "_writeDepth", 0);
46
+ p(this, "_disposed", !1);
47
+ p(this, "_handler");
48
+ p(this, "_weakSelf");
49
+ this._bridge = e, this._policy = t, this._weakSelf = new WeakRef(this), this._handler = {
50
+ defineProperty: (r, i, n) => this._define(r, i, n),
51
+ deleteProperty: (r, i) => this._delete(r, i),
52
+ get: (r, i, n) => this._get(r, i, n),
53
+ has: (r, i) => this._has(r, i),
54
+ ownKeys: (r) => this._ownKeys(r),
55
+ set: (r, i, n) => this._set(r, i, n)
56
+ };
57
+ }
58
+ get owner() {
59
+ return this._policy.owner;
60
+ }
61
+ get disposed() {
62
+ return this._disposed;
63
+ }
64
+ wrap(e) {
65
+ var o, c, _, h;
66
+ const t = b(e);
67
+ if (t !== void 0) {
68
+ if (t.context === this)
69
+ return e;
70
+ throw (c = (o = this._policy).throwForeign) == null || c.call(o, t.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
71
+ }
72
+ j(e);
73
+ const r = x(e);
74
+ if (r !== void 0 && r !== this && !r.disposed)
75
+ throw (h = (_ = this._policy).throwForeign) == null || h.call(_, r.owner), new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");
76
+ const i = this._rawToProxy.get(e);
77
+ if (i !== void 0)
78
+ return i;
79
+ const n = new Proxy(e, this._handler);
80
+ return d.set(e, this._weakSelf), this._rawToProxy.set(e, n), n;
81
+ }
82
+ dispose(e) {
83
+ this._disposed = !0, this._policy = e, this._bridge = void 0, this._rawToProxy = /* @__PURE__ */ new WeakMap(), this._rawToTracking = /* @__PURE__ */ new WeakMap(), this._arrayMethods.clear();
84
+ }
85
+ _get(e, t, r) {
86
+ var n, o;
87
+ if (t === D)
88
+ return { context: this, raw: e };
89
+ (o = (n = this._policy).assertRead) == null || o.call(n);
90
+ const i = Reflect.get(e, t, r);
91
+ return this._trackValue(e, t), Array.isArray(e) && P.has(t) && i === Array.prototype[t] ? this._arrayMutator(t) : y(i) ? this.wrap(i) : i;
92
+ }
93
+ _set(e, t, r) {
94
+ return this._write(() => {
95
+ var a, u;
96
+ const i = this._unwrap(r), n = Object.hasOwn(e, t), o = Reflect.get(e, t, e), c = Array.isArray(e) ? e.length : 0;
97
+ if (n && o === i)
98
+ return !0;
99
+ if (!Reflect.set(e, t, i, e))
100
+ return !1;
101
+ const h = this._rawToTracking.get(e);
102
+ return h === void 0 || (this._trigger((a = h.valueDeps) == null ? void 0 : a.get(t)), n || (this._trigger((u = h.hasDeps) == null ? void 0 : u.get(t)), this._trigger(h.iterateDep)), this._triggerArrayShape(e, t, i, c, h)), !0;
103
+ });
104
+ }
105
+ _define(e, t, r) {
106
+ return this._write(() => {
107
+ var R, T;
108
+ const i = Object.hasOwn(e, t), n = Reflect.getOwnPropertyDescriptor(e, t), o = Reflect.get(e, t, e), c = Array.isArray(e) ? e.length : 0, _ = "value" in r ? { ...r, value: this._unwrap(r.value) } : r;
109
+ if (!Reflect.defineProperty(e, t, _))
110
+ return !1;
111
+ const a = this._rawToTracking.get(e);
112
+ if (a === void 0)
113
+ return !0;
114
+ const u = Reflect.getOwnPropertyDescriptor(e, t), v = Reflect.get(e, t, e);
115
+ return (!i || o !== v || !S(n, u)) && this._trigger((R = a.valueDeps) == null ? void 0 : R.get(t)), i ? (n == null ? void 0 : n.enumerable) !== (u == null ? void 0 : u.enumerable) && this._trigger(a.iterateDep) : (this._trigger((T = a.hasDeps) == null ? void 0 : T.get(t)), this._trigger(a.iterateDep)), this._triggerArrayShape(
116
+ e,
117
+ t,
118
+ v,
119
+ c,
120
+ a
121
+ ), !0;
122
+ });
123
+ }
124
+ _delete(e, t) {
125
+ return this._write(() => {
126
+ var n, o;
127
+ if (!Object.hasOwn(e, t))
128
+ return !0;
129
+ if (!Reflect.deleteProperty(e, t))
130
+ return !1;
131
+ const i = this._rawToTracking.get(e);
132
+ return i !== void 0 && (this._trigger((n = i.valueDeps) == null ? void 0 : n.get(t)), this._trigger((o = i.hasDeps) == null ? void 0 : o.get(t)), this._trigger(i.iterateDep)), !0;
133
+ });
134
+ }
135
+ _has(e, t) {
136
+ var r, i;
137
+ return (i = (r = this._policy).assertRead) == null || i.call(r), this._trackHas(e, t), Reflect.has(e, t);
138
+ }
139
+ _ownKeys(e) {
140
+ var t, r;
141
+ return (r = (t = this._policy).assertRead) == null || r.call(t), this._trackIterate(e), Reflect.ownKeys(e);
142
+ }
143
+ _arrayMutator(e) {
144
+ const t = this._arrayMethods.get(e);
145
+ if (t !== void 0)
146
+ return t;
147
+ const r = (n) => this._write(n), i = function(...n) {
148
+ return r(() => Reflect.apply(
149
+ Array.prototype[e],
150
+ this,
151
+ n
152
+ ));
153
+ };
154
+ return this._arrayMethods.set(e, i), i;
155
+ }
156
+ _trackValue(e, t) {
157
+ const r = this._requireBridge();
158
+ if (!r.isTracking())
159
+ return;
160
+ const i = this._ensureTracking(e), n = i.valueDeps ?? (i.valueDeps = /* @__PURE__ */ new Map());
161
+ let o = n.get(t);
162
+ o === void 0 && (o = r.create(), n.set(t, o)), r.track(o);
163
+ }
164
+ _trackHas(e, t) {
165
+ const r = this._requireBridge();
166
+ if (!r.isTracking())
167
+ return;
168
+ const i = this._ensureTracking(e), n = i.hasDeps ?? (i.hasDeps = /* @__PURE__ */ new Map());
169
+ let o = n.get(t);
170
+ o === void 0 && (o = r.create(), n.set(t, o)), r.track(o);
171
+ }
172
+ _trackIterate(e) {
173
+ const t = this._requireBridge();
174
+ if (!t.isTracking())
175
+ return;
176
+ const r = this._ensureTracking(e), i = r.iterateDep ?? (r.iterateDep = t.create());
177
+ t.track(i);
178
+ }
179
+ _ensureTracking(e) {
180
+ let t = this._rawToTracking.get(e);
181
+ return t === void 0 && (t = {}, this._rawToTracking.set(e, t)), t;
182
+ }
183
+ _trigger(e) {
184
+ e !== void 0 && this._requireBridge().trigger(e);
185
+ }
186
+ _triggerArrayShape(e, t, r, i, n) {
187
+ var c, _, h;
188
+ if (!Array.isArray(e))
189
+ return;
190
+ if (w(t) && Number(t) >= i) {
191
+ this._trigger((c = n.valueDeps) == null ? void 0 : c.get("length"));
192
+ return;
193
+ }
194
+ if (t !== "length" || Number(r) >= i)
195
+ return;
196
+ const o = Number(r);
197
+ for (const [a, u] of ((_ = n.valueDeps) == null ? void 0 : _.entries()) ?? [])
198
+ w(a) && Number(a) >= o && this._trigger(u);
199
+ for (const [a, u] of ((h = n.hasDeps) == null ? void 0 : h.entries()) ?? [])
200
+ w(a) && Number(a) >= o && this._trigger(u);
201
+ this._trigger(n.iterateDep);
202
+ }
203
+ _write(e) {
204
+ var r, i;
205
+ if ((i = (r = this._policy).assertWrite) == null || i.call(r), this._writeDepth !== 0)
206
+ return e();
207
+ const t = () => {
208
+ ++this._writeDepth;
209
+ try {
210
+ return this._requireBridge().batch(e);
211
+ } finally {
212
+ --this._writeDepth;
213
+ }
214
+ };
215
+ return this._policy.runWrite === void 0 ? t() : this._policy.runWrite(t);
216
+ }
217
+ _unwrap(e) {
218
+ var r, i, n, o;
219
+ const t = b(e);
220
+ if (t === void 0) {
221
+ if (y(e)) {
222
+ const c = x(e);
223
+ if (c !== void 0 && c !== this && !c.disposed)
224
+ throw (i = (r = this._policy).throwForeign) == null || i.call(r, c.owner), new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");
225
+ }
226
+ return e;
227
+ }
228
+ if (t.context !== this)
229
+ throw (o = (n = this._policy).throwForeign) == null || o.call(n, t.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
230
+ return t.raw;
231
+ }
232
+ _requireBridge() {
233
+ const e = this._bridge;
234
+ return e === void 0 && f(), e;
235
+ }
236
+ }
237
+ function E(s, e) {
238
+ const t = new m(
239
+ e(),
240
+ l.get(s) ?? O
241
+ );
242
+ return g.set(s, t), t;
243
+ }
244
+ function x(s) {
245
+ const e = d.get(s), t = e == null ? void 0 : e.deref();
246
+ return e !== void 0 && t === void 0 && d.delete(s), t;
247
+ }
248
+ function b(s) {
249
+ if (!(s === null || typeof s != "object"))
250
+ return Reflect.get(s, D);
251
+ }
252
+ function y(s) {
253
+ if (s === null || typeof s != "object")
254
+ return !1;
255
+ if (Array.isArray(s))
256
+ return !0;
257
+ const e = Object.getPrototypeOf(s);
258
+ return e === Object.prototype || e === null;
259
+ }
260
+ function j(s) {
261
+ if (!y(s))
262
+ throw new TypeError("[Raph] reactive() accepts only plain objects and arrays.");
263
+ }
264
+ function w(s) {
265
+ if (typeof s != "string" || s === "")
266
+ return !1;
267
+ const e = Number(s);
268
+ return Number.isInteger(e) && e >= 0 && e < 4294967295 && String(e) === s;
269
+ }
270
+ function S(s, e) {
271
+ return s === e ? !0 : s === void 0 || e === void 0 ? !1 : s.configurable === e.configurable && s.enumerable === e.enumerable && s.get === e.get && s.set === e.set && s.value === e.value && s.writable === e.writable;
272
+ }
273
+ function f() {
274
+ throw new Error("[Raph] Reactive object owner is disposed.");
275
+ }
276
+ export {
277
+ N as configureReactiveObjectPolicy,
278
+ q as disposeReactiveObjectContext,
279
+ B as reactiveObject
280
+ };
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var l=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>l(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _{constructor(e){o(this,"scopeFirstChild");o(this,"scopeLastChild");o(this,"_resourceCount",0);o(this,"_sourceFinalizers");o(this,"_disposed",!1);o(this,"_disposing",!1);this.reactivity=e}get disposed(){return this._disposed}get active(){return!this._disposed&&!this._disposing}signal(e){this._assertAlive();const s=this._adoptSource(this.reactivity._ownedSignal(e));return{get:()=>(this._assertAlive(),s.get()),peek:()=>(this._assertAlive(),s.peek()),set:i=>{this._assertAlive(),s.set(i)}}}computed(e){this._assertAlive();const s=typeof e=="function"?e:e.get,i=this._adoptSource(this.reactivity._ownedComputed(s)),r={get:()=>(this._assertAlive(),i.get()),peek:()=>(this._assertAlive(),i.peek())};if(typeof e=="function")return r;let c=e.set;this._own(()=>{c=void 0});const n=r;return n.set=a=>{this._assertAlive(),c(a)},n}effect(e){return this._assertAlive(),this._adoptResource(this.reactivity.effect(e))}watch(e,s,i){return this._assertAlive(),this._adoptResource(this.reactivity.watch(e,s,i))}own(e){return this.active?this._own(e):(e(),v)}_debugResourceCount(){return this._resourceCount}_debugSourceCount(){var e;return((e=this._sourceFinalizers)==null?void 0:e.size)??0}dispose(){if(this._disposed)return;this._disposed=!0,this._disposing=!0;const e=[];try{for(;this.scopeLastChild!==void 0;)try{this.scopeLastChild.dispose()}catch(s){e.push(s)}this._finalizeSources(e)}finally{this._disposing=!1;try{this._afterDispose()}catch(s){e.push(s)}}p(e,this._disposalMessage())}_own(e){this._assertAlive();let s=e;const i={scopeParent:void 0,scopePrevious:void 0,scopeNext:void 0,dispose:()=>{const r=s;r!==void 0&&(s=void 0,h(i),--this._resourceCount,r())}};return u(this,i),++this._resourceCount,i.dispose}_adoptResource(e){try{return this._own(e)}catch(s){try{e()}catch(i){throw new AggregateError([s,i],"Resource registration and cleanup failed.")}throw s}}_adoptSource(e){try{this._ownSource(e.dispose)}catch(s){try{e.dispose()}catch(i){throw new AggregateError([s,i],"Source registration and cleanup failed.")}throw s}return e.source}_ownSource(e){this._assertAlive(),this._sourceFinalizers===void 0&&(this._sourceFinalizers=new Set),this._sourceFinalizers.add(e)}_assertAlive(){if(this._disposed||this._disposing)throw new Error("ScopeNode is disposed.")}_afterDispose(){}_disposalMessage(){return"ScopeNode disposal failed."}_finalizeSources(e){const s=this._sourceFinalizers;if(this._sourceFinalizers=void 0,s===void 0)return;let i=[...s].reverse();for(s.clear();i.length>0;){const r=[];let c=!1;for(const n of i)try{n()?c=!0:r.push(n)}catch(a){e.push(a),c=!0}if(!c)return;i=r}}}function u(t,e){const s=t.scopeLastChild;e.scopeParent=t,e.scopePrevious=s,e.scopeNext=void 0,s===void 0?t.scopeFirstChild=e:s.scopeNext=e,t.scopeLastChild=e}function h(t){const e=t.scopeParent;if(e===void 0)return;const s=t.scopePrevious,i=t.scopeNext;s===void 0?e.scopeFirstChild=i:s.scopeNext=i,i===void 0?e.scopeLastChild=s:i.scopePrevious=s,t.scopeParent=void 0,t.scopePrevious=void 0,t.scopeNext=void 0}function p(t,e){if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,e)}function v(){}exports.ScopeNode=_;exports.appendScopeChild=u;exports.detachScopeChild=h;exports.throwScopeErrors=p;
@@ -0,0 +1,274 @@
1
+ var u = Object.defineProperty;
2
+ var h = (t, e, s) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var o = (t, e, s) => h(t, typeof e != "symbol" ? e + "" : e, s);
4
+ class f {
5
+ /**
6
+ * Связывает владельца с реактивным экземпляром без создания нового графа.
7
+ * @param reactivity Экземпляр, в котором создаются owned-ресурсы.
8
+ */
9
+ constructor(e) {
10
+ /**
11
+ * Первый зарегистрированный ресурс; не является ребёнком execution-дерева.
12
+ * @internal
13
+ */
14
+ o(this, "scopeFirstChild");
15
+ /**
16
+ * Последний ресурс, с которого начинается освобождение владельца.
17
+ * @internal
18
+ */
19
+ o(this, "scopeLastChild");
20
+ // Число активных записей owned-ресурсов; финализаторы источников считаются отдельно.
21
+ o(this, "_resourceCount", 0);
22
+ // Лениво создаваемое множество финализаторов owned-источников.
23
+ o(this, "_sourceFinalizers");
24
+ // Окончательное состояние владельца; устанавливается до пользовательских cleanup.
25
+ o(this, "_disposed", !1);
26
+ // Признак выполняющегося освобождения для проверок lifetime и наследников.
27
+ o(this, "_disposing", !1);
28
+ this.reactivity = e;
29
+ }
30
+ /**
31
+ * Показывает, началось ли окончательное освобождение владельца.
32
+ */
33
+ get disposed() {
34
+ return this._disposed;
35
+ }
36
+ /**
37
+ * Разрешает регистрацию и доступ только до начала освобождения.
38
+ */
39
+ get active() {
40
+ return !this._disposed && !this._disposing;
41
+ }
42
+ /**
43
+ * Создаёт owned signal и регистрирует его финализатор.
44
+ * Все методы возвращённого handle проверяют, что владелец ещё активен.
45
+ */
46
+ signal(e) {
47
+ this._assertAlive();
48
+ const s = this._adoptSource(this.reactivity._ownedSignal(e));
49
+ return {
50
+ get: () => (this._assertAlive(), s.get()),
51
+ peek: () => (this._assertAlive(), s.peek()),
52
+ set: (i) => {
53
+ this._assertAlive(), s.set(i);
54
+ }
55
+ };
56
+ }
57
+ /**
58
+ * Создаёт owned computed; getter освобождается при dispose владельца.
59
+ * Для writable computed отдельно освобождает захваченный setter.
60
+ */
61
+ computed(e) {
62
+ this._assertAlive();
63
+ const s = typeof e == "function" ? e : e.get, i = this._adoptSource(this.reactivity._ownedComputed(s)), r = {
64
+ get: () => (this._assertAlive(), i.get()),
65
+ peek: () => (this._assertAlive(), i.peek())
66
+ };
67
+ if (typeof e == "function")
68
+ return r;
69
+ let c = e.set;
70
+ this._own(() => {
71
+ c = void 0;
72
+ });
73
+ const n = r;
74
+ return n.set = (a) => {
75
+ this._assertAlive(), c(a);
76
+ }, n;
77
+ }
78
+ /**
79
+ * Создаёт эффект и принимает его disposer во владение.
80
+ * Если владелец уничтожен во время синхронного запуска, немедленно останавливает эффект.
81
+ */
82
+ effect(e) {
83
+ return this._assertAlive(), this._adoptResource(this.reactivity.effect(e));
84
+ }
85
+ /**
86
+ * Создаёт watch и регистрирует окончательную остановку у владельца.
87
+ */
88
+ watch(e, s, i) {
89
+ return this._assertAlive(), this._adoptResource(this.reactivity.watch(e, s, i));
90
+ }
91
+ /**
92
+ * Принимает произвольный cleanup и возвращает однократный disposer.
93
+ * Если владелец уже неактивен, выполняет cleanup сразу и возвращает пустой disposer.
94
+ */
95
+ own(e) {
96
+ return this.active ? this._own(e) : (e(), _);
97
+ }
98
+ /**
99
+ * Возвращает число ещё не освобождённых записей ресурсов.
100
+ * @internal
101
+ */
102
+ _debugResourceCount() {
103
+ return this._resourceCount;
104
+ }
105
+ /**
106
+ * Возвращает число зарегистрированных финализаторов источников.
107
+ * @internal
108
+ */
109
+ _debugSourceCount() {
110
+ var e;
111
+ return ((e = this._sourceFinalizers) == null ? void 0 : e.size) ?? 0;
112
+ }
113
+ /**
114
+ * Освобождает ресурсы в обратном порядке, затем финализирует источники.
115
+ * Повторный вызов безопасен. Ошибки cleanup и завершающего hook собираются
116
+ * и передаются только после завершения остальных стадий.
117
+ */
118
+ dispose() {
119
+ if (this._disposed)
120
+ return;
121
+ this._disposed = !0, this._disposing = !0;
122
+ const e = [];
123
+ try {
124
+ for (; this.scopeLastChild !== void 0; )
125
+ try {
126
+ this.scopeLastChild.dispose();
127
+ } catch (s) {
128
+ e.push(s);
129
+ }
130
+ this._finalizeSources(e);
131
+ } finally {
132
+ this._disposing = !1;
133
+ try {
134
+ this._afterDispose();
135
+ } catch (s) {
136
+ e.push(s);
137
+ }
138
+ }
139
+ l(e, this._disposalMessage());
140
+ }
141
+ /**
142
+ * Регистрирует ресурс только у активного владельца.
143
+ * Дочерняя запись отсоединяется до вызова cleanup, включая ошибочный и вложенный stop.
144
+ * В отличие от own(), не принимает регистрацию после dispose.
145
+ * @internal
146
+ */
147
+ _own(e) {
148
+ this._assertAlive();
149
+ let s = e;
150
+ const i = {
151
+ scopeParent: void 0,
152
+ scopePrevious: void 0,
153
+ scopeNext: void 0,
154
+ dispose: () => {
155
+ const r = s;
156
+ r !== void 0 && (s = void 0, d(i), --this._resourceCount, r());
157
+ }
158
+ };
159
+ return p(this, i), ++this._resourceCount, i.dispose;
160
+ }
161
+ /**
162
+ * Принимает уже созданный ресурс и не оставляет его без владельца при ошибке регистрации.
163
+ * При неудачной очистке сохраняет и ошибку регистрации, и ошибку освобождения.
164
+ * @internal
165
+ */
166
+ _adoptResource(e) {
167
+ try {
168
+ return this._own(e);
169
+ } catch (s) {
170
+ try {
171
+ e();
172
+ } catch (i) {
173
+ throw new AggregateError([s, i], "Resource registration and cleanup failed.");
174
+ }
175
+ throw s;
176
+ }
177
+ }
178
+ /**
179
+ * Регистрирует финализатор owned-источника и возвращает его handle.
180
+ * Если владелец уже недоступен, освобождает источник до передачи ошибки.
181
+ * @internal
182
+ */
183
+ _adoptSource(e) {
184
+ try {
185
+ this._ownSource(e.dispose);
186
+ } catch (s) {
187
+ try {
188
+ e.dispose();
189
+ } catch (i) {
190
+ throw new AggregateError([s, i], "Source registration and cleanup failed.");
191
+ }
192
+ throw s;
193
+ }
194
+ return e.source;
195
+ }
196
+ /**
197
+ * Добавляет финализатор источника. Возвращённый им false означает повторную попытку
198
+ * после прогресса других финализаторов, а не успешное освобождение.
199
+ * @internal
200
+ */
201
+ _ownSource(e) {
202
+ this._assertAlive(), this._sourceFinalizers === void 0 && (this._sourceFinalizers = /* @__PURE__ */ new Set()), this._sourceFinalizers.add(e);
203
+ }
204
+ /**
205
+ * Запрещает операции после начала освобождения владельца.
206
+ * Текст существующей ошибки сохранён для совместимости вызывающих слоёв.
207
+ * @internal
208
+ */
209
+ _assertAlive() {
210
+ if (this._disposed || this._disposing)
211
+ throw new Error("ScopeNode is disposed.");
212
+ }
213
+ /**
214
+ * Завершающий hook для наследников после ресурсов и источников.
215
+ * Базовая реализация ничего не делает; исключение наследника попадёт в общий результат.
216
+ */
217
+ _afterDispose() {
218
+ }
219
+ /**
220
+ * Возвращает сообщение для AggregateError при нескольких ошибках освобождения.
221
+ */
222
+ _disposalMessage() {
223
+ return "ScopeNode disposal failed.";
224
+ }
225
+ /**
226
+ * Освобождает источники в обратном порядке регистрации с повторными попытками.
227
+ * Если в проходе не было прогресса, прекращает обход, сохраняя существующий контракт.
228
+ * Исключение одного финализатора не блокирует остальные.
229
+ */
230
+ _finalizeSources(e) {
231
+ const s = this._sourceFinalizers;
232
+ if (this._sourceFinalizers = void 0, s === void 0)
233
+ return;
234
+ let i = [...s].reverse();
235
+ for (s.clear(); i.length > 0; ) {
236
+ const r = [];
237
+ let c = !1;
238
+ for (const n of i)
239
+ try {
240
+ n() ? c = !0 : r.push(n);
241
+ } catch (a) {
242
+ e.push(a), c = !0;
243
+ }
244
+ if (!c)
245
+ return;
246
+ i = r;
247
+ }
248
+ }
249
+ }
250
+ function p(t, e) {
251
+ const s = t.scopeLastChild;
252
+ e.scopeParent = t, e.scopePrevious = s, e.scopeNext = void 0, s === void 0 ? t.scopeFirstChild = e : s.scopeNext = e, t.scopeLastChild = e;
253
+ }
254
+ function d(t) {
255
+ const e = t.scopeParent;
256
+ if (e === void 0)
257
+ return;
258
+ const s = t.scopePrevious, i = t.scopeNext;
259
+ s === void 0 ? e.scopeFirstChild = i : s.scopeNext = i, i === void 0 ? e.scopeLastChild = s : i.scopePrevious = s, t.scopeParent = void 0, t.scopePrevious = void 0, t.scopeNext = void 0;
260
+ }
261
+ function l(t, e) {
262
+ if (t.length === 1)
263
+ throw t[0];
264
+ if (t.length > 1)
265
+ throw new AggregateError(t, e);
266
+ }
267
+ function _() {
268
+ }
269
+ export {
270
+ f as ScopeNode,
271
+ p as appendScopeChild,
272
+ d as detachScopeChild,
273
+ l as throwScopeErrors
274
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./scope.cjs");function A(t,e,i,d,v={},f){const s=W(i);let l=!1,u,o,a=!1;function h(){if(a)return;a=!0;const n=o;o=void 0,n!==void 0&&e(n)}return t(()=>{if(a)return;const n=f===void 0?s():f(s),p=!l;if(!p&&m(n,u))return;const b=u;if(u=n,l=!0,p&&!v.immediate)return;const y=o;o=void 0;let c;if(y!==void 0)try{e(y)}catch(r){c=[r]}if(!a)try{const r=w(e(()=>d(n,b)));a?r!==void 0&&e(r):o=r}catch(r){c??(c=[]),c.push(r)}c!==void 0&&g.throwScopeErrors(c,"Watch callback and cleanup failed.")},h)}function W(t){if(Array.isArray(t))return()=>t.map(S);const e=t;return typeof e=="function"?e:()=>e.get()}function S(t){return typeof t=="function"?t():t.get()}function m(t,e){if(!Array.isArray(t)||!Array.isArray(e))return Object.is(t,e);if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Object.is(t[i],e[i]))return!1;return!0}function w(t){return typeof t=="function"?t:void 0}exports.watchWithReactivity=A;
@@ -0,0 +1,64 @@
1
+ import { throwScopeErrors as m } from "./scope.js";
2
+ function C(t, e, i, y, h = {}, u) {
3
+ const l = W(i);
4
+ let s = !1, c, o, a = !1;
5
+ function v() {
6
+ if (a)
7
+ return;
8
+ a = !0;
9
+ const n = o;
10
+ o = void 0, n !== void 0 && e(n);
11
+ }
12
+ return t(() => {
13
+ if (a)
14
+ return;
15
+ const n = u === void 0 ? l() : u(l), p = !s;
16
+ if (!p && g(n, c))
17
+ return;
18
+ const A = c;
19
+ if (c = n, s = !0, p && !h.immediate)
20
+ return;
21
+ const d = o;
22
+ o = void 0;
23
+ let f;
24
+ if (d !== void 0)
25
+ try {
26
+ e(d);
27
+ } catch (r) {
28
+ f = [r];
29
+ }
30
+ if (!a)
31
+ try {
32
+ const r = w(e(() => y(n, A)));
33
+ a ? r !== void 0 && e(r) : o = r;
34
+ } catch (r) {
35
+ f ?? (f = []), f.push(r);
36
+ }
37
+ f !== void 0 && m(f, "Watch callback and cleanup failed.");
38
+ }, v);
39
+ }
40
+ function W(t) {
41
+ if (Array.isArray(t))
42
+ return () => t.map(b);
43
+ const e = t;
44
+ return typeof e == "function" ? e : () => e.get();
45
+ }
46
+ function b(t) {
47
+ return typeof t == "function" ? t() : t.get();
48
+ }
49
+ function g(t, e) {
50
+ if (!Array.isArray(t) || !Array.isArray(e))
51
+ return Object.is(t, e);
52
+ if (t.length !== e.length)
53
+ return !1;
54
+ for (let i = 0; i < t.length; i++)
55
+ if (!Object.is(t[i], e[i]))
56
+ return !1;
57
+ return !0;
58
+ }
59
+ function w(t) {
60
+ return typeof t == "function" ? t : void 0;
61
+ }
62
+ export {
63
+ C as watchWithReactivity
64
+ };