@highlight-run/rrweb 2.0.0-lambda.8 → 2.0.0-lambda.9

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.cjs CHANGED
@@ -13674,66 +13674,142 @@ function getIdAndStyleId(sheet, mirror2, styleMirror) {
13674
13674
  id
13675
13675
  };
13676
13676
  }
13677
- function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetManager }, { win }) {
13677
+ function restorePatchedMethod(target, key, ours, restoreTo) {
13678
+ if (target[key] === ours) {
13679
+ target[key] = restoreTo;
13680
+ }
13681
+ }
13682
+ const MAX_CSSOM_REPATCH_ATTEMPTS = 5;
13683
+ function initStyleSheetObserver({
13684
+ styleSheetRuleCb,
13685
+ mirror: mirror2,
13686
+ stylesheetManager,
13687
+ doc,
13688
+ styleSheetResyncInterval
13689
+ }, { win }) {
13678
13690
  if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
13679
13691
  return () => {
13680
13692
  };
13681
13693
  }
13682
- const insertRule = win.CSSStyleSheet.prototype.insertRule;
13683
- win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
13694
+ const reportedRuleCounts = /* @__PURE__ */ new WeakMap();
13695
+ const unreconcilableSheets = /* @__PURE__ */ new WeakSet();
13696
+ let probing = false;
13697
+ let probeInsertObserved = false;
13698
+ let probeDeleteObserved = false;
13699
+ let probeSheet;
13700
+ let stopped = false;
13701
+ let insideInsertRule = false;
13702
+ let insideDeleteRule = false;
13703
+ const noteReportedRules = (sheet, delta) => {
13704
+ const state = reportedRuleCounts.get(sheet);
13705
+ if (state) {
13706
+ state.reported = Math.max(0, state.reported + delta);
13707
+ state.everSeen = Math.max(state.everSeen, state.reported);
13708
+ }
13709
+ };
13710
+ const patchInsertRule = (target) => new Proxy(target, {
13684
13711
  apply: callbackWrapper(
13685
- (target, thisArg, argumentsList) => {
13712
+ (nativeFn, thisArg, argumentsList) => {
13713
+ if (probing) {
13714
+ probeInsertObserved = true;
13715
+ return nativeFn.apply(thisArg, argumentsList);
13716
+ }
13717
+ if (stopped || insideInsertRule) {
13718
+ return nativeFn.apply(thisArg, argumentsList);
13719
+ }
13686
13720
  const [rule2, index2] = argumentsList;
13687
13721
  const { id, styleId } = getIdAndStyleId(
13688
13722
  thisArg,
13689
13723
  mirror2,
13690
13724
  stylesheetManager.styleMirror
13691
13725
  );
13692
- if (id && id !== -1 || styleId && styleId !== -1) {
13726
+ const reported = id && id !== -1 || styleId && styleId !== -1;
13727
+ if (reported) {
13693
13728
  styleSheetRuleCb({
13694
13729
  id,
13695
13730
  styleId,
13696
13731
  adds: [{ rule: rule2, index: index2 }]
13697
13732
  });
13698
13733
  }
13699
- return target.apply(thisArg, argumentsList);
13734
+ insideInsertRule = true;
13735
+ let result2;
13736
+ try {
13737
+ result2 = nativeFn.apply(thisArg, argumentsList);
13738
+ } finally {
13739
+ insideInsertRule = false;
13740
+ }
13741
+ if (reported) {
13742
+ noteReportedRules(thisArg, 1);
13743
+ }
13744
+ return result2;
13700
13745
  }
13701
13746
  )
13702
13747
  });
13703
- win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2 = this.cssRules.length) {
13704
- const rule2 = `${selector} { ${styleBlock} }`;
13705
- return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule2, index2]);
13706
- };
13707
- const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
13708
- win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
13748
+ const patchDeleteRule = (target) => new Proxy(target, {
13709
13749
  apply: callbackWrapper(
13710
- (target, thisArg, argumentsList) => {
13750
+ (nativeFn, thisArg, argumentsList) => {
13751
+ if (probing) {
13752
+ probeDeleteObserved = true;
13753
+ return nativeFn.apply(thisArg, argumentsList);
13754
+ }
13755
+ if (stopped || insideDeleteRule) {
13756
+ return nativeFn.apply(thisArg, argumentsList);
13757
+ }
13711
13758
  const [index2] = argumentsList;
13712
13759
  const { id, styleId } = getIdAndStyleId(
13713
13760
  thisArg,
13714
13761
  mirror2,
13715
13762
  stylesheetManager.styleMirror
13716
13763
  );
13717
- if (id && id !== -1 || styleId && styleId !== -1) {
13764
+ const reported = id && id !== -1 || styleId && styleId !== -1;
13765
+ if (reported) {
13718
13766
  styleSheetRuleCb({
13719
13767
  id,
13720
13768
  styleId,
13721
13769
  removes: [{ index: index2 }]
13722
13770
  });
13723
13771
  }
13724
- return target.apply(thisArg, argumentsList);
13772
+ insideDeleteRule = true;
13773
+ let result2;
13774
+ try {
13775
+ result2 = nativeFn.apply(thisArg, argumentsList);
13776
+ } finally {
13777
+ insideDeleteRule = false;
13778
+ }
13779
+ if (reported) {
13780
+ noteReportedRules(thisArg, -1);
13781
+ }
13782
+ return result2;
13725
13783
  }
13726
13784
  )
13727
13785
  });
13728
- win.CSSStyleSheet.prototype.removeRule = function(index2) {
13786
+ const insertRule = win.CSSStyleSheet.prototype.insertRule;
13787
+ let insertRuleProxy = patchInsertRule(insertRule);
13788
+ let restoreInsertRuleTo = insertRule;
13789
+ win.CSSStyleSheet.prototype.insertRule = insertRuleProxy;
13790
+ const addRule = win.CSSStyleSheet.prototype.addRule;
13791
+ const addRuleShim = function(selector, styleBlock, index2 = this.cssRules.length) {
13792
+ const rule2 = `${selector} { ${styleBlock} }`;
13793
+ return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule2, index2]);
13794
+ };
13795
+ win.CSSStyleSheet.prototype.addRule = addRuleShim;
13796
+ const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
13797
+ let deleteRuleProxy = patchDeleteRule(deleteRule);
13798
+ let restoreDeleteRuleTo = deleteRule;
13799
+ win.CSSStyleSheet.prototype.deleteRule = deleteRuleProxy;
13800
+ const removeRule = win.CSSStyleSheet.prototype.removeRule;
13801
+ const removeRuleShim = function(index2) {
13729
13802
  return win.CSSStyleSheet.prototype.deleteRule.apply(this, [index2]);
13730
13803
  };
13804
+ win.CSSStyleSheet.prototype.removeRule = removeRuleShim;
13731
13805
  let replace;
13806
+ let replaceProxy;
13732
13807
  if (win.CSSStyleSheet.prototype.replace) {
13733
13808
  replace = win.CSSStyleSheet.prototype.replace;
13734
- win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
13809
+ replaceProxy = new Proxy(replace, {
13735
13810
  apply: callbackWrapper(
13736
13811
  (target, thisArg, argumentsList) => {
13812
+ if (stopped) return target.apply(thisArg, argumentsList);
13737
13813
  const [text] = argumentsList;
13738
13814
  const { id, styleId } = getIdAndStyleId(
13739
13815
  thisArg,
@@ -13751,13 +13827,16 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13751
13827
  }
13752
13828
  )
13753
13829
  });
13830
+ win.CSSStyleSheet.prototype.replace = replaceProxy;
13754
13831
  }
13755
13832
  let replaceSync;
13833
+ let replaceSyncProxy;
13756
13834
  if (win.CSSStyleSheet.prototype.replaceSync) {
13757
13835
  replaceSync = win.CSSStyleSheet.prototype.replaceSync;
13758
- win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
13836
+ replaceSyncProxy = new Proxy(replaceSync, {
13759
13837
  apply: callbackWrapper(
13760
13838
  (target, thisArg, argumentsList) => {
13839
+ if (stopped) return target.apply(thisArg, argumentsList);
13761
13840
  const [text] = argumentsList;
13762
13841
  const { id, styleId } = getIdAndStyleId(
13763
13842
  thisArg,
@@ -13775,6 +13854,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13775
13854
  }
13776
13855
  )
13777
13856
  });
13857
+ win.CSSStyleSheet.prototype.replaceSync = replaceSyncProxy;
13778
13858
  }
13779
13859
  const supportedNestedCSSRuleTypes = {};
13780
13860
  if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
@@ -13791,6 +13871,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13791
13871
  }
13792
13872
  }
13793
13873
  const unmodifiedFunctions = {};
13874
+ const nestedProxies = {};
13794
13875
  Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
13795
13876
  unmodifiedFunctions[typeKey] = {
13796
13877
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -13798,11 +13879,13 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13798
13879
  // eslint-disable-next-line @typescript-eslint/unbound-method
13799
13880
  deleteRule: type.prototype.deleteRule
13800
13881
  };
13801
- type.prototype.insertRule = new Proxy(
13882
+ nestedProxies[typeKey] = {};
13883
+ nestedProxies[typeKey].insertRule = new Proxy(
13802
13884
  unmodifiedFunctions[typeKey].insertRule,
13803
13885
  {
13804
13886
  apply: callbackWrapper(
13805
13887
  (target, thisArg, argumentsList) => {
13888
+ if (stopped) return target.apply(thisArg, argumentsList);
13806
13889
  const [rule2, index2] = argumentsList;
13807
13890
  const { id, styleId } = getIdAndStyleId(
13808
13891
  thisArg.parentStyleSheet,
@@ -13830,11 +13913,12 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13830
13913
  )
13831
13914
  }
13832
13915
  );
13833
- type.prototype.deleteRule = new Proxy(
13916
+ nestedProxies[typeKey].deleteRule = new Proxy(
13834
13917
  unmodifiedFunctions[typeKey].deleteRule,
13835
13918
  {
13836
13919
  apply: callbackWrapper(
13837
13920
  (target, thisArg, argumentsList) => {
13921
+ if (stopped) return target.apply(thisArg, argumentsList);
13838
13922
  const [index2] = argumentsList;
13839
13923
  const { id, styleId } = getIdAndStyleId(
13840
13924
  thisArg.parentStyleSheet,
@@ -13855,15 +13939,148 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
13855
13939
  )
13856
13940
  }
13857
13941
  );
13942
+ type.prototype.insertRule = nestedProxies[typeKey].insertRule;
13943
+ type.prototype.deleteRule = nestedProxies[typeKey].deleteRule;
13858
13944
  });
13945
+ const captureIsHealthy = () => {
13946
+ probing = true;
13947
+ probeInsertObserved = false;
13948
+ probeDeleteObserved = false;
13949
+ try {
13950
+ const probe = probeSheet ?? (probeSheet = new win.CSSStyleSheet());
13951
+ probe.insertRule(":root {}", 0);
13952
+ probe.deleteRule(0);
13953
+ } catch (error) {
13954
+ return {
13955
+ insertRule: win.CSSStyleSheet.prototype.insertRule === insertRuleProxy,
13956
+ deleteRule: win.CSSStyleSheet.prototype.deleteRule === deleteRuleProxy
13957
+ };
13958
+ } finally {
13959
+ probing = false;
13960
+ }
13961
+ return {
13962
+ insertRule: probeInsertObserved,
13963
+ deleteRule: probeDeleteObserved
13964
+ };
13965
+ };
13966
+ let repatchAttempts = 0;
13967
+ const repatch = (health) => {
13968
+ if (repatchAttempts >= MAX_CSSOM_REPATCH_ATTEMPTS) return;
13969
+ repatchAttempts += 1;
13970
+ if (!health.insertRule) {
13971
+ restoreInsertRuleTo = win.CSSStyleSheet.prototype.insertRule;
13972
+ insertRuleProxy = patchInsertRule(restoreInsertRuleTo);
13973
+ win.CSSStyleSheet.prototype.insertRule = insertRuleProxy;
13974
+ }
13975
+ if (!health.deleteRule) {
13976
+ restoreDeleteRuleTo = win.CSSStyleSheet.prototype.deleteRule;
13977
+ deleteRuleProxy = patchDeleteRule(restoreDeleteRuleTo);
13978
+ win.CSSStyleSheet.prototype.deleteRule = deleteRuleProxy;
13979
+ }
13980
+ };
13981
+ const resyncCssomStyleSheets = (trusted) => {
13982
+ for (let i2 = 0; i2 < doc.styleSheets.length; i2++) {
13983
+ const sheet = doc.styleSheets[i2];
13984
+ if (unreconcilableSheets.has(sheet)) continue;
13985
+ const owner = sheet.ownerNode;
13986
+ if (!owner || toLowerCase(owner.nodeName) !== "style") continue;
13987
+ if ((owner.textContent || "").trim().length) continue;
13988
+ const id = mirror2.getId(owner);
13989
+ if (!id || id === -1) continue;
13990
+ let rules2;
13991
+ try {
13992
+ rules2 = sheet.cssRules;
13993
+ } catch (error) {
13994
+ continue;
13995
+ }
13996
+ const live = rules2.length;
13997
+ let state = reportedRuleCounts.get(sheet);
13998
+ if (!state) {
13999
+ if (Array.from(rules2).some((rule2) => isCSSImportRule(rule2))) {
14000
+ unreconcilableSheets.add(sheet);
14001
+ continue;
14002
+ }
14003
+ state = { reported: live, everSeen: live };
14004
+ reportedRuleCounts.set(sheet, state);
14005
+ if (trusted) continue;
14006
+ replaceReplayerCopy(id, state, rules2);
14007
+ continue;
14008
+ }
14009
+ state.everSeen = Math.max(state.everSeen, live);
14010
+ if (live === state.reported) continue;
14011
+ if (live > state.reported) {
14012
+ const adds = [];
14013
+ for (let index2 = state.reported; index2 < live; index2++) {
14014
+ adds.push({ rule: rules2[index2].cssText, index: index2 });
14015
+ }
14016
+ styleSheetRuleCb({ id, adds });
14017
+ state.reported = live;
14018
+ } else {
14019
+ replaceReplayerCopy(id, state, rules2);
14020
+ }
14021
+ }
14022
+ };
14023
+ function replaceReplayerCopy(id, state, rules2) {
14024
+ const removes = [];
14025
+ for (let index2 = state.everSeen - 1; index2 >= 0; index2--) {
14026
+ removes.push({ index: index2 });
14027
+ }
14028
+ if (removes.length) styleSheetRuleCb({ id, removes });
14029
+ styleSheetRuleCb({
14030
+ id,
14031
+ adds: Array.from(rules2, (rule2, index2) => ({
14032
+ rule: rule2.cssText,
14033
+ index: index2
14034
+ }))
14035
+ });
14036
+ state.reported = rules2.length;
14037
+ state.everSeen = rules2.length;
14038
+ }
14039
+ let resyncTimer;
14040
+ if (styleSheetResyncInterval > 0) {
14041
+ resyncTimer = win.setInterval(
14042
+ callbackWrapper(() => {
14043
+ const health = captureIsHealthy();
14044
+ const healthy = health.insertRule && health.deleteRule;
14045
+ if (!healthy) repatch(health);
14046
+ resyncCssomStyleSheets(healthy);
14047
+ }),
14048
+ styleSheetResyncInterval
14049
+ );
14050
+ }
13859
14051
  return callbackWrapper(() => {
13860
- win.CSSStyleSheet.prototype.insertRule = insertRule;
13861
- win.CSSStyleSheet.prototype.deleteRule = deleteRule;
13862
- replace && (win.CSSStyleSheet.prototype.replace = replace);
13863
- replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
14052
+ if (resyncTimer !== void 0) win.clearInterval(resyncTimer);
14053
+ stopped = true;
14054
+ const proto = win.CSSStyleSheet.prototype;
14055
+ restorePatchedMethod(
14056
+ proto,
14057
+ "insertRule",
14058
+ insertRuleProxy,
14059
+ restoreInsertRuleTo
14060
+ );
14061
+ restorePatchedMethod(
14062
+ proto,
14063
+ "deleteRule",
14064
+ deleteRuleProxy,
14065
+ restoreDeleteRuleTo
14066
+ );
14067
+ restorePatchedMethod(proto, "addRule", addRuleShim, addRule);
14068
+ restorePatchedMethod(proto, "removeRule", removeRuleShim, removeRule);
14069
+ replaceProxy && restorePatchedMethod(proto, "replace", replaceProxy, replace);
14070
+ replaceSyncProxy && restorePatchedMethod(proto, "replaceSync", replaceSyncProxy, replaceSync);
13864
14071
  Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
13865
- type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
13866
- type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
14072
+ restorePatchedMethod(
14073
+ type.prototype,
14074
+ "insertRule",
14075
+ nestedProxies[typeKey].insertRule,
14076
+ unmodifiedFunctions[typeKey].insertRule
14077
+ );
14078
+ restorePatchedMethod(
14079
+ type.prototype,
14080
+ "deleteRule",
14081
+ nestedProxies[typeKey].deleteRule,
14082
+ unmodifiedFunctions[typeKey].deleteRule
14083
+ );
13867
14084
  });
13868
14085
  });
13869
14086
  }
@@ -15631,6 +15848,7 @@ function record(options = {}) {
15631
15848
  keepIframeSrcFn = () => false,
15632
15849
  privacySetting = "default",
15633
15850
  ignoreCSSAttributes = /* @__PURE__ */ new Set([]),
15851
+ styleSheetResyncInterval = 2e3,
15634
15852
  errorHandler: errorHandler2,
15635
15853
  logger
15636
15854
  } = options;
@@ -16009,6 +16227,7 @@ function record(options = {}) {
16009
16227
  processedNodeManager,
16010
16228
  canvasManager,
16011
16229
  ignoreCSSAttributes,
16230
+ styleSheetResyncInterval,
16012
16231
  privacySetting,
16013
16232
  plugins: ((_a3 = plugins == null ? void 0 : plugins.filter((p) => p.observer)) == null ? void 0 : _a3.map((p) => ({
16014
16233
  observer: p.observer,
@@ -16895,12 +17114,36 @@ function variableListFor(ctx, ctor) {
16895
17114
  }
16896
17115
  return contextMap.get(ctor);
16897
17116
  }
16898
- function deserializeArg(imageMap, ctx, preload) {
17117
+ const canvasArgConstructors = /* @__PURE__ */ new Set([
17118
+ "Int8Array",
17119
+ "Int16Array",
17120
+ "Int32Array",
17121
+ "Uint8Array",
17122
+ "Uint8ClampedArray",
17123
+ "Uint16Array",
17124
+ "Uint32Array",
17125
+ "Float32Array",
17126
+ "Float64Array",
17127
+ "DataView",
17128
+ "ImageData",
17129
+ // normally serialized as base64, but reachable in `args` form through
17130
+ // recordings made by older clients and through nested `DataView` args.
17131
+ "ArrayBuffer",
17132
+ // wraps nested args in recordings made by older clients — see the
17133
+ // `preloadAllImages` tests for the shape.
17134
+ "Array"
17135
+ ]);
17136
+ function deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist = false) {
16899
17137
  return async (arg) => {
16900
17138
  if (arg && typeof arg === "object" && "rr_type" in arg) {
16901
17139
  if (preload) preload.isUnchanged = false;
16902
17140
  if (arg.rr_type === "ImageBitmap" && "args" in arg) {
16903
- const args = await deserializeArg(imageMap, ctx, preload)(arg.args);
17141
+ const args = await deserializeArg(
17142
+ imageMap,
17143
+ ctx,
17144
+ preload,
17145
+ enforceCanvasArgAllowlist
17146
+ )(arg.args);
16904
17147
  return await createImageBitmap.apply(null, args);
16905
17148
  } else if ("index" in arg) {
16906
17149
  if (preload || ctx === null) return arg;
@@ -16908,10 +17151,18 @@ function deserializeArg(imageMap, ctx, preload) {
16908
17151
  return variableListFor(ctx, name)[index2];
16909
17152
  } else if ("args" in arg) {
16910
17153
  const { rr_type: name, args } = arg;
17154
+ if (enforceCanvasArgAllowlist && !canvasArgConstructors.has(name)) {
17155
+ console.warn(
17156
+ `[replayer] refusing to construct canvas arg of unknown type: ${name}`
17157
+ );
17158
+ return null;
17159
+ }
16911
17160
  const ctor = window[name];
16912
17161
  return new ctor(
16913
17162
  ...await Promise.all(
16914
- args.map(deserializeArg(imageMap, ctx, preload))
17163
+ args.map(
17164
+ deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
17165
+ )
16915
17166
  )
16916
17167
  );
16917
17168
  } else if ("base64" in arg) {
@@ -16928,7 +17179,9 @@ function deserializeArg(imageMap, ctx, preload) {
16928
17179
  }
16929
17180
  } else if ("data" in arg && arg.rr_type === "Blob") {
16930
17181
  const blobContents = await Promise.all(
16931
- arg.data.map(deserializeArg(imageMap, ctx, preload))
17182
+ arg.data.map(
17183
+ deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
17184
+ )
16932
17185
  );
16933
17186
  const blob2 = new Blob(blobContents, {
16934
17187
  type: arg.type
@@ -16937,7 +17190,9 @@ function deserializeArg(imageMap, ctx, preload) {
16937
17190
  }
16938
17191
  } else if (Array.isArray(arg)) {
16939
17192
  const result2 = await Promise.all(
16940
- arg.map(deserializeArg(imageMap, ctx, preload))
17193
+ arg.map(
17194
+ deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
17195
+ )
16941
17196
  );
16942
17197
  return result2;
16943
17198
  }
@@ -16978,7 +17233,8 @@ async function webglMutation({
16978
17233
  target,
16979
17234
  type,
16980
17235
  imageMap,
16981
- errorHandler: errorHandler2
17236
+ errorHandler: errorHandler2,
17237
+ enforceCanvasArgAllowlist
16982
17238
  }) {
16983
17239
  try {
16984
17240
  const ctx = getContext(target, type);
@@ -16989,7 +17245,9 @@ async function webglMutation({
16989
17245
  }
16990
17246
  const original = ctx[mutation.property];
16991
17247
  const args = await Promise.all(
16992
- mutation.args.map(deserializeArg(imageMap, ctx))
17248
+ mutation.args.map(
17249
+ deserializeArg(imageMap, ctx, void 0, enforceCanvasArgAllowlist)
17250
+ )
16993
17251
  );
16994
17252
  const result2 = original.apply(ctx, args);
16995
17253
  saveToWebGLVarMap(ctx, result2);
@@ -17004,7 +17262,8 @@ async function canvasMutation$1({
17004
17262
  mutations,
17005
17263
  target,
17006
17264
  imageMap,
17007
- errorHandler: errorHandler2
17265
+ errorHandler: errorHandler2,
17266
+ enforceCanvasArgAllowlist
17008
17267
  }) {
17009
17268
  const ctx = target.getContext("2d");
17010
17269
  if (!ctx) {
@@ -17014,7 +17273,11 @@ async function canvasMutation$1({
17014
17273
  wrapCanvasContextDrawImage(ctx);
17015
17274
  const mutationArgsPromises = mutations.map(
17016
17275
  async (mutation) => {
17017
- return Promise.all(mutation.args.map(deserializeArg(imageMap, ctx)));
17276
+ return Promise.all(
17277
+ mutation.args.map(
17278
+ deserializeArg(imageMap, ctx, void 0, enforceCanvasArgAllowlist)
17279
+ )
17280
+ );
17018
17281
  }
17019
17282
  );
17020
17283
  const args = await Promise.all(mutationArgsPromises);
@@ -17044,7 +17307,8 @@ async function canvasMutation({
17044
17307
  target,
17045
17308
  imageMap,
17046
17309
  canvasEventMap,
17047
- errorHandler: errorHandler2
17310
+ errorHandler: errorHandler2,
17311
+ enforceCanvasArgAllowlist
17048
17312
  }) {
17049
17313
  try {
17050
17314
  const precomputedMutation = canvasEventMap.get(event) || mutation;
@@ -17057,7 +17321,8 @@ async function canvasMutation({
17057
17321
  type: mutation.type,
17058
17322
  target,
17059
17323
  imageMap,
17060
- errorHandler: errorHandler2
17324
+ errorHandler: errorHandler2,
17325
+ enforceCanvasArgAllowlist
17061
17326
  });
17062
17327
  }
17063
17328
  return;
@@ -17067,7 +17332,8 @@ async function canvasMutation({
17067
17332
  mutations: commands,
17068
17333
  target,
17069
17334
  imageMap,
17070
- errorHandler: errorHandler2
17335
+ errorHandler: errorHandler2,
17336
+ enforceCanvasArgAllowlist
17071
17337
  });
17072
17338
  } catch (error) {
17073
17339
  errorHandler2(mutation, error);
@@ -17510,6 +17776,7 @@ class Replayer {
17510
17776
  insertStyleRules: [],
17511
17777
  triggerFocus: true,
17512
17778
  UNSAFE_replayCanvas: false,
17779
+ enforceCanvasArgAllowlist: false,
17513
17780
  pauseAnimation: true,
17514
17781
  mouseTail: defaultMouseTailConfig,
17515
17782
  useVirtualDom: true,
@@ -17538,7 +17805,8 @@ class Replayer {
17538
17805
  target,
17539
17806
  imageMap: this.imageMap,
17540
17807
  canvasEventMap: this.canvasEventMap,
17541
- errorHandler: this.warnCanvasMutationFailed.bind(this)
17808
+ errorHandler: this.warnCanvasMutationFailed.bind(this),
17809
+ enforceCanvasArgAllowlist: this.config.enforceCanvasArgAllowlist
17542
17810
  });
17543
17811
  },
17544
17812
  applyInput: this.applyInput.bind(this),
@@ -18250,7 +18518,14 @@ class Replayer {
18250
18518
  const commands = await Promise.all(
18251
18519
  data.commands.map(async (c2) => {
18252
18520
  const args = await Promise.all(
18253
- c2.args.map(deserializeArg(this.imageMap, null, status))
18521
+ c2.args.map(
18522
+ deserializeArg(
18523
+ this.imageMap,
18524
+ null,
18525
+ status,
18526
+ this.config.enforceCanvasArgAllowlist
18527
+ )
18528
+ )
18254
18529
  );
18255
18530
  return { ...c2, args };
18256
18531
  })
@@ -18259,7 +18534,14 @@ class Replayer {
18259
18534
  this.canvasEventMap.set(event, { ...data, commands });
18260
18535
  } else {
18261
18536
  const args = await Promise.all(
18262
- data.args.map(deserializeArg(this.imageMap, null, status))
18537
+ data.args.map(
18538
+ deserializeArg(
18539
+ this.imageMap,
18540
+ null,
18541
+ status,
18542
+ this.config.enforceCanvasArgAllowlist
18543
+ )
18544
+ )
18263
18545
  );
18264
18546
  if (status.isUnchanged === false)
18265
18547
  this.canvasEventMap.set(event, { ...data, args });
@@ -18472,7 +18754,8 @@ class Replayer {
18472
18754
  target,
18473
18755
  imageMap: this.imageMap,
18474
18756
  canvasEventMap: this.canvasEventMap,
18475
- errorHandler: this.warnCanvasMutationFailed.bind(this)
18757
+ errorHandler: this.warnCanvasMutationFailed.bind(this),
18758
+ enforceCanvasArgAllowlist: this.config.enforceCanvasArgAllowlist
18476
18759
  });
18477
18760
  }
18478
18761
  break;
@@ -19210,6 +19493,7 @@ const SERIALIZABLE_CONFIG_KEYS = [
19210
19493
  "insertStyleRules",
19211
19494
  "triggerFocus",
19212
19495
  "UNSAFE_replayCanvas",
19496
+ "enforceCanvasArgAllowlist",
19213
19497
  "cspContent",
19214
19498
  "pauseAnimation",
19215
19499
  "mouseTail",