@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.
- package/README.md +21 -55
- package/dist/_index.d.ts +128 -0
- package/dist/_index.mjs +1426 -3
- package/dist/_index.mjs.map +1 -1
- package/dist/index.d.ts +439 -0
- package/dist/index.mjs +668 -9
- package/dist/index.mjs.map +1 -1
- package/dist/protocol-Ddx-dP-_.d.ts +298 -0
- package/dist/tasks-qNCrAmuM.d.ts +10 -0
- package/dist/workers/app-worker.d.ts +2 -0
- package/dist/workers/app-worker.mjs +1312 -42
- package/dist/workers/app-worker.mjs.map +1 -1
- package/dist/workers/task-worker.d.ts +21 -0
- package/dist/workers/task-worker.mjs +146 -0
- package/dist/workers/task-worker.mjs.map +1 -0
- package/package.json +13 -10
- package/dist/_index.d.mts +0 -3
- package/dist/builder.d.mts +0 -21
- package/dist/builder.mjs +0 -105
- package/dist/builder.mjs.map +0 -1
- package/dist/config.d.mts +0 -111
- package/dist/config.mjs +0 -44
- package/dist/config.mjs.map +0 -1
- package/dist/context/event-context.d.mts +0 -16
- package/dist/context/event-context.mjs +0 -27
- package/dist/context/event-context.mjs.map +0 -1
- package/dist/context/lithia-context.d.mts +0 -9
- package/dist/context/lithia-context.mjs +0 -22
- package/dist/context/lithia-context.mjs.map +0 -1
- package/dist/context/request-context.d.mts +0 -19
- package/dist/context/request-context.mjs +0 -27
- package/dist/context/request-context.mjs.map +0 -1
- package/dist/errors/app/client.d.mts +0 -19
- package/dist/errors/app/client.mjs +0 -20
- package/dist/errors/app/client.mjs.map +0 -1
- package/dist/errors/app/index.d.mts +0 -2
- package/dist/errors/app/index.mjs +0 -3
- package/dist/errors/app/index.mjs.map +0 -1
- package/dist/errors/app/server.d.mts +0 -10
- package/dist/errors/app/server.mjs +0 -17
- package/dist/errors/app/server.mjs.map +0 -1
- package/dist/errors/base.d.mts +0 -16
- package/dist/errors/base.mjs +0 -29
- package/dist/errors/base.mjs.map +0 -1
- package/dist/errors/internal/context.d.mts +0 -13
- package/dist/errors/internal/context.mjs +0 -18
- package/dist/errors/internal/context.mjs.map +0 -1
- package/dist/errors/internal/index.d.mts +0 -2
- package/dist/errors/internal/index.mjs +0 -3
- package/dist/errors/internal/index.mjs.map +0 -1
- package/dist/errors/internal/loader.d.mts +0 -13
- package/dist/errors/internal/loader.mjs +0 -20
- package/dist/errors/internal/loader.mjs.map +0 -1
- package/dist/hooks/event-hooks.d.mts +0 -6
- package/dist/hooks/event-hooks.mjs +0 -14
- package/dist/hooks/event-hooks.mjs.map +0 -1
- package/dist/hooks/lithia-hooks.d.mts +0 -16
- package/dist/hooks/lithia-hooks.mjs +0 -71
- package/dist/hooks/lithia-hooks.mjs.map +0 -1
- package/dist/hooks/route-hooks.d.mts +0 -53
- package/dist/hooks/route-hooks.mjs +0 -66
- package/dist/hooks/route-hooks.mjs.map +0 -1
- package/dist/index.d.mts +0 -11
- package/dist/lithia-app.d.mts +0 -36
- package/dist/lithia-app.mjs +0 -97
- package/dist/lithia-app.mjs.map +0 -1
- package/dist/lithia-host.d.mts +0 -80
- package/dist/lithia-host.mjs +0 -333
- package/dist/lithia-host.mjs.map +0 -1
- package/dist/meta.d.mts +0 -1
- package/dist/meta.mjs +0 -3
- package/dist/meta.mjs.map +0 -1
- package/dist/module-loader.d.ts +0 -10
- package/dist/module-loader.js +0 -35
- package/dist/module-loader.js.map +0 -1
- package/dist/scanner.d.mts +0 -11
- package/dist/scanner.mjs +0 -26
- package/dist/scanner.mjs.map +0 -1
- package/dist/server/event-processor.d.mts +0 -53
- package/dist/server/event-processor.mjs +0 -96
- package/dist/server/event-processor.mjs.map +0 -1
- package/dist/server/request-processor.d.mts +0 -83
- package/dist/server/request-processor.mjs +0 -263
- package/dist/server/request-processor.mjs.map +0 -1
- package/dist/server/request.d.mts +0 -106
- package/dist/server/request.mjs +0 -236
- package/dist/server/request.mjs.map +0 -1
- package/dist/server/response.d.mts +0 -103
- package/dist/server/response.mjs +0 -214
- package/dist/server/response.mjs.map +0 -1
- package/dist/server/server.d.mts +0 -76
- package/dist/server/server.mjs +0 -196
- package/dist/server/server.mjs.map +0 -1
- package/dist/strategy/events/convention.d.mts +0 -3
- package/dist/strategy/events/convention.mjs +0 -7
- package/dist/strategy/events/convention.mjs.map +0 -1
- package/dist/strategy/events/index.d.mts +0 -4
- package/dist/strategy/events/index.mjs +0 -5
- package/dist/strategy/events/index.mjs.map +0 -1
- package/dist/strategy/events/manifest.d.mts +0 -11
- package/dist/strategy/events/manifest.mjs +0 -34
- package/dist/strategy/events/manifest.mjs.map +0 -1
- package/dist/strategy/events/processor.d.mts +0 -15
- package/dist/strategy/events/processor.mjs +0 -38
- package/dist/strategy/events/processor.mjs.map +0 -1
- package/dist/strategy/events/transformer.d.mts +0 -6
- package/dist/strategy/events/transformer.mjs +0 -24
- package/dist/strategy/events/transformer.mjs.map +0 -1
- package/dist/strategy/functions/convention.d.mts +0 -9
- package/dist/strategy/functions/convention.mjs +0 -16
- package/dist/strategy/functions/convention.mjs.map +0 -1
- package/dist/strategy/functions/index.d.mts +0 -4
- package/dist/strategy/functions/index.mjs +0 -5
- package/dist/strategy/functions/index.mjs.map +0 -1
- package/dist/strategy/functions/manifest.d.mts +0 -11
- package/dist/strategy/functions/manifest.mjs +0 -34
- package/dist/strategy/functions/manifest.mjs.map +0 -1
- package/dist/strategy/functions/processor.d.mts +0 -16
- package/dist/strategy/functions/processor.mjs +0 -24
- package/dist/strategy/functions/processor.mjs.map +0 -1
- package/dist/strategy/functions/transformer.d.mts +0 -5
- package/dist/strategy/functions/transformer.mjs +0 -18
- package/dist/strategy/functions/transformer.mjs.map +0 -1
- package/dist/strategy/routes/convention.d.mts +0 -9
- package/dist/strategy/routes/convention.mjs +0 -14
- package/dist/strategy/routes/convention.mjs.map +0 -1
- package/dist/strategy/routes/index.d.mts +0 -4
- package/dist/strategy/routes/index.mjs +0 -5
- package/dist/strategy/routes/index.mjs.map +0 -1
- package/dist/strategy/routes/manifest.d.mts +0 -19
- package/dist/strategy/routes/manifest.mjs +0 -31
- package/dist/strategy/routes/manifest.mjs.map +0 -1
- package/dist/strategy/routes/processor.d.mts +0 -23
- package/dist/strategy/routes/processor.mjs +0 -39
- package/dist/strategy/routes/processor.mjs.map +0 -1
- package/dist/strategy/routes/transformer.d.mts +0 -56
- package/dist/strategy/routes/transformer.mjs +0 -109
- package/dist/strategy/routes/transformer.mjs.map +0 -1
- package/dist/types-generation.d.mts +0 -10
- package/dist/types-generation.mjs +0 -44
- package/dist/types-generation.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.mts +0 -2
- package/dist/utils.mjs +0 -13
- package/dist/utils.mjs.map +0 -1
- package/dist/workers/app-worker.d.mts +0 -1
- package/dist/workers/function-worker.d.mts +0 -3
- package/dist/workers/function-worker.mjs +0 -28
- 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
|
|
6
|
-
<p><strong>The
|
|
5
|
+
<h1>@lithia-js/core</h1>
|
|
6
|
+
<p><strong>The main Lithia runtime package.</strong></p>
|
|
7
7
|
|
|
8
|
-
<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
|
-
##
|
|
16
|
+
## Overview
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`@lithia-js/core` provides the main framework primitives:
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
28
|
+
## Example
|
|
29
29
|
|
|
30
|
-
```
|
|
31
|
-
// routes/hello/route.get.ts
|
|
30
|
+
```ts
|
|
32
31
|
import type { RouteHandler } from "@lithia-js/core";
|
|
33
32
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
33
|
+
const hello: RouteHandler = async (_req, res) => {
|
|
34
|
+
res.json({ message: "Hello, world!" });
|
|
35
|
+
};
|
|
38
36
|
|
|
39
|
-
export default
|
|
40
|
-
// Available at: GET /hello
|
|
37
|
+
export default hello;
|
|
41
38
|
```
|
|
42
39
|
|
|
43
|
-
##
|
|
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
|
-
|
|
59
|
-
|
|
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).
|
package/dist/_index.d.ts
ADDED
|
@@ -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 };
|