Spaces:
Running
Running
| // src/glossary.ts | |
| var IS_PATCHED_MODULE = Symbol("isPatchedModule"); | |
| // src/utils/fetchUtils.ts | |
| var _FetchResponse = class extends Response { | |
| static isConfigurableStatusCode(status) { | |
| return status >= 200 && status <= 599; | |
| } | |
| static isRedirectResponse(status) { | |
| return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status); | |
| } | |
| /** | |
| * Returns a boolean indicating whether the given response status | |
| * code represents a response that can have a body. | |
| */ | |
| static isResponseWithBody(status) { | |
| return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status); | |
| } | |
| static setUrl(url, response) { | |
| if (!url) { | |
| return; | |
| } | |
| if (response.url != "") { | |
| return; | |
| } | |
| Object.defineProperty(response, "url", { | |
| value: url, | |
| enumerable: true, | |
| configurable: true, | |
| writable: false | |
| }); | |
| } | |
| /** | |
| * Parses the given raw HTTP headers into a Fetch API `Headers` instance. | |
| */ | |
| static parseRawHeaders(rawHeaders) { | |
| const headers = new Headers(); | |
| for (let line = 0; line < rawHeaders.length; line += 2) { | |
| headers.append(rawHeaders[line], rawHeaders[line + 1]); | |
| } | |
| return headers; | |
| } | |
| constructor(body, init = {}) { | |
| var _a; | |
| const status = (_a = init.status) != null ? _a : 200; | |
| const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200; | |
| const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null; | |
| super(finalBody, { | |
| ...init, | |
| status: safeStatus | |
| }); | |
| if (status !== safeStatus) { | |
| const stateSymbol = Object.getOwnPropertySymbols(this).find( | |
| (symbol) => symbol.description === "state" | |
| ); | |
| if (stateSymbol) { | |
| const state = Reflect.get(this, stateSymbol); | |
| Reflect.set(state, "status", status); | |
| } else { | |
| Object.defineProperty(this, "status", { | |
| value: status, | |
| enumerable: true, | |
| configurable: true, | |
| writable: false | |
| }); | |
| } | |
| } | |
| _FetchResponse.setUrl(init.url, this); | |
| } | |
| }; | |
| var FetchResponse = _FetchResponse; | |
| /** | |
| * Response status codes for responses that cannot have body. | |
| * @see https://fetch.spec.whatwg.org/#statuses | |
| */ | |
| FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304]; | |
| FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308]; | |
| export { | |
| IS_PATCHED_MODULE, | |
| FetchResponse | |
| }; | |
| //# sourceMappingURL=chunk-5UK33FSU.mjs.map |