@posthog/rrweb-snapshot 0.0.27 → 0.0.28

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.
@@ -247,91 +247,6 @@ function isShadowRoot(n) {
247
247
  function isNativeShadowDom(shadowRoot2) {
248
248
  return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
249
249
  }
250
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
251
- if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
252
- cssText = cssText.replace(
253
- /\sbackground-clip:\s*text;/g,
254
- " -webkit-background-clip: text; background-clip: text;"
255
- );
256
- }
257
- return cssText;
258
- }
259
- function escapeImportStatement(rule2) {
260
- const { cssText } = rule2;
261
- if (cssText.split('"').length < 3) return cssText;
262
- const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
263
- if (rule2.layerName === "") {
264
- statement.push(`layer`);
265
- } else if (rule2.layerName) {
266
- statement.push(`layer(${rule2.layerName})`);
267
- }
268
- if (rule2.supportsText) {
269
- statement.push(`supports(${rule2.supportsText})`);
270
- }
271
- if (rule2.media.length) {
272
- statement.push(rule2.media.mediaText);
273
- }
274
- return statement.join(" ") + ";";
275
- }
276
- function stringifyStylesheet(s) {
277
- try {
278
- const rules = s.rules || s.cssRules;
279
- if (!rules) {
280
- return null;
281
- }
282
- let sheetHref = s.href;
283
- if (!sheetHref && s.ownerNode) {
284
- sheetHref = s.ownerNode.baseURI;
285
- }
286
- const stringifiedRules = Array.from(
287
- rules,
288
- (rule2) => stringifyRule(rule2, sheetHref)
289
- ).join("");
290
- return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
291
- } catch (error) {
292
- return null;
293
- }
294
- }
295
- function stringifyRule(rule2, sheetHref) {
296
- var _a;
297
- if (isCSSImportRule(rule2)) {
298
- let importStringified;
299
- try {
300
- importStringified = // for same-origin stylesheets,
301
- // we can access the imported stylesheet rules directly
302
- stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
303
- escapeImportStatement(rule2);
304
- } catch (error) {
305
- importStringified = rule2.cssText;
306
- }
307
- try {
308
- if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
309
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
310
- }
311
- } catch (e) {
312
- }
313
- return importStringified;
314
- } else {
315
- let ruleStringified = rule2.cssText;
316
- if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
317
- ruleStringified = fixSafariColons(ruleStringified);
318
- }
319
- if (sheetHref) {
320
- return absolutifyURLs(ruleStringified, sheetHref);
321
- }
322
- return ruleStringified;
323
- }
324
- }
325
- function fixSafariColons(cssStringified) {
326
- const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
327
- return cssStringified.replace(regex, "$1\\$2");
328
- }
329
- function isCSSImportRule(rule2) {
330
- return "styleSheet" in rule2;
331
- }
332
- function isCSSStyleRule(rule2) {
333
- return "selectorText" in rule2;
334
- }
335
250
  class Mirror {
336
251
  constructor() {
337
252
  __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -467,6 +382,91 @@ function extractFileExtension(path, baseURL) {
467
382
  const match = url.pathname.match(regex);
468
383
  return (_a = match == null ? void 0 : match[1]) != null ? _a : null;
469
384
  }
385
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
386
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
387
+ cssText = cssText.replace(
388
+ /\sbackground-clip:\s*text;/g,
389
+ " -webkit-background-clip: text; background-clip: text;"
390
+ );
391
+ }
392
+ return cssText;
393
+ }
394
+ function escapeImportStatement(rule2) {
395
+ const { cssText } = rule2;
396
+ if (cssText.split('"').length < 3) return cssText;
397
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
398
+ if (rule2.layerName === "") {
399
+ statement.push(`layer`);
400
+ } else if (rule2.layerName) {
401
+ statement.push(`layer(${rule2.layerName})`);
402
+ }
403
+ if (rule2.supportsText) {
404
+ statement.push(`supports(${rule2.supportsText})`);
405
+ }
406
+ if (rule2.media.length) {
407
+ statement.push(rule2.media.mediaText);
408
+ }
409
+ return statement.join(" ") + ";";
410
+ }
411
+ function stringifyStylesheet(s) {
412
+ try {
413
+ const rules = s.rules || s.cssRules;
414
+ if (!rules) {
415
+ return null;
416
+ }
417
+ let sheetHref = s.href;
418
+ if (!sheetHref && s.ownerNode) {
419
+ sheetHref = s.ownerNode.baseURI;
420
+ }
421
+ const stringifiedRules = Array.from(
422
+ rules,
423
+ (rule2) => stringifyRule(rule2, sheetHref)
424
+ ).join("");
425
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
426
+ } catch (error) {
427
+ return null;
428
+ }
429
+ }
430
+ function stringifyRule(rule2, sheetHref) {
431
+ var _a;
432
+ if (isCSSImportRule(rule2)) {
433
+ let importStringified;
434
+ try {
435
+ importStringified = // for same-origin stylesheets,
436
+ // we can access the imported stylesheet rules directly
437
+ stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
438
+ escapeImportStatement(rule2);
439
+ } catch (error) {
440
+ importStringified = rule2.cssText;
441
+ }
442
+ try {
443
+ if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
444
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
445
+ }
446
+ } catch (e) {
447
+ }
448
+ return importStringified;
449
+ } else {
450
+ let ruleStringified = rule2.cssText;
451
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
452
+ ruleStringified = fixSafariColons(ruleStringified);
453
+ }
454
+ if (sheetHref) {
455
+ return absolutifyURLs(ruleStringified, sheetHref);
456
+ }
457
+ return ruleStringified;
458
+ }
459
+ }
460
+ function fixSafariColons(cssStringified) {
461
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
462
+ return cssStringified.replace(regex, "$1\\$2");
463
+ }
464
+ function isCSSImportRule(rule2) {
465
+ return "styleSheet" in rule2;
466
+ }
467
+ function isCSSStyleRule(rule2) {
468
+ return "selectorText" in rule2;
469
+ }
470
470
  function extractOrigin(url) {
471
471
  let origin = "";
472
472
  if (url.indexOf("//") > -1) {
@@ -1438,6 +1438,15 @@ function visitSnapshot(node2, onVisit) {
1438
1438
  function cleanupSnapshot() {
1439
1439
  _id = 1;
1440
1440
  }
1441
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
1442
+ NodeType2[NodeType2["Document"] = 0] = "Document";
1443
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
1444
+ NodeType2[NodeType2["Element"] = 2] = "Element";
1445
+ NodeType2[NodeType2["Text"] = 3] = "Text";
1446
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
1447
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
1448
+ return NodeType2;
1449
+ })(NodeType || {});
1441
1450
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
1442
1451
  const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
1443
1452
  const mediaSelectorPlugin = {
@@ -5358,15 +5367,6 @@ function requireSafeParse() {
5358
5367
  }
5359
5368
  var safeParseExports = requireSafeParse();
5360
5369
  const safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParseExports);
5361
- var NodeType = /* @__PURE__ */ ((NodeType2) => {
5362
- NodeType2[NodeType2["Document"] = 0] = "Document";
5363
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
5364
- NodeType2[NodeType2["Element"] = 2] = "Element";
5365
- NodeType2[NodeType2["Text"] = 3] = "Text";
5366
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
5367
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
5368
- return NodeType2;
5369
- })(NodeType || {});
5370
5370
  var postcssExports = requirePostcss();
5371
5371
  const postcss = /* @__PURE__ */ getDefaultExportFromCjs(postcssExports);
5372
5372
  postcss.stringify;
@@ -5393,6 +5393,22 @@ postcss.Input;
5393
5393
  postcss.Rule;
5394
5394
  postcss.Root;
5395
5395
  postcss.Node;
5396
+ function adaptCssForReplay(cssText, cache) {
5397
+ const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
5398
+ if (cachedStyle) return cachedStyle;
5399
+ let result2 = cssText;
5400
+ try {
5401
+ const ast = postcss([
5402
+ mediaSelectorPlugin,
5403
+ pseudoClassPlugin
5404
+ ]).process(cssText, { parser: safeParser });
5405
+ result2 = ast.css;
5406
+ } catch (error) {
5407
+ console.warn("Failed to adapt css for replay", error);
5408
+ }
5409
+ cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
5410
+ return result2;
5411
+ }
5396
5412
  const tagMap = {
5397
5413
  script: "noscript",
5398
5414
  // camel case svg element tag names
@@ -5440,22 +5456,6 @@ function getTagName(n) {
5440
5456
  }
5441
5457
  return tagName;
5442
5458
  }
5443
- function adaptCssForReplay(cssText, cache) {
5444
- const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
5445
- if (cachedStyle) return cachedStyle;
5446
- let result2 = cssText;
5447
- try {
5448
- const ast = postcss([
5449
- mediaSelectorPlugin,
5450
- pseudoClassPlugin
5451
- ]).process(cssText, { parser: safeParser });
5452
- result2 = ast.css;
5453
- } catch (error) {
5454
- console.warn("Failed to adapt css for replay", error);
5455
- }
5456
- cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
5457
- return result2;
5458
- }
5459
5459
  function createCache() {
5460
5460
  const stylesWithHoverClass = /* @__PURE__ */ new Map();
5461
5461
  return {