Luxar Viewer API Documentation - v2026.10.19
    Preparing search index...

    A per-instance bounded-concurrency FIFO write queue with per-key coalescing. Unlike the page-wide gates (utils/fetch-concurrency.ts, and the OPFS read gate on utils/async-gate.ts), which hold every waiter until a slot frees, this one is per-instance, configurable, and bounded by both task count and retained bytes: past its bounds it DROPS writes instead of queuing them. It has no abort exit — a queued task re-checks staleness when it runs (see the module doc). utils/README.md tabulates what each queue honours.

    Index
    pending: Map<string, PendingWrite> = ...

    Pending tasks keyed by cache key. Map insertion order IS the FIFO order; re-enqueuing a key coalesces (the latest task wins and moves to newest).

    pendingBytes: number = 0
    speculativeCount: number = 0

    Count and bytes of the speculative subset of pending.

    speculativeBytes: number = 0
    inFlightPromises: Set<Promise<void>> = ...

    Currently-running task promises (for drain()).

    droppedCount: number = 0
    droppedSpeculativeCount: number = 0
    pumping: boolean = false
    concurrency: number
    maxDepth: number
    maxBytes: number
    • Resolve one configured limit: finite, floored, at least 1. All three go through here because Math.max(1, Math.floor(NaN)) is NaN, and each limit fails differently and silently on a NaN — size < NaN is false, so a non-finite concurrency means the pump never starts a task (total L2 write loss) while a non-finite maxDepth/maxBytes simply removes that bound. Every one of them is reachable through MultiLevelCachingStore's opfsWrite* options, which bypass the config validators.

      Parameters

      • value: number

      Returns number

    • Schedule a write. Returns synchronously; the task runs in the background when a concurrency slot frees. Re-enqueuing the same key replaces its pending task (coalesce, keep-latest; the entry keeps the higher of the two priorities). Past maxDepth or maxBytes the overflow policy in the module docstring decides what goes: speculative writes before demand ones, and otherwise this arrival.

      Parameters

      • key: string
      • run: () => Promise<void>
      • byteLength: number
      • priority: OpfsWritePriority = 'demand'

      Returns void

    • Restore both caps after arrivalKey was (re-)inserted. Both held before the insert, so this removes only what the arrival pushed over.

      Parameters

      • arrivalKey: string
      • replaced: boolean

      Returns void

    • Whether evicting speculative writes can ever make room for arrival: false when the arrival plus the pending writes that are NOT evictable (every demand write, and the arrival itself) already exceed a cap. Checked first so a hopeless arrival never discards speculative work for nothing.

      Parameters

      Returns boolean