@raphy-js/raph 1.0.0-dev.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/LICENSE +202 -0
  2. package/dist/api/Raph.d.ts +97 -0
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +25 -0
  6. package/dist/api/types.d.ts +170 -0
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -0
  10. package/dist/debug/api/Raph.js +421 -0
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -0
  15. package/dist/debug/api/errors.cjs +1 -0
  16. package/dist/debug/api/errors.js +17 -0
  17. package/dist/debug/api/types.cjs +1 -0
  18. package/dist/debug/api/types.js +1 -0
  19. package/dist/debug/path/DataPath.cjs +1 -0
  20. package/dist/debug/path/DataPath.js +394 -0
  21. package/dist/debug/path/PathRouter.cjs +1 -0
  22. package/dist/debug/path/PathRouter.js +86 -0
  23. package/dist/debug/path/RaphKernel.cjs +1 -0
  24. package/dist/debug/path/RaphKernel.js +687 -0
  25. package/dist/debug/path/data-path.types.cjs +1 -0
  26. package/dist/debug/path/data-path.types.js +1 -0
  27. package/dist/debug/path/data-path.utils.cjs +1 -0
  28. package/dist/debug/path/data-path.utils.js +56 -0
  29. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  30. package/dist/debug/path/derived/DerivedRegistry.js +157 -0
  31. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  32. package/dist/debug/path/derived/RaphDerivedHandle.js +125 -0
  33. package/dist/debug/path/derived/derived-collection.types.cjs +1 -0
  34. package/dist/debug/path/derived/derived-collection.types.js +1 -0
  35. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  36. package/dist/debug/path/derived/derived-collection.utils.js +179 -0
  37. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  38. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  39. package/dist/debug/path/derived/derived-strategy.utils.cjs +1 -0
  40. package/dist/debug/path/derived/derived-strategy.utils.js +20 -0
  41. package/dist/debug/path/meta/MetaController.cjs +1 -0
  42. package/dist/debug/path/meta/MetaController.js +214 -0
  43. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  44. package/dist/debug/path/meta/RaphMeta.js +68 -0
  45. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  46. package/dist/debug/path/meta/RaphMetaStore.js +184 -0
  47. package/dist/debug/path/meta/meta.types.cjs +1 -0
  48. package/dist/debug/path/meta/meta.types.js +1 -0
  49. package/dist/debug/path/path.types.cjs +1 -0
  50. package/dist/debug/path/path.types.js +1 -0
  51. package/dist/debug/path/pathSegmentKey.cjs +1 -0
  52. package/dist/debug/path/pathSegmentKey.js +12 -0
  53. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  54. package/dist/debug/path/storage/AdapterPathStore.js +133 -0
  55. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  56. package/dist/debug/path/storage/DefaultDataAdapter.js +356 -0
  57. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  58. package/dist/debug/path/storage/PathEventHub.js +148 -0
  59. package/dist/debug/path/storage/PathStore.cjs +1 -0
  60. package/dist/debug/path/storage/PathStore.js +326 -0
  61. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  62. package/dist/debug/path/storage/createDataDraft.js +71 -0
  63. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  64. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  65. package/dist/debug/reactivity/engine.cjs +1 -0
  66. package/dist/debug/reactivity/engine.js +1305 -0
  67. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  68. package/dist/debug/reactivity/reactive-object.js +280 -0
  69. package/dist/debug/reactivity/scope.cjs +1 -0
  70. package/dist/debug/reactivity/scope.js +274 -0
  71. package/dist/debug/reactivity/types.cjs +1 -0
  72. package/dist/debug/reactivity/types.js +1 -0
  73. package/dist/debug/reactivity/watch.cjs +1 -0
  74. package/dist/debug/reactivity/watch.js +64 -0
  75. package/dist/debug/runtime/RaphRuntime.cjs +1 -0
  76. package/dist/debug/runtime/RaphRuntime.js +979 -0
  77. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  78. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  79. package/dist/debug/runtime/errors.cjs +1 -0
  80. package/dist/debug/runtime/errors.js +15 -0
  81. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  82. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  83. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  84. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  85. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  86. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  87. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  88. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  89. package/dist/debug/runtime/ownership/parentGraph.cjs +1 -0
  90. package/dist/debug/runtime/ownership/parentGraph.js +10 -0
  91. package/dist/debug/runtime/ownership/throwDisposalErrors.cjs +1 -0
  92. package/dist/debug/runtime/ownership/throwDisposalErrors.js +9 -0
  93. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  94. package/dist/debug/runtime/phases/RaphFrameLoop.js +106 -0
  95. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  96. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  97. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  98. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  99. package/dist/debug/runtime/phases/phase.types.cjs +1 -0
  100. package/dist/debug/runtime/phases/phase.types.js +8 -0
  101. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/PathHandle.js +175 -0
  103. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  104. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  105. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  106. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  107. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  108. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  109. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  110. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  111. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  112. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  113. package/dist/entrypoints/machine-testing.d.ts +2 -0
  114. package/dist/entrypoints/machine.d.ts +5 -0
  115. package/dist/entrypoints/path.d.ts +14 -0
  116. package/dist/entrypoints/reactivity.d.ts +1 -0
  117. package/dist/entrypoints/runtime.d.ts +17 -0
  118. package/dist/index.cjs +1 -0
  119. package/dist/index.js +48 -0
  120. package/dist/machine/compiler.d.ts +71 -0
  121. package/dist/machine/core.d.ts +50 -0
  122. package/dist/machine/persistence.d.ts +5 -0
  123. package/dist/machine/runtime.d.ts +4 -0
  124. package/dist/machine/testing.d.ts +43 -0
  125. package/dist/machine/types.d.ts +155 -0
  126. package/dist/machine-testing.cjs +1 -0
  127. package/dist/machine-testing.js +188 -0
  128. package/dist/machine.cjs +1 -0
  129. package/dist/machine.js +837 -0
  130. package/dist/main.d.ts +20 -0
  131. package/dist/path/DataPath.d.ts +73 -0
  132. package/dist/path/PathRouter.d.ts +21 -0
  133. package/dist/path/RaphKernel.d.ts +169 -0
  134. package/dist/path/data-path.types.d.ts +34 -0
  135. package/dist/path/data-path.utils.d.ts +9 -0
  136. package/dist/path/derived/DerivedRegistry.d.ts +67 -0
  137. package/dist/path/derived/RaphDerivedHandle.d.ts +97 -0
  138. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  139. package/dist/path/derived/derived-collection.utils.d.ts +20 -0
  140. package/dist/path/derived/derived-strategy.types.d.ts +12 -0
  141. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  142. package/dist/path/meta/MetaController.d.ts +85 -0
  143. package/dist/path/meta/RaphMeta.d.ts +45 -0
  144. package/dist/path/meta/RaphMetaStore.d.ts +45 -0
  145. package/dist/path/meta/meta.types.d.ts +31 -0
  146. package/dist/path/path.types.d.ts +27 -0
  147. package/dist/path/pathSegmentKey.d.ts +2 -0
  148. package/dist/path/storage/AdapterPathStore.d.ts +45 -0
  149. package/dist/path/storage/DefaultDataAdapter.d.ts +63 -0
  150. package/dist/path/storage/PathEventHub.d.ts +48 -0
  151. package/dist/path/storage/PathStore.d.ts +51 -0
  152. package/dist/path/storage/createDataDraft.d.ts +4 -0
  153. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  154. package/dist/path.cjs +1 -0
  155. package/dist/path.js +18 -0
  156. package/dist/raph.cjs +1 -0
  157. package/dist/raph.js +48 -0
  158. package/dist/reactivity/engine.d.ts +393 -0
  159. package/dist/reactivity/reactive-object.d.ts +36 -0
  160. package/dist/reactivity/scope.d.ts +146 -0
  161. package/dist/reactivity/types.d.ts +175 -0
  162. package/dist/reactivity/watch.d.ts +15 -0
  163. package/dist/reactivity.cjs +1 -0
  164. package/dist/reactivity.js +14 -0
  165. package/dist/runtime/RaphRuntime.d.ts +225 -0
  166. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  167. package/dist/runtime/errors.d.ts +21 -0
  168. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  169. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  170. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  171. package/dist/runtime/ownership/parent-graph.types.d.ts +4 -0
  172. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  173. package/dist/runtime/ownership/throwDisposalErrors.d.ts +1 -0
  174. package/dist/runtime/phases/RaphFrameLoop.d.ts +51 -0
  175. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  176. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  177. package/dist/runtime/phases/phase.types.d.ts +92 -0
  178. package/dist/runtime/reactivity/PathHandle.d.ts +80 -0
  179. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  180. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  181. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +45 -0
  182. package/dist/runtime/reactivity/RuntimeWatch.d.ts +34 -0
  183. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +11 -0
  184. package/dist/runtime.cjs +1 -0
  185. package/dist/runtime.js +23 -0
  186. package/package.json +141 -0
@@ -0,0 +1,175 @@
1
+ export type Disposer = () => void;
2
+ export interface ReadonlySignal<T> {
3
+ get: (this: ReadonlySignal<unknown>) => T;
4
+ peek: (this: ReadonlySignal<unknown>) => T;
5
+ }
6
+ export interface Signal<T> extends ReadonlySignal<T> {
7
+ set: (value: T) => void;
8
+ }
9
+ export interface WritableComputedOptions<T> {
10
+ readonly get: () => T;
11
+ readonly set: (value: T) => void;
12
+ }
13
+ export type EffectCallback = () => void | Disposer;
14
+ export interface EffectTask {
15
+ dependencyOwner?: object;
16
+ allowScheduleDuringRun?: boolean;
17
+ notify?: (source: unknown) => void;
18
+ cancelPending?: () => boolean;
19
+ rearmPending?: () => void;
20
+ schedule: () => void;
21
+ dispose: Disposer;
22
+ }
23
+ export interface EffectScheduler {
24
+ bind: (run: () => void) => EffectTask;
25
+ }
26
+ export interface ReactivityOptions {
27
+ readonly adaptiveDependencyIndex?: boolean;
28
+ readonly effectScheduler?: EffectScheduler;
29
+ }
30
+ export type WatchSource<T = unknown> = ReadonlySignal<T> | (() => T);
31
+ export interface WatchOptions {
32
+ readonly immediate?: boolean;
33
+ }
34
+ export type WatchValue<S> = S extends readonly unknown[] ? {
35
+ [K in keyof S]: S[K] extends WatchSource<infer V> ? V : never;
36
+ } : S extends WatchSource<infer V> ? V : never;
37
+ export type WatchCallback<S> = (value: WatchValue<S>, previous: WatchValue<S> | undefined) => void | Disposer;
38
+ export type EffectFactory = (callback: EffectCallback, onStop?: Disposer) => Disposer;
39
+ export type TrackedOperation = <T>(operation: () => T) => T;
40
+ /**
41
+ * Финализатор источника: true означает завершение, false — необходимость повторной
42
+ * попытки после освобождения зависимостей. Не является дублем Disposer.
43
+ * @internal
44
+ */
45
+ export type SourceFinalizer = () => boolean;
46
+ /**
47
+ * Запись произвольного ресурса в списке владельца.
48
+ * Функция dispose отсоединяет запись перед вызовом пользовательской очистки.
49
+ * @internal
50
+ */
51
+ export interface OwnedResource extends ScopeLink<OwnedResource> {
52
+ dispose: Disposer;
53
+ }
54
+ /**
55
+ * Границы списка принадлежащих ресурсов. Не описывают граф зависимостей
56
+ * или дерево исполнения RaphNode.
57
+ * @internal
58
+ */
59
+ export interface ScopeChildren<T> {
60
+ scopeFirstChild?: T;
61
+ scopeLastChild?: T;
62
+ }
63
+ /**
64
+ * Встроенные связи ресурса с владельцем и соседями списка.
65
+ * Не требуют отдельного ScopeNode для каждого эффекта.
66
+ * @internal
67
+ */
68
+ export interface ScopeLink<T> {
69
+ scopeParent?: ScopeChildren<T>;
70
+ scopePrevious?: T;
71
+ scopeNext?: T;
72
+ }
73
+ /**
74
+ * Одна зависимость производителя и потребителя, одновременно включённая
75
+ * в список потребителей производителя и список зависимостей потребителя.
76
+ * @internal
77
+ */
78
+ export interface ReactiveEdge {
79
+ dep: ReactiveNode;
80
+ sub: ReactiveNode;
81
+ prevSub: ReactiveEdge | null;
82
+ nextSub: ReactiveEdge | null;
83
+ prevDep: ReactiveEdge | null;
84
+ nextDep: ReactiveEdge | null;
85
+ dependencyCleanup?: Disposer;
86
+ }
87
+ /**
88
+ * Материализованная запись графа: signal, computed либо effect.
89
+ * Не наследует ScopeNode/RaphNode; поля scope используются только для вложенных эффектов.
90
+ * Гетерогенные значения графа намеренно имеют внутренний параметр any.
91
+ * @internal
92
+ */
93
+ export interface ReactiveNode<T = any> extends ScopeChildren<ReactiveNode>, ScopeLink<ReactiveNode> {
94
+ flags: number;
95
+ firstSub: ReactiveEdge | null;
96
+ lastSub: ReactiveEdge | null;
97
+ firstDep: ReactiveEdge | null;
98
+ tailDep: ReactiveEdge | null;
99
+ depCount: number;
100
+ subSearchCursor?: ReactiveEdge;
101
+ dependencyIndex?: Map<ReactiveNode, ReactiveEdge>;
102
+ dependencyLookupDebt?: number;
103
+ dependencyLookupSearches?: number;
104
+ evaluate: (() => any) | undefined;
105
+ cachedValue: T;
106
+ pendingValue?: T;
107
+ pendingAuthor?: ReactiveNode | null;
108
+ effectTask?: EffectTask;
109
+ onStop?: Disposer;
110
+ sourceHooks?: OwnedSourceHooks;
111
+ }
112
+ /**
113
+ * Низкоуровневые read/write для raw-дорожки Bench Lab.
114
+ * Публичный объектный API намеренно не использует этот контракт.
115
+ * @internal
116
+ */
117
+ export interface SignalAccess<T> {
118
+ read: () => T;
119
+ write: (value: T) => void;
120
+ }
121
+ /**
122
+ * Низкоуровневый computed с требованием сохранить receiver первого чтения.
123
+ * @internal
124
+ */
125
+ export interface ComputedAccess<T> {
126
+ read: (this: ComputedAccess<unknown>) => T;
127
+ }
128
+ /**
129
+ * Ленивый raw handle: до первого чтения поля ReactiveNode отсутствуют.
130
+ * Partial описывает стадию материализации, а не ослабляет контракт готового узла.
131
+ * @internal
132
+ */
133
+ export interface ComputedAccessHandle<T> extends Partial<ReactiveNode<T>>, ComputedAccess<T> {
134
+ evaluate: (() => T) | undefined;
135
+ }
136
+ /**
137
+ * Ленивый объектный computed: графовые поля становятся обязательными
138
+ * только после initializeComputedHandle(). Отдельной записи графа не выделяет.
139
+ * @internal
140
+ */
141
+ export interface ComputedSourceAccessHandle<T> extends Partial<ReactiveNode<T>>, ReadonlySignal<T> {
142
+ evaluate: (() => T) | undefined;
143
+ }
144
+ /**
145
+ * Handle источника вместе с независимым финализатором для владельца.
146
+ * @internal
147
+ */
148
+ export interface OwnedSource<T> {
149
+ source: T;
150
+ hasSubscribers?: () => boolean;
151
+ dispose: SourceFinalizer;
152
+ }
153
+ /**
154
+ * Необязательные Runtime hooks owned-источника. Standalone sources не передают
155
+ * этот объект и сохраняют прежний hot path без ownership metadata.
156
+ * @internal
157
+ */
158
+ export interface OwnedSourceHooks {
159
+ readonly token?: unknown;
160
+ readonly dependencyOwner?: object;
161
+ readonly onDependency?: (consumerOwner: object) => Disposer | undefined;
162
+ readonly onChange?: (previous: unknown, value: unknown, hasReactiveSubscribers: boolean) => void;
163
+ readonly onInvalidate?: (hasReactiveSubscribers: boolean) => void;
164
+ readonly onDispose?: (hasReactiveSubscribers: boolean) => void;
165
+ }
166
+ /**
167
+ * Общие для одного графа адаптеры receiver его handles.
168
+ * Не хранят состояние алгоритмов: передают исходный handle методам движка.
169
+ * @internal
170
+ */
171
+ export interface HandleReaders {
172
+ initializeComputed: <T>(this: ReadonlySignal<unknown>) => T;
173
+ initializeRaw: <T>(this: ComputedAccess<unknown>) => T;
174
+ peek: <T>(this: ReadonlySignal<unknown>) => T;
175
+ }
@@ -0,0 +1,15 @@
1
+ import { Disposer, EffectFactory, TrackedOperation, WatchCallback, WatchOptions, WatchSource } from './types';
2
+ /**
3
+ * Создаёт watch поверх переданной фабрики эффектов и политики чтения.
4
+ * Фабрика обязана поддерживать второй аргумент onStop: он связывает окончательную
5
+ * очистку watch с остановкой эффекта родителем, scope или внешним disposer.
6
+ * Повторный запуск с равным результатом не вызывает cleanup callback.
7
+ * @param effect Фабрика с независимым финализатором окончательной остановки.
8
+ * @param untracked Выполняет callback и cleanup без сбора зависимостей.
9
+ * @param source Один источник либо список источников.
10
+ * @param callback Обрабатывает новое и предыдущее значения.
11
+ * @param options Настройки первоначального вызова.
12
+ * @param runTracked Оборачивает только чтение selector; используется Runtime.
13
+ * @internal
14
+ */
15
+ export declare function watchWithReactivity<S extends WatchSource | readonly WatchSource[]>(effect: EffectFactory, untracked: TrackedOperation, source: S, callback: WatchCallback<S>, options?: WatchOptions, runTracked?: TrackedOperation): Disposer;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./debug/reactivity/engine.cjs"),t=require("./debug/reactivity/scope.cjs");exports.RaphReactivity=e.RaphReactivity;exports.batch=e.batch;exports.computed=e.computed;exports.effect=e.effect;exports.reactive=e.reactive;exports.scope=e.scope;exports.signal=e.signal;exports.untracked=e.untracked;exports.watch=e.watch;exports.ScopeNode=t.ScopeNode;
@@ -0,0 +1,14 @@
1
+ import { RaphReactivity as c, batch as o, computed as a, effect as p, reactive as r, scope as f, signal as i, untracked as d, watch as h } from "./debug/reactivity/engine.js";
2
+ import { ScopeNode as n } from "./debug/reactivity/scope.js";
3
+ export {
4
+ c as RaphReactivity,
5
+ n as ScopeNode,
6
+ o as batch,
7
+ a as computed,
8
+ p as effect,
9
+ r as reactive,
10
+ f as scope,
11
+ i as signal,
12
+ d as untracked,
13
+ h as watch
14
+ };
@@ -0,0 +1,225 @@
1
+ import { DerivedOptions, RaphDerivedHandle } from '../path/derived/RaphDerivedHandle';
2
+ import { RaphMeta } from '../path/meta/RaphMeta';
3
+ import { DataPathDef, PathOptions } from '../path/path.types';
4
+ import { RaphKernelRoot, RaphKernel } from '../path/RaphKernel';
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';
15
+ export interface RaphRuntimeOptions {
16
+ readonly adaptiveDependencyIndex?: boolean;
17
+ readonly debug?: RaphDebugOptions;
18
+ readonly id?: string;
19
+ readonly kernel?: RaphKernel;
20
+ readonly enforceActions?: boolean;
21
+ readonly scheduler?: RaphSchedulerMode;
22
+ }
23
+ export interface RaphRuntimeConfiguration {
24
+ readonly adaptiveDependencyIndex: boolean;
25
+ readonly debug?: RaphDebugOptions;
26
+ readonly id: string;
27
+ readonly kernel: RaphKernel;
28
+ readonly enforceActions: boolean;
29
+ readonly scheduler: RaphSchedulerMode;
30
+ }
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. */
39
+ export declare class RaphRuntime {
40
+ private static _runtimeCounter;
41
+ readonly mode: "runtime";
42
+ readonly configuration: RaphRuntimeConfiguration;
43
+ readonly rootScope: RaphScope;
44
+ readonly root: RaphNode;
45
+ readonly frameTick: ReadonlySignal<number>;
46
+ private readonly _reactivity;
47
+ private readonly _signalLifecycle;
48
+ private readonly _workGraph;
49
+ private readonly _frameTickWritable;
50
+ private readonly _setFrameTick;
51
+ private _pathHandles;
52
+ private _meta;
53
+ private _phases;
54
+ private _frameLoop;
55
+ private _debug;
56
+ private readonly _debugController;
57
+ private _parentGraph;
58
+ private readonly _owners;
59
+ private _batchDepth;
60
+ private _mutationDepth;
61
+ private _kernelBatchDepth;
62
+ private _ownerDisposalDepth;
63
+ private _actionDepth;
64
+ private _actionCounter;
65
+ private readonly _traceCauseStack;
66
+ private _phaseTraceOperations;
67
+ private _executionRequested;
68
+ private _disposed;
69
+ private readonly _disposedListeners;
70
+ constructor(options?: RaphRuntimeOptions);
71
+ /** @internal */
72
+ _getReactivity(): RuntimeReactivity;
73
+ /**
74
+ * Возвращает внутренний WorkGraph для optional execution layers.
75
+ *
76
+ * @internal
77
+ */
78
+ _getWorkGraph(): RaphWorkGraph;
79
+ get id(): string;
80
+ get kernel(): RaphKernel;
81
+ get disposed(): boolean;
82
+ get graph(): DepGraph;
83
+ get loopEnabled(): boolean;
84
+ get frame(): import('./phases/phase.types').RaphFrameContext;
85
+ get phases(): readonly RaphPhase[];
86
+ /** Runtime metadata facade intentionally excludes unphased watch(). */
87
+ get meta(): RaphRuntimeMeta;
88
+ getDerivedSnapshot(): ReturnType<RaphKernel['getDerivedSnapshot']>;
89
+ get debug(): RaphRuntimeDebug;
90
+ signal<T>(value: T, owner?: RaphScope): Signal<T>;
91
+ /**
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.
95
+ */
96
+ reactive<T extends object>(value: T): T;
97
+ computed<T>(getter: () => T, owner?: RaphScope): ReadonlySignal<T>;
98
+ computed<T>(options: WritableComputedOptions<T>, owner?: RaphScope): Signal<T>;
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;
110
+ path<T>(path: DataPathDef, options?: PathOptions): PathHandle<T>;
111
+ get<T = RaphKernelRoot>(): T | undefined;
112
+ get<T = unknown>(path: DataPathDef, options?: PathOptions): T | undefined;
113
+ peek<T = RaphKernelRoot>(): T | undefined;
114
+ peek<T = unknown>(path: DataPathDef, options?: PathOptions): T | undefined;
115
+ has(path: DataPathDef, options?: PathOptions): boolean;
116
+ set<T>(path: DataPathDef, value: T, options?: PathOptions): void;
117
+ merge(path: DataPathDef, value: unknown, options?: PathOptions): void;
118
+ delete(path: DataPathDef, options?: PathOptions): void;
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;
124
+ action<Args extends unknown[], Result>(name: string, operation: (...args: Args) => Result, owner?: RaphScope): (...args: Args) => Result;
125
+ untracked<T>(operation: () => T): T;
126
+ scope(id: string): RaphScope;
127
+ node<TApi = void>(options: NodeOptions, setup?: (node: RaphNode) => TApi): RaphNode<TApi>;
128
+ getNode(id: string): RaphNode | undefined;
129
+ definePhases(phases: readonly RaphPhase[]): void;
130
+ addPhase(phase: RaphPhase): void;
131
+ clearPhases(): void;
132
+ requestExecution(): void;
133
+ flush(): void;
134
+ afterFlush(): Promise<void>;
135
+ acquireLoop(owner: string): FrameLoopLease;
136
+ startLoop(): void;
137
+ stopLoop(): void;
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;
178
+ /**
179
+ * Проверяет optional trace path без выделения operation ID.
180
+ *
181
+ * @internal
182
+ */
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;
188
+ /**
189
+ * Проверяет, должен ли untracked work изолировать reactive или Runtime owner context.
190
+ *
191
+ * @internal
192
+ */
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;
199
+ private _createDebugSnapshot;
200
+ private _createDebugTree;
201
+ private _createDebugStats;
202
+ private _releasePathHandle;
203
+ private get _execution();
204
+ private get _clock();
205
+ private _tickFrameLoop;
206
+ private _attachWritableComputed;
207
+ private _own;
208
+ private _runTracked;
209
+ private _runUntracked;
210
+ private _runWrite;
211
+ private _finishExecutionBoundary;
212
+ private _clearTransientCausesIfSettled;
213
+ private _requestExecution;
214
+ private _assertTrackedRead;
215
+ /**
216
+ * Проверяет tracked read из optional owned source.
217
+ *
218
+ * @internal
219
+ */
220
+ _assertSourceReadable(owner: RaphScope): void;
221
+ private _assertImplicitDependency;
222
+ private _assertWriteAllowed;
223
+ private _throwCrossRuntime;
224
+ private _assertAlive;
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;