@highlight-run/rrweb 2.0.1 → 2.0.4

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 (117) hide show
  1. package/dist/plugins/console-record.js +408 -609
  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 +142 -271
  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 +23 -26
  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 +26 -30
  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 +63 -146
  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 +3002 -3118
  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.js +4354 -4054
  20. package/dist/replay/rrweb-replay-unpack.min.js +5 -17
  21. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  22. package/dist/replay/rrweb-replay.js +4286 -3984
  23. package/dist/replay/rrweb-replay.min.js +5 -17
  24. package/dist/replay/rrweb-replay.min.js.map +1 -1
  25. package/dist/rrweb-all.js +7634 -7453
  26. package/dist/rrweb-all.min.js +16 -17
  27. package/dist/rrweb-all.min.js.map +1 -1
  28. package/dist/rrweb.js +7339 -7075
  29. package/dist/rrweb.min.js +6 -17
  30. package/dist/rrweb.min.js.map +1 -1
  31. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  32. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  33. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
  34. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  35. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  36. package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
  37. package/es/rrweb/ext/mitt/dist/mitt.es.js +1 -1
  38. package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
  39. package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
  40. package/es/rrweb/packages/rrweb/src/index.js +6 -4
  41. package/es/rrweb/packages/rrweb/src/packer/base.js +1 -1
  42. package/es/rrweb/packages/rrweb/src/packer/pack.js +4 -5
  43. package/es/rrweb/packages/rrweb/src/packer/unpack.js +24 -24
  44. package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +175 -176
  45. package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +109 -128
  46. package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +125 -138
  47. package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +88 -105
  48. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +19 -20
  49. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +25 -25
  50. package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +29 -30
  51. package/es/rrweb/packages/rrweb/src/record/index.js +348 -373
  52. package/es/rrweb/packages/rrweb/src/record/mutation.js +487 -528
  53. package/es/rrweb/packages/rrweb/src/record/observer.js +584 -659
  54. package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +44 -73
  55. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +166 -87
  56. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +21 -26
  57. package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +119 -112
  58. package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +53 -72
  59. package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +38 -40
  60. package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
  61. package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +27 -23
  62. package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
  63. package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +37 -29
  64. package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +58 -120
  65. package/es/rrweb/packages/rrweb/src/replay/index.js +1545 -1854
  66. package/es/rrweb/packages/rrweb/src/replay/machine.js +275 -315
  67. package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +216 -218
  68. package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -7
  69. package/es/rrweb/packages/rrweb/src/replay/timer.js +87 -91
  70. package/es/rrweb/packages/rrweb/src/types.js +72 -72
  71. package/es/rrweb/packages/rrweb/src/utils.js +312 -506
  72. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +195 -71
  73. package/lib/plugins/console-record.js +469 -627
  74. package/lib/plugins/console-replay.js +198 -268
  75. package/lib/plugins/sequential-id-record.js +19 -20
  76. package/lib/plugins/sequential-id-replay.js +25 -25
  77. package/lib/record/rrweb-record-pack.js +184 -139
  78. package/lib/record/rrweb-record.js +2473 -2425
  79. package/lib/replay/rrweb-replay-unpack.js +3797 -3343
  80. package/lib/replay/rrweb-replay.js +3742 -3288
  81. package/lib/rrweb-all.js +6725 -6247
  82. package/lib/rrweb.js +6157 -5632
  83. package/package.json +14 -13
  84. package/typings/packer/base.d.ts +1 -1
  85. package/typings/plugins/console/record/index.d.ts +1 -1
  86. package/typings/plugins/console/record/stringify.d.ts +1 -1
  87. package/typings/plugins/sequential-id/record/index.d.ts +1 -1
  88. package/typings/plugins/sequential-id/replay/index.d.ts +1 -1
  89. package/typings/record/iframe-manager.d.ts +3 -3
  90. package/typings/record/index.d.ts +1 -1
  91. package/typings/record/mutation.d.ts +2 -1
  92. package/typings/record/observers/canvas/2d.d.ts +2 -1
  93. package/typings/record/observers/canvas/canvas-manager.d.ts +5 -2
  94. package/typings/record/observers/canvas/canvas.d.ts +1 -1
  95. package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
  96. package/typings/record/observers/canvas/webgl.d.ts +2 -1
  97. package/typings/record/shadow-dom-manager.d.ts +2 -1
  98. package/typings/record/stylesheet-manager.d.ts +12 -0
  99. package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
  100. package/typings/replay/canvas/2d.d.ts +3 -3
  101. package/typings/replay/canvas/deserialize-args.d.ts +7 -0
  102. package/typings/replay/canvas/index.d.ts +4 -3
  103. package/typings/replay/canvas/webgl.d.ts +3 -5
  104. package/typings/replay/index.d.ts +7 -10
  105. package/typings/types.d.ts +45 -17
  106. package/typings/utils.d.ts +17 -44
  107. package/dist/replay/rrweb-replay-unpack.min.css +0 -2
  108. package/dist/replay/rrweb-replay-unpack.min.css.map +0 -1
  109. package/dist/replay/rrweb-replay.min.css +0 -2
  110. package/dist/replay/rrweb-replay.min.css.map +0 -1
  111. package/dist/rrweb-all.min.css +0 -2
  112. package/dist/rrweb-all.min.css.map +0 -1
  113. package/dist/rrweb.min.css +0 -2
  114. package/dist/rrweb.min.css.map +0 -1
  115. package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +0 -78
  116. package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +0 -121
  117. 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 };