@stream-io/video-react-bindings 0.2.34 → 0.2.35
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/CHANGELOG.md +10 -0
- package/dist/index.cjs.js +609 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +589 -0
- package/dist/index.es.js.map +1 -0
- package/dist/src/contexts/StreamI18nContext.d.ts +2 -2
- package/dist/src/i18n/StreamI18n.d.ts +29 -0
- package/dist/src/i18n/index.d.ts +3 -0
- package/dist/src/i18n/types.d.ts +7 -0
- package/dist/src/i18n/utils.d.ts +2 -0
- package/index.ts +2 -0
- package/package.json +13 -11
- package/src/contexts/StreamI18nContext.tsx +5 -3
- package/src/i18n/StreamI18n.ts +124 -0
- package/src/i18n/index.ts +3 -0
- package/src/i18n/types.ts +19 -0
- package/src/i18n/utils.ts +10 -0
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/src/contexts/StreamCallContext.js +0 -26
- package/dist/src/contexts/StreamCallContext.js.map +0 -1
- package/dist/src/contexts/StreamI18nContext.js +0 -40
- package/dist/src/contexts/StreamI18nContext.js.map +0 -1
- package/dist/src/contexts/StreamVideoContext.js +0 -23
- package/dist/src/contexts/StreamVideoContext.js.map +0 -1
- package/dist/src/contexts/index.js +0 -4
- package/dist/src/contexts/index.js.map +0 -1
- package/dist/src/hooks/callStateHooks.js +0 -311
- package/dist/src/hooks/callStateHooks.js.map +0 -1
- package/dist/src/hooks/index.js +0 -10
- package/dist/src/hooks/index.js.map +0 -1
- package/dist/src/hooks/permissions.js +0 -23
- package/dist/src/hooks/permissions.js.map +0 -1
- package/dist/src/hooks/store.js +0 -33
- package/dist/src/hooks/store.js.map +0 -1
- package/dist/src/hooks/useObservableValue.js +0 -17
- package/dist/src/hooks/useObservableValue.js.map +0 -1
- package/dist/src/wrappers/Restricted.js +0 -17
- package/dist/src/wrappers/Restricted.js.map +0 -1
- package/dist/src/wrappers/index.js +0 -2
- package/dist/src/wrappers/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/contexts/StreamCallContext.tsx","../../src/i18n/utils.ts","../../src/i18n/StreamI18n.ts","../../src/contexts/StreamI18nContext.tsx","../../src/contexts/StreamVideoContext.tsx","../../src/hooks/useObservableValue.ts","../../src/hooks/callStateHooks.ts","../../src/hooks/permissions.ts","../../src/hooks/store.ts","../../src/hooks/index.ts","../../src/wrappers/Restricted.tsx"],"sourcesContent":["import { createContext, PropsWithChildren, useContext } from 'react';\nimport { Call } from '@stream-io/video-client';\n\nconst StreamCallContext = createContext<Call | undefined>(undefined);\n\n/**\n *\n * We don't expose types in our docs site but we should still add doc comments\n * @internal\n */\nexport interface StreamCallProviderProps {\n call?: Call;\n}\n\n/**\n *\n * @param props\n * @returns\n *\n * @category Call State\n *\n * @react If you're using the React SDK we recommend using the `StreamCall` component that wraps the `StreamCallProvider`. You only need to use the `StreamCallProvider` for advanced use-cases.\n */\nexport const StreamCallProvider = (\n props: PropsWithChildren<StreamCallProviderProps>,\n) => {\n const { call, children } = props;\n return (\n <StreamCallContext.Provider value={call}>\n {children}\n </StreamCallContext.Provider>\n );\n};\n\n/**\n *\n * @returns\n *\n * @category Call State\n */\nexport const useCall = () => {\n return useContext(StreamCallContext);\n};\n","import { TranslationsMap, TranslationsRegistry } from './types';\n\nexport const mapToRegistry = (\n translationsMap: TranslationsMap,\n namespace: string,\n) =>\n Object.entries(translationsMap).reduce((acc, [lng, translations]) => {\n acc[lng] = { [namespace]: translations };\n return acc;\n }, {} as TranslationsRegistry);\n","import i18next from 'i18next';\nimport { mapToRegistry } from './utils';\nimport {\n TranslationLanguage,\n TranslationSheet,\n TranslationsMap,\n TranslatorFunction,\n} from './types';\n\nexport const DEFAULT_LANGUAGE = 'en';\nexport const DEFAULT_NAMESPACE = 'stream-video';\nconst DEFAULT_CONFIG = {\n debug: false,\n currentLanguage: DEFAULT_LANGUAGE,\n};\n\nconst DEFAULT_TRANSLATIONS_REGISTRY = mapToRegistry({}, DEFAULT_NAMESPACE);\n\nexport const defaultTranslationFunction = (key: string) => key;\n\nexport type StreamI18nConstructor = {\n /** Language into which the provided strings are translated */\n currentLanguage?: TranslationLanguage;\n /** Logs info level to console output. Helps find issues with loading not working. */\n debug?: boolean;\n /** Custom translations that will be merged with the defaults provided by the library. */\n translationsOverrides?: TranslationsMap;\n};\n\nexport class StreamI18n {\n /** Exposed i18n instance from the i18next library */\n i18nInstance;\n /** Translator function that converts the provided string into its equivalent in the current language. */\n t: TranslatorFunction = defaultTranslationFunction;\n /** Simple logger function */\n constructor(options: StreamI18nConstructor = {}) {\n const {\n debug = DEFAULT_CONFIG.debug,\n currentLanguage = DEFAULT_CONFIG.currentLanguage,\n translationsOverrides,\n } = options;\n\n this.i18nInstance = i18next.createInstance({\n debug,\n defaultNS: DEFAULT_NAMESPACE,\n fallbackLng: false,\n interpolation: { escapeValue: false },\n keySeparator: false,\n lng: currentLanguage,\n nsSeparator: false,\n parseMissingKeyHandler: (key) => {\n return key;\n },\n resources: DEFAULT_TRANSLATIONS_REGISTRY,\n });\n\n if (translationsOverrides) {\n this.i18nInstance.on('initialized', () => {\n Object.entries(translationsOverrides).forEach(([lng, translations]) => {\n this.registerTranslationsForLanguage({ lng, translations });\n });\n });\n }\n }\n\n get currentLanguage() {\n this._checkIsInitialized();\n return this.i18nInstance.language;\n }\n\n get isInitialized() {\n return this.i18nInstance.isInitialized;\n }\n\n init = async () => {\n try {\n this.t = await this.i18nInstance.init();\n } catch (e) {\n console.error(`Failed to initialize translations: ${JSON.stringify(e)}`);\n }\n return this;\n };\n\n changeLanguage = async (\n language?: TranslationLanguage,\n onChange?: (language: TranslationLanguage) => void,\n ) => {\n if (!this._checkIsInitialized()) return;\n // i18next detects the language, if none provided, but it is better\n // to show this detection here explicitly\n const browserLanguage =\n typeof window !== 'undefined' && window.navigator\n ? window.navigator.language\n : undefined;\n await this.i18nInstance.changeLanguage(language || browserLanguage);\n onChange?.(this.currentLanguage);\n };\n\n registerTranslationsForLanguage = ({\n lng,\n translations,\n }: {\n lng: TranslationLanguage;\n translations: TranslationSheet;\n }) => {\n if (!this._checkIsInitialized()) return;\n this.i18nInstance.addResourceBundle(\n lng,\n DEFAULT_NAMESPACE,\n translations,\n true,\n true,\n );\n };\n\n private _checkIsInitialized = () => {\n if (!this.i18nInstance.isInitialized) {\n console.warn(\n 'I18n instance is not initialized. Call yourStreamI18nInstance.init().',\n );\n }\n return this.i18nInstance.isInitialized;\n };\n}\n","import {\n createContext,\n PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport {\n defaultTranslationFunction,\n StreamI18n,\n TranslationsMap,\n} from '../i18n';\n\ntype StreamI18nContextValue = {\n t: StreamI18n['t'];\n i18n?: StreamI18n;\n};\n\nconst StreamI18nContext = createContext<StreamI18nContextValue>({\n t: defaultTranslationFunction,\n});\n\ntype CreateI18nParams = {\n i18nInstance?: StreamI18n;\n language?: string;\n translationsOverrides?: TranslationsMap;\n};\n\nexport type StreamI18nProviderProps = CreateI18nParams;\n\nexport const StreamI18nProvider = ({\n children,\n ...createI18nParams\n}: PropsWithChildren<StreamI18nProviderProps>) => {\n const { i18n, t } = useCreateI18n(createI18nParams);\n\n return (\n <StreamI18nContext.Provider value={{ t, i18n }}>\n {children}\n </StreamI18nContext.Provider>\n );\n};\n\nexport const useCreateI18n = ({\n i18nInstance,\n language,\n translationsOverrides,\n}: CreateI18nParams) => {\n const [i18n] = useState(\n () =>\n i18nInstance ||\n new StreamI18n({ currentLanguage: language, translationsOverrides }),\n );\n const [t, setTranslationFn] = useState<StreamI18n['t']>(\n () => defaultTranslationFunction,\n );\n\n useEffect(() => {\n const { isInitialized } = i18n;\n if (!isInitialized) {\n i18n.init().then((_i18n) => setTranslationFn(() => _i18n.i18nInstance.t));\n return;\n }\n if (language && i18n?.currentLanguage !== language) {\n i18n.changeLanguage(language).catch((err) => {\n console.log('Error while changing language', err);\n });\n }\n }, [i18n, i18nInstance, language, translationsOverrides]);\n\n return { i18n, t };\n};\n\nexport const useI18n = () => useContext(StreamI18nContext);\n","import { createContext, PropsWithChildren, useContext } from 'react';\nimport { StreamVideoClient } from '@stream-io/video-client';\nimport {\n StreamI18nProvider,\n StreamI18nProviderProps,\n} from './StreamI18nContext';\n\nconst StreamVideoContext = createContext<StreamVideoClient | undefined>(\n undefined,\n);\n\n/**\n * Exclude types from documentation site, but we should still add doc comments\n * @internal\n */\nexport type StreamVideoProps = StreamI18nProviderProps & {\n client: StreamVideoClient;\n};\n\n/**\n * StreamVideo is a provider component which should be used to wrap the entire application.\n * It provides the client object to all children components and initializes the i18n instance.\n * @param PropsWithChildren<StreamVideoProps>\n * @category Client State\n */\nexport const StreamVideoProvider = ({\n children,\n client,\n i18nInstance,\n language,\n translationsOverrides,\n}: PropsWithChildren<StreamVideoProps>) => {\n return (\n <StreamVideoContext.Provider value={client}>\n <StreamI18nProvider\n i18nInstance={i18nInstance}\n language={language}\n translationsOverrides={translationsOverrides}\n >\n {children}\n </StreamI18nProvider>\n </StreamVideoContext.Provider>\n );\n};\n\n/**\n *\n * @returns\n *\n * @category Client State\n */\nexport const useStreamVideoClient = () => {\n return useContext(StreamVideoContext);\n};\n","import type { Observable } from 'rxjs';\nimport { useEffect, useState } from 'react';\nimport { RxUtils } from '@stream-io/video-client';\n\n/**\n * Utility hook which provides the current value of the given observable.\n * @internal\n */\nexport const useObservableValue = <T>(observable$: Observable<T>) => {\n const [value, setValue] = useState<T>(() =>\n RxUtils.getCurrentValue(observable$),\n );\n useEffect(() => {\n const subscription = observable$.subscribe(setValue);\n return () => {\n subscription.unsubscribe();\n };\n }, [observable$]);\n\n return value;\n};\n","import { useMemo } from 'react';\nimport {\n Call,\n CallIngressResponse,\n CallSessionResponse,\n CallSettingsResponse,\n CallState,\n CallStatsReport,\n Comparator,\n EgressResponse,\n MemberResponse,\n StreamVideoParticipant,\n UserResponse,\n} from '@stream-io/video-client';\nimport { useCall } from '../contexts';\nimport { useObservableValue } from './useObservableValue';\n\n/**\n * Utility hook, which provides the current call's state.\n *\n * @category Call State\n */\nexport const useCallState = () => {\n const call = useCall();\n // return an empty and unlinked CallState object if there is no call in the provider\n // this ensures that the hooks always return a value and many null checks can be avoided\n if (!call) {\n const message =\n 'You are using useCallState() outside a Call context. ' +\n 'Please wrap your component in <StreamCall /> and provide a \"call\" instance.';\n console.warn(message);\n return new CallState();\n }\n return call.state;\n};\n\n/**\n * Utility hook which provides information whether the current call is being recorded. It will return `true` if the call is being recorded.\n *\n * @category Call State\n */\nexport const useIsCallRecordingInProgress = (): boolean => {\n const { recording$ } = useCallState();\n return useObservableValue(recording$);\n};\n\n/**\n * Utility hook which provides information whether the current call is broadcasting.\n *\n * @category Call State\n */\nexport const useIsCallBroadcastingInProgress = (): boolean => {\n const { egress$ } = useCallState();\n const egress = useObservableValue(egress$);\n if (!egress) return false;\n return egress.broadcasting;\n};\n\n/**\n * Utility hook which provides information whether the current call is live.\n *\n * @category Call State\n */\nexport const useIsCallLive = (): boolean => {\n const { backstage$ } = useCallState();\n const isBackstageOn = useObservableValue(backstage$);\n return !isBackstageOn;\n};\n\n/**\n * Returns the list of blocked users in the current call.\n */\nexport const useCallBlockedUserIds = (): string[] => {\n const { blockedUserIds$ } = useCallState();\n return useObservableValue(blockedUserIds$);\n};\n\n/**\n * Returns the timestamp when this call was created.\n */\nexport const useCallCreatedAt = (): Date | undefined => {\n const { createdAt$ } = useCallState();\n return useObservableValue(createdAt$);\n};\n\n/**\n * Returns the timestamp when this call was ended.\n */\nexport const useCallEndedAt = (): Date | undefined => {\n const { endedAt$ } = useCallState();\n return useObservableValue(endedAt$);\n};\n\n/**\n * Returns the timestamp telling when the call is scheduled to start.\n */\nexport const useCallStartsAt = (): Date | undefined => {\n const { startsAt$ } = useCallState();\n return useObservableValue(startsAt$);\n};\n\n/**\n * Returns the timestamp when this call was updated.\n */\nexport const useCallUpdatedAt = (): Date | undefined => {\n const { updatedAt$ } = useCallState();\n return useObservableValue(updatedAt$);\n};\n\n/**\n * Returns the information about the call's creator.\n */\nexport const useCallCreatedBy = (): UserResponse | undefined => {\n const { createdBy$ } = useCallState();\n return useObservableValue(createdBy$);\n};\n\n/**\n * Returns the call's custom data.\n */\nexport const useCallCustomData = (): Record<string, any> => {\n const { custom$ } = useCallState();\n return useObservableValue(custom$);\n};\n\n/**\n * Returns the call's Egress information.\n */\nexport const useCallEgress = (): EgressResponse | undefined => {\n const { egress$ } = useCallState();\n return useObservableValue(egress$);\n};\n\n/**\n * Returns the call's Ingress information.\n */\nexport const useCallIngress = (): CallIngressResponse | undefined => {\n const { ingress$ } = useCallState();\n return useObservableValue(ingress$);\n};\n\n/**\n * Returns the data for the current call session.\n */\nexport const useCallSession = (): CallSessionResponse | undefined => {\n const { session$ } = useCallState();\n return useObservableValue(session$);\n};\n\n/**\n * Returns the call's settings.\n */\nexport const useCallSettings = (): CallSettingsResponse | undefined => {\n const { settings$ } = useCallState();\n return useObservableValue(settings$);\n};\n\n/**\n * Returns whether the call has transcribing enabled.\n */\nexport const useIsCallTranscribingInProgress = (): boolean => {\n const { transcribing$ } = useCallState();\n return useObservableValue(transcribing$);\n};\n\n/**\n * Returns information about the user who has marked this call as ended.\n */\nexport const useCallEndedBy = (): UserResponse | undefined => {\n const { endedBy$ } = useCallState();\n return useObservableValue(endedBy$);\n};\n\n/**\n * Utility hook which provides a boolean indicating whether there is\n * a participant in the current call which shares their screen.\n *\n * @category Call State\n */\nexport const useHasOngoingScreenShare = (): boolean => {\n const { hasOngoingScreenShare$ } = useCallState();\n return useObservableValue(hasOngoingScreenShare$);\n};\n\n/**\n * Utility hook which provides the latest stats report of the current call.\n *\n * The latest stats report of the current call.\n * When stats gathering is enabled, this observable will emit a new value\n * at a regular (configurable) interval.\n *\n * Consumers of this observable can implement their own batching logic\n * in case they want to show historical stats data.\n *\n * @category Call State\n */\nexport const useCallStatsReport = (): CallStatsReport | undefined => {\n const { callStatsReport$ } = useCallState();\n return useObservableValue(callStatsReport$);\n};\n\n/**\n * Utility hook which provides the dominant speaker of the current call.\n *\n * @category Call State\n */\nexport const useDominantSpeaker = (): StreamVideoParticipant | undefined => {\n const { dominantSpeaker$ } = useCallState();\n return useObservableValue(dominantSpeaker$);\n};\n\n/**\n * Utility hook which provides a list of call members.\n *\n * @category Call State\n */\nexport const useCallMembers = (): MemberResponse[] => {\n const { members$ } = useCallState();\n return useObservableValue(members$);\n};\n\n/**\n * Utility hook providing the current calling state of the call. For example, `RINGING` or `JOINED`.\n *\n * @category Call State\n */\nexport const useCallCallingState = () => {\n const { callingState$ } = useCallState();\n return useObservableValue(callingState$);\n};\n\n/**\n * Utility hook providing the actual start time of the current session.\n * Useful for calculating the call duration.\n *\n * @category Call State\n */\nexport const useCallStartedAt = () => {\n const { startedAt$ } = useCallState();\n return useObservableValue(startedAt$);\n};\n\n/**\n * A hook which provides a list of all participants that have joined an active call.\n *\n * @category Call State\n *\n * @param options.sortBy - A comparator function to sort the participants by.\n * Make sure to memoize output of the `combineComparators` function\n * (or keep it out of component's scope if possible) before passing it down to this property.\n */\nexport const useParticipants = ({\n sortBy,\n}: {\n /**\n * Make sure to memoize output of the `combineComparators` function\n * (or keep it out of component's scope if possible) before passing it down to this property.\n */\n sortBy?: Comparator<StreamVideoParticipant>;\n} = {}) => {\n const { participants$ } = useCallState();\n const participants = useObservableValue(participants$);\n\n return useMemo(() => {\n if (sortBy) {\n return [...participants].sort(sortBy);\n }\n return participants;\n }, [participants, sortBy]);\n};\n\n/**\n * A hook which provides a StreamVideoLocalParticipant object.\n * It signals that I have joined a call.\n *\n * @category Call State\n */\nexport const useLocalParticipant = () => {\n const { localParticipant$ } = useCallState();\n return useObservableValue(localParticipant$);\n};\n\n/**\n * A hook which provides a list of all other participants than me that have joined an active call.\n *\n * @category Call State\n */\nexport const useRemoteParticipants = () => {\n const { remoteParticipants$ } = useCallState();\n return useObservableValue(remoteParticipants$);\n};\n\n/**\n * Returns the approximate participant count of the active call.\n * This includes the anonymous users as well, and it is computed on the server.\n *\n * @category Call State\n */\nexport const useParticipantCount = () => {\n const { participantCount$ } = useCallState();\n return useObservableValue(participantCount$);\n};\n\n/**\n * Returns the approximate anonymous participant count of the active call.\n * The regular participants are not included in this count. It is computed on the server.\n *\n * @category Call State\n */\nexport const useAnonymousParticipantCount = () => {\n const { anonymousParticipantCount$ } = useCallState();\n return useObservableValue(anonymousParticipantCount$);\n};\n\n/**\n * Returns the generated thumbnail of the current call, if enabled in settings.\n */\nexport const useCallThumbnail = () => {\n const { thumbnails$ } = useCallState();\n return useObservableValue(thumbnails$);\n};\n\n/**\n * Returns the camera state of the current call.\n *\n * @category Camera Manager State\n *\n */\nexport const useCameraState = () => {\n const call = useCall();\n const { camera } = call as Call;\n\n const status = useObservableValue(camera.state.status$);\n const direction = useObservableValue(camera.state.direction$);\n\n return {\n status,\n direction,\n };\n};\n\n/**\n * Returns the microphone state of the current call.\n *\n * @category Microphone Manager State\n */\nexport const useMicrophoneState = () => {\n const call = useCall();\n const { microphone } = call as Call;\n\n const status = useObservableValue(microphone.state.status$);\n const selectedDevice = useObservableValue(microphone.state.selectedDevice$);\n\n return {\n status,\n selectedDevice,\n };\n};\n\nexport const useScreenShareState = () => {\n const call = useCall();\n const { screenShare } = call as Call;\n\n const status = useObservableValue(screenShare.state.status$);\n\n return {\n status,\n };\n};\n","import { OwnCapability } from '@stream-io/video-client';\nimport { useCallState } from './callStateHooks';\nimport { useObservableValue } from './useObservableValue';\n\n/**\n * Hook that returns true if the local participant has all the given permissions.\n *\n * @param permissions the permissions to check.\n *\n * @category Call State\n */\nexport const useHasPermissions = (...permissions: OwnCapability[]): boolean => {\n const capabilities = useOwnCapabilities();\n return permissions.every((permission) => capabilities?.includes(permission));\n};\n\n/**\n * A hook which returns the local participant's own capabilities.\n *\n * @category Call State\n */\nexport const useOwnCapabilities = (): OwnCapability[] | undefined => {\n const { ownCapabilities$ } = useCallState();\n return useObservableValue(ownCapabilities$);\n};\n","import { useStreamVideoClient } from '../contexts';\nimport { useObservableValue } from './useObservableValue';\n\n/**\n * Utility hook which provides access to client's state store.\n */\nexport const useStore = () => {\n const client = useStreamVideoClient();\n if (!client) {\n throw new Error(\n `StreamVideoClient isn't initialized or this hook is called outside of <StreamVideo> context.`,\n );\n }\n return client.readOnlyStateStore;\n};\n\n/**\n * Utility hook which provides a list of all notifications about created calls.\n * In the ring call settings, these calls can be outgoing (I have called somebody)\n * or incoming (somebody has called me).\n *\n * @category Client State\n */\nexport const useCalls = () => {\n const { calls$ } = useStore();\n return useObservableValue(calls$);\n};\n\n/**\n * Returns the current connected user.\n *\n * @category Client State\n */\nexport const useConnectedUser = () => {\n const { connectedUser$ } = useStore();\n return useObservableValue(connectedUser$);\n};\n","import * as CallStateHooks from './callStateHooks';\n\nexport * from './permissions';\nexport * from './store';\n\n/**\n * A hook-alike function that exposes all call state hooks.\n *\n * @category Call State\n */\nexport const useCallStateHooks = () => CallStateHooks;\n","import { OwnCapability } from '@stream-io/video-client';\n\nimport { PropsWithChildren } from 'react';\nimport { useCall } from '../contexts';\nimport { useOwnCapabilities } from '../hooks';\n\ntype RestrictedProps = PropsWithChildren<{\n /**\n * Required grants for the component to be able to render supplied children elements\n */\n requiredGrants: OwnCapability[];\n /**\n * Render children only if user can request capability, but does not have it\n */\n canRequestOnly?: boolean;\n /**\n * Render children only if user has capability\n */\n hasPermissionsOnly?: boolean;\n /**\n * Require all grants specified in `requiredGrants` to be available in the `availableGrants`,\n * component by default requires only one grant to appear in both arrays to render its children\n */\n requireAll?: boolean;\n}>;\n\nexport const Restricted = ({\n canRequestOnly,\n hasPermissionsOnly,\n requiredGrants,\n requireAll = true,\n children,\n}: RestrictedProps) => {\n const call = useCall();\n const ownCapabilities = useOwnCapabilities();\n const hasPermissions = requiredGrants[requireAll ? 'every' : 'some'](\n (capability) => ownCapabilities?.includes(capability),\n );\n\n if (hasPermissionsOnly) return hasPermissions ? <>{children}</> : null;\n\n const canRequest = requiredGrants.some(\n (capability) => !!call && call.permissionsContext.canRequest(capability),\n );\n\n if (canRequestOnly) return canRequest ? <>{children}</> : null;\n\n if (hasPermissions || canRequest) return <>{children}</>;\n\n return null;\n};\n"],"names":["createContext","_jsx","useContext","useState","useEffect","RxUtils","CallState","useMemo","_Fragment"],"mappings":";;;;;;;AAGA,MAAM,iBAAiB,GAAGA,mBAAa,CAAmB,SAAS,CAAC,CAAC;AAWrE;;;;;;;;AAQG;AACU,MAAA,kBAAkB,GAAG,CAChC,KAAiD,KAC/C;AACF,IAAA,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AACjC,IAAA,QACEC,cAAA,CAAC,iBAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EACpC,QAAQ,EAAA,CACkB,EAC7B;AACJ,EAAE;AAEF;;;;;AAKG;AACI,MAAM,OAAO,GAAG,MAAK;AAC1B,IAAA,OAAOC,gBAAU,CAAC,iBAAiB,CAAC,CAAC;AACvC;;ACxCO,MAAM,aAAa,GAAG,CAC3B,eAAgC,EAChC,SAAiB,KAEjB,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,YAAY,CAAC,KAAI;IAClE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,GAAG,YAAY,EAAE,CAAC;AACzC,IAAA,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAA0B;;ACAxB,MAAM,gBAAgB,GAAG,KAAK;AAC9B,MAAM,iBAAiB,GAAG,eAAe;AAChD,MAAM,cAAc,GAAG;AACrB,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,eAAe,EAAE,gBAAgB;CAClC,CAAC;AAEF,MAAM,6BAA6B,GAAG,aAAa,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAE9D,MAAA,0BAA0B,GAAG,CAAC,GAAW,KAAK,IAAI;MAWlD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EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI,GAAG,IAAI,CAAC;IAE/D,IAAI,cAAc,IAAI,UAAU;QAAE,OAAOP,cAAA,CAAAO,mBAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI,CAAC;AAEzD,IAAA,OAAO,IAAI,CAAC;AACd;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import i18next from 'i18next';
|
|
4
|
+
import { RxUtils, CallState } from '@stream-io/video-client';
|
|
5
|
+
|
|
6
|
+
const StreamCallContext = createContext(undefined);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param props
|
|
10
|
+
* @returns
|
|
11
|
+
*
|
|
12
|
+
* @category Call State
|
|
13
|
+
*
|
|
14
|
+
* @react If you're using the React SDK we recommend using the `StreamCall` component that wraps the `StreamCallProvider`. You only need to use the `StreamCallProvider` for advanced use-cases.
|
|
15
|
+
*/
|
|
16
|
+
const StreamCallProvider = (props) => {
|
|
17
|
+
const { call, children } = props;
|
|
18
|
+
return (jsx(StreamCallContext.Provider, { value: call, children: children }));
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @returns
|
|
23
|
+
*
|
|
24
|
+
* @category Call State
|
|
25
|
+
*/
|
|
26
|
+
const useCall = () => {
|
|
27
|
+
return useContext(StreamCallContext);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const mapToRegistry = (translationsMap, namespace) => Object.entries(translationsMap).reduce((acc, [lng, translations]) => {
|
|
31
|
+
acc[lng] = { [namespace]: translations };
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
|
|
35
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
36
|
+
const DEFAULT_NAMESPACE = 'stream-video';
|
|
37
|
+
const DEFAULT_CONFIG = {
|
|
38
|
+
debug: false,
|
|
39
|
+
currentLanguage: DEFAULT_LANGUAGE,
|
|
40
|
+
};
|
|
41
|
+
const DEFAULT_TRANSLATIONS_REGISTRY = mapToRegistry({}, DEFAULT_NAMESPACE);
|
|
42
|
+
const defaultTranslationFunction = (key) => key;
|
|
43
|
+
class StreamI18n {
|
|
44
|
+
/** Simple logger function */
|
|
45
|
+
constructor(options = {}) {
|
|
46
|
+
/** Translator function that converts the provided string into its equivalent in the current language. */
|
|
47
|
+
this.t = defaultTranslationFunction;
|
|
48
|
+
this.init = async () => {
|
|
49
|
+
try {
|
|
50
|
+
this.t = await this.i18nInstance.init();
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
console.error(`Failed to initialize translations: ${JSON.stringify(e)}`);
|
|
54
|
+
}
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
this.changeLanguage = async (language, onChange) => {
|
|
58
|
+
if (!this._checkIsInitialized())
|
|
59
|
+
return;
|
|
60
|
+
// i18next detects the language, if none provided, but it is better
|
|
61
|
+
// to show this detection here explicitly
|
|
62
|
+
const browserLanguage = typeof window !== 'undefined' && window.navigator
|
|
63
|
+
? window.navigator.language
|
|
64
|
+
: undefined;
|
|
65
|
+
await this.i18nInstance.changeLanguage(language || browserLanguage);
|
|
66
|
+
onChange?.(this.currentLanguage);
|
|
67
|
+
};
|
|
68
|
+
this.registerTranslationsForLanguage = ({ lng, translations, }) => {
|
|
69
|
+
if (!this._checkIsInitialized())
|
|
70
|
+
return;
|
|
71
|
+
this.i18nInstance.addResourceBundle(lng, DEFAULT_NAMESPACE, translations, true, true);
|
|
72
|
+
};
|
|
73
|
+
this._checkIsInitialized = () => {
|
|
74
|
+
if (!this.i18nInstance.isInitialized) {
|
|
75
|
+
console.warn('I18n instance is not initialized. Call yourStreamI18nInstance.init().');
|
|
76
|
+
}
|
|
77
|
+
return this.i18nInstance.isInitialized;
|
|
78
|
+
};
|
|
79
|
+
const { debug = DEFAULT_CONFIG.debug, currentLanguage = DEFAULT_CONFIG.currentLanguage, translationsOverrides, } = options;
|
|
80
|
+
this.i18nInstance = i18next.createInstance({
|
|
81
|
+
debug,
|
|
82
|
+
defaultNS: DEFAULT_NAMESPACE,
|
|
83
|
+
fallbackLng: false,
|
|
84
|
+
interpolation: { escapeValue: false },
|
|
85
|
+
keySeparator: false,
|
|
86
|
+
lng: currentLanguage,
|
|
87
|
+
nsSeparator: false,
|
|
88
|
+
parseMissingKeyHandler: (key) => {
|
|
89
|
+
return key;
|
|
90
|
+
},
|
|
91
|
+
resources: DEFAULT_TRANSLATIONS_REGISTRY,
|
|
92
|
+
});
|
|
93
|
+
if (translationsOverrides) {
|
|
94
|
+
this.i18nInstance.on('initialized', () => {
|
|
95
|
+
Object.entries(translationsOverrides).forEach(([lng, translations]) => {
|
|
96
|
+
this.registerTranslationsForLanguage({ lng, translations });
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
get currentLanguage() {
|
|
102
|
+
this._checkIsInitialized();
|
|
103
|
+
return this.i18nInstance.language;
|
|
104
|
+
}
|
|
105
|
+
get isInitialized() {
|
|
106
|
+
return this.i18nInstance.isInitialized;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const StreamI18nContext = createContext({
|
|
111
|
+
t: defaultTranslationFunction,
|
|
112
|
+
});
|
|
113
|
+
const StreamI18nProvider = ({ children, ...createI18nParams }) => {
|
|
114
|
+
const { i18n, t } = useCreateI18n(createI18nParams);
|
|
115
|
+
return (jsx(StreamI18nContext.Provider, { value: { t, i18n }, children: children }));
|
|
116
|
+
};
|
|
117
|
+
const useCreateI18n = ({ i18nInstance, language, translationsOverrides, }) => {
|
|
118
|
+
const [i18n] = useState(() => i18nInstance ||
|
|
119
|
+
new StreamI18n({ currentLanguage: language, translationsOverrides }));
|
|
120
|
+
const [t, setTranslationFn] = useState(() => defaultTranslationFunction);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const { isInitialized } = i18n;
|
|
123
|
+
if (!isInitialized) {
|
|
124
|
+
i18n.init().then((_i18n) => setTranslationFn(() => _i18n.i18nInstance.t));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (language && i18n?.currentLanguage !== language) {
|
|
128
|
+
i18n.changeLanguage(language).catch((err) => {
|
|
129
|
+
console.log('Error while changing language', err);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}, [i18n, i18nInstance, language, translationsOverrides]);
|
|
133
|
+
return { i18n, t };
|
|
134
|
+
};
|
|
135
|
+
const useI18n = () => useContext(StreamI18nContext);
|
|
136
|
+
|
|
137
|
+
const StreamVideoContext = createContext(undefined);
|
|
138
|
+
/**
|
|
139
|
+
* StreamVideo is a provider component which should be used to wrap the entire application.
|
|
140
|
+
* It provides the client object to all children components and initializes the i18n instance.
|
|
141
|
+
* @param PropsWithChildren<StreamVideoProps>
|
|
142
|
+
* @category Client State
|
|
143
|
+
*/
|
|
144
|
+
const StreamVideoProvider = ({ children, client, i18nInstance, language, translationsOverrides, }) => {
|
|
145
|
+
return (jsx(StreamVideoContext.Provider, { value: client, children: jsx(StreamI18nProvider, { i18nInstance: i18nInstance, language: language, translationsOverrides: translationsOverrides, children: children }) }));
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* @returns
|
|
150
|
+
*
|
|
151
|
+
* @category Client State
|
|
152
|
+
*/
|
|
153
|
+
const useStreamVideoClient = () => {
|
|
154
|
+
return useContext(StreamVideoContext);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Utility hook which provides the current value of the given observable.
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
const useObservableValue = (observable$) => {
|
|
162
|
+
const [value, setValue] = useState(() => RxUtils.getCurrentValue(observable$));
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
const subscription = observable$.subscribe(setValue);
|
|
165
|
+
return () => {
|
|
166
|
+
subscription.unsubscribe();
|
|
167
|
+
};
|
|
168
|
+
}, [observable$]);
|
|
169
|
+
return value;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Utility hook, which provides the current call's state.
|
|
174
|
+
*
|
|
175
|
+
* @category Call State
|
|
176
|
+
*/
|
|
177
|
+
const useCallState = () => {
|
|
178
|
+
const call = useCall();
|
|
179
|
+
// return an empty and unlinked CallState object if there is no call in the provider
|
|
180
|
+
// this ensures that the hooks always return a value and many null checks can be avoided
|
|
181
|
+
if (!call) {
|
|
182
|
+
const message = 'You are using useCallState() outside a Call context. ' +
|
|
183
|
+
'Please wrap your component in <StreamCall /> and provide a "call" instance.';
|
|
184
|
+
console.warn(message);
|
|
185
|
+
return new CallState();
|
|
186
|
+
}
|
|
187
|
+
return call.state;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Utility hook which provides information whether the current call is being recorded. It will return `true` if the call is being recorded.
|
|
191
|
+
*
|
|
192
|
+
* @category Call State
|
|
193
|
+
*/
|
|
194
|
+
const useIsCallRecordingInProgress = () => {
|
|
195
|
+
const { recording$ } = useCallState();
|
|
196
|
+
return useObservableValue(recording$);
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Utility hook which provides information whether the current call is broadcasting.
|
|
200
|
+
*
|
|
201
|
+
* @category Call State
|
|
202
|
+
*/
|
|
203
|
+
const useIsCallBroadcastingInProgress = () => {
|
|
204
|
+
const { egress$ } = useCallState();
|
|
205
|
+
const egress = useObservableValue(egress$);
|
|
206
|
+
if (!egress)
|
|
207
|
+
return false;
|
|
208
|
+
return egress.broadcasting;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Utility hook which provides information whether the current call is live.
|
|
212
|
+
*
|
|
213
|
+
* @category Call State
|
|
214
|
+
*/
|
|
215
|
+
const useIsCallLive = () => {
|
|
216
|
+
const { backstage$ } = useCallState();
|
|
217
|
+
const isBackstageOn = useObservableValue(backstage$);
|
|
218
|
+
return !isBackstageOn;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Returns the list of blocked users in the current call.
|
|
222
|
+
*/
|
|
223
|
+
const useCallBlockedUserIds = () => {
|
|
224
|
+
const { blockedUserIds$ } = useCallState();
|
|
225
|
+
return useObservableValue(blockedUserIds$);
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Returns the timestamp when this call was created.
|
|
229
|
+
*/
|
|
230
|
+
const useCallCreatedAt = () => {
|
|
231
|
+
const { createdAt$ } = useCallState();
|
|
232
|
+
return useObservableValue(createdAt$);
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Returns the timestamp when this call was ended.
|
|
236
|
+
*/
|
|
237
|
+
const useCallEndedAt = () => {
|
|
238
|
+
const { endedAt$ } = useCallState();
|
|
239
|
+
return useObservableValue(endedAt$);
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Returns the timestamp telling when the call is scheduled to start.
|
|
243
|
+
*/
|
|
244
|
+
const useCallStartsAt = () => {
|
|
245
|
+
const { startsAt$ } = useCallState();
|
|
246
|
+
return useObservableValue(startsAt$);
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Returns the timestamp when this call was updated.
|
|
250
|
+
*/
|
|
251
|
+
const useCallUpdatedAt = () => {
|
|
252
|
+
const { updatedAt$ } = useCallState();
|
|
253
|
+
return useObservableValue(updatedAt$);
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Returns the information about the call's creator.
|
|
257
|
+
*/
|
|
258
|
+
const useCallCreatedBy = () => {
|
|
259
|
+
const { createdBy$ } = useCallState();
|
|
260
|
+
return useObservableValue(createdBy$);
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Returns the call's custom data.
|
|
264
|
+
*/
|
|
265
|
+
const useCallCustomData = () => {
|
|
266
|
+
const { custom$ } = useCallState();
|
|
267
|
+
return useObservableValue(custom$);
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Returns the call's Egress information.
|
|
271
|
+
*/
|
|
272
|
+
const useCallEgress = () => {
|
|
273
|
+
const { egress$ } = useCallState();
|
|
274
|
+
return useObservableValue(egress$);
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Returns the call's Ingress information.
|
|
278
|
+
*/
|
|
279
|
+
const useCallIngress = () => {
|
|
280
|
+
const { ingress$ } = useCallState();
|
|
281
|
+
return useObservableValue(ingress$);
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Returns the data for the current call session.
|
|
285
|
+
*/
|
|
286
|
+
const useCallSession = () => {
|
|
287
|
+
const { session$ } = useCallState();
|
|
288
|
+
return useObservableValue(session$);
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Returns the call's settings.
|
|
292
|
+
*/
|
|
293
|
+
const useCallSettings = () => {
|
|
294
|
+
const { settings$ } = useCallState();
|
|
295
|
+
return useObservableValue(settings$);
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Returns whether the call has transcribing enabled.
|
|
299
|
+
*/
|
|
300
|
+
const useIsCallTranscribingInProgress = () => {
|
|
301
|
+
const { transcribing$ } = useCallState();
|
|
302
|
+
return useObservableValue(transcribing$);
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Returns information about the user who has marked this call as ended.
|
|
306
|
+
*/
|
|
307
|
+
const useCallEndedBy = () => {
|
|
308
|
+
const { endedBy$ } = useCallState();
|
|
309
|
+
return useObservableValue(endedBy$);
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Utility hook which provides a boolean indicating whether there is
|
|
313
|
+
* a participant in the current call which shares their screen.
|
|
314
|
+
*
|
|
315
|
+
* @category Call State
|
|
316
|
+
*/
|
|
317
|
+
const useHasOngoingScreenShare = () => {
|
|
318
|
+
const { hasOngoingScreenShare$ } = useCallState();
|
|
319
|
+
return useObservableValue(hasOngoingScreenShare$);
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Utility hook which provides the latest stats report of the current call.
|
|
323
|
+
*
|
|
324
|
+
* The latest stats report of the current call.
|
|
325
|
+
* When stats gathering is enabled, this observable will emit a new value
|
|
326
|
+
* at a regular (configurable) interval.
|
|
327
|
+
*
|
|
328
|
+
* Consumers of this observable can implement their own batching logic
|
|
329
|
+
* in case they want to show historical stats data.
|
|
330
|
+
*
|
|
331
|
+
* @category Call State
|
|
332
|
+
*/
|
|
333
|
+
const useCallStatsReport = () => {
|
|
334
|
+
const { callStatsReport$ } = useCallState();
|
|
335
|
+
return useObservableValue(callStatsReport$);
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Utility hook which provides the dominant speaker of the current call.
|
|
339
|
+
*
|
|
340
|
+
* @category Call State
|
|
341
|
+
*/
|
|
342
|
+
const useDominantSpeaker = () => {
|
|
343
|
+
const { dominantSpeaker$ } = useCallState();
|
|
344
|
+
return useObservableValue(dominantSpeaker$);
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Utility hook which provides a list of call members.
|
|
348
|
+
*
|
|
349
|
+
* @category Call State
|
|
350
|
+
*/
|
|
351
|
+
const useCallMembers = () => {
|
|
352
|
+
const { members$ } = useCallState();
|
|
353
|
+
return useObservableValue(members$);
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Utility hook providing the current calling state of the call. For example, `RINGING` or `JOINED`.
|
|
357
|
+
*
|
|
358
|
+
* @category Call State
|
|
359
|
+
*/
|
|
360
|
+
const useCallCallingState = () => {
|
|
361
|
+
const { callingState$ } = useCallState();
|
|
362
|
+
return useObservableValue(callingState$);
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Utility hook providing the actual start time of the current session.
|
|
366
|
+
* Useful for calculating the call duration.
|
|
367
|
+
*
|
|
368
|
+
* @category Call State
|
|
369
|
+
*/
|
|
370
|
+
const useCallStartedAt = () => {
|
|
371
|
+
const { startedAt$ } = useCallState();
|
|
372
|
+
return useObservableValue(startedAt$);
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* A hook which provides a list of all participants that have joined an active call.
|
|
376
|
+
*
|
|
377
|
+
* @category Call State
|
|
378
|
+
*
|
|
379
|
+
* @param options.sortBy - A comparator function to sort the participants by.
|
|
380
|
+
* Make sure to memoize output of the `combineComparators` function
|
|
381
|
+
* (or keep it out of component's scope if possible) before passing it down to this property.
|
|
382
|
+
*/
|
|
383
|
+
const useParticipants = ({ sortBy, } = {}) => {
|
|
384
|
+
const { participants$ } = useCallState();
|
|
385
|
+
const participants = useObservableValue(participants$);
|
|
386
|
+
return useMemo(() => {
|
|
387
|
+
if (sortBy) {
|
|
388
|
+
return [...participants].sort(sortBy);
|
|
389
|
+
}
|
|
390
|
+
return participants;
|
|
391
|
+
}, [participants, sortBy]);
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* A hook which provides a StreamVideoLocalParticipant object.
|
|
395
|
+
* It signals that I have joined a call.
|
|
396
|
+
*
|
|
397
|
+
* @category Call State
|
|
398
|
+
*/
|
|
399
|
+
const useLocalParticipant = () => {
|
|
400
|
+
const { localParticipant$ } = useCallState();
|
|
401
|
+
return useObservableValue(localParticipant$);
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* A hook which provides a list of all other participants than me that have joined an active call.
|
|
405
|
+
*
|
|
406
|
+
* @category Call State
|
|
407
|
+
*/
|
|
408
|
+
const useRemoteParticipants = () => {
|
|
409
|
+
const { remoteParticipants$ } = useCallState();
|
|
410
|
+
return useObservableValue(remoteParticipants$);
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Returns the approximate participant count of the active call.
|
|
414
|
+
* This includes the anonymous users as well, and it is computed on the server.
|
|
415
|
+
*
|
|
416
|
+
* @category Call State
|
|
417
|
+
*/
|
|
418
|
+
const useParticipantCount = () => {
|
|
419
|
+
const { participantCount$ } = useCallState();
|
|
420
|
+
return useObservableValue(participantCount$);
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Returns the approximate anonymous participant count of the active call.
|
|
424
|
+
* The regular participants are not included in this count. It is computed on the server.
|
|
425
|
+
*
|
|
426
|
+
* @category Call State
|
|
427
|
+
*/
|
|
428
|
+
const useAnonymousParticipantCount = () => {
|
|
429
|
+
const { anonymousParticipantCount$ } = useCallState();
|
|
430
|
+
return useObservableValue(anonymousParticipantCount$);
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Returns the generated thumbnail of the current call, if enabled in settings.
|
|
434
|
+
*/
|
|
435
|
+
const useCallThumbnail = () => {
|
|
436
|
+
const { thumbnails$ } = useCallState();
|
|
437
|
+
return useObservableValue(thumbnails$);
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Returns the camera state of the current call.
|
|
441
|
+
*
|
|
442
|
+
* @category Camera Manager State
|
|
443
|
+
*
|
|
444
|
+
*/
|
|
445
|
+
const useCameraState = () => {
|
|
446
|
+
const call = useCall();
|
|
447
|
+
const { camera } = call;
|
|
448
|
+
const status = useObservableValue(camera.state.status$);
|
|
449
|
+
const direction = useObservableValue(camera.state.direction$);
|
|
450
|
+
return {
|
|
451
|
+
status,
|
|
452
|
+
direction,
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Returns the microphone state of the current call.
|
|
457
|
+
*
|
|
458
|
+
* @category Microphone Manager State
|
|
459
|
+
*/
|
|
460
|
+
const useMicrophoneState = () => {
|
|
461
|
+
const call = useCall();
|
|
462
|
+
const { microphone } = call;
|
|
463
|
+
const status = useObservableValue(microphone.state.status$);
|
|
464
|
+
const selectedDevice = useObservableValue(microphone.state.selectedDevice$);
|
|
465
|
+
return {
|
|
466
|
+
status,
|
|
467
|
+
selectedDevice,
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
const useScreenShareState = () => {
|
|
471
|
+
const call = useCall();
|
|
472
|
+
const { screenShare } = call;
|
|
473
|
+
const status = useObservableValue(screenShare.state.status$);
|
|
474
|
+
return {
|
|
475
|
+
status,
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
var CallStateHooks = /*#__PURE__*/Object.freeze({
|
|
480
|
+
__proto__: null,
|
|
481
|
+
useAnonymousParticipantCount: useAnonymousParticipantCount,
|
|
482
|
+
useCallBlockedUserIds: useCallBlockedUserIds,
|
|
483
|
+
useCallCallingState: useCallCallingState,
|
|
484
|
+
useCallCreatedAt: useCallCreatedAt,
|
|
485
|
+
useCallCreatedBy: useCallCreatedBy,
|
|
486
|
+
useCallCustomData: useCallCustomData,
|
|
487
|
+
useCallEgress: useCallEgress,
|
|
488
|
+
useCallEndedAt: useCallEndedAt,
|
|
489
|
+
useCallEndedBy: useCallEndedBy,
|
|
490
|
+
useCallIngress: useCallIngress,
|
|
491
|
+
useCallMembers: useCallMembers,
|
|
492
|
+
useCallSession: useCallSession,
|
|
493
|
+
useCallSettings: useCallSettings,
|
|
494
|
+
useCallStartedAt: useCallStartedAt,
|
|
495
|
+
useCallStartsAt: useCallStartsAt,
|
|
496
|
+
useCallState: useCallState,
|
|
497
|
+
useCallStatsReport: useCallStatsReport,
|
|
498
|
+
useCallThumbnail: useCallThumbnail,
|
|
499
|
+
useCallUpdatedAt: useCallUpdatedAt,
|
|
500
|
+
useCameraState: useCameraState,
|
|
501
|
+
useDominantSpeaker: useDominantSpeaker,
|
|
502
|
+
useHasOngoingScreenShare: useHasOngoingScreenShare,
|
|
503
|
+
useIsCallBroadcastingInProgress: useIsCallBroadcastingInProgress,
|
|
504
|
+
useIsCallLive: useIsCallLive,
|
|
505
|
+
useIsCallRecordingInProgress: useIsCallRecordingInProgress,
|
|
506
|
+
useIsCallTranscribingInProgress: useIsCallTranscribingInProgress,
|
|
507
|
+
useLocalParticipant: useLocalParticipant,
|
|
508
|
+
useMicrophoneState: useMicrophoneState,
|
|
509
|
+
useParticipantCount: useParticipantCount,
|
|
510
|
+
useParticipants: useParticipants,
|
|
511
|
+
useRemoteParticipants: useRemoteParticipants,
|
|
512
|
+
useScreenShareState: useScreenShareState
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Hook that returns true if the local participant has all the given permissions.
|
|
517
|
+
*
|
|
518
|
+
* @param permissions the permissions to check.
|
|
519
|
+
*
|
|
520
|
+
* @category Call State
|
|
521
|
+
*/
|
|
522
|
+
const useHasPermissions = (...permissions) => {
|
|
523
|
+
const capabilities = useOwnCapabilities();
|
|
524
|
+
return permissions.every((permission) => capabilities?.includes(permission));
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* A hook which returns the local participant's own capabilities.
|
|
528
|
+
*
|
|
529
|
+
* @category Call State
|
|
530
|
+
*/
|
|
531
|
+
const useOwnCapabilities = () => {
|
|
532
|
+
const { ownCapabilities$ } = useCallState();
|
|
533
|
+
return useObservableValue(ownCapabilities$);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Utility hook which provides access to client's state store.
|
|
538
|
+
*/
|
|
539
|
+
const useStore = () => {
|
|
540
|
+
const client = useStreamVideoClient();
|
|
541
|
+
if (!client) {
|
|
542
|
+
throw new Error(`StreamVideoClient isn't initialized or this hook is called outside of <StreamVideo> context.`);
|
|
543
|
+
}
|
|
544
|
+
return client.readOnlyStateStore;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Utility hook which provides a list of all notifications about created calls.
|
|
548
|
+
* In the ring call settings, these calls can be outgoing (I have called somebody)
|
|
549
|
+
* or incoming (somebody has called me).
|
|
550
|
+
*
|
|
551
|
+
* @category Client State
|
|
552
|
+
*/
|
|
553
|
+
const useCalls = () => {
|
|
554
|
+
const { calls$ } = useStore();
|
|
555
|
+
return useObservableValue(calls$);
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Returns the current connected user.
|
|
559
|
+
*
|
|
560
|
+
* @category Client State
|
|
561
|
+
*/
|
|
562
|
+
const useConnectedUser = () => {
|
|
563
|
+
const { connectedUser$ } = useStore();
|
|
564
|
+
return useObservableValue(connectedUser$);
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* A hook-alike function that exposes all call state hooks.
|
|
569
|
+
*
|
|
570
|
+
* @category Call State
|
|
571
|
+
*/
|
|
572
|
+
const useCallStateHooks = () => CallStateHooks;
|
|
573
|
+
|
|
574
|
+
const Restricted = ({ canRequestOnly, hasPermissionsOnly, requiredGrants, requireAll = true, children, }) => {
|
|
575
|
+
const call = useCall();
|
|
576
|
+
const ownCapabilities = useOwnCapabilities();
|
|
577
|
+
const hasPermissions = requiredGrants[requireAll ? 'every' : 'some']((capability) => ownCapabilities?.includes(capability));
|
|
578
|
+
if (hasPermissionsOnly)
|
|
579
|
+
return hasPermissions ? jsx(Fragment, { children: children }) : null;
|
|
580
|
+
const canRequest = requiredGrants.some((capability) => !!call && call.permissionsContext.canRequest(capability));
|
|
581
|
+
if (canRequestOnly)
|
|
582
|
+
return canRequest ? jsx(Fragment, { children: children }) : null;
|
|
583
|
+
if (hasPermissions || canRequest)
|
|
584
|
+
return jsx(Fragment, { children: children });
|
|
585
|
+
return null;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
export { DEFAULT_LANGUAGE, DEFAULT_NAMESPACE, Restricted, StreamCallProvider, StreamI18n, StreamI18nProvider, StreamVideoProvider, defaultTranslationFunction, mapToRegistry, useCall, useCallStateHooks, useCalls, useConnectedUser, useCreateI18n, useHasPermissions, useI18n, useOwnCapabilities, useStore, useStreamVideoClient };
|
|
589
|
+
//# sourceMappingURL=index.es.js.map
|