@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,30 @@
|
|
|
1
|
+
import type { MediaSignals } from './headers.js';
|
|
2
|
+
/**
|
|
3
|
+
* What `spoolProxy({ video })` does to `<video>` start tags. `preload` is the value to set, or
|
|
4
|
+
* `false` to leave the attribute alone. `autoplay: 'defer'` removes the `autoplay` attribute, marks
|
|
5
|
+
* the tag `data-spool-autoplay`, adds `controls` so a visitor can start the video, and sets
|
|
6
|
+
* `preload` to `none` unless the option is `metadata`. With `'keep'` the `autoplay` attribute stays,
|
|
7
|
+
* and a video that autoplays loads its file whatever `preload` says. `when` limits the rewrite to a
|
|
8
|
+
* visitor who sent `Save-Data: on` (`save-data`) or who also has an `ECT` of `slow-2g`, `2g` or
|
|
9
|
+
* `3g` (`slow`). Defaults: `preload: 'none'`, `autoplay: 'keep'`, `when: 'always'`.
|
|
10
|
+
*/
|
|
11
|
+
export type VideoOptions = {
|
|
12
|
+
preload?: 'none' | 'metadata' | false;
|
|
13
|
+
autoplay?: 'keep' | 'defer';
|
|
14
|
+
when?: 'always' | 'save-data' | 'slow';
|
|
15
|
+
};
|
|
16
|
+
/** `VideoOptions` with every default applied */
|
|
17
|
+
export type ResolvedVideoOptions = Required<VideoOptions>;
|
|
18
|
+
/** applies the defaults to `options` and refuses an unknown value with `ProtocolError('bad-route')` */
|
|
19
|
+
export declare function resolveVideoOptions(options?: VideoOptions): ResolvedVideoOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Rewrites the `<video>` start tags of `html` as `options` ask and says how many tags changed.
|
|
22
|
+
* It reads tags with `tagsOf` and skips a tag inside an HTML comment, a tag that never closes, and
|
|
23
|
+
* every element that is not `<video>`. A tag that already says what the options ask for is not
|
|
24
|
+
* counted. Everything outside the edited start tags stays byte for byte, and the edits are ASCII,
|
|
25
|
+
* so a page in another charset read one byte per character comes back the same way.
|
|
26
|
+
*/
|
|
27
|
+
export declare function rewriteVideo(html: string, options: VideoOptions, signals: MediaSignals): {
|
|
28
|
+
html: string;
|
|
29
|
+
rewritten: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ProtocolError } from '../protocol/errors.js';
|
|
2
|
+
import { appendAttributes, applyEdits, find, setValue, tagsNamed } from './html.js';
|
|
3
|
+
/** applies the defaults to `options` and refuses an unknown value with `ProtocolError('bad-route')` */
|
|
4
|
+
export function resolveVideoOptions(options = {}) {
|
|
5
|
+
const resolved = {
|
|
6
|
+
preload: options.preload ?? 'none',
|
|
7
|
+
autoplay: options.autoplay ?? 'keep',
|
|
8
|
+
when: options.when ?? 'always'
|
|
9
|
+
};
|
|
10
|
+
if (![false, 'none', 'metadata'].includes(resolved.preload)) {
|
|
11
|
+
throw new ProtocolError('bad-route', `video preload must be 'none', 'metadata' or false`);
|
|
12
|
+
}
|
|
13
|
+
if (!['keep', 'defer'].includes(resolved.autoplay)) {
|
|
14
|
+
throw new ProtocolError('bad-route', `video autoplay must be 'keep' or 'defer'`);
|
|
15
|
+
}
|
|
16
|
+
if (!['always', 'save-data', 'slow'].includes(resolved.when)) {
|
|
17
|
+
throw new ProtocolError('bad-route', `video when must be 'always', 'save-data' or 'slow'`);
|
|
18
|
+
}
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
function editsFor(html, tag, options) {
|
|
22
|
+
const edits = [];
|
|
23
|
+
const autoplay = find(tag, 'autoplay');
|
|
24
|
+
const defer = options.autoplay === 'defer' && autoplay !== undefined;
|
|
25
|
+
const target = defer ? (options.preload === 'metadata' ? 'metadata' : 'none') : options.preload;
|
|
26
|
+
const added = [];
|
|
27
|
+
if (defer) {
|
|
28
|
+
if (find(tag, 'data-spool-autoplay')) {
|
|
29
|
+
let from = autoplay.start;
|
|
30
|
+
while (from > tag.start && /\s/.test(html[from - 1]))
|
|
31
|
+
from--;
|
|
32
|
+
edits.push({ at: from, to: autoplay.end, text: '' });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
edits.push({ at: autoplay.start, to: autoplay.end, text: 'data-spool-autoplay' });
|
|
36
|
+
}
|
|
37
|
+
if (!find(tag, 'controls'))
|
|
38
|
+
added.push('controls');
|
|
39
|
+
}
|
|
40
|
+
if (target !== false) {
|
|
41
|
+
const preload = find(tag, 'preload');
|
|
42
|
+
if (!preload)
|
|
43
|
+
added.push(`preload="${target}"`);
|
|
44
|
+
else if (preload.value.trim().toLowerCase() !== target) {
|
|
45
|
+
edits.push(setValue(html, preload, target));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (added.length > 0)
|
|
49
|
+
edits.push(appendAttributes(html, tag, added));
|
|
50
|
+
return edits;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rewrites the `<video>` start tags of `html` as `options` ask and says how many tags changed.
|
|
54
|
+
* It reads tags with `tagsOf` and skips a tag inside an HTML comment, a tag that never closes, and
|
|
55
|
+
* every element that is not `<video>`. A tag that already says what the options ask for is not
|
|
56
|
+
* counted. Everything outside the edited start tags stays byte for byte, and the edits are ASCII,
|
|
57
|
+
* so a page in another charset read one byte per character comes back the same way.
|
|
58
|
+
*/
|
|
59
|
+
export function rewriteVideo(html, options, signals) {
|
|
60
|
+
const resolved = resolveVideoOptions(options);
|
|
61
|
+
const applies = resolved.when === 'always' ||
|
|
62
|
+
(resolved.when === 'save-data' ? signals.saveData : signals.slow || signals.saveData);
|
|
63
|
+
if (!applies)
|
|
64
|
+
return { html, rewritten: 0 };
|
|
65
|
+
const edits = [];
|
|
66
|
+
let rewritten = 0;
|
|
67
|
+
for (const tag of tagsNamed(html, 'video')) {
|
|
68
|
+
const tagEdits = editsFor(html, tag, resolved);
|
|
69
|
+
if (tagEdits.length === 0)
|
|
70
|
+
continue;
|
|
71
|
+
rewritten++;
|
|
72
|
+
edits.push(...tagEdits);
|
|
73
|
+
}
|
|
74
|
+
return { html: applyEdits(html, edits), rewritten };
|
|
75
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
/** a Fetch-style handler; return `undefined` to hand the request to the next Node middleware */
|
|
3
|
+
export type FetchHandler = (request: Request) => Response | undefined | Promise<Response | undefined>;
|
|
4
|
+
/** options for {@link toNodeListener} */
|
|
5
|
+
export type NodeListenerOptions = {
|
|
6
|
+
/** the origin to build request URLs from, such as `https://example.edu`; default is the Host header */
|
|
7
|
+
origin?: string;
|
|
8
|
+
};
|
|
9
|
+
/** the Fetch `Request` for a Node request */
|
|
10
|
+
export declare function toRequest(req: IncomingMessage, res: ServerResponse, options?: NodeListenerOptions): Request;
|
|
11
|
+
/** writes a Fetch `Response` to a Node response, streaming the body */
|
|
12
|
+
export declare function writeResponse(res: ServerResponse, response: Response, head?: boolean): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Bridges `node:http` to a Fetch handler, with no dependency. The result is also an Express
|
|
15
|
+
* middleware: when the handler returns `undefined` and a `next` callback exists it is called,
|
|
16
|
+
* otherwise the reply is a 404. A handler that throws gets a 500 (or the socket is destroyed if
|
|
17
|
+
* headers are already out).
|
|
18
|
+
*/
|
|
19
|
+
export declare function toNodeListener(handler: FetchHandler, options?: NodeListenerOptions): (req: IncomingMessage, res: ServerResponse, next?: (error?: unknown) => void) => Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { pipeline } from 'node:stream/promises';
|
|
3
|
+
/** the Fetch `Request` for a Node request */
|
|
4
|
+
export function toRequest(req, res, options = {}) {
|
|
5
|
+
const encrypted = req.socket.encrypted === true;
|
|
6
|
+
const origin = options.origin ?? `${encrypted ? 'https' : 'http'}://${req.headers.host ?? 'localhost'}`;
|
|
7
|
+
const headers = new Headers();
|
|
8
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
9
|
+
if (value === undefined)
|
|
10
|
+
continue;
|
|
11
|
+
for (const v of Array.isArray(value) ? value : [value])
|
|
12
|
+
headers.append(name, v);
|
|
13
|
+
}
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
res.once('close', () => {
|
|
16
|
+
if (!res.writableFinished)
|
|
17
|
+
controller.abort();
|
|
18
|
+
});
|
|
19
|
+
const body = req.method === 'GET' || req.method === 'HEAD' ? undefined : Readable.toWeb(req);
|
|
20
|
+
return new Request(new URL(req.url ?? '/', origin), {
|
|
21
|
+
method: req.method,
|
|
22
|
+
headers,
|
|
23
|
+
signal: controller.signal,
|
|
24
|
+
...(body ? { body: body, duplex: 'half' } : {})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** writes a Fetch `Response` to a Node response, streaming the body */
|
|
28
|
+
export async function writeResponse(res, response, head = false) {
|
|
29
|
+
res.statusCode = response.status;
|
|
30
|
+
if (response.statusText)
|
|
31
|
+
res.statusMessage = response.statusText;
|
|
32
|
+
for (const [name, value] of response.headers) {
|
|
33
|
+
if (name !== 'set-cookie')
|
|
34
|
+
res.setHeader(name, value);
|
|
35
|
+
}
|
|
36
|
+
const cookies = response.headers.getSetCookie();
|
|
37
|
+
if (cookies.length > 0)
|
|
38
|
+
res.setHeader('set-cookie', cookies);
|
|
39
|
+
if (head || !response.body) {
|
|
40
|
+
res.end();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await pipeline(Readable.fromWeb(response.body), res);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Bridges `node:http` to a Fetch handler, with no dependency. The result is also an Express
|
|
47
|
+
* middleware: when the handler returns `undefined` and a `next` callback exists it is called,
|
|
48
|
+
* otherwise the reply is a 404. A handler that throws gets a 500 (or the socket is destroyed if
|
|
49
|
+
* headers are already out).
|
|
50
|
+
*/
|
|
51
|
+
export function toNodeListener(handler, options = {}) {
|
|
52
|
+
return async (req, res, next) => {
|
|
53
|
+
try {
|
|
54
|
+
const response = await handler(toRequest(req, res, options));
|
|
55
|
+
if (!response) {
|
|
56
|
+
if (next)
|
|
57
|
+
return next();
|
|
58
|
+
res.statusCode = 404;
|
|
59
|
+
res.end();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
await writeResponse(res, response, req.method === 'HEAD');
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (res.headersSent) {
|
|
66
|
+
res.destroy(error instanceof Error ? error : undefined);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (next)
|
|
70
|
+
return next(error);
|
|
71
|
+
res.statusCode = 500;
|
|
72
|
+
res.setHeader('content-type', 'text/plain');
|
|
73
|
+
res.end('internal error');
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ProjectionEntry, type RecordEntry, type Ref } from './graph.js';
|
|
2
|
+
/** protocol version both halves speak; a response with another value is ignored by the worker */
|
|
3
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
4
|
+
/** markup or a value, or a reference the replica resolves to one when the page renders */
|
|
5
|
+
export type Text = string | Ref;
|
|
6
|
+
/** a shell with named holes, the fragments that fill them and named values for the rest */
|
|
7
|
+
export type AssemblyBody = {
|
|
8
|
+
shell: string;
|
|
9
|
+
fragments?: Record<string, Text>;
|
|
10
|
+
slots?: Record<string, Text>;
|
|
11
|
+
};
|
|
12
|
+
/** the JSON a template renders against; the template itself ships in the worker config */
|
|
13
|
+
export type TemplateBody = {
|
|
14
|
+
data: unknown;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* What a stored static file is. The bytes live in the worker's Cache, keyed by the artifact's id;
|
|
18
|
+
* `version` is the manifest's label for them, absent when the server's version vector tracks the file.
|
|
19
|
+
*/
|
|
20
|
+
export type StaticBody = {
|
|
21
|
+
type: string;
|
|
22
|
+
bytes: number;
|
|
23
|
+
version?: string;
|
|
24
|
+
};
|
|
25
|
+
/** who may be served an artifact from the replica */
|
|
26
|
+
export type Scope = 'public' | 'principal';
|
|
27
|
+
/** the fields every artifact carries, whatever its body */
|
|
28
|
+
export type ArtifactBase = {
|
|
29
|
+
protocol: typeof PROTOCOL_VERSION;
|
|
30
|
+
/** the request path the artifact answers */
|
|
31
|
+
id: string;
|
|
32
|
+
scope: Scope;
|
|
33
|
+
/** tags the artifact was built from; a change to any of them invalidates it */
|
|
34
|
+
deps: string[];
|
|
35
|
+
/** the version vector cursor read before the artifact was built */
|
|
36
|
+
vector: number;
|
|
37
|
+
/** records this artifact references that the worker did not already hold */
|
|
38
|
+
records?: RecordEntry[];
|
|
39
|
+
/** projections this artifact references that the worker did not already hold */
|
|
40
|
+
projections?: ProjectionEntry[];
|
|
41
|
+
};
|
|
42
|
+
/** one authorised, versioned dependency set and what to render it with */
|
|
43
|
+
export type Artifact = ArtifactBase & ({
|
|
44
|
+
strategy: 'assembly';
|
|
45
|
+
body: AssemblyBody;
|
|
46
|
+
} | {
|
|
47
|
+
strategy: 'template' | 'projection' | 'data';
|
|
48
|
+
body: TemplateBody;
|
|
49
|
+
} | {
|
|
50
|
+
strategy: 'static';
|
|
51
|
+
body: StaticBody;
|
|
52
|
+
});
|
|
53
|
+
/** validates JSON from `/.spool/artifact`; the worker calls this before it stores anything */
|
|
54
|
+
export declare function parseArtifact(value: unknown): Artifact;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ProtocolError } from './errors.js';
|
|
2
|
+
import { isRef, parseProjectionEntry, parseRecordEntry } from './graph.js';
|
|
3
|
+
/** protocol version both halves speak; a response with another value is ignored by the worker */
|
|
4
|
+
export const PROTOCOL_VERSION = 1;
|
|
5
|
+
function bad(message) {
|
|
6
|
+
throw new ProtocolError('bad-artifact', message);
|
|
7
|
+
}
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function textMap(value, field) {
|
|
12
|
+
if (value === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (!isRecord(value))
|
|
15
|
+
return bad(`${field} must be an object`);
|
|
16
|
+
for (const v of Object.values(value)) {
|
|
17
|
+
if (typeof v !== 'string' && !isRef(v))
|
|
18
|
+
return bad(`${field} values must be strings or references`);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function entries(value, field, parse) {
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (!Array.isArray(value))
|
|
26
|
+
return bad(`${field} must be a list`);
|
|
27
|
+
return value.map(parse);
|
|
28
|
+
}
|
|
29
|
+
/** validates JSON from `/.spool/artifact`; the worker calls this before it stores anything */
|
|
30
|
+
export function parseArtifact(value) {
|
|
31
|
+
if (!isRecord(value))
|
|
32
|
+
return bad('artifact must be an object');
|
|
33
|
+
if (value['protocol'] !== PROTOCOL_VERSION)
|
|
34
|
+
return bad('unsupported protocol version');
|
|
35
|
+
const { id, scope, deps, vector, strategy, body } = value;
|
|
36
|
+
if (typeof id !== 'string' || !id.startsWith('/'))
|
|
37
|
+
return bad('id must be a path');
|
|
38
|
+
if (scope !== 'public' && scope !== 'principal')
|
|
39
|
+
return bad('scope must be public or principal');
|
|
40
|
+
if (!Array.isArray(deps) || deps.some((d) => typeof d !== 'string')) {
|
|
41
|
+
return bad('deps must be a list of strings');
|
|
42
|
+
}
|
|
43
|
+
if (typeof vector !== 'number' || !Number.isSafeInteger(vector) || vector < 0) {
|
|
44
|
+
return bad('vector must be a non-negative integer');
|
|
45
|
+
}
|
|
46
|
+
if (!isRecord(body))
|
|
47
|
+
return bad('body must be an object');
|
|
48
|
+
const base = {
|
|
49
|
+
protocol: PROTOCOL_VERSION,
|
|
50
|
+
id,
|
|
51
|
+
scope,
|
|
52
|
+
deps: deps,
|
|
53
|
+
vector
|
|
54
|
+
};
|
|
55
|
+
const records = entries(value['records'], 'records', parseRecordEntry);
|
|
56
|
+
const projections = entries(value['projections'], 'projections', parseProjectionEntry);
|
|
57
|
+
if (records)
|
|
58
|
+
base.records = records;
|
|
59
|
+
if (projections)
|
|
60
|
+
base.projections = projections;
|
|
61
|
+
if (strategy === 'template' || strategy === 'projection' || strategy === 'data') {
|
|
62
|
+
if (!('data' in body))
|
|
63
|
+
return bad(`${strategy} body needs data`);
|
|
64
|
+
return { ...base, strategy, body: { data: body['data'] } };
|
|
65
|
+
}
|
|
66
|
+
if (strategy === 'assembly') {
|
|
67
|
+
if (typeof body['shell'] !== 'string')
|
|
68
|
+
return bad('assembly body needs a shell string');
|
|
69
|
+
const out = { shell: body['shell'] };
|
|
70
|
+
const fragments = textMap(body['fragments'], 'fragments');
|
|
71
|
+
const slots = textMap(body['slots'], 'slots');
|
|
72
|
+
if (fragments)
|
|
73
|
+
out.fragments = fragments;
|
|
74
|
+
if (slots)
|
|
75
|
+
out.slots = slots;
|
|
76
|
+
return { ...base, strategy, body: out };
|
|
77
|
+
}
|
|
78
|
+
return bad(`unknown strategy ${String(strategy)}`);
|
|
79
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AssemblyBody } from './artifact.js';
|
|
2
|
+
/** the markup a shell carries for a hole named `id`; `id` must not contain a double quote */
|
|
3
|
+
export declare function placeholder(id: string): string;
|
|
4
|
+
/** the token a shell carries for a named value */
|
|
5
|
+
export declare function slot(name: string): string;
|
|
6
|
+
/** every placeholder id in a shell, in document order */
|
|
7
|
+
export declare function placeholderIds(shell: string): string[];
|
|
8
|
+
/** every slot name in a shell, in document order */
|
|
9
|
+
export declare function slotNames(shell: string): string[];
|
|
10
|
+
/** what a fill produced and which names did not line up */
|
|
11
|
+
export type AssemblyResult = {
|
|
12
|
+
html: string;
|
|
13
|
+
filled: string[];
|
|
14
|
+
/** names the shell has that nothing answered */
|
|
15
|
+
unfilled: string[];
|
|
16
|
+
/** names supplied that the shell does not have */
|
|
17
|
+
unmatched: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Fills a shell's placeholders with fragment markup by string replacement. An unfilled
|
|
21
|
+
* placeholder stays in place: dropping it would hide a region the shell and fragments disagree
|
|
22
|
+
* about.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assemble(shell: string, fragments: Readonly<Record<string, string>>): AssemblyResult;
|
|
25
|
+
/** fills a shell's slot tokens with named values; same contract as {@link assemble} */
|
|
26
|
+
export declare function fillSlots(shell: string, values: Readonly<Record<string, string>>): AssemblyResult;
|
|
27
|
+
/** the full page for an assembly body, or the reason it cannot be built locally */
|
|
28
|
+
export declare function renderAssembly(body: AssemblyBody): {
|
|
29
|
+
ok: true;
|
|
30
|
+
html: string;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
reason: string;
|
|
34
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const PLACEHOLDER = /<span data-spool-placeholder="([^"]*)"><\/span>/g;
|
|
2
|
+
const SLOT = /\{\{spool-slot:([A-Za-z0-9_.-]+)\}\}/g;
|
|
3
|
+
/** the markup a shell carries for a hole named `id`; `id` must not contain a double quote */
|
|
4
|
+
export function placeholder(id) {
|
|
5
|
+
return `<span data-spool-placeholder="${id}"></span>`;
|
|
6
|
+
}
|
|
7
|
+
/** the token a shell carries for a named value */
|
|
8
|
+
export function slot(name) {
|
|
9
|
+
return `{{spool-slot:${name}}}`;
|
|
10
|
+
}
|
|
11
|
+
/** every placeholder id in a shell, in document order */
|
|
12
|
+
export function placeholderIds(shell) {
|
|
13
|
+
return [...shell.matchAll(PLACEHOLDER)].map((m) => m[1]);
|
|
14
|
+
}
|
|
15
|
+
/** every slot name in a shell, in document order */
|
|
16
|
+
export function slotNames(shell) {
|
|
17
|
+
return [...shell.matchAll(SLOT)].map((m) => m[1]);
|
|
18
|
+
}
|
|
19
|
+
function fill(shell, pattern, values) {
|
|
20
|
+
const filled = [];
|
|
21
|
+
const unfilled = [];
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
const html = shell.replace(pattern, (whole, id) => {
|
|
24
|
+
seen.add(id);
|
|
25
|
+
const value = Object.hasOwn(values, id) ? values[id] : undefined;
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
unfilled.push(id);
|
|
28
|
+
return whole;
|
|
29
|
+
}
|
|
30
|
+
filled.push(id);
|
|
31
|
+
return value;
|
|
32
|
+
});
|
|
33
|
+
const unmatched = Object.keys(values).filter((id) => !seen.has(id));
|
|
34
|
+
return { html, filled, unfilled, unmatched };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fills a shell's placeholders with fragment markup by string replacement. An unfilled
|
|
38
|
+
* placeholder stays in place: dropping it would hide a region the shell and fragments disagree
|
|
39
|
+
* about.
|
|
40
|
+
*/
|
|
41
|
+
export function assemble(shell, fragments) {
|
|
42
|
+
return fill(shell, PLACEHOLDER, fragments);
|
|
43
|
+
}
|
|
44
|
+
/** fills a shell's slot tokens with named values; same contract as {@link assemble} */
|
|
45
|
+
export function fillSlots(shell, values) {
|
|
46
|
+
return fill(shell, SLOT, values);
|
|
47
|
+
}
|
|
48
|
+
/** the full page for an assembly body, or the reason it cannot be built locally */
|
|
49
|
+
export function renderAssembly(body) {
|
|
50
|
+
const plain = (values) => {
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const [name, value] of Object.entries(values ?? {})) {
|
|
53
|
+
if (typeof value !== 'string')
|
|
54
|
+
return null;
|
|
55
|
+
out[name] = value;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
};
|
|
59
|
+
const fragmentText = plain(body.fragments);
|
|
60
|
+
const slotText = plain(body.slots);
|
|
61
|
+
if (!fragmentText || !slotText)
|
|
62
|
+
return { ok: false, reason: 'unresolved reference' };
|
|
63
|
+
const fragments = assemble(body.shell, fragmentText);
|
|
64
|
+
if (fragments.unfilled.length > 0) {
|
|
65
|
+
return { ok: false, reason: `unfilled placeholders: ${fragments.unfilled.join(', ')}` };
|
|
66
|
+
}
|
|
67
|
+
const slots = fillSlots(fragments.html, slotText);
|
|
68
|
+
if (slots.unfilled.length > 0) {
|
|
69
|
+
return { ok: false, reason: `unfilled slots: ${slots.unfilled.join(', ')}` };
|
|
70
|
+
}
|
|
71
|
+
return { ok: true, html: slots.html };
|
|
72
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PROTOCOL_VERSION } from './artifact.js';
|
|
2
|
+
/**
|
|
3
|
+
* One request the worker held back: where it was going, what it carried and when it happened. A
|
|
4
|
+
* same-origin one leaves `origin` out. A request to another origin names it, with the `vendor`
|
|
5
|
+
* whose delay cap applies and, when `deliver` is `sink`, the server half forwards it.
|
|
6
|
+
*/
|
|
7
|
+
export type BeaconEvent = {
|
|
8
|
+
path: string;
|
|
9
|
+
body: string;
|
|
10
|
+
contentType: string;
|
|
11
|
+
/** epoch milliseconds on the device */
|
|
12
|
+
at: number;
|
|
13
|
+
/** the query string of the original URL, with its leading `?` */
|
|
14
|
+
search?: string;
|
|
15
|
+
/** `GET` for a pixel beacon; absent means `POST` */
|
|
16
|
+
method?: 'GET';
|
|
17
|
+
/** the origin of a held cross-origin request; absent for the site's own */
|
|
18
|
+
origin?: string;
|
|
19
|
+
/** the collector entry that matched, which sets the age cap */
|
|
20
|
+
vendor?: string;
|
|
21
|
+
/** `sink` sends the event to the server half in the flush; absent, the worker replays it to its URL */
|
|
22
|
+
deliver?: 'sink';
|
|
23
|
+
/** epoch milliseconds after which the worker drops the event instead of sending it; never sent */
|
|
24
|
+
until?: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A flush's request for the catalogue of the page the visitor is on. `sweep` says the worker names
|
|
28
|
+
* the entries it holds and no page has opened at every required sync of a principal page, so a
|
|
29
|
+
* revoked one is dropped. The server sends principal entries only to a worker that says so.
|
|
30
|
+
*/
|
|
31
|
+
export type CatalogueAsk = {
|
|
32
|
+
path: string;
|
|
33
|
+
sweep?: true;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The body of `/.spool/beacon`: every held request in one flush. `want` asks for the artifacts of
|
|
37
|
+
* these paths in the answer, so provisioning rides a request that is happening anyway, and
|
|
38
|
+
* `catalogue` asks for the entries a site suggests for the page the visitor is on.
|
|
39
|
+
*/
|
|
40
|
+
export type BeaconBatch = {
|
|
41
|
+
protocol: typeof PROTOCOL_VERSION;
|
|
42
|
+
events: BeaconEvent[];
|
|
43
|
+
want?: string[];
|
|
44
|
+
catalogue?: CatalogueAsk;
|
|
45
|
+
};
|
|
46
|
+
/** most characters of the page path a catalogue request names */
|
|
47
|
+
export declare const MAX_CATALOGUE_PATH = 2048;
|
|
48
|
+
/** where the worker records events it dropped past a vendor's age cap; the body is `{vendor, count}` */
|
|
49
|
+
export declare const DROPPED_PATH = "/.spool/dropped";
|
|
50
|
+
/** the paths under `/.spool/` are spool's own and always travel in the flush */
|
|
51
|
+
export declare const OWN_PREFIX = "/.spool/";
|
|
52
|
+
/** the largest beacon body the worker holds or the server keeps in one event, in UTF-8 bytes */
|
|
53
|
+
export declare const MAX_BEACON_BYTES = 65536;
|
|
54
|
+
/** most events one flush may carry; the server refuses a larger batch */
|
|
55
|
+
export declare const MAX_BEACON_EVENTS = 500;
|
|
56
|
+
/** most artifact paths one flush may ask for */
|
|
57
|
+
export declare const MAX_WANT = 8;
|
|
58
|
+
/** validates a flush body */
|
|
59
|
+
export declare function parseBeaconBatch(value: unknown): BeaconBatch;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PROTOCOL_VERSION } from './artifact.js';
|
|
2
|
+
import { ProtocolError } from './errors.js';
|
|
3
|
+
/** most characters of the page path a catalogue request names */
|
|
4
|
+
export const MAX_CATALOGUE_PATH = 2048;
|
|
5
|
+
/** where the worker records events it dropped past a vendor's age cap; the body is `{vendor, count}` */
|
|
6
|
+
export const DROPPED_PATH = '/.spool/dropped';
|
|
7
|
+
/** the paths under `/.spool/` are spool's own and always travel in the flush */
|
|
8
|
+
export const OWN_PREFIX = '/.spool/';
|
|
9
|
+
/** the largest beacon body the worker holds or the server keeps in one event, in UTF-8 bytes */
|
|
10
|
+
export const MAX_BEACON_BYTES = 65_536;
|
|
11
|
+
/** most events one flush may carry; the server refuses a larger batch */
|
|
12
|
+
export const MAX_BEACON_EVENTS = 500;
|
|
13
|
+
/** most artifact paths one flush may ask for */
|
|
14
|
+
export const MAX_WANT = 8;
|
|
15
|
+
function bad(message) {
|
|
16
|
+
throw new ProtocolError('bad-beacon', message);
|
|
17
|
+
}
|
|
18
|
+
/** validates a flush body */
|
|
19
|
+
export function parseBeaconBatch(value) {
|
|
20
|
+
if (typeof value !== 'object' || value === null)
|
|
21
|
+
return bad('batch must be an object');
|
|
22
|
+
const v = value;
|
|
23
|
+
if (v['protocol'] !== PROTOCOL_VERSION)
|
|
24
|
+
return bad('unsupported protocol version');
|
|
25
|
+
if (!Array.isArray(v['events']))
|
|
26
|
+
return bad('events must be a list');
|
|
27
|
+
if (v['events'].length > MAX_BEACON_EVENTS)
|
|
28
|
+
return bad(`more than ${MAX_BEACON_EVENTS} events`);
|
|
29
|
+
const events = v['events'].map((raw) => {
|
|
30
|
+
const e = (raw ?? {});
|
|
31
|
+
if (typeof e['path'] !== 'string' || !e['path'].startsWith('/'))
|
|
32
|
+
return bad('event path');
|
|
33
|
+
if (typeof e['body'] !== 'string')
|
|
34
|
+
return bad('event body must be a string');
|
|
35
|
+
if (typeof e['contentType'] !== 'string')
|
|
36
|
+
return bad('event contentType must be a string');
|
|
37
|
+
if (typeof e['at'] !== 'number' || !Number.isFinite(e['at']))
|
|
38
|
+
return bad('event at');
|
|
39
|
+
const out = {
|
|
40
|
+
path: e['path'],
|
|
41
|
+
body: e['body'],
|
|
42
|
+
contentType: e['contentType'],
|
|
43
|
+
at: e['at']
|
|
44
|
+
};
|
|
45
|
+
for (const field of ['search', 'origin', 'vendor']) {
|
|
46
|
+
const value = e[field];
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
continue;
|
|
49
|
+
if (typeof value !== 'string')
|
|
50
|
+
return bad(`event ${field} must be a string`);
|
|
51
|
+
out[field] = value;
|
|
52
|
+
}
|
|
53
|
+
if (e['method'] !== undefined) {
|
|
54
|
+
if (e['method'] !== 'GET')
|
|
55
|
+
return bad('event method must be GET');
|
|
56
|
+
out.method = 'GET';
|
|
57
|
+
}
|
|
58
|
+
if (e['deliver'] !== undefined) {
|
|
59
|
+
if (e['deliver'] !== 'sink')
|
|
60
|
+
return bad('event deliver must be sink');
|
|
61
|
+
out.deliver = 'sink';
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
});
|
|
65
|
+
const batch = { protocol: PROTOCOL_VERSION, events };
|
|
66
|
+
const want = v['want'];
|
|
67
|
+
if (want !== undefined) {
|
|
68
|
+
if (!Array.isArray(want) || want.length > MAX_WANT)
|
|
69
|
+
return bad(`want must be a list of at most ${MAX_WANT}`);
|
|
70
|
+
if (want.some((p) => typeof p !== 'string' || !p.startsWith('/')))
|
|
71
|
+
return bad('want paths');
|
|
72
|
+
batch.want = want;
|
|
73
|
+
}
|
|
74
|
+
const catalogue = v['catalogue'];
|
|
75
|
+
if (catalogue !== undefined) {
|
|
76
|
+
const ask = (catalogue ?? {});
|
|
77
|
+
const path = ask['path'];
|
|
78
|
+
if (typeof path !== 'string' || !path.startsWith('/') || path.length > MAX_CATALOGUE_PATH) {
|
|
79
|
+
return bad('catalogue path');
|
|
80
|
+
}
|
|
81
|
+
if (ask['sweep'] !== undefined && ask['sweep'] !== true)
|
|
82
|
+
return bad('catalogue sweep');
|
|
83
|
+
batch.catalogue = ask['sweep'] === true ? { path, sweep: true } : { path };
|
|
84
|
+
}
|
|
85
|
+
return batch;
|
|
86
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** how a replayed request carries the time the event happened */
|
|
2
|
+
export type StampKind = 'age-ms' | 'epoch-ms' | 'epoch-s' | 'datetime-utc';
|
|
3
|
+
/**
|
|
4
|
+
* A cross-origin analytics collector the worker holds instead of letting the page send it. The
|
|
5
|
+
* page gets an immediate empty answer; the event leaves on a network moment that happens anyway,
|
|
6
|
+
* inside `maxAgeMs`. Events older than that are dropped and counted, never sent late.
|
|
7
|
+
*/
|
|
8
|
+
export type CollectorConfig = {
|
|
9
|
+
/** names the collector in drop counts and on the held event */
|
|
10
|
+
vendor: string;
|
|
11
|
+
/** the origin and path prefix of the collector's URL, such as `https://www.google-analytics.com/g/collect` */
|
|
12
|
+
match: string;
|
|
13
|
+
/** the vendor's backfill window less a margin, in milliseconds */
|
|
14
|
+
maxAgeMs: number;
|
|
15
|
+
/**
|
|
16
|
+
* `replay` sends the held request from the worker to its own URL with no cookies, so identity
|
|
17
|
+
* has to be in the payload. `sink` hands it to the server half in the flush, for a vendor that
|
|
18
|
+
* needs a secret the page must not hold.
|
|
19
|
+
*/
|
|
20
|
+
delivery: 'replay' | 'sink';
|
|
21
|
+
/** a query parameter the replay sets to the event's time, for a vendor that accepts one */
|
|
22
|
+
stamp?: {
|
|
23
|
+
param: string;
|
|
24
|
+
kind: StampKind;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** GA4 Measurement Protocol: backdating works up to 72 hours, and attribution wants 48 */
|
|
28
|
+
export declare const GA4_RECOMMENDED_MS: number;
|
|
29
|
+
/** the longest cap a `ga4` collector may declare */
|
|
30
|
+
export declare const GA4_HARD_MS: number;
|
|
31
|
+
/**
|
|
32
|
+
* The GA4 browser collector, forwarded through the server half because the Measurement Protocol
|
|
33
|
+
* needs an API secret the page must not hold. The cap is the 48-hour attribution window.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GA4_COLLECTOR: CollectorConfig;
|
|
36
|
+
/** validates collectors from a server config; a `ga4` cap past the 72-hour limit is refused */
|
|
37
|
+
export declare function checkCollectors(collectors: readonly CollectorConfig[]): void;
|
|
38
|
+
/** the collector whose `match` the URL falls under, or undefined */
|
|
39
|
+
export declare function matchCollector(collectors: readonly CollectorConfig[] | undefined, url: string): CollectorConfig | undefined;
|
|
40
|
+
/** `search` with the stamp parameter set to when the event happened, other parameters kept */
|
|
41
|
+
export declare function applyStamp(search: string, stamp: NonNullable<CollectorConfig['stamp']>, at: number, now: number): string;
|