xmlui 0.7.21 → 0.7.22

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 (267) hide show
  1. package/dist/{apiInterceptorWorker-LRHkKnha.mjs → apiInterceptorWorker-D8M55a0M.mjs} +25 -10
  2. package/dist/{grammar.tmLanguage-DNepe_jP.mjs → grammar.tmLanguage-JAlHWPqw.mjs} +1 -1
  3. package/dist/{index-5NLXyjX0.mjs → index-BLoqesEB.mjs} +21343 -19576
  4. package/dist/index.css +1 -1
  5. package/dist/scripts/bin/build-lib.js +10 -4
  6. package/dist/scripts/bin/build.js +1 -4
  7. package/dist/scripts/bin/index.js +7 -7
  8. package/dist/scripts/bin/preview.js +19 -2
  9. package/dist/scripts/bin/start.js +2 -4
  10. package/dist/scripts/bin/viteConfig.js +2 -11
  11. package/dist/scripts/src/abstractions/ComponentDefs.js +2 -1
  12. package/dist/scripts/src/components/APICall/APICall.js +3 -3
  13. package/dist/scripts/src/components/APICall/APICallNative.js +2 -2
  14. package/dist/scripts/src/components/Accordion/Accordion.js +5 -5
  15. package/dist/scripts/src/components/Accordion/AccordionContext.js +1 -1
  16. package/dist/scripts/src/components/Accordion/AccordionItem.js +5 -5
  17. package/dist/scripts/src/components/Accordion/AccordionItemNative.js +3 -3
  18. package/dist/scripts/src/components/Accordion/AccordionNative.js +3 -3
  19. package/dist/scripts/src/components/Alert/Alert.js +4 -4
  20. package/dist/scripts/src/components/App/App.js +5 -5
  21. package/dist/scripts/src/components/App/AppNative.js +33 -34
  22. package/dist/scripts/src/components/App/Sheet.js +4 -4
  23. package/dist/scripts/src/components/AppHeader/AppHeader.js +6 -6
  24. package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +9 -9
  25. package/dist/scripts/src/components/AppState/AppState.js +2 -2
  26. package/dist/scripts/src/components/AppState/AppStateNative.js +2 -2
  27. package/dist/scripts/src/components/AutoComplete/AutoComplete.js +7 -7
  28. package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +29 -31
  29. package/dist/scripts/src/components/Avatar/Avatar.js +4 -4
  30. package/dist/scripts/src/components/Avatar/AvatarNative.js +1 -1
  31. package/dist/scripts/src/components/Backdrop/Backdrop.js +4 -4
  32. package/dist/scripts/src/components/Badge/Badge.js +3 -3
  33. package/dist/scripts/src/components/Badge/BadgeNative.js +2 -2
  34. package/dist/scripts/src/components/Bookmark/Bookmark.js +2 -2
  35. package/dist/scripts/src/components/Bookmark/BookmarkNative.js +1 -1
  36. package/dist/scripts/src/components/Breakout/Breakout.js +2 -2
  37. package/dist/scripts/src/components/Button/Button.js +6 -6
  38. package/dist/scripts/src/components/Button/ButtonNative.js +3 -3
  39. package/dist/scripts/src/components/ButtonGroup/ButtonGroup.js +5 -5
  40. package/dist/scripts/src/components/Card/Card.js +5 -5
  41. package/dist/scripts/src/components/Card/CardNative.js +7 -7
  42. package/dist/scripts/src/components/Carousel/Carousel.js +5 -5
  43. package/dist/scripts/src/components/Carousel/CarouselItem.js +3 -3
  44. package/dist/scripts/src/components/Carousel/CarouselItemNative.js +3 -3
  45. package/dist/scripts/src/components/Carousel/CarouselNative.js +6 -6
  46. package/dist/scripts/src/components/ChangeListener/ChangeListener.js +3 -3
  47. package/dist/scripts/src/components/ChangeListener/ChangeListenerNative.js +1 -1
  48. package/dist/scripts/src/components/Chart/Chart.js +2 -2
  49. package/dist/scripts/src/components/Chart/ChartNative.js +5 -6
  50. package/dist/scripts/src/components/Checkbox/Checkbox.js +6 -6
  51. package/dist/scripts/src/components/ColorPicker/ColorPicker.js +43 -0
  52. package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +54 -0
  53. package/dist/scripts/src/components/Column/Column.js +2 -2
  54. package/dist/scripts/src/components/Column/ColumnNative.js +2 -2
  55. package/dist/scripts/src/components/ComponentProvider.js +192 -94
  56. package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +4 -4
  57. package/dist/scripts/src/components/ContentSeparator/ContentSeparatorNative.js +1 -1
  58. package/dist/scripts/src/components/DatePicker/DatePicker.js +4 -4
  59. package/dist/scripts/src/components/DatePicker/DatePickerNative.js +18 -19
  60. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +6 -6
  61. package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +5 -5
  62. package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +4 -4
  63. package/dist/scripts/src/components/EmojiSelector/EmojiSelectorNative.js +1 -1
  64. package/dist/scripts/src/components/FileInput/FileInput.js +6 -6
  65. package/dist/scripts/src/components/FileInput/FileInputNative.js +6 -6
  66. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +3 -3
  67. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +6 -7
  68. package/dist/scripts/src/components/FlowLayout/FlowLayout.js +8 -6
  69. package/dist/scripts/src/components/FlowLayout/FlowLayoutNative.js +27 -16
  70. package/dist/scripts/src/components/Footer/Footer.js +4 -4
  71. package/dist/scripts/src/components/Footer/FooterNative.js +2 -2
  72. package/dist/scripts/src/components/Form/Form.js +5 -5
  73. package/dist/scripts/src/components/Form/FormNative.js +29 -29
  74. package/dist/scripts/src/components/FormItem/FormItem.js +4 -4
  75. package/dist/scripts/src/components/FormItem/FormItemNative.js +26 -16
  76. package/dist/scripts/src/components/FormItem/HelperText.js +3 -3
  77. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +5 -6
  78. package/dist/scripts/src/components/FormItem/Validations.js +5 -5
  79. package/dist/scripts/src/components/FormSection/FormSection.js +2 -2
  80. package/dist/scripts/src/components/Heading/Heading.js +3 -3
  81. package/dist/scripts/src/components/Heading/HeadingNative.js +10 -11
  82. package/dist/scripts/src/components/HoverCard/HoverCard.js +3 -3
  83. package/dist/scripts/src/components/HoverCard/HovercardNative.js +1 -1
  84. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1226 -19
  85. package/dist/scripts/src/components/Icon/Icon.js +3 -3
  86. package/dist/scripts/src/components/Icon/IconNative.js +3 -3
  87. package/dist/scripts/src/components/IconInfoCard/IconInfoCard.js +5 -4
  88. package/dist/scripts/src/components/IconProvider.js +49 -49
  89. package/dist/scripts/src/components/Image/Image.js +4 -4
  90. package/dist/scripts/src/components/Image/ImageNative.js +2 -2
  91. package/dist/scripts/src/components/Input/InputAdornment.js +3 -3
  92. package/dist/scripts/src/components/Items/Items.js +3 -3
  93. package/dist/scripts/src/components/Link/Link.js +6 -6
  94. package/dist/scripts/src/components/Link/LinkNative.js +29 -11
  95. package/dist/scripts/src/components/List/List.js +14 -16
  96. package/dist/scripts/src/components/List/ListNative.js +97 -218
  97. package/dist/scripts/src/components/Logo/Logo.js +2 -2
  98. package/dist/scripts/src/components/Logo/LogoNative.js +2 -2
  99. package/dist/scripts/src/components/Markdown/Markdown.js +3 -3
  100. package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
  101. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +5 -5
  102. package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +8 -8
  103. package/dist/scripts/src/components/NavGroup/NavGroup.js +6 -6
  104. package/dist/scripts/src/components/NavGroup/NavGroupNative.js +8 -8
  105. package/dist/scripts/src/components/NavLink/NavLink.js +5 -5
  106. package/dist/scripts/src/components/NavLink/NavLinkNative.js +6 -6
  107. package/dist/scripts/src/components/NavPanel/NavPanel.js +5 -5
  108. package/dist/scripts/src/components/NavPanel/NavPanelNative.js +6 -6
  109. package/dist/scripts/src/components/NoResult/NoResult.js +4 -4
  110. package/dist/scripts/src/components/NoResult/NoResultNative.js +2 -2
  111. package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -4
  112. package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +7 -7
  113. package/dist/scripts/src/components/OffCanvas/OffCanvas.js +5 -5
  114. package/dist/scripts/src/components/OffCanvas/OffCanvasNative.js +2 -2
  115. package/dist/scripts/src/components/Option/Option.js +4 -4
  116. package/dist/scripts/src/components/PageHeader/PageHeader.js +2 -2
  117. package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +2 -2
  118. package/dist/scripts/src/components/Pages/Pages.js +3 -3
  119. package/dist/scripts/src/components/Pages/PagesNative.js +2 -2
  120. package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +3 -3
  121. package/dist/scripts/src/components/PositionedContainer/PositionedContainerNative.js +1 -1
  122. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +3 -3
  123. package/dist/scripts/src/components/ProgressBar/ProgressBarNative.js +1 -1
  124. package/dist/scripts/src/components/Queue/Queue.js +3 -3
  125. package/dist/scripts/src/components/Queue/QueueNative.js +5 -5
  126. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -4
  127. package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +6 -6
  128. package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +2 -2
  129. package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +3 -3
  130. package/dist/scripts/src/components/Redirect/Redirect.js +2 -2
  131. package/dist/scripts/src/components/Select/Select.js +7 -7
  132. package/dist/scripts/src/components/Select/SelectNative.js +36 -37
  133. package/dist/scripts/src/components/SelectionStore/SelectionStore.js +2 -2
  134. package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +2 -2
  135. package/dist/scripts/src/components/Slider/Slider.js +39 -24
  136. package/dist/scripts/src/components/Slider/SliderNative.js +98 -3
  137. package/dist/scripts/src/components/SlotItem.js +2 -2
  138. package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +3 -3
  139. package/dist/scripts/src/components/Spinner/Spinner.js +3 -3
  140. package/dist/scripts/src/components/Spinner/SpinnerNative.js +3 -4
  141. package/dist/scripts/src/components/Splitter/Splitter.js +6 -6
  142. package/dist/scripts/src/components/Splitter/SplitterNative.js +3 -3
  143. package/dist/scripts/src/components/Stack/Stack.js +6 -6
  144. package/dist/scripts/src/components/Stack/StackNative.js +3 -3
  145. package/dist/scripts/src/components/StickyBox/StickyBox.js +3 -3
  146. package/dist/scripts/src/components/StickyBox/StickyBoxNative.js +1 -1
  147. package/dist/scripts/src/components/Switch/Switch.js +6 -6
  148. package/dist/scripts/src/components/Table/Table.js +9 -9
  149. package/dist/scripts/src/components/Table/TableNative.js +15 -15
  150. package/dist/scripts/src/components/Table/useRowSelection.js +4 -4
  151. package/dist/scripts/src/components/TableHeader/TableHeader.js +2 -2
  152. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +3 -3
  153. package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +3 -3
  154. package/dist/scripts/src/components/Tabs/TabContext.js +1 -1
  155. package/dist/scripts/src/components/Tabs/TabItem.js +3 -3
  156. package/dist/scripts/src/components/Tabs/TabItemNative.js +2 -2
  157. package/dist/scripts/src/components/Tabs/Tabs.js +5 -5
  158. package/dist/scripts/src/components/Tabs/TabsNative.js +2 -2
  159. package/dist/scripts/src/components/Text/Text.js +4 -4
  160. package/dist/scripts/src/components/Text/TextNative.js +6 -7
  161. package/dist/scripts/src/components/TextArea/TextArea.js +4 -4
  162. package/dist/scripts/src/components/TextArea/TextAreaNative.js +6 -6
  163. package/dist/scripts/src/components/TextBox/TextBox.js +4 -4
  164. package/dist/scripts/src/components/TextBox/TextBoxNative.js +5 -5
  165. package/dist/scripts/src/components/Theme/Theme.js +2 -2
  166. package/dist/scripts/src/components/Theme/ThemeNative.js +7 -7
  167. package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +11 -11
  168. package/dist/scripts/src/components/ThemeChanger/ToneChangerButton.js +5 -5
  169. package/dist/scripts/src/components/Toggle/Toggle.js +4 -4
  170. package/dist/scripts/src/components/Toolbar/Toolbar.js +2 -2
  171. package/dist/scripts/src/components/ToolbarButton/ToolbarButton.js +2 -2
  172. package/dist/scripts/src/components/Tree/TreeComponent.js +4 -4
  173. package/dist/scripts/src/components/Tree/TreeNative.js +2 -2
  174. package/dist/scripts/src/components/TrendLabel/TrendLabel.js +2 -2
  175. package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +8 -8
  176. package/dist/scripts/src/components/abstractions.js +6 -2
  177. package/dist/scripts/src/components/container-helpers.js +2 -2
  178. package/dist/scripts/src/components-core/CompoundComponent.js +2 -2
  179. package/dist/scripts/src/components-core/Fragment.js +2 -2
  180. package/dist/scripts/src/components-core/InspectorContext.js +5 -5
  181. package/dist/scripts/src/components-core/LoaderComponent.js +3 -3
  182. package/dist/scripts/src/components-core/RestApiProxy.js +4 -4
  183. package/dist/scripts/src/components-core/Slot.js +2 -2
  184. package/dist/scripts/src/components-core/TableOfContentsContext.js +1 -1
  185. package/dist/scripts/src/components-core/XmluiCodeHighlighter.js +2 -2
  186. package/dist/scripts/src/components-core/action/APICall.js +4 -4
  187. package/dist/scripts/src/components-core/action/FileDownloadAction.js +1 -1
  188. package/dist/scripts/src/components-core/action/FileUploadAction.js +3 -3
  189. package/dist/scripts/src/components-core/action/NavigateAction.js +1 -1
  190. package/dist/scripts/src/components-core/action/TimedAction.js +1 -1
  191. package/dist/scripts/src/components-core/component-hooks.js +2 -2
  192. package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
  193. package/dist/scripts/src/components-core/loader/ApiLoader.js +5 -5
  194. package/dist/scripts/src/components-core/loader/DataLoader.js +18 -10
  195. package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +5 -5
  196. package/dist/scripts/src/components-core/loader/Loader.js +3 -3
  197. package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +5 -5
  198. package/dist/scripts/src/components-core/loader/PageableLoader.js +3 -3
  199. package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +21 -15
  200. package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +2 -2
  201. package/dist/scripts/src/components-core/rendering/Container.js +16 -16
  202. package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +1 -1
  203. package/dist/scripts/src/components-core/rendering/InvalidComponent.js +1 -1
  204. package/dist/scripts/src/components-core/rendering/StateContainer.js +15 -15
  205. package/dist/scripts/src/components-core/rendering/reducer.js +1 -1
  206. package/dist/scripts/src/components-core/rendering/renderChild.js +1 -1
  207. package/dist/scripts/src/components-core/rendering/valueExtractor.js +4 -4
  208. package/dist/scripts/src/components-core/script-runner/asyncProxy.js +1 -1
  209. package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +1 -1
  210. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +1 -1
  211. package/dist/scripts/src/components-core/script-runner/process-statement-async.js +2 -2
  212. package/dist/scripts/src/components-core/script-runner/process-statement-common.js +1 -1
  213. package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +3 -3
  214. package/dist/scripts/src/components-core/script-runner/syncProxy.js +1 -1
  215. package/dist/scripts/src/components-core/script-runner/visitors.js +1 -1
  216. package/dist/scripts/src/components-core/theming/ThemeProvider.js +10 -10
  217. package/dist/scripts/src/components-core/theming/extendThemeUtils.js +1 -1
  218. package/dist/scripts/src/components-core/theming/layout-resolver.js +356 -0
  219. package/dist/scripts/src/components-core/theming/transformThemeVars.js +1 -1
  220. package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +9 -3
  221. package/dist/scripts/src/components-core/utils/actionUtils.js +3 -3
  222. package/dist/scripts/src/components-core/utils/compound-utils.js +1 -1
  223. package/dist/scripts/src/components-core/utils/css-utils.js +2 -2
  224. package/dist/scripts/src/components-core/utils/extractParam.js +3 -3
  225. package/dist/scripts/src/components-core/utils/hooks.js +3 -3
  226. package/dist/scripts/src/parsers/scripting/modules.js +1 -1
  227. package/dist/scripts/src/parsers/style-parser/style-compiler.js +6 -2
  228. package/dist/scripts/src/parsers/xmlui-parser/transform.js +14 -15
  229. package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
  230. package/dist/scripts/src/syntax/textMate/xmlui.json +27 -93
  231. package/dist/style.css +1 -1
  232. package/dist/xmlui-metadata.mjs +4651 -3827
  233. package/dist/xmlui-metadata.umd.js +23 -18
  234. package/dist/xmlui-standalone.umd.js +194 -193
  235. package/dist/xmlui.d.ts +3 -2
  236. package/dist/xmlui.mjs +1 -1
  237. package/package.json +3 -3
  238. package/dist/scripts/package.json +0 -210
  239. package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +0 -116
  240. package/dist/scripts/src/components/ModalDialog/Dialog.js +0 -20
  241. package/dist/scripts/src/components/Range/Range.js +0 -56
  242. package/dist/scripts/src/components/Range/RangeNative.js +0 -8
  243. package/dist/scripts/src/components/RawHtml/RawHtml.js +0 -39
  244. package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +0 -13
  245. package/dist/scripts/src/components-core/StandaloneApp.js +0 -589
  246. package/dist/scripts/src/components-core/abstractions/standalone.js +0 -2
  247. package/dist/scripts/src/components-core/appContext/date-functions.js +0 -19
  248. package/dist/scripts/src/components-core/appContext/math-function.js +0 -27
  249. package/dist/scripts/src/components-core/appContext/misc-utils.js +0 -13
  250. package/dist/scripts/src/components-core/interception/ApiInterceptor.js +0 -198
  251. package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +0 -94
  252. package/dist/scripts/src/components-core/interception/Backend.js +0 -129
  253. package/dist/scripts/src/components-core/interception/Errors.js +0 -129
  254. package/dist/scripts/src/components-core/interception/InMemoryDb.js +0 -41
  255. package/dist/scripts/src/components-core/interception/IndexedDb.js +0 -205
  256. package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +0 -145
  257. package/dist/scripts/src/components-core/interception/abstractions.js +0 -2
  258. package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +0 -46
  259. package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +0 -9
  260. package/dist/scripts/src/components-core/markup-check.js +0 -279
  261. package/dist/scripts/src/components-core/rendering/AppContent.js +0 -339
  262. package/dist/scripts/src/components-core/rendering/AppRoot.js +0 -55
  263. package/dist/scripts/src/components-core/rendering/AppWrapper.js +0 -44
  264. package/dist/scripts/src/components-core/utils/classnames.js +0 -58
  265. package/dist/scripts/src/components-core/utils/date-utils.js +0 -78
  266. package/dist/scripts/src/components-core/utils/request-params.js +0 -70
  267. package/dist/scripts/src/index.js +0 -66
@@ -1,589 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.startApp = startApp;
16
- const jsx_runtime_1 = require("react/jsx-runtime");
17
- const react_1 = require("react");
18
- const client_1 = __importDefault(require("react-dom/client"));
19
- require("../index.scss");
20
- const AppRoot_1 = require("@components-core/rendering/AppRoot");
21
- const misc_1 = require("@components-core/utils/misc");
22
- const ApiInterceptorProvider_1 = require("@components-core/interception/ApiInterceptorProvider");
23
- const constants_1 = require("@components-core/constants");
24
- const xmlui_parser_1 = require("@components-core/xmlui-parser");
25
- const hooks_1 = require("./utils/hooks");
26
- const fileExtensions_1 = require("../parsers/xmlui-parser/fileExtensions");
27
- const Parser_1 = require("../parsers/scripting/Parser");
28
- const code_behind_collect_1 = require("../parsers/scripting/code-behind-collect");
29
- const ComponentProvider_1 = require("@components/ComponentProvider");
30
- const markup_check_1 = require("@components-core/markup-check");
31
- const StandaloneExtensionManager_1 = __importDefault(require("./StandaloneExtensionManager"));
32
- const ThemeProvider_1 = require("@components-core/theming/ThemeProvider");
33
- const MAIN_FILE = "Main." + fileExtensions_1.componentFileExtension;
34
- const MAIN_CODE_BEHIND_FILE = "Main." + fileExtensions_1.codeBehindFileExtension;
35
- const CONFIG_FILE = "config.json";
36
- /**
37
- * This React component represents a standalone app that implements a web
38
- * application with xmlui components. A StandaloneApp instance uses a
39
- * AppRoot wrapped into an ApiInterceptor.
40
- *
41
- * AppRoot is responsible for rendering the app (using an internal
42
- * representation); ApiInterceptor can emulate some backend functionality
43
- * running in the browser.
44
- */
45
- function StandaloneApp({ appDef, decorateComponentsWithTestId, debugEnabled = false, runtime, extensionManager, }) {
46
- var _a;
47
- // --- Fetch all files constituting the standalone app, including components,
48
- // --- themes, and other artifacts. Display the app version numbers in the
49
- // --- console.
50
- const standaloneApp = useStandalone(appDef, runtime, extensionManager);
51
- usePrintVersionNumber(standaloneApp);
52
- if (!standaloneApp) {
53
- // --- Problems found, the standalone app cannot run
54
- return null;
55
- }
56
- const { apiInterceptor, name, appGlobals, defaultTheme, defaultTone, resources, resourceMap, entryPoint, components, themes, sources, } = standaloneApp;
57
- // --- The app may use a mocked API already defined in `window.XMLUI_MOCK_API`
58
- // --- or within the standalone app's definition, in `apiInterceptor`.
59
- const mockedApi =
60
- // @ts-ignore
61
- typeof window !== "undefined" && window.XMLUI_MOCK_API ? window.XMLUI_MOCK_API : apiInterceptor;
62
- // --- Components can be decorated with test IDs used in end-to-end tests.
63
- // --- This flag checks the environment if the app runs in E2E test mode.
64
- const shouldDecorateWithTestId = decorateComponentsWithTestId ||
65
- // @ts-ignore
66
- (typeof window !== "undefined" ? window.XMLUI_MOCK_TEST_ID : false);
67
- // --- An app can turn off the default hash routing.
68
- const useHashBasedRouting = (_a = appGlobals === null || appGlobals === void 0 ? void 0 : appGlobals.useHashBasedRouting) !== null && _a !== void 0 ? _a : true;
69
- return ((0, jsx_runtime_1.jsx)(ApiInterceptorProvider_1.ApiInterceptorProvider, { interceptor: mockedApi, useHashBasedRouting: useHashBasedRouting, children: (0, jsx_runtime_1.jsx)(AppRoot_1.AppRoot, { decorateComponentsWithTestId: shouldDecorateWithTestId, node: entryPoint, standalone: true, debugEnabled: debugEnabled,
70
- // @ts-ignore
71
- routerBaseName: typeof window !== "undefined" ? window.__PUBLIC_PATH || "" : "", globalProps: Object.assign({ name: name }, (appGlobals || {})), defaultTheme: defaultTheme, defaultTone: defaultTone, resources: resources, resourceMap: resourceMap, sources: sources, extensionManager: extensionManager, contributes: {
72
- compoundComponents: components,
73
- themes,
74
- } }) }));
75
- }
76
- /**
77
- * This function parses the response of a fetch retrieving the contents of a
78
- * component markup file.
79
- * @param response The response coming from the fetch
80
- * @returns If parsing is successful, it returns the parsed response containing
81
- * the component definition. Otherwise, it returns a component definition that
82
- * displays the errors.
83
- */
84
- function parseComponentMarkupResponse(response) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- if (!response.ok) {
87
- throw new Error(`Failed to fetch ${response.url}`);
88
- }
89
- const code = yield response.text();
90
- const fileId = response.url;
91
- let { component, errors, erroneousCompoundComponentName } = (0, xmlui_parser_1.xmlUiMarkupToComponent)(code, fileId);
92
- if (errors.length > 0) {
93
- const compName = erroneousCompoundComponentName !== null && erroneousCompoundComponentName !== void 0 ? erroneousCompoundComponentName : response.url.substring(response.url.lastIndexOf("/") + 1, response.url.length - ".xmlui".length);
94
- component = (0, xmlui_parser_1.errReportComponent)(errors, fileId, compName);
95
- }
96
- return {
97
- component,
98
- src: code,
99
- file: fileId,
100
- hasError: errors.length > 0,
101
- };
102
- });
103
- }
104
- /**
105
- * This function parses the response of a fetch retrieving the contents of a
106
- * code-behind file.
107
- * @param response The response coming from the fetch
108
- * @returns If parsing is successful, it returns the parsed response containing
109
- * the code-behind declarations. Otherwise, it returns a component definition that
110
- * displays the errors.
111
- */
112
- function parseCodeBehindResponse(response) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- var _a;
115
- if (!response.ok) {
116
- throw new Error(`Failed to fetch ${response.url}`);
117
- }
118
- const code = yield response.text();
119
- const parser = new Parser_1.Parser(code);
120
- try {
121
- parser.parseStatements();
122
- }
123
- catch (e) {
124
- // throw new Error(`Failed to fetch ${response.url}`);
125
- if (parser.errors.length > 0) {
126
- return {
127
- component: (0, xmlui_parser_1.errReportScriptError)(parser.errors[0], response.url),
128
- file: response.url,
129
- hasError: true,
130
- };
131
- }
132
- }
133
- const codeBehind = (0, code_behind_collect_1.collectCodeBehindFromSource)("Main", code, () => {
134
- return "";
135
- }, (a) => a);
136
- if (Object.keys((_a = codeBehind.moduleErrors) !== null && _a !== void 0 ? _a : {}).length > 0) {
137
- return {
138
- component: (0, xmlui_parser_1.errReportModuleErrors)(codeBehind.moduleErrors, response.url),
139
- file: response.url,
140
- hasError: true,
141
- };
142
- }
143
- // --- Remove the code-behind tokens from the tree shrinking the tree
144
- (0, code_behind_collect_1.removeCodeBehindTokensFromTree)(codeBehind);
145
- return {
146
- codeBehind: codeBehind,
147
- file: response.url,
148
- };
149
- });
150
- }
151
- // --- Tests is the given path matches the speified file name
152
- function matchesFileName(path, fileName) {
153
- return (path.endsWith(`/${fileName}.ts`) ||
154
- path.endsWith(`/${fileName}.js`) ||
155
- path.endsWith(`/${fileName}.${fileExtensions_1.componentFileExtension}`) ||
156
- path.endsWith(`/${fileName}.${fileExtensions_1.codeBehindFileExtension}`));
157
- }
158
- // --- Tests if the given path contains the specified folder
159
- function matchesFolder(path, folderName) {
160
- return path.includes(`/${folderName}/`);
161
- }
162
- /**
163
- * This function turns a collection of runtime file declarations into a standalone
164
- * app description.
165
- * @param runtime A hash object containing the runtime files. The keys are the file
166
- * paths and the values are the file contents.
167
- * @returns The standalone app description.
168
- *
169
- * When the standalone app is pre-compiled, each property in `runtime` holds such a
170
- * pre-compiled item. Otherwise, `runtime` is an empty object.
171
- *
172
- * While processing the files here, we can assume they are free from compilation
173
- * errors, as such errors would be observed in the compile phase.
174
- */
175
- function resolveRuntime(runtime) {
176
- // --- Collect the components and their sources. We pass the sources to the standalone app
177
- // --- so that it can be used for error display and debugging purposes.
178
- const sources = {};
179
- const componentsByFileName = {};
180
- const codeBehindsByFileName = {};
181
- const themes = [];
182
- // --- Some working variables
183
- let config;
184
- let entryPoint;
185
- let entryPointCodeBehind;
186
- let apiInterceptor;
187
- // --- Process the runtime files
188
- for (const [key, value] of Object.entries(runtime)) {
189
- if (matchesFileName(key, "config")) {
190
- // --- We assume that the config file has a default export and this
191
- // --- export is the standalone app's configuration.
192
- config = value.default;
193
- }
194
- // --- We assume that the entry point is either named "Main" or "App".
195
- if (matchesFileName(key, "Main") || matchesFileName(key, "App")) {
196
- if (key.endsWith(fileExtensions_1.codeBehindFileExtension)) {
197
- // --- "default" contains the functions and variables declared in the
198
- // --- code behind file.
199
- entryPointCodeBehind = value.default;
200
- }
201
- else {
202
- // --- "default" contains the component definition, the file index,
203
- // --- and the source code.
204
- entryPoint = value.default.component;
205
- if (value.default.file) {
206
- sources[value.default.file] = value.default.src;
207
- }
208
- }
209
- }
210
- // --- Use API emulation if available
211
- if (matchesFileName(key, "api")) {
212
- apiInterceptor = value.default;
213
- }
214
- // --- Collect the components and their code behinds
215
- if (matchesFolder(key, "components")) {
216
- if (key.endsWith(`.${fileExtensions_1.codeBehindFileExtension}`)) {
217
- // --- "default" contains the functions and variables declared in the
218
- // --- component's code behind file.
219
- codeBehindsByFileName[key] = value.default;
220
- }
221
- else {
222
- // --- "default" contains the component definition, the file index,
223
- // --- and the source code.
224
- componentsByFileName[key] = value.default.component;
225
- sources[value.default.file] = value.default.src;
226
- }
227
- }
228
- // --- Collect the themes declared with the app
229
- if (matchesFolder(key, "themes")) {
230
- themes.push(value.default);
231
- }
232
- }
233
- // --- We have an entry point defined in the configuration file or in the main app file.
234
- const safeEntryPoint = (config === null || config === void 0 ? void 0 : config.entryPoint) || entryPoint;
235
- // --- We may have a code-behind file. If so, we merge the variables and functions
236
- const entryPointWithCodeBehind = Object.assign(Object.assign({}, safeEntryPoint), { vars: Object.assign(Object.assign({}, entryPointCodeBehind === null || entryPointCodeBehind === void 0 ? void 0 : entryPointCodeBehind.vars), safeEntryPoint === null || safeEntryPoint === void 0 ? void 0 : safeEntryPoint.vars), functions: entryPointCodeBehind === null || entryPointCodeBehind === void 0 ? void 0 : entryPointCodeBehind.functions, scriptError: entryPointCodeBehind === null || entryPointCodeBehind === void 0 ? void 0 : entryPointCodeBehind.moduleErrors });
237
- // --- Collect the component definition we pass to the rendering engine
238
- let components = [];
239
- if (config === null || config === void 0 ? void 0 : config.components) {
240
- // --- We have a list of components defined in the configuration file
241
- components = config.components;
242
- }
243
- else {
244
- // --- Use the components collected from the runtime files; merge the components
245
- // --- with their code behinds
246
- Object.entries(componentsByFileName).forEach(([key, compound]) => {
247
- const componentCodeBehind = codeBehindsByFileName[`${key}.xs`];
248
- const componentWithCodeBehind = Object.assign(Object.assign({}, compound), { component: Object.assign(Object.assign({}, compound.component), { vars: Object.assign(Object.assign({}, compound.component.vars), componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.vars), functions: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.functions, scriptError: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.moduleErrors }) });
249
- components.push(componentWithCodeBehind);
250
- });
251
- }
252
- // --- Done.
253
- return Object.assign(Object.assign({}, config), { entryPoint: entryPointWithCodeBehind, components, themes: (config === null || config === void 0 ? void 0 : config.themes) || themes, apiInterceptor: (config === null || config === void 0 ? void 0 : config.apiInterceptor) || apiInterceptor, sources });
254
- }
255
- /**
256
- * Merges app definitions
257
- * @param resolvedRuntime Standalone app definition coming from the resolved runtime
258
- * @param standaloneAppDef Standalode app definition coming from the source
259
- * @returns Merged standalone app definition
260
- */
261
- function mergeAppDefWithRuntime(resolvedRuntime, standaloneAppDef) {
262
- if (!standaloneAppDef) {
263
- return resolvedRuntime;
264
- }
265
- return Object.assign(Object.assign({}, standaloneAppDef), { entryPoint: standaloneAppDef.entryPoint || resolvedRuntime.entryPoint, components: standaloneAppDef.components || resolvedRuntime.components, themes: standaloneAppDef.themes || resolvedRuntime.themes, apiInterceptor: standaloneAppDef.apiInterceptor || resolvedRuntime.apiInterceptor });
266
- }
267
- /**
268
- * Fetch the up-to-date state of the source file
269
- * @param url The URL to fetch the source file from
270
- * @returns The source file contents response
271
- */
272
- function fetchWithoutCache(url) {
273
- return __awaiter(this, void 0, void 0, function* () {
274
- return fetch((0, misc_1.normalizePath)(url), {
275
- headers: {
276
- "Cache-Control": "no-cache, no-store",
277
- },
278
- });
279
- });
280
- }
281
- /**
282
- * Using its definition, this React hook prepares the runtime environment of a
283
- * standalone app. It runs every time an app source file changes.
284
- * @param standaloneAppDef The standalone app description
285
- * @param runtime The pre-compiled runtime environment
286
- * @returns The prepared StandaloneAppDescription if the collection is
287
- * successful; otherwise, null.
288
- */
289
- function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT, extensionManager) {
290
- const [standaloneApp, setStandaloneApp] = (0, react_1.useState)(() => {
291
- // --- Initialize the standalone app
292
- const resolvedRuntime = resolveRuntime(runtime);
293
- const appDef = mergeAppDefWithRuntime(resolvedRuntime, standaloneAppDef);
294
- // --- In dev mode or when the app is inlined (provided we do not use the standalone mode),
295
- // --- we must have the app definition available.
296
- if ((process.env.VITE_DEV_MODE || process.env.VITE_BUILD_MODE === "INLINE_ALL") &&
297
- !process.env.VITE_STANDALONE) {
298
- if (!appDef) {
299
- throw new Error("couldn't find the application metadata");
300
- }
301
- return appDef;
302
- }
303
- // --- No standalone app yet, we need to get that from the fetched source code
304
- return null;
305
- });
306
- (0, hooks_1.useIsomorphicLayoutEffect)(() => {
307
- (function () {
308
- return __awaiter(this, void 0, void 0, function* () {
309
- var _a, _b, _c, _d;
310
- const resolvedRuntime = resolveRuntime(runtime);
311
- const appDef = mergeAppDefWithRuntime(resolvedRuntime, standaloneAppDef);
312
- // --- In dev mode or when the app is inlined (provided we do not use the standalone mode),
313
- // --- we must have the app definition available.
314
- if ((process.env.VITE_DEV_MODE || process.env.VITE_BUILD_MODE === "INLINE_ALL") &&
315
- !process.env.VITE_STANDALONE) {
316
- if (!appDef) {
317
- throw new Error("couldn't find the application metadata");
318
- }
319
- setStandaloneApp(appDef);
320
- return;
321
- }
322
- // --- In standalone mode, we must fetch the XMLUI app's source files,
323
- // --- compile them, and prepare the app's definition for the rendering
324
- // --- engine.
325
- if (process.env.VITE_BUILD_MODE === "CONFIG_ONLY") {
326
- // --- In config-only mode, we override the pre-compiled app definition
327
- // --- with elements from the configuration file. Note that we do not
328
- // --- check whether the config file's content is semantically valid.
329
- const configResponse = yield fetchWithoutCache(CONFIG_FILE);
330
- const config = yield configResponse.json();
331
- const themePromises = [];
332
- (_a = config.themes) === null || _a === void 0 ? void 0 : _a.forEach((theme) => {
333
- themePromises.push(fetchWithoutCache(theme).then((value) => value.json()));
334
- });
335
- const themes = yield Promise.all(themePromises);
336
- setStandaloneApp(Object.assign(Object.assign({}, appDef), { name: config.name, appGlobals: config.appGlobals, defaultTheme: config.defaultTheme, resources: config.resources, resourceMap: config.resourceMap, themes }));
337
- return;
338
- }
339
- // --- Fetch the main file
340
- const entryPointPromise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
341
- try {
342
- const resp = yield fetchWithoutCache(MAIN_FILE);
343
- if (resp.ok) {
344
- resolve(parseComponentMarkupResponse(resp));
345
- }
346
- else {
347
- resolve({
348
- component: (0, xmlui_parser_1.errReportMessage)(`Failed to load the main component (${MAIN_FILE})`),
349
- file: MAIN_FILE,
350
- hasError: true,
351
- });
352
- }
353
- }
354
- catch (e) {
355
- resolve(null);
356
- }
357
- }));
358
- // --- Fetch the main code-behind file (if any)
359
- const entryPointCodeBehindPromise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
360
- try {
361
- const resp = yield fetchWithoutCache(MAIN_CODE_BEHIND_FILE);
362
- const codeBehind = yield parseCodeBehindResponse(resp);
363
- resolve(codeBehind.hasError ? codeBehind : codeBehind.codeBehind);
364
- }
365
- catch (e) {
366
- resolve(null);
367
- }
368
- }));
369
- // --- Fetch the configuration file (we do not check whether the content is semantically valid)
370
- let config = undefined;
371
- try {
372
- const configResponse = yield fetchWithoutCache(CONFIG_FILE);
373
- config = yield configResponse.json();
374
- }
375
- catch (e) { }
376
- // --- Fetch the themes according to the configuration
377
- const themePromises = (_b = config === null || config === void 0 ? void 0 : config.themes) === null || _b === void 0 ? void 0 : _b.map((themePath) => {
378
- return fetchWithoutCache(themePath).then((value) => value.json());
379
- });
380
- // --- Fetch component files according to the configuration
381
- const componentPromises = (_c = config === null || config === void 0 ? void 0 : config.components) === null || _c === void 0 ? void 0 : _c.map((componentPath) => __awaiter(this, void 0, void 0, function* () {
382
- const value = yield fetchWithoutCache(componentPath);
383
- if (componentPath.endsWith(`.${fileExtensions_1.componentFileExtension}`)) {
384
- return yield parseComponentMarkupResponse(value);
385
- }
386
- else {
387
- return yield parseCodeBehindResponse(value);
388
- }
389
- }));
390
- // --- Let the promises resolve
391
- const [loadedEntryPoint, loadedEntryPointCodeBehind, loadedComponents, themes] = yield Promise.all([
392
- entryPointPromise,
393
- entryPointCodeBehindPromise,
394
- Promise.all(componentPromises || []),
395
- Promise.all(themePromises || []),
396
- ]);
397
- // --- Collect the elements of the standalone app (and potential errors)
398
- const errorComponents = [];
399
- // --- Check if the main component has errors
400
- if (loadedEntryPoint.hasError) {
401
- errorComponents.push(loadedEntryPoint.component);
402
- }
403
- if (loadedEntryPointCodeBehind === null || loadedEntryPointCodeBehind === void 0 ? void 0 : loadedEntryPointCodeBehind.hasError) {
404
- errorComponents.push(loadedEntryPointCodeBehind.component);
405
- }
406
- // --- Check if any of the components have markup errors
407
- loadedComponents.forEach((compWrapper) => {
408
- if (compWrapper.hasError) {
409
- errorComponents.push(compWrapper.component);
410
- }
411
- });
412
- // --- Collect the sources and code-behinds
413
- const sources = {};
414
- const codeBehinds = {};
415
- // --- The main component source
416
- if (loadedEntryPoint.file) {
417
- sources[loadedEntryPoint.file] = loadedEntryPoint.src;
418
- }
419
- // --- Components may have code-behind files
420
- loadedComponents.forEach((compWrapper) => {
421
- var _a;
422
- if ((_a = compWrapper === null || compWrapper === void 0 ? void 0 : compWrapper.file) === null || _a === void 0 ? void 0 : _a.endsWith(`.${fileExtensions_1.codeBehindFileExtension}`)) {
423
- codeBehinds[compWrapper.file] = compWrapper.codeBehind;
424
- }
425
- else {
426
- if (compWrapper.file) {
427
- sources[compWrapper.file] = compWrapper.src;
428
- }
429
- }
430
- });
431
- // --- Assemble the runtime for the main app file
432
- const entryPointWithCodeBehind = Object.assign(Object.assign({}, loadedEntryPoint.component), { vars: Object.assign(Object.assign({}, loadedEntryPointCodeBehind === null || loadedEntryPointCodeBehind === void 0 ? void 0 : loadedEntryPointCodeBehind.vars), loadedEntryPoint.component.vars), functions: loadedEntryPointCodeBehind === null || loadedEntryPointCodeBehind === void 0 ? void 0 : loadedEntryPointCodeBehind.functions, scriptError: loadedEntryPointCodeBehind === null || loadedEntryPointCodeBehind === void 0 ? void 0 : loadedEntryPointCodeBehind.moduleErrors });
433
- const defaultTheme = (_d = entryPointWithCodeBehind.props) === null || _d === void 0 ? void 0 : _d.defaultTheme;
434
- // --- We test whether the default theme is not from a binding
435
- // --- expression and is not a built-in theme already loaded. If so,
436
- // --- we load it from the `themes` folder.
437
- if (defaultTheme && typeof defaultTheme === "string" && !defaultTheme.includes("{")) {
438
- if (!ThemeProvider_1.builtInThemes.find((theme) => theme.id === defaultTheme) &&
439
- !themes.find((theme) => theme.id === defaultTheme)) {
440
- themes.push(yield fetchWithoutCache(`themes/${defaultTheme}.json`).then((value) => value.json()));
441
- }
442
- }
443
- // --- Assemble the runtime for the components
444
- const componentsWithCodeBehinds = loadedComponents
445
- .filter((compWrapper) => { var _a; return !((_a = compWrapper === null || compWrapper === void 0 ? void 0 : compWrapper.file) === null || _a === void 0 ? void 0 : _a.endsWith(".xmlui.xs")); })
446
- .map((compWrapper) => {
447
- const componentCodeBehind = codeBehinds[compWrapper.file + ".xs"];
448
- return Object.assign(Object.assign({}, compWrapper.component), { component: Object.assign(Object.assign({}, compWrapper.component.component), { vars: Object.assign(Object.assign({}, compWrapper.component.component.vars), componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.vars), functions: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.functions, scriptError: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.moduleErrors }) });
449
- });
450
- // --- We may have components that are not in the configuration file.
451
- // --- We need to load them and their code-behinds. First, we collect
452
- // --- the components to load.
453
- let componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, undefined, extensionManager);
454
- // --- Try to load the components referenced in the markup, collect
455
- // --- those that failed
456
- const componentsFailedToLoad = new Set();
457
- while (componentsToLoad.size > 0) {
458
- const componentPromises = [...componentsToLoad].map((componentPath) => __awaiter(this, void 0, void 0, function* () {
459
- try {
460
- // --- Promises for the component markup files
461
- const componentPromise = fetchWithoutCache(`components/${componentPath}.${fileExtensions_1.componentFileExtension}`);
462
- // --- Promises for the component code-behind files
463
- const componentCodeBehindPromise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
464
- try {
465
- const codeBehindWrapper = yield parseCodeBehindResponse(yield fetchWithoutCache(`components/${componentPath}.${fileExtensions_1.codeBehindFileExtension}`));
466
- if (codeBehindWrapper.hasError) {
467
- errorComponents.push(codeBehindWrapper.component);
468
- }
469
- resolve(codeBehindWrapper.hasError
470
- ? codeBehindWrapper.component
471
- : codeBehindWrapper.codeBehind);
472
- }
473
- catch (_a) {
474
- resolve(null);
475
- }
476
- }));
477
- // --- Let the promises resolve
478
- const [componentMarkup, componentCodeBehind] = yield Promise.all([
479
- componentPromise,
480
- componentCodeBehindPromise,
481
- ]);
482
- // --- Parse the component markup and check for errors
483
- const compWrapper = yield parseComponentMarkupResponse(componentMarkup);
484
- if (compWrapper.hasError) {
485
- errorComponents.push(compWrapper.component);
486
- }
487
- sources[compWrapper.file] = compWrapper.src;
488
- return Object.assign(Object.assign({}, compWrapper.component), { component: Object.assign(Object.assign({}, compWrapper.component.component), { vars: Object.assign(Object.assign({}, compWrapper.component.component.vars), componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.vars), functions: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.functions, scriptError: componentCodeBehind === null || componentCodeBehind === void 0 ? void 0 : componentCodeBehind.moduleErrors }) });
489
- }
490
- catch (e) {
491
- componentsFailedToLoad.add(componentPath);
492
- return null;
493
- }
494
- }));
495
- const componentWrappers = yield Promise.all(componentPromises);
496
- componentsWithCodeBehinds.push(...componentWrappers.filter((comp) => !!comp));
497
- componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, componentsFailedToLoad, extensionManager);
498
- }
499
- // --- Let's check for errors to display
500
- const errorComponent = errorComponents.length > 0
501
- ? {
502
- type: "VStack",
503
- props: { gap: 0, padding: 0 },
504
- children: errorComponents,
505
- }
506
- : null;
507
- setStandaloneApp(Object.assign(Object.assign({}, config), { themes,
508
- sources, components: componentsWithCodeBehinds, entryPoint: errorComponent || entryPointWithCodeBehind }));
509
- });
510
- })();
511
- }, [runtime, standaloneAppDef]);
512
- return standaloneApp;
513
- }
514
- /**
515
- * Collect the missing components referenced by any part of the app
516
- * @param entryPoint The app's main markup
517
- * @param components The component markups
518
- * @param componentsFailedToLoad The components that failed to load here
519
- * @returns The components that are still missing
520
- */
521
- function collectMissingComponents(entryPoint, components, componentsFailedToLoad = new Set(), extensionManager) {
522
- // --- Add the discovered compound components to the registry
523
- const componentRegistry = new ComponentProvider_1.ComponentRegistry({ compoundComponents: components }, extensionManager);
524
- // --- Check the xmlui markup. This check will find all unloaded components
525
- const result = (0, markup_check_1.checkXmlUiMarkup)(entryPoint, components, {
526
- getComponentProps: (componentName) => {
527
- var _a, _b;
528
- return (_b = (_a = componentRegistry.lookupComponentRenderer(componentName)) === null || _a === void 0 ? void 0 : _a.descriptor) === null || _b === void 0 ? void 0 : _b.props;
529
- },
530
- acceptArbitraryProps: () => {
531
- return true;
532
- },
533
- getComponentValidator: () => {
534
- return null;
535
- },
536
- getComponentEvents: () => {
537
- return null;
538
- },
539
- componentRegistered: (componentName) => {
540
- return componentRegistry.hasComponent(componentName);
541
- },
542
- });
543
- componentRegistry.destroy();
544
- // --- Collect all missing components.
545
- // Omit the components that failed to load and the ones that are not in #app-ns namespace
546
- return new Set(result
547
- .filter((r) => r.code === "M001")
548
- .map((r) => r.args[0].replace("#app-ns.", ""))
549
- .filter((comp) => !componentsFailedToLoad.has(comp) && !comp.includes(".")));
550
- }
551
- // --- This React hook logs the app's version number to the browser's console at startup
552
- function usePrintVersionNumber(standaloneApp) {
553
- const logged = (0, react_1.useRef)(false);
554
- (0, react_1.useEffect)(() => {
555
- if (logged.current) {
556
- return;
557
- }
558
- logged.current = true;
559
- let log = `XMLUI version: ${process.env.VITE_XMLUI_VERSION || "dev"}`;
560
- if (standaloneApp === null || standaloneApp === void 0 ? void 0 : standaloneApp.name) {
561
- log += `; ${standaloneApp.name} version: ${process.env.VITE_APP_VERSION || "dev"}`;
562
- }
563
- console.log(log);
564
- }, [standaloneApp === null || standaloneApp === void 0 ? void 0 : standaloneApp.name]);
565
- }
566
- let contentRoot = null;
567
- /**
568
- * This function injects the StandaloneApp component into a React app. It looks
569
- * up a component with the "root" id as the host of the standalone app. If such
570
- * an element does not exist, it creates a `<div id="root">` element.
571
- * @param runtime The app's runtime representation
572
- * @param components The related component's runtime representation
573
- * @returns The content's root element
574
- */
575
- function startApp(runtime, extensions = [], extensionManager = new StandaloneExtensionManager_1.default()) {
576
- extensionManager.registerExtension(extensions);
577
- let rootElement = document.getElementById("root");
578
- if (!rootElement) {
579
- rootElement = document.createElement("div");
580
- rootElement.setAttribute("id", "root");
581
- document.body.appendChild(rootElement);
582
- }
583
- if (!contentRoot) {
584
- contentRoot = client_1.default.createRoot(rootElement);
585
- }
586
- contentRoot.render((0, jsx_runtime_1.jsx)(StandaloneApp, { runtime: runtime, extensionManager: extensionManager }));
587
- return contentRoot;
588
- }
589
- exports.default = StandaloneApp;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateFunctions = void 0;
4
- const date_utils_1 = require("../utils/date-utils");
5
- exports.dateFunctions = {
6
- isoDateString: date_utils_1.isoDateString,
7
- formatDate: date_utils_1.formatDate,
8
- formatDateTime: date_utils_1.formatDateTime,
9
- formatTime: date_utils_1.formatTime,
10
- formatTimeWithoutSeconds: date_utils_1.formatTimeWithoutSeconds,
11
- formatDateWithoutYear: date_utils_1.formatDateWithoutYear,
12
- getDate: date_utils_1.getDate,
13
- getDateUntilNow: date_utils_1.getDateUntilNow,
14
- smartFormatDateTime: date_utils_1.smartFormatDateTime,
15
- smartFormatDate: date_utils_1.smartFormatDate,
16
- isToday: date_utils_1.isDateToday,
17
- isYesterday: date_utils_1.isDateYesterday,
18
- isTomorrow: date_utils_1.isDateTomorrow
19
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mathFunctions = void 0;
4
- /**
5
- * This function calculates the average of the specified values and returns it.
6
- * @param values Values to calculate the average
7
- * @param decimals Number of decimal places to round the result
8
- */
9
- function avg(values, decimals) {
10
- if (values.length === 0) {
11
- return 0;
12
- }
13
- const sumValues = sum(values);
14
- const result = sumValues / values.length;
15
- return decimals ? Number(result.toFixed(decimals)) : result;
16
- }
17
- /**
18
- * This function calculates the sum of the specified values and returns it.
19
- * @param values Values to calculate the sum
20
- */
21
- function sum(values) {
22
- return values.reduce((acc, val) => acc + val, 0);
23
- }
24
- exports.mathFunctions = {
25
- avg,
26
- sum
27
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.miscellaneousUtils = void 0;
4
- const lodash_es_1 = require("lodash-es");
5
- const misc_1 = require("@components-core/utils/misc");
6
- exports.miscellaneousUtils = {
7
- capitalize: lodash_es_1.capitalize,
8
- pluralize: misc_1.pluralize,
9
- defaultTo: lodash_es_1.defaultTo,
10
- toHashObject: misc_1.toHashObject,
11
- findByField: misc_1.findByField,
12
- distinct: misc_1.distinct
13
- };