@tsonic/nodejs 10.0.37 → 10.0.39
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 +38 -27
- package/bindings.json +204 -0
- package/node-aliases.d.ts +133 -0
- package/package.json +1 -1
- package/tsonic.bindings.json +6 -0
- package/tsonic.surface.json +7 -0
package/README.md
CHANGED
|
@@ -15,18 +15,22 @@ Use `@tsonic/nodejs` when you want Node-like modules (`fs`, `path`, `events`, `c
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
mkdir my-app && cd my-app
|
|
18
|
-
npx --yes tsonic@latest init
|
|
18
|
+
npx --yes tsonic@latest init --surface nodejs
|
|
19
19
|
npx --yes tsonic@latest add npm @tsonic/nodejs
|
|
20
|
+
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import {
|
|
22
|
+
```ts
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
import { readFileSync } from "node:fs";
|
|
24
25
|
|
|
25
26
|
export function main(): void {
|
|
26
|
-
|
|
27
|
+
const fullPath = join("src", "App.ts");
|
|
28
|
+
console.log(fullPath);
|
|
29
|
+
console.log(readFileSync(fullPath, "utf-8"));
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
```
|
|
29
32
|
|
|
33
|
+
```bash
|
|
30
34
|
npm run dev
|
|
31
35
|
```
|
|
32
36
|
|
|
@@ -36,6 +40,12 @@ npm run dev
|
|
|
36
40
|
npx --yes tsonic@latest add npm @tsonic/nodejs
|
|
37
41
|
```
|
|
38
42
|
|
|
43
|
+
If the workspace is not already Node surface, set:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx --yes tsonic@latest init --surface nodejs
|
|
47
|
+
```
|
|
48
|
+
|
|
39
49
|
## Versioning
|
|
40
50
|
|
|
41
51
|
This repo is versioned by runtime major:
|
|
@@ -51,32 +61,29 @@ When publishing, run: `npm publish versions/10 --access public`
|
|
|
51
61
|
|
|
52
62
|
## Usage
|
|
53
63
|
|
|
54
|
-
### File System
|
|
64
|
+
### File System (`node:fs`)
|
|
55
65
|
|
|
56
66
|
```typescript
|
|
57
|
-
import {
|
|
58
|
-
|
|
59
|
-
// Read file
|
|
60
|
-
const content = fs.readFileSync("./package.json", "utf-8");
|
|
67
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
const content = readFileSync("./package.json", "utf-8");
|
|
70
|
+
writeFileSync("./output.txt", "Hello from Tsonic!");
|
|
64
71
|
```
|
|
65
72
|
|
|
66
|
-
### Path Operations
|
|
73
|
+
### Path Operations (`node:path`)
|
|
67
74
|
|
|
68
75
|
```typescript
|
|
69
|
-
import {
|
|
76
|
+
import { join, extname, dirname } from "node:path";
|
|
70
77
|
|
|
71
|
-
const fullPath =
|
|
72
|
-
const ext =
|
|
73
|
-
const dir =
|
|
78
|
+
const fullPath = join("config", "settings.json");
|
|
79
|
+
const ext = extname(fullPath); // ".json"
|
|
80
|
+
const dir = dirname(fullPath);
|
|
74
81
|
```
|
|
75
82
|
|
|
76
83
|
### Events
|
|
77
84
|
|
|
78
85
|
```typescript
|
|
79
|
-
import { EventEmitter
|
|
86
|
+
import { EventEmitter } from "@tsonic/nodejs/index.js";
|
|
80
87
|
|
|
81
88
|
class MyEmitter extends EventEmitter {}
|
|
82
89
|
const emitter = new MyEmitter();
|
|
@@ -86,16 +93,16 @@ emitter.on("data", (chunk) => console.log(chunk));
|
|
|
86
93
|
### Crypto
|
|
87
94
|
|
|
88
95
|
```ts
|
|
89
|
-
import {
|
|
96
|
+
import { randomUUID } from "node:crypto";
|
|
90
97
|
|
|
91
|
-
const
|
|
92
|
-
void
|
|
98
|
+
const id = randomUUID();
|
|
99
|
+
void id;
|
|
93
100
|
```
|
|
94
101
|
|
|
95
102
|
### Process
|
|
96
103
|
|
|
97
104
|
```ts
|
|
98
|
-
import
|
|
105
|
+
import * as process from "node:process";
|
|
99
106
|
|
|
100
107
|
const cwd = process.cwd();
|
|
101
108
|
void cwd;
|
|
@@ -109,12 +116,16 @@ import { http } from "@tsonic/nodejs/nodejs.Http.js";
|
|
|
109
116
|
|
|
110
117
|
## Imports (important)
|
|
111
118
|
|
|
112
|
-
|
|
119
|
+
For `--surface nodejs` projects, prefer Node-style imports:
|
|
120
|
+
|
|
121
|
+
- `node:fs`, `node:path`, `node:crypto`, `node:process`, ...
|
|
122
|
+
- bare aliases (`fs`, `path`, `crypto`, ...) are also supported
|
|
123
|
+
|
|
124
|
+
Direct ESM imports from `@tsonic/nodejs/index.js` are still supported.
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
- submodules like `@tsonic/nodejs/nodejs.Http.js` for separately emitted namespaces
|
|
126
|
+
`node:http` is currently not mapped by the surface alias set; use:
|
|
116
127
|
|
|
117
|
-
|
|
128
|
+
- `@tsonic/nodejs/nodejs.Http.js`
|
|
118
129
|
|
|
119
130
|
## Relationship to `@tsonic/js`
|
|
120
131
|
|
package/bindings.json
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bindings": {
|
|
3
|
+
"node:assert": {
|
|
4
|
+
"kind": "module",
|
|
5
|
+
"assembly": "nodejs",
|
|
6
|
+
"type": "nodejs.assert"
|
|
7
|
+
},
|
|
8
|
+
"assert": {
|
|
9
|
+
"kind": "module",
|
|
10
|
+
"assembly": "nodejs",
|
|
11
|
+
"type": "nodejs.assert"
|
|
12
|
+
},
|
|
13
|
+
"node:buffer": {
|
|
14
|
+
"kind": "module",
|
|
15
|
+
"assembly": "nodejs",
|
|
16
|
+
"type": "nodejs.buffer"
|
|
17
|
+
},
|
|
18
|
+
"buffer": {
|
|
19
|
+
"kind": "module",
|
|
20
|
+
"assembly": "nodejs",
|
|
21
|
+
"type": "nodejs.buffer"
|
|
22
|
+
},
|
|
23
|
+
"node:child_process": {
|
|
24
|
+
"kind": "module",
|
|
25
|
+
"assembly": "nodejs",
|
|
26
|
+
"type": "nodejs.child_process"
|
|
27
|
+
},
|
|
28
|
+
"child_process": {
|
|
29
|
+
"kind": "module",
|
|
30
|
+
"assembly": "nodejs",
|
|
31
|
+
"type": "nodejs.child_process"
|
|
32
|
+
},
|
|
33
|
+
"node:crypto": {
|
|
34
|
+
"kind": "module",
|
|
35
|
+
"assembly": "nodejs",
|
|
36
|
+
"type": "nodejs.crypto"
|
|
37
|
+
},
|
|
38
|
+
"crypto": {
|
|
39
|
+
"kind": "module",
|
|
40
|
+
"assembly": "nodejs",
|
|
41
|
+
"type": "nodejs.crypto"
|
|
42
|
+
},
|
|
43
|
+
"node:dgram": {
|
|
44
|
+
"kind": "module",
|
|
45
|
+
"assembly": "nodejs",
|
|
46
|
+
"type": "nodejs.dgram"
|
|
47
|
+
},
|
|
48
|
+
"dgram": {
|
|
49
|
+
"kind": "module",
|
|
50
|
+
"assembly": "nodejs",
|
|
51
|
+
"type": "nodejs.dgram"
|
|
52
|
+
},
|
|
53
|
+
"node:dns": {
|
|
54
|
+
"kind": "module",
|
|
55
|
+
"assembly": "nodejs",
|
|
56
|
+
"type": "nodejs.dns"
|
|
57
|
+
},
|
|
58
|
+
"dns": {
|
|
59
|
+
"kind": "module",
|
|
60
|
+
"assembly": "nodejs",
|
|
61
|
+
"type": "nodejs.dns"
|
|
62
|
+
},
|
|
63
|
+
"node:events": {
|
|
64
|
+
"kind": "module",
|
|
65
|
+
"assembly": "nodejs",
|
|
66
|
+
"type": "nodejs.events"
|
|
67
|
+
},
|
|
68
|
+
"events": {
|
|
69
|
+
"kind": "module",
|
|
70
|
+
"assembly": "nodejs",
|
|
71
|
+
"type": "nodejs.events"
|
|
72
|
+
},
|
|
73
|
+
"node:fs": {
|
|
74
|
+
"kind": "module",
|
|
75
|
+
"assembly": "nodejs",
|
|
76
|
+
"type": "nodejs.fs"
|
|
77
|
+
},
|
|
78
|
+
"fs": {
|
|
79
|
+
"kind": "module",
|
|
80
|
+
"assembly": "nodejs",
|
|
81
|
+
"type": "nodejs.fs"
|
|
82
|
+
},
|
|
83
|
+
"node:net": {
|
|
84
|
+
"kind": "module",
|
|
85
|
+
"assembly": "nodejs",
|
|
86
|
+
"type": "nodejs.net"
|
|
87
|
+
},
|
|
88
|
+
"net": {
|
|
89
|
+
"kind": "module",
|
|
90
|
+
"assembly": "nodejs",
|
|
91
|
+
"type": "nodejs.net"
|
|
92
|
+
},
|
|
93
|
+
"node:os": {
|
|
94
|
+
"kind": "module",
|
|
95
|
+
"assembly": "nodejs",
|
|
96
|
+
"type": "nodejs.os"
|
|
97
|
+
},
|
|
98
|
+
"os": {
|
|
99
|
+
"kind": "module",
|
|
100
|
+
"assembly": "nodejs",
|
|
101
|
+
"type": "nodejs.os"
|
|
102
|
+
},
|
|
103
|
+
"node:path": {
|
|
104
|
+
"kind": "module",
|
|
105
|
+
"assembly": "nodejs",
|
|
106
|
+
"type": "nodejs.path"
|
|
107
|
+
},
|
|
108
|
+
"path": {
|
|
109
|
+
"kind": "module",
|
|
110
|
+
"assembly": "nodejs",
|
|
111
|
+
"type": "nodejs.path"
|
|
112
|
+
},
|
|
113
|
+
"node:process": {
|
|
114
|
+
"kind": "module",
|
|
115
|
+
"assembly": "nodejs",
|
|
116
|
+
"type": "nodejs.process"
|
|
117
|
+
},
|
|
118
|
+
"process": {
|
|
119
|
+
"kind": "module",
|
|
120
|
+
"assembly": "nodejs",
|
|
121
|
+
"type": "nodejs.process"
|
|
122
|
+
},
|
|
123
|
+
"node:querystring": {
|
|
124
|
+
"kind": "module",
|
|
125
|
+
"assembly": "nodejs",
|
|
126
|
+
"type": "nodejs.querystring"
|
|
127
|
+
},
|
|
128
|
+
"querystring": {
|
|
129
|
+
"kind": "module",
|
|
130
|
+
"assembly": "nodejs",
|
|
131
|
+
"type": "nodejs.querystring"
|
|
132
|
+
},
|
|
133
|
+
"node:readline": {
|
|
134
|
+
"kind": "module",
|
|
135
|
+
"assembly": "nodejs",
|
|
136
|
+
"type": "nodejs.readline"
|
|
137
|
+
},
|
|
138
|
+
"readline": {
|
|
139
|
+
"kind": "module",
|
|
140
|
+
"assembly": "nodejs",
|
|
141
|
+
"type": "nodejs.readline"
|
|
142
|
+
},
|
|
143
|
+
"node:stream": {
|
|
144
|
+
"kind": "module",
|
|
145
|
+
"assembly": "nodejs",
|
|
146
|
+
"type": "nodejs.stream"
|
|
147
|
+
},
|
|
148
|
+
"stream": {
|
|
149
|
+
"kind": "module",
|
|
150
|
+
"assembly": "nodejs",
|
|
151
|
+
"type": "nodejs.stream"
|
|
152
|
+
},
|
|
153
|
+
"node:timers": {
|
|
154
|
+
"kind": "module",
|
|
155
|
+
"assembly": "nodejs",
|
|
156
|
+
"type": "nodejs.timers"
|
|
157
|
+
},
|
|
158
|
+
"timers": {
|
|
159
|
+
"kind": "module",
|
|
160
|
+
"assembly": "nodejs",
|
|
161
|
+
"type": "nodejs.timers"
|
|
162
|
+
},
|
|
163
|
+
"node:tls": {
|
|
164
|
+
"kind": "module",
|
|
165
|
+
"assembly": "nodejs",
|
|
166
|
+
"type": "nodejs.tls"
|
|
167
|
+
},
|
|
168
|
+
"tls": {
|
|
169
|
+
"kind": "module",
|
|
170
|
+
"assembly": "nodejs",
|
|
171
|
+
"type": "nodejs.tls"
|
|
172
|
+
},
|
|
173
|
+
"node:url": {
|
|
174
|
+
"kind": "module",
|
|
175
|
+
"assembly": "nodejs",
|
|
176
|
+
"type": "nodejs.url"
|
|
177
|
+
},
|
|
178
|
+
"url": {
|
|
179
|
+
"kind": "module",
|
|
180
|
+
"assembly": "nodejs",
|
|
181
|
+
"type": "nodejs.url"
|
|
182
|
+
},
|
|
183
|
+
"node:util": {
|
|
184
|
+
"kind": "module",
|
|
185
|
+
"assembly": "nodejs",
|
|
186
|
+
"type": "nodejs.util"
|
|
187
|
+
},
|
|
188
|
+
"util": {
|
|
189
|
+
"kind": "module",
|
|
190
|
+
"assembly": "nodejs",
|
|
191
|
+
"type": "nodejs.util"
|
|
192
|
+
},
|
|
193
|
+
"node:zlib": {
|
|
194
|
+
"kind": "module",
|
|
195
|
+
"assembly": "nodejs",
|
|
196
|
+
"type": "nodejs.zlib"
|
|
197
|
+
},
|
|
198
|
+
"zlib": {
|
|
199
|
+
"kind": "module",
|
|
200
|
+
"assembly": "nodejs",
|
|
201
|
+
"type": "nodejs.zlib"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
declare module "node:assert" {
|
|
2
|
+
export { assert } from "@tsonic/nodejs/index.js";
|
|
3
|
+
}
|
|
4
|
+
declare module "assert" {
|
|
5
|
+
export { assert } from "@tsonic/nodejs/index.js";
|
|
6
|
+
}
|
|
7
|
+
declare module "node:buffer" {
|
|
8
|
+
export { buffer } from "@tsonic/nodejs/index.js";
|
|
9
|
+
}
|
|
10
|
+
declare module "buffer" {
|
|
11
|
+
export { buffer } from "@tsonic/nodejs/index.js";
|
|
12
|
+
}
|
|
13
|
+
declare module "node:child_process" {
|
|
14
|
+
export { child_process } from "@tsonic/nodejs/index.js";
|
|
15
|
+
}
|
|
16
|
+
declare module "child_process" {
|
|
17
|
+
export { child_process } from "@tsonic/nodejs/index.js";
|
|
18
|
+
}
|
|
19
|
+
declare module "node:fs" {
|
|
20
|
+
export { fs } from "@tsonic/nodejs/index.js";
|
|
21
|
+
export const existsSync: typeof import("@tsonic/nodejs/index.js").fs.existsSync;
|
|
22
|
+
export const readFileSync: typeof import("@tsonic/nodejs/index.js").fs.readFileSync;
|
|
23
|
+
export const mkdirSync: typeof import("@tsonic/nodejs/index.js").fs.mkdirSync;
|
|
24
|
+
}
|
|
25
|
+
declare module "fs" {
|
|
26
|
+
export { fs } from "@tsonic/nodejs/index.js";
|
|
27
|
+
}
|
|
28
|
+
declare module "node:path" {
|
|
29
|
+
export { path } from "@tsonic/nodejs/index.js";
|
|
30
|
+
export const join: typeof import("@tsonic/nodejs/index.js").path.join;
|
|
31
|
+
export const extname: typeof import("@tsonic/nodejs/index.js").path.extname;
|
|
32
|
+
export const basename: typeof import("@tsonic/nodejs/index.js").path.basename;
|
|
33
|
+
export const dirname: typeof import("@tsonic/nodejs/index.js").path.dirname;
|
|
34
|
+
export const parse: typeof import("@tsonic/nodejs/index.js").path.parse;
|
|
35
|
+
export const resolve: typeof import("@tsonic/nodejs/index.js").path.resolve;
|
|
36
|
+
}
|
|
37
|
+
declare module "path" {
|
|
38
|
+
export { path } from "@tsonic/nodejs/index.js";
|
|
39
|
+
}
|
|
40
|
+
declare module "node:crypto" {
|
|
41
|
+
export { crypto } from "@tsonic/nodejs/index.js";
|
|
42
|
+
export const randomUUID: typeof import("@tsonic/nodejs/index.js").crypto.randomUUID;
|
|
43
|
+
}
|
|
44
|
+
declare module "crypto" {
|
|
45
|
+
export { crypto } from "@tsonic/nodejs/index.js";
|
|
46
|
+
}
|
|
47
|
+
declare module "node:dgram" {
|
|
48
|
+
export { dgram } from "@tsonic/nodejs/index.js";
|
|
49
|
+
}
|
|
50
|
+
declare module "dgram" {
|
|
51
|
+
export { dgram } from "@tsonic/nodejs/index.js";
|
|
52
|
+
}
|
|
53
|
+
declare module "node:dns" {
|
|
54
|
+
export { dns } from "@tsonic/nodejs/index.js";
|
|
55
|
+
}
|
|
56
|
+
declare module "dns" {
|
|
57
|
+
export { dns } from "@tsonic/nodejs/index.js";
|
|
58
|
+
}
|
|
59
|
+
declare module "node:events" {
|
|
60
|
+
export { events } from "@tsonic/nodejs/index.js";
|
|
61
|
+
}
|
|
62
|
+
declare module "events" {
|
|
63
|
+
export { events } from "@tsonic/nodejs/index.js";
|
|
64
|
+
}
|
|
65
|
+
declare module "node:net" {
|
|
66
|
+
export { net } from "@tsonic/nodejs/index.js";
|
|
67
|
+
}
|
|
68
|
+
declare module "net" {
|
|
69
|
+
export { net } from "@tsonic/nodejs/index.js";
|
|
70
|
+
}
|
|
71
|
+
declare module "node:os" {
|
|
72
|
+
export { os } from "@tsonic/nodejs/index.js";
|
|
73
|
+
export const homedir: typeof import("@tsonic/nodejs/index.js").os.homedir;
|
|
74
|
+
export const tmpdir: typeof import("@tsonic/nodejs/index.js").os.tmpdir;
|
|
75
|
+
}
|
|
76
|
+
declare module "os" {
|
|
77
|
+
export { os } from "@tsonic/nodejs/index.js";
|
|
78
|
+
}
|
|
79
|
+
declare module "node:process" {
|
|
80
|
+
export { process } from "@tsonic/nodejs/index.js";
|
|
81
|
+
export const cwd: typeof import("@tsonic/nodejs/index.js").process.cwd;
|
|
82
|
+
}
|
|
83
|
+
declare module "process" {
|
|
84
|
+
export { process } from "@tsonic/nodejs/index.js";
|
|
85
|
+
}
|
|
86
|
+
declare module "node:querystring" {
|
|
87
|
+
export { querystring } from "@tsonic/nodejs/index.js";
|
|
88
|
+
}
|
|
89
|
+
declare module "querystring" {
|
|
90
|
+
export { querystring } from "@tsonic/nodejs/index.js";
|
|
91
|
+
}
|
|
92
|
+
declare module "node:readline" {
|
|
93
|
+
export { readline } from "@tsonic/nodejs/index.js";
|
|
94
|
+
}
|
|
95
|
+
declare module "readline" {
|
|
96
|
+
export { readline } from "@tsonic/nodejs/index.js";
|
|
97
|
+
}
|
|
98
|
+
declare module "node:stream" {
|
|
99
|
+
export { stream } from "@tsonic/nodejs/index.js";
|
|
100
|
+
}
|
|
101
|
+
declare module "stream" {
|
|
102
|
+
export { stream } from "@tsonic/nodejs/index.js";
|
|
103
|
+
}
|
|
104
|
+
declare module "node:timers" {
|
|
105
|
+
export { timers } from "@tsonic/nodejs/index.js";
|
|
106
|
+
}
|
|
107
|
+
declare module "timers" {
|
|
108
|
+
export { timers } from "@tsonic/nodejs/index.js";
|
|
109
|
+
}
|
|
110
|
+
declare module "node:tls" {
|
|
111
|
+
export { tls } from "@tsonic/nodejs/index.js";
|
|
112
|
+
}
|
|
113
|
+
declare module "tls" {
|
|
114
|
+
export { tls } from "@tsonic/nodejs/index.js";
|
|
115
|
+
}
|
|
116
|
+
declare module "node:url" {
|
|
117
|
+
export { url } from "@tsonic/nodejs/index.js";
|
|
118
|
+
}
|
|
119
|
+
declare module "url" {
|
|
120
|
+
export { url } from "@tsonic/nodejs/index.js";
|
|
121
|
+
}
|
|
122
|
+
declare module "node:util" {
|
|
123
|
+
export { util } from "@tsonic/nodejs/index.js";
|
|
124
|
+
}
|
|
125
|
+
declare module "util" {
|
|
126
|
+
export { util } from "@tsonic/nodejs/index.js";
|
|
127
|
+
}
|
|
128
|
+
declare module "node:zlib" {
|
|
129
|
+
export { zlib } from "@tsonic/nodejs/index.js";
|
|
130
|
+
}
|
|
131
|
+
declare module "zlib" {
|
|
132
|
+
export { zlib } from "@tsonic/nodejs/index.js";
|
|
133
|
+
}
|
package/package.json
CHANGED
package/tsonic.bindings.json
CHANGED