@d1g1tal/transportr 3.1.2 → 3.1.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [3.1.3](https://github.com/D1g1talEntr0py/transportr/compare/v3.1.2...v3.1.3) (2026-04-08)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **iife:** handle minified export blocks and remove -s flag from prepareCmd (ce709b27ca0d423c8e1454d88e5116eefe7770ae)
6
+
1
7
  ## [3.1.2](https://github.com/D1g1talEntr0py/transportr/compare/v3.1.1...v3.1.2) (2026-04-08)
2
8
 
3
9
  ### Bug Fixes
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ var i={AAC:"audio/aac",ABW:"application/x-abiword",ARC:"application/x-freearc",AVIF:"image/avif",AVI:"video/x-msvideo",AZW:"application/vnd.amazon.ebook",BIN:"application/octet-stream",BMP:"image/bmp",BZIP:"application/x-bzip",BZIP2:"application/x-bzip2",CDA:"application/x-cdf",CSH:"application/x-csh",CSS:"text/css",CSV:"text/csv",DOC:"application/msword",DOCX:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",EOT:"application/vnd.ms-fontobject",EPUB:"application/epub+zip",GZIP:"application/gzip",GIF:"image/gif",HTML:"text/html",ICO:"image/vnd.microsoft.icon",ICS:"text/calendar",JAR:"application/java-archive",JPEG:"image/jpeg",JAVA_SCRIPT:"text/javascript",JSON:"application/json",JSON_LD:"application/ld+json",JSON_MERGE_PATCH:"application/merge-patch+json",MID:"audio/midi",X_MID:"audio/x-midi",MP3:"audio/mpeg",MP4A:"audio/mp4",MP4:"video/mp4",MPEG:"video/mpeg",MPKG:"application/vnd.apple.installer+xml",ODP:"application/vnd.oasis.opendocument.presentation",ODS:"application/vnd.oasis.opendocument.spreadsheet",ODT:"application/vnd.oasis.opendocument.text",OGA:"audio/ogg",OGV:"video/ogg",OGX:"application/ogg",OPUS:"audio/opus",OTF:"font/otf",PNG:"image/png",PDF:"application/pdf",PHP:"application/x-httpd-php",PPT:"application/vnd.ms-powerpoint",PPTX:"application/vnd.openxmlformats-officedocument.presentationml.presentation",RAR:"application/vnd.rar",RTF:"application/rtf",SH:"application/x-sh",SVG:"image/svg+xml",TAR:"application/x-tar",TIFF:"image/tiff",TRANSPORT_STREAM:"video/mp2t",TTF:"font/ttf",TEXT:"text/plain",VSD:"application/vnd.visio",WAV:"audio/wav",WEBA:"audio/webm",WEBM:"video/webm",WEBP:"image/webp",WOFF:"font/woff",WOFF2:"font/woff2",FORM:"application/x-www-form-urlencoded",MULTIPART_FORM_DATA:"multipart/form-data",XHTML:"application/xhtml+xml",XLS:"application/vnd.ms-excel",XLSX:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",XML:"application/xml",XUL:"application/vnd.mozilla.xul+xml",ZIP:"application/zip","3GP":"video/3gpp","3G2":"video/3gpp2","7Z":"application/x-7z-compressed"};
3
+ globalThis.ContentType = i;
4
+ })();
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ var e={ACCEPT:"accept",ACCEPT_CHARSET:"accept-charset",ACCEPT_ENCODING:"accept-encoding",ACCEPT_LANGUAGE:"accept-language",AUTHORIZATION:"authorization",CACHE_CONTROL:"cache-control",CONNECTION:"connection",COOKIE:"cookie",CONTENT_LENGTH:"content-length",CONTENT_MD5:"content-md5",CONTENT_TYPE:"content-type",DATE:"date",HOST:"host",IF_MATCH:"if-match",IF_MODIFIED_SINCE:"if-modified-since",IF_NONE_MATCH:"if-none-match",IF_RANGE:"if-range",IF_UNMODIFIED_SINCE:"if-unmodified-since",MAX_FORWARDS:"max-forwards",ORIGIN:"origin",PRAGMA:"pragma",PROXY_AUTHORIZATION:"proxy-authorization",RANGE:"range",REFERER:"referer",TE:"te",USER_AGENT:"user-agent",UPGRADE:"upgrade",WARNING:"warning",X_REQUESTED_WITH:"x-requested-with",X_FORWARDED_FOR:"x-forwarded-for",X_FORWARDED_HOST:"x-forwarded-host",X_FORWARDED_PROTO:"x-forwarded-proto"};
3
+ globalThis.RequestHeader = e;
4
+ })();
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ var T={OPTIONS:"OPTIONS",GET:"GET",HEAD:"HEAD",POST:"POST",PUT:"PUT",DELETE:"DELETE",TRACE:"TRACE",CONNECT:"CONNECT",PATCH:"PATCH"};
3
+ globalThis.RequestMethod = T;
4
+ })();
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ var t={PROXY_CONNECTION:"proxy-connection",X_UIDH:"x-uidh",X_CSRF_TOKEN:"x-csrf-token",ACCESS_CONTROL_ALLOW_ORIGIN:"access-control-allow-origin",ACCEPT_PATCH:"accept-patch",ACCEPT_RANGES:"accept-ranges",AGE:"age",ALLOW:"allow",CACHE_CONTROL:"cache-control",CONNECTION:"connection",CONTENT_DISPOSITION:"content-disposition",CONTENT_ENCODING:"content-encoding",CONTENT_LANGUAGE:"content-language",CONTENT_LENGTH:"content-length",CONTENT_LOCATION:"content-location",CONTENT_RANGE:"content-range",CONTENT_TYPE:"content-type",DATE:"date",ETAG:"etag",EXPIRES:"expires",LAST_MODIFIED:"last-modified",LINK:"link",LOCATION:"location",P3P:"p3p",PRAGMA:"pragma",PROXY_AUTHENTICATION:"proxy-authenticate",PUBLIC_KEY_PINS:"public-key-pins",RETRY_AFTER:"retry-after",SERVER:"server",SET_COOKIE:"set-cookie",STATUS:"status",STRICT_TRANSPORT_SECURITY:"strict-transport-security",TRAILER:"trailer",TRANSFER_ENCODING:"transfer-encoding",UPGRADE:"upgrade",VARY:"vary",VIA:"via",WARNING:"warning",WWW_AUTHENTICATE:"www-authenticate",X_XSS_PROTECTION:"x-xss-protection",CONTENT_SECURITY_POLICY:"content-security-policy",X_CONTENT_TYPE_OPTIONS:"x-content-type-options",X_POWERED_BY:"x-powered-by"};
3
+ globalThis.ResponseHeader = t;
4
+ })();
@@ -0,0 +1,10 @@
1
+ (() => {
2
+ var L=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,Ce=/(["\\])/ug,Ue=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,ie=class ae extends Map{constructor(e=[]){super(e)}static isValid(e,t){return L.test(e)&&Ue.test(t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}set(e,t){if(!ae.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(e.toLowerCase(),t),this}delete(e){return super.delete(e.toLowerCase())}toString(){return Array.from(this).map(([e,t])=>`;${e}=${!t||!L.test(t)?`"${t.replace(Ce,"\\$1")}"`:t}`).join("")}get[Symbol.toStringTag](){return"MediaTypeParameters"}},xe=new Set([" "," ",`
3
+ `,"\r"]),Le=/[ \t\n\r]+$/u,Ie=/^[ \t\n\r]+|[ \t\n\r]+$/ug,Me=class w{static parse(e){e=e.replace(Ie,"");let t=0,[n,r]=w.collect(e,t,["/"]);if(t=r,!n.length||t>=e.length||!L.test(n))throw new TypeError(w.generateErrorMessage("type",n));++t;let[o,i]=w.collect(e,t,[";"],!0,!0);if(t=i,!o.length||!L.test(o))throw new TypeError(w.generateErrorMessage("subtype",o));let a=new ie;for(;t<e.length;){for(++t;xe.has(e[t]);)++t;let d;if([d,t]=w.collect(e,t,[";","="],!1),t>=e.length||e[t]===";")continue;++t;let R;if(e[t]==='"')for([R,t]=w.collectHttpQuotedString(e,t);t<e.length&&e[t]!==";";)++t;else if([R,t]=w.collect(e,t,[";"],!1,!0),!R)continue;d&&ie.isValid(d,R)&&!a.has(d)&&a.set(d,R)}return{type:n,subtype:o,parameters:a}}get[Symbol.toStringTag](){return"MediaTypeParser"}static collect(e,t,n,r=!0,o=!1){let i="";for(let{length:a}=e;t<a&&!n.includes(e[t]);t++)i+=e[t];return r&&(i=i.toLowerCase()),o&&(i=i.replace(Le,"")),[i,t]}static collectHttpQuotedString(e,t){let n="";for(let r=e.length,o;++t<r&&(o=e[t])!=='"';)n+=o=="\\"&&++t<r?e[t]:o;return[n,t]}static generateErrorMessage(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},T=class ue{_type;_subtype;_parameters;constructor(e,t={}){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");({type:this._type,subtype:this._subtype,parameters:this._parameters}=Me.parse(e));for(let[n,r]of Object.entries(t))this._parameters.set(n,r)}static parse(e){try{return new ue(e)}catch{}return null}get type(){return this._type}get subtype(){return this._subtype}get essence(){return`${this._type}/${this._subtype}`}get parameters(){return this._parameters}matches(e){return typeof e=="string"?this.essence.includes(e):this._type===e._type&&this._subtype===e._subtype}toString(){return`${this.essence}${this._parameters.toString()}`}get[Symbol.toStringTag](){return"MediaType"}};var Ne=class extends Map{set(s,e){return super.set(s,e instanceof Set?e:(super.get(s)??new Set).add(e)),this}getOrInsert(s,e){return this.has(s)?super.get(s):(super.set(s,e instanceof Set?e:(super.get(s)??new Set).add(e)),e)}getOrInsertComputed(s,e){if(this.has(s))return super.get(s);let t=e(s);return super.set(s,t instanceof Set?t:(super.get(s)??new Set).add(t)),t}find(s,e){let t=this.get(s);if(t!==void 0)return Array.from(t).find(e)}hasValue(s,e){let t=super.get(s);return t?t.has(e):!1}deleteValue(s,e){if(e===void 0)return this.delete(s);let t=super.get(s);if(t){let n=t.delete(e);return t.size===0&&super.delete(s),n}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},De=class{context;eventHandler;constructor(s,e){this.context=s,this.eventHandler=e}handle(s,e){this.eventHandler.call(this.context,s,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},_e=class{_eventName;_contextEventHandler;constructor(s,e){this._eventName=s,this._contextEventHandler=e}get eventName(){return this._eventName}get contextEventHandler(){return this._contextEventHandler}get[Symbol.toStringTag](){return"Subscription"}},I=class{subscribers=new Ne;errorHandler;setErrorHandler(s){this.errorHandler=s}subscribe(s,e,t=e,n){if(this.validateEventName(s),n?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new De(t,e);this.subscribers.set(s,r);let o=new _e(s,r);return o}unsubscribe({eventName:s,contextEventHandler:e}){let t=this.subscribers.get(s)??new Set,n=t.delete(e);return n&&t.size===0&&this.subscribers.delete(s),n}publish(s,e=new CustomEvent(s),t){this.validateEventName(s),this.subscribers.get(s)?.forEach(n=>{try{n.handle(e,t)}catch(r){this.errorHandler?this.errorHandler(r,s,e,t):console.error(`Error in event handler for '${s}':`,r)}})}isSubscribed({eventName:s,contextEventHandler:e}){return this.subscribers.get(s)?.has(e)??!1}validateEventName(s){if(!s||typeof s!="string")throw new TypeError("Event name must be a non-empty string");if(s.trim()!==s)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.subscribers.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var k=class extends Error{_entity;responseStatus;_url;_method;_timing;constructor(e,{message:t,cause:n,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:n}),this._entity=r,this.responseStatus=e,this._url=o,this._method=i,this._timing=a}get entity(){return this._entity}get statusCode(){return this.responseStatus.code}get statusText(){return this.responseStatus?.text}get url(){return this._url}get method(){return this._method}get timing(){return this._timing}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var v=class{_code;_text;constructor(e,t){this._code=e,this._text=t}get code(){return this._code}get text(){return this._text}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this._code} ${this._text}`}};var q={charset:"utf-8"},de=/\/$/,le="XSRF-TOKEN",ce="X-XSRF-TOKEN",m={PNG:new T("image/png"),TEXT:new T("text/plain",q),JSON:new T("application/json",q),HTML:new T("text/html",q),JAVA_SCRIPT:new T("text/javascript",q),CSS:new T("text/css",q),XML:new T("application/xml",q),BIN:new T("application/octet-stream"),EVENT_STREAM:new T("text/event-stream",q),NDJSON:new T("application/x-ndjson",q)},$=m.JSON.toString(),G=globalThis.location?.origin??"http://localhost",pe={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},b={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},H={ABORT:"abort",TIMEOUT:"timeout"},A={ABORT:"AbortError",TIMEOUT:"TimeoutError"},U={once:!0,passive:!0},M=()=>new CustomEvent(H.ABORT,{detail:{cause:A.ABORT}}),fe=()=>new CustomEvent(H.TIMEOUT,{detail:{cause:A.TIMEOUT}}),Re=["POST","PUT","PATCH","DELETE"],he=new v(500,"Internal Server Error"),ge=new v(499,"Aborted"),me=new v(504,"Request Timeout"),X=[408,413,429,500,502,503,504],V=["GET","PUT","HEAD","DELETE","OPTIONS"],N=300,D=2;var _=class{abortSignal;abortController=new AbortController;events=new Map;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let n=[this.abortController.signal];e!=null&&n.push(e),t!==1/0&&n.push(AbortSignal.timeout(t)),(this.abortSignal=AbortSignal.any(n)).addEventListener(H.ABORT,this,U)}handleEvent({target:{reason:e}}){this.abortController.signal.aborted||e instanceof DOMException&&e.name===A.TIMEOUT&&this.abortSignal.dispatchEvent(fe())}get signal(){return this.abortSignal}onAbort(e){return this.addEventListener(H.ABORT,e)}onTimeout(e){return this.addEventListener(H.TIMEOUT,e)}abort(e=M()){this.abortController.abort(e.detail?.cause)}destroy(){this.abortSignal.removeEventListener(H.ABORT,this,U);for(let[e,t]of this.events)this.abortSignal.removeEventListener(t,e,U);return this.events.clear(),this}addEventListener(e,t){return this.abortSignal.addEventListener(e,t,U),this.events.set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var ye,je,z=()=>je??=import("./OP3JQ447.js").then(({default:s})=>e=>s.sanitize(e)),B=async()=>typeof document<"u"&&typeof DOMParser<"u"&&typeof DocumentFragment<"u"?Promise.resolve():ye??=import("jsdom").then(({JSDOM:s})=>{let{window:e}=new s("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=e,Object.assign(globalThis,{document:e.document,DOMParser:e.DOMParser,DocumentFragment:e.DocumentFragment})}).catch(()=>{throw ye=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}),be=async s=>await s.text(),K=async s=>{await B();let e=URL.createObjectURL(await s.blob());return new Promise((t,n)=>{let r=document.createElement("script");Object.assign(r,{src:e,type:"text/javascript",async:!0}),r.onload=()=>{URL.revokeObjectURL(e),document.head.removeChild(r),t()},r.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(r),n(new Error("Script failed to load"))},document.head.appendChild(r)})},W=async s=>{await B();let e=URL.createObjectURL(await s.blob());return new Promise((t,n)=>{let r=document.createElement("link");Object.assign(r,{href:e,type:"text/css",rel:"stylesheet"}),r.onload=()=>t(URL.revokeObjectURL(e)),r.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(r),n(new Error("Stylesheet load failed"))},document.head.appendChild(r)})},Y=async s=>await s.json(),Te=async s=>await s.blob(),Q=async s=>{await B();let e=URL.createObjectURL(await s.blob());return new Promise((t,n)=>{let r=new Image;r.onload=()=>{URL.revokeObjectURL(e),t(r)},r.onerror=()=>{URL.revokeObjectURL(e),n(new Error("Image failed to load"))},r.src=e})},Ee=async s=>await s.arrayBuffer(),Z=async s=>Promise.resolve(s.body),ee=async s=>{await B();let e=await z();return new DOMParser().parseFromString(e(await s.text()),"application/xml")},te=async s=>{await B();let e=await z();return new DOMParser().parseFromString(e(await s.text()),"text/html")},Se=async s=>{await B();let e=await z();return document.createRange().createContextualFragment(e(await s.text()))},Oe=s=>({[Symbol.asyncIterator](){let e=s.body.getReader(),t=new TextDecoder,n="",r=!1;return{async next(){for(;!r;){let o=n.indexOf(`
4
+
5
+ `);if(o!==-1){let a=n.slice(0,o);n=n.slice(o+2);let d={event:"message",data:"",id:"",retry:void 0},R=[],g=a.split(`
6
+ `);for(let h=0;h<g.length;h++){let p=g[h];if(p.startsWith(":"))continue;let l=p.indexOf(":"),u,c;switch(l===-1?(u=p,c=""):(u=p.slice(0,l),c=p.slice(l+1),c.charCodeAt(0)===32&&(c=c.slice(1))),u){case"event":d.event=c;break;case"data":R.push(c);break;case"id":d.id=c;break;case"retry":{let S=parseInt(c,10);isNaN(S)||(d.retry=S);break}}}if(d.data=R.join(`
7
+ `),d.data||d.event!=="message")return{value:d,done:!1};continue}let i=await e.read();if(i.done){r=!0;break}n+=t.decode(i.value,{stream:!0})}return{value:void 0,done:!0}},async return(){return await e.cancel(),r=!0,{value:void 0,done:!0}}}}}),we=s=>({[Symbol.asyncIterator](){let e=s.body.getReader(),t=new TextDecoder,n="",r=!1;return{async next(){for(;!r;){let o=n.indexOf(`
8
+ `);if(o!==-1){let a=n.slice(0,o).trim();if(n=n.slice(o+1),a)return{value:JSON.parse(a),done:!1};continue}let i=await e.read();if(i.done){r=!0;let a=(n+t.decode()).trim();if(n="",a)return{value:JSON.parse(a),done:!1};break}n+=t.decode(i.value,{stream:!0})}return{value:void 0,done:!0}},async return(){return await e.cancel(),r=!0,{value:void 0,done:!0}}}}});var ve=s=>s!==void 0&&Re.includes(s),qe=s=>s instanceof FormData||s instanceof Blob||s instanceof ArrayBuffer||s instanceof ReadableStream||s instanceof URLSearchParams||ArrayBuffer.isView(s),Pe=s=>{if(typeof document>"u"||!document.cookie)return;let e=`${s}=`,t=document.cookie.split(";");for(let n=0,r=t.length;n<r;n++){let o=t[n].trim();if(o.startsWith(e))return decodeURIComponent(o.slice(e.length))}},He=s=>JSON.stringify(s),j=s=>s!==null&&typeof s=="string",Ae=s=>s instanceof ArrayBuffer||Object.prototype.toString.call(s)==="[object ArrayBuffer]",y=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&Object.getPrototypeOf(s)===Object.prototype,F=(...s)=>{let e=s.length;if(e===0)return;if(e===1){let[n]=s;return y(n)?se(n):n}let t={};for(let n of s){if(!y(n))return;for(let[r,o]of Object.entries(n)){let i=t[r];Array.isArray(o)?t[r]=[...o,...Array.isArray(i)?i.filter(a=>!o.includes(a)):[]]:y(o)?t[r]=y(i)?F(i,o):se(o):t[r]=o}}return t};function se(s){if(y(s)){let e={},t=Object.keys(s);for(let n=0,r=t.length,o;n<r;n++)o=t[n],e[o]=se(s[o]);return e}return s}var ke=class s{_baseUrl;_options;subscribr;hooks={beforeRequest:[],afterResponse:[],beforeError:[]};static globalSubscribr=new I;static globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]};static signalControllers=new Set;static inflightRequests=new Map;static mediaTypeCache=new Map(Object.values(m).map(e=>[e.toString(),e]));static contentTypeHandlers=[[m.TEXT.type,be],[m.JSON.subtype,Y],[m.BIN.subtype,Z],[m.HTML.subtype,te],[m.XML.subtype,ee],[m.PNG.type,Q],[m.JAVA_SCRIPT.subtype,K],[m.CSS.subtype,W]];constructor(e=G,t={}){y(e)&&([e,t]=[G,e]),this._baseUrl=s.getBaseUrl(e),this._options=s.createOptions(t,s.defaultRequestOptions),this.subscribr=new I}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=b;static defaultRequestOptions={body:void 0,cache:pe.NO_STORE,credentials:s.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":$,accept:$}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:s.RequestMode.CORS,priority:s.RequestPriority.AUTO,redirect:s.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:s.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,n){return s.globalSubscribr.subscribe(e,t,n)}static unregister(e){return s.globalSubscribr.unsubscribe(e)}static abortAll(){for(let e of this.signalControllers)e.abort(M());this.signalControllers.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],n=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),n[r]=e[r](o.signal)}try{return await Promise.race(n)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){s.contentTypeHandlers.unshift([e,t])}static unregisterContentTypeHandler(e){let t=s.contentTypeHandlers.findIndex(([n])=>n===e);return t===-1?!1:(s.contentTypeHandlers.splice(t,1),!0)}static addHooks(e){e.beforeRequest&&s.globalHooks.beforeRequest.push(...e.beforeRequest),e.afterResponse&&s.globalHooks.afterResponse.push(...e.afterResponse),e.beforeError&&s.globalHooks.beforeError.push(...e.beforeError)}static clearHooks(){s.globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]}}static unregisterAll(){s.abortAll(),s.globalSubscribr=new I,s.clearHooks(),s.inflightRequests.clear()}get baseUrl(){return this._baseUrl}register(e,t,n){return this.subscribr.subscribe(e,t,n)}unregister(e){return this.subscribr.unsubscribe(e)}addHooks(e){return e.beforeRequest&&this.hooks.beforeRequest.push(...e.beforeRequest),e.afterResponse&&this.hooks.afterResponse.push(...e.afterResponse),e.beforeError&&this.hooks.beforeError.push(...e.beforeError),this}clearHooks(){return this.hooks.beforeRequest.length=0,this.hooks.afterResponse.length=0,this.hooks.beforeError.length=0,this}configure({headers:e,searchParams:t,hooks:n,...r}){return e&&s.mergeHeaders(this._options.headers,e),t&&s.mergeSearchParams(this._options.searchParams,t),Object.keys(r).length>0&&Object.assign(this._options,r),n&&this.addHooks(n),this}destroy(){this.clearHooks(),this.subscribr.destroy()}async get(e,t){return this._get(e,t)}async post(e,t,n){return this.executeBodyMethod("POST",e,t,n)}async put(e,t,n){return this.executeBodyMethod("PUT",e,t,n)}async patch(e,t,n){return this.executeBodyMethod("PATCH",e,t,n)}async delete(e,t,n){return this.executeBodyMethod("DELETE",e,t,n)}async head(e,t){return this.execute(e,t,{method:"HEAD"})}async options(e,t={}){y(e)&&([e,t]=[void 0,e]);let n=this.processRequestOptions(t,{method:"OPTIONS"}),{requestOptions:r}=n,o=r.unwrap!==!1,i=r.hooks;try{let a=s.createUrl(this._baseUrl,e,r.searchParams),d=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,i?.beforeRequest];for(let p of d)if(p)for(let l of p){let u=await l(r,a);u&&(Object.assign(r,u),u.searchParams!==void 0&&(a=s.createUrl(this._baseUrl,e,r.searchParams)))}let R=await this._request(e,n),g=[s.globalHooks.afterResponse,this.hooks.afterResponse,i?.afterResponse];for(let p of g)if(p)for(let l of p){let u=await l(R,r);u&&(R=u)}let h=R.headers.get("allow")?.split(",").map(p=>p.trim());return this.publish({name:b.SUCCESS,data:h,global:t.global}),o?h:[!0,h]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){y(e)&&([e,t]=[void 0,e]);let n=this.processRequestOptions(t,{}),r=n.requestOptions.unwrap!==!1;try{let o=await this._request(e,n);return this.publish({name:b.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this._get(e,t,{headers:{accept:`${m.JSON}`}},Y)}async getXml(e,t){return this._get(e,t,{headers:{accept:`${m.XML}`}},ee)}async getHtml(e,t,n){let r=await this._get(e,t,{headers:{accept:`${m.HTML}`}},te);return Array.isArray(r)?r:n&&r?r.querySelector(n):r}async getHtmlFragment(e,t,n){let r=await this._get(e,t,{headers:{accept:`${m.HTML}`}},Se);return Array.isArray(r)?r:n&&r?r.querySelector(n):r}async getScript(e,t){return this._get(e,t,{headers:{accept:`${m.JAVA_SCRIPT}`}},K)}async getStylesheet(e,t){return this._get(e,t,{headers:{accept:`${m.CSS}`}},W)}async getBlob(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},Te)}async getImage(e,t){return this._get(e,t,{headers:{accept:"image/*"}},Q)}async getBuffer(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},Ee)}async getStream(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},Z)}async getEventStream(e,t){y(e)&&([e,t]=[void 0,e]);let n=this.processRequestOptions(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${m.EVENT_STREAM}`}}),{requestOptions:r}=n,o=r.unwrap!==!1,i=r.hooks;try{let a=s.createUrl(this._baseUrl,e,r.searchParams),d=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,i?.beforeRequest];for(let l of d)if(l)for(let u of l){let c=await u(r,a);c&&(Object.assign(r,c),c.searchParams!==void 0&&(a=s.createUrl(this._baseUrl,e,r.searchParams)))}let g=await this._request(e,n),h=[s.globalHooks.afterResponse,this.hooks.afterResponse,i?.afterResponse];for(let l of h)if(l)for(let u of l){let c=await u(g,r);c&&(g=c)}this.publish({name:b.SUCCESS,data:g,global:n.global});let p=Oe(g);return o?p:[!0,p]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){y(e)&&([e,t]=[void 0,e]);let n=this.processRequestOptions(t??{},{method:"GET",headers:{accept:`${m.NDJSON}`}}),{requestOptions:r}=n,o=r.unwrap!==!1,i=r.hooks;try{let a=s.createUrl(this._baseUrl,e,r.searchParams),d=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,i?.beforeRequest];for(let l of d)if(l)for(let u of l){let c=await u(r,a);c&&(Object.assign(r,c),c.searchParams!==void 0&&(a=s.createUrl(this._baseUrl,e,r.searchParams)))}let g=await this._request(e,n),h=[s.globalHooks.afterResponse,this.hooks.afterResponse,i?.afterResponse];for(let l of h)if(l)for(let u of l){let c=await u(g,r);c&&(g=c)}this.publish({name:b.SUCCESS,data:g,global:n.global});let p=we(g);return o?p:[!0,p]}catch(a){if(!o)return[!1,a];throw a}}async _get(e,t,n={},r){return this.execute(e,t,{...n,method:"GET",body:void 0},r)}async _request(e,{signalController:t,requestOptions:n,global:r}){s.signalControllers.add(t);let o=s.normalizeRetryOptions(n.retry),i=n.method??"GET",a=o.limit>0&&o.methods.includes(i),d=n.dedupe===!0&&(i==="GET"||i==="HEAD"),R=0,g=performance.now(),h=()=>{let p=performance.now();return{start:g,end:p,duration:p-g}};try{let p=s.createUrl(this._baseUrl,e,n.searchParams),l=d?`${i}:${p.href}`:"";if(d){let f=s.inflightRequests.get(l);if(f)return(await f).clone()}let u=n.body,c=n.onUploadProgress,S=async()=>{if(!c||u==null)return;let f=null;if(typeof u=="string")f=new TextEncoder().encode(u);else if(u instanceof Blob)f=new Uint8Array(await u.arrayBuffer());else if(Ae(u))f=new Uint8Array(u);else if(ArrayBuffer.isView(u))f=new Uint8Array(u.buffer,u.byteOffset,u.byteLength);else if(!(u instanceof ReadableStream))return;let E=f?f.byteLength:null,x=f?new ReadableStream({start(P){P.enqueue(f),P.close()}}):u,O=0,C=new TransformStream({transform(P,J){O+=P.byteLength,c({loaded:O,total:E,percentage:E!==null&&E>0?Math.round(O/E*100):null}),J.enqueue(P)}});n.body=x.pipeThrough(C),Object.assign(n,{duplex:"half"})},ne=async()=>{for(;;)try{await S();let f=await fetch(p,n);if(!f.ok){if(a&&R<o.limit&&o.statusCodes.includes(f.status)){R++,this.publish({name:b.RETRY,data:{attempt:R,status:f.status,method:i,path:e,timing:h()},global:r}),await s.retryDelay(o,R);continue}let E;try{E=await f.text()}catch{}throw await this.handleError(e,f,{entity:E,url:p,method:i,timing:h()},n)}return f}catch(f){if(f instanceof k)throw f;if(a&&R<o.limit){R++,this.publish({name:b.RETRY,data:{attempt:R,error:f.message,method:i,path:e,timing:h()},global:r}),await s.retryDelay(o,R);continue}throw await this.handleError(e,void 0,{cause:f,url:p,method:i,timing:h()},n)}},re=f=>{let E=n.onDownloadProgress;if(!E||!f.body)return f;let x=f.headers.get("content-length"),O=x?parseInt(x,10):null,C=0,P=new TransformStream({transform(oe,Be){C+=oe.byteLength,E({loaded:C,total:O,percentage:O!==null&&O>0?Math.round(C/O*100):null}),Be.enqueue(oe)}}),J=f.body.pipeThrough(P);return new Response(J,{status:f.status,statusText:f.statusText,headers:f.headers})};if(d){let f=ne();s.inflightRequests.set(l,f);try{let E=await f;return re(E)}finally{s.inflightRequests.delete(l)}}return re(await ne())}finally{if(s.signalControllers.delete(t.destroy()),!n.signal?.aborted){let p=h();this.publish({name:b.COMPLETE,data:{timing:p},global:r}),s.signalControllers.size===0&&this.publish({name:b.ALL_COMPLETE,global:r})}}}static normalizeRetryOptions(e){return e===void 0?{limit:0,statusCodes:[],methods:[],delay:N,backoffFactor:D}:typeof e=="number"?{limit:e,statusCodes:[...X],methods:[...V],delay:N,backoffFactor:D}:{limit:e.limit??0,statusCodes:e.statusCodes??[...X],methods:e.methods??[...V],delay:e.delay??N,backoffFactor:e.backoffFactor??D}}static retryDelay(e,t){let n=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,n))}executeBodyMethod(e,t,n,r,o){let[i,a,d]=j(t)?[t,n,r]:[void 0,t,n];return this.execute(i,Object.assign(d??{},{body:a,method:e}),{},o)}async execute(e,t={},n={},r){y(e)&&([e,t]=[void 0,e]);let o=this.processRequestOptions(t,n),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let R=s.createUrl(this._baseUrl,e,i.searchParams),g=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,d?.beforeRequest];for(let l of g)if(l)for(let u of l){let c=await u(i,R);c&&(Object.assign(i,c),c.searchParams!==void 0&&(R=s.createUrl(this._baseUrl,e,i.searchParams)))}let h=await this._request(e,o),p=[s.globalHooks.afterResponse,this.hooks.afterResponse,d?.afterResponse];for(let l of p)if(l)for(let u of l){let c=await u(h,i);c&&(h=c)}try{!r&&h.status!==204&&(r=this.getResponseHandler(h.headers.get("content-type")));let l=await r?.(h);return this.publish({name:b.SUCCESS,data:l,global:o.global}),a?l:[!0,l]}catch(l){throw await this.handleError(e,h,{cause:l},i)}}catch(R){if(!a)return[!1,R];throw R}}static createOptions({headers:e,searchParams:t,...n},{headers:r,searchParams:o,...i}){return r=s.mergeHeaders(new Headers,e,r),o=s.mergeSearchParams(new URLSearchParams,t,o),{...F(i,n),headers:r,searchParams:o}}static mergeHeaders(e,...t){for(let n of t)if(n!==void 0){if(n instanceof Headers)n.forEach((r,o)=>e.set(o,r));else if(Array.isArray(n))for(let[r,o]of n)e.set(r,o);else if(y(n))for(let[r,o]of Object.entries(n))o!==void 0&&e.set(r,o)}return e}static mergeSearchParams(e,...t){for(let n of t)if(n!==void 0)if(n instanceof URLSearchParams)n.forEach((r,o)=>e.set(o,r));else if(j(n)||Array.isArray(n))for(let[r,o]of new URLSearchParams(n))e.set(r,o);else{let r=Object.keys(n);for(let o=0;o<r.length;o++){let i=r[o],a=n[i];a!==void 0&&e.set(i,String(a))}}return e}processRequestOptions({body:e,headers:t,searchParams:n,...r},{headers:o,searchParams:i,...a}){let d={...this._options,...r,...a,headers:s.mergeHeaders(new Headers,this._options.headers,t,o),searchParams:s.mergeSearchParams(new URLSearchParams,this._options.searchParams,n,i)};if(ve(d.method))if(qe(e))Object.assign(d,{body:e}),d.headers.delete("content-type");else{let u=this._options.body,c=y(u)&&y(e)?F(u,e):e!==void 0?e:u,S=d.headers.get("content-type")?.includes("json")??!1;Object.assign(d,{body:S&&y(c)?He(c):c})}else d.headers.delete("content-type"),d.body instanceof URLSearchParams&&s.mergeSearchParams(d.searchParams,d.body),d.body=void 0;let{signal:R,timeout:g,global:h=!1,xsrf:p}=d;if(p){let{cookieName:u,headerName:c}=typeof p=="object"?p:{},S=Pe(u??le);S&&d.headers.set(c??ce,S)}let l=new _({signal:R,timeout:g}).onAbort(u=>this.publish({name:b.ABORTED,event:u,global:h})).onTimeout(u=>this.publish({name:b.TIMEOUT,event:u,global:h}));return d.signal=l.signal,this.publish({name:b.CONFIGURED,data:d,global:h}),{signalController:l,requestOptions:d,global:h}}static getBaseUrl(e){if(e instanceof URL)return e;if(!j(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static getOrParseMediaType(e){if(e===null)return;let t=s.mediaTypeCache.get(e);if(t!==void 0)return t;if(t=T.parse(e)??void 0,t!==void 0){if(s.mediaTypeCache.size>=100){let n=s.mediaTypeCache.keys().next();n.done||s.mediaTypeCache.delete(n.value)}s.mediaTypeCache.set(e,t)}return t}static createUrl(e,t,n){let r=t?new URL(`${e.pathname.replace(de,"")}${t}`,e.origin):new URL(e);return n&&s.mergeSearchParams(r.searchParams,n),r}static generateResponseStatusFromError(e,{status:t,statusText:n}=new Response){switch(e){case A.ABORT:return ge;case A.TIMEOUT:return me;default:return t>=400?new v(t,n):he}}async handleError(e,t,{cause:n,entity:r,url:o,method:i,timing:a}={},d){let R=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,g=new k(s.generateResponseStatusFromError(n?.name,t),{message:R,cause:n,entity:r,url:o,method:i,timing:a}),h=[s.globalHooks.beforeError,this.hooks.beforeError,d?.hooks?.beforeError];for(let p of h)if(p)for(let l of p){let u=await l(g);u instanceof k&&(g=u)}return this.publish({name:b.ERROR,data:g}),g}publish({name:e,event:t=new CustomEvent(e),data:n,global:r=!0}){r&&s.globalSubscribr.publish(e,t,n),this.subscribr.publish(e,t,n)}getResponseHandler(e){if(!e)return;let t=s.getOrParseMediaType(e);if(t){for(let[n,r]of s.contentTypeHandlers)if(t.matches(n))return r}}get[Symbol.toStringTag](){return"Transportr"}};
9
+ globalThis.Transportr = ke;
10
+ })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d1g1tal/transportr",
3
3
  "author": "D1g1talEntr0py",
4
- "version": "3.1.2",
4
+ "version": "3.1.3",
5
5
  "license": "MIT",
6
6
  "description": "JavaScript wrapper for the Fetch API and more...",
7
7
  "homepage": "https://github.com/D1g1talEntr0py/transportr#readme",
@@ -112,7 +112,7 @@
112
112
  "scripts": {
113
113
  "build": "tsbuild && node scripts/build-iife.js",
114
114
  "build:iife": "node scripts/build-iife.js",
115
- "build:release": "tsbuild --minify --force",
115
+ "build:release": "tsbuild --minify --force && node scripts/build-iife.js",
116
116
  "build:watch": "tsbuild --watch",
117
117
  "type-check": "tsbuild --noEmit",
118
118
  "lint": "eslint ./src",