Skip to content

Commit ea78eb7

Browse files
committed
use patch-package to add stopLive to rrweb
1 parent 03f8b17 commit ea78eb7

File tree

4 files changed

+221
-6
lines changed

4 files changed

+221
-6
lines changed

package-lock.json

Lines changed: 147 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"scripts": {
1212
"preinstall": "node install-k6.js",
13+
"postinstall": "patch-package",
1314
"start": "electron-forge start",
1415
"start:extension": "STANDALONE_EXTENSION=true vite --config vite.extension.config.mts",
1516
"watch:extension": "vite --config vite.extension.config.mts",
@@ -68,6 +69,7 @@
6869
"husky": "^9.0.11",
6970
"jsdom": "^25.0.0",
7071
"lint-staged": "^15.2.5",
72+
"patch-package": "^8.0.1",
7173
"ts-node": "^10.9.2",
7274
"tsconfig-paths": "^4.2.0",
7375
"vite": "^5.4.21",

patches/rrweb+2.0.0-alpha.18.patch

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
diff --git a/node_modules/rrweb/dist/rrweb.cjs b/node_modules/rrweb/dist/rrweb.cjs
2+
index d455aa0..86e7de1 100644
3+
--- a/node_modules/rrweb/dist/rrweb.cjs
4+
+++ b/node_modules/rrweb/dist/rrweb.cjs
5+
@@ -14576,6 +14576,10 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
6+
},
7+
live: {
8+
on: {
9+
+ STOP_LIVE: {
10+
+ target: "paused",
11+
+ actions: ["pause"]
12+
+ },
13+
ADD_EVENT: {
14+
target: "live",
15+
actions: ["addEvent"]
16+
@@ -15702,6 +15706,9 @@ class Replayer {
17+
startLive(baselineTime) {
18+
this.service.send({ type: "TO_LIVE", payload: { baselineTime } });
19+
}
20+
+ stopLive() {
21+
+ this.service.send({ type: "STOP_LIVE" });
22+
+ }
23+
addEvent(rawEvent) {
24+
const event = this.config.unpackFn ? this.config.unpackFn(rawEvent) : rawEvent;
25+
if (indicatesTouchDevice(event)) {
26+
diff --git a/node_modules/rrweb/dist/rrweb.d.ts b/node_modules/rrweb/dist/rrweb.d.ts
27+
index 95305d6..66540cb 100644
28+
--- a/node_modules/rrweb/dist/rrweb.d.ts
29+
+++ b/node_modules/rrweb/dist/rrweb.d.ts
30+
@@ -182,6 +182,8 @@ declare type PlayerEvent = {
31+
};
32+
} | {
33+
type: 'PAUSE';
34+
+} | {
35+
+ type: 'STOP_LIVE';
36+
} | {
37+
type: 'TO_LIVE';
38+
payload: {
39+
@@ -299,6 +301,7 @@ export declare class Replayer {
40+
resume(timeOffset?: number): void;
41+
destroy(): void;
42+
startLive(baselineTime?: number): void;
43+
+ stopLive(): void;
44+
addEvent(rawEvent: eventWithTime | string): void;
45+
enableInteract(): void;
46+
disableInteract(): void;
47+
diff --git a/node_modules/rrweb/dist/rrweb.js b/node_modules/rrweb/dist/rrweb.js
48+
index 5d38597..13a9d10 100644
49+
--- a/node_modules/rrweb/dist/rrweb.js
50+
+++ b/node_modules/rrweb/dist/rrweb.js
51+
@@ -14574,6 +14574,10 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
52+
},
53+
live: {
54+
on: {
55+
+ STOP_LIVE: {
56+
+ target: 'paused',
57+
+ actions: ["pause"]
58+
+ },
59+
ADD_EVENT: {
60+
target: "live",
61+
actions: ["addEvent"]
62+
@@ -15700,6 +15704,9 @@ class Replayer {
63+
startLive(baselineTime) {
64+
this.service.send({ type: "TO_LIVE", payload: { baselineTime } });
65+
}
66+
+ stopLive() {
67+
+ this.service.send({ type: "STOP_LIVE" });
68+
+ }
69+
addEvent(rawEvent) {
70+
const event = this.config.unpackFn ? this.config.unpackFn(rawEvent) : rawEvent;
71+
if (indicatesTouchDevice(event)) {

src/views/Validator/Browser/SessionPlayer/SessionPlayer.hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function usePlayer({ streaming, mount, events }: UsePlayerOptions) {
107107
switch (parsedEvent.data.tag) {
108108
case 'recording-end':
109109
newPlayer.setConfig({ liveMode: false })
110+
newPlayer.stopLive()
110111

111112
setState('ended')
112113

0 commit comments

Comments
 (0)