@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
@@ -1,35 +1,43 @@
1
+ import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
1
2
  import { CanvasContext } from '../../types.js';
2
3
  import webglMutation from './webgl.js';
3
4
  import canvasMutation$1 from './2d.js';
4
5
 
5
- function canvasMutation(_a) {
6
- var event = _a.event, mutation = _a.mutation, target = _a.target, imageMap = _a.imageMap, errorHandler = _a.errorHandler;
7
- try {
8
- var mutations = 'commands' in mutation ? mutation.commands : [mutation];
9
- if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {
10
- return mutations.forEach(function (command) {
11
- webglMutation({
12
- mutation: command,
13
- type: mutation.type,
14
- target: target,
15
- imageMap: imageMap,
16
- errorHandler: errorHandler,
17
- });
18
- });
19
- }
20
- return mutations.forEach(function (command) {
21
- canvasMutation$1({
22
- event: event,
23
- mutation: command,
24
- target: target,
25
- imageMap: imageMap,
26
- errorHandler: errorHandler,
27
- });
28
- });
29
- }
30
- catch (error) {
31
- errorHandler(mutation, error);
32
- }
6
+ function canvasMutation({ event, mutation, target, imageMap, canvasEventMap, errorHandler, }) {
7
+ return __awaiter(this, void 0, void 0, function* () {
8
+ try {
9
+ const precomputedMutation = canvasEventMap.get(event) || mutation;
10
+ const commands = 'commands' in precomputedMutation
11
+ ? precomputedMutation.commands
12
+ : [precomputedMutation];
13
+ if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {
14
+ for (let i = 0; i < commands.length; i++) {
15
+ const command = commands[i];
16
+ yield webglMutation({
17
+ mutation: command,
18
+ type: mutation.type,
19
+ target,
20
+ imageMap,
21
+ errorHandler,
22
+ });
23
+ }
24
+ return;
25
+ }
26
+ for (let i = 0; i < commands.length; i++) {
27
+ const command = commands[i];
28
+ yield canvasMutation$1({
29
+ event,
30
+ mutation: command,
31
+ target,
32
+ imageMap,
33
+ errorHandler,
34
+ });
35
+ }
36
+ }
37
+ catch (error) {
38
+ errorHandler(mutation, error);
39
+ }
40
+ });
33
41
  }
34
42
 
35
- export default canvasMutation;
43
+ export { canvasMutation as default };
@@ -1,124 +1,62 @@
1
- import { __spreadArray, __read } from '../../../ext/tslib/tslib.es6.js';
2
- import { decode } from '../../../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
1
+ import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
3
2
  import { CanvasContext } from '../../types.js';
3
+ import { deserializeArg, variableListFor } from './deserialize-args.js';
4
4
 
5
- var webGLVarMap = new Map();
6
- function variableListFor(ctx, ctor) {
7
- var contextMap = webGLVarMap.get(ctx);
8
- if (!contextMap) {
9
- contextMap = new Map();
10
- webGLVarMap.set(ctx, contextMap);
11
- }
12
- if (!contextMap.has(ctor)) {
13
- contextMap.set(ctor, []);
14
- }
15
- return contextMap.get(ctor);
16
- }
17
- function getContext(target, type) {
18
- try {
19
- if (type === CanvasContext.WebGL) {
20
- return (target.getContext('webgl') || target.getContext('experimental-webgl'));
21
- }
22
- return target.getContext('webgl2');
23
- }
24
- catch (e) {
25
- return null;
26
- }
27
- }
28
- var WebGLVariableConstructorsNames = [
29
- 'WebGLActiveInfo',
30
- 'WebGLBuffer',
31
- 'WebGLFramebuffer',
32
- 'WebGLProgram',
33
- 'WebGLRenderbuffer',
34
- 'WebGLShader',
35
- 'WebGLShaderPrecisionFormat',
36
- 'WebGLTexture',
37
- 'WebGLUniformLocation',
38
- 'WebGLVertexArrayObject',
39
- ];
40
- function saveToWebGLVarMap(ctx, result) {
41
- if (!(result === null || result === void 0 ? void 0 : result.constructor))
42
- return;
43
- var name = result.constructor.name;
44
- if (!WebGLVariableConstructorsNames.includes(name))
45
- return;
46
- var variables = variableListFor(ctx, name);
47
- if (!variables.includes(result))
48
- variables.push(result);
49
- }
50
- function deserializeArg(imageMap, ctx) {
51
- return function (arg) {
52
- if (arg && typeof arg === 'object' && 'rr_type' in arg) {
53
- if ('index' in arg) {
54
- var name_1 = arg.rr_type, index = arg.index;
55
- return variableListFor(ctx, name_1)[index];
56
- }
57
- else if ('args' in arg) {
58
- var name_2 = arg.rr_type, args = arg.args;
59
- var ctor = window[name_2];
60
- return new (ctor.bind.apply(ctor, __spreadArray([void 0], __read(args.map(deserializeArg(imageMap, ctx))), false)))();
61
- }
62
- else if ('base64' in arg) {
63
- return decode(arg.base64);
64
- }
65
- else if ('src' in arg) {
66
- var image = imageMap.get(arg.src);
67
- if (image) {
68
- return image;
69
- }
70
- else {
71
- var image_1 = new Image();
72
- image_1.src = arg.src;
73
- imageMap.set(arg.src, image_1);
74
- return image_1;
75
- }
76
- }
77
- }
78
- else if (Array.isArray(arg)) {
79
- return arg.map(deserializeArg(imageMap, ctx));
80
- }
81
- return arg;
82
- };
83
- }
84
- function webglMutation(_a) {
85
- var mutation = _a.mutation, target = _a.target, type = _a.type, imageMap = _a.imageMap, errorHandler = _a.errorHandler;
86
- try {
87
- var ctx = getContext(target, type);
88
- if (!ctx)
89
- return;
90
- if (mutation.setter) {
91
- ctx[mutation.property] = mutation.args[0];
92
- return;
93
- }
94
- var original = ctx[mutation.property];
95
- var args = mutation.args.map(deserializeArg(imageMap, ctx));
96
- var result = original.apply(ctx, args);
97
- saveToWebGLVarMap(ctx, result);
98
- var debugMode = false;
99
- if (debugMode) {
100
- if (mutation.property === 'compileShader') {
101
- if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))
102
- console.warn('something went wrong in replay', ctx.getShaderInfoLog(args[0]));
103
- }
104
- else if (mutation.property === 'linkProgram') {
105
- ctx.validateProgram(args[0]);
106
- if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))
107
- console.warn('something went wrong in replay', ctx.getProgramInfoLog(args[0]));
108
- }
109
- var webglError = ctx.getError();
110
- if (webglError !== ctx.NO_ERROR) {
111
- console.warn.apply(console, __spreadArray(['WEBGL ERROR',
112
- webglError,
113
- 'on command:',
114
- mutation.property], __read(args), false));
115
- }
116
- }
117
- }
118
- catch (error) {
119
- errorHandler(mutation, error);
120
- }
5
+ function getContext(target, type) {
6
+ try {
7
+ if (type === CanvasContext.WebGL) {
8
+ return (target.getContext('webgl') ||
9
+ target.getContext('experimental-webgl'));
10
+ }
11
+ return target.getContext('webgl2');
12
+ }
13
+ catch (e) {
14
+ return null;
15
+ }
16
+ }
17
+ const WebGLVariableConstructorsNames = [
18
+ 'WebGLActiveInfo',
19
+ 'WebGLBuffer',
20
+ 'WebGLFramebuffer',
21
+ 'WebGLProgram',
22
+ 'WebGLRenderbuffer',
23
+ 'WebGLShader',
24
+ 'WebGLShaderPrecisionFormat',
25
+ 'WebGLTexture',
26
+ 'WebGLUniformLocation',
27
+ 'WebGLVertexArrayObject',
28
+ ];
29
+ function saveToWebGLVarMap(ctx, result) {
30
+ if (!(result === null || result === void 0 ? void 0 : result.constructor))
31
+ return;
32
+ const { name } = result.constructor;
33
+ if (!WebGLVariableConstructorsNames.includes(name))
34
+ return;
35
+ const variables = variableListFor(ctx, name);
36
+ if (!variables.includes(result))
37
+ variables.push(result);
38
+ }
39
+ function webglMutation({ mutation, target, type, imageMap, errorHandler, }) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const ctx = getContext(target, type);
43
+ if (!ctx)
44
+ return;
45
+ if (mutation.setter) {
46
+ ctx[mutation.property] = mutation.args[0];
47
+ return;
48
+ }
49
+ const original = ctx[mutation.property];
50
+ const args = yield Promise.all(mutation.args.map(deserializeArg(imageMap, ctx)));
51
+ const result = original.apply(ctx, args);
52
+ saveToWebGLVarMap(ctx, result);
53
+ const debugMode = false;
54
+ if (debugMode) ;
55
+ }
56
+ catch (error) {
57
+ errorHandler(mutation, error);
58
+ }
59
+ });
121
60
  }
122
61
 
123
- export default webglMutation;
124
- export { deserializeArg, variableListFor };
62
+ export { webglMutation as default };