@bytecodealliance/preview2-shim 0.0.7 → 0.0.9
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 +4 -3
- package/lib/browser/cli-base.js +57 -0
- package/lib/browser/clocks.js +50 -0
- package/lib/browser/filesystem.js +134 -141
- package/lib/browser/http.js +120 -0
- package/lib/browser/index.js +14 -20
- package/lib/browser/io.js +62 -20
- package/lib/browser/logging.js +8 -4
- package/lib/browser/poll.js +10 -6
- package/lib/browser/random.js +32 -25
- package/lib/browser/sockets.js +203 -0
- package/lib/nodejs/cli-base.js +108 -0
- package/lib/nodejs/clocks.js +50 -0
- package/lib/nodejs/filesystem.js +313 -150
- package/lib/nodejs/http.js +120 -0
- package/lib/nodejs/index.js +14 -20
- package/lib/nodejs/io.js +138 -19
- package/lib/nodejs/logging.js +8 -4
- package/lib/nodejs/poll.js +10 -6
- package/lib/nodejs/random.js +18 -13
- package/lib/nodejs/sockets.js +203 -0
- package/package.json +1 -1
- package/types/exports/{HTTP.d.ts → http-incoming-handler.d.ts} +1 -1
- package/types/imports/cli-base-environment.d.ts +17 -0
- package/types/imports/{exit.d.ts → cli-base-exit.d.ts} +4 -1
- package/types/imports/{preopens.d.ts → cli-base-preopens.d.ts} +6 -9
- package/types/imports/cli-base-stderr.d.ts +5 -0
- package/types/imports/cli-base-stdin.d.ts +5 -0
- package/types/imports/cli-base-stdout.d.ts +5 -0
- package/types/imports/clocks-monotonic-clock.d.ts +24 -0
- package/types/imports/clocks-timezone.d.ts +71 -0
- package/types/imports/clocks-wall-clock.d.ts +31 -0
- package/types/imports/filesystem-filesystem.d.ts +857 -0
- package/types/imports/{default-outgoing-HTTP.d.ts → http-outgoing-handler.d.ts} +1 -1
- package/types/imports/{types.d.ts → http-types.d.ts} +28 -28
- package/types/imports/io-streams.d.ts +180 -0
- package/types/imports/logging-handler.d.ts +40 -0
- package/types/imports/poll-poll.d.ts +41 -0
- package/types/imports/random-insecure-seed.d.ts +22 -0
- package/types/imports/random-insecure.d.ts +20 -0
- package/types/imports/random-random.d.ts +22 -0
- package/types/imports/{instance-network.d.ts → sockets-instance-network.d.ts} +4 -1
- package/types/imports/sockets-ip-name-lookup.d.ts +76 -0
- package/types/imports/sockets-network.d.ts +212 -0
- package/types/imports/sockets-tcp-create-socket.d.ts +33 -0
- package/types/imports/sockets-tcp.d.ts +285 -0
- package/types/imports/sockets-udp-create-socket.d.ts +33 -0
- package/types/imports/sockets-udp.d.ts +219 -0
- package/types/wasi-command.d.ts +23 -0
- package/types/wasi-proxy.d.ts +11 -44
- package/types/wasi-reactor.d.ts +23 -70
- package/lib/browser/default-outgoing-HTTP.js +0 -3
- package/lib/browser/environment.js +0 -3
- package/lib/browser/exit.js +0 -21
- package/lib/browser/monotonic-clock.js +0 -35
- package/lib/browser/preopens.js +0 -11
- package/lib/browser/stderr.js +0 -4
- package/lib/browser/streams.js +0 -60
- package/lib/browser/timezone.js +0 -12
- package/lib/browser/types.js +0 -99
- package/lib/browser/wall-clock.js +0 -12
- package/lib/nodejs/default-outgoing-HTTP.js +0 -3
- package/lib/nodejs/environment.js +0 -7
- package/lib/nodejs/exit.js +0 -4
- package/lib/nodejs/monotonic-clock.js +0 -14
- package/lib/nodejs/preopens.js +0 -11
- package/lib/nodejs/stderr.js +0 -4
- package/lib/nodejs/streams.js +0 -63
- package/lib/nodejs/timezone.js +0 -12
- package/lib/nodejs/types.js +0 -99
- package/lib/nodejs/wall-clock.js +0 -12
- package/types/imports/console.d.ts +0 -17
- package/types/imports/environment.d.ts +0 -4
- package/types/imports/filesystem.d.ts +0 -212
- package/types/imports/ip-name-lookup.d.ts +0 -19
- package/types/imports/monotonic-clock.d.ts +0 -8
- package/types/imports/network.d.ts +0 -50
- package/types/imports/poll.d.ts +0 -5
- package/types/imports/random.d.ts +0 -5
- package/types/imports/streams.d.ts +0 -23
- package/types/imports/tcp-create-socket.d.ts +0 -9
- package/types/imports/tcp.d.ts +0 -52
- package/types/imports/timezone.d.ts +0 -13
- package/types/imports/udp-create-socket.d.ts +0 -9
- package/types/imports/udp.d.ts +0 -36
- package/types/imports/wall-clock.d.ts +0 -8
- package/types/index.d.ts +0 -8
package/lib/nodejs/filesystem.js
CHANGED
|
@@ -1,150 +1,313 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
import { openSync, constants, statSync, lstatSync, fstatSync, closeSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { _descriptors, _addOpenedDescriptor, _removeOpenedDescriptor, _getDescriptorType, _setSubdescriptorType, _setDescriptorType, _getFullPath } from './cli-base.js';
|
|
3
|
+
import { _createFileStream } from './io.js';
|
|
4
|
+
|
|
5
|
+
let _dirStreams = [];
|
|
6
|
+
|
|
7
|
+
const nsMagnitude = 1_000_000_000_000n;
|
|
8
|
+
function nsToDateTime (ns) {
|
|
9
|
+
const seconds = ns / nsMagnitude;
|
|
10
|
+
const nanoseconds = Number(ns % seconds);
|
|
11
|
+
return { seconds, nanoseconds };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _convertFsError (e) {
|
|
15
|
+
switch (e.code) {
|
|
16
|
+
case 'EACCES': throw 'access';
|
|
17
|
+
case 'EAGAIN':
|
|
18
|
+
case 'EWOULDBLOCK': throw 'would-block';
|
|
19
|
+
case 'EALREADY': throw 'already';
|
|
20
|
+
case 'EBADF': throw 'bad-descriptor';
|
|
21
|
+
case 'EBUSY': throw 'busy';
|
|
22
|
+
case 'EDEADLK': throw 'deadlock';
|
|
23
|
+
case 'EDQUOT': throw 'quota';
|
|
24
|
+
case 'EEXIST': throw 'exist';
|
|
25
|
+
case 'EFBIG': throw 'file-too-large';
|
|
26
|
+
case 'EILSEQ': throw 'illegal-byte-sequence';
|
|
27
|
+
case 'EINPROGRESS': throw 'in-progress';
|
|
28
|
+
case 'EINTR': throw 'interrupted';
|
|
29
|
+
case 'EINVAL': throw 'invalid';
|
|
30
|
+
case 'EIO': throw 'io';
|
|
31
|
+
case 'EISDIR': throw 'is-directory';
|
|
32
|
+
case 'ELOOP': throw 'loop';
|
|
33
|
+
case 'EMLINK': throw 'too-many-links';
|
|
34
|
+
case 'EMSGSIZE': throw 'message-size';
|
|
35
|
+
case 'ENAMETOOLONG': throw 'name-too-long'
|
|
36
|
+
case 'ENODEV': throw 'no-device';
|
|
37
|
+
case 'ENOENT': throw 'no-entry';
|
|
38
|
+
case 'ENOLCK': throw 'no-lock';
|
|
39
|
+
case 'ENOMEM': throw 'insufficient-memory';
|
|
40
|
+
case 'ENOSPC': throw 'insufficient-space';
|
|
41
|
+
case 'ENOTDIR': throw 'not-directory';
|
|
42
|
+
case 'ENOTEMPTY': throw 'not-empty';
|
|
43
|
+
case 'ENOTRECOVERABLE': throw 'not-recoverable';
|
|
44
|
+
case 'ENOTSUP': throw 'unsupported';
|
|
45
|
+
case 'ENOTTY': throw 'no-tty';
|
|
46
|
+
case 'ENXIO': throw 'no-such-device';
|
|
47
|
+
case 'EOVERFLOW': throw 'overflow';
|
|
48
|
+
case 'EPERM': throw 'not-permitted';
|
|
49
|
+
case 'EPIPE': throw 'pipe';
|
|
50
|
+
case 'EROFS': throw 'read-only';
|
|
51
|
+
case 'ESPIPE': throw 'invalid-seek';
|
|
52
|
+
case 'ETXTBSY': throw 'text-file-busy';
|
|
53
|
+
case 'EXDEV': throw 'cross-device';
|
|
54
|
+
default: throw e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _lookupType (obj) {
|
|
59
|
+
if (obj.isFile())
|
|
60
|
+
return 'regular-file';
|
|
61
|
+
else if (obj.isSocket())
|
|
62
|
+
return 'socket';
|
|
63
|
+
else if (obj.isSymbolicLink())
|
|
64
|
+
return 'symbolic-link';
|
|
65
|
+
else if (obj.isFIFO())
|
|
66
|
+
return 'fifo';
|
|
67
|
+
else if (obj.isDirectory())
|
|
68
|
+
return 'directory';
|
|
69
|
+
else if (obj.isCharacterDevice())
|
|
70
|
+
return 'character-device';
|
|
71
|
+
else if (obj.isBlockDevice())
|
|
72
|
+
return 'block-device';
|
|
73
|
+
return 'unknown';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const filesystem = {
|
|
77
|
+
readViaStream(fd, offset) {
|
|
78
|
+
return _createFileStream(fd, offset);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
writeViaStream(fd, offset) {
|
|
82
|
+
console.log(`[filesystem] WRITE STREAM ${fd} ${offset}`);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
appendViaStream(fd) {
|
|
86
|
+
console.log(`[filesystem] APPEND STREAM ${fd}`);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
advise(fd, offset, length, advice) {
|
|
90
|
+
console.log(`[filesystem] ADVISE`, fd, offset, length, advice);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
syncData(fd) {
|
|
94
|
+
console.log(`[filesystem] SYNC DATA ${fd}`);
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
getFlags(fd) {
|
|
98
|
+
console.log(`[filesystem] FLAGS FOR ${fd}`);
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
getType(fd) {
|
|
102
|
+
let type = _getDescriptorType(fd);
|
|
103
|
+
if (type === null) {
|
|
104
|
+
filesystem.stat(fd);
|
|
105
|
+
type = _getDescriptorType(fd);
|
|
106
|
+
}
|
|
107
|
+
return type;
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
setFlags(fd, flags) {
|
|
111
|
+
console.log(`[filesystem] SET FLAGS ${fd} ${JSON.stringify(flags)}`);
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
setSize(fd, size) {
|
|
115
|
+
console.log(`[filesystem] SET SIZE`, fd, size);
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
setTimes(fd, dataAccessTimestamp, dataModificationTimestamp) {
|
|
119
|
+
console.log(`[filesystem] SET TIMES`, fd, dataAccessTimestamp, dataModificationTimestamp);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
read(fd, length, offset) {
|
|
123
|
+
console.log(`[filesystem] READ`, fd, length, offset);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
write(fd, buffer, offset) {
|
|
127
|
+
console.log(`[filesystem] WRITE`, fd, buffer, offset);
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
readDirectory(fd) {
|
|
131
|
+
const fullPath = _getFullPath(fd);
|
|
132
|
+
let dirs;
|
|
133
|
+
try {
|
|
134
|
+
dirs = readdirSync(fullPath, { withFileTypes: true });
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
_convertFsError(e);
|
|
138
|
+
}
|
|
139
|
+
_dirStreams.push({ fd, dirs, cursor: 0 });
|
|
140
|
+
return _dirStreams.length - 1;
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
sync(fd) {
|
|
144
|
+
console.log(`[filesystem] SYNC`, fd);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
createDirectoryAt(fd, path) {
|
|
148
|
+
console.log(`[filesystem] CREATE DIRECTORY`, fd, path);
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
stat(fd) {
|
|
152
|
+
let stats;
|
|
153
|
+
try {
|
|
154
|
+
stats = fstatSync(fd, { bigint: true });
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
_convertFsError(e);
|
|
158
|
+
}
|
|
159
|
+
const type = _lookupType(stats);
|
|
160
|
+
_setDescriptorType(fd, type);
|
|
161
|
+
return {
|
|
162
|
+
device: stats.dev,
|
|
163
|
+
inode: stats.ino,
|
|
164
|
+
type,
|
|
165
|
+
linkCount: stats.nlink,
|
|
166
|
+
size: stats.size,
|
|
167
|
+
dataAccessTimestamp: nsToDateTime(stats.atimeNs),
|
|
168
|
+
dataModificationTimestamp: nsToDateTime(stats.mtimeNs),
|
|
169
|
+
statusChangeTimestamp: nsToDateTime(stats.ctimeNs),
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
statAt(fd, { symlinkFollow }, path) {
|
|
174
|
+
const fullPath = _descriptors[fd].path + path;
|
|
175
|
+
let stats;
|
|
176
|
+
try {
|
|
177
|
+
stats = (symlinkFollow ? statSync : lstatSync)(fullPath, { bigint: true });
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
_convertFsError(e);
|
|
181
|
+
}
|
|
182
|
+
const type = _lookupType(stats);
|
|
183
|
+
_setSubdescriptorType(fd, path, type);
|
|
184
|
+
return {
|
|
185
|
+
device: stats.dev,
|
|
186
|
+
inode: stats.ino,
|
|
187
|
+
type,
|
|
188
|
+
linkCount: stats.nlink,
|
|
189
|
+
size: stats.size,
|
|
190
|
+
dataAccessTimestamp: nsToDateTime(stats.atimeNs),
|
|
191
|
+
dataModificationTimestamp: nsToDateTime(stats.mtimeNs),
|
|
192
|
+
statusChangeTimestamp: nsToDateTime(stats.ctimeNs),
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
setTimesAt(fd) {
|
|
197
|
+
console.log(`[filesystem] SET TIMES AT`, fd);
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
linkAt(fd) {
|
|
201
|
+
console.log(`[filesystem] LINK AT`, fd);
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
openAt(fd, pathFlags, path, openFlags, descriptorFlags, modes) {
|
|
205
|
+
// TODO
|
|
206
|
+
// if (pathFlags.symlinkFollow) {
|
|
207
|
+
// // resolve symlink
|
|
208
|
+
// }
|
|
209
|
+
const fullPath = _descriptors[fd].path + path;
|
|
210
|
+
let fsOpenFlags = 0x0;
|
|
211
|
+
if (openFlags.create)
|
|
212
|
+
fsOpenFlags |= constants.O_CREAT;
|
|
213
|
+
if (openFlags.directory)
|
|
214
|
+
fsOpenFlags |= constants.O_DIRECTORY;
|
|
215
|
+
if (openFlags.exclusive)
|
|
216
|
+
fsOpenFlags |= constants.O_EXCL;
|
|
217
|
+
if (openFlags.truncate)
|
|
218
|
+
fsOpenFlags |= constants.O_TRUNC;
|
|
219
|
+
if (descriptorFlags.read && descriptorFlags.write)
|
|
220
|
+
fsOpenFlags |= constants.O_RDWR;
|
|
221
|
+
else if (descriptorFlags.write)
|
|
222
|
+
fsOpenFlags |= constants.O_WRONLY;
|
|
223
|
+
// if (descriptorFlags.fileIntegritySync)
|
|
224
|
+
// if (descriptorFlags.dataIntegritySync)
|
|
225
|
+
// if (descriptorFlags.requestedWriteSync)
|
|
226
|
+
// if (descriptorFlags.mutateDirectory)
|
|
227
|
+
let fsMode = 0x0;
|
|
228
|
+
if (modes.readable)
|
|
229
|
+
fsMode |= 0o444;
|
|
230
|
+
if (modes.writeable)
|
|
231
|
+
fsMode |= 0o222;
|
|
232
|
+
if (modes.executable)
|
|
233
|
+
fsMode |= 0o111;
|
|
234
|
+
let localFd;
|
|
235
|
+
try {
|
|
236
|
+
localFd = openSync(fullPath, fsOpenFlags, fsMode);
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
_convertFsError(e);
|
|
240
|
+
}
|
|
241
|
+
_addOpenedDescriptor(localFd, path, fd);
|
|
242
|
+
return localFd;
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
readlinkAt(fd) {
|
|
246
|
+
console.log(`[filesystem] READLINK AT`, fd);
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
removeDirectoryAt(fd) {
|
|
250
|
+
console.log(`[filesystem] REMOVE DIR AT`, fd);
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
renameAt(fd) {
|
|
254
|
+
console.log(`[filesystem] RENAME AT`, fd);
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
symlinkAt(fd) {
|
|
258
|
+
console.log(`[filesystem] SYMLINK AT`, fd);
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
unlinkFileAt(fd) {
|
|
262
|
+
console.log(`[filesystem] UNLINK FILE AT`, fd);
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
changeFilePermissionsAt(fd) {
|
|
266
|
+
console.log(`[filesystem] CHANGE FILE PERMISSIONS AT`, fd);
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
changeDirectoryPermissionsAt(fd) {
|
|
270
|
+
console.log(`[filesystem] CHANGE DIR PERMISSIONS AT`, fd);
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
lockShared(fd) {
|
|
274
|
+
console.log(`[filesystem] LOCK SHARED`, fd);
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
lockExclusive(fd) {
|
|
278
|
+
console.log(`[filesystem] LOCK EXCLUSIVE`, fd);
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
tryLockShared(fd) {
|
|
282
|
+
console.log(`[filesystem] TRY LOCK SHARED`, fd);
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
tryLockExclusive(fd) {
|
|
286
|
+
console.log(`[filesystem] TRY LOCK EXCLUSIVE`, fd);
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
unlock(fd) {
|
|
290
|
+
console.log(`[filesystem] UNLOCK`, fd);
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
dropDescriptor(fd) {
|
|
294
|
+
_removeOpenedDescriptor(fd);
|
|
295
|
+
closeSync(fd);
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
readDirectoryEntry(stream) {
|
|
299
|
+
const streamValue = _dirStreams[stream];
|
|
300
|
+
if (streamValue.cursor === streamValue.dirs.length)
|
|
301
|
+
return null;
|
|
302
|
+
const dir = streamValue.dirs[streamValue.cursor++];
|
|
303
|
+
const type = _lookupType(dir);
|
|
304
|
+
_setSubdescriptorType(streamValue.fd, '/' + dir.name, type);
|
|
305
|
+
return { inode: null, type, name: dir.name };
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
dropDirectoryEntryStream(stream) {
|
|
309
|
+
_dirStreams.splice(stream, 1);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export { filesystem as filesystemFilesystem }
|
package/lib/nodejs/http.js
CHANGED
|
@@ -17,3 +17,123 @@ export function send(req) {
|
|
|
17
17
|
}
|
|
18
18
|
throw new UnexpectedError(response);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
export const httpIncomingHandler = {
|
|
22
|
+
handle () {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const httpOutgoingHandler = {
|
|
28
|
+
handle () {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const httpTypes = {
|
|
34
|
+
dropFields(_fields) {
|
|
35
|
+
console.log("[types] Drop fields");
|
|
36
|
+
},
|
|
37
|
+
newFields(_entries) {
|
|
38
|
+
console.log("[types] New fields");
|
|
39
|
+
},
|
|
40
|
+
fieldsGet(_fields, _name) {
|
|
41
|
+
console.log("[types] Fields get");
|
|
42
|
+
},
|
|
43
|
+
fieldsSet(_fields, _name, _value) {
|
|
44
|
+
console.log("[types] Fields set");
|
|
45
|
+
},
|
|
46
|
+
fieldsDelete(_fields, _name) {
|
|
47
|
+
console.log("[types] Fields delete");
|
|
48
|
+
},
|
|
49
|
+
fieldsAppend(_fields, _name, _value) {
|
|
50
|
+
console.log("[types] Fields append");
|
|
51
|
+
},
|
|
52
|
+
fieldsEntries(_fields) {
|
|
53
|
+
console.log("[types] Fields entries");
|
|
54
|
+
},
|
|
55
|
+
fieldsClone(_fields) {
|
|
56
|
+
console.log("[types] Fields clone");
|
|
57
|
+
},
|
|
58
|
+
finishIncomingStream(s) {
|
|
59
|
+
console.log(`[types] Finish incoming stream ${s}`);
|
|
60
|
+
},
|
|
61
|
+
finishOutgoingStream(s, _trailers) {
|
|
62
|
+
console.log(`[types] Finish outgoing stream ${s}`);
|
|
63
|
+
},
|
|
64
|
+
dropIncomingRequest(_req) {
|
|
65
|
+
console.log("[types] Drop incoming request");
|
|
66
|
+
},
|
|
67
|
+
dropOutgoingRequest(_req) {
|
|
68
|
+
console.log("[types] Drop outgoing request");
|
|
69
|
+
},
|
|
70
|
+
incomingRequestMethod(_req) {
|
|
71
|
+
console.log("[types] Incoming request method");
|
|
72
|
+
},
|
|
73
|
+
incomingRequestPath(_req) {
|
|
74
|
+
console.log("[types] Incoming request path");
|
|
75
|
+
},
|
|
76
|
+
incomingRequestQuery(_req) {
|
|
77
|
+
console.log("[types] Incoming request query");
|
|
78
|
+
},
|
|
79
|
+
incomingRequestScheme(_req) {
|
|
80
|
+
console.log("[types] Incoming request scheme");
|
|
81
|
+
},
|
|
82
|
+
incomingRequestAuthority(_req) {
|
|
83
|
+
console.log("[types] Incoming request authority");
|
|
84
|
+
},
|
|
85
|
+
incomingRequestHeaders(_req) {
|
|
86
|
+
console.log("[types] Incoming request headers");
|
|
87
|
+
},
|
|
88
|
+
incomingRequestConsume(_req) {
|
|
89
|
+
console.log("[types] Incoming request consume");
|
|
90
|
+
},
|
|
91
|
+
newOutgoingRequest(_method, _path, _query, _scheme, _authority, _headers) {
|
|
92
|
+
console.log("[types] New outgoing request");
|
|
93
|
+
},
|
|
94
|
+
outgoingRequestWrite(_req) {
|
|
95
|
+
console.log("[types] Outgoing request write");
|
|
96
|
+
},
|
|
97
|
+
dropResponseOutparam(_res) {
|
|
98
|
+
console.log("[types] Drop response outparam");
|
|
99
|
+
},
|
|
100
|
+
setResponseOutparam(_response) {
|
|
101
|
+
console.log("[types] Drop fields");
|
|
102
|
+
},
|
|
103
|
+
dropIncomingResponse(_res) {
|
|
104
|
+
console.log("[types] Drop incoming response");
|
|
105
|
+
},
|
|
106
|
+
dropOutgoingResponse(_res) {
|
|
107
|
+
console.log("[types] Drop outgoing response");
|
|
108
|
+
},
|
|
109
|
+
incomingResponseStatus(_res) {
|
|
110
|
+
console.log("[types] Incoming response status");
|
|
111
|
+
},
|
|
112
|
+
incomingResponseHeaders(_res) {
|
|
113
|
+
console.log("[types] Incoming response headers");
|
|
114
|
+
},
|
|
115
|
+
incomingResponseConsume(_res) {
|
|
116
|
+
console.log("[types] Incoming response consume");
|
|
117
|
+
},
|
|
118
|
+
newOutgoingResponse(_statusCode, _headers) {
|
|
119
|
+
console.log("[types] New outgoing response");
|
|
120
|
+
},
|
|
121
|
+
outgoingResponseWrite(_res) {
|
|
122
|
+
console.log("[types] Outgoing response write");
|
|
123
|
+
},
|
|
124
|
+
dropFutureIncomingResponse(_f) {
|
|
125
|
+
console.log("[types] Drop future incoming response");
|
|
126
|
+
},
|
|
127
|
+
futureIncomingResponseGet(_f) {
|
|
128
|
+
console.log("[types] Future incoming response get");
|
|
129
|
+
},
|
|
130
|
+
listenToFutureIncomingResponse(_f) {
|
|
131
|
+
console.log("[types] Listen to future incoming response");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
httpIncomingHandler as incomingHandler,
|
|
137
|
+
httpOutgoingHandler as outgoingHandler,
|
|
138
|
+
httpTypes as types
|
|
139
|
+
}
|
package/lib/nodejs/index.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as defaultOutgoingHttp from "./default-outgoing-HTTP.js";
|
|
3
|
-
import * as environment from "./environment.js";
|
|
4
|
-
import * as exit from "./exit.js";
|
|
1
|
+
import * as clocks from "./clocks.js";
|
|
5
2
|
import * as filesystem from "./filesystem.js";
|
|
6
3
|
import * as http from "./http.js";
|
|
7
|
-
import * as
|
|
4
|
+
import * as io from "./io.js";
|
|
5
|
+
import * as logging from "./logging.js";
|
|
8
6
|
import * as poll from "./poll.js";
|
|
9
|
-
import * as preopens from "./preopens.js";
|
|
10
7
|
import * as random from "./random.js";
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
8
|
+
import * as sockets from "./sockets.js";
|
|
9
|
+
import * as cliBase from "./cli-base.js";
|
|
13
10
|
|
|
14
11
|
export const importObject = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"random": random,
|
|
25
|
-
"streams": streams,
|
|
26
|
-
"wall-clock": wallClock,
|
|
12
|
+
clocks,
|
|
13
|
+
filesystem,
|
|
14
|
+
http,
|
|
15
|
+
io,
|
|
16
|
+
logging,
|
|
17
|
+
poll,
|
|
18
|
+
random,
|
|
19
|
+
sockets,
|
|
20
|
+
cliBase,
|
|
27
21
|
};
|
|
28
22
|
|
|
29
23
|
export { WasiHttp } from "../http/wasi-http.js";
|