From 4439d7ee569484604fd6dfd5902fab8cd4cbc4e9 Mon Sep 17 00:00:00 2001 From: Auke van Slooten Date: Tue, 7 Jan 2025 13:03:27 +0100 Subject: [PATCH] bumped version --- dist/browser.js | 4 ++-- dist/browser.js.map | 4 ++-- dist/browser.min.js | 2 +- dist/browser.min.js.map | 6 +++--- dist/everything.js | 3 +-- dist/everything.js.map | 4 ++-- dist/everything.min.js | 2 +- dist/everything.min.js.map | 4 ++-- package.json | 2 +- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dist/browser.js b/dist/browser.js index a41e984..b5e183d 100644 --- a/dist/browser.js +++ b/dist/browser.js @@ -618,9 +618,9 @@ }; } }; - trace.add("group", trace.group()); // src/browser.mjs - window.metro = metro_exports; + globalThis.metro = metro_exports; + var browser_default = metro_exports; })(); //# sourceMappingURL=browser.js.map diff --git a/dist/browser.js.map b/dist/browser.js.map index ccf1f8a..f289a91 100644 --- a/dist/browser.js.map +++ b/dist/browser.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/metro.mjs", "../src/browser.mjs"], - "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n\ntrace.add('group', trace.group())", "import * as metro from './metro.mjs'\n\nwindow.metro = metro\n"], - "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,WAAW;AAOjB,MAAI,CAAC,OAAO,YAAY;AACvB,WAAO,aAAa,OAAO,SAAS;AAAA,EACrC;AACA,MAAI,CAAC,OAAO,aAAa;AACxB,WAAO,cAAc,OAAO,QAAQ;AAAA,EACrC;AAaA,MAAM,SAAN,MAAM,QACN;AAAA,IACC,WAAW;AAAA,MACV,KAAK,OAAO,UAAU,cAAc,OAAO,WAAW;AAAA,IACvD;AAAA,IACA,SAAS,CAAC,OAAM,QAAO,OAAM,UAAS,SAAQ,QAAO,WAAU,OAAO;AAAA,IAEtE,OAAO,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYlB,eAAe,SACf;AACC,eAAS,UAAU,SAAS;AAC3B,YAAI,OAAO,UAAU,YAAY,kBAAkB,QAAQ;AAC1D,eAAK,SAAS,MAAM,KAAG;AAAA,QACxB,WAAW,kBAAkB,SAAQ;AACpC,iBAAO,OAAO,KAAK,UAAU,OAAO,QAAQ;AAAA,QAC7C,WAAW,kBAAkB,UAAU;AACtC,eAAK,gBAAgB,CAAC,MAAM,CAAC;AAAA,QAC9B,WAAW,UAAU,OAAO,UAAU,UAAU;AAC/C,mBAAS,SAAS,QAAQ;AACzB,gBAAI,SAAS,eAAe;AAC3B,mBAAK,gBAAgB,OAAO,KAAK,CAAC;AAAA,YACnC,WAAW,OAAO,OAAO,KAAK,KAAK,YAAY;AAC9C,mBAAK,SAAS,KAAK,IAAI,OAAO,KAAK,EAAE,KAAK,SAAS,KAAK,GAAG,KA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;AACZ,aAAO;AAAA,QACN,SAAS,CAAC,KAAK,eAAe;AAC7B;AACA,uBAAa,MAAM,KAAK;AACxB,uBAAa,KAAK,KAAK,KAAK,KAAK,UAAU;AAAA,QAC5C;AAAA,QACA,UAAU,CAAC,KAAK,eAAe;AAC9B,uBAAa,KAAK,KAAK,OAAO,IAAI,KAAK,OAAO,WAAW,IAAG,MAAM,KAAK,UAAU;AACjF,uBAAa,SAAS,KAAK;AAC3B;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,IAAI,SAAS,MAAM,MAAM,CAAC;;;AC5wBhC,SAAO,QAAQ;", + "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n", "import * as metro from './metro.mjs'\n\nglobalThis.metro = metro\n\nexport default metro"], + "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,WA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AAC3B;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;;;AC1wBA,aAAW,QAAQ;AAEnB,MAAO,kBAAQ;", "names": ["options", "req", "next", "middleware", "options", "url"] } diff --git a/dist/browser.min.js b/dist/browser.min.js index 76a6243..9d7ba8e 100644 --- a/dist/browser.min.js +++ b/dist/browser.min.js @@ -1,2 +1,2 @@ -(()=>{var O=Object.defineProperty;var g=(t,o)=>{for(var r in o)O(t,r,{get:o[r],enumerable:!0})};var j={};g(j,{client:()=>A,formdata:()=>v,metroError:()=>f,request:()=>b,response:()=>P,trace:()=>S,url:()=>d});var y="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var u=class t{#e={url:typeof window<"u"?window.location:"https://localhost"};#r=["get","post","put","delete","patch","head","options","query"];static tracers={};constructor(...o){for(let r of o)if(typeof r=="string"||r instanceof String)this.#e.url=""+r;else if(r instanceof t)Object.assign(this.#e,r.#e);else if(r instanceof Function)this.#t([r]);else if(r&&typeof r=="object")for(let e in r)e=="middlewares"?this.#t(r[e]):typeof r[e]=="function"?this.#e[e]=r[e](this.#e[e],this.#e):this.#e[e]=r[e];this.#e.verbs&&(this.#r=this.#e.verbs,delete this.#e.verbs);for(let r of this.#r)this[r]=async function(...e){return this.fetch(b(this.#e,...e,{method:r.toUpperCase()}))};Object.freeze(this)}#t(o){typeof o=="function"&&(o=[o]);let r=o.findIndex(e=>typeof e!="function");if(r>=0)throw f("metro.client: middlewares must be a function or an array of functions "+y+"client/invalid-middlewares-value/",o[r]);Array.isArray(this.#e.middlewares)||(this.#e.middlewares=[]),this.#e.middlewares=this.#e.middlewares.concat(o)}fetch(o,r){if(o=b(o,r),!o.url)throw f("metro.client."+o.method.toLowerCase()+": Missing url parameter "+y+"client/missing-url-param/",o);if(r||(r={}),typeof r!="object"||Array.isArray(r)||r instanceof String)throw f("metro.client.fetch: Options is not an object");let n=[async function(s){if(s[Symbol.metroProxy])if(s.body&&s.body[Symbol.metroSource]){let h=s.body[Symbol.metroSource];s=new Request(s[Symbol.metroSource],{body:h})}else s=s[Symbol.metroSource];let l=await fetch(s);return P(l)}].concat(this.#e?.middlewares?.slice()||[]);r=Object.assign({},this.#e,r);let i;for(let a of n)i=function(s,l){return async function(h){let p,k=Object.values(t.tracers);for(let c of k)c.request&&c.request.call(c,h,l);p=await l(h,s);for(let c of k)c.response&&c.response.call(c,p,l);return p}}(i,a);return i(o)}with(...o){return new t(this,...o)}};function A(...t){return new u(...t)}function w(t,o){let r=o.body;return r||(t===null?r=new ReadableStream:t instanceof ReadableStream?r=t:t instanceof Blob?r=t.stream():r=new ReadableStream({start(e){let n;switch(typeof t){case"object":if(typeof t.toString=="function")n=t.toString();else if(t instanceof FormData)n=new URLSearchParams(t).toString();else if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))n=t;else throw f("Cannot convert body to ReadableStream",t);break;case"string":case"number":case"boolean":n=t;break;default:throw f("Cannot convert body to ReadableStream",t)}e.enqueue(n),e.close()}})),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return t;case"toString":return function(){return""+t}}if(t&&typeof t=="object"&&n in t)return typeof t[n]=="function"?function(...a){return t[n].apply(t,a)}:t[n];if(n in e&&n!="toString")return typeof e[n]=="function"?function(...a){return e[n].apply(e,a)}:e[n]},has(e,n){return t&&typeof t=="object"?n in t:n in e},ownKeys(e){return Reflect.ownKeys(t&&typeof t=="object"?t:e)},getOwnPropertyDescriptor(e,n){return Object.getOwnPropertyDescriptor(t&&typeof t=="object"?t:e,n)}})}function L(t,o){let r=o||{};!r.url&&o.url&&(r.url=o.url);for(let e of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"])if(typeof t[e]=="function")t[e](r[e],r);else if(typeof t[e]<"u")if(e=="url")r.url=d(r.url,t.url);else if(e=="headers"){r.headers=new Headers(o.headers),t.headers instanceof Headers||(t.headers=new Headers(t.headers));for(let[n,i]of t.headers.entries())r.headers.set(n,i)}else r[e]=t[e];return r}function b(...t){let o={url:typeof window<"u"?window.location:"https://localhost/",duplex:"half"};for(let n of t)typeof n=="string"||n instanceof URL||n instanceof URLSearchParams?o.url=d(o.url,n):n&&(n instanceof FormData||n instanceof ReadableStream||n instanceof Blob||n instanceof ArrayBuffer||n instanceof DataView)?o.body=n:n&&typeof n=="object"&&Object.assign(o,L(n,o));let r=o.body;r&&typeof r=="object"&&!(r instanceof String)&&!(r instanceof ReadableStream)&&!(r instanceof Blob)&&!(r instanceof ArrayBuffer)&&!(r instanceof DataView)&&!(r instanceof FormData)&&!(r instanceof URLSearchParams)&&(typeof TypedArray>"u"||!(r instanceof TypedArray))&&(o.body=JSON.stringify(r));let e=new Request(o.url,o);return Object.freeze(e),new Proxy(e,{get(n,i,a){switch(i){case Symbol.metroSource:return n;case Symbol.metroProxy:return!0;case"with":return function(...s){return r&&s.unshift({body:r}),b(n,...s)};case"body":if(r||(r=n.body),r)return r[Symbol.metroProxy]?r:w(r,n);break}return n[i]instanceof Function?n[i].bind(n):n[i]}})}function R(t,o){let r=o||{};!r.url&&o.url&&(r.url=o.url);for(let e of["status","statusText","headers","body","url","type","redirected"])typeof t[e]=="function"?t[e](r[e],r):typeof t[e]<"u"&&(e=="url"?r.url=new URL(t.url,r.url||"https://localhost/"):r[e]=t[e]);return r}function P(...t){let o={};for(let e of t)typeof e=="string"?o.body=e:e instanceof Response?Object.assign(o,R(e,o)):e&&typeof e=="object"&&(e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||e instanceof DataView||e instanceof ReadableStream||e instanceof URLSearchParams||e instanceof String||typeof TypedArray<"u"&&e instanceof TypedArray?o.body=e:Object.assign(o,R(e,o)));let r=new Response(o.body,o);return Object.freeze(r),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...a){return P(e,...a)};case"body":return o.body?o.body[Symbol.metroProxy]?o.body:w(o.body,e):w("",e);case"ok":return e.status>=200&&e.status<400;case"headers":return e.headers;default:if(n in o&&n!="toString")return o[n];if(n in e&&n!="toString")return typeof e[n]=="function"?function(...a){return e[n].apply(e,a)}:e[n];break}}})}function x(t,o){typeof o=="function"?o(t.searchParams,t):(o=new URLSearchParams(o),o.forEach((r,e)=>{t.searchParams.append(e,r)}))}function d(...t){let o=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],r=new URL("https://localhost/");for(let e of t)if(typeof e=="string"||e instanceof String)r=new URL(e,r);else if(e instanceof URL||typeof Location<"u"&&e instanceof Location)r=new URL(e);else if(e instanceof URLSearchParams)x(r,e);else if(e&&typeof e=="object")for(let n in e)if(n=="search")typeof e.search=="function"?e.search(r.search,r):r.search=new URLSearchParams(e.search);else if(n=="searchParams")x(r,e.searchParams);else{if(!o.includes(n))throw f("metro.url: unknown url parameter "+y+"url/unknown-param-name/",n);if(typeof e[n]=="function")e[n](r[n],r);else if(typeof e[n]=="string"||e[n]instanceof String||typeof e[n]=="number"||e[n]instanceof Number||typeof e[n]=="boolean"||e[n]instanceof Boolean)r[n]=""+e[n];else if(typeof e[n]=="object"&&e[n].toString)r[n]=e[n].toString();else throw f("metro.url: unsupported value for "+n+" "+y+"url/unsupported-param-value/",t[n])}else throw f("metro.url: unsupported option value "+y+"url/unsupported-option-value/",e);return Object.freeze(r),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...a){return d(e,...a)}}return e[n]instanceof Function?e[n].bind(e):e[n]}})}function v(...t){var o=new FormData;for(let r of t)if(r instanceof FormData)for(let e of r.entries())o.append(e[0],e[1]);else if(r&&typeof r=="object")for(let e of Object.entries(r))if(Array.isArray(e[1]))for(let n of e[1])o.append(e[0],n);else o.append(e[0],e[1]);else throw new f("metro.formdata: unknown option type, only FormData or Object supported",r);return Object.freeze(o),new Proxy(o,{get:(r,e,n)=>{switch(e){case Symbol.metroProxy:return!0;case Symbol.metroSource:return r;case"with":return function(...i){return v(r,...i)}}return r[e]instanceof Function?r[e].bind(r):r[e]}})}var m={error:(t,...o)=>{console.error("\u24C2\uFE0F ",t,...o)},info:(t,...o)=>{console.info("\u24C2\uFE0F ",t,...o)},group:t=>{console.group("\u24C2\uFE0F "+t)},groupEnd:t=>{console.groupEnd("\u24C2\uFE0F "+t)}};function f(t,...o){return m.error(t,...o),new Error(t,...o)}var S={add(t,o){u.tracers[t]=o},delete(t){delete u.tracers[t]},clear(){u.tracers={}},group(){let t=0;return{request:(o,r)=>{t++,m.group(t),m.info(o?.url,o,r)},response:(o,r)=>{m.info(o?.body?o.body[Symbol.metroSource]:null,o,r),m.groupEnd(t),t--}}}};S.add("group",S.group());window.metro=j;})(); +(()=>{var v=Object.defineProperty;var O=(t,o)=>{for(var r in o)v(t,r,{get:o[r],enumerable:!0})};var p={};O(p,{client:()=>A,formdata:()=>R,metroError:()=>f,request:()=>b,response:()=>P,trace:()=>L,url:()=>d});var y="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var u=class t{#e={url:typeof window<"u"?window.location:"https://localhost"};#r=["get","post","put","delete","patch","head","options","query"];static tracers={};constructor(...o){for(let r of o)if(typeof r=="string"||r instanceof String)this.#e.url=""+r;else if(r instanceof t)Object.assign(this.#e,r.#e);else if(r instanceof Function)this.#t([r]);else if(r&&typeof r=="object")for(let e in r)e=="middlewares"?this.#t(r[e]):typeof r[e]=="function"?this.#e[e]=r[e](this.#e[e],this.#e):this.#e[e]=r[e];this.#e.verbs&&(this.#r=this.#e.verbs,delete this.#e.verbs);for(let r of this.#r)this[r]=async function(...e){return this.fetch(b(this.#e,...e,{method:r.toUpperCase()}))};Object.freeze(this)}#t(o){typeof o=="function"&&(o=[o]);let r=o.findIndex(e=>typeof e!="function");if(r>=0)throw f("metro.client: middlewares must be a function or an array of functions "+y+"client/invalid-middlewares-value/",o[r]);Array.isArray(this.#e.middlewares)||(this.#e.middlewares=[]),this.#e.middlewares=this.#e.middlewares.concat(o)}fetch(o,r){if(o=b(o,r),!o.url)throw f("metro.client."+o.method.toLowerCase()+": Missing url parameter "+y+"client/missing-url-param/",o);if(r||(r={}),typeof r!="object"||Array.isArray(r)||r instanceof String)throw f("metro.client.fetch: Options is not an object");let n=[async function(s){if(s[Symbol.metroProxy])if(s.body&&s.body[Symbol.metroSource]){let h=s.body[Symbol.metroSource];s=new Request(s[Symbol.metroSource],{body:h})}else s=s[Symbol.metroSource];let l=await fetch(s);return P(l)}].concat(this.#e?.middlewares?.slice()||[]);r=Object.assign({},this.#e,r);let i;for(let a of n)i=function(s,l){return async function(h){let w,j=Object.values(t.tracers);for(let c of j)c.request&&c.request.call(c,h,l);w=await l(h,s);for(let c of j)c.response&&c.response.call(c,w,l);return w}}(i,a);return i(o)}with(...o){return new t(this,...o)}};function A(...t){return new u(...t)}function S(t,o){let r=o.body;return r||(t===null?r=new ReadableStream:t instanceof ReadableStream?r=t:t instanceof Blob?r=t.stream():r=new ReadableStream({start(e){let n;switch(typeof t){case"object":if(typeof t.toString=="function")n=t.toString();else if(t instanceof FormData)n=new URLSearchParams(t).toString();else if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))n=t;else throw f("Cannot convert body to ReadableStream",t);break;case"string":case"number":case"boolean":n=t;break;default:throw f("Cannot convert body to ReadableStream",t)}e.enqueue(n),e.close()}})),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return t;case"toString":return function(){return""+t}}if(t&&typeof t=="object"&&n in t)return typeof t[n]=="function"?function(...a){return t[n].apply(t,a)}:t[n];if(n in e&&n!="toString")return typeof e[n]=="function"?function(...a){return e[n].apply(e,a)}:e[n]},has(e,n){return t&&typeof t=="object"?n in t:n in e},ownKeys(e){return Reflect.ownKeys(t&&typeof t=="object"?t:e)},getOwnPropertyDescriptor(e,n){return Object.getOwnPropertyDescriptor(t&&typeof t=="object"?t:e,n)}})}function g(t,o){let r=o||{};!r.url&&o.url&&(r.url=o.url);for(let e of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"])if(typeof t[e]=="function")t[e](r[e],r);else if(typeof t[e]<"u")if(e=="url")r.url=d(r.url,t.url);else if(e=="headers"){r.headers=new Headers(o.headers),t.headers instanceof Headers||(t.headers=new Headers(t.headers));for(let[n,i]of t.headers.entries())r.headers.set(n,i)}else r[e]=t[e];return r}function b(...t){let o={url:typeof window<"u"?window.location:"https://localhost/",duplex:"half"};for(let n of t)typeof n=="string"||n instanceof URL||n instanceof URLSearchParams?o.url=d(o.url,n):n&&(n instanceof FormData||n instanceof ReadableStream||n instanceof Blob||n instanceof ArrayBuffer||n instanceof DataView)?o.body=n:n&&typeof n=="object"&&Object.assign(o,g(n,o));let r=o.body;r&&typeof r=="object"&&!(r instanceof String)&&!(r instanceof ReadableStream)&&!(r instanceof Blob)&&!(r instanceof ArrayBuffer)&&!(r instanceof DataView)&&!(r instanceof FormData)&&!(r instanceof URLSearchParams)&&(typeof TypedArray>"u"||!(r instanceof TypedArray))&&(o.body=JSON.stringify(r));let e=new Request(o.url,o);return Object.freeze(e),new Proxy(e,{get(n,i,a){switch(i){case Symbol.metroSource:return n;case Symbol.metroProxy:return!0;case"with":return function(...s){return r&&s.unshift({body:r}),b(n,...s)};case"body":if(r||(r=n.body),r)return r[Symbol.metroProxy]?r:S(r,n);break}return n[i]instanceof Function?n[i].bind(n):n[i]}})}function k(t,o){let r=o||{};!r.url&&o.url&&(r.url=o.url);for(let e of["status","statusText","headers","body","url","type","redirected"])typeof t[e]=="function"?t[e](r[e],r):typeof t[e]<"u"&&(e=="url"?r.url=new URL(t.url,r.url||"https://localhost/"):r[e]=t[e]);return r}function P(...t){let o={};for(let e of t)typeof e=="string"?o.body=e:e instanceof Response?Object.assign(o,k(e,o)):e&&typeof e=="object"&&(e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||e instanceof DataView||e instanceof ReadableStream||e instanceof URLSearchParams||e instanceof String||typeof TypedArray<"u"&&e instanceof TypedArray?o.body=e:Object.assign(o,k(e,o)));let r=new Response(o.body,o);return Object.freeze(r),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...a){return P(e,...a)};case"body":return o.body?o.body[Symbol.metroProxy]?o.body:S(o.body,e):S("",e);case"ok":return e.status>=200&&e.status<400;case"headers":return e.headers;default:if(n in o&&n!="toString")return o[n];if(n in e&&n!="toString")return typeof e[n]=="function"?function(...a){return e[n].apply(e,a)}:e[n];break}}})}function x(t,o){typeof o=="function"?o(t.searchParams,t):(o=new URLSearchParams(o),o.forEach((r,e)=>{t.searchParams.append(e,r)}))}function d(...t){let o=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],r=new URL("https://localhost/");for(let e of t)if(typeof e=="string"||e instanceof String)r=new URL(e,r);else if(e instanceof URL||typeof Location<"u"&&e instanceof Location)r=new URL(e);else if(e instanceof URLSearchParams)x(r,e);else if(e&&typeof e=="object")for(let n in e)if(n=="search")typeof e.search=="function"?e.search(r.search,r):r.search=new URLSearchParams(e.search);else if(n=="searchParams")x(r,e.searchParams);else{if(!o.includes(n))throw f("metro.url: unknown url parameter "+y+"url/unknown-param-name/",n);if(typeof e[n]=="function")e[n](r[n],r);else if(typeof e[n]=="string"||e[n]instanceof String||typeof e[n]=="number"||e[n]instanceof Number||typeof e[n]=="boolean"||e[n]instanceof Boolean)r[n]=""+e[n];else if(typeof e[n]=="object"&&e[n].toString)r[n]=e[n].toString();else throw f("metro.url: unsupported value for "+n+" "+y+"url/unsupported-param-value/",t[n])}else throw f("metro.url: unsupported option value "+y+"url/unsupported-option-value/",e);return Object.freeze(r),new Proxy(r,{get(e,n,i){switch(n){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...a){return d(e,...a)}}return e[n]instanceof Function?e[n].bind(e):e[n]}})}function R(...t){var o=new FormData;for(let r of t)if(r instanceof FormData)for(let e of r.entries())o.append(e[0],e[1]);else if(r&&typeof r=="object")for(let e of Object.entries(r))if(Array.isArray(e[1]))for(let n of e[1])o.append(e[0],n);else o.append(e[0],e[1]);else throw new f("metro.formdata: unknown option type, only FormData or Object supported",r);return Object.freeze(o),new Proxy(o,{get:(r,e,n)=>{switch(e){case Symbol.metroProxy:return!0;case Symbol.metroSource:return r;case"with":return function(...i){return R(r,...i)}}return r[e]instanceof Function?r[e].bind(r):r[e]}})}var m={error:(t,...o)=>{console.error("\u24C2\uFE0F ",t,...o)},info:(t,...o)=>{console.info("\u24C2\uFE0F ",t,...o)},group:t=>{console.group("\u24C2\uFE0F "+t)},groupEnd:t=>{console.groupEnd("\u24C2\uFE0F "+t)}};function f(t,...o){return m.error(t,...o),new Error(t,...o)}var L={add(t,o){u.tracers[t]=o},delete(t){delete u.tracers[t]},clear(){u.tracers={}},group(){let t=0;return{request:(o,r)=>{t++,m.group(t),m.info(o?.url,o,r)},response:(o,r)=>{m.info(o?.body?o.body[Symbol.metroSource]:null,o,r),m.groupEnd(t),t--}}}};globalThis.metro=p;var D=p;})(); //# sourceMappingURL=browser.min.js.map diff --git a/dist/browser.min.js.map b/dist/browser.min.js.map index 704aadd..78f302e 100644 --- a/dist/browser.min.js.map +++ b/dist/browser.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/metro.mjs", "../src/browser.mjs"], - "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n\ntrace.add('group', trace.group())", "import * as metro from './metro.mjs'\n\nwindow.metro = metro\n"], - "mappings": "gGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,UAAAC,EAAA,QAAAC,IAGA,IAAMC,EAAW,iCAOZ,OAAO,aACX,OAAO,WAAa,OAAO,SAAS,GAEhC,OAAO,cACX,OAAO,YAAc,OAAO,QAAQ,GAcrC,IAAMC,EAAN,MAAMC,CACN,CACCC,GAAW,CACV,IAAK,OAAO,OAAU,IAAc,OAAO,SAAW,mBACvD,EACAC,GAAS,CAAC,MAAM,OAAO,MAAM,SAAS,QAAQ,OAAO,UAAU,OAAO,EAEtE,OAAO,QAAU,CAAC,EAYlB,eAAeC,EACf,CACC,QAASC,KAAUD,EAClB,GAAI,OAAOC,GAAU,UAAYA,aAAkB,OAClD,KAAKH,GAAS,IAAM,GAAGG,UACbA,aAAkBJ,EAC5B,OAAO,OAAO,KAAKC,GAAUG,EAAOH,EAAQ,UAClCG,aAAkB,SAC5B,KAAKC,GAAgB,CAACD,CAAM,CAAC,UACnBA,GAAU,OAAOA,GAAU,SACrC,QAASE,KAASF,EACbE,GAAS,cACZ,KAAKD,GAAgBD,EAAOE,CAAK,CAAC,EACxB,OAAOF,EAAOE,CAAK,GAAK,WAClC,KAAKL,GAASK,CAAK,EAAIF,EAAOE,CAAK,EA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", "formdata", "metroError", "request", "response", "trace", "url", "metroURL", "Client", "_Client", "#options", "#verbs", "options", "option", "#addMiddlewares", "param", "verb", "middlewares", "index", "m", "req", "body", "res", "next", "middleware", "tracers", "tracer", "bodyProxy", "body", "r", "source", "controller", "chunk", "metroError", "target", "prop", "receiver", "args", "getRequestParams", "req", "current", "params", "url", "key", "value", "request", "options", "requestParams", "option", "getResponseParams", "res", "response", "responseParams", "appendSearchParams", "validParams", "u", "param", "metroURL", "formdata", "entry", "metroConsole", "message", "details", "name", "trace", "tracer", "Client", "group", "middleware", "metro_exports"] + "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n", "import * as metro from './metro.mjs'\n\nglobalThis.metro = metro\n\nexport default metro"], + "mappings": "gGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,UAAAC,EAAA,Q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,OAAAF,EAAa,MAAMC,EAAS,GAAGC,CAAO,EAC/B,IAAI,MAAMD,EAAS,GAAGC,CAAO,CACrC,CAMO,IAAME,EAAQ,CAMpB,IAAID,EAAME,EAAQ,CACjBC,EAAO,QAAQH,CAAI,EAAIE,CACxB,EAKA,OAAOF,EAAM,CACZ,OAAOG,EAAO,QAAQH,CAAI,CAC3B,EAIA,OAAQ,CACPG,EAAO,QAAU,CAAC,CACnB,EAMA,OAAQ,CACP,IAAIC,EAAQ,EACZ,MAAO,CACN,QAAS,CAAC5B,EAAK6B,IAAe,CAC7BD,IACAP,EAAa,MAAMO,CAAK,EACxBP,EAAa,KAAKrB,GAAK,IAAKA,EAAK6B,CAAU,CAC5C,EACA,SAAU,CAAClB,EAAKkB,IAAe,CAC9BR,EAAa,KAAKV,GAAK,KAAOA,EAAI,KAAK,OAAO,WAAW,EAAG,KAAMA,EAAKkB,CAAU,EACjFR,EAAa,SAASO,CAAK,EAC3BA,GACD,CACD,CACD,CACD,EC1wBA,WAAW,MAAQE,EAEnB,IAAOC,EAAQD", + "names": ["metro_exports", "__export", "client", "formdata", "metroError", "request", "response", "trace", "url", "metroURL", "Client", "_Client", "#options", "#verbs", "options", "option", "#addMiddlewares", "param", "verb", "middlewares", "index", "m", "req", "body", "res", "next", "middleware", "tracers", "tracer", "bodyProxy", "body", "r", "source", "controller", "chunk", "metroError", "target", "prop", "receiver", "args", "getRequestParams", "req", "current", "params", "url", "key", "value", "request", "options", "requestParams", "option", "getResponseParams", "res", "response", "responseParams", "appendSearchParams", "validParams", "u", "param", "metroURL", "formdata", "entry", "metroConsole", "message", "details", "name", "trace", "tracer", "Client", "group", "middleware", "metro_exports", "browser_default"] } diff --git a/dist/everything.js b/dist/everything.js index 81f7dae..620c927 100644 --- a/dist/everything.js +++ b/dist/everything.js @@ -618,7 +618,6 @@ }; } }; - trace.add("group", trace.group()); // src/mw/json.mjs function jsonmw(options) { @@ -680,7 +679,7 @@ thrower } }); - window.metro = metro; + globalThis.metro = metro; var everything_default = metro; })(); //# sourceMappingURL=everything.js.map diff --git a/dist/everything.js.map b/dist/everything.js.map index 7ce0076..2460c9b 100644 --- a/dist/everything.js.map +++ b/dist/everything.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/metro.mjs", "../src/mw/json.mjs", "../src/mw/thrower.mjs", "../src/everything.mjs"], - "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n\ntrace.add('group', trace.group())", "import * as metro from '../metro.mjs'\n\nexport default function jsonmw(options) {\n\toptions = Object.assign({\n\t\treviver: null,\n\t\treplacer: null,\n\t\tspace: ''\n\t}, options)\n\n\treturn async (req, next) => {\n\t\tif (['POST','PUT','PATCH','QUERY'].includes(req.method)) {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type':'application/json',\n\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (req.body && typeof req.body[Symbol.metroSource] == 'object') {\n\t\t\t\treq = req.with({\n\t\t\t\t\tbody: JSON.stringify(req.body[Symbol.metroSource], options.replacer, options.space)\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tlet res = await next(req)\n\t\tlet body = await res.text()\n\t\tlet json = JSON.parse(body, options.reviver)\n\t\treturn res.with({\n\t\t\tbody: json\n\t\t})\n\t}\n}", "import * as metro from '../metro.mjs'\n\nexport default function thrower(options) {\n\n\treturn async (req, next) => {\n\t\tlet res = await next(req)\n\t\tif (!res.ok) {\n\t\t\tif (options && typeof options[res.status] == 'function') {\n\t\t\t\tres = options[res.status].apply(res, req)\n\t\t\t} else {\n\t\t\t\tthrow new Error(res.status+': '+res.statusText, {\n\t\t\t\t\tcause: res\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\n}", "import * as m from './metro.mjs'\nimport jsonmw from './mw/json.mjs'\nimport thrower from './mw/thrower.mjs'\n\nconst metro = Object.assign({}, m, {\n\tmw: {\n\t\tjsonmw,\n\t\tthrower\n\t}\n})\n\nwindow.metro = metro\n\nexport default metro"], - "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,WAAW;AAOjB,MAAI,CAAC,OAAO,YAAY;AACvB,WAAO,aAAa,OAAO,SAAS;AAAA,EACrC;AACA,MAAI,CAAC,OAAO,aAAa;AACxB,WAAO,cAAc,OAAO,QAAQ;AAAA,EACrC;AAaA,MAAM,SAAN,MAAM,QACN;AAAA,IACC,WAAW;AAAA,MACV,KAAK,OAAO,UAAU,cAAc,OAAO,WAAW;AAAA,IACvD;AAAA,IACA,SAAS,CAAC,OAAM,QAAO,OAAM,UAAS,SAAQ,QAAO,WAAU,OAAO;AAAA,IAEtE,OAAO,UAAU,CAAC;AAAA;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AAS;AAAA,YACR,gBAAe;AAAA,YACH,UAAS;AAAA,UACtB;AAAA,QACD,CAAC;AACD,YAAI,IAAI,QAAQ,OAAO,IAAI,KAAK,OAAO,WAAW,KAAK,UAAU;AAChE,gBAAM,IAAI,KAAK;AAAA,YACd,MAAM,KAAK,UAAU,IAAI,KAAK,OAAO,WAAW,GAAG,QAAQ,UAAU,QAAQ,KAAK;AAAA,UACnF,CAAC;AAAA,QACF;AAAA,MACD,OAAO;AACN,cAAM,IAAI,KAAK;AAAA,UACd,SAAS;AAAA,YACF,UAAS;AAAA,UAChB;AAAA,QACD,CAAC;AAAA,MACF;AACA,UAAI,MAAM,MAAM,KAAK,GAAG;AACxB,UAAI,OAAO,MAAM,IAAI,KAAK;AAC1B,UAAI,OAAO,KAAK,MAAM,MAAM,QAAQ,OAAO;AAC3C,aAAO,IAAI,KAAK;AAAA,QACf,MAAM;AAAA,MACP,CAAC;AAAA,IACF;AAAA,EACD;;;AClCe,WAAR,QAAyB,SAAS;AAExC,WAAO,OAAO,KAAK,SAAS;AAC3B,UAAI,MAAM,MAAM,KAAK,GAAG;AACxB,UAAI,CAAC,IAAI,IAAI;AACZ,YAAI,WAAW,OAAO,QAAQ,IAAI,MAAM,KAAK,YAAY;AACxD,gBAAM,QAAQ,IAAI,MAAM,EAAE,MAAM,KAAK,GAAG;AAAA,QACzC,OAAO;AACN,gBAAM,IAAI,MAAM,IAAI,SAAO,OAAK,IAAI,YAAY;AAAA,YAC/C,OAAO;AAAA,UACR,CAAC;AAAA,QACF;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EAED;;;ACdA,MAAM,QAAQ,OAAO,OAAO,CAAC,GAAG,eAAG;AAAA,IAClC,IAAI;AAAA,MACH;AAAA,MACA;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,QAAQ;AAEf,MAAO,qBAAQ;", + "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n", "import * as metro from '../metro.mjs'\n\nexport default function jsonmw(options) {\n\toptions = Object.assign({\n\t\treviver: null,\n\t\treplacer: null,\n\t\tspace: ''\n\t}, options)\n\n\treturn async (req, next) => {\n\t\tif (['POST','PUT','PATCH','QUERY'].includes(req.method)) {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type':'application/json',\n\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (req.body && typeof req.body[Symbol.metroSource] == 'object') {\n\t\t\t\treq = req.with({\n\t\t\t\t\tbody: JSON.stringify(req.body[Symbol.metroSource], options.replacer, options.space)\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tlet res = await next(req)\n\t\tlet body = await res.text()\n\t\tlet json = JSON.parse(body, options.reviver)\n\t\treturn res.with({\n\t\t\tbody: json\n\t\t})\n\t}\n}", "import * as metro from '../metro.mjs'\n\nexport default function thrower(options) {\n\n\treturn async (req, next) => {\n\t\tlet res = await next(req)\n\t\tif (!res.ok) {\n\t\t\tif (options && typeof options[res.status] == 'function') {\n\t\t\t\tres = options[res.status].apply(res, req)\n\t\t\t} else {\n\t\t\t\tthrow new Error(res.status+': '+res.statusText, {\n\t\t\t\t\tcause: res\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\n}", "import * as m from './metro.mjs'\nimport jsonmw from './mw/json.mjs'\nimport thrower from './mw/thrower.mjs'\n\nconst metro = Object.assign({}, m, {\n\tmw: {\n\t\tjsonmw,\n\t\tthrower\n\t}\n})\n\nglobalThis.metro = metro\n\nexport default metro"], + "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,WAAW;AAOjB,MAAI,CAAC,OAAO,YAAY;AACvB,WAAO,aAAa,OAAO,SAAS;AAAA,EACrC;AACA,MAAI,CAAC,OAAO,aAAa;AACxB,WAAO,cAAc,OAAO,QAAQ;AAAA,EACrC;AAaA,MAAM,SAAN,MAAM,QACN;AAAA,IACC,WAAW;AAAA,MACV,KAAK,OAAO,UAAU,cAAc,OAAO,WAAW;AAAA,IACvD;AAAA,IACA,SAAS,CAAC,OAAM,QAAO,OAAM,UAAS,SAAQ,QAAO,WAAU,OAAO;AAAA,IAEtE,OAAO,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYlB,eAAe,SACf;AACC,eAAS,UAAU,SAAS;AAC3B,YAAI,OAAO,UAAU,YAAY,kBAAkB,QAAQ;AAC1D,eAAK,SAAS,MAAM,KAAG;AAAA,QACxB,WAAW,kBAAkB,SAAQ;AACpC,iBAAO,OAAO,KAAK,UAAU,OAAO,QAAQ;AAAA,QAC7C,WAAW,kBAAkB,UAAU;AACtC,eAAK,gBAAgB,CAAC,MA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A,QACD,CAAC;AAAA,MACF;AACA,UAAI,MAAM,MAAM,KAAK,GAAG;AACxB,UAAI,OAAO,MAAM,IAAI,KAAK;AAC1B,UAAI,OAAO,KAAK,MAAM,MAAM,QAAQ,OAAO;AAC3C,aAAO,IAAI,KAAK;AAAA,QACf,MAAM;AAAA,MACP,CAAC;AAAA,IACF;AAAA,EACD;;;AClCe,WAAR,QAAyB,SAAS;AAExC,WAAO,OAAO,KAAK,SAAS;AAC3B,UAAI,MAAM,MAAM,KAAK,GAAG;AACxB,UAAI,CAAC,IAAI,IAAI;AACZ,YAAI,WAAW,OAAO,QAAQ,IAAI,MAAM,KAAK,YAAY;AACxD,gBAAM,QAAQ,IAAI,MAAM,EAAE,MAAM,KAAK,GAAG;AAAA,QACzC,OAAO;AACN,gBAAM,IAAI,MAAM,IAAI,SAAO,OAAK,IAAI,YAAY;AAAA,YAC/C,OAAO;AAAA,UACR,CAAC;AAAA,QACF;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EAED;;;ACdA,MAAM,QAAQ,OAAO,OAAO,CAAC,GAAG,eAAG;AAAA,IAClC,IAAI;AAAA,MACH;AAAA,MACA;AAAA,IACD;AAAA,EACD,CAAC;AAED,aAAW,QAAQ;AAEnB,MAAO,qBAAQ;", "names": ["options", "req", "next", "middleware", "options", "url"] } diff --git a/dist/everything.min.js b/dist/everything.min.js index 07772e4..ae3d508 100644 --- a/dist/everything.min.js +++ b/dist/everything.min.js @@ -1,2 +1,2 @@ -(()=>{var L=Object.defineProperty;var U=(r,n)=>{for(var t in n)L(r,t,{get:n[t],enumerable:!0})};var j={};U(j,{client:()=>D,formdata:()=>g,metroError:()=>f,request:()=>b,response:()=>P,trace:()=>S,url:()=>d});var y="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var u=class r{#e={url:typeof window<"u"?window.location:"https://localhost"};#t=["get","post","put","delete","patch","head","options","query"];static tracers={};constructor(...n){for(let t of n)if(typeof t=="string"||t instanceof String)this.#e.url=""+t;else if(t instanceof r)Object.assign(this.#e,t.#e);else if(t instanceof Function)this.#r([t]);else if(t&&typeof t=="object")for(let e in t)e=="middlewares"?this.#r(t[e]):typeof t[e]=="function"?this.#e[e]=t[e](this.#e[e],this.#e):this.#e[e]=t[e];this.#e.verbs&&(this.#t=this.#e.verbs,delete this.#e.verbs);for(let t of this.#t)this[t]=async function(...e){return this.fetch(b(this.#e,...e,{method:t.toUpperCase()}))};Object.freeze(this)}#r(n){typeof n=="function"&&(n=[n]);let t=n.findIndex(e=>typeof e!="function");if(t>=0)throw f("metro.client: middlewares must be a function or an array of functions "+y+"client/invalid-middlewares-value/",n[t]);Array.isArray(this.#e.middlewares)||(this.#e.middlewares=[]),this.#e.middlewares=this.#e.middlewares.concat(n)}fetch(n,t){if(n=b(n,t),!n.url)throw f("metro.client."+n.method.toLowerCase()+": Missing url parameter "+y+"client/missing-url-param/",n);if(t||(t={}),typeof t!="object"||Array.isArray(t)||t instanceof String)throw f("metro.client.fetch: Options is not an object");let o=[async function(a){if(a[Symbol.metroProxy])if(a.body&&a.body[Symbol.metroSource]){let h=a.body[Symbol.metroSource];a=new Request(a[Symbol.metroSource],{body:h})}else a=a[Symbol.metroSource];let l=await fetch(a);return P(l)}].concat(this.#e?.middlewares?.slice()||[]);t=Object.assign({},this.#e,t);let i;for(let s of o)i=function(a,l){return async function(h){let p,R=Object.values(r.tracers);for(let c of R)c.request&&c.request.call(c,h,l);p=await l(h,a);for(let c of R)c.response&&c.response.call(c,p,l);return p}}(i,s);return i(n)}with(...n){return new r(this,...n)}};function D(...r){return new u(...r)}function w(r,n){let t=n.body;return t||(r===null?t=new ReadableStream:r instanceof ReadableStream?t=r:r instanceof Blob?t=r.stream():t=new ReadableStream({start(e){let o;switch(typeof r){case"object":if(typeof r.toString=="function")o=r.toString();else if(r instanceof FormData)o=new URLSearchParams(r).toString();else if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))o=r;else throw f("Cannot convert body to ReadableStream",r);break;case"string":case"number":case"boolean":o=r;break;default:throw f("Cannot convert body to ReadableStream",r)}e.enqueue(o),e.close()}})),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return r;case"toString":return function(){return""+r}}if(r&&typeof r=="object"&&o in r)return typeof r[o]=="function"?function(...s){return r[o].apply(r,s)}:r[o];if(o in e&&o!="toString")return typeof e[o]=="function"?function(...s){return e[o].apply(e,s)}:e[o]},has(e,o){return r&&typeof r=="object"?o in r:o in e},ownKeys(e){return Reflect.ownKeys(r&&typeof r=="object"?r:e)},getOwnPropertyDescriptor(e,o){return Object.getOwnPropertyDescriptor(r&&typeof r=="object"?r:e,o)}})}function F(r,n){let t=n||{};!t.url&&n.url&&(t.url=n.url);for(let e of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"])if(typeof r[e]=="function")r[e](t[e],t);else if(typeof r[e]<"u")if(e=="url")t.url=d(t.url,r.url);else if(e=="headers"){t.headers=new Headers(n.headers),r.headers instanceof Headers||(r.headers=new Headers(r.headers));for(let[o,i]of r.headers.entries())t.headers.set(o,i)}else t[e]=r[e];return t}function b(...r){let n={url:typeof window<"u"?window.location:"https://localhost/",duplex:"half"};for(let o of r)typeof o=="string"||o instanceof URL||o instanceof URLSearchParams?n.url=d(n.url,o):o&&(o instanceof FormData||o instanceof ReadableStream||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView)?n.body=o:o&&typeof o=="object"&&Object.assign(n,F(o,n));let t=n.body;t&&typeof t=="object"&&!(t instanceof String)&&!(t instanceof ReadableStream)&&!(t instanceof Blob)&&!(t instanceof ArrayBuffer)&&!(t instanceof DataView)&&!(t instanceof FormData)&&!(t instanceof URLSearchParams)&&(typeof TypedArray>"u"||!(t instanceof TypedArray))&&(n.body=JSON.stringify(t));let e=new Request(n.url,n);return Object.freeze(e),new Proxy(e,{get(o,i,s){switch(i){case Symbol.metroSource:return o;case Symbol.metroProxy:return!0;case"with":return function(...a){return t&&a.unshift({body:t}),b(o,...a)};case"body":if(t||(t=o.body),t)return t[Symbol.metroProxy]?t:w(t,o);break}return o[i]instanceof Function?o[i].bind(o):o[i]}})}function v(r,n){let t=n||{};!t.url&&n.url&&(t.url=n.url);for(let e of["status","statusText","headers","body","url","type","redirected"])typeof r[e]=="function"?r[e](t[e],t):typeof r[e]<"u"&&(e=="url"?t.url=new URL(r.url,t.url||"https://localhost/"):t[e]=r[e]);return t}function P(...r){let n={};for(let e of r)typeof e=="string"?n.body=e:e instanceof Response?Object.assign(n,v(e,n)):e&&typeof e=="object"&&(e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||e instanceof DataView||e instanceof ReadableStream||e instanceof URLSearchParams||e instanceof String||typeof TypedArray<"u"&&e instanceof TypedArray?n.body=e:Object.assign(n,v(e,n)));let t=new Response(n.body,n);return Object.freeze(t),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...s){return P(e,...s)};case"body":return n.body?n.body[Symbol.metroProxy]?n.body:w(n.body,e):w("",e);case"ok":return e.status>=200&&e.status<400;case"headers":return e.headers;default:if(o in n&&o!="toString")return n[o];if(o in e&&o!="toString")return typeof e[o]=="function"?function(...s){return e[o].apply(e,s)}:e[o];break}}})}function O(r,n){typeof n=="function"?n(r.searchParams,r):(n=new URLSearchParams(n),n.forEach((t,e)=>{r.searchParams.append(e,t)}))}function d(...r){let n=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],t=new URL("https://localhost/");for(let e of r)if(typeof e=="string"||e instanceof String)t=new URL(e,t);else if(e instanceof URL||typeof Location<"u"&&e instanceof Location)t=new URL(e);else if(e instanceof URLSearchParams)O(t,e);else if(e&&typeof e=="object")for(let o in e)if(o=="search")typeof e.search=="function"?e.search(t.search,t):t.search=new URLSearchParams(e.search);else if(o=="searchParams")O(t,e.searchParams);else{if(!n.includes(o))throw f("metro.url: unknown url parameter "+y+"url/unknown-param-name/",o);if(typeof e[o]=="function")e[o](t[o],t);else if(typeof e[o]=="string"||e[o]instanceof String||typeof e[o]=="number"||e[o]instanceof Number||typeof e[o]=="boolean"||e[o]instanceof Boolean)t[o]=""+e[o];else if(typeof e[o]=="object"&&e[o].toString)t[o]=e[o].toString();else throw f("metro.url: unsupported value for "+o+" "+y+"url/unsupported-param-value/",r[o])}else throw f("metro.url: unsupported option value "+y+"url/unsupported-option-value/",e);return Object.freeze(t),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...s){return d(e,...s)}}return e[o]instanceof Function?e[o].bind(e):e[o]}})}function g(...r){var n=new FormData;for(let t of r)if(t instanceof FormData)for(let e of t.entries())n.append(e[0],e[1]);else if(t&&typeof t=="object")for(let e of Object.entries(t))if(Array.isArray(e[1]))for(let o of e[1])n.append(e[0],o);else n.append(e[0],e[1]);else throw new f("metro.formdata: unknown option type, only FormData or Object supported",t);return Object.freeze(n),new Proxy(n,{get:(t,e,o)=>{switch(e){case Symbol.metroProxy:return!0;case Symbol.metroSource:return t;case"with":return function(...i){return g(t,...i)}}return t[e]instanceof Function?t[e].bind(t):t[e]}})}var m={error:(r,...n)=>{console.error("\u24C2\uFE0F ",r,...n)},info:(r,...n)=>{console.info("\u24C2\uFE0F ",r,...n)},group:r=>{console.group("\u24C2\uFE0F "+r)},groupEnd:r=>{console.groupEnd("\u24C2\uFE0F "+r)}};function f(r,...n){return m.error(r,...n),new Error(r,...n)}var S={add(r,n){u.tracers[r]=n},delete(r){delete u.tracers[r]},clear(){u.tracers={}},group(){let r=0;return{request:(n,t)=>{r++,m.group(r),m.info(n?.url,n,t)},response:(n,t)=>{m.info(n?.body?n.body[Symbol.metroSource]:null,n,t),m.groupEnd(r),r--}}}};S.add("group",S.group());function x(r){return r=Object.assign({reviver:null,replacer:null,space:""},r),async(n,t)=>{["POST","PUT","PATCH","QUERY"].includes(n.method)?(n=n.with({headers:{"Content-Type":"application/json",Accept:"application/json"}}),n.body&&typeof n.body[Symbol.metroSource]=="object"&&(n=n.with({body:JSON.stringify(n.body[Symbol.metroSource],r.replacer,r.space)}))):n=n.with({headers:{Accept:"application/json"}});let e=await t(n),o=await e.text(),i=JSON.parse(o,r.reviver);return e.with({body:i})}}function k(r){return async(n,t)=>{let e=await t(n);if(!e.ok)if(r&&typeof r[e.status]=="function")e=r[e.status].apply(e,n);else throw new Error(e.status+": "+e.statusText,{cause:e});return e}}var A=Object.assign({},j,{mw:{jsonmw:x,thrower:k}});window.metro=A;var V=A;})(); +(()=>{var g=Object.defineProperty;var L=(r,n)=>{for(var t in n)g(r,t,{get:n[t],enumerable:!0})};var P={};L(P,{client:()=>U,formdata:()=>O,metroError:()=>f,request:()=>b,response:()=>S,trace:()=>F,url:()=>d});var y="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var u=class r{#e={url:typeof window<"u"?window.location:"https://localhost"};#t=["get","post","put","delete","patch","head","options","query"];static tracers={};constructor(...n){for(let t of n)if(typeof t=="string"||t instanceof String)this.#e.url=""+t;else if(t instanceof r)Object.assign(this.#e,t.#e);else if(t instanceof Function)this.#r([t]);else if(t&&typeof t=="object")for(let e in t)e=="middlewares"?this.#r(t[e]):typeof t[e]=="function"?this.#e[e]=t[e](this.#e[e],this.#e):this.#e[e]=t[e];this.#e.verbs&&(this.#t=this.#e.verbs,delete this.#e.verbs);for(let t of this.#t)this[t]=async function(...e){return this.fetch(b(this.#e,...e,{method:t.toUpperCase()}))};Object.freeze(this)}#r(n){typeof n=="function"&&(n=[n]);let t=n.findIndex(e=>typeof e!="function");if(t>=0)throw f("metro.client: middlewares must be a function or an array of functions "+y+"client/invalid-middlewares-value/",n[t]);Array.isArray(this.#e.middlewares)||(this.#e.middlewares=[]),this.#e.middlewares=this.#e.middlewares.concat(n)}fetch(n,t){if(n=b(n,t),!n.url)throw f("metro.client."+n.method.toLowerCase()+": Missing url parameter "+y+"client/missing-url-param/",n);if(t||(t={}),typeof t!="object"||Array.isArray(t)||t instanceof String)throw f("metro.client.fetch: Options is not an object");let o=[async function(a){if(a[Symbol.metroProxy])if(a.body&&a.body[Symbol.metroSource]){let h=a.body[Symbol.metroSource];a=new Request(a[Symbol.metroSource],{body:h})}else a=a[Symbol.metroSource];let l=await fetch(a);return S(l)}].concat(this.#e?.middlewares?.slice()||[]);t=Object.assign({},this.#e,t);let i;for(let s of o)i=function(a,l){return async function(h){let p,k=Object.values(r.tracers);for(let c of k)c.request&&c.request.call(c,h,l);p=await l(h,a);for(let c of k)c.response&&c.response.call(c,p,l);return p}}(i,s);return i(n)}with(...n){return new r(this,...n)}};function U(...r){return new u(...r)}function w(r,n){let t=n.body;return t||(r===null?t=new ReadableStream:r instanceof ReadableStream?t=r:r instanceof Blob?t=r.stream():t=new ReadableStream({start(e){let o;switch(typeof r){case"object":if(typeof r.toString=="function")o=r.toString();else if(r instanceof FormData)o=new URLSearchParams(r).toString();else if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))o=r;else throw f("Cannot convert body to ReadableStream",r);break;case"string":case"number":case"boolean":o=r;break;default:throw f("Cannot convert body to ReadableStream",r)}e.enqueue(o),e.close()}})),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return r;case"toString":return function(){return""+r}}if(r&&typeof r=="object"&&o in r)return typeof r[o]=="function"?function(...s){return r[o].apply(r,s)}:r[o];if(o in e&&o!="toString")return typeof e[o]=="function"?function(...s){return e[o].apply(e,s)}:e[o]},has(e,o){return r&&typeof r=="object"?o in r:o in e},ownKeys(e){return Reflect.ownKeys(r&&typeof r=="object"?r:e)},getOwnPropertyDescriptor(e,o){return Object.getOwnPropertyDescriptor(r&&typeof r=="object"?r:e,o)}})}function D(r,n){let t=n||{};!t.url&&n.url&&(t.url=n.url);for(let e of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"])if(typeof r[e]=="function")r[e](t[e],t);else if(typeof r[e]<"u")if(e=="url")t.url=d(t.url,r.url);else if(e=="headers"){t.headers=new Headers(n.headers),r.headers instanceof Headers||(r.headers=new Headers(r.headers));for(let[o,i]of r.headers.entries())t.headers.set(o,i)}else t[e]=r[e];return t}function b(...r){let n={url:typeof window<"u"?window.location:"https://localhost/",duplex:"half"};for(let o of r)typeof o=="string"||o instanceof URL||o instanceof URLSearchParams?n.url=d(n.url,o):o&&(o instanceof FormData||o instanceof ReadableStream||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView)?n.body=o:o&&typeof o=="object"&&Object.assign(n,D(o,n));let t=n.body;t&&typeof t=="object"&&!(t instanceof String)&&!(t instanceof ReadableStream)&&!(t instanceof Blob)&&!(t instanceof ArrayBuffer)&&!(t instanceof DataView)&&!(t instanceof FormData)&&!(t instanceof URLSearchParams)&&(typeof TypedArray>"u"||!(t instanceof TypedArray))&&(n.body=JSON.stringify(t));let e=new Request(n.url,n);return Object.freeze(e),new Proxy(e,{get(o,i,s){switch(i){case Symbol.metroSource:return o;case Symbol.metroProxy:return!0;case"with":return function(...a){return t&&a.unshift({body:t}),b(o,...a)};case"body":if(t||(t=o.body),t)return t[Symbol.metroProxy]?t:w(t,o);break}return o[i]instanceof Function?o[i].bind(o):o[i]}})}function R(r,n){let t=n||{};!t.url&&n.url&&(t.url=n.url);for(let e of["status","statusText","headers","body","url","type","redirected"])typeof r[e]=="function"?r[e](t[e],t):typeof r[e]<"u"&&(e=="url"?t.url=new URL(r.url,t.url||"https://localhost/"):t[e]=r[e]);return t}function S(...r){let n={};for(let e of r)typeof e=="string"?n.body=e:e instanceof Response?Object.assign(n,R(e,n)):e&&typeof e=="object"&&(e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||e instanceof DataView||e instanceof ReadableStream||e instanceof URLSearchParams||e instanceof String||typeof TypedArray<"u"&&e instanceof TypedArray?n.body=e:Object.assign(n,R(e,n)));let t=new Response(n.body,n);return Object.freeze(t),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...s){return S(e,...s)};case"body":return n.body?n.body[Symbol.metroProxy]?n.body:w(n.body,e):w("",e);case"ok":return e.status>=200&&e.status<400;case"headers":return e.headers;default:if(o in n&&o!="toString")return n[o];if(o in e&&o!="toString")return typeof e[o]=="function"?function(...s){return e[o].apply(e,s)}:e[o];break}}})}function v(r,n){typeof n=="function"?n(r.searchParams,r):(n=new URLSearchParams(n),n.forEach((t,e)=>{r.searchParams.append(e,t)}))}function d(...r){let n=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],t=new URL("https://localhost/");for(let e of r)if(typeof e=="string"||e instanceof String)t=new URL(e,t);else if(e instanceof URL||typeof Location<"u"&&e instanceof Location)t=new URL(e);else if(e instanceof URLSearchParams)v(t,e);else if(e&&typeof e=="object")for(let o in e)if(o=="search")typeof e.search=="function"?e.search(t.search,t):t.search=new URLSearchParams(e.search);else if(o=="searchParams")v(t,e.searchParams);else{if(!n.includes(o))throw f("metro.url: unknown url parameter "+y+"url/unknown-param-name/",o);if(typeof e[o]=="function")e[o](t[o],t);else if(typeof e[o]=="string"||e[o]instanceof String||typeof e[o]=="number"||e[o]instanceof Number||typeof e[o]=="boolean"||e[o]instanceof Boolean)t[o]=""+e[o];else if(typeof e[o]=="object"&&e[o].toString)t[o]=e[o].toString();else throw f("metro.url: unsupported value for "+o+" "+y+"url/unsupported-param-value/",r[o])}else throw f("metro.url: unsupported option value "+y+"url/unsupported-option-value/",e);return Object.freeze(t),new Proxy(t,{get(e,o,i){switch(o){case Symbol.metroProxy:return!0;case Symbol.metroSource:return e;case"with":return function(...s){return d(e,...s)}}return e[o]instanceof Function?e[o].bind(e):e[o]}})}function O(...r){var n=new FormData;for(let t of r)if(t instanceof FormData)for(let e of t.entries())n.append(e[0],e[1]);else if(t&&typeof t=="object")for(let e of Object.entries(t))if(Array.isArray(e[1]))for(let o of e[1])n.append(e[0],o);else n.append(e[0],e[1]);else throw new f("metro.formdata: unknown option type, only FormData or Object supported",t);return Object.freeze(n),new Proxy(n,{get:(t,e,o)=>{switch(e){case Symbol.metroProxy:return!0;case Symbol.metroSource:return t;case"with":return function(...i){return O(t,...i)}}return t[e]instanceof Function?t[e].bind(t):t[e]}})}var m={error:(r,...n)=>{console.error("\u24C2\uFE0F ",r,...n)},info:(r,...n)=>{console.info("\u24C2\uFE0F ",r,...n)},group:r=>{console.group("\u24C2\uFE0F "+r)},groupEnd:r=>{console.groupEnd("\u24C2\uFE0F "+r)}};function f(r,...n){return m.error(r,...n),new Error(r,...n)}var F={add(r,n){u.tracers[r]=n},delete(r){delete u.tracers[r]},clear(){u.tracers={}},group(){let r=0;return{request:(n,t)=>{r++,m.group(r),m.info(n?.url,n,t)},response:(n,t)=>{m.info(n?.body?n.body[Symbol.metroSource]:null,n,t),m.groupEnd(r),r--}}}};function j(r){return r=Object.assign({reviver:null,replacer:null,space:""},r),async(n,t)=>{["POST","PUT","PATCH","QUERY"].includes(n.method)?(n=n.with({headers:{"Content-Type":"application/json",Accept:"application/json"}}),n.body&&typeof n.body[Symbol.metroSource]=="object"&&(n=n.with({body:JSON.stringify(n.body[Symbol.metroSource],r.replacer,r.space)}))):n=n.with({headers:{Accept:"application/json"}});let e=await t(n),o=await e.text(),i=JSON.parse(o,r.reviver);return e.with({body:i})}}function x(r){return async(n,t)=>{let e=await t(n);if(!e.ok)if(r&&typeof r[e.status]=="function")e=r[e.status].apply(e,n);else throw new Error(e.status+": "+e.statusText,{cause:e});return e}}var A=Object.assign({},P,{mw:{jsonmw:j,thrower:x}});globalThis.metro=A;var V=A;})(); //# sourceMappingURL=everything.min.js.map diff --git a/dist/everything.min.js.map b/dist/everything.min.js.map index c1f3f99..5210299 100644 --- a/dist/everything.min.js.map +++ b/dist/everything.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/metro.mjs", "../src/mw/json.mjs", "../src/mw/thrower.mjs", "../src/everything.mjs"], - "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n\ntrace.add('group', trace.group())", "import * as metro from '../metro.mjs'\n\nexport default function jsonmw(options) {\n\toptions = Object.assign({\n\t\treviver: null,\n\t\treplacer: null,\n\t\tspace: ''\n\t}, options)\n\n\treturn async (req, next) => {\n\t\tif (['POST','PUT','PATCH','QUERY'].includes(req.method)) {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type':'application/json',\n\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (req.body && typeof req.body[Symbol.metroSource] == 'object') {\n\t\t\t\treq = req.with({\n\t\t\t\t\tbody: JSON.stringify(req.body[Symbol.metroSource], options.replacer, options.space)\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tlet res = await next(req)\n\t\tlet body = await res.text()\n\t\tlet json = JSON.parse(body, options.reviver)\n\t\treturn res.with({\n\t\t\tbody: json\n\t\t})\n\t}\n}", "import * as metro from '../metro.mjs'\n\nexport default function thrower(options) {\n\n\treturn async (req, next) => {\n\t\tlet res = await next(req)\n\t\tif (!res.ok) {\n\t\t\tif (options && typeof options[res.status] == 'function') {\n\t\t\t\tres = options[res.status].apply(res, req)\n\t\t\t} else {\n\t\t\t\tthrow new Error(res.status+': '+res.statusText, {\n\t\t\t\t\tcause: res\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\n}", "import * as m from './metro.mjs'\nimport jsonmw from './mw/json.mjs'\nimport thrower from './mw/thrower.mjs'\n\nconst metro = Object.assign({}, m, {\n\tmw: {\n\t\tjsonmw,\n\t\tthrower\n\t}\n})\n\nwindow.metro = metro\n\nexport default metro"], - "mappings": "gGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,UAAAC,EAAA,QAAAC,IAGA,IAAMC,EAAW,iCAOZ,OAAO,aACX,OAAO,WAAa,OAAO,SAAS,GAEhC,OAAO,cACX,OAAO,YAAc,OAAO,QAAQ,GAcrC,IAAMC,EAAN,MAAMC,CACN,CACCC,GAAW,CACV,IAAK,OAAO,OAAU,IAAc,OAAO,SAAW,mBACvD,EACAC,GAAS,CAAC,MAAM,OAAO,MAAM,SAAS,QAAQ,OAAO,UAAU,OAAO,EAEtE,OAAO,QAAU,CAAC,EAYlB,eAAeC,EACf,CACC,QAASC,KAAUD,EAClB,GAAI,OAAOC,GAAU,UAAYA,aAAkB,OAClD,KAAKH,GAAS,IAAM,GAAGG,UACbA,aAAkBJ,EAC5B,OAAO,OAAO,KAAKC,GAAUG,EAAOH,EAAQ,UAClCG,aAAkB,SAC5B,KAAKC,GAAgB,CAACD,CAAM,CAAC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,CAClC,GAAI,CACH,OAAAC,EACA,QAAAC,CACD,CACD,CAAC,EAED,OAAO,MAAQH,EAEf,IAAOI,EAAQJ", + "sourcesContent": ["/**\n * base URL used to link to more information about an error message\n */\nconst metroURL = 'https://metro.muze.nl/details/'\n\n/**\n * Symbols:\n * - isProxy: used to test if an object is a metro Proxy to another object\n * - source: used to return the actual source (target) of a metro Proxy\n */\nif (!Symbol.metroProxy) {\n\tSymbol.metroProxy = Symbol('isProxy')\n}\nif (!Symbol.metroSource) {\n\tSymbol.metroSource = Symbol('source')\n}\n\n/**\n * Metro HTTP Client with middleware support\n * @method get\n * @method post\n * @method put\n * @method delete\n * @method patch\n * @method head\n * @method options\n * @method query\n */\nclass Client\n{\n\t#options = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost'\n\t}\n\t#verbs = ['get','post','put','delete','patch','head','options','query']\n\n\tstatic tracers = {}\n\n\t/**\n\t * @typedef {Object} ClientOptions\n\t * @property {Array} middlewares - list of middleware functions\n\t * @property {string|URL} url - default url of the client\n\t * @property {[string]} verbs - a list of verb methods to expose, e.g. ['get','post']\n\t * \n\t * Constructs a new metro client. Can have any number of params.\n\t * @params {ClientOptions|URL|Function|Client}\n\t * @returns {Client} - A metro client object with given or default verb methods\n\t */\n\tconstructor(...options)\n\t{\n\t\tfor (let option of options) {\n\t\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t\tthis.#options.url = ''+option\n\t\t\t} else if (option instanceof Client) {\n\t\t\t\tObject.assign(this.#options, option.#options)\n\t\t\t} else if (option instanceof Function) {\n\t\t\t\tthis.#addMiddlewares([option])\n\t\t\t} else if (option && typeof option == 'object') {\n\t\t\t\tfor (let param in option) {\n\t\t\t\t\tif (param == 'middlewares') {\n\t\t\t\t\t\tthis.#addMiddlewares(option[param])\n\t\t\t\t\t} else if (typeof option[param] == 'function') {\n\t\t\t\t\t\tthis.#options[param] = option[param](this.#options[param], this.#options)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#options[param] = option[param]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.#options.verbs) {\n\t\t\tthis.#verbs = this.#options.verbs\n\t\t\tdelete this.#options.verbs\n\t\t}\n\n\t\tfor (const verb of this.#verbs) {\n\t\t\tthis[verb] = async function(...options) {\n\t\t\t\treturn this.fetch(request(\n\t\t\t\t\tthis.#options,\n\t\t\t\t\t...options,\n\t\t\t\t\t{method: verb.toUpperCase()}\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\n\t#addMiddlewares(middlewares)\n\t{\n\t\tif (typeof middlewares == 'function') {\n\t\t\tmiddlewares = [ middlewares ]\n\t\t}\n\t\tlet index = middlewares.findIndex(m => typeof m != 'function')\n\t\tif (index>=0) {\n\t\t\tthrow metroError('metro.client: middlewares must be a function or an array of functions '\n\t\t\t\t+metroURL+'client/invalid-middlewares-value/', middlewares[index])\n\t\t}\n\t\tif (!Array.isArray(this.#options.middlewares)) {\n\t\t\tthis.#options.middlewares = []\n\t\t}\n\t\tthis.#options.middlewares = this.#options.middlewares.concat(middlewares)\n\t}\n\n\t/**\n\t * Mimics the standard browser fetch method, but uses any middleware installed through\n\t * the constructor.\n\t * @param {Request|string|Object} - Required. The URL or Request object, accepts all types that are accepted by metro.request\n\t * @param {Object} - Optional. Any object that is accepted by metro.request\n\t * @return {Promise} - The metro.response to this request, or any other result as changed by any included middleware.\n\t */\n\tfetch(req, options)\n\t{\n\t\treq = request(req, options)\n\t\tif (!req.url) {\n\t\t\tthrow metroError('metro.client.'+req.method.toLowerCase()+': Missing url parameter '+metroURL+'client/missing-url-param/', req)\n\t\t}\n\t\tif (!options) {\n\t\t\toptions = {}\n\t\t}\n\t\tif (!(typeof options === 'object') \n\t\t\t|| Array.isArray(options)\n\t\t\t|| options instanceof String) \n\t\t{\n\t\t\tthrow metroError('metro.client.fetch: Options is not an object')\n\t\t}\n\n\t\tconst metrofetch = async function browserFetch(req)\n\t\t{\n\t\t\tif (req[Symbol.metroProxy]) {\n\t\t\t\t// even though a Proxy is supposed to be 'invisible'\n\t\t\t\t// fetch() doesn't work with the proxy (in Firefox), \n\t\t\t\t// you need the actual Request object here\n\t\t\t\t// and the actual body if you use e.g. FormData\n\t\t\t\tif (req.body && req.body[Symbol.metroSource]) {\n\t\t\t\t\tlet body = req.body[Symbol.metroSource]\n\t\t\t\t\treq = new Request(req[Symbol.metroSource], { body })\n\t\t\t\t} else {\n\t\t\t\t\treq = req[Symbol.metroSource]\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst res = await fetch(req)\n\t\t\treturn response(res)\n\t\t}\n\t\t\n\t\tlet middlewares = [metrofetch].concat(this.#options?.middlewares?.slice() || [])\n\t\toptions = Object.assign({}, this.#options, options)\n\t\t//@TODO: do this once in constructor?\n\t\tlet next\n\t\tfor (let middleware of middlewares) {\n\t\t\tnext = (function(next, middleware) {\n\t\t\t\treturn async function(req) {\n\t\t\t\t\tlet res\n\t\t\t\t\tlet tracers = Object.values(Client.tracers)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.request) {\n\t\t\t\t\t\t\ttracer.request.call(tracer, req, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tres = await middleware(req, next)\n\t\t\t\t\tfor(let tracer of tracers) {\n\t\t\t\t\t\tif (tracer.response) {\n\t\t\t\t\t\t\ttracer.response.call(tracer, res, middleware)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t})(next, middleware)\n\t\t}\n\t\treturn next(req)\n\t}\n\n\twith(...options) {\n\t\treturn new Client(this, ...options)\n\t}\n}\n\n/**\n * Returns a new metro Client object.\n * @param {...ClientOptions|string|URL}\n * @return Client\n */\nexport function client(...options)\n{\n\treturn new Client(...options)\n}\n\nfunction appendHeaders(r, headers)\n{\n\tif (!Array.isArray(headers)) {\n\t\theaders = [headers]\n\t}\n\theaders.forEach((header) => {\n\t\tif (typeof header == 'function') {\n\t\t\tlet result = header(r.headers, r)\n\t\t\tif (result) {\n\t\t\t\tif (!Array.isArray(result)) {\n\t\t\t\t\tresult = [result]\n\t\t\t\t}\n\t\t\t\theaders = headers.concat(result)\n\t\t\t}\n\t\t}\n\t})\n\theaders.forEach((header) => {\n\t\tObject.entries(header).forEach(([name,value]) => {\t\t\t\n\t\t\tr.headers.append(name, value)\n\t\t})\n\t})\n}\n\nfunction bodyProxy(body, r)\n{\n\tlet source = r.body\n\tif (!source) {\n\t\t//Firefox does not allow access to Request.body (undefined)\n\t\t//Chrome and Nodejs do, so mimic the correct (documented)\n\t\t//result here\n\t\tif (body === null) {\n\t\t\tsource = new ReadableStream()\n\t\t} else if (body instanceof ReadableStream) {\n\t\t\tsource = body\n\t\t} else if (body instanceof Blob) {\n\t\t\tsource = body.stream()\n\t\t} else {\n\t\t\tsource = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tlet chunk\n\t\t\t\t\tswitch(typeof body) {\n\t\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t\tif (typeof body.toString == 'function') {\n\t\t\t\t\t\t\t\t// also catches URLSearchParams\n\t\t\t\t\t\t\t\tchunk = body.toString()\n\t\t\t\t\t\t\t} else if (body instanceof FormData) {\n\t\t\t\t\t\t\t\tchunk = new URLSearchParams(body).toString()\n\t\t\t\t\t\t\t} else if (body instanceof ArrayBuffer\n\t\t\t\t\t\t\t\t|| ArrayBuffer.isView(body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// catchs TypedArrays - e.g. Uint16Array\n\t\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tchunk = body\n\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow metroError('Cannot convert body to ReadableStream', body)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk)\n\t\t\t\t\tcontroller.close()\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\treturn new Proxy(source, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch (prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn body\n\t\t\t\tbreak\n\t\t\t\tcase 'toString':\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\treturn ''+body\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\tif (prop in body) {\n\t\t\t\t\tif (typeof body[prop] == 'function') {\n\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\treturn body[prop].apply(body, args)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn body[prop]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t// and body may have its own toString\n\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop]\n\t\t\t}\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn prop in body\n\t\t\t} else {\n\t\t\t\treturn prop in target\n\t\t\t}\n\t\t},\n\t\townKeys(target) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Reflect.ownKeys(body)\n\t\t\t} else {\n\t\t\t\treturn Reflect.ownKeys(target)\n\t\t\t}\n\t\t},\n\t\tgetOwnPropertyDescriptor(target, prop) {\n\t\t\tif (body && typeof body == 'object') {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(body,prop)\n\t\t\t} else {\n\t\t\t\treturn Object.getOwnPropertyDescriptor(target,prop)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction getRequestParams(req, current)\n{\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\t// function to fetch all relevant properties of a Request\n\tfor(let prop of ['method','headers','body','mode','credentials','cache','redirect',\n\t\t'referrer','referrerPolicy','integrity','keepalive','signal',\n\t\t'priority','url']) {\n\t\tif (typeof req[prop] == 'function') {\n\t\t\treq[prop](params[prop], params)\n\t\t} else if (typeof req[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = url(params.url, req.url)\n\t\t\t} else if (prop == 'headers') {\n\t\t\t\tparams.headers = new Headers(current.headers)\n\t\t\t\tif (!(req.headers instanceof Headers)) {\n\t\t\t\t\treq.headers = new Headers(req.headers)\n\t\t\t\t}\n\t\t\t\tfor (let [key, value] of req.headers.entries()) {\n\t\t\t\t\tparams.headers.set(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams[prop] = req[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Request} MetroRequest\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - request options, handled in order\n * \n * Returns a new metro Request object\n * @param {} ...options - request options, handled in order\n * @return {MetroRequest} - a new metro Request object\n */\nexport function request(...options)\n{\n\t// the standard Request constructor is a minefield\n\t// so first gather all the options together into a single\n\t// javascript object, then set it in one go\n\tlet requestParams = {\n\t\turl: typeof window != 'undefined' ? window.location : 'https://localhost/',\n\t\tduplex: 'half' // required when setting body to ReadableStream, just set it here by default already\n\t}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string'\n\t\t\t|| option instanceof URL\n\t\t\t|| option instanceof URLSearchParams\n\t\t) {\n\t\t\trequestParams.url = url(requestParams.url, option)\n\t\t} else if (option && (\n\t\t\toption instanceof FormData\n\t\t\t|| option instanceof ReadableStream\n\t\t\t|| option instanceof Blob\n\t\t\t|| option instanceof ArrayBuffer\n\t\t\t|| option instanceof DataView\n\t\t)) {\n\t\t\trequestParams.body = option\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tObject.assign(requestParams, getRequestParams(option, requestParams))\n\t\t}\n\t}\n\tlet body = requestParams.body\n\tif (body) {\n\t\tif (typeof body == 'object'\n\t\t\t&& !(body instanceof String)\n\t\t\t&& !(body instanceof ReadableStream)\n\t\t\t&& !(body instanceof Blob)\n\t\t\t&& !(body instanceof ArrayBuffer)\n\t\t\t&& !(body instanceof DataView)\n\t\t\t&& !(body instanceof FormData)\n\t\t\t&& !(body instanceof URLSearchParams)\n\t\t\t&& (typeof TypedArray=='undefined' || !(body instanceof TypedArray))\n\t\t) {\n\t\t\trequestParams.body = JSON.stringify(body)\n\t\t}\n\t}\n\tlet r = new Request(requestParams.url, requestParams)\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\tif (body) { // body is kept in a seperate value, if it set earlier\n\t\t\t\t\t\t\toptions.unshift({ body }) // unshifted so it can be overridden by options\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn request(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\t// Request.body is always a ReadableStream\n\t\t\t\t\t// which is a horrible API, if you want to\n\t\t\t\t\t// allow middleware to alter the body\n\t\t\t\t\t// so we keep the original body, wrap a Proxy\n\t\t\t\t\t// around it to keep the ReadableStream api\n\t\t\t\t\t// accessible, but allow access to the original\n\t\t\t\t\t// body value as well\n\t\t\t\t\tif (!body) {\n\t\t\t\t\t\tbody = target.body\n\t\t\t\t\t}\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tif (body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(body, target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nfunction getResponseParams(res, current)\n{\n\t// function to fetch all relevant properties of a Response\n\tlet params = current || {}\n\tif (!params.url && current.url) {\n\t\tparams.url = current.url\n\t}\n\tfor(let prop of ['status','statusText','headers','body','url','type','redirected']) {\n\t\tif (typeof res[prop] == 'function') {\n\t\t\tres[prop](params[prop], params)\n\t\t} else if (typeof res[prop] != 'undefined') {\n\t\t\tif (prop == 'url') {\n\t\t\t\tparams.url = new URL(res.url, params.url || 'https://localhost/')\n\t\t\t} else {\n\t\t\t\tparams[prop] = res[prop]\n\t\t\t}\n\t\t}\n\t}\n\treturn params\n}\n\n/**\n * @typedef {Response} MetroResponse\n * @property {Symbol(source)} - returns the target Response of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroResponse, with the given options added\n * @param {} ...options - respomse options, handled in order\n * \n * Returns a new metro Response object\n * @param {} ...options - request options, handled in order\n * @return {MetroResponse} - a new metro Response object\n */\nexport function response(...options)\n{\n\tlet responseParams = {}\n\tfor (let option of options) {\n\t\tif (typeof option == 'string') {\n\t\t\tresponseParams.body = option\n\t\t} else if (option instanceof Response) {\n\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tif (option instanceof FormData\n\t\t\t\t|| option instanceof Blob\n\t\t\t\t|| option instanceof ArrayBuffer\n\t\t\t\t|| option instanceof DataView\n\t\t\t\t|| option instanceof ReadableStream\n\t\t\t\t|| option instanceof URLSearchParams\n\t\t\t\t|| option instanceof String\n\t\t\t\t|| (typeof TypedArray != 'undefined' && option instanceof TypedArray)\n\t\t\t) {\n\t\t\t\tresponseParams.body = option\n\t\t\t} else {\n\t\t\t\tObject.assign(responseParams, getResponseParams(option, responseParams))\n\t\t\t}\n\t\t}\n\t}\n\tlet r = new Response(responseParams.body, responseParams)\t\n\tObject.freeze(r)\n\treturn new Proxy(r, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn response(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'body':\n\t\t\t\t\tif (responseParams.body) {\n\t\t\t\t\t\tif (responseParams.body[Symbol.metroProxy]) {\n\t\t\t\t\t\t\treturn responseParams.body\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn bodyProxy(responseParams.body, target)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn bodyProxy('',target)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'ok':\n\t\t\t\t\treturn (target.status>=200) && (target.status<400)\n\t\t\t\tbreak\n\t\t\t\tcase 'headers':\n\t\t\t\t\treturn target.headers\n\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (prop in responseParams && prop != 'toString') {\n\t\t\t\t\t\treturn responseParams[prop]\n\t\t\t\t\t}\n\t\t\t\t\tif (prop in target && prop != 'toString') {\n\t\t\t\t\t\t// skipped toString, since it has no usable output\n\t\t\t\t\t\t// and body may have its own toString\n\t\t\t\t\t\tif (typeof target[prop] == 'function') {\n\t\t\t\t\t\t\treturn function(...args) {\n\t\t\t\t\t\t\t\treturn target[prop].apply(target, args)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop]\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t})\n}\n\nfunction appendSearchParams(url, params) {\n\tif (typeof params == 'function') {\n\t\t params(url.searchParams, url)\n\t} else {\n\t\tparams = new URLSearchParams(params)\n\t\tparams.forEach((value,key) => {\n\t\t\turl.searchParams.append(key, value)\n\t\t})\n\t}\n}\n\n/**\n * @typedef {URL} MetroURL\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro URL object\n * @param {} ...options - url options, handled in order\n * @return {MetroURL} - a new metro URL object\n */\nexport function url(...options)\n{\n\tlet validParams = ['hash','host','hostname','href',\n\t\t\t'password','pathname','port','protocol','username','search','searchParams']\n\tlet u = new URL('https://localhost/')\n\tfor (let option of options) {\n\t\tif (typeof option == 'string' || option instanceof String) {\n\t\t\t// option is a relative or absolute url\n\t\t\tu = new URL(option, u)\n\t\t} else if (option instanceof URL \n\t\t\t|| (typeof Location != 'undefined' \n\t\t\t\t&& option instanceof Location)\n\t\t) {\n\t\t\tu = new URL(option)\n\t\t} else if (option instanceof URLSearchParams) {\n\t\t\tappendSearchParams(u, option)\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let param in option) {\n\t\t\t\tif (param=='search') {\n\t\t\t\t\tif (typeof option.search == 'function') {\n\t\t\t\t\t\toption.search(u.search, u)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu.search = new URLSearchParams(option.search)\n\t\t\t\t\t}\n\t\t\t\t} else if (param=='searchParams') {\n\t\t\t\t\tappendSearchParams(u, option.searchParams)\n\t\t\t\t} else {\n\t\t\t\t\tif (!validParams.includes(param)) {\n\t\t\t\t\t\tthrow metroError('metro.url: unknown url parameter '+metroURL+'url/unknown-param-name/', param)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof option[param] == 'function') {\n\t\t\t\t\t\toption[param](u[param], u)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof option[param] == 'string' || option[param] instanceof String \n\t\t\t\t\t\t|| typeof option[param] == 'number' || option[param] instanceof Number\n\t\t\t\t\t\t|| typeof option[param] == 'boolean' || option[param] instanceof Boolean\n\t\t\t\t\t) {\n\t\t\t\t\t\tu[param] = ''+option[param]\n\t\t\t\t\t} else if (typeof option[param] == 'object' && option[param].toString) {\n\t\t\t\t\t\tu[param] = option[param].toString()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow metroError('metro.url: unsupported value for '+param+' '+metroURL+'url/unsupported-param-value/', options[param])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow metroError('metro.url: unsupported option value '+metroURL+'url/unsupported-option-value/', option)\n\t\t}\n\t}\n\tObject.freeze(u)\n\treturn new Proxy(u, {\n\t\tget(target, prop, receiver) {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn url(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\n/**\n * @typedef {FormData} MetroFormData\n * @property {Symbol(source)} - returns the target Request of this Proxy\n * @property {Symbol(isProxy)} - returns true\n * @method with - returns a new MetroRequest, with the given options added\n * @param {} ...options - url options, handled in order\n * \n * Returns a new metro FormData object\n * @param {} ...options - formdata options, handled in order\n * @return {MetroURL} - a new metro FormData object\n */\nexport function formdata(...options)\n{\n\tvar params = new FormData()\n\tfor (let option of options) {\n\t\tif (option instanceof FormData) {\n\t\t\tfor (let entry of option.entries()) {\n\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t}\n\t\t} else if (option && typeof option == 'object') {\n\t\t\tfor (let entry of Object.entries(option)) {\n\t\t\t\tif (Array.isArray(entry[1])) {\n\t\t\t\t\tfor (let value of entry[1]) {\n\t\t\t\t\t\tparams.append(entry[0], value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tparams.append(entry[0],entry[1])\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new metroError('metro.formdata: unknown option type, only FormData or Object supported',option)\n\t\t}\n\t}\n\tObject.freeze(params)\n\treturn new Proxy(params, {\n\t\tget: (target,prop,receiver) => {\n\t\t\tswitch(prop) {\n\t\t\t\tcase Symbol.metroProxy:\n\t\t\t\t\treturn true\n\t\t\t\tbreak\n\t\t\t\tcase Symbol.metroSource:\n\t\t\t\t\treturn target\n\t\t\t\tbreak\n\t\t\t\tcase 'with':\n\t\t\t\t\treturn function(...options) {\n\t\t\t\t\t\treturn formdata(target, ...options)\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (target[prop] instanceof Function) {\n\t\t\t\treturn target[prop].bind(target)\n\t\t\t}\n\t\t\treturn target[prop]\n\t\t}\n\t})\n}\n\nconst metroConsole = {\n\terror: (message, ...details) => {\n\t\tconsole.error('\u24C2\uFE0F ',message, ...details)\n\t},\n\tinfo: (message, ...details) => {\n\t\tconsole.info('\u24C2\uFE0F ',message, ...details)\n\t},\n\tgroup: (name) => {\n\t\tconsole.group('\u24C2\uFE0F '+name)\n\t},\n\tgroupEnd: (name) => {\n\t\tconsole.groupEnd('\u24C2\uFE0F '+name)\n\t}\n}\n\n\n/**\n * Custom Metro Error function that outputs to the console then throws an error\n */\nexport function metroError(message, ...details) {\n\tmetroConsole.error(message, ...details)\n\treturn new Error(message, ...details)\n}\n\n/**\n * Set of debugging tools to trace the request - response flow\n * Tracer are run on all metro fetch calls\n */\nexport const trace = {\n\t/**\n\t * Adds a named tracer function\n\t * @param {string} name - the name of the tracer\n\t * @param {Function} tracer - the tracer function to call\n\t */\n\tadd(name, tracer) {\n\t\tClient.tracers[name] = tracer\n\t},\n\t/**\n\t * Removes a named tracer function\n\t * @param {string} name\n\t */\n\tdelete(name) {\n\t\tdelete Client.tracers[name]\n\t},\n\t/**\n\t * Removes all tracer functions\n\t */\n\tclear() {\n\t\tClient.tracers = {}\n\t},\n\t/**\n\t * Returns a set of request and response tracer functions that use the\n\t * console.group feature to shows nested request/response pairs, with\n\t * most commonly needed information for debugging\n\t */\n\tgroup() {\n\t\tlet group = 0;\n\t\treturn {\n\t\t\trequest: (req, middleware) => {\n\t\t\t\tgroup++\n\t\t\t\tmetroConsole.group(group)\n\t\t\t\tmetroConsole.info(req?.url, req, middleware)\n\t\t\t},\n\t\t\tresponse: (res, middleware) => {\n\t\t\t\tmetroConsole.info(res?.body ? res.body[Symbol.metroSource]: null, res, middleware)\n\t\t\t\tmetroConsole.groupEnd(group)\n\t\t\t\tgroup--\n\t\t\t}\n\t\t}\n\t}\n}\n", "import * as metro from '../metro.mjs'\n\nexport default function jsonmw(options) {\n\toptions = Object.assign({\n\t\treviver: null,\n\t\treplacer: null,\n\t\tspace: ''\n\t}, options)\n\n\treturn async (req, next) => {\n\t\tif (['POST','PUT','PATCH','QUERY'].includes(req.method)) {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type':'application/json',\n\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (req.body && typeof req.body[Symbol.metroSource] == 'object') {\n\t\t\t\treq = req.with({\n\t\t\t\t\tbody: JSON.stringify(req.body[Symbol.metroSource], options.replacer, options.space)\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\treq = req.with({\n\t\t\t\theaders: {\n\t\t\t 'Accept':'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tlet res = await next(req)\n\t\tlet body = await res.text()\n\t\tlet json = JSON.parse(body, options.reviver)\n\t\treturn res.with({\n\t\t\tbody: json\n\t\t})\n\t}\n}", "import * as metro from '../metro.mjs'\n\nexport default function thrower(options) {\n\n\treturn async (req, next) => {\n\t\tlet res = await next(req)\n\t\tif (!res.ok) {\n\t\t\tif (options && typeof options[res.status] == 'function') {\n\t\t\t\tres = options[res.status].apply(res, req)\n\t\t\t} else {\n\t\t\t\tthrow new Error(res.status+': '+res.statusText, {\n\t\t\t\t\tcause: res\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\n}", "import * as m from './metro.mjs'\nimport jsonmw from './mw/json.mjs'\nimport thrower from './mw/thrower.mjs'\n\nconst metro = Object.assign({}, m, {\n\tmw: {\n\t\tjsonmw,\n\t\tthrower\n\t}\n})\n\nglobalThis.metro = metro\n\nexport default metro"], + "mappings": "gGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,UAAAC,EAAA,QAAAC,IAGA,IAAMC,EAAW,iCAOZ,OAAO,aACX,OAAO,WAAa,OAAO,SAAS,GAEhC,OAAO,cACX,OAAO,YAAc,OAAO,QAAQ,GAcrC,IAAMC,EAAN,MAAMC,CACN,CACCC,GAAW,CACV,IAAK,OAAO,OAAU,IAAc,OAAO,SAAW,mBACvD,EACAC,GAAS,CAAC,MAAM,OAAO,MAAM,SAAS,QAAQ,OAAO,UAAU,OAAO,EAEtE,OAAO,QAAU,CAAC,EAYlB,eAAeC,EACf,CACC,QAASC,KAAUD,EAClB,GAAI,OAAOC,GAAU,UAAYA,aAAkB,OAClD,KAAKH,GAAS,IAAM,GAAGG,UACbA,aAAkBJ,EAC5B,OAAO,OAAO,KAAKC,GAAUG,EAAOH,EAAQ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AGC,EAAG,CAClC,GAAI,CACH,OAAAC,EACA,QAAAC,CACD,CACD,CAAC,EAED,WAAW,MAAQH,EAEnB,IAAOI,EAAQJ", "names": ["metro_exports", "__export", "client", "formdata", "metroError", "request", "response", "trace", "url", "metroURL", "Client", "_Client", "#options", "#verbs", "options", "option", "#addMiddlewares", "param", "verb", "middlewares", "index", "m", "req", "body", "res", "next", "middleware", "tracers", "tracer", "bodyProxy", "body", "r", "source", "controller", "chunk", "metroError", "target", "prop", "receiver", "args", "getRequestParams", "req", "current", "params", "url", "key", "value", "request", "options", "requestParams", "option", "getResponseParams", "res", "response", "responseParams", "appendSearchParams", "validParams", "u", "param", "metroURL", "formdata", "entry", "metroConsole", "message", "details", "name", "trace", "tracer", "Client", "group", "middleware", "jsonmw", "options", "req", "next", "res", "body", "json", "thrower", "options", "req", "next", "res", "metro", "metro_exports", "jsonmw", "thrower", "everything_default"] } diff --git a/package.json b/package.json index 5dbe9ec..e758907 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muze-nl/metro", - "version": "0.5.3", + "version": "0.5.4", "description": "http client with middleware support", "type": "module", "source": [ "src/browser.mjs", "src/everything.mjs" ],