communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
55 lines • 2.66 kB
JavaScript
// 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 { createAzureCommunicationCallWithChatAdapter, CallWithChatComposite } from "../../react-composites/src/index-public";
import { initializeIcons } from '@fluentui/react';
/**
* Props for the CallWithChatComposite that you can use in your application. This
* function will load the CallWithChatComposite 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 loadCallWithChatComposite = function (loaderArgs, htmlElement) {
return __awaiter(this, void 0, void 0, function* () {
initializeIcons();
const { userId, credential, displayName, endpoint, locator, callAdapterOptions, callWithChatCompositeOptions, formFactor, fluentTheme, locale, icons, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl } = loaderArgs;
const adapter = yield createAzureCommunicationCallWithChatAdapter({
userId,
displayName: displayName !== null && displayName !== void 0 ? displayName : 'anonymous',
credential,
endpoint: endpoint,
locator: locator,
callAdapterOptions
});
if (!htmlElement) {
throw new Error('Failed to find the root element');
}
createRoot(htmlElement).render(React.createElement(CallWithChatComposite, {
options: callWithChatCompositeOptions,
adapter,
formFactor,
fluentTheme,
icons,
locale,
onFetchAvatarPersonaData,
onFetchParticipantMenuItems,
rtl
}, null));
return adapter;
});
};
//# sourceMappingURL=callWithChatCompositeLoader.js.map