@cloudcare/browser-rum 3.0.0 → 3.0.1

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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: '3.0.0',
8
+ sdkVersion: '3.0.1',
9
9
  sdkName: 'df_web_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -83,13 +83,19 @@ function processMutations(mutations, mutationCallback, configuration, shadowRoot
83
83
  }), configuration, shadowRootsController);
84
84
 
85
85
  var adds = _processChildListMutations.adds;
86
- var removes = _processChildListMutations.removes;
87
- var hasBeenSerialized = _processChildListMutations.hasBeenSerialized;
86
+ var removes = _processChildListMutations.removes; // var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
87
+
88
+ var serializedNodeIds = _processChildListMutations.serializedNodeIds;
89
+
90
+ function hasBeenSerialized(node) {
91
+ return (0, _serializationUtils.hasSerializedNode)(node) && serializedNodeIds.has((0, _serializationUtils.getSerializedNodeId)(node));
92
+ }
93
+
88
94
  var texts = processCharacterDataMutations(filteredMutations.filter(function (mutation) {
89
95
  return mutation.type === 'characterData' && !hasBeenSerialized(mutation.target);
90
96
  }), configuration);
91
97
  var attributes = processAttributesMutations(filteredMutations.filter(function (mutation) {
92
- mutation.type === 'attributes' && !hasBeenSerialized(mutation.target);
98
+ return mutation.type === 'attributes' && !hasBeenSerialized(mutation.target);
93
99
  }), configuration);
94
100
 
95
101
  if (!texts.length && !attributes.length && !removes.length && !adds.length) {
@@ -207,6 +213,7 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
207
213
  return {
208
214
  adds: addedNodeMutations,
209
215
  removes: removedNodeMutations,
216
+ serializedNodeIds: serializedNodeIds,
210
217
  hasBeenSerialized: hasBeenSerialized
211
218
  };
212
219
 
@@ -247,8 +254,6 @@ function processCharacterDataMutations(mutations, configuration) {
247
254
 
248
255
  try {
249
256
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
250
- var _getTextContent;
251
-
252
257
  var mutation = _step2.value;
253
258
  var value = mutation.target.textContent;
254
259
 
@@ -265,7 +270,7 @@ function processCharacterDataMutations(mutations, configuration) {
265
270
  textMutations.push({
266
271
  id: (0, _serializationUtils.getSerializedNodeId)(mutation.target),
267
272
  // TODO: pass a valid "ignoreWhiteSpace" argument
268
- value: (_getTextContent = (0, _privacy.getTextContent)(mutation.target, false, parentNodePrivacyLevel)) !== null && _getTextContent !== void 0 ? _getTextContent : null
273
+ value: (0, _browserCore.isNullUndefinedDefaultValue)((0, _privacy.getTextContent)(mutation.target, false, parentNodePrivacyLevel, null))
269
274
  });
270
275
  }
271
276
  } catch (err) {
@@ -284,7 +289,7 @@ function processAttributesMutations(mutations, configuration) {
284
289
  var filteredMutations = mutations.filter(function (mutation) {
285
290
  var handledAttributes = handledElements.get(mutation.target);
286
291
 
287
- if (handledAttributes !== null && handledAttributes !== void 0 && handledAttributes.has(mutation.attributeName)) {
292
+ if (handledAttributes && handledAttributes.has(mutation.attributeName)) {
288
293
  return false;
289
294
  }
290
295
 
@@ -447,19 +447,16 @@ function initVisualViewportResizeObserver(cb) {
447
447
 
448
448
  function initFrustrationObserver(lifeCycle, frustrationCb) {
449
449
  return lifeCycle.subscribe(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
450
- var _data$rawRumEvent$act, _data$rawRumEvent$act2, _data$domainContext$e;
451
-
452
- if (data.rawRumEvent.type === _browserCore.RumEventType.ACTION && data.rawRumEvent.action.type === _browserCore.ActionType.CLICK && (_data$rawRumEvent$act = data.rawRumEvent.action.frustration) !== null && _data$rawRumEvent$act !== void 0 && (_data$rawRumEvent$act2 = _data$rawRumEvent$act.type) !== null && _data$rawRumEvent$act2 !== void 0 && _data$rawRumEvent$act2.length && 'events' in data.domainContext && (_data$domainContext$e = data.domainContext.events) !== null && _data$domainContext$e !== void 0 && _data$domainContext$e.length) {
453
- frustrationCb({
454
- timestamp: data.rawRumEvent.date,
455
- type: _types.RecordType.FrustrationRecord,
456
- data: {
457
- frustrationTypes: data.rawRumEvent.action.frustration.type,
458
- recordIds: data.domainContext.events.map(function (e) {
459
- return getRecordIdForEvent(e);
460
- })
461
- }
462
- });
450
+ if (data.rawRumEvent.type === _browserCore.RumEventType.ACTION && data.rawRumEvent.action.type === _browserCore.ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {// frustrationCb({
451
+ // timestamp: data.rawRumEvent.date,
452
+ // type: RecordType.FrustrationRecord,
453
+ // data: {
454
+ // frustrationTypes: data.rawRumEvent.action.frustration.type,
455
+ // recordIds: data.domainContext.events.map(function (e) {
456
+ // return getRecordIdForEvent(e)
457
+ // })
458
+ // }
459
+ // })
463
460
  }
464
461
  }).unsubscribe;
465
462
  }
@@ -17,11 +17,11 @@ function createDeflateWorker() {
17
17
 
18
18
  function workerCodeFn() {
19
19
  monitor(function () {
20
- var _makePakoDeflate = makePakoDeflate(),
21
- Deflate = _makePakoDeflate.Deflate,
22
- constants = _makePakoDeflate.constants,
23
- string2buf = _makePakoDeflate.string2buf;
20
+ var _makePakoDeflate = makePakoDeflate();
24
21
 
22
+ var Deflate = _makePakoDeflate.Deflate;
23
+ var constants = _makePakoDeflate.constants;
24
+ var string2buf = _makePakoDeflate.string2buf;
25
25
  var deflate = new Deflate();
26
26
  var rawBytesCount = 0;
27
27
  self.addEventListener('message', monitor(function (event) {
@@ -50,14 +50,13 @@ function workerCodeFn() {
50
50
 
51
51
  case 'flush':
52
52
  {
53
- var _additionalBytesCount = data.data ? pushData(data.data) : 0;
54
-
53
+ var additionalBytesCount = data.data ? pushData(data.data) : 0;
55
54
  deflate.push('', constants.Z_FINISH);
56
55
  self.postMessage({
57
56
  type: 'flushed',
58
57
  id: data.id,
59
58
  result: deflate.result,
60
- additionalBytesCount: _additionalBytesCount,
59
+ additionalBytesCount: additionalBytesCount,
61
60
  rawBytesCount: rawBytesCount
62
61
  });
63
62
  deflate = new Deflate();
@@ -81,6 +80,8 @@ function workerCodeFn() {
81
80
  try {
82
81
  return fn.apply(this, arguments);
83
82
  } catch (e) {
83
+ console.error('===monitor', e);
84
+
84
85
  try {
85
86
  self.postMessage({
86
87
  type: 'errored',
@@ -92,6 +92,7 @@ function doStartDeflateWorker(createDeflateWorkerImpl) {
92
92
  });
93
93
  return worker;
94
94
  } catch (error) {
95
+ console.errror('====doStartDeflateWorker', error);
95
96
  onError(error);
96
97
  }
97
98
  }
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '3.0.0',
2
+ sdkVersion: '3.0.1',
3
3
  sdkName: 'df_web_rum_sdk'
4
4
  };
@@ -1,4 +1,4 @@
1
- import { noop, getChildNodes, isNodeShadowHost, getParentNode } from '@cloudcare/browser-core';
1
+ import { noop, getChildNodes, isNodeShadowHost, getParentNode, isNullUndefinedDefaultValue } from '@cloudcare/browser-core';
2
2
  import { getMutationObserverConstructor } from '../../domMutationCollection';
3
3
  import { NodePrivacyLevel } from '../../../constants';
4
4
  import { getNodePrivacyLevel, getTextContent } from './privacy';
@@ -63,13 +63,19 @@ function processMutations(mutations, mutationCallback, configuration, shadowRoot
63
63
  }), configuration, shadowRootsController);
64
64
 
65
65
  var adds = _processChildListMutations.adds;
66
- var removes = _processChildListMutations.removes;
67
- var hasBeenSerialized = _processChildListMutations.hasBeenSerialized;
66
+ var removes = _processChildListMutations.removes; // var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
67
+
68
+ var serializedNodeIds = _processChildListMutations.serializedNodeIds;
69
+
70
+ function hasBeenSerialized(node) {
71
+ return hasSerializedNode(node) && serializedNodeIds.has(getSerializedNodeId(node));
72
+ }
73
+
68
74
  var texts = processCharacterDataMutations(filteredMutations.filter(function (mutation) {
69
75
  return mutation.type === 'characterData' && !hasBeenSerialized(mutation.target);
70
76
  }), configuration);
71
77
  var attributes = processAttributesMutations(filteredMutations.filter(function (mutation) {
72
- mutation.type === 'attributes' && !hasBeenSerialized(mutation.target);
78
+ return mutation.type === 'attributes' && !hasBeenSerialized(mutation.target);
73
79
  }), configuration);
74
80
 
75
81
  if (!texts.length && !attributes.length && !removes.length && !adds.length) {
@@ -175,6 +181,7 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
175
181
  return {
176
182
  adds: addedNodeMutations,
177
183
  removes: removedNodeMutations,
184
+ serializedNodeIds: serializedNodeIds,
178
185
  hasBeenSerialized: hasBeenSerialized
179
186
  };
180
187
 
@@ -211,8 +218,6 @@ function processCharacterDataMutations(mutations, configuration) {
211
218
  }); // Emit mutations
212
219
 
213
220
  for (var mutation of filteredMutations) {
214
- var _getTextContent;
215
-
216
221
  var value = mutation.target.textContent;
217
222
 
218
223
  if (value === mutation.oldValue) {
@@ -228,7 +233,7 @@ function processCharacterDataMutations(mutations, configuration) {
228
233
  textMutations.push({
229
234
  id: getSerializedNodeId(mutation.target),
230
235
  // TODO: pass a valid "ignoreWhiteSpace" argument
231
- value: (_getTextContent = getTextContent(mutation.target, false, parentNodePrivacyLevel)) !== null && _getTextContent !== void 0 ? _getTextContent : null
236
+ value: isNullUndefinedDefaultValue(getTextContent(mutation.target, false, parentNodePrivacyLevel, null))
232
237
  });
233
238
  }
234
239
 
@@ -242,7 +247,7 @@ function processAttributesMutations(mutations, configuration) {
242
247
  var filteredMutations = mutations.filter(function (mutation) {
243
248
  var handledAttributes = handledElements.get(mutation.target);
244
249
 
245
- if (handledAttributes !== null && handledAttributes !== void 0 && handledAttributes.has(mutation.attributeName)) {
250
+ if (handledAttributes && handledAttributes.has(mutation.attributeName)) {
246
251
  return false;
247
252
  }
248
253
 
@@ -162,8 +162,8 @@ function tryToComputeCoordinates(event) {
162
162
  }
163
163
 
164
164
  return {
165
- x,
166
- y
165
+ x: x,
166
+ y: y
167
167
  };
168
168
  }
169
169
 
@@ -431,19 +431,16 @@ function initVisualViewportResizeObserver(cb) {
431
431
 
432
432
  export function initFrustrationObserver(lifeCycle, frustrationCb) {
433
433
  return lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
434
- var _data$rawRumEvent$act, _data$rawRumEvent$act2, _data$domainContext$e;
435
-
436
- if (data.rawRumEvent.type === RumEventType.ACTION && data.rawRumEvent.action.type === ActionType.CLICK && (_data$rawRumEvent$act = data.rawRumEvent.action.frustration) !== null && _data$rawRumEvent$act !== void 0 && (_data$rawRumEvent$act2 = _data$rawRumEvent$act.type) !== null && _data$rawRumEvent$act2 !== void 0 && _data$rawRumEvent$act2.length && 'events' in data.domainContext && (_data$domainContext$e = data.domainContext.events) !== null && _data$domainContext$e !== void 0 && _data$domainContext$e.length) {
437
- frustrationCb({
438
- timestamp: data.rawRumEvent.date,
439
- type: RecordType.FrustrationRecord,
440
- data: {
441
- frustrationTypes: data.rawRumEvent.action.frustration.type,
442
- recordIds: data.domainContext.events.map(function (e) {
443
- return getRecordIdForEvent(e);
444
- })
445
- }
446
- });
434
+ if (data.rawRumEvent.type === RumEventType.ACTION && data.rawRumEvent.action.type === ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {// frustrationCb({
435
+ // timestamp: data.rawRumEvent.date,
436
+ // type: RecordType.FrustrationRecord,
437
+ // data: {
438
+ // frustrationTypes: data.rawRumEvent.action.frustration.type,
439
+ // recordIds: data.domainContext.events.map(function (e) {
440
+ // return getRecordIdForEvent(e)
441
+ // })
442
+ // }
443
+ // })
447
444
  }
448
445
  }).unsubscribe;
449
446
  }
@@ -10,14 +10,14 @@ export function createDeflateWorker() {
10
10
 
11
11
  function workerCodeFn() {
12
12
  monitor(function () {
13
- var {
14
- Deflate,
15
- constants,
16
- string2buf
17
- } = makePakoDeflate();
13
+ var _makePakoDeflate = makePakoDeflate();
14
+
15
+ var Deflate = _makePakoDeflate.Deflate;
16
+ var constants = _makePakoDeflate.constants;
17
+ var string2buf = _makePakoDeflate.string2buf;
18
18
  var deflate = new Deflate();
19
19
  var rawBytesCount = 0;
20
- self.addEventListener('message', monitor(event => {
20
+ self.addEventListener('message', monitor(function (event) {
21
21
  var data = event.data;
22
22
 
23
23
  switch (data.action) {
@@ -33,7 +33,9 @@ function workerCodeFn() {
33
33
  self.postMessage({
34
34
  type: 'wrote',
35
35
  id: data.id,
36
- compressedBytesCount: deflate.chunks.reduce((total, chunk) => total + chunk.length, 0),
36
+ compressedBytesCount: deflate.chunks.reduce(function (total, chunk) {
37
+ return total + chunk.length;
38
+ }, 0),
37
39
  additionalBytesCount
38
40
  });
39
41
  break;
@@ -41,14 +43,13 @@ function workerCodeFn() {
41
43
 
42
44
  case 'flush':
43
45
  {
44
- var _additionalBytesCount = data.data ? pushData(data.data) : 0;
45
-
46
+ var additionalBytesCount = data.data ? pushData(data.data) : 0;
46
47
  deflate.push('', constants.Z_FINISH);
47
48
  self.postMessage({
48
49
  type: 'flushed',
49
50
  id: data.id,
50
51
  result: deflate.result,
51
- additionalBytesCount: _additionalBytesCount,
52
+ additionalBytesCount,
52
53
  rawBytesCount
53
54
  });
54
55
  deflate = new Deflate();
@@ -72,6 +73,8 @@ function workerCodeFn() {
72
73
  try {
73
74
  return fn.apply(this, arguments);
74
75
  } catch (e) {
76
+ console.error('===monitor', e);
77
+
75
78
  try {
76
79
  self.postMessage({
77
80
  type: 'errored',
@@ -79,6 +79,7 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
79
79
  });
80
80
  return worker;
81
81
  } catch (error) {
82
+ console.errror('====doStartDeflateWorker', error);
82
83
  onError(error);
83
84
  }
84
85
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "2.0.0"
7
+ "@cloudcare/browser-core": "2.0.1"
8
8
  },
9
9
  "scripts": {
10
10
  "dev": "webpack serve --open --mode=development",
@@ -29,5 +29,5 @@
29
29
  "license": "MIT",
30
30
  "homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
31
31
  "description": "DataFlux RUM Web 端数据指标监控",
32
- "gitHead": "bc7a044056367a5f9a0bc941462cb4e1d4d1d925"
32
+ "gitHead": "4c9417de87768497d73bb0ce422e76c982ed69b7"
33
33
  }
@@ -2,7 +2,8 @@ import {
2
2
  noop,
3
3
  getChildNodes,
4
4
  isNodeShadowHost,
5
- getParentNode
5
+ getParentNode,
6
+ isNullUndefinedDefaultValue
6
7
  } from '@cloudcare/browser-core'
7
8
  import { getMutationObserverConstructor } from '../../domMutationCollection'
8
9
  import { NodePrivacyLevel } from '../../../constants'
@@ -109,7 +110,14 @@ function processMutations(
109
110
  )
110
111
  var adds = _processChildListMutations.adds
111
112
  var removes = _processChildListMutations.removes
112
- var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
113
+ // var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
114
+ var serializedNodeIds = _processChildListMutations.serializedNodeIds
115
+ function hasBeenSerialized(node) {
116
+ return (
117
+ hasSerializedNode(node) &&
118
+ serializedNodeIds.has(getSerializedNodeId(node))
119
+ )
120
+ }
113
121
  var texts = processCharacterDataMutations(
114
122
  filteredMutations.filter(function (mutation) {
115
123
  return (
@@ -121,15 +129,15 @@ function processMutations(
121
129
 
122
130
  var attributes = processAttributesMutations(
123
131
  filteredMutations.filter(function (mutation) {
124
- mutation.type === 'attributes' && !hasBeenSerialized(mutation.target)
132
+ return (
133
+ mutation.type === 'attributes' && !hasBeenSerialized(mutation.target)
134
+ )
125
135
  }),
126
136
  configuration
127
137
  )
128
-
129
138
  if (!texts.length && !attributes.length && !removes.length && !adds.length) {
130
139
  return
131
140
  }
132
-
133
141
  mutationCallback({
134
142
  adds: adds,
135
143
  removes: removes,
@@ -236,6 +244,7 @@ function processChildListMutations(
236
244
  return {
237
245
  adds: addedNodeMutations,
238
246
  removes: removedNodeMutations,
247
+ serializedNodeIds: serializedNodeIds,
239
248
  hasBeenSerialized: hasBeenSerialized
240
249
  }
241
250
 
@@ -293,8 +302,9 @@ function processCharacterDataMutations(mutations, configuration) {
293
302
  textMutations.push({
294
303
  id: getSerializedNodeId(mutation.target),
295
304
  // TODO: pass a valid "ignoreWhiteSpace" argument
296
- value:
297
- getTextContent(mutation.target, false, parentNodePrivacyLevel) ?? null
305
+ value: isNullUndefinedDefaultValue(
306
+ getTextContent(mutation.target, false, parentNodePrivacyLevel, null)
307
+ )
298
308
  })
299
309
  }
300
310
 
@@ -308,7 +318,7 @@ function processAttributesMutations(mutations, configuration) {
308
318
  var handledElements = new Map()
309
319
  var filteredMutations = mutations.filter(function (mutation) {
310
320
  var handledAttributes = handledElements.get(mutation.target)
311
- if (handledAttributes?.has(mutation.attributeName)) {
321
+ if (handledAttributes && handledAttributes.has(mutation.attributeName)) {
312
322
  return false
313
323
  }
314
324
  if (!handledAttributes) {
@@ -236,7 +236,7 @@ function tryToComputeCoordinates(event) {
236
236
  if (!Number.isFinite(x) || !Number.isFinite(y)) {
237
237
  return undefined
238
238
  }
239
- return { x, y }
239
+ return { x: x, y: y }
240
240
  }
241
241
 
242
242
  function initScrollObserver(cb, defaultPrivacyLevel, elementsScrollPositions) {
@@ -535,20 +535,23 @@ export function initFrustrationObserver(lifeCycle, frustrationCb) {
535
535
  if (
536
536
  data.rawRumEvent.type === RumEventType.ACTION &&
537
537
  data.rawRumEvent.action.type === ActionType.CLICK &&
538
- data.rawRumEvent.action.frustration?.type?.length &&
538
+ data.rawRumEvent.action.frustration &&
539
+ data.rawRumEvent.action.frustration.type &&
540
+ data.rawRumEvent.action.frustration.type.length &&
539
541
  'events' in data.domainContext &&
540
- data.domainContext.events?.length
542
+ data.domainContext.events &&
543
+ data.domainContext.events.length
541
544
  ) {
542
- frustrationCb({
543
- timestamp: data.rawRumEvent.date,
544
- type: RecordType.FrustrationRecord,
545
- data: {
546
- frustrationTypes: data.rawRumEvent.action.frustration.type,
547
- recordIds: data.domainContext.events.map(function (e) {
548
- return getRecordIdForEvent(e)
549
- })
550
- }
551
- })
545
+ // frustrationCb({
546
+ // timestamp: data.rawRumEvent.date,
547
+ // type: RecordType.FrustrationRecord,
548
+ // data: {
549
+ // frustrationTypes: data.rawRumEvent.action.frustration.type,
550
+ // recordIds: data.domainContext.events.map(function (e) {
551
+ // return getRecordIdForEvent(e)
552
+ // })
553
+ // }
554
+ // })
552
555
  }
553
556
  }
554
557
  ).unsubscribe
@@ -343,7 +343,6 @@ function getCssRulesString(s) {
343
343
  var styleSheetCssText = Array.from(rules, getCssRuleString).join('')
344
344
  return switchToAbsoluteUrl(styleSheetCssText, s.href)
345
345
  }
346
-
347
346
  return null
348
347
  } catch (error) {
349
348
  return null
@@ -416,6 +415,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
416
415
  return s.href === element.href
417
416
  })
418
417
  var cssText = getCssRulesString(stylesheet)
418
+
419
419
  if (cssText && stylesheet) {
420
420
  safeAttrs._cssText = cssText
421
421
  }
@@ -465,8 +465,8 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
465
465
  /**
466
466
  * Serialize the scroll state for each element only for full snapshot
467
467
  */
468
- let scrollTop
469
- let scrollLeft
468
+ var scrollTop
469
+ var scrollLeft
470
470
  var serializationContext = options.serializationContext
471
471
  switch (serializationContext.status) {
472
472
  case SerializationContextStatus.INITIAL_FULL_SNAPSHOT:
@@ -10,14 +10,17 @@ export function createDeflateWorker() {
10
10
 
11
11
  function workerCodeFn() {
12
12
  monitor(function () {
13
- const { Deflate, constants, string2buf } = makePakoDeflate()
13
+ var _makePakoDeflate = makePakoDeflate()
14
+ var Deflate = _makePakoDeflate.Deflate
15
+ var constants = _makePakoDeflate.constants
16
+ var string2buf = _makePakoDeflate.string2buf
14
17
 
15
- let deflate = new Deflate()
16
- let rawBytesCount = 0
18
+ var deflate = new Deflate()
19
+ var rawBytesCount = 0
17
20
  self.addEventListener(
18
21
  'message',
19
- monitor((event) => {
20
- const data = event.data
22
+ monitor(function (event) {
23
+ var data = event.data
21
24
  switch (data.action) {
22
25
  case 'init':
23
26
  self.postMessage({
@@ -25,20 +28,23 @@ function workerCodeFn() {
25
28
  })
26
29
  break
27
30
  case 'write': {
28
- const additionalBytesCount = pushData(data.data)
31
+ var additionalBytesCount = pushData(data.data)
29
32
  self.postMessage({
30
33
  type: 'wrote',
31
34
  id: data.id,
32
- compressedBytesCount: deflate.chunks.reduce(
33
- (total, chunk) => total + chunk.length,
34
- 0
35
- ),
35
+ compressedBytesCount: deflate.chunks.reduce(function (
36
+ total,
37
+ chunk
38
+ ) {
39
+ return total + chunk.length
40
+ },
41
+ 0),
36
42
  additionalBytesCount
37
43
  })
38
44
  break
39
45
  }
40
46
  case 'flush': {
41
- const additionalBytesCount = data.data ? pushData(data.data) : 0
47
+ var additionalBytesCount = data.data ? pushData(data.data) : 0
42
48
  deflate.push('', constants.Z_FINISH)
43
49
  self.postMessage({
44
50
  type: 'flushed',
@@ -57,7 +63,7 @@ function workerCodeFn() {
57
63
 
58
64
  function pushData(data) {
59
65
  // TextEncoder is not supported on old browser version like Edge 18, therefore we use string2buf
60
- const binaryData = string2buf(data)
66
+ var binaryData = string2buf(data)
61
67
  deflate.push(binaryData, constants.Z_SYNC_FLUSH)
62
68
  rawBytesCount += binaryData.length
63
69
  return binaryData.length
@@ -69,6 +75,7 @@ function workerCodeFn() {
69
75
  try {
70
76
  return fn.apply(this, arguments)
71
77
  } catch (e) {
78
+ console.error('===monitor', e)
72
79
  try {
73
80
  self.postMessage({
74
81
  type: 'errored',
@@ -35,7 +35,6 @@ export function Segment(
35
35
  if (data.type === 'errored' || data.type === 'initialized') {
36
36
  return
37
37
  }
38
-
39
38
  if (data.id === _this.id) {
40
39
  replayStats.addWroteData(viewId, data.additionalBytesCount)
41
40
  if (data.type === 'flushed') {
@@ -67,6 +67,7 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
67
67
  worker.postMessage({ action: 'init' })
68
68
  return worker
69
69
  } catch (error) {
70
+ console.errror('====doStartDeflateWorker', error)
70
71
  onError(error)
71
72
  }
72
73
  }