@posthog/rrweb 0.0.27 → 0.0.29

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.
@@ -12192,6 +12192,11 @@ class MutationBuffer {
12192
12192
  this.shadowDomManager.reset();
12193
12193
  this.canvasManager.reset();
12194
12194
  }
12195
+ destroy() {
12196
+ while (this.mapRemoves.length) {
12197
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
12198
+ }
12199
+ }
12195
12200
  }
12196
12201
  function deepDelete(addsSet, n2) {
12197
12202
  addsSet.delete(n2);
@@ -13236,6 +13241,7 @@ function initObservers(o2, hooks = {}) {
13236
13241
  );
13237
13242
  }
13238
13243
  return callbackWrapper(() => {
13244
+ mutationBuffers.forEach((b) => b.destroy());
13239
13245
  mutationBuffers.forEach((b) => b.reset());
13240
13246
  mutationObserver == null ? void 0 : mutationObserver.disconnect();
13241
13247
  mousemoveHandler();
@@ -13573,6 +13579,8 @@ class IframeManager {
13573
13579
  contentWindow.removeEventListener("message", handler);
13574
13580
  });
13575
13581
  this.nestedIframeListeners.clear();
13582
+ this.crossOriginIframeMirror.reset();
13583
+ this.crossOriginIframeStyleMirror.reset();
13576
13584
  }
13577
13585
  }
13578
13586
  class ShadowDomManager {
@@ -13739,9 +13747,9 @@ const saveWebGLVar = (value, win, ctx) => {
13739
13747
  }
13740
13748
  return index2;
13741
13749
  };
13742
- function serializeArg(value, win, ctx) {
13750
+ function serializeArg(value, win, ctx, dataURLOptions) {
13743
13751
  if (value instanceof Array) {
13744
- return value.map((arg) => serializeArg(arg, win, ctx));
13752
+ return value.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
13745
13753
  } else if (value === null) {
13746
13754
  return value;
13747
13755
  } else if (value instanceof Float32Array || value instanceof Float64Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Int16Array || value instanceof Int8Array || value instanceof Uint8ClampedArray) {
@@ -13767,7 +13775,7 @@ function serializeArg(value, win, ctx) {
13767
13775
  return {
13768
13776
  rr_type: name,
13769
13777
  args: [
13770
- serializeArg(value.buffer, win, ctx),
13778
+ serializeArg(value.buffer, win, ctx, dataURLOptions),
13771
13779
  value.byteOffset,
13772
13780
  value.byteLength
13773
13781
  ]
@@ -13781,7 +13789,7 @@ function serializeArg(value, win, ctx) {
13781
13789
  };
13782
13790
  } else if (value instanceof HTMLCanvasElement) {
13783
13791
  const name = "HTMLImageElement";
13784
- const src = value.toDataURL();
13792
+ const src = value.toDataURL(dataURLOptions.type, dataURLOptions.quality);
13785
13793
  return {
13786
13794
  rr_type: name,
13787
13795
  src
@@ -13790,7 +13798,11 @@ function serializeArg(value, win, ctx) {
13790
13798
  const name = value.constructor.name;
13791
13799
  return {
13792
13800
  rr_type: name,
13793
- args: [serializeArg(value.data, win, ctx), value.width, value.height]
13801
+ args: [
13802
+ serializeArg(value.data, win, ctx, dataURLOptions),
13803
+ value.width,
13804
+ value.height
13805
+ ]
13794
13806
  };
13795
13807
  } else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
13796
13808
  const name = value.constructor.name;
@@ -13802,8 +13814,8 @@ function serializeArg(value, win, ctx) {
13802
13814
  }
13803
13815
  return value;
13804
13816
  }
13805
- const serializeArgs = (args, win, ctx) => {
13806
- return args.map((arg) => serializeArg(arg, win, ctx));
13817
+ const serializeArgs = (args, win, ctx, dataURLOptions) => {
13818
+ return args.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
13807
13819
  };
13808
13820
  const isInstanceOfWebGLObject = (value, win) => {
13809
13821
  const webGLConstructorNames = [
@@ -13829,7 +13841,7 @@ const isInstanceOfWebGLObject = (value, win) => {
13829
13841
  )
13830
13842
  );
13831
13843
  };
13832
- function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
13844
+ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
13833
13845
  const handlers = [];
13834
13846
  const props2D = Object.getOwnPropertyNames(
13835
13847
  win.CanvasRenderingContext2D.prototype
@@ -13846,7 +13858,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
13846
13858
  return function(...args) {
13847
13859
  if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
13848
13860
  setTimeout(() => {
13849
- const recordArgs = serializeArgs(args, win, this);
13861
+ const recordArgs = serializeArgs(
13862
+ args,
13863
+ win,
13864
+ this,
13865
+ dataURLOptions
13866
+ );
13850
13867
  cb(this.canvas, {
13851
13868
  type: CanvasContext["2D"],
13852
13869
  property: prop,
@@ -13920,7 +13937,7 @@ function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDr
13920
13937
  handlers.forEach((h) => h());
13921
13938
  };
13922
13939
  }
13923
- function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13940
+ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, dataURLOptions) {
13924
13941
  const handlers = [];
13925
13942
  const props = Object.getOwnPropertyNames(prototype);
13926
13943
  for (const prop of props) {
@@ -13947,7 +13964,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13947
13964
  const result2 = original.apply(this, args);
13948
13965
  saveWebGLVar(result2, win, this);
13949
13966
  if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
13950
- const recordArgs = serializeArgs(args, win, this);
13967
+ const recordArgs = serializeArgs(args, win, this, dataURLOptions);
13951
13968
  const mutation = {
13952
13969
  type,
13953
13970
  property: prop,
@@ -13976,7 +13993,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13976
13993
  }
13977
13994
  return handlers;
13978
13995
  }
13979
- function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13996
+ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
13980
13997
  const handlers = [];
13981
13998
  handlers.push(
13982
13999
  ...patchGLPrototype(
@@ -13985,7 +14002,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13985
14002
  cb,
13986
14003
  blockClass,
13987
14004
  blockSelector,
13988
- win
14005
+ win,
14006
+ dataURLOptions
13989
14007
  )
13990
14008
  );
13991
14009
  if (typeof win.WebGL2RenderingContext !== "undefined") {
@@ -13996,7 +14014,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13996
14014
  cb,
13997
14015
  blockClass,
13998
14016
  blockSelector,
13999
- win
14017
+ win,
14018
+ dataURLOptions
14000
14019
  )
14001
14020
  );
14002
14021
  }
@@ -14038,6 +14057,8 @@ class CanvasManager {
14038
14057
  __publicField(this, "resetObservers");
14039
14058
  __publicField(this, "frozen", false);
14040
14059
  __publicField(this, "locked", false);
14060
+ __publicField(this, "rafIdTimestamp", null);
14061
+ __publicField(this, "rafIdFlush", null);
14041
14062
  __publicField(this, "processMutation", (target, mutation) => {
14042
14063
  const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
14043
14064
  if (newFrame || !this.rafStamps.invokeId)
@@ -14058,7 +14079,12 @@ class CanvasManager {
14058
14079
  this.mutationCb = options.mutationCb;
14059
14080
  this.mirror = options.mirror;
14060
14081
  if (recordCanvas && sampling === "all")
14061
- this.initCanvasMutationObserver(win, blockClass, blockSelector);
14082
+ this.initCanvasMutationObserver(
14083
+ win,
14084
+ blockClass,
14085
+ blockSelector,
14086
+ dataURLOptions
14087
+ );
14062
14088
  if (recordCanvas && typeof sampling === "number")
14063
14089
  this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
14064
14090
  dataURLOptions
@@ -14067,6 +14093,14 @@ class CanvasManager {
14067
14093
  reset() {
14068
14094
  this.pendingCanvasMutations.clear();
14069
14095
  this.resetObservers && this.resetObservers();
14096
+ if (this.rafIdTimestamp !== null) {
14097
+ cancelAnimationFrame(this.rafIdTimestamp);
14098
+ this.rafIdTimestamp = null;
14099
+ }
14100
+ if (this.rafIdFlush !== null) {
14101
+ cancelAnimationFrame(this.rafIdFlush);
14102
+ this.rafIdFlush = null;
14103
+ }
14070
14104
  }
14071
14105
  freeze() {
14072
14106
  this.frozen = true;
@@ -14187,7 +14221,7 @@ class CanvasManager {
14187
14221
  cancelAnimationFrame(rafId);
14188
14222
  };
14189
14223
  }
14190
- initCanvasMutationObserver(win, blockClass, blockSelector) {
14224
+ initCanvasMutationObserver(win, blockClass, blockSelector, dataURLOptions) {
14191
14225
  this.startRAFTimestamping();
14192
14226
  this.startPendingCanvasMutationFlusher();
14193
14227
  const canvasContextReset = initCanvasContextObserver(
@@ -14200,13 +14234,15 @@ class CanvasManager {
14200
14234
  this.processMutation.bind(this),
14201
14235
  win,
14202
14236
  blockClass,
14203
- blockSelector
14237
+ blockSelector,
14238
+ dataURLOptions
14204
14239
  );
14205
14240
  const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(
14206
14241
  this.processMutation.bind(this),
14207
14242
  win,
14208
14243
  blockClass,
14209
- blockSelector
14244
+ blockSelector,
14245
+ dataURLOptions
14210
14246
  );
14211
14247
  this.resetObservers = () => {
14212
14248
  canvasContextReset();
@@ -14215,14 +14251,16 @@ class CanvasManager {
14215
14251
  };
14216
14252
  }
14217
14253
  startPendingCanvasMutationFlusher() {
14218
- requestAnimationFrame(() => this.flushPendingCanvasMutations());
14254
+ this.rafIdFlush = requestAnimationFrame(
14255
+ () => this.flushPendingCanvasMutations()
14256
+ );
14219
14257
  }
14220
14258
  startRAFTimestamping() {
14221
14259
  const setLatestRAFTimestamp = (timestamp) => {
14222
14260
  this.rafStamps.latestId = timestamp;
14223
- requestAnimationFrame(setLatestRAFTimestamp);
14261
+ this.rafIdTimestamp = requestAnimationFrame(setLatestRAFTimestamp);
14224
14262
  };
14225
- requestAnimationFrame(setLatestRAFTimestamp);
14263
+ this.rafIdTimestamp = requestAnimationFrame(setLatestRAFTimestamp);
14226
14264
  }
14227
14265
  flushPendingCanvasMutations() {
14228
14266
  this.pendingCanvasMutations.forEach(
@@ -14231,7 +14269,9 @@ class CanvasManager {
14231
14269
  this.flushPendingCanvasMutationFor(canvas, id);
14232
14270
  }
14233
14271
  );
14234
- requestAnimationFrame(() => this.flushPendingCanvasMutations());
14272
+ this.rafIdFlush = requestAnimationFrame(
14273
+ () => this.flushPendingCanvasMutations()
14274
+ );
14235
14275
  }
14236
14276
  flushPendingCanvasMutationFor(canvas, id) {
14237
14277
  if (this.frozen || this.locked) {
@@ -14797,6 +14837,7 @@ function record(options = {}) {
14797
14837
  processedNodeManager.destroy();
14798
14838
  iframeManager.removeLoadListener();
14799
14839
  iframeManager.destroy();
14840
+ mirror.reset();
14800
14841
  recording = false;
14801
14842
  unregisterErrorHandler();
14802
14843
  };