@posthog/rrweb-record 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.
- package/dist/rrweb-record.cjs +121 -103
- package/dist/rrweb-record.cjs.map +1 -1
- package/dist/rrweb-record.js +121 -103
- package/dist/rrweb-record.js.map +1 -1
- package/dist/rrweb-record.umd.cjs +121 -103
- package/dist/rrweb-record.umd.cjs.map +2 -2
- package/dist/rrweb-record.umd.min.cjs +31 -31
- package/dist/rrweb-record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/rrweb-record.cjs
CHANGED
|
@@ -207,91 +207,6 @@ function isShadowRoot(n2) {
|
|
|
207
207
|
function isNativeShadowDom(shadowRoot2) {
|
|
208
208
|
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
209
209
|
}
|
|
210
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
211
|
-
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
212
|
-
cssText = cssText.replace(
|
|
213
|
-
/\sbackground-clip:\s*text;/g,
|
|
214
|
-
" -webkit-background-clip: text; background-clip: text;"
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
return cssText;
|
|
218
|
-
}
|
|
219
|
-
function escapeImportStatement(rule2) {
|
|
220
|
-
const { cssText } = rule2;
|
|
221
|
-
if (cssText.split('"').length < 3) return cssText;
|
|
222
|
-
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
223
|
-
if (rule2.layerName === "") {
|
|
224
|
-
statement.push(`layer`);
|
|
225
|
-
} else if (rule2.layerName) {
|
|
226
|
-
statement.push(`layer(${rule2.layerName})`);
|
|
227
|
-
}
|
|
228
|
-
if (rule2.supportsText) {
|
|
229
|
-
statement.push(`supports(${rule2.supportsText})`);
|
|
230
|
-
}
|
|
231
|
-
if (rule2.media.length) {
|
|
232
|
-
statement.push(rule2.media.mediaText);
|
|
233
|
-
}
|
|
234
|
-
return statement.join(" ") + ";";
|
|
235
|
-
}
|
|
236
|
-
function stringifyStylesheet(s2) {
|
|
237
|
-
try {
|
|
238
|
-
const rules2 = s2.rules || s2.cssRules;
|
|
239
|
-
if (!rules2) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
let sheetHref = s2.href;
|
|
243
|
-
if (!sheetHref && s2.ownerNode) {
|
|
244
|
-
sheetHref = s2.ownerNode.baseURI;
|
|
245
|
-
}
|
|
246
|
-
const stringifiedRules = Array.from(
|
|
247
|
-
rules2,
|
|
248
|
-
(rule2) => stringifyRule(rule2, sheetHref)
|
|
249
|
-
).join("");
|
|
250
|
-
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
251
|
-
} catch (error) {
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function stringifyRule(rule2, sheetHref) {
|
|
256
|
-
var _a2;
|
|
257
|
-
if (isCSSImportRule(rule2)) {
|
|
258
|
-
let importStringified;
|
|
259
|
-
try {
|
|
260
|
-
importStringified = // for same-origin stylesheets,
|
|
261
|
-
// we can access the imported stylesheet rules directly
|
|
262
|
-
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
263
|
-
escapeImportStatement(rule2);
|
|
264
|
-
} catch (error) {
|
|
265
|
-
importStringified = rule2.cssText;
|
|
266
|
-
}
|
|
267
|
-
try {
|
|
268
|
-
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
269
|
-
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
270
|
-
}
|
|
271
|
-
} catch {
|
|
272
|
-
}
|
|
273
|
-
return importStringified;
|
|
274
|
-
} else {
|
|
275
|
-
let ruleStringified = rule2.cssText;
|
|
276
|
-
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
277
|
-
ruleStringified = fixSafariColons(ruleStringified);
|
|
278
|
-
}
|
|
279
|
-
if (sheetHref) {
|
|
280
|
-
return absolutifyURLs(ruleStringified, sheetHref);
|
|
281
|
-
}
|
|
282
|
-
return ruleStringified;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function fixSafariColons(cssStringified) {
|
|
286
|
-
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
287
|
-
return cssStringified.replace(regex, "$1\\$2");
|
|
288
|
-
}
|
|
289
|
-
function isCSSImportRule(rule2) {
|
|
290
|
-
return "styleSheet" in rule2;
|
|
291
|
-
}
|
|
292
|
-
function isCSSStyleRule(rule2) {
|
|
293
|
-
return "selectorText" in rule2;
|
|
294
|
-
}
|
|
295
210
|
class Mirror {
|
|
296
211
|
constructor() {
|
|
297
212
|
__publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
|
|
@@ -414,6 +329,91 @@ function extractFileExtension(path, baseURL) {
|
|
|
414
329
|
const match = url.pathname.match(regex);
|
|
415
330
|
return (match == null ? void 0 : match[1]) ?? null;
|
|
416
331
|
}
|
|
332
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
333
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
334
|
+
cssText = cssText.replace(
|
|
335
|
+
/\sbackground-clip:\s*text;/g,
|
|
336
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
return cssText;
|
|
340
|
+
}
|
|
341
|
+
function escapeImportStatement(rule2) {
|
|
342
|
+
const { cssText } = rule2;
|
|
343
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
344
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
345
|
+
if (rule2.layerName === "") {
|
|
346
|
+
statement.push(`layer`);
|
|
347
|
+
} else if (rule2.layerName) {
|
|
348
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
349
|
+
}
|
|
350
|
+
if (rule2.supportsText) {
|
|
351
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
352
|
+
}
|
|
353
|
+
if (rule2.media.length) {
|
|
354
|
+
statement.push(rule2.media.mediaText);
|
|
355
|
+
}
|
|
356
|
+
return statement.join(" ") + ";";
|
|
357
|
+
}
|
|
358
|
+
function stringifyStylesheet(s2) {
|
|
359
|
+
try {
|
|
360
|
+
const rules2 = s2.rules || s2.cssRules;
|
|
361
|
+
if (!rules2) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
let sheetHref = s2.href;
|
|
365
|
+
if (!sheetHref && s2.ownerNode) {
|
|
366
|
+
sheetHref = s2.ownerNode.baseURI;
|
|
367
|
+
}
|
|
368
|
+
const stringifiedRules = Array.from(
|
|
369
|
+
rules2,
|
|
370
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
371
|
+
).join("");
|
|
372
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
373
|
+
} catch (error) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function stringifyRule(rule2, sheetHref) {
|
|
378
|
+
var _a2;
|
|
379
|
+
if (isCSSImportRule(rule2)) {
|
|
380
|
+
let importStringified;
|
|
381
|
+
try {
|
|
382
|
+
importStringified = // for same-origin stylesheets,
|
|
383
|
+
// we can access the imported stylesheet rules directly
|
|
384
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
385
|
+
escapeImportStatement(rule2);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
importStringified = rule2.cssText;
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
|
|
391
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
392
|
+
}
|
|
393
|
+
} catch {
|
|
394
|
+
}
|
|
395
|
+
return importStringified;
|
|
396
|
+
} else {
|
|
397
|
+
let ruleStringified = rule2.cssText;
|
|
398
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
399
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
400
|
+
}
|
|
401
|
+
if (sheetHref) {
|
|
402
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
403
|
+
}
|
|
404
|
+
return ruleStringified;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function fixSafariColons(cssStringified) {
|
|
408
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
409
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
410
|
+
}
|
|
411
|
+
function isCSSImportRule(rule2) {
|
|
412
|
+
return "styleSheet" in rule2;
|
|
413
|
+
}
|
|
414
|
+
function isCSSStyleRule(rule2) {
|
|
415
|
+
return "selectorText" in rule2;
|
|
416
|
+
}
|
|
417
417
|
function extractOrigin(url) {
|
|
418
418
|
let origin = "";
|
|
419
419
|
if (url.indexOf("//") > -1) {
|
|
@@ -11824,9 +11824,9 @@ const saveWebGLVar = (value, win, ctx) => {
|
|
|
11824
11824
|
}
|
|
11825
11825
|
return index2;
|
|
11826
11826
|
};
|
|
11827
|
-
function serializeArg(value, win, ctx) {
|
|
11827
|
+
function serializeArg(value, win, ctx, dataURLOptions) {
|
|
11828
11828
|
if (value instanceof Array) {
|
|
11829
|
-
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
11829
|
+
return value.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11830
11830
|
} else if (value === null) {
|
|
11831
11831
|
return value;
|
|
11832
11832
|
} 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) {
|
|
@@ -11852,7 +11852,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11852
11852
|
return {
|
|
11853
11853
|
rr_type: name,
|
|
11854
11854
|
args: [
|
|
11855
|
-
serializeArg(value.buffer, win, ctx),
|
|
11855
|
+
serializeArg(value.buffer, win, ctx, dataURLOptions),
|
|
11856
11856
|
value.byteOffset,
|
|
11857
11857
|
value.byteLength
|
|
11858
11858
|
]
|
|
@@ -11866,7 +11866,7 @@ function serializeArg(value, win, ctx) {
|
|
|
11866
11866
|
};
|
|
11867
11867
|
} else if (value instanceof HTMLCanvasElement) {
|
|
11868
11868
|
const name = "HTMLImageElement";
|
|
11869
|
-
const src = value.toDataURL();
|
|
11869
|
+
const src = value.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
11870
11870
|
return {
|
|
11871
11871
|
rr_type: name,
|
|
11872
11872
|
src
|
|
@@ -11875,7 +11875,11 @@ function serializeArg(value, win, ctx) {
|
|
|
11875
11875
|
const name = value.constructor.name;
|
|
11876
11876
|
return {
|
|
11877
11877
|
rr_type: name,
|
|
11878
|
-
args: [
|
|
11878
|
+
args: [
|
|
11879
|
+
serializeArg(value.data, win, ctx, dataURLOptions),
|
|
11880
|
+
value.width,
|
|
11881
|
+
value.height
|
|
11882
|
+
]
|
|
11879
11883
|
};
|
|
11880
11884
|
} else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
|
|
11881
11885
|
const name = value.constructor.name;
|
|
@@ -11887,8 +11891,8 @@ function serializeArg(value, win, ctx) {
|
|
|
11887
11891
|
}
|
|
11888
11892
|
return value;
|
|
11889
11893
|
}
|
|
11890
|
-
const serializeArgs = (args, win, ctx) => {
|
|
11891
|
-
return args.map((arg) => serializeArg(arg, win, ctx));
|
|
11894
|
+
const serializeArgs = (args, win, ctx, dataURLOptions) => {
|
|
11895
|
+
return args.map((arg) => serializeArg(arg, win, ctx, dataURLOptions));
|
|
11892
11896
|
};
|
|
11893
11897
|
const isInstanceOfWebGLObject = (value, win) => {
|
|
11894
11898
|
const webGLConstructorNames = [
|
|
@@ -11914,7 +11918,7 @@ const isInstanceOfWebGLObject = (value, win) => {
|
|
|
11914
11918
|
)
|
|
11915
11919
|
);
|
|
11916
11920
|
};
|
|
11917
|
-
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
11921
|
+
function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
11918
11922
|
const handlers = [];
|
|
11919
11923
|
const props2D = Object.getOwnPropertyNames(
|
|
11920
11924
|
win.CanvasRenderingContext2D.prototype
|
|
@@ -11931,7 +11935,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
11931
11935
|
return function(...args) {
|
|
11932
11936
|
if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
11933
11937
|
setTimeout(() => {
|
|
11934
|
-
const recordArgs = serializeArgs(
|
|
11938
|
+
const recordArgs = serializeArgs(
|
|
11939
|
+
args,
|
|
11940
|
+
win,
|
|
11941
|
+
this,
|
|
11942
|
+
dataURLOptions
|
|
11943
|
+
);
|
|
11935
11944
|
cb(this.canvas, {
|
|
11936
11945
|
type: CanvasContext["2D"],
|
|
11937
11946
|
property: prop,
|
|
@@ -12005,7 +12014,7 @@ function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDr
|
|
|
12005
12014
|
handlers.forEach((h) => h());
|
|
12006
12015
|
};
|
|
12007
12016
|
}
|
|
12008
|
-
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
12017
|
+
function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, dataURLOptions) {
|
|
12009
12018
|
const handlers = [];
|
|
12010
12019
|
const props = Object.getOwnPropertyNames(prototype);
|
|
12011
12020
|
for (const prop of props) {
|
|
@@ -12032,7 +12041,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12032
12041
|
const result2 = original.apply(this, args);
|
|
12033
12042
|
saveWebGLVar(result2, win, this);
|
|
12034
12043
|
if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
12035
|
-
const recordArgs = serializeArgs(args, win, this);
|
|
12044
|
+
const recordArgs = serializeArgs(args, win, this, dataURLOptions);
|
|
12036
12045
|
const mutation = {
|
|
12037
12046
|
type,
|
|
12038
12047
|
property: prop,
|
|
@@ -12061,7 +12070,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
|
|
|
12061
12070
|
}
|
|
12062
12071
|
return handlers;
|
|
12063
12072
|
}
|
|
12064
|
-
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
12073
|
+
function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
|
|
12065
12074
|
const handlers = [];
|
|
12066
12075
|
handlers.push(
|
|
12067
12076
|
...patchGLPrototype(
|
|
@@ -12070,7 +12079,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12070
12079
|
cb,
|
|
12071
12080
|
blockClass,
|
|
12072
12081
|
blockSelector,
|
|
12073
|
-
win
|
|
12082
|
+
win,
|
|
12083
|
+
dataURLOptions
|
|
12074
12084
|
)
|
|
12075
12085
|
);
|
|
12076
12086
|
if (typeof win.WebGL2RenderingContext !== "undefined") {
|
|
@@ -12081,7 +12091,8 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
12081
12091
|
cb,
|
|
12082
12092
|
blockClass,
|
|
12083
12093
|
blockSelector,
|
|
12084
|
-
win
|
|
12094
|
+
win,
|
|
12095
|
+
dataURLOptions
|
|
12085
12096
|
)
|
|
12086
12097
|
);
|
|
12087
12098
|
}
|
|
@@ -12143,7 +12154,12 @@ class CanvasManager {
|
|
|
12143
12154
|
this.mutationCb = options.mutationCb;
|
|
12144
12155
|
this.mirror = options.mirror;
|
|
12145
12156
|
if (recordCanvas && sampling === "all")
|
|
12146
|
-
this.initCanvasMutationObserver(
|
|
12157
|
+
this.initCanvasMutationObserver(
|
|
12158
|
+
win,
|
|
12159
|
+
blockClass,
|
|
12160
|
+
blockSelector,
|
|
12161
|
+
dataURLOptions
|
|
12162
|
+
);
|
|
12147
12163
|
if (recordCanvas && typeof sampling === "number")
|
|
12148
12164
|
this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
|
|
12149
12165
|
dataURLOptions
|
|
@@ -12272,7 +12288,7 @@ class CanvasManager {
|
|
|
12272
12288
|
cancelAnimationFrame(rafId);
|
|
12273
12289
|
};
|
|
12274
12290
|
}
|
|
12275
|
-
initCanvasMutationObserver(win, blockClass, blockSelector) {
|
|
12291
|
+
initCanvasMutationObserver(win, blockClass, blockSelector, dataURLOptions) {
|
|
12276
12292
|
this.startRAFTimestamping();
|
|
12277
12293
|
this.startPendingCanvasMutationFlusher();
|
|
12278
12294
|
const canvasContextReset = initCanvasContextObserver(
|
|
@@ -12285,13 +12301,15 @@ class CanvasManager {
|
|
|
12285
12301
|
this.processMutation.bind(this),
|
|
12286
12302
|
win,
|
|
12287
12303
|
blockClass,
|
|
12288
|
-
blockSelector
|
|
12304
|
+
blockSelector,
|
|
12305
|
+
dataURLOptions
|
|
12289
12306
|
);
|
|
12290
12307
|
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(
|
|
12291
12308
|
this.processMutation.bind(this),
|
|
12292
12309
|
win,
|
|
12293
12310
|
blockClass,
|
|
12294
|
-
blockSelector
|
|
12311
|
+
blockSelector,
|
|
12312
|
+
dataURLOptions
|
|
12295
12313
|
);
|
|
12296
12314
|
this.resetObservers = () => {
|
|
12297
12315
|
canvasContextReset();
|