@opencode/codemode 2.2.7 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -13
- package/dist/{vm/async.d.ts → async.d.ts} +1 -1
- package/dist/codemode.d.ts +8 -22
- package/dist/codemode.js +17 -38
- package/dist/data.d.ts +4 -19
- package/dist/data.js +1 -82
- package/dist/extension.d.ts +8 -2
- package/dist/extension.js +9 -0
- package/dist/{vm/host.d.ts → host.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{vm/opcodes.d.ts → opcodes.d.ts} +1 -1
- package/dist/{vm/prelude → prelude}/helpers.js +1 -1
- package/dist/{vm/runtime → runtime}/driver.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/driver.js +1 -1
- package/dist/{vm/runtime → runtime}/errors.js +2 -2
- package/dist/{vm/runtime → runtime}/execute.d.ts +17 -8
- package/dist/{vm/runtime → runtime}/execute.js +11 -9
- package/dist/{vm/runtime → runtime}/extensions.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/extensions.js +39 -4
- package/dist/{vm/runtime → runtime}/globals.js +1 -1
- package/dist/{vm/runtime → runtime}/interpreter.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/model.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/objects.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/objects.js +1 -1
- package/dist/{vm/runtime → runtime}/operations.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/operations.js +1 -1
- package/dist/scan.js +2 -2
- package/dist/{vm/scheduler.d.ts → scheduler.d.ts} +1 -1
- package/dist/{vm/snapshot → snapshot}/codec.d.ts +6 -5
- package/dist/{vm/snapshot → snapshot}/codec.js +12 -5
- package/dist/{vm/snapshot → snapshot}/snapshot.d.ts +8 -5
- package/dist/{vm/snapshot → snapshot}/snapshot.js +14 -3
- package/dist/{vm/snapshot.js → snapshot.js} +1 -1
- package/dist/stdlib/array.d.ts +14 -9
- package/dist/stdlib/array.js +89 -276
- package/dist/stdlib/bytes.d.ts +11 -7
- package/dist/stdlib/bytes.js +112 -79
- package/dist/stdlib/collections.d.ts +7 -7
- package/dist/stdlib/collections.js +30 -339
- package/dist/stdlib/console.d.ts +2 -2
- package/dist/stdlib/console.js +3 -3
- package/dist/stdlib/date.d.ts +2 -2
- package/dist/stdlib/date.js +21 -30
- package/dist/stdlib/headers.d.ts +2 -2
- package/dist/stdlib/headers.js +15 -33
- package/dist/stdlib/iterator.d.ts +2 -2
- package/dist/stdlib/iterator.js +10 -302
- package/dist/stdlib/json.d.ts +2 -2
- package/dist/stdlib/json.js +15 -31
- package/dist/stdlib/math.d.ts +2 -7
- package/dist/stdlib/math.js +6 -30
- package/dist/stdlib/number.d.ts +3 -3
- package/dist/stdlib/number.js +8 -8
- package/dist/stdlib/object.d.ts +4 -4
- package/dist/stdlib/object.js +12 -30
- package/dist/stdlib/regexp.d.ts +6 -5
- package/dist/stdlib/regexp.js +18 -13
- package/dist/stdlib/string.d.ts +2 -2
- package/dist/stdlib/string.js +53 -53
- package/dist/stdlib/url.d.ts +21 -9
- package/dist/stdlib/url.js +55 -55
- package/dist/stdlib/value.d.ts +3 -4
- package/dist/stdlib/value.js +5 -6
- package/dist/stdlib/web.d.ts +4 -4
- package/dist/stdlib/web.js +7 -7
- package/dist/tool-runtime.d.ts +14 -13
- package/dist/tool-runtime.js +245 -53
- package/dist/tool-schema.d.ts +5 -0
- package/dist/tool-schema.js +36 -16
- package/dist/tool.d.ts +24 -9
- package/dist/tool.js +15 -22
- package/dist/{vm/vm.d.ts → vm.d.ts} +3 -3
- package/dist/{vm/vm.js → vm.js} +1 -1
- package/package.json +3 -5
- package/dist/interpreter/callback.d.ts +0 -35
- package/dist/interpreter/callback.js +0 -98
- package/dist/interpreter/errors.js +0 -173
- package/dist/interpreter/execute.d.ts +0 -14
- package/dist/interpreter/execute.js +0 -207
- package/dist/interpreter/extensions.d.ts +0 -9
- package/dist/interpreter/extensions.js +0 -248
- package/dist/interpreter/generators.d.ts +0 -3
- package/dist/interpreter/generators.js +0 -168
- package/dist/interpreter/globals.js +0 -144
- package/dist/interpreter/interpreter.d.ts +0 -48
- package/dist/interpreter/interpreter.js +0 -2253
- package/dist/interpreter/intrinsics.d.ts +0 -15
- package/dist/interpreter/intrinsics.js +0 -105
- package/dist/interpreter/model.d.ts +0 -68
- package/dist/interpreter/model.js +0 -54
- package/dist/interpreter/native.d.ts +0 -17
- package/dist/interpreter/native.js +0 -35
- package/dist/interpreter/objects.d.ts +0 -301
- package/dist/interpreter/objects.js +0 -592
- package/dist/interpreter/promises.d.ts +0 -18
- package/dist/interpreter/promises.js +0 -292
- package/dist/interpreter/runner.d.ts +0 -178
- package/dist/interpreter/runner.js +0 -480
- package/dist/interpreter/scope.d.ts +0 -16
- package/dist/interpreter/scope.js +0 -79
- package/dist/suspend-error.d.ts +0 -24
- package/dist/suspend-error.js +0 -25
- package/dist/vm/data.d.ts +0 -7
- package/dist/vm/data.js +0 -13
- package/dist/vm/index.d.ts +0 -6
- package/dist/vm/index.js +0 -6
- package/dist/vm/runtime/errors.d.ts +0 -23
- package/dist/vm/runtime/globals.d.ts +0 -6
- package/dist/vm/runtime/limits.d.ts +0 -10
- package/dist/vm/runtime/limits.js +0 -19
- package/dist/vm/runtime/modules.d.ts +0 -4
- package/dist/vm/runtime/modules.js +0 -33
- package/dist/vm/runtime/references.d.ts +0 -8
- package/dist/vm/runtime/references.js +0 -51
- package/dist/vm/stdlib/array.d.ts +0 -16
- package/dist/vm/stdlib/array.js +0 -311
- package/dist/vm/stdlib/bytes.d.ts +0 -11
- package/dist/vm/stdlib/bytes.js +0 -222
- package/dist/vm/stdlib/collections.d.ts +0 -7
- package/dist/vm/stdlib/collections.js +0 -188
- package/dist/vm/stdlib/console.d.ts +0 -6
- package/dist/vm/stdlib/console.js +0 -93
- package/dist/vm/stdlib/date.d.ts +0 -2
- package/dist/vm/stdlib/date.js +0 -123
- package/dist/vm/stdlib/headers.d.ts +0 -2
- package/dist/vm/stdlib/headers.js +0 -92
- package/dist/vm/stdlib/iterator.d.ts +0 -2
- package/dist/vm/stdlib/iterator.js +0 -30
- package/dist/vm/stdlib/json.d.ts +0 -3
- package/dist/vm/stdlib/json.js +0 -42
- package/dist/vm/stdlib/math.d.ts +0 -3
- package/dist/vm/stdlib/math.js +0 -73
- package/dist/vm/stdlib/number.d.ts +0 -3
- package/dist/vm/stdlib/number.js +0 -72
- package/dist/vm/stdlib/object.d.ts +0 -6
- package/dist/vm/stdlib/object.js +0 -201
- package/dist/vm/stdlib/regexp.d.ts +0 -8
- package/dist/vm/stdlib/regexp.js +0 -119
- package/dist/vm/stdlib/string.d.ts +0 -2
- package/dist/vm/stdlib/string.js +0 -272
- package/dist/vm/stdlib/url.d.ts +0 -25
- package/dist/vm/stdlib/url.js +0 -255
- package/dist/vm/stdlib/value.d.ts +0 -6
- package/dist/vm/stdlib/value.js +0 -32
- package/dist/vm/stdlib/web.d.ts +0 -5
- package/dist/vm/stdlib/web.js +0 -97
- /package/dist/{vm/async.js → async.js} +0 -0
- /package/dist/{vm/code.d.ts → code.d.ts} +0 -0
- /package/dist/{vm/code.js → code.js} +0 -0
- /package/dist/{vm/compiler → compiler}/compile.d.ts +0 -0
- /package/dist/{vm/compiler → compiler}/compile.js +0 -0
- /package/dist/{vm/compiler → compiler}/scope.d.ts +0 -0
- /package/dist/{vm/compiler → compiler}/scope.js +0 -0
- /package/dist/{vm/generators.d.ts → generators.d.ts} +0 -0
- /package/dist/{vm/generators.js → generators.js} +0 -0
- /package/dist/{vm/host.js → host.js} +0 -0
- /package/dist/{vm/internal-prelude.d.ts → internal-prelude.d.ts} +0 -0
- /package/dist/{vm/internal-prelude.js → internal-prelude.js} +0 -0
- /package/dist/{vm/opcodes.js → opcodes.js} +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.js +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.json +0 -0
- /package/dist/{vm/prelude → prelude}/helpers.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/prelude.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/prelude.js +0 -0
- /package/dist/{vm/prelude → prelude}/source.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/source.js +0 -0
- /package/dist/{vm/runtime → runtime}/callback.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/callback.js +0 -0
- /package/dist/{interpreter → runtime}/errors.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/generators.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/generators.js +0 -0
- /package/dist/{interpreter → runtime}/globals.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/interpreter.js +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsic-names.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsic-names.js +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsics.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsics.js +0 -0
- /package/dist/{interpreter → runtime}/limits.d.ts +0 -0
- /package/dist/{interpreter → runtime}/limits.js +0 -0
- /package/dist/{vm/runtime → runtime}/model.js +0 -0
- /package/dist/{interpreter → runtime}/modules.d.ts +0 -0
- /package/dist/{interpreter → runtime}/modules.js +0 -0
- /package/dist/{vm/runtime → runtime}/native.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/native.js +0 -0
- /package/dist/{vm/runtime → runtime}/promises.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/promises.js +0 -0
- /package/dist/{interpreter → runtime}/references.d.ts +0 -0
- /package/dist/{interpreter → runtime}/references.js +0 -0
- /package/dist/{vm/runtime → runtime}/signals.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/signals.js +0 -0
- /package/dist/{vm/runtime → runtime}/source.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/source.js +0 -0
- /package/dist/{vm/runtime → runtime}/table.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/table.js +0 -0
- /package/dist/{vm/scheduler.js → scheduler.js} +0 -0
- /package/dist/{vm/snapshot.d.ts → snapshot.d.ts} +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ErrorObj, Obj, type Value } from "./objects.js";
|
|
2
|
-
export declare const errorTypes: readonly ["Error", "TypeError", "RangeError", "SyntaxError", "ReferenceError", "EvalError", "URIError", "AggregateError"];
|
|
3
|
-
export type ErrorType = (typeof errorTypes)[number];
|
|
4
|
-
export declare const isErrorType: (name: string) => name is ErrorType;
|
|
5
|
-
declare const builtins: readonly ["Object", "Function", "Array", "String", "Number", "Boolean", "Date", "RegExp", "Map", "Set", "WeakMap", "WeakSet", "URL", "URLSearchParams", "Headers", "Uint8Array", "TextEncoder", "TextDecoder", "Promise", "Iterator", "IteratorHelper", "AsyncIterator", "Generator", "AsyncGenerator"];
|
|
6
|
-
/**
|
|
7
|
-
* The built-in prototype objects of one runtime, allocated empty in dependency order. The globals populate them
|
|
8
|
-
* and attach their constructors when the runtime is built.
|
|
9
|
-
*/
|
|
10
|
-
export type Builtins = Readonly<Record<(typeof builtins)[number] | ErrorType, Obj>>;
|
|
11
|
-
export declare const createErrorValue: (prototype: Obj, message: string | undefined) => ErrorObj;
|
|
12
|
-
/** The prototype a primitive reads its methods from without being boxed; none for null, undefined, and symbols. */
|
|
13
|
-
export declare const primitivePrototype: (builtins: Builtins, value: Value) => Obj | undefined;
|
|
14
|
-
export declare const createBuiltins: () => Builtins;
|
|
15
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { define, hidden, Native, Arr, ErrorObj, Obj } from "./objects.js";
|
|
2
|
-
export const errorTypes = [
|
|
3
|
-
"Error",
|
|
4
|
-
"TypeError",
|
|
5
|
-
"RangeError",
|
|
6
|
-
"SyntaxError",
|
|
7
|
-
"ReferenceError",
|
|
8
|
-
"EvalError",
|
|
9
|
-
"URIError",
|
|
10
|
-
"AggregateError",
|
|
11
|
-
];
|
|
12
|
-
export const isErrorType = (name) => errorTypes.includes(name);
|
|
13
|
-
const builtins = [
|
|
14
|
-
"Object",
|
|
15
|
-
"Function",
|
|
16
|
-
"Array",
|
|
17
|
-
"String",
|
|
18
|
-
"Number",
|
|
19
|
-
"Boolean",
|
|
20
|
-
"Date",
|
|
21
|
-
"RegExp",
|
|
22
|
-
"Map",
|
|
23
|
-
"Set",
|
|
24
|
-
"WeakMap",
|
|
25
|
-
"WeakSet",
|
|
26
|
-
"URL",
|
|
27
|
-
"URLSearchParams",
|
|
28
|
-
"Headers",
|
|
29
|
-
"Uint8Array",
|
|
30
|
-
"TextEncoder",
|
|
31
|
-
"TextDecoder",
|
|
32
|
-
"Promise",
|
|
33
|
-
"Iterator",
|
|
34
|
-
"IteratorHelper",
|
|
35
|
-
"AsyncIterator",
|
|
36
|
-
"Generator",
|
|
37
|
-
"AsyncGenerator",
|
|
38
|
-
];
|
|
39
|
-
export const createErrorValue = (prototype, message) => {
|
|
40
|
-
const value = new ErrorObj(prototype);
|
|
41
|
-
if (message !== undefined)
|
|
42
|
-
define(value, "message", message, hidden);
|
|
43
|
-
return value;
|
|
44
|
-
};
|
|
45
|
-
/** The prototype a primitive reads its methods from without being boxed; none for null, undefined, and symbols. */
|
|
46
|
-
export const primitivePrototype = (builtins, value) => {
|
|
47
|
-
if (typeof value === "string")
|
|
48
|
-
return builtins.String;
|
|
49
|
-
if (typeof value === "number")
|
|
50
|
-
return builtins.Number;
|
|
51
|
-
if (typeof value === "boolean")
|
|
52
|
-
return builtins.Boolean;
|
|
53
|
-
return undefined;
|
|
54
|
-
};
|
|
55
|
-
export const createBuiltins = () => {
|
|
56
|
-
const object = new Obj(null);
|
|
57
|
-
// Function.prototype is itself callable and returns undefined.
|
|
58
|
-
const fn = new Native(object, { name: "", call: () => undefined });
|
|
59
|
-
const plain = () => new Obj(object);
|
|
60
|
-
const error = plain();
|
|
61
|
-
define(error, "name", "Error", hidden);
|
|
62
|
-
define(error, "message", "", hidden);
|
|
63
|
-
const derived = (type) => {
|
|
64
|
-
const proto = new Obj(error);
|
|
65
|
-
define(proto, "name", type, hidden);
|
|
66
|
-
define(proto, "message", "", hidden);
|
|
67
|
-
return proto;
|
|
68
|
-
};
|
|
69
|
-
const iterator = plain();
|
|
70
|
-
const asyncIterator = plain();
|
|
71
|
-
return {
|
|
72
|
-
Object: object,
|
|
73
|
-
Function: fn,
|
|
74
|
-
Array: new Arr(object),
|
|
75
|
-
String: plain(),
|
|
76
|
-
Number: plain(),
|
|
77
|
-
Boolean: plain(),
|
|
78
|
-
Date: plain(),
|
|
79
|
-
RegExp: plain(),
|
|
80
|
-
Map: plain(),
|
|
81
|
-
Set: plain(),
|
|
82
|
-
WeakMap: plain(),
|
|
83
|
-
WeakSet: plain(),
|
|
84
|
-
URL: plain(),
|
|
85
|
-
URLSearchParams: plain(),
|
|
86
|
-
Headers: plain(),
|
|
87
|
-
Uint8Array: plain(),
|
|
88
|
-
TextEncoder: plain(),
|
|
89
|
-
TextDecoder: plain(),
|
|
90
|
-
Promise: plain(),
|
|
91
|
-
Iterator: iterator,
|
|
92
|
-
IteratorHelper: new Obj(iterator),
|
|
93
|
-
AsyncIterator: asyncIterator,
|
|
94
|
-
Generator: new Obj(iterator),
|
|
95
|
-
AsyncGenerator: new Obj(asyncIterator),
|
|
96
|
-
Error: error,
|
|
97
|
-
TypeError: derived("TypeError"),
|
|
98
|
-
RangeError: derived("RangeError"),
|
|
99
|
-
SyntaxError: derived("SyntaxError"),
|
|
100
|
-
ReferenceError: derived("ReferenceError"),
|
|
101
|
-
EvalError: derived("EvalError"),
|
|
102
|
-
URIError: derived("URIError"),
|
|
103
|
-
AggregateError: derived("AggregateError"),
|
|
104
|
-
};
|
|
105
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Node } from "acorn";
|
|
2
|
-
import type { ErrorType } from "./intrinsics.js";
|
|
3
|
-
import type { DiagnosticKind } from "../codemode.js";
|
|
4
|
-
import type { ErrorObj, Value } from "./objects.js";
|
|
5
|
-
/** Any parsed node; the interpreter narrows on `type` and reads `loc` for diagnostics. */
|
|
6
|
-
export type AstNode = Node;
|
|
7
|
-
export type Binding = {
|
|
8
|
-
mutable: boolean;
|
|
9
|
-
value: Value;
|
|
10
|
-
initialized?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type StatementResult = {
|
|
13
|
-
kind: "none";
|
|
14
|
-
} | {
|
|
15
|
-
kind: "return";
|
|
16
|
-
value: Value;
|
|
17
|
-
} | {
|
|
18
|
-
kind: "break";
|
|
19
|
-
label?: string;
|
|
20
|
-
} | {
|
|
21
|
-
kind: "continue";
|
|
22
|
-
label?: string;
|
|
23
|
-
};
|
|
24
|
-
export type GeneratorRequestKind = "next" | "return" | "throw";
|
|
25
|
-
export declare const AsyncIteratorSymbol: unique symbol;
|
|
26
|
-
export declare const IteratorSymbol: unique symbol;
|
|
27
|
-
export declare const IteratorSymbols: readonly [typeof AsyncIteratorSymbol, typeof IteratorSymbol];
|
|
28
|
-
export declare class Throw {
|
|
29
|
-
readonly value: Value;
|
|
30
|
-
constructor(value: Value);
|
|
31
|
-
}
|
|
32
|
-
export declare class GeneratorReturn {
|
|
33
|
-
readonly value: Value;
|
|
34
|
-
constructor(value: Value);
|
|
35
|
-
}
|
|
36
|
-
export declare const OptionalShortCircuit: unique symbol;
|
|
37
|
-
/**
|
|
38
|
-
* A failure raised by the interpreter or a built-in. It travels as a defect and becomes one program Error object
|
|
39
|
-
* the first time a handler observes it, so every observer of the same failure sees the same value.
|
|
40
|
-
*/
|
|
41
|
-
export declare class PendingThrow {
|
|
42
|
-
/** The JS error class a program sees when it catches this failure. */
|
|
43
|
-
readonly type: ErrorType;
|
|
44
|
-
readonly message: string;
|
|
45
|
-
readonly kind: DiagnosticKind;
|
|
46
|
-
readonly suggestions?: ReadonlyArray<string> | undefined;
|
|
47
|
-
node?: AstNode;
|
|
48
|
-
value?: ErrorObj;
|
|
49
|
-
constructor(
|
|
50
|
-
/** The JS error class a program sees when it catches this failure. */
|
|
51
|
-
type: ErrorType, message: string, node?: AstNode, kind?: DiagnosticKind, suggestions?: ReadonlyArray<string> | undefined);
|
|
52
|
-
}
|
|
53
|
-
export declare const typeError: (message: string, node?: AstNode) => PendingThrow;
|
|
54
|
-
export declare const invalidData: (message: string, node?: AstNode) => PendingThrow;
|
|
55
|
-
export declare const rangeError: (message: string, node?: AstNode) => PendingThrow;
|
|
56
|
-
export declare const referenceError: (message: string, node?: AstNode) => PendingThrow;
|
|
57
|
-
export declare const syntaxError: (message: string, node?: AstNode) => PendingThrow;
|
|
58
|
-
export declare const uriError: (message: string, node?: AstNode) => PendingThrow;
|
|
59
|
-
export declare const supportedSyntaxMessage = "This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, getters/setters, BigInt, and custom Symbols. Use plain functions and data objects instead.";
|
|
60
|
-
export declare const unsupportedSyntax: (kind: string, node: AstNode) => PendingThrow;
|
|
61
|
-
export declare const sourceLocation: (node: AstNode) => {
|
|
62
|
-
readonly line: number;
|
|
63
|
-
readonly column: number;
|
|
64
|
-
};
|
|
65
|
-
export declare const formatLocation: (location?: {
|
|
66
|
-
readonly line: number;
|
|
67
|
-
readonly column: number;
|
|
68
|
-
}) => string;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export const AsyncIteratorSymbol = Symbol("codemode.async-iterator");
|
|
2
|
-
export const IteratorSymbol = Symbol("codemode.iterator");
|
|
3
|
-
export const IteratorSymbols = [AsyncIteratorSymbol, IteratorSymbol];
|
|
4
|
-
export class Throw {
|
|
5
|
-
value;
|
|
6
|
-
constructor(value) {
|
|
7
|
-
this.value = value;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export class GeneratorReturn {
|
|
11
|
-
value;
|
|
12
|
-
constructor(value) {
|
|
13
|
-
this.value = value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export const OptionalShortCircuit = Symbol("codemode.optional-short-circuit");
|
|
17
|
-
/**
|
|
18
|
-
* A failure raised by the interpreter or a built-in. It travels as a defect and becomes one program Error object
|
|
19
|
-
* the first time a handler observes it, so every observer of the same failure sees the same value.
|
|
20
|
-
*/
|
|
21
|
-
export class PendingThrow {
|
|
22
|
-
type;
|
|
23
|
-
message;
|
|
24
|
-
kind;
|
|
25
|
-
suggestions;
|
|
26
|
-
node;
|
|
27
|
-
value;
|
|
28
|
-
constructor(
|
|
29
|
-
/** The JS error class a program sees when it catches this failure. */
|
|
30
|
-
type, message, node, kind = "ExecutionFailure", suggestions) {
|
|
31
|
-
this.type = type;
|
|
32
|
-
this.message = message;
|
|
33
|
-
this.kind = kind;
|
|
34
|
-
this.suggestions = suggestions;
|
|
35
|
-
if (node)
|
|
36
|
-
this.node = node;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const failure = (type, kind) => (message, node) => new PendingThrow(type, message, node, kind);
|
|
40
|
-
export const typeError = failure("TypeError");
|
|
41
|
-
export const invalidData = failure("TypeError", "InvalidDataValue");
|
|
42
|
-
export const rangeError = failure("RangeError");
|
|
43
|
-
export const referenceError = failure("ReferenceError");
|
|
44
|
-
export const syntaxError = failure("SyntaxError");
|
|
45
|
-
export const uriError = failure("URIError");
|
|
46
|
-
// Orient the agent rather than enumerate JavaScript; interpreter-support.md is the full matrix.
|
|
47
|
-
export const supportedSyntaxMessage = "This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, getters/setters, BigInt, and custom Symbols. Use plain functions and data objects instead.";
|
|
48
|
-
export const unsupportedSyntax = (kind, node) => new PendingThrow("SyntaxError", `Syntax '${kind}' is not supported. ${supportedSyntaxMessage}`, node, "UnsupportedSyntax", [supportedSyntaxMessage]);
|
|
49
|
-
// Acorn lines are 1-based and its columns are 0-based. Diagnostics use 1-based columns of the submitted source.
|
|
50
|
-
export const sourceLocation = (node) => ({
|
|
51
|
-
line: node.loc?.start.line ?? 1,
|
|
52
|
-
column: (node.loc?.start.column ?? 0) + 1,
|
|
53
|
-
});
|
|
54
|
-
export const formatLocation = (location) => location ? ` (line ${location.line}, col ${location.column})` : "";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Builtins } from "./intrinsics.js";
|
|
2
|
-
import { type Callable, Native, type NativeCall, type NativeOptions, Obj, type Value } from "./objects.js";
|
|
3
|
-
/** A native function body: a value, a thrown `PendingThrow`, or interpreter work producing a value. */
|
|
4
|
-
export type Impl = NativeCall;
|
|
5
|
-
export declare const native: (builtins: Builtins, options: NativeOptions) => Native;
|
|
6
|
-
export declare const fn: (builtins: Builtins, name: string, length: number, impl: Impl) => Native;
|
|
7
|
-
export type Method = readonly [name: string, length: number, impl: Impl];
|
|
8
|
-
export declare const methods: (builtins: Builtins, target: Obj, table: ReadonlyArray<Method>) => void;
|
|
9
|
-
export declare const constants: (target: Obj, table: Record<string, Value>) => void;
|
|
10
|
-
/** A constructor wired to its prototype: `C.prototype === proto` and `proto.constructor === C`. */
|
|
11
|
-
export declare const constructor: (builtins: Builtins, proto: Obj, options: NativeOptions) => Native;
|
|
12
|
-
/** The `call` of a constructor that JS requires to be invoked with `new`. */
|
|
13
|
-
export declare const requiresNew: (name: string) => () => never;
|
|
14
|
-
/** The instance prototype for `new` via `newTarget.prototype`, falling back to the built-in's own. */
|
|
15
|
-
export declare const prototypeFrom: (newTarget: Callable, fallback: Obj) => Obj;
|
|
16
|
-
/** Narrows a method receiver to the built-in it belongs to, or throws the TypeError JS would. */
|
|
17
|
-
export declare const receiver: <T extends Obj>(cls: abstract new (...args: never) => T, thisValue: Value, method: string) => T;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { typeError } from "./model.js";
|
|
2
|
-
import { define, frozen, hidden, Native, Obj, } from "./objects.js";
|
|
3
|
-
import { describeValue } from "./references.js";
|
|
4
|
-
export const native = (builtins, options) => new Native(builtins.Function, options);
|
|
5
|
-
export const fn = (builtins, name, length, impl) => native(builtins, { name, length, call: impl });
|
|
6
|
-
export const methods = (builtins, target, table) => {
|
|
7
|
-
for (const [name, length, impl] of table)
|
|
8
|
-
define(target, name, fn(builtins, name, length, impl), hidden);
|
|
9
|
-
};
|
|
10
|
-
export const constants = (target, table) => {
|
|
11
|
-
for (const [name, value] of Object.entries(table))
|
|
12
|
-
define(target, name, value, frozen);
|
|
13
|
-
};
|
|
14
|
-
/** A constructor wired to its prototype: `C.prototype === proto` and `proto.constructor === C`. */
|
|
15
|
-
export const constructor = (builtins, proto, options) => {
|
|
16
|
-
const ctor = native(builtins, options);
|
|
17
|
-
define(ctor, "prototype", proto, frozen);
|
|
18
|
-
define(proto, "constructor", ctor, hidden);
|
|
19
|
-
return ctor;
|
|
20
|
-
};
|
|
21
|
-
/** The `call` of a constructor that JS requires to be invoked with `new`. */
|
|
22
|
-
export const requiresNew = (name) => () => {
|
|
23
|
-
throw typeError(`Constructor ${name} requires 'new'.`);
|
|
24
|
-
};
|
|
25
|
-
/** The instance prototype for `new` via `newTarget.prototype`, falling back to the built-in's own. */
|
|
26
|
-
export const prototypeFrom = (newTarget, fallback) => {
|
|
27
|
-
const proto = newTarget.props.get("prototype");
|
|
28
|
-
return proto !== undefined && "value" in proto && proto.value instanceof Obj ? proto.value : fallback;
|
|
29
|
-
};
|
|
30
|
-
/** Narrows a method receiver to the built-in it belongs to, or throws the TypeError JS would. */
|
|
31
|
-
export const receiver = (cls, thisValue, method) => {
|
|
32
|
-
if (thisValue instanceof cls)
|
|
33
|
-
return thisValue;
|
|
34
|
-
throw typeError(`${method} called on incompatible receiver ${describeValue(thisValue)}.`);
|
|
35
|
-
};
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import type { BlockStatement, Expression, Pattern } from "acorn";
|
|
2
|
-
import { ToolReference } from "../tool-runtime.js";
|
|
3
|
-
import type { Builtins } from "./intrinsics.js";
|
|
4
|
-
import { type AstNode, type Binding } from "./model.js";
|
|
5
|
-
import type { Entry, Eval, GeneratorRequest, Reaction, Resolving } from "./runner.js";
|
|
6
|
-
/** Property attributes, as in a JS property descriptor. */
|
|
7
|
-
export type Attributes = {
|
|
8
|
-
readonly writable: boolean;
|
|
9
|
-
readonly enumerable: boolean;
|
|
10
|
-
readonly configurable: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type Getter = (receiver: Value) => Value;
|
|
13
|
-
export type Setter = (receiver: Value, value: Value) => void;
|
|
14
|
-
/** One own property: a data slot or a native accessor pair. */
|
|
15
|
-
export type Slot = {
|
|
16
|
-
value: Value;
|
|
17
|
-
writable: boolean;
|
|
18
|
-
enumerable: boolean;
|
|
19
|
-
configurable: boolean;
|
|
20
|
-
} | {
|
|
21
|
-
get: Getter | undefined;
|
|
22
|
-
set: Setter | undefined;
|
|
23
|
-
enumerable: boolean;
|
|
24
|
-
configurable: boolean;
|
|
25
|
-
};
|
|
26
|
-
/** Ordinary assignment: writable, enumerable, configurable. */
|
|
27
|
-
export declare const data: Attributes;
|
|
28
|
-
/** Built-in methods and `constructor`: writable and configurable but hidden from enumeration. */
|
|
29
|
-
export declare const hidden: Attributes;
|
|
30
|
-
/** Function `name` and `length`: read-only but deletable. */
|
|
31
|
-
export declare const readonly: Attributes;
|
|
32
|
-
/** Constants such as `Math.PI` and a constructor's `prototype`. */
|
|
33
|
-
export declare const frozen: Attributes;
|
|
34
|
-
/**
|
|
35
|
-
* An object owned by the program: own properties plus a prototype link. Subclasses answer, in one place, how a
|
|
36
|
-
* built-in kind of object prints, coerces, iterates, and crosses to the host.
|
|
37
|
-
*/
|
|
38
|
-
export declare class Obj {
|
|
39
|
-
proto: Obj | null;
|
|
40
|
-
readonly props: Map<string | symbol, Slot>;
|
|
41
|
-
/** [[Extensible]]: cleared by `Object.preventExtensions`, `seal`, and `freeze`. */
|
|
42
|
-
extensible: boolean;
|
|
43
|
-
constructor(proto: Obj | null);
|
|
44
|
-
/** The class name `Object.prototype.toString` reports: `[object Map]`. */
|
|
45
|
-
readonly tag: string;
|
|
46
|
-
/** How diagnostics refer to a value of this kind. */
|
|
47
|
-
get describe(): string;
|
|
48
|
-
/** ToString without consulting program-defined methods. */
|
|
49
|
-
toString(): string;
|
|
50
|
-
/** ToPrimitive without consulting program-defined methods: only a Date answers a number hint differently. */
|
|
51
|
-
toPrimitive(hint: "default" | "number" | "string"): string | number;
|
|
52
|
-
/** ToNumber without consulting program-defined methods. */
|
|
53
|
-
toNumber(): number;
|
|
54
|
-
/** How `console.log` shows the value; `item` formats a child with cycle and depth tracking. */
|
|
55
|
-
inspect(item: (value: Value) => string): string;
|
|
56
|
-
/** A copy the host can hold; `item` converts a child. A `__proto__` key never reaches host code. */
|
|
57
|
-
toHost(item: (value: Value) => unknown): unknown;
|
|
58
|
-
/** The built-in iteration `for...of` and spread use, when this kind of object has one. */
|
|
59
|
-
iterator(builtins: Builtins): Iterator<Value, undefined> | undefined;
|
|
60
|
-
}
|
|
61
|
-
export declare class Arr extends Obj {
|
|
62
|
-
readonly items: Array<Value>;
|
|
63
|
-
readonly tag = "Array";
|
|
64
|
-
/** The attributes every live element shares; `seal` and `freeze` narrow them since elements have no slots. */
|
|
65
|
-
elements: Attributes;
|
|
66
|
-
constructor(proto: Obj, items?: Array<Value>);
|
|
67
|
-
get describe(): string;
|
|
68
|
-
toString(): string;
|
|
69
|
-
inspect(item: (value: Value) => string): string;
|
|
70
|
-
toHost(item: (value: Value) => unknown): unknown[];
|
|
71
|
-
iterator(): ArrayIterator<Value>;
|
|
72
|
-
}
|
|
73
|
-
/** An object with the [[ErrorData]] slot: what `Error.prototype.toString` and the host boundary recognize as an error. */
|
|
74
|
-
export declare class ErrorObj extends Obj {
|
|
75
|
-
readonly tag = "Error";
|
|
76
|
-
/** The failure this error materialized from, so rethrowing it keeps the diagnostic kind and location. */
|
|
77
|
-
host?: unknown;
|
|
78
|
-
/** Error.prototype.toString: "name: message", or just one when the other is empty. */
|
|
79
|
-
toString(): string;
|
|
80
|
-
inspect(): string;
|
|
81
|
-
}
|
|
82
|
-
/** Interpreter machinery a program can hold but never inspect, serialize, or hand to the host. */
|
|
83
|
-
export declare abstract class Opaque extends Obj {
|
|
84
|
-
inspect(): string;
|
|
85
|
-
}
|
|
86
|
-
export declare abstract class Callable extends Opaque {
|
|
87
|
-
readonly length: number;
|
|
88
|
-
readonly tag = "Function";
|
|
89
|
-
constructor(proto: Obj, name: string, length: number);
|
|
90
|
-
get describe(): string;
|
|
91
|
-
}
|
|
92
|
-
export declare class Fn extends Callable {
|
|
93
|
-
readonly parameters: ReadonlyArray<Pattern>;
|
|
94
|
-
readonly body: BlockStatement | Expression;
|
|
95
|
-
readonly capturedScopes: Array<Map<string, Binding>>;
|
|
96
|
-
readonly async: boolean;
|
|
97
|
-
readonly generator: boolean;
|
|
98
|
-
/** Arrows have no `this` or `arguments` of their own; they read the enclosing function's. */
|
|
99
|
-
readonly arrow: boolean;
|
|
100
|
-
constructor(proto: Obj, name: string, parameters: ReadonlyArray<Pattern>, body: BlockStatement | Expression, capturedScopes: Array<Map<string, Binding>>, async: boolean, generator: boolean,
|
|
101
|
-
/** Arrows have no `this` or `arguments` of their own; they read the enclosing function's. */
|
|
102
|
-
arrow: boolean);
|
|
103
|
-
}
|
|
104
|
-
/** The strict `arguments` object: an ordinary object with indexed own properties and a hidden `length`. */
|
|
105
|
-
export declare class Arguments extends Obj {
|
|
106
|
-
readonly tag = "Arguments";
|
|
107
|
-
constructor(proto: Obj, args: Array<Value>);
|
|
108
|
-
iterator(): ArrayIterator<Value>;
|
|
109
|
-
}
|
|
110
|
-
/** A native function body: a value, or interpreter work for bodies that call program code or the host. */
|
|
111
|
-
export type NativeResult = Value | Eval<Value>;
|
|
112
|
-
/** `site` is the call running the built-in, where a failure it reports later (a rejection) is located. */
|
|
113
|
-
export type NativeCall = (thisValue: Value, args: Array<Value>, site: AstNode | undefined) => NativeResult;
|
|
114
|
-
export type NativeConstruct = (args: Array<Value>, newTarget: Callable, site: AstNode | undefined) => NativeResult;
|
|
115
|
-
export type NativeOptions = {
|
|
116
|
-
readonly name: string;
|
|
117
|
-
readonly length?: number;
|
|
118
|
-
readonly call: NativeCall;
|
|
119
|
-
/** `new name(...)`; without it the function is not a constructor. */
|
|
120
|
-
readonly construct?: NativeConstruct;
|
|
121
|
-
/** Whether callback sites (array methods, replacers, promise reactions) admit this function. Defaults to true. */
|
|
122
|
-
readonly callback?: boolean;
|
|
123
|
-
};
|
|
124
|
-
export declare class Native extends Callable {
|
|
125
|
-
readonly call: NativeCall;
|
|
126
|
-
readonly construct: NativeConstruct | undefined;
|
|
127
|
-
readonly callback: boolean;
|
|
128
|
-
constructor(proto: Obj, options: NativeOptions);
|
|
129
|
-
}
|
|
130
|
-
export declare class PromiseObj extends Opaque {
|
|
131
|
-
/** Creation order, for reporting unhandled rejections in the order their promises were made. */
|
|
132
|
-
readonly id: number;
|
|
133
|
-
readonly tag = "Promise";
|
|
134
|
-
state: "pending" | "fulfilled" | "rejected";
|
|
135
|
-
/** The value, or the failure as thrown; a handler receives it materialized. */
|
|
136
|
-
result: unknown;
|
|
137
|
-
reactions: Array<Reaction>;
|
|
138
|
-
/** [[PromiseIsHandled]]: a reaction was attached, so a rejection is not reported as unhandled. */
|
|
139
|
-
handled: boolean;
|
|
140
|
-
constructor(proto: Obj,
|
|
141
|
-
/** Creation order, for reporting unhandled rejections in the order their promises were made. */
|
|
142
|
-
id: number);
|
|
143
|
-
get describe(): string;
|
|
144
|
-
inspect(): string;
|
|
145
|
-
}
|
|
146
|
-
export type GeneratorState = "suspendedStart" | "suspendedYield" | "executing" | "awaiting-return" | "draining" | "completed";
|
|
147
|
-
export declare class GeneratorObj extends Opaque {
|
|
148
|
-
readonly asynchronous: boolean;
|
|
149
|
-
/** The body, started by the first `next()`. */
|
|
150
|
-
readonly body: Eval<Value>;
|
|
151
|
-
readonly tag = "Generator";
|
|
152
|
-
state: GeneratorState;
|
|
153
|
-
/** The suspended body's activations, kept while it waits for the next request. */
|
|
154
|
-
entries: Array<Entry> | undefined;
|
|
155
|
-
/** An async generator's requests, oldest first, each with the functions that settle its promise. */
|
|
156
|
-
readonly queue: Array<{
|
|
157
|
-
readonly request: GeneratorRequest;
|
|
158
|
-
readonly resolving: Resolving;
|
|
159
|
-
}>;
|
|
160
|
-
constructor(proto: Obj, asynchronous: boolean,
|
|
161
|
-
/** The body, started by the first `next()`. */
|
|
162
|
-
body: Eval<Value>);
|
|
163
|
-
get describe(): string;
|
|
164
|
-
}
|
|
165
|
-
/** One pull from an iterator, as `for...of` sees it. */
|
|
166
|
-
export type Step = {
|
|
167
|
-
readonly done: boolean;
|
|
168
|
-
readonly value: Value;
|
|
169
|
-
};
|
|
170
|
-
/** How the interpreter drives any iterator: pull the next step, or close it early. */
|
|
171
|
-
export type Cursor = {
|
|
172
|
-
readonly next: () => Eval<Step>;
|
|
173
|
-
readonly close: () => Eval<void>;
|
|
174
|
-
};
|
|
175
|
-
/** A cursor over a host iterator; there is nothing to close. */
|
|
176
|
-
export declare const hostCursor: (iterator: Iterator<Value, undefined>) => Cursor;
|
|
177
|
-
/** A built-in iterator: a live cursor over a host collection or an iterator helper, yielding program values. */
|
|
178
|
-
export declare class IteratorObj extends Opaque {
|
|
179
|
-
readonly cursor: Cursor;
|
|
180
|
-
readonly tag = "Iterator";
|
|
181
|
-
constructor(proto: Obj, cursor: Cursor);
|
|
182
|
-
get describe(): string;
|
|
183
|
-
}
|
|
184
|
-
/** A built-in iterator over a host iterator, e.g. `array.values()`. */
|
|
185
|
-
export declare const hostIterator: (builtins: Builtins, iterator: Iterator<Value, undefined>) => IteratorObj;
|
|
186
|
-
/** A built-in object around a host value: data-like, so it prints as itself and crosses to extensions as a copy. */
|
|
187
|
-
export declare abstract class Wrapper extends Obj {
|
|
188
|
-
inspect(item: (value: Value) => string): string;
|
|
189
|
-
}
|
|
190
|
-
export declare class DateObj extends Wrapper {
|
|
191
|
-
time: number;
|
|
192
|
-
readonly tag = "Date";
|
|
193
|
-
constructor(proto: Obj, time: number);
|
|
194
|
-
toString(): string;
|
|
195
|
-
toPrimitive(hint: "default" | "number" | "string"): string | number;
|
|
196
|
-
toHost(): Date;
|
|
197
|
-
}
|
|
198
|
-
export declare class RegExpObj extends Wrapper {
|
|
199
|
-
readonly tag = "RegExp";
|
|
200
|
-
readonly regex: RegExp;
|
|
201
|
-
constructor(proto: Obj, pattern: string, flags: string);
|
|
202
|
-
toString(): string;
|
|
203
|
-
toHost(): RegExp;
|
|
204
|
-
}
|
|
205
|
-
export declare class MapObj extends Wrapper {
|
|
206
|
-
readonly tag = "Map";
|
|
207
|
-
readonly map: Map<Value, Value>;
|
|
208
|
-
inspect(item: (value: Value) => string): string;
|
|
209
|
-
toHost(item: (value: Value) => unknown): Map<unknown, unknown>;
|
|
210
|
-
iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
|
|
211
|
-
}
|
|
212
|
-
export declare class SetObj extends Wrapper {
|
|
213
|
-
readonly tag = "Set";
|
|
214
|
-
readonly set: Set<Value>;
|
|
215
|
-
inspect(item: (value: Value) => string): string;
|
|
216
|
-
toHost(item: (value: Value) => unknown): Set<unknown>;
|
|
217
|
-
iterator(): SetIterator<Value>;
|
|
218
|
-
}
|
|
219
|
-
/** Keys are program objects, so a host WeakMap gives the same lifetime rule as JavaScript without any bookkeeping. */
|
|
220
|
-
export declare class WeakMapObj extends Wrapper {
|
|
221
|
-
readonly tag = "WeakMap";
|
|
222
|
-
readonly map: WeakMap<Obj, Value>;
|
|
223
|
-
inspect(): string;
|
|
224
|
-
}
|
|
225
|
-
export declare class WeakSetObj extends Wrapper {
|
|
226
|
-
readonly tag = "WeakSet";
|
|
227
|
-
readonly set: WeakSet<Obj>;
|
|
228
|
-
inspect(): string;
|
|
229
|
-
}
|
|
230
|
-
export declare class URLSearchParamsObj extends Wrapper {
|
|
231
|
-
readonly params: URLSearchParams;
|
|
232
|
-
readonly tag = "URLSearchParams";
|
|
233
|
-
constructor(proto: Obj, params: URLSearchParams);
|
|
234
|
-
toString(): string;
|
|
235
|
-
toHost(): URLSearchParams;
|
|
236
|
-
iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
|
|
237
|
-
}
|
|
238
|
-
export declare class HeadersObj extends Wrapper {
|
|
239
|
-
readonly headers: Headers;
|
|
240
|
-
readonly tag = "Headers";
|
|
241
|
-
constructor(proto: Obj, headers: Headers);
|
|
242
|
-
inspect(): string;
|
|
243
|
-
toHost(): Headers;
|
|
244
|
-
iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
|
|
245
|
-
}
|
|
246
|
-
export declare class URLObj extends Wrapper {
|
|
247
|
-
readonly url: URL;
|
|
248
|
-
readonly tag = "URL";
|
|
249
|
-
readonly searchParams: URLSearchParamsObj;
|
|
250
|
-
constructor(proto: Obj, searchParamsProto: Obj, url: URL);
|
|
251
|
-
toString(): string;
|
|
252
|
-
toHost(): URL;
|
|
253
|
-
}
|
|
254
|
-
/** A `Uint8Array`: the host array does the byte clamping and ignores out-of-range writes, as JS does. */
|
|
255
|
-
export declare class Bytes extends Wrapper {
|
|
256
|
-
readonly bytes: Uint8Array;
|
|
257
|
-
readonly tag = "Uint8Array";
|
|
258
|
-
constructor(proto: Obj, bytes: Uint8Array);
|
|
259
|
-
toString(): string;
|
|
260
|
-
inspect(): string;
|
|
261
|
-
toHost(): Uint8Array<ArrayBuffer>;
|
|
262
|
-
iterator(): ArrayIterator<number>;
|
|
263
|
-
}
|
|
264
|
-
/** Every value a program can hold. Host values never appear here; they are copied in at the boundaries. */
|
|
265
|
-
export type Value = string | number | boolean | null | undefined | symbol | Obj | ToolReference;
|
|
266
|
-
/** ToString without consulting program-defined methods. */
|
|
267
|
-
export declare const coerceToString: (value: Value) => string;
|
|
268
|
-
/** ToNumber without consulting program-defined methods; tool references are not numbers. */
|
|
269
|
-
export declare const coerceToNumber: (value: Value) => number;
|
|
270
|
-
/** ToIntegerOrInfinity: NaN is 0, fractions truncate. */
|
|
271
|
-
export declare const coerceToInteger: (value: Value) => number;
|
|
272
|
-
/** Values that cannot cross the data boundary: opaque machinery and host-backed wrappers. */
|
|
273
|
-
export declare const isRuntimeReference: (value: Value) => boolean;
|
|
274
|
-
export declare const parseArrayIndex: (key: string | number) => number | undefined;
|
|
275
|
-
/** The own property under `key`, including an array's live indexes and `length`. */
|
|
276
|
-
export declare const own: (target: Obj, key: PropertyKey) => Slot | undefined;
|
|
277
|
-
export declare const hasOwn: (target: Obj, key: PropertyKey) => boolean;
|
|
278
|
-
export declare const getOwn: (target: Obj, key: PropertyKey) => Value;
|
|
279
|
-
/** [[Get]]: walks the prototype chain; accessors see `receiver`, which is the primitive for wrapper prototypes. */
|
|
280
|
-
export declare const get: (target: Obj, key: PropertyKey, receiver?: Value) => Value;
|
|
281
|
-
export declare const has: (target: Obj, key: PropertyKey) => boolean;
|
|
282
|
-
export declare const hasPrototype: (value: Value, proto: Obj) => boolean;
|
|
283
|
-
/** [[Set]]: an inherited setter or read-only property decides before an own data property is created. */
|
|
284
|
-
export declare const set: (target: Obj, key: PropertyKey, value: Value) => boolean;
|
|
285
|
-
/** Creating a property on a non-extensible object is the one [[Set]] failure with its own message. */
|
|
286
|
-
export declare const rejectAddition: (target: Obj, key: string | symbol | number) => void;
|
|
287
|
-
/** [[DefineOwnProperty]] for a data property, ignoring the chain. */
|
|
288
|
-
export declare const define: (target: Obj, key: PropertyKey, value: Value, attrs?: Attributes) => void;
|
|
289
|
-
export declare const defineAccessor: (target: Obj, key: PropertyKey, get: Getter | undefined, set?: Setter) => void;
|
|
290
|
-
export declare const remove: (target: Obj, key: PropertyKey) => boolean;
|
|
291
|
-
export declare const ownKeys: (target: Obj) => Array<string | symbol>;
|
|
292
|
-
/** Own enumerable keys, including the iterator symbols; what spread and `Object.assign` copy. */
|
|
293
|
-
export declare const enumerableKeys: (target: Obj) => Array<string | symbol>;
|
|
294
|
-
/** Own enumerable string keys: `Object.keys`. */
|
|
295
|
-
export declare const keys: (target: Obj) => Array<string>;
|
|
296
|
-
/** Own enumerable string entries: `Object.entries` and serialization. */
|
|
297
|
-
export declare const entries: (target: Obj) => Array<[string, Value]>;
|
|
298
|
-
/** An iterator result `{ value, done }`, built directly since every iteration step makes one. */
|
|
299
|
-
export declare const iteratorResult: (proto: Obj, value: Value, done: boolean) => Obj;
|
|
300
|
-
export declare const record: (proto: Obj, fields: Record<string, Value>) => Obj;
|
|
301
|
-
export declare const assign: (target: Obj, source: Obj, skip?: ReadonlySet<PropertyKey>) => void;
|