@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 +1,7 @@
1
- import type { DeviceState, MediaManager, DeviceError, DeviceManagerStatus } from "./types/internal";
1
+ import type { DeviceError, DeviceManagerStatus, DeviceState, Media, MediaManager } from "./types/internal";
2
2
  import type TypedEmitter from "typed-emitter";
3
- import type { PersistLastDeviceHandlers } from "./types/public";
3
+ import type { PersistLastDeviceHandlers, TrackMiddleware } from "./types/public";
4
+ export type DeviceType = "audio" | "video";
4
5
  export type DeviceManagerEvents = {
5
6
  managerStarted: (event: DeviceState & {
6
7
  constraints: MediaTrackConstraints | undefined;
@@ -19,10 +20,11 @@ export type DeviceManagerEvents = {
19
20
  deviceStopped: (state: DeviceState) => void;
20
21
  deviceEnabled: (state: DeviceState) => void;
21
22
  deviceDisabled: (state: DeviceState) => void;
23
+ middlewareSet: (state: DeviceState) => void;
22
24
  error: (event: any, state: DeviceState) => void;
23
25
  };
24
26
  export type DeviceManagerConfig = {
25
- deviceType: "audio" | "video";
27
+ deviceType: DeviceType;
26
28
  defaultConstraints: MediaTrackConstraints;
27
29
  userConstraints?: boolean | MediaTrackConstraints;
28
30
  storage?: boolean | PersistLastDeviceHandlers;
@@ -30,26 +32,34 @@ export type DeviceManagerConfig = {
30
32
  declare const DeviceManager_base: new () => TypedEmitter<DeviceManagerEvents>;
31
33
  export declare class DeviceManager extends DeviceManager_base implements MediaManager {
32
34
  private readonly constraints;
33
- private readonly storageConfig;
34
35
  private status;
35
36
  private readonly deviceType;
36
- deviceState: DeviceState;
37
+ private readonly middlewareManager;
38
+ readonly getLastDevice: () => MediaDeviceInfo | null;
39
+ private readonly saveLastDevice;
40
+ private rawMedia;
41
+ private processedMediaTrack;
42
+ private media;
43
+ private mediaStatus;
44
+ private devices;
45
+ private devicesStatus;
46
+ private error;
37
47
  constructor({ deviceType, storage, userConstraints, defaultConstraints }: DeviceManagerConfig);
38
- private createStorageConfig;
48
+ getState(): DeviceState;
39
49
  getStatus(): DeviceManagerStatus;
40
50
  getConstraints(): MediaTrackConstraints | boolean;
41
- getMedia: () => import("./types/internal").Media | null;
42
- getTracks: () => MediaStreamTrack[];
43
- initialize: (stream: MediaStream | null, track: MediaStreamTrack | null, devices: MediaDeviceInfo[], requestedMedia: boolean, error?: DeviceError | null) => DeviceState;
44
- private setupOnEndedCallback;
45
- private onTrackEnded;
46
- getLastDevice(): MediaDeviceInfo | null;
47
- private saveLastDevice;
51
+ getDeviceType: () => DeviceType;
52
+ getMedia: () => Media | null;
53
+ initialize: (stream: MediaStream | null, track: MediaStreamTrack | null, devices: MediaDeviceInfo[], requestedMedia: boolean, error?: DeviceError | null) => void;
48
54
  start(deviceId?: string): Promise<void>;
49
- stop(): Promise<void>;
55
+ setTrackMiddleware(middleware: TrackMiddleware | null): Promise<void>;
56
+ getMiddleware(): TrackMiddleware | null;
57
+ stop(): void;
50
58
  disable(): void;
51
59
  enable(): void;
52
- getDeviceType: () => "audio" | "video";
60
+ private setEnable;
61
+ private updateMedia;
62
+ private setCurrentMedia;
53
63
  }
54
64
  export {};
55
65
  //# sourceMappingURL=DeviceManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceManager.d.ts","sourceRoot":"","sources":["../src/DeviceManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAKpG,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,CACd,KAAK,EAAE,WAAW,GAAG;QACnB,WAAW,EAAE,qBAAqB,GAAG,SAAS,CAAC;KAChD,EACD,KAAK,EAAE,WAAW,KACf,IAAI,CAAC;IACV,kBAAkB,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,cAAc,EAAE,CACd,KAAK,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAA;KAAE,EAC7E,KAAK,EAAE,WAAW,KACf,IAAI,CAAC;IACV,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1E,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACxF,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAE7C,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,KAAK,IAA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AS3E,aAAa,IAAI,eAAe,GAAG,IAAI;IAIvC,IAAI;IAUJ,OAAO;IAOP,MAAM;IAOb,OAAO,CAAC,SAAS,CAGf;IAEF,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,eAAe;CAaxB"}
@@ -1,31 +1,43 @@
1
1
  import { prepareMediaTrackConstraints } from "./constraints";
2
2
  import EventEmitter from "events";
3
- import { getDeviceInfo, getLocalStorageConfig, prepareDeviceState } from "./utils/media";
3
+ import { MiddlewareManager } from "./devices/MiddlewareManager";
4
+ import { createStorageConfig } from "./utils/localStorage";
5
+ import { setupOnEndedCallback } from "./utils/track";
4
6
  import { parseUserMediaError } from "./utils/errors";
7
+ const NOOP = () => { };
5
8
  export class DeviceManager extends EventEmitter {
6
9
  constraints;
7
- storageConfig;
8
10
  status = "uninitialized";
9
11
  deviceType;
10
- deviceState = {
11
- media: null,
12
- mediaStatus: "Not requested",
13
- devices: null,
14
- devicesStatus: "Not requested",
15
- error: null,
16
- };
12
+ middlewareManager = new MiddlewareManager();
13
+ getLastDevice = () => null;
14
+ saveLastDevice = NOOP;
15
+ rawMedia = null;
16
+ processedMediaTrack = null;
17
+ media = null;
18
+ mediaStatus = "Not requested";
19
+ devices = null;
20
+ devicesStatus = "Not requested";
21
+ error = null;
17
22
  constructor({ deviceType, storage, userConstraints, defaultConstraints }) {
18
23
  super();
19
- this.storageConfig = this.createStorageConfig(deviceType, storage);
24
+ const storageConfig = createStorageConfig(deviceType, storage);
25
+ if (storageConfig) {
26
+ this.getLastDevice = storageConfig.getLastDevice;
27
+ this.saveLastDevice = storageConfig.saveLastDevice;
28
+ }
20
29
  this.deviceType = deviceType;
21
30
  this.constraints = userConstraints ?? defaultConstraints;
22
31
  }
23
- createStorageConfig(deviceType, storage) {
24
- if (storage === false)
25
- return null;
26
- if (storage === true || storage === undefined)
27
- return getLocalStorageConfig(deviceType);
28
- return storage;
32
+ getState() {
33
+ return {
34
+ mediaStatus: this.mediaStatus,
35
+ devices: this.devices,
36
+ devicesStatus: this.devicesStatus,
37
+ error: this.error,
38
+ media: this.media,
39
+ currentMiddleware: this.middlewareManager.getMiddleware(),
40
+ };
29
41
  }
30
42
  getStatus() {
31
43
  return this.status;
@@ -33,60 +45,49 @@ export class DeviceManager extends EventEmitter {
33
45
  getConstraints() {
34
46
  return this.constraints;
35
47
  }
36
- getMedia = () => this.deviceState.media;
37
- getTracks = () => {
38
- const stream = this.deviceState.media?.stream;
39
- if (this.deviceType === "audio") {
40
- return stream?.getAudioTracks() ?? [];
41
- }
42
- return stream?.getVideoTracks() ?? [];
48
+ getDeviceType = () => {
49
+ return this.deviceType;
50
+ };
51
+ getMedia = () => {
52
+ return this.media;
43
53
  };
44
54
  initialize = (stream, track, devices, requestedMedia, error = null) => {
45
- this.deviceState = prepareDeviceState(stream, track, devices, error, requestedMedia);
46
- const deviceInfo = this.deviceState.media?.deviceInfo;
55
+ const deviceInfo = getDeviceInfo(track?.getSettings()?.deviceId || null, devices);
56
+ const [devicesStatus, newError] = prepareStatus(requestedMedia, track);
57
+ this.devices = devices;
58
+ this.devicesStatus = devicesStatus;
59
+ this.mediaStatus = devicesStatus;
60
+ this.error = newError ?? error;
61
+ this.updateMedia({
62
+ stream: track ? stream : null,
63
+ track,
64
+ deviceInfo,
65
+ enabled: Boolean(track?.enabled),
66
+ });
47
67
  if (deviceInfo)
48
- this.saveLastDevice(deviceInfo);
68
+ this.saveLastDevice?.(deviceInfo);
49
69
  this.status = "initialized";
50
- this.setupOnEndedCallback();
51
- this.emit("managerInitialized", this.deviceState);
52
- return this.deviceState;
53
- };
54
- setupOnEndedCallback() {
55
- if (this.deviceState?.media?.track) {
56
- this.deviceState.media.track.addEventListener("ended", async (event) => await this.onTrackEnded(event.target.id));
57
- }
58
- }
59
- onTrackEnded = async (trackId) => {
60
- if (trackId === this?.deviceState.media?.track?.id) {
61
- await this.stop();
70
+ if (track) {
71
+ setupOnEndedCallback(track, () => this?.rawMedia?.track?.id, async () => this.stop());
62
72
  }
73
+ this.emit("managerInitialized", this.getState());
63
74
  };
64
- getLastDevice() {
65
- return this.storageConfig?.getLastDevice?.() ?? null;
66
- }
67
- saveLastDevice(info) {
68
- this.storageConfig?.saveLastDevice(info);
69
- }
70
75
  async start(deviceId) {
71
- const newDeviceId = deviceId ?? this.getLastDevice()?.deviceId;
72
- const currentDeviceId = this.deviceState.media?.deviceInfo?.deviceId;
76
+ const newDeviceId = deviceId ?? this.getLastDevice?.()?.deviceId;
77
+ const currentDeviceId = this.rawMedia?.deviceInfo?.deviceId;
73
78
  const shouldReplaceDevice = Boolean(currentDeviceId && currentDeviceId !== newDeviceId);
74
79
  const isDeviceStopped = currentDeviceId === undefined;
75
80
  const shouldProceed = isDeviceStopped || shouldReplaceDevice;
76
81
  const exactConstraints = shouldProceed && prepareMediaTrackConstraints(newDeviceId, this.constraints);
77
82
  if (!exactConstraints)
78
83
  return;
79
- this.deviceState.mediaStatus = "Requesting";
80
- this.emit("devicesStarted", { ...this.deviceState, restarting: shouldReplaceDevice, constraints: exactConstraints }, this.deviceState);
84
+ this.mediaStatus = "Requesting";
85
+ this.emit("devicesStarted", { restarting: shouldReplaceDevice, constraints: exactConstraints }, this.getState());
81
86
  try {
82
87
  const stream = await navigator.mediaDevices.getUserMedia({ [this.deviceType]: exactConstraints });
83
- const getTrack = () => {
84
- const tracks = this.deviceType === "audio" ? stream.getAudioTracks() : stream.getVideoTracks();
85
- return tracks[0] ?? null;
86
- };
87
- const track = getTrack();
88
+ const track = getTrack(stream, this.deviceType);
88
89
  const currentDeviceId = track?.getSettings()?.deviceId;
89
- const deviceInfo = currentDeviceId ? getDeviceInfo(currentDeviceId, this.deviceState.devices ?? []) : null;
90
+ const deviceInfo = currentDeviceId ? getDeviceInfo(currentDeviceId, this.devices ?? []) : null;
90
91
  if (deviceInfo) {
91
92
  this.saveLastDevice?.(deviceInfo);
92
93
  }
@@ -103,17 +104,20 @@ export class DeviceManager extends EventEmitter {
103
104
  // The ended event in Safari has already been emitted and will be handled in the future.
104
105
  // Therefore, in the `onTrackEnded` method, events for already stopped tracks are filtered out to prevent the state from being damaged.
105
106
  if (shouldReplaceDevice) {
106
- this.deviceState?.media?.track?.stop();
107
+ this.rawMedia?.track?.stop();
108
+ this.processedMediaTrack?.stop();
107
109
  }
108
- this.deviceState.media = {
110
+ this.updateMedia({
109
111
  stream,
110
112
  track,
111
113
  deviceInfo,
112
- enabled: true,
113
- };
114
- this.setupOnEndedCallback();
115
- this.deviceState.mediaStatus = "OK";
116
- this.emit("devicesReady", { ...this.deviceState, restarted: shouldReplaceDevice }, this.deviceState);
114
+ enabled: Boolean(track?.enabled),
115
+ });
116
+ if (track) {
117
+ setupOnEndedCallback(track, () => this?.rawMedia?.track?.id, async () => this.stop());
118
+ }
119
+ this.mediaStatus = "OK";
120
+ this.emit("devicesReady", { ...this.getState(), restarted: shouldReplaceDevice }, this.getState());
117
121
  }
118
122
  catch (err) {
119
123
  const parsedError = parseUserMediaError(err);
@@ -122,33 +126,69 @@ export class DeviceManager extends EventEmitter {
122
126
  constraints: exactConstraints,
123
127
  };
124
128
  if (exactConstraints) {
125
- this.deviceState.error = parsedError;
129
+ this.error = parsedError;
126
130
  }
127
- this.emit("error", event, this.deviceState);
131
+ this.emit("error", event, this.getState());
128
132
  }
129
133
  }
130
- async stop() {
131
- this.deviceState.media?.track?.stop();
132
- this.deviceState.media = null;
133
- this.emit("deviceStopped", this.deviceState);
134
+ async setTrackMiddleware(middleware) {
135
+ const rawTrack = this.rawMedia?.track ?? null;
136
+ const processedMedia = this.middlewareManager.applyMiddleware(rawTrack, middleware);
137
+ this.setCurrentMedia(this.rawMedia, processedMedia);
138
+ this.emit("middlewareSet", this.getState());
139
+ }
140
+ getMiddleware() {
141
+ return this.middlewareManager.getMiddleware();
142
+ }
143
+ stop() {
144
+ this.middlewareManager.clearMiddleware();
145
+ this.processedMediaTrack?.stop();
146
+ this.rawMedia?.track?.stop();
147
+ this.updateMedia(null);
148
+ this.emit("deviceStopped", this.getState());
134
149
  }
135
150
  disable() {
136
- if (!this.deviceState.media || !this.deviceState.media?.track) {
137
- return;
138
- }
139
- this.deviceState.media.track.enabled = false;
140
- this.deviceState.media.enabled = false;
141
- this.emit("deviceDisabled", this.deviceState);
151
+ this.setEnable(this.rawMedia?.track ?? null, false);
152
+ this.setEnable(this.processedMediaTrack, false);
153
+ this.emit("deviceDisabled", this.getState());
142
154
  }
143
155
  enable() {
144
- if (!this.deviceState.media || !this.deviceState.media?.track) {
145
- return;
146
- }
147
- this.deviceState.media.track.enabled = true;
148
- this.deviceState.media.enabled = true;
149
- this.emit("deviceEnabled", this.deviceState);
156
+ this.setEnable(this.rawMedia?.track ?? null, true);
157
+ this.setEnable(this.processedMediaTrack, true);
158
+ this.emit("deviceEnabled", this.getState());
150
159
  }
151
- getDeviceType = () => {
152
- return this.deviceType;
160
+ setEnable = (track, value) => {
161
+ if (!track)
162
+ return;
163
+ track.enabled = value;
153
164
  };
165
+ updateMedia(media) {
166
+ this.rawMedia = !media ? null : { ...media };
167
+ const processedMedia = this.middlewareManager.applyMiddleware(media?.track ?? null);
168
+ this.setCurrentMedia(this.rawMedia, processedMedia);
169
+ }
170
+ setCurrentMedia(media, processedTrack) {
171
+ this.processedMediaTrack = processedTrack;
172
+ const streamTrack = processedTrack ? { track: processedTrack, stream: new MediaStream([processedTrack]) } : media;
173
+ this.media = streamTrack
174
+ ? {
175
+ ...streamTrack,
176
+ enabled: Boolean(streamTrack.track?.enabled),
177
+ deviceInfo: this.rawMedia?.deviceInfo ?? null,
178
+ }
179
+ : null;
180
+ }
181
+ }
182
+ function getDeviceInfo(trackDeviceId, devices) {
183
+ return (trackDeviceId && devices.find(({ deviceId }) => trackDeviceId === deviceId)) || null;
184
+ }
185
+ function getTrack(stream, deviceType) {
186
+ return (deviceType === "audio" ? stream?.getAudioTracks()?.[0] : stream?.getVideoTracks()?.[0]) ?? null;
187
+ }
188
+ function prepareStatus(requested, track) {
189
+ if (!requested)
190
+ return ["Not requested", null];
191
+ if (track)
192
+ return ["OK", null];
193
+ return ["Error", null];
154
194
  }
@@ -0,0 +1,9 @@
1
+ import type { TrackMiddleware } from "../types/public";
2
+ export declare class MiddlewareManager {
3
+ private middleware;
4
+ private clearMiddlewareFn;
5
+ getMiddleware(): TrackMiddleware | null;
6
+ clearMiddleware(): void;
7
+ applyMiddleware(rawTrack: MediaStreamTrack | null, middleware?: TrackMiddleware | null): MediaStreamTrack | null;
8
+ }
9
+ //# sourceMappingURL=MiddlewareManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MiddlewareManager.d.ts","sourceRoot":"","sources":["../../src/devices/MiddlewareManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,iBAAiB,CAA6B;IAE/C,aAAa,IAAI,eAAe,GAAG,IAAI;IAIvC,eAAe;IAKf,eAAe,CACpB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,UAAU,GAAE,eAAe,GAAG,IAAsB,GACnD,gBAAgB,GAAG,IAAI;CAmB3B"}
@@ -0,0 +1,26 @@
1
+ import { setupOnEndedCallback } from "../utils/track";
2
+ export class MiddlewareManager {
3
+ middleware = null;
4
+ clearMiddlewareFn = null;
5
+ getMiddleware() {
6
+ return this.middleware;
7
+ }
8
+ clearMiddleware() {
9
+ this.clearMiddlewareFn?.();
10
+ this.clearMiddlewareFn = null;
11
+ }
12
+ applyMiddleware(rawTrack, middleware = this.middleware) {
13
+ this.middleware = middleware;
14
+ this.clearMiddleware();
15
+ if (!rawTrack || !middleware)
16
+ return null;
17
+ const { onClear, track } = middleware(rawTrack);
18
+ if (onClear)
19
+ this.clearMiddlewareFn = onClear;
20
+ setupOnEndedCallback(track, () => track.id, async () => {
21
+ this.clearMiddleware();
22
+ track.stop();
23
+ });
24
+ return track;
25
+ }
26
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"fishjamProvider.d.ts","sourceRoot":"","sources":["../src/fishjamProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,UAAU,oBAAqB,SAAQ,iBAAiB;IACtD,SAAS,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;IAC9D,iBAAiB,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC;CACzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,EAAE,oBAAoB,2CAsD5G"}
1
+ {"version":3,"file":"fishjamProvider.d.ts","sourceRoot":"","sources":["../src/fishjamProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,UAAU,oBAAqB,SAAQ,iBAAiB;IACtD,SAAS,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;IAC9D,iBAAiB,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC;CACzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,EAAE,oBAAoB,2CAuD5G"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useRef, useState } from "react";
2
+ import { useRef } from "react";
3
3
  import { useTrackManager } from "./hooks/useTrackManager";
4
4
  import { FishjamClient } from "@fishjam-cloud/ts-client";
5
5
  import { FishjamContext } from "./hooks/useFishjamContext";
@@ -7,6 +7,7 @@ import { DeviceManager } from "./DeviceManager";
7
7
  import { usePeerStatus } from "./hooks/usePeerStatus";
8
8
  import { useFishjamClientState } from "./hooks/useFishjamClientState";
9
9
  import { AUDIO_TRACK_CONSTRAINTS, VIDEO_TRACK_CONSTRAINTS } from "./constraints";
10
+ import { useScreenShareManager } from "./hooks/useScreenShare";
10
11
  /**
11
12
  * @category Components
12
13
  */
@@ -26,7 +27,6 @@ export function FishjamProvider({ children, reconnect, constraints, persistLastD
26
27
  userConstraints: constraints?.audio,
27
28
  storage,
28
29
  }));
29
- const screenShareState = useState({ stream: null, trackIds: null });
30
30
  const { peerStatus, getCurrentPeerStatus } = usePeerStatus(fishjamClientRef.current);
31
31
  const videoTrackManager = useTrackManager({
32
32
  mediaManager: videoDeviceManagerRef.current,
@@ -38,11 +38,12 @@ export function FishjamProvider({ children, reconnect, constraints, persistLastD
38
38
  tsClient: fishjamClientRef.current,
39
39
  getCurrentPeerStatus,
40
40
  });
41
+ const screenShareManager = useScreenShareManager({ fishjamClient: fishjamClientRef.current });
41
42
  const clientState = useFishjamClientState(fishjamClientRef.current);
42
43
  const context = {
43
44
  fishjamClientRef,
44
45
  peerStatus,
45
- screenShareState,
46
+ screenShareManager,
46
47
  videoTrackManager,
47
48
  audioTrackManager,
48
49
  videoDeviceManagerRef,
@@ -1 +1 @@
1
- {"version":3,"file":"useDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useDeviceManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AAc9E,eAAO,MAAM,gBAAgB,kBAAmB,aAAa,uBAoC5D,CAAC"}
1
+ {"version":3,"file":"useDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useDeviceManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AAe9E,eAAO,MAAM,gBAAgB,kBAAmB,aAAa,uBAmC5D,CAAC"}
@@ -9,6 +9,7 @@ const eventNames = [
9
9
  "devicesReady",
10
10
  "managerInitialized",
11
11
  "error",
12
+ "middlewareSet",
12
13
  ];
13
14
  export const useDeviceManager = (deviceManager) => {
14
15
  const mutationRef = useRef(false);
@@ -26,9 +27,8 @@ export const useDeviceManager = (deviceManager) => {
26
27
  const getSnapshot = useCallback(() => {
27
28
  if (mutationRef.current || lastSnapshotRef.current === null) {
28
29
  lastSnapshotRef.current = {
29
- deviceState: deviceManager.deviceState,
30
+ deviceState: deviceManager.getState(),
30
31
  status: deviceManager.getStatus(),
31
- tracks: deviceManager.getTracks(),
32
32
  };
33
33
  mutationRef.current = false;
34
34
  }
@@ -16,4 +16,4 @@ export declare function useMicrophone(): AudioDevice;
16
16
  export declare const useInitializeDevices: () => {
17
17
  initializeDevices: () => Promise<void>;
18
18
  };
19
- //# sourceMappingURL=useDevices.d.ts.map
19
+ //# sourceMappingURL=devices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/hooks/devices.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAK3D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAyBlC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,WAAW,CA2B3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAqDhC,CAAC"}
@@ -1,20 +1,18 @@
1
1
  import { useFishjamContext } from "./useFishjamContext";
2
- import { useVideoDeviceManager } from "./deviceManagers/useVideoDeviceManager";
3
- import { useAudioDeviceManager } from "./deviceManagers/useAudioDeviceManager";
4
2
  import { useCallback } from "react";
3
+ import { useDeviceManager } from "./deviceManagers/useDeviceManager";
5
4
  import { getAvailableMedia, getCorrectedResult } from "../mediaInitializer";
6
- import { useProcessedPreviewStream } from "./useProcessedPreviewStream";
7
5
  import { prepareConstraints } from "../constraints";
8
6
  /**
9
7
  *
10
8
  * @category Devices
11
9
  */
12
10
  export function useCamera() {
13
- const { videoTrackManager } = useFishjamContext();
14
- const { deviceState, status } = useVideoDeviceManager();
11
+ const { videoTrackManager, videoDeviceManagerRef } = useFishjamContext();
12
+ const { deviceState, status } = useDeviceManager(videoDeviceManagerRef.current);
15
13
  const { currentTrack, ...trackManager } = videoTrackManager;
16
- const processedPreviewStream = useProcessedPreviewStream(videoTrackManager, deviceState.media?.track);
17
- const stream = currentTrack?.stream ?? processedPreviewStream ?? deviceState.media?.stream ?? null;
14
+ const stream = deviceState.media?.stream ?? null;
15
+ const currentMiddleware = deviceState.currentMiddleware ?? null;
18
16
  const isStreaming = Boolean(currentTrack?.stream);
19
17
  const track = stream?.getAudioTracks()[0] ?? null;
20
18
  const trackId = currentTrack?.trackId ?? null;
@@ -22,12 +20,13 @@ export function useCamera() {
22
20
  const activeDevice = deviceState.media?.deviceInfo ?? null;
23
21
  return {
24
22
  ...trackManager,
23
+ currentMiddleware,
25
24
  status,
26
25
  stream,
26
+ track,
27
27
  devices,
28
28
  activeDevice,
29
29
  isStreaming,
30
- track,
31
30
  trackId,
32
31
  };
33
32
  }
@@ -36,11 +35,11 @@ export function useCamera() {
36
35
  * @category Devices
37
36
  */
38
37
  export function useMicrophone() {
39
- const { audioTrackManager } = useFishjamContext();
40
- const { deviceState, status } = useAudioDeviceManager();
38
+ const { audioTrackManager, audioDeviceManagerRef } = useFishjamContext();
39
+ const { deviceState, status } = useDeviceManager(audioDeviceManagerRef.current);
41
40
  const { currentTrack, ...trackManager } = audioTrackManager;
42
- const processedPreviewStream = useProcessedPreviewStream(audioTrackManager, deviceState.media?.track);
43
- const stream = currentTrack?.stream ?? processedPreviewStream ?? deviceState.media?.stream ?? null;
41
+ const stream = deviceState.media?.stream ?? null;
42
+ const currentMiddleware = deviceState.currentMiddleware ?? null;
44
43
  const isStreaming = Boolean(currentTrack?.stream);
45
44
  const track = stream?.getAudioTracks()[0] ?? null;
46
45
  const trackId = currentTrack?.trackId ?? null;
@@ -49,10 +48,11 @@ export function useMicrophone() {
49
48
  const isAudioPlaying = currentTrack?.vadStatus === "speech";
50
49
  return {
51
50
  ...trackManager,
51
+ currentMiddleware,
52
52
  status,
53
53
  stream,
54
- isStreaming,
55
54
  track,
55
+ isStreaming,
56
56
  trackId,
57
57
  devices,
58
58
  activeDevice,
@@ -1,6 +1,6 @@
1
1
  export { useConnect, useDisconnect } from "./useConnection";
2
2
  export { useReconnection } from "./useReconnection";
3
- export { useCamera, useMicrophone, useInitializeDevices } from "./useDevices";
3
+ export { useCamera, useMicrophone, useInitializeDevices } from "./devices";
4
4
  export { usePeers } from "./usePeers";
5
5
  export { useScreenShare } from "./useScreenShare";
6
6
  export { useStatus } from "./useStatus";
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/hooks/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/hooks/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { useConnect, useDisconnect } from "./useConnection";
2
2
  export { useReconnection } from "./useReconnection";
3
- export { useCamera, useMicrophone, useInitializeDevices } from "./useDevices";
3
+ export { useCamera, useMicrophone, useInitializeDevices } from "./devices";
4
4
  export { usePeers } from "./usePeers";
5
5
  export { useScreenShare } from "./useScreenShare";
6
6
  export { useStatus } from "./useStatus";
@@ -1,15 +1,15 @@
1
1
  import type { FishjamClient } from "@fishjam-cloud/ts-client";
2
2
  import { type MutableRefObject } from "react";
3
- import type { PeerMetadata, TrackMetadata, ScreenShareState, TrackManager } from "../types/internal";
3
+ import type { PeerMetadata, TrackMetadata, TrackManager } from "../types/internal";
4
4
  import type { DeviceManager } from "../DeviceManager";
5
5
  import type { FishjamClientState } from "./useFishjamClientState";
6
- import type { PeerStatus } from "../types/public";
6
+ import type { PeerStatus, ScreenshareApi } from "../types/public";
7
7
  export type FishjamContextType = {
8
8
  fishjamClientRef: MutableRefObject<FishjamClient<PeerMetadata, TrackMetadata>>;
9
9
  videoDeviceManagerRef: MutableRefObject<DeviceManager>;
10
10
  audioDeviceManagerRef: MutableRefObject<DeviceManager>;
11
11
  hasDevicesBeenInitializedRef: MutableRefObject<boolean>;
12
- screenShareState: [ScreenShareState, React.Dispatch<React.SetStateAction<ScreenShareState>>];
12
+ screenShareManager: ScreenshareApi;
13
13
  peerStatus: PeerStatus;
14
14
  videoTrackManager: TrackManager;
15
15
  audioTrackManager: TrackManager;
@@ -1 +1 @@
1
- {"version":3,"file":"useFishjamContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAiB,KAAK,gBAAgB,EAAc,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAC/E,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACvD,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACvD,4BAA4B,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD,gBAAgB,EAAE,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7F,UAAU,EAAE,UAAU,CAAC;IACvB,iBAAiB,EAAE,YAAY,CAAC;IAChC,iBAAiB,EAAE,YAAY,CAAC;IAChC,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,cAAc,oDAAiD,CAAC;AAE7E,wBAAgB,iBAAiB,IAGb,kBAAkB,CACrC"}
1
+ {"version":3,"file":"useFishjamContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAiB,KAAK,gBAAgB,EAAc,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAC/E,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACvD,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACvD,4BAA4B,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD,kBAAkB,EAAE,cAAc,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,iBAAiB,EAAE,YAAY,CAAC;IAChC,iBAAiB,EAAE,YAAY,CAAC;IAChC,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,cAAc,oDAAiD,CAAC;AAE7E,wBAAgB,iBAAiB,IAGb,kBAAkB,CACrC"}
@@ -1,7 +1,15 @@
1
+ import type { FishjamClient } from "@fishjam-cloud/ts-client";
1
2
  import type { ScreenshareApi } from "../types/public";
3
+ import type { PeerMetadata, TrackMetadata } from "../types/internal";
4
+ interface ScreenShareManagerProps {
5
+ fishjamClient: FishjamClient<PeerMetadata, TrackMetadata>;
6
+ }
2
7
  /**
3
8
  *
4
9
  * @category Screenshare
5
10
  */
11
+ export declare const useScreenShareManager: ({ fishjamClient }: ScreenShareManagerProps) => ScreenshareApi;
6
12
  export declare const useScreenShare: () => ScreenshareApi;
13
+ export declare const getTracksFromStream: (stream: MediaStream) => [MediaStreamTrack, MediaStreamTrack | null];
14
+ export {};
7
15
  //# sourceMappingURL=useScreenShare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQxE;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,cA0IjC,CAAC"}
1
+ {"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAoB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvF,UAAU,uBAAuB;IAC/B,aAAa,EAAE,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;CAC3D;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,sBAAuB,uBAAuB,KAAG,cAmIlF,CAAC;AAEF,eAAO,MAAM,cAAc,sBAI1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAY,WAAW,KAAG,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAKnG,CAAC"}