@conference-kit/react 0.0.6 → 0.0.7
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/package.json +1 -1
- package/src/hooks/useMeshRoom.ts +21 -3
- package/dist/components/AudioPlayer.d.ts +0 -5
- package/dist/components/AudioPlayer.d.ts.map +0 -1
- package/dist/components/AudioPlayer.js +0 -16
- package/dist/components/AudioPlayer.js.map +0 -1
- package/dist/components/ErrorBanner.d.ts +0 -6
- package/dist/components/ErrorBanner.d.ts.map +0 -1
- package/dist/components/ErrorBanner.js +0 -12
- package/dist/components/ErrorBanner.js.map +0 -1
- package/dist/components/StatusBadge.d.ts +0 -7
- package/dist/components/StatusBadge.d.ts.map +0 -1
- package/dist/components/StatusBadge.js +0 -30
- package/dist/components/StatusBadge.js.map +0 -1
- package/dist/components/VideoPlayer.d.ts +0 -5
- package/dist/components/VideoPlayer.d.ts.map +0 -1
- package/dist/components/VideoPlayer.js +0 -30
- package/dist/components/VideoPlayer.js.map +0 -1
- package/dist/config/features.d.ts +0 -10
- package/dist/config/features.d.ts.map +0 -1
- package/dist/config/features.js +0 -11
- package/dist/config/features.js.map +0 -1
- package/dist/context/WebRTCProvider.d.ts +0 -12
- package/dist/context/WebRTCProvider.d.ts.map +0 -1
- package/dist/context/WebRTCProvider.js +0 -13
- package/dist/context/WebRTCProvider.js.map +0 -1
- package/dist/hooks/useCall.d.ts +0 -31
- package/dist/hooks/useCall.d.ts.map +0 -1
- package/dist/hooks/useCall.js +0 -168
- package/dist/hooks/useCall.js.map +0 -1
- package/dist/hooks/useCallState.d.ts +0 -18
- package/dist/hooks/useCallState.d.ts.map +0 -1
- package/dist/hooks/useCallState.js +0 -33
- package/dist/hooks/useCallState.js.map +0 -1
- package/dist/hooks/useDataChannel.d.ts +0 -13
- package/dist/hooks/useDataChannel.d.ts.map +0 -1
- package/dist/hooks/useDataChannel.js +0 -33
- package/dist/hooks/useDataChannel.js.map +0 -1
- package/dist/hooks/useDataChannelMessages.d.ts +0 -17
- package/dist/hooks/useDataChannelMessages.d.ts.map +0 -1
- package/dist/hooks/useDataChannelMessages.js +0 -49
- package/dist/hooks/useDataChannelMessages.js.map +0 -1
- package/dist/hooks/useMediaStream.d.ts +0 -13
- package/dist/hooks/useMediaStream.d.ts.map +0 -1
- package/dist/hooks/useMediaStream.js +0 -81
- package/dist/hooks/useMediaStream.js.map +0 -1
- package/dist/hooks/useMeshRoom.d.ts +0 -42
- package/dist/hooks/useMeshRoom.d.ts.map +0 -1
- package/dist/hooks/useMeshRoom.js +0 -319
- package/dist/hooks/useMeshRoom.js.map +0 -1
- package/dist/hooks/useScreenShare.d.ts +0 -8
- package/dist/hooks/useScreenShare.d.ts.map +0 -1
- package/dist/hooks/useScreenShare.js +0 -41
- package/dist/hooks/useScreenShare.js.map +0 -1
- package/dist/hooks/useWebRTC.d.ts +0 -21
- package/dist/hooks/useWebRTC.d.ts.map +0 -1
- package/dist/hooks/useWebRTC.js +0 -96
- package/dist/hooks/useWebRTC.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/signaling/SignalingClient.d.ts +0 -58
- package/dist/signaling/SignalingClient.d.ts.map +0 -1
- package/dist/signaling/SignalingClient.js +0 -147
- package/dist/signaling/SignalingClient.js.map +0 -1
package/package.json
CHANGED
package/src/hooks/useMeshRoom.ts
CHANGED
|
@@ -333,6 +333,8 @@ export function useMeshRoom(options: UseMeshRoomOptions) {
|
|
|
333
333
|
}
|
|
334
334
|
>
|
|
335
335
|
>(new Map());
|
|
336
|
+
const activeCandidate = useRef<string | null>(null);
|
|
337
|
+
const activeSince = useRef<number>(0);
|
|
336
338
|
|
|
337
339
|
useEffect(() => {
|
|
338
340
|
if (!features.enableActiveSpeaker) return;
|
|
@@ -366,6 +368,8 @@ export function useMeshRoom(options: UseMeshRoomOptions) {
|
|
|
366
368
|
}
|
|
367
369
|
});
|
|
368
370
|
|
|
371
|
+
const minHoldMs = 700;
|
|
372
|
+
const minLevel = 18;
|
|
369
373
|
const interval = window.setInterval(() => {
|
|
370
374
|
let loudestId: string | null = null;
|
|
371
375
|
let loudest = 0;
|
|
@@ -375,11 +379,23 @@ export function useMeshRoom(options: UseMeshRoomOptions) {
|
|
|
375
379
|
const avg = data.reduce((acc, v) => acc + v, 0) / data.length;
|
|
376
380
|
if (avg > loudest) {
|
|
377
381
|
loudest = avg;
|
|
378
|
-
loudestId = avg >
|
|
382
|
+
loudestId = avg > minLevel ? id : null;
|
|
379
383
|
}
|
|
380
384
|
});
|
|
381
|
-
|
|
382
|
-
|
|
385
|
+
|
|
386
|
+
const now = performance.now();
|
|
387
|
+
if (loudestId !== activeCandidate.current) {
|
|
388
|
+
activeCandidate.current = loudestId;
|
|
389
|
+
activeSince.current = now;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const heldLongEnough = now - activeSince.current >= minHoldMs;
|
|
393
|
+
if (heldLongEnough) {
|
|
394
|
+
setActiveSpeakerId((prev) =>
|
|
395
|
+
prev === activeCandidate.current ? prev : activeCandidate.current
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
}, 400);
|
|
383
399
|
|
|
384
400
|
return () => {
|
|
385
401
|
window.clearInterval(interval);
|
|
@@ -389,6 +405,8 @@ export function useMeshRoom(options: UseMeshRoomOptions) {
|
|
|
389
405
|
entry.ctx.close();
|
|
390
406
|
});
|
|
391
407
|
analyzers.current.clear();
|
|
408
|
+
activeCandidate.current = null;
|
|
409
|
+
activeSince.current = 0;
|
|
392
410
|
};
|
|
393
411
|
}, [features.enableActiveSpeaker, participants]);
|
|
394
412
|
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type AudioPlayerProps = React.AudioHTMLAttributes<HTMLAudioElement> & {
|
|
2
|
-
stream?: MediaStream | null;
|
|
3
|
-
};
|
|
4
|
-
export declare function AudioPlayer({ stream, autoPlay, ...props }: AudioPlayerProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
//# sourceMappingURL=AudioPlayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../src/components/AudioPlayer.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC3E,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAe,EACf,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAYlB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
export function AudioPlayer({ stream, autoPlay = true, ...props }) {
|
|
4
|
-
const ref = useRef(null);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (!ref.current || !stream)
|
|
7
|
-
return;
|
|
8
|
-
ref.current.srcObject = stream;
|
|
9
|
-
return () => {
|
|
10
|
-
if (ref.current)
|
|
11
|
-
ref.current.srcObject = null;
|
|
12
|
-
};
|
|
13
|
-
}, [stream]);
|
|
14
|
-
return _jsx("audio", { ref: ref, autoPlay: autoPlay, ...props });
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=AudioPlayer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioPlayer.js","sourceRoot":"","sources":["../../src/components/AudioPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAM1C,MAAM,UAAU,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,GAAG,IAAI,EACf,GAAG,KAAK,EACS;IACjB,MAAM,GAAG,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO;QACpC,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;QAC/B,OAAO,GAAG,EAAE;YACV,IAAI,GAAG,CAAC,OAAO;gBAAE,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,gBAAO,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,KAAM,KAAK,GAAI,CAAC;AAC5D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBanner.d.ts","sourceRoot":"","sources":["../../src/components/ErrorBanner.tsx"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,gBAAgB,2CAexD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export function ErrorBanner({ message }) {
|
|
3
|
-
return (_jsx("div", { style: {
|
|
4
|
-
background: "#fef2f2",
|
|
5
|
-
color: "#991b1b",
|
|
6
|
-
padding: "8px 12px",
|
|
7
|
-
borderRadius: 8,
|
|
8
|
-
border: "1px solid #fecdd3",
|
|
9
|
-
fontSize: 14,
|
|
10
|
-
}, children: message }));
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ErrorBanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBanner.js","sourceRoot":"","sources":["../../src/components/ErrorBanner.tsx"],"names":[],"mappings":";AAIA,MAAM,UAAU,WAAW,CAAC,EAAE,OAAO,EAAoB;IACvD,OAAO,CACL,cACE,KAAK,EAAE;YACL,UAAU,EAAE,SAAS;YACrB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,UAAU;YACnB,YAAY,EAAE,CAAC;YACf,MAAM,EAAE,mBAAmB;YAC3B,QAAQ,EAAE,EAAE;SACb,YAEA,OAAO,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
type StatusBadgeProps = {
|
|
2
|
-
label: string;
|
|
3
|
-
tone?: "neutral" | "success" | "warn" | "error";
|
|
4
|
-
};
|
|
5
|
-
export declare function StatusBadge({ label, tone }: StatusBadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=StatusBadge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../src/components/StatusBadge.tsx"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;CACjD,CAAC;AAgBF,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE,gBAAgB,2CAqBxE"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const toneStyles = {
|
|
3
|
-
neutral: "#e5e7eb",
|
|
4
|
-
success: "#d1fae5",
|
|
5
|
-
warn: "#fef3c7",
|
|
6
|
-
error: "#fee2e2",
|
|
7
|
-
};
|
|
8
|
-
const toneText = {
|
|
9
|
-
neutral: "#111827",
|
|
10
|
-
success: "#065f46",
|
|
11
|
-
warn: "#92400e",
|
|
12
|
-
error: "#991b1b",
|
|
13
|
-
};
|
|
14
|
-
export function StatusBadge({ label, tone = "neutral" }) {
|
|
15
|
-
const bg = toneStyles[tone];
|
|
16
|
-
const color = toneText[tone];
|
|
17
|
-
return (_jsx("span", { style: {
|
|
18
|
-
display: "inline-flex",
|
|
19
|
-
alignItems: "center",
|
|
20
|
-
padding: "4px 8px",
|
|
21
|
-
borderRadius: 999,
|
|
22
|
-
background: bg,
|
|
23
|
-
color,
|
|
24
|
-
fontSize: 12,
|
|
25
|
-
fontWeight: 600,
|
|
26
|
-
textTransform: "uppercase",
|
|
27
|
-
letterSpacing: 0.3,
|
|
28
|
-
}, children: label }));
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=StatusBadge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.js","sourceRoot":"","sources":["../../src/components/StatusBadge.tsx"],"names":[],"mappings":";AAKA,MAAM,UAAU,GAA0D;IACxE,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,MAAM,QAAQ,GAA0D;IACtE,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,EAAoB;IACvE,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,CACL,eACE,KAAK,EAAE;YACL,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,GAAG;YACjB,UAAU,EAAE,EAAE;YACd,KAAK;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,WAAW;YAC1B,aAAa,EAAE,GAAG;SACnB,YAEA,KAAK,GACD,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type VideoPlayerProps = React.VideoHTMLAttributes<HTMLVideoElement> & {
|
|
2
|
-
stream?: MediaStream | null;
|
|
3
|
-
};
|
|
4
|
-
export declare function VideoPlayer({ stream, autoPlay, playsInline, muted, ...props }: VideoPlayerProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
//# sourceMappingURL=VideoPlayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC3E,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,QAAe,EACf,WAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAsClB"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
export function VideoPlayer({ stream, autoPlay = true, playsInline = true, muted, ...props }) {
|
|
4
|
-
const ref = useRef(null);
|
|
5
|
-
const prevStream = useRef(null);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const el = ref.current;
|
|
8
|
-
if (!el)
|
|
9
|
-
return;
|
|
10
|
-
// Avoid resetting srcObject if the exact same MediaStream instance is already attached.
|
|
11
|
-
if (stream && prevStream.current !== stream) {
|
|
12
|
-
el.srcObject = stream;
|
|
13
|
-
prevStream.current = stream;
|
|
14
|
-
}
|
|
15
|
-
// Kick playback on mobile where autoplay can be flaky even when muted.
|
|
16
|
-
if (stream) {
|
|
17
|
-
el.play().catch(() => {
|
|
18
|
-
/* ignore autoplay rejection; user gesture will resume */
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return () => {
|
|
22
|
-
if (el) {
|
|
23
|
-
el.srcObject = null;
|
|
24
|
-
prevStream.current = null;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}, [stream]);
|
|
28
|
-
return (_jsx("video", { ref: ref, autoPlay: autoPlay, playsInline: playsInline, muted: muted ?? stream == null, ...props }));
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=VideoPlayer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["../../src/components/VideoPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAM1C,MAAM,UAAU,WAAW,CAAC,EAC1B,MAAM,EACN,QAAQ,GAAG,IAAI,EACf,WAAW,GAAG,IAAI,EAClB,KAAK,EACL,GAAG,KAAK,EACS;IACjB,MAAM,GAAG,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE;YAAE,OAAO;QAEhB,wFAAwF;QACxF,IAAI,MAAM,IAAI,UAAU,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC5C,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC;YACtB,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;QAC9B,CAAC;QAED,uEAAuE;QACvE,IAAI,MAAM,EAAE,CAAC;YACX,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnB,yDAAyD;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,EAAE,CAAC;gBACP,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC;gBACpB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,IAAI,MAAM,IAAI,IAAI,KAC1B,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type FeatureConfig = {
|
|
2
|
-
enableDataChannel?: boolean;
|
|
3
|
-
enableScreenShare?: boolean;
|
|
4
|
-
enableWaitingRoom?: boolean;
|
|
5
|
-
enableHostControls?: boolean;
|
|
6
|
-
enableActiveSpeaker?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare const defaultFeatures: Required<FeatureConfig>;
|
|
9
|
-
export declare function mergeFeatures(features?: FeatureConfig): Required<FeatureConfig>;
|
|
10
|
-
//# sourceMappingURL=features.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/config/features.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,aAAa,CAMnD,CAAC;AAEF,wBAAgB,aAAa,CAC3B,QAAQ,CAAC,EAAE,aAAa,GACvB,QAAQ,CAAC,aAAa,CAAC,CAEzB"}
|
package/dist/config/features.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const defaultFeatures = {
|
|
2
|
-
enableDataChannel: true,
|
|
3
|
-
enableScreenShare: true,
|
|
4
|
-
enableWaitingRoom: false,
|
|
5
|
-
enableHostControls: false,
|
|
6
|
-
enableActiveSpeaker: false,
|
|
7
|
-
};
|
|
8
|
-
export function mergeFeatures(features) {
|
|
9
|
-
return { ...defaultFeatures, ...(features ?? {}) };
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=features.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/config/features.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,eAAe,GAA4B;IACtD,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;IACzB,mBAAmB,EAAE,KAAK;CAC3B,CAAC;AAEF,MAAM,UAAU,aAAa,CAC3B,QAAwB;IAExB,OAAO,EAAE,GAAG,eAAe,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SignalData } from "@conference-kit/core";
|
|
2
|
-
export type WebRTCContextValue = {
|
|
3
|
-
onSignal?: (data: SignalData) => void;
|
|
4
|
-
config?: RTCConfiguration;
|
|
5
|
-
trickle?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type WebRTCProviderProps = WebRTCContextValue & {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
};
|
|
10
|
-
export declare function WebRTCProvider({ children, onSignal, config, trickle, }: WebRTCProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare function useWebRTCContext(): WebRTCContextValue;
|
|
12
|
-
//# sourceMappingURL=WebRTCProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebRTCProvider.d.ts","sourceRoot":"","sources":["../../src/context/WebRTCProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAIF,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,GACR,EAAE,mBAAmB,2CAMrB;AAED,wBAAgB,gBAAgB,uBAK/B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const WebRTCContext = createContext(undefined);
|
|
4
|
-
export function WebRTCProvider({ children, onSignal, config, trickle, }) {
|
|
5
|
-
return (_jsx(WebRTCContext.Provider, { value: { onSignal, config, trickle }, children: children }));
|
|
6
|
-
}
|
|
7
|
-
export function useWebRTCContext() {
|
|
8
|
-
const value = useContext(WebRTCContext);
|
|
9
|
-
if (!value)
|
|
10
|
-
throw new Error("useWebRTCContext must be used within a WebRTCProvider");
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=WebRTCProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebRTCProvider.js","sourceRoot":"","sources":["../../src/context/WebRTCProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AASlD,MAAM,aAAa,GAAG,aAAa,CAAiC,SAAS,CAAC,CAAC;AAM/E,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,GACa;IACpB,OAAO,CACL,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YACzD,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/hooks/useCall.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type CallState = "idle" | "calling" | "ringing" | "connected" | "ended";
|
|
2
|
-
type UseCallOptions = {
|
|
3
|
-
peerId: string;
|
|
4
|
-
signalingUrl: string;
|
|
5
|
-
room?: string | null;
|
|
6
|
-
autoReconnect?: boolean;
|
|
7
|
-
mediaConstraints?: MediaStreamConstraints;
|
|
8
|
-
rtcConfig?: RTCConfiguration;
|
|
9
|
-
trickle?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type ReturnTypeUseCall = ReturnType<typeof useCall>;
|
|
12
|
-
export declare function useCall(options: UseCallOptions): {
|
|
13
|
-
readonly peer: import("@conference-kit/core").Peer | null;
|
|
14
|
-
readonly callState: CallState;
|
|
15
|
-
readonly connectionState: RTCPeerConnectionState;
|
|
16
|
-
readonly iceState: RTCIceConnectionState;
|
|
17
|
-
readonly localStream: MediaStream | null;
|
|
18
|
-
readonly remoteStream: MediaStream | null;
|
|
19
|
-
readonly ready: boolean;
|
|
20
|
-
readonly requesting: boolean;
|
|
21
|
-
readonly error: Error | null;
|
|
22
|
-
readonly call: (to: string) => Promise<void>;
|
|
23
|
-
readonly answer: () => Promise<void>;
|
|
24
|
-
readonly hangUp: () => void;
|
|
25
|
-
readonly reset: () => void;
|
|
26
|
-
readonly muteAudio: (muted: boolean) => void;
|
|
27
|
-
readonly muteVideo: (muted: boolean) => void;
|
|
28
|
-
readonly sendData: (payload: string | ArrayBufferView | ArrayBuffer | Blob) => void;
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=useCall.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCall.d.ts","sourceRoot":"","sources":["../../src/hooks/useCall.ts"],"names":[],"mappings":"AAMA,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAExE,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAE3D,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc;;;;;;;;;;wBA2HhC,MAAM;;;;gCA8CT,OAAO;gCASP,OAAO;iCA2BH,MAAM,GAAG,eAAe,GAAG,WAAW,GAAG,IAAI;EAW5D"}
|
package/dist/hooks/useCall.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { useMediaStream } from "./useMediaStream";
|
|
3
|
-
import { useWebRTC } from "./useWebRTC";
|
|
4
|
-
import { SignalingClient } from "../signaling/SignalingClient";
|
|
5
|
-
export function useCall(options) {
|
|
6
|
-
const { peerId, signalingUrl, room, autoReconnect = true, mediaConstraints, rtcConfig, trickle, } = options;
|
|
7
|
-
const { stream: localStream, ready, requesting, error: mediaError, requestStream, stopStream, } = useMediaStream({ constraints: mediaConstraints });
|
|
8
|
-
const [callState, setCallState] = useState("idle");
|
|
9
|
-
const [targetId, setTargetId] = useState(null);
|
|
10
|
-
const [side, setSide] = useState("initiator");
|
|
11
|
-
const [callError, setCallError] = useState(null);
|
|
12
|
-
const pendingSignals = useRef([]);
|
|
13
|
-
const pendingOutbound = useRef([]);
|
|
14
|
-
const shouldEnablePeer = targetId !== null || callState !== "idle";
|
|
15
|
-
const signaling = useMemo(() => new SignalingClient({
|
|
16
|
-
url: signalingUrl,
|
|
17
|
-
peerId,
|
|
18
|
-
room,
|
|
19
|
-
autoReconnect,
|
|
20
|
-
}), [autoReconnect, peerId, room, signalingUrl]);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
signaling.connect();
|
|
23
|
-
return () => signaling.close();
|
|
24
|
-
}, [signaling]);
|
|
25
|
-
const { peer, remoteStream, connectionState, iceState, error: webrtcError, signal, sendData, destroy, } = useWebRTC({
|
|
26
|
-
side,
|
|
27
|
-
stream: localStream ?? undefined,
|
|
28
|
-
config: rtcConfig,
|
|
29
|
-
trickle,
|
|
30
|
-
enabled: shouldEnablePeer,
|
|
31
|
-
onSignal: (data) => {
|
|
32
|
-
if (!targetId) {
|
|
33
|
-
pendingOutbound.current.push(data);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
signaling.sendSignal(targetId, data);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!webrtcError)
|
|
41
|
-
return;
|
|
42
|
-
destroy();
|
|
43
|
-
setCallState("idle");
|
|
44
|
-
setTargetId(null);
|
|
45
|
-
pendingSignals.current = [];
|
|
46
|
-
pendingOutbound.current = [];
|
|
47
|
-
stopStream();
|
|
48
|
-
}, [destroy, stopStream, webrtcError]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (!targetId)
|
|
51
|
-
return;
|
|
52
|
-
if (!pendingOutbound.current.length)
|
|
53
|
-
return;
|
|
54
|
-
for (const msg of pendingOutbound.current) {
|
|
55
|
-
signaling.sendSignal(targetId, msg);
|
|
56
|
-
}
|
|
57
|
-
pendingOutbound.current = [];
|
|
58
|
-
}, [signaling, targetId]);
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (!peer)
|
|
61
|
-
return;
|
|
62
|
-
if (pendingSignals.current.length === 0)
|
|
63
|
-
return;
|
|
64
|
-
for (const msg of pendingSignals.current) {
|
|
65
|
-
void signal(msg);
|
|
66
|
-
}
|
|
67
|
-
pendingSignals.current = [];
|
|
68
|
-
}, [peer, signal]);
|
|
69
|
-
const handleIncoming = useCallback(({ from, data }) => {
|
|
70
|
-
setTargetId((prev) => prev ?? from);
|
|
71
|
-
if (callState === "idle")
|
|
72
|
-
setCallState("ringing");
|
|
73
|
-
if (callState === "ended")
|
|
74
|
-
setCallState("ringing");
|
|
75
|
-
// If peer not ready yet, queue and ensure responder side
|
|
76
|
-
if (!peer) {
|
|
77
|
-
pendingSignals.current.push(data);
|
|
78
|
-
setSide("responder");
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
void signal(data);
|
|
82
|
-
}, [callState, peer, signal]);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
const onSignal = ({ from, data }) => handleIncoming({ from, data: data });
|
|
85
|
-
signaling.on("signal", onSignal);
|
|
86
|
-
return () => signaling.off("signal", onSignal);
|
|
87
|
-
}, [handleIncoming, signaling]);
|
|
88
|
-
const call = useCallback(async (to) => {
|
|
89
|
-
setTargetId(to);
|
|
90
|
-
setSide("initiator");
|
|
91
|
-
setCallState("calling");
|
|
92
|
-
try {
|
|
93
|
-
if (!ready && !requesting) {
|
|
94
|
-
await requestStream();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
setCallError(error);
|
|
99
|
-
}
|
|
100
|
-
}, [ready, requesting, requestStream]);
|
|
101
|
-
const answer = useCallback(async () => {
|
|
102
|
-
setSide("responder");
|
|
103
|
-
setCallState("connected");
|
|
104
|
-
try {
|
|
105
|
-
if (!ready && !requesting) {
|
|
106
|
-
await requestStream();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
setCallError(error);
|
|
111
|
-
}
|
|
112
|
-
}, [ready, requesting, requestStream]);
|
|
113
|
-
const hangUp = useCallback(() => {
|
|
114
|
-
destroy();
|
|
115
|
-
setCallState("idle");
|
|
116
|
-
setTargetId(null);
|
|
117
|
-
stopStream();
|
|
118
|
-
}, [destroy, stopStream]);
|
|
119
|
-
const reset = useCallback(() => {
|
|
120
|
-
destroy();
|
|
121
|
-
pendingSignals.current = [];
|
|
122
|
-
pendingOutbound.current = [];
|
|
123
|
-
setCallState("idle");
|
|
124
|
-
setTargetId(null);
|
|
125
|
-
setSide("initiator");
|
|
126
|
-
setCallError(null);
|
|
127
|
-
stopStream();
|
|
128
|
-
}, [destroy, stopStream]);
|
|
129
|
-
const muteAudio = useCallback((muted) => {
|
|
130
|
-
localStream?.getAudioTracks().forEach((track) => {
|
|
131
|
-
track.enabled = !muted;
|
|
132
|
-
});
|
|
133
|
-
}, [localStream]);
|
|
134
|
-
const muteVideo = useCallback((muted) => {
|
|
135
|
-
localStream?.getVideoTracks().forEach((track) => {
|
|
136
|
-
track.enabled = !muted;
|
|
137
|
-
});
|
|
138
|
-
}, [localStream]);
|
|
139
|
-
const currentError = callError ?? webrtcError ?? mediaError ?? null;
|
|
140
|
-
return {
|
|
141
|
-
peer,
|
|
142
|
-
callState,
|
|
143
|
-
connectionState,
|
|
144
|
-
iceState,
|
|
145
|
-
localStream,
|
|
146
|
-
remoteStream,
|
|
147
|
-
ready,
|
|
148
|
-
requesting,
|
|
149
|
-
error: currentError,
|
|
150
|
-
call,
|
|
151
|
-
answer,
|
|
152
|
-
hangUp,
|
|
153
|
-
reset,
|
|
154
|
-
muteAudio,
|
|
155
|
-
muteVideo,
|
|
156
|
-
sendData: useCallback((payload) => {
|
|
157
|
-
try {
|
|
158
|
-
if (!peer)
|
|
159
|
-
return;
|
|
160
|
-
peer.send(payload);
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
setCallError(error);
|
|
164
|
-
}
|
|
165
|
-
}, [peer]),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingURL=useCall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCall.js","sourceRoot":"","sources":["../../src/hooks/useCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAkB/D,MAAM,UAAU,OAAO,CAAC,OAAuB;IAC7C,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,aAAa,GAAG,IAAI,EACpB,gBAAgB,EAChB,SAAS,EACT,OAAO,GACR,GAAG,OAAO,CAAC;IAEZ,MAAM,EACJ,MAAM,EAAE,WAAW,EACnB,KAAK,EACL,UAAU,EACV,KAAK,EAAE,UAAU,EACjB,aAAa,EACb,UAAU,GACX,GAAG,cAAc,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEtD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY,MAAM,CAAC,CAAC;IAC9D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAW,WAAW,CAAC,CAAC;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,MAAM,CAAe,EAAE,CAAC,CAAC;IAChD,MAAM,eAAe,GAAG,MAAM,CAAe,EAAE,CA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AAC;IACL,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,MAAM,YAAY,GAAG,SAAS,IAAI,WAAW,IAAI,UAAU,IAAI,IAAI,CAAC;IAEpE,OAAO;QACL,IAAI;QACJ,SAAS;QACT,eAAe;QACf,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,KAAK;QACL,UAAU;QACV,KAAK,EAAE,YAAY;QACnB,IAAI;QACJ,MAAM;QACN,MAAM;QACN,KAAK;QACL,SAAS;QACT,SAAS;QACT,QAAQ,EAAE,WAAW,CACnB,CAAC,OAAsD,EAAE,EAAE;YACzD,IAAI,CAAC;gBACH,IAAI,CAAC,IAAI;oBAAE,OAAO;gBAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,YAAY,CAAC,KAAc,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,EACD,CAAC,IAAI,CAAC,CACP;KACO,CAAC;AACb,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ReturnTypeUseCall } from "./useCall";
|
|
2
|
-
type UseCallStateOptions = {
|
|
3
|
-
hasTarget?: boolean;
|
|
4
|
-
};
|
|
5
|
-
type CallStateView = {
|
|
6
|
-
callLabel: string;
|
|
7
|
-
connLabel: string;
|
|
8
|
-
iceLabel: string;
|
|
9
|
-
canCall: boolean;
|
|
10
|
-
canAnswer: boolean;
|
|
11
|
-
canHangUp: boolean;
|
|
12
|
-
canReset: boolean;
|
|
13
|
-
inCall: boolean;
|
|
14
|
-
errorMessage: string | null;
|
|
15
|
-
};
|
|
16
|
-
export declare function useCallState(call: ReturnTypeUseCall, options?: UseCallStateOptions): CallStateView;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=useCallState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCallState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCallState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,KAAK,mBAAmB,GAAG;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,mBAAwB,GAChC,aAAa,CAgCf"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
export function useCallState(call, options = {}) {
|
|
3
|
-
const hasTarget = options.hasTarget ?? false;
|
|
4
|
-
return useMemo(() => {
|
|
5
|
-
const callLabel = call.callState;
|
|
6
|
-
const connLabel = call.connectionState;
|
|
7
|
-
const iceLabel = call.iceState;
|
|
8
|
-
const canCall = hasTarget && call.callState === "idle";
|
|
9
|
-
const canAnswer = call.callState === "ringing";
|
|
10
|
-
const canHangUp = call.callState !== "idle";
|
|
11
|
-
const canReset = true;
|
|
12
|
-
const inCall = call.callState === "connected";
|
|
13
|
-
const errorMessage = call.error?.message ?? null;
|
|
14
|
-
return {
|
|
15
|
-
callLabel,
|
|
16
|
-
connLabel,
|
|
17
|
-
iceLabel,
|
|
18
|
-
canCall,
|
|
19
|
-
canAnswer,
|
|
20
|
-
canHangUp,
|
|
21
|
-
canReset,
|
|
22
|
-
inCall,
|
|
23
|
-
errorMessage,
|
|
24
|
-
};
|
|
25
|
-
}, [
|
|
26
|
-
call.callState,
|
|
27
|
-
call.connectionState,
|
|
28
|
-
call.error,
|
|
29
|
-
call.iceState,
|
|
30
|
-
hasTarget,
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=useCallState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCallState.js","sourceRoot":"","sources":["../../src/hooks/useCallState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAmBhC,MAAM,UAAU,YAAY,CAC1B,IAAuB,EACvB,UAA+B,EAAE;IAEjC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAE7C,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,OAAO,GAAG,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC;QACvD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC;QAEjD,OAAO;YACL,SAAS;YACT,SAAS;YACT,QAAQ;YACR,OAAO;YACP,SAAS;YACT,SAAS;YACT,QAAQ;YACR,MAAM;YACN,YAAY;SACb,CAAC;IACJ,CAAC,EAAE;QACD,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,eAAe;QACpB,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,QAAQ;QACb,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Peer } from "@conference-kit/core";
|
|
2
|
-
export type UseDataChannelState = {
|
|
3
|
-
ready: boolean;
|
|
4
|
-
lastMessage: unknown;
|
|
5
|
-
error: Error | null;
|
|
6
|
-
};
|
|
7
|
-
export declare function useDataChannel(peer: Peer | null): {
|
|
8
|
-
readonly send: (payload: string | ArrayBufferView | ArrayBuffer | Blob) => void;
|
|
9
|
-
readonly ready: boolean;
|
|
10
|
-
readonly lastMessage: unknown;
|
|
11
|
-
readonly error: Error | null;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=useDataChannel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDataChannel.d.ts","sourceRoot":"","sources":["../../src/hooks/useDataChannel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;6BA+BlC,MAAM,GAAG,eAAe,GAAG,WAAW,GAAG,IAAI;oBApClD,OAAO;0BACD,OAAO;oBACb,KAAK,GAAG,IAAI;EA0CpB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
export function useDataChannel(peer) {
|
|
3
|
-
const [state, setState] = useState({
|
|
4
|
-
ready: false,
|
|
5
|
-
lastMessage: null,
|
|
6
|
-
error: null,
|
|
7
|
-
});
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (!peer)
|
|
10
|
-
return;
|
|
11
|
-
const handleConnect = () => setState((prev) => ({ ...prev, ready: true }));
|
|
12
|
-
const handleData = (data) => setState((prev) => ({ ...prev, lastMessage: data }));
|
|
13
|
-
const handleError = (error) => setState((prev) => ({ ...prev, error }));
|
|
14
|
-
const handleClose = () => setState((prev) => ({ ...prev, ready: false }));
|
|
15
|
-
peer.on("connect", handleConnect);
|
|
16
|
-
peer.on("data", handleData);
|
|
17
|
-
peer.on("error", handleError);
|
|
18
|
-
peer.on("close", handleClose);
|
|
19
|
-
return () => {
|
|
20
|
-
peer.off("connect", handleConnect);
|
|
21
|
-
peer.off("data", handleData);
|
|
22
|
-
peer.off("error", handleError);
|
|
23
|
-
peer.off("close", handleClose);
|
|
24
|
-
};
|
|
25
|
-
}, [peer]);
|
|
26
|
-
const send = useCallback((payload) => {
|
|
27
|
-
if (!peer)
|
|
28
|
-
throw new Error("Peer not ready");
|
|
29
|
-
peer.send(payload);
|
|
30
|
-
}, [peer]);
|
|
31
|
-
return { ...state, send };
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=useDataChannel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDataChannel.js","sourceRoot":"","sources":["../../src/hooks/useDataChannel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASzD,MAAM,UAAU,cAAc,CAAC,IAAiB;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB;QACtD,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3E,MAAM,UAAU,GAAG,CAAC,IAAa,EAAE,EAAE,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AC,CACP,CAAC;IAEF,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAW,CAAC;AACrC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Peer } from "@conference-kit/core";
|
|
2
|
-
type Options = {
|
|
3
|
-
limit?: number;
|
|
4
|
-
};
|
|
5
|
-
type MessageEntry = {
|
|
6
|
-
id: string;
|
|
7
|
-
direction: "in" | "out";
|
|
8
|
-
payload: unknown;
|
|
9
|
-
};
|
|
10
|
-
export declare function useDataChannelMessages(peer: Peer | null, options?: Options): {
|
|
11
|
-
ready: boolean;
|
|
12
|
-
error: Error | null;
|
|
13
|
-
messages: MessageEntry[];
|
|
14
|
-
sendMessage: (payload: string | ArrayBufferView | ArrayBuffer | Blob) => void;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=useDataChannelMessages.d.ts.map
|