ecma-evaluator 2.0.0 → 2.0.1
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/dist/cjs/index.cjs +70 -48
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +70 -48
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -275,6 +275,74 @@ var ERROR_MESSAGES = {
|
|
|
275
275
|
THIS_NOT_ALLOWED: "'this' keyword is not allowed",
|
|
276
276
|
NOT_A_VALID_SYNTAX: "is not a valid syntax"
|
|
277
277
|
};
|
|
278
|
+
var BINARY_OPERATION_MAP = {
|
|
279
|
+
"+": function(a, b) {
|
|
280
|
+
return a + b;
|
|
281
|
+
},
|
|
282
|
+
"-": function(a, b) {
|
|
283
|
+
return a - b;
|
|
284
|
+
},
|
|
285
|
+
"*": function(a, b) {
|
|
286
|
+
return a * b;
|
|
287
|
+
},
|
|
288
|
+
"**": function(a, b) {
|
|
289
|
+
return Math.pow(a, b);
|
|
290
|
+
},
|
|
291
|
+
"==": function(a, b) {
|
|
292
|
+
return a == b;
|
|
293
|
+
},
|
|
294
|
+
"===": function(a, b) {
|
|
295
|
+
return a === b;
|
|
296
|
+
},
|
|
297
|
+
"!=": function(a, b) {
|
|
298
|
+
return a != b;
|
|
299
|
+
},
|
|
300
|
+
"!==": function(a, b) {
|
|
301
|
+
return a !== b;
|
|
302
|
+
},
|
|
303
|
+
">": function(a, b) {
|
|
304
|
+
return a > b;
|
|
305
|
+
},
|
|
306
|
+
">=": function(a, b) {
|
|
307
|
+
return a >= b;
|
|
308
|
+
},
|
|
309
|
+
"<": function(a, b) {
|
|
310
|
+
return a < b;
|
|
311
|
+
},
|
|
312
|
+
"<=": function(a, b) {
|
|
313
|
+
return a <= b;
|
|
314
|
+
},
|
|
315
|
+
"%": function(a, b) {
|
|
316
|
+
return a % b;
|
|
317
|
+
},
|
|
318
|
+
"/": function(a, b) {
|
|
319
|
+
return a / b;
|
|
320
|
+
},
|
|
321
|
+
"|": function(a, b) {
|
|
322
|
+
return a | b;
|
|
323
|
+
},
|
|
324
|
+
"&": function(a, b) {
|
|
325
|
+
return a & b;
|
|
326
|
+
},
|
|
327
|
+
"^": function(a, b) {
|
|
328
|
+
return a ^ b;
|
|
329
|
+
},
|
|
330
|
+
"<<": function(a, b) {
|
|
331
|
+
return a << b;
|
|
332
|
+
},
|
|
333
|
+
">>": function(a, b) {
|
|
334
|
+
return a >> b;
|
|
335
|
+
},
|
|
336
|
+
">>>": function(a, b) {
|
|
337
|
+
return a >>> b;
|
|
338
|
+
},
|
|
339
|
+
in: function(a, b) {
|
|
340
|
+
return a in b;
|
|
341
|
+
},
|
|
342
|
+
instanceof: function(a, b) {
|
|
343
|
+
return _instanceof(a, b);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
278
346
|
function createGlobalScope() {
|
|
279
347
|
var scope = Object.create(null);
|
|
280
348
|
var builtin = external_globals_namespaceObject.builtin;
|
|
@@ -453,54 +521,8 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
453
521
|
var op = node.operator;
|
|
454
522
|
var left = this.visit(node.left);
|
|
455
523
|
var right = this.visit(node.right);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return left + right;
|
|
459
|
-
case "-":
|
|
460
|
-
return left - right;
|
|
461
|
-
case "*":
|
|
462
|
-
return left * right;
|
|
463
|
-
case "**":
|
|
464
|
-
return Math.pow(left, right);
|
|
465
|
-
case "==":
|
|
466
|
-
return left == right;
|
|
467
|
-
case "===":
|
|
468
|
-
return left === right;
|
|
469
|
-
case "!=":
|
|
470
|
-
return left != right;
|
|
471
|
-
case "!==":
|
|
472
|
-
return left !== right;
|
|
473
|
-
case ">":
|
|
474
|
-
return left > right;
|
|
475
|
-
case ">=":
|
|
476
|
-
return left >= right;
|
|
477
|
-
case "<":
|
|
478
|
-
return left < right;
|
|
479
|
-
case "<=":
|
|
480
|
-
return left <= right;
|
|
481
|
-
case "%":
|
|
482
|
-
return left % right;
|
|
483
|
-
case "/":
|
|
484
|
-
return left / right;
|
|
485
|
-
case "|":
|
|
486
|
-
return left | right;
|
|
487
|
-
case "&":
|
|
488
|
-
return left & right;
|
|
489
|
-
case "^":
|
|
490
|
-
return left ^ right;
|
|
491
|
-
case "<<":
|
|
492
|
-
return left << right;
|
|
493
|
-
case ">>":
|
|
494
|
-
return left >> right;
|
|
495
|
-
case ">>>":
|
|
496
|
-
return left >>> right;
|
|
497
|
-
case "in":
|
|
498
|
-
return left in right;
|
|
499
|
-
case "instanceof":
|
|
500
|
-
return _instanceof(left, right);
|
|
501
|
-
default:
|
|
502
|
-
throw new Error("Unsupported operator: ".concat(node.operator));
|
|
503
|
-
}
|
|
524
|
+
if (BINARY_OPERATION_MAP.hasOwnProperty(op)) return BINARY_OPERATION_MAP[op](left, right);
|
|
525
|
+
throw new Error("Unsupported operator: ".concat(node.operator));
|
|
504
526
|
}
|
|
505
527
|
},
|
|
506
528
|
{
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cjs/index.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/mutableMethods.js","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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\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\t\tswitch (op) {\n\t\t\tcase \"+\":\n\t\t\t\treturn left + right;\n\t\t\tcase \"-\":\n\t\t\t\treturn left - right;\n\t\t\tcase \"*\":\n\t\t\t\treturn left * right;\n\t\t\tcase \"**\":\n\t\t\t\treturn left ** right;\n\t\t\tcase \"==\":\n\t\t\t\treturn left == right;\n\t\t\tcase \"===\":\n\t\t\t\treturn left === right;\n\t\t\tcase \"!=\":\n\t\t\t\treturn left != right;\n\t\t\tcase \"!==\":\n\t\t\t\treturn left !== right;\n\t\t\tcase \">\":\n\t\t\t\treturn left > right;\n\t\t\tcase \">=\":\n\t\t\t\treturn left >= right;\n\t\t\tcase \"<\":\n\t\t\t\treturn left < right;\n\t\t\tcase \"<=\":\n\t\t\t\treturn left <= right;\n\t\t\tcase \"%\":\n\t\t\t\treturn left % right;\n\t\t\tcase \"/\":\n\t\t\t\treturn left / right;\n\t\t\tcase \"|\":\n\t\t\t\treturn left | right;\n\t\t\tcase \"&\":\n\t\t\t\treturn left & right;\n\t\t\tcase \"^\":\n\t\t\t\treturn left ^ right;\n\t\t\tcase \"<<\":\n\t\t\t\treturn left << right;\n\t\t\tcase \">>\":\n\t\t\t\treturn left >> right;\n\t\t\tcase \">>>\":\n\t\t\t\treturn left >>> right;\n\t\t\tcase \"in\": {\n\t\t\t\treturn left in right;\n\t\t\t}\n\t\t\tcase \"instanceof\": {\n\t\t\t\treturn left instanceof right;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported operator: ${node.operator}`);\n\t\t\t}\n\t\t}\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":["__webpack_require__","definition","key","Object","obj","prop","Symbol","mutableMethods","ERROR_MESSAGES","createGlobalScope","scope","builtin","globals","globalThis","isWritable","getMutableMethods","MUTABLE_METHODS","set","Set","_iteratorError","path","_path_split","object","properties","current","_iteratorError1","Evaluator","variables","undefined","evaluate","expression","ast","acorn","execute","body","result","node","visit","Error","Constructor","args","arg","content","handleBinaryExpression","op","left","right","_instanceof","handleLogicalExpression","left1","left2","handleUnaryExpression","_type_of","handleIdentifier","name","ReferenceError","handleMemberExpression","isStaticProperty","property","TypeError","handleObjectExpression","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":";;;IAAAA,oBAAoB,CAAC,GAAG,SAAS,QAAO,EAAEC,UAAU;QACnD,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,SAASI,GAAG,EAAEC,IAAI;QAAI,OAAOF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;IAAO;;;ICCtGL,oBAAoB,CAAC,GAAG,SAAS,QAAO;QACvC,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;ACNO,IAAMI,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,SAASC;IACR,IAAMC,QAAQP,OAAO,MAAM,CAAC;IAC5B,IAAQQ,UAAYC,iCAAAA,OAALD;IAEfR,OAAO,IAAI,CAACQ,SAAS,OAAO,CAAC,SAACT,GAAG;QAChC,IAAIA,OAAOW,cAAcX,AAAQ,WAARA,OAAkBA,AAAQ,iBAARA,KAAsB;YAChE,IAAMY,aAAaH,OAAO,CAACT,IAAI;YAE/BC,OAAO,cAAc,CAACO,OAAOR,KAAK;gBACjC,OAAOW,UAAU,CAACX,IAAI;gBACtB,UAAUY;gBACV,YAAY;gBACZ,cAAc;YACf;QACD;IACD;IAEAX,OAAO,cAAc,CAACO,OAAO,cAAc;QAC1C,OAAOA;QACP,UAAU;QACV,YAAY;QACZ,cAAc;IACf;IAEA,OAAOA;AACR;AAGA,IA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gBAEf,IAAS3D,eAAL2D,OAAiBnD,mBAAkBmD,MAAM,OAAO,CAAC,QAAQ,CAAC,mBAC7DvE,UAAU;qBAEV,MAAMuE;YAER;QAEF;;QAfKvF,oBAAAA;QAAAA,iBAAAA;;;iBAAAA,6BAAAA,AAAAA,QAAAA,UAAAA,MAAAA,EAAAA,UAAAA,MAAAA;;gBAAAA,mB,MAAAA;;;IAiBL,OAAOgB;AACR"}
|
|
1
|
+
{"version":3,"file":"cjs/index.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/mutableMethods.js","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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":["__webpack_require__","definition","key","Object","obj","prop","Symbol","mutableMethods","ERROR_MESSAGES","BINARY_OPERATION_MAP","a","b","_instanceof","createGlobalScope","scope","builtin","globals","globalThis","isWritable","getMutableMethods","MUTABLE_METHODS","set","Set","_iteratorError","path","_path_split","object","properties","current","_iteratorError1","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","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":";;;IAAAA,oBAAoB,CAAC,GAAG,SAAS,QAAO,EAAEC,UAAU;QACnD,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,SAASI,GAAG,EAAEC,IAAI;QAAI,OAAOF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;IAAO;;;ICCtGL,oBAAoB,CAAC,GAAG,SAAS,QAAO;QACvC,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;ACNO,IAAMI,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;IACr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AA,AAAAA,QAAAA,UAAAA,MAAAA,EAAAA,UAAAA,MAAAA;;gBAAAA,mB,MAAAA;;;IAiBL,OAAOgB;AACR"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -237,6 +237,74 @@ var ERROR_MESSAGES = {
|
|
|
237
237
|
THIS_NOT_ALLOWED: "'this' keyword is not allowed",
|
|
238
238
|
NOT_A_VALID_SYNTAX: "is not a valid syntax"
|
|
239
239
|
};
|
|
240
|
+
var BINARY_OPERATION_MAP = {
|
|
241
|
+
"+": function(a, b) {
|
|
242
|
+
return a + b;
|
|
243
|
+
},
|
|
244
|
+
"-": function(a, b) {
|
|
245
|
+
return a - b;
|
|
246
|
+
},
|
|
247
|
+
"*": function(a, b) {
|
|
248
|
+
return a * b;
|
|
249
|
+
},
|
|
250
|
+
"**": function(a, b) {
|
|
251
|
+
return Math.pow(a, b);
|
|
252
|
+
},
|
|
253
|
+
"==": function(a, b) {
|
|
254
|
+
return a == b;
|
|
255
|
+
},
|
|
256
|
+
"===": function(a, b) {
|
|
257
|
+
return a === b;
|
|
258
|
+
},
|
|
259
|
+
"!=": function(a, b) {
|
|
260
|
+
return a != b;
|
|
261
|
+
},
|
|
262
|
+
"!==": function(a, b) {
|
|
263
|
+
return a !== b;
|
|
264
|
+
},
|
|
265
|
+
">": function(a, b) {
|
|
266
|
+
return a > b;
|
|
267
|
+
},
|
|
268
|
+
">=": function(a, b) {
|
|
269
|
+
return a >= b;
|
|
270
|
+
},
|
|
271
|
+
"<": function(a, b) {
|
|
272
|
+
return a < b;
|
|
273
|
+
},
|
|
274
|
+
"<=": function(a, b) {
|
|
275
|
+
return a <= b;
|
|
276
|
+
},
|
|
277
|
+
"%": function(a, b) {
|
|
278
|
+
return a % b;
|
|
279
|
+
},
|
|
280
|
+
"/": function(a, b) {
|
|
281
|
+
return a / b;
|
|
282
|
+
},
|
|
283
|
+
"|": function(a, b) {
|
|
284
|
+
return a | b;
|
|
285
|
+
},
|
|
286
|
+
"&": function(a, b) {
|
|
287
|
+
return a & b;
|
|
288
|
+
},
|
|
289
|
+
"^": function(a, b) {
|
|
290
|
+
return a ^ b;
|
|
291
|
+
},
|
|
292
|
+
"<<": function(a, b) {
|
|
293
|
+
return a << b;
|
|
294
|
+
},
|
|
295
|
+
">>": function(a, b) {
|
|
296
|
+
return a >> b;
|
|
297
|
+
},
|
|
298
|
+
">>>": function(a, b) {
|
|
299
|
+
return a >>> b;
|
|
300
|
+
},
|
|
301
|
+
in: function(a, b) {
|
|
302
|
+
return a in b;
|
|
303
|
+
},
|
|
304
|
+
instanceof: function(a, b) {
|
|
305
|
+
return _instanceof(a, b);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
240
308
|
function createGlobalScope() {
|
|
241
309
|
var scope = Object.create(null);
|
|
242
310
|
var builtin = globals.builtin;
|
|
@@ -415,54 +483,8 @@ var Evaluator_Evaluator = /*#__PURE__*/ function() {
|
|
|
415
483
|
var op = node.operator;
|
|
416
484
|
var left = this.visit(node.left);
|
|
417
485
|
var right = this.visit(node.right);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return left + right;
|
|
421
|
-
case "-":
|
|
422
|
-
return left - right;
|
|
423
|
-
case "*":
|
|
424
|
-
return left * right;
|
|
425
|
-
case "**":
|
|
426
|
-
return Math.pow(left, right);
|
|
427
|
-
case "==":
|
|
428
|
-
return left == right;
|
|
429
|
-
case "===":
|
|
430
|
-
return left === right;
|
|
431
|
-
case "!=":
|
|
432
|
-
return left != right;
|
|
433
|
-
case "!==":
|
|
434
|
-
return left !== right;
|
|
435
|
-
case ">":
|
|
436
|
-
return left > right;
|
|
437
|
-
case ">=":
|
|
438
|
-
return left >= right;
|
|
439
|
-
case "<":
|
|
440
|
-
return left < right;
|
|
441
|
-
case "<=":
|
|
442
|
-
return left <= right;
|
|
443
|
-
case "%":
|
|
444
|
-
return left % right;
|
|
445
|
-
case "/":
|
|
446
|
-
return left / right;
|
|
447
|
-
case "|":
|
|
448
|
-
return left | right;
|
|
449
|
-
case "&":
|
|
450
|
-
return left & right;
|
|
451
|
-
case "^":
|
|
452
|
-
return left ^ right;
|
|
453
|
-
case "<<":
|
|
454
|
-
return left << right;
|
|
455
|
-
case ">>":
|
|
456
|
-
return left >> right;
|
|
457
|
-
case ">>>":
|
|
458
|
-
return left >>> right;
|
|
459
|
-
case "in":
|
|
460
|
-
return left in right;
|
|
461
|
-
case "instanceof":
|
|
462
|
-
return _instanceof(left, right);
|
|
463
|
-
default:
|
|
464
|
-
throw new Error("Unsupported operator: ".concat(node.operator));
|
|
465
|
-
}
|
|
486
|
+
if (BINARY_OPERATION_MAP.hasOwnProperty(op)) return BINARY_OPERATION_MAP[op](left, right);
|
|
487
|
+
throw new Error("Unsupported operator: ".concat(node.operator));
|
|
466
488
|
}
|
|
467
489
|
},
|
|
468
490
|
{
|
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\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\t\tswitch (op) {\n\t\t\tcase \"+\":\n\t\t\t\treturn left + right;\n\t\t\tcase \"-\":\n\t\t\t\treturn left - right;\n\t\t\tcase \"*\":\n\t\t\t\treturn left * right;\n\t\t\tcase \"**\":\n\t\t\t\treturn left ** right;\n\t\t\tcase \"==\":\n\t\t\t\treturn left == right;\n\t\t\tcase \"===\":\n\t\t\t\treturn left === right;\n\t\t\tcase \"!=\":\n\t\t\t\treturn left != right;\n\t\t\tcase \"!==\":\n\t\t\t\treturn left !== right;\n\t\t\tcase \">\":\n\t\t\t\treturn left > right;\n\t\t\tcase \">=\":\n\t\t\t\treturn left >= right;\n\t\t\tcase \"<\":\n\t\t\t\treturn left < right;\n\t\t\tcase \"<=\":\n\t\t\t\treturn left <= right;\n\t\t\tcase \"%\":\n\t\t\t\treturn left % right;\n\t\t\tcase \"/\":\n\t\t\t\treturn left / right;\n\t\t\tcase \"|\":\n\t\t\t\treturn left | right;\n\t\t\tcase \"&\":\n\t\t\t\treturn left & right;\n\t\t\tcase \"^\":\n\t\t\t\treturn left ^ right;\n\t\t\tcase \"<<\":\n\t\t\t\treturn left << right;\n\t\t\tcase \">>\":\n\t\t\t\treturn left >> right;\n\t\t\tcase \">>>\":\n\t\t\t\treturn left >>> right;\n\t\t\tcase \"in\": {\n\t\t\t\treturn left in right;\n\t\t\t}\n\t\t\tcase \"instanceof\": {\n\t\t\t\treturn left instanceof right;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported operator: ${node.operator}`);\n\t\t\t}\n\t\t}\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","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","_instanceof","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,SAASC;IACR,IAAMC,QAAQC,OAAO,MAAM,CAAC;IAC5B,IAAQC,UAAYC,QAAAA,OAALD;IAEfD,OAAO,IAAI,CAACC,SAAS,OAAO,CAAC,SAACE,GAAG;QAChC,IAAIA,OAAOC,cAAcD,AAAQ,WAARA,OAAkBA,AAAQ,iBAARA,KAAsB;YAChE,IAAME,aAAaJ,OAAO,CAACE,IAAI;YAE/BH,OAAO,cAAc,CAACD,OAAOI,KAAK;gBACjC,OAAOC,UAAU,CAACD,IAAI;gBACtB,UAAUE;gBACV,YAAY;gBACZ,cAAc;YACf;QACD;IACD;IAEAL,OAAO,cAAc,CAACD,OAAO,cAAc;QAC1C,OAAOA;QACP,UAAU;QACV,YAAY;QACZ,cA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C,EAAE,OAAO2B,OAAO;gBAEf,IAAS5D,eAAL4D,OAAiBpD,mBAAkBoD,MAAM,OAAO,CAAC,QAAQ,CAAC,mBAC7DxE,UAAU;qBAEV,MAAMwE;YAER;QAEF;;QAfKzF,oBAAAA;QAAAA,iBAAAA;;;iBAAAA,6BAAAA,AAAAA,QAAAA,UAAAA,MAAAA,EAAAA,UAAAA,MAAAA;;gBAAAA,mB,MAAAA;;;IAiBL,OAAOiB;AACR"}
|
|
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;;;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