@syntropika/tembra-sdk 0.2.1 → 0.3.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 +43 -17
- package/dist/authoring/types.d.ts +64 -3
- package/dist/authoring/wit.d.ts +6 -0
- package/dist/bridge/commands.d.ts +1190 -0
- package/dist/bridge/identifiers.d.ts +2 -0
- package/dist/bridge/kernel.d.ts +18 -107
- package/dist/bridge/protocol.d.ts +3 -138
- package/dist/browser.d.ts +14 -1
- package/dist/browser.js +141 -3298
- package/dist/chunks/browser-b8jamxw2.js +3399 -0
- package/dist/chunks/execution-nsqc6nrt.js +1419 -0
- package/dist/chunks/index-01zk0xqx.js +160 -0
- package/dist/chunks/index-3fjdfdfd.js +152 -0
- package/dist/chunks/index-aaymjn7v.js +787 -0
- package/dist/chunks/index-c1w7z9hx.js +356 -0
- package/dist/chunks/index-h8t0n42q.js +738 -0
- package/dist/chunks/index-hfds9mzp.js +308 -0
- package/dist/chunks/index-kr4x67wt.js +177 -0
- package/dist/chunks/index-kr6bnh34.js +117 -0
- package/dist/chunks/index-kyt9dj0a.js +1421 -0
- package/dist/chunks/index-n1wxzc9w.js +830 -0
- package/dist/chunks/index-pvac426d.js +74 -0
- package/dist/chunks/index-smyds5ce.js +3234 -0
- package/dist/chunks/index-sse8aapb.js +121 -0
- package/dist/chunks/index-v6heph77.js +643 -0
- package/dist/chunks/index-xrdvnv37.js +3448 -0
- package/dist/chunks/index-za4mg94e.js +26 -0
- package/dist/chunks/index-zkqmnjj8.js +167 -0
- package/dist/coordinator.js +9 -500
- package/dist/error.d.ts +2 -0
- package/dist/errors.d.ts +3 -0
- package/dist/guest.d.ts +173 -0
- package/dist/guest.js +26 -0
- package/dist/host.d.ts +36 -30
- package/dist/host.js +37 -3276
- package/dist/http/bytes.d.ts +8 -0
- package/dist/http/events.d.ts +7 -0
- package/dist/http.d.ts +45 -0
- package/dist/http.js +291 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -862
- package/dist/infrastructure/rpc/client.d.ts +2 -1
- package/dist/infrastructure/rpc/resources.d.ts +28 -0
- package/dist/interpreter/abi.d.ts +54 -0
- package/dist/interpreter/acquire.d.ts +18 -0
- package/dist/interpreter/browser-network.d.ts +52 -0
- package/dist/interpreter/browser-port.d.ts +55 -0
- package/dist/interpreter/browser.d.ts +79 -0
- package/dist/interpreter/cli.d.ts +5 -0
- package/dist/interpreter/codec.d.ts +42 -0
- package/dist/interpreter/component/execution.d.ts +42 -0
- package/dist/interpreter/component/host.d.ts +69 -0
- package/dist/interpreter/component/instance.d.ts +40 -0
- package/dist/interpreter/component/kernel.d.ts +120 -0
- package/dist/interpreter/component/names.d.ts +5 -0
- package/dist/interpreter/component/port.d.ts +85 -0
- package/dist/interpreter/component/prepared.d.ts +97 -0
- package/dist/interpreter/component/resources.d.ts +45 -0
- package/dist/interpreter/component/revision.d.ts +87 -0
- package/dist/interpreter/component/scope.d.ts +116 -0
- package/dist/interpreter/component/streams.d.ts +28 -0
- package/dist/interpreter/component/values.d.ts +79 -0
- package/dist/interpreter/component/wasi-filesystem.d.ts +21 -0
- package/dist/interpreter/component/wasi-host.d.ts +64 -0
- package/dist/interpreter/component/wasi-http.d.ts +33 -0
- package/dist/interpreter/component/wasi-sockets.d.ts +183 -0
- package/dist/interpreter/component/wasi.d.ts +41 -0
- package/dist/interpreter/core.d.ts +64 -0
- package/dist/interpreter/fetch-http-provider.d.ts +17 -0
- package/dist/interpreter/filesystem/contract.d.ts +85 -0
- package/dist/interpreter/filesystem/memory.d.ts +3 -0
- package/dist/interpreter/filesystem/opfs.d.ts +3 -0
- package/dist/interpreter/filesystem/scope.d.ts +35 -0
- package/dist/interpreter/filesystem.d.ts +8 -0
- package/dist/interpreter/gate.d.ts +6 -0
- package/dist/interpreter/host-protocol.d.ts +100 -0
- package/dist/interpreter/http-ingress-fetch.d.ts +7 -0
- package/dist/interpreter/http-ingress.d.ts +96 -0
- package/dist/interpreter/http-provider.d.ts +85 -0
- package/dist/interpreter/io.d.ts +20 -0
- package/dist/interpreter/mobile.d.ts +149 -0
- package/dist/interpreter/native-ingress.d.ts +95 -0
- package/dist/interpreter/node-port.d.ts +25 -0
- package/dist/interpreter/node.d.ts +36 -0
- package/dist/interpreter/revision.d.ts +64 -0
- package/dist/interpreter/scope.d.ts +89 -0
- package/dist/interpreter/socket-addresses.d.ts +50 -0
- package/dist/interpreter/socket-provider.d.ts +110 -0
- package/dist/interpreter/standard-cli.d.ts +34 -0
- package/dist/interpreter/standard-codec.d.ts +96 -0
- package/dist/interpreter/standard-filesystem.d.ts +47 -0
- package/dist/interpreter/standard-host.d.ts +71 -0
- package/dist/interpreter/standard-http-values.d.ts +159 -0
- package/dist/interpreter/standard-http.d.ts +9 -0
- package/dist/interpreter/standard-ingress.d.ts +63 -0
- package/dist/interpreter/standard-sockets.d.ts +177 -0
- package/dist/interpreter/standard-streams.d.ts +218 -0
- package/dist/interpreter/standard-system.d.ts +35 -0
- package/dist/interpreter/standard-utf8.d.ts +4 -0
- package/dist/interpreter/standard.d.ts +18 -0
- package/dist/interpreter/types.d.ts +152 -0
- package/dist/interpreter/wit-shape.d.ts +92 -0
- package/dist/manager.js +5 -332
- package/dist/msgpack.js +9 -615
- package/dist/node.d.ts +8 -1
- package/dist/node.js +248 -3287
- package/dist/rpc.js +196 -699
- package/dist/runtime/adapters.d.ts +120 -0
- package/dist/runtime/adapters.js +38 -0
- package/dist/runtime/calls.d.ts +9 -3
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/orbs.d.ts +5 -4
- package/dist/runtime/references.d.ts +27 -1
- package/dist/runtime/reload.d.ts +5 -3
- package/dist/runtime/scopes.d.ts +1 -1
- package/dist/runtime/signals.d.ts +4 -0
- package/dist/runtime/wit-client.d.ts +38 -0
- package/dist/telemetry.js +4 -25
- package/dist/tooling/build.d.ts +2 -2
- package/dist/tooling/client-resources.d.ts +23 -0
- package/dist/tooling/client.d.ts +10 -0
- package/dist/tooling/component-glue.d.ts +17 -0
- package/dist/tooling/component.d.ts +11 -0
- package/dist/tooling/index.d.ts +3 -1
- package/dist/tooling/index.js +1155 -102
- package/dist/tooling/resolver.d.ts +4 -4
- package/dist/tooling/typecheck.d.ts +2 -1
- package/dist/tooling/types.d.ts +27 -12
- package/dist/tooling/wit.d.ts +9 -0
- package/dist/wasi/wasi-clocks-types.d.ts +2 -0
- package/dist/wasi/wasi-http-client.d.ts +5 -0
- package/dist/wasi/wasi-http-types.d.ts +285 -0
- package/dist/wasi/wasi-sockets-ip-name-lookup.d.ts +23 -0
- package/dist/wasi/wasi-sockets-types.d.ts +146 -0
- package/package.json +62 -35
- package/src/authoring/declaration.ts +1 -1
- package/src/authoring/types.ts +53 -3
- package/src/authoring/wit.ts +15 -0
- package/src/bridge/commands.ts +1105 -0
- package/src/bridge/identifiers.ts +2 -0
- package/src/bridge/kernel.ts +56 -98
- package/src/bridge/protocol.ts +3 -142
- package/src/browser.ts +90 -6
- package/src/context-key.ts +4 -7
- package/src/error.ts +1 -1
- package/src/errors.ts +7 -0
- package/src/guest.ts +327 -0
- package/src/host.ts +128 -23
- package/src/http/bytes.ts +87 -0
- package/src/http/events.ts +34 -0
- package/src/http.ts +272 -0
- package/src/index.ts +3 -0
- package/src/infrastructure/rpc/client.ts +136 -17
- package/src/infrastructure/rpc/resources.ts +123 -0
- package/src/interpreter/abi.ts +69 -0
- package/src/interpreter/acquire.ts +58 -0
- package/src/interpreter/browser-network.ts +170 -0
- package/src/interpreter/browser-port.ts +425 -0
- package/src/interpreter/browser.ts +340 -0
- package/src/interpreter/cli.ts +30 -0
- package/src/interpreter/codec.ts +298 -0
- package/src/interpreter/component/execution.ts +264 -0
- package/src/interpreter/component/host.ts +409 -0
- package/src/interpreter/component/instance.ts +138 -0
- package/src/interpreter/component/kernel.ts +611 -0
- package/src/interpreter/component/names.ts +13 -0
- package/src/interpreter/component/port.ts +598 -0
- package/src/interpreter/component/prepared.ts +194 -0
- package/src/interpreter/component/resources.ts +345 -0
- package/src/interpreter/component/revision.ts +702 -0
- package/src/interpreter/component/scope.ts +447 -0
- package/src/interpreter/component/streams.ts +180 -0
- package/src/interpreter/component/values.ts +254 -0
- package/src/interpreter/component/wasi-filesystem.ts +472 -0
- package/src/interpreter/component/wasi-host.ts +197 -0
- package/src/interpreter/component/wasi-http.ts +939 -0
- package/src/interpreter/component/wasi-sockets.ts +958 -0
- package/src/interpreter/component/wasi.ts +238 -0
- package/src/interpreter/core.ts +386 -0
- package/src/interpreter/fetch-http-provider.ts +98 -0
- package/src/interpreter/filesystem/contract.ts +138 -0
- package/src/interpreter/filesystem/memory.ts +180 -0
- package/src/interpreter/filesystem/opfs.ts +294 -0
- package/src/interpreter/filesystem/scope.ts +390 -0
- package/src/interpreter/filesystem.ts +20 -0
- package/src/interpreter/gate.ts +55 -0
- package/src/interpreter/host-protocol.ts +242 -0
- package/src/interpreter/http-ingress-fetch.ts +133 -0
- package/src/interpreter/http-ingress.ts +203 -0
- package/src/interpreter/http-provider.ts +105 -0
- package/src/interpreter/io.ts +66 -0
- package/src/interpreter/mobile.ts +385 -0
- package/src/interpreter/native-ingress.ts +550 -0
- package/src/interpreter/node-port.ts +218 -0
- package/src/interpreter/node.ts +114 -0
- package/src/interpreter/revision.ts +450 -0
- package/src/interpreter/scope.ts +453 -0
- package/src/interpreter/socket-addresses.ts +246 -0
- package/src/interpreter/socket-provider.ts +126 -0
- package/src/interpreter/standard-cli.ts +184 -0
- package/src/interpreter/standard-codec.ts +403 -0
- package/src/interpreter/standard-filesystem.ts +545 -0
- package/src/interpreter/standard-host.ts +840 -0
- package/src/interpreter/standard-http-values.ts +624 -0
- package/src/interpreter/standard-http.ts +622 -0
- package/src/interpreter/standard-ingress.ts +344 -0
- package/src/interpreter/standard-sockets.ts +847 -0
- package/src/interpreter/standard-streams.ts +710 -0
- package/src/interpreter/standard-system.ts +182 -0
- package/src/interpreter/standard-utf8.ts +72 -0
- package/src/interpreter/standard.ts +283 -0
- package/src/interpreter/types.ts +163 -0
- package/src/interpreter/wit-shape.ts +175 -0
- package/src/node.ts +43 -14
- package/src/runtime/activities.ts +6 -6
- package/src/runtime/adapters.ts +314 -0
- package/src/runtime/calls.ts +218 -56
- package/src/runtime/context.ts +7 -7
- package/src/runtime/lifecycle.ts +36 -17
- package/src/runtime/orbs.ts +81 -39
- package/src/runtime/programs.ts +16 -8
- package/src/runtime/references.ts +128 -11
- package/src/runtime/reload.ts +71 -30
- package/src/runtime/resources.ts +2 -2
- package/src/runtime/scopes.ts +17 -17
- package/src/runtime/session.ts +3 -1
- package/src/runtime/signals.ts +31 -0
- package/src/runtime/wit-client.ts +228 -0
- package/src/tooling/build.ts +152 -54
- package/src/tooling/client-resources.ts +74 -0
- package/src/tooling/client.ts +531 -0
- package/src/tooling/component-glue.ts +288 -0
- package/src/tooling/component.ts +225 -0
- package/src/tooling/index.ts +3 -7
- package/src/tooling/resolver.ts +42 -25
- package/src/tooling/typecheck.ts +59 -4
- package/src/tooling/types.ts +27 -12
- package/src/tooling/wit.ts +188 -0
- package/dist/embedded.d.ts +0 -1
- package/dist/embedded.js +0 -1
- package/src/embedded.ts +0 -293
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Errors2,
|
|
3
|
+
TembraError2,
|
|
4
|
+
failure
|
|
5
|
+
} from "./index-c1w7z9hx.js";
|
|
6
|
+
import {
|
|
7
|
+
utf8Encode,
|
|
8
|
+
utf8Decode
|
|
9
|
+
} from "./index-pvac426d.js";
|
|
10
|
+
|
|
11
|
+
// src/interpreter/http-ingress.ts
|
|
12
|
+
var HTTP_HANDLER = "wasi:http/handler@0.3.0";
|
|
13
|
+
|
|
14
|
+
class HttpHandlerError2 extends Error {
|
|
15
|
+
code;
|
|
16
|
+
constructor(code, message = `HTTP handler failed: ${code.tag}`) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.name = "HttpHandlerError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var CONNECTION_TERMINATED = { tag: "connection-terminated" };
|
|
23
|
+
var issued = new WeakSet;
|
|
24
|
+
|
|
25
|
+
class IngressExchange {
|
|
26
|
+
request;
|
|
27
|
+
head;
|
|
28
|
+
#resolve;
|
|
29
|
+
#reject;
|
|
30
|
+
#claimed = false;
|
|
31
|
+
#owned = false;
|
|
32
|
+
#published = false;
|
|
33
|
+
#refusal;
|
|
34
|
+
constructor(request) {
|
|
35
|
+
this.request = request;
|
|
36
|
+
this.head = new Promise((resolve, reject) => {
|
|
37
|
+
this.#resolve = resolve;
|
|
38
|
+
this.#reject = reject;
|
|
39
|
+
});
|
|
40
|
+
issued.add(this);
|
|
41
|
+
}
|
|
42
|
+
get published() {
|
|
43
|
+
return this.#published;
|
|
44
|
+
}
|
|
45
|
+
respond(response) {
|
|
46
|
+
if (this.#published)
|
|
47
|
+
throw new Error("the response head was already published");
|
|
48
|
+
this.#published = true;
|
|
49
|
+
this.#resolve(response);
|
|
50
|
+
}
|
|
51
|
+
refuse(code) {
|
|
52
|
+
if (this.#published)
|
|
53
|
+
throw new Error("the response head was already published");
|
|
54
|
+
this.#published = true;
|
|
55
|
+
this.#refusal = new HttpHandlerError2(code);
|
|
56
|
+
}
|
|
57
|
+
own() {
|
|
58
|
+
this.#owned = true;
|
|
59
|
+
return this.request;
|
|
60
|
+
}
|
|
61
|
+
settle(failure) {
|
|
62
|
+
if (!this.#owned) {
|
|
63
|
+
this.#owned = true;
|
|
64
|
+
try {
|
|
65
|
+
const done = this.request.body?.[Symbol.asyncIterator]().return?.();
|
|
66
|
+
if (typeof done?.then === "function")
|
|
67
|
+
Promise.resolve(done).catch(() => {});
|
|
68
|
+
} catch {}
|
|
69
|
+
if (typeof this.request.trailers?.then === "function")
|
|
70
|
+
Promise.resolve(this.request.trailers).catch(() => {});
|
|
71
|
+
}
|
|
72
|
+
if (this.#refusal !== undefined)
|
|
73
|
+
return this.#reject(this.#refusal);
|
|
74
|
+
if (this.#published && this.#refusal === undefined)
|
|
75
|
+
return;
|
|
76
|
+
this.#reject(failure ?? new Error("the HTTP handler ended without a response"));
|
|
77
|
+
}
|
|
78
|
+
static claim(value) {
|
|
79
|
+
if (typeof value !== "object" || value === null || !issued.has(value))
|
|
80
|
+
throw new TembraError2(Errors2.Invalid.LocalValue, `${HTTP_HANDLER} is served only through Host.handleHttp`);
|
|
81
|
+
const exchange = value;
|
|
82
|
+
if (exchange.#claimed)
|
|
83
|
+
throw new Error("the HTTP request was already handled");
|
|
84
|
+
exchange.#claimed = true;
|
|
85
|
+
return exchange;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function checkedRequest(request) {
|
|
89
|
+
if (typeof request !== "object" || request === null)
|
|
90
|
+
throw new TypeError("handleHttp requires a request");
|
|
91
|
+
const { method, scheme, authority, pathWithQuery, fields, body, trailers } = request;
|
|
92
|
+
if (typeof method !== "string")
|
|
93
|
+
throw new TypeError("request method must be a string");
|
|
94
|
+
for (const [name, value] of [
|
|
95
|
+
["scheme", scheme],
|
|
96
|
+
["authority", authority],
|
|
97
|
+
["pathWithQuery", pathWithQuery]
|
|
98
|
+
])
|
|
99
|
+
if (value !== undefined && typeof value !== "string")
|
|
100
|
+
throw new TypeError(`request ${name} must be a string`);
|
|
101
|
+
if (!Array.isArray(fields))
|
|
102
|
+
throw new TypeError("request fields must be an array");
|
|
103
|
+
const copied = fields.map((field) => {
|
|
104
|
+
const [name, value] = Array.isArray(field) ? field : [];
|
|
105
|
+
if (typeof name !== "string" || !(value instanceof Uint8Array))
|
|
106
|
+
throw new TypeError("request fields are [name, Uint8Array] pairs");
|
|
107
|
+
return Object.freeze([name, value.slice()]);
|
|
108
|
+
});
|
|
109
|
+
if (body !== null && typeof body?.[Symbol.asyncIterator] !== "function")
|
|
110
|
+
throw new TypeError("request body must be an AsyncIterable<Uint8Array> or null");
|
|
111
|
+
if (trailers !== undefined && typeof trailers?.then !== "function")
|
|
112
|
+
throw new TypeError("request trailers must be a promise");
|
|
113
|
+
return Object.freeze({
|
|
114
|
+
method,
|
|
115
|
+
scheme,
|
|
116
|
+
authority,
|
|
117
|
+
pathWithQuery,
|
|
118
|
+
fields: Object.freeze(copied),
|
|
119
|
+
body,
|
|
120
|
+
trailers
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/interpreter/http-provider.ts
|
|
125
|
+
class HttpProviderError2 extends Error {
|
|
126
|
+
code;
|
|
127
|
+
constructor(code, message = `HTTP provider failed: ${code.tag}`) {
|
|
128
|
+
super(message);
|
|
129
|
+
this.code = code;
|
|
130
|
+
this.name = "HttpProviderError";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function byteString(bytes) {
|
|
134
|
+
let text = "";
|
|
135
|
+
for (let at = 0;at < bytes.length; at += 8192)
|
|
136
|
+
text += String.fromCharCode(...bytes.subarray(at, at + 8192));
|
|
137
|
+
return text;
|
|
138
|
+
}
|
|
139
|
+
function bytesOf(text) {
|
|
140
|
+
return Uint8Array.from(text, (unit) => unit.charCodeAt(0) & 255);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/interpreter/types.ts
|
|
144
|
+
function answer(packet) {
|
|
145
|
+
const value = JSON.parse(packet);
|
|
146
|
+
if (Object.hasOwn(value, "ok"))
|
|
147
|
+
return value.ok;
|
|
148
|
+
throw failure(value.error ?? "Interpreter operation failed");
|
|
149
|
+
}
|
|
150
|
+
function query(contract, value) {
|
|
151
|
+
return answer(contract.request(JSON.stringify(value)));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/interpreter/standard.ts
|
|
155
|
+
var TYPES = [
|
|
156
|
+
["u64"],
|
|
157
|
+
["s64"],
|
|
158
|
+
["u32"],
|
|
159
|
+
["record", [["seconds", 1], ["nanoseconds", 2]]],
|
|
160
|
+
["bytes"],
|
|
161
|
+
["tuple", [0, 0]],
|
|
162
|
+
["own", 0],
|
|
163
|
+
["string"],
|
|
164
|
+
["tuple", [6, 7]],
|
|
165
|
+
["list", 8],
|
|
166
|
+
["borrow", 0],
|
|
167
|
+
["stream", "u8"],
|
|
168
|
+
["option", 7],
|
|
169
|
+
["variant", [["access", -1], ["already", -1], ["bad-descriptor", -1], ["busy", -1], ["deadlock", -1], ["quota", -1], ["exist", -1], ["file-too-large", -1], ["illegal-byte-sequence", -1], ["in-progress", -1], ["interrupted", -1], ["invalid", -1], ["io", -1], ["is-directory", -1], ["loop", -1], ["too-many-links", -1], ["message-size", -1], ["name-too-long", -1], ["no-device", -1], ["no-entry", -1], ["no-lock", -1], ["insufficient-memory", -1], ["insufficient-space", -1], ["not-directory", -1], ["not-empty", -1], ["not-recoverable", -1], ["unsupported", -1], ["no-tty", -1], ["no-such-device", -1], ["overflow", -1], ["not-permitted", -1], ["pipe", -1], ["read-only", -1], ["invalid-seek", -1], ["text-file-busy", -1], ["cross-device", -1], ["other", 12]]],
|
|
170
|
+
["result", -1, 13],
|
|
171
|
+
["future", 14],
|
|
172
|
+
["tuple", [11, 15]],
|
|
173
|
+
["enum", ["normal", "sequential", "random", "will-need", "dont-need", "no-reuse"]],
|
|
174
|
+
["flags", ["read", "write", "fileIntegritySync", "dataIntegritySync", "requestedWriteSync", "mutateDirectory"]],
|
|
175
|
+
["result", 18, 13],
|
|
176
|
+
["variant", [["block-device", -1], ["character-device", -1], ["directory", -1], ["fifo", -1], ["symbolic-link", -1], ["regular-file", -1], ["socket", -1], ["other", 12]]],
|
|
177
|
+
["result", 20, 13],
|
|
178
|
+
["variant", [["no-change", -1], ["now", -1], ["timestamp", 3]]],
|
|
179
|
+
["record", [["type", 20], ["name", 7]]],
|
|
180
|
+
["stream", 23],
|
|
181
|
+
["tuple", [24, 15]],
|
|
182
|
+
["option", 3],
|
|
183
|
+
["record", [["type", 20], ["linkCount", 0], ["size", 0], ["dataAccessTimestamp", 26], ["dataModificationTimestamp", 26], ["statusChangeTimestamp", 26]]],
|
|
184
|
+
["result", 27, 13],
|
|
185
|
+
["flags", ["symlinkFollow"]],
|
|
186
|
+
["flags", ["create", "directory", "exclusive", "truncate"]],
|
|
187
|
+
["result", 6, 13],
|
|
188
|
+
["result", 7, 13],
|
|
189
|
+
["bool"],
|
|
190
|
+
["record", [["lower", 0], ["upper", 0]]],
|
|
191
|
+
["result", 34, 13],
|
|
192
|
+
["tuple", [7, 7]],
|
|
193
|
+
["list", 36],
|
|
194
|
+
["list", 7],
|
|
195
|
+
["result", -1, -1],
|
|
196
|
+
["u8"],
|
|
197
|
+
["enum", ["io", "illegal-byte-sequence", "pipe"]],
|
|
198
|
+
["result", -1, 41],
|
|
199
|
+
["future", 42],
|
|
200
|
+
["tuple", [11, 43]],
|
|
201
|
+
["own", 1],
|
|
202
|
+
["option", 45],
|
|
203
|
+
["own", 2],
|
|
204
|
+
["option", 47],
|
|
205
|
+
["own", 3],
|
|
206
|
+
["tuple", [7, 4]],
|
|
207
|
+
["list", 50],
|
|
208
|
+
["variant", [["invalid-syntax", -1], ["forbidden", -1], ["immutable", -1], ["size-exceeded", -1], ["other", 12]]],
|
|
209
|
+
["result", 49, 52],
|
|
210
|
+
["borrow", 3],
|
|
211
|
+
["list", 4],
|
|
212
|
+
["result", -1, 52],
|
|
213
|
+
["result", 55, 52],
|
|
214
|
+
["option", 49],
|
|
215
|
+
["u16"],
|
|
216
|
+
["option", 59],
|
|
217
|
+
["record", [["rcode", 12], ["infoCode", 60]]],
|
|
218
|
+
["option", 40],
|
|
219
|
+
["record", [["alertId", 62], ["alertMessage", 12]]],
|
|
220
|
+
["option", 0],
|
|
221
|
+
["option", 2],
|
|
222
|
+
["record", [["fieldName", 12], ["fieldSize", 65]]],
|
|
223
|
+
["option", 66],
|
|
224
|
+
["variant", [["DNS-timeout", -1], ["DNS-error", 61], ["destination-not-found", -1], ["destination-unavailable", -1], ["destination-IP-prohibited", -1], ["destination-IP-unroutable", -1], ["connection-refused", -1], ["connection-terminated", -1], ["connection-timeout", -1], ["connection-read-timeout", -1], ["connection-write-timeout", -1], ["connection-limit-reached", -1], ["TLS-protocol-error", -1], ["TLS-certificate-error", -1], ["TLS-alert-received", 63], ["HTTP-request-denied", -1], ["HTTP-request-length-required", -1], ["HTTP-request-body-size", 64], ["HTTP-request-method-invalid", -1], ["HTTP-request-URI-invalid", -1], ["HTTP-request-URI-too-long", -1], ["HTTP-request-header-section-size", 65], ["HTTP-request-header-size", 67], ["HTTP-request-trailer-section-size", 65], ["HTTP-request-trailer-size", 66], ["HTTP-response-incomplete", -1], ["HTTP-response-header-section-size", 65], ["HTTP-response-header-size", 66], ["HTTP-response-body-size", 64], ["HTTP-response-trailer-section-size", 65], ["HTTP-response-trailer-size", 66], ["HTTP-response-transfer-coding", 12], ["HTTP-response-content-coding", 12], ["HTTP-response-timeout", -1], ["HTTP-upgrade-failed", -1], ["HTTP-protocol-error", -1], ["loop-detected", -1], ["configuration-error", -1], ["internal-error", 12]]],
|
|
225
|
+
["result", 58, 68],
|
|
226
|
+
["future", 69],
|
|
227
|
+
["option", 11],
|
|
228
|
+
["own", 4],
|
|
229
|
+
["option", 72],
|
|
230
|
+
["own", 5],
|
|
231
|
+
["result", -1, 68],
|
|
232
|
+
["future", 75],
|
|
233
|
+
["tuple", [74, 76]],
|
|
234
|
+
["borrow", 5],
|
|
235
|
+
["variant", [["get", -1], ["head", -1], ["post", -1], ["put", -1], ["delete", -1], ["connect", -1], ["options", -1], ["trace", -1], ["patch", -1], ["other", 7]]],
|
|
236
|
+
["variant", [["HTTP", -1], ["HTTPS", -1], ["other", 7]]],
|
|
237
|
+
["option", 80],
|
|
238
|
+
["tuple", [11, 70]],
|
|
239
|
+
["borrow", 4],
|
|
240
|
+
["variant", [["not-supported", -1], ["immutable", -1], ["other", 12]]],
|
|
241
|
+
["result", -1, 84],
|
|
242
|
+
["own", 6],
|
|
243
|
+
["tuple", [86, 76]],
|
|
244
|
+
["borrow", 6],
|
|
245
|
+
["result", 86, 68],
|
|
246
|
+
["enum", ["ipv4", "ipv6"]],
|
|
247
|
+
["own", 7],
|
|
248
|
+
["variant", [["access-denied", -1], ["not-supported", -1], ["invalid-argument", -1], ["out-of-memory", -1], ["timeout", -1], ["invalid-state", -1], ["address-not-bindable", -1], ["address-in-use", -1], ["remote-unreachable", -1], ["connection-refused", -1], ["connection-broken", -1], ["connection-reset", -1], ["connection-aborted", -1], ["datagram-too-large", -1], ["other", 12]]],
|
|
249
|
+
["result", 91, 92],
|
|
250
|
+
["borrow", 7],
|
|
251
|
+
["tuple", [40, 40, 40, 40]],
|
|
252
|
+
["record", [["port", 59], ["address", 95]]],
|
|
253
|
+
["tuple", [59, 59, 59, 59, 59, 59, 59, 59]],
|
|
254
|
+
["record", [["port", 59], ["flowInfo", 2], ["address", 97], ["scopeId", 2]]],
|
|
255
|
+
["variant", [["ipv4", 96], ["ipv6", 98]]],
|
|
256
|
+
["result", -1, 92],
|
|
257
|
+
["stream", 91],
|
|
258
|
+
["result", 101, 92],
|
|
259
|
+
["future", 100],
|
|
260
|
+
["tuple", [11, 103]],
|
|
261
|
+
["result", 99, 92],
|
|
262
|
+
["result", 33, 92],
|
|
263
|
+
["result", 0, 92],
|
|
264
|
+
["result", 2, 92],
|
|
265
|
+
["result", 40, 92],
|
|
266
|
+
["own", 8],
|
|
267
|
+
["result", 110, 92],
|
|
268
|
+
["borrow", 8],
|
|
269
|
+
["option", 99],
|
|
270
|
+
["tuple", [4, 99]],
|
|
271
|
+
["result", 114, 92],
|
|
272
|
+
["variant", [["ipv4", 95], ["ipv6", 97]]],
|
|
273
|
+
["list", 116],
|
|
274
|
+
["variant", [["access-denied", -1], ["invalid-argument", -1], ["name-unresolvable", -1], ["temporary-resolver-failure", -1], ["permanent-resolver-failure", -1], ["other", 12]]],
|
|
275
|
+
["result", 117, 118]
|
|
276
|
+
];
|
|
277
|
+
var RESOURCES = [
|
|
278
|
+
"wasi:filesystem/types@0.3.0#descriptor",
|
|
279
|
+
"wasi:cli/terminal-input@0.3.0#terminal-input",
|
|
280
|
+
"wasi:cli/terminal-output@0.3.0#terminal-output",
|
|
281
|
+
"wasi:http/types@0.3.0#fields",
|
|
282
|
+
"wasi:http/types@0.3.0#request-options",
|
|
283
|
+
"wasi:http/types@0.3.0#request",
|
|
284
|
+
"wasi:http/types@0.3.0#response",
|
|
285
|
+
"wasi:sockets/types@0.3.0#tcp-socket",
|
|
286
|
+
"wasi:sockets/types@0.3.0#udp-socket"
|
|
287
|
+
];
|
|
288
|
+
var METHODS = [
|
|
289
|
+
{ interface: "wasi:clocks/monotonic-clock@0.3.0", name: "now", asynchronous: false, params: [], result: 0 },
|
|
290
|
+
{ interface: "wasi:clocks/monotonic-clock@0.3.0", name: "getResolution", asynchronous: false, params: [], result: 0 },
|
|
291
|
+
{ interface: "wasi:clocks/monotonic-clock@0.3.0", name: "waitUntil", asynchronous: true, params: [0] },
|
|
292
|
+
{ interface: "wasi:clocks/monotonic-clock@0.3.0", name: "waitFor", asynchronous: true, params: [0] },
|
|
293
|
+
{ interface: "wasi:clocks/system-clock@0.3.0", name: "now", asynchronous: false, params: [], result: 3 },
|
|
294
|
+
{ interface: "wasi:clocks/system-clock@0.3.0", name: "getResolution", asynchronous: false, params: [], result: 0 },
|
|
295
|
+
{ interface: "wasi:random/random@0.3.0", name: "getRandomBytes", asynchronous: false, params: [0], result: 4 },
|
|
296
|
+
{ interface: "wasi:random/random@0.3.0", name: "getRandomU64", asynchronous: false, params: [], result: 0 },
|
|
297
|
+
{ interface: "wasi:random/insecure@0.3.0", name: "getInsecureRandomBytes", asynchronous: false, params: [0], result: 4 },
|
|
298
|
+
{ interface: "wasi:random/insecure@0.3.0", name: "getInsecureRandomU64", asynchronous: false, params: [], result: 0 },
|
|
299
|
+
{ interface: "wasi:random/insecure-seed@0.3.0", name: "getInsecureSeed", asynchronous: false, params: [], result: 5 },
|
|
300
|
+
{ interface: "wasi:filesystem/preopens@0.3.0", name: "getDirectories", asynchronous: false, params: [], result: 9 },
|
|
301
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "readViaStream", resource: 0, asynchronous: false, params: [10, 0], result: 16 },
|
|
302
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "writeViaStream", resource: 0, asynchronous: false, params: [10, 11, 0], result: 15 },
|
|
303
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "appendViaStream", resource: 0, asynchronous: false, params: [10, 11], result: 15 },
|
|
304
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "advise", resource: 0, asynchronous: true, params: [10, 0, 0, 17], result: 14 },
|
|
305
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "syncData", resource: 0, asynchronous: true, params: [10], result: 14 },
|
|
306
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "getFlags", resource: 0, asynchronous: true, params: [10], result: 19 },
|
|
307
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "getType", resource: 0, asynchronous: true, params: [10], result: 21 },
|
|
308
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "setSize", resource: 0, asynchronous: true, params: [10, 0], result: 14 },
|
|
309
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "setTimes", resource: 0, asynchronous: true, params: [10, 22, 22], result: 14 },
|
|
310
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "readDirectory", resource: 0, asynchronous: false, params: [10], result: 25 },
|
|
311
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "sync", resource: 0, asynchronous: true, params: [10], result: 14 },
|
|
312
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "createDirectoryAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
|
|
313
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "stat", resource: 0, asynchronous: true, params: [10], result: 28 },
|
|
314
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "statAt", resource: 0, asynchronous: true, params: [10, 29, 7], result: 28 },
|
|
315
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "setTimesAt", resource: 0, asynchronous: true, params: [10, 29, 7, 22, 22], result: 14 },
|
|
316
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "linkAt", resource: 0, asynchronous: true, params: [10, 29, 7, 10, 7], result: 14 },
|
|
317
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "openAt", resource: 0, asynchronous: true, params: [10, 29, 7, 30, 18], result: 31 },
|
|
318
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "readlinkAt", resource: 0, asynchronous: true, params: [10, 7], result: 32 },
|
|
319
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "removeDirectoryAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
|
|
320
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "renameAt", resource: 0, asynchronous: true, params: [10, 7, 10, 7], result: 14 },
|
|
321
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "symlinkAt", resource: 0, asynchronous: true, params: [10, 7, 7], result: 14 },
|
|
322
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "unlinkFileAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
|
|
323
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "isSameObject", resource: 0, asynchronous: true, params: [10, 10], result: 33 },
|
|
324
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "metadataHash", resource: 0, asynchronous: true, params: [10], result: 35 },
|
|
325
|
+
{ interface: "wasi:filesystem/types@0.3.0", name: "metadataHashAt", resource: 0, asynchronous: true, params: [10, 29, 7], result: 35 },
|
|
326
|
+
{ interface: "wasi:cli/environment@0.3.0", name: "getEnvironment", asynchronous: false, params: [], result: 37 },
|
|
327
|
+
{ interface: "wasi:cli/environment@0.3.0", name: "getArguments", asynchronous: false, params: [], result: 38 },
|
|
328
|
+
{ interface: "wasi:cli/environment@0.3.0", name: "getInitialCwd", asynchronous: false, params: [], result: 12 },
|
|
329
|
+
{ interface: "wasi:cli/exit@0.3.0", name: "exit", asynchronous: false, params: [39] },
|
|
330
|
+
{ interface: "wasi:cli/exit@0.3.0", name: "exitWithCode", asynchronous: false, params: [40] },
|
|
331
|
+
{ interface: "wasi:cli/stdin@0.3.0", name: "readViaStream", asynchronous: false, params: [], result: 44 },
|
|
332
|
+
{ interface: "wasi:cli/stdout@0.3.0", name: "writeViaStream", asynchronous: false, params: [11], result: 43 },
|
|
333
|
+
{ interface: "wasi:cli/stderr@0.3.0", name: "writeViaStream", asynchronous: false, params: [11], result: 43 },
|
|
334
|
+
{ interface: "wasi:cli/terminal-stdin@0.3.0", name: "getTerminalStdin", asynchronous: false, params: [], result: 46 },
|
|
335
|
+
{ interface: "wasi:cli/terminal-stdout@0.3.0", name: "getTerminalStdout", asynchronous: false, params: [], result: 48 },
|
|
336
|
+
{ interface: "wasi:cli/terminal-stderr@0.3.0", name: "getTerminalStderr", asynchronous: false, params: [], result: 48 },
|
|
337
|
+
{ interface: "wasi:http/types@0.3.0", name: "constructor", resource: 3, kind: "constructor", asynchronous: false, params: [], result: 49 },
|
|
338
|
+
{ interface: "wasi:http/types@0.3.0", name: "fromList", resource: 3, kind: "static", asynchronous: false, params: [51], result: 53 },
|
|
339
|
+
{ interface: "wasi:http/types@0.3.0", name: "get", resource: 3, asynchronous: false, params: [54, 7], result: 55 },
|
|
340
|
+
{ interface: "wasi:http/types@0.3.0", name: "has", resource: 3, asynchronous: false, params: [54, 7], result: 33 },
|
|
341
|
+
{ interface: "wasi:http/types@0.3.0", name: "set", resource: 3, asynchronous: false, params: [54, 7, 55], result: 56 },
|
|
342
|
+
{ interface: "wasi:http/types@0.3.0", name: "delete", resource: 3, asynchronous: false, params: [54, 7], result: 56 },
|
|
343
|
+
{ interface: "wasi:http/types@0.3.0", name: "getAndDelete", resource: 3, asynchronous: false, params: [54, 7], result: 57 },
|
|
344
|
+
{ interface: "wasi:http/types@0.3.0", name: "append", resource: 3, asynchronous: false, params: [54, 7, 4], result: 56 },
|
|
345
|
+
{ interface: "wasi:http/types@0.3.0", name: "copyAll", resource: 3, asynchronous: false, params: [54], result: 51 },
|
|
346
|
+
{ interface: "wasi:http/types@0.3.0", name: "clone", resource: 3, asynchronous: false, params: [54], result: 49 },
|
|
347
|
+
{ interface: "wasi:http/types@0.3.0", name: "new", resource: 5, kind: "static", asynchronous: false, params: [49, 71, 70, 73], result: 77 },
|
|
348
|
+
{ interface: "wasi:http/types@0.3.0", name: "getMethod", resource: 5, asynchronous: false, params: [78], result: 79 },
|
|
349
|
+
{ interface: "wasi:http/types@0.3.0", name: "setMethod", resource: 5, asynchronous: false, params: [78, 79], result: 39 },
|
|
350
|
+
{ interface: "wasi:http/types@0.3.0", name: "getPathWithQuery", resource: 5, asynchronous: false, params: [78], result: 12 },
|
|
351
|
+
{ interface: "wasi:http/types@0.3.0", name: "setPathWithQuery", resource: 5, asynchronous: false, params: [78, 12], result: 39 },
|
|
352
|
+
{ interface: "wasi:http/types@0.3.0", name: "getScheme", resource: 5, asynchronous: false, params: [78], result: 81 },
|
|
353
|
+
{ interface: "wasi:http/types@0.3.0", name: "setScheme", resource: 5, asynchronous: false, params: [78, 81], result: 39 },
|
|
354
|
+
{ interface: "wasi:http/types@0.3.0", name: "getAuthority", resource: 5, asynchronous: false, params: [78], result: 12 },
|
|
355
|
+
{ interface: "wasi:http/types@0.3.0", name: "setAuthority", resource: 5, asynchronous: false, params: [78, 12], result: 39 },
|
|
356
|
+
{ interface: "wasi:http/types@0.3.0", name: "getOptions", resource: 5, asynchronous: false, params: [78], result: 73 },
|
|
357
|
+
{ interface: "wasi:http/types@0.3.0", name: "getHeaders", resource: 5, asynchronous: false, params: [78], result: 49 },
|
|
358
|
+
{ interface: "wasi:http/types@0.3.0", name: "consumeBody", resource: 5, kind: "static", asynchronous: false, params: [74, 76], result: 82 },
|
|
359
|
+
{ interface: "wasi:http/types@0.3.0", name: "constructor", resource: 4, kind: "constructor", asynchronous: false, params: [], result: 72 },
|
|
360
|
+
{ interface: "wasi:http/types@0.3.0", name: "getConnectTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
|
|
361
|
+
{ interface: "wasi:http/types@0.3.0", name: "setConnectTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
|
|
362
|
+
{ interface: "wasi:http/types@0.3.0", name: "getFirstByteTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
|
|
363
|
+
{ interface: "wasi:http/types@0.3.0", name: "setFirstByteTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
|
|
364
|
+
{ interface: "wasi:http/types@0.3.0", name: "getBetweenBytesTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
|
|
365
|
+
{ interface: "wasi:http/types@0.3.0", name: "setBetweenBytesTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
|
|
366
|
+
{ interface: "wasi:http/types@0.3.0", name: "clone", resource: 4, asynchronous: false, params: [83], result: 72 },
|
|
367
|
+
{ interface: "wasi:http/types@0.3.0", name: "new", resource: 6, kind: "static", asynchronous: false, params: [49, 71, 70], result: 87 },
|
|
368
|
+
{ interface: "wasi:http/types@0.3.0", name: "getStatusCode", resource: 6, asynchronous: false, params: [88], result: 59 },
|
|
369
|
+
{ interface: "wasi:http/types@0.3.0", name: "setStatusCode", resource: 6, asynchronous: false, params: [88, 59], result: 39 },
|
|
370
|
+
{ interface: "wasi:http/types@0.3.0", name: "getHeaders", resource: 6, asynchronous: false, params: [88], result: 49 },
|
|
371
|
+
{ interface: "wasi:http/types@0.3.0", name: "consumeBody", resource: 6, kind: "static", asynchronous: false, params: [86, 76], result: 82 },
|
|
372
|
+
{ interface: "wasi:http/client@0.3.0", name: "send", asynchronous: true, params: [74], result: 89 },
|
|
373
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "create", resource: 7, kind: "static", asynchronous: false, params: [90], result: 93 },
|
|
374
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "bind", resource: 7, asynchronous: false, params: [94, 99], result: 100 },
|
|
375
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "connect", resource: 7, asynchronous: true, params: [94, 99], result: 100 },
|
|
376
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "listen", resource: 7, asynchronous: false, params: [94], result: 102 },
|
|
377
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "send", resource: 7, asynchronous: false, params: [94, 11], result: 103 },
|
|
378
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "receive", resource: 7, asynchronous: false, params: [94], result: 104 },
|
|
379
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getLocalAddress", resource: 7, asynchronous: false, params: [94], result: 105 },
|
|
380
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getRemoteAddress", resource: 7, asynchronous: false, params: [94], result: 105 },
|
|
381
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getIsListening", resource: 7, asynchronous: false, params: [94], result: 33 },
|
|
382
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getAddressFamily", resource: 7, asynchronous: false, params: [94], result: 90 },
|
|
383
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setListenBacklogSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
|
|
384
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveEnabled", resource: 7, asynchronous: false, params: [94], result: 106 },
|
|
385
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveEnabled", resource: 7, asynchronous: false, params: [94, 33], result: 100 },
|
|
386
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveIdleTime", resource: 7, asynchronous: false, params: [94], result: 107 },
|
|
387
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveIdleTime", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
|
|
388
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveInterval", resource: 7, asynchronous: false, params: [94], result: 107 },
|
|
389
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveInterval", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
|
|
390
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveCount", resource: 7, asynchronous: false, params: [94], result: 108 },
|
|
391
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveCount", resource: 7, asynchronous: false, params: [94, 2], result: 100 },
|
|
392
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getHopLimit", resource: 7, asynchronous: false, params: [94], result: 109 },
|
|
393
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setHopLimit", resource: 7, asynchronous: false, params: [94, 40], result: 100 },
|
|
394
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getReceiveBufferSize", resource: 7, asynchronous: false, params: [94], result: 107 },
|
|
395
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setReceiveBufferSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
|
|
396
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getSendBufferSize", resource: 7, asynchronous: false, params: [94], result: 107 },
|
|
397
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setSendBufferSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
|
|
398
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "create", resource: 8, kind: "static", asynchronous: false, params: [90], result: 111 },
|
|
399
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "bind", resource: 8, asynchronous: false, params: [112, 99], result: 100 },
|
|
400
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "connect", resource: 8, asynchronous: false, params: [112, 99], result: 100 },
|
|
401
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "disconnect", resource: 8, asynchronous: false, params: [112], result: 100 },
|
|
402
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "send", resource: 8, asynchronous: true, params: [112, 4, 113], result: 100 },
|
|
403
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "receive", resource: 8, asynchronous: true, params: [112], result: 115 },
|
|
404
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getLocalAddress", resource: 8, asynchronous: false, params: [112], result: 105 },
|
|
405
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getRemoteAddress", resource: 8, asynchronous: false, params: [112], result: 105 },
|
|
406
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getAddressFamily", resource: 8, asynchronous: false, params: [112], result: 90 },
|
|
407
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getUnicastHopLimit", resource: 8, asynchronous: false, params: [112], result: 109 },
|
|
408
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setUnicastHopLimit", resource: 8, asynchronous: false, params: [112, 40], result: 100 },
|
|
409
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getReceiveBufferSize", resource: 8, asynchronous: false, params: [112], result: 107 },
|
|
410
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setReceiveBufferSize", resource: 8, asynchronous: false, params: [112, 0], result: 100 },
|
|
411
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "getSendBufferSize", resource: 8, asynchronous: false, params: [112], result: 107 },
|
|
412
|
+
{ interface: "wasi:sockets/types@0.3.0", name: "setSendBufferSize", resource: 8, asynchronous: false, params: [112, 0], result: 100 },
|
|
413
|
+
{ interface: "wasi:sockets/ip-name-lookup@0.3.0", name: "resolveAddresses", asynchronous: true, params: [7], result: 119 }
|
|
414
|
+
];
|
|
415
|
+
var WRITABLE_FUTURES = [70, 76];
|
|
416
|
+
|
|
417
|
+
// src/interpreter/standard-codec.ts
|
|
418
|
+
var STANDARD_PACKET = 0;
|
|
419
|
+
var CALL = 0;
|
|
420
|
+
var STREAM_READ = 1;
|
|
421
|
+
var FUTURE_READ = 2;
|
|
422
|
+
var DROP = 3;
|
|
423
|
+
var STREAM_NEW = 4;
|
|
424
|
+
var STREAM_WRITE = 5;
|
|
425
|
+
var WRITE_ACCEPTED = 0;
|
|
426
|
+
var WRITE_CLOSED = 1;
|
|
427
|
+
var FUTURE_NEW = 6;
|
|
428
|
+
var FUTURE_WRITE = 7;
|
|
429
|
+
var INGRESS_HEAD = 8;
|
|
430
|
+
var STREAM_IMPORT = 10;
|
|
431
|
+
var STREAM_CHUNK = 64 << 10;
|
|
432
|
+
function resourceClassName(name) {
|
|
433
|
+
return name.split("#")[1].replace(/(^|-)(\w)/g, (_match, _separator, letter) => letter.toUpperCase());
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
class Writer {
|
|
437
|
+
#bytes = new Uint8Array(64);
|
|
438
|
+
#view = new DataView(this.#bytes.buffer);
|
|
439
|
+
#length = 0;
|
|
440
|
+
#reserve(count) {
|
|
441
|
+
const start = this.#length;
|
|
442
|
+
if (start + count > this.#bytes.length) {
|
|
443
|
+
const grown = new Uint8Array(Math.max(this.#bytes.length * 2, start + count));
|
|
444
|
+
grown.set(this.#bytes.subarray(0, start));
|
|
445
|
+
this.#bytes = grown;
|
|
446
|
+
this.#view = new DataView(grown.buffer);
|
|
447
|
+
}
|
|
448
|
+
this.#length += count;
|
|
449
|
+
return start;
|
|
450
|
+
}
|
|
451
|
+
u8(value) {
|
|
452
|
+
const offset = this.#reserve(1);
|
|
453
|
+
this.#view.setUint8(offset, value);
|
|
454
|
+
}
|
|
455
|
+
u16(value) {
|
|
456
|
+
const offset = this.#reserve(2);
|
|
457
|
+
this.#view.setUint16(offset, value, true);
|
|
458
|
+
}
|
|
459
|
+
u32(value) {
|
|
460
|
+
const offset = this.#reserve(4);
|
|
461
|
+
this.#view.setUint32(offset, value, true);
|
|
462
|
+
}
|
|
463
|
+
u64(value) {
|
|
464
|
+
const offset = this.#reserve(8);
|
|
465
|
+
this.#view.setBigUint64(offset, value, true);
|
|
466
|
+
}
|
|
467
|
+
handle(value) {
|
|
468
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
469
|
+
throw new RangeError("invalid handle identity");
|
|
470
|
+
this.u64(BigInt(value));
|
|
471
|
+
}
|
|
472
|
+
s64(value) {
|
|
473
|
+
const offset = this.#reserve(8);
|
|
474
|
+
this.#view.setBigInt64(offset, value, true);
|
|
475
|
+
}
|
|
476
|
+
raw(bytes) {
|
|
477
|
+
const offset = this.#reserve(bytes.length);
|
|
478
|
+
this.#bytes.set(bytes, offset);
|
|
479
|
+
}
|
|
480
|
+
bytes(bytes) {
|
|
481
|
+
this.u32(bytes.length);
|
|
482
|
+
this.raw(bytes);
|
|
483
|
+
}
|
|
484
|
+
finish() {
|
|
485
|
+
return this.#bytes.slice(0, this.#length);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
class Reader {
|
|
490
|
+
source;
|
|
491
|
+
#view;
|
|
492
|
+
#offset = 0;
|
|
493
|
+
constructor(source) {
|
|
494
|
+
this.source = source;
|
|
495
|
+
this.#view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
496
|
+
}
|
|
497
|
+
#take(count) {
|
|
498
|
+
const start = this.#offset;
|
|
499
|
+
if (start + count > this.source.length)
|
|
500
|
+
throw new RangeError("standard packet is truncated");
|
|
501
|
+
this.#offset += count;
|
|
502
|
+
return start;
|
|
503
|
+
}
|
|
504
|
+
u8() {
|
|
505
|
+
return this.#view.getUint8(this.#take(1));
|
|
506
|
+
}
|
|
507
|
+
u16() {
|
|
508
|
+
return this.#view.getUint16(this.#take(2), true);
|
|
509
|
+
}
|
|
510
|
+
u32() {
|
|
511
|
+
return this.#view.getUint32(this.#take(4), true);
|
|
512
|
+
}
|
|
513
|
+
u64() {
|
|
514
|
+
return this.#view.getBigUint64(this.#take(8), true);
|
|
515
|
+
}
|
|
516
|
+
handle() {
|
|
517
|
+
const value = this.u64();
|
|
518
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
|
519
|
+
throw new RangeError("invalid handle identity");
|
|
520
|
+
return Number(value);
|
|
521
|
+
}
|
|
522
|
+
s64() {
|
|
523
|
+
return this.#view.getBigInt64(this.#take(8), true);
|
|
524
|
+
}
|
|
525
|
+
bytes() {
|
|
526
|
+
return this.raw(this.u32());
|
|
527
|
+
}
|
|
528
|
+
raw(length) {
|
|
529
|
+
const start = this.#take(length);
|
|
530
|
+
return this.source.slice(start, start + length);
|
|
531
|
+
}
|
|
532
|
+
string() {
|
|
533
|
+
return utf8Decode(this.bytes());
|
|
534
|
+
}
|
|
535
|
+
get remaining() {
|
|
536
|
+
return this.source.length - this.#offset;
|
|
537
|
+
}
|
|
538
|
+
end() {
|
|
539
|
+
if (this.#offset !== this.source.length)
|
|
540
|
+
throw new RangeError("standard packet has trailing bytes");
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
var NONE = -1;
|
|
544
|
+
var U64_MAX = (1n << 64n) - 1n;
|
|
545
|
+
var S64_LIMIT = 1n << 63n;
|
|
546
|
+
var isSurrogate = (code) => code >= 55296 && code <= 57343;
|
|
547
|
+
function integer(value, minimum, maximum) {
|
|
548
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > maximum)
|
|
549
|
+
throw new RangeError(`integer ${String(value)} is outside ${minimum}..=${maximum}`);
|
|
550
|
+
return value;
|
|
551
|
+
}
|
|
552
|
+
function big(value, minimum, maximum) {
|
|
553
|
+
const exact = typeof value === "bigint" ? value : typeof value === "number" && Number.isSafeInteger(value) ? BigInt(value) : undefined;
|
|
554
|
+
if (exact === undefined || exact < minimum || exact > maximum)
|
|
555
|
+
throw new RangeError(`64-bit integer ${String(value)} is outside ${minimum}..=${maximum}`);
|
|
556
|
+
return exact;
|
|
557
|
+
}
|
|
558
|
+
function encode2(w, index, value, handles) {
|
|
559
|
+
const [kind, a, b] = TYPES[index];
|
|
560
|
+
switch (kind) {
|
|
561
|
+
case "bool":
|
|
562
|
+
return w.u8(value ? 1 : 0);
|
|
563
|
+
case "u8":
|
|
564
|
+
return w.u8(integer(value, 0, 255));
|
|
565
|
+
case "s8":
|
|
566
|
+
return w.u8(integer(value, -128, 127) & 255);
|
|
567
|
+
case "u16":
|
|
568
|
+
return w.u16(integer(value, 0, 65535));
|
|
569
|
+
case "s16":
|
|
570
|
+
return w.u16(integer(value, -32768, 32767) & 65535);
|
|
571
|
+
case "u32":
|
|
572
|
+
return w.u32(integer(value, 0, 4294967295));
|
|
573
|
+
case "s32":
|
|
574
|
+
return w.u32(integer(value, -2147483648, 2147483647) >>> 0);
|
|
575
|
+
case "u64":
|
|
576
|
+
return w.u64(big(value, 0n, U64_MAX));
|
|
577
|
+
case "s64":
|
|
578
|
+
return w.s64(big(value, -S64_LIMIT, S64_LIMIT - 1n));
|
|
579
|
+
case "char": {
|
|
580
|
+
const text = String(value);
|
|
581
|
+
const code = text.codePointAt(0);
|
|
582
|
+
if (code === undefined || text.length !== (code > 65535 ? 2 : 1) || isSurrogate(code))
|
|
583
|
+
throw new TypeError("char requires one Unicode scalar value");
|
|
584
|
+
return w.u32(code);
|
|
585
|
+
}
|
|
586
|
+
case "string":
|
|
587
|
+
return w.bytes(utf8Encode(String(value)));
|
|
588
|
+
case "bytes":
|
|
589
|
+
if (!(value instanceof Uint8Array))
|
|
590
|
+
throw new TypeError("list<u8> requires a Uint8Array");
|
|
591
|
+
return w.bytes(value);
|
|
592
|
+
case "list":
|
|
593
|
+
w.u32(value.length);
|
|
594
|
+
for (const item of value)
|
|
595
|
+
encode2(w, a, item, handles);
|
|
596
|
+
return;
|
|
597
|
+
case "tuple":
|
|
598
|
+
a.forEach((type, position) => encode2(w, type, value[position], handles));
|
|
599
|
+
return;
|
|
600
|
+
case "record":
|
|
601
|
+
for (const [name, type] of a)
|
|
602
|
+
encode2(w, type, value[name], handles);
|
|
603
|
+
return;
|
|
604
|
+
case "flags": {
|
|
605
|
+
let bits = 0;
|
|
606
|
+
a.forEach((name, bit) => {
|
|
607
|
+
if (value?.[name])
|
|
608
|
+
bits |= 1 << bit;
|
|
609
|
+
});
|
|
610
|
+
return w.u32(bits >>> 0);
|
|
611
|
+
}
|
|
612
|
+
case "enum": {
|
|
613
|
+
const position = a.indexOf(value);
|
|
614
|
+
if (position < 0)
|
|
615
|
+
throw new TypeError(`unknown enum case ${value}`);
|
|
616
|
+
return w.u32(position);
|
|
617
|
+
}
|
|
618
|
+
case "variant": {
|
|
619
|
+
const cases = a;
|
|
620
|
+
const position = cases.findIndex(([tag]) => tag === value?.tag);
|
|
621
|
+
if (position < 0)
|
|
622
|
+
throw new TypeError(`unknown variant case ${value?.tag}`);
|
|
623
|
+
w.u32(position);
|
|
624
|
+
if (cases[position][1] !== NONE)
|
|
625
|
+
encode2(w, cases[position][1], value.val, handles);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
case "option":
|
|
629
|
+
if (value === undefined || value === null)
|
|
630
|
+
return w.u8(0);
|
|
631
|
+
w.u8(1);
|
|
632
|
+
return encode2(w, a, value, handles);
|
|
633
|
+
case "result": {
|
|
634
|
+
const ok = value?.tag === "ok";
|
|
635
|
+
if (!ok && value?.tag !== "err")
|
|
636
|
+
throw new TypeError("result requires { tag, val }");
|
|
637
|
+
w.u8(ok ? 0 : 1);
|
|
638
|
+
const type = ok ? a : b;
|
|
639
|
+
if (type !== NONE)
|
|
640
|
+
encode2(w, type, value.val, handles);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
default:
|
|
644
|
+
return w.handle(handles.handle(kind, a, value));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function decode(r, index, handles) {
|
|
648
|
+
const [kind, a, b] = TYPES[index];
|
|
649
|
+
switch (kind) {
|
|
650
|
+
case "bool": {
|
|
651
|
+
const tag = r.u8();
|
|
652
|
+
if (tag > 1)
|
|
653
|
+
throw new RangeError("invalid bool");
|
|
654
|
+
return tag === 1;
|
|
655
|
+
}
|
|
656
|
+
case "u8":
|
|
657
|
+
return r.u8();
|
|
658
|
+
case "s8":
|
|
659
|
+
return r.u8() << 24 >> 24;
|
|
660
|
+
case "u16":
|
|
661
|
+
return r.u16();
|
|
662
|
+
case "s16":
|
|
663
|
+
return r.u16() << 16 >> 16;
|
|
664
|
+
case "u32":
|
|
665
|
+
return r.u32();
|
|
666
|
+
case "s32":
|
|
667
|
+
return r.u32() | 0;
|
|
668
|
+
case "u64":
|
|
669
|
+
return r.u64();
|
|
670
|
+
case "s64":
|
|
671
|
+
return r.s64();
|
|
672
|
+
case "char": {
|
|
673
|
+
const code = r.u32();
|
|
674
|
+
if (code > 1114111 || isSurrogate(code))
|
|
675
|
+
throw new RangeError("invalid char");
|
|
676
|
+
return String.fromCodePoint(code);
|
|
677
|
+
}
|
|
678
|
+
case "string":
|
|
679
|
+
return r.string();
|
|
680
|
+
case "bytes":
|
|
681
|
+
return r.bytes();
|
|
682
|
+
case "list": {
|
|
683
|
+
const items = [];
|
|
684
|
+
for (let count = r.u32();count > 0; count--)
|
|
685
|
+
items.push(decode(r, a, handles));
|
|
686
|
+
return items;
|
|
687
|
+
}
|
|
688
|
+
case "tuple":
|
|
689
|
+
return a.map((type) => decode(r, type, handles));
|
|
690
|
+
case "record": {
|
|
691
|
+
const record = {};
|
|
692
|
+
for (const [name, type] of a) {
|
|
693
|
+
const field = decode(r, type, handles);
|
|
694
|
+
if (field !== undefined)
|
|
695
|
+
record[name] = field;
|
|
696
|
+
}
|
|
697
|
+
return record;
|
|
698
|
+
}
|
|
699
|
+
case "flags": {
|
|
700
|
+
const bits = r.u32();
|
|
701
|
+
const names = a;
|
|
702
|
+
if (names.length < 32 && bits >>> names.length !== 0)
|
|
703
|
+
throw new RangeError("unknown flag bits");
|
|
704
|
+
return Object.fromEntries(a.map((name, bit) => [name, (bits & 1 << bit) !== 0]));
|
|
705
|
+
}
|
|
706
|
+
case "enum": {
|
|
707
|
+
const name = a[r.u32()];
|
|
708
|
+
if (name === undefined)
|
|
709
|
+
throw new RangeError("unknown enum case");
|
|
710
|
+
return name;
|
|
711
|
+
}
|
|
712
|
+
case "variant": {
|
|
713
|
+
const entry = a[r.u32()];
|
|
714
|
+
if (!entry)
|
|
715
|
+
throw new RangeError("unknown variant case");
|
|
716
|
+
const [tag, type] = entry;
|
|
717
|
+
return type === NONE ? { tag } : { tag, val: decode(r, type, handles) };
|
|
718
|
+
}
|
|
719
|
+
case "option": {
|
|
720
|
+
const tag = r.u8();
|
|
721
|
+
if (tag > 1)
|
|
722
|
+
throw new RangeError("invalid option tag");
|
|
723
|
+
return tag === 0 ? undefined : decode(r, a, handles);
|
|
724
|
+
}
|
|
725
|
+
case "result": {
|
|
726
|
+
const tag = r.u8();
|
|
727
|
+
if (tag > 1)
|
|
728
|
+
throw new RangeError("invalid result tag");
|
|
729
|
+
const ok = tag === 0;
|
|
730
|
+
const type = ok ? a : b;
|
|
731
|
+
return { tag: ok ? "ok" : "err", val: type === NONE ? undefined : decode(r, type, handles) };
|
|
732
|
+
}
|
|
733
|
+
default:
|
|
734
|
+
return handles.value(kind, a, r.handle());
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export { HTTP_HANDLER, HttpHandlerError2, CONNECTION_TERMINATED, IngressExchange, checkedRequest, HttpProviderError2, byteString, bytesOf, answer, query, TYPES, RESOURCES, METHODS, WRITABLE_FUTURES, STANDARD_PACKET, CALL, STREAM_READ, FUTURE_READ, DROP, STREAM_NEW, STREAM_WRITE, WRITE_ACCEPTED, WRITE_CLOSED, FUTURE_NEW, FUTURE_WRITE, INGRESS_HEAD, STREAM_IMPORT, STREAM_CHUNK, resourceClassName, Writer, Reader, encode2, decode };
|