| "use strict";
|
| var __defProp = Object.defineProperty;
|
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| var __getOwnPropNames = Object.getOwnPropertyNames;
|
| var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| var __export = (target, all) => {
|
| for (var name in all)
|
| __defProp(target, name, { get: all[name], enumerable: true });
|
| };
|
| var __copyProps = (to, from, except, desc) => {
|
| if (from && typeof from === "object" || typeof from === "function") {
|
| for (let key of __getOwnPropNames(from))
|
| if (!__hasOwnProp.call(to, key) && key !== except)
|
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| }
|
| return to;
|
| };
|
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
|
| var response_exports = {};
|
| __export(response_exports, {
|
| GlobalResponse: () => GlobalResponse,
|
| Response: () => Response,
|
| cacheKey: () => cacheKey
|
| });
|
| module.exports = __toCommonJS(response_exports);
|
| var responseCache = Symbol("responseCache");
|
| var getResponseCache = Symbol("getResponseCache");
|
| var cacheKey = Symbol("cache");
|
| var GlobalResponse = global.Response;
|
| var Response = class _Response {
|
| #body;
|
| #init;
|
| [getResponseCache]() {
|
| delete this[cacheKey];
|
| return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
|
| }
|
| constructor(body, init) {
|
| let headers;
|
| this.#body = body;
|
| if (init instanceof _Response) {
|
| const cachedGlobalResponse = init[responseCache];
|
| if (cachedGlobalResponse) {
|
| this.#init = cachedGlobalResponse;
|
| this[getResponseCache]();
|
| return;
|
| } else {
|
| this.#init = init.#init;
|
| headers = new Headers(init.#init.headers);
|
| }
|
| } else {
|
| this.#init = init;
|
| }
|
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
|
| ;
|
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
|
| }
|
| }
|
| get headers() {
|
| const cache = this[cacheKey];
|
| if (cache) {
|
| if (!(cache[2] instanceof Headers)) {
|
| cache[2] = new Headers(
|
| cache[2] || { "content-type": "text/plain; charset=UTF-8" }
|
| );
|
| }
|
| return cache[2];
|
| }
|
| return this[getResponseCache]().headers;
|
| }
|
| get status() {
|
| return this[cacheKey]?.[0] ?? this[getResponseCache]().status;
|
| }
|
| get ok() {
|
| const status = this.status;
|
| return status >= 200 && status < 300;
|
| }
|
| };
|
| ["body", "bodyUsed", "redirected", "statusText", "trailers", "type", "url"].forEach((k) => {
|
| Object.defineProperty(Response.prototype, k, {
|
| get() {
|
| return this[getResponseCache]()[k];
|
| }
|
| });
|
| });
|
| ["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
|
| Object.defineProperty(Response.prototype, k, {
|
| value: function() {
|
| return this[getResponseCache]()[k]();
|
| }
|
| });
|
| });
|
| Object.defineProperty(Response.prototype, Symbol.for("nodejs.util.inspect.custom"), {
|
| value: function(depth, options, inspectFn) {
|
| const props = {
|
| status: this.status,
|
| headers: this.headers,
|
| ok: this.ok,
|
| nativeResponse: this[responseCache]
|
| };
|
| return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
| }
|
| });
|
| Object.setPrototypeOf(Response, GlobalResponse);
|
| Object.setPrototypeOf(Response.prototype, GlobalResponse.prototype);
|
|
|
| 0 && (module.exports = {
|
| GlobalResponse,
|
| Response,
|
| cacheKey
|
| });
|
|
|