@opencode/codemode 2.2.5 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -1
- package/dist/codemode.d.ts +55 -4
- package/dist/codemode.js +63 -8
- package/dist/extension.d.ts +14 -9
- package/dist/extension.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interpreter/execute.d.ts +1 -1
- package/dist/interpreter/execute.js +16 -4
- package/dist/interpreter/extensions.d.ts +3 -3
- package/dist/interpreter/extensions.js +17 -11
- package/dist/interpreter/globals.js +10 -0
- package/dist/interpreter/interpreter.d.ts +11 -1
- package/dist/interpreter/interpreter.js +86 -2
- package/dist/interpreter/modules.d.ts +4 -0
- package/dist/interpreter/modules.js +33 -0
- package/dist/suspend-error.d.ts +23 -0
- package/dist/suspend-error.js +25 -0
- package/dist/tool-runtime.d.ts +4 -1
- package/dist/vm/async.d.ts +78 -0
- package/dist/vm/async.js +335 -0
- package/dist/vm/code.d.ts +122 -0
- package/dist/vm/code.js +407 -0
- package/dist/vm/compiler/compile.d.ts +13 -0
- package/dist/vm/compiler/compile.js +1477 -0
- package/dist/vm/compiler/scope.d.ts +74 -0
- package/dist/vm/compiler/scope.js +515 -0
- package/dist/vm/data.d.ts +7 -0
- package/dist/vm/data.js +13 -0
- package/dist/vm/generators.d.ts +42 -0
- package/dist/vm/generators.js +413 -0
- package/dist/vm/host.d.ts +103 -0
- package/dist/vm/host.js +226 -0
- package/dist/vm/index.d.ts +6 -0
- package/dist/vm/index.js +6 -0
- package/dist/vm/internal-prelude.d.ts +45 -0
- package/dist/vm/internal-prelude.js +534 -0
- package/dist/vm/opcodes.d.ts +222 -0
- package/dist/vm/opcodes.js +235 -0
- package/dist/vm/prelude/bytecode.d.ts +18 -0
- package/dist/vm/prelude/bytecode.js +31 -0
- package/dist/vm/prelude/bytecode.json +1 -0
- package/dist/vm/prelude/helpers.d.ts +8 -0
- package/dist/vm/prelude/helpers.js +258 -0
- package/dist/vm/prelude/prelude.d.ts +21 -0
- package/dist/vm/prelude/prelude.js +53 -0
- package/dist/vm/prelude/source.d.ts +1 -0
- package/dist/vm/prelude/source.js +652 -0
- package/dist/vm/runtime/callback.d.ts +25 -0
- package/dist/vm/runtime/callback.js +51 -0
- package/dist/vm/runtime/driver.d.ts +58 -0
- package/dist/vm/runtime/driver.js +184 -0
- package/dist/vm/runtime/errors.d.ts +23 -0
- package/dist/vm/runtime/errors.js +169 -0
- package/dist/vm/runtime/execute.d.ts +80 -0
- package/dist/vm/runtime/execute.js +414 -0
- package/dist/vm/runtime/extensions.d.ts +16 -0
- package/dist/vm/runtime/extensions.js +270 -0
- package/dist/vm/runtime/generators.d.ts +6 -0
- package/dist/vm/runtime/generators.js +44 -0
- package/dist/vm/runtime/globals.d.ts +6 -0
- package/dist/vm/runtime/globals.js +137 -0
- package/dist/vm/runtime/interpreter.d.ts +50 -0
- package/dist/vm/runtime/interpreter.js +94 -0
- package/dist/vm/runtime/intrinsic-names.d.ts +56 -0
- package/dist/vm/runtime/intrinsic-names.js +166 -0
- package/dist/vm/runtime/intrinsics.d.ts +15 -0
- package/dist/vm/runtime/intrinsics.js +111 -0
- package/dist/vm/runtime/limits.d.ts +10 -0
- package/dist/vm/runtime/limits.js +19 -0
- package/dist/vm/runtime/model.d.ts +58 -0
- package/dist/vm/runtime/model.js +57 -0
- package/dist/vm/runtime/modules.d.ts +4 -0
- package/dist/vm/runtime/modules.js +33 -0
- package/dist/vm/runtime/native.d.ts +19 -0
- package/dist/vm/runtime/native.js +41 -0
- package/dist/vm/runtime/objects.d.ts +403 -0
- package/dist/vm/runtime/objects.js +784 -0
- package/dist/vm/runtime/operations.d.ts +49 -0
- package/dist/vm/runtime/operations.js +288 -0
- package/dist/vm/runtime/promises.d.ts +55 -0
- package/dist/vm/runtime/promises.js +232 -0
- package/dist/vm/runtime/references.d.ts +8 -0
- package/dist/vm/runtime/references.js +51 -0
- package/dist/vm/runtime/signals.d.ts +69 -0
- package/dist/vm/runtime/signals.js +68 -0
- package/dist/vm/runtime/source.d.ts +29 -0
- package/dist/vm/runtime/source.js +63 -0
- package/dist/vm/runtime/table.d.ts +43 -0
- package/dist/vm/runtime/table.js +132 -0
- package/dist/vm/scheduler.d.ts +178 -0
- package/dist/vm/scheduler.js +63 -0
- package/dist/vm/snapshot/codec.d.ts +87 -0
- package/dist/vm/snapshot/codec.js +751 -0
- package/dist/vm/snapshot/snapshot.d.ts +49 -0
- package/dist/vm/snapshot/snapshot.js +70 -0
- package/dist/vm/snapshot.d.ts +32 -0
- package/dist/vm/snapshot.js +306 -0
- package/dist/vm/stdlib/array.d.ts +16 -0
- package/dist/vm/stdlib/array.js +311 -0
- package/dist/vm/stdlib/bytes.d.ts +11 -0
- package/dist/vm/stdlib/bytes.js +222 -0
- package/dist/vm/stdlib/collections.d.ts +7 -0
- package/dist/vm/stdlib/collections.js +188 -0
- package/dist/vm/stdlib/console.d.ts +6 -0
- package/dist/vm/stdlib/console.js +93 -0
- package/dist/vm/stdlib/date.d.ts +2 -0
- package/dist/vm/stdlib/date.js +123 -0
- package/dist/vm/stdlib/headers.d.ts +2 -0
- package/dist/vm/stdlib/headers.js +92 -0
- package/dist/vm/stdlib/iterator.d.ts +2 -0
- package/dist/vm/stdlib/iterator.js +30 -0
- package/dist/vm/stdlib/json.d.ts +3 -0
- package/dist/vm/stdlib/json.js +42 -0
- package/dist/vm/stdlib/math.d.ts +3 -0
- package/dist/vm/stdlib/math.js +73 -0
- package/dist/vm/stdlib/number.d.ts +3 -0
- package/dist/vm/stdlib/number.js +72 -0
- package/dist/vm/stdlib/object.d.ts +6 -0
- package/dist/vm/stdlib/object.js +201 -0
- package/dist/vm/stdlib/regexp.d.ts +8 -0
- package/dist/vm/stdlib/regexp.js +119 -0
- package/dist/vm/stdlib/string.d.ts +2 -0
- package/dist/vm/stdlib/string.js +272 -0
- package/dist/vm/stdlib/url.d.ts +25 -0
- package/dist/vm/stdlib/url.js +255 -0
- package/dist/vm/stdlib/value.d.ts +6 -0
- package/dist/vm/stdlib/value.js +32 -0
- package/dist/vm/stdlib/web.d.ts +5 -0
- package/dist/vm/stdlib/web.js +97 -0
- package/dist/vm/vm.d.ts +225 -0
- package/dist/vm/vm.js +2931 -0
- package/package.json +6 -3
package/dist/vm/host.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { fromJson } from "./data.js";
|
|
2
|
+
import { startExtensionCall } from "./runtime/extensions.js";
|
|
3
|
+
import { Lost, lostError } from "./runtime/model.js";
|
|
4
|
+
import { Arr, PromiseObj } from "./runtime/objects.js";
|
|
5
|
+
import { promiseLike } from "./runtime/promises.js";
|
|
6
|
+
import { HostCall, Resolving } from "./scheduler.js";
|
|
7
|
+
import { internalCode, tryFastBoundaryOrJson, VmIntrinsic } from "./internal-prelude.js";
|
|
8
|
+
import { Mode } from "./vm.js";
|
|
9
|
+
/** A native's answer asking the VM to stop the job until the blocking host call it queued completes. */
|
|
10
|
+
export const BLOCK = Symbol("vm.block");
|
|
11
|
+
/** A host operation pushed an internal frame that produces its result. */
|
|
12
|
+
export const ENTERED = Symbol("vm.entered");
|
|
13
|
+
/** Visited nodes a native fast path may spend before it hands the work to the prelude walk, which slices. */
|
|
14
|
+
export const VISIT_BUDGET = 2048;
|
|
15
|
+
/**
|
|
16
|
+
* The host calls of one run: queued (written ahead, for the driver to start at the next stop), running, completed and
|
|
17
|
+
* waiting in the inbox, and the blocking call the current job waits on. Ids count up in program order.
|
|
18
|
+
*/
|
|
19
|
+
export class HostCalls {
|
|
20
|
+
ctx;
|
|
21
|
+
promises;
|
|
22
|
+
queued = [];
|
|
23
|
+
running = new Map();
|
|
24
|
+
inbox = [];
|
|
25
|
+
nextID = 0;
|
|
26
|
+
/** The blocking call the job on the stack waits on. */
|
|
27
|
+
blocked = undefined;
|
|
28
|
+
/** A completed blocking call's outcome, which continues the job on the stack before anything else runs. */
|
|
29
|
+
input = undefined;
|
|
30
|
+
/** The synchronous extension call the program is in the middle of: see `Engine.activeExtension`. */
|
|
31
|
+
extension = undefined;
|
|
32
|
+
extensionResume = undefined;
|
|
33
|
+
constructor(ctx, promises) {
|
|
34
|
+
this.ctx = ctx;
|
|
35
|
+
this.promises = promises;
|
|
36
|
+
}
|
|
37
|
+
/** Queues concurrent host work; `resolving` settles its promise in a later job, in completion order. */
|
|
38
|
+
host(request, call) {
|
|
39
|
+
return this.queue(request, call.label, false, call.result, call.resolving, call.site);
|
|
40
|
+
}
|
|
41
|
+
/** Queues blocking `search` work: the job stops until it completes, then continues with its result. */
|
|
42
|
+
blockSearch(args) {
|
|
43
|
+
return this.block({ kind: "search", args }, "search", undefined);
|
|
44
|
+
}
|
|
45
|
+
/** Queues blocking extension work: the job stops until it completes, then continues with `resume`. */
|
|
46
|
+
blockExtension(call, resume) {
|
|
47
|
+
return this.block({ kind: "extension", call }, "extension", resume);
|
|
48
|
+
}
|
|
49
|
+
block(request, label, resume) {
|
|
50
|
+
this.blocked = this.queue(request, label, true, "value", undefined, undefined);
|
|
51
|
+
this.extensionResume = resume;
|
|
52
|
+
return BLOCK;
|
|
53
|
+
}
|
|
54
|
+
queue(request, label, blocking, result, resolving, site) {
|
|
55
|
+
const id = this.nextID++;
|
|
56
|
+
const call = new HostCall(id, request, label, blocking, result, resolving, site);
|
|
57
|
+
this.queued.push(call);
|
|
58
|
+
return call;
|
|
59
|
+
}
|
|
60
|
+
/** Continues the job stopped at a blocking call with its outcome. */
|
|
61
|
+
resume(input) {
|
|
62
|
+
const resume = this.extensionResume;
|
|
63
|
+
if (resume !== undefined) {
|
|
64
|
+
this.extensionResume = undefined;
|
|
65
|
+
return resume(input.completion);
|
|
66
|
+
}
|
|
67
|
+
if (!input.completion.ok)
|
|
68
|
+
throw input.completion.error;
|
|
69
|
+
return promiseLike(this.ctx, fromJson(this.ctx, input.completion.value));
|
|
70
|
+
}
|
|
71
|
+
/** Hands the queued calls to the driver: they are running from now on. */
|
|
72
|
+
handOver() {
|
|
73
|
+
const calls = this.queued;
|
|
74
|
+
this.queued = [];
|
|
75
|
+
for (const call of calls)
|
|
76
|
+
this.running.set(call.id, call);
|
|
77
|
+
return calls;
|
|
78
|
+
}
|
|
79
|
+
complete(id, completion) {
|
|
80
|
+
const call = this.running.get(id);
|
|
81
|
+
if (call === undefined)
|
|
82
|
+
return;
|
|
83
|
+
this.running.delete(id);
|
|
84
|
+
// Its outcome is all that is left: the host function, its arguments, and what it returned are dropped.
|
|
85
|
+
const request = call.request;
|
|
86
|
+
if (request.kind === "extension") {
|
|
87
|
+
request.call.invocation = undefined;
|
|
88
|
+
request.call.host = undefined;
|
|
89
|
+
request.call.args = [];
|
|
90
|
+
}
|
|
91
|
+
if (call.blocking) {
|
|
92
|
+
call.status = "completed";
|
|
93
|
+
if (this.blocked !== call)
|
|
94
|
+
return;
|
|
95
|
+
this.blocked = undefined;
|
|
96
|
+
this.input = { call, completion };
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.inbox.push({ call, completion });
|
|
100
|
+
}
|
|
101
|
+
/** Settles the oldest completed concurrent call's promise; false when the inbox is empty. */
|
|
102
|
+
deliver() {
|
|
103
|
+
const delivery = this.inbox.shift();
|
|
104
|
+
if (delivery === undefined)
|
|
105
|
+
return false;
|
|
106
|
+
const call = delivery.call;
|
|
107
|
+
const completion = delivery.completion;
|
|
108
|
+
call.status = "completed";
|
|
109
|
+
const resolving = call.resolving;
|
|
110
|
+
if (!completion.ok)
|
|
111
|
+
resolving.reject(completion.error);
|
|
112
|
+
else {
|
|
113
|
+
resolving.resolve(call.result === "json" ? fromJson(this.ctx, completion.value) : completion.value);
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// --- Tool calls ---
|
|
119
|
+
/**
|
|
120
|
+
* A tool call returns its promise at once. Plain-data arguments cross on the native fast path; anything else
|
|
121
|
+
* (`toJSON`, a promise, a deep or shared value) crosses through `$vmCross` at the call, which queues the call with the
|
|
122
|
+
* same `Resolving` or rejects it. Either way the call is queued once its arguments have crossed, and the driver starts
|
|
123
|
+
* it before any other job runs.
|
|
124
|
+
*/
|
|
125
|
+
export const callTool = (vm, hosts, path, args, site) => {
|
|
126
|
+
const resolving = hosts.promises.resolving(hosts.promises.newPromise());
|
|
127
|
+
const json = crossFast(vm.ctx, args);
|
|
128
|
+
if (json === undefined) {
|
|
129
|
+
// A failure while crossing rejects the promise, which the caller receives either way.
|
|
130
|
+
vm.pushInternal(internalCode("$vmCross"), [arrayOf(vm, args), arrayOf(vm, [...path]), resolving], site, Mode.REJECT_ONLY, resolving, resolving.promise);
|
|
131
|
+
return ENTERED;
|
|
132
|
+
}
|
|
133
|
+
if (json instanceof Failure) {
|
|
134
|
+
resolving.reject(json.error);
|
|
135
|
+
return resolving.promise;
|
|
136
|
+
}
|
|
137
|
+
hosts.host({ kind: "tool", path, args: json }, { label: path.join("."), result: "json", resolving, site });
|
|
138
|
+
return resolving.promise;
|
|
139
|
+
};
|
|
140
|
+
/** `search(...)`: blocking; its result can be used directly, or awaited and chained like a Promise. */
|
|
141
|
+
export const callSearch = (vm, hosts, args, site) => {
|
|
142
|
+
const json = crossFast(vm.ctx, args);
|
|
143
|
+
if (json === undefined) {
|
|
144
|
+
vm.pushInternal(internalCode("$vmCross"), [arrayOf(vm, args), "search"], site);
|
|
145
|
+
return ENTERED;
|
|
146
|
+
}
|
|
147
|
+
if (json instanceof Failure)
|
|
148
|
+
throw json.error;
|
|
149
|
+
return hosts.blockSearch(json);
|
|
150
|
+
};
|
|
151
|
+
class Failure {
|
|
152
|
+
error;
|
|
153
|
+
constructor(error) {
|
|
154
|
+
this.error = error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Every argument as host JSON on the budgeted fast path; undefined when one needs the prelude walk.
|
|
158
|
+
const crossFast = (ctx, args) => {
|
|
159
|
+
const json = [];
|
|
160
|
+
try {
|
|
161
|
+
for (const arg of args) {
|
|
162
|
+
const crossed = tryFastBoundaryOrJson(ctx.builtins, arg, true, VISIT_BUDGET);
|
|
163
|
+
if (!crossed.ok)
|
|
164
|
+
return undefined;
|
|
165
|
+
json.push(crossed.json);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return new Failure(error);
|
|
170
|
+
}
|
|
171
|
+
return json;
|
|
172
|
+
};
|
|
173
|
+
const arrayOf = (vm, values) => new Arr(vm.ctx.builtins.Array, [...values]);
|
|
174
|
+
// --- Extension calls ---
|
|
175
|
+
/**
|
|
176
|
+
* A synchronous extension function's call, staged here so its host values never enter a frame: the `extension.before`
|
|
177
|
+
* hook (blocking), then the host function; what it returns settles now (blocking) unless it is an Effect or a Promise,
|
|
178
|
+
* which the program holds a promise for. The call is active, holding live host values, until its result is a program
|
|
179
|
+
* value or its concurrent call is queued.
|
|
180
|
+
*/
|
|
181
|
+
export const callExtension = (ctx, hosts, slots, site) => {
|
|
182
|
+
const label = slots[2];
|
|
183
|
+
const call = {
|
|
184
|
+
host: slots[0],
|
|
185
|
+
args: slots[1],
|
|
186
|
+
label,
|
|
187
|
+
invocation: slots[3],
|
|
188
|
+
};
|
|
189
|
+
if (call.host instanceof Lost)
|
|
190
|
+
throw lostError(`The function ${label}`);
|
|
191
|
+
hosts.extension = { path: label };
|
|
192
|
+
const run = () => {
|
|
193
|
+
const started = startExtensionCall(ctx, call.host, call.args, call, site);
|
|
194
|
+
if (started instanceof PromiseObj) {
|
|
195
|
+
hosts.extension = undefined;
|
|
196
|
+
return started;
|
|
197
|
+
}
|
|
198
|
+
return hosts.blockExtension(started, (completion) => {
|
|
199
|
+
hosts.extension = undefined;
|
|
200
|
+
if (!completion.ok)
|
|
201
|
+
throw completion.error;
|
|
202
|
+
return completion.value;
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
if (call.invocation === undefined || ctx.tools.hooks["extension.before"] === undefined)
|
|
206
|
+
return run();
|
|
207
|
+
const before = { stage: "before", ...call, host: undefined, threw: false };
|
|
208
|
+
return hosts.blockExtension(before, (completion) => {
|
|
209
|
+
if (!completion.ok) {
|
|
210
|
+
hosts.extension = undefined;
|
|
211
|
+
throw completion.error;
|
|
212
|
+
}
|
|
213
|
+
return run();
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
/** The intrinsics the boundary walk calls to queue a tool or search host call. */
|
|
217
|
+
export const registerHostIntrinsics = (map, vm) => {
|
|
218
|
+
const json = (value) => value.items;
|
|
219
|
+
map.set("$HostTool", new VmIntrinsic("$HostTool", ([path, args, resolving]) => {
|
|
220
|
+
const keys = path.items;
|
|
221
|
+
const site = vm.frames[vm.frames.length - 1]?.origin;
|
|
222
|
+
vm.hosts.host({ kind: "tool", path: keys, args: json(args) }, { label: keys.join("."), result: "json", resolving: resolving, site });
|
|
223
|
+
return undefined;
|
|
224
|
+
}));
|
|
225
|
+
map.set("$HostSearch", new VmIntrinsic("$HostSearch", ([args]) => vm.hosts.blockSearch(json(args))));
|
|
226
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as VmEngine from "./index.js";
|
|
2
|
+
export { fromJson } from "./data.js";
|
|
3
|
+
export { execute, finishExecution, resumeProgram, type Running, type Setup, startProgram } from "./runtime/execute.js";
|
|
4
|
+
export { extensionGlobals } from "./runtime/extensions.js";
|
|
5
|
+
export { globalNames } from "./runtime/globals.js";
|
|
6
|
+
export { fromBytes, type Snapshot, SnapshotError, type SnapshotHeader, toBytes } from "./snapshot/snapshot.js";
|
package/dist/vm/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as VmEngine from "./index.js";
|
|
2
|
+
export { fromJson } from "./data.js";
|
|
3
|
+
export { execute, finishExecution, resumeProgram, startProgram } from "./runtime/execute.js";
|
|
4
|
+
export { extensionGlobals } from "./runtime/extensions.js";
|
|
5
|
+
export { globalNames } from "./runtime/globals.js";
|
|
6
|
+
export { fromBytes, SnapshotError, toBytes } from "./snapshot/snapshot.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Json } from "./data.js";
|
|
2
|
+
import type { Builtins } from "./runtime/intrinsics.js";
|
|
3
|
+
import { type NativeResult, type Value } from "./runtime/objects.js";
|
|
4
|
+
import type { Code } from "./code.js";
|
|
5
|
+
import { type Vm } from "./vm.js";
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight internal callable for VM-only `$` intrinsics. Does not extend `Obj` or `Native`,
|
|
8
|
+
* so it never touches `builtins.Function`, `nativeRule.sealed`, or static intrinsic numbering.
|
|
9
|
+
*/
|
|
10
|
+
export declare class VmIntrinsic {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly call: (args: Array<Value>) => NativeResult;
|
|
13
|
+
constructor(name: string, call: (args: Array<Value>) => NativeResult);
|
|
14
|
+
}
|
|
15
|
+
export declare const INTERNAL_SOURCE: string;
|
|
16
|
+
/** The VM's internal helpers' bytecode, and their functions' code by name. */
|
|
17
|
+
export declare const getInternalPrelude: () => {
|
|
18
|
+
codes: readonly Code[];
|
|
19
|
+
byName: Map<string, Code>;
|
|
20
|
+
};
|
|
21
|
+
/** The code of the internal helper `name`. */
|
|
22
|
+
export declare const internalCode: (name: string) => Code;
|
|
23
|
+
/**
|
|
24
|
+
* Adds the intrinsics available to `CodeFlags.INTERNAL` functions (both `@prelude` and `@vm-internal`) to `map`: the
|
|
25
|
+
* internal helpers, and the `$` natives. Uses `VmIntrinsic` rather than `Native` so it never touches
|
|
26
|
+
* `builtins.Function` or `nativeRule.sealed`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const registerVmIntrinsics: (map: Map<string, unknown>, vm: Vm) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Budgeted native fast path for copying plain data at the host boundary (`boundary`) or for `JSON.stringify`. Returns
|
|
31
|
+
* `{ ok: true, json }` if the tree has no custom `toJSON`, promises, or shared references revisited more than `budget`
|
|
32
|
+
* times; otherwise the prelude walk (`$vmJsonWalk`) does the work, ticking fuel.
|
|
33
|
+
*
|
|
34
|
+
* Both give the text `JSON.stringify` would: `toJSON` is honored, functions and `undefined` vanish, non-finite numbers
|
|
35
|
+
* become null, and everything else is copied. Two departures from JS so a mistake is not a silent `{}`: an Error
|
|
36
|
+
* serializes as `{ name, message, ...own }`, and a promise throws. At the host boundary a promise is awaited, a Set
|
|
37
|
+
* crosses as an array, a URLSearchParams as its query string, a Uint8Array asks to be encoded as text first, and a
|
|
38
|
+
* `__proto__` key is dropped so host code can never receive one.
|
|
39
|
+
*/
|
|
40
|
+
export declare const tryFastBoundaryOrJson: (builtins: Builtins, value: Value, boundary: boolean, revisitBudget?: number) => {
|
|
41
|
+
readonly ok: true;
|
|
42
|
+
readonly json: Json | undefined;
|
|
43
|
+
} | {
|
|
44
|
+
readonly ok: false;
|
|
45
|
+
};
|