Documentation
    Preparing search index...

    Interface AssetManagerOptions<TSignal>

    Construction options for AssetManager.

    TSignal is inferred from whichever of AssetManagerOptions.fetch and AssetManagerOptions.abortController is present, and its only job is to make the two agree: a controller whose signal the transport would refuse is a compile error here rather than a TypeError at the first load.

    interface AssetManagerOptions<TSignal = never> {
        abortController?: () => AbortHandle<TSignal>;
        decodeText?: TextDecodeLike;
        digest?: DigestLike;
        fetch?: FetchLike<TSignal>;
        maximumBytes?: number;
        timeoutSeconds?: number;
        timer?: TimerLike;
        watch?: AssetWatchLike;
        workerFactory?: () => WorkerLike;
    }

    Type Parameters

    • TSignal = never
    Index
    abortController?: () => AbortHandle<TSignal>

    Mints one cancellation source per load — () => new AbortController() in any modern runtime (§76).

    Presence is the capability. Without it, cancellation still works at the promise level (an aborted load rejects, gives back its reference, and frees its cache slot) and the request merely drains; with it, the request is cancelled at the transport, and so is a request that outlives AssetManagerOptions.timeoutSeconds. AssetManager.canAbortTransport reports which manager this is, so a caller never has to guess.

    It is a factory, not a controller: a controller is single-use, and every load needs its own.

    decodeText?: TextDecodeLike

    The UTF-8 decoder a hashed text()/json() load needs, because hashing is defined over bytes. Defaults to globalThis.TextDecoder.

    Only ever consulted by a load that asked to be hashed and whose loader reads the body as text; a byte-reading loader needs none.

    digest?: DigestLike

    The content hash implementation (§76). Defaults to SHA-256 over globalThis.crypto.subtle, where the runtime has one.

    Presence is the capability, reported by AssetManager.canHashContent: a manager without one loads exactly as before, and refuses — loudly, at the call — any load that asked for a hash. See content-hash.ts for the algorithm argument.

    The IO implementation. Defaults to globalThis.fetch bound to globalThis; see the module comment for why an IO manager is allowed a platform default.

    maximumBytes?: number

    §96 input-size limit, in bytes. Defaults to DEFAULT_MAXIMUM_BYTES.

    Checked against the declared content-length before the body is read, and against the body itself as the loader reads it. text() is measured in UTF-16 code units, which is never more than the UTF-8 byte count, so that check is conservative in the safe direction.

    Number.POSITIVE_INFINITY disables it; anything else must be greater than zero.

    timeoutSeconds?: number

    §96 deadline for a whole load — transport and decode — in seconds (§7a). Defaults to DEFAULT_TIMEOUT_SECONDS.

    On expiry the load rejects with ASSET_LOAD_FAILED and the entry is evicted, so the caller is released and the key is retryable. The underlying request is aborted too when the manager was given an AssetManagerOptions.abortController, and left to drain when it was not — the caller's promise settles identically either way.

    Number.POSITIVE_INFINITY disables it — and with it the need for a TimerLike; anything else must be greater than zero.

    timer?: TimerLike

    The timer behind AssetManagerOptions.timeoutSeconds. Defaults to globalThis, which satisfies TimerLike in every browser and in Node.

    Dev-server file watcher (§76 hot reload).

    Presence is the capability, reported by AssetManager.canWatch. AssetManager.watch forwards to this function; without it, watch throws INVALID_APPLICATION_STATE naming the injection point. The host owns the protocol — this package never opens a socket.

    workerFactory?: () => WorkerLike

    Mints one Worker per decodeInWorker load (§76).

    Presence is the capability, reported by AssetManager.canDecodeInWorker. Without it, { decodeInWorker: true } decodes in-process. It is a factory, not a Worker: a Worker is single-use from this package's point of view, and every decode gets its own (then terminates it, when the fake has one).