Type Alias SpoolOptions
assets?: AssetMode;
beacons?: readonly string[];
bootstrap?: BootstrapGate;
bundle?: { blockRows?: number; maxBytes?: number; ringBytes?: number };
bundles?: BundleStore;
catalogueBytes?: number;
catalogueConfidence?: number;
catalogueSize?: Sizer;
cdn?: {
integrity: string;
url?: string;
worker?: boolean | { url: string };
};
clientTag?: "inline"
| "script";
collectors?: readonly CollectorConfig[];
datasets?: readonly Dataset[];
freshness?: { maxAge?: number };
identity?: IdentityOptions;
inlineMaxBytes?: number;
live?: boolean | "always" | LiveOptions;
logout?: readonly string[];
meter?: () => number;
mode?: Mode;
policy?: Record<string, string>;
principalDatasets?: boolean;
provision?: ProvisionConfig;
resources?: readonly Resource[];
routes: readonly Route[];
shadowSample?: number;
sink?: Sink;
stamp?: number | (() => number);
store: VersionStore;
thirdParty?: ThirdPartyConfig;
views?: boolean;
work?: WorkSeries;
worker?: string;
workerMode?: WorkerMode;
writes?: {
classes: readonly Write[];
enabled?: boolean;
remember?: number;
};
}
Index
Properties
Properties
Optionalassets
how the worker treats same-origin subresources; default cache
Optionalbeacons
same-origin POST paths the worker queues and flushes in one request
Optionalbootstrap
When the device fetches the pack: second-view on the second view, the default, or first-view.
The ring in the first document is the same either way.
Optionalbundle
Options for the packs publish builds. ringBytes is the budget of the ring on each
family page, default 24,576 and not measured. blockRows is rows per block, default 128.
maxBytes is the most compressed bytes of one block, at most the reader's frame cap.
Optionalbundles
where buildBundle keeps packs; GET /.spool/bundle/<version> answers 404 without it
Optionalcatalogue Bytes
the most compressed bytes of entries one catalogue bundle may carry; default 32 KiB
Optionalcatalogue Confidence
How cautious the catalogue is about a share it estimated: a guess with n observations is
judged on the lower confidence bound of its p at this many standard deviations (1.28 is
one-sided 90%). A guess with no n keeps its p. Default 0, which judges every guess on p.
Optionalcatalogue Size
measures an entry's compressed bytes for the catalogue; default Brotli, gzip where the runtime has no Brotli stream
Optionalcdn
serve the page runtime from a CDN with SRI; omitted, it is served from
/.spool/<version>/client.js. url defaults to this version's cdn.drupflare.com build,
whose integrity is in the release notes and in dist/cdn/manifest.json.
worker also moves the worker core to the CDN: the stub becomes the config and one
importScripts line, a few KB in place of the core, and the core is fetched from
worker.url, or from this version's cdn.drupflare.com build when worker is true. A
browser has no integrity check for an imported script, so the site trusts the CDN host with a
script that can answer every request of the origin. Off by default. A site with a custom
worker bundle must give worker.url. publishStatic checks the served bytes with
verifyCore.
Optionalclient Tag
How a second-view page loads the runtime. inline (default) puts a small gate in place of the
script tag. The gate waits for the first click or GET form submit that the held pages answer,
then loads one script that carries the runtime and the pack, in place of the document that
click would have fetched, so a visitor never makes more requests than the site without
spool. A page with no ring, or whose ring names no boot script (cdn is set), loads the
runtime from the second view. script keeps the tag, for a page whose CSP forbids inline
scripts. A first-view site always uses the tag.
Optionalcollectors
cross-origin analytics collectors the worker holds and delivers later
Optionaldatasets
public datasets /.spool/dataset answers, each by its own name
Optionalfreshness
maxAge, in seconds, is the lease of /spool-sw.js in the browser's cache; default one day.
A check inside it costs nothing, and after it one request brings the version and its changes.
A floor applies on top of the lease: Chromium checked the stub on the first document navigation
after each 24 hours whatever maxAge was (measured in Chromium only, with the wall clock shifted),
so a lease longer than a day does not cut the checks. A stub that changed at that check installs,
which is the contact.
Optionalidentity
Optionalinline Max Bytes
The most bytes of escaped artifact JSON a public template page carries in the page itself,
so the worker stores it from the navigation and asks no /.spool/artifact. Every network view
of such a page pays for the bytes and one more load, whether or not the visitor has a
worker; a larger artifact is left out. Default 0, which is off; 2048 is the limit measured.
Optionallive
The stream a visible page holds open at /.spool/live, for the principal lease and its
revocation and, with public, for pushed tag changes. A page with a principal partition and a
stream sends no renewal while it reads, and a revoked session reaches it in milliseconds. false
is off; true and an object are on; absent, it is on when identity is set on a host that is one
process (Node, Bun, Deno) and off on Workers, where the stream needs a hub every isolate can
reach: pass durableObjectHub from @drupflare/spool/stores/durable-object. A page without
the stream renews at its route's bound as before. The default is off for public freshness.
By default the policy is adaptive: the first lease renewal of a visible session is an ordinary
request and the second becomes the stream, so a visitor who loads documents never opens one.
'always' (or { mode: 'always' }) opens at login and whenever a tab becomes visible, for an
app that stays open.
Optionallogout
same-origin paths whose request ends the session; the worker wipes the principal store first
Optionalmeter
reads a millisecond clock for work; default performance.now, which is elapsed time and not CPU
Optionalmode
the mode for routes that do not name one; default serve. shadow never serves locally
Optionalpolicy
Security headers a pack or delta response names for a device that holds no site policy. Names
are limited to the policy list. Default: the headers of the last HTML page this server answered.
{} names no headers. With neither, publishStatic writes a stub with no policy field.
Optionalprincipal Datasets
Lets datasets hold principal ones, whose rows differ per signed-in principal and which the
device keeps sealed in that principal's partition. Off by default: a principal dataset then
throws bad-dataset. Needs identity. Unreviewed.
Optionalprovision
priors the worker uses before its own telemetry exists, and the server uses to leave out an artifact whose transfer its expected reuse does not repay
Optionalresources
Resources from defineResource: their item families join routes, and their writes are sent to
the server and answered with the rows they changed as Spool-Delta. Needs bundles for the
device to keep its pack current; the writes themselves work without it.
routes
Optionalshadow Sample
the share of views, 0 to 1, that run in shadow while the mode is serve; default 0
Optionalsink
Optionalstamp
A counter the stub carries, a non-negative integer or a function that returns one, read on each stub request. The stub's bytes change when it does, so advance it at each publish or each lease period. Absent, the stub's bytes are the same as before the option existed.
store
Optionalthird Party
the opt-in worker cache for versioned cross-origin files
Optionalviews
whether the worker queues a spool.view per page view; default true with a sink, false
without one
Optionalwork
records the time each request took, by route; read it with work.samples()
Optionalworker
a bundled worker to serve in place of the embedded one, such as a bundle of serve(config, renderers) from @drupflare/spool/sw; it finds the config in self.__SPOOL_CONFIG__
Optionalworker Mode
never keeps every read in the page: the ring names no worker and the page registers none.
auto (default) registers the worker, except on WebKit for a page that carries a ring: WebKit
checks the worker script on each navigation (WebKit bug 332455), so those pages keep every
read in the page. always registers the worker on WebKit too.
Optionalwrites
Declared last-value writes for principal routes, from defineWrite. Off unless enabled is
true: the worker then queues nothing and /.spool/write answers writes-off. Needs identity.
Unreviewed.
what
createSpooltakes