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,434 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evalBindingExpression = evalBindingExpression;
4
+ exports.evalBinding = evalBinding;
5
+ exports.executeArrowExpressionSync = executeArrowExpressionSync;
6
+ const eval_tree_common_1 = require("./eval-tree-common");
7
+ const Parser_1 = require("../../parsers/scripting/Parser");
8
+ const process_statement_common_1 = require("./process-statement-common");
9
+ const process_statement_sync_1 = require("./process-statement-sync");
10
+ const bannedFunctions_1 = require("./bannedFunctions");
11
+ /**
12
+ * Evaluates the specified binding expression tree and retrieves the evaluated value
13
+ * @param source Binding tree expression
14
+ * @param evalContext Evaluation context
15
+ * @param thread The logical thread to use for evaluation
16
+ * This code uses the JavaScript semantics and errors when evaluating the code.
17
+ */
18
+ function evalBindingExpression(source, evalContext, thread) {
19
+ // --- Use the main thread by default
20
+ thread !== null && thread !== void 0 ? thread : (thread = evalContext.mainThread);
21
+ // --- Parse the source code
22
+ const wParser = new Parser_1.Parser(source);
23
+ const tree = wParser.parseExpr();
24
+ if (tree === null) {
25
+ // --- This should happen only when an expression is empty
26
+ return undefined;
27
+ }
28
+ // --- Check for expression termination
29
+ if (!wParser.isEof) {
30
+ throw new Error("Expression is not terminated properly");
31
+ }
32
+ // --- Ok, valid source, evaluate
33
+ return evalBinding(tree, evalContext, thread);
34
+ }
35
+ /**
36
+ * Evaluates a binding represented by the specified expression
37
+ * @param expr Expression to evaluate
38
+ * @param evalContext Evaluation context to use
39
+ * @param thread The logical thread to use for evaluation
40
+ */
41
+ function evalBinding(expr, evalContext, thread) {
42
+ const thisStack = [];
43
+ (0, process_statement_common_1.ensureMainThread)(evalContext);
44
+ thread !== null && thread !== void 0 ? thread : (thread = evalContext.mainThread);
45
+ return evalBindingExpressionTree(thisStack, expr, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread);
46
+ }
47
+ /**
48
+ * Executes the specified arrow function
49
+ * @param expr Arrow function expression to run
50
+ * @param evalContext Evaluation context to use
51
+ * @param thread The logical thread to use for evaluation
52
+ * @param args Arguments of the arrow function to execute
53
+ */
54
+ function executeArrowExpressionSync(expr, evalContext, thread, ...args) {
55
+ // --- Just an extra safety check
56
+ if (expr.type !== "ArrowE") {
57
+ throw new Error("executeArrowExpression expects an 'ArrowExpression' object.");
58
+ }
59
+ // --- This is the evaluator that an arrow expression uses internally
60
+ const evaluator = evalBindingExpressionTree;
61
+ // --- Compiles the Arrow function to a JavaScript function
62
+ const nativeFunction = createArrowFunction(evaluator, expr);
63
+ // --- Run the compiled arrow function. Note, we have two prefix arguments:
64
+ // --- #1: The names of arrow function arguments
65
+ // --- #2: The evaluation context the arrow function runs in
66
+ // --- #others: The real arguments of the arrow function
67
+ return nativeFunction(expr.args, evalContext, thread !== null && thread !== void 0 ? thread : evalContext.mainThread, ...args);
68
+ }
69
+ /**
70
+ * Evaluates the specified binding expression tree and retrieves the evaluated value
71
+ * @param expr Binding tree expression
72
+ * @param thisStack Stack of "this" object to use with function calls
73
+ * @param evalContext Evaluation context
74
+ * @param thread The logical thread to use for evaluation
75
+ * This code uses the JavaScript semantics and errors when evaluating the code.
76
+ * We use `thisStack` to keep track of the partial results of the evaluation tree so that we can set
77
+ * the real `this` context when invoking a function.
78
+ */
79
+ function evalBindingExpressionTree(thisStack, expr, evalContext, thread) {
80
+ if (!evalContext.options) {
81
+ evalContext.options = { defaultToOptionalMemberAccess: true };
82
+ }
83
+ // --- Prepare evaluation
84
+ let customOp = null;
85
+ const evaluator = evalBindingExpressionTree;
86
+ // --- Reset the expression scope
87
+ expr.valueScope = expr.valueIndex = undefined;
88
+ // --- Process the expression according to its type
89
+ switch (expr.type) {
90
+ case "LitE":
91
+ return (0, eval_tree_common_1.evalLiteral)(thisStack, expr);
92
+ case "IdE":
93
+ return (0, eval_tree_common_1.evalIdentifier)(thisStack, expr, evalContext, thread);
94
+ case "MembE":
95
+ return evalMemberAccess(evaluator, thisStack, expr, evalContext, thread);
96
+ case "CMembE":
97
+ return evalCalculatedMemberAccess(evaluator, thisStack, expr, evalContext, thread);
98
+ case "SeqE":
99
+ return evalSequence(evaluator, thisStack, expr, evalContext, thread);
100
+ case "ALitE":
101
+ return evalArrayLiteral(evaluator, thisStack, expr, evalContext, thread);
102
+ case "OLitE":
103
+ return evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread);
104
+ case "UnaryE":
105
+ return evalUnary(evaluator, thisStack, customOp, expr, evalContext, thread);
106
+ case "BinaryE":
107
+ return evalBinary(evaluator, thisStack, customOp, expr, evalContext, thread);
108
+ case "CondE":
109
+ return evalConditional(evaluator, thisStack, expr, evalContext, thread);
110
+ case "AsgnE":
111
+ return evalAssignment(evaluator, thisStack, expr, evalContext, thread);
112
+ case "PrefE":
113
+ case "PostfE":
114
+ return evalPreOrPost(evaluator, thisStack, expr, evalContext, thread);
115
+ case "InvokeE":
116
+ // --- Special sync handling
117
+ const funcResult = evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread);
118
+ if ((0, eval_tree_common_1.isPromise)(funcResult)) {
119
+ throw new Error("Promises (async function calls) are not allowed in binding expressions.");
120
+ }
121
+ return funcResult;
122
+ case "ArrowE":
123
+ // --- Special sync handling
124
+ return (0, eval_tree_common_1.evalArrow)(thisStack, expr, thread);
125
+ case "SpreadE":
126
+ throw new Error("Cannot use spread expression (...) with the current intermediate value.");
127
+ default:
128
+ throw new Error(`Unknown expression tree node: ${expr.type}`);
129
+ }
130
+ }
131
+ function evalMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
132
+ const parentObj = evaluator(thisStack, expr.object, evalContext, thread);
133
+ return (0, eval_tree_common_1.evalMemberAccessCore)(parentObj, thisStack, expr, evalContext);
134
+ }
135
+ function evalCalculatedMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
136
+ const parentObj = evaluator(thisStack, expr.object, evalContext, thread);
137
+ // --- At this point we definitely keep the parent object on `thisStack`, as it will be the context object
138
+ // --- of a FunctionInvocationExpression, if that follows the MemberAccess. Other operations would call
139
+ // --- `thisStack.pop()` to remove the result from the previous `evalBindingExpressionTree` call.
140
+ const memberObj = evaluator(thisStack, expr.member, evalContext, thread);
141
+ thisStack.pop();
142
+ return (0, eval_tree_common_1.evalCalculatedMemberAccessCore)(parentObj, memberObj, thisStack, expr, evalContext);
143
+ }
144
+ function evalSequence(evaluator, thisStack, expr, evalContext, thread) {
145
+ if (!expr.expressions || expr.expressions.length === 0) {
146
+ throw new Error(`Missing expression sequence`);
147
+ }
148
+ const result = expr.expressions.map((e) => {
149
+ const exprValue = evaluator(thisStack, e, evalContext, thread);
150
+ thisStack.pop();
151
+ return exprValue;
152
+ });
153
+ const lastObj = result[result.length - 1];
154
+ thisStack.push(lastObj);
155
+ return lastObj;
156
+ }
157
+ function evalArrayLiteral(evaluator, thisStack, expr, evalContext, thread) {
158
+ const arrayValue = [];
159
+ for (const item of expr.items) {
160
+ if (item.type === "SpreadE") {
161
+ const spreadArray = evaluator(thisStack, item.operand, evalContext, thread);
162
+ thisStack.pop();
163
+ if (!Array.isArray(spreadArray)) {
164
+ throw new Error("Spread operator within an array literal expects an array operand.");
165
+ }
166
+ arrayValue.push(...spreadArray);
167
+ }
168
+ else {
169
+ arrayValue.push(evaluator(thisStack, item, evalContext, thread));
170
+ thisStack.pop();
171
+ thisStack.push(arrayValue);
172
+ }
173
+ }
174
+ return arrayValue;
175
+ }
176
+ function evalObjectLiteral(evaluator, thisStack, expr, evalContext, thread) {
177
+ const objectHash = {};
178
+ for (const prop of expr.props) {
179
+ if (!Array.isArray(prop)) {
180
+ // --- We're using a spread expression
181
+ const spreadItems = evaluator(thisStack, prop.operand, evalContext, thread);
182
+ thisStack.pop();
183
+ if (Array.isArray(spreadItems)) {
184
+ // --- Spread of an array
185
+ for (let i = 0; i < spreadItems.length; i++) {
186
+ objectHash[i] = spreadItems[i];
187
+ }
188
+ }
189
+ else if (typeof spreadItems === "object") {
190
+ // --- Spread of a hash object
191
+ for (const [key, value] of Object.entries(spreadItems)) {
192
+ objectHash[key] = value;
193
+ }
194
+ }
195
+ continue;
196
+ }
197
+ // --- We're using key/[value] pairs
198
+ let key;
199
+ switch (prop[0].type) {
200
+ case "LitE":
201
+ key = prop[0].value;
202
+ break;
203
+ case "IdE":
204
+ key = prop[0].name;
205
+ break;
206
+ default:
207
+ key = evaluator(thisStack, prop[0], evalContext, thread);
208
+ thisStack.pop();
209
+ break;
210
+ }
211
+ objectHash[key] = evaluator(thisStack, prop[1], evalContext, thread);
212
+ thisStack.pop();
213
+ }
214
+ thisStack.push(objectHash);
215
+ return objectHash;
216
+ }
217
+ function evalUnary(evaluator, thisStack, customOp, expr, evalContext, thread) {
218
+ const operand = evaluator(thisStack, expr.operand, evalContext, thread);
219
+ thisStack.pop();
220
+ return (0, eval_tree_common_1.evalUnaryCore)(expr, operand, thisStack, customOp);
221
+ }
222
+ function evalBinary(evaluator, thisStack, customOp, expr, evalContext, thread) {
223
+ const l = evaluator(thisStack, expr.left, evalContext, thread);
224
+ thisStack.pop();
225
+ if (expr.operator === "&&" && !l) {
226
+ thisStack.push(l);
227
+ return l;
228
+ }
229
+ if (expr.operator === "||" && l) {
230
+ thisStack.push(l);
231
+ return l;
232
+ }
233
+ const r = evaluator(thisStack, expr.right, evalContext, thread);
234
+ thisStack.pop();
235
+ return (0, eval_tree_common_1.evalBinaryCore)(l, r, thisStack, customOp, expr.operator);
236
+ }
237
+ function evalConditional(evaluator, thisStack, expr, evalContext, thread) {
238
+ const condition = evaluator(thisStack, expr.condition, evalContext, thread);
239
+ thisStack.pop();
240
+ return evaluator(thisStack, condition ? expr.consequent : expr.alternate, evalContext, thread);
241
+ }
242
+ function evalAssignment(evaluator, thisStack, expr, evalContext, thread) {
243
+ const leftValue = expr.leftValue;
244
+ evaluator(thisStack, leftValue, evalContext, thread);
245
+ thisStack.pop();
246
+ const newValue = evaluator(thisStack, expr.operand, evalContext, thread);
247
+ thisStack.pop();
248
+ return (0, eval_tree_common_1.evalAssignmentCore)(leftValue, newValue, thisStack, expr, thread);
249
+ }
250
+ function evalPreOrPost(evaluator, thisStack, expr, evalContext, thread) {
251
+ const operand = expr.operand;
252
+ evaluator(thisStack, operand, evalContext, thread);
253
+ thisStack.pop();
254
+ return (0, eval_tree_common_1.evalPreOrPostCore)(operand, thisStack, expr, evalContext, thread);
255
+ }
256
+ function evalFunctionInvocation(evaluator, thisStack, expr, evalContext, thread) {
257
+ var _a, _b, _c, _d;
258
+ let functionObj;
259
+ let implicitContextObject = null;
260
+ // --- Check for contexted object
261
+ if (expr.object.type === "MembE" && expr.object.object.type === "IdE") {
262
+ const hostObject = evaluator(thisStack, expr.object.object, evalContext, thread);
263
+ functionObj = (0, eval_tree_common_1.evalMemberAccessCore)(hostObject, thisStack, expr.object, evalContext);
264
+ if (hostObject === null || hostObject === void 0 ? void 0 : hostObject._SUPPORT_IMPLICIT_CONTEXT) {
265
+ implicitContextObject = hostObject;
266
+ }
267
+ }
268
+ else {
269
+ // --- Get the object on which to invoke the function
270
+ functionObj = evaluator(thisStack, expr.object, evalContext, thread);
271
+ }
272
+ thisStack.pop();
273
+ // --- Keep function arguments here, we pass it to the function later
274
+ const functionArgs = [];
275
+ // --- The functionObj may be an ArrowExpression. In this care we need to create the invokable arrow function
276
+ if (functionObj === null || functionObj === void 0 ? void 0 : functionObj._ARROW_EXPR_) {
277
+ functionArgs.push(functionObj.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
278
+ functionObj = createArrowFunction(evaluator, functionObj);
279
+ }
280
+ else if (expr.object.type === "ArrowE") {
281
+ // --- We delay evaluating expression values. We pass the argument names as the first parameter, and then
282
+ // --- all parameter expressions
283
+ functionArgs.push(expr.object.args, evalContext, thread, ...expr.arguments.map((a) => (Object.assign(Object.assign({}, a), { _EXPRESSION_: true }))));
284
+ }
285
+ else {
286
+ // --- We evaluate the argument values to pass to a JavaScript function
287
+ for (let i = 0; i < expr.arguments.length; i++) {
288
+ const arg = expr.arguments[i];
289
+ if (arg.type === "SpreadE") {
290
+ const funcArg = evaluator([], arg.operand, evalContext, thread);
291
+ if (!Array.isArray(funcArg)) {
292
+ throw new Error("Spread operator within a function invocation expects an array operand.");
293
+ }
294
+ functionArgs.push(...funcArg);
295
+ }
296
+ else {
297
+ if (arg.type === "ArrowE") {
298
+ const funcArg = createArrowFunction(evaluator, arg);
299
+ const wrappedFunc = (...args) => funcArg(arg.args, evalContext, thread, ...args);
300
+ functionArgs.push(wrappedFunc);
301
+ }
302
+ else {
303
+ const funcArg = evaluator([], arg, evalContext, thread);
304
+ if (funcArg === null || funcArg === void 0 ? void 0 : funcArg._ARROW_EXPR_) {
305
+ const wrappedFuncArg = createArrowFunction(evaluator, funcArg);
306
+ const wrappedFunc = (...args) => wrappedFuncArg(funcArg.args, evalContext, thread, ...args);
307
+ functionArgs.push(wrappedFunc);
308
+ }
309
+ else {
310
+ functionArgs.push(funcArg);
311
+ }
312
+ }
313
+ }
314
+ }
315
+ // --- We can pass implicit arguments to JavaScript function
316
+ if (implicitContextObject) {
317
+ // --- Let's obtain the implicit context
318
+ if (evalContext.implicitContextGetter) {
319
+ const implicitContext = evalContext.implicitContextGetter(implicitContextObject);
320
+ functionArgs.unshift(implicitContext);
321
+ }
322
+ else {
323
+ throw new Error("Cannot use implicitContextGetter, it is undefined");
324
+ }
325
+ }
326
+ }
327
+ // --- Check if the function is banned from running
328
+ const bannedInfo = (0, bannedFunctions_1.isBannedFunction)(functionObj);
329
+ if (bannedInfo.banned) {
330
+ throw new Error(`Function ${(_b = (_a = bannedInfo.func) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "unknown"} is not allowed to call. ${(_c = bannedInfo === null || bannedInfo === void 0 ? void 0 : bannedInfo.help) !== null && _c !== void 0 ? _c : ""}`);
331
+ }
332
+ // --- We use context for "this"
333
+ const currentContext = thisStack.length > 0 ? thisStack.pop() : evalContext.localContext;
334
+ // --- Now, invoke the function
335
+ const value = ((_d = evalContext.options) === null || _d === void 0 ? void 0 : _d.defaultToOptionalMemberAccess)
336
+ ? functionObj === null || functionObj === void 0 ? void 0 : functionObj.call(currentContext, ...functionArgs)
337
+ : functionObj.call(currentContext, ...functionArgs);
338
+ thisStack.push(value);
339
+ return value;
340
+ }
341
+ function createArrowFunction(evaluator, expr) {
342
+ // --- Use this function, it evaluates the arrow function
343
+ return (...args) => {
344
+ var _a;
345
+ // --- Prepare the variables to pass
346
+ const runTimeEvalContext = args[1];
347
+ const runtimeThread = args[2];
348
+ // --- Create the thread that runs the arrow function
349
+ const workingThread = {
350
+ parent: runtimeThread,
351
+ childThreads: [],
352
+ blocks: [{ vars: {} }],
353
+ loops: [],
354
+ breakLabelValue: -1,
355
+ closures: expr.closureContext,
356
+ };
357
+ runtimeThread.childThreads.push(workingThread);
358
+ // --- Assign argument values to names
359
+ const arrowBlock = { vars: {} };
360
+ (_a = workingThread.blocks) !== null && _a !== void 0 ? _a : (workingThread.blocks = []);
361
+ workingThread.blocks.push(arrowBlock);
362
+ const argSpecs = args[0];
363
+ for (let i = 0; i < argSpecs.length; i++) {
364
+ // --- Turn argument specification into processable variable declarations
365
+ const argSpec = argSpecs[i];
366
+ let decl;
367
+ switch (argSpec.type) {
368
+ case "IdE": {
369
+ decl = {
370
+ type: "VarD",
371
+ id: argSpec.name,
372
+ };
373
+ break;
374
+ }
375
+ case "Destr": {
376
+ decl = {
377
+ type: "VarD",
378
+ id: argSpec.id,
379
+ arrayDestruct: argSpec.arrayDestruct,
380
+ objectDestruct: argSpec.objectDestruct,
381
+ };
382
+ break;
383
+ }
384
+ default:
385
+ throw new Error("Unexpected arrow argument specification");
386
+ }
387
+ if (decl) {
388
+ // --- Get the actual value to work with
389
+ let argVal = args[i + 3];
390
+ if (argVal === null || argVal === void 0 ? void 0 : argVal._EXPRESSION_) {
391
+ argVal = evaluator([], argVal, runTimeEvalContext, runtimeThread);
392
+ }
393
+ (0, process_statement_sync_1.processDeclarations)(arrowBlock, runTimeEvalContext, runtimeThread, [decl], false, true, argVal);
394
+ }
395
+ }
396
+ // --- Evaluate the arrow expression body
397
+ let returnValue;
398
+ let statements;
399
+ switch (expr.statement.type) {
400
+ case "EmptyS":
401
+ statements = [];
402
+ break;
403
+ case "ExprS":
404
+ // --- Create a new thread for the call
405
+ statements = [
406
+ {
407
+ type: "RetS",
408
+ expression: expr.statement.expression,
409
+ },
410
+ ];
411
+ break;
412
+ case "BlockS":
413
+ // --- Create a new thread for the call
414
+ statements = expr.statement.statements;
415
+ break;
416
+ default:
417
+ throw new Error(`Arrow expression with a body of '${expr.statement.type}' is not supported yet.`);
418
+ }
419
+ // --- Process the statement with a new processor
420
+ (0, process_statement_sync_1.processStatementQueue)(statements, runTimeEvalContext, workingThread);
421
+ // --- Return value is in a return value slot
422
+ returnValue = workingThread.returnValue;
423
+ // --- Remove the current working thread
424
+ const workingIndex = runtimeThread.childThreads.indexOf(workingThread);
425
+ if (workingIndex < 0) {
426
+ throw new Error("Cannot find thread to remove.");
427
+ }
428
+ runtimeThread.childThreads.splice(workingIndex, 1);
429
+ // --- Remove the function level block
430
+ workingThread.blocks.pop();
431
+ // --- Return the function value
432
+ return returnValue;
433
+ };
434
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isModuleErrors = isModuleErrors;
4
+ exports.parseScriptModule = parseScriptModule;
5
+ const Parser_1 = require("../../parsers/scripting/Parser");
6
+ const Token_1 = require("../../abstractions/scripting/Token");
7
+ const process_statement_async_1 = require("./process-statement-async");
8
+ const tree_visitor_1 = require("../../parsers/scripting/tree-visitor");
9
+ const ParserError_1 = require("../../parsers/scripting/ParserError");
10
+ /**
11
+ * Checks if the result is a module error
12
+ * @param result Result to check
13
+ * @returns True if the result is a module error
14
+ */
15
+ function isModuleErrors(result) {
16
+ return result.type !== "ScriptModule";
17
+ }
18
+ /**
19
+ * Parses a script module
20
+ * @param moduleName Name of the module
21
+ * @param source Source code to parse
22
+ * @param moduleResolver A function that resolves a module path to the text of the module
23
+ * @returns The parsed and resolved module
24
+ */
25
+ function parseScriptModule(moduleName, source, moduleResolver, restrictiveMode = false) {
26
+ // --- Keep track of parsed modules to avoid circular references
27
+ const parsedModules = new Map();
28
+ const moduleErrors = {};
29
+ const parsedModule = doParseModule(moduleName, source, moduleResolver, true);
30
+ return !parsedModule || Object.keys(moduleErrors).length > 0 ? moduleErrors : parsedModule;
31
+ // --- Do the parsing, allow recursion
32
+ function doParseModule(moduleName, source, moduleResolver, topLevel = false) {
33
+ var _a;
34
+ // --- Do not parse the same module twice
35
+ if (parsedModules.has(moduleName)) {
36
+ return parsedModules.get(moduleName);
37
+ }
38
+ // --- Parse the source code
39
+ const parser = new Parser_1.Parser(source);
40
+ let statements = [];
41
+ try {
42
+ statements = parser.parseStatements();
43
+ }
44
+ catch (error) {
45
+ moduleErrors[moduleName] = parser.errors;
46
+ return null;
47
+ }
48
+ // --- Check for unparsed tail
49
+ const lastToken = parser.current;
50
+ if (lastToken.type !== Token_1.TokenType.Eof) {
51
+ (_a = moduleErrors[moduleName]) !== null && _a !== void 0 ? _a : (moduleErrors[moduleName] = []);
52
+ moduleErrors[moduleName].push({
53
+ code: "W002",
54
+ text: ParserError_1.errorMessages["W002"].replace(/\{(\d+)}/g, () => lastToken.text),
55
+ position: lastToken.location.startLine,
56
+ line: lastToken.location.startLine,
57
+ column: lastToken.location.startColumn,
58
+ });
59
+ return null;
60
+ }
61
+ const errors = [];
62
+ // --- Visit all statements in the module
63
+ const emptyState = {
64
+ data: null,
65
+ cancel: false,
66
+ skipChildren: false,
67
+ };
68
+ (0, tree_visitor_1.visitNode)(statements, emptyState, (before, stmt, state, parent, tag) => {
69
+ if (!before)
70
+ return state;
71
+ if (topLevel) {
72
+ // --- Restrict top-level statements
73
+ switch (stmt.type) {
74
+ case "VarS":
75
+ // --- Allow on top-level var declarations in a top-level module
76
+ if (parent) {
77
+ addErrorMessage("W027", stmt);
78
+ }
79
+ break;
80
+ case "FuncD":
81
+ case "ImportD":
82
+ break;
83
+ default:
84
+ if (restrictiveMode && !parent) {
85
+ addErrorMessage("W028", stmt, stmt.type);
86
+ }
87
+ break;
88
+ }
89
+ }
90
+ else {
91
+ switch (stmt.type) {
92
+ case "VarS":
93
+ addErrorMessage("W027", stmt);
94
+ break;
95
+ case "FuncD":
96
+ if (restrictiveMode && !stmt.isExported) {
97
+ addErrorMessage("W029", stmt);
98
+ }
99
+ break;
100
+ case "ImportD":
101
+ break;
102
+ default:
103
+ if (restrictiveMode && !parent) {
104
+ addErrorMessage("W028", stmt, stmt.type);
105
+ }
106
+ break;
107
+ }
108
+ }
109
+ return state;
110
+ });
111
+ // // --- Check for forbidden "var" declarations
112
+ // statements.forEach((stmt) => {
113
+ // if (topLevel) {
114
+ // // --- Restrict top-level statements
115
+ // switch (stmt.type) {
116
+ // case "VarS":
117
+ // case "FuncD":
118
+ // case "ImportD":
119
+ // break;
120
+ // default:
121
+ // if (restrictiveMode) {
122
+ // addErrorMessage("W028", stmt, stmt.type);
123
+ // }
124
+ // break;
125
+ // }
126
+ // } else {
127
+ // switch (stmt.type) {
128
+ // case "VarS":
129
+ // addErrorMessage("W027", stmt);
130
+ // break;
131
+ // case "FuncD":
132
+ // if (restrictiveMode && !stmt.isExported) {
133
+ // addErrorMessage("W029", stmt);
134
+ // }
135
+ // break;
136
+ // case "ImportD":
137
+ // break;
138
+ // default:
139
+ // if (restrictiveMode) {
140
+ // addErrorMessage("W028", stmt, stmt.type);
141
+ // }
142
+ // break;
143
+ // }
144
+ // }
145
+ // });
146
+ // --- Hoist functions
147
+ const functions = {};
148
+ statements
149
+ .filter((stmt) => stmt.type === "FuncD")
150
+ .forEach((stmt) => {
151
+ const func = stmt;
152
+ if (functions[func.name]) {
153
+ addErrorMessage("W020", stmt, func.name);
154
+ return;
155
+ }
156
+ functions[func.name] = func;
157
+ });
158
+ // --- Collect exports
159
+ const exports = new Map();
160
+ statements.forEach((stmt) => {
161
+ if (stmt.type === "ConstS" && stmt.isExported) {
162
+ (0, process_statement_async_1.visitLetConstDeclarations)(stmt, (id) => {
163
+ if (exports.has(id)) {
164
+ addErrorMessage("W021", stmt, id);
165
+ }
166
+ else {
167
+ exports.set(id, stmt);
168
+ }
169
+ });
170
+ }
171
+ else if (stmt.type === "FuncD" && stmt.isExported) {
172
+ if (exports.has(stmt.name)) {
173
+ addErrorMessage("W021", stmt, stmt.name);
174
+ }
175
+ else {
176
+ exports.set(stmt.name, stmt);
177
+ }
178
+ }
179
+ });
180
+ // --- Successful module parsing
181
+ const parsedModule = {
182
+ type: "ScriptModule",
183
+ name: moduleName,
184
+ exports,
185
+ importedModules: [],
186
+ imports: [],
187
+ functions,
188
+ statements,
189
+ executed: false,
190
+ };
191
+ // --- Sign this module as parsed
192
+ parsedModules.set(moduleName, parsedModule);
193
+ // --- Load imported modules and resolve imports
194
+ const importedModules = [];
195
+ const imports = {};
196
+ for (let i = 0; i < statements.length; i++) {
197
+ const stmt = statements[i];
198
+ if (stmt.type !== "ImportD") {
199
+ continue;
200
+ }
201
+ // --- Find the imported module
202
+ const source = moduleResolver(moduleName, stmt.moduleFile);
203
+ if (source === null) {
204
+ addErrorMessage("W022", stmt, stmt.moduleFile);
205
+ continue;
206
+ }
207
+ // --- Parse the imported module
208
+ const imported = doParseModule(stmt.moduleFile, source, moduleResolver);
209
+ if (!imported) {
210
+ // --- Error in the imported module
211
+ return;
212
+ }
213
+ // --- Successful import
214
+ importedModules.push(imported);
215
+ // --- Extract imported names
216
+ for (const key in stmt.imports) {
217
+ if (imported.exports.has(stmt.imports[key])) {
218
+ imports[key] = imported.exports.get(stmt.imports[key]);
219
+ }
220
+ else {
221
+ addErrorMessage("W023", stmt, stmt.moduleFile, key);
222
+ }
223
+ }
224
+ }
225
+ // --- Catch errors
226
+ if (errors.length > 0) {
227
+ moduleErrors[moduleName] = errors;
228
+ return null;
229
+ }
230
+ // --- All imported modules use this module as a parent
231
+ importedModules.forEach((m) => (m.parent = parsedModule));
232
+ // --- Done.
233
+ parsedModule.importedModules = importedModules;
234
+ parsedModule.imports = imports;
235
+ return parsedModule;
236
+ function addErrorMessage(code, stmt, ...args) {
237
+ let errorText = ParserError_1.errorMessages[code];
238
+ if (args) {
239
+ args.forEach((o, idx) => (errorText = errorText.replaceAll(`{${idx}}`, args[idx].toString())));
240
+ }
241
+ errors.push({
242
+ code,
243
+ text: ParserError_1.errorMessages[code].replace(/\{(\d+)}/g, (_, index) => args[index]),
244
+ position: stmt.startPosition,
245
+ line: stmt.startLine,
246
+ column: stmt.startColumn,
247
+ });
248
+ }
249
+ }
250
+ }