@fishjam-cloud/react-client 0.23.0 → 0.25.0-rc.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/dist/FishjamProvider.d.ts +4 -0
- package/dist/FishjamProvider.d.ts.map +1 -1
- package/dist/FishjamProvider.js +8 -2
- package/dist/hooks/devices/useCamera.d.ts +8 -0
- package/dist/hooks/devices/useCamera.d.ts.map +1 -1
- package/dist/hooks/devices/useCamera.js +8 -0
- package/dist/hooks/devices/useMicrophone.d.ts +4 -0
- package/dist/hooks/devices/useMicrophone.d.ts.map +1 -1
- package/dist/hooks/devices/useMicrophone.js +4 -0
- package/dist/hooks/internal/devices/useDeviceManager.d.ts +3 -1
- package/dist/hooks/internal/devices/useDeviceManager.d.ts.map +1 -1
- package/dist/hooks/internal/devices/useDeviceManager.js +3 -2
- package/dist/hooks/internal/devices/useMediaDevices.d.ts +3 -1
- package/dist/hooks/internal/devices/useMediaDevices.d.ts.map +1 -1
- package/dist/hooks/internal/devices/useMediaDevices.js +3 -1
- package/dist/hooks/internal/useCustomSourceManager.d.ts +3 -2
- package/dist/hooks/internal/useCustomSourceManager.d.ts.map +1 -1
- package/dist/hooks/internal/useCustomSourceManager.js +5 -5
- package/dist/hooks/internal/useScreenshareManager.d.ts +3 -2
- package/dist/hooks/internal/useScreenshareManager.d.ts.map +1 -1
- package/dist/hooks/internal/useScreenshareManager.js +27 -9
- package/dist/hooks/internal/useTrackManager.d.ts +3 -2
- package/dist/hooks/internal/useTrackManager.d.ts.map +1 -1
- package/dist/hooks/internal/useTrackManager.js +7 -5
- package/dist/hooks/useLivestreamStreamer.d.ts +1 -1
- package/dist/hooks/useLivestreamStreamer.d.ts.map +1 -1
- package/dist/hooks/useLivestreamStreamer.js +5 -3
- package/dist/hooks/useLivestreamViewer.d.ts.map +1 -1
- package/dist/hooks/useLivestreamViewer.js +11 -6
- package/dist/hooks/useScreenShare.d.ts.map +1 -1
- package/dist/hooks/useVAD.d.ts +4 -3
- package/dist/hooks/useVAD.d.ts.map +1 -1
- package/dist/hooks/useVAD.js +5 -3
- package/dist/types/internal.d.ts +2 -0
- package/dist/types/internal.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +2 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +2 -2
- package/dist/utils/fishjamUrl.d.ts +6 -0
- package/dist/utils/fishjamUrl.d.ts.map +1 -1
- package/dist/utils/fishjamUrl.js +22 -0
- package/package.json +16 -5
|
@@ -37,6 +37,10 @@ export interface FishjamProviderProps extends PropsWithChildren {
|
|
|
37
37
|
* You can get you Fishjam ID at https://fishjam.io/app
|
|
38
38
|
*/
|
|
39
39
|
fishjamId: string;
|
|
40
|
+
/**
|
|
41
|
+
* Enables Fishjam SDK's debug logs in the console.
|
|
42
|
+
*/
|
|
43
|
+
debug?: boolean;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Provides the Fishjam Context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FishjamProvider.d.ts","sourceRoot":"","sources":["../src/FishjamProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FishjamProvider.d.ts","sourceRoot":"","sources":["../src/FishjamProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAkBhE,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI/F;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACtC;;;;OAIG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;IAC9D;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC;IACxD;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAwF1D"}
|
package/dist/FishjamProvider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { FishjamClient } from "@fishjam-cloud/ts-client";
|
|
2
|
+
import { FishjamClient, getLogger } from "@fishjam-cloud/ts-client";
|
|
3
3
|
import { useMemo, useRef } from "react";
|
|
4
4
|
import { CameraContext } from "./contexts/camera";
|
|
5
5
|
import { CustomSourceContext } from "./contexts/customSource";
|
|
@@ -24,7 +24,7 @@ import { getLastDevice, saveLastDevice } from "./utils/localStorage";
|
|
|
24
24
|
* @category Components
|
|
25
25
|
*/
|
|
26
26
|
export function FishjamProvider(props) {
|
|
27
|
-
const fishjamClientRef = useRef(new FishjamClient({ reconnect: props.reconnect }));
|
|
27
|
+
const fishjamClientRef = useRef(new FishjamClient({ reconnect: props.reconnect, debug: props.debug }));
|
|
28
28
|
const persistHandlers = useMemo(() => {
|
|
29
29
|
if (props.persistLastDevice === false)
|
|
30
30
|
return undefined;
|
|
@@ -32,10 +32,12 @@ export function FishjamProvider(props) {
|
|
|
32
32
|
return props.persistLastDevice;
|
|
33
33
|
return { getLastDevice, saveLastDevice };
|
|
34
34
|
}, [props.persistLastDevice]);
|
|
35
|
+
const logger = getLogger(props.debug ?? false);
|
|
35
36
|
const { cameraManager, microphoneManager, initializeDevices } = useMediaDevices({
|
|
36
37
|
videoConstraints: props.constraints?.video ?? VIDEO_TRACK_CONSTRAINTS,
|
|
37
38
|
audioConstraints: props.constraints?.audio ?? true,
|
|
38
39
|
persistHandlers,
|
|
40
|
+
logger,
|
|
39
41
|
});
|
|
40
42
|
const peerStatus = usePeerStatus(fishjamClientRef.current);
|
|
41
43
|
const mergedBandwidthLimits = useMemo(() => mergeWithDefaultBandwitdthLimits(props.bandwidthLimits), [props.bandwidthLimits]);
|
|
@@ -46,6 +48,7 @@ export function FishjamProvider(props) {
|
|
|
46
48
|
bandwidthLimits: mergedBandwidthLimits,
|
|
47
49
|
streamConfig: props.videoConfig,
|
|
48
50
|
type: "camera",
|
|
51
|
+
logger,
|
|
49
52
|
});
|
|
50
53
|
const audioTrackManager = useTrackManager({
|
|
51
54
|
tsClient: fishjamClientRef.current,
|
|
@@ -54,16 +57,19 @@ export function FishjamProvider(props) {
|
|
|
54
57
|
bandwidthLimits: mergedBandwidthLimits,
|
|
55
58
|
streamConfig: props.audioConfig,
|
|
56
59
|
type: "microphone",
|
|
60
|
+
logger,
|
|
57
61
|
});
|
|
58
62
|
const screenShareManager = useScreenShareManager({
|
|
59
63
|
fishjamClient: fishjamClientRef.current,
|
|
60
64
|
peerStatus,
|
|
65
|
+
logger,
|
|
61
66
|
});
|
|
62
67
|
const cameraContext = useMemo(() => ({ videoTrackManager, cameraManager }), [videoTrackManager, cameraManager]);
|
|
63
68
|
const microphoneContext = useMemo(() => ({ audioTrackManager, microphoneManager }), [audioTrackManager, microphoneManager]);
|
|
64
69
|
const customSourceManager = useCustomSourceManager({
|
|
65
70
|
fishjamClient: fishjamClientRef.current,
|
|
66
71
|
peerStatus,
|
|
72
|
+
logger,
|
|
67
73
|
});
|
|
68
74
|
const fishjamClientState = useFishjamClientState(fishjamClientRef.current);
|
|
69
75
|
return (_jsx(FishjamClientContext.Provider, { value: fishjamClientRef, children: _jsx(FishjamClientStateContext.Provider, { value: fishjamClientState, children: _jsx(FishjamIdContext.Provider, { value: props.fishjamId, children: _jsx(InitDevicesContext.Provider, { value: initializeDevices, children: _jsx(PeerStatusContext.Provider, { value: peerStatus, children: _jsx(CameraContext.Provider, { value: cameraContext, children: _jsx(MicrophoneContext.Provider, { value: microphoneContext, children: _jsx(ScreenshareContext.Provider, { value: screenShareManager, children: _jsx(CustomSourceContext.Provider, { value: customSourceManager, children: props.children }) }) }) }) }) }) }) }) }));
|
|
@@ -7,6 +7,14 @@ export declare function useCamera(): {
|
|
|
7
7
|
* Toggles current camera on/off
|
|
8
8
|
*/
|
|
9
9
|
toggleCamera: () => Promise<undefined | import("../..").DeviceError>;
|
|
10
|
+
/**
|
|
11
|
+
* Stops the camera
|
|
12
|
+
*/
|
|
13
|
+
stopCamera: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Starts the camera
|
|
16
|
+
*/
|
|
17
|
+
startCamera: (deviceId?: string | null) => Promise<[MediaStreamTrack, null] | [null, import("../..").DeviceError]>;
|
|
10
18
|
/**
|
|
11
19
|
* Selects the camera device
|
|
12
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../../src/hooks/devices/useCamera.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,SAAS;IAarB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAGN"}
|
|
1
|
+
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../../src/hooks/devices/useCamera.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,SAAS;IAarB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAGN"}
|
|
@@ -20,6 +20,14 @@ export function useCamera() {
|
|
|
20
20
|
* Toggles current camera on/off
|
|
21
21
|
*/
|
|
22
22
|
toggleCamera: videoTrackManager.toggleDevice,
|
|
23
|
+
/**
|
|
24
|
+
* Stops the camera
|
|
25
|
+
*/
|
|
26
|
+
stopCamera: videoTrackManager.stopDevice,
|
|
27
|
+
/**
|
|
28
|
+
* Starts the camera
|
|
29
|
+
*/
|
|
30
|
+
startCamera: videoTrackManager.startDevice,
|
|
23
31
|
/**
|
|
24
32
|
* Selects the camera device
|
|
25
33
|
*/
|
|
@@ -7,6 +7,10 @@ export declare function useMicrophone(): {
|
|
|
7
7
|
toggleMicrophone: () => Promise<undefined | import("../..").DeviceError>;
|
|
8
8
|
/** Mutes/unmutes the microphone */
|
|
9
9
|
toggleMicrophoneMute: () => Promise<void>;
|
|
10
|
+
/** Stops the microphone */
|
|
11
|
+
stopMicrophone: () => void;
|
|
12
|
+
/** Starts the microphone */
|
|
13
|
+
startMicrophone: (deviceId?: string | null) => Promise<[MediaStreamTrack, null] | [null, import("../..").DeviceError]>;
|
|
10
14
|
/** Selects the microphone device */
|
|
11
15
|
selectMicrophone: (deviceId: string) => Promise<undefined | import("../..").DeviceError>;
|
|
12
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMicrophone.d.ts","sourceRoot":"","sources":["../../../src/hooks/devices/useMicrophone.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,aAAa;IAazB,wCAAwC;;IAExC,mCAAmC;;IAEnC,oCAAoC;;IAEpC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAGN"}
|
|
1
|
+
{"version":3,"file":"useMicrophone.d.ts","sourceRoot":"","sources":["../../../src/hooks/devices/useMicrophone.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,aAAa;IAazB,wCAAwC;;IAExC,mCAAmC;;IAEnC,2BAA2B;;IAE3B,4BAA4B;;IAE5B,oCAAoC;;IAEpC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAGN"}
|
|
@@ -20,6 +20,10 @@ export function useMicrophone() {
|
|
|
20
20
|
toggleMicrophone: audioTrackManager.toggleDevice,
|
|
21
21
|
/** Mutes/unmutes the microphone */
|
|
22
22
|
toggleMicrophoneMute: audioTrackManager.toggleMute,
|
|
23
|
+
/** Stops the microphone */
|
|
24
|
+
stopMicrophone: audioTrackManager.stopDevice,
|
|
25
|
+
/** Starts the microphone */
|
|
26
|
+
startMicrophone: audioTrackManager.startDevice,
|
|
23
27
|
/** Selects the microphone device */
|
|
24
28
|
selectMicrophone: audioTrackManager.selectDevice,
|
|
25
29
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Logger } from "@fishjam-cloud/ts-client";
|
|
1
2
|
import type { SetStateAction } from "react";
|
|
2
3
|
import type { DeviceError, DeviceItem, TrackMiddleware } from "../../../types/public";
|
|
3
4
|
type DeviceManagerProps = {
|
|
@@ -11,6 +12,7 @@ type DeviceManagerProps = {
|
|
|
11
12
|
constraints?: MediaTrackConstraints | boolean;
|
|
12
13
|
setSelectedDevice: (device: MediaDeviceInfo) => void;
|
|
13
14
|
selectedDevice: MediaDeviceInfo | null;
|
|
15
|
+
logger: Logger;
|
|
14
16
|
};
|
|
15
17
|
export type DeviceManager = {
|
|
16
18
|
startDevice: (deviceId?: string | null) => Promise<[MediaStreamTrack, null] | [null, DeviceError]>;
|
|
@@ -27,6 +29,6 @@ export type DeviceManager = {
|
|
|
27
29
|
deviceError: DeviceError | null;
|
|
28
30
|
selectedDevice: MediaDeviceInfo | null;
|
|
29
31
|
};
|
|
30
|
-
export declare const useDeviceManager: ({ mediaStream, setMediaStream, getInitialStream, deviceType, constraints, allDevicesList, setSelectedDevice, deviceError, setDeviceError, selectedDevice, }: DeviceManagerProps) => DeviceManager;
|
|
32
|
+
export declare const useDeviceManager: ({ mediaStream, setMediaStream, getInitialStream, deviceType, constraints, allDevicesList, setSelectedDevice, deviceError, setDeviceError, selectedDevice, logger, }: DeviceManagerProps) => DeviceManager;
|
|
31
33
|
export {};
|
|
32
34
|
//# sourceMappingURL=useDeviceManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeviceManager.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/devices/useDeviceManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAMtF,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpD,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC;IAC9C,iBAAiB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"useDeviceManager.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/devices/useDeviceManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAMtF,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpD,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC;IAC9C,iBAAiB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IACnG,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC;IACxG,YAAY,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,iBAAiB,EAAE,eAAe,CAAC;IACnC,eAAe,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACnF,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;CACxC,CAAC;AAsCF,eAAO,MAAM,gBAAgB,GAAI,qKAY9B,kBAAkB,KAAG,aAiIvB,CAAC"}
|
|
@@ -29,7 +29,7 @@ async function getDeviceStream(type, constraints, deviceId) {
|
|
|
29
29
|
});
|
|
30
30
|
return stream;
|
|
31
31
|
}
|
|
32
|
-
export const useDeviceManager = ({ mediaStream, setMediaStream, getInitialStream, deviceType, constraints, allDevicesList, setSelectedDevice, deviceError, setDeviceError, selectedDevice, }) => {
|
|
32
|
+
export const useDeviceManager = ({ mediaStream, setMediaStream, getInitialStream, deviceType, constraints, allDevicesList, setSelectedDevice, deviceError, setDeviceError, selectedDevice, logger, }) => {
|
|
33
33
|
const rawTrack = useMemo(() => mediaStream && getTrackFromStream(mediaStream, deviceType), [mediaStream, deviceType]);
|
|
34
34
|
const clearStream = useCallback(() => {
|
|
35
35
|
setMediaStream(null);
|
|
@@ -73,7 +73,7 @@ export const useDeviceManager = ({ mediaStream, setMediaStream, getInitialStream
|
|
|
73
73
|
return [retrievedTrack, null];
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
const parsedError = parseUserMediaError(err);
|
|
76
|
+
const parsedError = parseUserMediaError(err, logger);
|
|
77
77
|
setDeviceError(parsedError);
|
|
78
78
|
return [null, parsedError];
|
|
79
79
|
}
|
|
@@ -85,6 +85,7 @@ export const useDeviceManager = ({ mediaStream, setMediaStream, getInitialStream
|
|
|
85
85
|
setMediaStream,
|
|
86
86
|
deviceEnabled,
|
|
87
87
|
setSelectedDeviceId,
|
|
88
|
+
logger,
|
|
88
89
|
setDeviceError,
|
|
89
90
|
]);
|
|
90
91
|
const selectDevice = useCallback((deviceId) => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import type { Logger } from "@fishjam-cloud/ts-client";
|
|
1
2
|
import type { InitializeDevicesResult, PersistLastDeviceHandlers } from "../../../types/public";
|
|
2
3
|
interface UseDevicesProps {
|
|
3
4
|
videoConstraints?: MediaTrackConstraints | boolean;
|
|
4
5
|
audioConstraints?: MediaTrackConstraints | boolean;
|
|
5
6
|
persistHandlers?: PersistLastDeviceHandlers;
|
|
7
|
+
logger: Logger;
|
|
6
8
|
}
|
|
7
9
|
export type InitializeDevicesSettings = {
|
|
8
10
|
enableVideo?: boolean;
|
|
9
11
|
enableAudio?: boolean;
|
|
10
12
|
};
|
|
11
|
-
export declare const useMediaDevices: ({ videoConstraints, audioConstraints, persistHandlers }: UseDevicesProps) => {
|
|
13
|
+
export declare const useMediaDevices: ({ videoConstraints, audioConstraints, persistHandlers, logger }: UseDevicesProps) => {
|
|
12
14
|
initializeDevices: (settings?: InitializeDevicesSettings) => Promise<InitializeDevicesResult>;
|
|
13
15
|
cameraManager: import("./useDeviceManager").DeviceManager;
|
|
14
16
|
microphoneManager: import("./useDeviceManager").DeviceManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaDevices.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/devices/useMediaDevices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMediaDevices.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/devices/useMediaDevices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAKvD,OAAO,KAAK,EAAe,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,UAAU,eAAe;IACvB,gBAAgB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC;IACnD,gBAAgB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC;IACnD,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,yBAAyB,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzF,eAAO,MAAM,eAAe,GAAI,iEAAiE,eAAe;mCAmC1F,yBAAyB,KAAG,OAAO,CAAC,uBAAuB,CAAC;;;CA2GjF,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import { prepareConstraints } from "../../../devices/constraints";
|
|
3
3
|
import { correctDevicesOnSafari, getAvailableMedia } from "../../../devices/mediaInitializer";
|
|
4
4
|
import { useDeviceManager } from "./useDeviceManager";
|
|
5
|
-
export const useMediaDevices = ({ videoConstraints, audioConstraints, persistHandlers }) => {
|
|
5
|
+
export const useMediaDevices = ({ videoConstraints, audioConstraints, persistHandlers, logger }) => {
|
|
6
6
|
const [deviceList, setDeviceList] = useState([]);
|
|
7
7
|
const [videoStream, setVideoStream] = useState(null);
|
|
8
8
|
const [audioStream, setAudioStream] = useState(null);
|
|
@@ -88,6 +88,7 @@ export const useMediaDevices = ({ videoConstraints, audioConstraints, persistHan
|
|
|
88
88
|
constraints: videoConstraints,
|
|
89
89
|
setSelectedDevice: selectCamera,
|
|
90
90
|
selectedDevice: selectedCamera,
|
|
91
|
+
logger,
|
|
91
92
|
});
|
|
92
93
|
const microphoneManager = useDeviceManager({
|
|
93
94
|
mediaStream: audioStream,
|
|
@@ -100,6 +101,7 @@ export const useMediaDevices = ({ videoConstraints, audioConstraints, persistHan
|
|
|
100
101
|
constraints: audioConstraints,
|
|
101
102
|
setSelectedDevice: selectMic,
|
|
102
103
|
selectedDevice: selectedMic,
|
|
104
|
+
logger,
|
|
103
105
|
});
|
|
104
106
|
return {
|
|
105
107
|
initializeDevices,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type FishjamClient } from "@fishjam-cloud/ts-client";
|
|
1
|
+
import { type FishjamClient, type Logger } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import type { CustomSourceState } from "../../types/internal";
|
|
3
3
|
import type { PeerStatus } from "../../types/public";
|
|
4
4
|
type CustomSourceManagerProps = {
|
|
5
5
|
fishjamClient: FishjamClient;
|
|
6
6
|
peerStatus: PeerStatus;
|
|
7
|
+
logger: Logger;
|
|
7
8
|
};
|
|
8
9
|
export type CustomSourceManager = {
|
|
9
10
|
setStream: (sourceId: string, stream: MediaStream | null) => Promise<void>;
|
|
10
11
|
getSource: (sourceId: string) => CustomSourceState | undefined;
|
|
11
12
|
};
|
|
12
|
-
export declare function useCustomSourceManager({ fishjamClient, peerStatus }: CustomSourceManagerProps): CustomSourceManager;
|
|
13
|
+
export declare function useCustomSourceManager({ fishjamClient, peerStatus, logger, }: CustomSourceManagerProps): CustomSourceManager;
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=useCustomSourceManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCustomSourceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useCustomSourceManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useCustomSourceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useCustomSourceManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAsC,MAAM,0BAA0B,CAAC;AAG/G,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,KAAK,wBAAwB,GAAG;IAC9B,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;CAChE,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,EACrC,aAAa,EACb,UAAU,EACV,MAAM,GACP,EAAE,wBAAwB,GAAG,mBAAmB,CA8GhD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TrackTypeError } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
-
export function useCustomSourceManager({ fishjamClient, peerStatus }) {
|
|
3
|
+
export function useCustomSourceManager({ fishjamClient, peerStatus, logger, }) {
|
|
4
4
|
const [sources, setSources] = useState({});
|
|
5
5
|
const pendingSources = useMemo(() => Object.entries(sources).filter(([_, source]) => source.trackIds === undefined), [sources]);
|
|
6
6
|
const getDisplayName = useCallback(() => {
|
|
@@ -14,12 +14,12 @@ export function useCustomSourceManager({ fishjamClient, peerStatus }) {
|
|
|
14
14
|
}
|
|
15
15
|
catch (err) {
|
|
16
16
|
if (err instanceof TrackTypeError) {
|
|
17
|
-
|
|
17
|
+
logger.warn(err.message);
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
20
20
|
throw err;
|
|
21
21
|
}
|
|
22
|
-
}, [fishjamClient]);
|
|
22
|
+
}, [fishjamClient, logger]);
|
|
23
23
|
const startStreaming = useCallback(async (source) => {
|
|
24
24
|
const stream = source?.stream;
|
|
25
25
|
const video = stream.getVideoTracks().at(0);
|
|
@@ -35,12 +35,12 @@ export function useCustomSourceManager({ fishjamClient, peerStatus }) {
|
|
|
35
35
|
promises.push(addTrackToFishjamClient(audio, audioMetadata));
|
|
36
36
|
}
|
|
37
37
|
if (promises.length === 0) {
|
|
38
|
-
|
|
38
|
+
logger.warn("Attempted to add empty MediaStream as custom source.");
|
|
39
39
|
return source;
|
|
40
40
|
}
|
|
41
41
|
const [videoId, audioId] = await Promise.all(promises);
|
|
42
42
|
return { ...source, trackIds: { videoId, audioId } };
|
|
43
|
-
}, [addTrackToFishjamClient, getDisplayName]);
|
|
43
|
+
}, [addTrackToFishjamClient, getDisplayName, logger]);
|
|
44
44
|
const removeTracks = useCallback(async ({ videoId, audioId }) => {
|
|
45
45
|
const promises = [];
|
|
46
46
|
if (videoId)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FishjamClient } from "@fishjam-cloud/ts-client";
|
|
1
|
+
import { type FishjamClient, type Logger } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import type { PeerStatus, TracksMiddleware } from "../../types/public";
|
|
3
3
|
export type UseScreenshareResult = {
|
|
4
4
|
/**
|
|
@@ -40,7 +40,8 @@ export type UseScreenshareResult = {
|
|
|
40
40
|
interface ScreenShareManagerProps {
|
|
41
41
|
fishjamClient: FishjamClient;
|
|
42
42
|
peerStatus: PeerStatus;
|
|
43
|
+
logger: Logger;
|
|
43
44
|
}
|
|
44
|
-
export declare const useScreenShareManager: ({ fishjamClient, peerStatus }: ScreenShareManagerProps) => UseScreenshareResult;
|
|
45
|
+
export declare const useScreenShareManager: ({ fishjamClient, peerStatus, logger, }: ScreenShareManagerProps) => UseScreenshareResult;
|
|
45
46
|
export {};
|
|
46
47
|
//# sourceMappingURL=useScreenshareManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenshareManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useScreenshareManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useScreenshareManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useScreenshareManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAsC,MAAM,0BAA0B,CAAC;AAI/G,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE;QACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;QACnD,gBAAgB,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;KACpD,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB;;OAEG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;OAEG;IACH,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC;;OAEG;IACH,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,uBAAuB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E,CAAC;AAEF,UAAU,uBAAuB;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,qBAAqB,GAAI,wCAInC,uBAAuB,KAAG,oBAkK5B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TrackTypeError } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
|
|
3
|
+
export const useScreenShareManager = ({ fishjamClient, peerStatus, logger, }) => {
|
|
4
4
|
const [state, setState] = useState({ stream: null, trackIds: null });
|
|
5
5
|
const cleanMiddlewareFnRef = useRef(null);
|
|
6
6
|
const stream = state.stream ?? null;
|
|
@@ -16,7 +16,7 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
|
|
|
16
16
|
}
|
|
17
17
|
catch (err) {
|
|
18
18
|
if (err instanceof TrackTypeError) {
|
|
19
|
-
|
|
19
|
+
logger.warn(err.message);
|
|
20
20
|
return undefined;
|
|
21
21
|
}
|
|
22
22
|
throw err;
|
|
@@ -35,11 +35,21 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
|
|
|
35
35
|
audio = audioTrack;
|
|
36
36
|
cleanMiddlewareFnRef.current = onClear;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
// TODO: FCE-2659 Refactor this hook so this check is not required.
|
|
39
|
+
// This check is needed to support screensharing in livestreams which don't use the FishjamClient.
|
|
40
|
+
// trackIds are simply ignored because they are not used in this use case.
|
|
41
|
+
if (fishjamClient.status === "initialized") {
|
|
42
|
+
const addTrackPromises = [
|
|
43
|
+
addTrackToFishjamClient(video, { displayName, type: "screenShareVideo", paused: false }),
|
|
44
|
+
];
|
|
45
|
+
if (audio)
|
|
46
|
+
addTrackPromises.push(addTrackToFishjamClient(audio, { displayName, type: "screenShareAudio", paused: false }));
|
|
47
|
+
const [videoId, audioId] = await Promise.all(addTrackPromises);
|
|
48
|
+
setState({ stream: displayStream, trackIds: { videoId, audioId } });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setState({ stream: displayStream, trackIds: {} });
|
|
52
|
+
}
|
|
43
53
|
};
|
|
44
54
|
const replaceTracks = async (newVideoTrack, newAudioTrack) => {
|
|
45
55
|
if (!state?.stream)
|
|
@@ -70,7 +80,7 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
|
|
|
70
80
|
};
|
|
71
81
|
const stopStreaming = useCallback(async () => {
|
|
72
82
|
if (!state.stream) {
|
|
73
|
-
|
|
83
|
+
logger.warn("No stream to stop");
|
|
74
84
|
return;
|
|
75
85
|
}
|
|
76
86
|
const [video, audio] = getTracksFromStream(state.stream);
|
|
@@ -87,7 +97,15 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
|
|
|
87
97
|
}
|
|
88
98
|
cleanMiddleware();
|
|
89
99
|
setState(({ tracksMiddleware }) => ({ stream: null, trackIds: null, tracksMiddleware }));
|
|
90
|
-
}, [
|
|
100
|
+
}, [
|
|
101
|
+
state.stream,
|
|
102
|
+
state.trackIds?.videoId,
|
|
103
|
+
state.trackIds?.audioId,
|
|
104
|
+
peerStatus,
|
|
105
|
+
cleanMiddleware,
|
|
106
|
+
logger,
|
|
107
|
+
fishjamClient,
|
|
108
|
+
]);
|
|
91
109
|
useEffect(() => {
|
|
92
110
|
if (!state.stream)
|
|
93
111
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FishjamClient } from "@fishjam-cloud/ts-client";
|
|
1
|
+
import { type FishjamClient, type Logger } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import type { TrackManager } from "../../types/internal";
|
|
3
3
|
import type { BandwidthLimits, PeerStatus, StreamConfig } from "../../types/public";
|
|
4
4
|
import type { DeviceManager } from "./devices/useDeviceManager";
|
|
@@ -9,7 +9,8 @@ interface TrackManagerConfig {
|
|
|
9
9
|
bandwidthLimits: BandwidthLimits;
|
|
10
10
|
streamConfig?: StreamConfig;
|
|
11
11
|
type: "camera" | "microphone";
|
|
12
|
+
logger: Logger;
|
|
12
13
|
}
|
|
13
|
-
export declare const useTrackManager: ({ deviceManager, tsClient, peerStatus, bandwidthLimits, streamConfig, type, }: TrackManagerConfig) => TrackManager;
|
|
14
|
+
export declare const useTrackManager: ({ deviceManager, tsClient, peerStatus, bandwidthLimits, streamConfig, type, logger, }: TrackManagerConfig) => TrackManager;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=useTrackManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useTrackManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA+C,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useTrackManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useTrackManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAA+C,MAAM,0BAA0B,CAAC;AAGxH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAErG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,UAAU,kBAAkB;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,GAAI,uFAQ7B,kBAAkB,KAAG,YAoLvB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TrackTypeError, Variant } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import { useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import { getConfigAndBandwidthFromProps, getRemoteOrLocalTrack } from "../../utils/track";
|
|
4
|
-
export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidthLimits, streamConfig, type, }) => {
|
|
4
|
+
export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidthLimits, streamConfig, type, logger, }) => {
|
|
5
5
|
const currentTrackIdRef = useRef(null);
|
|
6
6
|
const { startDevice, stopDevice, enableDevice, disableDevice, deviceTrack, applyMiddleware, currentMiddleware, selectDevice: _selectDevice, } = deviceManager;
|
|
7
7
|
const getCurrentTrackId = useCallback(() => {
|
|
@@ -45,12 +45,12 @@ export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidth
|
|
|
45
45
|
}
|
|
46
46
|
catch (err) {
|
|
47
47
|
if (err instanceof TrackTypeError) {
|
|
48
|
-
|
|
48
|
+
logger.warn(err.message);
|
|
49
49
|
currentTrackIdRef.current = null;
|
|
50
50
|
}
|
|
51
51
|
throw err;
|
|
52
52
|
}
|
|
53
|
-
}, [tsClient,
|
|
53
|
+
}, [type, tsClient, bandwidthLimits, logger]);
|
|
54
54
|
const pauseStreaming = useCallback(async (trackId) => {
|
|
55
55
|
if (peerStatus !== "connected")
|
|
56
56
|
return;
|
|
@@ -70,7 +70,7 @@ export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidth
|
|
|
70
70
|
const isTrackCurrentlyEnabled = Boolean(deviceTrack?.enabled);
|
|
71
71
|
const currentTrackId = getCurrentTrackId();
|
|
72
72
|
if (!currentTrackId) {
|
|
73
|
-
|
|
73
|
+
logger.warn("Toggling mute is only possible while connected to a room.");
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
if (isTrackCurrentlyEnabled) {
|
|
@@ -81,7 +81,7 @@ export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidth
|
|
|
81
81
|
enableDevice();
|
|
82
82
|
await resumeStreaming(currentTrackId, deviceTrack);
|
|
83
83
|
}
|
|
84
|
-
}, [deviceTrack, getCurrentTrackId, disableDevice, pauseStreaming, enableDevice, resumeStreaming]);
|
|
84
|
+
}, [deviceTrack, getCurrentTrackId, logger, disableDevice, pauseStreaming, enableDevice, resumeStreaming]);
|
|
85
85
|
/**
|
|
86
86
|
* @see {@link TrackManager#toggleDevice} for more details.
|
|
87
87
|
*/
|
|
@@ -138,5 +138,7 @@ export const useTrackManager = ({ deviceManager, tsClient, peerStatus, bandwidth
|
|
|
138
138
|
selectDevice,
|
|
139
139
|
toggleMute,
|
|
140
140
|
toggleDevice,
|
|
141
|
+
stopDevice,
|
|
142
|
+
startDevice,
|
|
141
143
|
};
|
|
142
144
|
};
|
|
@@ -26,7 +26,7 @@ export interface UseLivestreamStreamerResult {
|
|
|
26
26
|
connect: (inputs: ConnectStreamerConfig, urlOverride?: string) => Promise<void>;
|
|
27
27
|
/** Callback to stop publishing anything previously published with {@link connect} */
|
|
28
28
|
disconnect: () => void;
|
|
29
|
-
/** Any errors
|
|
29
|
+
/** Any errors encountered in {@link connect} will populate this field */
|
|
30
30
|
error: LivestreamError | null;
|
|
31
31
|
/** Utility flag which indicates the current connection status */
|
|
32
32
|
isConnected: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmD,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmD,MAAM,0BAA0B,CAAC;AAM5G,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GACtB;IACE,sHAAsH;IACtH,KAAK,EAAE,WAAW,CAAC;IACnB,8HAA8H;IAC9H,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B,GACD;IACE,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAEN,2BAA2B;AAC3B,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,2BAA2B;AAC3B,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,qFAAqF;IACrF,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,yEAAyE;IACzE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;CACtB;AAKD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,2BA0CxC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LivestreamError, publishLivestream } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { useFishjamId } from "../contexts/fishjamId";
|
|
4
|
+
import { buildLivestreamWhipUrl } from "../utils/fishjamUrl";
|
|
4
5
|
const isLivestreamError = (err) => Object.values(LivestreamError).includes(err);
|
|
5
6
|
/**
|
|
6
7
|
* Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}
|
|
@@ -10,6 +11,7 @@ const isLivestreamError = (err) => Object.values(LivestreamError).includes(err);
|
|
|
10
11
|
export const useLivestreamStreamer = () => {
|
|
11
12
|
const [error, setError] = useState(null);
|
|
12
13
|
const [isConnected, setIsConnected] = useState(false);
|
|
14
|
+
const fishjamId = useFishjamId();
|
|
13
15
|
const resultRef = useRef(null);
|
|
14
16
|
const disconnect = useCallback(() => {
|
|
15
17
|
resultRef.current?.stopPublishing();
|
|
@@ -27,7 +29,7 @@ export const useLivestreamStreamer = () => {
|
|
|
27
29
|
const audioTrack = audio?.getAudioTracks().at(0);
|
|
28
30
|
const stream = new MediaStream([videoTrack, audioTrack].filter((v) => v != null));
|
|
29
31
|
try {
|
|
30
|
-
const result = await publishLivestream(stream, urlOverride ??
|
|
32
|
+
const result = await publishLivestream(stream, urlOverride ?? buildLivestreamWhipUrl(fishjamId), token, {
|
|
31
33
|
onConnectionStateChange,
|
|
32
34
|
});
|
|
33
35
|
resultRef.current = result;
|
|
@@ -39,6 +41,6 @@ export const useLivestreamStreamer = () => {
|
|
|
39
41
|
else
|
|
40
42
|
console.error(e);
|
|
41
43
|
}
|
|
42
|
-
}, [disconnect, onConnectionStateChange]);
|
|
44
|
+
}, [disconnect, onConnectionStateChange, fishjamId]);
|
|
43
45
|
return { connect, disconnect, error, isConnected };
|
|
44
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamViewer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmD,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useLivestreamViewer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmD,MAAM,0BAA0B,CAAC;AAM5G,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5G;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,oCAAoC;IACpC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,6FAA6F;IAC7F,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,+EAA+E;IAC/E,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;CACtB;AAUD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAO,yBAyCtC,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { LivestreamError, receiveLivestream } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { useFishjamId } from "../contexts/fishjamId";
|
|
4
|
+
import { buildLivestreamWhepUrl } from "../utils/fishjamUrl";
|
|
4
5
|
const isLivestreamError = (err) => Object.values(LivestreamError).includes(err);
|
|
5
|
-
const urlFromConfig = (config) => {
|
|
6
|
+
const urlFromConfig = (config, baseUrl) => {
|
|
6
7
|
if (config.streamId)
|
|
7
|
-
return `${
|
|
8
|
-
return
|
|
8
|
+
return `${baseUrl}/${config.streamId}`;
|
|
9
|
+
return baseUrl;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* Hook for receiving a published livestream.
|
|
@@ -17,6 +18,7 @@ export const useLivestreamViewer = () => {
|
|
|
17
18
|
const [error, setError] = useState(null);
|
|
18
19
|
const resultRef = useRef(null);
|
|
19
20
|
const [isConnected, setIsConnected] = useState(false);
|
|
21
|
+
const fishjamId = useFishjamId();
|
|
20
22
|
const disconnect = useCallback(() => {
|
|
21
23
|
setStream(null);
|
|
22
24
|
resultRef.current?.stop();
|
|
@@ -31,7 +33,10 @@ export const useLivestreamViewer = () => {
|
|
|
31
33
|
if (resultRef.current !== null)
|
|
32
34
|
disconnect();
|
|
33
35
|
try {
|
|
34
|
-
const
|
|
36
|
+
const baseUrl = buildLivestreamWhepUrl(fishjamId);
|
|
37
|
+
const result = await receiveLivestream(url ?? urlFromConfig(config, baseUrl), config.token, {
|
|
38
|
+
onConnectionStateChange,
|
|
39
|
+
});
|
|
35
40
|
resultRef.current = result;
|
|
36
41
|
setError(null);
|
|
37
42
|
setStream(result.stream);
|
|
@@ -40,6 +45,6 @@ export const useLivestreamViewer = () => {
|
|
|
40
45
|
if (isLivestreamError(e))
|
|
41
46
|
setError(e);
|
|
42
47
|
}
|
|
43
|
-
}, [disconnect, onConnectionStateChange]);
|
|
48
|
+
}, [disconnect, onConnectionStateChange, fishjamId]);
|
|
44
49
|
return { stream, connect, disconnect, error, isConnected };
|
|
45
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,cAAc;IAKvB;;OAEG;;
|
|
1
|
+
{"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,cAAc;IAKvB;;OAEG;;wBADiE,CAAC;wBAEpD,CAAC;;IAClB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;CAGN,CAAC"}
|
package/dist/hooks/useVAD.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { PeerId } from "../types/public";
|
|
|
2
2
|
/**
|
|
3
3
|
* Voice activity detection. Use this hook to check if voice is detected in audio track for given peer(s).
|
|
4
4
|
*
|
|
5
|
+
* @param options - Options object containing `peerIds` - a list of ids of peers to subscribe to for voice activity detection notifications.
|
|
6
|
+
*
|
|
5
7
|
* Example usage:
|
|
6
8
|
* ```tsx
|
|
7
9
|
* import { useVAD, type PeerId } from "@fishjam-cloud/react-client";
|
|
@@ -9,15 +11,14 @@ import type { PeerId } from "../types/public";
|
|
|
9
11
|
* const peersInfo = useVAD({peerIds});
|
|
10
12
|
* const activePeers = (Object.keys(peersInfo) as PeerId[]).filter((peerId) => peersInfo[peerId]);
|
|
11
13
|
*
|
|
12
|
-
* return
|
|
14
|
+
* return "Now talking: " + activePeers.join(", ");
|
|
13
15
|
* }
|
|
14
16
|
* ```
|
|
15
|
-
* @param peerIds List of ids of peers to subscribe to for voice activity detection notifications.
|
|
16
17
|
* @category Connection
|
|
17
18
|
* @group Hooks
|
|
18
19
|
* @returns Each key is a peerId and the boolean value indicates if voice activity is currently detected for that peer.
|
|
19
20
|
*/
|
|
20
|
-
export declare const useVAD: (
|
|
21
|
+
export declare const useVAD: (options: {
|
|
21
22
|
peerIds: ReadonlyArray<PeerId>;
|
|
22
23
|
}) => Record<PeerId, boolean>;
|
|
23
24
|
//# sourceMappingURL=useVAD.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVAD.d.ts","sourceRoot":"","sources":["../../src/hooks/useVAD.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"useVAD.d.ts","sourceRoot":"","sources":["../../src/hooks/useVAD.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,MAAM,GAAI,SAAS;IAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAiE1F,CAAC"}
|
package/dist/hooks/useVAD.js
CHANGED
|
@@ -3,6 +3,8 @@ import { FishjamClientStateContext } from "../contexts/fishjamState";
|
|
|
3
3
|
/**
|
|
4
4
|
* Voice activity detection. Use this hook to check if voice is detected in audio track for given peer(s).
|
|
5
5
|
*
|
|
6
|
+
* @param options - Options object containing `peerIds` - a list of ids of peers to subscribe to for voice activity detection notifications.
|
|
7
|
+
*
|
|
6
8
|
* Example usage:
|
|
7
9
|
* ```tsx
|
|
8
10
|
* import { useVAD, type PeerId } from "@fishjam-cloud/react-client";
|
|
@@ -10,15 +12,15 @@ import { FishjamClientStateContext } from "../contexts/fishjamState";
|
|
|
10
12
|
* const peersInfo = useVAD({peerIds});
|
|
11
13
|
* const activePeers = (Object.keys(peersInfo) as PeerId[]).filter((peerId) => peersInfo[peerId]);
|
|
12
14
|
*
|
|
13
|
-
* return
|
|
15
|
+
* return "Now talking: " + activePeers.join(", ");
|
|
14
16
|
* }
|
|
15
17
|
* ```
|
|
16
|
-
* @param peerIds List of ids of peers to subscribe to for voice activity detection notifications.
|
|
17
18
|
* @category Connection
|
|
18
19
|
* @group Hooks
|
|
19
20
|
* @returns Each key is a peerId and the boolean value indicates if voice activity is currently detected for that peer.
|
|
20
21
|
*/
|
|
21
|
-
export const useVAD = (
|
|
22
|
+
export const useVAD = (options) => {
|
|
23
|
+
const { peerIds } = options;
|
|
22
24
|
const clientState = useContext(FishjamClientStateContext);
|
|
23
25
|
if (!clientState)
|
|
24
26
|
throw Error("useVAD must be used within FishjamProvider");
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export type ScreenShareState = ({
|
|
|
22
22
|
};
|
|
23
23
|
export interface TrackManager {
|
|
24
24
|
selectDevice: (deviceId: string) => Promise<undefined | DeviceError>;
|
|
25
|
+
stopDevice: () => void;
|
|
26
|
+
startDevice: (deviceId?: string | null) => Promise<[MediaStreamTrack, null] | [null, DeviceError]>;
|
|
25
27
|
deviceTrack: MediaStreamTrack | null;
|
|
26
28
|
currentMiddleware: TrackMiddleware;
|
|
27
29
|
setTrackMiddleware: (middleware: TrackMiddleware | null) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEvF,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEnD,MAAM,MAAM,cAAc,GAAG;IAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAA;CAAE,CAAC;AAExG,MAAM,MAAM,gBAAgB,GAAG,CAC3B;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD,GACD;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CACnC,GAAG;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;IACrE,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,iBAAiB,EAAE,eAAe,CAAC;IACnC,kBAAkB,EAAE,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;CACtD;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEvF,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEnD,MAAM,MAAM,cAAc,GAAG;IAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAA;CAAE,CAAC;AAExG,MAAM,MAAM,gBAAgB,GAAG,CAC3B;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD,GACD;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CACnC,GAAG;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;IACrE,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IACnG,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,iBAAiB,EAAE,eAAe,CAAC;IACnC,kBAAkB,EAAE,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;CACtD;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC"}
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { getLogger } from "@fishjam-cloud/ts-client";
|
|
1
2
|
import type { DeviceError } from "../types/public";
|
|
2
3
|
export declare const PERMISSION_DENIED: DeviceError;
|
|
3
4
|
export declare const OVERCONSTRAINED_ERROR: DeviceError;
|
|
4
5
|
export declare const NOT_FOUND_ERROR: DeviceError;
|
|
5
6
|
export declare const UNHANDLED_ERROR: DeviceError;
|
|
6
|
-
export declare const parseUserMediaError: (error: unknown) => DeviceError;
|
|
7
|
+
export declare const parseUserMediaError: (error: unknown, logger: ReturnType<typeof getLogger>) => DeviceError;
|
|
7
8
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,WAAyC,CAAC;AAC1E,eAAO,MAAM,qBAAqB,EAAE,WAA8C,CAAC;AACnF,eAAO,MAAM,eAAe,EAAE,WAAuC,CAAC;AACtE,eAAO,MAAM,eAAe,EAAE,WAAyC,CAAC;AAIxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,WAAyC,CAAC;AAC1E,eAAO,MAAM,qBAAqB,EAAE,WAA8C,CAAC;AACnF,eAAO,MAAM,eAAe,EAAE,WAAuC,CAAC;AACtE,eAAO,MAAM,eAAe,EAAE,WAAyC,CAAC;AAIxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,EAAE,QAAQ,UAAU,CAAC,OAAO,SAAS,CAAC,KAAG,WAe1F,CAAC"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -4,9 +4,9 @@ export const NOT_FOUND_ERROR = { name: "NotFoundError" };
|
|
|
4
4
|
export const UNHANDLED_ERROR = { name: "UNHANDLED_ERROR" };
|
|
5
5
|
// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions
|
|
6
6
|
// OverconstrainedError has higher priority than NotAllowedError
|
|
7
|
-
export const parseUserMediaError = (error) => {
|
|
7
|
+
export const parseUserMediaError = (error, logger) => {
|
|
8
8
|
if (!(error instanceof DOMException)) {
|
|
9
|
-
|
|
9
|
+
logger.warn({ name: "Unhandled getUserMedia error", error });
|
|
10
10
|
return UNHANDLED_ERROR;
|
|
11
11
|
}
|
|
12
12
|
if (error.name === "NotAllowedError") {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type LivestreamKind = "whip" | "whep";
|
|
1
2
|
export declare function resolveFishjamUrl(fishjamId: string): string;
|
|
2
3
|
export declare function httpToWebsocketUrl(url: string): string;
|
|
4
|
+
export declare function extractDomainFromFishjamId(fishjamId: string): string;
|
|
5
|
+
export declare function buildLivestreamUrl(fishjamId: string, kind: LivestreamKind): string;
|
|
6
|
+
export declare function buildLivestreamWhipUrl(fishjamId: string): string;
|
|
7
|
+
export declare function buildLivestreamWhepUrl(fishjamId: string): string;
|
|
8
|
+
export {};
|
|
3
9
|
//# sourceMappingURL=fishjamUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fishjamUrl.d.ts","sourceRoot":"","sources":["../../src/utils/fishjamUrl.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
1
|
+
{"version":3,"file":"fishjamUrl.d.ts","sourceRoot":"","sources":["../../src/utils/fishjamUrl.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtC,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOpE;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAMlF;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
package/dist/utils/fishjamUrl.js
CHANGED
|
@@ -9,3 +9,25 @@ export function resolveFishjamUrl(fishjamId) {
|
|
|
9
9
|
export function httpToWebsocketUrl(url) {
|
|
10
10
|
return url.replace("https://", "wss://").replace("http://", "ws://");
|
|
11
11
|
}
|
|
12
|
+
export function extractDomainFromFishjamId(fishjamId) {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(fishjamId);
|
|
15
|
+
return url.origin;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return "https://fishjam.io";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function buildLivestreamUrl(fishjamId, kind) {
|
|
22
|
+
if (!fishjamId || fishjamId.trim() === "") {
|
|
23
|
+
throw new Error("fishjamId is required to build a livestream WHEP URL.");
|
|
24
|
+
}
|
|
25
|
+
const domain = extractDomainFromFishjamId(fishjamId);
|
|
26
|
+
return `${domain}/api/v1/live/api/${kind}`;
|
|
27
|
+
}
|
|
28
|
+
export function buildLivestreamWhipUrl(fishjamId) {
|
|
29
|
+
return buildLivestreamUrl(fishjamId, "whip");
|
|
30
|
+
}
|
|
31
|
+
export function buildLivestreamWhepUrl(fishjamId) {
|
|
32
|
+
return buildLivestreamUrl(fishjamId, "whep");
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/react-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0-rc.1",
|
|
4
4
|
"description": "React client library for Fishjam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fishjam Team",
|
|
@@ -42,6 +42,9 @@
|
|
|
42
42
|
"lint:check": "eslint . --ext .ts,.tsx",
|
|
43
43
|
"prepack": "yarn workspace @fishjam-cloud/ts-client build && yarn build"
|
|
44
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^19.1.0"
|
|
47
|
+
},
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@playwright/test": "^1.51.1",
|
|
47
50
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -49,10 +52,9 @@
|
|
|
49
52
|
"@types/events": "^3.0.3",
|
|
50
53
|
"@types/lodash.isequal": "^4.5.8",
|
|
51
54
|
"@types/node": "^22.14.0",
|
|
52
|
-
"@types/react": "
|
|
55
|
+
"@types/react": "19.1.0",
|
|
53
56
|
"fake-mediastreamtrack": "^2.0.0",
|
|
54
57
|
"jsdom": "^26.0.0",
|
|
55
|
-
"react": "^19.0.0",
|
|
56
58
|
"typed-emitter": "^2.1.0",
|
|
57
59
|
"typedoc": "^0.28.2",
|
|
58
60
|
"typedoc-plugin-mdn-links": "^5.0.1",
|
|
@@ -60,12 +62,21 @@
|
|
|
60
62
|
"vitest": "^3.1.1"
|
|
61
63
|
},
|
|
62
64
|
"dependencies": {
|
|
63
|
-
"@fishjam-cloud/ts-client": "0.
|
|
65
|
+
"@fishjam-cloud/ts-client": "0.25.0-rc.1",
|
|
64
66
|
"events": "3.3.0",
|
|
65
67
|
"lodash.isequal": "4.5.0"
|
|
66
68
|
},
|
|
67
69
|
"directories": {
|
|
68
70
|
"example": "examples"
|
|
69
71
|
},
|
|
70
|
-
"packageManager": "yarn@4.
|
|
72
|
+
"packageManager": "yarn@4.12.0",
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*": [
|
|
75
|
+
"yarn format"
|
|
76
|
+
],
|
|
77
|
+
"*.(js|ts|tsx)": [
|
|
78
|
+
"yarn lint"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"stableVersion": "0.24.0"
|
|
71
82
|
}
|