/** * Which registered service owns a URL. * * A pure lookup: no ServiceWorker, no storage, no I/O, so the routing rules * can be tested as arithmetic rather than through a browser. * * TWO KINDS OF MOUNT, AND WHY BOTH. A `path` is a prefix, which is all most * hosts need and costs nothing to match. A `match` predicate is the escape * hatch for anything richer -- a host that wants URLPattern brings it and pays * for it; this file must stay dependency-free, because it runs in a * ServiceWorker that has to start fast. * * SPECIFICITY, NOT REGISTRATION ORDER. Prefixes are tried longest-first, so a * catch-all at "/" cannot swallow "/peers/" and a host need not register in a * careful order. Predicates are opaque -- nothing can be said about how * specific they are -- so they are tried after every prefix, in the order they * were registered. */ export interface MountSpec { /** A path prefix, e.g. `/peers/`. `/` is the whole origin. */ path?: string; /** Anything richer. Consulted only when no prefix matches. */ match?: (url: URL) => boolean; } export interface MountTable { /** Add or replace the mount for `key`. */ set(key: string, spec: MountSpec): void; remove(key: string): void; /** The key that owns `url`, or `undefined` — meaning "not the relay's". */ find(url: URL): string | undefined; /** * Is `url` reserved by `exclude`? `find` already applies it, but the relay * has a SECOND route — the `/~/` spelling, which does not go through * the table at all — and "an excluded path is never claimed" has to hold * for both. The predicate lives here so there is one copy of it. */ excludes(url: URL): boolean; } export interface MountTableOptions { /** * Paths the relay never claims, checked BEFORE the table. A root mount * matches every path, so a host with files of its own (a relay page, a * worker, hashed assets) is unusable without this. */ exclude?: (url: URL) => boolean; } export declare function newMountTable(options?: MountTableOptions): MountTable; //# sourceMappingURL=mount-table.d.ts.map