effectable 0.1.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/LICENSE +21 -0
- package/README.md +157 -0
- package/build/LICENSE +21 -0
- package/build/bootstrap/bootstrap.d.ts +32 -0
- package/build/bootstrap/bootstrap.d.ts.map +1 -0
- package/build/bootstrap/bootstrap.js +179 -0
- package/build/bootstrap/bootstrap.js.map +1 -0
- package/build/bootstrap/index.d.ts +9 -0
- package/build/bootstrap/index.d.ts.map +1 -0
- package/build/bootstrap/index.js +14 -0
- package/build/bootstrap/index.js.map +1 -0
- package/build/bootstrap/types.d.ts +105 -0
- package/build/bootstrap/types.d.ts.map +1 -0
- package/build/bootstrap/types.js +26 -0
- package/build/bootstrap/types.js.map +1 -0
- package/build/component/Component.d.ts +126 -0
- package/build/component/Component.d.ts.map +1 -0
- package/build/component/Component.js +123 -0
- package/build/component/Component.js.map +1 -0
- package/build/component/GraphRuntime.d.ts +457 -0
- package/build/component/GraphRuntime.d.ts.map +1 -0
- package/build/component/GraphRuntime.js +1168 -0
- package/build/component/GraphRuntime.js.map +1 -0
- package/build/component/constants.d.ts +1 -0
- package/build/component/constants.d.ts.map +1 -0
- package/build/component/constants.js +2 -0
- package/build/component/constants.js.map +1 -0
- package/build/component/context.d.ts +199 -0
- package/build/component/context.d.ts.map +1 -0
- package/build/component/context.js +262 -0
- package/build/component/context.js.map +1 -0
- package/build/component/graphRuntime.constants.d.ts +13 -0
- package/build/component/graphRuntime.constants.d.ts.map +1 -0
- package/build/component/graphRuntime.constants.js +15 -0
- package/build/component/graphRuntime.constants.js.map +1 -0
- package/build/component/h.d.ts +48 -0
- package/build/component/h.d.ts.map +1 -0
- package/build/component/h.js +72 -0
- package/build/component/h.js.map +1 -0
- package/build/component/index.d.ts +19 -0
- package/build/component/index.d.ts.map +1 -0
- package/build/component/index.js +39 -0
- package/build/component/index.js.map +1 -0
- package/build/component/lifecycle.d.ts +179 -0
- package/build/component/lifecycle.d.ts.map +1 -0
- package/build/component/lifecycle.js +367 -0
- package/build/component/lifecycle.js.map +1 -0
- package/build/component/refs.d.ts +105 -0
- package/build/component/refs.d.ts.map +1 -0
- package/build/component/refs.js +128 -0
- package/build/component/refs.js.map +1 -0
- package/build/component/types.d.ts +169 -0
- package/build/component/types.d.ts.map +1 -0
- package/build/component/types.js +40 -0
- package/build/component/types.js.map +1 -0
- package/build/connect/connect.d.ts +31 -0
- package/build/connect/connect.d.ts.map +1 -0
- package/build/connect/connect.js +500 -0
- package/build/connect/connect.js.map +1 -0
- package/build/connect/index.d.ts +8 -0
- package/build/connect/index.d.ts.map +1 -0
- package/build/connect/index.js +11 -0
- package/build/connect/index.js.map +1 -0
- package/build/connect/types.d.ts +90 -0
- package/build/connect/types.d.ts.map +1 -0
- package/build/connect/types.js +8 -0
- package/build/connect/types.js.map +1 -0
- package/build/index.d.ts +26 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +60 -0
- package/build/index.js.map +1 -0
- package/build/runtime/BusDecorators.d.ts +113 -0
- package/build/runtime/BusDecorators.d.ts.map +1 -0
- package/build/runtime/BusDecorators.js +302 -0
- package/build/runtime/BusDecorators.js.map +1 -0
- package/build/runtime/CommandBus.d.ts +43 -0
- package/build/runtime/CommandBus.d.ts.map +1 -0
- package/build/runtime/CommandBus.js +65 -0
- package/build/runtime/CommandBus.js.map +1 -0
- package/build/runtime/EventBus.d.ts +50 -0
- package/build/runtime/EventBus.d.ts.map +1 -0
- package/build/runtime/EventBus.js +90 -0
- package/build/runtime/EventBus.js.map +1 -0
- package/build/runtime/HandleRegistry.d.ts +143 -0
- package/build/runtime/HandleRegistry.d.ts.map +1 -0
- package/build/runtime/HandleRegistry.js +244 -0
- package/build/runtime/HandleRegistry.js.map +1 -0
- package/build/runtime/QueryBus.d.ts +43 -0
- package/build/runtime/QueryBus.d.ts.map +1 -0
- package/build/runtime/QueryBus.js +65 -0
- package/build/runtime/QueryBus.js.map +1 -0
- package/build/runtime/index.d.ts +13 -0
- package/build/runtime/index.d.ts.map +1 -0
- package/build/runtime/index.js +32 -0
- package/build/runtime/index.js.map +1 -0
- package/build/runtime/types.d.ts +79 -0
- package/build/runtime/types.d.ts.map +1 -0
- package/build/runtime/types.js +8 -0
- package/build/runtime/types.js.map +1 -0
- package/build/store/createStore.d.ts +36 -0
- package/build/store/createStore.d.ts.map +1 -0
- package/build/store/createStore.js +131 -0
- package/build/store/createStore.js.map +1 -0
- package/build/store/index.d.ts +14 -0
- package/build/store/index.d.ts.map +1 -0
- package/build/store/index.js +39 -0
- package/build/store/index.js.map +1 -0
- package/build/store/middleware.d.ts +38 -0
- package/build/store/middleware.d.ts.map +1 -0
- package/build/store/middleware.js +99 -0
- package/build/store/middleware.js.map +1 -0
- package/build/store/selector.d.ts +62 -0
- package/build/store/selector.d.ts.map +1 -0
- package/build/store/selector.js +226 -0
- package/build/store/selector.js.map +1 -0
- package/build/store/semanticStateTree.d.ts +91 -0
- package/build/store/semanticStateTree.d.ts.map +1 -0
- package/build/store/semanticStateTree.js +263 -0
- package/build/store/semanticStateTree.js.map +1 -0
- package/build/store/types.d.ts +259 -0
- package/build/store/types.d.ts.map +1 -0
- package/build/store/types.js +28 -0
- package/build/store/types.js.map +1 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Nick Nask, also known as Nikita Neskuchaev (iamnikas)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Effectable
|
|
2
|
+
|
|
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`).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Requires **Node.js 18.18+** and **npm 9+**.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install effectable
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { bootstrap, connect, createStore, Component, h } from 'effectable';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Subpackages: `effectable/bootstrap`, `effectable/store`, `effectable/component`, `effectable/connect`, `effectable/runtime`.
|
|
18
|
+
|
|
19
|
+
## Structure
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Effectable/
|
|
23
|
+
├── src/
|
|
24
|
+
│ ├── index.ts # Re-exports bootstrap, store, component, connect, runtime
|
|
25
|
+
│ ├── bootstrap/ # Explicit root bootstrap, runtime handle, and default runtime primitives
|
|
26
|
+
│ ├── store/ # Redux-RxJS store (createStore, select, state$)
|
|
27
|
+
│ ├── component/ # Lifecycle, Component (state, setState, onMount, onUpdate, onUnmount), GraphRuntime, refs, context
|
|
28
|
+
│ ├── connect/ # connect(store, mapStateToProps)(MyClass) -> ConnectedClass (class-based HOC)
|
|
29
|
+
│ └── runtime/ # EventBus, CommandBus, QueryBus, HandleRegistry, BusDecorators
|
|
30
|
+
├── tests/ # Unit and integration Jest tests
|
|
31
|
+
├── benchmarks/ # Performance suites (`npm run bench`)
|
|
32
|
+
├── docs/ # Architecture notes (`docs/ARCHITECTURE.md`)
|
|
33
|
+
└── examples/ # Usage examples outside production build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Architecture overview: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Bootstrap
|
|
40
|
+
|
|
41
|
+
`bootstrap(...)` — explicit root runtime entry contract.
|
|
42
|
+
|
|
43
|
+
- Creates `EventBus`, `CommandBus`, `QueryBus`, and `HandleRegistry` when the caller does not pass them explicitly.
|
|
44
|
+
- Mounts the root component via `GraphRuntime` (including ones wrapped with `connect`).
|
|
45
|
+
- Returns a handle with `shutdown()` for graceful teardown: calls `onUnmount` in reverse order.
|
|
46
|
+
- On startup failure, automatically cleans up already created runtime primitives.
|
|
47
|
+
|
|
48
|
+
### Bootstrap-path example
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { bootstrap, connect } from 'effectable';
|
|
52
|
+
import { AppRoot, mapStateToProps } from './app';
|
|
53
|
+
import { store } from './store';
|
|
54
|
+
|
|
55
|
+
const ConnectedAppRoot = connect(store, mapStateToProps)(AppRoot);
|
|
56
|
+
|
|
57
|
+
const handle = await bootstrap(
|
|
58
|
+
ConnectedAppRoot,
|
|
59
|
+
{ /* refs, handles — BUT NOT store */ },
|
|
60
|
+
{ name: 'app.root' },
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
await handle.shutdown(); // graceful teardown via onUnmount
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Host application roles
|
|
67
|
+
|
|
68
|
+
In a consuming app, keep process concerns outside Effectable:
|
|
69
|
+
|
|
70
|
+
1. **Process entry** — env/config, signal handlers, infrastructure adapters, then `bootstrap(...)`.
|
|
71
|
+
2. **Root component** — extends `Component`, implements `compose()`, optional `onMount`/`onUnmount`; wrap with `connect(store, map)(Root)` so the store is injected by the HOC, not via props.
|
|
72
|
+
3. On shutdown call `handle.shutdown()`.
|
|
73
|
+
|
|
74
|
+
## Control plane / data plane boundary
|
|
75
|
+
|
|
76
|
+
- **Control plane**: `bootstrap`, lifecycle orchestration (`onMount`/`onUnmount`), reconcile, context resolution, HOC `connect`.
|
|
77
|
+
- **Data plane**: latency-sensitive work on an already-mounted graph.
|
|
78
|
+
|
|
79
|
+
Rules:
|
|
80
|
+
|
|
81
|
+
- `compose()`, reconcile, and context resolution must not sit on the hot execution path.
|
|
82
|
+
- Data-plane components use direct refs and pre-resolved handles for the fast path.
|
|
83
|
+
- `GraphRuntime` manages lifecycle; it is not meant to run on every high-frequency tick.
|
|
84
|
+
|
|
85
|
+
## Store
|
|
86
|
+
|
|
87
|
+
See [src/store/README.md](src/store/README.md): creating a store, selectors, middleware, `state$`, `select()`.
|
|
88
|
+
|
|
89
|
+
## Component and connect
|
|
90
|
+
|
|
91
|
+
Pattern for wiring a class to the store without manual subscriptions: reactive `state`, lifecycle hooks, automatic unsubscribe on unmount.
|
|
92
|
+
|
|
93
|
+
### Lifecycle
|
|
94
|
+
|
|
95
|
+
- **onMount** — once when the node mounts (start subscriptions, timers, background work).
|
|
96
|
+
- **onUpdate(prev, next)** — on every state update (from `setState`; in a connected class also on every store emit).
|
|
97
|
+
- **onUnmount** — once when the node unmounts (tear down subscriptions, stop effects).
|
|
98
|
+
|
|
99
|
+
A connected class with `mapStateToProps` receives **one deferred** `onUpdate` after mount
|
|
100
|
+
(post-mount kick-off) — see the migration note in [src/connect/README.md](src/connect/README.md).
|
|
101
|
+
`setState` inside `onMount` in GraphRuntime buffers subtree reconcile and applies it after
|
|
102
|
+
startup (same idea as deferring an update until after the mount pass completes).
|
|
103
|
+
|
|
104
|
+
### Example: class and connect
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { createStore } from 'effectable/store';
|
|
108
|
+
import { Component } from 'effectable/component';
|
|
109
|
+
import { connect } from 'effectable/connect';
|
|
110
|
+
|
|
111
|
+
interface AppState { status: string }
|
|
112
|
+
interface Props { id: string; status?: string }
|
|
113
|
+
|
|
114
|
+
class MyServiceRaw extends Component<never, Props> {
|
|
115
|
+
public override onMount (): void {
|
|
116
|
+
console.log('Mounting, status:', this.props.status);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public override onUpdate (_prev: never, _next: never): void {
|
|
120
|
+
console.log('status updated:', this.props.status);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public override onUnmount (): void {
|
|
124
|
+
console.log('Unmounting, tear down subscriptions');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const store = createStore(reducer, initialState);
|
|
129
|
+
const mapStateToProps = (state: AppState) => ({ status: state.status });
|
|
130
|
+
|
|
131
|
+
export const MyService = connect(store, mapStateToProps)(MyServiceRaw);
|
|
132
|
+
|
|
133
|
+
// in the parent's compose():
|
|
134
|
+
// h(MyService, { id: '1' })
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`store` is passed into the HOC `connect` (closure) and MUST NOT appear in the component `props`.
|
|
138
|
+
|
|
139
|
+
## Entry points
|
|
140
|
+
|
|
141
|
+
- `effectable` — canonical public entrypoint (`bootstrap`, store, component, connect, runtime)
|
|
142
|
+
- `effectable/bootstrap` — explicit root bootstrap-path
|
|
143
|
+
- `effectable/store` — store
|
|
144
|
+
- `effectable/component` — Component, Lifecycle, GraphRuntime, h, refs, context
|
|
145
|
+
- `effectable/connect` — connect, MapStateToProps, ConnectOptions
|
|
146
|
+
- `effectable/runtime` — EventBus, CommandBus, QueryBus, HandleRegistry, BusDecorators (`wireRuntimeBuses`, **`wireRuntimeBusesAll`** — wire several handlers to the same bus set; process code usually reuses the same `commandBus` / `queryBus` / `eventBus` as `bootstrap(...).runtime`, without a second `createRuntimeBuses` / `HandleRegistry`)
|
|
147
|
+
|
|
148
|
+
## Publishing
|
|
149
|
+
|
|
150
|
+
- **Canary** (`develop`): `npm install effectable@canary`
|
|
151
|
+
- **Stable** (`main` / tags `vX.Y.Z`): `npm install effectable`
|
|
152
|
+
|
|
153
|
+
Details: [docs/PUBLISHING.md](docs/PUBLISHING.md).
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT © 2025–2026 Nick Nask, also known as Nikita Neskuchaev ([iamnikas](https://github.com/iamnikas)). See [LICENSE](./LICENSE).
|
package/build/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Nick Nask, also known as Nikita Neskuchaev (iamnikas)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component-based bootstrap path for the Effectable root runtime.
|
|
3
|
+
*
|
|
4
|
+
* Mounts the root component via GraphRuntime (hidden in the implementation) and returns
|
|
5
|
+
* a handle with the root component instance and runtime buses. GraphRuntime / h / getRootInstance
|
|
6
|
+
* are not exposed — all mounting details are encapsulated here.
|
|
7
|
+
*
|
|
8
|
+
* @module Effectable/bootstrap/bootstrap
|
|
9
|
+
*/
|
|
10
|
+
import { Component } from '../component';
|
|
11
|
+
import type { ComponentConstructor } from '../component';
|
|
12
|
+
import type { RuntimeCommand, RuntimeEvent, RuntimeQuery } from '../runtime';
|
|
13
|
+
import type { BootstrapHandle, BootstrapOptions } from './types';
|
|
14
|
+
/**
|
|
15
|
+
* Mounts the root component via a hidden GraphRuntime and returns a handle
|
|
16
|
+
* with a ready instance, runtime buses, and an idempotent `shutdown()`.
|
|
17
|
+
*
|
|
18
|
+
* Example:
|
|
19
|
+
* ```ts
|
|
20
|
+
* const handle = await bootstrap(AppRoot, { logger }, { name: 'app.root' });
|
|
21
|
+
* const root = handle.rootInstance;
|
|
22
|
+
* await handle.shutdown();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param {ComponentConstructor<TProps>} type - root component class
|
|
26
|
+
* @param {TProps} props - root component props
|
|
27
|
+
* @param {BootstrapOptions<TCommand, TQuery, TEvent>} [options] - root runtime name and external runtime primitives
|
|
28
|
+
* @returns {Promise<BootstrapHandle<TComponent, TProps, TCommand, TQuery, TEvent>>} handle of the running root runtime
|
|
29
|
+
* @throws {Error} rethrown when mounting the root component fails
|
|
30
|
+
*/
|
|
31
|
+
export declare function bootstrap<TProps, TComponent extends Component<unknown, TProps> = Component<unknown, TProps>, TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent>(type: ComponentConstructor<TProps>, props: TProps, options?: BootstrapOptions<TCommand, TQuery, TEvent>): Promise<BootstrapHandle<TComponent, TProps, TCommand, TQuery, TEvent>>;
|
|
32
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +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,CA0ExE"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Component-based bootstrap path for the Effectable root runtime.
|
|
4
|
+
*
|
|
5
|
+
* Mounts the root component via GraphRuntime (hidden in the implementation) and returns
|
|
6
|
+
* a handle with the root component instance and runtime buses. GraphRuntime / h / getRootInstance
|
|
7
|
+
* are not exposed — all mounting details are encapsulated here.
|
|
8
|
+
*
|
|
9
|
+
* @module Effectable/bootstrap/bootstrap
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.bootstrap = bootstrap;
|
|
13
|
+
const component_1 = require("../component");
|
|
14
|
+
const runtime_1 = require("../runtime");
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
const DEFAULT_BOOTSTRAP_NAME = 'effectable.root';
|
|
17
|
+
/**
|
|
18
|
+
* Creates runtime primitives for the bootstrap path and marks which of them belong to the current handle.
|
|
19
|
+
*
|
|
20
|
+
* @param {Partial<BootstrapRuntimePrimitives<TCommand, TQuery, TEvent>> | undefined} providedRuntime - external runtime primitives
|
|
21
|
+
* @returns {{ runtime: BootstrapRuntimePrimitives<TCommand, TQuery, TEvent>; owned: OwnedRuntimePrimitives }} set of runtime primitives and ownership map
|
|
22
|
+
*/
|
|
23
|
+
function createRuntimePrimitives(providedRuntime) {
|
|
24
|
+
const providedCommandBus = typeof providedRuntime === 'undefined'
|
|
25
|
+
? undefined
|
|
26
|
+
: providedRuntime.commandBus;
|
|
27
|
+
const providedQueryBus = typeof providedRuntime === 'undefined'
|
|
28
|
+
? undefined
|
|
29
|
+
: providedRuntime.queryBus;
|
|
30
|
+
const providedEventBus = typeof providedRuntime === 'undefined'
|
|
31
|
+
? undefined
|
|
32
|
+
: providedRuntime.eventBus;
|
|
33
|
+
const providedHandleRegistry = typeof providedRuntime === 'undefined'
|
|
34
|
+
? undefined
|
|
35
|
+
: providedRuntime.handleRegistry;
|
|
36
|
+
const commandBus = typeof providedCommandBus === 'undefined'
|
|
37
|
+
? new runtime_1.CommandBus()
|
|
38
|
+
: providedCommandBus;
|
|
39
|
+
const queryBus = typeof providedQueryBus === 'undefined'
|
|
40
|
+
? new runtime_1.QueryBus()
|
|
41
|
+
: providedQueryBus;
|
|
42
|
+
const eventBus = typeof providedEventBus === 'undefined'
|
|
43
|
+
? new runtime_1.EventBus()
|
|
44
|
+
: providedEventBus;
|
|
45
|
+
const handleRegistry = typeof providedHandleRegistry === 'undefined'
|
|
46
|
+
? new runtime_1.HandleRegistry()
|
|
47
|
+
: providedHandleRegistry;
|
|
48
|
+
return {
|
|
49
|
+
runtime: {
|
|
50
|
+
commandBus,
|
|
51
|
+
queryBus,
|
|
52
|
+
eventBus,
|
|
53
|
+
handleRegistry,
|
|
54
|
+
},
|
|
55
|
+
owned: {
|
|
56
|
+
commandBus: typeof providedCommandBus === 'undefined',
|
|
57
|
+
queryBus: typeof providedQueryBus === 'undefined',
|
|
58
|
+
eventBus: typeof providedEventBus === 'undefined',
|
|
59
|
+
handleRegistry: typeof providedHandleRegistry === 'undefined',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clears only those runtime primitives owned by the current bootstrap handle.
|
|
65
|
+
*
|
|
66
|
+
* @param {BootstrapRuntimePrimitives<TCommand, TQuery, TEvent>} runtime - handle runtime primitives
|
|
67
|
+
* @param {OwnedRuntimePrimitives} owned - ownership map for the primitives
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
function clearOwnedRuntimePrimitives(runtime, owned) {
|
|
71
|
+
if (owned.commandBus) {
|
|
72
|
+
runtime.commandBus.clear();
|
|
73
|
+
}
|
|
74
|
+
if (owned.queryBus) {
|
|
75
|
+
runtime.queryBus.clear();
|
|
76
|
+
}
|
|
77
|
+
if (owned.eventBus) {
|
|
78
|
+
runtime.eventBus.clear();
|
|
79
|
+
}
|
|
80
|
+
if (owned.handleRegistry) {
|
|
81
|
+
runtime.handleRegistry.clear();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates an observability identity for the bootstrap-path root runtime.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} name - bootstrap root name
|
|
88
|
+
* @returns {BootstrapRuntimeNodeIdentity} root runtime identity
|
|
89
|
+
*/
|
|
90
|
+
function createBootstrapRootIdentity(name) {
|
|
91
|
+
return {
|
|
92
|
+
rootId: name,
|
|
93
|
+
nodeId: name,
|
|
94
|
+
displayName: name,
|
|
95
|
+
kind: types_1.BOOTSTRAP_RUNTIME_NODE_KIND.ROOT,
|
|
96
|
+
ownership: types_1.BOOTSTRAP_RUNTIME_NODE_OWNERSHIP.RUNTIME_OWNED,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Mounts the root component via a hidden GraphRuntime and returns a handle
|
|
101
|
+
* with a ready instance, runtime buses, and an idempotent `shutdown()`.
|
|
102
|
+
*
|
|
103
|
+
* Example:
|
|
104
|
+
* ```ts
|
|
105
|
+
* const handle = await bootstrap(AppRoot, { logger }, { name: 'app.root' });
|
|
106
|
+
* const root = handle.rootInstance;
|
|
107
|
+
* await handle.shutdown();
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @param {ComponentConstructor<TProps>} type - root component class
|
|
111
|
+
* @param {TProps} props - root component props
|
|
112
|
+
* @param {BootstrapOptions<TCommand, TQuery, TEvent>} [options] - root runtime name and external runtime primitives
|
|
113
|
+
* @returns {Promise<BootstrapHandle<TComponent, TProps, TCommand, TQuery, TEvent>>} handle of the running root runtime
|
|
114
|
+
* @throws {Error} rethrown when mounting the root component fails
|
|
115
|
+
*/
|
|
116
|
+
async function bootstrap(type, props, options) {
|
|
117
|
+
const name = typeof options !== 'undefined' && typeof options.name === 'string' && options.name !== ''
|
|
118
|
+
? options.name
|
|
119
|
+
: DEFAULT_BOOTSTRAP_NAME;
|
|
120
|
+
const providedRuntime = typeof options === 'undefined' ? undefined : options.runtime;
|
|
121
|
+
const onAutoReconcileError = typeof options !== 'undefined' ? options.onAutoReconcileError : undefined;
|
|
122
|
+
const { runtime, owned } = createRuntimePrimitives(providedRuntime);
|
|
123
|
+
const rootIdentity = createBootstrapRootIdentity(name); // TODO: remove; let this be configured automatically
|
|
124
|
+
let graphRuntime = null;
|
|
125
|
+
let rootInstance = null;
|
|
126
|
+
let running = false;
|
|
127
|
+
try {
|
|
128
|
+
graphRuntime = await component_1.GraphRuntime.mount((0, component_1.h)(type, props), component_1.EMPTY_CONTEXT_SCOPE, {
|
|
129
|
+
commandBus: runtime.commandBus,
|
|
130
|
+
queryBus: runtime.queryBus,
|
|
131
|
+
eventBus: runtime.eventBus,
|
|
132
|
+
}, onAutoReconcileError);
|
|
133
|
+
const resolved = graphRuntime.getRootInstance();
|
|
134
|
+
if (resolved === null) {
|
|
135
|
+
throw new Error('bootstrap: root instance is null after GraphRuntime.mount');
|
|
136
|
+
}
|
|
137
|
+
rootInstance = resolved;
|
|
138
|
+
running = true;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (graphRuntime !== null) {
|
|
142
|
+
await graphRuntime.unmount();
|
|
143
|
+
}
|
|
144
|
+
clearOwnedRuntimePrimitives(runtime, owned);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
// graphRuntime and rootInstance are guaranteed non-null at this point (running === true).
|
|
148
|
+
const activeGraphRuntime = graphRuntime;
|
|
149
|
+
const activeRootInstance = rootInstance;
|
|
150
|
+
return {
|
|
151
|
+
name,
|
|
152
|
+
rootInstance: activeRootInstance,
|
|
153
|
+
props,
|
|
154
|
+
runtime,
|
|
155
|
+
identity: rootIdentity,
|
|
156
|
+
isRunning() {
|
|
157
|
+
return running;
|
|
158
|
+
},
|
|
159
|
+
async reconcile() {
|
|
160
|
+
if (!running) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await activeGraphRuntime.reconcile((0, component_1.h)(type, props));
|
|
164
|
+
},
|
|
165
|
+
async shutdown() {
|
|
166
|
+
if (!running) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
running = false;
|
|
170
|
+
try {
|
|
171
|
+
await activeGraphRuntime.unmount();
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
clearOwnedRuntimePrimitives(runtime, owned);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,eAAe,CAAC,QAAQ,CAAC;IAC7B,MAAM,gBAAgB,GAAG,OAAO,eAAe,KAAK,WAAW;QAC7D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC;IAC7B,MAAM,sBAAsB,GAAG,OAAO,eAAe,KAAK,WAAW;QACnE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,eAAe,CAAC,cAAc,CAAC;IAEnC,MAAM,UAAU,GAAG,OAAO,kBAAkB,KAAK,WAAW;QAC1D,CAAC,CAAC,IAAI,oBAAU,EAAY;QAC5B,CAAC,CAAC,kBAAkB,CAAC;IACvB,MAAM,QAAQ,GAAG,OAAO,gBAAgB,KAAK,WAAW;QACtD,CAAC,CAAC,I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*/
|
|
6
|
+
export { bootstrap } from './bootstrap';
|
|
7
|
+
export { BOOTSTRAP_RUNTIME_NODE_KIND, BOOTSTRAP_RUNTIME_NODE_OWNERSHIP, } from './types';
|
|
8
|
+
export type { BootstrapHandle, BootstrapOptions, BootstrapRuntimeNodeIdentity, BootstrapRuntimeNodeKind, BootstrapRuntimeNodeOwnership, BootstrapRuntimePrimitives, } from './types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Public entry point of the Effectable bootstrap subsystem.
|
|
4
|
+
*
|
|
5
|
+
* @module Effectable/bootstrap
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BOOTSTRAP_RUNTIME_NODE_OWNERSHIP = exports.BOOTSTRAP_RUNTIME_NODE_KIND = exports.bootstrap = void 0;
|
|
9
|
+
var bootstrap_1 = require("./bootstrap");
|
|
10
|
+
Object.defineProperty(exports, "bootstrap", { enumerable: true, get: function () { return bootstrap_1.bootstrap; } });
|
|
11
|
+
var types_1 = require("./types");
|
|
12
|
+
Object.defineProperty(exports, "BOOTSTRAP_RUNTIME_NODE_KIND", { enumerable: true, get: function () { return types_1.BOOTSTRAP_RUNTIME_NODE_KIND; } });
|
|
13
|
+
Object.defineProperty(exports, "BOOTSTRAP_RUNTIME_NODE_OWNERSHIP", { enumerable: true, get: function () { return types_1.BOOTSTRAP_RUNTIME_NODE_OWNERSHIP; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,iCAGiB;AAFf,oHAAA,2BAA2B,OAAA;AAC3B,yHAAA,gCAAgC,OAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of the Effectable bootstrap subsystem.
|
|
3
|
+
*
|
|
4
|
+
* bootstrap mounts the root component via GraphRuntime (hidden in the implementation)
|
|
5
|
+
* and returns a handle with the root component instance and runtime buses.
|
|
6
|
+
*
|
|
7
|
+
* @module Effectable/bootstrap/types
|
|
8
|
+
*/
|
|
9
|
+
import type { Component } from '../component';
|
|
10
|
+
import type { CommandBus, EventBus, HandleRegistry, QueryBus, RuntimeCommand, RuntimeEvent, RuntimeQuery } from '../runtime';
|
|
11
|
+
/**
|
|
12
|
+
* Categories of runtime nodes in the bootstrap path.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BOOTSTRAP_RUNTIME_NODE_KIND: {
|
|
15
|
+
readonly ROOT: "ROOT";
|
|
16
|
+
readonly MOLECULE: "MOLECULE";
|
|
17
|
+
};
|
|
18
|
+
export type BootstrapRuntimeNodeKind = (typeof BOOTSTRAP_RUNTIME_NODE_KIND)[keyof typeof BOOTSTRAP_RUNTIME_NODE_KIND];
|
|
19
|
+
/**
|
|
20
|
+
* Ownership modes for a runtime node in the bootstrap path.
|
|
21
|
+
*/
|
|
22
|
+
export declare const BOOTSTRAP_RUNTIME_NODE_OWNERSHIP: {
|
|
23
|
+
readonly RUNTIME_OWNED: "RUNTIME_OWNED";
|
|
24
|
+
readonly COMPATIBILITY_BRIDGE: "COMPATIBILITY_BRIDGE";
|
|
25
|
+
};
|
|
26
|
+
export type BootstrapRuntimeNodeOwnership = (typeof BOOTSTRAP_RUNTIME_NODE_OWNERSHIP)[keyof typeof BOOTSTRAP_RUNTIME_NODE_OWNERSHIP];
|
|
27
|
+
/**
|
|
28
|
+
* Observability identity of the root node in the bootstrap path.
|
|
29
|
+
*/
|
|
30
|
+
export interface BootstrapRuntimeNodeIdentity {
|
|
31
|
+
rootId: string;
|
|
32
|
+
nodeId: string;
|
|
33
|
+
displayName: string;
|
|
34
|
+
kind: BootstrapRuntimeNodeKind;
|
|
35
|
+
ownership: BootstrapRuntimeNodeOwnership;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Full set of runtime primitives raised by the bootstrap path by default.
|
|
39
|
+
* Includes four buses: command / query / event and HandleRegistry.
|
|
40
|
+
*/
|
|
41
|
+
export interface BootstrapRuntimePrimitives<TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent> {
|
|
42
|
+
commandBus: CommandBus<TCommand>;
|
|
43
|
+
queryBus: QueryBus<TQuery>;
|
|
44
|
+
eventBus: EventBus<TEvent>;
|
|
45
|
+
handleRegistry: HandleRegistry;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Optional parameters for a bootstrap call.
|
|
49
|
+
*
|
|
50
|
+
* @template TCommand - command family type
|
|
51
|
+
* @template TQuery - query family type
|
|
52
|
+
* @template TEvent - event family type
|
|
53
|
+
*/
|
|
54
|
+
export interface BootstrapOptions<TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent> {
|
|
55
|
+
/** Root runtime name; defaults to `effectable.root`. */
|
|
56
|
+
name?: string;
|
|
57
|
+
/** Partially or fully external runtime primitives; missing ones are created internally. */
|
|
58
|
+
runtime?: Partial<BootstrapRuntimePrimitives<TCommand, TQuery, TEvent>>;
|
|
59
|
+
/**
|
|
60
|
+
* Hook invoked on automatic reconcile failure (triggered by `setState()`).
|
|
61
|
+
* Allows logging or handling errors that would otherwise be ignored.
|
|
62
|
+
*/
|
|
63
|
+
onAutoReconcileError?: (err: unknown) => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Handle of a running root runtime.
|
|
67
|
+
*
|
|
68
|
+
* @template TComponent - root component class
|
|
69
|
+
* @template TProps - root component props
|
|
70
|
+
* @template TCommand - command family type
|
|
71
|
+
* @template TQuery - query family type
|
|
72
|
+
* @template TEvent - event family type
|
|
73
|
+
*/
|
|
74
|
+
export interface BootstrapHandle<TComponent extends Component<unknown, TProps>, TProps, TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent> {
|
|
75
|
+
/** Root runtime name. */
|
|
76
|
+
name: string;
|
|
77
|
+
/** Root component instance that has already completed full startup. */
|
|
78
|
+
rootInstance: TComponent;
|
|
79
|
+
/** Props passed to the root component at bootstrap. */
|
|
80
|
+
props: TProps;
|
|
81
|
+
/** Runtime primitives (buses and registry) of the current handle. */
|
|
82
|
+
runtime: BootstrapRuntimePrimitives<TCommand, TQuery, TEvent>;
|
|
83
|
+
/** Observability identity of the root runtime. */
|
|
84
|
+
identity: BootstrapRuntimeNodeIdentity;
|
|
85
|
+
/**
|
|
86
|
+
* Checks whether the handle is still active (before shutdown).
|
|
87
|
+
*
|
|
88
|
+
* @returns {boolean} true if the handle has not been shut down yet
|
|
89
|
+
*/
|
|
90
|
+
isRunning(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Rebuilds the root runtime tree with the original props.
|
|
93
|
+
* Needed by external reactive sources because `Component.setState()` does not reconcile the subtree.
|
|
94
|
+
*
|
|
95
|
+
* @returns {Promise<void>} completion of the reconcile pass
|
|
96
|
+
*/
|
|
97
|
+
reconcile(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Idempotently shuts down the root runtime: unmounts the tree and clears owned buses.
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<void>}
|
|
102
|
+
*/
|
|
103
|
+
shutdown(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,MAAM,wBAAwB,GAClC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;CAGnC,CAAC;AACX,MAAM,MAAM,6BAA6B,GACvC,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,OAAO,gCAAgC,CAAC,CAAC;AAE3F;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,wBAAwB,CAAC;IAC/B,SAAS,EAAE,6BAA6B,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChD,MAAM,SAAS,YAAY,GAAG,YAAY,EAC1C,MAAM,SAAS,YAAY,GAAG,YAAY;IAE1C,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACjC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,QAAQ,EAA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of the Effectable bootstrap subsystem.
|
|
4
|
+
*
|
|
5
|
+
* bootstrap mounts the root component via GraphRuntime (hidden in the implementation)
|
|
6
|
+
* and returns a handle with the root component instance and runtime buses.
|
|
7
|
+
*
|
|
8
|
+
* @module Effectable/bootstrap/types
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.BOOTSTRAP_RUNTIME_NODE_OWNERSHIP = exports.BOOTSTRAP_RUNTIME_NODE_KIND = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Categories of runtime nodes in the bootstrap path.
|
|
14
|
+
*/
|
|
15
|
+
exports.BOOTSTRAP_RUNTIME_NODE_KIND = {
|
|
16
|
+
ROOT: 'ROOT',
|
|
17
|
+
MOLECULE: 'MOLECULE',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Ownership modes for a runtime node in the bootstrap path.
|
|
21
|
+
*/
|
|
22
|
+
exports.BOOTSTRAP_RUNTIME_NODE_OWNERSHIP = {
|
|
23
|
+
RUNTIME_OWNED: 'RUNTIME_OWNED',
|
|
24
|
+
COMPATIBILITY_BRIDGE: 'COMPATIBILITY_BRIDGE',
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAaH;;GAEG;AACU,QAAA,2BAA2B,GAAG;IACzC,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX;;GAEG;AACU,QAAA,gCAAgC,GAAG;IAC9C,aAAa,EAAE,eAAe;IAC9B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC"}
|