@skaldapp/runtime 3.0.6 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ const t=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,e=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,o=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function r(t,e){if(!("__proto__"===t||"constructor"===t&&e&&"object"==typeof e&&"prototype"in e))return e;!function(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}(t)}function n(n,s={}){if("string"!=typeof n)return n;if('"'===n[0]&&'"'===n[n.length-1]&&-1===n.indexOf("\\"))return n.slice(1,-1);const a=n.trim();if(a.length<=9)switch(a.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!o.test(n)){if(s.strict)throw new SyntaxError("[destr] Invalid JSON");return n}try{if(t.test(n)||e.test(n)){if(s.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(n,r)}return JSON.parse(n)}catch(i){if(s.strict)throw i;return n}}const s=/#/g,a=/&/g,i=/\//g,c=/=/g,p=/\+/g,u=/%5e/gi,f=/%60/gi,l=/%7c/gi,h=/%20/gi;function d(t){return(e="string"==typeof t?t:JSON.stringify(t),encodeURI(""+e).replace(l,"|")).replace(p,"%2B").replace(h,"+").replace(s,"%23").replace(a,"%26").replace(f,"`").replace(u,"^").replace(i,"%2F");var e}function y(t){return d(t).replace(c,"%3D")}function m(t=""){try{return decodeURIComponent(""+t)}catch{return""+t}}function b(t){return m(t.replace(p," "))}function w(t){return m(t.replace(p," "))}function g(t=""){const e=Object.create(null);"?"===t[0]&&(t=t.slice(1));for(const o of t.split("&")){const t=o.match(/([^=]+)=?(.*)/)||[];if(t.length<2)continue;const r=b(t[1]);if("__proto__"===r||"constructor"===r)continue;const n=w(t[2]||"");void 0===e[r]?e[r]=n:Array.isArray(e[r])?e[r].push(n):e[r]=[e[r],n]}return e}function T(t){return Object.keys(t).filter(e=>void 0!==t[e]).map(e=>{return o=e,"number"!=typeof(r=t[e])&&"boolean"!=typeof r||(r=String(r)),r?Array.isArray(r)?r.map(t=>`${y(o)}=${d(t)}`).join("&"):`${y(o)}=${d(r)}`:y(o);var o,r}).filter(Boolean).join("&")}const E=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,q=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,S=/^([/\\]\s*){2,}[^/\\]/,A=/^\.?\//;function R(t,e={}){return"boolean"==typeof e&&(e={acceptRelative:e}),e.strict?E.test(t):q.test(t)||!!e.acceptRelative&&S.test(t)}function j(t="",e){return t.endsWith("/")?t:t+"/"}function v(t,e){if(!(o=e)||"/"===o||R(t))return t;var o;const r=function(t=""){return(function(t=""){return t.endsWith("/")}(t)?t.slice(0,-1):t)||"/"}(e);if(t.startsWith(r)){const e=t[r.length];if(!e||"/"===e||"?"===e)return t}return function(t,...e){let o=t||"";for(const r of e.filter(t=>function(t){return t&&"/"!==t}(t)))if(o){const t=r.replace(A,"");o=j(o)+t}else o=r;return o}(r,t)}function _(t,e){const o=function(t=""){const e=t.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);if(e){const[,t,o=""]=e;return{protocol:t.toLowerCase(),pathname:o,href:t+o,auth:"",host:"",search:"",hash:""}}if(!R(t,{acceptRelative:!0}))return N(t);const[,o="",r,n=""]=t.replace(/\\/g,"/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/)||[];let[,s="",a=""]=n.match(/([^#/?]*)(.*)?/)||[];"file:"===o&&(a=a.replace(/\/(?=[A-Za-z]:)/,""));const{pathname:i,search:c,hash:p}=N(a);return{protocol:o.toLowerCase(),auth:r?r.slice(0,Math.max(0,r.length-1)):"",host:s,pathname:i,search:c,hash:p,[x]:!o}}(t),r={...g(o.search),...e};return o.search=T(r),function(t){const e=t.pathname||"",o=t.search?(t.search.startsWith("?")?"":"?")+t.search:"",r=t.hash||"",n=t.auth?t.auth+"@":"",s=t.host||"",a=t.protocol||t[x]?(t.protocol||"")+"//":"";return a+n+s+e+o+r}(o)}const x=Symbol.for("ufo:protocolRelative");function N(t=""){const[e="",o="",r=""]=(t.match(/([^#?]*)(\?[^#]*)?(#.*)?/)||[]).splice(1);return{pathname:e,search:o,hash:r}}class O extends Error{constructor(t,e){super(t,e),this.name="FetchError",e?.cause&&!this.cause&&(this.cause=e.cause)}}function $(t){const e=t.error?.message||t.error?.toString()||"",o=t.request?.method||t.options?.method||"GET",r=t.request?.url||String(t.request)||"/",n=`[${o}] ${JSON.stringify(r)}`,s=t.response?`${t.response.status} ${t.response.statusText}`:"<no response>",a=new O(`${n}: ${s}${e?` ${e}`:""}`,t.error?{cause:t.error}:void 0);for(const i of["request","options","response"])Object.defineProperty(a,i,{get:()=>t[i]});for(const[i,c]of[["data","_data"],["status","status"],["statusCode","status"],["statusText","statusText"],["statusMessage","statusText"]])Object.defineProperty(a,i,{get:()=>t.response&&t.response[c]});return a}const C=new Set(Object.freeze(["PATCH","POST","PUT","DELETE"]));function I(t="GET"){return C.has(t.toUpperCase())}const F=new Set(["image/svg","application/xml","application/xhtml","application/html"]),P=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function U(t,e,o,r){const n=function(t,e,o){if(!e)return new o(t);const r=new o(e);if(t)for(const[n,s]of Symbol.iterator in t||Array.isArray(t)?t:new o(t))r.set(n,s);return r}(e?.headers??t?.headers,o?.headers,r);let s;return(o?.query||o?.params||e?.params||e?.query)&&(s={...o?.params,...o?.query,...e?.params,...e?.query}),{...o,...e,query:s,params:s,headers:n}}async function D(t,e){if(e)if(Array.isArray(e))for(const o of e)await o(t);else await e(t)}const L=new Set([408,409,425,429,500,502,503,504]),J=new Set([101,204,205,304]);function k(t={}){const{fetch:e=globalThis.fetch,Headers:o=globalThis.Headers,AbortController:r=globalThis.AbortController}=t;async function s(t){const e=t.error&&"AbortError"===t.error.name&&!t.options.timeout||!1;if(!1!==t.options.retry&&!e){let e;e="number"==typeof t.options.retry?t.options.retry:I(t.options.method)?0:1;const o=t.response&&t.response.status||500;if(e>0&&(Array.isArray(t.options.retryStatusCodes)?t.options.retryStatusCodes.includes(o):L.has(o))){const o="function"==typeof t.options.retryDelay?t.options.retryDelay(t):t.options.retryDelay||0;return o>0&&await new Promise(t=>setTimeout(t,o)),a(t.request,{...t.options,retry:e-1})}}const o=$(t);throw Error.captureStackTrace&&Error.captureStackTrace(o,a),o}const a=async function(a,i={}){const c={request:a,options:U(a,i,t.defaults,o),response:void 0,error:void 0};if(c.options.method&&(c.options.method=c.options.method.toUpperCase()),c.options.onRequest&&(await D(c,c.options.onRequest),c.options.headers instanceof o||(c.options.headers=new o(c.options.headers||{}))),"string"==typeof c.request&&(c.options.baseURL&&(c.request=v(c.request,c.options.baseURL)),c.options.query&&(c.request=_(c.request,c.options.query),delete c.options.query),"query"in c.options&&delete c.options.query,"params"in c.options&&delete c.options.params),c.options.body&&I(c.options.method))if(function(t){if(void 0===t)return!1;const e=typeof t;return"string"===e||"number"===e||"boolean"===e||null===e||"object"===e&&(!!Array.isArray(t)||!t.buffer&&!(t instanceof FormData||t instanceof URLSearchParams)&&(t.constructor&&"Object"===t.constructor.name||"function"==typeof t.toJSON))}(c.options.body)){const t=c.options.headers.get("content-type");"string"!=typeof c.options.body&&(c.options.body="application/x-www-form-urlencoded"===t?new URLSearchParams(c.options.body).toString():JSON.stringify(c.options.body)),t||c.options.headers.set("content-type","application/json"),c.options.headers.has("accept")||c.options.headers.set("accept","application/json")}else("pipeTo"in c.options.body&&"function"==typeof c.options.body.pipeTo||"function"==typeof c.options.body.pipe)&&("duplex"in c.options||(c.options.duplex="half"));let p;if(!c.options.signal&&c.options.timeout){const t=new r;p=setTimeout(()=>{const e=new Error("[TimeoutError]: The operation was aborted due to timeout");e.name="TimeoutError",e.code=23,t.abort(e)},c.options.timeout),c.options.signal=t.signal}try{c.response=await e(c.request,c.options)}catch(u){return c.error=u,c.options.onRequestError&&await D(c,c.options.onRequestError),await s(c)}finally{p&&clearTimeout(p)}if((c.response.body||c.response._bodyInit)&&!J.has(c.response.status)&&"HEAD"!==c.options.method){const t=(c.options.parseResponse?"json":c.options.responseType)||function(t=""){if(!t)return"json";const e=t.split(";").shift()||"";return P.test(e)?"json":"text/event-stream"===e?"stream":F.has(e)||e.startsWith("text/")?"text":"blob"}(c.response.headers.get("content-type")||"");switch(t){case"json":{const t=await c.response.text(),e=c.options.parseResponse||n;c.response._data=e(t);break}case"stream":c.response._data=c.response.body||c.response._bodyInit;break;default:c.response._data=await c.response[t]()}}return c.options.onResponse&&await D(c,c.options.onResponse),!c.options.ignoreResponseError&&c.response.status>=400&&c.response.status<600?(c.options.onResponseError&&await D(c,c.options.onResponseError),await s(c)):c.response},i=async function(t,e){return(await a(t,e))._data};return i.raw=a,i.native=(...t)=>e(...t),i.create=(e={},o={})=>k({...t,...o,defaults:{...t.defaults,...o.defaults,...e}}),i}const H=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}(),W=H.fetch?(...t)=>H.fetch(...t):()=>Promise.reject(new Error("[ofetch] global.fetch is not supported!")),G=H.Headers,z=H.AbortController,B=k({fetch:W,Headers:G,AbortController:z}),M=B;export{M as $fetch,z as AbortController,O as FetchError,G as Headers,k as createFetch,$ as createFetchError,W as fetch,B as ofetch};