ecma-evaluator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,638 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ !function() {
4
+ __webpack_require__.d = function(exports1, definition) {
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ }();
11
+ !function() {
12
+ __webpack_require__.o = function(obj, prop) {
13
+ return Object.prototype.hasOwnProperty.call(obj, prop);
14
+ };
15
+ }();
16
+ !function() {
17
+ __webpack_require__.r = function(exports1) {
18
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
+ value: 'Module'
20
+ });
21
+ Object.defineProperty(exports1, '__esModule', {
22
+ value: true
23
+ });
24
+ };
25
+ }();
26
+ var __webpack_exports__ = {};
27
+ __webpack_require__.r(__webpack_exports__);
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ evaluatorExpression: function() {
30
+ return evaluatorExpression;
31
+ },
32
+ evaluatorTemplate: function() {
33
+ return evaluatorTemplate;
34
+ }
35
+ });
36
+ var external_acorn_namespaceObject = require("acorn");
37
+ function _array_like_to_array(arr, len) {
38
+ if (null == len || len > arr.length) len = arr.length;
39
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40
+ return arr2;
41
+ }
42
+ function _array_with_holes(arr) {
43
+ if (Array.isArray(arr)) return arr;
44
+ }
45
+ function _array_without_holes(arr) {
46
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
47
+ }
48
+ function _class_call_check(instance, Constructor) {
49
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
50
+ }
51
+ function _construct(Parent, args, Class) {
52
+ _construct = _is_native_reflect_construct() ? Reflect.construct : function(Parent, args, Class) {
53
+ var a = [
54
+ null
55
+ ];
56
+ a.push.apply(a, args);
57
+ var Constructor = Function.bind.apply(Parent, a);
58
+ var instance = new Constructor();
59
+ if (Class) _set_prototype_of(instance, Class.prototype);
60
+ return instance;
61
+ };
62
+ return _construct.apply(null, arguments);
63
+ }
64
+ function _defineProperties(target, props) {
65
+ for(var i = 0; i < props.length; i++){
66
+ var descriptor = props[i];
67
+ descriptor.enumerable = descriptor.enumerable || false;
68
+ descriptor.configurable = true;
69
+ if ("value" in descriptor) descriptor.writable = true;
70
+ Object.defineProperty(target, descriptor.key, descriptor);
71
+ }
72
+ }
73
+ function _create_class(Constructor, protoProps, staticProps) {
74
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
75
+ if (staticProps) _defineProperties(Constructor, staticProps);
76
+ return Constructor;
77
+ }
78
+ function _define_property(obj, key, value) {
79
+ if (key in obj) Object.defineProperty(obj, key, {
80
+ value: value,
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true
84
+ });
85
+ else obj[key] = value;
86
+ return obj;
87
+ }
88
+ function _iterable_to_array(iter) {
89
+ if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
90
+ }
91
+ function _iterable_to_array_limit(arr, i) {
92
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
93
+ if (null == _i) return;
94
+ var _arr = [];
95
+ var _n = true;
96
+ var _d = false;
97
+ var _s, _e;
98
+ try {
99
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
100
+ _arr.push(_s.value);
101
+ if (i && _arr.length === i) break;
102
+ }
103
+ } catch (err) {
104
+ _d = true;
105
+ _e = err;
106
+ } finally{
107
+ try {
108
+ if (!_n && null != _i["return"]) _i["return"]();
109
+ } finally{
110
+ if (_d) throw _e;
111
+ }
112
+ }
113
+ return _arr;
114
+ }
115
+ function _non_iterable_rest() {
116
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
117
+ }
118
+ function _non_iterable_spread() {
119
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
120
+ }
121
+ function _object_spread(target) {
122
+ for(var i = 1; i < arguments.length; i++){
123
+ var source = null != arguments[i] ? arguments[i] : {};
124
+ var ownKeys = Object.keys(source);
125
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
126
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
127
+ }));
128
+ ownKeys.forEach(function(key) {
129
+ _define_property(target, key, source[key]);
130
+ });
131
+ }
132
+ return target;
133
+ }
134
+ function _set_prototype_of(o, p) {
135
+ _set_prototype_of = Object.setPrototypeOf || function(o, p) {
136
+ o.__proto__ = p;
137
+ return o;
138
+ };
139
+ return _set_prototype_of(o, p);
140
+ }
141
+ function _sliced_to_array(arr, i) {
142
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
143
+ }
144
+ function _to_consumable_array(arr) {
145
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
146
+ }
147
+ function _type_of(obj) {
148
+ return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
149
+ }
150
+ function _unsupported_iterable_to_array(o, minLen) {
151
+ if (!o) return;
152
+ if ("string" == typeof o) return _array_like_to_array(o, minLen);
153
+ var n = Object.prototype.toString.call(o).slice(8, -1);
154
+ if ("Object" === n && o.constructor) n = o.constructor.name;
155
+ if ("Map" === n || "Set" === n) return Array.from(n);
156
+ if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
157
+ }
158
+ function _is_native_reflect_construct() {
159
+ try {
160
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
161
+ } catch (_) {}
162
+ return (_is_native_reflect_construct = function() {
163
+ return !!result;
164
+ })();
165
+ }
166
+ var typeArrayConstructors = [
167
+ Int8Array,
168
+ Uint8Array,
169
+ Uint8ClampedArray,
170
+ Int16Array,
171
+ Uint16Array,
172
+ Int32Array,
173
+ Uint32Array,
174
+ Float32Array,
175
+ Float64Array,
176
+ globalThis.BigInt64Array,
177
+ globalThis.BigUint64Array
178
+ ].filter(Boolean);
179
+ var mutableMethods = new Set([
180
+ Array.prototype.push,
181
+ Array.prototype.pop,
182
+ Array.prototype.shift,
183
+ Array.prototype.unshift,
184
+ Array.prototype.splice,
185
+ Array.prototype.reverse,
186
+ Array.prototype.sort,
187
+ Array.prototype.fill,
188
+ Array.prototype.copyWithin,
189
+ ArrayBuffer.prototype.slice,
190
+ DataView.prototype.setInt8,
191
+ DataView.prototype.setUint8,
192
+ DataView.prototype.setInt16,
193
+ DataView.prototype.setUint16,
194
+ DataView.prototype.setInt32,
195
+ DataView.prototype.setUint32,
196
+ DataView.prototype.setFloat32,
197
+ DataView.prototype.setFloat64
198
+ ].concat(_to_consumable_array(typeArrayConstructors.flatMap(function(TypedArray) {
199
+ return [
200
+ TypedArray.prototype.set,
201
+ TypedArray.prototype.fill,
202
+ TypedArray.prototype.copyWithin,
203
+ TypedArray.prototype.reverse,
204
+ TypedArray.prototype.sort
205
+ ];
206
+ })), [
207
+ Object.freeze,
208
+ Object.defineProperty,
209
+ Object.defineProperties,
210
+ Object.preventExtensions,
211
+ Object.setPrototypeOf,
212
+ Object.assign,
213
+ Set.prototype.add,
214
+ Set.prototype["delete"],
215
+ Set.prototype.clear,
216
+ WeakSet.prototype.add,
217
+ WeakSet.prototype["delete"],
218
+ Map.prototype.set,
219
+ Map.prototype["delete"],
220
+ Map.prototype.clear,
221
+ WeakMap.prototype.set,
222
+ WeakMap.prototype["delete"],
223
+ Date.prototype.setMilliseconds,
224
+ Date.prototype.setMinutes,
225
+ Date.prototype.setHours,
226
+ Date.prototype.setDate,
227
+ Date.prototype.setFullYear,
228
+ Date.prototype.setUTCMinutes,
229
+ Date.prototype.setUTCHours,
230
+ Date.prototype.setUTCDate,
231
+ Date.prototype.setUTCFullYear,
232
+ Date.prototype.setTime
233
+ ]));
234
+ var Evaluator_Evaluator = /*#__PURE__*/ function() {
235
+ "use strict";
236
+ function Evaluator() {
237
+ var variables = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
238
+ _class_call_check(this, Evaluator);
239
+ var globalScope = Object.assign(Object.create(null), _object_spread({
240
+ Infinity: 1 / 0,
241
+ null: null,
242
+ undefined: void 0,
243
+ NaN: Number.NaN,
244
+ isNaN: Number.isNaN,
245
+ isFinite: Number.isFinite,
246
+ parseFloat: Number.parseFloat,
247
+ parseInt: Number.parseInt,
248
+ encodeURI: globalThis.encodeURI,
249
+ encodeURIComponent: globalThis.encodeURIComponent,
250
+ decodeURI: globalThis.decodeURI,
251
+ decodeURIComponent: globalThis.decodeURIComponent,
252
+ Number: Number,
253
+ String: String,
254
+ Boolean: Boolean,
255
+ BigInt: globalThis.BigInt,
256
+ Symbol: globalThis.Symbol,
257
+ Object: Object,
258
+ Array: Array,
259
+ Set: Set,
260
+ WeakSet: WeakSet,
261
+ Map: Map,
262
+ WeakMap: WeakMap,
263
+ Math: Math,
264
+ JSON: JSON,
265
+ Date: Date,
266
+ RegExp: RegExp,
267
+ Error: Error,
268
+ EvalError: EvalError,
269
+ RangeError: RangeError,
270
+ ReferenceError: ReferenceError,
271
+ SyntaxError: SyntaxError,
272
+ TypeError: TypeError,
273
+ URIError: URIError,
274
+ Promise: Promise
275
+ }, typeArrayConstructors.reduce(function(acc, obj) {
276
+ acc[obj.name] = obj;
277
+ return acc;
278
+ }, {})));
279
+ this.scopes = [
280
+ variables,
281
+ globalScope
282
+ ];
283
+ }
284
+ _create_class(Evaluator, [
285
+ {
286
+ key: "evaluate",
287
+ value: function(expression) {
288
+ var ast = external_acorn_namespaceObject.parse(expression, {
289
+ ecmaVersion: "latest"
290
+ });
291
+ return this.execute(ast.body);
292
+ }
293
+ },
294
+ {
295
+ key: "execute",
296
+ value: function(body) {
297
+ var result;
298
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
299
+ try {
300
+ for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
301
+ var node = _step.value;
302
+ result = this.visit(node);
303
+ }
304
+ } catch (err) {
305
+ _didIteratorError = true;
306
+ _iteratorError = err;
307
+ } finally{
308
+ try {
309
+ if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
310
+ } finally{
311
+ if (_didIteratorError) throw _iteratorError;
312
+ }
313
+ }
314
+ return result;
315
+ }
316
+ },
317
+ {
318
+ key: "visit",
319
+ value: function(node) {
320
+ var _this = this;
321
+ switch(node.type){
322
+ case "ExpressionStatement":
323
+ return this.visit(node.expression);
324
+ case "BinaryExpression":
325
+ return this.handleBinaryExpression(node);
326
+ case "LogicalExpression":
327
+ return this.handleLogicalExpression(node);
328
+ case "UnaryExpression":
329
+ return this.handleUnaryExpression(node);
330
+ case "Identifier":
331
+ return this.handleIdentifier(node);
332
+ case "Literal":
333
+ return node.value;
334
+ case "MemberExpression":
335
+ return this.handleMemberExpression(node);
336
+ case "ObjectExpression":
337
+ return this.handleObjectExpression(node);
338
+ case "ArrayExpression":
339
+ return this.handleArrayExpression(node);
340
+ case "ArrowFunctionExpression":
341
+ return this.handleArrowFunctionExpression(node);
342
+ case "CallExpression":
343
+ return this.handleCallExpression(node);
344
+ case "ConditionalExpression":
345
+ return this.visit(node.test) ? this.visit(node.consequent) : this.visit(node.alternate);
346
+ case "NewExpression":
347
+ if ("Identifier" !== node.callee.type) throw new Error("Unsupported callee type '".concat(node.callee.type, "' in new expression"));
348
+ if ("Function" === node.callee.name) throw new Error("Cannot use new with Function constructor");
349
+ var Constructor = this.visit(node.callee);
350
+ var args = node["arguments"].map(function(arg) {
351
+ return _this.visit(arg);
352
+ });
353
+ return _construct(Constructor, _to_consumable_array(args));
354
+ case "ChainExpression":
355
+ return this.visit(node.expression);
356
+ case "TemplateLiteral":
357
+ return this.handleTemplateLiteral(node);
358
+ default:
359
+ throw new Error("Unsupported node type: ".concat(node.type));
360
+ }
361
+ }
362
+ },
363
+ {
364
+ key: "handleBinaryExpression",
365
+ value: function(node) {
366
+ switch(node.operator){
367
+ case "+":
368
+ return this.visit(node.left) + this.visit(node.right);
369
+ case "-":
370
+ return this.visit(node.left) - this.visit(node.right);
371
+ case "*":
372
+ return this.visit(node.left) * this.visit(node.right);
373
+ case "**":
374
+ return Math.pow(this.visit(node.left), this.visit(node.right));
375
+ case "/":
376
+ var left = this.visit(node.left);
377
+ var right = this.visit(node.right);
378
+ if (0 === right) throw new Error("Division by zero");
379
+ return left / right;
380
+ case "==":
381
+ return this.visit(node.left) == this.visit(node.right);
382
+ case "===":
383
+ return this.visit(node.left) === this.visit(node.right);
384
+ case "!=":
385
+ return this.visit(node.left) != this.visit(node.right);
386
+ case "!==":
387
+ return this.visit(node.left) !== this.visit(node.right);
388
+ case ">":
389
+ return this.visit(node.left) > this.visit(node.right);
390
+ case ">=":
391
+ return this.visit(node.left) >= this.visit(node.right);
392
+ case "<":
393
+ return this.visit(node.left) < this.visit(node.right);
394
+ case "<=":
395
+ return this.visit(node.left) <= this.visit(node.right);
396
+ case "%":
397
+ return this.visit(node.left) % this.visit(node.right);
398
+ case "&":
399
+ return this.visit(node.left) & this.visit(node.right);
400
+ case "|":
401
+ return this.visit(node.left) | this.visit(node.right);
402
+ case "^":
403
+ return this.visit(node.left) ^ this.visit(node.right);
404
+ case "<<":
405
+ return this.visit(node.left) << this.visit(node.right);
406
+ case ">>":
407
+ return this.visit(node.left) >> this.visit(node.right);
408
+ case ">>>":
409
+ return this.visit(node.left) >>> this.visit(node.right);
410
+ default:
411
+ throw new Error("Unsupported operator: ".concat(node.operator));
412
+ }
413
+ }
414
+ },
415
+ {
416
+ key: "handleLogicalExpression",
417
+ value: function(node) {
418
+ switch(node.operator){
419
+ case "&&":
420
+ return this.visit(node.left) && this.visit(node.right);
421
+ case "||":
422
+ return this.visit(node.left) || this.visit(node.right);
423
+ case "??":
424
+ var left = this.visit(node.left);
425
+ return null != left ? left : this.visit(node.right);
426
+ default:
427
+ throw new Error("Unsupported logical operator: ".concat(node.operator));
428
+ }
429
+ }
430
+ },
431
+ {
432
+ key: "handleUnaryExpression",
433
+ value: function(node) {
434
+ switch(node.operator){
435
+ case "-":
436
+ return -this.visit(node.argument);
437
+ case "+":
438
+ return +this.visit(node.argument);
439
+ case "!":
440
+ return !this.visit(node.argument);
441
+ case "~":
442
+ return ~this.visit(node.argument);
443
+ case "typeof":
444
+ return _type_of(this.visit(node.argument));
445
+ case "void":
446
+ return void this.visit(node.argument);
447
+ case "delete":
448
+ throw new Error("Delete operator is mutable and not supported");
449
+ default:
450
+ throw new Error("Unsupported unary operator: ".concat(node.operator));
451
+ }
452
+ }
453
+ },
454
+ {
455
+ key: "handleIdentifier",
456
+ value: function(node) {
457
+ var name = node.name;
458
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
459
+ try {
460
+ for(var _iterator = this.scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
461
+ var scope = _step.value;
462
+ if (Object.hasOwn(scope, name)) return scope[name];
463
+ }
464
+ } catch (err) {
465
+ _didIteratorError = true;
466
+ _iteratorError = err;
467
+ } finally{
468
+ try {
469
+ if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
470
+ } finally{
471
+ if (_didIteratorError) throw _iteratorError;
472
+ }
473
+ }
474
+ throw new ReferenceError("".concat(name, " is not defined"));
475
+ }
476
+ },
477
+ {
478
+ key: "handleMemberExpression",
479
+ value: function(node) {
480
+ var object = this.visit(node.object);
481
+ var property = "Identifier" !== node.property.type || node.computed ? this.visit(node.property) : node.property.name;
482
+ if (null == object) {
483
+ if (node.optional) return;
484
+ throw new TypeError("Cannot read property '".concat(property, "' of ").concat(object));
485
+ }
486
+ if (Object.hasOwn(object, property)) return object[property];
487
+ var prototypeValue = object[property];
488
+ if (mutableMethods.has(prototypeValue)) throw new Error("Cannot call mutable prototype method: ".concat(property));
489
+ if ("function" == typeof prototypeValue) return prototypeValue.bind(object);
490
+ return prototypeValue;
491
+ }
492
+ },
493
+ {
494
+ key: "handleObjectExpression",
495
+ value: function(node) {
496
+ var obj = {};
497
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
498
+ try {
499
+ for(var _iterator = node.properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
500
+ var prop = _step.value;
501
+ var key = prop.key.name || prop.key.value;
502
+ var value = this.visit(prop.value);
503
+ obj[key] = value;
504
+ }
505
+ } catch (err) {
506
+ _didIteratorError = true;
507
+ _iteratorError = err;
508
+ } finally{
509
+ try {
510
+ if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
511
+ } finally{
512
+ if (_didIteratorError) throw _iteratorError;
513
+ }
514
+ }
515
+ return obj;
516
+ }
517
+ },
518
+ {
519
+ key: "handleArrayExpression",
520
+ value: function(node) {
521
+ var _this = this;
522
+ return node.elements.map(function(element) {
523
+ return _this.visit(element);
524
+ });
525
+ }
526
+ },
527
+ {
528
+ key: "handleArrowFunctionExpression",
529
+ value: function(node) {
530
+ var _this = this;
531
+ return function() {
532
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key];
533
+ var newScope = {};
534
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
535
+ try {
536
+ for(var _iterator = node.params.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
537
+ var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], param = _step_value[1];
538
+ newScope[param.name] = args[index];
539
+ }
540
+ } catch (err) {
541
+ _didIteratorError = true;
542
+ _iteratorError = err;
543
+ } finally{
544
+ try {
545
+ if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
546
+ } finally{
547
+ if (_didIteratorError) throw _iteratorError;
548
+ }
549
+ }
550
+ _this.scopes.unshift(newScope);
551
+ var result = _this.visit(node.body);
552
+ _this.scopes.shift();
553
+ return result;
554
+ };
555
+ }
556
+ },
557
+ {
558
+ key: "handleCallExpression",
559
+ value: function(node) {
560
+ var _this = this;
561
+ var calledString = this.getNodeString(node.callee);
562
+ var func = this.visit(node.callee);
563
+ if ("function" != typeof func) {
564
+ var isOptional = node.optional || node.callee.optional;
565
+ if (null == func && isOptional) return;
566
+ throw new TypeError("".concat(calledString, " is not a function"));
567
+ }
568
+ var args = node["arguments"].map(function(arg) {
569
+ return _this.visit(arg);
570
+ });
571
+ return func.apply(void 0, _to_consumable_array(args));
572
+ }
573
+ },
574
+ {
575
+ key: "handleTemplateLiteral",
576
+ value: function(node) {
577
+ var _this = this;
578
+ return node.quasis.concat(node.expressions).filter(Boolean).sort(function(a, b) {
579
+ return a.start - b.start;
580
+ }).map(function(node) {
581
+ if ("TemplateElement" === node.type) return node.value.raw;
582
+ return _this.visit(node);
583
+ }).join("");
584
+ }
585
+ },
586
+ {
587
+ key: "getNodeString",
588
+ value: function(node) {
589
+ switch(node.type){
590
+ case "Identifier":
591
+ return node.name;
592
+ case "Literal":
593
+ return node.raw;
594
+ case "ArrayExpression":
595
+ return "(array)";
596
+ case "ObjectExpression":
597
+ return "(object)";
598
+ case "MemberExpression":
599
+ var accessor = this.getNodeString(node.object);
600
+ if (node.computed) accessor += "[".concat(this.getNodeString(node.property), "]");
601
+ else accessor += ".".concat(this.getNodeString(node.property));
602
+ return accessor;
603
+ default:
604
+ return null;
605
+ }
606
+ }
607
+ }
608
+ ]);
609
+ return Evaluator;
610
+ }();
611
+ var TEMPLATE_EXPRESSION_REGEX = /\$\{\{((?:[^{}]|{[^{}]*})+)\}\}/g;
612
+ function evaluatorExpression(expression, context) {
613
+ var evaluator = new Evaluator_Evaluator(context);
614
+ return evaluator.evaluate(expression);
615
+ }
616
+ function evaluatorTemplate(template, context) {
617
+ var evaluator = new Evaluator_Evaluator(context);
618
+ return template.replace(TEMPLATE_EXPRESSION_REGEX, function(match, expression) {
619
+ try {
620
+ var value = evaluator.evaluate(expression.trim());
621
+ return String(value);
622
+ } catch (error) {
623
+ if (error instanceof ReferenceError && error.message.endsWith("is not defined")) return "";
624
+ throw error;
625
+ }
626
+ });
627
+ }
628
+ exports.evaluatorExpression = __webpack_exports__.evaluatorExpression;
629
+ exports.evaluatorTemplate = __webpack_exports__.evaluatorTemplate;
630
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
631
+ "evaluatorExpression",
632
+ "evaluatorTemplate"
633
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
634
+ Object.defineProperty(exports, '__esModule', {
635
+ value: true
636
+ });
637
+
638
+ //# sourceMappingURL=index.cjs.map