@bytecodealliance/preview2-shim 0.0.3 → 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 (58) hide show
  1. package/lib/browser/default-outgoing-HTTP.js +3 -0
  2. package/lib/browser/http.js +6 -4
  3. package/lib/browser/index.js +25 -11
  4. package/lib/browser/poll.js +4 -0
  5. package/lib/browser/streams.js +45 -0
  6. package/lib/browser/types.js +99 -0
  7. package/lib/http/error.js +1 -1
  8. package/lib/http/make-request.js +2 -2
  9. package/lib/http/synckit/index.d.ts +71 -0
  10. package/lib/http/synckit/index.js +141 -0
  11. package/lib/nodejs/default-outgoing-HTTP.js +3 -0
  12. package/lib/nodejs/environment.js +4 -0
  13. package/lib/nodejs/filesystem.js +7 -5
  14. package/lib/nodejs/http.js +4 -4
  15. package/lib/nodejs/index.js +25 -11
  16. package/lib/nodejs/monotonic-clock.js +4 -0
  17. package/lib/nodejs/poll.js +4 -0
  18. package/lib/nodejs/streams.js +45 -0
  19. package/lib/nodejs/types.js +99 -0
  20. package/lib/nodejs/wall-clock.js +4 -0
  21. package/package.json +18 -3
  22. package/types/exports/HTTP.d.ts +7 -0
  23. package/types/imports/console.d.ts +17 -0
  24. package/types/imports/default-outgoing-HTTP.d.ts +9 -0
  25. package/types/imports/environment-preopens.d.ts +5 -0
  26. package/types/imports/environment.d.ts +3 -0
  27. package/types/imports/exit.d.ts +4 -0
  28. package/types/imports/filesystem.d.ts +212 -0
  29. package/types/imports/instance-monotonic-clock.d.ts +5 -0
  30. package/types/imports/instance-network.d.ts +5 -0
  31. package/types/imports/instance-wall-clock.d.ts +5 -0
  32. package/types/imports/ip-name-lookup.d.ts +19 -0
  33. package/types/imports/monotonic-clock.d.ts +10 -0
  34. package/types/imports/network.d.ts +50 -0
  35. package/types/imports/poll.d.ts +5 -0
  36. package/types/imports/random.d.ts +5 -0
  37. package/types/{wasi-stderr.d.ts → imports/stderr.d.ts} +1 -1
  38. package/types/imports/streams.d.ts +23 -0
  39. package/types/imports/tcp-create-socket.d.ts +9 -0
  40. package/types/imports/tcp.d.ts +52 -0
  41. package/types/imports/timezone.d.ts +13 -0
  42. package/types/imports/types.d.ts +119 -0
  43. package/types/imports/udp-create-socket.d.ts +9 -0
  44. package/types/imports/udp.d.ts +36 -0
  45. package/types/imports/wall-clock.d.ts +10 -0
  46. package/types/index.d.ts +8 -9
  47. package/types/wasi-proxy.d.ts +44 -0
  48. package/types/wasi-reactor.d.ts +70 -0
  49. package/types/wasi-clocks.d.ts +0 -11
  50. package/types/wasi-default-clocks.d.ts +0 -6
  51. package/types/wasi-exit.d.ts +0 -3
  52. package/types/wasi-filesystem.d.ts +0 -150
  53. package/types/wasi-http.d.ts +0 -55
  54. package/types/wasi-io.d.ts +0 -10
  55. package/types/wasi-poll.d.ts +0 -4
  56. package/types/wasi-random.d.ts +0 -3
  57. /package/lib/browser/{logging.js → console.js} +0 -0
  58. /package/lib/nodejs/{logging.js → console.js} +0 -0
@@ -0,0 +1,119 @@
1
+ export namespace Types {
2
+ export function dropFields(fields: Fields): void;
3
+ export function newFields(entries: [string, string][]): Fields;
4
+ export function fieldsGet(fields: Fields, name: string): string[];
5
+ export function fieldsSet(fields: Fields, name: string, value: string[]): void;
6
+ export function fieldsDelete(fields: Fields, name: string): void;
7
+ export function fieldsAppend(fields: Fields, name: string, value: string): void;
8
+ export function fieldsEntries(fields: Fields): [string, string][];
9
+ export function fieldsClone(fields: Fields): Fields;
10
+ export function finishIncomingStream(s: IncomingStream): Trailers | null;
11
+ export function finishOutgoingStream(s: OutgoingStream, trailers: Trailers | null): void;
12
+ export function dropIncomingRequest(request: IncomingRequest): void;
13
+ export function dropOutgoingRequest(request: OutgoingRequest): void;
14
+ export function incomingRequestMethod(request: IncomingRequest): Method;
15
+ export function incomingRequestPath(request: IncomingRequest): string;
16
+ export function incomingRequestQuery(request: IncomingRequest): string;
17
+ export function incomingRequestScheme(request: IncomingRequest): Scheme | null;
18
+ export function incomingRequestAuthority(request: IncomingRequest): string;
19
+ export function incomingRequestHeaders(request: IncomingRequest): Headers;
20
+ export function incomingRequestConsume(request: IncomingRequest): IncomingStream;
21
+ export function newOutgoingRequest(method: Method, path: string, query: string, scheme: Scheme | null, authority: string, headers: Headers): OutgoingRequest;
22
+ export function outgoingRequestWrite(request: OutgoingRequest): OutgoingStream;
23
+ export function dropResponseOutparam(response: ResponseOutparam): void;
24
+ export function setResponseOutparam(response: Result<OutgoingResponse, Error>): void;
25
+ export function dropIncomingResponse(response: IncomingResponse): void;
26
+ export function dropOutgoingResponse(response: OutgoingResponse): void;
27
+ export function incomingResponseStatus(response: IncomingResponse): StatusCode;
28
+ export function incomingResponseHeaders(response: IncomingResponse): Headers;
29
+ export function incomingResponseConsume(response: IncomingResponse): IncomingStream;
30
+ export function newOutgoingResponse(statusCode: StatusCode, headers: Headers): OutgoingResponse;
31
+ export function outgoingResponseWrite(response: OutgoingResponse): OutgoingStream;
32
+ export function dropFutureIncomingResponse(f: FutureIncomingResponse): void;
33
+ export function futureIncomingResponseGet(f: FutureIncomingResponse): Result<IncomingResponse, Error> | null;
34
+ export function listenToFutureIncomingResponse(f: FutureIncomingResponse): Pollable;
35
+ }
36
+ export type Fields = number;
37
+ import type { InputStream } from '../imports/streams';
38
+ export { InputStream };
39
+ export type IncomingStream = InputStream;
40
+ export type Trailers = Fields;
41
+ import type { OutputStream } from '../imports/streams';
42
+ export { OutputStream };
43
+ export type OutgoingStream = OutputStream;
44
+ export type IncomingRequest = number;
45
+ export type OutgoingRequest = number;
46
+ export type Method = MethodGet | MethodHead | MethodPost | MethodPut | MethodDelete | MethodConnect | MethodOptions | MethodTrace | MethodPatch | MethodOther;
47
+ export interface MethodGet {
48
+ tag: 'get',
49
+ }
50
+ export interface MethodHead {
51
+ tag: 'head',
52
+ }
53
+ export interface MethodPost {
54
+ tag: 'post',
55
+ }
56
+ export interface MethodPut {
57
+ tag: 'put',
58
+ }
59
+ export interface MethodDelete {
60
+ tag: 'delete',
61
+ }
62
+ export interface MethodConnect {
63
+ tag: 'connect',
64
+ }
65
+ export interface MethodOptions {
66
+ tag: 'options',
67
+ }
68
+ export interface MethodTrace {
69
+ tag: 'trace',
70
+ }
71
+ export interface MethodPatch {
72
+ tag: 'patch',
73
+ }
74
+ export interface MethodOther {
75
+ tag: 'other',
76
+ val: string,
77
+ }
78
+ export type Scheme = SchemeHttp | SchemeHttps | SchemeOther;
79
+ export interface SchemeHttp {
80
+ tag: 'HTTP',
81
+ }
82
+ export interface SchemeHttps {
83
+ tag: 'HTTPS',
84
+ }
85
+ export interface SchemeOther {
86
+ tag: 'other',
87
+ val: string,
88
+ }
89
+ export type Headers = Fields;
90
+ export type ResponseOutparam = number;
91
+ export type OutgoingResponse = number;
92
+ export type Error = ErrorInvalidUrl | ErrorTimeoutError | ErrorProtocolError | ErrorUnexpectedError;
93
+ export interface ErrorInvalidUrl {
94
+ tag: 'invalid-url',
95
+ val: string,
96
+ }
97
+ export interface ErrorTimeoutError {
98
+ tag: 'timeout-error',
99
+ val: string,
100
+ }
101
+ export interface ErrorProtocolError {
102
+ tag: 'protocol-error',
103
+ val: string,
104
+ }
105
+ export interface ErrorUnexpectedError {
106
+ tag: 'unexpected-error',
107
+ val: string,
108
+ }
109
+ export type IncomingResponse = number;
110
+ export type StatusCode = number;
111
+ export type FutureIncomingResponse = number;
112
+ import type { Pollable } from '../imports/poll';
113
+ export { Pollable };
114
+ export interface RequestOptions {
115
+ connectTimeoutMs?: number,
116
+ firstByteTimeoutMs?: number,
117
+ betweenBytesTimeoutMs?: number,
118
+ }
119
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,9 @@
1
+ export namespace UdpCreateSocket {
2
+ export function createUdpSocket(addressFamily: IpAddressFamily): UdpSocket;
3
+ }
4
+ import type { IpAddressFamily } from '../imports/network';
5
+ export { IpAddressFamily };
6
+ import type { UdpSocket } from '../imports/udp';
7
+ export { UdpSocket };
8
+ import type { Error } from '../imports/network';
9
+ export { Error };
@@ -0,0 +1,36 @@
1
+ export namespace Udp {
2
+ export function bind(this: UdpSocket, network: Network, localAddress: IpSocketAddress): void;
3
+ export function connect(this: UdpSocket, network: Network, remoteAddress: IpSocketAddress): void;
4
+ export function receive(this: UdpSocket): Datagram;
5
+ export function send(this: UdpSocket, datagram: Datagram): void;
6
+ export function localAddress(this: UdpSocket): IpSocketAddress;
7
+ export function remoteAddress(this: UdpSocket): IpSocketAddress;
8
+ export function addressFamily(this: UdpSocket): IpAddressFamily;
9
+ export function ipv6Only(this: UdpSocket): boolean;
10
+ export function setIpv6Only(this: UdpSocket, value: boolean): void;
11
+ export function unicastHopLimit(this: UdpSocket): number;
12
+ export function setUnicastHopLimit(this: UdpSocket, value: number): void;
13
+ export function receiveBufferSize(this: UdpSocket): bigint;
14
+ export function setReceiveBufferSize(this: UdpSocket, value: bigint): void;
15
+ export function sendBufferSize(this: UdpSocket): bigint;
16
+ export function setSendBufferSize(this: UdpSocket, value: bigint): void;
17
+ export function nonBlocking(this: UdpSocket): boolean;
18
+ export function setNonBlocking(this: UdpSocket, value: boolean): void;
19
+ export function subscribe(this: UdpSocket): Pollable;
20
+ export function dropUdpSocket(this: UdpSocket): void;
21
+ }
22
+ export type UdpSocket = number;
23
+ import type { Network } from '../imports/network';
24
+ export { Network };
25
+ import type { IpSocketAddress } from '../imports/network';
26
+ export { IpSocketAddress };
27
+ import type { Error } from '../imports/network';
28
+ export { Error };
29
+ export interface Datagram {
30
+ data: Uint8Array,
31
+ remoteAddress: IpSocketAddress,
32
+ }
33
+ import type { IpAddressFamily } from '../imports/network';
34
+ export { IpAddressFamily };
35
+ import type { Pollable } from '../imports/poll';
36
+ export { Pollable };
@@ -0,0 +1,10 @@
1
+ export namespace WallClock {
2
+ export function now(this: WallClock): Datetime;
3
+ export function resolution(this: WallClock): Datetime;
4
+ export function dropWallClock(this: WallClock): void;
5
+ }
6
+ export type WallClock = number;
7
+ export interface Datetime {
8
+ seconds: bigint,
9
+ nanoseconds: number,
10
+ }
package/types/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export * as clocks from "./types/wasi-clocks";
2
- export * as defaultClocks from "./types/wasi-default-clocks";
3
- export * as exit from "./types/wasi-exit";
4
- export * as filesystem from "./types/wasi-filesystem";
5
- export * as io from "./types/wasi-io";
6
- export * as logging from "./types/wasi-logging";
7
- export * as poll from "./types/wasi-poll";
8
- export * as random from "./types/wasi-random";
9
- export * as stderr from "./types/wasi-stderr";
1
+ import { ImportObject as WasiProxyImportObject } from "./wasi-proxy";
2
+ import { ImportObject as WasiReactorImportObject } from "./wasi-reactor";
3
+
4
+ export type ImportObject = WasiProxyImportObject & WasiReactorImportObject;
5
+
6
+ export declare const importObject: ImportObject;
7
+
8
+ export default importObject;
@@ -0,0 +1,44 @@
1
+ import { Random as RandomImports } from './imports/random';
2
+ import { Console as ConsoleImports } from './imports/console';
3
+ import { Poll as PollImports } from './imports/poll';
4
+ import { Streams as StreamsImports } from './imports/streams';
5
+ import { Types as TypesImports } from './imports/types';
6
+ import { DefaultOutgoingHttp as DefaultOutgoingHttpImports } from './imports/default-outgoing-HTTP';
7
+ import { Http as HttpExports } from './exports/HTTP';
8
+ export interface ImportObject {
9
+ 'random': typeof RandomImports,
10
+ 'console': typeof ConsoleImports,
11
+ 'poll': typeof PollImports,
12
+ 'streams': typeof StreamsImports,
13
+ 'types': typeof TypesImports,
14
+ 'default-outgoing-HTTP': typeof DefaultOutgoingHttpImports,
15
+ }
16
+ export interface WasiProxy {
17
+ 'HTTP': typeof HttpExports,
18
+ }
19
+
20
+ /**
21
+ * Instantiates this component with the provided imports and
22
+ * returns a map of all the exports of the component.
23
+ *
24
+ * This function is intended to be similar to the
25
+ * `WebAssembly.instantiate` function. The second `imports`
26
+ * argument is the "import object" for wasm, except here it
27
+ * uses component-model-layer types instead of core wasm
28
+ * integers/numbers/etc.
29
+ *
30
+ * The first argument to this function, `compileCore`, is
31
+ * used to compile core wasm modules within the component.
32
+ * Components are composed of core wasm modules and this callback
33
+ * will be invoked per core wasm module. The caller of this
34
+ * function is responsible for reading the core wasm module
35
+ * identified by `path` and returning its compiled
36
+ * WebAssembly.Module object. This would use `compileStreaming`
37
+ * on the web, for example.
38
+ */
39
+ export function instantiate(
40
+ compileCore: (path: string, imports: Record<string, any>) => Promise<WebAssembly.Module>,
41
+ imports: ImportObject,
42
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance>
43
+ ): Promise<WasiProxy>;
44
+
@@ -0,0 +1,70 @@
1
+ import { WallClock as WallClockImports } from './imports/wall-clock';
2
+ import { Poll as PollImports } from './imports/poll';
3
+ import { MonotonicClock as MonotonicClockImports } from './imports/monotonic-clock';
4
+ import { InstanceWallClock as InstanceWallClockImports } from './imports/instance-wall-clock';
5
+ import { InstanceMonotonicClock as InstanceMonotonicClockImports } from './imports/instance-monotonic-clock';
6
+ import { Timezone as TimezoneImports } from './imports/timezone';
7
+ import { Streams as StreamsImports } from './imports/streams';
8
+ import { Filesystem as FilesystemImports } from './imports/filesystem';
9
+ import { Network as NetworkImports } from './imports/network';
10
+ import { InstanceNetwork as InstanceNetworkImports } from './imports/instance-network';
11
+ import { IpNameLookup as IpNameLookupImports } from './imports/ip-name-lookup';
12
+ import { Tcp as TcpImports } from './imports/tcp';
13
+ import { TcpCreateSocket as TcpCreateSocketImports } from './imports/tcp-create-socket';
14
+ import { Udp as UdpImports } from './imports/udp';
15
+ import { UdpCreateSocket as UdpCreateSocketImports } from './imports/udp-create-socket';
16
+ import { Random as RandomImports } from './imports/random';
17
+ import { Environment as EnvironmentImports } from './imports/environment';
18
+ import { EnvironmentPreopens as EnvironmentPreopensImports } from './imports/environment-preopens';
19
+ import { Exit as ExitImports } from './imports/exit';
20
+ import { Stderr as StderrImports } from './imports/stderr';
21
+ export interface ImportObject {
22
+ 'wall-clock': typeof WallClockImports,
23
+ 'poll': typeof PollImports,
24
+ 'monotonic-clock': typeof MonotonicClockImports,
25
+ 'instance-wall-clock': typeof InstanceWallClockImports,
26
+ 'instance-monotonic-clock': typeof InstanceMonotonicClockImports,
27
+ 'timezone': typeof TimezoneImports,
28
+ 'streams': typeof StreamsImports,
29
+ 'filesystem': typeof FilesystemImports,
30
+ 'network': typeof NetworkImports,
31
+ 'instance-network': typeof InstanceNetworkImports,
32
+ 'ip-name-lookup': typeof IpNameLookupImports,
33
+ 'tcp': typeof TcpImports,
34
+ 'tcp-create-socket': typeof TcpCreateSocketImports,
35
+ 'udp': typeof UdpImports,
36
+ 'udp-create-socket': typeof UdpCreateSocketImports,
37
+ 'random': typeof RandomImports,
38
+ 'environment': typeof EnvironmentImports,
39
+ 'environment-preopens': typeof EnvironmentPreopensImports,
40
+ 'exit': typeof ExitImports,
41
+ 'stderr': typeof StderrImports,
42
+ }
43
+ export interface WasiReactor {
44
+ }
45
+
46
+ /**
47
+ * Instantiates this component with the provided imports and
48
+ * returns a map of all the exports of the component.
49
+ *
50
+ * This function is intended to be similar to the
51
+ * `WebAssembly.instantiate` function. The second `imports`
52
+ * argument is the "import object" for wasm, except here it
53
+ * uses component-model-layer types instead of core wasm
54
+ * integers/numbers/etc.
55
+ *
56
+ * The first argument to this function, `compileCore`, is
57
+ * used to compile core wasm modules within the component.
58
+ * Components are composed of core wasm modules and this callback
59
+ * will be invoked per core wasm module. The caller of this
60
+ * function is responsible for reading the core wasm module
61
+ * identified by `path` and returning its compiled
62
+ * WebAssembly.Module object. This would use `compileStreaming`
63
+ * on the web, for example.
64
+ */
65
+ export function instantiate(
66
+ compileCore: (path: string, imports: Record<string, any>) => Promise<WebAssembly.Module>,
67
+ imports: ImportObject,
68
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance>
69
+ ): Promise<WasiReactor>;
70
+
@@ -1,11 +0,0 @@
1
- export type MonotonicClock = number;
2
- export type Instant = bigint;
3
- export type WallClock = number;
4
- export interface Datetime {
5
- seconds: bigint,
6
- nanoseconds: number,
7
- }
8
- export namespace WasiClocks {
9
- export function monotonicClockNow(clock: MonotonicClock): Instant;
10
- export function wallClockNow(clock: WallClock): Datetime;
11
- }
@@ -1,6 +0,0 @@
1
- export type MonotonicClock = MonotonicClock;
2
- export type WallClock = WallClock;
3
- export namespace WasiDefaultClocks {
4
- export function defaultMonotonicClock(): MonotonicClock;
5
- export function defaultWallClock(): WallClock;
6
- }
@@ -1,3 +0,0 @@
1
- export namespace WasiExit {
2
- export function exit(status: { tag: 'err' | 'ok' }): void;
3
- }
@@ -1,150 +0,0 @@
1
- export type Descriptor = number;
2
- export type Filesize = bigint;
3
- export type InputStream = InputStream;
4
- /**
5
- * # Variants
6
- *
7
- * ## `"access"`
8
- *
9
- * ## `"again"`
10
- *
11
- * ## `"already"`
12
- *
13
- * ## `"badf"`
14
- *
15
- * ## `"busy"`
16
- *
17
- * ## `"deadlk"`
18
- *
19
- * ## `"dquot"`
20
- *
21
- * ## `"exist"`
22
- *
23
- * ## `"fbig"`
24
- *
25
- * ## `"ilseq"`
26
- *
27
- * ## `"inprogress"`
28
- *
29
- * ## `"intr"`
30
- *
31
- * ## `"inval"`
32
- *
33
- * ## `"io"`
34
- *
35
- * ## `"isdir"`
36
- *
37
- * ## `"loop"`
38
- *
39
- * ## `"mlink"`
40
- *
41
- * ## `"msgsize"`
42
- *
43
- * ## `"nametoolong"`
44
- *
45
- * ## `"nodev"`
46
- *
47
- * ## `"noent"`
48
- *
49
- * ## `"nolck"`
50
- *
51
- * ## `"nomem"`
52
- *
53
- * ## `"nospc"`
54
- *
55
- * ## `"nosys"`
56
- *
57
- * ## `"notdir"`
58
- *
59
- * ## `"notempty"`
60
- *
61
- * ## `"notrecoverable"`
62
- *
63
- * ## `"notsup"`
64
- *
65
- * ## `"notty"`
66
- *
67
- * ## `"nxio"`
68
- *
69
- * ## `"overflow"`
70
- *
71
- * ## `"perm"`
72
- *
73
- * ## `"pipe"`
74
- *
75
- * ## `"rofs"`
76
- *
77
- * ## `"spipe"`
78
- *
79
- * ## `"txtbsy"`
80
- *
81
- * ## `"xdev"`
82
- */
83
- export type Errno = 'access' | 'again' | 'already' | 'badf' | 'busy' | 'deadlk' | 'dquot' | 'exist' | 'fbig' | 'ilseq' | 'inprogress' | 'intr' | 'inval' | 'io' | 'isdir' | 'loop' | 'mlink' | 'msgsize' | 'nametoolong' | 'nodev' | 'noent' | 'nolck' | 'nomem' | 'nospc' | 'nosys' | 'notdir' | 'notempty' | 'notrecoverable' | 'notsup' | 'notty' | 'nxio' | 'overflow' | 'perm' | 'pipe' | 'rofs' | 'spipe' | 'txtbsy' | 'xdev';
84
- export type OutputStream = OutputStream;
85
- export type DirEntryStream = number;
86
- export type Device = bigint;
87
- export type Inode = bigint;
88
- /**
89
- * # Variants
90
- *
91
- * ## `"unknown"`
92
- *
93
- * ## `"block-device"`
94
- *
95
- * ## `"character-device"`
96
- *
97
- * ## `"directory"`
98
- *
99
- * ## `"fifo"`
100
- *
101
- * ## `"symbolic-link"`
102
- *
103
- * ## `"regular-file"`
104
- *
105
- * ## `"socket"`
106
- */
107
- export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
108
- export type Linkcount = bigint;
109
- export type Datetime = Datetime;
110
- export interface DescriptorStat {
111
- dev: Device,
112
- ino: Inode,
113
- type: DescriptorType,
114
- nlink: Linkcount,
115
- size: Filesize,
116
- atim: Datetime,
117
- mtim: Datetime,
118
- ctim: Datetime,
119
- }
120
- export interface AtFlags {
121
- symlinkFollow?: boolean,
122
- }
123
- export interface OFlags {
124
- create?: boolean,
125
- directory?: boolean,
126
- excl?: boolean,
127
- trunc?: boolean,
128
- }
129
- export interface DescriptorFlags {
130
- read?: boolean,
131
- write?: boolean,
132
- dsync?: boolean,
133
- nonblock?: boolean,
134
- rsync?: boolean,
135
- sync?: boolean,
136
- }
137
- export interface Mode {
138
- readable?: boolean,
139
- writeable?: boolean,
140
- executable?: boolean,
141
- }
142
- export namespace WasiFilesystem {
143
- export function readViaStream(fd: Descriptor, offset: Filesize): InputStream;
144
- export function writeViaStream(fd: Descriptor, offset: Filesize): OutputStream;
145
- export function appendViaStream(fd: Descriptor): OutputStream;
146
- export function closeDirEntryStream(s: DirEntryStream): void;
147
- export function stat(fd: Descriptor): DescriptorStat;
148
- export function openAt(fd: Descriptor, atFlags: AtFlags, path: string, oFlags: OFlags, flags: DescriptorFlags, mode: Mode): Descriptor;
149
- export function close(fd: Descriptor): void;
150
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * # Variants
3
- *
4
- * ## `"get"`
5
- *
6
- * ## `"post"`
7
- *
8
- * ## `"put"`
9
- *
10
- * ## `"delete"`
11
- *
12
- * ## `"patch"`
13
- *
14
- * ## `"head"`
15
- *
16
- * ## `"options"`
17
- */
18
- export type Method = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options';
19
- export type Uri = string;
20
- export type Headers = [string, string][];
21
- export type Params = [string, string][];
22
- export type Body = Uint8Array;
23
- export interface Request {
24
- method: Method,
25
- uri: Uri,
26
- headers: Headers,
27
- params: Params,
28
- body?: Body,
29
- }
30
- export type HttpStatus = number;
31
- export interface Response {
32
- status: HttpStatus,
33
- headers?: Headers,
34
- body?: Body,
35
- }
36
- export type HttpError = HttpErrorInvalidUrl | HttpErrorTimeoutError | HttpErrorProtocolError | HttpErrorUnexpectedError;
37
- export interface HttpErrorInvalidUrl {
38
- tag: 'invalid-url',
39
- val: string,
40
- }
41
- export interface HttpErrorTimeoutError {
42
- tag: 'timeout-error',
43
- val: string,
44
- }
45
- export interface HttpErrorProtocolError {
46
- tag: 'protocol-error',
47
- val: string,
48
- }
49
- export interface HttpErrorUnexpectedError {
50
- tag: 'unexpected-error',
51
- val: string,
52
- }
53
- export namespace WasiHttp {
54
- export function send(req: Request): Response;
55
- }
@@ -1,10 +0,0 @@
1
- export type InputStream = number;
2
- export interface StreamError {
3
- }
4
- export type OutputStream = number;
5
- export namespace WasiIo {
6
- export function read(src: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
7
- export function write(dst: OutputStream, buf: Uint8Array): bigint;
8
- export function dropInputStream(f: InputStream): void;
9
- export function dropOutputStream(f: OutputStream): void;
10
- }
@@ -1,4 +0,0 @@
1
- export type Pollable = number;
2
- export namespace WasiPoll {
3
- export function pollOneoff(input: Pollable[]): Uint8Array;
4
- }
@@ -1,3 +0,0 @@
1
- export namespace WasiRandom {
2
- export function getRandomBytes(len: number): Uint8Array | ArrayBuffer;
3
- }
File without changes
File without changes