@posthog/rrweb-record 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.
- package/dist/rrweb-record.cjs +128 -105
- package/dist/rrweb-record.cjs.map +1 -1
- package/dist/rrweb-record.js +128 -105
- package/dist/rrweb-record.js.map +1 -1
- package/dist/rrweb-record.umd.cjs +128 -105
- package/dist/rrweb-record.umd.cjs.map +2 -2
- package/dist/rrweb-record.umd.min.cjs +33 -33
- package/dist/rrweb-record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
|
@@ -251,91 +251,6 @@ function isShadowRoot(n2) {
|
|
|
251
251
|
function isNativeShadowDom(shadowRoot2) {
|
|
252
252
|
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
253
253
|
}
|
|
254
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
255
|
-
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
256
|
-
cssText = cssText.replace(
|
|
257
|
-
/\sbackground-clip:\s*text;/g,
|
|
258
|
-
" -webkit-background-clip: text; background-clip: text;"
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
return cssText;
|
|
262
|
-
}
|
|
263
|
-
function escapeImportStatement(rule2) {
|
|
264
|
-
const { cssText } = rule2;
|
|
265
|
-
if (cssText.split('"').length < 3) return cssText;
|
|
266
|
-
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
267
|
-
if (rule2.layerName === "") {
|
|
268
|
-
statement.push(`layer`);
|
|
269
|
-
} else if (rule2.layerName) {
|
|
270
|
-
statement.push(`layer(${rule2.layerName})`);
|
|
271
|
-
}
|
|
272
|
-
if (rule2.supportsText) {
|
|
273
|
-
statement.push(`supports(${rule2.supportsText})`);
|
|
274
|
-
}
|
|
275
|
-
if (rule2.media.length) {
|
|
276
|
-
statement.push(rule2.media.mediaText);
|
|
277
|
-
}
|
|
278
|
-
return statement.join(" ") + ";";
|
|
279
|
-
}
|
|
280
|
-
function stringifyStylesheet(s2) {
|
|
281
|
-
try {
|
|
282
|
-
const rules2 = s2.rules || s2.cssRules;
|
|
283
|
-
if (!rules2) {
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
|
-
let sheetHref = s2.href;
|
|
287
|
-
if (!sheetHref && s2.ownerNode) {
|
|
288
|
-
sheetHref = s2.ownerNode.baseURI;
|
|
289
|
-
}
|
|
290
|
-
const stringifiedRules = Array.from(
|
|
291
|
-
rules2,
|
|
292
|
-
(rule2) => stringifyRule(rule2, sheetHref)
|
|
293
|
-
).join("");
|
|
294
|
-
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
295
|
-
} catch (error) {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function stringifyRule(rule2, sheetHref) {
|
|
300
|
-
var _a2;
|
|
301
|
-
if (isCSSImportRule(rule2)) {
|
|
302
|
-
let importStringified;
|
|
303
|
-
try {
|
|
304
|
-
importStringified = // for same-origin stylesheets,
|
|
305
|
-
// we can access the imported stylesheet rules directly
|
|
306
|
-
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
307
|
-
escapeImportStatement(rule2);
|
|
308
|
-
} catch (error) {
|
|
309
|
-
importStringified = rule2.cssText;
|
|
310
|
-
}
|
|
311
|
-
try {
|
|
312
|
-
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
313
|
-
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
314
|
-
}
|
|
315
|
-
} catch (e) {
|
|
316
|
-
}
|
|
317
|
-
return importStringified;
|
|
318
|
-
} else {
|
|
319
|
-
let ruleStringified = rule2.cssText;
|
|
320
|
-
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
321
|
-
ruleStringified = fixSafariColons(ruleStringified);
|
|
322
|
-
}
|
|
323
|
-
if (sheetHref) {
|
|
324
|
-
return absolutifyURLs(ruleStringified, sheetHref);
|
|
325
|
-
}
|
|
326
|
-
return ruleStringified;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function fixSafariColons(cssStringified) {
|
|
330
|
-
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
331
|
-
return cssStringified.replace(regex, "$1\\$2");
|
|
332
|
-
}
|
|
333
|
-
function isCSSImportRule(rule2) {
|
|
334
|
-
return "styleSheet" in rule2;
|
|
335
|
-
}
|
|
336
|
-
function isCSSStyleRule(rule2) {
|
|
337
|
-
return "selectorText" in rule2;
|
|
338
|
-
}
|
|
339
254
|
class Mirror {
|
|
340
255
|
constructor() {
|
|
341
256
|
__publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
|
|
@@ -459,6 +374,91 @@ function extractFileExtension(path, baseURL) {
|
|
|
459
374
|
const match = url.pathname.match(regex);
|
|
460
375
|
return (_a2 = match == null ? void 0 : match[1]) != null ? _a2 : null;
|
|
461
376
|
}
|
|
377
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
378
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
379
|
+
cssText = cssText.replace(
|
|
380
|
+
/\sbackground-clip:\s*text;/g,
|
|
381
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
return cssText;
|
|
385
|
+
}
|
|
386
|
+
function escapeImportStatement(rule2) {
|
|
387
|
+
const { cssText } = rule2;
|
|
388
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
389
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
390
|
+
if (rule2.layerName === "") {
|
|
391
|
+
statement.push(`layer`);
|
|
392
|
+
} else if (rule2.layerName) {
|
|
393
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
394
|
+
}
|
|
395
|
+
if (rule2.supportsText) {
|
|
396
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
397
|
+
}
|
|
398
|
+
if (rule2.media.length) {
|
|
399
|
+
statement.push(rule2.media.mediaText);
|
|
400
|
+
}
|
|
401
|
+
return statement.join(" ") + ";";
|
|
402
|
+
}
|
|
403
|
+
function stringifyStylesheet(s2) {
|
|
404
|
+
try {
|
|
405
|
+
const rules2 = s2.rules || s2.cssRules;
|
|
406
|
+
if (!rules2) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
let sheetHref = s2.href;
|
|
410
|
+
if (!sheetHref && s2.ownerNode) {
|
|
411
|
+
sheetHref = s2.ownerNode.baseURI;
|
|
412
|
+
}
|
|
413
|
+
const stringifiedRules = Array.from(
|
|
414
|
+
rules2,
|
|
415
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
416
|
+
).join("");
|
|
417
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
418
|
+
} catch (error) {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function stringifyRule(rule2, sheetHref) {
|
|
423
|
+
var _a2;
|
|
424
|
+
if (isCSSImportRule(rule2)) {
|
|
425
|
+
let importStringified;
|
|
426
|
+
try {
|
|
427
|
+
importStringified = // for same-origin stylesheets,
|
|
428
|
+
// we can access the imported stylesheet rules directly
|
|
429
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
430
|
+
escapeImportStatement(rule2);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
importStringified = rule2.cssText;
|
|
433
|
+
}
|
|
434
|
+
try {
|
|
435
|
+
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
436
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
437
|
+
}
|
|
438
|
+
} catch (e) {
|
|
439
|
+
}
|
|
440
|
+
return importStringified;
|
|
441
|
+
} else {
|
|
442
|
+
let ruleStringified = rule2.cssText;
|
|
443
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
444
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
445
|
+
}
|
|
446
|
+
if (sheetHref) {
|
|
447
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
448
|
+
}
|
|
449
|
+
return ruleStringified;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function fixSafariColons(cssStringified) {
|
|
453
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
454
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
455
|
+
}
|
|
456
|
+
function isCSSImportRule(rule2) {
|
|
457
|
+
return "styleSheet" in rule2;
|
|
458
|
+
}
|
|
459
|
+
function isCSSStyleRule(rule2) {
|
|
460
|
+
return "selectorText" in rule2;
|
|
461
|
+
}
|
|
462
462
|
function extractOrigin(url) {
|
|
463
463
|
let origin = "";
|
|
464
464
|
if (url.indexOf("//") > -1) {
|
|
@@ -11508,6 +11508,9 @@ class IframeManager {
|
|
|
11508
11508
|
addLoadListener(cb) {
|
|
11509
11509
|
this.loadListener = cb;
|
|
11510
11510
|
}
|
|
11511
|
+
removeLoadListener() {
|
|
11512
|
+
this.loadListener = void 0;
|
|
11513
|
+
}
|
|
11511
11514
|
attachIframe(iframeEl, childSn) {
|
|
11512
11515
|
var _a2;
|
|
11513
11516
|
this.mutationCb({
|
|
@@ -11861,9 +11864,9 @@ const saveWebGLVar = (value, win, ctx) => {
|
|
|
11861
11864
|
}
|
|
11862
11865
|
return index2;
|
|
11863
11866
|
};
|
|
11864
|
-
function serializeArg(value, win, ctx) {
|
|
11867
|
+
function serializeArg(value, win, ctx, dataURLOptions) {
|
|
11865
11868
|
if (value instanceof Array) {
|
|
11866
|
-
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
11869
|
+
return value.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11867
11870
|
} else if (value === null) {
|
|
11868
11871
|
return value;
|
|
11869
11872
|
} else if (value instanceof Float32Array || value instanceof Float64Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Int16Array || value instanceof Int8Array || value instanceof Uint8ClampedArray) {
|
|
@@ -11889,7 +11892,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11889
11892
|
return {
|
|
11890
11893
|
rr_type: name,
|
|
11891
11894
|
args: [
|
|
11892
|
-
serializeArg(value.buffer, win, ctx),
|
|
11895
|
+
serializeArg(value.buffer, win, ctx, dataURLOptions),
|
|
11893
11896
|
value.byteOffset,
|
|
11894
11897
|
value.byteLength
|
|
11895
11898
|
]
|
|
@@ -11903,7 +11906,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11903
11906
|
};
|
|
11904
11907
|
} else if (value instanceof HTMLCanvasElement) {
|
|
11905
11908
|
const name = "HTMLImageElement";
|
|
11906
|
-
const src = value.toDataURL();
|
|
11909
|
+
const src = value.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
11907
11910
|
return {
|
|
11908
11911
|
rr_type: name,
|
|
11909
11912
|
src
|
|
@@ -11912,7 +11915,11 @@ function serializeArg(value, win, ctx) {
|
|
|
11912
11915
|
const name = value.constructor.name;
|
|
11913
11916
|
return {
|
|
11914
11917
|
rr_type: name,
|
|
11915
|
-
args: [
|
|
11918
|
+
args: [
|
|
11919
|
+
serializeArg(value.data, win, ctx, dataURLOptions),
|
|
11920
|
+
value.width,
|
|
11921
|
+
value.height
|
|
11922
|
+
]
|
|
11916
11923
|
};
|
|
11917
11924
|
} else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
|
|
11918
11925
|
const name = value.constructor.name;
|
|
@@ -11924,8 +11931,8 @@ function serializeArg(value, win, ctx) {
|
|
|
11924
11931
|
}
|
|
11925
11932
|
return value;
|
|
11926
11933
|
}
|
|
11927
|
-
const serializeArgs = (args, win, ctx) => {
|
|
11928
|
-
return args.map((arg) => serializeArg(arg, win, ctx));
|
|
11934
|
+
const serializeArgs = (args, win, ctx, dataURLOptions) => {
|
|
11935
|
+
return args.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11929
11936
|
};
|
|
11930
11937
|
const isInstanceOfWebGLObject = (value, win) => {
|
|
11931
11938
|
const webGLConstructorNames = [
|
|
@@ -11951,7 +11958,7 @@ const isInstanceOfWebGLObject = (value, win) => {
|
|
|
11951
11958
|
)
|
|
11952
11959
|
);
|
|
11953
11960
|
};
|
|
11954
|
-
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
11961
|
+
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
11955
11962
|
const handlers = [];
|
|
11956
11963
|
const props2D = Object.getOwnPropertyNames(
|
|
11957
11964
|
win.CanvasRenderingContext2D.prototype
|
|
@@ -11968,7 +11975,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
11968
11975
|
return function(...args) {
|
|
11969
11976
|
if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
11970
11977
|
setTimeout(() => {
|
|
11971
|
-
const recordArgs = serializeArgs(
|
|
11978
|
+
const recordArgs = serializeArgs(
|
|
11979
|
+
args,
|
|
11980
|
+
win,
|
|
11981
|
+
this,
|
|
11982
|
+
dataURLOptions
|
|
11983
|
+
);
|
|
11972
11984
|
cb(this.canvas, {
|
|
11973
11985
|
type: CanvasContext["2D"],
|
|
11974
11986
|
property: prop,
|
|
@@ -12042,7 +12054,7 @@ function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDr
|
|
|
12042
12054
|
handlers.forEach((h) => h());
|
|
12043
12055
|
};
|
|
12044
12056
|
}
|
|
12045
|
-
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
12057
|
+
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, dataURLOptions) {
|
|
12046
12058
|
const handlers = [];
|
|
12047
12059
|
const props = Object.getOwnPropertyNames(prototype);
|
|
12048
12060
|
for (const prop of props) {
|
|
@@ -12069,7 +12081,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12069
12081
|
const result2 = original.apply(this, args);
|
|
12070
12082
|
saveWebGLVar(result2, win, this);
|
|
12071
12083
|
if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
12072
|
-
const recordArgs = serializeArgs(args, win, this);
|
|
12084
|
+
const recordArgs = serializeArgs(args, win, this, dataURLOptions);
|
|
12073
12085
|
const mutation = {
|
|
12074
12086
|
type,
|
|
12075
12087
|
property: prop,
|
|
@@ -12098,7 +12110,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12098
12110
|
}
|
|
12099
12111
|
return handlers;
|
|
12100
12112
|
}
|
|
12101
|
-
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
12113
|
+
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
12102
12114
|
const handlers = [];
|
|
12103
12115
|
handlers.push(
|
|
12104
12116
|
...patchGLPrototype(
|
|
@@ -12107,7 +12119,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12107
12119
|
cb,
|
|
12108
12120
|
blockClass,
|
|
12109
12121
|
blockSelector,
|
|
12110
|
-
win
|
|
12122
|
+
win,
|
|
12123
|
+
dataURLOptions
|
|
12111
12124
|
)
|
|
12112
12125
|
);
|
|
12113
12126
|
if (typeof win.WebGL2RenderingContext !== "undefined") {
|
|
@@ -12118,7 +12131,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12118
12131
|
cb,
|
|
12119
12132
|
blockClass,
|
|
12120
12133
|
blockSelector,
|
|
12121
|
-
win
|
|
12134
|
+
win,
|
|
12135
|
+
dataURLOptions
|
|
12122
12136
|
)
|
|
12123
12137
|
);
|
|
12124
12138
|
}
|
|
@@ -12180,7 +12194,12 @@ class CanvasManager {
|
|
|
12180
12194
|
this.mutationCb = options.mutationCb;
|
|
12181
12195
|
this.mirror = options.mirror;
|
|
12182
12196
|
if (recordCanvas && sampling === "all")
|
|
12183
|
-
this.initCanvasMutationObserver(
|
|
12197
|
+
this.initCanvasMutationObserver(
|
|
12198
|
+
win,
|
|
12199
|
+
blockClass,
|
|
12200
|
+
blockSelector,
|
|
12201
|
+
dataURLOptions
|
|
12202
|
+
);
|
|
12184
12203
|
if (recordCanvas && typeof sampling === "number")
|
|
12185
12204
|
this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
|
|
12186
12205
|
dataURLOptions
|
|
@@ -12309,7 +12328,7 @@ class CanvasManager {
|
|
|
12309
12328
|
cancelAnimationFrame(rafId);
|
|
12310
12329
|
};
|
|
12311
12330
|
}
|
|
12312
|
-
initCanvasMutationObserver(win, blockClass, blockSelector) {
|
|
12331
|
+
initCanvasMutationObserver(win, blockClass, blockSelector, dataURLOptions) {
|
|
12313
12332
|
this.startRAFTimestamping();
|
|
12314
12333
|
this.startPendingCanvasMutationFlusher();
|
|
12315
12334
|
const canvasContextReset = initCanvasContextObserver(
|
|
@@ -12322,13 +12341,15 @@ class CanvasManager {
|
|
|
12322
12341
|
this.processMutation.bind(this),
|
|
12323
12342
|
win,
|
|
12324
12343
|
blockClass,
|
|
12325
|
-
blockSelector
|
|
12344
|
+
blockSelector,
|
|
12345
|
+
dataURLOptions
|
|
12326
12346
|
);
|
|
12327
12347
|
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(
|
|
12328
12348
|
this.processMutation.bind(this),
|
|
12329
12349
|
win,
|
|
12330
12350
|
blockClass,
|
|
12331
|
-
blockSelector
|
|
12351
|
+
blockSelector,
|
|
12352
|
+
dataURLOptions
|
|
12332
12353
|
);
|
|
12333
12354
|
this.resetObservers = () => {
|
|
12334
12355
|
canvasContextReset();
|
|
@@ -12875,13 +12896,14 @@ function record(options = {}) {
|
|
|
12875
12896
|
hooks
|
|
12876
12897
|
);
|
|
12877
12898
|
};
|
|
12878
|
-
|
|
12899
|
+
const loadListener = (iframeEl) => {
|
|
12879
12900
|
try {
|
|
12880
12901
|
handlers.push(observe(iframeEl.contentDocument));
|
|
12881
12902
|
} catch (error) {
|
|
12882
12903
|
console.warn(error);
|
|
12883
12904
|
}
|
|
12884
|
-
}
|
|
12905
|
+
};
|
|
12906
|
+
iframeManager.addLoadListener(loadListener);
|
|
12885
12907
|
const init = () => {
|
|
12886
12908
|
takeFullSnapshot$1();
|
|
12887
12909
|
handlers.push(observe(document));
|
|
@@ -12916,6 +12938,7 @@ function record(options = {}) {
|
|
|
12916
12938
|
return () => {
|
|
12917
12939
|
handlers.forEach((h) => h());
|
|
12918
12940
|
processedNodeManager.destroy();
|
|
12941
|
+
iframeManager.removeLoadListener();
|
|
12919
12942
|
iframeManager.destroy();
|
|
12920
12943
|
recording = false;
|
|
12921
12944
|
unregisterErrorHandler();
|