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