plum-e2e 2.9.13 → 2.9.14
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.
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
const META_EVENT_TYPE = 4;
|
|
17
17
|
|
|
18
|
+
let viewport;
|
|
18
19
|
let stage;
|
|
19
20
|
let container;
|
|
20
21
|
let player = null;
|
|
@@ -23,14 +24,18 @@
|
|
|
23
24
|
let nativeHeight = 0;
|
|
24
25
|
let resizeObserver;
|
|
25
26
|
|
|
26
|
-
// rrweb-player renders at the recording's native resolution
|
|
27
|
-
// it to
|
|
28
|
-
//
|
|
29
|
-
//
|
|
27
|
+
// rrweb-player renders at the recording's native resolution. Scale it to the
|
|
28
|
+
// full panel width and anchor it to the top: the browser frame is shown at
|
|
29
|
+
// true proportions (never zoomed or cropped), and any leftover space is a
|
|
30
|
+
// single region below the page — not the symmetric top+bottom letterbox
|
|
31
|
+
// bars a contain-fit leaves. Re-run on every resize.
|
|
30
32
|
function updateScale() {
|
|
31
|
-
if (!nativeWidth || !nativeHeight) return;
|
|
32
|
-
const
|
|
33
|
-
const scale =
|
|
33
|
+
if (!nativeWidth || !nativeHeight || !viewport) return;
|
|
34
|
+
const vp = viewport.getBoundingClientRect();
|
|
35
|
+
const scale = vp.width / nativeWidth || 0;
|
|
36
|
+
stage.style.width = `${vp.width}px`;
|
|
37
|
+
stage.style.height = `${nativeHeight * scale}px`;
|
|
38
|
+
container.style.transformOrigin = 'top left';
|
|
34
39
|
container.style.transform = `scale(${scale})`;
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -38,8 +43,8 @@
|
|
|
38
43
|
// construction) reads events[0].timestamp unconditionally, so the initial
|
|
39
44
|
// batch must be passed in props rather than fed empty and via addEvent.
|
|
40
45
|
function buildPlayer() {
|
|
41
|
-
const rect =
|
|
42
|
-
const meta = events
|
|
46
|
+
const rect = viewport.getBoundingClientRect();
|
|
47
|
+
const meta = events.find((e) => e?.type === META_EVENT_TYPE)?.data ?? null;
|
|
43
48
|
nativeWidth = meta?.width > 0 ? meta.width : rect.width;
|
|
44
49
|
nativeHeight = meta?.height > 0 ? meta.height : rect.height;
|
|
45
50
|
|
|
@@ -68,8 +73,9 @@
|
|
|
68
73
|
|
|
69
74
|
onMount(() => {
|
|
70
75
|
buildPlayer();
|
|
76
|
+
// Observe the viewport, not the stage — the stage's size is what we set.
|
|
71
77
|
resizeObserver = new ResizeObserver(updateScale);
|
|
72
|
-
resizeObserver.observe(
|
|
78
|
+
resizeObserver.observe(viewport);
|
|
73
79
|
});
|
|
74
80
|
onDestroy(() => {
|
|
75
81
|
resizeObserver?.disconnect();
|
|
@@ -81,25 +87,41 @@
|
|
|
81
87
|
});
|
|
82
88
|
</script>
|
|
83
89
|
|
|
84
|
-
<div class="live-
|
|
85
|
-
<div class="live-
|
|
90
|
+
<div class="live-viewport" bind:this={viewport}>
|
|
91
|
+
<div class="live-stage" bind:this={stage}>
|
|
92
|
+
<div class="live-mount" bind:this={container}></div>
|
|
93
|
+
</div>
|
|
86
94
|
</div>
|
|
87
95
|
|
|
88
96
|
<style>
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
/* Fills the panel; the stage is sized in JS to the panel width at the
|
|
98
|
+
recording's true aspect ratio, pinned to the top. */
|
|
99
|
+
.live-viewport {
|
|
91
100
|
flex: 1;
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
92
103
|
min-width: 0;
|
|
93
104
|
min-height: 0;
|
|
94
105
|
display: flex;
|
|
95
|
-
align-items:
|
|
106
|
+
align-items: flex-start;
|
|
96
107
|
justify-content: center;
|
|
97
|
-
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.live-stage {
|
|
112
|
+
position: relative;
|
|
98
113
|
overflow: hidden;
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
.live-mount {
|
|
102
|
-
|
|
117
|
+
position: absolute;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.live-mount :global(.rr-player) {
|
|
123
|
+
border-radius: 0 !important;
|
|
124
|
+
box-shadow: none !important;
|
|
103
125
|
}
|
|
104
126
|
|
|
105
127
|
/* Sandboxed iframe (no allow-scripts/forms/top-navigation) — safe to always
|