@northtalk/ts 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/base64-CDO-a06R.js +29 -0
- package/{binary-value-Bb6HPDtM.d.ts → binary-value-xvJoGg0C.d.ts} +1 -1
- package/{checker-DMI4LiRm.js → checker-CUhn2XaM.js} +4 -4
- package/{core-BzGUgjL6.d.ts → core-BuTAYRm-.d.ts} +1 -1
- package/{debug-C72o2pZy.d.ts → debug-DRhMZAxw.d.ts} +28 -8
- package/debug.d.ts +1 -1
- package/debug.js +1 -1
- package/{driver-ClV_UDEK.d.ts → driver-CHDcuqUy.d.ts} +1 -1
- package/driver.d.ts +1 -1
- package/driver.js +1 -1
- package/{encoding-C3Q7pIC9.js → encoding-RUuES_e4.js} +2 -2
- package/{engine-BpdGfAND.js → engine-CXf5FCwi.js} +6 -6
- package/{engine-Dtby_FkE.d.ts → engine-Cc3yofGM.d.ts} +2 -2
- package/{errors-BKJES3Zu.js → errors-D11zizZg.js} +1580 -1481
- package/{group-vuUL2tq-.js → group-BflSou2n.js} +66 -44
- package/http-fetch-DFwVIOQg.js +517 -0
- package/http.d.ts +39 -2
- package/http.js +189 -6
- package/index.d.ts +13 -5
- package/index.js +36 -49
- package/{inline-grants-Cx0Z9XAt.js → inline-grants-XbX9HL_w.js} +72 -304
- package/lean-BebPaTMK.js +47 -0
- package/{index-ByF5j53i.d.ts → lean-CjWVuOrC.d.ts} +86 -124
- package/lean.d.ts +8 -0
- package/lean.js +15 -0
- package/{manifest-Dw-8Unmf.js → manifest-CCfpn0kC.js} +3 -4
- package/manifest-DVrx-pT2.d.ts +122 -0
- package/message-layer.d.ts +2 -2
- package/message-layer.js +2 -2
- package/notify.d.ts +1 -1
- package/notify.js +1 -1
- package/{objects-Dnqor7Gn.d.ts → objects-DC6HjzBY.d.ts} +1 -1
- package/{objects-BC4fS0vq.js → objects-DmUc0lha.js} +1 -1
- package/{base64-Dtqaz_0A.js → operations-DnCcztkZ.js} +1632 -32
- package/package.json +36 -2
- package/{readers-B5e5bBrY.js → readers-CsvlahLi.js} +2 -2
- package/{readers-DAFVvvq4.d.ts → readers-MmyZ_d0w.d.ts} +1 -1
- package/{request-pump-binary-BjnyqXV5.js → request-pump-binary-oqjWFqZA.js} +5 -4
- package/{router-BCHEfs4x.js → router-BZ-aYeXA.js} +4 -4
- package/{router-BspOCPA0.d.ts → router-D56rSkU8.d.ts} +2 -2
- package/session.d.ts +2 -2
- package/session.js +54 -15
- package/setup.d.ts +1 -1
- package/setup.js +4 -4
- package/sqlite.d.ts +2 -2
- package/sqlite.js +5 -5
- package/stdlib/bytes.d.ts +6 -0
- package/stdlib/bytes.js +11 -0
- package/stdlib/date.d.ts +6 -0
- package/stdlib/date.js +11 -0
- package/stdlib/json.d.ts +6 -0
- package/stdlib/json.js +11 -0
- package/stdlib/list.d.ts +6 -0
- package/stdlib/list.js +10 -0
- package/stdlib/map.d.ts +6 -0
- package/stdlib/map.js +10 -0
- package/stdlib/text.d.ts +6 -0
- package/stdlib/text.js +10 -0
- package/stdlib/units.d.ts +6 -0
- package/stdlib/units.js +10 -0
- package/stdlib-registry-BwitI3Ox.d.ts +18 -0
- package/{store-DTQa0lyE.js → store-DHlo6fP5.js} +2 -2
- package/{store-capability-BxXgiRM7.js → store-capability-BrUUAwVS.js} +3 -4
- package/store.d.ts +2 -2
- package/store.js +2 -2
- package/{user-capability-5-IvCeZI.js → user-capability-BcRQyyEw.js} +4 -5
- package/wasm.d.ts +5 -5
- package/wasm.js +13 -11
- package/capabilities-Bi5Qm6Fr.js +0 -1320
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import { A as listValues, D as isDecimal,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { r as
|
|
6
|
-
import { c as fixed, s as costOf } from "./store-capability-
|
|
2
|
+
import { A as listValues, D as isDecimal, G as record, L as nothing, N as map, Q as text, R as num, bt as integerOf, d as bytes, i as ScriptError, l as Value, o as invalidValue, q as requireValue, t as HostError, u as bool, v as dec, xt as isInteger, y as decimalParts } from "./errors-D11zizZg.js";
|
|
3
|
+
import { St as validComputedMessageName, _t as defineCapability, n as ScriptError$1, vt as defineValueCapability, wt as validStaticMessageName, xt as shape, yt as expectedOf } from "./operations-DnCcztkZ.js";
|
|
4
|
+
import { r as registerStandardChecks } from "./encoding-RUuES_e4.js";
|
|
5
|
+
import { n as duplicateHeaderNames, r as fetchAnswerOk, s as encodeJson, t as checkFetch } from "./http-fetch-DFwVIOQg.js";
|
|
6
|
+
import { c as fixed, s as costOf } from "./store-capability-BrUUAwVS.js";
|
|
7
7
|
import { asyncDispose, newDrivenGroup } from "./driver.js";
|
|
8
8
|
//#region src/talk.ts
|
|
9
9
|
const blank = /^[\t ]*$/;
|
|
@@ -119,287 +119,6 @@ const fromValue = (v, options = {}) => {
|
|
|
119
119
|
return convert(v);
|
|
120
120
|
};
|
|
121
121
|
//#endregion
|
|
122
|
-
//#region src/json.ts
|
|
123
|
-
var JsonReader = class {
|
|
124
|
-
source;
|
|
125
|
-
i = 0;
|
|
126
|
-
constructor(source) {
|
|
127
|
-
this.source = source;
|
|
128
|
-
}
|
|
129
|
-
fail(at = this.i) {
|
|
130
|
-
const scalar = Array.from(this.source, (c) => /^[\uD800-\uDFFF]$/.test(c) ? "�" : c).join("");
|
|
131
|
-
const offset = characterBoundaries(scalar).filter((i) => i <= at).length;
|
|
132
|
-
throw new ScriptError("can't decode", errorMessages["can't decode"].replace("{format}", text("json").toString()).replace("{offset}", String(offset)), map([["format", text("json")], ["offset", num(offset)]]));
|
|
133
|
-
}
|
|
134
|
-
space() {
|
|
135
|
-
while (/[\t\n\r ]/.test(this.source[this.i] ?? "") && this.i < this.source.length) this.i++;
|
|
136
|
-
}
|
|
137
|
-
eat(c) {
|
|
138
|
-
if (this.source[this.i] !== c) this.fail();
|
|
139
|
-
this.i++;
|
|
140
|
-
}
|
|
141
|
-
hex4() {
|
|
142
|
-
let n = 0;
|
|
143
|
-
for (let k = 0; k < 4; k++) {
|
|
144
|
-
const c = this.source[this.i];
|
|
145
|
-
if (c === void 0 || !/[\dA-Fa-f]/.test(c)) this.fail();
|
|
146
|
-
n = n * 16 + Number.parseInt(c, 16);
|
|
147
|
-
this.i++;
|
|
148
|
-
}
|
|
149
|
-
return n;
|
|
150
|
-
}
|
|
151
|
-
string() {
|
|
152
|
-
this.eat("\"");
|
|
153
|
-
const parts = [];
|
|
154
|
-
const escapes = {
|
|
155
|
-
"\"": "\"",
|
|
156
|
-
"\\": "\\",
|
|
157
|
-
"/": "/",
|
|
158
|
-
b: "\b",
|
|
159
|
-
f: "\f",
|
|
160
|
-
n: "\n",
|
|
161
|
-
r: "\r",
|
|
162
|
-
t: " "
|
|
163
|
-
};
|
|
164
|
-
while (this.i < this.source.length) {
|
|
165
|
-
const start = this.i;
|
|
166
|
-
const cp = this.source.codePointAt(this.i);
|
|
167
|
-
const c = String.fromCodePoint(cp);
|
|
168
|
-
if (c === "\"") {
|
|
169
|
-
this.i++;
|
|
170
|
-
return normalizeNFC(parts.join(""));
|
|
171
|
-
}
|
|
172
|
-
if (cp < 32 || cp >= 55296 && cp <= 57343) this.fail();
|
|
173
|
-
this.i += c.length;
|
|
174
|
-
if (c !== "\\") {
|
|
175
|
-
parts.push(c);
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (this.i === this.source.length) this.fail();
|
|
179
|
-
const escape = this.source[this.i++];
|
|
180
|
-
if (Object.hasOwn(escapes, escape)) {
|
|
181
|
-
parts.push(escapes[escape]);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (escape !== "u") this.fail(this.i - 1);
|
|
185
|
-
let u = this.hex4();
|
|
186
|
-
if (u >= 56320 && u <= 57343) this.fail(start);
|
|
187
|
-
if (u >= 55296 && u <= 56319) {
|
|
188
|
-
const lowStart = this.i;
|
|
189
|
-
if (this.source[this.i] !== "\\" || this.source[this.i + 1] !== "u") this.fail();
|
|
190
|
-
this.i += 2;
|
|
191
|
-
const low = this.hex4();
|
|
192
|
-
if (low < 56320 || low > 57343) this.fail(lowStart);
|
|
193
|
-
u = 65536 + (u - 55296) * 1024 + low - 56320;
|
|
194
|
-
}
|
|
195
|
-
parts.push(String.fromCodePoint(u));
|
|
196
|
-
}
|
|
197
|
-
return this.fail();
|
|
198
|
-
}
|
|
199
|
-
digits() {
|
|
200
|
-
const start = this.i;
|
|
201
|
-
while (this.i < this.source.length && /\d/.test(this.source[this.i])) this.i++;
|
|
202
|
-
return this.source.slice(start, this.i);
|
|
203
|
-
}
|
|
204
|
-
number() {
|
|
205
|
-
const start = this.i;
|
|
206
|
-
let sign = "";
|
|
207
|
-
if (this.source[this.i] === "-") {
|
|
208
|
-
sign = "-";
|
|
209
|
-
this.i++;
|
|
210
|
-
}
|
|
211
|
-
if (!/\d/.test(this.source[this.i] ?? "")) this.fail();
|
|
212
|
-
let whole;
|
|
213
|
-
if (this.source[this.i] === "0") {
|
|
214
|
-
whole = "0";
|
|
215
|
-
this.i++;
|
|
216
|
-
} else whole = this.digits();
|
|
217
|
-
let fraction = "";
|
|
218
|
-
if (this.source[this.i] === ".") {
|
|
219
|
-
this.i++;
|
|
220
|
-
fraction = this.digits();
|
|
221
|
-
if (!fraction) this.fail();
|
|
222
|
-
}
|
|
223
|
-
let exponent = "", negativeExponent = false;
|
|
224
|
-
if (/[Ee]/.test(this.source[this.i] ?? "")) {
|
|
225
|
-
this.i++;
|
|
226
|
-
if (/[+-]/.test(this.source[this.i] ?? "")) negativeExponent = this.source[this.i++] === "-";
|
|
227
|
-
exponent = this.digits();
|
|
228
|
-
if (!exponent) this.fail();
|
|
229
|
-
}
|
|
230
|
-
const coefficient = whole + fraction;
|
|
231
|
-
const significant = coefficient.replace(/^0+/, "");
|
|
232
|
-
exponent = exponent.replace(/^0+/, "");
|
|
233
|
-
if (exponent.length > 9) {
|
|
234
|
-
if (!significant && !negativeExponent) return num(0);
|
|
235
|
-
this.fail(start);
|
|
236
|
-
}
|
|
237
|
-
const q = (negativeExponent ? -1 : 1) * Number(exponent) - fraction.length;
|
|
238
|
-
if (!significant && q >= 0) return num(0);
|
|
239
|
-
if (significant.length > 34) this.fail(start);
|
|
240
|
-
if (q >= 0) {
|
|
241
|
-
if (significant.length + q > 34) this.fail(start);
|
|
242
|
-
return dec(sign + significant + "0".repeat(q));
|
|
243
|
-
}
|
|
244
|
-
if (-q > 6176) this.fail(start);
|
|
245
|
-
const digits = coefficient.padStart(-q + 1, "0");
|
|
246
|
-
return dec(sign + digits.slice(0, q) + "." + digits.slice(q));
|
|
247
|
-
}
|
|
248
|
-
atom() {
|
|
249
|
-
const c = this.source[this.i];
|
|
250
|
-
if (c === "\"") return text(this.string());
|
|
251
|
-
if (c === "-" || /\d/.test(c ?? "")) return this.number();
|
|
252
|
-
for (const [literal, value] of [
|
|
253
|
-
["true", bool(true)],
|
|
254
|
-
["false", bool(false)],
|
|
255
|
-
["null", nothing]
|
|
256
|
-
]) {
|
|
257
|
-
if (c !== literal[0]) continue;
|
|
258
|
-
for (const ch of literal) this.eat(ch);
|
|
259
|
-
return value;
|
|
260
|
-
}
|
|
261
|
-
return this.fail();
|
|
262
|
-
}
|
|
263
|
-
read() {
|
|
264
|
-
const frames = [];
|
|
265
|
-
let value;
|
|
266
|
-
const key = (frame) => {
|
|
267
|
-
this.space();
|
|
268
|
-
const start = this.i;
|
|
269
|
-
frame.key = this.string();
|
|
270
|
-
if (frame.keys.has(frame.key)) this.fail(start);
|
|
271
|
-
frame.keys.add(frame.key);
|
|
272
|
-
this.space();
|
|
273
|
-
this.eat(":");
|
|
274
|
-
};
|
|
275
|
-
for (;;) {
|
|
276
|
-
if (!value) {
|
|
277
|
-
this.space();
|
|
278
|
-
const c = this.source[this.i];
|
|
279
|
-
if (c === "[" || c === "{") {
|
|
280
|
-
this.i++;
|
|
281
|
-
this.space();
|
|
282
|
-
const frame = c === "[" ? {
|
|
283
|
-
kind: "list",
|
|
284
|
-
values: []
|
|
285
|
-
} : {
|
|
286
|
-
kind: "map",
|
|
287
|
-
pairs: [],
|
|
288
|
-
keys: /* @__PURE__ */ new Set(),
|
|
289
|
-
key: ""
|
|
290
|
-
};
|
|
291
|
-
if (this.source[this.i] === (c === "[" ? "]" : "}")) {
|
|
292
|
-
this.i++;
|
|
293
|
-
value = c === "[" ? listValues([]) : map([]);
|
|
294
|
-
} else {
|
|
295
|
-
if (frame.kind === "map") key(frame);
|
|
296
|
-
frames.push(frame);
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
} else value = this.atom();
|
|
300
|
-
}
|
|
301
|
-
const parent = frames.at(-1);
|
|
302
|
-
this.space();
|
|
303
|
-
if (!parent) {
|
|
304
|
-
if (this.i !== this.source.length) this.fail();
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
if (parent.kind === "list") parent.values.push(value);
|
|
308
|
-
else parent.pairs.push([parent.key, value]);
|
|
309
|
-
if (this.source[this.i] === ",") {
|
|
310
|
-
this.i++;
|
|
311
|
-
if (parent.kind === "map") key(parent);
|
|
312
|
-
value = void 0;
|
|
313
|
-
} else {
|
|
314
|
-
this.eat(parent.kind === "list" ? "]" : "}");
|
|
315
|
-
frames.pop();
|
|
316
|
-
value = parent.kind === "list" ? listValues(parent.values) : map(parent.pairs);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
/** Read exact decimal digits, NFC strings and insertion-ordered maps. */
|
|
322
|
-
const decodeJson = (source) => {
|
|
323
|
-
if (typeof source !== "string") invalidValue("JSON must be text");
|
|
324
|
-
return new JsonReader(source).read();
|
|
325
|
-
};
|
|
326
|
-
const quoteJson = (s) => {
|
|
327
|
-
const short = {
|
|
328
|
-
"\b": "b",
|
|
329
|
-
" ": "t",
|
|
330
|
-
"\n": "n",
|
|
331
|
-
"\f": "f",
|
|
332
|
-
"\r": "r"
|
|
333
|
-
};
|
|
334
|
-
return "\"" + s.replaceAll(/[\u0000-\u001f"\\]/g, (c) => c === "\"" || c === "\\" ? "\\" + c : Object.hasOwn(short, c) ? "\\" + short[c] : String.raw`\u00` + c.charCodeAt(0).toString(16).padStart(2, "0")) + "\"";
|
|
335
|
-
};
|
|
336
|
-
/** Compact JSON, with canonical numbers and chapter 7's string escapes. */
|
|
337
|
-
const encodeJson = (value) => {
|
|
338
|
-
requireValue(value);
|
|
339
|
-
const pending = [{
|
|
340
|
-
value,
|
|
341
|
-
path: void 0
|
|
342
|
-
}];
|
|
343
|
-
const output = [];
|
|
344
|
-
while (pending.length) {
|
|
345
|
-
const next = pending.pop();
|
|
346
|
-
if (typeof next === "string") {
|
|
347
|
-
output.push(next);
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
const { value: v, path } = next;
|
|
351
|
-
switch (v.kind) {
|
|
352
|
-
case "nothing":
|
|
353
|
-
output.push("null");
|
|
354
|
-
break;
|
|
355
|
-
case "boolean":
|
|
356
|
-
case "number":
|
|
357
|
-
output.push(v.toString());
|
|
358
|
-
break;
|
|
359
|
-
case "text":
|
|
360
|
-
output.push(quoteJson(v.asText()));
|
|
361
|
-
break;
|
|
362
|
-
case "list":
|
|
363
|
-
output.push("[");
|
|
364
|
-
pending.push("]");
|
|
365
|
-
for (let i = v.length; i >= 1; i--) {
|
|
366
|
-
if (i < v.length) pending.push(",");
|
|
367
|
-
pending.push({
|
|
368
|
-
value: v.index(i),
|
|
369
|
-
path: {
|
|
370
|
-
key: i,
|
|
371
|
-
parent: path
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
break;
|
|
376
|
-
case "map": {
|
|
377
|
-
output.push("{");
|
|
378
|
-
pending.push("}");
|
|
379
|
-
const entries = v.entries();
|
|
380
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
381
|
-
const [k, child] = entries[i];
|
|
382
|
-
if (i < entries.length - 1) pending.push(",");
|
|
383
|
-
pending.push({
|
|
384
|
-
value: child,
|
|
385
|
-
path: {
|
|
386
|
-
key: k,
|
|
387
|
-
parent: path
|
|
388
|
-
}
|
|
389
|
-
}, quoteJson(k) + ":");
|
|
390
|
-
}
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
default: {
|
|
394
|
-
const keys = [];
|
|
395
|
-
for (let p = path; p; p = p.parent) keys.push(typeof p.key === "string" ? text(p.key) : num(p.key));
|
|
396
|
-
throw new ScriptError("not encodable", errorMessages["not encodable"].replace("{kind}", text(v.kind).toString()), map([["kind", text(v.kind)], ["path", listValues(keys.reverse())]]));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return output.join("");
|
|
401
|
-
};
|
|
402
|
-
//#endregion
|
|
403
122
|
//#region src/sqlite-capability.ts
|
|
404
123
|
const isWhole = (n) => Number.isSafeInteger(n) && n >= 0;
|
|
405
124
|
const INT64_MIN = -(2n ** 63n);
|
|
@@ -623,6 +342,19 @@ const addressShape = shape.map({
|
|
|
623
342
|
host: shape.text,
|
|
624
343
|
port: shape.number
|
|
625
344
|
});
|
|
345
|
+
const textsShape = shape.openMap({});
|
|
346
|
+
const requestShape = shape.optional(shape.map({
|
|
347
|
+
method: optional(shape.text),
|
|
348
|
+
headers: optional(textsShape),
|
|
349
|
+
query: optional(textsShape),
|
|
350
|
+
body: optional(shape.oneOf(shape.text, shape.bytes)),
|
|
351
|
+
json: optional(shape.any)
|
|
352
|
+
}));
|
|
353
|
+
const fetchResultShape = shape.map({
|
|
354
|
+
status: shape.number,
|
|
355
|
+
headers: textsShape,
|
|
356
|
+
body: shape.bytes
|
|
357
|
+
});
|
|
626
358
|
const whole = (value) => {
|
|
627
359
|
const parts = value?.kind === "number" ? decimalParts(value.asDecimal()) : void 0;
|
|
628
360
|
return parts && isInteger(parts) ? integerOf(parts) : void 0;
|
|
@@ -645,6 +377,7 @@ const checkResponse = (response) => {
|
|
|
645
377
|
}
|
|
646
378
|
const headers = given(response, "headers");
|
|
647
379
|
if (headers?.kind === "map") {
|
|
380
|
+
if (duplicateHeaderNames(headers)) throw invalid("invalid response", "headers");
|
|
648
381
|
for (const [, value] of headers.entries()) if (!(value.kind === "text" || value.kind === "list" && Array.from({ length: value.length }, (_, i) => value.index(i + 1).kind).every((kind) => kind === "text"))) throw invalid("invalid response", "headers");
|
|
649
382
|
}
|
|
650
383
|
const json = given(response, "json");
|
|
@@ -664,15 +397,27 @@ const resolvedResponse = (response) => {
|
|
|
664
397
|
if (!given(response, "json")) return response;
|
|
665
398
|
return map(response.entries().map(([k, v]) => [k, k === "json" ? text(jsonText(v)) : v]));
|
|
666
399
|
};
|
|
667
|
-
|
|
400
|
+
const SERVER = [
|
|
401
|
+
"serve",
|
|
402
|
+
"unserve",
|
|
403
|
+
"respond"
|
|
404
|
+
];
|
|
405
|
+
/**
|
|
406
|
+
* Optional for Hosts. The binding is the Host's own description of the
|
|
407
|
+
* addresses a Grant may listen on and the origins it may fetch from.
|
|
408
|
+
*/
|
|
668
409
|
const httpCapability = (impl, costs) => {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
410
|
+
const has = (name) => typeof impl?.[name] === "function";
|
|
411
|
+
const serving = SERVER.filter(has).length;
|
|
412
|
+
if (serving !== 0 && serving !== SERVER.length) {
|
|
413
|
+
const missing = SERVER.find((name) => !has(name));
|
|
414
|
+
throw new HostError("invalid value", `Http needs ${missing}`);
|
|
415
|
+
}
|
|
416
|
+
if (serving === 0 && !has("fetch")) throw new HostError("invalid value", "Http needs serve, unserve and respond, fetch, or all four");
|
|
417
|
+
const server = impl;
|
|
418
|
+
const client = impl;
|
|
419
|
+
const all = {
|
|
420
|
+
serve: () => ({
|
|
676
421
|
mode: "suspending",
|
|
677
422
|
args: [
|
|
678
423
|
shape.text,
|
|
@@ -684,20 +429,20 @@ const httpCapability = (impl, costs) => {
|
|
|
684
429
|
errors: [{ code: "address in use" }, { code: "bad address" }],
|
|
685
430
|
maxPendingMs: HTTP_MAX_PENDING_MS,
|
|
686
431
|
cost: costOf(costs, "serve"),
|
|
687
|
-
start: (call, ...args) =>
|
|
688
|
-
},
|
|
689
|
-
unserve: {
|
|
432
|
+
start: (call, ...args) => server.serve(call, args[0].asText(), args[1].asText(), effectiveMessage(args), args[3]?.kind === "map" ? args[3] : map([]))
|
|
433
|
+
}),
|
|
434
|
+
unserve: () => ({
|
|
690
435
|
mode: "immediate",
|
|
691
436
|
args: [shape.text],
|
|
692
437
|
result: shape.nothing,
|
|
693
438
|
errors: [],
|
|
694
439
|
cost: costOf(costs, "unserve"),
|
|
695
440
|
do: (call, name) => {
|
|
696
|
-
|
|
441
|
+
server.unserve(call, name.asText());
|
|
697
442
|
return nothing;
|
|
698
443
|
}
|
|
699
|
-
},
|
|
700
|
-
respond: {
|
|
444
|
+
}),
|
|
445
|
+
respond: () => ({
|
|
701
446
|
mode: "immediate",
|
|
702
447
|
args: [exchangeShape, responseShape],
|
|
703
448
|
result: shape.nothing,
|
|
@@ -708,11 +453,28 @@ const httpCapability = (impl, costs) => {
|
|
|
708
453
|
],
|
|
709
454
|
cost: costOf(costs, "respond"),
|
|
710
455
|
do: (call, exchange, response) => {
|
|
711
|
-
|
|
456
|
+
server.respond(call, exchange.asObject(), resolvedResponse(response));
|
|
712
457
|
return nothing;
|
|
713
458
|
}
|
|
714
|
-
}
|
|
459
|
+
}),
|
|
460
|
+
fetch: () => ({
|
|
461
|
+
mode: "suspending",
|
|
462
|
+
args: [shape.text, requestShape],
|
|
463
|
+
result: fetchResultShape,
|
|
464
|
+
errors: [
|
|
465
|
+
{ code: "bad address" },
|
|
466
|
+
{ code: "network error" },
|
|
467
|
+
{ code: "response too large" }
|
|
468
|
+
],
|
|
469
|
+
cost: costOf(costs, "fetch"),
|
|
470
|
+
start: (call, ...args) => {
|
|
471
|
+
const { url, request } = checkFetch(args);
|
|
472
|
+
client.fetch(call, url, request);
|
|
473
|
+
}
|
|
474
|
+
})
|
|
715
475
|
};
|
|
476
|
+
const operations = {};
|
|
477
|
+
for (const name of [...serving ? SERVER : [], ...has("fetch") ? ["fetch"] : []]) operations[name] = all[name]();
|
|
716
478
|
const hostErrors = {
|
|
717
479
|
serve: ["address in use", "bad address"],
|
|
718
480
|
unserve: [],
|
|
@@ -720,15 +482,21 @@ const httpCapability = (impl, costs) => {
|
|
|
720
482
|
"already responded",
|
|
721
483
|
"exchange closed",
|
|
722
484
|
"not owner"
|
|
485
|
+
],
|
|
486
|
+
fetch: [
|
|
487
|
+
"bad address",
|
|
488
|
+
"network error",
|
|
489
|
+
"response too large"
|
|
723
490
|
]
|
|
724
491
|
};
|
|
725
492
|
for (const [name, op] of Object.entries(operations)) registerStandardChecks(op, {
|
|
726
493
|
error: (code) => hostErrors[name].includes(code),
|
|
727
494
|
arguments: (args) => {
|
|
728
495
|
if (name === "respond") checkResponse(args[1]);
|
|
496
|
+
else if (name === "fetch") checkFetch(args);
|
|
729
497
|
else checkServe(args, name === "serve");
|
|
730
498
|
},
|
|
731
|
-
...name === "serve" ? { result: (answer) => answer.kind === "map" && whole(answer.get("port")) !== void 0 } : {}
|
|
499
|
+
...name === "serve" ? { result: (answer) => answer.kind === "map" && whole(answer.get("port")) !== void 0 } : name === "fetch" ? { result: fetchAnswerOk } : {}
|
|
732
500
|
});
|
|
733
501
|
return fixed(defineValueCapability("http", operations));
|
|
734
502
|
};
|
|
@@ -810,4 +578,4 @@ const inlineGrants = (capabilities) => Object.fromEntries(Object.entries(capabil
|
|
|
810
578
|
return [name, defineCapability(name, ops).grant("all", void 0)];
|
|
811
579
|
}));
|
|
812
580
|
//#endregion
|
|
813
|
-
export { sqliteCapability as a,
|
|
581
|
+
export { sqliteCapability as a, talk as c, httpCapability as i, createGroup as n, fromValue as o, handlersOf as r, toValue as s, inlineGrants as t };
|
package/lean-BebPaTMK.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import { in as unicodeVersion } from "./errors-D11zizZg.js";
|
|
3
|
+
import { i as restore, l as compileLibrary, r as newGroup, s as stateFingerprint } from "./group-BflSou2n.js";
|
|
4
|
+
import { t as defineObjectKind } from "./objects-DmUc0lha.js";
|
|
5
|
+
import { _t as defineCapability, ft as languageVersion, ut as costModel } from "./operations-DnCcztkZ.js";
|
|
6
|
+
import { a as sqliteCapability, i as httpCapability, n as createGroup$1 } from "./inline-grants-XbX9HL_w.js";
|
|
7
|
+
import { n as localeCapability, t as userCapability } from "./user-capability-BcRQyyEw.js";
|
|
8
|
+
import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability } from "./store-capability-BrUUAwVS.js";
|
|
9
|
+
//#region src/versions.ts
|
|
10
|
+
const coreVersions = Object.freeze({
|
|
11
|
+
language: languageVersion,
|
|
12
|
+
costModel: String(costModel.version),
|
|
13
|
+
unicode: unicodeVersion,
|
|
14
|
+
core: "ts/0.5.1",
|
|
15
|
+
saveFormat: String(1)
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/core.ts
|
|
19
|
+
const core = Object.freeze({
|
|
20
|
+
defineCapability,
|
|
21
|
+
defineObjectKind,
|
|
22
|
+
clockCapability,
|
|
23
|
+
calendarCapability,
|
|
24
|
+
localeCapability,
|
|
25
|
+
timerCapability,
|
|
26
|
+
consoleCapability,
|
|
27
|
+
storeCapability,
|
|
28
|
+
sqliteCapability,
|
|
29
|
+
userCapability,
|
|
30
|
+
httpCapability,
|
|
31
|
+
compileLibrary,
|
|
32
|
+
newGroup,
|
|
33
|
+
restore,
|
|
34
|
+
stateFingerprint,
|
|
35
|
+
versions: coreVersions
|
|
36
|
+
});
|
|
37
|
+
/** Return the process-wide Core, also used by the free-function helpers. */
|
|
38
|
+
const createCore = () => core;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/create-group.ts
|
|
41
|
+
/** Creates a driven Group that supports `await using` and explicit close(reason). */
|
|
42
|
+
const createGroup = (o) => createGroup$1({
|
|
43
|
+
...o,
|
|
44
|
+
core: o.core ?? createCore()
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createCore as n, coreVersions as r, createGroup as t };
|