@whereby.com/core 1.21.1 → 1.22.0

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/dist/index.cjs CHANGED
@@ -972,15 +972,6 @@ class RoomService {
972
972
  }
973
973
  }
974
974
 
975
- class LiveCaption {
976
- constructor({ resultId, senderId, text }) {
977
- this.resultId = resultId;
978
- this.participantId = senderId;
979
- this.text = text;
980
- this.timestamp = Date.now();
981
- }
982
- }
983
-
984
975
  /******************************************************************************
985
976
  Copyright (c) Microsoft Corporation.
986
977
 
@@ -1025,6 +1016,49 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1025
1016
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1026
1017
  };
1027
1018
 
1019
+ function roomPath(organizationId, roomName, suffix = "") {
1020
+ const encodedRoomName = encodeURIComponent(roomName.replace(/^\//, ""));
1021
+ return `/organizations/${encodeURIComponent(organizationId)}/room/${encodedRoomName}${suffix}`;
1022
+ }
1023
+ function asArray(value) {
1024
+ return Array.isArray(value) ? value : [];
1025
+ }
1026
+ class RoomIntegrationService {
1027
+ constructor({ apiClient }) {
1028
+ this._apiClient = apiClient;
1029
+ }
1030
+ findRoomIntegrations(_a) {
1031
+ return __awaiter(this, arguments, void 0, function* ({ organizationId, roomName, }) {
1032
+ const response = yield this._apiClient.request(roomPath(organizationId, roomName, "/room-integrations"), {
1033
+ method: "GET",
1034
+ });
1035
+ const data = (response.data || {});
1036
+ return {
1037
+ enabledRoomIntegrations: asArray(data.enabledRoomIntegrations),
1038
+ disabledRoomIntegrations: asArray(data.disabledRoomIntegrations),
1039
+ unavailableRoomIntegrations: asArray(data.unavailableRoomIntegrations),
1040
+ };
1041
+ });
1042
+ }
1043
+ toggleRoomIntegration(_a) {
1044
+ return __awaiter(this, arguments, void 0, function* ({ organizationId, roomName, roomIntegrationId, enable, }) {
1045
+ yield this._apiClient.request(roomPath(organizationId, roomName, `/room-integrations/${roomIntegrationId}`), {
1046
+ method: "PUT",
1047
+ data: { enable },
1048
+ });
1049
+ });
1050
+ }
1051
+ }
1052
+
1053
+ class LiveCaption {
1054
+ constructor({ resultId, senderId, text }) {
1055
+ this.resultId = resultId;
1056
+ this.participantId = senderId;
1057
+ this.text = text;
1058
+ this.timestamp = Date.now();
1059
+ }
1060
+ }
1061
+
1028
1062
  function getUsableCameraEffectPresets() {
1029
1063
  return __awaiter(this, void 0, void 0, function* () {
1030
1064
  const { getUsablePresets } = yield import('@whereby.com/camera-effects');
@@ -1038,6 +1072,54 @@ function isAudioDenoiserSupported() {
1038
1072
  });
1039
1073
  }
1040
1074
 
1075
+ function roomIntegrationContentTagName(integrationName) {
1076
+ return `${integrationName}-integration-contentframe`;
1077
+ }
1078
+ const YOUTUBE_ID = /(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/|live\/))([\w-]{11})/i;
1079
+ const YOUTUBE_BARE_ID = /^[\w-]{11}$/;
1080
+ function youtubeStartSeconds(url) {
1081
+ const match = url.match(/[?&](?:t|start)=(\d+)s?/i);
1082
+ return match ? parseInt(match[1], 10) : 0;
1083
+ }
1084
+ function youtube({ url, startAt, metadata = {}, }) {
1085
+ var _a;
1086
+ const trimmed = (url || "").trim();
1087
+ const videoref = YOUTUBE_BARE_ID.test(trimmed) ? trimmed : (_a = trimmed.match(YOUTUBE_ID)) === null || _a === void 0 ? void 0 : _a[1];
1088
+ if (!videoref) {
1089
+ return null;
1090
+ }
1091
+ const time = startAt !== null && startAt !== void 0 ? startAt : youtubeStartSeconds(trimmed);
1092
+ const { aspectRatio = 16 / 9, isLive = false, title } = metadata;
1093
+ return {
1094
+ tagName: roomIntegrationContentTagName("youtube"),
1095
+ shareUrl: `https://www.youtube.com/watch?v=${videoref}${time ? `&t=${time}s` : ""}`,
1096
+ props: {
1097
+ videoref,
1098
+ time,
1099
+ seek: time,
1100
+ playerstate: "playing",
1101
+ started: Date.now() + 4000,
1102
+ paused: false,
1103
+ aspectratio: aspectRatio,
1104
+ islive: isLive,
1105
+ metadata: JSON.stringify(Object.assign({ id: videoref, aspectratio: aspectRatio, live: isLive }, (title ? { title } : {}))),
1106
+ },
1107
+ };
1108
+ }
1109
+ const MIRO_EMBED_LINK = /^https:\/\/miro\.com\/app\/(?:live-embed|access-link)\/[0-9a-zA-Z]+/i;
1110
+ function miro({ accessLink }) {
1111
+ const trimmed = (accessLink || "").trim();
1112
+ if (!MIRO_EMBED_LINK.test(trimmed)) {
1113
+ return null;
1114
+ }
1115
+ return {
1116
+ tagName: roomIntegrationContentTagName("miro"),
1117
+ shareUrl: trimmed,
1118
+ props: { accesslink: trimmed },
1119
+ };
1120
+ }
1121
+ const roomIntegrationContent = { youtube, miro };
1122
+
1041
1123
  class RoomParticipant {
1042
1124
  constructor({ breakoutGroup, displayName, id, isAudioEnabled, isAudioRecorder, isDialIn, isVideoEnabled, stickyReaction, stream, }) {
1043
1125
  this.isLocalParticipant = false;
@@ -1079,6 +1161,7 @@ function createServices() {
1079
1161
  baseUrl: API_BASE_URL,
1080
1162
  });
1081
1163
  const organizationService = new OrganizationService({ apiClient });
1164
+ const roomIntegrationService = new RoomIntegrationService({ apiClient });
1082
1165
  const fetchOrganizationFromRoomUrl = (roomUrl) => {
1083
1166
  const roomUrlObj = new URL(roomUrl);
1084
1167
  const urls = media.fromLocation({ host: roomUrlObj.host });
@@ -1092,6 +1175,7 @@ function createServices() {
1092
1175
  credentialsService,
1093
1176
  apiClient,
1094
1177
  organizationService,
1178
+ roomIntegrationService,
1095
1179
  fetchOrganizationFromRoomUrl,
1096
1180
  };
1097
1181
  }
@@ -1226,7 +1310,7 @@ const createReactor = (selectors, callback) => {
1226
1310
  });
1227
1311
  };
1228
1312
 
1229
- const coreVersion = "1.21.1";
1313
+ const coreVersion = "1.22.0";
1230
1314
 
1231
1315
  function decodeRoomName(roomName) {
1232
1316
  if (!roomName) {
@@ -1306,6 +1390,11 @@ const signalEvents = {
1306
1390
  knockerLeft: createSignalEventAction("knockerLeft"),
1307
1391
  knockHandled: createSignalEventAction("knockHandled"),
1308
1392
  newClient: createSignalEventAction("newClient"),
1393
+ roomIntegrationStarted: createSignalEventAction("roomIntegrationStarted"),
1394
+ roomIntegrationStopped: createSignalEventAction("roomIntegrationStopped"),
1395
+ roomIntegrationPropsUpdated: createSignalEventAction("roomIntegrationPropsUpdated"),
1396
+ roomIntegrationEnabled: createSignalEventAction("roomIntegrationEnabled"),
1397
+ roomIntegrationDisabled: createSignalEventAction("roomIntegrationDisabled"),
1309
1398
  roomJoined: createSignalEventAction("roomJoined"),
1310
1399
  roomKnocked: createSignalEventAction("roomKnocked"),
1311
1400
  roomLeft: createSignalEventAction("roomLeft"),
@@ -1336,6 +1425,7 @@ const ROOM_ACTION_PERMISSIONS_BY_ROLE = {
1336
1425
  canAskToSpeak: ["host"],
1337
1426
  canSpotlight: ["host"],
1338
1427
  canManageBreakout: ["host"],
1428
+ canManageRoomIntegration: ["host"],
1339
1429
  };
1340
1430
  const authorizationSliceInitialState = {
1341
1431
  roomKey: null,
@@ -1380,6 +1470,7 @@ const selectIsAuthorizedToEndMeeting = toolkit.createSelector(selectAuthorizatio
1380
1470
  const selectIsAuthorizedToAskToSpeak = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canAskToSpeak.includes(localParticipantRole));
1381
1471
  const selectIsAuthorizedToSpotlight = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canSpotlight.includes(localParticipantRole));
1382
1472
  const selectIsAuthorizedToManageBreakout = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canManageBreakout.includes(localParticipantRole));
1473
+ const selectIsAuthorizedToManageRoomIntegration = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canManageRoomIntegration.includes(localParticipantRole));
1383
1474
 
1384
1475
  function createAppAsyncThunk(typePrefix, payloadCreator) {
1385
1476
  return toolkit.createAsyncThunk(typePrefix, payloadCreator);
@@ -1513,6 +1604,11 @@ function forwardSocketEvents(socket, dispatch) {
1513
1604
  socket.on("video_enable_requested", (payload) => dispatch(signalEvents.videoEnableRequested(payload)));
1514
1605
  socket.on("breakout_group_joined", (payload) => dispatch(signalEvents.breakoutGroupJoined(payload)));
1515
1606
  socket.on("breakout_session_updated", (payload) => dispatch(signalEvents.breakoutSessionUpdated(payload)));
1607
+ socket.on("room_integration_started", (payload) => dispatch(signalEvents.roomIntegrationStarted(payload)));
1608
+ socket.on("room_integration_stopped", (payload) => dispatch(signalEvents.roomIntegrationStopped(payload)));
1609
+ socket.on("room_integration_props_updated", (payload) => dispatch(signalEvents.roomIntegrationPropsUpdated(payload)));
1610
+ socket.on("room_integration_enabled", (payload) => dispatch(signalEvents.roomIntegrationEnabled(payload)));
1611
+ socket.on("room_integration_disabled", (payload) => dispatch(signalEvents.roomIntegrationDisabled(payload)));
1516
1612
  socket.on("breakout_move_to_group", () => dispatch(signalEvents.breakoutMoveToGroup()));
1517
1613
  socket.on("breakout_move_to_main", () => dispatch(signalEvents.breakoutMoveToMain()));
1518
1614
  socket.on("breakout_ending", () => dispatch(signalEvents.breakoutEnding()));
@@ -4555,6 +4651,378 @@ startAppListening({
4555
4651
  },
4556
4652
  });
4557
4653
 
4654
+ function isCustomElementName(value) {
4655
+ return typeof value === "string" && value === value.toLowerCase() && value.includes("-");
4656
+ }
4657
+ function isHttpsUrl(value) {
4658
+ if (typeof value !== "string") {
4659
+ return false;
4660
+ }
4661
+ try {
4662
+ return new URL(value).protocol === "https:";
4663
+ }
4664
+ catch (_a) {
4665
+ return false;
4666
+ }
4667
+ }
4668
+ function isValidProps(value) {
4669
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4670
+ return false;
4671
+ }
4672
+ return Object.values(value).every((entry) => entry === null || ["string", "number", "boolean"].includes(typeof entry));
4673
+ }
4674
+ function parseMatcher(matcher) {
4675
+ if (typeof matcher !== "string") {
4676
+ return null;
4677
+ }
4678
+ const parts = matcher.match(/^\/([\s\S]*)\/([a-z]*)$/);
4679
+ if (!parts) {
4680
+ return null;
4681
+ }
4682
+ const flags = (parts[2] || "").replace(/[gy]/g, "");
4683
+ try {
4684
+ return new RegExp(parts[1], flags);
4685
+ }
4686
+ catch (_a) {
4687
+ return null;
4688
+ }
4689
+ }
4690
+ function parseRoomIntegration(response) {
4691
+ const { roomIntegrationId, name, title, description, type, icons, link, entrypoint, webview, isEmbeddable } = response || {};
4692
+ const matcher = parseMatcher(response === null || response === void 0 ? void 0 : response.matcher);
4693
+ if (roomIntegrationId === undefined ||
4694
+ roomIntegrationId === null ||
4695
+ !name ||
4696
+ !title ||
4697
+ !type ||
4698
+ !(icons === null || icons === void 0 ? void 0 : icons.small) ||
4699
+ !(icons === null || icons === void 0 ? void 0 : icons.large) ||
4700
+ !entrypoint ||
4701
+ !webview ||
4702
+ !matcher) {
4703
+ console.warn(`Ignoring malformed room integration: ${name || roomIntegrationId}`);
4704
+ return null;
4705
+ }
4706
+ return {
4707
+ roomIntegrationId: String(roomIntegrationId),
4708
+ name,
4709
+ title,
4710
+ description: description || "",
4711
+ type,
4712
+ contentTagName: roomIntegrationContentTagName(name),
4713
+ icons: { small: icons.small, large: icons.large },
4714
+ link: { href: (link === null || link === void 0 ? void 0 : link.href) || "", text: (link === null || link === void 0 ? void 0 : link.text) || "" },
4715
+ entrypoint,
4716
+ webview,
4717
+ matcher,
4718
+ isEmbeddable: isEmbeddable !== null && isEmbeddable !== void 0 ? isEmbeddable : false,
4719
+ };
4720
+ }
4721
+ function parseRoomIntegrationSession(event) {
4722
+ const { roomIntegrationId, roomIntegrationSessionId, breakoutGroupId, tagName, shareUrl, props, clientId, roomIntegrationSessionStartedAt, } = event || {};
4723
+ if (typeof roomIntegrationSessionId !== "string" ||
4724
+ roomIntegrationId === undefined ||
4725
+ roomIntegrationId === null ||
4726
+ typeof clientId !== "string" ||
4727
+ !isCustomElementName(tagName) ||
4728
+ !isHttpsUrl(shareUrl) ||
4729
+ !isValidProps(props)) {
4730
+ console.warn(`Ignoring malformed room integration session: ${roomIntegrationSessionId}`);
4731
+ return null;
4732
+ }
4733
+ return {
4734
+ roomIntegrationSessionId,
4735
+ roomIntegrationId: String(roomIntegrationId),
4736
+ breakoutGroupId: breakoutGroupId || "",
4737
+ tagName,
4738
+ shareUrl,
4739
+ props,
4740
+ clientId,
4741
+ roomIntegrationSessionStartedAt: typeof roomIntegrationSessionStartedAt === "number" && isFinite(roomIntegrationSessionStartedAt)
4742
+ ? roomIntegrationSessionStartedAt
4743
+ : null,
4744
+ };
4745
+ }
4746
+ const SIGNAL_ERROR_MESSAGES = {
4747
+ not_in_a_room: (action) => `Cannot ${action} a room integration: not in a room. The signal connection has a room session, but the server does not consider this client a participant of it.`,
4748
+ forbidden: (action) => `Not allowed to ${action} this room integration (forbidden)`,
4749
+ missing_parameters: (action) => `Could not ${action} the room integration: the request was missing parameters`,
4750
+ invalid_parameters: (action) => `Could not ${action} the room integration: the request had invalid parameters`,
4751
+ internal_server_error: (action) => `The server failed to ${action} the room integration`,
4752
+ };
4753
+ function roomIntegrationSignalError(error, action) {
4754
+ if (!media.isRoomIntegrationErrorCode(error)) {
4755
+ return { code: "unknown", message: `Could not ${action} the room integration: ${error}` };
4756
+ }
4757
+ return { code: error, message: SIGNAL_ERROR_MESSAGES[error](action) };
4758
+ }
4759
+ const roomIntegrationsSliceInitialState = {
4760
+ available: [],
4761
+ unavailable: [],
4762
+ enabled: [],
4763
+ running: [],
4764
+ isFetching: false,
4765
+ hasFetched: false,
4766
+ error: null,
4767
+ };
4768
+ const roomIntegrationsSlice = toolkit.createSlice({
4769
+ name: "roomIntegrations",
4770
+ initialState: roomIntegrationsSliceInitialState,
4771
+ reducers: {
4772
+ setRoomIntegrationsError: (state, action) => {
4773
+ state.error = action.payload.error;
4774
+ },
4775
+ },
4776
+ extraReducers: (builder) => {
4777
+ builder.addCase(doFetchRoomIntegrations.pending, (state) => {
4778
+ state.isFetching = true;
4779
+ });
4780
+ builder.addCase(doFetchRoomIntegrations.fulfilled, (state, action) => {
4781
+ const { enabledRoomIntegrations, disabledRoomIntegrations, unavailableRoomIntegrations } = action.payload;
4782
+ const parse = (entries) => entries.map(parseRoomIntegration).filter((entry) => entry !== null);
4783
+ state.isFetching = false;
4784
+ state.hasFetched = true;
4785
+ state.error = null;
4786
+ state.available = [...parse(enabledRoomIntegrations), ...parse(disabledRoomIntegrations)];
4787
+ state.unavailable = parse(unavailableRoomIntegrations);
4788
+ state.enabled = enabledRoomIntegrations.map(({ roomIntegrationId }) => String(roomIntegrationId));
4789
+ });
4790
+ builder.addCase(doFetchRoomIntegrations.rejected, (state, action) => {
4791
+ state.isFetching = false;
4792
+ state.hasFetched = true;
4793
+ state.error = {
4794
+ code: "unknown",
4795
+ message: action.error.message || "Failed to fetch room integrations",
4796
+ };
4797
+ });
4798
+ builder.addCase(signalEvents.roomJoined, (state, action) => {
4799
+ if ("error" in action.payload) {
4800
+ return;
4801
+ }
4802
+ state.running = (action.payload.roomIntegrationSession || [])
4803
+ .map(parseRoomIntegrationSession)
4804
+ .filter((session) => session !== null);
4805
+ });
4806
+ builder.addCase(signalEvents.roomIntegrationStarted, (state, action) => {
4807
+ if ("error" in action.payload) {
4808
+ state.error = roomIntegrationSignalError(action.payload.error, "start");
4809
+ return;
4810
+ }
4811
+ const { roomIntegrationId, roomIntegrationSessionId, breakoutGroupId, roomIntegrationSessionStartedAt } = action.payload;
4812
+ const session = parseRoomIntegrationSession(Object.assign(Object.assign({}, action.payload.state), { roomIntegrationId,
4813
+ roomIntegrationSessionId,
4814
+ breakoutGroupId,
4815
+ roomIntegrationSessionStartedAt }));
4816
+ if (!session) {
4817
+ return;
4818
+ }
4819
+ const existing = state.running.findIndex((running) => running.roomIntegrationSessionId === session.roomIntegrationSessionId);
4820
+ if (existing >= 0) {
4821
+ state.running[existing] = session;
4822
+ return;
4823
+ }
4824
+ state.running.push(session);
4825
+ });
4826
+ builder.addCase(signalEvents.roomIntegrationStopped, (state, action) => {
4827
+ if ("error" in action.payload) {
4828
+ state.error = roomIntegrationSignalError(action.payload.error, "stop");
4829
+ return;
4830
+ }
4831
+ const { roomIntegrationSessionId } = action.payload;
4832
+ state.running = state.running.filter((running) => running.roomIntegrationSessionId !== roomIntegrationSessionId);
4833
+ });
4834
+ builder.addCase(signalEvents.roomIntegrationPropsUpdated, (state, action) => {
4835
+ if ("error" in action.payload) {
4836
+ state.error = roomIntegrationSignalError(action.payload.error, "update the props of");
4837
+ return;
4838
+ }
4839
+ const { roomIntegrationSessionId, props } = action.payload;
4840
+ const session = state.running.find((running) => running.roomIntegrationSessionId === roomIntegrationSessionId);
4841
+ if (!session || !isValidProps(props)) {
4842
+ return;
4843
+ }
4844
+ session.props = Object.assign(Object.assign({}, session.props), props);
4845
+ });
4846
+ builder.addCase(signalEvents.roomIntegrationEnabled, (state, action) => {
4847
+ const roomIntegrationId = String(action.payload.roomIntegrationId);
4848
+ if (!state.enabled.includes(roomIntegrationId)) {
4849
+ state.enabled.push(roomIntegrationId);
4850
+ }
4851
+ });
4852
+ builder.addCase(signalEvents.roomIntegrationDisabled, (state, action) => {
4853
+ const roomIntegrationId = String(action.payload.roomIntegrationId);
4854
+ state.enabled = state.enabled.filter((id) => id !== roomIntegrationId);
4855
+ });
4856
+ },
4857
+ });
4858
+ const { setRoomIntegrationsError } = roomIntegrationsSlice.actions;
4859
+ const doFetchRoomIntegrations = createAppAsyncThunk("roomIntegrations/doFetchRoomIntegrations", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { extra, getState }) {
4860
+ const state = getState();
4861
+ const organizationId = selectOrganizationId(state);
4862
+ const roomName = selectAppRoomName(state);
4863
+ if (!organizationId || !roomName) {
4864
+ throw new Error("Cannot fetch room integrations before the organization and room are known");
4865
+ }
4866
+ return extra.services.roomIntegrationService.findRoomIntegrations({ organizationId, roomName });
4867
+ }));
4868
+ const doStartRoomIntegration = createRoomConnectedThunk((payload) => (dispatch, getState) => {
4869
+ var _a;
4870
+ const state = getState();
4871
+ const { roomIntegrationId, tagName, shareUrl, props = {} } = payload;
4872
+ const integration = selectRoomIntegrationsRaw(state).available.find((entry) => entry.roomIntegrationId === roomIntegrationId);
4873
+ if (!integration) {
4874
+ dispatch(setRoomIntegrationsError({
4875
+ error: {
4876
+ code: "unknown_integration",
4877
+ message: `Unknown room integration: ${roomIntegrationId}`,
4878
+ },
4879
+ }));
4880
+ return;
4881
+ }
4882
+ if (!selectRoomIntegrationsEnabled(state).includes(roomIntegrationId)) {
4883
+ dispatch(setRoomIntegrationsError({
4884
+ error: {
4885
+ code: "integration_not_enabled",
4886
+ message: `Room integration is not enabled for this room: ${integration.name}`,
4887
+ },
4888
+ }));
4889
+ return;
4890
+ }
4891
+ if (!isCustomElementName(tagName)) {
4892
+ dispatch(setRoomIntegrationsError({
4893
+ error: {
4894
+ code: "invalid_content",
4895
+ message: `tagName must be a valid custom element name, got: ${tagName}`,
4896
+ },
4897
+ }));
4898
+ return;
4899
+ }
4900
+ if (!isHttpsUrl(shareUrl)) {
4901
+ dispatch(setRoomIntegrationsError({
4902
+ error: {
4903
+ code: "invalid_content",
4904
+ message: `shareUrl must be an https url, got: ${shareUrl}`,
4905
+ },
4906
+ }));
4907
+ return;
4908
+ }
4909
+ if (!isValidProps(props)) {
4910
+ dispatch(setRoomIntegrationsError({
4911
+ error: {
4912
+ code: "invalid_content",
4913
+ message: "props must be a flat object of primitive values",
4914
+ },
4915
+ }));
4916
+ return;
4917
+ }
4918
+ const clientId = selectSelfId(state);
4919
+ if (!clientId) {
4920
+ return;
4921
+ }
4922
+ dispatch(setRoomIntegrationsError({ error: null }));
4923
+ const request = {
4924
+ roomIntegrationId: Number(roomIntegrationId),
4925
+ breakoutGroupId: selectBreakoutCurrentId(state) || null,
4926
+ state: { tagName, shareUrl, props, clientId },
4927
+ };
4928
+ (_a = selectSignalConnectionRaw(state).socket) === null || _a === void 0 ? void 0 : _a.emit("start_room_integration", request);
4929
+ });
4930
+ const ROOM_INTEGRATION_PICKER_MESSAGES = {
4931
+ FORM_SUBMIT: "whereby:formSubmit",
4932
+ FORM_CLOSE: "whereby:formClose",
4933
+ ERROR: "whereby:bootstrapError",
4934
+ };
4935
+ function roomIntegrationPickerUrl({ integration, parentOrigin, featureSource, }) {
4936
+ const url = new URL("bootstrap.html", integration.webview);
4937
+ url.searchParams.set("parentOrigin", parentOrigin);
4938
+ if (featureSource) {
4939
+ url.searchParams.set("featuresource", featureSource);
4940
+ }
4941
+ return url.href;
4942
+ }
4943
+ const doStopRoomIntegration = createRoomConnectedThunk((payload) => (dispatch, getState) => {
4944
+ var _a;
4945
+ const state = getState();
4946
+ const { roomIntegrationSessionId, intent = "stop" } = payload;
4947
+ const session = selectRunningRoomIntegrations(state).find((running) => running.roomIntegrationSessionId === roomIntegrationSessionId);
4948
+ if (!session) {
4949
+ dispatch(setRoomIntegrationsError({
4950
+ error: {
4951
+ code: "unknown_integration",
4952
+ message: `No running room integration with session id: ${roomIntegrationSessionId}`,
4953
+ },
4954
+ }));
4955
+ return;
4956
+ }
4957
+ if (!session.canStop) {
4958
+ dispatch(setRoomIntegrationsError({
4959
+ error: {
4960
+ code: "not_allowed_to_stop",
4961
+ message: "Only the participant who started a room integration, or a host, can stop it",
4962
+ },
4963
+ }));
4964
+ return;
4965
+ }
4966
+ dispatch(setRoomIntegrationsError({ error: null }));
4967
+ (_a = selectSignalConnectionRaw(state).socket) === null || _a === void 0 ? void 0 : _a.emit("stop_room_integration", { roomIntegrationSessionId, intent });
4968
+ });
4969
+ const doUpdateRoomIntegrationProps = createRoomConnectedThunk((payload) => (dispatch, getState) => {
4970
+ var _a;
4971
+ const state = getState();
4972
+ const { roomIntegrationSessionId, props } = payload;
4973
+ if (!isValidProps(props)) {
4974
+ dispatch(setRoomIntegrationsError({
4975
+ error: {
4976
+ code: "invalid_content",
4977
+ message: "props must be a flat object of primitive values",
4978
+ },
4979
+ }));
4980
+ return;
4981
+ }
4982
+ (_a = selectSignalConnectionRaw(state).socket) === null || _a === void 0 ? void 0 : _a.emit("update_room_integration_props", {
4983
+ roomIntegrationSessionId,
4984
+ props,
4985
+ });
4986
+ });
4987
+ const selectRoomIntegrationsRaw = (state) => state.roomIntegrations;
4988
+ const selectRoomIntegrationsEnabled = (state) => state.roomIntegrations.enabled;
4989
+ const selectAvailableRoomIntegrations = (state) => state.roomIntegrations.available;
4990
+ const selectEnabledRoomIntegrations = toolkit.createSelector(selectAvailableRoomIntegrations, selectRoomIntegrationsEnabled, (available, enabled) => available.filter((integration) => enabled.includes(integration.roomIntegrationId)));
4991
+ const selectEmbeddableRoomIntegrations = toolkit.createSelector(selectEnabledRoomIntegrations, (enabled) => enabled.filter((integration) => integration.isEmbeddable));
4992
+ const selectRunningRoomIntegrations = toolkit.createSelector(selectRoomIntegrationsRaw, selectEnabledRoomIntegrations, selectBreakoutActive, selectBreakoutCurrentId, selectSelfId, selectRemoteParticipants, selectIsAuthorizedToManageRoomIntegration, (raw, enabledIntegrations, breakoutActive, breakoutCurrentId, selfId, remoteParticipants, canManageRoomIntegration) => {
4993
+ const currentGroupId = breakoutActive ? breakoutCurrentId : "";
4994
+ return raw.running.reduce((acc, session) => {
4995
+ var _a;
4996
+ if (session.breakoutGroupId !== currentGroupId) {
4997
+ return acc;
4998
+ }
4999
+ const integration = enabledIntegrations.find((entry) => entry.roomIntegrationId === session.roomIntegrationId);
5000
+ if (!integration) {
5001
+ return acc;
5002
+ }
5003
+ const isPresenter = !!selfId && session.clientId === selfId;
5004
+ acc.push(Object.assign(Object.assign({}, session), { integration,
5005
+ isPresenter, canStop: isPresenter || canManageRoomIntegration, presenterDisplayName: isPresenter
5006
+ ? null
5007
+ : ((_a = remoteParticipants.find((participant) => participant.id === session.clientId)) === null || _a === void 0 ? void 0 : _a.displayName) ||
5008
+ null }));
5009
+ return acc;
5010
+ }, []);
5011
+ });
5012
+ toolkit.createSelector(selectRunningRoomIntegrations, (running) => running.length > 0);
5013
+ toolkit.createSelector(selectEmbeddableRoomIntegrations, (integrations) => (url) => integrations.find((integration) => integration.matcher.test(url)) || null);
5014
+ const selectShouldFetchRoomIntegrations = toolkit.createSelector(selectAppIsActive, selectRoomConnectionStatus, selectOrganizationId, selectAppRoomName, selectRoomIntegrationsRaw, (appIsActive, connectionStatus, organizationId, roomName, raw) => appIsActive &&
5015
+ connectionStatus === "connected" &&
5016
+ !!organizationId &&
5017
+ !!roomName &&
5018
+ !raw.hasFetched &&
5019
+ !raw.isFetching);
5020
+ createReactor([selectShouldFetchRoomIntegrations], ({ dispatch }, shouldFetchRoomIntegrations) => {
5021
+ if (shouldFetchRoomIntegrations) {
5022
+ dispatch(doFetchRoomIntegrations());
5023
+ }
5024
+ });
5025
+
4558
5026
  function createRtcAnalyticsCustomEvent(parameters) {
4559
5027
  return parameters;
4560
5028
  }
@@ -5166,6 +5634,7 @@ const appReducer = toolkit.combineReducers({
5166
5634
  remoteParticipants: remoteParticipantsSlice.reducer,
5167
5635
  room: roomSlice.reducer,
5168
5636
  roomConnection: roomConnectionSlice.reducer,
5637
+ roomIntegrations: roomIntegrationsSlice.reducer,
5169
5638
  rtcAnalytics: rtcAnalyticsSlice.reducer,
5170
5639
  rtcConnection: rtcConnectionSlice.reducer,
5171
5640
  signalConnection: signalConnectionSlice.reducer,
@@ -5203,12 +5672,14 @@ const createStore = ({ preloadedState, injectServices, }) => {
5203
5672
  const CLIENT_VIEW_CHANGED = "grid:client-view-changed";
5204
5673
  const CLIENT_VIEW_SPOTLIGHTS_CHANGED = "grid:client-view-spotlights-changed";
5205
5674
  const NUMBER_OF_CLIENT_VIEWS_CHANGED = "grid:number-of-client-views-changed";
5675
+ const RUNNING_ROOM_INTEGRATIONS_CHANGED = "grid:running-room-integrations-changed";
5206
5676
 
5207
- const selectGridState = toolkit.createSelector(selectAllClientViews, selectSpotlightedClientViews, selectNumClients, (allClientViews, spotlightedParticipants, numClients) => {
5677
+ const selectGridState = toolkit.createSelector(selectAllClientViews, selectSpotlightedClientViews, selectNumClients, selectRunningRoomIntegrations, (allClientViews, spotlightedParticipants, numClients, runningRoomIntegrations) => {
5208
5678
  return {
5209
5679
  allClientViews,
5210
5680
  spotlightedParticipants,
5211
5681
  numParticipants: numClients,
5682
+ runningRoomIntegrations,
5212
5683
  };
5213
5684
  });
5214
5685
 
@@ -5247,6 +5718,7 @@ class GridClient extends BaseClient {
5247
5718
  this.clientViewSubscribers = new Set();
5248
5719
  this.spotlightedSubscribers = new Set();
5249
5720
  this.numberOfClientViewsSubscribers = new Set();
5721
+ this.runningRoomIntegrationsSubscribers = new Set();
5250
5722
  }
5251
5723
  handleStateChanges(state, previousState) {
5252
5724
  if (state.allClientViews !== previousState.allClientViews) {
@@ -5261,6 +5733,10 @@ class GridClient extends BaseClient {
5261
5733
  this.numberOfClientViewsSubscribers.forEach((cb) => cb(state.numParticipants));
5262
5734
  this.emit(NUMBER_OF_CLIENT_VIEWS_CHANGED, state.numParticipants);
5263
5735
  }
5736
+ if (state.runningRoomIntegrations !== previousState.runningRoomIntegrations) {
5737
+ this.runningRoomIntegrationsSubscribers.forEach((cb) => cb(state.runningRoomIntegrations));
5738
+ this.emit(RUNNING_ROOM_INTEGRATIONS_CHANGED, state.runningRoomIntegrations);
5739
+ }
5264
5740
  }
5265
5741
  getState() {
5266
5742
  return selectGridState(this.store.getState());
@@ -5277,6 +5753,10 @@ class GridClient extends BaseClient {
5277
5753
  this.numberOfClientViewsSubscribers.add(callback);
5278
5754
  return () => this.numberOfClientViewsSubscribers.delete(callback);
5279
5755
  }
5756
+ subscribeRunningRoomIntegrations(callback) {
5757
+ this.runningRoomIntegrationsSubscribers.add(callback);
5758
+ return () => this.runningRoomIntegrationsSubscribers.delete(callback);
5759
+ }
5280
5760
  spotlightParticipant(id) {
5281
5761
  this.store.dispatch(doSpotlightParticipant({ id }));
5282
5762
  }
@@ -5288,6 +5768,7 @@ class GridClient extends BaseClient {
5288
5768
  this.clientViewSubscribers.clear();
5289
5769
  this.spotlightedSubscribers.clear();
5290
5770
  this.numberOfClientViewsSubscribers.clear();
5771
+ this.runningRoomIntegrationsSubscribers.clear();
5291
5772
  this.removeAllListeners();
5292
5773
  }
5293
5774
  }
@@ -5551,7 +6032,7 @@ const SPOTLIGHT_PARTICIPANT_REMOVED = "spotlight:participant-removed";
5551
6032
  const ROOM_JOINED = "room:joined";
5552
6033
  const ROOM_JOINED_ERROR = "room:joined:error";
5553
6034
 
5554
- const selectRoomConnectionState = toolkit.createSelector(selectChatMessages, selectFileUploads, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutCurrentId, selectBreakoutActive, selectBreakoutGroupedParticipants, selectBreakoutGroups, selectBreakoutAssignments, selectBreakoutEnforceAssignment, selectBreakoutTimerSetting, selectBreakoutTimerDuration, selectBreakoutAutoMoveToGroup, selectBreakoutMoveToGroupGracePeriod, selectBreakoutAutoMoveToMain, selectBreakoutMoveToMainGracePeriod, selectBreakoutStartedAt, selectBreakoutEndTime, selectBreakoutMoveToGroupAt, selectBreakoutMoveToMainAt, selectBreakoutIsAvailable, selectBreakoutError, selectAllClientViewsInCurrentGroup, selectLiveCaptionsRaw, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectLocalScreenshareRaw, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectRoomConnectionKnockResponse, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, (chatMessages, fileUploads, cloudRecording, breakoutCurrentGroup, breakoutCurrentId, breakoutActive, breakoutGroupedParticipants, breakoutGroups, breakoutAssignments, breakoutEnforceAssignment, breakoutTimerSetting, breakoutTimerDuration, breakoutAutoMoveToGroup, breakoutMoveToGroupGracePeriod, breakoutAutoMoveToMain, breakoutMoveToMainGracePeriod, breakoutStartedAt, breakoutEndTime, breakoutMoveToGroupAt, breakoutMoveToMainAt, breakoutIsAvailable, breakoutError, clientViewsInCurrentGroup, liveCaptions, liveTranscription, localParticipant, localMediaStream, localScreenshare, remoteParticipants, screenshares, connectionStatus, connectionError, knockResponse, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled) => {
6035
+ const selectRoomConnectionState = toolkit.createSelector(selectChatMessages, selectFileUploads, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutCurrentId, selectBreakoutActive, selectBreakoutGroupedParticipants, selectBreakoutGroups, selectBreakoutAssignments, selectBreakoutEnforceAssignment, selectBreakoutTimerSetting, selectBreakoutTimerDuration, selectBreakoutAutoMoveToGroup, selectBreakoutMoveToGroupGracePeriod, selectBreakoutAutoMoveToMain, selectBreakoutMoveToMainGracePeriod, selectBreakoutStartedAt, selectBreakoutEndTime, selectBreakoutMoveToGroupAt, selectBreakoutMoveToMainAt, selectBreakoutIsAvailable, selectBreakoutError, selectAllClientViewsInCurrentGroup, selectLiveCaptionsRaw, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectLocalScreenshareRaw, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectRoomConnectionKnockResponse, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, selectRoomIntegrationsRaw, selectEnabledRoomIntegrations, selectEmbeddableRoomIntegrations, selectRunningRoomIntegrations, (chatMessages, fileUploads, cloudRecording, breakoutCurrentGroup, breakoutCurrentId, breakoutActive, breakoutGroupedParticipants, breakoutGroups, breakoutAssignments, breakoutEnforceAssignment, breakoutTimerSetting, breakoutTimerDuration, breakoutAutoMoveToGroup, breakoutMoveToGroupGracePeriod, breakoutAutoMoveToMain, breakoutMoveToMainGracePeriod, breakoutStartedAt, breakoutEndTime, breakoutMoveToGroupAt, breakoutMoveToMainAt, breakoutIsAvailable, breakoutError, clientViewsInCurrentGroup, liveCaptions, liveTranscription, localParticipant, localMediaStream, localScreenshare, remoteParticipants, screenshares, connectionStatus, connectionError, knockResponse, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled, roomIntegrationsRaw, enabledRoomIntegrations, embeddableRoomIntegrations, runningRoomIntegrations) => {
5555
6036
  const broadcastingParticipants = breakoutActive && breakoutCurrentId
5556
6037
  ? spotlightedClientViews.filter((c) => !c.breakoutGroup && c.isAudioEnabled && !c.isPresentation)
5557
6038
  : [];
@@ -5629,6 +6110,14 @@ const selectRoomConnectionState = toolkit.createSelector(selectChatMessages, sel
5629
6110
  : undefined,
5630
6111
  localParticipant: Object.assign(Object.assign({}, localParticipant), { isScreenSharing: localScreenshare.status === "active", stream: localMediaStream }),
5631
6112
  remoteParticipants: remoteParticipants.map((participant) => (Object.assign(Object.assign({}, participant), { breakoutGroupAssigned: (breakoutAssignments === null || breakoutAssignments === void 0 ? void 0 : breakoutAssignments[participant.deviceId]) || "" }))),
6113
+ roomIntegrations: {
6114
+ hasFetched: roomIntegrationsRaw.hasFetched,
6115
+ isFetching: roomIntegrationsRaw.isFetching,
6116
+ error: roomIntegrationsRaw.error,
6117
+ embeddable: embeddableRoomIntegrations,
6118
+ enabled: enabledRoomIntegrations,
6119
+ running: runningRoomIntegrations,
6120
+ },
5632
6121
  screenshares,
5633
6122
  waitingParticipants,
5634
6123
  spotlightedParticipants: spotlightedClientViews,
@@ -6013,6 +6502,15 @@ class RoomConnectionClient extends BaseClient {
6013
6502
  endMeeting(stayBehind = false) {
6014
6503
  this.store.dispatch(doEndMeeting({ stayBehind }));
6015
6504
  }
6505
+ startRoomIntegration(options) {
6506
+ this.store.dispatch(doStartRoomIntegration(options));
6507
+ }
6508
+ stopRoomIntegration(options) {
6509
+ this.store.dispatch(doStopRoomIntegration(options));
6510
+ }
6511
+ updateRoomIntegrationProps(options) {
6512
+ this.store.dispatch(doUpdateRoomIntegrationProps(options));
6513
+ }
6016
6514
  joinBreakoutGroup(group) {
6017
6515
  this.store.dispatch(doBreakoutJoin({ group }));
6018
6516
  }
@@ -6211,9 +6709,12 @@ exports.OrganizationApiClient = OrganizationApiClient;
6211
6709
  exports.OrganizationService = OrganizationService;
6212
6710
  exports.OrganizationServiceCache = OrganizationServiceCache;
6213
6711
  exports.REMOTE_PARTICIPANTS_CHANGED = REMOTE_PARTICIPANTS_CHANGED;
6712
+ exports.ROOM_INTEGRATION_PICKER_MESSAGES = ROOM_INTEGRATION_PICKER_MESSAGES;
6214
6713
  exports.ROOM_JOINED = ROOM_JOINED;
6215
6714
  exports.ROOM_JOINED_ERROR = ROOM_JOINED_ERROR;
6715
+ exports.RUNNING_ROOM_INTEGRATIONS_CHANGED = RUNNING_ROOM_INTEGRATIONS_CHANGED;
6216
6716
  exports.RoomConnectionClient = RoomConnectionClient;
6717
+ exports.RoomIntegrationService = RoomIntegrationService;
6217
6718
  exports.RoomService = RoomService;
6218
6719
  exports.SCREENSHARE_STARTED = SCREENSHARE_STARTED;
6219
6720
  exports.SCREENSHARE_STOPPED = SCREENSHARE_STOPPED;
@@ -6235,4 +6736,9 @@ exports.getUsableCameraEffectPresets = getUsableCameraEffectPresets;
6235
6736
  exports.getVideoTrack = getVideoTrack;
6236
6737
  exports.hasValue = hasValue;
6237
6738
  exports.isAudioDenoiserSupported = isAudioDenoiserSupported;
6739
+ exports.miro = miro;
6238
6740
  exports.parseUnverifiedRoomKeyData = parseUnverifiedRoomKeyData;
6741
+ exports.roomIntegrationContent = roomIntegrationContent;
6742
+ exports.roomIntegrationContentTagName = roomIntegrationContentTagName;
6743
+ exports.roomIntegrationPickerUrl = roomIntegrationPickerUrl;
6744
+ exports.youtube = youtube;