msw 2.12.3 → 2.12.5
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/lib/core/sse.js +5 -1
- package/lib/core/sse.js.map +1 -1
- package/lib/core/sse.mjs +5 -1
- package/lib/core/sse.mjs.map +1 -1
- package/lib/core/utils/cookieStore.js +2 -2
- package/lib/core/utils/cookieStore.js.map +1 -1
- package/lib/core/utils/cookieStore.mjs +2 -2
- package/lib/core/utils/cookieStore.mjs.map +1 -1
- package/lib/iife/index.js +7 -3
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +2 -2
- package/src/core/sse.ts +11 -1
- package/src/core/utils/cookieStore.ts +8 -2
package/lib/mockServiceWorker.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Please do NOT modify this file.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const PACKAGE_VERSION = '2.12.
|
|
10
|
+
const PACKAGE_VERSION = '2.12.5'
|
|
11
11
|
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
|
|
12
12
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
13
13
|
const activeClientIds = new Set()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.5",
|
|
4
4
|
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./lib/core/index.js",
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"vitest-environment-miniflare": "^2.14.4",
|
|
286
286
|
"webpack": "^5.95.0",
|
|
287
287
|
"webpack-http-server": "^0.5.0",
|
|
288
|
-
"msw": "2.12.
|
|
288
|
+
"msw": "2.12.5"
|
|
289
289
|
},
|
|
290
290
|
"peerDependencies": {
|
|
291
291
|
"typescript": ">= 4.8.x"
|
package/src/core/sse.ts
CHANGED
|
@@ -327,7 +327,17 @@ class ServerSentEventClient<
|
|
|
327
327
|
frames.push(`event:${message.event?.toString()}`)
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
if (message.data != null) {
|
|
331
|
+
/**
|
|
332
|
+
* Split data on line terminators (LF, CR, or CRLF) and translate them to individual frames.
|
|
333
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
|
|
334
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
|
|
335
|
+
*/
|
|
336
|
+
for (const line of message.data.toString().split(/\r\n|\r|\n/)) {
|
|
337
|
+
frames.push(`data:${line}`)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
331
341
|
frames.push('', '')
|
|
332
342
|
|
|
333
343
|
this.#controller.enqueue(this.#encoder.encode(frames.join('\n')))
|
|
@@ -36,7 +36,10 @@ class CookieStore {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
private getCookieStoreIndex(): MemoryCookieStoreIndex {
|
|
39
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
typeof localStorage === 'undefined' ||
|
|
41
|
+
typeof localStorage.getItem !== 'function'
|
|
42
|
+
) {
|
|
40
43
|
return {}
|
|
41
44
|
}
|
|
42
45
|
|
|
@@ -66,7 +69,10 @@ class CookieStore {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
private persist(): void {
|
|
69
|
-
if (
|
|
72
|
+
if (
|
|
73
|
+
typeof localStorage === 'undefined' ||
|
|
74
|
+
typeof localStorage.setItem !== 'function'
|
|
75
|
+
) {
|
|
70
76
|
return
|
|
71
77
|
}
|
|
72
78
|
|