xmlui 0.4.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.
Files changed (308) hide show
  1. package/dist/Pdf-DeGhSMXe.mjs +19537 -0
  2. package/dist/Pdf.css +1 -0
  3. package/dist/apiInterceptorWorker-CwuUhYyc.mjs +9229 -0
  4. package/dist/array-USo-Szhp.mjs +12 -0
  5. package/dist/index-C24dkfpd.mjs +1434 -0
  6. package/dist/index-ao27SnVp.mjs +145185 -0
  7. package/dist/index.css +1 -0
  8. package/dist/nivo-bar.es-CWh0ZlxB.mjs +1666 -0
  9. package/dist/nivo-geo.es-BTqNt5Db.mjs +1579 -0
  10. package/dist/nivo-legends.es-BuIxHGSU.mjs +6916 -0
  11. package/dist/nivo-pie.es-BvCBFA0L.mjs +700 -0
  12. package/dist/react-apexcharts.min-DqWuDOyO.mjs +8881 -0
  13. package/dist/scripts/bin/bootstrap.js +11 -0
  14. package/dist/scripts/bin/build.js +256 -0
  15. package/dist/scripts/bin/index.js +88 -0
  16. package/dist/scripts/bin/preview.js +27 -0
  17. package/dist/scripts/bin/start.js +41 -0
  18. package/dist/scripts/bin/vite-ueml-plugin.js +113 -0
  19. package/dist/scripts/bin/viteConfig.js +112 -0
  20. package/dist/scripts/src/abstractions/ActionDefs.js +2 -0
  21. package/dist/scripts/src/abstractions/AppContextDefs.js +2 -0
  22. package/dist/scripts/src/abstractions/BlockScope.js +4 -0
  23. package/dist/scripts/src/abstractions/ComponentDefs.js +2 -0
  24. package/dist/scripts/src/abstractions/ComponentDescriptorDefs.js +2 -0
  25. package/dist/scripts/src/abstractions/ContainerDefs.js +2 -0
  26. package/dist/scripts/src/abstractions/FunctionDefs.js +2 -0
  27. package/dist/scripts/src/abstractions/RendererDefs.js +2 -0
  28. package/dist/scripts/src/abstractions/scripting/ScriptParserError.js +2 -0
  29. package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +2 -0
  30. package/dist/scripts/src/abstractions/scripting/Token.js +110 -0
  31. package/dist/scripts/src/components/App/App.js +253 -0
  32. package/dist/scripts/src/components/App/AppLayoutContext.js +9 -0
  33. package/dist/scripts/src/components/App/AppStateContext.js +9 -0
  34. package/dist/scripts/src/components/App/Sheet.js +89 -0
  35. package/dist/scripts/src/components/AppHeader/AppHeader.js +121 -0
  36. package/dist/scripts/src/components/AppState/AppState.js +29 -0
  37. package/dist/scripts/src/components/Avatar/Avatar.js +81 -0
  38. package/dist/scripts/src/components/Badge/Badge.js +56 -0
  39. package/dist/scripts/src/components/BarChart/BarChart.js +199 -0
  40. package/dist/scripts/src/components/Bookmark/Bookmark.js +11 -0
  41. package/dist/scripts/src/components/Button/Button.js +196 -0
  42. package/dist/scripts/src/components/Card/Card.js +65 -0
  43. package/dist/scripts/src/components/ChangeListener/ChangeListener.js +43 -0
  44. package/dist/scripts/src/components/Chart/Chart.js +158 -0
  45. package/dist/scripts/src/components/Checkbox/Checkbox.js +43 -0
  46. package/dist/scripts/src/components/Combobox/Combobox.js +145 -0
  47. package/dist/scripts/src/components/ComponentProvider.js +357 -0
  48. package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +40 -0
  49. package/dist/scripts/src/components/DatePicker/DatePicker.js +196 -0
  50. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +175 -0
  51. package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +56 -0
  52. package/dist/scripts/src/components/FileInput/FileInput.js +127 -0
  53. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +106 -0
  54. package/dist/scripts/src/components/FlowLayout/FlowLayout.js +139 -0
  55. package/dist/scripts/src/components/Footer/Footer.js +42 -0
  56. package/dist/scripts/src/components/Form/Form.js +320 -0
  57. package/dist/scripts/src/components/Form/FormContext.js +9 -0
  58. package/dist/scripts/src/components/Form/formActions.js +86 -0
  59. package/dist/scripts/src/components/FormItem/FormItem.js +204 -0
  60. package/dist/scripts/src/components/FormItem/HelperText.js +27 -0
  61. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +39 -0
  62. package/dist/scripts/src/components/FormItem/Validations.js +346 -0
  63. package/dist/scripts/src/components/FormSection/FormSection.js +45 -0
  64. package/dist/scripts/src/components/Heading/Heading.js +206 -0
  65. package/dist/scripts/src/components/HoverCard/HoverCard.js +45 -0
  66. package/dist/scripts/src/components/Icon/ApiIcon.js +10 -0
  67. package/dist/scripts/src/components/Icon/Attach.js +10 -0
  68. package/dist/scripts/src/components/Icon/Binding.js +11 -0
  69. package/dist/scripts/src/components/Icon/BoardIcon.js +7 -0
  70. package/dist/scripts/src/components/Icon/BoxIcon.js +10 -0
  71. package/dist/scripts/src/components/Icon/CheckIcon.js +7 -0
  72. package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
  73. package/dist/scripts/src/components/Icon/ChevronLeft.js +7 -0
  74. package/dist/scripts/src/components/Icon/ChevronRight.js +7 -0
  75. package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
  76. package/dist/scripts/src/components/Icon/CodeFileIcon.js +10 -0
  77. package/dist/scripts/src/components/Icon/CodeSandbox.js +10 -0
  78. package/dist/scripts/src/components/Icon/CompactListIcon.js +7 -0
  79. package/dist/scripts/src/components/Icon/ContentCopyIcon.js +7 -0
  80. package/dist/scripts/src/components/Icon/DatabaseIcon.js +11 -0
  81. package/dist/scripts/src/components/Icon/DocFileIcon.js +10 -0
  82. package/dist/scripts/src/components/Icon/DocIcon.js +10 -0
  83. package/dist/scripts/src/components/Icon/DotMenuHorizontalIcon.js +7 -0
  84. package/dist/scripts/src/components/Icon/DotMenuIcon.js +7 -0
  85. package/dist/scripts/src/components/Icon/EmailIcon.js +7 -0
  86. package/dist/scripts/src/components/Icon/EmptyFolderIcon.js +10 -0
  87. package/dist/scripts/src/components/Icon/ErrorIcon.js +7 -0
  88. package/dist/scripts/src/components/Icon/ExpressionIcon.js +10 -0
  89. package/dist/scripts/src/components/Icon/FillPlusCricleIcon.js +7 -0
  90. package/dist/scripts/src/components/Icon/FilterIcon.js +10 -0
  91. package/dist/scripts/src/components/Icon/FolderIcon.js +10 -0
  92. package/dist/scripts/src/components/Icon/GlobeIcon.js +7 -0
  93. package/dist/scripts/src/components/Icon/HomeIcon.js +7 -0
  94. package/dist/scripts/src/components/Icon/HyperLinkIcon.js +7 -0
  95. package/dist/scripts/src/components/Icon/Icon.js +101 -0
  96. package/dist/scripts/src/components/Icon/ImageFileIcon.js +10 -0
  97. package/dist/scripts/src/components/Icon/LinkIcon.js +7 -0
  98. package/dist/scripts/src/components/Icon/ListIcon.js +7 -0
  99. package/dist/scripts/src/components/Icon/LooseListIcon.js +7 -0
  100. package/dist/scripts/src/components/Icon/MoonIcon.js +10 -0
  101. package/dist/scripts/src/components/Icon/MoreOptionsIcon.js +7 -0
  102. package/dist/scripts/src/components/Icon/PDFIcon.js +10 -0
  103. package/dist/scripts/src/components/Icon/PenIcon.js +7 -0
  104. package/dist/scripts/src/components/Icon/PhoneIcon.js +7 -0
  105. package/dist/scripts/src/components/Icon/PhotoIcon.js +10 -0
  106. package/dist/scripts/src/components/Icon/PlusIcon.js +7 -0
  107. package/dist/scripts/src/components/Icon/SearchIcon.js +7 -0
  108. package/dist/scripts/src/components/Icon/ShareIcon.js +10 -0
  109. package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
  110. package/dist/scripts/src/components/Icon/TrashIcon.js +7 -0
  111. package/dist/scripts/src/components/Icon/TxtIcon.js +10 -0
  112. package/dist/scripts/src/components/Icon/UnknownFileIcon.js +10 -0
  113. package/dist/scripts/src/components/Icon/UnlinkIcon.js +10 -0
  114. package/dist/scripts/src/components/Icon/UserIcon.js +7 -0
  115. package/dist/scripts/src/components/Icon/WarningIcon.js +7 -0
  116. package/dist/scripts/src/components/Icon/XlsIcon.js +10 -0
  117. package/dist/scripts/src/components/IconProvider.js +249 -0
  118. package/dist/scripts/src/components/IconRegistryContext.js +307 -0
  119. package/dist/scripts/src/components/Image/Image.js +34 -0
  120. package/dist/scripts/src/components/Input/InputAdornment.js +14 -0
  121. package/dist/scripts/src/components/Input/input-abstractions.js +44 -0
  122. package/dist/scripts/src/components/Items/Items.js +48 -0
  123. package/dist/scripts/src/components/Link/Link.js +72 -0
  124. package/dist/scripts/src/components/List/List.js +442 -0
  125. package/dist/scripts/src/components/Logo/Logo.js +25 -0
  126. package/dist/scripts/src/components/Map/Map.js +60 -0
  127. package/dist/scripts/src/components/Map/world_countries.json +45307 -0
  128. package/dist/scripts/src/components/Markdown/Markdown.js +120 -0
  129. package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +106 -0
  130. package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
  131. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +145 -0
  132. package/dist/scripts/src/components/MultiCombobox/MultiCombobox.js +249 -0
  133. package/dist/scripts/src/components/MultiSelect/MultiSelect.js +192 -0
  134. package/dist/scripts/src/components/NavGroup/NavGroup.js +113 -0
  135. package/dist/scripts/src/components/NavLink/NavLink.js +115 -0
  136. package/dist/scripts/src/components/NavPanel/NavPanel.js +101 -0
  137. package/dist/scripts/src/components/NoResult/NoResult.js +39 -0
  138. package/dist/scripts/src/components/NumberBox/NumberBox.js +373 -0
  139. package/dist/scripts/src/components/Option/Option.js +41 -0
  140. package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +22 -0
  141. package/dist/scripts/src/components/Pages/Pages.js +74 -0
  142. package/dist/scripts/src/components/Pdf/LazyPdf.js +44 -0
  143. package/dist/scripts/src/components/Pdf/Pdf.js +19 -0
  144. package/dist/scripts/src/components/PieChart/PieChart.js +184 -0
  145. package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +29 -0
  146. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +38 -0
  147. package/dist/scripts/src/components/Queue/Queue.js +286 -0
  148. package/dist/scripts/src/components/Queue/queueActions.js +87 -0
  149. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +144 -0
  150. package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +147 -0
  151. package/dist/scripts/src/components/Redirect/Redirect.js +10 -0
  152. package/dist/scripts/src/components/Select/Select.js +139 -0
  153. package/dist/scripts/src/components/Select/SelectContext.js +45 -0
  154. package/dist/scripts/src/components/SelectionStore/SelectionStore.js +88 -0
  155. package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +22 -0
  156. package/dist/scripts/src/components/Spinner/Spinner.js +59 -0
  157. package/dist/scripts/src/components/Splitter/Splitter.js +205 -0
  158. package/dist/scripts/src/components/Splitter/utils.js +17 -0
  159. package/dist/scripts/src/components/Stack/Stack.js +117 -0
  160. package/dist/scripts/src/components/StickyBox/StickyBox.js +33 -0
  161. package/dist/scripts/src/components/Switch/Switch.js +50 -0
  162. package/dist/scripts/src/components/Table/Table.js +499 -0
  163. package/dist/scripts/src/components/Table/useRowSelection.js +169 -0
  164. package/dist/scripts/src/components/TableColumnDef/TableColumnDef.js +44 -0
  165. package/dist/scripts/src/components/TableColumnDef/TableContext.js +12 -0
  166. package/dist/scripts/src/components/Tabs/Tabs.js +85 -0
  167. package/dist/scripts/src/components/Text/Text.js +175 -0
  168. package/dist/scripts/src/components/TextArea/TextArea.js +194 -0
  169. package/dist/scripts/src/components/TextArea/TextAreaResizable.js +63 -0
  170. package/dist/scripts/src/components/TextArea/useComposedRef.js +50 -0
  171. package/dist/scripts/src/components/TextBox/TextBox.js +145 -0
  172. package/dist/scripts/src/components/Theme/NotificationToast.js +39 -0
  173. package/dist/scripts/src/components/Theme/Theme.js +153 -0
  174. package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +125 -0
  175. package/dist/scripts/src/components/Toggle/Toggle.js +88 -0
  176. package/dist/scripts/src/components/Tree/TreeComponent.js +79 -0
  177. package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +59 -0
  178. package/dist/scripts/src/components/ViewComponentRegistryContext.js +34 -0
  179. package/dist/scripts/src/components/abstractions.js +2 -0
  180. package/dist/scripts/src/components/chart-color-schemes.js +43 -0
  181. package/dist/scripts/src/components/component-utils.js +32 -0
  182. package/dist/scripts/src/components/container-helpers.js +18 -0
  183. package/dist/scripts/src/components-core/ApiBoundComponent.js +189 -0
  184. package/dist/scripts/src/components-core/AppContext.js +17 -0
  185. package/dist/scripts/src/components-core/ChildrenSlot.js +10 -0
  186. package/dist/scripts/src/components-core/Component.js +280 -0
  187. package/dist/scripts/src/components-core/ComponentDecorator.js +63 -0
  188. package/dist/scripts/src/components-core/CompoundComponent.js +132 -0
  189. package/dist/scripts/src/components-core/EngineError.js +91 -0
  190. package/dist/scripts/src/components-core/ErrorBoundary.js +58 -0
  191. package/dist/scripts/src/components-core/Fragment.js +14 -0
  192. package/dist/scripts/src/components-core/InvalidComponent.js +15 -0
  193. package/dist/scripts/src/components-core/LoaderComponent.js +78 -0
  194. package/dist/scripts/src/components-core/RestApiProxy.js +341 -0
  195. package/dist/scripts/src/components-core/RootComponent.js +272 -0
  196. package/dist/scripts/src/components-core/RouteContext.js +45 -0
  197. package/dist/scripts/src/components-core/ScrollContext.js +9 -0
  198. package/dist/scripts/src/components-core/UnknownComponent.js +15 -0
  199. package/dist/scripts/src/components-core/abstractions/ComponentRenderer.js +2 -0
  200. package/dist/scripts/src/components-core/abstractions/LoaderRenderer.js +2 -0
  201. package/dist/scripts/src/components-core/abstractions/containers.js +18 -0
  202. package/dist/scripts/src/components-core/abstractions/treeAbstractions.js +2 -0
  203. package/dist/scripts/src/components-core/action/ApiAction.js +276 -0
  204. package/dist/scripts/src/components-core/action/DownloadFileAction.js +80 -0
  205. package/dist/scripts/src/components-core/action/NavigateAction.js +20 -0
  206. package/dist/scripts/src/components-core/action/TimedAction.js +21 -0
  207. package/dist/scripts/src/components-core/action/UploadAction.js +88 -0
  208. package/dist/scripts/src/components-core/action/actions.js +15 -0
  209. package/dist/scripts/src/components-core/appContext/date-functions.js +19 -0
  210. package/dist/scripts/src/components-core/appContext/misc-utils.js +12 -0
  211. package/dist/scripts/src/components-core/component-hooks.js +25 -0
  212. package/dist/scripts/src/components-core/constants.js +18 -0
  213. package/dist/scripts/src/components-core/container/Container.js +1110 -0
  214. package/dist/scripts/src/components-core/container/ContainerComponentDef.js +16 -0
  215. package/dist/scripts/src/components-core/container/buildProxy.js +54 -0
  216. package/dist/scripts/src/components-core/container/collectFnVarDeps.js +26 -0
  217. package/dist/scripts/src/components-core/container/valueExtractor.js +195 -0
  218. package/dist/scripts/src/components-core/descriptorHelper.js +75 -0
  219. package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
  220. package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
  221. package/dist/scripts/src/components-core/loader/ApiLoader.js +46 -0
  222. package/dist/scripts/src/components-core/loader/DataLoader.js +160 -0
  223. package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +52 -0
  224. package/dist/scripts/src/components-core/loader/Loader.js +115 -0
  225. package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +32 -0
  226. package/dist/scripts/src/components-core/loader/PageableLoader.js +240 -0
  227. package/dist/scripts/src/components-core/renderers.js +45 -0
  228. package/dist/scripts/src/components-core/reportEngineError.js +59 -0
  229. package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +35 -0
  230. package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +34 -0
  231. package/dist/scripts/src/components-core/script-runner/LogicalThread.js +2 -0
  232. package/dist/scripts/src/components-core/script-runner/LoopScope.js +2 -0
  233. package/dist/scripts/src/components-core/script-runner/ParameterParser.js +117 -0
  234. package/dist/scripts/src/components-core/script-runner/TryScope.js +2 -0
  235. package/dist/scripts/src/components-core/script-runner/asyncProxy.js +96 -0
  236. package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +34 -0
  237. package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +40 -0
  238. package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +40 -0
  239. package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +551 -0
  240. package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +498 -0
  241. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +434 -0
  242. package/dist/scripts/src/components-core/script-runner/modules.js +250 -0
  243. package/dist/scripts/src/components-core/script-runner/process-statement-async.js +818 -0
  244. package/dist/scripts/src/components-core/script-runner/process-statement-common.js +193 -0
  245. package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +740 -0
  246. package/dist/scripts/src/components-core/script-runner/statement-queue.js +62 -0
  247. package/dist/scripts/src/components-core/script-runner/visitors.js +352 -0
  248. package/dist/scripts/src/components-core/theming/ThemeContext.js +43 -0
  249. package/dist/scripts/src/components-core/theming/ThemeProvider.js +334 -0
  250. package/dist/scripts/src/components-core/theming/abstractions.js +11 -0
  251. package/dist/scripts/src/components-core/theming/extendThemeUtils.js +114 -0
  252. package/dist/scripts/src/components-core/theming/hvar.js +105 -0
  253. package/dist/scripts/src/components-core/theming/themeVars.js +62 -0
  254. package/dist/scripts/src/components-core/theming/themes/base-utils.js +31 -0
  255. package/dist/scripts/src/components-core/theming/themes/palette.js +53 -0
  256. package/dist/scripts/src/components-core/theming/themes/root.js +257 -0
  257. package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
  258. package/dist/scripts/src/components-core/theming/themes/theme-colors.js +407 -0
  259. package/dist/scripts/src/components-core/theming/themes/xmlui.js +32 -0
  260. package/dist/scripts/src/components-core/theming/transformThemeVars.js +286 -0
  261. package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +34 -0
  262. package/dist/scripts/src/components-core/utils/LruCache.js +184 -0
  263. package/dist/scripts/src/components-core/utils/actionUtils.js +32 -0
  264. package/dist/scripts/src/components-core/utils/classnames.js +58 -0
  265. package/dist/scripts/src/components-core/utils/css-utils.js +127 -0
  266. package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
  267. package/dist/scripts/src/components-core/utils/extractParam.js +148 -0
  268. package/dist/scripts/src/components-core/utils/hooks.js +221 -0
  269. package/dist/scripts/src/components-core/utils/mergeProps.js +45 -0
  270. package/dist/scripts/src/components-core/utils/misc.js +460 -0
  271. package/dist/scripts/src/components-core/utils/statementUtils.js +205 -0
  272. package/dist/scripts/src/components-core/utils/treeUtils.js +48 -0
  273. package/dist/scripts/src/components-core/xmlui-parser.js +52 -0
  274. package/dist/scripts/src/parsers/scripting/InputStream.js +59 -0
  275. package/dist/scripts/src/parsers/scripting/Lexer.js +1028 -0
  276. package/dist/scripts/src/parsers/scripting/Parser.js +2647 -0
  277. package/dist/scripts/src/parsers/scripting/ParserError.js +46 -0
  278. package/dist/scripts/src/parsers/scripting/TokenTrait.js +109 -0
  279. package/dist/scripts/src/parsers/scripting/code-behind-collect.js +118 -0
  280. package/dist/scripts/src/parsers/scripting/tree-visitor.js +602 -0
  281. package/dist/scripts/src/parsers/style-parser/StyleInputStream.js +39 -0
  282. package/dist/scripts/src/parsers/style-parser/StyleLexer.js +621 -0
  283. package/dist/scripts/src/parsers/style-parser/StyleParser.js +1000 -0
  284. package/dist/scripts/src/parsers/style-parser/errors.js +37 -0
  285. package/dist/scripts/src/parsers/style-parser/source-tree.js +2 -0
  286. package/dist/scripts/src/parsers/style-parser/style-compiler.js +513 -0
  287. package/dist/scripts/src/parsers/style-parser/tokens.js +42 -0
  288. package/dist/scripts/src/parsers/ueml/ParserError.js +54 -0
  289. package/dist/scripts/src/parsers/ueml/UemlHelper.js +579 -0
  290. package/dist/scripts/src/parsers/ueml/UemlInputStream.js +59 -0
  291. package/dist/scripts/src/parsers/ueml/UemlLexer.js +868 -0
  292. package/dist/scripts/src/parsers/ueml/UemlParser.js +1439 -0
  293. package/dist/scripts/src/parsers/ueml/UemlToken.js +24 -0
  294. package/dist/scripts/src/parsers/ueml/fileExtensions.js +6 -0
  295. package/dist/scripts/src/parsers/ueml/source-tree.js +2 -0
  296. package/dist/scripts/src/parsers/ueml/ueml-tree.js +2 -0
  297. package/dist/scripts/src/parsers/xmlui-parser/CharacterCodes.js +136 -0
  298. package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +100 -0
  299. package/dist/scripts/src/parsers/xmlui-parser/parser.js +476 -0
  300. package/dist/scripts/src/parsers/xmlui-parser/scanner.js +415 -0
  301. package/dist/scripts/src/parsers/xmlui-parser/syntax-kind.js +106 -0
  302. package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +2 -0
  303. package/dist/scripts/src/parsers/xmlui-parser/transform.js +922 -0
  304. package/dist/scripts/src/parsers/xmlui-parser/utils.js +83 -0
  305. package/dist/xmlui.es.d.ts +1667 -0
  306. package/dist/xmlui.es.js +17 -0
  307. package/dist/xmlui.umd.js +1589 -0
  308. package/package.json +175 -0
@@ -0,0 +1,818 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.processStatementQueueAsync = processStatementQueueAsync;
13
+ exports.visitLetConstDeclarations = visitLetConstDeclarations;
14
+ exports.processDeclarationsAsync = processDeclarationsAsync;
15
+ const eval_tree_async_1 = require("./eval-tree-async");
16
+ const process_statement_common_1 = require("./process-statement-common");
17
+ const statement_queue_1 = require("./statement-queue");
18
+ const EngineError_1 = require("../EngineError");
19
+ const reportEngineError_1 = require("../reportEngineError");
20
+ // --- Helper function to process the entire queue asynchronously
21
+ function processStatementQueueAsync(statements, evalContext, thread, onStatementCompleted) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b;
24
+ if (!thread) {
25
+ // --- Create the main thread for the queue
26
+ thread = (0, process_statement_common_1.ensureMainThread)(evalContext);
27
+ }
28
+ // --- Hoist function declarations to the top scope
29
+ (0, process_statement_common_1.hoistFunctionDeclarations)(thread, statements);
30
+ // --- Fill the queue with items
31
+ const queue = new statement_queue_1.StatementQueue();
32
+ queue.push((0, statement_queue_1.mapStatementsToQueueItems)(statements));
33
+ // --- Prepare queue diagnostics information
34
+ const diagInfo = {
35
+ processedStatements: 0,
36
+ maxQueueLength: queue.length,
37
+ unshiftedItems: 0,
38
+ clearToLabels: 0,
39
+ maxBlocks: 0,
40
+ maxLoops: 0,
41
+ };
42
+ // --- Consume the queue
43
+ let startTime = new Date().getTime();
44
+ while (queue.length > 0 && !((_a = evalContext.cancellationToken) === null || _a === void 0 ? void 0 : _a.cancelled)) {
45
+ // --- Allow time to break from infinite loops
46
+ if (evalContext.timeout && new Date().getTime() - startTime > evalContext.timeout) {
47
+ throw new Error("Script execution timeout");
48
+ }
49
+ // --- Process the first item
50
+ const queueItem = queue.dequeue();
51
+ thread.breakLabelValue = queue.length > 0 ? queue.peek().label : -1;
52
+ let outcome;
53
+ try {
54
+ outcome = yield processStatementAsync(queueItem.statement, evalContext, thread, onStatementCompleted);
55
+ }
56
+ catch (err) {
57
+ if (thread.tryBlocks && thread.tryBlocks.length > 0) {
58
+ // --- We have a try block to handle this error
59
+ const tryScope = thread.tryBlocks[thread.tryBlocks.length - 1];
60
+ // --- Sign the error to raise. Next time the guarded try block will execute the catch block, if there is any
61
+ tryScope.errorToThrow = err;
62
+ tryScope.errorSource = tryScope.processingPhase;
63
+ tryScope.processingPhase = "error";
64
+ // --- Let's skip the remaining parts of the current block (try/catch/finally)
65
+ outcome = {
66
+ clearToLabel: tryScope.tryLabel,
67
+ };
68
+ }
69
+ else {
70
+ if (err instanceof EngineError_1.ThrowStatementError) {
71
+ (0, reportEngineError_1.reportEngineError)(err);
72
+ }
73
+ else {
74
+ (0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err, (_b = queueItem.statement) === null || _b === void 0 ? void 0 : _b.source), err);
75
+ }
76
+ }
77
+ }
78
+ // --- Modify the queue's content according to the outcome
79
+ if (outcome) {
80
+ if (outcome.toUnshift) {
81
+ queue.unshift(outcome.toUnshift);
82
+ diagInfo.unshiftedItems += outcome.toUnshift.length;
83
+ }
84
+ if (outcome.clearToLabel !== undefined) {
85
+ queue.clearToLabel(outcome.clearToLabel);
86
+ diagInfo.clearToLabels++;
87
+ }
88
+ }
89
+ yield (onStatementCompleted === null || onStatementCompleted === void 0 ? void 0 : onStatementCompleted(evalContext, queueItem.statement));
90
+ // --- Provide diagnostics
91
+ if (queue.length > diagInfo.maxQueueLength) {
92
+ diagInfo.maxQueueLength = queue.length;
93
+ }
94
+ if (thread.blocks && thread.blocks.length > diagInfo.maxBlocks) {
95
+ diagInfo.maxBlocks = thread.blocks.length;
96
+ }
97
+ if (thread.loops && thread.loops.length > diagInfo.maxLoops) {
98
+ diagInfo.maxLoops = thread.loops.length;
99
+ }
100
+ diagInfo.processedStatements++;
101
+ }
102
+ return diagInfo;
103
+ });
104
+ }
105
+ /**
106
+ * Process the specified statement asynchronously
107
+ * @param statement Statement to process
108
+ * @param evalContext Evaluation context used for processing
109
+ * @param thread Logical thread to use for statement processing
110
+ * @param onStatementCompleted
111
+ * @returns Items to put back into the queue of statements
112
+ */
113
+ function processStatementAsync(statement, evalContext, thread, onStatementCompleted) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
116
+ // --- These items should be put in the statement queue after return
117
+ let toUnshift = [];
118
+ let clearToLabel;
119
+ // --- Process the statement according to its type
120
+ switch (statement.type) {
121
+ case "ImportD":
122
+ // --- Get module information
123
+ const thisModule = statement.module;
124
+ if (!thisModule) {
125
+ throw new Error("Missing module");
126
+ }
127
+ const parentModule = (_a = statement.module) === null || _a === void 0 ? void 0 : _a.parent;
128
+ if (!parentModule) {
129
+ throw new Error("Missing parent module");
130
+ }
131
+ // --- At this point the imported module is set
132
+ // if (!statement.module!.executed) {
133
+ // // --- Run the module, it has not been executed yet
134
+ // const childEvalContext = createEvalContext({
135
+ // cancellationToken: evalContext.cancellationToken,
136
+ // timeout: evalContext.timeout ?? 1000
137
+ // });
138
+ // statement.module!.executed = true;
139
+ // executeScriptModule(statement.module!, childEvalContext);
140
+ // }
141
+ // --- Import the module's exported variables into the parent module
142
+ const topVars = evalContext.mainThread.blocks[0].vars;
143
+ const topConst = evalContext.mainThread.blocks[0].constVars;
144
+ for (const key of Object.keys(statement.imports)) {
145
+ if (key in topVars) {
146
+ throw new Error(`Import ${key} already exists`);
147
+ }
148
+ topVars[key] = statement.module.exports.get(statement.imports[key]);
149
+ topConst.add(key);
150
+ }
151
+ break;
152
+ case "FuncD":
153
+ // --- Function declarations are already hoisted, nothing to do
154
+ break;
155
+ case "EmptyS":
156
+ // --- Nothing to do
157
+ break;
158
+ case "BlockS":
159
+ // --- No statement, nothing to process
160
+ if (statement.statements.length === 0)
161
+ break;
162
+ // --- Create a new block scope
163
+ (_b = thread.blocks) !== null && _b !== void 0 ? _b : (thread.blocks = []);
164
+ thread.blocks.push({ vars: {} });
165
+ // --- Hoist function declarations to the innermost block scope
166
+ (0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.statements);
167
+ // --- Prepare an empty statement that will only remove the block scope when the entire block is processed
168
+ const closing = {
169
+ type: "EmptyS",
170
+ removeBlockScope: true,
171
+ }; // --- We need the cast as we do not provide required props
172
+ // --- Queue the block scope's body
173
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statement.statements, closing]);
174
+ break;
175
+ case "ExprS":
176
+ // --- Just evaluate it
177
+ const statementValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread, onStatementCompleted);
178
+ if (thread.blocks && thread.blocks.length !== 0) {
179
+ thread.blocks[thread.blocks.length - 1].returnValue = statementValue;
180
+ }
181
+ break;
182
+ case "ArrowS":
183
+ // --- Compile the arrow expression
184
+ const arrowFuncValue = yield (0, eval_tree_async_1.executeArrowExpression)(statement.expression, evalContext, onStatementCompleted, thread, ...((_c = evalContext.eventArgs) !== null && _c !== void 0 ? _c : []));
185
+ if (thread.blocks && thread.blocks.length !== 0) {
186
+ thread.blocks[thread.blocks.length - 1].returnValue = arrowFuncValue;
187
+ }
188
+ break;
189
+ case "LetS": {
190
+ // --- Create a new variable in the innermost scope
191
+ const block = (0, process_statement_common_1.innermostBlockScope)(thread);
192
+ if (!block) {
193
+ throw new Error("Missing block scope");
194
+ }
195
+ yield processDeclarationsAsync(block, evalContext, thread, onStatementCompleted, statement.declarations);
196
+ break;
197
+ }
198
+ case "ConstS": {
199
+ // --- Create a new variable in the innermost scope
200
+ const block = (0, process_statement_common_1.innermostBlockScope)(thread);
201
+ if (!block) {
202
+ throw new Error("Missing block scope");
203
+ }
204
+ yield processDeclarationsAsync(block, evalContext, thread, onStatementCompleted, statement.declarations, true);
205
+ break;
206
+ }
207
+ case "IfS":
208
+ // --- Evaluate the condition
209
+ const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.condition, evalContext, thread, onStatementCompleted));
210
+ if (condition) {
211
+ toUnshift = (0, statement_queue_1.mapToItem)(statement.thenBranch);
212
+ }
213
+ else if (statement.elseBranch) {
214
+ toUnshift = (0, statement_queue_1.mapToItem)(statement.elseBranch);
215
+ }
216
+ break;
217
+ case "RetS": {
218
+ // --- Check if return is valid here
219
+ let blockScope = (0, process_statement_common_1.innermostBlockScope)(thread);
220
+ if (blockScope === undefined) {
221
+ throw new Error("Return requires a block scope");
222
+ }
223
+ // --- Store the return value
224
+ thread.returnValue = statement.expression
225
+ ? yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread, onStatementCompleted)
226
+ : undefined;
227
+ // --- Check for try blocks
228
+ if (((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length > 0) {
229
+ // --- Mark the loop's try scope to exit with "return"
230
+ const returnTryScope = thread.tryBlocks[0];
231
+ returnTryScope.exitType = "return";
232
+ // --- Remove the try/catch/finally block's scope
233
+ if (returnTryScope.processingPhase !== "postFinally") {
234
+ thread.blocks.pop();
235
+ }
236
+ // --- Clear the last part of the try/catch/finally block
237
+ const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
238
+ clearToLabel = tryScope.tryLabel;
239
+ }
240
+ else {
241
+ // --- Delete the remaining part of the queue
242
+ clearToLabel = -1;
243
+ }
244
+ break;
245
+ }
246
+ case "WhileS": {
247
+ // --- Create or get the loop's scope (guard is falsy for the first execution)
248
+ let loopScope = statement.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
249
+ // --- Evaluate the loop condition
250
+ const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.condition, evalContext, thread, onStatementCompleted));
251
+ if (condition) {
252
+ toUnshift = (0, process_statement_common_1.provideLoopBody)(loopScope, statement, thread.breakLabelValue);
253
+ }
254
+ else {
255
+ // --- When the condition is not met, we're done.
256
+ (0, process_statement_common_1.releaseLoopScope)(thread);
257
+ }
258
+ break;
259
+ }
260
+ case "DoWS": {
261
+ if (!statement.guard) {
262
+ // --- First loop execution (do-while is a post-test loop)
263
+ toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.createLoopScope)(thread), statement, thread.breakLabelValue);
264
+ break;
265
+ }
266
+ // --- Evaluate the loop condition
267
+ const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.condition, evalContext, thread, onStatementCompleted));
268
+ if (condition) {
269
+ toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.innermostLoopScope)(thread), statement, thread.breakLabelValue);
270
+ }
271
+ else {
272
+ // --- When the condition is not met, we're done.
273
+ (0, process_statement_common_1.releaseLoopScope)(thread);
274
+ }
275
+ break;
276
+ }
277
+ case "ContS": {
278
+ // --- Search for the innermost non-switch loop scope, release the switch scopes
279
+ if (!thread.loops || thread.loops.length === 0) {
280
+ throw new Error("Missing loop scope");
281
+ }
282
+ let loopScope;
283
+ while (thread.loops.length > 0) {
284
+ loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
285
+ if (!loopScope.isSwitch) {
286
+ break;
287
+ }
288
+ thread.loops.pop();
289
+ }
290
+ if (!loopScope) {
291
+ throw new Error("Missing loop scope");
292
+ }
293
+ if (loopScope.tryBlockDepth >= 0 && loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
294
+ // --- Mark the loop's try scope to exit with "continue"
295
+ for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
296
+ thread.tryBlocks[loopScope.tryBlockDepth].exitType = "continue";
297
+ }
298
+ // --- Clear the last part of the try/catch/finally block
299
+ const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
300
+ clearToLabel = tryScope.tryLabel;
301
+ }
302
+ else {
303
+ clearToLabel = loopScope.continueLabel;
304
+ (0, process_statement_common_1.releaseLoopScope)(thread, false);
305
+ }
306
+ break;
307
+ }
308
+ case "BrkS": {
309
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
310
+ if (loopScope === undefined) {
311
+ throw new Error("Missing loop scope");
312
+ }
313
+ if (!!loopScope.isSwitch) {
314
+ // --- Break is in a switch case
315
+ clearToLabel = loopScope.breakLabel;
316
+ break;
317
+ }
318
+ // --- Break is in a loop construct
319
+ if (loopScope.tryBlockDepth >= 0 && loopScope.tryBlockDepth < ((_f = thread.tryBlocks) !== null && _f !== void 0 ? _f : []).length) {
320
+ // --- Mark the loop's try scope to exit with "break"
321
+ for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
322
+ thread.tryBlocks[loopScope.tryBlockDepth].exitType = "break";
323
+ }
324
+ // --- Clear the last part of the try/catch/finally block
325
+ const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
326
+ clearToLabel = tryScope.tryLabel;
327
+ }
328
+ else {
329
+ clearToLabel = loopScope.breakLabel;
330
+ (0, process_statement_common_1.releaseLoopScope)(thread);
331
+ }
332
+ break;
333
+ }
334
+ case "ForS":
335
+ if (!statement.guard) {
336
+ // --- Init the loop with a new scope
337
+ (0, process_statement_common_1.createLoopScope)(thread, 1);
338
+ // --- Create a new block for the loop variables
339
+ (_g = thread.blocks) !== null && _g !== void 0 ? _g : (thread.blocks = []);
340
+ thread.blocks.push({
341
+ vars: {},
342
+ });
343
+ const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
344
+ if (statement.init) {
345
+ // --- Unshift the initialization part and the guarded for-loop
346
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.init, guardStatement]);
347
+ }
348
+ else {
349
+ // --- No init, unshift only the guard statement
350
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([guardStatement]);
351
+ }
352
+ }
353
+ else {
354
+ // --- Initialization already done. Evaluate the condition
355
+ if (!statement.condition ||
356
+ !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.condition, evalContext, thread, onStatementCompleted))) {
357
+ // --- Stay in the loop, inject the body, the update expression, and the loop guard
358
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
359
+ if (statement.update) {
360
+ const updateStmt = {
361
+ type: "ExprS",
362
+ expression: statement.update,
363
+ };
364
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, updateStmt, Object.assign({}, statement)]);
365
+ }
366
+ else {
367
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
368
+ }
369
+ // --- The next queue label is for "break"
370
+ loopScope.breakLabel = (_h = thread.breakLabelValue) !== null && _h !== void 0 ? _h : -1;
371
+ // --- The guard action's label is for "continue"
372
+ loopScope.continueLabel = toUnshift[1].label;
373
+ }
374
+ else {
375
+ // --- The condition is not met, we're done. Remove the loop's scope from the evaluation context
376
+ (0, process_statement_common_1.releaseLoopScope)(thread);
377
+ }
378
+ }
379
+ break;
380
+ case "ForInS":
381
+ if (!statement.guard) {
382
+ // --- Get the object keys
383
+ const keyedObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread);
384
+ if (keyedObject == undefined) {
385
+ // --- Nothing to do, no object to traverse
386
+ break;
387
+ }
388
+ // --- Init the loop with a new scope
389
+ (0, process_statement_common_1.createLoopScope)(thread, 1);
390
+ // --- Create a new block for the loop variables
391
+ (_j = thread.blocks) !== null && _j !== void 0 ? _j : (thread.blocks = []);
392
+ thread.blocks.push({ vars: {} });
393
+ statement.keys = Object.keys(keyedObject);
394
+ statement.keyIndex = 0;
395
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
396
+ }
397
+ else {
398
+ // --- Just for the sake of extra safety
399
+ if (statement.keyIndex === undefined || statement.keys === undefined) {
400
+ throw new Error("Keys information expected in for..in loop");
401
+ }
402
+ // --- Any key left?
403
+ if (statement.keyIndex < statement.keys.length) {
404
+ // --- Set the binding variable to the next key
405
+ const propValue = statement.keys[statement.keyIndex++];
406
+ switch (statement.varBinding) {
407
+ case "none": {
408
+ const assigmentExpr = {
409
+ type: "AsgnE",
410
+ leftValue: {
411
+ type: "IdE",
412
+ name: statement.id,
413
+ },
414
+ operator: "=",
415
+ operand: {
416
+ type: "LitE",
417
+ value: propValue,
418
+ },
419
+ };
420
+ yield (0, eval_tree_async_1.evalBindingAsync)(assigmentExpr, evalContext, thread);
421
+ break;
422
+ }
423
+ case "const":
424
+ case "let":
425
+ {
426
+ // --- Create a new variable in the innermost scope
427
+ const block = (0, process_statement_common_1.innermostBlockScope)(thread);
428
+ if (!block) {
429
+ throw new Error("Missing block scope");
430
+ }
431
+ block.vars[statement.id] = propValue;
432
+ if (statement.varBinding === "const") {
433
+ (_k = block.constVars) !== null && _k !== void 0 ? _k : (block.constVars = new Set());
434
+ block.constVars.add(statement.id);
435
+ }
436
+ }
437
+ break;
438
+ }
439
+ // --- Inject the loop body
440
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
441
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
442
+ // --- The next queue label is for "break"
443
+ loopScope.breakLabel = (_l = thread.breakLabelValue) !== null && _l !== void 0 ? _l : -1;
444
+ // --- The guard action's label is for "continue"
445
+ loopScope.continueLabel = toUnshift[1].label;
446
+ }
447
+ else {
448
+ // --- The condition is not met, we're done. Remove the loop's scope from the evaluation context
449
+ (0, process_statement_common_1.releaseLoopScope)(thread);
450
+ }
451
+ }
452
+ break;
453
+ case "ForOfS":
454
+ if (!statement.guard) {
455
+ // --- Get the object keys
456
+ const iteratorObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread);
457
+ if (iteratorObject == null || typeof iteratorObject[Symbol.iterator] !== "function") {
458
+ // --- The object is not an iterator
459
+ throw new Error("Object in for..of is not iterable");
460
+ }
461
+ // --- Init the loop with a new scope
462
+ (0, process_statement_common_1.createLoopScope)(thread, 1);
463
+ // --- Create a new block for the loop variables
464
+ (_m = thread.blocks) !== null && _m !== void 0 ? _m : (thread.blocks = []);
465
+ thread.blocks.push({ vars: {} });
466
+ statement.iterator = iteratorObject[Symbol.iterator]();
467
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
468
+ }
469
+ else {
470
+ // --- Just for the sake of extra safety
471
+ if (statement.iterator === undefined) {
472
+ throw new Error("Iterator expected in for..of loop");
473
+ }
474
+ // --- Any iteration left?
475
+ const nextIteration = statement.iterator.next();
476
+ if (nextIteration.done) {
477
+ // --- The for..of loop is complete. Remove the loop's scope from the evaluation context
478
+ (0, process_statement_common_1.releaseLoopScope)(thread);
479
+ break;
480
+ }
481
+ // --- Set the binding variable to the next key
482
+ const propValue = nextIteration.value;
483
+ switch (statement.varBinding) {
484
+ case "none": {
485
+ const assigmentExpr = {
486
+ type: "AsgnE",
487
+ leftValue: {
488
+ type: "IdE",
489
+ name: statement.id,
490
+ },
491
+ operator: "=",
492
+ operand: {
493
+ type: "LitE",
494
+ value: propValue,
495
+ },
496
+ };
497
+ yield (0, eval_tree_async_1.evalBindingAsync)(assigmentExpr, evalContext, thread);
498
+ break;
499
+ }
500
+ case "const":
501
+ case "let":
502
+ {
503
+ // --- Create a new variable in the innermost scope
504
+ const block = (0, process_statement_common_1.innermostBlockScope)(thread);
505
+ if (!block) {
506
+ throw new Error("Missing block scope");
507
+ }
508
+ block.vars[statement.id] = propValue;
509
+ if (statement.varBinding === "const") {
510
+ (_o = block.constVars) !== null && _o !== void 0 ? _o : (block.constVars = new Set());
511
+ block.constVars.add(statement.id);
512
+ }
513
+ }
514
+ break;
515
+ }
516
+ // --- Inject the loop body
517
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
518
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
519
+ // --- The next queue label is for "break"
520
+ loopScope.breakLabel = (_p = thread.breakLabelValue) !== null && _p !== void 0 ? _p : -1;
521
+ // --- The guard action's label is for "continue"
522
+ loopScope.continueLabel = toUnshift[1].label;
523
+ }
524
+ break;
525
+ case "ThrowS": {
526
+ throw new EngineError_1.ThrowStatementError(yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread, onStatementCompleted));
527
+ }
528
+ case "TryS": {
529
+ if (!statement.guard) {
530
+ // --- Execute the try block
531
+ toUnshift = (0, process_statement_common_1.provideTryBody)(thread, (0, process_statement_common_1.createTryScope)(thread, statement));
532
+ break;
533
+ }
534
+ // --- Evaluate try
535
+ const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
536
+ switch (tryScope.processingPhase) {
537
+ case "error":
538
+ // --- There was an error we may handle with catch
539
+ switch (tryScope.errorSource) {
540
+ case "try":
541
+ // --- Remove the "try" block's scope
542
+ thread.blocks.pop();
543
+ // --- Go on with catch or finally
544
+ if (statement.catchBlock) {
545
+ if (tryScope.statement.catchVariable) {
546
+ const block = (0, process_statement_common_1.innermostBlockScope)(thread);
547
+ block.vars[tryScope.statement.catchVariable] =
548
+ tryScope.errorToThrow instanceof EngineError_1.ThrowStatementError
549
+ ? tryScope.errorToThrow.errorObject
550
+ : tryScope.errorToThrow;
551
+ }
552
+ delete tryScope.errorToThrow;
553
+ tryScope.processingPhase = "catch";
554
+ toUnshift = (0, process_statement_common_1.provideCatchBody)(thread, tryScope);
555
+ }
556
+ else if (tryScope.statement.finallyBlock) {
557
+ // --- No catch, move on finally
558
+ tryScope.processingPhase = "finally";
559
+ toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
560
+ }
561
+ break;
562
+ case "catch":
563
+ // --- Remove the "catch" block's scope
564
+ thread.blocks.pop();
565
+ // --- Move to the finally block
566
+ tryScope.processingPhase = "finally";
567
+ toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
568
+ break;
569
+ case "finally":
570
+ // --- Remove the "finally" block's scope
571
+ thread.blocks.pop();
572
+ // --- Move to the post finally execution
573
+ tryScope.processingPhase = "postFinally";
574
+ toUnshift = (0, process_statement_common_1.provideFinallyErrorBody)(tryScope);
575
+ break;
576
+ }
577
+ break;
578
+ case "try":
579
+ // --- We completed the try block successfully
580
+ tryScope.processingPhase = "finally";
581
+ if (statement.finallyBlock) {
582
+ toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
583
+ }
584
+ break;
585
+ case "catch":
586
+ // --- We completed the catch block successfully, remove the handled error
587
+ tryScope.processingPhase = "finally";
588
+ if (statement.finallyBlock) {
589
+ toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
590
+ }
591
+ break;
592
+ case "finally":
593
+ tryScope.processingPhase = "postFinally";
594
+ toUnshift = (0, process_statement_common_1.provideFinallyErrorBody)(tryScope);
595
+ break;
596
+ case "postFinally":
597
+ // --- We completed the finally block successfully
598
+ const innermostTry = thread.tryBlocks.pop();
599
+ // --- Is there any special exit type?
600
+ switch (innermostTry.exitType) {
601
+ case "break": {
602
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
603
+ if (loopScope === undefined) {
604
+ throw new Error("Missing loop scope");
605
+ }
606
+ (0, process_statement_common_1.releaseLoopScope)(thread);
607
+ clearToLabel = loopScope.breakLabel;
608
+ break;
609
+ }
610
+ case "continue": {
611
+ const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
612
+ if (loopScope === undefined) {
613
+ throw new Error("Missing loop scope");
614
+ }
615
+ clearToLabel = loopScope.continueLabel;
616
+ (0, process_statement_common_1.releaseLoopScope)(thread, false);
617
+ break;
618
+ }
619
+ case "return":
620
+ clearToLabel = -1;
621
+ break;
622
+ }
623
+ // --- Should we raise an error?
624
+ if (innermostTry.errorToThrow) {
625
+ throw innermostTry.errorToThrow;
626
+ }
627
+ break;
628
+ }
629
+ break;
630
+ }
631
+ case "SwitchS": {
632
+ // --- Create or get the loop's scope (guard is falsy for the first execution)
633
+ if (statement.guard) {
634
+ // --- Complete the switch
635
+ (0, process_statement_common_1.releaseLoopScope)(thread);
636
+ }
637
+ else {
638
+ let loopScope = (0, process_statement_common_1.createLoopScope)(thread);
639
+ loopScope.isSwitch = true;
640
+ thread.blocks.push({ vars: {} });
641
+ // --- Evaluate the switch value
642
+ const switchValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expression, evalContext, thread);
643
+ // --- Find the matching label
644
+ let matchingIndex = -1;
645
+ for (let i = 0; i < statement.cases.length; i++) {
646
+ const currentCase = statement.cases[i];
647
+ // --- Check for default case
648
+ if (currentCase.caseExpression === undefined) {
649
+ matchingIndex = i;
650
+ break;
651
+ }
652
+ // --- Check for matching case
653
+ const caseValue = yield (0, eval_tree_async_1.evalBindingAsync)(currentCase.caseExpression, evalContext, thread);
654
+ if (caseValue === switchValue) {
655
+ matchingIndex = i;
656
+ break;
657
+ }
658
+ }
659
+ // --- Merge all statements from the matching label
660
+ const statementFlow = [];
661
+ if (matchingIndex >= 0) {
662
+ for (let i = matchingIndex; i < statement.cases.length; i++) {
663
+ statementFlow.push(...statement.cases[i].statements);
664
+ }
665
+ }
666
+ // --- Queue the statement flow and the guard
667
+ const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
668
+ toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statementFlow, guardStatement]);
669
+ loopScope.breakLabel = toUnshift[toUnshift.length - 1].label;
670
+ }
671
+ break;
672
+ }
673
+ }
674
+ // --- The statement may remove the innermost scope
675
+ if (statement.removeBlockScope) {
676
+ if (thread.blocks && thread.blocks.length > 0) {
677
+ thread.blocks.pop();
678
+ }
679
+ }
680
+ // --- Done.
681
+ return { toUnshift, clearToLabel };
682
+ });
683
+ }
684
+ /**
685
+ * Visits all declarations in a let or const statement
686
+ * @param declaration Declaration to process
687
+ * @param visitor Function to call on each visited declaration
688
+ */
689
+ function visitLetConstDeclarations(declaration, visitor) {
690
+ for (let i = 0; i < declaration.declarations.length; i++) {
691
+ let value;
692
+ const decl = declaration.declarations[i];
693
+ visitDeclaration(decl, visitor);
694
+ }
695
+ function visitDeclaration(varDecl, visitor) {
696
+ // --- Process each declaration
697
+ if (varDecl.id) {
698
+ visitor(varDecl.id);
699
+ }
700
+ else if (varDecl.arrayDestruct) {
701
+ visitArrayDestruct(varDecl.arrayDestruct, visitor);
702
+ }
703
+ else if (varDecl.objectDestruct) {
704
+ visitObjectDestruct(varDecl.objectDestruct, visitor);
705
+ }
706
+ else {
707
+ throw new Error("Unknown declaration specifier");
708
+ }
709
+ }
710
+ // --- Visits an array destructure declaration
711
+ function visitArrayDestruct(arrayD, visitor) {
712
+ for (let i = 0; i < arrayD.length; i++) {
713
+ const arrDecl = arrayD[i];
714
+ if (arrDecl.id) {
715
+ visitor(arrDecl.id);
716
+ }
717
+ else if (arrDecl.arrayDestruct) {
718
+ visitArrayDestruct(arrDecl.arrayDestruct, visitor);
719
+ }
720
+ else if (arrDecl.objectDestruct) {
721
+ visitObjectDestruct(arrDecl.objectDestruct, visitor);
722
+ }
723
+ }
724
+ }
725
+ // --- Visits an object destructure declaration
726
+ function visitObjectDestruct(objectD, visitor) {
727
+ var _a;
728
+ for (let i = 0; i < objectD.length; i++) {
729
+ const objDecl = objectD[i];
730
+ if (objDecl.arrayDestruct) {
731
+ visitArrayDestruct(objDecl.arrayDestruct, visitor);
732
+ }
733
+ else if (objDecl.objectDestruct) {
734
+ visitObjectDestruct(objDecl.objectDestruct, visitor);
735
+ }
736
+ else {
737
+ visitor((_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id);
738
+ }
739
+ }
740
+ }
741
+ }
742
+ // --- Process a variable declaration
743
+ function processDeclarationsAsync(block_1, evalContext_1, thread_1, onStatementCompleted_1, declarations_1) {
744
+ return __awaiter(this, arguments, void 0, function* (block, evalContext, thread, onStatementCompleted, declarations, addConst = false, useValue = false, baseValue = undefined) {
745
+ for (let i = 0; i < declarations.length; i++) {
746
+ let value;
747
+ const decl = declarations[i];
748
+ if (useValue) {
749
+ value = baseValue;
750
+ }
751
+ else if (decl.expression) {
752
+ value = yield (0, eval_tree_async_1.evalBindingAsync)(decl.expression, evalContext, thread, onStatementCompleted);
753
+ }
754
+ visitDeclaration(block, decl, value, addConst);
755
+ }
756
+ // --- Visit a variable
757
+ function visitDeclaration(block, decl, baseValue, addConst) {
758
+ // --- Process each declaration
759
+ if (decl.id) {
760
+ visitIdDeclaration(block, decl.id, baseValue, addConst);
761
+ }
762
+ else if (decl.arrayDestruct) {
763
+ visitArrayDestruct(block, decl.arrayDestruct, baseValue, addConst);
764
+ }
765
+ else if (decl.objectDestruct) {
766
+ visitObjectDestruct(block, decl.objectDestruct, baseValue, addConst);
767
+ }
768
+ else {
769
+ throw new Error("Unknown declaration specifier");
770
+ }
771
+ }
772
+ // --- Visits a single ID declaration
773
+ function visitIdDeclaration(block, id, baseValue, addConst) {
774
+ var _a;
775
+ if (block.vars[id]) {
776
+ throw new Error(`Variable ${id} is already declared in the current scope.`);
777
+ }
778
+ block.vars[id] = baseValue;
779
+ if (addConst) {
780
+ (_a = block.constVars) !== null && _a !== void 0 ? _a : (block.constVars = new Set());
781
+ block.constVars.add(id);
782
+ }
783
+ }
784
+ // --- Visits an array destructure declaration
785
+ function visitArrayDestruct(block, arrayD, baseValue, addConst) {
786
+ for (let i = 0; i < arrayD.length; i++) {
787
+ const arrDecl = arrayD[i];
788
+ const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[i];
789
+ if (arrDecl.id) {
790
+ visitIdDeclaration(block, arrDecl.id, value, addConst);
791
+ }
792
+ else if (arrDecl.arrayDestruct) {
793
+ visitArrayDestruct(block, arrDecl.arrayDestruct, value, addConst);
794
+ }
795
+ else if (arrDecl.objectDestruct) {
796
+ visitObjectDestruct(block, arrDecl.objectDestruct, value, addConst);
797
+ }
798
+ }
799
+ }
800
+ // --- Visits an object destructure declaration
801
+ function visitObjectDestruct(block, objectD, baseValue, addConst) {
802
+ var _a;
803
+ for (let i = 0; i < objectD.length; i++) {
804
+ const objDecl = objectD[i];
805
+ const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[objDecl.id];
806
+ if (objDecl.arrayDestruct) {
807
+ visitArrayDestruct(block, objDecl.arrayDestruct, value, addConst);
808
+ }
809
+ else if (objDecl.objectDestruct) {
810
+ visitObjectDestruct(block, objDecl.objectDestruct, value, addConst);
811
+ }
812
+ else {
813
+ visitIdDeclaration(block, (_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id, value, addConst);
814
+ }
815
+ }
816
+ }
817
+ });
818
+ }