mediasfu-shared 1.0.3 → 1.0.5

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.d.ts CHANGED
@@ -1672,6 +1672,14 @@ export declare interface CoHostResponsibility {
1672
1672
  dedicated: boolean;
1673
1673
  }
1674
1674
 
1675
+ /**
1676
+ * Curated list of the most widely-supported language codes for real-time translation.
1677
+ * This set covers the languages supported by major STT/TTS/translation providers
1678
+ * (Google, Azure, Deepgram, OpenAI, DeepL, etc.) and is the default shown in UI pickers.
1679
+ * Use getSupportedLanguages() if you need the full extended list.
1680
+ */
1681
+ export declare const COMMON_LANGUAGE_CODES: string[];
1682
+
1675
1683
  /**
1676
1684
  * Compares the current active names with the previous active names and triggers an action if there are changes.
1677
1685
  *
@@ -2584,7 +2592,7 @@ export declare interface ControlMediaHostTrackLike {
2584
2592
 
2585
2593
  export declare type ControlMediaHostType<TOnScreenChangesParameters = unknown, TStopShareScreenParameters = unknown, TDisconnectSendTransportVideoParameters = unknown, TDisconnectSendTransportAudioParameters = unknown, TDisconnectSendTransportScreenParameters = unknown, TAllParameters extends TOnScreenChangesParameters & TStopShareScreenParameters & TDisconnectSendTransportVideoParameters & TDisconnectSendTransportAudioParameters & TDisconnectSendTransportScreenParameters = TOnScreenChangesParameters & TStopShareScreenParameters & TDisconnectSendTransportVideoParameters & TDisconnectSendTransportAudioParameters & TDisconnectSendTransportScreenParameters, TMediaStream extends ControlMediaHostMediaStreamLike = MediaStream> = (options: ControlMediaHostOptions<TOnScreenChangesParameters, TStopShareScreenParameters, TDisconnectSendTransportVideoParameters, TDisconnectSendTransportAudioParameters, TDisconnectSendTransportScreenParameters, TAllParameters, TMediaStream>) => Promise<void>;
2586
2594
 
2587
- export declare interface ControlMediaOptions {
2595
+ declare interface ControlMediaOptions {
2588
2596
  data: ControlMediaData;
2589
2597
  showAlert?: ShowAlert;
2590
2598
  clickAudio?: () => void;
@@ -2592,6 +2600,8 @@ export declare interface ControlMediaOptions {
2592
2600
  audioAlreadyOn?: boolean;
2593
2601
  videoAlreadyOn?: boolean;
2594
2602
  }
2603
+ export { ControlMediaOptions }
2604
+ export { ControlMediaOptions as PanelistControlMediaOptions }
2595
2605
 
2596
2606
  declare interface ControlMediaOptions_2 {
2597
2607
  participantId: string;
@@ -2607,7 +2617,9 @@ declare interface ControlMediaOptions_2 {
2607
2617
  roomName: string;
2608
2618
  }
2609
2619
 
2610
- export declare type ControlMediaType = (options: ControlMediaOptions) => Promise<void>;
2620
+ declare type ControlMediaType = (options: ControlMediaOptions) => Promise<void>;
2621
+ export { ControlMediaType }
2622
+ export { ControlMediaType as PanelistControlMediaType }
2611
2623
 
2612
2624
  export declare type ControlsPosition = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
2613
2625
 
@@ -3714,6 +3726,12 @@ export declare const getAvailableVoices: (langCode: string, provider?: TTSProvid
3714
3726
  female: VoiceOption[];
3715
3727
  };
3716
3728
 
3729
+ /**
3730
+ * Returns the curated list of commonly-supported languages for translation UI pickers.
3731
+ * Sorted alphabetically by display name.
3732
+ */
3733
+ export declare const getCommonLanguages: (displayLocale?: string) => LanguageOption[];
3734
+
3717
3735
  /**
3718
3736
  * Resolves newly announced consuming domains to connection targets and connects missing ones.
3719
3737
  *
package/dist/index.js CHANGED
@@ -6349,6 +6349,7 @@ const updateRoomParametersClient = ({ parameters }) => {
6349
6349
  }
6350
6350
  };
6351
6351
  const DEFAULT_MEDIA_SFU_ROOM_API_URL = "https://mediasfu.com/v1/rooms/";
6352
+ const getDefaultMediaSFURoomApiUrl = () => DEFAULT_MEDIA_SFU_ROOM_API_URL;
6352
6353
  const normalizeManagedRoomApi = (normalizedLink) => {
6353
6354
  if (normalizedLink.includes("/v1/rooms")) {
6354
6355
  return `${normalizedLink.replace(/\/$/, "")}/`;
@@ -6358,7 +6359,7 @@ const normalizeManagedRoomApi = (normalizedLink) => {
6358
6359
  const resolveMediaSFURoomApi = (localLink, action) => {
6359
6360
  const normalizedLink = localLink?.trim();
6360
6361
  if (!normalizedLink) {
6361
- return DEFAULT_MEDIA_SFU_ROOM_API_URL;
6362
+ return getDefaultMediaSFURoomApiUrl();
6362
6363
  }
6363
6364
  if (normalizedLink.includes("mediasfu.com")) {
6364
6365
  return normalizeManagedRoomApi(normalizedLink);
@@ -7898,6 +7899,9 @@ const sendMessage = async ({
7898
7899
  chatSetting
7899
7900
  }) => {
7900
7901
  let chatValue = false;
7902
+ const normalizedReceivers = (receivers ?? []).filter(
7903
+ (receiver) => typeof receiver === "string" && receiver.trim().length > 0
7904
+ );
7901
7905
  if (messagesLength > 100 && roomName.startsWith("d") || messagesLength > 500 && roomName.startsWith("s") || messagesLength > 1e5 && roomName.startsWith("p")) {
7902
7906
  showAlert?.({
7903
7907
  message: "You have reached the maximum number of messages allowed.",
@@ -7914,7 +7918,7 @@ const sendMessage = async ({
7914
7918
  });
7915
7919
  return;
7916
7920
  }
7917
- if (receivers.length < 1 && group === false) {
7921
+ if (normalizedReceivers.length < 1 && group === false && islevel === "2") {
7918
7922
  showAlert?.({
7919
7923
  message: "Please select a message to reply to",
7920
7924
  type: "danger",
@@ -7924,7 +7928,7 @@ const sendMessage = async ({
7924
7928
  }
7925
7929
  const messageObject = {
7926
7930
  sender: sender ? sender : member,
7927
- receivers,
7931
+ receivers: normalizedReceivers,
7928
7932
  message,
7929
7933
  timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
7930
7934
  group: group !== void 0 && group !== null ? group : false
@@ -10081,13 +10085,112 @@ const TTS_SUPPORT_BY_LANGUAGE = {
10081
10085
  ca: "good",
10082
10086
  auto: "n/a"
10083
10087
  };
10088
+ const LANGUAGE_NAMES_EN = {
10089
+ en: "English",
10090
+ es: "Spanish",
10091
+ fr: "French",
10092
+ de: "German",
10093
+ it: "Italian",
10094
+ pt: "Portuguese",
10095
+ nl: "Dutch",
10096
+ ru: "Russian",
10097
+ zh: "Chinese",
10098
+ ja: "Japanese",
10099
+ ko: "Korean",
10100
+ ar: "Arabic",
10101
+ hi: "Hindi",
10102
+ bn: "Bengali",
10103
+ pa: "Punjabi",
10104
+ te: "Telugu",
10105
+ mr: "Marathi",
10106
+ ta: "Tamil",
10107
+ ur: "Urdu",
10108
+ gu: "Gujarati",
10109
+ kn: "Kannada",
10110
+ ml: "Malayalam",
10111
+ ne: "Nepali",
10112
+ si: "Sinhala",
10113
+ tr: "Turkish",
10114
+ pl: "Polish",
10115
+ vi: "Vietnamese",
10116
+ th: "Thai",
10117
+ id: "Indonesian",
10118
+ ms: "Malay",
10119
+ tl: "Filipino",
10120
+ km: "Khmer",
10121
+ lo: "Lao",
10122
+ my: "Burmese",
10123
+ sw: "Swahili",
10124
+ yo: "Yoruba",
10125
+ ha: "Hausa",
10126
+ ig: "Igbo",
10127
+ zu: "Zulu",
10128
+ xh: "Xhosa",
10129
+ af: "Afrikaans",
10130
+ st: "Sesotho",
10131
+ tn: "Tswana",
10132
+ sn: "Shona",
10133
+ am: "Amharic",
10134
+ so: "Somali",
10135
+ rw: "Kinyarwanda",
10136
+ mg: "Malagasy",
10137
+ ny: "Chichewa",
10138
+ ee: "Ewe",
10139
+ tw: "Twi",
10140
+ gaa: "Ga",
10141
+ he: "Hebrew",
10142
+ fa: "Persian",
10143
+ ps: "Pashto",
10144
+ ku: "Kurdish",
10145
+ uk: "Ukrainian",
10146
+ el: "Greek",
10147
+ cs: "Czech",
10148
+ ro: "Romanian",
10149
+ hu: "Hungarian",
10150
+ sv: "Swedish",
10151
+ da: "Danish",
10152
+ no: "Norwegian",
10153
+ fi: "Finnish",
10154
+ sk: "Slovak",
10155
+ bg: "Bulgarian",
10156
+ hr: "Croatian",
10157
+ et: "Estonian",
10158
+ lt: "Lithuanian",
10159
+ lv: "Latvian",
10160
+ sl: "Slovenian",
10161
+ sr: "Serbian",
10162
+ bs: "Bosnian",
10163
+ mk: "Macedonian",
10164
+ is: "Icelandic",
10165
+ ga: "Irish",
10166
+ cy: "Welsh",
10167
+ mt: "Maltese",
10168
+ lb: "Luxembourgish",
10169
+ sq: "Albanian",
10170
+ be: "Belarusian",
10171
+ ka: "Georgian",
10172
+ hy: "Armenian",
10173
+ az: "Azerbaijani",
10174
+ eu: "Basque",
10175
+ gl: "Galician",
10176
+ ca: "Catalan",
10177
+ la: "Latin",
10178
+ eo: "Esperanto",
10179
+ kk: "Kazakh",
10180
+ uz: "Uzbek",
10181
+ tg: "Tajik",
10182
+ ky: "Kyrgyz",
10183
+ tk: "Turkmen",
10184
+ mn: "Mongolian"
10185
+ };
10084
10186
  const getDisplayName = (code, locale, fallback) => {
10085
10187
  try {
10086
10188
  const displayNames = new Intl.DisplayNames([locale], { type: "language" });
10087
- return displayNames.of(code) || fallback;
10189
+ const result = displayNames.of(code);
10190
+ if (result) return result;
10088
10191
  } catch {
10089
- return fallback;
10090
10192
  }
10193
+ return LANGUAGE_NAMES_EN[code] ?? fallback;
10091
10194
  };
10092
10195
  const normalizeLanguageCode = (code) => {
10093
10196
  if (!code || typeof code !== "string") {
@@ -10134,6 +10237,58 @@ const getSupportedLanguages = (displayLocale = "en") => {
10134
10237
  };
10135
10238
  }).sort((left, right) => left.name.localeCompare(right.name));
10136
10239
  };
10240
+ const COMMON_LANGUAGE_CODES = [
10241
+ "en",
10242
+ "es",
10243
+ "fr",
10244
+ "de",
10245
+ "it",
10246
+ "pt",
10247
+ "nl",
10248
+ "ru",
10249
+ "zh",
10250
+ "ja",
10251
+ "ko",
10252
+ "ar",
10253
+ "hi",
10254
+ "bn",
10255
+ "tr",
10256
+ "pl",
10257
+ "vi",
10258
+ "th",
10259
+ "id",
10260
+ "ms",
10261
+ "sw",
10262
+ "yo",
10263
+ "ha",
10264
+ "ig",
10265
+ "zu",
10266
+ "am",
10267
+ "tw",
10268
+ "he",
10269
+ "fa",
10270
+ "uk",
10271
+ "el",
10272
+ "cs",
10273
+ "ro",
10274
+ "hu",
10275
+ "sv",
10276
+ "da",
10277
+ "no",
10278
+ "fi"
10279
+ ];
10280
+ const getCommonLanguages = (displayLocale = "en") => {
10281
+ return COMMON_LANGUAGE_CODES.map((code) => {
10282
+ const metadata = getLanguageMetadata(code);
10283
+ return {
10284
+ code,
10285
+ name: getLanguageName(code, displayLocale),
10286
+ nativeName: metadata.nativeName,
10287
+ region: metadata.region,
10288
+ ttsSupport: metadata.ttsSupport
10289
+ };
10290
+ }).sort((left, right) => left.name.localeCompare(right.name));
10291
+ };
10137
10292
  const TTS_PROVIDERS = {
10138
10293
  deepgram: { name: "Deepgram Aura", supportsSSML: false, isDefault: true },
10139
10294
  openai: { name: "OpenAI TTS", supportsSSML: false, multilingual: true },
@@ -12875,6 +13030,7 @@ const launchConfigureWhiteboard = ({
12875
13030
  updateIsConfigureWhiteboardModalVisible(!isConfigureWhiteboardModalVisible);
12876
13031
  };
12877
13032
  export {
13033
+ COMMON_LANGUAGE_CODES,
12878
13034
  MediaStream$1 as MediaStream,
12879
13035
  MediaStreamTrack,
12880
13036
  QnHDCons,
@@ -12962,6 +13118,7 @@ export {
12962
13118
  generateRandomWaitingRoomList,
12963
13119
  getActiveTranslationConsumers,
12964
13120
  getAvailableVoices,
13121
+ getCommonLanguages,
12965
13122
  getDomains,
12966
13123
  getEstimate,
12967
13124
  getLanguageMetadata,