@northtalk/ts 0.0.0-stage → 0.1.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 +55 -2
- package/UNICODE-LICENSE.txt +39 -0
- package/core-eU5KaYkz.d.ts +23 -0
- package/debug-D8Z_u244.d.ts +2698 -0
- package/debug.d.ts +2 -0
- package/debug.js +1 -0
- package/driver.d.ts +27 -0
- package/driver.js +74 -0
- package/encoding-DWlbPq-e.js +7792 -0
- package/engine-BPFnHT9N.d.ts +86 -0
- package/engine-CgCMdGGd.js +324 -0
- package/errors-DHwz1Vho.js +3661 -0
- package/group-B4eyJKTA.js +15958 -0
- package/index.d.ts +645 -0
- package/index.js +37 -0
- package/manifest-DKe2Je6Z.js +208 -0
- package/notify.d.ts +2 -0
- package/notify.js +1 -0
- package/objects-MeXIDDFo.d.ts +625 -0
- package/package.json +62 -4
- package/readers-DyjxJEkL.js +479 -0
- package/readers-Oh4tO2dK.d.ts +57 -0
- package/router-DHPJNvbt.js +341 -0
- package/router-DpDpAJjz.d.ts +54 -0
- package/session.d.ts +8 -0
- package/session.js +3476 -0
- package/setup.d.ts +2 -0
- package/setup.js +189 -0
- package/sha256-0jiTgVJu.js +123 -0
- package/sqlite-capability-C7-SYdD7.d.ts +87 -0
- package/sqlite-capability-CrCej3Po.js +478 -0
- package/sqlite.d.ts +75 -0
- package/sqlite.js +528 -0
- package/store-DrYjcoru.js +59 -0
- package/store-capability-CDoVafZL.js +387 -0
- package/store.d.ts +20 -0
- package/store.js +3 -0
- package/user-capability-CLkDsrCX.d.ts +40 -0
- package/user-capability-Cv0oJhhv.js +273 -0
- package/wasm.d.ts +223 -0
- package/wasm.js +1453 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import { Ct as HostObject, E as Script, Et as ObjectKindDef, Gt as ScopeDecl, I as compileLibrary, L as replacementLibraries, Rt as Grant, S as Report, T as RestoreResult, Tt as ObjectKind, Xt as Shape, at as Value, g as Inspection, h as GroupOptions, j as Library, jt as CapabilityDef, kt as GrantDecls, m as Group, rn as LoadError, t as DebugController, w as RestoreOptions, z as Limits } from "./debug-D8Z_u244.js";
|
|
2
|
+
import { i as SqliteBinding, l as CalendarImpl, s as LocaleImpl } from "./sqlite-capability-C7-SYdD7.js";
|
|
3
|
+
//#region src/setup.d.ts
|
|
4
|
+
type ShapeSpec = string | {
|
|
5
|
+
quantity: string;
|
|
6
|
+
} | {
|
|
7
|
+
unitKind: string;
|
|
8
|
+
} | {
|
|
9
|
+
list: ShapeSpec;
|
|
10
|
+
} | {
|
|
11
|
+
object: string;
|
|
12
|
+
} | {
|
|
13
|
+
oneOf: ShapeSpec[];
|
|
14
|
+
} | {
|
|
15
|
+
optional: ShapeSpec;
|
|
16
|
+
} | {
|
|
17
|
+
map: {
|
|
18
|
+
key: string;
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
shape: ShapeSpec;
|
|
21
|
+
}[];
|
|
22
|
+
open?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type OperationSpec = {
|
|
25
|
+
args?: ShapeSpec[];
|
|
26
|
+
capability: string;
|
|
27
|
+
/** Also callable as a Host Command (ADR 0094). */
|
|
28
|
+
command?: boolean;
|
|
29
|
+
cost?: {
|
|
30
|
+
alloc?: number;
|
|
31
|
+
fuel?: number;
|
|
32
|
+
};
|
|
33
|
+
errors?: {
|
|
34
|
+
code: string;
|
|
35
|
+
fields?: {
|
|
36
|
+
key: string;
|
|
37
|
+
optional?: boolean;
|
|
38
|
+
shape: ShapeSpec;
|
|
39
|
+
}[];
|
|
40
|
+
}[];
|
|
41
|
+
maxPending?: number;
|
|
42
|
+
mode: 'immediate' | 'suspending' | 'fire-and-forget';
|
|
43
|
+
name: string;
|
|
44
|
+
result?: ShapeSpec;
|
|
45
|
+
scope?: ScopeDecl;
|
|
46
|
+
segmentBound?: boolean;
|
|
47
|
+
};
|
|
48
|
+
type ObjectRefSpec = {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: string;
|
|
51
|
+
};
|
|
52
|
+
type Setup = {
|
|
53
|
+
/** Each Library's source file, or with `text`, the source itself. */
|
|
54
|
+
libraries?: {
|
|
55
|
+
name: string;
|
|
56
|
+
source: string;
|
|
57
|
+
text?: string;
|
|
58
|
+
version: string;
|
|
59
|
+
}[];
|
|
60
|
+
objectKinds?: {
|
|
61
|
+
/** Its Object Collection's declaration (#1143). */
|
|
62
|
+
elements?: {
|
|
63
|
+
atCost: {
|
|
64
|
+
alloc?: number;
|
|
65
|
+
fuel: number;
|
|
66
|
+
};
|
|
67
|
+
countCost: {
|
|
68
|
+
alloc?: number;
|
|
69
|
+
fuel: number;
|
|
70
|
+
};
|
|
71
|
+
findCost: {
|
|
72
|
+
alloc?: number;
|
|
73
|
+
fuel: number;
|
|
74
|
+
};
|
|
75
|
+
shape: ShapeSpec;
|
|
76
|
+
};
|
|
77
|
+
name: string;
|
|
78
|
+
parentKinds?: string[];
|
|
79
|
+
props?: {
|
|
80
|
+
getCost?: {
|
|
81
|
+
alloc?: number;
|
|
82
|
+
fuel: number;
|
|
83
|
+
};
|
|
84
|
+
name: string;
|
|
85
|
+
readOnly?: boolean;
|
|
86
|
+
setCost?: {
|
|
87
|
+
alloc?: number;
|
|
88
|
+
fuel: number;
|
|
89
|
+
};
|
|
90
|
+
shape?: ShapeSpec;
|
|
91
|
+
}[];
|
|
92
|
+
}[];
|
|
93
|
+
objects?: {
|
|
94
|
+
/** Its collection's members, in order, each object in the display form. */
|
|
95
|
+
elements?: {
|
|
96
|
+
name: string;
|
|
97
|
+
object: string;
|
|
98
|
+
}[];
|
|
99
|
+
id: string;
|
|
100
|
+
kind: string;
|
|
101
|
+
props?: Record<string, string>;
|
|
102
|
+
}[];
|
|
103
|
+
operations?: OperationSpec[];
|
|
104
|
+
scripts?: {
|
|
105
|
+
grants?: Record<string, {
|
|
106
|
+
binding?: string | SqliteBinding;
|
|
107
|
+
capability?: string;
|
|
108
|
+
coordinator?: string;
|
|
109
|
+
ops: string[] | 'all';
|
|
110
|
+
}>;
|
|
111
|
+
grantsAsUsed?: boolean;
|
|
112
|
+
limits?: Partial<Limits>;
|
|
113
|
+
name: string;
|
|
114
|
+
objects?: Record<string, ObjectRefSpec>;
|
|
115
|
+
owner?: ObjectRefSpec;
|
|
116
|
+
/** Its source file, or with `text`, the source itself. */
|
|
117
|
+
source: string;
|
|
118
|
+
text?: string;
|
|
119
|
+
}[];
|
|
120
|
+
/** The seed the Group's `random` generator starts from; 0 if absent. */
|
|
121
|
+
seed?: number | bigint;
|
|
122
|
+
sessionObjects?: readonly TranscriptItem[];
|
|
123
|
+
standard?: {
|
|
124
|
+
capability: string;
|
|
125
|
+
costs: Record<string, {
|
|
126
|
+
alloc?: number;
|
|
127
|
+
fuel?: number;
|
|
128
|
+
}>;
|
|
129
|
+
perRow?: number;
|
|
130
|
+
}[];
|
|
131
|
+
};
|
|
132
|
+
declare const operationDeclarations: (capabilities: ReadonlyMap<string, CapabilityDef<unknown>>) => GrantDecls;
|
|
133
|
+
/**
|
|
134
|
+
* The Core a case runs on: the TS Core's free functions by default, or
|
|
135
|
+
* another Core behind the same embedding interface, such as the Zig reactor's
|
|
136
|
+
* facade (`@northtalk/ts/wasm`).
|
|
137
|
+
*/
|
|
138
|
+
type CaseCore = {
|
|
139
|
+
compileLibrary: typeof compileLibrary;
|
|
140
|
+
defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
|
|
141
|
+
newGroup(o: GroupOptions): Group;
|
|
142
|
+
/** The Host's Libraries after a replacement, its dependents recompiled. */
|
|
143
|
+
replacementLibraries: typeof replacementLibraries;
|
|
144
|
+
restore(bytes: Uint8Array, o: RestoreOptions): {
|
|
145
|
+
group: Group;
|
|
146
|
+
result: RestoreResult;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
declare const tsCore: CaseCore;
|
|
150
|
+
declare const shapeSpec: (s: Shape) => ShapeSpec;
|
|
151
|
+
declare const capabilityOperations: (capabilities: readonly CapabilityDef<unknown>[]) => OperationSpec[];
|
|
152
|
+
/** Freeze a new declaration without modifying any previous Session Setup. */
|
|
153
|
+
declare const immutableSetup: (setup: Setup) => Setup;
|
|
154
|
+
type SetupGroup = {
|
|
155
|
+
declarations: GrantDecls;
|
|
156
|
+
grants: Map<string, Record<string, Grant<unknown>>>;
|
|
157
|
+
group: Group;
|
|
158
|
+
libraries: Map<string, Library | LoadError>;
|
|
159
|
+
load(group: Group, name: string, objects?: Record<string, HostObject>): Script;
|
|
160
|
+
};
|
|
161
|
+
/** Make a Group whose Scripts are loaded only when the Host requests them. */
|
|
162
|
+
declare const buildSetupGroup: (setup: Setup, capabilities: ReadonlyMap<string, CapabilityDef<unknown>>, options: {
|
|
163
|
+
core?: CaseCore;
|
|
164
|
+
name: string;
|
|
165
|
+
readSource?(file: string): string;
|
|
166
|
+
resolveObject?(kind: string, id: string): HostObject | undefined;
|
|
167
|
+
trace?(line: string): void;
|
|
168
|
+
withCoordinator?<T>(name: string | undefined, make: () => T): T;
|
|
169
|
+
}) => SetupGroup;
|
|
170
|
+
/** The caller decides whether an unavailable Capability is deferred or refused. */
|
|
171
|
+
declare class MissingCapabilityError extends Error {
|
|
172
|
+
readonly capability: string;
|
|
173
|
+
constructor(capability: string);
|
|
174
|
+
}
|
|
175
|
+
declare const shapeOf: (s: ShapeSpec) => Shape;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/session/host.d.ts
|
|
178
|
+
type SessionEnvironment = {
|
|
179
|
+
/**
|
|
180
|
+
* The Host functions of the Standard Capabilities this Host has built in
|
|
181
|
+
* for `:grant`, besides `clock`; each answer is recorded as a `~` line.
|
|
182
|
+
*/
|
|
183
|
+
builtIns?: {
|
|
184
|
+
calendar?: CalendarImpl;
|
|
185
|
+
locale?: LocaleImpl;
|
|
186
|
+
};
|
|
187
|
+
/** Fresh, deterministic immediate Host capabilities, also supplied during replay.
|
|
188
|
+
* They must not perform external I/O; their state belongs to this session. */
|
|
189
|
+
capabilities?(): readonly CapabilityDef<unknown>[];
|
|
190
|
+
/** A real Clock reading, in epoch microseconds. */
|
|
191
|
+
now(): bigint;
|
|
192
|
+
/** Initial bindings and all later objects/actions use the recording adapter. */
|
|
193
|
+
objects?(context: SessionObjects): Record<string, HostObject>;
|
|
194
|
+
/** Internal replay source; original native callbacks are never consulted. */
|
|
195
|
+
objectTranscript?: readonly TranscriptItem[];
|
|
196
|
+
/** A user Library's source, for `:library` given a path. */
|
|
197
|
+
readFile?(path: string): string;
|
|
198
|
+
/** A Store's contents, from the file `:store load` names. */
|
|
199
|
+
readStoreFile?(path: string): string;
|
|
200
|
+
/**
|
|
201
|
+
* Receives the session as its Session Transcript records it, item by item:
|
|
202
|
+
* each Entry and Session Command in its recorded form, each real Clock
|
|
203
|
+
* reading before its Pump, each line typed for `read`, and each line printed.
|
|
204
|
+
*/
|
|
205
|
+
record?(item: TranscriptItem): void;
|
|
206
|
+
resolveObject?(kind: string, id: string): {
|
|
207
|
+
native: unknown;
|
|
208
|
+
} | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Receives the value an expression Entry or `:inspect` echoes, with its Run,
|
|
211
|
+
* for tooling that copies it. It changes nothing the session prints.
|
|
212
|
+
*/
|
|
213
|
+
result?(run: string, value: Value): void;
|
|
214
|
+
/** Receives each line of the Group's Trace, without its LF. */
|
|
215
|
+
trace?(line: string): void;
|
|
216
|
+
/**
|
|
217
|
+
* TS tooling only: a `:fix` landed at a debugger pause, which a Transcript
|
|
218
|
+
* can't replay (ADR 0072). The Transcript ends before the last `dropped`
|
|
219
|
+
* items recorded, which came from the Host call whose Pump paused.
|
|
220
|
+
* Recording goes on, for a console, but isn't Transcript.
|
|
221
|
+
*/
|
|
222
|
+
transcriptEnds?(dropped: number): void;
|
|
223
|
+
/** Writes a file of `:export`, given a directory. */
|
|
224
|
+
writeFile?(directory: string, file: string, text: string): void;
|
|
225
|
+
/** Writes a Store's contents to the file `:store save` names. */
|
|
226
|
+
writeStoreFile?(path: string, text: string): void;
|
|
227
|
+
};
|
|
228
|
+
/** What the Session Host waits for before it returns the prompt. */
|
|
229
|
+
type Waiting = {
|
|
230
|
+
k: 'prompt';
|
|
231
|
+
} |
|
|
232
|
+
/** The Foreground Run waits on `console`'s `read`. */
|
|
233
|
+
{
|
|
234
|
+
k: 'read';
|
|
235
|
+
} |
|
|
236
|
+
/** The Foreground Run waits on a `user` prompt (chapter 12, Prompts). */
|
|
237
|
+
{
|
|
238
|
+
call: string;
|
|
239
|
+
k: 'user';
|
|
240
|
+
prompt: UserPrompt;
|
|
241
|
+
} |
|
|
242
|
+
/** The Foreground Run waits only for a deadline, so the Host sleeps. */
|
|
243
|
+
{
|
|
244
|
+
at: bigint;
|
|
245
|
+
k: 'deadline';
|
|
246
|
+
} |
|
|
247
|
+
/**
|
|
248
|
+
* A debugger paused the Group mid-Pump. Tooling only: the pause is not a
|
|
249
|
+
* Host Input, and the Pump's lines print when it completes.
|
|
250
|
+
*/
|
|
251
|
+
{
|
|
252
|
+
k: 'paused';
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* A `user` prompt, as the person sees it. An omitted prompt, default or
|
|
256
|
+
* title is "".
|
|
257
|
+
*/
|
|
258
|
+
type UserPrompt = {
|
|
259
|
+
k: 'confirm';
|
|
260
|
+
message: string;
|
|
261
|
+
} | {
|
|
262
|
+
items: readonly string[];
|
|
263
|
+
k: 'choose';
|
|
264
|
+
multiple: boolean;
|
|
265
|
+
prompt: string;
|
|
266
|
+
} | {
|
|
267
|
+
fallback: string;
|
|
268
|
+
k: 'enter';
|
|
269
|
+
message: string;
|
|
270
|
+
};
|
|
271
|
+
/** How a debugger continues a paused Pump. */
|
|
272
|
+
type DebugAction = 'resume' | 'step' | 'stepOver' | 'stepOut';
|
|
273
|
+
/** Where one declaration of the session source sits in the loaded code. */
|
|
274
|
+
type SourcePlacement = {
|
|
275
|
+
/** How many lines it has. */
|
|
276
|
+
lines: number;
|
|
277
|
+
/** The declaration's first line in the session source, from 1. */
|
|
278
|
+
sourceLine: number;
|
|
279
|
+
/** The code unit it was loaded in, and its first line there. */
|
|
280
|
+
unit: string;
|
|
281
|
+
unitLine: number;
|
|
282
|
+
};
|
|
283
|
+
/** How many arguments a mock Operation takes, each an Optional `any`. */
|
|
284
|
+
declare const MOCK_ARGUMENTS = 8;
|
|
285
|
+
/** A mock Operation `:mock` defined (chapter 12, Session Commands). */
|
|
286
|
+
type Mock = {
|
|
287
|
+
capability: string;
|
|
288
|
+
mode: 'immediate' | 'suspending' | 'fire-and-forget';
|
|
289
|
+
operation: string;
|
|
290
|
+
};
|
|
291
|
+
/** A Session Host for one session (chapter 12). */
|
|
292
|
+
declare class SessionHost {
|
|
293
|
+
private readonly env;
|
|
294
|
+
private group;
|
|
295
|
+
private objectSession;
|
|
296
|
+
private objectBindings;
|
|
297
|
+
private script;
|
|
298
|
+
private declarations;
|
|
299
|
+
private implicit;
|
|
300
|
+
private lastEntry;
|
|
301
|
+
private lastClock;
|
|
302
|
+
private placements;
|
|
303
|
+
private expressions;
|
|
304
|
+
private inspections;
|
|
305
|
+
private inspecting;
|
|
306
|
+
private reader;
|
|
307
|
+
private foreground;
|
|
308
|
+
private lastSeg;
|
|
309
|
+
private writes;
|
|
310
|
+
private reads;
|
|
311
|
+
private prompts;
|
|
312
|
+
private notes;
|
|
313
|
+
private events;
|
|
314
|
+
private state;
|
|
315
|
+
private units;
|
|
316
|
+
private deadline;
|
|
317
|
+
private setup0;
|
|
318
|
+
private stubs;
|
|
319
|
+
private mockCalls;
|
|
320
|
+
private readonly pending;
|
|
321
|
+
private virtual;
|
|
322
|
+
private limits;
|
|
323
|
+
private latest;
|
|
324
|
+
private grantsByName;
|
|
325
|
+
private declarations0;
|
|
326
|
+
private readonly libraries;
|
|
327
|
+
private readonly saves;
|
|
328
|
+
private readonly stores;
|
|
329
|
+
private notified;
|
|
330
|
+
private readonly admitted;
|
|
331
|
+
private observation;
|
|
332
|
+
private measuring;
|
|
333
|
+
private readonly extensions;
|
|
334
|
+
constructor(env: SessionEnvironment);
|
|
335
|
+
/** What the Host waits for before returning the prompt. */
|
|
336
|
+
get waiting(): Waiting;
|
|
337
|
+
/** The session source: its declarations, in the order entered. */
|
|
338
|
+
get source(): string;
|
|
339
|
+
/** The latest Entry's Run, once it has started; its background lines carry `[<run>] `. */
|
|
340
|
+
get latestRun(): string | undefined;
|
|
341
|
+
/** Whether the session has started, so its Grants are fixed. */
|
|
342
|
+
get started(): boolean;
|
|
343
|
+
/** Whether the Clock is virtual, so only `:clock` commands move it. */
|
|
344
|
+
get virtualClock(): boolean;
|
|
345
|
+
/** The next deadline a background Pump is due at, if any. */
|
|
346
|
+
get nextDeadline(): bigint | undefined;
|
|
347
|
+
/** The immutable declaration of the live Group, also consumed by Trace replay. */
|
|
348
|
+
get setup(): Setup;
|
|
349
|
+
/** The Host Manifest derived from the Session Setup, without starting it. */
|
|
350
|
+
exportManifest(): string;
|
|
351
|
+
/** Where each declaration of the session source is in the loaded code. */
|
|
352
|
+
get placementsOfSource(): SourcePlacement[];
|
|
353
|
+
/**
|
|
354
|
+
* TS tooling only: the debug controller of the session's Group, once the
|
|
355
|
+
* session has started. A Pump it pauses waits as `paused` until
|
|
356
|
+
* `continueDebug`; `:restore` replaces the Group and its controller.
|
|
357
|
+
*/
|
|
358
|
+
debugController(): DebugController | null;
|
|
359
|
+
/**
|
|
360
|
+
* Continues a debug-paused Pump. Returns the lines the Pump printed once it
|
|
361
|
+
* completes, as it would have printed them without the pause.
|
|
362
|
+
*/
|
|
363
|
+
continueDebug(action: DebugAction): string[];
|
|
364
|
+
/**
|
|
365
|
+
* TS tooling only: a `:fix` landed at a debugger pause, which a Transcript
|
|
366
|
+
* can't replay, so it records nothing from the Host call whose Pump paused
|
|
367
|
+
* (ADR 0072).
|
|
368
|
+
*/
|
|
369
|
+
get transcriptEnded(): boolean;
|
|
370
|
+
private transcriptEnd;
|
|
371
|
+
private unrecorded;
|
|
372
|
+
private callStart;
|
|
373
|
+
private entryHandlers;
|
|
374
|
+
private rewound;
|
|
375
|
+
private controller;
|
|
376
|
+
private paused;
|
|
377
|
+
/**
|
|
378
|
+
* Tooling's line prompt uses the same Entry classification as input(). A
|
|
379
|
+
* leading doc block waits for the declaration it documents.
|
|
380
|
+
*/
|
|
381
|
+
incomplete(source: string): boolean;
|
|
382
|
+
/**
|
|
383
|
+
* The Declaration Documentation of a current name or Handler Selector, as
|
|
384
|
+
* binding precedence resolves it: the session's own declarations and
|
|
385
|
+
* Imports, then the Built-ins. An Import resolves to its defining Library
|
|
386
|
+
* declaration. It executes nothing.
|
|
387
|
+
*/
|
|
388
|
+
documentation(name: string): Doc[];
|
|
389
|
+
/**
|
|
390
|
+
* A public Library export's Declaration Documentation, from the Library's
|
|
391
|
+
* source, whether or not it is imported.
|
|
392
|
+
*/
|
|
393
|
+
libraryDocumentation(library: string, name: string): Doc[];
|
|
394
|
+
private get names();
|
|
395
|
+
/**
|
|
396
|
+
* The Declaration Documentation of a Function Value's defining code, even
|
|
397
|
+
* when calling it would raise `function gone`. A Lambda's is empty; null
|
|
398
|
+
* means the value is not a Function Value.
|
|
399
|
+
*/
|
|
400
|
+
functionDocumentation(value: Value): string | null;
|
|
401
|
+
/**
|
|
402
|
+
* An Entry or a Session Command. Returns the lines it printed. At a
|
|
403
|
+
* debugger pause, only `:fix` of the paused Run.
|
|
404
|
+
*/
|
|
405
|
+
input(source: string): string[];
|
|
406
|
+
private recording;
|
|
407
|
+
private readonly recordedItems;
|
|
408
|
+
private record;
|
|
409
|
+
private recorded;
|
|
410
|
+
private printed;
|
|
411
|
+
private finished;
|
|
412
|
+
private entry;
|
|
413
|
+
/** Answers the Foreground Run's `read` with a line the user typed. */
|
|
414
|
+
read(line: string): string[];
|
|
415
|
+
/**
|
|
416
|
+
* Answers the Foreground Run's `user` prompt with what the person gave:
|
|
417
|
+
* a boolean, the chosen item or items, the entered text, or Nothing.
|
|
418
|
+
*/
|
|
419
|
+
answerPrompt(answer: Value): string[];
|
|
420
|
+
/** `Inspect()`, which is the Host Input `vars`; null before the session starts. */
|
|
421
|
+
inspect(): Inspection | null;
|
|
422
|
+
/** Replay an external action at its recorded position. */
|
|
423
|
+
replayObjectItem(item: TranscriptItem): void;
|
|
424
|
+
finishObjectReplay(): void;
|
|
425
|
+
/** Pumps at a deadline, under a real Clock. */
|
|
426
|
+
tick(): string[];
|
|
427
|
+
private start;
|
|
428
|
+
private capabilities;
|
|
429
|
+
private ask;
|
|
430
|
+
private userHost;
|
|
431
|
+
private answered;
|
|
432
|
+
private libraryDeclarations;
|
|
433
|
+
private mockCapabilities;
|
|
434
|
+
private command;
|
|
435
|
+
private beforeStart;
|
|
436
|
+
private grant;
|
|
437
|
+
private builtIn;
|
|
438
|
+
private mock;
|
|
439
|
+
private stub;
|
|
440
|
+
private settle;
|
|
441
|
+
private isHandler;
|
|
442
|
+
private has;
|
|
443
|
+
private sessionSource;
|
|
444
|
+
private declare;
|
|
445
|
+
private redeclareVariable;
|
|
446
|
+
private redefine;
|
|
447
|
+
private reloadFrom;
|
|
448
|
+
private fix;
|
|
449
|
+
private clock;
|
|
450
|
+
private limit;
|
|
451
|
+
private cancel;
|
|
452
|
+
private fuel;
|
|
453
|
+
private save;
|
|
454
|
+
private restore;
|
|
455
|
+
private library;
|
|
456
|
+
private store;
|
|
457
|
+
private export;
|
|
458
|
+
private inspected;
|
|
459
|
+
private discarded;
|
|
460
|
+
private refused;
|
|
461
|
+
private inspectExpression;
|
|
462
|
+
private readProperties;
|
|
463
|
+
private run;
|
|
464
|
+
private implicitVariables;
|
|
465
|
+
private pump;
|
|
466
|
+
private pumpAt;
|
|
467
|
+
private notifications;
|
|
468
|
+
private notifiedPump;
|
|
469
|
+
private pumped;
|
|
470
|
+
private print;
|
|
471
|
+
private ended;
|
|
472
|
+
private where;
|
|
473
|
+
private prefix;
|
|
474
|
+
private settleForeground;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* One declaration's Declaration Documentation, as a name lookup finds it.
|
|
478
|
+
* Handler Clauses are separate, in declaration order, numbered from 1.
|
|
479
|
+
*/
|
|
480
|
+
type Doc = {
|
|
481
|
+
/** A Handler Clause's number within its Selector, from 1; otherwise 0. */
|
|
482
|
+
clause: number;
|
|
483
|
+
declaration: 'function' | 'handler' | 'constant' | 'variable' | 'builtin';
|
|
484
|
+
doc: string;
|
|
485
|
+
/** `session`, `builtin` or the defining Library's name. */
|
|
486
|
+
origin: string;
|
|
487
|
+
};
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/session/transcript.d.ts
|
|
490
|
+
/** One line of a Transcript, with an Entry's further lines folded in. */
|
|
491
|
+
type TranscriptItem =
|
|
492
|
+
/** An Entry or a recorded Session Command, its lines joined by LF. */
|
|
493
|
+
{
|
|
494
|
+
k: 'input';
|
|
495
|
+
source: string;
|
|
496
|
+
} |
|
|
497
|
+
/** A line the user typed for `console`'s `read`. */
|
|
498
|
+
{
|
|
499
|
+
k: 'read';
|
|
500
|
+
line: string;
|
|
501
|
+
} |
|
|
502
|
+
/** A real Clock reading, before the Pump it was taken for. */
|
|
503
|
+
{
|
|
504
|
+
at: bigint;
|
|
505
|
+
k: 'clock';
|
|
506
|
+
} |
|
|
507
|
+
/** A built-in Capability's answer to a call. */
|
|
508
|
+
{
|
|
509
|
+
answer: string;
|
|
510
|
+
call: string;
|
|
511
|
+
k: 'answer';
|
|
512
|
+
} | {
|
|
513
|
+
json: string;
|
|
514
|
+
k: 'envelope';
|
|
515
|
+
} | {
|
|
516
|
+
k: 'comment';
|
|
517
|
+
text: string;
|
|
518
|
+
} | {
|
|
519
|
+
k: 'output';
|
|
520
|
+
text: string;
|
|
521
|
+
};
|
|
522
|
+
/** Read a Transcript's lines (chapter 12). */
|
|
523
|
+
declare const parseTranscript: (source: string) => TranscriptItem[];
|
|
524
|
+
/** Write a Transcript's lines, each ended by an LF. */
|
|
525
|
+
declare const writeTranscript: (items: readonly TranscriptItem[]) => string;
|
|
526
|
+
type ReplayOptions = {
|
|
527
|
+
capabilities?: SessionEnvironment['capabilities'];
|
|
528
|
+
/**
|
|
529
|
+
* Where the Session Host turns once the Transcript runs out, so a
|
|
530
|
+
* Playground can go on live from a replayed session: its Clock, its
|
|
531
|
+
* built-in Capabilities, and where later items and echoed values go.
|
|
532
|
+
*/
|
|
533
|
+
live?: Pick<SessionEnvironment, 'builtIns' | 'capabilities' | 'now' | 'record' | 'result' | 'transcriptEnds'>;
|
|
534
|
+
/** Receives each line of the Group's Trace, without its LF. */
|
|
535
|
+
trace?(line: string): void;
|
|
536
|
+
};
|
|
537
|
+
type Replayed = {
|
|
538
|
+
/** The Session Host the Transcript replayed through, as it ended. */
|
|
539
|
+
host: SessionHost;
|
|
540
|
+
/** The Transcript with the output lines the replay printed. */
|
|
541
|
+
items: TranscriptItem[];
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Replay a Transcript through a fresh Session Host (chapter 12, Replaying):
|
|
545
|
+
* each `@` reading is that Pump's Clock reading, each `<` line answers
|
|
546
|
+
* `read`, and each `~` line answers its call, a `user` prompt's included. The result has the lines it printed in place of the recorded ones.
|
|
547
|
+
*/
|
|
548
|
+
declare const replayTranscript: (recorded: readonly TranscriptItem[], options?: ReplayOptions) => Replayed;
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/session/objects.d.ts
|
|
551
|
+
type ObjectReference = {
|
|
552
|
+
id: string;
|
|
553
|
+
kind: string;
|
|
554
|
+
};
|
|
555
|
+
type Envelope = Record<string, unknown> & {
|
|
556
|
+
type: string;
|
|
557
|
+
};
|
|
558
|
+
declare const parseEnvelope: (source: string) => Envelope;
|
|
559
|
+
/** Host adapters use this context for object registration and external actions. */
|
|
560
|
+
declare class SessionObjects {
|
|
561
|
+
private readonly record;
|
|
562
|
+
private readonly recorded?;
|
|
563
|
+
private enabled;
|
|
564
|
+
private group;
|
|
565
|
+
readonly items: TranscriptItem[];
|
|
566
|
+
private kinds;
|
|
567
|
+
private declarations;
|
|
568
|
+
private objects;
|
|
569
|
+
private crossing;
|
|
570
|
+
private exposure;
|
|
571
|
+
private handle;
|
|
572
|
+
private handles;
|
|
573
|
+
private supplied;
|
|
574
|
+
private replay;
|
|
575
|
+
private active;
|
|
576
|
+
private failure;
|
|
577
|
+
private traceSaves;
|
|
578
|
+
private queuedTraceActions;
|
|
579
|
+
constructor(record: (item: TranscriptItem) => void, recorded?: readonly TranscriptItem[] | undefined, enabled?: boolean);
|
|
580
|
+
attach(group: Group): void;
|
|
581
|
+
private next;
|
|
582
|
+
private consume;
|
|
583
|
+
private emit;
|
|
584
|
+
private commandCursor;
|
|
585
|
+
private beforeCommand;
|
|
586
|
+
private describeSnapshot;
|
|
587
|
+
traceInput(name: string, ids?: readonly string[]): boolean;
|
|
588
|
+
traceObjects(): HostObject[];
|
|
589
|
+
private registrations;
|
|
590
|
+
private nextType;
|
|
591
|
+
preload(): Record<string, HostObject>;
|
|
592
|
+
initial(bindings: Record<string, HostObject>): void;
|
|
593
|
+
defineKind<N>(definition: ObjectKindDef<N>): ObjectKind<N>;
|
|
594
|
+
object<N>(kind: ObjectKind<N>, id: string, native: N): HostObject<N>;
|
|
595
|
+
private registerKind;
|
|
596
|
+
private registerObject;
|
|
597
|
+
private objectRef;
|
|
598
|
+
private property;
|
|
599
|
+
private propertyCrossing;
|
|
600
|
+
encode(value: Value): string;
|
|
601
|
+
private decode;
|
|
602
|
+
expose(tree: unknown): void;
|
|
603
|
+
reports(reports: readonly Report[]): void;
|
|
604
|
+
snapshot(scripts: readonly {
|
|
605
|
+
name: string;
|
|
606
|
+
vars: readonly [string, Value][];
|
|
607
|
+
}[]): void;
|
|
608
|
+
resolve(kind: string, id: string, resolve?: (kind: string, id: string) => {
|
|
609
|
+
native: unknown;
|
|
610
|
+
} | undefined): {
|
|
611
|
+
native: unknown;
|
|
612
|
+
} | undefined;
|
|
613
|
+
private resolving;
|
|
614
|
+
private outcomes;
|
|
615
|
+
crossesHandles(): boolean;
|
|
616
|
+
saved(name: string): void;
|
|
617
|
+
restored(name?: string): void;
|
|
618
|
+
action(request: Record<string, unknown>): Record<string, unknown>;
|
|
619
|
+
private replayInput;
|
|
620
|
+
drain(item: TranscriptItem): void;
|
|
621
|
+
finish(): void;
|
|
622
|
+
private perform;
|
|
623
|
+
}
|
|
624
|
+
//#endregion
|
|
625
|
+
export { shapeOf as A, Setup as C, capabilityOperations as D, buildSetupGroup as E, tsCore as M, immutableSetup as O, OperationSpec as S, ShapeSpec as T, UserPrompt as _, ReplayOptions as a, MissingCapabilityError as b, parseTranscript as c, DebugAction as d, MOCK_ARGUMENTS as f, SourcePlacement as g, SessionHost as h, parseEnvelope as i, shapeSpec as j, operationDeclarations as k, replayTranscript as l, SessionEnvironment as m, ObjectReference as n, Replayed as o, Mock as p, SessionObjects as r, TranscriptItem as s, Envelope as t, writeTranscript as u, Waiting as v, SetupGroup as w, ObjectRefSpec as x, CaseCore as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@northtalk/ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NorthTalk, a readable scripting language for embedding: the TS Core, its Session Host and Standard Capabilities.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://github.com/odogono/odgn-talk/tree/main/impl/ts#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/odogono/odgn-talk.git",
|
|
11
|
+
"directory": "impl/ts"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/odogono/odgn-talk/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"northtalk",
|
|
16
|
+
"scripting",
|
|
17
|
+
"language",
|
|
18
|
+
"interpreter",
|
|
19
|
+
"embedding"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
|
+
"default": "./index.js"
|
|
29
|
+
},
|
|
30
|
+
"./session": {
|
|
31
|
+
"types": "./session.d.ts",
|
|
32
|
+
"default": "./session.js"
|
|
33
|
+
},
|
|
34
|
+
"./store": {
|
|
35
|
+
"types": "./store.d.ts",
|
|
36
|
+
"default": "./store.js"
|
|
37
|
+
},
|
|
38
|
+
"./notify": {
|
|
39
|
+
"types": "./notify.d.ts",
|
|
40
|
+
"default": "./notify.js"
|
|
41
|
+
},
|
|
42
|
+
"./sqlite": {
|
|
43
|
+
"types": "./sqlite.d.ts",
|
|
44
|
+
"default": "./sqlite.js"
|
|
45
|
+
},
|
|
46
|
+
"./setup": {
|
|
47
|
+
"types": "./setup.d.ts",
|
|
48
|
+
"default": "./setup.js"
|
|
49
|
+
},
|
|
50
|
+
"./debug": {
|
|
51
|
+
"types": "./debug.d.ts",
|
|
52
|
+
"default": "./debug.js"
|
|
53
|
+
},
|
|
54
|
+
"./driver": {
|
|
55
|
+
"types": "./driver.d.ts",
|
|
56
|
+
"default": "./driver.js"
|
|
57
|
+
},
|
|
58
|
+
"./wasm": {
|
|
59
|
+
"types": "./wasm.d.ts",
|
|
60
|
+
"default": "./wasm.js"
|
|
61
|
+
},
|
|
62
|
+
"./package.json": "./package.json"
|
|
63
|
+
}
|
|
64
|
+
}
|