@lunardinos/browser 0.2.4 → 0.2.5
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/recorder-core.js +309 -389
- package/dist/src/recorder-core.d.ts.map +1 -1
- package/dist/src/recorder-core.js +48 -29
- package/dist/src/recorder.browser.test.d.ts +2 -0
- package/dist/src/recorder.browser.test.d.ts.map +1 -0
- package/dist/src/recorder.browser.test.js +144 -0
- package/dist/src/session-lifecycle.d.ts +8 -1
- package/dist/src/session-lifecycle.d.ts.map +1 -1
- package/dist/src/session-lifecycle.js +11 -3
- package/dist/src/session-lifecycle.test.js +9 -1
- package/dist/src/testing/measure-bytes.d.ts +2 -0
- package/dist/src/testing/measure-bytes.d.ts.map +1 -0
- package/dist/src/testing/measure-bytes.js +151 -0
- package/dist/src/testing/recorder-bundle.d.ts +6 -0
- package/dist/src/testing/recorder-bundle.d.ts.map +1 -0
- package/dist/src/testing/recorder-bundle.js +19 -0
- package/package.json +3 -2
package/dist/recorder-core.js
CHANGED
|
@@ -15,7 +15,7 @@ var __export = (target, all) => {
|
|
|
15
15
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
16
16
|
|
|
17
17
|
// ../rrweb-types/src/index.ts
|
|
18
|
-
var MouseInteractions;
|
|
18
|
+
var MouseInteractions, NAVIGATION_TAG = "navigation";
|
|
19
19
|
var init_src = __esm(() => {
|
|
20
20
|
((MouseInteractions2) => {
|
|
21
21
|
MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
|
|
@@ -267,157 +267,70 @@ function isCSSStyleRule(rule) {
|
|
|
267
267
|
return "selectorText" in rule;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
class
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
class Mirror {
|
|
271
|
+
idNodeMap = new Map;
|
|
272
|
+
nodeIdMap = new WeakMap;
|
|
273
273
|
nodeMetaMap = new WeakMap;
|
|
274
|
-
|
|
275
|
-
const parts = [];
|
|
276
|
-
let current = n;
|
|
277
|
-
let parent = dom_default.parentNode(current);
|
|
278
|
-
while (parent) {
|
|
279
|
-
const children = dom_default.childNodes(parent);
|
|
280
|
-
const idx = Array.prototype.indexOf.call(children, current);
|
|
281
|
-
if (idx === -1)
|
|
282
|
-
break;
|
|
283
|
-
parts.unshift(idx);
|
|
284
|
-
current = parent;
|
|
285
|
-
parent = dom_default.parentNode(current);
|
|
286
|
-
}
|
|
287
|
-
return parts.join(".");
|
|
288
|
-
}
|
|
289
|
-
getPath(n) {
|
|
274
|
+
getId(n) {
|
|
290
275
|
if (!n)
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
if (cached !== undefined)
|
|
294
|
-
return cached;
|
|
295
|
-
return this.computePath(n);
|
|
276
|
+
return -1;
|
|
277
|
+
return this.nodeIdMap.get(n) ?? -1;
|
|
296
278
|
}
|
|
297
|
-
getNode(
|
|
298
|
-
return this.
|
|
279
|
+
getNode(id) {
|
|
280
|
+
return this.idNodeMap.get(id) || null;
|
|
299
281
|
}
|
|
300
|
-
|
|
301
|
-
return Array.from(this.
|
|
282
|
+
getIds() {
|
|
283
|
+
return Array.from(this.idNodeMap.keys());
|
|
302
284
|
}
|
|
303
|
-
has(
|
|
304
|
-
return this.
|
|
285
|
+
has(id) {
|
|
286
|
+
return this.idNodeMap.has(id);
|
|
305
287
|
}
|
|
306
288
|
add(n, meta) {
|
|
307
|
-
|
|
308
|
-
if (path !== undefined) {
|
|
309
|
-
this.nodePathMap.set(n, path);
|
|
310
|
-
this.pathNodeMap.set(path, n);
|
|
311
|
-
}
|
|
289
|
+
this.nodeIdMap.set(n, meta.id);
|
|
312
290
|
this.nodeMetaMap.set(n, meta);
|
|
291
|
+
if (meta.id !== IGNORED_NODE)
|
|
292
|
+
this.idNodeMap.set(meta.id, n);
|
|
313
293
|
}
|
|
314
|
-
replace(
|
|
315
|
-
const oldNode = this.
|
|
294
|
+
replace(id, n) {
|
|
295
|
+
const oldNode = this.idNodeMap.get(id);
|
|
316
296
|
if (oldNode) {
|
|
317
297
|
const meta = this.nodeMetaMap.get(oldNode);
|
|
318
298
|
if (meta)
|
|
319
299
|
this.nodeMetaMap.set(n, meta);
|
|
320
300
|
}
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
323
|
-
}
|
|
324
|
-
setPath(n, path) {
|
|
325
|
-
this.nodePathMap.set(n, path);
|
|
326
|
-
this.pathNodeMap.set(path, n);
|
|
327
|
-
}
|
|
328
|
-
setMeta(n, meta) {
|
|
329
|
-
this.nodeMetaMap.set(n, meta);
|
|
301
|
+
this.idNodeMap.set(id, n);
|
|
302
|
+
this.nodeIdMap.set(n, id);
|
|
330
303
|
}
|
|
331
304
|
getMeta(n) {
|
|
332
305
|
return this.nodeMetaMap.get(n) || null;
|
|
333
306
|
}
|
|
334
307
|
hasNode(node) {
|
|
335
|
-
return this.
|
|
308
|
+
return this.nodeIdMap.has(node);
|
|
336
309
|
}
|
|
337
310
|
isIgnored(n) {
|
|
338
|
-
return this.
|
|
311
|
+
return this.nodeIdMap.get(n) === IGNORED_NODE;
|
|
339
312
|
}
|
|
340
313
|
isSerialized(n) {
|
|
341
|
-
const
|
|
342
|
-
return
|
|
314
|
+
const id = this.nodeIdMap.get(n);
|
|
315
|
+
return id !== undefined && id !== IGNORED_NODE;
|
|
343
316
|
}
|
|
344
317
|
removeNodeFromMap(n) {
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
347
|
-
this.
|
|
348
|
-
|
|
349
|
-
this.nodePathMap.delete(n);
|
|
318
|
+
const id = this.nodeIdMap.get(n);
|
|
319
|
+
if (id !== undefined && this.idNodeMap.get(id) === n)
|
|
320
|
+
this.idNodeMap.delete(id);
|
|
321
|
+
this.nodeIdMap.delete(n);
|
|
350
322
|
if (n.childNodes) {
|
|
351
323
|
n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
|
|
352
324
|
}
|
|
353
325
|
}
|
|
354
326
|
reset() {
|
|
355
|
-
this.
|
|
356
|
-
this.
|
|
327
|
+
this.idNodeMap = new Map;
|
|
328
|
+
this.nodeIdMap = new WeakMap;
|
|
357
329
|
this.nodeMetaMap = new WeakMap;
|
|
358
330
|
}
|
|
359
331
|
}
|
|
360
332
|
function createMirror() {
|
|
361
|
-
return new
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
class Mirror {
|
|
365
|
-
pathNodeMap = new Map;
|
|
366
|
-
nodeMetaMap = new WeakMap;
|
|
367
|
-
nodePathMap = new WeakMap;
|
|
368
|
-
getPath(n) {
|
|
369
|
-
if (!n)
|
|
370
|
-
return "";
|
|
371
|
-
return this.nodePathMap.get(n) ?? "";
|
|
372
|
-
}
|
|
373
|
-
getNode(path) {
|
|
374
|
-
return this.pathNodeMap.get(path) || null;
|
|
375
|
-
}
|
|
376
|
-
getPaths() {
|
|
377
|
-
return Array.from(this.pathNodeMap.keys());
|
|
378
|
-
}
|
|
379
|
-
getMeta(n) {
|
|
380
|
-
return this.nodeMetaMap.get(n) || null;
|
|
381
|
-
}
|
|
382
|
-
has(path) {
|
|
383
|
-
return this.pathNodeMap.has(path);
|
|
384
|
-
}
|
|
385
|
-
hasNode(node) {
|
|
386
|
-
return this.nodeMetaMap.has(node);
|
|
387
|
-
}
|
|
388
|
-
add(n, meta) {
|
|
389
|
-
const path = meta.path;
|
|
390
|
-
if (path !== undefined) {
|
|
391
|
-
this.pathNodeMap.set(path, n);
|
|
392
|
-
this.nodePathMap.set(n, path);
|
|
393
|
-
}
|
|
394
|
-
this.nodeMetaMap.set(n, meta);
|
|
395
|
-
}
|
|
396
|
-
replace(path, n) {
|
|
397
|
-
const oldNode = this.pathNodeMap.get(path);
|
|
398
|
-
if (oldNode) {
|
|
399
|
-
const meta = this.nodeMetaMap.get(oldNode);
|
|
400
|
-
if (meta)
|
|
401
|
-
this.nodeMetaMap.set(n, meta);
|
|
402
|
-
}
|
|
403
|
-
this.pathNodeMap.set(path, n);
|
|
404
|
-
this.nodePathMap.set(n, path);
|
|
405
|
-
}
|
|
406
|
-
removeNodeFromMap(n) {
|
|
407
|
-
const path = this.nodePathMap.get(n);
|
|
408
|
-
if (path !== undefined) {
|
|
409
|
-
this.pathNodeMap.delete(path);
|
|
410
|
-
}
|
|
411
|
-
this.nodePathMap.delete(n);
|
|
412
|
-
if (n.childNodes) {
|
|
413
|
-
n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
reset() {
|
|
417
|
-
this.pathNodeMap = new Map;
|
|
418
|
-
this.nodeMetaMap = new WeakMap;
|
|
419
|
-
this.nodePathMap = new WeakMap;
|
|
420
|
-
}
|
|
333
|
+
return new Mirror;
|
|
421
334
|
}
|
|
422
335
|
function maskInputValue({
|
|
423
336
|
element,
|
|
@@ -548,7 +461,7 @@ function splitCssText(cssText, style) {
|
|
|
548
461
|
function markCssSplits(cssText, style) {
|
|
549
462
|
return splitCssText(cssText, style).join("/* rr_split */");
|
|
550
463
|
}
|
|
551
|
-
var
|
|
464
|
+
var IGNORED_NODE = -2, ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__", URL_IN_CSS_REF, URL_PROTOCOL_MATCH, URL_WWW_MATCH, DATA_URI;
|
|
552
465
|
var init_snapshot_utils = __esm(() => {
|
|
553
466
|
init_src();
|
|
554
467
|
init_dom();
|
|
@@ -570,6 +483,33 @@ function getValidTagName(element) {
|
|
|
570
483
|
}
|
|
571
484
|
return processedTagName;
|
|
572
485
|
}
|
|
486
|
+
function inlineImageSize(image) {
|
|
487
|
+
const natW = image.naturalWidth;
|
|
488
|
+
const natH = image.naturalHeight;
|
|
489
|
+
const box = image.getBoundingClientRect();
|
|
490
|
+
const scale = box.width > 0 && box.height > 0 ? Math.max(box.width / natW, box.height / natH) : UNRENDERED_IMAGE_MAX_EDGE / Math.max(natW, natH);
|
|
491
|
+
const s = Math.min(1, scale);
|
|
492
|
+
return { width: Math.max(1, Math.round(natW * s)), height: Math.max(1, Math.round(natH * s)) };
|
|
493
|
+
}
|
|
494
|
+
function inlineImage(image, src, dataURLOptions) {
|
|
495
|
+
const { width, height } = inlineImageSize(image);
|
|
496
|
+
const type = dataURLOptions.type ?? INLINE_IMAGE_TYPE;
|
|
497
|
+
const quality = dataURLOptions.quality ?? INLINE_IMAGE_QUALITY;
|
|
498
|
+
const key = `${width}x${height}|${type}|${quality}|${src}`;
|
|
499
|
+
const cached = inlinedImages.get(key);
|
|
500
|
+
if (cached)
|
|
501
|
+
return cached;
|
|
502
|
+
canvasService.width = width;
|
|
503
|
+
canvasService.height = height;
|
|
504
|
+
canvasCtx?.drawImage(image, 0, 0, width, height);
|
|
505
|
+
const dataURL = canvasService?.toDataURL(type, quality);
|
|
506
|
+
if (dataURL) {
|
|
507
|
+
if (inlinedImages.size >= INLINED_IMAGES_MAX)
|
|
508
|
+
inlinedImages.clear();
|
|
509
|
+
inlinedImages.set(key, dataURL);
|
|
510
|
+
}
|
|
511
|
+
return dataURL;
|
|
512
|
+
}
|
|
573
513
|
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
574
514
|
if (attributeValue.trim() === "") {
|
|
575
515
|
return attributeValue;
|
|
@@ -888,8 +828,8 @@ function serializeNode(n, options) {
|
|
|
888
828
|
function getRootId(doc, mirror) {
|
|
889
829
|
if (!mirror.hasNode(doc))
|
|
890
830
|
return;
|
|
891
|
-
const
|
|
892
|
-
return
|
|
831
|
+
const docId = mirror.getId(doc);
|
|
832
|
+
return docId === 1 ? undefined : docId;
|
|
893
833
|
}
|
|
894
834
|
function serializeTextNode(n, options) {
|
|
895
835
|
const { needsMask, maskTextFn, rootId, cssCaptured } = options;
|
|
@@ -1019,10 +959,7 @@ function serializeElementNode(n, options) {
|
|
|
1019
959
|
const recordInlineImage = () => {
|
|
1020
960
|
image.removeEventListener("load", recordInlineImage);
|
|
1021
961
|
try {
|
|
1022
|
-
|
|
1023
|
-
canvasService.height = image.naturalHeight;
|
|
1024
|
-
canvasCtx?.drawImage(image, 0, 0);
|
|
1025
|
-
attributes.rr_dataURL = canvasService?.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
962
|
+
attributes.rr_dataURL = inlineImage(image, imageSrc, dataURLOptions);
|
|
1026
963
|
} catch (err) {
|
|
1027
964
|
if (image.crossOrigin !== "anonymous") {
|
|
1028
965
|
image.crossOrigin = "anonymous";
|
|
@@ -1130,6 +1067,9 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
1130
1067
|
}
|
|
1131
1068
|
return false;
|
|
1132
1069
|
}
|
|
1070
|
+
function genId() {
|
|
1071
|
+
return _id++;
|
|
1072
|
+
}
|
|
1133
1073
|
function serializeNodeWithId(n, options) {
|
|
1134
1074
|
const {
|
|
1135
1075
|
doc,
|
|
@@ -1154,9 +1094,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1154
1094
|
stylesheetLoadTimeout = 5000,
|
|
1155
1095
|
keepIframeSrcFn = () => false,
|
|
1156
1096
|
newlyAddedElement = false,
|
|
1157
|
-
cssCaptured = false
|
|
1158
|
-
_parentPath,
|
|
1159
|
-
_childIndex
|
|
1097
|
+
cssCaptured = false
|
|
1160
1098
|
} = options;
|
|
1161
1099
|
let { needsMask } = options;
|
|
1162
1100
|
let { preserveWhiteSpace = true } = options;
|
|
@@ -1185,22 +1123,18 @@ function serializeNodeWithId(n, options) {
|
|
|
1185
1123
|
console.warn(n, "not serialized");
|
|
1186
1124
|
return null;
|
|
1187
1125
|
}
|
|
1188
|
-
let
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1191
|
-
} else if (
|
|
1192
|
-
|
|
1126
|
+
let id;
|
|
1127
|
+
if (mirror.hasNode(n)) {
|
|
1128
|
+
id = mirror.getId(n);
|
|
1129
|
+
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === 3 /* Text */ && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
|
|
1130
|
+
id = IGNORED_NODE;
|
|
1193
1131
|
} else {
|
|
1194
|
-
|
|
1132
|
+
id = genId();
|
|
1195
1133
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1134
|
+
const serializedNode = Object.assign(_serializedNode, { id });
|
|
1135
|
+
mirror.add(n, serializedNode);
|
|
1136
|
+
if (id === IGNORED_NODE)
|
|
1199
1137
|
return null;
|
|
1200
|
-
}
|
|
1201
|
-
const serializedNode = Object.assign(_serializedNode, { path });
|
|
1202
|
-
mirror.setPath(n, path);
|
|
1203
|
-
mirror.setMeta(n, serializedNode);
|
|
1204
1138
|
if (onSerialize) {
|
|
1205
1139
|
onSerialize(n);
|
|
1206
1140
|
}
|
|
@@ -1240,39 +1174,27 @@ function serializeNodeWithId(n, options) {
|
|
|
1240
1174
|
onStylesheetLoad,
|
|
1241
1175
|
stylesheetLoadTimeout,
|
|
1242
1176
|
keepIframeSrcFn,
|
|
1243
|
-
cssCaptured: false
|
|
1244
|
-
_parentPath: path,
|
|
1245
|
-
_childIndex: 0
|
|
1177
|
+
cssCaptured: false
|
|
1246
1178
|
};
|
|
1247
1179
|
if (serializedNode.type === 2 /* Element */ && serializedNode.tagName === "textarea" && serializedNode.attributes?.value !== undefined) {} else {
|
|
1248
1180
|
if (serializedNode.type === 2 /* Element */ && serializedNode.attributes?._cssText !== undefined && typeof serializedNode.attributes._cssText === "string") {
|
|
1249
1181
|
bypassOptions.cssCaptured = true;
|
|
1250
1182
|
}
|
|
1251
|
-
let childIndex = 0;
|
|
1252
1183
|
for (const childN of Array.from(dom_default.childNodes(n))) {
|
|
1253
|
-
bypassOptions._childIndex = childIndex;
|
|
1254
1184
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1255
1185
|
if (serializedChildNode) {
|
|
1256
|
-
if (!serializedNode.childNodes)
|
|
1257
|
-
serializedNode.childNodes = [];
|
|
1258
1186
|
serializedNode.childNodes.push(serializedChildNode);
|
|
1259
1187
|
}
|
|
1260
|
-
childIndex++;
|
|
1261
1188
|
}
|
|
1262
1189
|
}
|
|
1263
1190
|
let shadowRootEl = null;
|
|
1264
1191
|
if (isElement(n) && (shadowRootEl = dom_default.shadowRoot(n))) {
|
|
1265
|
-
let shadowChildIndex = dom_default.childNodes(n).length;
|
|
1266
1192
|
for (const childN of Array.from(dom_default.childNodes(shadowRootEl))) {
|
|
1267
|
-
bypassOptions._childIndex = shadowChildIndex;
|
|
1268
1193
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1269
1194
|
if (serializedChildNode) {
|
|
1270
1195
|
isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
|
|
1271
|
-
if (!serializedNode.childNodes)
|
|
1272
|
-
serializedNode.childNodes = [];
|
|
1273
1196
|
serializedNode.childNodes.push(serializedChildNode);
|
|
1274
1197
|
}
|
|
1275
|
-
shadowChildIndex++;
|
|
1276
1198
|
}
|
|
1277
1199
|
}
|
|
1278
1200
|
}
|
|
@@ -1353,7 +1275,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1353
1275
|
}
|
|
1354
1276
|
function snapshot(n, options) {
|
|
1355
1277
|
const {
|
|
1356
|
-
mirror = new
|
|
1278
|
+
mirror = new Mirror,
|
|
1357
1279
|
blockClass = "rr-block",
|
|
1358
1280
|
blockSelector = null,
|
|
1359
1281
|
maskTextClass = "rr-mask",
|
|
@@ -1432,13 +1354,17 @@ function snapshot(n, options) {
|
|
|
1432
1354
|
newlyAddedElement: false
|
|
1433
1355
|
});
|
|
1434
1356
|
}
|
|
1435
|
-
|
|
1357
|
+
function cleanupSnapshot() {
|
|
1358
|
+
_id = 1;
|
|
1359
|
+
}
|
|
1360
|
+
var tagNameRegex, canvasService, canvasCtx, INLINE_IMAGE_TYPE = "image/webp", INLINE_IMAGE_QUALITY = 0.8, UNRENDERED_IMAGE_MAX_EDGE = 256, inlinedImages, INLINED_IMAGES_MAX = 500, SRCSET_NOT_SPACES, SRCSET_COMMAS_OR_SPACES, cachedDocument, _id = 1, snapshot_default;
|
|
1436
1361
|
var init_snapshot = __esm(() => {
|
|
1437
1362
|
init_src();
|
|
1438
1363
|
init_dom();
|
|
1439
1364
|
init_redact_pii();
|
|
1440
1365
|
init_snapshot_utils();
|
|
1441
1366
|
tagNameRegex = /[^a-z0-9-_:]/;
|
|
1367
|
+
inlinedImages = new Map;
|
|
1442
1368
|
SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
1443
1369
|
SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
1444
1370
|
cachedDocument = new WeakMap;
|
|
@@ -2081,20 +2007,18 @@ class CanvasManager {
|
|
|
2081
2007
|
initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
|
|
2082
2008
|
const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
|
|
2083
2009
|
const snapshotInProgressMap = new Map;
|
|
2084
|
-
let nextWorkerId = 1;
|
|
2085
|
-
const workerIdToPath = new Map;
|
|
2086
2010
|
const worker = {
|
|
2087
2011
|
postMessage() {},
|
|
2088
2012
|
onmessage() {}
|
|
2089
2013
|
};
|
|
2090
2014
|
worker.onmessage = (e) => {
|
|
2091
|
-
const
|
|
2092
|
-
snapshotInProgressMap.set(
|
|
2015
|
+
const { id } = e.data;
|
|
2016
|
+
snapshotInProgressMap.set(id, false);
|
|
2093
2017
|
if (!("base64" in e.data))
|
|
2094
2018
|
return;
|
|
2095
2019
|
const { base64, type, width, height } = e.data;
|
|
2096
2020
|
this.mutationCb({
|
|
2097
|
-
|
|
2021
|
+
id,
|
|
2098
2022
|
type: 0 /* 2D */,
|
|
2099
2023
|
commands: [
|
|
2100
2024
|
{
|
|
@@ -2140,12 +2064,12 @@ class CanvasManager {
|
|
|
2140
2064
|
}
|
|
2141
2065
|
lastSnapshotTime = timestamp;
|
|
2142
2066
|
getCanvas().forEach(async (canvas) => {
|
|
2143
|
-
const
|
|
2144
|
-
if (snapshotInProgressMap.get(
|
|
2067
|
+
const id = this.mirror.getId(canvas);
|
|
2068
|
+
if (snapshotInProgressMap.get(id))
|
|
2145
2069
|
return;
|
|
2146
2070
|
if (canvas.width === 0 || canvas.height === 0)
|
|
2147
2071
|
return;
|
|
2148
|
-
snapshotInProgressMap.set(
|
|
2072
|
+
snapshotInProgressMap.set(id, true);
|
|
2149
2073
|
if (["webgl", "webgl2"].includes(canvas.__context)) {
|
|
2150
2074
|
const context = canvas.getContext(canvas.__context);
|
|
2151
2075
|
if (context?.getContextAttributes()?.preserveDrawingBuffer === false) {
|
|
@@ -2153,10 +2077,8 @@ class CanvasManager {
|
|
|
2153
2077
|
}
|
|
2154
2078
|
}
|
|
2155
2079
|
const bitmap = await createImageBitmap(canvas);
|
|
2156
|
-
const workerId = nextWorkerId++;
|
|
2157
|
-
workerIdToPath.set(workerId, canvasPath);
|
|
2158
2080
|
worker.postMessage({
|
|
2159
|
-
id
|
|
2081
|
+
id,
|
|
2160
2082
|
bitmap,
|
|
2161
2083
|
width: canvas.width,
|
|
2162
2084
|
height: canvas.height,
|
|
@@ -2195,24 +2117,24 @@ class CanvasManager {
|
|
|
2195
2117
|
}
|
|
2196
2118
|
flushPendingCanvasMutations() {
|
|
2197
2119
|
this.pendingCanvasMutations.forEach((_values, canvas) => {
|
|
2198
|
-
const
|
|
2199
|
-
this.flushPendingCanvasMutationFor(canvas,
|
|
2120
|
+
const id = this.mirror.getId(canvas);
|
|
2121
|
+
this.flushPendingCanvasMutationFor(canvas, id);
|
|
2200
2122
|
});
|
|
2201
2123
|
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
2202
2124
|
}
|
|
2203
|
-
flushPendingCanvasMutationFor(canvas,
|
|
2125
|
+
flushPendingCanvasMutationFor(canvas, id) {
|
|
2204
2126
|
if (this.frozen || this.locked) {
|
|
2205
2127
|
return;
|
|
2206
2128
|
}
|
|
2207
2129
|
const valuesWithType = this.pendingCanvasMutations.get(canvas);
|
|
2208
|
-
if (!valuesWithType ||
|
|
2130
|
+
if (!valuesWithType || id === -1)
|
|
2209
2131
|
return;
|
|
2210
2132
|
const values = valuesWithType.map((value) => {
|
|
2211
2133
|
const { type: type2, ...rest } = value;
|
|
2212
2134
|
return rest;
|
|
2213
2135
|
});
|
|
2214
2136
|
const { type } = valuesWithType[0];
|
|
2215
|
-
this.mutationCb({
|
|
2137
|
+
this.mutationCb({ id, type, commands: values });
|
|
2216
2138
|
this.pendingCanvasMutations.delete(canvas);
|
|
2217
2139
|
}
|
|
2218
2140
|
}
|
|
@@ -2233,86 +2155,75 @@ init_utils();
|
|
|
2233
2155
|
|
|
2234
2156
|
// ../rrweb-record/src/record/iframe-manager.ts
|
|
2235
2157
|
init_src();
|
|
2158
|
+
init_snapshot();
|
|
2236
2159
|
|
|
2237
2160
|
// ../rrweb-record/src/record/cross-origin-iframe-mirror.ts
|
|
2238
2161
|
class CrossOriginIframeMirror {
|
|
2239
2162
|
generateIdFn;
|
|
2240
|
-
|
|
2241
|
-
|
|
2163
|
+
iframeIdToRemoteIdMap = new WeakMap;
|
|
2164
|
+
iframeRemoteIdToIdMap = new WeakMap;
|
|
2242
2165
|
constructor(generateIdFn) {
|
|
2243
2166
|
this.generateIdFn = generateIdFn;
|
|
2244
2167
|
}
|
|
2245
|
-
|
|
2246
|
-
const
|
|
2247
|
-
const
|
|
2248
|
-
let
|
|
2249
|
-
if (
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
}
|
|
2254
|
-
return
|
|
2255
|
-
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
const
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
}
|
|
2273
|
-
getRemotePaths(iframe, parentPaths) {
|
|
2274
|
-
const p2l = this.getParentToLocalMap(iframe);
|
|
2275
|
-
return parentPaths.map((p) => this.getRemotePath(iframe, p, p2l));
|
|
2276
|
-
}
|
|
2277
|
-
getRemoteId = this.getRemotePath;
|
|
2278
|
-
getRemoteIds = this.getRemotePaths;
|
|
2168
|
+
getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
|
|
2169
|
+
const idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
|
|
2170
|
+
const remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
|
|
2171
|
+
let id = remoteIdToIdMap.get(remoteId);
|
|
2172
|
+
if (!id) {
|
|
2173
|
+
id = this.generateIdFn();
|
|
2174
|
+
remoteIdToIdMap.set(remoteId, id);
|
|
2175
|
+
idToRemoteIdMap.set(id, remoteId);
|
|
2176
|
+
}
|
|
2177
|
+
return id;
|
|
2178
|
+
}
|
|
2179
|
+
getIds(iframe, remoteIds) {
|
|
2180
|
+
const idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
|
|
2181
|
+
const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
|
|
2182
|
+
return remoteIds.map((id) => this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap));
|
|
2183
|
+
}
|
|
2184
|
+
getRemoteId(iframe, id, map) {
|
|
2185
|
+
const idToRemoteIdMap = map || this.getIdToRemoteIdMap(iframe);
|
|
2186
|
+
const remoteId = idToRemoteIdMap.get(id);
|
|
2187
|
+
if (!remoteId)
|
|
2188
|
+
return -1;
|
|
2189
|
+
return remoteId;
|
|
2190
|
+
}
|
|
2191
|
+
getRemoteIds(iframe, ids) {
|
|
2192
|
+
const idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
|
|
2193
|
+
return ids.map((id) => this.getRemoteId(iframe, id, idToRemoteIdMap));
|
|
2194
|
+
}
|
|
2279
2195
|
reset(iframe) {
|
|
2280
2196
|
if (!iframe) {
|
|
2281
|
-
this.
|
|
2282
|
-
this.
|
|
2197
|
+
this.iframeIdToRemoteIdMap = new WeakMap;
|
|
2198
|
+
this.iframeRemoteIdToIdMap = new WeakMap;
|
|
2283
2199
|
return;
|
|
2284
2200
|
}
|
|
2285
|
-
this.
|
|
2286
|
-
this.
|
|
2201
|
+
this.iframeIdToRemoteIdMap.delete(iframe);
|
|
2202
|
+
this.iframeRemoteIdToIdMap.delete(iframe);
|
|
2287
2203
|
}
|
|
2288
|
-
|
|
2289
|
-
let
|
|
2290
|
-
if (!
|
|
2291
|
-
|
|
2292
|
-
this.
|
|
2204
|
+
getIdToRemoteIdMap(iframe) {
|
|
2205
|
+
let idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
|
|
2206
|
+
if (!idToRemoteIdMap) {
|
|
2207
|
+
idToRemoteIdMap = new Map;
|
|
2208
|
+
this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
|
|
2293
2209
|
}
|
|
2294
|
-
return
|
|
2210
|
+
return idToRemoteIdMap;
|
|
2295
2211
|
}
|
|
2296
|
-
|
|
2297
|
-
let
|
|
2298
|
-
if (!
|
|
2299
|
-
|
|
2300
|
-
this.
|
|
2212
|
+
getRemoteIdToIdMap(iframe) {
|
|
2213
|
+
let remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
|
|
2214
|
+
if (!remoteIdToIdMap) {
|
|
2215
|
+
remoteIdToIdMap = new Map;
|
|
2216
|
+
this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
|
|
2301
2217
|
}
|
|
2302
|
-
return
|
|
2218
|
+
return remoteIdToIdMap;
|
|
2303
2219
|
}
|
|
2304
2220
|
}
|
|
2305
2221
|
|
|
2306
2222
|
// ../rrweb-record/src/record/iframe-manager.ts
|
|
2307
|
-
var _crossOriginPathCounter = 1;
|
|
2308
|
-
function genCrossOriginPath() {
|
|
2309
|
-
return `__xo_${_crossOriginPathCounter++}`;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
2223
|
class IframeManager {
|
|
2313
2224
|
iframes = new WeakMap;
|
|
2314
2225
|
crossOriginIframeMap = new WeakMap;
|
|
2315
|
-
crossOriginIframeMirror = new CrossOriginIframeMirror(
|
|
2226
|
+
crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
|
|
2316
2227
|
crossOriginIframeStyleMirror;
|
|
2317
2228
|
crossOriginIframeRootIdMap = new WeakMap;
|
|
2318
2229
|
mirror;
|
|
@@ -2344,8 +2255,8 @@ class IframeManager {
|
|
|
2344
2255
|
this.mutationCb({
|
|
2345
2256
|
adds: [
|
|
2346
2257
|
{
|
|
2347
|
-
|
|
2348
|
-
|
|
2258
|
+
parentId: this.mirror.getId(iframeEl),
|
|
2259
|
+
nextId: null,
|
|
2349
2260
|
node: childSn
|
|
2350
2261
|
}
|
|
2351
2262
|
],
|
|
@@ -2358,7 +2269,7 @@ class IframeManager {
|
|
|
2358
2269
|
iframeEl.contentWindow?.addEventListener("message", this.handleMessage.bind(this));
|
|
2359
2270
|
this.loadListener?.(iframeEl);
|
|
2360
2271
|
if (iframeEl.contentDocument?.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0)
|
|
2361
|
-
this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.
|
|
2272
|
+
this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
|
|
2362
2273
|
}
|
|
2363
2274
|
handleMessage(message) {
|
|
2364
2275
|
const crossOriginMessageEvent = message;
|
|
@@ -2379,10 +2290,10 @@ class IframeManager {
|
|
|
2379
2290
|
case 7 /* Pageview */: {
|
|
2380
2291
|
this.crossOriginIframeMirror.reset(iframeEl);
|
|
2381
2292
|
this.crossOriginIframeStyleMirror.reset(iframeEl);
|
|
2382
|
-
this.
|
|
2383
|
-
const
|
|
2384
|
-
this.crossOriginIframeRootIdMap.set(iframeEl,
|
|
2385
|
-
this.patchRootIdOnNode(e.data.node,
|
|
2293
|
+
this.replaceIdOnNode(e.data.node, iframeEl);
|
|
2294
|
+
const pvRootId = e.data.node.id;
|
|
2295
|
+
this.crossOriginIframeRootIdMap.set(iframeEl, pvRootId);
|
|
2296
|
+
this.patchRootIdOnNode(e.data.node, pvRootId);
|
|
2386
2297
|
return {
|
|
2387
2298
|
timestamp: e.timestamp,
|
|
2388
2299
|
type: 3 /* IncrementalSnapshot */,
|
|
@@ -2390,8 +2301,8 @@ class IframeManager {
|
|
|
2390
2301
|
source: 0 /* Mutation */,
|
|
2391
2302
|
adds: [
|
|
2392
2303
|
{
|
|
2393
|
-
|
|
2394
|
-
|
|
2304
|
+
parentId: this.mirror.getId(iframeEl),
|
|
2305
|
+
nextId: null,
|
|
2395
2306
|
node: e.data.node
|
|
2396
2307
|
}
|
|
2397
2308
|
],
|
|
@@ -2405,10 +2316,10 @@ class IframeManager {
|
|
|
2405
2316
|
case 2 /* FullSnapshot */: {
|
|
2406
2317
|
this.crossOriginIframeMirror.reset(iframeEl);
|
|
2407
2318
|
this.crossOriginIframeStyleMirror.reset(iframeEl);
|
|
2408
|
-
this.
|
|
2409
|
-
const
|
|
2410
|
-
this.crossOriginIframeRootIdMap.set(iframeEl,
|
|
2411
|
-
this.patchRootIdOnNode(e.data.node,
|
|
2319
|
+
this.replaceIdOnNode(e.data.node, iframeEl);
|
|
2320
|
+
const rootId = e.data.node.id;
|
|
2321
|
+
this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
|
|
2322
|
+
this.patchRootIdOnNode(e.data.node, rootId);
|
|
2412
2323
|
return {
|
|
2413
2324
|
timestamp: e.timestamp,
|
|
2414
2325
|
type: 3 /* IncrementalSnapshot */,
|
|
@@ -2416,8 +2327,8 @@ class IframeManager {
|
|
|
2416
2327
|
source: 0 /* Mutation */,
|
|
2417
2328
|
adds: [
|
|
2418
2329
|
{
|
|
2419
|
-
|
|
2420
|
-
|
|
2330
|
+
parentId: this.mirror.getId(iframeEl),
|
|
2331
|
+
nextId: null,
|
|
2421
2332
|
node: e.data.node
|
|
2422
2333
|
}
|
|
2423
2334
|
],
|
|
@@ -2437,11 +2348,11 @@ class IframeManager {
|
|
|
2437
2348
|
return e;
|
|
2438
2349
|
}
|
|
2439
2350
|
case 5 /* Custom */: {
|
|
2440
|
-
this.
|
|
2441
|
-
"
|
|
2442
|
-
"
|
|
2443
|
-
"
|
|
2444
|
-
"
|
|
2351
|
+
this.replaceIds(e.data.payload, iframeEl, [
|
|
2352
|
+
"id",
|
|
2353
|
+
"parentId",
|
|
2354
|
+
"previousId",
|
|
2355
|
+
"nextId"
|
|
2445
2356
|
]);
|
|
2446
2357
|
return e;
|
|
2447
2358
|
}
|
|
@@ -2449,19 +2360,19 @@ class IframeManager {
|
|
|
2449
2360
|
switch (e.data.source) {
|
|
2450
2361
|
case 0 /* Mutation */: {
|
|
2451
2362
|
e.data.adds.forEach((n) => {
|
|
2452
|
-
this.
|
|
2453
|
-
this.
|
|
2454
|
-
const
|
|
2455
|
-
|
|
2363
|
+
this.replaceIds(n, iframeEl, ["parentId", "nextId", "previousId"]);
|
|
2364
|
+
this.replaceIdOnNode(n.node, iframeEl);
|
|
2365
|
+
const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);
|
|
2366
|
+
rootId && this.patchRootIdOnNode(n.node, rootId);
|
|
2456
2367
|
});
|
|
2457
2368
|
e.data.removes.forEach((n) => {
|
|
2458
|
-
this.
|
|
2369
|
+
this.replaceIds(n, iframeEl, ["parentId", "id"]);
|
|
2459
2370
|
});
|
|
2460
2371
|
e.data.attributes.forEach((n) => {
|
|
2461
|
-
this.
|
|
2372
|
+
this.replaceIds(n, iframeEl, ["id"]);
|
|
2462
2373
|
});
|
|
2463
2374
|
e.data.texts.forEach((n) => {
|
|
2464
|
-
this.
|
|
2375
|
+
this.replaceIds(n, iframeEl, ["id"]);
|
|
2465
2376
|
});
|
|
2466
2377
|
return e;
|
|
2467
2378
|
}
|
|
@@ -2469,7 +2380,7 @@ class IframeManager {
|
|
|
2469
2380
|
case 6 /* TouchMove */:
|
|
2470
2381
|
case 1 /* MouseMove */: {
|
|
2471
2382
|
e.data.positions.forEach((p) => {
|
|
2472
|
-
this.
|
|
2383
|
+
this.replaceIds(p, iframeEl, ["id"]);
|
|
2473
2384
|
});
|
|
2474
2385
|
return e;
|
|
2475
2386
|
}
|
|
@@ -2481,12 +2392,12 @@ class IframeManager {
|
|
|
2481
2392
|
case 3 /* Scroll */:
|
|
2482
2393
|
case 9 /* CanvasMutation */:
|
|
2483
2394
|
case 5 /* Input */: {
|
|
2484
|
-
this.
|
|
2395
|
+
this.replaceIds(e.data, iframeEl, ["id"]);
|
|
2485
2396
|
return e;
|
|
2486
2397
|
}
|
|
2487
2398
|
case 8 /* StyleSheetRule */:
|
|
2488
2399
|
case 13 /* StyleDeclaration */: {
|
|
2489
|
-
this.
|
|
2400
|
+
this.replaceIds(e.data, iframeEl, ["id"]);
|
|
2490
2401
|
this.replaceStyleIds(e.data, iframeEl, ["styleId"]);
|
|
2491
2402
|
return e;
|
|
2492
2403
|
}
|
|
@@ -2495,12 +2406,12 @@ class IframeManager {
|
|
|
2495
2406
|
}
|
|
2496
2407
|
case 14 /* Selection */: {
|
|
2497
2408
|
e.data.ranges.forEach((range) => {
|
|
2498
|
-
this.
|
|
2409
|
+
this.replaceIds(range, iframeEl, ["start", "end"]);
|
|
2499
2410
|
});
|
|
2500
2411
|
return e;
|
|
2501
2412
|
}
|
|
2502
2413
|
case 15 /* AdoptedStyleSheet */: {
|
|
2503
|
-
this.
|
|
2414
|
+
this.replaceIds(e.data, iframeEl, ["id"]);
|
|
2504
2415
|
this.replaceStyleIds(e.data, iframeEl, ["styleIds"]);
|
|
2505
2416
|
e.data.styles?.forEach((style) => {
|
|
2506
2417
|
this.replaceStyleIds(style, iframeEl, ["styleId"]);
|
|
@@ -2514,36 +2425,36 @@ class IframeManager {
|
|
|
2514
2425
|
}
|
|
2515
2426
|
replace(iframeMirror, obj, iframeEl, keys) {
|
|
2516
2427
|
for (const key of keys) {
|
|
2517
|
-
if (!Array.isArray(obj[key]) && typeof obj[key] !== "
|
|
2428
|
+
if (!Array.isArray(obj[key]) && typeof obj[key] !== "number")
|
|
2518
2429
|
continue;
|
|
2519
2430
|
if (Array.isArray(obj[key])) {
|
|
2520
|
-
obj[key] = iframeMirror.
|
|
2431
|
+
obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
|
|
2521
2432
|
} else {
|
|
2522
|
-
obj[key] = iframeMirror.
|
|
2433
|
+
obj[key] = iframeMirror.getId(iframeEl, obj[key]);
|
|
2523
2434
|
}
|
|
2524
2435
|
}
|
|
2525
2436
|
return obj;
|
|
2526
2437
|
}
|
|
2527
|
-
|
|
2438
|
+
replaceIds(obj, iframeEl, keys) {
|
|
2528
2439
|
return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
|
|
2529
2440
|
}
|
|
2530
2441
|
replaceStyleIds(obj, iframeEl, keys) {
|
|
2531
2442
|
return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
|
|
2532
2443
|
}
|
|
2533
|
-
|
|
2534
|
-
this.
|
|
2444
|
+
replaceIdOnNode(node, iframeEl) {
|
|
2445
|
+
this.replaceIds(node, iframeEl, ["id", "rootId"]);
|
|
2535
2446
|
if ("childNodes" in node) {
|
|
2536
2447
|
node.childNodes.forEach((child) => {
|
|
2537
|
-
this.
|
|
2448
|
+
this.replaceIdOnNode(child, iframeEl);
|
|
2538
2449
|
});
|
|
2539
2450
|
}
|
|
2540
2451
|
}
|
|
2541
|
-
patchRootIdOnNode(node,
|
|
2452
|
+
patchRootIdOnNode(node, rootId) {
|
|
2542
2453
|
if (node.type !== 0 /* Document */ && !node.rootId)
|
|
2543
|
-
node.rootId =
|
|
2454
|
+
node.rootId = rootId;
|
|
2544
2455
|
if ("childNodes" in node) {
|
|
2545
2456
|
node.childNodes.forEach((child) => {
|
|
2546
|
-
this.patchRootIdOnNode(child,
|
|
2457
|
+
this.patchRootIdOnNode(child, rootId);
|
|
2547
2458
|
});
|
|
2548
2459
|
}
|
|
2549
2460
|
}
|
|
@@ -2640,7 +2551,7 @@ class DoubleLinkedList {
|
|
|
2640
2551
|
this.length--;
|
|
2641
2552
|
}
|
|
2642
2553
|
}
|
|
2643
|
-
var moveKey = (
|
|
2554
|
+
var moveKey = (id, parentId) => `${id}@${parentId}`;
|
|
2644
2555
|
|
|
2645
2556
|
class MutationBuffer {
|
|
2646
2557
|
frozen = false;
|
|
@@ -2767,22 +2678,22 @@ class MutationBuffer {
|
|
|
2767
2678
|
return;
|
|
2768
2679
|
}
|
|
2769
2680
|
const adds = [];
|
|
2770
|
-
const
|
|
2681
|
+
const addedIds = new Set;
|
|
2771
2682
|
const addList = new DoubleLinkedList;
|
|
2772
|
-
const
|
|
2683
|
+
const getNextId = (n) => {
|
|
2773
2684
|
let ns = n;
|
|
2774
2685
|
while (ns = ns?.nextSibling ?? null) {
|
|
2775
2686
|
if (this.mirror.isSerialized(ns)) {
|
|
2776
|
-
return this.mirror.
|
|
2687
|
+
return this.mirror.getId(ns);
|
|
2777
2688
|
}
|
|
2778
2689
|
}
|
|
2779
2690
|
return null;
|
|
2780
2691
|
};
|
|
2781
|
-
const
|
|
2692
|
+
const getPreviousId = (n) => {
|
|
2782
2693
|
let ps = n;
|
|
2783
2694
|
while (ps = ps?.previousSibling ?? null) {
|
|
2784
2695
|
if (this.mirror.isSerialized(ps)) {
|
|
2785
|
-
return this.mirror.
|
|
2696
|
+
return this.mirror.getId(ps);
|
|
2786
2697
|
}
|
|
2787
2698
|
}
|
|
2788
2699
|
return null;
|
|
@@ -2802,10 +2713,9 @@ class MutationBuffer {
|
|
|
2802
2713
|
cssCaptured = true;
|
|
2803
2714
|
}
|
|
2804
2715
|
}
|
|
2805
|
-
const
|
|
2806
|
-
const
|
|
2807
|
-
const
|
|
2808
|
-
if (!parentPath && parentPath !== "" || afterPath === "") {}
|
|
2716
|
+
const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n)) : this.mirror.getId(parent);
|
|
2717
|
+
const nextId = getNextId(n);
|
|
2718
|
+
const previousId = getPreviousId(n);
|
|
2809
2719
|
if (!this.mirror.isSerialized(parent) && !isShadowRoot(parent)) {
|
|
2810
2720
|
return addList.addNode(n);
|
|
2811
2721
|
}
|
|
@@ -2848,12 +2758,12 @@ class MutationBuffer {
|
|
|
2848
2758
|
});
|
|
2849
2759
|
if (sn) {
|
|
2850
2760
|
adds.push({
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2761
|
+
parentId,
|
|
2762
|
+
previousId,
|
|
2763
|
+
nextId,
|
|
2854
2764
|
node: sn
|
|
2855
2765
|
});
|
|
2856
|
-
|
|
2766
|
+
addedIds.add(sn.id);
|
|
2857
2767
|
}
|
|
2858
2768
|
};
|
|
2859
2769
|
while (this.mapRemoves.length) {
|
|
@@ -2880,8 +2790,7 @@ class MutationBuffer {
|
|
|
2880
2790
|
if (candidate) {
|
|
2881
2791
|
const parentNode2 = dom_default.parentNode(candidate.value);
|
|
2882
2792
|
const parentSerialized = parentNode2 && this.mirror.isSerialized(parentNode2);
|
|
2883
|
-
|
|
2884
|
-
if (parentSerialized && afterPath !== IGNORED_PATH) {
|
|
2793
|
+
if (parentSerialized) {
|
|
2885
2794
|
node = candidate;
|
|
2886
2795
|
}
|
|
2887
2796
|
}
|
|
@@ -2893,9 +2802,6 @@ class MutationBuffer {
|
|
|
2893
2802
|
if (_node) {
|
|
2894
2803
|
const parentNode2 = dom_default.parentNode(_node.value);
|
|
2895
2804
|
const parentSerialized = parentNode2 && this.mirror.isSerialized(parentNode2);
|
|
2896
|
-
const afterPath = getNextPath(_node.value);
|
|
2897
|
-
if (afterPath === IGNORED_PATH)
|
|
2898
|
-
continue;
|
|
2899
2805
|
if (parentSerialized) {
|
|
2900
2806
|
node = _node;
|
|
2901
2807
|
break;
|
|
@@ -2930,10 +2836,10 @@ class MutationBuffer {
|
|
|
2930
2836
|
this.genTextAreaValueMutation(parent);
|
|
2931
2837
|
}
|
|
2932
2838
|
return {
|
|
2933
|
-
|
|
2839
|
+
id: this.mirror.getId(n),
|
|
2934
2840
|
value: text.value
|
|
2935
2841
|
};
|
|
2936
|
-
}).filter((text) => !
|
|
2842
|
+
}).filter((text) => !addedIds.has(text.id)).filter((text) => this.mirror.has(text.id)),
|
|
2937
2843
|
attributes: this.attributes.map((attribute) => {
|
|
2938
2844
|
const { attributes } = attribute;
|
|
2939
2845
|
if (typeof attributes.style === "string") {
|
|
@@ -2946,10 +2852,10 @@ class MutationBuffer {
|
|
|
2946
2852
|
}
|
|
2947
2853
|
}
|
|
2948
2854
|
return {
|
|
2949
|
-
|
|
2855
|
+
id: this.mirror.getId(attribute.node),
|
|
2950
2856
|
attributes
|
|
2951
2857
|
};
|
|
2952
|
-
}).filter((attribute) => !
|
|
2858
|
+
}).filter((attribute) => !addedIds.has(attribute.id)).filter((attribute) => this.mirror.has(attribute.id)),
|
|
2953
2859
|
removes: this.removes,
|
|
2954
2860
|
adds
|
|
2955
2861
|
};
|
|
@@ -3087,20 +2993,20 @@ class MutationBuffer {
|
|
|
3087
2993
|
}
|
|
3088
2994
|
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
3089
2995
|
m.removedNodes.forEach((n) => {
|
|
3090
|
-
const
|
|
3091
|
-
const
|
|
2996
|
+
const nodeId = this.mirror.getId(n);
|
|
2997
|
+
const parentId = isShadowRoot(m.target) ? this.mirror.getId(dom_default.host(m.target)) : this.mirror.getId(m.target);
|
|
3092
2998
|
if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n, this.mirror, this.slimDOMOptions) || !isSerialized(n, this.mirror)) {
|
|
3093
2999
|
return;
|
|
3094
3000
|
}
|
|
3095
3001
|
if (this.addedSet.has(n)) {
|
|
3096
3002
|
deepDelete(this.addedSet, n);
|
|
3097
3003
|
this.droppedSet.add(n);
|
|
3098
|
-
} else if (this.addedSet.has(m.target) && !this.mirror.hasNode(n)) {} else if (isAncestorRemoved(m.target, this.mirror)) {} else if (this.movedSet.has(n) && this.movedMap[moveKey(
|
|
3004
|
+
} else if (this.addedSet.has(m.target) && !this.mirror.hasNode(n)) {} else if (isAncestorRemoved(m.target, this.mirror)) {} else if (this.movedSet.has(n) && this.movedMap[moveKey(nodeId, parentId)]) {
|
|
3099
3005
|
deepDelete(this.movedSet, n);
|
|
3100
3006
|
} else {
|
|
3101
3007
|
this.removes.push({
|
|
3102
|
-
|
|
3103
|
-
|
|
3008
|
+
parentId,
|
|
3009
|
+
id: nodeId,
|
|
3104
3010
|
isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : undefined
|
|
3105
3011
|
});
|
|
3106
3012
|
processRemoves(n, this.removesSubTreeCache);
|
|
@@ -3124,9 +3030,9 @@ class MutationBuffer {
|
|
|
3124
3030
|
}
|
|
3125
3031
|
this.movedSet.add(n);
|
|
3126
3032
|
if (target && this.mirror.hasNode(target)) {
|
|
3127
|
-
const
|
|
3128
|
-
if (
|
|
3129
|
-
this.movedMap[moveKey(this.mirror.
|
|
3033
|
+
const targetId = this.mirror.getId(target);
|
|
3034
|
+
if (targetId > 0) {
|
|
3035
|
+
this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;
|
|
3130
3036
|
}
|
|
3131
3037
|
}
|
|
3132
3038
|
} else {
|
|
@@ -3252,7 +3158,7 @@ function initMoveObserver({ mousemoveCb, sampling, doc, mirror }) {
|
|
|
3252
3158
|
positions.push({
|
|
3253
3159
|
x: clientX,
|
|
3254
3160
|
y: clientY,
|
|
3255
|
-
|
|
3161
|
+
id: mirror.getId(target),
|
|
3256
3162
|
timeOffset: nowTimestamp() - timeBaseline
|
|
3257
3163
|
});
|
|
3258
3164
|
wrappedCb(typeof DragEvent !== "undefined" && evt instanceof DragEvent ? 12 /* Drag */ : evt instanceof MouseEvent ? 1 /* MouseMove */ : 6 /* TouchMove */);
|
|
@@ -3325,11 +3231,11 @@ function initMouseInteractionObserver({
|
|
|
3325
3231
|
if (!e) {
|
|
3326
3232
|
return;
|
|
3327
3233
|
}
|
|
3328
|
-
const
|
|
3234
|
+
const id = mirror.getId(target);
|
|
3329
3235
|
const { clientX, clientY } = e;
|
|
3330
3236
|
callbackWrapper(mouseInteractionCb)({
|
|
3331
3237
|
type: MouseInteractions[thisEventKey],
|
|
3332
|
-
|
|
3238
|
+
id,
|
|
3333
3239
|
x: clientX,
|
|
3334
3240
|
y: clientY,
|
|
3335
3241
|
...pointerType !== null && { pointerType }
|
|
@@ -3369,17 +3275,17 @@ function initScrollObserver({
|
|
|
3369
3275
|
if (!target || isBlocked(target, blockClass, blockSelector, true)) {
|
|
3370
3276
|
return;
|
|
3371
3277
|
}
|
|
3372
|
-
const
|
|
3278
|
+
const id = mirror.getId(target);
|
|
3373
3279
|
if (target === doc && doc.defaultView) {
|
|
3374
3280
|
const scrollLeftTop = getWindowScroll(doc.defaultView);
|
|
3375
3281
|
scrollCb({
|
|
3376
|
-
|
|
3282
|
+
id,
|
|
3377
3283
|
x: scrollLeftTop.left,
|
|
3378
3284
|
y: scrollLeftTop.top
|
|
3379
3285
|
});
|
|
3380
3286
|
} else {
|
|
3381
3287
|
scrollCb({
|
|
3382
|
-
|
|
3288
|
+
id,
|
|
3383
3289
|
x: target.scrollLeft,
|
|
3384
3290
|
y: target.scrollTop
|
|
3385
3291
|
});
|
|
@@ -3460,10 +3366,10 @@ function initInputObserver({
|
|
|
3460
3366
|
const lastInputValue = lastInputValueMap.get(target);
|
|
3461
3367
|
if (!lastInputValue || lastInputValue.text !== v.text || lastInputValue.isChecked !== v.isChecked) {
|
|
3462
3368
|
lastInputValueMap.set(target, v);
|
|
3463
|
-
const
|
|
3369
|
+
const id = mirror.getId(target);
|
|
3464
3370
|
callbackWrapper(inputCb)({
|
|
3465
3371
|
...v,
|
|
3466
|
-
|
|
3372
|
+
id
|
|
3467
3373
|
});
|
|
3468
3374
|
}
|
|
3469
3375
|
}
|
|
@@ -3514,18 +3420,18 @@ function getNestedCSSRulePositions(rule) {
|
|
|
3514
3420
|
}
|
|
3515
3421
|
return recurse(rule, positions);
|
|
3516
3422
|
}
|
|
3517
|
-
function
|
|
3518
|
-
let
|
|
3423
|
+
function getIdAndStyleId(sheet, mirror, styleMirror) {
|
|
3424
|
+
let id;
|
|
3519
3425
|
let styleId;
|
|
3520
3426
|
if (!sheet)
|
|
3521
3427
|
return {};
|
|
3522
3428
|
if (sheet.ownerNode)
|
|
3523
|
-
|
|
3429
|
+
id = mirror.getId(sheet.ownerNode);
|
|
3524
3430
|
else
|
|
3525
3431
|
styleId = styleMirror.getId(sheet);
|
|
3526
3432
|
return {
|
|
3527
3433
|
styleId,
|
|
3528
|
-
|
|
3434
|
+
id
|
|
3529
3435
|
};
|
|
3530
3436
|
}
|
|
3531
3437
|
function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager }, { win }) {
|
|
@@ -3536,10 +3442,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3536
3442
|
win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
|
|
3537
3443
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3538
3444
|
const [rule, index] = argumentsList;
|
|
3539
|
-
const {
|
|
3540
|
-
if (
|
|
3445
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
3446
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3541
3447
|
styleSheetRuleCb({
|
|
3542
|
-
|
|
3448
|
+
id,
|
|
3543
3449
|
styleId,
|
|
3544
3450
|
adds: [{ rule, index }]
|
|
3545
3451
|
});
|
|
@@ -3551,10 +3457,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3551
3457
|
win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
|
|
3552
3458
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3553
3459
|
const [index] = argumentsList;
|
|
3554
|
-
const {
|
|
3555
|
-
if (
|
|
3460
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
3461
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3556
3462
|
styleSheetRuleCb({
|
|
3557
|
-
|
|
3463
|
+
id,
|
|
3558
3464
|
styleId,
|
|
3559
3465
|
removes: [{ index }]
|
|
3560
3466
|
});
|
|
@@ -3568,10 +3474,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3568
3474
|
win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
|
|
3569
3475
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3570
3476
|
const [text] = argumentsList;
|
|
3571
|
-
const {
|
|
3572
|
-
if (
|
|
3477
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
3478
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3573
3479
|
styleSheetRuleCb({
|
|
3574
|
-
|
|
3480
|
+
id,
|
|
3575
3481
|
styleId,
|
|
3576
3482
|
replace: text
|
|
3577
3483
|
});
|
|
@@ -3586,10 +3492,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3586
3492
|
win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
|
|
3587
3493
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3588
3494
|
const [text] = argumentsList;
|
|
3589
|
-
const {
|
|
3590
|
-
if (
|
|
3495
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
3496
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3591
3497
|
styleSheetRuleCb({
|
|
3592
|
-
|
|
3498
|
+
id,
|
|
3593
3499
|
styleId,
|
|
3594
3500
|
replaceSync: text
|
|
3595
3501
|
});
|
|
@@ -3621,10 +3527,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3621
3527
|
type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
|
|
3622
3528
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3623
3529
|
const [rule, index] = argumentsList;
|
|
3624
|
-
const {
|
|
3625
|
-
if (
|
|
3530
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
3531
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3626
3532
|
styleSheetRuleCb({
|
|
3627
|
-
|
|
3533
|
+
id,
|
|
3628
3534
|
styleId,
|
|
3629
3535
|
adds: [
|
|
3630
3536
|
{
|
|
@@ -3643,10 +3549,10 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3643
3549
|
type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
|
|
3644
3550
|
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
3645
3551
|
const [index] = argumentsList;
|
|
3646
|
-
const {
|
|
3647
|
-
if (
|
|
3552
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
3553
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3648
3554
|
styleSheetRuleCb({
|
|
3649
|
-
|
|
3555
|
+
id,
|
|
3650
3556
|
styleId,
|
|
3651
3557
|
removes: [{ index: [...getNestedCSSRulePositions(thisArg), index] }]
|
|
3652
3558
|
});
|
|
@@ -3667,14 +3573,14 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
|
|
|
3667
3573
|
});
|
|
3668
3574
|
}
|
|
3669
3575
|
function initAdoptedStyleSheetObserver({ mirror, stylesheetManager }, host2) {
|
|
3670
|
-
let
|
|
3576
|
+
let hostId = null;
|
|
3671
3577
|
if (host2.nodeName === "#document")
|
|
3672
|
-
|
|
3578
|
+
hostId = mirror.getId(host2);
|
|
3673
3579
|
else
|
|
3674
|
-
|
|
3580
|
+
hostId = mirror.getId(dom_default.host(host2));
|
|
3675
3581
|
const patchTarget = host2.nodeName === "#document" ? host2.defaultView?.Document : host2.ownerDocument?.defaultView?.ShadowRoot;
|
|
3676
3582
|
const originalPropertyDescriptor = patchTarget?.prototype ? Object.getOwnPropertyDescriptor(patchTarget?.prototype, "adoptedStyleSheets") : undefined;
|
|
3677
|
-
if (
|
|
3583
|
+
if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor)
|
|
3678
3584
|
return () => {};
|
|
3679
3585
|
Object.defineProperty(host2, "adoptedStyleSheets", {
|
|
3680
3586
|
configurable: originalPropertyDescriptor.configurable,
|
|
@@ -3684,9 +3590,9 @@ function initAdoptedStyleSheetObserver({ mirror, stylesheetManager }, host2) {
|
|
|
3684
3590
|
},
|
|
3685
3591
|
set(sheets) {
|
|
3686
3592
|
const result = originalPropertyDescriptor.set?.call(this, sheets);
|
|
3687
|
-
if (
|
|
3593
|
+
if (hostId !== null && hostId !== -1) {
|
|
3688
3594
|
try {
|
|
3689
|
-
stylesheetManager.adoptStyleSheets(sheets,
|
|
3595
|
+
stylesheetManager.adoptStyleSheets(sheets, hostId);
|
|
3690
3596
|
} catch (_e) {}
|
|
3691
3597
|
}
|
|
3692
3598
|
return result;
|
|
@@ -3709,10 +3615,10 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror, ignoreCSSAtt
|
|
|
3709
3615
|
if (ignoreCSSAttributes.has(property)) {
|
|
3710
3616
|
return setProperty.apply(thisArg, [property, value, priority]);
|
|
3711
3617
|
}
|
|
3712
|
-
const {
|
|
3713
|
-
if (
|
|
3618
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentRule?.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
3619
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3714
3620
|
styleDeclarationCb({
|
|
3715
|
-
|
|
3621
|
+
id,
|
|
3716
3622
|
styleId,
|
|
3717
3623
|
set: {
|
|
3718
3624
|
property,
|
|
@@ -3732,10 +3638,10 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror, ignoreCSSAtt
|
|
|
3732
3638
|
if (ignoreCSSAttributes.has(property)) {
|
|
3733
3639
|
return removeProperty.apply(thisArg, [property]);
|
|
3734
3640
|
}
|
|
3735
|
-
const {
|
|
3736
|
-
if (
|
|
3641
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentRule?.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
3642
|
+
if (id && id !== -1 || styleId && styleId !== -1) {
|
|
3737
3643
|
styleDeclarationCb({
|
|
3738
|
-
|
|
3644
|
+
id,
|
|
3739
3645
|
styleId,
|
|
3740
3646
|
remove: {
|
|
3741
3647
|
property
|
|
@@ -3767,7 +3673,7 @@ function initMediaInteractionObserver({
|
|
|
3767
3673
|
const { currentTime, volume, muted, playbackRate, loop } = target;
|
|
3768
3674
|
mediaInteractionCb({
|
|
3769
3675
|
type,
|
|
3770
|
-
|
|
3676
|
+
id: mirror.getId(target),
|
|
3771
3677
|
currentTime,
|
|
3772
3678
|
volume,
|
|
3773
3679
|
muted,
|
|
@@ -3803,9 +3709,9 @@ function initSelectionObserver(param) {
|
|
|
3803
3709
|
if (blocked)
|
|
3804
3710
|
continue;
|
|
3805
3711
|
ranges.push({
|
|
3806
|
-
start: mirror.
|
|
3712
|
+
start: mirror.getId(startContainer),
|
|
3807
3713
|
startOffset,
|
|
3808
|
-
end: mirror.
|
|
3714
|
+
end: mirror.getId(endContainer),
|
|
3809
3715
|
endOffset
|
|
3810
3716
|
});
|
|
3811
3717
|
}
|
|
@@ -3948,7 +3854,7 @@ class ShadowDomManager {
|
|
|
3948
3854
|
}));
|
|
3949
3855
|
setTimeout(() => {
|
|
3950
3856
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
3951
|
-
this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, this.mirror.
|
|
3857
|
+
this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, this.mirror.getId(dom_default.host(shadowRoot2)));
|
|
3952
3858
|
this.restoreHandlers.push(initAdoptedStyleSheetObserver({
|
|
3953
3859
|
mirror: this.mirror,
|
|
3954
3860
|
stylesheetManager: this.bypassOptions.stylesheetManager
|
|
@@ -4002,7 +3908,7 @@ class StylesheetManager {
|
|
|
4002
3908
|
texts: [],
|
|
4003
3909
|
attributes: [
|
|
4004
3910
|
{
|
|
4005
|
-
|
|
3911
|
+
id: childSn.id,
|
|
4006
3912
|
attributes: childSn.attributes
|
|
4007
3913
|
}
|
|
4008
3914
|
]
|
|
@@ -4015,11 +3921,11 @@ class StylesheetManager {
|
|
|
4015
3921
|
this.trackedLinkElements.add(linkEl);
|
|
4016
3922
|
this.trackStylesheetInLinkElement(linkEl);
|
|
4017
3923
|
}
|
|
4018
|
-
adoptStyleSheets(sheets,
|
|
3924
|
+
adoptStyleSheets(sheets, hostId) {
|
|
4019
3925
|
if (sheets.length === 0)
|
|
4020
3926
|
return;
|
|
4021
3927
|
const adoptedStyleSheetData = {
|
|
4022
|
-
|
|
3928
|
+
id: hostId,
|
|
4023
3929
|
styleIds: []
|
|
4024
3930
|
};
|
|
4025
3931
|
const styles = [];
|
|
@@ -4099,6 +4005,7 @@ function record(options = {}) {
|
|
|
4099
4005
|
return () => {};
|
|
4100
4006
|
}
|
|
4101
4007
|
mirror.reset();
|
|
4008
|
+
cleanupSnapshot();
|
|
4102
4009
|
const maskInputOptions = maskAllInputs === false ? _maskInputOptions !== undefined ? _maskInputOptions : { password: true } : {
|
|
4103
4010
|
color: true,
|
|
4104
4011
|
date: true,
|
|
@@ -4133,7 +4040,7 @@ function record(options = {}) {
|
|
|
4133
4040
|
wrappedEmit = (r, isCheckout) => {
|
|
4134
4041
|
const e = r;
|
|
4135
4042
|
e.timestamp = nowTimestamp();
|
|
4136
|
-
if (mutationBuffers[0]?.isFrozen() && e.type !==
|
|
4043
|
+
if (mutationBuffers[0]?.isFrozen() && e.type !== 4 /* Meta */ && e.type !== 2 /* FullSnapshot */ && !(e.type === 3 /* IncrementalSnapshot */ && e.data.source === 0 /* Mutation */)) {
|
|
4137
4044
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
4138
4045
|
}
|
|
4139
4046
|
if (inEmittingFrame) {
|
|
@@ -4233,7 +4140,15 @@ function record(options = {}) {
|
|
|
4233
4140
|
},
|
|
4234
4141
|
mirror
|
|
4235
4142
|
});
|
|
4236
|
-
takeFullSnapshot = (isCheckout = false,
|
|
4143
|
+
takeFullSnapshot = (isCheckout = false, navigation) => {
|
|
4144
|
+
const href = navigation?.href ?? window.location.href;
|
|
4145
|
+
if (navigation) {
|
|
4146
|
+
wrappedEmit({ type: 5 /* Custom */, data: { tag: NAVIGATION_TAG, payload: { ...navigation, href } } });
|
|
4147
|
+
}
|
|
4148
|
+
wrappedEmit({
|
|
4149
|
+
type: 4 /* Meta */,
|
|
4150
|
+
data: { href, width: getWindowWidth(), height: getWindowHeight() }
|
|
4151
|
+
}, isCheckout);
|
|
4237
4152
|
stylesheetManager.reset();
|
|
4238
4153
|
shadowDomManager.init();
|
|
4239
4154
|
mutationBuffers.forEach((buf) => buf.lock());
|
|
@@ -4275,19 +4190,12 @@ function record(options = {}) {
|
|
|
4275
4190
|
return console.warn("Failed to snapshot the document");
|
|
4276
4191
|
}
|
|
4277
4192
|
wrappedEmit({
|
|
4278
|
-
type:
|
|
4279
|
-
data: {
|
|
4280
|
-
href: window.location.href,
|
|
4281
|
-
width: getWindowWidth(),
|
|
4282
|
-
height: getWindowHeight(),
|
|
4283
|
-
node,
|
|
4284
|
-
initialOffset: getWindowScroll(window),
|
|
4285
|
-
...pageMetadata
|
|
4286
|
-
}
|
|
4193
|
+
type: 2 /* FullSnapshot */,
|
|
4194
|
+
data: { node, initialOffset: getWindowScroll(window) }
|
|
4287
4195
|
}, isCheckout);
|
|
4288
4196
|
mutationBuffers.forEach((buf) => buf.unlock());
|
|
4289
4197
|
if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
|
|
4290
|
-
stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.
|
|
4198
|
+
stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
|
|
4291
4199
|
};
|
|
4292
4200
|
try {
|
|
4293
4201
|
const handlers = [];
|
|
@@ -4405,7 +4313,7 @@ function record(options = {}) {
|
|
|
4405
4313
|
}
|
|
4406
4314
|
});
|
|
4407
4315
|
const init = () => {
|
|
4408
|
-
takeFullSnapshot(false, initialPageMetadata);
|
|
4316
|
+
takeFullSnapshot(false, inEmittingFrame ? initialPageMetadata ?? {} : undefined);
|
|
4409
4317
|
handlers.push(observe(document));
|
|
4410
4318
|
recording = true;
|
|
4411
4319
|
};
|
|
@@ -4457,9 +4365,9 @@ record.takeFullSnapshot = (isCheckout) => {
|
|
|
4457
4365
|
}
|
|
4458
4366
|
takeFullSnapshot(isCheckout);
|
|
4459
4367
|
};
|
|
4460
|
-
record.
|
|
4368
|
+
record.takeNavigationSnapshot = (metadata = {}) => {
|
|
4461
4369
|
if (!recording) {
|
|
4462
|
-
throw new Error("please take
|
|
4370
|
+
throw new Error("please take navigation snapshot after start recording");
|
|
4463
4371
|
}
|
|
4464
4372
|
flushMutationObservers();
|
|
4465
4373
|
mutationBuffers.forEach((buf) => buf.dropPending());
|
|
@@ -4539,8 +4447,11 @@ var USER_ACTIVITY_SOURCES = new Set([
|
|
|
4539
4447
|
12,
|
|
4540
4448
|
14
|
|
4541
4449
|
]);
|
|
4450
|
+
function isNavigation(event) {
|
|
4451
|
+
return event.type === 5 && event.data?.tag === "navigation";
|
|
4452
|
+
}
|
|
4542
4453
|
function isUserActivity(event) {
|
|
4543
|
-
if (event
|
|
4454
|
+
if (isNavigation(event))
|
|
4544
4455
|
return true;
|
|
4545
4456
|
if (event.type === 3)
|
|
4546
4457
|
return USER_ACTIVITY_SOURCES.has(event.data?.source ?? -1);
|
|
@@ -4654,7 +4565,13 @@ function createLunarDinosRecorder(config) {
|
|
|
4654
4565
|
method: "POST",
|
|
4655
4566
|
headers: reqHeaders,
|
|
4656
4567
|
body
|
|
4657
|
-
}).
|
|
4568
|
+
}).then((res) => {
|
|
4569
|
+
if (!res.ok) {
|
|
4570
|
+
console.error(`lunardinos: ingest request failed with status ${res.status}`);
|
|
4571
|
+
}
|
|
4572
|
+
}).catch(() => {
|
|
4573
|
+
console.error("lunardinos: ingest request failed (network error)");
|
|
4574
|
+
});
|
|
4658
4575
|
}
|
|
4659
4576
|
function sendViaBeacon(json) {
|
|
4660
4577
|
try {
|
|
@@ -4681,6 +4598,7 @@ function createLunarDinosRecorder(config) {
|
|
|
4681
4598
|
let recording2 = false;
|
|
4682
4599
|
let lastActivityAt = 0;
|
|
4683
4600
|
let rotating = false;
|
|
4601
|
+
let currentPage = {};
|
|
4684
4602
|
let pendingClickContext = null;
|
|
4685
4603
|
let pendingInputContext = null;
|
|
4686
4604
|
function captureSubmit(e) {
|
|
@@ -4727,7 +4645,7 @@ function createLunarDinosRecorder(config) {
|
|
|
4727
4645
|
const href = redactAuthFromUrl(tag === "a" ? clicked.getAttribute("href") : clicked.closest("a")?.getAttribute("href") ?? null);
|
|
4728
4646
|
pendingClickContext = { clickTag: tag, clickRole: role, clickName: name, clickHref: href };
|
|
4729
4647
|
}
|
|
4730
|
-
function rotateSession() {
|
|
4648
|
+
function rotateSession(snapshot2) {
|
|
4731
4649
|
if (rotating)
|
|
4732
4650
|
return;
|
|
4733
4651
|
rotating = true;
|
|
@@ -4740,9 +4658,11 @@ function createLunarDinosRecorder(config) {
|
|
|
4740
4658
|
}
|
|
4741
4659
|
lastActivityAt = Date.now();
|
|
4742
4660
|
markActivity();
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4661
|
+
if (snapshot2) {
|
|
4662
|
+
try {
|
|
4663
|
+
record_default.takeNavigationSnapshot(currentPage);
|
|
4664
|
+
} catch {}
|
|
4665
|
+
}
|
|
4746
4666
|
} finally {
|
|
4747
4667
|
rotating = false;
|
|
4748
4668
|
}
|
|
@@ -4787,17 +4707,23 @@ function createLunarDinosRecorder(config) {
|
|
|
4787
4707
|
} catch {}
|
|
4788
4708
|
flush();
|
|
4789
4709
|
}
|
|
4710
|
+
function pageMetadata(payload) {
|
|
4711
|
+
return {
|
|
4712
|
+
href: redactAuthFromUrl(payload.href) ?? payload.href,
|
|
4713
|
+
title: payload.title,
|
|
4714
|
+
routePattern: payload.routePattern ?? undefined,
|
|
4715
|
+
params: payload.params,
|
|
4716
|
+
locale: resolveLocale(payload.locale)
|
|
4717
|
+
};
|
|
4718
|
+
}
|
|
4790
4719
|
function emitPageEvent(payload) {
|
|
4791
4720
|
if (!recording2)
|
|
4792
4721
|
return;
|
|
4722
|
+
currentPage = pageMetadata(payload);
|
|
4793
4723
|
try {
|
|
4794
|
-
record_default.
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
routePattern: payload.routePattern ?? undefined,
|
|
4798
|
-
params: payload.params,
|
|
4799
|
-
referrer: payload.referrer ?? externalReferrer(),
|
|
4800
|
-
locale: resolveLocale(payload.locale)
|
|
4724
|
+
record_default.takeNavigationSnapshot({
|
|
4725
|
+
...currentPage,
|
|
4726
|
+
referrer: payload.referrer ?? externalReferrer()
|
|
4801
4727
|
});
|
|
4802
4728
|
} catch {}
|
|
4803
4729
|
}
|
|
@@ -4882,22 +4808,16 @@ function createLunarDinosRecorder(config) {
|
|
|
4882
4808
|
document.addEventListener("submit", captureSubmit, true);
|
|
4883
4809
|
window.addEventListener("error", captureError);
|
|
4884
4810
|
window.addEventListener("unhandledrejection", captureRejection);
|
|
4811
|
+
currentPage = startOpts.pageMetadata ? pageMetadata(startOpts.pageMetadata) : {};
|
|
4885
4812
|
stopFn = record_default({
|
|
4886
4813
|
...defaultRrwebOptions,
|
|
4887
4814
|
...rrwebOptions,
|
|
4888
|
-
initialPageMetadata: startOpts.pageMetadata ? {
|
|
4889
|
-
href: redactAuthFromUrl(startOpts.pageMetadata.href) ?? startOpts.pageMetadata.href,
|
|
4890
|
-
title: startOpts.pageMetadata.title,
|
|
4891
|
-
routePattern: startOpts.pageMetadata.routePattern ?? undefined,
|
|
4892
|
-
params: startOpts.pageMetadata.params,
|
|
4893
|
-
referrer: startOpts.pageMetadata.referrer ?? undefined,
|
|
4894
|
-
locale: resolveLocale(startOpts.pageMetadata.locale)
|
|
4895
|
-
} : undefined,
|
|
4815
|
+
initialPageMetadata: startOpts.pageMetadata ? { ...currentPage, referrer: startOpts.pageMetadata.referrer ?? undefined } : undefined,
|
|
4896
4816
|
emit(event) {
|
|
4897
4817
|
const ev = event;
|
|
4898
4818
|
if (isUserActivity(ev) && !rotating) {
|
|
4899
4819
|
if (sessionExpired(lastActivityAt, Date.now()))
|
|
4900
|
-
rotateSession();
|
|
4820
|
+
rotateSession(!isNavigation(ev));
|
|
4901
4821
|
else
|
|
4902
4822
|
markActivity();
|
|
4903
4823
|
}
|