@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";const Z=new WeakMap,St=16384;function xt(t){var j;if(Pt(t.id,t.version),typeof t.states!="object"||t.states===null||Array.isArray(t.states))throw new TypeError("[Raph machine] states must be an object.");const e=t,n=[],r=new Map,i=[];for(const[h,b]of Object.entries(e.states))i.push(ct(h,b,void 0,0,n,r));const o=r.get(t.initial);if(o===void 0||((j=n[o])==null?void 0:j.parent)!==void 0)throw new Error(`[Raph machine] Initial state "${t.initial}" must be a root state key.`);const a=new Set,s=n.map(h=>{const b=h.initialKey===void 0?void 0:h.children.find(z=>{var l;return((l=n[z])==null?void 0:l.key)===h.initialKey});if(h.kind==="compound"&&b===void 0)throw new Error(`[Raph machine] Compound state "${h.path}" requires a valid direct initial child.`);if(b!==void 0&&n[b].kind==="history")throw new Error(`[Raph machine] Compound state "${h.path}" cannot use history as its initial child.`);const E=h.historyFallbackPath===void 0?void 0:r.get(h.historyFallbackPath);if(h.historyFallbackPath!==void 0&&E===void 0)throw new Error(`[Raph machine] History state "${h.path}" has unknown fallback "${h.historyFallbackPath}".`);for(const z of h.on.keys())a.add(z);return{after:h.after,always:h.always,children:Object.freeze([...h.children]),depth:h.depth,entry:h.entry,exit:h.exit,history:h.history,...E===void 0?{}:{historyFallback:E},id:h.id,...b===void 0?{}:{initial:b},invokes:h.invokes,key:h.key,kind:h.kind,...h.meta===void 0?{}:{meta:h.meta},on:h.on,onDone:h.onDone,...h.output===void 0?{}:{output:h.output},...h.parent===void 0?{}:{parent:h.parent},path:h.path,resources:h.resources,tags:h.tags}});for(const h of s)$t(h,r,s);const c=t.version??1;It(s);const f=Object.freeze([...a]),u=new Map(f.map((h,b)=>[h,b])),d=Object.freeze(s.map(h=>Object.freeze(gt(s,h.id)))),p=Rt(s),v=p&&f.length<=Math.floor(St/s.length)?zt(s,u,f.length):void 0,w=Object.freeze({ancestry:d,context:_t(e.context),eventIndexes:u,eventTypes:f,flat:p,...v===void 0?{}:{flatDispatch:v},id:t.id,initial:o,migrations:Dt(t.migrations,c),...e.output===void 0?{}:{output:e.output},pathToState:r,rootChildren:Object.freeze(i),states:Object.freeze(s),version:c}),m=Object.freeze({id:t.id,version:c});return Z.set(m,w),m}function zt(t,e,n){const r=Array.from({length:t.length*n}).fill(void 0);for(const i of t){const o=i.id*n;for(const[a,s]of i.on)r[o+e.get(a)]=s}return Object.freeze(r)}function gt(t,e){const n=[];for(let r=e;r!==void 0;r=t[r].parent)n.push(r);return n}function Rt(t){return t.every(e=>{if(e.parent!==void 0||e.kind!=="atomic"&&e.kind!=="final"||e.always.length!==0||e.onDone.length!==0||e.after.size!==0||e.entry.length!==0||e.exit.length!==0||e.resources.length!==0||e.invokes.length!==0)return!1;for(const n of e.on.values())if(n.some(r=>r.raise!==void 0))return!1;return!0})}function A(t){const e=Z.get(t);if(e===void 0)throw new TypeError("[Raph machine] Model was not created by defineMachine().");return e}function ct(t,e,n,r,i,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`[Raph machine] State "${t}" must be an object.`);At(e,t),Ct(t);const a=n===void 0?"":i[n].path,s=a?`${a}.${t}`:t,c=i.length;if(o.has(s))throw new Error(`[Raph machine] Duplicate state path "${s}".`);const f=kt(e),u={after:new Map,always:Object.freeze([]),children:[],depth:r,entry:I(e.entry),exit:I(e.exit),history:e.history??"shallow",...e.target===void 0?{}:{historyFallbackPath:e.target},id:c,...e.initial===void 0?{}:{initialKey:e.initial},invokes:Object.freeze([]),key:t,kind:f,...e.meta===void 0?{}:{meta:Object.freeze({...e.meta})},on:new Map,onDone:Object.freeze([]),...e.output===void 0?{}:{output:e.output},...n===void 0?{}:{parent:n},path:s,resources:ot(e.resources),tags:ot(e.tags)};i.push(u),o.set(s,c);for(const[v,w]of Object.entries(e.states??{}))u.children.push(ct(v,w,c,r+1,i,o));let d=0;for(const[v,w]of Object.entries(e.on??{})){if(!v.trim())throw new Error(`[Raph machine] State "${s}" has an empty event type.`);u.on.set(v,P(w,c,()=>d++))}u.always=P(e.always,c,()=>d++),u.onDone=P(e.onDone,c,()=>d++);for(const[v,w]of Object.entries(e.after??{})){if(!v.trim())throw new Error(`[Raph machine] State "${s}" has an empty delay key.`);u.after.set(v,P(w,c,()=>d++))}const p=Ft(e.invoke);return u.invokes=Object.freeze(p.map((v,w)=>Tt(v,u,w,()=>d++))),Mt(u,i),c}function Tt(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`[Raph machine] Invoke in "${e.path}" must be an object.`);const i=typeof t.src=="string"?"task":"machine",o=t.type??i,a=t.id??`${e.path}:invoke#${n+1}`;if(!a.trim())throw new Error(`[Raph machine] Invoke id in "${e.path}" must not be empty.`);if(o!=="machine"&&o!=="task")throw new Error(`[Raph machine] Invoke "${a}" has unsupported type "${String(o)}".`);if(typeof t.src=="string"){if(!t.src.trim())throw new Error(`[Raph machine] Invoke "${a}" source must not be empty.`)}else if(!Z.has(t.src))throw new TypeError(`[Raph machine] Invoke "${a}" actor source must come from defineMachine().`);if(o==="task"&&typeof t.src!="string")throw new TypeError(`[Raph machine] Task invoke "${a}" requires a string source.`);return Object.freeze({id:a,...t.input===void 0?{}:{input:t.input},onDone:P(t.onDone,e.id,r),onError:P(t.onError,e.id,r),src:t.src,type:o})}function P(t,e,n){if(t===void 0)return Object.freeze([]);const r=Array.isArray(t)?t:[t];return Object.freeze(r.map(i=>{const o=typeof i=="string"?{target:i}:i;if(o===null||typeof o!="object")throw new TypeError("[Raph machine] Transition must be a target string or object.");if(o.reenter===!0&&o.target===void 0)throw new Error("[Raph machine] A targetless transition cannot declare reenter: true.");if(o.reason!==void 0&&(typeof o.reason!="string"||!o.reason.trim()))throw new Error("[Raph machine] Transition reason must be a non-empty string.");return W(o.guard===void 0?[]:[o.guard],"guard"),W(I(o.reduce),"reducer"),W(I(o.emit),"output"),{emit:I(o.emit),...o.guard===void 0?{}:{guard:o.guard},index:n(),...o.raise===void 0?{}:{raise:o.raise},...o.reason===void 0?{}:{reason:o.reason},reduce:I(o.reduce),reenter:o.reenter===!0,source:e,...o.target===void 0?{}:{target:o.target}}}))}function $t(t,e,n){var i;const r=[t.always,t.onDone,...t.on.values(),...t.after.values()];for(const o of t.invokes)r.push(o.onDone,o.onError);for(const o of r)for(const a of o){if(a.target!==void 0){const s=a.target,c=e.get(s);if(c===void 0)throw new Error(`[Raph machine] Transition from "${t.path}" targets unknown state "${s}".`);a.target=c}Object.freeze(a)}if(t.kind==="history"&&t.historyFallback!==void 0){const o=(i=[...e].find(([,s])=>s===t.historyFallback))==null?void 0:i[0],a=t.path.slice(0,t.path.lastIndexOf("."));if(o===void 0||o===t.path||t.historyFallback===void 0||!o.startsWith(`${a}.`))throw new Error(`[Raph machine] History fallback for "${t.path}" must stay inside its parent state.`);if(n[t.historyFallback].kind==="history")throw new Error(`[Raph machine] History fallback for "${t.path}" cannot target another history state.`)}}function kt(t){if(t.type!==void 0){if(t.type!=="atomic"&&t.type!=="compound"&&t.type!=="final"&&t.type!=="history"&&t.type!=="parallel")throw new TypeError(`[Raph machine] Unsupported state type "${String(t.type)}".`);return t.type}return t.states===void 0?"atomic":"compound"}function Mt(t,e){if((t.kind==="atomic"||t.kind==="final"||t.kind==="history")&&t.children.length!==0)throw new Error(`[Raph machine] ${t.kind} state "${t.path}" cannot have children.`);if(t.kind==="parallel"&&t.initialKey!==void 0)throw new Error(`[Raph machine] Parallel state "${t.path}" cannot declare initial.`);if(t.kind==="parallel"&&!t.children.some(n=>e[n].kind!=="history"))throw new Error(`[Raph machine] Parallel state "${t.path}" requires at least one region.`);if(t.kind==="history"&&t.parent===void 0)throw new Error(`[Raph machine] History state "${t.path}" must have a parent.`);if(t.kind!=="history"&&t.historyFallbackPath!==void 0)throw new Error("[Raph machine] Only a history state may declare target as fallback.");if((t.kind==="atomic"||t.kind==="final"||t.kind==="history")&&t.initialKey!==void 0)throw new Error(`[Raph machine] ${t.kind} state "${t.path}" cannot declare initial.`);if((t.kind==="final"||t.kind==="history")&&(t.on.size!==0||t.always.length!==0||t.after.size!==0||t.onDone.length!==0||t.invokes.length!==0))throw new Error(`[Raph machine] ${t.kind} state "${t.path}" cannot declare transitions or invokes.`)}function At(t,e){if(U(t.states,`State "${e}" states`),U(t.on,`State "${e}" on`),U(t.after,`State "${e}" after`),t.history!==void 0&&t.history!=="deep"&&t.history!=="shallow")throw new TypeError(`[Raph machine] State "${e}" has unsupported history mode.`)}function U(t,e){if(t!==void 0&&(typeof t!="object"||t===null||Array.isArray(t)))throw new TypeError(`[Raph machine] ${e} must be an object.`)}function Pt(t,e){if(typeof t!="string"||!t.trim())throw new TypeError("[Raph machine] Model id must be a non-empty string.");const n=e??1;if(!Number.isSafeInteger(n)||n<1)throw new TypeError("[Raph machine] Model version must be a positive safe integer.")}function It(t){const e=new Set;for(const n of t)for(const r of n.invokes){if(e.has(r.id))throw new Error(`[Raph machine] Invoke id "${r.id}" is duplicated.`);e.add(r.id)}}function Dt(t,e){const n=new Map;for(const[r,i]of Object.entries(t??{})){const o=Number(r);if(!Number.isSafeInteger(o)||o<1||o>=e)throw new Error(`[Raph machine] Migration version "${r}" must be a positive integer below ${e}.`);if(typeof i!="function")throw new TypeError(`[Raph machine] Migration from version ${o} must be a function.`);n.set(o,i)}return n}function W(t,e){for(const n of t)if(typeof n!="function"&&(typeof n!="string"||!n.trim()))throw new TypeError(`[Raph machine] ${e} reference must be a function or non-empty string.`)}function Ct(t){if(!t||t.includes("."))throw new Error("[Raph machine] State keys must be non-empty and cannot contain dots.")}function I(t){return Object.freeze(t===void 0?[]:Array.isArray(t)?[...t]:[t])}function ot(t){if(t===void 0)return Object.freeze([]);const e=typeof t=="string"?[t]:[...t];for(const n of e)if(typeof n!="string"||!n.trim())throw new TypeError("[Raph machine] Tags and resource names must be non-empty strings.");return Object.freeze(e)}function Ft(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function _t(t){return Array.isArray(t)?Object.freeze([...t]):typeof t=="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype?Object.freeze({...t}):t}const T=Symbol("RaphMachineSnapshot"),it=new WeakMap;function ut(t){const e=Object.getPrototypeOf(t);return e!==null&&Object.hasOwn(e,T)?e:void 0}function ft(t){return t[T]}function L(t,e,n){const r=n??Object.freeze({[T]:e}),i=Object.create(r);return i.active=t.active,i.context=t.context,i.history=t.history,t.output!==void 0&&(i.output=t.output),i.revision=t.revision,i.status=t.status,Object.freeze(i)}function J(t,e,n,r,i){let o=t==null?void 0:t.flatPrototypes;o===void 0&&(n===void 0?(o=it.get(r),o===void 0&&(o=[],it.set(r,o))):o=[]);const a=o[e];if(a!==void 0)return a;const s=Object.freeze({[T]:Object.freeze({active:Object.freeze([e]),flatPrototypes:o,input:n,model:r,publicActive:Object.freeze([i])})});return o[e]=s,s}const Nt=100,G=Object.freeze({type:"@@init"}),ht=Object.freeze([]),q=Object.freeze({}),K=Object.freeze([]),C=Object.freeze([]),Ht=Object.freeze([]),Q=Object.freeze({entered:K,entryOutputs:C,event:G,exited:K,exitOutputs:C,transitionOutputs:C});function qt(t,e){return pt(t,e,void 0).snapshot}function Kt(t,e,n,r,i){const o=ft(e);if(o!==void 0&&o.model!==t)throw new TypeError("[Raph machine] Snapshot belongs to another model.");const a=A(t);return tt(t,e,n,r,o==null?void 0:o.input,i,a).snapshot}function dt(t,e){var n;if(((n=ut(e))==null?void 0:n[T].model)!==t)throw new TypeError("[Raph machine] Snapshot belongs to another model or was not created by Raph.")}function Lt(t,e){if(dt(t,e),e.status==="stopped")return e;const n=ut(e);return L({active:e.active,context:e.context,history:e.history,...e.output===void 0?{}:{output:e.output},revision:e.revision+1,status:"stopped"},n[T],n)}function pt(t,e,n,r){const i=A(t),o=i.context,a=typeof o=="function"?o(e):o;if(i.flat){const f=i.states[i.initial],u=f.kind==="final"?"done":"active",d=u==="done"?f.output??i.output:void 0,p=typeof d=="function"?d({context:a,event:G,input:e}):d,v=J(void 0,i.initial,e,t,f.path),w=v[T],m=L({active:w.publicActive,context:rt(a),history:q,...p===void 0?{}:{output:p},revision:0,status:u},w,v);return{changed:!1,plan:Q,snapshot:m}}const s=$(i,i.initial,q),c=F(t,e,{active:s,context:a,history:q},0,"active",void 0,i);return tt(t,c,G,n,e,r,i,!0)}function tt(t,e,n,r,i,o,a,s=!1,c=ht){return Et(n),lt(t,e,n,r,i,o,a,void 0,s,c)}function lt(t,e,n,r,i,o,a,s,c=!1,f=ht){const u=a??A(t);if(e.status!=="active")return D(e);if(!c&&u.flat){const y=s??u.eventIndexes.get(n.type);return y===void 0?D(e):Yt(t,u,e,n,y,r,i,o)}if(!c&&!ee(u,e.active,n.type))return D(e);const d={active:e.active.map(y=>N(u,y)),context:e.context,history:{...e.history}},p=r,v=new Set,w=new Set,m=[],j=[],h=[],b=[...f];let E=!1;if(!c){const y=at(u,d,n,p,i,o);st(y,v,w,m,j,h),E=y.changed,b.push(...y.raised)}const z=new Set;let l=0;for(;;){const y=b.shift();let S;if(y!==void 0?S=at(u,d,y,p,i,o):(S=Wt(u,d,n,p,i,o),S.changed||(S=Gt(u,d,n,p,i,z,o))),!S.changed){if(b.length!==0)continue;break}if(++l>Nt)throw new Error("[Raph machine] Macrostep exceeded 100 stabilization microsteps.");for(const B of S.exited)z.delete(B);for(const B of S.entered)z.delete(B);E=!0,st(S,v,w,m,j,h),b.push(...S.raised)}const O=nt(u,d.active)?"done":"active";if(!E&&O===e.status)return D(e);const k=O==="done"?bt(u,d,n,i):void 0,g=F(t,i,d,e.revision+1,O,k,u),R=new Set(_(u,d.active));return Object.freeze({changed:!0,plan:Object.freeze({entered:Object.freeze([...w].filter(y=>R.has(y)).sort((y,S)=>u.states[y].depth-u.states[S].depth)),entryOutputs:Object.freeze(h),event:n,exited:Object.freeze([...v].sort((y,S)=>u.states[S].depth-u.states[y].depth)),exitOutputs:Object.freeze(m),transitionOutputs:Object.freeze(j)}),snapshot:g})}function Yt(t,e,n,r,i,o,a,s){const c=ft(n),f=(c==null?void 0:c.active[0])??N(e,n.active[0]),u=e.flatDispatch===void 0?e.states[f].on.get(r.type):e.flatDispatch[f*e.eventTypes.length+i],d=H(u??Ht,n.context,r,o,a,s);if(d===void 0)return D(n);yt(e,d,s);let p=n.context;for(const z of d.reduce)p=Ot(z,o)({context:p,event:r,input:a});const v=d.target??f,w=e.states[v],m=w.kind==="final"?"done":"active",j=m==="done"?w.output??e.output:void 0,h=typeof j=="function"?j({context:p,event:r,input:a}):j,b=J(c,v,a,t,w.path),E=L({active:v===f?n.active:b[T].publicActive,context:p===n.context?n.context:rt(p),history:n.history,...h===void 0?{}:{output:h},revision:n.revision+1,status:m},b[T],b);return{changed:!0,plan:d.emit.length===0?Q:{entered:K,entryOutputs:C,event:r,exited:K,exitOutputs:C,transitionOutputRefs:d.emit,transitionOutputs:C},snapshot:E}}function Vt(t,e,n,r,i,o,a){const s=A(t),c=H(r,e.context,n,i,o,a);if(c===void 0)return D(e);const f={active:e.active.map(b=>N(s,b)),context:e.context,history:{...e.history}},u=Y(s,f,[c],n,i,o,a),d=F(t,o,f,e.revision,"active",void 0,s),p=tt(t,d,n,i,o,a,s,!0,u.raised),v=p.changed?{active:p.snapshot.active.map(b=>N(s,b)),context:p.snapshot.context,history:{...p.snapshot.history}}:f,w=p.changed?p.snapshot.status:nt(s,v.active)?"done":"active",m=w==="done"?p.snapshot.output??bt(s,v,n,o):void 0,j=F(t,o,v,e.revision+1,w,m,s),h=new Set(_(s,v.active));return Object.freeze({changed:!0,plan:Object.freeze({entered:Object.freeze(M([...u.entered,...p.plan.entered]).filter(b=>h.has(b)).sort((b,E)=>s.states[b].depth-s.states[E].depth)),entryOutputs:Object.freeze([...u.entryOutputs,...p.plan.entryOutputs]),event:n,exited:Object.freeze(M([...u.exited,...p.plan.exited]).sort((b,E)=>s.states[E].depth-s.states[b].depth)),exitOutputs:Object.freeze([...u.exitOutputs,...p.plan.exitOutputs]),transitionOutputs:Object.freeze([...u.transitionOutputs,...p.plan.transitionOutputs])}),snapshot:j})}function Bt(t,e,n){const r=A(t);if(e.status!=="active"&&e.status!=="done"&&e.status!=="stopped")throw new Error(`[Raph machine] Unknown persisted status "${String(e.status)}".`);if(!Number.isSafeInteger(e.revision)||e.revision<0)throw new Error("[Raph machine] Persisted revision must be a non-negative safe integer.");const i=e.active.map(o=>N(r,o));return Ut(r,i,e.history,e.status),F(t,n,{active:M(i),context:e.context,history:{...e.history}},e.revision,e.status,e.output,r)}function Ut(t,e,n,r){if(e.length===0||new Set(e).size!==e.length)throw new Error("[Raph machine] Persisted active configuration must contain unique leaf states.");for(const a of e){const s=t.states[a].kind;if(s!=="atomic"&&s!=="final")throw new Error(`[Raph machine] Persisted active state "${t.states[a].path}" is not a leaf.`)}if(new Set(e.map(a=>V(t,a))).size!==1)throw new Error("[Raph machine] Persisted configuration spans multiple root states.");for(const a of t.states){if(a.kind!=="compound"&&a.kind!=="parallel")continue;const s=a.children.filter(f=>t.states[f].kind!=="history"&&e.some(u=>u===f||x(t,f,u)));if(e.some(f=>x(t,a.id,f))){if(a.kind==="compound"&&s.length!==1)throw new Error(`[Raph machine] Compound state "${a.path}" requires one active child.`);if(a.kind==="parallel"&&s.length!==a.children.filter(f=>t.states[f].kind!=="history").length)throw new Error(`[Raph machine] Parallel state "${a.path}" requires every region.`)}}const o=nt(t,e);if(r==="done"&&!o)throw new Error("[Raph machine] Done persisted snapshot is not in a final configuration.");if(r==="active"&&o)throw new Error("[Raph machine] Active persisted snapshot is already final.");for(const[a,s]of Object.entries(n)){const c=t.pathToState.get(a);if(c===void 0)throw new Error(`[Raph machine] Persisted history has unknown owner "${a}".`);const f=t.states[c];if(f.kind!=="compound"&&f.kind!=="parallel")throw new Error(`[Raph machine] Persisted history owner "${a}" cannot own history.`);if(!Array.isArray(s))throw new TypeError(`[Raph machine] Persisted history for "${a}" must be an array.`);for(const u of s){const d=t.pathToState.get(u);if(d===void 0||!x(t,c,d))throw new Error(`[Raph machine] Persisted history path "${u}" is invalid for "${a}".`)}}}function at(t,e,n,r,i,o){const a=[],s=new Set,c=[...e.active].sort((f,u)=>t.states[u].depth-t.states[f].depth||f-u);for(const f of c)for(let u=f;u!==void 0&&!s.has(u);u=t.states[u].parent){const d=t.states[u].on.get(n.type);if(d===void 0)continue;const p=H(d,e.context,n,r,i,o);if(p!==void 0){s.add(u),a.push(p);break}}return Y(t,e,vt(t,a),n,r,i,o)}function Wt(t,e,n,r,i,o){const a=[],s=new Set;for(const c of e.active)for(let f=c;f!==void 0;f=t.states[f].parent){if(s.has(f))continue;s.add(f);const u=H(t.states[f].always,e.context,n,r,i,o);u!==void 0&&a.push(u)}return Y(t,e,vt(t,a),n,r,i,o)}function Gt(t,e,n,r,i,o,a){const s=_(t,e.active).filter(c=>!o.has(c)&&et(t,c,e.active)).sort((c,f)=>t.states[f].depth-t.states[c].depth);for(const c of s){o.add(c);const f=H(t.states[c].onDone,e.context,n,r,i,a);if(f!==void 0)return Y(t,e,[f],n,r,i,a)}return mt()}function Y(t,e,n,r,i,o,a){var z;if(n.length===0)return mt();const s=[...e.active],c=new Set(_(t,s)),f=new Set,u=new Set,d=new Set,p=[],v=[];let w=!1;for(const l of n){yt(t,l,a);for(const y of l.reduce)e.context=Ot(y,i)({context:e.context,event:r,input:o}),w=!0;for(const y of l.emit)p.push({event:r,ref:y});if(l.emit.length!==0&&(w=!0),l.raise!==void 0){const y=typeof l.raise=="function"?l.raise({context:e.context,event:r,input:o}):l.raise;Et(y),v.push(y),w=!0}if(l.target===void 0){w=!0;continue}const O=l.source,k=l.target;if(O===k&&!l.reenter){w=!0;continue}const g=X(t,O,k);if(l.reenter){d.add(g);for(const y of c)(y===g||x(t,g,y))&&f.add(y)}e.active=e.active.filter(y=>y!==g&&!x(t,g,y));const R=wt(t,k,e.history);e.active.push(...R),w=!0}e.active=Zt(t,M(e.active),e.history);const m=new Set(_(t,e.active));for(const l of d)for(const O of m)(O===l||x(t,l,O))&&u.add(O);const j=[...c].filter(l=>!m.has(l)||f.has(l)).sort((l,O)=>t.states[O].depth-t.states[l].depth),h=[...m].filter(l=>!c.has(l)||u.has(l)).sort((l,O)=>t.states[l].depth-t.states[O].depth);for(const l of j){const O=t.states[l];if(O.kind==="compound"||O.kind==="parallel"){const k=s.filter(g=>x(t,l,g));if(k.length!==0){const g=((z=O.children.map(R=>t.states[R]).find(R=>R.kind==="history"))==null?void 0:z.history)??O.history;e.history[O.path]=Object.freeze(k.map(R=>{if(g==="deep")return t.states[R].path;const y=jt(t,l,R);return t.states[y].path}))}}}const b=j.flatMap(l=>t.states[l].exit.map(O=>({event:r,ref:O}))),E=h.flatMap(l=>t.states[l].entry.map(O=>({event:r,ref:O})));return Object.freeze({changed:w||j.length!==0||h.length!==0,entered:Object.freeze(h),entryOutputs:Object.freeze(E),exited:Object.freeze(j),exitOutputs:Object.freeze(b),raised:Object.freeze(v),transitionOutputs:Object.freeze(p)})}function yt(t,e,n){(n==null?void 0:n.transition)!==void 0&&n.transition({...e.reason===void 0?{}:{reason:e.reason},source:t.states[e.source].path,...e.target===void 0?{}:{target:t.states[e.target].path}})}function H(t,e,n,r,i,o){var a;for(const s of t){if(s.guard===void 0)return s;const c=Jt(s.guard,r),f=c({context:e,event:n,input:i});if((a=o==null?void 0:o.guard)==null||a.call(o,typeof s.guard=="string"?s.guard:c.name||"inline",f,re(e)?e:void 0),f)return s}}function vt(t,e){const n=[...e].sort((i,o)=>t.states[o.source].depth-t.states[i.source].depth||i.source-o.source||i.index-o.index),r=[];for(const i of n)r.some(a=>Xt(t,i,a))||r.push(i);return r}function Xt(t,e,n){const r=X(t,e.source,e.target??e.source),i=X(t,n.source,n.target??n.source);return e.source===n.source||x(t,e.source,n.source)||x(t,n.source,e.source)||r===i||x(t,r,i)||x(t,i,r)}function X(t,e,n){if(e===n||x(t,e,n))return e;const r=Qt(t,e,n);return r!==void 0&&t.states[r].kind==="parallel"?r:r===void 0?V(t,e):jt(t,r,e)}function wt(t,e,n){const r=t.states[e];if(r.kind!=="history")return $(t,e,n);const i=r.parent,o=n[t.states[i].path];if(o!==void 0&&o.length!==0){const a=[];for(const s of o){const c=t.pathToState.get(s);c!==void 0&&a.push(...r.history==="deep"?$(t,c,n):$(t,c,{}))}if(a.length!==0)return M(a)}return r.historyFallback!==void 0?$(t,r.historyFallback,n):$(t,i,{})}function Zt(t,e,n){const r=[...e];for(let i=0;i<r.length;i++)for(const o of t.ancestry[r[i]].slice(1)){const a=t.states[o];if(a.kind==="parallel")for(const s of a.children)t.states[s].kind!=="history"&&(r.some(c=>c===s||x(t,s,c))||r.push(...$(t,s,n)))}return M(r)}function $(t,e,n){const r=t.states[e];if(r.kind==="history")return wt(t,e,n);if(r.kind==="atomic"||r.kind==="final")return[e];if(r.kind==="compound")return $(t,r.initial,n);const i=[];for(const o of r.children)t.states[o].kind!=="history"&&i.push(...$(t,o,n));return M(i)}function et(t,e,n){const r=t.states[e];return r.kind==="final"?n.includes(e):r.kind==="compound"?r.children.some(i=>t.states[i].kind==="final"&&n.includes(i)):r.kind==="parallel"?r.children.filter(i=>t.states[i].kind!=="history").every(i=>et(t,i,n)):!1}function nt(t,e){const n=te(t,e[0]);return n===void 0?!1:et(t,n,e)}function bt(t,e,n,r){const i=V(t,e.active[0]),o=t.states[i],a=o.kind==="compound"?e.active.find(c=>t.states[c].parent===i&&t.states[c].kind==="final"):o.kind==="final"?i:void 0,s=a===void 0?t.output:t.states[a].output??t.output;return typeof s=="function"?s({context:e.context,event:n,input:r}):s}function Jt(t,e){var r;if(typeof t=="function")return t;const n=(r=e==null?void 0:e.guards)==null?void 0:r[t];if(n===void 0)throw new Error(`[Raph machine] Guard binding "${t}" is not defined.`);return n}function Ot(t,e){var r;if(typeof t=="function")return t;const n=(r=e==null?void 0:e.reducers)==null?void 0:r[t];if(n===void 0)throw new Error(`[Raph machine] Reducer binding "${t}" is not defined.`);return n}function F(t,e,n,r,i,o,a){const s=a??A(t),c=s.flat&&n.active.length===1?n.active[0]:void 0,f=c===void 0?void 0:J(void 0,c,e,t,s.states[c].path),u=f===void 0?Object.freeze([...n.active]):void 0,d=(f==null?void 0:f[T])??Object.freeze({active:u,input:e,model:t});return L({active:d.publicActive??Object.freeze(u.map(p=>s.states[p].path)),context:rt(n.context),history:s.flat?q:ne(n.history),...o===void 0?{}:{output:o},revision:r,status:i},d,f)}function D(t,e){return{changed:!1,plan:Q,snapshot:t}}function mt(){return Object.freeze({changed:!1,entered:Object.freeze([]),entryOutputs:Object.freeze([]),exited:Object.freeze([]),exitOutputs:Object.freeze([]),raised:Object.freeze([]),transitionOutputs:Object.freeze([])})}function st(t,e,n,r,i,o){for(const a of t.exited)e.add(a);for(const a of t.entered)n.add(a);r.push(...t.exitOutputs),i.push(...t.transitionOutputs),o.push(...t.entryOutputs)}function _(t,e){const n=new Set;for(const r of e)for(const i of t.ancestry[r])n.add(i);return[...n]}function Qt(t,e,n){const r=new Set(t.ancestry[e]);for(const i of t.ancestry[n])if(r.has(i))return i}function x(t,e,n){const r=t.ancestry[n];return r.length>1&&r.includes(e,1)}function jt(t,e,n){let r=n;for(;t.states[r].parent!==e;){const i=t.states[r].parent;if(i===void 0)return r;r=i}return r}function V(t,e){return t.ancestry[e].at(-1)}function te(t,e){return e===void 0?void 0:V(t,e)}function N(t,e){const n=t.pathToState.get(e);if(n===void 0)throw new Error(`[Raph machine] Snapshot contains unknown state "${e}".`);return n}function ee(t,e,n){if(!t.eventIndexes.has(n))return!1;for(const r of e){const i=t.pathToState.get(r);if(i!==void 0){for(const o of t.ancestry[i])if(t.states[o].on.has(n))return!0}}return!1}function M(t){return[...new Set(t)].sort((e,n)=>e-n)}function rt(t){return typeof t=="object"&&t!==null?Object.freeze(t):t}function ne(t){const e={};for(const[n,r]of Object.entries(t))e[n]=Object.freeze([...r]);return Object.freeze(e)}function Et(t){if(typeof t!="object"||t===null||typeof t.type!="string"||!t.type)throw new TypeError("[Raph machine] Event must contain a non-empty string type.")}function re(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}exports.assertMachineSnapshot=dt;exports.createInitialSnapshot=pt;exports.defineMachine=xt;exports.getCompiledMachine=A;exports.getInitialSnapshot=qt;exports.hydrateSnapshot=Bt;exports.runExplicitTransitions=Vt;exports.runValidatedMacrostep=lt;exports.stopMachineSnapshot=Lt;exports.transition=Kt;
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var p=(i,e,t)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var a=(i,e,t)=>p(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../path/derived/derived-strategy.utils.cjs"),f=require("../runtime/phases/phase.types.cjs"),g=require("../runtime/RaphRuntime.cjs"),u=require("./errors.cjs"),m=require("./RaphFacadeSession.cjs"),h=require("./RaphReactivityInstance.cjs");class q{constructor(e){this._session=e}get configured(){return!0}get defaultInstanceId(){return this._session.defaultInstanceId}get kernel(){return this._runtime().kernel}get meta(){return this._runtime().meta}get debug(){return this._runtime().debug}get root(){return this._runtime().root}get rootScope(){return this._runtime().rootScope}get frameTick(){return this._runtime().frameTick}get frame(){return this._runtime().frame}get phases(){return this._runtime().phases}get loopEnabled(){return this._runtime().loopEnabled}instance(e){return this._session.instance(e)}getInstance(e){return this._session.getInstance(e)}hasInstance(e){return this._session.hasInstance(e)}disposeInstance(e){return this._session.disposeInstance(e)}runtime(e){return this._session.runtime(e)}reactivity(e){return this._session.reactivity(e)}createRuntime(e={}){return this._session.createRuntime(e)}createReactivity(e={}){return this._session.createReactivity(e)}createKernel(e={}){return this._session.createKernel(e)}signal(e){return this._reactive().signal(e)}reactive(e){return this._reactive().reactive(e)}computed(e){const t=this._reactive();return t instanceof g.RaphRuntime,t.computed(e)}effect(e,t,r){const s=this._session.instance();if(s instanceof h.RaphReactivityInstance){if(typeof e!="function"||t!==void 0)throw _("phase effect",s);return s.effect(e)}if(typeof e!="string"||t===void 0)throw new u.RaphCapabilityError("[Raph] Runtime effects require an explicit phase.");return s.effect(s.rootScope,e,t,r)}watch(e,t,r,s){const n=this._session.instance();if(n instanceof h.RaphReactivityInstance){if(typeof t!="function")throw _("phase watch",n);return n.watch(e,t,r)}if(typeof t!="string"||typeof r!="function")throw new u.RaphCapabilityError("[Raph] Runtime watches require an explicit phase.");return n.watch(n.rootScope,e,t,r,s)}batch(e){return this._reactive().batch(e)}untracked(e){return this._reactive().untracked(e)}scope(e){const t=this._session.instance();if(t instanceof h.RaphReactivityInstance){if(e!==void 0)throw _("named Runtime scope",t);return t.scope()}if(e===void 0)throw new u.RaphCapabilityError("[Raph] Runtime scopes require an explicit id.");return t.scope(e)}action(e,t){return typeof e=="function"?this._runtime().action(e):this._runtime().action(e,t)}definePhases(e){this._runtime().definePhases(e)}addPhase(e){this._runtime().addPhase(e)}clearPhases(){this._runtime().clearPhases()}requestExecution(){this._runtime().requestExecution()}flush(){this._runtime().flush()}afterFlush(){return this._runtime().afterFlush()}acquireLoop(e){return this._runtime().acquireLoop(e)}startLoop(){this._runtime().startLoop()}stopLoop(){this._runtime().stopLoop()}aggregate(e){const t=this._runtime();return t.aggregate(t.rootScope,e)}node(e,t){return this._runtime().node(e,t)}getNode(e){return this._runtime().getNode(e)}derive(e){return this._runtime().derive(e)}getDerivedSnapshot(){return this._runtime().getDerivedSnapshot()}path(e,t={}){return this._runtime().path(e,t)}get(e,t){return e===void 0?this._runtime().get():this._runtime().get(e,t)}peek(e,t){return e===void 0?this._runtime().peek():this._runtime().peek(e,t)}has(e,t){return this._runtime().has(e,t)}set(e,t,r){this._runtime().set(e,t,r)}merge(e,t,r){this._runtime().merge(e,t,r)}delete(e,t){this._runtime().delete(e,t)}_dispose(){this._session.dispose()}_runtime(){return this._session.runtime()}_reactive(){return this._session.instance()}}class c{constructor(){}static get configured(){return this._handle!==void 0}static get defaultInstanceId(){return this._require().defaultInstanceId}static get kernel(){return this._require().kernel}static get meta(){return this._require().meta}static get debug(){return this._require().debug}static get root(){return this._require().root}static get rootScope(){return this._require().rootScope}static get frameTick(){return this._require().frameTick}static get frame(){return this._require().frame}static get phases(){return this._require().phases}static get loopEnabled(){return this._require().loopEnabled}static configure(e){if(this._handle!==void 0)throw new u.RaphConfigurationError("[Raph] Facade is already configured.");const t=new q(m.RaphFacadeSession.create(e));return this._handle=t,t}static reset(){const e=this._handle;e!==void 0&&(this._handle=void 0,e._dispose())}static instance(e){return this._require().instance(e)}static getInstance(e){return this._require().getInstance(e)}static hasInstance(e){return this._require().hasInstance(e)}static disposeInstance(e){return this._require().disposeInstance(e)}static runtime(e){return this._require().runtime(e)}static reactivity(e){return this._require().reactivity(e)}static createRuntime(e={}){return this._require().createRuntime(e)}static createReactivity(e={}){return this._require().createReactivity(e)}static createKernel(e={}){return this._require().createKernel(e)}static signal(e){return this._require().signal(e)}static reactive(e){return this._require().reactive(e)}static computed(e){return typeof e=="function"?this._require().computed(e):this._require().computed(e)}static effect(e,t,r){return typeof e=="function"?this._require().effect(e):this._require().effect(e,t,r)}static watch(e,t,r,s){const n=this._require();return typeof t=="string"?n.watch(e,t,r,s):n.watch(e,t,r)}static batch(e){return this._require().batch(e)}static untracked(e){return this._require().untracked(e)}static scope(e){return e===void 0?this._require().scope():this._require().scope(e)}static action(e,t){return typeof e=="function"?this._require().action(e):this._require().action(e,t)}static definePhases(e){this._require().definePhases(e)}static addPhase(e){this._require().addPhase(e)}static clearPhases(){this._require().clearPhases()}static requestExecution(){this._require().requestExecution()}static flush(){this._require().flush()}static afterFlush(){return this._require().afterFlush()}static acquireLoop(e){return this._require().acquireLoop(e)}static startLoop(){this._require().startLoop()}static stopLoop(){this._require().stopLoop()}static aggregate(e){return this._require().aggregate(e)}static node(e,t){return this._require().node(e,t)}static getNode(e){return this._require().getNode(e)}static derive(e){return this._require().derive(e)}static getDerivedSnapshot(){return this._require().getDerivedSnapshot()}static path(e,t={}){return this._require().path(e,t)}static get(e,t){return e===void 0?this._require().get():this._require().get(e,t)}static peek(e,t){return e===void 0?this._require().peek():this._require().peek(e,t)}static has(e,t){return this._require().has(e,t)}static set(e,t,r){this._require().set(e,t,r)}static merge(e,t,r){this._require().merge(e,t,r)}static delete(e,t){this._require().delete(e,t)}static _require(){const e=this._handle;if(e===void 0)throw new u.RaphConfigurationError("[Raph] Facade is not configured. Call Raph.configure(...) first.");return e}}a(c,"_handle"),a(c,"Scheduler",f.RaphSchedulerType),a(c,"DerivedStrategy",Object.freeze({full:o.full,collectionByKey:o.collectionByKey,filterByKey:o.filterByKey}));function _(i,e){return new u.RaphCapabilityError(`[Raph] ${i} is unavailable for reactivity instance "${e.id}".`)}exports.Raph=c;
@@ -0,0 +1,421 @@
1
+ var d = Object.defineProperty;
2
+ var f = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var u = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { filterByKey as p, collectionByKey as m, full as g } from "../path/derived/derived-strategy.utils.js";
5
+ import { RaphSchedulerType as q } from "../runtime/phases/phase.types.js";
6
+ import { RaphRuntime as v } from "../runtime/RaphRuntime.js";
7
+ import { RaphConfigurationError as _, RaphCapabilityError as a } from "./errors.js";
8
+ import { RaphFacadeSession as l } from "./RaphFacadeSession.js";
9
+ import { RaphReactivityInstance as o } from "./RaphReactivityInstance.js";
10
+ class y {
11
+ constructor(e) {
12
+ this._session = e;
13
+ }
14
+ // ---------------------------------------------
15
+ // PUBLIC API
16
+ // ---------------------------------------------
17
+ get configured() {
18
+ return !0;
19
+ }
20
+ get defaultInstanceId() {
21
+ return this._session.defaultInstanceId;
22
+ }
23
+ get kernel() {
24
+ return this._runtime().kernel;
25
+ }
26
+ get meta() {
27
+ return this._runtime().meta;
28
+ }
29
+ get debug() {
30
+ return this._runtime().debug;
31
+ }
32
+ get root() {
33
+ return this._runtime().root;
34
+ }
35
+ get rootScope() {
36
+ return this._runtime().rootScope;
37
+ }
38
+ get frameTick() {
39
+ return this._runtime().frameTick;
40
+ }
41
+ get frame() {
42
+ return this._runtime().frame;
43
+ }
44
+ get phases() {
45
+ return this._runtime().phases;
46
+ }
47
+ get loopEnabled() {
48
+ return this._runtime().loopEnabled;
49
+ }
50
+ instance(e) {
51
+ return this._session.instance(e);
52
+ }
53
+ getInstance(e) {
54
+ return this._session.getInstance(e);
55
+ }
56
+ hasInstance(e) {
57
+ return this._session.hasInstance(e);
58
+ }
59
+ disposeInstance(e) {
60
+ return this._session.disposeInstance(e);
61
+ }
62
+ runtime(e) {
63
+ return this._session.runtime(e);
64
+ }
65
+ reactivity(e) {
66
+ return this._session.reactivity(e);
67
+ }
68
+ createRuntime(e = {}) {
69
+ return this._session.createRuntime(e);
70
+ }
71
+ createReactivity(e = {}) {
72
+ return this._session.createReactivity(e);
73
+ }
74
+ createKernel(e = {}) {
75
+ return this._session.createKernel(e);
76
+ }
77
+ signal(e) {
78
+ return this._reactive().signal(e);
79
+ }
80
+ reactive(e) {
81
+ return this._reactive().reactive(e);
82
+ }
83
+ computed(e) {
84
+ const t = this._reactive();
85
+ return t instanceof v, t.computed(e);
86
+ }
87
+ effect(e, t, r) {
88
+ const s = this._session.instance();
89
+ if (s instanceof o) {
90
+ if (typeof e != "function" || t !== void 0)
91
+ throw h("phase effect", s);
92
+ return s.effect(e);
93
+ }
94
+ if (typeof e != "string" || t === void 0)
95
+ throw new a("[Raph] Runtime effects require an explicit phase.");
96
+ return s.effect(s.rootScope, e, t, r);
97
+ }
98
+ watch(e, t, r, s) {
99
+ const n = this._session.instance();
100
+ if (n instanceof o) {
101
+ if (typeof t != "function")
102
+ throw h("phase watch", n);
103
+ return n.watch(
104
+ e,
105
+ t,
106
+ r
107
+ );
108
+ }
109
+ if (typeof t != "string" || typeof r != "function")
110
+ throw new a("[Raph] Runtime watches require an explicit phase.");
111
+ return n.watch(
112
+ n.rootScope,
113
+ e,
114
+ t,
115
+ r,
116
+ s
117
+ );
118
+ }
119
+ batch(e) {
120
+ return this._reactive().batch(e);
121
+ }
122
+ untracked(e) {
123
+ return this._reactive().untracked(e);
124
+ }
125
+ scope(e) {
126
+ const t = this._session.instance();
127
+ if (t instanceof o) {
128
+ if (e !== void 0)
129
+ throw h("named Runtime scope", t);
130
+ return t.scope();
131
+ }
132
+ if (e === void 0)
133
+ throw new a("[Raph] Runtime scopes require an explicit id.");
134
+ return t.scope(e);
135
+ }
136
+ action(e, t) {
137
+ return typeof e == "function" ? this._runtime().action(e) : this._runtime().action(e, t);
138
+ }
139
+ definePhases(e) {
140
+ this._runtime().definePhases(e);
141
+ }
142
+ addPhase(e) {
143
+ this._runtime().addPhase(e);
144
+ }
145
+ clearPhases() {
146
+ this._runtime().clearPhases();
147
+ }
148
+ requestExecution() {
149
+ this._runtime().requestExecution();
150
+ }
151
+ flush() {
152
+ this._runtime().flush();
153
+ }
154
+ afterFlush() {
155
+ return this._runtime().afterFlush();
156
+ }
157
+ acquireLoop(e) {
158
+ return this._runtime().acquireLoop(e);
159
+ }
160
+ startLoop() {
161
+ this._runtime().startLoop();
162
+ }
163
+ stopLoop() {
164
+ this._runtime().stopLoop();
165
+ }
166
+ aggregate(e) {
167
+ const t = this._runtime();
168
+ return t.aggregate(t.rootScope, e);
169
+ }
170
+ node(e, t) {
171
+ return this._runtime().node(e, t);
172
+ }
173
+ getNode(e) {
174
+ return this._runtime().getNode(e);
175
+ }
176
+ derive(e) {
177
+ return this._runtime().derive(e);
178
+ }
179
+ getDerivedSnapshot() {
180
+ return this._runtime().getDerivedSnapshot();
181
+ }
182
+ path(e, t = {}) {
183
+ return this._runtime().path(e, t);
184
+ }
185
+ get(e, t) {
186
+ return e === void 0 ? this._runtime().get() : this._runtime().get(e, t);
187
+ }
188
+ peek(e, t) {
189
+ return e === void 0 ? this._runtime().peek() : this._runtime().peek(e, t);
190
+ }
191
+ has(e, t) {
192
+ return this._runtime().has(e, t);
193
+ }
194
+ set(e, t, r) {
195
+ this._runtime().set(e, t, r);
196
+ }
197
+ merge(e, t, r) {
198
+ this._runtime().merge(e, t, r);
199
+ }
200
+ delete(e, t) {
201
+ this._runtime().delete(e, t);
202
+ }
203
+ // ---------------------------------------------
204
+ // INTERNAL
205
+ // ---------------------------------------------
206
+ /**
207
+ * Освобождает точную session generation для global reset.
208
+ * @internal
209
+ */
210
+ _dispose() {
211
+ this._session.dispose();
212
+ }
213
+ // ---------------------------------------------
214
+ // PRIVATE
215
+ // ---------------------------------------------
216
+ _runtime() {
217
+ return this._session.runtime();
218
+ }
219
+ _reactive() {
220
+ return this._session.instance();
221
+ }
222
+ }
223
+ class c {
224
+ constructor() {
225
+ }
226
+ // ---------------------------------------------
227
+ // PUBLIC API
228
+ // ---------------------------------------------
229
+ static get configured() {
230
+ return this._handle !== void 0;
231
+ }
232
+ static get defaultInstanceId() {
233
+ return this._require().defaultInstanceId;
234
+ }
235
+ static get kernel() {
236
+ return this._require().kernel;
237
+ }
238
+ static get meta() {
239
+ return this._require().meta;
240
+ }
241
+ static get debug() {
242
+ return this._require().debug;
243
+ }
244
+ static get root() {
245
+ return this._require().root;
246
+ }
247
+ static get rootScope() {
248
+ return this._require().rootScope;
249
+ }
250
+ static get frameTick() {
251
+ return this._require().frameTick;
252
+ }
253
+ static get frame() {
254
+ return this._require().frame;
255
+ }
256
+ static get phases() {
257
+ return this._require().phases;
258
+ }
259
+ static get loopEnabled() {
260
+ return this._require().loopEnabled;
261
+ }
262
+ static configure(e) {
263
+ if (this._handle !== void 0)
264
+ throw new _("[Raph] Facade is already configured.");
265
+ const t = new y(l.create(e));
266
+ return this._handle = t, t;
267
+ }
268
+ static reset() {
269
+ const e = this._handle;
270
+ e !== void 0 && (this._handle = void 0, e._dispose());
271
+ }
272
+ static instance(e) {
273
+ return this._require().instance(e);
274
+ }
275
+ static getInstance(e) {
276
+ return this._require().getInstance(e);
277
+ }
278
+ static hasInstance(e) {
279
+ return this._require().hasInstance(e);
280
+ }
281
+ static disposeInstance(e) {
282
+ return this._require().disposeInstance(e);
283
+ }
284
+ static runtime(e) {
285
+ return this._require().runtime(e);
286
+ }
287
+ static reactivity(e) {
288
+ return this._require().reactivity(e);
289
+ }
290
+ static createRuntime(e = {}) {
291
+ return this._require().createRuntime(e);
292
+ }
293
+ static createReactivity(e = {}) {
294
+ return this._require().createReactivity(e);
295
+ }
296
+ static createKernel(e = {}) {
297
+ return this._require().createKernel(e);
298
+ }
299
+ static signal(e) {
300
+ return this._require().signal(e);
301
+ }
302
+ static reactive(e) {
303
+ return this._require().reactive(e);
304
+ }
305
+ static computed(e) {
306
+ return typeof e == "function" ? this._require().computed(e) : this._require().computed(e);
307
+ }
308
+ static effect(e, t, r) {
309
+ return typeof e == "function" ? this._require().effect(e) : this._require().effect(e, t, r);
310
+ }
311
+ static watch(e, t, r, s) {
312
+ const n = this._require();
313
+ return typeof t == "string" ? n.watch(
314
+ e,
315
+ t,
316
+ r,
317
+ s
318
+ ) : n.watch(
319
+ e,
320
+ t,
321
+ r
322
+ );
323
+ }
324
+ static batch(e) {
325
+ return this._require().batch(e);
326
+ }
327
+ static untracked(e) {
328
+ return this._require().untracked(e);
329
+ }
330
+ static scope(e) {
331
+ return e === void 0 ? this._require().scope() : this._require().scope(e);
332
+ }
333
+ static action(e, t) {
334
+ return typeof e == "function" ? this._require().action(e) : this._require().action(e, t);
335
+ }
336
+ static definePhases(e) {
337
+ this._require().definePhases(e);
338
+ }
339
+ static addPhase(e) {
340
+ this._require().addPhase(e);
341
+ }
342
+ static clearPhases() {
343
+ this._require().clearPhases();
344
+ }
345
+ static requestExecution() {
346
+ this._require().requestExecution();
347
+ }
348
+ static flush() {
349
+ this._require().flush();
350
+ }
351
+ static afterFlush() {
352
+ return this._require().afterFlush();
353
+ }
354
+ static acquireLoop(e) {
355
+ return this._require().acquireLoop(e);
356
+ }
357
+ static startLoop() {
358
+ this._require().startLoop();
359
+ }
360
+ static stopLoop() {
361
+ this._require().stopLoop();
362
+ }
363
+ static aggregate(e) {
364
+ return this._require().aggregate(e);
365
+ }
366
+ static node(e, t) {
367
+ return this._require().node(e, t);
368
+ }
369
+ static getNode(e) {
370
+ return this._require().getNode(e);
371
+ }
372
+ static derive(e) {
373
+ return this._require().derive(e);
374
+ }
375
+ static getDerivedSnapshot() {
376
+ return this._require().getDerivedSnapshot();
377
+ }
378
+ static path(e, t = {}) {
379
+ return this._require().path(e, t);
380
+ }
381
+ static get(e, t) {
382
+ return e === void 0 ? this._require().get() : this._require().get(e, t);
383
+ }
384
+ static peek(e, t) {
385
+ return e === void 0 ? this._require().peek() : this._require().peek(e, t);
386
+ }
387
+ static has(e, t) {
388
+ return this._require().has(e, t);
389
+ }
390
+ static set(e, t, r) {
391
+ this._require().set(e, t, r);
392
+ }
393
+ static merge(e, t, r) {
394
+ this._require().merge(e, t, r);
395
+ }
396
+ static delete(e, t) {
397
+ this._require().delete(e, t);
398
+ }
399
+ // ---------------------------------------------
400
+ // PRIVATE
401
+ // ---------------------------------------------
402
+ static _require() {
403
+ const e = this._handle;
404
+ if (e === void 0)
405
+ throw new _("[Raph] Facade is not configured. Call Raph.configure(...) first.");
406
+ return e;
407
+ }
408
+ }
409
+ u(c, "_handle"), u(c, "Scheduler", q), u(c, "DerivedStrategy", Object.freeze({
410
+ full: g,
411
+ collectionByKey: m,
412
+ filterByKey: p
413
+ }));
414
+ function h(i, e) {
415
+ return new a(
416
+ `[Raph] ${i} is unavailable for reactivity instance "${e.id}".`
417
+ );
418
+ }
419
+ export {
420
+ c as Raph
421
+ };
@@ -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;