@bytecodealliance/preview2-shim 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/default-outgoing-HTTP.js +3 -0
- package/lib/browser/environment-preopens.js +3 -0
- package/lib/browser/http.js +17 -10
- package/lib/browser/index.js +34 -12
- package/lib/browser/instance-monotonic-clock.js +3 -0
- package/lib/browser/instance-wall-clock.js +3 -0
- package/lib/browser/io.js +10 -23
- package/lib/browser/poll.js +4 -0
- package/lib/browser/preopens.js +11 -0
- package/lib/browser/random.js +1 -1
- package/lib/browser/streams.js +60 -0
- package/lib/browser/types.js +99 -0
- package/lib/http/error.js +1 -1
- package/lib/http/make-request.js +4 -4
- package/lib/http/synckit/index.d.ts +71 -0
- package/lib/http/synckit/index.js +141 -0
- package/lib/http/wasi-http.js +267 -0
- package/lib/nodejs/default-outgoing-HTTP.js +3 -0
- package/lib/nodejs/environment-preopens.js +3 -0
- package/lib/nodejs/environment.js +4 -0
- package/lib/nodejs/filesystem.js +7 -5
- package/lib/nodejs/http.js +4 -4
- package/lib/nodejs/index.js +34 -12
- package/lib/nodejs/instance-monotonic-clock.js +3 -0
- package/lib/nodejs/instance-wall-clock.js +3 -0
- package/lib/nodejs/io.js +16 -24
- package/lib/nodejs/monotonic-clock.js +4 -0
- package/lib/nodejs/poll.js +4 -0
- package/lib/nodejs/preopens.js +11 -0
- package/lib/nodejs/random.js +1 -1
- package/lib/nodejs/streams.js +63 -0
- package/lib/nodejs/types.js +99 -0
- package/lib/nodejs/wall-clock.js +4 -0
- package/package.json +18 -3
- package/types/exports/HTTP.d.ts +7 -0
- package/types/imports/console.d.ts +17 -0
- package/types/imports/default-outgoing-HTTP.d.ts +9 -0
- package/types/imports/environment-preopens.d.ts +5 -0
- package/types/imports/environment.d.ts +3 -0
- package/types/imports/exit.d.ts +4 -0
- package/types/imports/filesystem.d.ts +212 -0
- package/types/imports/instance-monotonic-clock.d.ts +5 -0
- package/types/imports/instance-network.d.ts +5 -0
- package/types/imports/instance-wall-clock.d.ts +5 -0
- package/types/imports/ip-name-lookup.d.ts +19 -0
- package/types/imports/monotonic-clock.d.ts +10 -0
- package/types/imports/network.d.ts +50 -0
- package/types/imports/poll.d.ts +5 -0
- package/types/imports/preopens.d.ts +15 -0
- package/types/imports/random.d.ts +5 -0
- package/types/{wasi-stderr.d.ts → imports/stderr.d.ts} +1 -1
- package/types/imports/streams.d.ts +23 -0
- package/types/imports/tcp-create-socket.d.ts +9 -0
- package/types/imports/tcp.d.ts +52 -0
- package/types/imports/timezone.d.ts +13 -0
- package/types/imports/types.d.ts +119 -0
- package/types/imports/udp-create-socket.d.ts +9 -0
- package/types/imports/udp.d.ts +36 -0
- package/types/imports/wall-clock.d.ts +10 -0
- package/types/index.d.ts +8 -9
- package/types/wasi-proxy.d.ts +44 -0
- package/types/wasi-reactor.d.ts +72 -0
- package/lib/browser/clocks.js +0 -47
- package/lib/browser/default-clocks.js +0 -7
- package/lib/nodejs/default-clocks.js +0 -7
- package/types/wasi-clocks.d.ts +0 -11
- package/types/wasi-default-clocks.d.ts +0 -6
- package/types/wasi-exit.d.ts +0 -3
- package/types/wasi-filesystem.d.ts +0 -150
- package/types/wasi-http.d.ts +0 -55
- package/types/wasi-io.d.ts +0 -10
- package/types/wasi-poll.d.ts +0 -4
- package/types/wasi-random.d.ts +0 -3
- /package/lib/browser/{logging.js → console.js} +0 -0
- /package/lib/nodejs/{logging.js → console.js} +0 -0
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export
|
|
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,72 @@
|
|
|
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 { Preopens as PreopensImports } from './imports/preopens';
|
|
20
|
+
import { Exit as ExitImports } from './imports/exit';
|
|
21
|
+
import { Stderr as StderrImports } from './imports/stderr';
|
|
22
|
+
export interface ImportObject {
|
|
23
|
+
'wall-clock': typeof WallClockImports,
|
|
24
|
+
'poll': typeof PollImports,
|
|
25
|
+
'monotonic-clock': typeof MonotonicClockImports,
|
|
26
|
+
'instance-wall-clock': typeof InstanceWallClockImports,
|
|
27
|
+
'instance-monotonic-clock': typeof InstanceMonotonicClockImports,
|
|
28
|
+
'timezone': typeof TimezoneImports,
|
|
29
|
+
'streams': typeof StreamsImports,
|
|
30
|
+
'filesystem': typeof FilesystemImports,
|
|
31
|
+
'network': typeof NetworkImports,
|
|
32
|
+
'instance-network': typeof InstanceNetworkImports,
|
|
33
|
+
'ip-name-lookup': typeof IpNameLookupImports,
|
|
34
|
+
'tcp': typeof TcpImports,
|
|
35
|
+
'tcp-create-socket': typeof TcpCreateSocketImports,
|
|
36
|
+
'udp': typeof UdpImports,
|
|
37
|
+
'udp-create-socket': typeof UdpCreateSocketImports,
|
|
38
|
+
'random': typeof RandomImports,
|
|
39
|
+
'environment': typeof EnvironmentImports,
|
|
40
|
+
'environment-preopens': typeof EnvironmentPreopensImports,
|
|
41
|
+
'preopens': typeof PreopensImports,
|
|
42
|
+
'exit': typeof ExitImports,
|
|
43
|
+
'stderr': typeof StderrImports,
|
|
44
|
+
}
|
|
45
|
+
export interface WasiReactor {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Instantiates this component with the provided imports and
|
|
50
|
+
* returns a map of all the exports of the component.
|
|
51
|
+
*
|
|
52
|
+
* This function is intended to be similar to the
|
|
53
|
+
* `WebAssembly.instantiate` function. The second `imports`
|
|
54
|
+
* argument is the "import object" for wasm, except here it
|
|
55
|
+
* uses component-model-layer types instead of core wasm
|
|
56
|
+
* integers/numbers/etc.
|
|
57
|
+
*
|
|
58
|
+
* The first argument to this function, `compileCore`, is
|
|
59
|
+
* used to compile core wasm modules within the component.
|
|
60
|
+
* Components are composed of core wasm modules and this callback
|
|
61
|
+
* will be invoked per core wasm module. The caller of this
|
|
62
|
+
* function is responsible for reading the core wasm module
|
|
63
|
+
* identified by `path` and returning its compiled
|
|
64
|
+
* WebAssembly.Module object. This would use `compileStreaming`
|
|
65
|
+
* on the web, for example.
|
|
66
|
+
*/
|
|
67
|
+
export function instantiate(
|
|
68
|
+
compileCore: (path: string, imports: Record<string, any>) => Promise<WebAssembly.Module>,
|
|
69
|
+
imports: ImportObject,
|
|
70
|
+
instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance>
|
|
71
|
+
): Promise<WasiReactor>;
|
|
72
|
+
|
package/lib/browser/clocks.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export function wallClockNow(clock) {
|
|
2
|
-
if (clock === 1) {
|
|
3
|
-
const seconds = BigInt(Math.floor(Date.now() / 1000));
|
|
4
|
-
const nanoseconds = (Date.now() % 1000) * 1000 * 1000;
|
|
5
|
-
return { seconds, nanoseconds };
|
|
6
|
-
}
|
|
7
|
-
console.log("[clocks] UNKNOWN CLOCK");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function monotonicClockResolution(clock) {
|
|
11
|
-
console.log(`[clocks] Monotonic clock resolution ${clock}`);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function wallClockResolution(clock) {
|
|
15
|
-
console.log(`[clocks] Wall clock resolution ${clock}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let hrStart = hrtimeBigint();
|
|
19
|
-
|
|
20
|
-
export function monotonicClockNow(clock) {
|
|
21
|
-
if (clock === 0) {
|
|
22
|
-
return hrtimeBigint() - hrStart;
|
|
23
|
-
}
|
|
24
|
-
console.log("UNKNOWN CLOCK");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function hrtime(previousTimestamp) {
|
|
28
|
-
const baseNow = Math.floor((Date.now() - performance.now()) * 1e-3);
|
|
29
|
-
const clocktime = performance.now() * 1e-3;
|
|
30
|
-
let seconds = Math.floor(clocktime) + baseNow;
|
|
31
|
-
let nanoseconds = Math.floor((clocktime % 1) * 1e9);
|
|
32
|
-
|
|
33
|
-
if (previousTimestamp) {
|
|
34
|
-
seconds = seconds - previousTimestamp[0];
|
|
35
|
-
nanoseconds = nanoseconds - previousTimestamp[1];
|
|
36
|
-
if (nanoseconds < 0) {
|
|
37
|
-
seconds--;
|
|
38
|
-
nanoseconds += 1e9;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return [seconds, nanoseconds];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function hrtimeBigint(time) {
|
|
45
|
-
const diff = hrtime(time);
|
|
46
|
-
return BigInt(diff[0] * 1e9 + diff[1]);
|
|
47
|
-
}
|
package/types/wasi-clocks.d.ts
DELETED
|
@@ -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
|
-
}
|
package/types/wasi-exit.d.ts
DELETED
|
@@ -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
|
-
}
|
package/types/wasi-http.d.ts
DELETED
|
@@ -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
|
-
}
|
package/types/wasi-io.d.ts
DELETED
|
@@ -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
|
-
}
|
package/types/wasi-poll.d.ts
DELETED
package/types/wasi-random.d.ts
DELETED
|
File without changes
|
|
File without changes
|