@raphy-js/raph 1.0.1-dev.26 → 1.0.1-dev.54

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 (127) hide show
  1. package/README.md +100 -0
  2. package/dist/api/Raph.d.ts +15 -15
  3. package/dist/api/RaphFacadeSession.d.ts +4 -4
  4. package/dist/api/RaphReactivityInstance.d.ts +4 -4
  5. package/dist/api/types.d.ts +11 -11
  6. package/dist/compact.cjs +1 -0
  7. package/dist/compact.js +4 -0
  8. package/dist/debug/reactivity/engine-core.cjs +1 -0
  9. package/dist/debug/reactivity/engine-core.js +1760 -0
  10. package/dist/debug/reactivity/engine.cjs +1 -1
  11. package/dist/debug/reactivity/engine.js +25 -1689
  12. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  13. package/dist/debug/reactivity/reactive-object.js +604 -167
  14. package/dist/debug/runtime/RaphCompactExecutionRuntime.cjs +1 -0
  15. package/dist/debug/runtime/RaphCompactExecutionRuntime.js +9 -0
  16. package/dist/debug/runtime/RaphExecutionRuntime.cjs +1 -0
  17. package/dist/debug/runtime/RaphExecutionRuntime.js +11 -0
  18. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  19. package/dist/debug/runtime/RaphRuntime.js +115 -1176
  20. package/dist/debug/runtime/RaphRuntimeBase.cjs +1 -0
  21. package/dist/debug/runtime/RaphRuntimeBase.js +941 -0
  22. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  23. package/dist/debug/runtime/diagnostics/RaphDebug.js +72 -66
  24. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  25. package/dist/debug/runtime/ownership/RaphNode.js +11 -0
  26. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  27. package/dist/debug/runtime/ownership/RaphScope.js +12 -12
  28. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  29. package/dist/debug/runtime/phases/RaphPhasePipeline.js +361 -242
  30. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -1
  31. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +23 -22
  32. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -1
  33. package/dist/debug/runtime/reactivity/RaphSelector.js +111 -90
  34. package/dist/debug/runtime/reactivity/RuntimeObjectSupport.cjs +1 -0
  35. package/dist/debug/runtime/reactivity/RuntimeObjectSupport.js +11 -0
  36. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  37. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +118 -103
  38. package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.cjs +1 -0
  39. package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.js +12 -0
  40. package/dist/entrypoints/compact.d.ts +2 -0
  41. package/dist/entrypoints/execution.d.ts +2 -0
  42. package/dist/entrypoints/machine-testing.d.ts +2 -2
  43. package/dist/entrypoints/machine.d.ts +5 -5
  44. package/dist/entrypoints/observable.d.ts +4 -0
  45. package/dist/entrypoints/path.d.ts +14 -14
  46. package/dist/entrypoints/reactivity.d.ts +1 -1
  47. package/dist/entrypoints/runtime.d.ts +19 -18
  48. package/dist/execution.cjs +1 -0
  49. package/dist/execution.js +4 -0
  50. package/dist/index.cjs +1 -1
  51. package/dist/index.js +23 -21
  52. package/dist/machine/compiler.d.ts +1 -1
  53. package/dist/machine/core.d.ts +2 -2
  54. package/dist/machine/persistence.d.ts +1 -1
  55. package/dist/machine/runtime.d.ts +3 -3
  56. package/dist/machine/testing.d.ts +1 -1
  57. package/dist/machine/types.d.ts +3 -3
  58. package/dist/main.d.ts +19 -19
  59. package/dist/observable/buffer.d.ts +6 -0
  60. package/dist/observable/class-admin.d.ts +63 -0
  61. package/dist/observable/class-plan.d.ts +46 -0
  62. package/dist/observable/classes.d.ts +10 -0
  63. package/dist/observable/context.d.ts +73 -0
  64. package/dist/observable/native.d.ts +2 -0
  65. package/dist/observable/observable.d.ts +13 -0
  66. package/dist/observable/types.d.ts +60 -0
  67. package/dist/observable.cjs +1 -0
  68. package/dist/observable.js +1187 -0
  69. package/dist/path/DataPath.d.ts +2 -2
  70. package/dist/path/PathRouter.d.ts +1 -1
  71. package/dist/path/RaphKernel.d.ts +6 -6
  72. package/dist/path/data-path.types.d.ts +1 -1
  73. package/dist/path/data-path.utils.d.ts +2 -2
  74. package/dist/path/derived/DerivedRegistry.d.ts +3 -3
  75. package/dist/path/derived/RaphDerivedHandle.d.ts +3 -3
  76. package/dist/path/derived/derived-collection.types.d.ts +1 -1
  77. package/dist/path/derived/derived-collection.utils.d.ts +3 -3
  78. package/dist/path/derived/derived-strategy.utils.d.ts +1 -1
  79. package/dist/path/meta/MetaController.d.ts +5 -5
  80. package/dist/path/meta/RaphMeta.d.ts +3 -3
  81. package/dist/path/meta/RaphMetaStore.d.ts +1 -1
  82. package/dist/path/meta/meta.types.d.ts +2 -2
  83. package/dist/path/path.types.d.ts +2 -2
  84. package/dist/path/pathSegmentKey.d.ts +1 -1
  85. package/dist/path/storage/AdapterPathStore.d.ts +2 -2
  86. package/dist/path/storage/DefaultDataAdapter.d.ts +2 -2
  87. package/dist/path/storage/PathEventHub.d.ts +1 -1
  88. package/dist/path/storage/PathStore.d.ts +2 -2
  89. package/dist/path/storage/data-adapter.types.d.ts +1 -1
  90. package/dist/raph.cjs +1 -1
  91. package/dist/raph.js +23 -21
  92. package/dist/reactivity/engine-core.d.ts +600 -0
  93. package/dist/reactivity/engine.d.ts +6 -550
  94. package/dist/reactivity/reactive-object.d.ts +143 -2
  95. package/dist/reactivity/scope.d.ts +7 -6
  96. package/dist/reactivity/types.d.ts +9 -12
  97. package/dist/reactivity/watch.d.ts +1 -1
  98. package/dist/runtime/RaphCompactExecutionRuntime.d.ts +7 -0
  99. package/dist/runtime/RaphExecutionRuntime.d.ts +6 -0
  100. package/dist/runtime/RaphRuntime.d.ts +19 -403
  101. package/dist/runtime/RaphRuntimeBase.d.ts +194 -0
  102. package/dist/runtime/diagnostics/RaphDebug.d.ts +8 -5
  103. package/dist/runtime/errors.d.ts +1 -1
  104. package/dist/runtime/ownership/RaphEffectScope.d.ts +13 -12
  105. package/dist/runtime/ownership/RaphNode.d.ts +28 -21
  106. package/dist/runtime/ownership/RaphScope.d.ts +32 -19
  107. package/dist/runtime/ownership/parent-graph.types.d.ts +1 -1
  108. package/dist/runtime/ownership/parentGraph.d.ts +2 -2
  109. package/dist/runtime/phases/RaphFrameLoop.d.ts +1 -1
  110. package/dist/runtime/phases/RaphPhasePipeline.d.ts +80 -29
  111. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +21 -21
  112. package/dist/runtime/phases/RaphPhaseWatch.d.ts +3 -3
  113. package/dist/runtime/phases/orderPhaseTasks.d.ts +4 -2
  114. package/dist/runtime/phases/phase.types.d.ts +36 -35
  115. package/dist/runtime/reactivity/PathHandle.d.ts +5 -5
  116. package/dist/runtime/reactivity/RaphMetaSource.d.ts +7 -7
  117. package/dist/runtime/reactivity/RaphSelector.d.ts +27 -6
  118. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +40 -39
  119. package/dist/runtime/reactivity/RuntimeObjectSupport.d.ts +9 -0
  120. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +27 -19
  121. package/dist/runtime/reactivity/RuntimeSelectorSupport.d.ts +10 -0
  122. package/dist/runtime/reactivity/RuntimeWatch.d.ts +1 -1
  123. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +1 -1
  124. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +3 -3
  125. package/dist/runtime.cjs +1 -1
  126. package/dist/runtime.js +13 -11
  127. package/package.json +22 -62
@@ -1,5 +1,5 @@
1
- import { Disposer } from '../../reactivity/types';
2
- import { RaphScope } from '../ownership/RaphScope';
1
+ import { Disposer } from '../../reactivity/types.js';
2
+ import { RaphScope } from '../ownership/RaphScope.js';
3
3
  export type RaphTraceKind = 'action' | 'error' | 'machine' | 'phase';
4
4
  export type RaphTraceGuardMode = 'all' | 'failed' | 'none';
5
5
  export type RaphTraceContextMode = 'keys' | 'none';
@@ -146,6 +146,7 @@ export interface RaphRuntimeDebug {
146
146
  * @internal
147
147
  */
148
148
  export declare class RaphDebugController {
149
+ private readonly _onTraceChange?;
149
150
  private _capacity;
150
151
  private _context;
151
152
  private _guards;
@@ -157,12 +158,13 @@ export declare class RaphDebugController {
157
158
  private _sequence;
158
159
  private _operationSequence;
159
160
  private _machines;
161
+ private readonly _traceTarget?;
160
162
  readonly trace: RaphDebugTraceApi;
161
163
  readonly machines: RaphDebugMachinesApi;
162
164
  /**
163
165
  * Создаёт controller; ring buffer появляется только при включённом trace.
164
166
  */
165
- constructor(options?: RaphDebugOptions);
167
+ constructor(options?: RaphDebugOptions, traceTarget?: object, _onTraceChange?: ((this: object) => void) | undefined);
166
168
  /**
167
169
  * Включает trace с текущими или явно переданными настройками.
168
170
  */
@@ -171,6 +173,7 @@ export declare class RaphDebugController {
171
173
  * Останавливает запись, сохраняя уже накопленные events.
172
174
  */
173
175
  stop(): void;
176
+ private _notifyTraceChange;
174
177
  /**
175
178
  * Удаляет все накопленные events, не меняя status trace.
176
179
  */
@@ -235,5 +238,5 @@ export declare class RaphDebugController {
235
238
  private _applyOptions;
236
239
  private _ensureBuffer;
237
240
  }
238
- export declare function createOwnerSnapshot(owner: RaphScope): RaphDebugOwnerSnapshot;
239
- export declare function createOwnerTree(owner: RaphScope, machinesByOwner?: ReadonlyMap<string, readonly RaphDebugTreeNode[]>): RaphDebugTreeNode;
241
+ export declare function createOwnerSnapshot(owner: RaphScope<any>): RaphDebugOwnerSnapshot;
242
+ export declare function createOwnerTree(owner: RaphScope<any>, machinesByOwner?: ReadonlyMap<string, readonly RaphDebugTreeNode[]>): RaphDebugTreeNode;
@@ -1,4 +1,4 @@
1
- import { RaphError } from '../api/errors';
1
+ import { RaphError } from '../api/errors.js';
2
2
  /**
3
3
  * Сообщает о записи вне action при включённом enforceActions.
4
4
  */
@@ -1,9 +1,10 @@
1
- import { Disposer } from '../../reactivity/types';
2
- import { RaphEffectGroup, RaphEffectGroupOptions, RaphEffectGroupSlot, RaphEffectOptions, RaphOwnerWatchSource, RaphPhaseBody, RaphPhaseEffect, RaphWatchOptions, RaphWatchSource } from '../phases/phase.types';
3
- import { RaphRuntime } from '../RaphRuntime';
4
- import { RaphScope } from './RaphScope';
1
+ import { Disposer } from '../../reactivity/types.js';
2
+ import { RaphEffectGroup, RaphEffectGroupOptions, RaphEffectGroupSlot, RaphEffectOptions, RaphOwnerWatchSource, RaphPhaseBody, RaphPhaseEffect, RaphWatchOptions, RaphWatchSource } from '../phases/phase.types.js';
3
+ import { RaphRuntime } from '../RaphRuntime.js';
4
+ import { RaphRuntimeBase } from '../RaphRuntimeBase.js';
5
+ import { RaphScope } from './RaphScope.js';
5
6
  /** Pauses phase deliveries without detaching dependencies or losing accumulated causes. */
6
- export declare class RaphEffectScope {
7
+ export declare class RaphEffectScope<Runtime extends RaphRuntimeBase<Runtime> = RaphRuntime> {
7
8
  private readonly _owner;
8
9
  private _registrations;
9
10
  private _pruneAt;
@@ -13,11 +14,11 @@ export declare class RaphEffectScope {
13
14
  private _disposed;
14
15
  private readonly _releaseOwner;
15
16
  private readonly _parent;
16
- constructor(_owner: RaphScope, parent?: RaphEffectScope | null);
17
+ constructor(_owner: RaphScope<Runtime>, parent?: RaphEffectScope<Runtime> | null);
17
18
  get paused(): boolean;
18
19
  get disposed(): boolean;
19
- fork(owner: RaphScope): RaphEffectScope;
20
- effect(phase: string, callback: RaphPhaseEffect, options?: RaphEffectOptions): Disposer;
20
+ fork(owner: RaphScope<Runtime>): RaphEffectScope<Runtime>;
21
+ effect(phase: string, callback: RaphPhaseEffect<Runtime>, options?: RaphEffectOptions): Disposer;
21
22
  /**
22
23
  * Регистрирует в этой группе phase effect без task и без disposer: тело
23
24
  * вызывается без аргументов, а binding живёт до освобождения группы или её
@@ -57,17 +58,17 @@ export declare class RaphEffectScope {
57
58
  * @param options `priority` task группы, как у `effect()`.
58
59
  */
59
60
  effectGroup<Context>(phase: string, count: number, runSlot: RaphEffectGroupSlot<Context>, context: Context, options?: RaphEffectGroupOptions): RaphEffectGroup;
60
- watch(source: RaphOwnerWatchSource, phase: string, callback: RaphPhaseEffect, options?: RaphWatchOptions): Disposer;
61
+ watch(source: RaphOwnerWatchSource<Runtime>, phase: string, callback: RaphPhaseEffect<Runtime>, options?: RaphWatchOptions): Disposer;
61
62
  /**
62
63
  * Внутренний путь renderer сохраняет pause ancestry и late-disposal tracking.
63
64
  * Возвращаемый disposer renderer не использует; регистрация остаётся у scope.
64
65
  * @internal
65
66
  */
66
- _registerEffect(phase: string, callback: RaphPhaseEffect, options: RaphEffectOptions, taskless: boolean, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
67
+ _registerEffect(phase: string, callback: RaphPhaseEffect<Runtime>, options: RaphEffectOptions, taskless: boolean, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
67
68
  /** @internal */
68
- _registerWatch(source: RaphWatchSource, phase: string, callback: RaphPhaseEffect, options: RaphWatchOptions, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
69
+ _registerWatch(source: RaphWatchSource<Runtime>, phase: string, callback: RaphPhaseEffect<Runtime>, options: RaphWatchOptions, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
69
70
  /** @internal */
70
- _registerEffectGroup<Context>(phase: string, count: number, runSlot: RaphEffectGroupSlot<Context>, context: Context, options?: RaphEffectGroupOptions): ReturnType<RaphRuntime['_effectGroupRegistration']>;
71
+ _registerEffectGroup<Context>(phase: string, count: number, runSlot: RaphEffectGroupSlot<Context>, context: Context, options?: RaphEffectGroupOptions): ReturnType<RaphRuntimeBase<Runtime>['_effectGroupRegistration']>;
71
72
  pause(): void;
72
73
  resume(): void;
73
74
  private _pause;
@@ -1,10 +1,11 @@
1
- import { DisposalFailure } from '../../reactivity/disposal';
2
- import { RaphRuntime } from '../RaphRuntime';
3
- import { RaphScope } from './RaphScope';
4
- export interface NodeOptions {
1
+ import { DisposalFailure } from '../../reactivity/disposal.js';
2
+ import { RaphRuntime } from '../RaphRuntime.js';
3
+ import { RaphRuntimeBase } from '../RaphRuntimeBase.js';
4
+ import { RaphScope } from './RaphScope.js';
5
+ export interface NodeOptions<Runtime extends RaphRuntimeBase<Runtime> = RaphRuntime> {
5
6
  readonly id?: string;
6
7
  readonly priority?: number;
7
- readonly parent?: RaphNode;
8
+ readonly parent?: RaphNode<unknown, Runtime>;
8
9
  readonly meta?: Readonly<Record<string, unknown>>;
9
10
  readonly type?: string;
10
11
  }
@@ -13,11 +14,11 @@ export interface NodeOptions {
13
14
  * полем `node`. Позволяет передать на удаление уже существующий массив записей
14
15
  * без копии в массив nodes.
15
16
  */
16
- export interface RaphNodeHolder {
17
- readonly node: RaphNode;
17
+ export interface RaphNodeHolder<Runtime extends RaphRuntimeBase<Runtime> = RaphRuntime> {
18
+ readonly node: RaphNode<unknown, Runtime>;
18
19
  }
19
20
  /** Scope with an explicit parent/children ownership position. */
20
- export declare class RaphNode<TApi = unknown> extends RaphScope {
21
+ export declare class RaphNode<TApi = unknown, Runtime extends RaphRuntimeBase<Runtime> = RaphRuntime> extends RaphScope<Runtime> {
21
22
  #private;
22
23
  priority: number;
23
24
  private _parent;
@@ -37,7 +38,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
37
38
  private _meta;
38
39
  type: string;
39
40
  private _subtreeIdentity;
40
- constructor(parent: RaphNode | RaphRuntime | null, options?: Omit<NodeOptions, 'parent'>, runtime?: RaphRuntime, publication?: never);
41
+ constructor(parent: RaphNode<unknown, Runtime> | Runtime | null, options?: Omit<NodeOptions<Runtime>, 'parent'>, runtime?: Runtime, publication?: never);
41
42
  /**
42
43
  * Возвращает id; номер id по умолчанию превращается в `node-N` при первом чтении.
43
44
  */
@@ -56,8 +57,14 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
56
57
  * @internal
57
58
  */
58
59
  get _subtreeSourceIdentity(): object;
59
- get node(): RaphNode<TApi>;
60
- get parent(): RaphNode | null;
60
+ get node(): RaphNode<TApi, Runtime>;
61
+ get parent(): RaphNode<unknown, Runtime> | null;
62
+ /**
63
+ * Сообщает, является ли `owner` строгим предком узла: тот же обход, что по
64
+ * `parent`, но по полям, без вызова getter на каждом шаге.
65
+ * @internal
66
+ */
67
+ _hasAncestor(owner: RaphScope<any>): boolean;
61
68
  /**
62
69
  * Возвращает прямых детей в их порядке. Массив действителен до следующей
63
70
  * структурной mutation этой node; после неё порядок даёт новое чтение.
@@ -82,8 +89,8 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
82
89
  * дети выходят из него на месте и при отсутствии подписчика на node, а после
83
90
  * последнего child он тоже пуст.
84
91
  */
85
- get children(): readonly RaphNode[];
86
- addChild(node: RaphNode): boolean;
92
+ get children(): readonly RaphNode<unknown, Runtime>[];
93
+ addChild(node: RaphNode<unknown, Runtime>): boolean;
87
94
  /**
88
95
  * Ставит прямых детей в порядок `nodes`: в нём каждый прямой child ровно
89
96
  * один раз. Без подписчика на node порядок проверяется и применяется по
@@ -93,7 +100,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
93
100
  * меняет дерево — элемент Proxy либо accessor, — не оставляет списки в
94
101
  * промежуточном состоянии: порядок проверяется по составу детей после чтения.
95
102
  */
96
- reorderChildren(nodes: readonly RaphNode[]): void;
103
+ reorderChildren(nodes: readonly RaphNode<unknown, Runtime>[]): void;
97
104
  /**
98
105
  * Ставит прямого child перед прямым child `before` либо в конец списка, если
99
106
  * `before === null`. Без подписчика на node меняются только связи самого
@@ -101,7 +108,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
101
108
  * child, чей индекс изменился, получает тот же structure cause, что и после
102
109
  * `reorderChildren` с итоговым порядком.
103
110
  */
104
- moveChild(child: RaphNode, before: RaphNode | null): void;
111
+ moveChild(child: RaphNode<unknown, Runtime>, before: RaphNode<unknown, Runtime> | null): void;
105
112
  /**
106
113
  * Меняет местами двух прямых детей. Без подписчика на node правятся только
107
114
  * связи этих детей и их соседей; с подписчиком оба child получают те же
@@ -109,7 +116,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
109
116
  *
110
117
  * @internal
111
118
  */
112
- _swapChildren(first: RaphNode, second: RaphNode): void;
119
+ _swapChildren(first: RaphNode<unknown, Runtime>, second: RaphNode<unknown, Runtime>): void;
113
120
  /**
114
121
  * Удаляет детей одной границей удаления и возвращает их ошибки вместо throw.
115
122
  *
@@ -146,8 +153,8 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
146
153
  */
147
154
  _disposeChildren(): unknown[] | undefined;
148
155
  /** @internal */
149
- _disposeChildren(holders: readonly RaphNodeHolder[], start?: number, end?: number): unknown[] | undefined;
150
- options(options: Pick<NodeOptions, 'meta' | 'priority' | 'type'>): void;
156
+ _disposeChildren(holders: readonly RaphNodeHolder<Runtime>[], start?: number, end?: number): unknown[] | undefined;
157
+ options(options: Pick<NodeOptions<Runtime>, 'meta' | 'priority' | 'type'>): void;
151
158
  /** Invalidates coarse self/subtree/runtime granules for non-reactive state. */
152
159
  touch(metadata?: unknown): void;
153
160
  remove(): void;
@@ -183,7 +190,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
183
190
  *
184
191
  * @internal
185
192
  */
186
- _collectDescendants(into: RaphScope[]): void;
193
+ _collectDescendants(into: RaphScope<any>[]): void;
187
194
  /**
188
195
  * Прибавляет к `totals` число ресурсов и sources самой node и всех её
189
196
  * потомков. Обход тот же, что у `_collectDescendants`, но владельцев он не
@@ -201,7 +208,7 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
201
208
  *
202
209
  * @internal
203
210
  */
204
- _findNode(id: string): RaphNode | undefined;
211
+ _findNode(id: string): RaphNode<unknown, Runtime> | undefined;
205
212
  /**
206
213
  * Применяет порядок детей `nodes`. Возвращает `false` и оставляет список
207
214
  * прежним, если `nodes` не содержит каждого живого прямого child ровно один
@@ -307,4 +314,4 @@ export declare class RaphNode<TApi = unknown> extends RaphScope {
307
314
  private _resetChildList;
308
315
  }
309
316
  /** Creates an unpublished node that Runtime.node() commits after setup. @internal */
310
- export declare function createProvisionalNode<TApi>(parent: RaphNode, options: Omit<NodeOptions, 'parent'>, runtime: RaphRuntime): RaphNode<TApi>;
317
+ export declare function createProvisionalNode<TApi, Runtime extends RaphRuntimeBase<Runtime>>(parent: RaphNode<unknown, Runtime>, options: Omit<NodeOptions<Runtime>, 'parent'>, runtime: Runtime): RaphNode<TApi, Runtime>;
@@ -1,24 +1,25 @@
1
- import { DisposalFailure } from '../../reactivity/disposal';
2
- import { OwnedSourceEntry, ScopeOwner } from '../../reactivity/scope';
3
- import { Disposer, OwnedResource, OwnedSource, ReadonlySignal, Signal, WritableComputedOptions } from '../../reactivity/types';
4
- import { RaphAggregateSource, RaphEffectGroup, RaphEffectGroupOptions, RaphEffectGroupSlot, RaphEffectOptions, RaphPhaseBody, RaphPhaseEffect, RaphWatchOptions, RaphWatchSource } from '../phases/phase.types';
5
- import { RaphRuntime } from '../RaphRuntime';
6
- import { RaphSelector, RaphSelectorOptions } from '../reactivity/RaphSelector';
7
- import { RaphAggregate } from '../reactivity/RaphWorkGraph';
8
- import { RaphNode } from './RaphNode';
1
+ import { DisposalFailure } from '../../reactivity/disposal.js';
2
+ import { OwnedSourceEntry, ScopeOwner } from '../../reactivity/scope.js';
3
+ import { Disposer, OwnedResource, OwnedSource, ReadonlySignal, Signal, WritableComputedOptions } from '../../reactivity/types.js';
4
+ import { RaphAggregateSource, RaphEffectGroup, RaphEffectGroupOptions, RaphEffectGroupSlot, RaphEffectOptions, RaphPhaseBody, RaphPhaseEffect, RaphWatchOptions, RaphWatchSource } from '../phases/phase.types.js';
5
+ import { RaphRuntime } from '../RaphRuntime.js';
6
+ import { RaphRuntimeBase } from '../RaphRuntimeBase.js';
7
+ import { RaphSelector, RaphSelectorOptions } from '../reactivity/RaphSelector.js';
8
+ import { RaphAggregate } from '../reactivity/RaphWorkGraph.js';
9
+ import { RaphNode } from './RaphNode.js';
9
10
  /**
10
11
  * Runtime owner. Список ресурсов, список источников и признаки lifetime
11
12
  * наследуются от ScopeOwner и лежат в самом владельце; standalone unphased
12
13
  * effect/watch класса ScopeNode Runtime-владелец намеренно не наследует.
13
14
  */
14
- export declare class RaphScope extends ScopeOwner {
15
+ export declare class RaphScope<Runtime extends RaphRuntimeBase<Runtime> = RaphRuntime> extends ScopeOwner {
15
16
  /**
16
17
  * Явный id либо числовой номер id по умолчанию, который RaphNode
17
18
  * форматирует при первом чтении `id`.
18
19
  * @internal
19
20
  */
20
21
  protected _id: string | number;
21
- readonly runtime: RaphRuntime;
22
+ readonly runtime: Runtime;
22
23
  /**
23
24
  * Порядковый номер регистрации владельца в его Runtime. Владельцы, пережившие
24
25
  * дерево root, Runtime при собственном освобождении обходит по этому номеру
@@ -32,18 +33,30 @@ export declare class RaphScope extends ScopeOwner {
32
33
  * @internal
33
34
  */
34
35
  readonly _isNode: boolean;
35
- constructor(id: string, runtime: RaphRuntime);
36
+ /**
37
+ * Тот же признак, что `disposed`, открытый для горячих проверок: pipeline
38
+ * читает поле владельца записи binding, а чтение signal и регистрация —
39
+ * оба признака lifetime, без вызова getter или _assertAlive().
40
+ * @internal
41
+ */
42
+ _disposed: boolean;
43
+ /**
44
+ * Признак идущего освобождения, открытый для тех же проверок.
45
+ * @internal
46
+ */
47
+ _disposing: boolean;
48
+ constructor(id: string, runtime: Runtime);
36
49
  /**
37
50
  * Числовой id зарезервирован за ленивым id по умолчанию у RaphNode.
38
51
  * @internal
39
52
  */
40
- constructor(id: string | number, runtime: RaphRuntime);
53
+ constructor(id: string | number, runtime: Runtime);
41
54
  /**
42
55
  * Возвращает id владельца; plain scope всегда хранит явную строку.
43
56
  */
44
57
  get id(): string;
45
58
  /** Stable selector for process ordering; plain scopes are not tree nodes. */
46
- get node(): RaphNode | undefined;
59
+ get node(): RaphNode<unknown, Runtime> | undefined;
47
60
  signal<T>(value: T): Signal<T>;
48
61
  computed<T>(getter: () => T): ReadonlySignal<T>;
49
62
  computed<T>(options: WritableComputedOptions<T>): Signal<T>;
@@ -59,8 +72,8 @@ export declare class RaphScope extends ScopeOwner {
59
72
  *
60
73
  * @typeParam Key — тип ключа и значения `source`.
61
74
  */
62
- selector<Key>(source: Signal<Key>, options?: RaphSelectorOptions<Key>): RaphSelector<Key>;
63
- effect(phase: string, callback: RaphPhaseEffect, options?: RaphEffectOptions): Disposer;
75
+ selector<Key>(source: Runtime['selectors'] extends false ? never : Signal<Key>, options?: RaphSelectorOptions<Key>): RaphSelector<Key>;
76
+ effect(phase: string, callback: RaphPhaseEffect<Runtime>, options?: RaphEffectOptions): Disposer;
64
77
  /**
65
78
  * Регистрирует phase effect без task и без disposer. Тело вызывается без
66
79
  * аргументов, а binding живёт до освобождения этого владельца: отдельно его
@@ -117,22 +130,22 @@ export declare class RaphScope extends ScopeOwner {
117
130
  * @param options `priority` task группы, как у `effect()`.
118
131
  */
119
132
  effectGroup<Context>(phase: string, count: number, runSlot: RaphEffectGroupSlot<Context>, context: Context, options?: RaphEffectGroupOptions): RaphEffectGroup;
120
- watch(source: RaphWatchSource, phase: string, callback: RaphPhaseEffect, options?: RaphWatchOptions): Disposer;
133
+ watch(source: RaphWatchSource<Runtime>, phase: string, callback: RaphPhaseEffect<Runtime>, options?: RaphWatchOptions): Disposer;
121
134
  /**
122
135
  * Внутренняя регистрация renderer без возвращаемого disposer. Failure
123
136
  * continuation относится только к завершившемуся execution request.
124
137
  * @internal
125
138
  */
126
- _registerEffect(phase: string, callback: RaphPhaseEffect, options: RaphEffectOptions, taskless: boolean, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
139
+ _registerEffect(phase: string, callback: RaphPhaseEffect<Runtime>, options: RaphEffectOptions, taskless: boolean, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
127
140
  /** @internal */
128
- _registerWatch(source: RaphWatchSource, phase: string, callback: RaphPhaseEffect, options: RaphWatchOptions, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
141
+ _registerWatch(source: RaphWatchSource<Runtime>, phase: string, callback: RaphPhaseEffect<Runtime>, options: RaphWatchOptions, onExecutionFailure: (error: unknown) => never, isExecutionCancelled?: () => boolean): void;
129
142
  /**
130
143
  * Выдаёт внутренний typed handle вместо приведения публичного group handle.
131
144
  * Порядок создания и принятия ресурса совпадает с effectGroup().
132
145
  * @internal
133
146
  */
134
147
  _registerEffectGroup<Context>(phase: string, count: number, runSlot: RaphEffectGroupSlot<Context>, context: Context, options?: RaphEffectGroupOptions): ReturnType<RaphRuntime['_effectGroupRegistration']>;
135
- aggregate(sources: readonly RaphAggregateSource[]): RaphAggregate;
148
+ aggregate(sources: readonly RaphAggregateSource<Runtime>[]): RaphAggregate<Runtime>;
136
149
  action<Args extends unknown[], Result>(operation: (...args: Args) => Result): (...args: Args) => Result;
137
150
  action<Args extends unknown[], Result>(name: string, operation: (...args: Args) => Result): (...args: Args) => Result;
138
151
  own(disposer: Disposer): Disposer;
@@ -1,4 +1,4 @@
1
- import { RaphNode } from './RaphNode';
1
+ import { RaphNode } from './RaphNode.js';
2
2
  export interface DepGraph<T extends RaphNode = RaphNode> {
3
3
  parentsOf: (node: T) => ReadonlySet<T>;
4
4
  }
@@ -1,3 +1,3 @@
1
- import { DepGraph } from './parent-graph.types';
2
- import { RaphNode } from './RaphNode';
1
+ import { DepGraph } from './parent-graph.types.js';
2
+ import { RaphNode } from './RaphNode.js';
3
3
  export declare function parentGraph<T extends RaphNode>(): DepGraph<T>;
@@ -1,4 +1,4 @@
1
- import { FrameLoopLease } from './phase.types';
1
+ import { FrameLoopLease } from './phase.types.js';
2
2
  /**
3
3
  * Ленивые frame callbacks не запускаются обычной реактивной работой.
4
4
  */
@@ -1,20 +1,22 @@
1
- import { RaphScope } from '../ownership/RaphScope';
2
- import { RuntimeReactivity } from '../reactivity/RuntimeReactivity';
3
- import { RaphFrameContext, RaphPhase, RaphPhaseEffect, RaphSchedulerMode, RaphWorkCause } from './phase.types';
4
- import { RaphPhaseTaskRecord } from './RaphPhaseTaskRecord';
1
+ import { RaphScope } from '../ownership/RaphScope.js';
2
+ import { RuntimeReactivity } from '../reactivity/RuntimeReactivity.js';
3
+ import { RaphFrameContext, RaphPhase, RaphPhaseEffect, RaphSchedulerMode, RaphWorkCause } from './phase.types.js';
4
+ import { RaphPhaseTaskRecord } from './RaphPhaseTaskRecord.js';
5
5
  /**
6
- * Постоянное состояние одной phase: живая очередь, запасной массив для обмена
7
- * при разборе и число bindings. Состояние переживает переопределение phases, пока
6
+ * Постоянное состояние одной phase: первый binding, хвост живой очереди,
7
+ * запасной массив для обмена при разборе и число bindings.
8
+ * Состояние переживает переопределение phases, пока
8
9
  * имя phase сохраняется, поэтому запись binding держит прямую ссылку на него и
9
10
  * ставится в очередь без поиска по имени. Через него же запись находит свой
10
11
  * pipeline: отдельной ссылки на pipeline у записи нет.
11
12
  *
12
- * Инвариант: каждая запись живой очереди активна и ожидает доставки, а
13
+ * Инвариант: first и каждая запись хвоста активны и ожидают доставки, а
13
14
  * `spare` пуст вне разбора своей phase.
14
15
  */
15
16
  export declare class RaphPhaseState {
16
17
  readonly name: string;
17
18
  readonly pipeline: RaphPhasePipeline;
19
+ first: RaphPhaseTaskRecord | undefined;
18
20
  queue: RaphPhaseTaskRecord[];
19
21
  spare: RaphPhaseTaskRecord[];
20
22
  bindings: number;
@@ -26,11 +28,18 @@ export declare class RaphPhasePipeline {
26
28
  private readonly _reactivity;
27
29
  private readonly _resolveCause;
28
30
  private readonly _deferSync;
29
- private readonly _tracePhase?;
31
+ private _tracePhase?;
30
32
  private _phases;
31
33
  private _phaseByName;
32
- private _resolvedInput;
33
- private _resolvedState;
34
+ /**
35
+ * Последнее разрешённое имя phase в том виде, в каком его передал вызывающий,
36
+ * и его состояние. Регистрация binding читает этот кэш сама, без вызова
37
+ * resolvePhase().
38
+ * @internal
39
+ */
40
+ _resolvedInput: string | undefined;
41
+ /** @internal */
42
+ _resolvedState: RaphPhaseState | undefined;
34
43
  private _queuedCount;
35
44
  private readonly _deferred;
36
45
  private readonly _idleWaiters;
@@ -52,11 +61,31 @@ export declare class RaphPhasePipeline {
52
61
  private _lastFrameAt;
53
62
  private _frameNumber;
54
63
  private _frame;
55
- constructor(_scheduler: RaphSchedulerMode, _reactivity: RuntimeReactivity, _resolveCause: (token: unknown) => RaphWorkCause | undefined, _deferSync?: () => boolean, _tracePhase?: ((phase: string, status: "end" | "error" | "start", error?: unknown) => void) | undefined);
64
+ private _publicFrames;
65
+ private _frameStale;
66
+ private _unmeasuredFrame;
67
+ private _firstReadFrame;
68
+ private _readPublicFrame;
69
+ private readonly _now;
70
+ constructor(_scheduler: RaphSchedulerMode, _reactivity: RuntimeReactivity, _resolveCause: (token: unknown) => RaphWorkCause<any> | undefined, _deferSync?: () => boolean, _tracePhase?: ((phase: string, status: "end" | "error" | "start", error?: unknown) => void) | undefined);
71
+ /** @internal */
72
+ _setPhaseTrace(trace: RaphPhasePipeline['_tracePhase']): void;
56
73
  get frame(): RaphFrameContext;
57
- get phases(): readonly RaphPhase[];
58
- definePhases(phases: readonly RaphPhase[]): void;
59
- addPhase(phase: RaphPhase): void;
74
+ private _readCurrentFrame;
75
+ private _exposeCurrentFrame;
76
+ /**
77
+ * Доставка может удерживать ещё не опубликованный снимок.
78
+ * @internal
79
+ */
80
+ _frameForDelivery(): RaphFrameContext;
81
+ /**
82
+ * Первое чтение включает заморозку всех последующих кадров.
83
+ * @internal
84
+ */
85
+ _exposeFrame(frame: RaphFrameContext): RaphFrameContext;
86
+ get phases(): readonly RaphPhase<any>[];
87
+ definePhases(phases: readonly RaphPhase<any>[]): void;
88
+ addPhase(phase: RaphPhase<any>): void;
60
89
  clearPhases(): void;
61
90
  /**
62
91
  * Находит состояние объявленной phase по имени, которое передал вызывающий.
@@ -70,7 +99,7 @@ export declare class RaphPhasePipeline {
70
99
  * Запись ничего не выполняет, пока вызывающий не подключит engine effect
71
100
  * (`node`) или watch lifecycle (`watch`).
72
101
  */
73
- bindTask(phase: RaphPhaseState, consumerOwner: RaphScope, effect: RaphPhaseEffect, priority: number): RaphPhaseTaskRecord;
102
+ bindTask(phase: RaphPhaseState, consumerOwner: RaphScope<any>, effect: RaphPhaseEffect<any>, priority: number): RaphPhaseTaskRecord;
74
103
  /**
75
104
  * Создаёт постоянную запись группы из `count` slots: одна запись binding и
76
105
  * её состояние с местом под запись графа каждого slot. Вызывающий уже
@@ -83,25 +112,31 @@ export declare class RaphPhasePipeline {
83
112
  * группы, где лежат её context и номер slot. Поэтому запись группы несёт
84
113
  * `TASK_TASKLESS`: вместо task тело получает поле `group`.
85
114
  */
86
- bindGroup(phase: RaphPhaseState, consumerOwner: RaphScope, runSlot: RaphPhaseEffect, context: unknown, count: number, priority: number): RaphPhaseTaskRecord;
115
+ bindGroup(phase: RaphPhaseState, consumerOwner: RaphScope<any>, runSlot: RaphPhaseEffect<any>, context: unknown, count: number, priority: number): RaphPhaseTaskRecord;
87
116
  request(): void;
88
117
  afterFlush(): Promise<void>;
89
118
  flush(): void;
90
- dispose(): void;
91
- _debugPending(): boolean;
92
- private _describeQueued;
93
119
  /**
94
- * Открывает доставку одной записью `state`. Накопленные причины остаются на
95
- * своих местах и становятся причинами доставки под TASK_CAUSES_DELIVERED:
96
- * ничего не копируется, а массив для `task.causes` строится, только если его
97
- * прочитают. Frame доставки получает только запись с facade: без facade его
98
- * нечем прочитать, а запись ссылки на новый frame в каждую доставленную
99
- * запись стоит write barrier.
120
+ * Raph Top-1: первая доставка нового binding в простаивающем sync pipeline.
121
+ * Запись встаёт в очередь так же, как через `_queue()`, и разбирается тем же
122
+ * проходом flush, но без цепочки engine schedule → `_schedule()` → пролог
123
+ * flush. False значит, что pipeline не простаивает: тогда вызывающий
124
+ * планирует запись обычным путём.
100
125
  *
101
- * Запись попадает сюда только из живой очереди, а в ней нет записей с
102
- * открытой доставкой, поэтому причин прошлой доставки здесь не бывает.
126
+ * @internal
103
127
  */
104
- private _beginDelivery;
128
+ _canDeliverFirst(record: RaphPhaseTaskRecord): boolean;
129
+ /**
130
+ * Выполняет первую доставку после положительного `_canDeliverFirst()`.
131
+ *
132
+ * @internal
133
+ */
134
+ _deliverFirst(record: RaphPhaseTaskRecord): void;
135
+ /** Основной проход flush: `_running` уже выставлен, frame выбран. */
136
+ private _drain;
137
+ dispose(): void;
138
+ _debugPending(): boolean;
139
+ private _describeQueued;
105
140
  /**
106
141
  * Исполняет открытую доставку binding. `failures` передаёт default runner:
107
142
  * группа складывает туда сбой каждого slot отдельно. Без него сбои slots
@@ -135,7 +170,7 @@ export declare class RaphPhasePipeline {
135
170
  /** @internal */
136
171
  _notifyTask(record: RaphPhaseTaskRecord, token: unknown): void;
137
172
  /** @internal */
138
- _appendCause(record: RaphPhaseTaskRecord, cause: RaphWorkCause, key: object): void;
173
+ _appendCause(record: RaphPhaseTaskRecord, cause: RaphWorkCause<any>, key: object): void;
139
174
  /**
140
175
  * Переносит причины открытой доставки с места ожидающих в detail, без
141
176
  * копирования, и освобождает это место. После вызова запись хранит оба
@@ -155,6 +190,8 @@ export declare class RaphPhasePipeline {
155
190
  * @internal
156
191
  */
157
192
  _disposeBinding(record: RaphPhaseTaskRecord): void;
193
+ /** Callback создаётся только на пути explicit watch после очистки record.watch. */
194
+ private _stopPhaseWatch;
158
195
  /**
159
196
  * Убирает из состояния группы slots, записи графа которых уже остановлены, и
160
197
  * сообщает, остались ли при этом живые slots.
@@ -215,9 +252,23 @@ export declare class RaphPhasePipeline {
215
252
  private _scheduleDeferredTurn;
216
253
  private _cancelScheduled;
217
254
  private _activateDeferred;
255
+ /** Flush без читателей frame: только номер кадра, без clock и снимка. */
256
+ private _skipFrame;
257
+ /**
258
+ * Вычисляет текущий кадр при первом чтении. История до него не записывалась,
259
+ * поэтому кадр считается первым измеренным: delta и elapsed равны нулю.
260
+ */
261
+ private _materializeFrame;
218
262
  private _nextFrame;
219
263
  private _assertRetainedPhases;
220
264
  private _hasPending;
265
+ /**
266
+ * Есть ли то, что изменит flush(): очередь, отложенные записи, запланированный
267
+ * turn или ожидающие afterFlush(). Без этого flush() ничего не делает.
268
+ *
269
+ * @internal
270
+ */
271
+ _hasPendingWork(): boolean;
221
272
  private _cancelAllQueued;
222
273
  private _cancelAllDeferred;
223
274
  private _acknowledgeDiscard;