@bytecodealliance/preview2-shim 0.0.8 → 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.
Files changed (102) hide show
  1. package/README.md +1 -0
  2. package/lib/browser/cli-base.js +57 -0
  3. package/lib/browser/clocks.js +50 -0
  4. package/lib/browser/filesystem.js +134 -141
  5. package/lib/browser/http.js +120 -0
  6. package/lib/browser/index.js +15 -37
  7. package/lib/browser/io.js +62 -20
  8. package/lib/browser/logging.js +16 -0
  9. package/lib/browser/poll.js +10 -6
  10. package/lib/browser/random.js +32 -25
  11. package/lib/browser/sockets.js +203 -0
  12. package/lib/nodejs/{preopens.js → cli-base.js} +47 -8
  13. package/lib/nodejs/clocks.js +50 -0
  14. package/lib/nodejs/filesystem.js +239 -234
  15. package/lib/nodejs/http.js +120 -0
  16. package/lib/nodejs/index.js +15 -37
  17. package/lib/nodejs/io.js +138 -19
  18. package/lib/nodejs/logging.js +16 -0
  19. package/lib/nodejs/poll.js +10 -6
  20. package/lib/nodejs/random.js +18 -13
  21. package/lib/nodejs/sockets.js +203 -0
  22. package/package.json +1 -1
  23. package/types/exports/{HTTP.d.ts → http-incoming-handler.d.ts} +1 -1
  24. package/types/imports/cli-base-environment.d.ts +17 -0
  25. package/types/imports/{exit.d.ts → cli-base-exit.d.ts} +4 -1
  26. package/types/imports/{preopens.d.ts → cli-base-preopens.d.ts} +6 -9
  27. package/types/imports/cli-base-stderr.d.ts +5 -0
  28. package/types/imports/cli-base-stdin.d.ts +5 -0
  29. package/types/imports/cli-base-stdout.d.ts +5 -0
  30. package/types/imports/clocks-monotonic-clock.d.ts +24 -0
  31. package/types/imports/clocks-timezone.d.ts +71 -0
  32. package/types/imports/clocks-wall-clock.d.ts +31 -0
  33. package/types/imports/filesystem-filesystem.d.ts +857 -0
  34. package/types/imports/{default-outgoing-HTTP.d.ts → http-outgoing-handler.d.ts} +1 -1
  35. package/types/imports/{types.d.ts → http-types.d.ts} +28 -28
  36. package/types/imports/io-streams.d.ts +180 -0
  37. package/types/imports/logging-handler.d.ts +40 -0
  38. package/types/imports/poll-poll.d.ts +41 -0
  39. package/types/imports/random-insecure-seed.d.ts +22 -0
  40. package/types/imports/random-insecure.d.ts +20 -0
  41. package/types/imports/random-random.d.ts +22 -0
  42. package/types/imports/{instance-network.d.ts → sockets-instance-network.d.ts} +4 -1
  43. package/types/imports/sockets-ip-name-lookup.d.ts +76 -0
  44. package/types/imports/sockets-network.d.ts +212 -0
  45. package/types/imports/sockets-tcp-create-socket.d.ts +33 -0
  46. package/types/imports/sockets-tcp.d.ts +285 -0
  47. package/types/imports/sockets-udp-create-socket.d.ts +33 -0
  48. package/types/imports/sockets-udp.d.ts +219 -0
  49. package/types/wasi-command.d.ts +23 -0
  50. package/types/wasi-proxy.d.ts +11 -44
  51. package/types/wasi-reactor.d.ts +23 -70
  52. package/lib/browser/console.js +0 -12
  53. package/lib/browser/default-outgoing-HTTP.js +0 -3
  54. package/lib/browser/environment.js +0 -17
  55. package/lib/browser/exit.js +0 -21
  56. package/lib/browser/instance-network.js +0 -3
  57. package/lib/browser/ip-name-lookup.js +0 -23
  58. package/lib/browser/monotonic-clock.js +0 -14
  59. package/lib/browser/network.js +0 -3
  60. package/lib/browser/preopens.js +0 -11
  61. package/lib/browser/stderr.js +0 -4
  62. package/lib/browser/streams.js +0 -60
  63. package/lib/browser/tcp-create-socket.js +0 -3
  64. package/lib/browser/tcp.js +0 -75
  65. package/lib/browser/timezone.js +0 -12
  66. package/lib/browser/types.js +0 -99
  67. package/lib/browser/udp-create-socket.js +0 -3
  68. package/lib/browser/udp.js +0 -75
  69. package/lib/browser/wall-clock.js +0 -9
  70. package/lib/nodejs/console.js +0 -12
  71. package/lib/nodejs/default-outgoing-HTTP.js +0 -3
  72. package/lib/nodejs/environment.js +0 -19
  73. package/lib/nodejs/exit.js +0 -3
  74. package/lib/nodejs/instance-network.js +0 -3
  75. package/lib/nodejs/ip-name-lookup.js +0 -23
  76. package/lib/nodejs/monotonic-clock.js +0 -14
  77. package/lib/nodejs/network.js +0 -3
  78. package/lib/nodejs/stderr.js +0 -4
  79. package/lib/nodejs/streams.js +0 -97
  80. package/lib/nodejs/tcp-create-socket.js +0 -3
  81. package/lib/nodejs/tcp.js +0 -75
  82. package/lib/nodejs/timezone.js +0 -12
  83. package/lib/nodejs/types.js +0 -99
  84. package/lib/nodejs/udp-create-socket.js +0 -3
  85. package/lib/nodejs/udp.js +0 -75
  86. package/lib/nodejs/wall-clock.js +0 -9
  87. package/types/imports/console.d.ts +0 -17
  88. package/types/imports/environment.d.ts +0 -4
  89. package/types/imports/filesystem.d.ts +0 -210
  90. package/types/imports/ip-name-lookup.d.ts +0 -19
  91. package/types/imports/monotonic-clock.d.ts +0 -8
  92. package/types/imports/network.d.ts +0 -50
  93. package/types/imports/poll.d.ts +0 -5
  94. package/types/imports/random.d.ts +0 -5
  95. package/types/imports/streams.d.ts +0 -23
  96. package/types/imports/tcp-create-socket.d.ts +0 -9
  97. package/types/imports/tcp.d.ts +0 -52
  98. package/types/imports/timezone.d.ts +0 -13
  99. package/types/imports/udp-create-socket.d.ts +0 -9
  100. package/types/imports/udp.d.ts +0 -36
  101. package/types/imports/wall-clock.d.ts +0 -8
  102. package/types/index.d.ts +0 -8
@@ -1,81 +1,8 @@
1
1
  import { openSync, constants, statSync, lstatSync, fstatSync, closeSync, readdirSync } from 'node:fs';
2
- import { _descriptors, _addOpenedDescriptor, _removeOpenedDescriptor, _getDescriptorType, _setSubdescriptorType, _setDescriptorType, _getFullPath } from './preopens.js';
3
- import { _createFileStream } from './streams.js';
4
-
5
- export function readViaStream(fd, offset) {
6
- return _createFileStream(fd, offset);
7
- }
8
-
9
- export function writeViaStream(fd, offset) {
10
- console.log(`[filesystem] WRITE STREAM ${fd} ${offset}`);
11
- }
12
-
13
- export function appendViaStream(fd) {
14
- console.log(`[filesystem] APPEND STREAM ${fd}`);
15
- }
16
-
17
- export function advise(fd, offset, length, advice) {
18
- console.log(`[filesystem] ADVISE`, fd, offset, length, advice);
19
- }
20
-
21
- export function syncData(fd) {
22
- console.log(`[filesystem] SYNC DATA ${fd}`);
23
- }
24
-
25
- export function getFlags(fd) {
26
- console.log(`[filesystem] FLAGS FOR ${fd}`);
27
- }
28
-
29
- export function getType(fd) {
30
- let type = _getDescriptorType(fd);
31
- if (type === null) {
32
- stat(fd);
33
- type = _getDescriptorType(fd);
34
- }
35
- return type;
36
- }
37
-
38
- export function setFlags(fd, flags) {
39
- console.log(`[filesystem] SET FLAGS ${fd} ${JSON.stringify(flags)}`);
40
- }
41
-
42
- export function setSize(fd, size) {
43
- console.log(`[filesystem] SET SIZE`, fd, size);
44
- }
45
-
46
- export function setTimes(fd, dataAccessTimestamp, dataModificationTimestamp) {
47
- console.log(`[filesystem] SET TIMES`, fd, dataAccessTimestamp, dataModificationTimestamp);
48
- }
49
-
50
- export function read(fd, length, offset) {
51
- console.log(`[filesystem] READ`, fd, length, offset);
52
- }
53
-
54
- export function write(fd, buffer, offset) {
55
- console.log(`[filesystem] WRITE`, fd, buffer, offset);
56
- }
2
+ import { _descriptors, _addOpenedDescriptor, _removeOpenedDescriptor, _getDescriptorType, _setSubdescriptorType, _setDescriptorType, _getFullPath } from './cli-base.js';
3
+ import { _createFileStream } from './io.js';
57
4
 
58
5
  let _dirStreams = [];
59
- export function readDirectory(fd) {
60
- const fullPath = _getFullPath(fd);
61
- let dirs;
62
- try {
63
- dirs = readdirSync(fullPath, { withFileTypes: true });
64
- }
65
- catch (e) {
66
- _convertFsError(e);
67
- }
68
- _dirStreams.push({ fd, dirs, cursor: 0 });
69
- return _dirStreams.length - 1;
70
- }
71
-
72
- export function sync(fd) {
73
- console.log(`[filesystem] SYNC`, fd);
74
- }
75
-
76
- export function createDirectoryAt(fd, path) {
77
- console.log(`[filesystem] CREATE DIRECTORY`, fd, path);
78
- }
79
6
 
80
7
  const nsMagnitude = 1_000_000_000_000n;
81
8
  function nsToDateTime (ns) {
@@ -84,7 +11,7 @@ function nsToDateTime (ns) {
84
11
  return { seconds, nanoseconds };
85
12
  }
86
13
 
87
- export function _convertFsError (e) {
14
+ function _convertFsError (e) {
88
15
  switch (e.code) {
89
16
  case 'EACCES': throw 'access';
90
17
  case 'EAGAIN':
@@ -146,163 +73,241 @@ function _lookupType (obj) {
146
73
  return 'unknown';
147
74
  }
148
75
 
149
- export function stat(fd) {
150
- let stats;
151
- try {
152
- stats = fstatSync(fd, { bigint: true });
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);
153
310
  }
154
- catch (e) {
155
- _convertFsError(e);
156
- }
157
- const type = _lookupType(stats);
158
- _setDescriptorType(fd, type);
159
- return {
160
- device: stats.dev,
161
- inode: stats.ino,
162
- type,
163
- linkCount: stats.nlink,
164
- size: stats.size,
165
- dataAccessTimestamp: nsToDateTime(stats.atimeNs),
166
- dataModificationTimestamp: nsToDateTime(stats.mtimeNs),
167
- statusChangeTimestamp: nsToDateTime(stats.ctimeNs),
168
- };
169
- }
170
-
171
- export function statAt(fd, { symlinkFollow }, path) {
172
- const fullPath = _descriptors[fd].path + path;
173
- let stats;
174
- try {
175
- stats = (symlinkFollow ? statSync : lstatSync)(fullPath, { bigint: true });
176
- }
177
- catch (e) {
178
- _convertFsError(e);
179
- }
180
- const type = _lookupType(stats);
181
- _setSubdescriptorType(fd, path, type);
182
- return {
183
- device: stats.dev,
184
- inode: stats.ino,
185
- type,
186
- linkCount: stats.nlink,
187
- size: stats.size,
188
- dataAccessTimestamp: nsToDateTime(stats.atimeNs),
189
- dataModificationTimestamp: nsToDateTime(stats.mtimeNs),
190
- statusChangeTimestamp: nsToDateTime(stats.ctimeNs),
191
- };
192
- }
311
+ };
193
312
 
194
- export function setTimesAt(fd) {
195
- console.log(`[filesystem] SET TIMES AT`, fd);
196
- }
197
-
198
- export function linkAt(fd) {
199
- console.log(`[filesystem] LINK AT`, fd);
200
- }
201
-
202
- export function openAt(fd, pathFlags, path, openFlags, descriptorFlags, modes) {
203
- // TODO
204
- // if (pathFlags.symlinkFollow) {
205
- // // resolve symlink
206
- // }
207
- const fullPath = _descriptors[fd].path + path;
208
- let fsOpenFlags = 0x0;
209
- if (openFlags.create)
210
- fsOpenFlags |= constants.O_CREAT;
211
- if (openFlags.directory)
212
- fsOpenFlags |= constants.O_DIRECTORY;
213
- if (openFlags.exclusive)
214
- fsOpenFlags |= constants.O_EXCL;
215
- if (openFlags.truncate)
216
- fsOpenFlags |= constants.O_TRUNC;
217
- if (descriptorFlags.read && descriptorFlags.write)
218
- fsOpenFlags |= constants.O_RDWR;
219
- else if (descriptorFlags.write)
220
- fsOpenFlags |= constants.O_WRONLY;
221
- // if (descriptorFlags.fileIntegritySync)
222
- // if (descriptorFlags.dataIntegritySync)
223
- // if (descriptorFlags.requestedWriteSync)
224
- // if (descriptorFlags.mutateDirectory)
225
- let fsMode = 0x0;
226
- if (modes.readable)
227
- fsMode |= 0o444;
228
- if (modes.writeable)
229
- fsMode |= 0o222;
230
- if (modes.executable)
231
- fsMode |= 0o111;
232
- let localFd;
233
- try {
234
- localFd = openSync(fullPath, fsOpenFlags, fsMode);
235
- }
236
- catch (e) {
237
- _convertFsError(e);
238
- }
239
- _addOpenedDescriptor(localFd, path, fd);
240
- return localFd;
241
- }
242
-
243
- export function readlinkAt(fd) {
244
- console.log(`[filesystem] READLINK AT`, fd);
245
- }
246
-
247
- export function removeDirectoryAt(fd) {
248
- console.log(`[filesystem] REMOVE DIR AT`, fd);
249
- }
250
-
251
- export function renameAt(fd) {
252
- console.log(`[filesystem] RENAME AT`, fd);
253
- }
254
-
255
- export function symlinkAt(fd) {
256
- console.log(`[filesystem] SYMLINK AT`, fd);
257
- }
258
-
259
- export function unlinkFileAt(fd) {
260
- console.log(`[filesystem] UNLINK FILE AT`, fd);
261
- }
262
-
263
- export function changeFilePermissionsAt(fd) {
264
- console.log(`[filesystem] CHANGE FILE PERMISSIONS AT`, fd);
265
- }
266
-
267
- export function changeDirectoryPermissionsAt(fd) {
268
- console.log(`[filesystem] CHANGE DIR PERMISSIONS AT`, fd);
269
- }
270
-
271
- export function lockShared(fd) {
272
- console.log(`[filesystem] LOCK SHARED`, fd);
273
- }
274
-
275
- export function lockExclusive(fd) {
276
- console.log(`[filesystem] LOCK EXCLUSIVE`, fd);
277
- }
278
-
279
- export function tryLockShared(fd) {
280
- console.log(`[filesystem] TRY LOCK SHARED`, fd);
281
- }
282
-
283
- export function tryLockExclusive(fd) {
284
- console.log(`[filesystem] TRY LOCK EXCLUSIVE`, fd);
285
- }
286
-
287
- export function unlock(fd) {
288
- console.log(`[filesystem] UNLOCK`, fd);
289
- }
290
-
291
- export function dropDescriptor(fd) {
292
- _removeOpenedDescriptor(fd);
293
- closeSync(fd);
294
- }
295
-
296
- export function readDirectoryEntry(stream) {
297
- const streamValue = _dirStreams[stream];
298
- if (streamValue.cursor === streamValue.dirs.length)
299
- return null;
300
- const dir = streamValue.dirs[streamValue.cursor++];
301
- const type = _lookupType(dir);
302
- _setSubdescriptorType(streamValue.fd, '/' + dir.name, type);
303
- return { inode: null, type, name: dir.name };
304
- }
305
-
306
- export function dropDirectoryEntryStream(stream) {
307
- _dirStreams.splice(stream, 1);
308
- }
313
+ export { filesystem as filesystemFilesystem }
@@ -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
+ }
@@ -1,45 +1,23 @@
1
- import * as console from "./console.js";
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
- import * as instanceNetwork from "./instance-network.js";
7
- import * as ipNameLookup from "./ip-name-lookup.js";
8
- import * as monotonicClock from "./monotonic-clock.js";
9
- import * as network from "./network.js";
3
+ import * as http from "./http.js";
4
+ import * as io from "./io.js";
5
+ import * as logging from "./logging.js";
10
6
  import * as poll from "./poll.js";
11
- import * as preopens from "./preopens.js";
12
7
  import * as random from "./random.js";
13
- import * as streams from "./streams.js";
14
- import * as tcpCreateSocket from "./tcp-create-socket.js";
15
- import * as tcp from "./tcp.js";
16
- import * as timezone from "./timezone.js";
17
- import * as types from "./types.js";
18
- import * as udpCreateSocket from "./udp-create-socket.js";
19
- import * as udp from "./udp.js";
20
- import * as wallClock from "./wall-clock.js";
8
+ import * as sockets from "./sockets.js";
9
+ import * as cliBase from "./cli-base.js";
21
10
 
22
11
  export const importObject = {
23
- 'console': console,
24
- 'default-outgoing-HTTP': defaultOutgoingHttp,
25
- 'environment': environment,
26
- 'exit': exit,
27
- 'filesystem': filesystem,
28
- 'instance-network': instanceNetwork,
29
- 'ip-name-lookup': ipNameLookup,
30
- 'monotonic-clock': monotonicClock,
31
- 'network': network,
32
- 'poll': poll,
33
- 'preopens': preopens,
34
- 'random': random,
35
- 'streams': streams,
36
- 'tcp-create-socket': tcpCreateSocket,
37
- 'tcp': tcp,
38
- 'timezone': timezone,
39
- 'types': types,
40
- 'udp-create-socket': udpCreateSocket,
41
- 'udp': udp,
42
- 'wall-clock': wallClock
12
+ clocks,
13
+ filesystem,
14
+ http,
15
+ io,
16
+ logging,
17
+ poll,
18
+ random,
19
+ sockets,
20
+ cliBase,
43
21
  };
44
22
 
45
23
  export { WasiHttp } from "../http/wasi-http.js";