@cuxt/sandboxjs 0.1.0 → 0.1.3
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 -21
- package/README.md +198 -185
- package/{build → dist/cjs}/Sandbox.d.ts +15 -6
- package/dist/cjs/Sandbox.js +126 -0
- package/dist/{SandboxExec.d.ts → cjs/SandboxExec.d.ts} +8 -17
- package/dist/cjs/SandboxExec.js +227 -0
- package/{build/eval.d.ts → dist/cjs/eval/index.d.ts} +10 -2
- package/dist/cjs/eval/index.js +233 -0
- package/dist/cjs/executor/executorUtils.d.ts +161 -0
- package/dist/cjs/executor/executorUtils.js +930 -0
- package/dist/cjs/executor/index.d.ts +1 -0
- package/dist/cjs/executor/index.js +2 -0
- package/dist/cjs/executor/ops/assignment.d.ts +1 -0
- package/dist/cjs/executor/ops/assignment.js +88 -0
- package/dist/cjs/executor/ops/call.d.ts +1 -0
- package/dist/cjs/executor/ops/call.js +160 -0
- package/dist/cjs/executor/ops/comparison.d.ts +1 -0
- package/dist/cjs/executor/ops/comparison.js +36 -0
- package/dist/cjs/executor/ops/control.d.ts +1 -0
- package/dist/cjs/executor/ops/control.js +203 -0
- package/dist/cjs/executor/ops/functions.d.ts +1 -0
- package/dist/cjs/executor/ops/functions.js +55 -0
- package/dist/cjs/executor/ops/index.d.ts +0 -0
- package/dist/cjs/executor/ops/index.js +11 -0
- package/dist/cjs/executor/ops/literals.d.ts +1 -0
- package/dist/cjs/executor/ops/literals.js +45 -0
- package/dist/cjs/executor/ops/misc.d.ts +1 -0
- package/dist/cjs/executor/ops/misc.js +25 -0
- package/dist/cjs/executor/ops/object.d.ts +1 -0
- package/dist/cjs/executor/ops/object.js +51 -0
- package/dist/cjs/executor/ops/prop.d.ts +1 -0
- package/dist/cjs/executor/ops/prop.js +70 -0
- package/dist/cjs/executor/ops/unary.d.ts +1 -0
- package/dist/cjs/executor/ops/unary.js +48 -0
- package/dist/cjs/executor/ops/variables.d.ts +1 -0
- package/dist/cjs/executor/ops/variables.js +16 -0
- package/dist/cjs/executor/opsRegistry.d.ts +33 -0
- package/dist/cjs/executor/opsRegistry.js +8 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/parser/index.d.ts +3 -0
- package/dist/cjs/parser/index.js +1 -0
- package/dist/{parser.d.ts → cjs/parser/lisp.d.ts} +29 -42
- package/dist/cjs/parser/lispTypes/conditionals.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/conditionals.js +135 -0
- package/dist/cjs/parser/lispTypes/control.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/control.js +204 -0
- package/dist/cjs/parser/lispTypes/declarations.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/declarations.js +99 -0
- package/dist/cjs/parser/lispTypes/index.d.ts +3 -0
- package/dist/cjs/parser/lispTypes/index.js +17 -0
- package/dist/cjs/parser/lispTypes/operators.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/operators.js +252 -0
- package/dist/cjs/parser/lispTypes/shared.d.ts +38 -0
- package/dist/cjs/parser/lispTypes/structures.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/structures.js +188 -0
- package/dist/cjs/parser/lispTypes/values.d.ts +2 -0
- package/dist/cjs/parser/lispTypes/values.js +89 -0
- package/dist/cjs/parser/parserUtils.d.ts +34 -0
- package/dist/cjs/parser/parserUtils.js +968 -0
- package/dist/cjs/utils/CodeString.d.ts +16 -0
- package/dist/cjs/utils/CodeString.js +64 -0
- package/dist/cjs/utils/ExecContext.d.ts +34 -0
- package/dist/cjs/utils/ExecContext.js +171 -0
- package/dist/cjs/utils/Prop.d.ts +16 -0
- package/dist/cjs/utils/Prop.js +81 -0
- package/dist/cjs/utils/Scope.d.ts +47 -0
- package/dist/cjs/utils/Scope.js +127 -0
- package/dist/cjs/utils/errors.d.ts +10 -0
- package/dist/cjs/utils/errors.js +12 -0
- package/dist/cjs/utils/functionReplacements.d.ts +11 -0
- package/dist/cjs/utils/functionReplacements.js +362 -0
- package/dist/cjs/utils/index.d.ts +7 -0
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/types.d.ts +221 -0
- package/dist/cjs/utils/types.js +164 -0
- package/dist/cjs/utils/unraw.js +145 -0
- package/dist/{node → esm}/Sandbox.d.ts +15 -6
- package/dist/esm/Sandbox.js +115 -0
- package/dist/esm/Sandbox.js.map +1 -0
- package/{build → dist/esm}/SandboxExec.d.ts +8 -17
- package/dist/esm/SandboxExec.js +224 -0
- package/dist/esm/SandboxExec.js.map +1 -0
- package/dist/{eval.d.ts → esm/eval/index.d.ts} +10 -2
- package/dist/esm/eval/index.js +235 -0
- package/dist/esm/eval/index.js.map +1 -0
- package/dist/esm/executor/executorUtils.d.ts +161 -0
- package/dist/esm/executor/executorUtils.js +898 -0
- package/dist/esm/executor/executorUtils.js.map +1 -0
- package/dist/esm/executor/index.d.ts +1 -0
- package/dist/esm/executor/index.js +2 -0
- package/dist/esm/executor/ops/assignment.d.ts +1 -0
- package/dist/esm/executor/ops/assignment.js +90 -0
- package/dist/esm/executor/ops/assignment.js.map +1 -0
- package/dist/esm/executor/ops/call.d.ts +1 -0
- package/dist/esm/executor/ops/call.js +162 -0
- package/dist/esm/executor/ops/call.js.map +1 -0
- package/dist/esm/executor/ops/comparison.d.ts +1 -0
- package/dist/esm/executor/ops/comparison.js +38 -0
- package/dist/esm/executor/ops/comparison.js.map +1 -0
- package/dist/esm/executor/ops/control.d.ts +1 -0
- package/dist/esm/executor/ops/control.js +205 -0
- package/dist/esm/executor/ops/control.js.map +1 -0
- package/dist/esm/executor/ops/functions.d.ts +1 -0
- package/dist/esm/executor/ops/functions.js +57 -0
- package/dist/esm/executor/ops/functions.js.map +1 -0
- package/dist/esm/executor/ops/index.d.ts +0 -0
- package/dist/esm/executor/ops/index.js +11 -0
- package/dist/esm/executor/ops/literals.d.ts +1 -0
- package/dist/esm/executor/ops/literals.js +47 -0
- package/dist/esm/executor/ops/literals.js.map +1 -0
- package/dist/esm/executor/ops/misc.d.ts +1 -0
- package/dist/esm/executor/ops/misc.js +27 -0
- package/dist/esm/executor/ops/misc.js.map +1 -0
- package/dist/esm/executor/ops/object.d.ts +1 -0
- package/dist/esm/executor/ops/object.js +53 -0
- package/dist/esm/executor/ops/object.js.map +1 -0
- package/dist/esm/executor/ops/prop.d.ts +1 -0
- package/dist/esm/executor/ops/prop.js +72 -0
- package/dist/esm/executor/ops/prop.js.map +1 -0
- package/dist/esm/executor/ops/unary.d.ts +1 -0
- package/dist/esm/executor/ops/unary.js +50 -0
- package/dist/esm/executor/ops/unary.js.map +1 -0
- package/dist/esm/executor/ops/variables.d.ts +1 -0
- package/dist/esm/executor/ops/variables.js +18 -0
- package/dist/esm/executor/ops/variables.js.map +1 -0
- package/dist/esm/executor/opsRegistry.d.ts +33 -0
- package/dist/esm/executor/opsRegistry.js +9 -0
- package/dist/esm/executor/opsRegistry.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parser/index.d.ts +3 -0
- package/dist/esm/parser/index.js +1 -0
- package/{build/parser.d.ts → dist/esm/parser/lisp.d.ts} +29 -42
- package/dist/esm/parser/lispTypes/conditionals.d.ts +2 -0
- package/dist/esm/parser/lispTypes/conditionals.js +137 -0
- package/dist/esm/parser/lispTypes/conditionals.js.map +1 -0
- package/dist/esm/parser/lispTypes/control.d.ts +2 -0
- package/dist/esm/parser/lispTypes/control.js +206 -0
- package/dist/esm/parser/lispTypes/control.js.map +1 -0
- package/dist/esm/parser/lispTypes/declarations.d.ts +2 -0
- package/dist/esm/parser/lispTypes/declarations.js +101 -0
- package/dist/esm/parser/lispTypes/declarations.js.map +1 -0
- package/dist/esm/parser/lispTypes/index.d.ts +3 -0
- package/dist/esm/parser/lispTypes/index.js +19 -0
- package/dist/esm/parser/lispTypes/index.js.map +1 -0
- package/dist/esm/parser/lispTypes/operators.d.ts +2 -0
- package/dist/esm/parser/lispTypes/operators.js +254 -0
- package/dist/esm/parser/lispTypes/operators.js.map +1 -0
- package/dist/esm/parser/lispTypes/shared.d.ts +38 -0
- package/dist/esm/parser/lispTypes/structures.d.ts +2 -0
- package/dist/esm/parser/lispTypes/structures.js +190 -0
- package/dist/esm/parser/lispTypes/structures.js.map +1 -0
- package/dist/esm/parser/lispTypes/values.d.ts +2 -0
- package/dist/esm/parser/lispTypes/values.js +91 -0
- package/dist/esm/parser/lispTypes/values.js.map +1 -0
- package/dist/esm/parser/parserUtils.d.ts +34 -0
- package/dist/esm/parser/parserUtils.js +959 -0
- package/dist/esm/parser/parserUtils.js.map +1 -0
- package/dist/esm/utils/CodeString.d.ts +16 -0
- package/dist/esm/utils/CodeString.js +66 -0
- package/dist/esm/utils/CodeString.js.map +1 -0
- package/dist/esm/utils/ExecContext.d.ts +34 -0
- package/dist/esm/utils/ExecContext.js +168 -0
- package/dist/esm/utils/ExecContext.js.map +1 -0
- package/dist/esm/utils/Prop.d.ts +16 -0
- package/dist/esm/utils/Prop.js +80 -0
- package/dist/esm/utils/Prop.js.map +1 -0
- package/dist/esm/utils/Scope.d.ts +47 -0
- package/dist/esm/utils/Scope.js +122 -0
- package/dist/esm/utils/Scope.js.map +1 -0
- package/dist/esm/utils/errors.d.ts +10 -0
- package/dist/esm/utils/errors.js +10 -0
- package/dist/esm/utils/errors.js.map +1 -0
- package/dist/esm/utils/functionReplacements.d.ts +11 -0
- package/dist/esm/utils/functionReplacements.js +361 -0
- package/dist/esm/utils/functionReplacements.js.map +1 -0
- package/dist/esm/utils/index.d.ts +7 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/types.d.ts +221 -0
- package/dist/esm/utils/types.js +160 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/utils/unraw.js +147 -0
- package/dist/esm/utils/unraw.js.map +1 -0
- package/dist/umd/Sandbox.min.js +2 -0
- package/dist/umd/Sandbox.min.js.map +1 -0
- package/dist/umd/SandboxExec.min.js +2 -0
- package/dist/umd/SandboxExec.min.js.map +1 -0
- package/package.json +70 -68
- package/build/Sandbox.js +0 -62
- package/build/SandboxExec.js +0 -214
- package/build/eval.js +0 -205
- package/build/executor.d.ts +0 -124
- package/build/executor.js +0 -1546
- package/build/parser.js +0 -1527
- package/build/unraw.js +0 -168
- package/build/utils.d.ts +0 -264
- package/build/utils.js +0 -362
- package/dist/Sandbox.d.ts +0 -25
- package/dist/Sandbox.js +0 -270
- package/dist/Sandbox.js.map +0 -1
- package/dist/Sandbox.min.js +0 -2
- package/dist/Sandbox.min.js.map +0 -1
- package/dist/SandboxExec.js +0 -218
- package/dist/SandboxExec.js.map +0 -1
- package/dist/SandboxExec.min.js +0 -2
- package/dist/SandboxExec.min.js.map +0 -1
- package/dist/executor.d.ts +0 -124
- package/dist/executor.js +0 -1550
- package/dist/executor.js.map +0 -1
- package/dist/node/Sandbox.js +0 -277
- package/dist/node/SandboxExec.d.ts +0 -66
- package/dist/node/SandboxExec.js +0 -225
- package/dist/node/eval.d.ts +0 -27
- package/dist/node/executor.d.ts +0 -124
- package/dist/node/executor.js +0 -1567
- package/dist/node/parser.d.ts +0 -154
- package/dist/node/parser.js +0 -1704
- package/dist/node/utils.d.ts +0 -264
- package/dist/node/utils.js +0 -385
- package/dist/parser.js +0 -1690
- package/dist/parser.js.map +0 -1
- package/dist/unraw.d.ts +0 -11
- package/dist/utils.d.ts +0 -264
- package/dist/utils.js +0 -365
- package/dist/utils.js.map +0 -1
- /package/{build → dist/cjs/utils}/unraw.d.ts +0 -0
- /package/dist/{node → esm/utils}/unraw.d.ts +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_errors = require("./utils/errors.js");
|
|
6
|
+
const require_ExecContext = require("./utils/ExecContext.js");
|
|
7
|
+
require("./utils/index.js");
|
|
8
|
+
const require_executorUtils = require("./executor/executorUtils.js");
|
|
9
|
+
require("./executor/index.js");
|
|
10
|
+
//#region src/SandboxExec.ts
|
|
11
|
+
function subscribeSet(obj, name, callback, context) {
|
|
12
|
+
const names = context.setSubscriptions.get(obj) || /* @__PURE__ */ new Map();
|
|
13
|
+
context.setSubscriptions.set(obj, names);
|
|
14
|
+
const callbacks = names.get(name) || /* @__PURE__ */ new Set();
|
|
15
|
+
names.set(name, callbacks);
|
|
16
|
+
callbacks.add(callback);
|
|
17
|
+
let changeCbs;
|
|
18
|
+
const val = obj[name];
|
|
19
|
+
if (val instanceof Object) {
|
|
20
|
+
changeCbs = context.changeSubscriptions.get(val) || /* @__PURE__ */ new Set();
|
|
21
|
+
changeCbs.add(callback);
|
|
22
|
+
context.changeSubscriptions.set(val, changeCbs);
|
|
23
|
+
}
|
|
24
|
+
return { unsubscribe: () => {
|
|
25
|
+
callbacks.delete(callback);
|
|
26
|
+
changeCbs?.delete(callback);
|
|
27
|
+
} };
|
|
28
|
+
}
|
|
29
|
+
var SandboxExec = class SandboxExec {
|
|
30
|
+
constructor(options, evalContext) {
|
|
31
|
+
this.evalContext = evalContext;
|
|
32
|
+
this.setSubscriptions = /* @__PURE__ */ new WeakMap();
|
|
33
|
+
this.changeSubscriptions = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
this.sandboxFunctions = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
this.haltSubscriptions = /* @__PURE__ */ new Set();
|
|
36
|
+
this.resumeSubscriptions = /* @__PURE__ */ new Set();
|
|
37
|
+
this.halted = false;
|
|
38
|
+
this.timeoutHandleCounter = 0;
|
|
39
|
+
this.setTimeoutHandles = /* @__PURE__ */ new Map();
|
|
40
|
+
this.setIntervalHandles = /* @__PURE__ */ new Map();
|
|
41
|
+
const opt = Object.assign({
|
|
42
|
+
audit: false,
|
|
43
|
+
forbidFunctionCalls: false,
|
|
44
|
+
forbidFunctionCreation: false,
|
|
45
|
+
globals: SandboxExec.SAFE_GLOBALS,
|
|
46
|
+
symbolWhitelist: SandboxExec.SAFE_SYMBOLS,
|
|
47
|
+
prototypeWhitelist: SandboxExec.SAFE_PROTOTYPES,
|
|
48
|
+
maxParserRecursionDepth: 256,
|
|
49
|
+
nonBlocking: false,
|
|
50
|
+
functionReplacements: /* @__PURE__ */ new Map()
|
|
51
|
+
}, options || {});
|
|
52
|
+
this.context = require_ExecContext.createContext(this, opt);
|
|
53
|
+
}
|
|
54
|
+
static get SAFE_GLOBALS() {
|
|
55
|
+
return {
|
|
56
|
+
globalThis,
|
|
57
|
+
Function,
|
|
58
|
+
eval,
|
|
59
|
+
console: {
|
|
60
|
+
debug: console.debug,
|
|
61
|
+
error: console.error,
|
|
62
|
+
info: console.info,
|
|
63
|
+
log: console.log,
|
|
64
|
+
table: console.table,
|
|
65
|
+
warn: console.warn
|
|
66
|
+
},
|
|
67
|
+
isFinite,
|
|
68
|
+
isNaN,
|
|
69
|
+
parseFloat,
|
|
70
|
+
parseInt,
|
|
71
|
+
decodeURI,
|
|
72
|
+
decodeURIComponent,
|
|
73
|
+
encodeURI,
|
|
74
|
+
encodeURIComponent,
|
|
75
|
+
escape,
|
|
76
|
+
unescape,
|
|
77
|
+
Boolean,
|
|
78
|
+
Number,
|
|
79
|
+
BigInt,
|
|
80
|
+
String,
|
|
81
|
+
Object,
|
|
82
|
+
Array,
|
|
83
|
+
Symbol,
|
|
84
|
+
Error,
|
|
85
|
+
EvalError,
|
|
86
|
+
RangeError,
|
|
87
|
+
ReferenceError,
|
|
88
|
+
SyntaxError,
|
|
89
|
+
TypeError,
|
|
90
|
+
URIError,
|
|
91
|
+
Int8Array,
|
|
92
|
+
Uint8Array,
|
|
93
|
+
Uint8ClampedArray,
|
|
94
|
+
Int16Array,
|
|
95
|
+
Uint16Array,
|
|
96
|
+
Int32Array,
|
|
97
|
+
Uint32Array,
|
|
98
|
+
Float32Array,
|
|
99
|
+
Float64Array,
|
|
100
|
+
Map,
|
|
101
|
+
Set,
|
|
102
|
+
WeakMap,
|
|
103
|
+
WeakSet,
|
|
104
|
+
Promise,
|
|
105
|
+
Intl,
|
|
106
|
+
JSON,
|
|
107
|
+
Math,
|
|
108
|
+
Date,
|
|
109
|
+
RegExp
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
static get SAFE_SYMBOLS() {
|
|
113
|
+
const safeSymbols = {};
|
|
114
|
+
for (const key of [
|
|
115
|
+
"asyncIterator",
|
|
116
|
+
"iterator",
|
|
117
|
+
"match",
|
|
118
|
+
"matchAll",
|
|
119
|
+
"replace",
|
|
120
|
+
"search",
|
|
121
|
+
"split"
|
|
122
|
+
]) {
|
|
123
|
+
const value = Symbol[key];
|
|
124
|
+
if (typeof value === "symbol") safeSymbols[key] = value;
|
|
125
|
+
}
|
|
126
|
+
return safeSymbols;
|
|
127
|
+
}
|
|
128
|
+
static get SAFE_PROTOTYPES() {
|
|
129
|
+
const protos = [
|
|
130
|
+
Function,
|
|
131
|
+
Boolean,
|
|
132
|
+
Number,
|
|
133
|
+
BigInt,
|
|
134
|
+
String,
|
|
135
|
+
Date,
|
|
136
|
+
Error,
|
|
137
|
+
Array,
|
|
138
|
+
Int8Array,
|
|
139
|
+
Uint8Array,
|
|
140
|
+
Uint8ClampedArray,
|
|
141
|
+
Int16Array,
|
|
142
|
+
Uint16Array,
|
|
143
|
+
Int32Array,
|
|
144
|
+
Uint32Array,
|
|
145
|
+
Float32Array,
|
|
146
|
+
Float64Array,
|
|
147
|
+
Map,
|
|
148
|
+
Set,
|
|
149
|
+
WeakMap,
|
|
150
|
+
WeakSet,
|
|
151
|
+
Promise,
|
|
152
|
+
Symbol,
|
|
153
|
+
Date,
|
|
154
|
+
RegExp,
|
|
155
|
+
Response,
|
|
156
|
+
Request,
|
|
157
|
+
Headers,
|
|
158
|
+
FormData
|
|
159
|
+
];
|
|
160
|
+
const map = /* @__PURE__ */ new Map();
|
|
161
|
+
protos.forEach((proto) => {
|
|
162
|
+
map.set(proto, /* @__PURE__ */ new Set());
|
|
163
|
+
});
|
|
164
|
+
map.set(Object, new Set([
|
|
165
|
+
"constructor",
|
|
166
|
+
"name",
|
|
167
|
+
"entries",
|
|
168
|
+
"fromEntries",
|
|
169
|
+
"getOwnPropertyNames",
|
|
170
|
+
"is",
|
|
171
|
+
"keys",
|
|
172
|
+
"hasOwnProperty",
|
|
173
|
+
"isPrototypeOf",
|
|
174
|
+
"propertyIsEnumerable",
|
|
175
|
+
"toLocaleString",
|
|
176
|
+
"toString",
|
|
177
|
+
"valueOf",
|
|
178
|
+
"values"
|
|
179
|
+
]));
|
|
180
|
+
return map;
|
|
181
|
+
}
|
|
182
|
+
subscribeGet(callback, context) {
|
|
183
|
+
context.getSubscriptions.add(callback);
|
|
184
|
+
return { unsubscribe: () => context.getSubscriptions.delete(callback) };
|
|
185
|
+
}
|
|
186
|
+
subscribeSet(obj, name, callback, context) {
|
|
187
|
+
return subscribeSet(obj, name, callback, context);
|
|
188
|
+
}
|
|
189
|
+
subscribeSetGlobal(obj, name, callback) {
|
|
190
|
+
return subscribeSet(obj, name, callback, this);
|
|
191
|
+
}
|
|
192
|
+
subscribeHalt(cb) {
|
|
193
|
+
this.haltSubscriptions.add(cb);
|
|
194
|
+
return { unsubscribe: () => {
|
|
195
|
+
this.haltSubscriptions.delete(cb);
|
|
196
|
+
} };
|
|
197
|
+
}
|
|
198
|
+
subscribeResume(cb) {
|
|
199
|
+
this.resumeSubscriptions.add(cb);
|
|
200
|
+
return { unsubscribe: () => {
|
|
201
|
+
this.resumeSubscriptions.delete(cb);
|
|
202
|
+
} };
|
|
203
|
+
}
|
|
204
|
+
haltExecution(haltContext = { type: "manual" }) {
|
|
205
|
+
if (this.halted) return;
|
|
206
|
+
this.halted = true;
|
|
207
|
+
for (const cb of this.haltSubscriptions) cb(haltContext);
|
|
208
|
+
}
|
|
209
|
+
resumeExecution() {
|
|
210
|
+
if (!this.halted) return;
|
|
211
|
+
if (this.context.ticks.tickLimit !== void 0 && this.context.ticks.ticks >= this.context.ticks.tickLimit) throw new require_errors.SandboxExecutionQuotaExceededError("Cannot resume execution: tick limit exceeded");
|
|
212
|
+
this.halted = false;
|
|
213
|
+
for (const cb of this.resumeSubscriptions) cb();
|
|
214
|
+
}
|
|
215
|
+
getContext(fn) {
|
|
216
|
+
return this.sandboxFunctions.get(fn);
|
|
217
|
+
}
|
|
218
|
+
executeTree(context, scopes = []) {
|
|
219
|
+
return require_executorUtils.executeTree(context.ctx.ticks, context, context.tree, scopes, void 0, false);
|
|
220
|
+
}
|
|
221
|
+
executeTreeAsync(context, scopes = []) {
|
|
222
|
+
return require_executorUtils.executeTreeAsync(context.ctx.ticks, context, context.tree, scopes, void 0, false);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
//#endregion
|
|
226
|
+
exports.SandboxExec = SandboxExec;
|
|
227
|
+
exports.default = SandboxExec;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { lispifyFunction } from '
|
|
2
|
-
import { IExecContext } from '
|
|
1
|
+
import { lispifyFunction } from '../parser';
|
|
2
|
+
import { IExecContext } from '../utils';
|
|
3
3
|
export interface IEvalContext {
|
|
4
4
|
sandboxFunction: typeof sandboxFunction;
|
|
5
5
|
sandboxAsyncFunction: typeof sandboxAsyncFunction;
|
|
6
|
+
sandboxGeneratorFunction: typeof sandboxGeneratorFunction;
|
|
7
|
+
sandboxAsyncGeneratorFunction: typeof sandboxAsyncGeneratorFunction;
|
|
8
|
+
sandboxedSymbol: typeof sandboxedSymbol;
|
|
6
9
|
sandboxedEval: (func: SandboxFunction, context: IExecContext) => SandboxEval;
|
|
7
10
|
sandboxedSetTimeout: typeof sandboxedSetTimeout;
|
|
8
11
|
sandboxedSetInterval: typeof sandboxedSetInterval;
|
|
@@ -17,9 +20,14 @@ export type SandboxSetInterval = (handler: TimerHandler, timeout?: number, ...ar
|
|
|
17
20
|
export type SandboxClearTimeout = (handle: number) => void;
|
|
18
21
|
export type SandboxClearInterval = (handle: number) => void;
|
|
19
22
|
export declare function createEvalContext(): IEvalContext;
|
|
23
|
+
export declare function sandboxedSymbol(context: IExecContext): Function;
|
|
20
24
|
export declare function sandboxFunction(context: IExecContext): SandboxFunction;
|
|
21
25
|
export type SandboxAsyncFunction = (code: string, ...args: string[]) => () => Promise<unknown>;
|
|
22
26
|
export declare function sandboxAsyncFunction(context: IExecContext): SandboxAsyncFunction;
|
|
27
|
+
export type SandboxGeneratorFunction = (code: string, ...args: string[]) => () => Iterator<unknown> & Iterable<unknown>;
|
|
28
|
+
export declare function sandboxGeneratorFunction(context: IExecContext): SandboxGeneratorFunction;
|
|
29
|
+
export type SandboxAsyncGeneratorFunction = (code: string, ...args: string[]) => () => AsyncGenerator<unknown, unknown, unknown>;
|
|
30
|
+
export declare function sandboxAsyncGeneratorFunction(context: IExecContext): SandboxAsyncGeneratorFunction;
|
|
23
31
|
export declare function sandboxedEval(func: SandboxFunction, context: IExecContext): SandboxEval;
|
|
24
32
|
export declare function sandboxedSetTimeout(func: SandboxFunction, context: IExecContext): SandboxSetTimeout;
|
|
25
33
|
export declare function sandboxedClearTimeout(context: IExecContext): SandboxClearTimeout;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
const require_types = require("../utils/types.js");
|
|
2
|
+
const require_ExecContext = require("../utils/ExecContext.js");
|
|
3
|
+
require("../utils/index.js");
|
|
4
|
+
const require_executorUtils = require("../executor/executorUtils.js");
|
|
5
|
+
require("../executor/index.js");
|
|
6
|
+
const require_parserUtils = require("../parser/parserUtils.js");
|
|
7
|
+
require("../parser/index.js");
|
|
8
|
+
//#region src/eval/index.ts
|
|
9
|
+
function createEvalContext() {
|
|
10
|
+
return {
|
|
11
|
+
sandboxFunction,
|
|
12
|
+
sandboxAsyncFunction,
|
|
13
|
+
sandboxGeneratorFunction,
|
|
14
|
+
sandboxAsyncGeneratorFunction,
|
|
15
|
+
sandboxedSymbol,
|
|
16
|
+
sandboxedEval,
|
|
17
|
+
sandboxedSetTimeout,
|
|
18
|
+
sandboxedSetInterval,
|
|
19
|
+
sandboxedClearTimeout,
|
|
20
|
+
sandboxedClearInterval,
|
|
21
|
+
lispifyFunction: require_parserUtils.lispifyFunction
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function sandboxedSymbol(context) {
|
|
25
|
+
return require_ExecContext.getSandboxSymbolCtor(context.ctx.sandboxSymbols);
|
|
26
|
+
}
|
|
27
|
+
function SB() {}
|
|
28
|
+
function sandboxFunction(context) {
|
|
29
|
+
SandboxFunction.prototype = SB.prototype;
|
|
30
|
+
return SandboxFunction;
|
|
31
|
+
function SandboxFunction(...params) {
|
|
32
|
+
const parsed = require_parserUtils.default(params.pop() || "", false, false, context.ctx.options.maxParserRecursionDepth);
|
|
33
|
+
return require_executorUtils.createFunction(params, parsed.tree, context.ctx.ticks, {
|
|
34
|
+
...context,
|
|
35
|
+
constants: parsed.constants,
|
|
36
|
+
tree: parsed.tree
|
|
37
|
+
}, void 0, "anonymous");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function SAF() {}
|
|
41
|
+
function sandboxAsyncFunction(context) {
|
|
42
|
+
SandboxAsyncFunction.prototype = SAF.prototype;
|
|
43
|
+
return SandboxAsyncFunction;
|
|
44
|
+
function SandboxAsyncFunction(...params) {
|
|
45
|
+
const parsed = require_parserUtils.default(params.pop() || "", false, false, context.ctx.options.maxParserRecursionDepth);
|
|
46
|
+
return require_executorUtils.createFunctionAsync(params, parsed.tree, context.ctx.ticks, {
|
|
47
|
+
...context,
|
|
48
|
+
constants: parsed.constants,
|
|
49
|
+
tree: parsed.tree
|
|
50
|
+
}, void 0, "anonymous");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function SGF() {}
|
|
54
|
+
function sandboxGeneratorFunction(context) {
|
|
55
|
+
SandboxGeneratorFunction.prototype = SGF.prototype;
|
|
56
|
+
return SandboxGeneratorFunction;
|
|
57
|
+
function SandboxGeneratorFunction(...params) {
|
|
58
|
+
const parsed = require_parserUtils.default(params.pop() || "", false, false, context.ctx.options.maxParserRecursionDepth);
|
|
59
|
+
return require_executorUtils.createGeneratorFunction(params, parsed.tree, context.ctx.ticks, {
|
|
60
|
+
...context,
|
|
61
|
+
constants: parsed.constants,
|
|
62
|
+
tree: parsed.tree
|
|
63
|
+
}, void 0, "anonymous");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function SAGF() {}
|
|
67
|
+
function sandboxAsyncGeneratorFunction(context) {
|
|
68
|
+
SandboxAsyncGeneratorFunction.prototype = SAGF.prototype;
|
|
69
|
+
return SandboxAsyncGeneratorFunction;
|
|
70
|
+
function SandboxAsyncGeneratorFunction(...params) {
|
|
71
|
+
const parsed = require_parserUtils.default(params.pop() || "", false, false, context.ctx.options.maxParserRecursionDepth);
|
|
72
|
+
return require_executorUtils.createAsyncGeneratorFunction(params, parsed.tree, context.ctx.ticks, {
|
|
73
|
+
...context,
|
|
74
|
+
constants: parsed.constants,
|
|
75
|
+
tree: parsed.tree
|
|
76
|
+
}, void 0, "anonymous");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function SE() {}
|
|
80
|
+
function sandboxedEval(func, context) {
|
|
81
|
+
sandboxEval.prototype = SE.prototype;
|
|
82
|
+
return sandboxEval;
|
|
83
|
+
function sandboxEval(code) {
|
|
84
|
+
const parsed = require_parserUtils.default(code, false, false, context.ctx.options.maxParserRecursionDepth);
|
|
85
|
+
const tree = wrapLastStatementInReturn(parsed.tree);
|
|
86
|
+
return require_executorUtils.createFunction([], tree, context.ctx.ticks, {
|
|
87
|
+
...context,
|
|
88
|
+
constants: parsed.constants,
|
|
89
|
+
tree
|
|
90
|
+
}, void 0, "anonymous")();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function wrapLastStatementInReturn(tree) {
|
|
94
|
+
if (tree.length === 0) return tree;
|
|
95
|
+
const newTree = [...tree];
|
|
96
|
+
const lastIndex = newTree.length - 1;
|
|
97
|
+
const lastStmt = newTree[lastIndex];
|
|
98
|
+
if (Array.isArray(lastStmt) && lastStmt.length >= 1) {
|
|
99
|
+
const op = lastStmt[0];
|
|
100
|
+
if (op === require_types.LispType.Return || op === require_types.LispType.Throw) return newTree;
|
|
101
|
+
if ([
|
|
102
|
+
require_types.LispType.Let,
|
|
103
|
+
require_types.LispType.Const,
|
|
104
|
+
require_types.LispType.Var,
|
|
105
|
+
require_types.LispType.Function,
|
|
106
|
+
require_types.LispType.If,
|
|
107
|
+
require_types.LispType.Loop,
|
|
108
|
+
require_types.LispType.Try,
|
|
109
|
+
require_types.LispType.Switch,
|
|
110
|
+
require_types.LispType.InternalBlock,
|
|
111
|
+
require_types.LispType.Expression
|
|
112
|
+
].includes(op)) return newTree;
|
|
113
|
+
newTree[lastIndex] = [
|
|
114
|
+
require_types.LispType.Return,
|
|
115
|
+
require_types.LispType.None,
|
|
116
|
+
lastStmt
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
return newTree;
|
|
120
|
+
}
|
|
121
|
+
function sST() {}
|
|
122
|
+
function sandboxedSetTimeout(func, context) {
|
|
123
|
+
sandboxSetTimeout.prototype = sST.prototype;
|
|
124
|
+
return sandboxSetTimeout;
|
|
125
|
+
function sandboxSetTimeout(handler, timeout, ...args) {
|
|
126
|
+
const sandbox = context.ctx.sandbox;
|
|
127
|
+
const exec = (...a) => {
|
|
128
|
+
const h = typeof handler === "string" ? func(handler) : handler;
|
|
129
|
+
haltsub.unsubscribe();
|
|
130
|
+
contsub.unsubscribe();
|
|
131
|
+
sandbox.setTimeoutHandles.delete(sandBoxhandle);
|
|
132
|
+
return h(...a);
|
|
133
|
+
};
|
|
134
|
+
const sandBoxhandle = ++sandbox.timeoutHandleCounter;
|
|
135
|
+
let start = Date.now();
|
|
136
|
+
let handle = setTimeout(exec, timeout, ...args);
|
|
137
|
+
let elapsed = 0;
|
|
138
|
+
const haltsub = sandbox.subscribeHalt(() => {
|
|
139
|
+
elapsed = Date.now() - start + elapsed;
|
|
140
|
+
clearTimeout(handle);
|
|
141
|
+
});
|
|
142
|
+
const contsub = sandbox.subscribeResume(() => {
|
|
143
|
+
start = Date.now();
|
|
144
|
+
const remaining = Math.floor((timeout || 0) - elapsed);
|
|
145
|
+
handle = setTimeout(exec, remaining, ...args);
|
|
146
|
+
sandbox.setTimeoutHandles.set(sandBoxhandle, {
|
|
147
|
+
handle,
|
|
148
|
+
haltsub,
|
|
149
|
+
contsub
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
sandbox.setTimeoutHandles.set(sandBoxhandle, {
|
|
153
|
+
handle,
|
|
154
|
+
haltsub,
|
|
155
|
+
contsub
|
|
156
|
+
});
|
|
157
|
+
return sandBoxhandle;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function sCT() {}
|
|
161
|
+
function sandboxedClearTimeout(context) {
|
|
162
|
+
sandboxClearTimeout.prototype = sCT.prototype;
|
|
163
|
+
return sandboxClearTimeout;
|
|
164
|
+
function sandboxClearTimeout(handle) {
|
|
165
|
+
const sandbox = context.ctx.sandbox;
|
|
166
|
+
const timeoutHandle = sandbox.setTimeoutHandles.get(handle);
|
|
167
|
+
if (timeoutHandle) {
|
|
168
|
+
clearTimeout(timeoutHandle.handle);
|
|
169
|
+
timeoutHandle.haltsub.unsubscribe();
|
|
170
|
+
timeoutHandle.contsub.unsubscribe();
|
|
171
|
+
sandbox.setTimeoutHandles.delete(handle);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function sCI() {}
|
|
176
|
+
function sandboxedClearInterval(context) {
|
|
177
|
+
sandboxClearInterval.prototype = sCI.prototype;
|
|
178
|
+
return sandboxClearInterval;
|
|
179
|
+
function sandboxClearInterval(handle) {
|
|
180
|
+
const sandbox = context.ctx.sandbox;
|
|
181
|
+
const intervalHandle = sandbox.setIntervalHandles.get(handle);
|
|
182
|
+
if (intervalHandle) {
|
|
183
|
+
clearInterval(intervalHandle.handle);
|
|
184
|
+
clearTimeout(intervalHandle.handle);
|
|
185
|
+
intervalHandle.haltsub.unsubscribe();
|
|
186
|
+
intervalHandle.contsub.unsubscribe();
|
|
187
|
+
sandbox.setIntervalHandles.delete(handle);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function sSI() {}
|
|
192
|
+
function sandboxedSetInterval(func, context) {
|
|
193
|
+
sandboxSetInterval.prototype = sSI.prototype;
|
|
194
|
+
return sandboxSetInterval;
|
|
195
|
+
function sandboxSetInterval(handler, timeout, ...args) {
|
|
196
|
+
const sandbox = context.ctx.sandbox;
|
|
197
|
+
const h = typeof handler === "string" ? func(handler) : handler;
|
|
198
|
+
const exec = (...a) => {
|
|
199
|
+
start = Date.now();
|
|
200
|
+
elapsed = 0;
|
|
201
|
+
return h(...a);
|
|
202
|
+
};
|
|
203
|
+
const sandBoxhandle = ++sandbox.timeoutHandleCounter;
|
|
204
|
+
let start = Date.now();
|
|
205
|
+
let handle = setInterval(exec, timeout, ...args);
|
|
206
|
+
let elapsed = 0;
|
|
207
|
+
const haltsub = sandbox.subscribeHalt(() => {
|
|
208
|
+
elapsed = Date.now() - start + elapsed;
|
|
209
|
+
clearInterval(handle);
|
|
210
|
+
clearTimeout(handle);
|
|
211
|
+
});
|
|
212
|
+
const contsub = sandbox.subscribeResume(() => {
|
|
213
|
+
start = Date.now();
|
|
214
|
+
handle = setTimeout(() => {
|
|
215
|
+
start = Date.now();
|
|
216
|
+
elapsed = 0;
|
|
217
|
+
handle = setInterval(exec, timeout, ...args);
|
|
218
|
+
handlObj.handle = handle;
|
|
219
|
+
exec(...args);
|
|
220
|
+
}, Math.floor((timeout || 0) - elapsed), ...args);
|
|
221
|
+
handlObj.handle = handle;
|
|
222
|
+
});
|
|
223
|
+
const handlObj = {
|
|
224
|
+
handle,
|
|
225
|
+
haltsub,
|
|
226
|
+
contsub
|
|
227
|
+
};
|
|
228
|
+
sandbox.setIntervalHandles.set(sandBoxhandle, handlObj);
|
|
229
|
+
return sandBoxhandle;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
exports.createEvalContext = createEvalContext;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { LispItem, Lisp, StatementLabel } from '../parser';
|
|
2
|
+
import { LispType, Prop, Scope, Unknown, IAuditReport, IExecContext, IScope, optional, Ticks } from '../utils';
|
|
3
|
+
import { Execution } from './opsRegistry';
|
|
4
|
+
export type Done<T = any> = (err?: any, res?: T | typeof optional) => void;
|
|
5
|
+
export type ControlFlowAction = 'break' | 'continue';
|
|
6
|
+
export interface ControlFlowSignal {
|
|
7
|
+
type: ControlFlowAction;
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ControlFlowTarget {
|
|
11
|
+
label?: string;
|
|
12
|
+
acceptsBreak: boolean;
|
|
13
|
+
acceptsContinue: boolean;
|
|
14
|
+
acceptsUnlabeledBreak: boolean;
|
|
15
|
+
acceptsUnlabeledContinue: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type ControlFlowTargets = readonly ControlFlowTarget[] | undefined;
|
|
18
|
+
export declare class ExecReturn<T> {
|
|
19
|
+
auditReport: IAuditReport | undefined;
|
|
20
|
+
result: T;
|
|
21
|
+
returned: boolean;
|
|
22
|
+
controlFlow?: ControlFlowSignal | undefined;
|
|
23
|
+
constructor(auditReport: IAuditReport | undefined, result: T, returned: boolean, controlFlow?: ControlFlowSignal | undefined);
|
|
24
|
+
get breakLoop(): boolean;
|
|
25
|
+
get continueLoop(): boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface IChange {
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ICreate extends IChange {
|
|
31
|
+
type: 'create';
|
|
32
|
+
prop: number | string;
|
|
33
|
+
}
|
|
34
|
+
export interface IReplace extends IChange {
|
|
35
|
+
type: 'replace';
|
|
36
|
+
}
|
|
37
|
+
export interface IDelete extends IChange {
|
|
38
|
+
type: 'delete';
|
|
39
|
+
prop: number | string;
|
|
40
|
+
}
|
|
41
|
+
export interface IReverse extends IChange {
|
|
42
|
+
type: 'reverse';
|
|
43
|
+
}
|
|
44
|
+
export interface ISort extends IChange {
|
|
45
|
+
type: 'sort';
|
|
46
|
+
}
|
|
47
|
+
export interface IPush extends IChange {
|
|
48
|
+
type: 'push';
|
|
49
|
+
added: unknown[];
|
|
50
|
+
}
|
|
51
|
+
export interface IPop extends IChange {
|
|
52
|
+
type: 'pop';
|
|
53
|
+
removed: unknown[];
|
|
54
|
+
}
|
|
55
|
+
export interface IShift extends IChange {
|
|
56
|
+
type: 'shift';
|
|
57
|
+
removed: unknown[];
|
|
58
|
+
}
|
|
59
|
+
export interface IUnShift extends IChange {
|
|
60
|
+
type: 'unshift';
|
|
61
|
+
added: unknown[];
|
|
62
|
+
}
|
|
63
|
+
export interface ISplice extends IChange {
|
|
64
|
+
type: 'splice';
|
|
65
|
+
startIndex: number;
|
|
66
|
+
deleteCount: number;
|
|
67
|
+
added: unknown[];
|
|
68
|
+
removed: unknown[];
|
|
69
|
+
}
|
|
70
|
+
export interface ICopyWithin extends IChange {
|
|
71
|
+
type: 'copyWithin';
|
|
72
|
+
startIndex: number;
|
|
73
|
+
endIndex: number;
|
|
74
|
+
added: unknown[];
|
|
75
|
+
removed: unknown[];
|
|
76
|
+
}
|
|
77
|
+
export type Change = ICreate | IReplace | IDelete | IReverse | ISort | IPush | IPop | IUnShift | IShift | ISplice | ICopyWithin;
|
|
78
|
+
export declare function normalizeStatementLabel(label: StatementLabel | undefined): string | undefined;
|
|
79
|
+
export declare function normalizeStatementLabels(label: LispItem | StatementLabel | undefined): string[];
|
|
80
|
+
export declare function createLoopTarget(label?: string, acceptsUnlabeled?: boolean): ControlFlowTarget;
|
|
81
|
+
export declare function createSwitchTarget(label?: string): ControlFlowTarget;
|
|
82
|
+
export declare function createLabeledStatementTarget(label?: string): ControlFlowTarget | undefined;
|
|
83
|
+
export declare function addControlFlowTarget(controlFlowTargets: ControlFlowTargets, target?: ControlFlowTarget): ControlFlowTargets;
|
|
84
|
+
export declare function addControlFlowTargets(controlFlowTargets: ControlFlowTargets, targets: ControlFlowTarget[]): ControlFlowTargets;
|
|
85
|
+
export declare function matchesControlFlowTarget(signal: ControlFlowSignal, target: ControlFlowTarget): boolean;
|
|
86
|
+
export declare function findControlFlowTarget(controlFlowTargets: ControlFlowTargets, type: ControlFlowAction, label?: string): ControlFlowTarget | null | undefined;
|
|
87
|
+
export declare function createFunction(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string, internal?: boolean): (...args: unknown[]) => unknown;
|
|
88
|
+
export declare function createFunctionAsync(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string, internal?: boolean): (...args: unknown[]) => Promise<unknown>;
|
|
89
|
+
export declare class YieldValue {
|
|
90
|
+
value: unknown;
|
|
91
|
+
delegate: boolean;
|
|
92
|
+
constructor(value: unknown, delegate: boolean);
|
|
93
|
+
}
|
|
94
|
+
export declare function createGeneratorFunction(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string, internal?: boolean): (this: Unknown, ...args: unknown[]) => Iterator<unknown, any, any> & Iterable<unknown>;
|
|
95
|
+
export declare function createAsyncGeneratorFunction(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string, internal?: boolean): (this: Unknown, ...args: unknown[]) => AsyncGenerator;
|
|
96
|
+
export declare function assignCheck(obj: Prop, context: IExecContext, op?: string): void;
|
|
97
|
+
export declare const arrayChange: Set<(() => undefined) | ((...items: never[]) => number) | ((compareFn?: ((a: never, b: never) => number) | undefined) => never[]) | ((target: number, start: number, end?: number) => never[])>;
|
|
98
|
+
export declare class KeyVal {
|
|
99
|
+
key: PropertyKey | SpreadObject;
|
|
100
|
+
val: unknown;
|
|
101
|
+
constructor(key: PropertyKey | SpreadObject, val: unknown);
|
|
102
|
+
}
|
|
103
|
+
export declare class SpreadObject {
|
|
104
|
+
item: {
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
};
|
|
107
|
+
constructor(item: {
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export declare class SpreadArray {
|
|
112
|
+
item: unknown[];
|
|
113
|
+
constructor(item: unknown[]);
|
|
114
|
+
}
|
|
115
|
+
export declare class ArrayHole {
|
|
116
|
+
}
|
|
117
|
+
export declare class If {
|
|
118
|
+
t: Lisp;
|
|
119
|
+
f: Lisp;
|
|
120
|
+
label?: string | undefined;
|
|
121
|
+
constructor(t: Lisp, f: Lisp, label?: string | undefined);
|
|
122
|
+
}
|
|
123
|
+
export declare const literalRegex: RegExp;
|
|
124
|
+
export { ops, addOps } from './opsRegistry';
|
|
125
|
+
export declare const prorptyKeyTypes: string[];
|
|
126
|
+
export declare function isPropertyKey(val: unknown): val is PropertyKey;
|
|
127
|
+
export declare function hasPossibleProperties(val: unknown): val is {};
|
|
128
|
+
export declare function execMany(ticks: Ticks, exec: Execution, tree: Lisp[], done: Done, scope: Scope, context: IExecContext, statementLabels: ControlFlowTargets, internal: boolean, generatorYield: ((yv: YieldValue, done?: Done) => void) | undefined): void;
|
|
129
|
+
export interface AsyncDoneRet {
|
|
130
|
+
isInstant: boolean;
|
|
131
|
+
instant: any;
|
|
132
|
+
p: Promise<{
|
|
133
|
+
result: any;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
136
|
+
export declare function asyncDone(callback: (done: Done) => void): AsyncDoneRet;
|
|
137
|
+
export declare function syncDone(callback: (done: Done) => void): {
|
|
138
|
+
result: any;
|
|
139
|
+
};
|
|
140
|
+
export declare function execAsync<T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, doneOriginal: Done<T>, statementLabels: ControlFlowTargets, internal: boolean, generatorYield: ((yv: YieldValue, done?: Done) => void) | undefined): Promise<void>;
|
|
141
|
+
export declare function execSync<T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done<T>, statementLabels: ControlFlowTargets, internal: boolean, generatorYield: ((yv: YieldValue, done?: Done) => void) | undefined): void;
|
|
142
|
+
type OpsCallbackParams<a, b, obj, bobj> = {
|
|
143
|
+
op: LispType;
|
|
144
|
+
exec: Execution;
|
|
145
|
+
a: a;
|
|
146
|
+
b: b;
|
|
147
|
+
obj: obj;
|
|
148
|
+
bobj: bobj;
|
|
149
|
+
ticks: Ticks;
|
|
150
|
+
tree: LispItem;
|
|
151
|
+
scope: Scope;
|
|
152
|
+
context: IExecContext;
|
|
153
|
+
done: Done;
|
|
154
|
+
statementLabels: ControlFlowTargets;
|
|
155
|
+
internal: boolean;
|
|
156
|
+
generatorYield: ((yv: YieldValue, done?: Done) => void) | undefined;
|
|
157
|
+
};
|
|
158
|
+
export declare function checkHaltExpectedTicks(params: OpsCallbackParams<any, any, any, any>, expectTicks?: bigint): boolean;
|
|
159
|
+
export declare function executeTree<T>(ticks: Ticks, context: IExecContext, executionTree: Lisp[], scopes: IScope[] | undefined, statementLabels: ControlFlowTargets, internal: boolean, generatorYield?: ((yv: YieldValue, done?: Done) => void) | undefined): ExecReturn<T>;
|
|
160
|
+
export declare function executeTreeAsync<T>(ticks: Ticks, context: IExecContext, executionTree: Lisp[], scopes: IScope[] | undefined, statementLabels: ControlFlowTargets, internal: boolean, generatorYield?: ((yv: YieldValue, done?: Done) => void) | undefined): Promise<ExecReturn<T>>;
|
|
161
|
+
export declare function executeTreeWithDone(exec: Execution, done: Done, ticks: Ticks, context: IExecContext, executionTree: Lisp[], scopes: IScope[] | undefined, statementLabels: ControlFlowTargets, internal: boolean, generatorYield?: ((yv: YieldValue, done?: Done) => void) | undefined): void;
|