@posthog/rrweb-snapshot 0.0.26 → 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.
@@ -203,91 +203,6 @@ function isShadowRoot(n) {
203
203
  function isNativeShadowDom(shadowRoot2) {
204
204
  return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
205
205
  }
206
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
207
- if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
208
- cssText = cssText.replace(
209
- /\sbackground-clip:\s*text;/g,
210
- " -webkit-background-clip: text; background-clip: text;"
211
- );
212
- }
213
- return cssText;
214
- }
215
- function escapeImportStatement(rule2) {
216
- const { cssText } = rule2;
217
- if (cssText.split('"').length < 3) return cssText;
218
- const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
219
- if (rule2.layerName === "") {
220
- statement.push(`layer`);
221
- } else if (rule2.layerName) {
222
- statement.push(`layer(${rule2.layerName})`);
223
- }
224
- if (rule2.supportsText) {
225
- statement.push(`supports(${rule2.supportsText})`);
226
- }
227
- if (rule2.media.length) {
228
- statement.push(rule2.media.mediaText);
229
- }
230
- return statement.join(" ") + ";";
231
- }
232
- function stringifyStylesheet(s) {
233
- try {
234
- const rules = s.rules || s.cssRules;
235
- if (!rules) {
236
- return null;
237
- }
238
- let sheetHref = s.href;
239
- if (!sheetHref && s.ownerNode) {
240
- sheetHref = s.ownerNode.baseURI;
241
- }
242
- const stringifiedRules = Array.from(
243
- rules,
244
- (rule2) => stringifyRule(rule2, sheetHref)
245
- ).join("");
246
- return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
247
- } catch (error) {
248
- return null;
249
- }
250
- }
251
- function stringifyRule(rule2, sheetHref) {
252
- var _a;
253
- if (isCSSImportRule(rule2)) {
254
- let importStringified;
255
- try {
256
- importStringified = // for same-origin stylesheets,
257
- // we can access the imported stylesheet rules directly
258
- stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
259
- escapeImportStatement(rule2);
260
- } catch (error) {
261
- importStringified = rule2.cssText;
262
- }
263
- try {
264
- if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
265
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
266
- }
267
- } catch {
268
- }
269
- return importStringified;
270
- } else {
271
- let ruleStringified = rule2.cssText;
272
- if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
273
- ruleStringified = fixSafariColons(ruleStringified);
274
- }
275
- if (sheetHref) {
276
- return absolutifyURLs(ruleStringified, sheetHref);
277
- }
278
- return ruleStringified;
279
- }
280
- }
281
- function fixSafariColons(cssStringified) {
282
- const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
283
- return cssStringified.replace(regex, "$1\\$2");
284
- }
285
- function isCSSImportRule(rule2) {
286
- return "styleSheet" in rule2;
287
- }
288
- function isCSSStyleRule(rule2) {
289
- return "selectorText" in rule2;
290
- }
291
206
  class Mirror {
292
207
  constructor() {
293
208
  __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -422,6 +337,91 @@ function extractFileExtension(path, baseURL) {
422
337
  const match = url.pathname.match(regex);
423
338
  return (match == null ? void 0 : match[1]) ?? null;
424
339
  }
340
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
341
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
342
+ cssText = cssText.replace(
343
+ /\sbackground-clip:\s*text;/g,
344
+ " -webkit-background-clip: text; background-clip: text;"
345
+ );
346
+ }
347
+ return cssText;
348
+ }
349
+ function escapeImportStatement(rule2) {
350
+ const { cssText } = rule2;
351
+ if (cssText.split('"').length < 3) return cssText;
352
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
353
+ if (rule2.layerName === "") {
354
+ statement.push(`layer`);
355
+ } else if (rule2.layerName) {
356
+ statement.push(`layer(${rule2.layerName})`);
357
+ }
358
+ if (rule2.supportsText) {
359
+ statement.push(`supports(${rule2.supportsText})`);
360
+ }
361
+ if (rule2.media.length) {
362
+ statement.push(rule2.media.mediaText);
363
+ }
364
+ return statement.join(" ") + ";";
365
+ }
366
+ function stringifyStylesheet(s) {
367
+ try {
368
+ const rules = s.rules || s.cssRules;
369
+ if (!rules) {
370
+ return null;
371
+ }
372
+ let sheetHref = s.href;
373
+ if (!sheetHref && s.ownerNode) {
374
+ sheetHref = s.ownerNode.baseURI;
375
+ }
376
+ const stringifiedRules = Array.from(
377
+ rules,
378
+ (rule2) => stringifyRule(rule2, sheetHref)
379
+ ).join("");
380
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
381
+ } catch (error) {
382
+ return null;
383
+ }
384
+ }
385
+ function stringifyRule(rule2, sheetHref) {
386
+ var _a;
387
+ if (isCSSImportRule(rule2)) {
388
+ let importStringified;
389
+ try {
390
+ importStringified = // for same-origin stylesheets,
391
+ // we can access the imported stylesheet rules directly
392
+ stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
393
+ escapeImportStatement(rule2);
394
+ } catch (error) {
395
+ importStringified = rule2.cssText;
396
+ }
397
+ try {
398
+ if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
399
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
400
+ }
401
+ } catch {
402
+ }
403
+ return importStringified;
404
+ } else {
405
+ let ruleStringified = rule2.cssText;
406
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
407
+ ruleStringified = fixSafariColons(ruleStringified);
408
+ }
409
+ if (sheetHref) {
410
+ return absolutifyURLs(ruleStringified, sheetHref);
411
+ }
412
+ return ruleStringified;
413
+ }
414
+ }
415
+ function fixSafariColons(cssStringified) {
416
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
417
+ return cssStringified.replace(regex, "$1\\$2");
418
+ }
419
+ function isCSSImportRule(rule2) {
420
+ return "styleSheet" in rule2;
421
+ }
422
+ function isCSSStyleRule(rule2) {
423
+ return "selectorText" in rule2;
424
+ }
425
425
  function extractOrigin(url) {
426
426
  let origin = "";
427
427
  if (url.indexOf("//") > -1) {
@@ -1393,6 +1393,15 @@ function visitSnapshot(node2, onVisit) {
1393
1393
  function cleanupSnapshot() {
1394
1394
  _id = 1;
1395
1395
  }
1396
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
1397
+ NodeType2[NodeType2["Document"] = 0] = "Document";
1398
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
1399
+ NodeType2[NodeType2["Element"] = 2] = "Element";
1400
+ NodeType2[NodeType2["Text"] = 3] = "Text";
1401
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
1402
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
1403
+ return NodeType2;
1404
+ })(NodeType || {});
1396
1405
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
1397
1406
  const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
1398
1407
  const mediaSelectorPlugin = {
@@ -5314,15 +5323,6 @@ function requireSafeParse() {
5314
5323
  }
5315
5324
  var safeParseExports = requireSafeParse();
5316
5325
  const safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParseExports);
5317
- var NodeType = /* @__PURE__ */ ((NodeType2) => {
5318
- NodeType2[NodeType2["Document"] = 0] = "Document";
5319
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
5320
- NodeType2[NodeType2["Element"] = 2] = "Element";
5321
- NodeType2[NodeType2["Text"] = 3] = "Text";
5322
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
5323
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
5324
- return NodeType2;
5325
- })(NodeType || {});
5326
5326
  var postcssExports = requirePostcss();
5327
5327
  const postcss = /* @__PURE__ */ getDefaultExportFromCjs(postcssExports);
5328
5328
  postcss.stringify;
@@ -5349,6 +5349,22 @@ postcss.Input;
5349
5349
  postcss.Rule;
5350
5350
  postcss.Root;
5351
5351
  postcss.Node;
5352
+ function adaptCssForReplay(cssText, cache) {
5353
+ const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
5354
+ if (cachedStyle) return cachedStyle;
5355
+ let result2 = cssText;
5356
+ try {
5357
+ const ast = postcss([
5358
+ mediaSelectorPlugin,
5359
+ pseudoClassPlugin
5360
+ ]).process(cssText, { parser: safeParser });
5361
+ result2 = ast.css;
5362
+ } catch (error) {
5363
+ console.warn("Failed to adapt css for replay", error);
5364
+ }
5365
+ cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
5366
+ return result2;
5367
+ }
5352
5368
  const tagMap = {
5353
5369
  script: "noscript",
5354
5370
  // camel case svg element tag names
@@ -5396,22 +5412,6 @@ function getTagName(n) {
5396
5412
  }
5397
5413
  return tagName;
5398
5414
  }
5399
- function adaptCssForReplay(cssText, cache) {
5400
- const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
5401
- if (cachedStyle) return cachedStyle;
5402
- let result2 = cssText;
5403
- try {
5404
- const ast = postcss([
5405
- mediaSelectorPlugin,
5406
- pseudoClassPlugin
5407
- ]).process(cssText, { parser: safeParser });
5408
- result2 = ast.css;
5409
- } catch (error) {
5410
- console.warn("Failed to adapt css for replay", error);
5411
- }
5412
- cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
5413
- return result2;
5414
- }
5415
5415
  function createCache() {
5416
5416
  const stylesWithHoverClass = /* @__PURE__ */ new Map();
5417
5417
  return {