@bytecodealliance/preview3-shim 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/browser/cli/environment.d.ts +1 -0
- package/dist/browser/cli/environment.js +9 -4
- package/dist/browser/cli/exit.js +4 -3
- package/dist/browser/cli/run.d.ts +2 -0
- package/dist/browser/cli/run.js +11 -3
- package/dist/browser/cli/stderr.js +10 -3
- package/dist/browser/cli/stdin.js +3 -2
- package/dist/browser/cli/stdout.js +10 -3
- package/dist/browser/cli/terminal-stderr.js +2 -2
- package/dist/browser/cli/terminal-stdin.js +2 -2
- package/dist/browser/cli/terminal-stdout.js +2 -2
- package/dist/browser/cli.d.ts +3 -0
- package/dist/browser/cli.js +3 -0
- package/dist/browser/clocks/monotonic-clock.js +7 -7
- package/dist/browser/clocks/system-clock.js +4 -3
- package/dist/browser/filesystem/preopens.js +3 -2
- package/dist/browser/filesystem/types.d.ts +44 -1
- package/dist/browser/filesystem/types.js +139 -50
- package/dist/browser/filesystem.d.ts +13 -0
- package/dist/browser/filesystem.js +20 -0
- package/dist/browser/http/client.d.ts +2 -2
- package/dist/browser/http/client.js +138 -3
- package/dist/browser/http/handler.d.ts +4 -0
- package/dist/browser/http/handler.js +11 -3
- package/dist/browser/http/types.d.ts +44 -22
- package/dist/browser/http/types.js +192 -50
- package/dist/browser/http.d.ts +3 -0
- package/dist/browser/http.js +3 -0
- package/dist/browser/sockets/ip-name-lookup.js +34 -3
- package/dist/browser/sockets/types.d.ts +15 -0
- package/dist/browser/sockets/types.js +241 -49
- package/dist/browser/sockets.d.ts +2 -0
- package/dist/browser/sockets.js +2 -0
- package/dist/browser/streams.d.ts +20 -0
- package/dist/browser/streams.js +106 -0
- package/dist/nodejs/filesystem/descriptor.js +14 -17
- package/package.json +3 -3
- package/dist/common/errors.d.ts +0 -3
- package/dist/common/errors.js +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Preview3 Shim
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[WebAssembly System Interface (WASI) Preview 3][wasi] implementations for NodeJS & browsers.
|
|
4
|
+
|
|
5
|
+
Similar to the [Preview 2 Shim][p2-shim], the P3 shim makes available WASI
|
|
6
|
+
interfaces for [WebAssembly Components][cm-book] that make use of them.
|
|
7
|
+
|
|
8
|
+
[wasi]: https://github.com/webassembly/wasi
|
|
9
|
+
[cm-book]: https://component-model.bytecodealliance.org/
|
|
10
|
+
[p2-shim]: https://www.npmjs.com/package/@bytecodealliance/preview2-shim
|
|
4
11
|
|
|
5
12
|
### Contribution
|
|
6
13
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _setCwd as setPreview2Cwd, environment } from "@bytecodealliance/preview2-shim/cli";
|
|
2
|
+
let initialCwd = environment.initialCwd();
|
|
3
|
+
export function _setCwd(cwd) {
|
|
4
|
+
initialCwd = cwd;
|
|
5
|
+
setPreview2Cwd(cwd);
|
|
6
|
+
}
|
|
2
7
|
function getEnvironment() {
|
|
3
|
-
|
|
8
|
+
return environment.getEnvironment();
|
|
4
9
|
}
|
|
5
10
|
function getArguments() {
|
|
6
|
-
|
|
11
|
+
return environment.getArguments();
|
|
7
12
|
}
|
|
8
13
|
function getInitialCwd() {
|
|
9
|
-
|
|
14
|
+
return initialCwd;
|
|
10
15
|
}
|
|
11
16
|
export default {
|
|
12
17
|
getEnvironment,
|
package/dist/browser/cli/exit.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exit as preview2Exit } from "@bytecodealliance/preview2-shim/cli";
|
|
2
|
+
const exitWithCodeV2 = preview2Exit;
|
|
2
3
|
function exit(status) {
|
|
3
|
-
|
|
4
|
+
preview2Exit.exit(status);
|
|
4
5
|
}
|
|
5
6
|
function exitWithCode(statusCode) {
|
|
6
|
-
|
|
7
|
+
exitWithCodeV2.exitWithCode(statusCode);
|
|
7
8
|
}
|
|
8
9
|
export default {
|
|
9
10
|
exit,
|
package/dist/browser/cli/run.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
function run() {
|
|
3
|
-
|
|
1
|
+
let handler;
|
|
2
|
+
async function run() {
|
|
3
|
+
if (!handler) {
|
|
4
|
+
throw new Error("wasi:cli/run import is not configured");
|
|
5
|
+
}
|
|
6
|
+
await handler();
|
|
7
|
+
}
|
|
8
|
+
export function _setRun(next) {
|
|
9
|
+
const previous = handler;
|
|
10
|
+
handler = next;
|
|
11
|
+
return previous;
|
|
4
12
|
}
|
|
5
13
|
export default {
|
|
6
14
|
run,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { stderr } from "@bytecodealliance/preview2-shim/cli";
|
|
2
|
+
import { preview2StreamErrorCode, writeToPreview2Output } from "../streams.js";
|
|
3
|
+
async function writeViaStream(data) {
|
|
4
|
+
try {
|
|
5
|
+
await writeToPreview2Output(data, stderr.getStderr());
|
|
6
|
+
return { tag: "ok", val: undefined };
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
return { tag: "err", val: preview2StreamErrorCode(error) };
|
|
10
|
+
}
|
|
4
11
|
}
|
|
5
12
|
export default {
|
|
6
13
|
writeViaStream,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stdin } from "@bytecodealliance/preview2-shim/cli";
|
|
2
|
+
import { readableFromPreview2Input } from "../streams.js";
|
|
2
3
|
function readViaStream() {
|
|
3
|
-
|
|
4
|
+
return readableFromPreview2Input(stdin.getStdin(), () => "io");
|
|
4
5
|
}
|
|
5
6
|
export default {
|
|
6
7
|
readViaStream,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { stdout } from "@bytecodealliance/preview2-shim/cli";
|
|
2
|
+
import { preview2StreamErrorCode, writeToPreview2Output } from "../streams.js";
|
|
3
|
+
async function writeViaStream(data) {
|
|
4
|
+
try {
|
|
5
|
+
await writeToPreview2Output(data, stdout.getStdout());
|
|
6
|
+
return { tag: "ok", val: undefined };
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
return { tag: "err", val: preview2StreamErrorCode(error) };
|
|
10
|
+
}
|
|
4
11
|
}
|
|
5
12
|
export default {
|
|
6
13
|
writeViaStream,
|
package/dist/browser/cli.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as environment } from "./cli/environment.js";
|
|
2
|
+
export { _setCwd } from "./cli/environment.js";
|
|
2
3
|
export { default as exit } from "./cli/exit.js";
|
|
3
4
|
export { default as run } from "./cli/run.js";
|
|
5
|
+
export { _setRun } from "./cli/run.js";
|
|
4
6
|
export { default as stderr } from "./cli/stderr.js";
|
|
5
7
|
export { default as stdin } from "./cli/stdin.js";
|
|
6
8
|
export { default as stdout } from "./cli/stdout.js";
|
|
@@ -9,3 +11,4 @@ export { default as terminalOutput } from "./cli/terminal-output.js";
|
|
|
9
11
|
export { default as terminalStderr } from "./cli/terminal-stderr.js";
|
|
10
12
|
export { default as terminalStdin } from "./cli/terminal-stdin.js";
|
|
11
13
|
export { default as terminalStdout } from "./cli/terminal-stdout.js";
|
|
14
|
+
export { _setArgs, _setEnv, _setStderr, _setStdin, _setStdout, } from "@bytecodealliance/preview2-shim/cli";
|
package/dist/browser/cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as environment } from "./cli/environment.js";
|
|
2
|
+
export { _setCwd } from "./cli/environment.js";
|
|
2
3
|
export { default as exit } from "./cli/exit.js";
|
|
3
4
|
export { default as run } from "./cli/run.js";
|
|
5
|
+
export { _setRun } from "./cli/run.js";
|
|
4
6
|
export { default as stderr } from "./cli/stderr.js";
|
|
5
7
|
export { default as stdin } from "./cli/stdin.js";
|
|
6
8
|
export { default as stdout } from "./cli/stdout.js";
|
|
@@ -9,3 +11,4 @@ export { default as terminalOutput } from "./cli/terminal-output.js";
|
|
|
9
11
|
export { default as terminalStderr } from "./cli/terminal-stderr.js";
|
|
10
12
|
export { default as terminalStdin } from "./cli/terminal-stdin.js";
|
|
11
13
|
export { default as terminalStdout } from "./cli/terminal-stdout.js";
|
|
14
|
+
export { _setArgs, _setEnv, _setStderr, _setStdin, _setStdout, } from "@bytecodealliance/preview2-shim/cli";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { monotonicClock } from "@bytecodealliance/preview2-shim/clocks";
|
|
2
2
|
function now() {
|
|
3
|
-
|
|
3
|
+
return monotonicClock.now();
|
|
4
4
|
}
|
|
5
5
|
function getResolution() {
|
|
6
|
-
|
|
6
|
+
return monotonicClock.resolution();
|
|
7
7
|
}
|
|
8
|
-
function waitUntil(when) {
|
|
9
|
-
|
|
8
|
+
async function waitUntil(when) {
|
|
9
|
+
await monotonicClock.subscribeInstant(when).block();
|
|
10
10
|
}
|
|
11
|
-
function waitFor(howLong) {
|
|
12
|
-
|
|
11
|
+
async function waitFor(howLong) {
|
|
12
|
+
await monotonicClock.subscribeDuration(howLong).block();
|
|
13
13
|
}
|
|
14
14
|
export default {
|
|
15
15
|
now,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wallClock } from "@bytecodealliance/preview2-shim/clocks";
|
|
2
2
|
function now() {
|
|
3
|
-
|
|
3
|
+
return wallClock.now();
|
|
4
4
|
}
|
|
5
5
|
function getResolution() {
|
|
6
|
-
|
|
6
|
+
const resolution = wallClock.resolution();
|
|
7
|
+
return resolution.seconds * 1000000000n + BigInt(resolution.nanoseconds);
|
|
7
8
|
}
|
|
8
9
|
export default {
|
|
9
10
|
now,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { preopens } from "@bytecodealliance/preview2-shim/filesystem";
|
|
2
|
+
import { wrapDescriptor } from "./types.js";
|
|
2
3
|
function getDirectories() {
|
|
3
|
-
|
|
4
|
+
return preopens.getDirectories().map(([descriptor, path]) => [wrapDescriptor(descriptor), path]);
|
|
4
5
|
}
|
|
5
6
|
export default {
|
|
6
7
|
getDirectories,
|
|
@@ -1,5 +1,47 @@
|
|
|
1
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
|
-
|
|
2
|
+
import { readableFromPreview2Input, writeToPreview2Output } from "../streams.js";
|
|
3
|
+
declare const symbolDispose: symbol;
|
|
4
|
+
type Preview2Descriptor = {
|
|
5
|
+
readViaStream(offset: Filesize): Parameters<typeof readableFromPreview2Input>[0];
|
|
6
|
+
writeViaStream(offset: Filesize): Parameters<typeof writeToPreview2Output>[1];
|
|
7
|
+
appendViaStream(): Parameters<typeof writeToPreview2Output>[1];
|
|
8
|
+
advise(offset: Filesize, length: Filesize, advice: Advice): void;
|
|
9
|
+
syncData(): void;
|
|
10
|
+
getFlags(): DescriptorFlags;
|
|
11
|
+
getType(): string;
|
|
12
|
+
setSize(size: Filesize): void;
|
|
13
|
+
setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
14
|
+
readDirectory(): {
|
|
15
|
+
readDirectoryEntry(): {
|
|
16
|
+
type: string;
|
|
17
|
+
name: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
};
|
|
20
|
+
sync(): void;
|
|
21
|
+
createDirectoryAt(path: string): void;
|
|
22
|
+
stat(): Omit<DescriptorStat, "type"> & {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
statAt(pathFlags: PathFlags, path: string): Omit<DescriptorStat, "type"> & {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
29
|
+
linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Preview2Descriptor, newPath: string): void;
|
|
30
|
+
openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Preview2Descriptor;
|
|
31
|
+
readlinkAt(path: string): string;
|
|
32
|
+
removeDirectoryAt(path: string): void;
|
|
33
|
+
renameAt(oldPath: string, newDescriptor: Preview2Descriptor, newPath: string): void;
|
|
34
|
+
symlinkAt(oldPath: string, newPath: string): void;
|
|
35
|
+
unlinkFileAt(path: string): void;
|
|
36
|
+
isSameObject(other: Preview2Descriptor): boolean;
|
|
37
|
+
metadataHash(): MetadataHashValue;
|
|
38
|
+
metadataHashAt(pathFlags: PathFlags, path: string): MetadataHashValue;
|
|
39
|
+
};
|
|
40
|
+
export declare function filesystemErrorCode(error: unknown): ErrorCode;
|
|
41
|
+
export declare class Descriptor implements DescriptorT {
|
|
42
|
+
#private;
|
|
43
|
+
[symbolDispose]: () => void;
|
|
44
|
+
static _wrap(descriptor: Preview2Descriptor): Descriptor;
|
|
3
45
|
readViaStream(offset: Filesize): [ReadableStream<number>, Promise<Result<void, ErrorCode>>];
|
|
4
46
|
writeViaStream(data: ReadableStream<number>, offset: Filesize): Promise<Result<void, ErrorCode>>;
|
|
5
47
|
appendViaStream(data: ReadableStream<number>): Promise<Result<void, ErrorCode>>;
|
|
@@ -26,6 +68,7 @@ declare class Descriptor implements DescriptorT {
|
|
|
26
68
|
metadataHash(): Promise<MetadataHashValue>;
|
|
27
69
|
metadataHashAt(pathFlags: PathFlags, path: string): Promise<MetadataHashValue>;
|
|
28
70
|
}
|
|
71
|
+
export declare function wrapDescriptor(descriptor: unknown): Descriptor;
|
|
29
72
|
declare const _default: {
|
|
30
73
|
Descriptor: typeof Descriptor;
|
|
31
74
|
};
|
|
@@ -1,81 +1,170 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { readableFromPreview2Input, writeToPreview2Output } from "../streams.js";
|
|
2
|
+
const symbolDispose = Symbol.dispose ?? Symbol.for("dispose");
|
|
3
|
+
const TYPE_TAGS = new Set([
|
|
4
|
+
"block-device",
|
|
5
|
+
"character-device",
|
|
6
|
+
"directory",
|
|
7
|
+
"fifo",
|
|
8
|
+
"symbolic-link",
|
|
9
|
+
"regular-file",
|
|
10
|
+
"socket",
|
|
11
|
+
]);
|
|
12
|
+
function descriptorType(type) {
|
|
13
|
+
if (TYPE_TAGS.has(type)) {
|
|
14
|
+
return { tag: type };
|
|
15
|
+
}
|
|
16
|
+
return { tag: "other", val: type === "unknown" ? undefined : type };
|
|
17
|
+
}
|
|
18
|
+
export function filesystemErrorCode(error) {
|
|
19
|
+
let tag = typeof error === "string" ? error : error?.tag;
|
|
20
|
+
if (!tag && error instanceof Error) {
|
|
21
|
+
tag = error.message;
|
|
22
|
+
}
|
|
23
|
+
if (tag === "would-block") {
|
|
24
|
+
return { tag: "other", val: tag };
|
|
25
|
+
}
|
|
26
|
+
if (tag) {
|
|
27
|
+
return { tag };
|
|
28
|
+
}
|
|
29
|
+
return { tag: "other", val: String(error) };
|
|
30
|
+
}
|
|
31
|
+
class FilesystemError extends Error {
|
|
32
|
+
payload;
|
|
33
|
+
constructor(error) {
|
|
34
|
+
const payload = filesystemErrorCode(error);
|
|
35
|
+
super(payload.tag);
|
|
36
|
+
this.name = "FilesystemError";
|
|
37
|
+
this.payload = payload;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function filesystemCall(operation) {
|
|
41
|
+
try {
|
|
42
|
+
return operation();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw error instanceof FilesystemError ? error : new FilesystemError(error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function stat(value) {
|
|
49
|
+
return { ...value, type: descriptorType(value.type) };
|
|
50
|
+
}
|
|
51
|
+
export class Descriptor {
|
|
52
|
+
#descriptor;
|
|
53
|
+
static _wrap(descriptor) {
|
|
54
|
+
const wrapped = new Descriptor();
|
|
55
|
+
wrapped.#descriptor = descriptor;
|
|
56
|
+
return wrapped;
|
|
57
|
+
}
|
|
3
58
|
readViaStream(offset) {
|
|
4
|
-
|
|
59
|
+
return readableFromPreview2Input(this.#descriptor.readViaStream(offset), filesystemErrorCode);
|
|
5
60
|
}
|
|
6
|
-
writeViaStream(data, offset) {
|
|
7
|
-
|
|
61
|
+
async writeViaStream(data, offset) {
|
|
62
|
+
try {
|
|
63
|
+
await writeToPreview2Output(data, this.#descriptor.writeViaStream(offset));
|
|
64
|
+
return { tag: "ok", val: undefined };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return { tag: "err", val: filesystemErrorCode(error) };
|
|
68
|
+
}
|
|
8
69
|
}
|
|
9
|
-
appendViaStream(data) {
|
|
10
|
-
|
|
70
|
+
async appendViaStream(data) {
|
|
71
|
+
try {
|
|
72
|
+
await writeToPreview2Output(data, this.#descriptor.appendViaStream());
|
|
73
|
+
return { tag: "ok", val: undefined };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return { tag: "err", val: filesystemErrorCode(error) };
|
|
77
|
+
}
|
|
11
78
|
}
|
|
12
|
-
advise(offset, length, advice) {
|
|
13
|
-
|
|
79
|
+
async advise(offset, length, advice) {
|
|
80
|
+
filesystemCall(() => this.#descriptor.advise(offset, length, advice));
|
|
14
81
|
}
|
|
15
|
-
syncData() {
|
|
16
|
-
|
|
82
|
+
async syncData() {
|
|
83
|
+
filesystemCall(() => this.#descriptor.syncData());
|
|
17
84
|
}
|
|
18
|
-
getFlags() {
|
|
19
|
-
|
|
85
|
+
async getFlags() {
|
|
86
|
+
return filesystemCall(() => this.#descriptor.getFlags());
|
|
20
87
|
}
|
|
21
|
-
getType() {
|
|
22
|
-
|
|
88
|
+
async getType() {
|
|
89
|
+
return descriptorType(filesystemCall(() => this.#descriptor.getType()));
|
|
23
90
|
}
|
|
24
|
-
setSize(size) {
|
|
25
|
-
|
|
91
|
+
async setSize(size) {
|
|
92
|
+
filesystemCall(() => this.#descriptor.setSize(size));
|
|
26
93
|
}
|
|
27
|
-
setTimes(dataAccessTimestamp, dataModificationTimestamp) {
|
|
28
|
-
|
|
94
|
+
async setTimes(dataAccessTimestamp, dataModificationTimestamp) {
|
|
95
|
+
filesystemCall(() => this.#descriptor.setTimes(dataAccessTimestamp, dataModificationTimestamp));
|
|
29
96
|
}
|
|
30
97
|
readDirectory() {
|
|
31
|
-
|
|
98
|
+
const directory = this.#descriptor.readDirectory();
|
|
99
|
+
const stream = new ReadableStream({
|
|
100
|
+
pull(controller) {
|
|
101
|
+
try {
|
|
102
|
+
const entry = directory.readDirectoryEntry();
|
|
103
|
+
if (!entry) {
|
|
104
|
+
controller.close();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
controller.enqueue({ ...entry, type: descriptorType(entry.type) });
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
controller.error(error);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
return [stream, Promise.resolve({ tag: "ok", val: undefined })];
|
|
115
|
+
}
|
|
116
|
+
async sync() {
|
|
117
|
+
filesystemCall(() => this.#descriptor.sync());
|
|
32
118
|
}
|
|
33
|
-
|
|
34
|
-
|
|
119
|
+
async createDirectoryAt(path) {
|
|
120
|
+
filesystemCall(() => this.#descriptor.createDirectoryAt(path));
|
|
35
121
|
}
|
|
36
|
-
|
|
37
|
-
|
|
122
|
+
async stat() {
|
|
123
|
+
return stat(filesystemCall(() => this.#descriptor.stat()));
|
|
38
124
|
}
|
|
39
|
-
|
|
40
|
-
|
|
125
|
+
async statAt(pathFlags, path) {
|
|
126
|
+
return stat(filesystemCall(() => this.#descriptor.statAt(pathFlags, path)));
|
|
41
127
|
}
|
|
42
|
-
|
|
43
|
-
|
|
128
|
+
async setTimesAt(pathFlags, path, dataAccessTimestamp, dataModificationTimestamp) {
|
|
129
|
+
filesystemCall(() => this.#descriptor.setTimesAt(pathFlags, path, dataAccessTimestamp, dataModificationTimestamp));
|
|
44
130
|
}
|
|
45
|
-
|
|
46
|
-
|
|
131
|
+
async linkAt(oldPathFlags, oldPath, newDescriptor, newPath) {
|
|
132
|
+
filesystemCall(() => this.#descriptor.linkAt(oldPathFlags, oldPath, newDescriptor.#descriptor, newPath));
|
|
47
133
|
}
|
|
48
|
-
|
|
49
|
-
|
|
134
|
+
async openAt(pathFlags, path, openFlags, flags) {
|
|
135
|
+
return Descriptor._wrap(filesystemCall(() => this.#descriptor.openAt(pathFlags, path, openFlags, flags)));
|
|
50
136
|
}
|
|
51
|
-
|
|
52
|
-
|
|
137
|
+
async readlinkAt(path) {
|
|
138
|
+
return filesystemCall(() => this.#descriptor.readlinkAt(path));
|
|
53
139
|
}
|
|
54
|
-
|
|
55
|
-
|
|
140
|
+
async removeDirectoryAt(path) {
|
|
141
|
+
filesystemCall(() => this.#descriptor.removeDirectoryAt(path));
|
|
56
142
|
}
|
|
57
|
-
|
|
58
|
-
|
|
143
|
+
async renameAt(oldPath, newDescriptor, newPath) {
|
|
144
|
+
filesystemCall(() => this.#descriptor.renameAt(oldPath, newDescriptor.#descriptor, newPath));
|
|
59
145
|
}
|
|
60
|
-
|
|
61
|
-
|
|
146
|
+
async symlinkAt(oldPath, newPath) {
|
|
147
|
+
filesystemCall(() => this.#descriptor.symlinkAt(oldPath, newPath));
|
|
62
148
|
}
|
|
63
|
-
|
|
64
|
-
|
|
149
|
+
async unlinkFileAt(path) {
|
|
150
|
+
filesystemCall(() => this.#descriptor.unlinkFileAt(path));
|
|
65
151
|
}
|
|
66
|
-
|
|
67
|
-
|
|
152
|
+
async isSameObject(other) {
|
|
153
|
+
return filesystemCall(() => this.#descriptor.isSameObject(other.#descriptor));
|
|
68
154
|
}
|
|
69
|
-
|
|
70
|
-
|
|
155
|
+
async metadataHash() {
|
|
156
|
+
return filesystemCall(() => this.#descriptor.metadataHash());
|
|
71
157
|
}
|
|
72
|
-
|
|
73
|
-
|
|
158
|
+
async metadataHashAt(pathFlags, path) {
|
|
159
|
+
return filesystemCall(() => this.#descriptor.metadataHashAt(pathFlags, path));
|
|
74
160
|
}
|
|
75
|
-
|
|
76
|
-
|
|
161
|
+
[symbolDispose]() {
|
|
162
|
+
this.#descriptor[symbolDispose]?.();
|
|
77
163
|
}
|
|
78
164
|
}
|
|
165
|
+
export function wrapDescriptor(descriptor) {
|
|
166
|
+
return Descriptor._wrap(descriptor);
|
|
167
|
+
}
|
|
79
168
|
export default {
|
|
80
169
|
Descriptor,
|
|
81
170
|
};
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
import type { BrowserFilesystemConfig } from "@bytecodealliance/preview2-shim/filesystem";
|
|
1
2
|
export { default as preopens } from "./filesystem/preopens.js";
|
|
2
3
|
export { default as types } from "./filesystem/types.js";
|
|
4
|
+
export { _addPreopen, _addPreopenWithAdapter, _clearPreopens, _getFileData, _setCwd, _setFileData, _setPreopens, InMemoryFilesystemAdapter, loadOpfsCapability, OpfsFilesystemAdapter, } from "@bytecodealliance/preview2-shim/filesystem";
|
|
5
|
+
export type { BrowserFilesystemAdapter, BrowserFilesystemConfig, FileData, FileDataEntry, OpfsCapability, } from "@bytecodealliance/preview2-shim/filesystem";
|
|
6
|
+
export declare function _getPreopens(): (readonly [import("./filesystem/types.js").Descriptor, string])[];
|
|
7
|
+
export declare function createFilesystem<Capability>(config: BrowserFilesystemConfig<Capability>): {
|
|
8
|
+
types: {
|
|
9
|
+
Descriptor: typeof import("./filesystem/types.js").Descriptor;
|
|
10
|
+
};
|
|
11
|
+
preopens: {
|
|
12
|
+
getDirectories(): (readonly [import("./filesystem/types.js").Descriptor, string])[];
|
|
13
|
+
};
|
|
14
|
+
dispose: () => void;
|
|
15
|
+
};
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
import { _getPreopens as getPreview2Preopens, createFilesystem as createPreview2Filesystem, } from "@bytecodealliance/preview2-shim/filesystem";
|
|
2
|
+
import types, { wrapDescriptor } from "./filesystem/types.js";
|
|
1
3
|
export { default as preopens } from "./filesystem/preopens.js";
|
|
2
4
|
export { default as types } from "./filesystem/types.js";
|
|
5
|
+
export { _addPreopen, _addPreopenWithAdapter, _clearPreopens, _getFileData, _setCwd, _setFileData, _setPreopens, InMemoryFilesystemAdapter, loadOpfsCapability, OpfsFilesystemAdapter, } from "@bytecodealliance/preview2-shim/filesystem";
|
|
6
|
+
export function _getPreopens() {
|
|
7
|
+
return getPreview2Preopens().map(([descriptor, path]) => [wrapDescriptor(descriptor), path]);
|
|
8
|
+
}
|
|
9
|
+
export function createFilesystem(config) {
|
|
10
|
+
const filesystem = createPreview2Filesystem(config);
|
|
11
|
+
return {
|
|
12
|
+
types,
|
|
13
|
+
preopens: {
|
|
14
|
+
getDirectories() {
|
|
15
|
+
return filesystem.preopens
|
|
16
|
+
.getDirectories()
|
|
17
|
+
.map(([descriptor, path]) => [wrapDescriptor(descriptor), path]);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
dispose: filesystem.dispose,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Request, Response } from "../../../types/interfaces/wasi-http-
|
|
2
|
-
declare function send(request:
|
|
1
|
+
import type { Request as RequestT, Response as ResponseT } from "../../../types/interfaces/wasi-http-types.d.ts";
|
|
2
|
+
declare function send(request: RequestT): Promise<ResponseT>;
|
|
3
3
|
declare const _default: {
|
|
4
4
|
send: typeof send;
|
|
5
5
|
};
|