xmlui 0.8.6 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/{apiInterceptorWorker-fLBfPj2T.mjs → apiInterceptorWorker-230V_-Ds.mjs} +1 -1
  2. package/dist/{index-wd8FRzuM.mjs → index-DUwwx3L4.mjs} +5864 -6108
  3. package/dist/index.css +274 -301
  4. package/dist/language-server.mjs +25 -1
  5. package/dist/{lint-B18Ko6Sy.mjs → lint-gX2osbkz.mjs} +920 -1120
  6. package/dist/scripts/bin/build.js +2 -2
  7. package/dist/scripts/bin/start.js +3 -9
  8. package/dist/scripts/bin/vite-xmlui-plugin.js +2 -2
  9. package/dist/scripts/bin/viteConfig.js +89 -63
  10. package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +1 -2
  11. package/dist/scripts/src/components/Accordion/Accordion.js +6 -16
  12. package/dist/scripts/src/components/App/AppNative.js +8 -0
  13. package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -5
  14. package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +10 -4
  15. package/dist/scripts/src/components/AutoComplete/AutoComplete.js +13 -19
  16. package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
  17. package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +7 -3
  18. package/dist/scripts/src/components/Avatar/Avatar.js +2 -9
  19. package/dist/scripts/src/components/Badge/Badge.js +2 -8
  20. package/dist/scripts/src/components/Button/Button.js +28 -60
  21. package/dist/scripts/src/components/Card/Card.js +1 -6
  22. package/dist/scripts/src/components/Checkbox/Checkbox.js +4 -12
  23. package/dist/scripts/src/components/ComponentProvider.js +4 -0
  24. package/dist/scripts/src/components/DatePicker/DatePicker.js +3 -10
  25. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
  26. package/dist/scripts/src/components/Form/Form.js +12 -28
  27. package/dist/scripts/src/components/Form/FormNative.js +9 -0
  28. package/dist/scripts/src/components/FormItem/HelperText.js +1 -1
  29. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +2 -2
  30. package/dist/scripts/src/components/Heading/HeadingNative.js +0 -1
  31. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +4 -19
  32. package/dist/scripts/src/components/IconProvider.js +2 -2
  33. package/dist/scripts/src/components/Link/Link.js +2 -8
  34. package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
  35. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +1 -3
  36. package/dist/scripts/src/components/NavGroup/NavGroup.js +34 -3
  37. package/dist/scripts/src/components/NavGroup/NavGroupNative.js +24 -12
  38. package/dist/scripts/src/components/NavLink/NavLink.js +4 -11
  39. package/dist/scripts/src/components/NavPanel/NavPanel.js +1 -6
  40. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +2 -8
  41. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -12
  42. package/dist/scripts/src/components/Select/Select.js +5 -13
  43. package/dist/scripts/src/components/Select/SelectNative.js +7 -3
  44. package/dist/scripts/src/components/Slider/Slider.js +2 -8
  45. package/dist/scripts/src/components/Spinner/Spinner.js +1 -6
  46. package/dist/scripts/src/components/SubNavPanel/SubNavPanel.js +22 -0
  47. package/dist/scripts/src/components/SubNavPanel/SubNavPanelNative.js +9 -0
  48. package/dist/scripts/src/components/Switch/Switch.js +6 -16
  49. package/dist/scripts/src/components/Table/Table.js +8 -17
  50. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +4 -12
  51. package/dist/scripts/src/components/Tabs/Tabs.js +3 -10
  52. package/dist/scripts/src/components/Text/Text.js +10 -24
  53. package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
  54. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
  55. package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +3 -3
  56. package/dist/scripts/src/components-core/DevTools.js +5 -4
  57. package/dist/scripts/src/components-core/RestApiProxy.js +7 -3
  58. package/dist/scripts/src/components-core/action/APICall.js +2 -1
  59. package/dist/scripts/src/components-core/rendering/Container.js +15 -11
  60. package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -2
  61. package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +0 -2
  62. package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
  63. package/dist/scripts/src/components-core/script-runner/asyncProxy.js +11 -64
  64. package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +196 -175
  65. package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +173 -231
  66. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +129 -100
  67. package/dist/scripts/src/components-core/script-runner/process-statement-async.js +170 -175
  68. package/dist/scripts/src/components-core/script-runner/process-statement-common.js +48 -33
  69. package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +164 -170
  70. package/dist/scripts/src/components-core/script-runner/statement-queue.js +5 -4
  71. package/dist/scripts/src/components-core/script-runner/visitors.js +124 -116
  72. package/dist/scripts/src/components-core/theming/themes/palette.js +1 -0
  73. package/dist/scripts/src/components-core/theming/themes/root.js +300 -154
  74. package/dist/scripts/src/components-core/theming/themes/theme-colors.js +510 -510
  75. package/dist/scripts/src/components-core/theming/themes/xmlui.js +0 -1
  76. package/dist/scripts/src/components-core/theming/transformThemeVars.js +11 -11
  77. package/dist/scripts/src/components-core/utils/misc.js +13 -0
  78. package/dist/scripts/src/components-core/utils/statementUtils.js +56 -53
  79. package/dist/scripts/src/components-core/xmlui-parser.js +1 -1
  80. package/dist/scripts/src/parsers/scripting-exp/Lexer.js +1092 -0
  81. package/dist/scripts/src/parsers/scripting-exp/Parser.js +2635 -0
  82. package/dist/scripts/src/parsers/scripting-exp/ParserError.js +47 -0
  83. package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +109 -0
  84. package/dist/scripts/src/parsers/scripting-exp/TokenType.js +2 -4
  85. package/dist/scripts/src/parsers/scripting-exp/code-behind-collect.js +101 -0
  86. package/dist/scripts/src/parsers/scripting-exp/modules.js +107 -0
  87. package/dist/scripts/src/parsers/{scripting → scripting-exp}/tree-visitor.js +103 -107
  88. package/dist/scripts/src/parsers/xmlui-parser/transform.js +12 -12
  89. package/dist/style.css +245 -286
  90. package/dist/xmlui-metadata.mjs +2741 -2211
  91. package/dist/xmlui-metadata.umd.js +2740 -2212
  92. package/dist/xmlui-parser.d.ts +320 -232
  93. package/dist/xmlui-parser.mjs +19 -19
  94. package/dist/xmlui-standalone.umd.js +6770 -7220
  95. package/dist/xmlui.d.ts +322 -230
  96. package/dist/xmlui.mjs +1 -1
  97. package/package.json +10 -6
  98. package/dist/_commonjsHelpers-CcAunmGO.mjs +0 -33
  99. package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +0 -34
  100. package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +0 -40
  101. package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +0 -40
  102. package/dist/scripts/src/components-core/script-runner/syncProxy.js +0 -31
  103. package/dist/scripts/src/parsers/scripting/code-behind-collect.js +0 -153
  104. package/dist/scripts/src/parsers/scripting/modules.js +0 -284
  105. /package/dist/scripts/src/abstractions/scripting/{LogicalThread.js → LogicalThreadExp.js} +0 -0
  106. /package/dist/scripts/src/abstractions/scripting/{TryScope.js → TryScopeExp.js} +0 -0
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.evalBindingAsync = evalBindingAsync;
13
13
  exports.executeArrowExpression = executeArrowExpression;
14
- exports.isConstVar = isConstVar;
14
+ exports.completeExprValue = completeExprValue;
15
15
  const lodash_es_1 = require("lodash-es");
16
+ const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
16
17
  const process_statement_async_1 = require("./process-statement-async");
17
18
  const eval_tree_common_1 = require("./eval-tree-common");
18
19
  const process_statement_common_1 = require("./process-statement-common");
@@ -25,12 +26,14 @@ const bannedFunctions_1 = require("./bannedFunctions");
25
26
  * @param thread The logical thread to use for evaluation
26
27
  * @param onStatementCompleted Execute this function when a statement is completed
27
28
  */
28
- function evalBindingAsync(expr, evalContext, thread, onStatementCompleted) {
29
+ function evalBindingAsync(expr, evalContext, thread) {
29
30
  return __awaiter(this, void 0, void 0, function* () {
31
+ // --- Prepare the evaluation context
30
32
  const thisStack = [];
31
33
  (0, process_statement_common_1.ensureMainThread)(evalContext);
32
34
  thread !== null && thread !== void 0 ? thread : (thread = evalContext.mainThread);
33
- return yield evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread, onStatementCompleted);
35
+ // --- Evaluate the expression using the context
36
+ return yield evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread);
34
37
  });
35
38
  }
36
39
  /**
@@ -41,10 +44,10 @@ function evalBindingAsync(expr, evalContext, thread, onStatementCompleted) {
41
44
  * @param thread The logical thread to use for evaluation
42
45
  * @param args Arguments of the arrow function to execute
43
46
  */
44
- function executeArrowExpression(expr, evalContext, onStatementCompleted, thread, ...args) {
47
+ function executeArrowExpression(expr, evalContext, thread, ...args) {
45
48
  return __awaiter(this, void 0, void 0, function* () {
46
49
  // --- Just an extra safety check
47
- if (expr.type !== "ArrowE") {
50
+ if (expr.type !== ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
48
51
  throw new Error("executeArrowExpression expects an 'ArrowExpression' object.");
49
52
  }
50
53
  // --- This is the evaluator that an arrow expression uses internally
@@ -55,7 +58,7 @@ function executeArrowExpression(expr, evalContext, onStatementCompleted, thread,
55
58
  // --- #1: The names of arrow function arguments
56
59
  // --- #2: The evaluation context the arrow function runs in
57
60
  // --- #others: The real arguments of the arrow function
58
- return yield nativeFunction(expr.args, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread, onStatementCompleted, ...args);
61
+ return yield nativeFunction(expr.args, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread, ...args);
59
62
  });
60
63
  }
61
64
  /**
@@ -69,52 +72,49 @@ function executeArrowExpression(expr, evalContext, onStatementCompleted, thread,
69
72
  * We use `thisStack` to keep track of the partial results of the evaluation tree so that we can set
70
73
  * the real `this` context when invoking a function.
71
74
  */
72
- function evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread, onStatementCompleted) {
75
+ function evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread) {
73
76
  return __awaiter(this, void 0, void 0, function* () {
74
77
  if (!evalContext.options) {
75
78
  evalContext.options = { defaultToOptionalMemberAccess: true };
76
79
  }
77
80
  // --- Prepare evaluation
78
- let customOp = null;
79
81
  const evaluator = evalBindingExpressionTreeAsync;
80
- // --- Reset the expression scope
81
- expr.valueScope = expr.valueIndex = undefined;
82
82
  // --- Process the expression according to its type
83
83
  try {
84
84
  switch (expr.type) {
85
- case "TempLitE":
86
- return evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
87
- case "LitE":
88
- return (0, eval_tree_common_1.evalLiteral)(thisStack, expr);
89
- case "IdE":
85
+ case ScriptingSourceTreeExp_1.T_TEMPLATE_LITERAL_EXPRESSION:
86
+ return evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
87
+ case ScriptingSourceTreeExp_1.T_LITERAL:
88
+ return (0, eval_tree_common_1.evalLiteral)(thisStack, expr, thread);
89
+ case ScriptingSourceTreeExp_1.T_IDENTIFIER:
90
90
  return (0, eval_tree_common_1.evalIdentifier)(thisStack, expr, evalContext, thread);
91
- case "MembE":
92
- return yield evalMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
93
- case "CMembE":
94
- return yield evalCalculatedMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
95
- case "SeqE":
96
- return yield evalSequenceAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
97
- case "ALitE":
98
- return yield evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
99
- case "OLitE":
100
- return yield evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
101
- case "UnaryE":
102
- return yield evalUnaryAsync(evaluator, thisStack, customOp, expr, evalContext, thread, onStatementCompleted);
103
- case "BinaryE":
104
- return yield evalBinaryAsync(evaluator, thisStack, customOp, expr, evalContext, thread, onStatementCompleted);
105
- case "CondE":
106
- return yield evalConditionalAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
107
- case "AsgnE":
108
- return yield evalAssignmentAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
109
- case "PrefE":
110
- case "PostfE":
111
- return yield evalPreOrPostAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
112
- case "InvokeE":
91
+ case ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION:
92
+ return yield evalMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread);
93
+ case ScriptingSourceTreeExp_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
94
+ return yield evalCalculatedMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread);
95
+ case ScriptingSourceTreeExp_1.T_SEQUENCE_EXPRESSION:
96
+ return yield evalSequenceAsync(evaluator, thisStack, expr, evalContext, thread);
97
+ case ScriptingSourceTreeExp_1.T_ARRAY_LITERAL:
98
+ return yield evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
99
+ case ScriptingSourceTreeExp_1.T_OBJECT_LITERAL:
100
+ return yield evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
101
+ case ScriptingSourceTreeExp_1.T_UNARY_EXPRESSION:
102
+ return yield evalUnaryAsync(evaluator, thisStack, expr, evalContext, thread);
103
+ case ScriptingSourceTreeExp_1.T_BINARY_EXPRESSION:
104
+ return yield evalBinaryAsync(evaluator, thisStack, expr, evalContext, thread);
105
+ case ScriptingSourceTreeExp_1.T_CONDITIONAL_EXPRESSION:
106
+ return yield evalConditionalAsync(evaluator, thisStack, expr, evalContext, thread);
107
+ case ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION:
108
+ return yield evalAssignmentAsync(evaluator, thisStack, expr, evalContext, thread);
109
+ case ScriptingSourceTreeExp_1.T_PREFIX_OP_EXPRESSION:
110
+ case ScriptingSourceTreeExp_1.T_POSTFIX_OP_EXPRESSION:
111
+ return yield evalPreOrPostAsync(evaluator, thisStack, expr, evalContext, thread);
112
+ case ScriptingSourceTreeExp_1.T_FUNCTION_INVOCATION_EXPRESSION:
113
113
  // --- Special async handling
114
- return yield evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted);
115
- case "ArrowE":
114
+ return yield evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, thread);
115
+ case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION:
116
116
  return (0, eval_tree_common_1.evalArrow)(thisStack, expr, thread);
117
- case "SpreadE":
117
+ case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION:
118
118
  throw new Error("Cannot use spread expression (...) with the current intermediate value.");
119
119
  default:
120
120
  throw new Error(`Unknown expression tree node: ${expr.type}`);
@@ -126,66 +126,72 @@ function evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread, on
126
126
  }
127
127
  });
128
128
  }
129
- function evalMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
129
+ function evalMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread) {
130
130
  return __awaiter(this, void 0, void 0, function* () {
131
- const parentObj = yield evaluator(thisStack, expr.object, evalContext, thread, onStatementCompleted);
132
- return (0, eval_tree_common_1.evalMemberAccessCore)(parentObj, thisStack, expr, evalContext);
133
- });
134
- }
135
- function evalCalculatedMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- const parentObj = yield evaluator(thisStack, expr.object, evalContext, thread, onStatementCompleted);
131
+ yield evaluator(thisStack, expr.obj, evalContext, thread);
132
+ yield completeExprValue(expr.obj, thread);
138
133
  // --- At this point we definitely keep the parent object on `thisStack`, as it will be the context object
139
134
  // --- of a FunctionInvocationExpression, if that follows the MemberAccess. Other operations would call
140
135
  // --- `thisStack.pop()` to remove the result from the previous `evalBindingExpressionTree` call.
141
- const memberObj = yield evaluator(thisStack, expr.member, evalContext, thread, onStatementCompleted);
136
+ return (0, eval_tree_common_1.evalMemberAccessCore)(thisStack, expr, evalContext, thread);
137
+ });
138
+ }
139
+ function evalCalculatedMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread) {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ yield evaluator(thisStack, expr.obj, evalContext, thread);
142
+ yield completeExprValue(expr.obj, thread);
143
+ yield evaluator(thisStack, expr.member, evalContext, thread);
142
144
  thisStack.pop();
143
- return (0, eval_tree_common_1.evalCalculatedMemberAccessCore)(parentObj, memberObj, thisStack, expr, evalContext);
145
+ yield completeExprValue(expr.member, thread);
146
+ return (0, eval_tree_common_1.evalCalculatedMemberAccessCore)(thisStack, expr, evalContext, thread);
144
147
  });
145
148
  }
146
- function evalSequenceAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
149
+ function evalSequenceAsync(evaluator, thisStack, expr, evalContext, thread) {
147
150
  return __awaiter(this, void 0, void 0, function* () {
148
- if (!expr.expressions || expr.expressions.length === 0) {
151
+ if (!expr.exprs || expr.exprs.length === 0) {
149
152
  throw new Error(`Missing expression sequence`);
150
153
  }
151
- const result = expr.expressions.map((e) => __awaiter(this, void 0, void 0, function* () {
152
- const exprValue = yield evaluator(thisStack, e, evalContext, thread, onStatementCompleted);
154
+ const result = expr.exprs.map((e) => __awaiter(this, void 0, void 0, function* () {
155
+ const value = yield evaluator(thisStack, e, evalContext, thread);
156
+ (0, eval_tree_common_1.setExprValue)(e, { value }, thread);
153
157
  thisStack.pop();
154
- return exprValue;
158
+ return value;
155
159
  }));
156
160
  const lastObj = result[result.length - 1];
157
161
  thisStack.push(lastObj);
158
162
  return lastObj;
159
163
  });
160
164
  }
161
- function evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
165
+ function evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread) {
162
166
  return __awaiter(this, void 0, void 0, function* () {
163
- const arrayValue = [];
167
+ const value = [];
164
168
  for (const item of expr.items) {
165
- if (item.type === "SpreadE") {
166
- const spreadArray = yield evaluator(thisStack, item.operand, evalContext, thread, onStatementCompleted);
169
+ if (item.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
170
+ const spreadArray = yield evaluator(thisStack, item.expr, evalContext, thread);
167
171
  thisStack.pop();
168
172
  if (!Array.isArray(spreadArray)) {
169
173
  throw new Error("Spread operator within an array literal expects an array operand.");
170
174
  }
171
- arrayValue.push(...spreadArray);
175
+ value.push(...spreadArray);
172
176
  }
173
177
  else {
174
- arrayValue.push(yield evaluator(thisStack, item, evalContext, thread, onStatementCompleted));
178
+ value.push(yield evaluator(thisStack, item, evalContext, thread));
175
179
  thisStack.pop();
176
- thisStack.push(arrayValue);
180
+ thisStack.push(value);
177
181
  }
178
182
  }
179
- return arrayValue;
183
+ // --- Done.
184
+ (0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
185
+ return value;
180
186
  });
181
187
  }
182
- function evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
188
+ function evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread) {
183
189
  return __awaiter(this, void 0, void 0, function* () {
184
190
  const objectHash = {};
185
191
  for (const prop of expr.props) {
186
192
  if (!Array.isArray(prop)) {
187
193
  // --- We're using a spread expression
188
- const spreadItems = yield evaluator(thisStack, prop.operand, evalContext, thread, onStatementCompleted);
194
+ const spreadItems = yield evaluator(thisStack, prop.expr, evalContext, thread);
189
195
  thisStack.pop();
190
196
  if (Array.isArray(spreadItems)) {
191
197
  // --- Spread of an array
@@ -204,140 +210,160 @@ function evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread,
204
210
  // --- We're using key/[value] pairs
205
211
  let key;
206
212
  switch (prop[0].type) {
207
- case "LitE":
213
+ case ScriptingSourceTreeExp_1.T_LITERAL:
208
214
  key = prop[0].value;
209
215
  break;
210
- case "IdE":
216
+ case ScriptingSourceTreeExp_1.T_IDENTIFIER:
211
217
  key = prop[0].name;
212
218
  break;
213
219
  default:
214
- key = yield evaluator(thisStack, prop[0], evalContext, thread, onStatementCompleted);
220
+ key = yield evaluator(thisStack, prop[0], evalContext, thread);
215
221
  thisStack.pop();
216
222
  break;
217
223
  }
218
- objectHash[key] = yield evaluator(thisStack, prop[1], evalContext, thread, onStatementCompleted);
224
+ objectHash[key] = yield evaluator(thisStack, prop[1], evalContext, thread);
219
225
  thisStack.pop();
220
226
  }
227
+ // --- Done.
228
+ (0, eval_tree_common_1.setExprValue)(expr, { value: objectHash }, thread);
221
229
  thisStack.push(objectHash);
222
230
  return objectHash;
223
231
  });
224
232
  }
225
- function evalUnaryAsync(evaluator, thisStack, customOp, expr, evalContext, thread, onStatementCompleted) {
233
+ function evalUnaryAsync(evaluator, thisStack, expr, evalContext, thread) {
226
234
  return __awaiter(this, void 0, void 0, function* () {
227
- const operand = yield evaluator(thisStack, expr.operand, evalContext, thread, onStatementCompleted);
235
+ yield evaluator(thisStack, expr.expr, evalContext, thread);
228
236
  thisStack.pop();
229
- return (0, eval_tree_common_1.evalUnaryCore)(expr, operand, thisStack, customOp);
237
+ yield completeExprValue(expr.expr, thread);
238
+ return (0, eval_tree_common_1.evalUnaryCore)(expr, thisStack, evalContext, thread);
230
239
  });
231
240
  }
232
- function evalBinaryAsync(evaluator, thisStack, customOp, expr, evalContext, thread, onStatementCompleted) {
241
+ function evalBinaryAsync(evaluator, thisStack, expr, evalContext, thread) {
233
242
  return __awaiter(this, void 0, void 0, function* () {
234
- const l = yield evaluator(thisStack, expr.left, evalContext, thread, onStatementCompleted);
243
+ yield evaluator(thisStack, expr.left, evalContext, thread);
235
244
  thisStack.pop();
236
- if (expr.operator === "&&" && !l) {
237
- thisStack.push(l);
245
+ const l = yield completeExprValue(expr.left, thread);
246
+ if (expr.op === "&&" && !l) {
247
+ (0, eval_tree_common_1.setExprValue)(expr, { value: l }, thread);
238
248
  return l;
239
249
  }
240
- if (expr.operator === "||" && l) {
241
- thisStack.push(l);
250
+ if (expr.op === "||" && l) {
251
+ (0, eval_tree_common_1.setExprValue)(expr, { value: l }, thread);
242
252
  return l;
243
253
  }
244
- const r = yield evaluator(thisStack, expr.right, evalContext, thread, onStatementCompleted);
254
+ yield evaluator(thisStack, expr.right, evalContext, thread);
245
255
  thisStack.pop();
246
- return (0, eval_tree_common_1.evalBinaryCore)(l, r, thisStack, customOp, expr.operator);
256
+ yield completeExprValue(expr.right, thread);
257
+ return (0, eval_tree_common_1.evalBinaryCore)(expr, thisStack, evalContext, thread);
247
258
  });
248
259
  }
249
- function evalConditionalAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
260
+ function evalConditionalAsync(evaluator, thisStack, expr, evalContext, thread) {
250
261
  return __awaiter(this, void 0, void 0, function* () {
251
- const condition = yield evaluator(thisStack, expr.condition, evalContext, thread, onStatementCompleted);
262
+ yield evaluator(thisStack, expr.cond, evalContext, thread);
252
263
  thisStack.pop();
253
- return yield evaluator(thisStack, condition ? expr.consequent : expr.alternate, evalContext, thread, onStatementCompleted);
254
- });
255
- }
256
- function runAssignment(evalContext, doAssignment) {
257
- return __awaiter(this, void 0, void 0, function* () {
258
- const updateHook = evalContext.onUpdateHook || ((updateFn) => __awaiter(this, void 0, void 0, function* () { return yield updateFn(); }));
259
- return yield updateHook(() => __awaiter(this, void 0, void 0, function* () {
260
- return yield doAssignment();
261
- }));
264
+ const condition = yield completeExprValue(expr.cond, thread);
265
+ const value = yield evaluator(thisStack, condition ? expr.thenE : expr.elseE, evalContext, thread);
266
+ (0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
267
+ return value;
262
268
  });
263
269
  }
264
- function evalAssignmentAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
270
+ function evalAssignmentAsync(evaluator, thisStack, expr, evalContext, thread) {
265
271
  return __awaiter(this, void 0, void 0, function* () {
266
- return runAssignment(evalContext, () => __awaiter(this, void 0, void 0, function* () {
267
- const leftValue = expr.leftValue;
268
- yield evaluator(thisStack, leftValue, evalContext, thread, onStatementCompleted);
269
- thisStack.pop();
270
- const newValue = yield evaluator(thisStack, expr.operand, evalContext, thread, onStatementCompleted);
271
- thisStack.pop();
272
- return (0, eval_tree_common_1.evalAssignmentCore)(leftValue, newValue, thisStack, expr, thread);
273
- }));
272
+ const leftValue = expr.leftValue;
273
+ const rootScope = (0, eval_tree_common_1.getRootIdScope)(leftValue, evalContext, thread);
274
+ const updatesState = rootScope && rootScope.type !== "block";
275
+ if (updatesState && evalContext.onWillUpdate) {
276
+ evalContext.onWillUpdate(rootScope, rootScope.name, "assignment");
277
+ }
278
+ yield evaluator(thisStack, leftValue, evalContext, thread);
279
+ thisStack.pop();
280
+ yield completeExprValue(leftValue, thread);
281
+ yield evaluator(thisStack, expr.expr, evalContext, thread);
282
+ thisStack.pop();
283
+ yield completeExprValue(expr.expr, thread);
284
+ const value = (0, eval_tree_common_1.evalAssignmentCore)(thisStack, expr, evalContext, thread);
285
+ if (updatesState && evalContext.onDidUpdate) {
286
+ evalContext.onDidUpdate(rootScope, rootScope.name, "assignment");
287
+ }
288
+ return value;
274
289
  });
275
290
  }
276
- function evalPreOrPostAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
291
+ function evalPreOrPostAsync(evaluator, thisStack, expr, evalContext, thread) {
277
292
  return __awaiter(this, void 0, void 0, function* () {
278
- return runAssignment(evalContext, () => __awaiter(this, void 0, void 0, function* () {
279
- const operand = expr.operand;
280
- yield evaluator(thisStack, operand, evalContext, thread, onStatementCompleted);
281
- thisStack.pop();
282
- return (0, eval_tree_common_1.evalPreOrPostCore)(operand, thisStack, expr, evalContext, thread);
283
- }));
293
+ const rootScope = (0, eval_tree_common_1.getRootIdScope)(expr.expr, evalContext, thread);
294
+ const updatesState = rootScope && rootScope.type !== "block";
295
+ if (updatesState && evalContext.onWillUpdate) {
296
+ evalContext.onWillUpdate(rootScope, rootScope.name, "pre-post");
297
+ }
298
+ yield evaluator(thisStack, expr.expr, evalContext, thread);
299
+ thisStack.pop();
300
+ yield completeExprValue(expr.expr, thread);
301
+ const value = (0, eval_tree_common_1.evalPreOrPostCore)(thisStack, expr, evalContext, thread);
302
+ if (updatesState && evalContext.onDidUpdate) {
303
+ evalContext.onDidUpdate(rootScope, rootScope.name, "pre-post");
304
+ }
305
+ return value;
284
306
  });
285
307
  }
286
- function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
308
+ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, thread) {
287
309
  return __awaiter(this, void 0, void 0, function* () {
288
310
  var _a, _b, _c, _d;
289
311
  let functionObj;
290
312
  let implicitContextObject = null;
291
313
  let hostObject;
292
314
  // --- Check for contexted object
293
- if (expr.object.type === "MembE") {
294
- hostObject = yield evaluator(thisStack, expr.object.object, evalContext, thread, onStatementCompleted);
295
- functionObj = (0, eval_tree_common_1.evalMemberAccessCore)(hostObject, thisStack, expr.object, evalContext);
296
- if (expr.object.object.type === "IdE" && (hostObject === null || hostObject === void 0 ? void 0 : hostObject._SUPPORT_IMPLICIT_CONTEXT)) {
315
+ if (expr.obj.type === ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION) {
316
+ hostObject = yield evaluator(thisStack, expr.obj.obj, evalContext, thread);
317
+ yield completeExprValue(expr.obj.obj, thread);
318
+ functionObj = (0, eval_tree_common_1.evalMemberAccessCore)(thisStack, expr.obj, evalContext, thread);
319
+ if (expr.obj.obj.type === ScriptingSourceTreeExp_1.T_IDENTIFIER && (hostObject === null || hostObject === void 0 ? void 0 : hostObject._SUPPORT_IMPLICIT_CONTEXT)) {
297
320
  implicitContextObject = hostObject;
298
321
  }
299
322
  }
300
323
  else {
301
324
  // --- Get the object on which to invoke the function
302
- functionObj = yield evaluator(thisStack, expr.object, evalContext, thread, onStatementCompleted);
325
+ yield evaluator(thisStack, expr.obj, evalContext, thread);
326
+ functionObj = yield completeExprValue(expr.obj, thread);
303
327
  }
304
328
  thisStack.pop();
305
329
  // --- Keep function arguments here, we pass it to the function later
306
330
  const functionArgs = [];
307
331
  // --- The functionObj may be an ArrowExpression. In this care we need to create the invokable arrow function
308
332
  if (functionObj === null || functionObj === void 0 ? void 0 : functionObj._ARROW_EXPR_) {
309
- functionArgs.push(functionObj.args, evalContext, thread, onStatementCompleted, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
333
+ functionArgs.push(functionObj.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
310
334
  functionObj = yield createArrowFunctionAsync(evaluator, functionObj);
311
335
  }
312
- else if (expr.object.type === "ArrowE") {
336
+ else if (expr.obj.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
313
337
  // --- We delay evaluating expression values. We pass the argument names as the first parameter, and then
314
338
  // --- all parameter expressions
315
- functionArgs.push(expr.object.args.map((a) => a.name), evalContext, thread, onStatementCompleted, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
339
+ functionArgs.push(expr.obj.args.map((a) => a.name), evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
316
340
  }
317
341
  else {
318
342
  // --- We evaluate the argument values to pass to a JavaScript function
319
343
  for (let i = 0; i < expr.arguments.length; i++) {
320
344
  const arg = expr.arguments[i];
321
- if (arg.type === "SpreadE") {
322
- const funcArg = yield evaluator([], arg.operand, evalContext, thread, onStatementCompleted);
345
+ if (arg.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
346
+ yield evaluator([], arg.expr, evalContext, thread);
347
+ const funcArg = yield completeExprValue(arg.expr, thread);
323
348
  if (!Array.isArray(funcArg)) {
324
349
  throw new Error("Spread operator within a function invocation expects an array operand.");
325
350
  }
326
351
  functionArgs.push(...funcArg);
327
352
  }
328
353
  else {
329
- if (arg.type === "ArrowE") {
354
+ if (arg.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
330
355
  const funcArg = yield createArrowFunctionAsync(evaluator, arg);
331
356
  const wrappedFunc = (...args) => __awaiter(this, void 0, void 0, function* () {
332
- return funcArg(arg.args, evalContext, thread, onStatementCompleted, ...args);
357
+ return funcArg(arg.args, evalContext, thread, ...args);
333
358
  });
334
359
  functionArgs.push(wrappedFunc);
335
360
  }
336
361
  else {
337
- const funcArg = yield evaluator([], arg, evalContext, thread, onStatementCompleted);
362
+ yield evaluator([], arg, evalContext, thread);
363
+ const funcArg = yield completeExprValue(arg, thread);
338
364
  if (funcArg === null || funcArg === void 0 ? void 0 : funcArg._ARROW_EXPR_) {
339
365
  const wrappedFuncArg = yield createArrowFunctionAsync(evaluator, funcArg);
340
- const wrappedFunc = (...args) => wrappedFuncArg(funcArg.args, evalContext, thread, onStatementCompleted, ...args);
366
+ const wrappedFunc = (...args) => wrappedFuncArg(funcArg.args, evalContext, thread, ...args);
341
367
  functionArgs.push(wrappedFunc);
342
368
  }
343
369
  else {
@@ -369,17 +395,22 @@ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, th
369
395
  // --- async arguments
370
396
  functionObj = (0, asyncProxy_1.getAsyncProxy)(functionObj, functionArgs, currentContext);
371
397
  // --- Now, invoke the function
372
- try {
373
- const value = ((_d = evalContext.options) === null || _d === void 0 ? void 0 : _d.defaultToOptionalMemberAccess)
374
- ? functionObj === null || functionObj === void 0 ? void 0 : functionObj.call(currentContext, ...functionArgs)
375
- : functionObj.call(currentContext, ...functionArgs);
376
- let returnValue = yield completePromise(value);
377
- thisStack.push(returnValue);
378
- return returnValue;
398
+ const rootScope = (0, eval_tree_common_1.getRootIdScope)(expr.obj, evalContext, thread);
399
+ const updatesState = rootScope && rootScope.type !== "block";
400
+ if (updatesState && evalContext.onWillUpdate) {
401
+ evalContext.onWillUpdate(rootScope, rootScope.name, "function-call");
379
402
  }
380
- catch (err) {
381
- throw err;
403
+ const value = ((_d = evalContext.options) === null || _d === void 0 ? void 0 : _d.defaultToOptionalMemberAccess)
404
+ ? functionObj === null || functionObj === void 0 ? void 0 : functionObj.call(currentContext, ...functionArgs)
405
+ : functionObj.call(currentContext, ...functionArgs);
406
+ let returnValue = yield completePromise(value);
407
+ if (updatesState && evalContext.onDidUpdate) {
408
+ evalContext.onDidUpdate(rootScope, rootScope.name, "function-call");
382
409
  }
410
+ // --- Done.
411
+ (0, eval_tree_common_1.setExprValue)(expr, { value: returnValue }, thread);
412
+ thisStack.push(returnValue);
413
+ return returnValue;
383
414
  });
384
415
  }
385
416
  function createArrowFunctionAsync(evaluator, expr) {
@@ -390,7 +421,6 @@ function createArrowFunctionAsync(evaluator, expr) {
390
421
  // --- Prepare the variables to pass
391
422
  const runTimeEvalContext = args[1];
392
423
  const runtimeThread = args[2];
393
- const runTimeOnStatementCompleted = args[3];
394
424
  // --- Create the thread that runs the arrow function
395
425
  const workingThread = {
396
426
  parent: runtimeThread,
@@ -420,27 +450,27 @@ function createArrowFunctionAsync(evaluator, expr) {
420
450
  const argSpec = argSpecs[i];
421
451
  let decl;
422
452
  switch (argSpec.type) {
423
- case "IdE": {
453
+ case ScriptingSourceTreeExp_1.T_IDENTIFIER: {
424
454
  decl = {
425
- type: "VarD",
455
+ type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
426
456
  id: argSpec.name,
427
457
  };
428
458
  break;
429
459
  }
430
- case "Destr": {
460
+ case ScriptingSourceTreeExp_1.T_DESTRUCTURE: {
431
461
  decl = {
432
- type: "VarD",
462
+ type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
433
463
  id: argSpec.id,
434
- arrayDestruct: argSpec.arrayDestruct,
435
- objectDestruct: argSpec.objectDestruct,
464
+ aDestr: argSpec.aDestr,
465
+ oDestr: argSpec.oDestr,
436
466
  };
437
467
  break;
438
468
  }
439
- case "SpreadE": {
469
+ case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION: {
440
470
  restFound = true;
441
471
  decl = {
442
- type: "VarD",
443
- id: argSpec.operand.name,
472
+ type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
473
+ id: argSpec.expr.name,
444
474
  };
445
475
  break;
446
476
  }
@@ -450,25 +480,25 @@ function createArrowFunctionAsync(evaluator, expr) {
450
480
  if (decl) {
451
481
  if (restFound) {
452
482
  // --- Get the rest of the arguments
453
- const restArgs = args.slice(i + 4);
483
+ const restArgs = args.slice(i + 3);
454
484
  let argVals = [];
455
485
  for (const arg of restArgs) {
456
486
  if (arg === null || arg === void 0 ? void 0 : arg._EXPRESSION_) {
457
- argVals.push(yield evaluator([], arg, runTimeEvalContext, runtimeThread, runTimeOnStatementCompleted));
487
+ argVals.push(yield evaluator([], arg, runTimeEvalContext, runtimeThread));
458
488
  }
459
489
  else {
460
490
  argVals.push(arg);
461
491
  }
462
492
  }
463
- yield (0, process_statement_async_1.processDeclarationsAsync)(arrowBlock, runTimeEvalContext, runtimeThread, runTimeOnStatementCompleted, [decl], false, true, argVals);
493
+ yield (0, process_statement_async_1.processDeclarationsAsync)(arrowBlock, runTimeEvalContext, runtimeThread, [decl], false, true, argVals);
464
494
  }
465
495
  else {
466
496
  // --- Get the actual value to work with
467
- let argVal = args[i + 4];
497
+ let argVal = args[i + 3];
468
498
  if (argVal === null || argVal === void 0 ? void 0 : argVal._EXPRESSION_) {
469
- argVal = yield evaluator([], argVal, runTimeEvalContext, runtimeThread, runTimeOnStatementCompleted);
499
+ argVal = yield evaluator([], argVal, runTimeEvalContext, runtimeThread);
470
500
  }
471
- yield (0, process_statement_async_1.processDeclarationsAsync)(arrowBlock, runTimeEvalContext, runtimeThread, runTimeOnStatementCompleted, [decl], false, true, argVal);
501
+ yield (0, process_statement_async_1.processDeclarationsAsync)(arrowBlock, runTimeEvalContext, runtimeThread, [decl], false, true, argVal);
472
502
  }
473
503
  }
474
504
  }
@@ -476,27 +506,27 @@ function createArrowFunctionAsync(evaluator, expr) {
476
506
  let returnValue;
477
507
  let statements;
478
508
  switch (expr.statement.type) {
479
- case "EmptyS":
509
+ case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
480
510
  statements = [];
481
511
  break;
482
- case "ExprS":
512
+ case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
483
513
  // --- Create a new thread for the call
484
514
  statements = [
485
515
  {
486
- type: "RetS",
487
- expression: expr.statement.expression,
516
+ type: ScriptingSourceTreeExp_1.T_RETURN_STATEMENT,
517
+ expr: expr.statement.expr,
488
518
  },
489
519
  ];
490
520
  break;
491
- case "BlockS":
521
+ case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
492
522
  // --- Create a new thread for the call
493
- statements = expr.statement.statements;
523
+ statements = expr.statement.stmts;
494
524
  break;
495
525
  default:
496
526
  throw new Error(`Arrow expression with a body of '${expr.statement.type}' is not supported yet.`);
497
527
  }
498
528
  // --- Process the statement with a new processor
499
- yield (0, process_statement_async_1.processStatementQueueAsync)(statements, runTimeEvalContext, workingThread, runTimeOnStatementCompleted);
529
+ yield (0, process_statement_async_1.processStatementQueueAsync)(statements, runTimeEvalContext, workingThread);
500
530
  // --- Return value is in a return value slot
501
531
  returnValue = workingThread.returnValue;
502
532
  // --- Remove the current working thread
@@ -562,32 +592,23 @@ function completePromise(input) {
562
592
  }
563
593
  });
564
594
  }
565
- /**
566
- * Gets the context of the variable
567
- * @param id Identifier to test
568
- * @param thread Thread to use for evaluation
569
- */
570
- function isConstVar(id, thread) {
571
- var _a;
572
- // --- Start search the block context
573
- if (thread.blocks) {
574
- for (let idx = thread.blocks.length; idx >= 0; idx--) {
575
- const constContext = (_a = thread.blocks[idx]) === null || _a === void 0 ? void 0 : _a.constVars;
576
- if (constContext && constContext.has(id))
577
- return true;
578
- }
579
- }
580
- // --- Not in block context
581
- return false;
582
- }
583
- function evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, thread, onStatementCompleted) {
595
+ function evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, thread) {
584
596
  return __awaiter(this, void 0, void 0, function* () {
585
597
  const segmentValues = new Array(expr.segments.length);
586
598
  for (let i = 0; i < expr.segments.length; ++i) {
587
- const evaledValue = yield evaluator(thisStack, expr.segments[i], evalContext, thread, onStatementCompleted);
599
+ yield evaluator(thisStack, expr.segments[i], evalContext, thread);
588
600
  thisStack.pop();
589
- segmentValues[i] = (evaledValue);
601
+ const evaledValue = yield completeExprValue(expr.segments[i], thread);
602
+ segmentValues[i] = evaledValue;
590
603
  }
591
604
  return (0, eval_tree_common_1.evalTemplateLiteralCore)(segmentValues);
592
605
  });
593
606
  }
607
+ function completeExprValue(expr, thread) {
608
+ return __awaiter(this, void 0, void 0, function* () {
609
+ const exprValue = (0, eval_tree_common_1.getExprValue)(expr, thread);
610
+ const awaited = yield completePromise(exprValue === null || exprValue === void 0 ? void 0 : exprValue.value);
611
+ (0, eval_tree_common_1.setExprValue)(expr, Object.assign(Object.assign({}, exprValue), { value: awaited }), thread);
612
+ return awaited;
613
+ });
614
+ }