@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";var A=Object.defineProperty;var C=(n,e,t)=>e in n?A(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>C(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../path/RaphKernel.cjs"),l=require("../runtime/phases/phase.types.cjs"),g=require("../runtime/RaphRuntime.cjs"),i=require("./errors.cjs"),R=require("./RaphReactivityInstance.cjs"),d=class d{constructor(){c(this,"_instances",new Map);c(this,"_instanceOrder",[]);c(this,"_defaultInstance");c(this,"_disposed",!1)}static create(e){const t=D(e),r=new d,s=[];try{for(const a of t){const o=r._construct(a);r._register(o),a.default&&(r._defaultInstance=o)}return r}catch(a){s.push(a);try{r.dispose()}catch(o){o instanceof AggregateError?s.push(...o.errors):s.push(o)}throw s.length===1?a:new AggregateError(s,"[Raph] Facade configuration and cleanup failed.")}}get disposed(){return this._disposed}get defaultInstanceId(){var e;return(e=this._defaultInstance)==null?void 0:e.id}instance(e){if(this._assertActive(),e===void 0){if(this._defaultInstance===void 0)throw new i.RaphDefaultInstanceError("[Raph] Facade session has no default instance.");return this._defaultInstance}h(e);const t=this._instances.get(e);if(t===void 0)throw new i.RaphConfigurationError(`[Raph] Instance "${e}" is not registered.`);return t}getInstance(e){return this._assertActive(),h(e),this._instances.get(e)}hasInstance(e){return this.getInstance(e)!==void 0}runtime(e){const t=this.instance(e);if(!(t instanceof g.RaphRuntime))throw new i.RaphCapabilityError(`[Raph] Instance "${t.id}" uses reactivity mode and has no Runtime capabilities.`);return t}reactivity(e){const t=this.instance(e);if(!(t instanceof R.RaphReactivityInstance))throw new i.RaphCapabilityError(`[Raph] Instance "${t.id}" uses runtime mode and is not a pure reactivity instance.`);return t}createRuntime(e={}){this._assertActive();const t=e.id??this._generateId("runtime");h(t),this._assertFreeId(t);const r=new g.RaphRuntime({...e,id:t});return this._register(r),r}createReactivity(e={}){this._assertActive();const t=e.id??this._generateId("reactivity");h(t),this._assertFreeId(t);const r=new R.RaphReactivityInstance(t,e);return this._register(r),r}createKernel(e={}){return this._assertActive(),new E.RaphKernel(e)}disposeInstance(e){const t=this.getInstance(e);return t===void 0?!1:(t.dispose(),!0)}dispose(){if(this._disposed)return;this._disposed=!0;const e=[...this._instanceOrder].reverse();this._instances.clear(),this._instanceOrder.length=0,this._defaultInstance=void 0;const t=[];for(const r of e)try{r.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[Raph] Facade session reset failed.")}_construct(e){if(e.mode==="reactivity"){const s=e.config;return new R.RaphReactivityInstance(e.id,{...s.adaptiveDependencyIndex===void 0?{}:{adaptiveDependencyIndex:s.adaptiveDependencyIndex}})}const t=e.config,r=new g.RaphRuntime({...t.adaptiveDependencyIndex===void 0?{}:{adaptiveDependencyIndex:t.adaptiveDependencyIndex},...t.debug===void 0?{}:{debug:t.debug},...t.enforceActions===void 0?{}:{enforceActions:t.enforceActions},...t.kernel===void 0?{}:{kernel:t.kernel},...t.scheduler===void 0?{}:{scheduler:t.scheduler},id:e.id});try{return t.phases!==void 0&&r.definePhases(t.phases),r}catch(s){try{r.dispose()}catch(a){throw new AggregateError([s,a],`[Raph] Runtime "${e.id}" construction and cleanup failed.`)}throw s}}_register(e){this._assertFreeId(e.id),this._instances.set(e.id,e),this._instanceOrder.push(e),e._onDisposed(()=>this._forget(e))}_forget(e){this._instances.get(e.id)===e&&this._instances.delete(e.id);const t=this._instanceOrder.indexOf(e);t>=0&&this._instanceOrder.splice(t,1),this._defaultInstance===e&&(this._defaultInstance=void 0)}_generateId(e){let t;do t=e==="runtime"?`runtime-${d._runtimeCounter++}`:`reactivity-${d._reactivityCounter++}`;while(this._instances.has(t));return t}_assertFreeId(e){if(this._instances.has(e))throw new i.RaphConfigurationError(`[Raph] Instance id "${e}" is already registered.`)}_assertActive(){if(this._disposed)throw new i.RaphFacadeDisposedError("[Raph] Facade session is disposed.")}};c(d,"_runtimeCounter",0),c(d,"_reactivityCounter",0);let y=d;function D(n){if(typeof n!="object"||n===null||Array.isArray(n))throw new i.RaphConfigurationError("[Raph] Configure options must be an object.");if(Object.hasOwn(n,"instances")){w(n,new Set(["instances"]),"configure");const s=n.instances;if(typeof s!="object"||s===null||Array.isArray(s))throw new i.RaphConfigurationError("[Raph] instances must be an object.");const a=[],o=new Set;let v=0;for(const[_,f]of Object.entries(s)){if(typeof f!="object"||f===null||Array.isArray(f))throw new i.RaphConfigurationError(`[Raph] Instance definition "${_}" must be an object.`);const u=f;b(u,!0);const p=u.id??_;if(h(p),o.has(p))throw new i.RaphConfigurationError(`[Raph] Resolved instance id "${p}" is duplicated.`);o.add(p);const m=u.default===!0;m&&v++,a.push({config:u,default:m,id:p,mode:u.mode})}if(v>1)throw new i.RaphConfigurationError("[Raph] Exactly one instance may declare default: true.");return a}const e=n;b(e,!1);const t=e.mode??"runtime",r=e.id??"default";return h(r),[{config:e,default:!0,id:r,mode:t}]}function b(n,e){const t=n.mode??(e?void 0:"runtime");if(t!=="runtime"&&t!=="reactivity")throw new i.RaphConfigurationError(e?"[Raph] Every instances entry must declare mode.":"[Raph] Unsupported instance mode.");if(t==="reactivity"){if(w(n,new Set(e?["adaptiveDependencyIndex","default","id","mode"]:["adaptiveDependencyIndex","id","mode"]),"reactivity instance"),I(n.adaptiveDependencyIndex),e&&n.default!==void 0&&typeof n.default!="boolean")throw new i.RaphConfigurationError("[Raph] default must be boolean.");return}if(w(n,new Set(e?["adaptiveDependencyIndex","debug","default","enforceActions","id","kernel","mode","phases","scheduler"]:["adaptiveDependencyIndex","debug","enforceActions","id","kernel","mode","phases","scheduler"]),"runtime instance"),I(n.adaptiveDependencyIndex),e&&n.default!==void 0&&typeof n.default!="boolean")throw new i.RaphConfigurationError("[Raph] default must be boolean.");const r=n;if(r.enforceActions!==void 0&&typeof r.enforceActions!="boolean")throw new i.RaphConfigurationError("[Raph] enforceActions must be boolean.");if(r.kernel!==void 0&&!(r.kernel instanceof E.RaphKernel))throw new i.RaphConfigurationError("[Raph] kernel must be a RaphKernel instance.");if(r.phases!==void 0&&!Array.isArray(r.phases))throw new i.RaphConfigurationError("[Raph] phases must be an array.");if(r.scheduler!==void 0&&!x(r.scheduler))throw new i.RaphConfigurationError(`[Raph] Unsupported scheduler "${String(r.scheduler)}".`);if(r.debug!==void 0&&(typeof r.debug!="object"||r.debug===null))throw new i.RaphConfigurationError("[Raph] debug must be an object.")}function I(n){if(n!==void 0&&typeof n!="boolean")throw new i.RaphConfigurationError("[Raph] adaptiveDependencyIndex must be boolean.")}function w(n,e,t){for(const r of Object.keys(n))if(!e.has(r))throw new i.RaphConfigurationError(`[Raph] Unsupported ${t} option "${r}".`)}function h(n){if(typeof n!="string"||n.length===0||n.trim()!==n)throw new i.RaphConfigurationError("[Raph] Instance id must be a non-empty string without surrounding whitespace.")}function x(n){return n===l.RaphSchedulerType.Sync||n===l.RaphSchedulerType.Microtask||n===l.RaphSchedulerType.AnimationFrame}exports.RaphFacadeSession=y;
@@ -0,0 +1,306 @@
1
+ var x = Object.defineProperty;
2
+ var k = (n, e, t) => e in n ? x(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var c = (n, e, t) => k(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { RaphKernel as D } from "../path/RaphKernel.js";
5
+ import { RaphSchedulerType as l } from "../runtime/phases/phase.types.js";
6
+ import { RaphRuntime as w } from "../runtime/RaphRuntime.js";
7
+ import { RaphDefaultInstanceError as E, RaphConfigurationError as i, RaphCapabilityError as I, RaphFacadeDisposedError as $ } from "./errors.js";
8
+ import { RaphReactivityInstance as y } from "./RaphReactivityInstance.js";
9
+ const d = class d {
10
+ constructor() {
11
+ c(this, "_instances", /* @__PURE__ */ new Map());
12
+ c(this, "_instanceOrder", []);
13
+ c(this, "_defaultInstance");
14
+ c(this, "_disposed", !1);
15
+ }
16
+ // ---------------------------------------------
17
+ // PUBLIC API
18
+ // ---------------------------------------------
19
+ /**
20
+ * Валидирует всю конфигурацию до construction и атомарно создаёт session.
21
+ */
22
+ static create(e) {
23
+ const t = j(e), s = new d(), r = [];
24
+ try {
25
+ for (const a of t) {
26
+ const o = s._construct(a);
27
+ s._register(o), a.default && (s._defaultInstance = o);
28
+ }
29
+ return s;
30
+ } catch (a) {
31
+ r.push(a);
32
+ try {
33
+ s.dispose();
34
+ } catch (o) {
35
+ o instanceof AggregateError ? r.push(...o.errors) : r.push(o);
36
+ }
37
+ throw r.length === 1 ? a : new AggregateError(r, "[Raph] Facade configuration and cleanup failed.");
38
+ }
39
+ }
40
+ /**
41
+ * Показывает, завершен ли lifecycle session.
42
+ */
43
+ get disposed() {
44
+ return this._disposed;
45
+ }
46
+ /**
47
+ * Возвращает ID default instance без создания fallback.
48
+ */
49
+ get defaultInstanceId() {
50
+ var e;
51
+ return (e = this._defaultInstance) == null ? void 0 : e.id;
52
+ }
53
+ /**
54
+ * Возвращает default либо явно адресованный instance.
55
+ */
56
+ instance(e) {
57
+ if (this._assertActive(), e === void 0) {
58
+ if (this._defaultInstance === void 0)
59
+ throw new E("[Raph] Facade session has no default instance.");
60
+ return this._defaultInstance;
61
+ }
62
+ h(e);
63
+ const t = this._instances.get(e);
64
+ if (t === void 0)
65
+ throw new i(`[Raph] Instance "${e}" is not registered.`);
66
+ return t;
67
+ }
68
+ /**
69
+ * Читает registry без ошибки для неизвестного ID.
70
+ */
71
+ getInstance(e) {
72
+ return this._assertActive(), h(e), this._instances.get(e);
73
+ }
74
+ /**
75
+ * Проверяет наличие managed instance.
76
+ */
77
+ hasInstance(e) {
78
+ return this.getInstance(e) !== void 0;
79
+ }
80
+ /**
81
+ * Возвращает Runtime или сообщает о capability mismatch.
82
+ */
83
+ runtime(e) {
84
+ const t = this.instance(e);
85
+ if (!(t instanceof w))
86
+ throw new I(
87
+ `[Raph] Instance "${t.id}" uses reactivity mode and has no Runtime capabilities.`
88
+ );
89
+ return t;
90
+ }
91
+ /**
92
+ * Возвращает pure-reactivity instance или сообщает о capability mismatch.
93
+ */
94
+ reactivity(e) {
95
+ const t = this.instance(e);
96
+ if (!(t instanceof y))
97
+ throw new I(
98
+ `[Raph] Instance "${t.id}" uses runtime mode and is not a pure reactivity instance.`
99
+ );
100
+ return t;
101
+ }
102
+ /**
103
+ * Создаёт managed Runtime без неявного изменения default pointer.
104
+ */
105
+ createRuntime(e = {}) {
106
+ this._assertActive();
107
+ const t = e.id ?? this._generateId("runtime");
108
+ h(t), this._assertFreeId(t);
109
+ const s = new w({ ...e, id: t });
110
+ return this._register(s), s;
111
+ }
112
+ /**
113
+ * Создаёт managed pure-reactivity instance без изменения default pointer.
114
+ */
115
+ createReactivity(e = {}) {
116
+ this._assertActive();
117
+ const t = e.id ?? this._generateId("reactivity");
118
+ h(t), this._assertFreeId(t);
119
+ const s = new y(t, e);
120
+ return this._register(s), s;
121
+ }
122
+ /** Создаёт unmanaged Kernel, сохраняя generation-bound lifecycle check. */
123
+ createKernel(e = {}) {
124
+ return this._assertActive(), new D(e);
125
+ }
126
+ /**
127
+ * Освобождает managed instance и сразу удаляет его из registry.
128
+ */
129
+ disposeInstance(e) {
130
+ const t = this.getInstance(e);
131
+ return t === void 0 ? !1 : (t.dispose(), !0);
132
+ }
133
+ /**
134
+ * Освобождает managed instances в обратном порядке construction.
135
+ */
136
+ dispose() {
137
+ if (this._disposed)
138
+ return;
139
+ this._disposed = !0;
140
+ const e = [...this._instanceOrder].reverse();
141
+ this._instances.clear(), this._instanceOrder.length = 0, this._defaultInstance = void 0;
142
+ const t = [];
143
+ for (const s of e)
144
+ try {
145
+ s.dispose();
146
+ } catch (r) {
147
+ t.push(r);
148
+ }
149
+ if (t.length === 1)
150
+ throw t[0];
151
+ if (t.length > 1)
152
+ throw new AggregateError(t, "[Raph] Facade session reset failed.");
153
+ }
154
+ // ---------------------------------------------
155
+ // PRIVATE
156
+ // ---------------------------------------------
157
+ /**
158
+ * Создаёт instance из заранее проверенного definition.
159
+ */
160
+ _construct(e) {
161
+ if (e.mode === "reactivity") {
162
+ const r = e.config;
163
+ return new y(e.id, {
164
+ ...r.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: r.adaptiveDependencyIndex }
165
+ });
166
+ }
167
+ const t = e.config, s = new w({
168
+ ...t.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: t.adaptiveDependencyIndex },
169
+ ...t.debug === void 0 ? {} : { debug: t.debug },
170
+ ...t.enforceActions === void 0 ? {} : { enforceActions: t.enforceActions },
171
+ ...t.kernel === void 0 ? {} : { kernel: t.kernel },
172
+ ...t.scheduler === void 0 ? {} : { scheduler: t.scheduler },
173
+ id: e.id
174
+ });
175
+ try {
176
+ return t.phases !== void 0 && s.definePhases(t.phases), s;
177
+ } catch (r) {
178
+ try {
179
+ s.dispose();
180
+ } catch (a) {
181
+ throw new AggregateError(
182
+ [r, a],
183
+ `[Raph] Runtime "${e.id}" construction and cleanup failed.`
184
+ );
185
+ }
186
+ throw r;
187
+ }
188
+ }
189
+ /**
190
+ * Регистрирует единственный managed owner и его terminal cleanup.
191
+ */
192
+ _register(e) {
193
+ this._assertFreeId(e.id), this._instances.set(e.id, e), this._instanceOrder.push(e), e._onDisposed(() => this._forget(e));
194
+ }
195
+ /**
196
+ * Удаляет точную identity после её terminal disposal.
197
+ */
198
+ _forget(e) {
199
+ this._instances.get(e.id) === e && this._instances.delete(e.id);
200
+ const t = this._instanceOrder.indexOf(e);
201
+ t >= 0 && this._instanceOrder.splice(t, 1), this._defaultInstance === e && (this._defaultInstance = void 0);
202
+ }
203
+ /**
204
+ * Формирует свободный ID для dynamic factory.
205
+ */
206
+ _generateId(e) {
207
+ let t;
208
+ do
209
+ t = e === "runtime" ? `runtime-${d._runtimeCounter++}` : `reactivity-${d._reactivityCounter++}`;
210
+ while (this._instances.has(t));
211
+ return t;
212
+ }
213
+ /**
214
+ * Отклоняет duplicate resolved ID до registration.
215
+ */
216
+ _assertFreeId(e) {
217
+ if (this._instances.has(e))
218
+ throw new i(`[Raph] Instance id "${e}" is already registered.`);
219
+ }
220
+ /**
221
+ * Запрещает stale typed/global handle после reset.
222
+ */
223
+ _assertActive() {
224
+ if (this._disposed)
225
+ throw new $("[Raph] Facade session is disposed.");
226
+ }
227
+ };
228
+ c(d, "_runtimeCounter", 0), c(d, "_reactivityCounter", 0);
229
+ let b = d;
230
+ function j(n) {
231
+ if (typeof n != "object" || n === null || Array.isArray(n))
232
+ throw new i("[Raph] Configure options must be an object.");
233
+ if (Object.hasOwn(n, "instances")) {
234
+ v(n, /* @__PURE__ */ new Set(["instances"]), "configure");
235
+ const r = n.instances;
236
+ if (typeof r != "object" || r === null || Array.isArray(r))
237
+ throw new i("[Raph] instances must be an object.");
238
+ const a = [], o = /* @__PURE__ */ new Set();
239
+ let g = 0;
240
+ for (const [m, p] of Object.entries(r)) {
241
+ if (typeof p != "object" || p === null || Array.isArray(p))
242
+ throw new i(`[Raph] Instance definition "${m}" must be an object.`);
243
+ const u = p;
244
+ R(u, !0);
245
+ const f = u.id ?? m;
246
+ if (h(f), o.has(f))
247
+ throw new i(`[Raph] Resolved instance id "${f}" is duplicated.`);
248
+ o.add(f);
249
+ const _ = u.default === !0;
250
+ _ && g++, a.push({ config: u, default: _, id: f, mode: u.mode });
251
+ }
252
+ if (g > 1)
253
+ throw new i("[Raph] Exactly one instance may declare default: true.");
254
+ return a;
255
+ }
256
+ const e = n;
257
+ R(e, !1);
258
+ const t = e.mode ?? "runtime", s = e.id ?? "default";
259
+ return h(s), [{ config: e, default: !0, id: s, mode: t }];
260
+ }
261
+ function R(n, e) {
262
+ const t = n.mode ?? (e ? void 0 : "runtime");
263
+ if (t !== "runtime" && t !== "reactivity")
264
+ throw new i(
265
+ e ? "[Raph] Every instances entry must declare mode." : "[Raph] Unsupported instance mode."
266
+ );
267
+ if (t === "reactivity") {
268
+ if (v(n, new Set(e ? ["adaptiveDependencyIndex", "default", "id", "mode"] : ["adaptiveDependencyIndex", "id", "mode"]), "reactivity instance"), A(n.adaptiveDependencyIndex), e && n.default !== void 0 && typeof n.default != "boolean")
269
+ throw new i("[Raph] default must be boolean.");
270
+ return;
271
+ }
272
+ if (v(n, new Set(e ? ["adaptiveDependencyIndex", "debug", "default", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"] : ["adaptiveDependencyIndex", "debug", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"]), "runtime instance"), A(n.adaptiveDependencyIndex), e && n.default !== void 0 && typeof n.default != "boolean")
273
+ throw new i("[Raph] default must be boolean.");
274
+ const s = n;
275
+ if (s.enforceActions !== void 0 && typeof s.enforceActions != "boolean")
276
+ throw new i("[Raph] enforceActions must be boolean.");
277
+ if (s.kernel !== void 0 && !(s.kernel instanceof D))
278
+ throw new i("[Raph] kernel must be a RaphKernel instance.");
279
+ if (s.phases !== void 0 && !Array.isArray(s.phases))
280
+ throw new i("[Raph] phases must be an array.");
281
+ if (s.scheduler !== void 0 && !O(s.scheduler))
282
+ throw new i(`[Raph] Unsupported scheduler "${String(s.scheduler)}".`);
283
+ if (s.debug !== void 0 && (typeof s.debug != "object" || s.debug === null))
284
+ throw new i("[Raph] debug must be an object.");
285
+ }
286
+ function A(n) {
287
+ if (n !== void 0 && typeof n != "boolean")
288
+ throw new i("[Raph] adaptiveDependencyIndex must be boolean.");
289
+ }
290
+ function v(n, e, t) {
291
+ for (const s of Object.keys(n))
292
+ if (!e.has(s))
293
+ throw new i(`[Raph] Unsupported ${t} option "${s}".`);
294
+ }
295
+ function h(n) {
296
+ if (typeof n != "string" || n.length === 0 || n.trim() !== n)
297
+ throw new i(
298
+ "[Raph] Instance id must be a non-empty string without surrounding whitespace."
299
+ );
300
+ }
301
+ function O(n) {
302
+ return n === l.Sync || n === l.Microtask || n === l.AnimationFrame;
303
+ }
304
+ export {
305
+ b as RaphFacadeSession
306
+ };
@@ -0,0 +1 @@
1
+ "use strict";var h=Object.defineProperty;var d=(s,e,t)=>e in s?h(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>d(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../reactivity/engine.cjs"),n=require("../reactivity/reactive-object.cjs"),u=require("../reactivity/scope.cjs"),c=require("../runtime/errors.cjs");class v{constructor(e,t={}){i(this,"mode","reactivity");i(this,"engine");i(this,"rootScope");i(this,"_disposed",!1);i(this,"_disposedListeners",new Set);this.id=e,this.engine=new p.RaphReactivity({adaptiveDependencyIndex:t.adaptiveDependencyIndex??!1}),this.rootScope=new u.ScopeNode(this.engine),n.configureReactiveObjectPolicy(this.engine,{owner:this,assertRead:()=>this._assertAlive(),assertWrite:()=>this._assertAlive(),throwForeign:()=>{throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.")}})}get disposed(){return this._disposed}signal(e){return this._assertAlive(),this.rootScope.signal(e)}reactive(e){return this._assertAlive(),this.engine.reactive(e)}computed(e){return this._assertAlive(),typeof e=="function"?this.rootScope.computed(e):this.rootScope.computed(e)}effect(e){return this._assertAlive(),this.rootScope.effect(e)}watch(e,t,o){return this._assertAlive(),this.rootScope.watch(e,t,o)}batch(e){return this._assertAlive(),this.engine.batch(e)}untracked(e){return this._assertAlive(),this.engine.untracked(e)}scope(){this._assertAlive();const e=this.engine.scope();return this.rootScope.own(()=>e.dispose()),e}dispose(){if(this._disposed)return;this._disposed=!0;const e=[];try{this.rootScope.dispose()}catch(r){e.push(r)}const t=()=>{throw new c.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)};try{n.disposeReactiveObjectContext(this.engine,{assertRead:t,assertWrite:t,throwForeign:t})}catch(r){e.push(r)}const o=[...this._disposedListeners];this._disposedListeners.clear();for(const r of o)try{r()}catch(a){e.push(a)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,`[Raph] Reactivity instance "${this.id}" disposal failed.`)}_onDisposed(e){return this._disposed?(e(),()=>{}):(this._disposedListeners.add(e),()=>{this._disposedListeners.delete(e)})}_assertAlive(){if(this._disposed)throw new c.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)}}exports.RaphReactivityInstance=v;
@@ -0,0 +1,149 @@
1
+ var a = Object.defineProperty;
2
+ var c = (s, e, t) => e in s ? a(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var i = (s, e, t) => c(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { RaphReactivity as d } from "../reactivity/engine.js";
5
+ import { configureReactiveObjectPolicy as p, disposeReactiveObjectContext as v } from "../reactivity/reactive-object.js";
6
+ import { ScopeNode as l } from "../reactivity/scope.js";
7
+ import { RaphDisposedError as n } from "../runtime/errors.js";
8
+ class R {
9
+ /**
10
+ * Создаёт изолированный graph с общим lifecycle owner.
11
+ */
12
+ constructor(e, t = {}) {
13
+ i(this, "mode", "reactivity");
14
+ i(this, "engine");
15
+ i(this, "rootScope");
16
+ i(this, "_disposed", !1);
17
+ i(this, "_disposedListeners", /* @__PURE__ */ new Set());
18
+ this.id = e, this.engine = new d({
19
+ adaptiveDependencyIndex: t.adaptiveDependencyIndex ?? !1
20
+ }), this.rootScope = new l(this.engine), p(this.engine, {
21
+ owner: this,
22
+ assertRead: () => this._assertAlive(),
23
+ assertWrite: () => this._assertAlive(),
24
+ throwForeign: () => {
25
+ throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.");
26
+ }
27
+ });
28
+ }
29
+ // ---------------------------------------------
30
+ // PUBLIC API
31
+ // ---------------------------------------------
32
+ /**
33
+ * Показывает, завершён ли lifecycle instance.
34
+ */
35
+ get disposed() {
36
+ return this._disposed;
37
+ }
38
+ /**
39
+ * Создаёт signal, принадлежащий root scope instance.
40
+ */
41
+ signal(e) {
42
+ return this._assertAlive(), this.rootScope.signal(e);
43
+ }
44
+ /**
45
+ * Создаёт deep reactive Proxy в изолированном graph instance.
46
+ */
47
+ reactive(e) {
48
+ return this._assertAlive(), this.engine.reactive(e);
49
+ }
50
+ computed(e) {
51
+ return this._assertAlive(), typeof e == "function" ? this.rootScope.computed(e) : this.rootScope.computed(e);
52
+ }
53
+ /**
54
+ * Создаёт синхронный effect в root scope instance.
55
+ */
56
+ effect(e) {
57
+ return this._assertAlive(), this.rootScope.effect(e);
58
+ }
59
+ /**
60
+ * Создаёт value watch в root scope instance.
61
+ */
62
+ watch(e, t, o) {
63
+ return this._assertAlive(), this.rootScope.watch(e, t, o);
64
+ }
65
+ /**
66
+ * Группирует propagation одного reactive graph.
67
+ */
68
+ batch(e) {
69
+ return this._assertAlive(), this.engine.batch(e);
70
+ }
71
+ /**
72
+ * Выполняет операцию без dependency tracking.
73
+ */
74
+ untracked(e) {
75
+ return this._assertAlive(), this.engine.untracked(e);
76
+ }
77
+ /**
78
+ * Создаёт дочерний resource scope, освобождаемый вместе с instance.
79
+ */
80
+ scope() {
81
+ this._assertAlive();
82
+ const e = this.engine.scope();
83
+ return this.rootScope.own(() => e.dispose()), e;
84
+ }
85
+ /**
86
+ * Освобождает owned resources и делает retained reactive proxies терминальными.
87
+ */
88
+ dispose() {
89
+ if (this._disposed)
90
+ return;
91
+ this._disposed = !0;
92
+ const e = [];
93
+ try {
94
+ this.rootScope.dispose();
95
+ } catch (r) {
96
+ e.push(r);
97
+ }
98
+ const t = () => {
99
+ throw new n(`[Raph] Reactivity instance "${this.id}" is disposed.`);
100
+ };
101
+ try {
102
+ v(this.engine, {
103
+ assertRead: t,
104
+ assertWrite: t,
105
+ throwForeign: t
106
+ });
107
+ } catch (r) {
108
+ e.push(r);
109
+ }
110
+ const o = [...this._disposedListeners];
111
+ this._disposedListeners.clear();
112
+ for (const r of o)
113
+ try {
114
+ r();
115
+ } catch (h) {
116
+ e.push(h);
117
+ }
118
+ if (e.length === 1)
119
+ throw e[0];
120
+ if (e.length > 1)
121
+ throw new AggregateError(e, `[Raph] Reactivity instance "${this.id}" disposal failed.`);
122
+ }
123
+ // ---------------------------------------------
124
+ // INTERNAL
125
+ // ---------------------------------------------
126
+ /**
127
+ * Привязывает registry cleanup к lifecycle managed instance.
128
+ * @internal
129
+ */
130
+ _onDisposed(e) {
131
+ return this._disposed ? (e(), () => {
132
+ }) : (this._disposedListeners.add(e), () => {
133
+ this._disposedListeners.delete(e);
134
+ });
135
+ }
136
+ // ---------------------------------------------
137
+ // PRIVATE
138
+ // ---------------------------------------------
139
+ /**
140
+ * Запрещает операции после завершения lifecycle.
141
+ */
142
+ _assertAlive() {
143
+ if (this._disposed)
144
+ throw new n(`[Raph] Reactivity instance "${this.id}" is disposed.`);
145
+ }
146
+ }
147
+ export {
148
+ R as RaphReactivityInstance
149
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o extends Error{}class e extends o{}class a extends e{}class t extends e{}exports.RaphConfigurationError=e;exports.RaphDefaultRuntimeError=t;exports.RaphError=o;exports.RaphModeError=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class e extends Error{}class a extends e{}class s extends a{}class o extends a{}class t extends a{}exports.RaphCapabilityError=s;exports.RaphConfigurationError=a;exports.RaphDefaultInstanceError=o;exports.RaphError=e;exports.RaphFacadeDisposedError=t;
@@ -1,14 +1,17 @@
1
- class s extends Error {
1
+ class a extends Error {
2
+ }
3
+ class s extends a {
2
4
  }
3
5
  class e extends s {
4
6
  }
5
- class a extends e {
7
+ class o extends s {
6
8
  }
7
- class o extends e {
9
+ class t extends s {
8
10
  }
9
11
  export {
10
- e as RaphConfigurationError,
11
- o as RaphDefaultRuntimeError,
12
- s as RaphError,
13
- a as RaphModeError
12
+ e as RaphCapabilityError,
13
+ s as RaphConfigurationError,
14
+ o as RaphDefaultInstanceError,
15
+ a as RaphError,
16
+ t as RaphFacadeDisposedError
14
17
  };
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.defineProperty;var S=(t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>S(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=2e4,u=class u{constructor(e,n){f(this,"_canonical");f(this,"_segments");f(this,"_exact");f(this,"_mask");this._canonical=e,this._segments=Object.freeze(n.map(r=>Object.freeze({...r})))}static from(e,n){return e instanceof u?e:typeof e=="string"?this.fromString(e,n):this.fromPlain(e)}static fromString(e,n){const r=m(e,n==null?void 0:n.vars,!0,(n==null?void 0:n.wildcardDynamic)===!0,!0),s=this._cache??(this._cache=new Map),i=s.get(r.canonical);if(i!==void 0)return i;s.size>=E&&s.clear();const c=new u(r.canonical,r.segments);return s.set(r.canonical,c),c}static fromPlain(e){const r=(Array.isArray(e.segs)?e.segs:[]).map(M);return new u(y(r),r)}static _parseExactString(e,n){const r=m(e,n==null?void 0:n.vars,!1,!1,!0);return{canonical:r.canonical,segments:r.segments}}static _parseMaskString(e){const n=m(e,void 0,!0,!1,!0);for(let i=0;i<n.segments.length-1;i++){const c=n.segments[i];if(c.kind==="wildcard"&&!c.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${e}".`)}const r=n.segments[n.segments.length-1],s=(r==null?void 0:r.kind)==="wildcard"&&!r.indexed;return{canonical:n.canonical,deep:s,segments:s?n.segments.slice(0,-1):n.segments}}static _renderSegments(e){return y(e)}toPlain(){return{segs:this._segments.map(e=>e.kind==="key"?{t:"key",k:e.key}:e.kind==="index"?{t:"idx",i:e.index}:e.kind==="selector"?{t:"param",pk:e.key,pv:e.value}:{t:"wc",indexed:e.indexed}),deepOnTail:_(this._segments)}}toStringPath(){return this._canonical}toString(){return this._canonical}segments(){return this._segments}static match(e,n){const r=this.from(e)._segments,s=this.from(n)._segments;let i=0;for(;i<r.length;i++){const c=r[i];if(c.kind==="wildcard"&&!c.indexed&&i===r.length-1)return!0;const a=s[i];if(a===void 0||!q(c,a))return!1}return i===s.length}_asExact(){for(const e of this._segments)if(e.kind==="wildcard")throw x(this._canonical);return this._exact??(this._exact={canonical:this._canonical,segments:this._segments})}_asMask(){for(let n=0;n<this._segments.length-1;n++){const r=this._segments[n];if(r.kind==="wildcard"&&!r.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${this._canonical}".`)}const e=_(this._segments);return this._mask??(this._mask={canonical:this._canonical,deep:e,segments:e?this._segments.slice(0,-1):this._segments})}};f(u,"_cache");let w=u;function m(t,e,n,r=!1,s=!1){const i=t.trim();if(i.length===0){if(s)return{canonical:"",segments:[]};throw new TypeError("[Raph] Data path must not be empty.")}const c=[];let a=0,l=!0;for(;a<i.length;){const b=i[a];if(b==="."){if(l)throw d(t);l=!0,a++;continue}if(b==="["){const k=T(i,a);c.push(P(i.slice(a+1,k),e,n,r)),a=k+1,l=!1;continue}if(!l)throw d(t);let o=a;for(;o<i.length&&i[o]!=="."&&i[o]!=="[";)o++;const h=i.slice(a,o).trim();if(h.length===0)throw d(t);if(h==="*"){if(!n)throw x(t);c.push({kind:"wildcard",indexed:!1})}else r&&h.startsWith("$")&&!g(h.slice(1),e)?c.push({kind:"wildcard",indexed:!1}):c.push({kind:"key",key:A(h,e)});a=o,l=!1}if(l||c.length===0)throw d(t);return{canonical:y(c),segments:c}}function T(t,e){let n,r=1;for(let s=e+1;s<t.length;s++){const i=t[s];if(i==="\\"){s++;continue}if(n!==void 0){i===n&&(n=void 0);continue}if(i==='"'||i==="'"){n=i;continue}if(i==="["){r++;continue}if(i==="]"&&--r===0)return s}throw d(t)}function P(t,e,n,r){const s=t.trim();if(s==="*"){if(!n)throw x(`[${t}]`);return{kind:"wildcard",indexed:!0}}if(/^\d+$/.test(s))return{kind:"index",index:Number(s)};if(/^\$[A-Z_$][\w$]*$/i.test(s)){if(r&&!g(s.slice(1),e))return{kind:"wildcard",indexed:!0};const l=p(s.slice(1),e);if(!Number.isInteger(l)||l<0)throw new TypeError(`[Raph] Index variable "${s}" must be a non-negative integer.`);return{kind:"index",index:l}}const i=R(s);if(i===-1)throw d(`[${t}]`);const c=s.slice(0,i).trim(),a=s.slice(i+1).trim();if(!c||!a)throw d(`[${t}]`);return r&&I(a,e)?{kind:"wildcard",indexed:!0}:{kind:"selector",key:c,value:N(a,e)}}function R(t){let e;for(let n=0;n<t.length;n++){const r=t[n];if(r==="\\"){n++;continue}if(e!==void 0){r===e&&(e=void 0);continue}if(r==='"'||r==="'")e=r;else if(r==="=")return n}return-1}function N(t,e){if(/^\$[A-Z_$][\w$]*$/i.test(t)){const n=p(t.slice(1),e);if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return n;throw new TypeError(`[Raph] Selector variable "${t}" must be scalar.`)}if(t[0]==='"'||t[0]==="'")return O(t);if(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t)){const n=Number(t);if(Number.isFinite(n))return n}return t==="true"?!0:t==="false"?!1:t==="null"?null:t}function O(t){const e=t[0];if(t.length<2||t[t.length-1]!==e)throw d(t);if(e==='"')try{const r=JSON.parse(t);if(typeof r=="string")return r}catch{throw d(t)}let n="";for(let r=1;r<t.length-1;r++){const s=t[r];if(s==="\\"){if(r++,r>=t.length-1)throw d(t);n+=t[r]}else n+=s}return n}function A(t,e){if(!t.startsWith("$"))return t;const n=p(t.slice(1),e);if(typeof n!="string"&&typeof n!="number")throw new TypeError(`[Raph] Key variable "${t}" must be a string or number.`);const r=String(n);if(!r||r.includes(".")||r.includes("[")||r.includes("]"))throw new TypeError(`[Raph] Key variable "${t}" contains path syntax.`);return r}function p(t,e){if(!g(t,e))throw new TypeError(`[Raph] Missing path variable "${t}".`);return e[t]}function g(t,e){return e!==void 0&&Object.hasOwn(e,t)}function I(t,e){for(const n of t.matchAll(/\$([A-Z_$][\w$]*)/gi))if(!g(n[1],e))return!0;return!1}function M(t){if(typeof t!="object"||t===null)throw $();const e=t;if(e.t==="key"&&typeof e.k=="string")return{kind:"key",key:e.k};if(e.t==="idx"&&typeof e.i=="number"&&Number.isInteger(e.i)&&e.i>=0)return{kind:"index",index:e.i};if(e.t==="wc")return{kind:"wildcard",indexed:e.indexed===!0};if(e.t==="param"&&typeof e.pk=="string"&&j(e.pv))return{kind:"selector",key:e.pk,value:e.pv};throw $()}function j(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function _(t){const e=t[t.length-1];return(e==null?void 0:e.kind)==="wildcard"&&!e.indexed}function q(t,e){return t.kind==="wildcard"?!t.indexed||e.kind==="index"||e.kind==="selector":t.kind!==e.kind?!1:t.kind==="key"?t.key===e.key:t.kind==="index"?t.index===e.index:t.key===e.key&&Object.is(t.value,e.value)}function y(t){let e="";for(const n of t)n.kind==="key"?e+=e?`.${n.key}`:n.key:n.kind==="index"?e+=`[${n.index}]`:n.kind==="selector"?e+=`[${n.key}=${D(n.value)}]`:e+=n.indexed?"[*]":e?".*":"*";return e}function D(t){return typeof t=="string"?JSON.stringify(t):String(t)}function d(t){return new TypeError(`[Raph] Invalid data path "${t}".`)}function $(){return new TypeError("[Raph] Invalid plain DataPath representation.")}function x(t){return new TypeError(`[Raph] Wildcard is only allowed in watch masks: "${t}".`)}exports.DataPath=w;