@fishjam-cloud/react-client 0.7.1 → 0.7.2

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 (51) hide show
  1. package/dist/DeviceManager.d.ts +25 -15
  2. package/dist/DeviceManager.d.ts.map +1 -1
  3. package/dist/DeviceManager.js +121 -81
  4. package/dist/devices/MiddlewareManager.d.ts +9 -0
  5. package/dist/devices/MiddlewareManager.d.ts.map +1 -0
  6. package/dist/devices/MiddlewareManager.js +26 -0
  7. package/dist/fishjamProvider.d.ts.map +1 -1
  8. package/dist/fishjamProvider.js +4 -3
  9. package/dist/hooks/deviceManagers/useDeviceManager.d.ts.map +1 -1
  10. package/dist/hooks/deviceManagers/useDeviceManager.js +2 -2
  11. package/dist/hooks/{useDevices.d.ts → devices.d.ts} +1 -1
  12. package/dist/hooks/devices.d.ts.map +1 -0
  13. package/dist/hooks/{useDevices.js → devices.js} +13 -13
  14. package/dist/hooks/public.d.ts +1 -1
  15. package/dist/hooks/public.d.ts.map +1 -1
  16. package/dist/hooks/public.js +1 -1
  17. package/dist/hooks/useFishjamContext.d.ts +3 -3
  18. package/dist/hooks/useFishjamContext.d.ts.map +1 -1
  19. package/dist/hooks/useScreenShare.d.ts +8 -0
  20. package/dist/hooks/useScreenShare.d.ts.map +1 -1
  21. package/dist/hooks/useScreenShare.js +30 -31
  22. package/dist/hooks/useTrackManager.d.ts.map +1 -1
  23. package/dist/hooks/useTrackManager.js +29 -44
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/mediaInitializer.d.ts.map +1 -1
  27. package/dist/mediaInitializer.js +30 -1
  28. package/dist/types/internal.d.ts +19 -29
  29. package/dist/types/internal.d.ts.map +1 -1
  30. package/dist/types/public.d.ts +4 -4
  31. package/dist/types/public.d.ts.map +1 -1
  32. package/dist/utils/localStorage.d.ts +3 -4
  33. package/dist/utils/localStorage.d.ts.map +1 -1
  34. package/dist/utils/localStorage.js +18 -4
  35. package/dist/utils/track.d.ts +1 -0
  36. package/dist/utils/track.d.ts.map +1 -1
  37. package/dist/utils/track.js +8 -0
  38. package/package.json +5 -5
  39. package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts +0 -6
  40. package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts.map +0 -1
  41. package/dist/hooks/deviceManagers/useAudioDeviceManager.js +0 -11
  42. package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts +0 -6
  43. package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts.map +0 -1
  44. package/dist/hooks/deviceManagers/useVideoDeviceManager.js +0 -11
  45. package/dist/hooks/useDevices.d.ts.map +0 -1
  46. package/dist/hooks/useProcessedPreviewStream.d.ts +0 -3
  47. package/dist/hooks/useProcessedPreviewStream.d.ts.map +0 -1
  48. package/dist/hooks/useProcessedPreviewStream.js +0 -17
  49. package/dist/utils/media.d.ts +0 -13
  50. package/dist/utils/media.d.ts.map +0 -1
  51. package/dist/utils/media.js +0 -64
@@ -1,6 +0,0 @@
1
- /**
2
- *
3
- * @category Devices
4
- */
5
- export declare const useAudioDeviceManager: () => import("../../types/internal").DeviceManagerState;
6
- //# sourceMappingURL=useAudioDeviceManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAudioDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useAudioDeviceManager.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yDAKjC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { useFishjamContext } from "../useFishjamContext";
2
- import { useDeviceManager } from "./useDeviceManager";
3
- /**
4
- *
5
- * @category Devices
6
- */
7
- export const useAudioDeviceManager = () => {
8
- const { audioDeviceManagerRef } = useFishjamContext();
9
- const audioDeviceState = useDeviceManager(audioDeviceManagerRef.current);
10
- return audioDeviceState;
11
- };
@@ -1,6 +0,0 @@
1
- /**
2
- *
3
- * @category Devices
4
- */
5
- export declare const useVideoDeviceManager: () => import("../../types/internal").DeviceManagerState;
6
- //# sourceMappingURL=useVideoDeviceManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVideoDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useVideoDeviceManager.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yDAIjC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { useFishjamContext } from "../useFishjamContext";
2
- import { useDeviceManager } from "./useDeviceManager";
3
- /**
4
- *
5
- * @category Devices
6
- */
7
- export const useVideoDeviceManager = () => {
8
- const { videoDeviceManagerRef } = useFishjamContext();
9
- const videoDeviceState = useDeviceManager(videoDeviceManagerRef.current);
10
- return videoDeviceState;
11
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDevices.d.ts","sourceRoot":"","sources":["../../src/hooks/useDevices.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAuBlC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,WAAW,CA2B3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAqDhC,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { TrackManager } from "../types/internal";
2
- export declare function useProcessedPreviewStream(trackManager: TrackManager, deviceTrack: MediaStreamTrack | null | undefined): MediaStream | null;
3
- //# sourceMappingURL=useProcessedPreviewStream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useProcessedPreviewStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useProcessedPreviewStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,sBAiBjD"}
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- export function useProcessedPreviewStream(trackManager, deviceTrack) {
3
- const [previewStream, setPreviewStream] = useState(null);
4
- const { currentTrack, currentTrackMiddleware } = trackManager;
5
- useEffect(() => {
6
- if (currentTrack || !deviceTrack)
7
- return;
8
- const result = currentTrackMiddleware?.(deviceTrack);
9
- if (result?.track)
10
- setPreviewStream(new MediaStream([result.track]));
11
- return () => {
12
- result?.onClear?.();
13
- setPreviewStream(null);
14
- };
15
- }, [currentTrack, deviceTrack, currentTrackMiddleware]);
16
- return previewStream;
17
- }
@@ -1,13 +0,0 @@
1
- import type { CurrentDevices, DeviceError, DeviceState } from "../types/internal";
2
- import type { PersistLastDeviceHandlers } from "../types/public";
3
- export declare const removeSpecifiedDeviceFromConstraints: (trackConstraints?: boolean | MediaTrackConstraints) => boolean | MediaTrackConstraints | undefined;
4
- export declare const REQUESTING = "Requesting";
5
- export declare const NOT_REQUESTED = "Not requested";
6
- export declare const getDeviceInfo: (trackDeviceId: string | null, devices: MediaDeviceInfo[]) => MediaDeviceInfo | null;
7
- export declare const getCurrentDevicesSettings: (requestedDevices: MediaStream, mediaDeviceInfos: MediaDeviceInfo[]) => CurrentDevices;
8
- export declare const isDeviceDifferentFromLastSession: (lastDevice: MediaDeviceInfo | null, currentDevice: MediaDeviceInfo | null) => boolean | null;
9
- export declare const isAnyDeviceDifferentFromLastSession: (lastVideoDevice: MediaDeviceInfo | null, lastAudioDevice: MediaDeviceInfo | null, currentDevices: CurrentDevices | null) => boolean;
10
- export declare const stopTracks: (requestedDevices: MediaStream) => void;
11
- export declare const prepareDeviceState: (stream: MediaStream | null, track: MediaStreamTrack | null, devices: MediaDeviceInfo[], error: DeviceError | null, shouldAsk: boolean) => DeviceState;
12
- export declare const getLocalStorageConfig: (deviceType: "audio" | "video") => PersistLastDeviceHandlers;
13
- //# sourceMappingURL=media.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGjG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAO,MAAM,oCAAoC,sBAC5B,OAAO,GAAG,qBAAqB,KACjD,OAAO,GAAG,qBAAqB,GAAG,SAKpC,CAAC;AAEF,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,eAAO,MAAM,aAAa,kBAAmB,MAAM,GAAG,IAAI,WAAW,eAAe,EAAE,KAAG,eAAe,GAAG,IACpB,CAAC;AAExF,eAAO,MAAM,yBAAyB,qBAClB,WAAW,oBACX,eAAe,EAAE,KAClC,cAcF,CAAC;AAEF,eAAO,MAAM,gCAAgC,eAC/B,eAAe,GAAG,IAAI,iBACnB,eAAe,GAAG,IAAI,mBAC2E,CAAC;AAEnH,eAAO,MAAM,mCAAmC,oBAC7B,eAAe,GAAG,IAAI,mBACtB,eAAe,GAAG,IAAI,kBACvB,cAAc,GAAG,IAAI,KACpC,OAMA,CAAC;AAEJ,eAAO,MAAM,UAAU,qBAAsB,WAAW,SAIvD,CAAC;AAQF,eAAO,MAAM,kBAAkB,WACrB,WAAW,GAAG,IAAI,SACnB,gBAAgB,GAAG,IAAI,WACrB,eAAe,EAAE,SACnB,WAAW,GAAG,IAAI,aACd,OAAO,KACjB,WAgBF,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,OAAO,GAAG,OAAO,KAAG,yBAMrE,CAAC"}
@@ -1,64 +0,0 @@
1
- import { loadObject, saveObject } from "./localStorage";
2
- export const removeSpecifiedDeviceFromConstraints = (trackConstraints) => {
3
- if (typeof trackConstraints === "object") {
4
- return { ...trackConstraints, deviceId: undefined };
5
- }
6
- return trackConstraints;
7
- };
8
- export const REQUESTING = "Requesting";
9
- export const NOT_REQUESTED = "Not requested";
10
- export const getDeviceInfo = (trackDeviceId, devices) => (trackDeviceId && devices.find(({ deviceId }) => trackDeviceId === deviceId)) || null;
11
- export const getCurrentDevicesSettings = (requestedDevices, mediaDeviceInfos) => {
12
- const currentDevices = { videoinput: null, audioinput: null };
13
- for (const track of requestedDevices.getTracks()) {
14
- const settings = track.getSettings();
15
- if (settings.deviceId) {
16
- const currentDevice = mediaDeviceInfos.find((device) => device.deviceId == settings.deviceId);
17
- const kind = currentDevice?.kind ?? null;
18
- if ((currentDevice && kind === "videoinput") || kind === "audioinput") {
19
- currentDevices[kind] = currentDevice ?? null;
20
- }
21
- }
22
- }
23
- return currentDevices;
24
- };
25
- export const isDeviceDifferentFromLastSession = (lastDevice, currentDevice) => lastDevice && (currentDevice?.deviceId !== lastDevice.deviceId || currentDevice?.label !== lastDevice?.label);
26
- export const isAnyDeviceDifferentFromLastSession = (lastVideoDevice, lastAudioDevice, currentDevices) => !!((currentDevices?.videoinput &&
27
- isDeviceDifferentFromLastSession(lastVideoDevice, currentDevices?.videoinput || null)) ||
28
- (currentDevices?.audioinput &&
29
- isDeviceDifferentFromLastSession(lastAudioDevice, currentDevices?.audioinput || null)));
30
- export const stopTracks = (requestedDevices) => {
31
- for (const track of requestedDevices.getTracks()) {
32
- track.stop();
33
- }
34
- };
35
- const prepareStatus = (requested, track) => {
36
- if (!requested)
37
- return ["Not requested", null];
38
- if (track)
39
- return ["OK", null];
40
- return ["Error", null];
41
- };
42
- export const prepareDeviceState = (stream, track, devices, error, shouldAsk) => {
43
- const deviceInfo = getDeviceInfo(track?.getSettings()?.deviceId || null, devices);
44
- const [devicesStatus, newError] = prepareStatus(shouldAsk, track);
45
- return {
46
- devices,
47
- devicesStatus,
48
- media: {
49
- stream: track ? stream : null,
50
- track: track,
51
- deviceInfo,
52
- enabled: !!track,
53
- },
54
- mediaStatus: devicesStatus,
55
- error: newError ?? error,
56
- };
57
- };
58
- export const getLocalStorageConfig = (deviceType) => {
59
- const key = `last-selected-${deviceType}-device`;
60
- return {
61
- getLastDevice: () => loadObject(key, null),
62
- saveLastDevice: (info) => saveObject(key, info),
63
- };
64
- };