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,1110 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __rest = (this && this.__rest) || function (s, e) {
35
+ var t = {};
36
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
+ t[p] = s[p];
38
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
+ t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ };
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.containerReducer = void 0;
50
+ exports.renderRoot = renderRoot;
51
+ exports.eventHandlerStarted = eventHandlerStarted;
52
+ exports.eventHandlerCompleted = eventHandlerCompleted;
53
+ exports.eventHandlerError = eventHandlerError;
54
+ exports.statePartChanged = statePartChanged;
55
+ exports.renderLoaders = renderLoaders;
56
+ const jsx_runtime_1 = require("react/jsx-runtime");
57
+ const react_1 = __importStar(require("react"));
58
+ const memoize_one_1 = __importDefault(require("memoize-one"));
59
+ const immer_1 = __importDefault(require("immer"));
60
+ const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
61
+ const lodash_es_1 = require("lodash-es");
62
+ const ErrorBoundary_1 = require("@components-core/ErrorBoundary");
63
+ const extractParam_1 = require("@components-core/utils/extractParam");
64
+ const misc_1 = require("@components-core/utils/misc");
65
+ const process_statement_async_1 = require("@components-core/script-runner/process-statement-async");
66
+ const process_statement_sync_1 = require("@components-core/script-runner/process-statement-sync");
67
+ const Component_1 = __importDefault(require("@components-core/Component"));
68
+ const constants_1 = require("@components-core/constants");
69
+ const ContainerComponentDef_1 = require("./ContainerComponentDef");
70
+ const style_compiler_1 = require("../../parsers/style-parser/style-compiler");
71
+ const descriptorHelper_1 = require("@components-core/descriptorHelper");
72
+ const buildProxy_1 = __importDefault(require("./buildProxy"));
73
+ const statementUtils_1 = require("@components-core/utils/statementUtils");
74
+ const react_2 = require("@remix-run/react");
75
+ const AppContext_1 = require("@components-core/AppContext");
76
+ const visitors_1 = require("@components-core/script-runner/visitors");
77
+ const ParameterParser_1 = require("@components-core/script-runner/ParameterParser");
78
+ const ThemeContext_1 = require("@components-core/theming/ThemeContext");
79
+ const code_behind_collect_1 = require("../../parsers/scripting/code-behind-collect");
80
+ const eval_tree_sync_1 = require("@components-core/script-runner/eval-tree-sync");
81
+ const collectFnVarDeps_1 = require("@components-core/container/collectFnVarDeps");
82
+ const hooks_1 = require("@components-core/utils/hooks");
83
+ const containers_1 = require("@components-core/abstractions/containers");
84
+ const LoaderComponent_1 = require("@components-core/LoaderComponent");
85
+ // This function renders the entire component tree starting from the root component. As it works recursively,
86
+ // all child components will be rendered, including the wrapping containers
87
+ function renderRoot(node, memoedVarsRef) {
88
+ return renderChild({
89
+ node,
90
+ state: constants_1.EMPTY_OBJECT,
91
+ dispatch: constants_1.noop,
92
+ appContext: undefined,
93
+ lookupAction: constants_1.noop,
94
+ lookupSyncCallback: constants_1.noop,
95
+ registerComponentApi: constants_1.noop,
96
+ renderChild: constants_1.noop,
97
+ stateFieldPartChanged: constants_1.noop,
98
+ layoutCss: constants_1.EMPTY_OBJECT,
99
+ layoutNonCss: constants_1.EMPTY_OBJECT,
100
+ cleanup: constants_1.noop,
101
+ memoedVarsRef,
102
+ });
103
+ }
104
+ // React component to display a view container and implement its behavior
105
+ const MemoizedContainer = (0, react_1.memo)((0, react_1.forwardRef)(function Container({ node, componentState, dispatch: containerDispatch, parentDispatch, resolvedKey, version, setVersion, stateFieldPartChanged, registerComponentApi: containerRegisterComponentApi, parentRegisterComponentApi, layoutContextRef, dynamicChildren, memoedVarsRef, isImplicit, }, ref) {
106
+ var _a;
107
+ const { apiBoundContainer } = node;
108
+ const dispatch = isImplicit ? parentDispatch : containerDispatch;
109
+ const registerComponentApi = isImplicit ? parentRegisterComponentApi : containerRegisterComponentApi;
110
+ const { themeVars } = (0, ThemeContext_1.useTheme)();
111
+ const appContext = (0, AppContext_1.useAppContext)();
112
+ const { getThemeVar } = (0, ThemeContext_1.useTheme)();
113
+ const navigate = (0, react_2.useNavigate)();
114
+ const location = (0, react_2.useLocation)();
115
+ const fnsRef = (0, react_1.useRef)({});
116
+ // console.log({ componentState });
117
+ // const publicComponentState = useShallowCompareMemoize(useMemo(()=>{
118
+ // const ret = {};
119
+ // return ret;
120
+ // }, []));
121
+ const stateRef = (0, react_1.useRef)(componentState);
122
+ const parsedStatementsRef = (0, react_1.useRef)({});
123
+ const statementPromises = (0, react_1.useRef)(new Map());
124
+ const [_, startTransition] = (0, react_1.useTransition)();
125
+ const mountedRef = (0, react_1.useRef)(true);
126
+ (0, hooks_1.useIsomorphicLayoutEffect)(() => {
127
+ stateRef.current = componentState;
128
+ }, [componentState]);
129
+ (0, hooks_1.useIsomorphicLayoutEffect)(() => {
130
+ for (const resolve of statementPromises.current.values()) {
131
+ resolve();
132
+ }
133
+ }, [version]);
134
+ (0, react_1.useEffect)(() => {
135
+ mountedRef.current = true;
136
+ const leftPromises = statementPromises.current;
137
+ return () => {
138
+ mountedRef.current = false;
139
+ for (const resolve of leftPromises.values()) {
140
+ resolve();
141
+ }
142
+ };
143
+ }, []);
144
+ const runCodeAsync = (0, misc_1.useEvent)((source, componentUid, options, ...eventArgs) => __awaiter(this, void 0, void 0, function* () {
145
+ var _a, _b, _c;
146
+ // console.log({
147
+ // source,
148
+ // componentUid,
149
+ // options,
150
+ // eventArgs,
151
+ // state: stateRef.current,
152
+ // "$this": stateRef.current[componentUid]
153
+ // });
154
+ let changes = [];
155
+ const getComponentStateClone = () => {
156
+ changes.length = 0;
157
+ const poj = (0, lodash_es_1.cloneDeep)(Object.assign({}, stateRef.current));
158
+ poj["$this"] = stateRef.current[componentUid];
159
+ return (0, buildProxy_1.default)(poj, (changeInfo) => {
160
+ var _a;
161
+ const idRoot = (_a = changeInfo.pathArray) === null || _a === void 0 ? void 0 : _a[0];
162
+ if (idRoot === null || idRoot === void 0 ? void 0 : idRoot.startsWith("$")) {
163
+ throw new Error("Cannot update a read-only variable");
164
+ }
165
+ changes.push(changeInfo);
166
+ });
167
+ };
168
+ const evalAppContext = Object.assign(Object.assign({}, appContext), { getThemeVar });
169
+ const evalContext = {
170
+ appContext: evalAppContext,
171
+ eventArgs,
172
+ localContext: getComponentStateClone(),
173
+ implicitContextGetter: () => {
174
+ return {
175
+ uid: componentUid,
176
+ state: stateRef.current,
177
+ dispatch,
178
+ appContext: evalAppContext,
179
+ navigate,
180
+ location,
181
+ lookupAction: (action, uid, actionOptions = {}) => {
182
+ return lookupAction(action, uid, Object.assign(Object.assign({}, actionOptions), { ephemeral: true }));
183
+ },
184
+ };
185
+ },
186
+ options: {
187
+ defaultToOptionalMemberAccess: typeof ((_a = appContext.globals) === null || _a === void 0 ? void 0 : _a.defaultToOptionalMemberAccess) === "boolean"
188
+ ? appContext.globals.defaultToOptionalMemberAccess
189
+ : true,
190
+ },
191
+ };
192
+ try {
193
+ // --- Prepare the event handler to an arrow expression statement
194
+ let statements;
195
+ if (typeof source === "string") {
196
+ if (!parsedStatementsRef.current[source]) {
197
+ parsedStatementsRef.current[source] = (0, statementUtils_1.prepareHandlerStatements)((0, statementUtils_1.parseHandlerCode)(source), evalContext);
198
+ }
199
+ statements = parsedStatementsRef.current[source];
200
+ }
201
+ else {
202
+ statements = [
203
+ {
204
+ type: "ArrowS",
205
+ expression: (0, lodash_es_1.cloneDeep)(source), //TODO illesg (talk it through why we need to deep clone, it it's omitted, it gets slower every time we run it)
206
+ },
207
+ ];
208
+ }
209
+ if (!(statements === null || statements === void 0 ? void 0 : statements.length)) {
210
+ return;
211
+ }
212
+ if (canSignEventLifecycle(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName)) {
213
+ dispatch(eventHandlerStarted(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName));
214
+ }
215
+ let mainThreadBlockingRuns = 0;
216
+ yield (0, process_statement_async_1.processStatementQueueAsync)(statements, evalContext, undefined, (evalContext, completedStatement) => __awaiter(this, void 0, void 0, function* () {
217
+ if (changes.length) {
218
+ mainThreadBlockingRuns = 0;
219
+ changes.forEach((change) => {
220
+ stateFieldPartChanged(change.pathArray, (0, lodash_es_1.cloneDeep)(change.newValue), change.target, change.action);
221
+ });
222
+ let resolve = null;
223
+ const stateUpdatedPromise = new Promise((res) => {
224
+ resolve = () => {
225
+ res(null);
226
+ };
227
+ });
228
+ const key = (0, misc_1.generatedId)();
229
+ statementPromises.current.set(key, resolve);
230
+ // We use this to tell react that this update is not high-priority.
231
+ // If we don't put it to a transition, the whole app would be blocked if we run a long,
232
+ // update intensive queue (e.g. an infinite loop which
233
+ // increments a counter, see playground example learning/01_Experiments/01_Event_Framework/app ).
234
+ // Before this solution, we used a setTimeout(..., 0); hack, but some browsers (chrome especially)
235
+ // do some funky stuff with the background tabs (e.g. all the setTimeouts are
236
+ // maximized to run in 1 time / minute, doesn't matter if it's timeout is 0)
237
+ // As of 2023. June 20, this solution works with backgrounded tabs, too.
238
+ startTransition(() => {
239
+ setVersion((prev) => prev + 1);
240
+ });
241
+ //TODO this could be a problem - if this container gets unmounted, we still have to wait for the update,
242
+ // but in that case this update probably happened in the parent (e.g. a button's event handler removes the whole container
243
+ // where the button lives, but it still has some statements to run).
244
+ // with this solution the statement execution doesn't stop, and we fallback waiting with a setTimeout(0)
245
+ if (mountedRef.current) {
246
+ yield stateUpdatedPromise;
247
+ }
248
+ else {
249
+ yield (0, misc_1.delay)(0);
250
+ }
251
+ statementPromises.current.delete(key);
252
+ changes = [];
253
+ }
254
+ else {
255
+ //in this else branch normally we block the main thread (we don't wait for any state promise to be resolved),
256
+ // so in a long-running (typically infinite loop) situation, where there aren't any changes in the state
257
+ // we block the main thread indefinitely... this 'mainThreadBlockingRuns' var solution makes sure that
258
+ // we pause in every 100 runs, and let the main thread breath a bit, so it's not frozen for the whole time
259
+ // (we clear that counter above, too, where we use a startTransition call to de-prioritize this work)
260
+ mainThreadBlockingRuns++;
261
+ if (mainThreadBlockingRuns > 100) {
262
+ mainThreadBlockingRuns = 0;
263
+ yield (0, misc_1.delay)(0);
264
+ }
265
+ }
266
+ evalContext.localContext = getComponentStateClone();
267
+ }));
268
+ if (canSignEventLifecycle(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName)) {
269
+ dispatch(eventHandlerCompleted(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName));
270
+ }
271
+ if ((_c = (_b = evalContext.mainThread) === null || _b === void 0 ? void 0 : _b.blocks) === null || _c === void 0 ? void 0 : _c.length) {
272
+ return evalContext.mainThread.blocks[evalContext.mainThread.blocks.length - 1].returnValue;
273
+ }
274
+ }
275
+ catch (e) {
276
+ //if we pass down an event handler to a component, we should sign the error once, not in every step of the component chain
277
+ // (we use it in the compoundComponent, resolving it's event handlers)
278
+ if ((options === null || options === void 0 ? void 0 : options.signError) !== false) {
279
+ appContext.signError(e);
280
+ }
281
+ if (canSignEventLifecycle(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName)) {
282
+ dispatch(eventHandlerError(componentUid.description, options === null || options === void 0 ? void 0 : options.eventName, e));
283
+ }
284
+ throw e;
285
+ }
286
+ }));
287
+ const runCodeSync = (0, misc_1.useEvent)((arrowExpression, ...eventArgs) => {
288
+ var _a, _b;
289
+ const evalContext = {
290
+ localContext: (0, lodash_es_1.cloneDeep)(stateRef.current),
291
+ appContext,
292
+ eventArgs,
293
+ };
294
+ try {
295
+ const arrowStmt = {
296
+ type: "ArrowS",
297
+ expression: arrowExpression,
298
+ };
299
+ (0, process_statement_sync_1.processStatementQueue)([arrowStmt], evalContext);
300
+ if ((_b = (_a = evalContext.mainThread) === null || _a === void 0 ? void 0 : _a.blocks) === null || _b === void 0 ? void 0 : _b.length) {
301
+ return evalContext.mainThread.blocks[evalContext.mainThread.blocks.length - 1].returnValue;
302
+ }
303
+ }
304
+ catch (e) {
305
+ console.error(e);
306
+ throw e;
307
+ }
308
+ });
309
+ const getOrCreateEventHandlerFn = (0, misc_1.useEvent)((src, uid, options) => {
310
+ var _a;
311
+ const stringSrc = typeof src === "string" ? src : src.statement.source;
312
+ const fnCacheKey = `${options === null || options === void 0 ? void 0 : options.eventName};${stringSrc}`;
313
+ const handler = (...eventArgs) => {
314
+ return runCodeAsync(src, uid, options, ...(0, lodash_es_1.cloneDeep)(eventArgs));
315
+ };
316
+ if (options === null || options === void 0 ? void 0 : options.ephemeral) {
317
+ return handler;
318
+ }
319
+ if (!((_a = fnsRef.current[uid]) === null || _a === void 0 ? void 0 : _a[fnCacheKey])) {
320
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
321
+ fnsRef.current[uid][fnCacheKey] = handler;
322
+ }
323
+ return fnsRef.current[uid][fnCacheKey];
324
+ });
325
+ const getOrCreateSyncCallbackFn = (0, misc_1.useEvent)((arrowExpression, uid) => {
326
+ var _a;
327
+ const fnCacheKey = `sync-callback-${arrowExpression.source}`;
328
+ if (!((_a = fnsRef.current[uid]) === null || _a === void 0 ? void 0 : _a[fnCacheKey])) {
329
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
330
+ fnsRef.current[uid][fnCacheKey] = (...eventArgs) => {
331
+ return runCodeSync(arrowExpression, ...eventArgs);
332
+ };
333
+ }
334
+ return fnsRef.current[uid][fnCacheKey];
335
+ });
336
+ const lookupSyncCallback = (0, misc_1.useEvent)((action, uid) => {
337
+ if (!action) {
338
+ return undefined;
339
+ }
340
+ if (typeof action === "function") {
341
+ return action;
342
+ }
343
+ const resolvedAction = (0, extractParam_1.extractParam)(componentState, action, appContext, true);
344
+ if (!resolvedAction) {
345
+ return undefined;
346
+ }
347
+ if (typeof resolvedAction === "function") {
348
+ return resolvedAction;
349
+ }
350
+ if (!resolvedAction._ARROW_EXPR_) {
351
+ throw new Error("Only arrow expression allowed in sync callback");
352
+ }
353
+ return getOrCreateSyncCallbackFn(resolvedAction, uid);
354
+ });
355
+ const lookupAction = (0, react_1.useCallback)((action, uid, options) => {
356
+ let safeAction = action;
357
+ if (!action && uid.description && (options === null || options === void 0 ? void 0 : options.eventName)) {
358
+ const handlerFnName = `${uid.description}_on${(0, misc_1.capitalizeFirstLetter)(options === null || options === void 0 ? void 0 : options.eventName)}`;
359
+ if (componentState[handlerFnName] && componentState[handlerFnName]._ARROW_EXPR_) {
360
+ safeAction = componentState[handlerFnName];
361
+ }
362
+ }
363
+ if (!safeAction) {
364
+ return undefined;
365
+ }
366
+ if (typeof safeAction === "function") {
367
+ return safeAction;
368
+ }
369
+ return getOrCreateEventHandlerFn(safeAction, uid, options);
370
+ }, [componentState, getOrCreateEventHandlerFn]);
371
+ const isApiRegisteredInnerRef = (0, react_1.useRef)(false);
372
+ (0, react_1.useEffect)(() => {
373
+ if (!node.api) {
374
+ return;
375
+ }
376
+ if (!node.containerUid) {
377
+ return;
378
+ }
379
+ if (isApiRegisteredInnerRef.current) {
380
+ return;
381
+ }
382
+ isApiRegisteredInnerRef.current = true;
383
+ const api = {};
384
+ const self = Symbol("$self");
385
+ Object.entries(node.api).forEach(([key, value]) => {
386
+ api[key] = lookupAction(value, self);
387
+ });
388
+ if (!isImplicit) {
389
+ registerComponentApi(self, api); //we register the api as $self for the compound components,
390
+ }
391
+ parentRegisterComponentApi(node.containerUid, api); // and register it for the parent component instance
392
+ }, [
393
+ lookupAction,
394
+ node.api,
395
+ node.containerUid,
396
+ node.uid,
397
+ isImplicit,
398
+ parentRegisterComponentApi,
399
+ registerComponentApi,
400
+ ]);
401
+ const cleanup = (0, misc_1.useEvent)((uid) => {
402
+ // console.log("CLEANUP CALLED FOR", node);
403
+ //TODO cleanup registered component api for that uid
404
+ //TODO cleanup state for that uid
405
+ delete fnsRef.current[uid];
406
+ });
407
+ const stableRenderChild = (0, react_1.useCallback)((childNode, lc, rc) => {
408
+ // let node: any = childNode;
409
+ if (typeof childNode === "string") {
410
+ throw Error("should be resolved for now");
411
+ }
412
+ // if(rc){
413
+ // console.log("hey, ", rc);
414
+ // // console.log(childNode);
415
+ // }
416
+ const children = (0, lodash_es_1.isArray)(childNode) ? childNode : [childNode];
417
+ if (!children || !children.length) {
418
+ return null;
419
+ }
420
+ const wrapWithFragment = children.length > 1;
421
+ const dynamicChildren = children.map((child, childIndex) => {
422
+ if (!child) {
423
+ return undefined;
424
+ }
425
+ let renderedChild;
426
+ if ("childToRender" in child) {
427
+ //inside a compoundComponent, render it with the parent state context, but the actual CC layoutContext
428
+ renderedChild = child.renderChild(child.childToRender, lc);
429
+ }
430
+ else {
431
+ const resolvedProps = {};
432
+ descriptorHelper_1.layoutOptionKeys.forEach((key) => {
433
+ if (child.props && key in child.props) {
434
+ resolvedProps[key] = (0, extractParam_1.extractParam)(componentState, child.props[key], appContext, true);
435
+ }
436
+ });
437
+ // console.log("compile layout for child", { child, lc });
438
+ const { cssProps, nonCssProps } = (0, style_compiler_1.compileLayout)(resolvedProps, themeVars, lc);
439
+ renderedChild = renderChild({
440
+ node: child,
441
+ state: componentState,
442
+ dispatch,
443
+ appContext,
444
+ lookupAction,
445
+ lookupSyncCallback,
446
+ registerComponentApi,
447
+ renderChild: stableRenderChild,
448
+ stateFieldPartChanged,
449
+ layoutCss: cssProps,
450
+ layoutNonCss: nonCssProps,
451
+ layoutContext: lc,
452
+ dynamicChildren: rc,
453
+ memoedVarsRef,
454
+ cleanup,
455
+ childIndex,
456
+ });
457
+ }
458
+ if (renderedChild === undefined) {
459
+ return undefined;
460
+ }
461
+ let rendered = renderedChild;
462
+ if (wrapWithFragment) {
463
+ if (react_1.default.isValidElement(renderedChild)) {
464
+ rendered = react_1.default.cloneElement(renderedChild, {
465
+ key: `${childIndex}_${child.uid}`,
466
+ });
467
+ }
468
+ else {
469
+ //e.g. simple text nodes
470
+ rendered = (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderedChild }, `${childIndex}_${child.uid}`);
471
+ }
472
+ }
473
+ return rendered;
474
+ });
475
+ if (dynamicChildren.length === 1) {
476
+ return ref && dynamicChildren[0] && (0, react_1.isValidElement)(dynamicChildren[0])
477
+ ? react_1.default.cloneElement(dynamicChildren[0], {
478
+ ref: (0, react_compose_refs_1.composeRefs)(ref, dynamicChildren[0].ref),
479
+ })
480
+ : dynamicChildren[0];
481
+ }
482
+ return dynamicChildren;
483
+ }, [
484
+ themeVars,
485
+ componentState,
486
+ dispatch,
487
+ appContext,
488
+ lookupAction,
489
+ lookupSyncCallback,
490
+ registerComponentApi,
491
+ stateFieldPartChanged,
492
+ memoedVarsRef,
493
+ cleanup,
494
+ ref,
495
+ ]);
496
+ // --- Log the component state if you need it for debugging
497
+ if ((_a = node.props) === null || _a === void 0 ? void 0 : _a.debug) {
498
+ console.log(`Container: ${resolvedKey}`, {
499
+ componentState,
500
+ node,
501
+ });
502
+ }
503
+ // --- Use this object to store information about already rendered UIDs.
504
+ // --- We do not allow any action, loader, or transform to use the same UID; however (as of now) children
505
+ // --- may use the same UID.
506
+ const uidInfo = {};
507
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [renderLoaders({
508
+ uidInfo,
509
+ loaders: node.loaders,
510
+ componentState,
511
+ //if it's an api bound container, we always use this container, otherwise use the parent if it's an implicit one
512
+ dispatch: apiBoundContainer ? containerDispatch : dispatch,
513
+ registerComponentApi: apiBoundContainer ? containerRegisterComponentApi : registerComponentApi,
514
+ appContext,
515
+ lookupAction,
516
+ cleanup,
517
+ }), stableRenderChild(node.children, layoutContextRef === null || layoutContextRef === void 0 ? void 0 : layoutContextRef.current, dynamicChildren)] }, node.uid ? `${resolvedKey}>${(0, extractParam_1.extractParam)(componentState, node.uid, appContext, true)}` : undefined));
518
+ }));
519
+ const useRoutingParams = () => {
520
+ const [queryParams] = (0, react_2.useSearchParams)();
521
+ const routeParams = (0, react_2.useParams)();
522
+ const queryParamsMap = (0, react_1.useMemo)(() => {
523
+ const result = {};
524
+ for (const [key, value] of Array.from(queryParams.entries())) {
525
+ result[key] = value;
526
+ }
527
+ return result;
528
+ }, [queryParams]);
529
+ return (0, react_1.useMemo)(() => {
530
+ return {
531
+ $routeParams: routeParams,
532
+ $queryParams: queryParamsMap,
533
+ };
534
+ }, [queryParamsMap, routeParams]);
535
+ };
536
+ class CodeBehindParseError extends Error {
537
+ constructor(errors) {
538
+ const mainErrors = errors["Main"] || [];
539
+ const messages = mainErrors.map((errorMessage) => {
540
+ let ret = `${errorMessage.code} : ${errorMessage.text}`;
541
+ const posInfo = [];
542
+ if (errorMessage.line !== undefined) {
543
+ posInfo.push(`line:${errorMessage.line}`);
544
+ }
545
+ if (errorMessage.column !== undefined) {
546
+ posInfo.push(`column:${errorMessage.column}`);
547
+ }
548
+ if (posInfo.length) {
549
+ ret = `${ret} (${posInfo.join(", ")})`;
550
+ }
551
+ return ret;
552
+ });
553
+ super(messages.join("\n"));
554
+ Object.setPrototypeOf(this, CodeBehindParseError.prototype);
555
+ }
556
+ }
557
+ // A React component that wraps a view container into an error boundary
558
+ // (it's a named function inside the memo, this way it will be visible with that name in the react devtools)
559
+ const MemoizedErrorProneContainer = (0, react_1.memo)((0, react_1.forwardRef)(function ErrorProneContainer({ node, parentState, resolvedKey, parentStateFieldPartChanged, parentRegisterComponentApi, layoutContextRef, dynamicChildren: dynamicChildren, isImplicit, parentDispatch, }, ref) {
560
+ const [version, setVersion] = (0, react_1.useState)(0);
561
+ const routingParams = useRoutingParams();
562
+ const memoedVars = (0, react_1.useRef)(new Map());
563
+ const stateFromOutside = (0, hooks_1.useShallowCompareMemoize)((0, react_1.useMemo)(() => extractScopedState(parentState, node.uses), [node.uses, parentState]));
564
+ const [componentState, dispatch] = (0, react_1.useReducer)(exports.containerReducer, constants_1.EMPTY_OBJECT);
565
+ const [componentApis, setComponentApis] = (0, react_1.useState)(constants_1.EMPTY_OBJECT);
566
+ const componentStateWithApis = (0, hooks_1.useShallowCompareMemoize)((0, react_1.useMemo)(() => {
567
+ const ret = Object.assign({}, componentState);
568
+ for (const stateKey of Object.getOwnPropertySymbols(componentState)) {
569
+ const value = componentState[stateKey];
570
+ if (stateKey.description) {
571
+ ret[stateKey.description] = value;
572
+ }
573
+ }
574
+ if (Reflect.ownKeys(componentApis).length === 0) {
575
+ //skip containers with no registered apis
576
+ return ret;
577
+ }
578
+ for (const componentApiKey of Object.getOwnPropertySymbols(componentApis)) {
579
+ const value = componentApis[componentApiKey];
580
+ if (componentApiKey.description) {
581
+ const key = componentApiKey.description;
582
+ ret[key] = Object.assign(Object.assign({}, (ret[key] || {})), value);
583
+ }
584
+ ret[componentApiKey] = Object.assign(Object.assign({}, ret[componentApiKey]), value);
585
+ }
586
+ return ret;
587
+ }, [componentState, componentApis]));
588
+ const localVarsStateContext = useCombinedState(stateFromOutside, componentStateWithApis, node.contextVars);
589
+ const parsedScriptPart = node.scriptCollected;
590
+ if ((parsedScriptPart === null || parsedScriptPart === void 0 ? void 0 : parsedScriptPart.moduleErrors) && !(0, lodash_es_1.isEmpty)(parsedScriptPart.moduleErrors)) {
591
+ throw new CodeBehindParseError(parsedScriptPart.moduleErrors);
592
+ }
593
+ if (node.scriptError && !(0, lodash_es_1.isEmpty)(node.scriptError)) {
594
+ throw new CodeBehindParseError(node.scriptError);
595
+ }
596
+ const referenceTrackedApi = (0, hooks_1.useReferenceTrackedApi)(componentState);
597
+ const varDefinitions = (0, hooks_1.useShallowCompareMemoize)(Object.assign(Object.assign(Object.assign(Object.assign({}, parsedScriptPart === null || parsedScriptPart === void 0 ? void 0 : parsedScriptPart.functions), node.functions), parsedScriptPart === null || parsedScriptPart === void 0 ? void 0 : parsedScriptPart.vars), node.vars));
598
+ //first: collection function (arrowExpressions) dependencies
599
+ // -> do it until there's no function dep, only var deps
600
+ const functionDeps = (0, react_1.useMemo)(() => {
601
+ const fnDeps = {};
602
+ Object.entries(varDefinitions).forEach(([key, value]) => {
603
+ if (isParsedValue(value) && value.tree.type === "ArrowE") {
604
+ fnDeps[key] = (0, visitors_1.collectVariableDependencies)(value.tree, referenceTrackedApi);
605
+ }
606
+ });
607
+ return (0, collectFnVarDeps_1.collectFnVarDeps)(fnDeps);
608
+ }, [referenceTrackedApi, varDefinitions]);
609
+ // then resolve vars and replace function deps with the collected deps for that function
610
+ //first resolve round (we do 2, to make sure that the order of the definitions doesn't cause problems)
611
+ // e.g. 'testFn' uses $props, but $props is not resolved yet
612
+ const preResolvedLocalVars = useVars(varDefinitions, functionDeps, localVarsStateContext, (0, react_1.useRef)(new Map()));
613
+ const localVarsStateContextWithPreResolvedLocalVars = (0, hooks_1.useShallowCompareMemoize)(Object.assign(Object.assign({}, preResolvedLocalVars), localVarsStateContext));
614
+ const resolvedLocalVars = useVars(varDefinitions, functionDeps, localVarsStateContextWithPreResolvedLocalVars, memoedVars);
615
+ const mergedWithVars = useMergedState(resolvedLocalVars, componentStateWithApis);
616
+ const combinedState = useCombinedState(stateFromOutside, node.contextVars, mergedWithVars, routingParams);
617
+ const registerComponentApi = (0, react_1.useCallback)((uid, api) => {
618
+ setComponentApis((0, immer_1.default)((draft) => {
619
+ // console.log("-----BUST----setComponentApis");
620
+ if (!draft[uid]) {
621
+ draft[uid] = {};
622
+ }
623
+ Object.entries(api).forEach(([key, value]) => {
624
+ if (draft[uid][key] !== value) {
625
+ // console.log(`-----BUST------new api for ${uid}`, draft[uid][key], value)
626
+ draft[uid][key] = value;
627
+ }
628
+ });
629
+ }));
630
+ }, []);
631
+ const componentStateRef = (0, react_1.useRef)(componentStateWithApis);
632
+ const stateFieldPartChanged = (0, react_1.useCallback)((pathArray, newValue, target, action) => {
633
+ const key = pathArray[0];
634
+ if (key in componentStateRef.current || key in resolvedLocalVars) {
635
+ dispatch(statePartChanged(pathArray, newValue, target, action));
636
+ }
637
+ else {
638
+ if (!node.uses || node.uses.includes(key)) {
639
+ parentStateFieldPartChanged(pathArray, newValue, target, action);
640
+ }
641
+ }
642
+ }, [resolvedLocalVars, node.uses, parentStateFieldPartChanged]);
643
+ return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { node: node, location: "container", children: (0, jsx_runtime_1.jsx)(MemoizedContainer, { resolvedKey: resolvedKey, node: node, componentState: combinedState, dispatch: dispatch, parentDispatch: parentDispatch, setVersion: setVersion, version: version, stateFieldPartChanged: stateFieldPartChanged, registerComponentApi: registerComponentApi, parentRegisterComponentApi: parentRegisterComponentApi, layoutContextRef: layoutContextRef, dynamicChildren: dynamicChildren, memoedVarsRef: memoedVars, isImplicit: isImplicit, ref: ref }) }));
644
+ }));
645
+ /**
646
+ * Wraps the specified component node with a container
647
+ * @param node The component node to wrap
648
+ * @returns A "Container" node
649
+ */
650
+ const getWrappedWithContainer = (node) => {
651
+ var _a, _b;
652
+ if (node.type === "Container") {
653
+ // --- Already wrapped
654
+ return node;
655
+ }
656
+ // --- Clone the node and remove the properties that will be moved to the container
657
+ // --- Note: we need the "when" property in the ModalDialog component, so we don't remove it
658
+ const wrappedNode = Object.assign(Object.assign({}, node), { props: Object.assign({}, node.props) });
659
+ delete wrappedNode.loaders;
660
+ delete wrappedNode.vars;
661
+ delete wrappedNode.functions;
662
+ delete wrappedNode.script;
663
+ delete wrappedNode.scriptCollected;
664
+ delete wrappedNode.scriptError;
665
+ delete wrappedNode.uses;
666
+ (_a = wrappedNode.props) === null || _a === void 0 ? true : delete _a.uses;
667
+ delete wrappedNode.api;
668
+ // --- Do the wrapping
669
+ return {
670
+ type: "Container",
671
+ uid: node.uid,
672
+ when: node.when,
673
+ loaders: node.loaders,
674
+ vars: node.vars,
675
+ functions: node.functions,
676
+ scriptCollected: node.scriptCollected,
677
+ scriptError: node.scriptError,
678
+ // TODO: it seems so that we need only node.uses, but we have to check it
679
+ uses: node.uses, // || node.props?.uses?.split(",").map((txt: string) => txt.trim()),
680
+ api: node.api,
681
+ containerUid: "containerUid" in node && node.containerUid,
682
+ apiBoundContainer: "apiBoundContainer" in node && node.apiBoundContainer,
683
+ props: {
684
+ debug: (_b = node.props) === null || _b === void 0 ? void 0 : _b.debug,
685
+ // debug: true,
686
+ },
687
+ children: [wrappedNode],
688
+ };
689
+ };
690
+ const ComponentContainer = (0, react_1.memo)((0, react_1.forwardRef)(function ComponentContainer({ resolvedKey, node, parentState, parentStateFieldPartChanged, parentRegisterComponentApi, layoutContextRef, dynamicChildren, parentDispatch, }, ref) {
691
+ const enhancedNode = (0, react_1.useMemo)(() => getWrappedWithContainer(node), [node]);
692
+ return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { node: node, location: "container", children: (0, jsx_runtime_1.jsx)(MemoizedErrorProneContainer, { parentStateFieldPartChanged: parentStateFieldPartChanged, resolvedKey: resolvedKey, node: enhancedNode, parentState: parentState, layoutContextRef: layoutContextRef, dynamicChildren: dynamicChildren, isImplicit: node.type !== "Container" && enhancedNode.uses === undefined, parentRegisterComponentApi: parentRegisterComponentApi, parentDispatch: parentDispatch, ref: ref }) }));
693
+ }));
694
+ function renderChild({ node, state, dispatch, appContext, lookupAction, lookupSyncCallback, registerComponentApi, renderChild, layoutCss, layoutNonCss, stateFieldPartChanged, layoutContext, dynamicChildren, memoedVarsRef, cleanup, childIndex, }) {
695
+ var _a, _b, _c;
696
+ if (!node) {
697
+ return null;
698
+ }
699
+ // --- Render only visible components
700
+ if (!(0, extractParam_1.shouldKeep)(node.when, state, appContext)) {
701
+ return null;
702
+ }
703
+ // --- We do not parse text nodes specified with CDATA
704
+ if (node.type === "TextNodeCData") {
705
+ return (_b = (_a = node.props) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
706
+ }
707
+ if (node.type === "TextNode") {
708
+ // --- Special conversion: "&nbsp;" is converted to a non-breaking space
709
+ let nodeValue = (0, extractParam_1.extractParam)(state, (_c = node.props) === null || _c === void 0 ? void 0 : _c.value, appContext, true);
710
+ return nodeValue;
711
+ }
712
+ const key = (0, extractParam_1.extractParam)(state, node.uid, appContext, true);
713
+ return ((0, jsx_runtime_1.jsx)(Node, { resolvedKey: key, node: node, cleanup: cleanup, stateFieldPartChanged: stateFieldPartChanged, memoedVarsRef: memoedVarsRef, state: state, dispatch: dispatch, appContext: appContext, lookupAction: lookupAction, lookupSyncCallback: lookupSyncCallback, registerComponentApi: registerComponentApi, renderChild: renderChild, layoutCss: layoutCss, layoutNonCss: layoutNonCss, layoutContext: layoutContext, dynamicChildren: dynamicChildren, childIndex: childIndex }, key));
714
+ }
715
+ function transformNodeWithChildDatasource(node) {
716
+ var _a;
717
+ let didResolve = false;
718
+ let loaders = node.loaders;
719
+ let children = undefined;
720
+ (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
721
+ if (child.type === "Datasource") {
722
+ didResolve = true;
723
+ if (!loaders) {
724
+ loaders = [];
725
+ }
726
+ loaders.push({
727
+ uid: child.uid,
728
+ type: "DataLoader",
729
+ props: child.props,
730
+ events: child.events,
731
+ when: child.when,
732
+ });
733
+ }
734
+ else {
735
+ if (!children) {
736
+ children = [];
737
+ }
738
+ children.push(child);
739
+ }
740
+ });
741
+ if (didResolve) {
742
+ return Object.assign(Object.assign({}, node), { children,
743
+ loaders });
744
+ }
745
+ return node;
746
+ }
747
+ function transformNodeWithDatasourceProp(node) {
748
+ if (node.props && "datasource" in node.props && typeof node.props.datasource === "string") {
749
+ return Object.assign(Object.assign({}, node), { props: Object.assign(Object.assign({}, node.props), { datasource: {
750
+ type: "Datasource",
751
+ props: {
752
+ url: node.props.datasource,
753
+ },
754
+ } }) });
755
+ }
756
+ return node;
757
+ }
758
+ const Node = (0, react_1.memo)((0, react_1.forwardRef)(function Node(_a, ref) {
759
+ var { node, state, dispatch, appContext, lookupAction, lookupSyncCallback, registerComponentApi, renderChild, layoutCss, layoutNonCss, stateFieldPartChanged, layoutContext, dynamicChildren, memoedVarsRef, resolvedKey, cleanup, childIndex } = _a, rest = __rest(_a, ["node", "state", "dispatch", "appContext", "lookupAction", "lookupSyncCallback", "registerComponentApi", "renderChild", "layoutCss", "layoutNonCss", "stateFieldPartChanged", "layoutContext", "dynamicChildren", "memoedVarsRef", "resolvedKey", "cleanup", "childIndex"]);
760
+ //pref, this way
761
+ const stableLayoutContext = (0, react_1.useRef)(layoutContext);
762
+ stableLayoutContext.current = layoutContext;
763
+ const stableLayoutCss = (0, hooks_1.useShallowCompareMemoize)(layoutCss);
764
+ const stableLayoutNonCss = (0, hooks_1.useShallowCompareMemoize)(layoutNonCss);
765
+ const nodeWithTransformedLoaders = (0, react_1.useMemo)(() => {
766
+ let transformed = transformNodeWithChildDatasource(node); //if we have an Datasource child, we transform it to a loader on the node
767
+ transformed = transformNodeWithDatasourceProp(transformed);
768
+ // console.log(transformNodeWithDatasourceProp(transformed));
769
+ return transformed;
770
+ }, [node]);
771
+ let renderedChild = null;
772
+ if ((0, ContainerComponentDef_1.isContainerLike)(nodeWithTransformedLoaders)) {
773
+ renderedChild = ((0, jsx_runtime_1.jsx)(ComponentContainer, { resolvedKey: resolvedKey, node: nodeWithTransformedLoaders, parentState: state, parentDispatch: dispatch, layoutContextRef: stableLayoutContext, dynamicChildren: dynamicChildren, parentStateFieldPartChanged: stateFieldPartChanged, parentRegisterComponentApi: registerComponentApi, ref: ref }));
774
+ }
775
+ else {
776
+ renderedChild = ((0, jsx_runtime_1.jsx)(Component_1.default, Object.assign({ onUnmount: cleanup, memoedVarsRef: memoedVarsRef, node: nodeWithTransformedLoaders, state: state, dispatch: dispatch, appContext: appContext, lookupAction: lookupAction, lookupSyncCallback: lookupSyncCallback, registerComponentApi: registerComponentApi, renderChild: renderChild, layoutCss: stableLayoutCss, layoutNonCss: stableLayoutNonCss, dynamicChildren: dynamicChildren, layoutContextRef: stableLayoutContext, childIndex: childIndex, ref: ref }, rest)));
777
+ }
778
+ return renderedChild;
779
+ }));
780
+ // Extracts the `state` property values defined in a component definition's `uses` property. It uses the specified
781
+ // `appContext` when resolving the state values.
782
+ function extractScopedState(parentState, uses) {
783
+ if (!uses) {
784
+ return parentState;
785
+ }
786
+ if (uses.length === 0) {
787
+ return constants_1.EMPTY_OBJECT;
788
+ }
789
+ return (0, lodash_es_1.pick)(parentState, uses);
790
+ }
791
+ // This hook combines state properties in a list of states so that a particular state property in a higher
792
+ // argument index overrides the same-named state property in a lower argument index.
793
+ function useCombinedState(...states) {
794
+ const combined = (0, react_1.useMemo)(() => {
795
+ let ret = {};
796
+ states.forEach((state = constants_1.EMPTY_OBJECT) => {
797
+ // console.log("st", state);
798
+ if (state !== constants_1.EMPTY_OBJECT) {
799
+ ret = Object.assign(Object.assign({}, ret), state);
800
+ }
801
+ // console.log("ret", ret);
802
+ });
803
+ return ret;
804
+ }, [states]);
805
+ return (0, hooks_1.useShallowCompareMemoize)(combined);
806
+ }
807
+ // This hook combines state properties in a list of states so that a particular state property in a higher
808
+ // argument index merges into the same-named state property in a lower argument index.
809
+ // This hook combines state properties in a list of states so that a particular state property in a higher
810
+ // argument index merges into the same-named state property in a lower argument index.
811
+ function useMergedState(localVars, componentState) {
812
+ const merged = (0, react_1.useMemo)(() => {
813
+ const ret = Object.assign({}, localVars);
814
+ Reflect.ownKeys(componentState).forEach((key) => {
815
+ const value = componentState[key];
816
+ if (ret[key] === undefined) {
817
+ ret[key] = value;
818
+ }
819
+ else {
820
+ if ((0, lodash_es_1.isPlainObject)(ret[key]) && (0, lodash_es_1.isPlainObject)(value)) {
821
+ ret[key] = (0, lodash_es_1.merge)((0, lodash_es_1.cloneDeep)(ret[key]), value);
822
+ }
823
+ else {
824
+ ret[key] = value;
825
+ }
826
+ }
827
+ });
828
+ return ret;
829
+ }, [localVars, componentState]);
830
+ return (0, hooks_1.useShallowCompareMemoize)(merged);
831
+ }
832
+ class ParseVarError extends Error {
833
+ constructor(varName, originalError) {
834
+ super(`Error on var: ${varName} - ${(originalError === null || originalError === void 0 ? void 0 : originalError.message) || "unknown"}`);
835
+ }
836
+ }
837
+ //true if it's coming from a code behind or a script tag
838
+ function isParsedValue(value) {
839
+ return value && typeof value === "object" && value[code_behind_collect_1.PARSED_MARK_PROP];
840
+ }
841
+ // This hook resolves variables to their current value (using binding expression evaluation)
842
+ function useVars(vars = constants_1.EMPTY_OBJECT, fnDeps = constants_1.EMPTY_OBJECT, componentState, memoedVars) {
843
+ const appContext = (0, AppContext_1.useAppContext)();
844
+ const referenceTrackedApi = (0, hooks_1.useReferenceTrackedApi)(componentState);
845
+ const resolvedVars = (0, react_1.useMemo)(() => {
846
+ const ret = {};
847
+ Object.entries(vars).forEach(([key, value]) => {
848
+ if (key === "$events" || key === "$props") {
849
+ // --- We already resolved props and events in a compound component
850
+ ret[key] = value;
851
+ }
852
+ else {
853
+ if (!isParsedValue(value) && typeof value !== "string") {
854
+ ret[key] = value;
855
+ }
856
+ else {
857
+ // --- Resolve each variable's value, without going into the details of arrays and objects
858
+ if (!memoedVars.current.has(value)) {
859
+ memoedVars.current.set(value, {
860
+ getDependencies: (0, memoize_one_1.default)((value, referenceTrackedApi) => {
861
+ if (isParsedValue(value)) {
862
+ return (0, visitors_1.collectVariableDependencies)(value.tree, referenceTrackedApi);
863
+ }
864
+ // console.log(`GETTING DEPENDENCY FOR ${value} with:`, referenceTrackedApi);
865
+ const params = (0, ParameterParser_1.parseParameterString)(value);
866
+ let ret = new Set();
867
+ params.forEach((param) => {
868
+ if (param.type === "expression") {
869
+ ret = new Set([...ret, ...(0, visitors_1.collectVariableDependencies)(param.value, referenceTrackedApi)]);
870
+ }
871
+ });
872
+ return Array.from(ret);
873
+ }),
874
+ obtainValue: (0, memoize_one_1.default)((value, state, appContext, strict, deps, appContextDeps) => {
875
+ // console.log(
876
+ // "VARS, BUST, obtain value called with",
877
+ // value,
878
+ // { state, appContext },
879
+ // {
880
+ // deps,
881
+ // appContextDeps,
882
+ // }
883
+ // );
884
+ try {
885
+ return isParsedValue(value)
886
+ ? (0, eval_tree_sync_1.evalBinding)(value.tree, {
887
+ localContext: state,
888
+ appContext,
889
+ options: {
890
+ defaultToOptionalMemberAccess: true,
891
+ },
892
+ })
893
+ : (0, extractParam_1.extractParam)(state, value, appContext, strict);
894
+ }
895
+ catch (e) {
896
+ console.log(state);
897
+ throw new ParseVarError(value, e);
898
+ }
899
+ }, ([_newExpression, _newState, _newAppContext, _newStrict, newDeps, newAppContextDeps], [_lastExpression, _lastState, _lastAppContext, _lastStrict, lastDeps, lastAppContextDeps]) => {
900
+ return (0, misc_1.shallowCompare)(newDeps, lastDeps) && (0, misc_1.shallowCompare)(newAppContextDeps, lastAppContextDeps);
901
+ }),
902
+ });
903
+ }
904
+ const stateContext = Object.assign(Object.assign({}, ret), componentState);
905
+ let dependencies = [];
906
+ if (fnDeps[key]) {
907
+ dependencies = fnDeps[key];
908
+ }
909
+ else {
910
+ memoedVars.current
911
+ .get(value)
912
+ .getDependencies(value, referenceTrackedApi)
913
+ .forEach((dep) => {
914
+ if (fnDeps[dep]) {
915
+ dependencies.push(...fnDeps[dep]);
916
+ }
917
+ else {
918
+ dependencies.push(dep);
919
+ }
920
+ });
921
+ dependencies = [...new Set(dependencies)];
922
+ }
923
+ const stateDepValues = (0, misc_1.pickFromObject)(stateContext, dependencies);
924
+ const appContextDepValues = (0, misc_1.pickFromObject)(appContext, dependencies);
925
+ // console.log("VARS, obtain value called with", stateDepValues, appContextDepValues);
926
+ ret[key] = memoedVars.current
927
+ .get(value)
928
+ .obtainValue(value, stateContext, appContext, true, stateDepValues, appContextDepValues);
929
+ }
930
+ }
931
+ });
932
+ return ret;
933
+ }, [appContext, componentState, fnDeps, memoedVars, referenceTrackedApi, vars]);
934
+ return (0, hooks_1.useShallowCompareMemoize)(resolvedVars);
935
+ }
936
+ // --- Tests if a particular component (`componentUid`) can sign event (with `eventName`)
937
+ // --- life cycle changes
938
+ function canSignEventLifecycle(componentUid, eventName) {
939
+ return componentUid !== undefined && eventName !== undefined;
940
+ }
941
+ // Signs that a particular component (`uid`) has started running an event handler
942
+ // for the event with `eventName`.
943
+ function eventHandlerStarted(uid, eventName) {
944
+ return {
945
+ type: containers_1.ContainerActionKind.EVENT_HANDLER_STARTED,
946
+ payload: {
947
+ uid,
948
+ eventName,
949
+ },
950
+ };
951
+ }
952
+ // Signs that a particular component (`uid`) has completed running an event handler
953
+ // for the event with `eventName`.
954
+ function eventHandlerCompleted(uid, eventName) {
955
+ return {
956
+ type: containers_1.ContainerActionKind.EVENT_HANDLER_COMPLETED,
957
+ payload: {
958
+ uid,
959
+ eventName,
960
+ },
961
+ };
962
+ }
963
+ // Signs that a particular component (`uid`) has received an error while running an event handler
964
+ // for the event with `eventName`.
965
+ function eventHandlerError(uid, eventName, error) {
966
+ return {
967
+ type: containers_1.ContainerActionKind.EVENT_HANDLER_ERROR,
968
+ payload: {
969
+ uid,
970
+ eventName,
971
+ error,
972
+ },
973
+ };
974
+ }
975
+ // Signs that a particular state part (`path`) has been changed to a new `value` on a `target` object
976
+ // when executing an `action`.
977
+ function statePartChanged(path, value, target, action) {
978
+ return {
979
+ type: containers_1.ContainerActionKind.STATE_PART_CHANGED,
980
+ payload: {
981
+ path,
982
+ value,
983
+ target,
984
+ actionType: action,
985
+ },
986
+ };
987
+ }
988
+ // This value defines the reducer to manage the state of the view container using the current state of the container
989
+ // and an action. Note that the reducer function in this package handles immutability with the `produce` function of
990
+ // the `immer` package.
991
+ exports.containerReducer = (0, immer_1.default)((state, action) => {
992
+ const { uid } = action.payload;
993
+ if (uid === undefined && action.type !== containers_1.ContainerActionKind.STATE_PART_CHANGED) {
994
+ console.error("uid not provided for control component", {
995
+ state,
996
+ action,
997
+ });
998
+ return state;
999
+ }
1000
+ switch (action.type) {
1001
+ case containers_1.ContainerActionKind.LOADER_IN_PROGRESS_CHANGED: {
1002
+ state[uid] = Object.assign(Object.assign({}, state[uid]), { inProgress: action.payload.inProgress });
1003
+ break;
1004
+ }
1005
+ case containers_1.ContainerActionKind.LOADER_LOADED: {
1006
+ const { data, pageInfo } = action.payload;
1007
+ state[uid] = {
1008
+ value: data,
1009
+ byId: Array.isArray(data) ? (0, lodash_es_1.keyBy)(data, (item) => item.$id) : undefined,
1010
+ inProgress: false,
1011
+ loaded: data !== undefined,
1012
+ pageInfo,
1013
+ };
1014
+ break;
1015
+ }
1016
+ case containers_1.ContainerActionKind.LOADER_ERROR: {
1017
+ const { error } = action.payload;
1018
+ state[uid] = Object.assign(Object.assign({}, state[uid]), { error, inProgress: false, loaded: true });
1019
+ break;
1020
+ }
1021
+ case containers_1.ContainerActionKind.EVENT_HANDLER_STARTED: {
1022
+ const { eventName } = action.payload;
1023
+ const inProgressFlagName = `${eventName}InProgress`;
1024
+ state[uid] = Object.assign(Object.assign({}, state[uid]), { [inProgressFlagName]: true });
1025
+ break;
1026
+ }
1027
+ case containers_1.ContainerActionKind.EVENT_HANDLER_COMPLETED: {
1028
+ const { eventName } = action.payload;
1029
+ const inProgressFlagName = `${eventName}InProgress`;
1030
+ state[uid] = Object.assign(Object.assign({}, state[uid]), { [inProgressFlagName]: false });
1031
+ break;
1032
+ }
1033
+ case containers_1.ContainerActionKind.EVENT_HANDLER_ERROR: {
1034
+ const { eventName } = action.payload;
1035
+ const inProgressFlagName = `${eventName}InProgress`;
1036
+ state[uid] = Object.assign(Object.assign({}, state[uid]), { [inProgressFlagName]: false });
1037
+ break;
1038
+ }
1039
+ case containers_1.ContainerActionKind.COMPONENT_STATE_CHANGED: {
1040
+ const { state: newState } = action.payload;
1041
+ state[uid] = Object.assign(Object.assign({}, state[uid]), newState);
1042
+ break;
1043
+ }
1044
+ case containers_1.ContainerActionKind.STATE_PART_CHANGED: {
1045
+ const { path, value, target, actionType } = action.payload;
1046
+ if (actionType === "unset") {
1047
+ (0, lodash_es_1.unset)(state, path);
1048
+ }
1049
+ else {
1050
+ (0, lodash_es_1.setWith)(state, path, value, (nsValue) => {
1051
+ if (nsValue === undefined && (0, lodash_es_1.isPlainObject)(target)) {
1052
+ // if we are setting a new object's key, lodash defaults it to an array, if the key is a number.
1053
+ // This way we can force it to be an object.
1054
+ // (example: we have an empty object in vars called usersTyped: {}, we set usersTyped[1] = Date.now().
1055
+ // During the first state setting, we don't have a previous value for usersTyped, because it was defined
1056
+ // in vars, and wasn't updated yet. In the first update, it's value is undefined, and because the key is
1057
+ // a number (an id in our case), lodash thinks it has to create an array after this 'set'. This way we
1058
+ // can force it, because in the target we have the target object value (given by the proxy change),so if
1059
+ // it's an object, it should be an object. Otherwise we let lodash decide)
1060
+ return Object(nsValue);
1061
+ }
1062
+ });
1063
+ }
1064
+ break;
1065
+ }
1066
+ default:
1067
+ throw new Error();
1068
+ }
1069
+ });
1070
+ function renderLoaders({ uidInfo, loaders = constants_1.EMPTY_ARRAY, componentState, dispatch, appContext, registerComponentApi, lookupAction, cleanup, }) {
1071
+ return loaders.map((loader) => {
1072
+ // --- Check for the uniqueness of UIDs
1073
+ if (loader === null || loader === void 0 ? void 0 : loader.uid) {
1074
+ if (uidInfo[loader.uid]) {
1075
+ // --- We have a duplicated ID (another loader)
1076
+ throw new Error(`Another ${uidInfo[loader.uid]} definition in this container already uses the uid '${loader.uid}'`);
1077
+ }
1078
+ uidInfo[loader.uid] = "loader";
1079
+ }
1080
+ // --- Render the current loader
1081
+ const renderedLoader = renderLoader({
1082
+ loader,
1083
+ componentState,
1084
+ dispatch,
1085
+ appContext,
1086
+ registerComponentApi,
1087
+ lookupAction,
1088
+ cleanup,
1089
+ });
1090
+ // --- Skip loaders with rendering errors
1091
+ if (renderedLoader === undefined) {
1092
+ return undefined;
1093
+ }
1094
+ // --- Take care to use a key property for the loader
1095
+ return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderedLoader }, loader.uid);
1096
+ });
1097
+ function renderLoader({ loader, componentState, dispatch, appContext, registerComponentApi, lookupAction, cleanup, }) {
1098
+ // --- For the sake of avoiding further issues
1099
+ if (!loader) {
1100
+ return null;
1101
+ }
1102
+ // --- Evaluate "when" to decide if the loader should be rendered
1103
+ // --- Render only visible components
1104
+ if (!(0, extractParam_1.shouldKeep)(loader.when, componentState, appContext)) {
1105
+ return null;
1106
+ }
1107
+ // --- Use the loader type's renderer function
1108
+ return ((0, jsx_runtime_1.jsx)(LoaderComponent_1.LoaderComponent, { onUnmount: cleanup, node: loader, state: componentState, dispatch: dispatch, registerComponentApi: registerComponentApi, lookupAction: lookupAction }));
1109
+ }
1110
+ }