@replayd/core 0.1.1 → 0.1.3

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.
@@ -1,5 +1,5 @@
1
1
  /** @replayd/core — public API (PRD §4.1). `init()` is synchronous, < 1 ms, and never throws. */
2
- import type { Breadcrumb, ReplaydEvent, ReplaydOptions, User } from './types';
2
+ import type { BreadcrumbInput, ProblemReport, ReplaydEvent, ReplaydOptions, User } from './types';
3
3
  import { loaders } from './chunks';
4
4
  export { setCustomFields } from './fields';
5
5
  export type * from './types';
@@ -15,13 +15,26 @@ export interface CaptureHint {
15
15
  }
16
16
  export declare function captureException(error: unknown, hint?: CaptureHint): void;
17
17
  export declare function captureMessage(message: string, level?: ReplaydEvent['level']): void;
18
+ /**
19
+ * Records a problem the user reported in the app's own UI (T-110). Returns the report (attach `id` to your support
20
+ * ticket) or null when nothing was recorded: capture disabled (kill switch, `close()`), empty description, more
21
+ * than 10 reports in this session, or `beforeSend` dropped it. Never throws.
22
+ */
23
+ export declare function reportProblem(description: string): ProblemReport | null;
18
24
  export declare function setUser(u: User | null): void;
19
25
  export declare function setTag(k: string, v: string): void;
20
26
  export declare function setTags(t: Record<string, string>): void;
27
+ /**
28
+ * App state snapshot (T-121, opt-in): `getter` is called for every error event that is sent (never for reports) and
29
+ * its result attached as `state`, after key redaction (`redact.bodyKeys`), ≤ 16 KB (else `{ truncated: size }`;
30
+ * a value that is not plain JSON gives `{ invalid: true }`). Keep it small: it runs on the main thread per error.
31
+ * The adapters' `replayPinia(pinia)` / `replayRedux(store)` call this. `null` stops it.
32
+ */
33
+ export declare function setAppState(getter: (() => unknown) | null): void;
21
34
  export declare function setContext(name: string, x: Record<string, unknown> | null): void;
22
- export declare function addBreadcrumb(b: Partial<Breadcrumb> & {
23
- msg: string;
24
- }): void;
35
+ /** App breadcrumb (T-107): redacted (data keys, `key=value` text in msg) and bounded before it reaches error events and
36
+ * the replay; never throws into the app. */
37
+ export declare function addBreadcrumb<D extends Record<string, unknown>>(b: BreadcrumbInput<D>): void;
25
38
  /** sends pending events now; resolves once queued (uploads continue in the background) */
26
39
  export declare function flush(): Promise<void>;
27
40
  /** flushes, then removes every patch/listener and stops capture */
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Debugging signals recorded by the replay chunk (D-94), as `sig` custom events `{ k, … }`. The worker counts them per
3
+ * segment (`meta.sig`), the server sums them per session. Each one has a switch in `signals` (remote config wins).
4
+ *
5
+ * Rage click (T-115): the 3rd click on one element within 1 s of the burst's first click, once per burst.
6
+ * Dead click (T-115): a click on a clickable element after which, for 3 s, the page records no DOM change, input,
7
+ * scroll, page change, tab change or request started after the click. On a page whose DOM changes all the time
8
+ * (tickers without `data-rp-throttle`) dead clicks cannot be told apart and are not reported.
9
+ *
10
+ * Freeze (T-116): a main-thread stall of ≥ 200 ms: a long animation frame (Chromium 123+, with the script that ran
11
+ * longest) or, where only that exists, a long task. Frames from before the chunk loaded are included (buffered).
12
+ *
13
+ * Vitals (T-118): LCP, INP (≈ p98 of interactions), CLS (largest 5 s session window), FCP, TTFB, DOMContentLoaded and
14
+ * load of this page load, from buffered observers, sent as `{ k: 'vitals', … }` whenever the page is hidden or
15
+ * unloads (latest values; the server keeps the last one per page load).
16
+ *
17
+ * Memory (T-119): every 30 s while the page is visible, the JS heap where the browser exposes it (`performance.memory`:
18
+ * Chromium and Android WebView, coarse values) in MB; the first sample adds `navigator.deviceMemory` (GB, rounded by
19
+ * the browser) and the core count. `{ k: 'mem', used, total, limit, dm?, cores? }`.
20
+ *
21
+ * Storage (T-120): `localStorage`/`sessionStorage` `setItem`/`removeItem`/`clear` and `document.cookie` writes as
22
+ * `{ k: 'storage', area, op, key?, v? }`. Values (≤ 256 chars) are redacted before they are recorded: `[Filtered]` for
23
+ * a key on the redaction list, else core's text/JSON redaction plus JWT-like and long opaque token values; cookies by
24
+ * name only, never values. The SDK's own `rp_*` keys are skipped; at most 20 changes per second (the rest counted as
25
+ * `skipped` on the next one). Direct property writes (`localStorage.x = 1`) cannot be seen.
26
+ *
27
+ * Elements are named by descriptor (`button#buy.btn`), never by their text; `id` is the replay mirror id.
28
+ */
29
+ import type { Internal } from '../types';
30
+ type Ev = {
31
+ type: number;
32
+ data?: {
33
+ source?: number;
34
+ tag?: string;
35
+ payload?: {
36
+ start?: unknown;
37
+ k?: unknown;
38
+ };
39
+ };
40
+ };
41
+ type Rec = (k: string, data: Record<string, unknown>, ts: number) => void;
42
+ export declare const desc: (el: Element) => string;
43
+ export declare const signals: (I: Internal, rec: Rec, id: (n: Node) => number) => {
44
+ stop(): void;
45
+ click: (e: Event) => void;
46
+ /** every recorded event while a dead check is pending: pointer moves and focus changes are not a response */
47
+ see(e: Ev): void;
48
+ /** the page is going away or hidden: pending clicks did something; the vitals so far are sent */
49
+ away(): void;
50
+ };
51
+ export {};
@@ -6,6 +6,8 @@ export declare const rec: (type: RingEvent["type"], data: RingEvent["data"], ts?
6
6
  /** drains the ring (oldest first); WS frames and network bodies are redacted here, lazily, never on the hot path */
7
7
  export declare const drain: () => RingEvent[];
8
8
  export declare const setSink: (f: typeof sink) => void;
9
+ /** the replay chunk is recording this page (its sink is attached) */
10
+ export declare const live: () => boolean;
9
11
  export declare let crumbs: Breadcrumb[];
10
12
  export declare const crumb: (cat: Breadcrumb["cat"], msg: string, data?: Breadcrumb["data"], ts?: number) => void;
11
13
  export declare const resetRing: () => void;
@@ -54,6 +54,42 @@ export interface RedactOptions {
54
54
  bodyKeys?: string[];
55
55
  queryParams?: string[];
56
56
  }
57
+ /**
58
+ * Backend log correlation (T-109): read an EXISTING request/correlation ID from these response headers, for these
59
+ * URLs only. Nothing is ever added to requests. Cross-origin APIs must list the header in
60
+ * `Access-Control-Expose-Headers`. Values longer than 128 characters or with characters other than letters, digits
61
+ * and `._:@/+=-` are dropped; headers in `redact.headers` are never read.
62
+ */
63
+ export interface CorrelationOptions {
64
+ /** Response header names, at most 3 are used, e.g. `['x-request-id']`. */
65
+ headers: string[];
66
+ /** URLs to read them from; default `replay.networkDetailAllowUrls`. `'self'` = `location.origin`. */
67
+ urls?: Matcher[];
68
+ }
69
+ /**
70
+ * Debugging signals (D-94). Every capture is on unless set to `false` here or switched off per project in the remote
71
+ * config (`signals` section). Replay-chunk signals exist only for sessions that are recorded.
72
+ */
73
+ export interface SignalOptions {
74
+ /** ≥ 3 clicks on one element within 1 s (replay) */
75
+ rage?: boolean;
76
+ /** a click on a button/link that changed nothing within 3 s (replay) */
77
+ dead?: boolean;
78
+ /** main-thread stalls ≥ 200 ms: long animation frames / long tasks (replay) */
79
+ freeze?: boolean;
80
+ /** LCP, INP, CLS, FCP and navigation timing per page load (replay) */
81
+ vitals?: boolean;
82
+ /** JS heap every 30 s where exposed, device memory (replay) */
83
+ memory?: boolean;
84
+ /** localStorage / sessionStorage changes (values redacted) and cookie names (replay) */
85
+ storage?: boolean;
86
+ /** app state snapshots on error events, only where the app opted in with `setAppState` (core) */
87
+ state?: boolean;
88
+ /** failed script / stylesheet / preload / image loads as `resource` issues (core, also without a replay) */
89
+ resources?: boolean;
90
+ /** Content-Security-Policy violations as `csp` warnings (core, also without a replay) */
91
+ csp?: boolean;
92
+ }
57
93
  export interface ReplaydOptions {
58
94
  /** `https://<publicKey>@<host>/<projectId|slug>` */
59
95
  dsn: string;
@@ -66,6 +102,8 @@ export interface ReplaydOptions {
66
102
  websocket?: WebSocketOptions;
67
103
  errors?: ErrorOptions;
68
104
  redact?: RedactOptions;
105
+ correlation?: CorrelationOptions;
106
+ signals?: SignalOptions;
69
107
  beforeSend?: (event: ReplaydEvent) => ReplaydEvent | null | undefined | void;
70
108
  /** IndexedDB offline queue on web (always on under Capacitor; T-26). */
71
109
  offlineQueue?: boolean;
@@ -76,6 +114,17 @@ export interface Breadcrumb {
76
114
  msg: string;
77
115
  data?: Record<string, unknown>;
78
116
  }
117
+ /**
118
+ * `addBreadcrumb` input (T-107). `msg` is a short label (≤ 256 chars kept); put values in `data`, whose keys are
119
+ * redacted with `redact.bodyKeys` (password, token, …). `data` over 1 KB of JSON is replaced by `{ truncated: <size> }`.
120
+ * `cat` defaults to `'custom'` (≤ 32 chars kept); `ts` to now. Type `D` to describe your own breadcrumbs.
121
+ */
122
+ export interface BreadcrumbInput<D extends Record<string, unknown> = Record<string, unknown>> {
123
+ msg: string;
124
+ cat?: Breadcrumb['cat'];
125
+ data?: D;
126
+ ts?: number;
127
+ }
79
128
  export interface User {
80
129
  id?: string;
81
130
  email?: string;
@@ -88,7 +137,7 @@ export interface ReplaydEvent {
88
137
  ts: number;
89
138
  sid: string;
90
139
  level: 'error' | 'warning';
91
- source: 'onerror' | 'unhandledrejection' | 'console' | 'http' | 'ws' | 'vue' | 'react' | 'manual';
140
+ source: 'onerror' | 'unhandledrejection' | 'console' | 'http' | 'ws' | 'vue' | 'react' | 'manual' | 'report' | 'resource' | 'csp';
92
141
  type: string;
93
142
  message: string;
94
143
  stack?: string;
@@ -105,10 +154,22 @@ export interface ReplaydEvent {
105
154
  ctx?: Record<string, unknown>;
106
155
  breadcrumbs: Breadcrumb[];
107
156
  count: number;
157
+ /** T-121: redacted app state at the time of the error (`setAppState`) */
158
+ state?: unknown;
159
+ /** T-133: debug ids of the stack's files (file URL → id), when the bundles carry them */
160
+ debug_ids?: Record<string, string>;
161
+ }
162
+ /** `reportProblem` result (T-110): the report's id, the session it belongs to, its time, and whether this page was
163
+ * recording a replay of that session when it was made. */
164
+ export interface ProblemReport {
165
+ id: string;
166
+ sid: string;
167
+ ts: number;
168
+ replay: boolean;
108
169
  }
109
170
  /** Ring-buffer / replay custom event (rrweb custom event tag + payload + original timestamp). */
110
171
  export interface RingEvent {
111
- type: 'console' | 'network' | 'ws' | 'nav' | 'breadcrumb' | 'error' | 'app' | 'gap' | 'fields';
172
+ type: 'console' | 'network' | 'ws' | 'nav' | 'breadcrumb' | 'error' | 'app' | 'gap' | 'fields' | 'report' | 'sig';
112
173
  ts: number;
113
174
  data: Record<string, unknown>;
114
175
  }
@@ -200,4 +261,5 @@ export interface Resolved extends ReplaydOptions {
200
261
  };
201
262
  errors: Required<ErrorOptions>;
202
263
  redact: Required<RedactOptions>;
264
+ signals: SignalOptions;
203
265
  }
package/dist/worker.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";(()=>{var e,t,r,a=new TextEncoder,n={redact:{headers:[],bodyKeys:[],queryParams:[]}},s=0,i=()=>s,l=e=>{let t=n.redact;e.headers.length+e.bodyKeys.length+e.queryParams.length!=t.headers.length+t.bodyKeys.length+t.queryParams.length&&(n.redact=e,s++)},o="[Filtered]",f=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=-1,u=()=>{if(d==i())return;d=i();let r=n.redact.bodyKeys.map(f).join("|");e=new RegExp(`([?&#;](?:${n.redact.queryParams.map(f).join("|")}|${r})=)[^&#;]*`,"gi"),t=new RegExp(`("(?:${r})"\\s*:\\s*)("(?:[^"\\\\]|\\\\.)*"?|[^,}\\]\\s]+)|((?:^|&)(?:${r})=)[^&\\s]*`,"gi")},h=(e,t=0)=>{if(!e||"object"!=typeof e)return e;if(t>7)return"[Depth]";if(Array.isArray(e))return e.map(e=>h(e,t+1));let r=Object.create(null);for(let a in e)r[a]=n.redact.bodyKeys.includes(a.toLowerCase())?o:h(e[a],t+1);return r},p=e=>{u();let r=e.trimStart()[0];if(("{"==r||"["==r)&&e.length<1e5)try{return JSON.stringify(h(JSON.parse(e)))}catch{}return e.includes("\n")?e.split("\n").map(p).join("\n"):e.replace(t,(e,t,r,a)=>t?`${t}"${o}"`:a+o)},g=null,c=(e,t,r)=>(g??=new Promise((e,t)=>{let r=indexedDB.open("replayd",1);r.onupgradeneeded=()=>{for(let e of["q","e"])r.result.createObjectStore(e,{autoIncrement:!0})},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})).catch(e=>{throw g=null,e}).then(a=>new Promise((n,s)=>{let i=a.transaction(e,t?"readwrite":"readonly"),l=r(i.objectStore(e));i.oncomplete=()=>n(l?l.result:void 0),i.onerror=i.onabort=()=>s(i.error)})),y=(e,t)=>c(e,!0,e=>{e.delete(t)}),m=self,w=5<<20,b="",v=0,M=1,j=new Map,S=0,$=0,q=new Set,x=0,O=0,P=((e,t)=>{let r=[],a=0,n=0,s=0,i=0,l=0,o=0,f=0,d=[],u=e=>"string"==typeof e&&d.length<10&&!d.includes(e)&&d.push(e),h=()=>{r=[],a=n=i=l=o=f=0,d=[]};return{raw:()=>a,n:()=>n,reset:h,add(d){let h=d.data,p=d.timestamp;if(4==d.type&&h.href)u(h.href=e.u(h.href));else if(3==d.type&&2==h.source&&2==h.type)l++;else if(5==d.type){let r=h.payload;if("error"==h.tag)"warning"==r.level?f++:o++;else if("fields"==h.tag)r.value=e.j(r.value);else if("nav"==h.tag&&"string"==typeof r.to)u(r.to=e.u(r.to));else if("network"==h.tag)for(let t of["reqBody","resBody"])"string"==typeof r[t]&&(r[t]=e.t(r[t]));else if("ws"==h.tag&&"string"==typeof r.raw){if(t&&"in"==r.dir){let e=t(r.raw,p);if(null==e)return;r.raw=e}r.raw=e.t(r.raw)}}n++||(s=p),p>i&&(i=p);let g=JSON.stringify(d);a+=g.length,r.push(g)},take(t,a){t.init&&(t.init.url=e.u(t.init.url),t.init.ref=e.u(t.init.ref),t.init.user=e.j(t.init.user)),t.fields&&(t.fields.user=e.j(t.fields.user),t.fields.custom_fields=e.j(t.fields.custom_fields),t.fields.tags=e.j(t.fields.tags),(new TextEncoder).encode(JSON.stringify(t.fields.tags)).length>8192&&delete t.fields.tags),a&&r.unshift(JSON.stringify({type:5,timestamp:s,data:{tag:"gap",payload:{reason:"dropped",segments:a}}}));let u=JSON.stringify({canvas_bytes:0,...t,t0:s,t1:i,enc:"gzip",n,urls:d,clicks:l,errs:o,warns:f,has_error:o>0,gap:a>0}),p=`[${r.join(",")}]`;return h(),[u,p]}}})({u:t=>(u(),t.replace(e,`$1${o}`)),t:p,j:h},(e,t)=>v?((e,t)=>{let r=[];for(let a of e.split("\n")){let e;try{e=JSON.parse(a).push?.channel}catch{}if("string"==typeof e){if(t-(j.get(e)??-1e15)<1e3/M)continue;j.size>999&&(j=new Map),j.set(e,t)}r.push(a)}return r.join("\n")})(e,t)||null:e),T=[],U=0,J=0,N=0,B=new Map,_=0,A=e=>{if(2==e.type){_=Math.max(_,e.timestamp);for(let[t,[,r]]of B)r<e.timestamp&&B.delete(t)}P.add(e)},C=[],D=0,K=0,k=0,E=!1,L=e=>{let t=C.indexOf(e);t>=0&&(D-=C.splice(t,1)[0].b.length),e.s&&m.postMessage([3,e.s])},R=(e,t)=>{e.f=!0,K++,fetch(b,{method:"POST",body:e.b,keepalive:t,credentials:"omit",headers:{"Content-Type":"text/plain"}}).then(e=>{let t=+(e.headers.get("x-replayd-disable")??0);t>0&&m.postMessage([1,t]);let r=e.status;return r<400?0:r<500&&429!=r?-2:+(e.headers.get("retry-after")??0)||-1},()=>-1).then(t=>{if(e.f=!1,K--,t>-2&&t&&++e.n<5)return clearTimeout(k),E=t>0,void(k=setTimeout(()=>{k=0,F()},t>0?1e3*t:Math.min(6e4,500*2**e.n)));S&&-1==t?L(e):(t&&O++,z(e),F())})},z=e=>{L(e),e.p?.then(e=>null!=e&&y("q",e)).catch(()=>{})},I=async e=>{if(e&&k&&!E&&(clearTimeout(k),k=0,F()),!$){$=1;try{let e=new Set(await Promise.all(C.map(e=>e.p))),[t,r]=await(()=>{let e=[],t=[],r=0,a=0;return c("q",!0,n=>{let s=Date.now(),i=n.openCursor();i.onsuccess=()=>{let l=i.result;if(l)return t.push([l.primaryKey,l.value]),void l.continue();for(let i=t.length-1;i>=0;i--){let[l,o]=t[i];s-o.t>864e5||(a+=o.b.byteLength)>20971520?(n.delete(l),r++):e.unshift([l,o])}}}).then(()=>[e,r])})();O+=r;for(let[r,a]of t)if(!(e.has(r)||D+a.b.byteLength>w)){if(a.s&&q.has(a.s)){y("q",r).catch(()=>{});continue}C.push({b:a.b,n:0,p:Promise.resolve(r)}),D+=a.b.byteLength}}catch{}$=0,F()}},F=e=>{if(!e&&(K||k))return;let t=6e4;for(let r of C){if(r.f)continue;let a=r.b.length;if(!e)return R(r,a<6e4);let n=a<t;n&&(t-=a),R(r,n)}},V=async(e,t,r,n,s)=>{let i=function(e,t,r=[]){let n=a.encode(e);if(n.length>32768)throw new RangeError("meta too large");let s=2+n.length+4+t.length+2;for(let e of r)s+=9+e.data.length;let i=new Uint8Array(s),l=new DataView(i.buffer),o=0;l.setUint16(o,n.length,!0),o+=2,i.set(n,o),o+=n.length,l.setUint32(o,t.length,!0),o+=4,i.set(t,o),o+=t.length,l.setUint16(o,r.length,!0),o+=2;for(let e of r)l.setUint32(o,e.id,!0),o+=4,i[o++]=e.type,l.setUint32(o,e.data.length,!0),o+=4,i.set(e.data,o),o+=e.data.length;return i}(e,new Uint8Array(await new Response(new Blob([t]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer()),s),l={b:i,n:0,s:r};S&&(l.p=((e,t)=>c("q",!0,e=>e.add(t)))(0,{t:Date.now(),b:i}).catch(()=>{})),C.push(l),D+=i.length;for(let e=0;D>w&&e<C.length-1;)C[e].f?e++:(L(C[e]),S||O++);F(n)};m.onmessage=e=>{let t=e.data;try{if(1==t[0]){t[2]&&l(t[2]);for(let e of t[1])A(e)}else if(2==t[0]){t[5]&&l(t[5]);for(let e of t[4]??[])A(e);let e=t[1],r=t[2].split("\0"),a=[];for(let t=0;t<e.length;t++)a.push({id:e[t],value:r[t]});A({type:3,timestamp:t[3],data:{source:0,texts:a,attributes:[],removes:[],adds:[]}})}else if(3==t[0])((e,t,a)=>{l(t),r&&r.sid==e.sid&&(e.init??=r.init,e.fields??=r.fields,e.ws_disc+=r.ws_disc),r=0;let n=`${e.sid}:${e.seq}`;if(!P.n())return r=e,void m.postMessage([3,n]);let[s,i]=P.take({...e,canvas_bytes:U},O),o=T;return x=O=U=0,T=[],V(s,i,n,a,o)})(t[1],t[2],t[3])?.catch(()=>{});else if(5==t[0])P.reset(),T=[],x=U=0,B.clear(),t[1]&&F(!0);else if(6==t[0]){let e=JSON.parse(t[1]),r=`${e.sid}:${e.seq}`;q.add(r),O+=0|t[3],V(t[1],t[2],r).catch(()=>{})}else 7==t[0]?(async(e,t,r,a,n)=>{try{if(N)return;if(J>30<<20)return A({type:5,timestamp:r,data:{tag:"gap",payload:{reason:"canvas cap"}}}),void(N=1);let s=t.width,i=t.height,l=Math.min(1,a/s),o=Math.max(1,Math.round(s*l)),f=Math.max(1,Math.round(i*l)),d=new OffscreenCanvas(o,f),u=d.getContext("2d");u.drawImage(t,0,0,o,f);let h=new Uint32Array(u.getImageData(0,0,o,f).data.buffer),p=2166136261^s^i<<16;for(let e=0;e<h.length;e++)p=Math.imul(p^h[e],16777619);if(B.get(e)?.[0]===p)return;let g=await d.convertToBlob({type:"image/webp",quality:n});if("image/webp"!=g.type)return void(N=1);let c=new Uint8Array(await g.arrayBuffer());r>=_&&B.set(e,[p,r]),T.push({id:T.length,type:1,data:c}),U+=c.length,J+=c.length,A({type:5,timestamp:r,data:{tag:"canvas",payload:{id:e,a:T.length-1,w:s,h:i}}})}finally{t.close(),m.postMessage([2,e,N])}})(t[1],t[2],t[3],t[4],t[5]):0==t[0]?(b=t[1],l(t[2]),v=t[3],M=t[4]||1,S=t[5]?1:0,I()):4==t[0]&&I(1);(P.raw()>=262144||U>=1<<20)&&!x&&(x=1,m.postMessage([0]))}catch{}}})();
1
+ "use strict";(()=>{var e,t,r,a=new TextEncoder,s={redact:{headers:[],bodyKeys:[],queryParams:[]}},n=0,i=()=>n,l=e=>{let t=s.redact;e.headers.length+e.bodyKeys.length+e.queryParams.length!=t.headers.length+t.bodyKeys.length+t.queryParams.length&&(s.redact=e,n++)},o="[Filtered]",d=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=-1,u=()=>{if(f==i())return;f=i();let r=s.redact.bodyKeys.map(d).join("|");e=new RegExp(`([?&#;](?:${s.redact.queryParams.map(d).join("|")}|${r})=)[^&#;]*`,"gi"),t=new RegExp(`("(?:${r})"\\s*:\\s*)("(?:[^"\\\\]|\\\\.)*"?|[^,}\\]\\s]+)|((?:^|&)(?:${r})=)[^&\\s]*`,"gi")},h=(e,t=0)=>{if(!e||"object"!=typeof e)return e;if(t>7)return"[Depth]";if(Array.isArray(e))return e.map(e=>h(e,t+1));let r=Object.create(null);for(let a in e)r[a]=s.redact.bodyKeys.includes(a.toLowerCase())?o:h(e[a],t+1);return r},g=e=>{u();let r=e.trimStart()[0];if(("{"==r||"["==r)&&e.length<1e5)try{return JSON.stringify(h(JSON.parse(e)))}catch{}return e.includes("\n")?e.split("\n").map(g).join("\n"):e.replace(t,(e,t,r,a)=>t?`${t}"${o}"`:a+o)},p=null,c=(e,t,r)=>(p??=new Promise((e,t)=>{let r=indexedDB.open("replayd",1);r.onupgradeneeded=()=>{for(let e of["q","e"])r.result.createObjectStore(e,{autoIncrement:!0})},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})).catch(e=>{throw p=null,e}).then(a=>new Promise((s,n)=>{let i=a.transaction(e,t?"readwrite":"readonly"),l=r(i.objectStore(e));i.oncomplete=()=>s(l?l.result:void 0),i.onerror=i.onabort=()=>n(i.error)})),y=(e,t)=>c(e,!0,e=>{e.delete(t)}),m=self,w=5<<20,b="",v=0,M=1,j=new Map,S=0,$=0,x=new Set,q=0,O=0,k=((e,t)=>{let r,a=[],s=0,n=0,i=0,l=0,o=0,d=0,f=0,u=[],h={},g=[],p=[],c=[],y=e=>c.length<30&&!c.includes(e)&&c.push(e),m=e=>"string"==typeof e&&(y("u:"+e),u.length<10&&!u.includes(e)&&u.push(e)),w=()=>{a=[],s=n=l=o=d=f=0,u=[],h={},g=[],r=void 0,p=[],c=[]};return{raw:()=>s,n:()=>n,reset:w,add(u){let c=u.data,w=u.timestamp;if(4==u.type&&c.href)m(c.href=e.u(c.href));else if(3==u.type&&2==c.source&&2==c.type)o++;else if(5==u.type){let a=c.payload;if("error"==c.tag)"warning"==a.level?f++:d++;else if("sig"==c.tag)h[a.k]=(h[a.k]??0)+1,"vitals"==a.k&&g.push(a),"mem"==a.k&&(r={...r,...a,used:Math.max(r?.used??0,a.used??0)});else if("fields"==c.tag)a.value=e.j(a.value);else if("nav"==c.tag&&"string"==typeof a.to)m(a.to=e.u(a.to));else if("network"==c.tag){for(let t of["reqBody","resBody"])"string"==typeof a[t]&&(a[t]=e.t(a[t]));(a.status>=400||0===a.status)&&p.length<10&&!p.includes(a.status)&&p.push(a.status)}else if("breadcrumb"==c.tag)y(("c:"+a.cat+":"+a.msg).slice(0,100));else if("ws"==c.tag&&"string"==typeof a.raw){if(t&&"in"==a.dir){let e=t(a.raw,w);if(null==e)return;a.raw=e}a.raw=e.t(a.raw)}}n++||(i=w),w>l&&(l=w);let b=JSON.stringify(u);s+=b.length,a.push(b)},take(t,s){t.init&&(t.init.url=e.u(t.init.url),t.init.ref=e.u(t.init.ref),t.init.user=e.j(t.init.user)),t.fields&&(t.fields.user=e.j(t.fields.user),t.fields.custom_fields=e.j(t.fields.custom_fields),t.fields.tags=e.j(t.fields.tags),(new TextEncoder).encode(JSON.stringify(t.fields.tags)).length>8192&&delete t.fields.tags),s&&a.unshift(JSON.stringify({type:5,timestamp:i,data:{tag:"gap",payload:{reason:"dropped",segments:s}}}));let y=JSON.stringify({canvas_bytes:0,...t,t0:i,t1:l,enc:"gzip",n,urls:u,clicks:o,errs:d,warns:f,sig:h,vitals:g,mem:r,st:p,tr:c,has_error:d>0,gap:s>0}),m=`[${a.join(",")}]`;return w(),[y,m]}}})({u:t=>(u(),t.replace(e,`$1${o}`)),t:g,j:h},(e,t)=>v?((e,t)=>{let r=[];for(let a of e.split("\n")){let e;try{e=JSON.parse(a).push?.channel}catch{}if("string"==typeof e){if(t-(j.get(e)??-1e15)<1e3/M)continue;j.size>999&&(j=new Map),j.set(e,t)}r.push(a)}return r.join("\n")})(e,t)||null:e),P=[],T=0,U=0,J=0,N=new Map,B=0,_=e=>{if(2==e.type){B=Math.max(B,e.timestamp);for(let[t,[,r]]of N)r<e.timestamp&&N.delete(t)}k.add(e)},A=[],C=0,D=0,K=0,E=!1,L=e=>{let t=A.indexOf(e);t>=0&&(C-=A.splice(t,1)[0].b.length),e.s&&m.postMessage([3,e.s])},R=(e,t)=>{e.f=!0,D++,fetch(b,{method:"POST",body:e.b,keepalive:t,credentials:"omit",headers:{"Content-Type":"text/plain"}}).then(e=>{let t=+(e.headers.get("x-replayd-disable")??0);t>0&&m.postMessage([1,t]);let r=e.status;return r<400?0:r<500&&429!=r?-2:+(e.headers.get("retry-after")??0)||-1},()=>-1).then(t=>{if(e.f=!1,D--,t>-2&&t&&++e.n<5)return clearTimeout(K),E=t>0,void(K=setTimeout(()=>{K=0,F()},t>0?1e3*t:Math.min(6e4,500*2**e.n)));S&&-1==t?L(e):(t&&O++,z(e),F())})},z=e=>{L(e),e.p?.then(e=>null!=e&&y("q",e)).catch(()=>{})},I=async e=>{if(e&&K&&!E&&(clearTimeout(K),K=0,F()),!$){$=1;try{let e=new Set(await Promise.all(A.map(e=>e.p))),[t,r]=await(()=>{let e=[],t=[],r=0,a=0;return c("q",!0,s=>{let n=Date.now(),i=s.openCursor();i.onsuccess=()=>{let l=i.result;if(l)return t.push([l.primaryKey,l.value]),void l.continue();for(let i=t.length-1;i>=0;i--){let[l,o]=t[i];n-o.t>864e5||(a+=o.b.byteLength)>20971520?(s.delete(l),r++):e.unshift([l,o])}}}).then(()=>[e,r])})();O+=r;for(let[r,a]of t)if(!(e.has(r)||C+a.b.byteLength>w)){if(a.s&&x.has(a.s)){y("q",r).catch(()=>{});continue}A.push({b:a.b,n:0,p:Promise.resolve(r)}),C+=a.b.byteLength}}catch{}$=0,F()}},F=e=>{if(!e&&(D||K))return;let t=6e4;for(let r of A){if(r.f)continue;let a=r.b.length;if(!e)return R(r,a<6e4);let s=a<t;s&&(t-=a),R(r,s)}},V=async(e,t,r,s,n)=>{let i=function(e,t,r=[]){let s=a.encode(e);if(s.length>32768)throw new RangeError("meta too large");let n=2+s.length+4+t.length+2;for(let e of r)n+=9+e.data.length;let i=new Uint8Array(n),l=new DataView(i.buffer),o=0;l.setUint16(o,s.length,!0),o+=2,i.set(s,o),o+=s.length,l.setUint32(o,t.length,!0),o+=4,i.set(t,o),o+=t.length,l.setUint16(o,r.length,!0),o+=2;for(let e of r)l.setUint32(o,e.id,!0),o+=4,i[o++]=e.type,l.setUint32(o,e.data.length,!0),o+=4,i.set(e.data,o),o+=e.data.length;return i}(e,new Uint8Array(await new Response(new Blob([t]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer()),n),l={b:i,n:0,s:r};S&&(l.p=((e,t)=>c("q",!0,e=>e.add(t)))(0,{t:Date.now(),b:i}).catch(()=>{})),A.push(l),C+=i.length;for(let e=0;C>w&&e<A.length-1;)A[e].f?e++:(L(A[e]),S||O++);F(s)};m.onmessage=e=>{let t=e.data;try{if(1==t[0]){t[2]&&l(t[2]);for(let e of t[1])_(e)}else if(2==t[0]){t[5]&&l(t[5]);for(let e of t[4]??[])_(e);let e=t[1],r=t[2].split("\0"),a=[];for(let t=0;t<e.length;t++)a.push({id:e[t],value:r[t]});_({type:3,timestamp:t[3],data:{source:0,texts:a,attributes:[],removes:[],adds:[]}})}else if(3==t[0])((e,t,a)=>{l(t),r&&r.sid==e.sid&&(e.init??=r.init,e.fields??=r.fields,e.ws_disc+=r.ws_disc),r=0;let s=`${e.sid}:${e.seq}`;if(!k.n())return r=e,void m.postMessage([3,s]);let[n,i]=k.take({...e,canvas_bytes:T},O),o=P;return q=O=T=0,P=[],V(n,i,s,a,o)})(t[1],t[2],t[3])?.catch(()=>{});else if(5==t[0])k.reset(),P=[],q=T=0,N.clear(),t[1]&&F(!0);else if(6==t[0]){let e=JSON.parse(t[1]),r=`${e.sid}:${e.seq}`;x.add(r),O+=0|t[3],V(t[1],t[2],r).catch(()=>{})}else 7==t[0]?(async(e,t,r,a,s)=>{try{if(J)return;if(U>30<<20)return _({type:5,timestamp:r,data:{tag:"gap",payload:{reason:"canvas cap"}}}),void(J=1);let n=t.width,i=t.height,l=Math.min(1,a/n),o=Math.max(1,Math.round(n*l)),d=Math.max(1,Math.round(i*l)),f=new OffscreenCanvas(o,d),u=f.getContext("2d");u.drawImage(t,0,0,o,d);let h=new Uint32Array(u.getImageData(0,0,o,d).data.buffer),g=2166136261^n^i<<16;for(let e=0;e<h.length;e++)g=Math.imul(g^h[e],16777619);if(N.get(e)?.[0]===g)return;let p=await f.convertToBlob({type:"image/webp",quality:s});if("image/webp"!=p.type)return void(J=1);let c=new Uint8Array(await p.arrayBuffer());r>=B&&N.set(e,[g,r]),P.push({id:P.length,type:1,data:c}),T+=c.length,U+=c.length,_({type:5,timestamp:r,data:{tag:"canvas",payload:{id:e,a:P.length-1,w:n,h:i}}})}finally{t.close(),m.postMessage([2,e,J])}})(t[1],t[2],t[3],t[4],t[5]):0==t[0]?(b=t[1],l(t[2]),v=t[3],M=t[4]||1,S=t[5]?1:0,I()):4==t[0]&&I(1);(k.raw()>=262144||T>=1<<20)&&!q&&(q=1,m.postMessage([0]))}catch{}}})();
2
2
  //# sourceMappingURL=worker.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["qre","kre","late","te","TextEncoder","O","redact","headers","bodyKeys","queryParams","v","redactVer","setRedact","r","d","length","FILTERED","esc","s","replace","re","k","map","join","RegExp","rJson","x","Array","isArray","y","o","Object","create","includes","toLowerCase","rText","c","trimStart","JSON","stringify","parse","split","_m","a","_x","f","db","run","st","rw","Promise","ok","no","indexedDB","open","onupgradeneeded","result","createObjectStore","autoIncrement","onsuccess","onerror","error","catch","e","then","t","transaction","objectStore","oncomplete","onabort","del","delete","G","self","CAP","url","co","cpc","last","Map","ob","draining","kept","Set","asked","gap","S","sample","P","raw","n","t0","t1","clicks","errs","warns","urls","url1","u","push","reset","add","data","ts","timestamp","type","href","source","p","payload","tag","level","value","j","to","dir","take","m","init","ref","user","fields","custom_fields","tags","encode","unshift","reason","segments","meta","canvas_bytes","enc","has_error","json","seg","l","ch","channel","get","size","set","A","ab","cvb","cvOff","sum","fs","Math","max","id","q","qb","fl","tm","sv","rm","it","i","indexOf","splice","b","postMessage","go","ka","fetch","method","body","keepalive","credentials","off","status","ra","clearTimeout","setTimeout","pump","min","done","drain","async","now","mine","all","recs","lost","out","Date","openCursor","primaryKey","continue","byteLength","load","has","resolve","hide","send","metaJson","eventsGz","assets","RangeError","Uint8Array","dv","DataView","buffer","setUint16","setUint32","encodeSegment","Response","Blob","stream","pipeThrough","CompressionStream","arrayBuffer","put","onmessage","ids","texts","attributes","removes","adds","sid","ws_disc","seq","cut","clear","bmp","mw","ql","W0","width","H0","height","w","round","h","oc","OffscreenCanvas","getContext","drawImage","px","Uint32Array","getImageData","imul","convertToBlob","quality","close","shot"],"sources":["../src/wire.ts","../src/redact.ts","../src/worker/index.ts","../src/worker/cfg.ts","../src/idb.ts","../src/seg.ts"],"sourcesContent":["/**\n * Replay segment wire format (PRD §4.10) and `.rpl` reader (PRD §5.3). Little-endian.\n *\n * body: u16 meta_len | meta JSON | u32 events_len | events (gzip) | u16 asset_count | assets…\n * asset: u32 asset_id | u8 type (1 = webp) | u32 len | bytes\n * .rpl: \"RPL2\" | u16 version | 16-byte sid, then frames:\n * u32 len | u32 seq | u64 t0 | u64 t1 | u32 received_at | u8 flags | body-without-meta\n *\n * Mirrors server/crates/common/src/{wire,rpl}.rs; cross-checked by fixtures in /fixtures/wire.\n */\n\nexport const ASSET_WEBP = 1;\nexport const RPL_HEADER_LEN = 22;\nexport const RPL_FRAME_HEADER_LEN = 29;\nexport const RPL_FLAG_GAP = 1;\nexport const RPL_FLAG_HAS_ERROR = 2;\nexport const RPL_FLAG_REDACTED = 4;\n\nexport interface WireAsset {\n id: number;\n type: number;\n data: Uint8Array;\n}\n\nconst te = /* @__PURE__ */ new TextEncoder();\n\n/** Encodes a replay segment body. `metaJson` must be a JSON object string; `eventsGz` gzip bytes. */\nexport function encodeSegment(metaJson: string, eventsGz: Uint8Array, assets: WireAsset[] = []): Uint8Array {\n const meta = te.encode(metaJson);\n if (meta.length > 32 * 1024) throw new RangeError('meta too large');\n let size = 2 + meta.length + 4 + eventsGz.length + 2;\n for (const a of assets) size += 9 + a.data.length;\n const out = new Uint8Array(size);\n const dv = new DataView(out.buffer);\n let p = 0;\n dv.setUint16(p, meta.length, true); p += 2;\n out.set(meta, p); p += meta.length;\n dv.setUint32(p, eventsGz.length, true); p += 4;\n out.set(eventsGz, p); p += eventsGz.length;\n dv.setUint16(p, assets.length, true); p += 2;\n for (const a of assets) {\n dv.setUint32(p, a.id, true); p += 4;\n out[p++] = a.type;\n dv.setUint32(p, a.data.length, true); p += 4;\n out.set(a.data, p); p += a.data.length;\n }\n return out;\n}\n\nexport interface StoredBody {\n events: Uint8Array;\n assets: WireAsset[];\n}\n\n/** Parses a body-without-meta (as stored in a `.rpl` frame). Throws on malformed input. */\nexport function parseStoredBody(b: Uint8Array): StoredBody {\n const dv = new DataView(b.buffer, b.byteOffset, b.byteLength);\n const need = (p: number, n: number) => {\n if (p + n > b.length) throw new RangeError('truncated body');\n };\n let p = 0;\n need(p, 4);\n const el = dv.getUint32(p, true); p += 4;\n need(p, el);\n const events = b.subarray(p, p + el); p += el;\n need(p, 2);\n const n = dv.getUint16(p, true); p += 2;\n const assets: WireAsset[] = [];\n for (let i = 0; i < n; i++) {\n need(p, 9);\n const id = dv.getUint32(p, true);\n const type = b[p + 4]!;\n const len = dv.getUint32(p + 5, true);\n p += 9;\n need(p, len);\n assets.push({ id, type, data: b.subarray(p, p + len) });\n p += len;\n }\n if (p !== b.length) throw new RangeError('trailing bytes');\n return { events, assets };\n}\n\n/** Splits a full segment body into meta JSON text and the stored body. */\nexport function splitSegment(b: Uint8Array): { meta: string; body: Uint8Array } {\n if (b.length < 2) throw new RangeError('truncated');\n const ml = b[0]! | (b[1]! << 8);\n if (2 + ml > b.length) throw new RangeError('truncated meta');\n return { meta: new TextDecoder().decode(b.subarray(2, 2 + ml)), body: b.subarray(2 + ml) };\n}\n\nexport interface RplFrame {\n seq: number;\n t0: number;\n t1: number;\n receivedAt: number;\n flags: number;\n body: Uint8Array;\n}\n\nexport interface RplIndex {\n sid: string;\n frames: RplFrame[];\n validLen: number;\n duplicates: number;\n}\n\nconst hex = (b: Uint8Array) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');\n\n/** Formats 16 raw bytes as a UUID string. */\nexport function uuidFromBytes(b: Uint8Array): string {\n const h = hex(b);\n return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;\n}\n\n/**\n * Indexes an `.rpl` buffer: ignores a truncated tail, keeps the first copy of each seq, sorts by seq.\n * Works on partial (streamed) buffers too: `validLen` tells how far complete frames go.\n */\nexport function indexRpl(buf: Uint8Array): RplIndex {\n if (buf.length < RPL_HEADER_LEN) throw new RangeError('short');\n if (buf[0] !== 0x52 || buf[1] !== 0x50 || buf[2] !== 0x4c || buf[3] !== 0x32) throw new Error('bad magic');\n const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n const version = dv.getUint16(4, true);\n if (version !== 1) throw new Error(`unsupported version ${version}`);\n const sid = uuidFromBytes(buf.subarray(6, 22));\n const frames: RplFrame[] = [];\n let p = RPL_HEADER_LEN;\n while (p + RPL_FRAME_HEADER_LEN <= buf.length) {\n const len = dv.getUint32(p, true);\n const end = p + RPL_FRAME_HEADER_LEN + len;\n if (len > 4 * 1024 * 1024 || end > buf.length) break;\n frames.push({\n seq: dv.getUint32(p + 4, true),\n t0: Number(dv.getBigUint64(p + 8, true)),\n t1: Number(dv.getBigUint64(p + 16, true)),\n receivedAt: dv.getUint32(p + 24, true),\n flags: buf[p + 28]!,\n body: buf.subarray(p + RPL_FRAME_HEADER_LEN, end),\n });\n p = end;\n }\n frames.sort((a, b) => a.seq - b.seq); // stable: first copy of a seq stays first\n const out: RplFrame[] = [];\n for (const f of frames) if (out.length === 0 || out[out.length - 1]!.seq !== f.seq) out.push(f);\n return { sid, frames: out, validLen: p, duplicates: frames.length - out.length };\n}\n","/**\n * Redaction (PRD §0.2, §4.11): headers stripped, query params + JSON keys replaced by `[Filtered]`,\n * recursive to depth 8, case-insensitive. Pure functions over `O.redact` — reusable by the worker (T-20).\n */\nimport { O, redactVer } from './config';\n\nexport const FILTERED = '[Filtered]';\nconst esc = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\nlet v = -1, qre: RegExp, kre: RegExp;\nconst re = () => {\n if (v == redactVer()) return;\n v = redactVer();\n const k = O.redact.bodyKeys.map(esc).join('|');\n // URL params: query-param list + body keys (e.g. `#access_token=` in OAuth redirects)\n qre = new RegExp(`([?&#;](?:${O.redact.queryParams.map(esc).join('|')}|${k})=)[^&#;]*`, 'gi');\n // fallback for non-JSON / truncated text: `\"key\": value` and form fields `key=value`\n kre = new RegExp(`(\"(?:${k})\"\\\\s*:\\\\s*)(\"(?:[^\"\\\\\\\\]|\\\\\\\\.)*\"?|[^,}\\\\]\\\\s]+)|((?:^|&)(?:${k})=)[^&\\\\s]*`, 'gi');\n};\n\n/** redacts secret query params (and fragment params) of a URL string */\nexport const rUrl = (u: string) => (re(), u.replace(qre, `$1${FILTERED}`));\n\n/** copies headers into a lower-cased plain object, dropping the header denylist */\nexport const rHeaders = (h: Iterable<[string, string]>) => {\n const o: Record<string, string> = {};\n for (const [k, x] of h) {\n const l = k.toLowerCase();\n if (!O.redact.headers.includes(l)) o[l] = x;\n }\n return o;\n};\n\n/** recursive key redaction; subtrees deeper than 8 levels are dropped (never leaked unredacted) */\nexport const rJson = (x: unknown, d = 0): unknown => {\n if (!x || typeof x != 'object') return x;\n if (d > 7) return '[Depth]';\n if (Array.isArray(x)) return x.map((y) => rJson(y, d + 1));\n const o: Record<string, unknown> = Object.create(null);\n for (const k in x) o[k] = O.redact.bodyKeys.includes(k.toLowerCase()) ? FILTERED : rJson((x as Record<string, unknown>)[k], d + 1);\n return o;\n};\n\n/**\n * Redacts a text body / WS frame. JSON (≤ 100 KB) is parsed and redacted structurally; newline-batched\n * JSON (Centrifugo) line by line; anything else (truncated frames, form bodies) by regex.\n */\nexport const rText = (s: string): string => {\n re();\n const c = s.trimStart()[0];\n if ((c == '{' || c == '[') && s.length < 1e5)\n try {\n return JSON.stringify(rJson(JSON.parse(s)));\n } catch {\n /* not (complete) JSON */\n }\n if (s.includes('\\n')) return s.split('\\n').map(rText).join('\\n');\n return s.replace(kre, (_m, a, _x, f) => (a ? `${a}\"${FILTERED}\"` : f + FILTERED));\n};\n","/**\n * Replay worker (PRD §4.10, D-09/D-15): per-event redaction + bookkeeping, Centrifugo per-channel sampling,\n * JSON encoding, gzip (CompressionStream), segment wrapping (wire.ts) and upload with retry/backoff, a 5 MB\n * drop-oldest queue and gap markers. Built as a classic IIFE script (build.json) with `./config` aliased to\n * ./cfg so redact.ts runs here without the main-thread config module.\n *\n * Main → worker: [0, url, redact, centrifugo, perChannelPerSec, outbox] init · [4] drain the outbox (online/resume) · [1, events] batch ·\n * [2, ids, values, ts, events] events, then coalesced texts (D-04) · [3, meta, redact, hide] cut a segment ·\n * [5, unload] drop the current segment (idle expiry, T-90); unload: the main thread sent it itself,\n * send the queue now ·\n * [6, meta, events, gap] send a segment the previous page of this tab kept when it unloaded (T-89); gap:\n * kept segments dropped before it (D-80) ·\n * [7, nodeId, ImageBitmap, ts, maxWidth, quality] canvas snapshot (T-91)\n * Worker → main: [0] raw events / canvas bytes over the segment limit (please cut) · [1, seconds] X-Replayd-Disable ·\n * [2, nodeId, off] canvas snapshot handled (the next one of that canvas may follow; off: no more) ·\n * [3, 'sid:seq'] that segment is out of this worker's hands (sent, rejected, stored or dropped, D-80)\n */\nimport type { RedactOptions } from '../types';\nimport { encodeSegment, type WireAsset } from '../wire';\nimport { rJson, rText, rUrl } from '../redact';\nimport { seg } from '../seg';\nimport { setRedact } from './cfg';\nimport { del, load, put } from '../idb';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype A = any;\ninterface Q {\n b: Uint8Array;\n n: number;\n f?: boolean;\n /** outbox key (IndexedDB), when the outbox is on */\n p?: Promise<IDBValidKey | undefined>;\n /** 'sid:seq', acknowledged to the main thread once the segment leaves the queue */\n s?: string;\n}\nconst G = self as unknown as { postMessage(m: unknown): void; onmessage: ((e: MessageEvent) => void) | null };\nconst CAP = 5 << 20, KA = 6e4, FULL = 256 << 10;\n\nlet url = '', co = 0, cpc = 1, last = new Map<string, number>();\n/** IndexedDB outbox (PRD §4.9: Capacitor always, web with `offlineQueue: true`): every segment is stored before\n * it is sent and deleted once the server answered; network failures stay stored and are drained later */\nlet ob = 0, draining = 0;\n/** 'sid:seq' of the segments the previous page of this tab handed over ([6]): their outbox copies are not sent twice */\nconst kept = new Set<string>();\n// cut already asked for the current segment\nlet asked = 0;\n// segments lost since the last one that went out (queue cap, retries exhausted, rejected)\nlet gap = 0;\n\n/** Centrifugo JSON: keeps lines whose `push.channel` passed its 1/perChannelPerSec gate (others: replies etc.) */\nconst sample = (s: string, ts: number) => {\n const k: string[] = [];\n for (const l of s.split('\\n')) {\n let ch: unknown;\n try {\n ch = JSON.parse(l).push?.channel;\n } catch {\n /* truncated / not JSON: keep */\n }\n if (typeof ch == 'string') {\n if (ts - (last.get(ch) ?? -1e15) < 1e3 / cpc) continue;\n if (last.size > 999) last = new Map();\n last.set(ch, ts);\n }\n k.push(l);\n }\n return k.join('\\n');\n};\n\n// current segment (redaction, sampling, counters)\nconst S = seg({ u: rUrl, t: rText, j: rJson }, (s, ts) => (co ? sample(s, ts) || null : s));\n\n// ---- canvas snapshots (PRD §4.7, T-91): downscale, skip unchanged, WebP, binary asset of the current segment\n/** assets of the current segment (a canvas event names its asset by index: both always land in one segment) */\nlet A: WireAsset[] = [], ab = 0;\n/** canvas bytes of this page (PRD: 30 MB per session, then capture stops with a gap marker, `cvOff`) */\nlet cvb = 0, cvOff = 0;\n/** last frame per canvas node: [checksum, time]. A full snapshot (latest: `fs`) rebuilds blank canvases, so no frame\n * taken before it may hide a later one; its event can reach the worker before or after such frames. */\nconst sum = new Map<number, [number, number]>();\nlet fs = 0;\nconst add = (e: A) => {\n if (e.type == 2) {\n fs = Math.max(fs, e.timestamp);\n for (const [id, [, t]] of sum) if (t < e.timestamp) sum.delete(id);\n }\n S.add(e);\n};\nconst shot = async (id: number, bmp: ImageBitmap, ts: number, mw: number, ql: number) => {\n try {\n if (cvOff) return;\n if (cvb > 30 << 20) {\n add({ type: 5, timestamp: ts, data: { tag: 'gap', payload: { reason: 'canvas cap' } } });\n cvOff = 1;\n return;\n }\n const W0 = bmp.width, H0 = bmp.height, s = Math.min(1, mw / W0), w = Math.max(1, Math.round(W0 * s)), h = Math.max(1, Math.round(H0 * s));\n const oc = new OffscreenCanvas(w, h), x = oc.getContext('2d')!;\n x.drawImage(bmp, 0, 0, w, h);\n // FNV-1a over the scaled pixels: an unchanged canvas (idle chart, weekend) costs no bytes\n const px = new Uint32Array(x.getImageData(0, 0, w, h).data.buffer);\n let c = 0x811c9dc5 ^ W0 ^ (H0 << 16);\n for (let i = 0; i < px.length; i++) c = Math.imul(c ^ px[i]!, 16777619);\n if (sum.get(id)?.[0] === c) return;\n const b = await oc.convertToBlob({ type: 'image/webp', quality: ql });\n // a browser without a WebP encoder (Safari) returns PNG: the wire format only carries WebP, so no canvases here\n if (b.type != 'image/webp') return void (cvOff = 1);\n const data = new Uint8Array(await b.arrayBuffer());\n if (ts >= fs) sum.set(id, [c, ts]);\n A.push({ id: A.length, type: 1, data });\n ab += data.length;\n cvb += data.length;\n add({ type: 5, timestamp: ts, data: { tag: 'canvas', payload: { id, a: A.length - 1, w: W0, h: H0 } } });\n } finally {\n bmp.close();\n G.postMessage([2, id, cvOff]);\n }\n};\n\n// ---- upload queue: one request in flight, exp. backoff 1 s → 60 s, max 5 attempts, Retry-After on 429/503\nconst q: Q[] = [];\n// sv: the pending timer is a server Retry-After (honoured even on online/resume), else a network backoff\nlet qb = 0, fl = 0, tm: ReturnType<typeof setTimeout> | 0 = 0, sv = false;\nconst rm = (it: Q) => {\n const i = q.indexOf(it);\n if (i >= 0) qb -= q.splice(i, 1)[0]!.b.length;\n if (it.s) G.postMessage([3, it.s]);\n};\nconst go = (it: Q, ka: boolean) => {\n it.f = true;\n fl++;\n fetch(url, { method: 'POST', body: it.b as BodyInit, keepalive: ka, credentials: 'omit', headers: { 'Content-Type': 'text/plain' } })\n .then(\n (r) => {\n const off = +(r.headers.get('x-replayd-disable') ?? 0);\n if (off > 0) G.postMessage([1, off]);\n const s = r.status;\n // 0 = done; -2 = rejected (4xx other than 429: retrying can't fix it); > 0 Retry-After s; -1 backoff\n return s < 400 ? 0 : s < 500 && s != 429 ? -2 : +(r.headers.get('retry-after') ?? 0) || -1;\n },\n () => -1,\n )\n .then((ra) => {\n it.f = false;\n fl--;\n if (ra > -2 && ra && ++it.n < 5) {\n clearTimeout(tm);\n sv = ra > 0;\n tm = setTimeout(\n () => {\n tm = 0;\n pump();\n },\n ra > 0 ? ra * 1e3 : Math.min(6e4, 500 * 2 ** it.n),\n );\n return;\n }\n // stored segments survive network/5xx failures (drained on online/resume/next start); else: lost\n if (ob && ra == -1) {\n rm(it);\n return;\n }\n if (ra) gap++;\n done(it);\n pump();\n });\n};\n/** finished (sent or rejected): out of memory and out of the outbox */\nconst done = (it: Q) => {\n rm(it);\n it.p?.then((k) => k != null && del('q', k)).catch(() => {});\n};\n/** loads stored segments that are not in memory (oldest first, ≤ the memory cap); expired/over-cap → gap */\nconst drain = async (now?: 1) => {\n // back online / resumed: a network backoff (up to 60 s) would hold the whole outbox, retry now\n if (now && tm && !sv) {\n clearTimeout(tm);\n tm = 0;\n pump();\n }\n // also without the outbox: an unloading page stores the segments it could not send there (D-80)\n if (draining) return;\n draining = 1;\n try {\n const mine = new Set(await Promise.all(q.map((x) => x.p)));\n const [recs, lost] = await load('q');\n gap += lost;\n for (const [k, r] of recs) {\n if (mine.has(k) || qb + r.b.byteLength > CAP) continue;\n if (r.s && kept.has(r.s)) {\n del('q', k).catch(() => {});\n continue;\n }\n q.push({ b: r.b, n: 0, p: Promise.resolve(k) });\n qb += r.b.byteLength;\n }\n } catch {\n /* no IndexedDB (private mode, quota): memory queue only */\n }\n draining = 0;\n pump();\n};\n/** sends the head (sequential); on hide: everything not in flight, keepalive within a 60 KB total */\nconst pump = (hide?: boolean) => {\n if (!hide && (fl || tm)) return;\n let ka = KA;\n for (const it of q) {\n if (it.f) continue;\n const s = it.b.length;\n if (!hide) return go(it, s < KA);\n const k = s < ka;\n if (k) ka -= s;\n go(it, k);\n }\n};\n\n/** meta of a cut that had no events to go with (all of them sampled out). The main thread has already counted its\n * init, field snapshot and WS disconnects as sent: they go with the next segment of that session. */\nlet late: A;\nconst cut = (m: A, r: Required<RedactOptions>, hide: boolean) => {\n setRedact(r);\n if (late && late.sid == m.sid) {\n m.init ??= late.init;\n m.fields ??= late.fields;\n m.ws_disc += late.ws_disc;\n }\n late = 0;\n const s = `${m.sid}:${m.seq}`;\n if (!S.n()) return void ((late = m), G.postMessage([3, s]));\n const [meta, json] = S.take({ ...m, canvas_bytes: ab }, gap), a = A;\n asked = gap = ab = 0;\n A = [];\n return send(meta, json, s, hide, a);\n};\nconst send = async (meta: string, json: string, s: string, hide?: boolean, a?: WireAsset[]) => {\n const gz = new Uint8Array(await new Response(new Blob([json]).stream().pipeThrough(new CompressionStream('gzip'))).arrayBuffer());\n const b = encodeSegment(meta, gz, a), it: Q = { b, n: 0, s };\n if (ob) it.p = put('q', { t: Date.now(), b }).catch(() => undefined);\n q.push(it);\n qb += b.length;\n // 5 MB memory cap: drop the oldest segments that are not in flight (with the outbox they stay stored)\n for (let i = 0; qb > CAP && i < q.length - 1; )\n if (q[i]!.f) i++;\n else {\n rm(q[i]!);\n if (!ob) gap++;\n }\n pump(hide);\n};\n\nG.onmessage = (e: MessageEvent) => {\n const m = e.data;\n try {\n // redaction lists that grew since the last message apply before this batch is redacted\n if (m[0] == 1) {\n if (m[2]) setRedact(m[2]);\n for (const x of m[1]) add(x);\n } else if (m[0] == 2) {\n if (m[5]) setRedact(m[5]);\n for (const x of m[4] ?? []) add(x);\n const ids: Int32Array = m[1], v: string[] = m[2].split('\\0'), texts = [];\n for (let i = 0; i < ids.length; i++) texts.push({ id: ids[i], value: v[i] });\n add({ type: 3, timestamp: m[3], data: { source: 0, texts, attributes: [], removes: [], adds: [] } });\n } else if (m[0] == 3) cut(m[1], m[2], m[3])?.catch(() => {});\n else if (m[0] == 5) {\n S.reset();\n A = [];\n asked = ab = 0;\n // the dropped frames never reach the replay: an unchanged canvas has to be sent again\n sum.clear();\n if (m[1]) pump(true);\n } else if (m[0] == 6) {\n const x = JSON.parse(m[1]), s = `${x.sid}:${x.seq}`;\n kept.add(s);\n gap += m[3] | 0;\n send(m[1], m[2], s).catch(() => {});\n }\n else if (m[0] == 7) void shot(m[1], m[2], m[3], m[4], m[5]);\n else if (m[0] == 0) {\n url = m[1];\n setRedact(m[2]);\n co = m[3];\n cpc = m[4] || 1;\n ob = m[5] ? 1 : 0;\n void drain();\n } else if (m[0] == 4) void drain(1);\n // canvas frames count as well: a segment stays well under the 2 MB ingest limit\n if ((S.raw() >= FULL || ab >= 1 << 20) && !asked) {\n asked = 1;\n G.postMessage([0]);\n }\n } catch {\n /* a malformed event must not kill the worker */\n }\n};\n","/**\n * Worker build stand-in for `../config` (build.json alias): redact.ts reads its lists from `O.redact`.\n * The main thread sends the resolved lists (defaults + user + remote extensions) with every segment cut.\n */\nimport type { RedactOptions } from '../types';\n\nexport const O = { redact: { headers: [], bodyKeys: [], queryParams: [] } as Required<RedactOptions> };\nlet v = 0;\nexport const redactVer = () => v;\n/** replaces the lists when they changed (they only ever grow, so comparing lengths is enough) */\nexport const setRedact = (r: Required<RedactOptions>) => {\n const d = O.redact;\n if (r.headers.length + r.bodyKeys.length + r.queryParams.length != d.headers.length + d.bodyKeys.length + d.queryParams.length) {\n O.redact = r;\n v++;\n }\n};\n","/**\n * Tiny IndexedDB outbox shared by the replay worker (store `q`: segments) and the Capacitor chunk (store `e`:\n * error-event bodies). PRD §4.9: cap 20 MB, max age 24 h, oldest first. Never imported by index.js.\n * Records: `{ t: enqueued ms, b: body bytes, k?: ingest kind }`, auto-increment keys (= insertion order).\n */\nexport interface Rec {\n t: number;\n b: Uint8Array;\n k?: string;\n /** 'sid:seq' of a replay segment an unloading page stored (D-80) */\n s?: string;\n}\nexport const CAP = 20 << 20, AGE = 864e5;\nlet db: Promise<IDBDatabase> | null = null;\nconst open = () =>\n (db ??= new Promise<IDBDatabase>((ok, no) => {\n const r = indexedDB.open('replayd', 1);\n r.onupgradeneeded = () => {\n for (const s of ['q', 'e']) r.result.createObjectStore(s, { autoIncrement: true });\n };\n r.onsuccess = () => ok(r.result);\n r.onerror = () => no(r.error);\n })).catch((e) => {\n db = null;\n throw e;\n });\n\nconst run = <T>(st: string, rw: boolean, f: (s: IDBObjectStore) => IDBRequest<T> | void) =>\n open().then(\n (d) =>\n new Promise<T | undefined>((ok, no) => {\n const t = d.transaction(st, rw ? 'readwrite' : 'readonly'), r = f(t.objectStore(st));\n t.oncomplete = () => ok(r ? r.result : undefined);\n t.onerror = t.onabort = () => no(t.error);\n }),\n );\n\n/** appends a record; resolves to its key */\nexport const put = (st: string, v: Rec) => run<IDBValidKey>(st, true, (s) => s.add(v));\nexport const del = (st: string, k: IDBValidKey) => run(st, true, (s) => void s.delete(k));\n\n/**\n * All records oldest first, after dropping the expired (> 24 h) and the oldest beyond 20 MB.\n * Resolves to `[kept: [key, rec][], dropped count]`.\n */\nexport const load = (st: string): Promise<[[IDBValidKey, Rec][], number]> => {\n const out: [IDBValidKey, Rec][] = [], all: [IDBValidKey, Rec][] = [];\n let n = 0, size = 0;\n return run(st, true, (s) => {\n const now = Date.now(), c = s.openCursor();\n c.onsuccess = () => {\n const x = c.result;\n if (x) {\n all.push([x.primaryKey, x.value as Rec]);\n x.continue();\n return;\n }\n // newest first for the size cap, then back to oldest-first order\n for (let i = all.length - 1; i >= 0; i--) {\n const [k, v] = all[i]!;\n if (now - v.t > AGE || (size += v.b.byteLength) > CAP) {\n s.delete(k);\n n++;\n } else out.unshift([k, v]);\n }\n };\n }).then(() => [out, n]);\n};\n","/**\n * Replay segment builder (PRD §4.10), shared by the worker and, on page unload, the replay chunk's main thread\n * (T-89): per-event redaction and bookkeeping, then the meta + events JSON of one segment. It imports nothing: the\n * redaction functions are passed in (the worker has its own copy of redact.ts, the main thread core's through\n * `Internal`), so neither build pulls a core module into a shared chunk.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype A = any;\nexport interface Red {\n /** URL redaction (query/fragment params) */\n u: (s: string) => string;\n /** text body / WS frame redaction */\n t: (s: string) => string;\n /** recursive JSON key redaction */\n j: (x: unknown) => unknown;\n}\n\n/** `sample`: incoming WS frame → the frame to keep, null = drop it (worker: Centrifugo per-channel sampling) */\nexport const seg = (r: Red, sample?: (raw: string, ts: number) => string | null) => {\n let P: string[] = [], raw = 0, n = 0, t0 = 0, t1 = 0, clicks = 0, errs = 0, warns = 0, urls: string[] = [];\n const url1 = (u: unknown) => typeof u == 'string' && urls.length < 10 && !urls.includes(u) && urls.push(u);\n const reset = () => {\n P = [];\n raw = n = t1 = clicks = errs = warns = 0;\n urls = [];\n };\n return {\n raw: () => raw,\n n: () => n,\n reset,\n add(e: A) {\n const d = e.data, ts = e.timestamp;\n if (e.type == 4 && d.href) url1((d.href = r.u(d.href)));\n else if (e.type == 3 && d.source == 2 && d.type == 2) clicks++;\n else if (e.type == 5) {\n const p = d.payload;\n if (d.tag == 'error') {\n if (p.level == 'warning') warns++;\n else errs++;\n }\n else if (d.tag == 'fields') p.value = r.j(p.value);\n // core redacts its history navigations; the page-load entry comes raw from the replay chunk\n else if (d.tag == 'nav' && typeof p.to == 'string') url1((p.to = r.u(p.to)));\n else if (d.tag == 'network') {\n for (const k of ['reqBody', 'resBody']) if (typeof p[k] == 'string') p[k] = r.t(p[k]);\n }\n else if (d.tag == 'ws' && typeof p.raw == 'string') {\n if (sample && p.dir == 'in') {\n const x = sample(p.raw, ts);\n if (x == null) return;\n p.raw = x;\n }\n p.raw = r.t(p.raw);\n }\n }\n if (!n++) t0 = ts;\n if (ts > t1) t1 = ts;\n const s = JSON.stringify(e);\n raw += s.length;\n P.push(s);\n },\n /** the segment's [meta JSON, events JSON]; `m` = sid/seq/init/fields from the main thread, `gap` = segments lost\n * before it. Starts the next segment. */\n take(m: A, gap: number): [string, string] {\n if (m.init) {\n m.init.url = r.u(m.init.url);\n m.init.ref = r.u(m.init.ref);\n m.init.user = r.j(m.init.user);\n }\n if (m.fields) {\n m.fields.user = r.j(m.fields.user);\n m.fields.custom_fields = r.j(m.fields.custom_fields);\n m.fields.tags = r.j(m.fields.tags);\n // tags have no limit of their own: past 8 KB they stay out (the server keeps the last ones) so the 32 KB meta fits\n if (new TextEncoder().encode(JSON.stringify(m.fields.tags)).length > 8192) delete m.fields.tags;\n }\n if (gap) P.unshift(JSON.stringify({ type: 5, timestamp: t0, data: { tag: 'gap', payload: { reason: 'dropped', segments: gap } } }));\n const meta = JSON.stringify({ canvas_bytes: 0, ...m, t0, t1, enc: 'gzip', n, urls, clicks, errs, warns, has_error: errs > 0, gap: gap > 0 });\n const json = `[${P.join(',')}]`;\n reset();\n return [meta, json];\n },\n };\n};\n\nlet CRC: Int32Array | undefined;\n/**\n * gzip without compression (stored deflate blocks), built synchronously: a page that is unloading cannot wait for\n * CompressionStream. Larger than real gzip, so it is only used for the unload segment's keepalive request.\n */\nexport const stored = (d: Uint8Array): Uint8Array => {\n if (!CRC) {\n CRC = new Int32Array(256);\n for (let i = 0; i < 256; i++) {\n let c = i;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[i] = c;\n }\n }\n const len = d.length, nb = Math.ceil(len / 65535) || 1, o = new Uint8Array(18 + len + nb * 5), v = new DataView(o.buffer);\n o.set([31, 139, 8, 0, 0, 0, 0, 0, 0, 255]);\n let p = 10, i = 0, c = -1;\n for (let b = 0; b < nb; b++) {\n const l = Math.min(65535, len - i);\n o[p] = +(b == nb - 1);\n v.setUint16(p + 1, l, true);\n v.setUint16(p + 3, ~l, true);\n o.set(d.subarray(i, (i += l)), (p += 5));\n p += l;\n }\n for (let k = 0; k < len; k++) c = CRC[(c ^ d[k]!) & 255]! ^ (c >>> 8);\n v.setUint32(p, ~c, true);\n v.setUint32(p + 4, len, true);\n return o;\n};\n\n/** segment body without assets (wire.ts layout; the replay chunk must not import wire.ts, also a build entry) */\nexport const body = (meta: string, gz: Uint8Array): Uint8Array => {\n const m = new TextEncoder().encode(meta), o = new Uint8Array(8 + m.length + gz.length), v = new DataView(o.buffer);\n v.setUint16(0, m.length, true);\n o.set(m, 2);\n v.setUint32(2 + m.length, gz.length, true);\n o.set(gz, 6 + m.length);\n return o;\n};\n"],"mappings":"mBAwBA,IChBYA,EAAaC,ECkNrBC,EFlMEC,EAAqB,IAAIC,YGlBlBC,EAAI,CAAEC,OAAQ,CAAEC,QAAS,GAAIC,SAAU,GAAIC,YAAa,KACjEC,EAAI,EACKC,EAAY,IAAMD,EAElBE,EAAaC,IACxB,IAAMC,EAAIT,EAAEC,OACRO,EAAEN,QAAQQ,OAASF,EAAEL,SAASO,OAASF,EAAEJ,YAAYM,QAAUD,EAAEP,QAAQQ,OAASD,EAAEN,SAASO,OAASD,EAAEL,YAAYM,SACtHV,EAAEC,OAASO,EACXH,MFRSM,EAAW,aAClBC,EAAOC,GAAcA,EAAEC,QAAQ,sBAAuB,QACxDT,GAAI,EACFU,EAAK,KACT,GAAIV,GAAKC,IAAa,OACtBD,EAAIC,IACJ,IAAMU,EAAIhB,EAAEC,OAAOE,SAASc,IAAIL,GAAKM,KAAK,KAE1CvB,EAAM,IAAIwB,OAAO,aAAanB,EAAEC,OAAOG,YAAYa,IAAIL,GAAKM,KAAK,QAAQF,cAAe,MAExFpB,EAAM,IAAIuB,OAAO,QAAQH,iEAAiEA,eAAgB,OAiB/FI,EAAQ,CAACC,EAAYZ,EAAI,KACpC,IAAKY,GAAiB,iBAALA,EAAe,OAAOA,EACvC,GAAIZ,EAAI,EAAG,MAAO,UAClB,GAAIa,MAAMC,QAAQF,GAA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AE5B1F,EAAEG,OA3P2B,QA2PVoD,GAAM,GAAK,MAAQzD,IACzCA,EAAQ,EACRZ,EAAEwF,YAAY,CAAC,IAEnB,OAEA,EACF,E","ignoreList":[]}
1
+ {"version":3,"names":["qre","kre","late","te","TextEncoder","O","redact","headers","bodyKeys","queryParams","v","redactVer","setRedact","r","d","length","FILTERED","esc","s","replace","re","k","map","join","RegExp","rJson","x","Array","isArray","y","o","Object","create","includes","toLowerCase","rText","c","trimStart","JSON","stringify","parse","split","_m","a","_x","f","db","run","st","rw","Promise","ok","no","indexedDB","open","onupgradeneeded","result","createObjectStore","autoIncrement","onsuccess","onerror","error","catch","e","then","t","transaction","objectStore","oncomplete","onabort","del","delete","G","self","CAP","url","co","cpc","last","Map","ob","draining","kept","Set","asked","gap","S","sample","mem","P","raw","n","t0","t1","clicks","errs","warns","urls","sig","vit","tr","tr1","push","url1","u","reset","add","data","ts","timestamp","type","href","source","p","payload","tag","level","used","Math","max","value","j","to","status","cat","msg","slice","dir","take","m","init","ref","user","fields","custom_fields","tags","encode","unshift","reason","segments","meta","canvas_bytes","enc","vitals","has_error","json","seg","l","ch","channel","get","size","set","A","ab","cvb","cvOff","sum","fs","id","q","qb","fl","tm","sv","rm","it","i","indexOf","splice","b","postMessage","go","ka","fetch","method","body","keepalive","credentials","off","ra","clearTimeout","setTimeout","pump","min","done","drain","async","now","mine","all","recs","lost","out","Date","openCursor","primaryKey","continue","byteLength","load","has","resolve","hide","send","metaJson","eventsGz","assets","RangeError","Uint8Array","dv","DataView","buffer","setUint16","setUint32","encodeSegment","Response","Blob","stream","pipeThrough","CompressionStream","arrayBuffer","put","onmessage","ids","texts","attributes","removes","adds","sid","ws_disc","seq","cut","clear","bmp","mw","ql","W0","width","H0","height","w","round","h","oc","OffscreenCanvas","getContext","drawImage","px","Uint32Array","getImageData","imul","convertToBlob","quality","close","shot"],"sources":["../src/wire.ts","../src/redact.ts","../src/worker/index.ts","../src/worker/cfg.ts","../src/idb.ts","../src/seg.ts"],"sourcesContent":["/**\n * Replay segment wire format (PRD §4.10) and `.rpl` reader (PRD §5.3). Little-endian.\n *\n * body: u16 meta_len | meta JSON | u32 events_len | events (gzip) | u16 asset_count | assets…\n * asset: u32 asset_id | u8 type (1 = webp) | u32 len | bytes\n * .rpl: \"RPL2\" | u16 version | 16-byte sid, then frames:\n * u32 len | u32 seq | u64 t0 | u64 t1 | u32 received_at | u8 flags | body-without-meta\n *\n * Mirrors server/crates/common/src/{wire,rpl}.rs; cross-checked by fixtures in /fixtures/wire.\n */\n\nexport const ASSET_WEBP = 1;\nexport const RPL_HEADER_LEN = 22;\nexport const RPL_FRAME_HEADER_LEN = 29;\nexport const RPL_FLAG_GAP = 1;\nexport const RPL_FLAG_HAS_ERROR = 2;\nexport const RPL_FLAG_REDACTED = 4;\n\nexport interface WireAsset {\n id: number;\n type: number;\n data: Uint8Array;\n}\n\nconst te = /* @__PURE__ */ new TextEncoder();\n\n/** Encodes a replay segment body. `metaJson` must be a JSON object string; `eventsGz` gzip bytes. */\nexport function encodeSegment(metaJson: string, eventsGz: Uint8Array, assets: WireAsset[] = []): Uint8Array {\n const meta = te.encode(metaJson);\n if (meta.length > 32 * 1024) throw new RangeError('meta too large');\n let size = 2 + meta.length + 4 + eventsGz.length + 2;\n for (const a of assets) size += 9 + a.data.length;\n const out = new Uint8Array(size);\n const dv = new DataView(out.buffer);\n let p = 0;\n dv.setUint16(p, meta.length, true); p += 2;\n out.set(meta, p); p += meta.length;\n dv.setUint32(p, eventsGz.length, true); p += 4;\n out.set(eventsGz, p); p += eventsGz.length;\n dv.setUint16(p, assets.length, true); p += 2;\n for (const a of assets) {\n dv.setUint32(p, a.id, true); p += 4;\n out[p++] = a.type;\n dv.setUint32(p, a.data.length, true); p += 4;\n out.set(a.data, p); p += a.data.length;\n }\n return out;\n}\n\nexport interface StoredBody {\n events: Uint8Array;\n assets: WireAsset[];\n}\n\n/** Parses a body-without-meta (as stored in a `.rpl` frame). Throws on malformed input. */\nexport function parseStoredBody(b: Uint8Array): StoredBody {\n const dv = new DataView(b.buffer, b.byteOffset, b.byteLength);\n const need = (p: number, n: number) => {\n if (p + n > b.length) throw new RangeError('truncated body');\n };\n let p = 0;\n need(p, 4);\n const el = dv.getUint32(p, true); p += 4;\n need(p, el);\n const events = b.subarray(p, p + el); p += el;\n need(p, 2);\n const n = dv.getUint16(p, true); p += 2;\n const assets: WireAsset[] = [];\n for (let i = 0; i < n; i++) {\n need(p, 9);\n const id = dv.getUint32(p, true);\n const type = b[p + 4]!;\n const len = dv.getUint32(p + 5, true);\n p += 9;\n need(p, len);\n assets.push({ id, type, data: b.subarray(p, p + len) });\n p += len;\n }\n if (p !== b.length) throw new RangeError('trailing bytes');\n return { events, assets };\n}\n\n/** Splits a full segment body into meta JSON text and the stored body. */\nexport function splitSegment(b: Uint8Array): { meta: string; body: Uint8Array } {\n if (b.length < 2) throw new RangeError('truncated');\n const ml = b[0]! | (b[1]! << 8);\n if (2 + ml > b.length) throw new RangeError('truncated meta');\n return { meta: new TextDecoder().decode(b.subarray(2, 2 + ml)), body: b.subarray(2 + ml) };\n}\n\nexport interface RplFrame {\n seq: number;\n t0: number;\n t1: number;\n receivedAt: number;\n flags: number;\n body: Uint8Array;\n}\n\nexport interface RplIndex {\n sid: string;\n frames: RplFrame[];\n validLen: number;\n duplicates: number;\n}\n\nconst hex = (b: Uint8Array) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');\n\n/** Formats 16 raw bytes as a UUID string. */\nexport function uuidFromBytes(b: Uint8Array): string {\n const h = hex(b);\n return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;\n}\n\n/**\n * Indexes an `.rpl` buffer: ignores a truncated tail, keeps the first copy of each seq, sorts by seq.\n * Works on partial (streamed) buffers too: `validLen` tells how far complete frames go.\n */\nexport function indexRpl(buf: Uint8Array): RplIndex {\n if (buf.length < RPL_HEADER_LEN) throw new RangeError('short');\n if (buf[0] !== 0x52 || buf[1] !== 0x50 || buf[2] !== 0x4c || buf[3] !== 0x32) throw new Error('bad magic');\n const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n const version = dv.getUint16(4, true);\n if (version !== 1) throw new Error(`unsupported version ${version}`);\n const sid = uuidFromBytes(buf.subarray(6, 22));\n const frames: RplFrame[] = [];\n let p = RPL_HEADER_LEN;\n while (p + RPL_FRAME_HEADER_LEN <= buf.length) {\n const len = dv.getUint32(p, true);\n const end = p + RPL_FRAME_HEADER_LEN + len;\n if (len > 4 * 1024 * 1024 || end > buf.length) break;\n frames.push({\n seq: dv.getUint32(p + 4, true),\n t0: Number(dv.getBigUint64(p + 8, true)),\n t1: Number(dv.getBigUint64(p + 16, true)),\n receivedAt: dv.getUint32(p + 24, true),\n flags: buf[p + 28]!,\n body: buf.subarray(p + RPL_FRAME_HEADER_LEN, end),\n });\n p = end;\n }\n frames.sort((a, b) => a.seq - b.seq); // stable: first copy of a seq stays first\n const out: RplFrame[] = [];\n for (const f of frames) if (out.length === 0 || out[out.length - 1]!.seq !== f.seq) out.push(f);\n return { sid, frames: out, validLen: p, duplicates: frames.length - out.length };\n}\n","/**\n * Redaction (PRD §0.2, §4.11): headers stripped, query params + JSON keys replaced by `[Filtered]`,\n * recursive to depth 8, case-insensitive. Pure functions over `O.redact` — reusable by the worker (T-20).\n */\nimport { O, redactVer } from './config';\n\nexport const FILTERED = '[Filtered]';\nconst esc = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\nlet v = -1, qre: RegExp, kre: RegExp;\nconst re = () => {\n if (v == redactVer()) return;\n v = redactVer();\n const k = O.redact.bodyKeys.map(esc).join('|');\n // URL params: query-param list + body keys (e.g. `#access_token=` in OAuth redirects)\n qre = new RegExp(`([?&#;](?:${O.redact.queryParams.map(esc).join('|')}|${k})=)[^&#;]*`, 'gi');\n // fallback for non-JSON / truncated text: `\"key\": value` and form fields `key=value`\n kre = new RegExp(`(\"(?:${k})\"\\\\s*:\\\\s*)(\"(?:[^\"\\\\\\\\]|\\\\\\\\.)*\"?|[^,}\\\\]\\\\s]+)|((?:^|&)(?:${k})=)[^&\\\\s]*`, 'gi');\n};\n\n/** redacts secret query params (and fragment params) of a URL string */\nexport const rUrl = (u: string) => (re(), u.replace(qre, `$1${FILTERED}`));\n\n/** copies headers into a lower-cased plain object, dropping the header denylist */\nexport const rHeaders = (h: Iterable<[string, string]>) => {\n const o: Record<string, string> = {};\n for (const [k, x] of h) {\n const l = k.toLowerCase();\n if (!O.redact.headers.includes(l)) o[l] = x;\n }\n return o;\n};\n\n/** recursive key redaction; subtrees deeper than 8 levels are dropped (never leaked unredacted) */\nexport const rJson = (x: unknown, d = 0): unknown => {\n if (!x || typeof x != 'object') return x;\n if (d > 7) return '[Depth]';\n if (Array.isArray(x)) return x.map((y) => rJson(y, d + 1));\n const o: Record<string, unknown> = Object.create(null);\n for (const k in x) o[k] = O.redact.bodyKeys.includes(k.toLowerCase()) ? FILTERED : rJson((x as Record<string, unknown>)[k], d + 1);\n return o;\n};\n\n/**\n * Redacts a text body / WS frame. JSON (≤ 100 KB) is parsed and redacted structurally; newline-batched\n * JSON (Centrifugo) line by line; anything else (truncated frames, form bodies) by regex.\n */\nexport const rText = (s: string): string => {\n re();\n const c = s.trimStart()[0];\n if ((c == '{' || c == '[') && s.length < 1e5)\n try {\n return JSON.stringify(rJson(JSON.parse(s)));\n } catch {\n /* not (complete) JSON */\n }\n if (s.includes('\\n')) return s.split('\\n').map(rText).join('\\n');\n return s.replace(kre, (_m, a, _x, f) => (a ? `${a}\"${FILTERED}\"` : f + FILTERED));\n};\n","/**\n * Replay worker (PRD §4.10, D-09/D-15): per-event redaction + bookkeeping, Centrifugo per-channel sampling,\n * JSON encoding, gzip (CompressionStream), segment wrapping (wire.ts) and upload with retry/backoff, a 5 MB\n * drop-oldest queue and gap markers. Built as a classic IIFE script (build.json) with `./config` aliased to\n * ./cfg so redact.ts runs here without the main-thread config module.\n *\n * Main → worker: [0, url, redact, centrifugo, perChannelPerSec, outbox] init · [4] drain the outbox (online/resume) · [1, events] batch ·\n * [2, ids, values, ts, events] events, then coalesced texts (D-04) · [3, meta, redact, hide] cut a segment ·\n * [5, unload] drop the current segment (idle expiry, T-90); unload: the main thread sent it itself,\n * send the queue now ·\n * [6, meta, events, gap] send a segment the previous page of this tab kept when it unloaded (T-89); gap:\n * kept segments dropped before it (D-80) ·\n * [7, nodeId, ImageBitmap, ts, maxWidth, quality] canvas snapshot (T-91)\n * Worker → main: [0] raw events / canvas bytes over the segment limit (please cut) · [1, seconds] X-Replayd-Disable ·\n * [2, nodeId, off] canvas snapshot handled (the next one of that canvas may follow; off: no more) ·\n * [3, 'sid:seq'] that segment is out of this worker's hands (sent, rejected, stored or dropped, D-80)\n */\nimport type { RedactOptions } from '../types';\nimport { encodeSegment, type WireAsset } from '../wire';\nimport { rJson, rText, rUrl } from '../redact';\nimport { seg } from '../seg';\nimport { setRedact } from './cfg';\nimport { del, load, put } from '../idb';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype A = any;\ninterface Q {\n b: Uint8Array;\n n: number;\n f?: boolean;\n /** outbox key (IndexedDB), when the outbox is on */\n p?: Promise<IDBValidKey | undefined>;\n /** 'sid:seq', acknowledged to the main thread once the segment leaves the queue */\n s?: string;\n}\nconst G = self as unknown as { postMessage(m: unknown): void; onmessage: ((e: MessageEvent) => void) | null };\nconst CAP = 5 << 20, KA = 6e4, FULL = 256 << 10;\n\nlet url = '', co = 0, cpc = 1, last = new Map<string, number>();\n/** IndexedDB outbox (PRD §4.9: Capacitor always, web with `offlineQueue: true`): every segment is stored before\n * it is sent and deleted once the server answered; network failures stay stored and are drained later */\nlet ob = 0, draining = 0;\n/** 'sid:seq' of the segments the previous page of this tab handed over ([6]): their outbox copies are not sent twice */\nconst kept = new Set<string>();\n// cut already asked for the current segment\nlet asked = 0;\n// segments lost since the last one that went out (queue cap, retries exhausted, rejected)\nlet gap = 0;\n\n/** Centrifugo JSON: keeps lines whose `push.channel` passed its 1/perChannelPerSec gate (others: replies etc.) */\nconst sample = (s: string, ts: number) => {\n const k: string[] = [];\n for (const l of s.split('\\n')) {\n let ch: unknown;\n try {\n ch = JSON.parse(l).push?.channel;\n } catch {\n /* truncated / not JSON: keep */\n }\n if (typeof ch == 'string') {\n if (ts - (last.get(ch) ?? -1e15) < 1e3 / cpc) continue;\n if (last.size > 999) last = new Map();\n last.set(ch, ts);\n }\n k.push(l);\n }\n return k.join('\\n');\n};\n\n// current segment (redaction, sampling, counters)\nconst S = seg({ u: rUrl, t: rText, j: rJson }, (s, ts) => (co ? sample(s, ts) || null : s));\n\n// ---- canvas snapshots (PRD §4.7, T-91): downscale, skip unchanged, WebP, binary asset of the current segment\n/** assets of the current segment (a canvas event names its asset by index: both always land in one segment) */\nlet A: WireAsset[] = [], ab = 0;\n/** canvas bytes of this page (PRD: 30 MB per session, then capture stops with a gap marker, `cvOff`) */\nlet cvb = 0, cvOff = 0;\n/** last frame per canvas node: [checksum, time]. A full snapshot (latest: `fs`) rebuilds blank canvases, so no frame\n * taken before it may hide a later one; its event can reach the worker before or after such frames. */\nconst sum = new Map<number, [number, number]>();\nlet fs = 0;\nconst add = (e: A) => {\n if (e.type == 2) {\n fs = Math.max(fs, e.timestamp);\n for (const [id, [, t]] of sum) if (t < e.timestamp) sum.delete(id);\n }\n S.add(e);\n};\nconst shot = async (id: number, bmp: ImageBitmap, ts: number, mw: number, ql: number) => {\n try {\n if (cvOff) return;\n if (cvb > 30 << 20) {\n add({ type: 5, timestamp: ts, data: { tag: 'gap', payload: { reason: 'canvas cap' } } });\n cvOff = 1;\n return;\n }\n const W0 = bmp.width, H0 = bmp.height, s = Math.min(1, mw / W0), w = Math.max(1, Math.round(W0 * s)), h = Math.max(1, Math.round(H0 * s));\n const oc = new OffscreenCanvas(w, h), x = oc.getContext('2d')!;\n x.drawImage(bmp, 0, 0, w, h);\n // FNV-1a over the scaled pixels: an unchanged canvas (idle chart, weekend) costs no bytes\n const px = new Uint32Array(x.getImageData(0, 0, w, h).data.buffer);\n let c = 0x811c9dc5 ^ W0 ^ (H0 << 16);\n for (let i = 0; i < px.length; i++) c = Math.imul(c ^ px[i]!, 16777619);\n if (sum.get(id)?.[0] === c) return;\n const b = await oc.convertToBlob({ type: 'image/webp', quality: ql });\n // a browser without a WebP encoder (Safari) returns PNG: the wire format only carries WebP, so no canvases here\n if (b.type != 'image/webp') return void (cvOff = 1);\n const data = new Uint8Array(await b.arrayBuffer());\n if (ts >= fs) sum.set(id, [c, ts]);\n A.push({ id: A.length, type: 1, data });\n ab += data.length;\n cvb += data.length;\n add({ type: 5, timestamp: ts, data: { tag: 'canvas', payload: { id, a: A.length - 1, w: W0, h: H0 } } });\n } finally {\n bmp.close();\n G.postMessage([2, id, cvOff]);\n }\n};\n\n// ---- upload queue: one request in flight, exp. backoff 1 s → 60 s, max 5 attempts, Retry-After on 429/503\nconst q: Q[] = [];\n// sv: the pending timer is a server Retry-After (honoured even on online/resume), else a network backoff\nlet qb = 0, fl = 0, tm: ReturnType<typeof setTimeout> | 0 = 0, sv = false;\nconst rm = (it: Q) => {\n const i = q.indexOf(it);\n if (i >= 0) qb -= q.splice(i, 1)[0]!.b.length;\n if (it.s) G.postMessage([3, it.s]);\n};\nconst go = (it: Q, ka: boolean) => {\n it.f = true;\n fl++;\n fetch(url, { method: 'POST', body: it.b as BodyInit, keepalive: ka, credentials: 'omit', headers: { 'Content-Type': 'text/plain' } })\n .then(\n (r) => {\n const off = +(r.headers.get('x-replayd-disable') ?? 0);\n if (off > 0) G.postMessage([1, off]);\n const s = r.status;\n // 0 = done; -2 = rejected (4xx other than 429: retrying can't fix it); > 0 Retry-After s; -1 backoff\n return s < 400 ? 0 : s < 500 && s != 429 ? -2 : +(r.headers.get('retry-after') ?? 0) || -1;\n },\n () => -1,\n )\n .then((ra) => {\n it.f = false;\n fl--;\n if (ra > -2 && ra && ++it.n < 5) {\n clearTimeout(tm);\n sv = ra > 0;\n tm = setTimeout(\n () => {\n tm = 0;\n pump();\n },\n ra > 0 ? ra * 1e3 : Math.min(6e4, 500 * 2 ** it.n),\n );\n return;\n }\n // stored segments survive network/5xx failures (drained on online/resume/next start); else: lost\n if (ob && ra == -1) {\n rm(it);\n return;\n }\n if (ra) gap++;\n done(it);\n pump();\n });\n};\n/** finished (sent or rejected): out of memory and out of the outbox */\nconst done = (it: Q) => {\n rm(it);\n it.p?.then((k) => k != null && del('q', k)).catch(() => {});\n};\n/** loads stored segments that are not in memory (oldest first, ≤ the memory cap); expired/over-cap → gap */\nconst drain = async (now?: 1) => {\n // back online / resumed: a network backoff (up to 60 s) would hold the whole outbox, retry now\n if (now && tm && !sv) {\n clearTimeout(tm);\n tm = 0;\n pump();\n }\n // also without the outbox: an unloading page stores the segments it could not send there (D-80)\n if (draining) return;\n draining = 1;\n try {\n const mine = new Set(await Promise.all(q.map((x) => x.p)));\n const [recs, lost] = await load('q');\n gap += lost;\n for (const [k, r] of recs) {\n if (mine.has(k) || qb + r.b.byteLength > CAP) continue;\n if (r.s && kept.has(r.s)) {\n del('q', k).catch(() => {});\n continue;\n }\n q.push({ b: r.b, n: 0, p: Promise.resolve(k) });\n qb += r.b.byteLength;\n }\n } catch {\n /* no IndexedDB (private mode, quota): memory queue only */\n }\n draining = 0;\n pump();\n};\n/** sends the head (sequential); on hide: everything not in flight, keepalive within a 60 KB total */\nconst pump = (hide?: boolean) => {\n if (!hide && (fl || tm)) return;\n let ka = KA;\n for (const it of q) {\n if (it.f) continue;\n const s = it.b.length;\n if (!hide) return go(it, s < KA);\n const k = s < ka;\n if (k) ka -= s;\n go(it, k);\n }\n};\n\n/** meta of a cut that had no events to go with (all of them sampled out). The main thread has already counted its\n * init, field snapshot and WS disconnects as sent: they go with the next segment of that session. */\nlet late: A;\nconst cut = (m: A, r: Required<RedactOptions>, hide: boolean) => {\n setRedact(r);\n if (late && late.sid == m.sid) {\n m.init ??= late.init;\n m.fields ??= late.fields;\n m.ws_disc += late.ws_disc;\n }\n late = 0;\n const s = `${m.sid}:${m.seq}`;\n if (!S.n()) return void ((late = m), G.postMessage([3, s]));\n const [meta, json] = S.take({ ...m, canvas_bytes: ab }, gap), a = A;\n asked = gap = ab = 0;\n A = [];\n return send(meta, json, s, hide, a);\n};\nconst send = async (meta: string, json: string, s: string, hide?: boolean, a?: WireAsset[]) => {\n const gz = new Uint8Array(await new Response(new Blob([json]).stream().pipeThrough(new CompressionStream('gzip'))).arrayBuffer());\n const b = encodeSegment(meta, gz, a), it: Q = { b, n: 0, s };\n if (ob) it.p = put('q', { t: Date.now(), b }).catch(() => undefined);\n q.push(it);\n qb += b.length;\n // 5 MB memory cap: drop the oldest segments that are not in flight (with the outbox they stay stored)\n for (let i = 0; qb > CAP && i < q.length - 1; )\n if (q[i]!.f) i++;\n else {\n rm(q[i]!);\n if (!ob) gap++;\n }\n pump(hide);\n};\n\nG.onmessage = (e: MessageEvent) => {\n const m = e.data;\n try {\n // redaction lists that grew since the last message apply before this batch is redacted\n if (m[0] == 1) {\n if (m[2]) setRedact(m[2]);\n for (const x of m[1]) add(x);\n } else if (m[0] == 2) {\n if (m[5]) setRedact(m[5]);\n for (const x of m[4] ?? []) add(x);\n const ids: Int32Array = m[1], v: string[] = m[2].split('\\0'), texts = [];\n for (let i = 0; i < ids.length; i++) texts.push({ id: ids[i], value: v[i] });\n add({ type: 3, timestamp: m[3], data: { source: 0, texts, attributes: [], removes: [], adds: [] } });\n } else if (m[0] == 3) cut(m[1], m[2], m[3])?.catch(() => {});\n else if (m[0] == 5) {\n S.reset();\n A = [];\n asked = ab = 0;\n // the dropped frames never reach the replay: an unchanged canvas has to be sent again\n sum.clear();\n if (m[1]) pump(true);\n } else if (m[0] == 6) {\n const x = JSON.parse(m[1]), s = `${x.sid}:${x.seq}`;\n kept.add(s);\n gap += m[3] | 0;\n send(m[1], m[2], s).catch(() => {});\n }\n else if (m[0] == 7) void shot(m[1], m[2], m[3], m[4], m[5]);\n else if (m[0] == 0) {\n url = m[1];\n setRedact(m[2]);\n co = m[3];\n cpc = m[4] || 1;\n ob = m[5] ? 1 : 0;\n void drain();\n } else if (m[0] == 4) void drain(1);\n // canvas frames count as well: a segment stays well under the 2 MB ingest limit\n if ((S.raw() >= FULL || ab >= 1 << 20) && !asked) {\n asked = 1;\n G.postMessage([0]);\n }\n } catch {\n /* a malformed event must not kill the worker */\n }\n};\n","/**\n * Worker build stand-in for `../config` (build.json alias): redact.ts reads its lists from `O.redact`.\n * The main thread sends the resolved lists (defaults + user + remote extensions) with every segment cut.\n */\nimport type { RedactOptions } from '../types';\n\nexport const O = { redact: { headers: [], bodyKeys: [], queryParams: [] } as Required<RedactOptions> };\nlet v = 0;\nexport const redactVer = () => v;\n/** replaces the lists when they changed (they only ever grow, so comparing lengths is enough) */\nexport const setRedact = (r: Required<RedactOptions>) => {\n const d = O.redact;\n if (r.headers.length + r.bodyKeys.length + r.queryParams.length != d.headers.length + d.bodyKeys.length + d.queryParams.length) {\n O.redact = r;\n v++;\n }\n};\n","/**\n * Tiny IndexedDB outbox shared by the replay worker (store `q`: segments) and the Capacitor chunk (store `e`:\n * error-event bodies). PRD §4.9: cap 20 MB, max age 24 h, oldest first. Never imported by index.js.\n * Records: `{ t: enqueued ms, b: body bytes, k?: ingest kind }`, auto-increment keys (= insertion order).\n */\nexport interface Rec {\n t: number;\n b: Uint8Array;\n k?: string;\n /** 'sid:seq' of a replay segment an unloading page stored (D-80) */\n s?: string;\n}\nexport const CAP = 20 << 20, AGE = 864e5;\nlet db: Promise<IDBDatabase> | null = null;\nconst open = () =>\n (db ??= new Promise<IDBDatabase>((ok, no) => {\n const r = indexedDB.open('replayd', 1);\n r.onupgradeneeded = () => {\n for (const s of ['q', 'e']) r.result.createObjectStore(s, { autoIncrement: true });\n };\n r.onsuccess = () => ok(r.result);\n r.onerror = () => no(r.error);\n })).catch((e) => {\n db = null;\n throw e;\n });\n\nconst run = <T>(st: string, rw: boolean, f: (s: IDBObjectStore) => IDBRequest<T> | void) =>\n open().then(\n (d) =>\n new Promise<T | undefined>((ok, no) => {\n const t = d.transaction(st, rw ? 'readwrite' : 'readonly'), r = f(t.objectStore(st));\n t.oncomplete = () => ok(r ? r.result : undefined);\n t.onerror = t.onabort = () => no(t.error);\n }),\n );\n\n/** appends a record; resolves to its key */\nexport const put = (st: string, v: Rec) => run<IDBValidKey>(st, true, (s) => s.add(v));\nexport const del = (st: string, k: IDBValidKey) => run(st, true, (s) => void s.delete(k));\n\n/**\n * All records oldest first, after dropping the expired (> 24 h) and the oldest beyond 20 MB.\n * Resolves to `[kept: [key, rec][], dropped count]`.\n */\nexport const load = (st: string): Promise<[[IDBValidKey, Rec][], number]> => {\n const out: [IDBValidKey, Rec][] = [], all: [IDBValidKey, Rec][] = [];\n let n = 0, size = 0;\n return run(st, true, (s) => {\n const now = Date.now(), c = s.openCursor();\n c.onsuccess = () => {\n const x = c.result;\n if (x) {\n all.push([x.primaryKey, x.value as Rec]);\n x.continue();\n return;\n }\n // newest first for the size cap, then back to oldest-first order\n for (let i = all.length - 1; i >= 0; i--) {\n const [k, v] = all[i]!;\n if (now - v.t > AGE || (size += v.b.byteLength) > CAP) {\n s.delete(k);\n n++;\n } else out.unshift([k, v]);\n }\n };\n }).then(() => [out, n]);\n};\n","/**\n * Replay segment builder (PRD §4.10), shared by the worker and, on page unload, the replay chunk's main thread\n * (T-89): per-event redaction and bookkeeping, then the meta + events JSON of one segment. It imports nothing: the\n * redaction functions are passed in (the worker has its own copy of redact.ts, the main thread core's through\n * `Internal`), so neither build pulls a core module into a shared chunk.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype A = any;\nexport interface Red {\n /** URL redaction (query/fragment params) */\n u: (s: string) => string;\n /** text body / WS frame redaction */\n t: (s: string) => string;\n /** recursive JSON key redaction */\n j: (x: unknown) => unknown;\n}\n\n/** `sample`: incoming WS frame → the frame to keep, null = drop it (worker: Centrifugo per-channel sampling) */\nexport const seg = (r: Red, sample?: (raw: string, ts: number) => string | null) => {\n let P: string[] = [], raw = 0, n = 0, t0 = 0, t1 = 0, clicks = 0, errs = 0, warns = 0, urls: string[] = [], sig: Record<string, number> = {}, vit: A[] = [], mem: A, st: number[] = [], tr: string[] = [];\n // T-123: the order things first happened in (`u:` page URL, `c:` app breadcrumb `cat:msg`), for search and funnels\n const tr1 = (x: string) => tr.length < 30 && !tr.includes(x) && tr.push(x);\n const url1 = (u: unknown) => typeof u == 'string' && (tr1('u:' + u), urls.length < 10 && !urls.includes(u) && urls.push(u));\n const reset = () => {\n P = [];\n raw = n = t1 = clicks = errs = warns = 0;\n urls = [];\n sig = {};\n vit = [];\n mem = undefined;\n st = [];\n tr = [];\n };\n return {\n raw: () => raw,\n n: () => n,\n reset,\n add(e: A) {\n const d = e.data, ts = e.timestamp;\n if (e.type == 4 && d.href) url1((d.href = r.u(d.href)));\n else if (e.type == 3 && d.source == 2 && d.type == 2) clicks++;\n else if (e.type == 5) {\n const p = d.payload;\n if (d.tag == 'error') {\n if (p.level == 'warning') warns++;\n else errs++;\n }\n else if (d.tag == 'sig') {\n sig[p.k] = (sig[p.k] ?? 0) + 1;\n if (p.k == 'vitals') vit.push(p);\n // T-119: the segment's heap peak (and device memory from the first sample)\n if (p.k == 'mem') mem = { ...mem, ...p, used: Math.max(mem?.used ?? 0, p.used ?? 0) };\n }\n else if (d.tag == 'fields') p.value = r.j(p.value);\n // core redacts its history navigations; the page-load entry comes raw from the replay chunk\n else if (d.tag == 'nav' && typeof p.to == 'string') url1((p.to = r.u(p.to)));\n else if (d.tag == 'network') {\n for (const k of ['reqBody', 'resBody']) if (typeof p[k] == 'string') p[k] = r.t(p[k]);\n // T-123: failed statuses seen (0 = no response)\n if ((p.status >= 400 || p.status === 0) && st.length < 10 && !st.includes(p.status)) st.push(p.status);\n }\n else if (d.tag == 'breadcrumb') tr1(('c:' + p.cat + ':' + p.msg).slice(0, 100));\n else if (d.tag == 'ws' && typeof p.raw == 'string') {\n if (sample && p.dir == 'in') {\n const x = sample(p.raw, ts);\n if (x == null) return;\n p.raw = x;\n }\n p.raw = r.t(p.raw);\n }\n }\n if (!n++) t0 = ts;\n if (ts > t1) t1 = ts;\n const s = JSON.stringify(e);\n raw += s.length;\n P.push(s);\n },\n /** the segment's [meta JSON, events JSON]; `m` = sid/seq/init/fields from the main thread, `gap` = segments lost\n * before it. Starts the next segment. */\n take(m: A, gap: number): [string, string] {\n if (m.init) {\n m.init.url = r.u(m.init.url);\n m.init.ref = r.u(m.init.ref);\n m.init.user = r.j(m.init.user);\n }\n if (m.fields) {\n m.fields.user = r.j(m.fields.user);\n m.fields.custom_fields = r.j(m.fields.custom_fields);\n m.fields.tags = r.j(m.fields.tags);\n // tags have no limit of their own: past 8 KB they stay out (the server keeps the last ones) so the 32 KB meta fits\n if (new TextEncoder().encode(JSON.stringify(m.fields.tags)).length > 8192) delete m.fields.tags;\n }\n if (gap) P.unshift(JSON.stringify({ type: 5, timestamp: t0, data: { tag: 'gap', payload: { reason: 'dropped', segments: gap } } }));\n const meta = JSON.stringify({ canvas_bytes: 0, ...m, t0, t1, enc: 'gzip', n, urls, clicks, errs, warns, sig, vitals: vit, mem, st, tr, has_error: errs > 0, gap: gap > 0 });\n const json = `[${P.join(',')}]`;\n reset();\n return [meta, json];\n },\n };\n};\n\nlet CRC: Int32Array | undefined;\n/**\n * gzip without compression (stored deflate blocks), built synchronously: a page that is unloading cannot wait for\n * CompressionStream. Larger than real gzip, so it is only used for the unload segment's keepalive request.\n */\nexport const stored = (d: Uint8Array): Uint8Array => {\n if (!CRC) {\n CRC = new Int32Array(256);\n for (let i = 0; i < 256; i++) {\n let c = i;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[i] = c;\n }\n }\n const len = d.length, nb = Math.ceil(len / 65535) || 1, o = new Uint8Array(18 + len + nb * 5), v = new DataView(o.buffer);\n o.set([31, 139, 8, 0, 0, 0, 0, 0, 0, 255]);\n let p = 10, i = 0, c = -1;\n for (let b = 0; b < nb; b++) {\n const l = Math.min(65535, len - i);\n o[p] = +(b == nb - 1);\n v.setUint16(p + 1, l, true);\n v.setUint16(p + 3, ~l, true);\n o.set(d.subarray(i, (i += l)), (p += 5));\n p += l;\n }\n for (let k = 0; k < len; k++) c = CRC[(c ^ d[k]!) & 255]! ^ (c >>> 8);\n v.setUint32(p, ~c, true);\n v.setUint32(p + 4, len, true);\n return o;\n};\n\n/** segment body without assets (wire.ts layout; the replay chunk must not import wire.ts, also a build entry) */\nexport const body = (meta: string, gz: Uint8Array): Uint8Array => {\n const m = new TextEncoder().encode(meta), o = new Uint8Array(8 + m.length + gz.length), v = new DataView(o.buffer);\n v.setUint16(0, m.length, true);\n o.set(m, 2);\n v.setUint32(2 + m.length, gz.length, true);\n o.set(gz, 6 + m.length);\n return o;\n};\n"],"mappings":"mBAwBA,IChBYA,EAAaC,ECkNrBC,EFlMEC,EAAqB,IAAIC,YGlBlBC,EAAI,CAAEC,OAAQ,CAAEC,QAAS,GAAIC,SAAU,GAAIC,YAAa,KACjEC,EAAI,EACKC,EAAY,IAAMD,EAElBE,EAAaC,IACxB,IAAMC,EAAIT,EAAEC,OACRO,EAAEN,QAAQQ,OAASF,EAAEL,SAASO,OAASF,EAAEJ,YAAYM,QAAUD,EAAEP,QAAQQ,OAASD,EAAEN,SAASO,OAASD,EAAEL,YAAYM,SACtHV,EAAEC,OAASO,EACXH,MFRSM,EAAW,aAClBC,EAAOC,GAAcA,EAAEC,QAAQ,sBAAuB,QACxDT,GAAI,EACFU,EAAK,KACT,GAAIV,GAAKC,IAAa,OACtBD,EAAIC,IACJ,IAAMU,EAAIhB,EAAEC,OAAOE,SAASc,IAAIL,GAAKM,KAAK,KAE1CvB,EAAM,IAAIwB,OAAO,aAAanB,EAAEC,OAAOG,YAAYa,IAAIL,GAAKM,KAAK,QAAQF,cAAe,MAExFpB,EAAM,IAAIuB,OAAO,QAAQH,iEAAiEA,eAAgB,OAiB/FI,EAAQ,CAACC,EAAYZ,EAAI,KACpC,IAAKY,GAAiB,iB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GAAK,UAC9D,GAAIV,EAAIP,IAAIS,KAAM,KAAO3H,EAAG,OAC5B,IAAMsI,QAAUyE,EAAGQ,cAAc,CAAE7I,KAAM,aAAc8I,QAASjB,IAEhE,GAAc,cAAVjE,EAAE5D,KAAsB,YAAa8C,EAAQ,GACjD,IAAMjD,EAAO,IAAIqG,iBAAiBtC,EAAEkD,eAChChH,GAAMkD,GAAID,EAAIL,IAAIO,EAAI,CAAC3H,EAAGwE,IAC9B6C,EAAEnD,KAAK,CAAEyD,GAAIN,EAAE1I,OAAQ+F,KAAM,EAAGH,SAChC+C,GAAM/C,EAAK5F,OACX4I,GAAOhD,EAAK5F,OACZ2F,EAAI,CAAEI,KAAM,EAAGD,UAAWD,EAAID,KAAM,CAAEQ,IAAK,SAAUD,QAAS,CAAE6C,KAAIpH,EAAG8G,EAAE1I,OAAS,EAAGiO,EAAGJ,EAAIM,EAAGJ,KACjG,SACEL,EAAIoB,QACJrL,EAAEmG,YAAY,CAAC,EAAGZ,EAAIH,GACxB,GAiK2BkG,CAAK7H,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACvC,GAARA,EAAE,IACTtD,EAAMsD,EAAE,GACRrH,EAAUqH,EAAE,IACZrD,EAAKqD,EAAE,GACPpD,EAAMoD,EAAE,IAAM,EACdjD,EAAKiD,EAAE,GAAK,EAAI,EACXyD,KACY,GAARzD,EAAE,IAAcyD,EAAM,IAE5BpG,EAAEI,OA3P2B,QA2PVgE,GAAM,GAAK,MAAQtE,IACzCA,EAAQ,EACRZ,EAAEmG,YAAY,CAAC,IAEnB,OAEA,EACF,E","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayd/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "replayd browser SDK: errors, breadcrumbs, console, network and WebSocket capture, session replay",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@rrweb/record": "2.2.0"
36
36
  },
37
- "gitHead": "cdd3ef1bef13e31db0d36ec969d4d1868c25de2e",
37
+ "gitHead": "1cce427be5cd233e4c3406e42ed69ed807354389",
38
38
  "scripts": {
39
39
  "build": "node ../../scripts/build.mjs build.json && tsc -p tsconfig.build.json"
40
40
  }