@lvce-editor/renderer-process 30.58.0 → 30.58.2
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/rendererProcessMain.js +11408 -146
- package/dist/sessionReplayWorkerMain.js +212 -97
- package/package.json +1 -1
|
@@ -4,30 +4,79 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// ../session-replay-worker/src/
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
// ../session-replay-worker/src/parts/ReplayCommand/ReplayCommand.ts
|
|
8
|
+
var replayCommands = [
|
|
9
|
+
"Css.addCssStyleSheet",
|
|
10
|
+
"Css.removeCssStyleSheet",
|
|
11
|
+
"Viewlet.addCss",
|
|
12
|
+
"Viewlet.append",
|
|
13
|
+
"Viewlet.appendToBody",
|
|
14
|
+
"Viewlet.appendToRoot",
|
|
15
|
+
"Viewlet.commitPending",
|
|
16
|
+
"Viewlet.create",
|
|
17
|
+
"Viewlet.createFunctionalRoot",
|
|
18
|
+
"Viewlet.createPlaceholder",
|
|
19
|
+
"Viewlet.dispose",
|
|
20
|
+
"Viewlet.executeCommands",
|
|
21
|
+
"Viewlet.patchCss",
|
|
22
|
+
"Viewlet.queueCommands",
|
|
23
|
+
"Viewlet.replaceChildren",
|
|
24
|
+
"Viewlet.scrollSelectorBy",
|
|
25
|
+
"Viewlet.sendMultiple",
|
|
26
|
+
"Viewlet.setBounds",
|
|
27
|
+
"Viewlet.setCheckBoxValue",
|
|
28
|
+
"Viewlet.setComponentDom",
|
|
29
|
+
"Viewlet.setCss",
|
|
30
|
+
"Viewlet.setDom",
|
|
31
|
+
"Viewlet.setDom2",
|
|
32
|
+
"Viewlet.setInputValues",
|
|
33
|
+
"Viewlet.setPatches",
|
|
34
|
+
"Viewlet.setProperty",
|
|
35
|
+
"Viewlet.setTreePatches",
|
|
36
|
+
"Viewlet.setValueByName",
|
|
37
|
+
"Viewlet.show"
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
// ../session-replay-worker/src/parts/FilterReplayMessage/FilterReplayMessage.ts
|
|
41
|
+
var createReplayMessageFilter = () => {
|
|
42
|
+
const replies = /* @__PURE__ */ Object.create(null);
|
|
43
|
+
return ({ connection, direction, message, renderer }) => {
|
|
44
|
+
if (!renderer || !message || typeof message !== "object") return false;
|
|
45
|
+
const { id, method } = message;
|
|
46
|
+
if (direction === "to-renderer") {
|
|
47
|
+
if (!replayCommands.includes(method)) return false;
|
|
48
|
+
if (method === "Viewlet.queueCommands" && id !== void 0) {
|
|
49
|
+
const pending3 = replies[connection] ||= [];
|
|
50
|
+
if (!pending3.includes(id)) pending3.push(id);
|
|
24
51
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (method || id === void 0) return false;
|
|
55
|
+
const pending2 = replies[connection];
|
|
56
|
+
const index = pending2?.indexOf(id) ?? -1;
|
|
57
|
+
if (index === -1) return false;
|
|
58
|
+
pending2.splice(index, 1);
|
|
59
|
+
if (pending2.length === 0) delete replies[connection];
|
|
60
|
+
return true;
|
|
28
61
|
};
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ../session-replay-worker/src/parts/Activity/Activity.ts
|
|
65
|
+
var getActivity = (events, duration) => {
|
|
66
|
+
const length = Math.max(1, Math.min(240, Math.ceil(duration / 250)));
|
|
67
|
+
const counts = Array.from({ length });
|
|
68
|
+
counts.fill(0);
|
|
69
|
+
if (duration <= 0) return counts;
|
|
70
|
+
let initialFrame = true;
|
|
71
|
+
for (const event of events) {
|
|
72
|
+
if (event.type === "frame" && initialFrame) {
|
|
73
|
+
initialFrame = false;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const index = Math.min(counts.length - 1, Math.floor(event.timestamp / duration * counts.length));
|
|
77
|
+
counts[index]++;
|
|
78
|
+
}
|
|
79
|
+
return counts;
|
|
31
80
|
};
|
|
32
81
|
|
|
33
82
|
// ../../node_modules/@lvce-editor/constants/dist/parts/ElementTagMap/ElementTagMap.js
|
|
@@ -374,9 +423,9 @@ var getElementTag = (type) => {
|
|
|
374
423
|
throw new Error(`element tag not found ${type}`);
|
|
375
424
|
};
|
|
376
425
|
|
|
377
|
-
// ../session-replay-worker/src/
|
|
426
|
+
// ../session-replay-worker/src/parts/VisualDom/VisualDom.ts
|
|
378
427
|
var element = (tag = "div") => ({ attrs: {}, children: [], tag });
|
|
379
|
-
var styleKeys =
|
|
428
|
+
var styleKeys = ["width", "height", "top", "left", "translate", "marginTop", "paddingLeft", "paddingRight"];
|
|
380
429
|
var attributes = { className: "class", htmlFor: "for", inputType: "type" };
|
|
381
430
|
var setStyle = (node, key, value) => {
|
|
382
431
|
node.attrs ||= {};
|
|
@@ -402,7 +451,7 @@ var property = (node, key, value) => {
|
|
|
402
451
|
default:
|
|
403
452
|
break;
|
|
404
453
|
}
|
|
405
|
-
if (styleKeys.
|
|
454
|
+
if (styleKeys.includes(key)) {
|
|
406
455
|
setStyle(
|
|
407
456
|
node,
|
|
408
457
|
key.replaceAll(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`),
|
|
@@ -430,8 +479,21 @@ var find = (node, selector) => {
|
|
|
430
479
|
}
|
|
431
480
|
return void 0;
|
|
432
481
|
};
|
|
482
|
+
var expandPatches = (patches) => patches.flatMap((value) => {
|
|
483
|
+
if (value.type !== 18) return [value];
|
|
484
|
+
const { navigations } = value;
|
|
485
|
+
if (!Array.isArray(navigations) || navigations.length % 2 !== 0) throw new Error("Invalid compact replay navigation");
|
|
486
|
+
const result = [];
|
|
487
|
+
for (let index = 0; index < navigations.length; index += 2) {
|
|
488
|
+
const type = navigations[index];
|
|
489
|
+
const childIndex = navigations[index + 1];
|
|
490
|
+
if (![7, 8, 10].includes(type) || !Number.isSafeInteger(childIndex) || childIndex < 0) throw new Error("Invalid compact replay navigation");
|
|
491
|
+
result.push({ ...value, index: childIndex, type });
|
|
492
|
+
}
|
|
493
|
+
return result;
|
|
494
|
+
});
|
|
433
495
|
var createVisualDom = () => {
|
|
434
|
-
const views = /* @__PURE__ */
|
|
496
|
+
const views = /* @__PURE__ */ Object.create(null);
|
|
435
497
|
const parents = /* @__PURE__ */ new WeakMap();
|
|
436
498
|
const owners = /* @__PURE__ */ new WeakMap();
|
|
437
499
|
let nodeCount = 0;
|
|
@@ -464,14 +526,14 @@ var createVisualDom = () => {
|
|
|
464
526
|
if (parent) append(parent, next, index);
|
|
465
527
|
const uid = owners.get(node);
|
|
466
528
|
if (uid !== void 0) {
|
|
467
|
-
views
|
|
529
|
+
views[uid] = next;
|
|
468
530
|
owners.set(next, uid);
|
|
469
531
|
}
|
|
470
532
|
return next;
|
|
471
533
|
};
|
|
472
534
|
const renderNode = (value) => {
|
|
473
535
|
let node;
|
|
474
|
-
if (value.type === VirtualDomElements_exports.Reference) node = views
|
|
536
|
+
if (value.type === VirtualDomElements_exports.Reference) node = views[value.uid] || { text: "Reference node not found" };
|
|
475
537
|
else if (value.type === VirtualDomElements_exports.Text) node = { text: value.text };
|
|
476
538
|
else {
|
|
477
539
|
node = element(ElementTagMap_exports.getElementTag(value.type));
|
|
@@ -498,8 +560,9 @@ var createVisualDom = () => {
|
|
|
498
560
|
if (stack.some((entry) => entry.remaining !== 0)) throw new Error("Incomplete replay virtual DOM");
|
|
499
561
|
return roots;
|
|
500
562
|
};
|
|
501
|
-
const patch = (uid,
|
|
502
|
-
|
|
563
|
+
const patch = (uid, input) => {
|
|
564
|
+
const patches = expandPatches(input);
|
|
565
|
+
let current = views[uid];
|
|
503
566
|
if (!current) return;
|
|
504
567
|
owners.set(current, uid);
|
|
505
568
|
const mutations = {
|
|
@@ -509,7 +572,7 @@ var createVisualDom = () => {
|
|
|
509
572
|
},
|
|
510
573
|
10: (node, value) => parents.get(node)?.children?.[value.index],
|
|
511
574
|
11: (node, value) => {
|
|
512
|
-
const next = views
|
|
575
|
+
const next = views[value.uid];
|
|
513
576
|
return next ? replace(node, next) : node;
|
|
514
577
|
},
|
|
515
578
|
2: (node, value) => {
|
|
@@ -540,7 +603,7 @@ var createVisualDom = () => {
|
|
|
540
603
|
};
|
|
541
604
|
for (let index = 0; index < patches.length; index++) {
|
|
542
605
|
const value = patches[index];
|
|
543
|
-
if (value.type === 7 && value.index === current.children?.length && patches[index + 1]?.type
|
|
606
|
+
if (value.type === 7 && value.index === current.children?.length && [2, 11].includes(patches[index + 1]?.type)) append(current, element());
|
|
544
607
|
if (!mutations[value.type]) continue;
|
|
545
608
|
current = mutations[value.type](current, value);
|
|
546
609
|
if (!current) return;
|
|
@@ -549,21 +612,21 @@ var createVisualDom = () => {
|
|
|
549
612
|
return { append, clear, detach, element, find, patch, property, render, replace, views };
|
|
550
613
|
};
|
|
551
614
|
|
|
552
|
-
// ../session-replay-worker/src/
|
|
615
|
+
// ../session-replay-worker/src/parts/VisualState/VisualState.ts
|
|
553
616
|
var createVisualState = (initial) => {
|
|
554
617
|
const frame = structuredClone(initial);
|
|
555
618
|
const dom = createVisualDom();
|
|
556
619
|
const { append, clear, detach, element: element2, find: find2, patch, property: property2, render, replace, views } = dom;
|
|
557
|
-
|
|
558
|
-
const calls = /* @__PURE__ */
|
|
559
|
-
const batches =
|
|
620
|
+
let sheets = (frame.styles || []).map((text, index) => ({ text, uid: `initial-${index}` }));
|
|
621
|
+
const calls = /* @__PURE__ */ Object.create(null);
|
|
622
|
+
const batches = [];
|
|
560
623
|
const setDom = (uid, nodes) => {
|
|
561
|
-
const view = views
|
|
624
|
+
const view = views[uid];
|
|
562
625
|
if (!view) return;
|
|
563
626
|
const next = render(nodes)[0];
|
|
564
627
|
if (next) {
|
|
565
628
|
replace(view, next);
|
|
566
|
-
views
|
|
629
|
+
views[uid] = next;
|
|
567
630
|
}
|
|
568
631
|
};
|
|
569
632
|
const apply = (method, params = []) => {
|
|
@@ -573,26 +636,28 @@ var createVisualState = (initial) => {
|
|
|
573
636
|
for (const [method, ...params] of commands2) apply(method, params);
|
|
574
637
|
};
|
|
575
638
|
const commit = (uid, transaction) => {
|
|
576
|
-
const batch = batches.
|
|
639
|
+
const batch = batches.find((entry) => entry.transaction === transaction);
|
|
577
640
|
if (!batch || batch.uid !== uid) return;
|
|
578
641
|
batch.committed = true;
|
|
579
|
-
for (
|
|
642
|
+
for (let index = 0; index < batches.length; index++) {
|
|
643
|
+
const pending2 = batches[index];
|
|
580
644
|
if (pending2.uid !== uid) continue;
|
|
581
645
|
if (!pending2.committed) return;
|
|
582
646
|
execute(pending2.commands);
|
|
583
|
-
batches.
|
|
647
|
+
batches.splice(index, 1);
|
|
648
|
+
index--;
|
|
584
649
|
}
|
|
585
650
|
};
|
|
586
651
|
const appendView = (uid, childId, references) => {
|
|
587
|
-
const view = views
|
|
588
|
-
const child = views
|
|
652
|
+
const view = views[uid];
|
|
653
|
+
const child = views[childId];
|
|
589
654
|
if (!view || !child) return;
|
|
590
655
|
const nextReferences = references?.slice(references.indexOf(childId) + 1) || [];
|
|
591
|
-
const next = nextReferences.map((id) => views
|
|
656
|
+
const next = nextReferences.map((id) => views[id]).find((node) => node && view.children?.includes(node));
|
|
592
657
|
append(view, child, next ? view.children.indexOf(next) : void 0);
|
|
593
658
|
};
|
|
594
659
|
const setProperty = (uid, selector, key, value) => {
|
|
595
|
-
const view = views
|
|
660
|
+
const view = views[uid];
|
|
596
661
|
const node = view && find2(view, selector);
|
|
597
662
|
if (!node) return;
|
|
598
663
|
if (key === "textContent") {
|
|
@@ -601,29 +666,31 @@ var createVisualState = (initial) => {
|
|
|
601
666
|
} else property2(node, key, value);
|
|
602
667
|
};
|
|
603
668
|
const setBounds = (uid, left, top, width, height) => {
|
|
604
|
-
const view = views
|
|
669
|
+
const view = views[uid];
|
|
605
670
|
const bounds = Object.entries({ height, left, top, width });
|
|
606
671
|
for (const [key, value] of bounds) property2(view, key, value);
|
|
607
672
|
};
|
|
608
673
|
const setCss = (uid, text) => {
|
|
609
|
-
sheets.
|
|
674
|
+
const sheet = sheets.find((entry) => [entry.uid].includes(uid));
|
|
675
|
+
if (sheet) sheet.text = text;
|
|
676
|
+
else sheets.push({ text, uid });
|
|
610
677
|
};
|
|
611
678
|
const create = (_id, uid = Number(_id)) => {
|
|
612
|
-
views
|
|
679
|
+
views[uid] = element2();
|
|
613
680
|
};
|
|
614
681
|
const handlers = {
|
|
615
682
|
"Css.addCssStyleSheet": setCss,
|
|
616
683
|
"Css.removeCssStyleSheet": (uid) => {
|
|
617
|
-
sheets.
|
|
684
|
+
sheets = sheets.filter((entry) => ![entry.uid].includes(uid));
|
|
618
685
|
},
|
|
619
686
|
"Viewlet.addCss": setCss,
|
|
620
687
|
"Viewlet.append": appendView,
|
|
621
688
|
"Viewlet.appendToBody": (uid) => {
|
|
622
|
-
const view = views
|
|
689
|
+
const view = views[uid];
|
|
623
690
|
if (view) append(frame.dom, view);
|
|
624
691
|
},
|
|
625
692
|
"Viewlet.appendToRoot": (uid, root) => {
|
|
626
|
-
const view = views
|
|
693
|
+
const view = views[uid];
|
|
627
694
|
const parent = find2(frame.dom, `#${root}`);
|
|
628
695
|
if (view && parent) append(parent, view);
|
|
629
696
|
},
|
|
@@ -631,33 +698,33 @@ var createVisualState = (initial) => {
|
|
|
631
698
|
"Viewlet.create": create,
|
|
632
699
|
"Viewlet.createFunctionalRoot": create,
|
|
633
700
|
"Viewlet.createPlaceholder": (uid, parentId, top, left, width, height) => {
|
|
634
|
-
views
|
|
635
|
-
property2(views
|
|
701
|
+
views[uid] = element2();
|
|
702
|
+
property2(views[uid], "className", `Viewlet ${uid}`);
|
|
636
703
|
setBounds(uid, left, top, width, height);
|
|
637
704
|
appendView(parentId, uid);
|
|
638
705
|
},
|
|
639
706
|
"Viewlet.dispose": (uid) => {
|
|
640
|
-
const view = views
|
|
707
|
+
const view = views[uid];
|
|
641
708
|
if (view) detach(view);
|
|
642
|
-
views
|
|
643
|
-
sheets.
|
|
709
|
+
delete views[uid];
|
|
710
|
+
sheets = sheets.filter((entry) => ![entry.uid].includes(uid));
|
|
644
711
|
},
|
|
645
712
|
"Viewlet.executeCommands": execute,
|
|
646
713
|
"Viewlet.patchCss": (uid, start, count, replacement) => {
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
714
|
+
const sheet = sheets.find((entry) => [entry.uid].includes(uid));
|
|
715
|
+
if (sheet) sheet.text = sheet.text.slice(0, start) + replacement + sheet.text.slice(start + count);
|
|
649
716
|
},
|
|
650
717
|
"Viewlet.replaceChildren": (uid, children) => {
|
|
651
|
-
const view = views
|
|
718
|
+
const view = views[uid];
|
|
652
719
|
if (!view) return;
|
|
653
720
|
clear(view);
|
|
654
721
|
for (const id of children) {
|
|
655
|
-
const child = views
|
|
722
|
+
const child = views[id];
|
|
656
723
|
if (child) append(view, child);
|
|
657
724
|
}
|
|
658
725
|
},
|
|
659
726
|
"Viewlet.scrollSelectorBy": (uid, selector, delta) => {
|
|
660
|
-
const view = views
|
|
727
|
+
const view = views[uid];
|
|
661
728
|
const node = view && find2(view, selector);
|
|
662
729
|
if (node) property2(node, "scrollLeft", (node.scroll?.[0] || 0) + delta);
|
|
663
730
|
},
|
|
@@ -667,7 +734,7 @@ var createVisualState = (initial) => {
|
|
|
667
734
|
"Viewlet.setComponentDom": setDom,
|
|
668
735
|
"Viewlet.setCss": setCss,
|
|
669
736
|
"Viewlet.setDom": (uid, nodes) => {
|
|
670
|
-
const view = views
|
|
737
|
+
const view = views[uid];
|
|
671
738
|
if (!view) return;
|
|
672
739
|
clear(view);
|
|
673
740
|
const children = render(nodes);
|
|
@@ -685,7 +752,7 @@ var createVisualState = (initial) => {
|
|
|
685
752
|
"Viewlet.setTreePatches": patch,
|
|
686
753
|
"Viewlet.setValueByName": (uid, name, value) => setProperty(uid, `[name="${name}"]`, "value", value),
|
|
687
754
|
"Viewlet.show": (uid) => {
|
|
688
|
-
const view = views
|
|
755
|
+
const view = views[uid];
|
|
689
756
|
if (view) append(find2(frame.dom, "#Workbench") || frame.dom, view);
|
|
690
757
|
}
|
|
691
758
|
};
|
|
@@ -695,21 +762,27 @@ var createVisualState = (initial) => {
|
|
|
695
762
|
const { connection, direction, message } = data;
|
|
696
763
|
const key = `${connection}:${message.id}`;
|
|
697
764
|
if (direction === "to-renderer") {
|
|
698
|
-
if (message.method === "Viewlet.queueCommands") calls
|
|
765
|
+
if (message.method === "Viewlet.queueCommands") calls[key] = message.params;
|
|
699
766
|
else apply(message.method, message.params);
|
|
700
|
-
} else if (
|
|
701
|
-
const [uid, commands2] = calls
|
|
702
|
-
calls
|
|
703
|
-
if (Number.isSafeInteger(message.result))
|
|
767
|
+
} else if (Object.hasOwn(calls, key)) {
|
|
768
|
+
const [uid, commands2] = calls[key];
|
|
769
|
+
delete calls[key];
|
|
770
|
+
if (Number.isSafeInteger(message.result)) {
|
|
771
|
+
const transaction = message.result;
|
|
772
|
+
const batch = { commands: commands2, committed: false, transaction, uid };
|
|
773
|
+
const index = batches.findIndex((entry) => entry.transaction === transaction);
|
|
774
|
+
if (index === -1) batches.push(batch);
|
|
775
|
+
else batches[index] = batch;
|
|
776
|
+
}
|
|
704
777
|
}
|
|
705
778
|
},
|
|
706
779
|
frame() {
|
|
707
|
-
return { ...frame, styles:
|
|
780
|
+
return { ...frame, styles: sheets.map((sheet) => sheet.text) };
|
|
708
781
|
}
|
|
709
782
|
};
|
|
710
783
|
};
|
|
711
784
|
|
|
712
|
-
// ../session-replay-worker/src/
|
|
785
|
+
// ../session-replay-worker/src/parts/Protocol/Protocol.ts
|
|
713
786
|
var version = 1;
|
|
714
787
|
var maxEventBytes = 75e4;
|
|
715
788
|
var maxSessionBytes = 64 * 1024 * 1024;
|
|
@@ -760,19 +833,46 @@ var loadContent = (value) => {
|
|
|
760
833
|
}
|
|
761
834
|
return { duration, frame: frames[Math.max(0, low - 1)].data, position };
|
|
762
835
|
};
|
|
763
|
-
return { duration, seek };
|
|
836
|
+
return { activity: getActivity(session.events, duration), duration, seek };
|
|
764
837
|
};
|
|
765
838
|
|
|
766
|
-
// ../session-replay-worker/src/
|
|
767
|
-
var
|
|
839
|
+
// ../session-replay-worker/src/parts/Transfer/Transfer.ts
|
|
840
|
+
var getTransferrables = (value) => {
|
|
841
|
+
const seen = [];
|
|
842
|
+
const result = [];
|
|
843
|
+
const visit = (item) => {
|
|
844
|
+
if (!item || typeof item !== "object" || seen.includes(item)) return;
|
|
845
|
+
seen.push(item);
|
|
846
|
+
if (Object.prototype.toString.call(item) === "[object ArrayBuffer]") result.push(item);
|
|
847
|
+
else if (ArrayBuffer.isView(item)) visit(item.buffer);
|
|
848
|
+
else if (["MessagePort", "OffscreenCanvas", "ImageBitmap", "AudioData", "VideoFrame", "ReadableStream", "WritableStream", "TransformStream"].some(
|
|
849
|
+
(name) => typeof globalThis[name] === "function" && item instanceof globalThis[name]
|
|
850
|
+
))
|
|
851
|
+
result.push(item);
|
|
852
|
+
else if (Object.prototype.toString.call(item) === "[object Map]") {
|
|
853
|
+
for (const [key, entry] of item) {
|
|
854
|
+
visit(key);
|
|
855
|
+
visit(entry);
|
|
856
|
+
}
|
|
857
|
+
} else if (Object.prototype.toString.call(item) === "[object Set]") {
|
|
858
|
+
for (const entry of item) visit(entry);
|
|
859
|
+
} else for (const entry of Object.values(item)) visit(entry);
|
|
860
|
+
};
|
|
861
|
+
visit(value);
|
|
862
|
+
return result;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
// ../session-replay-worker/src/parts/Proxy/Proxy.ts
|
|
866
|
+
var wrapPorts = (value, replacePort, seen = []) => {
|
|
768
867
|
if (!value || typeof value !== "object") return value;
|
|
769
|
-
|
|
868
|
+
const previous = seen.find((entry) => entry.original === value);
|
|
869
|
+
if (previous) return previous.replacement;
|
|
770
870
|
if (value instanceof MessagePort) {
|
|
771
871
|
const replacement = replacePort(value);
|
|
772
|
-
seen.
|
|
872
|
+
seen.push({ original: value, replacement });
|
|
773
873
|
return replacement;
|
|
774
874
|
}
|
|
775
|
-
seen.
|
|
875
|
+
seen.push({ original: value, replacement: value });
|
|
776
876
|
if (value instanceof Map) {
|
|
777
877
|
const entries = [...value];
|
|
778
878
|
value.clear();
|
|
@@ -787,12 +887,18 @@ var wrapPorts = (value, replacePort, seen = /* @__PURE__ */ new Map()) => {
|
|
|
787
887
|
}
|
|
788
888
|
return value;
|
|
789
889
|
};
|
|
890
|
+
var consumeReply = (replies, id) => {
|
|
891
|
+
const index = replies.findIndex((reply) => [reply].includes(id));
|
|
892
|
+
if (index === -1) return false;
|
|
893
|
+
replies.splice(index, 1);
|
|
894
|
+
return true;
|
|
895
|
+
};
|
|
790
896
|
var createProxyRegistry = ({
|
|
791
897
|
record,
|
|
792
898
|
report: report2 = () => {
|
|
793
899
|
}
|
|
794
900
|
}) => {
|
|
795
|
-
const connections = /* @__PURE__ */
|
|
901
|
+
const connections = /* @__PURE__ */ Object.create(null);
|
|
796
902
|
let nextId = 0;
|
|
797
903
|
const createNestedPort = (connection, renderer, port) => create(port, `${connection}/port`, renderer);
|
|
798
904
|
const create = (port, label = "renderer", renderer = true) => {
|
|
@@ -806,16 +912,16 @@ var createProxyRegistry = ({
|
|
|
806
912
|
endpoint.onmessageerror = null;
|
|
807
913
|
endpoint.close();
|
|
808
914
|
}
|
|
809
|
-
connections
|
|
915
|
+
delete connections[connection];
|
|
810
916
|
};
|
|
811
|
-
connections
|
|
812
|
-
const ignoredReplies = { "from-renderer":
|
|
917
|
+
connections[connection] = close;
|
|
918
|
+
const ignoredReplies = { "from-renderer": [], "to-renderer": [] };
|
|
813
919
|
const forward = (source, target, direction) => {
|
|
814
920
|
source.onmessage = ({ data }) => {
|
|
815
921
|
const opposite = direction === "to-renderer" ? "from-renderer" : "to-renderer";
|
|
816
922
|
const ignored = typeof data?.method === "string" && data.method.startsWith("SessionReplay.");
|
|
817
|
-
if (ignored && data.id !== void 0) ignoredReplies[opposite].
|
|
818
|
-
const ignoredReply = !data?.method && ignoredReplies[direction]
|
|
923
|
+
if (ignored && data.id !== void 0 && !ignoredReplies[opposite].includes(data.id)) ignoredReplies[opposite].push(data.id);
|
|
924
|
+
const ignoredReply = !data?.method && consumeReply(ignoredReplies[direction], data?.id);
|
|
819
925
|
if (!ignored && !ignoredReply) {
|
|
820
926
|
try {
|
|
821
927
|
record({ connection, direction, label, message: data, renderer });
|
|
@@ -839,14 +945,15 @@ var createProxyRegistry = ({
|
|
|
839
945
|
return {
|
|
840
946
|
create,
|
|
841
947
|
dispose() {
|
|
842
|
-
for (const close of connections) close();
|
|
948
|
+
for (const close of Object.values(connections)) close();
|
|
843
949
|
}
|
|
844
950
|
};
|
|
845
951
|
};
|
|
846
952
|
|
|
847
|
-
// ../session-replay-worker/src/
|
|
953
|
+
// ../session-replay-worker/src/parts/Recorder/Recorder.ts
|
|
848
954
|
var createRecorder = ({
|
|
849
955
|
fetch: request = globalThis.fetch,
|
|
956
|
+
navigator = globalThis.navigator,
|
|
850
957
|
now = () => performance.now(),
|
|
851
958
|
storage: storage2
|
|
852
959
|
}) => {
|
|
@@ -865,7 +972,13 @@ var createRecorder = ({
|
|
|
865
972
|
if (metadata) throw new Error("A session is already recording");
|
|
866
973
|
options = config;
|
|
867
974
|
origin = now();
|
|
868
|
-
metadata = {
|
|
975
|
+
metadata = {
|
|
976
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
977
|
+
id: crypto.randomUUID(),
|
|
978
|
+
platform: navigator?.platform || "",
|
|
979
|
+
userAgent: navigator?.userAgent || "",
|
|
980
|
+
version
|
|
981
|
+
};
|
|
869
982
|
if (options.local) await storage2.save(metadata, []);
|
|
870
983
|
return metadata.id;
|
|
871
984
|
};
|
|
@@ -899,7 +1012,8 @@ var createRecorder = ({
|
|
|
899
1012
|
if (!response.ok) throw new Error(`Session replay upload failed (${response.status})`);
|
|
900
1013
|
return response.json();
|
|
901
1014
|
};
|
|
902
|
-
if (!remote)
|
|
1015
|
+
if (!remote)
|
|
1016
|
+
remote = await send(endpoint, { createdAt: metadata.createdAt, platform: metadata.platform, userAgent: metadata.userAgent, version });
|
|
903
1017
|
while (pending2.length > 0) {
|
|
904
1018
|
const batch = [];
|
|
905
1019
|
let batchBytes = 0;
|
|
@@ -947,7 +1061,7 @@ var createRecorder = ({
|
|
|
947
1061
|
};
|
|
948
1062
|
};
|
|
949
1063
|
|
|
950
|
-
// ../session-replay-worker/src/
|
|
1064
|
+
// ../session-replay-worker/src/parts/Capture/Capture.ts
|
|
951
1065
|
var serializeMessage = (message) => {
|
|
952
1066
|
const ancestors = [];
|
|
953
1067
|
let count = 0;
|
|
@@ -968,13 +1082,13 @@ var serializeMessage = (message) => {
|
|
|
968
1082
|
);
|
|
969
1083
|
};
|
|
970
1084
|
|
|
971
|
-
// ../session-replay-worker/src/
|
|
1085
|
+
// ../session-replay-worker/src/parts/SerializeProxyMessage/SerializeProxyMessage.ts
|
|
972
1086
|
var redacted = "[redacted]";
|
|
973
1087
|
var isMasked = (node) => node.inputType === "password" || Object.hasOwn(node, "data-session-replay-mask") || Object.hasOwn(node, "data-session-replay-ignore");
|
|
974
|
-
var structuralKeys =
|
|
1088
|
+
var structuralKeys = ["type", "childCount", "uid"];
|
|
975
1089
|
var redactNode = (node) => {
|
|
976
1090
|
for (const key of Object.keys(node)) {
|
|
977
|
-
if (structuralKeys.
|
|
1091
|
+
if (structuralKeys.includes(key)) continue;
|
|
978
1092
|
if (["text", "value", "textContent"].includes(key)) node[key] = redacted;
|
|
979
1093
|
else if (key === "inputType" && node[key] === "password") continue;
|
|
980
1094
|
else if (["data-session-replay-mask", "data-session-replay-ignore"].includes(key)) node[key] = "";
|
|
@@ -993,14 +1107,14 @@ var redactUpdates = (method, params) => {
|
|
|
993
1107
|
}
|
|
994
1108
|
};
|
|
995
1109
|
var createMessageSerializer = () => {
|
|
996
|
-
const maskedViews = /* @__PURE__ */
|
|
1110
|
+
const maskedViews = /* @__PURE__ */ Object.create(null);
|
|
997
1111
|
const sanitizeCommand = (method, params, masked) => {
|
|
998
1112
|
if (!method.startsWith("Viewlet.") || typeof params[0] !== "number") return;
|
|
999
1113
|
const uid = params[0];
|
|
1000
1114
|
const patches = params[1];
|
|
1001
1115
|
const masksInput = Array.isArray(patches) && patches.some((patch) => patch?.key === "inputType" && patch.value === "password");
|
|
1002
|
-
if (masked || masksInput) maskedViews
|
|
1003
|
-
if (maskedViews
|
|
1116
|
+
if (masked || masksInput) maskedViews[uid] = true;
|
|
1117
|
+
if (maskedViews[uid]) redactUpdates(method, params);
|
|
1004
1118
|
};
|
|
1005
1119
|
const sanitizeArray = (array) => {
|
|
1006
1120
|
let remaining = 0;
|
|
@@ -1040,7 +1154,7 @@ var createMessageSerializer = () => {
|
|
|
1040
1154
|
};
|
|
1041
1155
|
};
|
|
1042
1156
|
|
|
1043
|
-
// ../session-replay-worker/src/
|
|
1157
|
+
// ../session-replay-worker/src/parts/Storage/Storage.ts
|
|
1044
1158
|
var withoutSessionId = ({ sessionId, ...event }) => event;
|
|
1045
1159
|
var open = () => new Promise((resolve, reject) => {
|
|
1046
1160
|
const request = indexedDB.open("lvce-session-replays", 1);
|
|
@@ -1075,7 +1189,7 @@ var createStorage = async () => {
|
|
|
1075
1189
|
};
|
|
1076
1190
|
};
|
|
1077
1191
|
|
|
1078
|
-
// ../session-replay-worker/src/
|
|
1192
|
+
// ../session-replay-worker/src/parts/Worker/Worker.ts
|
|
1079
1193
|
var storage;
|
|
1080
1194
|
var recorder;
|
|
1081
1195
|
var content;
|
|
@@ -1091,9 +1205,10 @@ var report = (error) => {
|
|
|
1091
1205
|
recording = false;
|
|
1092
1206
|
};
|
|
1093
1207
|
var serializeMessage2 = createMessageSerializer();
|
|
1208
|
+
var shouldRecord = createReplayMessageFilter();
|
|
1094
1209
|
var proxies = createProxyRegistry({
|
|
1095
1210
|
record(message) {
|
|
1096
|
-
if (!recording) return;
|
|
1211
|
+
if (!recording || !shouldRecord(message)) return;
|
|
1097
1212
|
if (pending >= 500) {
|
|
1098
1213
|
report(new Error("Recording cannot keep up with worker messages"));
|
|
1099
1214
|
return;
|
|
@@ -1125,7 +1240,7 @@ var commands = {
|
|
|
1125
1240
|
session = await response.json();
|
|
1126
1241
|
} else ({ session } = source);
|
|
1127
1242
|
content = loadContent(session);
|
|
1128
|
-
return content.seek(0);
|
|
1243
|
+
return { ...content.seek(0), activity: content.activity };
|
|
1129
1244
|
},
|
|
1130
1245
|
proxy: (port) => proxies.create(port),
|
|
1131
1246
|
record: (...params) => recorder.record(...params),
|