@encarnage7/local-meet 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +403 -2
- package/dist/index.cjs +2558 -0
- package/dist/index.d.ts +223 -0
- package/dist/index.mjs +2560 -0
- package/dist/local-meet.min.js +2574 -0
- package/package.json +44 -4
- package/src/crypto.js +92 -0
- package/src/events.js +38 -0
- package/src/index.js +150 -0
- package/src/room.js +2272 -0
- package/src/types.d.ts +223 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Declarations for Local Meet SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type EngineMode = "cf-calls" | "p2p" | "livekit";
|
|
6
|
+
|
|
7
|
+
export type RoomEventType =
|
|
8
|
+
| "participantConnected"
|
|
9
|
+
| "participantDisconnected"
|
|
10
|
+
| "participantMetadataChanged"
|
|
11
|
+
| "participantPermissionsChanged"
|
|
12
|
+
| "dataReceived"
|
|
13
|
+
| "trackSubscribed"
|
|
14
|
+
| "trackUnsubscribed"
|
|
15
|
+
| "trackUnpublished"
|
|
16
|
+
| "localTrackPublished"
|
|
17
|
+
| "localTrackUnpublished"
|
|
18
|
+
| "trackMuted"
|
|
19
|
+
| "trackUnmuted"
|
|
20
|
+
| "activeSpeakersChanged"
|
|
21
|
+
| "disconnected"
|
|
22
|
+
| "error";
|
|
23
|
+
|
|
24
|
+
export const RoomEvents: {
|
|
25
|
+
readonly ParticipantConnected: "participantConnected";
|
|
26
|
+
readonly ParticipantDisconnected: "participantDisconnected";
|
|
27
|
+
readonly ParticipantMetadataChanged: "participantMetadataChanged";
|
|
28
|
+
readonly ParticipantPermissionsChanged: "participantPermissionsChanged";
|
|
29
|
+
readonly DataReceived: "dataReceived";
|
|
30
|
+
readonly TrackSubscribed: "trackSubscribed";
|
|
31
|
+
readonly TrackUnsubscribed: "trackUnsubscribed";
|
|
32
|
+
readonly TrackUnpublished: "trackUnpublished";
|
|
33
|
+
readonly LocalTrackPublished: "localTrackPublished";
|
|
34
|
+
readonly LocalTrackUnpublished: "localTrackUnpublished";
|
|
35
|
+
readonly TrackMuted: "trackMuted";
|
|
36
|
+
readonly TrackUnmuted: "trackUnmuted";
|
|
37
|
+
readonly ActiveSpeakersChanged: "activeSpeakersChanged";
|
|
38
|
+
readonly Disconnected: "disconnected";
|
|
39
|
+
readonly Error: "error";
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TrackSources: {
|
|
43
|
+
readonly Camera: "camera";
|
|
44
|
+
readonly Microphone: "microphone";
|
|
45
|
+
readonly ScreenShare: "screen_share";
|
|
46
|
+
readonly ScreenShareAudio: "screen_share_audio";
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const TrackKinds: {
|
|
50
|
+
readonly Audio: "audio";
|
|
51
|
+
readonly Video: "video";
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const EngineModes: {
|
|
55
|
+
readonly CloudflareCalls: "cf-calls";
|
|
56
|
+
readonly P2PMesh: "p2p";
|
|
57
|
+
readonly LiveKit: "livekit";
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export interface IceServerConfig {
|
|
61
|
+
urls: string | string[];
|
|
62
|
+
username?: string;
|
|
63
|
+
credential?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface LocalMeetRoomOptions {
|
|
67
|
+
serverUrl?: string;
|
|
68
|
+
roomHash: string;
|
|
69
|
+
title?: string;
|
|
70
|
+
identity?: string;
|
|
71
|
+
displayName?: string;
|
|
72
|
+
isHost?: boolean;
|
|
73
|
+
hostSecret?: string;
|
|
74
|
+
engine?: EngineMode;
|
|
75
|
+
cfCallsReady?: boolean;
|
|
76
|
+
startInWaitingRoom?: boolean;
|
|
77
|
+
iceServers?: IceServerConfig[];
|
|
78
|
+
debug?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface CreateRoomOptions {
|
|
82
|
+
serverUrl?: string;
|
|
83
|
+
hostName?: string;
|
|
84
|
+
title?: string;
|
|
85
|
+
engine?: EngineMode;
|
|
86
|
+
accessKey?: string;
|
|
87
|
+
customHash?: string;
|
|
88
|
+
hostSecret?: string;
|
|
89
|
+
debug?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface JoinRoomOptions {
|
|
93
|
+
serverUrl?: string;
|
|
94
|
+
roomHash: string;
|
|
95
|
+
guestName?: string;
|
|
96
|
+
debug?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class HybridTrack {
|
|
100
|
+
mediaStreamTrack: MediaStreamTrack;
|
|
101
|
+
kind: "audio" | "video";
|
|
102
|
+
source: string;
|
|
103
|
+
mediaStream: MediaStream | null;
|
|
104
|
+
primaryElement: HTMLMediaElement | null;
|
|
105
|
+
attachedElements: Set<HTMLMediaElement>;
|
|
106
|
+
|
|
107
|
+
constructor(mediaStreamTrack: MediaStreamTrack, kind: "audio" | "video", source: string);
|
|
108
|
+
attach(existingElement?: HTMLMediaElement | null): HTMLMediaElement;
|
|
109
|
+
detach(): HTMLMediaElement[];
|
|
110
|
+
stop(): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class HybridPublication {
|
|
114
|
+
trackSid: string;
|
|
115
|
+
source: string;
|
|
116
|
+
track: HybridTrack | null;
|
|
117
|
+
isMuted: boolean;
|
|
118
|
+
|
|
119
|
+
constructor(params: {
|
|
120
|
+
trackSid: string;
|
|
121
|
+
source: string;
|
|
122
|
+
track?: HybridTrack | null;
|
|
123
|
+
isMuted?: boolean;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export class HybridParticipant {
|
|
128
|
+
identity: string;
|
|
129
|
+
name: string;
|
|
130
|
+
metadata: string;
|
|
131
|
+
permissions: {
|
|
132
|
+
canPublish: boolean;
|
|
133
|
+
canSubscribe: boolean;
|
|
134
|
+
canPublishData: boolean;
|
|
135
|
+
};
|
|
136
|
+
isLocal: boolean;
|
|
137
|
+
trackPublications: Map<string, HybridPublication>;
|
|
138
|
+
videoTrackPublications: Map<string, HybridPublication>;
|
|
139
|
+
peerId: string;
|
|
140
|
+
cfSessionId: string;
|
|
141
|
+
cfPublishedTracks: string[];
|
|
142
|
+
|
|
143
|
+
constructor(params: {
|
|
144
|
+
identity: string;
|
|
145
|
+
name: string;
|
|
146
|
+
metadata?: string;
|
|
147
|
+
permissions?: Partial<HybridParticipant["permissions"]>;
|
|
148
|
+
isLocal?: boolean;
|
|
149
|
+
room?: any;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
getTrackPublication(source: string): HybridPublication | null;
|
|
153
|
+
setPublication(source: string, publication: HybridPublication | null): void;
|
|
154
|
+
enableCameraAndMicrophone(): Promise<void>;
|
|
155
|
+
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
156
|
+
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
157
|
+
setScreenShareEnabled(enabled: boolean): Promise<HybridPublication | null>;
|
|
158
|
+
publishData(payload: Uint8Array | string | object, options?: { reliable?: boolean }): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class LocalMeetRoom {
|
|
162
|
+
serverUrl: string;
|
|
163
|
+
roomHash: string;
|
|
164
|
+
roomTitle: string;
|
|
165
|
+
isHost: boolean;
|
|
166
|
+
hostSecret: string;
|
|
167
|
+
engine: EngineMode;
|
|
168
|
+
cfCallsReady: boolean;
|
|
169
|
+
debug: boolean;
|
|
170
|
+
localParticipant: HybridParticipant;
|
|
171
|
+
remoteParticipants: Map<string, HybridParticipant>;
|
|
172
|
+
iceServers: IceServerConfig[];
|
|
173
|
+
|
|
174
|
+
constructor(options: LocalMeetRoomOptions);
|
|
175
|
+
|
|
176
|
+
on(event: RoomEventType | string, callback: (...args: any[]) => void): this;
|
|
177
|
+
off(event: RoomEventType | string, callback: (...args: any[]) => void): this;
|
|
178
|
+
emit(event: RoomEventType | string, ...args: any[]): void;
|
|
179
|
+
|
|
180
|
+
connect(): Promise<this>;
|
|
181
|
+
enableCameraAndMicrophone(): Promise<void>;
|
|
182
|
+
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
183
|
+
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
184
|
+
setScreenShareEnabled(enabled: boolean, stopTracks?: boolean): Promise<HybridPublication | null>;
|
|
185
|
+
startScreenShare(): Promise<HybridPublication | null>;
|
|
186
|
+
stopScreenShare(): Promise<HybridPublication | null>;
|
|
187
|
+
sendData(payload: Uint8Array | string | object, options?: { reliable?: boolean }): Promise<void>;
|
|
188
|
+
|
|
189
|
+
admitGuest(identity: string): Promise<void>;
|
|
190
|
+
rejectGuest(identity: string): Promise<void>;
|
|
191
|
+
muteParticipant(identity: string, trackSid?: string): Promise<void>;
|
|
192
|
+
kickParticipant(identity: string): Promise<void>;
|
|
193
|
+
endRoom(): Promise<void>;
|
|
194
|
+
disconnect(): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const LocalMeet: {
|
|
198
|
+
RoomEvents: typeof RoomEvents;
|
|
199
|
+
TrackSources: typeof TrackSources;
|
|
200
|
+
TrackKinds: typeof TrackKinds;
|
|
201
|
+
EngineModes: typeof EngineModes;
|
|
202
|
+
LocalMeetRoom: typeof LocalMeetRoom;
|
|
203
|
+
HybridTrack: typeof HybridTrack;
|
|
204
|
+
HybridPublication: typeof HybridPublication;
|
|
205
|
+
HybridParticipant: typeof HybridParticipant;
|
|
206
|
+
|
|
207
|
+
createRoom(options?: CreateRoomOptions): Promise<LocalMeetRoom>;
|
|
208
|
+
join(options?: JoinRoomOptions): Promise<LocalMeetRoom>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export function encryptDataPacket(
|
|
212
|
+
roomHash: string,
|
|
213
|
+
plaintext: string,
|
|
214
|
+
extraSecret?: string
|
|
215
|
+
): Promise<{ e2ee: string; iv: string; ct: string }>;
|
|
216
|
+
|
|
217
|
+
export function decryptDataPacket(
|
|
218
|
+
roomHash: string,
|
|
219
|
+
packet: { e2ee: string; iv: string; ct: string },
|
|
220
|
+
extraSecret?: string
|
|
221
|
+
): Promise<string | null>;
|
|
222
|
+
|
|
223
|
+
export default LocalMeet;
|