@appsocom/react 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/components.d.ts +157 -0
- package/dist/components.js +521 -0
- package/dist/components.js.map +1 -0
- package/dist/hooks.d.ts +196 -0
- package/dist/hooks.js +286 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -4
- package/styles.css +360 -0
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hooks for sfukit rooms. No DOM and no WebRTC imports here, so the
|
|
3
|
+
* same hooks work with the web Room (@appsocom/client) and the React Native
|
|
4
|
+
* room (@appsocom/react-native). Import from "@appsocom/react/hooks" in React Native.
|
|
5
|
+
*
|
|
6
|
+
* Features that land later (active speakers, connection quality, adaptive
|
|
7
|
+
* video) are picked up when the room offers them, and are no-ops otherwise.
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
|
+
import type { ChatMessage, DataSaverInput, DataSaverMode, DataSaverSettings, DataUsage, Participant, ParticipantState, Permissions, RecordingStatus, RoomState, TrackKind, TranscriptSegment, LessonState, LessonControl } from "@appsocom/protocol";
|
|
11
|
+
export type ConnectionState = "connecting" | "connected" | "reconnecting" | "disconnected";
|
|
12
|
+
export type ConnectionQuality = "excellent" | "good" | "poor" | "lost";
|
|
13
|
+
/** Anything shaped like a Room. Optional members are features some rooms/versions don't have. */
|
|
14
|
+
export interface RoomLike {
|
|
15
|
+
readonly roomId: string;
|
|
16
|
+
readonly userId: string;
|
|
17
|
+
readonly role: string;
|
|
18
|
+
permissions: Permissions;
|
|
19
|
+
self: Participant | null;
|
|
20
|
+
connectionState: ConnectionState;
|
|
21
|
+
readonly participants: Participant[];
|
|
22
|
+
readonly localState: ParticipantState;
|
|
23
|
+
readonly canPublish?: boolean;
|
|
24
|
+
getTrack(participantId: string, kind: TrackKind): MediaStreamTrack | undefined;
|
|
25
|
+
on(event: string, handler: (...args: any[]) => void): () => void;
|
|
26
|
+
setMic(on: boolean): void;
|
|
27
|
+
setCamera(on: boolean): void;
|
|
28
|
+
toggleMic(): void;
|
|
29
|
+
toggleCamera(): void;
|
|
30
|
+
toggleScreenShare?(): void;
|
|
31
|
+
send(data: unknown): void;
|
|
32
|
+
leave(reason?: string): void;
|
|
33
|
+
setPermissions?(userId: string, permissions: Partial<Omit<Permissions, "moderate">>): void;
|
|
34
|
+
getLocalTrack?(kind: "video" | "screenVideo"): MediaStreamTrack | null;
|
|
35
|
+
backgroundEffect?: unknown;
|
|
36
|
+
noiseSuppression?: boolean;
|
|
37
|
+
setBackgroundEffect?(effect: boolean | object): void;
|
|
38
|
+
setNoiseSuppression?(on: boolean | object): void;
|
|
39
|
+
setMicDevice?(device: MediaDeviceInfo): void;
|
|
40
|
+
setCameraDevice?(device: MediaDeviceInfo): void;
|
|
41
|
+
setAudioOutputDevice?(deviceId: string): void;
|
|
42
|
+
switchCamera?(): void;
|
|
43
|
+
resumeAudio?(): void;
|
|
44
|
+
activeSpeakers?: string[];
|
|
45
|
+
getConnectionQuality?(participantId: string): ConnectionQuality | undefined;
|
|
46
|
+
fitVideoQuality?(participantId: string, element: HTMLElement): () => void;
|
|
47
|
+
observeVisibility?(element: Element, participantId: string): () => void;
|
|
48
|
+
setAudioOnly?(on: boolean): void;
|
|
49
|
+
audioOnly?: boolean;
|
|
50
|
+
setDataSaver?(input: DataSaverInput): void;
|
|
51
|
+
dataSaver?: {
|
|
52
|
+
mode: DataSaverMode | "custom";
|
|
53
|
+
settings: DataSaverSettings;
|
|
54
|
+
};
|
|
55
|
+
audioFallback?: boolean;
|
|
56
|
+
setAudioFallback?(enabled: boolean): void;
|
|
57
|
+
dataUsage?: DataUsage;
|
|
58
|
+
roomState?: RoomState;
|
|
59
|
+
waiting?: Participant[];
|
|
60
|
+
chat?: ChatMessage[];
|
|
61
|
+
recording?: RecordingStatus | null;
|
|
62
|
+
raisedHands?: Participant[];
|
|
63
|
+
agents?: Participant[];
|
|
64
|
+
sendChat?(text: string, options?: {
|
|
65
|
+
to?: string;
|
|
66
|
+
}): void;
|
|
67
|
+
raiseHand?(): void;
|
|
68
|
+
lowerHand?(userId?: string): void;
|
|
69
|
+
mute?(userId: string, devices?: ("mic" | "camera" | "screen")[]): void;
|
|
70
|
+
remove?(userId: string): void;
|
|
71
|
+
admit?(userId: string): void;
|
|
72
|
+
deny?(userId: string): void;
|
|
73
|
+
}
|
|
74
|
+
/** Makes a room available to the hooks and components below it. */
|
|
75
|
+
export declare function RoomProvider({ room, children }: {
|
|
76
|
+
room: RoomLike | null;
|
|
77
|
+
children?: ReactNode;
|
|
78
|
+
}): import("react").FunctionComponentElement<import("react").ProviderProps<RoomLike | null>>;
|
|
79
|
+
/** The room from the nearest <RoomProvider> / <SfuRoom>. Throws if there is none. */
|
|
80
|
+
export declare function useRoom<R extends RoomLike = RoomLike>(): R;
|
|
81
|
+
/** Like useRoom(), but returns null outside a room (e.g. on a prejoin screen). */
|
|
82
|
+
export declare function useMaybeRoom<R extends RoomLike = RoomLike>(): R | null;
|
|
83
|
+
/**
|
|
84
|
+
* Re-reads `read(room)` whenever one of `events` fires. The value is compared
|
|
85
|
+
* with `same` so unchanged reads don't re-render.
|
|
86
|
+
*/
|
|
87
|
+
export declare function useRoomValue<T>(events: string[], read: (room: RoomLike) => T, same?: (a: T, b: T) => boolean, room?: RoomLike | null): T;
|
|
88
|
+
/** Subscribe to a room event for the lifetime of the component. */
|
|
89
|
+
export declare function useRoomEvent(event: string, handler: (...args: any[]) => void, room?: RoomLike | null): void;
|
|
90
|
+
/** App messages sent with room.send() by other participants. */
|
|
91
|
+
export declare function useRoomMessages(handler: (data: unknown, from: Participant | undefined) => void): void;
|
|
92
|
+
/** Everyone else in the room, in join order. */
|
|
93
|
+
export declare function useParticipants(): Participant[];
|
|
94
|
+
/** One remote participant by connection id (undefined once they leave). */
|
|
95
|
+
export declare function useParticipant(participantId: string): Participant | undefined;
|
|
96
|
+
/** Your own side: participant record, mic/camera/screen state, role and permissions. */
|
|
97
|
+
export declare function useLocalParticipant(): {
|
|
98
|
+
self: Participant | null;
|
|
99
|
+
state: ParticipantState;
|
|
100
|
+
role: string;
|
|
101
|
+
permissions: Permissions;
|
|
102
|
+
};
|
|
103
|
+
/** Your current permissions; updates when a teacher/host changes them. */
|
|
104
|
+
export declare function usePermissions(): Permissions;
|
|
105
|
+
/** Your mic/camera/screen on-off state. */
|
|
106
|
+
export declare function useLocalState(): ParticipantState;
|
|
107
|
+
/** A remote participant's track (null until it arrives or after it's removed). */
|
|
108
|
+
export declare function useTrack(participantId: string | undefined, kind: TrackKind): MediaStreamTrack | null;
|
|
109
|
+
/** Your own camera or screen preview. */
|
|
110
|
+
export declare function useLocalTrack(kind: "video" | "screenVideo"): MediaStreamTrack | null;
|
|
111
|
+
/** Room connection: "connecting" | "connected" | "reconnecting" | "disconnected". */
|
|
112
|
+
export declare function useConnectionState(): ConnectionState;
|
|
113
|
+
/** Media (WebRTC) connection state, e.g. to show "reconnecting media". */
|
|
114
|
+
export declare function useMediaConnectionState(): RTCPeerConnectionState | "new";
|
|
115
|
+
/** Participant ids currently speaking, loudest first (empty if the room doesn't report speakers). */
|
|
116
|
+
export declare function useActiveSpeakers(): string[];
|
|
117
|
+
/** True while this participant (connection id; your own is room.self.id) is speaking. */
|
|
118
|
+
export declare function useIsSpeaking(participantId: string | undefined): boolean;
|
|
119
|
+
/** Connection quality for a participant (undefined if the room doesn't report it). */
|
|
120
|
+
export declare function useConnectionQuality(participantId: string | undefined): ConnectionQuality | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Data saver: the current mode and a setter. `supported` is false for rooms
|
|
123
|
+
* without it. Modes: "off", "low", "minimal", "audio" (or custom settings).
|
|
124
|
+
*/
|
|
125
|
+
export declare function useDataSaver(): {
|
|
126
|
+
supported: boolean;
|
|
127
|
+
mode: DataSaverMode | "custom";
|
|
128
|
+
settings: DataSaverSettings | undefined;
|
|
129
|
+
setDataSaver: (input: DataSaverInput) => void;
|
|
130
|
+
};
|
|
131
|
+
/** True while your connection has fallen back to audio only because it's too weak for video. */
|
|
132
|
+
export declare function useAudioFallback(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Media data used in this call so far (bytes up/down, current rates, MB per
|
|
135
|
+
* hour at the current rate). Updates every couple of seconds; undefined for
|
|
136
|
+
* rooms that don't measure it.
|
|
137
|
+
*/
|
|
138
|
+
export declare function useDataUsage(): DataUsage | undefined;
|
|
139
|
+
/** Background effect and noise suppression state, with setters. */
|
|
140
|
+
export declare function useEffects(): {
|
|
141
|
+
supported: boolean;
|
|
142
|
+
backgroundBlur: boolean;
|
|
143
|
+
noiseSuppression: boolean;
|
|
144
|
+
setBackgroundBlur: (on: boolean) => void;
|
|
145
|
+
setBackgroundEffect: (effect: boolean | object) => void;
|
|
146
|
+
setNoiseSuppression: (on: boolean) => void;
|
|
147
|
+
};
|
|
148
|
+
/** Room-wide settings: locked, chat on/off, spotlight, waiting room, breakouts, metadata. */
|
|
149
|
+
export declare function useRoomState(): RoomState | undefined;
|
|
150
|
+
/** Room metadata set by your app's backend. */
|
|
151
|
+
export declare function useRoomMetadata(): Record<string, unknown> | undefined;
|
|
152
|
+
/** Chat messages (oldest first) and a send function. */
|
|
153
|
+
export declare function useChat(): {
|
|
154
|
+
messages: ChatMessage[];
|
|
155
|
+
send: (text: string, options?: {
|
|
156
|
+
to?: string;
|
|
157
|
+
}) => void;
|
|
158
|
+
enabled: boolean;
|
|
159
|
+
};
|
|
160
|
+
/** Participants with a raised hand, in the order they raised it. */
|
|
161
|
+
export declare function useRaisedHands(): Participant[];
|
|
162
|
+
/** Teachers/hosts: who's waiting to be let in. */
|
|
163
|
+
export declare function useWaitingList(): Participant[];
|
|
164
|
+
/** The recording in progress, or null. */
|
|
165
|
+
export declare function useRecording(): RecordingStatus | null;
|
|
166
|
+
/** AI agents in the room. */
|
|
167
|
+
export declare function useAgents(): Participant[];
|
|
168
|
+
/** Live transcript segments (agent conversations), last `limit` kept. */
|
|
169
|
+
export declare function useTranscript(limit?: number): TranscriptSegment[];
|
|
170
|
+
export type JoinStatus = "idle" | "joining" | "joined" | "left" | "error";
|
|
171
|
+
/**
|
|
172
|
+
* Joins a room while the component is mounted (and `enabled`), leaves on
|
|
173
|
+
* unmount. `join` is the platform's join function (joinRoom on the web).
|
|
174
|
+
* Rejoins when `key` changes (e.g. a new token for a different room).
|
|
175
|
+
*/
|
|
176
|
+
export declare function useJoin<R extends RoomLike, O>(join: (options: O) => Promise<R>, options: O, { enabled, key }?: {
|
|
177
|
+
enabled?: boolean;
|
|
178
|
+
key?: string;
|
|
179
|
+
}): {
|
|
180
|
+
room: R | null;
|
|
181
|
+
status: JoinStatus;
|
|
182
|
+
error: Error | null;
|
|
183
|
+
leftReason: string | null;
|
|
184
|
+
};
|
|
185
|
+
/** Initials for an avatar placeholder. */
|
|
186
|
+
export declare function initials(name: string): string;
|
|
187
|
+
/**
|
|
188
|
+
* The AI lesson in this room (slide, whiteboard, who has the floor, quiz,
|
|
189
|
+
* timer), or null, plus `ask` (type a question) and `control` (moderators:
|
|
190
|
+
* pause, takeover, handback, call-on, goto, scope, note, end).
|
|
191
|
+
*/
|
|
192
|
+
export declare function useLesson(): {
|
|
193
|
+
lesson: LessonState | null;
|
|
194
|
+
ask: (text: string) => void;
|
|
195
|
+
control: (control: LessonControl) => void;
|
|
196
|
+
};
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hooks for sfukit rooms. No DOM and no WebRTC imports here, so the
|
|
3
|
+
* same hooks work with the web Room (@appsocom/client) and the React Native
|
|
4
|
+
* room (@appsocom/react-native). Import from "@appsocom/react/hooks" in React Native.
|
|
5
|
+
*
|
|
6
|
+
* Features that land later (active speakers, connection quality, adaptive
|
|
7
|
+
* video) are picked up when the room offers them, and are no-ops otherwise.
|
|
8
|
+
*/
|
|
9
|
+
import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
10
|
+
const RoomContext = createContext(null);
|
|
11
|
+
/** Makes a room available to the hooks and components below it. */
|
|
12
|
+
export function RoomProvider({ room, children }) {
|
|
13
|
+
return createElement(RoomContext.Provider, { value: room }, children);
|
|
14
|
+
}
|
|
15
|
+
/** The room from the nearest <RoomProvider> / <SfuRoom>. Throws if there is none. */
|
|
16
|
+
export function useRoom() {
|
|
17
|
+
const room = useContext(RoomContext);
|
|
18
|
+
if (!room)
|
|
19
|
+
throw new Error("useRoom() must be used inside <SfuRoom> or <RoomProvider>");
|
|
20
|
+
return room;
|
|
21
|
+
}
|
|
22
|
+
/** Like useRoom(), but returns null outside a room (e.g. on a prejoin screen). */
|
|
23
|
+
export function useMaybeRoom() {
|
|
24
|
+
return useContext(RoomContext);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Re-reads `read(room)` whenever one of `events` fires. The value is compared
|
|
28
|
+
* with `same` so unchanged reads don't re-render.
|
|
29
|
+
*/
|
|
30
|
+
export function useRoomValue(events, read, same = Object.is, room) {
|
|
31
|
+
const ctx = useMaybeRoom();
|
|
32
|
+
const r = room ?? ctx;
|
|
33
|
+
const readRef = useRef(read);
|
|
34
|
+
readRef.current = read;
|
|
35
|
+
const [value, setValue] = useState(() => (r ? read(r) : undefined));
|
|
36
|
+
const key = events.join("|");
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!r)
|
|
39
|
+
return;
|
|
40
|
+
const update = () => setValue((prev) => {
|
|
41
|
+
const next = readRef.current(r);
|
|
42
|
+
return same(prev, next) ? prev : next;
|
|
43
|
+
});
|
|
44
|
+
update();
|
|
45
|
+
const offs = events.map((e) => r.on(e, update));
|
|
46
|
+
return () => offs.forEach((off) => off());
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
}, [r, key]);
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
/** Subscribe to a room event for the lifetime of the component. */
|
|
52
|
+
export function useRoomEvent(event, handler, room) {
|
|
53
|
+
const ctx = useMaybeRoom();
|
|
54
|
+
const r = room ?? ctx;
|
|
55
|
+
const ref = useRef(handler);
|
|
56
|
+
ref.current = handler;
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!r)
|
|
59
|
+
return;
|
|
60
|
+
return r.on(event, (...args) => ref.current(...args));
|
|
61
|
+
}, [r, event]);
|
|
62
|
+
}
|
|
63
|
+
/** App messages sent with room.send() by other participants. */
|
|
64
|
+
export function useRoomMessages(handler) {
|
|
65
|
+
useRoomEvent("message", handler);
|
|
66
|
+
}
|
|
67
|
+
const PARTICIPANT_EVENTS = ["participant-joined", "participant-updated", "participant-left"];
|
|
68
|
+
/** Everyone else in the room, in join order. */
|
|
69
|
+
export function useParticipants() {
|
|
70
|
+
return useRoomValue(PARTICIPANT_EVENTS, (r) => [...r.participants].sort((a, b) => a.joinedAt - b.joinedAt), sameList);
|
|
71
|
+
}
|
|
72
|
+
/** One remote participant by connection id (undefined once they leave). */
|
|
73
|
+
export function useParticipant(participantId) {
|
|
74
|
+
return useRoomValue(PARTICIPANT_EVENTS, (r) => r.participants.find((p) => p.id === participantId));
|
|
75
|
+
}
|
|
76
|
+
/** Your own side: participant record, mic/camera/screen state, role and permissions. */
|
|
77
|
+
export function useLocalParticipant() {
|
|
78
|
+
const self = useRoomValue(["connection", "permissions"], (r) => r.self);
|
|
79
|
+
const state = useRoomValue(["local-state"], (r) => r.localState, sameJson);
|
|
80
|
+
const permissions = usePermissions();
|
|
81
|
+
const role = useRoomValue([], (r) => r.role);
|
|
82
|
+
return { self, state, role, permissions };
|
|
83
|
+
}
|
|
84
|
+
/** Your current permissions; updates when a teacher/host changes them. */
|
|
85
|
+
export function usePermissions() {
|
|
86
|
+
return useRoomValue(["permissions", "connection"], (r) => ({ ...r.permissions }), sameJson);
|
|
87
|
+
}
|
|
88
|
+
/** Your mic/camera/screen on-off state. */
|
|
89
|
+
export function useLocalState() {
|
|
90
|
+
return useRoomValue(["local-state"], (r) => r.localState, sameJson);
|
|
91
|
+
}
|
|
92
|
+
/** A remote participant's track (null until it arrives or after it's removed). */
|
|
93
|
+
export function useTrack(participantId, kind) {
|
|
94
|
+
return useRoomValue(["track", "track-removed", "participant-left"], (r) => (participantId ? r.getTrack(participantId, kind) ?? null : null));
|
|
95
|
+
}
|
|
96
|
+
/** Your own camera or screen preview. */
|
|
97
|
+
export function useLocalTrack(kind) {
|
|
98
|
+
const [track, setTrack] = useState(null);
|
|
99
|
+
const room = useMaybeRoom();
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!room)
|
|
102
|
+
return;
|
|
103
|
+
setTrack(room.getLocalTrack?.(kind) ?? null);
|
|
104
|
+
return room.on("local-track", (k, t) => {
|
|
105
|
+
if (k === kind)
|
|
106
|
+
setTrack(t);
|
|
107
|
+
});
|
|
108
|
+
}, [room, kind]);
|
|
109
|
+
return track;
|
|
110
|
+
}
|
|
111
|
+
/** Room connection: "connecting" | "connected" | "reconnecting" | "disconnected". */
|
|
112
|
+
export function useConnectionState() {
|
|
113
|
+
return useRoomValue(["connection"], (r) => r.connectionState);
|
|
114
|
+
}
|
|
115
|
+
/** Media (WebRTC) connection state, e.g. to show "reconnecting media". */
|
|
116
|
+
export function useMediaConnectionState() {
|
|
117
|
+
const [state, setState] = useState("new");
|
|
118
|
+
useRoomEvent("media-connection", setState);
|
|
119
|
+
return state;
|
|
120
|
+
}
|
|
121
|
+
/** Participant ids currently speaking, loudest first (empty if the room doesn't report speakers). */
|
|
122
|
+
export function useActiveSpeakers() {
|
|
123
|
+
return useRoomValue(["active-speakers"], (r) => r.activeSpeakers ?? [], sameList);
|
|
124
|
+
}
|
|
125
|
+
/** True while this participant (connection id; your own is room.self.id) is speaking. */
|
|
126
|
+
export function useIsSpeaking(participantId) {
|
|
127
|
+
const speakers = useActiveSpeakers();
|
|
128
|
+
return !!participantId && speakers.includes(participantId);
|
|
129
|
+
}
|
|
130
|
+
/** Connection quality for a participant (undefined if the room doesn't report it). */
|
|
131
|
+
export function useConnectionQuality(participantId) {
|
|
132
|
+
return useRoomValue(["connection-quality"], (r) => participantId ? r.getConnectionQuality?.(participantId) : undefined);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Data saver: the current mode and a setter. `supported` is false for rooms
|
|
136
|
+
* without it. Modes: "off", "low", "minimal", "audio" (or custom settings).
|
|
137
|
+
*/
|
|
138
|
+
export function useDataSaver() {
|
|
139
|
+
const room = useMaybeRoom();
|
|
140
|
+
const value = useRoomValue(["data-saver"], (r) => r.dataSaver, sameJson);
|
|
141
|
+
const setDataSaver = useCallback((input) => room?.setDataSaver?.(input), [room]);
|
|
142
|
+
return { supported: !!room?.setDataSaver, mode: value?.mode ?? "off", settings: value?.settings, setDataSaver };
|
|
143
|
+
}
|
|
144
|
+
/** True while your connection has fallen back to audio only because it's too weak for video. */
|
|
145
|
+
export function useAudioFallback() {
|
|
146
|
+
return useRoomValue(["audio-fallback"], (r) => !!r.audioFallback);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Media data used in this call so far (bytes up/down, current rates, MB per
|
|
150
|
+
* hour at the current rate). Updates every couple of seconds; undefined for
|
|
151
|
+
* rooms that don't measure it.
|
|
152
|
+
*/
|
|
153
|
+
export function useDataUsage() {
|
|
154
|
+
return useRoomValue(["data-usage"], (r) => r.dataUsage, sameJson);
|
|
155
|
+
}
|
|
156
|
+
/** Background effect and noise suppression state, with setters. */
|
|
157
|
+
export function useEffects() {
|
|
158
|
+
const room = useMaybeRoom();
|
|
159
|
+
const value = useRoomValue(["effects"], (r) => ({ bg: !!r.backgroundEffect, ns: !!r.noiseSuppression }), sameJson);
|
|
160
|
+
const setBackgroundEffect = useCallback((e) => room?.setBackgroundEffect?.(e), [room]);
|
|
161
|
+
return {
|
|
162
|
+
supported: !!room?.setBackgroundEffect,
|
|
163
|
+
backgroundBlur: !!value?.bg,
|
|
164
|
+
noiseSuppression: !!value?.ns,
|
|
165
|
+
setBackgroundEffect,
|
|
166
|
+
setBackgroundBlur: (on) => setBackgroundEffect(on),
|
|
167
|
+
setNoiseSuppression: (on) => room?.setNoiseSuppression?.(on),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Room-wide settings: locked, chat on/off, spotlight, waiting room, breakouts, metadata. */
|
|
171
|
+
export function useRoomState() {
|
|
172
|
+
return useRoomValue(["room-state", "connection"], (r) => r.roomState, sameJson);
|
|
173
|
+
}
|
|
174
|
+
/** Room metadata set by your app's backend. */
|
|
175
|
+
export function useRoomMetadata() {
|
|
176
|
+
return useRoomState()?.metadata;
|
|
177
|
+
}
|
|
178
|
+
/** Chat messages (oldest first) and a send function. */
|
|
179
|
+
export function useChat() {
|
|
180
|
+
const room = useMaybeRoom();
|
|
181
|
+
const messages = useRoomValue(["chat", "chat-deleted", "connection"], (r) => [...(r.chat ?? [])], sameList);
|
|
182
|
+
const state = useRoomState();
|
|
183
|
+
return {
|
|
184
|
+
messages: messages ?? [],
|
|
185
|
+
send: useCallback((text, options) => room?.sendChat?.(text, options), [room]),
|
|
186
|
+
enabled: state?.chat !== false,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** Participants with a raised hand, in the order they raised it. */
|
|
190
|
+
export function useRaisedHands() {
|
|
191
|
+
return useRoomValue(["hands", "participant-left"], (r) => [...(r.raisedHands ?? [])], sameList);
|
|
192
|
+
}
|
|
193
|
+
/** Teachers/hosts: who's waiting to be let in. */
|
|
194
|
+
export function useWaitingList() {
|
|
195
|
+
return useRoomValue(["waiting-list"], (r) => [...(r.waiting ?? [])], sameList);
|
|
196
|
+
}
|
|
197
|
+
/** The recording in progress, or null. */
|
|
198
|
+
export function useRecording() {
|
|
199
|
+
return useRoomValue(["recording"], (r) => r.recording ?? null, sameJson);
|
|
200
|
+
}
|
|
201
|
+
/** AI agents in the room. */
|
|
202
|
+
export function useAgents() {
|
|
203
|
+
return useRoomValue(["participant-joined", "participant-updated", "participant-left", "agent-state"], (r) => [...(r.agents ?? [])], sameList);
|
|
204
|
+
}
|
|
205
|
+
/** Live transcript segments (agent conversations), last `limit` kept. */
|
|
206
|
+
export function useTranscript(limit = 100) {
|
|
207
|
+
const [segments, setSegments] = useState([]);
|
|
208
|
+
useRoomEvent("transcript", (seg) => setSegments((prev) => {
|
|
209
|
+
// Interim segments are replaced by later ones with the same id.
|
|
210
|
+
const i = prev.findIndex((p) => p.id === seg.id);
|
|
211
|
+
const next = i >= 0 ? [...prev.slice(0, i), seg, ...prev.slice(i + 1)] : [...prev, seg];
|
|
212
|
+
return next.slice(-limit);
|
|
213
|
+
}));
|
|
214
|
+
return segments;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Joins a room while the component is mounted (and `enabled`), leaves on
|
|
218
|
+
* unmount. `join` is the platform's join function (joinRoom on the web).
|
|
219
|
+
* Rejoins when `key` changes (e.g. a new token for a different room).
|
|
220
|
+
*/
|
|
221
|
+
export function useJoin(join, options, { enabled = true, key } = {}) {
|
|
222
|
+
const [state, setState] = useState({ room: null, status: "idle", error: null, leftReason: null });
|
|
223
|
+
const optsRef = useRef(options);
|
|
224
|
+
optsRef.current = options;
|
|
225
|
+
const joinRef = useRef(join);
|
|
226
|
+
joinRef.current = join;
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (!enabled)
|
|
229
|
+
return;
|
|
230
|
+
let cancelled = false;
|
|
231
|
+
let joined = null;
|
|
232
|
+
setState({ room: null, status: "joining", error: null, leftReason: null });
|
|
233
|
+
joinRef.current(optsRef.current).then((room) => {
|
|
234
|
+
if (cancelled)
|
|
235
|
+
return room.leave("unmounted");
|
|
236
|
+
joined = room;
|
|
237
|
+
room.on("left", (reason) => {
|
|
238
|
+
if (!cancelled)
|
|
239
|
+
setState((s) => ({ ...s, status: "left", leftReason: reason }));
|
|
240
|
+
});
|
|
241
|
+
setState({ room, status: "joined", error: null, leftReason: null });
|
|
242
|
+
}, (err) => {
|
|
243
|
+
if (!cancelled)
|
|
244
|
+
setState({ room: null, status: "error", error: err instanceof Error ? err : new Error(String(err)), leftReason: null });
|
|
245
|
+
});
|
|
246
|
+
return () => {
|
|
247
|
+
cancelled = true;
|
|
248
|
+
joined?.leave("unmounted");
|
|
249
|
+
};
|
|
250
|
+
}, [enabled, key]);
|
|
251
|
+
return state;
|
|
252
|
+
}
|
|
253
|
+
// ---------- small helpers ----------
|
|
254
|
+
function sameList(a, b) {
|
|
255
|
+
if (a === b)
|
|
256
|
+
return true;
|
|
257
|
+
if (!a || !b || a.length !== b.length)
|
|
258
|
+
return false;
|
|
259
|
+
for (let i = 0; i < a.length; i++)
|
|
260
|
+
if (a[i] !== b[i])
|
|
261
|
+
return false;
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
function sameJson(a, b) {
|
|
265
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
266
|
+
}
|
|
267
|
+
/** Initials for an avatar placeholder. */
|
|
268
|
+
export function initials(name) {
|
|
269
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
270
|
+
if (!parts.length)
|
|
271
|
+
return "?";
|
|
272
|
+
return ((parts[0][0] ?? "") + (parts.length > 1 ? parts[parts.length - 1][0] ?? "" : "")).toUpperCase();
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The AI lesson in this room (slide, whiteboard, who has the floor, quiz,
|
|
276
|
+
* timer), or null, plus `ask` (type a question) and `control` (moderators:
|
|
277
|
+
* pause, takeover, handback, call-on, goto, scope, note, end).
|
|
278
|
+
*/
|
|
279
|
+
export function useLesson() {
|
|
280
|
+
const room = useMaybeRoom();
|
|
281
|
+
const lesson = useRoomValue(["lesson", "lesson-ended", "connection-state"], (r) => r.lesson ?? null, Object.is, room);
|
|
282
|
+
const ask = useCallback((text) => room?.askLesson?.(text), [room]);
|
|
283
|
+
const control = useCallback((c) => room?.controlLesson?.(c), [room]);
|
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UAAU,SAAS;IAKvB,MAAM,IAAI,GAAG,YAAY,EAAoC,CAAC;IAC9D,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAE,CAA2B,CAAC,MAAM,IAAI,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACjJ,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAgB,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsocom/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "React hooks and components for Appsocom Live: video grid, controls, device picker, prejoin screen",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"appsocom",
|
|
7
|
+
"video",
|
|
8
|
+
"calls",
|
|
9
|
+
"webrtc",
|
|
10
|
+
"sfu",
|
|
11
|
+
"cloudflare",
|
|
12
|
+
"react",
|
|
13
|
+
"hooks",
|
|
14
|
+
"components"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://docs.appsocom.dev",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/appsotechltd/appsotech-sfu/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/appsotechltd/appsotech-sfu.git",
|
|
23
|
+
"directory": "packages/react"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "Appsotech Limited",
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./hooks": {
|
|
36
|
+
"types": "./dist/hooks.d.ts",
|
|
37
|
+
"default": "./dist/hooks.js"
|
|
38
|
+
},
|
|
39
|
+
"./styles.css": "./styles.css"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"styles.css",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"sideEffects": [
|
|
48
|
+
"*.css"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.json",
|
|
52
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@appsocom/client": "0.5.0",
|
|
56
|
+
"@appsocom/protocol": "0.5.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"react": ">=18"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
}
|
|
64
|
+
}
|