UNPKG

bigbluebutton-html-plugin-sdk

Version:

This repository contains the SDK for developing BigBlueButton plugins. Plugins are React components that can be loaded from external sources by the BigBlueButton HTML5 client to extend its functionalities.

156 lines 9.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BbbPluginSdk = void 0; /* eslint-disable no-console */ var react_1 = require("react"); var hook_1 = __importDefault(require("../auxiliary/plugin-unmount/hook")); var enums_1 = require("../../data-channel/enums"); var commands_1 = require("../../ui-commands/commands"); var hooks_1 = require("../../data-channel/hooks"); var hooks_2 = require("../../data-consumption/domain/presentations/current-presentation/hooks"); var hooks_3 = require("../../data-consumption/domain/shared/custom-subscription/hooks"); var hooks_4 = require("../../data-consumption/domain/users/loaded-user-list/hooks"); var hooks_5 = require("../../data-consumption/domain/users/current-user/hooks"); var hooks_6 = require("../../data-consumption/domain/users/users-basic-info/hooks"); var getter_1 = require("../auxiliary/session-token/getter"); var getter_2 = require("../auxiliary/join-url/getter"); var settings_1 = require("../../data-consumption/domain/settings"); var hooks_7 = require("../../data-consumption/domain/chat/loaded-chat-messages/hooks"); var hooks_8 = require("../../dom-element-manipulation/chat/message/hooks"); var hooks_9 = require("../../dom-element-manipulation/user-camera/hooks"); var hooks_10 = require("../../data-consumption/domain/user-voice/talking-indicator/hooks"); var hooks_11 = require("../../ui-data/hooks/hooks"); var hooks_12 = require("../../data-consumption/domain/meeting/from-core/hooks"); var commands_2 = require("../../server-commands/commands"); var hooks_13 = require("../../learning-analytics-dashboard/hooks"); var utils_1 = require("../../remote-data/utils"); var hooks_14 = require("../../event-persistence/hooks"); var useLocaleMessages_1 = __importDefault(require("../auxiliary/plugin-information/locale-messages/useLocaleMessages")); var getters_1 = require("../../ui-data/getters/getters"); var hooks_15 = require("../../data-consumption/domain/shared/custom-query/hooks"); var hook_2 = require("../../data-creation/hook"); /** * Class responsible for either initialize or get the PluginApi * * This PluginApi, is the object with which the developer can control * things in the plugin, such as the extensible areas or the hooks * */ var BbbPluginSdk = /** @class */ (function () { function BbbPluginSdk() { } /** * Method responsible for initializing the hooks use it from the plugin-side if you are using * one of the hooks, see complete list in the README.md * * @remarks * This method is part of the BbbPluginSdk abstract class. * * @param uuid - The UUID generated by the html5 in which the developer can get with * `document.currentScript?.getAttribute('uuid')` see any sample * */ BbbPluginSdk.initialize = function (uuid) { if (!this.isReactEnvironment()) throw new Error('Initializing pluginApi outside of a react function component. It should be done inside'); var pluginApi = window.bbb_plugins[uuid]; pluginApi.useCustomSubscription = (function (query, variablesObjectWrapper) { return (0, hooks_3.useCustomSubscription)(query, variablesObjectWrapper); }); pluginApi.useCustomQuery = (function (query, variablesObjectWrapper) { return (0, hooks_15.useCustomQuery)(query, variablesObjectWrapper); }); pluginApi.useCustomMutation = (function (mutation, options) { return (0, hook_2.useCustomMutation)(mutation, options); }); pluginApi.useCurrentPresentation = (function () { return (0, hooks_2.useCurrentPresentation)(); }); pluginApi.useLoadedUserList = (function () { return (0, hooks_4.useLoadedUserList)(); }); pluginApi.useCurrentUser = (function () { return (0, hooks_5.useCurrentUser)(); }); pluginApi.useMeeting = (function () { return (0, hooks_12.useMeeting)(); }); pluginApi.useUsersBasicInfo = (function () { return (0, hooks_6.useUsersBasicInfo)(); }); pluginApi.useTalkingIndicator = (function () { return (0, hooks_10.useTalkingIndicator)(); }); pluginApi.getJoinUrl = function (params) { return (0, getter_2.getJoinUrl)(params); }; pluginApi.useLoadedChatMessages = (function () { return (0, hooks_7.useLoadedChatMessages)(); }); pluginApi.useChatMessageDomElements = function (messageIds) { return (0, hooks_8.useChatMessageDomElements)(messageIds, uuid); }; pluginApi.useUserCameraDomElements = function (streamIds) { return (0, hooks_9.useUserCameraDomElements)(streamIds, uuid); }; pluginApi.uiCommands = commands_1.uiCommands; pluginApi.useUiData = hooks_11.useUiData; pluginApi.getUiData = getters_1.getUiData; var pluginName = pluginApi === null || pluginApi === void 0 ? void 0 : pluginApi.pluginName; pluginApi.useShouldUnmountPlugin = hook_1.default; if (pluginName) { pluginApi.useDataChannel = (function (channelName, dataChannelType, subChannelName) { if (dataChannelType === void 0) { dataChannelType = enums_1.DataChannelTypes.ALL_ITEMS; } if (subChannelName === void 0) { subChannelName = 'default'; } return (0, hooks_1.useDataChannelGeneral)(channelName, subChannelName, pluginName, window.bbb_plugins[uuid], dataChannelType); }); pluginApi.usePluginSettings = function () { return (0, settings_1.usePluginSettings)(pluginName); }; pluginApi.serverCommands = (0, commands_2.serverCommands)(pluginName); pluginApi.sendGenericDataForLearningAnalyticsDashboard = function (data) { return (0, hooks_13.sendGenericDataForLearningAnalyticsDashboard)(data, pluginName); }; pluginApi.getRemoteData = function (dataSourceName) { return (0, utils_1.getRemoteData)(dataSourceName, pluginName); }; pluginApi .persistEvent = function (eventName, payload) { return (0, hooks_14.persistEventFunctionWrapper)(pluginName, eventName, payload); }; pluginApi.useLocaleMessages = function (fetchConfigs) { return (0, useLocaleMessages_1.default)({ pluginApi: pluginApi, fetchConfigs: fetchConfigs }); }; } else { throw new Error('Plugin name not set'); } }; BbbPluginSdk.isReactEnvironment = function () { var fn = console.error; try { console.error = function () { }; (0, react_1.useEffect)(function () { }, []); } catch (_a) { console.error = fn; console.error('[PLUGIN-ERROR] Error: Initializing pluginApi outside of a react function component. It should be done inside'); return false; } console.error = fn; return true; }; /** * Returns the PluginApi. Use the PluginApi to access the hooks or setters functions for all the * extensible areas. For a complete list of those, see README.md * * @param uuid - The UUID generated by the html5 in which the developer can get with * `document.currentScript?.getAttribute('uuid')` see any sample. * * @param pluginName - The PluginName given by the html5 in which the developer can get with * `document.currentScript?.getAttribute('pluginName')` see any sample. * * @returns The PluginApi object * */ BbbPluginSdk.getPluginApi = function (uuid, pluginName, localesBaseUrl) { if (!window.bbb_plugins) window.bbb_plugins = {}; if (Object.keys(window.bbb_plugins).indexOf(uuid) === -1) { window.bbb_plugins[uuid] = { setUserListDropdownItems: function () { return []; }, setPresentationToolbarItems: function () { return []; }, setActionButtonDropdownItems: function () { return []; }, setActionsBarItems: function () { return []; }, setAudioSettingsDropdownItems: function () { return []; }, setPresentationDropdownItems: function () { return []; }, setNavBarItems: function () { return []; }, setScreenshareHelperItems: function () { return []; }, setUserCameraHelperItems: function () { return []; }, setOptionsDropdownItems: function () { return []; }, setCameraSettingsDropdownItems: function () { return []; }, setUserCameraDropdownItems: function () { return []; }, setUserListItemAdditionalInformation: function () { return []; }, setFloatingWindows: function () { return []; }, setGenericContentItems: function () { return []; }, mapOfPushEntryFunctions: { '': function () { }, }, getSessionToken: function () { return (0, getter_1.getSessionToken)(); }, pluginName: pluginName, localesBaseUrl: localesBaseUrl, }; } return window.bbb_plugins[uuid]; }; return BbbPluginSdk; }()); exports.BbbPluginSdk = BbbPluginSdk; //# sourceMappingURL=BbbPluginSdk.js.map