@d1g1tal/transportr 2.1.2 → 2.2.0

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/LICENSE CHANGED
@@ -1,12 +1,21 @@
1
- Copyright (c) 2023, Jason DiMeo
1
+ MIT License
2
2
 
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided
4
- that the above copyright notice and this permission notice appear in all copies.
3
+ Copyright (c) 2023 Jason DiMeo
5
4
 
6
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
7
- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
8
- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
10
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
11
 
12
- Source: http://opensource.org/licenses/ISC
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@d1g1tal/transportr)](https://www.npmjs.com/package/@d1g1tal/transportr)
5
5
  [![CI](https://github.com/D1g1talEntr0py/transportr/actions/workflows/ci.yml/badge.svg)](https://github.com/D1g1talEntr0py/transportr/actions/workflows/ci.yml)
6
6
  [![codecov](https://codecov.io/gh/D1g1talEntr0py/transportr/graph/badge.svg)](https://codecov.io/gh/D1g1talEntr0py/transportr)
7
- [![License: ISC](https://img.shields.io/github/license/D1g1talEntr0py/transportr)](https://github.com/D1g1talEntr0py/transportr/blob/main/LICENSE)
7
+ [![License: MIT](https://img.shields.io/github/license/D1g1talEntr0py/transportr)](https://github.com/D1g1talEntr0py/transportr/blob/main/LICENSE)
8
8
  [![Node.js](https://img.shields.io/node/v/@d1g1tal/transportr)](https://nodejs.org)
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
10
10
 
@@ -23,12 +23,6 @@ A TypeScript Fetch API wrapper providing type-safe HTTP requests with advanced a
23
23
  - **HTML selectors** — Extract specific elements from HTML responses with CSS selectors
24
24
  - **FormData auto-detection** — Automatically handles FormData, Blob, ArrayBuffer, and stream bodies
25
25
 
26
- ## Installation
27
-
28
- ```bash
29
- pnpm add @d1g1tal/transportr
30
- ```
31
-
32
26
  ## Requirements
33
27
 
34
28
  - **Node.js** ≥ 20.0.0 or a modern browser with native [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and `AbortController` support
@@ -38,17 +32,40 @@ pnpm add @d1g1tal/transportr
38
32
  pnpm add jsdom
39
33
  ```
40
34
 
35
+ ## Installation
36
+
37
+ ```bash
38
+ # With pnpm:
39
+ pnpm add @d1g1tal/transportr
40
+
41
+ # Or with npm:
42
+ npm install @d1g1tal/transportr
43
+
44
+ # Or with yarn
45
+ yarn add @d1g1tal/transportr
46
+ ```
47
+
41
48
  ## Quick Start
42
49
 
50
+ Only the main module is required — the submodule constants (`HttpRequestHeader`, `HttpMediaType`, etc.) are optional conveniences. Anywhere a constant is used, a plain string works just as well.
51
+
52
+ Out of the box, every instance defaults to:
53
+ - `Content-Type: application/json; charset=utf-8`
54
+ - `Accept: application/json; charset=utf-8`
55
+ - `timeout`: 30 000 ms
56
+ - `cache`: `no-store`
57
+ - `credentials`: `same-origin`
58
+ - `mode`: `cors`
59
+
43
60
  ```typescript
44
61
  import { Transportr } from '@d1g1tal/transportr';
45
62
 
46
63
  const api = new Transportr('https://api.example.com');
47
64
 
48
- // GET JSON
65
+ // GET JSON — default Accept header is already application/json
49
66
  const data = await api.getJson('/users/1');
50
67
 
51
- // POST with JSON body
68
+ // POST with JSON body — automatically serialized, no Content-Type needed
52
69
  const created = await api.post('/users', { body: { name: 'Alice' } });
53
70
 
54
71
  // GET with search params
@@ -57,8 +74,77 @@ const results = await api.getJson('/search', { searchParams: { q: 'term', page:
57
74
  // Typed response using generics
58
75
  interface User { id: number; name: string; }
59
76
  const user = await api.get<User>('/users/1');
77
+
78
+ // Plain strings work anywhere — constants are just for convenience
79
+ const api2 = new Transportr('https://api.example.com', {
80
+ headers: { 'authorization': 'Bearer token', 'accept-language': 'en-US' }
81
+ });
82
+ ```
83
+
84
+ ## Browser / CDN Usage
85
+
86
+ The package is published as pure ESM and works directly in modern browsers — no bundler required. All dependencies (`@d1g1tal/media-type`, `@d1g1tal/subscribr`, DOMPurify) are bundled into the output, so there are no external module URLs to manage. `jsdom` is not needed in a browser environment.
87
+
88
+ ### With an import map (recommended)
89
+
90
+ An [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) mirrors the package's named submodule exports and keeps your code identical to the Node.js form — use bare specifiers exactly as you would in a bundled project:
91
+
92
+ ```html
93
+ <script type="importmap">
94
+ {
95
+ "imports": {
96
+ "@d1g1tal/transportr": "https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/transportr.js",
97
+ "@d1g1tal/transportr/headers": "https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/headers.js",
98
+ "@d1g1tal/transportr/methods": "https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/methods.js",
99
+ "@d1g1tal/transportr/media-types": "https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/media-types.js",
100
+ "@d1g1tal/transportr/response-headers": "https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/response-headers.js"
101
+ }
102
+ }
103
+ </script>
104
+
105
+ <script type="module">
106
+ import { Transportr } from '@d1g1tal/transportr';
107
+ import { HttpRequestHeader } from '@d1g1tal/transportr/headers';
108
+ import { HttpRequestMethod } from '@d1g1tal/transportr/methods';
109
+ import { HttpMediaType } from '@d1g1tal/transportr/media-types';
110
+ import { HttpResponseHeader } from '@d1g1tal/transportr/response-headers';
111
+
112
+ const api = new Transportr('https://api.example.com', {
113
+ headers: {
114
+ [HttpRequestHeader.AUTHORIZATION]: 'Bearer token',
115
+ [HttpRequestHeader.ACCEPT]: HttpMediaType.JSON
116
+ }
117
+ });
118
+
119
+ const data = await api.getJson('/users/1');
120
+ console.log(data);
121
+ </script>
60
122
  ```
61
123
 
124
+ ### Without an import map
125
+
126
+ The CDN resolves the `"."` entry in `exports` automatically, so no explicit file path is needed for the main module. Submodules use their CDN paths directly:
127
+
128
+ ```html
129
+ <script type="module">
130
+ import { Transportr } from 'https://cdn.jsdelivr.net/npm/@d1g1tal/transportr';
131
+ import { HttpRequestHeader } from 'https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/headers.js';
132
+ import { HttpMediaType } from 'https://cdn.jsdelivr.net/npm/@d1g1tal/transportr/dist/media-types.js';
133
+
134
+ const api = new Transportr('https://api.example.com', {
135
+ headers: {
136
+ [HttpRequestHeader.AUTHORIZATION]: 'Bearer token',
137
+ [HttpRequestHeader.ACCEPT]: HttpMediaType.JSON
138
+ }
139
+ });
140
+
141
+ const data = await api.getJson('/users/1');
142
+ console.log(data);
143
+ </script>
144
+ ```
145
+
146
+ Import map support is available in all browsers covered by this project's `browserslist` configuration (Chrome 89+, Firefox 108+, Safari 16.4+).
147
+
62
148
  ## API
63
149
 
64
150
  ### Constructor
@@ -339,21 +425,66 @@ api
339
425
 
340
426
  ### Submodule Imports
341
427
 
342
- HTTP constant objects are available as named submodule imports rather than static class properties:
428
+ HTTP constant objects are available as named submodule imports. Each is a tree-shakeable, side-effect-free object of string constants — useful for avoiding magic strings and getting autocomplete.
429
+
430
+ #### `@d1g1tal/transportr/headers`
431
+
432
+ Request header name constants.
343
433
 
344
434
  ```typescript
345
- import { HttpMediaType } from '@d1g1tal/transportr/media-types';
346
- import { HttpRequestMethod } from '@d1g1tal/transportr/methods';
347
435
  import { HttpRequestHeader } from '@d1g1tal/transportr/headers';
348
- import { HttpResponseHeader } from '@d1g1tal/transportr/response-headers';
436
+
437
+ const api = new Transportr('https://api.example.com', {
438
+ headers: {
439
+ [HttpRequestHeader.AUTHORIZATION]: 'Bearer token',
440
+ [HttpRequestHeader.CONTENT_TYPE]: 'application/json',
441
+ [HttpRequestHeader.ACCEPT_LANGUAGE]: 'en-US'
442
+ }
443
+ });
349
444
  ```
350
445
 
351
- | Submodule | Export | Description |
352
- |-----------|--------|-------------|
353
- | `@d1g1tal/transportr/media-types` | `HttpMediaType` | MIME type string constants |
354
- | `@d1g1tal/transportr/methods` | `HttpRequestMethod` | HTTP method string constants |
355
- | `@d1g1tal/transportr/headers` | `HttpRequestHeader` | Request header name constants |
356
- | `@d1g1tal/transportr/response-headers` | `HttpResponseHeader` | Response header name constants |
446
+ #### `@d1g1tal/transportr/methods`
447
+
448
+ HTTP method string constants.
449
+
450
+ ```typescript
451
+ import { HttpRequestMethod } from '@d1g1tal/transportr/methods';
452
+
453
+ const response = await api.request('/data', { method: HttpRequestMethod.PATCH });
454
+ ```
455
+
456
+ #### `@d1g1tal/transportr/media-types`
457
+
458
+ MIME type string constants covering common content types (JSON, HTML, XML, CSS, images, audio, video, and more).
459
+
460
+ ```typescript
461
+ import { HttpMediaType } from '@d1g1tal/transportr/media-types';
462
+
463
+ const api = new Transportr('https://api.example.com', {
464
+ headers: { [HttpRequestHeader.ACCEPT]: HttpMediaType.JSON }
465
+ });
466
+
467
+ // Use as a content-type value
468
+ await api.post('/upload', {
469
+ body: csvData,
470
+ headers: { [HttpRequestHeader.CONTENT_TYPE]: HttpMediaType.CSV }
471
+ });
472
+ ```
473
+
474
+ #### `@d1g1tal/transportr/response-headers`
475
+
476
+ Response header name constants — useful when reading headers from a response.
477
+
478
+ ```typescript
479
+ import { HttpResponseHeader } from '@d1g1tal/transportr/response-headers';
480
+
481
+ const reg = api.register(Transportr.RequestEvents.SUCCESS, (event, data) => {
482
+ const response = data as Response;
483
+ const etag = response.headers.get(HttpResponseHeader.ETAG);
484
+ const retryAfter = response.headers.get(HttpResponseHeader.RETRY_AFTER);
485
+ const location = response.headers.get(HttpResponseHeader.LOCATION);
486
+ });
487
+ ```
357
488
 
358
489
  ## License
359
490
 
@@ -1,4 +1,4 @@
1
- import { Subscription } from "@d1g1tal/subscribr";
1
+ import type { Subscription } from "@d1g1tal/subscribr";
2
2
  import { MediaType } from "@d1g1tal/media-type";
3
3
 
4
4
  /**
@@ -1,3 +1,3 @@
1
- var P=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,me=/(["\\])/ug,ye=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,W=class K extends Map{constructor(e=[]){super(e)}static isValid(e,t){return P.test(e)&&ye.test(t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}set(e,t){if(!K.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||!P.test(t)?`"${t.replace(me,"\\$1")}"`:t}`).join("")}get[Symbol.toStringTag](){return"MediaTypeParameters"}},be=new Set([" "," ",`
2
- `,"\r"]),Ee=/[ \t\n\r]+$/u,Te=/^[ \t\n\r]+|[ \t\n\r]+$/ug,Oe=class E{static parse(e){e=e.replace(Te,"");let t=0,[r,n]=E.collect(e,t,["/"]);if(t=n,!r.length||t>=e.length||!P.test(r))throw new TypeError(E.generateErrorMessage("type",r));++t;let[o,i]=E.collect(e,t,[";"],!0,!0);if(t=i,!o.length||!P.test(o))throw new TypeError(E.generateErrorMessage("subtype",o));let u=new W;for(;t<e.length;){for(++t;be.has(e[t]);)++t;let a;if([a,t]=E.collect(e,t,[";","="],!1),t>=e.length||e[t]===";")continue;++t;let l;if(e[t]==='"')for([l,t]=E.collectHttpQuotedString(e,t);t<e.length&&e[t]!==";";)++t;else if([l,t]=E.collect(e,t,[";"],!1,!0),!l)continue;a&&W.isValid(a,l)&&!u.has(a)&&u.set(a,l)}return{type:r,subtype:o,parameters:u}}get[Symbol.toStringTag](){return"MediaTypeParser"}static collect(e,t,r,n=!0,o=!1){let i="";for(let{length:u}=e;t<u&&!r.includes(e[t]);t++)i+=e[t];return n&&(i=i.toLowerCase()),o&&(i=i.replace(Ee,"")),[i,t]}static collectHttpQuotedString(e,t){let r="";for(let n=e.length,o;++t<n&&(o=e[t])!=='"';)r+=o=="\\"&&++t<n?e[t]:o;return[r,t]}static generateErrorMessage(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},y=class Y{_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}=Oe.parse(e));for(let[r,n]of Object.entries(t))this._parameters.set(r,n)}static parse(e){try{return new Y(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 Se=class extends Map{set(s,e){return super.set(s,e instanceof Set?e:(super.get(s)??new Set).add(e)),this}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 r=t.delete(e);return t.size===0&&super.delete(s),r}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},ve=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"}},we=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"}},C=class{subscribers=new Se;errorHandler;setErrorHandler(s){this.errorHandler=s}subscribe(s,e,t=e,r){if(this.validateEventName(s),r?.once){let i=e;e=(u,a)=>{i.call(t,u,a),this.unsubscribe(o)}}let n=new ve(t,e);this.subscribers.set(s,n);let o=new we(s,n);return o}unsubscribe({eventName:s,contextEventHandler:e}){let t=this.subscribers.get(s)??new Set,r=t.delete(e);return r&&t.size===0&&this.subscribers.delete(s),r}publish(s,e=new CustomEvent(s),t){this.validateEventName(s),this.subscribers.get(s)?.forEach(r=>{try{r.handle(e,t)}catch(n){this.errorHandler?this.errorHandler(n,s,e,t):console.error(`Error in event handler for '${s}':`,n)}})}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 v=class extends Error{_entity;responseStatus;_url;_method;_timing;constructor(e,{message:t,cause:r,entity:n,url:o,method:i,timing:u}={}){super(t,{cause:r}),this._entity=n,this.responseStatus=e,this._url=o,this._method=i,this._timing=u}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 T=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 w={charset:"utf-8"},Q=/\/$/,Z="XSRF-TOKEN",ee="X-XSRF-TOKEN",R={PNG:new y("image/png"),TEXT:new y("text/plain",w),JSON:new y("application/json",w),HTML:new y("text/html",w),JAVA_SCRIPT:new y("text/javascript",w),CSS:new y("text/css",w),XML:new y("application/xml",w),BIN:new y("application/octet-stream")},x=R.JSON.toString(),te={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},O={ABORT:"abort",TIMEOUT:"timeout"},S={ABORT:"AbortError",TIMEOUT:"TimeoutError"},H={once:!0,passive:!0},L=()=>new CustomEvent(O.ABORT,{detail:{cause:S.ABORT}}),se=()=>new CustomEvent(O.TIMEOUT,{detail:{cause:S.TIMEOUT}}),re=["POST","PUT","PATCH","DELETE"],ne=new T(500,"Internal Server Error"),oe=new T(499,"Aborted"),ie=new T(504,"Request Timeout"),I=[408,413,429,500,502,503,504],B=["GET","PUT","HEAD","DELETE","OPTIONS"],k=300,A=2;var M=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 r=[this.abortController.signal];e!=null&&r.push(e),t!==1/0&&r.push(AbortSignal.timeout(t)),(this.abortSignal=AbortSignal.any(r)).addEventListener(O.ABORT,this,H)}handleEvent({target:{reason:e}}){this.abortController.signal.aborted||e instanceof DOMException&&e.name===S.TIMEOUT&&this.abortSignal.dispatchEvent(se())}get signal(){return this.abortSignal}onAbort(e){return this.addEventListener(O.ABORT,e)}onTimeout(e){return this.addEventListener(O.TIMEOUT,e)}abort(e=L()){this.abortController.abort(e.detail?.cause)}destroy(){this.abortSignal.removeEventListener(O.ABORT,this,H);for(let[e,t]of this.events)this.abortSignal.removeEventListener(t,e,H);return this.events.clear(),this}addEventListener(e,t){return this.abortSignal.addEventListener(e,t,H),this.events.set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var ae,qe,N=()=>qe??=import("./OP3JQ447.js").then(({default:s})=>e=>s.sanitize(e)),q=async()=>typeof document<"u"&&typeof DOMParser<"u"&&typeof DocumentFragment<"u"?Promise.resolve():ae??=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 ae=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}),ce=async s=>await s.text(),_=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=document.createElement("script");Object.assign(n,{src:e,type:"text/javascript",async:!0}),n.onload=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),t()},n.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),r(new Error("Script failed to load"))},document.head.appendChild(n)})},D=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=document.createElement("link");Object.assign(n,{href:e,type:"text/css",rel:"stylesheet"}),n.onload=()=>t(URL.revokeObjectURL(e)),n.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),r(new Error("Stylesheet load failed"))},document.head.appendChild(n)})},j=async s=>await s.json(),ue=async s=>await s.blob(),F=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=new Image;n.onload=()=>{URL.revokeObjectURL(e),t(n)},n.onerror=()=>{URL.revokeObjectURL(e),r(new Error("Image failed to load"))},n.src=e})},le=async s=>await s.arrayBuffer(),$=async s=>Promise.resolve(s.body),G=async s=>{await q();let e=await N();return new DOMParser().parseFromString(e(await s.text()),"application/xml")},J=async s=>{await q();let e=await N();return new DOMParser().parseFromString(e(await s.text()),"text/html")},de=async s=>{await q();let e=await N();return document.createRange().createContextualFragment(e(await s.text()))};var pe=s=>s!==void 0&&re.includes(s),fe=s=>s instanceof FormData||s instanceof Blob||s instanceof ArrayBuffer||s instanceof ReadableStream||s instanceof URLSearchParams||ArrayBuffer.isView(s),he=s=>{if(typeof document>"u"||!document.cookie)return;let e=`${s}=`,t=document.cookie.split(";");for(let r=0,n=t.length;r<n;r++){let o=t[r].trim();if(o.startsWith(e))return decodeURIComponent(o.slice(e.length))}},ge=s=>JSON.stringify(s),z=s=>s!==null&&typeof s=="string",b=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&Object.getPrototypeOf(s)===Object.prototype,V=(...s)=>{let e=s.length;if(e===0)return;if(e===1){let[r]=s;return b(r)?X(r):r}let t={};for(let r of s){if(!b(r))return;for(let[n,o]of Object.entries(r)){let i=t[n];Array.isArray(o)?t[n]=[...o,...Array.isArray(i)?i.filter(u=>!o.includes(u)):[]]:b(o)?t[n]=b(i)?V(i,o):X(o):t[n]=o}}return t};function X(s){if(b(s)){let e={},t=Object.keys(s);for(let r=0,n=t.length,o;r<n;r++)o=t[r],e[o]=X(s[o]);return e}return s}var Re=class s{_baseUrl;_options;subscribr;hooks={beforeRequest:[],afterResponse:[],beforeError:[]};static globalSubscribr=new C;static globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]};static signalControllers=new Set;static inflightRequests=new Map;static mediaTypeCache=new Map(Object.values(R).map(e=>[e.toString(),e]));static contentTypeHandlers=[[R.TEXT.type,ce],[R.JSON.subtype,j],[R.BIN.subtype,$],[R.HTML.subtype,J],[R.XML.subtype,G],[R.PNG.type,F],[R.JAVA_SCRIPT.subtype,_],[R.CSS.subtype,D]];constructor(e=globalThis.location?.origin??"http://localhost",t={}){b(e)&&([e,t]=[globalThis.location?.origin??"http://localhost",e]),this._baseUrl=s.getBaseUrl(e),this._options=s.createOptions(t,s.defaultRequestOptions),this.subscribr=new C}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestModes={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriorities={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicies={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 RequestEvents=m;static defaultRequestOptions={body:void 0,cache:te.NO_STORE,credentials:s.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":x,accept:x}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:s.RequestModes.CORS,priority:s.RequestPriorities.AUTO,redirect:s.RedirectPolicies.FOLLOW,referrer:"about:client",referrerPolicy:s.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,r){return s.globalSubscribr.subscribe(e,t,r)}static unregister(e){return s.globalSubscribr.unsubscribe(e)}static abortAll(){for(let e of this.signalControllers)e.abort(L());this.signalControllers.clear()}static registerContentTypeHandler(e,t){s.contentTypeHandlers.unshift([e,t])}static unregisterContentTypeHandler(e){let t=s.contentTypeHandlers.findIndex(([r])=>r===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 C,s.clearHooks(),s.inflightRequests.clear()}get baseUrl(){return this._baseUrl}register(e,t,r){return this.subscribr.subscribe(e,t,r)}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}destroy(){this.clearHooks(),this.subscribr.destroy()}async get(e,t){return this._get(e,t)}async post(e,t){return typeof e!="string"&&([e,t]=[void 0,e]),this.execute(e,t,{method:"POST"})}async put(e,t){return this.execute(e,t,{method:"PUT"})}async patch(e,t){return this.execute(e,t,{method:"PATCH"})}async delete(e,t){return this.execute(e,t,{method:"DELETE"})}async head(e,t){return this.execute(e,t,{method:"HEAD"})}async options(e,t={}){b(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t,{method:"OPTIONS"}),{requestOptions:n}=r,o=n.hooks,i=s.createUrl(this._baseUrl,e,n.searchParams),u=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,o?.beforeRequest];for(let d of u)if(d)for(let c of d){let g=await c(n,i);g&&(Object.assign(n,g),g.searchParams!==void 0&&(i=s.createUrl(this._baseUrl,e,n.searchParams)))}let a=await this._request(e,r),l=[s.globalHooks.afterResponse,this.hooks.afterResponse,o?.afterResponse];for(let d of l)if(d)for(let c of d){let g=await c(a,n);g&&(a=g)}let h=a.headers.get("allow")?.split(",").map(d=>d.trim());return this.publish({name:m.SUCCESS,data:h,global:t.global}),h}async request(e,t={}){b(e)&&([e,t]=[void 0,e]);let r=await this._request(e,this.processRequestOptions(t,{}));return this.publish({name:m.SUCCESS,data:r,global:t.global}),r}async getJson(e,t){return this._get(e,t,{headers:{accept:`${R.JSON}`}},j)}async getXml(e,t){return this._get(e,t,{headers:{accept:`${R.XML}`}},G)}async getHtml(e,t,r){let n=await this._get(e,t,{headers:{accept:`${R.HTML}`}},J);return r&&n?n.querySelector(r):n}async getHtmlFragment(e,t,r){let n=await this._get(e,t,{headers:{accept:`${R.HTML}`}},de);return r&&n?n.querySelector(r):n}async getScript(e,t){return this._get(e,t,{headers:{accept:`${R.JAVA_SCRIPT}`}},_)}async getStylesheet(e,t){return this._get(e,t,{headers:{accept:`${R.CSS}`}},D)}async getBlob(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},ue)}async getImage(e,t){return this._get(e,t,{headers:{accept:"image/*"}},F)}async getBuffer(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},le)}async getStream(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},$)}async _get(e,t,r={},n){return this.execute(e,t,{...r,method:"GET",body:void 0},n)}async _request(e,{signalController:t,requestOptions:r,global:n}){s.signalControllers.add(t);let o=s.normalizeRetryOptions(r.retry),i=r.method??"GET",u=o.limit>0&&o.methods.includes(i),a=r.dedupe===!0&&(i==="GET"||i==="HEAD"),l=0,h=performance.now(),d=()=>{let c=performance.now();return{start:h,end:c,duration:c-h}};try{let c=s.createUrl(this._baseUrl,e,r.searchParams),g=a?`${i}:${c.href}`:"";if(a){let f=s.inflightRequests.get(g);if(f)return(await f).clone()}let p=async()=>{for(;;)try{let f=await fetch(c,r);if(!f.ok){if(u&&l<o.limit&&o.statusCodes.includes(f.status)){l++,this.publish({name:m.RETRY,data:{attempt:l,status:f.status,method:i,path:e,timing:d()},global:n}),await s.retryDelay(o,l);continue}let U;try{U=await f.text()}catch{}throw await this.handleError(e,f,{entity:U,url:c,method:i,timing:d()},r)}return f}catch(f){if(f instanceof v)throw f;if(u&&l<o.limit){l++,this.publish({name:m.RETRY,data:{attempt:l,error:f.message,method:i,path:e,timing:d()},global:n}),await s.retryDelay(o,l);continue}throw await this.handleError(e,void 0,{cause:f,url:c,method:i,timing:d()},r)}};if(a){let f=p();s.inflightRequests.set(g,f);try{return await f}finally{s.inflightRequests.delete(g)}}return await p()}finally{if(s.signalControllers.delete(t.destroy()),!r.signal?.aborted){let c=d();this.publish({name:m.COMPLETE,data:{timing:c},global:n}),s.signalControllers.size===0&&this.publish({name:m.ALL_COMPLETE,global:n})}}}static normalizeRetryOptions(e){return e===void 0?{limit:0,statusCodes:[],methods:[],delay:k,backoffFactor:A}:typeof e=="number"?{limit:e,statusCodes:[...I],methods:[...B],delay:k,backoffFactor:A}:{limit:e.limit??0,statusCodes:e.statusCodes??[...I],methods:e.methods??[...B],delay:e.delay??k,backoffFactor:e.backoffFactor??A}}static retryDelay(e,t){let r=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(n=>setTimeout(n,r))}async execute(e,t={},r={},n){b(e)&&([e,t]=[void 0,e]);let o=this.processRequestOptions(t,r),{requestOptions:i}=o,u=i.hooks,a=s.createUrl(this._baseUrl,e,i.searchParams),l=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,u?.beforeRequest];for(let c of l)if(c)for(let g of c){let p=await g(i,a);p&&(Object.assign(i,p),p.searchParams!==void 0&&(a=s.createUrl(this._baseUrl,e,i.searchParams)))}let h=await this._request(e,o),d=[s.globalHooks.afterResponse,this.hooks.afterResponse,u?.afterResponse];for(let c of d)if(c)for(let g of c){let p=await g(h,i);p&&(h=p)}try{!n&&h.status!==204&&(n=this.getResponseHandler(h.headers.get("content-type")));let c=await n?.(h);return this.publish({name:m.SUCCESS,data:c,global:o.global}),c}catch(c){throw await this.handleError(e,h,{cause:c},i)}}static createOptions({headers:e,searchParams:t,...r},{headers:n,searchParams:o,...i}){return n=s.mergeHeaders(new Headers,e,n),o=s.mergeSearchParams(new URLSearchParams,t,o),{...V(i,r)??{},headers:n,searchParams:o}}static mergeHeaders(e,...t){for(let r of t)if(r!==void 0)if(r instanceof Headers)r.forEach((n,o)=>e.set(o,n));else if(Array.isArray(r))for(let[n,o]of r)e.set(n,o);else{let n=r,o=Object.keys(n);for(let i=0;i<o.length;i++){let u=o[i],a=n[u];a!==void 0&&e.set(u,String(a))}}return e}static mergeSearchParams(e,...t){for(let r of t)if(r!==void 0)if(r instanceof URLSearchParams)r.forEach((n,o)=>e.set(o,n));else if(z(r)||Array.isArray(r))for(let[n,o]of new URLSearchParams(r))e.set(n,o);else{let n=Object.keys(r);for(let o=0;o<n.length;o++){let i=n[o],u=r[i];u!==void 0&&e.set(i,String(u))}}return e}processRequestOptions({body:e,headers:t,searchParams:r,...n},{headers:o,searchParams:i,...u}){let a={...this._options,...n,...u,headers:s.mergeHeaders(new Headers,this._options.headers,t,o),searchParams:s.mergeSearchParams(new URLSearchParams,this._options.searchParams,r,i)};if(pe(a.method))if(fe(e))a.body=e,a.headers.delete("content-type");else{let p=a.headers.get("content-type")?.includes("json")??!1;a.body=p&&b(e)?ge(e):e}else a.headers.delete("content-type"),a.body instanceof URLSearchParams&&s.mergeSearchParams(a.searchParams,a.body),a.body=void 0;let{signal:l,timeout:h,global:d=!1,xsrf:c}=a;if(c){let p=typeof c=="object"?c:{},f=he(p.cookieName??Z);f&&a.headers.set(p.headerName??ee,f)}let g=new M({signal:l,timeout:h}).onAbort(p=>this.publish({name:m.ABORTED,event:p,global:d})).onTimeout(p=>this.publish({name:m.TIMEOUT,event:p,global:d}));return a.signal=g.signal,this.publish({name:m.CONFIGURED,data:a,global:d}),{signalController:g,requestOptions:a,global:d}}static getBaseUrl(e){if(e instanceof URL)return e;if(!z(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=y.parse(e)??void 0,t!==void 0){if(s.mediaTypeCache.size>=100){let r=s.mediaTypeCache.keys().next().value;r!==void 0&&s.mediaTypeCache.delete(r)}s.mediaTypeCache.set(e,t)}return t}static createUrl(e,t,r){let n=t?new URL(`${e.pathname.replace(Q,"")}${t}`,e.origin):new URL(e);return r&&s.mergeSearchParams(n.searchParams,r),n}static generateResponseStatusFromError(e,{status:t,statusText:r}=new Response){switch(e){case S.ABORT:return oe;case S.TIMEOUT:return ie;default:return t>=400?new T(t,r):ne}}async handleError(e,t,{cause:r,entity:n,url:o,method:i,timing:u}={},a){let l=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,h=new v(s.generateResponseStatusFromError(r?.name,t),{message:l,cause:r,entity:n,url:o,method:i,timing:u}),d=[s.globalHooks.beforeError,this.hooks.beforeError,a?.hooks?.beforeError];for(let c of d)if(c)for(let g of c){let p=await g(h);p instanceof v&&(h=p)}return this.publish({name:m.ERROR,data:h}),h}publish({name:e,event:t=new CustomEvent(e),data:r,global:n=!0}){n&&s.globalSubscribr.publish(e,t,r),this.subscribr.publish(e,t,r)}getResponseHandler(e){if(!e)return;let t=s.getOrParseMediaType(e);if(t){for(let[r,n]of s.contentTypeHandlers)if(t.matches(r))return n}}get[Symbol.toStringTag](){return"Transportr"}};export{Re as Transportr};
1
+ var C=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,me=/(["\\])/ug,ye=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,K=class W extends Map{constructor(e=[]){super(e)}static isValid(e,t){return C.test(e)&&ye.test(t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}set(e,t){if(!W.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||!C.test(t)?`"${t.replace(me,"\\$1")}"`:t}`).join("")}get[Symbol.toStringTag](){return"MediaTypeParameters"}},be=new Set([" "," ",`
2
+ `,"\r"]),Ee=/[ \t\n\r]+$/u,Te=/^[ \t\n\r]+|[ \t\n\r]+$/ug,Oe=class E{static parse(e){e=e.replace(Te,"");let t=0,[r,n]=E.collect(e,t,["/"]);if(t=n,!r.length||t>=e.length||!C.test(r))throw new TypeError(E.generateErrorMessage("type",r));++t;let[o,i]=E.collect(e,t,[";"],!0,!0);if(t=i,!o.length||!C.test(o))throw new TypeError(E.generateErrorMessage("subtype",o));let l=new K;for(;t<e.length;){for(++t;be.has(e[t]);)++t;let a;if([a,t]=E.collect(e,t,[";","="],!1),t>=e.length||e[t]===";")continue;++t;let c;if(e[t]==='"')for([c,t]=E.collectHttpQuotedString(e,t);t<e.length&&e[t]!==";";)++t;else if([c,t]=E.collect(e,t,[";"],!1,!0),!c)continue;a&&K.isValid(a,c)&&!l.has(a)&&l.set(a,c)}return{type:r,subtype:o,parameters:l}}get[Symbol.toStringTag](){return"MediaTypeParser"}static collect(e,t,r,n=!0,o=!1){let i="";for(let{length:l}=e;t<l&&!r.includes(e[t]);t++)i+=e[t];return n&&(i=i.toLowerCase()),o&&(i=i.replace(Ee,"")),[i,t]}static collectHttpQuotedString(e,t){let r="";for(let n=e.length,o;++t<n&&(o=e[t])!=='"';)r+=o=="\\"&&++t<n?e[t]:o;return[r,t]}static generateErrorMessage(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},y=class Y{_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}=Oe.parse(e));for(let[r,n]of Object.entries(t))this._parameters.set(r,n)}static parse(e){try{return new Y(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 Se=class extends Map{set(s,e){return super.set(s,e instanceof Set?e:(super.get(s)??new Set).add(e)),this}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 r=t.delete(e);return t.size===0&&super.delete(s),r}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},ve=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"}},we=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"}},P=class{subscribers=new Se;errorHandler;setErrorHandler(s){this.errorHandler=s}subscribe(s,e,t=e,r){if(this.validateEventName(s),r?.once){let i=e;e=(l,a)=>{i.call(t,l,a),this.unsubscribe(o)}}let n=new ve(t,e);this.subscribers.set(s,n);let o=new we(s,n);return o}unsubscribe({eventName:s,contextEventHandler:e}){let t=this.subscribers.get(s)??new Set,r=t.delete(e);return r&&t.size===0&&this.subscribers.delete(s),r}publish(s,e=new CustomEvent(s),t){this.validateEventName(s),this.subscribers.get(s)?.forEach(r=>{try{r.handle(e,t)}catch(n){this.errorHandler?this.errorHandler(n,s,e,t):console.error(`Error in event handler for '${s}':`,n)}})}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 v=class extends Error{_entity;responseStatus;_url;_method;_timing;constructor(e,{message:t,cause:r,entity:n,url:o,method:i,timing:l}={}){super(t,{cause:r}),this._entity=n,this.responseStatus=e,this._url=o,this._method=i,this._timing=l}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 T=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 w={charset:"utf-8"},Q=/\/$/,Z="XSRF-TOKEN",ee="X-XSRF-TOKEN",R={PNG:new y("image/png"),TEXT:new y("text/plain",w),JSON:new y("application/json",w),HTML:new y("text/html",w),JAVA_SCRIPT:new y("text/javascript",w),CSS:new y("text/css",w),XML:new y("application/xml",w),BIN:new y("application/octet-stream")},x=R.JSON.toString(),te={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},O={ABORT:"abort",TIMEOUT:"timeout"},S={ABORT:"AbortError",TIMEOUT:"TimeoutError"},H={once:!0,passive:!0},L=()=>new CustomEvent(O.ABORT,{detail:{cause:S.ABORT}}),se=()=>new CustomEvent(O.TIMEOUT,{detail:{cause:S.TIMEOUT}}),re=["POST","PUT","PATCH","DELETE"],ne=new T(500,"Internal Server Error"),oe=new T(499,"Aborted"),ie=new T(504,"Request Timeout"),I=[408,413,429,500,502,503,504],N=["GET","PUT","HEAD","DELETE","OPTIONS"],k=300,A=2;var U=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 r=[this.abortController.signal];e!=null&&r.push(e),t!==1/0&&r.push(AbortSignal.timeout(t)),(this.abortSignal=AbortSignal.any(r)).addEventListener(O.ABORT,this,H)}handleEvent({target:{reason:e}}){this.abortController.signal.aborted||e instanceof DOMException&&e.name===S.TIMEOUT&&this.abortSignal.dispatchEvent(se())}get signal(){return this.abortSignal}onAbort(e){return this.addEventListener(O.ABORT,e)}onTimeout(e){return this.addEventListener(O.TIMEOUT,e)}abort(e=L()){this.abortController.abort(e.detail?.cause)}destroy(){this.abortSignal.removeEventListener(O.ABORT,this,H);for(let[e,t]of this.events)this.abortSignal.removeEventListener(t,e,H);return this.events.clear(),this}addEventListener(e,t){return this.abortSignal.addEventListener(e,t,H),this.events.set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var ae,qe,B=()=>qe??=import("./OP3JQ447.js").then(({default:s})=>e=>s.sanitize(e)),q=async()=>typeof document<"u"&&typeof DOMParser<"u"&&typeof DocumentFragment<"u"?Promise.resolve():ae??=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 ae=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}),ue=async s=>await s.text(),_=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=document.createElement("script");Object.assign(n,{src:e,type:"text/javascript",async:!0}),n.onload=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),t()},n.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),r(new Error("Script failed to load"))},document.head.appendChild(n)})},D=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=document.createElement("link");Object.assign(n,{href:e,type:"text/css",rel:"stylesheet"}),n.onload=()=>t(URL.revokeObjectURL(e)),n.onerror=()=>{URL.revokeObjectURL(e),document.head.removeChild(n),r(new Error("Stylesheet load failed"))},document.head.appendChild(n)})},j=async s=>await s.json(),le=async s=>await s.blob(),F=async s=>{await q();let e=URL.createObjectURL(await s.blob());return new Promise((t,r)=>{let n=new Image;n.onload=()=>{URL.revokeObjectURL(e),t(n)},n.onerror=()=>{URL.revokeObjectURL(e),r(new Error("Image failed to load"))},n.src=e})},ce=async s=>await s.arrayBuffer(),$=async s=>Promise.resolve(s.body),G=async s=>{await q();let e=await B();return new DOMParser().parseFromString(e(await s.text()),"application/xml")},J=async s=>{await q();let e=await B();return new DOMParser().parseFromString(e(await s.text()),"text/html")},de=async s=>{await q();let e=await B();return document.createRange().createContextualFragment(e(await s.text()))};var pe=s=>s!==void 0&&re.includes(s),fe=s=>s instanceof FormData||s instanceof Blob||s instanceof ArrayBuffer||s instanceof ReadableStream||s instanceof URLSearchParams||ArrayBuffer.isView(s),he=s=>{if(typeof document>"u"||!document.cookie)return;let e=`${s}=`,t=document.cookie.split(";");for(let r=0,n=t.length;r<n;r++){let o=t[r].trim();if(o.startsWith(e))return decodeURIComponent(o.slice(e.length))}},ge=s=>JSON.stringify(s),z=s=>s!==null&&typeof s=="string",b=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&Object.getPrototypeOf(s)===Object.prototype,V=(...s)=>{let e=s.length;if(e===0)return;if(e===1){let[r]=s;return b(r)?X(r):r}let t={};for(let r of s){if(!b(r))return;for(let[n,o]of Object.entries(r)){let i=t[n];Array.isArray(o)?t[n]=[...o,...Array.isArray(i)?i.filter(l=>!o.includes(l)):[]]:b(o)?t[n]=b(i)?V(i,o):X(o):t[n]=o}}return t};function X(s){if(b(s)){let e={},t=Object.keys(s);for(let r=0,n=t.length,o;r<n;r++)o=t[r],e[o]=X(s[o]);return e}return s}var Re=class s{_baseUrl;_options;subscribr;hooks={beforeRequest:[],afterResponse:[],beforeError:[]};static globalSubscribr=new P;static globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]};static signalControllers=new Set;static inflightRequests=new Map;static mediaTypeCache=new Map(Object.values(R).map(e=>[e.toString(),e]));static contentTypeHandlers=[[R.TEXT.type,ue],[R.JSON.subtype,j],[R.BIN.subtype,$],[R.HTML.subtype,J],[R.XML.subtype,G],[R.PNG.type,F],[R.JAVA_SCRIPT.subtype,_],[R.CSS.subtype,D]];constructor(e=globalThis.location?.origin??"http://localhost",t={}){b(e)&&([e,t]=[globalThis.location?.origin??"http://localhost",e]),this._baseUrl=s.getBaseUrl(e),this._options=s.createOptions(t,s.defaultRequestOptions),this.subscribr=new P}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestModes={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriorities={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicies={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 RequestEvents=m;static defaultRequestOptions={body:void 0,cache:te.NO_STORE,credentials:s.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":x,accept:x}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:s.RequestModes.CORS,priority:s.RequestPriorities.AUTO,redirect:s.RedirectPolicies.FOLLOW,referrer:"about:client",referrerPolicy:s.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,r){return s.globalSubscribr.subscribe(e,t,r)}static unregister(e){return s.globalSubscribr.unsubscribe(e)}static abortAll(){for(let e of this.signalControllers)e.abort(L());this.signalControllers.clear()}static registerContentTypeHandler(e,t){s.contentTypeHandlers.unshift([e,t])}static unregisterContentTypeHandler(e){let t=s.contentTypeHandlers.findIndex(([r])=>r===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 P,s.clearHooks(),s.inflightRequests.clear()}get baseUrl(){return this._baseUrl}register(e,t,r){return this.subscribr.subscribe(e,t,r)}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}destroy(){this.clearHooks(),this.subscribr.destroy()}async get(e,t){return this._get(e,t)}async post(e,t){return typeof e!="string"&&([e,t]=[void 0,e]),this.execute(e,t,{method:"POST"})}async put(e,t){return this.execute(e,t,{method:"PUT"})}async patch(e,t){return this.execute(e,t,{method:"PATCH"})}async delete(e,t){return this.execute(e,t,{method:"DELETE"})}async head(e,t){return this.execute(e,t,{method:"HEAD"})}async options(e,t={}){b(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t,{method:"OPTIONS"}),{requestOptions:n}=r,o=n.hooks,i=s.createUrl(this._baseUrl,e,n.searchParams),l=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,o?.beforeRequest];for(let d of l)if(d)for(let u of d){let g=await u(n,i);g&&(Object.assign(n,g),g.searchParams!==void 0&&(i=s.createUrl(this._baseUrl,e,n.searchParams)))}let a=await this._request(e,r),c=[s.globalHooks.afterResponse,this.hooks.afterResponse,o?.afterResponse];for(let d of c)if(d)for(let u of d){let g=await u(a,n);g&&(a=g)}let h=a.headers.get("allow")?.split(",").map(d=>d.trim());return this.publish({name:m.SUCCESS,data:h,global:t.global}),h}async request(e,t={}){b(e)&&([e,t]=[void 0,e]);let r=await this._request(e,this.processRequestOptions(t,{}));return this.publish({name:m.SUCCESS,data:r,global:t.global}),r}async getJson(e,t){return this._get(e,t,{headers:{accept:`${R.JSON}`}},j)}async getXml(e,t){return this._get(e,t,{headers:{accept:`${R.XML}`}},G)}async getHtml(e,t,r){let n=await this._get(e,t,{headers:{accept:`${R.HTML}`}},J);return r&&n?n.querySelector(r):n}async getHtmlFragment(e,t,r){let n=await this._get(e,t,{headers:{accept:`${R.HTML}`}},de);return r&&n?n.querySelector(r):n}async getScript(e,t){return this._get(e,t,{headers:{accept:`${R.JAVA_SCRIPT}`}},_)}async getStylesheet(e,t){return this._get(e,t,{headers:{accept:`${R.CSS}`}},D)}async getBlob(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},le)}async getImage(e,t){return this._get(e,t,{headers:{accept:"image/*"}},F)}async getBuffer(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},ce)}async getStream(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},$)}async _get(e,t,r={},n){return this.execute(e,t,{...r,method:"GET",body:void 0},n)}async _request(e,{signalController:t,requestOptions:r,global:n}){s.signalControllers.add(t);let o=s.normalizeRetryOptions(r.retry),i=r.method??"GET",l=o.limit>0&&o.methods.includes(i),a=r.dedupe===!0&&(i==="GET"||i==="HEAD"),c=0,h=performance.now(),d=()=>{let u=performance.now();return{start:h,end:u,duration:u-h}};try{let u=s.createUrl(this._baseUrl,e,r.searchParams),g=a?`${i}:${u.href}`:"";if(a){let f=s.inflightRequests.get(g);if(f)return(await f).clone()}let p=async()=>{for(;;)try{let f=await fetch(u,r);if(!f.ok){if(l&&c<o.limit&&o.statusCodes.includes(f.status)){c++,this.publish({name:m.RETRY,data:{attempt:c,status:f.status,method:i,path:e,timing:d()},global:n}),await s.retryDelay(o,c);continue}let M;try{M=await f.text()}catch{}throw await this.handleError(e,f,{entity:M,url:u,method:i,timing:d()},r)}return f}catch(f){if(f instanceof v)throw f;if(l&&c<o.limit){c++,this.publish({name:m.RETRY,data:{attempt:c,error:f.message,method:i,path:e,timing:d()},global:n}),await s.retryDelay(o,c);continue}throw await this.handleError(e,void 0,{cause:f,url:u,method:i,timing:d()},r)}};if(a){let f=p();s.inflightRequests.set(g,f);try{return await f}finally{s.inflightRequests.delete(g)}}return await p()}finally{if(s.signalControllers.delete(t.destroy()),!r.signal?.aborted){let u=d();this.publish({name:m.COMPLETE,data:{timing:u},global:n}),s.signalControllers.size===0&&this.publish({name:m.ALL_COMPLETE,global:n})}}}static normalizeRetryOptions(e){return e===void 0?{limit:0,statusCodes:[],methods:[],delay:k,backoffFactor:A}:typeof e=="number"?{limit:e,statusCodes:[...I],methods:[...N],delay:k,backoffFactor:A}:{limit:e.limit??0,statusCodes:e.statusCodes??[...I],methods:e.methods??[...N],delay:e.delay??k,backoffFactor:e.backoffFactor??A}}static retryDelay(e,t){let r=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(n=>setTimeout(n,r))}async execute(e,t={},r={},n){b(e)&&([e,t]=[void 0,e]);let o=this.processRequestOptions(t,r),{requestOptions:i}=o,l=i.hooks,a=s.createUrl(this._baseUrl,e,i.searchParams),c=[s.globalHooks.beforeRequest,this.hooks.beforeRequest,l?.beforeRequest];for(let u of c)if(u)for(let g of u){let p=await g(i,a);p&&(Object.assign(i,p),p.searchParams!==void 0&&(a=s.createUrl(this._baseUrl,e,i.searchParams)))}let h=await this._request(e,o),d=[s.globalHooks.afterResponse,this.hooks.afterResponse,l?.afterResponse];for(let u of d)if(u)for(let g of u){let p=await g(h,i);p&&(h=p)}try{!n&&h.status!==204&&(n=this.getResponseHandler(h.headers.get("content-type")));let u=await n?.(h);return this.publish({name:m.SUCCESS,data:u,global:o.global}),u}catch(u){throw await this.handleError(e,h,{cause:u},i)}}static createOptions({headers:e,searchParams:t,...r},{headers:n,searchParams:o,...i}){return n=s.mergeHeaders(new Headers,e,n),o=s.mergeSearchParams(new URLSearchParams,t,o),{...V(i,r)??{},headers:n,searchParams:o}}static mergeHeaders(e,...t){for(let r of t)if(r!==void 0)if(r instanceof Headers)r.forEach((n,o)=>e.set(o,n));else if(Array.isArray(r))for(let[n,o]of r)e.set(n,o);else{let n=r,o=Object.keys(n);for(let i=0;i<o.length;i++){let l=o[i],a=n[l];a!==void 0&&e.set(l,String(a))}}return e}static mergeSearchParams(e,...t){for(let r of t)if(r!==void 0)if(r instanceof URLSearchParams)r.forEach((n,o)=>e.set(o,n));else if(z(r)||Array.isArray(r))for(let[n,o]of new URLSearchParams(r))e.set(n,o);else{let n=Object.keys(r);for(let o=0;o<n.length;o++){let i=n[o],l=r[i];l!==void 0&&e.set(i,String(l))}}return e}processRequestOptions({body:e,headers:t,searchParams:r,...n},{headers:o,searchParams:i,...l}){let a={...this._options,...n,...l,headers:s.mergeHeaders(new Headers,this._options.headers,t,o),searchParams:s.mergeSearchParams(new URLSearchParams,this._options.searchParams,r,i)};if(pe(a.method))if(fe(e))a.body=e,a.headers.delete("content-type");else{let p=a.headers.get("content-type")?.includes("json")??!1;a.body=p&&b(e)?ge(e):e}else a.headers.delete("content-type"),a.body instanceof URLSearchParams&&s.mergeSearchParams(a.searchParams,a.body),a.body=void 0;let{signal:c,timeout:h,global:d=!1,xsrf:u}=a;if(u){let p=typeof u=="object"?u:{},f=he(p.cookieName??Z);f&&a.headers.set(p.headerName??ee,f)}let g=new U({signal:c,timeout:h}).onAbort(p=>this.publish({name:m.ABORTED,event:p,global:d})).onTimeout(p=>this.publish({name:m.TIMEOUT,event:p,global:d}));return a.signal=g.signal,this.publish({name:m.CONFIGURED,data:a,global:d}),{signalController:g,requestOptions:a,global:d}}static getBaseUrl(e){if(e instanceof URL)return e;if(!z(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=y.parse(e)??void 0,t!==void 0){if(s.mediaTypeCache.size>=100){let r=s.mediaTypeCache.keys().next().value;r!==void 0&&s.mediaTypeCache.delete(r)}s.mediaTypeCache.set(e,t)}return t}static createUrl(e,t,r){let n=t?new URL(`${e.pathname.replace(Q,"")}${t}`,e.origin):new URL(e);return r&&s.mergeSearchParams(n.searchParams,r),n}static generateResponseStatusFromError(e,{status:t,statusText:r}=new Response){switch(e){case S.ABORT:return oe;case S.TIMEOUT:return ie;default:return t>=400?new T(t,r):ne}}async handleError(e,t,{cause:r,entity:n,url:o,method:i,timing:l}={},a){let c=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,h=new v(s.generateResponseStatusFromError(r?.name,t),{message:c,cause:r,entity:n,url:o,method:i,timing:l}),d=[s.globalHooks.beforeError,this.hooks.beforeError,a?.hooks?.beforeError];for(let u of d)if(u)for(let g of u){let p=await g(h);p instanceof v&&(h=p)}return this.publish({name:m.ERROR,data:h}),h}publish({name:e,event:t=new CustomEvent(e),data:r,global:n=!0}){n&&s.globalSubscribr.publish(e,t,r),this.subscribr.publish(e,t,r)}getResponseHandler(e){if(!e)return;let t=s.getOrParseMediaType(e);if(t){for(let[r,n]of s.contentTypeHandlers)if(t.matches(r))return n}}get[Symbol.toStringTag](){return"Transportr"}};export{Re as Transportr};
3
3
  //# sourceMappingURL=transportr.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../node_modules/.pnpm/@d1g1tal+media-type@6.0.4/node_modules/@d1g1tal/media-type/src/utils.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.4/node_modules/@d1g1tal/media-type/src/media-type-parameters.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.4/node_modules/@d1g1tal/media-type/src/media-type-parser.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.4/node_modules/@d1g1tal/media-type/src/media-type.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.8_typescript@5.9.3/node_modules/@d1g1tal/subscribr/node_modules/.pnpm/@d1g1tal+collections@2.1.1_typescript@5.9.3/node_modules/@d1g1tal/collections/src/set-multi-map.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.8_typescript@5.9.3/node_modules/@d1g1tal/subscribr/src/context-event-handler.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.8_typescript@5.9.3/node_modules/@d1g1tal/subscribr/src/subscription.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.8_typescript@5.9.3/node_modules/@d1g1tal/subscribr/src/subscribr.ts", "../src/http-error.ts", "../src/response-status.ts", "../src/constants.ts", "../src/signal-controller.ts", "../src/response-handlers.ts", "../src/utils.ts", "../src/transportr.ts"],
4
- "sourcesContent": ["export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(name.toLowerCase());\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(name.toLowerCase(), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(name.toLowerCase());\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\treturn Array.from(this).map(([ name, value ]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `\"${value.replace(matcher, '\\\\$1')}\"` : value}`).join('');\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\nconst whitespaceChars = new Set([' ', '\\t', '\\n', '\\r']);\nconst trailingWhitespace: RegExp = /[ \\t\\n\\r]+$/u;\nconst leadingAndTrailingWhitespace: RegExp = /^[ \\t\\n\\r]+|[ \\t\\n\\r]+$/ug;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\tinput = input.replace(leadingAndTrailingWhitespace, '');\n\n\t\tlet position = 0;\n\t\tconst [ type, typeEnd ] = MediaTypeParser.collect(input, position, ['/']);\n\t\tposition = typeEnd;\n\n\t\tif (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\t++position; // Skip \"/\"\n\t\tconst [ subtype, subtypeEnd ] = MediaTypeParser.collect(input, position, [';'], true, true);\n\t\tposition = subtypeEnd;\n\n\t\tif (!subtype.length || !httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('subtype', subtype));\n\t\t}\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < input.length) {\n\t\t\t++position; // Skip \";\"\n\t\t\twhile (whitespaceChars.has(input[position]!)) { ++position }\n\n\t\t\tlet name: string;\n\t\t\t[name, position] = MediaTypeParser.collect(input, position, [';', '='], false);\n\n\t\t\tif (position >= input.length || input[position] === ';') { continue }\n\n\t\t\t++position; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ value, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\t\t\t\twhile (position < input.length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t[ value, position ] = MediaTypeParser.collect(input, position, [';'], false, true);\n\t\t\t\tif (!value) { continue }\n\t\t\t}\n\n\t\t\tif (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {\n\t\t\t\tparameters.set(name, value);\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t/**\n\t * Gets the name of this class.\n\t * @returns The string tag of this class.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParser';\n\t}\n\n\t/**\n\t * Collects characters from `input` starting at `pos` until a stop character is found.\n\t * @param input The input string.\n\t * @param pos The starting position.\n\t * @param stopChars Characters that end collection.\n\t * @param lowerCase Whether to ASCII-lowercase the result.\n\t * @param trim Whether to strip trailing HTTP whitespace.\n\t * @returns A tuple of the collected string and the updated position.\n\t */\n\tprivate static collect(input: string, pos: number, stopChars: string[], lowerCase = true, trim = false): [string, number] {\n\t\tlet result = '';\n\t\tfor (const { length } = input; pos < length && !stopChars.includes(input[pos]!); pos++) {\n\t\t\tresult += input[pos];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn [result, pos];\n\t}\n\n\t/**\n\t * Collects all the HTTP quoted strings.\n\t * This variant only implements it with the extract-value flag set.\n\t * @param input The string to process.\n\t * @param position The starting position.\n\t * @returns An array that includes the resulting string and updated position.\n\t */\n\tprivate static collectHttpQuotedString(input: string, position: number): [string, number] {\n\t\tlet value = '';\n\n\t\tfor (let length = input.length, char; ++position < length;) {\n\t\t\tif ((char = input[position]) === '\"') { break }\n\n\t\t\tvalue += char == '\\\\' && ++position < length ? input[position] : char;\n\t\t}\n\n\t\treturn [ value, position ];\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tprivate static generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\tprivate readonly _type: string;\n\tprivate readonly _subtype: string;\n\tprivate readonly _parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters: Record<string, string> = {}) {\n\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t}\n\n\t\t({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));\n\n\t\tfor (const [ name, value ] of Object.entries(parameters)) { this._parameters.set(name, value) }\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this._type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this._subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn `${this._type}/${this._subtype}`;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this._parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn `${this.essence}${this._parameters.toString()}`;\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}", "/** A {@link Map} that can contain multiple, unique, values for the same key. */\nexport class SetMultiMap<K, V> extends Map<K, Set<V>>{\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The value to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V): this;\n\t/**\n\t * Adds a new Set with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The set of values to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: Set<V>): this;\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key The key to set.\n\t * @param value The value to add to the SetMultiMap\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V | Set<V>): SetMultiMap<K, V> {\n\t\tsuper.set(key, value instanceof Set ? value : (super.get(key) ?? new Set<V>()).add(value));\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Finds a specific value for a specific key using an iterator function.\n\t * @param key The key to find the value for.\n\t * @param iterator The iterator function to use to find the value.\n\t * @returns The value for the specified key\n\t */\n\tfind(key: K, iterator: (value: V) => boolean): V | undefined {\n\t\tconst values = this.get(key);\n\n\t\tif (values !== undefined) {\n\t\t\treturn Array.from(values).find(iterator);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Checks if a specific key has a specific value.\n\t *\n\t * @param key The key to check.\n\t * @param value The value to check.\n\t * @returns True if the key has the value, false otherwise.\n\t */\n\thasValue(key: K, value: V): boolean {\n\t\tconst values = super.get(key);\n\n\t\treturn values ? values.has(value) : false;\n\t}\n\n\t/**\n\t * Removes a specific value from a specific key.\n\t * @param key The key to remove the value from.\n\t * @param value The value to remove.\n\t * @returns True if the value was removed, false otherwise.\n\t */\n\tdeleteValue(key: K, value: V | undefined): boolean {\n\t\tif (value === undefined) { return this.delete(key) }\n\n\t\tconst values = super.get(key);\n\t\tif (values) {\n\t\t\tconst deleted = values.delete(value);\n\n\t\t\tif (values.size === 0) {\n\t\t\t\tsuper.delete(key);\n\t\t\t}\n\n\t\t\treturn deleted;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * The string tag of the SetMultiMap.\n\t * @returns The string tag of the SetMultiMap.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'SetMultiMap';\n\t}\n}", "import type { EventHandler } from './@types';\n\n/** A wrapper for an event handler that binds a context to the event handler. */\nexport class ContextEventHandler {\n\tprivate readonly context: unknown;\n\tprivate readonly eventHandler: EventHandler;\n\n\t/**\n\t * @param context The context to bind to the event handler.\n\t * @param eventHandler The event handler to call when the event is published.\n\t */\n\tconstructor(context: unknown, eventHandler: EventHandler) {\n\t\tthis.context = context;\n\t\tthis.eventHandler = eventHandler;\n\t}\n\n\t/**\n\t * Call the event handler for the provided event.\n\t *\n\t * @param event The event to handle\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\thandle(event: Event, data?: unknown): void {\n\t\tthis.eventHandler.call(this.context, event, data);\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ContextEventHandler';\n\t}\n}", "import type { ContextEventHandler } from './context-event-handler';\n\n/** Represents a subscription to an event. */\nexport class Subscription {\n\tprivate readonly _eventName: string;\n\tprivate readonly _contextEventHandler: ContextEventHandler;\n\n\t/**\n\t * @param eventName The event name.\n\t * @param contextEventHandler The context event handler.\n\t */\n\tconstructor(eventName: string, contextEventHandler: ContextEventHandler) {\n\t\tthis._eventName = eventName;\n\t\tthis._contextEventHandler = contextEventHandler;\n\t}\n\n\t/**\n\t * Gets the event name for the subscription.\n\t *\n\t * @returns The event name.\n\t */\n\tget eventName(): string {\n\t\treturn this._eventName;\n\t}\n\n\t/**\n\t * Gets the context event handler.\n\t *\n\t * @returns The context event handler\n\t */\n\tget contextEventHandler(): ContextEventHandler {\n\t\treturn this._contextEventHandler;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscription';\n\t}\n}", "import { SetMultiMap } from '@d1g1tal/collections/src';\nimport { ContextEventHandler } from './context-event-handler';\nimport { Subscription } from './subscription';\nimport type { EventHandler, ErrorHandler, SubscriptionOptions } from './@types';\n\n/** A class that allows objects to subscribe to events and be notified when the event is published. */\nexport class Subscribr {\n\tprivate readonly subscribers: SetMultiMap<string, ContextEventHandler> = new SetMultiMap();\n\tprivate errorHandler?: ErrorHandler;\n\n\t/**\n\t * Set a custom error handler for handling errors that occur in event listeners.\n\t * If not set, errors will be logged to the console.\n\t *\n\t * @param errorHandler The error handler function to call when an error occurs in an event listener.\n\t */\n\tsetErrorHandler(errorHandler: ErrorHandler): void {\n\t\tthis.errorHandler = errorHandler;\n\t}\n\n\t/**\n\t * Subscribe to an event\n\t *\n\t * @param eventName The event name to subscribe to.\n\t * @param eventHandler The event handler to call when the event is published.\n\t * @param context The context to bind to the event handler.\n\t * @param options Subscription options.\n\t * @returns An object used to check if the subscription still exists and to unsubscribe from the event.\n\t */\n\tsubscribe(eventName: string, eventHandler: EventHandler, context: unknown = eventHandler, options?: SubscriptionOptions): Subscription {\n\t\tthis.validateEventName(eventName);\n\n\t\t// If once option is set, wrap the handler to auto-unsubscribe\n\t\tif (options?.once) {\n\t\t\tconst originalHandler = eventHandler;\n\t\t\teventHandler = (event: Event, data?: unknown) => {\n\t\t\t\toriginalHandler.call(context, event, data);\n\t\t\t\tthis.unsubscribe(subscription);\n\t\t\t};\n\t\t}\n\n\t\tconst contextEventHandler = new ContextEventHandler(context, eventHandler);\n\t\tthis.subscribers.set(eventName, contextEventHandler);\n\n\t\tconst subscription = new Subscription(eventName, contextEventHandler);\n\n\t\treturn subscription;\n\t}\n\n\t/**\n\t * Unsubscribe from the event\n\t *\n\t * @param subscription The subscription to unsubscribe.\n\t * @returns true if eventListener has been removed successfully. false if the value is not found or if the value is not an object.\n\t */\n\tunsubscribe({ eventName, contextEventHandler }: Subscription): boolean {\n\t\tconst contextEventHandlers = this.subscribers.get(eventName) ?? new Set();\n\t\tconst removed = contextEventHandlers.delete(contextEventHandler);\n\n\t\tif (removed && contextEventHandlers.size === 0) {\tthis.subscribers.delete(eventName) }\n\n\t\treturn removed;\n\t}\n\n\t/**\n\t * Publish an event\n\t *\n\t * @template T\n\t * @param eventName The name of the event.\n\t * @param event The event to be handled.\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\tpublish<T>(eventName: string, event: Event = new CustomEvent(eventName), data?: T): void {\n\t\tthis.validateEventName(eventName);\n\t\tthis.subscribers.get(eventName)?.forEach((contextEventHandler: ContextEventHandler) => {\n\t\t\ttry {\n\t\t\t\tcontextEventHandler.handle(event, data);\n\t\t\t} catch (error) {\n\t\t\t\tif (this.errorHandler) {\n\t\t\t\t\tthis.errorHandler(error as Error, eventName, event, data);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error in event handler for '${eventName}':`, error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if the event and handler are subscribed.\n\t *\n\t * @param subscription The subscription object.\n\t * @returns true if the event name and handler are subscribed, false otherwise.\n\t */\n\tisSubscribed({ eventName, contextEventHandler }: Subscription): boolean {\n\t\treturn this.subscribers.get(eventName)?.has(contextEventHandler) ?? false;\n\t}\n\n\t/**\n\t * Validate the event name\n\t *\n\t * @param eventName The event name to validate.\n\t * @throws {TypeError} If the event name is not a non-empty string.\n\t * @throws {Error} If the event name has leading or trailing whitespace.\n\t */\n\tprivate validateEventName(eventName: string): void {\n\t\tif (!eventName || typeof eventName !== 'string') {\n\t\t\tthrow new TypeError('Event name must be a non-empty string');\n\t\t}\n\n\t\tif (eventName.trim() !== eventName) {\n\t\t\tthrow new Error('Event name cannot have leading or trailing whitespace');\n\t\t}\n\t}\n\n\t/**\n\t * Clears all subscriptions. The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.subscribers.clear();\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscribr';\n\t}\n}", "import type { ResponseStatus } from '@src/response-status';\nimport type { ResponseBody, RequestTiming, HttpErrorOptions } from '@src/@types/core';\n\n/**\n * An error that represents an HTTP error response.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nclass HttpError extends Error {\n\tprivate readonly _entity: ResponseBody;\n\tprivate readonly responseStatus: ResponseStatus;\n\tprivate readonly _url: URL | undefined;\n\tprivate readonly _method: string | undefined;\n\tprivate readonly _timing: RequestTiming | undefined;\n\n\t/**\n\t * Creates an instance of HttpError.\n\t * @param status The status code and status text of the {@link Response}.\n\t * @param httpErrorOptions The http error options.\n\t */\n\tconstructor(status: ResponseStatus, { message, cause, entity, url, method, timing }: HttpErrorOptions = {}) {\n\t\tsuper(message, { cause });\n\t\tthis._entity = entity;\n\t\tthis.responseStatus = status;\n\t\tthis._url = url;\n\t\tthis._method = method;\n\t\tthis._timing = timing;\n\t}\n\n\t/**\n\t * It returns the value of the private variable #entity.\n\t * @returns The entity property of the class.\n\t */\n\tget entity(): ResponseBody {\n\t\treturn this._entity;\n\t}\n\n\t/**\n\t * It returns the status code of the {@link Response}.\n\t * @returns The status code of the {@link Response}.\n\t */\n\tget statusCode(): number {\n\t\treturn this.responseStatus.code;\n\t}\n\n\t/**\n\t * It returns the status text of the {@link Response}.\n\t * @returns The status code and status text of the {@link Response}.\n\t */\n\tget statusText(): string {\n\t\treturn this.responseStatus?.text;\n\t}\n\n\t/**\n\t * The request URL that caused the error.\n\t * @returns The URL or undefined.\n\t */\n\tget url(): URL | undefined {\n\t\treturn this._url;\n\t}\n\n\t/**\n\t * The HTTP method that was used for the failed request.\n\t * @returns The method string or undefined.\n\t */\n\tget method(): string | undefined {\n\t\treturn this._method;\n\t}\n\n\t/**\n\t * Timing information for the failed request.\n\t * @returns The timing object or undefined.\n\t */\n\tget timing(): RequestTiming | undefined {\n\t\treturn this._timing;\n\t}\n\n\t/**\n\t * A String value representing the name of the error.\n\t * @returns The name of the error.\n\t */\n\toverride get name(): string {\n\t\treturn 'HttpError';\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn this.name;\n\t}\n}\n\nexport { HttpError };\nexport type { ResponseBody, RequestTiming, HttpErrorOptions };", "/**\n * A class that holds a status code and a status text, typically from a {@link Response}\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status|Response.status\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class ResponseStatus {\n\tprivate readonly _code: number;\n\tprivate readonly _text: string;\n\n\t/**\n\t *\n\t * @param code The status code from the {@link Response}\n\t * @param text The status text from the {@link Response}\n\t */\n\tconstructor(code: number, text: string) {\n\t\tthis._code = code;\n\t\tthis._text = text;\n\t}\n\n\t/**\n\t * Returns the status code from the {@link Response}\n\t *\n\t * @returns The status code.\n\t */\n\tget code(): number {\n\t\treturn this._code;\n\t}\n\n\t/**\n\t * Returns the status text from the {@link Response}.\n\t *\n\t * @returns The status text.\n\t */\n\tget text(): string {\n\t\treturn this._text;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ResponseStatus';\n\t}\n\n\t/**\n\t * tostring method for the class.\n\t *\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}\n\t * @returns The status code and status text.\n\t */\n\ttoString(): string {\n\t\treturn `${this._code} ${this._text}`;\n\t}\n}", "import { MediaType } from '@d1g1tal/media-type';\nimport { ResponseStatus } from './response-status';\nimport type { AbortEvent, TimeoutEvent, RequestMethod } from '@types';\n\nconst charset = { charset: 'utf-8' };\nconst endsWithSlashRegEx: RegExp = /\\/$/;\n/** Default XSRF cookie name */\nconst XSRF_COOKIE_NAME = 'XSRF-TOKEN';\n/** Default XSRF header name */\nconst XSRF_HEADER_NAME = 'X-XSRF-TOKEN';\n\ntype MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN';\n\nconst mediaTypes: { [key in MediaTypeKey]: MediaType } = {\n\tPNG: new MediaType('image/png'),\n\tTEXT: new MediaType('text/plain', charset),\n\tJSON: new MediaType('application/json', charset),\n\tHTML: new MediaType('text/html', charset),\n\tJAVA_SCRIPT: new MediaType('text/javascript', charset),\n\tCSS: new MediaType('text/css', charset),\n\tXML: new MediaType('application/xml', charset),\n\tBIN: new MediaType('application/octet-stream')\n} as const;\n\nconst defaultMediaType: string = mediaTypes.JSON.toString();\n\n/** Constant object for caching policies */\nconst RequestCachingPolicy = {\n\tDEFAULT: 'default',\n\tFORCE_CACHE: 'force-cache',\n\tNO_CACHE: 'no-cache',\n\tNO_STORE: 'no-store',\n\tONLY_IF_CACHED: 'only-if-cached',\n\tRELOAD: 'reload'\n} as const;\n\n/** Constant object for request events */\nexport const RequestEvent = {\n\tCONFIGURED: 'configured',\n\tSUCCESS: 'success',\n\tERROR: 'error',\n\tABORTED: 'aborted',\n\tTIMEOUT: 'timeout',\n\tRETRY: 'retry',\n\tCOMPLETE: 'complete',\n\tALL_COMPLETE: 'all-complete'\n} as const;\n\n/** Constant object for signal events */\nconst SignalEvents = {\n\tABORT: 'abort',\n\tTIMEOUT: 'timeout'\n} as const;\n\n/** Constant object for signal errors */\nconst SignalErrors = {\n\tABORT: 'AbortError',\n\tTIMEOUT: 'TimeoutError'\n} as const;\n\n/** Options for adding event listeners */\nconst eventListenerOptions: AddEventListenerOptions = { once: true, passive: true };\n\n/**\n * Creates a new custom abort event.\n * @returns A new AbortEvent instance.\n */\nconst abortEvent = (): AbortEvent => new CustomEvent(SignalEvents.ABORT, { detail: { cause: SignalErrors.ABORT } });\n\n/**\n * Creates a new custom timeout event.\n * @returns A new TimeoutEvent instance.\n */\nconst timeoutEvent = (): TimeoutEvent => new CustomEvent(SignalEvents.TIMEOUT, { detail: { cause: SignalErrors.TIMEOUT } });\n\n/** Array of request body methods */\nconst requestBodyMethods: ReadonlyArray<RequestMethod> = [ 'POST', 'PUT', 'PATCH', 'DELETE' ];\n\n/** Response status for internal server error */\nconst internalServerError: ResponseStatus = new ResponseStatus(500, 'Internal Server Error');\n\n/** Response status for aborted request */\nconst aborted: ResponseStatus = new ResponseStatus(499, 'Aborted');\n\n/** Response status for timed out request */\nconst timedOut: ResponseStatus = new ResponseStatus(504, 'Request Timeout');\n\n/** Default HTTP status codes that trigger a retry */\nconst retryStatusCodes: ReadonlyArray<number> = [ 408, 413, 429, 500, 502, 503, 504 ];\n\n/** Default HTTP methods allowed to retry (idempotent methods only) */\nconst retryMethods: ReadonlyArray<RequestMethod> = [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS' ];\n\n/** Default delay in ms before the first retry */\nconst retryDelay: number = 300;\n\n/** Default backoff factor applied after each retry attempt */\nconst retryBackoffFactor: number = 2;\n\nexport { aborted, abortEvent, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, defaultMediaType, requestBodyMethods, RequestCachingPolicy, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, SignalErrors, SignalEvents, timedOut, timeoutEvent, XSRF_COOKIE_NAME, XSRF_HEADER_NAME };\nexport type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];", "import { SignalErrors, SignalEvents, abortEvent, eventListenerOptions, timeoutEvent } from './constants.js';\nimport type { AbortConfiguration, AbortEvent, AbortSignalEvent } from '@types';\n\n/** Class representing a controller for abort signals, allowing for aborting requests and handling timeout events */\nexport class SignalController {\n\tprivate readonly abortSignal: AbortSignal;\n\tprivate readonly abortController = new AbortController();\n\tprivate readonly events = new Map<EventListener, string>();\n\n\t/**\n\t * Creates a new SignalController instance.\n\t * @param options - The options for the SignalController.\n\t * @param options.signal - The signal to listen for abort events. Defaults to the internal abort signal.\n\t * @param options.timeout - The timeout value in milliseconds. Defaults to Infinity.\n\t * @throws {RangeError} If the timeout value is negative.\n\t */\n\tconstructor({ signal, timeout = Infinity }: AbortConfiguration = {}) {\n\t\tif (timeout < 0) { throw new RangeError('The timeout cannot be negative') }\n\n\t\tconst signals = [ this.abortController.signal ];\n\t\tif (signal != null) { signals.push(signal) }\n\t\tif (timeout !== Infinity) { signals.push(AbortSignal.timeout(timeout)) }\n\n\t\t(this.abortSignal = AbortSignal.any(signals)).addEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\t}\n\n\t/**\n\t * Handles the 'abort' event. If the event is caused by a timeout, the 'timeout' event is dispatched.\n\t * Guards against a timeout firing after a manual abort to prevent spurious timeout events.\n\t * @param event The event to abort with\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#specifying_this_using_bind\n\t */\n\thandleEvent({ target: { reason } }: AbortSignalEvent): void {\n\t\tif (this.abortController.signal.aborted) { return }\n\t\tif (reason instanceof DOMException && reason.name === SignalErrors.TIMEOUT) { this.abortSignal.dispatchEvent(timeoutEvent()) }\n\t}\n\n\t/**\n\t * Gets the signal. This signal will be able to abort the request, but will not be notified if the request is aborted by the timeout.\n\t * @returns The signal\n\t */\n\tget signal(): AbortSignal {\n\t\treturn this.abortSignal;\n\t}\n\n\t/**\n\t * Adds an event listener for the 'abort' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonAbort(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.ABORT, eventListener);\n\t}\n\n\t/**\n\t * Adds an event listener for the 'timeout' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonTimeout(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.TIMEOUT, eventListener);\n\t}\n\n\t/**\n\t * Aborts the signal.\n\t *\n\t * @param event The event to abort with\n\t */\n\tabort(event: AbortEvent = abortEvent()): void {\n\t\tthis.abortController.abort(event.detail?.cause);\n\t}\n\n\t/**\n\t * Removes all event listeners from the signal.\n\t *\n\t * @returns The SignalController\n\t */\n\tdestroy(): SignalController {\n\t\tthis.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\n\t\tfor (const [ eventListener, type ] of this.events) {\n\t\t\tthis.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);\n\t\t}\n\n\t\tthis.events.clear();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an event listener for the specified event type.\n\t *\n\t * @param type The event type to listen for\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tprivate addEventListener(type: string, eventListener: EventListener): SignalController {\n\t\tthis.abortSignal.addEventListener(type, eventListener, eventListenerOptions);\n\t\tthis.events.set(eventListener, type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'SignalController';\n\t}\n}", "import type { Json, ResponseHandler } from '@types';\n\n/** Cached promise for lazy jsdom initialization \u2014 resolved once, reused thereafter */\nlet domReady: Promise<void> | undefined;\n\n/** Cached promise for lazy DOMPurify initialization \u2014 resolved once, reused thereafter */\nlet purifyReady: Promise<(dirty: string) => string> | undefined;\n\n/**\n * Returns a bound sanitize function, lazily loading DOMPurify on first invocation.\n * Must be called after ensureDom() to ensure the DOM environment is ready.\n * @returns A Promise resolving to the sanitize function.\n */\nconst getSanitize = (): Promise<(dirty: string) => string> =>\n\tpurifyReady ??= import('dompurify').then(({ default: p }) => (dirty: string): string => p.sanitize(dirty));\n\n/**\n * Ensures a DOM environment is available (document, DOMParser, DocumentFragment).\n * In browser environments this is a no-op. In Node.js it lazily imports jsdom on first call.\n * @returns A Promise that resolves when the DOM environment is ready.\n */\nconst ensureDom = async (): Promise<void> => {\n\tif (typeof document !== 'undefined' && typeof DOMParser !== 'undefined' && typeof DocumentFragment !== 'undefined') { return Promise.resolve() }\n\n\treturn domReady ??= import('jsdom').then(({ JSDOM }) => {\n\t\tconst { window } = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', { url: 'http://localhost' });\n\t\tglobalThis.window = window as unknown as Window & typeof globalThis;\n\t\tObject.assign(globalThis, { document: window.document, DOMParser: window.DOMParser, DocumentFragment: window.DocumentFragment });\n\t}).catch(() => {\n\t\tdomReady = undefined;\n\t\tthrow new Error('jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom');\n\t});\n};\n\n/**\n * Handles a text response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a string\n */\nconst handleText: ResponseHandler<string> = async (response) => await response.text();\n\n/**\n * Handles a script response by appending it to the Document HTMLHeadElement\n * Only available in browser environments with DOM support.\n *\n * **Security Warning:** This handler executes arbitrary JavaScript from the server response.\n * Only use with fully trusted content sources. No sanitization is applied to script content.\n * Consider using a Content Security Policy (CSP) nonce for additional protection.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleScript: ResponseHandler<void> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst script = document.createElement('script');\n\t\tObject.assign(script, { src: objectURL, type: 'text/javascript', async: true });\n\n\t\t/**\n\t\t * Revoke the object URL and resolve the promise once the script has loaded.\n\t\t */\n\t\tscript.onload = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(script);\n\t\t\tresolve();\n\t\t};\n\n\t\t/**\n\t\t * Revoke the object URL and reject the promise if the script fails to load.\n\t\t */\n\t\tscript.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(script);\n\t\t\treject(new Error('Script failed to load'));\n\t\t};\n\n\t\tdocument.head.appendChild(script);\n\t});\n};\n\n/**\n * Handles a CSS response by appending it to the Document HTMLHeadElement.\n * Only available in browser environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleCss: ResponseHandler<void> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst link = document.createElement('link');\n\t\tObject.assign(link, { href: objectURL, type: 'text/css', rel: 'stylesheet' });\n\n\t\t/**\n\t\t * Revoke the object URL and resolve the promise once the stylesheet has loaded.\n\t\t * @returns A Promise that resolves to void\n\t\t */\n\t\tlink.onload = () => resolve(URL.revokeObjectURL(objectURL));\n\n\t\t/**\n\t\t * Revoke the object URL, remove the link element, and reject the promise if the stylesheet fails to load.\n\t\t */\n\t\tlink.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(link);\n\t\t\treject(new Error('Stylesheet load failed'));\n\t\t};\n\n\t\tdocument.head.appendChild(link);\n\t});\n};\n\n/**\n * Handles a JSON response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a JsonObject\n */\nconst handleJson: ResponseHandler<Json> = async (response) => await response.json() as Json;\n\n/**\n * Handles a Blob response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Blob\n */\nconst handleBlob: ResponseHandler<Blob> = async (response) => await response.blob();\n\n/**\n * Handles an image response by creating an object URL and returning an HTMLImageElement.\n * The object URL is revoked once the image is loaded to prevent memory leaks.\n * Works in both browser and Node.js (via JSDOM) environments.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an HTMLImageElement\n */\nconst handleImage: ResponseHandler<HTMLImageElement> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst img = new Image();\n\n\t\t/**\n\t\t * Revoke the object URL once the image has loaded to free up memory and resolve with the image.\n\t\t */\n\t\timg.onload = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tresolve(img);\n\t\t};\n\n\t\t/**\n\t\t * Revoke the object URL and reject the promise if the image fails to load.\n\t\t */\n\t\timg.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\treject(new Error('Image failed to load'));\n\t\t};\n\n\t\timg.src = objectURL;\n\t});\n};\n\n/**\n * Handles a buffer response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an ArrayBuffer\n */\nconst handleBuffer: ResponseHandler<ArrayBuffer> = async (response) => await response.arrayBuffer();\n\n/**\n * Handles a ReadableStream response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a ReadableStream\n */\nconst handleReadableStream: ResponseHandler<ReadableStream<Uint8Array> | null> = async (response) => Promise.resolve(response.body);\n\n/**\n * Handles an XML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleXml: ResponseHandler<Document> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn new DOMParser().parseFromString(sanitize(await response.text()), 'application/xml');\n};\n\n/**\n * Handles an HTML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleHtml: ResponseHandler<Document> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn new DOMParser().parseFromString(sanitize(await response.text()), 'text/html');\n};\n\n/**\n * Handles an HTML fragment response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragment: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn document.createRange().createContextualFragment(sanitize(await response.text()));\n};\n\nexport { handleText, handleScript, handleCss, handleJson, handleBlob, handleImage, handleBuffer, handleReadableStream, handleXml, handleHtml, handleHtmlFragment };\n", "import { requestBodyMethods } from './constants';\nimport type { JsonString, JsonValue, RequestBodyMethod, RequestMethod } from '@types';\n\n/**\n * Type guard to check if a request method accepts a body.\n * @param method The request method to check.\n * @returns True if the method accepts a body, false otherwise.\n */\nexport const isRequestBodyMethod = (method: RequestMethod | undefined): method is RequestBodyMethod =>\n\tmethod !== undefined && requestBodyMethods.includes(method);\n\n/**\n * Checks whether a body value is a raw BodyInit type that should be sent as-is\n * (no JSON serialization) and should have its Content-Type deleted so the runtime\n * can set it automatically (e.g. multipart/form-data boundary for FormData).\n * @param body The request body to check.\n * @returns True if the body is a FormData, Blob, ArrayBuffer, TypedArray, DataView, ReadableStream, or URLSearchParams.\n */\nexport const isRawBody = (body: unknown): boolean =>\n\tbody instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream || body instanceof URLSearchParams || ArrayBuffer.isView(body);\n\n/**\n * Reads a cookie value by name from document.cookie.\n * Returns undefined in non-browser environments or when the cookie is not found.\n * @param name The cookie name to look up.\n * @returns The cookie value or undefined.\n */\nexport const getCookieValue = (name: string): string | undefined => {\n\tif (typeof document === 'undefined' || !document.cookie) { return }\n\n\tconst prefix = `${name}=`;\n\tconst cookies = document.cookie.split(';');\n\tfor (let i = 0, length = cookies.length; i < length; i++) {\n\t\tconst cookie = cookies[i]!.trim();\n\t\tif (cookie.startsWith(prefix)) { return decodeURIComponent(cookie.slice(prefix.length)) }\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Serialize an object of type T into a JSON string.\n * The type system ensures only JSON-serializable values can be passed.\n * @template T The type of data to serialize (will be validated for JSON compatibility)\n * @param data The object to serialize - must be JSON-serializable.\n * @returns The serialized JSON string.\n */\nexport const serialize = <const T>(data: JsonValue<T>): JsonString<T> => JSON.stringify(data) as JsonString<T>;\n\n/**\n * Type predicate to check if a value is a string\n * @param value The value to check\n * @returns True if value is a string, with type narrowing\n */\nexport const isString = (value: unknown): value is string => value !== null && typeof value === 'string';\n\n/**\n * Type predicate to check if a value is an object (not array or null)\n * @param value The value to check\n * @returns True if value is an object, with type narrowing\n */\nexport const isObject = <T = object>(value: unknown): value is T extends object ? T : never => value !== null && typeof value === 'object' && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;\n\n/**\n * Performs a deep merge of multiple objects\n * @param objects The objects to merge\n * @returns The merged object\n */\nexport const objectMerge = (...objects: Record<PropertyKey, unknown>[]): Record<PropertyKey, unknown> | undefined => {\n\t// Early return for empty input\n\tconst length = objects.length;\n\tif (length === 0) { return undefined }\n\n\t// Early return for single object - just clone it\n\tif (length === 1) {\n\t\tconst [ obj ] = objects;\n\t\tif (!isObject(obj)) { return obj }\n\t\treturn deepClone(obj);\n\t}\n\n\tconst target = {} as Record<PropertyKey, unknown>;\n\n\tfor (const source of objects) {\n\t\tif (!isObject(source)) { return undefined }\n\n\t\tfor (const [property, sourceValue] of Object.entries(source)) {\n\t\t\tconst targetValue = target[property];\n\t\t\tif (Array.isArray(sourceValue)) {\n\t\t\t\t// Handle arrays - source values come first, then unique target values\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\ttarget[property] = [ ...sourceValue, ...(Array.isArray(targetValue) ? targetValue.filter((item) => !sourceValue.includes(item)) : []) ];\n\t\t\t} else if (isObject<Record<string, unknown>>(sourceValue)) {\n\t\t\t\t// Handle plain objects using the isObject function | I am already testing that the targetValue is an object\n\t\t\t\ttarget[property] = isObject<Record<string, unknown>>(targetValue) ? objectMerge(targetValue, sourceValue)! : deepClone(sourceValue);\n\t\t\t} else {\n\t\t\t\t// Primitive values and null/undefined\n\t\t\t\ttarget[property] = sourceValue;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn target;\n};\n\n/**\n * Creates a deep clone of an object for better performance than spread operator in merge scenarios\n * @param object The object to clone\n * @returns The cloned object\n */\nfunction deepClone<T = Record<PropertyKey, unknown>>(object: T): T {\n\tif (isObject<Record<PropertyKey, unknown>>(object)) {\n\t\tconst cloned: Record<PropertyKey, unknown> = {};\n\t\tconst keys = Object.keys(object);\n\t\tfor (let i = 0, length = keys.length, key; i < length; i++) {\n\t\t\tkey = keys[i]!;\n\t\t\tcloned[key] = deepClone(object[key]);\n\t\t}\n\n\t\treturn cloned as T;\n\t}\n\n\t// For other object types (Date, RegExp, etc.), return as-is\n\treturn object;\n}", "import { MediaType } from '@d1g1tal/media-type';\nimport { Subscribr } from '@d1g1tal/subscribr';\nimport { HttpError } from './http-error';\nimport { ResponseStatus } from './response-status';\nimport { SignalController } from './signal-controller.js';\nimport { handleText, handleScript, handleCss, handleJson, handleBlob, handleImage, handleBuffer, handleReadableStream, handleXml, handleHtml, handleHtmlFragment } from './response-handlers';\nimport { isRequestBodyMethod, isRawBody, getCookieValue, isString, isObject, objectMerge, serialize } from './utils';\nimport { RequestCachingPolicy, RequestEvent, SignalErrors, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, endsWithSlashRegEx, internalServerError, mediaTypes, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut } from './constants';\nimport type {\tRequestOptions, ResponseBody, RequestEventHandler, SearchParameters, EventRegistration, ResponseHandler, RequestHeaders, TypedResponse, Json, Entries, HookOptions, HttpErrorOptions, NormalizedRetryOptions, PublishOptions, RetryOptions, RequestTiming, XsrfOptions } from '@types';\n\ndeclare function fetch<R = unknown>(input: RequestInfo | URL, requestOptions?: RequestOptions): Promise<TypedResponse<R>>;\n\ntype RequestConfiguration = {\n\tsignalController: NonNullable<SignalController>,\n\trequestOptions: RequestOptions,\n\tglobal: boolean\n};\n\n/**\n * A wrapper around the fetch API that makes it easier to make HTTP requests.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class Transportr {\n\tprivate readonly _baseUrl: URL;\n\tprivate readonly _options: RequestOptions;\n\tprivate readonly subscribr: Subscribr;\n\tprivate readonly hooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static globalSubscribr = new Subscribr();\n\tprivate static globalHooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static signalControllers = new Set<SignalController>();\n\t/** Map of in-flight deduplicated requests keyed by URL + method */\n\tprivate static inflightRequests = new Map<string, Promise<Response>>();\n\t/** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */\n\tprivate static mediaTypeCache = new Map(Object.values(mediaTypes).map((mediaType) => [ mediaType.toString(), mediaType ]));\n\tprivate static contentTypeHandlers: Entries<string, ResponseHandler<ResponseBody>> = [\n\t\t[ mediaTypes.TEXT.type, handleText ],\n\t\t[ mediaTypes.JSON.subtype, handleJson ],\n\t\t[ mediaTypes.BIN.subtype, handleReadableStream ],\n\t\t[ mediaTypes.HTML.subtype, handleHtml ],\n\t\t[ mediaTypes.XML.subtype, handleXml ],\n\t\t[ mediaTypes.PNG.type, handleImage as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.JAVA_SCRIPT.subtype, handleScript as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.CSS.subtype, handleCss as ResponseHandler<ResponseBody> ]\n\t];\n\n\t/**\n\t * Create a new Transportr instance with the provided location or origin and context path.\n\t *\n\t * @param url The URL for {@link fetch} requests.\n\t * @param options The default {@link RequestOptions} for this instance.\n\t */\n\tconstructor(url: URL | string | RequestOptions = globalThis.location?.origin ?? 'http://localhost', options: RequestOptions = {}) {\n\t\tif (isObject(url)) { [ url, options ] = [ globalThis.location?.origin ?? 'http://localhost', url ] }\n\n\t\tthis._baseUrl = Transportr.getBaseUrl(url);\n\t\tthis._options = Transportr.createOptions(options, Transportr.defaultRequestOptions);\n\t\tthis.subscribr = new Subscribr();\n\t}\n\n\t/** Credentials Policy */\n\tstatic readonly CredentialsPolicy = {\n\t\tINCLUDE: 'include',\n\t\tOMIT: 'omit',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Modes */\n\tstatic readonly RequestModes = {\n\t\tCORS: 'cors',\n\t\tNAVIGATE: 'navigate',\n\t\tNO_CORS: 'no-cors',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Priorities */\n\tstatic readonly RequestPriorities = {\n\t\tHIGH: 'high',\n\t\tLOW: 'low',\n\t\tAUTO: 'auto'\n\t} as const;\n\n\t/** Redirect Policies */\n\tstatic readonly RedirectPolicies = {\n\t\tERROR: 'error',\n\t\tFOLLOW: 'follow',\n\t\tMANUAL: 'manual'\n\t} as const;\n\n\t/** Referrer Policies */\n\tstatic readonly ReferrerPolicy = {\n\t\tNO_REFERRER: 'no-referrer',\n\t\tNO_REFERRER_WHEN_DOWNGRADE: 'no-referrer-when-downgrade',\n\t\tORIGIN: 'origin',\n\t\tORIGIN_WHEN_CROSS_ORIGIN: 'origin-when-cross-origin',\n\t\tSAME_ORIGIN: 'same-origin',\n\t\tSTRICT_ORIGIN: 'strict-origin',\n\t\tSTRICT_ORIGIN_WHEN_CROSS_ORIGIN: 'strict-origin-when-cross-origin',\n\t\tUNSAFE_URL: 'unsafe-url'\n\t} as const;\n\n\t/** Request Events\t*/\n\tstatic readonly RequestEvents: typeof RequestEvent = RequestEvent;\n\n\t/** Default Request Options */\n\tprivate static readonly defaultRequestOptions: RequestOptions = {\n\t\tbody: undefined,\n\t\tcache: RequestCachingPolicy.NO_STORE,\n\t\tcredentials: Transportr.CredentialsPolicy.SAME_ORIGIN,\n\t\theaders: new Headers({ 'content-type': defaultMediaType, 'accept': defaultMediaType }),\n\t\tsearchParams: undefined,\n\t\tintegrity: undefined,\n\t\tkeepalive: undefined,\n\t\tmethod: 'GET',\n\t\tmode: Transportr.RequestModes.CORS,\n\t\tpriority: Transportr.RequestPriorities.AUTO,\n\t\tredirect: Transportr.RedirectPolicies.FOLLOW,\n\t\treferrer: 'about:client',\n\t\treferrerPolicy: Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,\n\t\tsignal: undefined,\n\t\ttimeout: 30000,\n\t\tglobal: true\n\t};\n\n\t/**\n\t * Returns a {@link EventRegistration} used for subscribing to global events.\n\t *\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn Transportr.globalSubscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Removes a {@link EventRegistration} from the global event handler.\n\t *\n\t * @param eventRegistration The {@link EventRegistration} to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tstatic unregister(eventRegistration: EventRegistration): boolean {\n\t\treturn Transportr.globalSubscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Aborts all active requests.\n\t * This is useful for when the user navigates away from the current page.\n\t * This will also clear the {@link Transportr#signalControllers} set.\n\t */\n\tstatic abortAll(): void {\n\t\tfor (const signalController of this.signalControllers) {\n\t\t\tsignalController.abort(abortEvent());\n\t\t}\n\n\t\t// Clear the set after aborting all requests\n\t\tthis.signalControllers.clear();\n\t}\n\n\t/**\n\t * Registers a custom content-type response handler.\n\t * The handler will be matched against response content-type headers using MediaType matching.\n\t * New handlers are prepended so they take priority over built-in handlers.\n\t *\n\t * @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').\n\t * @param handler The response handler function.\n\t */\n\tstatic registerContentTypeHandler(contentType: string, handler: ResponseHandler): void {\n\t\t// Prepend so custom handlers take priority over built-in ones\n\t\tTransportr.contentTypeHandlers.unshift([ contentType, handler ]);\n\t}\n\n\t/**\n\t * Removes a previously registered content-type response handler.\n\t *\n\t * @param contentType The content-type string to remove.\n\t * @returns True if the handler was found and removed, false otherwise.\n\t */\n\tstatic unregisterContentTypeHandler(contentType: string): boolean {\n\t\tconst index = Transportr.contentTypeHandlers.findIndex(([ type ]) => type === contentType);\n\t\tif (index === -1) { return false }\n\n\t\tTransportr.contentTypeHandlers.splice(index, 1);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Registers global lifecycle hooks that run on all requests from all instances.\n\t * Global hooks execute before instance and per-request hooks.\n\t *\n\t * @param hooks The hooks to register globally.\n\t */\n\tstatic addHooks(hooks: HookOptions): void {\n\t\tif (hooks.beforeRequest) { Transportr.globalHooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { Transportr.globalHooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { Transportr.globalHooks.beforeError.push(...hooks.beforeError) }\n\t}\n\n\t/**\n\t * Removes all global lifecycle hooks.\n\t */\n\tstatic clearHooks(): void {\n\t\tTransportr.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\t}\n\n\t/**\n\t * Tears down all global state: aborts in-flight requests, clears global event subscriptions,\n\t * hooks, in-flight deduplication map, and media type cache (retaining built-in entries).\n\t */\n\tstatic unregisterAll(): void {\n\t\tTransportr.abortAll();\n\t\tTransportr.globalSubscribr = new Subscribr();\n\t\tTransportr.clearHooks();\n\t\tTransportr.inflightRequests.clear();\n\t}\n\n\t/**\n\t * It returns the base {@link URL} for the API.\n\t *\n\t * @returns The baseUrl property.\n\t */\n\tget baseUrl(): URL {\n\t\treturn this._baseUrl;\n\t}\n\n\t/**\n\t * Registers an event handler with a {@link Transportr} instance.\n\t *\n\t * @param event The name of the event to listen for.\n\t * @param handler The function to call when the event is triggered.\n\t * @param context The context to bind to the handler.\n\t * @returns An object that can be used to remove the event handler.\n\t */\n\tregister(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn this.subscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Unregisters an event handler from a {@link Transportr} instance.\n\t *\n\t * @param eventRegistration The event registration to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tunregister(eventRegistration: EventRegistration): boolean {\n\t\treturn this.subscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Registers instance-level lifecycle hooks that run on all requests from this instance.\n\t * Instance hooks execute after global hooks but before per-request hooks.\n\t *\n\t * @param hooks The hooks to register on this instance.\n\t * @returns This instance for method chaining.\n\t */\n\taddHooks(hooks: HookOptions): this {\n\t\tif (hooks.beforeRequest) { this.hooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { this.hooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { this.hooks.beforeError.push(...hooks.beforeError) }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes all instance-level lifecycle hooks.\n\t * @returns This instance for method chaining.\n\t */\n\tclearHooks(): this {\n\t\tthis.hooks.beforeRequest.length = 0;\n\t\tthis.hooks.afterResponse.length = 0;\n\t\tthis.hooks.beforeError.length = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Tears down this instance: clears all instance subscriptions and hooks.\n\t * The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.clearHooks();\n\t\tthis.subscribr.destroy();\n\t}\n\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is GET.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this._get<T>(path, options);\n\t}\n\n\t/**\n\t * This function makes a POST request to the given path with the given body and options.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tasync post<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\tif (typeof(path) !== 'string') { [ path, options ] = [ undefined, path as RequestOptions ] }\n\n\t\treturn this.execute<T>(path, options, { method: 'POST' });\n\t}\n\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is PUT.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param options The options for the request.\n\t * @returns The return value of the #request method.\n\t */\n\tasync put<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'PUT' });\n\t}\n\n\t/**\n\t * It takes a path and options, and returns a request with the method set to PATCH.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to hit.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync patch<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'PATCH' });\n\t}\n\n\t/**\n\t * It takes a path and options, and returns a request with the method set to DELETE.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param options The options for the request.\n\t * @returns The result of the request.\n\t */\n\tasync delete<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'DELETE' });\n\t}\n\n\t/**\n\t * Returns the response headers of a request to the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response object.\n\t */\n\tasync head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'HEAD' });\n\t}\n\n\t/**\n\t * It returns a promise that resolves to the allowed request methods for the given resource path.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an array of allowed request methods for this resource.\n\t */\n\tasync options(path?: string | RequestOptions, options: RequestOptions = {}): Promise<string[] | undefined> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, { method: 'OPTIONS' });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\tif (result) {\n\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet response: Response = await this._request(path, requestConfig);\n\n\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\tif (result) { response = result }\n\t\t\t}\n\t\t}\n\n\t\tconst allowedMethods = response.headers.get('allow')?.split(',').map((method: string) => method.trim());\n\n\t\tthis.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });\n\n\t\treturn allowedMethods;\n\t}\n\n\t/**\n\t * It takes a path and options, and makes a request to the server\n\t * @async\n\t * @param path The path to the endpoint you want to hit.\n\t * @param options The options for the request.\n\t * @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.\n\t * @throws {HttpError} If an error occurs during the request.\n\t */\n\tasync request<T = unknown>(path?: string | RequestOptions, options: RequestOptions = {}): Promise<TypedResponse<T>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst response = await this._request<T>(path, this.processRequestOptions(options, {}));\n\n\t\tthis.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });\n\n\t\treturn response;\n\t}\n\n\t/**\n\t * It gets the JSON representation of the resource at the given path.\n\t *\n\t * @async\n\t * @template T The expected JSON response type (defaults to JsonObject)\n\t * @param path The path to the resource.\n\t * @param options The options object to pass to the request.\n\t * @returns A promise that resolves to the response body as a typed JSON value.\n\t */\n\tasync getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);\n\t}\n\n\t/**\n\t * It gets the XML representation of the resource at the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns The result of the function call to #get.\n\t */\n\tasync getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);\n\t}\n\n\t/**\n\t * Get the HTML content of the specified path.\n\t * When a selector is provided, returns only the first matching element from the parsed document.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed HTML.\n\t * @returns A promise that resolves to a Document, an Element (if selector matched), or void.\n\t */\n\tasync getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined> {\n\t\tconst doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);\n\t\treturn selector && doc ? doc.querySelector(selector) : doc;\n\t}\n\n\t/**\n\t * It returns a promise that resolves to the HTML fragment at the given path.\n\t * When a selector is provided, returns only the first matching element from the parsed fragment.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed fragment.\n\t * @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.\n\t */\n\tasync getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined> {\n\t\tconst fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtmlFragment);\n\t\treturn selector && fragment ? fragment.querySelector(selector) : fragment;\n\t}\n\t/**\n\t * It gets a script from the server, and appends the script to the Document HTMLHeadElement\n\t * @param path The path to the script.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);\n\t}\n\n\t/**\n\t * Gets a stylesheet from the server, and adds it as a Blob URL.\n\t * @param path The path to the stylesheet.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);\n\t}\n\n\t/**\n\t * It returns a blob from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a Blob or void.\n\t */\n\tasync getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBlob);\n\t}\n\n\t/**\n\t * It returns a promise that resolves to an `HTMLImageElement`.\n\t * The object URL created to load the image is automatically revoked to prevent memory leaks.\n\t * Works in both browser and Node.js (via JSDOM) environments.\n\t * @param path The path to the image.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an `HTMLImageElement` or `void`.\n\t */\n\tasync getImage(path?: string, options?: RequestOptions): Promise<HTMLImageElement | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'image/*' } }, handleImage);\n\t}\n\n\t/**\n\t * It gets a buffer from the specified path\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an ArrayBuffer or void.\n\t */\n\tasync getBuffer(path?: string | RequestOptions, options?: RequestOptions): Promise<ArrayBuffer | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBuffer);\n\t}\n\n\t/**\n\t * It returns a readable stream of the response body from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a ReadableStream, null, or void.\n\t */\n\tasync getStream(path?: string | RequestOptions, options?: RequestOptions): Promise<ReadableStream<Uint8Array> | null | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleReadableStream);\n\t}\n\n\t/**\n\t * Handles a GET request.\n\t * @async\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A promise that resolves to the response body or void.\n\t */\n\tprivate async _get<T extends ResponseBody>(path?: string | RequestOptions, userOptions?: RequestOptions, options: RequestOptions = {}, responseHandler?: ResponseHandler<T>): Promise<T | undefined> {\n\t\treturn this.execute(path, userOptions, { ...options, method: 'GET', body: undefined }, responseHandler);\n\t}\n\n\t/**\n\t * It processes the request options and returns a new object with the processed options.\n\t * @param path The path to the resource.\n\t * @param processedRequestOptions The user options for the request.\n\t * @returns A new object with the processed options.\n\t */\n\tprivate async _request<T = unknown>(path: string | undefined, { signalController, requestOptions, global }: RequestConfiguration): Promise<TypedResponse<T>> {\n\t\tTransportr.signalControllers.add(signalController);\n\n\t\tconst retryConfig = Transportr.normalizeRetryOptions(requestOptions.retry);\n\t\tconst method = requestOptions.method ?? 'GET';\n\t\tconst canRetry = retryConfig.limit > 0 && retryConfig.methods.includes(method);\n\t\tconst canDedupe = requestOptions.dedupe === true && (method === 'GET' || method === 'HEAD');\n\t\tlet attempt = 0;\n\t\tconst startTime = performance.now();\n\n\t\t/**\n\t\t * Creates a RequestTiming snapshot from the start time to now.\n\t\t * @returns Timing information for the request.\n\t\t */\n\t\tconst getTiming = (): RequestTiming => {\n\t\t\tconst end = performance.now();\n\t\t\treturn { start: startTime, end, duration: end - startTime };\n\t\t};\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst dedupeKey = canDedupe ? `${method}:${url.href}` : '';\n\n\t\t\t// If deduplication is enabled and an in-flight request exists, clone its response\n\t\t\tif (canDedupe) {\n\t\t\t\tconst inflight = Transportr.inflightRequests.get(dedupeKey);\n\t\t\t\tif (inflight) { return (await inflight).clone() as TypedResponse<T> }\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Performs the fetch with retry logic.\n\t\t\t * @returns A promise resolving to the typed response.\n\t\t\t */\n\t\t\tconst doFetch = async (): Promise<TypedResponse<T>> => {\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await fetch<T>(url, requestOptions);\n\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit && retryConfig.statusCodes.includes(response.status)) {\n\t\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, status: response.status, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Capture response body for error diagnostics\n\t\t\t\t\t\t\tlet entity: ResponseBody | undefined;\n\t\t\t\t\t\t\ttry { entity = await response.text() } catch { /* body may be unavailable */ }\n\t\t\t\t\t\t\tthrow await this.handleError(path, response, { entity, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\tif (cause instanceof HttpError) { throw cause }\n\n\t\t\t\t\t\t// Network error \u2014 retry if allowed\n\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit) {\n\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, error: (cause as Error).message, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthrow await this.handleError(path, undefined, { cause: cause as Error, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (canDedupe) {\n\t\t\t\tconst promise = doFetch();\n\t\t\t\tTransportr.inflightRequests.set(dedupeKey, promise as Promise<Response>);\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await promise;\n\t\t\t\t\treturn response;\n\t\t\t\t} finally {\n\t\t\t\t\tTransportr.inflightRequests.delete(dedupeKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await doFetch();\n\t\t} finally {\n\t\t\tTransportr.signalControllers.delete(signalController.destroy());\n\t\t\tif (!requestOptions.signal?.aborted) {\n\t\t\t\tconst timing = getTiming();\n\t\t\t\tthis.publish({ name: RequestEvent.COMPLETE, data: { timing }, global });\n\t\t\t\tif (Transportr.signalControllers.size === 0) {\n\t\t\t\t\tthis.publish({ name: RequestEvent.ALL_COMPLETE, global });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Normalizes a retry option into a full RetryOptions object.\n\t * @param retry The retry option from request options.\n\t * @returns Normalized retry configuration.\n\t */\n\tprivate static normalizeRetryOptions(retry?: number | RetryOptions): NormalizedRetryOptions {\n\t\tif (retry === undefined) { return { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\t\tif (typeof retry === 'number') { return { limit: retry, statusCodes: [ ...retryStatusCodes ], methods: [ ...retryMethods ], delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\n\t\treturn {\n\t\t\tlimit: retry.limit ?? 0,\n\t\t\tstatusCodes: retry.statusCodes ?? [ ...retryStatusCodes ],\n\t\t\tmethods: retry.methods ?? [ ...retryMethods ],\n\t\t\tdelay: retry.delay ?? retryDelay,\n\t\t\tbackoffFactor: retry.backoffFactor ?? retryBackoffFactor\n\t\t};\n\t}\n\n\t/**\n\t * Waits for the appropriate delay before a retry attempt.\n\t * @param config The retry configuration.\n\t * @param attempt The current attempt number (1-based).\n\t * @returns A promise that resolves after the delay.\n\t */\n\tprivate static retryDelay(config: NormalizedRetryOptions, attempt: number): Promise<void> {\n\t\tconst ms = typeof config.delay === 'function' ? config.delay(attempt) : config.delay * (config.backoffFactor ** (attempt - 1));\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A response handler function.\n\t */\n\tprivate async execute<T extends ResponseBody>(path?: string | RequestOptions, userOptions: RequestOptions = {}, options: RequestOptions = {}, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined> {\n\t\tif (isObject(path)) { [ path, userOptions ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(userOptions, options);\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\n\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\tif (result) {\n\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet response = await this._request<T>(path, requestConfig);\n\n\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\tif (result) { response = result as TypedResponse<T> }\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tif (!responseHandler && response.status !== 204) {\n\t\t\t\tresponseHandler = this.getResponseHandler<T>(response.headers.get('content-type'));\n\t\t\t}\n\n\t\t\tconst data = await responseHandler?.(response);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });\n\n\t\t\treturn data;\n\t\t} catch (cause) {\n\t\t\tthrow await this.handleError(path as string, response, { cause: cause as Error }, requestOptions);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new set of options for a request.\n\t * @param options The user options for the request.\n\t * @param userOptions The default options for the request.\n\t * @returns A new set of options for the request.\n\t */\n\tprivate static createOptions({ headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestOptions {\n\t\theaders = Transportr.mergeHeaders(new Headers(), userHeaders, headers);\n\t\tsearchParams = Transportr.mergeSearchParams(new URLSearchParams(), userSearchParams, searchParams);\n\n\t\treturn { ...objectMerge(options, userOptions) ?? {}, headers, searchParams };\n\t}\n\n\t/**\n\t * Merges user and request headers into the target Headers object.\n\t * @param target The target Headers object.\n\t * @param headerSources Variable number of header sources to merge.\n\t * @returns The merged Headers object.\n\t */\n\tprivate static mergeHeaders(target: Headers, ...headerSources: (RequestHeaders | undefined)[]): Headers {\n\t\tfor (const headers of headerSources) {\n\t\t\tif (headers === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (headers instanceof Headers) {\n\t\t\t\t// Use the native forEach method for Headers\n\t\t\t\theaders.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (Array.isArray(headers)) {\n\t\t\t\t// Handle array of tuples format\n\t\t\t\tfor (const [ name, value ] of headers) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() for better performance\n\t\t\t\tconst record = headers as Record<string, string | undefined>;\n\t\t\t\tconst keys = Object.keys(record);\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = record[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, String(value)) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Merges user and request search parameters into the target URLSearchParams object.\n\t * @param target The target URLSearchParams object.\n\t * @param sources The search parameters to merge.\n\t * @returns The merged URLSearchParams object.\n\t */\n\tprivate static mergeSearchParams(target: URLSearchParams, ...sources: (SearchParameters | undefined)[]): URLSearchParams {\n\t\tfor (const searchParams of sources) {\n\t\t\tif (searchParams === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (searchParams instanceof URLSearchParams) {\n\t\t\t\t// Use the native forEach method for URLSearchParams\n\t\t\t\tsearchParams.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (isString(searchParams) || Array.isArray(searchParams)) {\n\t\t\t\tfor (const [name, value] of new URLSearchParams(searchParams)) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() for better performance\n\t\t\t\tconst keys = Object.keys(searchParams);\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = searchParams[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, String(value)) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Processes request options by merging user, instance, and method-specific options.\n\t * This method optimizes performance by using cached instance options and performing\n\t * shallow merges where possible instead of deep object cloning.\n\t * @param userOptions The user-provided options for the request.\n\t * @param options Additional method-specific options.\n\t * @returns Processed request options with signal controller and global flag.\n\t */\n\tprivate processRequestOptions({ body: userBody, headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestConfiguration {\n\t\t// Optimize: Use shallow merge for non-nested properties instead of deep objectMerge\n\t\t// The instance _options are already merged with defaults in the constructor\n\t\tconst requestOptions = {\n\t\t\t// Spread instance options (already merged with defaults)\n\t\t\t...this._options,\n\t\t\t// Spread user options (shallow merge, sufficient for flat properties)\n\t\t\t...userOptions,\n\t\t\t// Spread method-specific options (e.g., method: 'POST')\n\t\t\t...options,\n\t\t\t// Deep merge required for headers and searchParams\n\t\t\theaders: Transportr.mergeHeaders(new Headers(), this._options.headers, userHeaders, headers),\n\t\t\tsearchParams: Transportr.mergeSearchParams(new URLSearchParams(), this._options.searchParams, userSearchParams, searchParams)\n\t\t};\n\n\t\tif (isRequestBodyMethod(requestOptions.method)) {\n\t\t\tif (isRawBody(userBody)) {\n\t\t\t\t// Raw BodyInit \u2014 send as-is, delete Content-Type so the runtime sets it automatically\n\t\t\t\trequestOptions.body = userBody;\n\t\t\t\trequestOptions.headers.delete('content-type');\n\t\t\t} else {\n\t\t\t\tconst isJson = requestOptions.headers.get('content-type')?.includes('json') ?? false;\n\t\t\t\trequestOptions.body = isJson && isObject(userBody) ? serialize(userBody) : userBody;\n\t\t\t}\n\t\t} else {\n\t\t\trequestOptions.headers.delete('content-type');\n\t\t\tif (requestOptions.body instanceof URLSearchParams) {\n\t\t\t\tTransportr.mergeSearchParams(requestOptions.searchParams, requestOptions.body);\n\t\t\t}\n\t\t\trequestOptions.body = undefined;\n\t\t}\n\n\t\tconst { signal, timeout, global = false, xsrf } = requestOptions;\n\n\t\t// XSRF/CSRF protection: read token from cookie and set as request header\n\t\tif (xsrf) {\n\t\t\tconst xsrfConfig: XsrfOptions = typeof xsrf === 'object' ? xsrf : {};\n\t\t\tconst token = getCookieValue(xsrfConfig.cookieName ?? XSRF_COOKIE_NAME);\n\t\t\tif (token) { requestOptions.headers.set(xsrfConfig.headerName ?? XSRF_HEADER_NAME, token) }\n\t\t}\n\n\t\tconst signalController = new SignalController({ signal, timeout })\n\t\t\t.onAbort((event) => this.publish({ name: RequestEvent.ABORTED, event, global }))\n\t\t\t.onTimeout((event) => this.publish({ name: RequestEvent.TIMEOUT, event, global }));\n\n\t\trequestOptions.signal = signalController.signal;\n\t\tthis.publish({ name: RequestEvent.CONFIGURED, data: requestOptions, global });\n\n\t\treturn { signalController, requestOptions, global } as RequestConfiguration;\n\t}\n\n\t/**\n\t * Gets the base URL from a URL or string.\n\t * @param url The URL or string to parse.\n\t * @returns The base URL.\n\t */\n\tprivate static getBaseUrl(url: URL | string): URL {\n\t\tif (url instanceof URL) { return url }\n\n\t\tif (!isString(url)) { throw new TypeError('Invalid URL') }\n\n\t\treturn new URL(url, url.startsWith('/') ? globalThis.location.origin : undefined);\n\t}\n\n\t/**\n\t * Parses a content-type string into a MediaType instance with caching.\n\t * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,\n\t * which significantly improves performance for repeated requests with the same content types.\n\t * @param contentType The content-type string to parse.\n\t * @returns The parsed MediaType instance, or undefined if parsing fails.\n\t */\n\tprivate static getOrParseMediaType(contentType: string | null): MediaType | undefined {\n\t\tif (contentType === null) { return }\n\n\t\t// Check the predefined mediaTypes map first (fastest lookup) or the cache\n\t\tlet mediaType = Transportr.mediaTypeCache.get(contentType);\n\n\t\tif (mediaType !== undefined) { return mediaType }\n\n\t\t// Parse and cache the new MediaType\n\t\tmediaType = MediaType.parse(contentType) ?? undefined;\n\n\t\tif (mediaType !== undefined) {\n\t\t\t// Evict oldest entries when cache exceeds limit to prevent unbounded growth\n\t\t\tif (Transportr.mediaTypeCache.size >= 100) {\n\t\t\t\tconst firstKey = Transportr.mediaTypeCache.keys().next().value;\n\t\t\t\tif (firstKey !== undefined) { Transportr.mediaTypeCache.delete(firstKey) }\n\t\t\t}\n\t\t\tTransportr.mediaTypeCache.set(contentType, mediaType);\n\t\t}\n\n\t\treturn mediaType;\n\t}\n\n\t/**\n\t * Creates a new URL with the given path and search parameters.\n\t * @param url The base URL.\n\t * @param path The path to append to the base URL.\n\t * @param searchParams The search parameters to append to the URL.\n\t * @returns A new URL with the given path and search parameters.\n\t */\n\tprivate static createUrl(url: URL, path?: string, searchParams?: SearchParameters): URL {\n\t\tconst requestUrl = path ? new URL(`${url.pathname.replace(endsWithSlashRegEx, '')}${path}`, url.origin) : new URL(url);\n\n\t\tif (searchParams) {\n\t\t\tTransportr.mergeSearchParams(requestUrl.searchParams, searchParams);\n\t\t}\n\n\t\treturn requestUrl;\n\t}\n\n\t/**\n\t * It generates a ResponseStatus object from an error name and a Response object.\n\t * @param errorName The name of the error.\n\t * @param response The Response object.\n\t * @returns A ResponseStatus object.\n\t */\n\tprivate static generateResponseStatusFromError(errorName?: string, { status, statusText }: Response = new Response()): ResponseStatus {\n\t\tswitch (errorName) {\n\t\t\tcase SignalErrors.ABORT: return aborted;\n\t\t\tcase SignalErrors.TIMEOUT: return timedOut;\n\t\t\tdefault: return status >= 400 ? new ResponseStatus(status, statusText) : internalServerError;\n\t\t}\n\t}\n\n\t/**\n\t * Handles an error that occurs during a request.\n\t * @param path The path of the request.\n\t * @param response The Response object.\n\t * @param options Additional error context including cause, entity, url, method, and timing.\n\t * @param requestOptions The original request options that led to the error, used for hooks context.\n\t * @returns An HttpError object.\n\t */\n\tprivate async handleError(path?: string, response?: Response, { cause, entity, url, method, timing }: Omit<HttpErrorOptions, 'message'> = {}, requestOptions?: RequestOptions): Promise<HttpError> {\n\t\tconst message = method && url\t? `${method} ${url.href} failed${response ? ` with status ${response.status}` : ''}` : `An error has occurred with your request to: '${path}'`;\n\t\tlet error = new HttpError(Transportr.generateResponseStatusFromError(cause?.name, response), { message, cause, entity, url, method, timing });\n\n\t\t// Run beforeError hooks: global \u2192 instance \u2192 per-request\n\t\tconst beforeErrorHookSets = [ Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError ];\n\t\tfor (const hooks of beforeErrorHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(error);\n\t\t\t\tif (result instanceof HttpError) { error = result }\n\t\t\t}\n\t\t}\n\n\t\tthis.publish({ name: RequestEvent.ERROR, data: error });\n\n\t\treturn error;\n\t}\n\n\t/**\n\t * Publishes an event to the global and instance event handlers.\n\t * @param eventObject The event object to publish.\n\t */\n\tprivate publish({ name, event = new CustomEvent(name), data, global = true }: PublishOptions): void {\n\t\tif (global) { Transportr.globalSubscribr.publish(name, event, data) }\n\t\tthis.subscribr.publish(name, event, data);\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param contentType The content type of the response.\n\t * @returns A response handler function.\n\t */\n\tprivate getResponseHandler<T extends ResponseBody>(contentType?: string | null): ResponseHandler<T> | undefined {\n\t\tif (!contentType) { return }\n\n\t\tconst mediaType = Transportr.getOrParseMediaType(contentType);\n\n\t\tif (!mediaType) { return }\n\n\t\tfor (const [ contentType, responseHandler ] of Transportr.contentTypeHandlers) {\n\t\t\tif (mediaType.matches(contentType)) { return responseHandler as ResponseHandler<T> }\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * A string representation of the Transportr instance.\n\t * @returns The string 'Transportr'.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Transportr';\n\t}\n}\n"],
5
- "mappings": "AAAO,IAAMA,EAA8B,iCCErCC,GAAkB,YAClBC,GAA0C,qCAanCC,EAAN,MAAMC,UAA4B,GAAoB,CAM5D,YAAYC,EAAsC,CAAC,EAAG,CACrD,MAAMA,CAAO,CACd,CASA,OAAO,QAAQC,EAAcC,EAAwB,CACpD,OAAOP,EAAoB,KAAKM,CAAI,GAAKJ,GAAgC,KAAKK,CAAK,CACpF,CAQS,IAAID,EAAkC,CAC9C,OAAO,MAAM,IAAIA,EAAK,YAAY,CAAC,CACpC,CAQS,IAAIA,EAAuB,CACnC,OAAO,MAAM,IAAIA,EAAK,YAAY,CAAC,CACpC,CAUS,IAAIA,EAAcC,EAAqB,CAC/C,GAAI,CAACH,EAAoB,QAAQE,EAAMC,CAAK,EAC3C,MAAM,IAAI,MAAM,4CAA4CD,CAAI,IAAIC,CAAK,EAAE,EAG5E,aAAM,IAAID,EAAK,YAAY,EAAGC,CAAK,EAE5B,IACR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AAS,MAAMD,EAAKgF,CAAK,EAC3B/E,aAAkB0B,IAAaqD,EAAQ/E,EAC5C,CAGD,YAAK,QAAQ,CAAE,KAAMnB,EAAa,MAAO,KAAMkG,CAAM,CAAC,EAE/CA,CACR,CAMQ,QAAQ,CAAE,KAAAjC,EAAM,MAAA9D,EAAQ,IAAI,YAAY8D,CAAI,EAAG,KAAAT,EAAM,OAAAxB,EAAS,EAAK,EAAyB,CAC/FA,GAAU/C,EAAW,gBAAgB,QAAQgF,EAAM9D,EAAOqD,CAAI,EAClE,KAAK,UAAU,QAAQS,EAAM9D,EAAOqD,CAAI,CACzC,CAOQ,mBAA2C/C,EAA6D,CAC/G,GAAI,CAACA,EAAe,OAEpB,IAAMrB,EAAYH,EAAW,oBAAoBwB,CAAW,EAE5D,GAAKrB,GAEL,OAAW,CAAEqB,EAAasB,CAAgB,IAAK9C,EAAW,oBACzD,GAAIG,EAAU,QAAQqB,CAAW,EAAK,OAAOsB,EAI/C,CAMA,IAAK,OAAO,WAAW,GAAY,CAClC,MAAO,YACR,CACD",
6
- "names": ["httpTokenCodePoints", "matcher", "httpQuotedStringTokenCodePoints", "MediaTypeParameters", "_MediaTypeParameters", "entries", "name", "value", "whitespaceChars", "trailingWhitespace", "leadingAndTrailingWhitespace", "MediaTypeParser", "_MediaTypeParser", "input", "position", "type", "typeEnd", "subtype", "subtypeEnd", "parameters", "pos", "stopChars", "lowerCase", "trim", "result", "length", "char", "component", "MediaType", "_MediaType", "mediaType", "SetMultiMap", "key", "value", "iterator", "values", "deleted", "ContextEventHandler", "context", "eventHandler", "event", "data", "Subscription", "eventName", "contextEventHandler", "Subscribr", "errorHandler", "options", "originalHandler", "subscription", "contextEventHandlers", "removed", "error", "HttpError", "status", "message", "cause", "entity", "url", "method", "timing", "ResponseStatus", "code", "text", "charset", "endsWithSlashRegEx", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "mediaTypes", "MediaType", "defaultMediaType", "RequestCachingPolicy", "RequestEvent", "SignalEvents", "SignalErrors", "eventListenerOptions", "abortEvent", "timeoutEvent", "requestBodyMethods", "internalServerError", "ResponseStatus", "aborted", "timedOut", "retryStatusCodes", "retryMethods", "retryDelay", "retryBackoffFactor", "SignalController", "signal", "timeout", "signals", "SignalEvents", "eventListenerOptions", "reason", "SignalErrors", "timeoutEvent", "eventListener", "event", "abortEvent", "type", "domReady", "purifyReady", "getSanitize", "p", "dirty", "ensureDom", "JSDOM", "window", "handleText", "response", "handleScript", "objectURL", "resolve", "reject", "script", "handleCss", "link", "handleJson", "handleBlob", "handleImage", "img", "handleBuffer", "handleReadableStream", "handleXml", "sanitize", "handleHtml", "handleHtmlFragment", "isRequestBodyMethod", "method", "requestBodyMethods", "isRawBody", "body", "getCookieValue", "name", "prefix", "cookies", "i", "length", "cookie", "serialize", "data", "isString", "value", "isObject", "objectMerge", "objects", "obj", "deepClone", "target", "source", "property", "sourceValue", "targetValue", "item", "object", "cloned", "keys", "key", "Transportr", "_Transportr", "Subscribr", "mediaTypes", "mediaType", "handleText", "handleJson", "handleReadableStream", "handleHtml", "handleXml", "handleImage", "handleScript", "handleCss", "url", "options", "isObject", "RequestEvent", "RequestCachingPolicy", "defaultMediaType", "event", "handler", "context", "eventRegistration", "signalController", "abortEvent", "contentType", "index", "type", "hooks", "path", "requestConfig", "requestOptions", "requestHooks", "beforeRequestHookSets", "hook", "result", "response", "afterResponseHookSets", "allowedMethods", "method", "selector", "doc", "fragment", "handleHtmlFragment", "handleBlob", "handleBuffer", "userOptions", "responseHandler", "global", "retryConfig", "canRetry", "canDedupe", "attempt", "startTime", "getTiming", "end", "dedupeKey", "inflight", "doFetch", "entity", "cause", "HttpError", "promise", "timing", "retry", "retryDelay", "retryBackoffFactor", "retryStatusCodes", "retryMethods", "config", "ms", "resolve", "data", "userHeaders", "userSearchParams", "headers", "searchParams", "objectMerge", "target", "headerSources", "value", "name", "record", "keys", "sources", "isString", "i", "userBody", "isRequestBodyMethod", "isRawBody", "isJson", "serialize", "signal", "timeout", "xsrf", "xsrfConfig", "token", "getCookieValue", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "SignalController", "MediaType", "firstKey", "requestUrl", "endsWithSlashRegEx", "errorName", "status", "statusText", "SignalErrors", "aborted", "timedOut", "ResponseStatus", "internalServerError", "message", "error", "beforeErrorHookSets"]
3
+ "sources": ["../node_modules/.pnpm/@d1g1tal+media-type@6.0.6/node_modules/@d1g1tal/media-type/src/utils.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.6/node_modules/@d1g1tal/media-type/src/media-type-parameters.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.6/node_modules/@d1g1tal/media-type/src/media-type-parser.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.6/node_modules/@d1g1tal/media-type/src/media-type.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.10/node_modules/@d1g1tal/subscribr/node_modules/.pnpm/@d1g1tal+collections@2.1.6/node_modules/@d1g1tal/collections/src/set-multi-map.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.10/node_modules/@d1g1tal/subscribr/src/context-event-handler.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.10/node_modules/@d1g1tal/subscribr/src/subscription.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.1.10/node_modules/@d1g1tal/subscribr/src/subscribr.ts", "../src/http-error.ts", "../src/response-status.ts", "../src/constants.ts", "../src/signal-controller.ts", "../src/response-handlers.ts", "../src/utils.ts", "../src/transportr.ts"],
4
+ "sourcesContent": ["export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(name.toLowerCase());\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(name.toLowerCase(), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(name.toLowerCase());\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\treturn Array.from(this).map(([ name, value ]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `\"${value.replace(matcher, '\\\\$1')}\"` : value}`).join('');\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\nconst whitespaceChars = new Set([' ', '\\t', '\\n', '\\r']);\nconst trailingWhitespace: RegExp = /[ \\t\\n\\r]+$/u;\nconst leadingAndTrailingWhitespace: RegExp = /^[ \\t\\n\\r]+|[ \\t\\n\\r]+$/ug;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\tinput = input.replace(leadingAndTrailingWhitespace, '');\n\n\t\tlet position = 0;\n\t\tconst [ type, typeEnd ] = MediaTypeParser.collect(input, position, ['/']);\n\t\tposition = typeEnd;\n\n\t\tif (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\t++position; // Skip \"/\"\n\t\tconst [ subtype, subtypeEnd ] = MediaTypeParser.collect(input, position, [';'], true, true);\n\t\tposition = subtypeEnd;\n\n\t\tif (!subtype.length || !httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('subtype', subtype));\n\t\t}\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < input.length) {\n\t\t\t++position; // Skip \";\"\n\t\t\twhile (whitespaceChars.has(input[position]!)) { ++position }\n\n\t\t\tlet name: string;\n\t\t\t[name, position] = MediaTypeParser.collect(input, position, [';', '='], false);\n\n\t\t\tif (position >= input.length || input[position] === ';') { continue }\n\n\t\t\t++position; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ value, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\t\t\t\twhile (position < input.length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t[ value, position ] = MediaTypeParser.collect(input, position, [';'], false, true);\n\t\t\t\tif (!value) { continue }\n\t\t\t}\n\n\t\t\tif (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {\n\t\t\t\tparameters.set(name, value);\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t/**\n\t * Gets the name of this class.\n\t * @returns The string tag of this class.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParser';\n\t}\n\n\t/**\n\t * Collects characters from `input` starting at `pos` until a stop character is found.\n\t * @param input The input string.\n\t * @param pos The starting position.\n\t * @param stopChars Characters that end collection.\n\t * @param lowerCase Whether to ASCII-lowercase the result.\n\t * @param trim Whether to strip trailing HTTP whitespace.\n\t * @returns A tuple of the collected string and the updated position.\n\t */\n\tprivate static collect(input: string, pos: number, stopChars: string[], lowerCase = true, trim = false): [string, number] {\n\t\tlet result = '';\n\t\tfor (const { length } = input; pos < length && !stopChars.includes(input[pos]!); pos++) {\n\t\t\tresult += input[pos];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn [result, pos];\n\t}\n\n\t/**\n\t * Collects all the HTTP quoted strings.\n\t * This variant only implements it with the extract-value flag set.\n\t * @param input The string to process.\n\t * @param position The starting position.\n\t * @returns An array that includes the resulting string and updated position.\n\t */\n\tprivate static collectHttpQuotedString(input: string, position: number): [string, number] {\n\t\tlet value = '';\n\n\t\tfor (let length = input.length, char; ++position < length;) {\n\t\t\tif ((char = input[position]) === '\"') { break }\n\n\t\t\tvalue += char == '\\\\' && ++position < length ? input[position] : char;\n\t\t}\n\n\t\treturn [ value, position ];\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tprivate static generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\tprivate readonly _type: string;\n\tprivate readonly _subtype: string;\n\tprivate readonly _parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters: Record<string, string> = {}) {\n\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t}\n\n\t\t({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));\n\n\t\tfor (const [ name, value ] of Object.entries(parameters)) { this._parameters.set(name, value) }\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this._type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this._subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn `${this._type}/${this._subtype}`;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this._parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn `${this.essence}${this._parameters.toString()}`;\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}", "/** A {@link Map} that can contain multiple, unique, values for the same key. */\nexport class SetMultiMap<K, V> extends Map<K, Set<V>>{\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The value to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V): this;\n\t/**\n\t * Adds a new Set with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The set of values to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: Set<V>): this;\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key The key to set.\n\t * @param value The value to add to the SetMultiMap\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V | Set<V>): SetMultiMap<K, V> {\n\t\tsuper.set(key, value instanceof Set ? value : (super.get(key) ?? new Set<V>()).add(value));\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Finds a specific value for a specific key using an iterator function.\n\t * @param key The key to find the value for.\n\t * @param iterator The iterator function to use to find the value.\n\t * @returns The value for the specified key\n\t */\n\tfind(key: K, iterator: (value: V) => boolean): V | undefined {\n\t\tconst values = this.get(key);\n\n\t\tif (values !== undefined) {\n\t\t\treturn Array.from(values).find(iterator);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Checks if a specific key has a specific value.\n\t *\n\t * @param key The key to check.\n\t * @param value The value to check.\n\t * @returns True if the key has the value, false otherwise.\n\t */\n\thasValue(key: K, value: V): boolean {\n\t\tconst values = super.get(key);\n\n\t\treturn values ? values.has(value) : false;\n\t}\n\n\t/**\n\t * Removes a specific value from a specific key.\n\t * @param key The key to remove the value from.\n\t * @param value The value to remove.\n\t * @returns True if the value was removed, false otherwise.\n\t */\n\tdeleteValue(key: K, value: V | undefined): boolean {\n\t\tif (value === undefined) { return this.delete(key) }\n\n\t\tconst values = super.get(key);\n\t\tif (values) {\n\t\t\tconst deleted = values.delete(value);\n\n\t\t\tif (values.size === 0) {\n\t\t\t\tsuper.delete(key);\n\t\t\t}\n\n\t\t\treturn deleted;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * The string tag of the SetMultiMap.\n\t * @returns The string tag of the SetMultiMap.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'SetMultiMap';\n\t}\n}", "import type { EventHandler } from './@types';\n\n/** A wrapper for an event handler that binds a context to the event handler. */\nexport class ContextEventHandler {\n\tprivate readonly context: unknown;\n\tprivate readonly eventHandler: EventHandler;\n\n\t/**\n\t * @param context The context to bind to the event handler.\n\t * @param eventHandler The event handler to call when the event is published.\n\t */\n\tconstructor(context: unknown, eventHandler: EventHandler) {\n\t\tthis.context = context;\n\t\tthis.eventHandler = eventHandler;\n\t}\n\n\t/**\n\t * Call the event handler for the provided event.\n\t *\n\t * @param event The event to handle\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\thandle(event: Event, data?: unknown): void {\n\t\tthis.eventHandler.call(this.context, event, data);\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ContextEventHandler';\n\t}\n}", "import type { ContextEventHandler } from './context-event-handler';\n\n/** Represents a subscription to an event. */\nexport class Subscription {\n\tprivate readonly _eventName: string;\n\tprivate readonly _contextEventHandler: ContextEventHandler;\n\n\t/**\n\t * @param eventName The event name.\n\t * @param contextEventHandler The context event handler.\n\t */\n\tconstructor(eventName: string, contextEventHandler: ContextEventHandler) {\n\t\tthis._eventName = eventName;\n\t\tthis._contextEventHandler = contextEventHandler;\n\t}\n\n\t/**\n\t * Gets the event name for the subscription.\n\t *\n\t * @returns The event name.\n\t */\n\tget eventName(): string {\n\t\treturn this._eventName;\n\t}\n\n\t/**\n\t * Gets the context event handler.\n\t *\n\t * @returns The context event handler\n\t */\n\tget contextEventHandler(): ContextEventHandler {\n\t\treturn this._contextEventHandler;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscription';\n\t}\n}", "import { SetMultiMap } from '@d1g1tal/collections';\nimport { ContextEventHandler } from './context-event-handler';\nimport { Subscription } from './subscription';\nimport type { EventHandler, ErrorHandler, SubscriptionOptions } from './@types';\n\n/** A class that allows objects to subscribe to events and be notified when the event is published. */\nexport class Subscribr {\n\tprivate readonly subscribers: SetMultiMap<string, ContextEventHandler> = new SetMultiMap();\n\tprivate errorHandler?: ErrorHandler;\n\n\t/**\n\t * Set a custom error handler for handling errors that occur in event listeners.\n\t * If not set, errors will be logged to the console.\n\t *\n\t * @param errorHandler The error handler function to call when an error occurs in an event listener.\n\t */\n\tsetErrorHandler(errorHandler: ErrorHandler): void {\n\t\tthis.errorHandler = errorHandler;\n\t}\n\n\t/**\n\t * Subscribe to an event\n\t *\n\t * @param eventName The event name to subscribe to.\n\t * @param eventHandler The event handler to call when the event is published.\n\t * @param context The context to bind to the event handler.\n\t * @param options Subscription options.\n\t * @returns An object used to check if the subscription still exists and to unsubscribe from the event.\n\t */\n\tsubscribe(eventName: string, eventHandler: EventHandler, context: unknown = eventHandler, options?: SubscriptionOptions): Subscription {\n\t\tthis.validateEventName(eventName);\n\n\t\t// If once option is set, wrap the handler to auto-unsubscribe\n\t\tif (options?.once) {\n\t\t\tconst originalHandler = eventHandler;\n\t\t\teventHandler = (event: Event, data?: unknown) => {\n\t\t\t\toriginalHandler.call(context, event, data);\n\t\t\t\tthis.unsubscribe(subscription);\n\t\t\t};\n\t\t}\n\n\t\tconst contextEventHandler = new ContextEventHandler(context, eventHandler);\n\t\tthis.subscribers.set(eventName, contextEventHandler);\n\n\t\tconst subscription = new Subscription(eventName, contextEventHandler);\n\n\t\treturn subscription;\n\t}\n\n\t/**\n\t * Unsubscribe from the event\n\t *\n\t * @param subscription The subscription to unsubscribe.\n\t * @returns true if eventListener has been removed successfully. false if the value is not found or if the value is not an object.\n\t */\n\tunsubscribe({ eventName, contextEventHandler }: Subscription): boolean {\n\t\tconst contextEventHandlers = this.subscribers.get(eventName) ?? new Set();\n\t\tconst removed = contextEventHandlers.delete(contextEventHandler);\n\n\t\tif (removed && contextEventHandlers.size === 0) {\tthis.subscribers.delete(eventName) }\n\n\t\treturn removed;\n\t}\n\n\t/**\n\t * Publish an event\n\t *\n\t * @template T\n\t * @param eventName The name of the event.\n\t * @param event The event to be handled.\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\tpublish<T>(eventName: string, event: Event = new CustomEvent(eventName), data?: T): void {\n\t\tthis.validateEventName(eventName);\n\t\tthis.subscribers.get(eventName)?.forEach((contextEventHandler: ContextEventHandler) => {\n\t\t\ttry {\n\t\t\t\tcontextEventHandler.handle(event, data);\n\t\t\t} catch (error) {\n\t\t\t\tif (this.errorHandler) {\n\t\t\t\t\tthis.errorHandler(error as Error, eventName, event, data);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error in event handler for '${eventName}':`, error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if the event and handler are subscribed.\n\t *\n\t * @param subscription The subscription object.\n\t * @returns true if the event name and handler are subscribed, false otherwise.\n\t */\n\tisSubscribed({ eventName, contextEventHandler }: Subscription): boolean {\n\t\treturn this.subscribers.get(eventName)?.has(contextEventHandler) ?? false;\n\t}\n\n\t/**\n\t * Validate the event name\n\t *\n\t * @param eventName The event name to validate.\n\t * @throws {TypeError} If the event name is not a non-empty string.\n\t * @throws {Error} If the event name has leading or trailing whitespace.\n\t */\n\tprivate validateEventName(eventName: string): void {\n\t\tif (!eventName || typeof eventName !== 'string') {\n\t\t\tthrow new TypeError('Event name must be a non-empty string');\n\t\t}\n\n\t\tif (eventName.trim() !== eventName) {\n\t\t\tthrow new Error('Event name cannot have leading or trailing whitespace');\n\t\t}\n\t}\n\n\t/**\n\t * Clears all subscriptions. The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.subscribers.clear();\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscribr';\n\t}\n}", "import type { ResponseStatus } from '@src/response-status';\nimport type { ResponseBody, RequestTiming, HttpErrorOptions } from '@src/@types/core';\n\n/**\n * An error that represents an HTTP error response.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nclass HttpError extends Error {\n\tprivate readonly _entity: ResponseBody;\n\tprivate readonly responseStatus: ResponseStatus;\n\tprivate readonly _url: URL | undefined;\n\tprivate readonly _method: string | undefined;\n\tprivate readonly _timing: RequestTiming | undefined;\n\n\t/**\n\t * Creates an instance of HttpError.\n\t * @param status The status code and status text of the {@link Response}.\n\t * @param httpErrorOptions The http error options.\n\t */\n\tconstructor(status: ResponseStatus, { message, cause, entity, url, method, timing }: HttpErrorOptions = {}) {\n\t\tsuper(message, { cause });\n\t\tthis._entity = entity;\n\t\tthis.responseStatus = status;\n\t\tthis._url = url;\n\t\tthis._method = method;\n\t\tthis._timing = timing;\n\t}\n\n\t/**\n\t * It returns the value of the private variable #entity.\n\t * @returns The entity property of the class.\n\t */\n\tget entity(): ResponseBody {\n\t\treturn this._entity;\n\t}\n\n\t/**\n\t * It returns the status code of the {@link Response}.\n\t * @returns The status code of the {@link Response}.\n\t */\n\tget statusCode(): number {\n\t\treturn this.responseStatus.code;\n\t}\n\n\t/**\n\t * It returns the status text of the {@link Response}.\n\t * @returns The status code and status text of the {@link Response}.\n\t */\n\tget statusText(): string {\n\t\treturn this.responseStatus?.text;\n\t}\n\n\t/**\n\t * The request URL that caused the error.\n\t * @returns The URL or undefined.\n\t */\n\tget url(): URL | undefined {\n\t\treturn this._url;\n\t}\n\n\t/**\n\t * The HTTP method that was used for the failed request.\n\t * @returns The method string or undefined.\n\t */\n\tget method(): string | undefined {\n\t\treturn this._method;\n\t}\n\n\t/**\n\t * Timing information for the failed request.\n\t * @returns The timing object or undefined.\n\t */\n\tget timing(): RequestTiming | undefined {\n\t\treturn this._timing;\n\t}\n\n\t/**\n\t * A String value representing the name of the error.\n\t * @returns The name of the error.\n\t */\n\toverride get name(): string {\n\t\treturn 'HttpError';\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn this.name;\n\t}\n}\n\nexport { HttpError };\nexport type { ResponseBody, RequestTiming, HttpErrorOptions };", "/**\n * A class that holds a status code and a status text, typically from a {@link Response}\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status|Response.status\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class ResponseStatus {\n\tprivate readonly _code: number;\n\tprivate readonly _text: string;\n\n\t/**\n\t *\n\t * @param code The status code from the {@link Response}\n\t * @param text The status text from the {@link Response}\n\t */\n\tconstructor(code: number, text: string) {\n\t\tthis._code = code;\n\t\tthis._text = text;\n\t}\n\n\t/**\n\t * Returns the status code from the {@link Response}\n\t *\n\t * @returns The status code.\n\t */\n\tget code(): number {\n\t\treturn this._code;\n\t}\n\n\t/**\n\t * Returns the status text from the {@link Response}.\n\t *\n\t * @returns The status text.\n\t */\n\tget text(): string {\n\t\treturn this._text;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ResponseStatus';\n\t}\n\n\t/**\n\t * tostring method for the class.\n\t *\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}\n\t * @returns The status code and status text.\n\t */\n\ttoString(): string {\n\t\treturn `${this._code} ${this._text}`;\n\t}\n}", "import { MediaType } from '@d1g1tal/media-type';\nimport { ResponseStatus } from './response-status';\nimport type { AbortEvent, TimeoutEvent, RequestMethod } from '@types';\n\nconst charset = { charset: 'utf-8' };\nconst endsWithSlashRegEx: RegExp = /\\/$/;\n/** Default XSRF cookie name */\nconst XSRF_COOKIE_NAME = 'XSRF-TOKEN';\n/** Default XSRF header name */\nconst XSRF_HEADER_NAME = 'X-XSRF-TOKEN';\n\ntype MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN';\n\nconst mediaTypes: { [key in MediaTypeKey]: MediaType } = {\n\tPNG: new MediaType('image/png'),\n\tTEXT: new MediaType('text/plain', charset),\n\tJSON: new MediaType('application/json', charset),\n\tHTML: new MediaType('text/html', charset),\n\tJAVA_SCRIPT: new MediaType('text/javascript', charset),\n\tCSS: new MediaType('text/css', charset),\n\tXML: new MediaType('application/xml', charset),\n\tBIN: new MediaType('application/octet-stream')\n} as const;\n\nconst defaultMediaType: string = mediaTypes.JSON.toString();\n\n/** Constant object for caching policies */\nconst RequestCachingPolicy = {\n\tDEFAULT: 'default',\n\tFORCE_CACHE: 'force-cache',\n\tNO_CACHE: 'no-cache',\n\tNO_STORE: 'no-store',\n\tONLY_IF_CACHED: 'only-if-cached',\n\tRELOAD: 'reload'\n} as const;\n\n/** Constant object for request events */\nexport const RequestEvent = {\n\tCONFIGURED: 'configured',\n\tSUCCESS: 'success',\n\tERROR: 'error',\n\tABORTED: 'aborted',\n\tTIMEOUT: 'timeout',\n\tRETRY: 'retry',\n\tCOMPLETE: 'complete',\n\tALL_COMPLETE: 'all-complete'\n} as const;\n\n/** Constant object for signal events */\nconst SignalEvents = {\n\tABORT: 'abort',\n\tTIMEOUT: 'timeout'\n} as const;\n\n/** Constant object for signal errors */\nconst SignalErrors = {\n\tABORT: 'AbortError',\n\tTIMEOUT: 'TimeoutError'\n} as const;\n\n/** Options for adding event listeners */\nconst eventListenerOptions: AddEventListenerOptions = { once: true, passive: true };\n\n/**\n * Creates a new custom abort event.\n * @returns A new AbortEvent instance.\n */\nconst abortEvent = (): AbortEvent => new CustomEvent(SignalEvents.ABORT, { detail: { cause: SignalErrors.ABORT } });\n\n/**\n * Creates a new custom timeout event.\n * @returns A new TimeoutEvent instance.\n */\nconst timeoutEvent = (): TimeoutEvent => new CustomEvent(SignalEvents.TIMEOUT, { detail: { cause: SignalErrors.TIMEOUT } });\n\n/** Array of request body methods */\nconst requestBodyMethods: ReadonlyArray<RequestMethod> = [ 'POST', 'PUT', 'PATCH', 'DELETE' ];\n\n/** Response status for internal server error */\nconst internalServerError: ResponseStatus = new ResponseStatus(500, 'Internal Server Error');\n\n/** Response status for aborted request */\nconst aborted: ResponseStatus = new ResponseStatus(499, 'Aborted');\n\n/** Response status for timed out request */\nconst timedOut: ResponseStatus = new ResponseStatus(504, 'Request Timeout');\n\n/** Default HTTP status codes that trigger a retry */\nconst retryStatusCodes: ReadonlyArray<number> = [ 408, 413, 429, 500, 502, 503, 504 ];\n\n/** Default HTTP methods allowed to retry (idempotent methods only) */\nconst retryMethods: ReadonlyArray<RequestMethod> = [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS' ];\n\n/** Default delay in ms before the first retry */\nconst retryDelay: number = 300;\n\n/** Default backoff factor applied after each retry attempt */\nconst retryBackoffFactor: number = 2;\n\nexport { aborted, abortEvent, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, defaultMediaType, requestBodyMethods, RequestCachingPolicy, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, SignalErrors, SignalEvents, timedOut, timeoutEvent, XSRF_COOKIE_NAME, XSRF_HEADER_NAME };\nexport type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];", "import { SignalErrors, SignalEvents, abortEvent, eventListenerOptions, timeoutEvent } from './constants.js';\nimport type { AbortConfiguration, AbortEvent, AbortSignalEvent } from '@types';\n\n/** Class representing a controller for abort signals, allowing for aborting requests and handling timeout events */\nexport class SignalController {\n\tprivate readonly abortSignal: AbortSignal;\n\tprivate readonly abortController = new AbortController();\n\tprivate readonly events = new Map<EventListener, string>();\n\n\t/**\n\t * Creates a new SignalController instance.\n\t * @param options - The options for the SignalController.\n\t * @param options.signal - The signal to listen for abort events. Defaults to the internal abort signal.\n\t * @param options.timeout - The timeout value in milliseconds. Defaults to Infinity.\n\t * @throws {RangeError} If the timeout value is negative.\n\t */\n\tconstructor({ signal, timeout = Infinity }: AbortConfiguration = {}) {\n\t\tif (timeout < 0) { throw new RangeError('The timeout cannot be negative') }\n\n\t\tconst signals = [ this.abortController.signal ];\n\t\tif (signal != null) { signals.push(signal) }\n\t\tif (timeout !== Infinity) { signals.push(AbortSignal.timeout(timeout)) }\n\n\t\t(this.abortSignal = AbortSignal.any(signals)).addEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\t}\n\n\t/**\n\t * Handles the 'abort' event. If the event is caused by a timeout, the 'timeout' event is dispatched.\n\t * Guards against a timeout firing after a manual abort to prevent spurious timeout events.\n\t * @param event The event to abort with\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#specifying_this_using_bind\n\t */\n\thandleEvent({ target: { reason } }: AbortSignalEvent): void {\n\t\tif (this.abortController.signal.aborted) { return }\n\t\tif (reason instanceof DOMException && reason.name === SignalErrors.TIMEOUT) { this.abortSignal.dispatchEvent(timeoutEvent()) }\n\t}\n\n\t/**\n\t * Gets the signal. This signal will be able to abort the request, but will not be notified if the request is aborted by the timeout.\n\t * @returns The signal\n\t */\n\tget signal(): AbortSignal {\n\t\treturn this.abortSignal;\n\t}\n\n\t/**\n\t * Adds an event listener for the 'abort' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonAbort(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.ABORT, eventListener);\n\t}\n\n\t/**\n\t * Adds an event listener for the 'timeout' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonTimeout(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.TIMEOUT, eventListener);\n\t}\n\n\t/**\n\t * Aborts the signal.\n\t *\n\t * @param event The event to abort with\n\t */\n\tabort(event: AbortEvent = abortEvent()): void {\n\t\tthis.abortController.abort(event.detail?.cause);\n\t}\n\n\t/**\n\t * Removes all event listeners from the signal.\n\t *\n\t * @returns The SignalController\n\t */\n\tdestroy(): SignalController {\n\t\tthis.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\n\t\tfor (const [ eventListener, type ] of this.events) {\n\t\t\tthis.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);\n\t\t}\n\n\t\tthis.events.clear();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an event listener for the specified event type.\n\t *\n\t * @param type The event type to listen for\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tprivate addEventListener(type: string, eventListener: EventListener): SignalController {\n\t\tthis.abortSignal.addEventListener(type, eventListener, eventListenerOptions);\n\t\tthis.events.set(eventListener, type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'SignalController';\n\t}\n}", "import type { Json, ResponseHandler } from '@types';\n\n/** Cached promise for lazy jsdom initialization \u2014 resolved once, reused thereafter */\nlet domReady: Promise<void> | undefined;\n\n/** Cached promise for lazy DOMPurify initialization \u2014 resolved once, reused thereafter */\nlet purifyReady: Promise<(dirty: string) => string> | undefined;\n\n/**\n * Returns a bound sanitize function, lazily loading DOMPurify on first invocation.\n * Must be called after ensureDom() to ensure the DOM environment is ready.\n * @returns A Promise resolving to the sanitize function.\n */\nconst getSanitize = (): Promise<(dirty: string) => string> =>\n\tpurifyReady ??= import('dompurify').then(({ default: p }) => (dirty: string): string => p.sanitize(dirty));\n\n/**\n * Ensures a DOM environment is available (document, DOMParser, DocumentFragment).\n * In browser environments this is a no-op. In Node.js it lazily imports jsdom on first call.\n * @returns A Promise that resolves when the DOM environment is ready.\n */\nconst ensureDom = async (): Promise<void> => {\n\tif (typeof document !== 'undefined' && typeof DOMParser !== 'undefined' && typeof DocumentFragment !== 'undefined') { return Promise.resolve() }\n\n\treturn domReady ??= import('jsdom').then(({ JSDOM }) => {\n\t\tconst { window } = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', { url: 'http://localhost' });\n\t\tglobalThis.window = window as unknown as Window & typeof globalThis;\n\t\tObject.assign(globalThis, { document: window.document, DOMParser: window.DOMParser, DocumentFragment: window.DocumentFragment });\n\t}).catch(() => {\n\t\tdomReady = undefined;\n\t\tthrow new Error('jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom');\n\t});\n};\n\n/**\n * Handles a text response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a string\n */\nconst handleText: ResponseHandler<string> = async (response) => await response.text();\n\n/**\n * Handles a script response by appending it to the Document HTMLHeadElement\n * Only available in browser environments with DOM support.\n *\n * **Security Warning:** This handler executes arbitrary JavaScript from the server response.\n * Only use with fully trusted content sources. No sanitization is applied to script content.\n * Consider using a Content Security Policy (CSP) nonce for additional protection.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleScript: ResponseHandler<void> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst script = document.createElement('script');\n\t\tObject.assign(script, { src: objectURL, type: 'text/javascript', async: true });\n\n\t\t/**\n\t\t * Revoke the object URL and resolve the promise once the script has loaded.\n\t\t */\n\t\tscript.onload = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(script);\n\t\t\tresolve();\n\t\t};\n\n\t\t/**\n\t\t * Revoke the object URL and reject the promise if the script fails to load.\n\t\t */\n\t\tscript.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(script);\n\t\t\treject(new Error('Script failed to load'));\n\t\t};\n\n\t\tdocument.head.appendChild(script);\n\t});\n};\n\n/**\n * Handles a CSS response by appending it to the Document HTMLHeadElement.\n * Only available in browser environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleCss: ResponseHandler<void> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst link = document.createElement('link');\n\t\tObject.assign(link, { href: objectURL, type: 'text/css', rel: 'stylesheet' });\n\n\t\t/**\n\t\t * Revoke the object URL and resolve the promise once the stylesheet has loaded.\n\t\t * @returns A Promise that resolves to void\n\t\t */\n\t\tlink.onload = () => resolve(URL.revokeObjectURL(objectURL));\n\n\t\t/**\n\t\t * Revoke the object URL, remove the link element, and reject the promise if the stylesheet fails to load.\n\t\t */\n\t\tlink.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tdocument.head.removeChild(link);\n\t\t\treject(new Error('Stylesheet load failed'));\n\t\t};\n\n\t\tdocument.head.appendChild(link);\n\t});\n};\n\n/**\n * Handles a JSON response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a JsonObject\n */\nconst handleJson: ResponseHandler<Json> = async (response) => await response.json() as Json;\n\n/**\n * Handles a Blob response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Blob\n */\nconst handleBlob: ResponseHandler<Blob> = async (response) => await response.blob();\n\n/**\n * Handles an image response by creating an object URL and returning an HTMLImageElement.\n * The object URL is revoked once the image is loaded to prevent memory leaks.\n * Works in both browser and Node.js (via JSDOM) environments.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an HTMLImageElement\n */\nconst handleImage: ResponseHandler<HTMLImageElement> = async (response) => {\n\tawait ensureDom();\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\n\treturn new Promise((resolve, reject) => {\n\t\tconst img = new Image();\n\n\t\t/**\n\t\t * Revoke the object URL once the image has loaded to free up memory and resolve with the image.\n\t\t */\n\t\timg.onload = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\tresolve(img);\n\t\t};\n\n\t\t/**\n\t\t * Revoke the object URL and reject the promise if the image fails to load.\n\t\t */\n\t\timg.onerror = () => {\n\t\t\tURL.revokeObjectURL(objectURL);\n\t\t\treject(new Error('Image failed to load'));\n\t\t};\n\n\t\timg.src = objectURL;\n\t});\n};\n\n/**\n * Handles a buffer response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an ArrayBuffer\n */\nconst handleBuffer: ResponseHandler<ArrayBuffer> = async (response) => await response.arrayBuffer();\n\n/**\n * Handles a ReadableStream response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a ReadableStream\n */\nconst handleReadableStream: ResponseHandler<ReadableStream<Uint8Array> | null> = async (response) => Promise.resolve(response.body);\n\n/**\n * Handles an XML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleXml: ResponseHandler<Document> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn new DOMParser().parseFromString(sanitize(await response.text()), 'application/xml');\n};\n\n/**\n * Handles an HTML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleHtml: ResponseHandler<Document> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn new DOMParser().parseFromString(sanitize(await response.text()), 'text/html');\n};\n\n/**\n * Handles an HTML fragment response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragment: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\tconst sanitize = await getSanitize();\n\treturn document.createRange().createContextualFragment(sanitize(await response.text()));\n};\n\nexport { handleText, handleScript, handleCss, handleJson, handleBlob, handleImage, handleBuffer, handleReadableStream, handleXml, handleHtml, handleHtmlFragment };\n", "import { requestBodyMethods } from './constants';\nimport type { JsonString, JsonValue, RequestBodyMethod, RequestMethod } from '@types';\n\n/**\n * Type guard to check if a request method accepts a body.\n * @param method The request method to check.\n * @returns True if the method accepts a body, false otherwise.\n */\nexport const isRequestBodyMethod = (method: RequestMethod | undefined): method is RequestBodyMethod =>\n\tmethod !== undefined && requestBodyMethods.includes(method);\n\n/**\n * Checks whether a body value is a raw BodyInit type that should be sent as-is\n * (no JSON serialization) and should have its Content-Type deleted so the runtime\n * can set it automatically (e.g. multipart/form-data boundary for FormData).\n * @param body The request body to check.\n * @returns True if the body is a FormData, Blob, ArrayBuffer, TypedArray, DataView, ReadableStream, or URLSearchParams.\n */\nexport const isRawBody = (body: unknown): boolean =>\n\tbody instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream || body instanceof URLSearchParams || ArrayBuffer.isView(body);\n\n/**\n * Reads a cookie value by name from document.cookie.\n * Returns undefined in non-browser environments or when the cookie is not found.\n * @param name The cookie name to look up.\n * @returns The cookie value or undefined.\n */\nexport const getCookieValue = (name: string): string | undefined => {\n\tif (typeof document === 'undefined' || !document.cookie) { return }\n\n\tconst prefix = `${name}=`;\n\tconst cookies = document.cookie.split(';');\n\tfor (let i = 0, length = cookies.length; i < length; i++) {\n\t\tconst cookie = cookies[i]!.trim();\n\t\tif (cookie.startsWith(prefix)) { return decodeURIComponent(cookie.slice(prefix.length)) }\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Serialize an object of type T into a JSON string.\n * The type system ensures only JSON-serializable values can be passed.\n * @template T The type of data to serialize (will be validated for JSON compatibility)\n * @param data The object to serialize - must be JSON-serializable.\n * @returns The serialized JSON string.\n */\nexport const serialize = <const T>(data: JsonValue<T>): JsonString<T> => JSON.stringify(data) as JsonString<T>;\n\n/**\n * Type predicate to check if a value is a string\n * @param value The value to check\n * @returns True if value is a string, with type narrowing\n */\nexport const isString = (value: unknown): value is string => value !== null && typeof value === 'string';\n\n/**\n * Type predicate to check if a value is an object (not array or null)\n * @param value The value to check\n * @returns True if value is an object, with type narrowing\n */\nexport const isObject = <T = object>(value: unknown): value is T extends object ? T : never => value !== null && typeof value === 'object' && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;\n\n/**\n * Performs a deep merge of multiple objects\n * @param objects The objects to merge\n * @returns The merged object\n */\nexport const objectMerge = (...objects: Record<PropertyKey, unknown>[]): Record<PropertyKey, unknown> | undefined => {\n\t// Early return for empty input\n\tconst length = objects.length;\n\tif (length === 0) { return undefined }\n\n\t// Early return for single object - just clone it\n\tif (length === 1) {\n\t\tconst [ obj ] = objects;\n\t\tif (!isObject(obj)) { return obj }\n\t\treturn deepClone(obj);\n\t}\n\n\tconst target = {} as Record<PropertyKey, unknown>;\n\n\tfor (const source of objects) {\n\t\tif (!isObject(source)) { return undefined }\n\n\t\tfor (const [property, sourceValue] of Object.entries(source)) {\n\t\t\tconst targetValue = target[property];\n\t\t\tif (Array.isArray(sourceValue)) {\n\t\t\t\t// Handle arrays - source values come first, then unique target values\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\ttarget[property] = [ ...sourceValue, ...(Array.isArray(targetValue) ? targetValue.filter((item) => !sourceValue.includes(item)) : []) ];\n\t\t\t} else if (isObject<Record<string, unknown>>(sourceValue)) {\n\t\t\t\t// Handle plain objects using the isObject function | I am already testing that the targetValue is an object\n\t\t\t\ttarget[property] = isObject<Record<string, unknown>>(targetValue) ? objectMerge(targetValue, sourceValue)! : deepClone(sourceValue);\n\t\t\t} else {\n\t\t\t\t// Primitive values and null/undefined\n\t\t\t\ttarget[property] = sourceValue;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn target;\n};\n\n/**\n * Creates a deep clone of an object for better performance than spread operator in merge scenarios\n * @param object The object to clone\n * @returns The cloned object\n */\nfunction deepClone<T = Record<PropertyKey, unknown>>(object: T): T {\n\tif (isObject<Record<PropertyKey, unknown>>(object)) {\n\t\tconst cloned: Record<PropertyKey, unknown> = {};\n\t\tconst keys = Object.keys(object);\n\t\tfor (let i = 0, length = keys.length, key; i < length; i++) {\n\t\t\tkey = keys[i]!;\n\t\t\tcloned[key] = deepClone(object[key]);\n\t\t}\n\n\t\treturn cloned as T;\n\t}\n\n\t// For other object types (Date, RegExp, etc.), return as-is\n\treturn object;\n}", "import { MediaType } from '@d1g1tal/media-type';\nimport { Subscribr } from '@d1g1tal/subscribr';\nimport { HttpError } from './http-error';\nimport { ResponseStatus } from './response-status';\nimport { SignalController } from './signal-controller.js';\nimport { handleText, handleScript, handleCss, handleJson, handleBlob, handleImage, handleBuffer, handleReadableStream, handleXml, handleHtml, handleHtmlFragment } from './response-handlers';\nimport { isRequestBodyMethod, isRawBody, getCookieValue, isString, isObject, objectMerge, serialize } from './utils';\nimport { RequestCachingPolicy, RequestEvent, SignalErrors, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, endsWithSlashRegEx, internalServerError, mediaTypes, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut } from './constants';\nimport type {\tRequestOptions, ResponseBody, RequestEventHandler, SearchParameters, EventRegistration, ResponseHandler, RequestHeaders, TypedResponse, Json, Entries, HookOptions, HttpErrorOptions, NormalizedRetryOptions, PublishOptions, RetryOptions, RequestTiming, XsrfOptions } from '@types';\n\ndeclare function fetch<R = unknown>(input: RequestInfo | URL, requestOptions?: RequestOptions): Promise<TypedResponse<R>>;\n\ntype RequestConfiguration = {\n\tsignalController: NonNullable<SignalController>,\n\trequestOptions: RequestOptions,\n\tglobal: boolean\n};\n\n/**\n * A wrapper around the fetch API that makes it easier to make HTTP requests.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class Transportr {\n\tprivate readonly _baseUrl: URL;\n\tprivate readonly _options: RequestOptions;\n\tprivate readonly subscribr: Subscribr;\n\tprivate readonly hooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static globalSubscribr = new Subscribr();\n\tprivate static globalHooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static signalControllers = new Set<SignalController>();\n\t/** Map of in-flight deduplicated requests keyed by URL + method */\n\tprivate static inflightRequests = new Map<string, Promise<Response>>();\n\t/** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */\n\tprivate static mediaTypeCache = new Map(Object.values(mediaTypes).map((mediaType) => [ mediaType.toString(), mediaType ]));\n\tprivate static contentTypeHandlers: Entries<string, ResponseHandler<ResponseBody>> = [\n\t\t[ mediaTypes.TEXT.type, handleText ],\n\t\t[ mediaTypes.JSON.subtype, handleJson ],\n\t\t[ mediaTypes.BIN.subtype, handleReadableStream ],\n\t\t[ mediaTypes.HTML.subtype, handleHtml ],\n\t\t[ mediaTypes.XML.subtype, handleXml ],\n\t\t[ mediaTypes.PNG.type, handleImage as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.JAVA_SCRIPT.subtype, handleScript as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.CSS.subtype, handleCss as ResponseHandler<ResponseBody> ]\n\t];\n\n\t/**\n\t * Create a new Transportr instance with the provided location or origin and context path.\n\t *\n\t * @param url The URL for {@link fetch} requests.\n\t * @param options The default {@link RequestOptions} for this instance.\n\t */\n\tconstructor(url: URL | string | RequestOptions = globalThis.location?.origin ?? 'http://localhost', options: RequestOptions = {}) {\n\t\tif (isObject(url)) { [ url, options ] = [ globalThis.location?.origin ?? 'http://localhost', url ] }\n\n\t\tthis._baseUrl = Transportr.getBaseUrl(url);\n\t\tthis._options = Transportr.createOptions(options, Transportr.defaultRequestOptions);\n\t\tthis.subscribr = new Subscribr();\n\t}\n\n\t/** Credentials Policy */\n\tstatic readonly CredentialsPolicy = {\n\t\tINCLUDE: 'include',\n\t\tOMIT: 'omit',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Modes */\n\tstatic readonly RequestModes = {\n\t\tCORS: 'cors',\n\t\tNAVIGATE: 'navigate',\n\t\tNO_CORS: 'no-cors',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Priorities */\n\tstatic readonly RequestPriorities = {\n\t\tHIGH: 'high',\n\t\tLOW: 'low',\n\t\tAUTO: 'auto'\n\t} as const;\n\n\t/** Redirect Policies */\n\tstatic readonly RedirectPolicies = {\n\t\tERROR: 'error',\n\t\tFOLLOW: 'follow',\n\t\tMANUAL: 'manual'\n\t} as const;\n\n\t/** Referrer Policies */\n\tstatic readonly ReferrerPolicy = {\n\t\tNO_REFERRER: 'no-referrer',\n\t\tNO_REFERRER_WHEN_DOWNGRADE: 'no-referrer-when-downgrade',\n\t\tORIGIN: 'origin',\n\t\tORIGIN_WHEN_CROSS_ORIGIN: 'origin-when-cross-origin',\n\t\tSAME_ORIGIN: 'same-origin',\n\t\tSTRICT_ORIGIN: 'strict-origin',\n\t\tSTRICT_ORIGIN_WHEN_CROSS_ORIGIN: 'strict-origin-when-cross-origin',\n\t\tUNSAFE_URL: 'unsafe-url'\n\t} as const;\n\n\t/** Request Events\t*/\n\tstatic readonly RequestEvents: typeof RequestEvent = RequestEvent;\n\n\t/** Default Request Options */\n\tprivate static readonly defaultRequestOptions: RequestOptions = {\n\t\tbody: undefined,\n\t\tcache: RequestCachingPolicy.NO_STORE,\n\t\tcredentials: Transportr.CredentialsPolicy.SAME_ORIGIN,\n\t\theaders: new Headers({ 'content-type': defaultMediaType, 'accept': defaultMediaType }),\n\t\tsearchParams: undefined,\n\t\tintegrity: undefined,\n\t\tkeepalive: undefined,\n\t\tmethod: 'GET',\n\t\tmode: Transportr.RequestModes.CORS,\n\t\tpriority: Transportr.RequestPriorities.AUTO,\n\t\tredirect: Transportr.RedirectPolicies.FOLLOW,\n\t\treferrer: 'about:client',\n\t\treferrerPolicy: Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,\n\t\tsignal: undefined,\n\t\ttimeout: 30000,\n\t\tglobal: true\n\t};\n\n\t/**\n\t * Returns a {@link EventRegistration} used for subscribing to global events.\n\t *\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn Transportr.globalSubscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Removes a {@link EventRegistration} from the global event handler.\n\t *\n\t * @param eventRegistration The {@link EventRegistration} to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tstatic unregister(eventRegistration: EventRegistration): boolean {\n\t\treturn Transportr.globalSubscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Aborts all active requests.\n\t * This is useful for when the user navigates away from the current page.\n\t * This will also clear the {@link Transportr#signalControllers} set.\n\t */\n\tstatic abortAll(): void {\n\t\tfor (const signalController of this.signalControllers) {\n\t\t\tsignalController.abort(abortEvent());\n\t\t}\n\n\t\t// Clear the set after aborting all requests\n\t\tthis.signalControllers.clear();\n\t}\n\n\t/**\n\t * Registers a custom content-type response handler.\n\t * The handler will be matched against response content-type headers using MediaType matching.\n\t * New handlers are prepended so they take priority over built-in handlers.\n\t *\n\t * @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').\n\t * @param handler The response handler function.\n\t */\n\tstatic registerContentTypeHandler(contentType: string, handler: ResponseHandler): void {\n\t\t// Prepend so custom handlers take priority over built-in ones\n\t\tTransportr.contentTypeHandlers.unshift([ contentType, handler ]);\n\t}\n\n\t/**\n\t * Removes a previously registered content-type response handler.\n\t *\n\t * @param contentType The content-type string to remove.\n\t * @returns True if the handler was found and removed, false otherwise.\n\t */\n\tstatic unregisterContentTypeHandler(contentType: string): boolean {\n\t\tconst index = Transportr.contentTypeHandlers.findIndex(([ type ]) => type === contentType);\n\t\tif (index === -1) { return false }\n\n\t\tTransportr.contentTypeHandlers.splice(index, 1);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Registers global lifecycle hooks that run on all requests from all instances.\n\t * Global hooks execute before instance and per-request hooks.\n\t *\n\t * @param hooks The hooks to register globally.\n\t */\n\tstatic addHooks(hooks: HookOptions): void {\n\t\tif (hooks.beforeRequest) { Transportr.globalHooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { Transportr.globalHooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { Transportr.globalHooks.beforeError.push(...hooks.beforeError) }\n\t}\n\n\t/**\n\t * Removes all global lifecycle hooks.\n\t */\n\tstatic clearHooks(): void {\n\t\tTransportr.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\t}\n\n\t/**\n\t * Tears down all global state: aborts in-flight requests, clears global event subscriptions,\n\t * hooks, in-flight deduplication map, and media type cache (retaining built-in entries).\n\t */\n\tstatic unregisterAll(): void {\n\t\tTransportr.abortAll();\n\t\tTransportr.globalSubscribr = new Subscribr();\n\t\tTransportr.clearHooks();\n\t\tTransportr.inflightRequests.clear();\n\t}\n\n\t/**\n\t * It returns the base {@link URL} for the API.\n\t *\n\t * @returns The baseUrl property.\n\t */\n\tget baseUrl(): URL {\n\t\treturn this._baseUrl;\n\t}\n\n\t/**\n\t * Registers an event handler with a {@link Transportr} instance.\n\t *\n\t * @param event The name of the event to listen for.\n\t * @param handler The function to call when the event is triggered.\n\t * @param context The context to bind to the handler.\n\t * @returns An object that can be used to remove the event handler.\n\t */\n\tregister(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn this.subscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Unregisters an event handler from a {@link Transportr} instance.\n\t *\n\t * @param eventRegistration The event registration to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tunregister(eventRegistration: EventRegistration): boolean {\n\t\treturn this.subscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Registers instance-level lifecycle hooks that run on all requests from this instance.\n\t * Instance hooks execute after global hooks but before per-request hooks.\n\t *\n\t * @param hooks The hooks to register on this instance.\n\t * @returns This instance for method chaining.\n\t */\n\taddHooks(hooks: HookOptions): this {\n\t\tif (hooks.beforeRequest) { this.hooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { this.hooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { this.hooks.beforeError.push(...hooks.beforeError) }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes all instance-level lifecycle hooks.\n\t * @returns This instance for method chaining.\n\t */\n\tclearHooks(): this {\n\t\tthis.hooks.beforeRequest.length = 0;\n\t\tthis.hooks.afterResponse.length = 0;\n\t\tthis.hooks.beforeError.length = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Tears down this instance: clears all instance subscriptions and hooks.\n\t * The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.clearHooks();\n\t\tthis.subscribr.destroy();\n\t}\n\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is GET.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this._get<T>(path, options);\n\t}\n\n\t/**\n\t * This function makes a POST request to the given path with the given body and options.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tasync post<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\tif (typeof(path) !== 'string') { [ path, options ] = [ undefined, path as RequestOptions ] }\n\n\t\treturn this.execute<T>(path, options, { method: 'POST' });\n\t}\n\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is PUT.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param options The options for the request.\n\t * @returns The return value of the #request method.\n\t */\n\tasync put<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'PUT' });\n\t}\n\n\t/**\n\t * It takes a path and options, and returns a request with the method set to PATCH.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to hit.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync patch<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'PATCH' });\n\t}\n\n\t/**\n\t * It takes a path and options, and returns a request with the method set to DELETE.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param options The options for the request.\n\t * @returns The result of the request.\n\t */\n\tasync delete<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'DELETE' });\n\t}\n\n\t/**\n\t * Returns the response headers of a request to the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response object.\n\t */\n\tasync head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined> {\n\t\treturn this.execute<T>(path, options, { method: 'HEAD' });\n\t}\n\n\t/**\n\t * It returns a promise that resolves to the allowed request methods for the given resource path.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an array of allowed request methods for this resource.\n\t */\n\tasync options(path?: string | RequestOptions, options: RequestOptions = {}): Promise<string[] | undefined> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, { method: 'OPTIONS' });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\tif (result) {\n\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet response: Response = await this._request(path, requestConfig);\n\n\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\tif (result) { response = result }\n\t\t\t}\n\t\t}\n\n\t\tconst allowedMethods = response.headers.get('allow')?.split(',').map((method: string) => method.trim());\n\n\t\tthis.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });\n\n\t\treturn allowedMethods;\n\t}\n\n\t/**\n\t * It takes a path and options, and makes a request to the server\n\t * @async\n\t * @param path The path to the endpoint you want to hit.\n\t * @param options The options for the request.\n\t * @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.\n\t * @throws {HttpError} If an error occurs during the request.\n\t */\n\tasync request<T = unknown>(path?: string | RequestOptions, options: RequestOptions = {}): Promise<TypedResponse<T>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst response = await this._request<T>(path, this.processRequestOptions(options, {}));\n\n\t\tthis.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });\n\n\t\treturn response;\n\t}\n\n\t/**\n\t * It gets the JSON representation of the resource at the given path.\n\t *\n\t * @async\n\t * @template T The expected JSON response type (defaults to JsonObject)\n\t * @param path The path to the resource.\n\t * @param options The options object to pass to the request.\n\t * @returns A promise that resolves to the response body as a typed JSON value.\n\t */\n\tasync getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);\n\t}\n\n\t/**\n\t * It gets the XML representation of the resource at the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns The result of the function call to #get.\n\t */\n\tasync getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);\n\t}\n\n\t/**\n\t * Get the HTML content of the specified path.\n\t * When a selector is provided, returns only the first matching element from the parsed document.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed HTML.\n\t * @returns A promise that resolves to a Document, an Element (if selector matched), or void.\n\t */\n\tasync getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined> {\n\t\tconst doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);\n\t\treturn selector && doc ? doc.querySelector(selector) : doc;\n\t}\n\n\t/**\n\t * It returns a promise that resolves to the HTML fragment at the given path.\n\t * When a selector is provided, returns only the first matching element from the parsed fragment.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed fragment.\n\t * @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.\n\t */\n\tasync getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined> {\n\t\tconst fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtmlFragment);\n\t\treturn selector && fragment ? fragment.querySelector(selector) : fragment;\n\t}\n\t/**\n\t * It gets a script from the server, and appends the script to the Document HTMLHeadElement\n\t * @param path The path to the script.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);\n\t}\n\n\t/**\n\t * Gets a stylesheet from the server, and adds it as a Blob URL.\n\t * @param path The path to the stylesheet.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);\n\t}\n\n\t/**\n\t * It returns a blob from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a Blob or void.\n\t */\n\tasync getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBlob);\n\t}\n\n\t/**\n\t * It returns a promise that resolves to an `HTMLImageElement`.\n\t * The object URL created to load the image is automatically revoked to prevent memory leaks.\n\t * Works in both browser and Node.js (via JSDOM) environments.\n\t * @param path The path to the image.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an `HTMLImageElement` or `void`.\n\t */\n\tasync getImage(path?: string, options?: RequestOptions): Promise<HTMLImageElement | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'image/*' } }, handleImage);\n\t}\n\n\t/**\n\t * It gets a buffer from the specified path\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an ArrayBuffer or void.\n\t */\n\tasync getBuffer(path?: string | RequestOptions, options?: RequestOptions): Promise<ArrayBuffer | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBuffer);\n\t}\n\n\t/**\n\t * It returns a readable stream of the response body from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a ReadableStream, null, or void.\n\t */\n\tasync getStream(path?: string | RequestOptions, options?: RequestOptions): Promise<ReadableStream<Uint8Array> | null | undefined> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleReadableStream);\n\t}\n\n\t/**\n\t * Handles a GET request.\n\t * @async\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A promise that resolves to the response body or void.\n\t */\n\tprivate async _get<T extends ResponseBody>(path?: string | RequestOptions, userOptions?: RequestOptions, options: RequestOptions = {}, responseHandler?: ResponseHandler<T>): Promise<T | undefined> {\n\t\treturn this.execute(path, userOptions, { ...options, method: 'GET', body: undefined }, responseHandler);\n\t}\n\n\t/**\n\t * It processes the request options and returns a new object with the processed options.\n\t * @param path The path to the resource.\n\t * @param processedRequestOptions The user options for the request.\n\t * @returns A new object with the processed options.\n\t */\n\tprivate async _request<T = unknown>(path: string | undefined, { signalController, requestOptions, global }: RequestConfiguration): Promise<TypedResponse<T>> {\n\t\tTransportr.signalControllers.add(signalController);\n\n\t\tconst retryConfig = Transportr.normalizeRetryOptions(requestOptions.retry);\n\t\tconst method = requestOptions.method ?? 'GET';\n\t\tconst canRetry = retryConfig.limit > 0 && retryConfig.methods.includes(method);\n\t\tconst canDedupe = requestOptions.dedupe === true && (method === 'GET' || method === 'HEAD');\n\t\tlet attempt = 0;\n\t\tconst startTime = performance.now();\n\n\t\t/**\n\t\t * Creates a RequestTiming snapshot from the start time to now.\n\t\t * @returns Timing information for the request.\n\t\t */\n\t\tconst getTiming = (): RequestTiming => {\n\t\t\tconst end = performance.now();\n\t\t\treturn { start: startTime, end, duration: end - startTime };\n\t\t};\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst dedupeKey = canDedupe ? `${method}:${url.href}` : '';\n\n\t\t\t// If deduplication is enabled and an in-flight request exists, clone its response\n\t\t\tif (canDedupe) {\n\t\t\t\tconst inflight = Transportr.inflightRequests.get(dedupeKey);\n\t\t\t\tif (inflight) { return (await inflight).clone() as TypedResponse<T> }\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Performs the fetch with retry logic.\n\t\t\t * @returns A promise resolving to the typed response.\n\t\t\t */\n\t\t\tconst doFetch = async (): Promise<TypedResponse<T>> => {\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await fetch<T>(url, requestOptions);\n\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit && retryConfig.statusCodes.includes(response.status)) {\n\t\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, status: response.status, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Capture response body for error diagnostics\n\t\t\t\t\t\t\tlet entity: ResponseBody | undefined;\n\t\t\t\t\t\t\ttry { entity = await response.text() } catch { /* body may be unavailable */ }\n\t\t\t\t\t\t\tthrow await this.handleError(path, response, { entity, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\tif (cause instanceof HttpError) { throw cause }\n\n\t\t\t\t\t\t// Network error \u2014 retry if allowed\n\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit) {\n\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, error: (cause as Error).message, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthrow await this.handleError(path, undefined, { cause: cause as Error, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (canDedupe) {\n\t\t\t\tconst promise = doFetch();\n\t\t\t\tTransportr.inflightRequests.set(dedupeKey, promise as Promise<Response>);\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await promise;\n\t\t\t\t\treturn response;\n\t\t\t\t} finally {\n\t\t\t\t\tTransportr.inflightRequests.delete(dedupeKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await doFetch();\n\t\t} finally {\n\t\t\tTransportr.signalControllers.delete(signalController.destroy());\n\t\t\tif (!requestOptions.signal?.aborted) {\n\t\t\t\tconst timing = getTiming();\n\t\t\t\tthis.publish({ name: RequestEvent.COMPLETE, data: { timing }, global });\n\t\t\t\tif (Transportr.signalControllers.size === 0) {\n\t\t\t\t\tthis.publish({ name: RequestEvent.ALL_COMPLETE, global });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Normalizes a retry option into a full RetryOptions object.\n\t * @param retry The retry option from request options.\n\t * @returns Normalized retry configuration.\n\t */\n\tprivate static normalizeRetryOptions(retry?: number | RetryOptions): NormalizedRetryOptions {\n\t\tif (retry === undefined) { return { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\t\tif (typeof retry === 'number') { return { limit: retry, statusCodes: [ ...retryStatusCodes ], methods: [ ...retryMethods ], delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\n\t\treturn {\n\t\t\tlimit: retry.limit ?? 0,\n\t\t\tstatusCodes: retry.statusCodes ?? [ ...retryStatusCodes ],\n\t\t\tmethods: retry.methods ?? [ ...retryMethods ],\n\t\t\tdelay: retry.delay ?? retryDelay,\n\t\t\tbackoffFactor: retry.backoffFactor ?? retryBackoffFactor\n\t\t};\n\t}\n\n\t/**\n\t * Waits for the appropriate delay before a retry attempt.\n\t * @param config The retry configuration.\n\t * @param attempt The current attempt number (1-based).\n\t * @returns A promise that resolves after the delay.\n\t */\n\tprivate static retryDelay(config: NormalizedRetryOptions, attempt: number): Promise<void> {\n\t\tconst ms = typeof config.delay === 'function' ? config.delay(attempt) : config.delay * (config.backoffFactor ** (attempt - 1));\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A response handler function.\n\t */\n\tprivate async execute<T extends ResponseBody>(path?: string | RequestOptions, userOptions: RequestOptions = {}, options: RequestOptions = {}, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined> {\n\t\tif (isObject(path)) { [ path, userOptions ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(userOptions, options);\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\n\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\tif (result) {\n\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet response = await this._request<T>(path, requestConfig);\n\n\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\tif (result) { response = result as TypedResponse<T> }\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tif (!responseHandler && response.status !== 204) {\n\t\t\t\tresponseHandler = this.getResponseHandler<T>(response.headers.get('content-type'));\n\t\t\t}\n\n\t\t\tconst data = await responseHandler?.(response);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });\n\n\t\t\treturn data;\n\t\t} catch (cause) {\n\t\t\tthrow await this.handleError(path as string, response, { cause: cause as Error }, requestOptions);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new set of options for a request.\n\t * @param options The user options for the request.\n\t * @param userOptions The default options for the request.\n\t * @returns A new set of options for the request.\n\t */\n\tprivate static createOptions({ headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestOptions {\n\t\theaders = Transportr.mergeHeaders(new Headers(), userHeaders, headers);\n\t\tsearchParams = Transportr.mergeSearchParams(new URLSearchParams(), userSearchParams, searchParams);\n\n\t\treturn { ...objectMerge(options, userOptions) ?? {}, headers, searchParams };\n\t}\n\n\t/**\n\t * Merges user and request headers into the target Headers object.\n\t * @param target The target Headers object.\n\t * @param headerSources Variable number of header sources to merge.\n\t * @returns The merged Headers object.\n\t */\n\tprivate static mergeHeaders(target: Headers, ...headerSources: (RequestHeaders | undefined)[]): Headers {\n\t\tfor (const headers of headerSources) {\n\t\t\tif (headers === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (headers instanceof Headers) {\n\t\t\t\t// Use the native forEach method for Headers\n\t\t\t\theaders.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (Array.isArray(headers)) {\n\t\t\t\t// Handle array of tuples format\n\t\t\t\tfor (const [ name, value ] of headers) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() for better performance\n\t\t\t\tconst record = headers as Record<string, string | undefined>;\n\t\t\t\tconst keys = Object.keys(record);\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = record[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, String(value)) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Merges user and request search parameters into the target URLSearchParams object.\n\t * @param target The target URLSearchParams object.\n\t * @param sources The search parameters to merge.\n\t * @returns The merged URLSearchParams object.\n\t */\n\tprivate static mergeSearchParams(target: URLSearchParams, ...sources: (SearchParameters | undefined)[]): URLSearchParams {\n\t\tfor (const searchParams of sources) {\n\t\t\tif (searchParams === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (searchParams instanceof URLSearchParams) {\n\t\t\t\t// Use the native forEach method for URLSearchParams\n\t\t\t\tsearchParams.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (isString(searchParams) || Array.isArray(searchParams)) {\n\t\t\t\tfor (const [name, value] of new URLSearchParams(searchParams)) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() for better performance\n\t\t\t\tconst keys = Object.keys(searchParams);\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = searchParams[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, String(value)) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Processes request options by merging user, instance, and method-specific options.\n\t * This method optimizes performance by using cached instance options and performing\n\t * shallow merges where possible instead of deep object cloning.\n\t * @param userOptions The user-provided options for the request.\n\t * @param options Additional method-specific options.\n\t * @returns Processed request options with signal controller and global flag.\n\t */\n\tprivate processRequestOptions({ body: userBody, headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestConfiguration {\n\t\t// Optimize: Use shallow merge for non-nested properties instead of deep objectMerge\n\t\t// The instance _options are already merged with defaults in the constructor\n\t\tconst requestOptions = {\n\t\t\t// Spread instance options (already merged with defaults)\n\t\t\t...this._options,\n\t\t\t// Spread user options (shallow merge, sufficient for flat properties)\n\t\t\t...userOptions,\n\t\t\t// Spread method-specific options (e.g., method: 'POST')\n\t\t\t...options,\n\t\t\t// Deep merge required for headers and searchParams\n\t\t\theaders: Transportr.mergeHeaders(new Headers(), this._options.headers, userHeaders, headers),\n\t\t\tsearchParams: Transportr.mergeSearchParams(new URLSearchParams(), this._options.searchParams, userSearchParams, searchParams)\n\t\t};\n\n\t\tif (isRequestBodyMethod(requestOptions.method)) {\n\t\t\tif (isRawBody(userBody)) {\n\t\t\t\t// Raw BodyInit \u2014 send as-is, delete Content-Type so the runtime sets it automatically\n\t\t\t\trequestOptions.body = userBody;\n\t\t\t\trequestOptions.headers.delete('content-type');\n\t\t\t} else {\n\t\t\t\tconst isJson = requestOptions.headers.get('content-type')?.includes('json') ?? false;\n\t\t\t\trequestOptions.body = isJson && isObject(userBody) ? serialize(userBody) : userBody;\n\t\t\t}\n\t\t} else {\n\t\t\trequestOptions.headers.delete('content-type');\n\t\t\tif (requestOptions.body instanceof URLSearchParams) {\n\t\t\t\tTransportr.mergeSearchParams(requestOptions.searchParams, requestOptions.body);\n\t\t\t}\n\t\t\trequestOptions.body = undefined;\n\t\t}\n\n\t\tconst { signal, timeout, global = false, xsrf } = requestOptions;\n\n\t\t// XSRF/CSRF protection: read token from cookie and set as request header\n\t\tif (xsrf) {\n\t\t\tconst xsrfConfig: XsrfOptions = typeof xsrf === 'object' ? xsrf : {};\n\t\t\tconst token = getCookieValue(xsrfConfig.cookieName ?? XSRF_COOKIE_NAME);\n\t\t\tif (token) { requestOptions.headers.set(xsrfConfig.headerName ?? XSRF_HEADER_NAME, token) }\n\t\t}\n\n\t\tconst signalController = new SignalController({ signal, timeout })\n\t\t\t.onAbort((event) => this.publish({ name: RequestEvent.ABORTED, event, global }))\n\t\t\t.onTimeout((event) => this.publish({ name: RequestEvent.TIMEOUT, event, global }));\n\n\t\trequestOptions.signal = signalController.signal;\n\t\tthis.publish({ name: RequestEvent.CONFIGURED, data: requestOptions, global });\n\n\t\treturn { signalController, requestOptions, global } as RequestConfiguration;\n\t}\n\n\t/**\n\t * Gets the base URL from a URL or string.\n\t * @param url The URL or string to parse.\n\t * @returns The base URL.\n\t */\n\tprivate static getBaseUrl(url: URL | string): URL {\n\t\tif (url instanceof URL) { return url }\n\n\t\tif (!isString(url)) { throw new TypeError('Invalid URL') }\n\n\t\treturn new URL(url, url.startsWith('/') ? globalThis.location.origin : undefined);\n\t}\n\n\t/**\n\t * Parses a content-type string into a MediaType instance with caching.\n\t * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,\n\t * which significantly improves performance for repeated requests with the same content types.\n\t * @param contentType The content-type string to parse.\n\t * @returns The parsed MediaType instance, or undefined if parsing fails.\n\t */\n\tprivate static getOrParseMediaType(contentType: string | null): MediaType | undefined {\n\t\tif (contentType === null) { return }\n\n\t\t// Check the predefined mediaTypes map first (fastest lookup) or the cache\n\t\tlet mediaType = Transportr.mediaTypeCache.get(contentType);\n\n\t\tif (mediaType !== undefined) { return mediaType }\n\n\t\t// Parse and cache the new MediaType\n\t\tmediaType = MediaType.parse(contentType) ?? undefined;\n\n\t\tif (mediaType !== undefined) {\n\t\t\t// Evict oldest entries when cache exceeds limit to prevent unbounded growth\n\t\t\tif (Transportr.mediaTypeCache.size >= 100) {\n\t\t\t\tconst firstKey = Transportr.mediaTypeCache.keys().next().value;\n\t\t\t\tif (firstKey !== undefined) { Transportr.mediaTypeCache.delete(firstKey) }\n\t\t\t}\n\t\t\tTransportr.mediaTypeCache.set(contentType, mediaType);\n\t\t}\n\n\t\treturn mediaType;\n\t}\n\n\t/**\n\t * Creates a new URL with the given path and search parameters.\n\t * @param url The base URL.\n\t * @param path The path to append to the base URL.\n\t * @param searchParams The search parameters to append to the URL.\n\t * @returns A new URL with the given path and search parameters.\n\t */\n\tprivate static createUrl(url: URL, path?: string, searchParams?: SearchParameters): URL {\n\t\tconst requestUrl = path ? new URL(`${url.pathname.replace(endsWithSlashRegEx, '')}${path}`, url.origin) : new URL(url);\n\n\t\tif (searchParams) {\n\t\t\tTransportr.mergeSearchParams(requestUrl.searchParams, searchParams);\n\t\t}\n\n\t\treturn requestUrl;\n\t}\n\n\t/**\n\t * It generates a ResponseStatus object from an error name and a Response object.\n\t * @param errorName The name of the error.\n\t * @param response The Response object.\n\t * @returns A ResponseStatus object.\n\t */\n\tprivate static generateResponseStatusFromError(errorName?: string, { status, statusText }: Response = new Response()): ResponseStatus {\n\t\tswitch (errorName) {\n\t\t\tcase SignalErrors.ABORT: return aborted;\n\t\t\tcase SignalErrors.TIMEOUT: return timedOut;\n\t\t\tdefault: return status >= 400 ? new ResponseStatus(status, statusText) : internalServerError;\n\t\t}\n\t}\n\n\t/**\n\t * Handles an error that occurs during a request.\n\t * @param path The path of the request.\n\t * @param response The Response object.\n\t * @param options Additional error context including cause, entity, url, method, and timing.\n\t * @param requestOptions The original request options that led to the error, used for hooks context.\n\t * @returns An HttpError object.\n\t */\n\tprivate async handleError(path?: string, response?: Response, { cause, entity, url, method, timing }: Omit<HttpErrorOptions, 'message'> = {}, requestOptions?: RequestOptions): Promise<HttpError> {\n\t\tconst message = method && url\t? `${method} ${url.href} failed${response ? ` with status ${response.status}` : ''}` : `An error has occurred with your request to: '${path}'`;\n\t\tlet error = new HttpError(Transportr.generateResponseStatusFromError(cause?.name, response), { message, cause, entity, url, method, timing });\n\n\t\t// Run beforeError hooks: global \u2192 instance \u2192 per-request\n\t\tconst beforeErrorHookSets = [ Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError ];\n\t\tfor (const hooks of beforeErrorHookSets) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(error);\n\t\t\t\tif (result instanceof HttpError) { error = result }\n\t\t\t}\n\t\t}\n\n\t\tthis.publish({ name: RequestEvent.ERROR, data: error });\n\n\t\treturn error;\n\t}\n\n\t/**\n\t * Publishes an event to the global and instance event handlers.\n\t * @param eventObject The event object to publish.\n\t */\n\tprivate publish({ name, event = new CustomEvent(name), data, global = true }: PublishOptions): void {\n\t\tif (global) { Transportr.globalSubscribr.publish(name, event, data) }\n\t\tthis.subscribr.publish(name, event, data);\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param contentType The content type of the response.\n\t * @returns A response handler function.\n\t */\n\tprivate getResponseHandler<T extends ResponseBody>(contentType?: string | null): ResponseHandler<T> | undefined {\n\t\tif (!contentType) { return }\n\n\t\tconst mediaType = Transportr.getOrParseMediaType(contentType);\n\n\t\tif (!mediaType) { return }\n\n\t\tfor (const [ contentType, responseHandler ] of Transportr.contentTypeHandlers) {\n\t\t\tif (mediaType.matches(contentType)) { return responseHandler as ResponseHandler<T> }\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * A string representation of the Transportr instance.\n\t * @returns The string 'Transportr'.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Transportr';\n\t}\n}\n"],
5
+ "mappings": "AAAO,IAAMA,EAA8B,iCCErCC,GAAkB,YAClBC,GAA0C,qCAanCC,EAAN,MAAMC,UAA4B,GAAoB,CAM5D,YAAYC,EAAsC,CAAC,EAAG,CACrD,MAAMA,CAAO,CACd,CASA,OAAO,QAAQC,EAAcC,EAAwB,CACpD,OAAOP,EAAoB,KAAKM,CAAI,GAAKJ,GAAgC,KAA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,GAAK,gDAAgDP,CAAI,IACrKoF,EAAQ,IAAIpD,EAAU5D,EAAW,gCAAgC2D,GAAO,KAAMxB,CAAQ,EAAG,CAAE,QAAA4E,EAAS,MAAApD,EAAO,OAAAD,EAAQ,IAAA9C,EAAK,OAAA0B,EAAQ,OAAAwB,CAAO,CAAC,EAGtImD,EAAsB,CAAEjH,EAAW,YAAY,YAAa,KAAK,MAAM,YAAa8B,GAAgB,OAAO,WAAY,EAC7H,QAAWH,KAASsF,EACnB,GAAKtF,EACL,QAAWM,KAAQN,EAAO,CACzB,IAAMO,EAAS,MAAMD,EAAK+E,CAAK,EAC3B9E,aAAkB0B,IAAaoD,EAAQ9E,EAC5C,CAGD,YAAK,QAAQ,CAAE,KAAMnB,EAAa,MAAO,KAAMiG,CAAM,CAAC,EAE/CA,CACR,CAMQ,QAAQ,CAAE,KAAAhC,EAAM,MAAA9D,EAAQ,IAAI,YAAY8D,CAAI,EAAG,KAAAT,EAAM,OAAAxB,EAAS,EAAK,EAAyB,CAC/FA,GAAU/C,EAAW,gBAAgB,QAAQgF,EAAM9D,EAAOqD,CAAI,EAClE,KAAK,UAAU,QAAQS,EAAM9D,EAAOqD,CAAI,CACzC,CAOQ,mBAA2C/C,EAA6D,CAC/G,GAAI,CAACA,EAAe,OAEpB,IAAMrB,EAAYH,EAAW,oBAAoBwB,CAAW,EAE5D,GAAKrB,GAEL,OAAW,CAAEqB,EAAasB,CAAgB,IAAK9C,EAAW,oBACzD,GAAIG,EAAU,QAAQqB,CAAW,EAAK,OAAOsB,EAI/C,CAMA,IAAK,OAAO,WAAW,GAAY,CAClC,MAAO,YACR,CACD",
6
+ "names": ["httpTokenCodePoints", "matcher", "httpQuotedStringTokenCodePoints", "MediaTypeParameters", "_MediaTypeParameters", "entries", "name", "value", "whitespaceChars", "trailingWhitespace", "leadingAndTrailingWhitespace", "MediaTypeParser", "_MediaTypeParser", "input", "position", "type", "typeEnd", "subtype", "subtypeEnd", "parameters", "pos", "stopChars", "lowerCase", "trim", "result", "length", "char", "component", "MediaType", "_MediaType", "mediaType", "SetMultiMap", "key", "value", "iterator", "values", "deleted", "ContextEventHandler", "context", "eventHandler", "event", "data", "Subscription", "eventName", "contextEventHandler", "Subscribr", "i", "errorHandler", "options", "originalHandler", "subscription", "contextEventHandlers", "removed", "error", "HttpError", "status", "message", "cause", "entity", "url", "method", "timing", "ResponseStatus", "code", "text", "charset", "endsWithSlashRegEx", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "mediaTypes", "h", "defaultMediaType", "RequestCachingPolicy", "RequestEvent", "SignalEvents", "SignalErrors", "eventListenerOptions", "abortEvent", "timeoutEvent", "requestBodyMethods", "internalServerError", "ResponseStatus", "aborted", "timedOut", "retryStatusCodes", "retryMethods", "retryDelay", "retryBackoffFactor", "SignalController", "signal", "timeout", "signals", "SignalEvents", "eventListenerOptions", "reason", "SignalErrors", "timeoutEvent", "eventListener", "event", "abortEvent", "type", "domReady", "purifyReady", "getSanitize", "p", "dirty", "ensureDom", "JSDOM", "window", "handleText", "response", "handleScript", "objectURL", "resolve", "reject", "script", "handleCss", "link", "handleJson", "handleBlob", "handleImage", "img", "handleBuffer", "handleReadableStream", "handleXml", "sanitize", "handleHtml", "handleHtmlFragment", "isRequestBodyMethod", "method", "requestBodyMethods", "isRawBody", "body", "getCookieValue", "name", "prefix", "cookies", "i", "length", "cookie", "serialize", "data", "isString", "value", "isObject", "objectMerge", "objects", "obj", "deepClone", "target", "source", "property", "sourceValue", "targetValue", "item", "object", "cloned", "keys", "key", "Transportr", "_Transportr", "h", "mediaTypes", "mediaType", "handleText", "handleJson", "handleReadableStream", "handleHtml", "handleXml", "handleImage", "handleScript", "handleCss", "url", "options", "isObject", "RequestEvent", "RequestCachingPolicy", "defaultMediaType", "event", "handler", "context", "eventRegistration", "signalController", "abortEvent", "contentType", "index", "type", "hooks", "path", "requestConfig", "requestOptions", "requestHooks", "beforeRequestHookSets", "hook", "result", "response", "afterResponseHookSets", "allowedMethods", "method", "selector", "doc", "fragment", "handleHtmlFragment", "handleBlob", "handleBuffer", "userOptions", "responseHandler", "global", "retryConfig", "canRetry", "canDedupe", "attempt", "startTime", "getTiming", "end", "dedupeKey", "inflight", "doFetch", "entity", "cause", "HttpError", "promise", "timing", "retry", "retryDelay", "retryBackoffFactor", "retryStatusCodes", "retryMethods", "config", "ms", "resolve", "data", "userHeaders", "userSearchParams", "headers", "searchParams", "objectMerge", "target", "headerSources", "value", "name", "record", "keys", "sources", "isString", "i", "userBody", "isRequestBodyMethod", "isRawBody", "isJson", "serialize", "signal", "timeout", "xsrf", "xsrfConfig", "token", "getCookieValue", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "SignalController", "firstKey", "requestUrl", "endsWithSlashRegEx", "errorName", "status", "statusText", "SignalErrors", "aborted", "timedOut", "ResponseStatus", "internalServerError", "message", "error", "beforeErrorHookSets"]
7
7
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@d1g1tal/transportr",
3
3
  "author": "D1g1talEntr0py",
4
- "version": "2.1.2",
5
- "license": "ISC",
4
+ "version": "2.2.0",
5
+ "license": "MIT",
6
6
  "description": "JavaScript wrapper for the Fetch API and more...",
7
7
  "homepage": "https://github.com/D1g1talEntr0py/transportr#readme",
8
8
  "repository": {
@@ -22,6 +22,7 @@
22
22
  "node": ">=20.0.0"
23
23
  },
24
24
  "type": "module",
25
+ "types": "./dist/transportr.d.ts",
25
26
  "exports": {
26
27
  ".": {
27
28
  "types": "./dist/transportr.d.ts",
@@ -53,8 +54,8 @@
53
54
  "LICENSE"
54
55
  ],
55
56
  "dependencies": {
56
- "@d1g1tal/media-type": "^6.0.4",
57
- "@d1g1tal/subscribr": "^4.1.8",
57
+ "@d1g1tal/media-type": "^6.0.6",
58
+ "@d1g1tal/subscribr": "^4.1.10",
58
59
  "dompurify": "^3.3.3"
59
60
  },
60
61
  "peerDependencies": {
@@ -66,24 +67,24 @@
66
67
  }
67
68
  },
68
69
  "devDependencies": {
69
- "@d1g1tal/tsbuild": "^1.6.0",
70
+ "@d1g1tal/tsbuild": "^1.7.1",
70
71
  "@eslint/eslintrc": "^3.3.5",
71
72
  "@eslint/js": "^10.0.1",
72
- "@types/jsdom": "^28.0.0",
73
+ "@types/jsdom": "^28.0.1",
73
74
  "@types/node": "^25.5.0",
74
- "@typescript-eslint/eslint-plugin": "^8.57.0",
75
- "@typescript-eslint/parser": "^8.57.0",
76
- "@vitest/coverage-v8": "^4.1.0",
77
- "@vitest/ui": "^4.1.0",
78
- "@xmldom/xmldom": "^0.9.8",
79
- "eslint": "^10.0.3",
75
+ "@typescript-eslint/eslint-plugin": "^8.58.0",
76
+ "@typescript-eslint/parser": "^8.58.0",
77
+ "@vitest/coverage-v8": "^4.1.2",
78
+ "@vitest/ui": "^4.1.2",
79
+ "@xmldom/xmldom": "^0.9.9",
80
+ "eslint": "^10.1.0",
80
81
  "eslint-plugin-compat": "^7.0.1",
81
- "jsdom": "^28.1.0",
82
- "eslint-plugin-jsdoc": "^62.8.0",
82
+ "eslint-plugin-jsdoc": "^62.8.1",
83
83
  "globals": "^17.4.0",
84
- "typescript": "^5.9.3",
85
- "typescript-eslint": "^8.57.0",
86
- "vitest": "^4.1.0"
84
+ "jsdom": "^29.0.1",
85
+ "typescript": "^6.0.2",
86
+ "typescript-eslint": "^8.58.0",
87
+ "vitest": "^4.1.2"
87
88
  },
88
89
  "browserslist": [
89
90
  ">0.3% and not dead",