@zvenigora/ng-eval-core 0.1.104 → 0.1.106

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.
Files changed (29) hide show
  1. package/esm2022/lib/actual/services/base-eval.mjs +32 -1
  2. package/esm2022/lib/actual/services/compiler.service.mjs +66 -40
  3. package/esm2022/lib/actual/services/discovery.service.mjs +4 -23
  4. package/esm2022/lib/actual/services/eval.service.mjs +65 -30
  5. package/esm2022/lib/actual/services/parser.service.mjs +19 -9
  6. package/esm2022/lib/internal/classes/eval/eval-context.mjs +21 -3
  7. package/esm2022/lib/internal/classes/eval/eval-result.mjs +19 -3
  8. package/esm2022/lib/internal/classes/eval/eval-scope.mjs +83 -0
  9. package/esm2022/lib/internal/classes/eval/eval-state.mjs +1 -1
  10. package/esm2022/lib/internal/classes/eval/eval-trace.mjs +22 -0
  11. package/esm2022/lib/internal/classes/eval/parser-options.mjs +8 -0
  12. package/esm2022/lib/internal/classes/eval/public-api.mjs +4 -1
  13. package/esm2022/lib/internal/visitors/member-expression.mjs +7 -1
  14. package/esm2022/lib/internal/visitors/visitor-result.mjs +3 -9
  15. package/fesm2022/zvenigora-ng-eval-core.mjs +1026 -800
  16. package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
  17. package/lib/actual/services/base-eval.d.ts +21 -2
  18. package/lib/actual/services/compiler.service.d.ts +28 -16
  19. package/lib/actual/services/discovery.service.d.ts +1 -7
  20. package/lib/actual/services/eval.service.d.ts +22 -10
  21. package/lib/actual/services/parser.service.d.ts +11 -2
  22. package/lib/internal/classes/eval/eval-context.d.ts +9 -1
  23. package/lib/internal/classes/eval/eval-result.d.ts +16 -3
  24. package/lib/internal/classes/eval/eval-scope.d.ts +51 -0
  25. package/lib/internal/classes/eval/eval-state.d.ts +4 -4
  26. package/lib/internal/classes/eval/eval-trace.d.ts +20 -0
  27. package/lib/internal/classes/eval/parser-options.d.ts +2 -0
  28. package/lib/internal/classes/eval/public-api.d.ts +3 -0
  29. package/package.json +1 -1
@@ -1,28 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable } from '@angular/core';
3
3
  import { sha256 } from 'js-sha256';
4
- import { parse as parse$1, defaultOptions as defaultOptions$1, version } from 'acorn';
4
+ import { defaultOptions as defaultOptions$1, parse as parse$1, version } from 'acorn';
5
5
  import * as walk from 'acorn-walk';
6
6
 
7
- /**
8
- * Base class for evaluation.
9
- */
10
- class BaseEval {
11
- /**
12
- * Gets the parser options.
13
- */
14
- get parserOptions() {
15
- return this._parserOptions;
16
- }
17
- /**
18
- * Sets the parser options.
19
- * @param value The parser options to set.
20
- */
21
- set parserOptions(value) {
22
- this._parserOptions = value;
23
- }
24
- }
25
-
26
7
  /**
27
8
  * Represents a registry that stores key-value pairs.
28
9
  */
@@ -968,207 +949,600 @@ const getContextKey = (context, key, caseInsensitive) => {
968
949
  };
969
950
 
970
951
  /**
971
- * @description
972
- * Parses expression and returns ES6/ES2020 AST.
973
- * @param expr expression to parse
974
- * @param options parser options
975
- */
976
- const parse = (expr, options) => {
977
- options = { ecmaVersion: 2020, ...options };
978
- const acornOptions = { ecmaVersion: 2020, ...options };
979
- const program = parse$1(expr, acornOptions);
980
- if (!options.extractExpressions) {
981
- return program;
982
- }
983
- return extractExpression(program);
984
- };
985
- /**
986
- * @description
987
- * Walks through the AST and extracts first expression.
988
- * @param expr expression to parse
989
- */
990
- const extractExpression = (program) => {
991
- if (program.body.length === 1) {
992
- const expression = program.body[0];
993
- if (expression.type === 'ExpressionStatement') {
994
- return expression.expression;
995
- }
996
- }
997
- return undefined;
998
- };
999
-
1000
- const pushVisitorResult = (node, st, value) => {
1001
- const key = getKey(node);
1002
- const result = st.result;
1003
- result.stack.push(value);
1004
- result.trace.set(key, value);
1005
- return value;
1006
- };
1007
- const popVisitorResult = (node, st) => {
1008
- const result = st.result;
1009
- const value = result.stack.pop();
1010
- return value;
1011
- };
1012
- const pushVisitorResultAsync = (node, st, value) => {
1013
- const key = getKey(node);
1014
- const result = st.result;
1015
- result.stack.push(value);
1016
- result.trace.set(key, value);
1017
- return value;
1018
- };
1019
- const popVisitorResultAsync = (node, st) => {
1020
- const result = st.result;
1021
- const value = result.stack.pop();
1022
- return value;
1023
- };
1024
- const getKey = (node) => {
1025
- const key = `${node.type}(${node.start}:${node.end})`;
1026
- return key;
1027
- };
1028
-
1029
- const beforeVisitor = (node, st) => {
1030
- const options = st.options;
1031
- if (options?.['trackTime']) {
1032
- const t = performance.now();
1033
- console.time('before: ' + node.type);
1034
- return t;
1035
- }
1036
- return undefined;
1037
- };
1038
-
1039
- const afterVisitor = (node, st) => {
1040
- const options = st.options;
1041
- if (options?.['trackTime']) {
1042
- const t = performance.now();
1043
- console.time('after: ' + node.type);
1044
- return t;
952
+ * Represents the evaluation context for the code execution.
953
+ */
954
+ class EvalContext {
955
+ /**
956
+ * Gets the original registry.
957
+ */
958
+ get original() {
959
+ return this._original;
1045
960
  }
1046
- return undefined;
1047
- };
1048
-
1049
- var RecursiveVisitorResultType;
1050
- (function (RecursiveVisitorResultType) {
1051
- RecursiveVisitorResultType[RecursiveVisitorResultType["Stack"] = 0] = "Stack";
1052
- RecursiveVisitorResultType[RecursiveVisitorResultType["Registry"] = 1] = "Registry";
1053
- })(RecursiveVisitorResultType || (RecursiveVisitorResultType = {}));
1054
-
1055
- const literals = Registry.fromObject({
1056
- 'undefined': undefined,
1057
- 'null': null,
1058
- 'true': true,
1059
- 'false': false,
1060
- }, { caseInsensitive: true });
1061
- const identifierVisitor = (node, st) => {
1062
- if (st.options?.caseInsensitive) {
1063
- return identifierVisitorCaseInsensitive(node, st);
961
+ /**
962
+ * Gets the scopes registry.
963
+ */
964
+ get priorScopes() {
965
+ return this._priorScopes;
1064
966
  }
1065
- beforeVisitor(node, st);
1066
- const context = st.context;
1067
- const value = node.name === 'this'
1068
- ? st.context
1069
- : context?.get(node.name);
1070
- pushVisitorResult(node, st, value);
1071
- afterVisitor(node, st);
1072
- };
1073
- const identifierVisitorCaseInsensitive = (node, st) => {
1074
- beforeVisitor(node, st);
1075
- const context = st.context;
1076
- const value = equalIgnoreCase(node.name, 'this')
1077
- ? st.context
1078
- : context?.get(node.name) ?? literals.get(node.name);
1079
- pushVisitorResult(node, st, value);
1080
- afterVisitor(node, st);
1081
- };
1082
-
1083
- const literalVisitor = (node, st) => {
1084
- beforeVisitor(node, st);
1085
- const value = node.value;
1086
- pushVisitorResult(node, st, value);
1087
- afterVisitor(node, st);
1088
- };
1089
-
1090
- const binaryExpressionVisitor = (node, st, callback) => {
1091
- beforeVisitor(node, st);
1092
- callback(node.left, st);
1093
- const left = popVisitorResult(node, st);
1094
- callback(node.right, st);
1095
- const right = popVisitorResult(node, st);
1096
- const value = node.operator === '+' ? left + right :
1097
- node.operator === '-' ? left - right :
1098
- node.operator === '*' ? left * right :
1099
- node.operator === '/' ? left / right :
1100
- node.operator === '%' ? left % right :
1101
- node.operator === '**' ? left ** right :
1102
- node.operator === '<<' ? left << right :
1103
- node.operator === '>>' ? left >> right :
1104
- node.operator === '>>>' ? left >>> right :
1105
- node.operator === '&' ? left & right :
1106
- node.operator === '^' ? left ^ right :
1107
- node.operator === '|' ? left | right :
1108
- node.operator === '==' ? left == right :
1109
- node.operator === '!=' ? left != right :
1110
- node.operator === '===' ? left === right :
1111
- node.operator === '!==' ? left !== right :
1112
- node.operator === '<' ? left < right :
1113
- node.operator === '<=' ? left <= right :
1114
- node.operator === '>' ? left > right :
1115
- node.operator === '>=' ? left >= right :
1116
- node.operator === 'in' ? left in right :
1117
- node.operator === 'instanceof' ? left instanceof right :
1118
- node.operator === '??' ? left ?? right :
1119
- undefined;
1120
- pushVisitorResult(node, st, value);
1121
- afterVisitor(node, st);
1122
- };
1123
-
1124
- const memberExpressionVisitor = (node, st, callback) => {
1125
- beforeVisitor(node, st);
1126
- const [, , value] = evaluateMember(node, st, callback);
1127
- pushVisitorResult(node, st, value);
1128
- afterVisitor(node, st);
1129
- };
1130
- const evaluateMember = (node, st, callback) => {
1131
- // Get the object
1132
- callback(node.object, st);
1133
- const obj = popVisitorResult(node, st);
1134
- const object = (node.optional ? (obj || {}) : obj);
1135
- // Get the property
1136
- let key;
1137
- if (node.property.type === 'Identifier') {
1138
- key = node.property.name;
967
+ /**
968
+ * Gets the scopes registry.
969
+ */
970
+ get scopes() {
971
+ return this._scopes;
1139
972
  }
1140
- else if (node.property.type === 'Literal') {
1141
- key = node.property.value;
973
+ /**
974
+ * Gets the lookups registry.
975
+ */
976
+ get lookups() {
977
+ return this._lookups;
1142
978
  }
1143
- else {
1144
- callback(node.property, st);
1145
- key = popVisitorResult(node, st);
979
+ /**
980
+ * Gets the evaluation options.
981
+ */
982
+ get options() {
983
+ return this._options;
1146
984
  }
1147
- // Get the value
1148
- if (object === st.context) {
1149
- const value = st.context.get(key);
1150
- const thisValue = st.context.getThis(key);
1151
- return [thisValue ?? object, key, value];
985
+ /**
986
+ * Creates a new instance of EvalContext.
987
+ * @param original - The original registry or an object to create a registry from.
988
+ * @param options - The evaluation options.
989
+ */
990
+ constructor(original, options) {
991
+ this.type = 'EvalContext';
992
+ this._original = original;
993
+ this._priorScopes = [];
994
+ this._scopes = new Stack();
995
+ this._options = options;
996
+ this._lookups = new Registry();
1152
997
  }
1153
- else {
1154
- const caseInsesitive = !!(st.options?.caseInsensitive);
1155
- const pair = getKeyValue(object, key, caseInsesitive);
1156
- if (pair) {
1157
- const [key, value] = pair;
1158
- return [object, key, value];
998
+ /**
999
+ * Converts the given context to an instance of EvalContext.
1000
+ * @param context - The context to convert.
1001
+ * @param options - The evaluation options.
1002
+ * @returns The converted EvalContext instance.
1003
+ */
1004
+ static fromContext(context, options) {
1005
+ if (context instanceof EvalContext) {
1006
+ return context;
1159
1007
  }
1008
+ const ctx = fromContext(context ?? {}, options);
1009
+ return new EvalContext(ctx, options ?? {});
1160
1010
  }
1161
- return [object, key, undefined];
1162
- };
1163
-
1164
- const arrayExpressionVisitor = (node, st, callback) => {
1165
- beforeVisitor(node, st);
1166
- const elements = evaluateArray(node, node.elements, st, callback);
1167
- pushVisitorResult(node, st, elements);
1168
- afterVisitor(node, st);
1169
- };
1170
- const evaluateArray = (node, items, st, callback) => {
1171
- const elements = [];
1011
+ /**
1012
+ * Gets the value associated with the specified key from the evaluation context.
1013
+ * @param key - The key to retrieve the value for.
1014
+ * @returns The value associated with the key, or undefined if not found.
1015
+ */
1016
+ get(key) {
1017
+ for (const scope of this._scopes.asArray()) {
1018
+ const value = getContextValue(scope, key);
1019
+ if (value !== undefined) {
1020
+ return value;
1021
+ }
1022
+ }
1023
+ if (this._original) {
1024
+ const value = getContextValue(this._original, key);
1025
+ if (value !== undefined) {
1026
+ return value;
1027
+ }
1028
+ }
1029
+ for (const scope of this._priorScopes) {
1030
+ const value = scope.get(key);
1031
+ if (value !== undefined) {
1032
+ return value;
1033
+ }
1034
+ }
1035
+ for (const lookup of Array.from(this._lookups.values)) {
1036
+ const value = lookup(key, this, this._options);
1037
+ if (value !== undefined) {
1038
+ return value;
1039
+ }
1040
+ }
1041
+ return undefined;
1042
+ }
1043
+ /**
1044
+ * Retrieves the `this` value of the specified key from the evaluation context.
1045
+ * The value is searched in the original context, prior scopes, and lookup functions.
1046
+ * @param key - The key to retrieve the value for.
1047
+ * @returns The `this` value associated with the key, or undefined if not found.
1048
+ */
1049
+ getThis(key) {
1050
+ if (this._original) {
1051
+ const value = getContextValue(this._original, key);
1052
+ if (value !== undefined) {
1053
+ return this._original;
1054
+ }
1055
+ }
1056
+ for (const scope of this._priorScopes) {
1057
+ const value = getContextValue(this._original, key);
1058
+ if (value !== undefined) {
1059
+ return scope;
1060
+ }
1061
+ }
1062
+ for (const lookup of Array.from(this._lookups.values)) {
1063
+ const value = lookup(key, this, this._options);
1064
+ if (value !== undefined) {
1065
+ return lookup;
1066
+ }
1067
+ }
1068
+ return undefined;
1069
+ }
1070
+ /**
1071
+ * Retrieves the value associated with the specified key from the evaluation context.
1072
+ *
1073
+ * @param key - The key to retrieve the value for.
1074
+ * @returns The value associated with the key, or undefined if the key is not found.
1075
+ */
1076
+ getKey(key) {
1077
+ const caseInsensitive = !!this._options.caseInsensitive;
1078
+ for (const scope of this._scopes.asArray()) {
1079
+ const foundKey = getContextKey(scope, key, caseInsensitive);
1080
+ if (foundKey !== undefined) {
1081
+ return foundKey;
1082
+ }
1083
+ }
1084
+ if (this._original) {
1085
+ const foundKey = getContextKey(this._original, key, caseInsensitive);
1086
+ if (foundKey !== undefined) {
1087
+ return foundKey;
1088
+ }
1089
+ }
1090
+ for (const scope of this._priorScopes) {
1091
+ const foundKey = getContextKey(scope.context, key, caseInsensitive);
1092
+ if (foundKey !== undefined) {
1093
+ return foundKey;
1094
+ }
1095
+ }
1096
+ return undefined;
1097
+ }
1098
+ /**
1099
+ * Sets a key-value pair in the context.
1100
+ * If the original context is a Registry, the key-value pair is set using the Registry's set method.
1101
+ * If the original context is an Object, the key-value pair is set directly on the object.
1102
+ * @param key - The key of the pair.
1103
+ * @param value - The value of the pair.
1104
+ */
1105
+ set(key, value) {
1106
+ if (this._original && this._original instanceof Registry) {
1107
+ const registry = this._original;
1108
+ registry.set(key, value);
1109
+ }
1110
+ else if (this._original && this._original instanceof Object) {
1111
+ const obj = this._original;
1112
+ obj[key] = value;
1113
+ }
1114
+ }
1115
+ /**
1116
+ * Pushes a context to the scope stack.
1117
+ * @param context - The context to push.
1118
+ * @param options - The evaluation options.
1119
+ */
1120
+ push(context, options) {
1121
+ const ctx = fromContext(context, options);
1122
+ this._scopes.push(ctx);
1123
+ }
1124
+ /**
1125
+ * Pops a context from the scope stack.
1126
+ */
1127
+ pop() {
1128
+ this._scopes.pop();
1129
+ }
1130
+ /**
1131
+ * Converts the EvalContext instance to an object representation.
1132
+ * If the original value is an instance of Registry, it converts it to an object using the toObject method of the registry.
1133
+ * If the original value is an object, it returns the original object.
1134
+ * @returns The object representation of the EvalContext instance.
1135
+ */
1136
+ toObject() {
1137
+ if (this._original && this._original instanceof Registry) {
1138
+ const registry = this._original;
1139
+ const object = registry.toObject();
1140
+ return object;
1141
+ }
1142
+ else if (this._original && this._original instanceof Object) {
1143
+ const obj = this._original;
1144
+ return obj;
1145
+ }
1146
+ return undefined;
1147
+ }
1148
+ }
1149
+
1150
+ /**
1151
+ * Represents a trace of evaluation for a specific code execution.
1152
+ */
1153
+ class EvalTrace extends Array {
1154
+ /**
1155
+ * Adds a new trace item to the evaluation trace.
1156
+ * @param node - The AST node associated with the trace item.
1157
+ * @param value - The value of the evaluated expression.
1158
+ * @param expression - The expression being evaluated.
1159
+ */
1160
+ add(node, value, expression) {
1161
+ const item = {
1162
+ type: node.type,
1163
+ value
1164
+ };
1165
+ if (expression) {
1166
+ item.expression = expression.substring(node.start, node.end);
1167
+ }
1168
+ this.push(item);
1169
+ }
1170
+ }
1171
+
1172
+ /**
1173
+ * Represents the result of an evaluation.
1174
+ */
1175
+ class EvalResult {
1176
+ /**
1177
+ * Gets the stack of evaluated values.
1178
+ */
1179
+ get stack() {
1180
+ return this._stack;
1181
+ }
1182
+ /**
1183
+ * Gets the evaluated value.
1184
+ */
1185
+ get value() {
1186
+ return this._value;
1187
+ }
1188
+ /**
1189
+ * Gets the error that occurred during evaluation.
1190
+ */
1191
+ get error() {
1192
+ return this._error;
1193
+ }
1194
+ /**
1195
+ * Gets the error message associated with the evaluation error.
1196
+ */
1197
+ get errorMessage() {
1198
+ return this._errorMessage;
1199
+ }
1200
+ /**
1201
+ * Gets whether the evaluation resulted in an error.
1202
+ */
1203
+ get isError() {
1204
+ return this._isError;
1205
+ }
1206
+ /**
1207
+ * Gets whether the evaluation was successful.
1208
+ */
1209
+ get isSuccess() {
1210
+ return this._isSuccess;
1211
+ }
1212
+ /**
1213
+ * Gets whether the evaluated value is undefined.
1214
+ */
1215
+ get isUndefined() {
1216
+ return this._isUndefined;
1217
+ }
1218
+ /**
1219
+ * Gets the trace of evaluated values.
1220
+ */
1221
+ get trace() {
1222
+ return this._trace;
1223
+ }
1224
+ /**
1225
+ * Gets the evaluation context.
1226
+ */
1227
+ get context() {
1228
+ return this._context;
1229
+ }
1230
+ /**
1231
+ * Gets the evaluation options.
1232
+ */
1233
+ get options() {
1234
+ return this._context.options;
1235
+ }
1236
+ /**
1237
+ * Gets the duration of the evaluation result.
1238
+ * @returns The duration in milliseconds.
1239
+ */
1240
+ get duration() {
1241
+ if (!this._startDate || !this._endDate) {
1242
+ return undefined;
1243
+ }
1244
+ return this._endDate - this._startDate;
1245
+ }
1246
+ /**
1247
+ * Gets the expression associated with the evaluation result.
1248
+ * @returns The expression as a string, or undefined if no expression is associated.
1249
+ */
1250
+ get expression() {
1251
+ return this._expression;
1252
+ }
1253
+ /**
1254
+ * Sets the expression for the evaluation result.
1255
+ *
1256
+ * @param value - The expression to be set.
1257
+ */
1258
+ set expression(value) {
1259
+ this._expression = value;
1260
+ }
1261
+ /**
1262
+ * Creates a new instance of EvalResult.
1263
+ * @param trace The trace of evaluated values.
1264
+ * @param context The evaluation context.
1265
+ */
1266
+ constructor(context) {
1267
+ this._stack = new Stack();
1268
+ this._trace = new EvalTrace();
1269
+ this._context = context;
1270
+ }
1271
+ /**
1272
+ * Starts the evaluation process.
1273
+ */
1274
+ start() {
1275
+ this._startDate = performance.now();
1276
+ }
1277
+ /**
1278
+ * Stops the evaluation and records the end date.
1279
+ */
1280
+ stop() {
1281
+ this._endDate = performance.now();
1282
+ return this.duration;
1283
+ }
1284
+ /**
1285
+ * Sets the success value of the evaluation result.
1286
+ *
1287
+ * @param value The value to set as the success value.
1288
+ * @returns void
1289
+ */
1290
+ setSuccess(value) {
1291
+ this._value = value;
1292
+ this._isSuccess = true;
1293
+ this._isError = false;
1294
+ this._isUndefined = false;
1295
+ }
1296
+ /**
1297
+ * Sets the failure state of the evaluation result.
1298
+ * @param error The error object associated with the failure.
1299
+ */
1300
+ setFailure(error) {
1301
+ this._error = error;
1302
+ if (error instanceof Error) {
1303
+ this._errorMessage = error.message;
1304
+ }
1305
+ this._isSuccess = false;
1306
+ this._isError = true;
1307
+ this._isUndefined = false;
1308
+ }
1309
+ }
1310
+
1311
+ /**
1312
+ * Represents the evaluation state, which includes the context, result, and options.
1313
+ */
1314
+ class EvalState {
1315
+ /**
1316
+ * Gets the evaluation context.
1317
+ */
1318
+ get context() {
1319
+ return this._context;
1320
+ }
1321
+ /**
1322
+ * Gets the evaluation result.
1323
+ */
1324
+ get result() {
1325
+ return this._result;
1326
+ }
1327
+ /**
1328
+ * Gets the evaluation options.
1329
+ */
1330
+ get options() {
1331
+ return this._options;
1332
+ }
1333
+ /**
1334
+ * Gets whether the evaluation is asynchronous.
1335
+ */
1336
+ get isAsync() {
1337
+ return this._isAsync;
1338
+ }
1339
+ /**
1340
+ * Represents the state of an evaluation.
1341
+ * @param context The evaluation context.
1342
+ * @param result The evaluation result.
1343
+ * @param options The evaluation options.
1344
+ * @param isAsync Indicates whether the evaluation is asynchronous.
1345
+ */
1346
+ constructor(context, result, options, isAsync) {
1347
+ this._context = context;
1348
+ this._result = result;
1349
+ this._options = options;
1350
+ this._isAsync = isAsync;
1351
+ }
1352
+ /**
1353
+ * Creates an instance of EvalState from a given context, options, and async flag.
1354
+ *
1355
+ * @param context - The evaluation context or context object.
1356
+ * @param options - The evaluation options.
1357
+ * @param isAsync - A flag indicating whether the evaluation is asynchronous.
1358
+ * @returns The created EvalState instance.
1359
+ */
1360
+ static fromContext(context, options, isAsync) {
1361
+ const ctx = EvalContext.fromContext(context, options);
1362
+ const result = new EvalResult(ctx);
1363
+ const state = new EvalState(ctx, result, options, isAsync);
1364
+ return state;
1365
+ }
1366
+ }
1367
+
1368
+ const defaultParserOptions = {
1369
+ ...defaultOptions$1,
1370
+ ecmaVersion: 2020,
1371
+ extractExpressions: false,
1372
+ cacheSize: 100
1373
+ };
1374
+
1375
+ const pushVisitorResult = (node, st, value) => {
1376
+ const result = st.result;
1377
+ result.stack.push(value);
1378
+ result.trace.add(node, value, st.result.expression);
1379
+ return value;
1380
+ };
1381
+ const popVisitorResult = (node, st) => {
1382
+ const result = st.result;
1383
+ const value = result.stack.pop();
1384
+ return value;
1385
+ };
1386
+ const pushVisitorResultAsync = (node, st, value) => {
1387
+ const result = st.result;
1388
+ result.stack.push(value);
1389
+ result.trace.add(node, value, st.result.expression);
1390
+ return value;
1391
+ };
1392
+ const popVisitorResultAsync = (node, st) => {
1393
+ const result = st.result;
1394
+ const value = result.stack.pop();
1395
+ return value;
1396
+ };
1397
+
1398
+ const beforeVisitor = (node, st) => {
1399
+ const options = st.options;
1400
+ if (options?.['trackTime']) {
1401
+ const t = performance.now();
1402
+ console.time('before: ' + node.type);
1403
+ return t;
1404
+ }
1405
+ return undefined;
1406
+ };
1407
+
1408
+ const afterVisitor = (node, st) => {
1409
+ const options = st.options;
1410
+ if (options?.['trackTime']) {
1411
+ const t = performance.now();
1412
+ console.time('after: ' + node.type);
1413
+ return t;
1414
+ }
1415
+ return undefined;
1416
+ };
1417
+
1418
+ var RecursiveVisitorResultType;
1419
+ (function (RecursiveVisitorResultType) {
1420
+ RecursiveVisitorResultType[RecursiveVisitorResultType["Stack"] = 0] = "Stack";
1421
+ RecursiveVisitorResultType[RecursiveVisitorResultType["Registry"] = 1] = "Registry";
1422
+ })(RecursiveVisitorResultType || (RecursiveVisitorResultType = {}));
1423
+
1424
+ const literals = Registry.fromObject({
1425
+ 'undefined': undefined,
1426
+ 'null': null,
1427
+ 'true': true,
1428
+ 'false': false,
1429
+ }, { caseInsensitive: true });
1430
+ const identifierVisitor = (node, st) => {
1431
+ if (st.options?.caseInsensitive) {
1432
+ return identifierVisitorCaseInsensitive(node, st);
1433
+ }
1434
+ beforeVisitor(node, st);
1435
+ const context = st.context;
1436
+ const value = node.name === 'this'
1437
+ ? st.context
1438
+ : context?.get(node.name);
1439
+ pushVisitorResult(node, st, value);
1440
+ afterVisitor(node, st);
1441
+ };
1442
+ const identifierVisitorCaseInsensitive = (node, st) => {
1443
+ beforeVisitor(node, st);
1444
+ const context = st.context;
1445
+ const value = equalIgnoreCase(node.name, 'this')
1446
+ ? st.context
1447
+ : context?.get(node.name) ?? literals.get(node.name);
1448
+ pushVisitorResult(node, st, value);
1449
+ afterVisitor(node, st);
1450
+ };
1451
+
1452
+ const literalVisitor = (node, st) => {
1453
+ beforeVisitor(node, st);
1454
+ const value = node.value;
1455
+ pushVisitorResult(node, st, value);
1456
+ afterVisitor(node, st);
1457
+ };
1458
+
1459
+ const binaryExpressionVisitor = (node, st, callback) => {
1460
+ beforeVisitor(node, st);
1461
+ callback(node.left, st);
1462
+ const left = popVisitorResult(node, st);
1463
+ callback(node.right, st);
1464
+ const right = popVisitorResult(node, st);
1465
+ const value = node.operator === '+' ? left + right :
1466
+ node.operator === '-' ? left - right :
1467
+ node.operator === '*' ? left * right :
1468
+ node.operator === '/' ? left / right :
1469
+ node.operator === '%' ? left % right :
1470
+ node.operator === '**' ? left ** right :
1471
+ node.operator === '<<' ? left << right :
1472
+ node.operator === '>>' ? left >> right :
1473
+ node.operator === '>>>' ? left >>> right :
1474
+ node.operator === '&' ? left & right :
1475
+ node.operator === '^' ? left ^ right :
1476
+ node.operator === '|' ? left | right :
1477
+ node.operator === '==' ? left == right :
1478
+ node.operator === '!=' ? left != right :
1479
+ node.operator === '===' ? left === right :
1480
+ node.operator === '!==' ? left !== right :
1481
+ node.operator === '<' ? left < right :
1482
+ node.operator === '<=' ? left <= right :
1483
+ node.operator === '>' ? left > right :
1484
+ node.operator === '>=' ? left >= right :
1485
+ node.operator === 'in' ? left in right :
1486
+ node.operator === 'instanceof' ? left instanceof right :
1487
+ node.operator === '??' ? left ?? right :
1488
+ undefined;
1489
+ pushVisitorResult(node, st, value);
1490
+ afterVisitor(node, st);
1491
+ };
1492
+
1493
+ const memberExpressionVisitor = (node, st, callback) => {
1494
+ beforeVisitor(node, st);
1495
+ const [, , value] = evaluateMember(node, st, callback);
1496
+ pushVisitorResult(node, st, value);
1497
+ afterVisitor(node, st);
1498
+ };
1499
+ const evaluateMember = (node, st, callback) => {
1500
+ // Get the object
1501
+ callback(node.object, st);
1502
+ const obj = popVisitorResult(node, st);
1503
+ const object = (node.optional ? (obj || {}) : obj);
1504
+ // Get the property
1505
+ let key;
1506
+ if (node.property.type === 'Identifier') {
1507
+ key = node.property.name;
1508
+ }
1509
+ else if (node.property.type === 'Literal') {
1510
+ key = node.property.value;
1511
+ }
1512
+ else {
1513
+ callback(node.property, st);
1514
+ key = popVisitorResult(node, st);
1515
+ }
1516
+ // Get the value
1517
+ if (object === st.context) {
1518
+ const value = st.context.get(key);
1519
+ const thisValue = st.context.getThis(key);
1520
+ return [thisValue ?? object, key, value];
1521
+ }
1522
+ else if (object instanceof EvalScope) {
1523
+ const value = object.get(key);
1524
+ const thisValue = object;
1525
+ return [thisValue ?? object, key, value];
1526
+ }
1527
+ else {
1528
+ const caseInsesitive = !!(st.options?.caseInsensitive);
1529
+ const pair = getKeyValue(object, key, caseInsesitive);
1530
+ if (pair) {
1531
+ const [key, value] = pair;
1532
+ return [object, key, value];
1533
+ }
1534
+ }
1535
+ return [object, key, undefined];
1536
+ };
1537
+
1538
+ const arrayExpressionVisitor = (node, st, callback) => {
1539
+ beforeVisitor(node, st);
1540
+ const elements = evaluateArray(node, node.elements, st, callback);
1541
+ pushVisitorResult(node, st, elements);
1542
+ afterVisitor(node, st);
1543
+ };
1544
+ const evaluateArray = (node, items, st, callback) => {
1545
+ const elements = [];
1172
1546
  for (const element of items) {
1173
1547
  if (element === null || typeof element === 'undefined') {
1174
1548
  elements.push(element);
@@ -1467,32 +1841,161 @@ const assignmentExpressionVisitor = (node, st, callback) => {
1467
1841
  afterVisitor(node, st);
1468
1842
  };
1469
1843
 
1470
- const updateOperators = {
1471
- '++': (value) => { return value + 1; },
1472
- '--': (value) => { return value - 1; },
1473
- };
1474
- const updateExpressionVisitor = (node, st, callback) => {
1475
- beforeVisitor(node, st);
1476
- if (!st.context) {
1477
- throw new Error(`Context is not set.`);
1478
- }
1479
- else if (node.argument.type === 'Identifier') {
1480
- const key = st.options?.caseInsensitive
1481
- ? st.context.getKey(node.argument.name)
1482
- : node.argument.name;
1483
- const value = st.context?.get(key);
1484
- const newValue = updateOperators[node.operator](value);
1485
- st.context?.set(key, newValue);
1486
- pushVisitorResult(node, st, node.prefix ? newValue : value);
1487
- }
1488
- else if (node.argument.type === 'MemberExpression') {
1489
- callback(node.argument, st);
1490
- const [, property, value] = evaluateMember(node.argument, st, callback);
1491
- const newValue = updateOperators[node.operator](value);
1492
- st.context?.set(property, newValue);
1493
- pushVisitorResult(node, st, node.prefix ? newValue : value);
1844
+ const updateOperators = {
1845
+ '++': (value) => { return value + 1; },
1846
+ '--': (value) => { return value - 1; },
1847
+ };
1848
+ const updateExpressionVisitor = (node, st, callback) => {
1849
+ beforeVisitor(node, st);
1850
+ if (!st.context) {
1851
+ throw new Error(`Context is not set.`);
1852
+ }
1853
+ else if (node.argument.type === 'Identifier') {
1854
+ const key = st.options?.caseInsensitive
1855
+ ? st.context.getKey(node.argument.name)
1856
+ : node.argument.name;
1857
+ const value = st.context?.get(key);
1858
+ const newValue = updateOperators[node.operator](value);
1859
+ st.context?.set(key, newValue);
1860
+ pushVisitorResult(node, st, node.prefix ? newValue : value);
1861
+ }
1862
+ else if (node.argument.type === 'MemberExpression') {
1863
+ callback(node.argument, st);
1864
+ const [, property, value] = evaluateMember(node.argument, st, callback);
1865
+ const newValue = updateOperators[node.operator](value);
1866
+ st.context?.set(property, newValue);
1867
+ pushVisitorResult(node, st, node.prefix ? newValue : value);
1868
+ }
1869
+ afterVisitor(node, st);
1870
+ };
1871
+
1872
+ /**
1873
+ * @description
1874
+ * Parses expression and returns ES6/ES2020 AST.
1875
+ * @param expr expression to parse
1876
+ * @param options parser options
1877
+ */
1878
+ const parse = (expr, options) => {
1879
+ options = { ecmaVersion: 2020, ...options };
1880
+ const acornOptions = { ecmaVersion: 2020, ...options };
1881
+ const program = parse$1(expr, acornOptions);
1882
+ if (!options.extractExpressions) {
1883
+ return program;
1884
+ }
1885
+ return extractExpression(program);
1886
+ };
1887
+ /**
1888
+ * @description
1889
+ * Walks through the AST and extracts first expression.
1890
+ * @param expr expression to parse
1891
+ */
1892
+ const extractExpression = (program) => {
1893
+ if (program.body.length === 1) {
1894
+ const expression = program.body[0];
1895
+ if (expression.type === 'ExpressionStatement') {
1896
+ return expression.expression;
1897
+ }
1898
+ }
1899
+ return undefined;
1900
+ };
1901
+
1902
+ /**
1903
+ * Evaluates the given node and returns the result.
1904
+ *
1905
+ * @param node The node to evaluate.
1906
+ * @param state The evaluation state.
1907
+ * @returns The result of the evaluation.
1908
+ */
1909
+ const evaluate = (node, state) => {
1910
+ if (node) {
1911
+ state.result.start();
1912
+ try {
1913
+ const visitors = getDefaultVisitors();
1914
+ walk.recursive(node, state, visitors);
1915
+ const value = popVisitorResult(node, state);
1916
+ state.result.stop();
1917
+ state.result.setSuccess(value);
1918
+ return value;
1919
+ }
1920
+ catch (error) {
1921
+ state.result.stop();
1922
+ state.result.setFailure(error);
1923
+ throw error;
1924
+ }
1925
+ }
1926
+ return undefined;
1927
+ };
1928
+ /**
1929
+ * Asynchronously evaluates the given abstract syntax tree (AST) using the provided evaluation state.
1930
+ * @param ast The abstract syntax tree to evaluate.
1931
+ * @param state The evaluation state.
1932
+ * @returns A promise that resolves to the evaluated value or undefined.
1933
+ */
1934
+ const evaluateAsync = (ast, state) => {
1935
+ const promise = new Promise((resolve) => {
1936
+ const value = evaluate(ast, state);
1937
+ resolve(value);
1938
+ });
1939
+ return promise;
1940
+ };
1941
+
1942
+ /**
1943
+ * Compiles the given node and returns a function that can be used to evaluate it.
1944
+ *
1945
+ * @param node The node to compile.
1946
+ * @returns A function that takes an `EvalState` and returns the result of evaluating the node.
1947
+ */
1948
+ const compile = (node) => {
1949
+ return evaluate.bind(null, node);
1950
+ };
1951
+ /**
1952
+ * Compiles the given node asynchronously.
1953
+ *
1954
+ * @param node - The node to compile.
1955
+ * @returns A function that takes an `EvalState` object and returns a `Promise` that resolves to the compiled result.
1956
+ */
1957
+ const compileAsync = (node) => {
1958
+ return evaluateAsync.bind(null, node);
1959
+ };
1960
+ /**
1961
+ * Calls the provided function with the given state and returns the result.
1962
+ *
1963
+ * @param fn The function to be called.
1964
+ * @param state The state to be passed to the function.
1965
+ * @returns The result of calling the function.
1966
+ */
1967
+ const call = (fn, state) => {
1968
+ const value = fn(state);
1969
+ return value;
1970
+ };
1971
+ /**
1972
+ * Calls an asynchronous function with the given state and returns a promise that resolves to the result.
1973
+ * @param fn The asynchronous function to call.
1974
+ * @param state The state to pass to the function.
1975
+ * @returns A promise that resolves to the result of the function.
1976
+ */
1977
+ const callAsync = (fn, state) => {
1978
+ const promise = fn(state);
1979
+ return promise;
1980
+ };
1981
+
1982
+ /**
1983
+ * Finds all nodes of a specific type in the given AST.
1984
+ *
1985
+ * @param ast The AST to search in.
1986
+ * @param searchType The type of nodes to search for.
1987
+ * @returns An array of nodes of the specified type if found, otherwise undefined.
1988
+ */
1989
+ const extract = (node, searchType) => {
1990
+ if (node) {
1991
+ const state = [];
1992
+ const visitors = {
1993
+ [searchType]: (node) => { state.push(node); return; }
1994
+ };
1995
+ walk.simple(node, visitors);
1996
+ return state.length > 0 ? state : undefined;
1494
1997
  }
1495
- afterVisitor(node, st);
1998
+ return undefined;
1496
1999
  };
1497
2000
 
1498
2001
  const arrowFunctionExpressionVisitor = (node, st, callback) => {
@@ -1639,551 +2142,230 @@ const evaluateRestElement = (pattern, st, callback, args) => {
1639
2142
  // return object;
1640
2143
  // }
1641
2144
 
1642
- /**
1643
- * Evaluates the given node and returns the result.
1644
- *
1645
- * @param node The node to evaluate.
1646
- * @param state The evaluation state.
1647
- * @returns The result of the evaluation.
1648
- */
1649
- const evaluate = (node, state) => {
1650
- if (node) {
1651
- state.result.start();
1652
- try {
1653
- const visitors = getDefaultVisitors();
1654
- walk.recursive(node, state, visitors);
1655
- const value = popVisitorResult(node, state);
1656
- state.result.stop();
1657
- state.result.setSuccess(value);
1658
- return value;
1659
- }
1660
- catch (error) {
1661
- state.result.stop();
1662
- state.result.setFailure(error);
1663
- throw error;
1664
- }
1665
- }
1666
- return undefined;
1667
- };
1668
- /**
1669
- * Asynchronously evaluates the given abstract syntax tree (AST) using the provided evaluation state.
1670
- * @param ast The abstract syntax tree to evaluate.
1671
- * @param state The evaluation state.
1672
- * @returns A promise that resolves to the evaluated value or undefined.
1673
- */
1674
- const evaluateAsync = (ast, state) => {
1675
- const promise = new Promise((resolve) => {
1676
- const value = evaluate(ast, state);
1677
- resolve(value);
1678
- });
1679
- return promise;
1680
- };
1681
-
1682
- /**
1683
- * Compiles the given node and returns a function that can be used to evaluate it.
1684
- *
1685
- * @param node The node to compile.
1686
- * @returns A function that takes an `EvalState` and returns the result of evaluating the node.
1687
- */
1688
- const compile = (node) => {
1689
- return evaluate.bind(null, node);
1690
- };
1691
- /**
1692
- * Compiles the given node asynchronously.
1693
- *
1694
- * @param node - The node to compile.
1695
- * @returns A function that takes an `EvalState` object and returns a `Promise` that resolves to the compiled result.
1696
- */
1697
- const compileAsync = (node) => {
1698
- return evaluateAsync.bind(null, node);
1699
- };
1700
- /**
1701
- * Calls the provided function with the given state and returns the result.
1702
- *
1703
- * @param fn The function to be called.
1704
- * @param state The state to be passed to the function.
1705
- * @returns The result of calling the function.
1706
- */
1707
- const call = (fn, state) => {
1708
- const value = fn(state);
1709
- return value;
1710
- };
1711
- /**
1712
- * Calls an asynchronous function with the given state and returns a promise that resolves to the result.
1713
- * @param fn The asynchronous function to call.
1714
- * @param state The state to pass to the function.
1715
- * @returns A promise that resolves to the result of the function.
1716
- */
1717
- const callAsync = (fn, state) => {
1718
- const promise = fn(state);
1719
- return promise;
1720
- };
1721
-
1722
- /**
1723
- * Finds all nodes of a specific type in the given AST.
1724
- *
1725
- * @param ast The AST to search in.
1726
- * @param searchType The type of nodes to search for.
1727
- * @returns An array of nodes of the specified type if found, otherwise undefined.
1728
- */
1729
- const extract = (node, searchType) => {
1730
- if (node) {
1731
- const state = [];
1732
- const visitors = {
1733
- [searchType]: (node) => { state.push(node); return; }
1734
- };
1735
- walk.simple(node, visitors);
1736
- return state.length > 0 ? state : undefined;
1737
- }
1738
- return undefined;
2145
+ const defaultEvalScopeOptions = {
2146
+ global: false,
2147
+ caseInsensitive: false,
2148
+ namespace: undefined,
2149
+ thisArg: undefined
1739
2150
  };
1740
-
1741
- /**
1742
- * @description
1743
- * Service for parsing expressions and returning ES6/ES2020 AST.
1744
- */
1745
- class ParserService extends BaseEval {
1746
- /**
1747
- * Constructs a new instance of the ParserService class.
1748
- */
1749
- constructor() {
1750
- super();
1751
- this.parserOptions = {
1752
- ...defaultOptions$1,
1753
- ecmaVersion: 2020,
1754
- extractExpressions: true,
1755
- cacheSize: 100
1756
- };
1757
- if (this.parserOptions.cacheSize) {
1758
- this._cache = new Cache(this.parserOptions.cacheSize);
1759
- }
1760
- }
1761
- /**
1762
- * @description
1763
- * Returns acorn version.
1764
- */
1765
- get version() {
1766
- return version;
1767
- }
1768
- /**
1769
- * Gets the parser options.
1770
- * @returns The parser options.
1771
- */
1772
- get options() {
1773
- return this.parserOptions;
1774
- }
1775
- /**
1776
- * @description
1777
- * Parses expression and returns ES6/ES2023 AST.
1778
- * @param expr expression to parse
1779
- * @param options optional parser options
1780
- * @returns The parsed AST (Abstract Syntax Tree).
1781
- */
1782
- parse(expr, options) {
1783
- if (expr) {
1784
- try {
1785
- const parserOptions = { ...this.parserOptions, ...options };
1786
- const isCache = this.parserOptions.cacheSize && this._cache;
1787
- const ast = isCache
1788
- ? this.fromCacheOrParse(expr, parserOptions)
1789
- : parse(expr, parserOptions);
1790
- return ast;
1791
- }
1792
- catch (error) {
1793
- if (error instanceof Error) {
1794
- throw new Error(error.message);
1795
- }
1796
- else {
1797
- throw error;
1798
- }
1799
- }
1800
- }
1801
- return undefined;
1802
- }
1803
- //#region Private methods
1804
- fromCacheOrParse(expr, options) {
1805
- if (this._cache) {
1806
- const hashKey = this._cache.getHashKey('', expr);
1807
- let ast = this._cache.get(hashKey);
1808
- if (!ast) {
1809
- ast = parse(expr, options);
1810
- this._cache.set(hashKey, ast);
1811
- }
1812
- return ast;
1813
- }
1814
- return undefined;
1815
- }
1816
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1817
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, providedIn: 'root' }); }
1818
- }
1819
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, decorators: [{
1820
- type: Injectable,
1821
- args: [{
1822
- providedIn: 'root'
1823
- }]
1824
- }], ctorParameters: () => [] });
1825
-
1826
2151
  /**
1827
- * Represents the evaluation context for the code execution.
2152
+ * Represents an evaluation scope.
1828
2153
  */
1829
- class EvalContext {
1830
- /**
1831
- * Gets the original registry.
1832
- */
1833
- get original() {
1834
- return this._original;
1835
- }
1836
- /**
1837
- * Gets the scopes registry.
1838
- */
1839
- get priorScopes() {
1840
- return this._priorScopes;
1841
- }
1842
- /**
1843
- * Gets the scopes registry.
1844
- */
1845
- get scopes() {
1846
- return this._scopes;
1847
- }
1848
- /**
1849
- * Gets the lookups registry.
1850
- */
1851
- get lookups() {
1852
- return this._lookups;
1853
- }
1854
- /**
1855
- * Gets the evaluation options.
1856
- */
1857
- get options() {
1858
- return this._options;
1859
- }
2154
+ class EvalScope {
1860
2155
  /**
1861
- * Creates a new instance of EvalContext.
1862
- * @param original - The original registry or an object to create a registry from.
1863
- * @param options - The evaluation options.
2156
+ * Gets the context of the evaluation scope.
2157
+ * @returns The context object.
1864
2158
  */
1865
- constructor(original, options) {
1866
- this.type = 'EvalContext';
1867
- this._original = original;
1868
- this._priorScopes = [];
1869
- this._scopes = new Stack();
1870
- this._options = options;
1871
- this._lookups = new Registry();
2159
+ get context() {
2160
+ return this._context;
1872
2161
  }
1873
2162
  /**
1874
- * Converts the given context to an instance of EvalContext.
1875
- * @param context - The context to convert.
1876
- * @param options - The evaluation options.
1877
- * @returns The converted EvalContext instance.
2163
+ * Gets the options for evaluating the scope.
2164
+ * @returns The evaluation options.
1878
2165
  */
1879
- static fromContext(context, options) {
1880
- if (context instanceof EvalContext) {
1881
- return context;
1882
- }
1883
- const ctx = fromContext(context ?? {}, options);
1884
- return new EvalContext(ctx, options ?? {});
2166
+ get options() {
2167
+ return this._options;
1885
2168
  }
1886
2169
  /**
1887
- * Gets the value associated with the specified key from the evaluation context.
1888
- * @param key - The key to retrieve the value for.
1889
- * @returns The value associated with the key, or undefined if not found.
2170
+ * Creates a new instance of EvalScope.
2171
+ * @param context - The context of the evaluation scope.
2172
+ * @param options - The options for evaluating the scope.
1890
2173
  */
1891
- get(key) {
1892
- for (const scope of this._scopes.asArray()) {
1893
- const value = getContextValue(scope, key);
1894
- if (value !== undefined) {
1895
- return value;
1896
- }
1897
- }
1898
- if (this._original) {
1899
- const value = getContextValue(this._original, key);
1900
- if (value !== undefined) {
1901
- return value;
1902
- }
1903
- }
1904
- for (const scope of this._priorScopes) {
1905
- const value = getContextValue(scope, key);
1906
- if (value !== undefined) {
1907
- return value;
1908
- }
1909
- }
1910
- for (const lookup of Array.from(this._lookups.values)) {
1911
- const value = lookup(key, this, this._options);
1912
- if (value !== undefined) {
1913
- return value;
1914
- }
1915
- }
1916
- return undefined;
2174
+ constructor(context, options) {
2175
+ this.type = 'EvalScope';
2176
+ this._context = context ?? {};
2177
+ this._options = { ...defaultEvalScopeOptions, ...options ?? {} };
1917
2178
  }
1918
2179
  /**
1919
- * Retrieves the `this` value of the specified key from the evaluation context.
1920
- * The value is searched in the original context, prior scopes, and lookup functions.
1921
- * @param key - The key to retrieve the value for.
1922
- * @returns The `this` value associated with the key, or undefined if not found.
2180
+ * Creates an instance of EvalScope from the given context and options.
2181
+ *
2182
+ * @param context - The context object.
2183
+ * @param options - The options object.
2184
+ * @returns An instance of EvalScope.
1923
2185
  */
1924
- getThis(key) {
1925
- if (this._original) {
1926
- const value = getContextValue(this._original, key);
1927
- if (value !== undefined) {
1928
- return this._original;
1929
- }
1930
- }
1931
- for (const scope of this._priorScopes) {
1932
- const value = getContextValue(this._original, key);
1933
- if (value !== undefined) {
1934
- return scope;
1935
- }
1936
- }
1937
- for (const lookup of Array.from(this._lookups.values)) {
1938
- const value = lookup(key, this, this._options);
1939
- if (value !== undefined) {
1940
- return lookup;
1941
- }
1942
- }
1943
- return undefined;
2186
+ static fromObject(context, options) {
2187
+ return new EvalScope(context, options);
1944
2188
  }
1945
2189
  /**
1946
- * Retrieves the value associated with the specified key from the evaluation context.
1947
- *
2190
+ * Gets the value of the specified key.
1948
2191
  * @param key - The key to retrieve the value for.
1949
- * @returns The value associated with the key, or undefined if the key is not found.
2192
+ * @returns The value of the specified key, or undefined if the key is not found.
1950
2193
  */
1951
- getKey(key) {
1952
- const caseInsensitive = !!this._options.caseInsensitive;
1953
- for (const scope of this._scopes.asArray()) {
1954
- const foundKey = getContextKey(scope, key, caseInsensitive);
1955
- if (foundKey !== undefined) {
1956
- return foundKey;
1957
- }
1958
- }
1959
- if (this._original) {
1960
- const foundKey = getContextKey(this._original, key, caseInsensitive);
1961
- if (foundKey !== undefined) {
1962
- return foundKey;
1963
- }
1964
- }
1965
- for (const scope of this._priorScopes) {
1966
- const foundKey = getContextKey(scope, key, caseInsensitive);
1967
- if (foundKey !== undefined) {
1968
- return foundKey;
2194
+ get(key) {
2195
+ const { caseInsensitive, namespace } = this._options;
2196
+ const { context } = this;
2197
+ if (typeof key === 'string' && namespace) {
2198
+ const found = caseInsensitive
2199
+ ? equalIgnoreCase(key, namespace)
2200
+ : key === namespace;
2201
+ if (found) {
2202
+ return this.context;
1969
2203
  }
1970
2204
  }
1971
- return undefined;
2205
+ const value = getContextValue(context, key);
2206
+ return value;
1972
2207
  }
1973
2208
  /**
1974
- * Sets a key-value pair in the context.
1975
- * If the original context is a Registry, the key-value pair is set using the Registry's set method.
1976
- * If the original context is an Object, the key-value pair is set directly on the object.
1977
- * @param key - The key of the pair.
1978
- * @param value - The value of the pair.
2209
+ * Sets the value of the specified key.
2210
+ * @param key - The key to set the value for.
2211
+ * @param value - The value to set.
1979
2212
  */
1980
2213
  set(key, value) {
1981
- if (this._original && this._original instanceof Registry) {
1982
- const registry = this._original;
2214
+ const { context } = this;
2215
+ if (context && context instanceof Registry) {
2216
+ const registry = context;
1983
2217
  registry.set(key, value);
1984
2218
  }
1985
- else if (this._original && this._original instanceof Object) {
1986
- const obj = this._original;
2219
+ else if (context && context instanceof Object) {
2220
+ const obj = context;
1987
2221
  obj[key] = value;
1988
2222
  }
1989
2223
  }
1990
- /**
1991
- * Pushes a context to the scope stack.
1992
- * @param context - The context to push.
1993
- * @param options - The evaluation options.
1994
- */
1995
- push(context, options) {
1996
- const ctx = fromContext(context, options);
1997
- this._scopes.push(ctx);
1998
- }
1999
- /**
2000
- * Pops a context from the scope stack.
2001
- */
2002
- pop() {
2003
- this._scopes.pop();
2004
- }
2005
2224
  }
2006
2225
 
2007
2226
  /**
2008
- * Represents the result of an evaluation.
2227
+ * Base class for evaluation.
2009
2228
  */
2010
- class EvalResult {
2011
- /**
2012
- * Gets the stack of evaluated values.
2013
- */
2014
- get stack() {
2015
- return this._stack;
2016
- }
2017
- /**
2018
- * Gets the evaluated value.
2019
- */
2020
- get value() {
2021
- return this._value;
2022
- }
2023
- /**
2024
- * Gets the error that occurred during evaluation.
2025
- */
2026
- get error() {
2027
- return this._error;
2028
- }
2029
- /**
2030
- * Gets the error message associated with the evaluation error.
2031
- */
2032
- get errorMessage() {
2033
- return this._errorMessage;
2034
- }
2035
- /**
2036
- * Gets whether the evaluation resulted in an error.
2037
- */
2038
- get isError() {
2039
- return this._isError;
2040
- }
2041
- /**
2042
- * Gets whether the evaluation was successful.
2043
- */
2044
- get isSuccess() {
2045
- return this._isSuccess;
2046
- }
2047
- /**
2048
- * Gets whether the evaluated value is undefined.
2049
- */
2050
- get isUndefined() {
2051
- return this._isUndefined;
2052
- }
2053
- /**
2054
- * Gets the trace of evaluated values.
2055
- */
2056
- get trace() {
2057
- return this._trace;
2229
+ class BaseEval {
2230
+ constructor(parserService) {
2231
+ this.parserService = parserService;
2058
2232
  }
2059
2233
  /**
2060
- * Gets the evaluation context.
2234
+ * Gets the parser options.
2061
2235
  */
2062
- get context() {
2063
- return this._context;
2236
+ get parserOptions() {
2237
+ return this._parserOptions;
2064
2238
  }
2065
2239
  /**
2066
- * Gets the evaluation options.
2240
+ * Sets the parser options.
2241
+ * @param value The parser options to set.
2067
2242
  */
2068
- get options() {
2069
- return this._context.options;
2243
+ set parserOptions(value) {
2244
+ this._parserOptions = value;
2070
2245
  }
2071
2246
  /**
2072
- * Gets the duration of the evaluation result.
2073
- * @returns The duration in milliseconds.
2247
+ * Parses the given expression into an abstract syntax tree (AST).
2248
+ * @param expression - The expression to parse.
2249
+ * @returns The parsed AST.
2074
2250
  */
2075
- get duration() {
2076
- if (!this._startDate || !this._endDate) {
2251
+ parse(expression) {
2252
+ if (!expression) {
2077
2253
  return undefined;
2078
2254
  }
2079
- return this._endDate - this._startDate;
2080
- }
2081
- /**
2082
- * Creates a new instance of EvalResult.
2083
- * @param trace The trace of evaluated values.
2084
- * @param context The evaluation context.
2085
- */
2086
- constructor(context) {
2087
- this._stack = new Stack();
2088
- this._trace = new Registry;
2089
- this._context = context;
2090
- }
2091
- /**
2092
- * Starts the evaluation process.
2093
- */
2094
- start() {
2095
- this._startDate = performance.now();
2096
- }
2097
- /**
2098
- * Stops the evaluation and records the end date.
2099
- */
2100
- stop() {
2101
- this._endDate = performance.now();
2102
- return this.duration;
2103
- }
2104
- /**
2105
- * Sets the success value of the evaluation result.
2106
- *
2107
- * @param value The value to set as the success value.
2108
- * @returns void
2109
- */
2110
- setSuccess(value) {
2111
- this._value = value;
2112
- this._isSuccess = true;
2113
- this._isError = false;
2114
- this._isUndefined = false;
2115
- }
2116
- /**
2117
- * Sets the failure state of the evaluation result.
2118
- * @param error The error object associated with the failure.
2119
- */
2120
- setFailure(error) {
2121
- this._error = error;
2122
- if (error instanceof Error) {
2123
- this._errorMessage = error.message;
2255
+ else if (typeof expression === 'string') {
2256
+ const ast = this.parserService.parse(expression, this.parserOptions);
2257
+ return ast;
2258
+ }
2259
+ else {
2260
+ return expression;
2124
2261
  }
2125
- this._isSuccess = false;
2126
- this._isError = true;
2127
- this._isUndefined = false;
2262
+ }
2263
+ /**
2264
+ * Creates an instance of EvalState.
2265
+ * @param context - The evaluation context or context object.
2266
+ * @param options - The evaluation options.
2267
+ * @returns The created EvalState instance.
2268
+ */
2269
+ createState(context, options) {
2270
+ const state = EvalState.fromContext(context, options);
2271
+ return state;
2128
2272
  }
2129
2273
  }
2130
2274
 
2131
2275
  /**
2132
- * Represents the evaluation state, which includes the context, result, and options.
2276
+ * @description
2277
+ * Service for parsing expressions and returning ES6/ES2020 AST.
2133
2278
  */
2134
- class EvalState {
2279
+ class ParserService {
2135
2280
  /**
2136
- * Gets the evaluation context.
2281
+ * Gets the parser options.
2137
2282
  */
2138
- get context() {
2139
- return this._context;
2283
+ get parserOptions() {
2284
+ return this._parserOptions;
2140
2285
  }
2141
2286
  /**
2142
- * Gets the evaluation result.
2287
+ * Sets the parser options.
2288
+ * @param value The parser options to set.
2143
2289
  */
2144
- get result() {
2145
- return this._result;
2290
+ set parserOptions(value) {
2291
+ this._parserOptions = value;
2146
2292
  }
2147
2293
  /**
2148
- * Gets the evaluation options.
2294
+ * Constructs a new instance of the ParserService class.
2149
2295
  */
2150
- get options() {
2151
- return this._options;
2296
+ constructor() {
2297
+ this.parserOptions = {
2298
+ ...defaultParserOptions,
2299
+ extractExpressions: true
2300
+ };
2301
+ if (this.parserOptions.cacheSize) {
2302
+ this._cache = new Cache(this.parserOptions.cacheSize);
2303
+ }
2152
2304
  }
2153
2305
  /**
2154
- * Gets whether the evaluation is asynchronous.
2306
+ * @description
2307
+ * Returns acorn version.
2155
2308
  */
2156
- get isAsync() {
2157
- return this._isAsync;
2309
+ get version() {
2310
+ return version;
2158
2311
  }
2159
2312
  /**
2160
- * Represents the state of an evaluation.
2161
- * @param context The evaluation context.
2162
- * @param result The evaluation result.
2163
- * @param options The evaluation options.
2164
- * @param isAsync Indicates whether the evaluation is asynchronous.
2313
+ * Gets the parser options.
2314
+ * @returns The parser options.
2165
2315
  */
2166
- constructor(context, result, options, isAsync) {
2167
- this._context = context;
2168
- this._result = result;
2169
- this._options = options;
2170
- this._isAsync = isAsync;
2316
+ get options() {
2317
+ return this.parserOptions;
2171
2318
  }
2172
2319
  /**
2173
- * Creates an instance of EvalState from a given context, options, and async flag.
2174
- *
2175
- * @param context - The evaluation context or context object.
2176
- * @param options - The evaluation options.
2177
- * @param isAsync - A flag indicating whether the evaluation is asynchronous.
2178
- * @returns The created EvalState instance.
2320
+ * @description
2321
+ * Parses expression and returns ES6/ES2023 AST.
2322
+ * @param expr expression to parse
2323
+ * @param options optional parser options
2324
+ * @returns The parsed AST (Abstract Syntax Tree).
2179
2325
  */
2180
- static fromContext(context, options, isAsync) {
2181
- const ctx = EvalContext.fromContext(context, options);
2182
- const result = new EvalResult(ctx);
2183
- const state = new EvalState(ctx, result, options, isAsync);
2184
- return state;
2326
+ parse(expr, options) {
2327
+ if (expr) {
2328
+ try {
2329
+ const parserOptions = { ...this.parserOptions, ...options };
2330
+ const isCache = this.parserOptions.cacheSize && this._cache;
2331
+ const ast = isCache
2332
+ ? this.fromCacheOrParse(expr, parserOptions)
2333
+ : parse(expr, parserOptions);
2334
+ return ast;
2335
+ }
2336
+ catch (error) {
2337
+ if (error instanceof Error) {
2338
+ throw new Error(error.message);
2339
+ }
2340
+ else {
2341
+ throw error;
2342
+ }
2343
+ }
2344
+ }
2345
+ return undefined;
2346
+ }
2347
+ //#region Private methods
2348
+ fromCacheOrParse(expr, options) {
2349
+ if (this._cache) {
2350
+ const hashKey = this._cache.getHashKey('', expr);
2351
+ let ast = this._cache.get(hashKey);
2352
+ if (!ast) {
2353
+ ast = parse(expr, options);
2354
+ this._cache.set(hashKey, ast);
2355
+ }
2356
+ return ast;
2357
+ }
2358
+ return undefined;
2185
2359
  }
2360
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2361
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, providedIn: 'root' }); }
2186
2362
  }
2363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ParserService, decorators: [{
2364
+ type: Injectable,
2365
+ args: [{
2366
+ providedIn: 'root'
2367
+ }]
2368
+ }], ctorParameters: () => [] });
2187
2369
 
2188
2370
  /**
2189
2371
  * Service for evaluating and parsing expressions.
@@ -2194,43 +2376,50 @@ class EvalService extends BaseEval {
2194
2376
  * @param parserService The parser service used for parsing expressions.
2195
2377
  */
2196
2378
  constructor(parserService) {
2197
- super();
2379
+ super(parserService);
2198
2380
  this.parserService = parserService;
2199
- this.parserOptions = {
2200
- ...defaultOptions$1,
2201
- ecmaVersion: 2020,
2202
- extractExpressions: false,
2203
- cacheSize: 100
2204
- };
2381
+ this.parserOptions = defaultParserOptions;
2205
2382
  }
2206
2383
  /**
2207
- * Parses the given expression into an abstract syntax tree (AST).
2208
- * @param expression The expression to parse.
2209
- * @returns The AST representing the expression.
2384
+ * Evaluates the given expression.
2385
+ * @param expression The expression to evaluate.
2386
+ * @param context The evaluation context.
2387
+ * @param options The evaluation options.
2388
+ * @returns The result of the evaluation.
2210
2389
  */
2211
- parse(expression) {
2212
- if (!expression) {
2213
- return undefined;
2214
- }
2215
- else if (typeof expression === 'string') {
2216
- const ast = this.parserService.parse(expression, this.parserOptions);
2217
- return ast;
2390
+ simpleEval(expression, context, options) {
2391
+ try {
2392
+ const ast = this.parse(expression);
2393
+ const state = this.createState(context, options);
2394
+ if (state?.result && typeof expression === 'string') {
2395
+ state.result.expression = expression;
2396
+ }
2397
+ const value = evaluate(ast, state);
2398
+ return value;
2218
2399
  }
2219
- else {
2220
- return expression;
2400
+ catch (error) {
2401
+ if (error instanceof Error) {
2402
+ throw new Error(error.message);
2403
+ }
2404
+ else {
2405
+ throw error;
2406
+ }
2221
2407
  }
2222
2408
  }
2223
2409
  /**
2224
- * Evaluates the given expression.
2225
- * @param expression The expression to evaluate.
2226
- * @param context The evaluation context.
2227
- * @param options The evaluation options.
2410
+ * Evaluates an expression using the provided state.
2411
+ *
2412
+ * @param expression - The expression to evaluate.
2413
+ * @param state - The state object containing variables and functions used in the evaluation.
2228
2414
  * @returns The result of the evaluation.
2415
+ * @throws If an error occurs during evaluation.
2229
2416
  */
2230
- eval(expression, context, options) {
2417
+ eval(expression, state) {
2231
2418
  try {
2232
2419
  const ast = this.parse(expression);
2233
- const state = EvalState.fromContext(context, options);
2420
+ if (state?.result && typeof expression === 'string') {
2421
+ state.result.expression = expression;
2422
+ }
2234
2423
  const value = evaluate(ast, state);
2235
2424
  return value;
2236
2425
  }
@@ -2250,10 +2439,39 @@ class EvalService extends BaseEval {
2250
2439
  * @param options The evaluation options.
2251
2440
  * @returns A promise that resolves to the result of the evaluation.
2252
2441
  */
2253
- evalAsync(expression, context, options) {
2442
+ simpleEvalAsync(expression, context, options) {
2443
+ try {
2444
+ const ast = this.parse(expression);
2445
+ const state = this.createState(context, options);
2446
+ if (state?.result && typeof expression === 'string') {
2447
+ state.result.expression = expression;
2448
+ }
2449
+ const promise = evaluateAsync(ast, state);
2450
+ return promise;
2451
+ }
2452
+ catch (error) {
2453
+ if (error instanceof Error) {
2454
+ throw new Error(error.message);
2455
+ }
2456
+ else {
2457
+ throw error;
2458
+ }
2459
+ }
2460
+ }
2461
+ /**
2462
+ * Asynchronously evaluates an expression using the provided state.
2463
+ *
2464
+ * @param expression - The expression to evaluate. Can be a string or an AST node.
2465
+ * @param state - The evaluation state.
2466
+ * @returns A promise that resolves to the result of the evaluation.
2467
+ * @throws If an error occurs during evaluation.
2468
+ */
2469
+ evalAsync(expression, state) {
2254
2470
  try {
2255
2471
  const ast = this.parse(expression);
2256
- const state = EvalState.fromContext(context, options);
2472
+ if (state?.result && typeof expression === 'string') {
2473
+ state.result.expression = expression;
2474
+ }
2257
2475
  const promise = evaluateAsync(ast, state);
2258
2476
  return promise;
2259
2477
  }
@@ -2282,32 +2500,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImpor
2282
2500
  */
2283
2501
  class CompilerService extends BaseEval {
2284
2502
  constructor(parserService, evalService) {
2285
- super();
2503
+ super(parserService);
2286
2504
  this.parserService = parserService;
2287
2505
  this.evalService = evalService;
2288
- this.parserOptions = {
2289
- ...defaultOptions$1,
2290
- ecmaVersion: 2020,
2291
- extractExpressions: false,
2292
- cacheSize: 100
2293
- };
2294
- }
2295
- /**
2296
- * Parses the given expression into an abstract syntax tree (AST).
2297
- * @param expression - The expression to parse.
2298
- * @returns The parsed AST.
2299
- */
2300
- parse(expression) {
2301
- if (!expression) {
2302
- return undefined;
2303
- }
2304
- else if (typeof expression === 'string') {
2305
- const ast = this.parserService.parse(expression, this.parserOptions);
2306
- return ast;
2307
- }
2308
- else {
2309
- return expression;
2310
- }
2506
+ this.parserOptions = defaultParserOptions;
2311
2507
  }
2312
2508
  /**
2313
2509
  * Compiles the given expression into a state callback function.
@@ -2336,10 +2532,10 @@ class CompilerService extends BaseEval {
2336
2532
  * @returns The result of the evaluation.
2337
2533
  * @throws Error if there is an error during the evaluation.
2338
2534
  */
2339
- call(fn, context, options) {
2535
+ simpleCall(fn, context, options) {
2340
2536
  if (fn) {
2341
2537
  try {
2342
- const state = EvalState.fromContext(context, options);
2538
+ const state = this.createState(context, options);
2343
2539
  const value = call(fn, state);
2344
2540
  return value;
2345
2541
  }
@@ -2355,26 +2551,26 @@ class CompilerService extends BaseEval {
2355
2551
  return undefined;
2356
2552
  }
2357
2553
  /**
2358
- * Calls the given asynchronous state callback function with the specified context and options.
2359
- * @param fn - The asynchronous state callback function to call.
2360
- * @param context - The evaluation context or context object.
2361
- * @param options - The evaluation options.
2362
- * @returns A promise that resolves to the result of the evaluation.
2363
- * @throws Error if there is an error during the evaluation.
2554
+ * Calls the provided function with the given state.
2555
+ *
2556
+ * @param fn - The function to be called.
2557
+ * @param state - The state to be passed to the function.
2558
+ * @returns The value returned by the function.
2559
+ * @throws If an error occurs during the function call.
2364
2560
  */
2365
- async callAsync(fn, context, options) {
2561
+ call(fn, state) {
2366
2562
  if (fn) {
2367
2563
  try {
2368
- const state = EvalState.fromContext(context, options);
2369
- const promise = callAsync(fn, state);
2370
- const value = await promise;
2564
+ const value = call(fn, state);
2371
2565
  return value;
2372
2566
  }
2373
2567
  catch (error) {
2374
2568
  if (error instanceof Error) {
2375
2569
  throw new Error(error.message);
2376
2570
  }
2377
- throw new Error('error in callAsync');
2571
+ else {
2572
+ throw new Error('call');
2573
+ }
2378
2574
  }
2379
2575
  }
2380
2576
  return undefined;
@@ -2398,6 +2594,55 @@ class CompilerService extends BaseEval {
2398
2594
  throw new Error('error in compileAsync');
2399
2595
  }
2400
2596
  }
2597
+ /**
2598
+ * Calls the given asynchronous state callback function with the specified context and options.
2599
+ * @param fn - The asynchronous state callback function to call.
2600
+ * @param context - The evaluation context or context object.
2601
+ * @param options - The evaluation options.
2602
+ * @returns A promise that resolves to the result of the evaluation.
2603
+ * @throws Error if there is an error during the evaluation.
2604
+ */
2605
+ async simpleCallAsync(fn, context, options) {
2606
+ if (fn) {
2607
+ try {
2608
+ const state = this.createState(context, options);
2609
+ const promise = callAsync(fn, state);
2610
+ const value = await promise;
2611
+ return value;
2612
+ }
2613
+ catch (error) {
2614
+ if (error instanceof Error) {
2615
+ throw new Error(error.message);
2616
+ }
2617
+ throw new Error('error in callAsync');
2618
+ }
2619
+ }
2620
+ return undefined;
2621
+ }
2622
+ /**
2623
+ * Calls the provided asynchronous function with the given state.
2624
+ *
2625
+ * @param fn - The asynchronous function to call.
2626
+ * @param state - The state to pass to the function.
2627
+ * @returns A promise that resolves to the value returned by the function.
2628
+ * @throws If an error occurs during the function call.
2629
+ */
2630
+ async callAsync(fn, state) {
2631
+ if (fn) {
2632
+ try {
2633
+ const promise = callAsync(fn, state);
2634
+ const value = await promise;
2635
+ return value;
2636
+ }
2637
+ catch (error) {
2638
+ if (error instanceof Error) {
2639
+ throw new Error(error.message);
2640
+ }
2641
+ throw new Error('error in callAsync');
2642
+ }
2643
+ }
2644
+ return undefined;
2645
+ }
2401
2646
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CompilerService, deps: [{ token: ParserService }, { token: EvalService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2402
2647
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CompilerService, providedIn: 'root' }); }
2403
2648
  }
@@ -2417,12 +2662,10 @@ class DiscoveryService extends BaseEval {
2417
2662
  * @param parserService The parser service to be used.
2418
2663
  */
2419
2664
  constructor(parserService) {
2420
- super();
2665
+ super(parserService);
2421
2666
  this.parserService = parserService;
2422
2667
  this.parserOptions = {
2423
- ...defaultOptions$1,
2424
- ecmaVersion: 2020,
2425
- extractExpressions: false,
2668
+ ...defaultParserOptions,
2426
2669
  cacheSize: undefined
2427
2670
  };
2428
2671
  }
@@ -2449,23 +2692,6 @@ class DiscoveryService extends BaseEval {
2449
2692
  }
2450
2693
  }
2451
2694
  }
2452
- /**
2453
- * Parses the given expression into an abstract syntax tree (AST).
2454
- * @param expression The expression to parse.
2455
- * @returns The AST representing the expression.
2456
- */
2457
- parse(expression) {
2458
- if (!expression) {
2459
- return undefined;
2460
- }
2461
- else if (typeof expression === 'string') {
2462
- const ast = this.parserService.parse(expression, this.parserOptions);
2463
- return ast;
2464
- }
2465
- else {
2466
- return expression;
2467
- }
2468
- }
2469
2695
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DiscoveryService, deps: [{ token: ParserService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2470
2696
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DiscoveryService, providedIn: 'root' }); }
2471
2697
  }
@@ -2480,5 +2706,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImpor
2480
2706
  * Generated bundle index. Do not edit.
2481
2707
  */
2482
2708
 
2483
- export { BaseRegistry, Cache, CaseInsensitiveRegistry, CompilerService, DiscoveryService, EvalContext, EvalResult, EvalService, EvalState, ParserService, Queue, RecursiveVisitorResultType, Registry, Scope, ScopeRegistry, Stack, call, callAsync, compile, compileAsync, evaluate, evaluateAsync, extract, extractExpression, fromContext, getContextKey, getContextValue, isRegistryContext, parse };
2709
+ export { BaseRegistry, Cache, CaseInsensitiveRegistry, CompilerService, DiscoveryService, EvalContext, EvalResult, EvalScope, EvalService, EvalState, EvalTrace, ParserService, Queue, RecursiveVisitorResultType, Registry, Scope, ScopeRegistry, Stack, call, callAsync, compile, compileAsync, defaultParserOptions, evaluate, evaluateAsync, extract, extractExpression, fromContext, getContextKey, getContextValue, isRegistryContext, parse };
2484
2710
  //# sourceMappingURL=zvenigora-ng-eval-core.mjs.map