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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) 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-CClhT8WR.js +1044 -0
  8. package/dist/core-cPQWYD4K.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -367
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +302 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +146 -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/DataPath.js +390 -0
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/PathRouter.js +80 -0
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +316 -236
  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/derived/DerivedRegistry.js +143 -0
  27. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  28. package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
  29. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  30. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
  31. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  32. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  33. package/dist/debug/path/meta/MetaController.cjs +1 -0
  34. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
  35. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  36. package/dist/debug/path/meta/RaphMeta.js +62 -0
  37. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  38. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
  39. package/dist/debug/path/meta/meta.types.cjs +1 -0
  40. package/dist/debug/path/meta/meta.types.js +1 -0
  41. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  42. package/dist/debug/path/storage/AdapterPathStore.js +128 -0
  43. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  44. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
  45. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  46. package/dist/debug/path/storage/PathEventHub.js +161 -0
  47. package/dist/debug/path/storage/PathStore.cjs +1 -0
  48. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
  49. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  50. package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
  51. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  52. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  53. package/dist/debug/reactivity/disposal.cjs +1 -0
  54. package/dist/debug/reactivity/disposal.js +32 -0
  55. package/dist/debug/reactivity/engine.cjs +1 -1
  56. package/dist/debug/reactivity/engine.js +888 -321
  57. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  58. package/dist/debug/reactivity/reactive-object.js +265 -0
  59. package/dist/debug/reactivity/scope.cjs +1 -1
  60. package/dist/debug/reactivity/scope.js +221 -117
  61. package/dist/debug/reactivity/watch.cjs +1 -1
  62. package/dist/debug/reactivity/watch.js +1 -1
  63. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  64. package/dist/debug/runtime/RaphRuntime.js +1134 -502
  65. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  66. package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
  67. package/dist/debug/runtime/errors.cjs +1 -1
  68. package/dist/debug/runtime/errors.js +6 -3
  69. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  70. package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
  71. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  72. package/dist/debug/runtime/ownership/RaphNode.js +665 -0
  73. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  74. package/dist/debug/runtime/ownership/RaphScope.js +236 -0
  75. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  76. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  77. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  78. package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
  79. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  80. package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
  81. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  82. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  83. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  84. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  85. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  86. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  87. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  88. package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
  89. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  90. package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
  91. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  92. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  93. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  94. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
  95. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  96. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
  97. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  98. package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
  99. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  100. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  101. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  103. package/dist/entrypoints/machine-testing.d.ts +2 -0
  104. package/dist/entrypoints/machine.d.ts +5 -0
  105. package/dist/entrypoints/path.d.ts +14 -0
  106. package/dist/entrypoints/reactivity.d.ts +1 -0
  107. package/dist/entrypoints/runtime.d.ts +18 -0
  108. package/dist/index.cjs +1 -1
  109. package/dist/index.js +46 -38
  110. package/dist/machine/compiler.d.ts +71 -0
  111. package/dist/machine/core.d.ts +50 -0
  112. package/dist/machine/persistence.d.ts +5 -0
  113. package/dist/machine/runtime.d.ts +4 -0
  114. package/dist/machine/testing.d.ts +43 -0
  115. package/dist/machine/types.d.ts +155 -0
  116. package/dist/machine-testing.cjs +1 -0
  117. package/dist/machine-testing.js +188 -0
  118. package/dist/machine.cjs +1 -0
  119. package/dist/machine.js +822 -0
  120. package/dist/main.d.ts +20 -0
  121. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  122. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  123. package/dist/path/RaphKernel.d.ts +37 -10
  124. package/dist/path/data-path.types.d.ts +34 -0
  125. package/dist/path/data-path.utils.d.ts +9 -0
  126. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  127. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  128. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  129. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  130. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  131. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  132. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  133. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  134. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  135. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  136. package/dist/path/path.types.d.ts +3 -2
  137. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  138. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  139. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  140. package/dist/path/storage/PathEventHub.d.ts +62 -0
  141. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
  142. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  143. package/dist/path.cjs +1 -1
  144. package/dist/path.js +16 -16
  145. package/dist/raph.cjs +1 -1
  146. package/dist/raph.js +46 -38
  147. package/dist/reactivity/disposal.d.ts +14 -0
  148. package/dist/reactivity/engine.d.ts +193 -6
  149. package/dist/reactivity/reactive-object.d.ts +36 -0
  150. package/dist/reactivity/scope.d.ts +108 -30
  151. package/dist/reactivity/types.d.ts +25 -0
  152. package/dist/reactivity.cjs +1 -1
  153. package/dist/reactivity.js +12 -12
  154. package/dist/runtime/RaphRuntime.d.ts +319 -160
  155. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  156. package/dist/runtime/errors.d.ts +5 -0
  157. package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
  158. package/dist/runtime/ownership/RaphNode.d.ts +310 -0
  159. package/dist/runtime/ownership/RaphScope.d.ts +168 -0
  160. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  161. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  162. package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
  163. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  164. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  165. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  166. package/dist/runtime/phases/phase.types.d.ts +171 -0
  167. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  168. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  169. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  170. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
  171. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
  172. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
  173. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  174. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
  175. package/dist/runtime.cjs +1 -1
  176. package/dist/runtime.js +21 -16
  177. package/package.json +76 -35
  178. package/ReadMe.md +0 -153
  179. package/dist/api/public.d.ts +0 -22
  180. package/dist/debug/api/public.cjs +0 -1
  181. package/dist/debug/api/public.js +0 -40
  182. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  183. package/dist/debug/path/AdapterPathStore.js +0 -133
  184. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  185. package/dist/debug/path/DerivedRegistry.js +0 -157
  186. package/dist/debug/path/MetaController.cjs +0 -1
  187. package/dist/debug/path/PathEventHub.cjs +0 -1
  188. package/dist/debug/path/PathEventHub.js +0 -148
  189. package/dist/debug/path/PathStore.cjs +0 -1
  190. package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
  191. package/dist/debug/path/RaphMeta.cjs +0 -1
  192. package/dist/debug/path/RaphMeta.js +0 -68
  193. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  194. package/dist/debug/path/data-adapter.cjs +0 -1
  195. package/dist/debug/path/data-draft.cjs +0 -1
  196. package/dist/debug/path/data-path.cjs +0 -1
  197. package/dist/debug/path/data-path.js +0 -423
  198. package/dist/debug/path/derived-collection.cjs +0 -1
  199. package/dist/debug/path/path-router.cjs +0 -1
  200. package/dist/debug/path/path-router.js +0 -86
  201. package/dist/debug/path/public.cjs +0 -1
  202. package/dist/debug/path/public.js +0 -18
  203. package/dist/debug/runtime/PathHandle.cjs +0 -1
  204. package/dist/debug/runtime/PathHandle.js +0 -139
  205. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  206. package/dist/debug/runtime/RaphDebug.js +0 -15
  207. package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
  208. package/dist/debug/runtime/RaphNode.cjs +0 -1
  209. package/dist/debug/runtime/RaphNode.js +0 -143
  210. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  211. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  212. package/dist/debug/runtime/RaphScope.cjs +0 -1
  213. package/dist/debug/runtime/RaphScope.js +0 -64
  214. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  215. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  216. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  217. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  218. package/dist/debug/runtime/public.cjs +0 -1
  219. package/dist/debug/runtime/public.js +0 -18
  220. package/dist/path/PathEventHub.d.ts +0 -48
  221. package/dist/path/public.d.ts +0 -14
  222. package/dist/runtime/RaphDebug.d.ts +0 -32
  223. package/dist/runtime/RaphNode.d.ts +0 -68
  224. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  225. package/dist/runtime/RaphScope.d.ts +0 -50
  226. package/dist/runtime/RuntimeReactivity.d.ts +0 -40
  227. package/dist/runtime/phase.types.d.ts +0 -49
  228. package/dist/runtime/public.d.ts +0 -13
  229. package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
  230. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  231. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  232. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  233. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  234. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  235. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  236. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  237. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  238. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  239. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  240. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  241. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  242. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  243. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  244. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  245. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  246. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -0,0 +1,42 @@
1
+ function s(n, t, e) {
2
+ t._sweepDue = e, n.push(t), r(n, t, n.length - 1);
3
+ }
4
+ function w(n, t) {
5
+ const e = t._sweepSlot;
6
+ if (e < 0 || n[e] !== t)
7
+ return !1;
8
+ t._sweepSlot = -1;
9
+ const o = n.pop();
10
+ return o === t || (e !== 0 && o._sweepDue < n[e - 1 >> 1]._sweepDue ? r(n, o, e) : f(n, o, e)), !0;
11
+ }
12
+ function S(n, t) {
13
+ const e = n[0];
14
+ e._sweepDue = t, f(n, e, 0);
15
+ }
16
+ function r(n, t, e) {
17
+ const o = t._sweepDue;
18
+ for (; e !== 0; ) {
19
+ const i = e - 1 >> 1, p = n[i];
20
+ if (p._sweepDue <= o)
21
+ break;
22
+ n[e] = p, p._sweepSlot = e, e = i;
23
+ }
24
+ n[e] = t, t._sweepSlot = e;
25
+ }
26
+ function f(n, t, e) {
27
+ const o = n.length, i = t._sweepDue;
28
+ for (let p = e * 2 + 1; p < o; p = e * 2 + 1) {
29
+ const c = p + 1;
30
+ c < o && n[c]._sweepDue < n[p]._sweepDue && (p = c);
31
+ const _ = n[p];
32
+ if (_._sweepDue >= i)
33
+ break;
34
+ n[e] = _, _._sweepSlot = e, e = p;
35
+ }
36
+ n[e] = t, t._sweepSlot = e;
37
+ }
38
+ export {
39
+ w as dequeueSweeper,
40
+ s as enqueueSweeper,
41
+ S as postponeFirstSweeper
42
+ };
@@ -0,0 +1,2 @@
1
+ export { createMachineCoverage, createManualMachineClock, enumerateMachinePaths, inspectMachine, } from '../machine/testing';
2
+ export type { EnumeratedMachinePath, EnumerateMachinePathOptions, MachineCoverage, MachineCoverageReport, MachineInspection, ManualMachineClock, } from '../machine/testing';
@@ -0,0 +1,5 @@
1
+ export { defineMachine } from '../machine/compiler';
2
+ export { getInitialSnapshot, transition } from '../machine/core';
3
+ export { MachinePersistenceError, persistMachineSnapshot, restoreMachineSnapshot, } from '../machine/persistence';
4
+ export { createMachine } from '../machine/runtime';
5
+ export type { CreateMachineOptions, MachineActorRef, MachineBindings, MachineClock, MachineConfig, MachineEvent, MachineEventStatus, MachineGuard, MachineGuardArgs, MachineInstance, MachineInvokeConfig, MachineMigration, MachineModel, MachineOutput, MachineOutputArgs, MachineReducer, MachineReducerArgs, MachineResource, MachineResourceArgs, MachineSendResult, MachineSnapshot, MachineStateConfig, MachineStatus, MachineTask, MachineTaskArgs, MachineTransitionConfig, MachineTransitionDefinition, PersistedMachineSnapshot, } from '../machine/types';
@@ -0,0 +1,14 @@
1
+ export type { DataPathParseOptions, PathScalar, PathSegment, PlainDataPath, } from '../path/data-path.types';
2
+ export { DataPath } from '../path/DataPath';
3
+ export type { DerivedCollectionByKeyStrategy, DerivedFilterByKeyStrategy, DerivedFullStrategy, DerivedStrategy, } from '../path/derived/derived-strategy.types';
4
+ export { collectionByKey, filterByKey, full } from '../path/derived/derived-strategy.utils';
5
+ export { RaphDerivedHandle } from '../path/derived/RaphDerivedHandle';
6
+ export type { DerivedOptions } from '../path/derived/RaphDerivedHandle';
7
+ export type { RaphMetaApi, RaphMetaEvents, RaphMetaMutationCause, RaphMetaMutationEvent, RaphMetaMutationKind, RaphMetaReadOptions, RaphMetaWatchCallback, RaphMetaWatchOptions, RaphMetaWriteOptions, } from '../path/meta/meta.types';
8
+ export { RaphMeta } from '../path/meta/RaphMeta';
9
+ export type { DataPathDef, PathApi, PathEvent, PathEvents, PathMutationKind, PathOptions, PathWatchCallback, } from '../path/path.types';
10
+ export { RaphKernel } from '../path/RaphKernel';
11
+ export type { RaphKernelOptions, RaphKernelRoot, RaphKernelRuntime, } from '../path/RaphKernel';
12
+ export type { DataAdapter, DataObject, DefaultAdapterOptions, } from '../path/storage/data-adapter.types';
13
+ export { DefaultDataAdapter } from '../path/storage/DefaultDataAdapter';
14
+ export { PathStore } from '../path/storage/PathStore';
@@ -0,0 +1 @@
1
+ export * from '../reactivity/engine';
@@ -0,0 +1,18 @@
1
+ export type { RaphDebugFrameLoopSnapshot, RaphDebugMachinesApi, RaphDebugOptions, RaphDebugOwnerSnapshot, RaphDebugSnapshot, RaphDebugStats, RaphDebugTraceApi, RaphDebugTreeNode, RaphMachineDebugSnapshot, RaphMachineDebugSummary, RaphRuntimeDebug, RaphTraceContextMode, RaphTraceEvent, RaphTraceGuardMode, RaphTraceKind, RaphTraceOptions, RaphTraceReadOptions, RaphTraceStatus, } from '../runtime/diagnostics/RaphDebug';
2
+ export { RaphActionError, RaphCrossRuntimeError, RaphDisposedError, RaphPhaseProcessError, } from '../runtime/errors';
3
+ export type { DepGraph } from '../runtime/ownership/parent-graph.types';
4
+ export { parentGraph } from '../runtime/ownership/parentGraph';
5
+ export { RaphEffectScope } from '../runtime/ownership/RaphEffectScope';
6
+ export { RaphNode } from '../runtime/ownership/RaphNode';
7
+ export type { NodeOptions } from '../runtime/ownership/RaphNode';
8
+ export { RaphScope } from '../runtime/ownership/RaphScope';
9
+ export { orderPhaseTasks } from '../runtime/phases/orderPhaseTasks';
10
+ export { RaphSchedulerType } from '../runtime/phases/phase.types';
11
+ export type { FrameLoopLease, RaphAggregateSource, RaphEffectGroup, RaphEffectGroupOptions, RaphEffectGroupRun, RaphEffectGroupSlot, RaphEffectInitialMode, RaphEffectOptions, RaphFrameContext, RaphPhase, RaphPhaseBatch, RaphPhaseBody, RaphPhaseEffect, RaphPhaseTask, RaphSchedulerMode, RaphStructureCause, RaphTaskOrderOptions, RaphWatchInclude, RaphWatchInitialMode, RaphWatchOptions, RaphWatchSource, RaphWorkCause, RaphWorkCauseKind, } from '../runtime/phases/phase.types';
12
+ export { RaphRuntime } from '../runtime/RaphRuntime';
13
+ export type { RaphRuntimeConfiguration, RaphRuntimeMeta, RaphRuntimeOptions, } from '../runtime/RaphRuntime';
14
+ export { PathHandle } from '../runtime/reactivity/PathHandle';
15
+ export type { RaphMetaSource } from '../runtime/reactivity/RaphMetaSource';
16
+ export type { RaphMetaSourceOptions } from '../runtime/reactivity/RaphMetaSource';
17
+ export type { RaphSelector, RaphSelectorOptions } from '../runtime/reactivity/RaphSelector';
18
+ export type { RaphAggregate } from '../runtime/reactivity/RaphWorkGraph';
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./debug/path/data-adapter.cjs"),o=require("./debug/path/data-path.cjs"),r=require("./debug/path/derived-strategies.cjs"),t=require("./debug/path/RaphDerivedHandle.cjs"),h=require("./debug/path/RaphKernel.cjs"),u=require("./debug/path/RaphMeta.cjs"),a=require("./debug/runtime/errors.cjs"),i=require("./debug/runtime/parent-graph.cjs"),n=require("./debug/runtime/PathHandle.cjs"),R=require("./debug/runtime/phase.types.cjs"),d=require("./debug/runtime/RaphNode.cjs"),_=require("./debug/runtime/RaphRuntime.cjs"),s=require("./debug/runtime/RaphScope.cjs"),e=require("./debug/api/errors.cjs"),c=require("./debug/api/Raph.cjs");exports.DefaultDataAdapter=p.DefaultDataAdapter;exports.DataPath=o.DataPath;exports.collectionByKey=r.collectionByKey;exports.filterByKey=r.filterByKey;exports.full=r.full;exports.RaphDerivedHandle=t.RaphDerivedHandle;exports.RaphDerivedTargetWriteError=t.RaphDerivedTargetWriteError;exports.RaphKernel=h.RaphKernel;exports.RaphMeta=u.RaphMeta;exports.RaphActionError=a.RaphActionError;exports.RaphCrossRuntimeError=a.RaphCrossRuntimeError;exports.RaphDisposedError=a.RaphDisposedError;exports.parentGraph=i.parentGraph;exports.PathHandle=n.PathHandle;exports.RaphSchedulerType=R.RaphSchedulerType;exports.RaphNode=d.RaphNode;exports.RaphRuntime=_.RaphRuntime;exports.RaphScope=s.RaphScope;exports.RaphConfigurationError=e.RaphConfigurationError;exports.RaphDefaultRuntimeError=e.RaphDefaultRuntimeError;exports.RaphError=e.RaphError;exports.RaphModeError=e.RaphModeError;exports.Raph=c.Raph;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./debug/api/errors.cjs"),p=require("./debug/api/Raph.cjs"),i=require("./debug/api/RaphReactivityInstance.cjs"),r=require("./debug/runtime/errors.cjs"),o=require("./debug/runtime/ownership/parentGraph.cjs"),h=require("./debug/runtime/ownership/RaphEffectScope.cjs"),n=require("./debug/runtime/ownership/RaphNode.cjs"),s=require("./debug/runtime/ownership/RaphScope.cjs"),u=require("./debug/runtime/phases/orderPhaseTasks.cjs"),R=require("./debug/runtime/phases/phase.types.cjs"),d=require("./debug/runtime/RaphRuntime.cjs"),c=require("./debug/runtime/reactivity/PathHandle.cjs"),_=require("./debug/path/DataPath.cjs"),a=require("./debug/path/derived/derived-strategy.utils.cjs"),t=require("./debug/path/derived/RaphDerivedHandle.cjs"),l=require("./debug/path/meta/RaphMeta.cjs"),g=require("./debug/path/RaphKernel.cjs"),E=require("./debug/path/storage/DefaultDataAdapter.cjs");exports.RaphCapabilityError=e.RaphCapabilityError;exports.RaphConfigurationError=e.RaphConfigurationError;exports.RaphDefaultInstanceError=e.RaphDefaultInstanceError;exports.RaphError=e.RaphError;exports.RaphFacadeDisposedError=e.RaphFacadeDisposedError;exports.Raph=p.Raph;exports.RaphReactivityInstance=i.RaphReactivityInstance;exports.RaphActionError=r.RaphActionError;exports.RaphCrossRuntimeError=r.RaphCrossRuntimeError;exports.RaphDisposedError=r.RaphDisposedError;exports.RaphPhaseProcessError=r.RaphPhaseProcessError;exports.parentGraph=o.parentGraph;exports.RaphEffectScope=h.RaphEffectScope;exports.RaphNode=n.RaphNode;exports.RaphScope=s.RaphScope;exports.orderPhaseTasks=u.orderPhaseTasks;exports.RaphSchedulerType=R.RaphSchedulerType;exports.RaphRuntime=d.RaphRuntime;exports.PathHandle=c.PathHandle;exports.DataPath=_.DataPath;exports.collectionByKey=a.collectionByKey;exports.filterByKey=a.filterByKey;exports.full=a.full;exports.RaphDerivedHandle=t.RaphDerivedHandle;exports.RaphDerivedTargetWriteError=t.RaphDerivedTargetWriteError;exports.RaphMeta=l.RaphMeta;exports.RaphKernel=g.RaphKernel;exports.DefaultDataAdapter=E.DefaultDataAdapter;
package/dist/index.js CHANGED
@@ -1,40 +1,48 @@
1
- import { DefaultDataAdapter as e } from "./debug/path/data-adapter.js";
2
- import { DataPath as t } from "./debug/path/data-path.js";
3
- import { collectionByKey as f, filterByKey as h, full as R } from "./debug/path/derived-strategies.js";
4
- import { RaphDerivedHandle as x, RaphDerivedTargetWriteError as i } from "./debug/path/RaphDerivedHandle.js";
5
- import { RaphKernel as n } from "./debug/path/RaphKernel.js";
6
- import { RaphMeta as u } from "./debug/path/RaphMeta.js";
7
- import { RaphActionError as D, RaphCrossRuntimeError as c, RaphDisposedError as y } from "./debug/runtime/errors.js";
8
- import { parentGraph as K } from "./debug/runtime/parent-graph.js";
9
- import { PathHandle as v } from "./debug/runtime/PathHandle.js";
10
- import { RaphSchedulerType as B } from "./debug/runtime/phase.types.js";
11
- import { RaphNode as H } from "./debug/runtime/RaphNode.js";
12
- import { RaphRuntime as P } from "./debug/runtime/RaphRuntime.js";
13
- import { RaphScope as T } from "./debug/runtime/RaphScope.js";
14
- import { RaphConfigurationError as N, RaphDefaultRuntimeError as W, RaphError as b, RaphModeError as j } from "./debug/api/errors.js";
15
- import { Raph as q } from "./debug/api/Raph.js";
1
+ import { RaphCapabilityError as e, RaphConfigurationError as p, RaphDefaultInstanceError as a, RaphError as t, RaphFacadeDisposedError as h } from "./debug/api/errors.js";
2
+ import { Raph as R } from "./debug/api/Raph.js";
3
+ import { RaphReactivityInstance as x } from "./debug/api/RaphReactivityInstance.js";
4
+ import { RaphActionError as n, RaphCrossRuntimeError as s, RaphDisposedError as c, RaphPhaseProcessError as l } from "./debug/runtime/errors.js";
5
+ import { parentGraph as E } from "./debug/runtime/ownership/parentGraph.js";
6
+ import { RaphEffectScope as u } from "./debug/runtime/ownership/RaphEffectScope.js";
7
+ import { RaphNode as P } from "./debug/runtime/ownership/RaphNode.js";
8
+ import { RaphScope as C } from "./debug/runtime/ownership/RaphScope.js";
9
+ import { orderPhaseTasks as S } from "./debug/runtime/phases/orderPhaseTasks.js";
10
+ import { RaphSchedulerType as g } from "./debug/runtime/phases/phase.types.js";
11
+ import { RaphRuntime as B } from "./debug/runtime/RaphRuntime.js";
12
+ import { PathHandle as I } from "./debug/runtime/reactivity/PathHandle.js";
13
+ import { DataPath as k } from "./debug/path/DataPath.js";
14
+ import { collectionByKey as G, filterByKey as M, full as N } from "./debug/path/derived/derived-strategy.utils.js";
15
+ import { RaphDerivedHandle as j, RaphDerivedTargetWriteError as q } from "./debug/path/derived/RaphDerivedHandle.js";
16
+ import { RaphMeta as z } from "./debug/path/meta/RaphMeta.js";
17
+ import { RaphKernel as L } from "./debug/path/RaphKernel.js";
18
+ import { DefaultDataAdapter as Q } from "./debug/path/storage/DefaultDataAdapter.js";
16
19
  export {
17
- t as DataPath,
18
- e as DefaultDataAdapter,
19
- v as PathHandle,
20
- q as Raph,
21
- D as RaphActionError,
22
- N as RaphConfigurationError,
23
- c as RaphCrossRuntimeError,
24
- W as RaphDefaultRuntimeError,
25
- x as RaphDerivedHandle,
26
- i as RaphDerivedTargetWriteError,
27
- y as RaphDisposedError,
28
- b as RaphError,
29
- n as RaphKernel,
30
- u as RaphMeta,
31
- j as RaphModeError,
32
- H as RaphNode,
33
- P as RaphRuntime,
34
- B as RaphSchedulerType,
35
- T as RaphScope,
36
- f as collectionByKey,
37
- h as filterByKey,
38
- R as full,
39
- K as parentGraph
20
+ k as DataPath,
21
+ Q as DefaultDataAdapter,
22
+ I as PathHandle,
23
+ R as Raph,
24
+ n as RaphActionError,
25
+ e as RaphCapabilityError,
26
+ p as RaphConfigurationError,
27
+ s as RaphCrossRuntimeError,
28
+ a as RaphDefaultInstanceError,
29
+ j as RaphDerivedHandle,
30
+ q as RaphDerivedTargetWriteError,
31
+ c as RaphDisposedError,
32
+ u as RaphEffectScope,
33
+ t as RaphError,
34
+ h as RaphFacadeDisposedError,
35
+ L as RaphKernel,
36
+ z as RaphMeta,
37
+ P as RaphNode,
38
+ l as RaphPhaseProcessError,
39
+ x as RaphReactivityInstance,
40
+ B as RaphRuntime,
41
+ g as RaphSchedulerType,
42
+ C as RaphScope,
43
+ G as collectionByKey,
44
+ M as filterByKey,
45
+ N as full,
46
+ S as orderPhaseTasks,
47
+ E as parentGraph
40
48
  };
@@ -0,0 +1,71 @@
1
+ import { MachineConfig, MachineEvent, MachineGuardRef, MachineInvokeConfig, MachineMigration, MachineModel, MachineOutputRef, MachineReducerRef } from './types';
2
+ export type CompiledStateKind = 'atomic' | 'compound' | 'final' | 'history' | 'parallel';
3
+ export interface CompiledTransition {
4
+ readonly emit: readonly MachineOutputRef<unknown, MachineEvent, unknown>[];
5
+ readonly guard?: MachineGuardRef<unknown, MachineEvent, unknown>;
6
+ readonly index: number;
7
+ readonly raise?: MachineEvent | ((args: {
8
+ readonly context: Readonly<unknown>;
9
+ readonly event: MachineEvent;
10
+ readonly input: unknown;
11
+ }) => MachineEvent);
12
+ readonly reason?: string;
13
+ readonly reduce: readonly MachineReducerRef<unknown, MachineEvent, unknown>[];
14
+ readonly reenter: boolean;
15
+ readonly source: number;
16
+ readonly target?: number;
17
+ }
18
+ export interface CompiledInvoke {
19
+ readonly id: string;
20
+ readonly input?: MachineInvokeConfig<unknown, MachineEvent, unknown>['input'];
21
+ readonly onDone: readonly CompiledTransition[];
22
+ readonly onError: readonly CompiledTransition[];
23
+ readonly src: MachineInvokeConfig<unknown, MachineEvent, unknown>['src'];
24
+ readonly type: 'machine' | 'task';
25
+ }
26
+ export interface CompiledState {
27
+ readonly after: ReadonlyMap<string, readonly CompiledTransition[]>;
28
+ readonly always: readonly CompiledTransition[];
29
+ readonly children: readonly number[];
30
+ readonly depth: number;
31
+ readonly entry: readonly MachineOutputRef<unknown, MachineEvent, unknown>[];
32
+ readonly exit: readonly MachineOutputRef<unknown, MachineEvent, unknown>[];
33
+ readonly history: 'deep' | 'shallow';
34
+ readonly historyFallback?: number;
35
+ readonly id: number;
36
+ readonly initial?: number;
37
+ readonly invokes: readonly CompiledInvoke[];
38
+ readonly key: string;
39
+ readonly kind: CompiledStateKind;
40
+ readonly meta?: Readonly<Record<string, unknown>>;
41
+ readonly on: ReadonlyMap<string, readonly CompiledTransition[]>;
42
+ readonly onDone: readonly CompiledTransition[];
43
+ readonly output?: unknown | ((args: {
44
+ readonly context: Readonly<unknown>;
45
+ readonly event: MachineEvent;
46
+ readonly input: unknown;
47
+ }) => unknown);
48
+ readonly parent?: number;
49
+ readonly path: string;
50
+ readonly resources: readonly string[];
51
+ readonly tags: readonly string[];
52
+ }
53
+ export interface CompiledMachine {
54
+ readonly ancestry: readonly (readonly number[])[];
55
+ readonly context: MachineConfig<unknown, MachineEvent, unknown, unknown>['context'];
56
+ readonly eventIndexes: ReadonlyMap<string, number>;
57
+ readonly eventTypes: readonly string[];
58
+ readonly flat: boolean;
59
+ readonly flatDispatch?: readonly (readonly CompiledTransition[] | undefined)[];
60
+ readonly id: string;
61
+ readonly initial: number;
62
+ readonly migrations: ReadonlyMap<number, MachineMigration>;
63
+ readonly output?: MachineConfig<unknown, MachineEvent, unknown, unknown>['output'];
64
+ readonly pathToState: ReadonlyMap<string, number>;
65
+ readonly rootChildren: readonly number[];
66
+ readonly states: readonly CompiledState[];
67
+ readonly version: number;
68
+ }
69
+ export declare function defineMachine<Context, Event extends MachineEvent, Input = void, Output = unknown>(config: MachineConfig<Context, Event, Input, Output>): MachineModel<Context, Event, Input, Output>;
70
+ /** @internal */
71
+ export declare function getCompiledMachine(model: MachineModel<unknown, MachineEvent, unknown, unknown>): CompiledMachine;
@@ -0,0 +1,50 @@
1
+ import { CompiledMachine, CompiledTransition } from './compiler';
2
+ import { MachineBindings, MachineEvent, MachineModel, MachineOutputRef, MachineSnapshot, PersistedMachineSnapshot } from './types';
3
+ export interface MachineEvaluationHooks {
4
+ readonly guard?: (name: string, passed: boolean, context: Readonly<Record<string, unknown>> | undefined) => void;
5
+ readonly transition?: (details: {
6
+ readonly reason?: string;
7
+ readonly source: string;
8
+ readonly target?: string;
9
+ }) => void;
10
+ }
11
+ export interface MachineEffectPlan {
12
+ readonly entered: readonly number[];
13
+ readonly entryOutputs: readonly PlannedOutput[];
14
+ readonly event: MachineEvent;
15
+ readonly exited: readonly number[];
16
+ readonly exitOutputs: readonly PlannedOutput[];
17
+ readonly transitionOutputRefs?: readonly MachineOutputRef<unknown, MachineEvent, unknown>[];
18
+ readonly transitionOutputs: readonly PlannedOutput[];
19
+ }
20
+ export interface PlannedOutput {
21
+ readonly event: MachineEvent;
22
+ readonly ref: MachineOutputRef<unknown, MachineEvent, unknown>;
23
+ }
24
+ export interface MachineMacrostepResult<Context, Output> {
25
+ readonly changed: boolean;
26
+ readonly plan: MachineEffectPlan;
27
+ readonly snapshot: MachineSnapshot<Context, Output>;
28
+ }
29
+ export declare function getInitialSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, input?: Input): MachineSnapshot<Context, Output>;
30
+ export declare function transition<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>, event: Event, bindings?: MachineBindings<Context, Event, Input>, hooks?: MachineEvaluationHooks): MachineSnapshot<Context, Output>;
31
+ /** @internal */
32
+ export declare function assertMachineSnapshot(model: MachineModel<unknown, MachineEvent, unknown, unknown>, snapshot: MachineSnapshot<unknown>): void;
33
+ /** Creates a terminal snapshot while retaining model/input provenance. @internal */
34
+ export declare function stopMachineSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>): MachineSnapshot<Context, Output>;
35
+ /** @internal */
36
+ export declare function createInitialSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, input: Input, bindings: MachineBindings<Context, Event, Input> | undefined, hooks?: MachineEvaluationHooks): MachineMacrostepResult<Context, Output>;
37
+ /** @internal */
38
+ export declare function runMacrostep<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>, event: Event, bindings: MachineBindings<Context, Event, Input> | undefined, input: Input, hooks?: MachineEvaluationHooks, compiledInput?: CompiledMachine, stabilizeOnly?: boolean, initialRaised?: readonly MachineEvent[]): MachineMacrostepResult<Context, Output>;
39
+ /**
40
+ * Выполняет macrostep после проверки события владеющим Runtime.
41
+ *
42
+ * @internal
43
+ */
44
+ export declare function runValidatedMacrostep<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>, event: Event, bindings: MachineBindings<Context, Event, Input> | undefined, input: Input, hooks?: MachineEvaluationHooks, compiledInput?: CompiledMachine, flatEventId?: number, stabilizeOnly?: boolean, initialRaised?: readonly MachineEvent[]): MachineMacrostepResult<Context, Output>;
45
+ /** @internal */
46
+ export declare function runExplicitTransitions<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>, event: Event, transitions: readonly CompiledTransition[], bindings: MachineBindings<Context, Event, Input> | undefined, input: Input, hooks?: MachineEvaluationHooks): MachineMacrostepResult<Context, Output>;
47
+ /** Создаёт validated immutable live snapshot без повторения entry outputs. @internal */
48
+ export declare function hydrateSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, persisted: PersistedMachineSnapshot<Context, Output>, input: Input): MachineSnapshot<Context, Output>;
49
+ /** @internal */
50
+ export declare function canHandleEvent(compiled: CompiledMachine, active: readonly string[], eventType: string): boolean;
@@ -0,0 +1,5 @@
1
+ import { MachineEvent, MachineModel, MachineSnapshot, PersistedMachineSnapshot } from './types';
2
+ export declare class MachinePersistenceError extends Error {
3
+ }
4
+ export declare function persistMachineSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, snapshot: MachineSnapshot<Context, Output>): PersistedMachineSnapshot<Context, Output>;
5
+ export declare function restoreMachineSnapshot<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, persisted: PersistedMachineSnapshot<unknown, unknown>, input?: Input): MachineSnapshot<Context, Output>;
@@ -0,0 +1,4 @@
1
+ import { RaphNode } from '../runtime/ownership/RaphNode';
2
+ import { CreateMachineOptions, MachineBindings, MachineEvent, MachineInstance, MachineModel } from './types';
3
+ import { RaphScope } from '../runtime/ownership/RaphScope';
4
+ export declare function createMachine<Context, Event extends MachineEvent, Input = void, Output = unknown>(owner: RaphNode | RaphScope, model: MachineModel<Context, Event, Input, Output>, bindings?: MachineBindings<Context, Event, Input>, options?: CreateMachineOptions<Context, Input, Output>): MachineInstance<Context, Event, Input, Output>;
@@ -0,0 +1,43 @@
1
+ import { MachineBindings, MachineClock, MachineEvent, MachineModel, MachineSnapshot } from './types';
2
+ export interface MachineInspection {
3
+ readonly deadEnds: readonly string[];
4
+ readonly inconsistencies: readonly string[];
5
+ readonly reachable: readonly string[];
6
+ readonly unreachable: readonly string[];
7
+ readonly valid: boolean;
8
+ }
9
+ export interface EnumeratedMachinePath<Context, Output> {
10
+ readonly events: readonly MachineEvent[];
11
+ readonly snapshot: MachineSnapshot<Context, Output>;
12
+ }
13
+ export interface EnumerateMachinePathOptions<Context, Event extends MachineEvent, Input> {
14
+ readonly bindings?: MachineBindings<Context, Event, Input>;
15
+ readonly events?: readonly Event[];
16
+ readonly input?: Input;
17
+ readonly maxDepth?: number;
18
+ readonly maxPaths?: number;
19
+ }
20
+ export interface MachineCoverageReport {
21
+ readonly guards: Readonly<Record<string, Readonly<{
22
+ failed: number;
23
+ passed: number;
24
+ }>>>;
25
+ readonly states: Readonly<Record<string, number>>;
26
+ readonly transitions: Readonly<Record<string, number>>;
27
+ }
28
+ export interface MachineCoverage {
29
+ guard: (name: string, passed: boolean) => void;
30
+ record: <Context, Output>(before: MachineSnapshot<Context, Output>, event: MachineEvent, after: MachineSnapshot<Context, Output>) => void;
31
+ report: () => MachineCoverageReport;
32
+ reset: () => void;
33
+ transition: <Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, before: MachineSnapshot<Context, Output>, event: Event, bindings?: MachineBindings<Context, Event, Input>) => MachineSnapshot<Context, Output>;
34
+ }
35
+ export interface ManualMachineClock extends MachineClock {
36
+ readonly pending: number;
37
+ advance: (duration: number) => void;
38
+ runAll: () => void;
39
+ }
40
+ export declare function inspectMachine<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>): MachineInspection;
41
+ export declare function enumerateMachinePaths<Context, Event extends MachineEvent, Input, Output>(model: MachineModel<Context, Event, Input, Output>, options?: EnumerateMachinePathOptions<Context, Event, Input>): readonly EnumeratedMachinePath<Context, Output>[];
42
+ export declare function createMachineCoverage(): MachineCoverage;
43
+ export declare function createManualMachineClock(initialNow?: number): ManualMachineClock;
@@ -0,0 +1,155 @@
1
+ import { Disposer, ReadonlySignal } from '../reactivity/types';
2
+ import { RaphNode } from '../runtime/ownership/RaphNode';
3
+ import { RaphScope } from '../runtime/ownership/RaphScope';
4
+ export interface MachineEvent {
5
+ readonly type: string;
6
+ }
7
+ export type MachineStatus = 'active' | 'done' | 'stopped';
8
+ export type MachineEventStatus = 'ignored' | 'queued' | 'transitioned';
9
+ export interface MachineSnapshot<Context, Output = unknown> {
10
+ readonly active: readonly string[];
11
+ readonly context: Readonly<Context>;
12
+ readonly history: Readonly<Record<string, readonly string[]>>;
13
+ readonly output?: Output;
14
+ readonly revision: number;
15
+ readonly status: MachineStatus;
16
+ }
17
+ export interface MachineGuardArgs<Context, Event extends MachineEvent, Input> {
18
+ readonly context: Readonly<Context>;
19
+ readonly event: Event;
20
+ readonly input: Input;
21
+ }
22
+ export interface MachineReducerArgs<Context, Event extends MachineEvent, Input> extends MachineGuardArgs<Context, Event, Input> {
23
+ }
24
+ export interface MachineOutputArgs<Context, Event extends MachineEvent, Input> extends MachineGuardArgs<Context, Event, Input> {
25
+ readonly snapshot: MachineSnapshot<Context>;
26
+ }
27
+ export type MachineGuard<Context, Event extends MachineEvent, Input> = (args: MachineGuardArgs<Context, Event, Input>) => boolean;
28
+ export type MachineReducer<Context, Event extends MachineEvent, Input> = (args: MachineReducerArgs<Context, Event, Input>) => Context;
29
+ export type MachineOutput<Context, Event extends MachineEvent, Input> = (args: MachineOutputArgs<Context, Event, Input>) => void;
30
+ export type MachineGuardRef<Context, Event extends MachineEvent, Input> = MachineGuard<Context, Event, Input> | string;
31
+ export type MachineReducerRef<Context, Event extends MachineEvent, Input> = MachineReducer<Context, Event, Input> | string;
32
+ export type MachineOutputRef<Context, Event extends MachineEvent, Input> = MachineOutput<Context, Event, Input> | string;
33
+ export interface MachineTransitionConfig<Context, Event extends MachineEvent, Input> {
34
+ readonly emit?: MachineOutputRef<Context, Event, Input> | readonly MachineOutputRef<Context, Event, Input>[];
35
+ readonly guard?: MachineGuardRef<Context, Event, Input>;
36
+ readonly raise?: Event | ((args: MachineReducerArgs<Context, Event, Input>) => Event);
37
+ readonly reason?: string;
38
+ readonly reduce?: MachineReducerRef<Context, Event, Input> | readonly MachineReducerRef<Context, Event, Input>[];
39
+ readonly reenter?: boolean;
40
+ readonly target?: string;
41
+ }
42
+ export type MachineTransitionDefinition<Context, Event extends MachineEvent, Input> = MachineTransitionConfig<Context, Event, Input> | readonly MachineTransitionConfig<Context, Event, Input>[] | string;
43
+ export interface MachineInvokeConfig<Context, Event extends MachineEvent, Input> {
44
+ readonly id?: string;
45
+ readonly input?: unknown | ((args: MachineGuardArgs<Context, Event, Input>) => unknown);
46
+ readonly onDone?: MachineTransitionDefinition<Context, Event, Input>;
47
+ readonly onError?: MachineTransitionDefinition<Context, Event, Input>;
48
+ readonly src: string | MachineModel<unknown, MachineEvent, unknown, unknown>;
49
+ readonly type?: 'machine' | 'task';
50
+ }
51
+ export interface MachineStateConfig<Context, Event extends MachineEvent, Input, Output> {
52
+ readonly after?: Readonly<Record<string, MachineTransitionDefinition<Context, Event, Input>>>;
53
+ readonly always?: MachineTransitionDefinition<Context, Event, Input>;
54
+ readonly entry?: MachineOutputRef<Context, Event, Input> | readonly MachineOutputRef<Context, Event, Input>[];
55
+ readonly exit?: MachineOutputRef<Context, Event, Input> | readonly MachineOutputRef<Context, Event, Input>[];
56
+ readonly history?: 'deep' | 'shallow';
57
+ readonly initial?: string;
58
+ readonly invoke?: MachineInvokeConfig<Context, Event, Input> | readonly MachineInvokeConfig<Context, Event, Input>[];
59
+ readonly meta?: Readonly<Record<string, unknown>>;
60
+ readonly on?: Readonly<Partial<Record<Event['type'], MachineTransitionDefinition<Context, Event, Input>>>> | Readonly<Record<string, MachineTransitionDefinition<Context, Event, Input>>>;
61
+ readonly onDone?: MachineTransitionDefinition<Context, Event, Input>;
62
+ readonly output?: Output | ((args: MachineGuardArgs<Context, Event, Input>) => Output);
63
+ readonly resources?: string | readonly string[];
64
+ readonly states?: Readonly<Record<string, MachineStateConfig<Context, Event, Input, Output>>>;
65
+ readonly tags?: string | readonly string[];
66
+ readonly target?: string;
67
+ readonly type?: 'atomic' | 'compound' | 'final' | 'history' | 'parallel';
68
+ }
69
+ export interface PersistedMachineSnapshot<Context = unknown, Output = unknown> {
70
+ readonly active: readonly string[];
71
+ readonly context: Context;
72
+ readonly history: Readonly<Record<string, readonly string[]>>;
73
+ readonly modelId: string;
74
+ readonly output?: Output;
75
+ readonly revision: number;
76
+ readonly status: MachineStatus;
77
+ readonly version: number;
78
+ }
79
+ export type MachineMigration = (snapshot: PersistedMachineSnapshot) => PersistedMachineSnapshot;
80
+ export interface MachineConfig<Context, Event extends MachineEvent, Input, Output> {
81
+ readonly context: Context | ((input: Input) => Context);
82
+ readonly id: string;
83
+ readonly initial: string;
84
+ readonly migrations?: Readonly<Record<number, MachineMigration>>;
85
+ readonly output?: Output | ((args: MachineGuardArgs<Context, Event, Input>) => Output);
86
+ readonly states: Readonly<Record<string, MachineStateConfig<Context, Event, Input, Output>>>;
87
+ readonly version?: number;
88
+ }
89
+ declare const MACHINE_MODEL_TYPES: unique symbol;
90
+ export interface MachineModel<Context, Event extends MachineEvent, Input, Output> {
91
+ readonly id: string;
92
+ readonly version: number;
93
+ readonly [MACHINE_MODEL_TYPES]?: {
94
+ readonly context: Context;
95
+ readonly event: Event;
96
+ readonly input: Input;
97
+ readonly output: Output;
98
+ };
99
+ }
100
+ export interface MachineClock {
101
+ clearTimeout: (handle: unknown) => void;
102
+ now: () => number;
103
+ setTimeout: (callback: () => void, delay: number) => unknown;
104
+ }
105
+ export interface MachineTaskArgs<Context, Event extends MachineEvent, Input> extends MachineGuardArgs<Context, Event, Input> {
106
+ readonly send: (event: Event) => void;
107
+ readonly signal: AbortSignal;
108
+ }
109
+ export type MachineTask<Context, Event extends MachineEvent, Input> = (args: MachineTaskArgs<Context, Event, Input>) => unknown | Promise<unknown>;
110
+ export interface MachineResourceArgs<Context, Event extends MachineEvent, Input> extends MachineOutputArgs<Context, Event, Input> {
111
+ readonly owner: RaphNode | RaphScope;
112
+ readonly signal: AbortSignal;
113
+ }
114
+ export type MachineResource<Context, Event extends MachineEvent, Input> = (args: MachineResourceArgs<Context, Event, Input>) => void | Disposer;
115
+ export interface MachineBindings<Context, Event extends MachineEvent, Input> {
116
+ readonly actors?: Readonly<Record<string, MachineModel<unknown, MachineEvent, unknown, unknown>>>;
117
+ readonly delays?: Readonly<Record<string, number | ((args: MachineGuardArgs<Context, Event, Input>) => number)>>;
118
+ readonly guards?: Readonly<Record<string, MachineGuard<Context, Event, Input>>>;
119
+ readonly outputs?: Readonly<Record<string, MachineOutput<Context, Event, Input>>>;
120
+ readonly reducers?: Readonly<Record<string, MachineReducer<Context, Event, Input>>>;
121
+ readonly resources?: Readonly<Record<string, MachineResource<Context, Event, Input>>>;
122
+ readonly tasks?: Readonly<Record<string, MachineTask<Context, Event, Input>>>;
123
+ }
124
+ export interface CreateMachineOptions<Context, Input, Output> {
125
+ readonly clock?: MachineClock;
126
+ readonly errorPolicy?: 'ignore' | 'stop' | 'throw';
127
+ readonly id?: string;
128
+ readonly input?: Input;
129
+ readonly parentId?: string;
130
+ readonly persisted?: PersistedMachineSnapshot<Context, Output>;
131
+ }
132
+ export interface MachineSendResult<Context, Output> {
133
+ readonly snapshot: MachineSnapshot<Context, Output>;
134
+ readonly status: MachineEventStatus;
135
+ }
136
+ export interface MachineActorRef<Event extends MachineEvent = MachineEvent> {
137
+ readonly id: string;
138
+ send: (event: Event) => MachineSendResult<unknown, unknown>;
139
+ stop: () => void;
140
+ }
141
+ export interface MachineInstance<Context, Event extends MachineEvent, Input, Output> {
142
+ readonly id: string;
143
+ readonly model: MachineModel<Context, Event, Input, Output>;
144
+ readonly snapshot: ReadonlySignal<MachineSnapshot<Context, Output>>;
145
+ readonly started: boolean;
146
+ hasTag: (tag: string) => boolean;
147
+ matches: (path: string) => boolean;
148
+ persist: () => PersistedMachineSnapshot<Context, Output>;
149
+ send: (event: Event) => MachineSendResult<Context, Output>;
150
+ sendTo: (actorId: string, event: MachineEvent) => MachineSendResult<unknown, unknown>;
151
+ start: () => MachineInstance<Context, Event, Input, Output>;
152
+ stop: () => void;
153
+ subscribe: (listener: (snapshot: MachineSnapshot<Context, Output>) => void) => Disposer;
154
+ }
155
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./core-cPQWYD4K.cjs");function y(n){const i=h.getCompiledMachine(n),c=M(i),a=i.states.filter(t=>t.kind!=="history"&&!c.has(t.id)).map(t=>t.path),o=i.states.filter(t=>t.kind==="atomic"&&t.on.size===0&&t.always.length===0&&t.after.size===0&&t.invokes.length===0).map(t=>t.path),r=[];for(const t of i.states)t.kind==="parallel"&&t.children.length===0&&r.push(`Parallel state "${t.path}" has no regions.`),t.kind==="compound"&&t.initial===void 0&&r.push(`Compound state "${t.path}" has no initial child.`);return Object.freeze({deadEnds:Object.freeze(o),inconsistencies:Object.freeze(r),reachable:Object.freeze([...c].map(t=>i.states[t].path)),unreachable:Object.freeze(a),valid:r.length===0})}function k(n,i={}){const c=h.getCompiledMachine(n),a=i.maxDepth??12,o=i.maxPaths??1e3;j(a,"maxDepth"),j(o,"maxPaths");const r=i.events??c.eventTypes.map(l=>({type:l})),t=h.getInitialSnapshot(n,i.input),s=[{events:Object.freeze([]),snapshot:t}],e=[s[0]],f=new Set([b(t)]);let u=0;for(;u<e.length&&s.length<o;){const l=e[u++];if(!(l.events.length>=a||l.snapshot.status!=="active"))for(const m of r){const p=h.transition(n,l.snapshot,m,i.bindings);if(p===l.snapshot)continue;const g=b(p);if(f.has(g))continue;f.add(g);const v=Object.freeze({events:Object.freeze([...l.events,m]),snapshot:p});if(s.push(v),e.push(v),s.length>=o)break}}return Object.freeze(s)}function w(){const n=new Map,i=new Map,c=new Map;return{guard:(a,o)=>{const r=c.get(a)??{failed:0,passed:0};o?r.passed++:r.failed++,c.set(a,r)},record:(a,o,r)=>{for(const t of r.active)n.set(t,(n.get(t)??0)+1);if(a!==r){const t=`${a.active.join("|")} --${o.type}--> ${r.active.join("|")}`;i.set(t,(i.get(t)??0)+1)}},report:()=>Object.freeze({guards:Object.freeze(Object.fromEntries([...c].map(([a,o])=>[a,Object.freeze({...o})]))),states:Object.freeze(Object.fromEntries(n)),transitions:Object.freeze(Object.fromEntries(i))}),reset:()=>{n.clear(),i.clear(),c.clear()},transition:(a,o,r,t)=>{const s=h.transition(a,o,r,t,{guard:(e,f)=>{const u=c.get(e)??{failed:0,passed:0};f?u.passed++:u.failed++,c.set(e,u)}});for(const e of s.active)n.set(e,(n.get(e)??0)+1);if(o!==s){const e=`${o.active.join("|")} --${r.type}--> ${s.active.join("|")}`;i.set(e,(i.get(e)??0)+1)}return s}}}function O(n=0){if(!Number.isFinite(n))throw new TypeError("[Raph machine] Manual clock initial time must be finite.");let i=n,c=1;const a=new Map;return{advance:s=>{if(!Number.isFinite(s)||s<0)throw new TypeError("[Raph machine] Clock advance duration must be non-negative and finite.");const e=i+s;r(e),i=e},clearTimeout:s=>{const e=a.get(s);e!==void 0&&(e.active=!1,a.delete(e.id))},now:()=>i,get pending(){return a.size},runAll:()=>{let s=0;for(;a.size!==0;){if(++s>1e5)throw new Error("[Raph machine] Manual clock exceeded 100000 timer turns.");const e=t();if(e===void 0)break;r(e.at),i=e.at}},setTimeout:(s,e)=>{if(!Number.isFinite(e)||e<0)throw new TypeError("[Raph machine] Timer delay must be non-negative and finite.");const f={active:!0,at:i+e,callback:s,id:c++};return a.set(f.id,f),f.id}};function r(s){for(;;){const e=t();if(e===void 0||e.at>s)return;i=e.at,a.delete(e.id),e.active&&(e.active=!1,e.callback())}}function t(){let s;for(const e of a.values())e.active&&(s===void 0||e.at<s.at||e.at===s.at&&e.id<s.id)&&(s=e);return s}}function M(n){const i=new Set,c=new Set,a=[n.initial];let o=0;for(;o<a.length;){const r=a[o++];if(c.has(r))continue;c.add(r);for(const e of n.ancestry[r])c.has(e)||a.push(e),i.add(e);const t=n.states[r];if(t.kind==="history"){if(t.historyFallback!==void 0)a.push(t.historyFallback);else if(t.parent!==void 0){const e=n.states[t.parent];e.initial!==void 0&&a.push(e.initial)}}t.initial!==void 0&&a.push(t.initial),t.kind==="parallel"&&a.push(...t.children.filter(e=>n.states[e].kind!=="history"));const s=[t.always,t.onDone,...t.on.values(),...t.after.values()];for(const e of t.invokes)s.push(e.onDone,e.onError);for(const e of s)for(const f of e)f.target!==void 0&&a.push(f.target)}return i}function b(n){return[n.status,n.active.join("|"),d(n.context),d(n.history),d(n.output)].join(":")}function d(n){return n===null||typeof n!="object"?JSON.stringify(n):Array.isArray(n)?`[${n.map(d).join(",")}]`:`{${Object.keys(n).sort().map(i=>`${JSON.stringify(i)}:${d(n[i])}`).join(",")}}`}function j(n,i){if(!Number.isSafeInteger(n)||n<=0)throw new TypeError(`[Raph machine] ${i} must be a positive safe integer.`)}exports.createMachineCoverage=w;exports.createManualMachineClock=O;exports.enumerateMachinePaths=k;exports.inspectMachine=y;