xmlui 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{apiInterceptorWorker-fLBfPj2T.mjs → apiInterceptorWorker-B1u6prJM.mjs} +1 -1
- package/dist/{index-wd8FRzuM.mjs → index-CVvazA5D.mjs} +5849 -6109
- package/dist/index.css +274 -301
- package/dist/language-server.mjs +25 -1
- package/dist/{lint-B18Ko6Sy.mjs → lint-gX2osbkz.mjs} +920 -1120
- package/dist/scripts/bin/build.js +2 -2
- package/dist/scripts/bin/start.js +3 -9
- package/dist/scripts/bin/vite-xmlui-plugin.js +2 -2
- package/dist/scripts/bin/viteConfig.js +89 -63
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +1 -2
- package/dist/scripts/src/components/Accordion/Accordion.js +6 -16
- package/dist/scripts/src/components/App/AppNative.js +8 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -5
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +10 -4
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +13 -19
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +7 -3
- package/dist/scripts/src/components/Avatar/Avatar.js +2 -9
- package/dist/scripts/src/components/Badge/Badge.js +2 -8
- package/dist/scripts/src/components/Button/Button.js +28 -60
- package/dist/scripts/src/components/Card/Card.js +1 -6
- package/dist/scripts/src/components/Checkbox/Checkbox.js +4 -12
- package/dist/scripts/src/components/ComponentProvider.js +4 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +3 -10
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/scripts/src/components/Form/Form.js +12 -28
- package/dist/scripts/src/components/Form/FormNative.js +9 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +1 -1
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +2 -2
- package/dist/scripts/src/components/Heading/HeadingNative.js +0 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +4 -19
- package/dist/scripts/src/components/IconProvider.js +2 -2
- package/dist/scripts/src/components/Link/Link.js +2 -8
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +1 -3
- package/dist/scripts/src/components/NavGroup/NavGroup.js +34 -3
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +24 -12
- package/dist/scripts/src/components/NavLink/NavLink.js +4 -11
- package/dist/scripts/src/components/NavPanel/NavPanel.js +1 -6
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +2 -8
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -12
- package/dist/scripts/src/components/Select/Select.js +5 -13
- package/dist/scripts/src/components/Select/SelectNative.js +7 -3
- package/dist/scripts/src/components/Slider/Slider.js +2 -8
- package/dist/scripts/src/components/Spinner/Spinner.js +1 -6
- package/dist/scripts/src/components/SubNavPanel/SubNavPanel.js +22 -0
- package/dist/scripts/src/components/SubNavPanel/SubNavPanelNative.js +9 -0
- package/dist/scripts/src/components/Switch/Switch.js +6 -16
- package/dist/scripts/src/components/Table/Table.js +8 -17
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +4 -12
- package/dist/scripts/src/components/Tabs/Tabs.js +3 -10
- package/dist/scripts/src/components/Text/Text.js +10 -24
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
- package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +3 -3
- package/dist/scripts/src/components-core/DevTools.js +5 -4
- package/dist/scripts/src/components-core/RestApiProxy.js +7 -3
- package/dist/scripts/src/components-core/action/APICall.js +2 -1
- package/dist/scripts/src/components-core/rendering/Container.js +15 -11
- package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -2
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +0 -2
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +11 -64
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +177 -175
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +173 -231
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +129 -100
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +170 -175
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +48 -33
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +164 -170
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +5 -4
- package/dist/scripts/src/components-core/script-runner/visitors.js +124 -116
- package/dist/scripts/src/components-core/theming/themes/palette.js +1 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +300 -154
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +510 -510
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +0 -1
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +11 -11
- package/dist/scripts/src/components-core/utils/misc.js +13 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +56 -53
- package/dist/scripts/src/components-core/xmlui-parser.js +1 -1
- package/dist/scripts/src/parsers/scripting-exp/Lexer.js +1092 -0
- package/dist/scripts/src/parsers/scripting-exp/Parser.js +2635 -0
- package/dist/scripts/src/parsers/scripting-exp/ParserError.js +47 -0
- package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting-exp/TokenType.js +2 -4
- package/dist/scripts/src/parsers/scripting-exp/code-behind-collect.js +101 -0
- package/dist/scripts/src/parsers/scripting-exp/modules.js +107 -0
- package/dist/scripts/src/parsers/{scripting → scripting-exp}/tree-visitor.js +103 -107
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +12 -12
- package/dist/style.css +245 -286
- package/dist/xmlui-metadata.mjs +2741 -2211
- package/dist/xmlui-metadata.umd.js +2740 -2212
- package/dist/xmlui-parser.d.ts +320 -232
- package/dist/xmlui-parser.mjs +19 -19
- package/dist/xmlui-standalone.umd.js +6754 -7220
- package/dist/xmlui.d.ts +322 -230
- package/dist/xmlui.mjs +1 -1
- package/package.json +10 -6
- package/dist/_commonjsHelpers-CcAunmGO.mjs +0 -33
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +0 -34
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +0 -40
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +0 -40
- package/dist/scripts/src/components-core/script-runner/syncProxy.js +0 -31
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +0 -153
- package/dist/scripts/src/parsers/scripting/modules.js +0 -284
- /package/dist/scripts/src/abstractions/scripting/{LogicalThread.js → LogicalThreadExp.js} +0 -0
- /package/dist/scripts/src/abstractions/scripting/{TryScope.js → TryScopeExp.js} +0 -0
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.evalBindingExpression = evalBindingExpression;
|
|
4
4
|
exports.evalBinding = evalBinding;
|
|
5
5
|
exports.executeArrowExpressionSync = executeArrowExpressionSync;
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const process_statement_sync_1 = require("./process-statement-sync");
|
|
6
|
+
const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
|
|
7
|
+
const Parser_1 = require("../../parsers/scripting-exp/Parser");
|
|
9
8
|
const bannedFunctions_1 = require("./bannedFunctions");
|
|
10
|
-
const syncProxy_1 = require("./syncProxy");
|
|
11
9
|
const eval_tree_common_1 = require("./eval-tree-common");
|
|
10
|
+
const process_statement_common_1 = require("./process-statement-common");
|
|
11
|
+
const process_statement_sync_1 = require("./process-statement-sync");
|
|
12
12
|
/**
|
|
13
13
|
* Evaluates the specified binding expression tree and retrieves the evaluated value
|
|
14
14
|
* @param source Binding tree expression
|
|
@@ -54,13 +54,13 @@ function evalBinding(expr, evalContext, thread) {
|
|
|
54
54
|
*/
|
|
55
55
|
function executeArrowExpressionSync(expr, evalContext, thread, ...args) {
|
|
56
56
|
// --- Just an extra safety check
|
|
57
|
-
if (expr.type !==
|
|
57
|
+
if (expr.type !== ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
|
|
58
58
|
throw new Error("executeArrowExpression expects an 'ArrowExpression' object.");
|
|
59
59
|
}
|
|
60
60
|
// --- This is the evaluator that an arrow expression uses internally
|
|
61
61
|
const evaluator = evalBindingExpressionTree;
|
|
62
62
|
// --- Compiles the Arrow function to a JavaScript function
|
|
63
|
-
const nativeFunction = createArrowFunction(evaluator, expr);
|
|
63
|
+
const nativeFunction = createArrowFunction(evaluator, expr, evalContext);
|
|
64
64
|
// --- Run the compiled arrow function. Note, we have two prefix arguments:
|
|
65
65
|
// --- #1: The names of arrow function arguments
|
|
66
66
|
// --- #2: The evaluation context the arrow function runs in
|
|
@@ -82,50 +82,47 @@ function evalBindingExpressionTree(thisStack, expr, evalContext, thread) {
|
|
|
82
82
|
evalContext.options = { defaultToOptionalMemberAccess: true };
|
|
83
83
|
}
|
|
84
84
|
// --- Prepare evaluation
|
|
85
|
-
let customOp = null;
|
|
86
85
|
const evaluator = evalBindingExpressionTree;
|
|
87
|
-
// --- Reset the expression scope
|
|
88
|
-
expr.valueScope = expr.valueIndex = undefined;
|
|
89
86
|
// --- Process the expression according to its type
|
|
90
87
|
switch (expr.type) {
|
|
91
|
-
case
|
|
88
|
+
case ScriptingSourceTreeExp_1.T_TEMPLATE_LITERAL_EXPRESSION:
|
|
92
89
|
return evalTemplateLiteral(evaluator, thisStack, expr, evalContext, thread);
|
|
93
|
-
case
|
|
94
|
-
return (0, eval_tree_common_1.evalLiteral)(thisStack, expr);
|
|
95
|
-
case
|
|
90
|
+
case ScriptingSourceTreeExp_1.T_LITERAL:
|
|
91
|
+
return (0, eval_tree_common_1.evalLiteral)(thisStack, expr, thread);
|
|
92
|
+
case ScriptingSourceTreeExp_1.T_IDENTIFIER:
|
|
96
93
|
return (0, eval_tree_common_1.evalIdentifier)(thisStack, expr, evalContext, thread);
|
|
97
|
-
case
|
|
94
|
+
case ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION:
|
|
98
95
|
return evalMemberAccess(evaluator, thisStack, expr, evalContext, thread);
|
|
99
|
-
case
|
|
96
|
+
case ScriptingSourceTreeExp_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
|
|
100
97
|
return evalCalculatedMemberAccess(evaluator, thisStack, expr, evalContext, thread);
|
|
101
|
-
case
|
|
98
|
+
case ScriptingSourceTreeExp_1.T_SEQUENCE_EXPRESSION:
|
|
102
99
|
return evalSequence(evaluator, thisStack, expr, evalContext, thread);
|
|
103
|
-
case
|
|
100
|
+
case ScriptingSourceTreeExp_1.T_ARRAY_LITERAL:
|
|
104
101
|
return evalArrayLiteral(evaluator, thisStack, expr, evalContext, thread);
|
|
105
|
-
case
|
|
102
|
+
case ScriptingSourceTreeExp_1.T_OBJECT_LITERAL:
|
|
106
103
|
return evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread);
|
|
107
|
-
case
|
|
108
|
-
return evalUnary(evaluator, thisStack,
|
|
109
|
-
case
|
|
110
|
-
return evalBinary(evaluator, thisStack,
|
|
111
|
-
case
|
|
104
|
+
case ScriptingSourceTreeExp_1.T_UNARY_EXPRESSION:
|
|
105
|
+
return evalUnary(evaluator, thisStack, expr, evalContext, thread);
|
|
106
|
+
case ScriptingSourceTreeExp_1.T_BINARY_EXPRESSION:
|
|
107
|
+
return evalBinary(evaluator, thisStack, expr, evalContext, thread);
|
|
108
|
+
case ScriptingSourceTreeExp_1.T_CONDITIONAL_EXPRESSION:
|
|
112
109
|
return evalConditional(evaluator, thisStack, expr, evalContext, thread);
|
|
113
|
-
case
|
|
110
|
+
case ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION:
|
|
114
111
|
return evalAssignment(evaluator, thisStack, expr, evalContext, thread);
|
|
115
|
-
case
|
|
116
|
-
case
|
|
112
|
+
case ScriptingSourceTreeExp_1.T_PREFIX_OP_EXPRESSION:
|
|
113
|
+
case ScriptingSourceTreeExp_1.T_POSTFIX_OP_EXPRESSION:
|
|
117
114
|
return evalPreOrPost(evaluator, thisStack, expr, evalContext, thread);
|
|
118
|
-
case
|
|
115
|
+
case ScriptingSourceTreeExp_1.T_FUNCTION_INVOCATION_EXPRESSION:
|
|
119
116
|
// --- Special sync handling
|
|
120
117
|
const funcResult = evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread);
|
|
121
118
|
if ((0, eval_tree_common_1.isPromise)(funcResult)) {
|
|
122
119
|
throw new Error("Promises (async function calls) are not allowed in binding expressions.");
|
|
123
120
|
}
|
|
124
121
|
return funcResult;
|
|
125
|
-
case
|
|
122
|
+
case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION:
|
|
126
123
|
// --- Special sync handling
|
|
127
124
|
return (0, eval_tree_common_1.evalArrow)(thisStack, expr, thread);
|
|
128
|
-
case
|
|
125
|
+
case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION:
|
|
129
126
|
throw new Error("Cannot use spread expression (...) with the current intermediate value.");
|
|
130
127
|
default:
|
|
131
128
|
throw new Error(`Unknown expression tree node: ${expr.type}`);
|
|
@@ -140,56 +137,59 @@ function evalTemplateLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
|
140
137
|
return (0, eval_tree_common_1.evalTemplateLiteralCore)(segmentValues);
|
|
141
138
|
}
|
|
142
139
|
function evalMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
|
|
143
|
-
|
|
144
|
-
return (0, eval_tree_common_1.evalMemberAccessCore)(parentObj, thisStack, expr, evalContext);
|
|
145
|
-
}
|
|
146
|
-
function evalCalculatedMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
|
|
147
|
-
const parentObj = evaluator(thisStack, expr.object, evalContext, thread);
|
|
140
|
+
evaluator(thisStack, expr.obj, evalContext, thread);
|
|
148
141
|
// --- At this point we definitely keep the parent object on `thisStack`, as it will be the context object
|
|
149
142
|
// --- of a FunctionInvocationExpression, if that follows the MemberAccess. Other operations would call
|
|
150
143
|
// --- `thisStack.pop()` to remove the result from the previous `evalBindingExpressionTree` call.
|
|
151
|
-
|
|
144
|
+
return (0, eval_tree_common_1.evalMemberAccessCore)(thisStack, expr, evalContext, thread);
|
|
145
|
+
}
|
|
146
|
+
function evalCalculatedMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
|
|
147
|
+
evaluator(thisStack, expr.obj, evalContext, thread);
|
|
148
|
+
evaluator(thisStack, expr.member, evalContext, thread);
|
|
152
149
|
thisStack.pop();
|
|
153
|
-
return (0, eval_tree_common_1.evalCalculatedMemberAccessCore)(
|
|
150
|
+
return (0, eval_tree_common_1.evalCalculatedMemberAccessCore)(thisStack, expr, evalContext, thread);
|
|
154
151
|
}
|
|
155
152
|
function evalSequence(evaluator, thisStack, expr, evalContext, thread) {
|
|
156
|
-
if (!expr.
|
|
153
|
+
if (!expr.exprs || expr.exprs.length === 0) {
|
|
157
154
|
throw new Error(`Missing expression sequence`);
|
|
158
155
|
}
|
|
159
|
-
const result = expr.
|
|
160
|
-
const
|
|
156
|
+
const result = expr.exprs.map((e) => {
|
|
157
|
+
const value = evaluator(thisStack, e, evalContext, thread);
|
|
158
|
+
(0, eval_tree_common_1.setExprValue)(e, { value }, thread);
|
|
161
159
|
thisStack.pop();
|
|
162
|
-
return
|
|
160
|
+
return value;
|
|
163
161
|
});
|
|
164
162
|
const lastObj = result[result.length - 1];
|
|
165
163
|
thisStack.push(lastObj);
|
|
166
164
|
return lastObj;
|
|
167
165
|
}
|
|
168
166
|
function evalArrayLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
169
|
-
const
|
|
167
|
+
const value = [];
|
|
170
168
|
for (const item of expr.items) {
|
|
171
|
-
if (item.type ===
|
|
172
|
-
const spreadArray = evaluator(thisStack, item.
|
|
169
|
+
if (item.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
|
|
170
|
+
const spreadArray = evaluator(thisStack, item.expr, evalContext, thread);
|
|
173
171
|
thisStack.pop();
|
|
174
172
|
if (!Array.isArray(spreadArray)) {
|
|
175
173
|
throw new Error("Spread operator within an array literal expects an array operand.");
|
|
176
174
|
}
|
|
177
|
-
|
|
175
|
+
value.push(...spreadArray);
|
|
178
176
|
}
|
|
179
177
|
else {
|
|
180
|
-
|
|
178
|
+
value.push(evaluator(thisStack, item, evalContext, thread));
|
|
181
179
|
thisStack.pop();
|
|
182
|
-
thisStack.push(
|
|
180
|
+
thisStack.push(value);
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
|
-
|
|
183
|
+
// --- Done.
|
|
184
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
|
|
185
|
+
return value;
|
|
186
186
|
}
|
|
187
187
|
function evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
188
188
|
const objectHash = {};
|
|
189
189
|
for (const prop of expr.props) {
|
|
190
190
|
if (!Array.isArray(prop)) {
|
|
191
191
|
// --- We're using a spread expression
|
|
192
|
-
const spreadItems = evaluator(thisStack, prop.
|
|
192
|
+
const spreadItems = evaluator(thisStack, prop.expr, evalContext, thread);
|
|
193
193
|
thisStack.pop();
|
|
194
194
|
if (Array.isArray(spreadItems)) {
|
|
195
195
|
// --- Spread of an array
|
|
@@ -208,10 +208,10 @@ function evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
|
208
208
|
// --- We're using key/[value] pairs
|
|
209
209
|
let key;
|
|
210
210
|
switch (prop[0].type) {
|
|
211
|
-
case
|
|
211
|
+
case ScriptingSourceTreeExp_1.T_LITERAL:
|
|
212
212
|
key = prop[0].value;
|
|
213
213
|
break;
|
|
214
|
-
case
|
|
214
|
+
case ScriptingSourceTreeExp_1.T_IDENTIFIER:
|
|
215
215
|
key = prop[0].name;
|
|
216
216
|
break;
|
|
217
217
|
default:
|
|
@@ -222,63 +222,86 @@ function evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
|
222
222
|
objectHash[key] = evaluator(thisStack, prop[1], evalContext, thread);
|
|
223
223
|
thisStack.pop();
|
|
224
224
|
}
|
|
225
|
+
// --- Done.
|
|
226
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value: objectHash }, thread);
|
|
225
227
|
thisStack.push(objectHash);
|
|
226
228
|
return objectHash;
|
|
227
229
|
}
|
|
228
|
-
function evalUnary(evaluator, thisStack,
|
|
229
|
-
|
|
230
|
+
function evalUnary(evaluator, thisStack, expr, evalContext, thread) {
|
|
231
|
+
evaluator(thisStack, expr.expr, evalContext, thread);
|
|
230
232
|
thisStack.pop();
|
|
231
|
-
return (0, eval_tree_common_1.evalUnaryCore)(expr,
|
|
233
|
+
return (0, eval_tree_common_1.evalUnaryCore)(expr, thisStack, evalContext, thread);
|
|
232
234
|
}
|
|
233
|
-
function evalBinary(evaluator, thisStack,
|
|
234
|
-
|
|
235
|
+
function evalBinary(evaluator, thisStack, expr, evalContext, thread) {
|
|
236
|
+
var _a;
|
|
237
|
+
evaluator(thisStack, expr.left, evalContext, thread);
|
|
235
238
|
thisStack.pop();
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
const l = (_a = (0, eval_tree_common_1.getExprValue)(expr.left, thread)) === null || _a === void 0 ? void 0 : _a.value;
|
|
240
|
+
if (expr.op === "&&" && !l) {
|
|
241
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value: l }, thread);
|
|
238
242
|
return l;
|
|
239
243
|
}
|
|
240
|
-
if (expr.
|
|
241
|
-
|
|
244
|
+
if (expr.op === "||" && l) {
|
|
245
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value: l }, thread);
|
|
242
246
|
return l;
|
|
243
247
|
}
|
|
244
|
-
|
|
248
|
+
evaluator(thisStack, expr.right, evalContext, thread);
|
|
245
249
|
thisStack.pop();
|
|
246
|
-
return (0, eval_tree_common_1.evalBinaryCore)(
|
|
250
|
+
return (0, eval_tree_common_1.evalBinaryCore)(expr, thisStack, evalContext, thread);
|
|
247
251
|
}
|
|
248
252
|
function evalConditional(evaluator, thisStack, expr, evalContext, thread) {
|
|
249
|
-
const condition = evaluator(thisStack, expr.
|
|
253
|
+
const condition = evaluator(thisStack, expr.cond, evalContext, thread);
|
|
250
254
|
thisStack.pop();
|
|
251
|
-
|
|
255
|
+
const value = evaluator(thisStack, condition ? expr.thenE : expr.elseE, evalContext, thread);
|
|
256
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
|
|
257
|
+
return value;
|
|
252
258
|
}
|
|
253
259
|
function evalAssignment(evaluator, thisStack, expr, evalContext, thread) {
|
|
254
260
|
const leftValue = expr.leftValue;
|
|
261
|
+
const rootScope = (0, eval_tree_common_1.getRootIdScope)(leftValue, evalContext, thread);
|
|
262
|
+
const updatesState = rootScope && rootScope.type !== "block";
|
|
263
|
+
if (updatesState && evalContext.onWillUpdate) {
|
|
264
|
+
evalContext.onWillUpdate(rootScope, rootScope.name, "assignment");
|
|
265
|
+
}
|
|
255
266
|
evaluator(thisStack, leftValue, evalContext, thread);
|
|
256
267
|
thisStack.pop();
|
|
257
|
-
|
|
268
|
+
evaluator(thisStack, expr.expr, evalContext, thread);
|
|
258
269
|
thisStack.pop();
|
|
259
|
-
|
|
270
|
+
const value = (0, eval_tree_common_1.evalAssignmentCore)(thisStack, expr, evalContext, thread);
|
|
271
|
+
if (updatesState && evalContext.onDidUpdate) {
|
|
272
|
+
evalContext.onDidUpdate(rootScope, rootScope.name, "assignment");
|
|
273
|
+
}
|
|
274
|
+
return value;
|
|
260
275
|
}
|
|
261
276
|
function evalPreOrPost(evaluator, thisStack, expr, evalContext, thread) {
|
|
262
|
-
const
|
|
263
|
-
|
|
277
|
+
const rootScope = (0, eval_tree_common_1.getRootIdScope)(expr.expr, evalContext, thread);
|
|
278
|
+
const updatesState = rootScope && rootScope.type !== "block";
|
|
279
|
+
if (updatesState && evalContext.onWillUpdate) {
|
|
280
|
+
evalContext.onWillUpdate(rootScope, rootScope.name, "pre-post");
|
|
281
|
+
}
|
|
282
|
+
evaluator(thisStack, expr.expr, evalContext, thread);
|
|
264
283
|
thisStack.pop();
|
|
265
|
-
|
|
284
|
+
const value = (0, eval_tree_common_1.evalPreOrPostCore)(thisStack, expr, evalContext, thread);
|
|
285
|
+
if (updatesState && evalContext.onDidUpdate) {
|
|
286
|
+
evalContext.onDidUpdate(rootScope, rootScope.name, "pre-post");
|
|
287
|
+
}
|
|
288
|
+
return value;
|
|
266
289
|
}
|
|
267
290
|
function evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread) {
|
|
268
291
|
var _a, _b, _c, _d;
|
|
269
292
|
let functionObj;
|
|
270
293
|
let implicitContextObject = null;
|
|
271
294
|
// --- Check for contexted object
|
|
272
|
-
if (expr.
|
|
273
|
-
const hostObject = evaluator(thisStack, expr.
|
|
274
|
-
functionObj = (0, eval_tree_common_1.evalMemberAccessCore)(
|
|
295
|
+
if (expr.obj.type === ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION && expr.obj.obj.type === ScriptingSourceTreeExp_1.T_IDENTIFIER) {
|
|
296
|
+
const hostObject = evaluator(thisStack, expr.obj.obj, evalContext, thread);
|
|
297
|
+
functionObj = (0, eval_tree_common_1.evalMemberAccessCore)(thisStack, expr.obj, evalContext, thread);
|
|
275
298
|
if (hostObject === null || hostObject === void 0 ? void 0 : hostObject._SUPPORT_IMPLICIT_CONTEXT) {
|
|
276
299
|
implicitContextObject = hostObject;
|
|
277
300
|
}
|
|
278
301
|
}
|
|
279
302
|
else {
|
|
280
303
|
// --- Get the object on which to invoke the function
|
|
281
|
-
functionObj = evaluator(thisStack, expr.
|
|
304
|
+
functionObj = evaluator(thisStack, expr.obj, evalContext, thread);
|
|
282
305
|
}
|
|
283
306
|
thisStack.pop();
|
|
284
307
|
// --- Keep function arguments here, we pass it to the function later
|
|
@@ -286,34 +309,34 @@ function evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread)
|
|
|
286
309
|
// --- The functionObj may be an ArrowExpression. In this care we need to create the invokable arrow function
|
|
287
310
|
if (functionObj === null || functionObj === void 0 ? void 0 : functionObj._ARROW_EXPR_) {
|
|
288
311
|
functionArgs.push(functionObj.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
|
|
289
|
-
functionObj = createArrowFunction(evaluator, functionObj);
|
|
312
|
+
functionObj = createArrowFunction(evaluator, functionObj, evalContext);
|
|
290
313
|
}
|
|
291
|
-
else if (expr.
|
|
314
|
+
else if (expr.obj.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
|
|
292
315
|
// --- We delay evaluating expression values. We pass the argument names as the first parameter, and then
|
|
293
316
|
// --- all parameter expressions
|
|
294
|
-
functionArgs.push(expr.
|
|
317
|
+
functionArgs.push(expr.obj.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
|
|
295
318
|
}
|
|
296
319
|
else {
|
|
297
320
|
// --- We evaluate the argument values to pass to a JavaScript function
|
|
298
321
|
for (let i = 0; i < expr.arguments.length; i++) {
|
|
299
322
|
const arg = expr.arguments[i];
|
|
300
|
-
if (arg.type ===
|
|
301
|
-
const funcArg = evaluator([], arg.
|
|
323
|
+
if (arg.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
|
|
324
|
+
const funcArg = evaluator([], arg.expr, evalContext, thread);
|
|
302
325
|
if (!Array.isArray(funcArg)) {
|
|
303
326
|
throw new Error("Spread operator within a function invocation expects an array operand.");
|
|
304
327
|
}
|
|
305
328
|
functionArgs.push(...funcArg);
|
|
306
329
|
}
|
|
307
330
|
else {
|
|
308
|
-
if (arg.type ===
|
|
309
|
-
const funcArg = createArrowFunction(evaluator, arg);
|
|
331
|
+
if (arg.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
|
|
332
|
+
const funcArg = createArrowFunction(evaluator, arg, evalContext);
|
|
310
333
|
const wrappedFunc = (...args) => funcArg(arg.args, evalContext, thread, ...args);
|
|
311
334
|
functionArgs.push(wrappedFunc);
|
|
312
335
|
}
|
|
313
336
|
else {
|
|
314
337
|
const funcArg = evaluator([], arg, evalContext, thread);
|
|
315
338
|
if (funcArg === null || funcArg === void 0 ? void 0 : funcArg._ARROW_EXPR_) {
|
|
316
|
-
const wrappedFuncArg = createArrowFunction(evaluator, funcArg);
|
|
339
|
+
const wrappedFuncArg = createArrowFunction(evaluator, funcArg, evalContext);
|
|
317
340
|
const wrappedFunc = (...args) => wrappedFuncArg(funcArg.args, evalContext, thread, ...args);
|
|
318
341
|
functionArgs.push(wrappedFunc);
|
|
319
342
|
}
|
|
@@ -342,17 +365,23 @@ function evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread)
|
|
|
342
365
|
}
|
|
343
366
|
// --- We use context for "this"
|
|
344
367
|
const currentContext = thisStack.length > 0 ? thisStack.pop() : evalContext.localContext;
|
|
345
|
-
// --- We need to use proxies for JavaScript functions (such as Array.prototype.sort) using
|
|
346
|
-
// --- in-place changes on DataSource values
|
|
347
|
-
functionObj = (0, syncProxy_1.getSyncProxy)(functionObj, functionArgs, currentContext);
|
|
348
368
|
// --- Now, invoke the function
|
|
369
|
+
const rootScope = (0, eval_tree_common_1.getRootIdScope)(expr.obj, evalContext, thread);
|
|
370
|
+
const updatesState = rootScope && rootScope.type !== "block";
|
|
371
|
+
if (updatesState && evalContext.onWillUpdate) {
|
|
372
|
+
evalContext.onWillUpdate(rootScope, rootScope.name, "function-call");
|
|
373
|
+
}
|
|
349
374
|
const value = ((_d = evalContext.options) === null || _d === void 0 ? void 0 : _d.defaultToOptionalMemberAccess)
|
|
350
375
|
? functionObj === null || functionObj === void 0 ? void 0 : functionObj.call(currentContext, ...functionArgs)
|
|
351
376
|
: functionObj.call(currentContext, ...functionArgs);
|
|
377
|
+
if (updatesState && evalContext.onDidUpdate) {
|
|
378
|
+
evalContext.onDidUpdate(rootScope, rootScope.name, "function-call");
|
|
379
|
+
}
|
|
380
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
|
|
352
381
|
thisStack.push(value);
|
|
353
382
|
return value;
|
|
354
383
|
}
|
|
355
|
-
function createArrowFunction(evaluator, expr) {
|
|
384
|
+
function createArrowFunction(evaluator, expr, evalContext) {
|
|
356
385
|
// --- Use this function, it evaluates the arrow function
|
|
357
386
|
return (...args) => {
|
|
358
387
|
var _a, _b;
|
|
@@ -388,32 +417,31 @@ function createArrowFunction(evaluator, expr) {
|
|
|
388
417
|
const argSpec = argSpecs[i];
|
|
389
418
|
let decl;
|
|
390
419
|
switch (argSpec.type) {
|
|
391
|
-
case
|
|
420
|
+
case ScriptingSourceTreeExp_1.T_IDENTIFIER: {
|
|
392
421
|
decl = {
|
|
393
|
-
type:
|
|
422
|
+
type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
|
|
394
423
|
id: argSpec.name,
|
|
395
424
|
};
|
|
396
425
|
break;
|
|
397
426
|
}
|
|
398
|
-
case
|
|
427
|
+
case ScriptingSourceTreeExp_1.T_DESTRUCTURE: {
|
|
399
428
|
decl = {
|
|
400
|
-
type:
|
|
429
|
+
type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
|
|
401
430
|
id: argSpec.id,
|
|
402
|
-
|
|
403
|
-
|
|
431
|
+
aDestr: argSpec.aDestr,
|
|
432
|
+
oDestr: argSpec.oDestr,
|
|
404
433
|
};
|
|
405
434
|
break;
|
|
406
435
|
}
|
|
407
|
-
case
|
|
436
|
+
case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION: {
|
|
408
437
|
restFound = true;
|
|
409
438
|
decl = {
|
|
410
|
-
type:
|
|
411
|
-
id: argSpec.
|
|
439
|
+
type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
|
|
440
|
+
id: argSpec.expr.name,
|
|
412
441
|
};
|
|
413
442
|
break;
|
|
414
443
|
}
|
|
415
444
|
default:
|
|
416
|
-
console.log(argSpec);
|
|
417
445
|
throw new Error("Unexpected arrow argument specification");
|
|
418
446
|
}
|
|
419
447
|
if (decl) {
|
|
@@ -445,21 +473,22 @@ function createArrowFunction(evaluator, expr) {
|
|
|
445
473
|
let returnValue;
|
|
446
474
|
let statements;
|
|
447
475
|
switch (expr.statement.type) {
|
|
448
|
-
case
|
|
476
|
+
case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
|
|
449
477
|
statements = [];
|
|
450
478
|
break;
|
|
451
|
-
case
|
|
479
|
+
case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
|
|
452
480
|
// --- Create a new thread for the call
|
|
453
481
|
statements = [
|
|
454
482
|
{
|
|
455
|
-
type:
|
|
456
|
-
|
|
483
|
+
type: ScriptingSourceTreeExp_1.T_RETURN_STATEMENT,
|
|
484
|
+
nodeId: (0, Parser_1.createXmlUiTreeNodeId)(),
|
|
485
|
+
expr: expr.statement.expr,
|
|
457
486
|
},
|
|
458
487
|
];
|
|
459
488
|
break;
|
|
460
|
-
case
|
|
489
|
+
case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
|
|
461
490
|
// --- Create a new thread for the call
|
|
462
|
-
statements = expr.statement.
|
|
491
|
+
statements = expr.statement.stmts;
|
|
463
492
|
break;
|
|
464
493
|
default:
|
|
465
494
|
throw new Error(`Arrow expression with a body of '${expr.statement.type}' is not supported yet.`);
|