@bytecodealliance/preview3-shim 0.1.1 → 0.2.0
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/dist/nodejs/cli.d.ts +51 -0
- package/dist/nodejs/cli.js +106 -0
- package/dist/nodejs/clocks.d.ts +55 -0
- package/dist/nodejs/clocks.js +83 -0
- package/dist/nodejs/filesystem/descriptor.d.ts +443 -0
- package/dist/nodejs/filesystem/descriptor.js +1010 -0
- package/dist/nodejs/filesystem/error.d.ts +61 -0
- package/dist/nodejs/filesystem/error.js +86 -0
- package/dist/nodejs/filesystem/utils.d.ts +8 -0
- package/dist/nodejs/filesystem/utils.js +25 -0
- package/dist/nodejs/filesystem.js +2 -0
- package/dist/nodejs/finalization.d.ts +2 -0
- package/{lib → dist}/nodejs/finalization.js +15 -21
- package/dist/nodejs/future.d.ts +98 -0
- package/dist/nodejs/future.js +176 -0
- package/dist/nodejs/http/client.d.ts +22 -0
- package/dist/nodejs/http/client.js +138 -0
- package/dist/nodejs/http/error.d.ts +18 -0
- package/dist/nodejs/http/error.js +62 -0
- package/dist/nodejs/http/fields.d.ts +144 -0
- package/dist/nodejs/http/fields.js +327 -0
- package/dist/nodejs/http/request.d.ts +256 -0
- package/dist/nodejs/http/request.js +606 -0
- package/dist/nodejs/http/response.d.ts +82 -0
- package/dist/nodejs/http/response.js +202 -0
- package/dist/nodejs/http/server.d.ts +13 -0
- package/dist/nodejs/http/server.js +127 -0
- package/dist/nodejs/http.d.ts +19 -0
- package/{lib → dist}/nodejs/http.js +13 -18
- package/dist/nodejs/index.js +8 -0
- package/dist/nodejs/random.d.ts +5 -0
- package/{lib → dist}/nodejs/random.js +2 -8
- package/dist/nodejs/sockets/address.d.ts +78 -0
- package/dist/nodejs/sockets/address.js +120 -0
- package/dist/nodejs/sockets/error.d.ts +83 -0
- package/dist/nodejs/sockets/error.js +120 -0
- package/dist/nodejs/sockets/ip-name-lookup.d.ts +18 -0
- package/dist/nodejs/sockets/ip-name-lookup.js +84 -0
- package/dist/nodejs/sockets/tcp.d.ts +333 -0
- package/dist/nodejs/sockets/tcp.js +723 -0
- package/dist/nodejs/sockets/udp.d.ts +224 -0
- package/dist/nodejs/sockets/udp.js +475 -0
- package/dist/nodejs/sockets.d.ts +11 -0
- package/{lib → dist}/nodejs/sockets.js +2 -5
- package/dist/nodejs/stream.d.ts +161 -0
- package/dist/nodejs/stream.js +388 -0
- package/dist/nodejs/workers/cli-worker.d.ts +1 -0
- package/dist/nodejs/workers/cli-worker.js +41 -0
- package/dist/nodejs/workers/filesystem-worker.d.ts +1 -0
- package/dist/nodejs/workers/filesystem-worker.js +102 -0
- package/dist/nodejs/workers/http-worker.d.ts +1 -0
- package/dist/nodejs/workers/http-worker.js +355 -0
- package/dist/nodejs/workers/resource-worker.d.ts +13 -0
- package/dist/nodejs/workers/resource-worker.js +152 -0
- package/dist/nodejs/workers/tcp-worker.d.ts +2 -0
- package/dist/nodejs/workers/tcp-worker.js +318 -0
- package/dist/nodejs/workers/udp-worker.d.ts +1 -0
- package/dist/nodejs/workers/udp-worker.js +156 -0
- package/package.json +20 -12
- package/types/interfaces/wasi-cli-environment.d.ts +3 -3
- package/types/interfaces/wasi-cli-exit.d.ts +12 -1
- package/types/interfaces/wasi-cli-run.d.ts +1 -1
- package/types/interfaces/wasi-cli-stderr.d.ts +3 -3
- package/types/interfaces/wasi-cli-stdin.d.ts +5 -5
- package/types/interfaces/wasi-cli-stdout.d.ts +3 -3
- package/types/interfaces/wasi-cli-terminal-input.d.ts +1 -1
- package/types/interfaces/wasi-cli-terminal-output.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-cli-types.d.ts +5 -5
- package/types/interfaces/wasi-clocks-monotonic-clock.d.ts +3 -3
- package/types/interfaces/wasi-clocks-system-clock.d.ts +6 -6
- package/types/interfaces/wasi-clocks-types.d.ts +1 -1
- package/types/interfaces/wasi-filesystem-preopens.d.ts +1 -1
- package/types/interfaces/wasi-filesystem-types.d.ts +74 -74
- package/types/interfaces/wasi-http-client.d.ts +1 -1
- package/types/interfaces/wasi-http-handler.d.ts +1 -1
- package/types/interfaces/wasi-http-types.d.ts +34 -34
- package/types/interfaces/wasi-random-insecure-seed.d.ts +5 -5
- package/types/interfaces/wasi-random-insecure.d.ts +5 -5
- package/types/interfaces/wasi-random-random.d.ts +5 -5
- package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +11 -11
- package/types/interfaces/wasi-sockets-types.d.ts +121 -121
- package/types/wasi-cli-command.d.ts +23 -23
- package/types/wasi-http-service.d.ts +14 -14
- package/lib/nodejs/cli.js +0 -127
- package/lib/nodejs/clocks.js +0 -100
- package/lib/nodejs/filesystem/descriptor.js +0 -1093
- package/lib/nodejs/filesystem/error.js +0 -92
- package/lib/nodejs/filesystem/utils.js +0 -19
- package/lib/nodejs/future.js +0 -190
- package/lib/nodejs/http/client.js +0 -161
- package/lib/nodejs/http/error.js +0 -71
- package/lib/nodejs/http/fields.js +0 -373
- package/lib/nodejs/http/request.js +0 -691
- package/lib/nodejs/http/response.js +0 -227
- package/lib/nodejs/http/server.js +0 -157
- package/lib/nodejs/sockets/address.js +0 -146
- package/lib/nodejs/sockets/error.js +0 -123
- package/lib/nodejs/sockets/ip-name-lookup.js +0 -93
- package/lib/nodejs/sockets/tcp.js +0 -801
- package/lib/nodejs/sockets/udp.js +0 -516
- package/lib/nodejs/stream.js +0 -437
- package/lib/nodejs/workers/cli-worker.js +0 -49
- package/lib/nodejs/workers/filesystem-worker.js +0 -119
- package/lib/nodejs/workers/http-worker.js +0 -417
- package/lib/nodejs/workers/resource-worker.js +0 -195
- package/lib/nodejs/workers/tcp-worker.js +0 -370
- package/lib/nodejs/workers/udp-worker.js +0 -194
- /package/{lib/nodejs/filesystem.js → dist/nodejs/filesystem.d.ts} +0 -0
- /package/{lib/nodejs/index.js → dist/nodejs/index.d.ts} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/** @module Interface wasi:cli/types@0.3.0
|
|
1
|
+
/** @module Interface wasi:cli/types@0.3.0 **/
|
|
2
2
|
/**
|
|
3
3
|
* # Variants
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* ## `"io"`
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* Input/output error
|
|
8
8
|
* ## `"illegal-byte-sequence"`
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* Invalid or incomplete multibyte or wide character
|
|
11
11
|
* ## `"pipe"`
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* Broken pipe
|
|
14
14
|
*/
|
|
15
15
|
export type ErrorCode = 'io' | 'illegal-byte-sequence' | 'pipe';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @module Interface wasi:clocks/monotonic-clock@0.3.0
|
|
1
|
+
/** @module Interface wasi:clocks/monotonic-clock@0.3.0 **/
|
|
2
2
|
/**
|
|
3
3
|
* Read the current value of the clock.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* The clock is monotonic, therefore calling this function repeatedly will
|
|
6
6
|
* produce a sequence of non-decreasing values.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
* For completeness, this function traps if it's not possible to represent
|
|
9
9
|
* the value of the clock in a `mark`. Consequently, implementations
|
|
10
10
|
* should ensure that the starting time is low enough to avoid the
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @module Interface wasi:clocks/system-clock@0.3.0
|
|
1
|
+
/** @module Interface wasi:clocks/system-clock@0.3.0 **/
|
|
2
2
|
/**
|
|
3
3
|
* Read the current value of the clock.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* This clock is not monotonic, therefore calling this function repeatedly
|
|
6
6
|
* will not necessarily produce a sequence of non-decreasing values.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
* The nanoseconds field of the output is always less than 1000000000.
|
|
9
9
|
*/
|
|
10
10
|
export function now(): Instant;
|
|
@@ -18,17 +18,17 @@ export type Duration = import('./wasi-clocks-types.js').Duration;
|
|
|
18
18
|
* An "instant", or "exact time", is a point in time without regard to any
|
|
19
19
|
* time zone: just the time since a particular external reference point,
|
|
20
20
|
* often called an "epoch".
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
22
|
* Here, the epoch is 1970-01-01T00:00:00Z, also known as
|
|
23
23
|
* [POSIX's Seconds Since the Epoch], also known as [Unix Time].
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* Note that even if the seconds field is negative, incrementing
|
|
26
26
|
* nanoseconds always represents moving forwards in time.
|
|
27
27
|
* For example, `{ -1 seconds, 999999999 nanoseconds }` represents the
|
|
28
28
|
* instant one nanosecond before the epoch.
|
|
29
29
|
* For more on various different ways to represent time, see
|
|
30
30
|
* https://tc39.es/proposal-temporal/docs/timezone.html
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
32
|
* [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
|
|
33
33
|
* [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
|
|
34
34
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module Interface wasi:filesystem/types@0.3.0
|
|
1
|
+
/** @module Interface wasi:filesystem/types@0.3.0 **/
|
|
2
2
|
export type Instant = import('./wasi-clocks-system-clock.js').Instant;
|
|
3
3
|
/**
|
|
4
4
|
* File size or length of a region within a file.
|
|
@@ -6,7 +6,7 @@ export type Instant = import('./wasi-clocks-system-clock.js').Instant;
|
|
|
6
6
|
export type Filesize = bigint;
|
|
7
7
|
/**
|
|
8
8
|
* The type of a filesystem object referenced by a descriptor.
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* Note: This was called `filetype` in earlier versions of WASI.
|
|
11
11
|
*/
|
|
12
12
|
export type DescriptorType = DescriptorTypeBlockDevice | DescriptorTypeCharacterDevice | DescriptorTypeDirectory | DescriptorTypeFifo | DescriptorTypeSymbolicLink | DescriptorTypeRegularFile | DescriptorTypeSocket | DescriptorTypeOther;
|
|
@@ -62,7 +62,7 @@ export interface DescriptorTypeOther {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Descriptor flags.
|
|
65
|
-
*
|
|
65
|
+
*
|
|
66
66
|
* Note: This was called `fdflags` in earlier versions of WASI.
|
|
67
67
|
*/
|
|
68
68
|
export interface DescriptorFlags {
|
|
@@ -78,7 +78,7 @@ export interface DescriptorFlags {
|
|
|
78
78
|
* Request that writes be performed according to synchronized I/O file
|
|
79
79
|
* integrity completion. The data stored in the file and the file's
|
|
80
80
|
* metadata are synchronized. This is similar to `O_SYNC` in POSIX.
|
|
81
|
-
*
|
|
81
|
+
*
|
|
82
82
|
* The precise semantics of this operation have not yet been defined for
|
|
83
83
|
* WASI. At this time, it should be interpreted as a request, and not a
|
|
84
84
|
* requirement.
|
|
@@ -88,7 +88,7 @@ export interface DescriptorFlags {
|
|
|
88
88
|
* Request that writes be performed according to synchronized I/O data
|
|
89
89
|
* integrity completion. Only the data stored in the file is
|
|
90
90
|
* synchronized. This is similar to `O_DSYNC` in POSIX.
|
|
91
|
-
*
|
|
91
|
+
*
|
|
92
92
|
* The precise semantics of this operation have not yet been defined for
|
|
93
93
|
* WASI. At this time, it should be interpreted as a request, and not a
|
|
94
94
|
* requirement.
|
|
@@ -97,7 +97,7 @@ export interface DescriptorFlags {
|
|
|
97
97
|
/**
|
|
98
98
|
* Requests that reads be performed at the same level of integrity
|
|
99
99
|
* requested for writes. This is similar to `O_RSYNC` in POSIX.
|
|
100
|
-
*
|
|
100
|
+
*
|
|
101
101
|
* The precise semantics of this operation have not yet been defined for
|
|
102
102
|
* WASI. At this time, it should be interpreted as a request, and not a
|
|
103
103
|
* requirement.
|
|
@@ -105,13 +105,13 @@ export interface DescriptorFlags {
|
|
|
105
105
|
requestedWriteSync?: boolean,
|
|
106
106
|
/**
|
|
107
107
|
* Mutating directories mode: Directory contents may be mutated.
|
|
108
|
-
*
|
|
108
|
+
*
|
|
109
109
|
* When this flag is unset on a descriptor, operations using the
|
|
110
110
|
* descriptor which would create, rename, delete, modify the data or
|
|
111
111
|
* metadata of filesystem objects, or obtain another handle which
|
|
112
112
|
* would permit any of those, shall fail with `error-code::read-only` if
|
|
113
113
|
* they would otherwise succeed.
|
|
114
|
-
*
|
|
114
|
+
*
|
|
115
115
|
* This may only be set on directories.
|
|
116
116
|
*/
|
|
117
117
|
mutateDirectory?: boolean,
|
|
@@ -153,7 +153,7 @@ export interface OpenFlags {
|
|
|
153
153
|
export type LinkCount = bigint;
|
|
154
154
|
/**
|
|
155
155
|
* File attributes.
|
|
156
|
-
*
|
|
156
|
+
*
|
|
157
157
|
* Note: This was called `filestat` in earlier versions of WASI.
|
|
158
158
|
*/
|
|
159
159
|
export interface DescriptorStat {
|
|
@@ -172,21 +172,21 @@ export interface DescriptorStat {
|
|
|
172
172
|
size: Filesize,
|
|
173
173
|
/**
|
|
174
174
|
* Last data access timestamp.
|
|
175
|
-
*
|
|
175
|
+
*
|
|
176
176
|
* If the `option` is none, the platform doesn't maintain an access
|
|
177
177
|
* timestamp for this file.
|
|
178
178
|
*/
|
|
179
179
|
dataAccessTimestamp?: Instant,
|
|
180
180
|
/**
|
|
181
181
|
* Last data modification timestamp.
|
|
182
|
-
*
|
|
182
|
+
*
|
|
183
183
|
* If the `option` is none, the platform doesn't maintain a
|
|
184
184
|
* modification timestamp for this file.
|
|
185
185
|
*/
|
|
186
186
|
dataModificationTimestamp?: Instant,
|
|
187
187
|
/**
|
|
188
188
|
* Last file status-change timestamp.
|
|
189
|
-
*
|
|
189
|
+
*
|
|
190
190
|
* If the `option` is none, the platform doesn't maintain a
|
|
191
191
|
* status-change timestamp for this file.
|
|
192
192
|
*/
|
|
@@ -464,29 +464,29 @@ export interface ErrorCodeOther {
|
|
|
464
464
|
/**
|
|
465
465
|
* File or memory access pattern advisory information.
|
|
466
466
|
* # Variants
|
|
467
|
-
*
|
|
467
|
+
*
|
|
468
468
|
* ## `"normal"`
|
|
469
|
-
*
|
|
469
|
+
*
|
|
470
470
|
* The application has no advice to give on its behavior with respect
|
|
471
471
|
* to the specified data.
|
|
472
472
|
* ## `"sequential"`
|
|
473
|
-
*
|
|
473
|
+
*
|
|
474
474
|
* The application expects to access the specified data sequentially
|
|
475
475
|
* from lower offsets to higher offsets.
|
|
476
476
|
* ## `"random"`
|
|
477
|
-
*
|
|
477
|
+
*
|
|
478
478
|
* The application expects to access the specified data in a random
|
|
479
479
|
* order.
|
|
480
480
|
* ## `"will-need"`
|
|
481
|
-
*
|
|
481
|
+
*
|
|
482
482
|
* The application expects to access the specified data in the near
|
|
483
483
|
* future.
|
|
484
484
|
* ## `"dont-need"`
|
|
485
|
-
*
|
|
485
|
+
*
|
|
486
486
|
* The application expects that it will not access the specified data
|
|
487
487
|
* in the near future.
|
|
488
488
|
* ## `"no-reuse"`
|
|
489
|
-
*
|
|
489
|
+
*
|
|
490
490
|
* The application expects to access the specified data once and then
|
|
491
491
|
* not reuse it thereafter.
|
|
492
492
|
*/
|
|
@@ -514,82 +514,82 @@ export class Descriptor {
|
|
|
514
514
|
private constructor();
|
|
515
515
|
/**
|
|
516
516
|
* Return a stream for reading from a file.
|
|
517
|
-
*
|
|
517
|
+
*
|
|
518
518
|
* Multiple read, write, and append streams may be active on the same open
|
|
519
519
|
* file and they do not interfere with each other.
|
|
520
|
-
*
|
|
520
|
+
*
|
|
521
521
|
* This function returns a `stream` which provides the data received from the
|
|
522
522
|
* file, and a `future` providing additional error information in case an
|
|
523
523
|
* error is encountered.
|
|
524
|
-
*
|
|
524
|
+
*
|
|
525
525
|
* If no error is encountered, `stream.read` on the `stream` will return
|
|
526
526
|
* `read-status::closed` with no `error-context` and the future resolves to
|
|
527
527
|
* the value `ok`. If an error is encountered, `stream.read` on the
|
|
528
528
|
* `stream` returns `read-status::closed` with an `error-context` and the future
|
|
529
529
|
* resolves to `err` with an `error-code`.
|
|
530
|
-
*
|
|
530
|
+
*
|
|
531
531
|
* Note: This is similar to `pread` in POSIX.
|
|
532
532
|
*/
|
|
533
533
|
readViaStream(offset: Filesize): [ReadableStream<number>, Promise<Result<void, ErrorCode>>];
|
|
534
534
|
/**
|
|
535
535
|
* Return a stream for writing to a file, if available.
|
|
536
|
-
*
|
|
536
|
+
*
|
|
537
537
|
* May fail with an error-code describing why the file cannot be written.
|
|
538
|
-
*
|
|
538
|
+
*
|
|
539
539
|
* It is valid to write past the end of a file; the file is extended to the
|
|
540
540
|
* extent of the write, with bytes between the previous end and the start of
|
|
541
541
|
* the write set to zero.
|
|
542
|
-
*
|
|
542
|
+
*
|
|
543
543
|
* This function returns once either full contents of the stream are
|
|
544
544
|
* written or an error is encountered.
|
|
545
|
-
*
|
|
545
|
+
*
|
|
546
546
|
* Note: This is similar to `pwrite` in POSIX.
|
|
547
547
|
*/
|
|
548
548
|
writeViaStream(data: ReadableStream<number>, offset: Filesize): Promise<Result<void, ErrorCode>>;
|
|
549
549
|
/**
|
|
550
550
|
* Return a stream for appending to a file, if available.
|
|
551
|
-
*
|
|
551
|
+
*
|
|
552
552
|
* May fail with an error-code describing why the file cannot be appended.
|
|
553
|
-
*
|
|
553
|
+
*
|
|
554
554
|
* This function returns once either full contents of the stream are
|
|
555
555
|
* written or an error is encountered.
|
|
556
|
-
*
|
|
556
|
+
*
|
|
557
557
|
* Note: This is similar to `write` with `O_APPEND` in POSIX.
|
|
558
558
|
*/
|
|
559
559
|
appendViaStream(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
560
560
|
/**
|
|
561
561
|
* Provide file advisory information on a descriptor.
|
|
562
|
-
*
|
|
562
|
+
*
|
|
563
563
|
* This is similar to `posix_fadvise` in POSIX.
|
|
564
564
|
*/
|
|
565
565
|
advise(offset: Filesize, length: Filesize, advice: Advice): Promise<void>;
|
|
566
566
|
/**
|
|
567
567
|
* Synchronize the data of a file to disk.
|
|
568
|
-
*
|
|
568
|
+
*
|
|
569
569
|
* This function succeeds with no effect if the file descriptor is not
|
|
570
570
|
* opened for writing.
|
|
571
|
-
*
|
|
571
|
+
*
|
|
572
572
|
* Note: This is similar to `fdatasync` in POSIX.
|
|
573
573
|
*/
|
|
574
574
|
syncData(): Promise<void>;
|
|
575
575
|
/**
|
|
576
576
|
* Get flags associated with a descriptor.
|
|
577
|
-
*
|
|
577
|
+
*
|
|
578
578
|
* Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
|
|
579
|
-
*
|
|
579
|
+
*
|
|
580
580
|
* Note: This returns the value that was the `fs_flags` value returned
|
|
581
581
|
* from `fdstat_get` in earlier versions of WASI.
|
|
582
582
|
*/
|
|
583
583
|
getFlags(): Promise<DescriptorFlags>;
|
|
584
584
|
/**
|
|
585
585
|
* Get the dynamic type of a descriptor.
|
|
586
|
-
*
|
|
586
|
+
*
|
|
587
587
|
* Note: This returns the same value as the `type` field of the `fd-stat`
|
|
588
588
|
* returned by `stat`, `stat-at` and similar.
|
|
589
|
-
*
|
|
589
|
+
*
|
|
590
590
|
* Note: This returns similar flags to the `st_mode & S_IFMT` value provided
|
|
591
591
|
* by `fstat` in POSIX.
|
|
592
|
-
*
|
|
592
|
+
*
|
|
593
593
|
* Note: This returns the value that was the `fs_filetype` value returned
|
|
594
594
|
* from `fdstat_get` in earlier versions of WASI.
|
|
595
595
|
*/
|
|
@@ -597,143 +597,143 @@ export class Descriptor {
|
|
|
597
597
|
/**
|
|
598
598
|
* Adjust the size of an open file. If this increases the file's size, the
|
|
599
599
|
* extra bytes are filled with zeros.
|
|
600
|
-
*
|
|
600
|
+
*
|
|
601
601
|
* Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
|
|
602
602
|
*/
|
|
603
603
|
setSize(size: Filesize): Promise<void>;
|
|
604
604
|
/**
|
|
605
605
|
* Adjust the timestamps of an open file or directory.
|
|
606
|
-
*
|
|
606
|
+
*
|
|
607
607
|
* Note: This is similar to `futimens` in POSIX.
|
|
608
|
-
*
|
|
608
|
+
*
|
|
609
609
|
* Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
|
|
610
610
|
*/
|
|
611
611
|
setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise<void>;
|
|
612
612
|
/**
|
|
613
613
|
* Read directory entries from a directory.
|
|
614
|
-
*
|
|
614
|
+
*
|
|
615
615
|
* On filesystems where directories contain entries referring to themselves
|
|
616
616
|
* and their parents, often named `.` and `..` respectively, these entries
|
|
617
617
|
* are omitted.
|
|
618
|
-
*
|
|
618
|
+
*
|
|
619
619
|
* This always returns a new stream which starts at the beginning of the
|
|
620
620
|
* directory. Multiple streams may be active on the same directory, and they
|
|
621
621
|
* do not interfere with each other.
|
|
622
|
-
*
|
|
622
|
+
*
|
|
623
623
|
* This function returns a future, which will resolve to an error code if
|
|
624
624
|
* reading full contents of the directory fails.
|
|
625
625
|
*/
|
|
626
626
|
readDirectory(): [ReadableStream<DirectoryEntry>, Promise<Result<void, ErrorCode>>];
|
|
627
627
|
/**
|
|
628
628
|
* Synchronize the data and metadata of a file to disk.
|
|
629
|
-
*
|
|
629
|
+
*
|
|
630
630
|
* This function succeeds with no effect if the file descriptor is not
|
|
631
631
|
* opened for writing.
|
|
632
|
-
*
|
|
632
|
+
*
|
|
633
633
|
* Note: This is similar to `fsync` in POSIX.
|
|
634
634
|
*/
|
|
635
635
|
sync(): Promise<void>;
|
|
636
636
|
/**
|
|
637
637
|
* Create a directory.
|
|
638
|
-
*
|
|
638
|
+
*
|
|
639
639
|
* Note: This is similar to `mkdirat` in POSIX.
|
|
640
640
|
*/
|
|
641
641
|
createDirectoryAt(path: string): Promise<void>;
|
|
642
642
|
/**
|
|
643
643
|
* Return the attributes of an open file or directory.
|
|
644
|
-
*
|
|
644
|
+
*
|
|
645
645
|
* Note: This is similar to `fstat` in POSIX, except that it does not return
|
|
646
646
|
* device and inode information. For testing whether two descriptors refer to
|
|
647
647
|
* the same underlying filesystem object, use `is-same-object`. To obtain
|
|
648
648
|
* additional data that can be used do determine whether a file has been
|
|
649
649
|
* modified, use `metadata-hash`.
|
|
650
|
-
*
|
|
650
|
+
*
|
|
651
651
|
* Note: This was called `fd_filestat_get` in earlier versions of WASI.
|
|
652
652
|
*/
|
|
653
653
|
stat(): Promise<DescriptorStat>;
|
|
654
654
|
/**
|
|
655
655
|
* Return the attributes of a file or directory.
|
|
656
|
-
*
|
|
656
|
+
*
|
|
657
657
|
* Note: This is similar to `fstatat` in POSIX, except that it does not
|
|
658
658
|
* return device and inode information. See the `stat` description for a
|
|
659
659
|
* discussion of alternatives.
|
|
660
|
-
*
|
|
660
|
+
*
|
|
661
661
|
* Note: This was called `path_filestat_get` in earlier versions of WASI.
|
|
662
662
|
*/
|
|
663
663
|
statAt(pathFlags: PathFlags, path: string): Promise<DescriptorStat>;
|
|
664
664
|
/**
|
|
665
665
|
* Adjust the timestamps of a file or directory.
|
|
666
|
-
*
|
|
666
|
+
*
|
|
667
667
|
* Note: This is similar to `utimensat` in POSIX.
|
|
668
|
-
*
|
|
668
|
+
*
|
|
669
669
|
* Note: This was called `path_filestat_set_times` in earlier versions of
|
|
670
670
|
* WASI.
|
|
671
671
|
*/
|
|
672
672
|
setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise<void>;
|
|
673
673
|
/**
|
|
674
674
|
* Create a hard link.
|
|
675
|
-
*
|
|
675
|
+
*
|
|
676
676
|
* Fails with `error-code::no-entry` if the old path does not exist,
|
|
677
677
|
* with `error-code::exist` if the new path already exists, and
|
|
678
678
|
* `error-code::not-permitted` if the old path is not a file.
|
|
679
|
-
*
|
|
679
|
+
*
|
|
680
680
|
* Note: This is similar to `linkat` in POSIX.
|
|
681
681
|
*/
|
|
682
682
|
linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): Promise<void>;
|
|
683
683
|
/**
|
|
684
684
|
* Open a file or directory.
|
|
685
|
-
*
|
|
685
|
+
*
|
|
686
686
|
* If `flags` contains `descriptor-flags::mutate-directory`, and the base
|
|
687
687
|
* descriptor doesn't have `descriptor-flags::mutate-directory` set,
|
|
688
688
|
* `open-at` fails with `error-code::read-only`.
|
|
689
|
-
*
|
|
689
|
+
*
|
|
690
690
|
* If `flags` contains `write` or `mutate-directory`, or `open-flags`
|
|
691
691
|
* contains `truncate` or `create`, and the base descriptor doesn't have
|
|
692
692
|
* `descriptor-flags::mutate-directory` set, `open-at` fails with
|
|
693
693
|
* `error-code::read-only`.
|
|
694
|
-
*
|
|
694
|
+
*
|
|
695
695
|
* Note: This is similar to `openat` in POSIX.
|
|
696
696
|
*/
|
|
697
697
|
openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Promise<Descriptor>;
|
|
698
698
|
/**
|
|
699
699
|
* Read the contents of a symbolic link.
|
|
700
|
-
*
|
|
700
|
+
*
|
|
701
701
|
* If the contents contain an absolute or rooted path in the underlying
|
|
702
702
|
* filesystem, this function fails with `error-code::not-permitted`.
|
|
703
|
-
*
|
|
703
|
+
*
|
|
704
704
|
* Note: This is similar to `readlinkat` in POSIX.
|
|
705
705
|
*/
|
|
706
706
|
readlinkAt(path: string): Promise<string>;
|
|
707
707
|
/**
|
|
708
708
|
* Remove a directory.
|
|
709
|
-
*
|
|
709
|
+
*
|
|
710
710
|
* Return `error-code::not-empty` if the directory is not empty.
|
|
711
|
-
*
|
|
711
|
+
*
|
|
712
712
|
* Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
|
|
713
713
|
*/
|
|
714
714
|
removeDirectoryAt(path: string): Promise<void>;
|
|
715
715
|
/**
|
|
716
716
|
* Rename a filesystem object.
|
|
717
|
-
*
|
|
717
|
+
*
|
|
718
718
|
* Note: This is similar to `renameat` in POSIX.
|
|
719
719
|
*/
|
|
720
720
|
renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): Promise<void>;
|
|
721
721
|
/**
|
|
722
722
|
* Create a symbolic link (also known as a "symlink").
|
|
723
|
-
*
|
|
723
|
+
*
|
|
724
724
|
* If `old-path` starts with `/`, the function fails with
|
|
725
725
|
* `error-code::not-permitted`.
|
|
726
|
-
*
|
|
726
|
+
*
|
|
727
727
|
* Note: This is similar to `symlinkat` in POSIX.
|
|
728
728
|
*/
|
|
729
729
|
symlinkAt(oldPath: string, newPath: string): Promise<void>;
|
|
730
730
|
/**
|
|
731
731
|
* Unlink a filesystem object that is not a directory.
|
|
732
|
-
*
|
|
732
|
+
*
|
|
733
733
|
* This is similar to `unlinkat(fd, path, 0)` in POSIX.
|
|
734
|
-
*
|
|
734
|
+
*
|
|
735
735
|
* Error returns are as specified by POSIX.
|
|
736
|
-
*
|
|
736
|
+
*
|
|
737
737
|
* If the filesystem object is a directory, `error-code::access` or
|
|
738
738
|
* `error-code::is-directory` may be returned instead of the
|
|
739
739
|
* POSIX-specified `error-code::not-permitted`.
|
|
@@ -741,7 +741,7 @@ export class Descriptor {
|
|
|
741
741
|
unlinkFileAt(path: string): Promise<void>;
|
|
742
742
|
/**
|
|
743
743
|
* Test whether two descriptors refer to the same filesystem object.
|
|
744
|
-
*
|
|
744
|
+
*
|
|
745
745
|
* In POSIX, this corresponds to testing whether the two descriptors have the
|
|
746
746
|
* same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
|
|
747
747
|
* wasi-filesystem does not expose device and inode numbers, so this function
|
|
@@ -751,29 +751,29 @@ export class Descriptor {
|
|
|
751
751
|
/**
|
|
752
752
|
* Return a hash of the metadata associated with a filesystem object referred
|
|
753
753
|
* to by a descriptor.
|
|
754
|
-
*
|
|
754
|
+
*
|
|
755
755
|
* This returns a hash of the last-modification timestamp and file size, and
|
|
756
756
|
* may also include the inode number, device number, birth timestamp, and
|
|
757
757
|
* other metadata fields that may change when the file is modified or
|
|
758
758
|
* replaced. It may also include a secret value chosen by the
|
|
759
759
|
* implementation and not otherwise exposed.
|
|
760
|
-
*
|
|
760
|
+
*
|
|
761
761
|
* Implementations are encouraged to provide the following properties:
|
|
762
|
-
*
|
|
762
|
+
*
|
|
763
763
|
* - If the file is not modified or replaced, the computed hash value should
|
|
764
764
|
* usually not change.
|
|
765
765
|
* - If the object is modified or replaced, the computed hash value should
|
|
766
766
|
* usually change.
|
|
767
767
|
* - The inputs to the hash should not be easily computable from the
|
|
768
768
|
* computed hash.
|
|
769
|
-
*
|
|
769
|
+
*
|
|
770
770
|
* However, none of these is required.
|
|
771
771
|
*/
|
|
772
772
|
metadataHash(): Promise<MetadataHashValue>;
|
|
773
773
|
/**
|
|
774
774
|
* Return a hash of the metadata associated with a filesystem object referred
|
|
775
775
|
* to by a directory descriptor and a relative path.
|
|
776
|
-
*
|
|
776
|
+
*
|
|
777
777
|
* This performs the same hash computation as `metadata-hash`.
|
|
778
778
|
*/
|
|
779
779
|
metadataHashAt(pathFlags: PathFlags, path: string): Promise<MetadataHashValue>;
|