@fishjam-cloud/react-client 0.22.0 → 0.24.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.
Files changed (33) hide show
  1. package/dist/FishjamProvider.d.ts +4 -0
  2. package/dist/FishjamProvider.d.ts.map +1 -1
  3. package/dist/FishjamProvider.js +8 -2
  4. package/dist/hooks/devices/useCamera.d.ts +8 -0
  5. package/dist/hooks/devices/useCamera.d.ts.map +1 -1
  6. package/dist/hooks/devices/useCamera.js +8 -0
  7. package/dist/hooks/devices/useMicrophone.d.ts +4 -0
  8. package/dist/hooks/devices/useMicrophone.d.ts.map +1 -1
  9. package/dist/hooks/devices/useMicrophone.js +4 -0
  10. package/dist/hooks/internal/devices/useDeviceManager.d.ts +3 -1
  11. package/dist/hooks/internal/devices/useDeviceManager.d.ts.map +1 -1
  12. package/dist/hooks/internal/devices/useDeviceManager.js +3 -2
  13. package/dist/hooks/internal/devices/useMediaDevices.d.ts +3 -1
  14. package/dist/hooks/internal/devices/useMediaDevices.d.ts.map +1 -1
  15. package/dist/hooks/internal/devices/useMediaDevices.js +3 -1
  16. package/dist/hooks/internal/useCustomSourceManager.d.ts +3 -2
  17. package/dist/hooks/internal/useCustomSourceManager.d.ts.map +1 -1
  18. package/dist/hooks/internal/useCustomSourceManager.js +5 -5
  19. package/dist/hooks/internal/useScreenshareManager.d.ts +3 -2
  20. package/dist/hooks/internal/useScreenshareManager.d.ts.map +1 -1
  21. package/dist/hooks/internal/useScreenshareManager.js +12 -4
  22. package/dist/hooks/internal/useTrackManager.d.ts +3 -2
  23. package/dist/hooks/internal/useTrackManager.d.ts.map +1 -1
  24. package/dist/hooks/internal/useTrackManager.js +7 -5
  25. package/dist/hooks/useLivestreamStreamer.d.ts +1 -1
  26. package/dist/hooks/useLivestreamStreamer.d.ts.map +1 -1
  27. package/dist/hooks/useScreenShare.d.ts.map +1 -1
  28. package/dist/types/internal.d.ts +2 -0
  29. package/dist/types/internal.d.ts.map +1 -1
  30. package/dist/utils/errors.d.ts +2 -1
  31. package/dist/utils/errors.d.ts.map +1 -1
  32. package/dist/utils/errors.js +2 -2
  33. package/package.json +2 -2
@@ -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,EAAiB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC/E,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;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAiF1D"}
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"}
@@ -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,O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AAC;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":"AAIA,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;CAC7C;AAED,MAAM,MAAM,yBAAyB,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzF,eAAO,MAAM,eAAe,GAAI,yDAAyD,eAAe;mCAmClF,yBAAyB,KAAG,OAAO,CAAC,uBAAuB,CAAC;;;CAyGjF,CAAC"}
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;AAGlG,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;CACxB,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,EAAE,aAAa,EAAE,UAAU,EAAE,EAAE,wBAAwB,GAAG,mBAAmB,CA8GnH"}
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
- console.warn(err.message);
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
- console.warn("Attempted to add empty MediaStream as custom source.");
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;AAIlG,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,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C;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,qBAAqB,GAAI,wCAInC,uBAAuB,KAAG,oBAyJ5B,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
- console.warn(err.message);
19
+ logger.warn(err.message);
20
20
  return undefined;
21
21
  }
22
22
  throw err;
@@ -70,7 +70,7 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
70
70
  };
71
71
  const stopStreaming = useCallback(async () => {
72
72
  if (!state.stream) {
73
- console.warn("No stream to stop");
73
+ logger.warn("No stream to stop");
74
74
  return;
75
75
  }
76
76
  const [video, audio] = getTracksFromStream(state.stream);
@@ -87,7 +87,15 @@ export const useScreenShareManager = ({ fishjamClient, peerStatus }) => {
87
87
  }
88
88
  cleanMiddleware();
89
89
  setState(({ tracksMiddleware }) => ({ stream: null, trackIds: null, tracksMiddleware }));
90
- }, [state, fishjamClient, setState, cleanMiddleware, peerStatus]);
90
+ }, [
91
+ state.stream,
92
+ state.trackIds?.videoId,
93
+ state.trackIds?.audioId,
94
+ peerStatus,
95
+ cleanMiddleware,
96
+ logger,
97
+ fishjamClient,
98
+ ]);
91
99
  useEffect(() => {
92
100
  if (!state.stream)
93
101
  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;AAG3G,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;CAC/B;AAED,eAAO,MAAM,eAAe,GAAI,+EAO7B,kBAAkB,KAAG,YAkLvB,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
- console.warn(err.message);
48
+ logger.warn(err.message);
49
49
  currentTrackIdRef.current = null;
50
50
  }
51
51
  throw err;
52
52
  }
53
- }, [tsClient, type, bandwidthLimits]);
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
- console.warn("Toggling mute is only possible while connected to a room.");
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 encounterd in {@link connect} will populate this field */
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,EAAm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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,2BAyCxC,CAAC"}
@@ -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;;wBADoD,CAAC;wBAEpD,CAAC;;IACL;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;CAGN,CAAC"}
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"}
@@ -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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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"}
@@ -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,WAepD,CAAC"}
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"}
@@ -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
- console.warn({ name: "Unhandled getUserMedia error", error });
9
+ logger.warn({ name: "Unhandled getUserMedia error", error });
10
10
  return UNHANDLED_ERROR;
11
11
  }
12
12
  if (error.name === "NotAllowedError") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishjam-cloud/react-client",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "React client library for Fishjam",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fishjam Team",
@@ -60,7 +60,7 @@
60
60
  "vitest": "^3.1.1"
61
61
  },
62
62
  "dependencies": {
63
- "@fishjam-cloud/ts-client": "0.22.0",
63
+ "@fishjam-cloud/ts-client": "0.24.0",
64
64
  "events": "3.3.0",
65
65
  "lodash.isequal": "4.5.0"
66
66
  },