effectable 1.0.0-canary.2 → 1.0.0
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.
- package/README.md +3 -9
- package/build/bootstrap/bootstrap.d.ts.map +1 -1
- package/build/bootstrap/bootstrap.js +6 -12
- package/build/bootstrap/bootstrap.js.map +1 -1
- package/build/bootstrap/types.d.ts +1 -7
- package/build/bootstrap/types.d.ts.map +1 -1
- package/build/component/GraphRuntime.d.ts +18 -226
- package/build/component/GraphRuntime.d.ts.map +1 -1
- package/build/component/GraphRuntime.js +211 -944
- package/build/component/GraphRuntime.js.map +1 -1
- package/build/component/context.d.ts +11 -3
- package/build/component/context.d.ts.map +1 -1
- package/build/component/context.js +23 -24
- package/build/component/context.js.map +1 -1
- package/build/component/h.d.ts +6 -14
- package/build/component/h.d.ts.map +1 -1
- package/build/component/h.js +1 -19
- package/build/component/h.js.map +1 -1
- package/build/component/refs.d.ts +5 -7
- package/build/component/refs.d.ts.map +1 -1
- package/build/component/refs.js +22 -45
- package/build/component/refs.js.map +1 -1
- package/build/component/types.d.ts +5 -16
- package/build/component/types.d.ts.map +1 -1
- package/build/component/types.js.map +1 -1
- package/build/connect/connect.d.ts.map +1 -1
- package/build/connect/connect.js +12 -3
- package/build/connect/connect.js.map +1 -1
- package/build/connect/types.d.ts +2 -2
- package/build/connect/types.d.ts.map +1 -1
- package/build/runtime/BusDecorators.d.ts +0 -6
- package/build/runtime/BusDecorators.d.ts.map +1 -1
- package/build/runtime/BusDecorators.js +56 -117
- package/build/runtime/BusDecorators.js.map +1 -1
- package/build/runtime/CommandBus.d.ts +1 -1
- package/build/runtime/CommandBus.d.ts.map +1 -1
- package/build/runtime/CommandBus.js +3 -6
- package/build/runtime/CommandBus.js.map +1 -1
- package/build/runtime/HandleRegistry.d.ts +1 -2
- package/build/runtime/HandleRegistry.d.ts.map +1 -1
- package/build/runtime/HandleRegistry.js +7 -38
- package/build/runtime/HandleRegistry.js.map +1 -1
- package/build/runtime/QueryBus.d.ts +1 -1
- package/build/runtime/QueryBus.d.ts.map +1 -1
- package/build/runtime/QueryBus.js +3 -6
- package/build/runtime/QueryBus.js.map +1 -1
- package/build/store/createStore.d.ts +2 -2
- package/build/store/createStore.d.ts.map +1 -1
- package/build/store/createStore.js +4 -31
- package/build/store/createStore.js.map +1 -1
- package/build/store/middleware.d.ts +1 -16
- package/build/store/middleware.d.ts.map +1 -1
- package/build/store/middleware.js +15 -16
- package/build/store/middleware.js.map +1 -1
- package/build/store/types.d.ts +4 -11
- package/build/store/types.d.ts.map +1 -1
- package/build/store/types.js.map +1 -1
- package/package.json +3 -10
package/README.md
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
# Effectable
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/effectable)
|
|
4
|
-
[](https://github.com/iamnikas/effectable/actions/workflows/ci.yml)
|
|
5
|
-
[](./LICENSE)
|
|
6
|
-
[](https://nodejs.org)
|
|
7
|
-
[](https://eslint.org)
|
|
8
|
-
|
|
9
3
|
Reactive layer library: explicit bootstrap-path, Redux-RxJS store, base class with lifecycle, class-based HOC `connect`, and GraphRuntime with a declarative component tree (`h`, `compose`).
|
|
10
4
|
|
|
11
5
|
## Installation
|
|
12
6
|
|
|
13
|
-
Requires **Node.js
|
|
7
|
+
Requires **Node.js 18.18+** and **npm 9+**.
|
|
14
8
|
|
|
15
9
|
```bash
|
|
16
10
|
npm install effectable
|
|
@@ -48,7 +42,7 @@ Architecture overview: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
|
|
48
42
|
|
|
49
43
|
- Creates `EventBus`, `CommandBus`, `QueryBus`, and `HandleRegistry` when the caller does not pass them explicitly.
|
|
50
44
|
- Mounts the root component via `GraphRuntime` (including ones wrapped with `connect`).
|
|
51
|
-
- Returns a handle with `shutdown()` for graceful teardown: calls `onUnmount`
|
|
45
|
+
- Returns a handle with `shutdown()` for graceful teardown: calls `onUnmount` in reverse order.
|
|
52
46
|
- On startup failure, automatically cleans up already created runtime primitives.
|
|
53
47
|
|
|
54
48
|
### Bootstrap-path example
|
|
@@ -161,7 +155,7 @@ fix: buffer setState during onMount
|
|
|
161
155
|
docs: clarify bootstrap shutdown
|
|
162
156
|
```
|
|
163
157
|
|
|
164
|
-
After `npm ci`, lefthook installs a local `commit-msg` hook. CI also lint-checks PR commits. Prefer Conventional Commits for squash-merge titles too.
|
|
158
|
+
After `npm ci`, lefthook installs a local `commit-msg` hook. CI also lint-checks PR commits. Prefer Conventional Commits for squash-merge titles too.
|
|
165
159
|
|
|
166
160
|
## Publishing
|
|
167
161
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAwC,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOzD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAgIjB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EACN,UAAU,SAAS,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAC1E,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChD,MAAM,SAAS,YAAY,GAAG,YAAY,EAC1C,MAAM,SAAS,YAAY,GAAG,YAAY,EAE1C,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAClC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,GACnD,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAwC,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOzD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAgIjB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EACN,UAAU,SAAS,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAC1E,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChD,MAAM,SAAS,YAAY,GAAG,YAAY,EAC1C,MAAM,SAAS,YAAY,GAAG,YAAY,EAE1C,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAClC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,GACnD,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CA0ExE"}
|
|
@@ -147,11 +147,6 @@ async function bootstrap(type, props, options) {
|
|
|
147
147
|
// graphRuntime and rootInstance are guaranteed non-null at this point (running === true).
|
|
148
148
|
const activeGraphRuntime = graphRuntime;
|
|
149
149
|
const activeRootInstance = rootInstance;
|
|
150
|
-
/**
|
|
151
|
-
* Cached shutdown promise for concurrent shutdown callers.
|
|
152
|
-
* Ensures that multiple concurrent shutdown() calls await the same work.
|
|
153
|
-
*/
|
|
154
|
-
let cachedShutdownPromise = null;
|
|
155
150
|
return {
|
|
156
151
|
name,
|
|
157
152
|
rootInstance: activeRootInstance,
|
|
@@ -167,18 +162,17 @@ async function bootstrap(type, props, options) {
|
|
|
167
162
|
}
|
|
168
163
|
await activeGraphRuntime.reconcile((0, component_1.h)(type, props));
|
|
169
164
|
},
|
|
170
|
-
async shutdown(
|
|
171
|
-
if (cachedShutdownPromise !== null) {
|
|
172
|
-
return cachedShutdownPromise;
|
|
173
|
-
}
|
|
165
|
+
async shutdown() {
|
|
174
166
|
if (!running) {
|
|
175
167
|
return;
|
|
176
168
|
}
|
|
177
169
|
running = false;
|
|
178
|
-
|
|
170
|
+
try {
|
|
171
|
+
await activeGraphRuntime.unmount();
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
179
174
|
clearOwnedRuntimePrimitives(runtime, owned);
|
|
180
|
-
}
|
|
181
|
-
return cachedShutdownPromise;
|
|
175
|
+
}
|
|
182
176
|
},
|
|
183
177
|
};
|
|
184
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAsKH,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAsKH,8BAoFC;AAxPD,4CAA+E;AAE/E,wCAKoB;AAapB,mCAGiB;AAEjB,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAgBjD;;;;;GAKG;AACH,SAAS,uBAAuB,CAK9B,eAA0F;IAK1F,MAAM,kBAAkB,GAAG,OAAO,eAAe,KAAK,WAAW;QAC/D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC;IAC/B,MAAM,gBAAgB,GAAG,OAAO,eAAe,KAAK,WAAW;QAC7D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,eAA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C;QACrD,CAAC;QACD,KAAK,CAAC,QAAQ;YACZ,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YAED,OAAO,GAAG,KAAK,CAAC;YAEhB,IAAI,CAAC;gBACH,MAAM,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACrC,CAAC;oBAAS,CAAC;gBACT,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -97,15 +97,9 @@ export interface BootstrapHandle<TComponent extends Component<unknown, TProps>,
|
|
|
97
97
|
reconcile(): Promise<void>;
|
|
98
98
|
/**
|
|
99
99
|
* Idempotently shuts down the root runtime: unmounts the tree and clears owned buses.
|
|
100
|
-
* Accepts optional `rejectOnCleanupError` to make teardown errors observable.
|
|
101
|
-
* Default behavior remains non-breaking: resolves even with cleanup errors.
|
|
102
100
|
*
|
|
103
|
-
* @param {object} [options] - shutdown options
|
|
104
|
-
* @param {boolean} [options.rejectOnCleanupError=false] - reject on cleanup errors
|
|
105
101
|
* @returns {Promise<void>}
|
|
106
102
|
*/
|
|
107
|
-
shutdown(
|
|
108
|
-
rejectOnCleanupError?: boolean;
|
|
109
|
-
}): Promise<void>;
|
|
103
|
+
shutdown(): Promise<void>;
|
|
110
104
|
}
|
|
111
105
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;CAG9B,CAAC;AACX,MAAM,MAA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AO,EAAE,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9D,kDAAkD;IAClD,QAAQ,EAAE,4BAA4B,CAAC;IACvC;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
|
|
@@ -4,14 +4,10 @@
|
|
|
4
4
|
* Responsibilities:
|
|
5
5
|
* - Materialize a VirtualServiceNode tree into real component instances (Fiber tree).
|
|
6
6
|
* - Fiber-like reconcile: diff current vs next trees by key + type, assign effectTags.
|
|
7
|
-
* Reconciliation mutates the live graph (not an isolated work-in-progress tree).
|
|
8
7
|
* - Drive lifecycle via LifecycleEngine: startup in topological order (children before parent),
|
|
9
|
-
* shutdown in
|
|
8
|
+
* shutdown in reverse order (parent before children).
|
|
10
9
|
* - Inject contexts (@UseContext) and bind refs on mount.
|
|
11
10
|
* - Pass updated props into existing instances during reconcile.
|
|
12
|
-
* - Serialize all graph operations through a single operation queue.
|
|
13
|
-
* - Fail-stop on unrecoverable errors: mark runtime FAILED, reject later reconcile,
|
|
14
|
-
* unmount stays safe.
|
|
15
11
|
*
|
|
16
12
|
* Current limitations:
|
|
17
13
|
* - Work loop is synchronous (no priority lanes — next increment).
|
|
@@ -26,22 +22,6 @@ import type { FiberEffectTag, FiberInspectNode, VirtualServiceNode } from './typ
|
|
|
26
22
|
import type { ContextScope } from './context';
|
|
27
23
|
import type { RuntimeCommand, RuntimeEvent, RuntimeQuery } from '../runtime/types';
|
|
28
24
|
import type { RuntimeBusesBundle } from '../runtime/BusDecorators';
|
|
29
|
-
/**
|
|
30
|
-
* Runtime state literals.
|
|
31
|
-
* Private to GraphRuntime; reduced set without mounting/reconciling.
|
|
32
|
-
*/
|
|
33
|
-
declare const RUNTIME_STATE: {
|
|
34
|
-
readonly IDLE: "idle";
|
|
35
|
-
readonly ACTIVE: "active";
|
|
36
|
-
readonly FAILED: "failed";
|
|
37
|
-
readonly UNMOUNTING: "unmounting";
|
|
38
|
-
readonly UNMOUNTED: "unmounted";
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Runtime state type derived from RUNTIME_STATE.
|
|
42
|
-
* Not exported from package index (internal diagnostic only).
|
|
43
|
-
*/
|
|
44
|
-
type RuntimeState = (typeof RUNTIME_STATE)[keyof typeof RUNTIME_STATE];
|
|
45
25
|
/**
|
|
46
26
|
* Runtime engine for a declarative component tree.
|
|
47
27
|
*
|
|
@@ -55,28 +35,13 @@ type RuntimeState = (typeof RUNTIME_STATE)[keyof typeof RUNTIME_STATE];
|
|
|
55
35
|
export declare class GraphRuntime {
|
|
56
36
|
/** Current root fiber tree (current tree). */
|
|
57
37
|
private currentRoot;
|
|
38
|
+
/** Whether unmount has completed. */
|
|
39
|
+
private unmounted;
|
|
58
40
|
/**
|
|
59
41
|
* Entry counter for {@link continueStableReconcileAsync} (test/debug probe).
|
|
60
42
|
* Not reset automatically — compare before/after around reconcile.
|
|
61
43
|
*/
|
|
62
44
|
private stableAsyncContinueCount;
|
|
63
|
-
/**
|
|
64
|
-
* Backing field for {@link GraphRuntime.state}. Writes and most reads go
|
|
65
|
-
* through the accessor; post-await re-reads use `_state` (TS 6 still narrows getters).
|
|
66
|
-
*/
|
|
67
|
-
private _state;
|
|
68
|
-
/**
|
|
69
|
-
* Runtime state machine.
|
|
70
|
-
* IDLE → ACTIVE (on mount) → FAILED | UNMOUNTING → UNMOUNTED.
|
|
71
|
-
* FAILED is terminal: subsequent reconcile rejects, unmount is safe.
|
|
72
|
-
*/
|
|
73
|
-
private get state();
|
|
74
|
-
private set state(value);
|
|
75
|
-
/**
|
|
76
|
-
* Terminal error captured by failStop().
|
|
77
|
-
* Stored to reject later reconcile calls with the same error.
|
|
78
|
-
*/
|
|
79
|
-
private terminalError;
|
|
80
45
|
/**
|
|
81
46
|
* Runtime buses for auto-wiring decorators on nodes (optional, set in {@link GraphRuntime.mount}).
|
|
82
47
|
*/
|
|
@@ -116,45 +81,10 @@ export declare class GraphRuntime {
|
|
|
116
81
|
* Set via the fourth argument of {@link GraphRuntime.mount}.
|
|
117
82
|
*/
|
|
118
83
|
private onAutoReconcileError;
|
|
119
|
-
/**
|
|
120
|
-
* Operation queue: serializes reconcile and unmount.
|
|
121
|
-
* Each operation is a Promise-returning function executed sequentially.
|
|
122
|
-
*/
|
|
123
|
-
private operationQueue;
|
|
124
|
-
/**
|
|
125
|
-
* Whether an operation is currently running.
|
|
126
|
-
*/
|
|
127
|
-
private operationInProgress;
|
|
128
|
-
/**
|
|
129
|
-
* Cached unmount promise for concurrent unmount callers.
|
|
130
|
-
*/
|
|
131
|
-
private cachedUnmountPromise;
|
|
132
|
-
/**
|
|
133
|
-
* Pending fail-stop teardown work.
|
|
134
|
-
* When failStop nulls currentRoot but destroy is async, this tracks the in-flight cleanup.
|
|
135
|
-
* unmount() must await this before concluding teardown is finished.
|
|
136
|
-
*/
|
|
137
|
-
private pendingTeardown;
|
|
138
84
|
/**
|
|
139
85
|
* Instances are created only via {@link GraphRuntime.mount}; direct `new GraphRuntime()` is unavailable externally.
|
|
140
86
|
*/
|
|
141
87
|
private constructor();
|
|
142
|
-
/**
|
|
143
|
-
* Fail-stop: mark the runtime as failed, disable scheduling, tear down the graph best-effort.
|
|
144
|
-
* After fail-stop:
|
|
145
|
-
* - state is FAILED
|
|
146
|
-
* - terminalError is set
|
|
147
|
-
* - currentRoot is null (even if destroyFiber throws)
|
|
148
|
-
* - later reconcile() rejects with the terminal error
|
|
149
|
-
* - unmount() is safe and joinable
|
|
150
|
-
*
|
|
151
|
-
* No failed reconcile leaves the runtime active with a partial graph.
|
|
152
|
-
* Primary-error rules: cleanup errors attached as rollbackErrors, never replace primary.
|
|
153
|
-
*
|
|
154
|
-
* @param {Error} error - unrecoverable error that triggered fail-stop
|
|
155
|
-
* @returns {void | Promise<void>}
|
|
156
|
-
*/
|
|
157
|
-
private failStop;
|
|
158
88
|
/**
|
|
159
89
|
* Auto-wires runtime-bus decorators onto the instance before {@link LifecycleEngine.runStartup}.
|
|
160
90
|
*
|
|
@@ -171,84 +101,6 @@ export declare class GraphRuntime {
|
|
|
171
101
|
* @returns {void}
|
|
172
102
|
*/
|
|
173
103
|
private disposeEffectableRuntimeBusWiring;
|
|
174
|
-
/**
|
|
175
|
-
* Identity-safe ref clearing: clears ref.current only if it still points to the expected owner.
|
|
176
|
-
* Prevents an old rollback from clearing a ref that a newer materialization already reused.
|
|
177
|
-
* No cast required (Component | null → unknown | null is assignable).
|
|
178
|
-
*
|
|
179
|
-
* @param {RefObject<unknown>} ref - ref object
|
|
180
|
-
* @param {Component<unknown, unknown>} expectedOwner - expected current owner
|
|
181
|
-
* @returns {void}
|
|
182
|
-
*/
|
|
183
|
-
private clearRefSafe;
|
|
184
|
-
/**
|
|
185
|
-
* Centralized ref ownership transition.
|
|
186
|
-
* Handles every ref binding/clearing operation: add, remove, replace.
|
|
187
|
-
*
|
|
188
|
-
* Rules:
|
|
189
|
-
* - Clear previousRef only if it still points to expectedPreviousOwner (identity-safe).
|
|
190
|
-
* - Bind nextRef to instance if nextRef is provided.
|
|
191
|
-
* - previousRef and nextRef can be the same object (ref reuse) or different (ref swap).
|
|
192
|
-
* - Do not let an old disposer clear a newer owner.
|
|
193
|
-
*
|
|
194
|
-
* No casts: Component | null → unknown | null is assignable (widening).
|
|
195
|
-
*
|
|
196
|
-
* @param {RefObject<unknown> | undefined} previousRef - ref to clear (can be undefined if no previous ref)
|
|
197
|
-
* @param {Component<unknown, unknown> | null} expectedPreviousOwner - expected owner of previousRef (null if unknown)
|
|
198
|
-
* @param {RefObject<unknown> | undefined} nextRef - ref to bind to instance (can be undefined if removing ref)
|
|
199
|
-
* @param {Component<unknown, unknown> | null} instance - instance to bind nextRef to (null when clearing only)
|
|
200
|
-
* @returns {void}
|
|
201
|
-
*/
|
|
202
|
-
private commitRef;
|
|
203
|
-
/**
|
|
204
|
-
* Finalize fiber destroy: dispose wiring, clear ref, update status.
|
|
205
|
-
* Collects errors when collectErrors is provided (best-effort cleanup).
|
|
206
|
-
* When collectErrors is null, errors are thrown immediately.
|
|
207
|
-
*
|
|
208
|
-
* Uses commitRef for identity-safe ref clearing.
|
|
209
|
-
*
|
|
210
|
-
* @param {RuntimeFiber<unknown>} fiber - fiber being finalized
|
|
211
|
-
* @param {Error[] | null} collectErrors - array to collect errors (null to throw)
|
|
212
|
-
* @returns {void}
|
|
213
|
-
*/
|
|
214
|
-
private finalizeFiberDestroy;
|
|
215
|
-
/**
|
|
216
|
-
* Transactional rollback for failed fiber materialization.
|
|
217
|
-
* Releases acquired resources in reverse acquisition order:
|
|
218
|
-
* 1. disable scheduler hook
|
|
219
|
-
* 2. dispose runtime bus registrations
|
|
220
|
-
* 3. clear bound ref (identity-safe)
|
|
221
|
-
* 4. run failed-startup cleanup
|
|
222
|
-
* 5. destroy mounted children in reverse order
|
|
223
|
-
* 6. unlink the partial fiber
|
|
224
|
-
* Cleanup is best-effort: one failure does not skip remaining steps.
|
|
225
|
-
* Preserves the original materialization error; cleanup errors are attached.
|
|
226
|
-
* Rollback is idempotent.
|
|
227
|
-
*
|
|
228
|
-
* @param {RuntimeFiber<P>} fiber - fiber being rolled back
|
|
229
|
-
* @param {Error} primaryError - original materialization/startup error
|
|
230
|
-
* @returns {void | Promise<void>}
|
|
231
|
-
*/
|
|
232
|
-
private rollbackFailedMaterialization;
|
|
233
|
-
/**
|
|
234
|
-
* Async continuation of rollback child destruction after one child's destroy returned a Promise.
|
|
235
|
-
*
|
|
236
|
-
* @param {RuntimeFiber<unknown>[]} children - mounted children
|
|
237
|
-
* @param {number} lastIdx - index of the last processed child
|
|
238
|
-
* @param {Promise<void>} pending - Promise from destroying the previous child
|
|
239
|
-
* @param {Error} primaryError - original materialization error
|
|
240
|
-
* @param {Error[]} cleanupErrors - accumulated cleanup errors
|
|
241
|
-
* @returns {Promise<void>}
|
|
242
|
-
*/
|
|
243
|
-
private continueRollbackDestroyAsync;
|
|
244
|
-
/**
|
|
245
|
-
* Attaches cleanup errors to the primary error and rethrows.
|
|
246
|
-
*
|
|
247
|
-
* @param {Error} primaryError - original materialization error
|
|
248
|
-
* @param {Error[]} cleanupErrors - cleanup errors
|
|
249
|
-
* @returns {never}
|
|
250
|
-
*/
|
|
251
|
-
private finalizeRollback;
|
|
252
104
|
/**
|
|
253
105
|
* Injects the scheduler hook onto the component instance after successful startup.
|
|
254
106
|
* The hook is called from {@link Component.setState} and enqueues the fiber for automatic reconcile.
|
|
@@ -286,34 +138,13 @@ export declare class GraphRuntime {
|
|
|
286
138
|
* - If an ancestor of the fiber is already queued → skip (ancestor covers the subtree).
|
|
287
139
|
* - If descendants of the fiber are queued → remove them (fiber covers their subtrees).
|
|
288
140
|
*
|
|
289
|
-
* Skip scheduling when runtime is FAILED.
|
|
290
|
-
*
|
|
291
141
|
* @param {RuntimeFiber<unknown>} fiber - fiber whose subtree needs rebuild
|
|
292
142
|
* @returns {void}
|
|
293
143
|
*/
|
|
294
144
|
private scheduleUpdate;
|
|
295
|
-
/**
|
|
296
|
-
* Enqueues an operation and starts the queue processor if idle.
|
|
297
|
-
* Operations are executed sequentially; concurrent callers await the same in-flight operation.
|
|
298
|
-
* Serialize all graph mutations.
|
|
299
|
-
*
|
|
300
|
-
* @param {() => Promise<void>} operation - operation to enqueue
|
|
301
|
-
* @returns {Promise<void>}
|
|
302
|
-
*/
|
|
303
|
-
private enqueueOperation;
|
|
304
|
-
/**
|
|
305
|
-
* Processes the operation queue: runs operations one at a time.
|
|
306
|
-
* Single serialized owner of tree mutations.
|
|
307
|
-
* Errors from individual operations are propagated to their callers but do not stop the queue.
|
|
308
|
-
*
|
|
309
|
-
* @returns {Promise<void>}
|
|
310
|
-
*/
|
|
311
|
-
private processOperationQueue;
|
|
312
145
|
/**
|
|
313
146
|
* Queues one dirty-flush microtask and publishes {@link activeFlush} for await from `reconcile`.
|
|
314
147
|
*
|
|
315
|
-
* Skip scheduling when runtime is FAILED.
|
|
316
|
-
*
|
|
317
148
|
* @returns {void}
|
|
318
149
|
*/
|
|
319
150
|
private scheduleDirtyFlushMicrotask;
|
|
@@ -323,9 +154,6 @@ export declare class GraphRuntime {
|
|
|
323
154
|
* Guarded by the `flushing` flag against re-entrancy.
|
|
324
155
|
* The chain of repeat passes is capped by {@link GRAPH_RUNTIME_MAX_DIRTY_FLUSH_PASSES}.
|
|
325
156
|
*
|
|
326
|
-
* Respects state (UNMOUNTING/UNMOUNTED/FAILED) to cancel flush when unmount begins or failure occurs.
|
|
327
|
-
* On unrecoverable error, invokes onAutoReconcileError then fail-stops.
|
|
328
|
-
*
|
|
329
157
|
* @returns {Promise<void>}
|
|
330
158
|
*/
|
|
331
159
|
private flushDirtyFibers;
|
|
@@ -352,35 +180,24 @@ export declare class GraphRuntime {
|
|
|
352
180
|
static mount<P = unknown>(root: VirtualServiceNode<P>, initialScope?: ContextScope, runtimeBuses?: RuntimeBusesBundle<RuntimeCommand, RuntimeQuery, RuntimeEvent>, onAutoReconcileError?: (err: unknown) => void): Promise<GraphRuntime>;
|
|
353
181
|
/**
|
|
354
182
|
* Reconciles against a new tree.
|
|
355
|
-
*
|
|
183
|
+
* Builds a work-in-progress tree, computes effectTags, applies changes:
|
|
356
184
|
* - PLACE: create and mount a new node
|
|
357
185
|
* - UPDATE: update props on an existing instance, call onUpdate
|
|
358
186
|
* - DELETE: unmount and destroy a node
|
|
359
187
|
*
|
|
360
|
-
* All reconcile calls are serialized through the operation queue.
|
|
361
|
-
* Rejects with terminal error when runtime is FAILED.
|
|
362
|
-
*
|
|
363
188
|
* @param {VirtualServiceNode<P>} nextTree - new virtual tree
|
|
364
189
|
* @returns {Promise<void>}
|
|
365
|
-
* @throws {Error} if the runtime
|
|
190
|
+
* @throws {Error} if the runtime is already unmounted
|
|
366
191
|
*/
|
|
367
192
|
reconcile<P = unknown>(nextTree: VirtualServiceNode<P>): Promise<void>;
|
|
368
193
|
/**
|
|
369
194
|
* Fully unmounts the component tree.
|
|
370
|
-
* Calls onUnmount for each node (children before parent) and
|
|
195
|
+
* Calls onUnmount for each node in reverse order (children before parent) and
|
|
371
196
|
* moves stages to destroyed via LifecycleEngine.
|
|
372
197
|
*
|
|
373
|
-
* Unmount is serialized, cached promise returned for concurrent callers.
|
|
374
|
-
* Safe and joinable even when runtime is FAILED.
|
|
375
|
-
* Collects cleanup errors when `rejectOnCleanupError: true` is passed.
|
|
376
|
-
*
|
|
377
|
-
* @param {object} [options] - unmount options
|
|
378
|
-
* @param {boolean} [options.rejectOnCleanupError=false] - reject on cleanup errors
|
|
379
198
|
* @returns {Promise<void>}
|
|
380
199
|
*/
|
|
381
|
-
unmount(
|
|
382
|
-
rejectOnCleanupError?: boolean;
|
|
383
|
-
}): Promise<void>;
|
|
200
|
+
unmount(): Promise<void>;
|
|
384
201
|
/**
|
|
385
202
|
* Returns the root component instance (for testing and introspection).
|
|
386
203
|
*
|
|
@@ -388,8 +205,7 @@ export declare class GraphRuntime {
|
|
|
388
205
|
*/
|
|
389
206
|
getRootInstance(): Component<unknown, unknown> | null;
|
|
390
207
|
/**
|
|
391
|
-
* Whether the runtime is active (
|
|
392
|
-
* Returns false when state is FAILED.
|
|
208
|
+
* Whether the runtime is active (unmount has not been called).
|
|
393
209
|
*
|
|
394
210
|
* @returns {boolean}
|
|
395
211
|
*/
|
|
@@ -416,13 +232,6 @@ export declare class GraphRuntime {
|
|
|
416
232
|
* @returns {number} accumulated counter
|
|
417
233
|
*/
|
|
418
234
|
getStableAsyncContinueCount(): number;
|
|
419
|
-
/**
|
|
420
|
-
* Current runtime state.
|
|
421
|
-
* Test/debug probe; not a production API.
|
|
422
|
-
*
|
|
423
|
-
* @returns {RuntimeState} current state
|
|
424
|
-
*/
|
|
425
|
-
getState(): RuntimeState;
|
|
426
235
|
/**
|
|
427
236
|
* Builds a deep readonly {@link FiberInspectNode} from a RuntimeFiber.
|
|
428
237
|
*
|
|
@@ -454,7 +263,7 @@ export declare class GraphRuntime {
|
|
|
454
263
|
* @param {LifecycleEngine} engine - lifecycle engine
|
|
455
264
|
* @param {VirtualServiceNode<P>} vnode - virtual node
|
|
456
265
|
* @param {VirtualServiceNode[]} childVnodes - all child vnodes
|
|
457
|
-
* @param {
|
|
266
|
+
* @param {RuntimeFiber<unknown>[]} childFibers - already materialized child fibers
|
|
458
267
|
* @param {Promise<RuntimeFiber<unknown>>} pending - Promise for the current child
|
|
459
268
|
* @param {number} pendingIdx - index of the current child
|
|
460
269
|
* @returns {Promise<RuntimeFiber<P>>}
|
|
@@ -466,10 +275,19 @@ export declare class GraphRuntime {
|
|
|
466
275
|
* @template P node props type
|
|
467
276
|
* @param {RuntimeFiber<P>} fiber - fiber of the subtree root node
|
|
468
277
|
* @param {LifecycleEngine} engine - lifecycle engine for this node
|
|
278
|
+
* @param {RuntimeFiber<unknown>[]} childFibers - already mounted child fibers (for rollback on error)
|
|
469
279
|
* @param {PromiseLike<import('./lifecycle').LifecycleTransitionResult>} pendingStartup - Promise of the `runStartup` result
|
|
470
280
|
* @returns {Promise<RuntimeFiber<P>>} ready fiber, or rollback children and rethrow
|
|
471
281
|
*/
|
|
472
282
|
private finalizeMaterializeAsync;
|
|
283
|
+
/**
|
|
284
|
+
* Unmounts already-mounted children when parent startup fails.
|
|
285
|
+
* Returns sync void if all demounts are sync, otherwise a Promise.
|
|
286
|
+
*
|
|
287
|
+
* @param {RuntimeFiber<unknown>[]} childFibers
|
|
288
|
+
* @returns {void | Promise<void>}
|
|
289
|
+
*/
|
|
290
|
+
private destroyChildrenOnError;
|
|
473
291
|
/**
|
|
474
292
|
* Runs fiber-like reconcile for a single node.
|
|
475
293
|
* If type and key match — UPDATE: update props, reconcile children.
|
|
@@ -544,35 +362,15 @@ export declare class GraphRuntime {
|
|
|
544
362
|
* @returns {Promise<RuntimeFiber<unknown>[]>}
|
|
545
363
|
*/
|
|
546
364
|
private continueStableReconcileAsync;
|
|
547
|
-
/**
|
|
548
|
-
* Validates that sibling keys are unique within a list.
|
|
549
|
-
* Follows React v16.5 keyed child reconciliation contract: duplicate keys are invalid.
|
|
550
|
-
* Throws a descriptive error including the duplicate key and parent component identity.
|
|
551
|
-
*
|
|
552
|
-
* @param {Array<{ vnode: { key?: string }; instance?: Component<unknown, unknown> | null }>} items - list of fibers or vnodes
|
|
553
|
-
* @param {RuntimeFiber<unknown>} parentFiber - parent fiber (for error message)
|
|
554
|
-
* @param {string} listName - "current" or "next" (for error message)
|
|
555
|
-
* @returns {void}
|
|
556
|
-
* @throws {Error} when duplicate keys are detected
|
|
557
|
-
*/
|
|
558
|
-
private validateUniqueKeys;
|
|
559
365
|
/**
|
|
560
366
|
* Full-diff reconcile: keyed/unkeyed Map + destroy orphans.
|
|
561
367
|
* Always async — internal branching is too complex for an efficient sync path.
|
|
562
368
|
*
|
|
563
|
-
* Contract: Sibling keys must be unique (React v16.5 keyed child reconciliation).
|
|
564
|
-
* Validates both current and next children BEFORE any side effects.
|
|
565
|
-
* Throws deterministic error on duplicate keys to prevent lifecycle leaks.
|
|
566
|
-
*
|
|
567
|
-
* HOLE 3: On throw during PLACE, cleans up previously placed new nodes
|
|
568
|
-
* to prevent lifecycle leaks. Uses identity-safe check against currentChildren Set.
|
|
569
|
-
*
|
|
570
369
|
* @param {RuntimeFiber<unknown>[]} currentChildren - current child fibers
|
|
571
370
|
* @param {VirtualServiceNode[]} nextVnodes - new vnodes
|
|
572
371
|
* @param {RuntimeFiber<unknown>} parentFiber - parent fiber
|
|
573
372
|
* @param {ContextScope} childScope - children scope
|
|
574
373
|
* @returns {Promise<RuntimeFiber<unknown>[]>}
|
|
575
|
-
* @throws {Error} when duplicate keys are detected in current or next children
|
|
576
374
|
*/
|
|
577
375
|
private reconcileChildrenFullDiff;
|
|
578
376
|
/**
|
|
@@ -608,10 +406,7 @@ export declare class GraphRuntime {
|
|
|
608
406
|
* Returns `void` synchronously if the whole subtree is sync (up to 266x speedup
|
|
609
407
|
* on an 85-node tree); otherwise a Promise. `await` works correctly with either union branch.
|
|
610
408
|
*
|
|
611
|
-
* Collects cleanup errors via `collectErrors` parameter (best-effort cleanup).
|
|
612
|
-
*
|
|
613
409
|
* @param {RuntimeFiber} fiber - fiber to destroy
|
|
614
|
-
* @param {Error[] | null} collectErrors - array to collect cleanup errors (null to throw immediately)
|
|
615
410
|
* @returns {void | Promise<void>}
|
|
616
411
|
*/
|
|
617
412
|
private destroyFiber;
|
|
@@ -622,7 +417,6 @@ export declare class GraphRuntime {
|
|
|
622
417
|
* @param {Fiber[]} children - children list
|
|
623
418
|
* @param {number} pendingIdx - index of the pending child
|
|
624
419
|
* @param {PromiseLike<void>} pending - Promise from destroying the child
|
|
625
|
-
* @param {Error[] | null} collectErrors - array to collect cleanup errors
|
|
626
420
|
* @returns {Promise<void>}
|
|
627
421
|
*/
|
|
628
422
|
private continueDestroyAsync;
|
|
@@ -632,7 +426,6 @@ export declare class GraphRuntime {
|
|
|
632
426
|
*
|
|
633
427
|
* @param {RuntimeFiber<unknown>} fiber
|
|
634
428
|
* @param {PromiseLike<unknown>} pendingShutdown
|
|
635
|
-
* @param {Error[] | null} collectErrors - array to collect cleanup errors
|
|
636
429
|
* @returns {Promise<void>}
|
|
637
430
|
*/
|
|
638
431
|
private finalizeDestroyAsync;
|
|
@@ -661,5 +454,4 @@ export declare class GraphRuntime {
|
|
|
661
454
|
* @returns {FiberEffectTag}
|
|
662
455
|
*/
|
|
663
456
|
export declare function makeFiberEffectTag(tag: FiberEffectTag): FiberEffectTag;
|
|
664
|
-
export {};
|
|
665
457
|
//# sourceMappingURL=GraphRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../src/component/GraphRuntime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../src/component/GraphRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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