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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +1096 -0
  2. package/dist/api/Raph.d.ts +59 -190
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +9 -4
  6. package/dist/api/types.d.ts +162 -17
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -366
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -0
  15. package/dist/debug/api/errors.cjs +1 -1
  16. package/dist/debug/api/errors.js +10 -7
  17. package/dist/debug/path/DataPath.cjs +1 -0
  18. package/dist/debug/path/{data-path.js → DataPath.js} +151 -180
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +258 -207
  23. package/dist/debug/path/data-path.utils.cjs +1 -0
  24. package/dist/debug/path/data-path.utils.js +56 -0
  25. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  26. package/dist/debug/path/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
  27. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  28. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
  29. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  30. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  31. package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
  32. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
  33. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  34. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
  35. package/dist/debug/path/meta/meta.types.cjs +1 -0
  36. package/dist/debug/path/meta/meta.types.js +1 -0
  37. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  38. package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
  39. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  40. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
  41. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  42. package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
  43. package/dist/debug/path/storage/PathStore.cjs +1 -0
  44. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
  45. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  46. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  47. package/dist/debug/reactivity/engine.cjs +1 -1
  48. package/dist/debug/reactivity/engine.js +478 -306
  49. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  50. package/dist/debug/reactivity/reactive-object.js +280 -0
  51. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  52. package/dist/debug/runtime/RaphRuntime.js +798 -519
  53. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  54. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  55. package/dist/debug/runtime/errors.cjs +1 -1
  56. package/dist/debug/runtime/errors.js +6 -3
  57. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  58. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  59. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  60. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  61. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  62. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  63. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  64. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  65. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  67. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  68. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  69. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  70. package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
  71. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  79. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  81. package/dist/entrypoints/machine-testing.d.ts +2 -0
  82. package/dist/entrypoints/machine.d.ts +5 -0
  83. package/dist/entrypoints/path.d.ts +14 -0
  84. package/dist/entrypoints/reactivity.d.ts +1 -0
  85. package/dist/entrypoints/runtime.d.ts +17 -0
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +46 -38
  88. package/dist/machine/compiler.d.ts +71 -0
  89. package/dist/machine/core.d.ts +50 -0
  90. package/dist/machine/persistence.d.ts +5 -0
  91. package/dist/machine/runtime.d.ts +4 -0
  92. package/dist/machine/testing.d.ts +43 -0
  93. package/dist/machine/types.d.ts +155 -0
  94. package/dist/machine-testing.cjs +1 -0
  95. package/dist/machine-testing.js +188 -0
  96. package/dist/machine.cjs +1 -0
  97. package/dist/machine.js +837 -0
  98. package/dist/main.d.ts +20 -0
  99. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  100. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  101. package/dist/path/RaphKernel.d.ts +13 -10
  102. package/dist/path/data-path.types.d.ts +34 -0
  103. package/dist/path/data-path.utils.d.ts +9 -0
  104. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  105. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  106. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  107. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  108. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  109. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  110. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  111. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  112. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  113. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  114. package/dist/path/path.types.d.ts +3 -2
  115. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  116. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  117. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  118. package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
  119. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
  120. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  121. package/dist/path.cjs +1 -1
  122. package/dist/path.js +16 -16
  123. package/dist/raph.cjs +1 -1
  124. package/dist/raph.js +46 -38
  125. package/dist/reactivity/engine.d.ts +17 -3
  126. package/dist/reactivity/reactive-object.d.ts +36 -0
  127. package/dist/reactivity/types.d.ts +25 -0
  128. package/dist/reactivity.cjs +1 -1
  129. package/dist/reactivity.js +12 -12
  130. package/dist/runtime/RaphRuntime.d.ts +132 -192
  131. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  132. package/dist/runtime/errors.d.ts +5 -0
  133. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  134. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  135. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  136. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  137. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  138. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  139. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  140. package/dist/runtime/phases/phase.types.d.ts +92 -0
  141. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  142. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  143. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  144. package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
  145. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
  146. package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
  147. package/dist/runtime.cjs +1 -1
  148. package/dist/runtime.js +21 -16
  149. package/package.json +68 -35
  150. package/ReadMe.md +0 -153
  151. package/dist/api/public.d.ts +0 -22
  152. package/dist/debug/api/public.cjs +0 -1
  153. package/dist/debug/api/public.js +0 -40
  154. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  155. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  156. package/dist/debug/path/PathEventHub.cjs +0 -1
  157. package/dist/debug/path/PathStore.cjs +0 -1
  158. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  159. package/dist/debug/path/data-adapter.cjs +0 -1
  160. package/dist/debug/path/data-path.cjs +0 -1
  161. package/dist/debug/path/derived-collection.cjs +0 -1
  162. package/dist/debug/path/path-router.cjs +0 -1
  163. package/dist/debug/path/public.cjs +0 -1
  164. package/dist/debug/path/public.js +0 -18
  165. package/dist/debug/runtime/PathHandle.cjs +0 -1
  166. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  167. package/dist/debug/runtime/RaphDebug.js +0 -15
  168. package/dist/debug/runtime/RaphNode.cjs +0 -1
  169. package/dist/debug/runtime/RaphNode.js +0 -143
  170. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  171. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  172. package/dist/debug/runtime/RaphScope.cjs +0 -1
  173. package/dist/debug/runtime/RaphScope.js +0 -64
  174. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  175. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  176. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  177. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  178. package/dist/debug/runtime/public.cjs +0 -1
  179. package/dist/debug/runtime/public.js +0 -18
  180. package/dist/path/public.d.ts +0 -14
  181. package/dist/runtime/RaphDebug.d.ts +0 -32
  182. package/dist/runtime/RaphNode.d.ts +0 -68
  183. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  184. package/dist/runtime/RaphScope.d.ts +0 -50
  185. package/dist/runtime/phase.types.d.ts +0 -49
  186. package/dist/runtime/public.d.ts +0 -13
  187. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  188. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  189. /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
  190. /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
  191. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  192. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  193. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  194. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  195. /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
  196. /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
  197. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  198. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  199. /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
  200. /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
  201. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  202. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  203. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  204. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  205. /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
  206. /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
  207. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  208. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  209. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  210. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  211. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -1,285 +1,225 @@
1
- import { DataPathDef, PathEvents, PathOptions } from '../path/path.types';
2
- import { DerivedOptions, RaphDerivedHandle } from '../path/RaphDerivedHandle';
1
+ import { DerivedOptions, RaphDerivedHandle } from '../path/derived/RaphDerivedHandle';
2
+ import { RaphMeta } from '../path/meta/RaphMeta';
3
+ import { DataPathDef, PathOptions } from '../path/path.types';
3
4
  import { RaphKernelRoot, RaphKernel } from '../path/RaphKernel';
4
- import { Disposer, ReadonlySignal, Signal, WatchOptions, WatchSource, WatchValue, WritableComputedOptions } from '../reactivity/types';
5
- import { DepGraph } from './parent-graph';
6
- import { FrameLoopLease, RaphEffectOptions, RaphObserveDataOptions, RaphPhase, RaphSchedulerMode, RaphTrackOptions } from './phase.types';
7
- import { RaphRuntimeDebug } from './RaphDebug';
8
- import { NodeOptions, RaphNode } from './RaphNode';
9
- import { RaphMeta } from '../path/RaphMeta';
10
- import { PathHandle } from './PathHandle';
11
- import { RaphScope } from './RaphScope';
12
- import { RuntimeReactivity } from './RuntimeReactivity';
5
+ import { Disposer, ReadonlySignal, Signal, WritableComputedOptions } from '../reactivity/types';
6
+ import { RaphDebugOptions, RaphMachineDebugRegistration, RaphRuntimeDebug, RaphTraceEventInput, RaphTraceKind } from './diagnostics/RaphDebug';
7
+ import { DepGraph } from './ownership/parent-graph.types';
8
+ import { NodeOptions, RaphNode } from './ownership/RaphNode';
9
+ import { FrameLoopLease, RaphAggregateSource, RaphEffectOptions, RaphPhase, RaphPhaseEffect, RaphSchedulerMode, RaphStructureCause, RaphWatchOptions, RaphWatchSource } from './phases/phase.types';
10
+ import { RaphMetaSourceOptions, RaphMetaSource } from './reactivity/RaphMetaSource';
11
+ import { RaphAggregate, RaphWorkGraph } from './reactivity/RaphWorkGraph';
12
+ import { RaphScope } from './ownership/RaphScope';
13
+ import { PathHandle } from './reactivity/PathHandle';
14
+ import { RuntimeReactivity } from './reactivity/RuntimeReactivity';
13
15
  export interface RaphRuntimeOptions {
16
+ readonly adaptiveDependencyIndex?: boolean;
17
+ readonly debug?: RaphDebugOptions;
14
18
  readonly id?: string;
15
19
  readonly kernel?: RaphKernel;
16
20
  readonly enforceActions?: boolean;
17
21
  readonly scheduler?: RaphSchedulerMode;
18
22
  }
19
23
  export interface RaphRuntimeConfiguration {
24
+ readonly adaptiveDependencyIndex: boolean;
25
+ readonly debug?: RaphDebugOptions;
20
26
  readonly id: string;
21
27
  readonly kernel: RaphKernel;
22
28
  readonly enforceActions: boolean;
23
29
  readonly scheduler: RaphSchedulerMode;
24
30
  }
25
- /**
26
- * Один изолированный signal execution-plane поверх собственного или shared Kernel.
27
- */
31
+ export type RaphRuntimeMeta = Pick<RaphMeta, 'delete' | 'get' | 'has' | 'merge' | 'set'>;
32
+ /** @internal */
33
+ export interface RaphPausableRegistration {
34
+ readonly dispose: Disposer;
35
+ readonly pause: () => void;
36
+ readonly resume: () => void;
37
+ }
38
+ /** Isolated Runtime execution plane with phase-bound work only. */
28
39
  export declare class RaphRuntime {
29
40
  private static _runtimeCounter;
41
+ readonly mode: "runtime";
30
42
  readonly configuration: RaphRuntimeConfiguration;
31
43
  readonly rootScope: RaphScope;
32
44
  readonly root: RaphNode;
45
+ readonly frameTick: ReadonlySignal<number>;
33
46
  private readonly _reactivity;
34
47
  private readonly _signalLifecycle;
48
+ private readonly _workGraph;
49
+ private readonly _frameTickWritable;
50
+ private readonly _setFrameTick;
35
51
  private _pathHandles;
36
52
  private _meta;
37
53
  private _phases;
38
54
  private _frameLoop;
39
- private _frameRevision;
40
- private _frameRevisionValue;
41
55
  private _debug;
56
+ private readonly _debugController;
42
57
  private _parentGraph;
43
58
  private readonly _owners;
44
- private _transactionDepth;
59
+ private _batchDepth;
45
60
  private _mutationDepth;
46
- private _kernelTransactionDepth;
61
+ private _kernelBatchDepth;
62
+ private _ownerDisposalDepth;
47
63
  private _actionDepth;
64
+ private _actionCounter;
65
+ private readonly _traceCauseStack;
66
+ private _phaseTraceOperations;
48
67
  private _executionRequested;
49
68
  private _disposed;
50
69
  private readonly _disposedListeners;
51
- /**
52
- * Создаёт изолированный execution graph поверх собственного или shared Kernel.
53
- */
54
70
  constructor(options?: RaphRuntimeOptions);
55
- /**
56
- * Возвращает внутренний runtime reactivity adapter.
57
- * @internal
58
- */
71
+ /** @internal */
59
72
  _getReactivity(): RuntimeReactivity;
60
73
  /**
61
- * Возвращает стабильный идентификатор runtime.
74
+ * Возвращает внутренний WorkGraph для optional execution layers.
75
+ *
76
+ * @internal
62
77
  */
78
+ _getWorkGraph(): RaphWorkGraph;
63
79
  get id(): string;
64
- /**
65
- * Возвращает data/meta Kernel этого runtime.
66
- */
67
80
  get kernel(): RaphKernel;
68
- /**
69
- * Возвращает лениво созданный runtime-owned metadata facade.
70
- */
71
- get meta(): RaphMeta;
72
- /**
73
- * Показывает, освобождён ли runtime.
74
- */
75
81
  get disposed(): boolean;
76
- /**
77
- * Возвращает лениво созданное read-only представление ownership graph.
78
- */
79
82
  get graph(): DepGraph;
80
- /**
81
- * Показывает, удерживается ли автоматический frame-loop.
82
- */
83
83
  get loopEnabled(): boolean;
84
- /**
85
- * Возвращает последний frame context runtime pipeline.
86
- */
87
- get frame(): Readonly<{
88
- now: number;
89
- delta: number;
90
- elapsed: number;
91
- frame: number;
92
- }>;
93
- /**
94
- * Возвращает текущее определение runtime phases.
95
- */
84
+ get frame(): import('./phases/phase.types').RaphFrameContext;
96
85
  get phases(): readonly RaphPhase[];
97
- /**
98
- * Формирует диагностический снимок materialized derived registry.
99
- */
86
+ /** Runtime metadata facade intentionally excludes unphased watch(). */
87
+ get meta(): RaphRuntimeMeta;
100
88
  getDerivedSnapshot(): ReturnType<RaphKernel['getDerivedSnapshot']>;
101
- /**
102
- * Возвращает лениво созданную read-only диагностику runtime и ownership tree.
103
- */
104
89
  get debug(): RaphRuntimeDebug;
105
- /**
106
- * Создаёт writable signal, принадлежащий указанному owner.
107
- */
108
90
  signal<T>(value: T, owner?: RaphScope): Signal<T>;
109
91
  /**
110
- * Создаёт computed, принадлежащий указанному owner.
92
+ * Creates a deep reactive Proxy owned by this Runtime root scope.
93
+ * Property dependencies use the intrusive graph directly and intentionally
94
+ * do not create per-property WorkGraph producers or phase causes.
111
95
  */
96
+ reactive<T extends object>(value: T): T;
112
97
  computed<T>(getter: () => T, owner?: RaphScope): ReadonlySignal<T>;
113
98
  computed<T>(options: WritableComputedOptions<T>, owner?: RaphScope): Signal<T>;
114
- /**
115
- * Создаёт реактивный effect и регистрирует его lifecycle у owner.
116
- */
117
- effect(callback: () => void | Disposer, owner?: RaphScope): Disposer;
118
- effect(phase: string, callback: () => void | Disposer, options?: RaphEffectOptions, owner?: RaphScope): Disposer;
119
- /**
120
- * Подписывает runtime owner на path- либо signal-изменения.
121
- */
122
- watch(masks: DataPathDef | readonly DataPathDef[], callback: (payload: PathEvents) => void | Disposer, options?: WatchOptions, owner?: RaphScope): Disposer;
123
- watch<S extends WatchSource | readonly WatchSource[]>(source: S, callback: (value: WatchValue<S>, previous: WatchValue<S> | undefined) => void | Disposer, options?: WatchOptions, owner?: RaphScope): Disposer;
124
- /**
125
- * Возвращает кешируемый runtime-owned handle canonical path.
126
- */
99
+ /** Low-level adapter form. Prefer consumer.effect(). */
100
+ effect(consumer: RaphScope, phaseInput: string, callback: RaphPhaseEffect, options?: RaphEffectOptions): Disposer;
101
+ /** @internal */
102
+ _effectRegistration(consumer: RaphScope, phaseInput: string, callback: RaphPhaseEffect, options?: RaphEffectOptions, startPaused?: boolean): RaphPausableRegistration;
103
+ /** Low-level adapter form. Prefer consumer.watch(). */
104
+ watch(consumer: RaphScope, source: RaphWatchSource, phaseInput: string, callback: RaphPhaseEffect, options?: RaphWatchOptions): Disposer;
105
+ /** @internal */
106
+ _watchRegistration(consumer: RaphScope, source: RaphWatchSource, phaseInput: string, callback: RaphPhaseEffect, options?: RaphWatchOptions, startPaused?: boolean): RaphPausableRegistration;
107
+ aggregate(consumer: RaphScope, sources: readonly RaphAggregateSource[]): RaphAggregate;
108
+ /** Creates a lazy root-owned metadata event source for phase watches. */
109
+ metaSource(masks: DataPathDef | readonly DataPathDef[], options?: RaphMetaSourceOptions): RaphMetaSource;
127
110
  path<T>(path: DataPathDef, options?: PathOptions): PathHandle<T>;
128
- /**
129
- * Возвращает весь path-root Kernel с обычным tracking чтения.
130
- */
131
111
  get<T = RaphKernelRoot>(): T | undefined;
132
- /**
133
- * Возвращает значение Kernel по пути с runtime lifecycle checks.
134
- */
135
112
  get<T = unknown>(path: DataPathDef, options?: PathOptions): T | undefined;
136
- /**
137
- * Читает весь path-root Kernel без регистрации реактивной зависимости.
138
- */
139
113
  peek<T = RaphKernelRoot>(): T | undefined;
140
- /**
141
- * Читает значение Kernel без регистрации реактивной зависимости.
142
- */
143
114
  peek<T = unknown>(path: DataPathDef, options?: PathOptions): T | undefined;
144
- /**
145
- * Проверяет наличие значения Kernel по пути.
146
- */
147
115
  has(path: DataPathDef, options?: PathOptions): boolean;
148
- /**
149
- * Записывает значение Kernel внутри runtime write policy.
150
- */
151
116
  set<T>(path: DataPathDef, value: T, options?: PathOptions): void;
152
- /**
153
- * Объединяет значение Kernel внутри runtime write policy.
154
- */
155
117
  merge(path: DataPathDef, value: unknown, options?: PathOptions): void;
156
- /**
157
- * Удаляет значение Kernel внутри runtime write policy.
158
- */
159
118
  delete(path: DataPathDef, options?: PathOptions): void;
160
- /**
161
- * Выполняет операцию в общей синхронной transaction boundary.
162
- */
163
- transaction<T>(operation: () => T): T;
164
- /**
165
- * Создаёт именованную action boundary для разрешённых записей.
166
- */
119
+ batch<T>(operation: () => T): T;
120
+ /** Batches an internal reactive-only commit without opening an unused Kernel boundary. @internal */
121
+ _batchReactive<T>(operation: () => T): T;
122
+ private _batch;
123
+ action<Args extends unknown[], Result>(operation: (...args: Args) => Result, owner?: RaphScope): (...args: Args) => Result;
167
124
  action<Args extends unknown[], Result>(name: string, operation: (...args: Args) => Result, owner?: RaphScope): (...args: Args) => Result;
168
- /**
169
- * Выполняет операцию внутри action boundary.
170
- */
171
- runInAction<T>(_name: string, operation: () => T): T;
172
- /**
173
- * Выполняет операцию без регистрации реактивных зависимостей.
174
- */
175
125
  untracked<T>(operation: () => T): T;
176
- /**
177
- * Создаёт дочерний lifecycle scope.
178
- */
179
126
  scope(id: string): RaphScope;
180
- /**
181
- * Создаёт дочерний execution node.
182
- */
183
- node<TApi>(options: NodeOptions, setup: (node: RaphNode) => TApi): RaphNode<TApi>;
184
- /**
185
- * Находит принадлежащий runtime node по id для диагностики.
186
- */
127
+ node<TApi = void>(options: NodeOptions, setup?: (node: RaphNode) => TApi): RaphNode<TApi>;
187
128
  getNode(id: string): RaphNode | undefined;
188
- /**
189
- * Заменяет полное определение phase pipeline до его первого выполнения.
190
- */
191
129
  definePhases(phases: readonly RaphPhase[]): void;
192
- /**
193
- * Добавляет phase до первого выполнения pipeline.
194
- */
195
130
  addPhase(phase: RaphPhase): void;
196
- /**
197
- * Удаляет пользовательские phases до первого выполнения pipeline.
198
- */
199
131
  clearPhases(): void;
200
- /**
201
- * Регистрирует path observer в phase pipeline.
202
- */
203
- observeData(node: RaphNode, masks: DataPathDef | readonly DataPathDef[], options: RaphObserveDataOptions): Disposer;
204
- /**
205
- * Регистрирует tracked executor указанной phase.
206
- */
207
- track(node: RaphNode, masks: DataPathDef | readonly DataPathDef[], options?: RaphTrackOptions): Disposer;
208
- /**
209
- * Помечает node для выполнения в pipeline.
210
- */
211
- invalidateNode(node: RaphNode, phase: string): void;
212
- /**
213
- * Синхронно выполняет все готовые очереди pipeline.
214
- */
132
+ requestExecution(): void;
215
133
  flush(): void;
216
- /**
217
- * Получает lease автоматического frame-loop.
218
- */
134
+ afterFlush(): Promise<void>;
219
135
  acquireLoop(owner: string): FrameLoopLease;
220
- /**
221
- * Запускает manual lease автоматического frame-loop.
222
- */
223
136
  startLoop(): void;
224
- /**
225
- * Останавливает manual lease автоматического frame-loop.
226
- */
227
137
  stopLoop(): void;
228
- /**
229
- * Создаёт управляемое derived-представление source path в target path.
230
- */
231
138
  derive<TSource, TTarget>(options: DerivedOptions<TSource, TTarget>): RaphDerivedHandle<TSource, TTarget>;
139
+ dispose(): void;
140
+ /** @internal */
141
+ _onDisposed(listener: () => void): Disposer;
142
+ /** @internal */
143
+ _notifyNodeStructure(node: RaphNode, structure: RaphStructureCause, oldAncestors: readonly RaphNode[], newAncestors: readonly RaphNode[]): void;
144
+ /** @internal */
145
+ _notifyNodeTouch(node: RaphNode, metadata?: unknown): void;
146
+ /** @internal */
147
+ _assertNodeReparentAllowed(node: RaphNode, newParent: RaphNode): void;
148
+ /** @internal */
149
+ _releaseNode(node: RaphNode): void;
150
+ /** @internal */
151
+ _runNodeMutation<T>(operation: () => T): T;
152
+ /** @internal */
153
+ _runPhaseTransition<T>(operation: () => T): T;
154
+ /** @internal */
155
+ _beginOwnerDisposal(): void;
156
+ /** @internal */
157
+ _endOwnerDisposal(): void;
158
+ /** @internal */
159
+ _ownerDisposalActive(): boolean;
160
+ /** @internal */
161
+ _registerOwner(owner: RaphScope): void;
162
+ /** @internal */
163
+ _unregisterOwner(owner: RaphScope): void;
164
+ /** @internal */
165
+ _assertOwnerRuntime(owner: RaphScope): void;
166
+ /** @internal */
167
+ _beginKernelBatch(): void;
168
+ /** @internal */
169
+ _endKernelBatch(): void;
170
+ /** Регистрирует read-only diagnostics projection optional Machine. @internal */
171
+ _registerMachineDebug(registration: RaphMachineDebugRegistration): Disposer;
172
+ /**
173
+ * Проверяет optional diagnostic identity без создания public facade.
174
+ *
175
+ * @internal
176
+ */
177
+ _hasMachineDebug(id: string): boolean;
232
178
  /**
233
- * Освобождает execution graph и отсоединяет runtime от shared Kernel.
179
+ * Проверяет optional trace path без выделения operation ID.
180
+ *
181
+ * @internal
234
182
  */
235
- dispose(): void;
183
+ _traces(kind: RaphTraceKind): boolean;
184
+ /** Возвращает наследуемый cause для optional execution layers. @internal */
185
+ _currentTraceCauseId(): number | undefined;
186
+ /** Выдаёт operation id только на активном trace path. @internal */
187
+ _nextTraceOperation(kind: RaphTraceKind): number | undefined;
236
188
  /**
237
- * Регистрирует listener освобождения runtime.
189
+ * Проверяет, должен ли untracked work изолировать reactive или Runtime owner context.
190
+ *
238
191
  * @internal
239
192
  */
240
- _onDisposed(listener: () => void): Disposer;
241
- private _watchPath;
193
+ _hasActiveReactiveContext(): boolean;
194
+ /** Записывает optional trace event без machine dependency. @internal */
195
+ _recordTrace(event: RaphTraceEventInput): void;
196
+ /** Наследует cause через outputs/tasks optional execution layers. @internal */
197
+ _runWithTraceCause<T>(causeId: number | undefined, operation: () => T): T;
198
+ private _validatePhaseBinding;
242
199
  private _createDebugSnapshot;
243
- private _watchMeta;
244
- private _watchMetaInPhase;
200
+ private _createDebugTree;
201
+ private _createDebugStats;
245
202
  private _releasePathHandle;
246
203
  private get _execution();
247
204
  private get _clock();
248
205
  private _tickFrameLoop;
249
206
  private _attachWritableComputed;
250
207
  private _own;
251
- /**
252
- * Регистрирует lifecycle owner в runtime registry.
253
- * @internal
254
- */
255
- _registerOwner(owner: RaphScope): void;
256
- /**
257
- * Удаляет lifecycle owner из runtime registry.
258
- * @internal
259
- */
260
- _unregisterOwner(owner: RaphScope): void;
261
- /**
262
- * Проверяет, что owner принадлежит этому живому runtime.
263
- * @internal
264
- */
265
- _assertOwnerRuntime(owner: RaphScope): void;
266
208
  private _runTracked;
267
209
  private _runUntracked;
268
210
  private _runWrite;
211
+ private _finishExecutionBoundary;
212
+ private _clearTransientCausesIfSettled;
269
213
  private _requestExecution;
214
+ private _assertTrackedRead;
270
215
  /**
271
- * Открывает shared Kernel transaction для runtime.
272
- * @internal
273
- */
274
- _beginKernelTransaction(): void;
275
- /**
276
- * Закрывает shared Kernel transaction и запускает отложенное выполнение.
216
+ * Проверяет tracked read из optional owned source.
217
+ *
277
218
  * @internal
278
219
  */
279
- _endKernelTransaction(): void;
280
- private _assertTrackedRead;
220
+ _assertSourceReadable(owner: RaphScope): void;
221
+ private _assertImplicitDependency;
281
222
  private _assertWriteAllowed;
282
223
  private _throwCrossRuntime;
283
- private _throwDisposed;
284
224
  private _assertAlive;
285
225
  }
@@ -0,0 +1,239 @@
1
+ import { Disposer } from '../../reactivity/types';
2
+ import { RaphScope } from '../ownership/RaphScope';
3
+ export type RaphTraceKind = 'action' | 'error' | 'machine' | 'phase';
4
+ export type RaphTraceGuardMode = 'all' | 'failed' | 'none';
5
+ export type RaphTraceContextMode = 'keys' | 'none';
6
+ export interface RaphTraceOptions {
7
+ readonly capacity?: number;
8
+ readonly context?: RaphTraceContextMode;
9
+ readonly guards?: RaphTraceGuardMode;
10
+ readonly include?: readonly RaphTraceKind[];
11
+ }
12
+ export interface RaphDebugOptions {
13
+ readonly trace?: false | RaphTraceOptions;
14
+ }
15
+ export interface RaphTraceEventInput {
16
+ readonly causeId?: number;
17
+ readonly context?: Readonly<Record<string, unknown>>;
18
+ readonly details?: Readonly<Record<string, unknown>>;
19
+ readonly guard?: 'failed' | 'passed';
20
+ readonly kind: RaphTraceKind;
21
+ readonly name: string;
22
+ readonly operationId?: number;
23
+ readonly status?: 'end' | 'error' | 'ignored' | 'start';
24
+ }
25
+ export interface RaphTraceEvent {
26
+ readonly causeId?: number;
27
+ readonly contextKeys?: readonly string[];
28
+ readonly details?: Readonly<Record<string, unknown>>;
29
+ readonly guard?: 'failed' | 'passed';
30
+ readonly kind: RaphTraceKind;
31
+ readonly name: string;
32
+ readonly operationId?: number;
33
+ readonly sequence: number;
34
+ readonly status?: 'end' | 'error' | 'ignored' | 'start';
35
+ readonly timestamp: number;
36
+ }
37
+ export interface RaphTraceReadOptions {
38
+ readonly limit?: number;
39
+ readonly since?: number;
40
+ }
41
+ export interface RaphTraceStatus {
42
+ readonly capacity: number;
43
+ readonly context: RaphTraceContextMode;
44
+ readonly enabled: boolean;
45
+ readonly guards: RaphTraceGuardMode;
46
+ readonly include: readonly RaphTraceKind[];
47
+ readonly size: number;
48
+ }
49
+ export interface RaphDebugTraceApi {
50
+ clear: () => void;
51
+ read: (options?: RaphTraceReadOptions) => readonly RaphTraceEvent[];
52
+ start: (options?: RaphTraceOptions) => void;
53
+ status: () => RaphTraceStatus;
54
+ stop: () => void;
55
+ }
56
+ export interface RaphMachineDebugSnapshot {
57
+ readonly active: readonly string[];
58
+ readonly contextKeys: readonly string[];
59
+ readonly id: string;
60
+ readonly modelId: string;
61
+ readonly meta: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
62
+ readonly ownerId: string;
63
+ readonly parentId?: string;
64
+ readonly revision: number;
65
+ readonly status: string;
66
+ readonly actors: readonly string[];
67
+ }
68
+ export interface RaphMachineDebugSummary {
69
+ readonly active: readonly string[];
70
+ readonly id: string;
71
+ readonly modelId: string;
72
+ readonly ownerId: string;
73
+ readonly parentId?: string;
74
+ readonly revision: number;
75
+ readonly status: string;
76
+ }
77
+ /** @internal */
78
+ export interface RaphMachineDebugRegistration {
79
+ readonly id: string;
80
+ readonly ownerId: string;
81
+ readonly parentId?: string;
82
+ readonly snapshot: () => RaphMachineDebugSnapshot;
83
+ }
84
+ export interface RaphDebugMachinesApi {
85
+ list: () => readonly RaphMachineDebugSummary[];
86
+ snapshot: (id: string) => RaphMachineDebugSnapshot | undefined;
87
+ }
88
+ export interface RaphDebugOwnerSnapshot {
89
+ readonly children: readonly RaphDebugOwnerSnapshot[];
90
+ readonly disposed: boolean;
91
+ readonly id: string;
92
+ readonly kind: 'node' | 'scope';
93
+ readonly resources: number;
94
+ readonly sources: number;
95
+ }
96
+ export interface RaphDebugFrameLoopSnapshot {
97
+ readonly leases: number;
98
+ readonly manual: boolean;
99
+ readonly running: boolean;
100
+ }
101
+ export interface RaphDebugSnapshot {
102
+ readonly actionDepth: number;
103
+ readonly batchDepth: number;
104
+ readonly disposed: boolean;
105
+ readonly frameLoop: RaphDebugFrameLoopSnapshot;
106
+ readonly id: string;
107
+ readonly kernelBatchDepth: number;
108
+ readonly machines: number;
109
+ readonly owners: number;
110
+ readonly pathHandles: number;
111
+ readonly pending: boolean;
112
+ readonly root: RaphDebugOwnerSnapshot;
113
+ readonly rootScope: RaphDebugOwnerSnapshot;
114
+ readonly scopes: readonly RaphDebugOwnerSnapshot[];
115
+ readonly traceEvents: number;
116
+ }
117
+ export interface RaphDebugTreeNode {
118
+ readonly children: readonly RaphDebugTreeNode[];
119
+ readonly count?: number;
120
+ readonly disposed?: boolean;
121
+ readonly id: string;
122
+ readonly kind: 'actor' | 'machine' | 'node' | 'resource' | 'runtime' | 'scope';
123
+ readonly status?: string;
124
+ }
125
+ export interface RaphDebugStats {
126
+ readonly actors: number;
127
+ readonly machines: number;
128
+ readonly nodes: number;
129
+ readonly owners: number;
130
+ readonly pathHandles: number;
131
+ readonly pending: boolean;
132
+ readonly resources: number;
133
+ readonly scopes: number;
134
+ readonly sources: number;
135
+ readonly traceEvents: number;
136
+ }
137
+ export interface RaphRuntimeDebug {
138
+ readonly machines: RaphDebugMachinesApi;
139
+ readonly trace: RaphDebugTraceApi;
140
+ getTree: () => RaphDebugTreeNode;
141
+ snapshot: () => RaphDebugSnapshot;
142
+ stats: () => RaphDebugStats;
143
+ }
144
+ /**
145
+ * Хранит opt-in trace и ленивый registry machine diagnostics одного Runtime.
146
+ * @internal
147
+ */
148
+ export declare class RaphDebugController {
149
+ private _capacity;
150
+ private _context;
151
+ private _guards;
152
+ private _include;
153
+ private _enabled;
154
+ private _events;
155
+ private _eventStart;
156
+ private _eventSize;
157
+ private _sequence;
158
+ private _operationSequence;
159
+ private _machines;
160
+ readonly trace: RaphDebugTraceApi;
161
+ readonly machines: RaphDebugMachinesApi;
162
+ /**
163
+ * Создаёт controller; ring buffer появляется только при включённом trace.
164
+ */
165
+ constructor(options?: RaphDebugOptions);
166
+ /**
167
+ * Включает trace с текущими или явно переданными настройками.
168
+ */
169
+ start(options?: RaphTraceOptions): void;
170
+ /**
171
+ * Останавливает запись, сохраняя уже накопленные events.
172
+ */
173
+ stop(): void;
174
+ /**
175
+ * Удаляет все накопленные events, не меняя status trace.
176
+ */
177
+ clear(): void;
178
+ /**
179
+ * Формирует immutable chronological copy ring buffer.
180
+ */
181
+ read(options?: RaphTraceReadOptions): readonly RaphTraceEvent[];
182
+ /**
183
+ * Возвращает текущую конфигурацию и заполнение buffer.
184
+ */
185
+ status(): RaphTraceStatus;
186
+ /**
187
+ * Выделяет operation ID только когда trace активен для этого kind.
188
+ * @internal
189
+ */
190
+ nextOperationId(kind: RaphTraceKind): number | undefined;
191
+ /**
192
+ * Проверяет active trace path без выделения operation ID.
193
+ *
194
+ * @internal
195
+ */
196
+ traces(kind: RaphTraceKind): boolean;
197
+ /**
198
+ * Записывает одно событие без allocations/timestamp на disabled path.
199
+ * @internal
200
+ */
201
+ record(input: RaphTraceEventInput): void;
202
+ /**
203
+ * Регистрирует read-only machine projection без импорта machine engine в Runtime.
204
+ * @internal
205
+ */
206
+ registerMachine(registration: RaphMachineDebugRegistration): Disposer;
207
+ /**
208
+ * Проверяет diagnostic identity без создания public snapshot.
209
+ *
210
+ * @internal
211
+ */
212
+ hasMachine(id: string): boolean;
213
+ /**
214
+ * Возвращает compact machine summaries без выполнения guards.
215
+ */
216
+ listMachines(): readonly RaphMachineDebugSummary[];
217
+ /**
218
+ * Читает готовый machine snapshot; transition selection и guards не вызываются.
219
+ */
220
+ machineSnapshot(id: string): RaphMachineDebugSnapshot | undefined;
221
+ /**
222
+ * Возвращает число зарегистрированных machines.
223
+ * @internal
224
+ */
225
+ get machineCount(): number;
226
+ /**
227
+ * Возвращает число текущих trace events.
228
+ * @internal
229
+ */
230
+ get traceSize(): number;
231
+ /** Возвращает число child actors по уже готовым snapshots. @internal */
232
+ get actorCount(): number;
233
+ /** Группирует machine/actor ветви по фактическому lifecycle owner. @internal */
234
+ machineTreeNodesByOwner(): ReadonlyMap<string, readonly RaphDebugTreeNode[]>;
235
+ private _applyOptions;
236
+ private _ensureBuffer;
237
+ }
238
+ export declare function createOwnerSnapshot(owner: RaphScope): RaphDebugOwnerSnapshot;
239
+ export declare function createOwnerTree(owner: RaphScope, machinesByOwner?: ReadonlyMap<string, readonly RaphDebugTreeNode[]>): RaphDebugTreeNode;
@@ -14,3 +14,8 @@ export declare class RaphDisposedError extends RaphError {
14
14
  */
15
15
  export declare class RaphCrossRuntimeError extends RaphError {
16
16
  }
17
+ /**
18
+ * Сообщает об ошибке пользовательского phase processor или task resolution.
19
+ */
20
+ export declare class RaphPhaseProcessError extends RaphError {
21
+ }