@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.
package/dist/rrweb.js CHANGED
@@ -12166,6 +12166,11 @@ class MutationBuffer {
12166
12166
  this.shadowDomManager.reset();
12167
12167
  this.canvasManager.reset();
12168
12168
  }
12169
+ destroy() {
12170
+ while (this.mapRemoves.length) {
12171
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
12172
+ }
12173
+ }
12169
12174
  }
12170
12175
  function deepDelete(addsSet, n2) {
12171
12176
  addsSet.delete(n2);
@@ -13212,6 +13217,7 @@ function initObservers(o2, hooks = {}) {
13212
13217
  );
13213
13218
  }
13214
13219
  return callbackWrapper(() => {
13220
+ mutationBuffers.forEach((b) => b.destroy());
13215
13221
  mutationBuffers.forEach((b) => b.reset());
13216
13222
  mutationObserver == null ? void 0 : mutationObserver.disconnect();
13217
13223
  mousemoveHandler();
@@ -13550,6 +13556,8 @@ class IframeManager {
13550
13556
  contentWindow.removeEventListener("message", handler);
13551
13557
  });
13552
13558
  this.nestedIframeListeners.clear();
13559
+ this.crossOriginIframeMirror.reset();
13560
+ this.crossOriginIframeStyleMirror.reset();
13553
13561
  }
13554
13562
  }
13555
13563
  class ShadowDomManager {
@@ -13718,9 +13726,9 @@ const saveWebGLVar = (value, win, ctx) => {
13718
13726
  }
13719
13727
  return index2;
13720
13728
  };
13721
- function serializeArg(value, win, ctx) {
13729
+ function serializeArg(value, win, ctx, dataURLOptions) {
13722
13730
  if (value instanceof Array) {
13723
- return value.map((arg) => serializeArg(arg, win, ctx));
13731
+ return value.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
13724
13732
  } else if (value === null) {
13725
13733
  return value;
13726
13734
  } 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) {
@@ -13746,7 +13754,7 @@ function serializeArg(value, win, ctx) {
13746
13754
  return {
13747
13755
  rr_type: name,
13748
13756
  args: [
13749
- serializeArg(value.buffer, win, ctx),
13757
+ serializeArg(value.buffer, win, ctx, dataURLOptions),
13750
13758
  value.byteOffset,
13751
13759
  value.byteLength
13752
13760
  ]
@@ -13760,7 +13768,7 @@ function serializeArg(value, win, ctx) {
13760
13768
  };
13761
13769
  } else if (value instanceof HTMLCanvasElement) {
13762
13770
  const name = "HTMLImageElement";
13763
- const src = value.toDataURL();
13771
+ const src = value.toDataURL(dataURLOptions.type, dataURLOptions.quality);
13764
13772
  return {
13765
13773
  rr_type: name,
13766
13774
  src
@@ -13769,7 +13777,11 @@ function serializeArg(value, win, ctx) {
13769
13777
  const name = value.constructor.name;
13770
13778
  return {
13771
13779
  rr_type: name,
13772
- args: [serializeArg(value.data, win, ctx), value.width, value.height]
13780
+ args: [
13781
+ serializeArg(value.data, win, ctx, dataURLOptions),
13782
+ value.width,
13783
+ value.height
13784
+ ]
13773
13785
  };
13774
13786
  } else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
13775
13787
  const name = value.constructor.name;
@@ -13781,8 +13793,8 @@ function serializeArg(value, win, ctx) {
13781
13793
  }
13782
13794
  return value;
13783
13795
  }
13784
- const serializeArgs = (args, win, ctx) => {
13785
- return args.map((arg) => serializeArg(arg, win, ctx));
13796
+ const serializeArgs = (args, win, ctx, dataURLOptions) => {
13797
+ return args.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
13786
13798
  };
13787
13799
  const isInstanceOfWebGLObject = (value, win) => {
13788
13800
  const webGLConstructorNames = [
@@ -13808,7 +13820,7 @@ const isInstanceOfWebGLObject = (value, win) => {
13808
13820
  )
13809
13821
  );
13810
13822
  };
13811
- function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
13823
+ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
13812
13824
  const handlers = [];
13813
13825
  const props2D = Object.getOwnPropertyNames(
13814
13826
  win.CanvasRenderingContext2D.prototype
@@ -13825,7 +13837,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
13825
13837
  return function(...args) {
13826
13838
  if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
13827
13839
  setTimeout(() => {
13828
- const recordArgs = serializeArgs(args, win, this);
13840
+ const recordArgs = serializeArgs(
13841
+ args,
13842
+ win,
13843
+ this,
13844
+ dataURLOptions
13845
+ );
13829
13846
  cb(this.canvas, {
13830
13847
  type: CanvasContext["2D"],
13831
13848
  property: prop,
@@ -13899,7 +13916,7 @@ function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDr
13899
13916
  handlers.forEach((h) => h());
13900
13917
  };
13901
13918
  }
13902
- function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13919
+ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, dataURLOptions) {
13903
13920
  const handlers = [];
13904
13921
  const props = Object.getOwnPropertyNames(prototype);
13905
13922
  for (const prop of props) {
@@ -13926,7 +13943,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13926
13943
  const result2 = original.apply(this, args);
13927
13944
  saveWebGLVar(result2, win, this);
13928
13945
  if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
13929
- const recordArgs = serializeArgs(args, win, this);
13946
+ const recordArgs = serializeArgs(args, win, this, dataURLOptions);
13930
13947
  const mutation = {
13931
13948
  type,
13932
13949
  property: prop,
@@ -13955,7 +13972,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
13955
13972
  }
13956
13973
  return handlers;
13957
13974
  }
13958
- function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13975
+ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
13959
13976
  const handlers = [];
13960
13977
  handlers.push(
13961
13978
  ...patchGLPrototype(
@@ -13964,7 +13981,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13964
13981
  cb,
13965
13982
  blockClass,
13966
13983
  blockSelector,
13967
- win
13984
+ win,
13985
+ dataURLOptions
13968
13986
  )
13969
13987
  );
13970
13988
  if (typeof win.WebGL2RenderingContext !== "undefined") {
@@ -13975,7 +13993,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
13975
13993
  cb,
13976
13994
  blockClass,
13977
13995
  blockSelector,
13978
- win
13996
+ win,
13997
+ dataURLOptions
13979
13998
  )
13980
13999
  );
13981
14000
  }
@@ -14017,6 +14036,8 @@ class CanvasManager {
14017
14036
  __publicField(this, "resetObservers");
14018
14037
  __publicField(this, "frozen", false);
14019
14038
  __publicField(this, "locked", false);
14039
+ __publicField(this, "rafIdTimestamp", null);
14040
+ __publicField(this, "rafIdFlush", null);
14020
14041
  __publicField(this, "processMutation", (target, mutation) => {
14021
14042
  const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
14022
14043
  if (newFrame || !this.rafStamps.invokeId)
@@ -14037,7 +14058,12 @@ class CanvasManager {
14037
14058
  this.mutationCb = options.mutationCb;
14038
14059
  this.mirror = options.mirror;
14039
14060
  if (recordCanvas && sampling === "all")
14040
- this.initCanvasMutationObserver(win, blockClass, blockSelector);
14061
+ this.initCanvasMutationObserver(
14062
+ win,
14063
+ blockClass,
14064
+ blockSelector,
14065
+ dataURLOptions
14066
+ );
14041
14067
  if (recordCanvas && typeof sampling === "number")
14042
14068
  this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
14043
14069
  dataURLOptions
@@ -14046,6 +14072,14 @@ class CanvasManager {
14046
14072
  reset() {
14047
14073
  this.pendingCanvasMutations.clear();
14048
14074
  this.resetObservers && this.resetObservers();
14075
+ if (this.rafIdTimestamp !== null) {
14076
+ cancelAnimationFrame(this.rafIdTimestamp);
14077
+ this.rafIdTimestamp = null;
14078
+ }
14079
+ if (this.rafIdFlush !== null) {
14080
+ cancelAnimationFrame(this.rafIdFlush);
14081
+ this.rafIdFlush = null;
14082
+ }
14049
14083
  }
14050
14084
  freeze() {
14051
14085
  this.frozen = true;
@@ -14166,7 +14200,7 @@ class CanvasManager {
14166
14200
  cancelAnimationFrame(rafId);
14167
14201
  };
14168
14202
  }
14169
- initCanvasMutationObserver(win, blockClass, blockSelector) {
14203
+ initCanvasMutationObserver(win, blockClass, blockSelector, dataURLOptions) {
14170
14204
  this.startRAFTimestamping();
14171
14205
  this.startPendingCanvasMutationFlusher();
14172
14206
  const canvasContextReset = initCanvasContextObserver(
@@ -14179,13 +14213,15 @@ class CanvasManager {
14179
14213
  this.processMutation.bind(this),
14180
14214
  win,
14181
14215
  blockClass,
14182
- blockSelector
14216
+ blockSelector,
14217
+ dataURLOptions
14183
14218
  );
14184
14219
  const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(
14185
14220
  this.processMutation.bind(this),
14186
14221
  win,
14187
14222
  blockClass,
14188
- blockSelector
14223
+ blockSelector,
14224
+ dataURLOptions
14189
14225
  );
14190
14226
  this.resetObservers = () => {
14191
14227
  canvasContextReset();
@@ -14194,14 +14230,16 @@ class CanvasManager {
14194
14230
  };
14195
14231
  }
14196
14232
  startPendingCanvasMutationFlusher() {
14197
- requestAnimationFrame(() => this.flushPendingCanvasMutations());
14233
+ this.rafIdFlush = requestAnimationFrame(
14234
+ () => this.flushPendingCanvasMutations()
14235
+ );
14198
14236
  }
14199
14237
  startRAFTimestamping() {
14200
14238
  const setLatestRAFTimestamp = (timestamp) => {
14201
14239
  this.rafStamps.latestId = timestamp;
14202
- requestAnimationFrame(setLatestRAFTimestamp);
14240
+ this.rafIdTimestamp = requestAnimationFrame(setLatestRAFTimestamp);
14203
14241
  };
14204
- requestAnimationFrame(setLatestRAFTimestamp);
14242
+ this.rafIdTimestamp = requestAnimationFrame(setLatestRAFTimestamp);
14205
14243
  }
14206
14244
  flushPendingCanvasMutations() {
14207
14245
  this.pendingCanvasMutations.forEach(
@@ -14210,7 +14248,9 @@ class CanvasManager {
14210
14248
  this.flushPendingCanvasMutationFor(canvas, id);
14211
14249
  }
14212
14250
  );
14213
- requestAnimationFrame(() => this.flushPendingCanvasMutations());
14251
+ this.rafIdFlush = requestAnimationFrame(
14252
+ () => this.flushPendingCanvasMutations()
14253
+ );
14214
14254
  }
14215
14255
  flushPendingCanvasMutationFor(canvas, id) {
14216
14256
  if (this.frozen || this.locked) {
@@ -14789,6 +14829,7 @@ function record(options = {}) {
14789
14829
  processedNodeManager.destroy();
14790
14830
  iframeManager.removeLoadListener();
14791
14831
  iframeManager.destroy();
14832
+ mirror.reset();
14792
14833
  recording = false;
14793
14834
  unregisterErrorHandler();
14794
14835
  };