@bytecodealliance/preview2-shim 0.0.2 → 0.0.4

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 (60) hide show
  1. package/lib/browser/default-outgoing-HTTP.js +3 -0
  2. package/lib/browser/environment.js +3 -0
  3. package/lib/browser/filesystem.js +4 -0
  4. package/lib/browser/http.js +6 -4
  5. package/lib/browser/index.js +25 -11
  6. package/lib/browser/poll.js +4 -0
  7. package/lib/browser/streams.js +45 -0
  8. package/lib/browser/types.js +99 -0
  9. package/lib/http/error.js +1 -1
  10. package/lib/http/make-request.js +2 -2
  11. package/lib/http/synckit/index.d.ts +71 -0
  12. package/lib/http/synckit/index.js +141 -0
  13. package/lib/nodejs/default-outgoing-HTTP.js +3 -0
  14. package/lib/nodejs/environment.js +7 -0
  15. package/lib/nodejs/filesystem.js +9 -3
  16. package/lib/nodejs/http.js +4 -4
  17. package/lib/nodejs/index.js +25 -11
  18. package/lib/nodejs/monotonic-clock.js +4 -0
  19. package/lib/nodejs/poll.js +4 -0
  20. package/lib/nodejs/streams.js +45 -0
  21. package/lib/nodejs/types.js +99 -0
  22. package/lib/nodejs/wall-clock.js +4 -0
  23. package/package.json +18 -3
  24. package/types/exports/HTTP.d.ts +7 -0
  25. package/types/imports/console.d.ts +17 -0
  26. package/types/imports/default-outgoing-HTTP.d.ts +9 -0
  27. package/types/imports/environment-preopens.d.ts +5 -0
  28. package/types/imports/environment.d.ts +3 -0
  29. package/types/imports/exit.d.ts +4 -0
  30. package/types/imports/filesystem.d.ts +212 -0
  31. package/types/imports/instance-monotonic-clock.d.ts +5 -0
  32. package/types/imports/instance-network.d.ts +5 -0
  33. package/types/imports/instance-wall-clock.d.ts +5 -0
  34. package/types/imports/ip-name-lookup.d.ts +19 -0
  35. package/types/imports/monotonic-clock.d.ts +10 -0
  36. package/types/imports/network.d.ts +50 -0
  37. package/types/imports/poll.d.ts +5 -0
  38. package/types/imports/random.d.ts +5 -0
  39. package/types/{wasi-stderr.d.ts → imports/stderr.d.ts} +1 -1
  40. package/types/imports/streams.d.ts +23 -0
  41. package/types/imports/tcp-create-socket.d.ts +9 -0
  42. package/types/imports/tcp.d.ts +52 -0
  43. package/types/imports/timezone.d.ts +13 -0
  44. package/types/imports/types.d.ts +119 -0
  45. package/types/imports/udp-create-socket.d.ts +9 -0
  46. package/types/imports/udp.d.ts +36 -0
  47. package/types/imports/wall-clock.d.ts +10 -0
  48. package/types/index.d.ts +8 -9
  49. package/types/wasi-proxy.d.ts +44 -0
  50. package/types/wasi-reactor.d.ts +70 -0
  51. package/types/wasi-clocks.d.ts +0 -11
  52. package/types/wasi-default-clocks.d.ts +0 -6
  53. package/types/wasi-exit.d.ts +0 -3
  54. package/types/wasi-filesystem.d.ts +0 -150
  55. package/types/wasi-http.d.ts +0 -55
  56. package/types/wasi-io.d.ts +0 -10
  57. package/types/wasi-poll.d.ts +0 -4
  58. package/types/wasi-random.d.ts +0 -3
  59. /package/lib/browser/{logging.js → console.js} +0 -0
  60. /package/lib/nodejs/{logging.js → console.js} +0 -0
@@ -0,0 +1,99 @@
1
+ export function dropFields(_fields) {
2
+ console.log("[types] Drop fields");
3
+ }
4
+ export function newFields(_entries) {
5
+ console.log("[types] New fields");
6
+ }
7
+ export function fieldsGet(_fields, _name) {
8
+ console.log("[types] Fields get");
9
+ }
10
+ export function fieldsSet(_fields, _name, _value) {
11
+ console.log("[types] Fields set");
12
+ }
13
+ export function fieldsDelete(_fields, _name) {
14
+ console.log("[types] Fields delete");
15
+ }
16
+ export function fieldsAppend(_fields, _name, _value) {
17
+ console.log("[types] Fields append");
18
+ }
19
+ export function fieldsEntries(_fields) {
20
+ console.log("[types] Fields entries");
21
+ }
22
+ export function fieldsClone(_fields) {
23
+ console.log("[types] Fields clone");
24
+ }
25
+ export function finishIncomingStream(s) {
26
+ console.log(`[types] Finish incoming stream ${s}`);
27
+ }
28
+ export function finishOutgoingStream(s, _trailers) {
29
+ console.log(`[types] Finish outgoing stream ${s}`);
30
+ }
31
+ export function dropIncomingRequest(_req) {
32
+ console.log("[types] Drop incoming request");
33
+ }
34
+ export function dropOutgoingRequest(_req) {
35
+ console.log("[types] Drop outgoing request");
36
+ }
37
+ export function incomingRequestMethod(_req) {
38
+ console.log("[types] Incoming request method");
39
+ }
40
+ export function incomingRequestPath(_req) {
41
+ console.log("[types] Incoming request path");
42
+ }
43
+ export function incomingRequestQuery(_req) {
44
+ console.log("[types] Incoming request query");
45
+ }
46
+ export function incomingRequestScheme(_req) {
47
+ console.log("[types] Incoming request scheme");
48
+ }
49
+ export function incomingRequestAuthority(_req) {
50
+ console.log("[types] Incoming request authority");
51
+ }
52
+ export function incomingRequestHeaders(_req) {
53
+ console.log("[types] Incoming request headers");
54
+ }
55
+ export function incomingRequestConsume(_req) {
56
+ console.log("[types] Incoming request consume");
57
+ }
58
+ export function newOutgoingRequest(_method, _path, _query, _scheme, _authority, _headers) {
59
+ console.log("[types] New outgoing request");
60
+ }
61
+ export function outgoingRequestWrite(_req) {
62
+ console.log("[types] Outgoing request write");
63
+ }
64
+ export function dropResponseOutparam(_res) {
65
+ console.log("[types] Drop response outparam");
66
+ }
67
+ export function setResponseOutparam(_response) {
68
+ console.log("[types] Drop fields");
69
+ }
70
+ export function dropIncomingResponse(_res) {
71
+ console.log("[types] Drop incoming response");
72
+ }
73
+ export function dropOutgoingResponse(_res) {
74
+ console.log("[types] Drop outgoing response");
75
+ }
76
+ export function incomingResponseStatus(_res) {
77
+ console.log("[types] Incoming response status");
78
+ }
79
+ export function incomingResponseHeaders(_res) {
80
+ console.log("[types] Incoming response headers");
81
+ }
82
+ export function incomingResponseConsume(_res) {
83
+ console.log("[types] Incoming response consume");
84
+ }
85
+ export function newOutgoingResponse(_statusCode, _headers) {
86
+ console.log("[types] New outgoing response");
87
+ }
88
+ export function outgoingResponseWrite(_res) {
89
+ console.log("[types] Outgoing response write");
90
+ }
91
+ export function dropFutureIncomingResponse(_f) {
92
+ console.log("[types] Drop future incoming response");
93
+ }
94
+ export function futureIncomingResponseGet(_f) {
95
+ console.log("[types] Future incoming response get");
96
+ }
97
+ export function listenToFutureIncomingResponse(_f) {
98
+ console.log("[types] Listen to future incoming response");
99
+ }
@@ -10,3 +10,7 @@ export function now(clock) {
10
10
  export function resolution(clock) {
11
11
  console.log(`[clocks] Wall clock resolution ${clock}`);
12
12
  }
13
+
14
+ export function instanceWallClock () {
15
+ return 1;
16
+ }
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@bytecodealliance/preview2-shim",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "WASI Preview2 shim for JS environments",
5
5
  "author": "Guy Bedford, Eduardo Rodrigues<16357187+eduardomourar@users.noreply.github.com>",
6
6
  "type": "module",
7
+ "types": "./types/index.d.ts",
7
8
  "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "node": "./lib/nodejs/index.js",
12
+ "default": "./lib/browser/index.js"
13
+ },
8
14
  "./*": {
9
- "types": "./types/*.js",
15
+ "types": "./types/*.d.ts",
10
16
  "node": "./lib/nodejs/*.js",
11
17
  "default": "./lib/browser/*.js"
12
18
  }
@@ -20,5 +26,14 @@
20
26
  ],
21
27
  "devDependencies": {
22
28
  "mocha": "^10.2.0"
23
- }
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/bytecodealliance/jco.git"
33
+ },
34
+ "license": "(Apache-2.0 WITH LLVM-exception)",
35
+ "bugs": {
36
+ "url": "https://github.com/bytecodealliance/jco/issues"
37
+ },
38
+ "homepage": "https://github.com/bytecodealliance/jco#readme"
24
39
  }
@@ -0,0 +1,7 @@
1
+ export namespace Http {
2
+ export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
3
+ }
4
+ import type { IncomingRequest } from '../imports/types';
5
+ export { IncomingRequest };
6
+ import type { ResponseOutparam } from '../imports/types';
7
+ export { ResponseOutparam };
@@ -0,0 +1,17 @@
1
+ export namespace Console {
2
+ export function log(level: Level, context: string, message: string): void;
3
+ }
4
+ /**
5
+ * # Variants
6
+ *
7
+ * ## `"trace"`
8
+ *
9
+ * ## `"debug"`
10
+ *
11
+ * ## `"info"`
12
+ *
13
+ * ## `"warn"`
14
+ *
15
+ * ## `"error"`
16
+ */
17
+ export type Level = 'trace' | 'debug' | 'info' | 'warn' | 'error';
@@ -0,0 +1,9 @@
1
+ export namespace DefaultOutgoingHttp {
2
+ export function handle(request: OutgoingRequest, options: RequestOptions | null): FutureIncomingResponse;
3
+ }
4
+ import type { OutgoingRequest } from '../imports/types';
5
+ export { OutgoingRequest };
6
+ import type { RequestOptions } from '../imports/types';
7
+ export { RequestOptions };
8
+ import type { FutureIncomingResponse } from '../imports/types';
9
+ export { FutureIncomingResponse };
@@ -0,0 +1,5 @@
1
+ export namespace EnvironmentPreopens {
2
+ export function preopens(): [Descriptor, string][];
3
+ }
4
+ import type { Descriptor } from '../imports/filesystem';
5
+ export { Descriptor };
@@ -0,0 +1,3 @@
1
+ export namespace Environment {
2
+ export function getEnvironment(): [string, string][];
3
+ }
@@ -0,0 +1,4 @@
1
+ export namespace Exit {
2
+ export function exit(status: Result<void, void>): void;
3
+ }
4
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,212 @@
1
+ export namespace Filesystem {
2
+ export function readViaStream(this: Descriptor, offset: Filesize): InputStream;
3
+ export function writeViaStream(this: Descriptor, offset: Filesize): OutputStream;
4
+ export function appendViaStream(this: Descriptor): OutputStream;
5
+ export function advise(this: Descriptor, offset: Filesize, length: Filesize, advice: Advice): void;
6
+ export function syncData(this: Descriptor): void;
7
+ export function getFlags(this: Descriptor): DescriptorFlags;
8
+ export function getType(this: Descriptor): DescriptorType;
9
+ export function setFlags(this: Descriptor, flags: DescriptorFlags): void;
10
+ export function setSize(this: Descriptor, size: Filesize): void;
11
+ export function setTimes(this: Descriptor, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
12
+ export function read(this: Descriptor, length: Filesize, offset: Filesize): [Uint8Array | ArrayBuffer, boolean];
13
+ export function write(this: Descriptor, buffer: Uint8Array, offset: Filesize): Filesize;
14
+ export function readDirectory(this: Descriptor): DirectoryEntryStream;
15
+ export function sync(this: Descriptor): void;
16
+ export function createDirectoryAt(this: Descriptor, path: string): void;
17
+ export function stat(this: Descriptor): DescriptorStat;
18
+ export function statAt(this: Descriptor, pathFlags: PathFlags, path: string): DescriptorStat;
19
+ export function setTimesAt(this: Descriptor, pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
20
+ export function linkAt(this: Descriptor, oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
21
+ export function openAt(this: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
22
+ export function readlinkAt(this: Descriptor, path: string): string;
23
+ export function removeDirectoryAt(this: Descriptor, path: string): void;
24
+ export function renameAt(this: Descriptor, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
25
+ export function symlinkAt(this: Descriptor, oldPath: string, newPath: string): void;
26
+ export function unlinkFileAt(this: Descriptor, path: string): void;
27
+ export function changeFilePermissionsAt(this: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
28
+ export function changeDirectoryPermissionsAt(this: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
29
+ export function lockShared(this: Descriptor): void;
30
+ export function lockExclusive(this: Descriptor): void;
31
+ export function tryLockShared(this: Descriptor): void;
32
+ export function tryLockExclusive(this: Descriptor): void;
33
+ export function unlock(this: Descriptor): void;
34
+ export function dropDescriptor(this: Descriptor): void;
35
+ export function readDirectoryEntry(this: DirectoryEntryStream): DirectoryEntry | null;
36
+ export function dropDirectoryEntryStream(this: DirectoryEntryStream): void;
37
+ }
38
+ export type Descriptor = number;
39
+ export type Filesize = bigint;
40
+ import type { InputStream } from '../imports/streams';
41
+ export { InputStream };
42
+ import type { OutputStream } from '../imports/streams';
43
+ export { OutputStream };
44
+ /**
45
+ * # Variants
46
+ *
47
+ * ## `"normal"`
48
+ *
49
+ * ## `"sequential"`
50
+ *
51
+ * ## `"random"`
52
+ *
53
+ * ## `"will-need"`
54
+ *
55
+ * ## `"dont-need"`
56
+ *
57
+ * ## `"no-reuse"`
58
+ */
59
+ export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
60
+ /**
61
+ * # Variants
62
+ *
63
+ * ## `"access"`
64
+ *
65
+ * ## `"would-block"`
66
+ *
67
+ * ## `"already"`
68
+ *
69
+ * ## `"bad-descriptor"`
70
+ *
71
+ * ## `"busy"`
72
+ *
73
+ * ## `"deadlock"`
74
+ *
75
+ * ## `"quota"`
76
+ *
77
+ * ## `"exist"`
78
+ *
79
+ * ## `"file-too-large"`
80
+ *
81
+ * ## `"illegal-byte-sequence"`
82
+ *
83
+ * ## `"in-progress"`
84
+ *
85
+ * ## `"interrupted"`
86
+ *
87
+ * ## `"invalid"`
88
+ *
89
+ * ## `"io"`
90
+ *
91
+ * ## `"is-directory"`
92
+ *
93
+ * ## `"loop"`
94
+ *
95
+ * ## `"too-many-links"`
96
+ *
97
+ * ## `"message-size"`
98
+ *
99
+ * ## `"name-too-long"`
100
+ *
101
+ * ## `"no-device"`
102
+ *
103
+ * ## `"no-entry"`
104
+ *
105
+ * ## `"no-lock"`
106
+ *
107
+ * ## `"insufficient-memory"`
108
+ *
109
+ * ## `"insufficient-space"`
110
+ *
111
+ * ## `"not-directory"`
112
+ *
113
+ * ## `"not-empty"`
114
+ *
115
+ * ## `"not-recoverable"`
116
+ *
117
+ * ## `"unsupported"`
118
+ *
119
+ * ## `"no-tty"`
120
+ *
121
+ * ## `"no-such-device"`
122
+ *
123
+ * ## `"overflow"`
124
+ *
125
+ * ## `"not-permitted"`
126
+ *
127
+ * ## `"pipe"`
128
+ *
129
+ * ## `"read-only"`
130
+ *
131
+ * ## `"invalid-seek"`
132
+ *
133
+ * ## `"text-file-busy"`
134
+ *
135
+ * ## `"cross-device"`
136
+ */
137
+ 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';
138
+ export interface DescriptorFlags {
139
+ read?: boolean,
140
+ write?: boolean,
141
+ nonBlocking?: boolean,
142
+ fileIntegritySync?: boolean,
143
+ dataIntegritySync?: boolean,
144
+ requestedWriteSync?: boolean,
145
+ mutateDirectory?: boolean,
146
+ }
147
+ /**
148
+ * # Variants
149
+ *
150
+ * ## `"unknown"`
151
+ *
152
+ * ## `"block-device"`
153
+ *
154
+ * ## `"character-device"`
155
+ *
156
+ * ## `"directory"`
157
+ *
158
+ * ## `"fifo"`
159
+ *
160
+ * ## `"symbolic-link"`
161
+ *
162
+ * ## `"regular-file"`
163
+ *
164
+ * ## `"socket"`
165
+ */
166
+ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
167
+ import type { Datetime } from '../imports/wall-clock';
168
+ export { Datetime };
169
+ export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
170
+ export interface NewTimestampNoChange {
171
+ tag: 'no-change',
172
+ }
173
+ export interface NewTimestampNow {
174
+ tag: 'now',
175
+ }
176
+ export interface NewTimestampTimestamp {
177
+ tag: 'timestamp',
178
+ val: Datetime,
179
+ }
180
+ export type DirectoryEntryStream = number;
181
+ export type Device = bigint;
182
+ export type Inode = bigint;
183
+ export type LinkCount = bigint;
184
+ export interface DescriptorStat {
185
+ device: Device,
186
+ inode: Inode,
187
+ type: DescriptorType,
188
+ linkCount: LinkCount,
189
+ size: Filesize,
190
+ dataAccessTimestamp: Datetime,
191
+ dataModificationTimestamp: Datetime,
192
+ statusChangeTimestamp: Datetime,
193
+ }
194
+ export interface PathFlags {
195
+ symlinkFollow?: boolean,
196
+ }
197
+ export interface OpenFlags {
198
+ create?: boolean,
199
+ directory?: boolean,
200
+ exclusive?: boolean,
201
+ truncate?: boolean,
202
+ }
203
+ export interface Modes {
204
+ readable?: boolean,
205
+ writeable?: boolean,
206
+ executable?: boolean,
207
+ }
208
+ export interface DirectoryEntry {
209
+ inode?: Inode,
210
+ type: DescriptorType,
211
+ name: string,
212
+ }
@@ -0,0 +1,5 @@
1
+ export namespace InstanceMonotonicClock {
2
+ export function instanceMonotonicClock(): MonotonicClock;
3
+ }
4
+ import type { MonotonicClock } from '../imports/monotonic-clock';
5
+ export { MonotonicClock };
@@ -0,0 +1,5 @@
1
+ export namespace InstanceNetwork {
2
+ export function instanceNetwork(): Network;
3
+ }
4
+ import type { Network } from '../imports/network';
5
+ export { Network };
@@ -0,0 +1,5 @@
1
+ export namespace InstanceWallClock {
2
+ export function instanceWallClock(): WallClock;
3
+ }
4
+ import type { WallClock } from '../imports/wall-clock';
5
+ export { WallClock };
@@ -0,0 +1,19 @@
1
+ export namespace IpNameLookup {
2
+ export function resolveAddresses(network: Network, name: string, addressFamily: IpAddressFamily | null, includeUnavailable: boolean): ResolveAddressStream;
3
+ export function resolveNextAddress(this: ResolveAddressStream): IpAddress | null;
4
+ export function dropResolveAddressStream(this: ResolveAddressStream): void;
5
+ export function nonBlocking(this: ResolveAddressStream): boolean;
6
+ export function setNonBlocking(this: ResolveAddressStream, value: boolean): void;
7
+ export function subscribe(this: ResolveAddressStream): Pollable;
8
+ }
9
+ import type { Network } from '../imports/network';
10
+ export { Network };
11
+ import type { IpAddressFamily } from '../imports/network';
12
+ export { IpAddressFamily };
13
+ export type ResolveAddressStream = number;
14
+ import type { Error } from '../imports/network';
15
+ export { Error };
16
+ import type { IpAddress } from '../imports/network';
17
+ export { IpAddress };
18
+ import type { Pollable } from '../imports/poll';
19
+ export { Pollable };
@@ -0,0 +1,10 @@
1
+ export namespace MonotonicClock {
2
+ export function now(this: MonotonicClock): Instant;
3
+ export function resolution(this: MonotonicClock): Instant;
4
+ export function subscribe(this: MonotonicClock, when: Instant, absolute: boolean): Pollable;
5
+ export function dropMonotonicClock(this: MonotonicClock): void;
6
+ }
7
+ export type MonotonicClock = number;
8
+ export type Instant = bigint;
9
+ import type { Pollable } from '../imports/poll';
10
+ export { Pollable };
@@ -0,0 +1,50 @@
1
+ export namespace Network {
2
+ export function dropNetwork(this: Network): void;
3
+ }
4
+ export type Network = number;
5
+ export type Ipv6Address = [number, number, number, number, number, number, number, number];
6
+ export interface Ipv6SocketAddress {
7
+ port: number,
8
+ flowInfo: number,
9
+ address: Ipv6Address,
10
+ scopeId: number,
11
+ }
12
+ export type Ipv4Address = [number, number, number, number];
13
+ export interface Ipv4SocketAddress {
14
+ port: number,
15
+ address: Ipv4Address,
16
+ }
17
+ export type IpSocketAddress = IpSocketAddressIpv4 | IpSocketAddressIpv6;
18
+ export interface IpSocketAddressIpv4 {
19
+ tag: 'ipv4',
20
+ val: Ipv4SocketAddress,
21
+ }
22
+ export interface IpSocketAddressIpv6 {
23
+ tag: 'ipv6',
24
+ val: Ipv6SocketAddress,
25
+ }
26
+ export type IpAddress = IpAddressIpv4 | IpAddressIpv6;
27
+ export interface IpAddressIpv4 {
28
+ tag: 'ipv4',
29
+ val: Ipv4Address,
30
+ }
31
+ export interface IpAddressIpv6 {
32
+ tag: 'ipv6',
33
+ val: Ipv6Address,
34
+ }
35
+ /**
36
+ * # Variants
37
+ *
38
+ * ## `"unknown"`
39
+ *
40
+ * ## `"again"`
41
+ */
42
+ export type Error = 'unknown' | 'again';
43
+ /**
44
+ * # Variants
45
+ *
46
+ * ## `"ipv4"`
47
+ *
48
+ * ## `"ipv6"`
49
+ */
50
+ export type IpAddressFamily = 'ipv4' | 'ipv6';
@@ -0,0 +1,5 @@
1
+ export namespace Poll {
2
+ export function dropPollable(this: Pollable): void;
3
+ export function pollOneoff(in_: Uint32Array): Uint8Array | ArrayBuffer;
4
+ }
5
+ export type Pollable = number;
@@ -0,0 +1,5 @@
1
+ export namespace Random {
2
+ export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
+ export function getRandomU64(): bigint;
4
+ export function insecureRandom(): [bigint, bigint];
5
+ }
@@ -1,3 +1,3 @@
1
- export namespace WasiStderr {
1
+ export namespace Stderr {
2
2
  export function print(message: string): void;
3
3
  }
@@ -0,0 +1,23 @@
1
+ export namespace Streams {
2
+ export function read(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
3
+ export function blockingRead(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
4
+ export function skip(this: InputStream, len: bigint): [bigint, boolean];
5
+ export function blockingSkip(this: InputStream, len: bigint): [bigint, boolean];
6
+ export function subscribeToInputStream(this: InputStream): Pollable;
7
+ export function dropInputStream(this: InputStream): void;
8
+ export function write(this: OutputStream, buf: Uint8Array): bigint;
9
+ export function blockingWrite(this: OutputStream, buf: Uint8Array): bigint;
10
+ export function writeZeroes(this: OutputStream, len: bigint): bigint;
11
+ export function blockingWriteZeroes(this: OutputStream, len: bigint): bigint;
12
+ export function splice(this: OutputStream, src: InputStream, len: bigint): [bigint, boolean];
13
+ export function blockingSplice(this: OutputStream, src: InputStream, len: bigint): [bigint, boolean];
14
+ export function forward(this: OutputStream, src: InputStream): bigint;
15
+ export function subscribeToOutputStream(this: OutputStream): Pollable;
16
+ export function dropOutputStream(this: OutputStream): void;
17
+ }
18
+ export type InputStream = number;
19
+ export interface StreamError {
20
+ }
21
+ import type { Pollable } from '../imports/poll';
22
+ export { Pollable };
23
+ export type OutputStream = number;
@@ -0,0 +1,9 @@
1
+ export namespace TcpCreateSocket {
2
+ export function createTcpSocket(addressFamily: IpAddressFamily): TcpSocket;
3
+ }
4
+ import type { IpAddressFamily } from '../imports/network';
5
+ export { IpAddressFamily };
6
+ import type { TcpSocket } from '../imports/tcp';
7
+ export { TcpSocket };
8
+ import type { Error } from '../imports/network';
9
+ export { Error };
@@ -0,0 +1,52 @@
1
+ export namespace Tcp {
2
+ export function bind(this: TcpSocket, network: Network, localAddress: IpSocketAddress): void;
3
+ export function connect(this: TcpSocket, network: Network, remoteAddress: IpSocketAddress): [InputStream, OutputStream];
4
+ export function listen(this: TcpSocket, network: Network): void;
5
+ export function accept(this: TcpSocket): [TcpSocket, InputStream, OutputStream];
6
+ export function localAddress(this: TcpSocket): IpSocketAddress;
7
+ export function remoteAddress(this: TcpSocket): IpSocketAddress;
8
+ export function addressFamily(this: TcpSocket): IpAddressFamily;
9
+ export function ipv6Only(this: TcpSocket): boolean;
10
+ export function setIpv6Only(this: TcpSocket, value: boolean): void;
11
+ export function setListenBacklogSize(this: TcpSocket, value: bigint): void;
12
+ export function keepAlive(this: TcpSocket): boolean;
13
+ export function setKeepAlive(this: TcpSocket, value: boolean): void;
14
+ export function noDelay(this: TcpSocket): boolean;
15
+ export function setNoDelay(this: TcpSocket, value: boolean): void;
16
+ export function unicastHopLimit(this: TcpSocket): number;
17
+ export function setUnicastHopLimit(this: TcpSocket, value: number): void;
18
+ export function receiveBufferSize(this: TcpSocket): bigint;
19
+ export function setReceiveBufferSize(this: TcpSocket, value: bigint): void;
20
+ export function sendBufferSize(this: TcpSocket): bigint;
21
+ export function setSendBufferSize(this: TcpSocket, value: bigint): void;
22
+ export function nonBlocking(this: TcpSocket): boolean;
23
+ export function setNonBlocking(this: TcpSocket, value: boolean): void;
24
+ export function subscribe(this: TcpSocket): Pollable;
25
+ export function shutdown(this: TcpSocket, shutdownType: ShutdownType): void;
26
+ export function dropTcpSocket(this: TcpSocket): void;
27
+ }
28
+ export type TcpSocket = number;
29
+ import type { Network } from '../imports/network';
30
+ export { Network };
31
+ import type { IpSocketAddress } from '../imports/network';
32
+ export { IpSocketAddress };
33
+ import type { Error } from '../imports/network';
34
+ export { Error };
35
+ import type { InputStream } from '../imports/streams';
36
+ export { InputStream };
37
+ import type { OutputStream } from '../imports/streams';
38
+ export { OutputStream };
39
+ import type { IpAddressFamily } from '../imports/network';
40
+ export { IpAddressFamily };
41
+ import type { Pollable } from '../imports/poll';
42
+ export { Pollable };
43
+ /**
44
+ * # Variants
45
+ *
46
+ * ## `"receive"`
47
+ *
48
+ * ## `"send"`
49
+ *
50
+ * ## `"both"`
51
+ */
52
+ export type ShutdownType = 'receive' | 'send' | 'both';
@@ -0,0 +1,13 @@
1
+ export namespace Timezone {
2
+ export function display(this: Timezone, when: Datetime): TimezoneDisplay;
3
+ export function utcOffset(this: Timezone, when: Datetime): number;
4
+ export function dropTimezone(this: Timezone): void;
5
+ }
6
+ export type Timezone = number;
7
+ import type { Datetime } from '../imports/wall-clock';
8
+ export { Datetime };
9
+ export interface TimezoneDisplay {
10
+ utcOffset: number,
11
+ name: string,
12
+ inDaylightSavingTime: boolean,
13
+ }