@signalwire/js 3.12.0 → 3.12.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/core/src/BaseComponent.d.ts +3 -1
- package/dist/core/src/BaseComponent.d.ts.map +1 -1
- package/dist/core/src/RPCMessages/VertoMessages.d.ts +8 -0
- package/dist/core/src/RPCMessages/VertoMessages.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +1 -0
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/redux/features/session/sessionSaga.d.ts.map +1 -1
- package/dist/core/src/redux/features/session/sessionSelectors.d.ts +1 -0
- package/dist/core/src/redux/features/session/sessionSelectors.d.ts.map +1 -1
- package/dist/core/src/redux/features/session/sessionSlice.d.ts +65 -0
- package/dist/core/src/redux/features/session/sessionSlice.d.ts.map +1 -1
- package/dist/core/src/redux/interfaces.d.ts +2 -1
- package/dist/core/src/redux/interfaces.d.ts.map +1 -1
- package/dist/core/src/redux/rootReducer.d.ts +16 -0
- package/dist/core/src/redux/rootReducer.d.ts.map +1 -1
- package/dist/core/src/rooms/RoomSessionPlayback.d.ts +3 -0
- package/dist/core/src/rooms/RoomSessionPlayback.d.ts.map +1 -1
- package/dist/core/src/rooms/methods.d.ts +3 -0
- package/dist/core/src/rooms/methods.d.ts.map +1 -1
- package/dist/core/src/testUtils.d.ts.map +1 -1
- package/dist/core/src/types/common.d.ts +11 -0
- package/dist/core/src/types/common.d.ts.map +1 -1
- package/dist/core/src/types/videoPlayback.d.ts +5 -0
- package/dist/core/src/types/videoPlayback.d.ts.map +1 -1
- package/dist/core/src/types/videoRoomSession.d.ts +1 -0
- package/dist/core/src/types/videoRoomSession.d.ts.map +1 -1
- package/dist/core/src/utils/interfaces.d.ts +7 -5
- package/dist/core/src/utils/interfaces.d.ts.map +1 -1
- package/dist/index.esm.js +82 -3
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +80 -3
- package/dist/index.js.map +3 -3
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/BaseRoomSession.d.ts +5 -0
- package/dist/js/src/BaseRoomSession.d.ts.map +1 -1
- package/dist/js/src/RoomSession.d.ts +2 -2
- package/dist/js/src/RoomSession.d.ts.map +1 -1
- package/dist/js/src/RoomSession.docs.d.ts +21 -0
- package/dist/js/src/RoomSession.docs.d.ts.map +1 -1
- package/dist/js/src/features/mediaElements/mediaElementsSagas.d.ts.map +1 -1
- package/dist/js/src/utils/interfaces.d.ts +4 -0
- package/dist/js/src/utils/interfaces.d.ts.map +1 -1
- package/dist/js/src/utils/roomSession.d.ts +13 -0
- package/dist/js/src/utils/roomSession.d.ts.map +1 -0
- package/dist/js/src/utils/videoElement.d.ts +1 -0
- package/dist/js/src/utils/videoElement.d.ts.map +1 -1
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webrtc/src/BaseConnection.d.ts +8 -0
- package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
- package/dist/webrtc/src/utils/interfaces.d.ts +2 -0
- package/dist/webrtc/src/utils/interfaces.d.ts.map +1 -1
- package/dist/webrtc/src/utils/webrtcHelpers.native.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/BaseRoomSession.ts +4 -1
- package/src/RoomSession.docs.ts +20 -0
- package/src/RoomSession.ts +60 -3
- package/src/features/mediaElements/mediaElementsSagas.ts +10 -0
- package/src/utils/interfaces.ts +5 -0
- package/src/utils/roomSession.ts +54 -0
- package/src/utils/videoElement.ts +3 -0
package/src/RoomSession.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
UserOptions,
|
|
3
|
+
AssertSameType,
|
|
4
|
+
getLogger,
|
|
5
|
+
Authorization,
|
|
6
|
+
} from '@signalwire/core'
|
|
2
7
|
import { createClient } from './createClient'
|
|
3
|
-
import type { MakeRoomOptions } from './Client'
|
|
4
8
|
import { BaseRoomSession } from './BaseRoomSession'
|
|
5
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getJoinAudienceMediaParams,
|
|
11
|
+
isValidJoinAudienceMediaParams,
|
|
12
|
+
} from './utils/roomSession'
|
|
13
|
+
import type { MakeRoomOptions } from './Client'
|
|
14
|
+
import type { RoomSessionDocs } from './RoomSession.docs'
|
|
15
|
+
import type { RoomSessionJoinAudienceParams } from './utils/interfaces'
|
|
6
16
|
|
|
7
17
|
const VIDEO_CONSTRAINTS: MediaTrackConstraints = {
|
|
18
|
+
width: { ideal: 1280, min: 320 },
|
|
19
|
+
height: { ideal: 720, min: 180 },
|
|
8
20
|
aspectRatio: { ideal: 16 / 9 },
|
|
9
21
|
}
|
|
10
22
|
|
|
@@ -149,8 +161,53 @@ export const RoomSession = function (roomOptions: RoomSessionOptions) {
|
|
|
149
161
|
})
|
|
150
162
|
}
|
|
151
163
|
|
|
164
|
+
const joinAudience = (params?: RoomSessionJoinAudienceParams) => {
|
|
165
|
+
return new Promise(async (resolve, reject) => {
|
|
166
|
+
try {
|
|
167
|
+
// @ts-expect-error
|
|
168
|
+
room.attachPreConnectWorkers()
|
|
169
|
+
|
|
170
|
+
const session = await client.connect()
|
|
171
|
+
|
|
172
|
+
// @ts-expect-error
|
|
173
|
+
const authState: Authorization = session._sessionAuthState
|
|
174
|
+
const mediaOptions = getJoinAudienceMediaParams({
|
|
175
|
+
authState,
|
|
176
|
+
...params,
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
if (!isValidJoinAudienceMediaParams(mediaOptions)) {
|
|
180
|
+
await session.disconnect()
|
|
181
|
+
return reject(
|
|
182
|
+
new Error(
|
|
183
|
+
'[joinAudience] Either (or both) `audio` and `video` must be `true` when calling this method.'
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// @ts-expect-error
|
|
189
|
+
room.updateMediaOptions(mediaOptions)
|
|
190
|
+
|
|
191
|
+
room.once('room.subscribed', (payload) => {
|
|
192
|
+
// @ts-expect-error
|
|
193
|
+
room.attachOnSubscribedWorkers(payload)
|
|
194
|
+
resolve(room)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
await room.join()
|
|
198
|
+
} catch (error) {
|
|
199
|
+
getLogger().error('RoomSession JoinAudience', error)
|
|
200
|
+
// Disconnect the underlay client in case of media/signaling errors
|
|
201
|
+
client.disconnect()
|
|
202
|
+
|
|
203
|
+
reject(error)
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
152
208
|
const interceptors = {
|
|
153
209
|
join,
|
|
210
|
+
joinAudience,
|
|
154
211
|
} as const
|
|
155
212
|
|
|
156
213
|
return new Proxy<Omit<RoomSession, 'new'>>(room, {
|
|
@@ -42,6 +42,8 @@ export const makeVideoElementSaga = ({
|
|
|
42
42
|
* Instead of querying the `document`, let's use our `layerMap`.
|
|
43
43
|
*/
|
|
44
44
|
const localOverlay: LocalOverlay = {
|
|
45
|
+
// Each `layout.changed` event will update `status`
|
|
46
|
+
status: 'hidden',
|
|
45
47
|
get id() {
|
|
46
48
|
return addSDKPrefix(room.memberId)
|
|
47
49
|
},
|
|
@@ -67,6 +69,9 @@ export const makeVideoElementSaga = ({
|
|
|
67
69
|
if (!this.domElement) {
|
|
68
70
|
return getLogger().warn('Missing localOverlay to show')
|
|
69
71
|
}
|
|
72
|
+
if (this.status === 'hidden') {
|
|
73
|
+
return getLogger().info('localOverlay not visible')
|
|
74
|
+
}
|
|
70
75
|
this.domElement.style.opacity = '1'
|
|
71
76
|
},
|
|
72
77
|
}
|
|
@@ -161,6 +166,11 @@ export const makeAudioElementSaga = ({ speakerId }: { speakerId?: string }) => {
|
|
|
161
166
|
instance: room,
|
|
162
167
|
runSaga,
|
|
163
168
|
}: CustomSagaParams<RoomSessionConnection>): SagaIterator {
|
|
169
|
+
if (typeof Audio === 'undefined') {
|
|
170
|
+
getLogger().warn('`Audio` is not supported on this environment.')
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
|
|
164
174
|
try {
|
|
165
175
|
const audioEl = new Audio()
|
|
166
176
|
let audioTask: Task | undefined
|
package/src/utils/interfaces.ts
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getLogger } from '@signalwire/core'
|
|
2
|
+
import type { Authorization } from '@signalwire/core'
|
|
3
|
+
import type { RoomSessionJoinAudienceParams } from './interfaces'
|
|
4
|
+
|
|
5
|
+
// `joinAudience` utils
|
|
6
|
+
const getJoinAudienceMediaParams = ({
|
|
7
|
+
authState,
|
|
8
|
+
audio = true,
|
|
9
|
+
video = true,
|
|
10
|
+
}: RoomSessionJoinAudienceParams & {
|
|
11
|
+
authState: Authorization
|
|
12
|
+
}) => {
|
|
13
|
+
const getMediaValue = ({
|
|
14
|
+
remote,
|
|
15
|
+
local,
|
|
16
|
+
kind,
|
|
17
|
+
}: {
|
|
18
|
+
remote?: boolean
|
|
19
|
+
local?: boolean
|
|
20
|
+
kind: 'audio' | 'video'
|
|
21
|
+
}) => {
|
|
22
|
+
if (!remote && local) {
|
|
23
|
+
getLogger().warn(
|
|
24
|
+
`[joinAudience] ${kind} is currently not allowed on this room.`
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return !!(remote && local)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
audio: false,
|
|
33
|
+
video: false,
|
|
34
|
+
negotiateAudio: getMediaValue({
|
|
35
|
+
remote: authState.audio_allowed,
|
|
36
|
+
local: audio,
|
|
37
|
+
kind: 'audio',
|
|
38
|
+
}),
|
|
39
|
+
negotiateVideo: getMediaValue({
|
|
40
|
+
remote: authState.video_allowed,
|
|
41
|
+
local: video,
|
|
42
|
+
kind: 'video',
|
|
43
|
+
}),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const isValidJoinAudienceMediaParams = (
|
|
48
|
+
options: Record<string, boolean | undefined>
|
|
49
|
+
) => {
|
|
50
|
+
// At least one value must be true
|
|
51
|
+
return Object.values(options).some(Boolean)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { getJoinAudienceMediaParams, isValidJoinAudienceMediaParams }
|
|
@@ -70,6 +70,7 @@ const _buildLayer = ({ location }: { location: InternalVideoLayoutLayer }) => {
|
|
|
70
70
|
|
|
71
71
|
export interface LocalOverlay {
|
|
72
72
|
readonly id: string
|
|
73
|
+
status: 'hidden' | 'visible'
|
|
73
74
|
domElement: HTMLDivElement | undefined
|
|
74
75
|
hide(): void
|
|
75
76
|
show(): void
|
|
@@ -95,6 +96,8 @@ const makeLayoutChangedHandler =
|
|
|
95
96
|
const location = layers.find(({ member_id }) => member_id === myMemberId)
|
|
96
97
|
|
|
97
98
|
let myLayer = localOverlay.domElement
|
|
99
|
+
// Update localOverlay.status if a location has been found
|
|
100
|
+
localOverlay.status = location ? 'visible' : 'hidden'
|
|
98
101
|
if (!location) {
|
|
99
102
|
getLogger().debug('Location not found')
|
|
100
103
|
if (myLayer) {
|