xmlui 0.10.13 → 0.10.15

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 (217) hide show
  1. package/dist/lib/{index-Db5iQkFp.mjs → index-axjeT2uJ.mjs} +1626 -1080
  2. package/dist/lib/index.css +1 -1
  3. package/dist/lib/{initMock-B9LtmFJG.mjs → initMock-BoTWMs19.mjs} +1 -1
  4. package/dist/lib/language-server-web-worker.mjs +1 -1
  5. package/dist/lib/language-server.mjs +1 -1
  6. package/dist/lib/{metadata-utils-D90qqMGc.mjs → metadata-utils-CtY0QcvH.mjs} +2 -1
  7. package/dist/lib/{server-common-lmBDLpUh.mjs → server-common-Cine5nRR.mjs} +1 -1
  8. package/dist/lib/xmlui.d.ts +99 -6
  9. package/dist/lib/xmlui.mjs +78 -42
  10. package/dist/metadata/{collectedComponentMetadata-BN8eg9Gr.mjs → collectedComponentMetadata-CQywuPDB.mjs} +17448 -16984
  11. package/dist/metadata/{initMock-J7pN8owj.mjs → initMock-Bi5kF5Af.mjs} +1 -1
  12. package/dist/metadata/style.css +1 -1
  13. package/dist/metadata/xmlui-metadata.mjs +1 -1
  14. package/dist/metadata/xmlui-metadata.umd.js +3 -3
  15. package/dist/scripts/bin/build-lib.js +21 -13
  16. package/dist/scripts/bin/viteConfig.js +3 -1
  17. package/dist/scripts/package.json +2 -3
  18. package/dist/scripts/src/abstractions/scripting/Token.js +2 -0
  19. package/dist/scripts/src/abstractions/scripting/TryScope.js +2 -0
  20. package/dist/scripts/src/abstractions/scripting/modules.js +2 -0
  21. package/dist/scripts/src/components/APICall/APICall.spec.js +910 -0
  22. package/dist/scripts/src/components/Accordion/Accordion.spec.js +969 -0
  23. package/dist/scripts/src/components/Animation/Animation.js +50 -0
  24. package/dist/scripts/src/components/App/App.spec.js +219 -0
  25. package/dist/scripts/src/components/AppHeader/AppHeader.spec.js +169 -0
  26. package/dist/scripts/src/components/AppState/AppState.js +32 -2
  27. package/dist/scripts/src/components/AppState/AppState.spec.js +268 -0
  28. package/dist/scripts/src/components/AppState/AppStateNative.js +27 -3
  29. package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +383 -0
  30. package/dist/scripts/src/components/Avatar/Avatar.spec.js +1543 -0
  31. package/dist/scripts/src/components/Backdrop/Backdrop.spec.js +131 -0
  32. package/dist/scripts/src/components/Badge/Badge.spec.js +2214 -0
  33. package/dist/scripts/src/components/Bookmark/Bookmark.spec.js +230 -0
  34. package/dist/scripts/src/components/Breakout/Breakout.spec.js +56 -0
  35. package/dist/scripts/src/components/Button/Button-style.spec.js +274 -0
  36. package/dist/scripts/src/components/Button/Button.js +5 -1
  37. package/dist/scripts/src/components/Button/Button.spec.js +454 -0
  38. package/dist/scripts/src/components/Card/Card.spec.js +150 -0
  39. package/dist/scripts/src/components/Carousel/Carousel.spec.js +343 -0
  40. package/dist/scripts/src/components/Carousel/CarouselNative.js +2 -2
  41. package/dist/scripts/src/components/ChangeListener/ChangeListener.spec.js +169 -0
  42. package/dist/scripts/src/components/Charts/AreaChart/AreaChart.spec.js +999 -0
  43. package/dist/scripts/src/components/Charts/BarChart/BarChart.spec.js +597 -0
  44. package/dist/scripts/src/components/Charts/DonutChart/DonutChart.spec.js +608 -0
  45. package/dist/scripts/src/components/Charts/LabelList/LabelList.spec.js +539 -0
  46. package/dist/scripts/src/components/Charts/Legend/Legend.spec.js +558 -0
  47. package/dist/scripts/src/components/Charts/LineChart/LineChart.spec.js +450 -0
  48. package/dist/scripts/src/components/Charts/PieChart/PieChart.spec.js +584 -0
  49. package/dist/scripts/src/components/Charts/PieChart/PieChartNative.js +41 -2
  50. package/dist/scripts/src/components/Charts/RadarChart/RadarChart.spec.js +571 -0
  51. package/dist/scripts/src/components/Charts/Tooltip/TooltipContent.spec.js +449 -0
  52. package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +964 -0
  53. package/dist/scripts/src/components/CodeBlock/CodeBlock.spec.js +196 -0
  54. package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +283 -0
  55. package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +9 -26
  56. package/dist/scripts/src/components/Column/doc-resources/list-component-data.js +53 -0
  57. package/dist/scripts/src/components/ComponentProvider.js +6 -2
  58. package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +338 -0
  59. package/dist/scripts/src/components/DateInput/DateInput.spec.js +918 -0
  60. package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +362 -0
  61. package/dist/scripts/src/components/DatePicker/DatePickerNative.js +3 -3
  62. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +331 -0
  63. package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +7 -9
  64. package/dist/scripts/src/components/EmojiSelector/EmojiSelector.spec.js +29 -0
  65. package/dist/scripts/src/components/ExpandableItem/ExpandableItem.spec.js +435 -0
  66. package/dist/scripts/src/components/FileInput/FileInput.spec.js +249 -0
  67. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.spec.js +296 -0
  68. package/dist/scripts/src/components/FlowLayout/FlowLayout.spec.js +518 -0
  69. package/dist/scripts/src/components/Footer/Footer.spec.js +991 -0
  70. package/dist/scripts/src/components/Form/Form.spec.js +1257 -0
  71. package/dist/scripts/src/components/FormItem/FormItem.spec.js +723 -0
  72. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +3 -3
  73. package/dist/scripts/src/components/FormSection/FormSection.js +6 -31
  74. package/dist/scripts/src/components/Fragment/Fragment.spec.js +50 -0
  75. package/dist/scripts/src/components/Heading/H1.spec.js +66 -0
  76. package/dist/scripts/src/components/Heading/H2.spec.js +66 -0
  77. package/dist/scripts/src/components/Heading/H3.spec.js +66 -0
  78. package/dist/scripts/src/components/Heading/H4.spec.js +66 -0
  79. package/dist/scripts/src/components/Heading/H5.spec.js +66 -0
  80. package/dist/scripts/src/components/Heading/H6.spec.js +66 -0
  81. package/dist/scripts/src/components/Heading/Heading.spec.js +897 -0
  82. package/dist/scripts/src/components/HtmlTags/HtmlTags.spec.js +69 -0
  83. package/dist/scripts/src/components/IFrame/IFrame.spec.js +527 -0
  84. package/dist/scripts/src/components/Icon/ArrowDropDown.js +11 -0
  85. package/dist/scripts/src/components/Icon/ArrowDropUp.js +11 -0
  86. package/dist/scripts/src/components/Icon/ArrowLeft.js +11 -0
  87. package/dist/scripts/src/components/Icon/ArrowRight.js +11 -0
  88. package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
  89. package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
  90. package/dist/scripts/src/components/Icon/Icon.spec.js +527 -0
  91. package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
  92. package/dist/scripts/src/components/Image/Image.js +2 -1
  93. package/dist/scripts/src/components/Image/Image.spec.js +198 -0
  94. package/dist/scripts/src/components/Image/ImageNative.js +30 -2
  95. package/dist/scripts/src/components/Input/InputLabel.js +25 -0
  96. package/dist/scripts/src/components/Input/index.js +5 -0
  97. package/dist/scripts/src/components/Items/Items.spec.js +397 -0
  98. package/dist/scripts/src/components/Link/Link.spec.js +894 -0
  99. package/dist/scripts/src/components/List/List.spec.js +927 -0
  100. package/dist/scripts/src/components/List/doc-resources/list-component-data.js +53 -0
  101. package/dist/scripts/src/components/Markdown/Markdown.spec.js +188 -0
  102. package/dist/scripts/src/components/ModalDialog/ModalDialog.spec.js +162 -0
  103. package/dist/scripts/src/components/NavGroup/NavGroup.spec.js +212 -0
  104. package/dist/scripts/src/components/NavGroup/NavGroupNative.js +15 -7
  105. package/dist/scripts/src/components/NavLink/NavLink.spec.js +864 -0
  106. package/dist/scripts/src/components/NavPanel/NavPanel.spec.js +864 -0
  107. package/dist/scripts/src/components/NoResult/NoResult.spec.js +863 -0
  108. package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +1237 -0
  109. package/dist/scripts/src/components/Option/Option.spec.js +472 -0
  110. package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.spec.js +80 -0
  111. package/dist/scripts/src/components/Pagination/Pagination.spec.js +1003 -0
  112. package/dist/scripts/src/components/ProfileMenu/ProfileMenu.js +20 -0
  113. package/dist/scripts/src/components/ProgressBar/ProgressBar.spec.js +166 -0
  114. package/dist/scripts/src/components/Queue/Queue.spec.js +626 -0
  115. package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +479 -0
  116. package/dist/scripts/src/components/Redirect/Redirect.spec.js +527 -0
  117. package/dist/scripts/src/components/ResponsiveBar/ResponsiveBar.spec.js +76 -0
  118. package/dist/scripts/src/components/Select/Select.spec.js +527 -0
  119. package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +3 -1
  120. package/dist/scripts/src/components/Slider/Slider.js +2 -0
  121. package/dist/scripts/src/components/Slider/Slider.spec.js +574 -0
  122. package/dist/scripts/src/components/Slider/SliderNative.js +63 -26
  123. package/dist/scripts/src/components/Slot/Slot.spec.js +368 -0
  124. package/dist/scripts/src/components/SpaceFiller/SpaceFiller.spec.js +184 -0
  125. package/dist/scripts/src/components/Spinner/Spinner.spec.js +161 -0
  126. package/dist/scripts/src/components/Splitter/HSplitter.spec.js +104 -0
  127. package/dist/scripts/src/components/Splitter/Splitter.spec.js +543 -0
  128. package/dist/scripts/src/components/Splitter/VSplitter.spec.js +104 -0
  129. package/dist/scripts/src/components/Stack/CHStack.spec.js +86 -0
  130. package/dist/scripts/src/components/Stack/CVStack.spec.js +86 -0
  131. package/dist/scripts/src/components/Stack/HStack.spec.js +67 -0
  132. package/dist/scripts/src/components/Stack/Stack.spec.js +654 -0
  133. package/dist/scripts/src/components/Stack/VStack.spec.js +67 -0
  134. package/dist/scripts/src/components/Switch/Switch.spec.js +829 -0
  135. package/dist/scripts/src/components/Table/Table.js +7 -1
  136. package/dist/scripts/src/components/Table/Table.spec.js +555 -0
  137. package/dist/scripts/src/components/Table/TableNative.js +4 -1
  138. package/dist/scripts/src/components/Table/doc-resources/list-component-data.js +53 -0
  139. package/dist/scripts/src/components/Table/useRowSelection.js +215 -1
  140. package/dist/scripts/src/components/TableOfContents/TableOfContents.spec.js +838 -0
  141. package/dist/scripts/src/components/Tabs/Tabs.spec.js +875 -0
  142. package/dist/scripts/src/components/Text/Text.spec.js +1075 -0
  143. package/dist/scripts/src/components/TextArea/TextArea.spec.js +714 -0
  144. package/dist/scripts/src/components/TextBox/TextBox.js +1 -5
  145. package/dist/scripts/src/components/TextBox/TextBox.spec.js +687 -0
  146. package/dist/scripts/src/components/TextBox/TextBoxNative.js +10 -15
  147. package/dist/scripts/src/components/Theme/Theme.spec.js +124 -0
  148. package/dist/scripts/src/components/Theme/ThemeNative.js +2 -6
  149. package/dist/scripts/src/components/TimeInput/TimeInput.js +1 -5
  150. package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +1122 -0
  151. package/dist/scripts/src/components/TimeInput/TimeInputNative.js +2 -9
  152. package/dist/scripts/src/components/Timer/Timer.spec.js +358 -0
  153. package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.spec.js +414 -0
  154. package/dist/scripts/src/components/ToneSwitch/ToneSwitch.spec.js +89 -0
  155. package/dist/scripts/src/components/Tooltip/Tooltip.spec.js +418 -0
  156. package/dist/scripts/src/components/chart-color-schemes.js +43 -0
  157. package/dist/scripts/src/components-core/ApiBoundComponent.js +38 -24
  158. package/dist/scripts/src/components-core/CompoundComponent.js +1 -1
  159. package/dist/scripts/src/components-core/RestApiProxy.js +84 -8
  160. package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +54 -0
  161. package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +80 -0
  162. package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
  163. package/dist/scripts/src/components-core/devtools/InspectorDialogVisibilityContext.js +8 -0
  164. package/dist/scripts/src/components-core/parts.js +4 -1
  165. package/dist/scripts/src/components-core/renderers.js +31 -0
  166. package/dist/scripts/src/components-core/rendering/AppRoot.js +2 -1
  167. package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +31 -46
  168. package/dist/scripts/src/components-core/rendering/nodeUtils.js +6 -0
  169. package/dist/scripts/src/components-core/script-runner/simplify-expression.js +386 -0
  170. package/dist/scripts/src/components-core/theming/component-layout-resolver.js +153 -0
  171. package/dist/scripts/src/components-core/theming/layout-resolver.js +2 -0
  172. package/dist/scripts/src/components-core/theming/parse-layout-props.js +98 -0
  173. package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
  174. package/dist/scripts/src/components-core/utils/audio-utils.js +83 -0
  175. package/dist/scripts/src/index-standalone.js +61 -0
  176. package/dist/scripts/src/index.js +39 -1
  177. package/dist/scripts/src/language-server/server-common.js +151 -0
  178. package/dist/scripts/src/language-server/server-web-worker.js +47 -0
  179. package/dist/scripts/src/language-server/server.js +42 -0
  180. package/dist/scripts/src/language-server/services/common/docs-generation.js +73 -0
  181. package/dist/scripts/src/language-server/services/common/lsp-utils.js +9 -0
  182. package/dist/scripts/src/language-server/services/common/syntax-node-utilities.js +135 -0
  183. package/dist/scripts/src/language-server/services/completion.js +270 -0
  184. package/dist/scripts/src/language-server/services/diagnostic.js +19 -0
  185. package/dist/scripts/src/language-server/services/format.js +430 -0
  186. package/dist/scripts/src/language-server/services/hover.js +164 -0
  187. package/dist/scripts/src/language-server/xmlui-metadata-generated.mjs +16266 -0
  188. package/dist/scripts/src/logging/xmlui.js +21 -0
  189. package/dist/scripts/src/parsers/common/utils.js +19 -0
  190. package/dist/scripts/src/syntax/monaco/grammar.monacoLanguage.js +286 -0
  191. package/dist/scripts/src/syntax/monaco/index.js +14 -0
  192. package/dist/scripts/src/syntax/monaco/xmlui-dark.js +25 -0
  193. package/dist/scripts/src/syntax/monaco/xmlui-light.js +25 -0
  194. package/dist/scripts/src/syntax/monaco/xmluiscript.monacoLanguage.js +310 -0
  195. package/dist/scripts/src/syntax/textMate/index.js +14 -0
  196. package/dist/scripts/src/syntax/textMate/xmlui-dark.json +631 -0
  197. package/dist/scripts/src/syntax/textMate/xmlui-light.json +565 -0
  198. package/dist/scripts/src/syntax/textMate/xmlui.json +564 -0
  199. package/dist/scripts/src/syntax/textMate/xmlui.tmLanguage.json +341 -0
  200. package/dist/scripts/src/testing/ComponentDrivers.js +1327 -0
  201. package/dist/scripts/src/testing/assertions.js +444 -0
  202. package/dist/scripts/src/testing/component-test-helpers.js +389 -0
  203. package/dist/scripts/src/testing/drivers/DateInputDriver.js +19 -0
  204. package/dist/scripts/src/testing/drivers/ModalDialogDriver.js +10 -0
  205. package/dist/scripts/src/testing/drivers/NumberBoxDriver.js +44 -0
  206. package/dist/scripts/src/testing/drivers/SliderDriver.js +20 -0
  207. package/dist/scripts/src/testing/drivers/TextBoxDriver.js +20 -0
  208. package/dist/scripts/src/testing/drivers/TimeInputDriver.js +22 -0
  209. package/dist/scripts/src/testing/drivers/TimerDriver.js +64 -0
  210. package/dist/scripts/src/testing/fixtures.js +513 -0
  211. package/dist/scripts/src/testing/infrastructure/TestBed.js +17 -0
  212. package/dist/scripts/src/testing/infrastructure/main.js +9 -0
  213. package/dist/scripts/src/testing/infrastructure/public/mockServiceWorker.js +266 -0
  214. package/dist/scripts/src/testing/themed-app-test-helpers.js +139 -0
  215. package/dist/standalone/xmlui-standalone.es.d.ts +172 -10
  216. package/dist/standalone/xmlui-standalone.umd.js +36 -36
  217. package/package.json +2 -3
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ /* tslint:disable */
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ /**
14
+ * Mock Service Worker.
15
+ * @see https://github.com/mswjs/msw
16
+ * - Please do NOT modify this file.
17
+ * - Please do NOT serve this file on production.
18
+ */
19
+ const PACKAGE_VERSION = '2.8.4';
20
+ const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f';
21
+ const IS_MOCKED_RESPONSE = Symbol('isMockedResponse');
22
+ const activeClientIds = new Set();
23
+ self.addEventListener('install', function () {
24
+ self.skipWaiting();
25
+ });
26
+ self.addEventListener('activate', function (event) {
27
+ event.waitUntil(self.clients.claim());
28
+ });
29
+ self.addEventListener('message', function (event) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const clientId = event.source.id;
32
+ if (!clientId || !self.clients) {
33
+ return;
34
+ }
35
+ const client = yield self.clients.get(clientId);
36
+ if (!client) {
37
+ return;
38
+ }
39
+ const allClients = yield self.clients.matchAll({
40
+ type: 'window',
41
+ });
42
+ switch (event.data) {
43
+ case 'KEEPALIVE_REQUEST': {
44
+ sendToClient(client, {
45
+ type: 'KEEPALIVE_RESPONSE',
46
+ });
47
+ break;
48
+ }
49
+ case 'INTEGRITY_CHECK_REQUEST': {
50
+ sendToClient(client, {
51
+ type: 'INTEGRITY_CHECK_RESPONSE',
52
+ payload: {
53
+ packageVersion: PACKAGE_VERSION,
54
+ checksum: INTEGRITY_CHECKSUM,
55
+ },
56
+ });
57
+ break;
58
+ }
59
+ case 'MOCK_ACTIVATE': {
60
+ activeClientIds.add(clientId);
61
+ sendToClient(client, {
62
+ type: 'MOCKING_ENABLED',
63
+ payload: {
64
+ client: {
65
+ id: client.id,
66
+ frameType: client.frameType,
67
+ },
68
+ },
69
+ });
70
+ break;
71
+ }
72
+ case 'MOCK_DEACTIVATE': {
73
+ activeClientIds.delete(clientId);
74
+ break;
75
+ }
76
+ case 'CLIENT_CLOSED': {
77
+ activeClientIds.delete(clientId);
78
+ const remainingClients = allClients.filter((client) => {
79
+ return client.id !== clientId;
80
+ });
81
+ // Unregister itself when there are no more clients
82
+ if (remainingClients.length === 0) {
83
+ self.registration.unregister();
84
+ }
85
+ break;
86
+ }
87
+ }
88
+ });
89
+ });
90
+ self.addEventListener('fetch', function (event) {
91
+ const { request } = event;
92
+ // Bypass navigation requests.
93
+ if (request.mode === 'navigate') {
94
+ return;
95
+ }
96
+ // Opening the DevTools triggers the "only-if-cached" request
97
+ // that cannot be handled by the worker. Bypass such requests.
98
+ if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
99
+ return;
100
+ }
101
+ // Bypass all requests when there are no active clients.
102
+ // Prevents the self-unregistered worked from handling requests
103
+ // after it's been deleted (still remains active until the next reload).
104
+ if (activeClientIds.size === 0) {
105
+ return;
106
+ }
107
+ // Generate unique request ID.
108
+ const requestId = crypto.randomUUID();
109
+ event.respondWith(handleRequest(event, requestId));
110
+ });
111
+ function handleRequest(event, requestId) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const client = yield resolveMainClient(event);
114
+ const response = yield getResponse(event, client, requestId);
115
+ // Send back the response clone for the "response:*" life-cycle events.
116
+ // Ensure MSW is active and ready to handle the message, otherwise
117
+ // this message will pend indefinitely.
118
+ if (client && activeClientIds.has(client.id)) {
119
+ ;
120
+ (function () {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const responseClone = response.clone();
123
+ sendToClient(client, {
124
+ type: 'RESPONSE',
125
+ payload: {
126
+ requestId,
127
+ isMockedResponse: IS_MOCKED_RESPONSE in response,
128
+ type: responseClone.type,
129
+ status: responseClone.status,
130
+ statusText: responseClone.statusText,
131
+ body: responseClone.body,
132
+ headers: Object.fromEntries(responseClone.headers.entries()),
133
+ },
134
+ }, [responseClone.body]);
135
+ });
136
+ })();
137
+ }
138
+ return response;
139
+ });
140
+ }
141
+ // Resolve the main client for the given event.
142
+ // Client that issues a request doesn't necessarily equal the client
143
+ // that registered the worker. It's with the latter the worker should
144
+ // communicate with during the response resolving phase.
145
+ function resolveMainClient(event) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const client = yield self.clients.get(event.clientId);
148
+ if (activeClientIds.has(event.clientId)) {
149
+ return client;
150
+ }
151
+ if ((client === null || client === void 0 ? void 0 : client.frameType) === 'top-level') {
152
+ return client;
153
+ }
154
+ const allClients = yield self.clients.matchAll({
155
+ type: 'window',
156
+ });
157
+ return allClients
158
+ .filter((client) => {
159
+ // Get only those clients that are currently visible.
160
+ return client.visibilityState === 'visible';
161
+ })
162
+ .find((client) => {
163
+ // Find the client ID that's recorded in the
164
+ // set of clients that have registered the worker.
165
+ return activeClientIds.has(client.id);
166
+ });
167
+ });
168
+ }
169
+ function getResponse(event, client, requestId) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ const { request } = event;
172
+ // Clone the request because it might've been already used
173
+ // (i.e. its body has been read and sent to the client).
174
+ const requestClone = request.clone();
175
+ function passthrough() {
176
+ // Cast the request headers to a new Headers instance
177
+ // so the headers can be manipulated with.
178
+ const headers = new Headers(requestClone.headers);
179
+ // Remove the "accept" header value that marked this request as passthrough.
180
+ // This prevents request alteration and also keeps it compliant with the
181
+ // user-defined CORS policies.
182
+ const acceptHeader = headers.get('accept');
183
+ if (acceptHeader) {
184
+ const values = acceptHeader.split(',').map((value) => value.trim());
185
+ const filteredValues = values.filter((value) => value !== 'msw/passthrough');
186
+ if (filteredValues.length > 0) {
187
+ headers.set('accept', filteredValues.join(', '));
188
+ }
189
+ else {
190
+ headers.delete('accept');
191
+ }
192
+ }
193
+ return fetch(requestClone, { headers });
194
+ }
195
+ // Bypass mocking when the client is not active.
196
+ if (!client) {
197
+ return passthrough();
198
+ }
199
+ // Bypass initial page load requests (i.e. static assets).
200
+ // The absence of the immediate/parent client in the map of the active clients
201
+ // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
202
+ // and is not ready to handle requests.
203
+ if (!activeClientIds.has(client.id)) {
204
+ return passthrough();
205
+ }
206
+ // Notify the client that a request has been intercepted.
207
+ const requestBuffer = yield request.arrayBuffer();
208
+ const clientMessage = yield sendToClient(client, {
209
+ type: 'REQUEST',
210
+ payload: {
211
+ id: requestId,
212
+ url: request.url,
213
+ mode: request.mode,
214
+ method: request.method,
215
+ headers: Object.fromEntries(request.headers.entries()),
216
+ cache: request.cache,
217
+ credentials: request.credentials,
218
+ destination: request.destination,
219
+ integrity: request.integrity,
220
+ redirect: request.redirect,
221
+ referrer: request.referrer,
222
+ referrerPolicy: request.referrerPolicy,
223
+ body: requestBuffer,
224
+ keepalive: request.keepalive,
225
+ },
226
+ }, [requestBuffer]);
227
+ switch (clientMessage.type) {
228
+ case 'MOCK_RESPONSE': {
229
+ return respondWithMock(clientMessage.data);
230
+ }
231
+ case 'PASSTHROUGH': {
232
+ return passthrough();
233
+ }
234
+ }
235
+ return passthrough();
236
+ });
237
+ }
238
+ function sendToClient(client, message, transferrables = []) {
239
+ return new Promise((resolve, reject) => {
240
+ const channel = new MessageChannel();
241
+ channel.port1.onmessage = (event) => {
242
+ if (event.data && event.data.error) {
243
+ return reject(event.data.error);
244
+ }
245
+ resolve(event.data);
246
+ };
247
+ client.postMessage(message, [channel.port2].concat(transferrables.filter(Boolean)));
248
+ });
249
+ }
250
+ function respondWithMock(response) {
251
+ return __awaiter(this, void 0, void 0, function* () {
252
+ // Setting response status code to 0 is a no-op.
253
+ // However, when responding with a "Response.error()", the produced Response
254
+ // instance will have status code set to 0. Since it's not possible to create
255
+ // a Response instance with status code 0, handle that use-case separately.
256
+ if (response.status === 0) {
257
+ return Response.error();
258
+ }
259
+ const mockedResponse = new Response(response.body, response);
260
+ Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
261
+ value: true,
262
+ enumerable: true,
263
+ });
264
+ return mockedResponse;
265
+ });
266
+ }
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.initApp = initApp;
13
+ exports.prepPage = prepPage;
14
+ exports.initThemedApp = initThemedApp;
15
+ exports.scalePercentBy = scalePercentBy;
16
+ exports.getBoundingRect = getBoundingRect;
17
+ exports.getFullRectangle = getFullRectangle;
18
+ exports.isElementOverflown = isElementOverflown;
19
+ exports.pixelStrToNum = pixelStrToNum;
20
+ exports.getElementStyle = getElementStyle;
21
+ exports.getElementStyles = getElementStyles;
22
+ exports.getStyle = getStyle;
23
+ const xmlui_parser_1 = require("../components-core/xmlui-parser");
24
+ function parseComponent(entryPoint) {
25
+ if (typeof entryPoint === "string") {
26
+ return (0, xmlui_parser_1.xmlUiMarkupToComponent)(entryPoint).component;
27
+ }
28
+ return entryPoint;
29
+ }
30
+ function initApp(page_1, appDescription_1) {
31
+ return __awaiter(this, arguments, void 0, function* (page, appDescription, url = "/", resources = {}) {
32
+ const { entryPoint, components } = appDescription;
33
+ const _appDescription = Object.assign(Object.assign({}, appDescription), { name: appDescription.name || "Test App", entryPoint: parseComponent(entryPoint), resources, components: (!components
34
+ ? undefined
35
+ : Array.isArray(components)
36
+ ? components.map((comp) => parseComponent(comp))
37
+ : [parseComponent(components)]) });
38
+ yield page.addInitScript((app) => {
39
+ // @ts-ignore
40
+ window.TEST_ENV = app;
41
+ }, _appDescription);
42
+ yield page.goto(url);
43
+ });
44
+ }
45
+ function prepPage(co_1, appDesc_1) {
46
+ return __awaiter(this, arguments, void 0, function* (co, appDesc, url = "/") {
47
+ const context = co;
48
+ const page = yield context.newPage();
49
+ yield initApp(page, appDesc, url);
50
+ return page;
51
+ });
52
+ }
53
+ function initThemedApp(page, entryPoint, theme) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ var _a, _b;
56
+ (_a = theme.id) !== null && _a !== void 0 ? _a : (theme.id = "testTheme");
57
+ (_b = theme.name) !== null && _b !== void 0 ? _b : (theme.name = "Custom Test theme");
58
+ yield initApp(page, { entryPoint, defaultTheme: theme.id, themes: [theme] });
59
+ });
60
+ }
61
+ /**
62
+ * @param percentage a percenage value as a string, like "40%"
63
+ * @param scalarOf100Percent The value to multiply the percentage by
64
+ */
65
+ function scalePercentBy(scalarOf100Percent, percentage) {
66
+ if (!percentage.endsWith("%")) {
67
+ throw new Error("argument doesn't end with % sign");
68
+ }
69
+ const percentageNum = Number(percentage.slice(0, -1));
70
+ return (scalarOf100Percent / 100) * percentageNum;
71
+ }
72
+ function getBoundingRect(locator) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ return locator.evaluate((element) => element.getBoundingClientRect());
75
+ });
76
+ }
77
+ function getFullRectangle(locator) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const boundingRect = yield locator.evaluate((element) => element.getBoundingClientRect());
80
+ const margins = yield getElementStyles(locator, [
81
+ "margin-left",
82
+ "margin-right",
83
+ "margin-top",
84
+ "margin-bottom",
85
+ ]);
86
+ const marginLeft = parseFloat(margins["margin-left"]);
87
+ const marginRight = parseFloat(margins["margin-right"]);
88
+ const marginTop = parseFloat(margins["margin-top"]);
89
+ const marginBottom = parseFloat(margins["margin-bottom"]);
90
+ const width = boundingRect.width + marginLeft + marginRight;
91
+ const height = boundingRect.height + marginTop + marginBottom;
92
+ const left = boundingRect.left - marginLeft;
93
+ const right = boundingRect.right + marginRight;
94
+ const top = boundingRect.top - marginTop;
95
+ const bottom = boundingRect.bottom + marginBottom;
96
+ return { width, height, left, right, top, bottom };
97
+ });
98
+ }
99
+ function isElementOverflown(locator_1) {
100
+ return __awaiter(this, arguments, void 0, function* (locator, direction = "both") {
101
+ const [width, height, scrollWidth, scrollHeight] = yield locator.evaluate((element) => [
102
+ element.clientWidth,
103
+ element.clientHeight,
104
+ element.scrollWidth,
105
+ element.scrollHeight,
106
+ ]);
107
+ if (direction === "x")
108
+ return scrollWidth > width;
109
+ if (direction === "y")
110
+ return scrollHeight > height;
111
+ return scrollWidth > width && scrollHeight > height;
112
+ });
113
+ }
114
+ function pixelStrToNum(pixelStr) {
115
+ return Number(pixelStr.replace("px", ""));
116
+ }
117
+ function getElementStyle(locator, style) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ return locator.evaluate((element, style) => window.getComputedStyle(element).getPropertyValue(style), style);
120
+ });
121
+ }
122
+ /**
123
+ * Retreives all the provided style properties from the locator
124
+ * @returns an object with the keys being the elements of the styles argument
125
+ */
126
+ function getElementStyles(locator_1) {
127
+ return __awaiter(this, arguments, void 0, function* (locator, styles = []) {
128
+ return locator.evaluate((element, styles) => Object.fromEntries(styles.map((styleName) => [
129
+ styleName,
130
+ window.getComputedStyle(element).getPropertyValue(styleName),
131
+ ])), styles);
132
+ });
133
+ }
134
+ function getStyle(page, testId, style) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const locator = page.getByTestId(testId);
137
+ return yield getElementStyle(locator, style);
138
+ });
139
+ }