UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

54 lines 2.55 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import React from 'react'; import { parseReactVersion } from './utils'; const reactVersion = React.version; parseReactVersion(reactVersion); import { createRoot } from 'react-dom/client'; import { CallComposite, createAzureCommunicationCallAdapter } from "../../react-composites/src/index-public"; import { initializeIcons } from '@fluentui/react'; /** * Loader function for the CallComposite that you can use in your application. This * function will load the CallComposite into the provided HTML element. The best use case for this * is in a Node ui framework that is not React based. * * @public */ export const loadCallComposite = function (loaderArgs, htmlElement) { return __awaiter(this, void 0, void 0, function* () { initializeIcons(); const { userId, credential, displayName, locator, callAdapterOptions, callCompositeOptions, formFactor, fluentTheme, icons, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl, locale } = loaderArgs; const adapter = yield createAzureCommunicationCallAdapter({ userId, displayName: displayName !== null && displayName !== void 0 ? displayName : 'anonymous', credential, locator, options: callAdapterOptions }); if (!htmlElement) { throw new Error('Failed to find the root element'); } createRoot(htmlElement).render(React.createElement(CallComposite, { options: callCompositeOptions, adapter, formFactor, fluentTheme, icons, locale, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl }, null)); return adapter; }); }; //# sourceMappingURL=callCompositeLoader.js.map