posthog-js 1.428.7 → 1.428.9

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.
Files changed (60) hide show
  1. package/LICENSE +64 -0
  2. package/dist/all-external-dependencies.js +1 -1
  3. package/dist/all-external-dependencies.js.map +1 -1
  4. package/dist/array.full.es5.js +1 -1
  5. package/dist/array.full.es5.js.map +1 -1
  6. package/dist/array.full.js +1 -1
  7. package/dist/array.full.js.map +1 -1
  8. package/dist/array.full.no-external.js +1 -1
  9. package/dist/array.full.no-external.js.map +1 -1
  10. package/dist/array.js +1 -1
  11. package/dist/array.js.map +1 -1
  12. package/dist/array.no-external.js +1 -1
  13. package/dist/array.no-external.js.map +1 -1
  14. package/dist/customizations.d.ts +1 -0
  15. package/dist/customizations.full.js +1 -1
  16. package/dist/customizations.js +1 -1
  17. package/dist/default-extensions.js +1 -1
  18. package/dist/default-extensions.js.map +1 -1
  19. package/dist/exception-autocapture.js +1 -1
  20. package/dist/exception-autocapture.js.map +1 -1
  21. package/dist/extension-bundles.js +1 -1
  22. package/dist/extension-bundles.js.map +1 -1
  23. package/dist/lazy-recorder.js +1 -1
  24. package/dist/lazy-recorder.js.map +1 -1
  25. package/dist/main.d.ts +1 -0
  26. package/dist/main.js +1 -1
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.d.ts +1 -0
  29. package/dist/module.full.d.ts +1 -0
  30. package/dist/module.full.js +1 -1
  31. package/dist/module.full.js.map +1 -1
  32. package/dist/module.full.no-external.d.ts +1 -0
  33. package/dist/module.full.no-external.js +1 -1
  34. package/dist/module.full.no-external.js.map +1 -1
  35. package/dist/module.js +1 -1
  36. package/dist/module.js.map +1 -1
  37. package/dist/module.mjs +1 -1
  38. package/dist/module.mjs.map +1 -1
  39. package/dist/module.no-external.d.ts +1 -0
  40. package/dist/module.no-external.js +1 -1
  41. package/dist/module.no-external.js.map +1 -1
  42. package/dist/module.slim.js +1 -1
  43. package/dist/module.slim.no-external.d.ts +1 -0
  44. package/dist/module.slim.no-external.js +1 -1
  45. package/dist/posthog-recorder.d.ts +577 -653
  46. package/dist/posthog-recorder.js +1 -1
  47. package/dist/posthog-recorder.js.map +1 -1
  48. package/dist/recorder.d.ts +577 -653
  49. package/dist/rrweb-plugin-console-record.d.ts +436 -500
  50. package/dist/rrweb-types.d.ts +688 -735
  51. package/dist/rrweb.d.ts +1303 -1433
  52. package/dist/src/entrypoints/rrweb-types.es.d.ts +9 -0
  53. package/dist/src/extensions/replay/types/rrweb-types.d.ts +1 -0
  54. package/lib/package.json +10 -4
  55. package/lib/src/entrypoints/rrweb-types.es.d.ts +9 -0
  56. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +12 -2
  57. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
  58. package/lib/src/extensions/replay/types/rrweb-types.d.ts +1 -0
  59. package/lib/src/extensions/replay/types/rrweb-types.js.map +1 -1
  60. package/package.json +16 -10
@@ -1,663 +1,587 @@
1
- declare type addedNodeMutation = {
2
- parentId: number;
3
- previousId?: number | null;
4
- nextId: number | null;
5
- node: serializedNodeWithId;
6
- };
7
-
8
- declare type adoptedStyleSheetData = {
9
- source: IncrementalSource.AdoptedStyleSheet;
10
- } & adoptedStyleSheetParam;
11
-
12
- declare type adoptedStyleSheetParam = {
13
- id: number;
14
- styles?: {
15
- styleId: number;
16
- rules: styleSheetAddRule[];
17
- }[];
18
- styleIds: number[];
19
- };
20
-
21
- declare type attributeMutation = {
22
- id: number;
23
- attributes: {
24
- [key: string]: string | styleOMValue | null;
25
- };
26
- };
27
-
28
- declare type attributes = cssTextKeyAttr & {
29
- [key: string]: string | number | true | null;
30
- };
31
-
32
- declare type blockClass = string | RegExp;
33
-
34
- declare enum CanvasContext {
35
- '2D' = 0,
36
- WebGL = 1,
37
- WebGL2 = 2
38
- }
39
-
40
- declare type CanvasMasking = {
41
- regionsFn?: (canvas: HTMLCanvasElement) => CanvasMaskRegion[] | null | undefined;
42
- configured?: () => boolean;
43
- };
44
-
45
- declare type CanvasMaskRegion = {
46
- x: number;
47
- y: number;
48
- width: number;
49
- height: number;
50
- };
51
-
52
- declare type canvasMutationCallback = (p: canvasMutationParam) => void;
53
-
54
- declare type canvasMutationCommand = {
55
- property: string;
56
- args: Array<unknown>;
57
- setter?: true;
58
- };
59
-
60
- declare type canvasMutationData = {
61
- source: IncrementalSource.CanvasMutation;
62
- } & canvasMutationParam;
63
-
64
- declare type canvasMutationParam = {
65
- id: number;
66
- type: CanvasContext;
67
- commands: canvasMutationCommand[];
68
- displayWidth?: number;
69
- displayHeight?: number;
70
- } | ({
71
- id: number;
72
- type: CanvasContext;
73
- displayWidth?: number;
74
- displayHeight?: number;
75
- } & canvasMutationCommand);
76
-
77
- declare type cdataNode = {
78
- type: NodeType.CDATA;
79
- textContent: '';
80
- };
81
-
82
- declare type commentNode = {
83
- type: NodeType.Comment;
84
- textContent: string;
85
- };
86
-
87
- declare type cssTextKeyAttr = {
88
- _cssText?: string;
89
- };
90
-
91
- declare type customElementCallback = (c: customElementParam) => void;
92
-
93
- declare type customElementData = {
94
- source: IncrementalSource.CustomElement;
95
- } & customElementParam;
96
-
97
- declare type customElementParam = {
98
- define?: {
99
- name: string;
100
- };
101
- };
102
-
103
- declare type customEvent<T = unknown> = {
104
- type: EventType.Custom;
105
- data: {
106
- tag: string;
107
- payload: T;
108
- };
109
- };
110
-
111
- declare type DataURLOptions = Partial<{
112
- type: string;
113
- quality: number;
114
- maxBase64ImageLength: number;
115
- }>;
116
-
117
- declare type documentNode = {
118
- type: NodeType.Document;
119
- childNodes: serializedNodeWithId[];
120
- compatMode?: string;
121
- };
122
-
123
- declare type documentTypeNode = {
124
- type: NodeType.DocumentType;
125
- name: string;
126
- publicId: string;
127
- systemId: string;
128
- };
129
-
130
- declare type domContentLoadedEvent = {
131
- type: EventType.DomContentLoaded;
132
- data: unknown;
133
- };
134
-
135
- declare type elementNode = {
136
- type: NodeType.Element;
137
- tagName: string;
138
- attributes: attributes;
139
- childNodes: serializedNodeWithId[];
140
- isSVG?: true;
141
- needBlock?: boolean;
142
- isCustom?: true;
143
- };
144
-
145
- declare enum EventType {
146
- DomContentLoaded = 0,
147
- Load = 1,
148
- FullSnapshot = 2,
149
- IncrementalSnapshot = 3,
150
- Meta = 4,
151
- Custom = 5,
152
- Plugin = 6
153
- }
154
-
155
- declare type eventWithoutTime = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
156
-
157
- declare type eventWithTime = eventWithoutTime & {
158
- timestamp: number;
159
- delay?: number;
160
- };
161
-
162
- declare type fontCallback = (p: fontParam) => void;
163
-
164
- declare type fontData = {
165
- source: IncrementalSource.Font;
166
- } & fontParam;
167
-
168
- declare type fontParam = {
169
- family: string;
170
- fontSource: string;
171
- buffer: boolean;
172
- descriptors?: FontFaceDescriptors;
173
- };
174
-
175
- declare type fullSnapshotEvent = {
176
- type: EventType.FullSnapshot;
177
- data: {
178
- node: serializedNodeWithId;
179
- initialOffset: {
180
- top: number;
181
- left: number;
182
- };
183
- };
184
- };
185
-
186
- declare type hooksParam = {
187
- mutation?: mutationCallBack;
188
- mousemove?: mousemoveCallBack;
189
- mouseInteraction?: mouseInteractionCallBack;
190
- scroll?: scrollCallback;
191
- viewportResize?: viewportResizeCallback;
192
- input?: inputCallback;
193
- mediaInteaction?: mediaInteractionCallback;
194
- styleSheetRule?: styleSheetRuleCallback;
195
- styleDeclaration?: styleDeclarationCallback;
196
- canvasMutation?: canvasMutationCallback;
197
- font?: fontCallback;
198
- selection?: selectionCallback;
199
- customElement?: customElementCallback;
200
- };
201
-
202
- declare interface ICrossOriginIframeMirror {
203
- getId(iframe: HTMLIFrameElement, remoteId: number, parentToRemoteMap?: Map<number, number>, remoteToParentMap?: Map<number, number>): number;
204
- getIds(iframe: HTMLIFrameElement, remoteId: number[]): number[];
205
- getRemoteId(iframe: HTMLIFrameElement, parentId: number, map?: Map<number, number>): number;
206
- getRemoteIds(iframe: HTMLIFrameElement, parentId: number[]): number[];
207
- reset(iframe?: HTMLIFrameElement): void;
208
- }
209
-
210
- declare interface IMirror<TNode> {
211
- getId(n: TNode | undefined | null): number;
212
- getNode(id: number): TNode | null;
213
- getIds(): number[];
214
- getMeta(n: TNode): serializedNodeWithId | null;
215
- removeNodeFromMap(n: TNode): void;
216
- has(id: number): boolean;
217
- hasNode(node: TNode): boolean;
218
- add(n: TNode, meta: serializedNodeWithId): void;
219
- replace(id: number, n: TNode): void;
220
- reset(): void;
221
- }
222
-
223
- declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData | customElementData;
224
-
225
- declare type incrementalSnapshotEvent = {
226
- type: EventType.IncrementalSnapshot;
227
- data: incrementalData;
228
- };
229
-
230
- declare enum IncrementalSource {
231
- Mutation = 0,
232
- MouseMove = 1,
233
- MouseInteraction = 2,
234
- Scroll = 3,
235
- ViewportResize = 4,
236
- Input = 5,
237
- TouchMove = 6,
238
- MediaInteraction = 7,
239
- StyleSheetRule = 8,
240
- CanvasMutation = 9,
241
- Font = 10,
242
- Log = 11,
243
- Drag = 12,
244
- StyleDeclaration = 13,
245
- Selection = 14,
246
- AdoptedStyleSheet = 15,
247
- CustomElement = 16
248
- }
249
-
250
- declare type inputCallback = (v: inputValue & {
251
- id: number;
252
- }) => void;
253
-
254
- declare type inputData = {
255
- source: IncrementalSource.Input;
256
- id: number;
257
- } & inputValue;
258
-
259
- declare type inputValue = {
260
- text: string;
261
- isChecked: boolean;
262
- userTriggered?: boolean;
263
- };
264
-
265
- declare type IWindow = Window & typeof globalThis;
266
-
267
- declare type KeepIframeSrcFn = (src: string) => boolean;
268
-
269
- declare type listenerHandler = () => void;
270
-
271
- declare type loadedEvent = {
272
- type: EventType.Load;
273
- data: unknown;
274
- };
275
-
276
- declare type maskTextClass = string | RegExp;
277
-
278
- declare type mediaInteractionCallback = (p: mediaInteractionParam) => void;
279
-
280
- declare type mediaInteractionData = {
281
- source: IncrementalSource.MediaInteraction;
282
- } & mediaInteractionParam;
283
-
284
- declare type mediaInteractionParam = {
285
- type: MediaInteractions;
286
- id: number;
287
- currentTime?: number;
288
- volume?: number;
289
- muted?: boolean;
290
- loop?: boolean;
291
- playbackRate?: number;
292
- };
293
-
294
- declare enum MediaInteractions {
295
- Play = 0,
296
- Pause = 1,
297
- Seeked = 2,
298
- VolumeChange = 3,
299
- RateChange = 4
300
- }
301
-
302
- declare type metaEvent = {
303
- type: EventType.Meta;
304
- data: {
305
- href: string;
306
- width: number;
307
- height: number;
308
- };
309
- };
310
-
311
- declare type mouseInteractionCallBack = (d: mouseInteractionParam) => void;
312
-
313
- declare type mouseInteractionData = {
314
- source: IncrementalSource.MouseInteraction;
315
- } & mouseInteractionParam;
316
-
317
- declare type mouseInteractionParam = {
318
- type: MouseInteractions;
319
- id: number;
320
- x?: number;
321
- y?: number;
322
- pointerType?: PointerTypes;
323
- };
324
-
325
- declare enum MouseInteractions {
326
- MouseUp = 0,
327
- MouseDown = 1,
328
- Click = 2,
329
- ContextMenu = 3,
330
- DblClick = 4,
331
- Focus = 5,
332
- Blur = 6,
333
- TouchStart = 7,
334
- TouchMove_Departed = 8,
335
- TouchEnd = 9,
336
- TouchCancel = 10
337
- }
338
-
339
- declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;
340
-
341
- declare type mousemoveData = {
342
- source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
343
- positions: mousePosition[];
344
- };
345
-
346
- declare type mousePosition = {
347
- x: number;
348
- y: number;
349
- id: number;
350
- timeOffset: number;
351
- };
352
-
353
- declare type mutationCallBack = (m: mutationCallbackParam) => void;
354
-
355
- declare type mutationCallbackParam = {
356
- texts: textMutation[];
357
- attributes: attributeMutation[];
358
- removes: removedNodeMutation[];
359
- adds: addedNodeMutation[];
360
- isAttachIframe?: true;
361
- };
362
-
363
- declare type mutationData = {
364
- source: IncrementalSource.Mutation;
365
- } & mutationCallbackParam;
366
-
367
- declare enum NodeType {
368
- Document = 0,
369
- DocumentType = 1,
370
- Element = 2,
371
- Text = 3,
372
- CDATA = 4,
373
- Comment = 5
374
- }
375
-
376
- declare type PackFn = (event: eventWithTime) => string;
377
-
378
- declare type pluginEvent<T = unknown> = {
379
- type: EventType.Plugin;
380
- data: {
381
- plugin: string;
382
- payload: T;
383
- };
384
- };
385
-
386
- declare enum PointerTypes {
387
- Mouse = 0,
388
- Pen = 1,
389
- Touch = 2
390
- }
391
-
392
- declare type RecordPlugin<TOptions = unknown> = {
393
- name: string;
394
- observer?: (cb: (...args: Array<unknown>) => void, win: IWindow, options: TOptions) => listenerHandler;
395
- eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend;
396
- getMirror?: (mirrors: {
397
- nodeMirror: IMirror<Node>;
398
- crossOriginIframeMirror: ICrossOriginIframeMirror;
399
- crossOriginIframeStyleMirror: ICrossOriginIframeMirror;
400
- }) => void;
401
- options: TOptions;
402
- };
403
-
404
- declare type removedNodeMutation = {
405
- parentId: number;
406
- id: number;
407
- isShadow?: boolean;
408
- };
409
-
410
- declare type SamplingStrategy = Partial<{
411
- mousemove: boolean | number;
412
- mousemoveCallback: number;
413
- mouseInteraction: boolean | Record<string, boolean | undefined>;
414
- scroll: number;
415
- media: number;
416
- input: 'all' | 'last';
417
- canvas: 'all' | number;
418
- }>;
419
-
420
- declare type scrollCallback = (p: scrollPosition) => void;
421
-
422
- declare type scrollData = {
423
- source: IncrementalSource.Scroll;
424
- } & scrollPosition;
425
-
426
- declare type scrollPosition = {
427
- id: number;
428
- x: number;
429
- y: number;
430
- };
431
-
432
- declare type selectionCallback = (p: selectionParam) => void;
433
-
434
- declare type selectionData = {
435
- source: IncrementalSource.Selection;
436
- } & selectionParam;
437
-
438
- declare type selectionParam = {
439
- ranges: Array<SelectionRange>;
440
- };
441
-
442
- declare type SelectionRange = {
443
- start: number;
444
- startOffset: number;
445
- end: number;
446
- endOffset: number;
447
- };
448
-
449
- declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
450
- rootId?: number;
451
- isShadowHost?: boolean;
452
- isShadow?: boolean;
453
- };
454
-
455
- declare type serializedNodeWithId = serializedNode & {
456
- id: number;
457
- };
458
-
459
- declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;
460
-
461
- declare type styleDeclarationData = {
462
- source: IncrementalSource.StyleDeclaration;
463
- } & styleDeclarationParam;
464
-
465
- declare type styleDeclarationParam = {
466
- id?: number;
467
- styleId?: number;
468
- index: number[];
469
- set?: {
470
- property: string;
471
- value: string | null;
472
- priority: string | undefined;
473
- };
474
- remove?: {
475
- property: string;
476
- };
477
- };
478
-
479
- declare type styleOMValue = {
480
- [key: string]: styleValueWithPriority | string | false;
481
- };
482
-
483
- declare type styleSheetAddRule = {
484
- rule: string;
485
- index?: number | number[];
486
- };
487
-
488
- declare type styleSheetDeleteRule = {
489
- index: number | number[];
490
- };
491
-
492
- declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;
493
-
494
- declare type styleSheetRuleData = {
495
- source: IncrementalSource.StyleSheetRule;
496
- } & styleSheetRuleParam;
497
-
498
- declare type styleSheetRuleParam = {
499
- id?: number;
500
- styleId?: number;
501
- removes?: styleSheetDeleteRule[];
502
- adds?: styleSheetAddRule[];
503
- replace?: string;
504
- replaceSync?: string;
505
- };
506
-
507
- declare type styleValueWithPriority = [string, string];
508
-
509
- declare type textMutation = {
510
- id: number;
511
- value: string | null;
512
- };
513
-
514
- declare type textNode = {
515
- type: NodeType.Text;
516
- textContent: string;
517
- isStyle?: true;
518
- };
519
-
520
- declare type viewportResizeCallback = (d: viewportResizeDimension) => void;
521
-
522
- declare type viewportResizeData = {
523
- source: IncrementalSource.ViewportResize;
524
- } & viewportResizeDimension;
525
-
526
- declare type viewportResizeDimension = {
527
- width: number;
528
- height: number;
529
- };
530
-
531
-
532
-
1
+ //#region src/index.d.ts
2
+ declare enum EventType {
3
+ DomContentLoaded = 0,
4
+ Load = 1,
5
+ FullSnapshot = 2,
6
+ IncrementalSnapshot = 3,
7
+ Meta = 4,
8
+ Custom = 5,
9
+ Plugin = 6
10
+ }
11
+ type domContentLoadedEvent = {
12
+ type: EventType.DomContentLoaded;
13
+ data: unknown;
14
+ };
15
+ type loadedEvent = {
16
+ type: EventType.Load;
17
+ data: unknown;
18
+ };
19
+ type fullSnapshotEvent = {
20
+ type: EventType.FullSnapshot;
21
+ data: {
22
+ node: serializedNodeWithId;
23
+ initialOffset: {
24
+ top: number;
25
+ left: number;
26
+ };
27
+ };
28
+ };
29
+ type incrementalSnapshotEvent = {
30
+ type: EventType.IncrementalSnapshot;
31
+ data: incrementalData;
32
+ };
33
+ type metaEvent = {
34
+ type: EventType.Meta;
35
+ data: {
36
+ href: string;
37
+ width: number;
38
+ height: number;
39
+ };
40
+ };
41
+ type customEvent<T = unknown> = {
42
+ type: EventType.Custom;
43
+ data: {
44
+ tag: string;
45
+ payload: T;
46
+ };
47
+ };
48
+ type pluginEvent<T = unknown> = {
49
+ type: EventType.Plugin;
50
+ data: {
51
+ plugin: string;
52
+ payload: T;
53
+ };
54
+ };
55
+ declare enum IncrementalSource {
56
+ Mutation = 0,
57
+ MouseMove = 1,
58
+ MouseInteraction = 2,
59
+ Scroll = 3,
60
+ ViewportResize = 4,
61
+ Input = 5,
62
+ TouchMove = 6,
63
+ MediaInteraction = 7,
64
+ StyleSheetRule = 8,
65
+ CanvasMutation = 9,
66
+ Font = 10,
67
+ Log = 11,
68
+ Drag = 12,
69
+ StyleDeclaration = 13,
70
+ Selection = 14,
71
+ AdoptedStyleSheet = 15,
72
+ CustomElement = 16
73
+ }
74
+ type mutationData = {
75
+ source: IncrementalSource.Mutation;
76
+ } & mutationCallbackParam;
77
+ type mousemoveData = {
78
+ source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
79
+ positions: mousePosition[];
80
+ };
81
+ type mouseInteractionData = {
82
+ source: IncrementalSource.MouseInteraction;
83
+ } & mouseInteractionParam;
84
+ type scrollData = {
85
+ source: IncrementalSource.Scroll;
86
+ } & scrollPosition;
87
+ type viewportResizeData = {
88
+ source: IncrementalSource.ViewportResize;
89
+ } & viewportResizeDimension;
90
+ type inputData = {
91
+ source: IncrementalSource.Input;
92
+ id: number;
93
+ } & inputValue;
94
+ type mediaInteractionData = {
95
+ source: IncrementalSource.MediaInteraction;
96
+ } & mediaInteractionParam;
97
+ type styleSheetRuleData = {
98
+ source: IncrementalSource.StyleSheetRule;
99
+ } & styleSheetRuleParam;
100
+ type styleDeclarationData = {
101
+ source: IncrementalSource.StyleDeclaration;
102
+ } & styleDeclarationParam;
103
+ type canvasMutationData = {
104
+ source: IncrementalSource.CanvasMutation;
105
+ } & canvasMutationParam;
106
+ type fontData = {
107
+ source: IncrementalSource.Font;
108
+ } & fontParam;
109
+ type selectionData = {
110
+ source: IncrementalSource.Selection;
111
+ } & selectionParam;
112
+ type adoptedStyleSheetData = {
113
+ source: IncrementalSource.AdoptedStyleSheet;
114
+ } & adoptedStyleSheetParam;
115
+ type customElementData = {
116
+ source: IncrementalSource.CustomElement;
117
+ } & customElementParam;
118
+ type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData | customElementData;
119
+ type eventWithoutTime = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
120
+ type eventWithTime = eventWithoutTime & {
121
+ timestamp: number;
122
+ delay?: number;
123
+ };
124
+ type blockClass = string | RegExp;
125
+ type maskTextClass = string | RegExp;
126
+ type SamplingStrategy = Partial<{
127
+ /**
128
+ * false means not to record mouse/touch move events
129
+ * number is the throttle threshold of recording mouse/touch move
130
+ */
131
+ mousemove: boolean | number;
132
+ /**
133
+ * number is the throttle threshold of mouse/touch move callback
134
+ */
135
+ mousemoveCallback: number;
136
+ /**
137
+ * false means not to record mouse interaction events
138
+ * can also specify record some kinds of mouse interactions
139
+ */
140
+ mouseInteraction: boolean | Record<string, boolean | undefined>;
141
+ /**
142
+ * number is the throttle threshold of recording scroll
143
+ */
144
+ scroll: number;
145
+ /**
146
+ * number is the throttle threshold of recording media interactions
147
+ */
148
+ media: number;
149
+ /**
150
+ * 'all' will record all the input events
151
+ * 'last' will only record the last input value while input a sequence of chars
152
+ */
153
+ input: "all" | "last";
154
+ /**
155
+ * 'all' will record every single canvas call
156
+ * number between 1 and 60, will record an image snapshots in a web-worker a (maximum) number of times per second.
157
+ * Number only supported where [`OffscreenCanvas`](http://mdn.io/offscreencanvas) is supported.
158
+ */
159
+ canvas: "all" | number;
160
+ }>;
161
+ interface ICrossOriginIframeMirror {
162
+ getId(iframe: HTMLIFrameElement, remoteId: number, parentToRemoteMap?: Map<number, number>, remoteToParentMap?: Map<number, number>): number;
163
+ getIds(iframe: HTMLIFrameElement, remoteId: number[]): number[];
164
+ getRemoteId(iframe: HTMLIFrameElement, parentId: number, map?: Map<number, number>): number;
165
+ getRemoteIds(iframe: HTMLIFrameElement, parentId: number[]): number[];
166
+ reset(iframe?: HTMLIFrameElement): void;
167
+ }
168
+ type RecordPlugin<TOptions = unknown> = {
169
+ name: string;
170
+ observer?: (cb: (...args: Array<unknown>) => void, win: IWindow, options: TOptions) => listenerHandler;
171
+ eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend;
172
+ getMirror?: (mirrors: {
173
+ nodeMirror: IMirror<Node>;
174
+ crossOriginIframeMirror: ICrossOriginIframeMirror;
175
+ crossOriginIframeStyleMirror: ICrossOriginIframeMirror;
176
+ }) => void;
177
+ options: TOptions;
178
+ };
179
+ type hooksParam = {
180
+ mutation?: mutationCallBack;
181
+ mousemove?: mousemoveCallBack;
182
+ mouseInteraction?: mouseInteractionCallBack;
183
+ scroll?: scrollCallback;
184
+ viewportResize?: viewportResizeCallback;
185
+ input?: inputCallback;
186
+ mediaInteaction?: mediaInteractionCallback;
187
+ styleSheetRule?: styleSheetRuleCallback;
188
+ styleDeclaration?: styleDeclarationCallback;
189
+ canvasMutation?: canvasMutationCallback;
190
+ font?: fontCallback;
191
+ selection?: selectionCallback;
192
+ customElement?: customElementCallback;
193
+ };
194
+ type textMutation = {
195
+ id: number;
196
+ value: string | null;
197
+ };
198
+ type styleOMValue = {
199
+ [key: string]: styleValueWithPriority | string | false;
200
+ };
201
+ type styleValueWithPriority = [string, string];
202
+ type attributeMutation = {
203
+ id: number;
204
+ attributes: {
205
+ [key: string]: string | styleOMValue | null;
206
+ };
207
+ };
208
+ type removedNodeMutation = {
209
+ parentId: number;
210
+ id: number;
211
+ isShadow?: boolean;
212
+ };
213
+ type addedNodeMutation = {
214
+ parentId: number;
215
+ previousId?: number | null;
216
+ nextId: number | null;
217
+ node: serializedNodeWithId;
218
+ };
219
+ type mutationCallbackParam = {
220
+ texts: textMutation[];
221
+ attributes: attributeMutation[];
222
+ removes: removedNodeMutation[];
223
+ adds: addedNodeMutation[];
224
+ isAttachIframe?: true;
225
+ };
226
+ type mutationCallBack = (m: mutationCallbackParam) => void;
227
+ type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;
228
+ type mousePosition = {
229
+ x: number;
230
+ y: number;
231
+ id: number;
232
+ timeOffset: number;
233
+ };
234
+ declare enum MouseInteractions {
235
+ MouseUp = 0,
236
+ MouseDown = 1,
237
+ Click = 2,
238
+ ContextMenu = 3,
239
+ DblClick = 4,
240
+ Focus = 5,
241
+ Blur = 6,
242
+ TouchStart = 7,
243
+ TouchMove_Departed = 8,
244
+ TouchEnd = 9,
245
+ TouchCancel = 10
246
+ }
247
+ declare enum PointerTypes {
248
+ Mouse = 0,
249
+ Pen = 1,
250
+ Touch = 2
251
+ }
252
+ declare enum CanvasContext {
253
+ "2D" = 0,
254
+ WebGL = 1,
255
+ WebGL2 = 2
256
+ }
257
+ type mouseInteractionParam = {
258
+ type: MouseInteractions;
259
+ id: number;
260
+ x?: number;
261
+ y?: number;
262
+ pointerType?: PointerTypes;
263
+ };
264
+ type mouseInteractionCallBack = (d: mouseInteractionParam) => void;
265
+ type scrollPosition = {
266
+ id: number;
267
+ x: number;
268
+ y: number;
269
+ };
270
+ type scrollCallback = (p: scrollPosition) => void;
271
+ type styleSheetAddRule = {
272
+ rule: string;
273
+ index?: number | number[];
274
+ };
275
+ type styleSheetDeleteRule = {
276
+ index: number | number[];
277
+ };
278
+ type styleSheetRuleParam = {
279
+ id?: number;
280
+ styleId?: number;
281
+ removes?: styleSheetDeleteRule[];
282
+ adds?: styleSheetAddRule[];
283
+ replace?: string;
284
+ replaceSync?: string;
285
+ };
286
+ type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;
287
+ type adoptedStyleSheetParam = {
288
+ id: number;
289
+ styles?: {
290
+ styleId: number;
291
+ rules: styleSheetAddRule[];
292
+ }[];
293
+ styleIds: number[];
294
+ };
295
+ type styleDeclarationParam = {
296
+ id?: number;
297
+ styleId?: number;
298
+ index: number[];
299
+ set?: {
300
+ property: string;
301
+ value: string | null;
302
+ priority: string | undefined;
303
+ };
304
+ remove?: {
305
+ property: string;
306
+ };
307
+ };
308
+ type styleDeclarationCallback = (s: styleDeclarationParam) => void;
309
+ type canvasMutationCommand = {
310
+ property: string;
311
+ args: Array<unknown>;
312
+ setter?: true;
313
+ };
314
+ type canvasMutationParam = {
315
+ id: number;
316
+ type: CanvasContext;
317
+ commands: canvasMutationCommand[];
318
+ displayWidth?: number;
319
+ displayHeight?: number;
320
+ } | ({
321
+ id: number;
322
+ type: CanvasContext;
323
+ displayWidth?: number;
324
+ displayHeight?: number;
325
+ } & canvasMutationCommand);
326
+ type canvasMutationCallback = (p: canvasMutationParam) => void;
327
+ type CanvasMaskRegion = {
328
+ x: number;
329
+ y: number;
330
+ width: number;
331
+ height: number;
332
+ };
333
+ type CanvasMasking = {
334
+ regionsFn?: (canvas: HTMLCanvasElement) => CanvasMaskRegion[] | null | undefined;
335
+ configured?: () => boolean;
336
+ };
337
+ type fontParam = {
338
+ family: string;
339
+ fontSource: string;
340
+ buffer: boolean;
341
+ descriptors?: FontFaceDescriptors;
342
+ };
343
+ type fontCallback = (p: fontParam) => void;
344
+ type viewportResizeDimension = {
345
+ width: number;
346
+ height: number;
347
+ };
348
+ type viewportResizeCallback = (d: viewportResizeDimension) => void;
349
+ type inputValue = {
350
+ text: string;
351
+ isChecked: boolean;
352
+ userTriggered?: boolean;
353
+ };
354
+ type inputCallback = (v: inputValue & {
355
+ id: number;
356
+ }) => void;
357
+ declare enum MediaInteractions {
358
+ Play = 0,
359
+ Pause = 1,
360
+ Seeked = 2,
361
+ VolumeChange = 3,
362
+ RateChange = 4
363
+ }
364
+ type mediaInteractionParam = {
365
+ type: MediaInteractions;
366
+ id: number;
367
+ currentTime?: number;
368
+ volume?: number;
369
+ muted?: boolean;
370
+ loop?: boolean;
371
+ playbackRate?: number;
372
+ };
373
+ type mediaInteractionCallback = (p: mediaInteractionParam) => void;
374
+ type SelectionRange = {
375
+ start: number;
376
+ startOffset: number;
377
+ end: number;
378
+ endOffset: number;
379
+ };
380
+ type selectionParam = {
381
+ ranges: Array<SelectionRange>;
382
+ };
383
+ type selectionCallback = (p: selectionParam) => void;
384
+ type customElementParam = {
385
+ define?: {
386
+ name: string;
387
+ };
388
+ };
389
+ type customElementCallback = (c: customElementParam) => void;
390
+ type listenerHandler = () => void;
391
+ type KeepIframeSrcFn = (src: string) => boolean;
533
392
  declare global {
534
- interface Window {
535
- FontFace: typeof FontFace;
536
- }
393
+ interface Window {
394
+ FontFace: typeof FontFace;
395
+ }
537
396
  }
538
-
539
- declare type MaskAttributeFn = (name: string, value: string, element: Element) => string;
540
-
541
- declare type MaskInputFn = (text: string, element: HTMLElement) => string;
542
-
543
- declare type MaskInputOptions = Partial<{
544
- color: boolean;
545
- date: boolean;
546
- 'datetime-local': boolean;
547
- email: boolean;
548
- month: boolean;
549
- number: boolean;
550
- range: boolean;
551
- search: boolean;
552
- tel: boolean;
553
- text: boolean;
554
- time: boolean;
555
- url: boolean;
556
- week: boolean;
557
- textarea: boolean;
558
- select: boolean;
559
- password: boolean;
560
- }>;
561
-
562
- declare type MaskTextFn = (text: string, element: HTMLElement | null) => string;
563
-
564
- declare class Mirror implements IMirror<Node> {
565
- private idNodeMap;
566
- private nodeMetaMap;
567
- getId(n: Node | undefined | null): number;
568
- getNode(id: number): Node | null;
569
- getIds(): number[];
570
- getMeta(n: Node): serializedNodeWithId | null;
571
- removeNodeFromMap(n: Node): void;
572
- has(id: number): boolean;
573
- hasNode(node: Node): boolean;
574
- add(n: Node, meta: serializedNodeWithId): void;
575
- replace(id: number, n: Node): void;
576
- reset(): void;
577
- }
578
-
579
- declare type SlimDOMOptions = Partial<{
580
- script: boolean;
581
- comment: boolean;
582
- headFavicon: boolean;
583
- headWhitespace: boolean;
584
- headMetaDescKeywords: boolean;
585
- headMetaSocial: boolean;
586
- headMetaRobots: boolean;
587
- headMetaHttpEquiv: boolean;
588
- headMetaAuthorship: boolean;
589
- headMetaVerification: boolean;
590
- headTitleMutations: boolean;
397
+ type IWindow = Window & typeof globalThis;
398
+ declare enum NodeType {
399
+ Document = 0,
400
+ DocumentType = 1,
401
+ Element = 2,
402
+ Text = 3,
403
+ CDATA = 4,
404
+ Comment = 5
405
+ }
406
+ type documentNode = {
407
+ type: NodeType.Document;
408
+ childNodes: serializedNodeWithId[];
409
+ compatMode?: string;
410
+ };
411
+ type documentTypeNode = {
412
+ type: NodeType.DocumentType;
413
+ name: string;
414
+ publicId: string;
415
+ systemId: string;
416
+ };
417
+ type cssTextKeyAttr = {
418
+ _cssText?: string;
419
+ };
420
+ type attributes = cssTextKeyAttr & {
421
+ [key: string]: string | number | true | null;
422
+ };
423
+ type elementNode = {
424
+ type: NodeType.Element;
425
+ tagName: string;
426
+ attributes: attributes;
427
+ childNodes: serializedNodeWithId[];
428
+ isSVG?: true;
429
+ needBlock?: boolean;
430
+ isCustom?: true;
431
+ };
432
+ type textNode = {
433
+ type: NodeType.Text;
434
+ textContent: string;
435
+ /**
436
+ * @deprecated styles are now always snapshotted against parent <style> element
437
+ * style mutations can still happen via an added textNode, but they don't need this attribute for correct replay
438
+ */
439
+ isStyle?: true;
440
+ };
441
+ type cdataNode = {
442
+ type: NodeType.CDATA;
443
+ textContent: "";
444
+ };
445
+ type commentNode = {
446
+ type: NodeType.Comment;
447
+ textContent: string;
448
+ };
449
+ type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
450
+ rootId?: number;
451
+ isShadowHost?: boolean;
452
+ isShadow?: boolean;
453
+ };
454
+ type serializedNodeWithId = serializedNode & {
455
+ id: number;
456
+ };
457
+ interface IMirror<TNode> {
458
+ getId(n: TNode | undefined | null): number;
459
+ getNode(id: number): TNode | null;
460
+ getIds(): number[];
461
+ getMeta(n: TNode): serializedNodeWithId | null;
462
+ removeNodeFromMap(n: TNode): void;
463
+ has(id: number): boolean;
464
+ hasNode(node: TNode): boolean;
465
+ add(n: TNode, meta: serializedNodeWithId): void;
466
+ replace(id: number, n: TNode): void;
467
+ reset(): void;
468
+ }
469
+ type DataURLOptions = Partial<{
470
+ type: string;
471
+ quality: number;
472
+ maxBase64ImageLength: number;
591
473
  }>;
474
+ type PackFn = (event: eventWithTime) => string;
592
475
 
593
- declare type ErrorHandler = (error: unknown, context?: ErrorHandlerContext) => void | boolean;
594
-
595
- declare type ErrorHandlerContext = 'rrweb' | 'host';
596
-
597
-
598
- declare type recordOptions<T> = {
599
- emit?: (e: T, isCheckout?: boolean) => void;
600
- checkoutEveryNth?: number;
601
- checkoutEveryNms?: number;
602
- blockClass?: blockClass;
603
- blockSelector?: string;
604
- ignoreClass?: string;
605
- ignoreSelector?: string;
606
- maskTextClass?: maskTextClass;
607
- maskTextSelector?: string;
608
- maskAllInputs?: boolean;
609
- maskInputOptions?: MaskInputOptions;
610
- maskInputFn?: MaskInputFn;
611
- maskTextFn?: MaskTextFn;
612
- maskAllElementAttributes?: boolean;
613
- maskAttributeFn?: MaskAttributeFn;
614
- slimDOMOptions?: SlimDOMOptions | 'all' | true;
615
- ignoreCSSAttributes?: Set<string>;
616
- attributeFilter?: string[];
617
- inlineStylesheet?: boolean;
618
- inlineStylesheetBudgetRules?: number;
619
- hooks?: hooksParam;
620
- packFn?: PackFn;
621
- sampling?: SamplingStrategy;
622
- dataURLOptions?: DataURLOptions;
623
- canvasResolutionScale?: number;
624
- canvasMasking?: CanvasMasking;
625
- recordDOM?: boolean;
626
- recordCanvas?: boolean;
627
- recordCrossOriginIframes?: boolean;
628
- recordAfter?: 'DOMContentLoaded' | 'load';
629
- userTriggeredOnInput?: boolean;
630
- collectFonts?: boolean;
631
- inlineImages?: boolean;
632
- plugins?: RecordPlugin[];
633
- mousemoveWait?: number;
634
- keepIframeSrcFn?: KeepIframeSrcFn;
635
- errorHandler?: ErrorHandler;
636
- };
637
-
638
- declare function record<T = eventWithTime>(options?: recordOptions<T>): listenerHandler | undefined;
639
-
640
- declare namespace record {
641
- var addCustomEvent: <T>(tag: string, payload: T) => void;
642
- var freezePage: () => void;
643
- var takeFullSnapshot: (isCheckout?: boolean) => void;
644
- var mirror: Mirror;
645
- }
646
-
647
-
648
- declare namespace record {
649
- var addCustomEvent: <T>(tag: string, payload: T) => void;
650
- var freezePage: () => void;
651
- var takeFullSnapshot: (isCheckout?: boolean) => void;
652
- var mirror: Mirror;
476
+ type MaskInputOptions = Partial<{
477
+ color: boolean;
478
+ date: boolean;
479
+ "datetime-local": boolean;
480
+ email: boolean;
481
+ month: boolean;
482
+ number: boolean;
483
+ range: boolean;
484
+ search: boolean;
485
+ tel: boolean;
486
+ text: boolean;
487
+ time: boolean;
488
+ url: boolean;
489
+ week: boolean;
490
+ textarea: boolean;
491
+ select: boolean;
492
+ password: boolean;
493
+ }>;
494
+ type SlimDOMOptions = Partial<{
495
+ script: boolean;
496
+ comment: boolean;
497
+ headFavicon: boolean;
498
+ headWhitespace: boolean;
499
+ headMetaDescKeywords: boolean;
500
+ headMetaSocial: boolean;
501
+ headMetaRobots: boolean;
502
+ headMetaHttpEquiv: boolean;
503
+ headMetaAuthorship: boolean;
504
+ headMetaVerification: boolean;
505
+ /**
506
+ * blocks title tag 'animations' which can generate a lot of mutations that aren't usually displayed in replayers
507
+ **/
508
+ headTitleMutations: boolean;
509
+ }>;
510
+ type MaskTextFn = (text: string, element: HTMLElement | null) => string;
511
+ type MaskInputFn = (text: string, element: HTMLElement) => string;
512
+ type MaskAttributeFn = (name: string, value: string, element: Element) => string;
513
+ declare class Mirror implements IMirror<Node> {
514
+ private idNodeMap;
515
+ private nodeMetaMap;
516
+ getId(n: Node | undefined | null): number;
517
+ getNode(id: number): Node | null;
518
+ getIds(): number[];
519
+ getMeta(n: Node): serializedNodeWithId | null;
520
+ removeNodeFromMap(n: Node): void;
521
+ has(id: number): boolean;
522
+ hasNode(node: Node): boolean;
523
+ add(n: Node, meta: serializedNodeWithId): void;
524
+ replace(id: number, n: Node): void;
525
+ reset(): void;
653
526
  }
654
527
 
655
-
528
+ //#endregion
529
+ //#region src/types.d.ts
530
+ type recordOptions<T> = {
531
+ emit?: (e: T, isCheckout?: boolean) => void;
532
+ checkoutEveryNth?: number;
533
+ checkoutEveryNms?: number;
534
+ blockClass?: blockClass;
535
+ blockSelector?: string;
536
+ ignoreClass?: string;
537
+ ignoreSelector?: string;
538
+ maskTextClass?: maskTextClass;
539
+ maskTextSelector?: string;
540
+ maskAllInputs?: boolean;
541
+ maskInputOptions?: MaskInputOptions;
542
+ maskInputFn?: MaskInputFn;
543
+ maskTextFn?: MaskTextFn;
544
+ maskAllElementAttributes?: boolean;
545
+ maskAttributeFn?: MaskAttributeFn;
546
+ slimDOMOptions?: SlimDOMOptions | 'all' | true;
547
+ ignoreCSSAttributes?: Set<string>;
548
+ attributeFilter?: string[];
549
+ inlineStylesheet?: boolean;
550
+ inlineStylesheetBudgetRules?: number;
551
+ hooks?: hooksParam;
552
+ packFn?: PackFn;
553
+ sampling?: SamplingStrategy;
554
+ dataURLOptions?: DataURLOptions;
555
+ canvasResolutionScale?: number;
556
+ canvasMasking?: CanvasMasking;
557
+ recordDOM?: boolean;
558
+ recordCanvas?: boolean;
559
+ recordCrossOriginIframes?: boolean;
560
+ recordAfter?: 'DOMContentLoaded' | 'load';
561
+ userTriggeredOnInput?: boolean;
562
+ collectFonts?: boolean;
563
+ inlineImages?: boolean;
564
+ plugins?: RecordPlugin[];
565
+ mousemoveWait?: number;
566
+ keepIframeSrcFn?: KeepIframeSrcFn;
567
+ errorHandler?: ErrorHandler;
568
+ };
656
569
  declare global {
657
- interface Window {
658
- FontFace: typeof FontFace;
659
- Array: typeof Array;
660
- }
570
+ interface Window {
571
+ FontFace: typeof FontFace;
572
+ Array: typeof Array;
573
+ }
574
+ }
575
+ type ErrorHandlerContext = 'rrweb' | 'host';
576
+ type ErrorHandler = (error: unknown, context?: ErrorHandlerContext) => void | boolean;
577
+ //#endregion
578
+ //#region src/record/index.d.ts
579
+ declare function record<T = eventWithTime>(options?: recordOptions<T>): listenerHandler | undefined;
580
+ declare namespace record {
581
+ var addCustomEvent: <T>(tag: string, payload: T) => void;
582
+ var freezePage: () => void;
583
+ var takeFullSnapshot: (isCheckout?: boolean) => void;
584
+ var mirror: Mirror;
661
585
  }
662
586
 
663
587
  export { record as default };