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

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 (151) hide show
  1. package/README.md +21 -55
  2. package/dist/_index.d.ts +128 -0
  3. package/dist/_index.mjs +1426 -3
  4. package/dist/_index.mjs.map +1 -1
  5. package/dist/index.d.ts +439 -0
  6. package/dist/index.mjs +668 -9
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/protocol-Ddx-dP-_.d.ts +298 -0
  9. package/dist/tasks-qNCrAmuM.d.ts +10 -0
  10. package/dist/workers/app-worker.d.ts +2 -0
  11. package/dist/workers/app-worker.mjs +1312 -42
  12. package/dist/workers/app-worker.mjs.map +1 -1
  13. package/dist/workers/task-worker.d.ts +21 -0
  14. package/dist/workers/task-worker.mjs +146 -0
  15. package/dist/workers/task-worker.mjs.map +1 -0
  16. package/package.json +13 -10
  17. package/dist/_index.d.mts +0 -3
  18. package/dist/builder.d.mts +0 -21
  19. package/dist/builder.mjs +0 -105
  20. package/dist/builder.mjs.map +0 -1
  21. package/dist/config.d.mts +0 -111
  22. package/dist/config.mjs +0 -44
  23. package/dist/config.mjs.map +0 -1
  24. package/dist/context/event-context.d.mts +0 -16
  25. package/dist/context/event-context.mjs +0 -27
  26. package/dist/context/event-context.mjs.map +0 -1
  27. package/dist/context/lithia-context.d.mts +0 -9
  28. package/dist/context/lithia-context.mjs +0 -22
  29. package/dist/context/lithia-context.mjs.map +0 -1
  30. package/dist/context/request-context.d.mts +0 -19
  31. package/dist/context/request-context.mjs +0 -27
  32. package/dist/context/request-context.mjs.map +0 -1
  33. package/dist/errors/app/client.d.mts +0 -19
  34. package/dist/errors/app/client.mjs +0 -20
  35. package/dist/errors/app/client.mjs.map +0 -1
  36. package/dist/errors/app/index.d.mts +0 -2
  37. package/dist/errors/app/index.mjs +0 -3
  38. package/dist/errors/app/index.mjs.map +0 -1
  39. package/dist/errors/app/server.d.mts +0 -10
  40. package/dist/errors/app/server.mjs +0 -17
  41. package/dist/errors/app/server.mjs.map +0 -1
  42. package/dist/errors/base.d.mts +0 -16
  43. package/dist/errors/base.mjs +0 -29
  44. package/dist/errors/base.mjs.map +0 -1
  45. package/dist/errors/internal/context.d.mts +0 -13
  46. package/dist/errors/internal/context.mjs +0 -18
  47. package/dist/errors/internal/context.mjs.map +0 -1
  48. package/dist/errors/internal/index.d.mts +0 -2
  49. package/dist/errors/internal/index.mjs +0 -3
  50. package/dist/errors/internal/index.mjs.map +0 -1
  51. package/dist/errors/internal/loader.d.mts +0 -13
  52. package/dist/errors/internal/loader.mjs +0 -20
  53. package/dist/errors/internal/loader.mjs.map +0 -1
  54. package/dist/hooks/event-hooks.d.mts +0 -6
  55. package/dist/hooks/event-hooks.mjs +0 -14
  56. package/dist/hooks/event-hooks.mjs.map +0 -1
  57. package/dist/hooks/lithia-hooks.d.mts +0 -16
  58. package/dist/hooks/lithia-hooks.mjs +0 -71
  59. package/dist/hooks/lithia-hooks.mjs.map +0 -1
  60. package/dist/hooks/route-hooks.d.mts +0 -53
  61. package/dist/hooks/route-hooks.mjs +0 -66
  62. package/dist/hooks/route-hooks.mjs.map +0 -1
  63. package/dist/index.d.mts +0 -11
  64. package/dist/lithia-app.d.mts +0 -36
  65. package/dist/lithia-app.mjs +0 -97
  66. package/dist/lithia-app.mjs.map +0 -1
  67. package/dist/lithia-host.d.mts +0 -80
  68. package/dist/lithia-host.mjs +0 -333
  69. package/dist/lithia-host.mjs.map +0 -1
  70. package/dist/meta.d.mts +0 -1
  71. package/dist/meta.mjs +0 -3
  72. package/dist/meta.mjs.map +0 -1
  73. package/dist/module-loader.d.ts +0 -10
  74. package/dist/module-loader.js +0 -35
  75. package/dist/module-loader.js.map +0 -1
  76. package/dist/scanner.d.mts +0 -11
  77. package/dist/scanner.mjs +0 -26
  78. package/dist/scanner.mjs.map +0 -1
  79. package/dist/server/event-processor.d.mts +0 -53
  80. package/dist/server/event-processor.mjs +0 -96
  81. package/dist/server/event-processor.mjs.map +0 -1
  82. package/dist/server/request-processor.d.mts +0 -83
  83. package/dist/server/request-processor.mjs +0 -263
  84. package/dist/server/request-processor.mjs.map +0 -1
  85. package/dist/server/request.d.mts +0 -106
  86. package/dist/server/request.mjs +0 -236
  87. package/dist/server/request.mjs.map +0 -1
  88. package/dist/server/response.d.mts +0 -103
  89. package/dist/server/response.mjs +0 -214
  90. package/dist/server/response.mjs.map +0 -1
  91. package/dist/server/server.d.mts +0 -76
  92. package/dist/server/server.mjs +0 -196
  93. package/dist/server/server.mjs.map +0 -1
  94. package/dist/strategy/events/convention.d.mts +0 -3
  95. package/dist/strategy/events/convention.mjs +0 -7
  96. package/dist/strategy/events/convention.mjs.map +0 -1
  97. package/dist/strategy/events/index.d.mts +0 -4
  98. package/dist/strategy/events/index.mjs +0 -5
  99. package/dist/strategy/events/index.mjs.map +0 -1
  100. package/dist/strategy/events/manifest.d.mts +0 -11
  101. package/dist/strategy/events/manifest.mjs +0 -34
  102. package/dist/strategy/events/manifest.mjs.map +0 -1
  103. package/dist/strategy/events/processor.d.mts +0 -15
  104. package/dist/strategy/events/processor.mjs +0 -38
  105. package/dist/strategy/events/processor.mjs.map +0 -1
  106. package/dist/strategy/events/transformer.d.mts +0 -6
  107. package/dist/strategy/events/transformer.mjs +0 -24
  108. package/dist/strategy/events/transformer.mjs.map +0 -1
  109. package/dist/strategy/functions/convention.d.mts +0 -9
  110. package/dist/strategy/functions/convention.mjs +0 -16
  111. package/dist/strategy/functions/convention.mjs.map +0 -1
  112. package/dist/strategy/functions/index.d.mts +0 -4
  113. package/dist/strategy/functions/index.mjs +0 -5
  114. package/dist/strategy/functions/index.mjs.map +0 -1
  115. package/dist/strategy/functions/manifest.d.mts +0 -11
  116. package/dist/strategy/functions/manifest.mjs +0 -34
  117. package/dist/strategy/functions/manifest.mjs.map +0 -1
  118. package/dist/strategy/functions/processor.d.mts +0 -16
  119. package/dist/strategy/functions/processor.mjs +0 -24
  120. package/dist/strategy/functions/processor.mjs.map +0 -1
  121. package/dist/strategy/functions/transformer.d.mts +0 -5
  122. package/dist/strategy/functions/transformer.mjs +0 -18
  123. package/dist/strategy/functions/transformer.mjs.map +0 -1
  124. package/dist/strategy/routes/convention.d.mts +0 -9
  125. package/dist/strategy/routes/convention.mjs +0 -14
  126. package/dist/strategy/routes/convention.mjs.map +0 -1
  127. package/dist/strategy/routes/index.d.mts +0 -4
  128. package/dist/strategy/routes/index.mjs +0 -5
  129. package/dist/strategy/routes/index.mjs.map +0 -1
  130. package/dist/strategy/routes/manifest.d.mts +0 -19
  131. package/dist/strategy/routes/manifest.mjs +0 -31
  132. package/dist/strategy/routes/manifest.mjs.map +0 -1
  133. package/dist/strategy/routes/processor.d.mts +0 -23
  134. package/dist/strategy/routes/processor.mjs +0 -39
  135. package/dist/strategy/routes/processor.mjs.map +0 -1
  136. package/dist/strategy/routes/transformer.d.mts +0 -56
  137. package/dist/strategy/routes/transformer.mjs +0 -109
  138. package/dist/strategy/routes/transformer.mjs.map +0 -1
  139. package/dist/types-generation.d.mts +0 -10
  140. package/dist/types-generation.mjs +0 -44
  141. package/dist/types-generation.mjs.map +0 -1
  142. package/dist/types.d.ts +0 -1
  143. package/dist/types.js +0 -2
  144. package/dist/types.js.map +0 -1
  145. package/dist/utils.d.mts +0 -2
  146. package/dist/utils.mjs +0 -13
  147. package/dist/utils.mjs.map +0 -1
  148. package/dist/workers/app-worker.d.mts +0 -1
  149. package/dist/workers/function-worker.d.mts +0 -3
  150. package/dist/workers/function-worker.mjs +0 -28
  151. package/dist/workers/function-worker.mjs.map +0 -1
package/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
  <a href="https://github.com/lithia-framework/lithia">
3
3
  <img alt="Lithia logo" src="https://raw.githubusercontent.com/lithia-framework/lithia/canary/.github/assets/logo.svg" height="128">
4
4
  </a>
5
- <h1>Lithia</h1>
6
- <p><strong>The high-performance Node.js framework powered by Rust.</strong></p>
5
+ <h1>@lithia-js/core</h1>
6
+ <p><strong>The main Lithia runtime package.</strong></p>
7
7
 
8
- <p>Build APIs with magic, speed, and Type Safety by default.</p>
8
+ <p>Routes, events, async tasks, startup bootstrap, config, and the public runtime APIs.</p>
9
9
 
10
10
  <a href="https://www.npmjs.com/package/@lithia-js/core"><img alt="NPM version" src="https://img.shields.io/npm/v/@lithia-js/core.svg?style=for-the-badge&labelColor=000000"></a>
11
11
  <a href="https://github.com/lithia-framework/lithia/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@lithia-js/core.svg?style=for-the-badge&labelColor=000000"></a>
@@ -13,65 +13,31 @@
13
13
 
14
14
  </div>
15
15
 
16
- ## 🚀 Quick Start
16
+ ## Overview
17
17
 
18
- Build your first Lithia app in seconds:
18
+ `@lithia-js/core` provides the main framework primitives:
19
19
 
20
- ```bash
21
- npx create-lithia@latest my-app
22
- cd my-app
23
- npm run dev
24
- ```
25
-
26
- ## 🪄 Magic in Action
20
+ - `defineConfig()` for `lithia.config.ts`
21
+ - file-based HTTP routes and Socket.IO events
22
+ - request/response primitives and route/event hooks
23
+ - dependency injection with `provide()` and `useDependency()`
24
+ - native async tasks with `executeTask()` and `dispatchTask()`
25
+ - optional `src/app/server.ts` startup bootstrap
26
+ - route metadata types for OpenAPI generation
27
27
 
28
- Lithia uses a clean, file-based routing convention. No boilerplate, just focus on your logic.
28
+ ## Example
29
29
 
30
- ```typescript
31
- // routes/hello/route.get.ts
30
+ ```ts
32
31
  import type { RouteHandler } from "@lithia-js/core";
33
32
 
34
- const Hello: RouteHandler = async (req, res) => {
35
- const name = req.query.name || "World";
36
- return res.json({ message: `Hello, ${name}!` });
37
- }
33
+ const hello: RouteHandler = async (_req, res) => {
34
+ res.json({ message: "Hello, world!" });
35
+ };
38
36
 
39
- export default Hello;
40
- // Available at: GET /hello
37
+ export default hello;
41
38
  ```
42
39
 
43
- ## Features
44
-
45
- * **Intuitive Routing**: Method-based file naming (`.get.ts`, `.post.ts`) for automatic route registration.
46
- * **Native Performance**: Core engine written in Rust for lightning-fast request handling.
47
- * **Full-stack Ready**: Native support for WebSockets, Auth, and Drizzle ORM.
48
- * **Modern Stack**: Ships with Biome and TypeScript pre-configured for the best DX.
49
-
50
- ## 📖 Documentation
51
-
52
- Everything you need to know is at [lithiajs.com/docs](https://lithiajs.com/docs).
53
-
54
- ---
55
-
56
- ## 🤝 Community & Support
40
+ ## Internal layout
57
41
 
58
- * **Discussions**: [GitHub Discussions](https://github.com/lithia-framework/lithia/discussions)
59
- * **Contribution**: We love PRs! See [CONTRIBUTING.md](https://www.google.com/search?q=CONTRIBUTING.md)
60
- * **Sponsor**: Support the magic on [OpenCollective](https://opencollective.com/lithiajs)
61
-
62
- ---
63
-
64
- ## License
65
-
66
- Lithia is [MIT licensed](https://www.google.com/search?q=LICENSE). Built with ❤️ by Lucas Arch and the community.
67
-
68
- ---
69
-
70
- <div align="center">
71
- <p>
72
- <a href="https://github.com/lithia-framework/lithia">GitHub</a> •
73
- <a href="https://lithiajs.com">Documentation</a> •
74
- <a href="https://opencollective.com/lithiajs">OpenCollective</a> •
75
- <a href="https://github.com/lithia-framework/lithia/discussions">Discussions</a>
76
- </p>
77
- </div>
42
+ The internal package layout is documented in
43
+ [src/README.md](./src/README.md).
@@ -0,0 +1,128 @@
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';
4
+ import '@lithia-js/utils';
5
+ import 'c12';
6
+
7
+ type Environment = "test" | "build" | "production" | "development";
8
+
9
+ /**
10
+ * Thrown when a Lithia hook is used outside a managed Lithia execution
11
+ * context.
12
+ */
13
+ declare class NotInLithiaContextError extends LithiaError {
14
+ constructor();
15
+ }
16
+
17
+ /**
18
+ * Minimal runtime options required to bootstrap the Lithia host.
19
+ */
20
+ interface LithiaOpts {
21
+ environment: Environment;
22
+ }
23
+ /**
24
+ * Main-process orchestrator for the Lithia runtime.
25
+ *
26
+ * The host is responsible for loading configuration and manifests, building the
27
+ * app, spawning the app worker, and coordinating async task execution.
28
+ */
29
+ declare class HostSupervisor {
30
+ private readonly opts;
31
+ private _config;
32
+ private _env;
33
+ private readonly _builder;
34
+ private readonly _manifestStore;
35
+ private readonly _appSupervisor;
36
+ private readonly _taskRunner;
37
+ private _appCount;
38
+ private _lastPortUsed;
39
+ constructor(opts: LithiaOpts);
40
+ get config(): LithiaOptions;
41
+ get environment(): Environment;
42
+ get isAppReady(): boolean;
43
+ get routes(): Route[];
44
+ get events(): Event[];
45
+ get tasks(): TaskCore[];
46
+ /**
47
+ * Loads the user configuration file into the host runtime.
48
+ */
49
+ loadConfig(): Promise<void>;
50
+ /**
51
+ * Loads and merges configured environment files into the host snapshot.
52
+ */
53
+ loadEnv(): Promise<Record<string, string>>;
54
+ /**
55
+ * Loads the routes manifest from the current build output.
56
+ */
57
+ loadRoutes(): Promise<void>;
58
+ /**
59
+ * Loads the events manifest from the current build output.
60
+ */
61
+ loadEvents(): Promise<void>;
62
+ /**
63
+ * Loads the async tasks manifest from the current build output.
64
+ */
65
+ loadTasks(): Promise<void>;
66
+ /**
67
+ * Returns a copy of the currently loaded environment snapshot.
68
+ */
69
+ getEnvSnapshot(): Record<string, string>;
70
+ /**
71
+ * Replaces the in-memory resolved config snapshot.
72
+ */
73
+ replaceConfig(config: LithiaOptions): void;
74
+ /**
75
+ * Replaces the in-memory environment snapshot.
76
+ */
77
+ replaceEnv(env: Record<string, string>): void;
78
+ /**
79
+ * Builds the application output and manifests.
80
+ *
81
+ * Returns `true` when the build succeeds. In non-build environments, failures
82
+ * are reported and surfaced as `false` so the caller can decide how to
83
+ * recover.
84
+ */
85
+ build(): Promise<boolean>;
86
+ /**
87
+ * Loads config/env and prints the CLI header for the current run.
88
+ */
89
+ setup(): Promise<void>;
90
+ /**
91
+ * Starts the app worker using the latest manifests and runtime state.
92
+ */
93
+ start(): Promise<void>;
94
+ /**
95
+ * Reloads manifests, resets task workers, and swaps the app worker.
96
+ */
97
+ reload(): Promise<void>;
98
+ /**
99
+ * Stops task execution and tears down the app worker.
100
+ */
101
+ stop(): Promise<void>;
102
+ /**
103
+ * Replaces the current app worker with a fresh instance.
104
+ */
105
+ swapApp(): Promise<void>;
106
+ /**
107
+ * Prints the Lithia CLI header and the env files currently in use.
108
+ */
109
+ printHeader(): Promise<void>;
110
+ /**
111
+ * Prints the loaded routes in a CLI-friendly tree format.
112
+ */
113
+ printRouteTree(): void;
114
+ /**
115
+ * Prints the loaded events in a CLI-friendly tree format.
116
+ */
117
+ printEventTree(): void;
118
+ /**
119
+ * Prints the loaded async tasks in a CLI-friendly tree format.
120
+ */
121
+ printTaskTree(): void;
122
+ private handleAppMessage;
123
+ private printTree;
124
+ private getAvailableEnvFiles;
125
+ private ensureConfigLoaded;
126
+ }
127
+
128
+ export { HostSupervisor, NotInLithiaContextError };