@tsonic/nodejs 10.0.12 → 10.0.13
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 +58 -18
- package/package.json +1 -1
- package/tsonic.bindings.json +10 -0
package/README.md
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
# @tsonic/nodejs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node-style APIs for **Tsonic** (TypeScript → .NET).
|
|
4
|
+
|
|
5
|
+
Use `@tsonic/nodejs` when you want Node-like modules (`fs`, `path`, `events`, `crypto`, `process`, `http`, …) while still compiling to a native binary with `tsonic`.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### New project
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
mkdir my-app && cd my-app
|
|
13
|
+
tsonic init
|
|
14
|
+
tsonic add npm @tsonic/nodejs
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Existing project
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
tsonic add npm @tsonic/nodejs
|
|
22
|
+
```
|
|
4
23
|
|
|
5
24
|
## Versioning
|
|
6
25
|
|
|
@@ -10,18 +29,10 @@ This repo is versioned by **.NET major**:
|
|
|
10
29
|
|
|
11
30
|
When publishing, run: `npm publish versions/10 --access public`
|
|
12
31
|
|
|
13
|
-
##
|
|
32
|
+
## Core Modules (what you get)
|
|
14
33
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- **Primitive aliases** - `int`, `long`, `decimal`, etc. via `@tsonic/core`
|
|
18
|
-
- **Full type safety** - Complete TypeScript declarations
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install @tsonic/nodejs @tsonic/dotnet @tsonic/core
|
|
24
|
-
```
|
|
34
|
+
- `fs`, `path`, `events`, `crypto`, `process`
|
|
35
|
+
- `http` (separate module entrypoint)
|
|
25
36
|
|
|
26
37
|
## Usage
|
|
27
38
|
|
|
@@ -50,30 +61,59 @@ const dir = path.dirname(fullPath);
|
|
|
50
61
|
### Events
|
|
51
62
|
|
|
52
63
|
```typescript
|
|
53
|
-
import { EventEmitter } from "@tsonic/nodejs/index.js";
|
|
64
|
+
import { EventEmitter, console } from "@tsonic/nodejs/index.js";
|
|
54
65
|
|
|
55
66
|
class MyEmitter extends EventEmitter {}
|
|
56
67
|
const emitter = new MyEmitter();
|
|
57
68
|
emitter.on("data", (chunk) => console.log(chunk));
|
|
58
69
|
```
|
|
59
70
|
|
|
71
|
+
### Crypto
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { crypto } from "@tsonic/nodejs/index.js";
|
|
75
|
+
|
|
76
|
+
const hash = crypto.createHash("sha256").update("hello").digest("hex");
|
|
77
|
+
void hash;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Process
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { process } from "@tsonic/nodejs/index.js";
|
|
84
|
+
|
|
85
|
+
const cwd = process.cwd();
|
|
86
|
+
void cwd;
|
|
87
|
+
```
|
|
88
|
+
|
|
60
89
|
### HTTP
|
|
61
90
|
|
|
62
91
|
```typescript
|
|
63
92
|
import { http } from "@tsonic/nodejs/nodejs.Http.js";
|
|
64
93
|
```
|
|
65
94
|
|
|
95
|
+
## Imports (important)
|
|
96
|
+
|
|
97
|
+
This is an ESM package. Import from the explicit entrypoints:
|
|
98
|
+
|
|
99
|
+
- `@tsonic/nodejs/index.js` for most Node-style APIs (`fs`, `path`, `crypto`, `process`, …)
|
|
100
|
+
- submodules like `@tsonic/nodejs/nodejs.Http.js` for separately emitted namespaces
|
|
101
|
+
|
|
102
|
+
Node’s built-in specifiers like `node:fs` are **not** supported here.
|
|
103
|
+
|
|
104
|
+
## Relationship to `@tsonic/js`
|
|
105
|
+
|
|
106
|
+
- `@tsonic/js` provides JavaScript runtime APIs (JS-style `console`, `JSON`, timers, etc.)
|
|
107
|
+
- `@tsonic/nodejs` provides Node-style modules (`fs`, `path`, `crypto`, `http`, etc.)
|
|
108
|
+
|
|
66
109
|
## Documentation
|
|
67
110
|
|
|
68
|
-
-
|
|
111
|
+
- https://github.com/tsoniclang/nodejs/blob/main/docs/README.md
|
|
69
112
|
- https://tsonic.org/nodejs/
|
|
70
113
|
|
|
71
114
|
## Naming Conventions
|
|
72
115
|
|
|
73
|
-
- **
|
|
74
|
-
- **Members**: camelCase (TypeScript convention)
|
|
75
|
-
|
|
76
|
-
To generate CLR/PascalCase member names, regenerate with `--naming clr` (or omit `--naming js`).
|
|
116
|
+
- `@tsonic/nodejs` intentionally uses **Node/JS-style naming** (camelCase members).
|
|
77
117
|
|
|
78
118
|
## Development
|
|
79
119
|
|
package/package.json
CHANGED