xmlui 0.10.13 → 0.10.14
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.
- package/dist/lib/{index-Db5iQkFp.mjs → index-779mp2Bm.mjs} +943 -736
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-B9LtmFJG.mjs → initMock-CAXdczCj.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +16 -1
- package/dist/lib/xmlui.mjs +33 -32
- package/dist/metadata/{collectedComponentMetadata-BN8eg9Gr.mjs → collectedComponentMetadata-7DFXlw-J.mjs} +15057 -14865
- package/dist/metadata/{initMock-J7pN8owj.mjs → initMock-AFWEftc6.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/bin/build-lib.js +21 -13
- package/dist/scripts/bin/viteConfig.js +3 -1
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/abstractions/scripting/Token.js +2 -0
- package/dist/scripts/src/abstractions/scripting/TryScope.js +2 -0
- package/dist/scripts/src/abstractions/scripting/modules.js +2 -0
- package/dist/scripts/src/components/APICall/APICall.spec.js +910 -0
- package/dist/scripts/src/components/Accordion/Accordion.spec.js +969 -0
- package/dist/scripts/src/components/Animation/Animation.js +50 -0
- package/dist/scripts/src/components/App/App.spec.js +219 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.spec.js +169 -0
- package/dist/scripts/src/components/AppState/AppState.spec.js +268 -0
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +383 -0
- package/dist/scripts/src/components/Avatar/Avatar.spec.js +1543 -0
- package/dist/scripts/src/components/Backdrop/Backdrop.spec.js +131 -0
- package/dist/scripts/src/components/Badge/Badge.spec.js +2214 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.spec.js +230 -0
- package/dist/scripts/src/components/Breakout/Breakout.spec.js +56 -0
- package/dist/scripts/src/components/Button/Button-style.spec.js +274 -0
- package/dist/scripts/src/components/Button/Button.spec.js +454 -0
- package/dist/scripts/src/components/Card/Card.spec.js +150 -0
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +343 -0
- package/dist/scripts/src/components/Carousel/CarouselNative.js +2 -2
- package/dist/scripts/src/components/ChangeListener/ChangeListener.spec.js +169 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.spec.js +999 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChart.spec.js +597 -0
- package/dist/scripts/src/components/Charts/DonutChart/DonutChart.spec.js +608 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelList.spec.js +539 -0
- package/dist/scripts/src/components/Charts/Legend/Legend.spec.js +558 -0
- package/dist/scripts/src/components/Charts/LineChart/LineChart.spec.js +450 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChart.spec.js +584 -0
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.spec.js +571 -0
- package/dist/scripts/src/components/Charts/Tooltip/TooltipContent.spec.js +449 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +964 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlock.spec.js +196 -0
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +283 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +9 -26
- package/dist/scripts/src/components/Column/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/ComponentProvider.js +6 -2
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +338 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +918 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +362 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +3 -3
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +331 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.spec.js +29 -0
- package/dist/scripts/src/components/ExpandableItem/ExpandableItem.spec.js +435 -0
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +249 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.spec.js +296 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.spec.js +518 -0
- package/dist/scripts/src/components/Footer/Footer.spec.js +991 -0
- package/dist/scripts/src/components/Form/Form.spec.js +1257 -0
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +723 -0
- package/dist/scripts/src/components/FormSection/FormSection.js +6 -31
- package/dist/scripts/src/components/Fragment/Fragment.spec.js +50 -0
- package/dist/scripts/src/components/Heading/H1.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H2.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H3.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H4.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H5.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H6.spec.js +66 -0
- package/dist/scripts/src/components/Heading/Heading.spec.js +897 -0
- package/dist/scripts/src/components/HtmlTags/HtmlTags.spec.js +69 -0
- package/dist/scripts/src/components/IFrame/IFrame.spec.js +527 -0
- package/dist/scripts/src/components/Icon/ArrowDropDown.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowDropUp.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowLeft.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowRight.js +11 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.spec.js +527 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Image/Image.js +2 -1
- package/dist/scripts/src/components/Image/Image.spec.js +198 -0
- package/dist/scripts/src/components/Image/ImageNative.js +30 -2
- package/dist/scripts/src/components/Input/InputLabel.js +25 -0
- package/dist/scripts/src/components/Input/index.js +5 -0
- package/dist/scripts/src/components/Items/Items.spec.js +397 -0
- package/dist/scripts/src/components/Link/Link.spec.js +894 -0
- package/dist/scripts/src/components/List/List.spec.js +927 -0
- package/dist/scripts/src/components/List/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/Markdown/Markdown.spec.js +188 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.spec.js +162 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.spec.js +153 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +2 -2
- package/dist/scripts/src/components/NavLink/NavLink.spec.js +864 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.spec.js +864 -0
- package/dist/scripts/src/components/NoResult/NoResult.spec.js +863 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +1231 -0
- package/dist/scripts/src/components/Option/Option.spec.js +472 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.spec.js +80 -0
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +1003 -0
- package/dist/scripts/src/components/ProfileMenu/ProfileMenu.js +20 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.spec.js +166 -0
- package/dist/scripts/src/components/Queue/Queue.spec.js +626 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +479 -0
- package/dist/scripts/src/components/Redirect/Redirect.spec.js +527 -0
- package/dist/scripts/src/components/ResponsiveBar/ResponsiveBar.spec.js +76 -0
- package/dist/scripts/src/components/Select/Select.spec.js +527 -0
- package/dist/scripts/src/components/Slider/Slider.js +2 -0
- package/dist/scripts/src/components/Slider/Slider.spec.js +574 -0
- package/dist/scripts/src/components/Slider/SliderNative.js +62 -25
- package/dist/scripts/src/components/Slot/Slot.spec.js +368 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.spec.js +184 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +161 -0
- package/dist/scripts/src/components/Splitter/HSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Splitter/Splitter.spec.js +543 -0
- package/dist/scripts/src/components/Splitter/VSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Stack/CHStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/CVStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/HStack.spec.js +67 -0
- package/dist/scripts/src/components/Stack/Stack.spec.js +654 -0
- package/dist/scripts/src/components/Stack/VStack.spec.js +67 -0
- package/dist/scripts/src/components/Switch/Switch.spec.js +829 -0
- package/dist/scripts/src/components/Table/Table.spec.js +555 -0
- package/dist/scripts/src/components/Table/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/TableOfContents/TableOfContents.spec.js +838 -0
- package/dist/scripts/src/components/Tabs/Tabs.spec.js +875 -0
- package/dist/scripts/src/components/Text/Text.spec.js +1075 -0
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +714 -0
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +643 -0
- package/dist/scripts/src/components/Theme/Theme.spec.js +124 -0
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +1122 -0
- package/dist/scripts/src/components/Timer/Timer.spec.js +358 -0
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.spec.js +414 -0
- package/dist/scripts/src/components/ToneSwitch/ToneSwitch.spec.js +89 -0
- package/dist/scripts/src/components/Tooltip/Tooltip.spec.js +418 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components-core/CompoundComponent.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +85 -8
- package/dist/scripts/src/components-core/devtools/InspectorDialogVisibilityContext.js +8 -0
- package/dist/scripts/src/components-core/renderers.js +31 -0
- package/dist/scripts/src/components-core/script-runner/simplify-expression.js +386 -0
- package/dist/scripts/src/components-core/theming/component-layout-resolver.js +153 -0
- package/dist/scripts/src/components-core/theming/parse-layout-props.js +98 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/utils/audio-utils.js +83 -0
- package/dist/scripts/src/index-standalone.js +61 -0
- package/dist/scripts/src/index.js +2 -1
- package/dist/scripts/src/language-server/server-common.js +151 -0
- package/dist/scripts/src/language-server/server-web-worker.js +47 -0
- package/dist/scripts/src/language-server/server.js +42 -0
- package/dist/scripts/src/language-server/services/common/docs-generation.js +73 -0
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +9 -0
- package/dist/scripts/src/language-server/services/common/syntax-node-utilities.js +135 -0
- package/dist/scripts/src/language-server/services/completion.js +270 -0
- package/dist/scripts/src/language-server/services/diagnostic.js +19 -0
- package/dist/scripts/src/language-server/services/format.js +430 -0
- package/dist/scripts/src/language-server/services/hover.js +164 -0
- package/dist/scripts/src/language-server/xmlui-metadata-generated.mjs +16266 -0
- package/dist/scripts/src/logging/xmlui.js +21 -0
- package/dist/scripts/src/parsers/common/utils.js +19 -0
- package/dist/scripts/src/syntax/monaco/grammar.monacoLanguage.js +286 -0
- package/dist/scripts/src/syntax/monaco/index.js +14 -0
- package/dist/scripts/src/syntax/monaco/xmlui-dark.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmlui-light.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmluiscript.monacoLanguage.js +310 -0
- package/dist/scripts/src/syntax/textMate/index.js +14 -0
- package/dist/scripts/src/syntax/textMate/xmlui-dark.json +631 -0
- package/dist/scripts/src/syntax/textMate/xmlui-light.json +565 -0
- package/dist/scripts/src/syntax/textMate/xmlui.json +564 -0
- package/dist/scripts/src/syntax/textMate/xmlui.tmLanguage.json +341 -0
- package/dist/scripts/src/testing/ComponentDrivers.js +1355 -0
- package/dist/scripts/src/testing/assertions.js +444 -0
- package/dist/scripts/src/testing/component-test-helpers.js +389 -0
- package/dist/scripts/src/testing/drivers/DateInputDriver.js +19 -0
- package/dist/scripts/src/testing/drivers/ModalDialogDriver.js +10 -0
- package/dist/scripts/src/testing/drivers/TimeInputDriver.js +22 -0
- package/dist/scripts/src/testing/drivers/TimerDriver.js +64 -0
- package/dist/scripts/src/testing/fixtures.js +487 -0
- package/dist/scripts/src/testing/infrastructure/TestBed.js +17 -0
- package/dist/scripts/src/testing/infrastructure/main.js +9 -0
- package/dist/scripts/src/testing/infrastructure/public/mockServiceWorker.js +266 -0
- package/dist/scripts/src/testing/themed-app-test-helpers.js +139 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +18 -1
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -438,7 +438,7 @@ declare interface ComponentDefCore {
|
|
|
438
438
|
debug?: Record<string, any>;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
declare type ComponentExtension = ComponentRendererDef |
|
|
441
|
+
declare type ComponentExtension = ComponentRendererDef | CompoundComponentRendererInfo;
|
|
442
442
|
|
|
443
443
|
declare type ComponentLike = ComponentDef | CompoundComponentDef;
|
|
444
444
|
|
|
@@ -506,6 +506,11 @@ declare interface CompoundComponentDef extends Scriptable {
|
|
|
506
506
|
codeBehind?: string;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
declare type CompoundComponentRendererInfo = {
|
|
510
|
+
compoundComponentDef: CompoundComponentDef;
|
|
511
|
+
metadata?: ComponentMetadata;
|
|
512
|
+
};
|
|
513
|
+
|
|
509
514
|
declare type CONDITIONAL_EXPRESSION = typeof T_CONDITIONAL_EXPRESSION;
|
|
510
515
|
|
|
511
516
|
declare interface ConditionalExpression extends ExpressionBase {
|
|
@@ -561,6 +566,16 @@ declare function createComponentRenderer<TMd extends ComponentMetadata>(type: st
|
|
|
561
566
|
|
|
562
567
|
declare function createMetadata<TProps extends Record<string, ComponentPropertyMetadata>, TEvents extends Record<string, ComponentPropertyMetadata>, TContextVars extends Record<string, ComponentPropertyMetadata> = Record<string, any>, TApis extends Record<string, ComponentPropertyMetadata> = Record<string, any>>(metadata: ComponentMetadata<TProps, TEvents, TContextVars, TApis>): ComponentMetadata<TProps, TEvents, TContextVars, TApis>;
|
|
563
568
|
|
|
569
|
+
/**
|
|
570
|
+
* This helper function creates a user defined component renderer definition from its arguments.
|
|
571
|
+
* @param metadata The metadata of the user-defined component
|
|
572
|
+
* @param componentMarkup The XMLUI markup that defines the user-defined component
|
|
573
|
+
* @param codeBehind Optional code-behind script that contains variable and function definitions
|
|
574
|
+
* used by the component
|
|
575
|
+
* @returns The view renderer definition composed of the arguments
|
|
576
|
+
*/
|
|
577
|
+
declare function createUserDefinedComponentRenderer<TMd extends ComponentMetadata>(metadata: TMd, def: any, codeBehind?: any): CompoundComponentRendererInfo;
|
|
578
|
+
|
|
564
579
|
declare function d(description: string, availableValues?: readonly PropertyValueDescription[], valueType?: PropertyValueType, defaultValue?: any, isValid?: IsValidFunction<any>, isRequired?: boolean): ComponentPropertyMetadata;
|
|
565
580
|
|
|
566
581
|
declare function dComponent(description: string): ComponentPropertyMetadata;
|
|
@@ -1349,6 +1364,7 @@ declare const standaloneExports: {
|
|
|
1349
1364
|
StandaloneApp: typeof xmluiExports.StandaloneApp;
|
|
1350
1365
|
StandaloneExtensionManager: typeof StandaloneExtensionManager;
|
|
1351
1366
|
createComponentRenderer: typeof xmluiExports.createComponentRenderer;
|
|
1367
|
+
createUserDefinedComponentRenderer: typeof xmluiExports.createUserDefinedComponentRenderer;
|
|
1352
1368
|
createMetadata: typeof xmluiExports.createMetadata;
|
|
1353
1369
|
d: typeof xmluiExports.d;
|
|
1354
1370
|
dComponent: typeof xmluiExports.dComponent;
|
|
@@ -2119,6 +2135,7 @@ declare namespace xmluiExports {
|
|
|
2119
2135
|
StandaloneApp,
|
|
2120
2136
|
StandaloneExtensionManager,
|
|
2121
2137
|
createComponentRenderer,
|
|
2138
|
+
createUserDefinedComponentRenderer,
|
|
2122
2139
|
createMetadata,
|
|
2123
2140
|
d,
|
|
2124
2141
|
dComponent,
|