@d1g1tal/transportr 3.3.3 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/BDFNHL2U.js +8 -0
- package/dist/BDFNHL2U.js.map +7 -0
- package/dist/iife/content-type.js +2 -0
- package/dist/iife/request-header.js +2 -0
- package/dist/iife/request-method.js +2 -0
- package/dist/iife/response-header.js +2 -0
- package/dist/iife/transportr.js +888 -727
- package/dist/iife/transportr.js.map +4 -4
- package/dist/transportr.d.ts +97 -5
- package/dist/transportr.js +7 -6
- package/dist/transportr.js.map +3 -3
- package/package.json +17 -16
- package/dist/OP3JQ447.js +0 -8
- package/dist/OP3JQ447.js.map +0 -7
package/dist/transportr.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/utils.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type-parameters.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type-parser.ts", "../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/node_modules/.pnpm/@d1g1tal+collections@2.2.1/node_modules/@d1g1tal/collections/src/set-multi-map.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/src/context-event-handler.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/src/subscription.ts", "../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/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>) {\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 * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tconst defaultValue = compute(key);\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\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]() {\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 };", "/**\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' | 'EVENT_STREAM' | 'NDJSON';\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\tEVENT_STREAM: new MediaType('text/event-stream', charset),\n\tNDJSON: new MediaType('application/x-ndjson', charset)\n} as const;\n\nconst defaultMediaType: string = mediaTypes.JSON.toString();\nconst defaultOrigin: string = globalThis.location?.origin ?? 'http://localhost';\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: Array<number> = [ 408, 413, 429, 500, 502, 503, 504 ];\n\n/** Default HTTP methods allowed to retry (idempotent methods only) */\nconst retryMethods: Array<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, defaultOrigin, requestBodyMethods, RequestCachingPolicy, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, SignalErrors, SignalEvents, timedOut, timeoutEvent, XSRF_COOKIE_NAME, XSRF_HEADER_NAME };\nexport type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];\n", "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 { DOMPurify } from 'dompurify';\nimport type { Json, ResponseHandler, ServerSentEvent } from '@types';\n\n/** Cached promise for lazy DOM + DOMPurify initialization \u2014 resolved once, reused thereafter */\nlet domReady: Promise<void> | undefined;\n/** DOMPurify instance \u2014 set once domReady resolves */\nlet purify: DOMPurify | undefined;\n\n/**\n * Ensures a DOM environment is available (document, DOMParser, DocumentFragment) and\n * initializes DOMPurify. In browser environments the DOM is already present so only\n * DOMPurify is imported. In Node.js jsdom is lazily set up first.\n * @returns A Promise that resolves when the DOM environment and DOMPurify are ready.\n */\nconst ensureDom = (): Promise<void> => {\n\tif (domReady) { return domReady }\n\n\tconst domSetup: Promise<void> = typeof document === 'undefined' || typeof DOMParser === 'undefined' || typeof DocumentFragment === 'undefined' ?\n\t\timport('jsdom').then(({ JSDOM }) => {\n\t\t\tconst { window } = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', { url: 'http://localhost' });\n\n\t\t\tglobalThis.window = window as unknown as Window & typeof globalThis;\n\n\t\t\tObject.assign(globalThis, { document: window.document, DOMParser: window.DOMParser, DocumentFragment: window.DocumentFragment });\n\t\t}).catch(() => {\n\t\t\tdomReady = undefined;\n\t\t\tthrow new Error('jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom');\n\t\t}) : Promise.resolve();\n\n\treturn domReady = domSetup.then(() => import('dompurify')).then(({ default: p }) => { purify = p });\n};\n\n/**\n * Sanitizes the response text and parses it as a DOM Document using DOMParser.\n * @param response The response to parse.\n * @param mimeType The MIME type to use when parsing the document.\n * @returns A Promise that resolves to a parsed Document.\n */\nconst parseSanitizedDocument = async (response: Response, mimeType: DOMParserSupportedType): Promise<Document> => {\n\tawait ensureDom();\n\n\treturn new DOMParser().parseFromString(purify!.sanitize(await response.text()), mimeType);\n};\n\n/**\n * Creates an object URL from the response blob, constructs a Promise with the given executor,\n * and ensures the URL is revoked after the promise settles.\n * @param response The response to create the object URL from.\n * @param executor A function receiving the object URL, resolve, and reject callbacks.\n * @returns A Promise that resolves to the value produced by the executor.\n */\nconst withObjectURL = async <T>(response: Response, executor: (objectURL: string, resolve: (value: T) => void, reject: (reason?: unknown) => void) => void): Promise<T> => {\n\tawait ensureDom();\n\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\ttry {\n\t\treturn new Promise<T>((res, rej) => executor(objectURL, res, rej));\n\t} finally {\n\t\tURL.revokeObjectURL(objectURL);\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> = (response) => {\n\treturn withObjectURL(response, (objectURL, 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/** Resolve the promise once the script has loaded. */\n\t\tscript.onload = () => {\n\t\t\tdocument.head.removeChild(script);\n\t\t\tresolve();\n\t\t};\n\n\t\t/** Reject the promise if the script fails to load. */\n\t\tscript.onerror = () => {\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> = (response) => {\n\treturn withObjectURL(response, (objectURL, resolve, reject) => {\n\t\tconst link = document.createElement('link');\n\t\tObject.assign(link, { href: objectURL, type: 'text/css', rel: 'stylesheet' });\n\n\t\tlink.onload = () => resolve();\n\n\t\t/** Remove the link element and reject the promise if the stylesheet fails to load. */\n\t\tlink.onerror = () => {\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> = (response) => withObjectURL(response, (objectURL, resolve, reject) => {\n\tconst img = new Image();\n\n\timg.onload = () => resolve(img);\n\timg.onerror = () => reject(new Error('Image failed to load'));\n\n\timg.src = objectURL;\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) => parseSanitizedDocument(response, 'application/xml');\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) => parseSanitizedDocument(response, 'text/html');\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\n\treturn document.createRange().createContextualFragment(purify!.sanitize(await response.text()));\n};\n\n/**\n * Handles an HTML fragment response without sanitization.\n * Only available in environments with DOM support.\n *\n * **Security Warning:** DOMPurify is bypassed entirely. Scripts, inline event handlers,\n * and all other content are preserved as-is. Only use with fully trusted same-origin content.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragmentWithScripts: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\n\treturn document.createRange().createContextualFragment(await response.text());\n};\n\n/**\n * Reads delimited segments from a ReadableStream, yielding each segment as a string.\n * Handles buffering, decoding, and automatic reader cancellation on early exit or error.\n * @param body The ReadableStream to read from.\n * @param delimiter The delimiter string that separates segments.\n * @param flushRemaining Whether to yield remaining buffered content when the stream ends.\n * @yields {string} Each delimited segment as a raw string.\n */\nasync function* readDelimited(body: ReadableStream<Uint8Array>, delimiter: string, flushRemaining: boolean): AsyncGenerator<string> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffer = '';\n\n\ttry {\n\t\tfor (;;) {\n\t\t\tlet index: number;\n\t\t\twhile ((index = buffer.indexOf(delimiter)) !== -1) {\n\t\t\t\tyield buffer.slice(0, index);\n\t\t\t\tbuffer = buffer.slice(index + delimiter.length);\n\t\t\t}\n\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) { break }\n\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t}\n\n\t\tif (flushRemaining) {\n\t\t\tconst remaining = (buffer + decoder.decode()).trim();\n\t\t\tif (remaining) { yield remaining }\n\t\t}\n\t} finally {\n\t\tawait reader.cancel();\n\t}\n}\n\n/**\n * Parses a raw SSE event block into a ServerSentEvent object.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * @param rawEvent The raw event text (lines separated by \\n, without the trailing \\n\\n delimiter).\n * @returns A parsed ServerSentEvent, or undefined for empty dispatch events.\n */\nconst parseServerSentEvent = (rawEvent: string): ServerSentEvent | undefined => {\n\tlet event = 'message';\n\tlet id = '';\n\tlet retry: number | undefined;\n\tconst dataLines: string[] = [];\n\n\tconst lines = rawEvent.split('\\n');\n\tfor (let i = 0, length = lines.length; i < length; i++) {\n\t\tconst line = lines[i]!;\n\t\t// comment line\n\t\tif (line.charCodeAt(0) === 58) { continue }\n\n\t\tconst colonIndex = line.indexOf(':');\n\t\tlet field: string;\n\t\tlet value: string;\n\t\tif (colonIndex === -1) {\n\t\t\tfield = line;\n\t\t\tvalue = '';\n\t\t} else {\n\t\t\tfield = line.slice(0, colonIndex);\n\t\t\t// strip single leading space after colon per spec\n\t\t\tvalue = line.charCodeAt(colonIndex + 1) === 32\t? line.slice(colonIndex + 2)\t: line.slice(colonIndex + 1);\n\t\t}\n\n\t\tswitch (field) {\n\t\t\tcase 'event': event = value; break;\n\t\t\tcase 'data': dataLines.push(value); break;\n\t\t\tcase 'id': id = value; break;\n\t\t\tcase 'retry': {\n\t\t\t\tconst n = parseInt(value, 10);\n\t\t\t\tif (!isNaN(n)) { retry = n }\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (dataLines.length > 0 || event !== 'message') ? { event, data: dataLines.join('\\n'), id, retry } : undefined;\n};\n\n/**\n * Parses a text/event-stream response into an AsyncIterable of ServerSentEvent objects.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed ServerSentEvent objects.\n */\nconst handleEventStream = (response: Response): AsyncIterable<ServerSentEvent> => ({\n\t/** @yields {ServerSentEvent} Parsed ServerSentEvent objects from the stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const rawEvent of readDelimited(response.body!, '\\n\\n', false)) {\n\t\t\tif (!rawEvent) { continue }\n\t\t\tconst sse = parseServerSentEvent(rawEvent);\n\t\t\tif (sse) { yield sse }\n\t\t}\n\t}\n});\n\n/**\n * Parses an NDJSON (Newline Delimited JSON) response into an AsyncIterable of typed JSON values.\n * Each line of the response is parsed as an independent JSON object.\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed JSON values.\n */\nconst handleNdjsonStream = <T = Json>(response: Response): AsyncIterable<T> => ({\n\t/** @yields {T} Parsed JSON values from the NDJSON stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const line of readDelimited(response.body!, '\\n', true)) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (trimmed) { yield JSON.parse(trimmed) as T }\n\t\t}\n\t}\n});\n\nexport {\n\thandleText,\n\thandleScript,\n\thandleCss,\n\thandleJson,\n\thandleBlob,\n\thandleImage,\n\thandleBuffer,\n\thandleReadableStream,\n\thandleXml,\n\thandleHtml,\n\thandleHtmlFragment,\n\thandleHtmlFragmentWithScripts,\n\thandleEventStream,\n\thandleNdjsonStream\n};\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): body is Exclude<BodyInit, string> =>\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 ArrayBuffer (cross-realm safe).\n * @param value The value to check.\n * @returns True if value is an ArrayBuffer, with type narrowing.\n */\nexport const isArrayBuffer = (value: unknown): value is ArrayBuffer =>\n\tvalue instanceof ArrayBuffer || Object.prototype.toString.call(value) === '[object ArrayBuffer]';\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<string, unknown>[]): Record<string, 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<string, 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}\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, handleHtmlFragmentWithScripts, handleEventStream, handleNdjsonStream } from './response-handlers';\nimport { isRequestBodyMethod, isRawBody, getCookieValue, isString, isArrayBuffer, isObject, objectMerge, serialize } from './utils';\nimport { RequestCachingPolicy, RequestEvent, SignalErrors, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, defaultOrigin, endsWithSlashRegEx, internalServerError, mediaTypes, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut } from './constants';\nimport type {\tRequestBody, RequestBodyMethod, RequestOptions, ResponseBody, RequestEventHandler, SearchParameters, EventRegistration, ResponseHandler, RequestHeaders, TypedResponse, Json, Entries, HookOptions, HttpErrorOptions, NormalizedRetryOptions, PublishOptions, RetryOptions, RequestTiming, XsrfOptions, ServerSentEvent, RequestEventDataMap, TypedRequestEventHandler, Result } 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/** Cached config for the common \"no retry\" case (retry === undefined) */\n\tprivate static readonly noRetryConfig: NormalizedRetryOptions = { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor };\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 = defaultOrigin, options: RequestOptions = {}) {\n\t\tif (isObject(url)) { [ url, options ] = [ defaultOrigin, 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 Mode */\n\tstatic readonly RequestMode = {\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 Priority */\n\tstatic readonly RequestPriority = {\n\t\tHIGH: 'high',\n\t\tLOW: 'low',\n\t\tAUTO: 'auto'\n\t} as const;\n\n\t/** Redirect Policy */\n\tstatic readonly RedirectPolicy = {\n\t\tERROR: 'error',\n\t\tFOLLOW: 'follow',\n\t\tMANUAL: 'manual'\n\t} as const;\n\n\t/** Referrer Policy */\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 Event */\n\tstatic readonly RequestEvent: 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.RequestMode.CORS,\n\t\tpriority: Transportr.RequestPriority.AUTO,\n\t\tredirect: Transportr.RedirectPolicy.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 with typed data.\n\t *\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler with typed data parameter.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\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 * Executes multiple requests concurrently and resolves when all complete.\n\t * @param requests An array of promises from Transportr request methods.\n\t * @returns A promise resolving to an array of all results.\n\t */\n\tstatic all<T extends readonly Promise<unknown>[]>(requests: T): Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }> {\n\t\treturn Promise.all(requests) as Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }>;\n\t}\n\n\t/**\n\t * Races multiple requests concurrently. The first to settle wins; all others are aborted.\n\t * Each factory receives an AbortSignal that the caller should pass to the request options.\n\t * @template T The expected result type.\n\t * @param requests An array of functions that accept an AbortSignal and return a promise.\n\t * @returns A promise resolving to the first settled result.\n\t * @example\n\t * ```typescript\n\t * const result = await Transportr.race([\n\t * (signal) => api.getJson('/primary', { signal }),\n\t * (signal) => api.getJson('/fallback', { signal })\n\t * ]);\n\t * ```\n\t */\n\tstatic async race<T>(requests: ReadonlyArray<(signal: AbortSignal) => Promise<T>>): Promise<T> {\n\t\tconst controllers: AbortController[] = [];\n\n\t\tconst promises = new Array<Promise<T>>(requests.length);\n\t\tfor (let i = 0; i < requests.length; i++) {\n\t\t\tconst controller = new AbortController();\n\t\t\tcontrollers.push(controller);\n\t\t\tpromises[i] = requests[i]!(controller.signal);\n\t\t}\n\n\t\ttry {\n\t\t\treturn await Promise.race(promises);\n\t\t} finally {\n\t\t\tfor (const controller_1 of controllers) { controller_1.abort() }\n\t\t}\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 with typed data.\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<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\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 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 * Updates the instance's default options after construction.\n\t * Mirrors what the constructor accepts: headers and searchParams are merged onto\n\t * the existing defaults; all other options overwrite the current value; hooks\n\t * are appended via {@link addHooks}.\n\t *\n\t * @param options The options to apply. Accepts the same shape as the constructor.\n\t * @returns This instance for method chaining.\n\t */\n\tconfigure({ headers, searchParams, hooks, ...options }: RequestOptions): this {\n\t\tif (headers) { Transportr.mergeHeaders(this._options.headers as Headers, headers) }\n\t\tif (searchParams) { Transportr.mergeSearchParams(this._options.searchParams as URLSearchParams, searchParams) }\n\t\tif (Object.keys(options).length > 0) { Object.assign(this._options, options) }\n\t\tif (hooks) { this.addHooks(hooks) }\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/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 | Result<T | undefined>> {\n\t\treturn this._get<T>(path, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('POST', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PUT', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PATCH', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('DELETE', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 | Result<T | undefined>> {\n\t\treturn this.execute<T>(path, options, { method: 'HEAD' });\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\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 | Result<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 unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet response: Response = await this._request(path, requestConfig);\n\n\t\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\t\tif (result) { response = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst allowHeader = response.headers.get('allow');\n\t\t\tlet allowedMethods: string[] | undefined;\n\t\t\tif (allowHeader) {\n\t\t\t\tconst parts = allowHeader.split(',');\n\t\t\t\tallowedMethods = new Array(parts.length);\n\t\t\t\tfor (let i = 0, length = parts.length; i < length; i++) {\n\t\t\t\t\tallowedMethods[i] = parts[i]!.trim();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });\n\n\t\t\treturn unwrap ? allowedMethods : [ true, allowedMethods ];\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\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> | Result<TypedResponse<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, {});\n\t\tconst unwrap = requestConfig.requestOptions.unwrap !== false;\n\n\t\ttry {\n\t\t\tconst response = await this._request<T>(path, requestConfig);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });\n\n\t\t\treturn unwrap ? response : [true, response] as Result<TypedResponse<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<TypedResponse<T>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\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 | Result<Json | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\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 | Result<Document | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<Document | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | Element | null | undefined>>;\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 | Result<Document | Element | null | undefined>> {\n\t\tconst doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);\n\t\tif (Array.isArray(doc)) return doc;\n\t\treturn selector && doc ? doc.querySelector(selector) : doc;\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<DocumentFragment | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: RequestOptions & { unwrap: false }): Promise<Result<DocumentFragment | Element | null | undefined>>;\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 | Result<DocumentFragment | Element | null | undefined>> {\n\t\tconst allowScripts = (isObject(path) ? path : options)?.allowScripts === true;\n\t\tconst fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, allowScripts ? handleHtmlFragmentWithScripts : handleHtmlFragment);\n\t\tif (Array.isArray(fragment)) return fragment;\n\t\treturn selector && fragment ? fragment.querySelector(selector) : fragment;\n\t}\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\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 | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\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 | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\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 | Result<Blob | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBlob);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetImage(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<HTMLImageElement | undefined>>;\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 | Result<HTMLImageElement | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'image/*' } }, handleImage);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\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 | Result<ArrayBuffer | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBuffer);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\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 | Result<ReadableStream<Uint8Array> | null | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleReadableStream);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/**\n\t * Opens a Server-Sent Events stream and returns an AsyncIterable of typed events.\n\t * Follows the EventStream specification for parsing event, data, id, and retry fields.\n\t * Iteration ends when the server closes the stream or the request is aborted.\n\t *\n\t * @async\n\t * @param path The path to the SSE endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed ServerSentEvent objects.\n\t * @example\n\t * ```typescript\n\t * for await (const event of api.getEventStream('/chat/completions', { body: { prompt } })) {\n\t * console.log(event.event, event.data);\n\t * }\n\t * ```\n\t */\n\tasync getEventStream(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<ServerSentEvent> | Result<AsyncIterable<ServerSentEvent>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: options?.body ? 'POST' : 'GET', headers: { accept: `${mediaTypes.EVENT_STREAM}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tlet afterResponse: Response = response;\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(afterResponse, requestOptions);\n\t\t\t\t\tif (result) { afterResponse = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleEventStream(afterResponse);\n\t\t\treturn unwrap ? stream : [true, stream] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/**\n\t * Opens an NDJSON (Newline Delimited JSON) stream and returns an AsyncIterable of typed JSON values.\n\t * Each line is independently parsed as JSON, making it suitable for streaming large datasets\n\t * or real-time JSON feeds.\n\t *\n\t * @async\n\t * @template T The expected type of each JSON line (defaults to Json).\n\t * @param path The path to the NDJSON endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed JSON values.\n\t * @example\n\t * ```typescript\n\t * for await (const user of api.getJsonStream<User>('/users/export')) {\n\t * processUser(user);\n\t * }\n\t * ```\n\t */\n\tasync getJsonStream<T = Json>(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<T> | Result<AsyncIterable<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: 'GET', headers: { accept: `${mediaTypes.NDJSON}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tlet afterResponse: Response = response;\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(afterResponse, requestOptions);\n\t\t\t\t\tif (result) { afterResponse = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleNdjsonStream<T>(afterResponse);\n\t\t\treturn unwrap ? stream : [ true, stream ] as Result<AsyncIterable<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [ false, error as HttpError ] as Result<AsyncIterable<T>>;\n\t\t\tthrow error;\n\t\t}\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 | Result<T | undefined>> {\n\t\toptions.method = 'GET';\n\t\toptions.body = undefined;\n\t\treturn this.execute<T>(path, userOptions, options, 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\tlet dedupeKey: string | undefined;\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\tdedupeKey = `${method}:${url.href}`;\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 originalBody = requestOptions.body;\n\t\t\tconst onUploadProgress = requestOptions.onUploadProgress;\n\n\t\t\t/**\n\t\t\t * Wraps the request body with a progress-tracking TransformStream when onUploadProgress is set.\n\t\t\t * Re-creates the stream from the original body on each call so retries get a fresh stream.\n\t\t\t */\n\t\t\tconst wrapUploadBody = async (): Promise<void> => {\n\t\t\t\tif (!onUploadProgress || originalBody == null) { return }\n\n\t\t\t\tlet bytes: Uint8Array | null = null;\n\n\t\t\t\tif (typeof originalBody === 'string') {\n\t\t\t\t\tbytes = new TextEncoder().encode(originalBody);\n\t\t\t\t} else if (originalBody instanceof Blob) {\n\t\t\t\t\tbytes = new Uint8Array(await originalBody.arrayBuffer());\n\t\t\t\t} else if (isArrayBuffer(originalBody)) {\n\t\t\t\t\tbytes = new Uint8Array(originalBody);\n\t\t\t\t} else if (ArrayBuffer.isView(originalBody)) {\n\t\t\t\t\tbytes = new Uint8Array(originalBody.buffer, originalBody.byteOffset, originalBody.byteLength);\n\t\t\t\t} else if (!(originalBody instanceof ReadableStream)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst total = bytes ? bytes.byteLength : null;\n\t\t\t\tconst readable: ReadableStream<Uint8Array> = bytes\n\t\t\t\t\t? new ReadableStream<Uint8Array>({\n\t\t\t\t\t\t/** @param controller The stream controller. */\n\t\t\t\t\t\tstart(controller) { controller.enqueue(bytes); controller.close() }\n\t\t\t\t\t})\n\t\t\t\t\t: originalBody as ReadableStream<Uint8Array>;\n\n\t\t\t\tlet loaded = 0;\n\t\t\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t\t\t/**\n\t\t\t\t\t * Tracks bytes and invokes upload progress callback.\n\t\t\t\t\t * @param chunk The data chunk.\n\t\t\t\t\t * @param controller The transform controller.\n\t\t\t\t\t */\n\t\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\t\t\tonUploadProgress({\n\t\t\t\t\t\t\tloaded,\n\t\t\t\t\t\t\ttotal,\n\t\t\t\t\t\t\tpercentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\trequestOptions.body = readable.pipeThrough(transform);\n\t\t\t\tObject.assign(requestOptions, { duplex: 'half' });\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Performs the fetch with upload progress wrapping and retry logic.\n\t\t\t * @returns 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\tawait wrapUploadBody();\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\t/**\n\t\t\t * Wraps the response body with a progress-tracking TransformStream when onDownloadProgress is set.\n\t\t\t * @param response The response to potentially wrap.\n\t\t\t * @returns The original response or a new response with progress tracking.\n\t\t\t */\n\t\t\tconst wrapProgress = (response: TypedResponse<T>): TypedResponse<T> => {\n\t\t\t\tconst onDownloadProgress = requestOptions.onDownloadProgress;\n\t\t\t\tif (!onDownloadProgress || !response.body) return response;\n\n\t\t\t\tconst contentLength = response.headers.get('content-length');\n\t\t\t\tconst total = contentLength ? parseInt(contentLength, 10) : null;\n\t\t\t\tlet loaded = 0;\n\n\t\t\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t\t\t/**\n\t\t\t\t\t * Tracks bytes and invokes progress callback.\n\t\t\t\t\t * @param chunk The data chunk.\n\t\t\t\t\t * @param controller The transform controller.\n\t\t\t\t\t */\n\t\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\t\t\tonDownloadProgress({ loaded, total, percentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null });\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn new Response(response.body.pipeThrough(transform), { status: response.status, statusText: response.statusText, headers: response.headers }) as TypedResponse<T>;\n\t\t\t};\n\n\t\t\tif (canDedupe) {\n\t\t\t\tconst typedResponse = doFetch();\n\t\t\t\tTransportr.inflightRequests.set(dedupeKey!, typedResponse);\n\t\t\t\ttry {\n\t\t\t\t\treturn wrapProgress(await typedResponse);\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 wrapProgress(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\tthis.publish({ name: RequestEvent.COMPLETE, data: { timing: getTiming() }, 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 Transportr.noRetryConfig }\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\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * Shared implementation for body-accepting HTTP methods (POST, PUT, PATCH, DELETE).\n\t * @param method The HTTP method to use.\n\t * @param path The request path, or the request body when called without a path.\n\t * @param body The request body, or options when called without a path.\n\t * @param options Additional request options.\n\t * @param responseHandler Optional response handler override.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tprivate executeBodyMethod<T extends ResponseBody>(method: RequestBodyMethod, path: string | RequestBody | undefined, body?: RequestBody | RequestOptions, options?: RequestOptions, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined | Result<T | undefined>> {\n\t\tconst [ resolvedPath, resolvedBody, resolvedOptions ] = isString(path) ? [ path, body as RequestBody, options ] : [ undefined, path, body as RequestOptions ];\n\n\t\treturn this.execute<T>(resolvedPath, Object.assign(resolvedOptions ?? {}, { body: resolvedBody, method }), {}, responseHandler);\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 | Result<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 unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\n\t\t\tfor (const hooks of [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ]) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet response = await this._request<T>(path, requestConfig);\n\n\t\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\t\tfor (const hooks of [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ]) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\t\tif (result) { response = result as TypedResponse<T> }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tif (!responseHandler && response.status !== 204) {\n\t\t\t\t\tresponseHandler = this.getResponseHandler<T>(response.headers.get('content-type'));\n\t\t\t\t}\n\n\t\t\t\tconst data = await responseHandler?.(response);\n\n\t\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });\n\n\t\t\t\treturn unwrap ? data : [ true, data ];\n\t\t\t} catch (cause) {\n\t\t\t\tthrow await this.handleError(path as string, response, { cause: cause as Error }, requestOptions);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\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() to avoid intermediate tuple array\n\t\t\t\tconst keys = Object.keys(headers);\n\t\t\t\tfor (let i = 0, length = keys.length; i < length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = (headers as Record<string, string | undefined>)[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, 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, typeof value === 'string' ? value : 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// Native copy constructors for Headers/URLSearchParams skip JS-level merge of instance defaults\n\t\tconst requestOptions = {\n\t\t\t...this._options,\n\t\t\t...userOptions,\n\t\t\t...options,\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\tObject.assign(requestOptions, { body: userBody });\n\t\t\t\trequestOptions.headers.delete('content-type');\n\t\t\t} else {\n\t\t\t\tconst instanceBody = this._options.body;\n\t\t\t\tconst body = isObject<Record<string, unknown>>(instanceBody) && isObject<Record<string, unknown>>(userBody)\t? objectMerge(instanceBody, userBody)\t: (userBody !== undefined ? userBody : instanceBody);\n\t\t\t\tconst isJson = requestOptions.headers.get('content-type')?.includes('json') ?? false;\n\t\t\t\tObject.assign(requestOptions, { body: isJson && isObject(body) ? serialize(body) : body });\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 { cookieName, headerName }: XsrfOptions = typeof xsrf === 'object' ? xsrf : {};\n\t\t\tconst token = getCookieValue(cookieName ?? XSRF_COOKIE_NAME);\n\t\t\tif (token) { requestOptions.headers.set(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 entry when cache exceeds limit to prevent unbounded growth\n\t\t\tif (Transportr.mediaTypeCache.size >= 100) {\n\t\t\t\tTransportr.mediaTypeCache.delete(Transportr.mediaTypeCache.keys().next().value!);\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\tfor (const hooks of [ Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError ]) {\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,GAAN,MAAMC,WAA4B,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,GAAoB,QAAQE,EAAMC,CAAK,EAC3C,MAAM,IAAI,MAAM,4CAA4CD,CAAI,IAAIC,CAAK,EAAE,EAG5E,OAAA,MAAM,IAAID,EAAK,YAAY,EAAGC,CAAK,EAE5B,IACR,CAQS,OAAOD,EAAuB,CACtC,OAAO,MAAM,OAAOA,EAAK,YAAY,CAAC,CACvC,CAOS,UAAmB,CAC3B,OAAO,MAAM,KAAK,IAAI,EAAE,IAAI,CAAC,CAAEA,EAAMC,CAAM,IAAM,IAAID,CAAI,IAAI,CAACC,GAAS,CAACP,EAAoB,KAAKO,CAAK,EAAI,IAAI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,EAA6D,CAC/G,GAAI,CAACA,EAAe,OAEpB,IAAM5B,EAAYL,EAAW,oBAAoBiC,CAAW,EAE5D,GAAK5B,GAEL,OAAW,CAAE4B,EAAamC,CAAgB,IAAKpE,EAAW,oBACzD,GAAIK,EAAU,QAAQ4B,CAAW,EAAK,OAAOmC,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", "defaultValue", "compute", "iterator", "values", "deleted", "ContextEventHandler", "context", "eventHandler", "event", "data", "Subscription", "eventName", "contextEventHandler", "Subscribr", "u", "errorHandler", "options", "originalHandler", "subscription", "contextEventHandlers", "removed", "error", "HttpError", "status", "message", "cause", "entity", "url", "method", "timing", "ResponseStatus", "code", "text", "charset", "
|
|
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>) {\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 * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tconst defaultValue = compute(key);\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\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]() {\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 };", "/**\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' | 'EVENT_STREAM' | 'NDJSON';\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\tEVENT_STREAM: new MediaType('text/event-stream', charset),\n\tNDJSON: new MediaType('application/x-ndjson', charset)\n} as const;\n\nconst defaultMediaType: string = mediaTypes.JSON.toString();\nconst defaultOrigin: string = globalThis.location?.origin ?? 'http://localhost';\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: Array<number> = [ 408, 413, 429, 500, 502, 503, 504 ];\n\n/** Default HTTP methods allowed to retry (idempotent methods only) */\nconst retryMethods: Array<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, defaultOrigin, requestBodyMethods, RequestCachingPolicy, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, SignalErrors, SignalEvents, timedOut, timeoutEvent, XSRF_COOKIE_NAME, XSRF_HEADER_NAME };\nexport type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];\n", "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\t/** Lazily-allocated. Tracks user-attached listeners for cleanup. */\n\tprivate events: Map<EventListener, string> | undefined;\n\t/** True when the signal is a composite (AbortSignal.any wrapper) \u2014 only then must we remove the internal abort listener. */\n\tprivate readonly hasComposite: boolean;\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 hasExternal = signal != null;\n\t\tconst hasTimeout = timeout !== Infinity;\n\n\t\t// Fast path: no external signal and no timeout \u2014 reuse the internal controller's signal directly.\n\t\t// Avoids AbortSignal.any allocation and the abort listener (only required for timeout dispatch).\n\t\tif (!hasExternal && !hasTimeout) {\n\t\t\tthis.abortSignal = this.abortController.signal;\n\t\t\tthis.hasComposite = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst signals: AbortSignal[] = [ this.abortController.signal ];\n\t\tif (hasExternal) { signals.push(signal) }\n\t\tif (hasTimeout) { signals.push(AbortSignal.timeout(timeout)) }\n\n\t\tthis.abortSignal = AbortSignal.any(signals);\n\t\tthis.hasComposite = true;\n\t\t// Only register the abort listener when a timeout is in play (it dispatches the synthetic timeout event).\n\t\tif (hasTimeout) {\n\t\t\tthis.abortSignal.addEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\t\t}\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\t// Only remove the internal abort listener if it was actually registered (composite signals with a timeout).\n\t\tif (this.hasComposite) {\n\t\t\tthis.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\t\t}\n\n\t\tconst events = this.events;\n\t\tif (events !== undefined) {\n\t\t\tfor (const [ eventListener, type ] of events) {\n\t\t\t\tthis.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);\n\t\t\t}\n\t\t\tevents.clear();\n\t\t}\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\t(this.events ??= new Map()).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}\n", "import type { DOMPurify } from 'dompurify';\nimport type { Json, ResponseHandler, ServerSentEvent } from '@types';\n\n/** Cached promise for lazy DOM + DOMPurify initialization \u2014 resolved once, reused thereafter */\nlet domReady: Promise<void> | undefined;\n/** DOMPurify instance \u2014 set once domReady resolves */\nlet purify: DOMPurify | undefined;\n\n/**\n * Ensures a DOM environment is available (document, DOMParser, DocumentFragment) and\n * initializes DOMPurify. In browser environments the DOM is already present so only\n * DOMPurify is imported. In Node.js jsdom is lazily set up first.\n * @returns A Promise that resolves when the DOM environment and DOMPurify are ready.\n */\nconst ensureDom = (): Promise<void> => {\n\tif (domReady) { return domReady }\n\n\tconst domSetup: Promise<void> = typeof document === 'undefined' || typeof DOMParser === 'undefined' || typeof DocumentFragment === 'undefined' ?\n\t\timport('jsdom').then(({ JSDOM }) => {\n\t\t\tconst { window } = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', { url: 'http://localhost' });\n\n\t\t\tglobalThis.window = window as unknown as Window & typeof globalThis;\n\n\t\t\tObject.assign(globalThis, { document: window.document, DOMParser: window.DOMParser, DocumentFragment: window.DocumentFragment });\n\t\t}).catch(() => {\n\t\t\tdomReady = undefined;\n\t\t\tthrow new Error('jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom');\n\t\t}) : Promise.resolve();\n\n\treturn domReady = domSetup.then(() => import('dompurify')).then(({ default: p }) => { purify = p });\n};\n\n/**\n * Sanitizes the response text and parses it as a DOM Document using DOMParser.\n * @param response The response to parse.\n * @param mimeType The MIME type to use when parsing the document.\n * @returns A Promise that resolves to a parsed Document.\n */\nconst parseSanitizedDocument = async (response: Response, mimeType: DOMParserSupportedType): Promise<Document> => {\n\tawait ensureDom();\n\n\treturn new DOMParser().parseFromString(purify!.sanitize(await response.text()), mimeType);\n};\n\n/**\n * Creates an object URL from the response blob, constructs a Promise with the given executor,\n * and ensures the URL is revoked after the promise settles.\n * @param response The response to create the object URL from.\n * @param executor A function receiving the object URL, resolve, and reject callbacks.\n * @returns A Promise that resolves to the value produced by the executor.\n */\nconst withObjectURL = async <T>(response: Response, executor: (objectURL: string, resolve: (value: T) => void, reject: (reason?: unknown) => void) => void): Promise<T> => {\n\tawait ensureDom();\n\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\ttry {\n\t\treturn new Promise<T>((res, rej) => executor(objectURL, res, rej));\n\t} finally {\n\t\tURL.revokeObjectURL(objectURL);\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> = (response) => 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> = (response) => {\n\treturn withObjectURL(response, (objectURL, 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/** Resolve the promise once the script has loaded. */\n\t\tscript.onload = () => {\n\t\t\tdocument.head.removeChild(script);\n\t\t\tresolve();\n\t\t};\n\n\t\t/** Reject the promise if the script fails to load. */\n\t\tscript.onerror = () => {\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> = (response) => {\n\treturn withObjectURL(response, (objectURL, resolve, reject) => {\n\t\tconst link = document.createElement('link');\n\t\tObject.assign(link, { href: objectURL, type: 'text/css', rel: 'stylesheet' });\n\n\t\tlink.onload = () => resolve();\n\n\t\t/** Remove the link element and reject the promise if the stylesheet fails to load. */\n\t\tlink.onerror = () => {\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> = (response) => response.json() as Promise<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> = (response) => 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> = (response) => withObjectURL(response, (objectURL, resolve, reject) => {\n\tconst img = new Image();\n\n\timg.onload = () => resolve(img);\n\timg.onerror = () => reject(new Error('Image failed to load'));\n\n\timg.src = objectURL;\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> = (response) => 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> = (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) => parseSanitizedDocument(response, 'application/xml');\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) => parseSanitizedDocument(response, 'text/html');\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\n\treturn document.createRange().createContextualFragment(purify!.sanitize(await response.text()));\n};\n\n/**\n * Handles an HTML fragment response without sanitization.\n * Only available in environments with DOM support.\n *\n * **Security Warning:** DOMPurify is bypassed entirely. Scripts, inline event handlers,\n * and all other content are preserved as-is. Only use with fully trusted same-origin content.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragmentWithScripts: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\n\treturn document.createRange().createContextualFragment(await response.text());\n};\n\n/**\n * Reads delimited segments from a ReadableStream, yielding each segment as a string.\n * Handles buffering, decoding, and automatic reader cancellation on early exit or error.\n * @param body The ReadableStream to read from.\n * @param delimiter The delimiter string that separates segments.\n * @param flushRemaining Whether to yield remaining buffered content when the stream ends.\n * @yields {string} Each delimited segment as a raw string.\n */\nasync function* readDelimited(body: ReadableStream<Uint8Array>, delimiter: string, flushRemaining: boolean): AsyncGenerator<string> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tconst delimLength = delimiter.length;\n\tlet buffer = '';\n\tlet cursor = 0;\n\n\ttry {\n\t\tfor (;;) {\n\t\t\tlet index: number;\n\t\t\twhile ((index = buffer.indexOf(delimiter, cursor)) !== -1) {\n\t\t\t\tyield buffer.slice(cursor, index);\n\t\t\t\tcursor = index + delimLength;\n\t\t\t}\n\n\t\t\t// Compact the buffer when the unread region is small relative to the consumed prefix.\n\t\t\tif (cursor > 0 && cursor >= buffer.length - cursor) {\n\t\t\t\tbuffer = cursor < buffer.length ? buffer.slice(cursor) : '';\n\t\t\t\tcursor = 0;\n\t\t\t}\n\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) { break }\n\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t}\n\n\t\tif (flushRemaining) {\n\t\t\tconst tail = (cursor < buffer.length ? buffer.slice(cursor) : '') + decoder.decode();\n\t\t\tconst remaining = tail.trim();\n\t\t\tif (remaining) { yield remaining }\n\t\t}\n\t} finally {\n\t\tawait reader.cancel();\n\t}\n}\n\n/**\n * Parses a raw SSE event block into a ServerSentEvent object.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * @param rawEvent The raw event text (lines separated by \\n, without the trailing \\n\\n delimiter).\n * @returns A parsed ServerSentEvent, or undefined for empty dispatch events.\n */\nconst parseServerSentEvent = (rawEvent: string): ServerSentEvent | undefined => {\n\tlet event = 'message';\n\tlet id = '';\n\tlet retry: number | undefined;\n\t// Lazy data accumulation: most SSE events contain exactly one `data:` line, so avoid the array allocation in that case.\n\tlet firstData: string | undefined;\n\tlet extraData: string[] | undefined;\n\n\tconst lines = rawEvent.split('\\n');\n\tfor (let i = 0, length = lines.length; i < length; i++) {\n\t\tconst line = lines[i]!;\n\t\t// comment line\n\t\tif (line.charCodeAt(0) === 58) { continue }\n\n\t\tconst colonIndex = line.indexOf(':');\n\t\tlet field: string;\n\t\tlet value: string;\n\t\tif (colonIndex === -1) {\n\t\t\tfield = line;\n\t\t\tvalue = '';\n\t\t} else {\n\t\t\tfield = line.slice(0, colonIndex);\n\t\t\t// strip single leading space after colon per spec\n\t\t\tvalue = line.charCodeAt(colonIndex + 1) === 32\t? line.slice(colonIndex + 2)\t: line.slice(colonIndex + 1);\n\t\t}\n\n\t\tswitch (field) {\n\t\t\tcase 'event': event = value; break;\n\t\t\tcase 'data':\n\t\t\t\tif (firstData === undefined) {\n\t\t\t\t\tfirstData = value;\n\t\t\t\t} else {\n\t\t\t\t\t(extraData ??= []).push(value);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'id': id = value; break;\n\t\t\tcase 'retry': {\n\t\t\t\tconst n = parseInt(value, 10);\n\t\t\t\tif (!isNaN(n)) { retry = n }\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (firstData === undefined && event === 'message') { return undefined }\n\n\tconst data = extraData === undefined\n\t\t? (firstData ?? '')\n\t\t: `${firstData}\\n${extraData.join('\\n')}`;\n\treturn { event, data, id, retry };\n};\n\n/**\n * Parses a text/event-stream response into an AsyncIterable of ServerSentEvent objects.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed ServerSentEvent objects.\n */\nconst handleEventStream = (response: Response): AsyncIterable<ServerSentEvent> => ({\n\t/** @yields {ServerSentEvent} Parsed ServerSentEvent objects from the stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const rawEvent of readDelimited(response.body!, '\\n\\n', false)) {\n\t\t\tif (!rawEvent) { continue }\n\t\t\tconst sse = parseServerSentEvent(rawEvent);\n\t\t\tif (sse) { yield sse }\n\t\t}\n\t}\n});\n\n/**\n * Parses an NDJSON (Newline Delimited JSON) response into an AsyncIterable of typed JSON values.\n * Each line of the response is parsed as an independent JSON object.\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed JSON values.\n */\nconst handleNdjsonStream = <T = Json>(response: Response): AsyncIterable<T> => ({\n\t/** @yields {T} Parsed JSON values from the NDJSON stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const line of readDelimited(response.body!, '\\n', true)) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (trimmed) { yield JSON.parse(trimmed) as T }\n\t\t}\n\t}\n});\n\nexport {\n\thandleText,\n\thandleScript,\n\thandleCss,\n\thandleJson,\n\thandleBlob,\n\thandleImage,\n\thandleBuffer,\n\thandleReadableStream,\n\thandleXml,\n\thandleHtml,\n\thandleHtmlFragment,\n\thandleHtmlFragmentWithScripts,\n\thandleEventStream,\n\thandleNdjsonStream\n};\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): body is Exclude<BodyInit, string> =>\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') { return }\n\tconst cookieStr = document.cookie;\n\tif (!cookieStr) { return }\n\n\tconst prefix = `${name}=`;\n\tconst prefixLength = prefix.length;\n\tconst cookieLength = cookieStr.length;\n\tlet start = 0;\n\n\twhile (start < cookieLength) {\n\t\t// Skip leading whitespace (cookies are separated by '; ').\n\t\twhile (start < cookieLength && cookieStr.charCodeAt(start) === 32) { start++ }\n\n\t\tlet end = cookieStr.indexOf(';', start);\n\t\tif (end === -1) { end = cookieLength }\n\n\t\tif (end - start >= prefixLength && cookieStr.startsWith(prefix, start)) {\n\t\t\treturn decodeURIComponent(cookieStr.slice(start + prefixLength, end));\n\t\t}\n\n\t\tstart = end + 1;\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 ArrayBuffer (cross-realm safe).\n * @param value The value to check.\n * @returns True if value is an ArrayBuffer, with type narrowing.\n */\nexport const isArrayBuffer = (value: unknown): value is ArrayBuffer =>\n\tvalue instanceof ArrayBuffer || Object.prototype.toString.call(value) === '[object ArrayBuffer]';\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<string, unknown>[]): Record<string, 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<string, unknown>;\n\n\tfor (let s = 0, sLength = objects.length; s < sLength; s++) {\n\t\tconst source = objects[s]!;\n\t\tif (!isObject(source)) { return undefined }\n\n\t\tconst keys = Object.keys(source);\n\t\tfor (let i = 0, length = keys.length; i < length; i++) {\n\t\t\tconst property = keys[i]!;\n\t\t\tconst sourceValue = source[property];\n\t\t\tconst targetValue = target[property];\n\t\t\tif (Array.isArray(sourceValue)) {\n\t\t\t\t// Handle arrays \u2014 source values come first, then unique target values.\n\t\t\t\tif (Array.isArray(targetValue)) {\n\t\t\t\t\tconst merged: unknown[] = sourceValue.slice();\n\t\t\t\t\tfor (let j = 0, tLength = (targetValue as unknown[]).length; j < tLength; j++) {\n\t\t\t\t\t\tconst item = (targetValue as unknown[])[j];\n\t\t\t\t\t\tif (!sourceValue.includes(item)) { merged.push(item) }\n\t\t\t\t\t}\n\t\t\t\t\ttarget[property] = merged;\n\t\t\t\t} else {\n\t\t\t\t\ttarget[property] = sourceValue.slice();\n\t\t\t\t}\n\t\t\t} else if (isObject<Record<string, unknown>>(sourceValue)) {\n\t\t\t\t// Handle plain objects using the isObject function \u2014 we already test targetValue.\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}\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, handleHtmlFragmentWithScripts, handleEventStream, handleNdjsonStream } from './response-handlers';\nimport { isRequestBodyMethod, isRawBody, getCookieValue, isString, isArrayBuffer, isObject, objectMerge, serialize } from './utils';\nimport { RequestCachingPolicy, RequestEvent, SignalErrors, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, defaultOrigin, internalServerError, mediaTypes, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut } from './constants';\nimport type {\tRequestBody, RequestBodyMethod, RequestOptions, ResponseBody, RequestEventHandler, SearchParameters, EventRegistration, ResponseHandler, RequestHeaders, TypedResponse, Json, Entries, HookOptions, HttpErrorOptions, NormalizedRetryOptions, PublishOptions, RetryOptions, RequestTiming, XsrfOptions, ServerSentEvent, RequestEventDataMap, TypedRequestEventHandler, Result, BeforeRequestHook, AfterResponseHook, BeforeErrorHook } from '@types';\n\n/** A handler-set for the three lifecycle phases. Used to skip empty hook loops without allocating a transient array per phase. */\ntype HookCount = { beforeRequest: number, afterResponse: number, beforeError: number };\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 _origin: string;\n\t/** Pre-normalized base pathname with any trailing slash stripped \u2014 reused per request to avoid repeated regex/replace work. */\n\tprivate readonly _basePath: string;\n\tprivate readonly _options: RequestOptions;\n\t/** Pre-built Headers template for methods that strip Content-Type (GET/HEAD/OPTIONS/etc.). Cloned per request. Rebuilt by `configure()` when defaults change. */\n\tprivate _noBodyHeadersTemplate: Headers;\n\tprivate readonly subscribr: Subscribr;\n\tprivate readonly hooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\t/** Aggregate count of hooks registered on this instance \u2014 zero phases are skipped without array allocation. */\n\tprivate readonly hookCount: HookCount = { beforeRequest: 0, afterResponse: 0, beforeError: 0 };\n\t/** Per-event subscription counts on this instance \u2014 used to skip publish() entirely when no listeners exist. */\n\tprivate readonly subCounts: Record<string, number> = Object.create(null) as Record<string, number>;\n\tprivate static globalSubscribr = new Subscribr();\n\tprivate static globalHooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\t/** Aggregate count of registered global hooks \u2014 zero means we skip the entire global-hook loop. */\n\tprivate static globalHookCount: HookCount = { beforeRequest: 0, afterResponse: 0, beforeError: 0 };\n\t/** Per-event subscription counts on the global subscribr \u2014 mirrors `subCounts` per instance. */\n\tprivate static globalSubCounts: Record<string, number> = Object.create(null) as Record<string, number>;\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/** Cached config for the common \"no retry\" case (retry === undefined) */\n\tprivate static readonly noRetryConfig: NormalizedRetryOptions = { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor };\n\t/** Memoized normalized retry options keyed by the user-provided RetryOptions object (reference identity). */\n\tprivate static readonly retryConfigCache = new WeakMap<object, NormalizedRetryOptions>();\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\t/** Cache mapping raw response Content-Type header strings to their resolved ResponseHandler (or null when no handler matches). */\n\tprivate static readonly handlerResolutionCache = new Map<string, ResponseHandler<ResponseBody> | null>();\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 = defaultOrigin, options: RequestOptions = {}) {\n\t\tif (isObject(url)) { [ url, options ] = [ defaultOrigin, url ] }\n\n\t\tthis._baseUrl = Transportr.getBaseUrl(url);\n\t\tthis._origin = this._baseUrl.origin;\n\t\t// Normalize once: strip a single trailing '/' so per-request URL building is plain string concatenation.\n\t\tconst basePath = this._baseUrl.pathname;\n\t\tthis._basePath = basePath.length > 0 && basePath.charCodeAt(basePath.length - 1) === 47 ? basePath.slice(0, -1) : basePath;\n\t\tthis._options = Transportr.createOptions(options, Transportr.defaultRequestOptions);\n\t\t// Pre-build a Headers template for methods that drop Content-Type (GET/HEAD/OPTIONS/etc.).\n\t\tthis._noBodyHeadersTemplate = new Headers(this._options.headers);\n\t\tthis._noBodyHeadersTemplate.delete('content-type');\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 Mode */\n\tstatic readonly RequestMode = {\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 Priority */\n\tstatic readonly RequestPriority = {\n\t\tHIGH: 'high',\n\t\tLOW: 'low',\n\t\tAUTO: 'auto'\n\t} as const;\n\n\t/** Redirect Policy */\n\tstatic readonly RedirectPolicy = {\n\t\tERROR: 'error',\n\t\tFOLLOW: 'follow',\n\t\tMANUAL: 'manual'\n\t} as const;\n\n\t/** Referrer Policy */\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 Event */\n\tstatic readonly RequestEvent: 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.RequestMode.CORS,\n\t\tpriority: Transportr.RequestPriority.AUTO,\n\t\tredirect: Transportr.RedirectPolicy.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 with typed data.\n\t *\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler with typed data parameter.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\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\tconst registration = Transportr.globalSubscribr.subscribe(event, handler, context);\n\t\tTransportr.globalSubCounts[event] = (Transportr.globalSubCounts[event] ?? 0) + 1;\n\t\treturn registration;\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\tconst removed = Transportr.globalSubscribr.unsubscribe(eventRegistration);\n\t\tif (removed) {\n\t\t\tconst event = eventRegistration.eventName;\n\t\t\tconst next = (Transportr.globalSubCounts[event] ?? 1) - 1;\n\t\t\tif (next <= 0) { delete Transportr.globalSubCounts[event] } else { Transportr.globalSubCounts[event] = next }\n\t\t}\n\t\treturn removed;\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 * Executes multiple requests concurrently and resolves when all complete.\n\t * @param requests An array of promises from Transportr request methods.\n\t * @returns A promise resolving to an array of all results.\n\t */\n\tstatic all<T extends readonly Promise<unknown>[]>(requests: T): Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }> {\n\t\treturn Promise.all(requests);\n\t}\n\n\t/**\n\t * Races multiple requests concurrently. The first to settle wins; all others are aborted.\n\t * Each factory receives an AbortSignal that the caller should pass to the request options.\n\t * @template T The expected result type.\n\t * @param requests An array of functions that accept an AbortSignal and return a promise.\n\t * @returns A promise resolving to the first settled result.\n\t * @example\n\t * ```typescript\n\t * const result = await Transportr.race([\n\t * (signal) => api.getJson('/primary', { signal }),\n\t * (signal) => api.getJson('/fallback', { signal })\n\t * ]);\n\t * ```\n\t */\n\tstatic async race<T>(requests: ReadonlyArray<(signal: AbortSignal) => Promise<T>>): Promise<T> {\n\t\tconst controllers: AbortController[] = [];\n\n\t\tconst promises = new Array<Promise<T>>(requests.length);\n\t\tfor (let i = 0; i < requests.length; i++) {\n\t\t\tconst controller = new AbortController();\n\t\t\tcontrollers.push(controller);\n\t\t\tpromises[i] = requests[i]!(controller.signal);\n\t\t}\n\n\t\ttry {\n\t\t\treturn await Promise.race(promises);\n\t\t} finally {\n\t\t\tfor (const controller_1 of controllers) { controller_1.abort() }\n\t\t}\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\t// Invalidate the resolution cache so previously cached lookups can pick up the new handler.\n\t\tTransportr.handlerResolutionCache.clear();\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\t\tTransportr.handlerResolutionCache.clear();\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\tconst { beforeRequest, afterResponse, beforeError } = hooks;\n\t\tif (beforeRequest) { Transportr.globalHooks.beforeRequest.push(...beforeRequest); Transportr.globalHookCount.beforeRequest += beforeRequest.length }\n\t\tif (afterResponse) { Transportr.globalHooks.afterResponse.push(...afterResponse); Transportr.globalHookCount.afterResponse += afterResponse.length }\n\t\tif (beforeError) { Transportr.globalHooks.beforeError.push(...beforeError); Transportr.globalHookCount.beforeError += beforeError.length }\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\tTransportr.globalHookCount.beforeRequest = 0;\n\t\tTransportr.globalHookCount.afterResponse = 0;\n\t\tTransportr.globalHookCount.beforeError = 0;\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.globalSubCounts = Object.create(null) as Record<string, number>;\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 with typed data.\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<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\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 An object that can be used to remove the event handler.\n\t */\n\tregister(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\tconst registration = this.subscribr.subscribe(event, handler, context);\n\t\tthis.subCounts[event] = (this.subCounts[event] ?? 0) + 1;\n\t\treturn registration;\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\tconst removed = this.subscribr.unsubscribe(eventRegistration);\n\t\tif (removed) {\n\t\t\tconst event = eventRegistration.eventName;\n\t\t\tconst next = (this.subCounts[event] ?? 1) - 1;\n\t\t\tif (next <= 0) { delete this.subCounts[event] } else { this.subCounts[event] = next }\n\t\t}\n\t\treturn removed;\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\tconst { beforeRequest, afterResponse, beforeError } = hooks;\n\t\tif (beforeRequest) { this.hooks.beforeRequest.push(...beforeRequest); this.hookCount.beforeRequest += beforeRequest.length }\n\t\tif (afterResponse) { this.hooks.afterResponse.push(...afterResponse); this.hookCount.afterResponse += afterResponse.length }\n\t\tif (beforeError) { this.hooks.beforeError.push(...beforeError); this.hookCount.beforeError += beforeError.length }\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\tthis.hookCount.beforeRequest = 0;\n\t\tthis.hookCount.afterResponse = 0;\n\t\tthis.hookCount.beforeError = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Updates the instance's default options after construction.\n\t * Mirrors what the constructor accepts: headers and searchParams are merged onto\n\t * the existing defaults; all other options overwrite the current value; hooks\n\t * are appended via {@link addHooks}.\n\t *\n\t * @param options The options to apply. Accepts the same shape as the constructor.\n\t * @returns This instance for method chaining.\n\t */\n\tconfigure({ headers, searchParams, hooks, ...options }: RequestOptions): this {\n\t\tif (headers) {\n\t\t\tTransportr.mergeHeaders(this._options.headers as Headers, headers);\n\t\t\t// Header defaults changed \u2014 rebuild the no-body Content-Type-stripped template used by the fast path.\n\t\t\tthis._noBodyHeadersTemplate = new Headers(this._options.headers);\n\t\t\tthis._noBodyHeadersTemplate.delete('content-type');\n\t\t}\n\t\tif (searchParams) { Transportr.mergeSearchParams(this._options.searchParams as URLSearchParams, searchParams) }\n\t\t// `options` is a fresh rest object; Object.assign is a no-op if it has no own keys, so skip the count check.\n\t\tObject.assign(this._options, options);\n\t\tif (hooks) { this.addHooks(hooks) }\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\tfor (const k in this.subCounts) { delete this.subCounts[k] }\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 | Result<T | undefined>> {\n\t\treturn this._get<T>(path, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('POST', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PUT', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PATCH', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 body The body of the request.\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 | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('DELETE', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\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 | Result<T | undefined>> {\n\t\treturn this.execute<T>(path, options, { method: 'HEAD' });\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\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 | Result<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 unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\t\tconst url = Transportr.createUrl(this, path, requestOptions.searchParams);\n\t\t\tawait this.runBeforeRequestHooks(requestOptions, url, path, requestHooks?.beforeRequest);\n\n\t\t\tlet response: Response = await this._request(path, requestConfig);\n\n\t\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\t\tresponse = await this.runAfterResponseHooks(response, requestOptions, requestHooks?.afterResponse);\n\n\t\t\tconst allowHeader = response.headers.get('allow');\n\t\t\tlet allowedMethods: string[] | undefined;\n\t\t\tif (allowHeader) {\n\t\t\t\tconst parts = allowHeader.split(',');\n\t\t\t\tallowedMethods = new Array(parts.length);\n\t\t\t\tfor (let i = 0, length = parts.length; i < length; i++) {\n\t\t\t\t\tallowedMethods[i] = parts[i]!.trim();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });\n\n\t\t\treturn unwrap ? allowedMethods : [ true, allowedMethods ];\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\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> | Result<TypedResponse<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, {});\n\t\tconst unwrap = requestConfig.requestOptions.unwrap !== false;\n\n\t\ttry {\n\t\t\tconst response = await this._request<T>(path, requestConfig);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });\n\n\t\t\treturn unwrap ? response : [true, response] as Result<TypedResponse<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<TypedResponse<T>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\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 | Result<Json | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\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 | Result<Document | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<Document | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | Element | null | undefined>>;\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 | Result<Document | Element | null | undefined>> {\n\t\tconst doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);\n\t\tif (Array.isArray(doc)) return doc;\n\t\treturn selector && doc ? doc.querySelector(selector) : doc;\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<DocumentFragment | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: RequestOptions & { unwrap: false }): Promise<Result<DocumentFragment | Element | null | undefined>>;\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 | Result<DocumentFragment | Element | null | undefined>> {\n\t\tconst allowScripts = (isObject(path) ? path : options)?.allowScripts === true;\n\t\tconst fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, allowScripts ? handleHtmlFragmentWithScripts : handleHtmlFragment);\n\t\tif (Array.isArray(fragment)) return fragment;\n\t\treturn selector && fragment ? fragment.querySelector(selector) : fragment;\n\t}\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\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 | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\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 | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\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 | Result<Blob | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBlob);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetImage(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<HTMLImageElement | undefined>>;\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 | Result<HTMLImageElement | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'image/*' } }, handleImage);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\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 | Result<ArrayBuffer | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBuffer);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\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 | Result<ReadableStream<Uint8Array> | null | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleReadableStream);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/**\n\t * Opens a Server-Sent Events stream and returns an AsyncIterable of typed events.\n\t * Follows the EventStream specification for parsing event, data, id, and retry fields.\n\t * Iteration ends when the server closes the stream or the request is aborted.\n\t *\n\t * @async\n\t * @param path The path to the SSE endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed ServerSentEvent objects.\n\t * @example\n\t * ```typescript\n\t * for await (const event of api.getEventStream('/chat/completions', { body: { prompt } })) {\n\t * console.log(event.event, event.data);\n\t * }\n\t * ```\n\t */\n\tasync getEventStream(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<ServerSentEvent> | Result<AsyncIterable<ServerSentEvent>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: options?.body ? 'POST' : 'GET', headers: { accept: `${mediaTypes.EVENT_STREAM}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this, path, requestOptions.searchParams);\n\t\t\tawait this.runBeforeRequestHooks(requestOptions, url, path, requestHooks?.beforeRequest);\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tconst afterResponse: Response = await this.runAfterResponseHooks(response, requestOptions, requestHooks?.afterResponse);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleEventStream(afterResponse);\n\t\t\treturn unwrap ? stream : [true, stream] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/**\n\t * Opens an NDJSON (Newline Delimited JSON) stream and returns an AsyncIterable of typed JSON values.\n\t * Each line is independently parsed as JSON, making it suitable for streaming large datasets\n\t * or real-time JSON feeds.\n\t *\n\t * @async\n\t * @template T The expected type of each JSON line (defaults to Json).\n\t * @param path The path to the NDJSON endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed JSON values.\n\t * @example\n\t * ```typescript\n\t * for await (const user of api.getJsonStream<User>('/users/export')) {\n\t * processUser(user);\n\t * }\n\t * ```\n\t */\n\tasync getJsonStream<T = Json>(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<T> | Result<AsyncIterable<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: 'GET', headers: { accept: `${mediaTypes.NDJSON}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this, path, requestOptions.searchParams);\n\t\t\tawait this.runBeforeRequestHooks(requestOptions, url, path, requestHooks?.beforeRequest);\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tconst afterResponse: Response = await this.runAfterResponseHooks(response, requestOptions, requestHooks?.afterResponse);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleNdjsonStream<T>(afterResponse);\n\t\t\treturn unwrap ? stream : [ true, stream ] as Result<AsyncIterable<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [ false, error as HttpError ] as Result<AsyncIterable<T>>;\n\t\t\tthrow error;\n\t\t}\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 | Result<T | undefined>> {\n\t\toptions.method = 'GET';\n\t\toptions.body = undefined;\n\t\treturn this.execute<T>(path, userOptions, options, responseHandler);\n\t}\n\n\t/**\n\t * It processes the request options and returns a new object with the processed options.\n\t * Hot path: when no retry, no dedupe, and no upload/download progress tracking, this is essentially\n\t * `fetch(url, options)` with two `Set` operations and one event publish bracket \u2014 all inner closures have been hoisted\n\t * to private static helpers to avoid per-request allocations.\n\t * @param path The path to the resource.\n\t * @param config The processed request configuration produced by `processRequestOptions`.\n\t * @returns A promise resolving to the typed response.\n\t */\n\tprivate async _request<T = unknown>(path: string | undefined, config: RequestConfiguration): Promise<TypedResponse<T>> {\n\t\tconst { signalController, requestOptions, global } = config;\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\tconst startTime = performance.now();\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this, path, requestOptions.searchParams);\n\t\t\tlet dedupeKey: string | undefined;\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\tdedupeKey = `${method}:${url.href}`;\n\t\t\t\tconst inflight = Transportr.inflightRequests.get(dedupeKey);\n\t\t\t\tif (inflight) { return (await inflight).clone() }\n\t\t\t}\n\n\t\t\tconst onUploadProgress = requestOptions.onUploadProgress;\n\t\t\tconst originalBody = requestOptions.body;\n\t\t\t// Set duplex once (it's static for this request) \u2014 avoids redundant Object.assign in retry loop.\n\t\t\tif (onUploadProgress && originalBody != null) {\n\t\t\t\t(requestOptions as RequestOptions & { duplex?: string }).duplex = 'half';\n\t\t\t}\n\n\t\t\tconst responsePromise = this._doFetch<T>(url, requestOptions, path, method, canRetry, retryConfig, originalBody, onUploadProgress, startTime, global);\n\n\t\t\tif (canDedupe) {\n\t\t\t\tTransportr.inflightRequests.set(dedupeKey!, responsePromise);\n\t\t\t\ttry {\n\t\t\t\t\treturn Transportr._wrapDownloadProgress(await responsePromise, requestOptions);\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 Transportr._wrapDownloadProgress(await responsePromise, requestOptions);\n\t\t} finally {\n\t\t\tTransportr.signalControllers.delete(signalController.destroy());\n\t\t\tif (!requestOptions.signal?.aborted) {\n\t\t\t\tconst end = performance.now();\n\t\t\t\tthis.publish({ name: RequestEvent.COMPLETE, data: { timing: { start: startTime, end, duration: end - startTime } }, 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 * Performs the underlying fetch with retry logic. Hoisted out of `_request` so the function body\n\t * does not allocate a closure per request.\n\t * @param url The fully-resolved request URL.\n\t * @param requestOptions The processed request options.\n\t * @param path The original request path (used in error/retry events).\n\t * @param method The HTTP method.\n\t * @param canRetry Whether the request is eligible for retry.\n\t * @param retryConfig Normalized retry configuration.\n\t * @param originalBody The original (pre-upload-wrap) body, needed to rebuild the upload stream on retry.\n\t * @param onUploadProgress Optional upload progress callback.\n\t * @param startTime The performance.now() timestamp captured at request start (for timing reporting).\n\t * @param global Whether this request publishes to global event subscribers.\n\t * @returns The typed response.\n\t */\n\tprivate async _doFetch<T>(url: URL, requestOptions: RequestOptions, path: string | undefined, method: string, canRetry: boolean, retryConfig: NormalizedRetryOptions, originalBody: RequestBody | undefined, onUploadProgress: RequestOptions['onUploadProgress'], startTime: number, global: boolean): Promise<TypedResponse<T>> {\n\t\tlet attempt = 0;\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tif (onUploadProgress) { await Transportr._wrapUploadBody(requestOptions, originalBody, onUploadProgress) }\n\t\t\t\tconst response = await fetch<T>(url, requestOptions);\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tif (canRetry && attempt < retryConfig.limit && retryConfig.statusCodes.includes(response.status)) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, status: response.status, method, path, timing: Transportr._snapshotTiming(startTime) }, global });\n\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// Capture response body for error diagnostics (subject to consumer opt-out via captureErrorBody=false).\n\t\t\t\t\tlet entity: ResponseBody | undefined;\n\t\t\t\t\tif ((requestOptions as RequestOptions & { captureErrorBody?: boolean }).captureErrorBody !== false) {\n\t\t\t\t\t\ttry { entity = await response.text() } catch { /* body may be unavailable */ }\n\t\t\t\t\t}\n\t\t\t\t\tthrow await this.handleError(path, response, { entity, url, method, timing: Transportr._snapshotTiming(startTime) }, requestOptions);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t} catch (cause) {\n\t\t\t\tif (cause instanceof HttpError) { throw cause }\n\n\t\t\t\t// Network error \u2014 retry if allowed.\n\t\t\t\tif (canRetry && attempt < retryConfig.limit) {\n\t\t\t\t\tattempt++;\n\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, error: (cause as Error).message, method, path, timing: Transportr._snapshotTiming(startTime) }, global });\n\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthrow await this.handleError(path, undefined, { cause: cause as Error, url, method, timing: Transportr._snapshotTiming(startTime) }, requestOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Wraps the request body with a progress-tracking TransformStream.\n\t * Re-creates the stream from the original body on each call so retries get a fresh stream.\n\t * @param requestOptions Mutable request options whose `body` will be replaced with the wrapped stream.\n\t * @param originalBody The original body before any wrapping.\n\t * @param onUploadProgress The progress callback (already validated as defined by the caller).\n\t */\n\tprivate static async _wrapUploadBody(requestOptions: RequestOptions, originalBody: RequestBody | undefined, onUploadProgress: NonNullable<RequestOptions['onUploadProgress']>): Promise<void> {\n\t\tif (originalBody == null) { return }\n\n\t\tlet bytes: Uint8Array | null = null;\n\t\tif (typeof originalBody === 'string') {\n\t\t\tbytes = new TextEncoder().encode(originalBody);\n\t\t} else if (originalBody instanceof Blob) {\n\t\t\tbytes = new Uint8Array(await originalBody.arrayBuffer());\n\t\t} else if (isArrayBuffer(originalBody)) {\n\t\t\tbytes = new Uint8Array(originalBody);\n\t\t} else if (ArrayBuffer.isView(originalBody)) {\n\t\t\tbytes = new Uint8Array(originalBody.buffer, originalBody.byteOffset, originalBody.byteLength);\n\t\t} else if (!(originalBody instanceof ReadableStream)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst total = bytes ? bytes.byteLength : null;\n\t\tconst readable: ReadableStream<Uint8Array> = bytes\n\t\t\t? new ReadableStream<Uint8Array>({\n\t\t\t\t/** @param controller The stream controller. */\n\t\t\t\tstart(controller) { controller.enqueue(bytes); controller.close() }\n\t\t\t})\n\t\t\t: originalBody as ReadableStream<Uint8Array>;\n\n\t\tlet loaded = 0;\n\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t/**\n\t\t\t * Tracks bytes and invokes upload progress callback.\n\t\t\t * @param chunk The data chunk.\n\t\t\t * @param controller The transform controller.\n\t\t\t */\n\t\t\ttransform(chunk, controller) {\n\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\tonUploadProgress({\n\t\t\t\t\tloaded,\n\t\t\t\t\ttotal,\n\t\t\t\t\tpercentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null\n\t\t\t\t});\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\t\t});\n\n\t\trequestOptions.body = readable.pipeThrough(transform);\n\t}\n\n\t/**\n\t * Wraps the response body with a progress-tracking TransformStream when onDownloadProgress is set.\n\t * @param response The response to potentially wrap.\n\t * @param requestOptions The request options carrying the optional onDownloadProgress callback.\n\t * @returns The original response or a new response with progress tracking.\n\t */\n\tprivate static _wrapDownloadProgress<T>(response: TypedResponse<T>, requestOptions: RequestOptions): TypedResponse<T> {\n\t\tconst onDownloadProgress = requestOptions.onDownloadProgress;\n\t\tif (!onDownloadProgress || !response.body) return response;\n\n\t\tconst contentLength = response.headers.get('content-length');\n\t\tconst total = contentLength ? parseInt(contentLength, 10) : null;\n\t\tlet loaded = 0;\n\n\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t/**\n\t\t\t * Tracks bytes and invokes progress callback.\n\t\t\t * @param chunk The data chunk.\n\t\t\t * @param controller The transform controller.\n\t\t\t */\n\t\t\ttransform(chunk, controller) {\n\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\tonDownloadProgress({ loaded, total, percentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null });\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\t\t});\n\n\t\treturn new Response(response.body.pipeThrough(transform), { status: response.status, statusText: response.statusText, headers: response.headers });\n\t}\n\n\t/**\n\t * Captures a RequestTiming snapshot from a start timestamp to now.\n\t * @param startTime The start timestamp from `performance.now()`.\n\t * @returns Timing information for the request.\n\t */\n\tprivate static _snapshotTiming(startTime: number): RequestTiming {\n\t\tconst end = performance.now();\n\t\treturn { start: startTime, end, duration: end - startTime };\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 Transportr.noRetryConfig }\n\t\tif (typeof retry === 'number') { return { limit: retry, statusCodes: retryStatusCodes, methods: retryMethods, delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\n\t\t// Object identity cache: most consumers reuse the same options object across requests.\n\t\tconst cached = Transportr.retryConfigCache.get(retry);\n\t\tif (cached !== undefined) { return cached }\n\n\t\tconst normalized: NormalizedRetryOptions = {\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\tTransportr.retryConfigCache.set(retry, normalized);\n\t\treturn normalized;\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\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * Shared implementation for body-accepting HTTP methods (POST, PUT, PATCH, DELETE).\n\t * @param method The HTTP method to use.\n\t * @param path The request path, or the request body when called without a path.\n\t * @param body The request body, or options when called without a path.\n\t * @param options Additional request options.\n\t * @param responseHandler Optional response handler override.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tprivate executeBodyMethod<T extends ResponseBody>(method: RequestBodyMethod, path: string | RequestBody | undefined, body?: RequestBody | RequestOptions, options?: RequestOptions, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined | Result<T | undefined>> {\n\t\tconst [ resolvedPath, resolvedBody, resolvedOptions ] = isString(path) ? [ path, body as RequestBody, options ] : [ undefined, path, body as RequestOptions ];\n\n\t\t// Important: do NOT mutate `resolvedOptions` here \\u2014 callers may reuse the same options reference across requests.\n\t\t// Build a fresh options object that overlays method/body via Object.assign on a new target (one allocation).\n\t\tconst merged = resolvedOptions !== undefined\n\t\t\t? Object.assign({} as RequestOptions, resolvedOptions, { body: resolvedBody, method })\n\t\t\t: { body: resolvedBody, method } as RequestOptions;\n\t\treturn this.execute<T>(resolvedPath, merged, {}, responseHandler);\n\t}\n\n\t/**\n\t * Runs the beforeRequest hook chain (global \u2192 instance \u2192 per-request).\n\t * Returns immediately if no hooks of any kind are registered, allocating nothing.\n\t * @param requestOptions Mutable request options (hooks may patch via Object.assign).\n\t * @param url The current request URL.\n\t * @param path The original path argument (used to rebuild the URL when hooks update searchParams).\n\t * @param perRequest Per-request beforeRequest hooks, if any.\n\t * @returns The (possibly rebuilt) request URL.\n\t */\n\tprivate async runBeforeRequestHooks(requestOptions: RequestOptions, url: URL, path: string | undefined, perRequest: BeforeRequestHook[] | undefined): Promise<URL> {\n\t\tconst globalHooks = Transportr.globalHooks.beforeRequest;\n\t\tconst instanceHooks = this.hooks.beforeRequest;\n\t\tconst perRequestLength = perRequest === undefined ? 0 : perRequest.length;\n\t\tif (globalHooks.length === 0 && instanceHooks.length === 0 && perRequestLength === 0) { return url }\n\n\t\tfor (let i = 0, length = globalHooks.length; i < length; i++) {\n\t\t\tconst result = await globalHooks[i]!(requestOptions, url);\n\t\t\tif (result) { Object.assign(requestOptions, result); if (result.searchParams !== undefined) { url = Transportr.createUrl(this, path, requestOptions.searchParams) } }\n\t\t}\n\t\tfor (let i = 0, length = instanceHooks.length; i < length; i++) {\n\t\t\tconst result = await instanceHooks[i]!(requestOptions, url);\n\t\t\tif (result) { Object.assign(requestOptions, result); if (result.searchParams !== undefined) { url = Transportr.createUrl(this, path, requestOptions.searchParams) } }\n\t\t}\n\t\tfor (let i = 0; i < perRequestLength; i++) {\n\t\t\tconst result = await perRequest![i]!(requestOptions, url);\n\t\t\tif (result) { Object.assign(requestOptions, result); if (result.searchParams !== undefined) { url = Transportr.createUrl(this, path, requestOptions.searchParams) } }\n\t\t}\n\t\treturn url;\n\t}\n\n\t/**\n\t * Runs the afterResponse hook chain (global \u2192 instance \u2192 per-request).\n\t * Returns the input response untouched when no hooks are registered.\n\t * @param response The current response.\n\t * @param requestOptions The original request options passed to each hook.\n\t * @param perRequest Per-request afterResponse hooks, if any.\n\t * @returns The (possibly replaced) response.\n\t */\n\tprivate async runAfterResponseHooks(response: Response, requestOptions: RequestOptions, perRequest: AfterResponseHook[] | undefined): Promise<Response> {\n\t\tconst globalHooks = Transportr.globalHooks.afterResponse;\n\t\tconst instanceHooks = this.hooks.afterResponse;\n\t\tconst perRequestLength = perRequest === undefined ? 0 : perRequest.length;\n\t\tif (globalHooks.length === 0 && instanceHooks.length === 0 && perRequestLength === 0) { return response }\n\n\t\tfor (let i = 0, length = globalHooks.length; i < length; i++) {\n\t\t\tconst result = await globalHooks[i]!(response, requestOptions);\n\t\t\tif (result) { response = result }\n\t\t}\n\t\tfor (let i = 0, length = instanceHooks.length; i < length; i++) {\n\t\t\tconst result = await instanceHooks[i]!(response, requestOptions);\n\t\t\tif (result) { response = result }\n\t\t}\n\t\tfor (let i = 0; i < perRequestLength; i++) {\n\t\t\tconst result = await perRequest![i]!(response, requestOptions);\n\t\t\tif (result) { response = result }\n\t\t}\n\t\treturn response;\n\t}\n\n\t/**\n\t * Runs the beforeError hook chain (global \u2192 instance \u2192 per-request).\n\t * Returns the input error untouched when no hooks are registered.\n\t * @param error The current HttpError.\n\t * @param perRequest Per-request beforeError hooks, if any.\n\t * @returns The (possibly transformed) error.\n\t */\n\tprivate async runBeforeErrorHooks(error: HttpError, perRequest: BeforeErrorHook[] | undefined): Promise<HttpError> {\n\t\tconst globalHooks = Transportr.globalHooks.beforeError;\n\t\tconst instanceHooks = this.hooks.beforeError;\n\t\tconst perRequestLength = perRequest === undefined ? 0 : perRequest.length;\n\t\tif (globalHooks.length === 0 && instanceHooks.length === 0 && perRequestLength === 0) { return error }\n\n\t\tfor (let i = 0, length = globalHooks.length; i < length; i++) {\n\t\t\tconst result = await globalHooks[i]!(error);\n\t\t\tif (result instanceof HttpError) { error = result }\n\t\t}\n\t\tfor (let i = 0, length = instanceHooks.length; i < length; i++) {\n\t\t\tconst result = await instanceHooks[i]!(error);\n\t\t\tif (result instanceof HttpError) { error = result }\n\t\t}\n\t\tfor (let i = 0; i < perRequestLength; i++) {\n\t\t\tconst result = await perRequest![i]!(error);\n\t\t\tif (result instanceof HttpError) { error = result }\n\t\t}\n\t\treturn error;\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 | Result<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 unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this, path, requestOptions.searchParams);\n\t\t\tawait this.runBeforeRequestHooks(requestOptions, url, path, requestHooks?.beforeRequest);\n\n\t\t\tlet response = await this._request<T>(path, requestConfig);\n\t\t\tresponse = await this.runAfterResponseHooks(response, requestOptions, requestHooks?.afterResponse);\n\n\t\t\ttry {\n\t\t\t\tif (!responseHandler && response.status !== 204) {\n\t\t\t\t\tresponseHandler = this.getResponseHandler<T>(response.headers.get('content-type'));\n\t\t\t\t}\n\n\t\t\t\tconst data = await responseHandler?.(response);\n\n\t\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });\n\n\t\t\t\treturn unwrap ? data : [ true, data ];\n\t\t\t} catch (cause) {\n\t\t\t\tthrow await this.handleError(path, response, { cause: cause as Error }, requestOptions);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\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() to avoid intermediate tuple array\n\t\t\t\tconst keys = Object.keys(headers);\n\t\t\t\tfor (let i = 0, length = keys.length; i < length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = (headers as Record<string, string | undefined>)[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, 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, typeof value === 'string' ? value : 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 *\n\t * Hot path optimizations:\n\t * - No parameter destructuring (avoids two transient rest objects per call).\n\t * - Skips Headers/URLSearchParams construction entirely when neither user nor method overrides supply them.\n\t * - Reuses the pre-stripped `_noBodyHeadersTemplate` for non-body methods so we never have to delete `content-type` per request.\n\t * - Builds `requestOptions` via `Object.assign` with a stable property order to keep V8 hidden classes monomorphic.\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(userOptions: RequestOptions, options: RequestOptions): RequestConfiguration {\n\t\tconst userHeaders = userOptions.headers;\n\t\tconst userSearchParams = userOptions.searchParams;\n\t\tconst userBody = userOptions.body;\n\t\tconst optHeaders = options.headers;\n\t\tconst optSearchParams = options.searchParams;\n\n\t\tconst method = (options.method ?? userOptions.method ?? this._options.method ?? 'GET');\n\t\tconst isBodyMethod = isRequestBodyMethod(method);\n\t\t// Headers fast path: when the method strips Content-Type AND there are no overrides, clone the pre-stripped template.\n\t\tlet headers: Headers;\n\t\tif (!isBodyMethod && userHeaders === undefined && optHeaders === undefined) {\n\t\t\theaders = new Headers(this._noBodyHeadersTemplate);\n\t\t} else {\n\t\t\theaders = new Headers(this._options.headers);\n\t\t\tif (userHeaders !== undefined || optHeaders !== undefined) {\n\t\t\t\tTransportr.mergeHeaders(headers, userHeaders, optHeaders);\n\t\t\t}\n\t\t}\n\n\t\t// SearchParams fast path: skip construction entirely when both inputs and instance defaults are empty.\n\t\tconst instanceSearchParams = this._options.searchParams as URLSearchParams | undefined;\n\t\tconst hasInstanceSearchParams = instanceSearchParams !== undefined && instanceSearchParams.size > 0;\n\t\tlet searchParams: URLSearchParams;\n\t\tif (!hasInstanceSearchParams && userSearchParams === undefined && optSearchParams === undefined) {\n\t\t\tsearchParams = new URLSearchParams();\n\t\t} else {\n\t\t\tsearchParams = new URLSearchParams(instanceSearchParams);\n\t\t\tif (userSearchParams !== undefined || optSearchParams !== undefined) {\n\t\t\t\tTransportr.mergeSearchParams(searchParams, userSearchParams, optSearchParams);\n\t\t\t}\n\t\t}\n\n\t\t// Build requestOptions via Object.assign to avoid the rest-object allocations the spread/destructure pattern produces.\n\t\t// Object.assign copies explicit `undefined` properties, so a user-passed `{ method: undefined }` correctly overrides\n\t\t// the instance default for the value handed to fetch \\u2014 we only use the local `method` var for retry/dedupe routing.\n\t\tconst requestOptions = Object.assign({} as RequestOptions, this._options, userOptions, options);\n\t\trequestOptions.headers = headers;\n\t\trequestOptions.searchParams = searchParams;\n\n\t\tif (isBodyMethod) {\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 (e.g. multipart boundary).\n\t\t\t\trequestOptions.body = userBody;\n\t\t\t\theaders.delete('content-type');\n\t\t\t} else {\n\t\t\t\tconst instanceBody = this._options.body;\n\t\t\t\tconst body = isObject<Record<string, unknown>>(instanceBody) && isObject<Record<string, unknown>>(userBody) ? objectMerge(instanceBody, userBody) : (userBody !== undefined ? userBody : instanceBody);\n\t\t\t\tconst contentType = headers.get('content-type');\n\t\t\t\tconst isJson = contentType !== null && contentType.includes('json');\n\t\t\t\trequestOptions.body = (isJson && isObject(body) ? serialize(body) : body) as RequestOptions['body'];\n\t\t\t}\n\t\t} else {\n\t\t\tif (requestOptions.body instanceof URLSearchParams) {\n\t\t\t\tTransportr.mergeSearchParams(searchParams, requestOptions.body);\n\t\t\t}\n\t\t\trequestOptions.body = undefined;\n\t\t\t// Headers were already built without Content-Type via the fast path; only need to strip when overrides reintroduced it.\n\t\t\tif (userHeaders !== undefined || optHeaders !== undefined) { headers.delete('content-type') }\n\t\t}\n\n\t\tconst signal = requestOptions.signal;\n\t\tconst timeout = requestOptions.timeout;\n\t\tconst global = requestOptions.global ?? false;\n\t\tconst xsrf = requestOptions.xsrf;\n\n\t\t// XSRF/CSRF protection: read token from cookie and set as request header.\n\t\tif (xsrf) {\n\t\t\tconst { cookieName, headerName }: XsrfOptions = typeof xsrf === 'object' ? xsrf : {};\n\t\t\tconst token = getCookieValue(cookieName ?? XSRF_COOKIE_NAME);\n\t\t\tif (token) { headers.set(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 };\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 entry when cache exceeds limit to prevent unbounded growth\n\t\t\tif (Transportr.mediaTypeCache.size >= 100) {\n\t\t\t\tTransportr.mediaTypeCache.delete(Transportr.mediaTypeCache.keys().next().value!);\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 * Uses the pre-normalized base pathname/origin to avoid per-request regex work.\n\t * Polymorphic on the first arg to preserve the legacy direct-URL test API.\n\t * @param source A Transportr instance (preferred) or a 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(source: Transportr | URL, path?: string, searchParams?: SearchParameters): URL {\n\t\tlet requestUrl: URL;\n\t\tif (source instanceof URL) {\n\t\t\t// Legacy/direct-call path \\u2014 strip a single trailing slash from pathname.\n\t\t\tconst basePath = source.pathname;\n\t\t\tconst normalizedBase = basePath.charCodeAt(basePath.length - 1) === 47 ? basePath.slice(0, -1) : basePath;\n\t\t\trequestUrl = path ? new URL(`${normalizedBase}${path}`, source.origin) : new URL(source);\n\t\t} else {\n\t\t\trequestUrl = path ? new URL(`${source._basePath}${path}`, source._origin) : new URL(source._baseUrl);\n\t\t}\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\terror = await this.runBeforeErrorHooks(error, requestOptions?.hooks?.beforeError);\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 * Skips entirely when no subscribers are registered for the event \u2014 the common case in production \u2014\n\t * which avoids both the CustomEvent allocation and the validateEventName/forEach overhead inside Subscribr.\n\t * @param eventObject The event object to publish.\n\t */\n\tprivate publish({ name, event, data, global = true }: PublishOptions): void {\n\t\tconst hasGlobal = global && (Transportr.globalSubCounts[name] ?? 0) > 0;\n\t\tconst hasLocal = (this.subCounts[name] ?? 0) > 0;\n\t\tif (!hasGlobal && !hasLocal) { return }\n\n\t\t// Lazily allocate the CustomEvent only when at least one subscriber exists.\n\t\tconst evt = event ?? new CustomEvent(name);\n\t\tif (hasGlobal) { Transportr.globalSubscribr.publish(name, evt, data) }\n\t\tif (hasLocal) { this.subscribr.publish(name, evt, 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\t// Fast path: result already resolved for this exact Content-Type string.\n\t\tconst cached = Transportr.handlerResolutionCache.get(contentType);\n\t\tif (cached !== undefined) { return cached === null ? undefined : cached as ResponseHandler<T> }\n\n\t\tconst mediaType = Transportr.getOrParseMediaType(contentType);\n\t\tif (!mediaType) {\n\t\t\tTransportr.handlerResolutionCache.set(contentType, null);\n\t\t\treturn;\n\t\t}\n\n\t\tconst handlers = Transportr.contentTypeHandlers;\n\t\tfor (let i = 0, length = handlers.length; i < length; i++) {\n\t\t\tconst entry = handlers[i]!;\n\t\t\tif (mediaType.matches(entry[0])) {\n\t\t\t\tconst resolved = entry[1];\n\t\t\t\tTransportr.handlerResolutionCache.set(contentType, resolved);\n\t\t\t\treturn resolved as ResponseHandler<T>;\n\t\t\t}\n\t\t}\n\n\t\tTransportr.handlerResolutionCache.set(contentType, null);\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"],
|
|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C5B,QAASkC,EAAI,EAAGuB,EAAS0G,EAAS,OAAQjI,EAAIuB,EAAQvB,IAAK,CAC1D,IAAMkI,EAAQD,EAASjI,CAAC,EACxB,GAAI7B,EAAU,QAAQ+J,EAAM,CAAC,CAAC,EAAG,CAChC,IAAMC,EAAWD,EAAM,CAAC,EACxB,OAAApK,EAAW,uBAAuB,IAAIqC,EAAagI,CAAQ,EACpDA,CACR,CACD,CAEArK,EAAW,uBAAuB,IAAIqC,EAAa,IAAI,CAExD,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", "defaultValue", "compute", "iterator", "values", "deleted", "ContextEventHandler", "context", "eventHandler", "event", "data", "Subscription", "eventName", "contextEventHandler", "Subscribr", "u", "errorHandler", "options", "originalHandler", "subscription", "contextEventHandlers", "removed", "error", "HttpError", "status", "message", "cause", "entity", "url", "method", "timing", "ResponseStatus", "code", "text", "charset", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "mediaTypes", "h", "charset", "defaultMediaType", "defaultOrigin", "RequestCachingPolicy", "RequestEvent", "SignalEvents", "SignalErrors", "eventListenerOptions", "abortEvent", "timeoutEvent", "requestBodyMethods", "internalServerError", "ResponseStatus", "aborted", "timedOut", "retryStatusCodes", "retryMethods", "retryDelay", "retryBackoffFactor", "SignalController", "signal", "timeout", "hasExternal", "hasTimeout", "signals", "SignalEvents", "eventListenerOptions", "reason", "SignalErrors", "timeoutEvent", "eventListener", "event", "abortEvent", "events", "type", "domReady", "purify", "ensureDom", "JSDOM", "window", "p", "parseSanitizedDocument", "response", "mimeType", "withObjectURL", "executor", "objectURL", "res", "rej", "handleText", "handleScript", "resolve", "reject", "script", "handleCss", "link", "handleJson", "handleBlob", "handleImage", "img", "handleBuffer", "handleReadableStream", "handleXml", "handleHtml", "handleHtmlFragment", "handleHtmlFragmentWithScripts", "readDelimited", "body", "delimiter", "flushRemaining", "reader", "decoder", "delimLength", "buffer", "cursor", "index", "done", "value", "remaining", "parseServerSentEvent", "rawEvent", "event", "id", "retry", "firstData", "extraData", "lines", "i", "length", "line", "colonIndex", "field", "n", "data", "handleEventStream", "sse", "handleNdjsonStream", "trimmed", "isRequestBodyMethod", "method", "requestBodyMethods", "isRawBody", "body", "getCookieValue", "name", "cookieStr", "prefix", "prefixLength", "cookieLength", "start", "end", "serialize", "data", "isString", "value", "isArrayBuffer", "isObject", "objectMerge", "objects", "length", "obj", "deepClone", "target", "s", "sLength", "source", "keys", "i", "property", "sourceValue", "targetValue", "merged", "j", "tLength", "item", "object", "cloned", "key", "Transportr", "_Transportr", "d", "retryDelay", "retryBackoffFactor", "mediaTypes", "mediaType", "handleText", "handleJson", "handleReadableStream", "handleHtml", "handleXml", "handleImage", "handleScript", "handleCss", "url", "defaultOrigin", "options", "isObject", "basePath", "RequestEvent", "RequestCachingPolicy", "defaultMediaType", "event", "handler", "context", "registration", "eventRegistration", "removed", "next", "signalController", "abortEvent", "requests", "controllers", "promises", "i", "controller", "controller_1", "contentType", "index", "type", "hooks", "beforeRequest", "afterResponse", "beforeError", "headers", "searchParams", "k", "path", "body", "requestConfig", "requestOptions", "unwrap", "requestHooks", "response", "allowHeader", "allowedMethods", "parts", "length", "error", "selector", "doc", "allowScripts", "fragment", "handleHtmlFragmentWithScripts", "handleHtmlFragment", "handleBlob", "handleBuffer", "stream", "handleEventStream", "handleNdjsonStream", "userOptions", "responseHandler", "config", "global", "retryConfig", "method", "canRetry", "canDedupe", "startTime", "dedupeKey", "inflight", "onUploadProgress", "originalBody", "responsePromise", "end", "attempt", "entity", "cause", "HttpError", "bytes", "isArrayBuffer", "total", "readable", "loaded", "transform", "chunk", "onDownloadProgress", "contentLength", "retry", "retryStatusCodes", "retryMethods", "cached", "normalized", "ms", "resolve", "resolvedPath", "resolvedBody", "resolvedOptions", "isString", "merged", "perRequest", "globalHooks", "instanceHooks", "perRequestLength", "result", "data", "userHeaders", "userSearchParams", "objectMerge", "target", "headerSources", "value", "name", "keys", "sources", "userBody", "optHeaders", "optSearchParams", "isBodyMethod", "isRequestBodyMethod", "instanceSearchParams", "hasInstanceSearchParams", "isRawBody", "instanceBody", "isJson", "serialize", "signal", "timeout", "xsrf", "cookieName", "headerName", "token", "getCookieValue", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "SignalController", "h", "source", "requestUrl", "normalizedBase", "errorName", "status", "statusText", "SignalErrors", "aborted", "timedOut", "ResponseStatus", "internalServerError", "timing", "message", "hasGlobal", "hasLocal", "evt", "handlers", "entry", "resolved"]
|
|
7
7
|
}
|