@xtr-dev/rondevu-client 0.3.4 → 0.4.0
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 +401 -60
- package/dist/auth.d.ts +18 -0
- package/dist/auth.js +39 -0
- package/dist/bloom.d.ts +30 -0
- package/dist/bloom.js +73 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.js +18 -0
- package/dist/connection.d.ts +96 -45
- package/dist/connection.js +217 -196
- package/dist/index.d.ts +8 -3
- package/dist/index.js +9 -5
- package/dist/offers.d.ts +108 -0
- package/dist/offers.js +214 -0
- package/dist/rondevu.d.ts +39 -42
- package/dist/rondevu.js +33 -175
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -150,4 +150,22 @@ export class RondevuAPI {
|
|
|
150
150
|
method: 'GET',
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Ends a session by deleting the offer from the server
|
|
155
|
+
*
|
|
156
|
+
* @param code - The offer code
|
|
157
|
+
* @returns Success confirmation
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
|
162
|
+
* await api.leave('my-offer-code');
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
async leave(code) {
|
|
166
|
+
return this.request('/leave', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
body: JSON.stringify({ code }),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
153
171
|
}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,76 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RondevuAPI } from './client.js';
|
|
3
|
-
import { RondevuConnectionParams } from './types.js';
|
|
1
|
+
import { RondevuOffers } from './offers.js';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
3
|
+
* Events emitted by RondevuConnection
|
|
6
4
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export interface RondevuConnectionEvents {
|
|
6
|
+
'connecting': () => void;
|
|
7
|
+
'connected': () => void;
|
|
8
|
+
'disconnected': () => void;
|
|
9
|
+
'error': (error: Error) => void;
|
|
10
|
+
'datachannel': (channel: RTCDataChannel) => void;
|
|
11
|
+
'track': (event: RTCTrackEvent) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for creating a WebRTC connection
|
|
15
|
+
*/
|
|
16
|
+
export interface ConnectionOptions {
|
|
17
|
+
/**
|
|
18
|
+
* RTCConfiguration for the peer connection
|
|
19
|
+
* @default { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] }
|
|
20
|
+
*/
|
|
21
|
+
rtcConfig?: RTCConfiguration;
|
|
22
|
+
/**
|
|
23
|
+
* Topics to advertise this connection under
|
|
24
|
+
*/
|
|
25
|
+
topics: string[];
|
|
26
|
+
/**
|
|
27
|
+
* How long the offer should live (milliseconds)
|
|
28
|
+
* @default 300000 (5 minutes)
|
|
29
|
+
*/
|
|
30
|
+
ttl?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to create a data channel automatically (for offerer)
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
createDataChannel?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Label for the automatically created data channel
|
|
38
|
+
* @default 'data'
|
|
39
|
+
*/
|
|
40
|
+
dataChannelLabel?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* High-level WebRTC connection manager for Rondevu
|
|
44
|
+
* Handles offer/answer exchange, ICE candidates, and connection lifecycle
|
|
45
|
+
*/
|
|
46
|
+
export declare class RondevuConnection {
|
|
47
|
+
private rtcConfig;
|
|
11
48
|
private pc;
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private wrtc?;
|
|
22
|
-
private RTCIceCandidate;
|
|
23
|
-
constructor(params: RondevuConnectionParams, client: RondevuAPI);
|
|
49
|
+
private offersApi;
|
|
50
|
+
private offerId?;
|
|
51
|
+
private role?;
|
|
52
|
+
private icePollingInterval?;
|
|
53
|
+
private answerPollingInterval?;
|
|
54
|
+
private lastIceTimestamp;
|
|
55
|
+
private eventListeners;
|
|
56
|
+
private dataChannel?;
|
|
57
|
+
private pendingIceCandidates;
|
|
24
58
|
/**
|
|
25
|
-
*
|
|
59
|
+
* Current connection state
|
|
26
60
|
*/
|
|
27
|
-
|
|
61
|
+
get connectionState(): RTCPeerConnectionState;
|
|
28
62
|
/**
|
|
29
|
-
*
|
|
63
|
+
* The offer ID for this connection
|
|
30
64
|
*/
|
|
31
|
-
|
|
65
|
+
get id(): string | undefined;
|
|
32
66
|
/**
|
|
33
|
-
*
|
|
67
|
+
* Get the primary data channel (if created)
|
|
34
68
|
*/
|
|
35
|
-
|
|
69
|
+
get channel(): RTCDataChannel | undefined;
|
|
70
|
+
constructor(offersApi: RondevuOffers, rtcConfig?: RTCConfiguration);
|
|
36
71
|
/**
|
|
37
|
-
*
|
|
72
|
+
* Set up peer connection event handlers
|
|
38
73
|
*/
|
|
39
|
-
|
|
74
|
+
private setupPeerConnection;
|
|
40
75
|
/**
|
|
41
|
-
*
|
|
76
|
+
* Flush buffered ICE candidates (trickle ICE support)
|
|
42
77
|
*/
|
|
43
|
-
private
|
|
78
|
+
private flushPendingIceCandidates;
|
|
44
79
|
/**
|
|
45
|
-
*
|
|
80
|
+
* Create an offer and advertise on topics
|
|
46
81
|
*/
|
|
47
|
-
|
|
82
|
+
createOffer(options: ConnectionOptions): Promise<string>;
|
|
48
83
|
/**
|
|
49
|
-
*
|
|
84
|
+
* Answer an existing offer
|
|
50
85
|
*/
|
|
51
|
-
|
|
86
|
+
answer(offerId: string, offerSdp: string): Promise<void>;
|
|
52
87
|
/**
|
|
53
|
-
*
|
|
88
|
+
* Start polling for answers (offerer only)
|
|
54
89
|
*/
|
|
55
|
-
|
|
90
|
+
private startAnswerPolling;
|
|
91
|
+
/**
|
|
92
|
+
* Start polling for ICE candidates
|
|
93
|
+
*/
|
|
94
|
+
private startIcePolling;
|
|
95
|
+
/**
|
|
96
|
+
* Stop answer polling
|
|
97
|
+
*/
|
|
98
|
+
private stopAnswerPolling;
|
|
99
|
+
/**
|
|
100
|
+
* Stop ICE polling
|
|
101
|
+
*/
|
|
102
|
+
private stopIcePolling;
|
|
103
|
+
/**
|
|
104
|
+
* Stop all polling
|
|
105
|
+
*/
|
|
106
|
+
private stopPolling;
|
|
56
107
|
/**
|
|
57
|
-
* Add
|
|
108
|
+
* Add event listener
|
|
58
109
|
*/
|
|
59
|
-
|
|
110
|
+
on<K extends keyof RondevuConnectionEvents>(event: K, listener: RondevuConnectionEvents[K]): void;
|
|
60
111
|
/**
|
|
61
|
-
*
|
|
112
|
+
* Remove event listener
|
|
62
113
|
*/
|
|
63
|
-
|
|
114
|
+
off<K extends keyof RondevuConnectionEvents>(event: K, listener: RondevuConnectionEvents[K]): void;
|
|
64
115
|
/**
|
|
65
|
-
*
|
|
116
|
+
* Emit event
|
|
66
117
|
*/
|
|
67
|
-
private
|
|
118
|
+
private emit;
|
|
68
119
|
/**
|
|
69
|
-
*
|
|
120
|
+
* Add a media track to the connection
|
|
70
121
|
*/
|
|
71
|
-
|
|
122
|
+
addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
|
|
72
123
|
/**
|
|
73
|
-
* Close the connection and
|
|
124
|
+
* Close the connection and clean up
|
|
74
125
|
*/
|
|
75
126
|
close(): void;
|
|
76
127
|
}
|