@bytecodealliance/preview3-shim 0.2.2 → 0.3.1
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/browser/cli/environment.d.ts +10 -0
- package/dist/browser/cli/environment.js +15 -0
- package/dist/browser/cli/exit.d.ts +9 -0
- package/dist/browser/cli/exit.js +11 -0
- package/dist/browser/cli/run.d.ts +6 -0
- package/dist/browser/cli/run.js +7 -0
- package/dist/browser/cli/stderr.d.ts +7 -0
- package/dist/browser/cli/stderr.js +7 -0
- package/dist/browser/cli/stdin.d.ts +7 -0
- package/dist/browser/cli/stdin.js +7 -0
- package/dist/browser/cli/stdout.d.ts +7 -0
- package/dist/browser/cli/stdout.js +7 -0
- package/dist/browser/cli/terminal-input.d.ts +8 -0
- package/dist/browser/cli/terminal-input.js +5 -0
- package/dist/browser/cli/terminal-output.d.ts +8 -0
- package/dist/browser/cli/terminal-output.js +5 -0
- package/dist/browser/cli/terminal-stderr.d.ts +7 -0
- package/dist/browser/cli/terminal-stderr.js +7 -0
- package/dist/browser/cli/terminal-stdin.d.ts +7 -0
- package/dist/browser/cli/terminal-stdin.js +7 -0
- package/dist/browser/cli/terminal-stdout.d.ts +7 -0
- package/dist/browser/cli/terminal-stdout.js +7 -0
- package/dist/browser/cli.d.ts +11 -0
- package/dist/browser/cli.js +11 -0
- package/dist/browser/clocks/monotonic-clock.d.ts +13 -0
- package/dist/browser/clocks/monotonic-clock.js +19 -0
- package/dist/browser/clocks/system-clock.d.ts +9 -0
- package/dist/browser/clocks/system-clock.js +11 -0
- package/dist/browser/clocks/types.d.ts +3 -0
- package/dist/browser/clocks/types.js +1 -0
- package/dist/browser/clocks.d.ts +3 -0
- package/dist/browser/clocks.js +3 -0
- package/dist/browser/filesystem/preopens.d.ts +7 -0
- package/dist/browser/filesystem/preopens.js +7 -0
- package/dist/browser/filesystem/types.d.ts +33 -0
- package/dist/browser/filesystem/types.js +81 -0
- package/dist/browser/filesystem.d.ts +2 -0
- package/dist/browser/filesystem.js +2 -0
- package/dist/browser/http/client.d.ts +7 -0
- package/dist/browser/http/client.js +7 -0
- package/dist/browser/http/handler.d.ts +7 -0
- package/dist/browser/http/handler.js +7 -0
- package/dist/browser/http/types.d.ts +50 -0
- package/dist/browser/http/types.js +114 -0
- package/dist/browser/http.d.ts +3 -0
- package/dist/browser/http.js +3 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/index.js +6 -0
- package/dist/browser/random/insecure-seed.d.ts +6 -0
- package/dist/browser/random/insecure-seed.js +7 -0
- package/dist/browser/random/insecure.d.ts +8 -0
- package/dist/browser/random/insecure.js +11 -0
- package/dist/browser/random/random.d.ts +8 -0
- package/dist/browser/random/random.js +11 -0
- package/dist/browser/random.d.ts +3 -0
- package/dist/browser/random.js +3 -0
- package/dist/browser/sockets/ip-name-lookup.d.ts +7 -0
- package/dist/browser/sockets/ip-name-lookup.js +7 -0
- package/dist/browser/sockets/types.d.ts +51 -0
- package/dist/browser/sockets/types.js +129 -0
- package/dist/browser/sockets.d.ts +2 -0
- package/dist/browser/sockets.js +2 -0
- package/dist/common/errors.d.ts +3 -0
- package/dist/common/errors.js +5 -0
- package/dist/nodejs/cli.d.ts +1 -1
- package/dist/nodejs/clocks.d.ts +2 -2
- package/dist/nodejs/filesystem/descriptor.d.ts +2 -2
- package/dist/nodejs/sockets/address.d.ts +2 -2
- package/dist/nodejs/sockets/tcp.d.ts +1 -1
- package/dist/nodejs/sockets/tcp.js +1 -1
- package/dist/nodejs/sockets/udp.js +1 -1
- package/dist/nodejs/workers/cli-worker.bundle.js +3 -1
- package/dist/nodejs/workers/filesystem-worker.bundle.js +1 -1
- package/dist/nodejs/workers/http-worker.bundle.js +2 -1
- package/package.json +16 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare function getEnvironment(): Array<[string, string]>;
|
|
2
|
+
declare function getArguments(): Array<string>;
|
|
3
|
+
declare function getInitialCwd(): string | undefined;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
getEnvironment: typeof getEnvironment;
|
|
6
|
+
getArguments: typeof getArguments;
|
|
7
|
+
getInitialCwd: typeof getInitialCwd;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
10
|
+
export type * from "../../../types/interfaces/wasi-cli-environment.d.ts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Todo } from "../../common/errors.js";
|
|
2
|
+
function getEnvironment() {
|
|
3
|
+
throw new Todo();
|
|
4
|
+
}
|
|
5
|
+
function getArguments() {
|
|
6
|
+
throw new Todo();
|
|
7
|
+
}
|
|
8
|
+
function getInitialCwd() {
|
|
9
|
+
throw new Todo();
|
|
10
|
+
}
|
|
11
|
+
export default {
|
|
12
|
+
getEnvironment,
|
|
13
|
+
getArguments,
|
|
14
|
+
getInitialCwd,
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result } from "../../../types/interfaces/wasi-cli-exit.d.ts";
|
|
2
|
+
declare function exit(status: Result<void, void>): void;
|
|
3
|
+
declare function exitWithCode(statusCode: number): void;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
exit: typeof exit;
|
|
6
|
+
exitWithCode: typeof exitWithCode;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
export type * from "../../../types/interfaces/wasi-cli-exit.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Result, ErrorCode } from "../../../types/interfaces/wasi-cli-stderr.d.ts";
|
|
2
|
+
declare function writeViaStream(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
writeViaStream: typeof writeViaStream;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-stderr.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Result, ErrorCode } from "../../../types/interfaces/wasi-cli-stdin.d.ts";
|
|
2
|
+
declare function readViaStream(): [ReadableStream<number>, Promise<Result<void, ErrorCode>>];
|
|
3
|
+
declare const _default: {
|
|
4
|
+
readViaStream: typeof readViaStream;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-stdin.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Result, ErrorCode } from "../../../types/interfaces/wasi-cli-stdout.d.ts";
|
|
2
|
+
declare function writeViaStream(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
writeViaStream: typeof writeViaStream;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-stdout.d.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TerminalInput as TerminalInputT } from "../../../types/interfaces/wasi-cli-terminal-input.d.ts";
|
|
2
|
+
declare class TerminalInput implements TerminalInputT {
|
|
3
|
+
}
|
|
4
|
+
declare const _default: {
|
|
5
|
+
TerminalInput: typeof TerminalInput;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export type * from "../../../types/interfaces/wasi-cli-terminal-input.d.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TerminalOutput as TerminalOutputT } from "../../../types/interfaces/wasi-cli-terminal-output.d.ts";
|
|
2
|
+
declare class TerminalOutput implements TerminalOutputT {
|
|
3
|
+
}
|
|
4
|
+
declare const _default: {
|
|
5
|
+
TerminalOutput: typeof TerminalOutput;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export type * from "../../../types/interfaces/wasi-cli-terminal-output.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TerminalOutput } from "../../../types/interfaces/wasi-cli-terminal-stderr.d.ts";
|
|
2
|
+
declare function getTerminalStderr(): TerminalOutput | undefined;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getTerminalStderr: typeof getTerminalStderr;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-terminal-stderr.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TerminalInput } from "../../../types/interfaces/wasi-cli-terminal-stdin.d.ts";
|
|
2
|
+
declare function getTerminalStdin(): TerminalInput | undefined;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getTerminalStdin: typeof getTerminalStdin;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-terminal-stdin.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TerminalOutput } from "../../../types/interfaces/wasi-cli-terminal-stdout.d.ts";
|
|
2
|
+
declare function getTerminalStdout(): TerminalOutput | undefined;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getTerminalStdout: typeof getTerminalStdout;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-cli-terminal-stdout.d.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as environment } from "./cli/environment.js";
|
|
2
|
+
export { default as exit } from "./cli/exit.js";
|
|
3
|
+
export { default as run } from "./cli/run.js";
|
|
4
|
+
export { default as stderr } from "./cli/stderr.js";
|
|
5
|
+
export { default as stdin } from "./cli/stdin.js";
|
|
6
|
+
export { default as stdout } from "./cli/stdout.js";
|
|
7
|
+
export { default as terminalInput } from "./cli/terminal-input.js";
|
|
8
|
+
export { default as terminalOutput } from "./cli/terminal-output.js";
|
|
9
|
+
export { default as terminalStderr } from "./cli/terminal-stderr.js";
|
|
10
|
+
export { default as terminalStdin } from "./cli/terminal-stdin.js";
|
|
11
|
+
export { default as terminalStdout } from "./cli/terminal-stdout.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as environment } from "./cli/environment.js";
|
|
2
|
+
export { default as exit } from "./cli/exit.js";
|
|
3
|
+
export { default as run } from "./cli/run.js";
|
|
4
|
+
export { default as stderr } from "./cli/stderr.js";
|
|
5
|
+
export { default as stdin } from "./cli/stdin.js";
|
|
6
|
+
export { default as stdout } from "./cli/stdout.js";
|
|
7
|
+
export { default as terminalInput } from "./cli/terminal-input.js";
|
|
8
|
+
export { default as terminalOutput } from "./cli/terminal-output.js";
|
|
9
|
+
export { default as terminalStderr } from "./cli/terminal-stderr.js";
|
|
10
|
+
export { default as terminalStdin } from "./cli/terminal-stdin.js";
|
|
11
|
+
export { default as terminalStdout } from "./cli/terminal-stdout.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Mark, Duration } from "../../../types/interfaces/wasi-clocks-monotonic-clock.d.ts";
|
|
2
|
+
declare function now(): Mark;
|
|
3
|
+
declare function getResolution(): Duration;
|
|
4
|
+
declare function waitUntil(when: Mark): Promise<void>;
|
|
5
|
+
declare function waitFor(howLong: Duration): Promise<void>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
now: typeof now;
|
|
8
|
+
getResolution: typeof getResolution;
|
|
9
|
+
waitUntil: typeof waitUntil;
|
|
10
|
+
waitFor: typeof waitFor;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
export type * from "../../../types/interfaces/wasi-clocks-monotonic-clock.d.ts";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Todo } from "../../common/errors.js";
|
|
2
|
+
function now() {
|
|
3
|
+
throw new Todo();
|
|
4
|
+
}
|
|
5
|
+
function getResolution() {
|
|
6
|
+
throw new Todo();
|
|
7
|
+
}
|
|
8
|
+
function waitUntil(when) {
|
|
9
|
+
throw new Todo();
|
|
10
|
+
}
|
|
11
|
+
function waitFor(howLong) {
|
|
12
|
+
throw new Todo();
|
|
13
|
+
}
|
|
14
|
+
export default {
|
|
15
|
+
now,
|
|
16
|
+
getResolution,
|
|
17
|
+
waitUntil,
|
|
18
|
+
waitFor,
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Instant, Duration } from "../../../types/interfaces/wasi-clocks-system-clock.d.ts";
|
|
2
|
+
declare function now(): Instant;
|
|
3
|
+
declare function getResolution(): Duration;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
now: typeof now;
|
|
6
|
+
getResolution: typeof getResolution;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
export type * from "../../../types/interfaces/wasi-clocks-system-clock.d.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Descriptor } from "../../../types/interfaces/wasi-filesystem-preopens.d.ts";
|
|
2
|
+
declare function getDirectories(): Array<[Descriptor, string]>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getDirectories: typeof getDirectories;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-filesystem-preopens.d.ts";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Descriptor as DescriptorT, Advice, DescriptorFlags, DescriptorStat, DescriptorType, DirectoryEntry, ErrorCode, Filesize, MetadataHashValue, NewTimestamp, OpenFlags, PathFlags, Result } from "../../../types/interfaces/wasi-filesystem-types.d.ts";
|
|
2
|
+
declare class Descriptor implements DescriptorT {
|
|
3
|
+
readViaStream(offset: Filesize): [ReadableStream<number>, Promise<Result<void, ErrorCode>>];
|
|
4
|
+
writeViaStream(data: ReadableStream<number>, offset: Filesize): Promise<Result<void, ErrorCode>>;
|
|
5
|
+
appendViaStream(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
6
|
+
advise(offset: Filesize, length: Filesize, advice: Advice): Promise<void>;
|
|
7
|
+
syncData(): Promise<void>;
|
|
8
|
+
getFlags(): Promise<DescriptorFlags>;
|
|
9
|
+
getType(): Promise<DescriptorType>;
|
|
10
|
+
setSize(size: Filesize): Promise<void>;
|
|
11
|
+
setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise<void>;
|
|
12
|
+
readDirectory(): [ReadableStream<DirectoryEntry>, Promise<Result<void, ErrorCode>>];
|
|
13
|
+
sync(): Promise<void>;
|
|
14
|
+
createDirectoryAt(path: string): Promise<void>;
|
|
15
|
+
stat(): Promise<DescriptorStat>;
|
|
16
|
+
statAt(pathFlags: PathFlags, path: string): Promise<DescriptorStat>;
|
|
17
|
+
setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): Promise<void>;
|
|
18
|
+
linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): Promise<void>;
|
|
19
|
+
openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Promise<Descriptor>;
|
|
20
|
+
readlinkAt(path: string): Promise<string>;
|
|
21
|
+
removeDirectoryAt(path: string): Promise<void>;
|
|
22
|
+
renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): Promise<void>;
|
|
23
|
+
symlinkAt(oldPath: string, newPath: string): Promise<void>;
|
|
24
|
+
unlinkFileAt(path: string): Promise<void>;
|
|
25
|
+
isSameObject(other: Descriptor): Promise<boolean>;
|
|
26
|
+
metadataHash(): Promise<MetadataHashValue>;
|
|
27
|
+
metadataHashAt(pathFlags: PathFlags, path: string): Promise<MetadataHashValue>;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: {
|
|
30
|
+
Descriptor: typeof Descriptor;
|
|
31
|
+
};
|
|
32
|
+
export default _default;
|
|
33
|
+
export type * from "../../../types/interfaces/wasi-filesystem-types.d.ts";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Todo } from "../../common/errors.js";
|
|
2
|
+
class Descriptor {
|
|
3
|
+
readViaStream(offset) {
|
|
4
|
+
throw new Todo();
|
|
5
|
+
}
|
|
6
|
+
writeViaStream(data, offset) {
|
|
7
|
+
throw new Todo();
|
|
8
|
+
}
|
|
9
|
+
appendViaStream(data) {
|
|
10
|
+
throw new Todo();
|
|
11
|
+
}
|
|
12
|
+
advise(offset, length, advice) {
|
|
13
|
+
throw new Todo();
|
|
14
|
+
}
|
|
15
|
+
syncData() {
|
|
16
|
+
throw new Todo();
|
|
17
|
+
}
|
|
18
|
+
getFlags() {
|
|
19
|
+
throw new Todo();
|
|
20
|
+
}
|
|
21
|
+
getType() {
|
|
22
|
+
throw new Todo();
|
|
23
|
+
}
|
|
24
|
+
setSize(size) {
|
|
25
|
+
throw new Todo();
|
|
26
|
+
}
|
|
27
|
+
setTimes(dataAccessTimestamp, dataModificationTimestamp) {
|
|
28
|
+
throw new Todo();
|
|
29
|
+
}
|
|
30
|
+
readDirectory() {
|
|
31
|
+
throw new Todo();
|
|
32
|
+
}
|
|
33
|
+
sync() {
|
|
34
|
+
throw new Todo();
|
|
35
|
+
}
|
|
36
|
+
createDirectoryAt(path) {
|
|
37
|
+
throw new Todo();
|
|
38
|
+
}
|
|
39
|
+
stat() {
|
|
40
|
+
throw new Todo();
|
|
41
|
+
}
|
|
42
|
+
statAt(pathFlags, path) {
|
|
43
|
+
throw new Todo();
|
|
44
|
+
}
|
|
45
|
+
setTimesAt(pathFlags, path, dataAccessTimestamp, dataModificationTimestamp) {
|
|
46
|
+
throw new Todo();
|
|
47
|
+
}
|
|
48
|
+
linkAt(oldPathFlags, oldPath, newDescriptor, newPath) {
|
|
49
|
+
throw new Todo();
|
|
50
|
+
}
|
|
51
|
+
openAt(pathFlags, path, openFlags, flags) {
|
|
52
|
+
throw new Todo();
|
|
53
|
+
}
|
|
54
|
+
readlinkAt(path) {
|
|
55
|
+
throw new Todo();
|
|
56
|
+
}
|
|
57
|
+
removeDirectoryAt(path) {
|
|
58
|
+
throw new Todo();
|
|
59
|
+
}
|
|
60
|
+
renameAt(oldPath, newDescriptor, newPath) {
|
|
61
|
+
throw new Todo();
|
|
62
|
+
}
|
|
63
|
+
symlinkAt(oldPath, newPath) {
|
|
64
|
+
throw new Todo();
|
|
65
|
+
}
|
|
66
|
+
unlinkFileAt(path) {
|
|
67
|
+
throw new Todo();
|
|
68
|
+
}
|
|
69
|
+
isSameObject(other) {
|
|
70
|
+
throw new Todo();
|
|
71
|
+
}
|
|
72
|
+
metadataHash() {
|
|
73
|
+
throw new Todo();
|
|
74
|
+
}
|
|
75
|
+
metadataHashAt(pathFlags, path) {
|
|
76
|
+
throw new Todo();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default {
|
|
80
|
+
Descriptor,
|
|
81
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Request, Response } from "../../../types/interfaces/wasi-http-client.d.ts";
|
|
2
|
+
declare function send(request: Request): Promise<Response>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
send: typeof send;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-http-client.d.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Request, Response } from "../../../types/interfaces/wasi-http-handler.d.ts";
|
|
2
|
+
declare function handle(request: Request): Promise<Response>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
handle: typeof handle;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-http-handler.d.ts";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Fields as FieldsT, Request as RequestT, RequestOptions as RequestOptionsT, Response as ResponseT, FieldName, FieldValue, Headers, Method, Scheme, Duration, StatusCode, Trailers, ErrorCode, Result } from "../../../types/interfaces/wasi-http-types.d.ts";
|
|
2
|
+
declare class Fields implements FieldsT {
|
|
3
|
+
static fromList(entries: Array<[FieldName, FieldValue]>): FieldsT;
|
|
4
|
+
get(name: FieldName): Array<FieldValue>;
|
|
5
|
+
has(name: FieldName): boolean;
|
|
6
|
+
set(name: FieldName, value: Array<FieldValue>): void;
|
|
7
|
+
delete(name: FieldName): void;
|
|
8
|
+
getAndDelete(name: FieldName): Array<FieldValue>;
|
|
9
|
+
append(name: FieldName, value: FieldValue): void;
|
|
10
|
+
copyAll(): Array<[FieldName, FieldValue]>;
|
|
11
|
+
clone(): FieldsT;
|
|
12
|
+
}
|
|
13
|
+
declare class Request implements RequestT {
|
|
14
|
+
static new(headers: Headers, contents: ReadableStream<number> | undefined, trailers: Promise<Result<Trailers | undefined, ErrorCode>>, options: RequestOptions | undefined): [Request, Promise<Result<void, ErrorCode>>];
|
|
15
|
+
getMethod(): Method;
|
|
16
|
+
setMethod(method: Method): void;
|
|
17
|
+
getPathWithQuery(): string | undefined;
|
|
18
|
+
setPathWithQuery(pathWithQuery: string | undefined): void;
|
|
19
|
+
getScheme(): Scheme | undefined;
|
|
20
|
+
setScheme(scheme: Scheme | undefined): void;
|
|
21
|
+
getAuthority(): string | undefined;
|
|
22
|
+
setAuthority(authority: string | undefined): void;
|
|
23
|
+
getOptions(): RequestOptionsT | undefined;
|
|
24
|
+
getHeaders(): Headers;
|
|
25
|
+
static consumeBody(this_: Request, res: Promise<Result<void, ErrorCode>>): [ReadableStream<number>, Promise<Result<Trailers | undefined, ErrorCode>>];
|
|
26
|
+
}
|
|
27
|
+
declare class RequestOptions implements RequestOptionsT {
|
|
28
|
+
getConnectTimeout(): Duration | undefined;
|
|
29
|
+
setConnectTimeout(duration: Duration | undefined): void;
|
|
30
|
+
getFirstByteTimeout(): Duration | undefined;
|
|
31
|
+
setFirstByteTimeout(duration: Duration | undefined): void;
|
|
32
|
+
getBetweenBytesTimeout(): Duration | undefined;
|
|
33
|
+
setBetweenBytesTimeout(duration: Duration | undefined): void;
|
|
34
|
+
clone(): RequestOptionsT;
|
|
35
|
+
}
|
|
36
|
+
declare class Response implements ResponseT {
|
|
37
|
+
static new(headers: Headers, contents: ReadableStream<number> | undefined, trailers: Promise<Result<Trailers | undefined, ErrorCode>>): [Response, Promise<Result<void, ErrorCode>>];
|
|
38
|
+
getStatusCode(): StatusCode;
|
|
39
|
+
setStatusCode(statusCode: StatusCode): void;
|
|
40
|
+
getHeaders(): Headers;
|
|
41
|
+
static consumeBody(this_: Response, res: Promise<Result<void, ErrorCode>>): [ReadableStream<number>, Promise<Result<Trailers | undefined, ErrorCode>>];
|
|
42
|
+
}
|
|
43
|
+
declare const _default: {
|
|
44
|
+
Fields: typeof Fields;
|
|
45
|
+
Request: typeof Request;
|
|
46
|
+
RequestOptions: typeof RequestOptions;
|
|
47
|
+
Response: typeof Response;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
50
|
+
export type * from "../../../types/interfaces/wasi-http-types.d.ts";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Todo } from "../../common/errors.js";
|
|
2
|
+
class Fields {
|
|
3
|
+
static fromList(entries) {
|
|
4
|
+
throw new Todo();
|
|
5
|
+
}
|
|
6
|
+
get(name) {
|
|
7
|
+
throw new Todo();
|
|
8
|
+
}
|
|
9
|
+
has(name) {
|
|
10
|
+
throw new Todo();
|
|
11
|
+
}
|
|
12
|
+
set(name, value) {
|
|
13
|
+
throw new Todo();
|
|
14
|
+
}
|
|
15
|
+
delete(name) {
|
|
16
|
+
throw new Todo();
|
|
17
|
+
}
|
|
18
|
+
getAndDelete(name) {
|
|
19
|
+
throw new Todo();
|
|
20
|
+
}
|
|
21
|
+
append(name, value) {
|
|
22
|
+
throw new Todo();
|
|
23
|
+
}
|
|
24
|
+
copyAll() {
|
|
25
|
+
throw new Todo();
|
|
26
|
+
}
|
|
27
|
+
clone() {
|
|
28
|
+
throw new Todo();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class Request {
|
|
32
|
+
static new(headers, contents, trailers, options) {
|
|
33
|
+
throw new Todo();
|
|
34
|
+
}
|
|
35
|
+
getMethod() {
|
|
36
|
+
throw new Todo();
|
|
37
|
+
}
|
|
38
|
+
setMethod(method) {
|
|
39
|
+
throw new Todo();
|
|
40
|
+
}
|
|
41
|
+
getPathWithQuery() {
|
|
42
|
+
throw new Todo();
|
|
43
|
+
}
|
|
44
|
+
setPathWithQuery(pathWithQuery) {
|
|
45
|
+
throw new Todo();
|
|
46
|
+
}
|
|
47
|
+
getScheme() {
|
|
48
|
+
throw new Todo();
|
|
49
|
+
}
|
|
50
|
+
setScheme(scheme) {
|
|
51
|
+
throw new Todo();
|
|
52
|
+
}
|
|
53
|
+
getAuthority() {
|
|
54
|
+
throw new Todo();
|
|
55
|
+
}
|
|
56
|
+
setAuthority(authority) {
|
|
57
|
+
throw new Todo();
|
|
58
|
+
}
|
|
59
|
+
getOptions() {
|
|
60
|
+
throw new Todo();
|
|
61
|
+
}
|
|
62
|
+
getHeaders() {
|
|
63
|
+
throw new Todo();
|
|
64
|
+
}
|
|
65
|
+
static consumeBody(this_, res) {
|
|
66
|
+
throw new Todo();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class RequestOptions {
|
|
70
|
+
getConnectTimeout() {
|
|
71
|
+
throw new Todo();
|
|
72
|
+
}
|
|
73
|
+
setConnectTimeout(duration) {
|
|
74
|
+
throw new Todo();
|
|
75
|
+
}
|
|
76
|
+
getFirstByteTimeout() {
|
|
77
|
+
throw new Todo();
|
|
78
|
+
}
|
|
79
|
+
setFirstByteTimeout(duration) {
|
|
80
|
+
throw new Todo();
|
|
81
|
+
}
|
|
82
|
+
getBetweenBytesTimeout() {
|
|
83
|
+
throw new Todo();
|
|
84
|
+
}
|
|
85
|
+
setBetweenBytesTimeout(duration) {
|
|
86
|
+
throw new Todo();
|
|
87
|
+
}
|
|
88
|
+
clone() {
|
|
89
|
+
throw new Todo();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
class Response {
|
|
93
|
+
static new(headers, contents, trailers) {
|
|
94
|
+
throw new Todo();
|
|
95
|
+
}
|
|
96
|
+
getStatusCode() {
|
|
97
|
+
throw new Todo();
|
|
98
|
+
}
|
|
99
|
+
setStatusCode(statusCode) {
|
|
100
|
+
throw new Todo();
|
|
101
|
+
}
|
|
102
|
+
getHeaders() {
|
|
103
|
+
throw new Todo();
|
|
104
|
+
}
|
|
105
|
+
static consumeBody(this_, res) {
|
|
106
|
+
throw new Todo();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export default {
|
|
110
|
+
Fields,
|
|
111
|
+
Request,
|
|
112
|
+
RequestOptions,
|
|
113
|
+
Response,
|
|
114
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function getInsecureRandomBytes(maxLen: bigint): Uint8Array;
|
|
2
|
+
declare function getInsecureRandomU64(): bigint;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getInsecureRandomBytes: typeof getInsecureRandomBytes;
|
|
5
|
+
getInsecureRandomU64: typeof getInsecureRandomU64;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export type * from "../../../types/interfaces/wasi-random-insecure.d.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { insecure } from "@bytecodealliance/preview2-shim/random";
|
|
2
|
+
function getInsecureRandomBytes(maxLen) {
|
|
3
|
+
return insecure.getInsecureRandomBytes(maxLen);
|
|
4
|
+
}
|
|
5
|
+
function getInsecureRandomU64() {
|
|
6
|
+
return insecure.getInsecureRandomU64();
|
|
7
|
+
}
|
|
8
|
+
export default {
|
|
9
|
+
getInsecureRandomBytes,
|
|
10
|
+
getInsecureRandomU64,
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function getRandomBytes(maxLen: bigint): Uint8Array;
|
|
2
|
+
declare function getRandomU64(): bigint;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getRandomBytes: typeof getRandomBytes;
|
|
5
|
+
getRandomU64: typeof getRandomU64;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export type * from "../../../types/interfaces/wasi-random-random.d.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { random } from "@bytecodealliance/preview2-shim/random";
|
|
2
|
+
function getRandomBytes(maxLen) {
|
|
3
|
+
return random.getRandomBytes(maxLen);
|
|
4
|
+
}
|
|
5
|
+
function getRandomU64() {
|
|
6
|
+
return random.getRandomU64();
|
|
7
|
+
}
|
|
8
|
+
export default {
|
|
9
|
+
getRandomBytes,
|
|
10
|
+
getRandomU64,
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IpAddress } from "../../../types/interfaces/wasi-sockets-ip-name-lookup.d.ts";
|
|
2
|
+
declare function resolveAddresses(name: string): Promise<Array<IpAddress>>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
resolveAddresses: typeof resolveAddresses;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export type * from "../../../types/interfaces/wasi-sockets-ip-name-lookup.d.ts";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Duration, ErrorCode, IpAddressFamily, IpSocketAddress, Result, TcpSocket as TcpSocketT, UdpSocket as UdpSocketT } from "../../../types/interfaces/wasi-sockets-types.d.ts";
|
|
2
|
+
export declare class TcpSocket implements TcpSocketT {
|
|
3
|
+
static create(addressFamily: IpAddressFamily): TcpSocket;
|
|
4
|
+
bind(localAddress: IpSocketAddress): void;
|
|
5
|
+
connect(remoteAddress: IpSocketAddress): Promise<void>;
|
|
6
|
+
listen(): ReadableStream<TcpSocketT>;
|
|
7
|
+
send(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
8
|
+
receive(): [ReadableStream<number>, Promise<Result<void, ErrorCode>>];
|
|
9
|
+
getLocalAddress(): IpSocketAddress;
|
|
10
|
+
getRemoteAddress(): IpSocketAddress;
|
|
11
|
+
getIsListening(): boolean;
|
|
12
|
+
getAddressFamily(): IpAddressFamily;
|
|
13
|
+
setListenBacklogSize(value: bigint): void;
|
|
14
|
+
getKeepAliveEnabled(): boolean;
|
|
15
|
+
setKeepAliveEnabled(value: boolean): void;
|
|
16
|
+
getKeepAliveIdleTime(): Duration;
|
|
17
|
+
setKeepAliveIdleTime(value: Duration): void;
|
|
18
|
+
getKeepAliveInterval(): Duration;
|
|
19
|
+
setKeepAliveInterval(value: Duration): void;
|
|
20
|
+
getKeepAliveCount(): number;
|
|
21
|
+
setKeepAliveCount(value: number): void;
|
|
22
|
+
getHopLimit(): number;
|
|
23
|
+
setHopLimit(value: number): void;
|
|
24
|
+
getReceiveBufferSize(): bigint;
|
|
25
|
+
setReceiveBufferSize(value: bigint): void;
|
|
26
|
+
getSendBufferSize(): bigint;
|
|
27
|
+
setSendBufferSize(value: bigint): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class UdpSocket implements UdpSocketT {
|
|
30
|
+
static create(addressFamily: IpAddressFamily): UdpSocket;
|
|
31
|
+
bind(localAddress: IpSocketAddress): void;
|
|
32
|
+
connect(remoteAddress: IpSocketAddress): void;
|
|
33
|
+
disconnect(): void;
|
|
34
|
+
send(data: Uint8Array, remoteAddress: IpSocketAddress | undefined): Promise<void>;
|
|
35
|
+
receive(): Promise<[Uint8Array, IpSocketAddress]>;
|
|
36
|
+
getLocalAddress(): IpSocketAddress;
|
|
37
|
+
getRemoteAddress(): IpSocketAddress;
|
|
38
|
+
getAddressFamily(): IpAddressFamily;
|
|
39
|
+
getUnicastHopLimit(): number;
|
|
40
|
+
setUnicastHopLimit(value: number): void;
|
|
41
|
+
getReceiveBufferSize(): bigint;
|
|
42
|
+
setReceiveBufferSize(value: bigint): void;
|
|
43
|
+
getSendBufferSize(): bigint;
|
|
44
|
+
setSendBufferSize(value: bigint): void;
|
|
45
|
+
}
|
|
46
|
+
declare const _default: {
|
|
47
|
+
TcpSocket: typeof TcpSocket;
|
|
48
|
+
UdpSocket: typeof UdpSocket;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
51
|
+
export type * from "../../../types/interfaces/wasi-sockets-types.d.ts";
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Todo } from "../../common/errors.js";
|
|
2
|
+
export class TcpSocket {
|
|
3
|
+
static create(addressFamily) {
|
|
4
|
+
throw new Todo();
|
|
5
|
+
}
|
|
6
|
+
bind(localAddress) {
|
|
7
|
+
throw new Todo();
|
|
8
|
+
}
|
|
9
|
+
connect(remoteAddress) {
|
|
10
|
+
throw new Todo();
|
|
11
|
+
}
|
|
12
|
+
listen() {
|
|
13
|
+
throw new Todo();
|
|
14
|
+
}
|
|
15
|
+
send(data) {
|
|
16
|
+
throw new Todo();
|
|
17
|
+
}
|
|
18
|
+
receive() {
|
|
19
|
+
throw new Todo();
|
|
20
|
+
}
|
|
21
|
+
getLocalAddress() {
|
|
22
|
+
throw new Todo();
|
|
23
|
+
}
|
|
24
|
+
getRemoteAddress() {
|
|
25
|
+
throw new Todo();
|
|
26
|
+
}
|
|
27
|
+
getIsListening() {
|
|
28
|
+
throw new Todo();
|
|
29
|
+
}
|
|
30
|
+
getAddressFamily() {
|
|
31
|
+
throw new Todo();
|
|
32
|
+
}
|
|
33
|
+
setListenBacklogSize(value) {
|
|
34
|
+
throw new Todo();
|
|
35
|
+
}
|
|
36
|
+
getKeepAliveEnabled() {
|
|
37
|
+
throw new Todo();
|
|
38
|
+
}
|
|
39
|
+
setKeepAliveEnabled(value) {
|
|
40
|
+
throw new Todo();
|
|
41
|
+
}
|
|
42
|
+
getKeepAliveIdleTime() {
|
|
43
|
+
throw new Todo();
|
|
44
|
+
}
|
|
45
|
+
setKeepAliveIdleTime(value) {
|
|
46
|
+
throw new Todo();
|
|
47
|
+
}
|
|
48
|
+
getKeepAliveInterval() {
|
|
49
|
+
throw new Todo();
|
|
50
|
+
}
|
|
51
|
+
setKeepAliveInterval(value) {
|
|
52
|
+
throw new Todo();
|
|
53
|
+
}
|
|
54
|
+
getKeepAliveCount() {
|
|
55
|
+
throw new Todo();
|
|
56
|
+
}
|
|
57
|
+
setKeepAliveCount(value) {
|
|
58
|
+
throw new Todo();
|
|
59
|
+
}
|
|
60
|
+
getHopLimit() {
|
|
61
|
+
throw new Todo();
|
|
62
|
+
}
|
|
63
|
+
setHopLimit(value) {
|
|
64
|
+
throw new Todo();
|
|
65
|
+
}
|
|
66
|
+
getReceiveBufferSize() {
|
|
67
|
+
throw new Todo();
|
|
68
|
+
}
|
|
69
|
+
setReceiveBufferSize(value) {
|
|
70
|
+
throw new Todo();
|
|
71
|
+
}
|
|
72
|
+
getSendBufferSize() {
|
|
73
|
+
throw new Todo();
|
|
74
|
+
}
|
|
75
|
+
setSendBufferSize(value) {
|
|
76
|
+
throw new Todo();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class UdpSocket {
|
|
80
|
+
static create(addressFamily) {
|
|
81
|
+
throw new Todo();
|
|
82
|
+
}
|
|
83
|
+
bind(localAddress) {
|
|
84
|
+
throw new Todo();
|
|
85
|
+
}
|
|
86
|
+
connect(remoteAddress) {
|
|
87
|
+
throw new Todo();
|
|
88
|
+
}
|
|
89
|
+
disconnect() {
|
|
90
|
+
throw new Todo();
|
|
91
|
+
}
|
|
92
|
+
send(data, remoteAddress) {
|
|
93
|
+
throw new Todo();
|
|
94
|
+
}
|
|
95
|
+
receive() {
|
|
96
|
+
throw new Todo();
|
|
97
|
+
}
|
|
98
|
+
getLocalAddress() {
|
|
99
|
+
throw new Todo();
|
|
100
|
+
}
|
|
101
|
+
getRemoteAddress() {
|
|
102
|
+
throw new Todo();
|
|
103
|
+
}
|
|
104
|
+
getAddressFamily() {
|
|
105
|
+
throw new Todo();
|
|
106
|
+
}
|
|
107
|
+
getUnicastHopLimit() {
|
|
108
|
+
throw new Todo();
|
|
109
|
+
}
|
|
110
|
+
setUnicastHopLimit(value) {
|
|
111
|
+
throw new Todo();
|
|
112
|
+
}
|
|
113
|
+
getReceiveBufferSize() {
|
|
114
|
+
throw new Todo();
|
|
115
|
+
}
|
|
116
|
+
setReceiveBufferSize(value) {
|
|
117
|
+
throw new Todo();
|
|
118
|
+
}
|
|
119
|
+
getSendBufferSize() {
|
|
120
|
+
throw new Todo();
|
|
121
|
+
}
|
|
122
|
+
setSendBufferSize(value) {
|
|
123
|
+
throw new Todo();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export default {
|
|
127
|
+
TcpSocket,
|
|
128
|
+
UdpSocket,
|
|
129
|
+
};
|
package/dist/nodejs/cli.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const stdin: {
|
|
|
17
17
|
*
|
|
18
18
|
* @returns {[StreamReader, FutureReader]} A tuple of [stream, future].
|
|
19
19
|
*/
|
|
20
|
-
readViaStream(): (
|
|
20
|
+
readViaStream(): (import("./future.js").FutureReader | StreamReader)[];
|
|
21
21
|
};
|
|
22
22
|
export declare const stdout: {
|
|
23
23
|
/**
|
package/dist/nodejs/clocks.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const systemClock: {
|
|
|
13
13
|
getResolution(): bigint;
|
|
14
14
|
};
|
|
15
15
|
export declare const monotonicClock: {
|
|
16
|
+
now(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Instant;
|
|
17
|
+
resolution(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Duration;
|
|
16
18
|
/**
|
|
17
19
|
* Query the resolution of the clock.
|
|
18
20
|
*
|
|
@@ -50,6 +52,4 @@ export declare const monotonicClock: {
|
|
|
50
52
|
* @throws {TypeError} If durationNs is not a bigint
|
|
51
53
|
*/
|
|
52
54
|
waitFor(durationNs: any): Promise<void>;
|
|
53
|
-
now(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Instant;
|
|
54
|
-
resolution(): import("@bytecodealliance/preview2-shim/interfaces/wasi-clocks-monotonic-clock").Duration;
|
|
55
55
|
};
|
|
@@ -18,7 +18,7 @@ declare class Descriptor {
|
|
|
18
18
|
* A tuple: a readable byte stream and a future that resolves to an error code.
|
|
19
19
|
* @throws {FSError} `payload.tag` contains mapped WASI error code.
|
|
20
20
|
*/
|
|
21
|
-
readViaStream(offset: any): (
|
|
21
|
+
readViaStream(offset: any): (FutureReader | StreamReader)[];
|
|
22
22
|
/**
|
|
23
23
|
* Write to a file via a byte stream.
|
|
24
24
|
* WIT:
|
|
@@ -141,7 +141,7 @@ declare class Descriptor {
|
|
|
141
141
|
* @returns {{stream: StreamReader, future: FutureReader}}
|
|
142
142
|
* @throws {FSError} `payload.tag` contains mapped WASI error code.
|
|
143
143
|
*/
|
|
144
|
-
readDirectory(): (
|
|
144
|
+
readDirectory(): (FutureReader | StreamReader)[];
|
|
145
145
|
/**
|
|
146
146
|
* Synchronize data & metadata to disk.
|
|
147
147
|
* WIT:
|
|
@@ -108,7 +108,7 @@ export declare class TcpSocket {
|
|
|
108
108
|
* @throws {SocketError} for other errors, payload.tag maps the system error
|
|
109
109
|
* @returns {{ stream: StreamReader, future: FutureReader }}
|
|
110
110
|
*/
|
|
111
|
-
receive(): (
|
|
111
|
+
receive(): (FutureReader | StreamReader)[];
|
|
112
112
|
/**
|
|
113
113
|
* Gets the bound local address
|
|
114
114
|
* WIT:
|
|
@@ -462,7 +462,7 @@ export class UdpSocket {
|
|
|
462
462
|
* Releases native resources and marks the socket as closed.
|
|
463
463
|
*/
|
|
464
464
|
[Symbol.dispose]() {
|
|
465
|
-
if (this.#socketId) {
|
|
465
|
+
if (this.#socketId !== null) {
|
|
466
466
|
worker().runSync({
|
|
467
467
|
op: "udp-dispose",
|
|
468
468
|
socketId: this.#socketId,
|
|
@@ -64,7 +64,9 @@ function notify(condvar) {
|
|
|
64
64
|
Router().op("stdout", handleOp).op("stderr", handleOp);
|
|
65
65
|
async function handleOp(msg) {
|
|
66
66
|
const { op, stream } = msg;
|
|
67
|
-
|
|
67
|
+
const readable = Readable.from(byteChunks(stream), { objectMode: false });
|
|
68
|
+
const writable = op === "stdout" ? process.stdout : process.stderr;
|
|
69
|
+
await pipeline(readable, writable, { end: false });
|
|
68
70
|
return { ok: true };
|
|
69
71
|
}
|
|
70
72
|
async function* byteChunks(stream) {
|
|
@@ -156,7 +156,7 @@ function wasiTypeFromDirent(obj) {
|
|
|
156
156
|
const readAsync = promisify(fs.read);
|
|
157
157
|
const writeAsync = promisify(fs.write);
|
|
158
158
|
const { opendir } = fs.promises;
|
|
159
|
-
const CHUNK_BYTES =
|
|
159
|
+
const CHUNK_BYTES = 65536;
|
|
160
160
|
const BUFFER = Buffer.alloc(CHUNK_BYTES);
|
|
161
161
|
const MAX_SAFE_FILE_POSITION = BigInt(Number.MAX_SAFE_INTEGER);
|
|
162
162
|
/** Auto‐dispatch all ops */
|
|
@@ -173,7 +173,8 @@ async function handleNext({ serverId }) {
|
|
|
173
173
|
const { req } = srv.inflight.get(requestId);
|
|
174
174
|
const { port1: tx, port2: trailers } = new MessageChannel();
|
|
175
175
|
const { readable: body, writable } = new TransformStream();
|
|
176
|
-
|
|
176
|
+
const stream = Writable.fromWeb(writable);
|
|
177
|
+
pipeline(req, stream).then(() => tx.postMessage({ val: toEntries(req.trailersDistinct || req.trailers || {}) })).catch((err) => tx.postMessage({ err })).finally(() => tx.close());
|
|
177
178
|
const headers = toEntries(req.headersDistinct);
|
|
178
179
|
const { method, url } = req;
|
|
179
180
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/preview3-shim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "WASI Preview3 shim for JS environments",
|
|
5
5
|
"homepage": "https://github.com/bytecodealliance/jco/blob/main/packages/preview3-shim/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -28,12 +28,20 @@
|
|
|
28
28
|
"type": "module",
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"types": "./dist/
|
|
32
|
-
"node":
|
|
31
|
+
"types": "./dist/browser/index.d.ts",
|
|
32
|
+
"node": {
|
|
33
|
+
"types": "./dist/nodejs/index.d.ts",
|
|
34
|
+
"default": "./dist/nodejs/index.js"
|
|
35
|
+
},
|
|
36
|
+
"default": "./dist/browser/index.js"
|
|
33
37
|
},
|
|
34
38
|
"./*": {
|
|
35
|
-
"types": "./dist/
|
|
36
|
-
"node":
|
|
39
|
+
"types": "./dist/browser/*.d.ts",
|
|
40
|
+
"node": {
|
|
41
|
+
"types": "./dist/nodejs/*.d.ts",
|
|
42
|
+
"default": "./dist/nodejs/*.js"
|
|
43
|
+
},
|
|
44
|
+
"default": "./dist/browser/*.js"
|
|
37
45
|
},
|
|
38
46
|
"./interfaces/*": {
|
|
39
47
|
"types": "./types/interfaces/*.d.ts"
|
|
@@ -45,10 +53,10 @@
|
|
|
45
53
|
"devDependencies": {
|
|
46
54
|
"@types/node": "^24.12.4",
|
|
47
55
|
"globals": "^17.6.0",
|
|
48
|
-
"rolldown": "^1.2.
|
|
49
|
-
"typescript": "
|
|
56
|
+
"rolldown": "^1.2.4",
|
|
57
|
+
"typescript": "7.0.2",
|
|
50
58
|
"vite": "^8.0.16",
|
|
51
|
-
"vitest": "^4.
|
|
59
|
+
"vitest": "^4.1.10"
|
|
52
60
|
},
|
|
53
61
|
"scripts": {
|
|
54
62
|
"build": "tsc --project tsconfig.build.json && node scripts/build-workers.mjs",
|