@northtalk/ts 0.1.0 → 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/README.md +9 -5
- package/{encoding-DWlbPq-e.js → base64-DORMd3Hv.js} +197 -1368
- 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-D8Z_u244.d.ts → debug-CQBxKnJB.d.ts} +1147 -780
- package/debug.d.ts +2 -1
- package/debug.js +2 -1
- package/driver.d.ts +16 -2
- package/driver.js +98 -20
- package/encoding-nlrpj-Pb.js +99 -0
- package/{engine-CgCMdGGd.js → engine-BGaJ9dAk.js} +7 -5
- package/{engine-BPFnHT9N.d.ts → engine-vbYInVYF.d.ts} +3 -3
- package/{errors-DHwz1Vho.js → errors-LYJZ_c8h.js} +91 -17
- package/{group-B4eyJKTA.js → group-B742gg4T.js} +1490 -7278
- package/{sqlite-capability-CrCej3Po.js → http-capability-CSTkw1Yt.js} +255 -5
- package/http.d.ts +59 -0
- package/http.js +465 -0
- package/index.d.ts +23 -17
- package/index.js +19 -12
- package/manifest-BscyH_rW.d.ts +70 -0
- package/{manifest-DKe2Je6Z.js → manifest-DjsxDSuB.js} +11 -90
- package/message-layer.d.ts +12 -0
- package/message-layer.js +4 -0
- package/notify.d.ts +2 -1
- package/notify.js +2 -1
- package/{objects-MeXIDDFo.d.ts → objects-DJ3QtCCs.d.ts} +23 -8
- package/objects-Db7IB5vQ.js +91 -0
- package/operation-promises-EgZXG5N_.js +23 -0
- package/package.json +9 -1
- package/readers-BFPuosPk.d.ts +25 -0
- package/{readers-DyjxJEkL.js → readers-CjJHKHvH.js} +6 -3
- package/request-pump-binary-DdY3X-yl.js +2246 -0
- package/{router-DHPJNvbt.js → router--71qvxtY.js} +8 -6
- package/{router-DpDpAJjz.d.ts → router-Zhrw5l__.d.ts} +6 -5
- package/session.d.ts +2 -1
- package/session.js +58 -24
- package/setup.d.ts +2 -1
- package/setup.js +8 -4
- package/{sha256-0jiTgVJu.js → sha256-B_kyYw3Z.js} +1 -0
- package/sqlite.d.ts +3 -4
- package/sqlite.js +6 -5
- package/{store-capability-CDoVafZL.js → store-capability-OZp4hXmj.js} +10 -7
- package/{store-DrYjcoru.js → store-hJrRULMx.js} +3 -2
- package/store.d.ts +3 -2
- package/store.js +3 -2
- package/{user-capability-Cv0oJhhv.js → user-capability-BK4Asg7D.js} +8 -5
- package/wasm.d.ts +42 -22
- package/wasm.js +330 -46
- package/core-eU5KaYkz.d.ts +0 -23
- package/readers-Oh4tO2dK.d.ts +0 -57
- package/sqlite-capability-C7-SYdD7.d.ts +0 -87
- package/user-capability-CLkDsrCX.d.ts +0 -40
|
@@ -1,1194 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const stack = [root];
|
|
5
|
-
let value;
|
|
6
|
-
let throwing = false;
|
|
7
|
-
while (stack.length) {
|
|
8
|
-
const task = stack.at(-1);
|
|
9
|
-
try {
|
|
10
|
-
const step = throwing ? task.throw(value) : task.next(value);
|
|
11
|
-
throwing = false;
|
|
12
|
-
if (step.done) {
|
|
13
|
-
stack.pop();
|
|
14
|
-
value = step.value;
|
|
15
|
-
} else {
|
|
16
|
-
stack.push(step.value);
|
|
17
|
-
value = void 0;
|
|
18
|
-
}
|
|
19
|
-
} catch (error) {
|
|
20
|
-
stack.pop();
|
|
21
|
-
value = error;
|
|
22
|
-
throwing = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (throwing) throw value;
|
|
26
|
-
return value;
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/lexer.ts
|
|
30
|
-
const RESERVED = new Set(grammar.reserved);
|
|
31
|
-
const UNIT_SHAPE = /^(?:1\/)?[A-Za-z]+(?:\^[+-]?\d*)?(?:[*/][A-Za-z]+(?:\^[+-]?\d*)?)*(?!\w)/;
|
|
32
|
-
const NAME = /^[A-Z_a-z]\w*/;
|
|
33
|
-
const NUMBER = /^(?:0x[\dA-Fa-f]+|\d+(?:\.\d+)?)/;
|
|
34
|
-
const OPS = [
|
|
35
|
-
"...",
|
|
36
|
-
"..",
|
|
37
|
-
"&",
|
|
38
|
-
"=",
|
|
39
|
-
"+",
|
|
40
|
-
"-",
|
|
41
|
-
"*",
|
|
42
|
-
"/",
|
|
43
|
-
"^",
|
|
44
|
-
"(",
|
|
45
|
-
")",
|
|
46
|
-
"[",
|
|
47
|
-
"]",
|
|
48
|
-
"{",
|
|
49
|
-
"}",
|
|
50
|
-
",",
|
|
51
|
-
":"
|
|
52
|
-
];
|
|
53
|
-
const unitProblem = (text) => {
|
|
54
|
-
try {
|
|
55
|
-
parseUnit(text);
|
|
56
|
-
return null;
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (error instanceof UnitError) return error.message;
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var Lexer = class {
|
|
63
|
-
src;
|
|
64
|
-
fences = /* @__PURE__ */ new Map();
|
|
65
|
-
lineStarts = [0];
|
|
66
|
-
surrogateOffsets = [];
|
|
67
|
-
constructor(src) {
|
|
68
|
-
this.src = src;
|
|
69
|
-
assertScalarText(src);
|
|
70
|
-
for (let i = 0; i < src.length; i++) {
|
|
71
|
-
const code = src.charCodeAt(i);
|
|
72
|
-
if (code >= 56320 && code <= 57343) this.surrogateOffsets.push(i);
|
|
73
|
-
if (src[i] === "\n" || src[i] === "\r" && src[i + 1] !== "\n") this.lineStarts.push(i + 1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
where(pos) {
|
|
77
|
-
let lo = 0;
|
|
78
|
-
let hi = this.lineStarts.length - 1;
|
|
79
|
-
while (lo < hi) {
|
|
80
|
-
const mid = lo + hi + 1 >> 1;
|
|
81
|
-
if (this.lineStarts[mid] <= pos) lo = mid;
|
|
82
|
-
else hi = mid - 1;
|
|
83
|
-
}
|
|
84
|
-
const start = this.lineStarts[lo];
|
|
85
|
-
const col = pos - start + 1 - (this.surrogatesBefore(pos) - this.surrogatesBefore(start));
|
|
86
|
-
return {
|
|
87
|
-
line: lo + 1,
|
|
88
|
-
col
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
surrogatesBefore(pos) {
|
|
92
|
-
let lo = 0;
|
|
93
|
-
let hi = this.surrogateOffsets.length;
|
|
94
|
-
while (lo < hi) {
|
|
95
|
-
const mid = lo + hi >>> 1;
|
|
96
|
-
if (this.surrogateOffsets[mid] < pos) lo = mid + 1;
|
|
97
|
-
else hi = mid;
|
|
98
|
-
}
|
|
99
|
-
return lo;
|
|
100
|
-
}
|
|
101
|
-
tok(t, v, pos, end, spaceBefore, mode, code) {
|
|
102
|
-
return {
|
|
103
|
-
kind: "token",
|
|
104
|
-
raw: this.src.slice(pos, end),
|
|
105
|
-
leadingTrivia: [],
|
|
106
|
-
t,
|
|
107
|
-
v,
|
|
108
|
-
code,
|
|
109
|
-
pos,
|
|
110
|
-
end,
|
|
111
|
-
...this.where(pos),
|
|
112
|
-
spaceBefore,
|
|
113
|
-
mode
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
trivia(start) {
|
|
117
|
-
const s = this.src;
|
|
118
|
-
let pos = start;
|
|
119
|
-
const trivia = [];
|
|
120
|
-
const add = (kind, from) => {
|
|
121
|
-
trivia.push({
|
|
122
|
-
kind,
|
|
123
|
-
pos: from,
|
|
124
|
-
end: pos,
|
|
125
|
-
raw: s.slice(from, pos),
|
|
126
|
-
...this.where(from)
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
if (pos === 0 && s.charCodeAt(0) === 65279) {
|
|
130
|
-
pos++;
|
|
131
|
-
add("bom", 0);
|
|
132
|
-
}
|
|
133
|
-
for (;;) {
|
|
134
|
-
const from = pos;
|
|
135
|
-
if (s[pos] === " " || s[pos] === " ") {
|
|
136
|
-
do
|
|
137
|
-
pos++;
|
|
138
|
-
while (s[pos] === " " || s[pos] === " ");
|
|
139
|
-
add("space", from);
|
|
140
|
-
} else if (s[pos] === "-" && s[pos + 1] === "-") {
|
|
141
|
-
while (pos < s.length && s[pos] !== "\n" && s[pos] !== "\r") pos++;
|
|
142
|
-
add("comment", from);
|
|
143
|
-
} else return {
|
|
144
|
-
pos,
|
|
145
|
-
trivia
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
*fenced(open, space, mode) {
|
|
150
|
-
const cached = this.fences.get(open);
|
|
151
|
-
if (cached) return {
|
|
152
|
-
...cached,
|
|
153
|
-
spaceBefore: space,
|
|
154
|
-
mode
|
|
155
|
-
};
|
|
156
|
-
const token = yield this.scanFenced(open, space, mode);
|
|
157
|
-
this.fences.set(open, token);
|
|
158
|
-
return token;
|
|
159
|
-
}
|
|
160
|
-
*scanFenced(open, space, mode) {
|
|
161
|
-
const s = this.src;
|
|
162
|
-
const raw = s[open] === "\"";
|
|
163
|
-
let width = 1;
|
|
164
|
-
if (raw) while (s[open + width] === "\"") width++;
|
|
165
|
-
const begin = open + width;
|
|
166
|
-
const block = s[begin] === "\r" || s[begin] === "\n";
|
|
167
|
-
const parts = [];
|
|
168
|
-
let start = begin;
|
|
169
|
-
let i = begin;
|
|
170
|
-
const error = (code, at, incomplete = false) => ({
|
|
171
|
-
...this.tok("error", code, at, Math.min(s.length, at + 1), space, mode, code),
|
|
172
|
-
incomplete,
|
|
173
|
-
parts: incomplete ? [] : parts.filter((p) => p.hole && p.hole.end < at)
|
|
174
|
-
});
|
|
175
|
-
while (i < s.length) {
|
|
176
|
-
if (!raw && s[i] === "`" || raw && s[i] === "\"") {
|
|
177
|
-
let count = 1;
|
|
178
|
-
if (raw) while (s[i + count] === "\"") count++;
|
|
179
|
-
if (raw && count > width) return error("invalid text delimiter", i);
|
|
180
|
-
if (count === width) break;
|
|
181
|
-
i += count;
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (!raw && s[i] === "\\") {
|
|
185
|
-
i++;
|
|
186
|
-
if (s[i] === "\r" && s[i + 1] === "\n") i++;
|
|
187
|
-
i++;
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (!raw && s.startsWith("${", i)) {
|
|
191
|
-
const at = i;
|
|
192
|
-
let cursor = i + 2;
|
|
193
|
-
let depth = 0;
|
|
194
|
-
for (;;) {
|
|
195
|
-
const next = this.trivia(cursor).pos;
|
|
196
|
-
const t = s[next] === "`" || s.startsWith("\"\"\"", next) ? yield this.fenced(next, true, "operand") : this.lex(cursor, "operand");
|
|
197
|
-
if (t.t === "error") return {
|
|
198
|
-
...t,
|
|
199
|
-
parts: t.incomplete ? [] : [...parts.filter((p) => p.hole), ...t.parts ?? []]
|
|
200
|
-
};
|
|
201
|
-
if (t.t === "eof") return error("unterminated interpolation", at, true);
|
|
202
|
-
if (t.t === "op" && t.v === "}" && depth === 0) {
|
|
203
|
-
parts.push({
|
|
204
|
-
start,
|
|
205
|
-
end: at,
|
|
206
|
-
value: "",
|
|
207
|
-
hole: {
|
|
208
|
-
at,
|
|
209
|
-
start: at + 2,
|
|
210
|
-
end: t.pos
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
i = t.end;
|
|
214
|
-
start = i;
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
if (t.t === "op" && t.v === "{") depth++;
|
|
218
|
-
if (t.t === "op" && t.v === "}") depth--;
|
|
219
|
-
cursor = t.end;
|
|
220
|
-
}
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
i++;
|
|
224
|
-
}
|
|
225
|
-
if (i >= s.length) return error("unterminated text", open, true);
|
|
226
|
-
parts.push({
|
|
227
|
-
start,
|
|
228
|
-
end: i,
|
|
229
|
-
value: ""
|
|
230
|
-
});
|
|
231
|
-
let margin = "";
|
|
232
|
-
let closeLine = i;
|
|
233
|
-
if (block) {
|
|
234
|
-
while (closeLine > 0 && s[closeLine - 1] !== "\n" && s[closeLine - 1] !== "\r") closeLine--;
|
|
235
|
-
margin = s.slice(closeLine, i);
|
|
236
|
-
const mismatch = margin.search(/[^\t ]/);
|
|
237
|
-
if (mismatch >= 0) return error("invalid text indentation", closeLine + mismatch);
|
|
238
|
-
}
|
|
239
|
-
for (const part of parts) {
|
|
240
|
-
let from = part.start;
|
|
241
|
-
let to = part.end;
|
|
242
|
-
if (block && from === begin) from += s[from] === "\r" && s[from + 1] === "\n" ? 2 : 1;
|
|
243
|
-
if (block && to === i) {
|
|
244
|
-
to = closeLine;
|
|
245
|
-
if (to > from && s[to - 1] === "\n") to--;
|
|
246
|
-
if (to > from && s[to - 1] === "\r") to--;
|
|
247
|
-
}
|
|
248
|
-
const chars = [];
|
|
249
|
-
const positions = [];
|
|
250
|
-
for (let j = from; j < to;) {
|
|
251
|
-
if (block && (j === 0 || s[j - 1] === "\n" || s[j - 1] === "\r")) {
|
|
252
|
-
let k = 0;
|
|
253
|
-
while (k < margin.length && j + k < to && s[j + k] === margin[k]) k++;
|
|
254
|
-
if (k !== margin.length) {
|
|
255
|
-
const c = s[j + k];
|
|
256
|
-
if (!(c === "\n" || c === "\r" || j + k === to && !part.hole)) return error("invalid text indentation", j + k);
|
|
257
|
-
}
|
|
258
|
-
j += k;
|
|
259
|
-
if (j >= to) break;
|
|
260
|
-
}
|
|
261
|
-
positions.push(j);
|
|
262
|
-
if (s[j] === "\r") {
|
|
263
|
-
chars.push("\n");
|
|
264
|
-
j += s[j + 1] === "\n" ? 2 : 1;
|
|
265
|
-
} else chars.push(s[j++]);
|
|
266
|
-
}
|
|
267
|
-
const text = chars.join("");
|
|
268
|
-
if (raw) {
|
|
269
|
-
part.value = text;
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
let value = "";
|
|
273
|
-
const origins = [];
|
|
274
|
-
const append = (v, at) => {
|
|
275
|
-
value += v;
|
|
276
|
-
for (let n = 0; n < v.length; n++) origins.push(at);
|
|
277
|
-
};
|
|
278
|
-
for (let j = 0; j < text.length; j++) {
|
|
279
|
-
const at = positions[j];
|
|
280
|
-
if (text[j] !== "\\") {
|
|
281
|
-
append(text[j], at);
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
const c = text[++j];
|
|
285
|
-
if (c === void 0) return error("invalid text escape", at);
|
|
286
|
-
if (c === "\n" || c === "\u2028" || c === "\u2029") continue;
|
|
287
|
-
if (c === "0") {
|
|
288
|
-
if (/\d/.test(text[j + 1] ?? "")) return error("invalid text escape", at);
|
|
289
|
-
append("\0", at);
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
if (/[1-9]/.test(c)) return error("invalid text escape", at);
|
|
293
|
-
const simple = {
|
|
294
|
-
b: "\b",
|
|
295
|
-
f: "\f",
|
|
296
|
-
n: "\n",
|
|
297
|
-
r: "\r",
|
|
298
|
-
t: " ",
|
|
299
|
-
v: "\v"
|
|
300
|
-
};
|
|
301
|
-
if (simple[c] !== void 0) {
|
|
302
|
-
append(simple[c], at);
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
if (c === "x" || c === "u") {
|
|
306
|
-
let digits;
|
|
307
|
-
if (c === "u" && text[j + 1] === "{") {
|
|
308
|
-
const end = text.indexOf("}", j + 2);
|
|
309
|
-
if (end < 0) return error("invalid text escape", at);
|
|
310
|
-
digits = text.slice(j + 2, end);
|
|
311
|
-
j = end;
|
|
312
|
-
} else {
|
|
313
|
-
const length = c === "x" ? 2 : 4;
|
|
314
|
-
digits = text.slice(j + 1, j + 1 + length);
|
|
315
|
-
j += length;
|
|
316
|
-
if (digits.length !== length) return error("invalid text escape", at);
|
|
317
|
-
}
|
|
318
|
-
if (!/^[\dA-Fa-f]+$/.test(digits) || Number.parseInt(digits, 16) > 1114111) return error("invalid text escape", at);
|
|
319
|
-
append(String.fromCodePoint(Number.parseInt(digits, 16)), at);
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
append(c, at);
|
|
323
|
-
}
|
|
324
|
-
for (let j = 0; j < value.length; j++) {
|
|
325
|
-
const c = value.charCodeAt(j);
|
|
326
|
-
if (c >= 55296 && c <= 56319 && value.charCodeAt(j + 1) >= 56320 && value.charCodeAt(j + 1) <= 57343) {
|
|
327
|
-
j++;
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
if (c >= 55296 && c <= 57343) return error("invalid text escape", origins[j]);
|
|
331
|
-
}
|
|
332
|
-
part.value = value;
|
|
333
|
-
}
|
|
334
|
-
return {
|
|
335
|
-
...this.tok(parts.length === 1 ? "str" : "template", parts[0].value, open, i + width, space, mode),
|
|
336
|
-
parts
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
lex(start, mode) {
|
|
340
|
-
const s = this.src;
|
|
341
|
-
const { pos, trivia } = this.trivia(start);
|
|
342
|
-
const sp = pos > start || pos === 0 || s[pos - 1] === "\n" || s[pos - 1] === "\r";
|
|
343
|
-
const T = (t, v, len = v.length, code) => ({
|
|
344
|
-
...this.tok(t, v, pos, pos + len, sp, mode, code),
|
|
345
|
-
leadingTrivia: trivia
|
|
346
|
-
});
|
|
347
|
-
if (pos >= s.length) return T("eof", "", 0);
|
|
348
|
-
const c = s[pos];
|
|
349
|
-
const rest = s.slice(pos);
|
|
350
|
-
if (c === "\n") return T("nl", String.raw`\n`, 1);
|
|
351
|
-
if (c === "\r") return T("nl", String.raw`\n`, s[pos + 1] === "\n" ? 2 : 1);
|
|
352
|
-
if (mode === "unit" || mode === "type") {
|
|
353
|
-
const m = UNIT_SHAPE.exec(rest);
|
|
354
|
-
const first = m?.[0].startsWith("1/") ? "1" : m?.[0].match(/^[A-Za-z]+/)?.[0];
|
|
355
|
-
const compound = m && /[*/^]/.test(m[0]);
|
|
356
|
-
if (m && (first === "1" || unitEntry(first) !== void 0) && (mode === "unit" || compound)) {
|
|
357
|
-
const problem = unitProblem(m[0]);
|
|
358
|
-
if (problem) return T("error", problem, m[0].length, "bad unit");
|
|
359
|
-
return T("unit", m[0]);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (c === "`" || rest.startsWith("\"\"\"")) return {
|
|
363
|
-
...runTask(this.fenced(pos, sp, mode)),
|
|
364
|
-
leadingTrivia: trivia
|
|
365
|
-
};
|
|
366
|
-
if (c === "\"") {
|
|
367
|
-
let i = pos + 1;
|
|
368
|
-
while (i < s.length && s[i] !== "\"" && s[i] !== "\n" && s[i] !== "\r") i++;
|
|
369
|
-
if (s[i] !== "\"") return T("error", "text has no closing quote on its line", i - pos, "unterminated text");
|
|
370
|
-
return {
|
|
371
|
-
...this.tok("str", s.slice(pos + 1, i), pos, i + 1, sp, mode),
|
|
372
|
-
leadingTrivia: trivia
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
if (/\d/.test(c)) return T("num", NUMBER.exec(rest)[0]);
|
|
376
|
-
if (/[A-Z_a-z]/.test(c)) return T("word", NAME.exec(rest)[0]);
|
|
377
|
-
if (c === "'" && s[pos + 1] === "s" && !/\w/.test(s[pos + 2] ?? "")) return T("op", "'s");
|
|
378
|
-
const interpretation = mode === "unit" ? "operator" : mode === "type" ? "operand" : mode;
|
|
379
|
-
if (c === "<") {
|
|
380
|
-
if (interpretation === "pattern") return T("patopen", "<");
|
|
381
|
-
if (interpretation === "operand") return s[pos + 1] === "<" ? T("binopen", "<<") : T("patopen", "<");
|
|
382
|
-
for (const op of [
|
|
383
|
-
"<<",
|
|
384
|
-
"<=",
|
|
385
|
-
"<>",
|
|
386
|
-
"<"
|
|
387
|
-
]) if (rest.startsWith(op)) return T("op", op);
|
|
388
|
-
}
|
|
389
|
-
if (c === ">") {
|
|
390
|
-
if (interpretation === "pattern") return T("patclose", ">");
|
|
391
|
-
for (const op of [
|
|
392
|
-
">>",
|
|
393
|
-
">=",
|
|
394
|
-
">"
|
|
395
|
-
]) if (rest.startsWith(op)) return T("op", op);
|
|
396
|
-
}
|
|
397
|
-
for (const op of OPS) if (rest.startsWith(op)) return T("op", op);
|
|
398
|
-
const ch = String.fromCodePoint(s.codePointAt(pos));
|
|
399
|
-
return T("error", `${JSON.stringify(ch)} starts no token`, ch.length, "bad character");
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/capabilities.ts
|
|
404
|
-
/** Only a suffix of directly Optional argument Shapes can be omitted. */
|
|
405
|
-
const acceptsArgumentCount = (args, count) => count <= args.length && args.slice(count).every((s) => s.k === "optional");
|
|
406
|
-
const kind = (k) => ({
|
|
407
|
-
k: "kind",
|
|
408
|
-
kind: k
|
|
409
|
-
});
|
|
410
|
-
const fieldsOf = (fields) => Object.entries(fields).map(([key, f]) => "shape" in f ? {
|
|
411
|
-
key,
|
|
412
|
-
optional: true,
|
|
413
|
-
shape: f.shape
|
|
414
|
-
} : {
|
|
415
|
-
key,
|
|
416
|
-
optional: false,
|
|
417
|
-
shape: f
|
|
418
|
-
});
|
|
419
|
-
/** The Shape constructors of `talk.ts`. */
|
|
420
|
-
const shape = {
|
|
421
|
-
any: { k: "any" },
|
|
422
|
-
value: { k: "value" },
|
|
423
|
-
nothing: kind("nothing"),
|
|
424
|
-
bool: kind("boolean"),
|
|
425
|
-
number: kind("number"),
|
|
426
|
-
text: kind("text"),
|
|
427
|
-
bytes: kind("bytes"),
|
|
428
|
-
instant: kind("instant"),
|
|
429
|
-
civilDate: kind("civil date"),
|
|
430
|
-
range: kind("range"),
|
|
431
|
-
pattern: kind("pattern"),
|
|
432
|
-
function: kind("function"),
|
|
433
|
-
object: (kind) => ({
|
|
434
|
-
k: "object",
|
|
435
|
-
kind: kind.name
|
|
436
|
-
}),
|
|
437
|
-
quantityOf: (unit) => ({
|
|
438
|
-
k: "quantity",
|
|
439
|
-
unit: unitText(parseUnit(unit))
|
|
440
|
-
}),
|
|
441
|
-
quantityKind: (unitKind) => ({
|
|
442
|
-
k: "unitKind",
|
|
443
|
-
kind: unitKind
|
|
444
|
-
}),
|
|
445
|
-
listOf: (of) => ({
|
|
446
|
-
k: "list",
|
|
447
|
-
of
|
|
448
|
-
}),
|
|
449
|
-
map: (fields) => ({
|
|
450
|
-
k: "map",
|
|
451
|
-
fields: fieldsOf(fields),
|
|
452
|
-
open: false
|
|
453
|
-
}),
|
|
454
|
-
openMap: (fields) => ({
|
|
455
|
-
k: "map",
|
|
456
|
-
fields: fieldsOf(fields),
|
|
457
|
-
open: true
|
|
458
|
-
}),
|
|
459
|
-
oneOf: (...of) => ({
|
|
460
|
-
k: "oneOf",
|
|
461
|
-
of
|
|
462
|
-
}),
|
|
463
|
-
optional: (of) => ({
|
|
464
|
-
k: "optional",
|
|
465
|
-
of
|
|
466
|
-
})
|
|
467
|
-
};
|
|
468
|
-
/** What a Shape expects, as `wrong kind` writes it. */
|
|
469
|
-
const expectedOf = (s) => {
|
|
470
|
-
switch (s.k) {
|
|
471
|
-
case "any": return "any";
|
|
472
|
-
case "value": return "value";
|
|
473
|
-
case "kind":
|
|
474
|
-
case "object": return s.kind;
|
|
475
|
-
case "quantity": return s.unit;
|
|
476
|
-
case "unitKind": return s.kind;
|
|
477
|
-
case "list": return "list";
|
|
478
|
-
case "map": return "map";
|
|
479
|
-
case "oneOf": return s.of.map(expectedOf).join(" or ");
|
|
480
|
-
case "optional": return `${expectedOf(s.of)} or nothing`;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
const nothingValue = (v) => v.kind === "nothing";
|
|
484
|
-
const gotOf = (v, s) => (s.k === "quantity" || s.k === "unitKind") && v.kind === "quantity" ? unitText(v.asQuantityRef().unit) : v.kind;
|
|
485
|
-
const mismatch = (v, s, path = []) => {
|
|
486
|
-
const wrong = () => ({
|
|
487
|
-
expected: expectedOf(s),
|
|
488
|
-
got: gotOf(v, s),
|
|
489
|
-
path,
|
|
490
|
-
value: v
|
|
491
|
-
});
|
|
492
|
-
switch (s.k) {
|
|
493
|
-
case "value": return null;
|
|
494
|
-
case "any": return v.kind === "function" ? {
|
|
495
|
-
...wrong(),
|
|
496
|
-
unencodable: true
|
|
497
|
-
} : deepFunction(v, path);
|
|
498
|
-
case "kind": return v.kind === s.kind ? null : wrong();
|
|
499
|
-
case "object": return v.asObjectRef()?.kind === s.kind ? null : wrong();
|
|
500
|
-
case "quantity": {
|
|
501
|
-
const q = v.asQuantityRef();
|
|
502
|
-
return q && unitText(q.unit) === s.unit ? null : wrong();
|
|
503
|
-
}
|
|
504
|
-
case "unitKind": {
|
|
505
|
-
const q = v.asQuantityRef();
|
|
506
|
-
const slot = q?.unit.length === 1 ? q.unit[0] : void 0;
|
|
507
|
-
return slot && slot.exponent === 1 && unitEntry(slot.unit)?.kind === s.kind ? null : wrong();
|
|
508
|
-
}
|
|
509
|
-
case "list":
|
|
510
|
-
if (v.kind !== "list") return wrong();
|
|
511
|
-
for (let i = 1; i <= v.length; i++) {
|
|
512
|
-
const m = mismatch(v.index(i), s.of, [...path, i]);
|
|
513
|
-
if (m) return m;
|
|
514
|
-
}
|
|
515
|
-
return null;
|
|
516
|
-
case "map": {
|
|
517
|
-
if (v.kind !== "map") return wrong();
|
|
518
|
-
const keys = new Set(v.entries().map(([k]) => k));
|
|
519
|
-
for (const f of s.fields) {
|
|
520
|
-
if (!keys.has(f.key)) {
|
|
521
|
-
if (!f.optional) return {
|
|
522
|
-
expected: expectedOf(f.shape),
|
|
523
|
-
got: "nothing",
|
|
524
|
-
path: [...path, f.key],
|
|
525
|
-
value: nothing
|
|
526
|
-
};
|
|
527
|
-
continue;
|
|
528
|
-
}
|
|
529
|
-
const m = mismatch(v.get(f.key), f.shape, [...path, f.key]);
|
|
530
|
-
if (m) return m;
|
|
531
|
-
}
|
|
532
|
-
const declared = new Set(s.fields.map((f) => f.key));
|
|
533
|
-
for (const [key, item] of v.entries()) if (!declared.has(key)) {
|
|
534
|
-
if (!s.open) return {
|
|
535
|
-
expected: "nothing",
|
|
536
|
-
got: item.kind,
|
|
537
|
-
path: [...path, key],
|
|
538
|
-
value: item
|
|
539
|
-
};
|
|
540
|
-
const m = deepFunction(item, [...path, key]);
|
|
541
|
-
if (m) return m;
|
|
542
|
-
}
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
case "oneOf": return s.of.some((option) => !mismatch(v, option, path)) ? null : wrong();
|
|
546
|
-
case "optional": {
|
|
547
|
-
if (nothingValue(v)) return null;
|
|
548
|
-
const m = mismatch(v, s.of, path);
|
|
549
|
-
return m && m.path.length === path.length && !m.unencodable ? {
|
|
550
|
-
...m,
|
|
551
|
-
expected: `${m.expected} or nothing`
|
|
552
|
-
} : m;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
const deepFunction = (v, path) => {
|
|
557
|
-
if (v.kind === "function") return {
|
|
558
|
-
expected: "any",
|
|
559
|
-
got: "function",
|
|
560
|
-
path,
|
|
561
|
-
value: v,
|
|
562
|
-
unencodable: true
|
|
563
|
-
};
|
|
564
|
-
if (v.kind === "list") for (let i = 1; i <= v.length; i++) {
|
|
565
|
-
const m = deepFunction(v.index(i), [...path, i]);
|
|
566
|
-
if (m) return m;
|
|
567
|
-
}
|
|
568
|
-
if (v.kind === "map") for (const [key, item] of v.entries()) {
|
|
569
|
-
const m = deepFunction(item, [...path, key]);
|
|
570
|
-
if (m) return m;
|
|
571
|
-
}
|
|
572
|
-
return null;
|
|
573
|
-
};
|
|
574
|
-
const scalarKinds = /* @__PURE__ */ new Set([
|
|
575
|
-
"nothing",
|
|
576
|
-
"boolean",
|
|
577
|
-
"number",
|
|
578
|
-
"quantity",
|
|
579
|
-
"text",
|
|
580
|
-
"bytes",
|
|
581
|
-
"list",
|
|
582
|
-
"map",
|
|
583
|
-
"range",
|
|
584
|
-
"instant",
|
|
585
|
-
"civil date",
|
|
586
|
-
"pattern",
|
|
587
|
-
"function",
|
|
588
|
-
"object"
|
|
589
|
-
]);
|
|
590
|
-
const wrapperKeys = [
|
|
591
|
-
"quantity",
|
|
592
|
-
"unitKind",
|
|
593
|
-
"object",
|
|
594
|
-
"list",
|
|
595
|
-
"oneOf",
|
|
596
|
-
"optional",
|
|
597
|
-
"map"
|
|
598
|
-
];
|
|
599
|
-
const scalarsOf = (s) => [...s].length;
|
|
600
|
-
/** Reads Shape data into a Shape, or gives the first definition error. */
|
|
601
|
-
const decodeShape = (data) => {
|
|
602
|
-
let scanned = 0;
|
|
603
|
-
const results = [];
|
|
604
|
-
const stack = [{
|
|
605
|
-
data,
|
|
606
|
-
path: [],
|
|
607
|
-
t: "enter"
|
|
608
|
-
}];
|
|
609
|
-
const fail = (reason, path, value) => ({
|
|
610
|
-
error: {
|
|
611
|
-
path,
|
|
612
|
-
reason,
|
|
613
|
-
value
|
|
614
|
-
},
|
|
615
|
-
scanned
|
|
616
|
-
});
|
|
617
|
-
while (stack.length) {
|
|
618
|
-
const frame = stack.pop();
|
|
619
|
-
switch (frame.t) {
|
|
620
|
-
case "wrap":
|
|
621
|
-
results.push({
|
|
622
|
-
k: frame.k,
|
|
623
|
-
of: results.pop()
|
|
624
|
-
});
|
|
625
|
-
break;
|
|
626
|
-
case "oneOf":
|
|
627
|
-
results.push({
|
|
628
|
-
k: "oneOf",
|
|
629
|
-
of: results.splice(results.length - frame.n, frame.n)
|
|
630
|
-
});
|
|
631
|
-
break;
|
|
632
|
-
case "mapDone":
|
|
633
|
-
results.push({
|
|
634
|
-
fields: frame.acc,
|
|
635
|
-
k: "map",
|
|
636
|
-
open: frame.open
|
|
637
|
-
});
|
|
638
|
-
break;
|
|
639
|
-
case "fieldDone":
|
|
640
|
-
frame.acc.push({
|
|
641
|
-
key: frame.key,
|
|
642
|
-
optional: frame.optional,
|
|
643
|
-
shape: results.pop()
|
|
644
|
-
});
|
|
645
|
-
break;
|
|
646
|
-
case "field": {
|
|
647
|
-
const { data: decl, path } = frame;
|
|
648
|
-
if (decl.kind !== "map") return fail("invalid field", path, decl);
|
|
649
|
-
const entries = new Map(decl.entries());
|
|
650
|
-
scanned += entries.size;
|
|
651
|
-
const key = entries.get("key");
|
|
652
|
-
if (key === void 0) return fail("invalid field key", path, decl);
|
|
653
|
-
if (key.kind !== "text") return fail("invalid field key", [...path, "key"], key);
|
|
654
|
-
const inner = entries.get("shape");
|
|
655
|
-
if (inner === void 0) return fail("missing field shape", path, decl);
|
|
656
|
-
const flag = entries.get("optional");
|
|
657
|
-
if (flag !== void 0 && flag.kind !== "boolean") return fail("invalid flag", [...path, "optional"], flag);
|
|
658
|
-
const name = key.asText();
|
|
659
|
-
if (frame.seen.has(name)) return fail("duplicate field", [...path, "key"], key);
|
|
660
|
-
frame.seen.add(name);
|
|
661
|
-
stack.push({
|
|
662
|
-
acc: frame.acc,
|
|
663
|
-
key: name,
|
|
664
|
-
optional: flag?.asBool() ?? false,
|
|
665
|
-
t: "fieldDone"
|
|
666
|
-
}, {
|
|
667
|
-
data: inner,
|
|
668
|
-
path: [...path, "shape"],
|
|
669
|
-
t: "enter"
|
|
670
|
-
});
|
|
671
|
-
break;
|
|
672
|
-
}
|
|
673
|
-
case "enter": {
|
|
674
|
-
const { data: node, path } = frame;
|
|
675
|
-
scanned++;
|
|
676
|
-
if (node.kind === "text") {
|
|
677
|
-
const name = node.asText();
|
|
678
|
-
scanned += scalarsOf(name);
|
|
679
|
-
if (name === "any" || name === "value") results.push({ k: name });
|
|
680
|
-
else if (scalarKinds.has(name)) results.push({
|
|
681
|
-
k: "kind",
|
|
682
|
-
kind: name
|
|
683
|
-
});
|
|
684
|
-
else return fail("unknown kind", path, node);
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
if (node.kind !== "map") return fail("not a shape", path, node);
|
|
688
|
-
const entries = new Map(node.entries());
|
|
689
|
-
scanned += entries.size;
|
|
690
|
-
const present = wrapperKeys.filter((k) => entries.has(k));
|
|
691
|
-
if (present.length === 0) return fail("not a shape", path, node);
|
|
692
|
-
if (present.length > 1) return fail("ambiguous shape", path, node);
|
|
693
|
-
const key = present[0];
|
|
694
|
-
const payload = entries.get(key);
|
|
695
|
-
switch (key) {
|
|
696
|
-
case "quantity":
|
|
697
|
-
if (payload.kind !== "text") return fail("invalid unit", [...path, key], payload);
|
|
698
|
-
scanned += scalarsOf(payload.asText());
|
|
699
|
-
try {
|
|
700
|
-
results.push({
|
|
701
|
-
k: "quantity",
|
|
702
|
-
unit: unitText(parseUnit(payload.asText()))
|
|
703
|
-
});
|
|
704
|
-
} catch {
|
|
705
|
-
return fail("invalid unit", [...path, key], payload);
|
|
706
|
-
}
|
|
707
|
-
break;
|
|
708
|
-
case "unitKind":
|
|
709
|
-
if (payload.kind === "text") scanned += scalarsOf(payload.asText());
|
|
710
|
-
if (payload.kind !== "text" || !unitKinds.includes(payload.asText())) return fail("unknown unit kind", [...path, key], payload);
|
|
711
|
-
results.push({
|
|
712
|
-
k: "unitKind",
|
|
713
|
-
kind: payload.asText()
|
|
714
|
-
});
|
|
715
|
-
break;
|
|
716
|
-
case "object":
|
|
717
|
-
if (payload.kind !== "text") return fail("invalid object kind", [...path, key], payload);
|
|
718
|
-
results.push({
|
|
719
|
-
k: "object",
|
|
720
|
-
kind: payload.asText()
|
|
721
|
-
});
|
|
722
|
-
break;
|
|
723
|
-
case "list":
|
|
724
|
-
case "optional":
|
|
725
|
-
stack.push({
|
|
726
|
-
k: key,
|
|
727
|
-
t: "wrap"
|
|
728
|
-
}, {
|
|
729
|
-
data: payload,
|
|
730
|
-
path: [...path, key],
|
|
731
|
-
t: "enter"
|
|
732
|
-
});
|
|
733
|
-
break;
|
|
734
|
-
case "oneOf":
|
|
735
|
-
if (payload.kind !== "list") return fail("invalid alternatives", [...path, key], payload);
|
|
736
|
-
if (payload.length === 0) return fail("empty union", [...path, key], payload);
|
|
737
|
-
stack.push({
|
|
738
|
-
n: payload.length,
|
|
739
|
-
t: "oneOf"
|
|
740
|
-
});
|
|
741
|
-
for (let i = payload.length; i >= 1; i--) stack.push({
|
|
742
|
-
data: payload.index(i),
|
|
743
|
-
path: [
|
|
744
|
-
...path,
|
|
745
|
-
key,
|
|
746
|
-
i
|
|
747
|
-
],
|
|
748
|
-
t: "enter"
|
|
749
|
-
});
|
|
750
|
-
break;
|
|
751
|
-
case "map": {
|
|
752
|
-
const flag = entries.get("open");
|
|
753
|
-
if (flag !== void 0 && flag.kind !== "boolean") return fail("invalid flag", [...path, "open"], flag);
|
|
754
|
-
if (payload.kind !== "list") return fail("invalid fields", [...path, key], payload);
|
|
755
|
-
const acc = [];
|
|
756
|
-
const seen = /* @__PURE__ */ new Set();
|
|
757
|
-
stack.push({
|
|
758
|
-
acc,
|
|
759
|
-
open: flag?.asBool() ?? false,
|
|
760
|
-
t: "mapDone"
|
|
761
|
-
});
|
|
762
|
-
for (let i = payload.length; i >= 1; i--) stack.push({
|
|
763
|
-
acc,
|
|
764
|
-
data: payload.index(i),
|
|
765
|
-
path: [
|
|
766
|
-
...path,
|
|
767
|
-
key,
|
|
768
|
-
i
|
|
769
|
-
],
|
|
770
|
-
seen,
|
|
771
|
-
t: "field"
|
|
772
|
-
});
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
break;
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return {
|
|
781
|
-
scanned,
|
|
782
|
-
shape: results[0]
|
|
783
|
-
};
|
|
784
|
-
};
|
|
785
|
-
/**
|
|
786
|
-
* Every mismatch of `v` against `s`, or only the first when `first`:
|
|
787
|
-
* the traversal of chapter 7, with failed union alternatives grouped.
|
|
788
|
-
*/
|
|
789
|
-
const shapeDiagnostics = (v, s, first, scanned) => {
|
|
790
|
-
const root = { diags: [] };
|
|
791
|
-
const discarded = /* @__PURE__ */ new Set();
|
|
792
|
-
let trials = 0;
|
|
793
|
-
let halted = false;
|
|
794
|
-
const deepInfo = /* @__PURE__ */ new Map();
|
|
795
|
-
const infoOf = (rootValue) => {
|
|
796
|
-
const pending = [rootValue];
|
|
797
|
-
const order = [];
|
|
798
|
-
const seen = /* @__PURE__ */ new Set();
|
|
799
|
-
while (pending.length) {
|
|
800
|
-
const next = pending.pop();
|
|
801
|
-
if (deepInfo.has(next) || seen.has(next)) continue;
|
|
802
|
-
seen.add(next);
|
|
803
|
-
order.push(next);
|
|
804
|
-
if (next.kind === "list") for (let i = 1; i <= next.length; i++) pending.push(next.index(i));
|
|
805
|
-
else if (next.kind === "map") for (const [, value] of next.entries()) pending.push(value);
|
|
806
|
-
}
|
|
807
|
-
for (let i = order.length - 1; i >= 0; i--) {
|
|
808
|
-
const value = order[i];
|
|
809
|
-
let clean = value.kind !== "function";
|
|
810
|
-
let nodes = 1;
|
|
811
|
-
const children = value.kind === "list" ? Array.from({ length: value.length }, (_, j) => value.index(j + 1)) : value.kind === "map" ? value.entries().map(([, item]) => item) : [];
|
|
812
|
-
for (const child of children) {
|
|
813
|
-
const info = deepInfo.get(child);
|
|
814
|
-
clean = clean && info.clean;
|
|
815
|
-
nodes += info.nodes;
|
|
816
|
-
}
|
|
817
|
-
deepInfo.set(value, {
|
|
818
|
-
clean,
|
|
819
|
-
nodes
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
return deepInfo.get(rootValue);
|
|
823
|
-
};
|
|
824
|
-
const stack = [{
|
|
825
|
-
path: [],
|
|
826
|
-
s,
|
|
827
|
-
sink: root,
|
|
828
|
-
t: "node",
|
|
829
|
-
trial: 0,
|
|
830
|
-
v
|
|
831
|
-
}];
|
|
832
|
-
const emit = (sink, trial, diag) => {
|
|
833
|
-
sink.diags.push(diag);
|
|
834
|
-
if (!first) return;
|
|
835
|
-
if (trial === 0) {
|
|
836
|
-
halted = true;
|
|
837
|
-
for (let i = stack.length - 1; i >= 0; i--) if (stack[i].t !== "adjust") stack.splice(i, 1);
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
discarded.add(trial);
|
|
841
|
-
for (let i = stack.length - 1; i >= 0; i--) if (stack[i].trial === trial) stack.splice(i, 1);
|
|
842
|
-
};
|
|
843
|
-
const wrong = (sink, trial, value, shape, path) => emit(sink, trial, {
|
|
844
|
-
expected: expectedOf(shape),
|
|
845
|
-
got: gotOf(value, shape),
|
|
846
|
-
path,
|
|
847
|
-
value
|
|
848
|
-
});
|
|
849
|
-
while (stack.length) {
|
|
850
|
-
const frame = stack.pop();
|
|
851
|
-
if (discarded.has(frame.trial)) continue;
|
|
852
|
-
switch (frame.t) {
|
|
853
|
-
case "adjust":
|
|
854
|
-
for (let i = frame.mark; i < frame.sink.diags.length; i++) {
|
|
855
|
-
const d = frame.sink.diags[i];
|
|
856
|
-
if (!d.unencodable && d.path.length === frame.path.length && d.path.every((p, j) => p === frame.path[j])) {
|
|
857
|
-
d.expected += " or nothing";
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
break;
|
|
862
|
-
case "missing":
|
|
863
|
-
scanned++;
|
|
864
|
-
emit(frame.sink, frame.trial, {
|
|
865
|
-
expected: frame.expected,
|
|
866
|
-
got: "nothing",
|
|
867
|
-
path: frame.path,
|
|
868
|
-
value: nothing
|
|
869
|
-
});
|
|
870
|
-
break;
|
|
871
|
-
case "deep": {
|
|
872
|
-
const info = infoOf(frame.v);
|
|
873
|
-
if (info.clean) {
|
|
874
|
-
scanned += info.nodes;
|
|
875
|
-
break;
|
|
876
|
-
}
|
|
877
|
-
scanned++;
|
|
878
|
-
const { path, sink, trial, v: value } = frame;
|
|
879
|
-
if (value.kind === "function") emit(sink, trial, {
|
|
880
|
-
expected: "any",
|
|
881
|
-
got: "function",
|
|
882
|
-
path,
|
|
883
|
-
unencodable: true,
|
|
884
|
-
value
|
|
885
|
-
});
|
|
886
|
-
else if (value.kind === "list") for (let i = value.length; i >= 1; i--) stack.push({
|
|
887
|
-
path: [...path, i],
|
|
888
|
-
sink,
|
|
889
|
-
t: "deep",
|
|
890
|
-
trial,
|
|
891
|
-
v: value.index(i)
|
|
892
|
-
});
|
|
893
|
-
else if (value.kind === "map") {
|
|
894
|
-
const entries = value.entries();
|
|
895
|
-
for (let i = entries.length - 1; i >= 0; i--) stack.push({
|
|
896
|
-
path: [...path, entries[i][0]],
|
|
897
|
-
sink,
|
|
898
|
-
t: "deep",
|
|
899
|
-
trial,
|
|
900
|
-
v: entries[i][1]
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
case "extras": {
|
|
906
|
-
const declared = new Set(frame.s.fields.map((f) => f.key));
|
|
907
|
-
const deeps = [];
|
|
908
|
-
for (const [key, item] of frame.v.entries()) {
|
|
909
|
-
if (declared.has(key)) continue;
|
|
910
|
-
if (!frame.s.open) {
|
|
911
|
-
scanned++;
|
|
912
|
-
emit(frame.sink, frame.trial, {
|
|
913
|
-
expected: "nothing",
|
|
914
|
-
got: item.kind,
|
|
915
|
-
path: [...frame.path, key],
|
|
916
|
-
value: item
|
|
917
|
-
});
|
|
918
|
-
if (halted || discarded.has(frame.trial)) break;
|
|
919
|
-
} else deeps.push({
|
|
920
|
-
path: [...frame.path, key],
|
|
921
|
-
sink: frame.sink,
|
|
922
|
-
t: "deep",
|
|
923
|
-
trial: frame.trial,
|
|
924
|
-
v: item
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
for (let i = deeps.length - 1; i >= 0; i--) stack.push(deeps[i]);
|
|
928
|
-
break;
|
|
929
|
-
}
|
|
930
|
-
case "union": {
|
|
931
|
-
if (frame.current) {
|
|
932
|
-
if (frame.current.diags.length === 0) break;
|
|
933
|
-
frame.collected.push(frame.current.diags);
|
|
934
|
-
frame.current = null;
|
|
935
|
-
frame.index++;
|
|
936
|
-
}
|
|
937
|
-
if (frame.index >= frame.alts.length) {
|
|
938
|
-
emit(frame.sink, frame.trial, {
|
|
939
|
-
alternatives: frame.collected,
|
|
940
|
-
expected: expectedOf(frame.s),
|
|
941
|
-
got: gotOf(frame.v, frame.s),
|
|
942
|
-
path: frame.path,
|
|
943
|
-
value: frame.v
|
|
944
|
-
});
|
|
945
|
-
break;
|
|
946
|
-
}
|
|
947
|
-
const sink = { diags: [] };
|
|
948
|
-
frame.current = sink;
|
|
949
|
-
stack.push(frame, {
|
|
950
|
-
path: frame.path,
|
|
951
|
-
s: frame.alts[frame.index],
|
|
952
|
-
sink,
|
|
953
|
-
t: "node",
|
|
954
|
-
trial: ++trials,
|
|
955
|
-
v: frame.v
|
|
956
|
-
});
|
|
957
|
-
break;
|
|
958
|
-
}
|
|
959
|
-
case "node": {
|
|
960
|
-
scanned++;
|
|
961
|
-
const { path, s: shape, sink, trial, v: value } = frame;
|
|
962
|
-
switch (shape.k) {
|
|
963
|
-
case "value": break;
|
|
964
|
-
case "any":
|
|
965
|
-
stack.push({
|
|
966
|
-
path,
|
|
967
|
-
sink,
|
|
968
|
-
t: "deep",
|
|
969
|
-
trial,
|
|
970
|
-
v: value
|
|
971
|
-
});
|
|
972
|
-
break;
|
|
973
|
-
case "kind":
|
|
974
|
-
if (value.kind !== shape.kind) wrong(sink, trial, value, shape, path);
|
|
975
|
-
break;
|
|
976
|
-
case "object":
|
|
977
|
-
if (value.asObjectRef()?.kind !== shape.kind) wrong(sink, trial, value, shape, path);
|
|
978
|
-
break;
|
|
979
|
-
case "quantity": {
|
|
980
|
-
const q = value.asQuantityRef();
|
|
981
|
-
if (!q || unitText(q.unit) !== shape.unit) wrong(sink, trial, value, shape, path);
|
|
982
|
-
break;
|
|
983
|
-
}
|
|
984
|
-
case "unitKind": {
|
|
985
|
-
const q = value.asQuantityRef();
|
|
986
|
-
const slot = q?.unit.length === 1 ? q.unit[0] : void 0;
|
|
987
|
-
if (!slot || slot.exponent !== 1 || unitEntry(slot.unit)?.kind !== shape.kind) wrong(sink, trial, value, shape, path);
|
|
988
|
-
break;
|
|
989
|
-
}
|
|
990
|
-
case "list":
|
|
991
|
-
if (value.kind !== "list") {
|
|
992
|
-
wrong(sink, trial, value, shape, path);
|
|
993
|
-
break;
|
|
994
|
-
}
|
|
995
|
-
for (let i = value.length; i >= 1; i--) stack.push({
|
|
996
|
-
path: [...path, i],
|
|
997
|
-
s: shape.of,
|
|
998
|
-
sink,
|
|
999
|
-
t: "node",
|
|
1000
|
-
trial,
|
|
1001
|
-
v: value.index(i)
|
|
1002
|
-
});
|
|
1003
|
-
break;
|
|
1004
|
-
case "map": {
|
|
1005
|
-
if (value.kind !== "map") {
|
|
1006
|
-
wrong(sink, trial, value, shape, path);
|
|
1007
|
-
break;
|
|
1008
|
-
}
|
|
1009
|
-
stack.push({
|
|
1010
|
-
path,
|
|
1011
|
-
s: shape,
|
|
1012
|
-
sink,
|
|
1013
|
-
t: "extras",
|
|
1014
|
-
trial,
|
|
1015
|
-
v: value
|
|
1016
|
-
});
|
|
1017
|
-
const entries = new Map(value.entries());
|
|
1018
|
-
for (let i = shape.fields.length - 1; i >= 0; i--) {
|
|
1019
|
-
const f = shape.fields[i];
|
|
1020
|
-
const item = entries.get(f.key);
|
|
1021
|
-
if (item !== void 0) stack.push({
|
|
1022
|
-
path: [...path, f.key],
|
|
1023
|
-
s: f.shape,
|
|
1024
|
-
sink,
|
|
1025
|
-
t: "node",
|
|
1026
|
-
trial,
|
|
1027
|
-
v: item
|
|
1028
|
-
});
|
|
1029
|
-
else if (!f.optional) stack.push({
|
|
1030
|
-
expected: expectedOf(f.shape),
|
|
1031
|
-
path: [...path, f.key],
|
|
1032
|
-
sink,
|
|
1033
|
-
t: "missing",
|
|
1034
|
-
trial
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
break;
|
|
1038
|
-
}
|
|
1039
|
-
case "oneOf":
|
|
1040
|
-
stack.push({
|
|
1041
|
-
alts: shape.of,
|
|
1042
|
-
collected: [],
|
|
1043
|
-
current: null,
|
|
1044
|
-
index: 0,
|
|
1045
|
-
path,
|
|
1046
|
-
s: shape,
|
|
1047
|
-
sink,
|
|
1048
|
-
t: "union",
|
|
1049
|
-
trial,
|
|
1050
|
-
v: value
|
|
1051
|
-
});
|
|
1052
|
-
break;
|
|
1053
|
-
case "optional":
|
|
1054
|
-
if (nothingValue(value)) break;
|
|
1055
|
-
stack.push({
|
|
1056
|
-
mark: sink.diags.length,
|
|
1057
|
-
path,
|
|
1058
|
-
sink,
|
|
1059
|
-
t: "adjust",
|
|
1060
|
-
trial
|
|
1061
|
-
}, {
|
|
1062
|
-
path,
|
|
1063
|
-
s: shape.of,
|
|
1064
|
-
sink,
|
|
1065
|
-
t: "node",
|
|
1066
|
-
trial,
|
|
1067
|
-
v: value
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
break;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
return {
|
|
1075
|
-
diags: root.diags,
|
|
1076
|
-
scanned
|
|
1077
|
-
};
|
|
1078
|
-
};
|
|
1079
|
-
/** A Value Path as a Script value: text keys and 1-based positions. */
|
|
1080
|
-
const pathValue = (path) => listValues(path.map((p) => typeof p === "number" ? dec(String(p)) : text(p)));
|
|
1081
|
-
/** One `explain` record: the error's fields as a plain map, without `message` or `at`. */
|
|
1082
|
-
const diagnosticRecord = (d) => {
|
|
1083
|
-
if (d.unencodable) return map([
|
|
1084
|
-
["code", text("not encodable")],
|
|
1085
|
-
["kind", text(d.got)],
|
|
1086
|
-
["path", pathValue(d.path)]
|
|
1087
|
-
]);
|
|
1088
|
-
const fields = [
|
|
1089
|
-
["code", text("wrong kind")],
|
|
1090
|
-
["expected", text(d.expected)],
|
|
1091
|
-
["got", text(d.got)],
|
|
1092
|
-
["value", d.value]
|
|
1093
|
-
];
|
|
1094
|
-
if (d.path.length) fields.push(["path", pathValue(d.path)]);
|
|
1095
|
-
if (d.alternatives) fields.push(["alternatives", listValues(d.alternatives.map((alt) => listValues(alt.map(diagnosticRecord))))]);
|
|
1096
|
-
return map(fields);
|
|
1097
|
-
};
|
|
1098
|
-
/** Thrown by `call.charge` when the Run's Fuel can't cover it. */
|
|
1099
|
-
var LimitReached = class extends Error {
|
|
1100
|
-
name = "LimitReached";
|
|
1101
|
-
};
|
|
1102
|
-
const refusedNames = /* @__PURE__ */ new Set([
|
|
1103
|
-
"ask",
|
|
1104
|
-
"tell",
|
|
1105
|
-
"send",
|
|
1106
|
-
"wait",
|
|
1107
|
-
"end"
|
|
1108
|
-
]);
|
|
1109
|
-
const scopeWord = (value) => typeof value === "string" && /^[A-Z_a-z]\w*$/.test(value);
|
|
1110
|
-
const hasHooks = (lifecycle) => !!lifecycle && typeof lifecycle === "object" && [
|
|
1111
|
-
"begin",
|
|
1112
|
-
"commit",
|
|
1113
|
-
"rollback"
|
|
1114
|
-
].every((phase) => typeof lifecycle[phase] === "function");
|
|
1115
|
-
/** Define a Capability, once per process (chapter 9, Capabilities). */
|
|
1116
|
-
const defineCapability = (name, ops, lifecycle, release) => {
|
|
1117
|
-
if (release !== void 0 && typeof release !== "function") invalidValue("A release hook must be a function");
|
|
1118
|
-
for (const op of Object.keys(ops)) if (refusedNames.has(op)) throw new HostError("invalid value", `${op} can't name an Operation`);
|
|
1119
|
-
const coordinated = !!lifecycle && typeof lifecycle === "object" && "coordinator" in lifecycle ? lifecycle : void 0;
|
|
1120
|
-
if (coordinated && typeof coordinated.coordinator !== "function") invalidValue("A coordinator mapping must be a function");
|
|
1121
|
-
if (lifecycle !== void 0 && !coordinated && !hasHooks(lifecycle)) invalidValue("A participant requires synchronous begin, commit and rollback hooks");
|
|
1122
|
-
const hooks = coordinated ? void 0 : lifecycle;
|
|
1123
|
-
const scopes = /* @__PURE__ */ new Map();
|
|
1124
|
-
const scopeEffects = /* @__PURE__ */ new Map();
|
|
1125
|
-
for (const [opName, op] of Object.entries(ops)) {
|
|
1126
|
-
if (op.command !== void 0 && typeof op.command !== "boolean") invalidValue("command must be Boolean");
|
|
1127
|
-
if (op.command && RESERVED.has(opName)) invalidValue(`${opName} is a Reserved Word, so it can't be a command`);
|
|
1128
|
-
if (op.description !== void 0 && typeof op.description !== "string") invalidValue("description must be text");
|
|
1129
|
-
if (op.examples !== void 0 && (!Array.isArray(op.examples) || [...op.examples].some((example) => typeof example !== "string"))) invalidValue("examples must be a list of text");
|
|
1130
|
-
const metadata = op;
|
|
1131
|
-
if (metadata.segmentBound !== void 0 && typeof metadata.segmentBound !== "boolean") invalidValue("segmentBound must be Boolean");
|
|
1132
|
-
if (metadata.segmentBound && (op.mode !== "immediate" || !lifecycle)) invalidValue("Segment-bound Operations require immediate mode and lifecycle hooks");
|
|
1133
|
-
const scope = metadata.scope;
|
|
1134
|
-
if (scope === void 0) continue;
|
|
1135
|
-
if (op.mode !== "immediate" || !scope || typeof scope !== "object") invalidValue("Scopes require immediate Operations");
|
|
1136
|
-
const scopeName = "opens" in scope ? scope.opens : scope.closes;
|
|
1137
|
-
const bound = metadata.segmentBound === true;
|
|
1138
|
-
if (scopeEffects.has(scopeName) && scopeEffects.get(scopeName) !== bound) invalidValue("All lifecycle Operations of a scope must agree on segmentBound");
|
|
1139
|
-
scopeEffects.set(scopeName, bound);
|
|
1140
|
-
const keys = Object.keys(scope).sort().join(",");
|
|
1141
|
-
if (keys === "abandon,opens" && "opens" in scope) {
|
|
1142
|
-
if (!scopeWord(scope.opens) || !scopeWord(scope.abandon)) invalidValue("Invalid scope name or abandonment Operation");
|
|
1143
|
-
const previous = scopes.get(scope.opens);
|
|
1144
|
-
if (previous && previous !== scope.abandon) invalidValue("Scope openers must agree on abandonment");
|
|
1145
|
-
scopes.set(scope.opens, scope.abandon);
|
|
1146
|
-
} else if (keys === "closes" && "closes" in scope) {
|
|
1147
|
-
if (!scopeWord(scope.closes)) invalidValue("Invalid scope name");
|
|
1148
|
-
} else invalidValue(`Invalid scope declaration for ${opName}`);
|
|
1149
|
-
}
|
|
1150
|
-
for (const [scopeName, abandon] of scopes) {
|
|
1151
|
-
const op = ops[abandon];
|
|
1152
|
-
if (!op || op.mode !== "immediate" || !op.scope || !("closes" in op.scope) || op.scope.closes !== scopeName || (op.args?.length ?? 0) !== 0 || op.result?.k !== "kind" || op.result.kind !== "nothing") invalidValue("Abandonment must close its scope immediately, take no arguments and return Nothing");
|
|
1153
|
-
}
|
|
1154
|
-
for (const op of Object.values(ops)) if (op.mode === "immediate" && op.scope && "closes" in op.scope && !scopes.has(op.scope.closes)) invalidValue("A closing scope has no opener");
|
|
1155
|
-
const operations = new Map(Object.keys(ops).sort().map((op) => {
|
|
1156
|
-
const declaration = ops[op];
|
|
1157
|
-
return [op, declaration.mode === "immediate" && (declaration.scope || declaration.segmentBound !== void 0) ? {
|
|
1158
|
-
...declaration,
|
|
1159
|
-
...declaration.scope ? { scope: Object.freeze({ ...declaration.scope }) } : {}
|
|
1160
|
-
} : declaration];
|
|
1161
|
-
}));
|
|
1162
|
-
const def = {
|
|
1163
|
-
name,
|
|
1164
|
-
operations,
|
|
1165
|
-
...release ? { release } : {},
|
|
1166
|
-
...hooks ? { lifecycle: Object.freeze({
|
|
1167
|
-
begin: hooks.begin,
|
|
1168
|
-
commit: hooks.commit,
|
|
1169
|
-
rollback: hooks.rollback
|
|
1170
|
-
}) } : {},
|
|
1171
|
-
...coordinated ? { coordinator: (binding) => coordinated.coordinator(binding) } : {},
|
|
1172
|
-
grant: (granted, binding) => {
|
|
1173
|
-
const names = granted === "all" ? [...operations.keys()] : granted;
|
|
1174
|
-
for (const op of names) if (!operations.has(op)) throw new HostError("invalid value", `${name} has no Operation ${op}`);
|
|
1175
|
-
for (const name of names) {
|
|
1176
|
-
const op = operations.get(name);
|
|
1177
|
-
if (op.mode === "immediate" && op.scope && "opens" in op.scope && !names.includes(op.scope.abandon)) invalidValue("An opener requires its abandonment Operation in the Grant");
|
|
1178
|
-
}
|
|
1179
|
-
const coordinator = def.coordinator?.(binding);
|
|
1180
|
-
if (def.coordinator && !hasHooks(coordinator)) invalidValue("A Segment Coordinator requires synchronous begin, commit and rollback hooks");
|
|
1181
|
-
return {
|
|
1182
|
-
capability: def,
|
|
1183
|
-
binding,
|
|
1184
|
-
ops: new Set(names),
|
|
1185
|
-
...coordinator ? { coordinator } : {}
|
|
1186
|
-
};
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
return def;
|
|
1190
|
-
};
|
|
1191
|
-
//#endregion
|
|
1
|
+
|
|
2
|
+
import { $ as powerOf, $t as parseInstantText, A as listWithItem, At as mod, B as range, Bt as addMonths, Ct as decOf, Dt as formatDec, Et as divide, F as num, Ft as subtract, Gt as civilUs, Ht as civilDays, It as withinLimits, J as UnitError, K as text, Kt as dayOfYear, L as patternValue, Lt as DateRangeError, M as map, Mt as negate, N as mapWithEntry, Nt as powerInteger, O as list, Ot as integerOf, P as nothing, Pt as roundRatio, Q as parseUnit, R as quantity, Rt as US_PER_DAY, St as compareDec, T as instantOf, Tt as div, U as smallInteger, Ut as civilOfDays, Vt as checkInstant, W as smallNumber, Wt as civilOfUs, X as fromBase, Y as combine, Yt as isoWeek, Z as ownUnit, Zt as parseCivil, _ as dec, _t as simpleFold, b as extendList, bt as ArithmeticError, dt as characterBoundaries, en as weekday, et as sameDimension, f as bytesOf, ft as generalCategory, g as compareBytes, gt as scalarCount, h as civilOf, ht as normalizeNFC, j as literalDigits, jt as multiply, k as listValues, kt as isInteger, mt as lower, p as canonicalNumber, pt as isWhiteSpace, q as trimWhiteSpace, rt as unitText, tt as toBase, u as bool, ut as assertScalarText, v as decimalParts, vt as upper, wt as digitsOf, xt as add, y as displayText, z as quantityOf, zt as US_PER_SECOND } from "./errors-LYJZ_c8h.js";
|
|
3
|
+
import { d as shapeDiagnostics, g as runTask, l as pathValue, o as diagnosticRecord, r as decodeShape } from "./capabilities-CH0FkRMq.js";
|
|
1192
4
|
//#region src/generated/machine.ts
|
|
1193
5
|
const instructions = [
|
|
1194
6
|
{
|
|
@@ -2324,7 +1136,9 @@ const instructions = [
|
|
|
2324
1136
|
"operands": [
|
|
2325
1137
|
"grant",
|
|
2326
1138
|
"operation",
|
|
2327
|
-
"count"
|
|
1139
|
+
"count",
|
|
1140
|
+
"target-kind?",
|
|
1141
|
+
"target?"
|
|
2328
1142
|
],
|
|
2329
1143
|
"pops": "count",
|
|
2330
1144
|
"pushes": 0,
|
|
@@ -2333,7 +1147,12 @@ const instructions = [
|
|
|
2333
1147
|
{
|
|
2334
1148
|
"name": "join-send",
|
|
2335
1149
|
"cost": "send",
|
|
2336
|
-
"operands": [
|
|
1150
|
+
"operands": [
|
|
1151
|
+
"message",
|
|
1152
|
+
"count",
|
|
1153
|
+
"target-kind?",
|
|
1154
|
+
"target?"
|
|
1155
|
+
],
|
|
2337
1156
|
"pops": "count + 1",
|
|
2338
1157
|
"pushes": 0,
|
|
2339
1158
|
"suspends": false
|
|
@@ -2341,7 +1160,11 @@ const instructions = [
|
|
|
2341
1160
|
{
|
|
2342
1161
|
"name": "join-send-named",
|
|
2343
1162
|
"cost": "send",
|
|
2344
|
-
"operands": [
|
|
1163
|
+
"operands": [
|
|
1164
|
+
"count",
|
|
1165
|
+
"target-kind?",
|
|
1166
|
+
"target?"
|
|
1167
|
+
],
|
|
2345
1168
|
"pops": "count + 2",
|
|
2346
1169
|
"pushes": 0,
|
|
2347
1170
|
"suspends": false
|
|
@@ -2349,7 +1172,7 @@ const instructions = [
|
|
|
2349
1172
|
{
|
|
2350
1173
|
"name": "join-send-spread",
|
|
2351
1174
|
"cost": "send",
|
|
2352
|
-
"operands": [],
|
|
1175
|
+
"operands": ["target-kind?", "target?"],
|
|
2353
1176
|
"pops": 3,
|
|
2354
1177
|
"pushes": 0,
|
|
2355
1178
|
"suspends": false
|
|
@@ -2447,7 +1270,14 @@ const errorMessages = {
|
|
|
2447
1270
|
"not read-only": "A query must not change the database",
|
|
2448
1271
|
"too many rows": "The statement gave more than {max} rows",
|
|
2449
1272
|
"unrepresentable": "The value in {column} can't be represented",
|
|
2450
|
-
"user busy": "Another prompt is waiting for an answer"
|
|
1273
|
+
"user busy": "Another prompt is waiting for an answer",
|
|
1274
|
+
"invalid serve": "A Serve Registration's {field} isn't valid",
|
|
1275
|
+
"address in use": "That address is already in use",
|
|
1276
|
+
"bad address": "That address can't be served",
|
|
1277
|
+
"invalid response": "The response's {field} isn't valid",
|
|
1278
|
+
"already responded": "That HTTP request has already been answered",
|
|
1279
|
+
"exchange closed": "The client has gone",
|
|
1280
|
+
"not owner": "Only the Run that received this HTTP request can answer it"
|
|
2451
1281
|
};
|
|
2452
1282
|
const reservedErrorKeys = [
|
|
2453
1283
|
"code",
|
|
@@ -3450,6 +2280,11 @@ const costModel = {
|
|
|
3450
2280
|
0,
|
|
3451
2281
|
10,
|
|
3452
2282
|
1
|
|
2283
|
+
], [
|
|
2284
|
+
11,
|
|
2285
|
+
0,
|
|
2286
|
+
1,
|
|
2287
|
+
1
|
|
3453
2288
|
]],
|
|
3454
2289
|
"alloc": [[
|
|
3455
2290
|
1,
|
|
@@ -4016,6 +2851,36 @@ const costModel = {
|
|
|
4016
2851
|
1
|
|
4017
2852
|
]]
|
|
4018
2853
|
},
|
|
2854
|
+
{
|
|
2855
|
+
"key": "builtin.degrees",
|
|
2856
|
+
"fuel": [[
|
|
2857
|
+
0,
|
|
2858
|
+
0,
|
|
2859
|
+
60,
|
|
2860
|
+
1
|
|
2861
|
+
]],
|
|
2862
|
+
"alloc": [[
|
|
2863
|
+
1,
|
|
2864
|
+
2,
|
|
2865
|
+
1,
|
|
2866
|
+
1
|
|
2867
|
+
]]
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
"key": "builtin.radians",
|
|
2871
|
+
"fuel": [[
|
|
2872
|
+
0,
|
|
2873
|
+
0,
|
|
2874
|
+
60,
|
|
2875
|
+
1
|
|
2876
|
+
]],
|
|
2877
|
+
"alloc": [[
|
|
2878
|
+
1,
|
|
2879
|
+
2,
|
|
2880
|
+
1,
|
|
2881
|
+
1
|
|
2882
|
+
]]
|
|
2883
|
+
},
|
|
4019
2884
|
{
|
|
4020
2885
|
"key": "builtin.random",
|
|
4021
2886
|
"fuel": [[
|
|
@@ -4725,7 +3590,7 @@ const makeCostRates = (measure) => [
|
|
|
4725
3590
|
alloc: 0
|
|
4726
3591
|
}),
|
|
4727
3592
|
(m) => ({
|
|
4728
|
-
fuel: 10,
|
|
3593
|
+
fuel: 10 + Math.ceil(1 * (m.steps ?? 0) / 1),
|
|
4729
3594
|
alloc: Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1)
|
|
4730
3595
|
}),
|
|
4731
3596
|
(m) => ({
|
|
@@ -4868,6 +3733,14 @@ const makeCostRates = (measure) => [
|
|
|
4868
3733
|
fuel: 60,
|
|
4869
3734
|
alloc: Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1)
|
|
4870
3735
|
}),
|
|
3736
|
+
(m) => ({
|
|
3737
|
+
fuel: 60,
|
|
3738
|
+
alloc: Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1)
|
|
3739
|
+
}),
|
|
3740
|
+
(m) => ({
|
|
3741
|
+
fuel: 60,
|
|
3742
|
+
alloc: Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1)
|
|
3743
|
+
}),
|
|
4871
3744
|
(m) => ({
|
|
4872
3745
|
fuel: 4,
|
|
4873
3746
|
alloc: Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1)
|
|
@@ -5152,6 +4025,8 @@ const partSize = (of, items, contents) => {
|
|
|
5152
4025
|
return total;
|
|
5153
4026
|
};
|
|
5154
4027
|
const compiledRates = makeCostRates(measureOf);
|
|
4028
|
+
/** Each rate's charge if its formulas measure nothing, else undefined. */
|
|
4029
|
+
const fixedRates = () => rates.map(({ alloc, fuel }, i) => [...alloc, ...fuel].every((term) => term[0] === CONSTANT) ? compiledRates[i](noCounts) : void 0);
|
|
5155
4030
|
/** A Cost Model key's rate, an index that `charge` takes, or -1 if none. */
|
|
5156
4031
|
const rateOf = (key) => rateIndex.get(key) ?? -1;
|
|
5157
4032
|
/** A rate's Fuel and allocation, over what the instruction worked on. */
|
|
@@ -5640,6 +4515,33 @@ const acos = (x) => {
|
|
|
5640
4515
|
});
|
|
5641
4516
|
};
|
|
5642
4517
|
const atan = (x) => atan2(x, ONE$1);
|
|
4518
|
+
const shift = (n, k) => k >= 0 ? n * ten(k) : n / ten(-k);
|
|
4519
|
+
/** x radians in degrees, x × 180/π. */
|
|
4520
|
+
const degrees = (x) => {
|
|
4521
|
+
if (x.coefficient === 0n) return ZERO;
|
|
4522
|
+
return settle((p) => {
|
|
4523
|
+
const q = p + 10 + below(magnitude(x) + 2);
|
|
4524
|
+
const g = Math.max(10, q + magnitude(x) + 5);
|
|
4525
|
+
return {
|
|
4526
|
+
v: shift(signedOf(x) * 180n, x.exponent + q + g) / pi(g),
|
|
4527
|
+
scale: q,
|
|
4528
|
+
err: ERR
|
|
4529
|
+
};
|
|
4530
|
+
});
|
|
4531
|
+
};
|
|
4532
|
+
/** x degrees in radians, x × π/180. */
|
|
4533
|
+
const radians = (x) => {
|
|
4534
|
+
if (x.coefficient === 0n) return ZERO;
|
|
4535
|
+
return settle((p) => {
|
|
4536
|
+
const q = p + 10 + below(magnitude(x) - 2);
|
|
4537
|
+
const g = Math.max(10, q + magnitude(x) + 5);
|
|
4538
|
+
return {
|
|
4539
|
+
v: shift(signedOf(x) * pi(g), x.exponent + q - g) / 180n,
|
|
4540
|
+
scale: q,
|
|
4541
|
+
err: ERR
|
|
4542
|
+
};
|
|
4543
|
+
});
|
|
4544
|
+
};
|
|
5643
4545
|
/** The angle of (x, y), for x and y not both 0. */
|
|
5644
4546
|
const atan2 = (y, x) => {
|
|
5645
4547
|
if (y.coefficient === 0n && !x.negative) return ZERO;
|
|
@@ -5977,59 +4879,57 @@ const runProgram = (program, cs, from, kind, first = false) => {
|
|
|
5977
4879
|
let steps = 0;
|
|
5978
4880
|
let found = null;
|
|
5979
4881
|
let list = [];
|
|
5980
|
-
let
|
|
5981
|
-
const
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
pc
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
4882
|
+
let next = [];
|
|
4883
|
+
const marks = new Uint32Array(code.length);
|
|
4884
|
+
let generation = 1;
|
|
4885
|
+
const emptySlots = Array(slotCount).fill(null);
|
|
4886
|
+
const pending = [];
|
|
4887
|
+
const add = (into, pc, slots, start, pos) => {
|
|
4888
|
+
for (;;) {
|
|
4889
|
+
while (marks[pc] !== generation) {
|
|
4890
|
+
marks[pc] = generation;
|
|
4891
|
+
const op = code[pc];
|
|
4892
|
+
switch (op.op) {
|
|
4893
|
+
case "jump":
|
|
4894
|
+
pc = op.a;
|
|
4895
|
+
continue;
|
|
4896
|
+
case "split":
|
|
4897
|
+
pending.push({
|
|
4898
|
+
pc: op.b,
|
|
4899
|
+
slots
|
|
4900
|
+
});
|
|
4901
|
+
pc = op.a;
|
|
4902
|
+
continue;
|
|
4903
|
+
case "save":
|
|
4904
|
+
slots = slots.slice();
|
|
4905
|
+
slots[op.n] = pos;
|
|
4906
|
+
pc++;
|
|
4907
|
+
continue;
|
|
4908
|
+
case "assert":
|
|
4909
|
+
if (holds(op.k, cs, pos)) {
|
|
4910
|
+
pc++;
|
|
4911
|
+
continue;
|
|
4912
|
+
}
|
|
4913
|
+
break;
|
|
4914
|
+
default: into.push({
|
|
4915
|
+
pc,
|
|
4916
|
+
slots,
|
|
4917
|
+
start
|
|
6011
4918
|
});
|
|
6012
|
-
break;
|
|
6013
4919
|
}
|
|
6014
|
-
|
|
6015
|
-
if (holds(op.k, cs, pos)) pending.push({
|
|
6016
|
-
...t,
|
|
6017
|
-
pc: t.pc + 1
|
|
6018
|
-
});
|
|
6019
|
-
break;
|
|
6020
|
-
default: into.push(t);
|
|
4920
|
+
break;
|
|
6021
4921
|
}
|
|
4922
|
+
const branch = pending.pop();
|
|
4923
|
+
if (!branch) return;
|
|
4924
|
+
pc = branch.pc;
|
|
4925
|
+
slots = branch.slots;
|
|
6022
4926
|
}
|
|
6023
4927
|
};
|
|
6024
4928
|
for (let pos = from; pos <= cs.length; pos++) {
|
|
6025
|
-
if (seeds ? !found : pos === from) add(list,
|
|
6026
|
-
pc: 0,
|
|
6027
|
-
slots: Array(slotCount).fill(null),
|
|
6028
|
-
start: pos
|
|
6029
|
-
}, pos);
|
|
4929
|
+
if (seeds ? !found : pos === from) add(list, 0, emptySlots, pos, pos);
|
|
6030
4930
|
steps += list.length;
|
|
6031
|
-
|
|
6032
|
-
|
|
4931
|
+
next.length = 0;
|
|
4932
|
+
generation++;
|
|
6033
4933
|
for (const t of list) {
|
|
6034
4934
|
const op = code[t.pc];
|
|
6035
4935
|
if (op.op === "match") {
|
|
@@ -6047,12 +4947,11 @@ const runProgram = (program, cs, from, kind, first = false) => {
|
|
|
6047
4947
|
}
|
|
6048
4948
|
if (pos === cs.length) continue;
|
|
6049
4949
|
const ch = cs[pos];
|
|
6050
|
-
if (op.op === "char" ? op.fold === null ? op.c === ch : op.fold === simpleFold(ch) : op.op === "class" && inClass(op.k, ch)) add(next,
|
|
6051
|
-
...t,
|
|
6052
|
-
pc: t.pc + 1
|
|
6053
|
-
}, pos + 1);
|
|
4950
|
+
if (op.op === "char" ? op.fold === null ? op.c === ch : op.fold === simpleFold(ch) : op.op === "class" && inClass(op.k, ch)) add(next, t.pc + 1, t.slots, t.start, pos + 1);
|
|
6054
4951
|
}
|
|
4952
|
+
const spare = list;
|
|
6055
4953
|
list = next;
|
|
4954
|
+
next = spare;
|
|
6056
4955
|
if (!list.length && (found || !seeds)) break;
|
|
6057
4956
|
}
|
|
6058
4957
|
return {
|
|
@@ -6449,9 +5348,16 @@ const comparison = (op, a, b, fold) => {
|
|
|
6449
5348
|
scanned
|
|
6450
5349
|
};
|
|
6451
5350
|
}
|
|
6452
|
-
const
|
|
6453
|
-
const
|
|
6454
|
-
|
|
5351
|
+
const x = smallOf(a);
|
|
5352
|
+
const y = smallOf(b);
|
|
5353
|
+
let scanned = 0;
|
|
5354
|
+
let o;
|
|
5355
|
+
if (!Number.isNaN(x) && !Number.isNaN(y)) o = x < y ? -1 : x > y ? 1 : 0;
|
|
5356
|
+
else {
|
|
5357
|
+
const comparer = new Comparer(fold);
|
|
5358
|
+
scanned = comparer.scanned(a, b);
|
|
5359
|
+
o = orderBy(comparer, a, b);
|
|
5360
|
+
}
|
|
6455
5361
|
return {
|
|
6456
5362
|
result: bool(op === "less" ? o < 0 : op === "greater" ? o > 0 : op === "less-or-equal" ? o <= 0 : o >= 0),
|
|
6457
5363
|
scanned
|
|
@@ -6562,12 +5468,18 @@ const inRangeDate = (make) => {
|
|
|
6562
5468
|
}
|
|
6563
5469
|
};
|
|
6564
5470
|
const durationUs = (q) => {
|
|
6565
|
-
const
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
5471
|
+
const base = inBase(q);
|
|
5472
|
+
const exponent = base.exponent + 6;
|
|
5473
|
+
let us = base.coefficient;
|
|
5474
|
+
if (exponent >= 0) us *= 10n ** BigInt(exponent);
|
|
5475
|
+
else if (exponent < -34) us = 0n;
|
|
5476
|
+
else {
|
|
5477
|
+
const divisor = 10n ** BigInt(-exponent);
|
|
5478
|
+
const whole = us / divisor;
|
|
5479
|
+
const twice = 2n * (us % divisor);
|
|
5480
|
+
us = whole + BigInt(twice > divisor || twice === divisor && whole % 2n === 1n);
|
|
5481
|
+
}
|
|
5482
|
+
return base.negative ? -us : us;
|
|
6571
5483
|
};
|
|
6572
5484
|
/** `wait d`'s duration in microseconds; anything but an exact duration is `wrong kind`. */
|
|
6573
5485
|
const waitUs = (v) => {
|
|
@@ -6622,7 +5534,20 @@ const dateArithmetic = (op, a, b) => {
|
|
|
6622
5534
|
if (us % US_PER_DAY !== 0n) throw incompatible(DAYS, q.unit);
|
|
6623
5535
|
return inRangeDate(() => civilOf(civilOfDays(civilDays(c) + us / US_PER_DAY, null)));
|
|
6624
5536
|
};
|
|
5537
|
+
/**
|
|
5538
|
+
* Add, subtract or multiply two small integers (see `smallInteger`), or
|
|
5539
|
+
* undefined when either isn't one or the result isn't a safe integer. The
|
|
5540
|
+
* exact result needs no rounding, so it equals the Decimal path's.
|
|
5541
|
+
*/
|
|
5542
|
+
const smallArithmetic = (op, x, y) => {
|
|
5543
|
+
const r = op === "add" ? x + y : op === "subtract" ? x - y : op === "multiply" ? x * y : NaN;
|
|
5544
|
+
return Number.isSafeInteger(r) ? smallNumber(r) : void 0;
|
|
5545
|
+
};
|
|
5546
|
+
/** A number Value's small integer, or NaN. */
|
|
5547
|
+
const smallOf = (v) => v.kind === "number" ? smallInteger(v.asDecimal()) : NaN;
|
|
6625
5548
|
const arithmetic = (op, a, b) => {
|
|
5549
|
+
const small = smallArithmetic(op, smallOf(a), smallOf(b));
|
|
5550
|
+
if (small) return small;
|
|
6626
5551
|
if (isDate(a) || isDate(b)) try {
|
|
6627
5552
|
return dateArithmetic(op, a, b);
|
|
6628
5553
|
} catch (error) {
|
|
@@ -7023,6 +5948,15 @@ const chunkThere = (kind, indexValue, whole, delimiter) => {
|
|
|
7023
5948
|
const writeOutOfRange = (kind, index) => outOfRange(kind, index.range ? list(index.written.asRange().from, index.written.asRange().to) : index.written);
|
|
7024
5949
|
/** One chunk level of a write: the new whole, with `part` in the chunk's place. */
|
|
7025
5950
|
const chunkSet = (kind, indexValue, whole, part, delimiter) => {
|
|
5951
|
+
if (kind === "item" && whole.kind === "list") {
|
|
5952
|
+
const written = smallOf(indexValue);
|
|
5953
|
+
const i = written < 0 ? whole.length + written : written - 1;
|
|
5954
|
+
if (i >= 0 && i < whole.length) {
|
|
5955
|
+
const result = listWithItem(whole, i, part);
|
|
5956
|
+
cacheListEdit(result, whole, i, part);
|
|
5957
|
+
return result;
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
7026
5960
|
const index = indexOf(indexValue);
|
|
7027
5961
|
if (whole.kind === "text" && textKinds.has(kind)) {
|
|
7028
5962
|
const d = delimiterText(delimiter);
|
|
@@ -7423,7 +6357,9 @@ const unary = {
|
|
|
7423
6357
|
tan,
|
|
7424
6358
|
asin,
|
|
7425
6359
|
acos,
|
|
7426
|
-
atan
|
|
6360
|
+
atan,
|
|
6361
|
+
degrees,
|
|
6362
|
+
radians
|
|
7427
6363
|
};
|
|
7428
6364
|
const ONE = {
|
|
7429
6365
|
negative: false,
|
|
@@ -7626,7 +6562,9 @@ const builtin = (name, args, measure = {}) => {
|
|
|
7626
6562
|
case "asin":
|
|
7627
6563
|
case "acos":
|
|
7628
6564
|
case "atan":
|
|
7629
|
-
case "atan2":
|
|
6565
|
+
case "atan2":
|
|
6566
|
+
case "degrees":
|
|
6567
|
+
case "radians": return { result: numberFunction(name, args) };
|
|
7630
6568
|
case "fromFloat64":
|
|
7631
6569
|
case "fromFloat32": return { result: fromFloat(name, x, y) };
|
|
7632
6570
|
case "toFloat64":
|
|
@@ -7680,113 +6618,4 @@ const fromBase64 = (s) => {
|
|
|
7680
6618
|
return toBase64(out) === s ? out : void 0;
|
|
7681
6619
|
};
|
|
7682
6620
|
//#endregion
|
|
7683
|
-
|
|
7684
|
-
const reserved = new Set(grammar.reserved);
|
|
7685
|
-
const allowed = new Set(grammar.labels.reserved);
|
|
7686
|
-
const excluded = new Set(grammar.labels.excluded);
|
|
7687
|
-
const name = (part) => part !== "_" && /^[A-Z_a-z]\w*$/.exec(part)?.[0] === part;
|
|
7688
|
-
const validMessageSelector = (message, arity) => {
|
|
7689
|
-
if (!message.includes(":")) return true;
|
|
7690
|
-
const parts = message.split(":");
|
|
7691
|
-
if (parts.pop() !== "" || parts.length < 2 || parts.length !== arity) return false;
|
|
7692
|
-
const first = parts.shift();
|
|
7693
|
-
return name(first) && first !== "all" && !reserved.has(first) && parts.every((part) => name(part) && (!reserved.has(part) || allowed.has(part)) && !excluded.has(part));
|
|
7694
|
-
};
|
|
7695
|
-
const validComputedMessageName = (message, arity) => message.includes(":") ? validMessageSelector(message, arity) : name(message) && message !== "all" && !reserved.has(message);
|
|
7696
|
-
//#endregion
|
|
7697
|
-
//#region src/standard-capability-checks.ts
|
|
7698
|
-
const checks = /* @__PURE__ */ new WeakMap();
|
|
7699
|
-
const registerStandardChecks = (op, rules) => {
|
|
7700
|
-
checks.set(op, rules);
|
|
7701
|
-
};
|
|
7702
|
-
const standardChecks = (op) => checks.get(op);
|
|
7703
|
-
//#endregion
|
|
7704
|
-
//#region src/encoding.ts
|
|
7705
|
-
/** The spec's JSON string form: every U+0000..U+001F uses lowercase \u00xx. */
|
|
7706
|
-
const quoteJSON = (s) => "\"" + s.replaceAll(/[\u0000-\u001f"\\]/g, (ch) => ch === "\"" ? String.raw`\"` : ch === "\\" ? "\\\\" : String.raw`\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`) + "\"";
|
|
7707
|
-
const encodeValue = (value, adapter) => {
|
|
7708
|
-
requireValue(value);
|
|
7709
|
-
const pending = [value];
|
|
7710
|
-
const output = [];
|
|
7711
|
-
while (pending.length) {
|
|
7712
|
-
const next = pending.pop();
|
|
7713
|
-
if (typeof next === "string") {
|
|
7714
|
-
output.push(next);
|
|
7715
|
-
continue;
|
|
7716
|
-
}
|
|
7717
|
-
switch (next.kind) {
|
|
7718
|
-
case "nothing":
|
|
7719
|
-
output.push("null");
|
|
7720
|
-
break;
|
|
7721
|
-
case "boolean":
|
|
7722
|
-
output.push(next.asBool() ? "true" : "false");
|
|
7723
|
-
break;
|
|
7724
|
-
case "text":
|
|
7725
|
-
output.push(quoteJSON(next.asText()));
|
|
7726
|
-
break;
|
|
7727
|
-
case "number": {
|
|
7728
|
-
const canonical = next.asDecimal().toString();
|
|
7729
|
-
output.push(!canonical.includes(".") && BigInt(canonical) > -(2n ** 53n) && BigInt(canonical) < 2n ** 53n ? canonical : `{"$dec":${quoteJSON(canonical)}}`);
|
|
7730
|
-
break;
|
|
7731
|
-
}
|
|
7732
|
-
case "instant":
|
|
7733
|
-
output.push(`{"$instant":${quoteJSON(next.toString())}}`);
|
|
7734
|
-
break;
|
|
7735
|
-
case "civil date":
|
|
7736
|
-
output.push(`{"$date":${quoteJSON(next.toString())}}`);
|
|
7737
|
-
break;
|
|
7738
|
-
case "object": {
|
|
7739
|
-
const o = next.asObjectRef();
|
|
7740
|
-
output.push(`{"$object":[${quoteJSON(o.kind)},${quoteJSON(o.id)}]}`);
|
|
7741
|
-
break;
|
|
7742
|
-
}
|
|
7743
|
-
case "bytes":
|
|
7744
|
-
output.push(`{"$bytes":${quoteJSON(toBase64(next.bytesView()))}}`);
|
|
7745
|
-
break;
|
|
7746
|
-
case "quantity": {
|
|
7747
|
-
const q = next.asQuantity();
|
|
7748
|
-
output.push(`{"$quantity":[${quoteJSON(q.number.toString())},${quoteJSON(q.unit)}]}`);
|
|
7749
|
-
break;
|
|
7750
|
-
}
|
|
7751
|
-
case "range": {
|
|
7752
|
-
const { from, to } = next.asRange();
|
|
7753
|
-
output.push("{\"$range\":[");
|
|
7754
|
-
pending.push("]}", to, ",", from);
|
|
7755
|
-
break;
|
|
7756
|
-
}
|
|
7757
|
-
case "list":
|
|
7758
|
-
output.push("[");
|
|
7759
|
-
pending.push("]");
|
|
7760
|
-
for (let i = next.length; i >= 1; i--) {
|
|
7761
|
-
if (i < next.length) pending.push(",");
|
|
7762
|
-
pending.push(next.index(i));
|
|
7763
|
-
}
|
|
7764
|
-
break;
|
|
7765
|
-
case "map": {
|
|
7766
|
-
const entries = next.entries();
|
|
7767
|
-
const tagged = entries.some(([k]) => k.startsWith("$"));
|
|
7768
|
-
output.push(tagged ? "{\"$map\":[" : "{");
|
|
7769
|
-
pending.push(tagged ? "]}" : "}");
|
|
7770
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
7771
|
-
const [k, v] = entries[i];
|
|
7772
|
-
if (i < entries.length - 1) pending.push(",");
|
|
7773
|
-
if (tagged) pending.push("]", v, `[${quoteJSON(k)},`);
|
|
7774
|
-
else pending.push(v, `${quoteJSON(k)}:`);
|
|
7775
|
-
}
|
|
7776
|
-
break;
|
|
7777
|
-
}
|
|
7778
|
-
case "function":
|
|
7779
|
-
case "pattern":
|
|
7780
|
-
if (adapter) {
|
|
7781
|
-
output.push(adapter(next));
|
|
7782
|
-
break;
|
|
7783
|
-
}
|
|
7784
|
-
invalidValue(`The Value Encoding of a ${next.kind} isn't implemented yet`);
|
|
7785
|
-
break;
|
|
7786
|
-
default: invalidValue(`The Value Encoding of a ${next.kind} isn't implemented yet`);
|
|
7787
|
-
}
|
|
7788
|
-
}
|
|
7789
|
-
return output.join("");
|
|
7790
|
-
};
|
|
7791
|
-
//#endregion
|
|
7792
|
-
export { arityOf as $, isEmpty as A, prepareConversion as B, convert as C, RESERVED as Ct, getKey as D, equals as E, matchCaptures as F, splice as G, randomBound as H, matchesOf as I, wrongKind as J, textForm as K, member as L, keyText as M, makePatternValue as N, hasKey as O, makeRange as P, sizeOf as Q, negated as R, concat as S, Lexer as St, deleteKey as T, search as U, property as V, setKey as W, partSize as X, charge as Y, rateOf as Z, chunkDelete as _, acceptsArgumentCount as _t, validComputedMessageName as a, numberText as at, chunkThere as b, mismatch as bt, toBase64 as c, splicesOf as ct, appendTo as d, costModel as dt, disassemble as et, arithmetic as f, errorMessages as ft, canConvert as g, LimitReached as gt, byteOf as h, reservedErrorKeys as ht, standardChecks as i, capturesOf$1 as it, isKind as j, integerValue as k, NotImplementedError as l, textDisplay as lt, builtinDefaults as m, limitDefaults as mt, quoteJSON as n, instructionSpec as nt, validMessageSelector as o, patternSource as ot, builtin as p, languageVersion as pt, waitUs as q, registerStandardChecks as r, opcodes as rt, fromBase64 as s, quantityText as st, encodeValue as t, functionHead as tt, ScriptError as u, compareText as ut, chunkGet as v, defineCapability as vt, decodeUtf8 as w, runTask as wt, comparison as x, shape as xt, chunkSet as y, expectedOf as yt, outOfRange as z };
|
|
6621
|
+
export { instructionSpec as $, matchesOf as A, smallOf as B, integerValue as C, makePatternValue as D, keyText as E, property as F, charge as G, textForm as H, randomBound as I, rateOf as J, fixedRates as K, search as L, negated as M, outOfRange as N, makeRange as O, prepareConversion as P, functionHead as Q, setKey as R, hasKey as S, isKind as T, waitUs as U, splice as V, wrongKind as W, arityOf as X, sizeOf as Y, disassemble as Z, convert as _, appendTo as a, splicesOf as at, equals as b, builtinDefaults as c, costModel as ct, chunkDelete as d, limitDefaults as dt, opcodes as et, chunkGet as f, reservedErrorKeys as ft, concat as g, comparison as h, ScriptError as i, quantityText as it, member as j, matchCaptures as k, byteOf as l, errorMessages as lt, chunkThere as m, toBase64 as n, numberText as nt, arithmetic as o, textDisplay as ot, chunkSet as p, partSize as q, NotImplementedError as r, patternSource as rt, builtin as s, compareText as st, fromBase64 as t, capturesOf$1 as tt, canConvert as u, languageVersion as ut, decodeUtf8 as v, isEmpty as w, getKey as x, deleteKey as y, smallArithmetic as z };
|