@mswjs/interceptors 0.41.4 → 0.41.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/lib/browser/{XMLHttpRequest-C2KXXdBy.cjs → XMLHttpRequest-DSAhl6_a.cjs} +9 -21
  2. package/lib/browser/XMLHttpRequest-DSAhl6_a.cjs.map +1 -0
  3. package/lib/browser/{XMLHttpRequest-Bbvn_AjX.mjs → XMLHttpRequest-DYyDAIJh.mjs} +9 -21
  4. package/lib/{node/XMLHttpRequest-BBbs-p9i.mjs.map → browser/XMLHttpRequest-DYyDAIJh.mjs.map} +1 -1
  5. package/lib/browser/{createRequestId-Cs4oXfa1.cjs → createRequestId-DOf8Ktjs.cjs} +1 -1
  6. package/lib/browser/{createRequestId-Cs4oXfa1.cjs.map → createRequestId-DOf8Ktjs.cjs.map} +1 -1
  7. package/lib/browser/{createRequestId-DQcIlohW.mjs → createRequestId-DYCsFHOi.mjs} +1 -1
  8. package/lib/browser/{createRequestId-DQcIlohW.mjs.map → createRequestId-DYCsFHOi.mjs.map} +1 -1
  9. package/lib/browser/{fetch-CJYWVliE.cjs → fetch-BMC2en2x.cjs} +10 -18
  10. package/lib/browser/fetch-BMC2en2x.cjs.map +1 -0
  11. package/lib/browser/{fetch-D4es-Apw.mjs → fetch-D5LGhx5i.mjs} +10 -18
  12. package/lib/browser/fetch-D5LGhx5i.mjs.map +1 -0
  13. package/lib/browser/{getRawRequest-DaxX6uMy.cjs → getRawRequest-B9kRTvjs.cjs} +1 -11
  14. package/lib/browser/getRawRequest-B9kRTvjs.cjs.map +1 -0
  15. package/lib/browser/{getRawRequest-Df640uw8.mjs → getRawRequest-BEw5hEOW.mjs} +2 -6
  16. package/lib/browser/getRawRequest-BEw5hEOW.mjs.map +1 -0
  17. package/lib/browser/{glossary-BdLS4k1H.d.cts → glossary-1lhZx6Aw.d.cts} +2 -3
  18. package/lib/browser/{glossary-DYwOrogs.d.mts → glossary-nkHWcwvY.d.mts} +2 -3
  19. package/lib/browser/{handleRequest--veikAod.cjs → handleRequest-BCtqvFSS.cjs} +3 -3
  20. package/lib/browser/{handleRequest--veikAod.cjs.map → handleRequest-BCtqvFSS.cjs.map} +1 -1
  21. package/lib/browser/{handleRequest-Dq1a55b4.mjs → handleRequest-DuUoGpfA.mjs} +3 -3
  22. package/lib/browser/{handleRequest-Dq1a55b4.mjs.map → handleRequest-DuUoGpfA.mjs.map} +1 -1
  23. package/lib/browser/hasConfigurableGlobal-B39W0thh.mjs +98 -0
  24. package/lib/browser/hasConfigurableGlobal-B39W0thh.mjs.map +1 -0
  25. package/lib/browser/hasConfigurableGlobal-B5o6PHq3.cjs +115 -0
  26. package/lib/browser/hasConfigurableGlobal-B5o6PHq3.cjs.map +1 -0
  27. package/lib/browser/index.cjs +2 -3
  28. package/lib/browser/index.d.cts +2 -2
  29. package/lib/browser/index.d.mts +2 -2
  30. package/lib/browser/index.mjs +3 -3
  31. package/lib/browser/interceptors/WebSocket/index.cjs +6 -10
  32. package/lib/browser/interceptors/WebSocket/index.cjs.map +1 -1
  33. package/lib/browser/interceptors/WebSocket/index.mjs +6 -10
  34. package/lib/browser/interceptors/WebSocket/index.mjs.map +1 -1
  35. package/lib/browser/interceptors/XMLHttpRequest/index.cjs +5 -4
  36. package/lib/browser/interceptors/XMLHttpRequest/index.d.cts +1 -1
  37. package/lib/browser/interceptors/XMLHttpRequest/index.d.mts +1 -1
  38. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +5 -4
  39. package/lib/browser/interceptors/fetch/index.cjs +5 -4
  40. package/lib/browser/interceptors/fetch/index.d.cts +1 -1
  41. package/lib/browser/interceptors/fetch/index.d.mts +1 -1
  42. package/lib/browser/interceptors/fetch/index.mjs +5 -4
  43. package/lib/browser/presets/browser.cjs +6 -5
  44. package/lib/browser/presets/browser.cjs.map +1 -1
  45. package/lib/browser/presets/browser.mjs +6 -5
  46. package/lib/browser/presets/browser.mjs.map +1 -1
  47. package/lib/node/{BatchInterceptor-7u9fqQIe.cjs → BatchInterceptor-AZr7q8p_.cjs} +2 -2
  48. package/lib/node/{BatchInterceptor-7u9fqQIe.cjs.map → BatchInterceptor-AZr7q8p_.cjs.map} +1 -1
  49. package/lib/node/{BatchInterceptor-BxgAXyLw.mjs → BatchInterceptor-B2YAn5m9.mjs} +2 -2
  50. package/lib/node/{BatchInterceptor-BxgAXyLw.mjs.map → BatchInterceptor-B2YAn5m9.mjs.map} +1 -1
  51. package/lib/node/{BatchInterceptor-D7mXzHcQ.d.mts → BatchInterceptor-KKF8Q47I.d.cts} +2 -2
  52. package/lib/node/{BatchInterceptor-D_YqR8qU.d.cts → BatchInterceptor-rSr-NH_H.d.mts} +2 -2
  53. package/lib/node/{ClientRequest-Cl3Ky7Tw.mjs → ClientRequest-5WjHvs9Y.mjs} +5 -5
  54. package/lib/node/{ClientRequest-Cl3Ky7Tw.mjs.map → ClientRequest-5WjHvs9Y.mjs.map} +1 -1
  55. package/lib/node/{ClientRequest-CMSXChAM.cjs → ClientRequest-BgwQG-9G.cjs} +5 -5
  56. package/lib/node/{ClientRequest-CMSXChAM.cjs.map → ClientRequest-BgwQG-9G.cjs.map} +1 -1
  57. package/lib/node/{Interceptor-DJ2akVWI.d.cts → Interceptor-BsZ21ue0.d.cts} +2 -3
  58. package/lib/node/{Interceptor-DEazpLJd.d.mts → Interceptor-soD-WpQO.d.mts} +2 -3
  59. package/lib/node/RemoteHttpInterceptor.cjs +9 -8
  60. package/lib/node/RemoteHttpInterceptor.cjs.map +1 -1
  61. package/lib/node/RemoteHttpInterceptor.d.cts +3 -3
  62. package/lib/node/RemoteHttpInterceptor.d.mts +3 -3
  63. package/lib/node/RemoteHttpInterceptor.mjs +9 -8
  64. package/lib/node/RemoteHttpInterceptor.mjs.map +1 -1
  65. package/lib/node/{XMLHttpRequest-Dj3xJgke.cjs → XMLHttpRequest-B7sloBex.cjs} +10 -23
  66. package/lib/node/XMLHttpRequest-B7sloBex.cjs.map +1 -0
  67. package/lib/node/{XMLHttpRequest-BBbs-p9i.mjs → XMLHttpRequest-DmsdUGmj.mjs} +10 -23
  68. package/lib/{browser/XMLHttpRequest-Bbvn_AjX.mjs.map → node/XMLHttpRequest-DmsdUGmj.mjs.map} +1 -1
  69. package/lib/node/{bufferUtils-_8XfKIfX.mjs → bufferUtils-DxPxwff_.mjs} +1 -1
  70. package/lib/node/{bufferUtils-_8XfKIfX.mjs.map → bufferUtils-DxPxwff_.mjs.map} +1 -1
  71. package/lib/node/{bufferUtils-DiCTqG-7.cjs → bufferUtils-S5_-2eN4.cjs} +1 -1
  72. package/lib/node/{bufferUtils-DiCTqG-7.cjs.map → bufferUtils-S5_-2eN4.cjs.map} +1 -1
  73. package/lib/node/{fetch-DmiwAmpu.mjs → fetch-DDAGTtZi.mjs} +10 -19
  74. package/lib/node/fetch-DDAGTtZi.mjs.map +1 -0
  75. package/lib/node/{fetch-BoCFyaYx.cjs → fetch-uc7pNtPg.cjs} +10 -19
  76. package/lib/node/fetch-uc7pNtPg.cjs.map +1 -0
  77. package/lib/node/{fetchUtils-BTrdMHGp.mjs → fetchUtils-BJxD7wvl.mjs} +1 -1
  78. package/lib/node/{fetchUtils-BTrdMHGp.mjs.map → fetchUtils-BJxD7wvl.mjs.map} +1 -1
  79. package/lib/node/{fetchUtils-DE_q7tpr.cjs → fetchUtils-Dw6kQghF.cjs} +1 -1
  80. package/lib/node/{fetchUtils-DE_q7tpr.cjs.map → fetchUtils-Dw6kQghF.cjs.map} +1 -1
  81. package/lib/node/{getRawRequest-BavnMWh_.cjs → getRawRequest-B6znU6il.cjs} +1 -1
  82. package/lib/node/{getRawRequest-BavnMWh_.cjs.map → getRawRequest-B6znU6il.cjs.map} +1 -1
  83. package/lib/node/{getRawRequest-DnwmXyOW.mjs → getRawRequest-C2-1urzA.mjs} +1 -1
  84. package/lib/node/{getRawRequest-DnwmXyOW.mjs.map → getRawRequest-C2-1urzA.mjs.map} +1 -1
  85. package/lib/node/{handleRequest-CDabRyt1.mjs → handleRequest-DGfUg9bm.mjs} +2 -2
  86. package/lib/node/{handleRequest-CDabRyt1.mjs.map → handleRequest-DGfUg9bm.mjs.map} +1 -1
  87. package/lib/node/{handleRequest-pLIe3KKo.cjs → handleRequest-Dzg1d3e5.cjs} +2 -2
  88. package/lib/node/{handleRequest-pLIe3KKo.cjs.map → handleRequest-Dzg1d3e5.cjs.map} +1 -1
  89. package/lib/node/hasConfigurableGlobal-Befl_QJD.cjs +97 -0
  90. package/lib/node/hasConfigurableGlobal-Befl_QJD.cjs.map +1 -0
  91. package/lib/node/hasConfigurableGlobal-jN_-v3gp.mjs +85 -0
  92. package/lib/node/hasConfigurableGlobal-jN_-v3gp.mjs.map +1 -0
  93. package/lib/node/{index-BMbJ8FXL.d.cts → index-BJ5E5aW-.d.cts} +2 -2
  94. package/lib/node/{index-C0YAQ36w.d.mts → index-DfoF45ih.d.mts} +2 -2
  95. package/lib/node/index.cjs +4 -6
  96. package/lib/node/index.cjs.map +1 -1
  97. package/lib/node/index.d.cts +3 -3
  98. package/lib/node/index.d.mts +3 -3
  99. package/lib/node/index.mjs +5 -6
  100. package/lib/node/index.mjs.map +1 -1
  101. package/lib/node/interceptors/ClientRequest/index.cjs +4 -4
  102. package/lib/node/interceptors/ClientRequest/index.d.cts +1 -1
  103. package/lib/node/interceptors/ClientRequest/index.d.mts +2 -2
  104. package/lib/node/interceptors/ClientRequest/index.mjs +4 -4
  105. package/lib/node/interceptors/XMLHttpRequest/index.cjs +5 -4
  106. package/lib/node/interceptors/XMLHttpRequest/index.d.cts +1 -1
  107. package/lib/node/interceptors/XMLHttpRequest/index.d.mts +1 -1
  108. package/lib/node/interceptors/XMLHttpRequest/index.mjs +5 -4
  109. package/lib/node/interceptors/fetch/index.cjs +4 -3
  110. package/lib/node/interceptors/fetch/index.d.cts +1 -1
  111. package/lib/node/interceptors/fetch/index.d.mts +1 -1
  112. package/lib/node/interceptors/fetch/index.mjs +4 -3
  113. package/lib/node/{node-dKdAf3tC.cjs → node-DIKcnzhK.cjs} +2 -2
  114. package/lib/node/{node-dKdAf3tC.cjs.map → node-DIKcnzhK.cjs.map} +1 -1
  115. package/lib/node/{node-DwCc6iuP.mjs → node-lsdNwZEW.mjs} +2 -2
  116. package/lib/node/{node-DwCc6iuP.mjs.map → node-lsdNwZEW.mjs.map} +1 -1
  117. package/lib/node/presets/node.cjs +8 -7
  118. package/lib/node/presets/node.cjs.map +1 -1
  119. package/lib/node/presets/node.d.cts +1 -1
  120. package/lib/node/presets/node.d.mts +2 -2
  121. package/lib/node/presets/node.mjs +8 -7
  122. package/lib/node/presets/node.mjs.map +1 -1
  123. package/lib/node/utils/node/index.cjs +1 -1
  124. package/lib/node/utils/node/index.mjs +1 -1
  125. package/package.json +1 -1
  126. package/src/glossary.ts +3 -5
  127. package/src/interceptors/WebSocket/index.ts +8 -15
  128. package/src/interceptors/XMLHttpRequest/index.ts +12 -32
  129. package/src/interceptors/fetch/index.ts +8 -24
  130. package/src/utils/globalUtils.test.ts +144 -0
  131. package/src/utils/globalsRegistry.ts +107 -0
  132. package/src/utils/hasConfigurableGlobal.test.ts +11 -0
  133. package/src/utils/hasConfigurableGlobal.ts +9 -3
  134. package/lib/browser/XMLHttpRequest-C2KXXdBy.cjs.map +0 -1
  135. package/lib/browser/fetch-CJYWVliE.cjs.map +0 -1
  136. package/lib/browser/fetch-D4es-Apw.mjs.map +0 -1
  137. package/lib/browser/getRawRequest-DaxX6uMy.cjs.map +0 -1
  138. package/lib/browser/getRawRequest-Df640uw8.mjs.map +0 -1
  139. package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs +0 -45
  140. package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs.map +0 -1
  141. package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs +0 -33
  142. package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs.map +0 -1
  143. package/lib/node/XMLHttpRequest-Dj3xJgke.cjs.map +0 -1
  144. package/lib/node/fetch-BoCFyaYx.cjs.map +0 -1
  145. package/lib/node/fetch-DmiwAmpu.mjs.map +0 -1
  146. package/lib/node/glossary-BLKRyLBd.cjs +0 -12
  147. package/lib/node/glossary-BLKRyLBd.cjs.map +0 -1
  148. package/lib/node/glossary-glQBRnVD.mjs +0 -6
  149. package/lib/node/glossary-glQBRnVD.mjs.map +0 -1
  150. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs +0 -26
  151. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs.map +0 -1
  152. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs +0 -20
  153. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"handleRequest-CDabRyt1.mjs","names":[],"sources":["../../src/utils/isPropertyAccessible.ts","../../src/utils/emitAsync.ts","../../src/utils/isObject.ts","../../src/utils/responseUtils.ts","../../src/utils/isNodeLikeError.ts","../../src/utils/handleRequest.ts"],"sourcesContent":["/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { Emitter, EventMap } from 'strict-event-emitter'\n\n/**\n * Emits an event on the given emitter but executes\n * the listeners sequentially. This accounts for asynchronous\n * listeners (e.g. those having \"sleep\" and handling the request).\n */\nexport async function emitAsync<\n Events extends EventMap,\n EventName extends keyof Events\n>(\n emitter: Emitter<Events>,\n eventName: EventName,\n ...data: Events[EventName]\n): Promise<void> {\n const listeners = emitter.listeners(eventName)\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n await listener.apply(emitter, data)\n }\n}\n","/**\n * Determines if a given value is an instance of object.\n */\nexport function isObject<T>(value: any, loose = false): value is T {\n return loose\n ? Object.prototype.toString.call(value).startsWith('[object ')\n : Object.prototype.toString.call(value) === '[object Object]'\n}\n","import { isObject } from './isObject'\nimport { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: unknown): response is ResponseError {\n return (\n response != null &&\n response instanceof Response &&\n isPropertyAccessible(response, 'type') &&\n response.type === 'error'\n )\n}\n\n/**\n * Check if the given value is a `Response` or a Response-like object.\n * This is different from `value instanceof Response` because it supports\n * custom `Response` constructors, like the one when using Undici directly.\n */\nexport function isResponseLike(value: unknown): value is Response {\n return (\n isObject<Record<string, any>>(value, true) &&\n isPropertyAccessible(value, 'status') &&\n isPropertyAccessible(value, 'statusText') &&\n isPropertyAccessible(value, 'bodyUsed')\n )\n}\n","export function isNodeLikeError(\n error: unknown\n): error is NodeJS.ErrnoException {\n if (error == null) {\n return false\n }\n\n if (!(error instanceof Error)) {\n return false\n }\n\n return 'code' in error && 'errno' in error\n}\n","import type { Emitter } from 'strict-event-emitter'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { until } from '@open-draft/until'\nimport type { HttpRequestEventMap } from '../glossary'\nimport { emitAsync } from './emitAsync'\nimport { RequestController } from '../RequestController'\nimport {\n createServerErrorResponse,\n isResponseError,\n isResponseLike,\n} from './responseUtils'\nimport { InterceptorError } from '../InterceptorError'\nimport { isNodeLikeError } from './isNodeLikeError'\nimport { isObject } from './isObject'\n\ninterface HandleRequestOptions {\n requestId: string\n request: Request\n emitter: Emitter<HttpRequestEventMap>\n controller: RequestController\n}\n\nexport async function handleRequest(\n options: HandleRequestOptions\n): Promise<void> {\n const handleResponse = async (\n response: Response | Error | Record<string, any>\n ) => {\n if (response instanceof Error) {\n await options.controller.errorWith(response)\n return true\n }\n\n // Handle \"Response.error()\" instances.\n if (isResponseError(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n /**\n * Handle normal responses or response-like objects.\n * @note This must come before the arbitrary object check\n * since Response instances are, in fact, objects.\n */\n if (isResponseLike(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n // Handle arbitrary objects provided to `.errorWith(reason)`.\n if (isObject(response)) {\n await options.controller.errorWith(response)\n return true\n }\n\n return false\n }\n\n const handleResponseError = async (error: unknown): Promise<boolean> => {\n // Forward the special interceptor error instances\n // to the developer. These must not be handled in any way.\n if (error instanceof InterceptorError) {\n throw result.error\n }\n\n // Support mocking Node.js-like errors.\n if (isNodeLikeError(error)) {\n await options.controller.errorWith(error)\n return true\n }\n\n // Handle thrown responses.\n if (error instanceof Response) {\n return await handleResponse(error)\n }\n\n return false\n }\n\n // Add the last \"request\" listener to check if the request\n // has been handled in any way. If it hasn't, resolve the\n // response promise with undefined.\n // options.emitter.once('request', async ({ requestId: pendingRequestId }) => {\n // if (\n // pendingRequestId === options.requestId &&\n // options.controller.readyState === RequestController.PENDING\n // ) {\n // await options.controller.passthrough()\n // }\n // })\n\n const requestAbortPromise = new DeferredPromise<void, unknown>()\n\n /**\n * @note `signal` is not always defined in React Native.\n */\n if (options.request.signal) {\n if (options.request.signal.aborted) {\n await options.controller.errorWith(options.request.signal.reason)\n return\n }\n\n options.request.signal.addEventListener(\n 'abort',\n () => {\n requestAbortPromise.reject(options.request.signal.reason)\n },\n { once: true }\n )\n }\n\n const result = await until(async () => {\n // Emit the \"request\" event and wait until all the listeners\n // for that event are finished (e.g. async listeners awaited).\n // By the end of this promise, the developer cannot affect the\n // request anymore.\n const requestListenersPromise = emitAsync(options.emitter, 'request', {\n requestId: options.requestId,\n request: options.request,\n controller: options.controller,\n })\n\n await Promise.race([\n // Short-circuit the request handling promise if the request gets aborted.\n requestAbortPromise,\n requestListenersPromise,\n options.controller.handled,\n ])\n })\n\n // Handle the request being aborted while waiting for the request listeners.\n if (requestAbortPromise.state === 'rejected') {\n await options.controller.errorWith(requestAbortPromise.rejectionReason)\n return\n }\n\n if (result.error) {\n // Handle the error during the request listener execution.\n // These can be thrown responses or request errors.\n if (await handleResponseError(result.error)) {\n return\n }\n\n // If the developer has added \"unhandledException\" listeners,\n // allow them to handle the error. They can translate it to a\n // mocked response, network error, or forward it as-is.\n if (options.emitter.listenerCount('unhandledException') > 0) {\n // Create a new request controller just for the unhandled exception case.\n // This is needed because the original controller might have been already\n // interacted with (e.g. \"respondWith\" or \"errorWith\" called on it).\n const unhandledExceptionController = new RequestController(\n options.request,\n {\n /**\n * @note Intentionally empty passthrough handle.\n * This controller is created within another controller and we only need\n * to know if `unhandledException` listeners handled the request.\n */\n passthrough() {},\n async respondWith(response) {\n await handleResponse(response)\n },\n async errorWith(reason) {\n /**\n * @note Handle the result of the unhandled controller\n * in the same way as the original request controller.\n * The exception here is that thrown errors within the\n * \"unhandledException\" event do NOT result in another\n * emit of the same event. They are forwarded as-is.\n */\n await options.controller.errorWith(reason)\n },\n }\n )\n\n await emitAsync(options.emitter, 'unhandledException', {\n error: result.error,\n request: options.request,\n requestId: options.requestId,\n controller: unhandledExceptionController,\n })\n\n // If all the \"unhandledException\" listeners have finished\n // but have not handled the request in any way, passthrough.\n if (\n unhandledExceptionController.readyState !== RequestController.PENDING\n ) {\n return\n }\n }\n\n // Otherwise, coerce unhandled exceptions to a 500 Internal Server Error response.\n await options.controller.respondWith(\n createServerErrorResponse(result.error)\n )\n return\n }\n\n // If the request hasn't been handled by this point, passthrough.\n if (options.controller.readyState === RequestController.PENDING) {\n return await options.controller.passthrough()\n }\n\n return options.controller.handled\n}\n"],"mappings":";;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IACd,MAAM,YAAY,UAAU;AAC1B,WAAM,eAAe,SAAS;;IAEhC,MAAM,UAAU,QAAQ;;;;;;;;AAQtB,WAAM,QAAQ,WAAW,UAAU,OAAO;;IAE7C,CACF;AAED,SAAM,UAAU,QAAQ,SAAS,sBAAsB;IACrD,OAAO,OAAO;IACd,SAAS,QAAQ;IACjB,WAAW,QAAQ;IACnB,YAAY;IACb,CAAC;AAIF,OACE,6BAA6B,eAAe,kBAAkB,QAE9D;;AAKJ,QAAM,QAAQ,WAAW,YACvB,0BAA0B,OAAO,MAAM,CACxC;AACD;;AAIF,KAAI,QAAQ,WAAW,eAAe,kBAAkB,QACtD,QAAO,MAAM,QAAQ,WAAW,aAAa;AAG/C,QAAO,QAAQ,WAAW"}
1
+ {"version":3,"file":"handleRequest-DGfUg9bm.mjs","names":[],"sources":["../../src/utils/isPropertyAccessible.ts","../../src/utils/emitAsync.ts","../../src/utils/isObject.ts","../../src/utils/responseUtils.ts","../../src/utils/isNodeLikeError.ts","../../src/utils/handleRequest.ts"],"sourcesContent":["/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { Emitter, EventMap } from 'strict-event-emitter'\n\n/**\n * Emits an event on the given emitter but executes\n * the listeners sequentially. This accounts for asynchronous\n * listeners (e.g. those having \"sleep\" and handling the request).\n */\nexport async function emitAsync<\n Events extends EventMap,\n EventName extends keyof Events\n>(\n emitter: Emitter<Events>,\n eventName: EventName,\n ...data: Events[EventName]\n): Promise<void> {\n const listeners = emitter.listeners(eventName)\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n await listener.apply(emitter, data)\n }\n}\n","/**\n * Determines if a given value is an instance of object.\n */\nexport function isObject<T>(value: any, loose = false): value is T {\n return loose\n ? Object.prototype.toString.call(value).startsWith('[object ')\n : Object.prototype.toString.call(value) === '[object Object]'\n}\n","import { isObject } from './isObject'\nimport { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: unknown): response is ResponseError {\n return (\n response != null &&\n response instanceof Response &&\n isPropertyAccessible(response, 'type') &&\n response.type === 'error'\n )\n}\n\n/**\n * Check if the given value is a `Response` or a Response-like object.\n * This is different from `value instanceof Response` because it supports\n * custom `Response` constructors, like the one when using Undici directly.\n */\nexport function isResponseLike(value: unknown): value is Response {\n return (\n isObject<Record<string, any>>(value, true) &&\n isPropertyAccessible(value, 'status') &&\n isPropertyAccessible(value, 'statusText') &&\n isPropertyAccessible(value, 'bodyUsed')\n )\n}\n","export function isNodeLikeError(\n error: unknown\n): error is NodeJS.ErrnoException {\n if (error == null) {\n return false\n }\n\n if (!(error instanceof Error)) {\n return false\n }\n\n return 'code' in error && 'errno' in error\n}\n","import type { Emitter } from 'strict-event-emitter'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { until } from '@open-draft/until'\nimport type { HttpRequestEventMap } from '../glossary'\nimport { emitAsync } from './emitAsync'\nimport { RequestController } from '../RequestController'\nimport {\n createServerErrorResponse,\n isResponseError,\n isResponseLike,\n} from './responseUtils'\nimport { InterceptorError } from '../InterceptorError'\nimport { isNodeLikeError } from './isNodeLikeError'\nimport { isObject } from './isObject'\n\ninterface HandleRequestOptions {\n requestId: string\n request: Request\n emitter: Emitter<HttpRequestEventMap>\n controller: RequestController\n}\n\nexport async function handleRequest(\n options: HandleRequestOptions\n): Promise<void> {\n const handleResponse = async (\n response: Response | Error | Record<string, any>\n ) => {\n if (response instanceof Error) {\n await options.controller.errorWith(response)\n return true\n }\n\n // Handle \"Response.error()\" instances.\n if (isResponseError(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n /**\n * Handle normal responses or response-like objects.\n * @note This must come before the arbitrary object check\n * since Response instances are, in fact, objects.\n */\n if (isResponseLike(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n // Handle arbitrary objects provided to `.errorWith(reason)`.\n if (isObject(response)) {\n await options.controller.errorWith(response)\n return true\n }\n\n return false\n }\n\n const handleResponseError = async (error: unknown): Promise<boolean> => {\n // Forward the special interceptor error instances\n // to the developer. These must not be handled in any way.\n if (error instanceof InterceptorError) {\n throw result.error\n }\n\n // Support mocking Node.js-like errors.\n if (isNodeLikeError(error)) {\n await options.controller.errorWith(error)\n return true\n }\n\n // Handle thrown responses.\n if (error instanceof Response) {\n return await handleResponse(error)\n }\n\n return false\n }\n\n // Add the last \"request\" listener to check if the request\n // has been handled in any way. If it hasn't, resolve the\n // response promise with undefined.\n // options.emitter.once('request', async ({ requestId: pendingRequestId }) => {\n // if (\n // pendingRequestId === options.requestId &&\n // options.controller.readyState === RequestController.PENDING\n // ) {\n // await options.controller.passthrough()\n // }\n // })\n\n const requestAbortPromise = new DeferredPromise<void, unknown>()\n\n /**\n * @note `signal` is not always defined in React Native.\n */\n if (options.request.signal) {\n if (options.request.signal.aborted) {\n await options.controller.errorWith(options.request.signal.reason)\n return\n }\n\n options.request.signal.addEventListener(\n 'abort',\n () => {\n requestAbortPromise.reject(options.request.signal.reason)\n },\n { once: true }\n )\n }\n\n const result = await until(async () => {\n // Emit the \"request\" event and wait until all the listeners\n // for that event are finished (e.g. async listeners awaited).\n // By the end of this promise, the developer cannot affect the\n // request anymore.\n const requestListenersPromise = emitAsync(options.emitter, 'request', {\n requestId: options.requestId,\n request: options.request,\n controller: options.controller,\n })\n\n await Promise.race([\n // Short-circuit the request handling promise if the request gets aborted.\n requestAbortPromise,\n requestListenersPromise,\n options.controller.handled,\n ])\n })\n\n // Handle the request being aborted while waiting for the request listeners.\n if (requestAbortPromise.state === 'rejected') {\n await options.controller.errorWith(requestAbortPromise.rejectionReason)\n return\n }\n\n if (result.error) {\n // Handle the error during the request listener execution.\n // These can be thrown responses or request errors.\n if (await handleResponseError(result.error)) {\n return\n }\n\n // If the developer has added \"unhandledException\" listeners,\n // allow them to handle the error. They can translate it to a\n // mocked response, network error, or forward it as-is.\n if (options.emitter.listenerCount('unhandledException') > 0) {\n // Create a new request controller just for the unhandled exception case.\n // This is needed because the original controller might have been already\n // interacted with (e.g. \"respondWith\" or \"errorWith\" called on it).\n const unhandledExceptionController = new RequestController(\n options.request,\n {\n /**\n * @note Intentionally empty passthrough handle.\n * This controller is created within another controller and we only need\n * to know if `unhandledException` listeners handled the request.\n */\n passthrough() {},\n async respondWith(response) {\n await handleResponse(response)\n },\n async errorWith(reason) {\n /**\n * @note Handle the result of the unhandled controller\n * in the same way as the original request controller.\n * The exception here is that thrown errors within the\n * \"unhandledException\" event do NOT result in another\n * emit of the same event. They are forwarded as-is.\n */\n await options.controller.errorWith(reason)\n },\n }\n )\n\n await emitAsync(options.emitter, 'unhandledException', {\n error: result.error,\n request: options.request,\n requestId: options.requestId,\n controller: unhandledExceptionController,\n })\n\n // If all the \"unhandledException\" listeners have finished\n // but have not handled the request in any way, passthrough.\n if (\n unhandledExceptionController.readyState !== RequestController.PENDING\n ) {\n return\n }\n }\n\n // Otherwise, coerce unhandled exceptions to a 500 Internal Server Error response.\n await options.controller.respondWith(\n createServerErrorResponse(result.error)\n )\n return\n }\n\n // If the request hasn't been handled by this point, passthrough.\n if (options.controller.readyState === RequestController.PENDING) {\n return await options.controller.passthrough()\n }\n\n return options.controller.handled\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,SAAgB,qBACd,KACA,KACA;AACA,KAAI;AACF,MAAI;AACJ,SAAO;SACD;AACN,SAAO;;;;;;;;;;;ACTX,eAAsB,UAIpB,SACA,WACA,GAAG,MACY;CACf,MAAM,YAAY,QAAQ,UAAU,UAAU;AAE9C,KAAI,UAAU,WAAW,EACvB;AAGF,MAAK,MAAM,YAAY,UACrB,OAAM,SAAS,MAAM,SAAS,KAAK;;;;;;;;ACnBvC,SAAgB,SAAY,OAAY,QAAQ,OAAmB;AACjE,QAAO,QACH,OAAO,UAAU,SAAS,KAAK,MAAM,CAAC,WAAW,WAAW,GAC5D,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;;;;;ACAhD,SAAgB,0BAA0B,MAAyB;AACjE,QAAO,IAAI,SACT,KAAK,UACH,gBAAgB,QACZ;EACE,MAAM,KAAK;EACX,SAAS,KAAK;EACd,OAAO,KAAK;EACb,GACD,KACL,EACD;EACE,QAAQ;EACR,YAAY;EACZ,SAAS,EACP,gBAAgB,oBACjB;EACF,CACF;;;;;;;;;;AAaH,SAAgB,gBAAgB,UAA8C;AAC5E,QACE,YAAY,QACZ,oBAAoB,YACpB,qBAAqB,UAAU,OAAO,IACtC,SAAS,SAAS;;;;;;;AAStB,SAAgB,eAAe,OAAmC;AAChE,QACE,SAA8B,OAAO,KAAK,IAC1C,qBAAqB,OAAO,SAAS,IACrC,qBAAqB,OAAO,aAAa,IACzC,qBAAqB,OAAO,WAAW;;;;;ACxD3C,SAAgB,gBACd,OACgC;AAChC,KAAI,SAAS,KACX,QAAO;AAGT,KAAI,EAAE,iBAAiB,OACrB,QAAO;AAGT,QAAO,UAAU,SAAS,WAAW;;;;;ACWvC,eAAsB,cACpB,SACe;CACf,MAAM,iBAAiB,OACrB,aACG;AACH,MAAI,oBAAoB,OAAO;AAC7B,SAAM,QAAQ,WAAW,UAAU,SAAS;AAC5C,UAA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3D,MAAM,+BAA+B,IAAI,kBACvC,QAAQ,SACR;IAME,cAAc;IACd,MAAM,YAAY,UAAU;AAC1B,WAAM,eAAe,SAAS;;IAEhC,MAAM,UAAU,QAAQ;;;;;;;;AAQtB,WAAM,QAAQ,WAAW,UAAU,OAAO;;IAE7C,CACF;AAED,SAAM,UAAU,QAAQ,SAAS,sBAAsB;IACrD,OAAO,OAAO;IACd,SAAS,QAAQ;IACjB,WAAW,QAAQ;IACnB,YAAY;IACb,CAAC;AAIF,OACE,6BAA6B,eAAe,kBAAkB,QAE9D;;AAKJ,QAAM,QAAQ,WAAW,YACvB,0BAA0B,OAAO,MAAM,CACxC;AACD;;AAIF,KAAI,QAAQ,WAAW,eAAe,kBAAkB,QACtD,QAAO,MAAM,QAAQ,WAAW,aAAa;AAG/C,QAAO,QAAQ,WAAW"}
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_fetchUtils = require('./fetchUtils-DE_q7tpr.cjs');
2
+ const require_fetchUtils = require('./fetchUtils-Dw6kQghF.cjs');
3
3
  let _open_draft_deferred_promise = require("@open-draft/deferred-promise");
4
4
  let _open_draft_until = require("@open-draft/until");
5
5
 
@@ -217,4 +217,4 @@ Object.defineProperty(exports, 'isResponseError', {
217
217
  return isResponseError;
218
218
  }
219
219
  });
220
- //# sourceMappingURL=handleRequest-pLIe3KKo.cjs.map
220
+ //# sourceMappingURL=handleRequest-Dzg1d3e5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleRequest-pLIe3KKo.cjs","names":["InterceptorError","DeferredPromise","RequestController"],"sources":["../../src/utils/isPropertyAccessible.ts","../../src/utils/emitAsync.ts","../../src/utils/isObject.ts","../../src/utils/responseUtils.ts","../../src/utils/isNodeLikeError.ts","../../src/utils/handleRequest.ts"],"sourcesContent":["/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { Emitter, EventMap } from 'strict-event-emitter'\n\n/**\n * Emits an event on the given emitter but executes\n * the listeners sequentially. This accounts for asynchronous\n * listeners (e.g. those having \"sleep\" and handling the request).\n */\nexport async function emitAsync<\n Events extends EventMap,\n EventName extends keyof Events\n>(\n emitter: Emitter<Events>,\n eventName: EventName,\n ...data: Events[EventName]\n): Promise<void> {\n const listeners = emitter.listeners(eventName)\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n await listener.apply(emitter, data)\n }\n}\n","/**\n * Determines if a given value is an instance of object.\n */\nexport function isObject<T>(value: any, loose = false): value is T {\n return loose\n ? Object.prototype.toString.call(value).startsWith('[object ')\n : Object.prototype.toString.call(value) === '[object Object]'\n}\n","import { isObject } from './isObject'\nimport { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: unknown): response is ResponseError {\n return (\n response != null &&\n response instanceof Response &&\n isPropertyAccessible(response, 'type') &&\n response.type === 'error'\n )\n}\n\n/**\n * Check if the given value is a `Response` or a Response-like object.\n * This is different from `value instanceof Response` because it supports\n * custom `Response` constructors, like the one when using Undici directly.\n */\nexport function isResponseLike(value: unknown): value is Response {\n return (\n isObject<Record<string, any>>(value, true) &&\n isPropertyAccessible(value, 'status') &&\n isPropertyAccessible(value, 'statusText') &&\n isPropertyAccessible(value, 'bodyUsed')\n )\n}\n","export function isNodeLikeError(\n error: unknown\n): error is NodeJS.ErrnoException {\n if (error == null) {\n return false\n }\n\n if (!(error instanceof Error)) {\n return false\n }\n\n return 'code' in error && 'errno' in error\n}\n","import type { Emitter } from 'strict-event-emitter'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { until } from '@open-draft/until'\nimport type { HttpRequestEventMap } from '../glossary'\nimport { emitAsync } from './emitAsync'\nimport { RequestController } from '../RequestController'\nimport {\n createServerErrorResponse,\n isResponseError,\n isResponseLike,\n} from './responseUtils'\nimport { InterceptorError } from '../InterceptorError'\nimport { isNodeLikeError } from './isNodeLikeError'\nimport { isObject } from './isObject'\n\ninterface HandleRequestOptions {\n requestId: string\n request: Request\n emitter: Emitter<HttpRequestEventMap>\n controller: RequestController\n}\n\nexport async function handleRequest(\n options: HandleRequestOptions\n): Promise<void> {\n const handleResponse = async (\n response: Response | Error | Record<string, any>\n ) => {\n if (response instanceof Error) {\n await options.controller.errorWith(response)\n return true\n }\n\n // Handle \"Response.error()\" instances.\n if (isResponseError(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n /**\n * Handle normal responses or response-like objects.\n * @note This must come before the arbitrary object check\n * since Response instances are, in fact, objects.\n */\n if (isResponseLike(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n // Handle arbitrary objects provided to `.errorWith(reason)`.\n if (isObject(response)) {\n await options.controller.errorWith(response)\n return true\n }\n\n return false\n }\n\n const handleResponseError = async (error: unknown): Promise<boolean> => {\n // Forward the special interceptor error instances\n // to the developer. These must not be handled in any way.\n if (error instanceof InterceptorError) {\n throw result.error\n }\n\n // Support mocking Node.js-like errors.\n if (isNodeLikeError(error)) {\n await options.controller.errorWith(error)\n return true\n }\n\n // Handle thrown responses.\n if (error instanceof Response) {\n return await handleResponse(error)\n }\n\n return false\n }\n\n // Add the last \"request\" listener to check if the request\n // has been handled in any way. If it hasn't, resolve the\n // response promise with undefined.\n // options.emitter.once('request', async ({ requestId: pendingRequestId }) => {\n // if (\n // pendingRequestId === options.requestId &&\n // options.controller.readyState === RequestController.PENDING\n // ) {\n // await options.controller.passthrough()\n // }\n // })\n\n const requestAbortPromise = new DeferredPromise<void, unknown>()\n\n /**\n * @note `signal` is not always defined in React Native.\n */\n if (options.request.signal) {\n if (options.request.signal.aborted) {\n await options.controller.errorWith(options.request.signal.reason)\n return\n }\n\n options.request.signal.addEventListener(\n 'abort',\n () => {\n requestAbortPromise.reject(options.request.signal.reason)\n },\n { once: true }\n )\n }\n\n const result = await until(async () => {\n // Emit the \"request\" event and wait until all the listeners\n // for that event are finished (e.g. async listeners awaited).\n // By the end of this promise, the developer cannot affect the\n // request anymore.\n const requestListenersPromise = emitAsync(options.emitter, 'request', {\n requestId: options.requestId,\n request: options.request,\n controller: options.controller,\n })\n\n await Promise.race([\n // Short-circuit the request handling promise if the request gets aborted.\n requestAbortPromise,\n requestListenersPromise,\n options.controller.handled,\n ])\n })\n\n // Handle the request being aborted while waiting for the request listeners.\n if (requestAbortPromise.state === 'rejected') {\n await options.controller.errorWith(requestAbortPromise.rejectionReason)\n return\n }\n\n if (result.error) {\n // Handle the error during the request listener execution.\n // These can be thrown responses or request errors.\n if (await handleResponseError(result.error)) {\n return\n }\n\n // If the developer has added \"unhandledException\" listeners,\n // allow them to handle the error. They can translate it to a\n // mocked response, network error, or forward it as-is.\n if (options.emitter.listenerCount('unhandledException') > 0) {\n // Create a new request controller just for the unhandled exception case.\n // This is needed because the original controller might have been already\n // interacted with (e.g. \"respondWith\" or \"errorWith\" called on it).\n const unhandledExceptionController = new RequestController(\n options.request,\n {\n /**\n * @note Intentionally empty passthrough handle.\n * This controller is created within another controller and we only need\n * to know if `unhandledException` listeners handled the request.\n */\n passthrough() {},\n async respondWith(response) {\n await handleResponse(response)\n },\n async errorWith(reason) {\n /**\n * @note Handle the result of the unhandled controller\n * in the same way as the original request controller.\n * The exception here is that thrown errors within the\n * \"unhandledException\" event do NOT result in another\n * emit of the same event. They are forwarded as-is.\n */\n await options.controller.errorWith(reason)\n },\n }\n )\n\n await emitAsync(options.emitter, 'unhandledException', {\n error: result.error,\n request: options.request,\n requestId: options.requestId,\n controller: unhandledExceptionController,\n })\n\n // If all the \"unhandledException\" listeners have finished\n // but have not handled the request in any way, passthrough.\n if (\n unhandledExceptionController.readyState !== RequestController.PENDING\n ) {\n return\n }\n }\n\n // Otherwise, coerce unhandled exceptions to a 500 Internal Server Error response.\n await options.controller.respondWith(\n createServerErrorResponse(result.error)\n )\n return\n }\n\n // If the request hasn't been handled by this point, passthrough.\n if (options.controller.readyState === RequestController.PENDING) {\n return await options.controller.passthrough()\n }\n\n return options.controller.handled\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,SAAgB,qBACd,KACA,KACA;AACA,KAAI;AACF,MAAI;AACJ,SAAO;SACD;AACN,SAAO;;;;;;;;;;;ACTX,eAAsB,UAIpB,SACA,WACA,GAAG,MACY;CACf,MAAM,YAAY,QAAQ,UAAU,UAAU;AAE9C,KAAI,UAAU,WAAW,EACvB;AAGF,MAAK,MAAM,YAAY,UACrB,OAAM,SAAS,MAAM,SAAS,KAAK;;;;;;;;ACnBvC,SAAgB,SAAY,OAAY,QAAQ,OAAmB;AACjE,QAAO,QACH,OAAO,UAAU,SAAS,KAAK,MAAM,CAAC,WAAW,WAAW,GAC5D,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;;;;;ACAhD,SAAgB,0BAA0B,MAAyB;AACjE,QAAO,IAAI,SACT,KAAK,UACH,gBAAgB,QACZ;EACE,MAAM,KAAK;EACX,SAAS,KAAK;EACd,OAAO,KAAK;EACb,GACD,KACL,EACD;EACE,QAAQ;EACR,YAAY;EACZ,SAAS,EACP,gBAAgB,oBACjB;EACF,CACF;;;;;;;;;;AAaH,SAAgB,gBAAgB,UAA8C;A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Q,OAAO,OAAO;KAE3D,EAAE,MAAM,MAAM,CACf;;CAGH,MAAM,SAAS,mCAAY,YAAY;EAKrC,MAAM,0BAA0B,UAAU,QAAQ,SAAS,WAAW;GACpE,WAAW,QAAQ;GACnB,SAAS,QAAQ;GACjB,YAAY,QAAQ;GACrB,CAAC;AAEF,QAAM,QAAQ,KAAK;GAEjB;GACA;GACA,QAAQ,WAAW;GACpB,CAAC;GACF;AAGF,KAAI,oBAAoB,UAAU,YAAY;AAC5C,QAAM,QAAQ,WAAW,UAAU,oBAAoB,gBAAgB;AACvE;;AAGF,KAAI,OAAO,OAAO;AAGhB,MAAI,MAAM,oBAAoB,OAAO,MAAM,CACzC;AAMF,MAAI,QAAQ,QAAQ,cAAc,qBAAqB,GAAG,GAAG;GAI3D,MAAM,+BAA+B,IAAIC,qCACvC,QAAQ,SACR;IAME,cAAc;IACd,MAAM,YAAY,UAAU;AAC1B,WAAM,eAAe,SAAS;;IAEhC,MAAM,UAAU,QAAQ;;;;;;;;AAQtB,WAAM,QAAQ,WAAW,UAAU,OAAO;;IAE7C,CACF;AAED,SAAM,UAAU,QAAQ,SAAS,sBAAsB;IACrD,OAAO,OAAO;IACd,SAAS,QAAQ;IACjB,WAAW,QAAQ;IACnB,YAAY;IACb,CAAC;AAIF,OACE,6BAA6B,eAAeA,qCAAkB,QAE9D;;AAKJ,QAAM,QAAQ,WAAW,YACvB,0BAA0B,OAAO,MAAM,CACxC;AACD;;AAIF,KAAI,QAAQ,WAAW,eAAeA,qCAAkB,QACtD,QAAO,MAAM,QAAQ,WAAW,aAAa;AAG/C,QAAO,QAAQ,WAAW"}
1
+ {"version":3,"file":"handleRequest-Dzg1d3e5.cjs","names":["InterceptorError","DeferredPromise","RequestController"],"sources":["../../src/utils/isPropertyAccessible.ts","../../src/utils/emitAsync.ts","../../src/utils/isObject.ts","../../src/utils/responseUtils.ts","../../src/utils/isNodeLikeError.ts","../../src/utils/handleRequest.ts"],"sourcesContent":["/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { Emitter, EventMap } from 'strict-event-emitter'\n\n/**\n * Emits an event on the given emitter but executes\n * the listeners sequentially. This accounts for asynchronous\n * listeners (e.g. those having \"sleep\" and handling the request).\n */\nexport async function emitAsync<\n Events extends EventMap,\n EventName extends keyof Events\n>(\n emitter: Emitter<Events>,\n eventName: EventName,\n ...data: Events[EventName]\n): Promise<void> {\n const listeners = emitter.listeners(eventName)\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n await listener.apply(emitter, data)\n }\n}\n","/**\n * Determines if a given value is an instance of object.\n */\nexport function isObject<T>(value: any, loose = false): value is T {\n return loose\n ? Object.prototype.toString.call(value).startsWith('[object ')\n : Object.prototype.toString.call(value) === '[object Object]'\n}\n","import { isObject } from './isObject'\nimport { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: unknown): response is ResponseError {\n return (\n response != null &&\n response instanceof Response &&\n isPropertyAccessible(response, 'type') &&\n response.type === 'error'\n )\n}\n\n/**\n * Check if the given value is a `Response` or a Response-like object.\n * This is different from `value instanceof Response` because it supports\n * custom `Response` constructors, like the one when using Undici directly.\n */\nexport function isResponseLike(value: unknown): value is Response {\n return (\n isObject<Record<string, any>>(value, true) &&\n isPropertyAccessible(value, 'status') &&\n isPropertyAccessible(value, 'statusText') &&\n isPropertyAccessible(value, 'bodyUsed')\n )\n}\n","export function isNodeLikeError(\n error: unknown\n): error is NodeJS.ErrnoException {\n if (error == null) {\n return false\n }\n\n if (!(error instanceof Error)) {\n return false\n }\n\n return 'code' in error && 'errno' in error\n}\n","import type { Emitter } from 'strict-event-emitter'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { until } from '@open-draft/until'\nimport type { HttpRequestEventMap } from '../glossary'\nimport { emitAsync } from './emitAsync'\nimport { RequestController } from '../RequestController'\nimport {\n createServerErrorResponse,\n isResponseError,\n isResponseLike,\n} from './responseUtils'\nimport { InterceptorError } from '../InterceptorError'\nimport { isNodeLikeError } from './isNodeLikeError'\nimport { isObject } from './isObject'\n\ninterface HandleRequestOptions {\n requestId: string\n request: Request\n emitter: Emitter<HttpRequestEventMap>\n controller: RequestController\n}\n\nexport async function handleRequest(\n options: HandleRequestOptions\n): Promise<void> {\n const handleResponse = async (\n response: Response | Error | Record<string, any>\n ) => {\n if (response instanceof Error) {\n await options.controller.errorWith(response)\n return true\n }\n\n // Handle \"Response.error()\" instances.\n if (isResponseError(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n /**\n * Handle normal responses or response-like objects.\n * @note This must come before the arbitrary object check\n * since Response instances are, in fact, objects.\n */\n if (isResponseLike(response)) {\n await options.controller.respondWith(response)\n return true\n }\n\n // Handle arbitrary objects provided to `.errorWith(reason)`.\n if (isObject(response)) {\n await options.controller.errorWith(response)\n return true\n }\n\n return false\n }\n\n const handleResponseError = async (error: unknown): Promise<boolean> => {\n // Forward the special interceptor error instances\n // to the developer. These must not be handled in any way.\n if (error instanceof InterceptorError) {\n throw result.error\n }\n\n // Support mocking Node.js-like errors.\n if (isNodeLikeError(error)) {\n await options.controller.errorWith(error)\n return true\n }\n\n // Handle thrown responses.\n if (error instanceof Response) {\n return await handleResponse(error)\n }\n\n return false\n }\n\n // Add the last \"request\" listener to check if the request\n // has been handled in any way. If it hasn't, resolve the\n // response promise with undefined.\n // options.emitter.once('request', async ({ requestId: pendingRequestId }) => {\n // if (\n // pendingRequestId === options.requestId &&\n // options.controller.readyState === RequestController.PENDING\n // ) {\n // await options.controller.passthrough()\n // }\n // })\n\n const requestAbortPromise = new DeferredPromise<void, unknown>()\n\n /**\n * @note `signal` is not always defined in React Native.\n */\n if (options.request.signal) {\n if (options.request.signal.aborted) {\n await options.controller.errorWith(options.request.signal.reason)\n return\n }\n\n options.request.signal.addEventListener(\n 'abort',\n () => {\n requestAbortPromise.reject(options.request.signal.reason)\n },\n { once: true }\n )\n }\n\n const result = await until(async () => {\n // Emit the \"request\" event and wait until all the listeners\n // for that event are finished (e.g. async listeners awaited).\n // By the end of this promise, the developer cannot affect the\n // request anymore.\n const requestListenersPromise = emitAsync(options.emitter, 'request', {\n requestId: options.requestId,\n request: options.request,\n controller: options.controller,\n })\n\n await Promise.race([\n // Short-circuit the request handling promise if the request gets aborted.\n requestAbortPromise,\n requestListenersPromise,\n options.controller.handled,\n ])\n })\n\n // Handle the request being aborted while waiting for the request listeners.\n if (requestAbortPromise.state === 'rejected') {\n await options.controller.errorWith(requestAbortPromise.rejectionReason)\n return\n }\n\n if (result.error) {\n // Handle the error during the request listener execution.\n // These can be thrown responses or request errors.\n if (await handleResponseError(result.error)) {\n return\n }\n\n // If the developer has added \"unhandledException\" listeners,\n // allow them to handle the error. They can translate it to a\n // mocked response, network error, or forward it as-is.\n if (options.emitter.listenerCount('unhandledException') > 0) {\n // Create a new request controller just for the unhandled exception case.\n // This is needed because the original controller might have been already\n // interacted with (e.g. \"respondWith\" or \"errorWith\" called on it).\n const unhandledExceptionController = new RequestController(\n options.request,\n {\n /**\n * @note Intentionally empty passthrough handle.\n * This controller is created within another controller and we only need\n * to know if `unhandledException` listeners handled the request.\n */\n passthrough() {},\n async respondWith(response) {\n await handleResponse(response)\n },\n async errorWith(reason) {\n /**\n * @note Handle the result of the unhandled controller\n * in the same way as the original request controller.\n * The exception here is that thrown errors within the\n * \"unhandledException\" event do NOT result in another\n * emit of the same event. They are forwarded as-is.\n */\n await options.controller.errorWith(reason)\n },\n }\n )\n\n await emitAsync(options.emitter, 'unhandledException', {\n error: result.error,\n request: options.request,\n requestId: options.requestId,\n controller: unhandledExceptionController,\n })\n\n // If all the \"unhandledException\" listeners have finished\n // but have not handled the request in any way, passthrough.\n if (\n unhandledExceptionController.readyState !== RequestController.PENDING\n ) {\n return\n }\n }\n\n // Otherwise, coerce unhandled exceptions to a 500 Internal Server Error response.\n await options.controller.respondWith(\n createServerErrorResponse(result.error)\n )\n return\n }\n\n // If the request hasn't been handled by this point, passthrough.\n if (options.controller.readyState === RequestController.PENDING) {\n return await options.controller.passthrough()\n }\n\n return options.controller.handled\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,SAAgB,qBACd,KACA,KACA;AACA,KAAI;AACF,MAAI;AACJ,SAAO;SACD;AACN,SAAO;;;;;;;;;;;ACTX,eAAsB,UAIpB,SACA,WACA,GAAG,MACY;CACf,MAAM,YAAY,QAAQ,UAAU,UAAU;AAE9C,KAAI,UAAU,WAAW,EACvB;AAGF,MAAK,MAAM,YAAY,UACrB,OAAM,SAAS,MAAM,SAAS,KAAK;;;;;;;;ACnBvC,SAAgB,SAAY,OAAY,QAAQ,OAAmB;AACjE,QAAO,QACH,OAAO,UAAU,SAAS,KAAK,MAAM,CAAC,WAAW,WAAW,GAC5D,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;;;;;ACAhD,SAAgB,0BAA0B,MAAyB;AACjE,QAAO,IAAI,SACT,KAAK,UACH,gBAAgB,QACZ;EACE,MAAM,KAAK;EACX,SAAS,KAAK;EACd,OAAO,KAAK;EACb,GACD,KACL,EACD;EACE,QAAQ;EACR,YAAY;E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AAO;AACjE;;AAGF,UAAQ,QAAQ,OAAO,iBACrB,eACM;AACJ,uBAAoB,OAAO,QAAQ,QAAQ,OAAO,OAAO;KAE3D,EAAE,MAAM,MAAM,CACf;;CAGH,MAAM,SAAS,mCAAY,YAAY;EAKrC,MAAM,0BAA0B,UAAU,QAAQ,SAAS,WAAW;GACpE,WAAW,QAAQ;GACnB,SAAS,QAAQ;GACjB,YAAY,QAAQ;GACrB,CAAC;AAEF,QAAM,QAAQ,KAAK;GAEjB;GACA;GACA,QAAQ,WAAW;GACpB,CAAC;GACF;AAGF,KAAI,oBAAoB,UAAU,YAAY;AAC5C,QAAM,QAAQ,WAAW,UAAU,oBAAoB,gBAAgB;AACvE;;AAGF,KAAI,OAAO,OAAO;AAGhB,MAAI,MAAM,oBAAoB,OAAO,MAAM,CACzC;AAMF,MAAI,QAAQ,QAAQ,cAAc,qBAAqB,GAAG,GAAG;GAI3D,MAAM,+BAA+B,IAAIC,qCACvC,QAAQ,SACR;IAME,cAAc;IACd,MAAM,YAAY,UAAU;AAC1B,WAAM,eAAe,SAAS;;IAEhC,MAAM,UAAU,QAAQ;;;;;;;;AAQtB,WAAM,QAAQ,WAAW,UAAU,OAAO;;IAE7C,CACF;AAED,SAAM,UAAU,QAAQ,SAAS,sBAAsB;IACrD,OAAO,OAAO;IACd,SAAS,QAAQ;IACjB,WAAW,QAAQ;IACnB,YAAY;IACb,CAAC;AAIF,OACE,6BAA6B,eAAeA,qCAAkB,QAE9D;;AAKJ,QAAM,QAAQ,WAAW,YACvB,0BAA0B,OAAO,MAAM,CACxC;AACD;;AAIF,KAAI,QAAQ,WAAW,eAAeA,qCAAkB,QACtD,QAAO,MAAM,QAAQ,WAAW,aAAa;AAG/C,QAAO,QAAQ,WAAW"}
@@ -0,0 +1,97 @@
1
+ const require_chunk = require('./chunk-CbDLau6x.cjs');
2
+ let outvariant = require("outvariant");
3
+
4
+ //#region src/utils/globalsRegistry.ts
5
+ var GlobalsRegistry = class {
6
+ #globals = /* @__PURE__ */ new Map();
7
+ replaceGlobal(key, nextValue) {
8
+ (0, outvariant.invariant)(!this.#globals.has(key), `Failed to replace a global value at "${key}": already replaced.`);
9
+ const match = getDeepPropertyDescriptor(globalThis, key);
10
+ if (typeof match === "undefined") {
11
+ console.warn(`Failed to replace a global value at "${key}": not a global value.`);
12
+ return () => {};
13
+ }
14
+ Object.defineProperty(globalThis, key, {
15
+ value: nextValue,
16
+ enumerable: true,
17
+ configurable: true
18
+ });
19
+ const restoreGlobal = () => {
20
+ if (!this.#globals.has(key)) return;
21
+ if (match.owner === globalThis) Object.defineProperty(match.owner, key, match.descriptor);
22
+ else
23
+ /**
24
+ * @todo Delete the proxy property set by the registry.
25
+ * If the owner isn't `globalThis`, the property is likely nested in the prototype.
26
+ * The registry does not meddle with those, they are left intact.
27
+ */
28
+ Reflect.deleteProperty(globalThis, key);
29
+ this.#globals.delete(key);
30
+ };
31
+ this.#globals.set(key, restoreGlobal);
32
+ return restoreGlobal;
33
+ }
34
+ restoreAllGlobals() {
35
+ const errors = [];
36
+ for (const [, restoreGlobal] of this.#globals) try {
37
+ restoreGlobal();
38
+ } catch (error) {
39
+ if (error instanceof Error) errors.push(error);
40
+ else throw error;
41
+ }
42
+ if (errors.length > 0) throw new AggregateError(errors, "FOO!");
43
+ }
44
+ };
45
+ const globalsRegistry = new GlobalsRegistry();
46
+ /**
47
+ * Returns a property descriptor for the given property on the owner.
48
+ * Walks down the prototype chain if the property does not exist on the owner.
49
+ * Handy for getting a global property descriptor where `globalThis` is
50
+ * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).
51
+ */
52
+ function getDeepPropertyDescriptor(owner, key) {
53
+ let currentOwner = owner;
54
+ let descriptor;
55
+ while (currentOwner) {
56
+ descriptor = Object.getOwnPropertyDescriptor(currentOwner, key);
57
+ if (descriptor) return {
58
+ owner: currentOwner,
59
+ descriptor
60
+ };
61
+ currentOwner = Object.getPrototypeOf(currentOwner);
62
+ }
63
+ }
64
+
65
+ //#endregion
66
+ //#region src/utils/hasConfigurableGlobal.ts
67
+ /**
68
+ * Returns a boolean indicating whether the given global property
69
+ * is defined and is configurable.
70
+ */
71
+ function hasConfigurableGlobal(propertyName) {
72
+ const match = getDeepPropertyDescriptor(globalThis, propertyName);
73
+ if (typeof match === "undefined") return false;
74
+ const { descriptor } = match;
75
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") return false;
76
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) return false;
77
+ if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
78
+ console.error(`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`);
79
+ return false;
80
+ }
81
+ return true;
82
+ }
83
+
84
+ //#endregion
85
+ Object.defineProperty(exports, 'globalsRegistry', {
86
+ enumerable: true,
87
+ get: function () {
88
+ return globalsRegistry;
89
+ }
90
+ });
91
+ Object.defineProperty(exports, 'hasConfigurableGlobal', {
92
+ enumerable: true,
93
+ get: function () {
94
+ return hasConfigurableGlobal;
95
+ }
96
+ });
97
+ //# sourceMappingURL=hasConfigurableGlobal-Befl_QJD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasConfigurableGlobal-Befl_QJD.cjs","names":["#globals","errors: Array<Error>","currentOwner: Owner | null","descriptor: PropertyDescriptor | undefined"],"sources":["../../src/utils/globalsRegistry.ts","../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["import { invariant } from 'outvariant'\n\nclass GlobalsRegistry {\n #globals = new Map<keyof typeof globalThis, () => void>()\n\n public replaceGlobal<K extends keyof typeof globalThis>(\n key: K,\n nextValue: (typeof globalThis)[K]\n ): () => void {\n invariant(\n !this.#globals.has(key),\n `Failed to replace a global value at \"${key}\": already replaced.`\n )\n\n const match = getDeepPropertyDescriptor(globalThis, key)\n\n if (typeof match === 'undefined') {\n console.warn(\n `Failed to replace a global value at \"${key}\": not a global value.`\n )\n return () => {}\n }\n\n Object.defineProperty(globalThis, key, {\n value: nextValue,\n enumerable: true,\n configurable: true,\n })\n\n const restoreGlobal = () => {\n if (!this.#globals.has(key)) {\n return\n }\n\n if (match.owner === globalThis) {\n Object.defineProperty(match.owner, key, match.descriptor)\n } else {\n /**\n * @todo Delete the proxy property set by the registry.\n * If the owner isn't `globalThis`, the property is likely nested in the prototype.\n * The registry does not meddle with those, they are left intact.\n */\n Reflect.deleteProperty(globalThis, key)\n }\n\n this.#globals.delete(key)\n }\n\n this.#globals.set(key, restoreGlobal)\n\n return restoreGlobal\n }\n\n public restoreAllGlobals(): void {\n const errors: Array<Error> = []\n\n for (const [, restoreGlobal] of this.#globals) {\n try {\n restoreGlobal()\n } catch (error) {\n if (error instanceof Error) {\n errors.push(error)\n } else {\n throw error\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'FOO!')\n }\n }\n}\n\nexport const globalsRegistry = new GlobalsRegistry()\n\ninterface DeepDescriptorMatch {\n owner: object\n descriptor: PropertyDescriptor\n}\n\n/**\n * Returns a property descriptor for the given property on the owner.\n * Walks down the prototype chain if the property does not exist on the owner.\n * Handy for getting a global property descriptor where `globalThis` is\n * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).\n */\nexport function getDeepPropertyDescriptor<Owner extends object>(\n owner: Owner,\n key: keyof Owner\n): DeepDescriptorMatch | undefined {\n let currentOwner: Owner | null = owner\n let descriptor: PropertyDescriptor | undefined\n\n while (currentOwner) {\n descriptor = Object.getOwnPropertyDescriptor(currentOwner, key)\n\n if (descriptor) {\n return {\n owner: currentOwner,\n descriptor,\n }\n }\n\n currentOwner = Object.getPrototypeOf(currentOwner)\n }\n}\n","import { getDeepPropertyDescriptor } from './globalsRegistry'\n\n/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(\n propertyName: keyof typeof globalThis\n): boolean {\n const match = getDeepPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof match === 'undefined') {\n return false\n }\n\n const { descriptor } = match\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";;;;AAEA,IAAM,kBAAN,MAAsB;CACpB,2BAAW,IAAI,KAA0C;CAEzD,AAAO,cACL,KACA,WACY;AACZ,4BACE,CAAC,MAAKA,QAAS,IAAI,IAAI,EACvB,wCAAwC,IAAI,sBAC7C;EAED,MAAM,QAAQ,0BAA0B,YAAY,IAAI;AAExD,MAAI,OAAO,UAAU,aAAa;AAChC,WAAQ,KACN,wCAAwC,IAAI,wBAC7C;AACD,gBAAa;;AAGf,SAAO,eAAe,YAAY,KAAK;GACrC,OAAO;GACP,YAAY;GACZ,cAAc;GACf,CAAC;EAEF,MAAM,sBAAsB;AAC1B,OAAI,CAAC,MAAKA,QAAS,IAAI,IAAI,CACzB;AAGF,OAAI,MAAM,UAAU,WAClB,QAAO,eAAe,MAAM,OAAO,KAAK,MAAM,WAAW;;;;;;;AAOzD,WAAQ,eAAe,YAAY,IAAI;AAGzC,SAAKA,QAAS,OAAO,IAAI;;AAG3B,QAAKA,QAAS,IAAI,KAAK,cAAc;AAErC,SAAO;;CAGT,AAAO,oBAA0B;EAC/B,MAAMC,SAAuB,EAAE;AAE/B,OAAK,MAAM,GAAG,kBAAkB,MAAKD,QACnC,KAAI;AACF,kBAAe;WACR,OAAO;AACd,OAAI,iBAAiB,MACnB,QAAO,KAAK,MAAM;OAElB,OAAM;;AAKZ,MAAI,OAAO,SAAS,EAClB,OAAM,IAAI,eAAe,QAAQ,OAAO;;;AAK9C,MAAa,kBAAkB,IAAI,iBAAiB;;;;;;;AAapD,SAAgB,0BACd,OACA,KACiC;CACjC,IAAIE,eAA6B;CACjC,IAAIC;AAEJ,QAAO,cAAc;AACnB,eAAa,OAAO,yBAAyB,cAAc,IAAI;AAE/D,MAAI,WACF,QAAO;GACL,OAAO;GACP;GACD;AAGH,iBAAe,OAAO,eAAe,aAAa;;;;;;;;;;AClGtD,SAAgB,sBACd,cACS;CACT,MAAM,QAAQ,0BAA0B,YAAY,aAAa;AAGjE,KAAI,OAAO,UAAU,YACnB,QAAO;CAGT,MAAM,EAAE,eAAe;AAGvB,KACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,KAAK,KAAK,YAE5B,QAAO;AAIT,KAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,KAC/D,QAAO;AAGT,KAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,UAAQ,MACN,mDAAmD,aAAa,oKACjE;AACD,SAAO;;AAGT,QAAO"}
@@ -0,0 +1,85 @@
1
+ import { invariant } from "outvariant";
2
+
3
+ //#region src/utils/globalsRegistry.ts
4
+ var GlobalsRegistry = class {
5
+ #globals = /* @__PURE__ */ new Map();
6
+ replaceGlobal(key, nextValue) {
7
+ invariant(!this.#globals.has(key), `Failed to replace a global value at "${key}": already replaced.`);
8
+ const match = getDeepPropertyDescriptor(globalThis, key);
9
+ if (typeof match === "undefined") {
10
+ console.warn(`Failed to replace a global value at "${key}": not a global value.`);
11
+ return () => {};
12
+ }
13
+ Object.defineProperty(globalThis, key, {
14
+ value: nextValue,
15
+ enumerable: true,
16
+ configurable: true
17
+ });
18
+ const restoreGlobal = () => {
19
+ if (!this.#globals.has(key)) return;
20
+ if (match.owner === globalThis) Object.defineProperty(match.owner, key, match.descriptor);
21
+ else
22
+ /**
23
+ * @todo Delete the proxy property set by the registry.
24
+ * If the owner isn't `globalThis`, the property is likely nested in the prototype.
25
+ * The registry does not meddle with those, they are left intact.
26
+ */
27
+ Reflect.deleteProperty(globalThis, key);
28
+ this.#globals.delete(key);
29
+ };
30
+ this.#globals.set(key, restoreGlobal);
31
+ return restoreGlobal;
32
+ }
33
+ restoreAllGlobals() {
34
+ const errors = [];
35
+ for (const [, restoreGlobal] of this.#globals) try {
36
+ restoreGlobal();
37
+ } catch (error) {
38
+ if (error instanceof Error) errors.push(error);
39
+ else throw error;
40
+ }
41
+ if (errors.length > 0) throw new AggregateError(errors, "FOO!");
42
+ }
43
+ };
44
+ const globalsRegistry = new GlobalsRegistry();
45
+ /**
46
+ * Returns a property descriptor for the given property on the owner.
47
+ * Walks down the prototype chain if the property does not exist on the owner.
48
+ * Handy for getting a global property descriptor where `globalThis` is
49
+ * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).
50
+ */
51
+ function getDeepPropertyDescriptor(owner, key) {
52
+ let currentOwner = owner;
53
+ let descriptor;
54
+ while (currentOwner) {
55
+ descriptor = Object.getOwnPropertyDescriptor(currentOwner, key);
56
+ if (descriptor) return {
57
+ owner: currentOwner,
58
+ descriptor
59
+ };
60
+ currentOwner = Object.getPrototypeOf(currentOwner);
61
+ }
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/utils/hasConfigurableGlobal.ts
66
+ /**
67
+ * Returns a boolean indicating whether the given global property
68
+ * is defined and is configurable.
69
+ */
70
+ function hasConfigurableGlobal(propertyName) {
71
+ const match = getDeepPropertyDescriptor(globalThis, propertyName);
72
+ if (typeof match === "undefined") return false;
73
+ const { descriptor } = match;
74
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") return false;
75
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) return false;
76
+ if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
77
+ console.error(`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`);
78
+ return false;
79
+ }
80
+ return true;
81
+ }
82
+
83
+ //#endregion
84
+ export { globalsRegistry as n, hasConfigurableGlobal as t };
85
+ //# sourceMappingURL=hasConfigurableGlobal-jN_-v3gp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasConfigurableGlobal-jN_-v3gp.mjs","names":["#globals","errors: Array<Error>","currentOwner: Owner | null","descriptor: PropertyDescriptor | undefined"],"sources":["../../src/utils/globalsRegistry.ts","../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["import { invariant } from 'outvariant'\n\nclass GlobalsRegistry {\n #globals = new Map<keyof typeof globalThis, () => void>()\n\n public replaceGlobal<K extends keyof typeof globalThis>(\n key: K,\n nextValue: (typeof globalThis)[K]\n ): () => void {\n invariant(\n !this.#globals.has(key),\n `Failed to replace a global value at \"${key}\": already replaced.`\n )\n\n const match = getDeepPropertyDescriptor(globalThis, key)\n\n if (typeof match === 'undefined') {\n console.warn(\n `Failed to replace a global value at \"${key}\": not a global value.`\n )\n return () => {}\n }\n\n Object.defineProperty(globalThis, key, {\n value: nextValue,\n enumerable: true,\n configurable: true,\n })\n\n const restoreGlobal = () => {\n if (!this.#globals.has(key)) {\n return\n }\n\n if (match.owner === globalThis) {\n Object.defineProperty(match.owner, key, match.descriptor)\n } else {\n /**\n * @todo Delete the proxy property set by the registry.\n * If the owner isn't `globalThis`, the property is likely nested in the prototype.\n * The registry does not meddle with those, they are left intact.\n */\n Reflect.deleteProperty(globalThis, key)\n }\n\n this.#globals.delete(key)\n }\n\n this.#globals.set(key, restoreGlobal)\n\n return restoreGlobal\n }\n\n public restoreAllGlobals(): void {\n const errors: Array<Error> = []\n\n for (const [, restoreGlobal] of this.#globals) {\n try {\n restoreGlobal()\n } catch (error) {\n if (error instanceof Error) {\n errors.push(error)\n } else {\n throw error\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'FOO!')\n }\n }\n}\n\nexport const globalsRegistry = new GlobalsRegistry()\n\ninterface DeepDescriptorMatch {\n owner: object\n descriptor: PropertyDescriptor\n}\n\n/**\n * Returns a property descriptor for the given property on the owner.\n * Walks down the prototype chain if the property does not exist on the owner.\n * Handy for getting a global property descriptor where `globalThis` is\n * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).\n */\nexport function getDeepPropertyDescriptor<Owner extends object>(\n owner: Owner,\n key: keyof Owner\n): DeepDescriptorMatch | undefined {\n let currentOwner: Owner | null = owner\n let descriptor: PropertyDescriptor | undefined\n\n while (currentOwner) {\n descriptor = Object.getOwnPropertyDescriptor(currentOwner, key)\n\n if (descriptor) {\n return {\n owner: currentOwner,\n descriptor,\n }\n }\n\n currentOwner = Object.getPrototypeOf(currentOwner)\n }\n}\n","import { getDeepPropertyDescriptor } from './globalsRegistry'\n\n/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(\n propertyName: keyof typeof globalThis\n): boolean {\n const match = getDeepPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof match === 'undefined') {\n return false\n }\n\n const { descriptor } = match\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";;;AAEA,IAAM,kBAAN,MAAsB;CACpB,2BAAW,IAAI,KAA0C;CAEzD,AAAO,cACL,KACA,WACY;AACZ,YACE,CAAC,MAAKA,QAAS,IAAI,IAAI,EACvB,wCAAwC,IAAI,sBAC7C;EAED,MAAM,QAAQ,0BAA0B,YAAY,IAAI;AAExD,MAAI,OAAO,UAAU,aAAa;AAChC,WAAQ,KACN,wCAAwC,IAAI,wBAC7C;AACD,gBAAa;;AAGf,SAAO,eAAe,YAAY,KAAK;GACrC,OAAO;GACP,YAA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ceptor-DJ2akVWI.cjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-BsZ21ue0.cjs";
2
2
  import net from "node:net";
3
3
 
4
4
  //#region src/interceptors/Socket/utils/normalizeSocketWriteArgs.d.ts
@@ -110,4 +110,4 @@ declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap>
110
110
  }
111
111
  //#endregion
112
112
  export { ClientRequestInterceptor as t };
113
- //# sourceMappingURL=index-BMbJ8FXL.d.cts.map
113
+ //# sourceMappingURL=index-BJ5E5aW-.d.cts.map
@@ -1,4 +1,4 @@
1
- import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-DEazpLJd.mjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-soD-WpQO.mjs";
2
2
  import net from "node:net";
3
3
 
4
4
  //#region src/interceptors/Socket/utils/normalizeSocketWriteArgs.d.ts
@@ -110,4 +110,4 @@ declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap>
110
110
  }
111
111
  //#endregion
112
112
  export { ClientRequestInterceptor as t };
113
- //# sourceMappingURL=index-C0YAQ36w.d.mts.map
113
+ //# sourceMappingURL=index-DfoF45ih.d.mts.map
@@ -1,8 +1,7 @@
1
- const require_glossary = require('./glossary-BLKRyLBd.cjs');
2
- const require_fetchUtils = require('./fetchUtils-DE_q7tpr.cjs');
3
- const require_BatchInterceptor = require('./BatchInterceptor-7u9fqQIe.cjs');
4
- const require_bufferUtils = require('./bufferUtils-DiCTqG-7.cjs');
5
- const require_getRawRequest = require('./getRawRequest-BavnMWh_.cjs');
1
+ const require_fetchUtils = require('./fetchUtils-Dw6kQghF.cjs');
2
+ const require_BatchInterceptor = require('./BatchInterceptor-AZr7q8p_.cjs');
3
+ const require_bufferUtils = require('./bufferUtils-S5_-2eN4.cjs');
4
+ const require_getRawRequest = require('./getRawRequest-B6znU6il.cjs');
6
5
 
7
6
  //#region src/utils/getCleanUrl.ts
8
7
  /**
@@ -40,7 +39,6 @@ exports.BatchInterceptor = require_BatchInterceptor.BatchInterceptor;
40
39
  exports.FetchRequest = require_fetchUtils.FetchRequest;
41
40
  exports.FetchResponse = require_fetchUtils.FetchResponse;
42
41
  exports.INTERNAL_REQUEST_ID_HEADER_NAME = require_fetchUtils.INTERNAL_REQUEST_ID_HEADER_NAME;
43
- exports.IS_PATCHED_MODULE = require_glossary.IS_PATCHED_MODULE;
44
42
  exports.Interceptor = require_fetchUtils.Interceptor;
45
43
  exports.InterceptorReadyState = require_fetchUtils.InterceptorReadyState;
46
44
  exports.RequestController = require_fetchUtils.RequestController;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
@@ -1,5 +1,5 @@
1
- import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestCredentials, f as RequestController, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, p as RequestControllerSource, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as IS_PATCHED_MODULE } from "./Interceptor-DJ2akVWI.cjs";
2
- import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-D_YqR8qU.cjs";
1
+ import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestController, f as RequestControllerSource, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as RequestCredentials } from "./Interceptor-BsZ21ue0.cjs";
2
+ import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-KKF8Q47I.cjs";
3
3
 
4
4
  //#region src/createRequestId.d.ts
5
5
 
@@ -90,5 +90,5 @@ declare function getRawRequest(request: Request): unknown | undefined;
90
90
  */
91
91
  declare function resolveWebSocketUrl(url: string | URL): string;
92
92
  //#endregion
93
- export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
93
+ export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
94
94
  //# sourceMappingURL=index.d.cts.map
@@ -1,5 +1,5 @@
1
- import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestCredentials, f as RequestController, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, p as RequestControllerSource, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as IS_PATCHED_MODULE } from "./Interceptor-DEazpLJd.mjs";
2
- import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-D7mXzHcQ.mjs";
1
+ import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestController, f as RequestControllerSource, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as RequestCredentials } from "./Interceptor-soD-WpQO.mjs";
2
+ import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-rSr-NH_H.mjs";
3
3
 
4
4
  //#region src/createRequestId.d.ts
5
5
 
@@ -90,5 +90,5 @@ declare function getRawRequest(request: Request): unknown | undefined;
90
90
  */
91
91
  declare function resolveWebSocketUrl(url: string | URL): string;
92
92
  //#endregion
93
- export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
93
+ export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
94
94
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,7 @@
1
- import { t as IS_PATCHED_MODULE } from "./glossary-glQBRnVD.mjs";
2
- import { a as RequestController, c as Interceptor, d as getGlobalSymbol, i as createRequestId, l as InterceptorReadyState, n as FetchResponse, s as INTERNAL_REQUEST_ID_HEADER_NAME, t as FetchRequest, u as deleteGlobalSymbol } from "./fetchUtils-BTrdMHGp.mjs";
3
- import { t as BatchInterceptor } from "./BatchInterceptor-BxgAXyLw.mjs";
4
- import { n as encodeBuffer, t as decodeBuffer } from "./bufferUtils-_8XfKIfX.mjs";
5
- import { t as getRawRequest } from "./getRawRequest-DnwmXyOW.mjs";
1
+ import { a as RequestController, c as Interceptor, d as getGlobalSymbol, i as createRequestId, l as InterceptorReadyState, n as FetchResponse, s as INTERNAL_REQUEST_ID_HEADER_NAME, t as FetchRequest, u as deleteGlobalSymbol } from "./fetchUtils-BJxD7wvl.mjs";
2
+ import { t as BatchInterceptor } from "./BatchInterceptor-B2YAn5m9.mjs";
3
+ import { n as encodeBuffer, t as decodeBuffer } from "./bufferUtils-DxPxwff_.mjs";
4
+ import { t as getRawRequest } from "./getRawRequest-C2-1urzA.mjs";
6
5
 
7
6
  //#region src/utils/getCleanUrl.ts
8
7
  /**
@@ -36,5 +35,5 @@ function resolveWebSocketUrl(url) {
36
35
  }
37
36
 
38
37
  //#endregion
39
- export { BatchInterceptor, FetchRequest, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorReadyState, RequestController, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
38
+ export { BatchInterceptor, FetchRequest, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorReadyState, RequestController, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
40
39
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
@@ -1,6 +1,6 @@
1
- require('../../fetchUtils-DE_q7tpr.cjs');
2
- const require_ClientRequest = require('../../ClientRequest-CMSXChAM.cjs');
3
- require('../../handleRequest-pLIe3KKo.cjs');
4
- require('../../node-dKdAf3tC.cjs');
1
+ require('../../fetchUtils-Dw6kQghF.cjs');
2
+ const require_ClientRequest = require('../../ClientRequest-BgwQG-9G.cjs');
3
+ require('../../handleRequest-Dzg1d3e5.cjs');
4
+ require('../../node-DIKcnzhK.cjs');
5
5
 
6
6
  exports.ClientRequestInterceptor = require_ClientRequest.ClientRequestInterceptor;
@@ -1,2 +1,2 @@
1
- import { t as ClientRequestInterceptor } from "../../index-BMbJ8FXL.cjs";
1
+ import { t as ClientRequestInterceptor } from "../../index-BJ5E5aW-.cjs";
2
2
  export { ClientRequestInterceptor };
@@ -1,3 +1,3 @@
1
- import "../../Interceptor-DEazpLJd.mjs";
2
- import { t as ClientRequestInterceptor } from "../../index-C0YAQ36w.mjs";
1
+ import "../../Interceptor-soD-WpQO.mjs";
2
+ import { t as ClientRequestInterceptor } from "../../index-DfoF45ih.mjs";
3
3
  export { ClientRequestInterceptor };
@@ -1,6 +1,6 @@
1
- import "../../fetchUtils-BTrdMHGp.mjs";
2
- import { t as ClientRequestInterceptor } from "../../ClientRequest-Cl3Ky7Tw.mjs";
3
- import "../../handleRequest-CDabRyt1.mjs";
4
- import "../../node-DwCc6iuP.mjs";
1
+ import "../../fetchUtils-BJxD7wvl.mjs";
2
+ import { t as ClientRequestInterceptor } from "../../ClientRequest-5WjHvs9Y.mjs";
3
+ import "../../handleRequest-DGfUg9bm.mjs";
4
+ import "../../node-lsdNwZEW.mjs";
5
5
 
6
6
  export { ClientRequestInterceptor };
@@ -1,6 +1,7 @@
1
- require('../../fetchUtils-DE_q7tpr.cjs');
2
- require('../../bufferUtils-DiCTqG-7.cjs');
3
- require('../../handleRequest-pLIe3KKo.cjs');
4
- const require_XMLHttpRequest = require('../../XMLHttpRequest-Dj3xJgke.cjs');
1
+ require('../../fetchUtils-Dw6kQghF.cjs');
2
+ require('../../bufferUtils-S5_-2eN4.cjs');
3
+ require('../../handleRequest-Dzg1d3e5.cjs');
4
+ const require_XMLHttpRequest = require('../../XMLHttpRequest-B7sloBex.cjs');
5
+ require('../../hasConfigurableGlobal-Befl_QJD.cjs');
5
6
 
6
7
  exports.XMLHttpRequestInterceptor = require_XMLHttpRequest.XMLHttpRequestInterceptor;
@@ -1,4 +1,4 @@
1
- import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DJ2akVWI.cjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-BsZ21ue0.cjs";
2
2
  import { Emitter } from "strict-event-emitter";
3
3
 
4
4
  //#region src/interceptors/XMLHttpRequest/index.d.ts
@@ -1,4 +1,4 @@
1
- import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DEazpLJd.mjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-soD-WpQO.mjs";
2
2
  import { Emitter } from "strict-event-emitter";
3
3
 
4
4
  //#region src/interceptors/XMLHttpRequest/index.d.ts
@@ -1,6 +1,7 @@
1
- import "../../fetchUtils-BTrdMHGp.mjs";
2
- import "../../bufferUtils-_8XfKIfX.mjs";
3
- import "../../handleRequest-CDabRyt1.mjs";
4
- import { t as XMLHttpRequestInterceptor } from "../../XMLHttpRequest-BBbs-p9i.mjs";
1
+ import "../../fetchUtils-BJxD7wvl.mjs";
2
+ import "../../bufferUtils-DxPxwff_.mjs";
3
+ import "../../handleRequest-DGfUg9bm.mjs";
4
+ import { t as XMLHttpRequestInterceptor } from "../../XMLHttpRequest-DmsdUGmj.mjs";
5
+ import "../../hasConfigurableGlobal-jN_-v3gp.mjs";
5
6
 
6
7
  export { XMLHttpRequestInterceptor };
@@ -1,5 +1,6 @@
1
- require('../../fetchUtils-DE_q7tpr.cjs');
2
- require('../../handleRequest-pLIe3KKo.cjs');
3
- const require_fetch = require('../../fetch-BoCFyaYx.cjs');
1
+ require('../../fetchUtils-Dw6kQghF.cjs');
2
+ require('../../handleRequest-Dzg1d3e5.cjs');
3
+ require('../../hasConfigurableGlobal-Befl_QJD.cjs');
4
+ const require_fetch = require('../../fetch-uc7pNtPg.cjs');
4
5
 
5
6
  exports.FetchInterceptor = require_fetch.FetchInterceptor;
@@ -1,4 +1,4 @@
1
- import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DJ2akVWI.cjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-BsZ21ue0.cjs";
2
2
 
3
3
  //#region src/interceptors/fetch/index.d.ts
4
4
  declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
@@ -1,4 +1,4 @@
1
- import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DEazpLJd.mjs";
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-soD-WpQO.mjs";
2
2
 
3
3
  //#region src/interceptors/fetch/index.d.ts
4
4
  declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {