ecma-evaluator 2.0.2 → 2.0.5
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 +23 -11
- package/README.zh-CN.md +521 -0
- package/dist/cjs/index.cjs +156 -57
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/esm/index.d.mts +4 -3
- package/dist/esm/index.mjs +152 -58
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { parse as external_acorn_parse } from "acorn";
|
|
2
2
|
import globals from "globals";
|
|
3
|
+
function _array_like_to_array(arr, len) {
|
|
4
|
+
if (null == len || len > arr.length) len = arr.length;
|
|
5
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
7
|
+
}
|
|
8
|
+
function _array_without_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
10
|
+
}
|
|
11
|
+
function _iterable_to_array(iter) {
|
|
12
|
+
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
13
|
+
}
|
|
14
|
+
function _non_iterable_spread() {
|
|
15
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
16
|
+
}
|
|
17
|
+
function _to_consumable_array(arr) {
|
|
18
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
19
|
+
}
|
|
20
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
21
|
+
if (!o) return;
|
|
22
|
+
if ("string" == typeof o) return _array_like_to_array(o, minLen);
|
|
23
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
24
|
+
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
25
|
+
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
26
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
27
|
+
}
|
|
3
28
|
var mutableMethods = [
|
|
4
29
|
"Array.prototype.push",
|
|
5
30
|
"Array.prototype.pop",
|
|
@@ -17,6 +42,8 @@ var mutableMethods = [
|
|
|
17
42
|
"Object.freeze",
|
|
18
43
|
"Object.setPrototypeOf",
|
|
19
44
|
"Object.assign",
|
|
45
|
+
"Object.prototype.__defineGetter__",
|
|
46
|
+
"Object.prototype.__defineSetter__",
|
|
20
47
|
"Reflect.set",
|
|
21
48
|
"Reflect.defineProperty",
|
|
22
49
|
"Reflect.deleteProperty",
|
|
@@ -138,9 +165,73 @@ var mutableMethods = [
|
|
|
138
165
|
"FormData.prototype.set",
|
|
139
166
|
"Headers.prototype.append",
|
|
140
167
|
"Headers.prototype.delete",
|
|
141
|
-
"Headers.prototype.set"
|
|
168
|
+
"Headers.prototype.set",
|
|
169
|
+
"Function.prototype.call",
|
|
170
|
+
"Function.prototype.apply",
|
|
171
|
+
"Function.prototype.bind",
|
|
172
|
+
"Function.prototype.constructor",
|
|
173
|
+
"Object.prototype.__lookupGetter__",
|
|
174
|
+
"Object.prototype.__lookupSetter__",
|
|
175
|
+
"Object.prototype.constructor"
|
|
142
176
|
];
|
|
143
|
-
|
|
177
|
+
var dangerousMethods = [
|
|
178
|
+
"Object.getPrototypeOf",
|
|
179
|
+
"Object.getOwnPropertyDescriptor",
|
|
180
|
+
"Object.getOwnPropertyDescriptors",
|
|
181
|
+
"Object.getOwnPropertyNames",
|
|
182
|
+
"Object.getOwnPropertySymbols",
|
|
183
|
+
"Object.getOwnPropertyDescriptors"
|
|
184
|
+
];
|
|
185
|
+
mutableMethods.push("Object.prototype.__proto__");
|
|
186
|
+
var blockedMethods = _to_consumable_array(mutableMethods).concat(_to_consumable_array(dangerousMethods));
|
|
187
|
+
var blockedGlobalBuiltIns = [
|
|
188
|
+
"Function",
|
|
189
|
+
"GeneratorFunction",
|
|
190
|
+
"AsyncFunction",
|
|
191
|
+
"AsyncGeneratorFunction",
|
|
192
|
+
"eval",
|
|
193
|
+
"setTimeout",
|
|
194
|
+
"setInterval",
|
|
195
|
+
"clearTimeout",
|
|
196
|
+
"clearInterval",
|
|
197
|
+
"setImmediate",
|
|
198
|
+
"XMLHttpRequest",
|
|
199
|
+
"fetch",
|
|
200
|
+
"WebSocket",
|
|
201
|
+
"globalThis",
|
|
202
|
+
"process",
|
|
203
|
+
"require",
|
|
204
|
+
"module",
|
|
205
|
+
"exports",
|
|
206
|
+
"global",
|
|
207
|
+
"Buffer",
|
|
208
|
+
"setImmediate",
|
|
209
|
+
"clearImmediate",
|
|
210
|
+
"importScripts",
|
|
211
|
+
"Worker",
|
|
212
|
+
"SharedWorker",
|
|
213
|
+
"ServiceWorker",
|
|
214
|
+
"BroadcastChannel",
|
|
215
|
+
"MessageChannel",
|
|
216
|
+
"MessagePort",
|
|
217
|
+
"postMessage",
|
|
218
|
+
"window",
|
|
219
|
+
"document",
|
|
220
|
+
"navigator",
|
|
221
|
+
"location",
|
|
222
|
+
"localStorage",
|
|
223
|
+
"sessionStorage",
|
|
224
|
+
"indexedDB",
|
|
225
|
+
"performance",
|
|
226
|
+
"Proxy",
|
|
227
|
+
"Reflect",
|
|
228
|
+
"Atomics",
|
|
229
|
+
"WebAssembly",
|
|
230
|
+
"console",
|
|
231
|
+
"Intl",
|
|
232
|
+
"Deno"
|
|
233
|
+
];
|
|
234
|
+
function Evaluator_array_like_to_array(arr, len) {
|
|
144
235
|
if (null == len || len > arr.length) len = arr.length;
|
|
145
236
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
146
237
|
return arr2;
|
|
@@ -148,8 +239,8 @@ function _array_like_to_array(arr, len) {
|
|
|
148
239
|
function _array_with_holes(arr) {
|
|
149
240
|
if (Array.isArray(arr)) return arr;
|
|
150
241
|
}
|
|
151
|
-
function
|
|
152
|
-
if (Array.isArray(arr)) return
|
|
242
|
+
function Evaluator_array_without_holes(arr) {
|
|
243
|
+
if (Array.isArray(arr)) return Evaluator_array_like_to_array(arr);
|
|
153
244
|
}
|
|
154
245
|
function _class_call_check(instance, Constructor) {
|
|
155
246
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -185,13 +276,13 @@ function _instanceof(left, right) {
|
|
|
185
276
|
if (null != right && "undefined" != typeof Symbol && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);
|
|
186
277
|
return left instanceof right;
|
|
187
278
|
}
|
|
188
|
-
function
|
|
279
|
+
function Evaluator_iterable_to_array(iter) {
|
|
189
280
|
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
190
281
|
}
|
|
191
282
|
function _non_iterable_rest() {
|
|
192
283
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
193
284
|
}
|
|
194
|
-
function
|
|
285
|
+
function Evaluator_non_iterable_spread() {
|
|
195
286
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
196
287
|
}
|
|
197
288
|
function _set_prototype_of(o, p) {
|
|
@@ -202,21 +293,21 @@ function _set_prototype_of(o, p) {
|
|
|
202
293
|
return _set_prototype_of(o, p);
|
|
203
294
|
}
|
|
204
295
|
function _to_array(arr) {
|
|
205
|
-
return _array_with_holes(arr) ||
|
|
296
|
+
return _array_with_holes(arr) || Evaluator_iterable_to_array(arr) || Evaluator_unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
206
297
|
}
|
|
207
|
-
function
|
|
208
|
-
return
|
|
298
|
+
function Evaluator_to_consumable_array(arr) {
|
|
299
|
+
return Evaluator_array_without_holes(arr) || Evaluator_iterable_to_array(arr) || Evaluator_unsupported_iterable_to_array(arr) || Evaluator_non_iterable_spread();
|
|
209
300
|
}
|
|
210
301
|
function _type_of(obj) {
|
|
211
302
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
212
303
|
}
|
|
213
|
-
function
|
|
304
|
+
function Evaluator_unsupported_iterable_to_array(o, minLen) {
|
|
214
305
|
if (!o) return;
|
|
215
|
-
if ("string" == typeof o) return
|
|
306
|
+
if ("string" == typeof o) return Evaluator_array_like_to_array(o, minLen);
|
|
216
307
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
217
308
|
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
218
309
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
219
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
310
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Evaluator_array_like_to_array(o, minLen);
|
|
220
311
|
}
|
|
221
312
|
function _is_native_reflect_construct() {
|
|
222
313
|
try {
|
|
@@ -228,14 +319,17 @@ function _is_native_reflect_construct() {
|
|
|
228
319
|
}
|
|
229
320
|
var ERROR_MESSAGES = {
|
|
230
321
|
DELETE_NOT_SUPPORTED: "Delete operator is not allow",
|
|
231
|
-
MUTABLE_METHOD: "Mutable method is not allowed",
|
|
232
322
|
NEW_FUNCTION_NOT_ALLOWED: "Cannot use new with Function constructor",
|
|
233
323
|
NOT_A_FUNCTION: "is not a function",
|
|
234
324
|
PROPERTY_READ_ERROR: "Cannot read property",
|
|
235
325
|
VARIABLE_NOT_DEFINED: "is not defined",
|
|
236
326
|
FUNCTION_CONSTRUCTOR_NOT_ALLOWED: "Function constructor is not allowed",
|
|
237
327
|
THIS_NOT_ALLOWED: "'this' keyword is not allowed",
|
|
238
|
-
NOT_A_VALID_SYNTAX: "is not a valid syntax"
|
|
328
|
+
NOT_A_VALID_SYNTAX: "is not a valid syntax",
|
|
329
|
+
ACCESSING_PROTOTYPE_NOT_ALLOWED: "Accessing prototype properties is not allowed",
|
|
330
|
+
WITH_NOT_ALLOWED: "'with' statement is not allowed",
|
|
331
|
+
FUNCTION_EXPRESSION_NOT_ALLOWED: "Function expressions are not allowed",
|
|
332
|
+
METHOD_NOT_ALLOWED: "is not allowed"
|
|
239
333
|
};
|
|
240
334
|
var BINARY_OPERATION_MAP = {
|
|
241
335
|
"+": function(a, b) {
|
|
@@ -308,17 +402,15 @@ var BINARY_OPERATION_MAP = {
|
|
|
308
402
|
function createGlobalScope() {
|
|
309
403
|
var scope = Object.create(null);
|
|
310
404
|
var builtin = globals.builtin;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
});
|
|
405
|
+
for(var key in builtin)if (!blockedGlobalBuiltIns.includes(key)) {
|
|
406
|
+
var isWritable = builtin[key];
|
|
407
|
+
Object.defineProperty(scope, key, {
|
|
408
|
+
value: globalThis[key],
|
|
409
|
+
writable: isWritable,
|
|
410
|
+
enumerable: false,
|
|
411
|
+
configurable: false
|
|
412
|
+
});
|
|
413
|
+
}
|
|
322
414
|
Object.defineProperty(scope, "globalThis", {
|
|
323
415
|
value: scope,
|
|
324
416
|
writable: false,
|
|
@@ -327,14 +419,14 @@ function createGlobalScope() {
|
|
|
327
419
|
});
|
|
328
420
|
return scope;
|
|
329
421
|
}
|
|
330
|
-
var
|
|
331
|
-
var
|
|
422
|
+
var getBlockedMethods = function() {
|
|
423
|
+
var BLOCKED_METHODS = null;
|
|
332
424
|
return function() {
|
|
333
|
-
if (
|
|
334
|
-
var
|
|
425
|
+
if (BLOCKED_METHODS) return BLOCKED_METHODS;
|
|
426
|
+
var map = new Map();
|
|
335
427
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
336
428
|
try {
|
|
337
|
-
for(var _iterator =
|
|
429
|
+
for(var _iterator = blockedMethods[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
338
430
|
var path = _step.value;
|
|
339
431
|
var _path_split = _to_array(path.split(".")), object = _path_split[0], properties = _path_split.slice(1);
|
|
340
432
|
var current = globalThis[object];
|
|
@@ -358,7 +450,7 @@ var getMutableMethods = function() {
|
|
|
358
450
|
if (_didIteratorError1) throw _iteratorError1;
|
|
359
451
|
}
|
|
360
452
|
}
|
|
361
|
-
if ("function" == typeof current) set
|
|
453
|
+
if ("function" == typeof current) map.set(current, path);
|
|
362
454
|
}
|
|
363
455
|
} catch (err) {
|
|
364
456
|
_didIteratorError = true;
|
|
@@ -370,8 +462,8 @@ var getMutableMethods = function() {
|
|
|
370
462
|
if (_didIteratorError) throw _iteratorError;
|
|
371
463
|
}
|
|
372
464
|
}
|
|
373
|
-
|
|
374
|
-
return
|
|
465
|
+
BLOCKED_METHODS = map;
|
|
466
|
+
return BLOCKED_METHODS;
|
|
375
467
|
};
|
|
376
468
|
}();
|
|
377
469
|
var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
@@ -442,14 +534,14 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
442
534
|
return node.value;
|
|
443
535
|
case "MemberExpression":
|
|
444
536
|
return this.handleMemberExpression(node);
|
|
445
|
-
case "ObjectExpression":
|
|
446
|
-
return this.handleObjectExpression(node);
|
|
447
537
|
case "ArrayExpression":
|
|
448
538
|
return this.handleArrayExpression(node);
|
|
449
539
|
case "SpreadElement":
|
|
450
540
|
return this.handleSpreadElement(node);
|
|
451
541
|
case "ObjectExpression":
|
|
452
542
|
return this.handleObjectExpression(node);
|
|
543
|
+
case "FunctionExpression":
|
|
544
|
+
throw new Error(ERROR_MESSAGES.FUNCTION_EXPRESSION_NOT_ALLOWED);
|
|
453
545
|
case "ArrowFunctionExpression":
|
|
454
546
|
return this.handleArrowFunctionExpression(node);
|
|
455
547
|
case "CallExpression":
|
|
@@ -463,13 +555,15 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
463
555
|
var args = node.arguments.length ? node.arguments.map(function(arg) {
|
|
464
556
|
return _this.visit(arg);
|
|
465
557
|
}) : [];
|
|
466
|
-
return _construct(Constructor,
|
|
558
|
+
return _construct(Constructor, Evaluator_to_consumable_array(args));
|
|
467
559
|
case "ChainExpression":
|
|
468
560
|
return this.visit(node.expression);
|
|
469
561
|
case "TemplateLiteral":
|
|
470
562
|
return this.handleTemplateLiteral(node);
|
|
471
563
|
case "ThisExpression":
|
|
472
564
|
throw new Error(ERROR_MESSAGES.THIS_NOT_ALLOWED);
|
|
565
|
+
case "WithStatement":
|
|
566
|
+
throw new Error(ERROR_MESSAGES.WITH_NOT_ALLOWED);
|
|
473
567
|
default:
|
|
474
568
|
var content = this.source.slice(node.start, node.end);
|
|
475
569
|
if (content.length > 20) content = content.slice(0, 17) + "...";
|
|
@@ -557,6 +651,7 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
557
651
|
var object = this.visit(node.object);
|
|
558
652
|
var isStaticProperty = "Identifier" === node.property.type && !node.computed;
|
|
559
653
|
var property = isStaticProperty ? node.property.name : this.visit(node.property);
|
|
654
|
+
if (null != object && object[property] === (null == object ? void 0 : object.__proto__)) throw new Error(ERROR_MESSAGES.ACCESSING_PROTOTYPE_NOT_ALLOWED);
|
|
560
655
|
if (null == object) {
|
|
561
656
|
if (node.optional) return;
|
|
562
657
|
throw new TypeError("".concat(ERROR_MESSAGES.PROPERTY_READ_ERROR, " '").concat(property, "' of ").concat(object));
|
|
@@ -564,6 +659,21 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
564
659
|
return object[property];
|
|
565
660
|
}
|
|
566
661
|
},
|
|
662
|
+
{
|
|
663
|
+
key: "handleArrayExpression",
|
|
664
|
+
value: function(node) {
|
|
665
|
+
var result = [];
|
|
666
|
+
for(var i = 0; i < node.elements.length; i++){
|
|
667
|
+
var element = node.elements.at(i);
|
|
668
|
+
var value = this.visit(element);
|
|
669
|
+
if ("SpreadElement" === element.type) {
|
|
670
|
+
var _result;
|
|
671
|
+
(_result = result).push.apply(_result, Evaluator_to_consumable_array(value));
|
|
672
|
+
} else result.push(value);
|
|
673
|
+
}
|
|
674
|
+
return result;
|
|
675
|
+
}
|
|
676
|
+
},
|
|
567
677
|
{
|
|
568
678
|
key: "handleObjectExpression",
|
|
569
679
|
value: function(node) {
|
|
@@ -593,21 +703,6 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
593
703
|
return obj;
|
|
594
704
|
}
|
|
595
705
|
},
|
|
596
|
-
{
|
|
597
|
-
key: "handleArrayExpression",
|
|
598
|
-
value: function(node) {
|
|
599
|
-
var result = [];
|
|
600
|
-
for(var i = 0; i < node.elements.length; i++){
|
|
601
|
-
var element = node.elements.at(i);
|
|
602
|
-
var value = this.visit(element);
|
|
603
|
-
if ("SpreadElement" === element.type) {
|
|
604
|
-
var _result;
|
|
605
|
-
(_result = result).push.apply(_result, _to_consumable_array(value));
|
|
606
|
-
} else result.push(value);
|
|
607
|
-
}
|
|
608
|
-
return result;
|
|
609
|
-
}
|
|
610
|
-
},
|
|
611
706
|
{
|
|
612
707
|
key: "handleSpreadElement",
|
|
613
708
|
value: function(node) {
|
|
@@ -634,10 +729,6 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
634
729
|
key: "handleCallExpression",
|
|
635
730
|
value: function(node) {
|
|
636
731
|
var _this = this;
|
|
637
|
-
if ("MemberExpression" === node.callee.type) {
|
|
638
|
-
var object = this.visit(node.callee.object);
|
|
639
|
-
if (getMutableMethods().has(object)) throw new Error(ERROR_MESSAGES.MUTABLE_METHOD);
|
|
640
|
-
}
|
|
641
732
|
var calledString = getNodeString(node.callee);
|
|
642
733
|
var func = this.visit(node.callee);
|
|
643
734
|
if ("function" != typeof func) {
|
|
@@ -646,6 +737,10 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
646
737
|
throw new TypeError("".concat(calledString, " ").concat(ERROR_MESSAGES.NOT_A_FUNCTION));
|
|
647
738
|
}
|
|
648
739
|
if (func === Function) throw new Error(ERROR_MESSAGES.FUNCTION_CONSTRUCTOR_NOT_ALLOWED);
|
|
740
|
+
if (getBlockedMethods().has(func)) {
|
|
741
|
+
var path = getBlockedMethods().get(func);
|
|
742
|
+
throw new Error("".concat(path, " ").concat(ERROR_MESSAGES.METHOD_NOT_ALLOWED));
|
|
743
|
+
}
|
|
649
744
|
var args = function() {
|
|
650
745
|
if (0 === node.arguments.length) return [];
|
|
651
746
|
var result = [];
|
|
@@ -654,12 +749,11 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
654
749
|
var value = _this.visit(element);
|
|
655
750
|
if ("SpreadElement" === element.type) {
|
|
656
751
|
var _result;
|
|
657
|
-
(_result = result).push.apply(_result,
|
|
752
|
+
(_result = result).push.apply(_result, Evaluator_to_consumable_array(value));
|
|
658
753
|
} else result.push(value);
|
|
659
754
|
}
|
|
660
755
|
return result;
|
|
661
756
|
}();
|
|
662
|
-
if (getMutableMethods().has(func)) throw new Error(ERROR_MESSAGES.MUTABLE_METHOD);
|
|
663
757
|
var target = "MemberExpression" === node.callee.type ? this.visit(node.callee.object) : null;
|
|
664
758
|
return func.apply(target, args);
|
|
665
759
|
}
|
|
@@ -897,6 +991,6 @@ function evalTemplate(template, context, templateParserOptions) {
|
|
|
897
991
|
}
|
|
898
992
|
return result;
|
|
899
993
|
}
|
|
900
|
-
export { Evaluator_Evaluator as Evaluator, evalExpression, evalTemplate };
|
|
994
|
+
export { Evaluator_Evaluator as Evaluator, TemplateParser_TemplateParser as TemplateParser, evalExpression, evalTemplate };
|
|
901
995
|
|
|
902
996
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm/index.mjs","sources":["../../src/mutableMethods.js","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["export const mutableMethods = [\n\t\"Array.prototype.push\",\n\t\"Array.prototype.pop\",\n\t\"Array.prototype.shift\",\n\t\"Array.prototype.unshift\",\n\t\"Array.prototype.splice\",\n\t\"Array.prototype.reverse\",\n\t\"Array.prototype.sort\",\n\t\"Array.prototype.fill\",\n\t\"Array.prototype.copyWithin\",\n\n\t\"Object.defineProperty\",\n\t\"Object.defineProperties\",\n\t\"Object.preventExtensions\",\n\t\"Object.seal\",\n\t\"Object.freeze\",\n\t\"Object.setPrototypeOf\",\n\t\"Object.assign\",\n\n\t\"Reflect.set\",\n\t\"Reflect.defineProperty\",\n\t\"Reflect.deleteProperty\",\n\t\"Reflect.setPrototypeOf\",\n\t\"Reflect.preventExtensions\",\n\n\t\"Set.prototype.add\",\n\t\"Set.prototype.delete\",\n\t\"Set.prototype.clear\",\n\t\"WeakSet.prototype.add\",\n\t\"WeakSet.prototype.delete\",\n\n\t\"Map.prototype.set\",\n\t\"Map.prototype.delete\",\n\t\"Map.prototype.clear\",\n\t\"WeakMap.prototype.set\",\n\t\"WeakMap.prototype.delete\",\n\n\t\"Date.prototype.setTime\",\n\t\"Date.prototype.setMilliseconds\",\n\t\"Date.prototype.setUTCSeconds\",\n\t\"Date.prototype.setSeconds\",\n\t\"Date.prototype.setMinutes\",\n\t\"Date.prototype.setHours\",\n\t\"Date.prototype.setDate\",\n\t\"Date.prototype.setMonth\",\n\t\"Date.prototype.setFullYear\",\n\t\"Date.prototype.setYear\",\n\t\"Date.prototype.setUTCMilliseconds\",\n\t\"Date.prototype.setUTCMinutes\",\n\t\"Date.prototype.setUTCHours\",\n\t\"Date.prototype.setUTCDate\",\n\t\"Date.prototype.setUTCMonth\",\n\t\"Date.prototype.setUTCFullYear\",\n\n\t\"RegExp.prototype.compile\",\n\n\t\"Int8Array.prototype.set\",\n\t\"Uint8Array.prototype.set\",\n\t\"Uint8ClampedArray.prototype.set\",\n\t\"Int16Array.prototype.set\",\n\t\"Uint16Array.prototype.set\",\n\t\"Int32Array.prototype.set\",\n\t\"Uint32Array.prototype.set\",\n\t\"Float32Array.prototype.set\",\n\t\"Float64Array.prototype.set\",\n\t\"BigInt64Array.prototype.set\",\n\t\"BigUint64Array.prototype.set\",\n\n\t\"Int8Array.prototype.fill\",\n\t\"Uint8Array.prototype.fill\",\n\t\"Uint8ClampedArray.prototype.fill\",\n\t\"Int16Array.prototype.fill\",\n\t\"Uint16Array.prototype.fill\",\n\t\"Int32Array.prototype.fill\",\n\t\"Uint32Array.prototype.fill\",\n\t\"Float32Array.prototype.fill\",\n\t\"Float64Array.prototype.fill\",\n\t\"BigInt64Array.prototype.fill\",\n\t\"BigUint64Array.prototype.fill\",\n\n\t\"Int8Array.prototype.reverse\",\n\t\"Uint8Array.prototype.reverse\",\n\t\"Uint8ClampedArray.prototype.reverse\",\n\t\"Int16Array.prototype.reverse\",\n\t\"Uint16Array.prototype.reverse\",\n\t\"Int32Array.prototype.reverse\",\n\t\"Uint32Array.prototype.reverse\",\n\t\"Float32Array.prototype.reverse\",\n\t\"Float64Array.prototype.reverse\",\n\t\"BigInt64Array.prototype.reverse\",\n\t\"BigUint64Array.prototype.reverse\",\n\n\t\"Int8Array.prototype.sort\",\n\t\"Uint8Array.prototype.sort\",\n\t\"Uint8ClampedArray.prototype.sort\",\n\t\"Int16Array.prototype.sort\",\n\t\"Uint16Array.prototype.sort\",\n\t\"Int32Array.prototype.sort\",\n\t\"Uint32Array.prototype.sort\",\n\t\"Float32Array.prototype.sort\",\n\t\"Float64Array.prototype.sort\",\n\t\"BigInt64Array.prototype.sort\",\n\t\"BigUint64Array.prototype.sort\",\n\n\t\"Int8Array.prototype.copyWithin\",\n\t\"Uint8Array.prototype.copyWithin\",\n\t\"Uint8ClampedArray.prototype.copyWithin\",\n\t\"Int16Array.prototype.copyWithin\",\n\t\"Uint16Array.prototype.copyWithin\",\n\t\"Int32Array.prototype.copyWithin\",\n\t\"Uint32Array.prototype.copyWithin\",\n\t\"Float32Array.prototype.copyWithin\",\n\t\"Float64Array.prototype.copyWithin\",\n\t\"BigInt64Array.prototype.copyWithin\",\n\t\"BigUint64Array.prototype.copyWithin\",\n\n\t\"ArrayBuffer.prototype.transfer\",\n\t\"ArrayBuffer.prototype.transferToFixedLength\",\n\n\t\"SharedArrayBuffer.prototype.grow\",\n\n\t\"DataView.prototype.setInt8\",\n\t\"DataView.prototype.setUint8\",\n\t\"DataView.prototype.setInt16\",\n\t\"DataView.prototype.setUint16\",\n\t\"DataView.prototype.setInt32\",\n\t\"DataView.prototype.setUint32\",\n\t\"DataView.prototype.setFloat32\",\n\t\"DataView.prototype.setFloat64\",\n\t\"DataView.prototype.setBigInt64\",\n\t\"DataView.prototype.setBigUint64\",\n\n\t\"Promise.prototype.catch\",\n\t\"Promise.prototype.finally\",\n\n\t\"Generator.prototype.next\",\n\t\"Generator.prototype.return\",\n\t\"Generator.prototype.throw\",\n\n\t\"AsyncGenerator.prototype.next\",\n\t\"AsyncGenerator.prototype.return\",\n\t\"AsyncGenerator.prototype.throw\",\n\n\t\"Iterator.prototype.next\",\n\n\t\"WeakRef.prototype.deref\",\n\n\t\"FinalizationRegistry.prototype.register\",\n\t\"FinalizationRegistry.prototype.unregister\",\n\n\t\"URLSearchParams.prototype.append\",\n\t\"URLSearchParams.prototype.delete\",\n\t\"URLSearchParams.prototype.set\",\n\t\"URLSearchParams.prototype.sort\",\n\n\t\"FormData.prototype.append\",\n\t\"FormData.prototype.delete\",\n\t\"FormData.prototype.set\",\n\n\t\"Headers.prototype.append\",\n\t\"Headers.prototype.delete\",\n\t\"Headers.prototype.set\",\n];\n","import * as acorn from \"acorn\";\nimport globals from \"globals\";\nimport { mutableMethods } from \"./mutableMethods.js\";\n\n// Error message constants for better maintainability\nconst ERROR_MESSAGES = {\n\tDELETE_NOT_SUPPORTED: \"Delete operator is not allow\",\n\tMUTABLE_METHOD: \"Mutable method is not allowed\",\n\tNEW_FUNCTION_NOT_ALLOWED: \"Cannot use new with Function constructor\",\n\tNOT_A_FUNCTION: \"is not a function\",\n\tPROPERTY_READ_ERROR: \"Cannot read property\",\n\tVARIABLE_NOT_DEFINED: \"is not defined\",\n\tFUNCTION_CONSTRUCTOR_NOT_ALLOWED: \"Function constructor is not allowed\",\n\tTHIS_NOT_ALLOWED: \"'this' keyword is not allowed\",\n\tNOT_A_VALID_SYNTAX: \"is not a valid syntax\",\n};\n\nconst BINARY_OPERATION_MAP = {\n\t\"+\": (a, b) => a + b,\n\t\"-\": (a, b) => a - b,\n\t\"*\": (a, b) => a * b,\n\t\"**\": (a, b) => a ** b,\n\t\"==\": (a, b) => a == b,\n\t\"===\": (a, b) => a === b,\n\t\"!=\": (a, b) => a != b,\n\t\"!==\": (a, b) => a !== b,\n\t\">\": (a, b) => a > b,\n\t\">=\": (a, b) => a >= b,\n\t\"<\": (a, b) => a < b,\n\t\"<=\": (a, b) => a <= b,\n\t\"%\": (a, b) => a % b,\n\t\"/\": (a, b) => a / b,\n\t\"|\": (a, b) => a | b,\n\t\"&\": (a, b) => a & b,\n\t\"^\": (a, b) => a ^ b,\n\t\"<<\": (a, b) => a << b,\n\t\">>\": (a, b) => a >> b,\n\t\">>>\": (a, b) => a >>> b,\n\tin: (a, b) => a in b,\n\tinstanceof: (a, b) => a instanceof b,\n};\n\nfunction createGlobalScope() {\n\tconst scope = Object.create(null);\n\tconst { builtin } = globals;\n\n\tObject.keys(builtin).forEach((key) => {\n\t\tif (key in globalThis && key !== \"eval\" && key !== \"globalThis\") {\n\t\t\tconst isWritable = builtin[key];\n\n\t\t\tObject.defineProperty(scope, key, {\n\t\t\t\tvalue: globalThis[key],\n\t\t\t\twritable: isWritable,\n\t\t\t\tenumerable: false,\n\t\t\t\tconfigurable: false,\n\t\t\t});\n\t\t}\n\t});\n\n\tObject.defineProperty(scope, \"globalThis\", {\n\t\tvalue: scope,\n\t\twritable: false,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n\n\treturn scope;\n}\n\n/** @type {() => Set<Function>} */\nconst getMutableMethods = (() => {\n\tlet MUTABLE_METHODS = null;\n\n\treturn () => {\n\t\tif (MUTABLE_METHODS) return MUTABLE_METHODS;\n\n\t\tconst set = new Set();\n\t\tfor (const path of mutableMethods) {\n\t\t\tconst [object, ...properties] = path.split(\".\");\n\t\t\tlet current = globalThis[object];\n\t\t\tfor (const prop of properties) {\n\t\t\t\tif (current && Object.hasOwn(current, prop)) {\n\t\t\t\t\tcurrent = current[prop];\n\t\t\t\t} else {\n\t\t\t\t\tcurrent = null;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof current === \"function\") set.add(current);\n\t\t}\n\t\tMUTABLE_METHODS = set;\n\t\treturn MUTABLE_METHODS;\n\t};\n})();\n\n/**\n * A JavaScript expression evaluator that safely evaluates expressions within a sandboxed environment.\n * Supports various JavaScript features including arithmetic, logical operations, functions, and more.\n *\n * Security features:\n * - Blocks mutable methods to prevent side effects\n * - No access to eval() or Function() constructor\n * - Sandboxed scope with limited global objects\n *\n * @example\n * const evaluator = new Evaluator({ x: 10, y: 20 });\n * evaluator.evaluate('x + y') // returns 30\n */\nexport class Evaluator {\n\t/**\n\t * Creates a new Evaluator instance with a custom variable context.\n\t * The scope hierarchy is: user variables -> global scope\n\t * @param {Object} [variables={}] - An optional object containing variables to make available in the evaluation context\n\t */\n\tconstructor(variables = {}) {\n\t\tthis.scopes = [variables, createGlobalScope()];\n\t\tthis.source = undefined;\n\t}\n\n\t/**\n\t * Evaluates a JavaScript expression with an optional context.\n\t * @param {string} expression\n\t * @param {unknown} [context]\n\t * @returns\n\t */\n\tstatic evaluate(expression, context) {\n\t\tconst evaluator = new Evaluator(context);\n\t\treturn evaluator.evaluate(expression);\n\t}\n\n\t/**\n\t * Parses and evaluates a JavaScript expression using acorn parser.\n\t * @param {string} expression - The JavaScript expression to evaluate\n\t * @returns {*} The result of the evaluation\n\t * @throws {SyntaxError} If the expression has invalid syntax\n\t * @throws {ReferenceError} If referencing undefined variables\n\t * @throws {TypeError} If performing invalid operations\n\t */\n\tevaluate(expression) {\n\t\tthis.source = expression;\n\n\t\tconst ast = acorn.parse(expression, { ecmaVersion: \"latest\" });\n\n\t\t// Start recursive evaluation from the root node\n\t\ttry {\n\t\t\treturn this.execute(ast.body);\n\t\t} finally {\n\t\t\tthis.source = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Executes an array of AST body nodes sequentially.\n\t * @private\n\t * @param {Array} body - Array of AST nodes to execute\n\t * @returns {*} The result of the last executed node\n\t */\n\texecute(body) {\n\t\tlet result;\n\t\tfor (const node of body) {\n\t\t\tresult = this.visit(node);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Visits an AST node and delegates to the appropriate handler based on node type.\n\t * @private\n\t * @param {Object} node - The AST node to visit\n\t * @returns {*} The result of visiting the node\n\t */\n\tvisit(node) {\n\t\tswitch (node.type) {\n\t\t\tcase \"ExpressionStatement\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"BinaryExpression\": {\n\t\t\t\treturn this.handleBinaryExpression(node);\n\t\t\t}\n\t\t\tcase \"LogicalExpression\": {\n\t\t\t\treturn this.handleLogicalExpression(node);\n\t\t\t}\n\t\t\tcase \"UnaryExpression\": {\n\t\t\t\treturn this.handleUnaryExpression(node);\n\t\t\t}\n\t\t\tcase \"Identifier\": {\n\t\t\t\treturn this.handleIdentifier(node);\n\t\t\t}\n\t\t\tcase \"Literal\": {\n\t\t\t\treturn node.value;\n\t\t\t}\n\t\t\tcase \"MemberExpression\": {\n\t\t\t\treturn this.handleMemberExpression(node);\n\t\t\t}\n\t\t\tcase \"ObjectExpression\": {\n\t\t\t\treturn this.handleObjectExpression(node);\n\t\t\t}\n\t\t\tcase \"ArrayExpression\": {\n\t\t\t\treturn this.handleArrayExpression(node);\n\t\t\t}\n\t\t\tcase \"SpreadElement\": {\n\t\t\t\treturn this.handleSpreadElement(node);\n\t\t\t}\n\t\t\tcase \"ObjectExpression\": {\n\t\t\t\treturn this.handleObjectExpression(node);\n\t\t\t}\n\t\t\tcase \"ArrowFunctionExpression\": {\n\t\t\t\treturn this.handleArrowFunctionExpression(node);\n\t\t\t}\n\t\t\tcase \"CallExpression\": {\n\t\t\t\treturn this.handleCallExpression(node);\n\t\t\t}\n\t\t\tcase \"ConditionalExpression\": {\n\t\t\t\treturn this.visit(node.test) ? this.visit(node.consequent) : this.visit(node.alternate);\n\t\t\t}\n\t\t\tcase \"NewExpression\": {\n\t\t\t\tif (node.callee.type !== \"Identifier\") {\n\t\t\t\t\tthrow new Error(`Unsupported callee type '${node.callee.type}' in new expression`);\n\t\t\t\t}\n\n\t\t\t\tif (node.callee.name === \"Function\") {\n\t\t\t\t\tthrow new Error(ERROR_MESSAGES.NEW_FUNCTION_NOT_ALLOWED);\n\t\t\t\t}\n\n\t\t\t\tconst Constructor = this.visit(node.callee);\n\n\t\t\t\t// 仅在存在参数时构建数组\n\t\t\t\tconst args = node.arguments.length ? node.arguments.map((arg) => this.visit(arg)) : [];\n\n\t\t\t\treturn new Constructor(...args);\n\t\t\t}\n\t\t\tcase \"ChainExpression\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"TemplateLiteral\": {\n\t\t\t\treturn this.handleTemplateLiteral(node);\n\t\t\t}\n\t\t\tcase \"ThisExpression\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.THIS_NOT_ALLOWED);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tlet content = this.source.slice(node.start, node.end);\n\n\t\t\t\tif (content.length > 20) {\n\t\t\t\t\tcontent = content.slice(0, 17) + \"...\";\n\t\t\t\t}\n\n\t\t\t\tthrow new Error(`'${content}'` + \" \" + ERROR_MESSAGES.NOT_A_VALID_SYNTAX);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles binary expressions (arithmetic and comparison operations).\n\t * @param {import('acorn').BinaryExpression} node\n\t * @private\n\t */\n\thandleBinaryExpression(node) {\n\t\tconst op = node.operator;\n\t\tconst left = this.visit(node.left);\n\t\tconst right = this.visit(node.right);\n\n\t\tif (BINARY_OPERATION_MAP.hasOwnProperty(op)) {\n\t\t\treturn BINARY_OPERATION_MAP[op](left, right);\n\t\t}\n\n\t\tthrow new Error(`Unsupported operator: ${node.operator}`);\n\t}\n\n\t/**\n\t * Handles logical expressions (&&, ||, ??).\n\t * Implements proper short-circuit evaluation for performance.\n\t * @private\n\t */\n\thandleLogicalExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"&&\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? this.visit(node.right) : left;\n\t\t\t}\n\t\t\tcase \"||\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tcase \"??\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left !== null && left !== undefined ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported logical operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles unary expressions (-, +, !, ~, typeof, void).\n\t * @private\n\t */\n\thandleUnaryExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"-\": {\n\t\t\t\treturn -this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"+\": {\n\t\t\t\treturn +this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"!\": {\n\t\t\t\treturn !this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"~\": {\n\t\t\t\treturn ~this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"typeof\": {\n\t\t\t\treturn typeof this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\treturn void this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.DELETE_NOT_SUPPORTED);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported unary operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles identifier (variable) lookups in the scope chain.\n\t * @private\n\t */\n\thandleIdentifier(node) {\n\t\tconst name = node.name;\n\t\tfor (const scope of this.scopes) {\n\t\t\tif (Object.hasOwn(scope, name)) {\n\t\t\t\treturn scope[name];\n\t\t\t}\n\t\t}\n\n\t\tthrow new ReferenceError(`${name} ${ERROR_MESSAGES.VARIABLE_NOT_DEFINED}`);\n\t}\n\n\t/**\n\t * Handles member expressions (property access like obj.prop or obj[prop]).\n\t * @private\n\t */\n\thandleMemberExpression(node) {\n\t\tconst object = this.visit(node.object);\n\n\t\t// Determine property name: either identifier name or computed value\n\t\tconst isStaticProperty = node.property.type === \"Identifier\" && !node.computed;\n\t\tconst property = isStaticProperty ? node.property.name : this.visit(node.property);\n\n\t\tif (object === null || object === undefined) {\n\t\t\t// optional chaining\n\t\t\tif (node.optional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(`${ERROR_MESSAGES.PROPERTY_READ_ERROR} '${property}' of ${object}`);\n\t\t}\n\n\t\treturn object[property];\n\t}\n\n\t/**\n\t * Handles object literal expressions.\n\t * @private\n\t */\n\thandleObjectExpression(node) {\n\t\tconst obj = {};\n\t\tfor (const prop of node.properties) {\n\t\t\tconst key = prop.key.name || prop.key.value;\n\t\t\tconst value = this.visit(prop.value);\n\t\t\tobj[key] = value;\n\t\t}\n\t\treturn obj;\n\t}\n\n\t/**\n\t * Handles array literal expressions.\n\t * @private\n\t */\n\thandleArrayExpression(node) {\n\t\tconst result = [];\n\n\t\tfor (let i = 0; i < node.elements.length; i++) {\n\t\t\tconst element = node.elements.at(i);\n\t\t\tconst value = this.visit(element);\n\n\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\tresult.push(...value);\n\t\t\t} else {\n\t\t\t\tresult.push(value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles object literal expressions.\n\t * @returns\n\t */\n\thandleObjectExpression(node) {\n\t\tconst obj = {};\n\t\tfor (const prop of node.properties) {\n\t\t\tif (prop.type === \"SpreadElement\") {\n\t\t\t\tObject.assign(obj, this.visit(prop.argument));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = prop.key.name || prop.key.value;\n\t\t\tconst value = this.visit(prop.value);\n\t\t\tobj[key] = value;\n\t\t}\n\t\treturn obj;\n\t}\n\n\thandleSpreadElement(node) {\n\t\treturn this.visit(node.argument);\n\t}\n\n\t/**\n\t * Handles arrow function expressions.\n\t * Creates a closure that captures the current scope and executes the function body\n\t * with parameters bound to a new scope.\n\t * @private\n\t */\n\thandleArrowFunctionExpression(node) {\n\t\treturn (...args) => {\n\t\t\t// Create new scope with parameters bound to arguments\n\t\t\tconst newScope = {};\n\t\t\tconst paramCount = node.params.length;\n\t\t\tfor (let i = 0; i < paramCount; i++) {\n\t\t\t\tnewScope[node.params[i].name] = args[i];\n\t\t\t}\n\n\t\t\t// Push new scope, evaluate body, then pop scope\n\t\t\tthis.scopes.unshift(newScope);\n\t\t\tconst result = this.visit(node.body);\n\t\t\tthis.scopes.shift();\n\t\t\treturn result;\n\t\t};\n\t}\n\n\t/**\n\t * Handles function call expressions, including optional chaining.\n\t * @private\n\t */\n\thandleCallExpression(node) {\n\t\t// 移除对 callee.object 的冗余检查,避免重复求值与错误集合匹配\n\t\tif (node.callee.type === \"MemberExpression\") {\n\t\t\tconst object = this.visit(node.callee.object);\n\t\t\tif (getMutableMethods().has(object)) {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.MUTABLE_METHOD);\n\t\t\t}\n\t\t}\n\n\t\tconst calledString = getNodeString(node.callee);\n\n\t\tconst func = this.visit(node.callee);\n\n\t\tif (typeof func !== \"function\") {\n\t\t\tconst isOptional = node.optional || node.callee.optional;\n\t\t\tif ((func === undefined || func === null) && isOptional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(`${calledString} ${ERROR_MESSAGES.NOT_A_FUNCTION}`);\n\t\t}\n\n\t\tif (func === Function) {\n\t\t\tthrow new Error(ERROR_MESSAGES.FUNCTION_CONSTRUCTOR_NOT_ALLOWED);\n\t\t}\n\n\t\t// 仅在存在参数时构建数组\n\t\tconst args = (() => {\n\t\t\tif (node.arguments.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tlet result = [];\n\n\t\t\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\t\t\tconst element = node.arguments.at(i);\n\t\t\t\tconst value = this.visit(element);\n\n\t\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\t\tresult.push(...value);\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t})();\n\n\t\tif (getMutableMethods().has(func)) {\n\t\t\tthrow new Error(ERROR_MESSAGES.MUTABLE_METHOD);\n\t\t}\n\n\t\tconst target = node.callee.type === \"MemberExpression\" ? this.visit(node.callee.object) : null;\n\t\treturn func.apply(target, args);\n\t}\n\n\t/**\n\t * Handles template literal expressions.\n\t * More efficient implementation that interleaves quasis and expressions without sorting.\n\t * @private\n\t */\n\thandleTemplateLiteral(node) {\n\t\tlet result = \"\";\n\t\tconst expressionCount = node.expressions.length;\n\n\t\tfor (let i = 0; i < node.quasis.length; i++) {\n\t\t\tresult += node.quasis[i].value.raw;\n\t\t\tif (i < expressionCount) {\n\t\t\t\tresult += this.visit(node.expressions[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n/**\n *\n * @param {import('acorn').Node} node\n * @returns\n */\nexport function getNodeString(node) {\n\tswitch (node.type) {\n\t\tcase \"Identifier\": {\n\t\t\treturn node.name;\n\t\t}\n\t\tcase \"Literal\": {\n\t\t\treturn node.raw;\n\t\t}\n\t\tcase \"ArrayExpression\": {\n\t\t\treturn `[${node.elements.map((child) => getNodeString(child)).join(\",\")}]`;\n\t\t}\n\t\tcase \"ObjectExpression\": {\n\t\t\t// if keys is empty\n\t\t\tif (node.properties.length === 0) {\n\t\t\t\treturn \"{}\";\n\t\t\t}\n\n\t\t\treturn \"{(intermediate value)}\";\n\t\t}\n\t\tcase \"MemberExpression\": {\n\t\t\tconst objectStr = getNodeString(node.object);\n\t\t\tconst propertyStr = getNodeString(node.property);\n\n\t\t\tif (node.computed) {\n\t\t\t\treturn `${objectStr}[${propertyStr}]`;\n\t\t\t}\n\t\t\treturn `${objectStr}.${propertyStr}`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","/**\n * 简单状态机模板解析器\n * 能够正确处理表达式中包含字符串、转义字符和结束标记的情况\n * @class SimpleStateTemplateParser\n */\nclass TemplateParser {\n\t/**\n\t * 创建解析器实例\n\t * @param {Object} [options] - 配置选项\n\t * @param {string} [options.expressionStart='{{'] - 表达式开始标记\n\t * @param {string} [options.expressionEnd='}}'] - 表达式结束标记\n\t * @param {boolean} [options.preserveWhitespace=true] - 是否保留表达式周围的空白字符\n\t */\n\tconstructor(options = {}) {\n\t\t// 表达式标记配置\n\t\tthis.exprStart = options.expressionStart || \"{{\";\n\t\tthis.exprEnd = options.expressionEnd || \"}}\";\n\n\t\t// 标记长度缓存,避免重复计算\n\t\tthis.startLen = this.exprStart.length;\n\t\tthis.endLen = this.exprEnd.length;\n\n\t\t// 其他配置\n\t\tthis.preserveWhitespace = options.preserveWhitespace === true;\n\t}\n\n\t/**\n\t * 解析模板字符串,将其转换为 token 数组\n\t * @param {string} template - 要解析的模板字符串\n\t * @returns {Array<{type: string, value: string}>} token 数组\n\t */\n\tparse(template) {\n\t\t// 输入验证\n\t\tif (typeof template !== \"string\") {\n\t\t\tthrow new TypeError(\"模板必须是字符串\");\n\t\t}\n\n\t\tconst tokens = []; // 存储解析结果的 token 数组\n\t\tconst length = template.length;\n\n\t\t// 状态机变量\n\t\tlet state = \"TEXT\"; // 当前状态:TEXT | EXPR | STRING_SQ | STRING_DQ | TEMPLATE | ESCAPE_*\n\t\tlet buffer = \"\"; // 当前状态的字符缓冲区\n\t\tlet exprStartPos = 0; // 当前表达式的开始位置(用于错误恢复)\n\t\tlet pos = 0; // 当前扫描位置\n\n\t\t// 主解析循环:逐个字符扫描模板\n\t\twhile (pos < length) {\n\t\t\tconst char = template[pos];\n\t\t\tconst nextChar = template[pos + 1];\n\n\t\t\t// 状态机核心逻辑\n\t\t\tswitch (state) {\n\t\t\t\t// ==================== 文本状态 ====================\n\t\t\t\tcase \"TEXT\":\n\t\t\t\t\t// 检查是否遇到表达式开始标记\n\t\t\t\t\tif (this._isMatch(pos, template, this.exprStart)) {\n\t\t\t\t\t\t// 将缓冲区中的文本保存为 token\n\t\t\t\t\t\tif (buffer.length > 0) {\n\t\t\t\t\t\t\ttokens.push({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 切换到表达式状态\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t\texprStartPos = pos; // 记录表达式开始位置\n\t\t\t\t\t\tpos += this.startLen; // 跳过开始标记\n\t\t\t\t\t\tcontinue; // 继续处理下一个字符(跳过本次循环的剩余部分)\n\t\t\t\t\t}\n\t\t\t\t\t// 普通文本字符,添加到缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 表达式状态 ====================\n\t\t\t\tcase \"EXPR\":\n\t\t\t\t\t// 在表达式中,需要处理各种字符串和转义字符\n\t\t\t\t\tif (char === \"'\") {\n\t\t\t\t\t\t// 进入单引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_SQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\t// 进入双引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\t// 进入模板字符串状态\n\t\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\t} else if (char === \"\\\\\") {\n\t\t\t\t\t\t// 遇到转义字符,根据当前上下文进入相应的转义状态\n\t\t\t\t\t\tif (nextChar === \"'\") state = \"ESCAPE_SQ\";\n\t\t\t\t\t\telse if (nextChar === '\"') state = \"ESCAPE_DQ\";\n\t\t\t\t\t\telse if (nextChar === \"`\") state = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t\telse state = \"ESCAPE_EXPR\";\n\t\t\t\t\t} else if (this._isMatch(pos, template, this.exprEnd)) {\n\t\t\t\t\t\t// 找到表达式结束标记,且不在字符串中\n\t\t\t\t\t\tconst exprValue = this.preserveWhitespace ? buffer : buffer.trim();\n\t\t\t\t\t\tif (exprValue.length > 0) {\n\t\t\t\t\t\t\ttokens.push({\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\tvalue: exprValue,\n\t\t\t\t\t\t\t\tstart: exprStartPos,\n\t\t\t\t\t\t\t\tend: pos + this.endLen,\n\t\t\t\t\t\t\t\tcontentStart: exprStartPos + this.startLen,\n\t\t\t\t\t\t\t\tcontentEnd: pos,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 重置状态,准备处理后续文本\n\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\tstate = \"TEXT\";\n\t\t\t\t\t\tpos += this.endLen; // 跳过结束标记\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// 将当前字符添加到表达式缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 字符串状态 ====================\n\t\t\t\tcase \"STRING_SQ\": // 单引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_SQ\"; // 遇到转义字符\n\t\t\t\t\t} else if (char === \"'\") {\n\t\t\t\t\t\tstate = \"EXPR\"; // 字符串结束,回到表达式状态\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"STRING_DQ\": // 双引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_DQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"TEMPLATE\": // 模板字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 转义状态 ====================\n\t\t\t\t// 转义状态:处理转义字符,然后返回到之前的状态\n\t\t\t\tcase \"ESCAPE_SQ\":\n\t\t\t\t\tbuffer += char; // 添加转义后的字符\n\t\t\t\t\tstate = \"STRING_SQ\"; // 回到单引号字符串状态\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_DQ\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_TEMPLATE\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_EXPR\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// 移动到下一个字符\n\t\t\tpos++;\n\t\t}\n\n\t\t// ==================== 后处理 ====================\n\t\t// 处理扫描结束后缓冲区中剩余的内容\n\t\tif (buffer.length > 0) {\n\t\t\tif (state === \"TEXT\") {\n\t\t\t\t// 剩余的文本内容\n\t\t\t\ttokens.push({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t} else {\n\t\t\t\t// 未完成的表达式,将其作为普通文本处理\n\t\t\t\t// 这里可以根据需要选择不同的错误处理策略:\n\t\t\t\t// 1. 抛出错误\n\t\t\t\t// 2. 忽略未完成的表达式\n\t\t\t\t// 3. 将其作为文本处理(当前实现)\n\t\t\t\tconst incompleteExpr = this.exprStart + buffer;\n\t\t\t\ttokens.push({ type: \"text\", value: incompleteExpr, start: exprStartPos, end: pos });\n\n\t\t\t\t// 可选:输出警告\n\t\t\t\tconsole.warn(`警告:在位置 ${exprStartPos} 开始的表达式未正确结束`);\n\t\t\t}\n\t\t}\n\n\t\treturn tokens;\n\t}\n\n\t/**\n\t * 检查指定位置是否匹配给定的字符序列\n\t * @param {number} pos - 开始检查的位置\n\t * @param {string} template - 模板字符串\n\t * @param {string} sequence - 要匹配的字符序列\n\t * @returns {boolean} 是否匹配\n\t * @private\n\t */\n\t_isMatch(pos, template, sequence) {\n\t\t// 检查剩余长度是否足够\n\t\tif (pos + sequence.length > template.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// 逐个字符比较\n\t\tfor (let i = 0; i < sequence.length; i++) {\n\t\t\tif (template[pos + i] !== sequence[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * 静态方法:快速解析模板\n\t * @param {string} template - 模板字符串\n\t * @param {Object} [options] - 配置选项\n\t * @returns {Array} token 数组\n\t */\n\tstatic parse(template, options) {\n\t\tconst parser = new TemplateParser(options);\n\t\treturn parser.parse(template);\n\t}\n}\n\nexport { TemplateParser };\n","import { Evaluator } from \"./Evaluator.js\";\nimport { TemplateParser } from \"./TemplateParser.js\";\n\nexport { Evaluator };\n\n/**\n * Evaluates a JavaScript expression with an optional context.\n * @param {string} expression - The JavaScript expression to evaluate\n * @param {unknown} [context] - Optional context object with variables to use in the expression\n * @returns {*} The result of evaluating the expression\n * @example\n * evalExpression('a + b', { a: 1, b: 2 }) // returns 3\n */\nexport function evalExpression(expression, context) {\n\treturn Evaluator.evaluate(expression, context);\n}\n\n/**\n * Evaluates a template string by replacing {{ expression }} patterns with their evaluated values.\n * Undefined variables in expressions are replaced with empty strings instead of throwing errors.\n * @param {string} template - The template string containing {{ expression }} patterns\n * @param {Object} [context] - Optional context object with variables to use in expressions\n * @param {Object} [templateParserOptions] - Optional options for the template parser\n * @returns {string} The template with all expressions evaluated and replaced\n * @example\n * evalTemplate('Hello {{ name }}!', { name: 'World' }) // returns 'Hello World!'\n */\nexport function evalTemplate(template, context, templateParserOptions) {\n\tlet result = \"\";\n\n\tfor (const token of TemplateParser.parse(template, templateParserOptions)) {\n\t\tif (token.type === \"text\") {\n\t\t\tresult += token.value;\n\t\t} else if (token.type === \"expression\") {\n\t\t\ttry {\n\t\t\t\tresult += Evaluator.evaluate(token.value, context);\n\t\t\t} catch (error) {\n\t\t\t\t// Replace undefined variables with empty string for graceful degradation\n\t\t\t\tif (error instanceof ReferenceError && error.message.endsWith(\"is not defined\")) {\n\t\t\t\t\tresult += \"undefined\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"names":["mutableMethods","ERROR_MESSAGES","BINARY_OPERATION_MAP","a","b","_instanceof","createGlobalScope","scope","Object","builtin","globals","key","globalThis","isWritable","getMutableMethods","MUTABLE_METHODS","set","Set","_iteratorError","path","_path_split","object","properties","current","_iteratorError1","prop","Evaluator","variables","undefined","evaluate","expression","ast","acorn","execute","body","result","node","visit","Error","Constructor","args","arg","content","handleBinaryExpression","op","left","right","handleLogicalExpression","left1","left2","handleUnaryExpression","_type_of","handleIdentifier","name","ReferenceError","handleMemberExpression","isStaticProperty","property","TypeError","handleObjectExpression","obj","value","handleArrayExpression","i","element","_result","handleSpreadElement","handleArrowFunctionExpression","newScope","paramCount","handleCallExpression","calledString","getNodeString","func","isOptional","Function","target","handleTemplateLiteral","expressionCount","context","evaluator","child","objectStr","propertyStr","TemplateParser","options","parse","template","tokens","length","state","buffer","exprStartPos","pos","char","nextChar","exprValue","incompleteExpr","console","_isMatch","sequence","parser","evalExpression","evalTemplate","templateParserOptions","token","error"],"mappings":";;AAAO,IAAMA,iBAAiB;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;IAEA;IAEA;IAEA;IACA;IAEA;IACA;IACA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7JD,IAAMC,iBAAiB;IACtB,sBAAsB;IACtB,gBAAgB;IAChB,0BAA0B;IAC1B,gBAAgB;IAChB,qBAAqB;IACrB,sBAAsB;IACtB,kCAAkC;IAClC,kBAAkB;IAClB,oBAAoB;AACrB;AAEA,IAAMC,uBAAuB;IAC5B,KAAK,SAACC,CAAC,EAAEC,CAAC;eAAKD,IA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","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["const mutableMethods = [\n\t\"Array.prototype.push\",\n\t\"Array.prototype.pop\",\n\t\"Array.prototype.shift\",\n\t\"Array.prototype.unshift\",\n\t\"Array.prototype.splice\",\n\t\"Array.prototype.reverse\",\n\t\"Array.prototype.sort\",\n\t\"Array.prototype.fill\",\n\t\"Array.prototype.copyWithin\",\n\n\t\"Object.defineProperty\",\n\t\"Object.defineProperties\",\n\t\"Object.preventExtensions\",\n\t\"Object.seal\",\n\t\"Object.freeze\",\n\t\"Object.setPrototypeOf\",\n\t\"Object.assign\",\n\t\"Object.prototype.__defineGetter__\",\n\t\"Object.prototype.__defineSetter__\",\n\n\t\"Reflect.set\",\n\t\"Reflect.defineProperty\",\n\t\"Reflect.deleteProperty\",\n\t\"Reflect.setPrototypeOf\",\n\t\"Reflect.preventExtensions\",\n\n\t\"Set.prototype.add\",\n\t\"Set.prototype.delete\",\n\t\"Set.prototype.clear\",\n\t\"WeakSet.prototype.add\",\n\t\"WeakSet.prototype.delete\",\n\n\t\"Map.prototype.set\",\n\t\"Map.prototype.delete\",\n\t\"Map.prototype.clear\",\n\t\"WeakMap.prototype.set\",\n\t\"WeakMap.prototype.delete\",\n\n\t\"Date.prototype.setTime\",\n\t\"Date.prototype.setMilliseconds\",\n\t\"Date.prototype.setUTCSeconds\",\n\t\"Date.prototype.setSeconds\",\n\t\"Date.prototype.setMinutes\",\n\t\"Date.prototype.setHours\",\n\t\"Date.prototype.setDate\",\n\t\"Date.prototype.setMonth\",\n\t\"Date.prototype.setFullYear\",\n\t\"Date.prototype.setYear\",\n\t\"Date.prototype.setUTCMilliseconds\",\n\t\"Date.prototype.setUTCMinutes\",\n\t\"Date.prototype.setUTCHours\",\n\t\"Date.prototype.setUTCDate\",\n\t\"Date.prototype.setUTCMonth\",\n\t\"Date.prototype.setUTCFullYear\",\n\n\t\"RegExp.prototype.compile\",\n\n\t\"Int8Array.prototype.set\",\n\t\"Uint8Array.prototype.set\",\n\t\"Uint8ClampedArray.prototype.set\",\n\t\"Int16Array.prototype.set\",\n\t\"Uint16Array.prototype.set\",\n\t\"Int32Array.prototype.set\",\n\t\"Uint32Array.prototype.set\",\n\t\"Float32Array.prototype.set\",\n\t\"Float64Array.prototype.set\",\n\t\"BigInt64Array.prototype.set\",\n\t\"BigUint64Array.prototype.set\",\n\n\t\"Int8Array.prototype.fill\",\n\t\"Uint8Array.prototype.fill\",\n\t\"Uint8ClampedArray.prototype.fill\",\n\t\"Int16Array.prototype.fill\",\n\t\"Uint16Array.prototype.fill\",\n\t\"Int32Array.prototype.fill\",\n\t\"Uint32Array.prototype.fill\",\n\t\"Float32Array.prototype.fill\",\n\t\"Float64Array.prototype.fill\",\n\t\"BigInt64Array.prototype.fill\",\n\t\"BigUint64Array.prototype.fill\",\n\n\t\"Int8Array.prototype.reverse\",\n\t\"Uint8Array.prototype.reverse\",\n\t\"Uint8ClampedArray.prototype.reverse\",\n\t\"Int16Array.prototype.reverse\",\n\t\"Uint16Array.prototype.reverse\",\n\t\"Int32Array.prototype.reverse\",\n\t\"Uint32Array.prototype.reverse\",\n\t\"Float32Array.prototype.reverse\",\n\t\"Float64Array.prototype.reverse\",\n\t\"BigInt64Array.prototype.reverse\",\n\t\"BigUint64Array.prototype.reverse\",\n\n\t\"Int8Array.prototype.sort\",\n\t\"Uint8Array.prototype.sort\",\n\t\"Uint8ClampedArray.prototype.sort\",\n\t\"Int16Array.prototype.sort\",\n\t\"Uint16Array.prototype.sort\",\n\t\"Int32Array.prototype.sort\",\n\t\"Uint32Array.prototype.sort\",\n\t\"Float32Array.prototype.sort\",\n\t\"Float64Array.prototype.sort\",\n\t\"BigInt64Array.prototype.sort\",\n\t\"BigUint64Array.prototype.sort\",\n\n\t\"Int8Array.prototype.copyWithin\",\n\t\"Uint8Array.prototype.copyWithin\",\n\t\"Uint8ClampedArray.prototype.copyWithin\",\n\t\"Int16Array.prototype.copyWithin\",\n\t\"Uint16Array.prototype.copyWithin\",\n\t\"Int32Array.prototype.copyWithin\",\n\t\"Uint32Array.prototype.copyWithin\",\n\t\"Float32Array.prototype.copyWithin\",\n\t\"Float64Array.prototype.copyWithin\",\n\t\"BigInt64Array.prototype.copyWithin\",\n\t\"BigUint64Array.prototype.copyWithin\",\n\n\t\"ArrayBuffer.prototype.transfer\",\n\t\"ArrayBuffer.prototype.transferToFixedLength\",\n\n\t\"SharedArrayBuffer.prototype.grow\",\n\n\t\"DataView.prototype.setInt8\",\n\t\"DataView.prototype.setUint8\",\n\t\"DataView.prototype.setInt16\",\n\t\"DataView.prototype.setUint16\",\n\t\"DataView.prototype.setInt32\",\n\t\"DataView.prototype.setUint32\",\n\t\"DataView.prototype.setFloat32\",\n\t\"DataView.prototype.setFloat64\",\n\t\"DataView.prototype.setBigInt64\",\n\t\"DataView.prototype.setBigUint64\",\n\n\t\"Promise.prototype.catch\",\n\t\"Promise.prototype.finally\",\n\n\t\"Generator.prototype.next\",\n\t\"Generator.prototype.return\",\n\t\"Generator.prototype.throw\",\n\n\t\"AsyncGenerator.prototype.next\",\n\t\"AsyncGenerator.prototype.return\",\n\t\"AsyncGenerator.prototype.throw\",\n\n\t\"Iterator.prototype.next\",\n\n\t\"WeakRef.prototype.deref\",\n\n\t\"FinalizationRegistry.prototype.register\",\n\t\"FinalizationRegistry.prototype.unregister\",\n\n\t\"URLSearchParams.prototype.append\",\n\t\"URLSearchParams.prototype.delete\",\n\t\"URLSearchParams.prototype.set\",\n\t\"URLSearchParams.prototype.sort\",\n\n\t\"FormData.prototype.append\",\n\t\"FormData.prototype.delete\",\n\t\"FormData.prototype.set\",\n\n\t\"Headers.prototype.append\",\n\t\"Headers.prototype.delete\",\n\t\"Headers.prototype.set\",\n\n\t// Function call/apply/bind can be used to invoke with arbitrary `this`\n\t\"Function.prototype.call\",\n\t\"Function.prototype.apply\",\n\t\"Function.prototype.bind\",\n\t\"Function.prototype.constructor\",\n\n\t// Legacy lookup helpers\n\t\"Object.prototype.__lookupGetter__\",\n\t\"Object.prototype.__lookupSetter__\",\n\n\t// Constructor property can be abused to retrieve the Function constructor\n\t\"Object.prototype.constructor\",\n];\n\nconst dangerousMethods = [\n\t\"Object.getPrototypeOf\",\n\t// Various reflective/object-inspection APIs that may expose internals\n\t\"Object.getOwnPropertyDescriptor\",\n\t\"Object.getOwnPropertyDescriptors\",\n\t\"Object.getOwnPropertyNames\",\n\t\"Object.getOwnPropertySymbols\",\n\t\"Object.getOwnPropertyDescriptors\",\n];\n\n// Some prototype-style aliases/properties that can be used to break sandboxes\nmutableMethods.push(\"Object.prototype.__proto__\");\n\n/**\n * List of methods to block due to mutability or dangerousness\n */\nexport const blockedMethods = [...mutableMethods, ...dangerousMethods];\n\n/**\n * List of global built-ins to block entirely\n */\nexport const blockedGlobalBuiltIns = [\n\t\"Function\",\n\t\"GeneratorFunction\",\n\t\"AsyncFunction\",\n\t\"AsyncGeneratorFunction\",\n\t\"eval\",\n\t\"setTimeout\",\n\t\"setInterval\",\n\t\"clearTimeout\",\n\t\"clearInterval\",\n\t\"setImmediate\",\n\t\"XMLHttpRequest\",\n\t\"fetch\",\n\t\"WebSocket\",\n\t\"globalThis\",\n\n\t// Node / runtime globals\n\t\"process\",\n\t\"require\",\n\t\"module\",\n\t\"exports\",\n\t\"global\",\n\t\"Buffer\",\n\t\"setImmediate\",\n\t\"clearImmediate\",\n\n\t// Worker / threading / messaging\n\t\"importScripts\",\n\t\"Worker\",\n\t\"SharedWorker\",\n\t\"ServiceWorker\",\n\t\"BroadcastChannel\",\n\t\"MessageChannel\",\n\t\"MessagePort\",\n\t\"postMessage\",\n\n\t// Host environment globals (browser)\n\t\"window\",\n\t\"document\",\n\t\"navigator\",\n\t\"location\",\n\t\"localStorage\",\n\t\"sessionStorage\",\n\t\"indexedDB\",\n\t\"performance\",\n\n\t// Low-level / concurrent / binary APIs\n\t\"Proxy\",\n\t\"Reflect\",\n\t\"Atomics\",\n\t\"WebAssembly\",\n\n\t// Console and internationalization\n\t\"console\",\n\t\"Intl\",\n\n\t// Other runtimes\n\t\"Deno\",\n];\n","import * as acorn from \"acorn\";\nimport globals from \"globals\";\nimport { blockedGlobalBuiltIns, blockedMethods } from \"./block.js\";\n\n// Error message constants for better maintainability\nconst ERROR_MESSAGES = {\n\tDELETE_NOT_SUPPORTED: \"Delete operator is not allow\",\n\tNEW_FUNCTION_NOT_ALLOWED: \"Cannot use new with Function constructor\",\n\tNOT_A_FUNCTION: \"is not a function\",\n\tPROPERTY_READ_ERROR: \"Cannot read property\",\n\tVARIABLE_NOT_DEFINED: \"is not defined\",\n\tFUNCTION_CONSTRUCTOR_NOT_ALLOWED: \"Function constructor is not allowed\",\n\tTHIS_NOT_ALLOWED: \"'this' keyword is not allowed\",\n\tNOT_A_VALID_SYNTAX: \"is not a valid syntax\",\n\tACCESSING_PROTOTYPE_NOT_ALLOWED: \"Accessing prototype properties is not allowed\",\n\tWITH_NOT_ALLOWED: \"'with' statement is not allowed\",\n\tFUNCTION_EXPRESSION_NOT_ALLOWED: \"Function expressions are not allowed\",\n\tMETHOD_NOT_ALLOWED: \"is not allowed\",\n};\n\nconst BINARY_OPERATION_MAP = {\n\t\"+\": (a, b) => a + b,\n\t\"-\": (a, b) => a - b,\n\t\"*\": (a, b) => a * b,\n\t\"**\": (a, b) => a ** b,\n\t\"==\": (a, b) => a == b,\n\t\"===\": (a, b) => a === b,\n\t\"!=\": (a, b) => a != b,\n\t\"!==\": (a, b) => a !== b,\n\t\">\": (a, b) => a > b,\n\t\">=\": (a, b) => a >= b,\n\t\"<\": (a, b) => a < b,\n\t\"<=\": (a, b) => a <= b,\n\t\"%\": (a, b) => a % b,\n\t\"/\": (a, b) => a / b,\n\t\"|\": (a, b) => a | b,\n\t\"&\": (a, b) => a & b,\n\t\"^\": (a, b) => a ^ b,\n\t\"<<\": (a, b) => a << b,\n\t\">>\": (a, b) => a >> b,\n\t\">>>\": (a, b) => a >>> b,\n\tin: (a, b) => a in b,\n\tinstanceof: (a, b) => a instanceof b,\n};\n\nfunction createGlobalScope() {\n\tconst scope = Object.create(null);\n\tconst { builtin } = globals;\n\n\tfor (const key in builtin) {\n\t\tif (blockedGlobalBuiltIns.includes(key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** @type {boolean} */\n\t\tconst isWritable = builtin[key];\n\n\t\tObject.defineProperty(scope, key, {\n\t\t\tvalue: globalThis[key],\n\t\t\twritable: isWritable,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(scope, \"globalThis\", {\n\t\tvalue: scope,\n\t\twritable: false,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n\n\treturn scope;\n}\n\nconst getBlockedMethods = (() => {\n\t/**\n\t * @type {Map<Function, string>}\n\t */\n\tlet BLOCKED_METHODS = null;\n\n\treturn () => {\n\t\tif (BLOCKED_METHODS) return BLOCKED_METHODS;\n\n\t\tconst map = new Map();\n\t\tfor (const path of blockedMethods) {\n\t\t\tconst [object, ...properties] = path.split(\".\");\n\t\t\tlet current = globalThis[object];\n\t\t\tfor (const prop of properties) {\n\t\t\t\tif (current && Object.hasOwn(current, prop)) {\n\t\t\t\t\tcurrent = current[prop];\n\t\t\t\t} else {\n\t\t\t\t\tcurrent = null;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof current === \"function\") map.set(current, path);\n\t\t}\n\t\tBLOCKED_METHODS = map;\n\n\t\treturn BLOCKED_METHODS;\n\t};\n})();\n\n/**\n * A JavaScript expression evaluator that safely evaluates expressions within a sandboxed environment.\n * Supports various JavaScript features including arithmetic, logical operations, functions, and more.\n *\n * Security features:\n * - Blocks mutable methods to prevent side effects\n * - No access to eval() or Function() constructor\n * - Sandboxed scope with limited global objects\n *\n * @example\n * const evaluator = new Evaluator({ x: 10, y: 20 });\n * evaluator.evaluate('x + y') // returns 30\n */\nexport class Evaluator {\n\t/**\n\t * Creates a new Evaluator instance with a custom variable context.\n\t * The scope hierarchy is: user variables -> global scope\n\t * @param {Object} [variables={}] - An optional object containing variables to make available in the evaluation context\n\t */\n\tconstructor(variables = {}) {\n\t\tthis.scopes = [variables, createGlobalScope()];\n\t\tthis.source = undefined;\n\t}\n\n\t/**\n\t * Evaluates a JavaScript expression with an optional context.\n\t * @param {string} expression\n\t * @param {unknown} [context]\n\t * @returns\n\t */\n\tstatic evaluate(expression, context) {\n\t\tconst evaluator = new Evaluator(context);\n\t\treturn evaluator.evaluate(expression);\n\t}\n\n\t/**\n\t * Parses and evaluates a JavaScript expression using acorn parser.\n\t * @param {string} expression - The JavaScript expression to evaluate\n\t * @returns {*} The result of the evaluation\n\t * @throws {SyntaxError} If the expression has invalid syntax\n\t * @throws {ReferenceError} If referencing undefined variables\n\t * @throws {TypeError} If performing invalid operations\n\t */\n\tevaluate(expression) {\n\t\tthis.source = expression;\n\n\t\tconst ast = acorn.parse(expression, { ecmaVersion: \"latest\" });\n\n\t\t// Start recursive evaluation from the root node\n\t\ttry {\n\t\t\treturn this.execute(ast.body);\n\t\t} finally {\n\t\t\tthis.source = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Executes an array of AST body nodes sequentially.\n\t * @private\n\t * @param {Array} body - Array of AST nodes to execute\n\t * @returns {*} The result of the last executed node\n\t */\n\texecute(body) {\n\t\tlet result;\n\t\tfor (const node of body) {\n\t\t\tresult = this.visit(node);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Visits an AST node and delegates to the appropriate handler based on node type.\n\t * @private\n\t * @param {Object} node - The AST node to visit\n\t * @returns {*} The result of visiting the node\n\t */\n\tvisit(node) {\n\t\tswitch (node.type) {\n\t\t\tcase \"ExpressionStatement\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"BinaryExpression\": {\n\t\t\t\treturn this.handleBinaryExpression(node);\n\t\t\t}\n\t\t\tcase \"LogicalExpression\": {\n\t\t\t\treturn this.handleLogicalExpression(node);\n\t\t\t}\n\t\t\tcase \"UnaryExpression\": {\n\t\t\t\treturn this.handleUnaryExpression(node);\n\t\t\t}\n\t\t\tcase \"Identifier\": {\n\t\t\t\treturn this.handleIdentifier(node);\n\t\t\t}\n\t\t\tcase \"Literal\": {\n\t\t\t\treturn node.value;\n\t\t\t}\n\t\t\tcase \"MemberExpression\": {\n\t\t\t\treturn this.handleMemberExpression(node);\n\t\t\t}\n\t\t\tcase \"ArrayExpression\": {\n\t\t\t\treturn this.handleArrayExpression(node);\n\t\t\t}\n\t\t\tcase \"SpreadElement\": {\n\t\t\t\treturn this.handleSpreadElement(node);\n\t\t\t}\n\t\t\tcase \"ObjectExpression\": {\n\t\t\t\treturn this.handleObjectExpression(node);\n\t\t\t}\n\t\t\tcase \"FunctionExpression\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.FUNCTION_EXPRESSION_NOT_ALLOWED);\n\t\t\t}\n\t\t\tcase \"ArrowFunctionExpression\": {\n\t\t\t\treturn this.handleArrowFunctionExpression(node);\n\t\t\t}\n\t\t\tcase \"CallExpression\": {\n\t\t\t\treturn this.handleCallExpression(node);\n\t\t\t}\n\t\t\tcase \"ConditionalExpression\": {\n\t\t\t\treturn this.visit(node.test) ? this.visit(node.consequent) : this.visit(node.alternate);\n\t\t\t}\n\t\t\tcase \"NewExpression\": {\n\t\t\t\tif (node.callee.type !== \"Identifier\") {\n\t\t\t\t\tthrow new Error(`Unsupported callee type '${node.callee.type}' in new expression`);\n\t\t\t\t}\n\n\t\t\t\tif (node.callee.name === \"Function\") {\n\t\t\t\t\tthrow new Error(ERROR_MESSAGES.NEW_FUNCTION_NOT_ALLOWED);\n\t\t\t\t}\n\n\t\t\t\tconst Constructor = this.visit(node.callee);\n\n\t\t\t\t// 仅在存在参数时构建数组\n\t\t\t\tconst args = node.arguments.length ? node.arguments.map((arg) => this.visit(arg)) : [];\n\n\t\t\t\treturn new Constructor(...args);\n\t\t\t}\n\t\t\tcase \"ChainExpression\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"TemplateLiteral\": {\n\t\t\t\treturn this.handleTemplateLiteral(node);\n\t\t\t}\n\t\t\tcase \"ThisExpression\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.THIS_NOT_ALLOWED);\n\t\t\t}\n\t\t\tcase \"WithStatement\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.WITH_NOT_ALLOWED);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tlet content = this.source.slice(node.start, node.end);\n\n\t\t\t\tif (content.length > 20) {\n\t\t\t\t\tcontent = content.slice(0, 17) + \"...\";\n\t\t\t\t}\n\n\t\t\t\tthrow new Error(`'${content}'` + \" \" + ERROR_MESSAGES.NOT_A_VALID_SYNTAX);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles binary expressions (arithmetic and comparison operations).\n\t * @param {import('acorn').BinaryExpression} node\n\t * @private\n\t */\n\thandleBinaryExpression(node) {\n\t\tconst op = node.operator;\n\t\tconst left = this.visit(node.left);\n\t\tconst right = this.visit(node.right);\n\n\t\tif (BINARY_OPERATION_MAP.hasOwnProperty(op)) {\n\t\t\treturn BINARY_OPERATION_MAP[op](left, right);\n\t\t}\n\n\t\tthrow new Error(`Unsupported operator: ${node.operator}`);\n\t}\n\n\t/**\n\t * Handles logical expressions (&&, ||, ??).\n\t * Implements proper short-circuit evaluation for performance.\n\t * @private\n\t */\n\thandleLogicalExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"&&\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? this.visit(node.right) : left;\n\t\t\t}\n\t\t\tcase \"||\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tcase \"??\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left !== null && left !== undefined ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported logical operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles unary expressions (-, +, !, ~, typeof, void).\n\t * @private\n\t */\n\thandleUnaryExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"-\": {\n\t\t\t\treturn -this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"+\": {\n\t\t\t\treturn +this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"!\": {\n\t\t\t\treturn !this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"~\": {\n\t\t\t\treturn ~this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"typeof\": {\n\t\t\t\treturn typeof this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\treturn void this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthrow new Error(ERROR_MESSAGES.DELETE_NOT_SUPPORTED);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported unary operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles identifier (variable) lookups in the scope chain.\n\t * @private\n\t */\n\thandleIdentifier(node) {\n\t\tconst name = node.name;\n\t\tfor (const scope of this.scopes) {\n\t\t\tif (Object.hasOwn(scope, name)) {\n\t\t\t\treturn scope[name];\n\t\t\t}\n\t\t}\n\n\t\tthrow new ReferenceError(`${name} ${ERROR_MESSAGES.VARIABLE_NOT_DEFINED}`);\n\t}\n\n\t/**\n\t * Handles member expressions (property access like obj.prop or obj[prop]).\n\t * @private\n\t */\n\thandleMemberExpression(node) {\n\t\tconst object = this.visit(node.object);\n\n\t\t// Determine property name: either identifier name or computed value\n\t\tconst isStaticProperty = node.property.type === \"Identifier\" && !node.computed;\n\t\tconst property = isStaticProperty ? node.property.name : this.visit(node.property);\n\n\t\t// Prevent access to prototype properties\n\t\tif (typeof object !== \"undefined\" && object !== null && object[property] === object?.__proto__) {\n\t\t\tthrow new Error(ERROR_MESSAGES.ACCESSING_PROTOTYPE_NOT_ALLOWED);\n\t\t}\n\n\t\tif (object === null || object === undefined) {\n\t\t\t// optional chaining\n\t\t\tif (node.optional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(`${ERROR_MESSAGES.PROPERTY_READ_ERROR} '${property}' of ${object}`);\n\t\t}\n\n\t\treturn object[property];\n\t}\n\n\t/**\n\t * Handles array literal expressions.\n\t * @private\n\t */\n\thandleArrayExpression(node) {\n\t\tconst result = [];\n\n\t\tfor (let i = 0; i < node.elements.length; i++) {\n\t\t\tconst element = node.elements.at(i);\n\t\t\tconst value = this.visit(element);\n\n\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\tresult.push(...value);\n\t\t\t} else {\n\t\t\t\tresult.push(value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles object literal expressions.\n\t * @returns\n\t */\n\thandleObjectExpression(node) {\n\t\tconst obj = {};\n\t\tfor (const prop of node.properties) {\n\t\t\tif (prop.type === \"SpreadElement\") {\n\t\t\t\tObject.assign(obj, this.visit(prop.argument));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = prop.key.name || prop.key.value;\n\t\t\tconst value = this.visit(prop.value);\n\t\t\tobj[key] = value;\n\t\t}\n\t\treturn obj;\n\t}\n\n\thandleSpreadElement(node) {\n\t\treturn this.visit(node.argument);\n\t}\n\n\t/**\n\t * Handles arrow function expressions.\n\t * Creates a closure that captures the current scope and executes the function body\n\t * with parameters bound to a new scope.\n\t * @private\n\t */\n\thandleArrowFunctionExpression(node) {\n\t\treturn (...args) => {\n\t\t\t// Create new scope with parameters bound to arguments\n\t\t\tconst newScope = {};\n\t\t\tconst paramCount = node.params.length;\n\t\t\tfor (let i = 0; i < paramCount; i++) {\n\t\t\t\tnewScope[node.params[i].name] = args[i];\n\t\t\t}\n\n\t\t\t// Push new scope, evaluate body, then pop scope\n\t\t\tthis.scopes.unshift(newScope);\n\t\t\tconst result = this.visit(node.body);\n\t\t\tthis.scopes.shift();\n\t\t\treturn result;\n\t\t};\n\t}\n\n\t/**\n\t * Handles function call expressions, including optional chaining.\n\t * @private\n\t */\n\thandleCallExpression(node) {\n\t\tconst calledString = getNodeString(node.callee);\n\n\t\tconst func = this.visit(node.callee);\n\n\t\tif (typeof func !== \"function\") {\n\t\t\tconst isOptional = node.optional || node.callee.optional;\n\t\t\tif ((func === undefined || func === null) && isOptional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(`${calledString} ${ERROR_MESSAGES.NOT_A_FUNCTION}`);\n\t\t}\n\n\t\tif (func === Function) {\n\t\t\tthrow new Error(ERROR_MESSAGES.FUNCTION_CONSTRUCTOR_NOT_ALLOWED);\n\t\t}\n\n\t\tif (getBlockedMethods().has(func)) {\n\t\t\tconst path = getBlockedMethods().get(func);\n\t\t\tthrow new Error(`${path} ${ERROR_MESSAGES.METHOD_NOT_ALLOWED}`);\n\t\t}\n\n\t\t// 仅在存在参数时构建数组\n\t\tconst args = (() => {\n\t\t\tif (node.arguments.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tlet result = [];\n\n\t\t\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\t\t\tconst element = node.arguments.at(i);\n\t\t\t\tconst value = this.visit(element);\n\n\t\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\t\tresult.push(...value);\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t})();\n\n\t\tconst target = node.callee.type === \"MemberExpression\" ? this.visit(node.callee.object) : null;\n\n\t\treturn func.apply(target, args);\n\t}\n\n\t/**\n\t * Handles template literal expressions.\n\t * More efficient implementation that interleaves quasis and expressions without sorting.\n\t * @private\n\t */\n\thandleTemplateLiteral(node) {\n\t\tlet result = \"\";\n\t\tconst expressionCount = node.expressions.length;\n\n\t\tfor (let i = 0; i < node.quasis.length; i++) {\n\t\t\tresult += node.quasis[i].value.raw;\n\t\t\tif (i < expressionCount) {\n\t\t\t\tresult += this.visit(node.expressions[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n/**\n *\n * @param {import('acorn').Node} node\n * @returns\n */\nexport function getNodeString(node) {\n\tswitch (node.type) {\n\t\tcase \"Identifier\": {\n\t\t\treturn node.name;\n\t\t}\n\t\tcase \"Literal\": {\n\t\t\treturn node.raw;\n\t\t}\n\t\tcase \"ArrayExpression\": {\n\t\t\treturn `[${node.elements.map((child) => getNodeString(child)).join(\",\")}]`;\n\t\t}\n\t\tcase \"ObjectExpression\": {\n\t\t\t// if keys is empty\n\t\t\tif (node.properties.length === 0) {\n\t\t\t\treturn \"{}\";\n\t\t\t}\n\n\t\t\treturn \"{(intermediate value)}\";\n\t\t}\n\t\tcase \"MemberExpression\": {\n\t\t\tconst objectStr = getNodeString(node.object);\n\t\t\tconst propertyStr = getNodeString(node.property);\n\n\t\t\tif (node.computed) {\n\t\t\t\treturn `${objectStr}[${propertyStr}]`;\n\t\t\t}\n\t\t\treturn `${objectStr}.${propertyStr}`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","/**\n * 简单状态机模板解析器\n * 能够正确处理表达式中包含字符串、转义字符和结束标记的情况\n * @class SimpleStateTemplateParser\n */\nclass TemplateParser {\n\t/**\n\t * 创建解析器实例\n\t * @param {Object} [options] - 配置选项\n\t * @param {string} [options.expressionStart='{{'] - 表达式开始标记\n\t * @param {string} [options.expressionEnd='}}'] - 表达式结束标记\n\t * @param {boolean} [options.preserveWhitespace=true] - 是否保留表达式周围的空白字符\n\t */\n\tconstructor(options = {}) {\n\t\t// 表达式标记配置\n\t\tthis.exprStart = options.expressionStart || \"{{\";\n\t\tthis.exprEnd = options.expressionEnd || \"}}\";\n\n\t\t// 标记长度缓存,避免重复计算\n\t\tthis.startLen = this.exprStart.length;\n\t\tthis.endLen = this.exprEnd.length;\n\n\t\t// 其他配置\n\t\tthis.preserveWhitespace = options.preserveWhitespace === true;\n\t}\n\n\t/**\n\t * 解析模板字符串,将其转换为 token 数组\n\t * @param {string} template - 要解析的模板字符串\n\t * @returns {Array<{type: string, value: string}>} token 数组\n\t */\n\tparse(template) {\n\t\t// 输入验证\n\t\tif (typeof template !== \"string\") {\n\t\t\tthrow new TypeError(\"模板必须是字符串\");\n\t\t}\n\n\t\tconst tokens = []; // 存储解析结果的 token 数组\n\t\tconst length = template.length;\n\n\t\t// 状态机变量\n\t\tlet state = \"TEXT\"; // 当前状态:TEXT | EXPR | STRING_SQ | STRING_DQ | TEMPLATE | ESCAPE_*\n\t\tlet buffer = \"\"; // 当前状态的字符缓冲区\n\t\tlet exprStartPos = 0; // 当前表达式的开始位置(用于错误恢复)\n\t\tlet pos = 0; // 当前扫描位置\n\n\t\t// 主解析循环:逐个字符扫描模板\n\t\twhile (pos < length) {\n\t\t\tconst char = template[pos];\n\t\t\tconst nextChar = template[pos + 1];\n\n\t\t\t// 状态机核心逻辑\n\t\t\tswitch (state) {\n\t\t\t\t// ==================== 文本状态 ====================\n\t\t\t\tcase \"TEXT\":\n\t\t\t\t\t// 检查是否遇到表达式开始标记\n\t\t\t\t\tif (this._isMatch(pos, template, this.exprStart)) {\n\t\t\t\t\t\t// 将缓冲区中的文本保存为 token\n\t\t\t\t\t\tif (buffer.length > 0) {\n\t\t\t\t\t\t\ttokens.push({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 切换到表达式状态\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t\texprStartPos = pos; // 记录表达式开始位置\n\t\t\t\t\t\tpos += this.startLen; // 跳过开始标记\n\t\t\t\t\t\tcontinue; // 继续处理下一个字符(跳过本次循环的剩余部分)\n\t\t\t\t\t}\n\t\t\t\t\t// 普通文本字符,添加到缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 表达式状态 ====================\n\t\t\t\tcase \"EXPR\":\n\t\t\t\t\t// 在表达式中,需要处理各种字符串和转义字符\n\t\t\t\t\tif (char === \"'\") {\n\t\t\t\t\t\t// 进入单引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_SQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\t// 进入双引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\t// 进入模板字符串状态\n\t\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\t} else if (char === \"\\\\\") {\n\t\t\t\t\t\t// 遇到转义字符,根据当前上下文进入相应的转义状态\n\t\t\t\t\t\tif (nextChar === \"'\") state = \"ESCAPE_SQ\";\n\t\t\t\t\t\telse if (nextChar === '\"') state = \"ESCAPE_DQ\";\n\t\t\t\t\t\telse if (nextChar === \"`\") state = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t\telse state = \"ESCAPE_EXPR\";\n\t\t\t\t\t} else if (this._isMatch(pos, template, this.exprEnd)) {\n\t\t\t\t\t\t// 找到表达式结束标记,且不在字符串中\n\t\t\t\t\t\tconst exprValue = this.preserveWhitespace ? buffer : buffer.trim();\n\t\t\t\t\t\tif (exprValue.length > 0) {\n\t\t\t\t\t\t\ttokens.push({\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\tvalue: exprValue,\n\t\t\t\t\t\t\t\tstart: exprStartPos,\n\t\t\t\t\t\t\t\tend: pos + this.endLen,\n\t\t\t\t\t\t\t\tcontentStart: exprStartPos + this.startLen,\n\t\t\t\t\t\t\t\tcontentEnd: pos,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 重置状态,准备处理后续文本\n\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\tstate = \"TEXT\";\n\t\t\t\t\t\tpos += this.endLen; // 跳过结束标记\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// 将当前字符添加到表达式缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 字符串状态 ====================\n\t\t\t\tcase \"STRING_SQ\": // 单引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_SQ\"; // 遇到转义字符\n\t\t\t\t\t} else if (char === \"'\") {\n\t\t\t\t\t\tstate = \"EXPR\"; // 字符串结束,回到表达式状态\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"STRING_DQ\": // 双引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_DQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"TEMPLATE\": // 模板字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 转义状态 ====================\n\t\t\t\t// 转义状态:处理转义字符,然后返回到之前的状态\n\t\t\t\tcase \"ESCAPE_SQ\":\n\t\t\t\t\tbuffer += char; // 添加转义后的字符\n\t\t\t\t\tstate = \"STRING_SQ\"; // 回到单引号字符串状态\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_DQ\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_TEMPLATE\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_EXPR\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// 移动到下一个字符\n\t\t\tpos++;\n\t\t}\n\n\t\t// ==================== 后处理 ====================\n\t\t// 处理扫描结束后缓冲区中剩余的内容\n\t\tif (buffer.length > 0) {\n\t\t\tif (state === \"TEXT\") {\n\t\t\t\t// 剩余的文本内容\n\t\t\t\ttokens.push({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t} else {\n\t\t\t\t// 未完成的表达式,将其作为普通文本处理\n\t\t\t\t// 这里可以根据需要选择不同的错误处理策略:\n\t\t\t\t// 1. 抛出错误\n\t\t\t\t// 2. 忽略未完成的表达式\n\t\t\t\t// 3. 将其作为文本处理(当前实现)\n\t\t\t\tconst incompleteExpr = this.exprStart + buffer;\n\t\t\t\ttokens.push({ type: \"text\", value: incompleteExpr, start: exprStartPos, end: pos });\n\n\t\t\t\t// 可选:输出警告\n\t\t\t\tconsole.warn(`警告:在位置 ${exprStartPos} 开始的表达式未正确结束`);\n\t\t\t}\n\t\t}\n\n\t\treturn tokens;\n\t}\n\n\t/**\n\t * 检查指定位置是否匹配给定的字符序列\n\t * @param {number} pos - 开始检查的位置\n\t * @param {string} template - 模板字符串\n\t * @param {string} sequence - 要匹配的字符序列\n\t * @returns {boolean} 是否匹配\n\t * @private\n\t */\n\t_isMatch(pos, template, sequence) {\n\t\t// 检查剩余长度是否足够\n\t\tif (pos + sequence.length > template.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// 逐个字符比较\n\t\tfor (let i = 0; i < sequence.length; i++) {\n\t\t\tif (template[pos + i] !== sequence[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * 静态方法:快速解析模板\n\t * @param {string} template - 模板字符串\n\t * @param {Object} [options] - 配置选项\n\t * @returns {Array} token 数组\n\t */\n\tstatic parse(template, options) {\n\t\tconst parser = new TemplateParser(options);\n\t\treturn parser.parse(template);\n\t}\n}\n\nexport { TemplateParser };\n","import { Evaluator } from \"./Evaluator.js\";\nimport { TemplateParser } from \"./TemplateParser.js\";\n\nexport { Evaluator, TemplateParser };\n\n/**\n * Evaluates a JavaScript expression with an optional context.\n * @param {string} expression - The JavaScript expression to evaluate\n * @param {unknown} [context] - Optional context object with variables to use in the expression\n * @returns {*} The result of evaluating the expression\n * @example\n * evalExpression('a + b', { a: 1, b: 2 }) // returns 3\n */\nexport function evalExpression(expression, context) {\n\treturn Evaluator.evaluate(expression, context);\n}\n\n/**\n * Evaluates a template string by replacing {{ expression }} patterns with their evaluated values.\n * Undefined variables in expressions are replaced with empty strings instead of throwing errors.\n * @param {string} template - The template string containing {{ expression }} patterns\n * @param {Object} [context] - Optional context object with variables to use in expressions\n * @param {Object} [templateParserOptions] - Optional options for the template parser\n * @returns {string} The template with all expressions evaluated and replaced\n * @example\n * evalTemplate('Hello {{ name }}!', { name: 'World' }) // returns 'Hello World!'\n */\nexport function evalTemplate(template, context, templateParserOptions) {\n\tlet result = \"\";\n\n\tfor (const token of TemplateParser.parse(template, templateParserOptions)) {\n\t\tif (token.type === \"text\") {\n\t\t\tresult += token.value;\n\t\t} else if (token.type === \"expression\") {\n\t\t\ttry {\n\t\t\t\tresult += Evaluator.evaluate(token.value, context);\n\t\t\t} catch (error) {\n\t\t\t\t// Replace undefined variables with empty string for graceful degradation\n\t\t\t\tif (error instanceof ReferenceError && error.message.endsWith(\"is not defined\")) {\n\t\t\t\t\tresult += \"undefined\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"names":["mutableMethods","dangerousMethods","blockedMethods","blockedGlobalBuiltIns","ERROR_MESSAGES","BINARY_OPERATION_MAP","a","b","_instanceof","createGlobalScope","scope","Object","builtin","globals","key","isWritable","globalThis","getBlockedMethods","BLOCKED_METHODS","map","Map","_iteratorError","path","_path_split","object","properties","current","_iteratorError1","prop","Evaluator","variables","undefined","evaluate","expression","ast","acorn","execute","body","result","node","visit","Error","Constructor","args","arg","content","handleBinaryExpression","op","left","right","handleLogicalExpression","left1","left2","handleUnaryExpression","_type_of","handleIdentifier","name","ReferenceError","handleMemberExpression","isStaticProperty","property","TypeError","handleArrayExpression","i","element","value","_result","handleObjectExpression","obj","handleSpreadElement","handleArrowFunctionExpression","newScope","paramCount","handleCallExpression","calledString","getNodeString","func","isOptional","Function","target","handleTemplateLiteral","expressionCount","context","evaluator","child","objectStr","propertyStr","TemplateParser","options","parse","template","tokens","length","state","buffer","exprStartPos","pos","char","nextChar","exprValue","incompleteExpr","console","_isMatch","sequence","parser","evalExpression","evalTemplate","templateParserOptions","token","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,iBAAiB;IACtB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA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