@lithia-js/core 1.0.0-canary.20 → 1.0.0-canary.22

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/dist/_index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { L as LithiaError, a as LithiaOptions, R as Route, E as Event } from './protocol-Ddx-dP-_.js';
2
- export { C as CFG_GLOBAL_KEY, b as RouteNotFoundError } from './protocol-Ddx-dP-_.js';
3
- import { T as TaskCore } from './tasks-qNCrAmuM.js';
1
+ import { L as LithiaError, a as LithiaOptions, R as Route, E as Event } from './protocol-BGSauS_S.js';
2
+ export { C as CFG_GLOBAL_KEY, b as RouteNotFoundError } from './protocol-BGSauS_S.js';
3
+ import { T as TaskCore } from './tasks-X-3clDS8.js';
4
4
  import '@lithia-js/utils';
5
5
  import 'c12';
6
6
 
@@ -18,6 +18,9 @@ declare class NotInLithiaContextError extends LithiaError {
18
18
  * Minimal runtime options required to bootstrap the Lithia host.
19
19
  */
20
20
  interface LithiaOpts {
21
+ /**
22
+ * Runtime environment mode used to load config, manifests, and workers.
23
+ */
21
24
  environment: Environment;
22
25
  }
23
26
  /**
@@ -36,43 +39,106 @@ declare class HostSupervisor {
36
39
  private readonly _taskRunner;
37
40
  private _appCount;
38
41
  private _lastPortUsed;
42
+ /**
43
+ * Creates the main-process supervisor for a Lithia runtime instance.
44
+ *
45
+ * The supervisor owns configuration loading, environment snapshots, build
46
+ * orchestration, manifest loading, app worker lifecycle, and async task
47
+ * execution coordination.
48
+ *
49
+ * @param {LithiaOpts} opts - Minimal host runtime options.
50
+ * @throws {Error} Throws when instantiated outside the Node.js main thread.
51
+ */
39
52
  constructor(opts: LithiaOpts);
53
+ /**
54
+ * Returns the resolved runtime configuration for the current host lifecycle.
55
+ *
56
+ * In production, the config is read from the global host runtime slot
57
+ * exposed through `CFG_GLOBAL_KEY`. In other environments, the in-memory
58
+ * loaded config snapshot is returned.
59
+ */
40
60
  get config(): LithiaOptions;
61
+ /**
62
+ * Returns the environment mode assigned to this host instance.
63
+ */
41
64
  get environment(): Environment;
65
+ /**
66
+ * Returns whether the supervised app worker has reported readiness.
67
+ */
42
68
  get isAppReady(): boolean;
69
+ /**
70
+ * Returns the currently loaded route manifest entries.
71
+ */
43
72
  get routes(): Route[];
73
+ /**
74
+ * Returns the currently loaded event manifest entries.
75
+ */
44
76
  get events(): Event[];
77
+ /**
78
+ * Returns the currently loaded async task manifest entries.
79
+ */
45
80
  get tasks(): TaskCore[];
46
81
  /**
47
82
  * Loads the user configuration file into the host runtime.
83
+ *
84
+ * This is skipped in production, where config is expected to be available
85
+ * through the global runtime slot.
86
+ *
87
+ * @returns {Promise<void>} Resolves after the config snapshot has been
88
+ * loaded when applicable.
48
89
  */
49
90
  loadConfig(): Promise<void>;
50
91
  /**
51
92
  * Loads and merges configured environment files into the host snapshot.
93
+ *
94
+ * Files are loaded in config order, and later files override earlier keys.
95
+ * Only files that currently exist are considered.
96
+ *
97
+ * @returns {Promise<Record<string, string>>} Copy of the merged environment
98
+ * snapshot.
99
+ * @throws {LithiaError} Throws when configuration has not been loaded yet.
52
100
  */
53
101
  loadEnv(): Promise<Record<string, string>>;
54
102
  /**
55
103
  * Loads the routes manifest from the current build output.
104
+ *
105
+ * @returns {Promise<void>} Resolves after the route manifest cache has been
106
+ * refreshed.
56
107
  */
57
108
  loadRoutes(): Promise<void>;
58
109
  /**
59
110
  * Loads the events manifest from the current build output.
111
+ *
112
+ * @returns {Promise<void>} Resolves after the event manifest cache has been
113
+ * refreshed.
60
114
  */
61
115
  loadEvents(): Promise<void>;
62
116
  /**
63
117
  * Loads the async tasks manifest from the current build output.
118
+ *
119
+ * @returns {Promise<void>} Resolves after the task manifest cache has been
120
+ * refreshed.
64
121
  */
65
122
  loadTasks(): Promise<void>;
66
123
  /**
67
124
  * Returns a copy of the currently loaded environment snapshot.
125
+ *
126
+ * @returns {Record<string, string>} Shallow copy of the host environment
127
+ * snapshot.
68
128
  */
69
129
  getEnvSnapshot(): Record<string, string>;
70
130
  /**
71
131
  * Replaces the in-memory resolved config snapshot.
132
+ *
133
+ * @param {LithiaOptions} config - Config snapshot that should replace the
134
+ * current in-memory value.
72
135
  */
73
136
  replaceConfig(config: LithiaOptions): void;
74
137
  /**
75
138
  * Replaces the in-memory environment snapshot.
139
+ *
140
+ * @param {Record<string, string>} env - Environment snapshot that should
141
+ * replace the current in-memory value.
76
142
  */
77
143
  replaceEnv(env: Record<string, string>): void;
78
144
  /**
@@ -81,30 +147,53 @@ declare class HostSupervisor {
81
147
  * Returns `true` when the build succeeds. In non-build environments, failures
82
148
  * are reported and surfaced as `false` so the caller can decide how to
83
149
  * recover.
150
+ *
151
+ * @returns {Promise<boolean>} `true` when the build succeeds, otherwise
152
+ * `false` outside build mode.
153
+ * @throws {unknown} Rethrows build failures when the host runs in `build`
154
+ * mode.
84
155
  */
85
156
  build(): Promise<boolean>;
86
157
  /**
87
158
  * Loads config/env and prints the CLI header for the current run.
159
+ *
160
+ * @returns {Promise<void>} Resolves after config, env, and header output are
161
+ * ready.
88
162
  */
89
163
  setup(): Promise<void>;
90
164
  /**
91
165
  * Starts the app worker using the latest manifests and runtime state.
166
+ *
167
+ * @returns {Promise<void>} Resolves after manifests are loaded and the app
168
+ * worker reports readiness.
169
+ * @throws {Error} Throws when worker startup fails.
92
170
  */
93
171
  start(): Promise<void>;
94
172
  /**
95
173
  * Reloads manifests, resets task workers, and swaps the app worker.
174
+ *
175
+ * @returns {Promise<void>} Resolves after manifests are refreshed, task
176
+ * workers are reset, and the replacement app worker becomes ready.
96
177
  */
97
178
  reload(): Promise<void>;
98
179
  /**
99
180
  * Stops task execution and tears down the app worker.
181
+ *
182
+ * @returns {Promise<void>} Resolves after warm task workers and the app
183
+ * worker have been terminated.
100
184
  */
101
185
  stop(): Promise<void>;
102
186
  /**
103
187
  * Replaces the current app worker with a fresh instance.
188
+ *
189
+ * @returns {Promise<void>} Resolves after the replacement app worker reports
190
+ * readiness.
104
191
  */
105
192
  swapApp(): Promise<void>;
106
193
  /**
107
194
  * Prints the Lithia CLI header and the env files currently in use.
195
+ *
196
+ * @returns {Promise<void>} Resolves after header output has been printed.
108
197
  */
109
198
  printHeader(): Promise<void>;
110
199
  /**
@@ -119,9 +208,37 @@ declare class HostSupervisor {
119
208
  * Prints the loaded async tasks in a CLI-friendly tree format.
120
209
  */
121
210
  printTaskTree(): void;
211
+ /**
212
+ * Forwards task invocation messages emitted by the app worker to the async
213
+ * task runner.
214
+ *
215
+ * @param {AppToHostEvent} event - Message emitted by the app worker.
216
+ * @returns {Promise<void>} Resolves after invocation messages are handled or
217
+ * ignored.
218
+ */
122
219
  private handleAppMessage;
220
+ /**
221
+ * Prints a simple labeled tree for CLI inspection of loaded runtime state.
222
+ *
223
+ * @param {string} label - Section label printed above the tree.
224
+ * @param {T[]} items - Items to render.
225
+ * @param {(item: T) => string} nameFn - Formatter used for the item label.
226
+ * @param {(item: T) => string} symbolFn - Formatter used for the item
227
+ * prefix symbol.
228
+ */
123
229
  private printTree;
230
+ /**
231
+ * Returns the configured env files that currently exist on disk.
232
+ *
233
+ * @returns {Promise<string[]>} Existing env files in configured load order.
234
+ */
124
235
  private getAvailableEnvFiles;
236
+ /**
237
+ * Verifies that a config snapshot is available before host operations that
238
+ * depend on it.
239
+ *
240
+ * @throws {LithiaError} Throws when configuration has not been loaded.
241
+ */
125
242
  private ensureConfigLoaded;
126
243
  }
127
244