xmlui 0.9.1 → 0.9.3

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 (57) hide show
  1. package/dist/{apiInterceptorWorker-230V_-Ds.mjs → apiInterceptorWorker-Y5MxQ95G.mjs} +1 -1
  2. package/dist/{core-XLM8cuFP.mjs → core-DowI-7YH.mjs} +2 -52
  3. package/dist/{index-DUwwx3L4.mjs → index-DHAz4bv_.mjs} +14904 -1512
  4. package/dist/index.css +309 -233
  5. package/dist/scripts/bin/vite-xmlui-plugin.js +1 -1
  6. package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +48 -0
  7. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +11 -1
  8. package/dist/scripts/src/components/Markdown/Markdown.js +17 -13
  9. package/dist/scripts/src/components/Markdown/MarkdownNative.js +40 -21
  10. package/dist/scripts/src/components/Slider/Slider.js +25 -6
  11. package/dist/scripts/src/components/Slider/SliderNative.js +78 -18
  12. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
  13. package/dist/scripts/src/components-core/InspectorContext.js +1 -1
  14. package/dist/scripts/src/components-core/RestApiProxy.js +21 -11
  15. package/dist/scripts/src/components-core/{DevTools.js → devtools/DevTools.js} +71 -10
  16. package/dist/scripts/src/components-core/rendering/Container.js +3 -3
  17. package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -3
  18. package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
  19. package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +37 -37
  20. package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +8 -8
  21. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +37 -37
  22. package/dist/scripts/src/components-core/script-runner/process-statement-async.js +29 -29
  23. package/dist/scripts/src/components-core/script-runner/process-statement-common.js +5 -5
  24. package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +29 -29
  25. package/dist/scripts/src/components-core/script-runner/visitors.js +47 -47
  26. package/dist/scripts/src/components-core/theming/ThemeProvider.js +2 -2
  27. package/dist/scripts/src/components-core/theming/themes/root.js +1 -1
  28. package/dist/scripts/src/components-core/utils/statementUtils.js +32 -32
  29. package/dist/scripts/src/parsers/scripting/Lexer.js +166 -178
  30. package/dist/scripts/src/parsers/scripting/Parser.js +555 -701
  31. package/dist/scripts/src/parsers/scripting/ParserError.js +3 -3
  32. package/dist/scripts/src/parsers/scripting/TokenTrait.js +103 -105
  33. package/dist/scripts/src/parsers/{scripting-exp → scripting}/code-behind-collect.js +4 -4
  34. package/dist/scripts/src/parsers/{scripting-exp → scripting}/modules.js +2 -2
  35. package/dist/scripts/src/parsers/{scripting-exp → scripting}/tree-visitor.js +45 -45
  36. package/dist/scripts/src/parsers/xmlui-parser/transform.js +2 -2
  37. package/dist/scripts/src/syntax/monaco/grammar.monacoLanguage.js +286 -0
  38. package/dist/scripts/src/syntax/monaco/xmlui-dark.js +27 -0
  39. package/dist/scripts/src/syntax/monaco/xmlui-light.js +26 -0
  40. package/dist/scripts/src/syntax/monaco/xmluiscript.monacoLanguage.js +310 -0
  41. package/dist/style.css +222 -152
  42. package/dist/xmlui-metadata.mjs +307 -478
  43. package/dist/xmlui-metadata.umd.js +309 -477
  44. package/dist/xmlui-parser.d.ts +1 -11
  45. package/dist/xmlui-standalone.umd.js +34047 -29191
  46. package/dist/xmlui.d.ts +2 -75
  47. package/dist/xmlui.mjs +10 -10
  48. package/package.json +5 -6
  49. package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +0 -50
  50. package/dist/scripts/src/abstractions/scripting/Token.js +0 -112
  51. package/dist/scripts/src/components-core/theming/abstractions.js +0 -11
  52. package/dist/scripts/src/parsers/scripting-exp/Lexer.js +0 -1092
  53. package/dist/scripts/src/parsers/scripting-exp/Parser.js +0 -2635
  54. package/dist/scripts/src/parsers/scripting-exp/ParserError.js +0 -47
  55. package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +0 -109
  56. /package/dist/scripts/src/abstractions/scripting/{LogicalThreadExp.js → LogicalThread.js} +0 -0
  57. /package/dist/scripts/src/parsers/{scripting-exp → scripting}/TokenType.js +0 -0
@@ -41,27 +41,39 @@ const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  const react_1 = require("react");
42
42
  const react_2 = require("react");
43
43
  const react_rnd_1 = require("react-rnd");
44
- const XmluiCodeHighlighter_1 = require("./XmluiCodeHighlighter");
45
- const ThemeContext_1 = require("./theming/ThemeContext");
44
+ const ThemeContext_1 = require("../theming/ThemeContext");
46
45
  const react_dom_1 = require("react-dom");
47
- const InspectorContext_1 = require("./InspectorContext");
48
- const ButtonNative_1 = require("../components/Button/ButtonNative");
46
+ const InspectorContext_1 = require("../InspectorContext");
47
+ const ButtonNative_1 = require("../../components/Button/ButtonNative");
49
48
  const DevTools_module_scss_1 = __importDefault(require("./DevTools.module.scss"));
50
49
  const react_tabs_1 = require("@radix-ui/react-tabs");
51
50
  const bi_1 = require("react-icons/bi");
52
51
  const DropdownMenu = __importStar(require("@radix-ui/react-dropdown-menu"));
53
- const all_1 = require("react-icons/all");
52
+ const hi_1 = require("react-icons/hi");
54
53
  const hi2_1 = require("react-icons/hi2");
55
- const IconNative_1 = __importDefault(require("../components/Icon/IconNative"));
54
+ const IconNative_1 = __importDefault(require("../../components/Icon/IconNative"));
55
+ const loader_1 = __importDefault(require("@monaco-editor/loader"));
56
+ const grammar_monacoLanguage_1 = require("../../syntax/monaco/grammar.monacoLanguage");
57
+ const xmluiscript_monacoLanguage_1 = require("../../syntax/monaco/xmluiscript.monacoLanguage");
58
+ const xmlui_light_1 = __importDefault(require("../../syntax/monaco/xmlui-light"));
59
+ const xmlui_dark_1 = __importDefault(require("../../syntax/monaco/xmlui-dark"));
56
60
  const DevTools = ({ setIsOpen, node }) => {
57
61
  var _a;
58
62
  const [side, setSide] = (0, react_2.useState)("bottom");
59
- const { root } = (0, ThemeContext_1.useTheme)();
63
+ const { root, activeThemeTone } = (0, ThemeContext_1.useTheme)();
60
64
  const { setDevToolsSize, setDevToolsSide } = (0, InspectorContext_1.useDevTools)();
61
65
  const [copied, setCopied] = (0, react_2.useState)(false);
66
+ const monacoEditorInstance = (0, react_1.useRef)(null);
67
+ const editorRef = (0, react_1.useRef)(null);
68
+ const [activeTab, setActiveTab] = (0, react_2.useState)("code");
69
+ const monacoSetupDone = (0, react_1.useRef)(false);
62
70
  const copyToClipboard = () => {
71
+ var _a;
63
72
  setCopied(true);
64
- navigator.clipboard.writeText(value);
73
+ if (monacoEditorInstance === null || monacoEditorInstance === void 0 ? void 0 : monacoEditorInstance.current) {
74
+ const code = (_a = monacoEditorInstance === null || monacoEditorInstance === void 0 ? void 0 : monacoEditorInstance.current) === null || _a === void 0 ? void 0 : _a.getValue();
75
+ navigator.clipboard.writeText(code);
76
+ }
65
77
  };
66
78
  const { sources } = (0, react_1.useContext)(InspectorContext_1.InspectorContext);
67
79
  const value = (0, react_1.useMemo)(() => {
@@ -95,6 +107,50 @@ const DevTools = ({ setIsOpen, node }) => {
95
107
  });
96
108
  return prunedLines.map((line) => line.slice(trimBeginCount)).join("\n");
97
109
  }, [(_a = node.debug) === null || _a === void 0 ? void 0 : _a.source, sources]);
110
+ (0, react_1.useEffect)(() => {
111
+ if (activeTab === "code") {
112
+ if (monacoEditorInstance.current) {
113
+ monacoEditorInstance.current.layout();
114
+ }
115
+ else if (editorRef.current) {
116
+ loader_1.default.init().then((monaco) => {
117
+ if (!editorRef.current || monacoEditorInstance.current)
118
+ return;
119
+ if (!monacoSetupDone.current) {
120
+ monaco.languages.register({ id: grammar_monacoLanguage_1.XmluiGrammar.id });
121
+ monaco.languages.setMonarchTokensProvider(grammar_monacoLanguage_1.XmluiGrammar.id, grammar_monacoLanguage_1.XmluiGrammar.language);
122
+ monaco.languages.setLanguageConfiguration(grammar_monacoLanguage_1.XmluiGrammar.id, grammar_monacoLanguage_1.XmluiGrammar.config);
123
+ monaco.languages.register({ id: xmluiscript_monacoLanguage_1.XmluiScripGrammar.id });
124
+ monaco.languages.setMonarchTokensProvider(xmluiscript_monacoLanguage_1.XmluiScripGrammar.id, xmluiscript_monacoLanguage_1.XmluiScripGrammar.language);
125
+ monaco.languages.setLanguageConfiguration(xmluiscript_monacoLanguage_1.XmluiScripGrammar.id, xmluiscript_monacoLanguage_1.XmluiScripGrammar.config);
126
+ monaco.editor.defineTheme("xmlui-light", xmlui_light_1.default);
127
+ monaco.editor.defineTheme("xmlui-dark", xmlui_dark_1.default);
128
+ monacoSetupDone.current = true;
129
+ }
130
+ monaco.editor.setTheme(activeThemeTone === "dark" ? "xmlui-dark" : "xmlui-light");
131
+ monacoEditorInstance.current = monaco.editor.create(editorRef.current, {
132
+ value,
133
+ language: "xmlui",
134
+ readOnly: true,
135
+ scrollBeyondLastLine: false,
136
+ overviewRulerLanes: 0,
137
+ hideCursorInOverviewRuler: true,
138
+ minimap: { enabled: false },
139
+ padding: {
140
+ top: 10,
141
+ bottom: 10
142
+ }
143
+ });
144
+ });
145
+ }
146
+ }
147
+ return () => {
148
+ if (monacoEditorInstance.current) {
149
+ monacoEditorInstance.current.dispose();
150
+ monacoEditorInstance.current = null;
151
+ }
152
+ };
153
+ }, [activeTab, activeThemeTone, value]);
98
154
  const getInitialSize = (0, react_1.useCallback)(() => {
99
155
  switch (side) {
100
156
  case "bottom":
@@ -120,6 +176,11 @@ const DevTools = ({ setIsOpen, node }) => {
120
176
  }, [side]);
121
177
  const [size, setSize] = (0, react_2.useState)(getInitialSize());
122
178
  const [position, setPosition] = (0, react_2.useState)(getInitialPosition());
179
+ (0, react_1.useEffect)(() => {
180
+ if ((monacoEditorInstance === null || monacoEditorInstance === void 0 ? void 0 : monacoEditorInstance.current) && activeTab === "code") {
181
+ monacoEditorInstance.current.layout();
182
+ }
183
+ }, [activeTab, size, position]);
123
184
  (0, react_1.useEffect)(() => {
124
185
  const handleResize = () => {
125
186
  setSize(getInitialSize());
@@ -153,12 +214,12 @@ const DevTools = ({ setIsOpen, node }) => {
153
214
  height: ref.offsetHeight,
154
215
  });
155
216
  setPosition(position);
156
- }, bounds: "window", children: (0, jsx_runtime_1.jsxs)(react_tabs_1.Root, { defaultValue: "code", className: DevTools_module_scss_1.default.tabs, style: { width: "100%", height: "100%" }, children: [(0, jsx_runtime_1.jsxs)(react_tabs_1.List, { className: DevTools_module_scss_1.default.list, children: [(0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.tabItems, children: [(0, jsx_runtime_1.jsx)(react_tabs_1.Trigger, { value: "code", children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "sm", children: "Code" }) }), (0, jsx_runtime_1.jsx)(react_tabs_1.Trigger, { value: "console", children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "sm", children: "Console" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.actions, children: [(0, jsx_runtime_1.jsxs)(DropdownMenu.Root, { children: [(0, jsx_runtime_1.jsx)(DropdownMenu.Trigger, { children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "xs", children: (0, jsx_runtime_1.jsx)(all_1.HiOutlineDotsVertical, { color: "currentColor" }) }) }), (0, jsx_runtime_1.jsx)(DropdownMenu.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(DropdownMenu.Content, { className: DevTools_module_scss_1.default.menu, children: (0, jsx_runtime_1.jsxs)(DropdownMenu.Item, { className: DevTools_module_scss_1.default.menuItem, children: ["Dock side", (0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.sideButtons, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { style: { padding: 8 }, onClick: () => {
217
+ }, bounds: "window", children: (0, jsx_runtime_1.jsxs)(react_tabs_1.Root, { defaultValue: "code", className: DevTools_module_scss_1.default.tabs, style: { width: "100%", height: "100%" }, onValueChange: setActiveTab, children: [(0, jsx_runtime_1.jsxs)(react_tabs_1.List, { className: DevTools_module_scss_1.default.list, children: [(0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.tabItems, children: [(0, jsx_runtime_1.jsx)(react_tabs_1.Trigger, { value: "code", children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "sm", children: "Code" }) }), (0, jsx_runtime_1.jsx)(react_tabs_1.Trigger, { value: "console", children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "sm", children: "Console" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.actions, children: [(0, jsx_runtime_1.jsxs)(DropdownMenu.Root, { children: [(0, jsx_runtime_1.jsx)(DropdownMenu.Trigger, { children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", size: "xs", children: (0, jsx_runtime_1.jsx)(hi_1.HiOutlineDotsVertical, { color: "currentColor" }) }) }), (0, jsx_runtime_1.jsx)(DropdownMenu.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(DropdownMenu.Content, { className: DevTools_module_scss_1.default.menu, children: (0, jsx_runtime_1.jsxs)(DropdownMenu.Item, { className: DevTools_module_scss_1.default.menuItem, children: ["Dock side", (0, jsx_runtime_1.jsxs)("div", { className: DevTools_module_scss_1.default.sideButtons, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { style: { padding: 8 }, onClick: () => {
157
218
  setSide("left");
158
219
  }, variant: "ghost", children: (0, jsx_runtime_1.jsx)(bi_1.BiDockLeft, { color: "currentColor", size: 16 }) }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { style: { padding: 8 }, onClick: () => {
159
220
  setSide("bottom");
160
221
  }, variant: "ghost", children: (0, jsx_runtime_1.jsx)(bi_1.BiDockBottom, { color: "currentColor", size: 16 }) }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { style: { padding: 8 }, onClick: () => {
161
222
  setSide("right");
162
- }, variant: "ghost", children: (0, jsx_runtime_1.jsx)(bi_1.BiDockRight, { color: "currentColor", size: 16 }) })] })] }) }) })] }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => setIsOpen(false), size: "xs", variant: "ghost", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close" }) })] })] }), (0, jsx_runtime_1.jsxs)(react_tabs_1.Content, { value: "code", className: DevTools_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(XmluiCodeHighlighter_1.XmluiCodeHighlighter, { value: value }), (0, jsx_runtime_1.jsx)("div", { className: DevTools_module_scss_1.default.copyButton, children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: copyToClipboard, variant: "solid", themeColor: "secondary", style: { padding: 8 }, size: "sm", children: copied ? ((0, jsx_runtime_1.jsx)(hi2_1.HiOutlineClipboardDocumentCheck, { size: 16 })) : ((0, jsx_runtime_1.jsx)(hi2_1.HiOutlineClipboardDocument, { size: 16 })) }) })] }), (0, jsx_runtime_1.jsx)(react_tabs_1.Content, { value: "console", className: DevTools_module_scss_1.default.content, children: "Debug console" })] }) }), root);
223
+ }, variant: "ghost", children: (0, jsx_runtime_1.jsx)(bi_1.BiDockRight, { color: "currentColor", size: 16 }) })] })] }) }) })] }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => setIsOpen(false), size: "xs", variant: "ghost", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close" }) })] })] }), (0, jsx_runtime_1.jsxs)(react_tabs_1.Content, { value: "code", className: DevTools_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)("div", { ref: editorRef, className: DevTools_module_scss_1.default.xmluiEditor }), (0, jsx_runtime_1.jsx)("div", { className: DevTools_module_scss_1.default.copyButton, children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: copyToClipboard, variant: "solid", themeColor: "secondary", style: { padding: 8 }, size: "sm", children: copied ? ((0, jsx_runtime_1.jsx)(hi2_1.HiOutlineClipboardDocumentCheck, { size: 16 })) : ((0, jsx_runtime_1.jsx)(hi2_1.HiOutlineClipboardDocument, { size: 16 })) }) })] }), (0, jsx_runtime_1.jsx)(react_tabs_1.Content, { value: "console", className: DevTools_module_scss_1.default.content, children: "Debug console" })] }) }), root);
163
224
  };
164
225
  exports.DevTools = DevTools;
@@ -52,7 +52,7 @@ const react_2 = require("@remix-run/react");
52
52
  const lodash_es_1 = require("lodash-es");
53
53
  const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
54
54
  const memoize_one_1 = __importDefault(require("memoize-one"));
55
- const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
55
+ const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
56
56
  const containers_1 = require("../abstractions/containers");
57
57
  const AppContext_1 = require("../AppContext");
58
58
  const buildProxy_1 = require("../rendering/buildProxy");
@@ -163,7 +163,7 @@ exports.Container = (0, react_1.memo)((0, react_1.forwardRef)(function Container
163
163
  else {
164
164
  statements = [
165
165
  {
166
- type: ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION_STATEMENT,
166
+ type: ScriptingSourceTree_1.T_ARROW_EXPRESSION_STATEMENT,
167
167
  expr: source, //TODO illesg (talk it through why we need to deep clone, it it's omitted, it gets slower every time we run it)
168
168
  },
169
169
  ];
@@ -278,7 +278,7 @@ exports.Container = (0, react_1.memo)((0, react_1.forwardRef)(function Container
278
278
  };
279
279
  try {
280
280
  const arrowStmt = {
281
- type: ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION_STATEMENT,
281
+ type: ScriptingSourceTree_1.T_ARROW_EXPRESSION_STATEMENT,
282
282
  expr: arrowExpression,
283
283
  };
284
284
  (0, process_statement_sync_1.processStatementQueue)([arrowStmt], evalContext);
@@ -11,7 +11,7 @@ const lodash_es_1 = require("lodash-es");
11
11
  const memoize_one_1 = __importDefault(require("memoize-one"));
12
12
  const react_2 = require("@remix-run/react");
13
13
  const containers_1 = require("../abstractions/containers");
14
- const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
14
+ const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
15
15
  const constants_1 = require("../constants");
16
16
  const collectFnVarDeps_1 = require("../rendering/collectFnVarDeps");
17
17
  const reducer_1 = require("../rendering/reducer");
@@ -20,7 +20,7 @@ const ErrorBoundary_1 = require("../rendering/ErrorBoundary");
20
20
  const visitors_1 = require("../script-runner/visitors");
21
21
  const hooks_1 = require("../utils/hooks");
22
22
  const Container_1 = require("./Container");
23
- const code_behind_collect_1 = require("../../parsers/scripting-exp/code-behind-collect");
23
+ const code_behind_collect_1 = require("../../parsers/scripting/code-behind-collect");
24
24
  const AppContext_1 = require("../AppContext");
25
25
  const ParameterParser_1 = require("../script-runner/ParameterParser");
26
26
  const eval_tree_sync_1 = require("../script-runner/eval-tree-sync");
@@ -78,7 +78,7 @@ exports.StateContainer = (0, react_1.memo)((0, react_1.forwardRef)(function Stat
78
78
  const functionDeps = (0, react_1.useMemo)(() => {
79
79
  const fnDeps = {};
80
80
  Object.entries(varDefinitions).forEach(([key, value]) => {
81
- if (isParsedValue(value) && value.tree.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
81
+ if (isParsedValue(value) && value.tree.type === ScriptingSourceTree_1.T_ARROW_EXPRESSION) {
82
82
  fnDeps[key] = (0, visitors_1.collectVariableDependencies)(value.tree, referenceTrackedApi);
83
83
  }
84
84
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseParameterString = parseParameterString;
4
- const Parser_1 = require("../../parsers/scripting-exp/Parser");
4
+ const Parser_1 = require("../../parsers/scripting/Parser");
5
5
  /**
6
6
  * This function parses a parameter string and splits them into string literal and binding expression sections
7
7
  * @param source String to parse
@@ -13,7 +13,7 @@ exports.evalBindingAsync = evalBindingAsync;
13
13
  exports.executeArrowExpression = executeArrowExpression;
14
14
  exports.completeExprValue = completeExprValue;
15
15
  const lodash_es_1 = require("lodash-es");
16
- const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
16
+ const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
17
17
  const process_statement_async_1 = require("./process-statement-async");
18
18
  const eval_tree_common_1 = require("./eval-tree-common");
19
19
  const process_statement_common_1 = require("./process-statement-common");
@@ -47,7 +47,7 @@ function evalBindingAsync(expr, evalContext, thread) {
47
47
  function executeArrowExpression(expr, evalContext, thread, ...args) {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
49
  // --- Just an extra safety check
50
- if (expr.type !== ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
50
+ if (expr.type !== ScriptingSourceTree_1.T_ARROW_EXPRESSION) {
51
51
  throw new Error("executeArrowExpression expects an 'ArrowExpression' object.");
52
52
  }
53
53
  // --- This is the evaluator that an arrow expression uses internally
@@ -82,39 +82,39 @@ function evalBindingExpressionTreeAsync(thisStack, expr, evalContext, thread) {
82
82
  // --- Process the expression according to its type
83
83
  try {
84
84
  switch (expr.type) {
85
- case ScriptingSourceTreeExp_1.T_TEMPLATE_LITERAL_EXPRESSION:
85
+ case ScriptingSourceTree_1.T_TEMPLATE_LITERAL_EXPRESSION:
86
86
  return evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
87
- case ScriptingSourceTreeExp_1.T_LITERAL:
87
+ case ScriptingSourceTree_1.T_LITERAL:
88
88
  return (0, eval_tree_common_1.evalLiteral)(thisStack, expr, thread);
89
- case ScriptingSourceTreeExp_1.T_IDENTIFIER:
89
+ case ScriptingSourceTree_1.T_IDENTIFIER:
90
90
  return (0, eval_tree_common_1.evalIdentifier)(thisStack, expr, evalContext, thread);
91
- case ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION:
91
+ case ScriptingSourceTree_1.T_MEMBER_ACCESS_EXPRESSION:
92
92
  return yield evalMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread);
93
- case ScriptingSourceTreeExp_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
93
+ case ScriptingSourceTree_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
94
94
  return yield evalCalculatedMemberAccessAsync(evaluator, thisStack, expr, evalContext, thread);
95
- case ScriptingSourceTreeExp_1.T_SEQUENCE_EXPRESSION:
95
+ case ScriptingSourceTree_1.T_SEQUENCE_EXPRESSION:
96
96
  return yield evalSequenceAsync(evaluator, thisStack, expr, evalContext, thread);
97
- case ScriptingSourceTreeExp_1.T_ARRAY_LITERAL:
97
+ case ScriptingSourceTree_1.T_ARRAY_LITERAL:
98
98
  return yield evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
99
- case ScriptingSourceTreeExp_1.T_OBJECT_LITERAL:
99
+ case ScriptingSourceTree_1.T_OBJECT_LITERAL:
100
100
  return yield evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread);
101
- case ScriptingSourceTreeExp_1.T_UNARY_EXPRESSION:
101
+ case ScriptingSourceTree_1.T_UNARY_EXPRESSION:
102
102
  return yield evalUnaryAsync(evaluator, thisStack, expr, evalContext, thread);
103
- case ScriptingSourceTreeExp_1.T_BINARY_EXPRESSION:
103
+ case ScriptingSourceTree_1.T_BINARY_EXPRESSION:
104
104
  return yield evalBinaryAsync(evaluator, thisStack, expr, evalContext, thread);
105
- case ScriptingSourceTreeExp_1.T_CONDITIONAL_EXPRESSION:
105
+ case ScriptingSourceTree_1.T_CONDITIONAL_EXPRESSION:
106
106
  return yield evalConditionalAsync(evaluator, thisStack, expr, evalContext, thread);
107
- case ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION:
107
+ case ScriptingSourceTree_1.T_ASSIGNMENT_EXPRESSION:
108
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:
109
+ case ScriptingSourceTree_1.T_PREFIX_OP_EXPRESSION:
110
+ case ScriptingSourceTree_1.T_POSTFIX_OP_EXPRESSION:
111
111
  return yield evalPreOrPostAsync(evaluator, thisStack, expr, evalContext, thread);
112
- case ScriptingSourceTreeExp_1.T_FUNCTION_INVOCATION_EXPRESSION:
112
+ case ScriptingSourceTree_1.T_FUNCTION_INVOCATION_EXPRESSION:
113
113
  // --- Special async handling
114
114
  return yield evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, thread);
115
- case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION:
115
+ case ScriptingSourceTree_1.T_ARROW_EXPRESSION:
116
116
  return (0, eval_tree_common_1.evalArrow)(thisStack, expr, thread);
117
- case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION:
117
+ case ScriptingSourceTree_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}`);
@@ -166,7 +166,7 @@ function evalArrayLiteralAsync(evaluator, thisStack, expr, evalContext, thread)
166
166
  return __awaiter(this, void 0, void 0, function* () {
167
167
  const value = [];
168
168
  for (const item of expr.items) {
169
- if (item.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
169
+ if (item.type === ScriptingSourceTree_1.T_SPREAD_EXPRESSION) {
170
170
  const spreadArray = yield evaluator(thisStack, item.expr, evalContext, thread);
171
171
  thisStack.pop();
172
172
  if (!Array.isArray(spreadArray)) {
@@ -210,10 +210,10 @@ function evalObjectLiteralAsync(evaluator, thisStack, expr, evalContext, thread)
210
210
  // --- We're using key/[value] pairs
211
211
  let key;
212
212
  switch (prop[0].type) {
213
- case ScriptingSourceTreeExp_1.T_LITERAL:
213
+ case ScriptingSourceTree_1.T_LITERAL:
214
214
  key = prop[0].value;
215
215
  break;
216
- case ScriptingSourceTreeExp_1.T_IDENTIFIER:
216
+ case ScriptingSourceTree_1.T_IDENTIFIER:
217
217
  key = prop[0].name;
218
218
  break;
219
219
  default:
@@ -312,11 +312,11 @@ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, th
312
312
  let implicitContextObject = null;
313
313
  let hostObject;
314
314
  // --- Check for contexted object
315
- if (expr.obj.type === ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION) {
315
+ if (expr.obj.type === ScriptingSourceTree_1.T_MEMBER_ACCESS_EXPRESSION) {
316
316
  hostObject = yield evaluator(thisStack, expr.obj.obj, evalContext, thread);
317
317
  yield completeExprValue(expr.obj.obj, thread);
318
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)) {
319
+ if (expr.obj.obj.type === ScriptingSourceTree_1.T_IDENTIFIER && (hostObject === null || hostObject === void 0 ? void 0 : hostObject._SUPPORT_IMPLICIT_CONTEXT)) {
320
320
  implicitContextObject = hostObject;
321
321
  }
322
322
  }
@@ -333,7 +333,7 @@ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, th
333
333
  functionArgs.push(functionObj.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
334
334
  functionObj = yield createArrowFunctionAsync(evaluator, functionObj);
335
335
  }
336
- else if (expr.obj.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
336
+ else if (expr.obj.type === ScriptingSourceTree_1.T_ARROW_EXPRESSION) {
337
337
  // --- We delay evaluating expression values. We pass the argument names as the first parameter, and then
338
338
  // --- all parameter expressions
339
339
  functionArgs.push(expr.obj.args.map((a) => a.name), evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
@@ -342,7 +342,7 @@ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, th
342
342
  // --- We evaluate the argument values to pass to a JavaScript function
343
343
  for (let i = 0; i < expr.arguments.length; i++) {
344
344
  const arg = expr.arguments[i];
345
- if (arg.type === ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION) {
345
+ if (arg.type === ScriptingSourceTree_1.T_SPREAD_EXPRESSION) {
346
346
  yield evaluator([], arg.expr, evalContext, thread);
347
347
  const funcArg = yield completeExprValue(arg.expr, thread);
348
348
  if (!Array.isArray(funcArg)) {
@@ -351,7 +351,7 @@ function evalFunctionInvocationAsync(evaluator, thisStack, expr, evalContext, th
351
351
  functionArgs.push(...funcArg);
352
352
  }
353
353
  else {
354
- if (arg.type === ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION) {
354
+ if (arg.type === ScriptingSourceTree_1.T_ARROW_EXPRESSION) {
355
355
  const funcArg = yield createArrowFunctionAsync(evaluator, arg);
356
356
  const wrappedFunc = (...args) => __awaiter(this, void 0, void 0, function* () {
357
357
  return funcArg(arg.args, evalContext, thread, ...args);
@@ -450,26 +450,26 @@ function createArrowFunctionAsync(evaluator, expr) {
450
450
  const argSpec = argSpecs[i];
451
451
  let decl;
452
452
  switch (argSpec.type) {
453
- case ScriptingSourceTreeExp_1.T_IDENTIFIER: {
453
+ case ScriptingSourceTree_1.T_IDENTIFIER: {
454
454
  decl = {
455
- type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
455
+ type: ScriptingSourceTree_1.T_VAR_DECLARATION,
456
456
  id: argSpec.name,
457
457
  };
458
458
  break;
459
459
  }
460
- case ScriptingSourceTreeExp_1.T_DESTRUCTURE: {
460
+ case ScriptingSourceTree_1.T_DESTRUCTURE: {
461
461
  decl = {
462
- type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
462
+ type: ScriptingSourceTree_1.T_VAR_DECLARATION,
463
463
  id: argSpec.id,
464
464
  aDestr: argSpec.aDestr,
465
465
  oDestr: argSpec.oDestr,
466
466
  };
467
467
  break;
468
468
  }
469
- case ScriptingSourceTreeExp_1.T_SPREAD_EXPRESSION: {
469
+ case ScriptingSourceTree_1.T_SPREAD_EXPRESSION: {
470
470
  restFound = true;
471
471
  decl = {
472
- type: ScriptingSourceTreeExp_1.T_VAR_DECLARATION,
472
+ type: ScriptingSourceTree_1.T_VAR_DECLARATION,
473
473
  id: argSpec.expr.name,
474
474
  };
475
475
  break;
@@ -506,19 +506,19 @@ function createArrowFunctionAsync(evaluator, expr) {
506
506
  let returnValue;
507
507
  let statements;
508
508
  switch (expr.statement.type) {
509
- case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
509
+ case ScriptingSourceTree_1.T_EMPTY_STATEMENT:
510
510
  statements = [];
511
511
  break;
512
- case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
512
+ case ScriptingSourceTree_1.T_EXPRESSION_STATEMENT:
513
513
  // --- Create a new thread for the call
514
514
  statements = [
515
515
  {
516
- type: ScriptingSourceTreeExp_1.T_RETURN_STATEMENT,
516
+ type: ScriptingSourceTree_1.T_RETURN_STATEMENT,
517
517
  expr: expr.statement.expr,
518
518
  },
519
519
  ];
520
520
  break;
521
- case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
521
+ case ScriptingSourceTree_1.T_BLOCK_STATEMENT:
522
522
  // --- Create a new thread for the call
523
523
  statements = expr.statement.stmts;
524
524
  break;
@@ -16,7 +16,7 @@ exports.evalPreOrPostCore = evalPreOrPostCore;
16
16
  exports.evalArrow = evalArrow;
17
17
  exports.obtainClosures = obtainClosures;
18
18
  exports.evalTemplateLiteralCore = evalTemplateLiteralCore;
19
- const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
19
+ const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
20
20
  // --- Get the cached expression value
21
21
  function getExprValue(expr, thread) {
22
22
  var _a, _b;
@@ -129,12 +129,12 @@ function evalIdentifier(thisStack, expr, evalContext, thread) {
129
129
  // --- Gets the scope of the root ID
130
130
  function getRootIdScope(expr, evalContext, thread) {
131
131
  switch (expr.type) {
132
- case ScriptingSourceTreeExp_1.T_IDENTIFIER:
132
+ case ScriptingSourceTree_1.T_IDENTIFIER:
133
133
  const idScope = getIdentifierScope(expr, evalContext, thread);
134
134
  return { type: idScope.type, name: expr.name };
135
- case ScriptingSourceTreeExp_1.T_MEMBER_ACCESS_EXPRESSION:
135
+ case ScriptingSourceTree_1.T_MEMBER_ACCESS_EXPRESSION:
136
136
  return getRootIdScope(expr.obj, evalContext, thread);
137
- case ScriptingSourceTreeExp_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
137
+ case ScriptingSourceTree_1.T_CALCULATED_MEMBER_ACCESS_EXPRESSION:
138
138
  return getRootIdScope(expr.obj, evalContext, thread);
139
139
  }
140
140
  return null;
@@ -316,7 +316,7 @@ function evalAssignmentCore(thisStack, expr, evalContext, thread) {
316
316
  throw new Error(`Unknown left-hand value`);
317
317
  }
318
318
  // --- Check for const value
319
- if (expr.leftValue.type === ScriptingSourceTreeExp_1.T_IDENTIFIER) {
319
+ if (expr.leftValue.type === ScriptingSourceTree_1.T_IDENTIFIER) {
320
320
  if (isConstVar(expr.leftValue.name, thread)) {
321
321
  throw new Error("A const variable cannot be modified");
322
322
  }
@@ -387,17 +387,17 @@ function evalPreOrPostCore(thisStack, expr, evalContext, thread) {
387
387
  throw new Error(`Evaluation of ${expr.op} requires a left-hand value.`);
388
388
  }
389
389
  // --- Check for const value
390
- if (expr.expr.type === ScriptingSourceTreeExp_1.T_IDENTIFIER) {
390
+ if (expr.expr.type === ScriptingSourceTree_1.T_IDENTIFIER) {
391
391
  if (isConstVar(expr.expr.name, thread)) {
392
392
  // --- We cannot modify a const value
393
393
  throw new Error("A const variable cannot be modified");
394
394
  }
395
395
  }
396
396
  const value = expr.op === "++"
397
- ? expr.type === ScriptingSourceTreeExp_1.T_PREFIX_OP_EXPRESSION
397
+ ? expr.type === ScriptingSourceTree_1.T_PREFIX_OP_EXPRESSION
398
398
  ? ++operand.valueScope[operand.valueIndex]
399
399
  : operand.valueScope[operand.valueIndex]++
400
- : expr.type === ScriptingSourceTreeExp_1.T_PREFIX_OP_EXPRESSION
400
+ : expr.type === ScriptingSourceTree_1.T_PREFIX_OP_EXPRESSION
401
401
  ? --operand.valueScope[operand.valueIndex]
402
402
  : operand.valueScope[operand.valueIndex]--;
403
403
  setExprValue(expr, { value }, thread);