@lithia-js/core 1.0.0-canary.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.
Files changed (91) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +13 -0
  3. package/LICENSE +21 -0
  4. package/README.md +60 -0
  5. package/dist/config.d.ts +101 -0
  6. package/dist/config.js +113 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/context/event-context.d.ts +53 -0
  9. package/dist/context/event-context.js +42 -0
  10. package/dist/context/event-context.js.map +1 -0
  11. package/dist/context/index.d.ts +16 -0
  12. package/dist/context/index.js +29 -0
  13. package/dist/context/index.js.map +1 -0
  14. package/dist/context/lithia-context.d.ts +47 -0
  15. package/dist/context/lithia-context.js +43 -0
  16. package/dist/context/lithia-context.js.map +1 -0
  17. package/dist/context/route-context.d.ts +74 -0
  18. package/dist/context/route-context.js +42 -0
  19. package/dist/context/route-context.js.map +1 -0
  20. package/dist/env.d.ts +1 -0
  21. package/dist/env.js +32 -0
  22. package/dist/env.js.map +1 -0
  23. package/dist/errors.d.ts +51 -0
  24. package/dist/errors.js +80 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/hooks/dependency-hooks.d.ts +105 -0
  27. package/dist/hooks/dependency-hooks.js +96 -0
  28. package/dist/hooks/dependency-hooks.js.map +1 -0
  29. package/dist/hooks/event-hooks.d.ts +61 -0
  30. package/dist/hooks/event-hooks.js +70 -0
  31. package/dist/hooks/event-hooks.js.map +1 -0
  32. package/dist/hooks/index.d.ts +41 -0
  33. package/dist/hooks/index.js +59 -0
  34. package/dist/hooks/index.js.map +1 -0
  35. package/dist/hooks/route-hooks.d.ts +154 -0
  36. package/dist/hooks/route-hooks.js +174 -0
  37. package/dist/hooks/route-hooks.js.map +1 -0
  38. package/dist/lib.d.ts +10 -0
  39. package/dist/lib.js +30 -0
  40. package/dist/lib.js.map +1 -0
  41. package/dist/lithia.d.ts +447 -0
  42. package/dist/lithia.js +649 -0
  43. package/dist/lithia.js.map +1 -0
  44. package/dist/logger.d.ts +11 -0
  45. package/dist/logger.js +55 -0
  46. package/dist/logger.js.map +1 -0
  47. package/dist/module-loader.d.ts +12 -0
  48. package/dist/module-loader.js +78 -0
  49. package/dist/module-loader.js.map +1 -0
  50. package/dist/server/event-processor.d.ts +195 -0
  51. package/dist/server/event-processor.js +253 -0
  52. package/dist/server/event-processor.js.map +1 -0
  53. package/dist/server/http-server.d.ts +196 -0
  54. package/dist/server/http-server.js +295 -0
  55. package/dist/server/http-server.js.map +1 -0
  56. package/dist/server/middlewares/validation.d.ts +12 -0
  57. package/dist/server/middlewares/validation.js +34 -0
  58. package/dist/server/middlewares/validation.js.map +1 -0
  59. package/dist/server/request-processor.d.ts +400 -0
  60. package/dist/server/request-processor.js +652 -0
  61. package/dist/server/request-processor.js.map +1 -0
  62. package/dist/server/request.d.ts +73 -0
  63. package/dist/server/request.js +207 -0
  64. package/dist/server/request.js.map +1 -0
  65. package/dist/server/response.d.ts +69 -0
  66. package/dist/server/response.js +173 -0
  67. package/dist/server/response.js.map +1 -0
  68. package/package.json +46 -0
  69. package/src/config.ts +212 -0
  70. package/src/context/event-context.ts +66 -0
  71. package/src/context/index.ts +32 -0
  72. package/src/context/lithia-context.ts +59 -0
  73. package/src/context/route-context.ts +89 -0
  74. package/src/env.ts +31 -0
  75. package/src/errors.ts +96 -0
  76. package/src/hooks/dependency-hooks.ts +122 -0
  77. package/src/hooks/event-hooks.ts +69 -0
  78. package/src/hooks/index.ts +58 -0
  79. package/src/hooks/route-hooks.ts +177 -0
  80. package/src/lib.ts +27 -0
  81. package/src/lithia.ts +777 -0
  82. package/src/logger.ts +66 -0
  83. package/src/module-loader.ts +45 -0
  84. package/src/server/event-processor.ts +344 -0
  85. package/src/server/http-server.ts +371 -0
  86. package/src/server/middlewares/validation.ts +46 -0
  87. package/src/server/request-processor.ts +860 -0
  88. package/src/server/request.ts +247 -0
  89. package/src/server/response.ts +204 -0
  90. package/tsconfig.build.tsbuildinfo +1 -0
  91. package/tsconfig.json +8 -0
package/dist/lithia.js ADDED
@@ -0,0 +1,649 @@
1
+ "use strict";
2
+ /**
3
+ * Core runtime entry for Lithia.
4
+ *
5
+ * This module provides the main `Lithia` class, which orchestrates the entire
6
+ * framework lifecycle including:
7
+ * - Building the project with the native Rust compiler
8
+ * - Loading route and event manifests
9
+ * - Managing the HTTP server lifecycle
10
+ * - Configuration management and hot-reloading
11
+ * - Dependency injection and global middleware
12
+ * - Lifecycle event emission (built, error, config:changed)
13
+ *
14
+ * @module lithia
15
+ */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Lithia = void 0;
21
+ const node_events_1 = require("node:events");
22
+ const node_fs_1 = require("node:fs");
23
+ const node_path_1 = __importDefault(require("node:path"));
24
+ const native_1 = require("@lithia-js/native");
25
+ const utils_1 = require("@lithia-js/utils");
26
+ const source_map_support_1 = __importDefault(require("source-map-support"));
27
+ const config_1 = require("./config");
28
+ const lithia_context_1 = require("./context/lithia-context");
29
+ const errors_1 = require("./errors");
30
+ const logger_1 = require("./logger");
31
+ const module_loader_1 = require("./module-loader");
32
+ const http_server_1 = require("./server/http-server");
33
+ /**
34
+ * Configuration keys that require a full server restart when changed.
35
+ *
36
+ * These settings cannot be hot-reloaded and require stopping/starting
37
+ * the HTTP server to take effect.
38
+ */
39
+ const RESTART_CONFIG_PREFIXES = ["http.port", "http.host", "http.ssl"];
40
+ // Install source map support for better stack traces in development
41
+ source_map_support_1.default.install({
42
+ environment: "node",
43
+ handleUncaughtExceptions: false,
44
+ });
45
+ /**
46
+ * Lithia runtime controller and main framework orchestrator.
47
+ *
48
+ * This is the core class that manages the entire Lithia application lifecycle.
49
+ * It acts as a singleton and coordinates:
50
+ * - Project compilation via the native Rust builder
51
+ * - Route and event manifest loading
52
+ * - HTTP server lifecycle management
53
+ * - Configuration management with hot-reloading in development
54
+ * - Global middleware and dependency injection
55
+ * - Lifecycle event emission and handling
56
+ *
57
+ * @remarks
58
+ * Always use `Lithia.create()` to obtain the singleton instance.
59
+ * Direct instantiation is not supported.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const lithia = await Lithia.create({
64
+ * environment: 'development',
65
+ * sourceRoot: './src',
66
+ * outRoot: './dist'
67
+ * });
68
+ *
69
+ * lithia.build();
70
+ * await lithia.start();
71
+ * ```
72
+ */
73
+ class Lithia {
74
+ /** Singleton instance of Lithia. */
75
+ static instance;
76
+ /** Current runtime environment (production or development). */
77
+ environment;
78
+ /** Absolute path to the source directory. */
79
+ sourceRoot;
80
+ /** Absolute path to the compiled output directory. */
81
+ outRoot;
82
+ /** Array of loaded application routes from the manifest. */
83
+ routes;
84
+ /** Array of loaded Socket.IO events from the manifest. */
85
+ events;
86
+ /** Current runtime configuration. */
87
+ config;
88
+ /** Event emitter for lifecycle events (built, error, config:changed). */
89
+ emitter;
90
+ /** Configuration provider that handles loading and watching. */
91
+ configProvider;
92
+ /** HTTP server instance (created when start() is called). */
93
+ httpServer;
94
+ /** Flag indicating whether the HTTP server is currently running. */
95
+ serverRunning = false;
96
+ /** Handle for the configuration file watcher (development only). */
97
+ configWatchHandle;
98
+ /**
99
+ * Global middlewares executed for every HTTP request.
100
+ *
101
+ * These run before route-specific handlers and can modify requests,
102
+ * responses, or perform authentication/logging.
103
+ */
104
+ globalMiddlewares = [];
105
+ /**
106
+ * Global dependency injection container.
107
+ *
108
+ * Stores dependencies registered via `provide()` that can be injected
109
+ * into route handlers and middlewares.
110
+ */
111
+ globalDependencies = new Map();
112
+ /**
113
+ * Gets the current runtime configuration.
114
+ *
115
+ * @returns The current LithiaOptions configuration object
116
+ */
117
+ get options() {
118
+ return this.config;
119
+ }
120
+ /**
121
+ * Private constructor to enforce singleton pattern.
122
+ *
123
+ * Use `Lithia.create()` instead of instantiating directly.
124
+ *
125
+ * @private
126
+ */
127
+ constructor() {
128
+ this.routes = [];
129
+ this.events = [];
130
+ this.emitter = new node_events_1.EventEmitter();
131
+ this.configProvider = new config_1.ConfigProvider();
132
+ }
133
+ /**
134
+ * Creates or returns the global Lithia singleton instance.
135
+ *
136
+ * This is the primary entry point for creating a Lithia application.
137
+ * On first call, it initializes the framework with the provided options,
138
+ * loads configuration, and (in development mode) sets up configuration
139
+ * hot-reloading.
140
+ *
141
+ * Subsequent calls return the same singleton instance.
142
+ *
143
+ * @param options - Configuration for paths and environment
144
+ * @returns The initialized Lithia singleton instance
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const lithia = await Lithia.create({
149
+ * environment: 'development',
150
+ * sourceRoot: path.resolve('./src'),
151
+ * outRoot: path.resolve('./dist')
152
+ * });
153
+ * ```
154
+ */
155
+ static async create(options) {
156
+ if (!Lithia.instance) {
157
+ const lithia = new Lithia();
158
+ await lithia.initialize(options);
159
+ Lithia.instance = lithia;
160
+ }
161
+ return Lithia.instance;
162
+ }
163
+ /**
164
+ * Registers a global middleware to run on every HTTP request.
165
+ *
166
+ * Middlewares are executed in the order they are registered, before
167
+ * route-specific handlers. They can modify the request/response or
168
+ * perform cross-cutting concerns like logging and authentication.
169
+ *
170
+ * @param middleware - The middleware function to register
171
+ * @returns The Lithia instance for method chaining
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * lithia.use(async (req, res, next) => {
176
+ * console.log(`${req.method} ${req.url}`);
177
+ * await next();
178
+ * });
179
+ * ```
180
+ */
181
+ use(middleware) {
182
+ this.globalMiddlewares.push(middleware);
183
+ return this;
184
+ }
185
+ /**
186
+ * Registers a global dependency for dependency injection.
187
+ *
188
+ * Registered dependencies can be injected into route handlers and
189
+ * middlewares using the `inject()` hook.
190
+ *
191
+ * @param key - The injection key (use `createInjectionKey<T>()` to create)
192
+ * @param value - The dependency value to provide
193
+ * @returns The Lithia instance for method chaining
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * const dbKey = createInjectionKey<Database>('database');
198
+ * lithia.provide(dbKey, new Database());
199
+ * ```
200
+ */
201
+ provide(key, value) {
202
+ this.globalDependencies.set(key, value);
203
+ return this;
204
+ }
205
+ /**
206
+ * Initializes the Lithia instance with configuration and environment settings.
207
+ *
208
+ * This method:
209
+ * - Sets up the environment, source root, and output root
210
+ * - Loads the initial configuration from lithia.config.ts
211
+ * - Configures the event emitter for lifecycle events
212
+ * - Sets up configuration hot-reloading (development mode only)
213
+ *
214
+ * @param options - Initialization options
215
+ * @private
216
+ */
217
+ async initialize(options) {
218
+ this.environment = options.environment;
219
+ this.sourceRoot = options.sourceRoot;
220
+ this.outRoot = options.outRoot;
221
+ this.config = await this.configProvider.loadConfig();
222
+ this.configureEventEmitter();
223
+ if (options.environment === "development") {
224
+ await this.setupConfigWatcher();
225
+ }
226
+ }
227
+ /**
228
+ * Sets up configuration file watching in development mode.
229
+ *
230
+ * Monitors lithia.config.ts for changes and emits `config:changed` events.
231
+ * Logs configuration diffs and warns when changes require a server restart.
232
+ *
233
+ * @private
234
+ */
235
+ async setupConfigWatcher() {
236
+ try {
237
+ this.configWatchHandle = await this.configProvider.watchConfig((ctx) => {
238
+ this.config = ctx.newConfig;
239
+ this.emit("config:changed", ctx.newConfig);
240
+ try {
241
+ const diffs = typeof ctx.getDiff === "function" ? ctx.getDiff() : [];
242
+ if (diffs && diffs.length > 0) {
243
+ logger_1.logger.event(`Config updated — ${diffs.length} change(s)`);
244
+ // Log first 20 changes to avoid spam
245
+ for (const d of diffs.slice(0, 20)) {
246
+ const requiresRestart = this.configChangeRequiresRestart(d.key);
247
+ if (requiresRestart) {
248
+ logger_1.logger.warn(` • ${d.key}: ${d.oldValue} → ${d.newValue} (requires server restart)`);
249
+ }
250
+ else {
251
+ logger_1.logger.info(` • ${d.key}: ${d.oldValue} → ${d.newValue}`);
252
+ }
253
+ }
254
+ }
255
+ }
256
+ catch (logErr) {
257
+ logger_1.logger.debug("Failed to summarize config diff:", logErr);
258
+ }
259
+ }, undefined);
260
+ }
261
+ catch (err) {
262
+ this.emitter.emit("error", err);
263
+ }
264
+ }
265
+ /**
266
+ * Checks if a configuration key change requires a server restart.
267
+ *
268
+ * @param key - The configuration key that changed
269
+ * @returns True if the change requires restarting the server
270
+ * @private
271
+ */
272
+ configChangeRequiresRestart(key) {
273
+ return RESTART_CONFIG_PREFIXES.some((prefix) => key === prefix || key.startsWith(`${prefix}.`));
274
+ }
275
+ /**
276
+ * Loads and executes the optional user bootstrap module.
277
+ *
278
+ * Looks for `src/app/_server.ts` (compiled to `dist/app/_server.js`).
279
+ * The bootstrap module should export an async default function that
280
+ * receives the Lithia instance and can register middlewares, providers, etc.
281
+ *
282
+ * @throws {InvalidBootstrapModuleError} If the module has invalid structure
283
+ * @private
284
+ */
285
+ async loadBootstrapModule() {
286
+ const bootstrapFile = node_path_1.default.join(this.outRoot, "app", "_server.js");
287
+ if (!(0, node_fs_1.existsSync)(bootstrapFile)) {
288
+ return; // Bootstrap module is optional
289
+ }
290
+ try {
291
+ const mod = await (0, module_loader_1.coldImport)(bootstrapFile, this.environment === "development");
292
+ this.validateBootstrapModule(mod, bootstrapFile);
293
+ // Execute the bootstrap function
294
+ await mod.default(this);
295
+ }
296
+ catch (err) {
297
+ // Don't swallow fatal validation errors
298
+ if (err instanceof errors_1.InvalidBootstrapModuleError) {
299
+ this.emitter.emit("error", err);
300
+ throw err; // Prevent server from starting with invalid bootstrap
301
+ }
302
+ logger_1.logger.error(`Failed to load _server.ts: ${err}`);
303
+ }
304
+ }
305
+ /**
306
+ * Validates the structure of the bootstrap module.
307
+ *
308
+ * Ensures the module:
309
+ * - Has a default export
310
+ * - Default export is a function
311
+ * - Default export is async
312
+ *
313
+ * @param mod - The loaded module
314
+ * @param filePath - Path to the module file (for error messages)
315
+ * @throws {InvalidBootstrapModuleError} If validation fails
316
+ * @private
317
+ */
318
+ validateBootstrapModule(mod, filePath) {
319
+ if (!mod.default) {
320
+ throw new errors_1.InvalidBootstrapModuleError(filePath, "missing default export");
321
+ }
322
+ if (typeof mod.default !== "function") {
323
+ throw new errors_1.InvalidBootstrapModuleError(filePath, "default export is not a function");
324
+ }
325
+ if (!(0, module_loader_1.isAsyncFunction)(mod.default)) {
326
+ throw new errors_1.InvalidBootstrapModuleError(filePath, "default export is not an async function");
327
+ }
328
+ }
329
+ /**
330
+ * Starts the HTTP server.
331
+ *
332
+ * This method:
333
+ * 1. Loads and executes the optional bootstrap module (_server.ts)
334
+ * 2. Creates the HTTP server with current configuration
335
+ * 3. Starts listening on the configured host and port
336
+ *
337
+ * Safe to call multiple times; subsequent calls are no-ops while the
338
+ * server is running.
339
+ *
340
+ * @throws {InvalidBootstrapModuleError} If bootstrap module is invalid
341
+ * @throws {Error} If server fails to start
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * await lithia.start();
346
+ * // Server is now listening on configured port
347
+ * ```
348
+ */
349
+ async start() {
350
+ if (this.serverRunning)
351
+ return;
352
+ // Load optional user bootstrap logic
353
+ await this.loadBootstrapModule();
354
+ // Create and start the HTTP server
355
+ this.httpServer = (0, http_server_1.createHttpServerFromConfig)({
356
+ options: this.config,
357
+ lithia: this,
358
+ });
359
+ try {
360
+ await this.httpServer.listen();
361
+ this.serverRunning = true;
362
+ }
363
+ catch (err) {
364
+ this.emitter.emit("error", err);
365
+ }
366
+ }
367
+ /**
368
+ * Stops the HTTP server.
369
+ *
370
+ * Gracefully shuts down the server and closes all active connections.
371
+ * No-op if the server isn't currently running.
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * await lithia.stop();
376
+ * // Server is now stopped
377
+ * ```
378
+ */
379
+ async stop() {
380
+ if (!this.serverRunning)
381
+ return;
382
+ try {
383
+ await this.httpServer?.close();
384
+ this.serverRunning = false;
385
+ }
386
+ catch (err) {
387
+ this.emitter.emit("error", err);
388
+ }
389
+ }
390
+ /**
391
+ * Executes a function within the Lithia context.
392
+ *
393
+ * Provides access to the global dependency container during execution.
394
+ * Used internally by the request processor to make dependencies available
395
+ * to route handlers and middlewares.
396
+ *
397
+ * @param fn - Async function to execute within the context
398
+ * @returns The result of the function execution
399
+ * @template T - The return type of the function
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * const result = await lithia.runWithContext(async () => {
404
+ * const db = inject(dbKey);
405
+ * return db.query('SELECT * FROM users');
406
+ * });
407
+ * ```
408
+ */
409
+ async runWithContext(fn) {
410
+ const ctx = {
411
+ dependencies: this.globalDependencies,
412
+ };
413
+ return lithia_context_1.lithiaContext.run(ctx, fn);
414
+ }
415
+ /**
416
+ * Gets the current runtime environment.
417
+ *
418
+ * @returns The environment mode ('production' or 'development')
419
+ */
420
+ getEnvironment() {
421
+ return this.environment;
422
+ }
423
+ /**
424
+ * Gets the currently loaded routes from the manifest.
425
+ *
426
+ * Routes are loaded after a successful build via the `loadRoutes()` method.
427
+ *
428
+ * @returns Array of route definitions
429
+ */
430
+ getRoutes() {
431
+ return this.routes;
432
+ }
433
+ /**
434
+ * Gets the currently loaded Socket.IO events from the manifest.
435
+ *
436
+ * Events are loaded after a successful build via the `loadEvents()` method.
437
+ *
438
+ * @returns Array of event definitions
439
+ */
440
+ getEvents() {
441
+ return this.events;
442
+ }
443
+ /**
444
+ * Gets the current runtime configuration.
445
+ *
446
+ * @returns The current LithiaOptions configuration object
447
+ */
448
+ getConfig() {
449
+ return this.config;
450
+ }
451
+ /**
452
+ * Configures internal event handlers for the lifecycle emitter.
453
+ *
454
+ * Sets up handlers for:
455
+ * - `built` event: Triggered after successful compilation, loads routes and events
456
+ * - `error` event: Logs errors with appropriate severity and exits on fatal errors
457
+ *
458
+ * @private
459
+ */
460
+ configureEventEmitter() {
461
+ // Auto-load routes and events after successful build
462
+ this.emitter.on("built", (durationMs) => {
463
+ logger_1.logger.success(`Build completed in ${durationMs.toFixed(2)}ms`);
464
+ this.loadRoutes();
465
+ this.loadEvents();
466
+ });
467
+ // Handle errors with appropriate logging and exit behavior
468
+ this.emitter.on("error", (err) => {
469
+ const level = err instanceof errors_1.LithiaError ? err.level : "error";
470
+ logger_1.logger.error(`[${(0, utils_1.red)(level.toUpperCase())}] ${err?.code ?? "UNKNOWN"} - ${err?.message ?? String(err)}`);
471
+ if (err?.cause) {
472
+ logger_1.logger.debug(`cause:`, err.cause);
473
+ }
474
+ // Fatal errors should terminate the process
475
+ if (level === "fatal") {
476
+ process.exit(1);
477
+ }
478
+ });
479
+ }
480
+ /**
481
+ * Compiles the project using the native Rust compiler.
482
+ *
483
+ * This performs a synchronous build that:
484
+ * - Scans the source directory for routes and events
485
+ * - Compiles TypeScript to JavaScript
486
+ * - Generates route and event manifests (routes.json, events.json)
487
+ *
488
+ * On success, emits the `built` event with build duration in milliseconds.
489
+ * On failure, emits the `error` event.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * lithia.on('built', () => {
494
+ * console.log('Build complete!');
495
+ * });
496
+ * lithia.build();
497
+ * ```
498
+ */
499
+ build() {
500
+ const start = process.hrtime.bigint();
501
+ try {
502
+ (0, native_1.buildProject)(this.sourceRoot, this.outRoot);
503
+ const durationMs = Number(process.hrtime.bigint() - start) / 1_000_000;
504
+ this.emitter.emit("built", durationMs);
505
+ }
506
+ catch (err) {
507
+ this.emitter.emit("error", err);
508
+ }
509
+ }
510
+ /**
511
+ * Loads and validates a JSON manifest file.
512
+ *
513
+ * @param fileName - Name of the manifest file (e.g., 'routes.json')
514
+ * @returns The parsed manifest object
515
+ * @throws {ManifestLoadError} If the file cannot be read or parsed
516
+ * @throws {SchemaVersionMismatchError} If the manifest version doesn't match
517
+ * @private
518
+ */
519
+ loadManifest(fileName) {
520
+ const manifestPath = node_path_1.default.join(this.outRoot, fileName);
521
+ if (!(0, node_fs_1.existsSync)(manifestPath)) {
522
+ return null;
523
+ }
524
+ const raw = (0, node_fs_1.readFileSync)(manifestPath, "utf-8");
525
+ const manifest = JSON.parse(raw);
526
+ const expectedVersion = (0, native_1.schemaVersion)();
527
+ if (manifest.version !== expectedVersion) {
528
+ throw new errors_1.SchemaVersionMismatchError(expectedVersion, manifest.version);
529
+ }
530
+ return manifest;
531
+ }
532
+ /**
533
+ * Loads and validates the routes manifest generated by the compiler.
534
+ *
535
+ * Reads `routes.json` from the output directory and populates the
536
+ * internal routes array. This is automatically called after a successful
537
+ * build (via the `built` event handler).
538
+ *
539
+ * On error, emits an `error` event and leaves routes unchanged.
540
+ */
541
+ loadRoutes() {
542
+ try {
543
+ const manifest = this.loadManifest("routes.json");
544
+ if (!manifest) {
545
+ return;
546
+ }
547
+ this.routes = manifest.routes;
548
+ }
549
+ catch (err) {
550
+ if (err instanceof errors_1.SchemaVersionMismatchError) {
551
+ this.emitter.emit("error", err);
552
+ return;
553
+ }
554
+ this.emitter.emit("error", new errors_1.ManifestLoadError(err));
555
+ }
556
+ }
557
+ /**
558
+ * Loads and validates the events manifest generated by the compiler.
559
+ *
560
+ * Reads `events.json` from the output directory and populates the
561
+ * internal events array. This is automatically called after a successful
562
+ * build (via the `built` event handler).
563
+ *
564
+ * On error, emits an `error` event and leaves events unchanged.
565
+ */
566
+ loadEvents() {
567
+ try {
568
+ const manifest = this.loadManifest("events.json");
569
+ if (!manifest) {
570
+ return;
571
+ }
572
+ this.events = manifest.events;
573
+ }
574
+ catch (err) {
575
+ if (err instanceof errors_1.SchemaVersionMismatchError) {
576
+ this.emitter.emit("error", err);
577
+ return;
578
+ }
579
+ this.emitter.emit("error", new errors_1.ManifestLoadError(err));
580
+ }
581
+ }
582
+ /**
583
+ * Gets the internal EventEmitter instance.
584
+ *
585
+ * The event emitter is used for lifecycle events like:
586
+ * - `built`: Emitted after successful compilation
587
+ * - `error`: Emitted when errors occur
588
+ * - `config:changed`: Emitted when configuration is updated (dev mode)
589
+ *
590
+ * @returns The internal EventEmitter instance
591
+ */
592
+ getEventEmitter() {
593
+ return this.emitter;
594
+ }
595
+ /**
596
+ * Emits a lifecycle event.
597
+ *
598
+ * @param event - The event name to emit
599
+ * @param payload - Optional payload data for the event
600
+ * @returns True if the event had listeners, false otherwise
601
+ *
602
+ * @example
603
+ * ```typescript
604
+ * lithia.emit('custom:event', { data: 'value' });
605
+ * ```
606
+ */
607
+ emit(event, payload) {
608
+ return this.emitter.emit(event, payload);
609
+ }
610
+ /**
611
+ * Registers a listener for a lifecycle event.
612
+ *
613
+ * @param event - The event name to listen for
614
+ * @param listener - Callback function to execute when the event is emitted
615
+ *
616
+ * @example
617
+ * ```typescript
618
+ * lithia.on('built', (durationMs) => {
619
+ * console.log(`Build took ${durationMs}ms`);
620
+ * });
621
+ *
622
+ * lithia.on('error', (error) => {
623
+ * console.error('An error occurred:', error);
624
+ * });
625
+ * ```
626
+ */
627
+ on(event, listener) {
628
+ this.emitter.on(event, listener);
629
+ }
630
+ /**
631
+ * Cleans up resources and removes all event listeners.
632
+ *
633
+ * This method should be called when shutting down the application to:
634
+ * - Close the configuration file watcher
635
+ * - Remove all event listeners to prevent memory leaks
636
+ *
637
+ * @example
638
+ * ```typescript
639
+ * await lithia.stop();
640
+ * lithia.close();
641
+ * ```
642
+ */
643
+ close() {
644
+ this.configWatchHandle?.close?.();
645
+ this.emitter.removeAllListeners();
646
+ }
647
+ }
648
+ exports.Lithia = Lithia;
649
+ //# sourceMappingURL=lithia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lithia.js","sourceRoot":"","sources":["../src/lithia.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;AAEH,6CAA2C;AAC3C,qCAAmD;AACnD,0DAA6B;AAC7B,8CAO2B;AAC3B,4CAAuC;AACvC,4EAAkD;AAClD,qCAA8D;AAC9D,6DAA6E;AAC7E,qCAKkB;AAElB,qCAAkC;AAClC,mDAA8D;AAC9D,sDAG8B;AAG9B;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAEvE,oEAAoE;AACpE,4BAAgB,CAAC,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM;IACnB,wBAAwB,EAAE,KAAK;CAC/B,CAAC,CAAC;AAwCH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG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CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK;QACJ,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;CACD;AA3oBD,wBA2oBC"}
@@ -0,0 +1,11 @@
1
+ export type LogLevel = "info" | "warn" | "error" | "debug" | "success" | "ready" | "event" | "wait";
2
+ export declare class Logger {
3
+ info(msg: any, meta?: any): void;
4
+ warn(msg: any, meta?: any): void;
5
+ error(msg: any, meta?: any): void;
6
+ success(msg: any, meta?: any): void;
7
+ event(msg: any, meta?: any): void;
8
+ debug(msg: any, meta?: any): void;
9
+ wait(msg: any, meta?: any): void;
10
+ }
11
+ export declare const logger: Logger;