export type ParsedData = Record; export type ParsedUri = { /** * - The category of the URI. */ type: Type; /** * - The parsed content. */ data: Data; }; export type ParseChecker = (uri: string) => boolean; export type ParserCallback = (uri: string) => ParsedUri; export type StringifyCallback = (parsed: Data) => string; export type ParserPair = readonly [Type, ParseChecker, ParserCallback, StringifyCallback]; /** * A generic template for parsed URI results. * @typedef {Record} ParsedData */ /** * A generic template for parsed URI results. * @template {string} Type * @template {ParsedData} Data * @typedef {Object} ParsedUri * @property {Type} type - The category of the URI. * @property {Data} data - The parsed content. */ /** * A function type used to validate whether a provided URI string matches a specific pattern or protocol. * @typedef {(uri: string) => boolean} ParseChecker */ /** * A function type that accepts a URI string and returns a structured `ParsedUri` object. * @template {string} Type * @template {ParsedData} Data * @typedef {(uri: string) => ParsedUri} ParserCallback */ /** * @template {string} Type * @template {ParsedData} Data * @typedef {(parsed: Data) => string} StringifyCallback */ /** * A tuple representing a single parsing unit, consisting of a validation function, * its corresponding parsing function, and an reconstruction function. * @template {string} Type * @template {ParsedData} Data * @typedef {readonly [Type, ParseChecker, ParserCallback, StringifyCallback]} ParserPair */ /** * A utility class designed to parse various Matrix-related URI formats into structured objects. * @template {ParserPair} Parser */ declare class TinyUriParser> { #private; /** * Creates a frozen, immutable tuple containing the type, validation condition, parsing function, and stringification function for a specific URI type. * @template {string} Type * @template {ParsedData} Data * @param {Type} type - The unique string identifier representing the URI category. * @param {ParseChecker} conditions - A validation function that returns `true` if the URI matches the specific pattern. * @param {(uri: string) => Data} parser - A function that extracts and returns the parsed data from the URI string. * @param {StringifyCallback} stringify - A function used to convert the parsed data back into a URI string. * @returns {ParserPair} An immutable tuple containing the type, validation checker, parser, and stringifier. */ static buildParserPair(type: Type, conditions: ParseChecker, parser: (uri: string) => Data, stringify: StringifyCallback): ParserPair; /** * Indicates whether this instance has been destroyed. * @type {boolean} */ get isDestroyed(): boolean; /** * Returns an array containing shallow copies of the registered parser pairs to prevent direct mutation of the internal set. * @type {Parser[]} */ get parsers(): Parser[]; /** * Returns the total number of registered parser pairs. * @type {number} */ get size(): number; /** * Initializes the TinyUriParser instance with a collection of parser pairs. * @param {...Parser} parsers * @throws {TypeError} If any provided parser is not a valid ParserPair. */ constructor(...parsers: Parser[]); /** * Main entry point for parsing. * @param {string} uriString - The raw URI string to parse. * @returns {ReturnType} The parsed object. * @throws {TypeError | RangeError | Error} If the input is invalid or parsing fails. */ parse(uriString: string): ReturnType; /** * Reconstructs the original URI string from a parsed object. * @param {ReturnType} parsedObject - The object returned by the parse method. * @returns {string} The reconstructed URI string. * @throws {TypeError | Error} If the object is invalid or no reconstructor is found. */ stringify(parsedObject: ReturnType): string; /** * Cleans up internal parsers and marks the instance as destroyed to prevent memory leaks. * @returns {void} */ destroy(): void; } export default TinyUriParser; //# sourceMappingURL=TinyUriParser.d.mts.map