@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
package/dist/rrweb-record.js
CHANGED
|
@@ -205,91 +205,6 @@ function isShadowRoot(n2) {
|
|
|
205
205
|
function isNativeShadowDom(shadowRoot2) {
|
|
206
206
|
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
207
207
|
}
|
|
208
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
209
|
-
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
210
|
-
cssText = cssText.replace(
|
|
211
|
-
/\sbackground-clip:\s*text;/g,
|
|
212
|
-
" -webkit-background-clip: text; background-clip: text;"
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
return cssText;
|
|
216
|
-
}
|
|
217
|
-
function escapeImportStatement(rule2) {
|
|
218
|
-
const { cssText } = rule2;
|
|
219
|
-
if (cssText.split('"').length < 3) return cssText;
|
|
220
|
-
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
221
|
-
if (rule2.layerName === "") {
|
|
222
|
-
statement.push(`layer`);
|
|
223
|
-
} else if (rule2.layerName) {
|
|
224
|
-
statement.push(`layer(${rule2.layerName})`);
|
|
225
|
-
}
|
|
226
|
-
if (rule2.supportsText) {
|
|
227
|
-
statement.push(`supports(${rule2.supportsText})`);
|
|
228
|
-
}
|
|
229
|
-
if (rule2.media.length) {
|
|
230
|
-
statement.push(rule2.media.mediaText);
|
|
231
|
-
}
|
|
232
|
-
return statement.join(" ") + ";";
|
|
233
|
-
}
|
|
234
|
-
function stringifyStylesheet(s2) {
|
|
235
|
-
try {
|
|
236
|
-
const rules2 = s2.rules || s2.cssRules;
|
|
237
|
-
if (!rules2) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
let sheetHref = s2.href;
|
|
241
|
-
if (!sheetHref && s2.ownerNode) {
|
|
242
|
-
sheetHref = s2.ownerNode.baseURI;
|
|
243
|
-
}
|
|
244
|
-
const stringifiedRules = Array.from(
|
|
245
|
-
rules2,
|
|
246
|
-
(rule2) => stringifyRule(rule2, sheetHref)
|
|
247
|
-
).join("");
|
|
248
|
-
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
249
|
-
} catch (error) {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function stringifyRule(rule2, sheetHref) {
|
|
254
|
-
var _a2;
|
|
255
|
-
if (isCSSImportRule(rule2)) {
|
|
256
|
-
let importStringified;
|
|
257
|
-
try {
|
|
258
|
-
importStringified = // for same-origin stylesheets,
|
|
259
|
-
// we can access the imported stylesheet rules directly
|
|
260
|
-
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
261
|
-
escapeImportStatement(rule2);
|
|
262
|
-
} catch (error) {
|
|
263
|
-
importStringified = rule2.cssText;
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
267
|
-
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
268
|
-
}
|
|
269
|
-
} catch {
|
|
270
|
-
}
|
|
271
|
-
return importStringified;
|
|
272
|
-
} else {
|
|
273
|
-
let ruleStringified = rule2.cssText;
|
|
274
|
-
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
275
|
-
ruleStringified = fixSafariColons(ruleStringified);
|
|
276
|
-
}
|
|
277
|
-
if (sheetHref) {
|
|
278
|
-
return absolutifyURLs(ruleStringified, sheetHref);
|
|
279
|
-
}
|
|
280
|
-
return ruleStringified;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
function fixSafariColons(cssStringified) {
|
|
284
|
-
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
285
|
-
return cssStringified.replace(regex, "$1\\$2");
|
|
286
|
-
}
|
|
287
|
-
function isCSSImportRule(rule2) {
|
|
288
|
-
return "styleSheet" in rule2;
|
|
289
|
-
}
|
|
290
|
-
function isCSSStyleRule(rule2) {
|
|
291
|
-
return "selectorText" in rule2;
|
|
292
|
-
}
|
|
293
208
|
class Mirror {
|
|
294
209
|
constructor() {
|
|
295
210
|
__publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
|
|
@@ -412,6 +327,91 @@ function extractFileExtension(path, baseURL) {
|
|
|
412
327
|
const match = url.pathname.match(regex);
|
|
413
328
|
return (match == null ? void 0 : match[1]) ?? null;
|
|
414
329
|
}
|
|
330
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
331
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
332
|
+
cssText = cssText.replace(
|
|
333
|
+
/\sbackground-clip:\s*text;/g,
|
|
334
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return cssText;
|
|
338
|
+
}
|
|
339
|
+
function escapeImportStatement(rule2) {
|
|
340
|
+
const { cssText } = rule2;
|
|
341
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
342
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
343
|
+
if (rule2.layerName === "") {
|
|
344
|
+
statement.push(`layer`);
|
|
345
|
+
} else if (rule2.layerName) {
|
|
346
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
347
|
+
}
|
|
348
|
+
if (rule2.supportsText) {
|
|
349
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
350
|
+
}
|
|
351
|
+
if (rule2.media.length) {
|
|
352
|
+
statement.push(rule2.media.mediaText);
|
|
353
|
+
}
|
|
354
|
+
return statement.join(" ") + ";";
|
|
355
|
+
}
|
|
356
|
+
function stringifyStylesheet(s2) {
|
|
357
|
+
try {
|
|
358
|
+
const rules2 = s2.rules || s2.cssRules;
|
|
359
|
+
if (!rules2) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
let sheetHref = s2.href;
|
|
363
|
+
if (!sheetHref && s2.ownerNode) {
|
|
364
|
+
sheetHref = s2.ownerNode.baseURI;
|
|
365
|
+
}
|
|
366
|
+
const stringifiedRules = Array.from(
|
|
367
|
+
rules2,
|
|
368
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
369
|
+
).join("");
|
|
370
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function stringifyRule(rule2, sheetHref) {
|
|
376
|
+
var _a2;
|
|
377
|
+
if (isCSSImportRule(rule2)) {
|
|
378
|
+
let importStringified;
|
|
379
|
+
try {
|
|
380
|
+
importStringified = // for same-origin stylesheets,
|
|
381
|
+
// we can access the imported stylesheet rules directly
|
|
382
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
383
|
+
escapeImportStatement(rule2);
|
|
384
|
+
} catch (error) {
|
|
385
|
+
importStringified = rule2.cssText;
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
389
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
390
|
+
}
|
|
391
|
+
} catch {
|
|
392
|
+
}
|
|
393
|
+
return importStringified;
|
|
394
|
+
} else {
|
|
395
|
+
let ruleStringified = rule2.cssText;
|
|
396
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
397
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
398
|
+
}
|
|
399
|
+
if (sheetHref) {
|
|
400
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
401
|
+
}
|
|
402
|
+
return ruleStringified;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function fixSafariColons(cssStringified) {
|
|
406
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
407
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
408
|
+
}
|
|
409
|
+
function isCSSImportRule(rule2) {
|
|
410
|
+
return "styleSheet" in rule2;
|
|
411
|
+
}
|
|
412
|
+
function isCSSStyleRule(rule2) {
|
|
413
|
+
return "selectorText" in rule2;
|
|
414
|
+
}
|
|
415
415
|
function extractOrigin(url) {
|
|
416
416
|
let origin = "";
|
|
417
417
|
if (url.indexOf("//") > -1) {
|
|
@@ -11464,6 +11464,9 @@ class IframeManager {
|
|
|
11464
11464
|
addLoadListener(cb) {
|
|
11465
11465
|
this.loadListener = cb;
|
|
11466
11466
|
}
|
|
11467
|
+
removeLoadListener() {
|
|
11468
|
+
this.loadListener = void 0;
|
|
11469
|
+
}
|
|
11467
11470
|
attachIframe(iframeEl, childSn) {
|
|
11468
11471
|
var _a2;
|
|
11469
11472
|
this.mutationCb({
|
|
@@ -11819,9 +11822,9 @@ const saveWebGLVar = (value, win, ctx) => {
|
|
|
11819
11822
|
}
|
|
11820
11823
|
return index2;
|
|
11821
11824
|
};
|
|
11822
|
-
function serializeArg(value, win, ctx) {
|
|
11825
|
+
function serializeArg(value, win, ctx, dataURLOptions) {
|
|
11823
11826
|
if (value instanceof Array) {
|
|
11824
|
-
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
11827
|
+
return value.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11825
11828
|
} else if (value === null) {
|
|
11826
11829
|
return value;
|
|
11827
11830
|
} 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) {
|
|
@@ -11847,7 +11850,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11847
11850
|
return {
|
|
11848
11851
|
rr_type: name,
|
|
11849
11852
|
args: [
|
|
11850
|
-
serializeArg(value.buffer, win, ctx),
|
|
11853
|
+
serializeArg(value.buffer, win, ctx, dataURLOptions),
|
|
11851
11854
|
value.byteOffset,
|
|
11852
11855
|
value.byteLength
|
|
11853
11856
|
]
|
|
@@ -11861,7 +11864,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11861
11864
|
};
|
|
11862
11865
|
} else if (value instanceof HTMLCanvasElement) {
|
|
11863
11866
|
const name = "HTMLImageElement";
|
|
11864
|
-
const src = value.toDataURL();
|
|
11867
|
+
const src = value.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
11865
11868
|
return {
|
|
11866
11869
|
rr_type: name,
|
|
11867
11870
|
src
|
|
@@ -11870,7 +11873,11 @@ function serializeArg(value, win, ctx) {
|
|
|
11870
11873
|
const name = value.constructor.name;
|
|
11871
11874
|
return {
|
|
11872
11875
|
rr_type: name,
|
|
11873
|
-
args: [
|
|
11876
|
+
args: [
|
|
11877
|
+
serializeArg(value.data, win, ctx, dataURLOptions),
|
|
11878
|
+
value.width,
|
|
11879
|
+
value.height
|
|
11880
|
+
]
|
|
11874
11881
|
};
|
|
11875
11882
|
} else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
|
|
11876
11883
|
const name = value.constructor.name;
|
|
@@ -11882,8 +11889,8 @@ function serializeArg(value, win, ctx) {
|
|
|
11882
11889
|
}
|
|
11883
11890
|
return value;
|
|
11884
11891
|
}
|
|
11885
|
-
const serializeArgs = (args, win, ctx) => {
|
|
11886
|
-
return args.map((arg) => serializeArg(arg, win, ctx));
|
|
11892
|
+
const serializeArgs = (args, win, ctx, dataURLOptions) => {
|
|
11893
|
+
return args.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11887
11894
|
};
|
|
11888
11895
|
const isInstanceOfWebGLObject = (value, win) => {
|
|
11889
11896
|
const webGLConstructorNames = [
|
|
@@ -11909,7 +11916,7 @@ const isInstanceOfWebGLObject = (value, win) => {
|
|
|
11909
11916
|
)
|
|
11910
11917
|
);
|
|
11911
11918
|
};
|
|
11912
|
-
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
11919
|
+
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
11913
11920
|
const handlers = [];
|
|
11914
11921
|
const props2D = Object.getOwnPropertyNames(
|
|
11915
11922
|
win.CanvasRenderingContext2D.prototype
|
|
@@ -11926,7 +11933,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
11926
11933
|
return function(...args) {
|
|
11927
11934
|
if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
11928
11935
|
setTimeout(() => {
|
|
11929
|
-
const recordArgs = serializeArgs(
|
|
11936
|
+
const recordArgs = serializeArgs(
|
|
11937
|
+
args,
|
|
11938
|
+
win,
|
|
11939
|
+
this,
|
|
11940
|
+
dataURLOptions
|
|
11941
|
+
);
|
|
11930
11942
|
cb(this.canvas, {
|
|
11931
11943
|
type: CanvasContext["2D"],
|
|
11932
11944
|
property: prop,
|
|
@@ -12000,7 +12012,7 @@ function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDr
|
|
|
12000
12012
|
handlers.forEach((h) => h());
|
|
12001
12013
|
};
|
|
12002
12014
|
}
|
|
12003
|
-
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
12015
|
+
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, dataURLOptions) {
|
|
12004
12016
|
const handlers = [];
|
|
12005
12017
|
const props = Object.getOwnPropertyNames(prototype);
|
|
12006
12018
|
for (const prop of props) {
|
|
@@ -12027,7 +12039,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12027
12039
|
const result2 = original.apply(this, args);
|
|
12028
12040
|
saveWebGLVar(result2, win, this);
|
|
12029
12041
|
if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
12030
|
-
const recordArgs = serializeArgs(args, win, this);
|
|
12042
|
+
const recordArgs = serializeArgs(args, win, this, dataURLOptions);
|
|
12031
12043
|
const mutation = {
|
|
12032
12044
|
type,
|
|
12033
12045
|
property: prop,
|
|
@@ -12056,7 +12068,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12056
12068
|
}
|
|
12057
12069
|
return handlers;
|
|
12058
12070
|
}
|
|
12059
|
-
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
12071
|
+
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
12060
12072
|
const handlers = [];
|
|
12061
12073
|
handlers.push(
|
|
12062
12074
|
...patchGLPrototype(
|
|
@@ -12065,7 +12077,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12065
12077
|
cb,
|
|
12066
12078
|
blockClass,
|
|
12067
12079
|
blockSelector,
|
|
12068
|
-
win
|
|
12080
|
+
win,
|
|
12081
|
+
dataURLOptions
|
|
12069
12082
|
)
|
|
12070
12083
|
);
|
|
12071
12084
|
if (typeof win.WebGL2RenderingContext !== "undefined") {
|
|
@@ -12076,7 +12089,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12076
12089
|
cb,
|
|
12077
12090
|
blockClass,
|
|
12078
12091
|
blockSelector,
|
|
12079
|
-
win
|
|
12092
|
+
win,
|
|
12093
|
+
dataURLOptions
|
|
12080
12094
|
)
|
|
12081
12095
|
);
|
|
12082
12096
|
}
|
|
@@ -12138,7 +12152,12 @@ class CanvasManager {
|
|
|
12138
12152
|
this.mutationCb = options.mutationCb;
|
|
12139
12153
|
this.mirror = options.mirror;
|
|
12140
12154
|
if (recordCanvas && sampling === "all")
|
|
12141
|
-
this.initCanvasMutationObserver(
|
|
12155
|
+
this.initCanvasMutationObserver(
|
|
12156
|
+
win,
|
|
12157
|
+
blockClass,
|
|
12158
|
+
blockSelector,
|
|
12159
|
+
dataURLOptions
|
|
12160
|
+
);
|
|
12142
12161
|
if (recordCanvas && typeof sampling === "number")
|
|
12143
12162
|
this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
|
|
12144
12163
|
dataURLOptions
|
|
@@ -12267,7 +12286,7 @@ class CanvasManager {
|
|
|
12267
12286
|
cancelAnimationFrame(rafId);
|
|
12268
12287
|
};
|
|
12269
12288
|
}
|
|
12270
|
-
initCanvasMutationObserver(win, blockClass, blockSelector) {
|
|
12289
|
+
initCanvasMutationObserver(win, blockClass, blockSelector, dataURLOptions) {
|
|
12271
12290
|
this.startRAFTimestamping();
|
|
12272
12291
|
this.startPendingCanvasMutationFlusher();
|
|
12273
12292
|
const canvasContextReset = initCanvasContextObserver(
|
|
@@ -12280,13 +12299,15 @@ class CanvasManager {
|
|
|
12280
12299
|
this.processMutation.bind(this),
|
|
12281
12300
|
win,
|
|
12282
12301
|
blockClass,
|
|
12283
|
-
blockSelector
|
|
12302
|
+
blockSelector,
|
|
12303
|
+
dataURLOptions
|
|
12284
12304
|
);
|
|
12285
12305
|
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(
|
|
12286
12306
|
this.processMutation.bind(this),
|
|
12287
12307
|
win,
|
|
12288
12308
|
blockClass,
|
|
12289
|
-
blockSelector
|
|
12309
|
+
blockSelector,
|
|
12310
|
+
dataURLOptions
|
|
12290
12311
|
);
|
|
12291
12312
|
this.resetObservers = () => {
|
|
12292
12313
|
canvasContextReset();
|
|
@@ -12846,13 +12867,14 @@ function record(options = {}) {
|
|
|
12846
12867
|
hooks
|
|
12847
12868
|
);
|
|
12848
12869
|
};
|
|
12849
|
-
|
|
12870
|
+
const loadListener = (iframeEl) => {
|
|
12850
12871
|
try {
|
|
12851
12872
|
handlers.push(observe(iframeEl.contentDocument));
|
|
12852
12873
|
} catch (error) {
|
|
12853
12874
|
console.warn(error);
|
|
12854
12875
|
}
|
|
12855
|
-
}
|
|
12876
|
+
};
|
|
12877
|
+
iframeManager.addLoadListener(loadListener);
|
|
12856
12878
|
const init = () => {
|
|
12857
12879
|
takeFullSnapshot$1();
|
|
12858
12880
|
handlers.push(observe(document));
|
|
@@ -12887,6 +12909,7 @@ function record(options = {}) {
|
|
|
12887
12909
|
return () => {
|
|
12888
12910
|
handlers.forEach((h) => h());
|
|
12889
12911
|
processedNodeManager.destroy();
|
|
12912
|
+
iframeManager.removeLoadListener();
|
|
12890
12913
|
iframeManager.destroy();
|
|
12891
12914
|
recording = false;
|
|
12892
12915
|
unregisterErrorHandler();
|