/** * Custom URL-scheme → SourceAdapter registry. * * The built-in pipeline reads http/https/blob/data/file (via fetch/File). Any * other scheme fails at fetch() and surfaces as a network error — and the UI * flags it as an invalid URL. This registry lets an app teach the player about * a custom scheme (s3://, ipfs://, ws://, myapp://): register a factory once, * and thereafter `src="s3://bucket/movie.mp4"` builds the source THROUGH that * factory instead of fetch(), and the scheme is no longer treated as a typo. * * This complements `element.sourceAdapter = new MyAdapter(url)` — the instance * property is an explicit per-element override; the registry is global * (per document, like customElements.define) and selects by scheme. */ import type { SourceAdapter } from "./SourceAdapter"; /** Config handed to a registered factory when a matching-scheme src loads. */ export interface SourceAdapterFactoryConfig { /** The full source URL, e.g. "s3://bucket/movie.mp4". */ url: string; /** Custom request headers set on the player (the `headers` config/attr). */ headers?: Record; } /** Builds a SourceAdapter for a custom URL scheme. May be async. */ export type SourceAdapterFactory = (config: SourceAdapterFactoryConfig) => SourceAdapter | Promise; /** * Register a SourceAdapter factory for one or more custom URL schemes. Once * registered, a `src` with that scheme builds the source through this factory * instead of fetch(), and the scheme is no longer rejected as an invalid URL. * * Pass an array to bind the same factory to several schemes in one call * (e.g. registerSourceAdapter(["s3", "s3a"], factory)). Registration is * atomic — if any scheme is invalid or built-in, none are applied. * * Built-in schemes (http/https/blob/data/file) can't be overridden — pass an * explicit `element.sourceAdapter` instance if you need to intercept those. * * @param scheme A scheme name, or an array of them, with or without trailing * punctuation ("s3", "s3:" and "s3://" are all accepted). * @param factory Builds the adapter for a matching URL. May be async. */ export declare function registerSourceAdapter(scheme: string | string[], factory: SourceAdapterFactory): void; /** * Remove one or more previously registered schemes. Returns true if at least * one was removed. */ export declare function unregisterSourceAdapter(scheme: string | string[]): boolean; /** The registered scheme keys (without colons), e.g. ["s3", "ipfs"]. */ export declare function getRegisteredSchemes(): string[]; /** * The factory registered for a URL's scheme, or null if none. `base` resolves * relative URLs (which never carry a custom scheme, so they return null). */ export declare function getSourceAdapterFactory(url: string, base?: string): SourceAdapterFactory | null; /** * True when a URL's scheme is one the player can actually open — a built-in * fetchable scheme or one with a registered factory. Distinguishes a genuine * typo ("httpss://") from a valid custom scheme ("s3://"). Unparseable input * (relative to no base) returns false. */ export declare function isOpenableScheme(url: string, base?: string): boolean; //# sourceMappingURL=adapterRegistry.d.ts.map