@electrojs/runtime 1.0.7 → 1.0.9

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 CHANGED
@@ -43,10 +43,11 @@ class AppModule {}
43
43
  const kernel = AppKernel.create(AppModule, {
44
44
  logger: createConsoleLogger(),
45
45
  });
46
+ await kernel.initialize();
46
47
  await kernel.start();
47
48
  ```
48
49
 
49
- `AppKernel.create` scans `AppModule`, validates the module graph, creates the DI container, instantiates module declarations, and runs startup lifecycle hooks. That single call is enough to bootstrap a working application.
50
+ `AppKernel.initialize()` scans `AppModule`, validates the module graph, creates the DI container, instantiates module declarations, installs capabilities, and runs `onInit`. `kernel.start()` then runs `onStart` and `onReady`. Calling `start()` directly from `idle` still performs initialization automatically for backward compatibility.
50
51
 
51
52
  Modules, providers, windows, and views also receive `this.logger` through the authoring API, so app-level logs can use the same runtime logger contract and be redirected to a file, Sentry, or any other sink by passing a custom logger into `AppKernel.create(...)`.
52
53
 
@@ -101,7 +102,7 @@ class AuthService {
101
102
  `inject()` works inside:
102
103
 
103
104
  - **Property initializers** -- during construction of framework-managed classes
104
- - **Lifecycle hooks** -- `onInit`, `onReady`, `onShutdown`, `onDispose`
105
+ - **Lifecycle hooks** -- `onInit`, `onStart`, `onReady`, `onShutdown`, `onDispose`
105
106
  - **Capability handlers** -- methods decorated with `@command`, `@query`, `@signal`, `@job`
106
107
 
107
108
  Calling it outside these scopes throws a `DIError`.
@@ -129,6 +130,10 @@ class DatabaseService {
129
130
  await this.pool.connect();
130
131
  }
131
132
 
133
+ async onStart() {
134
+ await this.attachWindowListeners();
135
+ }
136
+
132
137
  async onReady() {
133
138
  await this.runMigrations();
134
139
  }
@@ -143,14 +148,15 @@ class DatabaseService {
143
148
  }
144
149
  ```
145
150
 
146
- | Hook | Phase | Purpose |
147
- | ------------ | -------- | ---------------------------------------------------- |
148
- | `onInit` | Startup | Set up resources (connections, state) |
149
- | `onReady` | Startup | Cross-module coordination, everything is initialized |
150
- | `onShutdown` | Shutdown | Release resources gracefully |
151
- | `onDispose` | Shutdown | Final cleanup (file handles, timers) |
151
+ | Hook | Phase | Purpose |
152
+ | ------------ | ---------- | ------------------------------------------------------------- |
153
+ | `onInit` | Initialize | Prepare bridge-safe state, handlers, and runtime dependencies |
154
+ | `onStart` | Startup | Start windows, jobs, network bootstrapping, launch flows |
155
+ | `onReady` | Startup | Final coordination before the kernel becomes `started` |
156
+ | `onShutdown` | Shutdown | Release resources gracefully |
157
+ | `onDispose` | Shutdown | Final cleanup (file handles, timers) |
152
158
 
153
- **Ordering:** Startup hooks run per-module in dependency-first order. Within each module, provider hooks run before the module's own hook. Shutdown runs in the reverse order -- module first, then its providers.
159
+ **Ordering:** `onInit`, `onStart`, and `onReady` all run per-module in dependency-first order. Within each module, provider hooks run before the module's own hook. Shutdown runs in the reverse order -- module first, then its providers.
154
160
 
155
161
  If a startup hook throws, the framework automatically rolls back already-initialized modules by calling their shutdown hooks.
156
162
 
@@ -284,7 +290,7 @@ Windows and views are first-class providers. Extend the base classes `WindowProv
284
290
  class MainWindow extends WindowProvider {
285
291
  private readonly mainView = inject(MainView);
286
292
 
287
- onReady() {
293
+ onStart() {
288
294
  this.create();
289
295
  this.mount(this.mainView);
290
296
  this.show();
@@ -303,7 +309,7 @@ class MainWindow extends WindowProvider {
303
309
  signals: ["user-logged-in"],
304
310
  })
305
311
  class MainView extends ViewProvider {
306
- async onReady() {
312
+ async onStart() {
307
313
  await this.load();
308
314
  this.setBounds({ x: 0, y: 0, width: 1280, height: 800 });
309
315
  this.setBackgroundColor("#00000000");