msw 2.15.0 → 3.0.0

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 (765) hide show
  1. package/README.md +8 -0
  2. package/cli/init.js +12 -9
  3. package/cli/invariant.js +2 -2
  4. package/lib/_chunks/attach-sibling-handlers.js +360 -0
  5. package/lib/_chunks/attach-sibling-handlers.js.map +1 -0
  6. package/lib/_chunks/colors.js +18 -0
  7. package/lib/_chunks/colors.js.map +1 -0
  8. package/lib/_chunks/cookie-store.js +348 -0
  9. package/lib/_chunks/cookie-store.js.map +1 -0
  10. package/lib/_chunks/execute-handlers.js +29 -0
  11. package/lib/_chunks/execute-handlers.js.map +1 -0
  12. package/lib/_chunks/handlers-controller.d.ts +262 -0
  13. package/lib/_chunks/has-ref-counted.js +9 -0
  14. package/lib/_chunks/has-ref-counted.js.map +1 -0
  15. package/lib/_chunks/http-handler.d.ts +72 -0
  16. package/lib/_chunks/http-handler.js +182 -0
  17. package/lib/_chunks/http-handler.js.map +1 -0
  18. package/lib/_chunks/http-response.js +137 -0
  19. package/lib/_chunks/http-response.js.map +1 -0
  20. package/lib/{core → _chunks}/http.d.ts +15 -18
  21. package/lib/_chunks/http.js +30 -0
  22. package/lib/_chunks/http.js.map +1 -0
  23. package/lib/_chunks/interceptor-source.d.ts +163 -0
  24. package/lib/_chunks/interceptor-source.js +756 -0
  25. package/lib/_chunks/interceptor-source.js.map +1 -0
  26. package/lib/_chunks/is-object.js +11 -0
  27. package/lib/_chunks/is-object.js.map +1 -0
  28. package/lib/_chunks/match-request-url.d.ts +14 -0
  29. package/lib/_chunks/request-handler.d.ts +295 -0
  30. package/lib/_chunks/request-handler.js +369 -0
  31. package/lib/_chunks/request-handler.js.map +1 -0
  32. package/lib/_chunks/shared-options.d.ts +20 -0
  33. package/lib/_chunks/sse.d.ts +95 -0
  34. package/lib/_chunks/sse.js +599 -0
  35. package/lib/_chunks/sse.js.map +1 -0
  36. package/lib/_chunks/symbols.js +22 -0
  37. package/lib/_chunks/symbols.js.map +1 -0
  38. package/lib/_chunks/websocket-upgrade.js +46 -0
  39. package/lib/_chunks/websocket-upgrade.js.map +1 -0
  40. package/lib/_chunks/ws.d.ts +133 -0
  41. package/lib/_chunks/ws.js +293 -0
  42. package/lib/_chunks/ws.js.map +1 -0
  43. package/lib/browser/index.d.ts +225 -96
  44. package/lib/browser/index.js +555 -3694
  45. package/lib/browser/index.js.map +1 -1
  46. package/lib/core/experimental/index.d.ts +3 -17
  47. package/lib/core/experimental/index.js +2 -38
  48. package/lib/core/index.d.ts +15 -27
  49. package/lib/core/index.js +15 -64
  50. package/lib/graphql/index.d.ts +550 -0
  51. package/lib/graphql/index.js +1244 -0
  52. package/lib/graphql/index.js.map +1 -0
  53. package/lib/http/index.d.ts +4 -0
  54. package/lib/http/index.js +4 -0
  55. package/lib/iife/index.js +35857 -28422
  56. package/lib/iife/index.js.map +1 -1
  57. package/lib/mockServiceWorker.js +185 -86
  58. package/lib/node/index.d.ts +79 -104
  59. package/lib/node/index.js +103 -201
  60. package/lib/node/index.js.map +1 -1
  61. package/lib/sse/index.d.ts +2 -0
  62. package/lib/sse/index.js +2 -0
  63. package/lib/{core → utils}/bypass.d.ts +5 -4
  64. package/lib/utils/bypass.js +41 -0
  65. package/lib/utils/bypass.js.map +1 -0
  66. package/lib/utils/delay.d.ts +15 -0
  67. package/lib/utils/delay.js +45 -0
  68. package/lib/utils/delay.js.map +1 -0
  69. package/lib/utils/get-clean-url-string.d.ts +9 -0
  70. package/lib/utils/get-clean-url-string.js +15 -0
  71. package/lib/utils/get-clean-url-string.js.map +1 -0
  72. package/lib/utils/get-response.d.ts +13 -0
  73. package/lib/utils/get-response.js +23 -0
  74. package/lib/utils/get-response.js.map +1 -0
  75. package/lib/utils/is-common-asset-request.d.ts +22 -0
  76. package/lib/utils/is-common-asset-request.js +31 -0
  77. package/lib/utils/is-common-asset-request.js.map +1 -0
  78. package/lib/utils/passthrough.d.ts +31 -0
  79. package/lib/utils/passthrough.js +41 -0
  80. package/lib/utils/passthrough.js.map +1 -0
  81. package/lib/vite/index.d.ts +44 -0
  82. package/lib/vite/index.js +90 -0
  83. package/lib/vite/index.js.map +1 -0
  84. package/lib/vite/runtime.d.ts +6 -0
  85. package/lib/vite/runtime.js +77 -0
  86. package/lib/vite/runtime.js.map +1 -0
  87. package/lib/ws/index.d.ts +4 -0
  88. package/lib/ws/index.js +4 -0
  89. package/package.json +93 -201
  90. package/src/browser/default-network-options.ts +31 -0
  91. package/src/browser/glossary.ts +11 -23
  92. package/src/browser/index.ts +5 -1
  93. package/src/browser/setup-worker.ts +15 -68
  94. package/src/browser/sources/fallback-http-source.ts +1 -1
  95. package/src/browser/sources/service-worker-source.ts +76 -69
  96. package/src/browser/tsconfig.browser.json +4 -2
  97. package/src/browser/utils/{deserializeRequest.ts → deserialize-request.ts} +3 -4
  98. package/src/browser/utils/{getAbsoluteWorkerUrl.test.ts → get-absolute-worker-url.test.ts} +3 -3
  99. package/src/browser/utils/get-worker-instance.ts +2 -2
  100. package/src/browser/utils/should-invalidate-worker.test.ts +11 -11
  101. package/src/browser/utils/should-invalidate-worker.ts +1 -1
  102. package/src/browser/utils/validate-worker-scope.ts +1 -1
  103. package/src/browser/utils/{workerChannel.ts → worker-channel.ts} +42 -20
  104. package/src/core/experimental/define-network.test.ts +43 -8
  105. package/src/core/experimental/define-network.ts +32 -13
  106. package/src/core/experimental/frames/http-frame.test.ts +15 -13
  107. package/src/core/experimental/frames/http-frame.ts +10 -9
  108. package/src/core/experimental/frames/websocket-frame.test.ts +129 -15
  109. package/src/core/experimental/frames/websocket-frame.ts +71 -20
  110. package/src/core/experimental/handlers-controller.test.ts +141 -34
  111. package/src/core/experimental/handlers-controller.ts +107 -30
  112. package/src/core/experimental/index.ts +1 -0
  113. package/src/core/experimental/on-unhandled-frame.test.ts +19 -19
  114. package/src/core/experimental/on-unhandled-frame.ts +7 -12
  115. package/src/core/experimental/request-utils.test.ts +4 -29
  116. package/src/core/experimental/request-utils.ts +0 -14
  117. package/src/core/experimental/sources/interceptor-source.ts +44 -29
  118. package/src/core/experimental/sources/network-source.test.ts +3 -3
  119. package/src/core/experimental/sources/network-source.ts +3 -3
  120. package/src/core/handlers/handler.ts +42 -0
  121. package/src/core/handlers/{RequestHandler.ts → request-handler.ts} +26 -41
  122. package/src/core/index.ts +35 -58
  123. package/src/core/shared-options.ts +21 -0
  124. package/src/core/type-utils.ts +18 -0
  125. package/src/core/utils/{cookieStore.ts → cookie-store.ts} +14 -9
  126. package/src/core/utils/{executeHandlers.ts → execute-handlers.ts} +2 -2
  127. package/src/core/utils/http-status-messages.ts +69 -0
  128. package/src/core/utils/internal/{attachSiblingHandlers.ts → attach-sibling-handlers.ts} +20 -0
  129. package/src/core/utils/internal/{devUtils.test.ts → dev-utils.test.ts} +3 -3
  130. package/src/core/utils/internal/{Disposable.ts → disposable.ts} +1 -1
  131. package/src/core/utils/internal/{getCallFrame.test.ts → get-call-frame.test.ts} +1 -1
  132. package/src/core/utils/internal/{getCallFrame.ts → get-call-frame.ts} +1 -1
  133. package/src/core/utils/internal/{hasRefCounted.test.ts → has-ref-counted.test.ts} +4 -4
  134. package/src/core/utils/internal/{hasRefCounted.ts → has-ref-counted.ts} +1 -1
  135. package/src/core/utils/internal/{isIterable.test.ts → is-iterable.test.ts} +1 -1
  136. package/src/core/utils/internal/is-iterable.ts +16 -0
  137. package/src/core/utils/internal/{isObject.test.ts → is-object.test.ts} +1 -1
  138. package/src/core/utils/internal/{isStringEqual.test.ts → is-string-equal.test.ts} +7 -7
  139. package/src/core/utils/internal/{jsonParse.test.ts → json-parse.test.ts} +1 -1
  140. package/src/core/utils/internal/observe-response-body-stream.test.ts +7 -7
  141. package/src/core/utils/internal/observe-response-body-stream.ts +3 -4
  142. package/src/core/utils/internal/{parseMultipartData.test.ts → parse-multipart-data.test.ts} +1 -1
  143. package/src/core/utils/internal/{parseMultipartData.ts → parse-multipart-data.ts} +1 -1
  144. package/src/core/utils/internal/{toReadonlyArray.test.ts → to-readonly-array.test.ts} +4 -4
  145. package/src/core/utils/logging/colors.ts +13 -0
  146. package/src/core/utils/logging/{getStatusCodeColor.test.ts → get-status-code-color.test.ts} +1 -1
  147. package/src/core/utils/logging/{getTimestamp.test.ts → get-timestamp.test.ts} +1 -1
  148. package/src/core/utils/logging/{serializeRequest.test.ts → serialize-request.test.ts} +1 -1
  149. package/src/core/utils/logging/{serializeResponse.test.ts → serialize-response.test.ts} +8 -10
  150. package/src/core/utils/logging/{serializeResponse.ts → serialize-response.ts} +2 -4
  151. package/src/core/utils/matching/match-request-url.test.ts +90 -0
  152. package/src/core/utils/matching/match-request-url.ts +45 -0
  153. package/src/core/utils/matching/{normalizePath.node.test.ts → normalize-path.node.test.ts} +2 -4
  154. package/src/core/utils/matching/{normalizePath.test.ts → normalize-path.test.ts} +2 -4
  155. package/src/core/utils/matching/{normalizePath.ts → normalize-path.ts} +8 -5
  156. package/src/core/utils/request/{getAllAcceptedMimeTypes.test.ts → get-all-accepted-mime-types.test.ts} +14 -14
  157. package/src/core/utils/request/get-request-cookies.ts +76 -0
  158. package/src/core/utils/request/store-response-cookies.ts +15 -0
  159. package/src/core/utils/request/{toPublicUrl.node.test.ts → to-public-url.node.test.ts} +1 -1
  160. package/src/core/utils/request/{toPublicUrl.test.ts → to-public-url.test.ts} +2 -2
  161. package/src/core/utils/{HttpResponse/decorators.ts → response-decorators.ts} +6 -8
  162. package/src/core/utils/url/{getAbsoluteUrl.node.test.ts → get-absolute-url.node.test.ts} +5 -7
  163. package/src/core/utils/url/{getAbsoluteUrl.test.ts → get-absolute-url.test.ts} +7 -7
  164. package/src/core/utils/url/{getAbsoluteUrl.ts → get-absolute-url.ts} +1 -1
  165. package/src/core/utils/url/is-absolute-url.test.ts +30 -0
  166. package/src/{core/handlers/GraphQLHandler.test.ts → graphql/graphql-handler.test.ts} +37 -36
  167. package/src/{core/handlers/GraphQLHandler.ts → graphql/graphql-handler.ts} +54 -41
  168. package/src/graphql/graphql-subscription-event.ts +39 -0
  169. package/src/graphql/graphql-subscription.test.ts +208 -0
  170. package/src/graphql/graphql-subscription.ts +1487 -0
  171. package/src/graphql/graphql.test.ts +14 -0
  172. package/src/graphql/graphql.ts +179 -0
  173. package/src/graphql/index.ts +34 -0
  174. package/src/{core/utils/internal/parseGraphQLRequest.test.ts → graphql/parse-graphql-request.test.ts} +47 -6
  175. package/src/{core/utils/internal/parseGraphQLRequest.ts → graphql/parse-graphql-request.ts} +59 -32
  176. package/src/{core/handlers/HttpHandler.test.ts → http/http-handler.test.ts} +22 -22
  177. package/src/{core/handlers/HttpHandler.ts → http/http-handler.ts} +16 -18
  178. package/src/{core/HttpResponse.test.ts → http/http-response.test.ts} +25 -27
  179. package/src/{core/HttpResponse.ts → http/http-response.ts} +15 -17
  180. package/src/{core → http}/http.ts +7 -7
  181. package/src/http/index.test.ts +19 -0
  182. package/src/http/index.ts +22 -0
  183. package/src/http/symbols.ts +19 -0
  184. package/src/iife/index.ts +2 -0
  185. package/src/mockServiceWorker.js +183 -84
  186. package/src/node/async-handlers-controller.test.ts +4 -4
  187. package/src/node/glossary.ts +8 -4
  188. package/src/node/index.ts +1 -6
  189. package/src/node/setup-server-common.ts +16 -73
  190. package/src/node/setup-server.ts +9 -40
  191. package/src/sse/index.test.ts +14 -0
  192. package/src/sse/index.ts +7 -0
  193. package/src/{core → sse}/sse.ts +25 -21
  194. package/src/tsconfig.core.build.json +5 -1
  195. package/src/tsconfig.core.json +8 -1
  196. package/src/tsconfig.node.json +1 -1
  197. package/src/tsconfig.src.json +1 -1
  198. package/src/{core → utils}/bypass.test.ts +22 -5
  199. package/src/{core → utils}/bypass.ts +11 -0
  200. package/src/{core → utils}/delay.ts +5 -5
  201. package/src/utils/get-clean-url-string.test.ts +24 -0
  202. package/src/utils/get-clean-url-string.ts +16 -0
  203. package/src/{core/getResponse.test.ts → utils/get-response.test.ts} +9 -9
  204. package/src/{core/getResponse.ts → utils/get-response.ts} +2 -2
  205. package/src/{core/isCommonAssetRequest.ts → utils/is-common-asset-request.ts} +4 -3
  206. package/src/utils/passthrough.test.ts +41 -0
  207. package/src/utils/passthrough.ts +46 -0
  208. package/src/vite/client.d.ts +16 -0
  209. package/src/vite/index.ts +4 -0
  210. package/src/vite/options.d.ts +5 -0
  211. package/src/vite/plugin.test.ts +918 -0
  212. package/src/vite/plugin.ts +133 -0
  213. package/src/vite/runtime.ts +117 -0
  214. package/src/vite/tsconfig.build.json +7 -0
  215. package/src/ws/index.ts +23 -0
  216. package/src/{core/ws/utils/attachWebSocketLogger.ts → ws/utils/attach-websocket-logger.ts} +45 -23
  217. package/src/{core/ws/utils/getMessageLength.test.ts → ws/utils/get-message-length.test.ts} +4 -4
  218. package/src/{core/ws/utils/getMessageLength.ts → ws/utils/get-message-length.ts} +1 -1
  219. package/src/{core/ws/utils/getPublicData.test.ts → ws/utils/get-public-data.test.ts} +7 -7
  220. package/src/ws/utils/get-public-data.ts +23 -0
  221. package/src/{core/ws/utils/truncateMessage.test.ts → ws/utils/truncate-message.test.ts} +3 -3
  222. package/src/{core/ws/WebSocketClientManager.test.ts → ws/websocket-client-manager.test.ts} +8 -9
  223. package/src/{core/ws/WebSocketClientManager.ts → ws/websocket-client-manager.ts} +24 -28
  224. package/src/{core/ws/WebSocketClientStore.ts → ws/websocket-client-store.ts} +2 -2
  225. package/src/{core/handlers/WebSocketHandler.test.ts → ws/websocket-handler.test.ts} +15 -15
  226. package/src/{core/handlers/WebSocketHandler.ts → ws/websocket-handler.ts} +144 -32
  227. package/src/{core/ws/WebSocketIndexedDBClientStore.ts → ws/websocket-indexeddb-client-store.ts} +12 -13
  228. package/src/{core/ws/WebSocketMemoryClientStore.ts → ws/websocket-memory-client-store.ts} +4 -4
  229. package/src/ws/websocket-upgrade.ts +83 -0
  230. package/src/{core → ws}/ws.test.ts +3 -4
  231. package/src/{core → ws}/ws.ts +106 -53
  232. package/browser/package.json +0 -31
  233. package/cli/package.json +0 -3
  234. package/config/package.json +0 -3
  235. package/config/scripts/postinstall.js +0 -36
  236. package/lib/browser/index.d.mts +0 -112
  237. package/lib/browser/index.mjs +0 -3706
  238. package/lib/browser/index.mjs.map +0 -1
  239. package/lib/core/HttpResponse-BE_Y2Ak9.d.mts +0 -389
  240. package/lib/core/HttpResponse-DL-P1EeG.d.ts +0 -389
  241. package/lib/core/HttpResponse.d.mts +0 -6
  242. package/lib/core/HttpResponse.d.ts +0 -6
  243. package/lib/core/HttpResponse.js +0 -176
  244. package/lib/core/HttpResponse.js.map +0 -1
  245. package/lib/core/HttpResponse.mjs +0 -159
  246. package/lib/core/HttpResponse.mjs.map +0 -1
  247. package/lib/core/bypass.d.mts +0 -16
  248. package/lib/core/bypass.js +0 -42
  249. package/lib/core/bypass.js.map +0 -1
  250. package/lib/core/bypass.mjs +0 -22
  251. package/lib/core/bypass.mjs.map +0 -1
  252. package/lib/core/delay.d.mts +0 -18
  253. package/lib/core/delay.d.ts +0 -18
  254. package/lib/core/delay.js +0 -77
  255. package/lib/core/delay.js.map +0 -1
  256. package/lib/core/delay.mjs +0 -57
  257. package/lib/core/delay.mjs.map +0 -1
  258. package/lib/core/experimental/compat.d.mts +0 -17
  259. package/lib/core/experimental/compat.d.ts +0 -17
  260. package/lib/core/experimental/compat.js +0 -55
  261. package/lib/core/experimental/compat.js.map +0 -1
  262. package/lib/core/experimental/compat.mjs +0 -37
  263. package/lib/core/experimental/compat.mjs.map +0 -1
  264. package/lib/core/experimental/define-network.d.mts +0 -75
  265. package/lib/core/experimental/define-network.d.ts +0 -75
  266. package/lib/core/experimental/define-network.js +0 -134
  267. package/lib/core/experimental/define-network.js.map +0 -1
  268. package/lib/core/experimental/define-network.mjs +0 -119
  269. package/lib/core/experimental/define-network.mjs.map +0 -1
  270. package/lib/core/experimental/frames/http-frame.d.mts +0 -77
  271. package/lib/core/experimental/frames/http-frame.d.ts +0 -77
  272. package/lib/core/experimental/frames/http-frame.js +0 -197
  273. package/lib/core/experimental/frames/http-frame.js.map +0 -1
  274. package/lib/core/experimental/frames/http-frame.mjs +0 -181
  275. package/lib/core/experimental/frames/http-frame.mjs.map +0 -1
  276. package/lib/core/experimental/frames/network-frame.d.mts +0 -12
  277. package/lib/core/experimental/frames/network-frame.d.ts +0 -12
  278. package/lib/core/experimental/frames/network-frame.js +0 -35
  279. package/lib/core/experimental/frames/network-frame.js.map +0 -1
  280. package/lib/core/experimental/frames/network-frame.mjs +0 -15
  281. package/lib/core/experimental/frames/network-frame.mjs.map +0 -1
  282. package/lib/core/experimental/frames/websocket-frame.d.mts +0 -55
  283. package/lib/core/experimental/frames/websocket-frame.d.ts +0 -55
  284. package/lib/core/experimental/frames/websocket-frame.js +0 -131
  285. package/lib/core/experimental/frames/websocket-frame.js.map +0 -1
  286. package/lib/core/experimental/frames/websocket-frame.mjs +0 -118
  287. package/lib/core/experimental/frames/websocket-frame.mjs.map +0 -1
  288. package/lib/core/experimental/handlers-controller.d.mts +0 -36
  289. package/lib/core/experimental/handlers-controller.d.ts +0 -36
  290. package/lib/core/experimental/handlers-controller.js +0 -146
  291. package/lib/core/experimental/handlers-controller.js.map +0 -1
  292. package/lib/core/experimental/handlers-controller.mjs +0 -126
  293. package/lib/core/experimental/handlers-controller.mjs.map +0 -1
  294. package/lib/core/experimental/index.d.mts +0 -17
  295. package/lib/core/experimental/index.js.map +0 -1
  296. package/lib/core/experimental/index.mjs +0 -27
  297. package/lib/core/experimental/index.mjs.map +0 -1
  298. package/lib/core/experimental/on-unhandled-frame.d.mts +0 -12
  299. package/lib/core/experimental/on-unhandled-frame.d.ts +0 -12
  300. package/lib/core/experimental/on-unhandled-frame.js +0 -91
  301. package/lib/core/experimental/on-unhandled-frame.js.map +0 -1
  302. package/lib/core/experimental/on-unhandled-frame.mjs +0 -71
  303. package/lib/core/experimental/on-unhandled-frame.mjs.map +0 -1
  304. package/lib/core/experimental/request-utils.d.mts +0 -12
  305. package/lib/core/experimental/request-utils.d.ts +0 -12
  306. package/lib/core/experimental/request-utils.js +0 -50
  307. package/lib/core/experimental/request-utils.js.map +0 -1
  308. package/lib/core/experimental/request-utils.mjs +0 -30
  309. package/lib/core/experimental/request-utils.mjs.map +0 -1
  310. package/lib/core/experimental/setup-api.d.mts +0 -33
  311. package/lib/core/experimental/setup-api.d.ts +0 -33
  312. package/lib/core/experimental/setup-api.js +0 -58
  313. package/lib/core/experimental/setup-api.js.map +0 -1
  314. package/lib/core/experimental/setup-api.mjs +0 -40
  315. package/lib/core/experimental/setup-api.mjs.map +0 -1
  316. package/lib/core/experimental/sources/interceptor-source.d.mts +0 -28
  317. package/lib/core/experimental/sources/interceptor-source.d.ts +0 -28
  318. package/lib/core/experimental/sources/interceptor-source.js +0 -155
  319. package/lib/core/experimental/sources/interceptor-source.js.map +0 -1
  320. package/lib/core/experimental/sources/interceptor-source.mjs +0 -135
  321. package/lib/core/experimental/sources/interceptor-source.mjs.map +0 -1
  322. package/lib/core/experimental/sources/network-source.d.mts +0 -31
  323. package/lib/core/experimental/sources/network-source.d.ts +0 -31
  324. package/lib/core/experimental/sources/network-source.js +0 -51
  325. package/lib/core/experimental/sources/network-source.js.map +0 -1
  326. package/lib/core/experimental/sources/network-source.mjs +0 -32
  327. package/lib/core/experimental/sources/network-source.mjs.map +0 -1
  328. package/lib/core/getResponse.d.mts +0 -18
  329. package/lib/core/getResponse.d.ts +0 -18
  330. package/lib/core/getResponse.js +0 -35
  331. package/lib/core/getResponse.js.map +0 -1
  332. package/lib/core/getResponse.mjs +0 -17
  333. package/lib/core/getResponse.mjs.map +0 -1
  334. package/lib/core/graphql.d.mts +0 -76
  335. package/lib/core/graphql.d.ts +0 -76
  336. package/lib/core/graphql.js +0 -91
  337. package/lib/core/graphql.js.map +0 -1
  338. package/lib/core/graphql.mjs +0 -74
  339. package/lib/core/graphql.mjs.map +0 -1
  340. package/lib/core/handlers/GraphQLHandler.d.mts +0 -6
  341. package/lib/core/handlers/GraphQLHandler.d.ts +0 -6
  342. package/lib/core/handlers/GraphQLHandler.js +0 -232
  343. package/lib/core/handlers/GraphQLHandler.js.map +0 -1
  344. package/lib/core/handlers/GraphQLHandler.mjs +0 -221
  345. package/lib/core/handlers/GraphQLHandler.mjs.map +0 -1
  346. package/lib/core/handlers/HttpHandler.d.mts +0 -75
  347. package/lib/core/handlers/HttpHandler.d.ts +0 -75
  348. package/lib/core/handlers/HttpHandler.js +0 -129
  349. package/lib/core/handlers/HttpHandler.js.map +0 -1
  350. package/lib/core/handlers/HttpHandler.mjs +0 -113
  351. package/lib/core/handlers/HttpHandler.mjs.map +0 -1
  352. package/lib/core/handlers/RequestHandler.d.mts +0 -6
  353. package/lib/core/handlers/RequestHandler.d.ts +0 -6
  354. package/lib/core/handlers/RequestHandler.js +0 -365
  355. package/lib/core/handlers/RequestHandler.js.map +0 -1
  356. package/lib/core/handlers/RequestHandler.mjs +0 -348
  357. package/lib/core/handlers/RequestHandler.mjs.map +0 -1
  358. package/lib/core/handlers/WebSocketHandler.d.mts +0 -49
  359. package/lib/core/handlers/WebSocketHandler.d.ts +0 -49
  360. package/lib/core/handlers/WebSocketHandler.js +0 -178
  361. package/lib/core/handlers/WebSocketHandler.js.map +0 -1
  362. package/lib/core/handlers/WebSocketHandler.mjs +0 -160
  363. package/lib/core/handlers/WebSocketHandler.mjs.map +0 -1
  364. package/lib/core/http.d.mts +0 -31
  365. package/lib/core/http.js +0 -41
  366. package/lib/core/http.js.map +0 -1
  367. package/lib/core/http.mjs +0 -25
  368. package/lib/core/http.mjs.map +0 -1
  369. package/lib/core/index.d.mts +0 -27
  370. package/lib/core/index.js.map +0 -1
  371. package/lib/core/index.mjs +0 -52
  372. package/lib/core/index.mjs.map +0 -1
  373. package/lib/core/isCommonAssetRequest.d.mts +0 -20
  374. package/lib/core/isCommonAssetRequest.d.ts +0 -20
  375. package/lib/core/isCommonAssetRequest.js +0 -42
  376. package/lib/core/isCommonAssetRequest.js.map +0 -1
  377. package/lib/core/isCommonAssetRequest.mjs +0 -22
  378. package/lib/core/isCommonAssetRequest.mjs.map +0 -1
  379. package/lib/core/on-unhandled-frame-0KmwUmeV.d.ts +0 -56
  380. package/lib/core/on-unhandled-frame-gkokW4Rr.d.mts +0 -56
  381. package/lib/core/passthrough.d.mts +0 -24
  382. package/lib/core/passthrough.d.ts +0 -24
  383. package/lib/core/passthrough.js +0 -33
  384. package/lib/core/passthrough.js.map +0 -1
  385. package/lib/core/passthrough.mjs +0 -13
  386. package/lib/core/passthrough.mjs.map +0 -1
  387. package/lib/core/sharedOptions.d.mts +0 -68
  388. package/lib/core/sharedOptions.d.ts +0 -68
  389. package/lib/core/sharedOptions.js +0 -17
  390. package/lib/core/sharedOptions.js.map +0 -1
  391. package/lib/core/sharedOptions.mjs +0 -1
  392. package/lib/core/sharedOptions.mjs.map +0 -1
  393. package/lib/core/sse.d.mts +0 -102
  394. package/lib/core/sse.d.ts +0 -102
  395. package/lib/core/sse.js +0 -690
  396. package/lib/core/sse.js.map +0 -1
  397. package/lib/core/sse.mjs +0 -672
  398. package/lib/core/sse.mjs.map +0 -1
  399. package/lib/core/typeUtils.d.mts +0 -12
  400. package/lib/core/typeUtils.d.ts +0 -12
  401. package/lib/core/typeUtils.js +0 -17
  402. package/lib/core/typeUtils.js.map +0 -1
  403. package/lib/core/typeUtils.mjs +0 -1
  404. package/lib/core/typeUtils.mjs.map +0 -1
  405. package/lib/core/utils/HttpResponse/decorators.d.mts +0 -22
  406. package/lib/core/utils/HttpResponse/decorators.d.ts +0 -22
  407. package/lib/core/utils/HttpResponse/decorators.js +0 -84
  408. package/lib/core/utils/HttpResponse/decorators.js.map +0 -1
  409. package/lib/core/utils/HttpResponse/decorators.mjs +0 -54
  410. package/lib/core/utils/HttpResponse/decorators.mjs.map +0 -1
  411. package/lib/core/utils/cookieStore.d.mts +0 -13
  412. package/lib/core/utils/cookieStore.d.ts +0 -13
  413. package/lib/core/utils/cookieStore.js +0 -90
  414. package/lib/core/utils/cookieStore.js.map +0 -1
  415. package/lib/core/utils/cookieStore.mjs +0 -74
  416. package/lib/core/utils/cookieStore.mjs.map +0 -1
  417. package/lib/core/utils/executeHandlers.d.mts +0 -6
  418. package/lib/core/utils/executeHandlers.d.ts +0 -6
  419. package/lib/core/utils/executeHandlers.js +0 -51
  420. package/lib/core/utils/executeHandlers.js.map +0 -1
  421. package/lib/core/utils/executeHandlers.mjs +0 -31
  422. package/lib/core/utils/executeHandlers.mjs.map +0 -1
  423. package/lib/core/utils/handleRequest.d.mts +0 -30
  424. package/lib/core/utils/handleRequest.d.ts +0 -30
  425. package/lib/core/utils/handleRequest.js +0 -76
  426. package/lib/core/utils/handleRequest.js.map +0 -1
  427. package/lib/core/utils/handleRequest.mjs +0 -58
  428. package/lib/core/utils/handleRequest.mjs.map +0 -1
  429. package/lib/core/utils/internal/Disposable.d.mts +0 -7
  430. package/lib/core/utils/internal/Disposable.d.ts +0 -7
  431. package/lib/core/utils/internal/Disposable.js +0 -51
  432. package/lib/core/utils/internal/Disposable.js.map +0 -1
  433. package/lib/core/utils/internal/Disposable.mjs +0 -31
  434. package/lib/core/utils/internal/Disposable.mjs.map +0 -1
  435. package/lib/core/utils/internal/attachSiblingHandlers.d.mts +0 -15
  436. package/lib/core/utils/internal/attachSiblingHandlers.d.ts +0 -15
  437. package/lib/core/utils/internal/attachSiblingHandlers.js +0 -44
  438. package/lib/core/utils/internal/attachSiblingHandlers.js.map +0 -1
  439. package/lib/core/utils/internal/attachSiblingHandlers.mjs +0 -24
  440. package/lib/core/utils/internal/attachSiblingHandlers.mjs.map +0 -1
  441. package/lib/core/utils/internal/checkGlobals.d.mts +0 -3
  442. package/lib/core/utils/internal/checkGlobals.d.ts +0 -3
  443. package/lib/core/utils/internal/checkGlobals.js +0 -34
  444. package/lib/core/utils/internal/checkGlobals.js.map +0 -1
  445. package/lib/core/utils/internal/checkGlobals.mjs +0 -14
  446. package/lib/core/utils/internal/checkGlobals.mjs.map +0 -1
  447. package/lib/core/utils/internal/devUtils.d.mts +0 -28
  448. package/lib/core/utils/internal/devUtils.d.ts +0 -28
  449. package/lib/core/utils/internal/devUtils.js +0 -48
  450. package/lib/core/utils/internal/devUtils.js.map +0 -1
  451. package/lib/core/utils/internal/devUtils.mjs +0 -28
  452. package/lib/core/utils/internal/devUtils.mjs.map +0 -1
  453. package/lib/core/utils/internal/getCallFrame.d.mts +0 -6
  454. package/lib/core/utils/internal/getCallFrame.d.ts +0 -6
  455. package/lib/core/utils/internal/getCallFrame.js +0 -41
  456. package/lib/core/utils/internal/getCallFrame.js.map +0 -1
  457. package/lib/core/utils/internal/getCallFrame.mjs +0 -21
  458. package/lib/core/utils/internal/getCallFrame.mjs.map +0 -1
  459. package/lib/core/utils/internal/hasRefCounted.d.mts +0 -3
  460. package/lib/core/utils/internal/hasRefCounted.d.ts +0 -3
  461. package/lib/core/utils/internal/hasRefCounted.js +0 -34
  462. package/lib/core/utils/internal/hasRefCounted.js.map +0 -1
  463. package/lib/core/utils/internal/hasRefCounted.mjs +0 -14
  464. package/lib/core/utils/internal/hasRefCounted.mjs.map +0 -1
  465. package/lib/core/utils/internal/isHandlerKind.d.mts +0 -19
  466. package/lib/core/utils/internal/isHandlerKind.d.ts +0 -19
  467. package/lib/core/utils/internal/isHandlerKind.js +0 -30
  468. package/lib/core/utils/internal/isHandlerKind.js.map +0 -1
  469. package/lib/core/utils/internal/isHandlerKind.mjs +0 -10
  470. package/lib/core/utils/internal/isHandlerKind.mjs.map +0 -1
  471. package/lib/core/utils/internal/isIterable.d.mts +0 -20
  472. package/lib/core/utils/internal/isIterable.d.ts +0 -20
  473. package/lib/core/utils/internal/isIterable.js +0 -30
  474. package/lib/core/utils/internal/isIterable.js.map +0 -1
  475. package/lib/core/utils/internal/isIterable.mjs +0 -10
  476. package/lib/core/utils/internal/isIterable.mjs.map +0 -1
  477. package/lib/core/utils/internal/isObject.d.mts +0 -6
  478. package/lib/core/utils/internal/isObject.d.ts +0 -6
  479. package/lib/core/utils/internal/isObject.js +0 -27
  480. package/lib/core/utils/internal/isObject.js.map +0 -1
  481. package/lib/core/utils/internal/isObject.mjs +0 -7
  482. package/lib/core/utils/internal/isObject.mjs.map +0 -1
  483. package/lib/core/utils/internal/isStringEqual.d.mts +0 -6
  484. package/lib/core/utils/internal/isStringEqual.d.ts +0 -6
  485. package/lib/core/utils/internal/isStringEqual.js +0 -27
  486. package/lib/core/utils/internal/isStringEqual.js.map +0 -1
  487. package/lib/core/utils/internal/isStringEqual.mjs +0 -7
  488. package/lib/core/utils/internal/isStringEqual.mjs.map +0 -1
  489. package/lib/core/utils/internal/jsonParse.d.mts +0 -7
  490. package/lib/core/utils/internal/jsonParse.d.ts +0 -7
  491. package/lib/core/utils/internal/jsonParse.js +0 -31
  492. package/lib/core/utils/internal/jsonParse.js.map +0 -1
  493. package/lib/core/utils/internal/jsonParse.mjs +0 -11
  494. package/lib/core/utils/internal/jsonParse.mjs.map +0 -1
  495. package/lib/core/utils/internal/mergeRight.d.mts +0 -7
  496. package/lib/core/utils/internal/mergeRight.d.ts +0 -7
  497. package/lib/core/utils/internal/mergeRight.js +0 -43
  498. package/lib/core/utils/internal/mergeRight.js.map +0 -1
  499. package/lib/core/utils/internal/mergeRight.mjs +0 -23
  500. package/lib/core/utils/internal/mergeRight.mjs.map +0 -1
  501. package/lib/core/utils/internal/observe-response-body-stream.d.mts +0 -18
  502. package/lib/core/utils/internal/observe-response-body-stream.d.ts +0 -18
  503. package/lib/core/utils/internal/observe-response-body-stream.js +0 -64
  504. package/lib/core/utils/internal/observe-response-body-stream.js.map +0 -1
  505. package/lib/core/utils/internal/observe-response-body-stream.mjs +0 -44
  506. package/lib/core/utils/internal/observe-response-body-stream.mjs.map +0 -1
  507. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +0 -6
  508. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +0 -6
  509. package/lib/core/utils/internal/parseGraphQLRequest.js +0 -146
  510. package/lib/core/utils/internal/parseGraphQLRequest.js.map +0 -1
  511. package/lib/core/utils/internal/parseGraphQLRequest.mjs +0 -129
  512. package/lib/core/utils/internal/parseGraphQLRequest.mjs.map +0 -1
  513. package/lib/core/utils/internal/parseMultipartData.d.mts +0 -14
  514. package/lib/core/utils/internal/parseMultipartData.d.ts +0 -14
  515. package/lib/core/utils/internal/parseMultipartData.js +0 -84
  516. package/lib/core/utils/internal/parseMultipartData.js.map +0 -1
  517. package/lib/core/utils/internal/parseMultipartData.mjs +0 -64
  518. package/lib/core/utils/internal/parseMultipartData.mjs.map +0 -1
  519. package/lib/core/utils/internal/pipeEvents.d.mts +0 -8
  520. package/lib/core/utils/internal/pipeEvents.d.ts +0 -8
  521. package/lib/core/utils/internal/pipeEvents.js +0 -37
  522. package/lib/core/utils/internal/pipeEvents.js.map +0 -1
  523. package/lib/core/utils/internal/pipeEvents.mjs +0 -17
  524. package/lib/core/utils/internal/pipeEvents.mjs.map +0 -1
  525. package/lib/core/utils/internal/toReadonlyArray.d.mts +0 -6
  526. package/lib/core/utils/internal/toReadonlyArray.d.ts +0 -6
  527. package/lib/core/utils/internal/toReadonlyArray.js +0 -29
  528. package/lib/core/utils/internal/toReadonlyArray.js.map +0 -1
  529. package/lib/core/utils/internal/toReadonlyArray.mjs +0 -9
  530. package/lib/core/utils/internal/toReadonlyArray.mjs.map +0 -1
  531. package/lib/core/utils/internal/tryCatch.d.mts +0 -3
  532. package/lib/core/utils/internal/tryCatch.d.ts +0 -3
  533. package/lib/core/utils/internal/tryCatch.js +0 -32
  534. package/lib/core/utils/internal/tryCatch.js.map +0 -1
  535. package/lib/core/utils/internal/tryCatch.mjs +0 -12
  536. package/lib/core/utils/internal/tryCatch.mjs.map +0 -1
  537. package/lib/core/utils/logging/getStatusCodeColor.d.mts +0 -11
  538. package/lib/core/utils/logging/getStatusCodeColor.d.ts +0 -11
  539. package/lib/core/utils/logging/getStatusCodeColor.js +0 -40
  540. package/lib/core/utils/logging/getStatusCodeColor.js.map +0 -1
  541. package/lib/core/utils/logging/getStatusCodeColor.mjs +0 -20
  542. package/lib/core/utils/logging/getStatusCodeColor.mjs.map +0 -1
  543. package/lib/core/utils/logging/getTimestamp.d.mts +0 -9
  544. package/lib/core/utils/logging/getTimestamp.d.ts +0 -9
  545. package/lib/core/utils/logging/getTimestamp.js +0 -32
  546. package/lib/core/utils/logging/getTimestamp.js.map +0 -1
  547. package/lib/core/utils/logging/getTimestamp.mjs +0 -12
  548. package/lib/core/utils/logging/getTimestamp.mjs.map +0 -1
  549. package/lib/core/utils/logging/serializeRequest.d.mts +0 -12
  550. package/lib/core/utils/logging/serializeRequest.d.ts +0 -12
  551. package/lib/core/utils/logging/serializeRequest.js +0 -34
  552. package/lib/core/utils/logging/serializeRequest.js.map +0 -1
  553. package/lib/core/utils/logging/serializeRequest.mjs +0 -14
  554. package/lib/core/utils/logging/serializeRequest.mjs.map +0 -1
  555. package/lib/core/utils/logging/serializeResponse.d.mts +0 -9
  556. package/lib/core/utils/logging/serializeResponse.d.ts +0 -9
  557. package/lib/core/utils/logging/serializeResponse.js +0 -48
  558. package/lib/core/utils/logging/serializeResponse.js.map +0 -1
  559. package/lib/core/utils/logging/serializeResponse.mjs +0 -18
  560. package/lib/core/utils/logging/serializeResponse.mjs.map +0 -1
  561. package/lib/core/utils/matching/matchRequestUrl.d.mts +0 -20
  562. package/lib/core/utils/matching/matchRequestUrl.d.ts +0 -20
  563. package/lib/core/utils/matching/matchRequestUrl.js +0 -55
  564. package/lib/core/utils/matching/matchRequestUrl.js.map +0 -1
  565. package/lib/core/utils/matching/matchRequestUrl.mjs +0 -35
  566. package/lib/core/utils/matching/matchRequestUrl.mjs.map +0 -1
  567. package/lib/core/utils/matching/normalizePath.d.mts +0 -13
  568. package/lib/core/utils/matching/normalizePath.d.ts +0 -13
  569. package/lib/core/utils/matching/normalizePath.js +0 -33
  570. package/lib/core/utils/matching/normalizePath.js.map +0 -1
  571. package/lib/core/utils/matching/normalizePath.mjs +0 -13
  572. package/lib/core/utils/matching/normalizePath.mjs.map +0 -1
  573. package/lib/core/utils/request/getAllAcceptedMimeTypes.d.mts +0 -14
  574. package/lib/core/utils/request/getAllAcceptedMimeTypes.d.ts +0 -14
  575. package/lib/core/utils/request/getAllAcceptedMimeTypes.js +0 -61
  576. package/lib/core/utils/request/getAllAcceptedMimeTypes.js.map +0 -1
  577. package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs +0 -41
  578. package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs.map +0 -1
  579. package/lib/core/utils/request/getRequestCookies.d.mts +0 -3
  580. package/lib/core/utils/request/getRequestCookies.d.ts +0 -3
  581. package/lib/core/utils/request/getRequestCookies.js +0 -79
  582. package/lib/core/utils/request/getRequestCookies.js.map +0 -1
  583. package/lib/core/utils/request/getRequestCookies.mjs +0 -62
  584. package/lib/core/utils/request/getRequestCookies.mjs.map +0 -1
  585. package/lib/core/utils/request/onUnhandledRequest.d.mts +0 -9
  586. package/lib/core/utils/request/onUnhandledRequest.d.ts +0 -9
  587. package/lib/core/utils/request/onUnhandledRequest.js +0 -76
  588. package/lib/core/utils/request/onUnhandledRequest.js.map +0 -1
  589. package/lib/core/utils/request/onUnhandledRequest.mjs +0 -56
  590. package/lib/core/utils/request/onUnhandledRequest.mjs.map +0 -1
  591. package/lib/core/utils/request/storeResponseCookies.d.mts +0 -3
  592. package/lib/core/utils/request/storeResponseCookies.d.ts +0 -3
  593. package/lib/core/utils/request/storeResponseCookies.js +0 -32
  594. package/lib/core/utils/request/storeResponseCookies.js.map +0 -1
  595. package/lib/core/utils/request/storeResponseCookies.mjs +0 -12
  596. package/lib/core/utils/request/storeResponseCookies.mjs.map +0 -1
  597. package/lib/core/utils/request/toPublicUrl.d.mts +0 -7
  598. package/lib/core/utils/request/toPublicUrl.d.ts +0 -7
  599. package/lib/core/utils/request/toPublicUrl.js +0 -31
  600. package/lib/core/utils/request/toPublicUrl.js.map +0 -1
  601. package/lib/core/utils/request/toPublicUrl.mjs +0 -11
  602. package/lib/core/utils/request/toPublicUrl.mjs.map +0 -1
  603. package/lib/core/utils/toResponseInit.d.mts +0 -3
  604. package/lib/core/utils/toResponseInit.d.ts +0 -3
  605. package/lib/core/utils/toResponseInit.js +0 -31
  606. package/lib/core/utils/toResponseInit.js.map +0 -1
  607. package/lib/core/utils/toResponseInit.mjs +0 -11
  608. package/lib/core/utils/toResponseInit.mjs.map +0 -1
  609. package/lib/core/utils/url/cleanUrl.d.mts +0 -7
  610. package/lib/core/utils/url/cleanUrl.d.ts +0 -7
  611. package/lib/core/utils/url/cleanUrl.js +0 -31
  612. package/lib/core/utils/url/cleanUrl.js.map +0 -1
  613. package/lib/core/utils/url/cleanUrl.mjs +0 -11
  614. package/lib/core/utils/url/cleanUrl.mjs.map +0 -1
  615. package/lib/core/utils/url/getAbsoluteUrl.d.mts +0 -6
  616. package/lib/core/utils/url/getAbsoluteUrl.d.ts +0 -6
  617. package/lib/core/utils/url/getAbsoluteUrl.js +0 -38
  618. package/lib/core/utils/url/getAbsoluteUrl.js.map +0 -1
  619. package/lib/core/utils/url/getAbsoluteUrl.mjs +0 -18
  620. package/lib/core/utils/url/getAbsoluteUrl.mjs.map +0 -1
  621. package/lib/core/utils/url/isAbsoluteUrl.d.mts +0 -6
  622. package/lib/core/utils/url/isAbsoluteUrl.d.ts +0 -6
  623. package/lib/core/utils/url/isAbsoluteUrl.js +0 -27
  624. package/lib/core/utils/url/isAbsoluteUrl.js.map +0 -1
  625. package/lib/core/utils/url/isAbsoluteUrl.mjs +0 -7
  626. package/lib/core/utils/url/isAbsoluteUrl.mjs.map +0 -1
  627. package/lib/core/ws/WebSocketClientManager.d.mts +0 -65
  628. package/lib/core/ws/WebSocketClientManager.d.ts +0 -65
  629. package/lib/core/ws/WebSocketClientManager.js +0 -163
  630. package/lib/core/ws/WebSocketClientManager.js.map +0 -1
  631. package/lib/core/ws/WebSocketClientManager.mjs +0 -143
  632. package/lib/core/ws/WebSocketClientManager.mjs.map +0 -1
  633. package/lib/core/ws/WebSocketClientStore.d.mts +0 -13
  634. package/lib/core/ws/WebSocketClientStore.d.ts +0 -13
  635. package/lib/core/ws/WebSocketClientStore.js +0 -26
  636. package/lib/core/ws/WebSocketClientStore.js.map +0 -1
  637. package/lib/core/ws/WebSocketClientStore.mjs +0 -6
  638. package/lib/core/ws/WebSocketClientStore.mjs.map +0 -1
  639. package/lib/core/ws/WebSocketIndexedDBClientStore.d.mts +0 -14
  640. package/lib/core/ws/WebSocketIndexedDBClientStore.d.ts +0 -14
  641. package/lib/core/ws/WebSocketIndexedDBClientStore.js +0 -131
  642. package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +0 -1
  643. package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +0 -111
  644. package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +0 -1
  645. package/lib/core/ws/WebSocketMemoryClientStore.d.mts +0 -12
  646. package/lib/core/ws/WebSocketMemoryClientStore.d.ts +0 -12
  647. package/lib/core/ws/WebSocketMemoryClientStore.js +0 -42
  648. package/lib/core/ws/WebSocketMemoryClientStore.js.map +0 -1
  649. package/lib/core/ws/WebSocketMemoryClientStore.mjs +0 -22
  650. package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +0 -1
  651. package/lib/core/ws/handleWebSocketEvent.d.mts +0 -20
  652. package/lib/core/ws/handleWebSocketEvent.d.ts +0 -20
  653. package/lib/core/ws/handleWebSocketEvent.js +0 -61
  654. package/lib/core/ws/handleWebSocketEvent.js.map +0 -1
  655. package/lib/core/ws/handleWebSocketEvent.mjs +0 -43
  656. package/lib/core/ws/handleWebSocketEvent.mjs.map +0 -1
  657. package/lib/core/ws/utils/attachWebSocketLogger.d.mts +0 -18
  658. package/lib/core/ws/utils/attachWebSocketLogger.d.ts +0 -18
  659. package/lib/core/ws/utils/attachWebSocketLogger.js +0 -228
  660. package/lib/core/ws/utils/attachWebSocketLogger.js.map +0 -1
  661. package/lib/core/ws/utils/attachWebSocketLogger.mjs +0 -208
  662. package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +0 -1
  663. package/lib/core/ws/utils/getMessageLength.d.mts +0 -11
  664. package/lib/core/ws/utils/getMessageLength.d.ts +0 -11
  665. package/lib/core/ws/utils/getMessageLength.js +0 -34
  666. package/lib/core/ws/utils/getMessageLength.js.map +0 -1
  667. package/lib/core/ws/utils/getMessageLength.mjs +0 -14
  668. package/lib/core/ws/utils/getMessageLength.mjs.map +0 -1
  669. package/lib/core/ws/utils/getPublicData.d.mts +0 -5
  670. package/lib/core/ws/utils/getPublicData.d.ts +0 -5
  671. package/lib/core/ws/utils/getPublicData.js +0 -37
  672. package/lib/core/ws/utils/getPublicData.js.map +0 -1
  673. package/lib/core/ws/utils/getPublicData.mjs +0 -17
  674. package/lib/core/ws/utils/getPublicData.mjs.map +0 -1
  675. package/lib/core/ws/utils/truncateMessage.d.mts +0 -3
  676. package/lib/core/ws/utils/truncateMessage.d.ts +0 -3
  677. package/lib/core/ws/utils/truncateMessage.js +0 -31
  678. package/lib/core/ws/utils/truncateMessage.js.map +0 -1
  679. package/lib/core/ws/utils/truncateMessage.mjs +0 -11
  680. package/lib/core/ws/utils/truncateMessage.mjs.map +0 -1
  681. package/lib/core/ws/webSocketInterceptor.d.mts +0 -5
  682. package/lib/core/ws/webSocketInterceptor.d.ts +0 -5
  683. package/lib/core/ws/webSocketInterceptor.js +0 -26
  684. package/lib/core/ws/webSocketInterceptor.js.map +0 -1
  685. package/lib/core/ws/webSocketInterceptor.mjs +0 -6
  686. package/lib/core/ws/webSocketInterceptor.mjs.map +0 -1
  687. package/lib/core/ws.d.mts +0 -88
  688. package/lib/core/ws.d.ts +0 -88
  689. package/lib/core/ws.js +0 -94
  690. package/lib/core/ws.js.map +0 -1
  691. package/lib/core/ws.mjs +0 -80
  692. package/lib/core/ws.mjs.map +0 -1
  693. package/lib/native/index.d.mts +0 -66
  694. package/lib/native/index.d.ts +0 -66
  695. package/lib/native/index.js +0 -88
  696. package/lib/native/index.js.map +0 -1
  697. package/lib/native/index.mjs +0 -67
  698. package/lib/native/index.mjs.map +0 -1
  699. package/lib/node/index.d.mts +0 -113
  700. package/lib/node/index.mjs +0 -185
  701. package/lib/node/index.mjs.map +0 -1
  702. package/lib/shims/cookie.d.mts +0 -7
  703. package/lib/shims/cookie.d.ts +0 -7
  704. package/lib/shims/cookie.js +0 -294
  705. package/lib/shims/cookie.mjs +0 -286
  706. package/lib/shims/statuses.d.mts +0 -6
  707. package/lib/shims/statuses.d.ts +0 -6
  708. package/lib/shims/statuses.js +0 -195
  709. package/lib/shims/statuses.mjs +0 -187
  710. package/native/package.json +0 -30
  711. package/node/package.json +0 -33
  712. package/src/browser/utils/pruneGetRequestBody.test.ts +0 -51
  713. package/src/browser/utils/pruneGetRequestBody.ts +0 -21
  714. package/src/core/experimental/compat.ts +0 -50
  715. package/src/core/experimental/setup-api.ts +0 -55
  716. package/src/core/graphql.test.ts +0 -11
  717. package/src/core/graphql.ts +0 -136
  718. package/src/core/passthrough.test.ts +0 -11
  719. package/src/core/passthrough.ts +0 -25
  720. package/src/core/sharedOptions.ts +0 -71
  721. package/src/core/typeUtils.ts +0 -26
  722. package/src/core/utils/handleRequest.test.ts +0 -574
  723. package/src/core/utils/handleRequest.ts +0 -117
  724. package/src/core/utils/internal/checkGlobals.ts +0 -17
  725. package/src/core/utils/internal/isHandlerKind.test.ts +0 -62
  726. package/src/core/utils/internal/isHandlerKind.ts +0 -17
  727. package/src/core/utils/internal/isIterable.ts +0 -32
  728. package/src/core/utils/internal/mergeRight.test.ts +0 -43
  729. package/src/core/utils/internal/mergeRight.ts +0 -30
  730. package/src/core/utils/internal/pipeEvents.test.ts +0 -14
  731. package/src/core/utils/internal/pipeEvents.ts +0 -26
  732. package/src/core/utils/internal/tryCatch.test.ts +0 -29
  733. package/src/core/utils/internal/tryCatch.ts +0 -11
  734. package/src/core/utils/matching/matchRequestUrl.test.ts +0 -267
  735. package/src/core/utils/matching/matchRequestUrl.ts +0 -77
  736. package/src/core/utils/request/getRequestCookies.ts +0 -88
  737. package/src/core/utils/request/onUnhandledRequest.node.test.ts +0 -62
  738. package/src/core/utils/request/onUnhandledRequest.test.ts +0 -226
  739. package/src/core/utils/request/onUnhandledRequest.ts +0 -81
  740. package/src/core/utils/request/storeResponseCookies.ts +0 -15
  741. package/src/core/utils/url/cleanUrl.test.ts +0 -22
  742. package/src/core/utils/url/cleanUrl.ts +0 -16
  743. package/src/core/utils/url/isAbsoluteUrl.test.ts +0 -32
  744. package/src/core/ws/handleWebSocketEvent.ts +0 -68
  745. package/src/core/ws/utils/getPublicData.ts +0 -18
  746. package/src/core/ws/webSocketInterceptor.ts +0 -3
  747. package/src/native/index.ts +0 -44
  748. package/src/package.json +0 -3
  749. package/src/shims/cookie.ts +0 -7
  750. package/src/shims/statuses.ts +0 -6
  751. /package/src/browser/utils/{getAbsoluteWorkerUrl.ts → get-absolute-worker-url.ts} +0 -0
  752. /package/src/core/utils/internal/{devUtils.ts → dev-utils.ts} +0 -0
  753. /package/src/core/utils/internal/{isObject.ts → is-object.ts} +0 -0
  754. /package/src/core/utils/internal/{isStringEqual.ts → is-string-equal.ts} +0 -0
  755. /package/src/core/utils/internal/{jsonParse.ts → json-parse.ts} +0 -0
  756. /package/src/core/utils/internal/{toReadonlyArray.ts → to-readonly-array.ts} +0 -0
  757. /package/src/core/utils/logging/{getStatusCodeColor.ts → get-status-code-color.ts} +0 -0
  758. /package/src/core/utils/logging/{getTimestamp.ts → get-timestamp.ts} +0 -0
  759. /package/src/core/utils/logging/{serializeRequest.ts → serialize-request.ts} +0 -0
  760. /package/src/core/utils/request/{getAllAcceptedMimeTypes.ts → get-all-accepted-mime-types.ts} +0 -0
  761. /package/src/core/utils/request/{toPublicUrl.ts → to-public-url.ts} +0 -0
  762. /package/src/core/utils/{toResponseInit.ts → to-response-init.ts} +0 -0
  763. /package/src/core/utils/url/{isAbsoluteUrl.ts → is-absolute-url.ts} +0 -0
  764. /package/src/{core → http}/http.test.ts +0 -0
  765. /package/src/{core/ws/utils/truncateMessage.ts → ws/utils/truncate-message.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor-source.js","names":[],"sources":["../../src/core/experimental/sources/network-source.ts","../../src/core/experimental/handlers-controller.ts","../../src/core/utils/internal/to-readonly-array.ts","../../src/core/utils/internal/disposable.ts","../../src/core/experimental/define-network.ts","../../src/core/experimental/frames/network-frame.ts","../../src/core/utils/request/store-response-cookies.ts","../../src/core/experimental/request-utils.ts","../../src/core/experimental/on-unhandled-frame.ts","../../src/core/experimental/frames/http-frame.ts","../../src/core/experimental/frames/websocket-frame.ts","../../src/core/experimental/sources/interceptor-source.ts"],"sourcesContent":["import { Emitter, TypedEvent, type TypedListenerOptions } from 'rettime'\nimport type {\n AnyNetworkFrame,\n ExtractFrameEvents,\n} from '../frames/network-frame'\n\nclass NetworkFrameEvent<\n DataType = void,\n ReturnType = void,\n EventType extends string = string,\n> extends TypedEvent<DataType, ReturnType, EventType> {\n public frame: AnyNetworkFrame\n\n constructor(type: string, frame: AnyNetworkFrame) {\n super(...([type, {}] as any))\n this.frame = frame\n }\n}\n\ntype NetworkSourceEventMap<Frame extends AnyNetworkFrame> = {\n frame: NetworkFrameEvent<Frame>\n}\n\nexport type ExtractSourceEvents<Source> =\n Source extends NetworkSource<infer Frame> ? ExtractFrameEvents<Frame> : never\n\nexport abstract class NetworkSource<\n Frame extends AnyNetworkFrame = AnyNetworkFrame,\n> {\n protected emitter: Emitter<NetworkSourceEventMap<Frame>>\n\n constructor() {\n this.emitter = new Emitter()\n }\n\n public abstract enable(): unknown | Promise<unknown>\n\n public async queue(frame: Frame): Promise<void> {\n await this.emitter.emitAsPromise(\n // @ts-expect-error Trouble handling a conditional type parameter.\n new NetworkFrameEvent('frame', frame),\n )\n }\n\n public on<Type extends keyof NetworkSourceEventMap<Frame>>(\n type: Type,\n listener: Emitter.Listener<typeof this.emitter, Type>,\n options?: TypedListenerOptions,\n ): void {\n this.emitter.on(type, listener, options)\n }\n\n public disable(): void | Promise<void> {\n this.emitter.removeAllListeners()\n }\n}\n","import { invariant } from 'outvariant'\nimport type { HandlerKind } from '../handlers/handler'\nimport type { RequestHandler } from '../handlers/request-handler'\nimport type {\n WebSocketHandler,\n AnyWebSocketExtension,\n} from '#ws/websocket-handler'\nimport { devUtils } from '../utils/internal/dev-utils'\nimport type { MaybePromise } from '../type-utils'\nimport {\n getSiblingHandlers,\n isSiblingHandler,\n} from '../utils/internal/attach-sibling-handlers'\n\nexport type AnyHandler =\n RequestHandler | WebSocketHandler<AnyWebSocketExtension>\ntype HandlerOfKind<Kind extends HandlerKind> = Extract<\n AnyHandler,\n { kind: Kind }\n>\ntype HandlersMapOfKind<Kind extends HandlerKind> = {\n [K in Kind]?: Array<HandlerOfKind<K>>\n}\nexport type HandlersMap = HandlersMapOfKind<HandlerKind>\n\nfunction addHandlerToGroup<Kind extends HandlerKind>(\n groups: HandlersMapOfKind<Kind>,\n kind: Kind,\n handler: HandlerOfKind<Kind>,\n): void {\n const bucket = (groups[kind] ||= [])\n bucket.push(handler)\n}\n\nfunction prependHandlersToGroup<Kind extends HandlerKind>(\n groups: HandlersMapOfKind<Kind>,\n kind: Kind,\n overridesForKind: Array<HandlerOfKind<Kind>>,\n): void {\n const existingForKind = groups[kind]\n\n groups[kind] = existingForKind\n ? [\n ...overridesForKind,\n ...existingForKind.filter((existingHandler) => {\n return !overridesForKind.includes(existingHandler)\n }),\n ]\n : overridesForKind\n}\n\nexport function groupHandlersByKind(handlers: Array<AnyHandler>): HandlersMap {\n const groups: HandlersMap = {}\n const visitedHandlers = new Set<AnyHandler>()\n\n const visit = (handler: AnyHandler) => {\n if (visitedHandlers.has(handler)) {\n return\n }\n\n visitedHandlers.add(handler)\n addHandlerToGroup(groups, handler.kind, handler)\n\n // Recurse so siblings of siblings (user-composed handler\n // graphs) are grouped as well, not silently dropped.\n for (const sibling of getSiblingHandlers(handler)) {\n visit(sibling)\n }\n }\n\n for (const handler of handlers) {\n visit(handler)\n }\n\n return groups\n}\n\nexport interface HandlersControllerState {\n initialHandlers: HandlersMap\n handlers: HandlersMap\n}\n\nexport abstract class HandlersController {\n protected getInitialState(\n initialHandlers: Array<AnyHandler>,\n ): HandlersControllerState {\n invariant(\n this.#validateHandlers(initialHandlers),\n devUtils.formatMessage(\n 'Failed to apply given request handlers: invalid input. Did you forget to spread the request handlers Array?',\n ),\n )\n\n const normalizedInitialHandlers = groupHandlersByKind(initialHandlers)\n\n return {\n initialHandlers: normalizedInitialHandlers,\n handlers: { ...normalizedInitialHandlers },\n }\n }\n\n protected abstract getState(): HandlersControllerState\n protected abstract setState(nextState: Partial<HandlersControllerState>): void\n\n public currentHandlers(): Array<AnyHandler> {\n return Object.values(this.getState().handlers)\n .flat()\n .filter((handler) => handler != null)\n }\n\n /**\n * Return the list of explicitly registered handlers.\n * Unlike `currentHandlers()`, this excludes sibling handlers,\n * which are an implementation detail (e.g. the WebSocket upgrade\n * handler or the GraphQL subscription transport).\n */\n public listHandlers(): Array<AnyHandler> {\n return this.currentHandlers().filter((handler) => {\n return !isSiblingHandler(handler)\n })\n }\n\n /**\n * Return the list of handlers of the given kind.\n */\n public getHandlersByKind<Kind extends HandlerKind>(\n kind: Kind,\n ): Array<HandlerOfKind<Kind>> {\n return this.getState().handlers[kind] || []\n }\n\n public use(nextHandlers: Array<AnyHandler>): void {\n invariant(\n this.#validateHandlers(nextHandlers),\n devUtils.formatMessage(\n '[MSW] Failed to call \"use()\" with the given request handlers: invalid input. Did you forget to spread the array of request handlers?',\n ),\n )\n\n if (nextHandlers.length === 0) {\n return\n }\n\n const { handlers } = this.getState()\n const overrides = groupHandlersByKind(nextHandlers)\n\n // Prepend overrides to their respective kind buckets so they take\n // priority over existing handlers while preserving input order.\n // Drop existing references that reappear in the overrides (e.g. a\n // shared upgrade sibling from the same link) so a handler is never\n // registered twice.\n if (overrides.request) {\n prependHandlersToGroup(handlers, 'request', overrides.request)\n }\n\n if (overrides.websocket) {\n prependHandlersToGroup(handlers, 'websocket', overrides.websocket)\n }\n\n this.setState({ handlers })\n }\n\n public reset(nextHandlers: Array<AnyHandler>): void {\n invariant(\n nextHandlers.length > 0 ? this.#validateHandlers(nextHandlers) : true,\n devUtils.formatMessage(\n 'Failed to replace initial handlers during reset: invalid handlers. Did you forget to spread the handlers array?',\n ),\n )\n\n for (const handler of this.currentHandlers()) {\n handler.reset()\n }\n\n const { initialHandlers } = this.getState()\n\n if (nextHandlers.length === 0) {\n this.setState({\n handlers: { ...initialHandlers },\n })\n\n return\n }\n\n const normalizedNextHandlers = groupHandlersByKind(nextHandlers)\n\n this.setState({\n initialHandlers: normalizedNextHandlers,\n handlers: { ...normalizedNextHandlers },\n })\n }\n\n public restore(): void {\n for (const handler of this.currentHandlers()) {\n handler.restore()\n }\n }\n\n public dispose(): MaybePromise<void> {\n const pendingDisposals: Array<Promise<void>> = []\n\n for (const handler of this.currentHandlers()) {\n const disposal = handler.dispose()\n\n if (disposal instanceof Promise) {\n pendingDisposals.push(disposal)\n }\n }\n\n // Stay synchronous unless a handler actually disposes of\n // itself asynchronously.\n if (pendingDisposals.length > 0) {\n return Promise.all(pendingDisposals).then(() => {})\n }\n }\n\n #validateHandlers(handlers: Array<AnyHandler>): boolean {\n return handlers.every((handler) => !Array.isArray(handler))\n }\n}\n\nexport class InMemoryHandlersController extends HandlersController {\n #handlers: HandlersMap\n #initialHandlers: HandlersMap\n\n constructor(initialHandlers: Array<AnyHandler>) {\n super()\n\n const initialState = this.getInitialState(initialHandlers)\n\n this.#initialHandlers = initialState.initialHandlers\n this.#handlers = initialState.handlers\n }\n\n protected getState(): HandlersControllerState {\n return {\n initialHandlers: this.#initialHandlers,\n handlers: this.#handlers,\n }\n }\n\n protected setState(nextState: Partial<HandlersControllerState>): void {\n if (nextState.initialHandlers) {\n this.#initialHandlers = nextState.initialHandlers\n }\n\n if (nextState.handlers) {\n this.#handlers = nextState.handlers\n }\n }\n}\n","/**\n * Creates an immutable copy of the given array.\n */\nexport function toReadonlyArray<T>(source: Array<T>): ReadonlyArray<T> {\n const clone = [...source] as Array<T>\n Object.freeze(clone)\n return clone\n}\n","import { devUtils } from './dev-utils'\n\nexport type DisposableSubscription = () => void\n\nexport class Disposable {\n protected subscriptions: Array<DisposableSubscription> = []\n\n public dispose() {\n let subscription: DisposableSubscription | undefined\n const errors: Array<Error> = []\n\n while ((subscription = this.subscriptions.shift())) {\n try {\n subscription()\n } catch (error) {\n if (error instanceof Error) {\n errors.push(error)\n }\n }\n }\n\n if (errors.length > 0) {\n console.error(\n new AggregateError(\n errors,\n devUtils.formatMessage(\n 'Failed to dispose of some side effects. This is likely an issue with MSW, please report it on GitHub: https://github.com/mswjs/msw/issues',\n ),\n ),\n )\n }\n }\n}\n","import { invariant } from 'outvariant'\nimport { Emitter, type DefaultEventMap } from 'rettime'\nimport {\n NetworkSource,\n type ExtractSourceEvents,\n} from './sources/network-source'\nimport type { NetworkFrameResolutionContext } from './frames/network-frame'\nimport type { UnhandledFrameHandle } from './on-unhandled-frame'\nimport {\n HandlersController,\n InMemoryHandlersController,\n type AnyHandler,\n} from './handlers-controller'\nimport { toReadonlyArray } from '../utils/internal/to-readonly-array'\nimport { Disposable } from '../utils/internal/disposable'\nimport type { UnionToIntersection } from '../type-utils'\n\ntype MergeEventMaps<Sources extends Array<NetworkSource<any>>> =\n UnionToIntersection<ExtractSourceEvents<Sources[number]>> extends infer R\n ? R extends Record<string, any>\n ? R\n : DefaultEventMap\n : DefaultEventMap\n\ntype MaybePromise<T> =\n Extract<T, Promise<unknown>> extends never ? void : Promise<void>\n\nexport interface DefineNetworkOptions<\n Sources extends Array<NetworkSource<any>>,\n> {\n /**\n * List of the network sources.\n * Every network source emits frames, and every frame describes how\n * to handle the various network scenarios, like mocking a response,\n * erroring the request, or performing it as-is.\n */\n sources: Sources\n /**\n * List of handlers to describe the network.\n */\n handlers?: Array<AnyHandler> | HandlersController\n context?: NetworkFrameResolutionContext\n onUnhandledFrame?: UnhandledFrameHandle\n}\n\nexport interface NetworkApi<\n Sources extends Array<NetworkSource<any>>,\n> extends NetworkHandlersApi {\n readyState: NetworkReadyState\n /**\n * Enable the network interception and handling.\n */\n enable: () => MaybePromise<ReturnType<Sources[number]['enable']>>\n /**\n * Disable the network interception and handling.\n */\n disable: () => MaybePromise<ReturnType<Sources[number]['disable']>>\n /**\n * Configure the network instance with additional options.\n * The options provided in the `.configure()` call will override the same\n * options in the `defineNetwork()` call.\n */\n configure: (options: Partial<DefineNetworkOptions<Sources>>) => void\n events: Emitter<MergeEventMaps<Sources>>\n}\n\ninterface NetworkHandlersApi {\n use: (...handlers: Array<AnyHandler>) => void\n resetHandlers: (...handlers: Array<AnyHandler>) => void\n restoreHandlers: () => void\n listHandlers: () => ReadonlyArray<AnyHandler>\n}\n\nfunction colorlessPromiseAll<T>(values: Array<T>): MaybePromise<T>\nfunction colorlessPromiseAll(values: Array<unknown>): Promise<void> | void {\n const promises: Array<Promise<void>> = []\n\n for (const value of values) {\n if (value instanceof Promise) {\n promises.push(value)\n }\n }\n\n if (promises.length > 0) {\n return Promise.all(promises).then(() => {})\n }\n}\n\nexport enum NetworkReadyState {\n DISABLED,\n ENABLED,\n}\n\n/**\n * Define a network instance with the given configuration.\n * @example\n * import { InterceptorSource } from 'msw/experimental'\n * import { handlers } from './handlers'\n *\n * const network = defineNetwork({\n * sources: [new InterceptorSource({ interceptors })],\n * handlers,\n * })\n * await network.enable()\n */\nexport function defineNetwork<Sources extends Array<NetworkSource<any>>>(\n options: DefineNetworkOptions<Sources>,\n): NetworkApi<Sources> {\n let readyState: NetworkReadyState = NetworkReadyState.DISABLED\n const events = new Emitter<MergeEventMaps<Sources>>()\n const disposable = new Disposable()\n\n const deriveHandlersController = (\n handlers: DefineNetworkOptions<Sources>['handlers'],\n ) => {\n return handlers instanceof HandlersController\n ? handlers\n : new InMemoryHandlersController(handlers || [])\n }\n\n let resolvedOptions: DefineNetworkOptions<Sources> = {\n ...options,\n }\n\n /**\n * @note Create the handlers controller immediately because\n * certain setup APIs, like `setupServer`, don't await `.enable` (`.listen`).\n */\n let handlersController = deriveHandlersController(resolvedOptions.handlers)\n\n return {\n get readyState() {\n return readyState\n },\n events,\n configure(options) {\n invariant(\n readyState === NetworkReadyState.DISABLED,\n 'Failed to call \"configure()\" on the network: cannot configure an already enabled network.',\n )\n\n if (\n options.handlers &&\n !Object.is(options.handlers, resolvedOptions.handlers)\n ) {\n handlersController = deriveHandlersController(options.handlers)\n }\n\n resolvedOptions = {\n ...resolvedOptions,\n ...options,\n }\n },\n enable() {\n invariant(\n readyState === NetworkReadyState.DISABLED,\n 'Failed to call \"enable\" on the network: already enabled',\n )\n\n readyState = NetworkReadyState.ENABLED\n\n /**\n * @note Use a session object scoped to the current \"enable()\"\n * to prevent \"frame.events\" listeners from surviving across enable/disable cycles.\n * @see The note about `AbortController` below.\n */\n const session = { active: true }\n disposable['subscriptions'].push(() => {\n session.active = false\n })\n\n const result = resolvedOptions.sources.map((source) => {\n /**\n * @note Preemptively disable the network source before enabling.\n * This intentionally calls only the prototype method that clears the\n * event listeners and nothing else. This prevents the \"frame\" listeners\n * from accumulating across enable/disable in case the source is a singleton.\n */\n NetworkSource.prototype.disable.call(source)\n\n source.on('frame', async ({ frame }) => {\n frame.events.on('*', (event) => {\n /**\n * @note Prevent event forwarding manually and not via an AbortController\n * because certain runtimes, like Cloudflare, throw when referencing an\n * AbortController created in a different context. Bear in mind that the frame\n * events run in the patched request client context while the AbortController\n * is created outside, in the \"defineNetwork\" closure, which is a test context.\n */\n if (!session.active) {\n return\n }\n\n events.emit(event)\n })\n\n const handlers = frame.getHandlers(handlersController)\n\n await frame.resolve(\n handlers,\n resolvedOptions.onUnhandledFrame || 'warn',\n resolvedOptions.context,\n )\n })\n\n return source.enable()\n })\n\n return colorlessPromiseAll(result) as MaybePromise<\n ReturnType<Sources[number]['enable']>\n >\n },\n disable() {\n invariant(\n readyState === NetworkReadyState.ENABLED,\n 'Failed to call \"disable\" on the network: already disabled',\n )\n\n readyState = NetworkReadyState.DISABLED\n\n // Let the handlers release the resources they hold before\n // tearing down the network itself. Handlers may still need the\n // network while disposing of themselves (e.g. to close the\n // connections they own).\n const handlersDisposal = handlersController.dispose()\n disposable.dispose()\n\n /**\n * @note Tear down the sources synchronously, never behind the\n * handlers disposal. `disable()` is not always awaited (e.g.\n * `server.close()` is synchronous), and a deferred teardown would\n * race any `enable()` that follows, disabling the sources that the\n * new session has just enabled.\n */\n const sourcesDisposal = colorlessPromiseAll(\n resolvedOptions.sources.map((source) => source.disable()),\n )\n\n /**\n * @note Await both disposals so neither rejection goes unobserved.\n * Chaining them would leave the source disposal floating whenever\n * the handlers disposal rejects.\n */\n return (\n handlersDisposal instanceof Promise\n ? Promise.all([handlersDisposal, sourcesDisposal]).then(() => {})\n : sourcesDisposal\n ) as MaybePromise<ReturnType<Sources[number]['disable']>>\n },\n use(...handlers) {\n handlersController.use(handlers)\n },\n resetHandlers(...handlers) {\n handlersController.reset(handlers)\n },\n restoreHandlers() {\n handlersController.restore()\n },\n listHandlers() {\n return toReadonlyArray(handlersController.listHandlers())\n },\n }\n}\n","import { Emitter, type DefaultEventMap } from 'rettime'\nimport type { AnyHandler, HandlersController } from '../handlers-controller'\nimport type { UnhandledFrameHandle } from '../on-unhandled-frame'\n\nexport type AnyNetworkFrame = NetworkFrame<string, unknown, any>\n\nexport type ExtractFrameEvents<Frame> =\n Frame extends NetworkFrame<any, any, infer Events> ? Events : never\n\nexport interface NetworkFrameResolutionContext {\n baseUrl?: string | URL\n quiet?: boolean\n}\n\n/**\n * The base for the network frames. Extend this abstract class\n * to implement custom network frames.\n */\nexport abstract class NetworkFrame<\n Protocol extends string,\n Data,\n Events extends DefaultEventMap,\n> {\n public events: Emitter<Events>\n\n constructor(\n public readonly protocol: Protocol,\n public readonly data: Data,\n ) {\n this.events = new Emitter()\n }\n\n public abstract getHandlers(controller: HandlersController): Array<AnyHandler>\n\n /**\n * Resolve the current frame against the given list of handlers.\n * Optionally, use a custom resolution context to control behaviors\n * like `baseUrl`.\n *\n * Returns `true` if the frame was handled, `false` if it wasn't, and `null`\n * if its handling was skipped (e.g. the frame was bypassed).\n */\n public abstract resolve(\n handlers: Array<AnyHandler>,\n onUnhandledFrame: UnhandledFrameHandle,\n resolutionContext?: NetworkFrameResolutionContext,\n ): Promise<boolean | null>\n\n /**\n * Perform this network frame as-is.\n */\n public abstract passthrough(): void\n\n /**\n * Error the underling network frame.\n * @param reason The reason for the error.\n */\n public abstract errorWith(reason?: unknown): void\n\n /**\n * Get a message to be used when this frame is unhandled.\n */\n public abstract getUnhandledMessage(): Promise<string>\n}\n","import { cookieStore } from '../cookie-store'\nimport { getRawSetCookie } from '../response-decorators'\n\nexport async function storeResponseCookies(\n request: Request,\n response: Response,\n): Promise<void> {\n if (cookieStore === null) {\n return\n }\n\n for (const responseCookie of getRawSetCookie(response)) {\n await cookieStore.setCookie(responseCookie, request.url)\n }\n}\n","export function shouldBypassRequest(request: Request): boolean {\n return !!request.headers.get('accept')?.includes('msw/passthrough')\n}\n\n/**\n * Remove the internal passthrough instruction from the request's `Accept` header.\n */\nexport function deleteRequestPassthroughHeader(request: Request): void {\n const acceptHeader = request.headers.get('accept')\n\n /**\n * @note Remove the internal bypass request header.\n * In the browser, this is done by the worker script.\n * In Node.js, it has to be done here.\n */\n if (acceptHeader) {\n const nextAcceptHeader = acceptHeader.replace(/(,\\s+)?msw\\/passthrough/, '')\n\n if (nextAcceptHeader) {\n request.headers.set('accept', nextAcceptHeader)\n } else {\n request.headers.delete('accept')\n }\n }\n}\n","import { invariant } from 'outvariant'\nimport { isCommonAssetRequest } from '#utils/is-common-asset-request'\nimport { devUtils, InternalError } from '../utils/internal/dev-utils'\nimport { HttpNetworkFrame } from './frames/http-frame'\nimport type { AnyNetworkFrame } from './frames/network-frame'\n\nexport type UnhandledFrameHandle =\n UnhandledFrameStrategy | UnhandledFrameCallback\n\nexport type UnhandledFrameStrategy = 'bypass' | 'warn' | 'error'\n\nexport type UnhandledFrameCallback = (args: {\n frame: AnyNetworkFrame\n defaults: UnhandledFrameDefaults\n}) => Promise<void> | void\n\ntype UnhandledFrameDefaults = {\n warn: () => void\n error: () => void\n}\n\nexport async function executeUnhandledFrameHandle(\n frame: AnyNetworkFrame,\n handle: UnhandledFrameHandle,\n): Promise<void> {\n const printStrategyMessage = async (\n strategy: UnhandledFrameStrategy,\n ): Promise<void> => {\n if (strategy === 'bypass') {\n return\n }\n\n const message = await frame.getUnhandledMessage()\n\n switch (strategy) {\n case 'warn': {\n return devUtils.warn('Warning: %s', message)\n }\n\n case 'error': {\n return devUtils.error('Error: %s', message)\n }\n }\n }\n\n const applyStrategy = async (\n strategy: UnhandledFrameStrategy,\n ): Promise<void> => {\n invariant.as(\n InternalError,\n strategy === 'bypass' || strategy === 'warn' || strategy === 'error',\n devUtils.formatMessage(\n 'Failed to react to an unhandled network frame: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledFrame\" option.',\n strategy,\n ),\n )\n\n if (strategy === 'bypass') {\n return\n }\n\n await printStrategyMessage(strategy)\n\n if (strategy === 'error') {\n return Promise.reject(\n new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledFrame\" option.',\n ),\n ),\n )\n }\n }\n\n if (typeof handle === 'function') {\n return handle({\n frame,\n defaults: {\n warn: printStrategyMessage.bind(null, 'warn'),\n /**\n * @note The defaults only print the corresponding messages now.\n * They do not affect the frame resolution (e.g. do not error the frame).\n * That is only for backward compatibility reasons. In the future, these should\n * be an alias to `applyStrategy.bind(null, 'error')` instead.\n */\n error: printStrategyMessage.bind(null, 'error'),\n },\n })\n }\n\n /**\n * Ignore unhandled common HTTP assets.\n * @note Calling this here applies the common assets check\n * only to the scenarios when `onUnhandledFrame` was set to a predefined strategy.\n * When using a custom function, you need to check for common assets manually.\n */\n if (\n frame instanceof HttpNetworkFrame &&\n isCommonAssetRequest(frame.data.request)\n ) {\n return\n }\n\n return applyStrategy(handle)\n}\n","import { TypedEvent } from 'rettime'\nimport { until } from 'until-async'\nimport { createRequestId } from '@mswjs/interceptors'\nimport {\n NetworkFrame,\n type NetworkFrameResolutionContext,\n} from './network-frame'\nimport { toPublicUrl } from '../../utils/request/to-public-url'\nimport { executeHandlers } from '../../utils/execute-handlers'\nimport { storeResponseCookies } from '../../utils/request/store-response-cookies'\nimport { shouldBypassRequest } from '../request-utils'\nimport { isPassthroughResponse } from '#utils/passthrough'\nimport { devUtils } from '../../utils/internal/dev-utils'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameHandle,\n} from '../on-unhandled-frame'\nimport type { HandlersController } from '../handlers-controller'\nimport type { AnyHandler } from '../handlers-controller'\nimport type { RequestHandler } from '../../handlers/request-handler'\n\ninterface HttpNetworkFrameOptions {\n id?: string\n request: Request\n}\n\nclass RequestEvent<\n DataType extends { requestId: string; request: Request } = {\n requestId: string\n request: Request\n },\n ReturnType = void,\n EventType extends string = string,\n> extends TypedEvent<DataType, ReturnType, EventType> {\n public readonly requestId: string\n public readonly request: Request\n\n constructor(type: EventType, data: DataType) {\n super(...([type, {}] as any))\n this.requestId = data.requestId\n this.request = data.request\n }\n}\n\nexport class ResponseEvent<\n DataType extends {\n requestId: string\n request: Request\n response: Response\n } = {\n requestId: string\n request: Request\n response: Response\n },\n ReturnType = void,\n EventType extends string = string,\n> extends TypedEvent<DataType, ReturnType, EventType> {\n public readonly requestId: string\n public readonly request: Request\n public readonly response: Response\n\n constructor(type: EventType, data: DataType) {\n super(...([type, {}] as any))\n this.requestId = data.requestId\n this.request = data.request\n this.response = data.response\n }\n}\n\nclass UnhandledExceptionEvent<\n DataType extends {\n error: Error\n requestId: string\n request: Request\n } = {\n error: Error\n requestId: string\n request: Request\n },\n ReturnType = void,\n EventType extends string = string,\n> extends TypedEvent<DataType, ReturnType, EventType> {\n public readonly error: Error\n public readonly requestId: string\n public readonly request: Request\n\n constructor(type: EventType, data: DataType) {\n super(...([type, {}] as any))\n this.error = data.error\n this.requestId = data.requestId\n this.request = data.request\n }\n}\n\nexport type HttpNetworkFrameEventMap = {\n 'request:start': RequestEvent\n 'request:match': RequestEvent\n 'request:unhandled': RequestEvent\n 'request:end': RequestEvent\n 'response:mocked': ResponseEvent\n 'response:bypass': ResponseEvent\n unhandledException: UnhandledExceptionEvent\n}\n\nexport abstract class HttpNetworkFrame extends NetworkFrame<\n 'http',\n {\n id: string\n request: Request\n },\n HttpNetworkFrameEventMap\n> {\n constructor(options: HttpNetworkFrameOptions) {\n const id = options.id || createRequestId()\n super('http', { id, request: options.request })\n }\n\n public getHandlers(controller: HandlersController): Array<AnyHandler> {\n return controller.getHandlersByKind('request')\n }\n\n public abstract respondWith(response?: Response): void\n\n public async getUnhandledMessage(): Promise<string> {\n const { request } = this.data\n\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n const requestBody =\n request.body == null ? null : await request.clone().text()\n\n const details = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const message = `intercepted a request without a matching request handler:${details}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/http/intercepting-requests`\n\n return message\n }\n\n public async resolve(\n handlers: Array<RequestHandler>,\n onUnhandledFrame: UnhandledFrameHandle,\n resolutionContext?: NetworkFrameResolutionContext,\n ): Promise<boolean | null> {\n const { id: requestId, request } = this.data\n const requestCloneForLogs = resolutionContext?.quiet\n ? null\n : request.clone()\n\n this.events.emit(new RequestEvent('request:start', { requestId, request }))\n\n // Requests wrapped in explicit \"bypass(request)\".\n if (shouldBypassRequest(request)) {\n this.events.emit(new RequestEvent('request:end', { requestId, request }))\n this.passthrough()\n return null\n }\n\n const [lookupError, lookupResult] = await until(() => {\n return executeHandlers({\n requestId,\n request,\n handlers,\n resolutionContext: {\n baseUrl: resolutionContext?.baseUrl?.toString(),\n quiet: resolutionContext?.quiet,\n },\n })\n })\n\n if (lookupError != null) {\n if (\n !this.events.emit(\n new UnhandledExceptionEvent('unhandledException', {\n error: lookupError,\n requestId,\n request,\n }),\n )\n ) {\n // Surface the error to the developer since they haven't handled it.\n console.error(lookupError)\n devUtils.error(\n 'Encountered an unhandled exception during the handler lookup for \"%s %s\". Please see the original error above.',\n request.method,\n request.url,\n )\n }\n\n this.errorWith(lookupError)\n return null\n }\n\n // No matching handlers.\n if (lookupResult == null) {\n this.events.emit(\n new RequestEvent('request:unhandled', {\n requestId,\n request,\n }),\n )\n\n /**\n * @note The unhandled frame handle must be executed during the request resolution\n * since it can influence it (e.g. error the request if the \"error\" startegy was used).\n */\n await executeUnhandledFrameHandle(this, onUnhandledFrame).then(\n () => this.passthrough(),\n (error) => this.errorWith(error),\n )\n\n this.events.emit(\n new RequestEvent('request:end', {\n requestId,\n request,\n }),\n )\n\n return false\n }\n\n const { response, handler, parsedResult } = lookupResult\n\n this.events.emit(\n new RequestEvent('request:match', {\n requestId,\n request,\n }),\n )\n\n // Handlers that returned no mocked response.\n if (response == null) {\n this.events.emit(\n new RequestEvent('request:end', {\n requestId,\n request,\n }),\n )\n\n this.passthrough()\n return null\n }\n\n // Handlers that returned explicit `passthrough()`.\n if (isPassthroughResponse(response)) {\n this.events.emit(\n new RequestEvent('request:end', {\n requestId,\n request,\n }),\n )\n\n this.passthrough()\n return null\n }\n\n const responseCloneForLogs = resolutionContext?.quiet\n ? null\n : response.clone()\n\n await storeResponseCookies(request, response)\n\n this.respondWith(response)\n\n this.events.emit(\n new RequestEvent('request:end', {\n requestId,\n request,\n }),\n )\n\n if (!resolutionContext?.quiet) {\n handler.log({\n request: requestCloneForLogs!,\n response: responseCloneForLogs!,\n parsedResult,\n })\n }\n\n return true\n }\n}\n","import { TypedEvent } from 'rettime'\nimport type { GraphQLSubscriptionEvent } from '#graphql/graphql-subscription-event'\nimport type { WebSocketConnectionEventData } from '@mswjs/interceptors/WebSocket'\nimport {\n kConnect,\n kAutoConnect,\n type WebSocketHandler,\n type AnyWebSocketExtension,\n} from '#ws/websocket-handler'\nimport {\n NetworkFrame,\n type NetworkFrameResolutionContext,\n} from './network-frame'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameHandle,\n} from '../on-unhandled-frame'\nimport { devUtils } from '../../utils/internal/dev-utils'\nimport type { HandlersController } from '../handlers-controller'\nimport type { AnyHandler } from '../handlers-controller'\n\nexport interface WebSocketNetworkFrameOptions {\n connection: WebSocketConnectionEventData\n}\n\nexport type WebSocketNetworkFrameEventMap = {\n /**\n * Emitted when a WebSocket connection is intercepted,\n * before any handlers are resolved against it.\n */\n 'websocket:connection': WebSocketConnectionEvent\n /**\n * Emitted when the WebSocket connection errors.\n * This includes initial connection errors as well as runtime errors\n * after the connection has been established.\n */\n 'websocket:error': WebSocketErrorEvent\n 'graphql:subscription': GraphQLSubscriptionEvent\n unhandledException: WebSocketErrorEvent\n}\n\nclass WebSocketConnectionEvent<\n DataType extends {\n url: URL\n protocols: string | Array<string> | undefined\n } = { url: URL; protocols: string | Array<string> | undefined },\n ReturnType = void,\n EventType extends string = string,\n> extends TypedEvent<DataType, ReturnType, EventType> {\n public readonly url: URL\n public readonly protocols: string | Array<string> | undefined\n\n constructor(type: EventType, data: DataType) {\n super(...([type, {}] as any))\n this.url = data.url\n this.protocols = data.protocols\n }\n}\n\nclass WebSocketErrorEvent<\n DataType extends {\n url: URL\n protocols: string | Array<string> | undefined\n error: unknown\n } = {\n url: URL\n protocols: string | Array<string> | undefined\n error: unknown\n },\n ReturnType = void,\n EventType extends string = string,\n> extends WebSocketConnectionEvent<DataType, ReturnType, EventType> {\n public readonly error: unknown\n\n constructor(type: EventType, data: DataType) {\n super(type, data)\n this.error = data.error\n }\n}\n\nexport abstract class WebSocketNetworkFrame extends NetworkFrame<\n 'ws',\n {\n connection: WebSocketConnectionEventData\n },\n WebSocketNetworkFrameEventMap\n> {\n constructor(options: WebSocketNetworkFrameOptions) {\n super('ws', {\n connection: options.connection,\n })\n }\n\n public getHandlers(controller: HandlersController): Array<AnyHandler> {\n return controller.getHandlersByKind('websocket')\n }\n\n public async resolve(\n handlers: Array<WebSocketHandler<AnyWebSocketExtension>>,\n onUnhandledFrame: UnhandledFrameHandle,\n resolutionContext?: NetworkFrameResolutionContext,\n ): Promise<boolean | null> {\n const { connection } = this.data\n\n this.events.emit(\n new WebSocketConnectionEvent('websocket:connection', {\n url: connection.client.url,\n protocols: connection.info.protocols,\n }),\n )\n\n const handleSocketError = (event: Event) => {\n this.events.emit(\n new WebSocketErrorEvent('websocket:error', {\n url: connection.client.url,\n protocols: connection.info.protocols,\n error: getErrorFromEvent(event),\n }),\n )\n }\n\n connection.client.socket.addEventListener('error', handleSocketError)\n connection.client.socket.addEventListener(\n 'close',\n () => {\n connection.client.socket.removeEventListener('error', handleSocketError)\n },\n { once: true },\n )\n\n // No WebSocket handlers defined.\n if (handlers.length === 0) {\n await executeUnhandledFrameHandle(this, onUnhandledFrame).then(\n () => this.passthrough(),\n (error) => this.errorWith(error),\n )\n\n return false\n }\n\n let hasMatchingHandlers = false\n\n for (const handler of handlers) {\n const handlerConnection = await handler.run(connection, {\n baseUrl: resolutionContext?.baseUrl?.toString(),\n /**\n * @note Expose an emit-only reference to this frame's events\n * so the handlers can emit additional events not covered by\n * the frame (e.g. \"graphql:subscription\").\n */\n events: this.events,\n /**\n * @note Do not emit the handler's \"connection\" event when running the handler.\n * Use the run only to get the resolved connection object.\n */\n [kAutoConnect]: false,\n })\n\n if (!handlerConnection) {\n continue\n }\n\n hasMatchingHandlers = true\n\n /**\n * @note Attach the WebSocket logger *before* emitting the handler's \"connection\" event.\n * Connection event listeners may perform actions that should be reflected in the logs\n * (e.g. closing the connection immediately). If the logger is attached after the connection,\n * those actions cannot be properly logged.\n */\n const removeLogger = !resolutionContext?.quiet\n ? handler.log(connection)\n : undefined\n\n try {\n if (!handler[kConnect](handlerConnection)) {\n removeLogger?.()\n }\n } catch (error) {\n if (\n !this.events.emit(\n new WebSocketErrorEvent('unhandledException', {\n error,\n url: connection.client.url,\n protocols: connection.info.protocols,\n }),\n )\n ) {\n console.error(error)\n devUtils.error(\n 'Encountered an unhandled exception during the handler lookup for \"%s\". Please see the original error above.',\n connection.client.url,\n )\n }\n\n /**\n * @note Throw the caught error so it gets picked up by WebSocketInterceptor.\n * It's the interceptor who translates handler errors to WebSocket closures.\n */\n throw error\n }\n }\n\n // No matching WebSocket handlers found.\n if (!hasMatchingHandlers) {\n await executeUnhandledFrameHandle(this, onUnhandledFrame).then(\n () => this.passthrough(),\n (error) => this.errorWith(error),\n )\n\n return false\n }\n\n return true\n }\n\n public async getUnhandledMessage(): Promise<string> {\n const { connection } = this.data\n const details = `\\n\\n \\u2022 ${connection.client.url}\\n\\n`\n\n return `intercepted a WebSocket connection without a matching event handler:${details}If you still wish to intercept this unhandled connection, please create an event handler for it.\\nRead more: https://mswjs.io/docs/websocket`\n }\n}\n\n/**\n * Extract the error from the given \"error\" event, if any.\n * Supports both the `ErrorEvent.error` property and the `cause`\n * property that MSW sets when erroring the connection itself.\n */\nfunction getErrorFromEvent(event: Event): unknown {\n if ('error' in event && event.error != null) {\n return event.error\n }\n\n if ('cause' in event && event.cause != null) {\n return event.cause\n }\n\n return undefined\n}\n","import type { Interceptor, RequestController } from '@mswjs/interceptors'\nimport {\n BatchInterceptor,\n type HttpRequestEventMap,\n type HttpRequestEvent,\n type HttpResponseEvent,\n} from '@mswjs/interceptors'\nimport type {\n WebSocketClientConnection,\n WebSocketInterceptedConnection,\n WebSocketEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { NetworkSource } from './network-source'\nimport { InternalError } from '../../utils/internal/dev-utils'\nimport { HttpNetworkFrame, ResponseEvent } from '../frames/http-frame'\nimport { WebSocketNetworkFrame } from '../frames/websocket-frame'\nimport { deleteRequestPassthroughHeader } from '../request-utils'\n\nexport interface InterceptorSourceOptions {\n interceptors: Array<Interceptor<HttpRequestEventMap | WebSocketEventMap>>\n}\n\n/**\n * Create a network source from the given list of interceptors.\n */\nexport class InterceptorSource extends NetworkSource {\n #interceptor: BatchInterceptor<\n InterceptorSourceOptions['interceptors'],\n HttpRequestEventMap & WebSocketEventMap\n >\n\n /**\n * @note Frames are keyed by the request instance, not the request ID.\n * The interceptor emits the same request instance on the \"request\"\n * and \"response\" events, so the frame can be looked up by identity.\n * A weak reference lets the frame be garbage collected alongside\n * its request once the request settles without producing a response\n * (e.g. a passthrough request failing with a network error).\n * @see https://github.com/mswjs/msw/issues/2792\n */\n #frames: WeakMap<Request, HttpNetworkFrame>\n\n constructor(options: InterceptorSourceOptions) {\n super()\n\n this.#interceptor = new BatchInterceptor({\n name: 'interceptor-source',\n interceptors: options.interceptors,\n })\n this.#frames = new WeakMap()\n }\n\n public enable(): void {\n this.#interceptor.apply()\n\n this.#interceptor\n .on('request', this.#handleRequest.bind(this))\n .on('response', this.#handleResponse.bind(this))\n .on('connection', this.#handleWebSocketConnection.bind(this))\n }\n\n public disable(): void {\n super.disable()\n this.#interceptor.dispose()\n\n /**\n * @todo We can also abort any pending frames here, given we implement\n * the `NetworkFrame.abort()` method.\n */\n this.#frames = new WeakMap()\n }\n\n async #handleRequest(event: HttpRequestEvent): Promise<void> {\n const { requestId, request, controller } = event\n const httpFrame = new InterceptorHttpNetworkFrame({\n id: requestId,\n request,\n controller,\n })\n\n this.#frames.set(request, httpFrame)\n await this.queue(httpFrame)\n }\n\n async #handleResponse({\n requestId,\n request,\n response,\n responseType,\n }: HttpResponseEvent): Promise<void> {\n const httpFrame = this.#frames.get(request)\n this.#frames.delete(request)\n\n if (httpFrame == null) {\n return\n }\n\n queueMicrotask(() => {\n try {\n httpFrame.events.emit(\n new ResponseEvent(\n responseType === 'mock' ? 'response:mocked' : 'response:bypass',\n {\n requestId,\n request,\n response,\n },\n ),\n )\n } finally {\n /**\n * @note Remove any listeners from this frame.\n * Past this point, it won't emit anything. The removal is crucial\n * to prevent \"rettime\" from keeping the abort cleanup listeners internally.\n * @see https://github.com/mswjs/msw/issues/2735\n */\n httpFrame.events.removeAllListeners()\n }\n })\n }\n\n async #handleWebSocketConnection(\n connection: WebSocketEventMap['connection'],\n ): Promise<void> {\n await this.queue(\n new InterceptorWebSocketNetworkFrame({\n connection,\n }),\n )\n }\n}\n\nclass InterceptorHttpNetworkFrame extends HttpNetworkFrame {\n #controller: RequestController\n\n constructor(options: {\n id: string\n request: Request\n controller: RequestController\n }) {\n super({\n id: options.id,\n request: options.request,\n })\n\n this.#controller = options.controller\n }\n\n public passthrough(): void {\n deleteRequestPassthroughHeader(this.data.request)\n }\n\n public respondWith(response?: Response): void {\n if (response) {\n this.#controller.respondWith(response)\n }\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Response) {\n return this.respondWith(reason)\n }\n\n if (reason instanceof InternalError) {\n this.#controller.errorWith(reason)\n }\n\n throw reason\n }\n}\n\nclass InterceptorWebSocketNetworkFrame extends WebSocketNetworkFrame {\n /**\n * The in-process client connection, whose socket\n * the frame dispatches errors on.\n */\n readonly #client: WebSocketClientConnection\n\n constructor(args: { connection: WebSocketInterceptedConnection }) {\n super({ connection: args.connection })\n\n this.#client = args.connection.client\n\n /**\n * @note Provide a similar frame listener cleanup as for HTTP.\n * When the client connection closes, the handler can no longer be used.\n */\n args.connection.client.addEventListener(\n 'close',\n () => {\n this.events.removeAllListeners()\n },\n {\n once: true,\n },\n )\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Error) {\n /**\n * Use `client.errorWith(reason)` in the future.\n * @see https://github.com/mswjs/interceptors/issues/747\n */\n const errorEvent = new Event('error')\n\n Object.defineProperty(errorEvent, 'cause', {\n enumerable: true,\n configurable: false,\n value: reason,\n })\n\n this.#client.socket.dispatchEvent(errorEvent)\n }\n }\n\n public passthrough() {\n this.data.connection.server.connect()\n }\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAM,oBAAN,cAIU,WAA4C;CACpD;CAEA,YAAY,MAAc,OAAwB;EAChD,MAAM,GAAI,CAAC,MAAM,CAAC,CAAC,CAAS;EAC5B,KAAK,QAAQ;CACf;AACF;AASA,IAAsB,gBAAtB,MAEE;CACA;CAEA,cAAc;EACZ,KAAK,UAAU,IAAI,QAAQ;CAC7B;CAIA,MAAa,MAAM,OAA6B;EAC9C,MAAM,KAAK,QAAQ,cAEjB,I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,UAAU,KAAK,WAAW;;;;;EAM/B,KAAK,WAAW,OAAO,iBACrB,eACM;GACJ,KAAK,OAAO,mBAAmB;EACjC,GACA,EACE,MAAM,KACR,CACF;CACF;CAEA,UAAiB,QAAwB;EACvC,IAAI,kBAAkB,OAAO;;;;;GAK3B,MAAM,aAAa,IAAI,MAAM,OAAO;GAEpC,OAAO,eAAe,YAAY,SAAS;IACzC,YAAY;IACZ,cAAc;IACd,OAAO;GACT,CAAC;GAED,KAAK,QAAQ,OAAO,cAAc,UAAU;EAC9C;CACF;CAEA,cAAqB;EACnB,KAAK,KAAK,WAAW,OAAO,QAAQ;CACtC;AACF"}
@@ -0,0 +1,11 @@
1
+ //#region src/core/utils/internal/is-object.ts
2
+ /**
3
+ * Determines if the given value is an object.
4
+ */
5
+ function isObject(value) {
6
+ return value != null && typeof value === "object" && !Array.isArray(value);
7
+ }
8
+ //#endregion
9
+ export { isObject as t };
10
+
11
+ //# sourceMappingURL=is-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-object.js","names":[],"sources":["../../src/core/utils/internal/is-object.ts"],"sourcesContent":["/**\n * Determines if the given value is an object.\n */\nexport function isObject(value: any): value is Record<string, any> {\n return value != null && typeof value === 'object' && !Array.isArray(value)\n}\n"],"mappings":";;;;AAGA,SAAgB,SAAS,OAA0C;CACjE,OAAO,SAAS,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC3E"}
@@ -0,0 +1,14 @@
1
+ //#region src/core/utils/matching/match-request-url.d.ts
2
+ type Path = string | RegExp;
3
+ type PathParams<KeyType extends keyof any = string> = { [ParamName in KeyType]?: string | ReadonlyArray<string>; };
4
+ interface Match {
5
+ matches: boolean;
6
+ params?: PathParams;
7
+ }
8
+ /**
9
+ * Match the given URL against a path pattern.
10
+ */
11
+ declare function matchRequestUrl(url: URL, pattern: Path, baseUrl?: string): Match;
12
+ //#endregion
13
+ export { matchRequestUrl as i, Path as n, PathParams as r, Match as t };
14
+ //# sourceMappingURL=match-request-url.d.ts.map
@@ -0,0 +1,295 @@
1
+ import { FetchResponse } from "@mswjs/interceptors";
2
+ //#region src/core/type-utils.d.ts
3
+ type MaybePromise<T> = T | Promise<T>;
4
+ /**
5
+ * Blocks inference from the annotated position, like the built-in `NoInfer`,
6
+ * but resolves to a plain type once instantiated. The built-in `NoInfer` stays
7
+ * an opaque wrapper, which makes TypeScript report response body mismatches on
8
+ * the whole object literal instead of the offending property.
9
+ */
10
+ type TransparentNoInfer<T> = [T][T extends any ? 0 : never];
11
+ /**
12
+ * Turns a union of types into an intersection of its members.
13
+ */
14
+ type UnionToIntersection<Union> = (Union extends unknown ? (member: Union) => void : never) extends ((member: infer Intersection) => void) ? Intersection : never;
15
+ //#endregion
16
+ //#region src/core/handlers/handler.d.ts
17
+ type HandlerKind = 'request' | 'websocket';
18
+ /**
19
+ * The base class for all the handlers.
20
+ */
21
+ declare abstract class Handler {
22
+ /**
23
+ * The kind of the network frame this handler handles.
24
+ */
25
+ abstract readonly kind: HandlerKind;
26
+ /**
27
+ * Reset the runtime state this handler accumulated while handling
28
+ * the network (e.g. generator resolver progress).
29
+ *
30
+ * @note This method is invoked automatically when the handlers are
31
+ * reset (e.g. `server.resetHandlers()`).
32
+ */
33
+ reset(): void;
34
+ /**
35
+ * Restore this handler so it can handle the network again after
36
+ * being exhausted (e.g. via `{ once: true }`).
37
+ *
38
+ * @note This method is invoked automatically when the handlers are
39
+ * restored (e.g. `server.restoreHandlers()`).
40
+ */
41
+ restore(): void;
42
+ /**
43
+ * Release the resources held by this handler.
44
+ *
45
+ * @note This method is invoked automatically when the network is
46
+ * disabled (e.g. `server.close()`). Override it in the handlers that
47
+ * hold onto anything beyond a single frame, like timers, connections,
48
+ * or event listeners. Returning a promise makes the network await
49
+ * this handler's disposal before it tears itself down.
50
+ */
51
+ dispose(): MaybePromise<void>;
52
+ }
53
+ //#endregion
54
+ //#region src/core/utils/execute-handlers.d.ts
55
+ interface ResponseResolutionContext {
56
+ /**
57
+ * A base url to use when resolving relative urls.
58
+ * @note This is primarily used by the `@mswjs/http-middleware`
59
+ * to resolve relative urls in the context of the running server
60
+ */
61
+ baseUrl?: string;
62
+ quiet?: boolean;
63
+ }
64
+ //#endregion
65
+ //#region src/http/symbols.d.ts
66
+ /**
67
+ * Associates the mocked response body type with the response instance
68
+ * for stricter typing of the response resolvers.
69
+ */
70
+ declare const bodyType: unique symbol;
71
+ //#endregion
72
+ //#region src/http/http-response.d.ts
73
+ interface HttpResponseInit extends ResponseInit {
74
+ type?: ResponseType;
75
+ }
76
+ type DefaultUnsafeFetchResponse = Response & {
77
+ [bodyType]?: never;
78
+ };
79
+ interface StrictRequest<BodyType extends JsonBodyType> extends Request {
80
+ json(): Promise<BodyType>;
81
+ clone(): StrictRequest<BodyType>;
82
+ }
83
+ /**
84
+ * A drop-in replacement for the standard `Response` class
85
+ * to allow additional features, like mocking the response `Set-Cookie` header.
86
+ *
87
+ * @example
88
+ * new HttpResponse('Hello world', { status: 201 })
89
+ * HttpResponse.json({ name: 'John' })
90
+ * HttpResponse.formData(form)
91
+ *
92
+ * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
93
+ */
94
+ declare class HttpResponse<BodyType extends DefaultBodyType> extends FetchResponse {
95
+ readonly [bodyType]: BodyType;
96
+ constructor(body?: TransparentNoInfer<BodyType> | null, init?: HttpResponseInit);
97
+ static error(): HttpResponse<any>;
98
+ /**
99
+ * Create a `Response` with a `Content-Type: "text/plain"` body.
100
+ * @example
101
+ * HttpResponse.text('hello world')
102
+ * HttpResponse.text('Error', { status: 500 })
103
+ */
104
+ static text<BodyType extends string>(body?: TransparentNoInfer<BodyType> | null, init?: HttpResponseInit): HttpResponse<BodyType>;
105
+ /**
106
+ * Create a `Response` with a `Content-Type: "application/json"` body.
107
+ * @example
108
+ * HttpResponse.json({ firstName: 'John' })
109
+ * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
110
+ */
111
+ static json<BodyType extends JsonBodyType>(body?: TransparentNoInfer<BodyType> | null | undefined, init?: HttpResponseInit): HttpResponse<BodyType>;
112
+ /**
113
+ * Create a `Response` with a `Content-Type: "application/xml"` body.
114
+ * @example
115
+ * HttpResponse.xml(`<user name="John" />`)
116
+ * HttpResponse.xml(`<article id="abc-123" />`, { status: 201 })
117
+ */
118
+ static xml<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): HttpResponse<BodyType>;
119
+ /**
120
+ * Create a `Response` with a `Content-Type: "text/html"` body.
121
+ * @example
122
+ * HttpResponse.html(`<p class="author">Jane Doe</p>`)
123
+ * HttpResponse.html(`<main id="abc-123">Main text</main>`, { status: 201 })
124
+ */
125
+ static html<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): HttpResponse<BodyType>;
126
+ /**
127
+ * Create a `Response` with an `ArrayBuffer` body.
128
+ * @example
129
+ * const buffer = new ArrayBuffer(3)
130
+ * const view = new Uint8Array(buffer)
131
+ * view.set([1, 2, 3])
132
+ *
133
+ * HttpResponse.arrayBuffer(buffer)
134
+ */
135
+ static arrayBuffer<BodyType extends ArrayBuffer | SharedArrayBuffer>(body?: BodyType, init?: HttpResponseInit): HttpResponse<BodyType>;
136
+ /**
137
+ * Create a `Response` with a `FormData` body.
138
+ * @example
139
+ * const data = new FormData()
140
+ * data.set('name', 'Alice')
141
+ *
142
+ * HttpResponse.formData(data)
143
+ */
144
+ static formData(body?: FormData, init?: HttpResponseInit): HttpResponse<FormData>;
145
+ }
146
+ //#endregion
147
+ //#region src/core/handlers/request-handler.d.ts
148
+ type DefaultRequestMultipartBody = Record<string, string | File | Array<string | File>>;
149
+ type DefaultBodyType = Record<string, any> | DefaultRequestMultipartBody | string | number | boolean | null | undefined;
150
+ type JsonBodyType = Record<string, any> | string | number | boolean | null | undefined;
151
+ interface RequestHandlerDefaultInfo {
152
+ header: string;
153
+ }
154
+ interface RequestHandlerInternalInfo {
155
+ callFrame?: string;
156
+ }
157
+ type ResponseResolverReturnType<ResponseBodyType extends DefaultBodyType = undefined> = ([ResponseBodyType] extends [undefined] ? Response : ResponseBodyType extends Record<string, any> | undefined ? HttpResponse<ResponseBodyType> | DefaultUnsafeFetchResponse : HttpResponse<ResponseBodyType>) | undefined | void;
158
+ type MaybeAsyncResponseResolverReturnType<ResponseBodyType extends DefaultBodyType> = MaybePromise<ResponseResolverReturnType<ResponseBodyType>>;
159
+ type AsyncResponseResolverReturnType<ResponseBodyType extends DefaultBodyType> = MaybePromise<ResponseResolverReturnType<ResponseBodyType> | Iterable<MaybeAsyncResponseResolverReturnType<ResponseBodyType>, MaybeAsyncResponseResolverReturnType<ResponseBodyType>, MaybeAsyncResponseResolverReturnType<ResponseBodyType>> | AsyncIterable<MaybeAsyncResponseResolverReturnType<ResponseBodyType>, MaybeAsyncResponseResolverReturnType<ResponseBodyType>, MaybeAsyncResponseResolverReturnType<ResponseBodyType>>>;
160
+ type ResponseResolverInfo<ResolverExtraInfo extends Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType> = {
161
+ request: StrictRequest<RequestBodyType>;
162
+ requestId: string;
163
+ /**
164
+ * Schedule a callback to run after this response resolver completes.
165
+ * Handy for cleaning up the side effects introduced in the resolver.
166
+ *
167
+ * For responses with a `ReadableStream` body (including `sse()` handlers),
168
+ * the callback runs once the response stream settles: it is read to
169
+ * completion, errored, or canceled, or the request is aborted.
170
+ * @example
171
+ * sse('/', ({ client, finalize }) => {
172
+ * const interval = setInterval(() => client.send({ data: 'ping' }))
173
+ * finalize(() => clearInterval(interval))
174
+ * })
175
+ */
176
+ finalize: ResponseResolverFinalizeFunction;
177
+ } & ResolverExtraInfo;
178
+ type ResponseResolverFinalizeFunction = (callback: () => MaybePromise<void>) => void;
179
+ type ResponseResolver<ResolverExtraInfo extends Record<string, unknown> = Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType, ResponseBodyType extends DefaultBodyType = undefined> = (info: ResponseResolverInfo<ResolverExtraInfo, RequestBodyType>) => AsyncResponseResolverReturnType<ResponseBodyType>;
180
+ interface RequestHandlerArgs<HandlerInfo, HandlerOptions extends RequestHandlerOptions> {
181
+ info: HandlerInfo;
182
+ resolver: ResponseResolver<any>;
183
+ options?: HandlerOptions;
184
+ }
185
+ interface RequestHandlerOptions {
186
+ once?: boolean;
187
+ }
188
+ interface RequestHandlerExecutionResult<ParsedResult extends object | undefined> {
189
+ handler: RequestHandler;
190
+ parsedResult?: ParsedResult;
191
+ request: Request;
192
+ requestId: string;
193
+ response?: Response;
194
+ }
195
+ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultInfo = RequestHandlerDefaultInfo, ParsedResult extends Record<string, any> | undefined = any, ResolverExtras extends Record<string, unknown> = any, HandlerOptions extends RequestHandlerOptions = RequestHandlerOptions> extends Handler {
196
+ static cache: WeakMap<StrictRequest<DefaultBodyType>, StrictRequest<DefaultBodyType>>;
197
+ readonly kind = "request";
198
+ protected resolver: ResponseResolver<ResolverExtras, any, any>;
199
+ private resolverIterator?;
200
+ private resolverIteratorResult?;
201
+ private resolverIteratorCleanups?;
202
+ private options?;
203
+ private scheduledCleanups;
204
+ info: HandlerInfo & RequestHandlerInternalInfo;
205
+ /**
206
+ * Indicates whether this request handler has been used
207
+ * (its resolver has successfully executed).
208
+ */
209
+ isUsed: boolean;
210
+ constructor(args: RequestHandlerArgs<HandlerInfo, HandlerOptions>);
211
+ /**
212
+ * Reset the runtime state accumulated during response resolution,
213
+ * such as generator iterator progress. Called when this handler is
214
+ * removed from the active handlers list so re-adding it later starts
215
+ * from a clean state.
216
+ */
217
+ reset(): void;
218
+ /**
219
+ * Restore this handler so it can match requests again after being
220
+ * exhausted (e.g. via `{ once: true }`). Also clears any accumulated
221
+ * resolution state.
222
+ */
223
+ restore(): void;
224
+ /**
225
+ * Determine if the intercepted request should be mocked.
226
+ */
227
+ abstract predicate(args: {
228
+ request: Request;
229
+ parsedResult: ParsedResult;
230
+ resolutionContext?: ResponseResolutionContext;
231
+ }): boolean | Promise<boolean>;
232
+ /**
233
+ * Print out the successfully handled request.
234
+ */
235
+ abstract log(args: {
236
+ request: Request;
237
+ response: Response;
238
+ parsedResult: ParsedResult;
239
+ }): void;
240
+ /**
241
+ * Parse the intercepted request to extract additional information from it.
242
+ * Parsed result is then exposed to other methods of this request handler.
243
+ */
244
+ parse(_args: {
245
+ request: Request;
246
+ resolutionContext?: ResponseResolutionContext;
247
+ }): Promise<ParsedResult>;
248
+ /**
249
+ * Test if this handler matches the given request.
250
+ *
251
+ * This method is not used internally but is exposed
252
+ * as a convenience method for consumers writing custom
253
+ * handlers.
254
+ */
255
+ test(args: {
256
+ request: Request;
257
+ resolutionContext?: ResponseResolutionContext;
258
+ }): Promise<boolean>;
259
+ protected extendResolverArgs(_args: {
260
+ request: Request;
261
+ parsedResult: ParsedResult;
262
+ }): ResolverExtras;
263
+ private cloneRequestOrGetFromCache;
264
+ /**
265
+ * Execute this request handler and produce a mocked response
266
+ * using the given resolver function.
267
+ */
268
+ run(args: {
269
+ request: StrictRequest<any>;
270
+ requestId: string;
271
+ resolutionContext?: ResponseResolutionContext;
272
+ }): Promise<RequestHandlerExecutionResult<ParsedResult> | null>;
273
+ private wrapResolver;
274
+ private createExecutionResult;
275
+ private scheduleCleanup;
276
+ private exhaustCleanups;
277
+ /**
278
+ * Remove and return the cleanups scheduled for the given request
279
+ * (or the pending iterator cleanups for generator resolvers).
280
+ */
281
+ private takeScheduledCleanups;
282
+ private runScheduledCleanups;
283
+ /**
284
+ * Conclude the response resolution for the given request.
285
+ * Runs the scheduled cleanups immediately for responses without a
286
+ * `ReadableStream` body. For streamed responses, returns an observed
287
+ * copy of the response and defers the cleanups until its body settles
288
+ * (is read to completion, errored, or canceled) or the request is
289
+ * aborted, whichever comes first.
290
+ */
291
+ private complete;
292
+ }
293
+ //#endregion
294
+ export { Handler as _, RequestHandler as a, UnionToIntersection as b, RequestHandlerOptions as c, ResponseResolverInfo as d, ResponseResolverReturnType as f, ResponseResolutionContext as g, StrictRequest as h, JsonBodyType as i, ResponseResolver as l, HttpResponseInit as m, DefaultBodyType as n, RequestHandlerDefaultInfo as o, HttpResponse as p, DefaultRequestMultipartBody as r, RequestHandlerExecutionResult as s, AsyncResponseResolverReturnType as t, ResponseResolverFinalizeFunction as u, HandlerKind as v, MaybePromise as y };
295
+ //# sourceMappingURL=request-handler.d.ts.map