@glimt/record 0.0.56 → 0.0.57

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.
@@ -462,6 +462,9 @@ const index = {
462
462
  const shouldTryAnonymousFetchingOnCorsError$1 = () => {
463
463
  return !("_rrweb_skip_re_fetching_to_suppress_cors_errors" in window && window._rrweb_skip_re_fetching_to_suppress_cors_errors === true);
464
464
  };
465
+ const isDebug$1 = () => {
466
+ return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
467
+ };
465
468
  function isElement(n2) {
466
469
  return n2.nodeType === n2.ELEMENT_NODE;
467
470
  }
@@ -848,7 +851,7 @@ function markCssSplits(cssText, style) {
848
851
  return splitCssText(cssText, style).join("/* rr_split */");
849
852
  }
850
853
  const CLEANUP_DEBOUNCE_TIME$1 = 1e3 * 30;
851
- const DATA_ATTRIBUTE_CLONED_NAME$1 = "data-rrweb-link-cloned";
854
+ const DATA_ATTRIBUTE_CLONED_NAME$1 = "data-recapt-rrweb-link-cloned";
852
855
  const DISALLOWED_EXTENSIONS$1 = [
853
856
  // Fonts
854
857
  "woff",
@@ -1568,9 +1571,10 @@ function serializeElementNode(n2, options) {
1568
1571
  return;
1569
1572
  }
1570
1573
  } else {
1571
- console.warn(
1572
- `Cannot inline img src=${imageSrc}! Error: ${err}`
1573
- );
1574
+ if (isDebug$1())
1575
+ console.warn(
1576
+ `Cannot inline img src=${imageSrc}! Error: ${err}`
1577
+ );
1574
1578
  }
1575
1579
  }
1576
1580
  inlineImageCleanup();
@@ -1726,7 +1730,7 @@ function serializeNodeWithId(n2, options) {
1726
1730
  cssCaptured
1727
1731
  });
1728
1732
  if (!_serializedNode) {
1729
- console.warn(n2, "not serialized");
1733
+ if (isDebug$1()) console.warn(n2, "not serialized");
1730
1734
  return null;
1731
1735
  }
1732
1736
  let id;
@@ -5757,7 +5761,7 @@ function absolutifyURLs(cssText, href) {
5757
5761
  );
5758
5762
  }
5759
5763
  const CLEANUP_DEBOUNCE_TIME = 1e3 * 30;
5760
- const DATA_ATTRIBUTE_CLONED_NAME = "data-rrweb-link-cloned";
5764
+ const DATA_ATTRIBUTE_CLONED_NAME = "data-recapt-rrweb-link-cloned";
5761
5765
  const DISALLOWED_EXTENSIONS = [
5762
5766
  // Fonts
5763
5767
  "woff",
@@ -10189,6 +10193,13 @@ class IframeManager {
10189
10193
  }
10190
10194
  }
10191
10195
  }
10196
+ const isDebug = () => {
10197
+ return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
10198
+ };
10199
+ const debugLog = (...args) => {
10200
+ if (!isDebug()) return;
10201
+ console.log("[recapt:rrweb]", ...args);
10202
+ };
10192
10203
  const _StormSnapshotManager = class _StormSnapshotManager2 {
10193
10204
  constructor() {
10194
10205
  __publicField(this, "lastFullSnapshot", -1);
@@ -10224,10 +10235,10 @@ const _StormSnapshotManager = class _StormSnapshotManager2 {
10224
10235
  }
10225
10236
  takeSnapshot() {
10226
10237
  if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
10227
- console.log("StormSnapshotManager, takeSnapshot: too soon");
10238
+ debugLog("StormSnapshotManager, takeSnapshot: too soon");
10228
10239
  return;
10229
10240
  }
10230
- console.log("StormSnapshotManager, takeSnapshot: taking full snapshot");
10241
+ debugLog("StormSnapshotManager, takeSnapshot: taking full snapshot");
10231
10242
  takeFullSnapshot();
10232
10243
  this.lastFullSnapshot = Date.now();
10233
10244
  }
@@ -10316,6 +10327,14 @@ class DoubleLinkedList {
10316
10327
  }
10317
10328
  }
10318
10329
  const moveKey = (id, parentId) => `${id}@${parentId}`;
10330
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10331
+ function makeid(length = 8) {
10332
+ let result2 = "";
10333
+ for (let i2 = 0; i2 < length; i2++) {
10334
+ result2 += characters.charAt(Math.floor(Math.random() * characters.length));
10335
+ }
10336
+ return result2;
10337
+ }
10319
10338
  class MutationBuffer {
10320
10339
  constructor() {
10321
10340
  __publicField(this, "frozen", false);
@@ -10352,6 +10371,7 @@ class MutationBuffer {
10352
10371
  __publicField(this, "canvasManager");
10353
10372
  __publicField(this, "processedNodeManager");
10354
10373
  __publicField(this, "unattachedDoc");
10374
+ __publicField(this, "bufId", isDebug() ? makeid() : "");
10355
10375
  __publicField(this, "stormBatches", []);
10356
10376
  __publicField(this, "stormInfo", null);
10357
10377
  __publicField(this, "stormSettings", {
@@ -10365,6 +10385,11 @@ class MutationBuffer {
10365
10385
  __publicField(this, "handleStormMutations", (muts) => {
10366
10386
  const time = Date.now();
10367
10387
  if (this.stormInfo == null) {
10388
+ debugLog(
10389
+ "detected probable mutation storm start",
10390
+ "buffer id:",
10391
+ this.bufId
10392
+ );
10368
10393
  this.stormInfo = {
10369
10394
  startedAt: time,
10370
10395
  totalMutations: 0,
@@ -10395,6 +10420,18 @@ class MutationBuffer {
10395
10420
  __publicField(this, "handleStormFinish", () => {
10396
10421
  if (!this.stormInfo) return;
10397
10422
  const { stormExceededLimit } = this.stormInfo;
10423
+ debugLog(
10424
+ "mutation storm finished",
10425
+ "totalMutations:",
10426
+ this.stormInfo.totalMutations,
10427
+ "stormExceededLimit:",
10428
+ stormExceededLimit,
10429
+ "storm duration:",
10430
+ Date.now() - this.stormInfo.startedAt,
10431
+ "ms",
10432
+ "buffer id:",
10433
+ this.bufId
10434
+ );
10398
10435
  clearTimeout(this.stormInfo.timeout);
10399
10436
  this.stormInfo = null;
10400
10437
  if (!stormExceededLimit) {
@@ -10417,6 +10454,13 @@ class MutationBuffer {
10417
10454
  for (const mut of muts) {
10418
10455
  this.processMutation(mut);
10419
10456
  }
10457
+ debugLog(
10458
+ "processed mutations from storm",
10459
+ "overrideStorm:",
10460
+ overrideStorm,
10461
+ "buffer id:",
10462
+ this.bufId
10463
+ );
10420
10464
  this.emit();
10421
10465
  });
10422
10466
  __publicField(this, "processMutations", (mutations) => {
@@ -10882,7 +10926,6 @@ class MutationBuffer {
10882
10926
  }
10883
10927
  });
10884
10928
  }
10885
- // private bufId: string = makeid();
10886
10929
  init(options) {
10887
10930
  [
10888
10931
  "mutationCb",
@@ -12725,7 +12768,7 @@ try {
12725
12768
  document.body.removeChild(cleanFrame);
12726
12769
  }
12727
12770
  } catch (err) {
12728
- console.debug("Unable to override Array.from", err);
12771
+ if (isDebug()) console.debug("Unable to override Array.from", err);
12729
12772
  }
12730
12773
  const mirror = createMirror$2();
12731
12774
  function record(options = {}) {
@@ -13000,7 +13043,8 @@ function record(options = {}) {
13000
13043
  keepIframeSrcFn
13001
13044
  });
13002
13045
  if (!node2) {
13003
- return console.warn("Failed to snapshot the document");
13046
+ if (isDebug()) console.warn("Failed to snapshot the document");
13047
+ return;
13004
13048
  }
13005
13049
  wrappedEmit(
13006
13050
  {
@@ -13139,7 +13183,10 @@ function record(options = {}) {
13139
13183
  try {
13140
13184
  handlers.push(observe(iframeEl.contentDocument));
13141
13185
  } catch (error) {
13142
- console.warn(error);
13186
+ if (isDebug()) {
13187
+ console.warn("internal error");
13188
+ console.warn(error);
13189
+ }
13143
13190
  }
13144
13191
  });
13145
13192
  let initedAt = null;
@@ -13198,7 +13245,10 @@ function record(options = {}) {
13198
13245
  unregisterErrorHandler();
13199
13246
  };
13200
13247
  } catch (error) {
13201
- console.warn(error);
13248
+ if (isDebug()) {
13249
+ console.warn("internal error1");
13250
+ console.warn(error);
13251
+ }
13202
13252
  }
13203
13253
  }
13204
13254
  record.addCustomEvent = (tag, payload) => {