Skip to content
@drupflare/spool v1.0.0 GitHub
    Preparing search index...

    Type Alias SpoolClient

    the page's handle on the worker

    type SpoolClient = {
        hello: Hello;
        registration: ServiceWorkerRegistration;
        flush(): Promise<WriteRefusal | { ok: true } & WriteFlush>;
        persisted(): boolean | null;
        reportLoads(
            id: string,
            count: number,
            origins?: Record<string, number>,
        ): void;
        resolve(
            name: string,
            key: string,
            use: "local" | "server",
        ): Promise<WriteRefusal | WriteResolved>;
        status(): Promise<Status>;
        track(db: Closable): () => void;
        view(path?: string): Promise<string | null>;
        write(
            name: string,
            key: string,
            value: unknown,
            version: string,
        ): Promise<WriteRefusal | WriteQueued>;
        writes(): Promise<WriteRefusal | { ok: true; writes: WriteStatus[] }>;
    }
    Index
    • whether the browser granted persistent storage, or null until the worker held a dataset and the page asked

      Returns boolean | null

    • tells the worker how many cross-origin resources the page loaded, for view id, and from which origins

      Parameters

      • id: string
      • count: number
      • Optionalorigins: Record<string, number>

      Returns void

    • the id of this page's view, which the worker made when it handled the navigation; null if it made none

      Parameters

      • Optionalpath: string

      Returns Promise<string | null>

    • Queues value as the newest for a declared write class and key, edited from version. Never throws: it answers a refusal with a code while declared writes are off, the class is not declared or no principal is signed in.

      Parameters

      • name: string
      • key: string
      • value: unknown
      • version: string

      Returns Promise<WriteRefusal | WriteQueued>

    hello: Hello

    the version handshake; compatible is false when the worker speaks another protocol

    registration: ServiceWorkerRegistration