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,922 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onPrefixRegex = exports.UCRegex = exports.COMPOUND_COMP_ID = void 0;
4
+ exports.nodeToComponentDef = nodeToComponentDef;
5
+ const syntax_kind_1 = require("./syntax-kind");
6
+ const ParserError_1 = require("../ueml/ParserError");
7
+ const Parser_1 = require("../scripting/Parser");
8
+ const code_behind_collect_1 = require("../scripting/code-behind-collect");
9
+ const BindingTreeEvaluationContext_1 = require("../../components-core/script-runner/BindingTreeEvaluationContext");
10
+ const CharacterCodes_1 = require("./CharacterCodes");
11
+ exports.COMPOUND_COMP_ID = "Component";
12
+ exports.UCRegex = /^[A-Z]/;
13
+ exports.onPrefixRegex = /^on[A-Z]/;
14
+ const propAttrs = ["name", "value"];
15
+ const CDATA_PREFIX_LEN = 9;
16
+ const CDATA_POSTFIX_LEN = 3;
17
+ function nodeToComponentDef(node, originalGetText, moduleResolver = () => "") {
18
+ const getText = (node) => {
19
+ var _a;
20
+ return (_a = node.text) !== null && _a !== void 0 ? _a : originalGetText(node);
21
+ };
22
+ // --- Check that the nodes contains exactly only a single component root element before the EoF token
23
+ if (node.children.length !== 2) {
24
+ reportError("T001");
25
+ return null;
26
+ }
27
+ // --- Ensure it's a component
28
+ const element = node.children[0];
29
+ if (element.kind !== syntax_kind_1.SyntaxKind.ElementNode) {
30
+ reportError("T001");
31
+ return null;
32
+ }
33
+ const preppedElement = prepNode(element);
34
+ const name = getTagName(element);
35
+ if (!exports.UCRegex.test(name)) {
36
+ reportError("T002");
37
+ return null;
38
+ }
39
+ const usesStack = [];
40
+ return transformSingleElement(usesStack, preppedElement);
41
+ function transformSingleElement(usesStack, node) {
42
+ const name = getTagName(node);
43
+ const attrs = getAttributes(node).map(segmentAttr);
44
+ let component;
45
+ if (name === exports.COMPOUND_COMP_ID) {
46
+ // --- Validate component name
47
+ const compoundName = attrs.find((attr) => attr.name === "name");
48
+ if (!compoundName) {
49
+ reportError("T003");
50
+ return null;
51
+ }
52
+ if (!exports.UCRegex.test(compoundName.value)) {
53
+ reportError("T004");
54
+ return null;
55
+ }
56
+ // --- Get "api" attributes
57
+ let api;
58
+ const apiAttrs = attrs.filter((attr) => attr.startSegment === "api");
59
+ if (apiAttrs.length > 0) {
60
+ api = {};
61
+ apiAttrs.forEach((attr) => {
62
+ api[attr.name] = attr.value;
63
+ });
64
+ }
65
+ // --- Get "var" attributes
66
+ let vars;
67
+ const varsAttrs = attrs.filter((attr) => attr.startSegment === "var");
68
+ if (varsAttrs.length > 0) {
69
+ vars = {};
70
+ varsAttrs.forEach((attr) => {
71
+ vars[attr.name] = attr.value;
72
+ });
73
+ }
74
+ const children = getChildNodes(node);
75
+ // --- Check for nested component
76
+ const nestedCompound = children.find((child) => child.kind === syntax_kind_1.SyntaxKind.ElementNode && getTagName(child) === exports.COMPOUND_COMP_ID);
77
+ if (nestedCompound) {
78
+ reportError("T006");
79
+ return null;
80
+ }
81
+ // --- Get the single component definition
82
+ const nestedComponents = children.filter((child) => child.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getTagName(child)));
83
+ if (nestedComponents.length === 0) {
84
+ nestedComponents.push(createTextNodeElement(""));
85
+ }
86
+ const childrenToCollect = [];
87
+ const nestedVars = [];
88
+ for (let child of children) {
89
+ if (child.kind === syntax_kind_1.SyntaxKind.ElementNode) {
90
+ const childName = getTagName(child);
91
+ if (childName === "var") {
92
+ nestedVars.push(child);
93
+ }
94
+ else if (!exports.UCRegex.test(childName)) {
95
+ childrenToCollect.push(child);
96
+ }
97
+ }
98
+ }
99
+ // --- Should we use a Fragment?
100
+ if (nestedComponents.length > 1 || nestedVars.length > 0) {
101
+ // --- Wrap the children in a Fragment
102
+ const fragmentElement = wrapWithFragment([...nestedVars, ...nestedComponents]);
103
+ const nestedFragment = transformSingleElement(usesStack, fragmentElement);
104
+ component = {
105
+ name: compoundName.value,
106
+ component: nestedFragment,
107
+ };
108
+ if (api) {
109
+ component.api = api;
110
+ }
111
+ if (vars) {
112
+ nestedFragment.vars = Object.assign(Object.assign({}, nestedFragment.vars), vars);
113
+ }
114
+ }
115
+ else {
116
+ // --- Search for the element, take a note of the preceding comment
117
+ const element = nestedComponents[0];
118
+ const nestedComponent = transformSingleElement(usesStack, element);
119
+ // --- Create the component
120
+ component = {
121
+ name: compoundName.value,
122
+ component: nestedComponent,
123
+ };
124
+ if (api) {
125
+ component.api = api;
126
+ }
127
+ if (vars) {
128
+ nestedComponent.vars = Object.assign(Object.assign({}, nestedComponent.vars), vars);
129
+ }
130
+ }
131
+ const nodeClone = withNewChildNodes(node, childrenToCollect);
132
+ collectTraits(usesStack, component, nodeClone);
133
+ return component;
134
+ }
135
+ // --- Not a reusable component
136
+ if (!exports.UCRegex.test(name)) {
137
+ reportError("T002");
138
+ return null;
139
+ }
140
+ component = {
141
+ type: name,
142
+ };
143
+ // --- Done
144
+ collectTraits(usesStack, component, node);
145
+ return component;
146
+ }
147
+ /**
148
+ * Collects component traits from attributes and child elements
149
+ * @param comp Component definition
150
+ * @param element Component element
151
+ */
152
+ function collectTraits(usesStack, comp, element) {
153
+ var _a, _b;
154
+ const isCompound = !isComponent(comp);
155
+ const attributes = getAttributes(element);
156
+ // --- Process attributes
157
+ attributes.forEach((attr) => {
158
+ // --- Process the attribute
159
+ collectAttribute(comp, attr);
160
+ });
161
+ const childNodes = getChildNodes(element);
162
+ // --- Process child nodes
163
+ childNodes.forEach((child) => {
164
+ var _a;
165
+ if (child.kind === syntax_kind_1.SyntaxKind.Script) {
166
+ if (getAttributes(child).length > 0) {
167
+ reportError("T022");
168
+ }
169
+ const scriptText = getText(child);
170
+ const scriptContent = scriptText.slice(scriptText.indexOf(">") + 1, scriptText.lastIndexOf("</"));
171
+ (_a = comp.script) !== null && _a !== void 0 ? _a : (comp.script = "");
172
+ if (comp.script.length > 0) {
173
+ comp.script += "\n";
174
+ }
175
+ comp.script += scriptContent;
176
+ return;
177
+ }
178
+ const childName = getTagName(child);
179
+ if (isCompound && child.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(childName)) {
180
+ // --- This is the single nested component definition of a compound component,
181
+ // --- it is already processed
182
+ return;
183
+ }
184
+ // --- Single text element, consider it a child name
185
+ if (child.kind === syntax_kind_1.SyntaxKind.TextNode && !isCompound) {
186
+ comp.children = mergeValue(comp.children, getText(child));
187
+ }
188
+ // --- It should not happen, but just for being safe...
189
+ // todo:
190
+ // if (child.kind !== SyntaxKind.node) throw new Error("should not happen");
191
+ // --- Element name starts with an uppercase letter
192
+ if (exports.UCRegex.test(childName) && !isCompound) {
193
+ // --- This must be a child component
194
+ const childComponent = transformSingleElement(usesStack, child);
195
+ if (childComponent) {
196
+ if (!comp.children) {
197
+ comp.children = [childComponent];
198
+ }
199
+ else {
200
+ if (typeof comp.children === "string") {
201
+ comp.children = [comp.children, childComponent];
202
+ }
203
+ else if (Array.isArray(comp.children)) {
204
+ comp.children.push(childComponent);
205
+ }
206
+ }
207
+ }
208
+ return;
209
+ }
210
+ // --- Element with a lowercase start letter, it must be some traits of the host component
211
+ switch (childName) {
212
+ case "prop":
213
+ collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.props) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
214
+ var _a;
215
+ if (!isComponent(comp))
216
+ return;
217
+ (_a = comp.props) !== null && _a !== void 0 ? _a : (comp.props = {});
218
+ comp.props[name] = value;
219
+ });
220
+ return;
221
+ case "event":
222
+ collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.events) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
223
+ var _a;
224
+ if (!isComponent(comp))
225
+ return;
226
+ (_a = comp.events) !== null && _a !== void 0 ? _a : (comp.events = {});
227
+ comp.events[name] = value;
228
+ }, (name) => {
229
+ if (exports.onPrefixRegex.test(name)) {
230
+ reportError("T008", name);
231
+ }
232
+ });
233
+ return;
234
+ case "var":
235
+ collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.vars) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
236
+ var _a;
237
+ if (!isComponent(comp))
238
+ return;
239
+ (_a = comp.vars) !== null && _a !== void 0 ? _a : (comp.vars = {});
240
+ comp.vars[name] = value;
241
+ });
242
+ return;
243
+ case "loaders":
244
+ collectLoadersElements(usesStack, comp, child);
245
+ return;
246
+ case "uses":
247
+ collectUsesElements(comp, child);
248
+ return;
249
+ case "api":
250
+ collectElementHelper(usesStack, comp, child, (name) => { var _a; return (isComponent(comp) ? (_a = comp.api) === null || _a === void 0 ? void 0 : _a[name] : undefined); }, (name, value) => {
251
+ var _a;
252
+ (_a = comp.api) !== null && _a !== void 0 ? _a : (comp.api = {});
253
+ comp.api[name] = value;
254
+ });
255
+ return;
256
+ default:
257
+ reportError("T009", childName);
258
+ return;
259
+ }
260
+ });
261
+ if (!comp.script || comp.script.trim().length === 0) {
262
+ // --- No (or whitespace only) script
263
+ return;
264
+ }
265
+ // --- Run the parse and collect on scripts
266
+ const parser = new Parser_1.Parser(comp.script);
267
+ try {
268
+ // --- We parse the module file to catch parsing errors
269
+ parser.parseStatements();
270
+ const evalContext = (0, BindingTreeEvaluationContext_1.createEvalContext)({});
271
+ comp.scriptCollected = (0, code_behind_collect_1.collectCodeBehindFromSource)("Main", comp.script, moduleResolver, evalContext);
272
+ }
273
+ catch (err) {
274
+ if (parser.errors && parser.errors.length > 0) {
275
+ comp.scriptError = parser.errors;
276
+ }
277
+ else {
278
+ comp.scriptError = err;
279
+ }
280
+ }
281
+ // --- We may have module parsing/execution errors
282
+ const moduleErrors = (_b = (_a = comp.scriptCollected) === null || _a === void 0 ? void 0 : _a.moduleErrors) !== null && _b !== void 0 ? _b : {};
283
+ if (Object.keys(moduleErrors).length > 0) {
284
+ comp.scriptError = moduleErrors;
285
+ }
286
+ }
287
+ function collectAttribute(comp, attr) {
288
+ var _a, _b, _c, _d, _e;
289
+ const { startSegment, name, value } = segmentAttr(attr);
290
+ const isCompound = !isComponent(comp);
291
+ // --- Handle single-word attributes
292
+ if (isCompound) {
293
+ if (startSegment && startSegment !== "api" && startSegment !== "var") {
294
+ reportError("T021");
295
+ return;
296
+ }
297
+ if (name === "name" && !startSegment) {
298
+ // --- We already processed name
299
+ return;
300
+ }
301
+ // --- Compound components do not have any other attributable props
302
+ if (!startSegment && name) {
303
+ reportError("T021", name);
304
+ }
305
+ return;
306
+ }
307
+ // --- Do not allow segmented attribute names
308
+ if (name.indexOf(".") >= 0) {
309
+ reportError("T007", name);
310
+ return;
311
+ }
312
+ // --- Recognize special attributes by component definition type
313
+ switch (name) {
314
+ case "id":
315
+ comp.uid = value;
316
+ return;
317
+ case "testId":
318
+ comp.testId = value;
319
+ return;
320
+ case "when":
321
+ comp.when = value;
322
+ return;
323
+ default:
324
+ if (startSegment === "var") {
325
+ (_a = comp.vars) !== null && _a !== void 0 ? _a : (comp.vars = {});
326
+ comp.vars[name] = value;
327
+ }
328
+ else if (startSegment === "api") {
329
+ (_b = comp.api) !== null && _b !== void 0 ? _b : (comp.api = {});
330
+ comp.api[name] = value;
331
+ }
332
+ else if (startSegment === "event") {
333
+ (_c = comp.events) !== null && _c !== void 0 ? _c : (comp.events = {});
334
+ comp.events[name] = value;
335
+ }
336
+ else if (exports.onPrefixRegex.test(name)) {
337
+ (_d = comp.events) !== null && _d !== void 0 ? _d : (comp.events = {});
338
+ const eventName = name[2].toLowerCase() + name.substring(3);
339
+ comp.events[eventName] = value;
340
+ }
341
+ else {
342
+ (_e = comp.props) !== null && _e !== void 0 ? _e : (comp.props = {});
343
+ comp.props[name] = value;
344
+ }
345
+ return;
346
+ }
347
+ }
348
+ function collectObjectOrArray(usesStack, children) {
349
+ let result = null;
350
+ // --- No children, it's a null object
351
+ if (!children)
352
+ return result;
353
+ let nestedElementType = null;
354
+ children.forEach((child) => {
355
+ if (child.kind === syntax_kind_1.SyntaxKind.TextNode) {
356
+ result = mergeValue(result, getText(child));
357
+ return;
358
+ }
359
+ if (child.kind !== syntax_kind_1.SyntaxKind.ElementNode)
360
+ return;
361
+ const childName = getTagName(child);
362
+ // --- The only element names we accept are "field" or "item"
363
+ if (childName !== "field" && childName !== "item") {
364
+ reportError("T016");
365
+ return;
366
+ }
367
+ if (childName === "field") {
368
+ if (!nestedElementType) {
369
+ // --- First nested element is "field", so we have an object
370
+ nestedElementType = childName;
371
+ result = {};
372
+ }
373
+ else if (nestedElementType !== childName) {
374
+ reportError("T017");
375
+ return;
376
+ }
377
+ }
378
+ else if (childName === "item") {
379
+ if (!nestedElementType) {
380
+ // --- First nested element is "item", so we have an array
381
+ nestedElementType = childName;
382
+ result = [];
383
+ }
384
+ else if (nestedElementType !== childName) {
385
+ reportError("T017");
386
+ return;
387
+ }
388
+ }
389
+ // --- Get the field value
390
+ let valueInfo = collectValue(usesStack, child, childName === "field");
391
+ if (!valueInfo) {
392
+ return null;
393
+ }
394
+ // --- Does the field have a value?
395
+ if (nestedElementType === "field") {
396
+ result[valueInfo.name] = valueInfo.value;
397
+ }
398
+ else {
399
+ result.push(valueInfo.value);
400
+ }
401
+ });
402
+ return result;
403
+ }
404
+ function collectValue(usesStack, element, allowName = true) {
405
+ const elementName = getTagName(element);
406
+ // --- Accept only "name", "value"
407
+ const childNodes = getChildNodes(element);
408
+ const nestedComponents = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getTagName(c)));
409
+ const nestedElements = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && !exports.UCRegex.test(getTagName(c)));
410
+ const attributes = getAttributes(element).map(segmentAttr);
411
+ const attrProps = attributes.filter((attr) => propAttrs.indexOf(attr.name) >= 0);
412
+ if (attributes.length > attrProps.length) {
413
+ reportError("T011", elementName);
414
+ return null;
415
+ }
416
+ // --- Validate the "name" usage
417
+ const nameAttr = attrProps.find((attr) => attr.name === "name");
418
+ if (allowName) {
419
+ if (!(nameAttr === null || nameAttr === void 0 ? void 0 : nameAttr.value)) {
420
+ reportError("T012", elementName);
421
+ return null;
422
+ }
423
+ }
424
+ else {
425
+ if (nameAttr) {
426
+ reportError("T018", elementName);
427
+ return null;
428
+ }
429
+ }
430
+ const name = nameAttr === null || nameAttr === void 0 ? void 0 : nameAttr.value;
431
+ // --- Get the value attribute
432
+ const valueAttr = attrProps.find((attr) => attr.name === "value");
433
+ if (valueAttr && valueAttr.value === undefined) {
434
+ reportError("T019", elementName);
435
+ return null;
436
+ }
437
+ // --- Let's handle a special case, when the value is a component definition
438
+ if (name && nestedComponents.length >= 1) {
439
+ if (nestedElements.length > 0) {
440
+ reportError("T020");
441
+ return null;
442
+ }
443
+ // --- We expect a component definition here!
444
+ const nestedComps = nestedComponents.map((nc) => transformSingleElement(usesStack, nc));
445
+ return { name, value: nestedComps.length === 1 ? nestedComps[0] : nestedComps };
446
+ }
447
+ // --- At this point, all attributes are ok, let's get the value.
448
+ let value = valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.value;
449
+ if (value === null) {
450
+ return null;
451
+ }
452
+ if (typeof value === "string") {
453
+ return { name, value };
454
+ }
455
+ return { name, value: collectObjectOrArray(usesStack, childNodes) };
456
+ }
457
+ function collectLoadersElements(usesStack, comp, loaders) {
458
+ var _a, _b;
459
+ if (!isComponent(comp)) {
460
+ reportError("T009", "loaders");
461
+ return;
462
+ }
463
+ const children = getChildNodes(loaders);
464
+ //todo: this check seems not necesarry
465
+ if (children.length === 0) {
466
+ (_a = comp.loaders) !== null && _a !== void 0 ? _a : (comp.loaders = []);
467
+ }
468
+ const hasAttribute = (_b = loaders.children) === null || _b === void 0 ? void 0 : _b.some((c) => c.kind === syntax_kind_1.SyntaxKind.AttributeListNode);
469
+ if (hasAttribute) {
470
+ reportError("T014", "attributes");
471
+ return;
472
+ }
473
+ children.forEach((loader) => {
474
+ var _a;
475
+ // --- Test is not supported
476
+ if (loader.kind === syntax_kind_1.SyntaxKind.TextNode) {
477
+ reportError("T010", "loader");
478
+ return;
479
+ }
480
+ // todo: is this needed?
481
+ // --- Just for the sake of being sure...
482
+ // if (loader.type !== "Element") return;
483
+ const loaderDef = transformSingleElement(usesStack, loader);
484
+ // --- Get the uid value
485
+ if (!loaderDef.uid) {
486
+ reportError("T013");
487
+ return;
488
+ }
489
+ // --- Check props that a loader must not have
490
+ if (loaderDef.vars) {
491
+ reportError("T014", "vars");
492
+ return;
493
+ }
494
+ if (loaderDef.loaders) {
495
+ reportError("T014", "loaders");
496
+ return;
497
+ }
498
+ if (loaderDef.uses) {
499
+ reportError("T014", "uses");
500
+ return;
501
+ }
502
+ // --- Store this loader
503
+ (_a = comp.loaders) !== null && _a !== void 0 ? _a : (comp.loaders = []);
504
+ comp.loaders.push(loaderDef);
505
+ });
506
+ }
507
+ function collectElementHelper(usesStack, comp, child, getter, setter, nameValidator) {
508
+ // --- Compound component do not have a uses
509
+ var _a;
510
+ // --- Get the value
511
+ const valueInfo = collectValue(usesStack, child);
512
+ if (!valueInfo) {
513
+ return;
514
+ }
515
+ // --- Extra name validation, if required so
516
+ nameValidator === null || nameValidator === void 0 ? void 0 : nameValidator((_a = valueInfo === null || valueInfo === void 0 ? void 0 : valueInfo.name) !== null && _a !== void 0 ? _a : "");
517
+ const name = valueInfo.name;
518
+ const value = valueInfo.value;
519
+ if ((valueInfo === null || valueInfo === void 0 ? void 0 : valueInfo.value) !== undefined) {
520
+ setter(name, mergeValue(getter(name), value));
521
+ }
522
+ else {
523
+ // --- Consider the value to be null; check optional child items
524
+ const children = getChildNodes(child);
525
+ const itemValue = collectObjectOrArray(usesStack, children);
526
+ let updatedValue = getter(name);
527
+ updatedValue = mergeValue(updatedValue, itemValue);
528
+ setter(name, updatedValue);
529
+ }
530
+ }
531
+ function collectUsesElements(comp, uses) {
532
+ var _a;
533
+ // --- Compound component do not have a uses
534
+ if (!isComponent(comp)) {
535
+ reportError("T009", "uses");
536
+ return;
537
+ }
538
+ const attributes = getAttributes(uses).map(segmentAttr);
539
+ const valueAttr = attributes.find((attr) => attr.name === "value");
540
+ if (!(valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.value) || attributes.length !== 1) {
541
+ reportError("T015", "uses");
542
+ return;
543
+ }
544
+ // --- Extract the value
545
+ (_a = comp.uses) !== null && _a !== void 0 ? _a : (comp.uses = valueAttr.value.split(",").map((v) => v.trim()));
546
+ }
547
+ function getTagName(node) {
548
+ const nameTokens = node.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode).children;
549
+ const name = nameTokens[nameTokens.length - 1];
550
+ return getText(name);
551
+ }
552
+ function segmentAttr(attr) {
553
+ let key = getText(attr.children[0]);
554
+ const segments = key.split(".");
555
+ if (segments.length > 2) {
556
+ reportError("T007", attr, key);
557
+ }
558
+ let startSegment;
559
+ let name = key;
560
+ if (segments.length === 2) {
561
+ startSegment = segments[0];
562
+ name = segments[1];
563
+ if (name.trim() === "") {
564
+ reportError("T007", attr, name);
565
+ }
566
+ }
567
+ const valueText = getText(attr.children[2]);
568
+ const value = valueText.substring(1, valueText.length - 1);
569
+ return { startSegment, name, value };
570
+ }
571
+ function parseEscapeCharactersInAttrValues(attrs) {
572
+ for (let attr of attrs) {
573
+ const attrValue = attr.children[attr.children.length - 1];
574
+ const escapedText = tryEscapeEntities(getText(attrValue));
575
+ if (escapedText !== null) {
576
+ attrValue.text = escapedText;
577
+ }
578
+ }
579
+ }
580
+ function prepNode(node) {
581
+ const childNodes = getChildNodes(node);
582
+ const tagName = getTagName(node);
583
+ const hasComponentName = exports.UCRegex.test(tagName);
584
+ const shouldUseTextNodeElement = hasComponentName || tagName === "prop";
585
+ const shouldCollapseWhitespace = tagName !== "event" && tagName !== "api";
586
+ parseEscapeCharactersInAttrValues(getAttributes(node));
587
+ parseEscapeCharactersInContent(childNodes);
588
+ mergeConsecutiveTexts(childNodes, shouldCollapseWhitespace);
589
+ let shouldUseCData = false;
590
+ let hasScriptChild = false;
591
+ for (let i = 0; i < childNodes.length; ++i) {
592
+ const child = childNodes[i];
593
+ let newChild;
594
+ if (child.kind == syntax_kind_1.SyntaxKind.Script) {
595
+ hasScriptChild = true;
596
+ continue;
597
+ }
598
+ if (child.kind === syntax_kind_1.SyntaxKind.ElementNode) {
599
+ newChild = prepNode(child);
600
+ childNodes[i] = newChild;
601
+ continue;
602
+ }
603
+ let textValue = getText(child);
604
+ if (child.kind === syntax_kind_1.SyntaxKind.StringLiteral) {
605
+ textValue = textValue.slice(1, -1);
606
+ }
607
+ else if (child.kind === syntax_kind_1.SyntaxKind.CData) {
608
+ shouldUseCData = true;
609
+ }
610
+ else if (child.kind === syntax_kind_1.SyntaxKind.TextNode) {
611
+ }
612
+ if (shouldUseTextNodeElement) {
613
+ if (shouldUseCData) {
614
+ newChild = createTextNodeCDataElement(textValue);
615
+ }
616
+ else {
617
+ newChild = createTextNodeElement(textValue);
618
+ }
619
+ }
620
+ else {
621
+ newChild = { kind: syntax_kind_1.SyntaxKind.TextNode, text: textValue };
622
+ }
623
+ childNodes[i] = newChild;
624
+ }
625
+ const helperNodes = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && !exports.UCRegex.test(getTagName(c)));
626
+ const otherNodes = childNodes.filter((c) => c.kind !== syntax_kind_1.SyntaxKind.ElementNode || (c.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getTagName(c))));
627
+ const hasComponentChild = otherNodes.some((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getTagName(c)));
628
+ if (hasScriptChild && hasComponentChild) {
629
+ const fragment = wrapWithFragment(otherNodes);
630
+ helperNodes.push(fragment);
631
+ return withNewChildNodes(node, helperNodes);
632
+ }
633
+ return node;
634
+ }
635
+ function collapseWhitespace(childNodes) {
636
+ for (let i = 0; i < childNodes.length; ++i) {
637
+ if (childNodes[i].kind === syntax_kind_1.SyntaxKind.StringLiteral || childNodes[i].kind === syntax_kind_1.SyntaxKind.TextNode) {
638
+ //the union is the same as \s , but took \u00a0 (non breaking space) out
639
+ //source https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Cheatsheet
640
+ const allSubsequentWsExceptNonBreakingSpace = /[\f\n\r\t\v\u0020\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/g;
641
+ childNodes[i].text = getText(childNodes[i]).replace(allSubsequentWsExceptNonBreakingSpace, " ");
642
+ }
643
+ }
644
+ }
645
+ function stripCDataWrapper(childNodes) {
646
+ for (let i = 0; i < childNodes.length; ++i) {
647
+ if (childNodes[i].kind === syntax_kind_1.SyntaxKind.CData) {
648
+ childNodes[i].text = getText(childNodes[i]).slice(CDATA_PREFIX_LEN, -CDATA_POSTFIX_LEN);
649
+ }
650
+ }
651
+ }
652
+ function parseEscapeCharactersInContent(childNodes) {
653
+ for (let node of childNodes) {
654
+ if (node.kind === syntax_kind_1.SyntaxKind.StringLiteral || node.kind === syntax_kind_1.SyntaxKind.TextNode) {
655
+ const escapedText = tryEscapeEntities(getText(node));
656
+ if (escapedText !== null) {
657
+ node.text = escapedText;
658
+ }
659
+ }
660
+ }
661
+ }
662
+ function tryEscapeEntities(text) {
663
+ let newText = "";
664
+ let startOfSubstr = 0;
665
+ for (let i = 0; i < text.length; ++i) {
666
+ if (text.charCodeAt(i) === CharacterCodes_1.CharacterCodes.ampersand) {
667
+ switch (text.charCodeAt(i + 1)) {
668
+ //&a
669
+ case CharacterCodes_1.CharacterCodes.a:
670
+ switch (text.charCodeAt(i + 2)) {
671
+ //am
672
+ case CharacterCodes_1.CharacterCodes.m:
673
+ //amp;
674
+ if (text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.p &&
675
+ text.charCodeAt(i + 4) === CharacterCodes_1.CharacterCodes.semicolon) {
676
+ newText = newText + text.substring(startOfSubstr, i) + "&";
677
+ i += 4;
678
+ startOfSubstr = i + 1;
679
+ }
680
+ break;
681
+ //ap
682
+ case CharacterCodes_1.CharacterCodes.p:
683
+ //apos;
684
+ if (text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.o &&
685
+ text.charCodeAt(i + 4) === CharacterCodes_1.CharacterCodes.s &&
686
+ text.charCodeAt(i + 5) === CharacterCodes_1.CharacterCodes.semicolon) {
687
+ newText = newText + text.substring(startOfSubstr, i) + "'";
688
+ i += 5;
689
+ startOfSubstr = i + 1;
690
+ }
691
+ break;
692
+ }
693
+ break;
694
+ //&g
695
+ case CharacterCodes_1.CharacterCodes.g:
696
+ //\gt;
697
+ if (text.charCodeAt(i + 2) === CharacterCodes_1.CharacterCodes.t && text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.semicolon) {
698
+ newText = newText + text.substring(startOfSubstr, i) + ">";
699
+ i += 3;
700
+ startOfSubstr = i + 1;
701
+ }
702
+ break;
703
+ //&l
704
+ case CharacterCodes_1.CharacterCodes.l:
705
+ //&lt;
706
+ if (text.charCodeAt(i + 2) === CharacterCodes_1.CharacterCodes.t && text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.semicolon) {
707
+ newText = newText + text.substring(startOfSubstr, i) + "<";
708
+ i += 3;
709
+ startOfSubstr = i + 1;
710
+ }
711
+ break;
712
+ //&q
713
+ case CharacterCodes_1.CharacterCodes.q:
714
+ //&quot;
715
+ if (text.charCodeAt(i + 2) === CharacterCodes_1.CharacterCodes.u &&
716
+ text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.o &&
717
+ text.charCodeAt(i + 4) === CharacterCodes_1.CharacterCodes.t &&
718
+ text.charCodeAt(i + 5) === CharacterCodes_1.CharacterCodes.semicolon) {
719
+ newText = newText + text.substring(startOfSubstr, i) + '"';
720
+ i += 5;
721
+ startOfSubstr = i + 1;
722
+ }
723
+ break;
724
+ //&n
725
+ case CharacterCodes_1.CharacterCodes.n:
726
+ //&nbsp;
727
+ if (text.charCodeAt(i + 2) === CharacterCodes_1.CharacterCodes.b &&
728
+ text.charCodeAt(i + 3) === CharacterCodes_1.CharacterCodes.s &&
729
+ text.charCodeAt(i + 4) === CharacterCodes_1.CharacterCodes.p &&
730
+ text.charCodeAt(i + 5) === CharacterCodes_1.CharacterCodes.semicolon) {
731
+ newText = newText + text.substring(startOfSubstr, i) + "\xa0";
732
+ i += 5;
733
+ startOfSubstr = i + 1;
734
+ }
735
+ break;
736
+ }
737
+ }
738
+ }
739
+ if (startOfSubstr === 0) {
740
+ return null;
741
+ }
742
+ newText += text.substring(startOfSubstr);
743
+ return newText;
744
+ }
745
+ function mergeConsecutiveTexts(childNodes, shouldCollapseWs) {
746
+ if (shouldCollapseWs) {
747
+ collapseWhitespace(childNodes);
748
+ }
749
+ stripCDataWrapper(childNodes);
750
+ for (let i = childNodes.length - 1; i > 0; --i) {
751
+ const node = childNodes[i - 1];
752
+ const nextNode = childNodes[i];
753
+ if (node.kind === syntax_kind_1.SyntaxKind.StringLiteral && nextNode.kind === syntax_kind_1.SyntaxKind.CData) {
754
+ childNodes[i - 1] = {
755
+ kind: syntax_kind_1.SyntaxKind.CData,
756
+ text: getText(node).slice(1, -1) + getText(nextNode),
757
+ };
758
+ childNodes.pop();
759
+ }
760
+ else if (node.kind === syntax_kind_1.SyntaxKind.CData && nextNode.kind === syntax_kind_1.SyntaxKind.StringLiteral) {
761
+ childNodes[i - 1] = {
762
+ kind: syntax_kind_1.SyntaxKind.CData,
763
+ text: getText(node) + getText(nextNode).slice(1, -1),
764
+ };
765
+ childNodes.pop();
766
+ }
767
+ else if (node.kind === syntax_kind_1.SyntaxKind.CData && nextNode.kind === syntax_kind_1.SyntaxKind.TextNode) {
768
+ childNodes[i - 1] = {
769
+ kind: syntax_kind_1.SyntaxKind.CData,
770
+ text: getText(node) + getText(nextNode),
771
+ };
772
+ childNodes.pop();
773
+ }
774
+ else if (node.kind === syntax_kind_1.SyntaxKind.CData && nextNode.kind === syntax_kind_1.SyntaxKind.CData) {
775
+ childNodes[i - 1] = {
776
+ kind: syntax_kind_1.SyntaxKind.CData,
777
+ text: getText(node) + getText(nextNode),
778
+ };
779
+ childNodes.pop();
780
+ }
781
+ else if (node.kind === syntax_kind_1.SyntaxKind.TextNode && nextNode.kind === syntax_kind_1.SyntaxKind.TextNode) {
782
+ if (getText(node).endsWith(" ") && getText(nextNode).startsWith(" ")) {
783
+ node.text = getText(node).trimEnd();
784
+ }
785
+ childNodes[i - 1] = {
786
+ kind: syntax_kind_1.SyntaxKind.TextNode,
787
+ text: getText(node) + getText(nextNode),
788
+ };
789
+ childNodes.pop();
790
+ }
791
+ else if (node.kind === syntax_kind_1.SyntaxKind.TextNode && nextNode.kind === syntax_kind_1.SyntaxKind.CData) {
792
+ childNodes[i - 1] = {
793
+ kind: syntax_kind_1.SyntaxKind.CData,
794
+ text: getText(node) + getText(nextNode),
795
+ };
796
+ childNodes.pop();
797
+ }
798
+ }
799
+ }
800
+ }
801
+ function createTextNodeCDataElement(textValue) {
802
+ return {
803
+ kind: syntax_kind_1.SyntaxKind.ElementNode,
804
+ children: [
805
+ { kind: syntax_kind_1.SyntaxKind.OpenNodeStart },
806
+ { kind: syntax_kind_1.SyntaxKind.TagNameNode, children: [{ kind: syntax_kind_1.SyntaxKind.Identifier, text: "TextNodeCData" }] },
807
+ {
808
+ kind: syntax_kind_1.SyntaxKind.AttributeListNode,
809
+ children: [
810
+ {
811
+ kind: syntax_kind_1.SyntaxKind.AttributeNode,
812
+ children: [
813
+ { kind: syntax_kind_1.SyntaxKind.Identifier, text: "value" },
814
+ { kind: syntax_kind_1.SyntaxKind.Equal },
815
+ { kind: syntax_kind_1.SyntaxKind.Identifier, text: `"${textValue}"` },
816
+ ],
817
+ },
818
+ ],
819
+ },
820
+ { kind: syntax_kind_1.SyntaxKind.NodeClose },
821
+ ],
822
+ };
823
+ }
824
+ function createTextNodeElement(textValue) {
825
+ return {
826
+ kind: syntax_kind_1.SyntaxKind.ElementNode,
827
+ children: [
828
+ { kind: syntax_kind_1.SyntaxKind.OpenNodeStart },
829
+ { kind: syntax_kind_1.SyntaxKind.TagNameNode, children: [{ kind: syntax_kind_1.SyntaxKind.Identifier, text: "TextNode" }] },
830
+ {
831
+ kind: syntax_kind_1.SyntaxKind.AttributeListNode,
832
+ children: [
833
+ {
834
+ kind: syntax_kind_1.SyntaxKind.AttributeNode,
835
+ children: [
836
+ { kind: syntax_kind_1.SyntaxKind.Identifier, text: "value" },
837
+ { kind: syntax_kind_1.SyntaxKind.Equal },
838
+ { kind: syntax_kind_1.SyntaxKind.Identifier, text: `"${textValue}"` },
839
+ ],
840
+ },
841
+ ],
842
+ },
843
+ { kind: syntax_kind_1.SyntaxKind.NodeClose },
844
+ ],
845
+ };
846
+ }
847
+ /**
848
+ * Reports the specified error
849
+ * @param errorCode Error code
850
+ * @param options Error message options
851
+ */
852
+ function reportError(errorCode, ...options) {
853
+ var _a;
854
+ let errorText = (_a = ParserError_1.errorMessages[errorCode]) !== null && _a !== void 0 ? _a : "Unknown error";
855
+ if (options) {
856
+ options.forEach((o, idx) => (errorText = replace(errorText, `{${idx}}`, o.toString())));
857
+ }
858
+ throw new ParserError_1.ParserError(errorText, errorCode);
859
+ function replace(input, placeholder, replacement) {
860
+ do {
861
+ input = input.replace(placeholder, replacement);
862
+ } while (input.includes(placeholder));
863
+ return input;
864
+ }
865
+ }
866
+ function isComponent(obj) {
867
+ return obj.type;
868
+ }
869
+ function mergeValue(oldValue, itemValue) {
870
+ if (oldValue) {
871
+ if (Array.isArray(oldValue)) {
872
+ if (typeof oldValue === "string") {
873
+ return [oldValue, itemValue];
874
+ }
875
+ else {
876
+ oldValue.push(itemValue);
877
+ return oldValue;
878
+ }
879
+ }
880
+ else {
881
+ return [oldValue, itemValue];
882
+ }
883
+ }
884
+ else {
885
+ return itemValue;
886
+ }
887
+ }
888
+ function wrapWithFragment(wrappedChildren) {
889
+ const nameNode = { kind: syntax_kind_1.SyntaxKind.TagNameNode, children: [{ kind: syntax_kind_1.SyntaxKind.Identifier, text: "Fragment" }] };
890
+ return {
891
+ kind: syntax_kind_1.SyntaxKind.ElementNode,
892
+ children: [
893
+ { kind: syntax_kind_1.SyntaxKind.OpenNodeStart },
894
+ nameNode,
895
+ { kind: syntax_kind_1.SyntaxKind.NodeEnd },
896
+ { kind: syntax_kind_1.SyntaxKind.ContentListNode, children: wrappedChildren },
897
+ { kind: syntax_kind_1.SyntaxKind.CloseNodeStart },
898
+ nameNode,
899
+ { kind: syntax_kind_1.SyntaxKind.NodeEnd },
900
+ ],
901
+ };
902
+ }
903
+ function getAttributes(node) {
904
+ var _a, _b, _c;
905
+ return (_c = (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((c) => c.kind === syntax_kind_1.SyntaxKind.AttributeListNode)) === null || _b === void 0 ? void 0 : _b.children) !== null && _c !== void 0 ? _c : [];
906
+ }
907
+ function getChildNodes(node) {
908
+ var _a, _b, _c;
909
+ return (_c = (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((c) => c.kind === syntax_kind_1.SyntaxKind.ContentListNode)) === null || _b === void 0 ? void 0 : _b.children) !== null && _c !== void 0 ? _c : [];
910
+ }
911
+ function withNewChildNodes(node, newChildren) {
912
+ var _a;
913
+ const childrenListIdx = (_a = node.children) === null || _a === void 0 ? void 0 : _a.findIndex((c) => c.kind === syntax_kind_1.SyntaxKind.ContentListNode);
914
+ if (childrenListIdx === undefined || childrenListIdx === -1) {
915
+ return node;
916
+ }
917
+ return Object.assign(Object.assign({}, node), { children: [
918
+ ...node.children.slice(0, childrenListIdx),
919
+ Object.assign(Object.assign({}, node.children[childrenListIdx]), { children: newChildren }),
920
+ ...node.children.slice(childrenListIdx),
921
+ ] });
922
+ }