From 18e5312874514b056d6dd69a3cb36fd5a8113da2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:31:13 +0530 Subject: [PATCH 1/9] build(deps): bump ip from 2.0.0 to 2.0.1 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ab9b566b89..351693336e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10800,9 +10800,9 @@ invariant@^2.2.4: loose-envify "^1.0.0" ip@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" - integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== + version "2.0.1" + resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" + integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== ipaddr.js@1.9.1: version "1.9.1" From 4b850fd13952badb7357719c8a30f96f31e3e031 Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Wed, 21 Feb 2024 12:01:26 +0530 Subject: [PATCH 2/9] fix: focus on rerenders --- .../src/Prebuilt/components/Chat/ChatFooter.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx b/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx index 9de8f5c935..93c4b20fd3 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx @@ -92,9 +92,13 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo if (!selectedPeer.id && !selectedRole && !['Everyone', ''].includes(defaultSelection)) { setRoleSelector(defaultSelection); } else { - inputRef.current?.focus(); + // @ts-ignore + if (!elements?.chat?.disable_autofocus) { + inputRef.current?.focus(); + } } - }, [defaultSelection, selectedPeer, selectedRole, setRoleSelector]); + // @ts-ignore + }, [defaultSelection, elements?.chat?.disable_autofocus, selectedPeer, selectedRole, setRoleSelector]); const sendMessage = useCallback(async () => { const message = inputRef?.current?.value; if (!message || !message.trim().length) { From 19450a7366ee99cc554f0867d01758e2a07505ff Mon Sep 17 00:00:00 2001 From: Ravi theja Date: Wed, 21 Feb 2024 16:49:04 +0530 Subject: [PATCH 3/9] fix: typo in hipaa flag --- packages/hms-video-store/src/interfaces/room.ts | 2 +- packages/hms-video-store/src/reactive-store/adapter.ts | 2 +- packages/hms-video-store/src/schema/room.ts | 2 +- packages/hms-video-store/src/sdk/models/HMSRoom.ts | 2 +- packages/hms-video-store/src/signal/init/models.ts | 2 +- packages/hms-video-store/src/transport/index.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/hms-video-store/src/interfaces/room.ts b/packages/hms-video-store/src/interfaces/room.ts index 2458c35b9a..4a7cad0c5b 100644 --- a/packages/hms-video-store/src/interfaces/room.ts +++ b/packages/hms-video-store/src/interfaces/room.ts @@ -41,7 +41,7 @@ export interface HMSRoom { * @alpha */ effectsKey?: string; - isHippaEnabled?: boolean; + isHipaaEnabled?: boolean; isNoiseCancellationEnabled?: boolean; } diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index b8c48226f2..6d63e78958 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -157,7 +157,7 @@ export class SDKToHMS { isLargeRoom: sdkRoom.large_room_optimization, isEffectsEnabled: sdkRoom.isEffectsEnabled, effectsKey: sdkRoom.effectsKey, - isHippaEnabled: sdkRoom.isHippaEnabled, + isHipaaEnabled: sdkRoom.isHipaaEnabled, isNoiseCancellationEnabled: sdkRoom.isNoiseCancellationEnabled, }; } diff --git a/packages/hms-video-store/src/schema/room.ts b/packages/hms-video-store/src/schema/room.ts index 49945d00ec..831b23edbb 100644 --- a/packages/hms-video-store/src/schema/room.ts +++ b/packages/hms-video-store/src/schema/room.ts @@ -40,6 +40,6 @@ export interface HMSRoom { isLargeRoom?: boolean; isEffectsEnabled?: boolean; effectsKey?: string; - isHippaEnabled?: boolean; + isHipaaEnabled?: boolean; isNoiseCancellationEnabled?: boolean; } diff --git a/packages/hms-video-store/src/sdk/models/HMSRoom.ts b/packages/hms-video-store/src/sdk/models/HMSRoom.ts index 6ad524bed3..65063d5157 100644 --- a/packages/hms-video-store/src/sdk/models/HMSRoom.ts +++ b/packages/hms-video-store/src/sdk/models/HMSRoom.ts @@ -22,7 +22,7 @@ export default class Room implements HMSRoom { * @alpha */ effectsKey?: string; - isHippaEnabled?: boolean; + isHipaaEnabled?: boolean; isNoiseCancellationEnabled?: boolean; constructor(id: string) { diff --git a/packages/hms-video-store/src/signal/init/models.ts b/packages/hms-video-store/src/signal/init/models.ts index 1d6d02df13..75e6b12c02 100644 --- a/packages/hms-video-store/src/signal/init/models.ts +++ b/packages/hms-video-store/src/signal/init/models.ts @@ -58,6 +58,6 @@ export enum InitFlags { FLAG_DISABLE_VIDEO_TRACK_AUTO_UNSUBSCRIBE = 'disableVideoTrackAutoUnsubscribe', FLAG_WHITEBOARD_ENABLED = 'whiteboardEnabled', FLAG_EFFECTS_SDK_ENABLED = 'effectsSDKEnabled', - FLAG_HIPPA_ENABLED = 'hippa', + FLAG_HIPAA_ENABLED = 'hipaa', FLAG_NOISE_CANCELLATION = 'noiseCancellation', } diff --git a/packages/hms-video-store/src/transport/index.ts b/packages/hms-video-store/src/transport/index.ts index 6bdf41d8d2..6646bcb1d3 100644 --- a/packages/hms-video-store/src/transport/index.ts +++ b/packages/hms-video-store/src/transport/index.ts @@ -911,7 +911,7 @@ export default class HMSTransport { if (room) { room.effectsKey = this.initConfig.config.vb?.effectsKey; room.isEffectsEnabled = this.isFlagEnabled(InitFlags.FLAG_EFFECTS_SDK_ENABLED); - room.isHippaEnabled = this.isFlagEnabled(InitFlags.FLAG_HIPPA_ENABLED); + room.isHipaaEnabled = this.isFlagEnabled(InitFlags.FLAG_HIPAA_ENABLED); room.isNoiseCancellationEnabled = this.isFlagEnabled(InitFlags.FLAG_NOISE_CANCELLATION); } this.analyticsTimer.end(TimedEvent.INIT); From ca61b6d96e842e3184359de29f9e7e487fa60472 Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Wed, 21 Feb 2024 17:31:00 +0530 Subject: [PATCH 4/9] fix: display for empty chat image (#2575) --- .../roomkit-react/src/Prebuilt/components/Chat/EmptyChat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Chat/EmptyChat.tsx b/packages/roomkit-react/src/Prebuilt/components/Chat/EmptyChat.tsx index e32c4f940c..930c2805a0 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Chat/EmptyChat.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Chat/EmptyChat.tsx @@ -34,7 +34,7 @@ export const EmptyChat = () => { > - Empty Chat + Empty Chat From e922bd95b5740cd2028bc8a83abc8246c189c772 Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Wed, 21 Feb 2024 17:53:11 +0530 Subject: [PATCH 5/9] fix: truncation limit for room title (#2578) --- .../src/Prebuilt/components/Header/RoomDetailsHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Header/RoomDetailsHeader.tsx b/packages/roomkit-react/src/Prebuilt/components/Header/RoomDetailsHeader.tsx index 67b370223a..0e3ffe7835 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Header/RoomDetailsHeader.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Header/RoomDetailsHeader.tsx @@ -13,7 +13,7 @@ import { SHEET_OPTIONS, SIDE_PANE_OPTIONS } from '../../common/constants'; export const RoomDetailsHeader = () => { const { title, description } = useRoomLayoutHeader(); const isMobile = useMedia(cssConfig.media.md); - const clipLength = 80; + const clipLength = 30; const toggleDetailsPane = useSidepaneToggle(SIDE_PANE_OPTIONS.ROOM_DETAILS); const toggleDetailsSheet = useSheetToggle(SHEET_OPTIONS.ROOM_DETAILS); From af5ed703b4af62f1f65df25438b669798ea89d8e Mon Sep 17 00:00:00 2001 From: "Eswar Prasad Clinton. A" <64120992+eswarclynn@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:48:35 +0530 Subject: [PATCH 6/9] revert: "fix: upgrade ua-parser-js to track correct mac os version" --- packages/hms-video-store/package.json | 3 ++- .../hms-video-store/src/analytics/AnalyticsEvent.ts | 4 ++-- .../src/analytics/HTTPAnalyticsTransport.ts | 13 +++++-------- packages/hms-video-store/src/sdk/index.ts | 8 ++++---- packages/hms-video-store/src/sdk/store/Store.ts | 6 +++--- .../hms-video-store/src/signal/init/init.test.ts | 8 ++++---- packages/hms-video-store/src/transport/index.ts | 12 ++---------- packages/hms-video-store/src/utils/support.ts | 2 +- packages/hms-video-store/src/utils/user-agent.ts | 12 ++++-------- .../roomkit-react/src/Prebuilt/common/constants.ts | 9 ++++----- yarn.lock | 13 +++++++++---- 11 files changed, 40 insertions(+), 50 deletions(-) diff --git a/packages/hms-video-store/package.json b/packages/hms-video-store/package.json index 86dbeb3f86..b094248bd6 100644 --- a/packages/hms-video-store/package.json +++ b/packages/hms-video-store/package.json @@ -51,7 +51,7 @@ "lodash.isequal": "^4.5.0", "reselect": "4.0.0", "sdp-transform": "^2.14.1", - "ua-parser-js": "^2.0.0-beta.2", + "ua-parser-js": "^1.0.1", "uuid": "^8.3.2", "webrtc-adapter": "^8.0.0", "zustand": "3.5.7" @@ -60,6 +60,7 @@ "@types/dom-screen-wake-lock": "^1.0.1", "@types/lodash.isequal": "^4.5.8", "@types/sdp-transform": "^2.4.4", + "@types/ua-parser-js": "^0.7.36", "@types/uuid": "^8.3.0", "jest-canvas-mock": "^2.3.1", "jsdom-worker": "^0.3.0", diff --git a/packages/hms-video-store/src/analytics/AnalyticsEvent.ts b/packages/hms-video-store/src/analytics/AnalyticsEvent.ts index ddf1aa722a..c31174b846 100644 --- a/packages/hms-video-store/src/analytics/AnalyticsEvent.ts +++ b/packages/hms-video-store/src/analytics/AnalyticsEvent.ts @@ -38,9 +38,10 @@ export default class AnalyticsEvent implements ISignalParamsProvider (this.metadata.userAgent = userAgent)); } toSignalParams() { diff --git a/packages/hms-video-store/src/analytics/HTTPAnalyticsTransport.ts b/packages/hms-video-store/src/analytics/HTTPAnalyticsTransport.ts index 5f2059b0a3..e53d020775 100644 --- a/packages/hms-video-store/src/analytics/HTTPAnalyticsTransport.ts +++ b/packages/hms-video-store/src/analytics/HTTPAnalyticsTransport.ts @@ -66,16 +66,13 @@ class ClientAnalyticsTransport implements IAnalyticsTransportProvider { }, }; const url = this.env === ENV.PROD ? CLIENT_ANAYLTICS_PROD_ENDPOINT : CLIENT_ANAYLTICS_QA_ENDPOINT; - const headers = new Headers({ - 'Content-Type': 'application/json', - Authorization: `Bearer ${event.metadata.token}`, - }); - if (event.metadata.userAgent) { - headers.set('user_agent_v2', event.metadata.userAgent); - } fetch(url, { method: 'POST', - headers, + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${event.metadata.token}`, + user_agent_v2: event.metadata.userAgent, + }, body: JSON.stringify(requestBody), }) .then(response => { diff --git a/packages/hms-video-store/src/sdk/index.ts b/packages/hms-video-store/src/sdk/index.ts index 526e349d18..f5c263a5d4 100644 --- a/packages/hms-video-store/src/sdk/index.ts +++ b/packages/hms-video-store/src/sdk/index.ts @@ -361,7 +361,7 @@ export class HMSSdk implements HMSInterface { } this.analyticsTimer.start(TimedEvent.PREVIEW); - await this.setUpPreview(config, listener); + this.setUpPreview(config, listener); // Request permissions and populate devices before waiting for policy if (config.alwaysRequestPermissions) { @@ -517,7 +517,7 @@ export class HMSSdk implements HMSInterface { this.removeDevicesFromConfig(config); this.store.setConfig(config); /** set after config since we need config to get env for user agent */ - await this.store.createAndSetUserAgent(this.frameworkInfo); + this.store.createAndSetUserAgent(this.frameworkInfo); HMSAudioContextHandler.resumeContext(); // acquire screen lock to stay awake while in call const storeConfig = this.store.getConfig(); @@ -1239,7 +1239,7 @@ export class HMSSdk implements HMSInterface { * @param {HMSConfig} config * @param {HMSPreviewListener} listener */ - private async setUpPreview(config: HMSPreviewConfig, listener: HMSPreviewListener) { + private setUpPreview(config: HMSPreviewConfig, listener: HMSPreviewListener) { this.listener = listener as unknown as HMSUpdateListener; this.sdkState.isPreviewCalled = true; this.sdkState.isPreviewInProgress = true; @@ -1247,7 +1247,7 @@ export class HMSSdk implements HMSInterface { this.commonSetup(config, roomId, listener); this.store.setConfig(config); /** set after config since we need config to get env for user agent */ - await this.store.createAndSetUserAgent(this.frameworkInfo); + this.store.createAndSetUserAgent(this.frameworkInfo); this.createAndAddLocalPeerToStore(config, role, userId, config.asRole); } diff --git a/packages/hms-video-store/src/sdk/store/Store.ts b/packages/hms-video-store/src/sdk/store/Store.ts index aea6fb4393..88d98da715 100644 --- a/packages/hms-video-store/src/sdk/store/Store.ts +++ b/packages/hms-video-store/src/sdk/store/Store.ts @@ -47,7 +47,7 @@ class Store { private roleDetailsArrived = false; private env: ENV = ENV.PROD; private simulcastEnabled = false; - private userAgent?: string; + private userAgent: string = createUserAgent(this.env); private polls = new Map(); private whiteboards = new Map(); @@ -188,8 +188,8 @@ class Store { return this.userAgent; } - async createAndSetUserAgent(frameworkInfo?: HMSFrameworkInfo) { - this.userAgent = await createUserAgent(this.env, frameworkInfo); + createAndSetUserAgent(frameworkInfo?: HMSFrameworkInfo) { + this.userAgent = createUserAgent(this.env, frameworkInfo); } setRoom(room: HMSRoom) { diff --git a/packages/hms-video-store/src/signal/init/init.test.ts b/packages/hms-video-store/src/signal/init/init.test.ts index 359c4ae666..a987765d47 100644 --- a/packages/hms-video-store/src/signal/init/init.test.ts +++ b/packages/hms-video-store/src/signal/init/init.test.ts @@ -3,8 +3,8 @@ import { HMSException } from '../../error/HMSException'; import { ENV } from '../../utils/support'; import { createUserAgent } from '../../utils/user-agent'; -describe('getUrl', async () => { - const userAgent = await createUserAgent(ENV.PROD); +describe('getUrl', () => { + const userAgent = createUserAgent(ENV.PROD); const userAgentQueryParam = new URLSearchParams(`user_agent_v2=${userAgent}`).toString(); const peerId = '1234'; it('should return the URL even if unnecesary params are passed to the endpoint', () => { @@ -67,7 +67,7 @@ describe('transformInit', () => { }); }); -describe('init API call', async () => { +describe('init API call', () => { const peerId = '2e26acc7-d2c8-4235-883e-812695ff1e7d'; const correctToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2Nlc3Nfa2V5IjoiNjEwY2Q5Y2JmMzBlNzczZjQ3NTc3YjBkIiwicm9vbV9pZCI6IjYxOGU5NGY1YWYzMTg4ZGYzM2U2N2Q0NiIsInVzZXJfaWQiOiJiZTM5MzQwZC04ZDgzLTQ5ZjQtOTNhMy00ZjRmMTgwZTVkZWUiLCJyb2xlIjoiaG9zdCIsImp0aSI6IjY0ZTRjMTgzLWZkNTktNGE2OS1hOGY2LWNkNGE5MzBmOTYzZSIsInR5cGUiOiJhcHAiLCJ2ZXJzaW9uIjoyLCJleHAiOjE2NTIyNjUyNzV9.t1Wvwl0tXyMzi386LwfDACvUeWibZYIzSf20DTwjqJU'; @@ -76,7 +76,7 @@ describe('init API call', async () => { const wrongToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2Nlc3Nfa2V5IjoiNjEwY2Q5Y2JmMzBlNzczZjQ3NTc3YjBkIiwicm9vbV9pZCI6IjYxOGU5NGY1YWYzMTg4ZGYzM2U2N2Q0NyIsInVzZXJfaWQiOiJiZTM5MzQwZC04ZDgzLTQ5ZjQtOTNhMy00ZjRmMTgwZTVkZWUiLCJyb2xlIjoiaG9zdCIsImp0aSI6IjY0ZTRjMTgzLWZkNTktNGE2OS1hOGY2LWNkNGE5MzBmOTYzZSIsInR5cGUiOiJhcHAiLCJ2ZXJzaW9uIjoyLCJleHAiOjE2NTIyNjUyNzV9.tX4BZllTjOuA5L3bgItoDYKQa6J3d-L2cayvQiEntHY'; - const userAgent = await createUserAgent(ENV.PROD); + const userAgent = createUserAgent(ENV.PROD); const mockResponse = (init: RequestInit | undefined): Promise => { const headers = init?.headers as Record; diff --git a/packages/hms-video-store/src/transport/index.ts b/packages/hms-video-store/src/transport/index.ts index 6646bcb1d3..fc6a168e99 100644 --- a/packages/hms-video-store/src/transport/index.ts +++ b/packages/hms-video-store/src/transport/index.ts @@ -896,15 +896,11 @@ export default class HMSTransport { HMSLogger.d(TAG, 'connect: started ⏰'); const connectRequestedAt = new Date(); try { - const userAgent = this.store.getUserAgent(); - if (!userAgent) { - throw ErrorFactory.GenericErrors.PeerMetadataMissing(HMSAction.INIT, 'User Agent not available'); - } this.analyticsTimer.start(TimedEvent.INIT); this.initConfig = await InitService.fetchInitConfig({ token, peerId, - userAgent, + userAgent: this.store.getUserAgent(), initEndpoint, }); const room = this.store.getRoom(); @@ -955,16 +951,12 @@ export default class HMSTransport { if (!this.initConfig) { throw ErrorFactory.APIErrors.InitConfigNotAvailable(HMSAction.INIT, 'Init Config not found'); } - const userAgent = this.store.getUserAgent(); - if (!userAgent) { - throw ErrorFactory.GenericErrors.PeerMetadataMissing(HMSAction.INIT, 'User Agent not available'); - } HMSLogger.d(TAG, '⏳ internal connect: connecting to ws endpoint', this.initConfig.endpoint); const url = new URL(this.initConfig.endpoint); url.searchParams.set('peer', peerId); url.searchParams.set('token', token); - url.searchParams.set('user_agent_v2', userAgent); + url.searchParams.set('user_agent_v2', this.store.getUserAgent()); url.searchParams.set('protocol_version', PROTOCOL_VERSION); url.searchParams.set('protocol_spec', PROTOCOL_SPEC); diff --git a/packages/hms-video-store/src/utils/support.ts b/packages/hms-video-store/src/utils/support.ts index a0badd0de4..1c48e94f73 100644 --- a/packages/hms-video-store/src/utils/support.ts +++ b/packages/hms-video-store/src/utils/support.ts @@ -29,4 +29,4 @@ export const isPageHidden = () => typeof document !== 'undefined' && document.hi export const isIOS = () => parsedUserAgent.getOS().name?.toLowerCase() === 'ios'; -export const isFirefox = parsedUserAgent.getBrowser()?.name?.toLowerCase().includes('firefox'); +export const isFirefox = parsedUserAgent.getBrowser()?.name?.toLowerCase() === 'firefox'; diff --git a/packages/hms-video-store/src/utils/user-agent.ts b/packages/hms-video-store/src/utils/user-agent.ts index 210fa08ca0..335d6c4ffc 100644 --- a/packages/hms-video-store/src/utils/user-agent.ts +++ b/packages/hms-video-store/src/utils/user-agent.ts @@ -20,7 +20,7 @@ type UserAgent = { framework_sdk_version?: HMSFrameworkInfo['sdkVersion']; }; -export async function createUserAgent(sdkEnv: ENV = ENV.PROD, frameworkInfo?: HMSFrameworkInfo) { +export function createUserAgent(sdkEnv: ENV = ENV.PROD, frameworkInfo?: HMSFrameworkInfo): string { const sdk = 'web'; const env = domainCategory !== DomainCategory.LOCAL && sdkEnv === ENV.PROD ? 'prod' : 'debug'; @@ -39,13 +39,9 @@ export async function createUserAgent(sdkEnv: ENV = ENV.PROD, frameworkInfo?: HM }); } - /** - * User agent client hints are not yet supported on firefox and safari https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API#browser_compatibility - * the fallback navigator.userAgent would still report the old/incorrect versions on these browsers - */ - const parsedOs = await parsedUserAgent.getOS().withClientHints(); - const parsedDevice = await parsedUserAgent.getDevice().withClientHints(); - const parsedBrowser = await parsedUserAgent.getBrowser().withClientHints(); + const parsedOs = parsedUserAgent.getOS(); + const parsedDevice = parsedUserAgent.getDevice(); + const parsedBrowser = parsedUserAgent.getBrowser(); const os = replaceSpaces(`web_${parsedOs.name}`); const os_version = parsedOs.version || ''; diff --git a/packages/roomkit-react/src/Prebuilt/common/constants.ts b/packages/roomkit-react/src/Prebuilt/common/constants.ts index 5b0b955454..ccbba0d456 100644 --- a/packages/roomkit-react/src/Prebuilt/common/constants.ts +++ b/packages/roomkit-react/src/Prebuilt/common/constants.ts @@ -98,12 +98,11 @@ export const HLS_TIMED_METADATA_DOC_URL = export const REMOTE_STOP_SCREENSHARE_TYPE = 'REMOTE_STOP_SCREENSHARE'; -// mweb could have browser name as "Mobile Chrome" or "Mobile Firefox" -export const isChrome = parsedUserAgent.getBrowser()?.name?.toLowerCase().includes('chrome'); -export const isFirefox = parsedUserAgent.getBrowser()?.name?.toLowerCase().includes('firefox'); -export const isSafari = parsedUserAgent.getBrowser()?.name?.toLowerCase().includes('safari'); +export const isChrome = parsedUserAgent.getBrowser()?.name?.toLowerCase() === 'chrome'; +export const isFirefox = parsedUserAgent.getBrowser()?.name?.toLowerCase() === 'firefox'; +export const isSafari = parsedUserAgent.getBrowser()?.name?.toLowerCase() === 'safari'; export const isIOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'ios'; -export const isMacOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'macos'; +export const isMacOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'mac os'; export const isAndroid = parsedUserAgent.getOS()?.name?.toLowerCase() === 'android'; export const isIPadOS = false; // typeof navigator !== "undefined" && diff --git a/yarn.lock b/yarn.lock index 351693336e..39770349d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5738,6 +5738,11 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== +"@types/ua-parser-js@^0.7.36": + version "0.7.36" + resolved "https://registry.yarnpkg.com/@types/ua-parser-js/-/ua-parser-js-0.7.36.tgz#9bd0b47f26b5a3151be21ba4ce9f5fa457c5f190" + integrity sha512-N1rW+njavs70y2cApeIw1vLMYXRwfBy+7trgavGuuTfOd7j1Yh7QTRc/yqsPl6ncokt72ZXuxEU0PiCp9bSwNQ== + "@types/unist@^2.0.0": version "2.0.7" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.7.tgz#5b06ad6894b236a1d2bd6b2f07850ca5c59cf4d6" @@ -16536,10 +16541,10 @@ typescript@~4.7.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== -ua-parser-js@^2.0.0-beta.2: - version "2.0.0-beta.2" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-2.0.0-beta.2.tgz#7738c5ad7f4a8f1fdd9f736130c8fd941daf686a" - integrity sha512-v1tudz3YJqB2lFtmhs/Wh2aPNsOatJBeCQp5s67rgx7UprG1pkOgzm8H1jXabaMZBXH9cWU3gePSgBTe3lFeRA== +ua-parser-js@^1.0.1: + version "1.0.35" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.35.tgz#c4ef44343bc3db0a3cbefdf21822f1b1fc1ab011" + integrity sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA== uglify-js@^3.1.4: version "3.17.4" From 34ebd883853e8aefe7054badd305f7bdf813df58 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:13:23 +0530 Subject: [PATCH 7/9] build: update versions for release (#2584) Co-authored-by: KaustubhKumar05 --- examples/prebuilt-react-integration/package.json | 2 +- packages/hls-player/package.json | 4 ++-- packages/hls-stats/package.json | 2 +- packages/hms-video-store/package.json | 2 +- packages/hms-virtual-background/package.json | 6 +++--- packages/react-icons/package.json | 2 +- packages/react-sdk/package.json | 4 ++-- packages/roomkit-react/package.json | 10 +++++----- packages/roomkit-web/package.json | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/prebuilt-react-integration/package.json b/examples/prebuilt-react-integration/package.json index 1e1da55eb5..2971f27f84 100644 --- a/examples/prebuilt-react-integration/package.json +++ b/examples/prebuilt-react-integration/package.json @@ -10,7 +10,7 @@ "preview": "vite preview" }, "dependencies": { - "@100mslive/roomkit-react": "0.2.6", + "@100mslive/roomkit-react": "0.2.7", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/packages/hls-player/package.json b/packages/hls-player/package.json index af8ed212eb..5262f0be19 100644 --- a/packages/hls-player/package.json +++ b/packages/hls-player/package.json @@ -1,6 +1,6 @@ { "name": "@100mslive/hls-player", - "version": "0.2.6", + "version": "0.2.7", "description": "HLS client library which uses HTML5 Video element and Media Source Extension for playback", "main": "dist/index.cjs.js", "module": "dist/index.js", @@ -36,7 +36,7 @@ "author": "100ms", "license": "MIT", "dependencies": { - "@100mslive/hls-stats": "0.3.6", + "@100mslive/hls-stats": "0.3.7", "eventemitter2": "^6.4.9", "hls.js": "1.4.12" } diff --git a/packages/hls-stats/package.json b/packages/hls-stats/package.json index 11a33ecba2..08888a103f 100644 --- a/packages/hls-stats/package.json +++ b/packages/hls-stats/package.json @@ -1,6 +1,6 @@ { "name": "@100mslive/hls-stats", - "version": "0.3.6", + "version": "0.3.7", "description": "A simple library that provides stats for your hls stream", "main": "dist/index.cjs.js", "module": "dist/index.js", diff --git a/packages/hms-video-store/package.json b/packages/hms-video-store/package.json index b094248bd6..ed9100be96 100644 --- a/packages/hms-video-store/package.json +++ b/packages/hms-video-store/package.json @@ -1,5 +1,5 @@ { - "version": "0.11.6", + "version": "0.11.7", "license": "MIT", "repository": { "type": "git", diff --git a/packages/hms-virtual-background/package.json b/packages/hms-virtual-background/package.json index d79ec979b5..023b2eee1d 100755 --- a/packages/hms-virtual-background/package.json +++ b/packages/hms-virtual-background/package.json @@ -1,5 +1,5 @@ { - "version": "1.12.6", + "version": "1.12.7", "license": "MIT", "name": "@100mslive/hms-virtual-background", "author": "100ms", @@ -32,10 +32,10 @@ "format": "prettier --write src/**/*.ts" }, "peerDependencies": { - "@100mslive/hms-video-store": "0.11.6" + "@100mslive/hms-video-store": "0.11.7" }, "devDependencies": { - "@100mslive/hms-video-store": "0.11.6" + "@100mslive/hms-video-store": "0.11.7" }, "dependencies": { "@mediapipe/selfie_segmentation": "^0.1.1632777926", diff --git a/packages/react-icons/package.json b/packages/react-icons/package.json index 0c7b51192a..1c0ae04953 100644 --- a/packages/react-icons/package.json +++ b/packages/react-icons/package.json @@ -4,7 +4,7 @@ "main": "dist/index.cjs.js", "module": "dist/index.js", "typings": "dist/index.d.ts", - "version": "0.9.6", + "version": "0.9.7", "author": "100ms", "license": "MIT", "repository": { diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json index 4387bd4789..3654af9307 100644 --- a/packages/react-sdk/package.json +++ b/packages/react-sdk/package.json @@ -4,7 +4,7 @@ "main": "dist/index.cjs.js", "module": "dist/index.js", "typings": "dist/index.d.ts", - "version": "0.9.6", + "version": "0.9.7", "author": "100ms", "license": "MIT", "repository": { @@ -48,7 +48,7 @@ "react": ">=16.8 <19.0.0" }, "dependencies": { - "@100mslive/hms-video-store": "0.11.6", + "@100mslive/hms-video-store": "0.11.7", "react-resize-detector": "^7.0.0", "zustand": "^3.6.2" } diff --git a/packages/roomkit-react/package.json b/packages/roomkit-react/package.json index 804a835fb5..26a3393b5a 100644 --- a/packages/roomkit-react/package.json +++ b/packages/roomkit-react/package.json @@ -10,7 +10,7 @@ "prebuilt", "roomkit" ], - "version": "0.2.6", + "version": "0.2.7", "author": "100ms", "license": "MIT", "repository": { @@ -82,11 +82,11 @@ "react": ">=17.0.2 <19.0.0" }, "dependencies": { - "@100mslive/hls-player": "0.2.6", - "@100mslive/hms-virtual-background": "1.12.6", + "@100mslive/hls-player": "0.2.7", "@100mslive/hms-noise-cancellation": "0.0.0-alpha.1", - "@100mslive/react-icons": "0.9.6", - "@100mslive/react-sdk": "0.9.6", + "@100mslive/hms-virtual-background": "1.12.7", + "@100mslive/react-icons": "0.9.7", + "@100mslive/react-sdk": "0.9.7", "@100mslive/types-prebuilt": "0.12.7", "@emoji-mart/data": "^1.0.6", "@emoji-mart/react": "^1.0.1", diff --git a/packages/roomkit-web/package.json b/packages/roomkit-web/package.json index dd80a1675a..1e1f741553 100644 --- a/packages/roomkit-web/package.json +++ b/packages/roomkit-web/package.json @@ -1,6 +1,6 @@ { "name": "@100mslive/roomkit-web", - "version": "0.1.6", + "version": "0.1.7", "description": "A web component implementation of 100ms Prebuilt component", "keywords": [ "web-components", @@ -33,7 +33,7 @@ "build": "rm -rf dist && node ../../scripts/build-webapp" }, "dependencies": { - "@100mslive/roomkit-react": "0.2.6", + "@100mslive/roomkit-react": "0.2.7", "@r2wc/react-to-web-component": "2.0.2" } } From d1fc16416b234cdd2437238e2f0b52bceee9ca47 Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Sat, 24 Feb 2024 09:54:10 +0530 Subject: [PATCH 8/9] feat: disable video when in background --- .../src/media/tracks/HMSLocalVideoTrack.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts index 31218fc3c5..013b08236c 100644 --- a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts @@ -17,6 +17,7 @@ import { HMSMediaStreamPlugin, HMSVideoPluginsManager } from '../../plugins/vide import { HMSMediaStreamPluginsManager } from '../../plugins/video/HMSMediaStreamPluginsManager'; import { LocalTrackManager } from '../../sdk/LocalTrackManager'; import HMSLogger from '../../utils/logger'; +import { isBrowser, isMobile } from '../../utils/support'; import { getVideoTrack, isEmptyTrack } from '../../utils/track'; import { HMSVideoTrackSettings, HMSVideoTrackSettingsBuilder } from '../settings'; import { HMSLocalStream } from '../streams'; @@ -36,6 +37,7 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { private processedTrack?: MediaStreamTrack; private _layerDefinitions: HMSSimulcastLayerDefinition[] = []; private TAG = '[HMSLocalVideoTrack]'; + private enabledStateBeforeBackground = false; /** * true if it's screenshare and current tab is what is being shared. Browser dependent, Chromium only @@ -80,6 +82,9 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { this.pluginsManager = new HMSVideoPluginsManager(this, eventBus); this.mediaStreamPluginsManager = new HMSMediaStreamPluginsManager(eventBus); this.setFirstTrackId(this.trackId); + if (isBrowser && isMobile()) { + document.addEventListener('visibilitychange', this.handleVisibilityChange); + } } /** @internal */ @@ -232,6 +237,9 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { await this.pluginsManager.cleanup(); this.processedTrack?.stop(); this.isPublished = false; + if (isBrowser && isMobile()) { + document.removeEventListener('visibilitychange', this.handleVisibilityChange); + } } /** @@ -477,4 +485,16 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { } await this.replaceSenderTrack(this.processedTrack || this.nativeTrack); }; + + private handleVisibilityChange = async () => { + if (document.visibilityState === 'hidden' && this.source === 'regular') { + this.enabledStateBeforeBackground = this.enabled; + this.nativeTrack.enabled = false; + this.replaceSenderTrack(this.nativeTrack); + } else { + this.nativeTrack.enabled = this.enabledStateBeforeBackground; + this.replaceSenderTrack(this.nativeTrack); + } + this.eventBus.localVideoEnabled.publish({ enabled: this.nativeTrack.enabled, track: this }); + }; } From 3a1dde781ca250109541013266a04663a754aeca Mon Sep 17 00:00:00 2001 From: Ravi theja Date: Sat, 24 Feb 2024 09:54:35 +0530 Subject: [PATCH 9/9] feat: reduce no. of worker creation for vb --- .../plugins/video/HMSVideoPluginsManager.ts | 7 +++--- .../hms-video-store/src/utils/timer-utils.ts | 23 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/hms-video-store/src/plugins/video/HMSVideoPluginsManager.ts b/packages/hms-video-store/src/plugins/video/HMSVideoPluginsManager.ts index 15ffd20012..c976dc610a 100644 --- a/packages/hms-video-store/src/plugins/video/HMSVideoPluginsManager.ts +++ b/packages/hms-video-store/src/plugins/video/HMSVideoPluginsManager.ts @@ -6,7 +6,7 @@ import { HMSAction } from '../../error/HMSAction'; import { EventBus } from '../../events/EventBus'; import { HMSLocalVideoTrack } from '../../media/tracks'; import HMSLogger from '../../utils/logger'; -import { workerSleep } from '../../utils/timer-utils'; +import { reusableWorker, workerSleep } from '../../utils/timer-utils'; import { HMSPluginUnsupportedTypes } from '../audio'; const DEFAULT_FRAME_RATE = 24; @@ -57,6 +57,7 @@ export class HMSVideoPluginsManager { private pluginNumFramesToSkip: Record; private pluginNumFramesSkipped: Record; private canvases: Array; //array of canvases to store intermediate result + private reusableWorker = reusableWorker(); constructor(track: HMSLocalVideoTrack, eventBus: EventBus) { this.hmsTrack = track; @@ -288,7 +289,7 @@ export class HMSVideoPluginsManager { this.resetCanvases(); } this.pluginsLoopState = 'paused'; - await workerSleep(sleepTimeMs); + await this.reusableWorker.sleep(sleepTimeMs); continue; } let processingTime = 0; @@ -306,7 +307,7 @@ export class HMSVideoPluginsManager { } this.pluginsLoopState = 'running'; // take into account processing time to decide time to wait for the next loop - await workerSleep(sleepTimeMs - processingTime); + await this.reusableWorker.sleep(sleepTimeMs - processingTime); } } diff --git a/packages/hms-video-store/src/utils/timer-utils.ts b/packages/hms-video-store/src/utils/timer-utils.ts index 717224ee89..c7cda0717b 100644 --- a/packages/hms-video-store/src/utils/timer-utils.ts +++ b/packages/hms-video-store/src/utils/timer-utils.ts @@ -1,4 +1,4 @@ -export const worker = `(function metronomeWorkerSetup() { +export const worker = `(function workerSetup() { function ticker() { self.postMessage('tick'); } @@ -47,6 +47,27 @@ export function workerSleep(ms: number): Promise { }); } +export function reusableWorker() { + if (typeof Worker === 'undefined') { + return { + sleep: (ms: number) => sleep(ms), + }; + } + const WorkerThread = new Worker(URL.createObjectURL(new Blob([worker], { type: 'application/javascript' }))); + return { + sleep: (ms: number) => { + WorkerThread.postMessage(['start', ms]); + return new Promise(resolve => { + WorkerThread.onmessage = event => { + if (event.data === 'tick') { + resolve(); + } + }; + }); + }, + }; +} + /** * Debounce Fn - Function to limit the number of executions of the passed in * function in a given time duration