@highlight-run/rrweb 1.1.3 → 1.1.7

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,6 +1,7 @@
1
1
  import { MaskInputOptions, SlimDOMOptions, MaskTextFn, MaskInputFn } from '../snapshot';
2
2
  import { mutationRecord, blockClass, maskTextClass, mutationCallBack, Mirror } from '../types';
3
3
  import { IframeManager } from './iframe-manager';
4
+ import { CanvasManager } from './observers/canvas/canvas-manager';
4
5
  import { ShadowDomManager } from './shadow-dom-manager';
5
6
  export default class MutationBuffer {
6
7
  private frozen;
@@ -29,12 +30,14 @@ export default class MutationBuffer {
29
30
  private mirror;
30
31
  private iframeManager;
31
32
  private shadowDomManager;
32
- init(cb: mutationCallBack, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, maskInputFn: MaskInputFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, doc: Document, mirror: Mirror, iframeManager: IframeManager, shadowDomManager: ShadowDomManager, enableStrictPrivacy: boolean): void;
33
+ private canvasManager;
34
+ init(cb: mutationCallBack, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, maskInputFn: MaskInputFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, doc: Document, mirror: Mirror, iframeManager: IframeManager, shadowDomManager: ShadowDomManager, canvasManager: CanvasManager, enableStrictPrivacy: boolean): void;
33
35
  freeze(): void;
34
36
  unfreeze(): void;
35
37
  isFrozen(): boolean;
36
38
  lock(): void;
37
39
  unlock(): void;
40
+ reset(): void;
38
41
  processMutations: (mutations: mutationRecord[]) => void;
39
42
  emit: () => void;
40
43
  private processMutation;
@@ -3,8 +3,9 @@ import { mutationCallBack, observerParam, listenerHandler, scrollCallback, block
3
3
  import MutationBuffer from './mutation';
4
4
  import { IframeManager } from './iframe-manager';
5
5
  import { ShadowDomManager } from './shadow-dom-manager';
6
+ import { CanvasManager } from './observers/canvas/canvas-manager';
6
7
  export declare const mutationBuffers: MutationBuffer[];
7
- export declare function initMutationObserver(cb: mutationCallBack, doc: Document, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, maskInputFn: MaskInputFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, mirror: Mirror, iframeManager: IframeManager, shadowDomManager: ShadowDomManager, rootEl: Node, enableStrictPrivacy: boolean): MutationObserver;
8
+ export declare function initMutationObserver(cb: mutationCallBack, doc: Document, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, maskInputFn: MaskInputFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, mirror: Mirror, iframeManager: IframeManager, shadowDomManager: ShadowDomManager, canvasManager: CanvasManager, rootEl: Node, enableStrictPrivacy: boolean): MutationObserver;
8
9
  export declare function initScrollObserver(cb: scrollCallback, doc: Document, mirror: Mirror, blockClass: blockClass, sampling: SamplingStrategy): listenerHandler;
9
10
  export declare const INPUT_TAGS: string[];
10
11
  export declare function initObservers(o: observerParam, hooks?: hooksParam): listenerHandler;
@@ -1,2 +1,2 @@
1
- import { blockClass, canvasMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
2
- export default function initCanvas2DMutationObserver(cb: canvasMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
1
+ import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
2
+ export default function initCanvas2DMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
@@ -0,0 +1,32 @@
1
+ import { blockClass, canvasMutationCallback, IWindow, Mirror } from '../../../types';
2
+ export declare type RafStamps = {
3
+ latestId: number;
4
+ invokeId: number | null;
5
+ };
6
+ export declare class CanvasManager {
7
+ private pendingCanvasMutations;
8
+ private rafStamps;
9
+ private mirror;
10
+ private mutationCb;
11
+ private resetObservers;
12
+ private frozen;
13
+ private locked;
14
+ reset(): void;
15
+ freeze(): void;
16
+ unfreeze(): void;
17
+ lock(): void;
18
+ unlock(): void;
19
+ constructor(options: {
20
+ recordCanvas: boolean | number;
21
+ mutationCb: canvasMutationCallback;
22
+ win: IWindow;
23
+ blockClass: blockClass;
24
+ mirror: Mirror;
25
+ });
26
+ private processMutation;
27
+ private initCanvasMutationObserver;
28
+ private startPendingCanvasMutationFlusher;
29
+ private startRAFTimestamping;
30
+ flushPendingCanvasMutations(): void;
31
+ flushPendingCanvasMutationFor(canvas: HTMLCanvasElement, id: number): void;
32
+ }
@@ -1,5 +1,6 @@
1
1
  import { IWindow, SerializedWebGlArg } from '../../../types';
2
- export declare function serializeArg(value: any, win: IWindow): SerializedWebGlArg;
3
- export declare const serializeArgs: (args: Array<any>, win: IWindow) => SerializedWebGlArg[];
2
+ export declare function variableListFor(ctx: WebGLRenderingContext | WebGL2RenderingContext, ctor: string): any[];
3
+ export declare const saveWebGLVar: (value: any, win: IWindow, ctx: WebGL2RenderingContext | WebGLRenderingContext) => number | void;
4
+ export declare function serializeArg(value: any, win: IWindow, ctx: WebGL2RenderingContext | WebGLRenderingContext): SerializedWebGlArg;
5
+ export declare const serializeArgs: (args: Array<any>, win: IWindow, ctx: WebGLRenderingContext | WebGL2RenderingContext) => SerializedWebGlArg[];
4
6
  export declare const isInstanceOfWebGLObject: (value: any, win: IWindow) => value is WebGLShader | WebGLProgram | WebGLActiveInfo | WebGLBuffer | WebGLFramebuffer | WebGLRenderbuffer | WebGLShaderPrecisionFormat | WebGLTexture | WebGLUniformLocation | WebGLVertexArrayObject;
5
- export declare const saveWebGLVar: (value: any, win: IWindow) => number | void;
@@ -1,2 +1,2 @@
1
- import { blockClass, canvasMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
2
- export default function initCanvasWebGLMutationObserver(cb: canvasMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
1
+ import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
2
+ export default function initCanvasWebGLMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
@@ -1,6 +1,7 @@
1
1
  import { mutationCallBack, blockClass, maskTextClass, Mirror, scrollCallback, SamplingStrategy } from '../types';
2
2
  import { MaskInputOptions, SlimDOMOptions, MaskTextFn, MaskInputFn } from '../snapshot';
3
3
  import { IframeManager } from './iframe-manager';
4
+ import { CanvasManager } from './observers/canvas/canvas-manager';
4
5
  declare type BypassOptions = {
5
6
  blockClass: blockClass;
6
7
  blockSelector: string | null;
@@ -14,6 +15,7 @@ declare type BypassOptions = {
14
15
  sampling: SamplingStrategy;
15
16
  slimDOMOptions: SlimDOMOptions;
16
17
  iframeManager: IframeManager;
18
+ canvasManager: CanvasManager;
17
19
  enableStrictPrivacy: boolean;
18
20
  };
19
21
  export declare class ShadowDomManager {
@@ -1,8 +1,8 @@
1
1
  import { Replayer } from '../';
2
- import { canvasMutationData } from '../../types';
2
+ import { canvasMutationCommand } from '../../types';
3
3
  export default function canvasMutation({ event, mutation, target, imageMap, errorHandler, }: {
4
4
  event: Parameters<Replayer['applyIncremental']>[0];
5
- mutation: canvasMutationData;
5
+ mutation: canvasMutationCommand;
6
6
  target: HTMLCanvasElement;
7
7
  imageMap: Replayer['imageMap'];
8
8
  errorHandler: Replayer['warnCanvasMutationFailed'];
@@ -1,10 +1,11 @@
1
1
  import { Replayer } from '../';
2
- import { canvasMutationData, SerializedWebGlArg } from '../../types';
3
- export declare function variableListFor(ctor: string): any[];
4
- export declare function deserializeArg(imageMap: Replayer['imageMap']): (arg: SerializedWebGlArg) => any;
5
- export default function webglMutation({ mutation, target, imageMap, errorHandler, }: {
6
- mutation: canvasMutationData;
2
+ import { CanvasContext, canvasMutationCommand, SerializedWebGlArg } from '../../types';
3
+ export declare function variableListFor(ctx: WebGLRenderingContext | WebGL2RenderingContext, ctor: string): any[];
4
+ export declare function deserializeArg(imageMap: Replayer['imageMap'], ctx: WebGLRenderingContext | WebGL2RenderingContext): (arg: SerializedWebGlArg) => any;
5
+ export default function webglMutation({ mutation, target, type, imageMap, errorHandler, }: {
6
+ mutation: canvasMutationCommand;
7
7
  target: HTMLCanvasElement;
8
+ type: CanvasContext;
8
9
  imageMap: Replayer['imageMap'];
9
10
  errorHandler: Replayer['warnCanvasMutationFailed'];
10
11
  }): void;
@@ -58,6 +58,7 @@ export declare class Replayer {
58
58
  private hasImageArg;
59
59
  private getImageArgs;
60
60
  private preloadAllImages;
61
+ private preloadImages;
61
62
  private applyIncremental;
62
63
  private applyMutation;
63
64
  private applyScroll;
@@ -15,7 +15,4 @@ export declare class Timer {
15
15
  isActive(): boolean;
16
16
  private findActionIndex;
17
17
  }
18
- export declare type LastDelay = {
19
- at: number | null;
20
- };
21
- export declare function addDelay(event: eventWithTime, baselineTime: number, lastDelay?: LastDelay): number;
18
+ export declare function addDelay(event: eventWithTime, baselineTime: number): number;
@@ -8,3 +8,4 @@ export declare function maskInputValue({ maskInputOptions, tagName, type, value,
8
8
  value: string | null;
9
9
  maskInputFn?: MaskInputFn;
10
10
  }): string;
11
+ export declare function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean;
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ import { FontFaceDescriptors } from 'css-font-loading-module';
4
4
  import { IframeManager } from './record/iframe-manager';
5
5
  import { ShadowDomManager } from './record/shadow-dom-manager';
6
6
  import type { Replayer } from './replay';
7
+ import { CanvasManager } from './record/observers/canvas/canvas-manager';
7
8
  export declare enum EventType {
8
9
  DomContentLoaded = 0,
9
10
  Load = 1,
@@ -128,11 +129,12 @@ export declare type SamplingStrategy = Partial<{
128
129
  mousemoveCallback: number;
129
130
  mouseInteraction: boolean | Record<string, boolean | undefined>;
130
131
  scroll: number;
132
+ media: number;
131
133
  input: 'all' | 'last';
132
134
  }>;
133
135
  export declare type RecordPlugin<TOptions = unknown> = {
134
136
  name: string;
135
- observer: (cb: Function, win: Window, options: TOptions) => listenerHandler;
137
+ observer: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;
136
138
  options: TOptions;
137
139
  };
138
140
  export declare type recordOptions<T> = {
@@ -191,6 +193,7 @@ export declare type observerParam = {
191
193
  mirror: Mirror;
192
194
  iframeManager: IframeManager;
193
195
  shadowDomManager: ShadowDomManager;
196
+ canvasManager: CanvasManager;
194
197
  plugins: Array<{
195
198
  observer: Function;
196
199
  callback: Function;
@@ -345,15 +348,24 @@ export declare type styleDeclarationParam = {
345
348
  };
346
349
  };
347
350
  export declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;
348
- export declare type canvasMutationCallback = (p: canvasMutationParam) => void;
349
- export declare type canvasMutationParam = {
350
- id: number;
351
- type: CanvasContext;
351
+ export declare type canvasMutationCommand = {
352
352
  property: string;
353
353
  args: Array<unknown>;
354
354
  setter?: true;
355
- newFrame?: true;
356
355
  };
356
+ export declare type canvasMutationParam = {
357
+ id: number;
358
+ type: CanvasContext;
359
+ commands: canvasMutationCommand[];
360
+ } | ({
361
+ id: number;
362
+ type: CanvasContext;
363
+ } & canvasMutationCommand);
364
+ export declare type canvasMutationWithType = {
365
+ type: CanvasContext;
366
+ } & canvasMutationCommand;
367
+ export declare type canvasMutationCallback = (p: canvasMutationParam) => void;
368
+ export declare type canvasManagerMutationCallback = (target: HTMLCanvasElement, p: canvasMutationWithType) => void;
357
369
  export declare type fontParam = {
358
370
  family: string;
359
371
  fontSource: string;
@@ -377,12 +389,15 @@ export declare type inputCallback = (v: inputValue & {
377
389
  export declare const enum MediaInteractions {
378
390
  Play = 0,
379
391
  Pause = 1,
380
- Seeked = 2
392
+ Seeked = 2,
393
+ VolumeChange = 3
381
394
  }
382
395
  export declare type mediaInteractionParam = {
383
396
  type: MediaInteractions;
384
397
  id: number;
385
398
  currentTime?: number;
399
+ volume?: number;
400
+ muted?: boolean;
386
401
  };
387
402
  export declare type mediaInteractionCallback = (p: mediaInteractionParam) => void;
388
403
  export declare type DocumentDimension = {
@@ -450,7 +465,6 @@ export declare type missingNodeMap = {
450
465
  export declare type actionWithDelay = {
451
466
  doAction: () => void;
452
467
  delay: number;
453
- newFrame: boolean;
454
468
  };
455
469
  export declare type Handler = (event?: unknown) => void;
456
470
  export declare type Emitter = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highlight-run/rrweb",
3
- "version": "1.1.3",
3
+ "version": "1.1.7",
4
4
  "description": "record and replay the web",
5
5
  "scripts": {
6
6
  "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**.test.ts",