@webpros/tsxuserprofilevue 3.0.11 → 3.1.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +3 -3
- package/dist/mockServiceWorker.js +81 -100
- package/package.json +37 -40
@@ -2,13 +2,15 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
|
4
4
|
/**
|
5
|
-
* Mock Service Worker
|
5
|
+
* Mock Service Worker.
|
6
6
|
* @see https://github.com/mswjs/msw
|
7
7
|
* - Please do NOT modify this file.
|
8
8
|
* - Please do NOT serve this file on production.
|
9
9
|
*/
|
10
10
|
|
11
|
-
const
|
11
|
+
const PACKAGE_VERSION = '2.2.14'
|
12
|
+
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
13
|
+
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
12
14
|
const activeClientIds = new Set()
|
13
15
|
|
14
16
|
self.addEventListener('install', function () {
|
@@ -47,7 +49,10 @@ self.addEventListener('message', async function (event) {
|
|
47
49
|
case 'INTEGRITY_CHECK_REQUEST': {
|
48
50
|
sendToClient(client, {
|
49
51
|
type: 'INTEGRITY_CHECK_RESPONSE',
|
50
|
-
payload:
|
52
|
+
payload: {
|
53
|
+
packageVersion: PACKAGE_VERSION,
|
54
|
+
checksum: INTEGRITY_CHECKSUM,
|
55
|
+
},
|
51
56
|
})
|
52
57
|
break
|
53
58
|
}
|
@@ -86,12 +91,6 @@ self.addEventListener('message', async function (event) {
|
|
86
91
|
|
87
92
|
self.addEventListener('fetch', function (event) {
|
88
93
|
const { request } = event
|
89
|
-
const accept = request.headers.get('accept') || ''
|
90
|
-
|
91
|
-
// Bypass server-sent events.
|
92
|
-
if (accept.includes('text/event-stream')) {
|
93
|
-
return
|
94
|
-
}
|
95
94
|
|
96
95
|
// Bypass navigation requests.
|
97
96
|
if (request.mode === 'navigate') {
|
@@ -112,29 +111,8 @@ self.addEventListener('fetch', function (event) {
|
|
112
111
|
}
|
113
112
|
|
114
113
|
// Generate unique request ID.
|
115
|
-
const requestId =
|
116
|
-
|
117
|
-
event.respondWith(
|
118
|
-
handleRequest(event, requestId).catch((error) => {
|
119
|
-
if (error.name === 'NetworkError') {
|
120
|
-
console.warn(
|
121
|
-
'[MSW] Successfully emulated a network error for the "%s %s" request.',
|
122
|
-
request.method,
|
123
|
-
request.url,
|
124
|
-
)
|
125
|
-
return
|
126
|
-
}
|
127
|
-
|
128
|
-
// At this point, any exception indicates an issue with the original request/response.
|
129
|
-
console.error(
|
130
|
-
`\
|
131
|
-
[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
|
132
|
-
request.method,
|
133
|
-
request.url,
|
134
|
-
`${error.name}: ${error.message}`,
|
135
|
-
)
|
136
|
-
}),
|
137
|
-
)
|
114
|
+
const requestId = crypto.randomUUID()
|
115
|
+
event.respondWith(handleRequest(event, requestId))
|
138
116
|
})
|
139
117
|
|
140
118
|
async function handleRequest(event, requestId) {
|
@@ -146,21 +124,24 @@ async function handleRequest(event, requestId) {
|
|
146
124
|
// this message will pend indefinitely.
|
147
125
|
if (client && activeClientIds.has(client.id)) {
|
148
126
|
;(async function () {
|
149
|
-
const
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
type:
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
127
|
+
const responseClone = response.clone()
|
128
|
+
|
129
|
+
sendToClient(
|
130
|
+
client,
|
131
|
+
{
|
132
|
+
type: 'RESPONSE',
|
133
|
+
payload: {
|
134
|
+
requestId,
|
135
|
+
isMockedResponse: IS_MOCKED_RESPONSE in response,
|
136
|
+
type: responseClone.type,
|
137
|
+
status: responseClone.status,
|
138
|
+
statusText: responseClone.statusText,
|
139
|
+
body: responseClone.body,
|
140
|
+
headers: Object.fromEntries(responseClone.headers.entries()),
|
141
|
+
},
|
162
142
|
},
|
163
|
-
|
143
|
+
[responseClone.body],
|
144
|
+
)
|
164
145
|
})()
|
165
146
|
}
|
166
147
|
|
@@ -196,20 +177,20 @@ async function resolveMainClient(event) {
|
|
196
177
|
|
197
178
|
async function getResponse(event, client, requestId) {
|
198
179
|
const { request } = event
|
199
|
-
|
180
|
+
|
181
|
+
// Clone the request because it might've been already used
|
182
|
+
// (i.e. its body has been read and sent to the client).
|
183
|
+
const requestClone = request.clone()
|
200
184
|
|
201
185
|
function passthrough() {
|
202
|
-
|
203
|
-
// (i.e. its body has been read and sent to the client).
|
204
|
-
const headers = Object.fromEntries(clonedRequest.headers.entries())
|
186
|
+
const headers = Object.fromEntries(requestClone.headers.entries())
|
205
187
|
|
206
|
-
// Remove MSW
|
207
|
-
//
|
208
|
-
//
|
209
|
-
|
210
|
-
delete headers['x-msw-bypass']
|
188
|
+
// Remove internal MSW request header so the passthrough request
|
189
|
+
// complies with any potential CORS preflight checks on the server.
|
190
|
+
// Some servers forbid unknown request headers.
|
191
|
+
delete headers['x-msw-intention']
|
211
192
|
|
212
|
-
return fetch(
|
193
|
+
return fetch(requestClone, { headers })
|
213
194
|
}
|
214
195
|
|
215
196
|
// Bypass mocking when the client is not active.
|
@@ -225,57 +206,46 @@ async function getResponse(event, client, requestId) {
|
|
225
206
|
return passthrough()
|
226
207
|
}
|
227
208
|
|
228
|
-
// Bypass requests with the explicit bypass header.
|
229
|
-
// Such requests can be issued by "ctx.fetch()".
|
230
|
-
if (request.headers.get('x-msw-bypass') === 'true') {
|
231
|
-
return passthrough()
|
232
|
-
}
|
233
|
-
|
234
209
|
// Notify the client that a request has been intercepted.
|
235
|
-
const
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
210
|
+
const requestBuffer = await request.arrayBuffer()
|
211
|
+
const clientMessage = await sendToClient(
|
212
|
+
client,
|
213
|
+
{
|
214
|
+
type: 'REQUEST',
|
215
|
+
payload: {
|
216
|
+
id: requestId,
|
217
|
+
url: request.url,
|
218
|
+
mode: request.mode,
|
219
|
+
method: request.method,
|
220
|
+
headers: Object.fromEntries(request.headers.entries()),
|
221
|
+
cache: request.cache,
|
222
|
+
credentials: request.credentials,
|
223
|
+
destination: request.destination,
|
224
|
+
integrity: request.integrity,
|
225
|
+
redirect: request.redirect,
|
226
|
+
referrer: request.referrer,
|
227
|
+
referrerPolicy: request.referrerPolicy,
|
228
|
+
body: requestBuffer,
|
229
|
+
keepalive: request.keepalive,
|
230
|
+
},
|
253
231
|
},
|
254
|
-
|
232
|
+
[requestBuffer],
|
233
|
+
)
|
255
234
|
|
256
235
|
switch (clientMessage.type) {
|
257
236
|
case 'MOCK_RESPONSE': {
|
258
237
|
return respondWithMock(clientMessage.data)
|
259
238
|
}
|
260
239
|
|
261
|
-
case '
|
240
|
+
case 'PASSTHROUGH': {
|
262
241
|
return passthrough()
|
263
242
|
}
|
264
|
-
|
265
|
-
case 'NETWORK_ERROR': {
|
266
|
-
const { name, message } = clientMessage.data
|
267
|
-
const networkError = new Error(message)
|
268
|
-
networkError.name = name
|
269
|
-
|
270
|
-
// Rejecting a "respondWith" promise emulates a network error.
|
271
|
-
throw networkError
|
272
|
-
}
|
273
243
|
}
|
274
244
|
|
275
245
|
return passthrough()
|
276
246
|
}
|
277
247
|
|
278
|
-
function sendToClient(client, message) {
|
248
|
+
function sendToClient(client, message, transferrables = []) {
|
279
249
|
return new Promise((resolve, reject) => {
|
280
250
|
const channel = new MessageChannel()
|
281
251
|
|
@@ -287,17 +257,28 @@ function sendToClient(client, message) {
|
|
287
257
|
resolve(event.data)
|
288
258
|
}
|
289
259
|
|
290
|
-
client.postMessage(
|
260
|
+
client.postMessage(
|
261
|
+
message,
|
262
|
+
[channel.port2].concat(transferrables.filter(Boolean)),
|
263
|
+
)
|
291
264
|
})
|
292
265
|
}
|
293
266
|
|
294
|
-
function
|
295
|
-
|
296
|
-
|
267
|
+
async function respondWithMock(response) {
|
268
|
+
// Setting response status code to 0 is a no-op.
|
269
|
+
// However, when responding with a "Response.error()", the produced Response
|
270
|
+
// instance will have status code set to 0. Since it's not possible to create
|
271
|
+
// a Response instance with status code 0, handle that use-case separately.
|
272
|
+
if (response.status === 0) {
|
273
|
+
return Response.error()
|
274
|
+
}
|
275
|
+
|
276
|
+
const mockedResponse = new Response(response.body, response)
|
277
|
+
|
278
|
+
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
|
279
|
+
value: true,
|
280
|
+
enumerable: true,
|
297
281
|
})
|
298
|
-
}
|
299
282
|
|
300
|
-
|
301
|
-
await sleep(response.delay)
|
302
|
-
return new Response(response.body, response)
|
283
|
+
return mockedResponse
|
303
284
|
}
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"author": "Sascha Fuchs <sascha.fuchs@webpros.com>",
|
6
6
|
"license": "MIT",
|
7
|
-
"version": "3.0.
|
7
|
+
"version": "3.1.0-alpha.1",
|
8
8
|
"engines": {
|
9
9
|
"node": "18.x"
|
10
10
|
},
|
@@ -33,60 +33,57 @@
|
|
33
33
|
"story:preview": "histoire preview"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@headlessui/vue": "^1.7.
|
37
|
-
"@histoire/plugin-vue": "^0.17.
|
36
|
+
"@headlessui/vue": "^1.7.23",
|
37
|
+
"@histoire/plugin-vue": "^0.17.17",
|
38
38
|
"@tailwindcss/container-queries": "^0.1.1",
|
39
|
-
"@vueuse/core": "^
|
40
|
-
"@vueuse/integrations": "^
|
41
|
-
"axios": "^1.
|
39
|
+
"@vueuse/core": "^11.1.0",
|
40
|
+
"@vueuse/integrations": "^11.1.0",
|
41
|
+
"axios": "^1.7.7",
|
42
42
|
"container-query-polyfill": "^1.0.2",
|
43
|
-
"marked": "^5.1.
|
43
|
+
"marked": "^5.1.2",
|
44
44
|
"mitt": "^3.0.1",
|
45
|
-
"terser": "^5.
|
46
|
-
"universal-cookie": "^
|
47
|
-
"vue": "^3.
|
48
|
-
"vue-multiselect": "^3.
|
45
|
+
"terser": "^5.34.1",
|
46
|
+
"universal-cookie": "^7.2.1",
|
47
|
+
"vue": "^3.5.11",
|
48
|
+
"vue-multiselect": "^3.1.0"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"@
|
54
|
-
"@
|
55
|
-
"@
|
56
|
-
"@vitejs/plugin-vue": "^4.3.4",
|
57
|
-
"@vitest/ui": "^0.34.4",
|
51
|
+
"@babel/core": "^7.24.4",
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
53
|
+
"@typescript-eslint/parser": "^7.7.0",
|
54
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
55
|
+
"@vitest/ui": "^1.5.0",
|
58
56
|
"@vue/eslint-config-standard": "^8.0.1",
|
59
57
|
"@vue/eslint-config-typescript": "^11.0.3",
|
60
|
-
"@vue/test-utils": "^2.4.
|
61
|
-
"autoprefixer": "^10.4.
|
58
|
+
"@vue/test-utils": "^2.4.5",
|
59
|
+
"autoprefixer": "^10.4.19",
|
62
60
|
"babel-loader": "^9.1.3",
|
63
61
|
"cross-fetch": "^4.0.0",
|
64
|
-
"cssnano": "^6.
|
65
|
-
"eslint": "^
|
66
|
-
"eslint-config-prettier": "^9.
|
67
|
-
"eslint-import-resolver-typescript": "^3.6.
|
68
|
-
"eslint-plugin-import": "^2.
|
62
|
+
"cssnano": "^6.1.2",
|
63
|
+
"eslint": "^9.0.0",
|
64
|
+
"eslint-config-prettier": "^9.1.0",
|
65
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
66
|
+
"eslint-plugin-import": "^2.29.1",
|
69
67
|
"eslint-plugin-node": "^11.1.0",
|
70
68
|
"eslint-plugin-promise": "^6.1.1",
|
71
|
-
"eslint-plugin-vue": "^9.
|
69
|
+
"eslint-plugin-vue": "^9.25.0",
|
70
|
+
"histoire": "^0.17.17",
|
72
71
|
"jsdom": "^22.1.0",
|
73
|
-
"msw": "^
|
74
|
-
"plop": "^4.0.
|
75
|
-
"postcss": "^8.4.
|
72
|
+
"msw": "^2.2.14",
|
73
|
+
"plop": "^4.0.1",
|
74
|
+
"postcss": "^8.4.38",
|
76
75
|
"postcss-cli": "^10.1.0",
|
77
76
|
"postcss-import": "^15.1.0",
|
78
77
|
"postcss-nested": "^6.0.1",
|
79
|
-
"tailwindcss": "^3.
|
80
|
-
"typescript": "^5.3
|
81
|
-
"unplugin-auto-import": "^0.
|
78
|
+
"tailwindcss": "^3.4.3",
|
79
|
+
"typescript": "^5.6.3",
|
80
|
+
"unplugin-auto-import": "^0.17.5",
|
82
81
|
"unplugin-vue-components": "^0.25.2",
|
83
|
-
"vite": "^
|
84
|
-
"vitest": "^
|
85
|
-
"vue-loader": "^17.
|
86
|
-
"vue-tsc": "^
|
87
|
-
"wait-on": "^7.0
|
88
|
-
|
89
|
-
"msw": {
|
90
|
-
"workerDirectory": "public"
|
82
|
+
"vite": "^5.2.9",
|
83
|
+
"vitest": "^1.5.0",
|
84
|
+
"vue-loader": "^17.4.2",
|
85
|
+
"vue-tsc": "^2.0.13",
|
86
|
+
"wait-on": "^7.2.0",
|
87
|
+
"zod": "^4.0.0-beta.1"
|
91
88
|
}
|
92
89
|
}
|