@highlight-run/rrweb 2.0.1 → 2.0.6

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 (118) hide show
  1. package/dist/plugins/console-record.js +12 -655
  2. package/dist/plugins/console-record.min.js +12 -15
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +4 -293
  5. package/dist/plugins/console-replay.min.js +4 -15
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/plugins/sequential-id-record.js +1 -33
  8. package/dist/plugins/sequential-id-record.min.js +1 -1
  9. package/dist/plugins/sequential-id-record.min.js.map +1 -1
  10. package/dist/plugins/sequential-id-replay.js +1 -37
  11. package/dist/plugins/sequential-id-replay.min.js +1 -1
  12. package/dist/plugins/sequential-id-replay.min.js.map +1 -1
  13. package/dist/record/rrweb-record-pack.js +3 -747
  14. package/dist/record/rrweb-record-pack.min.js +3 -15
  15. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  16. package/dist/record/rrweb-record.js +4 -3318
  17. package/dist/record/rrweb-record.min.js +4 -15
  18. package/dist/record/rrweb-record.min.js.map +1 -1
  19. package/dist/replay/rrweb-replay-unpack.css +1 -0
  20. package/dist/replay/rrweb-replay-unpack.js +5 -4614
  21. package/dist/replay/rrweb-replay-unpack.min.js +5 -17
  22. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  23. package/dist/replay/rrweb-replay.css +1 -0
  24. package/dist/replay/rrweb-replay.js +5 -4204
  25. package/dist/replay/rrweb-replay.min.js +5 -17
  26. package/dist/replay/rrweb-replay.min.js.map +1 -1
  27. package/dist/rrweb-all.css +1 -0
  28. package/dist/rrweb-all.js +16 -8696
  29. package/dist/rrweb-all.min.js +16 -17
  30. package/dist/rrweb-all.min.js.map +1 -1
  31. package/dist/rrweb.css +1 -0
  32. package/dist/rrweb.js +6 -7282
  33. package/dist/rrweb.min.js +6 -17
  34. package/dist/rrweb.min.js.map +1 -1
  35. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  36. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  37. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
  38. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  39. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  40. package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
  41. package/es/rrweb/all.css +1 -0
  42. package/es/rrweb/ext/mitt/dist/mitt.es.js +1 -1
  43. package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
  44. package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
  45. package/es/rrweb/packages/rrweb/src/index.js +6 -4
  46. package/es/rrweb/packages/rrweb/src/packer/base.js +1 -1
  47. package/es/rrweb/packages/rrweb/src/packer/pack.js +4 -5
  48. package/es/rrweb/packages/rrweb/src/packer/unpack.js +24 -24
  49. package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +175 -176
  50. package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +109 -128
  51. package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +125 -138
  52. package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +88 -105
  53. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +19 -20
  54. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +25 -25
  55. package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +29 -30
  56. package/es/rrweb/packages/rrweb/src/record/index.js +348 -373
  57. package/es/rrweb/packages/rrweb/src/record/mutation.js +487 -528
  58. package/es/rrweb/packages/rrweb/src/record/observer.js +584 -659
  59. package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +44 -73
  60. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +166 -87
  61. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +21 -26
  62. package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +119 -112
  63. package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +53 -72
  64. package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +38 -40
  65. package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
  66. package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +27 -23
  67. package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
  68. package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +37 -29
  69. package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +58 -120
  70. package/es/rrweb/packages/rrweb/src/replay/index.js +1545 -1854
  71. package/es/rrweb/packages/rrweb/src/replay/machine.js +275 -315
  72. package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +216 -218
  73. package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -7
  74. package/es/rrweb/packages/rrweb/src/replay/timer.js +87 -91
  75. package/es/rrweb/packages/rrweb/src/types.js +72 -72
  76. package/es/rrweb/packages/rrweb/src/utils.js +312 -506
  77. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +190 -72
  78. package/lib/plugins/console-record.js +469 -627
  79. package/lib/plugins/console-replay.js +198 -268
  80. package/lib/plugins/sequential-id-record.js +19 -20
  81. package/lib/plugins/sequential-id-replay.js +25 -25
  82. package/lib/record/rrweb-record-pack.js +184 -139
  83. package/lib/record/rrweb-record.js +2467 -2425
  84. package/lib/replay/rrweb-replay-unpack.css +1 -0
  85. package/lib/replay/rrweb-replay-unpack.js +3798 -3344
  86. package/lib/replay/rrweb-replay.css +1 -0
  87. package/lib/replay/rrweb-replay.js +3743 -3289
  88. package/lib/rrweb-all.css +1 -0
  89. package/lib/rrweb-all.js +6721 -6249
  90. package/lib/rrweb.css +1 -0
  91. package/lib/rrweb.js +6151 -5632
  92. package/package.json +14 -13
  93. package/typings/packer/base.d.ts +1 -1
  94. package/typings/plugins/console/record/index.d.ts +1 -1
  95. package/typings/plugins/console/record/stringify.d.ts +1 -1
  96. package/typings/plugins/sequential-id/record/index.d.ts +1 -1
  97. package/typings/plugins/sequential-id/replay/index.d.ts +1 -1
  98. package/typings/record/iframe-manager.d.ts +3 -3
  99. package/typings/record/index.d.ts +1 -1
  100. package/typings/record/mutation.d.ts +2 -1
  101. package/typings/record/observers/canvas/2d.d.ts +2 -1
  102. package/typings/record/observers/canvas/canvas-manager.d.ts +5 -2
  103. package/typings/record/observers/canvas/canvas.d.ts +1 -1
  104. package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
  105. package/typings/record/observers/canvas/webgl.d.ts +2 -1
  106. package/typings/record/shadow-dom-manager.d.ts +2 -1
  107. package/typings/record/stylesheet-manager.d.ts +12 -0
  108. package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
  109. package/typings/replay/canvas/2d.d.ts +3 -3
  110. package/typings/replay/canvas/deserialize-args.d.ts +7 -0
  111. package/typings/replay/canvas/index.d.ts +4 -3
  112. package/typings/replay/canvas/webgl.d.ts +3 -5
  113. package/typings/replay/index.d.ts +7 -10
  114. package/typings/types.d.ts +45 -17
  115. package/typings/utils.d.ts +17 -44
  116. package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +0 -78
  117. package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +0 -121
  118. package/typings/replay/virtual-styles.d.ts +0 -43
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highlight-run/rrweb",
3
- "version": "2.0.1",
3
+ "version": "2.0.6",
4
4
  "description": "record and replay the web",
5
5
  "scripts": {
6
6
  "prepare": "npm run prepack",
@@ -14,7 +14,8 @@
14
14
  "bundle": "rollup --config",
15
15
  "typings": "tsc -d --declarationDir typings",
16
16
  "check-types": "tsc -noEmit",
17
- "prepublish": "npm run typings && npm run bundle"
17
+ "prepublish": "npm run typings && npm run bundle",
18
+ "lint": "yarn eslint src"
18
19
  },
19
20
  "repository": {
20
21
  "type": "git",
@@ -41,17 +42,17 @@
41
42
  },
42
43
  "homepage": "https://github.com/rrweb-io/rrweb#readme",
43
44
  "devDependencies": {
44
- "@rollup/plugin-node-resolve": "^7.0.0",
45
- "@rollup/plugin-typescript": "^8.3.1",
45
+ "@rollup/plugin-node-resolve": "^13.1.3",
46
46
  "@types/chai": "^4.1.6",
47
47
  "@types/inquirer": "0.0.43",
48
48
  "@types/jest": "^27.4.1",
49
49
  "@types/jest-image-snapshot": "^4.3.1",
50
- "@types/jsdom": "^16.2.14",
51
50
  "@types/node": "^17.0.21",
51
+ "@types/offscreencanvas": "^2019.6.4",
52
52
  "@types/prettier": "^2.3.2",
53
53
  "@types/puppeteer": "^5.4.4",
54
54
  "cross-env": "^5.2.0",
55
+ "esbuild": "^0.14.38",
55
56
  "fast-mhtml": "^1.1.9",
56
57
  "identity-obj-proxy": "^3.0.0",
57
58
  "ignore-styles": "^5.0.1",
@@ -59,27 +60,27 @@
59
60
  "jest": "^27.5.1",
60
61
  "jest-image-snapshot": "^4.5.1",
61
62
  "jest-snapshot": "^23.6.0",
62
- "jsdom": "^17.0.0",
63
- "jsdom-global": "^3.0.2",
64
63
  "prettier": "2.2.1",
65
64
  "puppeteer": "^9.1.1",
66
- "rollup": "^2.45.2",
65
+ "rollup": "^2.68.0",
66
+ "rollup-plugin-esbuild": "^4.9.1",
67
67
  "rollup-plugin-postcss": "^3.1.1",
68
- "rollup-plugin-rename-node-modules": "^1.1.0",
69
- "rollup-plugin-terser": "^7.0.2",
68
+ "rollup-plugin-rename-node-modules": "^1.3.1",
69
+ "rollup-plugin-typescript2": "^0.31.2",
70
+ "rollup-plugin-web-worker-loader": "^1.6.1",
70
71
  "ts-jest": "^27.1.3",
71
72
  "ts-node": "^10.7.0",
72
73
  "tslib": "^2.3.1",
73
- "tslint": "^6.1.3",
74
74
  "typescript": "^4.6.2"
75
75
  },
76
76
  "dependencies": {
77
- "@highlight-run/rrweb-snapshot": "^1.1.15",
77
+ "@highlight-run/rrdom": "^0.1.5",
78
+ "@highlight-run/rrweb-snapshot": "^1.1.18",
78
79
  "@types/css-font-loading-module": "0.0.7",
79
80
  "@xstate/fsm": "^1.4.0",
80
81
  "base64-arraybuffer": "^1.0.1",
81
82
  "fflate": "^0.4.4",
82
83
  "mitt": "^1.1.3"
83
84
  },
84
- "gitHead": "0a154a620f994a625f3689b0d851ca03c214a2c0"
85
+ "gitHead": "bdb5819c0b9f2753491f81d40161556b28059d13"
85
86
  }
@@ -1,4 +1,4 @@
1
- import { eventWithTime } from '../types';
1
+ import type { eventWithTime } from '../types';
2
2
  export declare type PackFn = (event: eventWithTime) => string;
3
3
  export declare type UnpackFn = (raw: string) => eventWithTime;
4
4
  export declare type eventWithTimeAndPacker = eventWithTime & {
@@ -1,4 +1,4 @@
1
- import { RecordPlugin } from '../../../types';
1
+ import type { RecordPlugin } from '../../../types';
2
2
  export declare type StringifyOptions = {
3
3
  stringLengthLimit?: number;
4
4
  numOfKeysLimit: number;
@@ -1,2 +1,2 @@
1
- import { StringifyOptions } from './index';
1
+ import type { StringifyOptions } from './index';
2
2
  export declare function stringify(obj: any, stringifyOptions?: StringifyOptions): string;
@@ -1,4 +1,4 @@
1
- import { RecordPlugin } from '../../../types';
1
+ import type { RecordPlugin } from '../../../types';
2
2
  export declare type SequentialIdOptions = {
3
3
  key: string;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import type { SequentialIdOptions } from '../record';
2
- import { ReplayPlugin } from '../../../types';
2
+ import type { ReplayPlugin } from '../../../types';
3
3
  declare type Options = SequentialIdOptions & {
4
4
  warnOnMissingId: boolean;
5
5
  };
@@ -1,5 +1,5 @@
1
- import { serializedNodeWithId, INode } from '@highlight-run/rrweb-snapshot';
2
- import { mutationCallBack } from '../types';
1
+ import type { Mirror, serializedNodeWithId } from '@highlight-run/rrweb-snapshot';
2
+ import type { mutationCallBack } from '../types';
3
3
  export declare class IframeManager {
4
4
  private iframes;
5
5
  private mutationCb;
@@ -9,5 +9,5 @@ export declare class IframeManager {
9
9
  });
10
10
  addIframe(iframeEl: HTMLIFrameElement): void;
11
11
  addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown): void;
12
- attachIframe(iframeEl: INode, childSn: serializedNodeWithId): void;
12
+ attachIframe(iframeEl: HTMLIFrameElement, childSn: serializedNodeWithId, mirror: Mirror): void;
13
13
  }
@@ -4,6 +4,6 @@ declare namespace record {
4
4
  var addCustomEvent: <T>(tag: string, payload: T) => void;
5
5
  var freezePage: () => void;
6
6
  var takeFullSnapshot: (isCheckout?: boolean | undefined) => void;
7
- var mirror: import("../types").Mirror;
7
+ var mirror: import("@highlight-run/rrweb-snapshot").Mirror;
8
8
  }
9
9
  export default record;
@@ -1,4 +1,4 @@
1
- import { mutationRecord, MutationBufferParam } from '../types';
1
+ import type { mutationRecord, MutationBufferParam } from '../types';
2
2
  export default class MutationBuffer {
3
3
  private frozen;
4
4
  private locked;
@@ -25,6 +25,7 @@ export default class MutationBuffer {
25
25
  private doc;
26
26
  private mirror;
27
27
  private iframeManager;
28
+ private stylesheetManager;
28
29
  private shadowDomManager;
29
30
  private canvasManager;
30
31
  private enableStrictPrivacy;
@@ -1,2 +1,3 @@
1
- import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
1
+ import type { Mirror } from '@highlight-run/rrweb-snapshot';
2
+ import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '../../../types';
2
3
  export default function initCanvas2DMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
@@ -1,4 +1,5 @@
1
- import { blockClass, canvasMutationCallback, IWindow, Mirror } from '../../../types';
1
+ import type { Mirror } from '@highlight-run/rrweb-snapshot';
2
+ import type { blockClass, canvasMutationCallback, IWindow } from '../../../types';
2
3
  export declare type RafStamps = {
3
4
  latestId: number;
4
5
  invokeId: number | null;
@@ -17,13 +18,15 @@ export declare class CanvasManager {
17
18
  lock(): void;
18
19
  unlock(): void;
19
20
  constructor(options: {
20
- recordCanvas: boolean | number;
21
+ recordCanvas: boolean;
21
22
  mutationCb: canvasMutationCallback;
22
23
  win: IWindow;
23
24
  blockClass: blockClass;
24
25
  mirror: Mirror;
26
+ sampling?: 'all' | number;
25
27
  });
26
28
  private processMutation;
29
+ private initCanvasFPSObserver;
27
30
  private initCanvasMutationObserver;
28
31
  private startPendingCanvasMutationFlusher;
29
32
  private startRAFTimestamping;
@@ -1,2 +1,2 @@
1
- import { blockClass, IWindow, listenerHandler } from '../../../types';
1
+ import type { blockClass, IWindow, listenerHandler } from '../../../types';
2
2
  export default function initCanvasContextObserver(win: IWindow, blockClass: blockClass): listenerHandler;
@@ -1,6 +1,6 @@
1
- import { IWindow, SerializedWebGlArg } from '../../../types';
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[];
1
+ import type { IWindow, CanvasArg } from '../../../types';
2
+ export declare function variableListFor(ctx: RenderingContext, ctor: string): any[];
3
+ export declare const saveWebGLVar: (value: any, win: IWindow, ctx: RenderingContext) => number | void;
4
+ export declare function serializeArg(value: any, win: IWindow, ctx: RenderingContext): CanvasArg;
5
+ export declare const serializeArgs: (args: Array<any>, win: IWindow, ctx: RenderingContext) => CanvasArg[];
6
6
  export declare const isInstanceOfWebGLObject: (value: any, win: IWindow) => value is WebGLTexture | WebGLShader | WebGLBuffer | WebGLVertexArrayObject | WebGLProgram | WebGLActiveInfo | WebGLUniformLocation | WebGLFramebuffer | WebGLRenderbuffer | WebGLShaderPrecisionFormat;
@@ -1,2 +1,3 @@
1
- import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler, Mirror } from '../../../types';
1
+ import type { Mirror } from '@highlight-run/rrweb-snapshot';
2
+ import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '../../../types';
2
3
  export default function initCanvasWebGLMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, mirror: Mirror): listenerHandler;
@@ -1,4 +1,5 @@
1
- import { mutationCallBack, Mirror, scrollCallback, MutationBufferParam, SamplingStrategy } from '../types';
1
+ import type { mutationCallBack, scrollCallback, MutationBufferParam, SamplingStrategy } from '../types';
2
+ import type { Mirror } from '@highlight-run/rrweb-snapshot';
2
3
  declare type BypassOptions = Omit<MutationBufferParam, 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'> & {
3
4
  sampling: SamplingStrategy;
4
5
  };
@@ -0,0 +1,12 @@
1
+ import type { Mirror, serializedNodeWithId } from '@highlight-run/rrweb-snapshot';
2
+ import type { mutationCallBack } from '../types';
3
+ export declare class StylesheetManager {
4
+ private trackedStylesheets;
5
+ private mutationCb;
6
+ constructor(options: {
7
+ mutationCb: mutationCallBack;
8
+ });
9
+ addStylesheet(linkEl: HTMLLinkElement): void;
10
+ private trackStylesheet;
11
+ attachStylesheet(linkEl: HTMLLinkElement, childSn: serializedNodeWithId, mirror: Mirror): void;
12
+ }
@@ -0,0 +1,5 @@
1
+ import type { ImageBitmapDataURLWorkerParams, ImageBitmapDataURLWorkerResponse } from '../../types';
2
+ export interface ImageBitmapDataURLRequestWorker {
3
+ postMessage: (message: ImageBitmapDataURLWorkerParams, transfer?: [ImageBitmap]) => void;
4
+ onmessage: (message: MessageEvent<ImageBitmapDataURLWorkerResponse>) => void;
5
+ }
@@ -1,9 +1,9 @@
1
- import { Replayer } from '../';
2
- import { canvasMutationCommand } from '../../types';
1
+ import type { Replayer } from '../';
2
+ import type { canvasMutationCommand } from '../../types';
3
3
  export default function canvasMutation({ event, mutation, target, imageMap, errorHandler, }: {
4
4
  event: Parameters<Replayer['applyIncremental']>[0];
5
5
  mutation: canvasMutationCommand;
6
6
  target: HTMLCanvasElement;
7
7
  imageMap: Replayer['imageMap'];
8
8
  errorHandler: Replayer['warnCanvasMutationFailed'];
9
- }): void;
9
+ }): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { Replayer } from '../';
2
+ import type { CanvasArg, SerializedCanvasArg } from '../../types';
3
+ export declare function variableListFor(ctx: CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext, ctor: string): any[];
4
+ export declare function isSerializedArg(arg: unknown): arg is SerializedCanvasArg;
5
+ export declare function deserializeArg(imageMap: Replayer['imageMap'], ctx: CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | null, preload?: {
6
+ isUnchanged: boolean;
7
+ }): (arg: CanvasArg) => Promise<any>;
@@ -1,9 +1,10 @@
1
- import { Replayer } from '..';
1
+ import type { Replayer } from '..';
2
2
  import { canvasMutationData } from '../../types';
3
- export default function canvasMutation({ event, mutation, target, imageMap, errorHandler, }: {
3
+ export default function canvasMutation({ event, mutation, target, imageMap, canvasEventMap, errorHandler, }: {
4
4
  event: Parameters<Replayer['applyIncremental']>[0];
5
5
  mutation: canvasMutationData;
6
6
  target: HTMLCanvasElement;
7
7
  imageMap: Replayer['imageMap'];
8
+ canvasEventMap: Replayer['canvasEventMap'];
8
9
  errorHandler: Replayer['warnCanvasMutationFailed'];
9
- }): void;
10
+ }): Promise<void>;
@@ -1,11 +1,9 @@
1
- import { Replayer } from '../';
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;
1
+ import type { Replayer } from '../';
2
+ import { CanvasContext, canvasMutationCommand } from '../../types';
5
3
  export default function webglMutation({ mutation, target, type, imageMap, errorHandler, }: {
6
4
  mutation: canvasMutationCommand;
7
5
  target: HTMLCanvasElement;
8
6
  type: CanvasContext;
9
7
  imageMap: Replayer['imageMap'];
10
8
  errorHandler: Replayer['warnCanvasMutationFailed'];
11
- }): void;
9
+ }): Promise<void>;
@@ -1,6 +1,8 @@
1
+ import { Mirror } from '@highlight-run/rrweb-snapshot';
2
+ import { RRDocument } from '@highlight-run/rrdom/es/virtual-dom';
1
3
  import { Timer } from './timer';
2
4
  import { createPlayerService, createSpeedService } from './machine';
3
- import { eventWithTime, playerConfig, playerMetaData, Handler, Mirror, SessionInterval } from '../types';
5
+ import { eventWithTime, playerConfig, playerMetaData, Handler, SessionInterval } from '../types';
4
6
  import './styles/style.css';
5
7
  export declare class Replayer {
6
8
  wrapper: HTMLDivElement;
@@ -9,6 +11,8 @@ export declare class Replayer {
9
11
  speedService: ReturnType<typeof createSpeedService>;
10
12
  get timer(): Timer;
11
13
  config: playerConfig;
14
+ usingVirtualDom: boolean;
15
+ virtualDom: RRDocument;
12
16
  private mouse;
13
17
  private mouseTail;
14
18
  private tailPositions;
@@ -17,12 +21,9 @@ export declare class Replayer {
17
21
  private activityIntervals;
18
22
  private inactiveEndTimestamp;
19
23
  private legacy_missingNodeRetryMap;
20
- private treeIndex;
21
- private fragmentParentMap;
22
- private elementStateMap;
23
- private virtualStyleRulesMap;
24
24
  private cache;
25
25
  private imageMap;
26
+ private canvasEventMap;
26
27
  private mirror;
27
28
  private firstFullSnapshot;
28
29
  private newDocumentQueue;
@@ -60,21 +61,17 @@ export declare class Replayer {
60
61
  private getImageArgs;
61
62
  private preloadAllImages;
62
63
  private preloadImages;
64
+ private deserializeAndPreloadCanvasEvents;
63
65
  private applyIncremental;
64
66
  private applyMutation;
65
67
  private applyScroll;
66
68
  private applyInput;
67
- private applyText;
68
69
  private legacy_resolveMissingNode;
69
70
  private moveAndHover;
70
71
  private drawMouseTail;
71
72
  private hoverElements;
72
73
  private isUserInteraction;
73
74
  private backToNormal;
74
- private restoreRealParent;
75
- private storeState;
76
- private restoreState;
77
- private restoreNodeSheet;
78
75
  private warnNodeNotFound;
79
76
  private warnCanvasMutationFailed;
80
77
  private debugNodeNotFound;
@@ -1,9 +1,11 @@
1
- import { serializedNodeWithId, idNodeMap, INode, MaskInputOptions, SlimDOMOptions, MaskInputFn, MaskTextFn } from '@highlight-run/rrweb-snapshot';
2
- import { PackFn, UnpackFn } from './packer/base';
3
- import { IframeManager } from './record/iframe-manager';
4
- import { ShadowDomManager } from './record/shadow-dom-manager';
1
+ import type { serializedNodeWithId, Mirror, INode, MaskInputOptions, SlimDOMOptions, MaskInputFn, MaskTextFn } from '@highlight-run/rrweb-snapshot';
2
+ import type { PackFn, UnpackFn } from './packer/base';
3
+ import type { IframeManager } from './record/iframe-manager';
4
+ import type { ShadowDomManager } from './record/shadow-dom-manager';
5
5
  import type { Replayer } from './replay';
6
- import { CanvasManager } from './record/observers/canvas/canvas-manager';
6
+ import type { RRNode } from '@highlight-run/rrdom/es/virtual-dom';
7
+ import type { CanvasManager } from './record/observers/canvas/canvas-manager';
8
+ import type { StylesheetManager } from './record/stylesheet-manager';
7
9
  export declare enum EventType {
8
10
  DomContentLoaded = 0,
9
11
  Load = 1,
@@ -121,6 +123,10 @@ export declare type eventWithTime = event & {
121
123
  timestamp: number;
122
124
  delay?: number;
123
125
  };
126
+ export declare type canvasEventWithTime = eventWithTime & {
127
+ type: EventType.IncrementalSnapshot;
128
+ data: canvasMutationData;
129
+ };
124
130
  export declare type blockClass = string | RegExp;
125
131
  export declare type maskTextClass = string | RegExp;
126
132
  export declare type SamplingStrategy = Partial<{
@@ -130,6 +136,7 @@ export declare type SamplingStrategy = Partial<{
130
136
  scroll: number;
131
137
  media: number;
132
138
  input: 'all' | 'last';
139
+ canvas: 'all' | number;
133
140
  }>;
134
141
  export declare type RecordPlugin<TOptions = unknown> = {
135
142
  name: string;
@@ -194,6 +201,7 @@ export declare type observerParam = {
194
201
  doc: Document;
195
202
  mirror: Mirror;
196
203
  iframeManager: IframeManager;
204
+ stylesheetManager: StylesheetManager;
197
205
  shadowDomManager: ShadowDomManager;
198
206
  canvasManager: CanvasManager;
199
207
  enableStrictPrivacy: boolean;
@@ -203,7 +211,7 @@ export declare type observerParam = {
203
211
  options: unknown;
204
212
  }>;
205
213
  };
206
- export declare type MutationBufferParam = Pick<observerParam, 'mutationCb' | 'blockClass' | 'blockSelector' | 'maskTextClass' | 'maskTextSelector' | 'inlineStylesheet' | 'maskInputOptions' | 'maskTextFn' | 'maskInputFn' | 'recordCanvas' | 'inlineImages' | 'slimDOMOptions' | 'doc' | 'mirror' | 'iframeManager' | 'shadowDomManager' | 'canvasManager' | 'enableStrictPrivacy'>;
214
+ export declare type MutationBufferParam = Pick<observerParam, 'mutationCb' | 'blockClass' | 'blockSelector' | 'maskTextClass' | 'maskTextSelector' | 'inlineStylesheet' | 'maskInputOptions' | 'maskTextFn' | 'maskInputFn' | 'recordCanvas' | 'inlineImages' | 'slimDOMOptions' | 'doc' | 'mirror' | 'iframeManager' | 'stylesheetManager' | 'shadowDomManager' | 'canvasManager' | 'enableStrictPrivacy'>;
207
215
  export declare type hooksParam = {
208
216
  mutation?: mutationCallBack;
209
217
  mousemove?: mousemoveCallBack;
@@ -299,19 +307,24 @@ export declare enum CanvasContext {
299
307
  WebGL = 1,
300
308
  WebGL2 = 2
301
309
  }
302
- export declare type SerializedWebGlArg = {
310
+ export declare type SerializedCanvasArg = {
303
311
  rr_type: 'ArrayBuffer';
304
312
  base64: string;
313
+ } | {
314
+ rr_type: 'Blob';
315
+ data: Array<CanvasArg>;
316
+ type?: string;
305
317
  } | {
306
318
  rr_type: string;
307
319
  src: string;
308
320
  } | {
309
321
  rr_type: string;
310
- args: SerializedWebGlArg[];
322
+ args: Array<CanvasArg>;
311
323
  } | {
312
324
  rr_type: string;
313
325
  index: number;
314
- } | string | number | boolean | null | SerializedWebGlArg[];
326
+ };
327
+ export declare type CanvasArg = SerializedCanvasArg | string | number | boolean | null | CanvasArg[];
315
328
  declare type mouseInteractionParam = {
316
329
  type: MouseInteractions;
317
330
  id: number;
@@ -369,6 +382,21 @@ export declare type canvasMutationWithType = {
369
382
  } & canvasMutationCommand;
370
383
  export declare type canvasMutationCallback = (p: canvasMutationParam) => void;
371
384
  export declare type canvasManagerMutationCallback = (target: HTMLCanvasElement, p: canvasMutationWithType) => void;
385
+ export declare type ImageBitmapDataURLWorkerParams = {
386
+ id: number;
387
+ bitmap: ImageBitmap;
388
+ width: number;
389
+ height: number;
390
+ };
391
+ export declare type ImageBitmapDataURLWorkerResponse = {
392
+ id: number;
393
+ } | {
394
+ id: number;
395
+ type: string;
396
+ base64: string;
397
+ width: number;
398
+ height: number;
399
+ };
372
400
  export declare type fontParam = {
373
401
  family: string;
374
402
  fontSource: string;
@@ -409,11 +437,13 @@ export declare type DocumentDimension = {
409
437
  relativeScale: number;
410
438
  absoluteScale: number;
411
439
  };
412
- export declare type Mirror = {
413
- map: idNodeMap;
414
- getId: (n: INode) => number;
440
+ export declare type DeprecatedMirror = {
441
+ map: {
442
+ [key: number]: INode;
443
+ };
444
+ getId: (n: Node) => number;
415
445
  getNode: (id: number) => INode | null;
416
- removeNodeFromMap: (n: INode) => void;
446
+ removeNodeFromMap: (n: Node) => void;
417
447
  has: (id: number) => boolean;
418
448
  reset: () => void;
419
449
  };
@@ -449,6 +479,7 @@ export declare type playerConfig = {
449
479
  strokeStyle?: string;
450
480
  };
451
481
  unpackFn?: UnpackFn;
482
+ useVirtualDom: boolean;
452
483
  plugins?: ReplayPlugin[];
453
484
  inactiveThreshold: number;
454
485
  inactiveSkipTime: number;
@@ -459,7 +490,7 @@ export declare type playerMetaData = {
459
490
  totalTime: number;
460
491
  };
461
492
  export declare type missingNode = {
462
- node: Node;
493
+ node: Node | RRNode;
463
494
  mutation: addedNodeMutation;
464
495
  };
465
496
  export declare type missingNodeMap = {
@@ -494,9 +525,6 @@ export declare enum ReplayerEvents {
494
525
  StateChange = "state-change",
495
526
  PlayBack = "play-back"
496
527
  }
497
- export declare type ElementState = {
498
- scroll?: [number, number];
499
- };
500
528
  export declare type KeepIframeSrcFn = (src: string) => boolean;
501
529
  declare global {
502
530
  interface Window {
@@ -1,8 +1,8 @@
1
- import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, removedNodeMutation, textMutation, attributeMutation, mutationData, scrollData, inputData, DocumentDimension, IWindow } from './types';
2
- import { INode, serializedNodeWithId } from '@highlight-run/rrweb-snapshot';
1
+ import type { throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, DocumentDimension, IWindow, DeprecatedMirror, textMutation } from './types';
2
+ import type { IMirror, Mirror } from '@highlight-run/rrweb-snapshot';
3
+ import type { RRNode, RRIFrameElement } from '@highlight-run/rrdom/es/virtual-dom';
3
4
  export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | IWindow): listenerHandler;
4
- export declare function createMirror(): Mirror;
5
- export declare let _mirror: Mirror;
5
+ export declare let _mirror: DeprecatedMirror;
6
6
  export declare function throttle<T>(func: (arg: T) => void, wait: number, options?: throttleOptions): (arg: T) => void;
7
7
  export declare function hookSetter<T>(target: T, key: string | number | symbol, d: PropertyDescriptor, isRevoked?: boolean, win?: Window & typeof globalThis): hookResetter;
8
8
  export declare function patch(source: {
@@ -12,42 +12,11 @@ export declare function getWindowHeight(): number;
12
12
  export declare function getWindowWidth(): number;
13
13
  export declare const isCanvasNode: (node: Node | null) => boolean;
14
14
  export declare function isBlocked(node: Node | null, blockClass: blockClass): boolean;
15
- export declare function isIgnored(n: Node | INode): boolean;
16
- export declare function isAncestorRemoved(target: INode, mirror: Mirror): boolean;
15
+ export declare function isSerialized(n: Node, mirror: Mirror): boolean;
16
+ export declare function isIgnored(n: Node, mirror: Mirror): boolean;
17
+ export declare function isAncestorRemoved(target: Node, mirror: Mirror): boolean;
17
18
  export declare function isTouchEvent(event: MouseEvent | TouchEvent): event is TouchEvent;
18
19
  export declare function polyfill(win?: Window & typeof globalThis): void;
19
- export declare type TreeNode = {
20
- id: number;
21
- mutation: addedNodeMutation;
22
- parent?: TreeNode;
23
- children: Record<number, TreeNode>;
24
- texts: textMutation[];
25
- attributes: attributeMutation[];
26
- };
27
- export declare class TreeIndex {
28
- tree: Record<number, TreeNode>;
29
- private removeNodeMutations;
30
- private textMutations;
31
- private attributeMutations;
32
- private indexes;
33
- private removeIdSet;
34
- private scrollMap;
35
- private inputMap;
36
- constructor();
37
- add(mutation: addedNodeMutation): void;
38
- remove(mutation: removedNodeMutation, mirror: Mirror): void;
39
- text(mutation: textMutation): void;
40
- attribute(mutation: attributeMutation): void;
41
- scroll(d: scrollData): void;
42
- input(d: inputData): void;
43
- flush(): {
44
- mutationData: mutationData;
45
- scrollMap: TreeIndex['scrollMap'];
46
- inputMap: TreeIndex['inputMap'];
47
- };
48
- private reset;
49
- idRemoved(id: number): boolean;
50
- }
51
20
  declare type ResolveTree = {
52
21
  value: addedNodeMutation;
53
22
  children: ResolveTree[];
@@ -55,16 +24,20 @@ declare type ResolveTree = {
55
24
  };
56
25
  export declare function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[];
57
26
  export declare function iterateResolveTree(tree: ResolveTree, cb: (mutation: addedNodeMutation) => unknown): void;
58
- declare type HTMLIFrameINode = HTMLIFrameElement & {
59
- __sn: serializedNodeWithId;
60
- };
61
27
  export declare type AppendedIframe = {
62
28
  mutationInQueue: addedNodeMutation;
63
- builtNode: HTMLIFrameINode;
29
+ builtNode: HTMLIFrameElement | RRIFrameElement;
64
30
  };
65
- export declare function isIframeINode(node: INode | ShadowRoot): node is HTMLIFrameINode;
31
+ export declare function isSerializedIframe<TNode extends Node | RRNode>(n: TNode, mirror: IMirror<TNode>): boolean;
32
+ export declare function isSerializedStylesheet<TNode extends Node | RRNode>(n: TNode, mirror: IMirror<TNode>): boolean;
66
33
  export declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension;
67
- export declare function hasShadowRoot<T extends Node>(n: T): n is T & {
34
+ export declare function hasShadowRoot<T extends Node | RRNode>(n: T): n is T & {
68
35
  shadowRoot: ShadowRoot;
69
36
  };
37
+ export declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule;
38
+ export declare function getPositionsAndIndex(nestedIndex: number[]): {
39
+ positions: number[];
40
+ index: number | undefined;
41
+ };
42
+ export declare function uniqueTextMutations(mutations: textMutation[]): textMutation[];
70
43
  export {};
@@ -1,78 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- var __assign = function() {
17
- __assign = Object.assign || function __assign(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
-
27
- function __rest(s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- }
38
-
39
- function __values(o) {
40
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
41
- if (m) return m.call(o);
42
- if (o && typeof o.length === "number") return {
43
- next: function () {
44
- if (o && i >= o.length) o = void 0;
45
- return { value: o && o[i++], done: !o };
46
- }
47
- };
48
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
49
- }
50
-
51
- function __read(o, n) {
52
- var m = typeof Symbol === "function" && o[Symbol.iterator];
53
- if (!m) return o;
54
- var i = m.call(o), r, ar = [], e;
55
- try {
56
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
57
- }
58
- catch (error) { e = { error: error }; }
59
- finally {
60
- try {
61
- if (r && !r.done && (m = i["return"])) m.call(i);
62
- }
63
- finally { if (e) throw e.error; }
64
- }
65
- return ar;
66
- }
67
-
68
- function __spreadArray(to, from, pack) {
69
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
70
- if (ar || !(i in from)) {
71
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
72
- ar[i] = from[i];
73
- }
74
- }
75
- return to.concat(ar || Array.prototype.slice.call(from));
76
- }
77
-
78
- export { __assign, __read, __rest, __spreadArray, __values };