@northtalk/ts 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -2
- package/UNICODE-LICENSE.txt +39 -0
- package/base64-DORMd3Hv.js +6621 -0
- package/binary-value-CEmh60GC.d.ts +15 -0
- package/capabilities-CH0FkRMq.js +1301 -0
- package/checker-Dc1jl2WH.js +6657 -0
- package/core-DptnvQT9.d.ts +14 -0
- package/debug-CQBxKnJB.d.ts +3065 -0
- package/debug.d.ts +3 -0
- package/debug.js +2 -0
- package/driver.d.ts +41 -0
- package/driver.js +152 -0
- package/encoding-nlrpj-Pb.js +99 -0
- package/engine-BGaJ9dAk.js +326 -0
- package/engine-vbYInVYF.d.ts +86 -0
- package/errors-LYJZ_c8h.js +3735 -0
- package/group-B742gg4T.js +10170 -0
- package/http-capability-CSTkw1Yt.js +728 -0
- package/http.d.ts +59 -0
- package/http.js +465 -0
- package/index.d.ts +651 -0
- package/index.js +44 -0
- package/manifest-BscyH_rW.d.ts +70 -0
- package/manifest-DjsxDSuB.js +129 -0
- package/message-layer.d.ts +12 -0
- package/message-layer.js +4 -0
- package/notify.d.ts +3 -0
- package/notify.js +2 -0
- package/objects-DJ3QtCCs.d.ts +640 -0
- package/objects-Db7IB5vQ.js +91 -0
- package/operation-promises-EgZXG5N_.js +23 -0
- package/package.json +70 -4
- package/readers-BFPuosPk.d.ts +25 -0
- package/readers-CjJHKHvH.js +482 -0
- package/request-pump-binary-DdY3X-yl.js +2246 -0
- package/router--71qvxtY.js +343 -0
- package/router-Zhrw5l__.d.ts +55 -0
- package/session.d.ts +9 -0
- package/session.js +3510 -0
- package/setup.d.ts +3 -0
- package/setup.js +193 -0
- package/sha256-B_kyYw3Z.js +124 -0
- package/sqlite.d.ts +74 -0
- package/sqlite.js +529 -0
- package/store-capability-OZp4hXmj.js +390 -0
- package/store-hJrRULMx.js +60 -0
- package/store.d.ts +21 -0
- package/store.js +4 -0
- package/user-capability-BK4Asg7D.js +276 -0
- package/wasm.d.ts +243 -0
- package/wasm.js +1737 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
|
|
2
|
+
import { K as text, M as map, Ot as integerOf, kt as isInteger, t as HostError, u as bool, v as decimalParts } from "./errors-LYJZ_c8h.js";
|
|
3
|
+
import { a as defineValueCapability, u as shape } from "./capabilities-CH0FkRMq.js";
|
|
4
|
+
import { i as ScriptError } from "./base64-DORMd3Hv.js";
|
|
5
|
+
import { r as registerStandardChecks } from "./encoding-nlrpj-Pb.js";
|
|
6
|
+
import { c as fixed, s as costOf } from "./store-capability-OZp4hXmj.js";
|
|
7
|
+
//#region src/locale-tag.ts
|
|
8
|
+
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;
|
|
9
|
+
const alpha = /^[a-z]+$/i;
|
|
10
|
+
const variant = /^(?:[\da-z]{5,8}|\d[\da-z]{3})$/i;
|
|
11
|
+
const wellFormedLocale = (tag) => {
|
|
12
|
+
if (!tag.length || /[^\da-z-]/i.test(tag)) return false;
|
|
13
|
+
if (grandfathered.test(tag)) return true;
|
|
14
|
+
const parts = tag.split("-");
|
|
15
|
+
if (parts.some((part) => part.length < 1 || part.length > 8)) return false;
|
|
16
|
+
let i = 0;
|
|
17
|
+
const language = parts[i++];
|
|
18
|
+
if (/^x$/i.test(language)) return parts.length > 1;
|
|
19
|
+
if (language.length < 2 || !alpha.test(language)) return false;
|
|
20
|
+
if (language.length <= 3) for (let extlangs = 0; extlangs < 3 && /^[a-z]{3}$/i.test(parts[i] ?? ""); extlangs++) i++;
|
|
21
|
+
if (/^[a-z]{4}$/i.test(parts[i] ?? "")) i++;
|
|
22
|
+
if (/^(?:[a-z]{2}|\d{3})$/i.test(parts[i] ?? "")) i++;
|
|
23
|
+
while (variant.test(parts[i] ?? "")) i++;
|
|
24
|
+
while (/^[\da-wyz]$/i.test(parts[i] ?? "")) {
|
|
25
|
+
i++;
|
|
26
|
+
const start = i;
|
|
27
|
+
while (i < parts.length && parts[i].length >= 2) i++;
|
|
28
|
+
if (i === start) return false;
|
|
29
|
+
}
|
|
30
|
+
if (/^x$/i.test(parts[i] ?? "")) return i + 1 < parts.length;
|
|
31
|
+
return i === parts.length;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/locale-capability.ts
|
|
35
|
+
const collationShape = shape.map({
|
|
36
|
+
sensitivity: {
|
|
37
|
+
optional: true,
|
|
38
|
+
shape: shape.text
|
|
39
|
+
},
|
|
40
|
+
numeric: {
|
|
41
|
+
optional: true,
|
|
42
|
+
shape: shape.bool
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const nameShape = shape.map({
|
|
46
|
+
width: {
|
|
47
|
+
optional: true,
|
|
48
|
+
shape: shape.text
|
|
49
|
+
},
|
|
50
|
+
form: {
|
|
51
|
+
optional: true,
|
|
52
|
+
shape: shape.text
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const textList = shape.listOf(shape.text);
|
|
56
|
+
const symbolsShape = shape.map({
|
|
57
|
+
decimal: shape.text,
|
|
58
|
+
group: shape.text,
|
|
59
|
+
minus: shape.text,
|
|
60
|
+
digits: textList,
|
|
61
|
+
primaryGroup: shape.number,
|
|
62
|
+
secondaryGroup: shape.number,
|
|
63
|
+
minGrouping: shape.number
|
|
64
|
+
});
|
|
65
|
+
const collationDefaults = map([["sensitivity", text("variant")], ["numeric", bool(false)]]);
|
|
66
|
+
const nameDefaults = map([["width", text("long")], ["form", text("format")]]);
|
|
67
|
+
const words = {
|
|
68
|
+
sensitivity: [
|
|
69
|
+
"base",
|
|
70
|
+
"accent",
|
|
71
|
+
"case",
|
|
72
|
+
"variant"
|
|
73
|
+
],
|
|
74
|
+
width: [
|
|
75
|
+
"long",
|
|
76
|
+
"short",
|
|
77
|
+
"narrow"
|
|
78
|
+
],
|
|
79
|
+
form: ["format", "standalone"]
|
|
80
|
+
};
|
|
81
|
+
const domainError = (name, value) => {
|
|
82
|
+
throw new ScriptError("out of domain", [["function", text(name)], ["value", value]], true);
|
|
83
|
+
};
|
|
84
|
+
const optionalParts = (args, required, options) => {
|
|
85
|
+
const first = args[required];
|
|
86
|
+
return {
|
|
87
|
+
options: options && first?.kind === "map" ? first : void 0,
|
|
88
|
+
tag: options && first?.kind !== "text" ? args[required + 1]?.asText() : first?.asText()
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const checkArguments = (name, required, options, args, binding) => {
|
|
92
|
+
if (options && args.length > required + 1 && args[required]?.kind === "text") domainError(name, args[required]);
|
|
93
|
+
const parts = optionalParts(args, required, options);
|
|
94
|
+
for (const [key, value] of parts.options?.entries() ?? []) if (words[key] && !words[key].includes(value.asText())) domainError(name, value);
|
|
95
|
+
const tag = parts.tag ?? binding;
|
|
96
|
+
if (typeof tag !== "string") throw new HostError("invalid value", "Locale binding must be a tag");
|
|
97
|
+
if (!wellFormedLocale(tag)) throw new ScriptError("bad locale", [["locale", text(tag)]], true);
|
|
98
|
+
};
|
|
99
|
+
const withDefaults = (given, defaults) => map(defaults.entries().map(([key, value]) => [key, given && given.get(key).kind !== "nothing" ? given.get(key) : value]));
|
|
100
|
+
const integer = (value) => {
|
|
101
|
+
const n = value.kind === "number" ? decimalParts(value.asDecimal()) : void 0;
|
|
102
|
+
return n && isInteger(n) ? integerOf(n) : void 0;
|
|
103
|
+
};
|
|
104
|
+
const validRank = (value, args) => {
|
|
105
|
+
const texts = args[0];
|
|
106
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
107
|
+
for (let i = 1; i <= texts.length; i++) wanted.add(texts.index(i).asText());
|
|
108
|
+
const entries = value.entries();
|
|
109
|
+
if (entries.length !== wanted.size) return false;
|
|
110
|
+
const ranks = /* @__PURE__ */ new Set();
|
|
111
|
+
for (const [key, rank] of entries) {
|
|
112
|
+
const n = integer(rank);
|
|
113
|
+
if (!wanted.has(key) || n === void 0 || n < 1n || n > BigInt(entries.length)) return false;
|
|
114
|
+
ranks.add(n);
|
|
115
|
+
}
|
|
116
|
+
for (let i = 1; i <= ranks.size; i++) if (!ranks.has(BigInt(i))) return false;
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
const validSymbols = (value) => {
|
|
120
|
+
for (const key of [
|
|
121
|
+
"decimal",
|
|
122
|
+
"group",
|
|
123
|
+
"minus"
|
|
124
|
+
]) if (!value.get(key).asText()) return false;
|
|
125
|
+
const digits = value.get("digits");
|
|
126
|
+
if (digits.length !== 10) return false;
|
|
127
|
+
for (let i = 1; i <= 10; i++) if (!digits.index(i).asText()) return false;
|
|
128
|
+
return [
|
|
129
|
+
"primaryGroup",
|
|
130
|
+
"secondaryGroup",
|
|
131
|
+
"minGrouping"
|
|
132
|
+
].every((key) => (integer(value.get(key)) ?? 0n) >= 1n);
|
|
133
|
+
};
|
|
134
|
+
/** The Host resolves tags and provides every Operation for each Locale. */
|
|
135
|
+
const localeCapability = (impl, costs) => {
|
|
136
|
+
for (const name of [
|
|
137
|
+
"compare",
|
|
138
|
+
"rank",
|
|
139
|
+
"upper",
|
|
140
|
+
"lower",
|
|
141
|
+
"numberSymbols",
|
|
142
|
+
"monthNames",
|
|
143
|
+
"dayNames",
|
|
144
|
+
"tag"
|
|
145
|
+
]) if (!impl || typeof impl[name] !== "function") throw new HostError("invalid value", `Locale needs ${name}`);
|
|
146
|
+
const operations = {};
|
|
147
|
+
const add = (name, args, result, doCall, options, resultCheck) => {
|
|
148
|
+
const required = args.length;
|
|
149
|
+
const optionShape = options === collationDefaults ? collationShape : nameShape;
|
|
150
|
+
const op = {
|
|
151
|
+
mode: "immediate",
|
|
152
|
+
args: [
|
|
153
|
+
...args,
|
|
154
|
+
...options ? [shape.optional(shape.oneOf(optionShape, shape.text))] : [],
|
|
155
|
+
shape.optional(shape.text)
|
|
156
|
+
],
|
|
157
|
+
result,
|
|
158
|
+
errors: [],
|
|
159
|
+
cost: costOf(costs, name),
|
|
160
|
+
do: (call, ...values) => {
|
|
161
|
+
const parts = optionalParts(values, required, !!options);
|
|
162
|
+
return doCall(call, values, options ? withDefaults(parts.options, options) : map([]), parts.tag);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
registerStandardChecks(op, {
|
|
166
|
+
arguments: (values, binding) => checkArguments(name, required, !!options, values, binding),
|
|
167
|
+
...resultCheck ? { result: resultCheck } : {}
|
|
168
|
+
});
|
|
169
|
+
operations[name] = op;
|
|
170
|
+
};
|
|
171
|
+
add("compare", [shape.text, shape.text], shape.number, (call, args, opts, tag) => impl.compare(call, args[0], args[1], opts, tag), collationDefaults, (value) => {
|
|
172
|
+
const n = integer(value);
|
|
173
|
+
return n !== void 0 && n >= -1n && n <= 1n;
|
|
174
|
+
});
|
|
175
|
+
add("rank", [textList], shape.openMap({}), (call, args, opts, tag) => impl.rank(call, args[0], opts, tag), collationDefaults, validRank);
|
|
176
|
+
add("upper", [shape.text], shape.text, (call, args, _opts, tag) => impl.upper(call, args[0], tag));
|
|
177
|
+
add("lower", [shape.text], shape.text, (call, args, _opts, tag) => impl.lower(call, args[0], tag));
|
|
178
|
+
add("numberSymbols", [], symbolsShape, (call, _args, _opts, tag) => impl.numberSymbols(call, tag), void 0, validSymbols);
|
|
179
|
+
add("monthNames", [], textList, (call, _args, opts, tag) => impl.monthNames(call, opts, tag), nameDefaults, (value) => value.length === 12);
|
|
180
|
+
add("dayNames", [], textList, (call, _args, opts, tag) => impl.dayNames(call, opts, tag), nameDefaults, (value) => value.length === 7);
|
|
181
|
+
add("tag", [], shape.text, (call, _args, _opts, tag) => impl.tag(call, tag), void 0, (value) => wellFormedLocale(value.asText()));
|
|
182
|
+
return fixed(defineValueCapability("locale", operations));
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/user-capability.ts
|
|
186
|
+
/** Every `confirm`, `choose` and `enter` waits as long as `console`'s `read`. */
|
|
187
|
+
const USER_MAX_PENDING_MS = 2147483647;
|
|
188
|
+
const optionalText = shape.optional(shape.text);
|
|
189
|
+
const options = (fields) => shape.optional(shape.map(Object.fromEntries(Object.entries(fields).map(([key, s]) => [key, {
|
|
190
|
+
optional: true,
|
|
191
|
+
shape: s
|
|
192
|
+
}]))));
|
|
193
|
+
const userBusy = [{
|
|
194
|
+
code: "user busy",
|
|
195
|
+
fields: {}
|
|
196
|
+
}];
|
|
197
|
+
const itemsOf = (list) => Array.from({ length: list.length }, (_, i) => list.index(i + 1));
|
|
198
|
+
const option = (options, key) => {
|
|
199
|
+
const value = options?.kind === "map" ? options.get(key) : void 0;
|
|
200
|
+
return value?.kind === "nothing" ? void 0 : value;
|
|
201
|
+
};
|
|
202
|
+
const optionText = (options, key) => option(options, key)?.asText() ?? "";
|
|
203
|
+
const multipleOf = (options) => option(options, "multiple")?.asBool() === true;
|
|
204
|
+
const chosen = (answer, args) => {
|
|
205
|
+
if (answer.kind === "nothing") return true;
|
|
206
|
+
const items = itemsOf(args[0]);
|
|
207
|
+
if (!multipleOf(args[1])) return answer.kind === "text" && items.some((item) => item.equals(answer));
|
|
208
|
+
if (answer.kind !== "list") return false;
|
|
209
|
+
let at = 0;
|
|
210
|
+
for (const item of itemsOf(answer)) {
|
|
211
|
+
while (at < items.length && !items[at].equals(item)) at += 1;
|
|
212
|
+
if (at === items.length) return false;
|
|
213
|
+
at += 1;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
};
|
|
217
|
+
/** Optional for Hosts. The binding is ignored. */
|
|
218
|
+
const userCapability = (impl, costs) => {
|
|
219
|
+
for (const name of [
|
|
220
|
+
"confirm",
|
|
221
|
+
"choose",
|
|
222
|
+
"enter",
|
|
223
|
+
"notify"
|
|
224
|
+
]) if (!impl || typeof impl[name] !== "function") throw new HostError("invalid value", `User needs ${name}`);
|
|
225
|
+
const operations = {
|
|
226
|
+
confirm: {
|
|
227
|
+
mode: "suspending",
|
|
228
|
+
args: [shape.text],
|
|
229
|
+
result: shape.bool,
|
|
230
|
+
errors: userBusy,
|
|
231
|
+
maxPendingMs: USER_MAX_PENDING_MS,
|
|
232
|
+
cost: costOf(costs, "confirm"),
|
|
233
|
+
start: (call, message) => impl.confirm(call, message.asText())
|
|
234
|
+
},
|
|
235
|
+
choose: {
|
|
236
|
+
mode: "suspending",
|
|
237
|
+
args: [shape.listOf(shape.text), options({
|
|
238
|
+
prompt: optionalText,
|
|
239
|
+
multiple: shape.optional(shape.bool)
|
|
240
|
+
})],
|
|
241
|
+
result: shape.optional(shape.oneOf(shape.text, shape.listOf(shape.text))),
|
|
242
|
+
errors: userBusy,
|
|
243
|
+
maxPendingMs: USER_MAX_PENDING_MS,
|
|
244
|
+
cost: costOf(costs, "choose"),
|
|
245
|
+
start: (call, items, options) => impl.choose(call, itemsOf(items).map((item) => item.asText()), optionText(options, "prompt"), multipleOf(options))
|
|
246
|
+
},
|
|
247
|
+
enter: {
|
|
248
|
+
mode: "suspending",
|
|
249
|
+
args: [shape.text, options({ default: optionalText })],
|
|
250
|
+
result: optionalText,
|
|
251
|
+
errors: userBusy,
|
|
252
|
+
maxPendingMs: USER_MAX_PENDING_MS,
|
|
253
|
+
cost: costOf(costs, "enter"),
|
|
254
|
+
start: (call, message, options) => impl.enter(call, message.asText(), optionText(options, "default"))
|
|
255
|
+
},
|
|
256
|
+
notify: {
|
|
257
|
+
mode: "fire-and-forget",
|
|
258
|
+
args: [shape.text, options({ title: optionalText })],
|
|
259
|
+
errors: [],
|
|
260
|
+
cost: costOf(costs, "notify"),
|
|
261
|
+
fire: (call, message, options) => impl.notify(call, message.asText(), optionText(options, "title"))
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
for (const [name, op] of Object.entries(operations)) registerStandardChecks(op, {
|
|
265
|
+
error: (code) => code === "user busy" && name !== "notify",
|
|
266
|
+
...name === "choose" ? {
|
|
267
|
+
arguments: (args) => {
|
|
268
|
+
if (args[0].length === 0) throw new ScriptError("out of domain", [["function", text("choose")], ["value", args[0]]], true);
|
|
269
|
+
},
|
|
270
|
+
result: chosen
|
|
271
|
+
} : {}
|
|
272
|
+
});
|
|
273
|
+
return fixed(defineValueCapability("user", operations));
|
|
274
|
+
};
|
|
275
|
+
//#endregion
|
|
276
|
+
export { localeCapability as n, userCapability as t };
|
package/wasm.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
|
|
2
|
+
import { An as Outcome, At as ImmediateOp, B as CausalWork, Bt as SegmentCoordinator, C as Requested, Cn as LibrarySource, Ct as Cost, Dt as FireOp, Et as FieldShape, Ft as PlainResult, G as Decimal, Gn as LoadError, Gt as defineCapability, H as RunAncestry, Hn as HostError, Ht as SegmentLifecycle, It as ReleaseHook, J as bool, Jn as SendFailedReason, Jt as Group, K as Kind, Kn as MailboxFull, Kt as shape, L as Verdict, Lt as ReleaseReason, M as Settlement, Mt as Operation, Nt as Operations, On as LimitName, Ot as Grant, Pt as PlainArg, Q as instant, Qt as HttpImpl, Rt as ScopeDecl, S as Report, St as CoordinatedLifecycle, T as RestoreResult, Tt as ErrorDecl, U as RunDiscarded, Un as HostErrorCode, Ut as Shape, V as RunAccounting, Vt as SegmentGrant, W as RunStarted, Wn as LoadDiagnostic, Wt as SuspendingOp, X as civilDate, Xt as Versions, Y as bytes, Yt as Script, Z as dec, _ as Message, an as SqlParams, at as range, b as PumpResult, bt as CapabilityDef, c as CancellationOptions, cn as SqliteBinding, ct as text, d as Decided, dn as LocaleImpl, dt as parseInstant, en as UserImpl, et as list, f as Deciding, ft as HostObject, g as LoadOptions, gn as TimerImpl, gt as PropDef, h as Inspection, hn as Costs, ht as ObjectKindDef, it as quantity, jt as LimitReached, kn as Limits, kt as GrantContext, l as CarryOver, ln as SqliteImpl, lt as formatInstant, m as GroupOptions, mn as ConsoleImpl, mt as ObjectKind, nn as StoreImpl, nt as nothing, on as SqlRows, ot as record, p as EffectFailure, pn as CalendarImpl, pt as ObjectElements, q as Value, qn as ScriptError, qt as Core, rn as add, rt as num, sn as SqlValue, tt as map, u as Counters, ut as nowMicros, v as PendingCall, vt as GrantDecls, w as RestoreOptions, wn as OperationRef, wt as EffectResult, x as PumpedRequest, xn as Library, xt as CapabilityDefiner, y as PumpOptions, yt as Call, zt as SegmentContext } from "./debug-CQBxKnJB.js";
|
|
3
|
+
import { a as encodeJson, c as PlainValue, d as toValue, f as talk, i as decodeJson, l as ToValueOptions, n as MessageDecl, o as encodeValue, r as exportManifest, s as FromValueOptions, t as ManifestSpec, u as fromValue } from "./manifest-BscyH_rW.js";
|
|
4
|
+
import { a as decodeValue, n as Json, o as readDisplay } from "./readers-BFPuosPk.js";
|
|
5
|
+
import { t as BinaryValueOptions } from "./binary-value-CEmh60GC.js";
|
|
6
|
+
//#region src/wasm/reactor.d.ts
|
|
7
|
+
/** Text the reactor writes to stdout or stderr, such as a fatal error. */
|
|
8
|
+
type Diagnostics = (line: string) => void;
|
|
9
|
+
/** Thrown when the instance traps or replies with something unreadable: it is lost. */
|
|
10
|
+
export declare class InstanceLostError extends Error {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
declare class Reactor {
|
|
14
|
+
#private;
|
|
15
|
+
/** Synchronous: the module is compiled once, by createCore. */
|
|
16
|
+
constructor(module: WebAssembly.Module, diagnostics: Diagnostics);
|
|
17
|
+
/** One JSON frame, retained for Hosts speaking only JSON. */
|
|
18
|
+
frame(json: string): string;
|
|
19
|
+
/** One mixed-transport frame; copy the reply before another export can run. */
|
|
20
|
+
frameBytes(bytes: Uint8Array): ArrayBuffer;
|
|
21
|
+
/** The instance's linear memory, in bytes. */
|
|
22
|
+
memoryBytes(): number;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/wasm/wire.d.ts
|
|
26
|
+
declare const raw: unique symbol;
|
|
27
|
+
/** Text already in JSON, such as a Value Encoding, placed in a frame as is. */
|
|
28
|
+
declare class Raw {
|
|
29
|
+
private source;
|
|
30
|
+
readonly value?: Value | undefined;
|
|
31
|
+
readonly [raw] = true;
|
|
32
|
+
/** `value`, when given, is the Value `json` encodes. */
|
|
33
|
+
constructor(source: string | (() => string), value?: Value | undefined);
|
|
34
|
+
/** Binary frames use `value` directly; only JSON frames need its encoding. */
|
|
35
|
+
get json(): string;
|
|
36
|
+
}
|
|
37
|
+
type Frame = null | boolean | number | string | Raw | readonly Frame[] | {
|
|
38
|
+
readonly [key: string]: Frame | undefined;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/wasm/session.d.ts
|
|
42
|
+
/** Answers one interim need with its `…-result` fields. */
|
|
43
|
+
type NeedHandler = (need: Json, packet: Json) => Record<string, Frame>;
|
|
44
|
+
/** Sees every reply of an exchange, interim ones included. */
|
|
45
|
+
type Observer = (packet: Json, m: string) => void;
|
|
46
|
+
/** The Core's names for its definitions, shared by every guest it makes. */
|
|
47
|
+
type Registry = {
|
|
48
|
+
handleOf(def: CapabilityDef<unknown>): string;
|
|
49
|
+
readonly kinds: readonly ObjectKind[];
|
|
50
|
+
};
|
|
51
|
+
declare class Session {
|
|
52
|
+
#private;
|
|
53
|
+
private readonly registry;
|
|
54
|
+
readonly reactor: Reactor;
|
|
55
|
+
readonly versions: Versions;
|
|
56
|
+
/** Whether the guest accepts Object Collection declarations. */
|
|
57
|
+
readonly elements: boolean;
|
|
58
|
+
readonly requestPump: boolean;
|
|
59
|
+
readonly callbacks: boolean;
|
|
60
|
+
nextToken(): Raw;
|
|
61
|
+
constructor(module: WebAssembly.Module, diagnostics: Diagnostics, registry: Registry, binaryCallbacks?: boolean);
|
|
62
|
+
/**
|
|
63
|
+
* One complete exchange: the message, then every need answered under its
|
|
64
|
+
* ref, until the final reply. Returns its `ok`, or throws its `err`.
|
|
65
|
+
* A callback may start other exchanges meanwhile, under their own refs.
|
|
66
|
+
*/
|
|
67
|
+
exchange(m: string, fields: Record<string, Frame | undefined>, answer?: NeedHandler, observe?: Observer): Json;
|
|
68
|
+
/** Resolves binary callback Values as the Group that owns this guest does. */
|
|
69
|
+
bind(values: BinaryValueOptions): void;
|
|
70
|
+
/** The guest's handle for a Capability, declared on first use. */
|
|
71
|
+
define(def: CapabilityDef<unknown>): string;
|
|
72
|
+
/** The guest's handle for a Grant, made on first use. */
|
|
73
|
+
grant(grant: Grant<unknown>): number;
|
|
74
|
+
/** A declared Capability's name, from the handle the guest reports. */
|
|
75
|
+
capabilityName(handle: string): string | undefined;
|
|
76
|
+
/** The coordinator a Grant's effect need names, by the name given it here. */
|
|
77
|
+
coordinator(name: string): SegmentCoordinator | undefined;
|
|
78
|
+
/** Declares every Object Kind the Core knows that this guest doesn't yet. */
|
|
79
|
+
syncKinds(): void;
|
|
80
|
+
/** Whether this guest has compiled a Library, by its identity. */
|
|
81
|
+
hasLibrary(identity: string): boolean;
|
|
82
|
+
addedLibrary(identity: string): void;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/wasm/group.d.ts
|
|
86
|
+
/** What a Group needs of the Core that made it. */
|
|
87
|
+
type GroupCore = {
|
|
88
|
+
/** Compiles a Library and its imports into a guest, once each. */
|
|
89
|
+
install(session: Session, library: Library): void;
|
|
90
|
+
kind(name: string): ObjectKind | undefined;
|
|
91
|
+
/** A guest with every definition the Core knows available to declare. */
|
|
92
|
+
session(): Session;
|
|
93
|
+
};
|
|
94
|
+
type GroupOptions$1 = {
|
|
95
|
+
name: string;
|
|
96
|
+
onReady?(): void;
|
|
97
|
+
/** The `random` generator's seed, 0 to 2⁶⁴ − 1; 0 when omitted. */
|
|
98
|
+
seed?: bigint;
|
|
99
|
+
trace?: (line: string) => void;
|
|
100
|
+
};
|
|
101
|
+
/** A handle for calls addressed to one Script. */
|
|
102
|
+
export declare class WasmScript implements Script {
|
|
103
|
+
private readonly group;
|
|
104
|
+
readonly name: string;
|
|
105
|
+
constructor(group: WasmGroup, name: string);
|
|
106
|
+
grants(): Record<string, string[]>;
|
|
107
|
+
counters(): Counters;
|
|
108
|
+
deliver(m: Message): string;
|
|
109
|
+
request(m: Message, o?: CancellationOptions): Requested;
|
|
110
|
+
requestPump(m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
111
|
+
/** Queued. A Request for the answer only; use `request` for its id or a signal. */
|
|
112
|
+
invoke(name: string, ...args: Value[]): Promise<Value>;
|
|
113
|
+
decide(m: Message, o?: CancellationOptions): Deciding;
|
|
114
|
+
reload(source: string, carry: CarryOver, o?: {
|
|
115
|
+
keepMailbox?: boolean;
|
|
116
|
+
}): Report[];
|
|
117
|
+
extend(source: string): void;
|
|
118
|
+
stop(reason: string): void;
|
|
119
|
+
cancelRun(runId: string): void;
|
|
120
|
+
rewindRun(runId: string): void;
|
|
121
|
+
revoke(grantName: string): void;
|
|
122
|
+
}
|
|
123
|
+
export declare class WasmGroup implements Group {
|
|
124
|
+
#private;
|
|
125
|
+
readonly name: string;
|
|
126
|
+
/** @internal Made by WasmCore. */
|
|
127
|
+
constructor(core: GroupCore, o: GroupOptions$1, restoring?: {
|
|
128
|
+
options: RestoreOptions;
|
|
129
|
+
save: Uint8Array;
|
|
130
|
+
});
|
|
131
|
+
/** @internal One exchange for this Group, its needs answered here. */
|
|
132
|
+
send(m: string, fields?: Record<string, Frame | undefined>, receive?: (packet: Json) => void): Json;
|
|
133
|
+
/**
|
|
134
|
+
* A worker call. Made from a callback, the guest refuses it as
|
|
135
|
+
* `reentrant call`, with its refusal record, as the in-process Core does.
|
|
136
|
+
*/
|
|
137
|
+
worker(m: string, fields?: Record<string, Frame | undefined>): Json;
|
|
138
|
+
/** @internal Message data shared with the Script combined operation. */
|
|
139
|
+
messageFrame(m: Message): Frame;
|
|
140
|
+
/** @internal */
|
|
141
|
+
queue(m: string, fields: Record<string, Frame | undefined>, message?: Message): string;
|
|
142
|
+
/** @internal */
|
|
143
|
+
ask(to: Record<string, Frame>, m: Message, o?: CancellationOptions): Requested;
|
|
144
|
+
/** @internal */
|
|
145
|
+
decision(fields: Record<string, Frame>, m: Message, o?: CancellationOptions): Deciding;
|
|
146
|
+
/** @internal Queued controls, which make the Group runnable. */
|
|
147
|
+
control(m: string, fields: Record<string, Frame | undefined>): void;
|
|
148
|
+
script(name: string): WasmScript | undefined;
|
|
149
|
+
scriptNames(): string[];
|
|
150
|
+
load(o: LoadOptions): WasmScript;
|
|
151
|
+
addLibrary(l: Library): void;
|
|
152
|
+
replaceLibrary(l: Library, carry: CarryOver): Report[];
|
|
153
|
+
/** @internal Reload and Library replacement end Runs and settle their futures. */
|
|
154
|
+
lifecycle(m: string, fields: Record<string, Frame | undefined>): Report[];
|
|
155
|
+
object<N>(kind: ObjectKind<N>, id: string, native: N): HostObject<N>;
|
|
156
|
+
objectById(kind: string, id: string): HostObject | undefined;
|
|
157
|
+
setParent(o: HostObject, parent: HostObject | undefined): void;
|
|
158
|
+
dispose(o: HostObject): void;
|
|
159
|
+
deliver(to: HostObject, m: Message): string;
|
|
160
|
+
request(to: HostObject, m: Message, o?: CancellationOptions): Requested;
|
|
161
|
+
requestPump(to: HostObject, m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
162
|
+
callPump(fn: Value, args: Value[], now: bigint, o?: PumpOptions & CancellationOptions & {
|
|
163
|
+
limits?: Message['limits'];
|
|
164
|
+
}): PumpedRequest;
|
|
165
|
+
/** @internal Shared by Script and Object targets. No fallback on old guests. */
|
|
166
|
+
combined(m: string, fields: () => Record<string, Frame | undefined>, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
167
|
+
broadcast(m: Message): string;
|
|
168
|
+
decide(to: HostObject, m: Message, o?: CancellationOptions): Deciding;
|
|
169
|
+
decideBroadcast(m: Message, o?: CancellationOptions): Deciding;
|
|
170
|
+
call(fn: Value, args: Value[], o?: CancellationOptions & {
|
|
171
|
+
limits?: Message['limits'];
|
|
172
|
+
}): Requested;
|
|
173
|
+
pump(now: bigint, o?: PumpOptions): PumpResult;
|
|
174
|
+
save(): Uint8Array;
|
|
175
|
+
fingerprint(): Uint8Array;
|
|
176
|
+
inspect(): Inspection;
|
|
177
|
+
settle(callId: string, s: Settlement): Call<unknown> | undefined;
|
|
178
|
+
/** @internal */
|
|
179
|
+
restore(save: Uint8Array, o: RestoreOptions): RestoreResult;
|
|
180
|
+
/** This Group's guest linear memory, in bytes. */
|
|
181
|
+
memoryBytes(): number;
|
|
182
|
+
/** @internal Rebinds a restored handle's native, as the TS Core does. */
|
|
183
|
+
rebind(o: HostObject, native: unknown): void;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/wasm/core.d.ts
|
|
187
|
+
/** Where `talk.wasm` comes from. A URL or path is fetched; `file:` URLs are read. */
|
|
188
|
+
type WasmSource = WebAssembly.Module | BufferSource | Response | PromiseLike<Response> | URL | string;
|
|
189
|
+
type CoreOptions = {
|
|
190
|
+
/** Request binary callbacks when offered. False keeps JSON for compatibility checks. */
|
|
191
|
+
binaryCallbacks?: boolean;
|
|
192
|
+
/** Lines the reactor writes to stdout or stderr. Defaults to console.warn. */
|
|
193
|
+
diagnostics?: (line: string) => void;
|
|
194
|
+
/** The reactor. Defaults to `talk.wasm` beside this module. */
|
|
195
|
+
wasm?: WasmSource;
|
|
196
|
+
};
|
|
197
|
+
export declare class WasmCore implements Core {
|
|
198
|
+
#private;
|
|
199
|
+
private readonly binaryCallbacks;
|
|
200
|
+
/** The reactor's `hello`: its Core, language, Cost Model, Unicode and save format. */
|
|
201
|
+
readonly versions: Versions;
|
|
202
|
+
/** @internal Use createCore. */
|
|
203
|
+
constructor(module: WebAssembly.Module, diagnostics: (line: string) => void, binaryCallbacks?: boolean);
|
|
204
|
+
defineCapability: typeof defineCapability;
|
|
205
|
+
clockCapability: (costs: Costs) => CapabilityDef<void>;
|
|
206
|
+
calendarCapability: (impl: CalendarImpl, costs: Costs) => CapabilityDef<string>;
|
|
207
|
+
localeCapability: (impl: LocaleImpl, costs: Costs) => CapabilityDef<string>;
|
|
208
|
+
timerCapability: (impl: TimerImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
209
|
+
consoleCapability: (impl: ConsoleImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
210
|
+
storeCapability: (impl: StoreImpl, costs: Costs) => CapabilityDef<string>;
|
|
211
|
+
sqliteCapability: (impl: SqliteImpl, costs: Costs, perRow: number) => CapabilityDef<SqliteBinding>;
|
|
212
|
+
userCapability: (impl: UserImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
213
|
+
httpCapability: (impl: HttpImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
214
|
+
defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
|
|
215
|
+
/** Checked in a guest the Core keeps; each Group's guest compiles it again when added. */
|
|
216
|
+
compileLibrary(src: LibrarySource, imports?: Library[], declarations?: GrantDecls): Library;
|
|
217
|
+
newGroup(o: GroupOptions): WasmGroup;
|
|
218
|
+
restore(save: Uint8Array, o: RestoreOptions): {
|
|
219
|
+
group: WasmGroup;
|
|
220
|
+
result: RestoreResult;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Compiles `talk.wasm` once and returns a Core over it. The one asynchronous
|
|
225
|
+
* call: `await createCore()` also works with the TS Core's synchronous one.
|
|
226
|
+
*/
|
|
227
|
+
export declare const createCore: (o?: CoreOptions) => Promise<WasmCore>;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/wasm/index.d.ts
|
|
230
|
+
/** Chapter 9's default Limits, which the reactor shares. */
|
|
231
|
+
export declare const defaultLimits: Readonly<{
|
|
232
|
+
fuelPerRun: number;
|
|
233
|
+
allocPerRun: number;
|
|
234
|
+
persistentState: number;
|
|
235
|
+
callDepth: number;
|
|
236
|
+
patternSize: number;
|
|
237
|
+
mailboxDepth: number;
|
|
238
|
+
maxWaitMs: number;
|
|
239
|
+
maxJoin: number;
|
|
240
|
+
cleanupBudget: number;
|
|
241
|
+
}>;
|
|
242
|
+
//#endregion
|
|
243
|
+
export { type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ConsoleImpl, type CoordinatedLifecycle, type Core, type CoreOptions, type Cost, type Costs, type Counters, type Decided, type Deciding, Decimal, type EffectFailure, type EffectResult, type ErrorDecl, type FieldShape, type FireOp, type FromValueOptions, type Grant, type GrantContext, type GrantDecls, type Group, type GroupOptions, HostError, type HostErrorCode, type HostObject, type HttpImpl, type ImmediateOp, 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 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 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, dec, decodeJson, decodeValue, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
|