Type Alias Spool
config: SwConfig;
decorate(
request: Request,
response: Response,
options?: DecorateOptions,
): Promise<Response>;
handle(
request: Request,
next: (request: Request) => Response | Promise<Response>,
): Promise<Response>;
invalidate(
tags: readonly string[],
options?: { drop?: readonly string[] },
): Promise<number>;
partition(principal: string): Promise<string>;
publish(url: URL): Promise<{ bytes: number; version: number }>;
publishStatic(
sink: StaticSink,
options?: PublishStaticOptions,
): Promise<PublishStaticResult>;
respond(request: Request): Promise<Response | undefined>;
revoke(principal: string): Promise<void>;
stub(): Response;
stub(request: Request): Promise<Response>;
}
Methods
decorate
-
adds the envelope headers and the client tag to a response the app produced. A public route's response that sets a cookie, is
privateorno-store, or varies by anything but encoding and cookies is returned unchanged.Parameters
- request: Request
- response: Response
Optionaloptions: DecorateOptions
Returns Promise<Response>
handle
invalidate
-
bumps the vector after a write;
dropalso removes artifacts by idParameters
- tags: readonly string[]
Optionaloptions: { drop?: readonly string[] }
Returns Promise<number>
partition
-
The
Spool-Partitionvalue for a principal. A login or account-switch handler sets it on its own response, since the request it answers still carries the old identity: the worker then swaps its store before any local view can read the old one.Parameters
- principal: string
Returns Promise<string>
publish
-
Builds the pack at the store cursor and keeps it in
bundles. Returns{ version, bytes }. A version already holding other bytes is refused, so callinvalidateafter a data change.urlis what the seed functions receive.Parameters
- url: URL
Returns Promise<{ bytes: number; version: number }>
publish Static
-
Writes the static tier to
sink: the page runtime, the stub, the packs held for the store cursor and the deltas to it, and a_headersfile. A host that serves these files answers them with no Worker invocation. Packs and runtime are immutable, so a sink that reports them withhaskeeps the ones already there. Build the packs withpublishfirst. Each pack also gets its boot script, unlesscdnis set. The stub names the site policy in this order:options.policy, thepolicyoption ofcreateSpool, the headers of the last HTML page answered,options.fallbackPolicy. With none of them the stub carries nopolicyfield, and a device renders locally after one network view that teaches it the headers;policy: 'none'in the result says so.{}names a known-empty policy.options.urlbuilds the pack at the cursor first. Returns the store cursor, the paths written and the policy source.Parameters
- sink: StaticSink
Optionaloptions: PublishStaticOptions
Returns Promise<PublishStaticResult>
respond
-
a
Responsefor/.spool/*,undefinedfor anything elseParameters
- request: Request
Returns Promise<Response | undefined>
revoke
-
Ends the live streams of a principal's partition: each gets
revokedand closes, and the page wipes the partition. Call it where the app ends a session on the server (a ban, a logout on another device, a sweep of expired sessions). It does nothing whileliveis off.Parameters
- principal: string
Returns Promise<void>
stub
-
The
/spool-sw.jsresponse. Pass the request to get anETagand a304for a matchingIf-None-Match, so a re-check of an unchanged script after the lease costs a few hundred bytes. With no request the response has no validator, as before.Returns Response
-
Parameters
- request: Request
Returns Promise<Response>
what
createSpoolreturns