@drupflare/spool 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1749 -2
- package/dist/cdn/client.js +1 -0
- package/dist/cdn/location.d.ts +11 -0
- package/dist/cdn/location.js +15 -0
- package/dist/cdn/manifest.json +16 -0
- package/dist/cdn/spool-sw.js +1 -0
- package/dist/client/entry.d.ts +1 -0
- package/dist/client/entry.js +25 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/lifecycle.d.ts +10 -0
- package/dist/client/lifecycle.js +10 -0
- package/dist/client/loads.d.ts +16 -0
- package/dist/client/loads.js +41 -0
- package/dist/client/register.d.ts +34 -0
- package/dist/client/register.js +58 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/media/embeds.d.ts +59 -0
- package/dist/media/embeds.js +120 -0
- package/dist/media/headers.d.ts +13 -0
- package/dist/media/headers.js +44 -0
- package/dist/media/html.d.ts +27 -0
- package/dist/media/html.js +93 -0
- package/dist/media/image.d.ts +222 -0
- package/dist/media/image.js +413 -0
- package/dist/media/index.d.ts +6 -0
- package/dist/media/index.js +6 -0
- package/dist/media/lazy.d.ts +26 -0
- package/dist/media/lazy.js +74 -0
- package/dist/media/responsive.d.ts +45 -0
- package/dist/media/responsive.js +98 -0
- package/dist/media/video.d.ts +30 -0
- package/dist/media/video.js +75 -0
- package/dist/node/listener.d.ts +19 -0
- package/dist/node/listener.js +76 -0
- package/dist/protocol/artifact.d.ts +54 -0
- package/dist/protocol/artifact.js +79 -0
- package/dist/protocol/assembly.d.ts +34 -0
- package/dist/protocol/assembly.js +72 -0
- package/dist/protocol/beacon.d.ts +59 -0
- package/dist/protocol/beacon.js +86 -0
- package/dist/protocol/collector.d.ts +41 -0
- package/dist/protocol/collector.js +84 -0
- package/dist/protocol/config.d.ts +89 -0
- package/dist/protocol/config.js +13 -0
- package/dist/protocol/envelope.d.ts +47 -0
- package/dist/protocol/envelope.js +162 -0
- package/dist/protocol/errors.d.ts +7 -0
- package/dist/protocol/errors.js +9 -0
- package/dist/protocol/graph.d.ts +81 -0
- package/dist/protocol/graph.js +201 -0
- package/dist/protocol/index.d.ts +19 -0
- package/dist/protocol/index.js +19 -0
- package/dist/protocol/manifest.d.ts +29 -0
- package/dist/protocol/manifest.js +94 -0
- package/dist/protocol/normalise.d.ts +20 -0
- package/dist/protocol/normalise.js +29 -0
- package/dist/protocol/pattern.d.ts +12 -0
- package/dist/protocol/pattern.js +82 -0
- package/dist/protocol/provision.d.ts +100 -0
- package/dist/protocol/provision.js +105 -0
- package/dist/protocol/route.d.ts +179 -0
- package/dist/protocol/route.js +135 -0
- package/dist/protocol/sync.d.ts +31 -0
- package/dist/protocol/sync.js +87 -0
- package/dist/protocol/tag.d.ts +12 -0
- package/dist/protocol/tag.js +26 -0
- package/dist/protocol/template/compile.d.ts +35 -0
- package/dist/protocol/template/compile.js +82 -0
- package/dist/protocol/template/interpret.d.ts +9 -0
- package/dist/protocol/template/interpret.js +82 -0
- package/dist/protocol/vector.d.ts +32 -0
- package/dist/protocol/vector.js +56 -0
- package/dist/protocol/view.d.ts +110 -0
- package/dist/protocol/view.js +201 -0
- package/dist/proxy/dictionary.d.ts +58 -0
- package/dist/proxy/dictionary.js +197 -0
- package/dist/proxy/eligible.d.ts +45 -0
- package/dist/proxy/eligible.js +96 -0
- package/dist/proxy/index.d.ts +5 -0
- package/dist/proxy/index.js +5 -0
- package/dist/proxy/proxy.d.ts +133 -0
- package/dist/proxy/proxy.js +507 -0
- package/dist/proxy/purge.d.ts +10 -0
- package/dist/proxy/purge.js +66 -0
- package/dist/proxy/tags.d.ts +8 -0
- package/dist/proxy/tags.js +36 -0
- package/dist/report/derive.d.ts +223 -0
- package/dist/report/derive.js +494 -0
- package/dist/report/economics.d.ts +14 -0
- package/dist/report/economics.js +24 -0
- package/dist/report/index.d.ts +9 -0
- package/dist/report/index.js +9 -0
- package/dist/report/inputs.d.ts +141 -0
- package/dist/report/inputs.js +216 -0
- package/dist/report/ledger.d.ts +169 -0
- package/dist/report/ledger.js +278 -0
- package/dist/report/measurement.d.ts +48 -0
- package/dist/report/measurement.js +117 -0
- package/dist/report/model.d.ts +42 -0
- package/dist/report/model.js +74 -0
- package/dist/report/thirdparty.d.ts +62 -0
- package/dist/report/thirdparty.js +107 -0
- package/dist/report/traffic.d.ts +140 -0
- package/dist/report/traffic.js +228 -0
- package/dist/report/trim.d.ts +81 -0
- package/dist/report/trim.js +105 -0
- package/dist/server/beacon.d.ts +20 -0
- package/dist/server/beacon.js +47 -0
- package/dist/server/embedded.d.ts +6 -0
- package/dist/server/embedded.js +6 -0
- package/dist/server/ga4.d.ts +70 -0
- package/dist/server/ga4.js +165 -0
- package/dist/server/identity.d.ts +12 -0
- package/dist/server/identity.js +17 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +7 -0
- package/dist/server/sink.d.ts +56 -0
- package/dist/server/sink.js +133 -0
- package/dist/server/size.d.ts +7 -0
- package/dist/server/size.js +18 -0
- package/dist/server/spool.d.ts +97 -0
- package/dist/server/spool.js +463 -0
- package/dist/server/stub.d.ts +9 -0
- package/dist/server/stub.js +19 -0
- package/dist/server/sync.d.ts +12 -0
- package/dist/server/sync.js +48 -0
- package/dist/server/work.d.ts +22 -0
- package/dist/server/work.js +30 -0
- package/dist/stores/durable-object.d.ts +19 -0
- package/dist/stores/durable-object.js +53 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/index.js +2 -0
- package/dist/stores/memory.d.ts +4 -0
- package/dist/stores/memory.js +10 -0
- package/dist/stores/version-store.d.ts +11 -0
- package/dist/stores/version-store.js +1 -0
- package/dist/sw/analytics.d.ts +81 -0
- package/dist/sw/analytics.js +275 -0
- package/dist/sw/collect.d.ts +8 -0
- package/dist/sw/collect.js +33 -0
- package/dist/sw/core.d.ts +1 -0
- package/dist/sw/core.js +3 -0
- package/dist/sw/freshness.d.ts +15 -0
- package/dist/sw/freshness.js +20 -0
- package/dist/sw/graph/index.d.ts +67 -0
- package/dist/sw/graph/index.js +170 -0
- package/dist/sw/graph/invalidate.d.ts +23 -0
- package/dist/sw/graph/invalidate.js +109 -0
- package/dist/sw/graph/projections.d.ts +7 -0
- package/dist/sw/graph/projections.js +9 -0
- package/dist/sw/graph/records.d.ts +7 -0
- package/dist/sw/graph/records.js +9 -0
- package/dist/sw/graph/store.d.ts +32 -0
- package/dist/sw/graph/store.js +52 -0
- package/dist/sw/idb.d.ts +8 -0
- package/dist/sw/idb.js +117 -0
- package/dist/sw/index.d.ts +2 -0
- package/dist/sw/index.js +1 -0
- package/dist/sw/partition.d.ts +21 -0
- package/dist/sw/partition.js +137 -0
- package/dist/sw/policy.d.ts +8 -0
- package/dist/sw/policy.js +24 -0
- package/dist/sw/provision.d.ts +39 -0
- package/dist/sw/provision.js +61 -0
- package/dist/sw/render.d.ts +21 -0
- package/dist/sw/render.js +53 -0
- package/dist/sw/replica.d.ts +77 -0
- package/dist/sw/replica.js +299 -0
- package/dist/sw/router.d.ts +42 -0
- package/dist/sw/router.js +48 -0
- package/dist/sw/routing.d.ts +23 -0
- package/dist/sw/routing.js +48 -0
- package/dist/sw/runtime.d.ts +112 -0
- package/dist/sw/runtime.js +1070 -0
- package/dist/sw/scheduler.d.ts +83 -0
- package/dist/sw/scheduler.js +149 -0
- package/dist/sw/seal.d.ts +37 -0
- package/dist/sw/seal.js +183 -0
- package/dist/sw/serve.d.ts +15 -0
- package/dist/sw/serve.js +63 -0
- package/dist/sw/shadow.d.ts +16 -0
- package/dist/sw/shadow.js +27 -0
- package/dist/sw/static.d.ts +17 -0
- package/dist/sw/static.js +81 -0
- package/dist/sw/storage.d.ts +64 -0
- package/dist/sw/storage.js +34 -0
- package/dist/sw/thirdparty.d.ts +17 -0
- package/dist/sw/thirdparty.js +36 -0
- package/dist/trim/css.d.ts +38 -0
- package/dist/trim/css.js +328 -0
- package/dist/trim/index.d.ts +3 -0
- package/dist/trim/index.js +3 -0
- package/dist/trim/manifest.d.ts +67 -0
- package/dist/trim/manifest.js +134 -0
- package/dist/trim/tokens.d.ts +47 -0
- package/dist/trim/tokens.js +142 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/package.json +150 -5
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ProtocolError } from '../errors.js';
|
|
2
|
+
const TAG = /\{\{\{([^}]*)\}\}\}|\{\{([^}]*)\}\}/g;
|
|
3
|
+
const PATH = /^(?:this|@index|[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*)$/;
|
|
4
|
+
function parsePath(text, tag) {
|
|
5
|
+
const path = text.trim();
|
|
6
|
+
if (!PATH.test(path))
|
|
7
|
+
throw new ProtocolError('bad-template', `bad field "${path}" in ${tag}`);
|
|
8
|
+
return path === 'this' ? [] : path.split('.');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Compiles Mustache-shaped source to a JSON tree: `{{field}}` escaped, `{{{field}}}` raw (only for
|
|
12
|
+
* paths in `trusted`), `{{#each list}}`, `{{#if field}}` with an optional `{{else}}`, `{{this}}`
|
|
13
|
+
* and `{{@index}}`. There is no expression syntax, so the interpreter needs no `eval`.
|
|
14
|
+
*/
|
|
15
|
+
export function compileTemplate(input) {
|
|
16
|
+
const trusted = [...(input.trusted ?? [])];
|
|
17
|
+
const root = [];
|
|
18
|
+
const stack = [{ kind: 'root', path: [], target: root }];
|
|
19
|
+
const top = () => stack[stack.length - 1];
|
|
20
|
+
let last = 0;
|
|
21
|
+
for (const match of input.source.matchAll(TAG)) {
|
|
22
|
+
const at = match.index;
|
|
23
|
+
if (at > last)
|
|
24
|
+
top().target.push({ t: 'text', v: input.source.slice(last, at) });
|
|
25
|
+
last = at + match[0].length;
|
|
26
|
+
if (match[1] !== undefined) {
|
|
27
|
+
const p = parsePath(match[1], match[0]);
|
|
28
|
+
const name = match[1].trim();
|
|
29
|
+
if (!trusted.includes(name)) {
|
|
30
|
+
throw new ProtocolError('bad-template', `{{{${name}}}} is not a trusted field`);
|
|
31
|
+
}
|
|
32
|
+
top().target.push({ t: 'var', p, raw: true });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const body = match[2].trim();
|
|
36
|
+
if (body.startsWith('!'))
|
|
37
|
+
continue;
|
|
38
|
+
if (body === 'else') {
|
|
39
|
+
const frame = top();
|
|
40
|
+
if (frame.kind !== 'if' || !frame.owner) {
|
|
41
|
+
throw new ProtocolError('bad-template', '{{else}} outside {{#if}}');
|
|
42
|
+
}
|
|
43
|
+
frame.target = frame.owner.else;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (body.startsWith('#')) {
|
|
47
|
+
const [kind = '', ...rest] = body.slice(1).trim().split(/\s+/);
|
|
48
|
+
if (rest.length !== 1)
|
|
49
|
+
throw new ProtocolError('bad-template', `bad block ${match[0]}`);
|
|
50
|
+
const p = parsePath(rest[0], match[0]);
|
|
51
|
+
if (kind === 'each') {
|
|
52
|
+
const node = { t: 'each', p, body: [] };
|
|
53
|
+
top().target.push(node);
|
|
54
|
+
stack.push({ kind: 'each', path: p, target: node.body });
|
|
55
|
+
}
|
|
56
|
+
else if (kind === 'if') {
|
|
57
|
+
const node = { t: 'if', p, then: [], else: [] };
|
|
58
|
+
top().target.push(node);
|
|
59
|
+
stack.push({ kind: 'if', path: p, target: node.then, owner: node });
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
throw new ProtocolError('bad-template', `unknown block "${kind}"`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (body.startsWith('/')) {
|
|
66
|
+
const kind = body.slice(1).trim();
|
|
67
|
+
const frame = top();
|
|
68
|
+
if (frame.kind === 'root' || frame.kind !== kind) {
|
|
69
|
+
throw new ProtocolError('bad-template', `unexpected {{/${kind}}}`);
|
|
70
|
+
}
|
|
71
|
+
stack.pop();
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
top().target.push({ t: 'var', p: parsePath(body, match[0]), raw: false });
|
|
75
|
+
}
|
|
76
|
+
if (last < input.source.length)
|
|
77
|
+
top().target.push({ t: 'text', v: input.source.slice(last) });
|
|
78
|
+
if (stack.length > 1) {
|
|
79
|
+
throw new ProtocolError('bad-template', `unclosed {{#${top().kind}}} block`);
|
|
80
|
+
}
|
|
81
|
+
return { v: 1, trusted, nodes: root };
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CompiledTemplate } from './compile.js';
|
|
2
|
+
/** escapes the five characters that matter in HTML text and quoted attributes */
|
|
3
|
+
export declare function escapeHtml(value: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Renders a compiled template against JSON data. A name resolves only to an own property of the
|
|
6
|
+
* data, so `constructor` and `__proto__` print nothing, and a raw field must be in the template's
|
|
7
|
+
* trusted list even if the tree was edited after compilation.
|
|
8
|
+
*/
|
|
9
|
+
export declare function interpretTemplate(template: CompiledTemplate, data: unknown): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ProtocolError } from '../errors.js';
|
|
2
|
+
const ESCAPES = {
|
|
3
|
+
'&': '&',
|
|
4
|
+
'<': '<',
|
|
5
|
+
'>': '>',
|
|
6
|
+
'"': '"',
|
|
7
|
+
"'": '''
|
|
8
|
+
};
|
|
9
|
+
/** escapes the five characters that matter in HTML text and quoted attributes */
|
|
10
|
+
export function escapeHtml(value) {
|
|
11
|
+
return value.replace(/[&<>"']/g, (c) => ESCAPES[c]);
|
|
12
|
+
}
|
|
13
|
+
function own(value, key) {
|
|
14
|
+
if (value === null || typeof value !== 'object')
|
|
15
|
+
return undefined;
|
|
16
|
+
return Object.hasOwn(value, key) ? value[key] : undefined;
|
|
17
|
+
}
|
|
18
|
+
function lookup(path, frames) {
|
|
19
|
+
const innermost = frames[frames.length - 1];
|
|
20
|
+
if (path.length === 0)
|
|
21
|
+
return innermost.value;
|
|
22
|
+
if (path[0] === '@index')
|
|
23
|
+
return innermost.index;
|
|
24
|
+
for (let i = frames.length - 1; i >= 0; i--) {
|
|
25
|
+
const frame = frames[i];
|
|
26
|
+
if (own(frame.value, path[0]) === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
return path.reduce((value, key) => own(value, key), frame.value);
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
function truthy(value) {
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value.length > 0;
|
|
35
|
+
return !(value === undefined ||
|
|
36
|
+
value === null ||
|
|
37
|
+
value === false ||
|
|
38
|
+
value === '' ||
|
|
39
|
+
value === 0);
|
|
40
|
+
}
|
|
41
|
+
function text(value) {
|
|
42
|
+
return typeof value === 'string' || typeof value === 'number' ? String(value) : '';
|
|
43
|
+
}
|
|
44
|
+
function run(nodes, frames, trusted) {
|
|
45
|
+
let out = '';
|
|
46
|
+
for (const node of nodes) {
|
|
47
|
+
if (node.t === 'text')
|
|
48
|
+
out += node.v;
|
|
49
|
+
else if (node.t === 'var') {
|
|
50
|
+
const value = text(lookup(node.p, frames));
|
|
51
|
+
if (!node.raw)
|
|
52
|
+
out += escapeHtml(value);
|
|
53
|
+
else if (trusted.has(node.p.join('.')))
|
|
54
|
+
out += value;
|
|
55
|
+
else
|
|
56
|
+
throw new ProtocolError('bad-template', `{{{${node.p.join('.')}}}} is not trusted`);
|
|
57
|
+
}
|
|
58
|
+
else if (node.t === 'if') {
|
|
59
|
+
out += run(truthy(lookup(node.p, frames)) ? node.then : node.else, frames, trusted);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const list = lookup(node.p, frames);
|
|
63
|
+
if (!Array.isArray(list))
|
|
64
|
+
continue;
|
|
65
|
+
list.forEach((value, index) => {
|
|
66
|
+
out += run(node.body, [...frames, { value, index }], trusted);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Renders a compiled template against JSON data. A name resolves only to an own property of the
|
|
74
|
+
* data, so `constructor` and `__proto__` print nothing, and a raw field must be in the template's
|
|
75
|
+
* trusted list even if the tree was edited after compilation.
|
|
76
|
+
*/
|
|
77
|
+
export function interpretTemplate(template, data) {
|
|
78
|
+
if (template.v !== 1) {
|
|
79
|
+
throw new ProtocolError('bad-template', `unknown template version ${String(template.v)}`);
|
|
80
|
+
}
|
|
81
|
+
return run(template.nodes, [{ value: data, index: 0 }], new Set(template.trusted));
|
|
82
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** the tags that changed after a cursor, each with the cursor value of its last change */
|
|
2
|
+
export type VectorDiff = {
|
|
3
|
+
cursor: number;
|
|
4
|
+
changed: Record<string, number>;
|
|
5
|
+
/** the asked-for cursor is ahead of this vector, so the holder lost state and must start over */
|
|
6
|
+
reset: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** a vector as JSON: the cursor and every tag's version */
|
|
9
|
+
export type VectorSnapshot = {
|
|
10
|
+
cursor: number;
|
|
11
|
+
versions: Record<string, number>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Tag to counter, with one cursor that only moves forward. A bump moves the cursor once and stamps
|
|
15
|
+
* every tag in it with the new value, so a tag's version is the cursor at its last change and
|
|
16
|
+
* `diff(from)` is every tag stamped after `from`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class VersionVector {
|
|
19
|
+
#private;
|
|
20
|
+
/** rebuilds a vector from {@link VersionVector.snapshot} */
|
|
21
|
+
static from(snapshot: VectorSnapshot): VersionVector;
|
|
22
|
+
/** the version of the most recent bump */
|
|
23
|
+
get cursor(): number;
|
|
24
|
+
/** the cursor at which `tag` last changed, or 0 when it never has */
|
|
25
|
+
version(tag: string): number;
|
|
26
|
+
/** records a change to `tags` and returns the new cursor; no tags is no change */
|
|
27
|
+
bump(tags: readonly string[]): number;
|
|
28
|
+
/** every tag changed after `from` */
|
|
29
|
+
diff(from: number): VectorDiff;
|
|
30
|
+
/** the vector as JSON */
|
|
31
|
+
snapshot(): VectorSnapshot;
|
|
32
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ProtocolError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tag to counter, with one cursor that only moves forward. A bump moves the cursor once and stamps
|
|
4
|
+
* every tag in it with the new value, so a tag's version is the cursor at its last change and
|
|
5
|
+
* `diff(from)` is every tag stamped after `from`.
|
|
6
|
+
*/
|
|
7
|
+
export class VersionVector {
|
|
8
|
+
#cursor = 0;
|
|
9
|
+
#versions = new Map();
|
|
10
|
+
/** rebuilds a vector from {@link VersionVector.snapshot} */
|
|
11
|
+
static from(snapshot) {
|
|
12
|
+
const vector = new VersionVector();
|
|
13
|
+
if (!Number.isSafeInteger(snapshot.cursor) || snapshot.cursor < 0) {
|
|
14
|
+
throw new ProtocolError('bad-sync', 'snapshot cursor must be a non-negative integer');
|
|
15
|
+
}
|
|
16
|
+
vector.#cursor = snapshot.cursor;
|
|
17
|
+
for (const [tag, version] of Object.entries(snapshot.versions)) {
|
|
18
|
+
if (!Number.isSafeInteger(version) || version < 1 || version > snapshot.cursor) {
|
|
19
|
+
throw new ProtocolError('bad-sync', `snapshot version for "${tag}" is out of range`);
|
|
20
|
+
}
|
|
21
|
+
vector.#versions.set(tag, version);
|
|
22
|
+
}
|
|
23
|
+
return vector;
|
|
24
|
+
}
|
|
25
|
+
/** the version of the most recent bump */
|
|
26
|
+
get cursor() {
|
|
27
|
+
return this.#cursor;
|
|
28
|
+
}
|
|
29
|
+
/** the cursor at which `tag` last changed, or 0 when it never has */
|
|
30
|
+
version(tag) {
|
|
31
|
+
return this.#versions.get(tag) ?? 0;
|
|
32
|
+
}
|
|
33
|
+
/** records a change to `tags` and returns the new cursor; no tags is no change */
|
|
34
|
+
bump(tags) {
|
|
35
|
+
if (tags.length === 0)
|
|
36
|
+
return this.#cursor;
|
|
37
|
+
this.#cursor += 1;
|
|
38
|
+
for (const tag of tags)
|
|
39
|
+
this.#versions.set(tag, this.#cursor);
|
|
40
|
+
return this.#cursor;
|
|
41
|
+
}
|
|
42
|
+
/** every tag changed after `from` */
|
|
43
|
+
diff(from) {
|
|
44
|
+
if (from > this.#cursor)
|
|
45
|
+
return { cursor: this.#cursor, changed: this.#all(), reset: true };
|
|
46
|
+
const changed = Object.fromEntries([...this.#versions].filter(([, version]) => version > from));
|
|
47
|
+
return { cursor: this.#cursor, changed, reset: false };
|
|
48
|
+
}
|
|
49
|
+
/** the vector as JSON */
|
|
50
|
+
snapshot() {
|
|
51
|
+
return { cursor: this.#cursor, versions: this.#all() };
|
|
52
|
+
}
|
|
53
|
+
#all() {
|
|
54
|
+
return Object.fromEntries(this.#versions);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Scope } from './artifact.js';
|
|
2
|
+
import type { BeaconEvent } from './beacon.js';
|
|
3
|
+
import type { Strategy } from './route.js';
|
|
4
|
+
/** `serve` answers views locally; `shadow` decides and compares but lets the network answer */
|
|
5
|
+
export type Mode = 'serve' | 'shadow';
|
|
6
|
+
/** how a view was answered; `shadow` means the network answered and the reason is what local would have done */
|
|
7
|
+
export type ViewTier = 'local' | 'local-revalidate' | 'network' | 'fallback' | 'shadow';
|
|
8
|
+
/**
|
|
9
|
+
* Why a view went the way it did, from the worker's first check to its last: nothing stored
|
|
10
|
+
* (`cold`), a route the worker never serves (`principal`), within the bound (`fresh`), past a
|
|
11
|
+
* soft bound with the sync left for a network moment (`soft-deferred`) or sent now (`soft-sync`),
|
|
12
|
+
* past a hard bound and synced first (`hard-sync`), past it offline and shown anyway
|
|
13
|
+
* (`offline-stale`), a stored copy a change outdated (`invalidated`, `stale-after-sync`), a hard
|
|
14
|
+
* route offline that refuses (`hard-refused`), or a render the worker declined (`refused`). A
|
|
15
|
+
* page the visitor had not opened, shown with no request from a catalogue entry that came with an
|
|
16
|
+
* earlier flush, is `catalogue`.
|
|
17
|
+
*/
|
|
18
|
+
export type ViewReason = 'cold' | 'principal' | 'fresh' | 'catalogue' | 'soft-deferred' | 'soft-sync' | 'hard-sync' | 'offline-stale' | 'invalidated' | 'stale-after-sync' | 'hard-refused' | 'refused';
|
|
19
|
+
/** the tier a reason has when the worker serves; a shadow view keeps the reason and drops the tier */
|
|
20
|
+
export declare const REASON_TIER: Record<ViewReason, Exclude<ViewTier, 'shadow'>>;
|
|
21
|
+
/** the layout engine, which decides what the browser does with a worker: not the vendor */
|
|
22
|
+
export type Engine = 'chromium' | 'firefox' | 'webkit' | 'other';
|
|
23
|
+
/** one page view on a declared route, as the worker reports it in `spool.view` */
|
|
24
|
+
export type ViewEvent = {
|
|
25
|
+
/** names this view, so the page's later report of its cross-origin loads can be joined to it */
|
|
26
|
+
id: string;
|
|
27
|
+
tier: ViewTier;
|
|
28
|
+
reason: ViewReason;
|
|
29
|
+
/** seconds since the stored copy was last known good, or null when none was stored */
|
|
30
|
+
staleSec: number | null;
|
|
31
|
+
engine: Engine;
|
|
32
|
+
scope: Scope;
|
|
33
|
+
strategy: Strategy;
|
|
34
|
+
/** the matched route pattern */
|
|
35
|
+
route: string;
|
|
36
|
+
/** whether the local render differed from the network one; null when no local render was made */
|
|
37
|
+
mismatch: boolean | null;
|
|
38
|
+
/** milliseconds since this worker instance started */
|
|
39
|
+
swAgeMs: number;
|
|
40
|
+
/** milliseconds since this worker's previous view, or null for its first */
|
|
41
|
+
gapMs: number | null;
|
|
42
|
+
/**
|
|
43
|
+
* Where the visitor came from: the referring page's route pattern when it is same-origin and
|
|
44
|
+
* matches a declared route, `external` for a cross-origin referrer, omitted otherwise. Never a path.
|
|
45
|
+
*/
|
|
46
|
+
from?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Cross-origin resources the page loaded during the view, as the page runtime counted them from
|
|
49
|
+
* `PerformanceResourceTiming` when it was hidden. Without `Timing-Allow-Origin` such an entry has a
|
|
50
|
+
* transfer size of 0 whether it came from cache or network, so a cache hit counts: this is an upper
|
|
51
|
+
* bound on cross-origin network requests. Null until the page reports, and when it never does.
|
|
52
|
+
*/
|
|
53
|
+
crossOriginLoads: number | null;
|
|
54
|
+
};
|
|
55
|
+
/** a view with the device time it was recorded at, epoch milliseconds */
|
|
56
|
+
export type TimedView = ViewEvent & {
|
|
57
|
+
at: number;
|
|
58
|
+
/** cross-origin loads by origin, when the page's report named them */
|
|
59
|
+
crossOriginOrigins?: Record<string, number>;
|
|
60
|
+
};
|
|
61
|
+
/** longest route pattern a view may name; a longer one is not read as a view */
|
|
62
|
+
export declare const MAX_ROUTE_CHARS = 256;
|
|
63
|
+
/** the `from` of a view whose referrer is another origin */
|
|
64
|
+
export declare const FROM_EXTERNAL = "external";
|
|
65
|
+
/** the `path` a view carries inside a beacon batch */
|
|
66
|
+
export declare const VIEW_PATH = "/.spool/view";
|
|
67
|
+
/** the `path` of the page's later report of a view's cross-origin loads */
|
|
68
|
+
export declare const LOADS_PATH = "/.spool/loads";
|
|
69
|
+
/** most origins a loads report names; the page keeps the busiest */
|
|
70
|
+
export declare const MAX_LOAD_ORIGINS = 32;
|
|
71
|
+
/**
|
|
72
|
+
* a page's count of the cross-origin loads of view `view`, and how many came from each origin
|
|
73
|
+
* (origins only, never paths or query strings)
|
|
74
|
+
*/
|
|
75
|
+
export type LoadsReport = {
|
|
76
|
+
view: string;
|
|
77
|
+
count: number;
|
|
78
|
+
at: number;
|
|
79
|
+
origins?: Record<string, number>;
|
|
80
|
+
};
|
|
81
|
+
/** a loads report as a queued beacon */
|
|
82
|
+
export declare function loadsToBeacon(view: string, count: number, at: number, origins?: Record<string, number>): BeaconEvent;
|
|
83
|
+
/** the report inside a beacon, or null when it is another request or does not validate */
|
|
84
|
+
export declare function loadsFromBeacon(event: BeaconEvent): LoadsReport | null;
|
|
85
|
+
/**
|
|
86
|
+
* The views in `events` with their cross-origin counts filled in from the loads reports among
|
|
87
|
+
* them. A report that arrives in a later batch than its view needs the whole stream, so pass every
|
|
88
|
+
* event; the last report for a view wins. A view with no report keeps null.
|
|
89
|
+
*/
|
|
90
|
+
export declare function viewsWithLoads(events: readonly BeaconEvent[]): TimedView[];
|
|
91
|
+
/** the view as a queued beacon, so it rides the same flush as every other held request */
|
|
92
|
+
export declare function viewToBeacon(view: ViewEvent, at: number): BeaconEvent;
|
|
93
|
+
/** the view inside a beacon, or null when it is another request or does not validate */
|
|
94
|
+
export declare function viewFromBeacon(event: BeaconEvent): TimedView | null;
|
|
95
|
+
/**
|
|
96
|
+
* The engine behind a user agent. Every browser on iOS runs WebKit, whatever its name says, so
|
|
97
|
+
* the iOS tokens are checked first.
|
|
98
|
+
*/
|
|
99
|
+
export declare function engineOf(userAgent: string): Engine;
|
|
100
|
+
/** where a view stopped on the way to a zero-network render */
|
|
101
|
+
export type Funnel = 'ineligible' | 'cold' | 'unusable' | 'local';
|
|
102
|
+
/**
|
|
103
|
+
* Where a view stopped: on a route the worker never serves (`ineligible`), with nothing stored
|
|
104
|
+
* (`cold`), with a copy it could not show without the network (`unusable`), or shown with no
|
|
105
|
+
* request (`local`). A view is local only when no cross-origin resource loaded during it, which the
|
|
106
|
+
* page must have reported as 0: a count above 0 or no report makes it `unusable`, whatever the worker
|
|
107
|
+
* did. A shadow view that would have been local but rendered differently from the network is
|
|
108
|
+
* `unusable` too.
|
|
109
|
+
*/
|
|
110
|
+
export declare function funnelOf(view: Pick<ViewEvent, 'reason' | 'mismatch' | 'crossOriginLoads'>): Funnel;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/** the tier a reason has when the worker serves; a shadow view keeps the reason and drops the tier */
|
|
2
|
+
export const REASON_TIER = {
|
|
3
|
+
cold: 'network',
|
|
4
|
+
principal: 'network',
|
|
5
|
+
fresh: 'local',
|
|
6
|
+
catalogue: 'local',
|
|
7
|
+
'soft-deferred': 'local',
|
|
8
|
+
'soft-sync': 'local-revalidate',
|
|
9
|
+
'hard-sync': 'local-revalidate',
|
|
10
|
+
'offline-stale': 'local-revalidate',
|
|
11
|
+
invalidated: 'fallback',
|
|
12
|
+
'stale-after-sync': 'fallback',
|
|
13
|
+
'hard-refused': 'fallback',
|
|
14
|
+
refused: 'fallback'
|
|
15
|
+
};
|
|
16
|
+
/** longest route pattern a view may name; a longer one is not read as a view */
|
|
17
|
+
export const MAX_ROUTE_CHARS = 256;
|
|
18
|
+
/** the `from` of a view whose referrer is another origin */
|
|
19
|
+
export const FROM_EXTERNAL = 'external';
|
|
20
|
+
/** the `path` a view carries inside a beacon batch */
|
|
21
|
+
export const VIEW_PATH = '/.spool/view';
|
|
22
|
+
/** the `path` of the page's later report of a view's cross-origin loads */
|
|
23
|
+
export const LOADS_PATH = '/.spool/loads';
|
|
24
|
+
/** most origins a loads report names; the page keeps the busiest */
|
|
25
|
+
export const MAX_LOAD_ORIGINS = 32;
|
|
26
|
+
/** a loads report as a queued beacon */
|
|
27
|
+
export function loadsToBeacon(view, count, at, origins) {
|
|
28
|
+
return {
|
|
29
|
+
path: LOADS_PATH,
|
|
30
|
+
body: JSON.stringify(origins && Object.keys(origins).length > 0 ? { view, count, origins } : { view, count }),
|
|
31
|
+
contentType: 'application/json',
|
|
32
|
+
at
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** the report inside a beacon, or null when it is another request or does not validate */
|
|
36
|
+
export function loadsFromBeacon(event) {
|
|
37
|
+
if (event.path !== LOADS_PATH)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
const { view, count, origins } = JSON.parse(event.body);
|
|
41
|
+
if (typeof view !== 'string' || view === '' || view.length > 64)
|
|
42
|
+
return null;
|
|
43
|
+
if (typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0)
|
|
44
|
+
return null;
|
|
45
|
+
if (origins === undefined)
|
|
46
|
+
return { view, count, at: event.at };
|
|
47
|
+
if (typeof origins !== 'object' || origins === null || Array.isArray(origins))
|
|
48
|
+
return null;
|
|
49
|
+
const entries = Object.entries(origins);
|
|
50
|
+
if (entries.length > MAX_LOAD_ORIGINS)
|
|
51
|
+
return null;
|
|
52
|
+
for (const [name, n] of entries) {
|
|
53
|
+
if (name.length > 253 || typeof n !== 'number' || !Number.isSafeInteger(n) || n < 1) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { view, count, at: event.at, origins: origins };
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The views in `events` with their cross-origin counts filled in from the loads reports among
|
|
65
|
+
* them. A report that arrives in a later batch than its view needs the whole stream, so pass every
|
|
66
|
+
* event; the last report for a view wins. A view with no report keeps null.
|
|
67
|
+
*/
|
|
68
|
+
export function viewsWithLoads(events) {
|
|
69
|
+
const counts = new Map();
|
|
70
|
+
const named = new Map();
|
|
71
|
+
for (const event of events) {
|
|
72
|
+
const report = loadsFromBeacon(event);
|
|
73
|
+
if (!report)
|
|
74
|
+
continue;
|
|
75
|
+
counts.set(report.view, report.count);
|
|
76
|
+
if (report.origins)
|
|
77
|
+
named.set(report.view, report.origins);
|
|
78
|
+
else
|
|
79
|
+
named.delete(report.view);
|
|
80
|
+
}
|
|
81
|
+
return events.flatMap((event) => {
|
|
82
|
+
const view = viewFromBeacon(event);
|
|
83
|
+
if (!view)
|
|
84
|
+
return [];
|
|
85
|
+
const count = counts.get(view.id);
|
|
86
|
+
if (count === undefined)
|
|
87
|
+
return [view];
|
|
88
|
+
const origins = named.get(view.id);
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
...view,
|
|
92
|
+
crossOriginLoads: count,
|
|
93
|
+
...(origins ? { crossOriginOrigins: origins } : {})
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const STRATEGIES = ['assembly', 'template', 'static', 'projection', 'data'];
|
|
99
|
+
const TIERS = [
|
|
100
|
+
'local',
|
|
101
|
+
'local-revalidate',
|
|
102
|
+
'network',
|
|
103
|
+
'fallback',
|
|
104
|
+
'shadow'
|
|
105
|
+
];
|
|
106
|
+
const ENGINES = ['chromium', 'firefox', 'webkit', 'other'];
|
|
107
|
+
/** the view as a queued beacon, so it rides the same flush as every other held request */
|
|
108
|
+
export function viewToBeacon(view, at) {
|
|
109
|
+
return { path: VIEW_PATH, body: JSON.stringify(view), contentType: 'application/json', at };
|
|
110
|
+
}
|
|
111
|
+
function nullableNumber(value) {
|
|
112
|
+
return value === null || (typeof value === 'number' && Number.isFinite(value));
|
|
113
|
+
}
|
|
114
|
+
/** the view inside a beacon, or null when it is another request or does not validate */
|
|
115
|
+
export function viewFromBeacon(event) {
|
|
116
|
+
if (event.path !== VIEW_PATH)
|
|
117
|
+
return null;
|
|
118
|
+
let value;
|
|
119
|
+
try {
|
|
120
|
+
value = JSON.parse(event.body);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
if (typeof value !== 'object' || value === null)
|
|
126
|
+
return null;
|
|
127
|
+
const { id, tier, reason, staleSec, engine, scope, strategy, route, mismatch, swAgeMs, gapMs, from, crossOriginLoads } = value;
|
|
128
|
+
if (typeof id !== 'string' || id === '' || id.length > 64)
|
|
129
|
+
return null;
|
|
130
|
+
if (crossOriginLoads !== null &&
|
|
131
|
+
(!Number.isSafeInteger(crossOriginLoads) || crossOriginLoads < 0)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (typeof tier !== 'string' || !TIERS.includes(tier))
|
|
135
|
+
return null;
|
|
136
|
+
if (typeof reason !== 'string' || !Object.hasOwn(REASON_TIER, reason))
|
|
137
|
+
return null;
|
|
138
|
+
if (typeof engine !== 'string' || !ENGINES.includes(engine))
|
|
139
|
+
return null;
|
|
140
|
+
if (scope !== 'public' && scope !== 'principal')
|
|
141
|
+
return null;
|
|
142
|
+
if (!STRATEGIES.includes(strategy))
|
|
143
|
+
return null;
|
|
144
|
+
if (typeof route !== 'string' || route.length > MAX_ROUTE_CHARS)
|
|
145
|
+
return null;
|
|
146
|
+
if (mismatch !== null && typeof mismatch !== 'boolean')
|
|
147
|
+
return null;
|
|
148
|
+
if (!nullableNumber(staleSec) || !nullableNumber(gapMs))
|
|
149
|
+
return null;
|
|
150
|
+
if (typeof swAgeMs !== 'number' || !Number.isFinite(swAgeMs))
|
|
151
|
+
return null;
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
crossOriginLoads: crossOriginLoads,
|
|
155
|
+
tier: tier,
|
|
156
|
+
reason: reason,
|
|
157
|
+
staleSec,
|
|
158
|
+
engine: engine,
|
|
159
|
+
scope,
|
|
160
|
+
strategy: strategy,
|
|
161
|
+
route,
|
|
162
|
+
mismatch,
|
|
163
|
+
swAgeMs,
|
|
164
|
+
gapMs,
|
|
165
|
+
...(typeof from === 'string' && from !== '' && from.length <= MAX_ROUTE_CHARS
|
|
166
|
+
? { from }
|
|
167
|
+
: {}),
|
|
168
|
+
at: event.at
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The engine behind a user agent. Every browser on iOS runs WebKit, whatever its name says, so
|
|
173
|
+
* the iOS tokens are checked first.
|
|
174
|
+
*/
|
|
175
|
+
export function engineOf(userAgent) {
|
|
176
|
+
if (/\b(?:CriOS|FxiOS|EdgiOS|OPiOS)\//.test(userAgent))
|
|
177
|
+
return 'webkit';
|
|
178
|
+
if (/\bFirefox\//.test(userAgent))
|
|
179
|
+
return 'firefox';
|
|
180
|
+
if (/\b(?:Chrome|Chromium)\//.test(userAgent))
|
|
181
|
+
return 'chromium';
|
|
182
|
+
if (/\bSafari\//.test(userAgent))
|
|
183
|
+
return 'webkit';
|
|
184
|
+
return 'other';
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Where a view stopped: on a route the worker never serves (`ineligible`), with nothing stored
|
|
188
|
+
* (`cold`), with a copy it could not show without the network (`unusable`), or shown with no
|
|
189
|
+
* request (`local`). A view is local only when no cross-origin resource loaded during it, which the
|
|
190
|
+
* page must have reported as 0: a count above 0 or no report makes it `unusable`, whatever the worker
|
|
191
|
+
* did. A shadow view that would have been local but rendered differently from the network is
|
|
192
|
+
* `unusable` too.
|
|
193
|
+
*/
|
|
194
|
+
export function funnelOf(view) {
|
|
195
|
+
if (view.reason === 'principal')
|
|
196
|
+
return 'ineligible';
|
|
197
|
+
if (view.reason === 'cold')
|
|
198
|
+
return 'cold';
|
|
199
|
+
const strict = REASON_TIER[view.reason] === 'local' && view.mismatch !== true;
|
|
200
|
+
return strict && view.crossOriginLoads === 0 ? 'local' : 'unusable';
|
|
201
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Gate } from './eligible.js';
|
|
2
|
+
/** the content codings of RFC 9842: Brotli (`dcb`) and Zstandard (`dcz`) against a dictionary */
|
|
3
|
+
export type DictionaryFormat = 'dcb' | 'dcz';
|
|
4
|
+
/**
|
|
5
|
+
* Compresses `input` against `dictionary` and returns the compressed stream only. spool adds the
|
|
6
|
+
* coding's header (the magic bytes and the SHA-256 of the dictionary). For `dcz` the dictionary is a
|
|
7
|
+
* raw content dictionary and the window must stay at or under 8 MiB or 1.25 times the dictionary,
|
|
8
|
+
* whichever is larger. For `dcb` it is a Brotli prefix dictionary. It throws for a format it cannot
|
|
9
|
+
* produce, and the proxy then answers with the plain body.
|
|
10
|
+
*/
|
|
11
|
+
export type DictionaryEncoder = (dictionary: Uint8Array, input: Uint8Array, format: DictionaryFormat) => Promise<Uint8Array>;
|
|
12
|
+
/** what `spoolProxy({ dictionary })` takes */
|
|
13
|
+
export type DictionaryOptions = {
|
|
14
|
+
/** produces the compressed stream; see {@link DictionaryEncoder} */
|
|
15
|
+
encoder: DictionaryEncoder;
|
|
16
|
+
/** the paths that become and use dictionaries, tested against the pathname; default `/\.(?:css|m?js)$/i` */
|
|
17
|
+
match?: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* Which of those responses register as dictionaries, as a function of the pathname, a regular
|
|
20
|
+
* expression or a list of them; default every one `match` accepts. The others get no
|
|
21
|
+
* `Use-As-Dictionary`, so the browser holds only the bases you name, and they are still encoded
|
|
22
|
+
* against a base the request names.
|
|
23
|
+
*/
|
|
24
|
+
base?: RegExp | readonly RegExp[] | ((pathname: string) => boolean);
|
|
25
|
+
/** largest body kept as a dictionary or encoded, in bytes; default 2 MiB */
|
|
26
|
+
maxBytes?: number;
|
|
27
|
+
/** the codings offered, in order of preference, when the request accepts them; default `['dcz']` */
|
|
28
|
+
formats?: readonly DictionaryFormat[];
|
|
29
|
+
/** bytes of dictionaries kept in memory, the least recently used going first; default 16 MiB */
|
|
30
|
+
cacheBytes?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* What the proxy counted since it started: `registered` is the dictionaries stored (new content
|
|
34
|
+
* hashes), `encoded` the responses sent as `dcb` or `dcz`, `bytesIn` and `bytesOut` the plain and
|
|
35
|
+
* encoded sizes of those responses, and `skipped` the eligible responses left plain by reason:
|
|
36
|
+
* `unavailable` (the request named no dictionary the proxy holds, or accepted no coding offered),
|
|
37
|
+
* `size`, `larger` (the encoded body was not smaller), `failed` (the encoder threw), `range` and
|
|
38
|
+
* `pattern` (the path cannot be written as a `match` pattern).
|
|
39
|
+
*/
|
|
40
|
+
export type DictionaryStats = {
|
|
41
|
+
registered: number;
|
|
42
|
+
encoded: number;
|
|
43
|
+
bytesIn: number;
|
|
44
|
+
bytesOut: number;
|
|
45
|
+
skipped: Record<string, number>;
|
|
46
|
+
};
|
|
47
|
+
/** the body of a `dcb` or `dcz` response: the coding's magic bytes, the dictionary's SHA-256, then the stream */
|
|
48
|
+
export declare function frameDictionaryBody(format: DictionaryFormat, hash: Uint8Array, stream: Uint8Array): Uint8Array;
|
|
49
|
+
/** the state `spoolProxy` keeps for `dictionary`: checked options, the dictionaries and the counters */
|
|
50
|
+
export type Dictionaries = {
|
|
51
|
+
readonly stats: DictionaryStats;
|
|
52
|
+
/** whether a response could take part, by its content type and the request's method and path */
|
|
53
|
+
applies(request: Request, response: Response): boolean;
|
|
54
|
+
/** answers one origin response for `request`, registering it and encoding it when the request names a stored dictionary */
|
|
55
|
+
apply(request: Request, response: Response): Promise<Response>;
|
|
56
|
+
};
|
|
57
|
+
/** applies the defaults and checks the values; `ProtocolError('bad-route')` for one out of range */
|
|
58
|
+
export declare function createDictionaries(options: DictionaryOptions, gate: Gate): Dictionaries;
|