@lithia-js/native 1.0.0-canary.2
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/CHANGELOG.md +19 -0
- package/Cargo.toml +31 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/index.d.ts +111 -0
- package/index.js +581 -0
- package/package.json +66 -0
- package/src/builder/compiler.rs +493 -0
- package/src/builder/config.rs +67 -0
- package/src/builder/mod.rs +126 -0
- package/src/builder/sourcemap.rs +36 -0
- package/src/builder/tests.rs +78 -0
- package/src/builder/tsconfig.rs +100 -0
- package/src/builder/types.rs +53 -0
- package/src/events/convention.rs +36 -0
- package/src/events/mod.rs +87 -0
- package/src/events/processor.rs +113 -0
- package/src/events/tests.rs +41 -0
- package/src/events/transformer.rs +78 -0
- package/src/lib.rs +54 -0
- package/src/router/convention.rs +239 -0
- package/src/router/mod.rs +118 -0
- package/src/router/processor.rs +201 -0
- package/src/router/transformer.rs +281 -0
- package/src/scanner/mod.rs +345 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @lithia-js/native
|
|
2
|
+
|
|
3
|
+
## 1.0.0-canary.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- .npmignore update
|
|
8
|
+
|
|
9
|
+
## 1.0.0-canary.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2992e91: Manifest update for workflow compatibility
|
|
14
|
+
|
|
15
|
+
## 1.0.0-canary.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- e9a0904: Lithia v1 canary release. Now with separated modules and napi bindings for build performance
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "lithia_native"
|
|
3
|
+
version = "5.0.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
path = "src/lib.rs"
|
|
8
|
+
crate-type = ["cdylib"]
|
|
9
|
+
|
|
10
|
+
[dependencies]
|
|
11
|
+
napi = { version = "3.8.2", features = ["napi9"] }
|
|
12
|
+
napi-derive = { version = "3.5.1" }
|
|
13
|
+
walkdir = "2.5.0"
|
|
14
|
+
globset = "0.4.18"
|
|
15
|
+
rayon = "1.11"
|
|
16
|
+
swc_common = { version = "18.0.1", features = ["concurrent", "sourcemap"] }
|
|
17
|
+
swc_ecma_codegen = "22.0.0"
|
|
18
|
+
swc_ecma_parser = "33.0.0"
|
|
19
|
+
swc_ecma_transforms_base = "36.0.1"
|
|
20
|
+
swc_ecma_transforms_typescript = "39.0.1"
|
|
21
|
+
swc_ecma_transforms_module = "39.0.0"
|
|
22
|
+
serde_json = "1.0.149"
|
|
23
|
+
swc_ecma_ast = "20.0.0"
|
|
24
|
+
swc_ecma_visit = "20.0.0"
|
|
25
|
+
swc_atoms = "9.0.0"
|
|
26
|
+
pathdiff = "0.2"
|
|
27
|
+
regex = { version = "1.12.2" }
|
|
28
|
+
serde = { version = "1.0.228", features = ["derive"] }
|
|
29
|
+
|
|
30
|
+
[dev-dependencies]
|
|
31
|
+
tempfile = "3.24.0"
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 lithiajs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://github.com/lithia-framework/lithia">
|
|
3
|
+
<img alt="Lithia logo" src="https://raw.githubusercontent.com/lithia-framework/lithia/canary/.github/assets/logo.svg" height="128">
|
|
4
|
+
</a>
|
|
5
|
+
<h1>Lithia</h1>
|
|
6
|
+
<p><strong>The Node.js framework that makes API development feel like magic</strong></p>
|
|
7
|
+
|
|
8
|
+
<a href="https://www.npmjs.com/package/lithia"><img alt="NPM version" src="https://img.shields.io/npm/v/lithia.svg?style=for-the-badge&labelColor=000000"></a>
|
|
9
|
+
<a href="https://github.com/lithia-framework/lithia/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/lithia.svg?style=for-the-badge&labelColor=000000"></a>
|
|
10
|
+
<a href="https://opencollective.com/lithiajs"><img alt="Support Lithia" src="https://img.shields.io/badge/Support%20Lithia-blueviolet.svg?style=for-the-badge&logo=OpenCollective&labelColor=000000&logoWidth=20"></a>
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
Lithia is a next-generation Node.js framework that enables you to build powerful APIs with file-based routing, built-in WebSocket support, and a beautiful development interface.
|
|
17
|
+
|
|
18
|
+
- Visit our [Learn Lithia](https://lithiajs.com/docs) guide to get started.
|
|
19
|
+
- Check out the [Examples](https://github.com/lithia-framework/lithia/tree/main/examples) to see Lithia in action.
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
Visit [https://lithiajs.com/docs](https://lithiajs.com/docs) to view the full documentation.
|
|
24
|
+
|
|
25
|
+
## Community
|
|
26
|
+
|
|
27
|
+
The Lithia community can be found on [GitHub Discussions](https://github.com/lithia-framework/lithia/discussions) where you can ask questions, voice ideas, and share your projects with other people.
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
|
|
31
|
+
Contributions to Lithia are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](CONTRIBUTING.md) to make sure you have a smooth experience contributing to Lithia.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Support the Project
|
|
36
|
+
|
|
37
|
+
If Lithia makes your life easier, consider supporting it:
|
|
38
|
+
|
|
39
|
+
- **Star** this repository
|
|
40
|
+
- **Share** on social media
|
|
41
|
+
- **Sponsor** via [OpenCollective](https://opencollective.com/lithiajs)
|
|
42
|
+
- **Report bugs** and suggest improvements
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
Lithia is [MIT licensed](LICENSE). Free for personal and commercial use.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<div align="center">
|
|
53
|
+
<p><strong>Built with ❤️ by the Lithia community</strong></p>
|
|
54
|
+
<p>
|
|
55
|
+
<a href="https://github.com/lithia-framework/lithia">GitHub</a> •
|
|
56
|
+
<a href="https://lithiajs.com">Documentation</a> •
|
|
57
|
+
<a href="https://opencollective.com/lithiajs">OpenCollective</a> •
|
|
58
|
+
<a href="https://github.com/lithia-framework/lithia/discussions">Discussions</a>
|
|
59
|
+
</p>
|
|
60
|
+
</div>
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Build the project located at `source_root` and emit outputs to `out_root`.
|
|
5
|
+
*
|
|
6
|
+
* This function is exported to the host via N-API and performs the full
|
|
7
|
+
* native compilation pipeline:
|
|
8
|
+
* 1. Reads build configuration from `source_root`.
|
|
9
|
+
* 2. Scans for TypeScript files matching `.ts`.
|
|
10
|
+
* 3. Compiles files (in parallel) using the embedded SWC-based compiler.
|
|
11
|
+
* 4. Aggregates compilation results and fails the build if there are errors.
|
|
12
|
+
* 5. If route files exist in the output, produces a `routes.json` manifest
|
|
13
|
+
* containing route metadata consumed by the runtime.
|
|
14
|
+
*
|
|
15
|
+
* Errors are returned as `napi::Error` to be propagated to the host.
|
|
16
|
+
* High-level build entrypoint for the native TypeScript builder.
|
|
17
|
+
*
|
|
18
|
+
* `build_project` coordinates scanning the source tree, applying route
|
|
19
|
+
* conventions, and producing a `RoutesManifest` that can be consumed by the
|
|
20
|
+
* runtime. Currently this function is a thin wrapper and may be expanded to
|
|
21
|
+
* run parallel compilation and emit artifacts to disk.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildProject(sourceRoot: string, outRoot: string): void
|
|
24
|
+
|
|
25
|
+
/** Serializable event representation sent to the host (N-API). */
|
|
26
|
+
export interface Event {
|
|
27
|
+
/** Event name (e.g., "chat:message" or "connection") */
|
|
28
|
+
name: string
|
|
29
|
+
/** Absolute filesystem path to the compiled handler (JS) file. */
|
|
30
|
+
filePath: string
|
|
31
|
+
/** Optional namespace (e.g., "chat" for "chat:message"). */
|
|
32
|
+
namespace?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Manifest containing all discovered events, serializable to the host. */
|
|
36
|
+
export interface EventsManifest {
|
|
37
|
+
/** Manifest version string. */
|
|
38
|
+
version: string
|
|
39
|
+
/** List of events. */
|
|
40
|
+
events: Array<Event>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Information about a discovered file.
|
|
45
|
+
* - `path` is the path relative to the scanned directory (using `/` as
|
|
46
|
+
* separator on all platforms).
|
|
47
|
+
* - `full_path` is the absolute filesystem path to the file.
|
|
48
|
+
*/
|
|
49
|
+
export interface FileInfo {
|
|
50
|
+
/** Relative path from the scanned directory */
|
|
51
|
+
path: string
|
|
52
|
+
/** Absolute path from the filesystem root */
|
|
53
|
+
fullPath: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Serializable route representation sent to the host (N-API).
|
|
58
|
+
* Fields are camel-cased to be idiomatic on the JavaScript side.
|
|
59
|
+
*/
|
|
60
|
+
export interface Route {
|
|
61
|
+
/** Uppercase HTTP method name, e.g. `GET` or `POST`, when present. */
|
|
62
|
+
method?: string
|
|
63
|
+
/** Normalized route path (always starting with `/`). */
|
|
64
|
+
path: string
|
|
65
|
+
/** True when the route contains dynamic segments. */
|
|
66
|
+
dynamic: boolean
|
|
67
|
+
/** Absolute filesystem path to the source file backing the route. */
|
|
68
|
+
filePath: string
|
|
69
|
+
/** Generated route matching regex as a string. */
|
|
70
|
+
regex: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Manifest containing all discovered routes, serializable to the host. */
|
|
74
|
+
export interface RoutesManifest {
|
|
75
|
+
/** Manifest version string. */
|
|
76
|
+
version: string
|
|
77
|
+
/** List of routes. */
|
|
78
|
+
routes: Array<Route>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Scan a directory tree for files matching the provided `path_components`.
|
|
83
|
+
*
|
|
84
|
+
* `path_components` is a vector of path segments used as roots for the
|
|
85
|
+
* scanner (for example `["examples/1-basic-api"]`). `options` may include
|
|
86
|
+
* include/ignore globs. Returns a list of `FileInfo` describing discovered
|
|
87
|
+
* files or an error which is converted into a `napi::Error` for the host.
|
|
88
|
+
*/
|
|
89
|
+
export declare function scanDir(pathComponents: Array<string>, options?: ScanOptions | undefined | null): Array<FileInfo>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Options controlling scanning behaviour.
|
|
93
|
+
* - `include`: list of glob patterns that select files to include. If
|
|
94
|
+
* omitted or empty, the scanner returns an empty result set.
|
|
95
|
+
* - `ignore`: optional list of glob patterns used to exclude matching files
|
|
96
|
+
* from the previously included set.
|
|
97
|
+
*/
|
|
98
|
+
export interface ScanOptions {
|
|
99
|
+
/** Glob patterns to include files. */
|
|
100
|
+
include?: Array<string>
|
|
101
|
+
/** Glob patterns to ignore (applied after include matching). */
|
|
102
|
+
ignore?: Array<string>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Return the native crate version embedded at compile time.
|
|
107
|
+
*
|
|
108
|
+
* This returns the value of `CARGO_PKG_VERSION` so the host can verify the
|
|
109
|
+
* native binary version matches expectations.
|
|
110
|
+
*/
|
|
111
|
+
export declare function schemaVersion(): string
|