@livo-tv/sdk 1.0.0 → 1.1.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.
@@ -0,0 +1,496 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ export { a as applyEmbedTheme, d as decodeEmbedTheme } from '../theme-CjyIlZUs.js';
4
+
5
+ type StudioRole = "moderator" | "guest";
6
+ type StudioStageStatus = "OFF_STAGE" | "REQUESTED_TO_JOIN_STAGE" | "ACCEPTED_TO_JOIN_STAGE" | "ON_STAGE";
7
+ type StudioStreamSummary = {
8
+ id: string;
9
+ title: string;
10
+ status: string;
11
+ encoderLostAt?: number | null;
12
+ };
13
+ type StudioSession = {
14
+ authToken: string;
15
+ meetingId: string;
16
+ role: StudioRole;
17
+ guestUrl: string | null;
18
+ studioControlToken?: string | null;
19
+ expiresAt?: number | null;
20
+ stream: StudioStreamSummary;
21
+ };
22
+ type StudioWaitlistedGuest = {
23
+ id: string;
24
+ name: string;
25
+ userId?: string;
26
+ picture?: string | null;
27
+ };
28
+ type StudioStageRequest = {
29
+ userId: string;
30
+ peerId: string;
31
+ name: string;
32
+ };
33
+ type StudioParticipantTile = {
34
+ id: string;
35
+ name: string;
36
+ isSelf: boolean;
37
+ audioEnabled: boolean;
38
+ videoEnabled: boolean;
39
+ screenShareEnabled: boolean;
40
+ picture: string | null;
41
+ userId?: string;
42
+ stageStatus?: StudioStageStatus;
43
+ pinned?: boolean;
44
+ chatCanSend?: boolean;
45
+ };
46
+ type StudioChatMessage = {
47
+ id: string;
48
+ userId: string;
49
+ name: string;
50
+ text: string;
51
+ time: number;
52
+ targetUserIds?: string[];
53
+ pinned?: boolean;
54
+ isEdited?: boolean;
55
+ };
56
+
57
+ type StudioLivestreamEgress = "live" | "starting";
58
+ declare function studioErrorCode(error: unknown): string | null;
59
+
60
+ /** Injected by the host app. JWT mint stays outside the SDK. */
61
+ type StudioControlActions = {
62
+ livestream: () => Promise<StudioLivestreamEgress>;
63
+ publish: () => Promise<void>;
64
+ stop: () => Promise<void>;
65
+ };
66
+
67
+ type StudioControlClientOptions = {
68
+ apiUrl?: string;
69
+ token: string;
70
+ fetchFn?: typeof fetch;
71
+ };
72
+ declare class StudioControlError extends Error {
73
+ readonly status: number;
74
+ readonly body: unknown;
75
+ constructor(status: number, message: string, body: unknown);
76
+ }
77
+ declare class StudioControlClient {
78
+ private token;
79
+ private readonly apiUrl;
80
+ private readonly fetchFn;
81
+ constructor(options: StudioControlClientOptions);
82
+ get currentToken(): string;
83
+ private url;
84
+ private request;
85
+ livestream(): Promise<{
86
+ ok: true;
87
+ egress: "live" | "starting";
88
+ }>;
89
+ publish(): Promise<{
90
+ stream: {
91
+ id: string;
92
+ status: string;
93
+ };
94
+ }>;
95
+ stop(): Promise<{
96
+ stream: {
97
+ id: string;
98
+ status: string;
99
+ };
100
+ }>;
101
+ state(): Promise<{
102
+ stream: {
103
+ id: string;
104
+ title: string;
105
+ status: string;
106
+ };
107
+ }>;
108
+ refresh(): Promise<{
109
+ studioControlToken: string;
110
+ expiresAt: number;
111
+ }>;
112
+ }
113
+ declare function createStudioControlClient(options: StudioControlClientOptions): StudioControlClient;
114
+ declare function controlActionsFromClient(client: StudioControlClient): StudioControlActions;
115
+
116
+ type StudioDeviceKind = "audio" | "video" | "speaker";
117
+ type StudioDeviceOption = {
118
+ deviceId: string;
119
+ label: string;
120
+ };
121
+ type StudioDevices = {
122
+ audio: StudioDeviceOption[];
123
+ video: StudioDeviceOption[];
124
+ speaker: StudioDeviceOption[];
125
+ };
126
+ type StudioVideoKind = "camera" | "screen";
127
+ type StudioHostMediaKind = "audio" | "video" | "screen";
128
+ type StudioScreenSharePermission = "ALLOWED" | "NOT_ALLOWED" | "CAN_REQUEST";
129
+ type StudioBroadcast = {
130
+ type: "host-media";
131
+ kind: StudioHostMediaKind;
132
+ } | {
133
+ type: "share-request";
134
+ participantId: string;
135
+ name: string;
136
+ } | {
137
+ type: "share-response";
138
+ participantId: string;
139
+ granted: boolean;
140
+ } | {
141
+ type: "display-name";
142
+ participantId: string;
143
+ name: string;
144
+ };
145
+ type StudioBroadcastTarget = {
146
+ participantIds: string[];
147
+ } | {
148
+ presetNames: string[];
149
+ };
150
+ type StudioMeetingHandle = {
151
+ join: () => Promise<void>;
152
+ leave: () => Promise<void>;
153
+ setAudioEnabled: (enabled: boolean) => Promise<void>;
154
+ setVideoEnabled: (enabled: boolean) => Promise<void>;
155
+ setScreenShareEnabled: (enabled: boolean) => Promise<void>;
156
+ admit: (participantId: string) => Promise<void>;
157
+ deny: (participantId: string) => Promise<void>;
158
+ kick: (participantId: string) => Promise<void>;
159
+ disableParticipantMedia: (participantId: string, kind: StudioHostMediaKind) => Promise<void>;
160
+ sendBroadcast: (message: StudioBroadcast, target?: StudioBroadcastTarget) => Promise<void>;
161
+ subscribeBroadcast: (cb: (message: StudioBroadcast) => void) => () => void;
162
+ admitAs: (participantId: string, as: "panelist" | "audience") => Promise<void>;
163
+ admitAll: (as: "panelist" | "audience") => Promise<void>;
164
+ setStageAccess: (userId: string, on: boolean) => Promise<void>;
165
+ denyStageAccess: (userId: string) => Promise<void>;
166
+ requestStageAccess: () => Promise<void>;
167
+ leaveStage: () => Promise<void>;
168
+ stageStatus: () => StudioStageStatus;
169
+ stageRequests: () => StudioStageRequest[];
170
+ subscribeStage: (cb: () => void) => () => void;
171
+ canManageStage: () => boolean;
172
+ stageEnabled: () => boolean;
173
+ ensureStageJoined: () => Promise<void>;
174
+ setParticipantPinned: (participantId: string, pinned: boolean) => Promise<void>;
175
+ pinnedIds: () => string[];
176
+ subscribePinned: (cb: () => void) => () => void;
177
+ setParticipantChat: (participantId: string, enabled: boolean) => Promise<void>;
178
+ sendChatMessage: (text: string, participantIds?: string[]) => Promise<void>;
179
+ editChatMessage: (id: string, text: string) => Promise<void>;
180
+ deleteChatMessage: (id: string) => Promise<void>;
181
+ pinChatMessage: (id: string, pinned: boolean) => Promise<void>;
182
+ fetchChatHistory: (opts?: {
183
+ timestamp?: number;
184
+ userId?: string;
185
+ }) => Promise<StudioChatMessage[]>;
186
+ pinnedChatMessages: () => StudioChatMessage[];
187
+ chatMaxTextLimit: () => number;
188
+ subscribeParticipants: (cb: () => void) => () => void;
189
+ participants: () => StudioParticipantTile[];
190
+ waitlisted: () => StudioWaitlistedGuest[];
191
+ inWaitingRoom: () => boolean;
192
+ moderatorIds: () => string[];
193
+ localAudioTrack: () => MediaStreamTrack | null;
194
+ localVideoTrack: () => MediaStreamTrack | null;
195
+ participantVideoTrack: (participantId: string) => MediaStreamTrack | null;
196
+ participantScreenTrack: (participantId: string) => MediaStreamTrack | null;
197
+ activeSpeakerId: () => string | null;
198
+ subscribeActiveSpeaker: (cb: () => void) => () => void;
199
+ screenSharePermission: () => StudioScreenSharePermission;
200
+ subscribePermissions: (cb: () => void) => () => void;
201
+ attachVideo: (participantId: string, el: HTMLVideoElement | null, kind?: StudioVideoKind) => void;
202
+ attachAudio: (participantId: string, el: HTMLAudioElement | null) => void;
203
+ subscribeMedia: (cb: () => void) => () => void;
204
+ subscribeRoomLeft: (cb: (state: string) => void) => () => void;
205
+ chatMessages: () => StudioChatMessage[];
206
+ subscribeChat: (cb: () => void) => () => void;
207
+ listDevices: () => Promise<StudioDevices>;
208
+ setDevice: (kind: StudioDeviceKind, deviceId: string) => Promise<void>;
209
+ setDisplayName: (name: string) => Promise<void>;
210
+ livestreamState: () => string | null;
211
+ roomState: () => string | null;
212
+ startLivestream: () => Promise<void>;
213
+ };
214
+
215
+ type StudioRoomLabels = ReturnType<typeof studioRoomLabels>;
216
+ declare function studioRoomLabels(t: (key: string, values?: Record<string, string>) => string): {
217
+ live: string;
218
+ preview: string;
219
+ waiting: string;
220
+ waitingHost: string;
221
+ admit: string;
222
+ deny: string;
223
+ denied: string;
224
+ denyError: string;
225
+ rejectedTitle: string;
226
+ rejectedDescription: string;
227
+ rejectedAction: string;
228
+ kick: string;
229
+ camera: string;
230
+ screen: string;
231
+ mute: string;
232
+ unmute: string;
233
+ copyLink: string;
234
+ shareLink: string;
235
+ shareGuestText: string;
236
+ shareFailed: string;
237
+ copied: string;
238
+ publish: string;
239
+ publishTitle: string;
240
+ publishDescription: string;
241
+ publishConfirm: string;
242
+ publishPending: string;
243
+ stop: string;
244
+ stopTitle: string;
245
+ stopDescription: string;
246
+ stopConfirm: string;
247
+ fullscreen: string;
248
+ publishError: string;
249
+ stopError: string;
250
+ published: string;
251
+ stopped: string;
252
+ cameraDevice: string;
253
+ micDevice: string;
254
+ speakerDevice: string;
255
+ preflightCamera: string;
256
+ preflightMic: string;
257
+ knock: string;
258
+ egressLost: string;
259
+ livestreamStarting: string;
260
+ livestreamSending: string;
261
+ livestreamInitializing: string;
262
+ livestreamRetry: string;
263
+ livestreamError: string;
264
+ screenBusy: string;
265
+ endedTitle: string;
266
+ endedDescription: string;
267
+ endedAction: string;
268
+ rejoin: string;
269
+ duplicateTitle: string;
270
+ duplicateDescription: string;
271
+ duplicateDescriptionNoTakeover: string;
272
+ duplicateAction: string;
273
+ duplicateTakenOver: string;
274
+ joinBusy: string;
275
+ cameraError: string;
276
+ screenError: string;
277
+ leave: string;
278
+ leaveTitle: string;
279
+ leaveDescription: string;
280
+ leaveConfirm: string;
281
+ chat: string;
282
+ chatSend: string;
283
+ chatPlaceholder: string;
284
+ chatError: string;
285
+ settings: string;
286
+ settingsTitle: string;
287
+ settingsDescription: string;
288
+ guestName: string;
289
+ displayNameSave: string;
290
+ displayNameSaved: string;
291
+ displayNameError: string;
292
+ testSpeaker: string;
293
+ testSpeakerError: string;
294
+ cameraOff: string;
295
+ micLevel: string;
296
+ share: string;
297
+ shareCopied: string;
298
+ stopCamera: string;
299
+ stopScreen: string;
300
+ hostMutedYou: string;
301
+ hostStoppedYourCamera: string;
302
+ hostStoppedYourScreen: string;
303
+ hostMediaError: string;
304
+ tileMenu: string;
305
+ openPip: string;
306
+ closePip: string;
307
+ backToStudio: string;
308
+ pipTitle: string;
309
+ pipError: string;
310
+ screenUnsupportedDevice: string;
311
+ screenNotAllowed: string;
312
+ askToShare: string;
313
+ shareRequested: string;
314
+ cancelShareRequest: string;
315
+ shareRequestSent: string;
316
+ shareRequestFrom: string;
317
+ approve: string;
318
+ shareApproved: string;
319
+ shareDenied: string;
320
+ shareRequestError: string;
321
+ shareRequestTimeout: string;
322
+ shareRespondError: string;
323
+ goOffAir: string;
324
+ goOnAir: string;
325
+ takeOffAir: string;
326
+ bringOnAir: string;
327
+ offAir: string;
328
+ offAirCount: string;
329
+ offAirBanner: string;
330
+ offAirLastVisible: string;
331
+ offAirHidden: string;
332
+ offAirShown: string;
333
+ offAirError: string;
334
+ takeOffAirTitle: string;
335
+ takeOffAirDescription: string;
336
+ takeOffAirConfirm: string;
337
+ admitAsPanelist: string;
338
+ admitAsAudience: string;
339
+ admitAllPanelists: string;
340
+ admitAllAudience: string;
341
+ askToGoOnAir: string;
342
+ stageRequested: string;
343
+ stageRequests: string;
344
+ people: string;
345
+ panelists: string;
346
+ audience: string;
347
+ noWaiting: string;
348
+ noPanelists: string;
349
+ noAudience: string;
350
+ closePanel: string;
351
+ muteChat: string;
352
+ allowChat: string;
353
+ pin: string;
354
+ unpin: string;
355
+ pinnedToast: string;
356
+ unpinnedToast: string;
357
+ pinError: string;
358
+ kickTitle: string;
359
+ kickDescription: string;
360
+ kickConfirm: string;
361
+ kickError: string;
362
+ stageError: string;
363
+ stageDisabled: string;
364
+ stageGrantNoEffect: string;
365
+ stageOverflow: string;
366
+ chatEveryone: string;
367
+ chatEdited: string;
368
+ chatPinned: string;
369
+ chatLoadOlder: string;
370
+ chatRateLimited: string;
371
+ chatDelete: string;
372
+ chatEdit: string;
373
+ chatPin: string;
374
+ chatUnpin: string;
375
+ chatSave: string;
376
+ waitingSkeleton: string;
377
+ };
378
+
379
+ declare function StudioRoom({ session, meeting, control, onRefreshStatus, onRejoin, labels, reducedMotion, embed, chrome, playerOrigin, windowGate, initialCameraOn, initialMuted, }: {
380
+ session: StudioSession;
381
+ meeting: StudioMeetingHandle;
382
+ control: StudioControlActions;
383
+ onRefreshStatus?: () => Promise<void>;
384
+ onRejoin?: () => void;
385
+ reducedMotion: boolean;
386
+ labels: StudioRoomLabels;
387
+ embed?: boolean;
388
+ chrome?: ReactNode;
389
+ playerOrigin?: string;
390
+ windowGate?: {
391
+ reportDuplicate: () => void;
392
+ };
393
+ initialCameraOn?: boolean;
394
+ initialMuted?: boolean;
395
+ }): react.JSX.Element;
396
+
397
+ declare function StudioSkeleton(): react.JSX.Element;
398
+
399
+ declare function StudioGuestLobby({ reducedMotion, cameraOn, muted, displayName, showName, joining, waitingForHost, error, labels, onCameraChange, onMutedChange, onDisplayNameChange, onJoin, }: {
400
+ reducedMotion: boolean;
401
+ cameraOn: boolean;
402
+ muted: boolean;
403
+ displayName: string;
404
+ showName: boolean;
405
+ joining: boolean;
406
+ waitingForHost: boolean;
407
+ error: string | null;
408
+ labels: {
409
+ title: string;
410
+ hint: string;
411
+ name: string;
412
+ join: string;
413
+ waitingForHost: string;
414
+ camera: string;
415
+ mic: string;
416
+ };
417
+ onCameraChange: (on: boolean) => void;
418
+ onMutedChange: (muted: boolean) => void;
419
+ onDisplayNameChange: (name: string) => void;
420
+ onJoin: () => void;
421
+ }): react.JSX.Element;
422
+
423
+ type StudioWindowGateContextValue = {
424
+ reportDuplicate: () => void;
425
+ };
426
+ declare const StudioWindowGateContext: react.Context<StudioWindowGateContextValue>;
427
+ declare function useStudioWindowGate(): StudioWindowGateContextValue;
428
+ declare function StudioWindowGate({ lockKey, allowTakeover, labels, children, }: {
429
+ lockKey: string;
430
+ allowTakeover?: boolean;
431
+ labels: {
432
+ duplicateTitle: string;
433
+ duplicateDescription: string;
434
+ duplicateDescriptionNoTakeover: string;
435
+ duplicateTakenOver: string;
436
+ duplicateAction: string;
437
+ };
438
+ children: ReactNode;
439
+ }): react.JSX.Element;
440
+
441
+ declare function LivoHostStudio({ token, apiUrl, labels, redeemError, embed, chrome, playerOrigin, theme, }: {
442
+ token: string;
443
+ apiUrl?: string;
444
+ labels: StudioRoomLabels;
445
+ redeemError?: string;
446
+ embed?: boolean;
447
+ chrome?: ReactNode;
448
+ playerOrigin?: string;
449
+ theme?: string | null;
450
+ }): react.JSX.Element;
451
+
452
+ type StudioLobbyLabels = {
453
+ title: string;
454
+ hint: string;
455
+ name: string;
456
+ join: string;
457
+ waitingForHost: string;
458
+ camera: string;
459
+ mic: string;
460
+ joinError: string;
461
+ joinBusy: string;
462
+ endedTitle: string;
463
+ };
464
+ declare function LivoGuestStudio({ token, apiUrl, labels, lobbyLabels, embed, playerOrigin, theme, }: {
465
+ token: string;
466
+ apiUrl?: string;
467
+ labels: StudioRoomLabels;
468
+ lobbyLabels: StudioLobbyLabels;
469
+ embed?: boolean;
470
+ playerOrigin?: string;
471
+ theme?: string | null;
472
+ }): react.JSX.Element;
473
+
474
+ declare function useRealtimeKitMeeting(authToken: string | null, generation?: number): {
475
+ meeting: StudioMeetingHandle | null;
476
+ error: string | null;
477
+ };
478
+
479
+ declare function usePrefersReducedMotion(): boolean;
480
+
481
+ declare class StudioApiError extends Error {
482
+ readonly status: number;
483
+ readonly body: unknown;
484
+ constructor(status: number, message: string, body: unknown);
485
+ }
486
+ declare function redeemStudioHost(token: string, apiUrl?: string, fetchFn?: typeof fetch): Promise<StudioSession>;
487
+ declare function joinStudioGuest(token: string, input: {
488
+ displayName: string;
489
+ guestId: string;
490
+ }, apiUrl?: string, fetchFn?: typeof fetch): Promise<StudioSession>;
491
+ declare function getStudioJoinStatus(token: string, apiUrl?: string, fetchFn?: typeof fetch): Promise<{
492
+ ready: boolean;
493
+ streamStatus: string | null;
494
+ } | "ended">;
495
+
496
+ export { LivoGuestStudio, LivoHostStudio, StudioApiError, type StudioControlActions, StudioControlClient, type StudioControlClientOptions, StudioControlError, StudioGuestLobby, type StudioLobbyLabels, type StudioMeetingHandle, type StudioRole, StudioRoom, type StudioRoomLabels, type StudioSession, StudioSkeleton, StudioWindowGate, StudioWindowGateContext, controlActionsFromClient, createStudioControlClient, getStudioJoinStatus, joinStudioGuest, redeemStudioHost, studioErrorCode, studioRoomLabels, usePrefersReducedMotion, useRealtimeKitMeeting, useStudioWindowGate };