@glimt/record 0.0.56 → 0.0.58

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.
package/dist/record.cjs CHANGED
@@ -430,6 +430,9 @@ const index = {
430
430
  const shouldTryAnonymousFetchingOnCorsError$1 = () => {
431
431
  return !("_rrweb_skip_re_fetching_to_suppress_cors_errors" in window && window._rrweb_skip_re_fetching_to_suppress_cors_errors === true);
432
432
  };
433
+ const isDebug$1 = () => {
434
+ return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
435
+ };
433
436
  function isElement(n2) {
434
437
  return n2.nodeType === n2.ELEMENT_NODE;
435
438
  }
@@ -815,7 +818,7 @@ function markCssSplits(cssText, style) {
815
818
  return splitCssText(cssText, style).join("/* rr_split */");
816
819
  }
817
820
  const CLEANUP_DEBOUNCE_TIME$1 = 1e3 * 30;
818
- const DATA_ATTRIBUTE_CLONED_NAME$1 = "data-rrweb-link-cloned";
821
+ const DATA_ATTRIBUTE_CLONED_NAME$1 = "data-recapt-rrweb-link-cloned";
819
822
  const DISALLOWED_EXTENSIONS$1 = [
820
823
  // Fonts
821
824
  "woff",
@@ -1535,9 +1538,10 @@ function serializeElementNode(n2, options) {
1535
1538
  return;
1536
1539
  }
1537
1540
  } else {
1538
- console.warn(
1539
- `Cannot inline img src=${imageSrc}! Error: ${err}`
1540
- );
1541
+ if (isDebug$1())
1542
+ console.warn(
1543
+ `Cannot inline img src=${imageSrc}! Error: ${err}`
1544
+ );
1541
1545
  }
1542
1546
  }
1543
1547
  inlineImageCleanup();
@@ -1693,7 +1697,7 @@ function serializeNodeWithId(n2, options) {
1693
1697
  cssCaptured
1694
1698
  });
1695
1699
  if (!_serializedNode) {
1696
- console.warn(n2, "not serialized");
1700
+ if (isDebug$1()) console.warn(n2, "not serialized");
1697
1701
  return null;
1698
1702
  }
1699
1703
  let id;
@@ -5720,7 +5724,7 @@ function absolutifyURLs(cssText, href) {
5720
5724
  );
5721
5725
  }
5722
5726
  const CLEANUP_DEBOUNCE_TIME = 1e3 * 30;
5723
- const DATA_ATTRIBUTE_CLONED_NAME = "data-rrweb-link-cloned";
5727
+ const DATA_ATTRIBUTE_CLONED_NAME = "data-recapt-rrweb-link-cloned";
5724
5728
  const DISALLOWED_EXTENSIONS = [
5725
5729
  // Fonts
5726
5730
  "woff",
@@ -10147,6 +10151,13 @@ class IframeManager {
10147
10151
  }
10148
10152
  }
10149
10153
  }
10154
+ const isDebug = () => {
10155
+ return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
10156
+ };
10157
+ const debugLog = (...args) => {
10158
+ if (!isDebug()) return;
10159
+ console.log("[recapt:rrweb]", ...args);
10160
+ };
10150
10161
  const _StormSnapshotManager = class _StormSnapshotManager2 {
10151
10162
  constructor() {
10152
10163
  __publicField(this, "lastFullSnapshot", -1);
@@ -10182,10 +10193,10 @@ const _StormSnapshotManager = class _StormSnapshotManager2 {
10182
10193
  }
10183
10194
  takeSnapshot() {
10184
10195
  if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
10185
- console.log("StormSnapshotManager, takeSnapshot: too soon");
10196
+ debugLog("StormSnapshotManager, takeSnapshot: too soon");
10186
10197
  return;
10187
10198
  }
10188
- console.log("StormSnapshotManager, takeSnapshot: taking full snapshot");
10199
+ debugLog("StormSnapshotManager, takeSnapshot: taking full snapshot");
10189
10200
  takeFullSnapshot();
10190
10201
  this.lastFullSnapshot = Date.now();
10191
10202
  }
@@ -10274,6 +10285,14 @@ class DoubleLinkedList {
10274
10285
  }
10275
10286
  }
10276
10287
  const moveKey = (id, parentId) => `${id}@${parentId}`;
10288
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10289
+ function makeid(length = 8) {
10290
+ let result2 = "";
10291
+ for (let i2 = 0; i2 < length; i2++) {
10292
+ result2 += characters.charAt(Math.floor(Math.random() * characters.length));
10293
+ }
10294
+ return result2;
10295
+ }
10277
10296
  class MutationBuffer {
10278
10297
  constructor() {
10279
10298
  __publicField(this, "frozen", false);
@@ -10310,6 +10329,7 @@ class MutationBuffer {
10310
10329
  __publicField(this, "canvasManager");
10311
10330
  __publicField(this, "processedNodeManager");
10312
10331
  __publicField(this, "unattachedDoc");
10332
+ __publicField(this, "bufId", isDebug() ? makeid() : "");
10313
10333
  __publicField(this, "stormBatches", []);
10314
10334
  __publicField(this, "stormInfo", null);
10315
10335
  __publicField(this, "stormSettings", {
@@ -10323,6 +10343,11 @@ class MutationBuffer {
10323
10343
  __publicField(this, "handleStormMutations", (muts) => {
10324
10344
  const time = Date.now();
10325
10345
  if (this.stormInfo == null) {
10346
+ debugLog(
10347
+ "detected probable mutation storm start",
10348
+ "buffer id:",
10349
+ this.bufId
10350
+ );
10326
10351
  this.stormInfo = {
10327
10352
  startedAt: time,
10328
10353
  totalMutations: 0,
@@ -10353,6 +10378,18 @@ class MutationBuffer {
10353
10378
  __publicField(this, "handleStormFinish", () => {
10354
10379
  if (!this.stormInfo) return;
10355
10380
  const { stormExceededLimit } = this.stormInfo;
10381
+ debugLog(
10382
+ "mutation storm finished",
10383
+ "totalMutations:",
10384
+ this.stormInfo.totalMutations,
10385
+ "stormExceededLimit:",
10386
+ stormExceededLimit,
10387
+ "storm duration:",
10388
+ Date.now() - this.stormInfo.startedAt,
10389
+ "ms",
10390
+ "buffer id:",
10391
+ this.bufId
10392
+ );
10356
10393
  clearTimeout(this.stormInfo.timeout);
10357
10394
  this.stormInfo = null;
10358
10395
  if (!stormExceededLimit) {
@@ -10840,7 +10877,6 @@ class MutationBuffer {
10840
10877
  }
10841
10878
  });
10842
10879
  }
10843
- // private bufId: string = makeid();
10844
10880
  init(options) {
10845
10881
  [
10846
10882
  "mutationCb",
@@ -12687,7 +12723,7 @@ try {
12687
12723
  document.body.removeChild(cleanFrame);
12688
12724
  }
12689
12725
  } catch (err) {
12690
- console.debug("Unable to override Array.from", err);
12726
+ if (isDebug()) console.debug("Unable to override Array.from", err);
12691
12727
  }
12692
12728
  const mirror = createMirror$2();
12693
12729
  function record(options = {}) {
@@ -12966,7 +13002,8 @@ function record(options = {}) {
12966
13002
  keepIframeSrcFn
12967
13003
  });
12968
13004
  if (!node2) {
12969
- return console.warn("Failed to snapshot the document");
13005
+ if (isDebug()) console.warn("Failed to snapshot the document");
13006
+ return;
12970
13007
  }
12971
13008
  wrappedEmit(
12972
13009
  {
@@ -13114,7 +13151,10 @@ function record(options = {}) {
13114
13151
  try {
13115
13152
  handlers.push(observe(iframeEl.contentDocument));
13116
13153
  } catch (error) {
13117
- console.warn(error);
13154
+ if (isDebug()) {
13155
+ console.warn("internal error");
13156
+ console.warn(error);
13157
+ }
13118
13158
  }
13119
13159
  });
13120
13160
  let initedAt = null;
@@ -13173,7 +13213,10 @@ function record(options = {}) {
13173
13213
  unregisterErrorHandler();
13174
13214
  };
13175
13215
  } catch (error) {
13176
- console.warn(error);
13216
+ if (isDebug()) {
13217
+ console.warn("internal error1");
13218
+ console.warn(error);
13219
+ }
13177
13220
  }
13178
13221
  }
13179
13222
  record.addCustomEvent = (tag, payload) => {