convex-rust 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +137 -2
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +200 -0
- package/dist/cli/build.d.ts +146 -0
- package/dist/cli/build.js +902 -0
- package/dist/cli/demangle.d.ts +7 -0
- package/dist/cli/demangle.js +328 -0
- package/dist/cli/diagnostics.d.ts +34 -0
- package/dist/cli/diagnostics.js +296 -0
- package/dist/cli/generate.d.ts +29 -0
- package/dist/cli/generate.js +82 -0
- package/dist/cli/manifest.d.ts +24 -0
- package/dist/cli/manifest.js +75 -0
- package/dist/cli/rustApi.d.ts +78 -0
- package/dist/cli/rustApi.js +609 -0
- package/dist/cli/scaffold.d.ts +22 -0
- package/dist/cli/scaffold.js +114 -0
- package/dist/cli/shim.d.ts +30 -0
- package/dist/cli/shim.js +140 -0
- package/dist/cli/size.d.ts +17 -0
- package/dist/cli/size.js +73 -0
- package/dist/cli/split.d.ts +20 -0
- package/dist/cli/split.js +140 -0
- package/dist/cli/symbols.d.ts +30 -0
- package/dist/cli/symbols.js +133 -0
- package/dist/cli/toolchain.d.ts +53 -0
- package/dist/cli/toolchain.js +167 -0
- package/dist/cli/validators.d.ts +6 -0
- package/dist/cli/validators.js +66 -0
- package/dist/cli/wasisdk.d.ts +82 -0
- package/dist/cli/wasisdk.js +220 -0
- package/dist/cli/wasmHints.d.ts +29 -0
- package/dist/cli/wasmHints.js +172 -0
- package/dist/runtime/base64.d.ts +4 -0
- package/dist/runtime/base64.js +77 -0
- package/dist/runtime/crypto.d.ts +7 -0
- package/dist/runtime/crypto.js +421 -0
- package/dist/runtime/fastjson.d.ts +3 -0
- package/dist/runtime/fastjson.js +170 -0
- package/dist/runtime/host.d.ts +73 -0
- package/dist/runtime/host.js +1230 -0
- package/dist/runtime/http.d.ts +40 -0
- package/dist/runtime/http.js +157 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/intl.d.ts +5 -0
- package/dist/runtime/intl.js +69 -0
- package/dist/runtime/tmpfs.d.ts +129 -0
- package/dist/runtime/tmpfs.js +624 -0
- package/dist/runtime/wasi.d.ts +33 -0
- package/dist/runtime/wasi.js +216 -0
- package/package.json +57 -4
- package/rust/convex_fn/Cargo.toml +32 -0
- package/rust/convex_fn/LICENSE +201 -0
- package/rust/convex_fn/build.rs +3 -0
- package/rust/convex_fn/src/args.rs +416 -0
- package/rust/convex_fn/src/crypto.rs +237 -0
- package/rust/convex_fn/src/ctx.rs +1044 -0
- package/rust/convex_fn/src/dns.rs +356 -0
- package/rust/convex_fn/src/error.rs +179 -0
- package/rust/convex_fn/src/executor.rs +577 -0
- package/rust/convex_fn/src/fanout.rs +106 -0
- package/rust/convex_fn/src/fs.rs +19 -0
- package/rust/convex_fn/src/function_ref.rs +219 -0
- package/rust/convex_fn/src/http.rs +441 -0
- package/rust/convex_fn/src/intl.rs +75 -0
- package/rust/convex_fn/src/lib.rs +242 -0
- package/rust/convex_fn/src/logging.rs +222 -0
- package/rust/convex_fn/src/native.rs +360 -0
- package/rust/convex_fn/src/net.rs +122 -0
- package/rust/convex_fn/src/sys.rs +178 -0
- package/rust/convex_fn/src/values.rs +121 -0
- package/rust/convex_fn/src/wire.rs +579 -0
- package/rust/convex_fn_macros/Cargo.toml +13 -0
- package/rust/convex_fn_macros/LICENSE +201 -0
- package/rust/convex_fn_macros/src/derive.rs +632 -0
- package/rust/convex_fn_macros/src/lib.rs +338 -0
- package/rust/convex_reqwest/Cargo.toml +69 -0
- package/rust/convex_reqwest/LICENSE +201 -0
- package/rust/convex_reqwest/src/blocking.rs +287 -0
- package/rust/convex_reqwest/src/body.rs +152 -0
- package/rust/convex_reqwest/src/client.rs +359 -0
- package/rust/convex_reqwest/src/config_types.rs +150 -0
- package/rust/convex_reqwest/src/error.rs +241 -0
- package/rust/convex_reqwest/src/into_url.rs +57 -0
- package/rust/convex_reqwest/src/lib.rs +42 -0
- package/rust/convex_reqwest/src/multipart.rs +140 -0
- package/rust/convex_reqwest/src/request.rs +358 -0
- package/rust/convex_reqwest/src/response.rs +310 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Convex limits an HTTP action's request and response body to 20 MiB. */
|
|
2
|
+
export declare const MAX_HTTP_BODY_BYTES: number;
|
|
3
|
+
export interface HttpHead {
|
|
4
|
+
method: string;
|
|
5
|
+
url: string;
|
|
6
|
+
headers: [string, string][];
|
|
7
|
+
}
|
|
8
|
+
/** The head the guest receives as its call args (the body follows as a host stream). */
|
|
9
|
+
export declare function requestHead(request: Request): HttpHead;
|
|
10
|
+
/** The Response for a buffered guest answer `{status, headers, body}` (`body` base64 or null). */
|
|
11
|
+
export declare function bufferedResponse(ok: any): Response;
|
|
12
|
+
/**
|
|
13
|
+
* Receives the guest's response writes. `start` builds the Response (its body is a ReadableStream
|
|
14
|
+
* fed by `write`); `write` waits while the client lags more than ~1 MiB behind, and fails once the
|
|
15
|
+
* client cancelled the response, so the guest stops producing.
|
|
16
|
+
*/
|
|
17
|
+
export declare class HttpSink {
|
|
18
|
+
readonly head: HttpHead;
|
|
19
|
+
readonly requestBody: ReadableStream<Uint8Array> | null;
|
|
20
|
+
/** Resolves when the guest sent `httpStart`. */
|
|
21
|
+
readonly started: Promise<void>;
|
|
22
|
+
/** Set by `start`. */
|
|
23
|
+
response: Response | null;
|
|
24
|
+
cancelled: boolean;
|
|
25
|
+
private resolveStarted;
|
|
26
|
+
private controller;
|
|
27
|
+
private waiting;
|
|
28
|
+
private written;
|
|
29
|
+
private ended;
|
|
30
|
+
constructor(head: HttpHead, requestBody: ReadableStream<Uint8Array> | null);
|
|
31
|
+
private release;
|
|
32
|
+
/** `httpStart`: validates the head and creates the streaming Response. */
|
|
33
|
+
start(status: unknown, headers: unknown): void;
|
|
34
|
+
/** `httpWrite`: queues bytes for the client; resolves once the queue has room again. */
|
|
35
|
+
write(bytes: Uint8Array): Promise<void>;
|
|
36
|
+
/** `httpEnd` (and the guest returning): closes the body. */
|
|
37
|
+
end(): void;
|
|
38
|
+
/** The guest failed after `httpStart`: error the body so the client sees a truncated response. */
|
|
39
|
+
fail(e: unknown): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// HTTP actions written in Rust (contracts/V8HOST.md "HTTP actions"): the Request -> guest head
|
|
2
|
+
// conversion, and the sink that turns a guest's `httpStart` / `httpWrite` / `httpEnd` tasks into a
|
|
3
|
+
// streamed Response. The wasm instance itself is driven by host.ts.
|
|
4
|
+
import { decodeBase64 } from "./base64.js";
|
|
5
|
+
/** Convex limits an HTTP action's request and response body to 20 MiB. */
|
|
6
|
+
export const MAX_HTTP_BODY_BYTES = 20 * 1024 * 1024;
|
|
7
|
+
/** Bytes buffered for a streamed response before `httpWrite` waits for the client to catch up. */
|
|
8
|
+
const STREAM_HIGH_WATER_BYTES = 1024 * 1024;
|
|
9
|
+
/** Statuses a `Response` cannot carry a body with. */
|
|
10
|
+
const NULL_BODY_STATUS = new Set([101, 204, 205, 304]);
|
|
11
|
+
/** The head the guest receives as its call args (the body follows as a host stream). */
|
|
12
|
+
export function requestHead(request) {
|
|
13
|
+
const headers = [];
|
|
14
|
+
request.headers.forEach((value, key) => headers.push([key, value]));
|
|
15
|
+
return { method: request.method, url: request.url, headers };
|
|
16
|
+
}
|
|
17
|
+
function toHeaders(pairs, what) {
|
|
18
|
+
const headers = new Headers();
|
|
19
|
+
if (pairs === undefined || pairs === null)
|
|
20
|
+
return headers;
|
|
21
|
+
if (!Array.isArray(pairs))
|
|
22
|
+
throw new Error(`${what}: headers must be a list of [name, value] pairs`);
|
|
23
|
+
for (const pair of pairs) {
|
|
24
|
+
if (!Array.isArray(pair) || typeof pair[0] !== "string" || typeof pair[1] !== "string") {
|
|
25
|
+
throw new Error(`${what}: headers must be [name, value] pairs`);
|
|
26
|
+
}
|
|
27
|
+
headers.append(pair[0], pair[1]);
|
|
28
|
+
}
|
|
29
|
+
return headers;
|
|
30
|
+
}
|
|
31
|
+
function checkStatus(status, what) {
|
|
32
|
+
if (typeof status !== "number" || !Number.isInteger(status) || status < 200 || status > 599) {
|
|
33
|
+
throw new Error(`${what}: invalid HTTP status ${String(status)} (expected 200..599)`);
|
|
34
|
+
}
|
|
35
|
+
return status;
|
|
36
|
+
}
|
|
37
|
+
/** The Response for a buffered guest answer `{status, headers, body}` (`body` base64 or null). */
|
|
38
|
+
export function bufferedResponse(ok) {
|
|
39
|
+
if (ok === null || typeof ok !== "object") {
|
|
40
|
+
throw new Error('The "use rust" HTTP action returned something other than an HttpResponse');
|
|
41
|
+
}
|
|
42
|
+
const status = checkStatus(ok.status, "HTTP response");
|
|
43
|
+
const headers = toHeaders(ok.headers, "HTTP response");
|
|
44
|
+
let body = null;
|
|
45
|
+
if (typeof ok.body === "string")
|
|
46
|
+
body = decodeBase64(ok.body);
|
|
47
|
+
else if (ok.body !== null && ok.body !== undefined) {
|
|
48
|
+
throw new Error("HTTP response: `body` must be a base64 string or null");
|
|
49
|
+
}
|
|
50
|
+
if (body !== null && body.length > MAX_HTTP_BODY_BYTES) {
|
|
51
|
+
throw new Error(`HTTP response of ${body.length} bytes exceeds the ${MAX_HTTP_BODY_BYTES} byte limit`);
|
|
52
|
+
}
|
|
53
|
+
if (NULL_BODY_STATUS.has(status))
|
|
54
|
+
body = null;
|
|
55
|
+
return new Response(body, { status, headers });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Receives the guest's response writes. `start` builds the Response (its body is a ReadableStream
|
|
59
|
+
* fed by `write`); `write` waits while the client lags more than ~1 MiB behind, and fails once the
|
|
60
|
+
* client cancelled the response, so the guest stops producing.
|
|
61
|
+
*/
|
|
62
|
+
export class HttpSink {
|
|
63
|
+
head;
|
|
64
|
+
requestBody;
|
|
65
|
+
/** Resolves when the guest sent `httpStart`. */
|
|
66
|
+
started;
|
|
67
|
+
/** Set by `start`. */
|
|
68
|
+
response = null;
|
|
69
|
+
cancelled = false;
|
|
70
|
+
resolveStarted;
|
|
71
|
+
controller;
|
|
72
|
+
waiting = [];
|
|
73
|
+
written = 0;
|
|
74
|
+
ended = false;
|
|
75
|
+
constructor(head, requestBody) {
|
|
76
|
+
this.head = head;
|
|
77
|
+
this.requestBody = requestBody;
|
|
78
|
+
this.started = new Promise((resolve) => {
|
|
79
|
+
this.resolveStarted = resolve;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
release() {
|
|
83
|
+
const w = this.waiting;
|
|
84
|
+
this.waiting = [];
|
|
85
|
+
for (const f of w)
|
|
86
|
+
f();
|
|
87
|
+
}
|
|
88
|
+
/** `httpStart`: validates the head and creates the streaming Response. */
|
|
89
|
+
start(status, headers) {
|
|
90
|
+
if (this.response)
|
|
91
|
+
throw new Error("httpStart: the response was already started");
|
|
92
|
+
const code = checkStatus(status, "httpStart");
|
|
93
|
+
if (NULL_BODY_STATUS.has(code)) {
|
|
94
|
+
throw new Error(`httpStart: status ${code} cannot have a streamed body`);
|
|
95
|
+
}
|
|
96
|
+
const h = toHeaders(headers, "httpStart");
|
|
97
|
+
const stream = new ReadableStream({
|
|
98
|
+
start: (c) => {
|
|
99
|
+
this.controller = c;
|
|
100
|
+
},
|
|
101
|
+
pull: () => this.release(),
|
|
102
|
+
cancel: () => {
|
|
103
|
+
this.cancelled = true;
|
|
104
|
+
this.release();
|
|
105
|
+
},
|
|
106
|
+
}, { highWaterMark: STREAM_HIGH_WATER_BYTES, size: (chunk) => chunk?.byteLength ?? 0 });
|
|
107
|
+
this.response = new Response(stream, { status: code, headers: h });
|
|
108
|
+
this.resolveStarted();
|
|
109
|
+
}
|
|
110
|
+
/** `httpWrite`: queues bytes for the client; resolves once the queue has room again. */
|
|
111
|
+
write(bytes) {
|
|
112
|
+
if (!this.response)
|
|
113
|
+
throw new Error("httpWrite before httpStart");
|
|
114
|
+
if (this.ended)
|
|
115
|
+
throw new Error("httpWrite after the response ended");
|
|
116
|
+
if (this.cancelled)
|
|
117
|
+
throw new Error("the client closed the response");
|
|
118
|
+
this.written += bytes.length;
|
|
119
|
+
if (this.written > MAX_HTTP_BODY_BYTES) {
|
|
120
|
+
const e = new Error(`HTTP response exceeds the ${MAX_HTTP_BODY_BYTES} byte limit`);
|
|
121
|
+
this.fail(e);
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
this.controller.enqueue(bytes);
|
|
125
|
+
const room = this.controller.desiredSize;
|
|
126
|
+
if (room !== null && room <= 0) {
|
|
127
|
+
return new Promise((resolve) => this.waiting.push(resolve));
|
|
128
|
+
}
|
|
129
|
+
return Promise.resolve();
|
|
130
|
+
}
|
|
131
|
+
/** `httpEnd` (and the guest returning): closes the body. */
|
|
132
|
+
end() {
|
|
133
|
+
if (!this.response || this.ended)
|
|
134
|
+
return;
|
|
135
|
+
this.ended = true;
|
|
136
|
+
try {
|
|
137
|
+
this.controller.close();
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// already cancelled / errored
|
|
141
|
+
}
|
|
142
|
+
this.release();
|
|
143
|
+
}
|
|
144
|
+
/** The guest failed after `httpStart`: error the body so the client sees a truncated response. */
|
|
145
|
+
fail(e) {
|
|
146
|
+
if (!this.response || this.ended)
|
|
147
|
+
return;
|
|
148
|
+
this.ended = true;
|
|
149
|
+
try {
|
|
150
|
+
this.controller.error(e);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// already cancelled / errored
|
|
154
|
+
}
|
|
155
|
+
this.release();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runRust, runRustHttp, collectEnviron, PANIC_LOG_PREFIX } from "./host.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Optional sync ops `intl/*` (contracts/ABI.md): time zones and locale formatting backed by the
|
|
2
|
+
// runtime's `Intl`. A wasm32 guest has no tz database; these never fall back to UTC.
|
|
3
|
+
const dtfCache = new Map();
|
|
4
|
+
function zoneFormat(tz) {
|
|
5
|
+
let f = dtfCache.get(tz);
|
|
6
|
+
if (!f) {
|
|
7
|
+
// Throws RangeError for an unknown zone.
|
|
8
|
+
f = new Intl.DateTimeFormat("en-US", {
|
|
9
|
+
timeZone: tz,
|
|
10
|
+
hourCycle: "h23",
|
|
11
|
+
year: "numeric",
|
|
12
|
+
month: "numeric",
|
|
13
|
+
day: "numeric",
|
|
14
|
+
hour: "numeric",
|
|
15
|
+
minute: "numeric",
|
|
16
|
+
second: "numeric",
|
|
17
|
+
era: "short",
|
|
18
|
+
});
|
|
19
|
+
dtfCache.set(tz, f);
|
|
20
|
+
}
|
|
21
|
+
return f;
|
|
22
|
+
}
|
|
23
|
+
/** Offset of `tz` from UTC at `epochMs`, in seconds (east positive). */
|
|
24
|
+
export function tzOffsetSeconds(tz, epochMs) {
|
|
25
|
+
if (typeof tz !== "string" || tz === "")
|
|
26
|
+
throw new Error("intl/tzOffset: `tz` must be a non-empty string");
|
|
27
|
+
if (typeof epochMs !== "number" || !Number.isFinite(epochMs)) {
|
|
28
|
+
throw new Error("intl/tzOffset: `epochMs` must be a finite number");
|
|
29
|
+
}
|
|
30
|
+
const secs = Math.floor(epochMs / 1000);
|
|
31
|
+
const parts = zoneFormat(tz).formatToParts(new Date(secs * 1000));
|
|
32
|
+
const get = (t) => parts.find((p) => p.type === t)?.value;
|
|
33
|
+
let year = Number(get("year"));
|
|
34
|
+
if ((get("era") ?? "").startsWith("B"))
|
|
35
|
+
year = 1 - year; // BC: astronomical year numbering
|
|
36
|
+
// The wall clock read as if it were UTC (setUTCFullYear, since Date.UTC maps years 0..99 to 1900..1999).
|
|
37
|
+
const d = new Date(0);
|
|
38
|
+
d.setUTCFullYear(year, Number(get("month")) - 1, Number(get("day")));
|
|
39
|
+
d.setUTCHours(Number(get("hour")), Number(get("minute")), Number(get("second")), 0);
|
|
40
|
+
return Math.round((d.getTime() - secs * 1000) / 1000);
|
|
41
|
+
}
|
|
42
|
+
export function intlOp(op, args) {
|
|
43
|
+
try {
|
|
44
|
+
if (op === "intl/tzOffset") {
|
|
45
|
+
return { ok: tzOffsetSeconds(args?.tz, args?.epochMs) };
|
|
46
|
+
}
|
|
47
|
+
if (op === "intl/format") {
|
|
48
|
+
const locale = args?.locale === undefined || args.locale === "" ? undefined : args.locale;
|
|
49
|
+
const options = args?.options ?? undefined;
|
|
50
|
+
if (args?.kind === "date") {
|
|
51
|
+
if (typeof args.value !== "number" || !Number.isFinite(args.value)) {
|
|
52
|
+
throw new Error("intl/format: date `value` must be a finite number of epoch milliseconds");
|
|
53
|
+
}
|
|
54
|
+
return { ok: new Intl.DateTimeFormat(locale, options).format(new Date(args.value)) };
|
|
55
|
+
}
|
|
56
|
+
if (args?.kind === "number") {
|
|
57
|
+
if (typeof args.value !== "number")
|
|
58
|
+
throw new Error("intl/format: number `value` must be a number");
|
|
59
|
+
return { ok: new Intl.NumberFormat(locale, options).format(args.value) };
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`intl/format: unknown kind ${JSON.stringify(args?.kind)}`);
|
|
62
|
+
}
|
|
63
|
+
return { error: { message: `unknown sync op ${op}` } };
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
const m = String(e?.message ?? e);
|
|
67
|
+
return { error: { message: m.startsWith("intl/") ? m : `${op}: ${m}` } };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export declare const TMP_DIR = "/tmp";
|
|
2
|
+
/** Default cap on the allocated bytes of all files. */
|
|
3
|
+
export declare const DEFAULT_TMP_BYTES: number;
|
|
4
|
+
interface Seg {
|
|
5
|
+
/** Guest address, or -1 when `arr` holds the bytes. */
|
|
6
|
+
ptr: number;
|
|
7
|
+
arr?: Uint8Array;
|
|
8
|
+
cap: number;
|
|
9
|
+
}
|
|
10
|
+
interface Base {
|
|
11
|
+
ino: number;
|
|
12
|
+
parent: DirNode | null;
|
|
13
|
+
atim: bigint;
|
|
14
|
+
mtim: bigint;
|
|
15
|
+
ctim: bigint;
|
|
16
|
+
/** Open descriptors; an unlinked node is released when the last one closes. */
|
|
17
|
+
open: number;
|
|
18
|
+
unlinked: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface FileNode extends Base {
|
|
21
|
+
kind: "file";
|
|
22
|
+
segs: Seg[];
|
|
23
|
+
size: number;
|
|
24
|
+
}
|
|
25
|
+
interface DirNode extends Base {
|
|
26
|
+
kind: "dir";
|
|
27
|
+
entries: Map<string, Node>;
|
|
28
|
+
}
|
|
29
|
+
type Node = FileNode | DirNode;
|
|
30
|
+
export interface TmpFsOptions {
|
|
31
|
+
maxBytes?: number;
|
|
32
|
+
memory: () => WebAssembly.Memory;
|
|
33
|
+
/** Guest allocator (`convex_alloc`); absent => JS-backed segments. */
|
|
34
|
+
alloc?: (len: number) => number;
|
|
35
|
+
/** `convex_free(ptr, len)`; absent => guest segments are only forgotten on reset. */
|
|
36
|
+
free?: (ptr: number, len: number) => void;
|
|
37
|
+
}
|
|
38
|
+
export declare class TmpFs {
|
|
39
|
+
maxBytes: number;
|
|
40
|
+
private opts;
|
|
41
|
+
private root;
|
|
42
|
+
private fds;
|
|
43
|
+
private nextFd;
|
|
44
|
+
private nextIno;
|
|
45
|
+
/** Sum of the allocated segment capacities. */
|
|
46
|
+
used: number;
|
|
47
|
+
constructor(opts: TmpFsOptions);
|
|
48
|
+
/** Empties the file system. `release` hands the guest segments back to the guest allocator. */
|
|
49
|
+
reset(release: boolean): void;
|
|
50
|
+
private freeTree;
|
|
51
|
+
private newBase;
|
|
52
|
+
private mkdir;
|
|
53
|
+
private mkfile;
|
|
54
|
+
private segCap;
|
|
55
|
+
private view;
|
|
56
|
+
private freeSegs;
|
|
57
|
+
/** Makes sure the file has segments for `size` bytes; throws ENOSPC beyond the cap or when the guest cannot allocate. */
|
|
58
|
+
private reserve;
|
|
59
|
+
/** Copies between the file and `buf`; callers have reserved the range for writes. */
|
|
60
|
+
private xfer;
|
|
61
|
+
private zero;
|
|
62
|
+
private setSize;
|
|
63
|
+
private release;
|
|
64
|
+
private dirOf;
|
|
65
|
+
/** Resolves `path` relative to `dir`. Returns the parent directory, the last name and the node (if it exists). */
|
|
66
|
+
private walk;
|
|
67
|
+
private unlinkNode;
|
|
68
|
+
open(dirfd: number, path: string, oflags: number, rightsBase: bigint, fdflags: number): number;
|
|
69
|
+
close(fd: number): void;
|
|
70
|
+
has(fd: number): boolean;
|
|
71
|
+
private file;
|
|
72
|
+
read(fd: number, bufs: Uint8Array[], at?: number): number;
|
|
73
|
+
/** `chunks` are copied before any allocation (an allocation can grow, and so detach, the guest memory). */
|
|
74
|
+
write(fd: number, chunks: Uint8Array[], at?: number): number;
|
|
75
|
+
seek(fd: number, offset: bigint, whence: number): number;
|
|
76
|
+
tell(fd: number): number;
|
|
77
|
+
truncate(fd: number, size: bigint): void;
|
|
78
|
+
allocate(fd: number, offset: bigint, len: bigint): void;
|
|
79
|
+
node(fd: number): Node;
|
|
80
|
+
stat(dirfd: number, path: string): Node;
|
|
81
|
+
createDir(dirfd: number, path: string): void;
|
|
82
|
+
removeDir(dirfd: number, path: string): void;
|
|
83
|
+
unlink(dirfd: number, path: string): void;
|
|
84
|
+
rename(oldfd: number, oldPath: string, newfd: number, newPath: string): void;
|
|
85
|
+
/** Directory listing for `fd_readdir`: `.`, `..`, then the entries in creation order. */
|
|
86
|
+
list(fd: number): {
|
|
87
|
+
name: string;
|
|
88
|
+
node: Node;
|
|
89
|
+
}[];
|
|
90
|
+
setTimes(n: Node, atim: bigint | null, mtim: bigint | null): void;
|
|
91
|
+
fdInfo(fd: number): {
|
|
92
|
+
filetype: number;
|
|
93
|
+
append: boolean;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** The `wasi_snapshot_preview1` file-system functions backed by `fs`. Merged into the table of `makeWasi`. */
|
|
97
|
+
export declare function tmpFsImports(fs: TmpFs, memory: () => WebAssembly.Memory): {
|
|
98
|
+
fd_prestat_get: (fd: number, ptr: number) => number;
|
|
99
|
+
fd_prestat_dir_name: (fd: number, ptr: number, len: number) => number;
|
|
100
|
+
path_open: (dirfd: number, _dirflags: number, pathPtr: number, pathLen: number, oflags: number, rightsBase: bigint, _rightsInh: bigint, fdflags: number, outPtr: number) => number;
|
|
101
|
+
fd_close: (fd: number) => number;
|
|
102
|
+
fd_read: (fd: number, iov: number, n: number, outPtr: number) => number;
|
|
103
|
+
fd_pread: (fd: number, iov: number, n: number, off: bigint, outPtr: number) => number;
|
|
104
|
+
fd_pwrite: (fd: number, iov: number, n: number, off: bigint, outPtr: number) => number;
|
|
105
|
+
fd_seek: (fd: number, off: bigint, whence: number, outPtr: number) => number;
|
|
106
|
+
fd_tell: (fd: number, outPtr: number) => number;
|
|
107
|
+
fd_sync: (fd: number) => number;
|
|
108
|
+
fd_datasync: (fd: number) => number;
|
|
109
|
+
fd_advise: (fd: number) => number;
|
|
110
|
+
fd_allocate: (fd: number, off: bigint, len: bigint) => number;
|
|
111
|
+
fd_fdstat_get: (fd: number, ptr: number) => number;
|
|
112
|
+
fd_fdstat_set_flags: (fd: number) => number;
|
|
113
|
+
fd_filestat_get: (fd: number, ptr: number) => number;
|
|
114
|
+
fd_filestat_set_size: (fd: number, size: bigint) => number;
|
|
115
|
+
fd_filestat_set_times: (fd: number, a: bigint, m: bigint, flags: number) => number;
|
|
116
|
+
path_filestat_get: (fd: number, _flags: number, p: number, l: number, out: number) => number;
|
|
117
|
+
path_filestat_set_times: (fd: number, _fl: number, p: number, l: number, a: bigint, m: bigint, flags: number) => number;
|
|
118
|
+
path_create_directory: (fd: number, p: number, l: number) => number;
|
|
119
|
+
path_remove_directory: (fd: number, p: number, l: number) => number;
|
|
120
|
+
path_unlink_file: (fd: number, p: number, l: number) => number;
|
|
121
|
+
path_rename: (ofd: number, op: number, ol: number, nfd: number, np: number, nl: number) => number;
|
|
122
|
+
path_readlink: () => 28;
|
|
123
|
+
path_symlink: () => 63;
|
|
124
|
+
path_link: () => 63;
|
|
125
|
+
fd_readdir: (fd: number, buf: number, bufLen: number, cookie: bigint, usedPtr: number) => number;
|
|
126
|
+
/** fd_write for descriptors of this file system (stdout/stderr stay with the caller). */
|
|
127
|
+
write: (fd: number, iov: number, n: number, outPtr: number) => number;
|
|
128
|
+
};
|
|
129
|
+
export {};
|