@posthog/rrweb-snapshot 0.0.40 → 0.0.41

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.
@@ -53,6 +53,8 @@ declare interface CSSImportRule_2 extends CSSRule {
53
53
  readonly supportsText?: string | null;
54
54
  }
55
55
 
56
+ export declare const DEFAULT_MAX_DEPTH = 50;
57
+
56
58
  export declare type DialogAttributes = {
57
59
  open: string;
58
60
  rr_open_mode: 'modal' | 'non-modal';
@@ -225,6 +227,9 @@ export declare function serializeNodeWithId(n: Node, options: {
225
227
  iframeLoadTimeout?: number;
226
228
  onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
227
229
  stylesheetLoadTimeout?: number;
230
+ depth?: number;
231
+ maxDepth?: number;
232
+ onMaxDepthReached?: () => void;
228
233
  }): serializedNodeWithId | null;
229
234
 
230
235
  export declare type SlimDOMOptions = Partial<{
@@ -262,6 +267,7 @@ export declare function snapshot(n: Document, options?: {
262
267
  onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
263
268
  stylesheetLoadTimeout?: number;
264
269
  keepIframeSrcFn?: KeepIframeSrcFn;
270
+ maxDepth?: number;
265
271
  }): serializedNodeWithId | null;
266
272
 
267
273
  export declare function stringifyRule(rule: CSSRule, sheetHref: string | null): string;
@@ -284,4 +290,6 @@ export declare function transformAttribute(doc: Document, tagName: Lowercase<str
284
290
 
285
291
  export declare function visitSnapshot(node: serializedNodeWithId, onVisit: (node: serializedNodeWithId) => unknown): void;
286
292
 
293
+ export declare function wasMaxDepthReached(): boolean;
294
+
287
295
  export { }
@@ -1,7 +1,8 @@
1
- import { IGNORED_NODE, classMatchesRegex, cleanupSnapshot, genId, ignoreAttribute, needMaskingText, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot } from "./record.js";
1
+ import { DEFAULT_MAX_DEPTH, IGNORED_NODE, classMatchesRegex, cleanupSnapshot, genId, ignoreAttribute, needMaskingText, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot, wasMaxDepthReached } from "./record.js";
2
2
  import { adaptCssForReplay, buildNodeWithSN, createCache, rebuild } from "./replay.js";
3
3
  import { M, N, o, p, h, e, n, f, l, j, d, g, i, b, k, a, m, r, c, s, t } from "./types-OLXvwyjP.js";
4
4
  export {
5
+ DEFAULT_MAX_DEPTH,
5
6
  IGNORED_NODE,
6
7
  M as Mirror,
7
8
  N as NodeType,
@@ -36,6 +37,7 @@ export {
36
37
  s as stringifyStylesheet,
37
38
  t as toLowerCase,
38
39
  transformAttribute,
39
- visitSnapshot
40
+ visitSnapshot,
41
+ wasMaxDepthReached
40
42
  };
41
43
  //# sourceMappingURL=rrweb-snapshot.js.map
@@ -1226,6 +1226,12 @@ var require_record = __commonJS({
1226
1226
  }
1227
1227
  return false;
1228
1228
  }
1229
+ var DEFAULT_MAX_DEPTH = 50;
1230
+ var _maxDepthWarned = false;
1231
+ var _maxDepthReached = false;
1232
+ function wasMaxDepthReached() {
1233
+ return _maxDepthReached;
1234
+ }
1229
1235
  function serializeNodeWithId(n, options) {
1230
1236
  const {
1231
1237
  doc,
@@ -1249,10 +1255,22 @@ var require_record = __commonJS({
1249
1255
  onStylesheetLoad,
1250
1256
  stylesheetLoadTimeout = 5e3,
1251
1257
  keepIframeSrcFn = () => false,
1252
- newlyAddedElement = false
1258
+ newlyAddedElement = false,
1259
+ depth = 0,
1260
+ maxDepth = DEFAULT_MAX_DEPTH
1253
1261
  } = options;
1254
1262
  let { needsMask } = options;
1255
1263
  let { preserveWhiteSpace = true } = options;
1264
+ if (depth >= maxDepth) {
1265
+ _maxDepthReached = true;
1266
+ if (!_maxDepthWarned) {
1267
+ _maxDepthWarned = true;
1268
+ console.warn(
1269
+ `[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.`
1270
+ );
1271
+ }
1272
+ return null;
1273
+ }
1256
1274
  if (!needsMask) {
1257
1275
  const checkAncestors = needsMask === void 0;
1258
1276
  needsMask = needMaskingText(
@@ -1333,7 +1351,9 @@ var require_record = __commonJS({
1333
1351
  iframeLoadTimeout,
1334
1352
  onStylesheetLoad,
1335
1353
  stylesheetLoadTimeout,
1336
- keepIframeSrcFn
1354
+ keepIframeSrcFn,
1355
+ depth: depth + 1,
1356
+ maxDepth
1337
1357
  };
1338
1358
  if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1339
1359
  else {
@@ -1388,7 +1408,9 @@ var require_record = __commonJS({
1388
1408
  iframeLoadTimeout,
1389
1409
  onStylesheetLoad,
1390
1410
  stylesheetLoadTimeout,
1391
- keepIframeSrcFn
1411
+ keepIframeSrcFn,
1412
+ depth: depth + 1,
1413
+ maxDepth
1392
1414
  });
1393
1415
  if (serializedIframeNode) {
1394
1416
  onIframeLoad(
@@ -1429,7 +1451,9 @@ var require_record = __commonJS({
1429
1451
  iframeLoadTimeout,
1430
1452
  onStylesheetLoad,
1431
1453
  stylesheetLoadTimeout,
1432
- keepIframeSrcFn
1454
+ keepIframeSrcFn,
1455
+ depth,
1456
+ maxDepth
1433
1457
  });
1434
1458
  if (serializedLinkNode) {
1435
1459
  onStylesheetLoad(
@@ -1465,7 +1489,8 @@ var require_record = __commonJS({
1465
1489
  iframeLoadTimeout,
1466
1490
  onStylesheetLoad,
1467
1491
  stylesheetLoadTimeout,
1468
- keepIframeSrcFn = () => false
1492
+ keepIframeSrcFn = () => false,
1493
+ maxDepth
1469
1494
  } = options || {};
1470
1495
  const maskInputOptions = maskAllInputs === true ? {
1471
1496
  color: true,
@@ -1526,7 +1551,8 @@ var require_record = __commonJS({
1526
1551
  onStylesheetLoad,
1527
1552
  stylesheetLoadTimeout,
1528
1553
  keepIframeSrcFn,
1529
- newlyAddedElement: false
1554
+ newlyAddedElement: false,
1555
+ maxDepth
1530
1556
  });
1531
1557
  }
1532
1558
  function visitSnapshot(node, onVisit) {
@@ -1562,6 +1588,7 @@ var require_record = __commonJS({
1562
1588
  exports2.stringifyRule = types2.stringifyRule;
1563
1589
  exports2.stringifyStylesheet = types2.stringifyStylesheet;
1564
1590
  exports2.toLowerCase = types2.toLowerCase;
1591
+ exports2.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1565
1592
  exports2.IGNORED_NODE = IGNORED_NODE;
1566
1593
  exports2.classMatchesRegex = classMatchesRegex;
1567
1594
  exports2.cleanupSnapshot = cleanupSnapshot;
@@ -1572,6 +1599,7 @@ var require_record = __commonJS({
1572
1599
  exports2.snapshot = snapshot;
1573
1600
  exports2.transformAttribute = transformAttribute;
1574
1601
  exports2.visitSnapshot = visitSnapshot;
1602
+ exports2.wasMaxDepthReached = wasMaxDepthReached;
1575
1603
  }
1576
1604
  });
1577
1605
 
@@ -5976,6 +6004,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5976
6004
  var record = require_record();
5977
6005
  var replay = require_replay();
5978
6006
  var types = require_types_B7TTv7Jc();
6007
+ exports.DEFAULT_MAX_DEPTH = record.DEFAULT_MAX_DEPTH;
5979
6008
  exports.IGNORED_NODE = record.IGNORED_NODE;
5980
6009
  exports.classMatchesRegex = record.classMatchesRegex;
5981
6010
  exports.cleanupSnapshot = record.cleanupSnapshot;
@@ -5986,6 +6015,7 @@ exports.serializeNodeWithId = record.serializeNodeWithId;
5986
6015
  exports.snapshot = record.snapshot;
5987
6016
  exports.transformAttribute = record.transformAttribute;
5988
6017
  exports.visitSnapshot = record.visitSnapshot;
6018
+ exports.wasMaxDepthReached = record.wasMaxDepthReached;
5989
6019
  exports.adaptCssForReplay = replay.adaptCssForReplay;
5990
6020
  exports.buildNodeWithSN = replay.buildNodeWithSN;
5991
6021
  exports.createCache = replay.createCache;