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
@@ -2,15 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processStatementQueue = processStatementQueue;
4
4
  exports.processDeclarations = processDeclarations;
5
- const eval_tree_sync_1 = require("../script-runner/eval-tree-sync");
5
+ const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
6
6
  const reportEngineError_1 = require("../reportEngineError");
7
7
  const EngineError_1 = require("../EngineError");
8
8
  const process_statement_common_1 = require("./process-statement-common");
9
+ const eval_tree_sync_1 = require("./eval-tree-sync");
9
10
  const statement_queue_1 = require("./statement-queue");
11
+ const Parser_1 = require("../../parsers/scripting-exp/Parser");
10
12
  const SYNC_EVAL_TIMEOUT = 1000;
11
13
  // --- Helper function to process the entire queue synchronously
12
14
  function processStatementQueue(statements, evalContext, thread) {
13
- var _a;
15
+ var _a, _b, _c;
14
16
  if (!thread) {
15
17
  // --- Create the main thread for the queue
16
18
  thread = (0, process_statement_common_1.ensureMainThread)(evalContext);
@@ -21,7 +23,7 @@ function processStatementQueue(statements, evalContext, thread) {
21
23
  evalContext.startTick = new Date().valueOf();
22
24
  // --- Fill the queue with items
23
25
  const queue = new statement_queue_1.StatementQueue();
24
- queue.push((0, statement_queue_1.mapStatementsToQueueItems)(statements));
26
+ queue.push((0, statement_queue_1.mapStatementsToQueueItems)((0, process_statement_common_1.toStatementItems)(statements)));
25
27
  // --- Prepare queue diagnostics information
26
28
  const diagInfo = {
27
29
  processedStatements: 0,
@@ -43,7 +45,10 @@ function processStatementQueue(statements, evalContext, thread) {
43
45
  thread.breakLabelValue = queue.length > 0 ? queue.peek().label : -1;
44
46
  let outcome;
45
47
  try {
46
- outcome = processStatement(queueItem.statement, evalContext, thread);
48
+ // --- Sign that the statement is about to start
49
+ (_a = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementStarted) === null || _a === void 0 ? void 0 : _a.call(evalContext, evalContext, queueItem.statement);
50
+ // --- Execute the statement
51
+ outcome = processStatement(queueItem.statement, (_b = queueItem.execInfo) !== null && _b !== void 0 ? _b : {}, evalContext, thread);
47
52
  }
48
53
  catch (err) {
49
54
  if (thread.tryBlocks && thread.tryBlocks.length > 0) {
@@ -63,7 +68,8 @@ function processStatementQueue(statements, evalContext, thread) {
63
68
  (0, reportEngineError_1.reportEngineError)(err);
64
69
  }
65
70
  else {
66
- (0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err, (_a = queueItem.statement) === null || _a === void 0 ? void 0 : _a.source), err);
71
+ // TODO: Provide source code information
72
+ (0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err /* queueItem!.statement?.source */), err);
67
73
  }
68
74
  }
69
75
  }
@@ -78,6 +84,8 @@ function processStatementQueue(statements, evalContext, thread) {
78
84
  diagInfo.clearToLabels++;
79
85
  }
80
86
  }
87
+ // --- Sign that the statement has been completed
88
+ (_c = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementCompleted) === null || _c === void 0 ? void 0 : _c.call(evalContext, evalContext, queueItem.statement);
81
89
  // --- Provide diagnostics
82
90
  if (queue.length > diagInfo.maxQueueLength) {
83
91
  diagInfo.maxQueueLength = queue.length;
@@ -90,6 +98,7 @@ function processStatementQueue(statements, evalContext, thread) {
90
98
  }
91
99
  diagInfo.processedStatements++;
92
100
  }
101
+ // --- Done.
93
102
  return diagInfo;
94
103
  }
95
104
  /**
@@ -99,128 +108,94 @@ function processStatementQueue(statements, evalContext, thread) {
99
108
  * @param thread Logical thread to use for statement processing
100
109
  * @returns Items to put back into the queue of statements
101
110
  */
102
- function processStatement(statement, evalContext, thread) {
103
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
111
+ function processStatement(statement, execInfo, evalContext, thread) {
112
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
104
113
  // --- These items should be put in the statement queue after return
105
114
  let toUnshift = [];
106
115
  let clearToLabel;
107
116
  // --- Process the statement according to its type
108
117
  switch (statement.type) {
109
- case "ImportD":
110
- // --- Get module information
111
- const thisModule = statement.module;
112
- if (!thisModule) {
113
- throw new Error("Missing module");
114
- }
115
- const parentModule = (_a = statement.module) === null || _a === void 0 ? void 0 : _a.parent;
116
- if (!parentModule) {
117
- throw new Error("Missing parent module");
118
- }
119
- // --- At this point the imported module is set
120
- // if (!statement.module!.executed) {
121
- // // --- Run the module, it has not been executed yet
122
- // const childEvalContext = createEvalContext({
123
- // cancellationToken: evalContext.cancellationToken,
124
- // timeout: evalContext.timeout ?? 1000
125
- // });
126
- // statement.module!.executed = true;
127
- // executeScriptModule(statement.module!, childEvalContext);
128
- // }
129
- // --- Import the module's exported variables into the parent module
130
- const topVars = evalContext.mainThread.blocks[0].vars;
131
- const topConst = evalContext.mainThread.blocks[0].constVars;
132
- for (const modImports of Object.values(statement.imports)) {
133
- for (const key of Object.keys(modImports)) {
134
- if (key in topVars) {
135
- throw new Error(`Import ${key} already exists`);
136
- }
137
- topVars[key] = statement.module.exports.get(modImports[key]);
138
- topConst.add(key);
139
- }
140
- }
141
- break;
142
- case "FuncD":
118
+ case ScriptingSourceTreeExp_1.T_FUNCTION_DECLARATION:
143
119
  // --- Function declarations are already hoisted, nothing to do
144
120
  break;
145
- case "VarS":
121
+ case ScriptingSourceTreeExp_1.T_VAR_STATEMENT:
146
122
  if (thread !== evalContext.mainThread) {
147
123
  throw new Error("'var' declarations are not allowed within functions");
148
124
  }
149
125
  break;
150
- case "EmptyS":
126
+ case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
151
127
  // --- Nothing to do
152
128
  break;
153
- case "BlockS":
129
+ case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
154
130
  // --- No statement, nothing to process
155
- if (statement.statements.length === 0)
131
+ if (statement.stmts.length === 0)
156
132
  break;
157
133
  // --- Create a new block scope
158
- (_b = thread.blocks) !== null && _b !== void 0 ? _b : (thread.blocks = []);
134
+ (_a = thread.blocks) !== null && _a !== void 0 ? _a : (thread.blocks = []);
159
135
  thread.blocks.push({ vars: {} });
160
136
  // --- Hoist function declarations to the innermost block scope
161
- (0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.statements);
162
- // --- Prepare an empty statement that will only remove the block scope when the entire block is processed
163
- const closing = {
164
- type: "EmptyS",
165
- removeBlockScope: true,
166
- }; // --- We need the cast as we do not provide required props
167
- // --- Queue the block scope's body
168
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statement.statements, closing]);
137
+ (0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.stmts);
138
+ // --- Queue the block scope's body...
139
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
140
+ ...(0, process_statement_common_1.toStatementItems)(statement.stmts),
141
+ // --- ...and an empty statement to remove the block scope
142
+ (0, process_statement_common_1.closing)(),
143
+ ]);
169
144
  break;
170
- case "ExprS":
145
+ case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
171
146
  // --- Just evaluate it
172
- const statementValue = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
147
+ const statementValue = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
173
148
  if (thread.blocks && thread.blocks.length !== 0) {
174
149
  thread.blocks[thread.blocks.length - 1].returnValue = statementValue;
175
150
  }
176
151
  break;
177
- case "ArrowS":
152
+ case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION_STATEMENT:
178
153
  // --- Compile the arrow expression
179
- const arrowFuncValue = (0, eval_tree_sync_1.executeArrowExpressionSync)(statement.expression, evalContext, thread, ...((_c = evalContext.eventArgs) !== null && _c !== void 0 ? _c : []));
154
+ const arrowFuncValue = (0, eval_tree_sync_1.executeArrowExpressionSync)(statement.expr, evalContext, thread, ...((_b = evalContext.eventArgs) !== null && _b !== void 0 ? _b : []));
180
155
  if (thread.blocks && thread.blocks.length !== 0) {
181
156
  thread.blocks[thread.blocks.length - 1].returnValue = arrowFuncValue;
182
157
  }
183
158
  break;
184
- case "LetS": {
159
+ case ScriptingSourceTreeExp_1.T_LET_STATEMENT: {
185
160
  // --- Create a new variable in the innermost scope
186
161
  const block = (0, process_statement_common_1.innermostBlockScope)(thread);
187
162
  if (!block) {
188
163
  throw new Error("Missing block scope");
189
164
  }
190
- processDeclarations(block, evalContext, thread, statement.declarations);
165
+ processDeclarations(block, evalContext, thread, statement.decls);
191
166
  break;
192
167
  }
193
- case "ConstS": {
168
+ case ScriptingSourceTreeExp_1.T_CONST_STATEMENT: {
194
169
  // --- Create a new variable in the innermost scope
195
170
  const block = (0, process_statement_common_1.innermostBlockScope)(thread);
196
171
  if (!block) {
197
172
  throw new Error("Missing block scope");
198
173
  }
199
- processDeclarations(block, evalContext, thread, statement.declarations, true);
174
+ processDeclarations(block, evalContext, thread, statement.decls, true);
200
175
  break;
201
176
  }
202
- case "IfS":
177
+ case ScriptingSourceTreeExp_1.T_IF_STATEMENT:
203
178
  // --- Evaluate the condition
204
- const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
179
+ const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
205
180
  if (condition) {
206
- toUnshift = (0, statement_queue_1.mapToItem)(statement.thenBranch);
181
+ toUnshift = (0, statement_queue_1.mapToItem)(statement.thenB);
207
182
  }
208
- else if (statement.elseBranch) {
209
- toUnshift = (0, statement_queue_1.mapToItem)(statement.elseBranch);
183
+ else if (statement.elseB) {
184
+ toUnshift = (0, statement_queue_1.mapToItem)(statement.elseB);
210
185
  }
211
186
  break;
212
- case "RetS": {
187
+ case ScriptingSourceTreeExp_1.T_RETURN_STATEMENT: {
213
188
  // --- Check if return is valid here
214
189
  let blockScope = (0, process_statement_common_1.innermostBlockScope)(thread);
215
190
  if (blockScope === undefined) {
216
191
  throw new Error("Return requires a block scope");
217
192
  }
218
193
  // --- Store the return value
219
- thread.returnValue = statement.expression
220
- ? (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread)
194
+ thread.returnValue = statement.expr
195
+ ? (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread)
221
196
  : undefined;
222
197
  // --- Check for try blocks
223
- if (((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length > 0) {
198
+ if (((_c = thread.tryBlocks) !== null && _c !== void 0 ? _c : []).length > 0) {
224
199
  // --- Mark the loop's try scope to exit with "return"
225
200
  const returnTryScope = thread.tryBlocks[0];
226
201
  returnTryScope.exitType = "return";
@@ -238,11 +213,11 @@ function processStatement(statement, evalContext, thread) {
238
213
  }
239
214
  break;
240
215
  }
241
- case "WhileS": {
216
+ case ScriptingSourceTreeExp_1.T_WHILE_STATEMENT: {
242
217
  // --- Create or get the loop's scope (guard is falsy for the first execution)
243
- let loopScope = statement.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
218
+ let loopScope = execInfo.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
244
219
  // --- Evaluate the loop condition
245
- const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
220
+ const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
246
221
  if (condition) {
247
222
  toUnshift = (0, process_statement_common_1.provideLoopBody)(loopScope, statement, thread.breakLabelValue);
248
223
  }
@@ -252,14 +227,14 @@ function processStatement(statement, evalContext, thread) {
252
227
  }
253
228
  break;
254
229
  }
255
- case "DoWS": {
256
- if (!statement.guard) {
230
+ case ScriptingSourceTreeExp_1.T_DO_WHILE_STATEMENT: {
231
+ if (!execInfo.guard) {
257
232
  // --- First loop execution (do-while is a post-test loop)
258
233
  toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.createLoopScope)(thread), statement, thread.breakLabelValue);
259
234
  break;
260
235
  }
261
236
  // --- Evaluate the loop condition
262
- const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
237
+ const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
263
238
  if (condition) {
264
239
  toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.innermostLoopScope)(thread), statement, thread.breakLabelValue);
265
240
  }
@@ -269,7 +244,7 @@ function processStatement(statement, evalContext, thread) {
269
244
  }
270
245
  break;
271
246
  }
272
- case "ContS": {
247
+ case ScriptingSourceTreeExp_1.T_CONTINUE_STATEMENT: {
273
248
  // --- Search for the innermost non-switch loop scope, release the switch scopes
274
249
  if (!thread.loops || thread.loops.length === 0) {
275
250
  throw new Error("Missing loop scope");
@@ -286,7 +261,7 @@ function processStatement(statement, evalContext, thread) {
286
261
  throw new Error("Missing loop scope");
287
262
  }
288
263
  if (loopScope.tryBlockDepth >= 0 &&
289
- loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
264
+ loopScope.tryBlockDepth < ((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length) {
290
265
  // --- Mark the loop's try scope to exit with "continue"
291
266
  for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
292
267
  thread.tryBlocks[loopScope.tryBlockDepth].exitType = "continue";
@@ -301,7 +276,7 @@ function processStatement(statement, evalContext, thread) {
301
276
  }
302
277
  break;
303
278
  }
304
- case "BrkS": {
279
+ case ScriptingSourceTreeExp_1.T_BREAK_STATEMENT: {
305
280
  const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
306
281
  if (loopScope === undefined) {
307
282
  throw new Error("Missing loop scope");
@@ -313,7 +288,7 @@ function processStatement(statement, evalContext, thread) {
313
288
  }
314
289
  // --- Break is in a loop construct
315
290
  if (loopScope.tryBlockDepth >= 0 &&
316
- loopScope.tryBlockDepth < ((_f = thread.tryBlocks) !== null && _f !== void 0 ? _f : []).length) {
291
+ loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
317
292
  // --- Mark the loop's try scope to exit with "break"
318
293
  for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
319
294
  thread.tryBlocks[loopScope.tryBlockDepth].exitType = "break";
@@ -328,17 +303,17 @@ function processStatement(statement, evalContext, thread) {
328
303
  }
329
304
  break;
330
305
  }
331
- case "ForS":
332
- if (!statement.guard) {
306
+ case ScriptingSourceTreeExp_1.T_FOR_STATEMENT:
307
+ if (!execInfo.guard) {
333
308
  // --- Init the loop with a new scope
334
309
  (0, process_statement_common_1.createLoopScope)(thread, 1);
335
310
  // --- Create a new block for the loop variables
336
- (_g = thread.blocks) !== null && _g !== void 0 ? _g : (thread.blocks = []);
311
+ (_f = thread.blocks) !== null && _f !== void 0 ? _f : (thread.blocks = []);
337
312
  thread.blocks.push({ vars: {} });
338
- const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
313
+ const guardStatement = (0, process_statement_common_1.guard)(statement);
339
314
  if (statement.init) {
340
315
  // --- Unshift the initialization part and the guarded for-loop
341
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.init, guardStatement]);
316
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([{ statement: statement.init }, guardStatement]);
342
317
  }
343
318
  else {
344
319
  // --- No init, unshift only the guard statement
@@ -347,21 +322,31 @@ function processStatement(statement, evalContext, thread) {
347
322
  }
348
323
  else {
349
324
  // --- Initialization already done. Evaluate the condition
350
- if (!statement.condition || (0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread)) {
325
+ if (!statement.cond || (0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread)) {
351
326
  // --- Stay in the loop, inject the body, the update expression, and the loop guard
352
327
  const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
353
- if (statement.update) {
328
+ if (statement.upd) {
354
329
  const updateStmt = {
355
- type: "ExprS",
356
- expression: statement.update,
330
+ statement: {
331
+ type: ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT,
332
+ nodeId: (0, Parser_1.createXmlUiTreeNodeId)(),
333
+ expr: statement.upd,
334
+ },
357
335
  };
358
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, updateStmt, Object.assign({}, statement)]);
336
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
337
+ { statement: statement.body },
338
+ updateStmt,
339
+ { statement, execInfo },
340
+ ]);
359
341
  }
360
342
  else {
361
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
343
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
344
+ { statement: statement.body },
345
+ { statement, execInfo },
346
+ ]);
362
347
  }
363
348
  // --- The next queue label is for "break"
364
- loopScope.breakLabel = (_h = thread.breakLabelValue) !== null && _h !== void 0 ? _h : -1;
349
+ loopScope.breakLabel = (_g = thread.breakLabelValue) !== null && _g !== void 0 ? _g : -1;
365
350
  // --- The guard action's label is for "continue"
366
351
  loopScope.continueLabel = toUnshift[1].label;
367
352
  }
@@ -371,10 +356,10 @@ function processStatement(statement, evalContext, thread) {
371
356
  }
372
357
  }
373
358
  break;
374
- case "ForInS":
375
- if (!statement.guard) {
359
+ case ScriptingSourceTreeExp_1.T_FOR_IN_STATEMENT:
360
+ if (!execInfo.guard) {
376
361
  // --- Get the object keys
377
- const keyedObject = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
362
+ const keyedObject = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
378
363
  if (keyedObject == undefined) {
379
364
  // --- Nothing to do, no object to traverse
380
365
  break;
@@ -382,32 +367,32 @@ function processStatement(statement, evalContext, thread) {
382
367
  // --- Init the loop with a new scope
383
368
  (0, process_statement_common_1.createLoopScope)(thread, 1);
384
369
  // --- Create a new block for the loop variables
385
- (_j = thread.blocks) !== null && _j !== void 0 ? _j : (thread.blocks = []);
370
+ (_h = thread.blocks) !== null && _h !== void 0 ? _h : (thread.blocks = []);
386
371
  thread.blocks.push({ vars: {} });
387
- statement.keys = Object.keys(keyedObject);
388
- statement.keyIndex = 0;
389
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
372
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
373
+ { statement, execInfo: { guard: true, keys: Object.keys(keyedObject), keyIndex: 0 } },
374
+ ]);
390
375
  }
391
376
  else {
392
377
  // --- Just for the sake of extra safety
393
- if (statement.keyIndex === undefined || statement.keys === undefined) {
378
+ if (execInfo.keyIndex === undefined || execInfo.keys === undefined) {
394
379
  throw new Error("Keys information expected in for..in loop");
395
380
  }
396
381
  // --- Any key left?
397
- if (statement.keyIndex < statement.keys.length) {
382
+ if (execInfo.keyIndex < execInfo.keys.length) {
398
383
  // --- Set the binding variable to the next key
399
- const propValue = statement.keys[statement.keyIndex++];
400
- switch (statement.varBinding) {
384
+ const propValue = execInfo.keys[execInfo.keyIndex++];
385
+ switch (statement.varB) {
401
386
  case "none": {
402
387
  const assigmentExpr = {
403
- type: "AsgnE",
388
+ type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
404
389
  leftValue: {
405
- type: "IdE",
406
- name: statement.id,
390
+ type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
391
+ name: statement.id.name,
407
392
  },
408
- operator: "=",
409
- operand: {
410
- type: "LitE",
393
+ op: "=",
394
+ expr: {
395
+ type: ScriptingSourceTreeExp_1.T_LITERAL,
411
396
  value: propValue,
412
397
  },
413
398
  };
@@ -422,19 +407,22 @@ function processStatement(statement, evalContext, thread) {
422
407
  if (!block) {
423
408
  throw new Error("Missing block scope");
424
409
  }
425
- block.vars[statement.id] = propValue;
426
- if (statement.varBinding === "const") {
427
- (_k = block.constVars) !== null && _k !== void 0 ? _k : (block.constVars = new Set());
428
- block.constVars.add(statement.id);
410
+ block.vars[statement.id.name] = propValue;
411
+ if (statement.varB === "const") {
412
+ (_j = block.constVars) !== null && _j !== void 0 ? _j : (block.constVars = new Set());
413
+ block.constVars.add(statement.id.name);
429
414
  }
430
415
  }
431
416
  break;
432
417
  }
433
418
  // --- Inject the loop body
434
419
  const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
435
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
420
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
421
+ { statement: statement.body },
422
+ { statement, execInfo },
423
+ ]);
436
424
  // --- The next queue label is for "break"
437
- loopScope.breakLabel = (_l = thread.breakLabelValue) !== null && _l !== void 0 ? _l : -1;
425
+ loopScope.breakLabel = (_k = thread.breakLabelValue) !== null && _k !== void 0 ? _k : -1;
438
426
  // --- The guard action's label is for "continue"
439
427
  loopScope.continueLabel = toUnshift[1].label;
440
428
  }
@@ -444,10 +432,10 @@ function processStatement(statement, evalContext, thread) {
444
432
  }
445
433
  }
446
434
  break;
447
- case "ForOfS":
448
- if (!statement.guard) {
435
+ case ScriptingSourceTreeExp_1.T_FOR_OF_STATEMENT:
436
+ if (!execInfo.guard) {
449
437
  // --- Get the object keys
450
- const iteratorObject = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
438
+ const iteratorObject = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
451
439
  if (iteratorObject == null || typeof iteratorObject[Symbol.iterator] !== "function") {
452
440
  // --- The object is not an iterator
453
441
  throw new Error("Object in for..of is not iterable");
@@ -455,18 +443,19 @@ function processStatement(statement, evalContext, thread) {
455
443
  // --- Init the loop with a new scope
456
444
  (0, process_statement_common_1.createLoopScope)(thread, 1);
457
445
  // --- Create a new block for the loop variables
458
- (_m = thread.blocks) !== null && _m !== void 0 ? _m : (thread.blocks = []);
446
+ (_l = thread.blocks) !== null && _l !== void 0 ? _l : (thread.blocks = []);
459
447
  thread.blocks.push({ vars: {} });
460
- statement.iterator = iteratorObject[Symbol.iterator]();
461
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
448
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
449
+ { statement, execInfo: { guard: true, iterator: iteratorObject[Symbol.iterator]() } },
450
+ ]);
462
451
  }
463
452
  else {
464
453
  // --- Just for the sake of extra safety
465
- if (statement.iterator === undefined) {
454
+ if (execInfo.iterator === undefined) {
466
455
  throw new Error("Iterator expected in for..of loop");
467
456
  }
468
457
  // --- Any iteration left?
469
- const nextIteration = statement.iterator.next();
458
+ const nextIteration = execInfo.iterator.next();
470
459
  if (nextIteration.done) {
471
460
  // --- The for..of loop is complete. Remove the loop's scope from the evaluation context
472
461
  (0, process_statement_common_1.releaseLoopScope)(thread);
@@ -474,17 +463,17 @@ function processStatement(statement, evalContext, thread) {
474
463
  }
475
464
  // --- Set the binding variable to the next key
476
465
  const propValue = nextIteration.value;
477
- switch (statement.varBinding) {
466
+ switch (statement.varB) {
478
467
  case "none": {
479
468
  const assigmentExpr = {
480
- type: "AsgnE",
469
+ type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
481
470
  leftValue: {
482
- type: "IdE",
483
- name: statement.id,
471
+ type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
472
+ name: statement.id.name,
484
473
  },
485
- operator: "=",
486
- operand: {
487
- type: "LitE",
474
+ op: "=",
475
+ expr: {
476
+ type: ScriptingSourceTreeExp_1.T_LITERAL,
488
477
  value: propValue,
489
478
  },
490
479
  };
@@ -499,28 +488,31 @@ function processStatement(statement, evalContext, thread) {
499
488
  if (!block) {
500
489
  throw new Error("Missing block scope");
501
490
  }
502
- block.vars[statement.id] = propValue;
503
- if (statement.varBinding === "const") {
504
- (_o = block.constVars) !== null && _o !== void 0 ? _o : (block.constVars = new Set());
505
- block.constVars.add(statement.id);
491
+ block.vars[statement.id.name] = propValue;
492
+ if (statement.varB === "const") {
493
+ (_m = block.constVars) !== null && _m !== void 0 ? _m : (block.constVars = new Set());
494
+ block.constVars.add(statement.id.name);
506
495
  }
507
496
  }
508
497
  break;
509
498
  }
510
499
  // --- Inject the loop body
511
500
  const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
512
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
501
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
502
+ { statement: statement.body },
503
+ { statement, execInfo },
504
+ ]);
513
505
  // --- The next queue label is for "break"
514
- loopScope.breakLabel = (_p = thread.breakLabelValue) !== null && _p !== void 0 ? _p : -1;
506
+ loopScope.breakLabel = (_o = thread.breakLabelValue) !== null && _o !== void 0 ? _o : -1;
515
507
  // --- The guard action's label is for "continue"
516
508
  loopScope.continueLabel = toUnshift[1].label;
517
509
  }
518
510
  break;
519
- case "ThrowS": {
520
- throw new EngineError_1.ThrowStatementError((0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread));
511
+ case ScriptingSourceTreeExp_1.T_THROW_STATEMENT: {
512
+ throw new EngineError_1.ThrowStatementError((0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread));
521
513
  }
522
- case "TryS": {
523
- if (!statement.guard) {
514
+ case ScriptingSourceTreeExp_1.T_TRY_STATEMENT: {
515
+ if (!execInfo.guard) {
524
516
  // --- Execute the try block
525
517
  toUnshift = (0, process_statement_common_1.provideTryBody)(thread, (0, process_statement_common_1.createTryScope)(thread, statement));
526
518
  break;
@@ -535,10 +527,10 @@ function processStatement(statement, evalContext, thread) {
535
527
  // --- Remove the "try" block's scope
536
528
  thread.blocks.pop();
537
529
  // --- Go on with catch or finally
538
- if (statement.catchBlock) {
539
- if (tryScope.statement.catchVariable) {
530
+ if (statement.catchB) {
531
+ if (tryScope.statement.catchV) {
540
532
  const block = (0, process_statement_common_1.innermostBlockScope)(thread);
541
- block.vars[tryScope.statement.catchVariable] =
533
+ block.vars[tryScope.statement.catchV.name] =
542
534
  tryScope.errorToThrow instanceof EngineError_1.ThrowStatementError
543
535
  ? tryScope.errorToThrow.errorObject
544
536
  : tryScope.errorToThrow;
@@ -547,7 +539,7 @@ function processStatement(statement, evalContext, thread) {
547
539
  tryScope.processingPhase = "catch";
548
540
  toUnshift = (0, process_statement_common_1.provideCatchBody)(thread, tryScope);
549
541
  }
550
- else if (tryScope.statement.finallyBlock) {
542
+ else if (tryScope.statement.finallyB) {
551
543
  // --- No catch, move on finally
552
544
  tryScope.processingPhase = "finally";
553
545
  toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
@@ -572,14 +564,14 @@ function processStatement(statement, evalContext, thread) {
572
564
  case "try":
573
565
  // --- We completed the try block successfully
574
566
  tryScope.processingPhase = "finally";
575
- if (statement.finallyBlock) {
567
+ if (statement.finallyB) {
576
568
  toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
577
569
  }
578
570
  break;
579
571
  case "catch":
580
572
  // --- We completed the catch block successfully, remove the handled error
581
573
  tryScope.processingPhase = "finally";
582
- if (statement.finallyBlock) {
574
+ if (statement.finallyB) {
583
575
  toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
584
576
  }
585
577
  break;
@@ -622,9 +614,9 @@ function processStatement(statement, evalContext, thread) {
622
614
  }
623
615
  break;
624
616
  }
625
- case "SwitchS": {
617
+ case ScriptingSourceTreeExp_1.T_SWITCH_STATEMENT: {
626
618
  // --- Create or get the loop's scope (guard is falsy for the first execution)
627
- if (statement.guard) {
619
+ if (execInfo.guard) {
628
620
  // --- Complete the switch
629
621
  (0, process_statement_common_1.releaseLoopScope)(thread);
630
622
  }
@@ -633,18 +625,18 @@ function processStatement(statement, evalContext, thread) {
633
625
  loopScope.isSwitch = true;
634
626
  thread.blocks.push({ vars: {} });
635
627
  // --- Evaluate the switch value
636
- const switchValue = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
628
+ const switchValue = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
637
629
  // --- Find the matching label
638
630
  let matchingIndex = -1;
639
631
  for (let i = 0; i < statement.cases.length; i++) {
640
632
  const currentCase = statement.cases[i];
641
633
  // --- Check for default case
642
- if (currentCase.caseExpression === undefined) {
634
+ if (currentCase.caseE === undefined) {
643
635
  matchingIndex = i;
644
636
  break;
645
637
  }
646
638
  // --- Check for matching case
647
- const caseValue = (0, eval_tree_sync_1.evalBinding)(currentCase.caseExpression, evalContext, thread);
639
+ const caseValue = (0, eval_tree_sync_1.evalBinding)(currentCase.caseE, evalContext, thread);
648
640
  if (caseValue === switchValue) {
649
641
  matchingIndex = i;
650
642
  break;
@@ -654,19 +646,21 @@ function processStatement(statement, evalContext, thread) {
654
646
  const statementFlow = [];
655
647
  if (matchingIndex >= 0) {
656
648
  for (let i = matchingIndex; i < statement.cases.length; i++) {
657
- statementFlow.push(...statement.cases[i].statements);
649
+ statementFlow.push(...statement.cases[i].stmts);
658
650
  }
659
651
  }
660
652
  // --- Queue the statement flow and the guard
661
- const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
662
- toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statementFlow, guardStatement]);
653
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
654
+ ...(0, process_statement_common_1.toStatementItems)(statementFlow),
655
+ (0, process_statement_common_1.guard)(statement),
656
+ ]);
663
657
  loopScope.breakLabel = toUnshift[toUnshift.length - 1].label;
664
658
  }
665
659
  break;
666
660
  }
667
661
  }
668
662
  // --- The statement may remove the innermost scope
669
- if (statement.removeBlockScope) {
663
+ if (execInfo.removeBlockScope) {
670
664
  if (thread.blocks && thread.blocks.length > 0) {
671
665
  thread.blocks.pop();
672
666
  }
@@ -682,9 +676,9 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
682
676
  if (useValue) {
683
677
  value = baseValue;
684
678
  }
685
- else if (decl.expression) {
679
+ else if (decl.expr) {
686
680
  //TODO illesg here, functionInvocation for global function (e.g. window.confirm... )
687
- value = (0, eval_tree_sync_1.evalBinding)(decl.expression, evalContext, thread);
681
+ value = (0, eval_tree_sync_1.evalBinding)(decl.expr, evalContext, thread);
688
682
  }
689
683
  visitDeclaration(block, decl, value, addConst);
690
684
  }
@@ -694,11 +688,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
694
688
  if (decl.id) {
695
689
  visitIdDeclaration(block, decl.id, baseValue, addConst);
696
690
  }
697
- else if (decl.arrayDestruct) {
698
- visitArrayDestruct(block, decl.arrayDestruct, baseValue, addConst);
691
+ else if (decl.aDestr) {
692
+ visitArrayDestruct(block, decl.aDestr, baseValue, addConst);
699
693
  }
700
- else if (decl.objectDestruct) {
701
- visitObjectDestruct(block, decl.objectDestruct, baseValue, addConst);
694
+ else if (decl.oDestr) {
695
+ visitObjectDestruct(block, decl.oDestr, baseValue, addConst);
702
696
  }
703
697
  else {
704
698
  throw new Error("Unknown declaration specifier");
@@ -724,11 +718,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
724
718
  if (arrDecl.id) {
725
719
  visitIdDeclaration(block, arrDecl.id, value, addConst);
726
720
  }
727
- else if (arrDecl.arrayDestruct) {
728
- visitArrayDestruct(block, arrDecl.arrayDestruct, value, addConst);
721
+ else if (arrDecl.aDestr) {
722
+ visitArrayDestruct(block, arrDecl.aDestr, value, addConst);
729
723
  }
730
- else if (arrDecl.objectDestruct) {
731
- visitObjectDestruct(block, arrDecl.objectDestruct, value, addConst);
724
+ else if (arrDecl.oDestr) {
725
+ visitObjectDestruct(block, arrDecl.oDestr, value, addConst);
732
726
  }
733
727
  }
734
728
  }
@@ -738,11 +732,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
738
732
  for (let i = 0; i < objectD.length; i++) {
739
733
  const objDecl = objectD[i];
740
734
  const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[objDecl.id];
741
- if (objDecl.arrayDestruct) {
742
- visitArrayDestruct(block, objDecl.arrayDestruct, value, addConst);
735
+ if (objDecl.aDestr) {
736
+ visitArrayDestruct(block, objDecl.aDestr, value, addConst);
743
737
  }
744
- else if (objDecl.objectDestruct) {
745
- visitObjectDestruct(block, objDecl.objectDestruct, value, addConst);
738
+ else if (objDecl.oDestr) {
739
+ visitObjectDestruct(block, objDecl.oDestr, value, addConst);
746
740
  }
747
741
  else {
748
742
  visitIdDeclaration(block, (_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id, value, addConst);