@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,12 +1,14 @@
1
1
  import record from './record/index.js';
2
2
  export { default as record } from './record/index.js';
3
- export { Replayer } from './replay/index.js';
3
+ import '../../rrweb-snapshot/es/rrweb-snapshot.js';
4
+ import '../../rrdom/es/virtual-dom.js';
5
+ export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from './types.js';
4
6
  import * as utils from './utils.js';
5
7
  export { utils };
6
8
  export { _mirror as mirror } from './utils.js';
7
- export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from './types.js';
9
+ import './../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
8
10
 
9
- var addCustomEvent = record.addCustomEvent;
10
- var freezePage = record.freezePage;
11
+ const { addCustomEvent } = record;
12
+ const { freezePage } = record;
11
13
 
12
14
  export { addCustomEvent, freezePage };
@@ -1,3 +1,3 @@
1
- var MARK = 'v1';
1
+ const MARK = 'v1';
2
2
 
3
3
  export { MARK };
@@ -1,10 +1,9 @@
1
- import { __assign } from '../../ext/tslib/tslib.es6.js';
2
- import { strFromU8, zlibSync, strToU8 } from '../../../../ext/fflate/esm/browser.js';
1
+ import { strFromU8, zlibSync, strToU8 } from './../../../../ext/fflate/esm/browser.js';
3
2
  import { MARK } from './base.js';
4
3
 
5
- var pack = function (event) {
6
- var _e = __assign(__assign({}, event), { v: MARK });
7
- return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);
4
+ const pack = (event) => {
5
+ const _e = Object.assign(Object.assign({}, event), { v: MARK });
6
+ return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);
8
7
  };
9
8
 
10
9
  export { pack };
@@ -1,29 +1,29 @@
1
- import { strFromU8, unzlibSync, strToU8 } from '../../../../ext/fflate/esm/browser.js';
1
+ import { strFromU8, unzlibSync, strToU8 } from './../../../../ext/fflate/esm/browser.js';
2
2
  import { MARK } from './base.js';
3
3
 
4
- var unpack = function (raw) {
5
- if (typeof raw !== 'string') {
6
- return raw;
7
- }
8
- try {
9
- var e = JSON.parse(raw);
10
- if (e.timestamp) {
11
- return e;
12
- }
13
- }
14
- catch (error) {
15
- }
16
- try {
17
- var e = JSON.parse(strFromU8(unzlibSync(strToU8(raw, true))));
18
- if (e.v === MARK) {
19
- return e;
20
- }
21
- throw new Error("These events were packed with packer ".concat(e.v, " which is incompatible with current packer ").concat(MARK, "."));
22
- }
23
- catch (error) {
24
- console.error(error);
25
- throw new Error('Unknown data format.');
26
- }
4
+ const unpack = (raw) => {
5
+ if (typeof raw !== 'string') {
6
+ return raw;
7
+ }
8
+ try {
9
+ const e = JSON.parse(raw);
10
+ if (e.timestamp) {
11
+ return e;
12
+ }
13
+ }
14
+ catch (error) {
15
+ }
16
+ try {
17
+ const e = JSON.parse(strFromU8(unzlibSync(strToU8(raw, true))));
18
+ if (e.v === MARK) {
19
+ return e;
20
+ }
21
+ throw new Error(`These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`);
22
+ }
23
+ catch (error) {
24
+ console.error(error);
25
+ throw new Error('Unknown data format.');
26
+ }
27
27
  };
28
28
 
29
29
  export { unpack };
@@ -1,179 +1,178 @@
1
- var StackFrame = (function () {
2
- function StackFrame(obj) {
3
- this.fileName = obj.fileName || '';
4
- this.functionName = obj.functionName || '';
5
- this.lineNumber = obj.lineNumber;
6
- this.columnNumber = obj.columnNumber;
7
- }
8
- StackFrame.prototype.toString = function () {
9
- var lineNumber = this.lineNumber || '';
10
- var columnNumber = this.columnNumber || '';
11
- if (this.functionName) {
12
- return (this.functionName +
13
- ' (' +
14
- this.fileName +
15
- ':' +
16
- lineNumber +
17
- ':' +
18
- columnNumber +
19
- ')');
20
- }
21
- return this.fileName + ':' + lineNumber + ':' + columnNumber;
22
- };
23
- return StackFrame;
24
- }());
25
- var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
26
- var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
27
- var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
28
- var ErrorStackParser = {
29
- parse: function (error) {
30
- if (!error) {
31
- return [];
32
- }
33
- if (typeof error.stacktrace !== 'undefined' ||
34
- typeof error['opera#sourceloc'] !== 'undefined') {
35
- return this.parseOpera(error);
36
- }
37
- else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
38
- return this.parseV8OrIE(error);
39
- }
40
- else if (error.stack) {
41
- return this.parseFFOrSafari(error);
42
- }
43
- else {
44
- throw new Error('Cannot parse given Error object');
45
- }
46
- },
47
- extractLocation: function (urlLike) {
48
- if (urlLike.indexOf(':') === -1) {
49
- return [urlLike];
50
- }
51
- var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
52
- var parts = regExp.exec(urlLike.replace(/[()]/g, ''));
53
- if (!parts)
54
- throw new Error("Cannot parse given url: ".concat(urlLike));
55
- return [parts[1], parts[2] || undefined, parts[3] || undefined];
56
- },
57
- parseV8OrIE: function (error) {
58
- var filtered = error.stack.split('\n').filter(function (line) {
59
- return !!line.match(CHROME_IE_STACK_REGEXP);
60
- }, this);
61
- return filtered.map(function (line) {
62
- if (line.indexOf('(eval ') > -1) {
63
- line = line
64
- .replace(/eval code/g, 'eval')
65
- .replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
66
- }
67
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
68
- var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
69
- sanitizedLine = location
70
- ? sanitizedLine.replace(location[0], '')
71
- : sanitizedLine;
72
- var tokens = sanitizedLine.split(/\s+/).slice(1);
73
- var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
74
- var functionName = tokens.join(' ') || undefined;
75
- var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1
76
- ? undefined
77
- : locationParts[0];
78
- return new StackFrame({
79
- functionName: functionName,
80
- fileName: fileName,
81
- lineNumber: locationParts[1],
82
- columnNumber: locationParts[2],
83
- });
84
- }, this);
85
- },
86
- parseFFOrSafari: function (error) {
87
- var filtered = error.stack.split('\n').filter(function (line) {
88
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
89
- }, this);
90
- return filtered.map(function (line) {
91
- if (line.indexOf(' > eval') > -1) {
92
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
93
- }
94
- if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
95
- return new StackFrame({
96
- functionName: line,
97
- });
98
- }
99
- else {
100
- var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
101
- var matches = line.match(functionNameRegex);
102
- var functionName = matches && matches[1] ? matches[1] : undefined;
103
- var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
104
- return new StackFrame({
105
- functionName: functionName,
106
- fileName: locationParts[0],
107
- lineNumber: locationParts[1],
108
- columnNumber: locationParts[2],
109
- });
110
- }
111
- }, this);
112
- },
113
- parseOpera: function (e) {
114
- if (!e.stacktrace ||
115
- (e.message.indexOf('\n') > -1 &&
116
- e.message.split('\n').length > e.stacktrace.split('\n').length)) {
117
- return this.parseOpera9(e);
118
- }
119
- else if (!e.stack) {
120
- return this.parseOpera10(e);
121
- }
122
- else {
123
- return this.parseOpera11(e);
124
- }
125
- },
126
- parseOpera9: function (e) {
127
- var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
128
- var lines = e.message.split('\n');
129
- var result = [];
130
- for (var i = 2, len = lines.length; i < len; i += 2) {
131
- var match = lineRE.exec(lines[i]);
132
- if (match) {
133
- result.push(new StackFrame({
134
- fileName: match[2],
135
- lineNumber: parseFloat(match[1]),
136
- }));
137
- }
138
- }
139
- return result;
140
- },
141
- parseOpera10: function (e) {
142
- var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
143
- var lines = e.stacktrace.split('\n');
144
- var result = [];
145
- for (var i = 0, len = lines.length; i < len; i += 2) {
146
- var match = lineRE.exec(lines[i]);
147
- if (match) {
148
- result.push(new StackFrame({
149
- functionName: match[3] || undefined,
150
- fileName: match[2],
151
- lineNumber: parseFloat(match[1]),
152
- }));
153
- }
154
- }
155
- return result;
156
- },
157
- parseOpera11: function (error) {
158
- var filtered = error.stack.split('\n').filter(function (line) {
159
- return (!!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
160
- !line.match(/^Error created at/));
161
- }, this);
162
- return filtered.map(function (line) {
163
- var tokens = line.split('@');
164
- var locationParts = this.extractLocation(tokens.pop());
165
- var functionCall = tokens.shift() || '';
166
- var functionName = functionCall
167
- .replace(/<anonymous function(: (\w+))?>/, '$2')
168
- .replace(/\([^)]*\)/g, '') || undefined;
169
- return new StackFrame({
170
- functionName: functionName,
171
- fileName: locationParts[0],
172
- lineNumber: locationParts[1],
173
- columnNumber: locationParts[2],
174
- });
175
- }, this);
176
- },
1
+ class StackFrame {
2
+ constructor(obj) {
3
+ this.fileName = obj.fileName || '';
4
+ this.functionName = obj.functionName || '';
5
+ this.lineNumber = obj.lineNumber;
6
+ this.columnNumber = obj.columnNumber;
7
+ }
8
+ toString() {
9
+ const lineNumber = this.lineNumber || '';
10
+ const columnNumber = this.columnNumber || '';
11
+ if (this.functionName) {
12
+ return (this.functionName +
13
+ ' (' +
14
+ this.fileName +
15
+ ':' +
16
+ lineNumber +
17
+ ':' +
18
+ columnNumber +
19
+ ')');
20
+ }
21
+ return this.fileName + ':' + lineNumber + ':' + columnNumber;
22
+ }
23
+ }
24
+ const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
25
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
26
+ const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
27
+ const ErrorStackParser = {
28
+ parse: function (error) {
29
+ if (!error) {
30
+ return [];
31
+ }
32
+ if (typeof error.stacktrace !== 'undefined' ||
33
+ typeof error['opera#sourceloc'] !== 'undefined') {
34
+ return this.parseOpera(error);
35
+ }
36
+ else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
37
+ return this.parseV8OrIE(error);
38
+ }
39
+ else if (error.stack) {
40
+ return this.parseFFOrSafari(error);
41
+ }
42
+ else {
43
+ throw new Error('Cannot parse given Error object');
44
+ }
45
+ },
46
+ extractLocation: function (urlLike) {
47
+ if (urlLike.indexOf(':') === -1) {
48
+ return [urlLike];
49
+ }
50
+ const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
51
+ const parts = regExp.exec(urlLike.replace(/[()]/g, ''));
52
+ if (!parts)
53
+ throw new Error(`Cannot parse given url: ${urlLike}`);
54
+ return [parts[1], parts[2] || undefined, parts[3] || undefined];
55
+ },
56
+ parseV8OrIE: function (error) {
57
+ const filtered = error.stack.split('\n').filter(function (line) {
58
+ return !!line.match(CHROME_IE_STACK_REGEXP);
59
+ }, this);
60
+ return filtered.map(function (line) {
61
+ if (line.indexOf('(eval ') > -1) {
62
+ line = line
63
+ .replace(/eval code/g, 'eval')
64
+ .replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
65
+ }
66
+ let sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
67
+ const location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
68
+ sanitizedLine = location
69
+ ? sanitizedLine.replace(location[0], '')
70
+ : sanitizedLine;
71
+ const tokens = sanitizedLine.split(/\s+/).slice(1);
72
+ const locationParts = this.extractLocation(location ? location[1] : tokens.pop());
73
+ const functionName = tokens.join(' ') || undefined;
74
+ const fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1
75
+ ? undefined
76
+ : locationParts[0];
77
+ return new StackFrame({
78
+ functionName,
79
+ fileName,
80
+ lineNumber: locationParts[1],
81
+ columnNumber: locationParts[2],
82
+ });
83
+ }, this);
84
+ },
85
+ parseFFOrSafari: function (error) {
86
+ const filtered = error.stack.split('\n').filter(function (line) {
87
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
88
+ }, this);
89
+ return filtered.map(function (line) {
90
+ if (line.indexOf(' > eval') > -1) {
91
+ line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
92
+ }
93
+ if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
94
+ return new StackFrame({
95
+ functionName: line,
96
+ });
97
+ }
98
+ else {
99
+ const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
100
+ const matches = line.match(functionNameRegex);
101
+ const functionName = matches && matches[1] ? matches[1] : undefined;
102
+ const locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
103
+ return new StackFrame({
104
+ functionName,
105
+ fileName: locationParts[0],
106
+ lineNumber: locationParts[1],
107
+ columnNumber: locationParts[2],
108
+ });
109
+ }
110
+ }, this);
111
+ },
112
+ parseOpera: function (e) {
113
+ if (!e.stacktrace ||
114
+ (e.message.indexOf('\n') > -1 &&
115
+ e.message.split('\n').length > e.stacktrace.split('\n').length)) {
116
+ return this.parseOpera9(e);
117
+ }
118
+ else if (!e.stack) {
119
+ return this.parseOpera10(e);
120
+ }
121
+ else {
122
+ return this.parseOpera11(e);
123
+ }
124
+ },
125
+ parseOpera9: function (e) {
126
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
127
+ const lines = e.message.split('\n');
128
+ const result = [];
129
+ for (let i = 2, len = lines.length; i < len; i += 2) {
130
+ const match = lineRE.exec(lines[i]);
131
+ if (match) {
132
+ result.push(new StackFrame({
133
+ fileName: match[2],
134
+ lineNumber: parseFloat(match[1]),
135
+ }));
136
+ }
137
+ }
138
+ return result;
139
+ },
140
+ parseOpera10: function (e) {
141
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
142
+ const lines = e.stacktrace.split('\n');
143
+ const result = [];
144
+ for (let i = 0, len = lines.length; i < len; i += 2) {
145
+ const match = lineRE.exec(lines[i]);
146
+ if (match) {
147
+ result.push(new StackFrame({
148
+ functionName: match[3] || undefined,
149
+ fileName: match[2],
150
+ lineNumber: parseFloat(match[1]),
151
+ }));
152
+ }
153
+ }
154
+ return result;
155
+ },
156
+ parseOpera11: function (error) {
157
+ const filtered = error.stack.split('\n').filter(function (line) {
158
+ return (!!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
159
+ !line.match(/^Error created at/));
160
+ }, this);
161
+ return filtered.map(function (line) {
162
+ const tokens = line.split('@');
163
+ const locationParts = this.extractLocation(tokens.pop());
164
+ const functionCall = tokens.shift() || '';
165
+ const functionName = functionCall
166
+ .replace(/<anonymous function(: (\w+))?>/, '$2')
167
+ .replace(/\([^)]*\)/g, '') || undefined;
168
+ return new StackFrame({
169
+ functionName,
170
+ fileName: locationParts[0],
171
+ lineNumber: locationParts[1],
172
+ columnNumber: locationParts[2],
173
+ });
174
+ }, this);
175
+ },
177
176
  };
178
177
 
179
178
  export { ErrorStackParser, StackFrame };