@northtalk/ts 0.5.1 → 0.7.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/{binary-value-xvJoGg0C.d.ts → binary-value-M8v567iA.d.ts} +1 -1
- package/{checker-CUhn2XaM.js → checker-Coml0Tf9.js} +581 -71
- package/{core-BuTAYRm-.d.ts → core-D4qYURer.d.ts} +1 -1
- package/{debug-DRhMZAxw.d.ts → debug-C_Ob5rkl.d.ts} +137 -12
- package/debug.d.ts +1 -1
- package/debug.js +1 -1
- package/{driver-CHDcuqUy.d.ts → driver-CLi_OmyQ.d.ts} +1 -1
- package/driver.d.ts +1 -1
- package/driver.js +1 -1
- package/encoding-BL2ECJmg.js +338 -0
- package/{engine-Cc3yofGM.d.ts → engine-BBNHy4-F.d.ts} +2 -2
- package/{engine-CXf5FCwi.js → engine-DhBk0lTt.js} +6 -6
- package/{errors-D11zizZg.js → errors-P3ga1I-9.js} +124 -21
- package/{group-BflSou2n.js → group-BqccKTWz.js} +406 -75
- package/{http-fetch-DFwVIOQg.js → http-fetch-DA-NbFIM.js} +2 -2
- package/http.d.ts +1 -1
- package/http.js +5 -5
- package/index-CBuczWK0.d.ts +9 -0
- package/index.d.ts +6 -12
- package/index.js +15 -14
- package/{inline-grants-XbX9HL_w.js → inline-grants-BT2nnfLA.js} +4 -5
- package/{lean-BebPaTMK.js → lean-BJmLobmd.js} +13 -8
- package/{lean-CjWVuOrC.d.ts → lean-CFLJ9VrX.d.ts} +155 -6
- package/lean.d.ts +5 -6
- package/lean.js +15 -14
- package/{manifest-CCfpn0kC.js → manifest-37x-HSxH.js} +4 -3
- 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-DmUc0lha.js → objects-DE6kRk0r.js} +1 -1
- package/{objects-DC6HjzBY.d.ts → objects-DVlpWsi0.d.ts} +11 -3
- package/{operations-DnCcztkZ.js → operations-CGjDlkGU.js} +73 -15
- package/package.json +5 -1
- package/peer-capability-elnbQy-J.js +149 -0
- package/peer.d.ts +173 -0
- package/peer.js +542 -0
- package/{readers-MmyZ_d0w.d.ts → readers-ChQ0e92c.d.ts} +1 -1
- package/{readers-CsvlahLi.js → readers-yMS1eAOp.js} +1 -1
- package/{request-pump-binary-oqjWFqZA.js → request-pump-binary-BS1J8DF2.js} +4 -4
- package/{router-BZ-aYeXA.js → router-Bm7A2kjt.js} +4 -4
- package/{router-D56rSkU8.d.ts → router-D0rf5SkW.d.ts} +2 -2
- package/session.d.ts +2 -2
- package/session.js +65 -17
- package/setup.d.ts +3 -2
- package/setup.js +13 -16
- package/sqlite.d.ts +2 -2
- package/sqlite.js +5 -5
- package/{store-DHlo6fP5.js → store-D80OlpyG.js} +2 -2
- package/store-capability-DBLlWaNO.js +187 -0
- package/store.d.ts +2 -2
- package/store.js +2 -2
- package/{user-capability-BcRQyyEw.js → user-capability-D6hGa3eF.js} +3 -4
- package/wasm.d.ts +16 -7
- package/wasm.js +52 -23
- package/encoding-RUuES_e4.js +0 -99
- package/manifest-DVrx-pT2.d.ts +0 -122
- package/store-capability-BrUUAwVS.js +0 -389
package/session.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group-
|
|
4
|
-
import { o as stateOf, t as defineObjectKind } from "./objects-
|
|
5
|
-
import { H as
|
|
6
|
-
import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-
|
|
7
|
-
import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-
|
|
8
|
-
import { c as readDisplay, l as readOrderedJSON, r as decodeValue } from "./readers-
|
|
9
|
-
import { n as quoteJSON, t as encodeValue } from "./encoding-
|
|
10
|
-
import { n as localeCapability, t as userCapability } from "./user-capability-
|
|
11
|
-
import {
|
|
12
|
-
import { buildSetupGroup, capabilityOperations, immutableSetup,
|
|
13
|
-
import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-
|
|
14
|
-
import { i as memoryStores } from "./store-
|
|
2
|
+
import { A as listValues, Jt as parseInstant, L as nothing, N as map, Qt as characterBoundaries, R as num, Ut as formatInstant, W as range, cn as builtins, et as text, i as ScriptError, l as Value, n as LoadError, nn as lower, t as HostError, u as bool } from "./errors-P3ga1I-9.js";
|
|
3
|
+
import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group-BqccKTWz.js";
|
|
4
|
+
import { o as stateOf, t as defineObjectKind } from "./objects-DE6kRk0r.js";
|
|
5
|
+
import { H as textForm$1, Tt as shape, U as waitUs, bt as defineValueCapability, kt as validStaticMessageName, tt as functionHead, ut as compareText, wt as operationDeclarations, x as integerValue } from "./operations-CGjDlkGU.js";
|
|
6
|
+
import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-Coml0Tf9.js";
|
|
7
|
+
import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-37x-HSxH.js";
|
|
8
|
+
import { c as readDisplay, l as readOrderedJSON, r as decodeValue } from "./readers-yMS1eAOp.js";
|
|
9
|
+
import { a as clockCapability, i as calendarCapability, n as quoteJSON, o as consoleCapability, t as encodeValue } from "./encoding-BL2ECJmg.js";
|
|
10
|
+
import { n as localeCapability, t as userCapability } from "./user-capability-D6hGa3eF.js";
|
|
11
|
+
import { r as storeCapability } from "./store-capability-DBLlWaNO.js";
|
|
12
|
+
import { buildSetupGroup, capabilityOperations, immutableSetup, shapeOf } from "./setup.js";
|
|
13
|
+
import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-DhBk0lTt.js";
|
|
14
|
+
import { i as memoryStores } from "./store-D80OlpyG.js";
|
|
15
15
|
//#region src/session/objects.ts
|
|
16
16
|
const externalCollection = () => {
|
|
17
17
|
throw new Error("external collection callback in replay");
|
|
@@ -1770,7 +1770,7 @@ var Stubs = class Stubs {
|
|
|
1770
1770
|
if (!stub.error.entries().length) throw new Error(`The Stub for ${operation} fails`);
|
|
1771
1771
|
throw hostFailure(stub.error);
|
|
1772
1772
|
}
|
|
1773
|
-
return stub.value ?? nothing;
|
|
1773
|
+
return stub.value ?? stub.later?.() ?? nothing;
|
|
1774
1774
|
}
|
|
1775
1775
|
/** A suspending call takes a Stub for its charge, and for an error that fails it at once. */
|
|
1776
1776
|
start(operation, call, recorded) {
|
|
@@ -2437,6 +2437,9 @@ var SessionHost = class {
|
|
|
2437
2437
|
case "library":
|
|
2438
2438
|
this.start();
|
|
2439
2439
|
return this.library(rest);
|
|
2440
|
+
case "script":
|
|
2441
|
+
this.start();
|
|
2442
|
+
return this.addScript(rest);
|
|
2440
2443
|
case "export":
|
|
2441
2444
|
this.start();
|
|
2442
2445
|
return this.export(words(rest, rest.trim() ? 1 : 0)[0]);
|
|
@@ -2936,6 +2939,49 @@ var SessionHost = class {
|
|
|
2936
2939
|
});
|
|
2937
2940
|
return this.discarded(reports);
|
|
2938
2941
|
}
|
|
2942
|
+
addScript(rest) {
|
|
2943
|
+
const newline = rest.indexOf("\n");
|
|
2944
|
+
const [how, name, path, more] = (newline < 0 ? rest : rest.slice(0, newline)).trim().split(/\s+/u);
|
|
2945
|
+
if (how !== "add" || !NAME_TEXT.test(name ?? "") || more !== void 0 || newline < 0 === (path === void 0)) refuse("bad arguments");
|
|
2946
|
+
let source;
|
|
2947
|
+
if (newline >= 0) source = `${rest.slice(newline + 1)}\n`;
|
|
2948
|
+
else {
|
|
2949
|
+
try {
|
|
2950
|
+
source = librarySource(this.env.readFile(path));
|
|
2951
|
+
} catch {
|
|
2952
|
+
return refuse("bad arguments");
|
|
2953
|
+
}
|
|
2954
|
+
this.recording = `:script add ${name}\n${source.slice(0, -1)}`;
|
|
2955
|
+
}
|
|
2956
|
+
if (name === NAME || this.group.script(name)) refuse("name reused");
|
|
2957
|
+
const session = this.setup0.scripts[0];
|
|
2958
|
+
this.setup0 = immutableSetup({
|
|
2959
|
+
...this.setup0,
|
|
2960
|
+
scripts: [...this.setup0.scripts, {
|
|
2961
|
+
name,
|
|
2962
|
+
source: "(inline)",
|
|
2963
|
+
text: source,
|
|
2964
|
+
grants: session.grants,
|
|
2965
|
+
grantsAsUsed: true
|
|
2966
|
+
}]
|
|
2967
|
+
});
|
|
2968
|
+
try {
|
|
2969
|
+
this.group.load({
|
|
2970
|
+
name,
|
|
2971
|
+
source,
|
|
2972
|
+
grants: this.grantsByName,
|
|
2973
|
+
grantsAsUsed: true,
|
|
2974
|
+
objects: this.objectBindings
|
|
2975
|
+
});
|
|
2976
|
+
} catch (error) {
|
|
2977
|
+
if (error instanceof LoadError) return error.diagnostics.map((d) => `! ${d.code} at ${d.unit}:${d.line}:${d.col}`);
|
|
2978
|
+
return this.refused(error, {
|
|
2979
|
+
line: 0,
|
|
2980
|
+
col: 0
|
|
2981
|
+
});
|
|
2982
|
+
}
|
|
2983
|
+
return this.pump();
|
|
2984
|
+
}
|
|
2939
2985
|
store(rest) {
|
|
2940
2986
|
const newline = rest.indexOf("\n");
|
|
2941
2987
|
const w = (newline < 0 ? rest : rest.slice(0, newline)).trim().split(/\s+/u).filter(Boolean);
|
|
@@ -2987,10 +3033,12 @@ var SessionHost = class {
|
|
|
2987
3033
|
return files.map(([file]) => `wrote ${file}`);
|
|
2988
3034
|
}
|
|
2989
3035
|
inspected(what) {
|
|
2990
|
-
const
|
|
3036
|
+
const scripts = this.inspect().scripts;
|
|
3037
|
+
const script = scripts.find((s) => s.name === NAME);
|
|
3038
|
+
const all = [script, ...scripts.filter((s) => s !== script)];
|
|
2991
3039
|
if (what === "vars") return script.vars.map(([name, value]) => `${name} = ${value.toString()}`);
|
|
2992
|
-
if (what === "mailbox") return
|
|
2993
|
-
return
|
|
3040
|
+
if (what === "mailbox") return all.flatMap((s) => s.mailbox).map((m) => `${m.delivery ?? m.from} ${m.message.name} ${listValues(m.message.args ?? []).toString()}`);
|
|
3041
|
+
return all.flatMap((s) => s.runs).map((r) => [
|
|
2994
3042
|
r.id,
|
|
2995
3043
|
r.status,
|
|
2996
3044
|
r.handler,
|
package/setup.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { Xt as operationDeclarations } from "./debug-C_Ob5rkl.js";
|
|
3
|
+
import { A as shapeOf, C as Setup, D as capabilityOperations, E as buildSetupGroup, M as tsCore, O as immutableSetup, S as OperationSpec, T as ShapeSpec, b as MissingCapabilityError, j as shapeSpec, k as musicalClockOf, w as SetupGroup, x as ObjectRefSpec, y as CaseCore } from "./objects-DVlpWsi0.js";
|
|
4
|
+
export { CaseCore, MissingCapabilityError, ObjectRefSpec, OperationSpec, Setup, SetupGroup, ShapeSpec, buildSetupGroup, capabilityOperations, immutableSetup, musicalClockOf, operationDeclarations, shapeOf, shapeSpec, tsCore };
|
package/setup.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import { n as LoadError } from "./errors-
|
|
3
|
-
import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group-
|
|
4
|
-
import { t as defineObjectKind } from "./objects-
|
|
5
|
-
import {
|
|
2
|
+
import { n as LoadError } from "./errors-P3ga1I-9.js";
|
|
3
|
+
import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group-BqccKTWz.js";
|
|
4
|
+
import { t as defineObjectKind } from "./objects-DE6kRk0r.js";
|
|
5
|
+
import { Tt as shape, wt as operationDeclarations } from "./operations-CGjDlkGU.js";
|
|
6
|
+
import { r as MUSICAL_CLOCK } from "./encoding-BL2ECJmg.js";
|
|
6
7
|
//#region src/setup.ts
|
|
7
|
-
const operationDeclarations = (capabilities) => {
|
|
8
|
-
const declarations = Object.create(null);
|
|
9
|
-
for (const [name, capability] of capabilities) declarations[name] = Object.fromEntries([...capability.operations].map(([operation, op]) => [operation, {
|
|
10
|
-
args: op.args ?? [],
|
|
11
|
-
mode: op.mode,
|
|
12
|
-
...op.labels?.length ? { labels: op.labels } : {},
|
|
13
|
-
...op.command ? { command: true } : {}
|
|
14
|
-
}]));
|
|
15
|
-
return declarations;
|
|
16
|
-
};
|
|
17
8
|
const tsCore = {
|
|
18
9
|
compileLibrary,
|
|
19
10
|
defineObjectKind,
|
|
@@ -95,13 +86,19 @@ const immutableSetup = (setup) => {
|
|
|
95
86
|
return setup;
|
|
96
87
|
};
|
|
97
88
|
/** Make a Group whose Scripts are loaded only when the Host requests them. */
|
|
89
|
+
/** A case's `musical-clock` Standard Capability, as the Group option. */
|
|
90
|
+
const musicalClockOf = (capabilities) => {
|
|
91
|
+
const clock = capabilities.get(MUSICAL_CLOCK);
|
|
92
|
+
return clock ? { musicalClock: clock } : {};
|
|
93
|
+
};
|
|
98
94
|
const buildSetupGroup = (setup, capabilities, options) => {
|
|
99
95
|
const core = options.core ?? tsCore;
|
|
100
96
|
const group = core.newGroup({
|
|
101
97
|
name: options.name,
|
|
102
98
|
session: options.session,
|
|
103
99
|
trace: options.trace,
|
|
104
|
-
...setup.seed === void 0 ? {} : { seed: BigInt(setup.seed) }
|
|
100
|
+
...setup.seed === void 0 ? {} : { seed: BigInt(setup.seed) },
|
|
101
|
+
...musicalClockOf(capabilities)
|
|
105
102
|
});
|
|
106
103
|
const readSource = options.readSource ?? ((file) => {
|
|
107
104
|
throw new Error(`No source reader for ${file}`);
|
|
@@ -190,4 +187,4 @@ const shapeOf = (s) => {
|
|
|
190
187
|
throw new Error("Unknown Shape");
|
|
191
188
|
};
|
|
192
189
|
//#endregion
|
|
193
|
-
export { MissingCapabilityError, buildSetupGroup, capabilityOperations, immutableSetup, operationDeclarations, shapeOf, shapeSpec, tsCore };
|
|
190
|
+
export { MissingCapabilityError, buildSetupGroup, capabilityOperations, immutableSetup, musicalClockOf, operationDeclarations, shapeOf, shapeSpec, tsCore };
|
package/sqlite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" />
|
|
2
|
-
import { Wt as SegmentCoordinator, bt as Call,
|
|
3
|
-
import { a as Stores, r as StoreQuotas } from "./engine-
|
|
2
|
+
import { Wt as SegmentCoordinator, bt as Call, fn as StoreImpl, gn as SqlRows, hn as SqlParams, vn as SqliteBinding, yn as SqliteImpl } from "./debug-C_Ob5rkl.js";
|
|
3
|
+
import { a as Stores, r as StoreQuotas } from "./engine-BBNHy4-F.js";
|
|
4
4
|
//#region src/sqlite/database.d.ts
|
|
5
5
|
/** The table that keeps a database's Stores, which no `sqlite` Grant may use. */
|
|
6
6
|
export declare const STORE_TABLE = "store";
|
package/sqlite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { r as decodeValue } from "./readers-
|
|
4
|
-
import { t as encodeValue } from "./encoding-
|
|
5
|
-
import { n as hostScriptError } from "./store-capability-
|
|
6
|
-
import { r as Stores, t as StoreContentsError } from "./engine-
|
|
2
|
+
import { et as text, t as HostError, v as dec } from "./errors-P3ga1I-9.js";
|
|
3
|
+
import { r as decodeValue } from "./readers-yMS1eAOp.js";
|
|
4
|
+
import { t as encodeValue } from "./encoding-BL2ECJmg.js";
|
|
5
|
+
import { n as hostScriptError } from "./store-capability-DBLlWaNO.js";
|
|
6
|
+
import { r as Stores, t as StoreContentsError } from "./engine-DhBk0lTt.js";
|
|
7
7
|
import { DatabaseSync } from "node:sqlite";
|
|
8
8
|
//#region src/sqlite/scan.ts
|
|
9
9
|
const isWordChar = (c) => /[\w$]/.test(c) || c.charCodeAt(0) > 127;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-
|
|
2
|
+
import { ut as compareText } from "./operations-CGjDlkGU.js";
|
|
3
|
+
import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-DhBk0lTt.js";
|
|
4
4
|
//#region src/store/memory.ts
|
|
5
5
|
/** A backend that keeps nothing outside the engine's own copy. */
|
|
6
6
|
const memoryBackend = () => ({
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
|
|
2
|
+
import { L as nothing, N as map, et as text, i as ScriptError, t as HostError, u as bool } from "./errors-P3ga1I-9.js";
|
|
3
|
+
import { Dt as validComputedMessageName, Tt as shape, bt as defineValueCapability, ft as errorMessages, i as arithmetic, n as ScriptError$1 } from "./operations-CGjDlkGU.js";
|
|
4
|
+
import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-BL2ECJmg.js";
|
|
5
|
+
//#region src/store-capability.ts
|
|
6
|
+
/** A Core-raised error as the Host sees it, with its catalogue message. */
|
|
7
|
+
const hostScriptError = (code, fields) => {
|
|
8
|
+
const message = (errorMessages[code] ?? code).replaceAll(/{(\w+)}/g, (_, name) => {
|
|
9
|
+
const field = fields.find(([k]) => k === name);
|
|
10
|
+
return field ? field[1].toString() : `{${name}}`;
|
|
11
|
+
});
|
|
12
|
+
return new ScriptError(code, message, map(fields.map(([k, v]) => [k, v])));
|
|
13
|
+
};
|
|
14
|
+
/** The `+` rules outside any Run, uncharged (chapter 9, Adding). */
|
|
15
|
+
const add = (a, b) => {
|
|
16
|
+
try {
|
|
17
|
+
return arithmetic("add", a, b);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw error instanceof ScriptError$1 ? hostScriptError(error.code, error.fields) : error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const textShape = shape.text;
|
|
23
|
+
const keyShape = textShape;
|
|
24
|
+
const amountShape = shape.oneOf(shape.number, {
|
|
25
|
+
k: "kind",
|
|
26
|
+
kind: "quantity"
|
|
27
|
+
});
|
|
28
|
+
const OPERATIONS = [
|
|
29
|
+
"get",
|
|
30
|
+
"set",
|
|
31
|
+
"delete",
|
|
32
|
+
"keys",
|
|
33
|
+
"increment",
|
|
34
|
+
"swap",
|
|
35
|
+
"watch",
|
|
36
|
+
"unwatch"
|
|
37
|
+
];
|
|
38
|
+
const isText = (data, field) => data.get(field).kind === "text";
|
|
39
|
+
const errorFields = {
|
|
40
|
+
"can't store": (data) => isText(data, "kind"),
|
|
41
|
+
"store full": (data) => [
|
|
42
|
+
"size",
|
|
43
|
+
"keys",
|
|
44
|
+
"value"
|
|
45
|
+
].includes(data.get("limit").asText() ?? ""),
|
|
46
|
+
"store busy": (data) => isText(data, "key"),
|
|
47
|
+
"watch limit": (data) => [
|
|
48
|
+
"watches",
|
|
49
|
+
"size",
|
|
50
|
+
"pending"
|
|
51
|
+
].includes(data.get("limit").asText() ?? ""),
|
|
52
|
+
"wrong kind": (data) => isText(data, "expected") && isText(data, "got") && data.entries().some(([k]) => k === "value"),
|
|
53
|
+
"incompatible units": (data) => isText(data, "left") && isText(data, "right"),
|
|
54
|
+
overflow: (data) => isText(data, "operator")
|
|
55
|
+
};
|
|
56
|
+
const checkKey = (args) => {
|
|
57
|
+
if (args[0].asText() === "") throw new ScriptError$1("invalid key", [], true);
|
|
58
|
+
};
|
|
59
|
+
const effectiveMessage = (args) => args[2]?.asText() ?? "storeChanged";
|
|
60
|
+
const checkUnwatch = (args) => {
|
|
61
|
+
if (args[0].asText() === "") throw new ScriptError$1("invalid watch", [["field", text("name")]], true);
|
|
62
|
+
};
|
|
63
|
+
const checkWatch = (args) => {
|
|
64
|
+
checkUnwatch(args);
|
|
65
|
+
const message = effectiveMessage(args);
|
|
66
|
+
if (message.includes(":") || !validComputedMessageName(message, 1)) throw new ScriptError$1("invalid watch", [["field", text("message")]], true);
|
|
67
|
+
};
|
|
68
|
+
const argumentChecks = {
|
|
69
|
+
watch: checkWatch,
|
|
70
|
+
unwatch: checkUnwatch
|
|
71
|
+
};
|
|
72
|
+
const errors = (...codes) => codes.map((code) => ({ code }));
|
|
73
|
+
const writes = [
|
|
74
|
+
"can't store",
|
|
75
|
+
"store full",
|
|
76
|
+
"store busy"
|
|
77
|
+
];
|
|
78
|
+
const key = (args) => args[0].asText();
|
|
79
|
+
/** The Store is the Host's; the Grant binding names it, and `impl` coordinates every binding. */
|
|
80
|
+
const storeCapability = (impl, costs) => {
|
|
81
|
+
for (const name of [
|
|
82
|
+
...OPERATIONS,
|
|
83
|
+
"begin",
|
|
84
|
+
"commit",
|
|
85
|
+
"rollback",
|
|
86
|
+
"release"
|
|
87
|
+
]) if (!impl || typeof impl[name] !== "function") throw new HostError("invalid value", `Store needs ${name}`);
|
|
88
|
+
const operations = {
|
|
89
|
+
watch: {
|
|
90
|
+
mode: "immediate",
|
|
91
|
+
args: [
|
|
92
|
+
textShape,
|
|
93
|
+
textShape,
|
|
94
|
+
shape.optional(textShape)
|
|
95
|
+
],
|
|
96
|
+
result: shape.nothing,
|
|
97
|
+
errors: errors("watch limit"),
|
|
98
|
+
cost: costOf(costs, "watch"),
|
|
99
|
+
do: (call, ...args) => {
|
|
100
|
+
impl.watch(call, key(args), args[1].asText(), effectiveMessage(args));
|
|
101
|
+
return nothing;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
unwatch: {
|
|
105
|
+
mode: "immediate",
|
|
106
|
+
args: [textShape],
|
|
107
|
+
result: shape.nothing,
|
|
108
|
+
errors: [],
|
|
109
|
+
cost: costOf(costs, "unwatch"),
|
|
110
|
+
do: (call, ...args) => {
|
|
111
|
+
impl.unwatch(call, key(args));
|
|
112
|
+
return nothing;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
get: {
|
|
116
|
+
mode: "immediate",
|
|
117
|
+
args: [keyShape, shape.optional(shape.any)],
|
|
118
|
+
result: shape.any,
|
|
119
|
+
errors: [],
|
|
120
|
+
cost: costOf(costs, "get"),
|
|
121
|
+
do: (call, ...args) => impl.get(call, key(args), args[1])
|
|
122
|
+
},
|
|
123
|
+
set: {
|
|
124
|
+
mode: "immediate",
|
|
125
|
+
args: [keyShape, shape.any],
|
|
126
|
+
result: shape.nothing,
|
|
127
|
+
errors: errors(...writes),
|
|
128
|
+
cost: costOf(costs, "set"),
|
|
129
|
+
segmentBound: true,
|
|
130
|
+
do: (call, ...args) => {
|
|
131
|
+
impl.set(call, key(args), args[1]);
|
|
132
|
+
return nothing;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
delete: {
|
|
136
|
+
mode: "immediate",
|
|
137
|
+
args: [keyShape],
|
|
138
|
+
result: shape.nothing,
|
|
139
|
+
errors: errors("store busy"),
|
|
140
|
+
cost: costOf(costs, "delete"),
|
|
141
|
+
segmentBound: true,
|
|
142
|
+
do: (call, ...args) => {
|
|
143
|
+
impl.delete(call, key(args));
|
|
144
|
+
return nothing;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
keys: {
|
|
148
|
+
mode: "immediate",
|
|
149
|
+
args: [shape.optional(textShape)],
|
|
150
|
+
result: shape.listOf(textShape),
|
|
151
|
+
errors: [],
|
|
152
|
+
cost: costOf(costs, "keys"),
|
|
153
|
+
do: (call, prefix) => impl.keys(call, prefix?.asText())
|
|
154
|
+
},
|
|
155
|
+
increment: {
|
|
156
|
+
mode: "immediate",
|
|
157
|
+
args: [keyShape, shape.optional(amountShape)],
|
|
158
|
+
result: amountShape,
|
|
159
|
+
errors: errors("wrong kind", "incompatible units", "overflow", "store full", "store busy"),
|
|
160
|
+
cost: costOf(costs, "increment"),
|
|
161
|
+
segmentBound: true,
|
|
162
|
+
do: (call, ...args) => impl.increment(call, key(args), args[1])
|
|
163
|
+
},
|
|
164
|
+
swap: {
|
|
165
|
+
mode: "immediate",
|
|
166
|
+
args: [
|
|
167
|
+
keyShape,
|
|
168
|
+
shape.any,
|
|
169
|
+
shape.any
|
|
170
|
+
],
|
|
171
|
+
result: shape.bool,
|
|
172
|
+
errors: errors(...writes),
|
|
173
|
+
cost: costOf(costs, "swap"),
|
|
174
|
+
segmentBound: true,
|
|
175
|
+
do: (call, ...args) => bool(impl.swap(call, key(args), args[1], args[2]))
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const coordinator = impl;
|
|
179
|
+
const capability = defineValueCapability("store", operations, { coordinator: () => coordinator }, (context) => impl.release(context));
|
|
180
|
+
for (const [name, op] of capability.operations) registerStandardChecks(op, {
|
|
181
|
+
error: (code, data) => Boolean(op.errors?.some((e) => e.code === code) && errorFields[code]?.(data)),
|
|
182
|
+
...name === "keys" ? {} : { arguments: argumentChecks[name] ?? checkKey }
|
|
183
|
+
});
|
|
184
|
+
return fixed(capability);
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
export { hostScriptError as n, storeCapability as r, add as t };
|
package/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" />
|
|
2
|
-
import { n as RouterOptions } from "./router-
|
|
3
|
-
import { a as Stores, c as sessionQuotas, i as StoreStateUnknownError, l as sessionWatchLimits, n as StoreContentsError, o as decodeContents, r as StoreQuotas, s as encodeContents, t as StoreBackend } from "./engine-
|
|
2
|
+
import { n as RouterOptions } from "./router-D0rf5SkW.js";
|
|
3
|
+
import { a as Stores, c as sessionQuotas, i as StoreStateUnknownError, l as sessionWatchLimits, n as StoreContentsError, o as decodeContents, r as StoreQuotas, s as encodeContents, t as StoreBackend } from "./engine-BBNHy4-F.js";
|
|
4
4
|
//#region src/store/memory.d.ts
|
|
5
5
|
/** A backend that keeps nothing outside the engine's own copy. */
|
|
6
6
|
export declare const memoryBackend: () => StoreBackend;
|
package/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-
|
|
3
|
-
import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-
|
|
2
|
+
import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-DhBk0lTt.js";
|
|
3
|
+
import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-D80OlpyG.js";
|
|
4
4
|
export { StoreContentsError, StoreStateUnknownError, Stores, decodeContents, encodeContents, memoryBackend, memoryStores, sessionQuotas, sessionWatchLimits, webStorageBackend, webStorageStores };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { c as fixed, s as costOf } from "./store-capability-BrUUAwVS.js";
|
|
2
|
+
import { Ct as integerOf, N as map, et as text, t as HostError, u as bool, wt as isInteger, y as decimalParts } from "./errors-P3ga1I-9.js";
|
|
3
|
+
import { Tt as shape, bt as defineValueCapability, n as ScriptError } from "./operations-CGjDlkGU.js";
|
|
4
|
+
import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-BL2ECJmg.js";
|
|
6
5
|
//#region src/locale-tag.ts
|
|
7
6
|
const grandfathered = /^(?:en-gb-oed|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)|sgn-(?:be-fr|be-nl|ch-de))$/i;
|
|
8
7
|
const alpha = /^[a-z]+$/i;
|
package/wasm.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" />
|
|
2
|
-
import { $ as instant, $
|
|
3
|
-
import {
|
|
4
|
-
import { a as decodeValue, n as Json, o as readDisplay } from "./readers-
|
|
5
|
-
import { t as BinaryValueOptions } from "./binary-value-
|
|
2
|
+
import { $ as instant, $t as Group, At as FireOp, Bn as LimitName, Bt as ReleaseHook, C as Report, Cn as CalendarImpl, Ct as ChargeRequest, Dn as TimerImpl, Dt as EffectResult, E as RestoreResult, En as MusicalClockImpl, Et as Cost, Fn as LibrarySource, Ft as Metering, G as RunStarted, Gt as SegmentGrant, H as RunAccounting, Hn as Outcome, Ht as ScopeDecl, In as OperationRef, It as Operation, J as Value, Jt as SuspendingOp, K as Decimal, Kt as SegmentLifecycle, Lt as Operations, Mt as GrantContext, N as Settlement, Nn as Library, Nt as ImmediateOp, Ot as ErrorDecl, Pt as LimitReached, Q as dec, Qt as Core, R as Verdict, Rt as PlainArg, S as PumpedRequest, St as CapabilityDefiner, T as RestoreOptions, Tn as Costs, Tt as CoordinatedLifecycle, U as RunAncestry, Ut as SegmentContext, V as CausalWork, Vn as Limits, Vt as ReleaseReason, W as RunDiscarded, Wt as SegmentCoordinator, X as bytes, Xt as operationDeclarations, Y as bool, Yt as defineCapability, Z as civilDate, Zt as shape, _ as LoadOptions, _n as SqlValue, _t as PropDef, ar as ScriptError, at as quantity, b as PumpOptions, bt as Call, cn as HttpServerImpl, d as Counters, dt as nowMicros, en as Script, er as HostError, f as Decided, fn as StoreImpl, ft as parseInstant, g as Inspection, gn as SqlRows, gt as ObjectKindDef, h as GroupOptions, hn as SqlParams, ht as ObjectKind, ir as MailboxFull, it as num, jt as Grant, kt as FieldShape, l as CancellationOptions, lt as text, m as EffectFailure, mt as ObjectElements, nr as LoadDiagnostic, nt as map, on as HttpClientImpl, or as SendFailedReason, ot as range, p as Deciding, pn as add, pt as HostObject, q as Kind, qt as Shape, rn as PeerImpl, rr as LoadError, rt as nothing, sn as HttpImpl, st as record, tn as Versions, tr as HostErrorCode, tt as list, u as CarryOver, un as UserImpl, ut as formatInstant, v as Message, vn as SqliteBinding, w as Requested, wn as ConsoleImpl, wt as ChargeResult, x as PumpResult, xn as LocaleImpl, xt as CapabilityDef, y as PendingCall, yn as SqliteImpl, yt as GrantDecls, zt as PlainResult } from "./debug-C_Ob5rkl.js";
|
|
3
|
+
import { A as PlainValue, C as decodeJson, M as fromValue, N as toValue, O as encodeValue, P as talk, S as handlersOf, _ as CreateGroupOptions, b as Handlers, d as exportManifest, f as InlineFunction, j as ToValueOptions, k as FromValueOptions, l as ManifestSpec, m as inlineGrants, p as InlineOperation, u as MessageDecl, v as DrivenGroup, w as encodeJson, x as ScriptWithHandlers, y as createGroup } from "./lean-CFLJ9VrX.js";
|
|
4
|
+
import { a as decodeValue, n as Json, o as readDisplay } from "./readers-ChQ0e92c.js";
|
|
5
|
+
import { t as BinaryValueOptions } from "./binary-value-M8v567iA.js";
|
|
6
6
|
//#region src/wasm/reactor.d.ts
|
|
7
7
|
/** Text the reactor writes to stdout or stderr, such as a fatal error. */
|
|
8
8
|
type Diagnostics = (line: string) => void;
|
|
@@ -92,6 +92,8 @@ type GroupCore = {
|
|
|
92
92
|
session(): Session;
|
|
93
93
|
};
|
|
94
94
|
type GroupOptions$1 = {
|
|
95
|
+
/** From `musicalClockCapability`; every Script holds it as `musical-clock`. */
|
|
96
|
+
musicalClock?: CapabilityDef<unknown>;
|
|
95
97
|
name: string;
|
|
96
98
|
onReady?(): void;
|
|
97
99
|
/** The `random` generator's seed, 0 to 2⁶⁴ − 1; 0 when omitted. */
|
|
@@ -149,10 +151,14 @@ export declare class WasmGroup implements Group {
|
|
|
149
151
|
scriptNames(): string[];
|
|
150
152
|
load(o: LoadOptions): WasmScript;
|
|
151
153
|
addLibrary(l: Library): void;
|
|
152
|
-
replaceLibrary(l: Library, carry: CarryOver
|
|
154
|
+
replaceLibrary(l: Library, carry: CarryOver, o?: {
|
|
155
|
+
keepMailbox?: boolean;
|
|
156
|
+
}): Report[];
|
|
153
157
|
/** @internal Reload and Library replacement end Runs and settle their futures. */
|
|
154
158
|
lifecycle(m: string, fields: Record<string, Frame | undefined>): Report[];
|
|
155
|
-
object<N>(kind: ObjectKind<N>, id: string, native: N
|
|
159
|
+
object<N>(kind: ObjectKind<N>, id: string, native: N, o?: {
|
|
160
|
+
parent?: HostObject;
|
|
161
|
+
}): HostObject<N>;
|
|
156
162
|
objectById(kind: string, id: string): HostObject | undefined;
|
|
157
163
|
setParent(o: HostObject, parent: HostObject | undefined): void;
|
|
158
164
|
dispose(o: HostObject): void;
|
|
@@ -213,6 +219,9 @@ export declare class WasmCore implements Core {
|
|
|
213
219
|
sqliteCapability: (impl: SqliteImpl, costs: Costs, perStep: number) => CapabilityDef<SqliteBinding>;
|
|
214
220
|
userCapability: (impl: UserImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
215
221
|
httpCapability: (impl: HttpImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
222
|
+
musicalClockCapability: (impl: MusicalClockImpl, costs: Costs, release?: ReleaseHook<unknown>) => CapabilityDef<unknown>;
|
|
223
|
+
peerCapability: (impl: PeerImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
224
|
+
readonly peerKind: ObjectKind<unknown>;
|
|
216
225
|
defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
|
|
217
226
|
/** Checked in a guest the Core keeps; each Group's guest compiles it again when added. */
|
|
218
227
|
compileLibrary(src: LibrarySource, imports?: Library[], declarations?: GrantDecls): Library;
|
|
@@ -244,4 +253,4 @@ export declare const defaultLimits: Readonly<{
|
|
|
244
253
|
cleanupBudget: number;
|
|
245
254
|
}>;
|
|
246
255
|
//#endregion
|
|
247
|
-
export { type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ChargeRequest, type ChargeResult, type ConsoleImpl, type CoordinatedLifecycle, type Core, type CoreOptions, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type DrivenGroup, type EffectFailure, type EffectResult, type ErrorDecl, type FieldShape, type FireOp, type FromValueOptions, type Grant, type GrantContext, type GrantDecls, type Group, type GroupOptions, type Handlers, HostError, type HostErrorCode, type HostObject, type HttpClientImpl, type HttpImpl, type HttpServerImpl, type ImmediateOp, type InlineFunction, type InlineOperation, type Inspection, type Kind, type Library, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type Metering, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, type RunAccounting, type RunAncestry, type RunDiscarded, type RunStarted, type ScopeDecl, type Script, ScriptError, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SendFailedReason, type Settlement, type Shape, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StoreImpl, type SuspendingOp, type TimerImpl, type ToValueOptions, type UserImpl, Value, type Verdict, type Versions, type WasmSource, add, bool, bytes, civilDate, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
|
|
256
|
+
export { type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ChargeRequest, type ChargeResult, type ConsoleImpl, type CoordinatedLifecycle, type Core, type CoreOptions, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type DrivenGroup, type EffectFailure, type EffectResult, type ErrorDecl, type FieldShape, type FireOp, type FromValueOptions, type Grant, type GrantContext, type GrantDecls, type Group, type GroupOptions, type Handlers, HostError, type HostErrorCode, type HostObject, type HttpClientImpl, type HttpImpl, type HttpServerImpl, type ImmediateOp, type InlineFunction, type InlineOperation, type Inspection, type Kind, type Library, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type Metering, type MusicalClockImpl, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PeerImpl, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, type RunAccounting, type RunAncestry, type RunDiscarded, type RunStarted, type ScopeDecl, type Script, ScriptError, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SendFailedReason, type Settlement, type Shape, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StoreImpl, type SuspendingOp, type TimerImpl, type ToValueOptions, type UserImpl, Value, type Verdict, type Versions, type WasmSource, add, bool, bytes, civilDate, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
|