@appsurify-testmap/rrweb-plugin-canvas-webrtc-record 2.1.0-alpha.1

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/Readme.md ADDED
@@ -0,0 +1,74 @@
1
+ # rrweb canvas webrtc plugin
2
+
3
+ Plugin that live streams contents of canvas elements via webrtc
4
+
5
+ ## Example of live streaming via `yarn live-stream`
6
+
7
+ https://user-images.githubusercontent.com/4106/186701616-fd71a107-5d53-423c-ba09-0395a3a0252f.mov
8
+
9
+ ## Instructions
10
+
11
+ ### Record side
12
+
13
+ ```js
14
+ // Record side
15
+
16
+ import rrweb from 'rrweb';
17
+ import { RRWebPluginCanvasWebRTCRecord } from 'rrweb-plugin-canvas-webrtc-record';
18
+
19
+ const webRTCRecordPlugin = new RRWebPluginCanvasWebRTCRecord({
20
+ signalSendCallback: (msg) => {
21
+ // provides webrtc sdp offer signal & connect message
22
+ // make sure you send this to the replayer's `webRTCReplayPlugin.signalReceive(signal)`
23
+ sendSignalToReplayer(msg); // example of function that sends the signal to the replayer
24
+ },
25
+ });
26
+
27
+ rrweb.record({
28
+ emit: (event) => {
29
+ // send these events to the `replayer.addEvent(event)`, how you do that is up to you
30
+ // you can send them to a server for example which can then send them to the replayer
31
+ sendEventToReplayer(event); // example of function that sends the event to the replayer
32
+ },
33
+ plugins: [
34
+ // add the plugin to the list of plugins, and initialize it via `.initPlugin()`
35
+ webRTCRecordPlugin.initPlugin(),
36
+ ],
37
+ recordCanvas: false, // we don't want canvas recording turned on, we're going to do that via the plugin
38
+ });
39
+ ```
40
+
41
+ ### Replay Side
42
+
43
+ ```js
44
+ // Replay side
45
+ import rrweb from 'rrweb';
46
+ import { RRWebPluginCanvasWebRTCReplay } from 'rrweb-plugin-canvas-webrtc-replay';
47
+
48
+ const webRTCReplayPlugin = new RRWebPluginCanvasWebRTCReplay({
49
+ canvasFoundCallback(canvas, context) {
50
+ console.log('canvas', canvas);
51
+ // send the canvas id to `webRTCRecordPlugin.setupStream(id)`, how you do that is up to you
52
+ // you can send them to a server for example which can then send them to the replayer
53
+ sendCanvasIdToRecordScript(context.id); // example of function that sends the id to the record script
54
+ },
55
+ signalSendCallback(signal) {
56
+ // provides webrtc sdp offer signal & connect message
57
+ // make sure you send this to the record script's `webRTCRecordPlugin.signalReceive(signal)`
58
+ sendSignalToRecordScript(signal); // example of function that sends the signal to the record script
59
+ },
60
+ });
61
+
62
+ const replayer = new rrweb.Replayer([], {
63
+ UNSAFE_replayCanvas: true, // turn canvas replay on!
64
+ liveMode: true, // live mode is needed to stream events to the replayer
65
+ plugins: [webRTCReplayPlugin.initPlugin()],
66
+ });
67
+ replayer.startLive(); // start the replayer in live mode
68
+
69
+ replayer.addEvent(event); // call this whenever an event is received from the record script
70
+ ```
71
+
72
+ ## More info
73
+
74
+ https://github.com/rrweb-io/rrweb/pull/976
@@ -0,0 +1,50 @@
1
+ import { default as default_2 } from 'simple-peer-light';
2
+ import { RecordPlugin } from '@appsurify-testmap/rrweb-types';
3
+
4
+ export declare type CrossOriginIframeMessageEventContent = {
5
+ type: 'rrweb-canvas-webrtc';
6
+ data: {
7
+ type: 'signal';
8
+ signal: RTCSessionDescriptionInit;
9
+ } | {
10
+ type: 'who-has-canvas';
11
+ rootId: number;
12
+ id: number;
13
+ } | {
14
+ type: 'i-have-canvas';
15
+ rootId: number;
16
+ };
17
+ };
18
+
19
+ export declare const PLUGIN_NAME = "rrweb/canvas-webrtc@1";
20
+
21
+ export declare class RRWebPluginCanvasWebRTCRecord {
22
+ private peer;
23
+ private mirror;
24
+ private crossOriginIframeMirror;
25
+ private streamMap;
26
+ private incomingStreams;
27
+ private outgoingStreams;
28
+ private streamNodeMap;
29
+ private canvasWindowMap;
30
+ private windowPeerMap;
31
+ private peerWindowMap;
32
+ private signalSendCallback;
33
+ constructor({ signalSendCallback, peer, }: {
34
+ signalSendCallback: RRWebPluginCanvasWebRTCRecord['signalSendCallback'];
35
+ peer?: default_2.Instance;
36
+ });
37
+ initPlugin(): RecordPlugin;
38
+ signalReceive(signal: RTCSessionDescriptionInit): void;
39
+ signalReceiveFromCrossOriginIframe(signal: RTCSessionDescriptionInit, source: WindowProxy): void;
40
+ private startStream;
41
+ setupPeer(source?: WindowProxy): default_2.Instance;
42
+ setupStream(id: number, rootId?: number): boolean | MediaStream;
43
+ private flushStreams;
44
+ private inRootFrame;
45
+ setupStreamInCrossOriginIframe(id: number, rootId: number): boolean;
46
+ private isCrossOriginIframeMessageEventContent;
47
+ private windowPostMessageHandler;
48
+ }
49
+
50
+ export { }
@@ -0,0 +1,50 @@
1
+ import { default as default_2 } from 'simple-peer-light';
2
+ import { RecordPlugin } from '@appsurify-testmap/rrweb-types';
3
+
4
+ export declare type CrossOriginIframeMessageEventContent = {
5
+ type: 'rrweb-canvas-webrtc';
6
+ data: {
7
+ type: 'signal';
8
+ signal: RTCSessionDescriptionInit;
9
+ } | {
10
+ type: 'who-has-canvas';
11
+ rootId: number;
12
+ id: number;
13
+ } | {
14
+ type: 'i-have-canvas';
15
+ rootId: number;
16
+ };
17
+ };
18
+
19
+ export declare const PLUGIN_NAME = "rrweb/canvas-webrtc@1";
20
+
21
+ export declare class RRWebPluginCanvasWebRTCRecord {
22
+ private peer;
23
+ private mirror;
24
+ private crossOriginIframeMirror;
25
+ private streamMap;
26
+ private incomingStreams;
27
+ private outgoingStreams;
28
+ private streamNodeMap;
29
+ private canvasWindowMap;
30
+ private windowPeerMap;
31
+ private peerWindowMap;
32
+ private signalSendCallback;
33
+ constructor({ signalSendCallback, peer, }: {
34
+ signalSendCallback: RRWebPluginCanvasWebRTCRecord['signalSendCallback'];
35
+ peer?: default_2.Instance;
36
+ });
37
+ initPlugin(): RecordPlugin;
38
+ signalReceive(signal: RTCSessionDescriptionInit): void;
39
+ signalReceiveFromCrossOriginIframe(signal: RTCSessionDescriptionInit, source: WindowProxy): void;
40
+ private startStream;
41
+ setupPeer(source?: WindowProxy): default_2.Instance;
42
+ setupStream(id: number, rootId?: number): boolean | MediaStream;
43
+ private flushStreams;
44
+ private inRootFrame;
45
+ setupStreamInCrossOriginIframe(id: number, rootId: number): boolean;
46
+ private isCrossOriginIframeMessageEventContent;
47
+ private windowPostMessageHandler;
48
+ }
49
+
50
+ export { }