Interface ProtocolModule<TKind, TAdapter>

Minimal executable protocol seam. Heavy peers are injected as values (peer) and are never imported by SDK core; discovery stays lazy so a module that is registered but never discovered pays no I/O or peer-import cost. discover may return synchronously when construction needs no I/O (as PMTiles does — the archive itself is opened lazily on first describe()), or asynchronously for a module whose discovery is inherently a network round trip.

capabilities()/discover() accept SourceDescriptor<TKind | Protocol> — the built-in Protocol union plus this module's own TKind — so a third-party module with a custom protocol id (e.g. the cloud-tiles fixture's "cloud-tiles", test/fixtures/plugins/cloud-tiles/protocol-module.ts) can pass a descriptor typed to its own kind without an as cast, matching how pmtilesProtocolModule() (src/contract/pmtiles.ts) already accepts SourceDescriptor<"pmtiles" | Protocol>, i.e. SourceDescriptor (issue #671).

interface ProtocolModule<TKind, TAdapter> {
    environments: readonly ProtocolModuleEnvironment[];
    kind: TKind;
    peer?: unknown;
    capabilities(descriptor: SourceDescriptor<Protocol | TKind>): Capabilities;
    discover(descriptor: SourceDescriptor<Protocol | TKind>, options?: ProtocolModuleDiscoverOptions): ProtocolModuleHandle<TAdapter, Protocol | TKind> | Promise<ProtocolModuleHandle<TAdapter, Protocol | TKind>>;
}

Type Parameters

  • TKind extends string = string
  • TAdapter = unknown

Hierarchy (view full)

Properties

environments: readonly ProtocolModuleEnvironment[]
kind: TKind
peer?: unknown

Methods