@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,3065 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/syntax.d.ts
|
|
3
|
+
type SyntaxErrorCode = 'unterminated interpolation' | 'empty interpolation' | 'invalid text escape' | 'invalid text indentation' | 'invalid text delimiter' | 'bad character' | 'unterminated text' | 'bad unit' | 'unexpected token' | 'not a container';
|
|
4
|
+
/** All offsets index the original TS string; line and col count Unicode scalars. */
|
|
5
|
+
type Trivia = {
|
|
6
|
+
col: number;
|
|
7
|
+
end: number;
|
|
8
|
+
kind: 'bom' | 'space' | 'comment' | 'continuation';
|
|
9
|
+
line: number;
|
|
10
|
+
pos: number;
|
|
11
|
+
raw: string;
|
|
12
|
+
};
|
|
13
|
+
type SyntaxRule = 'Source' | 'Entry' | 'Error' | 'Declaration' | 'Use' | 'Handler' | 'Parameter' | 'Function' | 'Block' | 'Body' | 'Statement' | 'SimpleStatement' | 'ExpressionList' | 'Container' | 'AndWait' | 'ResultTarget' | 'Send' | 'AskTell' | 'TellBlock' | 'TimeoutBlock' | 'OperationLine' | 'Wait' | 'Event' | 'If' | 'Repeat' | 'Collecting' | 'Match' | 'Try' | 'OfferClause' | 'OfferParameter' | 'RecoveryMarker' | 'ChooseOffer' | 'Replace' | 'IgnoringCase' | 'Expression' | 'Lambda' | 'Whose' | 'EveryHead' | 'WhoseKey' | 'Default' | 'Or' | 'And' | 'Not' | 'Comparison' | 'Concat' | 'Range' | 'Additive' | 'Multiplicative' | 'Power' | 'Unary' | 'Conversion' | 'Kind' | 'ChunkLevel' | 'Postfix' | 'Key' | 'Call' | 'Primary' | 'Interpolated' | 'Chunk' | 'The' | 'List' | 'MapKey' | 'Map' | 'Pattern' | 'PatternPrimary' | 'TextPattern' | 'Alternation' | 'Element' | 'Atom' | 'BinaryPattern' | 'Field' | 'AsText' | 'FieldType' | 'BinaryBuild' | 'Name' | 'MessageName' | 'Label';
|
|
14
|
+
type SyntaxElement = SyntaxNode | Token;
|
|
15
|
+
/** Children are ordered and own each source character exactly once. Spans include trivia. */
|
|
16
|
+
type SyntaxNode = {
|
|
17
|
+
children: readonly SyntaxElement[];
|
|
18
|
+
end: number;
|
|
19
|
+
kind: 'node';
|
|
20
|
+
rule: SyntaxRule;
|
|
21
|
+
start: number;
|
|
22
|
+
};
|
|
23
|
+
/** Reconstruct source by walking the tree, without retaining a second source copy. */
|
|
24
|
+
declare const syntaxText: (tree: SyntaxNode) => string;
|
|
25
|
+
/** A labelled message uses its Selector as its semantic and dispatch name. */
|
|
26
|
+
declare const syntaxSelector: (node: SyntaxNode, name: string) => string;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/lexer.d.ts
|
|
29
|
+
type Mode = 'operand' | 'operator' | 'pattern' | 'unit' | 'type';
|
|
30
|
+
type TokType = 'num' | 'str' | 'template' | 'word' | 'op' | 'unit' | 'patopen' | 'patclose' | 'binopen' | 'nl' | 'eof' | 'error';
|
|
31
|
+
type Token = {
|
|
32
|
+
code?: SyntaxErrorCode;
|
|
33
|
+
col: number;
|
|
34
|
+
end: number;
|
|
35
|
+
incomplete?: boolean;
|
|
36
|
+
kind: 'token';
|
|
37
|
+
leadingTrivia: readonly Trivia[];
|
|
38
|
+
line: number;
|
|
39
|
+
mode: Mode;
|
|
40
|
+
parts?: TextPart[];
|
|
41
|
+
pos: number;
|
|
42
|
+
raw: string;
|
|
43
|
+
spaceBefore: boolean;
|
|
44
|
+
t: TokType;
|
|
45
|
+
v: string;
|
|
46
|
+
};
|
|
47
|
+
type TextPart = {
|
|
48
|
+
end: number;
|
|
49
|
+
hole?: {
|
|
50
|
+
at: number;
|
|
51
|
+
end: number;
|
|
52
|
+
start: number;
|
|
53
|
+
};
|
|
54
|
+
start: number;
|
|
55
|
+
value: string;
|
|
56
|
+
};
|
|
57
|
+
declare class Lexer {
|
|
58
|
+
readonly src: string;
|
|
59
|
+
private readonly fences;
|
|
60
|
+
private readonly lineStarts;
|
|
61
|
+
private readonly surrogateOffsets;
|
|
62
|
+
constructor(src: string);
|
|
63
|
+
where(pos: number): {
|
|
64
|
+
col: number;
|
|
65
|
+
line: number;
|
|
66
|
+
};
|
|
67
|
+
private surrogatesBefore;
|
|
68
|
+
tok(t: TokType, v: string, pos: number, end: number, spaceBefore: boolean, mode: Mode, code?: SyntaxErrorCode): Token;
|
|
69
|
+
private trivia;
|
|
70
|
+
private fenced;
|
|
71
|
+
private scanFenced;
|
|
72
|
+
lex(start: number, mode: Mode): Token;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/semantic.d.ts
|
|
76
|
+
/** Half-open UTF-16 offsets, with a 1-based Unicode scalar start position. */
|
|
77
|
+
type SourceSpan = {
|
|
78
|
+
col: number;
|
|
79
|
+
end: number;
|
|
80
|
+
line: number;
|
|
81
|
+
start: number;
|
|
82
|
+
};
|
|
83
|
+
type BindingKind = 'local' | 'parameter' | 'script variable' | 'constant' | 'function' | 'handler' | 'object' | 'builtin constant' | 'builtin function';
|
|
84
|
+
type ExportKind = 'constant' | 'function' | 'handler';
|
|
85
|
+
/** Argument counts accepted by a statically named function. */
|
|
86
|
+
type FunctionContract = {
|
|
87
|
+
required: number;
|
|
88
|
+
total: number;
|
|
89
|
+
/** Takes any number of arguments past `required`. */
|
|
90
|
+
variadic?: boolean;
|
|
91
|
+
};
|
|
92
|
+
type LibraryExport = ExportKind | {
|
|
93
|
+
contract?: FunctionContract;
|
|
94
|
+
kind: ExportKind;
|
|
95
|
+
maySuspend?: boolean;
|
|
96
|
+
};
|
|
97
|
+
type Binding = {
|
|
98
|
+
contract?: FunctionContract;
|
|
99
|
+
id: number;
|
|
100
|
+
importedFrom?: {
|
|
101
|
+
library: string;
|
|
102
|
+
name: string;
|
|
103
|
+
};
|
|
104
|
+
initial: 'nothing' | 'parameter' | 'declaration';
|
|
105
|
+
kind: BindingKind;
|
|
106
|
+
name: string;
|
|
107
|
+
scope: number;
|
|
108
|
+
span: SourceSpan | null;
|
|
109
|
+
};
|
|
110
|
+
type SemanticScope = {
|
|
111
|
+
bindings: readonly Binding[];
|
|
112
|
+
captures: readonly Binding[];
|
|
113
|
+
id: number;
|
|
114
|
+
kind: 'unit' | 'handler' | 'function' | 'lambda';
|
|
115
|
+
parent: number | null;
|
|
116
|
+
};
|
|
117
|
+
type NameRole = 'declaration' | 'binding' | 'capture' | 'value' | 'call' | 'write' | 'binary size' | 'command' | 'message' | 'offer' | 'grant' | 'receiver' | 'import' | 'library';
|
|
118
|
+
type SemanticName = {
|
|
119
|
+
binding: Binding | null;
|
|
120
|
+
kind: 'name';
|
|
121
|
+
role: NameRole;
|
|
122
|
+
span: SourceSpan;
|
|
123
|
+
text: string;
|
|
124
|
+
};
|
|
125
|
+
type SemanticToken = {
|
|
126
|
+
kind: 'token';
|
|
127
|
+
raw: string;
|
|
128
|
+
span: SourceSpan;
|
|
129
|
+
text: string;
|
|
130
|
+
type: Exclude<TokType, 'nl' | 'eof' | 'error'>;
|
|
131
|
+
};
|
|
132
|
+
/** Production/operator structure is retained for lowering; trivia is omitted. */
|
|
133
|
+
type SemanticNode = {
|
|
134
|
+
children: readonly SemanticElement[];
|
|
135
|
+
kind: 'node';
|
|
136
|
+
rule: SyntaxRule;
|
|
137
|
+
scope: number;
|
|
138
|
+
span: SourceSpan;
|
|
139
|
+
};
|
|
140
|
+
type SemanticElement = SemanticNode | SemanticName | SemanticToken;
|
|
141
|
+
type SemanticTree = {
|
|
142
|
+
/**
|
|
143
|
+
* Each Host Command call, as `offset grant.operation tell|ask`, in source
|
|
144
|
+
* order. Resolution depends on the Grants, so it joins the compile cache key.
|
|
145
|
+
*/
|
|
146
|
+
commands?: readonly string[];
|
|
147
|
+
/** Each top-level declaration's Declaration Documentation, in source order. */
|
|
148
|
+
docs?: readonly string[];
|
|
149
|
+
/** The unit's Handlers that may suspend (chapter 5, Suspension Points). */
|
|
150
|
+
maySuspend?: readonly string[];
|
|
151
|
+
root: SemanticNode;
|
|
152
|
+
scopes: readonly SemanticScope[];
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/view.d.ts
|
|
156
|
+
type Pos = {
|
|
157
|
+
col: number;
|
|
158
|
+
line: number;
|
|
159
|
+
};
|
|
160
|
+
type Expr = {
|
|
161
|
+
k: 'number';
|
|
162
|
+
pos: Pos;
|
|
163
|
+
text: string;
|
|
164
|
+
} | {
|
|
165
|
+
k: 'quantity';
|
|
166
|
+
number: string;
|
|
167
|
+
pos: Pos;
|
|
168
|
+
unit: string;
|
|
169
|
+
} | {
|
|
170
|
+
k: 'text';
|
|
171
|
+
pos: Pos;
|
|
172
|
+
value: string;
|
|
173
|
+
} | {
|
|
174
|
+
k: 'literal';
|
|
175
|
+
pos: Pos;
|
|
176
|
+
value: 'true' | 'false' | 'nothing';
|
|
177
|
+
} | {
|
|
178
|
+
k: 'me';
|
|
179
|
+
pos: Pos;
|
|
180
|
+
} | {
|
|
181
|
+
k: 'target';
|
|
182
|
+
pos: Pos;
|
|
183
|
+
} | {
|
|
184
|
+
k: 'name';
|
|
185
|
+
name: SemanticName;
|
|
186
|
+
pos: Pos;
|
|
187
|
+
} | {
|
|
188
|
+
k: 'pin';
|
|
189
|
+
name: SemanticName;
|
|
190
|
+
pos: Pos;
|
|
191
|
+
} | {
|
|
192
|
+
fold: boolean;
|
|
193
|
+
k: 'binary';
|
|
194
|
+
l: Expr;
|
|
195
|
+
op: string;
|
|
196
|
+
pos: Pos;
|
|
197
|
+
r: Expr;
|
|
198
|
+
} | {
|
|
199
|
+
fold: boolean;
|
|
200
|
+
k: 'member';
|
|
201
|
+
l: Expr;
|
|
202
|
+
neg: boolean;
|
|
203
|
+
pos: Pos;
|
|
204
|
+
r: Expr;
|
|
205
|
+
} | {
|
|
206
|
+
k: 'is-kind';
|
|
207
|
+
kind: string;
|
|
208
|
+
l: Expr;
|
|
209
|
+
neg: boolean;
|
|
210
|
+
pos: Pos;
|
|
211
|
+
} | {
|
|
212
|
+
k: 'is-empty';
|
|
213
|
+
l: Expr;
|
|
214
|
+
neg: boolean;
|
|
215
|
+
pos: Pos;
|
|
216
|
+
} | {
|
|
217
|
+
e: Expr;
|
|
218
|
+
k: 'can-convert' | 'convert';
|
|
219
|
+
kind: string;
|
|
220
|
+
pos: Pos;
|
|
221
|
+
} | {
|
|
222
|
+
e: Expr;
|
|
223
|
+
k: 'not' | 'negate';
|
|
224
|
+
pos: Pos;
|
|
225
|
+
} | {
|
|
226
|
+
k: 'and' | 'or' | 'otherwise';
|
|
227
|
+
l: Expr;
|
|
228
|
+
pos: Pos;
|
|
229
|
+
r: Expr;
|
|
230
|
+
} | {
|
|
231
|
+
base: Expr;
|
|
232
|
+
k: 'key';
|
|
233
|
+
key: string;
|
|
234
|
+
optional?: boolean;
|
|
235
|
+
pos: Pos;
|
|
236
|
+
} | {
|
|
237
|
+
base: Expr;
|
|
238
|
+
k: 'computed';
|
|
239
|
+
key: Expr;
|
|
240
|
+
optional?: boolean;
|
|
241
|
+
pos: Pos;
|
|
242
|
+
} | {
|
|
243
|
+
base: Expr;
|
|
244
|
+
delimiter: Expr | null;
|
|
245
|
+
k: 'property';
|
|
246
|
+
name: string;
|
|
247
|
+
pos: Pos;
|
|
248
|
+
} | {
|
|
249
|
+
base: Expr;
|
|
250
|
+
delimiter: Expr | null;
|
|
251
|
+
index: Expr | number;
|
|
252
|
+
k: 'chunk';
|
|
253
|
+
kind: string;
|
|
254
|
+
pos: Pos;
|
|
255
|
+
} | {
|
|
256
|
+
base: Expr;
|
|
257
|
+
index: Expr | number;
|
|
258
|
+
k: 'element';
|
|
259
|
+
pos: Pos;
|
|
260
|
+
} | {
|
|
261
|
+
base: Expr;
|
|
262
|
+
k: 'element-count';
|
|
263
|
+
pos: Pos;
|
|
264
|
+
} | {
|
|
265
|
+
items: {
|
|
266
|
+
e: Expr;
|
|
267
|
+
spread: boolean;
|
|
268
|
+
}[];
|
|
269
|
+
k: 'list';
|
|
270
|
+
pos: Pos;
|
|
271
|
+
} | {
|
|
272
|
+
entries: {
|
|
273
|
+
key: string;
|
|
274
|
+
value: Expr;
|
|
275
|
+
}[];
|
|
276
|
+
k: 'map';
|
|
277
|
+
pos: Pos;
|
|
278
|
+
} | {
|
|
279
|
+
k: 'pattern';
|
|
280
|
+
pattern: TextPattern;
|
|
281
|
+
pos: Pos;
|
|
282
|
+
} | {
|
|
283
|
+
fields: BuildField[];
|
|
284
|
+
k: 'build';
|
|
285
|
+
pos: Pos;
|
|
286
|
+
} | {
|
|
287
|
+
k: 'match-all';
|
|
288
|
+
pat: Expr;
|
|
289
|
+
pos: Pos;
|
|
290
|
+
src: Expr;
|
|
291
|
+
} | Replace | {
|
|
292
|
+
args: Expr[];
|
|
293
|
+
k: 'call';
|
|
294
|
+
name: SemanticName;
|
|
295
|
+
pos: Pos;
|
|
296
|
+
} | Lambda | Whose | {
|
|
297
|
+
k: 'whose-it';
|
|
298
|
+
pos: Pos;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* `every K of x whose c`, or `the o K of x whose c` (ADR 0074). `index` is
|
|
302
|
+
* the ordinal's, -1 for `last`, or null for `every`; `at` is the chunk word.
|
|
303
|
+
*/
|
|
304
|
+
type Whose = {
|
|
305
|
+
at: Pos;
|
|
306
|
+
cond: Expr;
|
|
307
|
+
delimiter: Expr | null;
|
|
308
|
+
index: number | null;
|
|
309
|
+
k: 'whose';
|
|
310
|
+
kind: string;
|
|
311
|
+
pos: Pos;
|
|
312
|
+
src: Expr;
|
|
313
|
+
};
|
|
314
|
+
type Replace = {
|
|
315
|
+
first: boolean;
|
|
316
|
+
k: 'replace';
|
|
317
|
+
pat: Expr;
|
|
318
|
+
pos: Pos;
|
|
319
|
+
target: Expr;
|
|
320
|
+
value: Expr;
|
|
321
|
+
};
|
|
322
|
+
type Lambda = {
|
|
323
|
+
body: Expr | Stmt[];
|
|
324
|
+
end: Pos | null;
|
|
325
|
+
k: 'lambda';
|
|
326
|
+
params: Pattern[];
|
|
327
|
+
pos: Pos;
|
|
328
|
+
scope: number;
|
|
329
|
+
};
|
|
330
|
+
type TextPattern = {
|
|
331
|
+
els: PatternElement[];
|
|
332
|
+
pos: Pos;
|
|
333
|
+
};
|
|
334
|
+
type PatternElement = {
|
|
335
|
+
k: 'text';
|
|
336
|
+
value: string;
|
|
337
|
+
} | {
|
|
338
|
+
e: PatternElement;
|
|
339
|
+
k: 'count';
|
|
340
|
+
n: string;
|
|
341
|
+
} | {
|
|
342
|
+
els: PatternElement[];
|
|
343
|
+
k: 'group';
|
|
344
|
+
} | {
|
|
345
|
+
e: Expr;
|
|
346
|
+
k: 'splice';
|
|
347
|
+
} | {
|
|
348
|
+
e: PatternElement;
|
|
349
|
+
k: 'capture';
|
|
350
|
+
name: SemanticName;
|
|
351
|
+
} | {
|
|
352
|
+
k: 'words';
|
|
353
|
+
words: string;
|
|
354
|
+
} | {
|
|
355
|
+
e: PatternElement;
|
|
356
|
+
k: 'repeat';
|
|
357
|
+
phrase: 'one or more of' | 'zero or more of' | 'optional';
|
|
358
|
+
} | {
|
|
359
|
+
k: 'typed';
|
|
360
|
+
kind: string;
|
|
361
|
+
} | {
|
|
362
|
+
k: 'alternation';
|
|
363
|
+
options: PatternElement[];
|
|
364
|
+
} | {
|
|
365
|
+
as: string | null;
|
|
366
|
+
e: PatternElement;
|
|
367
|
+
fold: boolean;
|
|
368
|
+
k: 'suffixed';
|
|
369
|
+
lazily: boolean;
|
|
370
|
+
};
|
|
371
|
+
type Literal = {
|
|
372
|
+
k: 'number';
|
|
373
|
+
negative: boolean;
|
|
374
|
+
text: string;
|
|
375
|
+
unit: string | null;
|
|
376
|
+
} | {
|
|
377
|
+
k: 'text';
|
|
378
|
+
value: string;
|
|
379
|
+
} | {
|
|
380
|
+
k: 'word';
|
|
381
|
+
value: 'true' | 'false' | 'nothing';
|
|
382
|
+
};
|
|
383
|
+
type Pattern = {
|
|
384
|
+
k: 'bind';
|
|
385
|
+
name: SemanticName;
|
|
386
|
+
pos: Pos;
|
|
387
|
+
} | {
|
|
388
|
+
k: 'wildcard';
|
|
389
|
+
pos: Pos;
|
|
390
|
+
} | {
|
|
391
|
+
k: 'as';
|
|
392
|
+
name: SemanticName;
|
|
393
|
+
p: Pattern;
|
|
394
|
+
pos: Pos;
|
|
395
|
+
} | {
|
|
396
|
+
k: 'literal';
|
|
397
|
+
pos: Pos;
|
|
398
|
+
value: Literal;
|
|
399
|
+
} | {
|
|
400
|
+
k: 'pin';
|
|
401
|
+
name: SemanticName;
|
|
402
|
+
pos: Pos;
|
|
403
|
+
} | {
|
|
404
|
+
items: Pattern[];
|
|
405
|
+
k: 'list';
|
|
406
|
+
pos: Pos;
|
|
407
|
+
rest: {
|
|
408
|
+
name: SemanticName | null;
|
|
409
|
+
} | null;
|
|
410
|
+
} | {
|
|
411
|
+
entries: {
|
|
412
|
+
key: string;
|
|
413
|
+
value: Pattern;
|
|
414
|
+
}[];
|
|
415
|
+
k: 'map';
|
|
416
|
+
pos: Pos;
|
|
417
|
+
} | {
|
|
418
|
+
k: 'text';
|
|
419
|
+
pattern: TextPattern;
|
|
420
|
+
pos: Pos;
|
|
421
|
+
} | {
|
|
422
|
+
fields: BinaryField[];
|
|
423
|
+
k: 'binary';
|
|
424
|
+
pos: Pos;
|
|
425
|
+
};
|
|
426
|
+
type Size = {
|
|
427
|
+
k: 'number';
|
|
428
|
+
text: string;
|
|
429
|
+
} | {
|
|
430
|
+
k: 'pin';
|
|
431
|
+
name: SemanticName;
|
|
432
|
+
pos: Pos;
|
|
433
|
+
} | {
|
|
434
|
+
k: 'name';
|
|
435
|
+
name: SemanticName;
|
|
436
|
+
pos: Pos;
|
|
437
|
+
} | {
|
|
438
|
+
e: Expr;
|
|
439
|
+
k: 'expr';
|
|
440
|
+
};
|
|
441
|
+
type FieldType = {
|
|
442
|
+
k: 'int';
|
|
443
|
+
order: string | null;
|
|
444
|
+
type: string;
|
|
445
|
+
} | {
|
|
446
|
+
asText: boolean;
|
|
447
|
+
k: 'sized';
|
|
448
|
+
size: Size;
|
|
449
|
+
unit: 'bits' | 'bytes';
|
|
450
|
+
};
|
|
451
|
+
type BinaryField = {
|
|
452
|
+
k: 'literal';
|
|
453
|
+
pos: Pos;
|
|
454
|
+
value: Literal;
|
|
455
|
+
} | {
|
|
456
|
+
asText: boolean;
|
|
457
|
+
k: 'rest';
|
|
458
|
+
name: SemanticName | null;
|
|
459
|
+
pos: Pos;
|
|
460
|
+
} | {
|
|
461
|
+
k: 'field';
|
|
462
|
+
name: SemanticName | null;
|
|
463
|
+
pos: Pos;
|
|
464
|
+
type: FieldType;
|
|
465
|
+
};
|
|
466
|
+
type BuildField = {
|
|
467
|
+
pos: Pos;
|
|
468
|
+
type: FieldType | null;
|
|
469
|
+
value: Expr;
|
|
470
|
+
};
|
|
471
|
+
/** A Guard, and its first token, which its test is placed at. */
|
|
472
|
+
type Guard = {
|
|
473
|
+
e: Expr;
|
|
474
|
+
pos: Pos;
|
|
475
|
+
};
|
|
476
|
+
type Event = {
|
|
477
|
+
from: Expr | null;
|
|
478
|
+
message: string;
|
|
479
|
+
pats: Pattern[];
|
|
480
|
+
pos: Pos;
|
|
481
|
+
};
|
|
482
|
+
type WaitBranch = {
|
|
483
|
+
body: Stmt[];
|
|
484
|
+
event: Event;
|
|
485
|
+
guard: Guard | null;
|
|
486
|
+
k: 'when';
|
|
487
|
+
pos: Pos;
|
|
488
|
+
} | {
|
|
489
|
+
body: Stmt[];
|
|
490
|
+
duration: Expr;
|
|
491
|
+
k: 'after';
|
|
492
|
+
pos: Pos;
|
|
493
|
+
};
|
|
494
|
+
type Collecting = {
|
|
495
|
+
pos: Pos;
|
|
496
|
+
target: SemanticName;
|
|
497
|
+
value: Expr;
|
|
498
|
+
};
|
|
499
|
+
type RepeatHead = {
|
|
500
|
+
k: 'each';
|
|
501
|
+
pat: Pattern;
|
|
502
|
+
src: Expr;
|
|
503
|
+
} | {
|
|
504
|
+
cond: Expr;
|
|
505
|
+
k: 'while' | 'until';
|
|
506
|
+
} | {
|
|
507
|
+
k: 'forever';
|
|
508
|
+
} | {
|
|
509
|
+
count: Expr;
|
|
510
|
+
k: 'times';
|
|
511
|
+
};
|
|
512
|
+
type Offer = {
|
|
513
|
+
body: Stmt[];
|
|
514
|
+
name: string;
|
|
515
|
+
params: SemanticName[];
|
|
516
|
+
pos: Pos;
|
|
517
|
+
};
|
|
518
|
+
type Catch = {
|
|
519
|
+
body: Stmt[];
|
|
520
|
+
guard: Guard | null;
|
|
521
|
+
pat: Pattern;
|
|
522
|
+
pos: Pos;
|
|
523
|
+
recovery: boolean;
|
|
524
|
+
};
|
|
525
|
+
type Try = {
|
|
526
|
+
body: Stmt[];
|
|
527
|
+
catches: Catch[];
|
|
528
|
+
finally: Stmt[] | null;
|
|
529
|
+
k: 'try';
|
|
530
|
+
offers: Offer[];
|
|
531
|
+
pos: Pos;
|
|
532
|
+
};
|
|
533
|
+
type Stmt = {
|
|
534
|
+
args: Expr[];
|
|
535
|
+
k: 'choose-offer';
|
|
536
|
+
name: string;
|
|
537
|
+
pos: Pos;
|
|
538
|
+
} | {
|
|
539
|
+
k: 'put';
|
|
540
|
+
pos: Pos;
|
|
541
|
+
prep: 'into' | 'after' | 'before';
|
|
542
|
+
spread: boolean;
|
|
543
|
+
target: Expr;
|
|
544
|
+
value: Expr;
|
|
545
|
+
} | {
|
|
546
|
+
k: 'let';
|
|
547
|
+
pat: Pattern;
|
|
548
|
+
pos: Pos;
|
|
549
|
+
value: Expr;
|
|
550
|
+
} | {
|
|
551
|
+
k: 'set';
|
|
552
|
+
pos: Pos;
|
|
553
|
+
target: Expr;
|
|
554
|
+
value: Expr;
|
|
555
|
+
} | {
|
|
556
|
+
k: 'arithmetic';
|
|
557
|
+
op: 'add' | 'subtract' | 'multiply' | 'divide';
|
|
558
|
+
pos: Pos;
|
|
559
|
+
target: Expr;
|
|
560
|
+
value: Expr;
|
|
561
|
+
} | {
|
|
562
|
+
k: 'delete';
|
|
563
|
+
pos: Pos;
|
|
564
|
+
target: Expr;
|
|
565
|
+
} | {
|
|
566
|
+
args: Expr[];
|
|
567
|
+
into?: SemanticName;
|
|
568
|
+
k: 'send';
|
|
569
|
+
/** The message name, or for `send (e)` the expression that computes it. */
|
|
570
|
+
message: string | Expr;
|
|
571
|
+
pos: Pos;
|
|
572
|
+
/** Which `with` items are spreads, when any is (ADR 0064). */
|
|
573
|
+
spread?: boolean[];
|
|
574
|
+
target: Expr;
|
|
575
|
+
wait: boolean;
|
|
576
|
+
} | {
|
|
577
|
+
args: Expr[];
|
|
578
|
+
grant: string;
|
|
579
|
+
/** A Result Target (ADR 0114). */
|
|
580
|
+
into?: SemanticName;
|
|
581
|
+
k: 'ask' | 'tell';
|
|
582
|
+
/** A labelled call's Argument Labels, checked at load only (ADR 0115). */
|
|
583
|
+
labels?: string[];
|
|
584
|
+
operation: string;
|
|
585
|
+
pos: Pos;
|
|
586
|
+
wait: boolean;
|
|
587
|
+
} |
|
|
588
|
+
/** A `tell` block's lines, each the call the checker chose (ADR 0063). */
|
|
589
|
+
{
|
|
590
|
+
k: 'tell-block';
|
|
591
|
+
lines: Stmt[];
|
|
592
|
+
pos: Pos;
|
|
593
|
+
} | {
|
|
594
|
+
duration: Expr;
|
|
595
|
+
k: 'wait';
|
|
596
|
+
pos: Pos;
|
|
597
|
+
} | {
|
|
598
|
+
event: Event;
|
|
599
|
+
guard: Guard | null;
|
|
600
|
+
k: 'wait-for';
|
|
601
|
+
pos: Pos;
|
|
602
|
+
timeout: Expr | null;
|
|
603
|
+
} | {
|
|
604
|
+
branches: WaitBranch[];
|
|
605
|
+
k: 'wait-block';
|
|
606
|
+
pos: Pos;
|
|
607
|
+
} | {
|
|
608
|
+
body: Stmt[];
|
|
609
|
+
end: Pos;
|
|
610
|
+
k: 'join';
|
|
611
|
+
pos: Pos;
|
|
612
|
+
} |
|
|
613
|
+
/** A Timeout Block (ADR 0073). */
|
|
614
|
+
{
|
|
615
|
+
body: Stmt[];
|
|
616
|
+
duration: Expr;
|
|
617
|
+
k: 'timeout-block';
|
|
618
|
+
pos: Pos;
|
|
619
|
+
} | {
|
|
620
|
+
k: 'return' | 'veto';
|
|
621
|
+
pos: Pos;
|
|
622
|
+
value: Expr | null;
|
|
623
|
+
} | {
|
|
624
|
+
k: 'pass';
|
|
625
|
+
message: string;
|
|
626
|
+
pos: Pos;
|
|
627
|
+
} | {
|
|
628
|
+
k: 'exit' | 'next';
|
|
629
|
+
pos: Pos;
|
|
630
|
+
} | {
|
|
631
|
+
k: 'throw';
|
|
632
|
+
pos: Pos;
|
|
633
|
+
value: Expr;
|
|
634
|
+
} | (Omit<Replace, 'k'> & {
|
|
635
|
+
k: 'replace-statement';
|
|
636
|
+
}) | {
|
|
637
|
+
call: Expr & {
|
|
638
|
+
k: 'call';
|
|
639
|
+
};
|
|
640
|
+
into?: SemanticName;
|
|
641
|
+
k: 'call';
|
|
642
|
+
pos: Pos;
|
|
643
|
+
wait: boolean;
|
|
644
|
+
} | {
|
|
645
|
+
args: Expr[];
|
|
646
|
+
into?: SemanticName;
|
|
647
|
+
k: 'command';
|
|
648
|
+
name: SemanticName;
|
|
649
|
+
pos: Pos;
|
|
650
|
+
wait: boolean;
|
|
651
|
+
} | {
|
|
652
|
+
arms: {
|
|
653
|
+
body: Stmt[];
|
|
654
|
+
cond: Expr;
|
|
655
|
+
}[];
|
|
656
|
+
else: Stmt[] | null;
|
|
657
|
+
k: 'if';
|
|
658
|
+
pos: Pos;
|
|
659
|
+
} | {
|
|
660
|
+
body: Stmt[];
|
|
661
|
+
collect: Collecting | null;
|
|
662
|
+
head: RepeatHead;
|
|
663
|
+
k: 'repeat';
|
|
664
|
+
pos: Pos;
|
|
665
|
+
} | {
|
|
666
|
+
branches: {
|
|
667
|
+
body: Stmt[];
|
|
668
|
+
guard: Guard | null;
|
|
669
|
+
pat: Pattern;
|
|
670
|
+
pos: Pos;
|
|
671
|
+
search: boolean;
|
|
672
|
+
}[];
|
|
673
|
+
else: Stmt[] | null;
|
|
674
|
+
fold: boolean;
|
|
675
|
+
k: 'match';
|
|
676
|
+
pos: Pos;
|
|
677
|
+
subject: Expr;
|
|
678
|
+
} | Try;
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/code-unit.d.ts
|
|
681
|
+
type Operand = number | string;
|
|
682
|
+
type Instruction = {
|
|
683
|
+
col: number;
|
|
684
|
+
line: number;
|
|
685
|
+
op: string;
|
|
686
|
+
/** `op`'s index in the instruction table. The machine dispatches on it. */
|
|
687
|
+
opcode: number;
|
|
688
|
+
operands: Operand[];
|
|
689
|
+
/** The Cost Model rate it charges, from `rateOf`, or -1 if none. */
|
|
690
|
+
rate: number;
|
|
691
|
+
};
|
|
692
|
+
type BodyKind = 'init' | 'function' | 'handler' | 'fallback' | 'lambda' | 'event';
|
|
693
|
+
type Body = {
|
|
694
|
+
/** First body instruction after successful Handler dispatch. */
|
|
695
|
+
acceptedAt?: number;
|
|
696
|
+
captures: number;
|
|
697
|
+
/** The slot of the first capture, for a Lambda or an event test. */
|
|
698
|
+
captureStart: number;
|
|
699
|
+
clause: number | null;
|
|
700
|
+
deciding?: boolean;
|
|
701
|
+
/** For a function, each parameter's default definition, or null. */
|
|
702
|
+
defaults: (number | null)[];
|
|
703
|
+
/** A top-level function's or Handler Clause's Declaration Documentation. */
|
|
704
|
+
doc?: string;
|
|
705
|
+
/** Local slot bound by an error Handler’s `during` suffix. */
|
|
706
|
+
duringSlot?: number;
|
|
707
|
+
/** One past the body's last instruction. */
|
|
708
|
+
end: number;
|
|
709
|
+
index: number;
|
|
710
|
+
kind: BodyKind;
|
|
711
|
+
/** The name of each local slot: a name, or a temp's `(slot)`. */
|
|
712
|
+
locals: string[];
|
|
713
|
+
maySuspend: boolean;
|
|
714
|
+
name: string;
|
|
715
|
+
/** Each parameter's name, or `…` for a pattern. */
|
|
716
|
+
params: string[];
|
|
717
|
+
policy?: 'queued' | 'dropping' | 'replacing';
|
|
718
|
+
start: number;
|
|
719
|
+
};
|
|
720
|
+
type UnwindEntry = {
|
|
721
|
+
depth: number;
|
|
722
|
+
/** One past the range's last instruction. */
|
|
723
|
+
end: number;
|
|
724
|
+
kind: 'catch' | 'finally' | 'guard' | 'offer';
|
|
725
|
+
start: number;
|
|
726
|
+
target: number;
|
|
727
|
+
};
|
|
728
|
+
type OfferEntry = {
|
|
729
|
+
body: number;
|
|
730
|
+
depth: number;
|
|
731
|
+
end: number;
|
|
732
|
+
offers: {
|
|
733
|
+
binds: number[];
|
|
734
|
+
name: string;
|
|
735
|
+
target: number;
|
|
736
|
+
}[];
|
|
737
|
+
};
|
|
738
|
+
type EventBranch = {
|
|
739
|
+
binds: number[];
|
|
740
|
+
body: number | null;
|
|
741
|
+
captures: number;
|
|
742
|
+
from: boolean;
|
|
743
|
+
kind: 'when';
|
|
744
|
+
message: string;
|
|
745
|
+
} | {
|
|
746
|
+
kind: 'after';
|
|
747
|
+
};
|
|
748
|
+
type EventEntry = {
|
|
749
|
+
branches: EventBranch[];
|
|
750
|
+
timeout: boolean;
|
|
751
|
+
};
|
|
752
|
+
type CodeUnit = {
|
|
753
|
+
bodies: Body[];
|
|
754
|
+
code: Instruction[];
|
|
755
|
+
/** Each constant's display form, in pool order. */
|
|
756
|
+
constants: string[];
|
|
757
|
+
definitions: string[];
|
|
758
|
+
events: EventEntry[];
|
|
759
|
+
kind: 'script' | 'library';
|
|
760
|
+
name: string;
|
|
761
|
+
objects: string[];
|
|
762
|
+
offers?: OfferEntry[];
|
|
763
|
+
/**
|
|
764
|
+
* The elements of each Text Pattern constant, by its pool index, for the
|
|
765
|
+
* machine that runs the unit; a template's splices stay in place.
|
|
766
|
+
*/
|
|
767
|
+
patterns: Map<number, readonly PatternElement[]>;
|
|
768
|
+
unwind: UnwindEntry[];
|
|
769
|
+
variables: string[];
|
|
770
|
+
};
|
|
771
|
+
/** Chapter 8's canonical disassembly: LF line ends, ending with one. */
|
|
772
|
+
declare const disassemble: (unit: CodeUnit) => string;
|
|
773
|
+
//#endregion
|
|
774
|
+
//#region src/errors.d.ts
|
|
775
|
+
type HostErrorCode = 'clock backwards' | 'parent cycle' | 'duplicate object id' | 'name reused' | 'reentrant call' | 'wrong group' | 'library mismatch' | 'reserved name' | 'not adoptable' | 'invalid value' | 'invalid save' | 'save mismatch' | 'unknown call' | 'state too large' | 'effects pending' | 'effect state unknown' | 'invalid checkpoint';
|
|
776
|
+
declare class HostError extends Error {
|
|
777
|
+
readonly code: HostErrorCode;
|
|
778
|
+
constructor(code: HostErrorCode, message?: string);
|
|
779
|
+
}
|
|
780
|
+
/** A load-time diagnostic, or the first syntax error, as a LoadError carries it. */
|
|
781
|
+
type LoadDiagnostic = {
|
|
782
|
+
code: string;
|
|
783
|
+
col: number;
|
|
784
|
+
line: number;
|
|
785
|
+
message: string;
|
|
786
|
+
unit: string;
|
|
787
|
+
};
|
|
788
|
+
/** A rejected Load (chapter 9): its diagnostics, in order. */
|
|
789
|
+
declare class LoadError extends Error {
|
|
790
|
+
readonly diagnostics: readonly LoadDiagnostic[];
|
|
791
|
+
constructor(diagnostics: readonly LoadDiagnostic[]);
|
|
792
|
+
}
|
|
793
|
+
/** Load shedding at a Delivery's call, not a bug (chapter 9, Deliveries). */
|
|
794
|
+
declare class MailboxFull extends Error {
|
|
795
|
+
name: string;
|
|
796
|
+
}
|
|
797
|
+
/** Why a `send failed` came with no answer (ADR 0033, chapter 9). */
|
|
798
|
+
type SendFailedReason = 'errored' | 'limit fault' | 'cancelled' | 'unhandled' | 'dropped' | 'stopped' | 'function gone' | 'effect failed';
|
|
799
|
+
/**
|
|
800
|
+
* A Script-level error as the Host sees it, such as a Request's `send failed`
|
|
801
|
+
* or a `run end`'s error. Its `data` is a map, or Nothing. A `send failed`
|
|
802
|
+
* also carries its `reason` from `data`.
|
|
803
|
+
*/
|
|
804
|
+
declare class ScriptError extends Error {
|
|
805
|
+
readonly code: string;
|
|
806
|
+
readonly data: Value;
|
|
807
|
+
readonly reason: SendFailedReason | undefined;
|
|
808
|
+
constructor(code: string, message: string, data?: Value);
|
|
809
|
+
}
|
|
810
|
+
//#endregion
|
|
811
|
+
//#region src/binary.d.ts
|
|
812
|
+
/** A reader: Bytes and the position of the next byte to read. */
|
|
813
|
+
type Reader = {
|
|
814
|
+
at: number;
|
|
815
|
+
bytes: Uint8Array;
|
|
816
|
+
k: 'reader';
|
|
817
|
+
};
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/units.d.ts
|
|
820
|
+
/** One slot of a Unit: a Unit of a Unit Kind, and its exponent. */
|
|
821
|
+
type Slot = {
|
|
822
|
+
readonly exponent: number;
|
|
823
|
+
readonly unit: string;
|
|
824
|
+
};
|
|
825
|
+
/** A Unit's slots in Kind order. An empty Unit is a plain number. */
|
|
826
|
+
type UnitSpec = readonly Slot[];
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/operations.d.ts
|
|
829
|
+
/** Behaviour this Core doesn't implement yet; never a Script error. */
|
|
830
|
+
declare class NotImplementedError extends Error {
|
|
831
|
+
name: string;
|
|
832
|
+
}
|
|
833
|
+
/** `wait d`'s duration in microseconds; anything but an exact duration is `wrong kind`. */
|
|
834
|
+
declare const waitUs: (v: Value) => bigint;
|
|
835
|
+
/** A verified static Unit target, owned by its loaded code unit. */
|
|
836
|
+
type UnitConversion = {
|
|
837
|
+
readonly to: string;
|
|
838
|
+
readonly unit: UnitSpec;
|
|
839
|
+
};
|
|
840
|
+
declare const canConvert: (v: Value, kind: string, prepared?: UnitConversion) => Value;
|
|
841
|
+
//#endregion
|
|
842
|
+
//#region src/waits.d.ts
|
|
843
|
+
/**
|
|
844
|
+
* The ways a call's Wait ends without its answer being used. Hosts see only
|
|
845
|
+
* the aborted signal; neither the Trace nor a save records the reason.
|
|
846
|
+
*/
|
|
847
|
+
type AbandonReason = 'cancelled' | 'effect-failed' | 'join-ended' | 'join-failed' | 'limit' | 'rewound' | 'stopped' | 'timeout';
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region src/machine.d.ts
|
|
850
|
+
type LimitName = 'fuelPerRun' | 'allocPerRun' | 'persistentState' | 'callDepth' | 'patternSize' | 'mailboxDepth' | 'maxWaitMs' | 'maxJoin' | 'cleanupBudget';
|
|
851
|
+
type Limits = Record<LimitName, number>;
|
|
852
|
+
declare const defaultLimits: Limits;
|
|
853
|
+
/** A code unit that can't load: a literal pattern past its limit, or a failed initialiser. */
|
|
854
|
+
declare class UnitLoadError extends Error {
|
|
855
|
+
readonly code: 'pattern too large' | 'initialiser failed';
|
|
856
|
+
readonly line: number;
|
|
857
|
+
readonly col: number;
|
|
858
|
+
readonly error: Value | null;
|
|
859
|
+
constructor(code: 'pattern too large' | 'initialiser failed', line: number, col: number, error?: Value | null);
|
|
860
|
+
}
|
|
861
|
+
type Constant = {
|
|
862
|
+
k: 'value';
|
|
863
|
+
value: Value;
|
|
864
|
+
} | {
|
|
865
|
+
els: readonly PatternElement[];
|
|
866
|
+
k: 'template';
|
|
867
|
+
} | {
|
|
868
|
+
k: 'unimplemented';
|
|
869
|
+
what: string;
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* A loaded code unit, a Script's or a Library's: its constants, definitions
|
|
873
|
+
* and Handler clauses, linked to the Libraries its `use` lines name.
|
|
874
|
+
*/
|
|
875
|
+
declare class Code {
|
|
876
|
+
readonly unit: CodeUnit;
|
|
877
|
+
readonly identity: string;
|
|
878
|
+
/** Static conversion metadata; rebuilt on Load, Reload and Restore. */
|
|
879
|
+
readonly conversions: Map<Instruction, UnitConversion>;
|
|
880
|
+
readonly constants: Constant[];
|
|
881
|
+
readonly definitions: Value[];
|
|
882
|
+
readonly clauses: Map<string, Body[]>;
|
|
883
|
+
/**
|
|
884
|
+
* Its Fallback Handler's clauses, in source order. They are kept apart
|
|
885
|
+
* from `clauses`, so no Selector finds them (ADR 0064).
|
|
886
|
+
*/
|
|
887
|
+
fallback: Body[];
|
|
888
|
+
/** The Libraries it imports, by name. */
|
|
889
|
+
readonly libraries: Map<string, Code>;
|
|
890
|
+
/** Whether it is a stdlib Library's, whose errors name the caller (ADR 0037). */
|
|
891
|
+
stdlib: boolean;
|
|
892
|
+
/**
|
|
893
|
+
* Whether its errors name the caller, as a stdlib Library's do. A Host may
|
|
894
|
+
* ask this of any Library, outside the Spec, as `northtalk test` does.
|
|
895
|
+
*/
|
|
896
|
+
atCaller: boolean;
|
|
897
|
+
constructor(unit: CodeUnit, identity?: string);
|
|
898
|
+
get name(): string;
|
|
899
|
+
constant(i: number): Value;
|
|
900
|
+
/** The Library that holds an import, written `library:name`. */
|
|
901
|
+
library(name: string): {
|
|
902
|
+
code: Code;
|
|
903
|
+
name: string;
|
|
904
|
+
};
|
|
905
|
+
/** An exported function's body. */
|
|
906
|
+
function(name: string): Body;
|
|
907
|
+
/** Link the Libraries it imports, and take the Constants it imports from them. */
|
|
908
|
+
link(libraries: ReadonlyMap<string, Code>, home?: Script$1): void;
|
|
909
|
+
}
|
|
910
|
+
/** A loaded Script: its code, and its Script Variables. */
|
|
911
|
+
declare class Script$1 extends Code {
|
|
912
|
+
readonly limits: Limits;
|
|
913
|
+
readonly home?: Script$1 | undefined;
|
|
914
|
+
variables: Value[];
|
|
915
|
+
functionGroup?: object;
|
|
916
|
+
readonly boundConstants: Map<Value, Value>;
|
|
917
|
+
live: boolean;
|
|
918
|
+
readonly units: Code[];
|
|
919
|
+
variableNames: string[];
|
|
920
|
+
constructor(unit: CodeUnit, limits?: Limits, home?: Script$1 | undefined, identity?: string);
|
|
921
|
+
codeFor(body: Body): Code;
|
|
922
|
+
attach(extension: Script$1): void;
|
|
923
|
+
/** The Script Variables' share of Persistent State. */
|
|
924
|
+
variablesSize(): number;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Load a code unit: check each literal Text Pattern against the size limit,
|
|
928
|
+
* then run the initialiser, which is never charged (chapter 8, Charging).
|
|
929
|
+
*/
|
|
930
|
+
declare const loadScript: (unit: CodeUnit, limits?: Partial<Limits>, libraries?: ReadonlyMap<string, Code>, initialVariables?: readonly Value[], home?: Script$1, identity?: string, functionGroup?: object) => Script$1;
|
|
931
|
+
type Iterator = {
|
|
932
|
+
at: number;
|
|
933
|
+
count: number;
|
|
934
|
+
k: 'iterator';
|
|
935
|
+
source: Value | null;
|
|
936
|
+
};
|
|
937
|
+
type Replacement = {
|
|
938
|
+
at: number;
|
|
939
|
+
cs: readonly string[];
|
|
940
|
+
found: {
|
|
941
|
+
end: number;
|
|
942
|
+
start: number;
|
|
943
|
+
}[];
|
|
944
|
+
k: 'replacement';
|
|
945
|
+
matches: Value[];
|
|
946
|
+
pieces: string[];
|
|
947
|
+
subject: Value;
|
|
948
|
+
};
|
|
949
|
+
type Item = Value | Iterator | Replacement | Reader | Receiver | Deadline;
|
|
950
|
+
/**
|
|
951
|
+
* A Timeout Block's mathematical microsecond deadline and its duration
|
|
952
|
+
* (ADR 0073). The count may lie outside the Clock's Instant range.
|
|
953
|
+
*/
|
|
954
|
+
type Deadline = {
|
|
955
|
+
after: Value;
|
|
956
|
+
at: bigint;
|
|
957
|
+
k: 'deadline';
|
|
958
|
+
};
|
|
959
|
+
type Dispatch = {
|
|
960
|
+
args: Value[];
|
|
961
|
+
clauses: Body[];
|
|
962
|
+
code: Code;
|
|
963
|
+
/**
|
|
964
|
+
* A Delivery that may reach a Fallback Handler: its clauses, tried after
|
|
965
|
+
* `clauses` with the message map, and the message's Selector (ADR 0064).
|
|
966
|
+
*/
|
|
967
|
+
fallback?: {
|
|
968
|
+
clauses: Body[];
|
|
969
|
+
selector: string;
|
|
970
|
+
};
|
|
971
|
+
next: number;
|
|
972
|
+
};
|
|
973
|
+
type Frame = {
|
|
974
|
+
activation?: boolean;
|
|
975
|
+
body: Body;
|
|
976
|
+
/** A clause's `clause` charge, added to its first instruction's. */
|
|
977
|
+
clauseCharge: boolean;
|
|
978
|
+
/** The code unit the body is in: the Script's own, or a Library's. */
|
|
979
|
+
code: Code;
|
|
980
|
+
dispatch: Dispatch | null;
|
|
981
|
+
handler: string;
|
|
982
|
+
locals: Value[];
|
|
983
|
+
owner?: Frame;
|
|
984
|
+
pc: number;
|
|
985
|
+
/** Inherited by calls and retained recovery/cleanup activations. */
|
|
986
|
+
restricted: boolean;
|
|
987
|
+
stack: Item[];
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* What happened in a Run that a Trace records: each raise, caught or not,
|
|
991
|
+
* and each clause or branch a guard region skipped, with its error's code or
|
|
992
|
+
* the value its Guard gave that wasn't a boolean.
|
|
993
|
+
*/
|
|
994
|
+
type RunRecord = {
|
|
995
|
+
args: Value[];
|
|
996
|
+
at: {
|
|
997
|
+
pc: number;
|
|
998
|
+
unit: string;
|
|
999
|
+
};
|
|
1000
|
+
attempt: number;
|
|
1001
|
+
kind: 'offer-chosen';
|
|
1002
|
+
name: string;
|
|
1003
|
+
target: {
|
|
1004
|
+
pc: number;
|
|
1005
|
+
unit: string;
|
|
1006
|
+
};
|
|
1007
|
+
} | {
|
|
1008
|
+
attempt: number;
|
|
1009
|
+
kind: 'offer-entered';
|
|
1010
|
+
target: {
|
|
1011
|
+
pc: number;
|
|
1012
|
+
unit: string;
|
|
1013
|
+
};
|
|
1014
|
+
} | {
|
|
1015
|
+
code?: string;
|
|
1016
|
+
col: number;
|
|
1017
|
+
kind: 'raise' | 'guard-skip';
|
|
1018
|
+
line: number;
|
|
1019
|
+
pc: number;
|
|
1020
|
+
unit: string;
|
|
1021
|
+
value?: Value;
|
|
1022
|
+
} | {
|
|
1023
|
+
args: Value[];
|
|
1024
|
+
automatic?: boolean;
|
|
1025
|
+
charged: number;
|
|
1026
|
+
error?: Value;
|
|
1027
|
+
id: string;
|
|
1028
|
+
kind: 'call';
|
|
1029
|
+
op: string;
|
|
1030
|
+
result?: Value;
|
|
1031
|
+
} | {
|
|
1032
|
+
action: 'opened' | 'closed' | 'abandoned' | 'failed';
|
|
1033
|
+
grant: string;
|
|
1034
|
+
id: string;
|
|
1035
|
+
kind: 'scope';
|
|
1036
|
+
name: string;
|
|
1037
|
+
} | {
|
|
1038
|
+
detail: string;
|
|
1039
|
+
grant: string;
|
|
1040
|
+
kind: 'effect-failure';
|
|
1041
|
+
phase: EffectFailure['phase'];
|
|
1042
|
+
scope?: string;
|
|
1043
|
+
segment: string;
|
|
1044
|
+
status: 'failed' | 'unknown';
|
|
1045
|
+
} | {
|
|
1046
|
+
grant: string;
|
|
1047
|
+
kind: 'effect';
|
|
1048
|
+
phase: 'begin' | 'commit' | 'rollback';
|
|
1049
|
+
segment: string;
|
|
1050
|
+
status: EffectResult['status'];
|
|
1051
|
+
} | {
|
|
1052
|
+
detail: string;
|
|
1053
|
+
id: string;
|
|
1054
|
+
kind: 'call-failed';
|
|
1055
|
+
op: string;
|
|
1056
|
+
} | {
|
|
1057
|
+
id: string;
|
|
1058
|
+
kind: 'abandon';
|
|
1059
|
+
} | {
|
|
1060
|
+
args: Value[];
|
|
1061
|
+
kind: 'unhandled';
|
|
1062
|
+
message: string;
|
|
1063
|
+
target: Value | null;
|
|
1064
|
+
} | {
|
|
1065
|
+
error?: Value;
|
|
1066
|
+
kind: 'prop';
|
|
1067
|
+
name: string;
|
|
1068
|
+
object: Value;
|
|
1069
|
+
op: 'get' | 'set' | 'count' | 'at' | 'find';
|
|
1070
|
+
selector?: Value;
|
|
1071
|
+
value?: Value;
|
|
1072
|
+
} | {
|
|
1073
|
+
args: Value[];
|
|
1074
|
+
fn?: Value;
|
|
1075
|
+
/** The call id of a send that waits for its reply. */
|
|
1076
|
+
id?: string;
|
|
1077
|
+
/** A Join Member's send. */
|
|
1078
|
+
join?: boolean;
|
|
1079
|
+
kind: 'send';
|
|
1080
|
+
message?: string;
|
|
1081
|
+
to: string;
|
|
1082
|
+
};
|
|
1083
|
+
type CallContext = {
|
|
1084
|
+
adoptable?: boolean;
|
|
1085
|
+
/** A suspending Standard Capability call's arguments, for its answer rules. */
|
|
1086
|
+
args?: readonly Value[];
|
|
1087
|
+
declared: number;
|
|
1088
|
+
id: string;
|
|
1089
|
+
named: [string, Value][];
|
|
1090
|
+
op: ValueOperation<unknown>;
|
|
1091
|
+
/** As the Trace names it, `<granted name>.<operation>`. */
|
|
1092
|
+
opName: string;
|
|
1093
|
+
/** The rate the call is charged by. */
|
|
1094
|
+
rate: number;
|
|
1095
|
+
};
|
|
1096
|
+
/** Why a Run suspended, which its Group waits on (chapter 5, Suspension Points). */
|
|
1097
|
+
type Suspension = ({
|
|
1098
|
+
k: 'wait';
|
|
1099
|
+
us: bigint;
|
|
1100
|
+
} | {
|
|
1101
|
+
abort: AbortController;
|
|
1102
|
+
call: CallContext;
|
|
1103
|
+
k: 'ask';
|
|
1104
|
+
ms: number;
|
|
1105
|
+
} | {
|
|
1106
|
+
args: Value[];
|
|
1107
|
+
id: string;
|
|
1108
|
+
k: 'send';
|
|
1109
|
+
message: string;
|
|
1110
|
+
to: string;
|
|
1111
|
+
} | {
|
|
1112
|
+
args: Value[];
|
|
1113
|
+
fn: Value;
|
|
1114
|
+
id: string;
|
|
1115
|
+
k: 'call-value';
|
|
1116
|
+
to: string;
|
|
1117
|
+
} | {
|
|
1118
|
+
k: 'join';
|
|
1119
|
+
members: Member[];
|
|
1120
|
+
} | WaitFor) & {
|
|
1121
|
+
/** The Timeout Block deadline it is written in, if any (ADR 0073). */
|
|
1122
|
+
deadline?: Deadline;
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* A `wait for`, one-line or block: its `when` branches with their `from`
|
|
1126
|
+
* Scripts or objects and captures, its `after` branches' durations and its timeout,
|
|
1127
|
+
* each branch numbered from 1 in source order.
|
|
1128
|
+
*/
|
|
1129
|
+
type WaitFor = {
|
|
1130
|
+
afters: {
|
|
1131
|
+
branch: number;
|
|
1132
|
+
us: bigint;
|
|
1133
|
+
}[];
|
|
1134
|
+
any: boolean;
|
|
1135
|
+
code: Code;
|
|
1136
|
+
k: 'wait-for';
|
|
1137
|
+
timeout: bigint | null;
|
|
1138
|
+
whens: {
|
|
1139
|
+
binds: number[];
|
|
1140
|
+
body: number | null;
|
|
1141
|
+
branch: number;
|
|
1142
|
+
captures: Value[];
|
|
1143
|
+
from: string | Value | null;
|
|
1144
|
+
message: string;
|
|
1145
|
+
}[];
|
|
1146
|
+
};
|
|
1147
|
+
/** A Join Member: its call id, and for a Capability call, its context. */
|
|
1148
|
+
type Member = {
|
|
1149
|
+
abort: AbortController | null;
|
|
1150
|
+
/** An answer that arrived early, which Persistent State counts. */
|
|
1151
|
+
answer?: Value;
|
|
1152
|
+
/** Its deadline: the Clock of the Pump that started it, plus `ms`. */
|
|
1153
|
+
at: bigint;
|
|
1154
|
+
call: CallContext | null;
|
|
1155
|
+
id: string;
|
|
1156
|
+
ms: number;
|
|
1157
|
+
/** A Script reply received before its preempted Join closes. */
|
|
1158
|
+
reply?: Resumption;
|
|
1159
|
+
/** The checked member instruction retains its destination and owning frame. */
|
|
1160
|
+
site: {
|
|
1161
|
+
frame: Frame;
|
|
1162
|
+
pc: number;
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
/** What resumes a suspended Run. */
|
|
1166
|
+
type Resumption = {
|
|
1167
|
+
k: 'wake';
|
|
1168
|
+
} | {
|
|
1169
|
+
code: 'call lost' | 'capability revoked';
|
|
1170
|
+
k: 'restore-fail';
|
|
1171
|
+
} | {
|
|
1172
|
+
fuel: number;
|
|
1173
|
+
k: 'answer';
|
|
1174
|
+
value: Value;
|
|
1175
|
+
} | {
|
|
1176
|
+
detail?: string;
|
|
1177
|
+
error: ScriptError | null;
|
|
1178
|
+
k: 'fail';
|
|
1179
|
+
} |
|
|
1180
|
+
/** With `deadline`, a Timeout Block's deadline ended it, after that long. */
|
|
1181
|
+
{
|
|
1182
|
+
after: number;
|
|
1183
|
+
deadline?: Value;
|
|
1184
|
+
k: 'timeout';
|
|
1185
|
+
} |
|
|
1186
|
+
/** A Timeout Block's deadline ended a wait or Join, abandoning these. */
|
|
1187
|
+
{
|
|
1188
|
+
abandon: string[];
|
|
1189
|
+
after: Value;
|
|
1190
|
+
k: 'deadline';
|
|
1191
|
+
} | {
|
|
1192
|
+
k: 'reply';
|
|
1193
|
+
value: Value;
|
|
1194
|
+
} | {
|
|
1195
|
+
error: Value | null;
|
|
1196
|
+
k: 'send failed';
|
|
1197
|
+
reason: string;
|
|
1198
|
+
} | {
|
|
1199
|
+
answers: Resumption[];
|
|
1200
|
+
k: 'joined';
|
|
1201
|
+
} | {
|
|
1202
|
+
binds: Value[];
|
|
1203
|
+
branch: number;
|
|
1204
|
+
k: 'event';
|
|
1205
|
+
message: Value;
|
|
1206
|
+
} | {
|
|
1207
|
+
branch: number;
|
|
1208
|
+
k: 'event-timeout';
|
|
1209
|
+
} | {
|
|
1210
|
+
abandon: string[];
|
|
1211
|
+
failure: Resumption;
|
|
1212
|
+
index: number;
|
|
1213
|
+
k: 'join-failed';
|
|
1214
|
+
};
|
|
1215
|
+
/**
|
|
1216
|
+
* What a Run reaches outside its Script through, which its Group gives it:
|
|
1217
|
+
* the Script's Grants, the Pump's Clock reading, and other Scripts' mailboxes.
|
|
1218
|
+
*/
|
|
1219
|
+
type RunHost = {
|
|
1220
|
+
/** Queues a suspending call's answer, as the Host Input `answer`. */
|
|
1221
|
+
answer(id: string, value: Value, fuel: number): void;
|
|
1222
|
+
/** Queues a foreign Function Value in its Home Script's mailbox. */
|
|
1223
|
+
callValue(fn: Value, args: Value[], reply: string): string;
|
|
1224
|
+
/** Land Stop and CancelRun after the crossing record, before conversion. */
|
|
1225
|
+
crossing?(): boolean;
|
|
1226
|
+
/** The id of the Host Delivery that started the Run, if one did (ADR 0125). */
|
|
1227
|
+
readonly delivery?: string;
|
|
1228
|
+
disableGrant(name: string): void;
|
|
1229
|
+
/**
|
|
1230
|
+
* The next `random(n)` draw from the Group's generator; `commit` advances
|
|
1231
|
+
* the generator past it (chapter 7, Random numbers).
|
|
1232
|
+
*/
|
|
1233
|
+
drawRandom(n: bigint): {
|
|
1234
|
+
commit(): void;
|
|
1235
|
+
value: bigint;
|
|
1236
|
+
};
|
|
1237
|
+
expose?(tree: unknown): void;
|
|
1238
|
+
/**
|
|
1239
|
+
* Queues its failure, as `fail`; null fails with what isn't a Script error,
|
|
1240
|
+
* which `detail` describes for the `call failed` report.
|
|
1241
|
+
*/
|
|
1242
|
+
fail(id: string, error: ScriptError | null, detail?: string): void;
|
|
1243
|
+
readonly grants: ReadonlyMap<string, Grant<unknown>>;
|
|
1244
|
+
/** The Group, as the Calls and Segment contexts the Run makes see it. */
|
|
1245
|
+
readonly group: Group;
|
|
1246
|
+
/** Whether a Value refers only to objects of this Group. */
|
|
1247
|
+
holdsObject(v: Value): boolean;
|
|
1248
|
+
isDisabled(name: string): boolean;
|
|
1249
|
+
isRevoked?(name: string): boolean;
|
|
1250
|
+
/** Whether a name is a Script of the Group. */
|
|
1251
|
+
isScript(name: string): boolean;
|
|
1252
|
+
isUnbound?(name: string): boolean;
|
|
1253
|
+
/** The object the Script owns, or Nothing. */
|
|
1254
|
+
readonly me: Value;
|
|
1255
|
+
readonly now: bigint;
|
|
1256
|
+
/** The well-known Host Object the Host bound to a name at load. */
|
|
1257
|
+
object(name: string): Value | undefined;
|
|
1258
|
+
/**
|
|
1259
|
+
* Puts a message in the mailbox of a Script, or of an object's nearest
|
|
1260
|
+
* Owning Script, or throws ScriptError `mailbox full`; `reply` is the call
|
|
1261
|
+
* id of a send that waits for its reply. Gives the Script it reached, or
|
|
1262
|
+
* null for a message no Script on its path takes.
|
|
1263
|
+
*/
|
|
1264
|
+
send(to: string | ObjectState, message: string, args: Value[], reply: string | null): string | null;
|
|
1265
|
+
/** Sends a Command Call with no Handler up the Message Path, as `send` does. */
|
|
1266
|
+
sendUp(message: string, args: Value[], reply: string | null): string | null;
|
|
1267
|
+
};
|
|
1268
|
+
type Receiver = {
|
|
1269
|
+
k: 'receiver';
|
|
1270
|
+
name: string;
|
|
1271
|
+
};
|
|
1272
|
+
/** An instruction's code position and source position (chapter 9, Reports). */
|
|
1273
|
+
type CodePosition = {
|
|
1274
|
+
col: number;
|
|
1275
|
+
/** The frame's Handler, as an error's `at` names it. */
|
|
1276
|
+
handler: string;
|
|
1277
|
+
line: number;
|
|
1278
|
+
pc: number;
|
|
1279
|
+
/** The code unit the instruction is in. */
|
|
1280
|
+
unit: string;
|
|
1281
|
+
};
|
|
1282
|
+
type Outcome = {
|
|
1283
|
+
kind: 'completed';
|
|
1284
|
+
passed?: boolean;
|
|
1285
|
+
result: Value;
|
|
1286
|
+
veto?: Value;
|
|
1287
|
+
} |
|
|
1288
|
+
/** `at` is the raise that no Unwind Table entry caught. */
|
|
1289
|
+
{
|
|
1290
|
+
at: CodePosition;
|
|
1291
|
+
error: Value;
|
|
1292
|
+
kind: 'errored';
|
|
1293
|
+
} | {
|
|
1294
|
+
col: number;
|
|
1295
|
+
/** The faulting frame's Handler. */
|
|
1296
|
+
handler: string;
|
|
1297
|
+
kind: 'limit fault';
|
|
1298
|
+
limit: LimitName;
|
|
1299
|
+
line: number;
|
|
1300
|
+
pc: number;
|
|
1301
|
+
/** The Script Variables the rollback changed back, in declaration order. */
|
|
1302
|
+
rollback: string[];
|
|
1303
|
+
/** The code unit the faulting instruction is in. */
|
|
1304
|
+
unit: string;
|
|
1305
|
+
} | {
|
|
1306
|
+
effect: EffectFailure;
|
|
1307
|
+
kind: 'effect failed';
|
|
1308
|
+
} | {
|
|
1309
|
+
kind: 'unhandled' | 'dropped';
|
|
1310
|
+
} | {
|
|
1311
|
+
cleanupFailed?: {
|
|
1312
|
+
code: string;
|
|
1313
|
+
} | {
|
|
1314
|
+
limit: LimitName;
|
|
1315
|
+
};
|
|
1316
|
+
kind: 'cancelled';
|
|
1317
|
+
};
|
|
1318
|
+
declare class Run {
|
|
1319
|
+
readonly script: Script$1;
|
|
1320
|
+
readonly limits: Limits;
|
|
1321
|
+
/** Its id in the Trace, such as `orders/r2`, which its call ids extend. */
|
|
1322
|
+
id: string;
|
|
1323
|
+
/** Whether this Run holds a Decision’s open Verdict. */
|
|
1324
|
+
openVerdict: boolean;
|
|
1325
|
+
/** `the target`: the object its message was delivered to, or Nothing. */
|
|
1326
|
+
target: Value;
|
|
1327
|
+
host: RunHost | null;
|
|
1328
|
+
/** Why it suspended, until its Group resumes it. */
|
|
1329
|
+
suspended: Suspension | null;
|
|
1330
|
+
private resumption;
|
|
1331
|
+
private abandoning;
|
|
1332
|
+
/** The calls a Limit Fault abandoned, which the Trace writes after it. */
|
|
1333
|
+
faultAbandons: string[];
|
|
1334
|
+
/** The Join open in this Run, with the members it has started. */
|
|
1335
|
+
private join;
|
|
1336
|
+
private waitedOn;
|
|
1337
|
+
private calls;
|
|
1338
|
+
private segment;
|
|
1339
|
+
private scopes;
|
|
1340
|
+
private participant;
|
|
1341
|
+
private get participantSite();
|
|
1342
|
+
get hasParticipant(): boolean;
|
|
1343
|
+
get effectStateUnknown(): boolean;
|
|
1344
|
+
/** After charges/state checks, before any Segment outcome becomes visible. */
|
|
1345
|
+
finalizeEffects(rollback?: boolean): void;
|
|
1346
|
+
get hasOpenScopes(): boolean;
|
|
1347
|
+
/** Still in the Segment it started in, so it can be rewound (ADR 0068). */
|
|
1348
|
+
get rewindable(): boolean;
|
|
1349
|
+
get segmentId(): string;
|
|
1350
|
+
private checkScopeBoundary;
|
|
1351
|
+
/** Reserved Host cleanup, called by the Group before publishing termination. */
|
|
1352
|
+
abandonScopes(only?: (grantName: string) => boolean): void;
|
|
1353
|
+
private crossingCall;
|
|
1354
|
+
frames: Frame[];
|
|
1355
|
+
fuel: number;
|
|
1356
|
+
alloc: number;
|
|
1357
|
+
charging: boolean;
|
|
1358
|
+
records: RunRecord[];
|
|
1359
|
+
/**
|
|
1360
|
+
* The Script's Persistent State, measured at the Segment's end without this
|
|
1361
|
+
* Run, since a Run that is ending keeps nothing (chapter 6, Limits). The
|
|
1362
|
+
* Group adds what else the Script holds, such as its mailbox.
|
|
1363
|
+
*/
|
|
1364
|
+
persistentState: () => number;
|
|
1365
|
+
/** The Script Variables when the Segment began, for rollback (ADR 0006). */
|
|
1366
|
+
segmentBase: Value[];
|
|
1367
|
+
private cleanups;
|
|
1368
|
+
private recoveries;
|
|
1369
|
+
private offerAttempt;
|
|
1370
|
+
private outcome;
|
|
1371
|
+
private entryError;
|
|
1372
|
+
private m;
|
|
1373
|
+
private clause;
|
|
1374
|
+
/** Its entry dispatch reached the Fallback Handler's clauses (ADR 0064). */
|
|
1375
|
+
private viaFallback;
|
|
1376
|
+
private during;
|
|
1377
|
+
private cancellation;
|
|
1378
|
+
private cancellationOwners;
|
|
1379
|
+
private cleanupFuel;
|
|
1380
|
+
/** Calls abandoned when cancellation landed, traced after the cancel Segment. */
|
|
1381
|
+
cancellationAbandons: string[];
|
|
1382
|
+
rebindCalls(): void;
|
|
1383
|
+
/**
|
|
1384
|
+
* The Capability calls an open Join started and hasn't heard from, while a
|
|
1385
|
+
* Fuel Slice has preempted its body: they are pending too (chapter 8).
|
|
1386
|
+
*/
|
|
1387
|
+
openJoinCalls(): Member[];
|
|
1388
|
+
/** A pending call's context: the one suspended on, or an open Join's. */
|
|
1389
|
+
pendingCall(id: string): Pick<Member, 'abort' | 'call'> | undefined;
|
|
1390
|
+
callAdoptable(id: string): boolean;
|
|
1391
|
+
/** Reconnect the Host side of a saved suspending Operation. */
|
|
1392
|
+
restoredCall(id: string, grantName: string, args: Value[], reissue: boolean): {
|
|
1393
|
+
call: Call<unknown>;
|
|
1394
|
+
failure?: Resumption;
|
|
1395
|
+
};
|
|
1396
|
+
/** The plain machine state, without its Group's Host functions. */
|
|
1397
|
+
snapshot(): Record<string, unknown>;
|
|
1398
|
+
/** Allocate before linking shared frames and Join state from a save. */
|
|
1399
|
+
static empty(): Run;
|
|
1400
|
+
restore(state: Record<string, unknown>): void;
|
|
1401
|
+
/** Validate decoded control after the graph is complete, before Host rebinding. */
|
|
1402
|
+
validateSnapshot(knownCode: ReadonlySet<object>): void;
|
|
1403
|
+
private validateControl;
|
|
1404
|
+
get cancelling(): boolean;
|
|
1405
|
+
/** Drop a new Run immediately after dispatch, without entering its body. */
|
|
1406
|
+
drop(): void;
|
|
1407
|
+
/** Roll back the active Segment and abandon every pending call without unwinding. */
|
|
1408
|
+
discard(reason: AbandonReason, betweenSegments?: boolean): string[];
|
|
1409
|
+
/** Cancellation lands here; only finally copies are kept for the next turn. */
|
|
1410
|
+
cancel(betweenSegments?: boolean): void;
|
|
1411
|
+
/** Other Runs may have committed since cancellation made this Run ready. */
|
|
1412
|
+
beginCleanupSegment(): void;
|
|
1413
|
+
/** A parked Run resumes after dispatch, with no resumption instruction. */
|
|
1414
|
+
beginReadySegment(): void;
|
|
1415
|
+
park(): boolean;
|
|
1416
|
+
private nextCancellationCleanup;
|
|
1417
|
+
/** The failed Run’s message for an internally queued error Delivery. */
|
|
1418
|
+
setDuring(value: Value): void;
|
|
1419
|
+
constructor(script: Script$1, entry: Body | Body[], args: Value[], limits?: Limits, code?: Code,
|
|
1420
|
+
/** The Selector of a Delivery that may reach a Fallback Handler. */
|
|
1421
|
+
fallback?: string);
|
|
1422
|
+
/** Whether a Fallback Handler clause runs, or is being tried (ADR 0064). */
|
|
1423
|
+
get fallback(): boolean;
|
|
1424
|
+
/** A mailbox call has no Handler Clause and starts in the value's code unit. */
|
|
1425
|
+
static fromFunction(script: Script$1, fn: Value, args: Value[], limits: Limits): Run;
|
|
1426
|
+
/** The clause number the Run's dispatch chose, or is trying. */
|
|
1427
|
+
get clauseNumber(): number;
|
|
1428
|
+
/** A successful entry dispatch, at its first body instruction. */
|
|
1429
|
+
get selectedClause(): Body | null;
|
|
1430
|
+
/** Whether entry dispatch still shares its charge with a body instruction. */
|
|
1431
|
+
get clauseChargePending(): boolean;
|
|
1432
|
+
/** Empty parameter/Guard regions still pay the clause's dispatch rate. */
|
|
1433
|
+
acceptClause(dispatchOnly: boolean): boolean;
|
|
1434
|
+
/** Run to the end of the Run. */
|
|
1435
|
+
finish(): Outcome;
|
|
1436
|
+
get done(): boolean;
|
|
1437
|
+
/** How the Run ended, once it has. */
|
|
1438
|
+
get ended(): Outcome | null;
|
|
1439
|
+
private push;
|
|
1440
|
+
private dispatch;
|
|
1441
|
+
/** Whether a dispatch has a clause left to try after the current one. */
|
|
1442
|
+
private static more;
|
|
1443
|
+
private get frame();
|
|
1444
|
+
/** Tooling-only control views; never part of Inspect or saved state. */
|
|
1445
|
+
debugFrames(): {
|
|
1446
|
+
frame: Frame;
|
|
1447
|
+
owner?: number;
|
|
1448
|
+
role?: 'retained' | 'dispatch';
|
|
1449
|
+
}[];
|
|
1450
|
+
/** Charge an instruction, faulting before it does anything if it can't pay. */
|
|
1451
|
+
private pay;
|
|
1452
|
+
private payAmount;
|
|
1453
|
+
private pop;
|
|
1454
|
+
private popN;
|
|
1455
|
+
private reader;
|
|
1456
|
+
private peek;
|
|
1457
|
+
step(clausePaid?: () => void): void;
|
|
1458
|
+
/**
|
|
1459
|
+
* Execute the simple instructions ahead, while they spend less than `room`
|
|
1460
|
+
* Fuel, without the general step's machinery. These instructions cannot
|
|
1461
|
+
* raise, fault, suspend or write a record; anything else, or a charge the
|
|
1462
|
+
* Run can't pay, is left for `step`, as is every Run with something due.
|
|
1463
|
+
* The Group calls this only when no tooling observes the steps.
|
|
1464
|
+
*/
|
|
1465
|
+
fastSteps(room: number): void;
|
|
1466
|
+
/** Internal: also called after a debug-deferred unwind. */
|
|
1467
|
+
finishInstruction(): void;
|
|
1468
|
+
/** TS tooling: a resumption consumes the suspension instruction, not a new statement. */
|
|
1469
|
+
get resumingInstruction(): boolean;
|
|
1470
|
+
/** Retain a reply while a Fuel Slice has preempted an open Join's body. */
|
|
1471
|
+
replyToOpenJoin(id: string, reply: Resumption): boolean;
|
|
1472
|
+
/** Replay buffered replies in arrival order once the Join starts waiting. */
|
|
1473
|
+
takeJoinReplies(): {
|
|
1474
|
+
id: string;
|
|
1475
|
+
reply: Resumption;
|
|
1476
|
+
}[];
|
|
1477
|
+
/** Make a suspended Run ready: its next step resumes it with `r`. */
|
|
1478
|
+
wake(r: Resumption): void;
|
|
1479
|
+
private suspend;
|
|
1480
|
+
private blockDeadline;
|
|
1481
|
+
private checkDeadline;
|
|
1482
|
+
/**
|
|
1483
|
+
* Resume at the instruction the Run suspended at, in a new Segment: an
|
|
1484
|
+
* answer is checked and its conversion charged by that instruction's rate,
|
|
1485
|
+
* then pushed; a failure or timeout raises there (chapter 8, Charging).
|
|
1486
|
+
*/
|
|
1487
|
+
private resume;
|
|
1488
|
+
private settled;
|
|
1489
|
+
private memberTarget;
|
|
1490
|
+
private withIndex;
|
|
1491
|
+
/**
|
|
1492
|
+
* Whether a message a `wait for` is waiting on fires one of its `when`
|
|
1493
|
+
* branches: the first in source order whose message, `from` and test
|
|
1494
|
+
* match. The test runs on its own, and its Fuel and allocation count
|
|
1495
|
+
* toward this Run (chapter 8, The event table).
|
|
1496
|
+
*/
|
|
1497
|
+
matchEvent(message: string, args: Value[], from: string | null, target?: Value): Extract<Resumption, {
|
|
1498
|
+
k: 'event';
|
|
1499
|
+
}> | null;
|
|
1500
|
+
/**
|
|
1501
|
+
* `the p of o` on a Host Object (chapter 4, Keys): its Core-held `id`, or
|
|
1502
|
+
* the Host's property, charged as a Capability result is, recorded as
|
|
1503
|
+
* `prop`. A key its Object Kind doesn't define gives Nothing.
|
|
1504
|
+
*/
|
|
1505
|
+
private getProperty;
|
|
1506
|
+
private collectionOf;
|
|
1507
|
+
/**
|
|
1508
|
+
* `element s of o` (#1143): the selector is checked, then the receiver,
|
|
1509
|
+
* and one Host callback answers, charged and recorded as a property
|
|
1510
|
+
* getter is. Zero and positions past 2^53 - 1 select nothing.
|
|
1511
|
+
*/
|
|
1512
|
+
private getElement;
|
|
1513
|
+
private selectElement;
|
|
1514
|
+
/** `the number of elements of o` (#1143): the Host's count, one callback. */
|
|
1515
|
+
private countElements;
|
|
1516
|
+
private elementCall;
|
|
1517
|
+
private elementResultDetail;
|
|
1518
|
+
/** `set the p of o to v`: the Host's `Set`, after the value's Shape check. */
|
|
1519
|
+
private setProperty;
|
|
1520
|
+
private propContext;
|
|
1521
|
+
private joinWidth;
|
|
1522
|
+
/** Its logical size, as Persistent State counts a suspended Run (chapter 8). */
|
|
1523
|
+
size(s?: Suspension | null): number;
|
|
1524
|
+
private leaveJoin;
|
|
1525
|
+
private abandonJoin;
|
|
1526
|
+
private fault;
|
|
1527
|
+
private faultNow;
|
|
1528
|
+
private raiseCore;
|
|
1529
|
+
/** A Core-raised error map: `code`, `message`, its fields, then `at` (chapter 6). */
|
|
1530
|
+
errorMap(code: string, fields: readonly (readonly [string, Value])[], ins: Instruction): Value;
|
|
1531
|
+
private at;
|
|
1532
|
+
private record;
|
|
1533
|
+
/**
|
|
1534
|
+
* Unwind an error from the current instruction (chapter 8, The Unwind
|
|
1535
|
+
* Table): find the first entry that holds a frame's place, charge `unwind`
|
|
1536
|
+
* for the frames search leaves, then dispatch there.
|
|
1537
|
+
*/
|
|
1538
|
+
private unwind;
|
|
1539
|
+
private unwindNow;
|
|
1540
|
+
private activeEntries;
|
|
1541
|
+
private realOwner;
|
|
1542
|
+
private callWouldExceedDepth;
|
|
1543
|
+
private realDepth;
|
|
1544
|
+
private searchCatch;
|
|
1545
|
+
private entryKey;
|
|
1546
|
+
private dispatchEntries;
|
|
1547
|
+
private excludeEntry;
|
|
1548
|
+
private escapePolicy;
|
|
1549
|
+
private withDuring;
|
|
1550
|
+
private leaveCleanupSearch;
|
|
1551
|
+
private escapeCleanup;
|
|
1552
|
+
private exitedCleanups;
|
|
1553
|
+
private acceptCatch;
|
|
1554
|
+
private nextCatch;
|
|
1555
|
+
private lookupOffer;
|
|
1556
|
+
private chooseOffer;
|
|
1557
|
+
private advanceTransfer;
|
|
1558
|
+
private checkState;
|
|
1559
|
+
private returnFrom;
|
|
1560
|
+
private callBody;
|
|
1561
|
+
private fillDefaults;
|
|
1562
|
+
private functionValue;
|
|
1563
|
+
private popArgs;
|
|
1564
|
+
/**
|
|
1565
|
+
* A Capability call (chapter 9): the arguments checked against their
|
|
1566
|
+
* Shapes, uncharged; the declared cost; the Host function, which may
|
|
1567
|
+
* `Charge` more while it starts; then an immediate call's result checked
|
|
1568
|
+
* and its conversion charged. A suspending call suspends the Run until it
|
|
1569
|
+
* is answered, fails or times out. A `Fail` raises its code, and anything
|
|
1570
|
+
* else the Host does wrong is `host error`.
|
|
1571
|
+
*/
|
|
1572
|
+
private capability;
|
|
1573
|
+
private forwardResult;
|
|
1574
|
+
private hostCrossing;
|
|
1575
|
+
private hostError;
|
|
1576
|
+
private payConversion;
|
|
1577
|
+
/**
|
|
1578
|
+
* What a call's failure raises: a `Fail` with a code the Operation may
|
|
1579
|
+
* use raises it, its Data converted and charged; anything else, given as
|
|
1580
|
+
* null, is `host error` (chapter 6, Errors from Capabilities). `record`
|
|
1581
|
+
* writes the call's failure first, when the call record carries it.
|
|
1582
|
+
*/
|
|
1583
|
+
private failure;
|
|
1584
|
+
private restrictedOperation;
|
|
1585
|
+
private execute;
|
|
1586
|
+
private replace;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Start a Run by dispatching a message to a Handler's clauses, and then, for
|
|
1590
|
+
* a message that may reach one, to the Script's Fallback Handler's (ADR 0064).
|
|
1591
|
+
*/
|
|
1592
|
+
declare const deliver: (script: Script$1, message: string, args: Value[], limits?: Partial<Limits>, fallback?: boolean) => Run;
|
|
1593
|
+
/** Call a named function of the unit, as a Run on its own. */
|
|
1594
|
+
declare const callFunction: (script: Script$1, name: string, args: Value[]) => Run;
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region src/library.d.ts
|
|
1597
|
+
type OperationRef = {
|
|
1598
|
+
capability: string;
|
|
1599
|
+
operation: string;
|
|
1600
|
+
};
|
|
1601
|
+
type LibrarySource = {
|
|
1602
|
+
name: string;
|
|
1603
|
+
source: string;
|
|
1604
|
+
version: string;
|
|
1605
|
+
};
|
|
1606
|
+
/** A compiled Library, which any Group may add (chapter 9). */
|
|
1607
|
+
type Library = {
|
|
1608
|
+
/** 32 bytes. */
|
|
1609
|
+
readonly identity: Uint8Array;
|
|
1610
|
+
readonly imports: readonly Library[];
|
|
1611
|
+
readonly name: string;
|
|
1612
|
+
readonly needs: readonly OperationRef[];
|
|
1613
|
+
readonly source: string;
|
|
1614
|
+
readonly version: string;
|
|
1615
|
+
};
|
|
1616
|
+
/** A unit's code identity, given its direct imports' identities (chapter 9). */
|
|
1617
|
+
declare const codeIdentity: (unit: "script" | "library" | "extension", name: string, source: string, imports?: readonly string[]) => string;
|
|
1618
|
+
/** How a Host asks a Library to be compiled, outside the Spec. */
|
|
1619
|
+
type LibraryOptions = {
|
|
1620
|
+
/**
|
|
1621
|
+
* An error raised in it gets an `at` naming the call that entered it, as
|
|
1622
|
+
* for stdlib code (ADR 0037), rather than its own position.
|
|
1623
|
+
*/
|
|
1624
|
+
atCaller?: boolean;
|
|
1625
|
+
};
|
|
1626
|
+
/**
|
|
1627
|
+
* Compile a Library, once per process for each code identity. `imports` holds
|
|
1628
|
+
* every Library its `use` lines name, other than the stdlib's, which are
|
|
1629
|
+
* always there. Throws LoadError.
|
|
1630
|
+
*/
|
|
1631
|
+
declare const compileLibrary: (src: LibrarySource, imports?: readonly Library[], declarations?: GrantDecls, options?: LibraryOptions) => Library;
|
|
1632
|
+
/** Recompile the complete dependent Library graph without changing its registrations. */
|
|
1633
|
+
declare const replacementLibraries: (available: ReadonlyMap<string, Library>, replacement: Library) => Map<string, Library>;
|
|
1634
|
+
//#endregion
|
|
1635
|
+
//#region src/standard-capabilities.d.ts
|
|
1636
|
+
type Costs = Readonly<Record<string, Cost>>;
|
|
1637
|
+
type ConsoleImpl = {
|
|
1638
|
+
read(call: Call<unknown>): void;
|
|
1639
|
+
write(call: Call<unknown>, value: Value): void;
|
|
1640
|
+
};
|
|
1641
|
+
type TimerImpl = {
|
|
1642
|
+
cancel(call: Call<unknown>, name: string): void;
|
|
1643
|
+
schedule(call: Call<unknown>, name: string, at: Value, message: string, args: Value): void;
|
|
1644
|
+
};
|
|
1645
|
+
/** The Pump's Clock reading; there is no Host clock implementation. */
|
|
1646
|
+
declare const clockCapability: (costs: Costs) => CapabilityDef<void>;
|
|
1647
|
+
/** The Host owns durable timers, scoped by Script and name. */
|
|
1648
|
+
declare const timerCapability: (impl: TimerImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
1649
|
+
/** The Host shows Values in text form and answers read with a line of text. */
|
|
1650
|
+
declare const consoleCapability: (impl: ConsoleImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
1651
|
+
type CalendarImpl = {
|
|
1652
|
+
now(call: Call<string>, zone?: string): Value;
|
|
1653
|
+
offset(call: Call<string>, instant: Value, zone?: string): Value;
|
|
1654
|
+
toCivil(call: Call<string>, instant: Value, zone?: string): Value;
|
|
1655
|
+
today(call: Call<string>, zone?: string): Value;
|
|
1656
|
+
toInstant(call: Call<string>, civil: Value, disambiguation: string, zone?: string): Value;
|
|
1657
|
+
zone(call: Call<string>, zone?: string): Value;
|
|
1658
|
+
};
|
|
1659
|
+
/** The Host owns zone data; the Grant binding supplies its default zone. */
|
|
1660
|
+
declare const calendarCapability: (impl: CalendarImpl, costs: Costs) => CapabilityDef<string>;
|
|
1661
|
+
//#endregion
|
|
1662
|
+
//#region src/locale-capability.d.ts
|
|
1663
|
+
type LocaleImpl = {
|
|
1664
|
+
compare(call: Call<string>, a: Value, b: Value, opts: Value, tag?: string): Value;
|
|
1665
|
+
dayNames(call: Call<string>, opts: Value, tag?: string): Value;
|
|
1666
|
+
lower(call: Call<string>, s: Value, tag?: string): Value;
|
|
1667
|
+
monthNames(call: Call<string>, opts: Value, tag?: string): Value;
|
|
1668
|
+
numberSymbols(call: Call<string>, tag?: string): Value;
|
|
1669
|
+
rank(call: Call<string>, texts: Value, opts: Value, tag?: string): Value;
|
|
1670
|
+
tag(call: Call<string>, tag?: string): Value;
|
|
1671
|
+
upper(call: Call<string>, s: Value, tag?: string): Value;
|
|
1672
|
+
};
|
|
1673
|
+
/** The Host resolves tags and provides every Operation for each Locale. */
|
|
1674
|
+
declare const localeCapability: (impl: LocaleImpl, costs: Costs) => CapabilityDef<string>;
|
|
1675
|
+
//#endregion
|
|
1676
|
+
//#region src/sqlite-capability.d.ts
|
|
1677
|
+
/**
|
|
1678
|
+
* sqlite is optional (chapter 7, ADR 0070). The binding names a database the
|
|
1679
|
+
* Host keeps; tables, when present, limits the tables a Grant may use, and
|
|
1680
|
+
* maxRows caps the rows a call may give.
|
|
1681
|
+
*/
|
|
1682
|
+
type SqliteBinding = {
|
|
1683
|
+
readonly database: string;
|
|
1684
|
+
readonly maxRows: number;
|
|
1685
|
+
readonly tables?: readonly string[];
|
|
1686
|
+
};
|
|
1687
|
+
/** NULL, INTEGER, REAL, TEXT and BLOB. */
|
|
1688
|
+
type SqlValue = null | bigint | number | string | Uint8Array;
|
|
1689
|
+
/** A list binds `?` and `?NNN`; a Map binds `:name`, keyed without the colon. */
|
|
1690
|
+
type SqlParams = readonly SqlValue[] | ReadonlyMap<string, SqlValue>;
|
|
1691
|
+
type SqlRows = {
|
|
1692
|
+
readonly columns: readonly string[];
|
|
1693
|
+
readonly rows: readonly (readonly SqlValue[])[];
|
|
1694
|
+
};
|
|
1695
|
+
/**
|
|
1696
|
+
* The Core has checked the Shapes and max, converted params by the chapter 7
|
|
1697
|
+
* rules and charged max × perRow. It converts the result, raising `sql` for a
|
|
1698
|
+
* column named twice and `unrepresentable` for a double it can't hold.
|
|
1699
|
+
* change, begin, commit and rollback are Segment-bound: they act inside the
|
|
1700
|
+
* calling Segment's transaction, which the coordinator publishes or discards.
|
|
1701
|
+
* begin, commit and rollback open, release and roll back a savepoint. A failed
|
|
1702
|
+
* call leaves the database as it was. Throw ScriptError `sql` {reason},
|
|
1703
|
+
* `constraint` {kind}, `sqlite busy`, `not read-only`, `too many rows` {max},
|
|
1704
|
+
* or `unrepresentable` {column} for TEXT that isn't valid UTF-8 (chapter 9).
|
|
1705
|
+
*/
|
|
1706
|
+
type SqliteImpl = {
|
|
1707
|
+
begin(call: Call<SqliteBinding>): void;
|
|
1708
|
+
change(call: Call<SqliteBinding>, sql: string, params: SqlParams, max: number): SqlRows & {
|
|
1709
|
+
readonly changes: number;
|
|
1710
|
+
};
|
|
1711
|
+
commit(call: Call<SqliteBinding>): void;
|
|
1712
|
+
/** Called once per Grant. The same database gives the same coordinator. */
|
|
1713
|
+
coordinator(database: string): SegmentCoordinator;
|
|
1714
|
+
query(call: Call<SqliteBinding>, sql: string, params: SqlParams, max: number): SqlRows;
|
|
1715
|
+
rollback(call: Call<SqliteBinding>): void;
|
|
1716
|
+
};
|
|
1717
|
+
/** Optional for Hosts. perRow is whole Fuel charged per row of max. */
|
|
1718
|
+
declare const sqliteCapability: (impl: SqliteImpl, costs: Costs, perRow: number) => CapabilityDef<SqliteBinding>;
|
|
1719
|
+
//#endregion
|
|
1720
|
+
//#region src/store-capability.d.ts
|
|
1721
|
+
/**
|
|
1722
|
+
* The binding is the Store's name. `set`, `delete`, `increment` and `swap`
|
|
1723
|
+
* act on the calling Segment's pending writes, to every Store it writes,
|
|
1724
|
+
* which `commit` applies together and `rollback` discards (chapter 7,
|
|
1725
|
+
* ADR 0062). The implementation is the Segment Coordinator of every binding,
|
|
1726
|
+
* so its hooks see each enrolled Store's Grant (ADR 0069). Watch registrations
|
|
1727
|
+
* are final at the call, independent of the participant, and release drops
|
|
1728
|
+
* their owner when the named Grant stops being effective (ADR 0061).
|
|
1729
|
+
*/
|
|
1730
|
+
type StoreImpl = SegmentLifecycle<string> & {
|
|
1731
|
+
delete(call: Call<string>, key: string): void;
|
|
1732
|
+
get(call: Call<string>, key: string, fallback?: Value): Value;
|
|
1733
|
+
increment(call: Call<string>, key: string, by?: Value): Value;
|
|
1734
|
+
keys(call: Call<string>, prefix?: string): Value;
|
|
1735
|
+
release(context: GrantContext<string>): void;
|
|
1736
|
+
set(call: Call<string>, key: string, value: Value): void;
|
|
1737
|
+
swap(call: Call<string>, key: string, expected: Value, replacement: Value): boolean;
|
|
1738
|
+
unwatch(call: Call<string>, name: string): void;
|
|
1739
|
+
watch(call: Call<string>, name: string, prefix: string, message: string): void;
|
|
1740
|
+
};
|
|
1741
|
+
/** The `+` rules outside any Run, uncharged (chapter 9, Adding). */
|
|
1742
|
+
declare const add: (a: Value, b: Value) => Value;
|
|
1743
|
+
/** The Store is the Host's; the Grant binding names it, and `impl` coordinates every binding. */
|
|
1744
|
+
declare const storeCapability: (impl: StoreImpl, costs: Costs) => CapabilityDef<string>;
|
|
1745
|
+
//#endregion
|
|
1746
|
+
//#region src/user-capability.d.ts
|
|
1747
|
+
/** An omitted prompt, default or title is "". */
|
|
1748
|
+
type UserImpl = {
|
|
1749
|
+
choose(call: Call<unknown>, items: readonly string[], prompt: string, multiple: boolean): void;
|
|
1750
|
+
confirm(call: Call<unknown>, message: string): void;
|
|
1751
|
+
enter(call: Call<unknown>, message: string, fallback: string): void;
|
|
1752
|
+
notify(call: Call<unknown>, message: string, title: string): void;
|
|
1753
|
+
};
|
|
1754
|
+
/** Optional for Hosts. The binding is ignored. */
|
|
1755
|
+
declare const userCapability: (impl: UserImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
1756
|
+
//#endregion
|
|
1757
|
+
//#region src/http-capability.d.ts
|
|
1758
|
+
/**
|
|
1759
|
+
* `serve` hears its effective message, `httpRequest` when omitted or
|
|
1760
|
+
* Nothing, and its options as a map, empty when omitted or Nothing, and
|
|
1761
|
+
* answers through the Call with `{host, port}`. `respond` hears the response
|
|
1762
|
+
* map as the Script gave it, except that a `json` value is replaced by its
|
|
1763
|
+
* compact JSON text, written by the `json` Library's rules.
|
|
1764
|
+
*/
|
|
1765
|
+
type HttpImpl = {
|
|
1766
|
+
respond(call: Call<unknown>, exchange: HostObject, response: Value): void;
|
|
1767
|
+
serve(call: Call<unknown>, name: string, prefix: string, message: string, options: Value): void;
|
|
1768
|
+
unserve(call: Call<unknown>, name: string): void;
|
|
1769
|
+
};
|
|
1770
|
+
/** Optional for Hosts. The binding is the Host's own description of the addresses a Grant may listen on. */
|
|
1771
|
+
declare const httpCapability: (impl: HttpImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
1772
|
+
//#endregion
|
|
1773
|
+
//#region src/versions.d.ts
|
|
1774
|
+
type Versions = {
|
|
1775
|
+
core: string;
|
|
1776
|
+
costModel: string;
|
|
1777
|
+
language: string;
|
|
1778
|
+
saveFormat: string;
|
|
1779
|
+
unicode: string;
|
|
1780
|
+
};
|
|
1781
|
+
declare const coreVersions: Versions;
|
|
1782
|
+
//#endregion
|
|
1783
|
+
//#region src/embedding.d.ts
|
|
1784
|
+
/**
|
|
1785
|
+
* Process-wide: the compile cache, and Capability and Object Kind definitions.
|
|
1786
|
+
* `createCore` is each entry point's own: synchronous on the TS Core,
|
|
1787
|
+
* asynchronous on the Zig Host Adapter.
|
|
1788
|
+
*/
|
|
1789
|
+
type Core = {
|
|
1790
|
+
calendarCapability: typeof calendarCapability;
|
|
1791
|
+
clockCapability: typeof clockCapability;
|
|
1792
|
+
/** Throws LoadError. `imports` holds every Library its `use` lines name. */
|
|
1793
|
+
compileLibrary(src: LibrarySource, imports?: Library[], declarations?: GrantDecls): Library;
|
|
1794
|
+
consoleCapability: typeof consoleCapability;
|
|
1795
|
+
defineCapability: typeof defineCapability;
|
|
1796
|
+
defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
|
|
1797
|
+
httpCapability: typeof httpCapability;
|
|
1798
|
+
localeCapability: typeof localeCapability;
|
|
1799
|
+
newGroup(o: GroupOptions): Group;
|
|
1800
|
+
restore(save: Uint8Array, o: RestoreOptions): {
|
|
1801
|
+
group: Group;
|
|
1802
|
+
result: RestoreResult;
|
|
1803
|
+
};
|
|
1804
|
+
sqliteCapability: typeof sqliteCapability;
|
|
1805
|
+
storeCapability: typeof storeCapability;
|
|
1806
|
+
timerCapability: typeof timerCapability;
|
|
1807
|
+
userCapability: typeof userCapability;
|
|
1808
|
+
readonly versions: Versions;
|
|
1809
|
+
};
|
|
1810
|
+
/**
|
|
1811
|
+
* A Script Group. The TS Core's Group adds `save(options)` and the debugger
|
|
1812
|
+
* hooks; the Zig Host Adapter's adds `memoryBytes()`, `rebind()` and `restore()`.
|
|
1813
|
+
*/
|
|
1814
|
+
type Group = {
|
|
1815
|
+
addLibrary(l: Library): void;
|
|
1816
|
+
broadcast(m: Message): string;
|
|
1817
|
+
call(fn: Value, args: Value[], o?: CancellationOptions & {
|
|
1818
|
+
limits?: LimitOverride;
|
|
1819
|
+
}): Requested;
|
|
1820
|
+
callPump(fn: Value, args: Value[], now: bigint, o?: PumpOptions & CancellationOptions & {
|
|
1821
|
+
limits?: LimitOverride;
|
|
1822
|
+
}): PumpedRequest;
|
|
1823
|
+
decide(to: HostObject, m: Message, o?: CancellationOptions): Deciding;
|
|
1824
|
+
decideBroadcast(m: Message, o?: CancellationOptions): Deciding;
|
|
1825
|
+
deliver(to: HostObject, m: Message): string;
|
|
1826
|
+
dispose(o: HostObject): void;
|
|
1827
|
+
fingerprint(): Uint8Array;
|
|
1828
|
+
inspect(): Inspection;
|
|
1829
|
+
load(o: LoadOptions): Script;
|
|
1830
|
+
readonly name: string;
|
|
1831
|
+
object<N>(kind: ObjectKind<N>, id: string, native: N): HostObject<N>;
|
|
1832
|
+
objectById(kind: string, id: string): HostObject | undefined;
|
|
1833
|
+
pump(now: bigint, o?: PumpOptions): PumpResult;
|
|
1834
|
+
replaceLibrary(l: Library, carry: CarryOver): Report[];
|
|
1835
|
+
request(to: HostObject, m: Message, o?: CancellationOptions): Requested;
|
|
1836
|
+
requestPump(to: HostObject, m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
1837
|
+
save(): Uint8Array;
|
|
1838
|
+
script(name: string): Script | undefined;
|
|
1839
|
+
scriptNames(): string[];
|
|
1840
|
+
setParent(o: HostObject, parent: HostObject | undefined): void;
|
|
1841
|
+
settle(callId: string, s: Settlement): Call<unknown> | undefined;
|
|
1842
|
+
};
|
|
1843
|
+
/** A loaded Script's handle. */
|
|
1844
|
+
type Script = {
|
|
1845
|
+
cancelRun(runId: string): void;
|
|
1846
|
+
counters(): Counters;
|
|
1847
|
+
decide(m: Message, o?: CancellationOptions): Deciding;
|
|
1848
|
+
deliver(m: Message): string;
|
|
1849
|
+
extend(source: string): void;
|
|
1850
|
+
grants(): Record<string, string[]>;
|
|
1851
|
+
invoke(name: string, ...args: Value[]): Promise<Value>;
|
|
1852
|
+
readonly name: string;
|
|
1853
|
+
reload(source: string, carry: CarryOver, o?: {
|
|
1854
|
+
keepMailbox?: boolean;
|
|
1855
|
+
}): Report[];
|
|
1856
|
+
request(m: Message, o?: CancellationOptions): Requested;
|
|
1857
|
+
requestPump(m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
1858
|
+
revoke(grantName: string): void;
|
|
1859
|
+
rewindRun(runId: string): void;
|
|
1860
|
+
stop(reason: string): void;
|
|
1861
|
+
};
|
|
1862
|
+
//#endregion
|
|
1863
|
+
//#region src/capabilities.d.ts
|
|
1864
|
+
declare const plainForm: unique symbol;
|
|
1865
|
+
/**
|
|
1866
|
+
* A Shape, carrying the JS type a typed Host function receives for it
|
|
1867
|
+
* (#1420). The type is compile-time only.
|
|
1868
|
+
*/
|
|
1869
|
+
type Shape<T = unknown> = ShapeNode & {
|
|
1870
|
+
readonly [plainForm]?: T;
|
|
1871
|
+
};
|
|
1872
|
+
type ShapeNode = {
|
|
1873
|
+
k: 'any';
|
|
1874
|
+
} | {
|
|
1875
|
+
k: 'value';
|
|
1876
|
+
} | {
|
|
1877
|
+
k: 'kind';
|
|
1878
|
+
kind: string;
|
|
1879
|
+
} | {
|
|
1880
|
+
k: 'object';
|
|
1881
|
+
kind: string;
|
|
1882
|
+
} | {
|
|
1883
|
+
k: 'quantity';
|
|
1884
|
+
unit: string;
|
|
1885
|
+
} | {
|
|
1886
|
+
k: 'unitKind';
|
|
1887
|
+
kind: string;
|
|
1888
|
+
} | {
|
|
1889
|
+
k: 'list';
|
|
1890
|
+
of: Shape;
|
|
1891
|
+
} | {
|
|
1892
|
+
fields: readonly {
|
|
1893
|
+
key: string;
|
|
1894
|
+
optional: boolean;
|
|
1895
|
+
shape: Shape;
|
|
1896
|
+
}[];
|
|
1897
|
+
k: 'map';
|
|
1898
|
+
open: boolean;
|
|
1899
|
+
} | {
|
|
1900
|
+
k: 'oneOf';
|
|
1901
|
+
of: readonly Shape[];
|
|
1902
|
+
} | {
|
|
1903
|
+
k: 'optional';
|
|
1904
|
+
of: Shape;
|
|
1905
|
+
};
|
|
1906
|
+
type FieldShape = Shape | {
|
|
1907
|
+
optional: true;
|
|
1908
|
+
shape: Shape;
|
|
1909
|
+
};
|
|
1910
|
+
/** The Shape constructors of `talk.ts`. */
|
|
1911
|
+
declare const shape: {
|
|
1912
|
+
any: Shape<Value>;
|
|
1913
|
+
value: Shape<Value>;
|
|
1914
|
+
nothing: Shape<null>;
|
|
1915
|
+
bool: Shape<boolean>;
|
|
1916
|
+
number: Shape<Decimal>;
|
|
1917
|
+
text: Shape<string>;
|
|
1918
|
+
bytes: Shape<Uint8Array>;
|
|
1919
|
+
instant: Shape<bigint>;
|
|
1920
|
+
civilDate: Shape<Value>;
|
|
1921
|
+
range: Shape<Value>;
|
|
1922
|
+
pattern: Shape<Value>;
|
|
1923
|
+
function: Shape<Value>;
|
|
1924
|
+
object: <N>(kind: ObjectKind<N>) => Shape<HostObject<N>>;
|
|
1925
|
+
quantityOf: (unit: string) => Shape<Value>;
|
|
1926
|
+
quantityKind: (unitKind: string) => Shape<Value>;
|
|
1927
|
+
listOf: (of: Shape) => Shape<Value>;
|
|
1928
|
+
map: (fields: Record<string, FieldShape>) => Shape<Value>;
|
|
1929
|
+
openMap: (fields: Record<string, FieldShape>) => Shape<Value>;
|
|
1930
|
+
oneOf: (...of: Shape[]) => Shape<Value>;
|
|
1931
|
+
/** Supplied Nothing is null; an omitted trailing argument is undefined. */
|
|
1932
|
+
optional: <T>(of: Shape<T>) => Shape<T | null | undefined>;
|
|
1933
|
+
};
|
|
1934
|
+
type ScopeDecl = {
|
|
1935
|
+
abandon: string;
|
|
1936
|
+
opens: string;
|
|
1937
|
+
} | {
|
|
1938
|
+
closes: string;
|
|
1939
|
+
};
|
|
1940
|
+
/** Synchronous, unmetered participant lifecycle work. */
|
|
1941
|
+
type SegmentContext<B> = {
|
|
1942
|
+
readonly binding: B;
|
|
1943
|
+
/** The first enrolled Grant. */
|
|
1944
|
+
readonly grantName: string;
|
|
1945
|
+
/** Enrolled, in enrollment order; `begin` sees only the first. */
|
|
1946
|
+
readonly grants: readonly SegmentGrant<B>[];
|
|
1947
|
+
readonly group: Group;
|
|
1948
|
+
readonly now: bigint;
|
|
1949
|
+
readonly runId: string;
|
|
1950
|
+
readonly scriptName: string;
|
|
1951
|
+
readonly segmentId: string;
|
|
1952
|
+
};
|
|
1953
|
+
type SegmentGrant<B> = {
|
|
1954
|
+
readonly binding: B;
|
|
1955
|
+
readonly grantName: string;
|
|
1956
|
+
};
|
|
1957
|
+
type EffectResult = {
|
|
1958
|
+
detail?: string;
|
|
1959
|
+
status: 'ok' | 'failed' | 'unknown';
|
|
1960
|
+
};
|
|
1961
|
+
type SegmentLifecycle<B> = {
|
|
1962
|
+
begin(context: SegmentContext<B>): EffectResult;
|
|
1963
|
+
commit(context: SegmentContext<B>): EffectResult;
|
|
1964
|
+
rollback(context: SegmentContext<B>): EffectResult;
|
|
1965
|
+
};
|
|
1966
|
+
/** Compared by identity: Grants mapped to one coordinator share a Segment's participant (ADR 0069). */
|
|
1967
|
+
type SegmentCoordinator = SegmentLifecycle<unknown>;
|
|
1968
|
+
/** Maps each binding to its coordinator once, when a Grant is created. */
|
|
1969
|
+
type CoordinatedLifecycle<B> = {
|
|
1970
|
+
coordinator(binding: B): SegmentCoordinator;
|
|
1971
|
+
};
|
|
1972
|
+
type Cost = {
|
|
1973
|
+
alloc?: number;
|
|
1974
|
+
fuel: number;
|
|
1975
|
+
};
|
|
1976
|
+
type ErrorDecl = {
|
|
1977
|
+
code: string;
|
|
1978
|
+
fields?: Record<string, FieldShape>;
|
|
1979
|
+
};
|
|
1980
|
+
type OpBase<A extends readonly Shape[] = Shape[], R = Shape> = {
|
|
1981
|
+
args?: A;
|
|
1982
|
+
/** Also callable as a Host Command, by its name alone (ADR 0094). */
|
|
1983
|
+
command?: boolean;
|
|
1984
|
+
cost: Cost;
|
|
1985
|
+
/** Plain-text documentation, carried only by the Host Manifest. */
|
|
1986
|
+
description?: string;
|
|
1987
|
+
errors?: ErrorDecl[];
|
|
1988
|
+
examples?: string[];
|
|
1989
|
+
/**
|
|
1990
|
+
* Argument Labels, one per argument after the first, that a call may write
|
|
1991
|
+
* between its arguments; checked at load only (ADR 0115). Empty is absent.
|
|
1992
|
+
*/
|
|
1993
|
+
labels?: string[];
|
|
1994
|
+
result?: R;
|
|
1995
|
+
};
|
|
1996
|
+
/** What the Core gives a Host function at each call (chapter 9, The call). */
|
|
1997
|
+
type Call<B, R = Value> = {
|
|
1998
|
+
/** Queued, for a suspending call; ignored once the call isn't pending. */
|
|
1999
|
+
answer(v: R, lateCost?: {
|
|
2000
|
+
fuel: number;
|
|
2001
|
+
}): void;
|
|
2002
|
+
readonly automatic: boolean;
|
|
2003
|
+
readonly binding: B;
|
|
2004
|
+
/** Draws more Fuel, before the work. Throws LimitReached. */
|
|
2005
|
+
charge(fuel: number): void;
|
|
2006
|
+
/** The Host Delivery that started the calling Run; absent when none did (ADR 0125). */
|
|
2007
|
+
readonly delivery?: string;
|
|
2008
|
+
fail(e: ScriptError): void;
|
|
2009
|
+
readonly grantName: string;
|
|
2010
|
+
readonly group: Group;
|
|
2011
|
+
readonly id: string;
|
|
2012
|
+
readonly now: bigint;
|
|
2013
|
+
readonly runId: string;
|
|
2014
|
+
readonly scopeName?: string;
|
|
2015
|
+
readonly scriptName: string;
|
|
2016
|
+
readonly segmentId: string;
|
|
2017
|
+
readonly signal: AbortSignal;
|
|
2018
|
+
};
|
|
2019
|
+
/**
|
|
2020
|
+
* The JS type a Host function receives for an argument of Shape S (#1420):
|
|
2021
|
+
* scalars as their JS forms, Nothing as null, a Host Object as its handle,
|
|
2022
|
+
* and every other Shape as the Value. A Shape whose type was lost is unknown.
|
|
2023
|
+
*/
|
|
2024
|
+
type PlainArg<S> = S extends Shape<infer T> ? (unknown extends T ? unknown : T) : unknown;
|
|
2025
|
+
/** What a Host function may return for a result of Shape R: its JS form, a bigint for a number, or any Value. */
|
|
2026
|
+
type PlainResult<R> = [R] extends [undefined] ? Value : (R extends Shape<infer T> ? unknown extends T ? unknown : T extends Decimal ? Decimal | bigint : T : unknown) | Value;
|
|
2027
|
+
type PlainArgs<A extends readonly Shape[]> = { -readonly [K in keyof A]: PlainArg<A[K]>; };
|
|
2028
|
+
type ImmediateOp<B, A extends readonly Shape[] = Shape[], R = Shape> = OpBase<A, R> & {
|
|
2029
|
+
do(call: Call<B, PlainResult<R>>, ...args: PlainArgs<A>): PlainResult<R>;
|
|
2030
|
+
mode: 'immediate';
|
|
2031
|
+
scope?: ScopeDecl;
|
|
2032
|
+
segmentBound?: boolean;
|
|
2033
|
+
};
|
|
2034
|
+
type SuspendingOp<B, A extends readonly Shape[] = Shape[], R = Shape> = OpBase<A, R> & {
|
|
2035
|
+
maxPendingMs?: number;
|
|
2036
|
+
mode: 'suspending';
|
|
2037
|
+
run?(call: Call<B, PlainResult<R>>, ...args: PlainArgs<A>): Promise<PlainResult<R>>;
|
|
2038
|
+
start?(call: Call<B, PlainResult<R>>, ...args: PlainArgs<A>): void;
|
|
2039
|
+
};
|
|
2040
|
+
type FireOp<B, A extends readonly Shape[] = Shape[], R = Shape> = OpBase<A, R> & {
|
|
2041
|
+
fire(call: Call<B, PlainResult<R>>, ...args: PlainArgs<A>): void;
|
|
2042
|
+
mode: 'fire-and-forget';
|
|
2043
|
+
};
|
|
2044
|
+
/** An Operation whose Host function takes the JS forms of its Shapes (#1420). */
|
|
2045
|
+
type Operation<B, A extends readonly Shape[] = Shape[], R = Shape> = ImmediateOp<B, A, R> | SuspendingOp<B, A, R> | FireOp<B, A, R>;
|
|
2046
|
+
/** The Core's own form: every argument and result is a Value. */
|
|
2047
|
+
type ValueImmediateOp<B> = OpBase & {
|
|
2048
|
+
do(call: Call<B>, ...args: Value[]): Value;
|
|
2049
|
+
mode: 'immediate';
|
|
2050
|
+
scope?: ScopeDecl;
|
|
2051
|
+
segmentBound?: boolean;
|
|
2052
|
+
};
|
|
2053
|
+
type ValueSuspendingOp<B> = OpBase & {
|
|
2054
|
+
maxPendingMs?: number;
|
|
2055
|
+
mode: 'suspending';
|
|
2056
|
+
run?(call: Call<B>, ...args: Value[]): Promise<Value>;
|
|
2057
|
+
start?(call: Call<B>, ...args: Value[]): void;
|
|
2058
|
+
};
|
|
2059
|
+
type ValueFireOp<B> = OpBase & {
|
|
2060
|
+
fire(call: Call<B>, ...args: Value[]): void;
|
|
2061
|
+
mode: 'fire-and-forget';
|
|
2062
|
+
};
|
|
2063
|
+
type ValueOperation<B> = ValueImmediateOp<B> | ValueSuspendingOp<B> | ValueFireOp<B>;
|
|
2064
|
+
type OpDecl = {
|
|
2065
|
+
args?: readonly Shape[];
|
|
2066
|
+
mode: Operation<unknown>['mode'];
|
|
2067
|
+
result?: Shape;
|
|
2068
|
+
};
|
|
2069
|
+
type ArgsOf<D> = D extends {
|
|
2070
|
+
args: infer A extends readonly Shape[];
|
|
2071
|
+
} ? A : D extends {
|
|
2072
|
+
args?: infer A extends readonly Shape[];
|
|
2073
|
+
} ? A : [];
|
|
2074
|
+
type ResultOf<D> = D extends {
|
|
2075
|
+
result: infer R;
|
|
2076
|
+
} ? R : D extends {
|
|
2077
|
+
result?: infer R;
|
|
2078
|
+
} ? R : undefined;
|
|
2079
|
+
type ByMode<B, D> = D extends {
|
|
2080
|
+
mode: 'immediate';
|
|
2081
|
+
} ? ImmediateOp<B, ArgsOf<D>, ResultOf<D>> : D extends {
|
|
2082
|
+
mode: 'suspending';
|
|
2083
|
+
} ? SuspendingOp<B, ArgsOf<D>, ResultOf<D>> : FireOp<B, ArgsOf<D>, ResultOf<D>>;
|
|
2084
|
+
/**
|
|
2085
|
+
* Each Operation typed from its own `args` and `result`: the Pick lets
|
|
2086
|
+
* TypeScript infer them from the literal before it types the callbacks.
|
|
2087
|
+
*/
|
|
2088
|
+
type Operations<B, O> = { [K in keyof O]: Pick<O[K], keyof OpDecl & keyof O[K]> & ByMode<B, O[K]>; };
|
|
2089
|
+
/** Thrown by `call.charge` when the Run's Fuel can't cover it. */
|
|
2090
|
+
declare class LimitReached extends Error {
|
|
2091
|
+
name: string;
|
|
2092
|
+
}
|
|
2093
|
+
type ReleaseReason = 'stop' | 'reload' | 'revoke' | 'disable';
|
|
2094
|
+
/** One loaded Script's named Grant, identified within its Group. */
|
|
2095
|
+
type GrantContext<B> = {
|
|
2096
|
+
readonly binding: B;
|
|
2097
|
+
readonly grantName: string;
|
|
2098
|
+
readonly group: Group;
|
|
2099
|
+
readonly now: bigint;
|
|
2100
|
+
readonly reason: ReleaseReason;
|
|
2101
|
+
readonly scriptName: string;
|
|
2102
|
+
};
|
|
2103
|
+
/** Synchronous, unmetered cleanup. Exceptions cannot refuse release. */
|
|
2104
|
+
type ReleaseHook<B> = (context: GrantContext<B>) => void;
|
|
2105
|
+
type CapabilityDef<B> = {
|
|
2106
|
+
/** Maps a Grant's binding to its Segment Coordinator. */
|
|
2107
|
+
coordinator?(binding: B): SegmentCoordinator;
|
|
2108
|
+
/** A reusable template. Each load binds it to one Script. */
|
|
2109
|
+
grant(ops: readonly string[] | 'all', binding: B): Grant<B>;
|
|
2110
|
+
/** A plain lifecycle, making each Grant its own coordinator. */
|
|
2111
|
+
readonly lifecycle?: SegmentLifecycle<B>;
|
|
2112
|
+
readonly name: string;
|
|
2113
|
+
/** Its Operations, ordered by name. */
|
|
2114
|
+
readonly operations: ReadonlyMap<string, ValueOperation<B>>;
|
|
2115
|
+
release?(context: GrantContext<B>): void;
|
|
2116
|
+
};
|
|
2117
|
+
type Grant<B> = {
|
|
2118
|
+
readonly binding: B;
|
|
2119
|
+
readonly capability: CapabilityDef<B>;
|
|
2120
|
+
/** Resolved at Grant creation; absent when the Grant is its own coordinator. */
|
|
2121
|
+
readonly coordinator?: SegmentCoordinator;
|
|
2122
|
+
readonly ops: ReadonlySet<string>;
|
|
2123
|
+
};
|
|
2124
|
+
type CapabilityDefiner<B> = <const O extends Record<string, OpDecl>>(name: string, ops: Operations<B, O>, lifecycle?: SegmentLifecycle<B> | CoordinatedLifecycle<B>, release?: ReleaseHook<B>) => CapabilityDef<B>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Define a Capability, once per process (chapter 9, Capabilities). Each Host
|
|
2127
|
+
* function takes the JS forms of its argument Shapes and may return its
|
|
2128
|
+
* result's JS form (#1420). With a binding, name its type by currying:
|
|
2129
|
+
* `defineCapability<Db>()(name, ops)`.
|
|
2130
|
+
*/
|
|
2131
|
+
declare function defineCapability<const O extends Record<string, OpDecl>>(name: string, ops: Operations<void, O>, lifecycle?: SegmentLifecycle<void> | CoordinatedLifecycle<void>, release?: ReleaseHook<void>): CapabilityDef<void>;
|
|
2132
|
+
declare function defineCapability<B>(): CapabilityDefiner<B>;
|
|
2133
|
+
//#endregion
|
|
2134
|
+
//#region src/effects.d.ts
|
|
2135
|
+
type OperationMode = 'immediate' | 'suspending' | 'fire-and-forget';
|
|
2136
|
+
/** Each Grant's Operations, by the name the Script uses. */
|
|
2137
|
+
type GrantDecls = Readonly<Record<string, Readonly<Record<string, {
|
|
2138
|
+
args: readonly Shape[];
|
|
2139
|
+
command?: boolean;
|
|
2140
|
+
labels?: readonly string[];
|
|
2141
|
+
mode: OperationMode;
|
|
2142
|
+
}>>>>;
|
|
2143
|
+
//#endregion
|
|
2144
|
+
//#region src/objects.d.ts
|
|
2145
|
+
type PropDef<N> = {
|
|
2146
|
+
get(o: HostObject<N>): Value;
|
|
2147
|
+
getCost?: Cost;
|
|
2148
|
+
/** Omit for read-only. Throw ScriptError to refuse. */
|
|
2149
|
+
set?(o: HostObject<N>, v: Value): void;
|
|
2150
|
+
setCost?: Cost;
|
|
2151
|
+
shape?: Shape;
|
|
2152
|
+
};
|
|
2153
|
+
/**
|
|
2154
|
+
* An Object Kind's ordered, named collection of Host Objects (#1143). Its
|
|
2155
|
+
* callbacks are synchronous and read-only, like a property's `get`; `at`
|
|
2156
|
+
* gets a nonzero index, negative from the end.
|
|
2157
|
+
*/
|
|
2158
|
+
type ObjectElements<N> = {
|
|
2159
|
+
at(o: HostObject<N>, index: number): Value;
|
|
2160
|
+
atCost: Cost;
|
|
2161
|
+
count(o: HostObject<N>): Value;
|
|
2162
|
+
countCost: Cost;
|
|
2163
|
+
find(o: HostObject<N>, name: string): Value;
|
|
2164
|
+
findCost: Cost;
|
|
2165
|
+
shape: Shape;
|
|
2166
|
+
};
|
|
2167
|
+
type ObjectKindDef<N> = {
|
|
2168
|
+
/** Omit for a kind with no collection. */
|
|
2169
|
+
elements?: ObjectElements<N>;
|
|
2170
|
+
name: string;
|
|
2171
|
+
/** For the Host Manifest only; `setParent` doesn't check it. */
|
|
2172
|
+
parentKinds?: string[];
|
|
2173
|
+
props: Record<string, PropDef<N>>;
|
|
2174
|
+
};
|
|
2175
|
+
type ObjectKind<N = unknown> = {
|
|
2176
|
+
readonly elements: Readonly<ObjectElements<N>> | null;
|
|
2177
|
+
readonly name: string;
|
|
2178
|
+
readonly parentKinds: readonly string[];
|
|
2179
|
+
readonly props: ReadonlyMap<string, PropDef<N>>;
|
|
2180
|
+
};
|
|
2181
|
+
/** Define an Object Kind, once per process. */
|
|
2182
|
+
declare const defineObjectKind: <N>(k: ObjectKindDef<N>) => ObjectKind<N>;
|
|
2183
|
+
/** A Group-scoped handle to something the Host owns. */
|
|
2184
|
+
type HostObject<N = unknown> = {
|
|
2185
|
+
readonly id: string;
|
|
2186
|
+
readonly kind: ObjectKind<N>;
|
|
2187
|
+
readonly native: N;
|
|
2188
|
+
readonly value: Value;
|
|
2189
|
+
};
|
|
2190
|
+
/** What the Group holds for each of its objects (chapter 9, Host Objects). */
|
|
2191
|
+
type ObjectState = {
|
|
2192
|
+
disposed: boolean;
|
|
2193
|
+
handle: HostObject;
|
|
2194
|
+
/** The Script that owns it, by name. */
|
|
2195
|
+
owner: string | null;
|
|
2196
|
+
parent: ObjectState | null;
|
|
2197
|
+
};
|
|
2198
|
+
//#endregion
|
|
2199
|
+
//#region src/dates.d.ts
|
|
2200
|
+
/** The current wall-clock time as epoch microseconds, for `pump`. */
|
|
2201
|
+
declare const nowMicros: () => bigint;
|
|
2202
|
+
/** A Civil Date: a date, and a time of day as microseconds since midnight, or null. */
|
|
2203
|
+
type CivilRef = {
|
|
2204
|
+
readonly day: number;
|
|
2205
|
+
readonly month: number;
|
|
2206
|
+
/** Microseconds since midnight, for a date-time; null for a date-only value. */
|
|
2207
|
+
readonly us: bigint | null;
|
|
2208
|
+
readonly year: number;
|
|
2209
|
+
};
|
|
2210
|
+
/** A Civil Date from its fields, or a reason it isn't one. */
|
|
2211
|
+
declare const civilFromFields: (f: {
|
|
2212
|
+
day: number;
|
|
2213
|
+
hour?: number;
|
|
2214
|
+
microsecond?: number;
|
|
2215
|
+
minute?: number;
|
|
2216
|
+
month: number;
|
|
2217
|
+
second?: number;
|
|
2218
|
+
year: number;
|
|
2219
|
+
}) => CivilRef | string;
|
|
2220
|
+
/** A Civil Date's fields, as the Host reads them. */
|
|
2221
|
+
declare const civilFields: (c: CivilRef) => {
|
|
2222
|
+
year: number;
|
|
2223
|
+
month: number;
|
|
2224
|
+
day: number;
|
|
2225
|
+
} | {
|
|
2226
|
+
hour: number;
|
|
2227
|
+
minute: number;
|
|
2228
|
+
second: number;
|
|
2229
|
+
microsecond: number;
|
|
2230
|
+
year: number;
|
|
2231
|
+
month: number;
|
|
2232
|
+
day: number;
|
|
2233
|
+
};
|
|
2234
|
+
/** An Instant's text form, always in UTC: `2026-09-27T13:30:00Z`. */
|
|
2235
|
+
declare const formatInstant: (us: bigint) => string;
|
|
2236
|
+
/** An Instant's display form as epoch microseconds, for the Host and the Trace. */
|
|
2237
|
+
declare const parseInstant: (s: string) => bigint;
|
|
2238
|
+
//#endregion
|
|
2239
|
+
//#region src/values.d.ts
|
|
2240
|
+
/** The kinds implemented so far; the rest of chapter 3's follow with #126. */
|
|
2241
|
+
type Kind = 'nothing' | 'boolean' | 'number' | 'quantity' | 'text' | 'bytes' | 'list' | 'map' | 'range' | 'instant' | 'civil date' | 'pattern' | 'function' | 'object';
|
|
2242
|
+
type Pairs = readonly (readonly [string, Value])[];
|
|
2243
|
+
/**
|
|
2244
|
+
* A Function Value (chapter 3, ADR 0025): its Home Script, where its code is,
|
|
2245
|
+
* its captured values in capture-slot order, and its may-suspend flag. `code`
|
|
2246
|
+
* is the Abstract Machine's own reference, which no Host or Script sees.
|
|
2247
|
+
*/
|
|
2248
|
+
type FunctionRef = {
|
|
2249
|
+
readonly captures: Pairs;
|
|
2250
|
+
readonly code: unknown;
|
|
2251
|
+
/** The extension unit used in the display form, while home remains the Script. */
|
|
2252
|
+
readonly displayHome?: string;
|
|
2253
|
+
/** The Core's Group identity; rebound by same-family restore. */
|
|
2254
|
+
readonly group?: object;
|
|
2255
|
+
readonly home: string;
|
|
2256
|
+
/** Equal for the same Lambda or named function in the same Home Script. */
|
|
2257
|
+
readonly identity: string;
|
|
2258
|
+
readonly maySuspend: boolean;
|
|
2259
|
+
/** Where its code is, as its display form shows it: `12:3`, `tax`, `text:pad`. */
|
|
2260
|
+
readonly place: string;
|
|
2261
|
+
};
|
|
2262
|
+
/** A Text Pattern: its canonical source, and the matcher's own data. */
|
|
2263
|
+
type PatternRef = {
|
|
2264
|
+
readonly data: unknown;
|
|
2265
|
+
/** The number of instructions in its compiled program. */
|
|
2266
|
+
readonly program: number;
|
|
2267
|
+
readonly source: string;
|
|
2268
|
+
};
|
|
2269
|
+
/**
|
|
2270
|
+
* A Host Object (chapter 3): its kind and its id, and the Group's own handle,
|
|
2271
|
+
* whose identity is the object's, so two are equal only when they are one.
|
|
2272
|
+
*/
|
|
2273
|
+
type ObjectRef = {
|
|
2274
|
+
readonly handle: unknown;
|
|
2275
|
+
readonly id: string;
|
|
2276
|
+
readonly kind: string;
|
|
2277
|
+
};
|
|
2278
|
+
/** A Quantity: its number and its Unit, in Kind order (chapter 3). */
|
|
2279
|
+
type QuantityRef = {
|
|
2280
|
+
readonly number: Decimal;
|
|
2281
|
+
readonly unit: UnitSpec;
|
|
2282
|
+
};
|
|
2283
|
+
declare class Decimal {
|
|
2284
|
+
#private;
|
|
2285
|
+
private constructor();
|
|
2286
|
+
toString(): string;
|
|
2287
|
+
toBigInt(): bigint;
|
|
2288
|
+
toNumberLossy(): number;
|
|
2289
|
+
}
|
|
2290
|
+
/** Immutable, opaque value. Host code uses the named constructors. */
|
|
2291
|
+
declare class Value {
|
|
2292
|
+
#private;
|
|
2293
|
+
readonly kind: Kind;
|
|
2294
|
+
private constructor();
|
|
2295
|
+
static isValue(input: unknown): input is Value;
|
|
2296
|
+
asText(): string | undefined;
|
|
2297
|
+
asBool(): boolean | undefined;
|
|
2298
|
+
asDecimal(): Decimal | undefined;
|
|
2299
|
+
/** A Quantity's number and its Unit in normal form, as the Host reads it. */
|
|
2300
|
+
asQuantity(): {
|
|
2301
|
+
number: Decimal;
|
|
2302
|
+
unit: string;
|
|
2303
|
+
} | undefined;
|
|
2304
|
+
/** The Abstract Machine's view of a Quantity: its Unit's slots. */
|
|
2305
|
+
asQuantityRef(): QuantityRef | undefined;
|
|
2306
|
+
/** An Instant as epoch microseconds. */
|
|
2307
|
+
asInstant(): bigint | undefined;
|
|
2308
|
+
/** A Civil Date's fields; a date-only value has no time fields. */
|
|
2309
|
+
asCivilDate(): ReturnType<typeof civilFields> | undefined;
|
|
2310
|
+
/** The Abstract Machine's view of a Civil Date. */
|
|
2311
|
+
civilRef(): CivilRef | undefined;
|
|
2312
|
+
/** A copy of the bytes. */
|
|
2313
|
+
asBytes(): Uint8Array | undefined;
|
|
2314
|
+
/** The Abstract Machine's view of Bytes, which it never writes to. */
|
|
2315
|
+
bytesView(): Uint8Array | undefined;
|
|
2316
|
+
asRange(): {
|
|
2317
|
+
from: Value;
|
|
2318
|
+
to: Value;
|
|
2319
|
+
} | undefined;
|
|
2320
|
+
/** A Function Value's Home Script, its only Host-visible read. */
|
|
2321
|
+
homeScript(): string | undefined;
|
|
2322
|
+
/** A Text Pattern's canonical source, for display. */
|
|
2323
|
+
patternSource(): string | undefined;
|
|
2324
|
+
asPattern(): PatternRef | undefined;
|
|
2325
|
+
/** The Host Object handle this value stands for (chapter 9). */
|
|
2326
|
+
asObject(): HostObject | undefined;
|
|
2327
|
+
/** A Host Object's kind, id and handle. */
|
|
2328
|
+
asObjectRef(): ObjectRef | undefined;
|
|
2329
|
+
/** The Abstract Machine's view of a Function Value. */
|
|
2330
|
+
asFunction(): FunctionRef | undefined;
|
|
2331
|
+
get length(): number;
|
|
2332
|
+
index(i: number): Value;
|
|
2333
|
+
get(key: string): Value;
|
|
2334
|
+
/** Internal: the frozen pairs themselves, without copying. */
|
|
2335
|
+
mapPairs(): Pairs | undefined;
|
|
2336
|
+
get mapSize(): number;
|
|
2337
|
+
hasKey(key: string): boolean;
|
|
2338
|
+
entries(): [string, Value][];
|
|
2339
|
+
equals(other: Value): boolean;
|
|
2340
|
+
toString(): string;
|
|
2341
|
+
}
|
|
2342
|
+
declare const nothing: Value;
|
|
2343
|
+
declare const bool: (b: boolean) => Value;
|
|
2344
|
+
declare const text: (s: string) => Value;
|
|
2345
|
+
declare const dec: (s: string) => Value;
|
|
2346
|
+
/** ECMAScript's shortest round-trip digits, expanded without rounding. */
|
|
2347
|
+
declare const num: (n: number | bigint) => Value;
|
|
2348
|
+
declare const list: (...vs: Value[]) => Value;
|
|
2349
|
+
/** Two numbers, or two Quantities of one dimension, kept as given (ADR 0034). */
|
|
2350
|
+
declare const range: (from: Value, to: Value) => Value;
|
|
2351
|
+
/**
|
|
2352
|
+
* A Quantity of a number Value in a Unit spelled as a Script spells it, such
|
|
2353
|
+
* as `"kg"`. A Unit whose slots all drop, such as `"m/m"`, leaves the number.
|
|
2354
|
+
*/
|
|
2355
|
+
declare const quantity: (n: Value, unit: string) => Value;
|
|
2356
|
+
/** An Instant, from epoch microseconds; a JS Date is never accepted. */
|
|
2357
|
+
declare const instant: (epochMicros: bigint) => Value;
|
|
2358
|
+
type DateFields = Parameters<typeof civilFromFields>[0];
|
|
2359
|
+
/** A Civil Date, from its fields or from text in the `as civil date` form. */
|
|
2360
|
+
declare const civilDate: (f: DateFields | string) => Value;
|
|
2361
|
+
/** Bytes, copied in. */
|
|
2362
|
+
declare const bytes: (b: Uint8Array) => Value;
|
|
2363
|
+
declare const map: (input: Map<string, Value> | Iterable<[string, Value]>) => Value;
|
|
2364
|
+
declare const record: (input: Record<string, Value>) => Value;
|
|
2365
|
+
/**
|
|
2366
|
+
* Tooling's source form: the display form, with the substitutions that make it
|
|
2367
|
+
* source that reads back as an equal value with the same display form. Nothing
|
|
2368
|
+
* about it is normative (ADR 0028). An unreadable value keeps its display form.
|
|
2369
|
+
*/
|
|
2370
|
+
declare const sourceForm: (value: Value) => string;
|
|
2371
|
+
/** A value is readable when it contains no Function Value or Host Object. */
|
|
2372
|
+
declare const isReadable: (value: Value) => boolean;
|
|
2373
|
+
//#endregion
|
|
2374
|
+
//#region src/run-accounting.d.ts
|
|
2375
|
+
type RunAncestry = {
|
|
2376
|
+
parentCall?: string;
|
|
2377
|
+
parentRun?: string;
|
|
2378
|
+
rootDelivery: string;
|
|
2379
|
+
};
|
|
2380
|
+
type RunStarted = RunAncestry & {
|
|
2381
|
+
args: Value[];
|
|
2382
|
+
delivery?: string;
|
|
2383
|
+
fn?: Value;
|
|
2384
|
+
kind: 'run started';
|
|
2385
|
+
run: string;
|
|
2386
|
+
script: string;
|
|
2387
|
+
selector?: string;
|
|
2388
|
+
};
|
|
2389
|
+
type RunDiscarded = RunAncestry & {
|
|
2390
|
+
kind: 'run discarded';
|
|
2391
|
+
reason: string;
|
|
2392
|
+
run: string;
|
|
2393
|
+
script: string;
|
|
2394
|
+
};
|
|
2395
|
+
type RunAccounting = RunAncestry & {
|
|
2396
|
+
fuel: number;
|
|
2397
|
+
kind: 'run accounting';
|
|
2398
|
+
run: string;
|
|
2399
|
+
script: string;
|
|
2400
|
+
state: 'live' | 'terminal' | 'discarded';
|
|
2401
|
+
};
|
|
2402
|
+
type CausalWork = {
|
|
2403
|
+
discardedMessages: number;
|
|
2404
|
+
kind: 'causal work';
|
|
2405
|
+
liveRuns: number;
|
|
2406
|
+
queuedMessages: number;
|
|
2407
|
+
rootDelivery: string;
|
|
2408
|
+
};
|
|
2409
|
+
type AccountingReport = RunStarted | RunDiscarded | RunAccounting | CausalWork;
|
|
2410
|
+
//#endregion
|
|
2411
|
+
//#region src/group.d.ts
|
|
2412
|
+
type GroupOptions = {
|
|
2413
|
+
name: string;
|
|
2414
|
+
/**
|
|
2415
|
+
* Called once per queued Host Input. Don't pump inside it.
|
|
2416
|
+
* Inputs queued during a Pump notify in a microtask after it returns.
|
|
2417
|
+
*/
|
|
2418
|
+
onReady?(): void;
|
|
2419
|
+
/**
|
|
2420
|
+
* Seeds the generator `random` draws from, a whole number 0 to 2^64 - 1;
|
|
2421
|
+
* 0 when absent (chapter 7, Random numbers).
|
|
2422
|
+
*/
|
|
2423
|
+
seed?: bigint;
|
|
2424
|
+
/** Receives each Trace line, without its LF. */
|
|
2425
|
+
trace?: (line: string) => void;
|
|
2426
|
+
};
|
|
2427
|
+
/**
|
|
2428
|
+
* TS-internal, and not exported from the package: the Trace records a
|
|
2429
|
+
* Session Host follows its Runs through (ADR 0045), as typed values.
|
|
2430
|
+
*/
|
|
2431
|
+
type RunEvent = {
|
|
2432
|
+
/** Suspended: the calls, replies or Join Members it still waits for. */
|
|
2433
|
+
calls: string[];
|
|
2434
|
+
/** At a start, its Delivery. */
|
|
2435
|
+
delivery?: string;
|
|
2436
|
+
end: string;
|
|
2437
|
+
how: 'start' | 'resume' | 'continue';
|
|
2438
|
+
k: 'seg';
|
|
2439
|
+
run: string;
|
|
2440
|
+
until?: bigint;
|
|
2441
|
+
} | {
|
|
2442
|
+
call: string;
|
|
2443
|
+
k: 'call';
|
|
2444
|
+
run: string;
|
|
2445
|
+
} | {
|
|
2446
|
+
args: Value[];
|
|
2447
|
+
k: 'unhandled';
|
|
2448
|
+
message: string;
|
|
2449
|
+
run?: string;
|
|
2450
|
+
} | {
|
|
2451
|
+
delivery?: string;
|
|
2452
|
+
error?: Value;
|
|
2453
|
+
k: 'run';
|
|
2454
|
+
outcome: string;
|
|
2455
|
+
run: string;
|
|
2456
|
+
};
|
|
2457
|
+
/**
|
|
2458
|
+
* TS-internal, and not exported from the package: how a Session Host follows
|
|
2459
|
+
* a TS Core Group (ADR 0045). The Group calls `connect` once, when the port
|
|
2460
|
+
* attaches, with the controls only the Session drives.
|
|
2461
|
+
*/
|
|
2462
|
+
type SessionPort = {
|
|
2463
|
+
connect(controls: SessionControls): void;
|
|
2464
|
+
runs(r: RunEvent): void;
|
|
2465
|
+
values(tree: unknown): void;
|
|
2466
|
+
};
|
|
2467
|
+
type SessionControls = {
|
|
2468
|
+
/** Whether Host Inputs wait for the next Pump (chapter 12, The foreground). */
|
|
2469
|
+
queuedInputs(): boolean;
|
|
2470
|
+
/** Settles a Call the Session's message layer answered. */
|
|
2471
|
+
reply(id: string, reply: Resumption): void;
|
|
2472
|
+
};
|
|
2473
|
+
/** The TS Core's own options, beyond the embedding interface's. */
|
|
2474
|
+
type TsGroupOptions = GroupOptions & {
|
|
2475
|
+
session?: SessionPort;
|
|
2476
|
+
};
|
|
2477
|
+
type TsRestoreOptions = RestoreOptions & {
|
|
2478
|
+
session?: SessionPort;
|
|
2479
|
+
};
|
|
2480
|
+
type LoadOptions = {
|
|
2481
|
+
/** Its Grants, by the name the Script uses for each. */
|
|
2482
|
+
grants?: Readonly<Record<string, Grant<any>>>;
|
|
2483
|
+
/** Keep only Operations used by this source and its Libraries. */
|
|
2484
|
+
grantsAsUsed?: boolean;
|
|
2485
|
+
limits?: Partial<Limits>;
|
|
2486
|
+
name: string;
|
|
2487
|
+
/** Its well-known Host Objects, by the name the Script uses. */
|
|
2488
|
+
objects?: Readonly<Record<string, HostObject>>;
|
|
2489
|
+
/** The Host Object it owns: the start of its Message Path. */
|
|
2490
|
+
owner?: HostObject;
|
|
2491
|
+
source: string;
|
|
2492
|
+
};
|
|
2493
|
+
type LimitOverride = Partial<Pick<Limits, 'fuelPerRun' | 'allocPerRun' | 'maxWaitMs' | 'maxJoin'>>;
|
|
2494
|
+
type Message = {
|
|
2495
|
+
args?: Value[];
|
|
2496
|
+
limits?: LimitOverride;
|
|
2497
|
+
name: string;
|
|
2498
|
+
};
|
|
2499
|
+
type Verdict = 'allowed' | 'vetoed' | 'undecided';
|
|
2500
|
+
type Decided = {
|
|
2501
|
+
broadcast?: string;
|
|
2502
|
+
delivery?: string;
|
|
2503
|
+
undecided: {
|
|
2504
|
+
outcome: RunOutcome;
|
|
2505
|
+
run?: string;
|
|
2506
|
+
script: string;
|
|
2507
|
+
}[];
|
|
2508
|
+
verdict: Verdict;
|
|
2509
|
+
vetoes: {
|
|
2510
|
+
reason: Value;
|
|
2511
|
+
run: string;
|
|
2512
|
+
script: string;
|
|
2513
|
+
}[];
|
|
2514
|
+
};
|
|
2515
|
+
type Deciding = {
|
|
2516
|
+
decided: Promise<Decided>;
|
|
2517
|
+
id: string;
|
|
2518
|
+
};
|
|
2519
|
+
type Requested = {
|
|
2520
|
+
id: string;
|
|
2521
|
+
result: Promise<Value>;
|
|
2522
|
+
};
|
|
2523
|
+
/** Admission failure has no handle. A refused Pump retains the admitted Request. */
|
|
2524
|
+
type PumpedRequest = {
|
|
2525
|
+
admitted: false;
|
|
2526
|
+
error: unknown;
|
|
2527
|
+
} | {
|
|
2528
|
+
admitted: true;
|
|
2529
|
+
pump: {
|
|
2530
|
+
ok: true;
|
|
2531
|
+
result: PumpResult;
|
|
2532
|
+
} | {
|
|
2533
|
+
error: unknown;
|
|
2534
|
+
ok: false;
|
|
2535
|
+
};
|
|
2536
|
+
requested: Requested;
|
|
2537
|
+
};
|
|
2538
|
+
/** Native TS only; the Zig-backed adapter retains its own save format. */
|
|
2539
|
+
type SaveOptions = {
|
|
2540
|
+
sources?: 'embedded' | 'external';
|
|
2541
|
+
};
|
|
2542
|
+
type ScriptCodeRequest = {
|
|
2543
|
+
/** Base source first, then extensions in their saved order. */
|
|
2544
|
+
identities: readonly string[];
|
|
2545
|
+
name: string;
|
|
2546
|
+
};
|
|
2547
|
+
type ScriptSources = {
|
|
2548
|
+
extensions?: readonly string[];
|
|
2549
|
+
source: string;
|
|
2550
|
+
};
|
|
2551
|
+
type RestoreOptions = GroupOptions & {
|
|
2552
|
+
grants(script: string, name: string): Grant<unknown> | undefined;
|
|
2553
|
+
libraries: readonly Library[];
|
|
2554
|
+
onMismatch: 'reject' | 'variables only';
|
|
2555
|
+
resolve(kind: string, id: string): {
|
|
2556
|
+
native: unknown;
|
|
2557
|
+
} | undefined;
|
|
2558
|
+
/** Native TS external-source snapshots only. Different code requires variables-only policy. */
|
|
2559
|
+
scriptSources?(request: ScriptCodeRequest): ScriptSources | undefined;
|
|
2560
|
+
};
|
|
2561
|
+
type PendingCall = {
|
|
2562
|
+
args: Value[];
|
|
2563
|
+
grant: string;
|
|
2564
|
+
id: string;
|
|
2565
|
+
operation: {
|
|
2566
|
+
capability: string;
|
|
2567
|
+
operation: string;
|
|
2568
|
+
};
|
|
2569
|
+
script: string;
|
|
2570
|
+
};
|
|
2571
|
+
type RestoreResult = {
|
|
2572
|
+
abandonedCalls: string[];
|
|
2573
|
+
discardedRuns: string[];
|
|
2574
|
+
disposed: [string, string][];
|
|
2575
|
+
droppedMessages: string[];
|
|
2576
|
+
pending: PendingCall[];
|
|
2577
|
+
reports: Report[];
|
|
2578
|
+
variablesOnly: boolean;
|
|
2579
|
+
};
|
|
2580
|
+
type Settlement = {
|
|
2581
|
+
answer: Value;
|
|
2582
|
+
} | {
|
|
2583
|
+
fail: ScriptError;
|
|
2584
|
+
} | {
|
|
2585
|
+
reissue: true;
|
|
2586
|
+
} | {
|
|
2587
|
+
adopt: true;
|
|
2588
|
+
};
|
|
2589
|
+
type CarryOver = 'reset variables' | 'carry variables';
|
|
2590
|
+
type CancellationOptions = {
|
|
2591
|
+
signal?: AbortSignal;
|
|
2592
|
+
};
|
|
2593
|
+
type PumpOptions = {
|
|
2594
|
+
fuelCap?: number;
|
|
2595
|
+
fuelSlice?: number;
|
|
2596
|
+
};
|
|
2597
|
+
type RunOutcome = 'completed' | 'errored' | 'limit fault' | 'cancelled' | 'unhandled' | 'dropped' | 'effect failed';
|
|
2598
|
+
/** The Trace's name for a limit a Limit Fault or failed cleanup passed. */
|
|
2599
|
+
type LimitWord = 'fuel' | 'alloc' | 'persistent' | 'depth' | 'pattern' | 'join' | 'cleanup';
|
|
2600
|
+
/** Where a Run ended: a code position and its source position. */
|
|
2601
|
+
type Location = {
|
|
2602
|
+
col: number;
|
|
2603
|
+
handler: string;
|
|
2604
|
+
line: number;
|
|
2605
|
+
pc: number;
|
|
2606
|
+
unit: string;
|
|
2607
|
+
};
|
|
2608
|
+
type EffectFailure = {
|
|
2609
|
+
detail?: string;
|
|
2610
|
+
grant: string;
|
|
2611
|
+
phase: 'abandon' | 'begin' | 'commit' | 'rollback';
|
|
2612
|
+
run: string;
|
|
2613
|
+
scope?: string;
|
|
2614
|
+
script: string;
|
|
2615
|
+
segment: string;
|
|
2616
|
+
status: 'failed' | 'unknown';
|
|
2617
|
+
};
|
|
2618
|
+
type Report = AccountingReport | {
|
|
2619
|
+
code: HostErrorCode;
|
|
2620
|
+
detail?: string;
|
|
2621
|
+
kind: 'host error';
|
|
2622
|
+
} | ({
|
|
2623
|
+
kind: 'effect failure';
|
|
2624
|
+
} & EffectFailure) | {
|
|
2625
|
+
alloc: number;
|
|
2626
|
+
/** `errored`: the raise no Unwind Table entry caught; `limit fault`: the faulting instruction. */
|
|
2627
|
+
at?: Location;
|
|
2628
|
+
broadcast?: string;
|
|
2629
|
+
cleanupFailed?: {
|
|
2630
|
+
code: string;
|
|
2631
|
+
} | {
|
|
2632
|
+
limit: Exclude<LimitWord, 'fuel'>;
|
|
2633
|
+
};
|
|
2634
|
+
delivery?: string;
|
|
2635
|
+
effect?: EffectFailure;
|
|
2636
|
+
error?: ScriptError;
|
|
2637
|
+
/** Set when a Fallback Handler clause ran it; `handler` is then the Selector. */
|
|
2638
|
+
fallback?: boolean;
|
|
2639
|
+
fuel: number;
|
|
2640
|
+
handler?: string;
|
|
2641
|
+
kind: 'run end';
|
|
2642
|
+
limit?: LimitWord;
|
|
2643
|
+
outcome: RunOutcome;
|
|
2644
|
+
result?: Value;
|
|
2645
|
+
run?: string;
|
|
2646
|
+
script: string;
|
|
2647
|
+
} | {
|
|
2648
|
+
delivery: string;
|
|
2649
|
+
kind: 'unhandled';
|
|
2650
|
+
message: Message;
|
|
2651
|
+
/** The object it was delivered to; absent when addressed to a Script. */
|
|
2652
|
+
target?: HostObject;
|
|
2653
|
+
} | {
|
|
2654
|
+
call: string;
|
|
2655
|
+
/** What the Host did wrong; the Script saw only `host error`. */
|
|
2656
|
+
detail: string;
|
|
2657
|
+
kind: 'call failed';
|
|
2658
|
+
operation: OperationRef;
|
|
2659
|
+
script: string;
|
|
2660
|
+
} | {
|
|
2661
|
+
discardedRuns: string[];
|
|
2662
|
+
droppedMessages: string[];
|
|
2663
|
+
kind: 'stop';
|
|
2664
|
+
pendingCalls: string[];
|
|
2665
|
+
reason: string;
|
|
2666
|
+
script: string;
|
|
2667
|
+
} | ({
|
|
2668
|
+
kind: 'decided';
|
|
2669
|
+
} & Decided);
|
|
2670
|
+
type PumpResult = {
|
|
2671
|
+
fuelUsed: number;
|
|
2672
|
+
/** The earliest deadline the next Pump could fire, if there is one. */
|
|
2673
|
+
nextDeadline?: bigint;
|
|
2674
|
+
reports: Report[];
|
|
2675
|
+
state: 'idle' | 'sliced' | 'stopped' | 'rewound';
|
|
2676
|
+
};
|
|
2677
|
+
/** A snapshot of lifetime work and current retained state. */
|
|
2678
|
+
type Counters = {
|
|
2679
|
+
allocTotal: number;
|
|
2680
|
+
faults: number;
|
|
2681
|
+
fuelTotal: number;
|
|
2682
|
+
mailboxLen: number;
|
|
2683
|
+
persistentState: number;
|
|
2684
|
+
runs: number;
|
|
2685
|
+
};
|
|
2686
|
+
type RunView = {
|
|
2687
|
+
/** Suspended: the calls, replies or Join Members it still waits for. */
|
|
2688
|
+
calls?: string[];
|
|
2689
|
+
handler: string;
|
|
2690
|
+
id: string;
|
|
2691
|
+
status: 'preempted' | 'ready' | 'suspended' | 'parked';
|
|
2692
|
+
/** Suspended: its deadline, as its `seg` record's `until` gives it. */
|
|
2693
|
+
until?: bigint;
|
|
2694
|
+
/** Suspended: the `seg` end reason it suspended at. */
|
|
2695
|
+
wait?: string;
|
|
2696
|
+
};
|
|
2697
|
+
type MessageView = {
|
|
2698
|
+
/** Absent for a message a Script sent. */
|
|
2699
|
+
delivery?: string;
|
|
2700
|
+
/** For a message a Script sent, the call or Run that sent it. */
|
|
2701
|
+
from?: string;
|
|
2702
|
+
message: Message;
|
|
2703
|
+
};
|
|
2704
|
+
type Inspection = {
|
|
2705
|
+
scripts: {
|
|
2706
|
+
disabledGrants?: string[];
|
|
2707
|
+
mailbox: MessageView[];
|
|
2708
|
+
name: string;
|
|
2709
|
+
runs: RunView[];
|
|
2710
|
+
vars: [string, Value][];
|
|
2711
|
+
}[];
|
|
2712
|
+
};
|
|
2713
|
+
/**
|
|
2714
|
+
* What a Script handle reaches its Group through: the Group's Script-only
|
|
2715
|
+
* operations, which aren't on the Group itself.
|
|
2716
|
+
*/
|
|
2717
|
+
type ScriptChannel = {
|
|
2718
|
+
combine: TsGroup['combine'];
|
|
2719
|
+
counters: TsGroup['scriptCounters'];
|
|
2720
|
+
extend: TsGroup['extend'];
|
|
2721
|
+
grants: TsGroup['scriptGrants'];
|
|
2722
|
+
queueCancelRun: TsGroup['queueCancelRun'];
|
|
2723
|
+
queueDecision: TsGroup['queueDecision'];
|
|
2724
|
+
queueDelivery: TsGroup['queueDelivery'];
|
|
2725
|
+
queueRevoke: TsGroup['queueRevoke'];
|
|
2726
|
+
queueRewindRun: TsGroup['queueRewindRun'];
|
|
2727
|
+
queueStop: TsGroup['queueStop'];
|
|
2728
|
+
reload: TsGroup['reload'];
|
|
2729
|
+
watchCancellation: TsGroup['watchCancellation'];
|
|
2730
|
+
};
|
|
2731
|
+
/** A handle for calls addressed to one Script. */
|
|
2732
|
+
declare class TsScript implements Script {
|
|
2733
|
+
private readonly group;
|
|
2734
|
+
readonly name: string;
|
|
2735
|
+
constructor(group: ScriptChannel, name: string);
|
|
2736
|
+
/** Worker. A snapshot of kept Operations, including revoked Grants. */
|
|
2737
|
+
grants(): Record<string, string[]>;
|
|
2738
|
+
/** Worker. Lifetime totals and current state, without draining inputs. */
|
|
2739
|
+
counters(): Counters;
|
|
2740
|
+
/** Queued. Returns the delivery id. */
|
|
2741
|
+
deliver(m: Message): string;
|
|
2742
|
+
/** Queued. Asks for a Verdict sealed in a Pump. */
|
|
2743
|
+
decide(m: Message, o?: CancellationOptions): Deciding;
|
|
2744
|
+
/** Queued. Settles when a Pump ends the Run, or rejects with `send failed`. */
|
|
2745
|
+
request(m: Message, o?: CancellationOptions): Requested;
|
|
2746
|
+
/** Queued. A Request for the answer only; use `request` for its id or a signal. */
|
|
2747
|
+
invoke(name: string, ...args: Value[]): Promise<Value>;
|
|
2748
|
+
/** Worker. Request this Script and perform exactly one Pump. */
|
|
2749
|
+
requestPump(m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
2750
|
+
reload(source: string, carry: CarryOver, o?: {
|
|
2751
|
+
keepMailbox?: boolean;
|
|
2752
|
+
}): Report[];
|
|
2753
|
+
extend(source: string): void;
|
|
2754
|
+
stop(reason: string): void;
|
|
2755
|
+
cancelRun(runId: string): void;
|
|
2756
|
+
/** Queued, landing as cancelRun does (ADR 0068). */
|
|
2757
|
+
rewindRun(runId: string): void;
|
|
2758
|
+
/** Queued. In-flight calls are left to the Host. */
|
|
2759
|
+
revoke(grantName: string): void;
|
|
2760
|
+
}
|
|
2761
|
+
declare class TsGroup implements Group {
|
|
2762
|
+
private session;
|
|
2763
|
+
private readonly channel;
|
|
2764
|
+
readonly name: string;
|
|
2765
|
+
private readonly trace;
|
|
2766
|
+
private readonly onReady;
|
|
2767
|
+
private readonly scripts;
|
|
2768
|
+
private readonly libraries;
|
|
2769
|
+
private readonly waits;
|
|
2770
|
+
private readonly functionGroup;
|
|
2771
|
+
private readonly objects;
|
|
2772
|
+
private drainReports;
|
|
2773
|
+
private accounting;
|
|
2774
|
+
private discardReason;
|
|
2775
|
+
private inputs;
|
|
2776
|
+
private deliveries;
|
|
2777
|
+
private broadcasts;
|
|
2778
|
+
private saves;
|
|
2779
|
+
private lastClock;
|
|
2780
|
+
private randomState;
|
|
2781
|
+
private pumping;
|
|
2782
|
+
private combining;
|
|
2783
|
+
private combinedAdmission;
|
|
2784
|
+
private cleaning;
|
|
2785
|
+
private effectStateUnknown;
|
|
2786
|
+
private terminalReports;
|
|
2787
|
+
private active;
|
|
2788
|
+
private activeStop;
|
|
2789
|
+
/** A Rewind landed in this Pump, which returns at once (ADR 0068). */
|
|
2790
|
+
private rewound;
|
|
2791
|
+
private drainingTrace;
|
|
2792
|
+
private debugController;
|
|
2793
|
+
private debugPump;
|
|
2794
|
+
/**
|
|
2795
|
+
* The next `random(n)` draw from the Group's generator; `commit` advances
|
|
2796
|
+
* the generator past it (chapter 7, Random numbers).
|
|
2797
|
+
*/
|
|
2798
|
+
private drawRandom;
|
|
2799
|
+
private ancestry;
|
|
2800
|
+
private accountStart;
|
|
2801
|
+
private accountEnd;
|
|
2802
|
+
private accountDrop;
|
|
2803
|
+
private flushAccounting;
|
|
2804
|
+
/** TS tooling only, outside the embedding interface and Trace parity. */
|
|
2805
|
+
debug(): DebugController;
|
|
2806
|
+
private advanceDebugPump;
|
|
2807
|
+
private attachSession;
|
|
2808
|
+
/** Worker. A Fingerprint covers code, declarations and limits, never state. */
|
|
2809
|
+
fingerprint(): Uint8Array;
|
|
2810
|
+
/** Worker. Host callbacks, bindings and native objects aren't in the bytes. */
|
|
2811
|
+
private references;
|
|
2812
|
+
save(o?: SaveOptions): Uint8Array;
|
|
2813
|
+
/** Build and check the complete replacement before publishing the Group. */
|
|
2814
|
+
static restore(bytes: Uint8Array, o: TsRestoreOptions): {
|
|
2815
|
+
group: TsGroup;
|
|
2816
|
+
result: RestoreResult;
|
|
2817
|
+
};
|
|
2818
|
+
private discardedDecisions;
|
|
2819
|
+
private unsettled;
|
|
2820
|
+
private restored;
|
|
2821
|
+
private discardDecision;
|
|
2822
|
+
private drainCharges;
|
|
2823
|
+
/** Queued, and accepted only before the restored Group's first Pump. */
|
|
2824
|
+
settle(id: string, settlement: Settlement): Call<unknown> | undefined;
|
|
2825
|
+
private applySettlement;
|
|
2826
|
+
private pendingCall;
|
|
2827
|
+
private holders;
|
|
2828
|
+
private pendingOperations;
|
|
2829
|
+
/** A Request's signal lives until its Run ends; a Decision's until its seal. */
|
|
2830
|
+
private watchCancellation;
|
|
2831
|
+
/** Queue the Host Input produced by aborting a Request, Decision or Host call. */
|
|
2832
|
+
cancelDelivery(id: string): void;
|
|
2833
|
+
private cancelDeliveryNow;
|
|
2834
|
+
private queueCancelRun;
|
|
2835
|
+
private queueRewindRun;
|
|
2836
|
+
private queueStop;
|
|
2837
|
+
private queueRevoke;
|
|
2838
|
+
private applyInput;
|
|
2839
|
+
private runsOf;
|
|
2840
|
+
private forgetWait;
|
|
2841
|
+
private cancelRunning;
|
|
2842
|
+
/**
|
|
2843
|
+
* Roll back a Run's first Segment, end it and put its message back at the
|
|
2844
|
+
* head of the mailbox. The running Pump returns at once (ADR 0068).
|
|
2845
|
+
*/
|
|
2846
|
+
private rewindRunning;
|
|
2847
|
+
private stoppedDelivery;
|
|
2848
|
+
private stopState;
|
|
2849
|
+
private stopUnknownEffects;
|
|
2850
|
+
private requireKnownEffects;
|
|
2851
|
+
private releaseGrant;
|
|
2852
|
+
private releaseGrants;
|
|
2853
|
+
private reportStop;
|
|
2854
|
+
private dropStoppedMailbox;
|
|
2855
|
+
private acceptDelivery;
|
|
2856
|
+
private recordRefusal;
|
|
2857
|
+
private landUrgentInputs;
|
|
2858
|
+
constructor(options: TsGroupOptions);
|
|
2859
|
+
script(name: string): TsScript | undefined;
|
|
2860
|
+
/** Any time, inside a Pump too. Its Scripts' names, in load order; not a Host Input. */
|
|
2861
|
+
scriptNames(): string[];
|
|
2862
|
+
private queueInput;
|
|
2863
|
+
private worker;
|
|
2864
|
+
private finalizeEffects;
|
|
2865
|
+
private accumulateRunCosts;
|
|
2866
|
+
private scriptCounters;
|
|
2867
|
+
private scriptGrants;
|
|
2868
|
+
/** Worker. Compiles, checks and loads a Script, or throws LoadError. */
|
|
2869
|
+
load(o: LoadOptions): TsScript;
|
|
2870
|
+
private loadPrepared;
|
|
2871
|
+
private writeDiagnostics;
|
|
2872
|
+
private replacement;
|
|
2873
|
+
/** Worker. Check and initialise before discarding any old work. */
|
|
2874
|
+
reload(name: string, source: string, carry: CarryOver, keepMailbox?: boolean): Report[];
|
|
2875
|
+
private extension;
|
|
2876
|
+
private applyExtension;
|
|
2877
|
+
/** Worker. Existing code units and Runs remain untouched. */
|
|
2878
|
+
extend(name: string, source: string): void;
|
|
2879
|
+
private replaceScripts;
|
|
2880
|
+
/**
|
|
2881
|
+
* Worker, Host Input. Adds a compiled Library, whose imports the Group must
|
|
2882
|
+
* already hold, under a name it doesn't hold yet.
|
|
2883
|
+
*/
|
|
2884
|
+
addLibrary(l: Library): void;
|
|
2885
|
+
/** Worker. Prepare every dependent before changing the Group. */
|
|
2886
|
+
replaceLibrary(l: Library, carry: CarryOver): Report[];
|
|
2887
|
+
private hostFor;
|
|
2888
|
+
private enqueue;
|
|
2889
|
+
private fireTimer;
|
|
2890
|
+
private ready;
|
|
2891
|
+
private settleReply;
|
|
2892
|
+
private observe;
|
|
2893
|
+
private suspended;
|
|
2894
|
+
private checkFunctionGroups;
|
|
2895
|
+
/** A queued Delivery: its id now, its line and its mailbox entry at the next Pump. */
|
|
2896
|
+
private queueDelivery;
|
|
2897
|
+
/** Queued. Asks the object's Message Path for a Verdict. */
|
|
2898
|
+
decide(to: HostObject, m: Message, o?: CancellationOptions): Deciding;
|
|
2899
|
+
private queueDecision;
|
|
2900
|
+
/** Queued. Takes recipients at drain, then waits for every Verdict. */
|
|
2901
|
+
decideBroadcast(m: Message, o?: CancellationOptions): Deciding;
|
|
2902
|
+
/** Queued. Delivers to recipients taken in load order at drain. */
|
|
2903
|
+
broadcast(m: Message): string;
|
|
2904
|
+
private queueBroadcast;
|
|
2905
|
+
private broadcastLine;
|
|
2906
|
+
private seal;
|
|
2907
|
+
private reportDecision;
|
|
2908
|
+
/** Queued. Routes to the object's nearest Owning Script; returns the delivery id. */
|
|
2909
|
+
deliver(to: HostObject, m: Message): string;
|
|
2910
|
+
/** Queued. As `deliver`, and settles when a Pump ends the Run. */
|
|
2911
|
+
request(to: HostObject, m: Message, o?: CancellationOptions): Requested;
|
|
2912
|
+
/** Worker. Admit once, then Pump once; a Pump refusal retains the Request. */
|
|
2913
|
+
requestPump(to: HostObject, m: Message, now: bigint, o?: PumpOptions & CancellationOptions): PumpedRequest;
|
|
2914
|
+
/** Worker. A Function Call and one Pump, with ordinary Call options. */
|
|
2915
|
+
callPump(fn: Value, args: Value[], now: bigint, o?: PumpOptions & CancellationOptions & {
|
|
2916
|
+
limits?: LimitOverride;
|
|
2917
|
+
}): PumpedRequest;
|
|
2918
|
+
private combine;
|
|
2919
|
+
/** Queued. Calls a Function Value as a Request to its Home Script. */
|
|
2920
|
+
call(fn: Value, args: Value[], o?: CancellationOptions & {
|
|
2921
|
+
limits?: LimitOverride;
|
|
2922
|
+
}): Requested;
|
|
2923
|
+
/** Makes a handle for a Host-owned thing, the first time it crosses in. */
|
|
2924
|
+
object<N>(kind: ObjectKind<N>, id: string, native: N): HostObject<N>;
|
|
2925
|
+
/** The handle with this Object Kind name and id, disposed or not, such as one Restore made. */
|
|
2926
|
+
objectById(kind: string, id: string): HostObject | undefined;
|
|
2927
|
+
/** Whether an object value is one of this Group's handles. */
|
|
2928
|
+
private holdsObject;
|
|
2929
|
+
private held;
|
|
2930
|
+
private parentError;
|
|
2931
|
+
/** Queued. Refuses cycles and disposed children at admission and again at drain. */
|
|
2932
|
+
setParent(o: HostObject, parent: HostObject | undefined): void;
|
|
2933
|
+
/** Queued. Disposes an object: it stays a value, and sends to it raise `object gone`. */
|
|
2934
|
+
dispose(o: HostObject): void;
|
|
2935
|
+
private route;
|
|
2936
|
+
private unhandled;
|
|
2937
|
+
private answer;
|
|
2938
|
+
private deliveryLine;
|
|
2939
|
+
/** Worker. One Clock reading, the queue drained, then turns until done (chapter 5). */
|
|
2940
|
+
pump(now: bigint, o?: PumpOptions): PumpResult;
|
|
2941
|
+
private pumpWorker;
|
|
2942
|
+
private pumpAtClock;
|
|
2943
|
+
private moveDelivery;
|
|
2944
|
+
private turn;
|
|
2945
|
+
private writeCancellationAbandons;
|
|
2946
|
+
private callFailed;
|
|
2947
|
+
private releaseRecords;
|
|
2948
|
+
private writeRecords;
|
|
2949
|
+
private endRun;
|
|
2950
|
+
private releaseParked;
|
|
2951
|
+
/** A Script's Persistent State: its Script Variables and the messages it holds. */
|
|
2952
|
+
private persistentState;
|
|
2953
|
+
/** Worker, and the Host Input `vars`: the Group, read without changing it. */
|
|
2954
|
+
private waitView;
|
|
2955
|
+
/** A Run's calls and sends that a Rewind leaves done (ADR 0068). */
|
|
2956
|
+
private repeatedEffects;
|
|
2957
|
+
private debugSnapshot;
|
|
2958
|
+
inspect(): Inspection;
|
|
2959
|
+
private inspection;
|
|
2960
|
+
}
|
|
2961
|
+
declare const newGroup: (o: TsGroupOptions) => TsGroup;
|
|
2962
|
+
declare const restore: (bytes: Uint8Array, options: TsRestoreOptions) => {
|
|
2963
|
+
group: TsGroup;
|
|
2964
|
+
result: RestoreResult;
|
|
2965
|
+
};
|
|
2966
|
+
//#endregion
|
|
2967
|
+
//#region src/debug.d.ts
|
|
2968
|
+
type DebugInstruction = {
|
|
2969
|
+
pc: number;
|
|
2970
|
+
run?: string;
|
|
2971
|
+
script?: string;
|
|
2972
|
+
unit?: string;
|
|
2973
|
+
};
|
|
2974
|
+
type DebugPause = Location & {
|
|
2975
|
+
error?: Value;
|
|
2976
|
+
hostInputIndex?: number;
|
|
2977
|
+
limit?: LimitName;
|
|
2978
|
+
reason: 'breakpoint' | 'step' | 'error' | 'limitFault' | 'replay';
|
|
2979
|
+
run: string;
|
|
2980
|
+
script: string;
|
|
2981
|
+
};
|
|
2982
|
+
type DebugFrame = Location & {
|
|
2983
|
+
locals: [string, Value][];
|
|
2984
|
+
/** Zero-based index of the shared-local owner in this Run's frame view. */
|
|
2985
|
+
owner?: number;
|
|
2986
|
+
role?: 'retained' | 'dispatch';
|
|
2987
|
+
};
|
|
2988
|
+
/** An effect a Rewind leaves done, so it happens again (ADR 0068). */
|
|
2989
|
+
type RepeatedEffect = {
|
|
2990
|
+
id: string;
|
|
2991
|
+
kind: 'call';
|
|
2992
|
+
op: string;
|
|
2993
|
+
} | {
|
|
2994
|
+
kind: 'send';
|
|
2995
|
+
message?: string;
|
|
2996
|
+
to: string;
|
|
2997
|
+
};
|
|
2998
|
+
type DebugSnapshot = Omit<Inspection, 'scripts'> & {
|
|
2999
|
+
scripts: (Omit<Inspection['scripts'][number], 'runs'> & {
|
|
3000
|
+
runs: (Inspection['scripts'][number]['runs'][number] & {
|
|
3001
|
+
frames: DebugFrame[];
|
|
3002
|
+
fuel: number;
|
|
3003
|
+
/** Effects so far that a Rewind would repeat; empty unless rewindable. */
|
|
3004
|
+
repeated: RepeatedEffect[];
|
|
3005
|
+
/** It hasn't passed a Suspension Point, so it can be rewound. */
|
|
3006
|
+
rewindable: boolean;
|
|
3007
|
+
segment: number;
|
|
3008
|
+
})[];
|
|
3009
|
+
})[];
|
|
3010
|
+
};
|
|
3011
|
+
type DebugSource = {
|
|
3012
|
+
script?: string;
|
|
3013
|
+
statements: number[];
|
|
3014
|
+
unit: CodeUnit;
|
|
3015
|
+
};
|
|
3016
|
+
/** Tooling only; chapter 9's embedding declarations do not expose this API. */
|
|
3017
|
+
declare class DebugController {
|
|
3018
|
+
private readonly read;
|
|
3019
|
+
private readonly advance;
|
|
3020
|
+
private readonly readSources;
|
|
3021
|
+
paused: ((pause: DebugPause) => void) | null;
|
|
3022
|
+
private breaks;
|
|
3023
|
+
private faults;
|
|
3024
|
+
private stepping;
|
|
3025
|
+
private parents;
|
|
3026
|
+
private landing;
|
|
3027
|
+
/** Pause at the next Run of this Script to start, once (Fix and Continue). */
|
|
3028
|
+
private restart;
|
|
3029
|
+
private readonly seen;
|
|
3030
|
+
private pause;
|
|
3031
|
+
private pauseDepth;
|
|
3032
|
+
private notifying;
|
|
3033
|
+
private since;
|
|
3034
|
+
private elapsed;
|
|
3035
|
+
constructor(read: () => DebugSnapshot, advance: () => PumpResult, readSources: () => DebugSource[]);
|
|
3036
|
+
/** Detached lowerings of the code actually loaded, including extensions. */
|
|
3037
|
+
sources(): DebugSource[];
|
|
3038
|
+
get isPaused(): boolean;
|
|
3039
|
+
get current(): DebugPause | null;
|
|
3040
|
+
breakAt(instructions: readonly DebugInstruction[]): void;
|
|
3041
|
+
clearBreaks(): void;
|
|
3042
|
+
pauseOn(options: {
|
|
3043
|
+
error?: boolean;
|
|
3044
|
+
limitFault?: boolean;
|
|
3045
|
+
}): void;
|
|
3046
|
+
snapshot(): DebugSnapshot;
|
|
3047
|
+
pausedTime(): number;
|
|
3048
|
+
resume(): PumpResult;
|
|
3049
|
+
step(): PumpResult;
|
|
3050
|
+
stepOver(): PumpResult;
|
|
3051
|
+
stepOut(): PumpResult;
|
|
3052
|
+
/** Pause, as a step, at the first instruction of the Script's next new Run. */
|
|
3053
|
+
pauseAtNextStart(script: string): void;
|
|
3054
|
+
landAt(hostInputIndex: number, pc: DebugInstruction | number): void;
|
|
3055
|
+
private stepped;
|
|
3056
|
+
private assertCanContinue;
|
|
3057
|
+
private continue;
|
|
3058
|
+
/** Internal scheduler integration. */
|
|
3059
|
+
attach(run: Run, from: string | null): void;
|
|
3060
|
+
ended(run: Run): void;
|
|
3061
|
+
boundary(run: Run, script: string): DebugPause | null;
|
|
3062
|
+
enter(pause: DebugPause): void;
|
|
3063
|
+
}
|
|
3064
|
+
//#endregion
|
|
3065
|
+
export { isReadable as $, EventEntry as $n, httpCapability as $t, SessionControls as A, Outcome as An, ImmediateOp as At, CausalWork as B, canConvert as Bn, SegmentCoordinator as Bt, Requested as C, LibrarySource as Cn, SyntaxNode as Cr, Cost as Ct, SaveOptions as D, replacementLibraries as Dn, syntaxText as Dr, FireOp as Dt, RunEvent as E, compileLibrary as En, syntaxSelector as Er, FieldShape as Et, TsRestoreOptions as F, callFunction as Fn, PlainResult as Ft, Decimal as G, LoadError as Gn, defineCapability as Gt, RunAncestry as H, HostError as Hn, SegmentLifecycle as Ht, TsScript as I, defaultLimits as In, ReleaseHook as It, bool as J, SendFailedReason as Jn, Group as Jt, Kind as K, MailboxFull as Kn, shape as Kt, Verdict as L, deliver as Ln, ReleaseReason as Lt, Settlement as M, RunRecord as Mn, Operation as Mt, TsGroup as N, Script$1 as Nn, Operations as Nt, ScriptCodeRequest as O, LimitName as On, Grant as Ot, TsGroupOptions as P, UnitLoadError as Pn, PlainArg as Pt, instant as Q, EventBranch as Qn, HttpImpl as Qt, newGroup as R, loadScript as Rn, ScopeDecl as Rt, Report as S, LibraryOptions as Sn, SyntaxErrorCode as Sr, CoordinatedLifecycle as St, RestoreResult as T, codeIdentity as Tn, Trivia as Tr, ErrorDecl as Tt, RunDiscarded as U, HostErrorCode as Un, Shape as Ut, RunAccounting as V, waitUs as Vn, SegmentGrant as Vt, RunStarted as W, LoadDiagnostic as Wn, SuspendingOp as Wt, civilDate as X, BodyKind as Xn, Versions as Xt, bytes as Y, Body as Yn, Script as Yt, dec as Z, CodeUnit as Zn, coreVersions as Zt, Message as _, calendarCapability as _n, Lexer as _r, defineObjectKind as _t, DebugSnapshot as a, SqlParams as an, BindingKind as ar, range as at, PumpResult as b, timerCapability as bn, Token as br, CapabilityDef as bt, CancellationOptions as c, SqliteBinding as cn, LibraryExport as cr, text as ct, Decided as d, LocaleImpl as dn, SemanticName as dr, parseInstant as dt, UserImpl as en, Instruction as er, list as et, Deciding as f, localeCapability as fn, SemanticNode as fr, HostObject as ft, LoadOptions as g, TimerImpl as gn, SourceSpan as gr, PropDef as gt, Inspection as h, Costs as hn, SemanticTree as hr, ObjectKindDef as ht, DebugPause as i, storeCapability as in, Binding as ir, quantity as it, SessionPort as j, Run as jn, LimitReached as jt, ScriptSources as k, Limits as kn, GrantContext as kt, CarryOver as l, SqliteImpl as ln, NameRole as lr, formatInstant as lt, GroupOptions as m, ConsoleImpl as mn, SemanticToken as mr, ObjectKind as mt, DebugFrame as n, StoreImpl as nn, UnwindEntry as nr, nothing as nt, DebugSource as o, SqlRows as on, ExportKind as or, record as ot, EffectFailure as p, CalendarImpl as pn, SemanticScope as pr, ObjectElements as pt, Value as q, ScriptError as qn, Core as qt, DebugInstruction as r, add as rn, disassemble as rr, num as rt, RepeatedEffect as s, SqlValue as sn, FunctionContract as sr, sourceForm as st, DebugController as t, userCapability as tn, Operand as tr, map as tt, Counters as u, sqliteCapability as un, SemanticElement as ur, nowMicros as ut, PendingCall as v, clockCapability as vn, Mode as vr, GrantDecls as vt, RestoreOptions as w, OperationRef as wn, SyntaxRule as wr, EffectResult as wt, PumpedRequest as x, Library as xn, SyntaxElement as xr, CapabilityDefiner as xt, PumpOptions as y, consoleCapability as yn, TokType as yr, Call as yt, restore as z, NotImplementedError as zn, SegmentContext as zt };
|