@bytecodealliance/preview2-shim 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/browser/{cli-base.js → cli.js} +30 -6
  2. package/lib/browser/filesystem.js +16 -2
  3. package/lib/browser/index.js +2 -2
  4. package/lib/nodejs/cli.js +65 -0
  5. package/lib/nodejs/filesystem.js +93 -3
  6. package/lib/nodejs/index.js +2 -2
  7. package/package.json +1 -1
  8. package/lib/nodejs/cli-base.js +0 -99
  9. package/types/exports/wasi-http-incoming-handler.d.ts +0 -7
  10. package/types/imports/environment.d.ts +0 -17
  11. package/types/imports/exit.d.ts +0 -7
  12. package/types/imports/filesystem.d.ts +0 -857
  13. package/types/imports/handler.d.ts +0 -40
  14. package/types/imports/insecure-seed.d.ts +0 -22
  15. package/types/imports/insecure.d.ts +0 -20
  16. package/types/imports/instance-network.d.ts +0 -8
  17. package/types/imports/ip-name-lookup.d.ts +0 -76
  18. package/types/imports/monotonic-clock.d.ts +0 -24
  19. package/types/imports/network.d.ts +0 -212
  20. package/types/imports/outgoing-handler.d.ts +0 -9
  21. package/types/imports/poll.d.ts +0 -41
  22. package/types/imports/preopens.d.ts +0 -12
  23. package/types/imports/random.d.ts +0 -22
  24. package/types/imports/stderr.d.ts +0 -5
  25. package/types/imports/stdin.d.ts +0 -5
  26. package/types/imports/stdout.d.ts +0 -5
  27. package/types/imports/streams.d.ts +0 -180
  28. package/types/imports/tcp-create-socket.d.ts +0 -33
  29. package/types/imports/tcp.d.ts +0 -285
  30. package/types/imports/timezone.d.ts +0 -71
  31. package/types/imports/types.d.ts +0 -119
  32. package/types/imports/udp-create-socket.d.ts +0 -33
  33. package/types/imports/udp.d.ts +0 -219
  34. package/types/imports/wall-clock.d.ts +0 -31
  35. package/types/wasi-command.d.ts +0 -23
  36. package/types/wasi-proxy.d.ts +0 -10
  37. package/types/wasi-reactor.d.ts +0 -23
@@ -1,857 +0,0 @@
1
- export namespace ImportsFilesystem {
2
- /**
3
- * Return a stream for reading from a file.
4
- *
5
- * Multiple read, write, and append streams may be active on the same open
6
- * file and they do not interfere with each other.
7
- *
8
- * Note: This allows using `wasi:io/streams.read`, which is similar to `read` in POSIX.
9
- */
10
- export function readViaStream(this: Descriptor, offset: Filesize): InputStream;
11
- /**
12
- * Return a stream for writing to a file.
13
- *
14
- * Note: This allows using `wasi:io/streams.write`, which is similar to `write` in
15
- * POSIX.
16
- */
17
- export function writeViaStream(this: Descriptor, offset: Filesize): OutputStream;
18
- /**
19
- * Return a stream for appending to a file.
20
- *
21
- * Note: This allows using `wasi:io/streams.write`, which is similar to `write` with
22
- * `O_APPEND` in in POSIX.
23
- */
24
- export function appendViaStream(this: Descriptor): OutputStream;
25
- /**
26
- * Provide file advisory information on a descriptor.
27
- *
28
- * This is similar to `posix_fadvise` in POSIX.
29
- */
30
- export function advise(this: Descriptor, offset: Filesize, length: Filesize, advice: Advice): void;
31
- /**
32
- * Synchronize the data of a file to disk.
33
- *
34
- * This function succeeds with no effect if the file descriptor is not
35
- * opened for writing.
36
- *
37
- * Note: This is similar to `fdatasync` in POSIX.
38
- */
39
- export function syncData(this: Descriptor): void;
40
- /**
41
- * Get flags associated with a descriptor.
42
- *
43
- * Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
44
- *
45
- * Note: This returns the value that was the `fs_flags` value returned
46
- * from `fdstat_get` in earlier versions of WASI.
47
- */
48
- export function getFlags(this: Descriptor): DescriptorFlags;
49
- /**
50
- * Get the dynamic type of a descriptor.
51
- *
52
- * Note: This returns the same value as the `type` field of the `fd-stat`
53
- * returned by `stat`, `stat-at` and similar.
54
- *
55
- * Note: This returns similar flags to the `st_mode & S_IFMT` value provided
56
- * by `fstat` in POSIX.
57
- *
58
- * Note: This returns the value that was the `fs_filetype` value returned
59
- * from `fdstat_get` in earlier versions of WASI.
60
- */
61
- export function getType(this: Descriptor): DescriptorType;
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
- export function setSize(this: Descriptor, size: Filesize): void;
69
- /**
70
- * Adjust the timestamps of an open file or directory.
71
- *
72
- * Note: This is similar to `futimens` in POSIX.
73
- *
74
- * Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
75
- */
76
- export function setTimes(this: Descriptor, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
77
- /**
78
- * Read from a descriptor, without using and updating the descriptor's offset.
79
- *
80
- * This function returns a list of bytes containing the data that was
81
- * read, along with a bool which, when true, indicates that the end of the
82
- * file was reached. The returned list will contain up to `length` bytes; it
83
- * may return fewer than requested, if the end of the file is reached or
84
- * if the I/O operation is interrupted.
85
- *
86
- * In the future, this may change to return a `stream<u8, error-code>`.
87
- *
88
- * Note: This is similar to `pread` in POSIX.
89
- */
90
- export function read(this: Descriptor, length: Filesize, offset: Filesize): [Uint8Array | ArrayBuffer, boolean];
91
- /**
92
- * Write to a descriptor, without using and updating the descriptor's offset.
93
- *
94
- * It is valid to write past the end of a file; the file is extended to the
95
- * extent of the write, with bytes between the previous end and the start of
96
- * the write set to zero.
97
- *
98
- * In the future, this may change to take a `stream<u8, error-code>`.
99
- *
100
- * Note: This is similar to `pwrite` in POSIX.
101
- */
102
- export function write(this: Descriptor, buffer: Uint8Array, offset: Filesize): Filesize;
103
- /**
104
- * Read directory entries from a directory.
105
- *
106
- * On filesystems where directories contain entries referring to themselves
107
- * and their parents, often named `.` and `..` respectively, these entries
108
- * are omitted.
109
- *
110
- * This always returns a new stream which starts at the beginning of the
111
- * directory. Multiple streams may be active on the same directory, and they
112
- * do not interfere with each other.
113
- */
114
- export function readDirectory(this: Descriptor): DirectoryEntryStream;
115
- /**
116
- * Synchronize the data and metadata of a file to disk.
117
- *
118
- * This function succeeds with no effect if the file descriptor is not
119
- * opened for writing.
120
- *
121
- * Note: This is similar to `fsync` in POSIX.
122
- */
123
- export function sync(this: Descriptor): void;
124
- /**
125
- * Create a directory.
126
- *
127
- * Note: This is similar to `mkdirat` in POSIX.
128
- */
129
- export function createDirectoryAt(this: Descriptor, path: string): void;
130
- /**
131
- * Return the attributes of an open file or directory.
132
- *
133
- * Note: This is similar to `fstat` in POSIX.
134
- *
135
- * Note: This was called `fd_filestat_get` in earlier versions of WASI.
136
- */
137
- export function stat(this: Descriptor): DescriptorStat;
138
- /**
139
- * Return the attributes of a file or directory.
140
- *
141
- * Note: This is similar to `fstatat` in POSIX.
142
- *
143
- * Note: This was called `path_filestat_get` in earlier versions of WASI.
144
- */
145
- export function statAt(this: Descriptor, pathFlags: PathFlags, path: string): DescriptorStat;
146
- /**
147
- * Adjust the timestamps of a file or directory.
148
- *
149
- * Note: This is similar to `utimensat` in POSIX.
150
- *
151
- * Note: This was called `path_filestat_set_times` in earlier versions of
152
- * WASI.
153
- */
154
- export function setTimesAt(this: Descriptor, pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
155
- /**
156
- * Create a hard link.
157
- *
158
- * Note: This is similar to `linkat` in POSIX.
159
- */
160
- export function linkAt(this: Descriptor, oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
161
- /**
162
- * Open a file or directory.
163
- *
164
- * The returned descriptor is not guaranteed to be the lowest-numbered
165
- * descriptor not currently open/ it is randomized to prevent applications
166
- * from depending on making assumptions about indexes, since this is
167
- * error-prone in multi-threaded contexts. The returned descriptor is
168
- * guaranteed to be less than 2**31.
169
- *
170
- * If `flags` contains `descriptor-flags::mutate-directory`, and the base
171
- * descriptor doesn't have `descriptor-flags::mutate-directory` set,
172
- * `open-at` fails with `error-code::read-only`.
173
- *
174
- * If `flags` contains `write` or `mutate-directory`, or `open-flags`
175
- * contains `truncate` or `create`, and the base descriptor doesn't have
176
- * `descriptor-flags::mutate-directory` set, `open-at` fails with
177
- * `error-code::read-only`.
178
- *
179
- * Note: This is similar to `openat` in POSIX.
180
- */
181
- export function openAt(this: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
182
- /**
183
- * Read the contents of a symbolic link.
184
- *
185
- * If the contents contain an absolute or rooted path in the underlying
186
- * filesystem, this function fails with `error-code::not-permitted`.
187
- *
188
- * Note: This is similar to `readlinkat` in POSIX.
189
- */
190
- export function readlinkAt(this: Descriptor, path: string): string;
191
- /**
192
- * Remove a directory.
193
- *
194
- * Return `error-code::not-empty` if the directory is not empty.
195
- *
196
- * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
197
- */
198
- export function removeDirectoryAt(this: Descriptor, path: string): void;
199
- /**
200
- * Rename a filesystem object.
201
- *
202
- * Note: This is similar to `renameat` in POSIX.
203
- */
204
- export function renameAt(this: Descriptor, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
205
- /**
206
- * Create a symbolic link (also known as a "symlink").
207
- *
208
- * If `old-path` starts with `/`, the function fails with
209
- * `error-code::not-permitted`.
210
- *
211
- * Note: This is similar to `symlinkat` in POSIX.
212
- */
213
- export function symlinkAt(this: Descriptor, oldPath: string, newPath: string): void;
214
- /**
215
- * Check accessibility of a filesystem path.
216
- *
217
- * Check whether the given filesystem path names an object which is
218
- * readable, writable, or executable, or whether it exists.
219
- *
220
- * This does not a guarantee that subsequent accesses will succeed, as
221
- * filesystem permissions may be modified asynchronously by external
222
- * entities.
223
- *
224
- * Note: This is similar to `faccessat` with the `AT_EACCESS` flag in POSIX.
225
- */
226
- export function accessAt(this: Descriptor, pathFlags: PathFlags, path: string, type: AccessType): void;
227
- /**
228
- * Unlink a filesystem object that is not a directory.
229
- *
230
- * Return `error-code::is-directory` if the path refers to a directory.
231
- * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
232
- */
233
- export function unlinkFileAt(this: Descriptor, path: string): void;
234
- /**
235
- * Change the permissions of a filesystem object that is not a directory.
236
- *
237
- * Note that the ultimate meanings of these permissions is
238
- * filesystem-specific.
239
- *
240
- * Note: This is similar to `fchmodat` in POSIX.
241
- */
242
- export function changeFilePermissionsAt(this: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
243
- /**
244
- * Change the permissions of a directory.
245
- *
246
- * Note that the ultimate meanings of these permissions is
247
- * filesystem-specific.
248
- *
249
- * Unlike in POSIX, the `executable` flag is not reinterpreted as a "search"
250
- * flag. `read` on a directory implies readability and searchability, and
251
- * `execute` is not valid for directories.
252
- *
253
- * Note: This is similar to `fchmodat` in POSIX.
254
- */
255
- export function changeDirectoryPermissionsAt(this: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
256
- /**
257
- * Request a shared advisory lock for an open file.
258
- *
259
- * This requests a *shared* lock; more than one shared lock can be held for
260
- * a file at the same time.
261
- *
262
- * If the open file has an exclusive lock, this function downgrades the lock
263
- * to a shared lock. If it has a shared lock, this function has no effect.
264
- *
265
- * This requests an *advisory* lock, meaning that the file could be accessed
266
- * by other programs that don't hold the lock.
267
- *
268
- * It is unspecified how shared locks interact with locks acquired by
269
- * non-WASI programs.
270
- *
271
- * This function blocks until the lock can be acquired.
272
- *
273
- * Not all filesystems support locking; on filesystems which don't support
274
- * locking, this function returns `error-code::unsupported`.
275
- *
276
- * Note: This is similar to `flock(fd, LOCK_SH)` in Unix.
277
- */
278
- export function lockShared(this: Descriptor): void;
279
- /**
280
- * Request an exclusive advisory lock for an open file.
281
- *
282
- * This requests an *exclusive* lock; no other locks may be held for the
283
- * file while an exclusive lock is held.
284
- *
285
- * If the open file has a shared lock and there are no exclusive locks held
286
- * for the file, this function upgrades the lock to an exclusive lock. If the
287
- * open file already has an exclusive lock, this function has no effect.
288
- *
289
- * This requests an *advisory* lock, meaning that the file could be accessed
290
- * by other programs that don't hold the lock.
291
- *
292
- * It is unspecified whether this function succeeds if the file descriptor
293
- * is not opened for writing. It is unspecified how exclusive locks interact
294
- * with locks acquired by non-WASI programs.
295
- *
296
- * This function blocks until the lock can be acquired.
297
- *
298
- * Not all filesystems support locking; on filesystems which don't support
299
- * locking, this function returns `error-code::unsupported`.
300
- *
301
- * Note: This is similar to `flock(fd, LOCK_EX)` in Unix.
302
- */
303
- export function lockExclusive(this: Descriptor): void;
304
- /**
305
- * Request a shared advisory lock for an open file.
306
- *
307
- * This requests a *shared* lock; more than one shared lock can be held for
308
- * a file at the same time.
309
- *
310
- * If the open file has an exclusive lock, this function downgrades the lock
311
- * to a shared lock. If it has a shared lock, this function has no effect.
312
- *
313
- * This requests an *advisory* lock, meaning that the file could be accessed
314
- * by other programs that don't hold the lock.
315
- *
316
- * It is unspecified how shared locks interact with locks acquired by
317
- * non-WASI programs.
318
- *
319
- * This function returns `error-code::would-block` if the lock cannot be
320
- * acquired.
321
- *
322
- * Not all filesystems support locking; on filesystems which don't support
323
- * locking, this function returns `error-code::unsupported`.
324
- *
325
- * Note: This is similar to `flock(fd, LOCK_SH | LOCK_NB)` in Unix.
326
- */
327
- export function tryLockShared(this: Descriptor): void;
328
- /**
329
- * Request an exclusive advisory lock for an open file.
330
- *
331
- * This requests an *exclusive* lock; no other locks may be held for the
332
- * file while an exclusive lock is held.
333
- *
334
- * If the open file has a shared lock and there are no exclusive locks held
335
- * for the file, this function upgrades the lock to an exclusive lock. If the
336
- * open file already has an exclusive lock, this function has no effect.
337
- *
338
- * This requests an *advisory* lock, meaning that the file could be accessed
339
- * by other programs that don't hold the lock.
340
- *
341
- * It is unspecified whether this function succeeds if the file descriptor
342
- * is not opened for writing. It is unspecified how exclusive locks interact
343
- * with locks acquired by non-WASI programs.
344
- *
345
- * This function returns `error-code::would-block` if the lock cannot be
346
- * acquired.
347
- *
348
- * Not all filesystems support locking; on filesystems which don't support
349
- * locking, this function returns `error-code::unsupported`.
350
- *
351
- * Note: This is similar to `flock(fd, LOCK_EX | LOCK_NB)` in Unix.
352
- */
353
- export function tryLockExclusive(this: Descriptor): void;
354
- /**
355
- * Release a shared or exclusive lock on an open file.
356
- *
357
- * Note: This is similar to `flock(fd, LOCK_UN)` in Unix.
358
- */
359
- export function unlock(this: Descriptor): void;
360
- /**
361
- * Dispose of the specified `descriptor`, after which it may no longer
362
- * be used.
363
- */
364
- export function dropDescriptor(this: Descriptor): void;
365
- /**
366
- * Read a single directory entry from a `directory-entry-stream`.
367
- */
368
- export function readDirectoryEntry(this: DirectoryEntryStream): DirectoryEntry | null;
369
- /**
370
- * Dispose of the specified `directory-entry-stream`, after which it may no longer
371
- * be used.
372
- */
373
- export function dropDirectoryEntryStream(this: DirectoryEntryStream): void;
374
- }
375
- import type { InputStream } from '../imports/streams';
376
- export { InputStream };
377
- import type { OutputStream } from '../imports/streams';
378
- export { OutputStream };
379
- import type { Datetime } from '../imports/wall-clock';
380
- export { Datetime };
381
- /**
382
- * Flags determining the method of how paths are resolved.
383
- */
384
- export interface PathFlags {
385
- /**
386
- * As long as the resolved path corresponds to a symbolic link, it is
387
- * expanded.
388
- */
389
- symlinkFollow?: boolean,
390
- }
391
- /**
392
- * Open flags used by `open-at`.
393
- */
394
- export interface OpenFlags {
395
- /**
396
- * Create file if it does not exist, similar to `O_CREAT` in POSIX.
397
- */
398
- create?: boolean,
399
- /**
400
- * Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
401
- */
402
- directory?: boolean,
403
- /**
404
- * Fail if file already exists, similar to `O_EXCL` in POSIX.
405
- */
406
- exclusive?: boolean,
407
- /**
408
- * Truncate file to size 0, similar to `O_TRUNC` in POSIX.
409
- */
410
- truncate?: boolean,
411
- }
412
- /**
413
- * Permissions mode used by `open-at`, `change-file-permissions-at`, and
414
- * similar.
415
- */
416
- export interface Modes {
417
- /**
418
- * True if the resource is considered readable by the containing
419
- * filesystem.
420
- */
421
- readable?: boolean,
422
- /**
423
- * True if the resource is considered writable by the containing
424
- * filesystem.
425
- */
426
- writable?: boolean,
427
- /**
428
- * True if the resource is considered executable by the containing
429
- * filesystem. This does not apply to directories.
430
- */
431
- executable?: boolean,
432
- }
433
- /**
434
- * Number of hard links to an inode.
435
- */
436
- export type LinkCount = bigint;
437
- /**
438
- * Filesystem object serial number that is unique within its file system.
439
- */
440
- export type Inode = bigint;
441
- /**
442
- * File size or length of a region within a file.
443
- */
444
- export type Filesize = bigint;
445
- /**
446
- * Error codes returned by functions, similar to `errno` in POSIX.
447
- * Not all of these error codes are returned by the functions provided by this
448
- * API; some are used in higher-level library layers, and others are provided
449
- * merely for alignment with POSIX.
450
- *
451
- * # Variants
452
- *
453
- * ## `"access"`
454
- *
455
- * Permission denied, similar to `EACCES` in POSIX.
456
- *
457
- * ## `"would-block"`
458
- *
459
- * Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
460
- *
461
- * ## `"already"`
462
- *
463
- * Connection already in progress, similar to `EALREADY` in POSIX.
464
- *
465
- * ## `"bad-descriptor"`
466
- *
467
- * Bad descriptor, similar to `EBADF` in POSIX.
468
- *
469
- * ## `"busy"`
470
- *
471
- * Device or resource busy, similar to `EBUSY` in POSIX.
472
- *
473
- * ## `"deadlock"`
474
- *
475
- * Resource deadlock would occur, similar to `EDEADLK` in POSIX.
476
- *
477
- * ## `"quota"`
478
- *
479
- * Storage quota exceeded, similar to `EDQUOT` in POSIX.
480
- *
481
- * ## `"exist"`
482
- *
483
- * File exists, similar to `EEXIST` in POSIX.
484
- *
485
- * ## `"file-too-large"`
486
- *
487
- * File too large, similar to `EFBIG` in POSIX.
488
- *
489
- * ## `"illegal-byte-sequence"`
490
- *
491
- * Illegal byte sequence, similar to `EILSEQ` in POSIX.
492
- *
493
- * ## `"in-progress"`
494
- *
495
- * Operation in progress, similar to `EINPROGRESS` in POSIX.
496
- *
497
- * ## `"interrupted"`
498
- *
499
- * Interrupted function, similar to `EINTR` in POSIX.
500
- *
501
- * ## `"invalid"`
502
- *
503
- * Invalid argument, similar to `EINVAL` in POSIX.
504
- *
505
- * ## `"io"`
506
- *
507
- * I/O error, similar to `EIO` in POSIX.
508
- *
509
- * ## `"is-directory"`
510
- *
511
- * Is a directory, similar to `EISDIR` in POSIX.
512
- *
513
- * ## `"loop"`
514
- *
515
- * Too many levels of symbolic links, similar to `ELOOP` in POSIX.
516
- *
517
- * ## `"too-many-links"`
518
- *
519
- * Too many links, similar to `EMLINK` in POSIX.
520
- *
521
- * ## `"message-size"`
522
- *
523
- * Message too large, similar to `EMSGSIZE` in POSIX.
524
- *
525
- * ## `"name-too-long"`
526
- *
527
- * Filename too long, similar to `ENAMETOOLONG` in POSIX.
528
- *
529
- * ## `"no-device"`
530
- *
531
- * No such device, similar to `ENODEV` in POSIX.
532
- *
533
- * ## `"no-entry"`
534
- *
535
- * No such file or directory, similar to `ENOENT` in POSIX.
536
- *
537
- * ## `"no-lock"`
538
- *
539
- * No locks available, similar to `ENOLCK` in POSIX.
540
- *
541
- * ## `"insufficient-memory"`
542
- *
543
- * Not enough space, similar to `ENOMEM` in POSIX.
544
- *
545
- * ## `"insufficient-space"`
546
- *
547
- * No space left on device, similar to `ENOSPC` in POSIX.
548
- *
549
- * ## `"not-directory"`
550
- *
551
- * Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
552
- *
553
- * ## `"not-empty"`
554
- *
555
- * Directory not empty, similar to `ENOTEMPTY` in POSIX.
556
- *
557
- * ## `"not-recoverable"`
558
- *
559
- * State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
560
- *
561
- * ## `"unsupported"`
562
- *
563
- * Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
564
- *
565
- * ## `"no-tty"`
566
- *
567
- * Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
568
- *
569
- * ## `"no-such-device"`
570
- *
571
- * No such device or address, similar to `ENXIO` in POSIX.
572
- *
573
- * ## `"overflow"`
574
- *
575
- * Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
576
- *
577
- * ## `"not-permitted"`
578
- *
579
- * Operation not permitted, similar to `EPERM` in POSIX.
580
- *
581
- * ## `"pipe"`
582
- *
583
- * Broken pipe, similar to `EPIPE` in POSIX.
584
- *
585
- * ## `"read-only"`
586
- *
587
- * Read-only file system, similar to `EROFS` in POSIX.
588
- *
589
- * ## `"invalid-seek"`
590
- *
591
- * Invalid seek, similar to `ESPIPE` in POSIX.
592
- *
593
- * ## `"text-file-busy"`
594
- *
595
- * Text file busy, similar to `ETXTBSY` in POSIX.
596
- *
597
- * ## `"cross-device"`
598
- *
599
- * Cross-device link, similar to `EXDEV` in POSIX.
600
- */
601
- export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
602
- /**
603
- * A stream of directory entries.
604
- *
605
- * This [represents a stream of `dir-entry`](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Streams).
606
- */
607
- export type DirectoryEntryStream = number;
608
- /**
609
- * Identifier for a device containing a file system. Can be used in
610
- * combination with `inode` to uniquely identify a file or directory in
611
- * the filesystem.
612
- */
613
- export type Device = bigint;
614
- /**
615
- * The type of a filesystem object referenced by a descriptor.
616
- *
617
- * Note: This was called `filetype` in earlier versions of WASI.
618
- *
619
- * # Variants
620
- *
621
- * ## `"unknown"`
622
- *
623
- * The type of the descriptor or file is unknown or is different from
624
- * any of the other types specified.
625
- *
626
- * ## `"block-device"`
627
- *
628
- * The descriptor refers to a block device inode.
629
- *
630
- * ## `"character-device"`
631
- *
632
- * The descriptor refers to a character device inode.
633
- *
634
- * ## `"directory"`
635
- *
636
- * The descriptor refers to a directory inode.
637
- *
638
- * ## `"fifo"`
639
- *
640
- * The descriptor refers to a named pipe.
641
- *
642
- * ## `"symbolic-link"`
643
- *
644
- * The file refers to a symbolic link inode.
645
- *
646
- * ## `"regular-file"`
647
- *
648
- * The descriptor refers to a regular file inode.
649
- *
650
- * ## `"socket"`
651
- *
652
- * The descriptor refers to a socket.
653
- */
654
- export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
655
- /**
656
- * A directory entry.
657
- */
658
- export interface DirectoryEntry {
659
- /**
660
- * The serial number of the object referred to by this directory entry.
661
- * May be none if the inode value is not known.
662
- *
663
- * When this is none, libc implementations might do an extra `stat-at`
664
- * call to retrieve the inode number to fill their `d_ino` fields, so
665
- * implementations which can set this to a non-none value should do so.
666
- */
667
- inode?: Inode,
668
- /**
669
- * The type of the file referred to by this directory entry.
670
- */
671
- type: DescriptorType,
672
- /**
673
- * The name of the object.
674
- */
675
- name: string,
676
- }
677
- /**
678
- * Descriptor flags.
679
- *
680
- * Note: This was called `fdflags` in earlier versions of WASI.
681
- */
682
- export interface DescriptorFlags {
683
- /**
684
- * Read mode: Data can be read.
685
- */
686
- read?: boolean,
687
- /**
688
- * Write mode: Data can be written to.
689
- */
690
- write?: boolean,
691
- /**
692
- * Request that writes be performed according to synchronized I/O file
693
- * integrity completion. The data stored in the file and the file's
694
- * metadata are synchronized. This is similar to `O_SYNC` in POSIX.
695
- *
696
- * The precise semantics of this operation have not yet been defined for
697
- * WASI. At this time, it should be interpreted as a request, and not a
698
- * requirement.
699
- */
700
- fileIntegritySync?: boolean,
701
- /**
702
- * Request that writes be performed according to synchronized I/O data
703
- * integrity completion. Only the data stored in the file is
704
- * synchronized. This is similar to `O_DSYNC` in POSIX.
705
- *
706
- * The precise semantics of this operation have not yet been defined for
707
- * WASI. At this time, it should be interpreted as a request, and not a
708
- * requirement.
709
- */
710
- dataIntegritySync?: boolean,
711
- /**
712
- * Requests that reads be performed at the same level of integrety
713
- * requested for writes. This is similar to `O_RSYNC` in POSIX.
714
- *
715
- * The precise semantics of this operation have not yet been defined for
716
- * WASI. At this time, it should be interpreted as a request, and not a
717
- * requirement.
718
- */
719
- requestedWriteSync?: boolean,
720
- /**
721
- * Mutating directories mode: Directory contents may be mutated.
722
- *
723
- * When this flag is unset on a descriptor, operations using the
724
- * descriptor which would create, rename, delete, modify the data or
725
- * metadata of filesystem objects, or obtain another handle which
726
- * would permit any of those, shall fail with `error-code::read-only` if
727
- * they would otherwise succeed.
728
- *
729
- * This may only be set on directories.
730
- */
731
- mutateDirectory?: boolean,
732
- }
733
- /**
734
- * A descriptor is a reference to a filesystem object, which may be a file,
735
- * directory, named pipe, special file, or other object on which filesystem
736
- * calls may be made.
737
- *
738
- * This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
739
- */
740
- export type Descriptor = number;
741
- /**
742
- * When setting a timestamp, this gives the value to set it to.
743
- */
744
- export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
745
- /**
746
- * Leave the timestamp set to its previous value.
747
- */
748
- export interface NewTimestampNoChange {
749
- tag: 'no-change',
750
- }
751
- /**
752
- * Set the timestamp to the current time of the system clock associated
753
- * with the filesystem.
754
- */
755
- export interface NewTimestampNow {
756
- tag: 'now',
757
- }
758
- /**
759
- * Set the timestamp to the given value.
760
- */
761
- export interface NewTimestampTimestamp {
762
- tag: 'timestamp',
763
- val: Datetime,
764
- }
765
- /**
766
- * File attributes.
767
- *
768
- * Note: This was called `filestat` in earlier versions of WASI.
769
- */
770
- export interface DescriptorStat {
771
- /**
772
- * Device ID of device containing the file.
773
- */
774
- device: Device,
775
- /**
776
- * File serial number.
777
- */
778
- inode: Inode,
779
- /**
780
- * File type.
781
- */
782
- type: DescriptorType,
783
- /**
784
- * Number of hard links to the file.
785
- */
786
- linkCount: LinkCount,
787
- /**
788
- * For regular files, the file size in bytes. For symbolic links, the
789
- * length in bytes of the pathname contained in the symbolic link.
790
- */
791
- size: Filesize,
792
- /**
793
- * Last data access timestamp.
794
- */
795
- dataAccessTimestamp: Datetime,
796
- /**
797
- * Last data modification timestamp.
798
- */
799
- dataModificationTimestamp: Datetime,
800
- /**
801
- * Last file status change timestamp.
802
- */
803
- statusChangeTimestamp: Datetime,
804
- }
805
- /**
806
- * File or memory access pattern advisory information.
807
- *
808
- * # Variants
809
- *
810
- * ## `"normal"`
811
- *
812
- * The application has no advice to give on its behavior with respect
813
- * to the specified data.
814
- *
815
- * ## `"sequential"`
816
- *
817
- * The application expects to access the specified data sequentially
818
- * from lower offsets to higher offsets.
819
- *
820
- * ## `"random"`
821
- *
822
- * The application expects to access the specified data in a random
823
- * order.
824
- *
825
- * ## `"will-need"`
826
- *
827
- * The application expects to access the specified data in the near
828
- * future.
829
- *
830
- * ## `"dont-need"`
831
- *
832
- * The application expects that it will not access the specified data
833
- * in the near future.
834
- *
835
- * ## `"no-reuse"`
836
- *
837
- * The application expects to access the specified data once and then
838
- * not reuse it thereafter.
839
- */
840
- export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
841
- /**
842
- * Access type used by `access-at`.
843
- */
844
- export type AccessType = AccessTypeAccess | AccessTypeExists;
845
- /**
846
- * Test for readability, writeability, or executability.
847
- */
848
- export interface AccessTypeAccess {
849
- tag: 'access',
850
- val: Modes,
851
- }
852
- /**
853
- * Test whether the path exists.
854
- */
855
- export interface AccessTypeExists {
856
- tag: 'exists',
857
- }