@jitsi/react-sdk
Advanced tools
Comparing version 1.0.2 to 1.1.0
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import { useCallback, useEffect, useRef, useState } from 'react'; | ||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; | ||
import { DEFAULT_DOMAIN } from '../constants'; | ||
@@ -23,3 +23,2 @@ import { fetchExternalApi } from '../init'; | ||
const JitsiMeeting = ({ domain = DEFAULT_DOMAIN, roomName, configOverwrite, interfaceConfigOverwrite, jwt, invitees, devices, userInfo, release, spinner: Spinner, onApiReady, onReadyToClose, getIFrameRef }) => { | ||
const [componentId, setComponentId] = useState(''); | ||
const [loading, setLoading] = useState(true); | ||
@@ -30,5 +29,5 @@ const [apiLoaded, setApiLoaded] = useState(false); | ||
const meetingRef = useRef(null); | ||
const componentId = useMemo(() => generateComponentId('jitsiMeeting'), [generateComponentId]); | ||
useEffect(() => { | ||
setComponentId(generateComponentId('jitsiMeeting')); | ||
fetchExternalApi(domain) | ||
fetchExternalApi(domain, release) | ||
.then((api) => { | ||
@@ -41,4 +40,3 @@ externalApi.current = api; | ||
const loadIFrame = useCallback((JitsiMeetExternalAPI) => { | ||
apiRef.current = new JitsiMeetExternalAPI(domain, { | ||
roomName, | ||
apiRef.current = new JitsiMeetExternalAPI(domain, Object.assign(Object.assign({ roomName, | ||
configOverwrite, | ||
@@ -49,6 +47,3 @@ interfaceConfigOverwrite, | ||
devices, | ||
userInfo, | ||
release, | ||
parentNode: meetingRef.current | ||
}); | ||
userInfo }, release ? { release: `release-${release}` } : {}), { parentNode: meetingRef.current })); | ||
setLoading(false); | ||
@@ -55,0 +50,0 @@ if (apiRef.current) { |
import { JitsiMeetExternalApi } from './types'; | ||
/** | ||
* Injects the external_api.js script for the corresponding domain in DOM | ||
* and resolves with either the `JitsiMeetExternalApi` class definition or an error | ||
* and resolves with either the `JitsiMeetExternalApi` class definition or an error. | ||
* | ||
* Only the first script will be injected, therefore avoid using multiple instances | ||
* with mixed domains and release version at the same time. | ||
* | ||
* @param {string} domain - The domain of the external API | ||
* @returns {Promise<JitsiMeetExternalApi>} - the JitsiMeetExternalAPI or an error | ||
* @param {string} release - The Jitsi Meet release | ||
* @returns {Promise<JitsiMeetExternalApi>} - The JitsiMeetExternalAPI or an error | ||
*/ | ||
export declare const fetchExternalApi: (domain?: string) => Promise<JitsiMeetExternalApi>; | ||
export declare const fetchExternalApi: (domain?: string, release?: string | undefined) => Promise<JitsiMeetExternalApi>; |
@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { DEFAULT_DOMAIN } from './constants'; | ||
const loadExternalApi = (domain) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadExternalApi = (domain, release) => __awaiter(void 0, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
@@ -18,4 +18,5 @@ if (window.JitsiMeetExternalAPI) { | ||
const script = document.createElement('script'); | ||
const releaseParam = release ? `?release=release-${release}` : ''; | ||
script.async = true; | ||
script.src = `https://${domain}/external_api.js`; | ||
script.src = `https://${domain}/external_api.js${releaseParam}`; | ||
script.onload = () => resolve(window.JitsiMeetExternalAPI); | ||
@@ -29,13 +30,17 @@ script.onerror = () => reject(new Error(`Script load error: ${script.src}`)); | ||
* Injects the external_api.js script for the corresponding domain in DOM | ||
* and resolves with either the `JitsiMeetExternalApi` class definition or an error | ||
* and resolves with either the `JitsiMeetExternalApi` class definition or an error. | ||
* | ||
* Only the first script will be injected, therefore avoid using multiple instances | ||
* with mixed domains and release version at the same time. | ||
* | ||
* @param {string} domain - The domain of the external API | ||
* @returns {Promise<JitsiMeetExternalApi>} - the JitsiMeetExternalAPI or an error | ||
* @param {string} release - The Jitsi Meet release | ||
* @returns {Promise<JitsiMeetExternalApi>} - The JitsiMeetExternalAPI or an error | ||
*/ | ||
export const fetchExternalApi = (domain = DEFAULT_DOMAIN) => { | ||
export const fetchExternalApi = (domain = DEFAULT_DOMAIN, release) => { | ||
if (scriptPromise) { | ||
return scriptPromise; | ||
} | ||
scriptPromise = loadExternalApi(domain); | ||
scriptPromise = loadExternalApi(domain, release); | ||
return scriptPromise; | ||
}; |
@@ -61,3 +61,2 @@ import React from 'react'; | ||
* The `stage.8x8.vc` or `8x8.vc` release version to test. | ||
* Expects the following format: `release-${number}`. | ||
*/ | ||
@@ -64,0 +63,0 @@ release?: string; |
@@ -78,3 +78,3 @@ import { IJitsiMeetExternalApi } from '.'; | ||
* The `stage.8x8.vc` or `8x8.vc` release version to test. | ||
* Expects the following format: `release-${number}`. | ||
* Expects the following format: `release-${string}`. | ||
*/ | ||
@@ -81,0 +81,0 @@ release?: string; |
{ | ||
"name": "@jitsi/react-sdk", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "React SDK for the Jitsi Meet IFrame", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -97,3 +97,3 @@ # Jitsi Meet React SDK | ||
###### `release` | ||
Optional. Information regarding the `stage.8x8.vc` or `8x8.vc` release version. Expects the following format: `release-${number}`. | ||
Optional. Information regarding the `stage.8x8.vc` or `8x8.vc` release version. | ||
@@ -100,0 +100,0 @@ ###### `spinner` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40775
722