@posthog/rrweb-record 0.0.40 → 0.0.42

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.
@@ -1169,6 +1169,16 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1169
1169
  }
1170
1170
  return false;
1171
1171
  }
1172
+ const DEFAULT_MAX_DEPTH = 50;
1173
+ let _maxDepthWarned = false;
1174
+ let _maxDepthReached = false;
1175
+ function wasMaxDepthReached() {
1176
+ return _maxDepthReached;
1177
+ }
1178
+ function resetMaxDepthState() {
1179
+ _maxDepthReached = false;
1180
+ _maxDepthWarned = false;
1181
+ }
1172
1182
  function serializeNodeWithId(n2, options) {
1173
1183
  const {
1174
1184
  doc,
@@ -1192,10 +1202,22 @@ function serializeNodeWithId(n2, options) {
1192
1202
  onStylesheetLoad,
1193
1203
  stylesheetLoadTimeout = 5e3,
1194
1204
  keepIframeSrcFn = () => false,
1195
- newlyAddedElement = false
1205
+ newlyAddedElement = false,
1206
+ depth = 0,
1207
+ maxDepth = DEFAULT_MAX_DEPTH
1196
1208
  } = options;
1197
1209
  let { needsMask } = options;
1198
1210
  let { preserveWhiteSpace = true } = options;
1211
+ if (depth >= maxDepth) {
1212
+ _maxDepthReached = true;
1213
+ if (!_maxDepthWarned) {
1214
+ _maxDepthWarned = true;
1215
+ console.warn(
1216
+ `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1217
+ );
1218
+ }
1219
+ return null;
1220
+ }
1199
1221
  if (!needsMask) {
1200
1222
  const checkAncestors = needsMask === void 0;
1201
1223
  needsMask = needMaskingText(
@@ -1276,7 +1298,9 @@ function serializeNodeWithId(n2, options) {
1276
1298
  iframeLoadTimeout,
1277
1299
  onStylesheetLoad,
1278
1300
  stylesheetLoadTimeout,
1279
- keepIframeSrcFn
1301
+ keepIframeSrcFn,
1302
+ depth: depth + 1,
1303
+ maxDepth
1280
1304
  };
1281
1305
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1282
1306
  else {
@@ -1331,7 +1355,9 @@ function serializeNodeWithId(n2, options) {
1331
1355
  iframeLoadTimeout,
1332
1356
  onStylesheetLoad,
1333
1357
  stylesheetLoadTimeout,
1334
- keepIframeSrcFn
1358
+ keepIframeSrcFn,
1359
+ depth: depth + 1,
1360
+ maxDepth
1335
1361
  });
1336
1362
  if (serializedIframeNode) {
1337
1363
  onIframeLoad(
@@ -1372,7 +1398,9 @@ function serializeNodeWithId(n2, options) {
1372
1398
  iframeLoadTimeout,
1373
1399
  onStylesheetLoad,
1374
1400
  stylesheetLoadTimeout,
1375
- keepIframeSrcFn
1401
+ keepIframeSrcFn,
1402
+ depth,
1403
+ maxDepth
1376
1404
  });
1377
1405
  if (serializedLinkNode) {
1378
1406
  onStylesheetLoad(
@@ -1408,7 +1436,8 @@ function snapshot(n2, options) {
1408
1436
  iframeLoadTimeout,
1409
1437
  onStylesheetLoad,
1410
1438
  stylesheetLoadTimeout,
1411
- keepIframeSrcFn = () => false
1439
+ keepIframeSrcFn = () => false,
1440
+ maxDepth
1412
1441
  } = options || {};
1413
1442
  const maskInputOptions = maskAllInputs === true ? {
1414
1443
  color: true,
@@ -1469,7 +1498,8 @@ function snapshot(n2, options) {
1469
1498
  onStylesheetLoad,
1470
1499
  stylesheetLoadTimeout,
1471
1500
  keepIframeSrcFn,
1472
- newlyAddedElement: false
1501
+ newlyAddedElement: false,
1502
+ maxDepth
1473
1503
  });
1474
1504
  }
1475
1505
  function getDefaultExportFromCjs$1(x) {
@@ -13188,6 +13218,8 @@ const { addCustomEvent } = record;
13188
13218
  const { freezePage } = record;
13189
13219
  const { takeFullSnapshot } = record;
13190
13220
  exports.record = record;
13221
+ exports.resetMaxDepthState = resetMaxDepthState;
13222
+ exports.wasMaxDepthReached = wasMaxDepthReached;
13191
13223
  ;if (typeof module.exports == "object" && typeof exports == "object") {
13192
13224
  var __cp = (to, from, except, desc) => {
13193
13225
  if ((from && typeof from === "object") || typeof from === "function") {