@bytecodealliance/preview2-shim 0.16.0 → 0.16.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/lib/io/worker-http.js +12 -9
- package/lib/nodejs/clocks.js +2 -2
- package/lib/nodejs/http.js +11 -19
- package/lib/nodejs/random.js +1 -1
- package/package.json +1 -1
- package/types/clocks.d.ts +2 -2
- package/types/interfaces/wasi-cli-stderr.d.ts +1 -1
- package/types/interfaces/wasi-cli-stdin.d.ts +1 -1
- package/types/interfaces/wasi-cli-stdout.d.ts +1 -1
- package/types/interfaces/wasi-cli-terminal-stderr.d.ts +1 -1
- package/types/interfaces/wasi-cli-terminal-stdin.d.ts +1 -1
- package/types/interfaces/wasi-cli-terminal-stdout.d.ts +1 -1
- package/types/interfaces/wasi-clocks-monotonic-clock.d.ts +1 -1
- package/types/interfaces/wasi-filesystem-preopens.d.ts +1 -1
- package/types/interfaces/wasi-filesystem-types.d.ts +249 -249
- package/types/interfaces/wasi-http-incoming-handler.d.ts +2 -2
- package/types/interfaces/wasi-http-outgoing-handler.d.ts +4 -4
- package/types/interfaces/wasi-http-types.d.ts +359 -359
- package/types/interfaces/wasi-io-error.d.ts +9 -9
- package/types/interfaces/wasi-io-poll.d.ts +12 -12
- package/types/interfaces/wasi-io-streams.d.ts +218 -218
- package/types/interfaces/wasi-sockets-instance-network.d.ts +1 -1
- package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +25 -25
- package/types/interfaces/wasi-sockets-tcp-create-socket.d.ts +4 -4
- package/types/interfaces/wasi-sockets-tcp.d.ts +309 -309
- package/types/interfaces/wasi-sockets-udp-create-socket.d.ts +4 -4
- package/types/interfaces/wasi-sockets-udp.d.ts +276 -276
|
@@ -1,250 +1,5 @@
|
|
|
1
1
|
export namespace WasiFilesystemTypes {
|
|
2
|
-
/**
|
|
3
|
-
* Return a stream for reading from a file, if available.
|
|
4
|
-
*
|
|
5
|
-
* May fail with an error-code describing why the file cannot be read.
|
|
6
|
-
*
|
|
7
|
-
* Multiple read, write, and append streams may be active on the same open
|
|
8
|
-
* file and they do not interfere with each other.
|
|
9
|
-
*
|
|
10
|
-
* Note: This allows using `read-stream`, which is similar to `read` in POSIX.
|
|
11
|
-
*/
|
|
12
2
|
export { Descriptor };
|
|
13
|
-
/**
|
|
14
|
-
* Return a stream for writing to a file, if available.
|
|
15
|
-
*
|
|
16
|
-
* May fail with an error-code describing why the file cannot be written.
|
|
17
|
-
*
|
|
18
|
-
* Note: This allows using `write-stream`, which is similar to `write` in
|
|
19
|
-
* POSIX.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Return a stream for appending to a file, if available.
|
|
23
|
-
*
|
|
24
|
-
* May fail with an error-code describing why the file cannot be appended.
|
|
25
|
-
*
|
|
26
|
-
* Note: This allows using `write-stream`, which is similar to `write` with
|
|
27
|
-
* `O_APPEND` in in POSIX.
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Provide file advisory information on a descriptor.
|
|
31
|
-
*
|
|
32
|
-
* This is similar to `posix_fadvise` in POSIX.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* Synchronize the data of a file to disk.
|
|
36
|
-
*
|
|
37
|
-
* This function succeeds with no effect if the file descriptor is not
|
|
38
|
-
* opened for writing.
|
|
39
|
-
*
|
|
40
|
-
* Note: This is similar to `fdatasync` in POSIX.
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* Get flags associated with a descriptor.
|
|
44
|
-
*
|
|
45
|
-
* Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
|
|
46
|
-
*
|
|
47
|
-
* Note: This returns the value that was the `fs_flags` value returned
|
|
48
|
-
* from `fdstat_get` in earlier versions of WASI.
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* Get the dynamic type of a descriptor.
|
|
52
|
-
*
|
|
53
|
-
* Note: This returns the same value as the `type` field of the `fd-stat`
|
|
54
|
-
* returned by `stat`, `stat-at` and similar.
|
|
55
|
-
*
|
|
56
|
-
* Note: This returns similar flags to the `st_mode & S_IFMT` value provided
|
|
57
|
-
* by `fstat` in POSIX.
|
|
58
|
-
*
|
|
59
|
-
* Note: This returns the value that was the `fs_filetype` value returned
|
|
60
|
-
* from `fdstat_get` in earlier versions of WASI.
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Adjust the size of an open file. If this increases the file's size, the
|
|
64
|
-
* extra bytes are filled with zeros.
|
|
65
|
-
*
|
|
66
|
-
* Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Adjust the timestamps of an open file or directory.
|
|
70
|
-
*
|
|
71
|
-
* Note: This is similar to `futimens` in POSIX.
|
|
72
|
-
*
|
|
73
|
-
* Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* Read from a descriptor, without using and updating the descriptor's offset.
|
|
77
|
-
*
|
|
78
|
-
* This function returns a list of bytes containing the data that was
|
|
79
|
-
* read, along with a bool which, when true, indicates that the end of the
|
|
80
|
-
* file was reached. The returned list will contain up to `length` bytes; it
|
|
81
|
-
* may return fewer than requested, if the end of the file is reached or
|
|
82
|
-
* if the I/O operation is interrupted.
|
|
83
|
-
*
|
|
84
|
-
* In the future, this may change to return a `stream<u8, error-code>`.
|
|
85
|
-
*
|
|
86
|
-
* Note: This is similar to `pread` in POSIX.
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* Write to a descriptor, without using and updating the descriptor's offset.
|
|
90
|
-
*
|
|
91
|
-
* It is valid to write past the end of a file; the file is extended to the
|
|
92
|
-
* extent of the write, with bytes between the previous end and the start of
|
|
93
|
-
* the write set to zero.
|
|
94
|
-
*
|
|
95
|
-
* In the future, this may change to take a `stream<u8, error-code>`.
|
|
96
|
-
*
|
|
97
|
-
* Note: This is similar to `pwrite` in POSIX.
|
|
98
|
-
*/
|
|
99
|
-
/**
|
|
100
|
-
* Read directory entries from a directory.
|
|
101
|
-
*
|
|
102
|
-
* On filesystems where directories contain entries referring to themselves
|
|
103
|
-
* and their parents, often named `.` and `..` respectively, these entries
|
|
104
|
-
* are omitted.
|
|
105
|
-
*
|
|
106
|
-
* This always returns a new stream which starts at the beginning of the
|
|
107
|
-
* directory. Multiple streams may be active on the same directory, and they
|
|
108
|
-
* do not interfere with each other.
|
|
109
|
-
*/
|
|
110
|
-
/**
|
|
111
|
-
* Synchronize the data and metadata of a file to disk.
|
|
112
|
-
*
|
|
113
|
-
* This function succeeds with no effect if the file descriptor is not
|
|
114
|
-
* opened for writing.
|
|
115
|
-
*
|
|
116
|
-
* Note: This is similar to `fsync` in POSIX.
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Create a directory.
|
|
120
|
-
*
|
|
121
|
-
* Note: This is similar to `mkdirat` in POSIX.
|
|
122
|
-
*/
|
|
123
|
-
/**
|
|
124
|
-
* Return the attributes of an open file or directory.
|
|
125
|
-
*
|
|
126
|
-
* Note: This is similar to `fstat` in POSIX, except that it does not return
|
|
127
|
-
* device and inode information. For testing whether two descriptors refer to
|
|
128
|
-
* the same underlying filesystem object, use `is-same-object`. To obtain
|
|
129
|
-
* additional data that can be used do determine whether a file has been
|
|
130
|
-
* modified, use `metadata-hash`.
|
|
131
|
-
*
|
|
132
|
-
* Note: This was called `fd_filestat_get` in earlier versions of WASI.
|
|
133
|
-
*/
|
|
134
|
-
/**
|
|
135
|
-
* Return the attributes of a file or directory.
|
|
136
|
-
*
|
|
137
|
-
* Note: This is similar to `fstatat` in POSIX, except that it does not
|
|
138
|
-
* return device and inode information. See the `stat` description for a
|
|
139
|
-
* discussion of alternatives.
|
|
140
|
-
*
|
|
141
|
-
* Note: This was called `path_filestat_get` in earlier versions of WASI.
|
|
142
|
-
*/
|
|
143
|
-
/**
|
|
144
|
-
* Adjust the timestamps of a file or directory.
|
|
145
|
-
*
|
|
146
|
-
* Note: This is similar to `utimensat` in POSIX.
|
|
147
|
-
*
|
|
148
|
-
* Note: This was called `path_filestat_set_times` in earlier versions of
|
|
149
|
-
* WASI.
|
|
150
|
-
*/
|
|
151
|
-
/**
|
|
152
|
-
* Create a hard link.
|
|
153
|
-
*
|
|
154
|
-
* Note: This is similar to `linkat` in POSIX.
|
|
155
|
-
*/
|
|
156
|
-
/**
|
|
157
|
-
* Open a file or directory.
|
|
158
|
-
*
|
|
159
|
-
* The returned descriptor is not guaranteed to be the lowest-numbered
|
|
160
|
-
* descriptor not currently open/ it is randomized to prevent applications
|
|
161
|
-
* from depending on making assumptions about indexes, since this is
|
|
162
|
-
* error-prone in multi-threaded contexts. The returned descriptor is
|
|
163
|
-
* guaranteed to be less than 2**31.
|
|
164
|
-
*
|
|
165
|
-
* If `flags` contains `descriptor-flags::mutate-directory`, and the base
|
|
166
|
-
* descriptor doesn't have `descriptor-flags::mutate-directory` set,
|
|
167
|
-
* `open-at` fails with `error-code::read-only`.
|
|
168
|
-
*
|
|
169
|
-
* If `flags` contains `write` or `mutate-directory`, or `open-flags`
|
|
170
|
-
* contains `truncate` or `create`, and the base descriptor doesn't have
|
|
171
|
-
* `descriptor-flags::mutate-directory` set, `open-at` fails with
|
|
172
|
-
* `error-code::read-only`.
|
|
173
|
-
*
|
|
174
|
-
* Note: This is similar to `openat` in POSIX.
|
|
175
|
-
*/
|
|
176
|
-
/**
|
|
177
|
-
* Read the contents of a symbolic link.
|
|
178
|
-
*
|
|
179
|
-
* If the contents contain an absolute or rooted path in the underlying
|
|
180
|
-
* filesystem, this function fails with `error-code::not-permitted`.
|
|
181
|
-
*
|
|
182
|
-
* Note: This is similar to `readlinkat` in POSIX.
|
|
183
|
-
*/
|
|
184
|
-
/**
|
|
185
|
-
* Remove a directory.
|
|
186
|
-
*
|
|
187
|
-
* Return `error-code::not-empty` if the directory is not empty.
|
|
188
|
-
*
|
|
189
|
-
* Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
|
|
190
|
-
*/
|
|
191
|
-
/**
|
|
192
|
-
* Rename a filesystem object.
|
|
193
|
-
*
|
|
194
|
-
* Note: This is similar to `renameat` in POSIX.
|
|
195
|
-
*/
|
|
196
|
-
/**
|
|
197
|
-
* Create a symbolic link (also known as a "symlink").
|
|
198
|
-
*
|
|
199
|
-
* If `old-path` starts with `/`, the function fails with
|
|
200
|
-
* `error-code::not-permitted`.
|
|
201
|
-
*
|
|
202
|
-
* Note: This is similar to `symlinkat` in POSIX.
|
|
203
|
-
*/
|
|
204
|
-
/**
|
|
205
|
-
* Unlink a filesystem object that is not a directory.
|
|
206
|
-
*
|
|
207
|
-
* Return `error-code::is-directory` if the path refers to a directory.
|
|
208
|
-
* Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
|
|
209
|
-
*/
|
|
210
|
-
/**
|
|
211
|
-
* Test whether two descriptors refer to the same filesystem object.
|
|
212
|
-
*
|
|
213
|
-
* In POSIX, this corresponds to testing whether the two descriptors have the
|
|
214
|
-
* same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
|
|
215
|
-
* wasi-filesystem does not expose device and inode numbers, so this function
|
|
216
|
-
* may be used instead.
|
|
217
|
-
*/
|
|
218
|
-
/**
|
|
219
|
-
* Return a hash of the metadata associated with a filesystem object referred
|
|
220
|
-
* to by a descriptor.
|
|
221
|
-
*
|
|
222
|
-
* This returns a hash of the last-modification timestamp and file size, and
|
|
223
|
-
* may also include the inode number, device number, birth timestamp, and
|
|
224
|
-
* other metadata fields that may change when the file is modified or
|
|
225
|
-
* replaced. It may also include a secret value chosen by the
|
|
226
|
-
* implementation and not otherwise exposed.
|
|
227
|
-
*
|
|
228
|
-
* Implementations are encourated to provide the following properties:
|
|
229
|
-
*
|
|
230
|
-
* - If the file is not modified or replaced, the computed hash value should
|
|
231
|
-
* usually not change.
|
|
232
|
-
* - If the object is modified or replaced, the computed hash value should
|
|
233
|
-
* usually change.
|
|
234
|
-
* - The inputs to the hash should not be easily computable from the
|
|
235
|
-
* computed hash.
|
|
236
|
-
*
|
|
237
|
-
* However, none of these is required.
|
|
238
|
-
*/
|
|
239
|
-
/**
|
|
240
|
-
* Return a hash of the metadata associated with a filesystem object referred
|
|
241
|
-
* to by a directory descriptor and a relative path.
|
|
242
|
-
*
|
|
243
|
-
* This performs the same hash computation as `metadata-hash`.
|
|
244
|
-
*/
|
|
245
|
-
/**
|
|
246
|
-
* Read a single directory entry from a `directory-entry-stream`.
|
|
247
|
-
*/
|
|
248
3
|
export { DirectoryEntryStream };
|
|
249
4
|
/**
|
|
250
5
|
* Attempts to extract a filesystem-related `error-code` from the stream
|
|
@@ -260,13 +15,13 @@ export namespace WasiFilesystemTypes {
|
|
|
260
15
|
*/
|
|
261
16
|
export function filesystemErrorCode(err: Error): ErrorCode | undefined;
|
|
262
17
|
}
|
|
263
|
-
import type { InputStream } from '
|
|
18
|
+
import type { InputStream } from './wasi-io-streams.js';
|
|
264
19
|
export { InputStream };
|
|
265
|
-
import type { OutputStream } from '
|
|
20
|
+
import type { OutputStream } from './wasi-io-streams.js';
|
|
266
21
|
export { OutputStream };
|
|
267
|
-
import type { Error } from '
|
|
22
|
+
import type { Error } from './wasi-io-streams.js';
|
|
268
23
|
export { Error };
|
|
269
|
-
import type { Datetime } from '
|
|
24
|
+
import type { Datetime } from './wasi-clocks-wall-clock.js';
|
|
270
25
|
export { Datetime };
|
|
271
26
|
/**
|
|
272
27
|
* File size or length of a region within a file.
|
|
@@ -640,35 +395,280 @@ export interface MetadataHashValue {
|
|
|
640
395
|
}
|
|
641
396
|
|
|
642
397
|
export class Descriptor {
|
|
398
|
+
/**
|
|
399
|
+
* Return a stream for reading from a file, if available.
|
|
400
|
+
*
|
|
401
|
+
* May fail with an error-code describing why the file cannot be read.
|
|
402
|
+
*
|
|
403
|
+
* Multiple read, write, and append streams may be active on the same open
|
|
404
|
+
* file and they do not interfere with each other.
|
|
405
|
+
*
|
|
406
|
+
* Note: This allows using `read-stream`, which is similar to `read` in POSIX.
|
|
407
|
+
*/
|
|
643
408
|
readViaStream(offset: Filesize): InputStream;
|
|
409
|
+
/**
|
|
410
|
+
* Return a stream for writing to a file, if available.
|
|
411
|
+
*
|
|
412
|
+
* May fail with an error-code describing why the file cannot be written.
|
|
413
|
+
*
|
|
414
|
+
* Note: This allows using `write-stream`, which is similar to `write` in
|
|
415
|
+
* POSIX.
|
|
416
|
+
*/
|
|
644
417
|
writeViaStream(offset: Filesize): OutputStream;
|
|
418
|
+
/**
|
|
419
|
+
* Return a stream for appending to a file, if available.
|
|
420
|
+
*
|
|
421
|
+
* May fail with an error-code describing why the file cannot be appended.
|
|
422
|
+
*
|
|
423
|
+
* Note: This allows using `write-stream`, which is similar to `write` with
|
|
424
|
+
* `O_APPEND` in in POSIX.
|
|
425
|
+
*/
|
|
645
426
|
appendViaStream(): OutputStream;
|
|
427
|
+
/**
|
|
428
|
+
* Provide file advisory information on a descriptor.
|
|
429
|
+
*
|
|
430
|
+
* This is similar to `posix_fadvise` in POSIX.
|
|
431
|
+
*/
|
|
646
432
|
advise(offset: Filesize, length: Filesize, advice: Advice): void;
|
|
433
|
+
/**
|
|
434
|
+
* Synchronize the data of a file to disk.
|
|
435
|
+
*
|
|
436
|
+
* This function succeeds with no effect if the file descriptor is not
|
|
437
|
+
* opened for writing.
|
|
438
|
+
*
|
|
439
|
+
* Note: This is similar to `fdatasync` in POSIX.
|
|
440
|
+
*/
|
|
647
441
|
syncData(): void;
|
|
442
|
+
/**
|
|
443
|
+
* Get flags associated with a descriptor.
|
|
444
|
+
*
|
|
445
|
+
* Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
|
|
446
|
+
*
|
|
447
|
+
* Note: This returns the value that was the `fs_flags` value returned
|
|
448
|
+
* from `fdstat_get` in earlier versions of WASI.
|
|
449
|
+
*/
|
|
648
450
|
getFlags(): DescriptorFlags;
|
|
451
|
+
/**
|
|
452
|
+
* Get the dynamic type of a descriptor.
|
|
453
|
+
*
|
|
454
|
+
* Note: This returns the same value as the `type` field of the `fd-stat`
|
|
455
|
+
* returned by `stat`, `stat-at` and similar.
|
|
456
|
+
*
|
|
457
|
+
* Note: This returns similar flags to the `st_mode & S_IFMT` value provided
|
|
458
|
+
* by `fstat` in POSIX.
|
|
459
|
+
*
|
|
460
|
+
* Note: This returns the value that was the `fs_filetype` value returned
|
|
461
|
+
* from `fdstat_get` in earlier versions of WASI.
|
|
462
|
+
*/
|
|
649
463
|
getType(): DescriptorType;
|
|
464
|
+
/**
|
|
465
|
+
* Adjust the size of an open file. If this increases the file's size, the
|
|
466
|
+
* extra bytes are filled with zeros.
|
|
467
|
+
*
|
|
468
|
+
* Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
|
|
469
|
+
*/
|
|
650
470
|
setSize(size: Filesize): void;
|
|
471
|
+
/**
|
|
472
|
+
* Adjust the timestamps of an open file or directory.
|
|
473
|
+
*
|
|
474
|
+
* Note: This is similar to `futimens` in POSIX.
|
|
475
|
+
*
|
|
476
|
+
* Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
|
|
477
|
+
*/
|
|
651
478
|
setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
479
|
+
/**
|
|
480
|
+
* Read from a descriptor, without using and updating the descriptor's offset.
|
|
481
|
+
*
|
|
482
|
+
* This function returns a list of bytes containing the data that was
|
|
483
|
+
* read, along with a bool which, when true, indicates that the end of the
|
|
484
|
+
* file was reached. The returned list will contain up to `length` bytes; it
|
|
485
|
+
* may return fewer than requested, if the end of the file is reached or
|
|
486
|
+
* if the I/O operation is interrupted.
|
|
487
|
+
*
|
|
488
|
+
* In the future, this may change to return a `stream<u8, error-code>`.
|
|
489
|
+
*
|
|
490
|
+
* Note: This is similar to `pread` in POSIX.
|
|
491
|
+
*/
|
|
652
492
|
read(length: Filesize, offset: Filesize): [Uint8Array, boolean];
|
|
493
|
+
/**
|
|
494
|
+
* Write to a descriptor, without using and updating the descriptor's offset.
|
|
495
|
+
*
|
|
496
|
+
* It is valid to write past the end of a file; the file is extended to the
|
|
497
|
+
* extent of the write, with bytes between the previous end and the start of
|
|
498
|
+
* the write set to zero.
|
|
499
|
+
*
|
|
500
|
+
* In the future, this may change to take a `stream<u8, error-code>`.
|
|
501
|
+
*
|
|
502
|
+
* Note: This is similar to `pwrite` in POSIX.
|
|
503
|
+
*/
|
|
653
504
|
write(buffer: Uint8Array, offset: Filesize): Filesize;
|
|
505
|
+
/**
|
|
506
|
+
* Read directory entries from a directory.
|
|
507
|
+
*
|
|
508
|
+
* On filesystems where directories contain entries referring to themselves
|
|
509
|
+
* and their parents, often named `.` and `..` respectively, these entries
|
|
510
|
+
* are omitted.
|
|
511
|
+
*
|
|
512
|
+
* This always returns a new stream which starts at the beginning of the
|
|
513
|
+
* directory. Multiple streams may be active on the same directory, and they
|
|
514
|
+
* do not interfere with each other.
|
|
515
|
+
*/
|
|
654
516
|
readDirectory(): DirectoryEntryStream;
|
|
517
|
+
/**
|
|
518
|
+
* Synchronize the data and metadata of a file to disk.
|
|
519
|
+
*
|
|
520
|
+
* This function succeeds with no effect if the file descriptor is not
|
|
521
|
+
* opened for writing.
|
|
522
|
+
*
|
|
523
|
+
* Note: This is similar to `fsync` in POSIX.
|
|
524
|
+
*/
|
|
655
525
|
sync(): void;
|
|
526
|
+
/**
|
|
527
|
+
* Create a directory.
|
|
528
|
+
*
|
|
529
|
+
* Note: This is similar to `mkdirat` in POSIX.
|
|
530
|
+
*/
|
|
656
531
|
createDirectoryAt(path: string): void;
|
|
532
|
+
/**
|
|
533
|
+
* Return the attributes of an open file or directory.
|
|
534
|
+
*
|
|
535
|
+
* Note: This is similar to `fstat` in POSIX, except that it does not return
|
|
536
|
+
* device and inode information. For testing whether two descriptors refer to
|
|
537
|
+
* the same underlying filesystem object, use `is-same-object`. To obtain
|
|
538
|
+
* additional data that can be used do determine whether a file has been
|
|
539
|
+
* modified, use `metadata-hash`.
|
|
540
|
+
*
|
|
541
|
+
* Note: This was called `fd_filestat_get` in earlier versions of WASI.
|
|
542
|
+
*/
|
|
657
543
|
stat(): DescriptorStat;
|
|
544
|
+
/**
|
|
545
|
+
* Return the attributes of a file or directory.
|
|
546
|
+
*
|
|
547
|
+
* Note: This is similar to `fstatat` in POSIX, except that it does not
|
|
548
|
+
* return device and inode information. See the `stat` description for a
|
|
549
|
+
* discussion of alternatives.
|
|
550
|
+
*
|
|
551
|
+
* Note: This was called `path_filestat_get` in earlier versions of WASI.
|
|
552
|
+
*/
|
|
658
553
|
statAt(pathFlags: PathFlags, path: string): DescriptorStat;
|
|
554
|
+
/**
|
|
555
|
+
* Adjust the timestamps of a file or directory.
|
|
556
|
+
*
|
|
557
|
+
* Note: This is similar to `utimensat` in POSIX.
|
|
558
|
+
*
|
|
559
|
+
* Note: This was called `path_filestat_set_times` in earlier versions of
|
|
560
|
+
* WASI.
|
|
561
|
+
*/
|
|
659
562
|
setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
563
|
+
/**
|
|
564
|
+
* Create a hard link.
|
|
565
|
+
*
|
|
566
|
+
* Note: This is similar to `linkat` in POSIX.
|
|
567
|
+
*/
|
|
660
568
|
linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
|
|
569
|
+
/**
|
|
570
|
+
* Open a file or directory.
|
|
571
|
+
*
|
|
572
|
+
* The returned descriptor is not guaranteed to be the lowest-numbered
|
|
573
|
+
* descriptor not currently open/ it is randomized to prevent applications
|
|
574
|
+
* from depending on making assumptions about indexes, since this is
|
|
575
|
+
* error-prone in multi-threaded contexts. The returned descriptor is
|
|
576
|
+
* guaranteed to be less than 2**31.
|
|
577
|
+
*
|
|
578
|
+
* If `flags` contains `descriptor-flags::mutate-directory`, and the base
|
|
579
|
+
* descriptor doesn't have `descriptor-flags::mutate-directory` set,
|
|
580
|
+
* `open-at` fails with `error-code::read-only`.
|
|
581
|
+
*
|
|
582
|
+
* If `flags` contains `write` or `mutate-directory`, or `open-flags`
|
|
583
|
+
* contains `truncate` or `create`, and the base descriptor doesn't have
|
|
584
|
+
* `descriptor-flags::mutate-directory` set, `open-at` fails with
|
|
585
|
+
* `error-code::read-only`.
|
|
586
|
+
*
|
|
587
|
+
* Note: This is similar to `openat` in POSIX.
|
|
588
|
+
*/
|
|
661
589
|
openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Descriptor;
|
|
590
|
+
/**
|
|
591
|
+
* Read the contents of a symbolic link.
|
|
592
|
+
*
|
|
593
|
+
* If the contents contain an absolute or rooted path in the underlying
|
|
594
|
+
* filesystem, this function fails with `error-code::not-permitted`.
|
|
595
|
+
*
|
|
596
|
+
* Note: This is similar to `readlinkat` in POSIX.
|
|
597
|
+
*/
|
|
662
598
|
readlinkAt(path: string): string;
|
|
599
|
+
/**
|
|
600
|
+
* Remove a directory.
|
|
601
|
+
*
|
|
602
|
+
* Return `error-code::not-empty` if the directory is not empty.
|
|
603
|
+
*
|
|
604
|
+
* Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
|
|
605
|
+
*/
|
|
663
606
|
removeDirectoryAt(path: string): void;
|
|
607
|
+
/**
|
|
608
|
+
* Rename a filesystem object.
|
|
609
|
+
*
|
|
610
|
+
* Note: This is similar to `renameat` in POSIX.
|
|
611
|
+
*/
|
|
664
612
|
renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): void;
|
|
613
|
+
/**
|
|
614
|
+
* Create a symbolic link (also known as a "symlink").
|
|
615
|
+
*
|
|
616
|
+
* If `old-path` starts with `/`, the function fails with
|
|
617
|
+
* `error-code::not-permitted`.
|
|
618
|
+
*
|
|
619
|
+
* Note: This is similar to `symlinkat` in POSIX.
|
|
620
|
+
*/
|
|
665
621
|
symlinkAt(oldPath: string, newPath: string): void;
|
|
622
|
+
/**
|
|
623
|
+
* Unlink a filesystem object that is not a directory.
|
|
624
|
+
*
|
|
625
|
+
* Return `error-code::is-directory` if the path refers to a directory.
|
|
626
|
+
* Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
|
|
627
|
+
*/
|
|
666
628
|
unlinkFileAt(path: string): void;
|
|
629
|
+
/**
|
|
630
|
+
* Test whether two descriptors refer to the same filesystem object.
|
|
631
|
+
*
|
|
632
|
+
* In POSIX, this corresponds to testing whether the two descriptors have the
|
|
633
|
+
* same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
|
|
634
|
+
* wasi-filesystem does not expose device and inode numbers, so this function
|
|
635
|
+
* may be used instead.
|
|
636
|
+
*/
|
|
667
637
|
isSameObject(other: Descriptor): boolean;
|
|
638
|
+
/**
|
|
639
|
+
* Return a hash of the metadata associated with a filesystem object referred
|
|
640
|
+
* to by a descriptor.
|
|
641
|
+
*
|
|
642
|
+
* This returns a hash of the last-modification timestamp and file size, and
|
|
643
|
+
* may also include the inode number, device number, birth timestamp, and
|
|
644
|
+
* other metadata fields that may change when the file is modified or
|
|
645
|
+
* replaced. It may also include a secret value chosen by the
|
|
646
|
+
* implementation and not otherwise exposed.
|
|
647
|
+
*
|
|
648
|
+
* Implementations are encourated to provide the following properties:
|
|
649
|
+
*
|
|
650
|
+
* - If the file is not modified or replaced, the computed hash value should
|
|
651
|
+
* usually not change.
|
|
652
|
+
* - If the object is modified or replaced, the computed hash value should
|
|
653
|
+
* usually change.
|
|
654
|
+
* - The inputs to the hash should not be easily computable from the
|
|
655
|
+
* computed hash.
|
|
656
|
+
*
|
|
657
|
+
* However, none of these is required.
|
|
658
|
+
*/
|
|
668
659
|
metadataHash(): MetadataHashValue;
|
|
660
|
+
/**
|
|
661
|
+
* Return a hash of the metadata associated with a filesystem object referred
|
|
662
|
+
* to by a directory descriptor and a relative path.
|
|
663
|
+
*
|
|
664
|
+
* This performs the same hash computation as `metadata-hash`.
|
|
665
|
+
*/
|
|
669
666
|
metadataHashAt(pathFlags: PathFlags, path: string): MetadataHashValue;
|
|
670
667
|
}
|
|
671
668
|
|
|
672
669
|
export class DirectoryEntryStream {
|
|
670
|
+
/**
|
|
671
|
+
* Read a single directory entry from a `directory-entry-stream`.
|
|
672
|
+
*/
|
|
673
673
|
readDirectoryEntry(): DirectoryEntry | undefined;
|
|
674
674
|
}
|
|
@@ -13,7 +13,7 @@ export namespace WasiHttpIncomingHandler {
|
|
|
13
13
|
*/
|
|
14
14
|
export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
|
|
15
15
|
}
|
|
16
|
-
import type { IncomingRequest } from '
|
|
16
|
+
import type { IncomingRequest } from './wasi-http-types.js';
|
|
17
17
|
export { IncomingRequest };
|
|
18
|
-
import type { ResponseOutparam } from '
|
|
18
|
+
import type { ResponseOutparam } from './wasi-http-types.js';
|
|
19
19
|
export { ResponseOutparam };
|
|
@@ -13,11 +13,11 @@ export namespace WasiHttpOutgoingHandler {
|
|
|
13
13
|
*/
|
|
14
14
|
export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
|
|
15
15
|
}
|
|
16
|
-
import type { OutgoingRequest } from '
|
|
16
|
+
import type { OutgoingRequest } from './wasi-http-types.js';
|
|
17
17
|
export { OutgoingRequest };
|
|
18
|
-
import type { RequestOptions } from '
|
|
18
|
+
import type { RequestOptions } from './wasi-http-types.js';
|
|
19
19
|
export { RequestOptions };
|
|
20
|
-
import type { FutureIncomingResponse } from '
|
|
20
|
+
import type { FutureIncomingResponse } from './wasi-http-types.js';
|
|
21
21
|
export { FutureIncomingResponse };
|
|
22
|
-
import type { ErrorCode } from '
|
|
22
|
+
import type { ErrorCode } from './wasi-http-types.js';
|
|
23
23
|
export { ErrorCode };
|