@snapcall/stream-ui 1.7.0 → 1.8.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.
@@ -1190,7 +1190,7 @@ class $a2f0e3c29b11c88e$export$2e2bcd8739ae039 {
1190
1190
 
1191
1191
 
1192
1192
  const $0148b6fd862a22e8$var$log = new (0, $0f65a9eaf4a1e910$export$2e2bcd8739ae039)("MediaPipe");
1193
- const $0148b6fd862a22e8$var$mediapipeUrl = "https://stream-assets.snapcall.io/v1.7.0";
1193
+ const $0148b6fd862a22e8$var$mediapipeUrl = "https://stream-assets.snapcall.io/v1.8.0";
1194
1194
  let $0148b6fd862a22e8$var$selfieSegmentationInitialized = false;
1195
1195
  const $0148b6fd862a22e8$var$selfieSegmentation = new $3Sbms$SelfieSegmentation({
1196
1196
  locateFile: (file, prefix)=>{
@@ -1776,10 +1776,15 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
1776
1776
  async joinRoom() {
1777
1777
  this.streamerMediasoup = await (0, $a2f0e3c29b11c88e$export$2e2bcd8739ae039).create(this.protoo, this.config);
1778
1778
  // now we join
1779
- if (this.joinOptions.apiKey && this.joinOptions.email) try {
1780
- const agentInfo = await this.fetchAgentInfo({
1781
- apiKey: this.joinOptions.apiKey,
1782
- email: this.joinOptions.email
1779
+ const { apiKey: apiKey , email: email } = this.joinOptions;
1780
+ if (apiKey) try {
1781
+ let agentInfo = null;
1782
+ if (apiKey && email) agentInfo = await this.fetchAgentInfo({
1783
+ apiKey: apiKey,
1784
+ email: email
1785
+ });
1786
+ else if (apiKey) agentInfo = await this.fetchUserInfo({
1787
+ apiKey: apiKey
1783
1788
  });
1784
1789
  if (agentInfo) this.dispatchEvent(new $c31e3fb4360572af$var$SnapcallEvent("agentIdentity", {
1785
1790
  detail: {
@@ -1796,8 +1801,8 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
1796
1801
  }));
1797
1802
  }
1798
1803
  const { peers: peers } = await this.protoo.request("getRoomPeers", {
1799
- apiKey: this.joinOptions.apiKey,
1800
- email: this.joinOptions.email
1804
+ apiKey: apiKey,
1805
+ email: email
1801
1806
  });
1802
1807
  this.peers = new Map(peers.map((peer)=>[
1803
1808
  peer.id || peer.peerId,
@@ -2675,6 +2680,19 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
2675
2680
  });
2676
2681
  return agent;
2677
2682
  }
2683
+ async fetchUserInfo({ apiKey: apiKey }) {
2684
+ const apiURL = this.config.apiUrl;
2685
+ const user = await fetch(`${apiURL}/users/me`, {
2686
+ method: "get",
2687
+ headers: {
2688
+ Authorization: `Bearer ${apiKey}`
2689
+ }
2690
+ }).then((response)=>{
2691
+ if (response.ok) return response.json();
2692
+ throw new Error("Invalid user info");
2693
+ });
2694
+ return user;
2695
+ }
2678
2696
  setConfig(config) {
2679
2697
  this.config = {
2680
2698
  ...this.config,
@@ -3633,7 +3651,7 @@ const $f235befa4cdc42d6$var$Header = ()=>{
3633
3651
  ]
3634
3652
  },
3635
3653
  ];
3636
- if ($f235befa4cdc42d6$var$browser.platform.type === "desktop" && $f235befa4cdc42d6$var$browser.engine.name === "Blink") computedCategories[2].items.push({
3654
+ if ($f235befa4cdc42d6$var$browser.platform.type === "desktop" && $f235befa4cdc42d6$var$browser.engine.name === "Blink") computedCategories[2].items.unshift({
3637
3655
  id: "virtualBackground",
3638
3656
  title: t("virtualBackground.title"),
3639
3657
  jsxIcon: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $2da9626742e3560b$export$d5424e4dfe4be076), {}),
@@ -3702,6 +3720,35 @@ const $af23c74942bdcae7$export$2b86bedf890eab8 = (element)=>{
3702
3720
  ]);
3703
3721
  return size;
3704
3722
  };
3723
+ const $af23c74942bdcae7$var$defaultState = {
3724
+ bottom: 0,
3725
+ height: 0,
3726
+ left: 0,
3727
+ right: 0,
3728
+ top: 0,
3729
+ width: 0,
3730
+ x: 0,
3731
+ y: 0
3732
+ };
3733
+ function $af23c74942bdcae7$export$e295b0c537d32d7d() {
3734
+ const [element, ref] = (0, $3Sbms$useState)(null);
3735
+ const [rect, setRect] = (0, $3Sbms$useState)($af23c74942bdcae7$var$defaultState);
3736
+ (0, $3Sbms$useLayoutEffect)(()=>{
3737
+ if (!element) return;
3738
+ const updateSize = (entries)=>setRect(entries[0].contentRect);
3739
+ const observer = new ResizeObserver(updateSize);
3740
+ observer.observe(element);
3741
+ return ()=>{
3742
+ observer.disconnect();
3743
+ };
3744
+ }, [
3745
+ element
3746
+ ]);
3747
+ return [
3748
+ ref,
3749
+ rect
3750
+ ];
3751
+ }
3705
3752
 
3706
3753
 
3707
3754
 
@@ -4281,16 +4328,6 @@ const $6efc75079651494a$export$98d9314e6a208b24 = (0, $3Sbms$styledcomponents).d
4281
4328
  bottom: 0;
4282
4329
  cursor: ${(props)=>props.cursor};
4283
4330
  transition: all 0.4s;
4284
-
4285
- ${(props)=>{
4286
- if (props.full) return (0, $3Sbms$css)`
4287
- width: 100%;
4288
- height: 100%;
4289
- right: 0px;
4290
- padding: 17px 10px;
4291
- box-sizing: border-box;
4292
- `;
4293
- }}
4294
4331
  `;
4295
4332
  const $6efc75079651494a$export$ba5a75b023bcdce2 = (0, $3Sbms$styledcomponents).div`
4296
4333
  display: flex;
@@ -5142,22 +5179,18 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5142
5179
  const { videosContainerRef: videosContainerRef , remoteTilesContainerRef: remoteTilesContainerRef , profile: profile , muted: muted , streaming: streaming , orientation: orientation , options: options , } = (0, $3Sbms$useContext)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039));
5143
5180
  const { streams: streams } = (0, $cce9fd41d8a55a18$export$b5633a7cfbe42d9f)();
5144
5181
  const [containerWidth, containerHeight] = (0, $af23c74942bdcae7$export$2b86bedf890eab8)(videosContainerRef.current);
5182
+ const cursor = streaming && !extended ? "pointer" : "default";
5183
+ const computedWidth = (0, $b8e10de7c6dba8c4$export$a6112fefa8de799d)({
5184
+ containerWidth: containerWidth,
5185
+ containerHeight: containerHeight,
5186
+ minimumWidth: $5939a59dc7c96d41$var$minimumTileWidth,
5187
+ maximumWidth: $5939a59dc7c96d41$var$maximumTileWidth,
5188
+ orientation: orientation,
5189
+ extended: extended
5190
+ });
5191
+ let tileWidth = `${computedWidth}px`;
5192
+ let tileHeight = `${computedWidth}px`;
5145
5193
  const isAlone = streams.length < 1;
5146
- const cursor = streaming && !isAlone && !extended ? "pointer" : "default";
5147
- let tileWidth = orientation === "landscape" ? "50%" : "100%";
5148
- let tileHeight = orientation === "landscape" ? "100%" : "50%";
5149
- if (!isAlone) {
5150
- const computedWidth = (0, $b8e10de7c6dba8c4$export$a6112fefa8de799d)({
5151
- containerWidth: containerWidth,
5152
- containerHeight: containerHeight,
5153
- minimumWidth: $5939a59dc7c96d41$var$minimumTileWidth,
5154
- maximumWidth: $5939a59dc7c96d41$var$maximumTileWidth,
5155
- orientation: orientation,
5156
- extended: extended
5157
- });
5158
- tileWidth = `${computedWidth}px`;
5159
- tileHeight = `${computedWidth}px`;
5160
- }
5161
5194
  const onLocalVideoChange = (event)=>{
5162
5195
  if (!event.detail?.camera?.device) return;
5163
5196
  if (!videoElementRef.current) throw new Error("videoElementRef not available");
@@ -5167,7 +5200,7 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5167
5200
  setZoomAvailable((0, $c9e496369b59be7a$export$2f377c2162fd02b2).isVideoZoomAvailable());
5168
5201
  };
5169
5202
  const onSelfTileClick = ()=>{
5170
- if (streaming && !isAlone && !deviceRequest && !extended && SelfTileRef.current) {
5203
+ if (streaming && !deviceRequest && !extended && SelfTileRef.current) {
5171
5204
  (0, $d02c24b66b4606fd$export$ab7d69e250642927)({
5172
5205
  element: SelfTileRef.current
5173
5206
  });
@@ -5235,7 +5268,7 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5235
5268
  });
5236
5269
  };
5237
5270
  const onSelfTileMouseDown = (mouseDownEvent)=>{
5238
- if (!isAlone && !extended && SelfTileRef.current && videosContainerRef.current) (0, $d02c24b66b4606fd$export$298c6ed7f6695dd6)({
5271
+ if (!extended && SelfTileRef.current && videosContainerRef.current) (0, $d02c24b66b4606fd$export$298c6ed7f6695dd6)({
5239
5272
  mouseDownEvent: mouseDownEvent,
5240
5273
  targetElement: SelfTileRef.current,
5241
5274
  containerElement: videosContainerRef.current
@@ -5260,6 +5293,7 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5260
5293
  if (streaming && videoElementRef.current && !videoElementRef.current.srcObject) videoElementRef.current.srcObject = videoMediaProviderRef.current;
5261
5294
  }, [
5262
5295
  streaming,
5296
+ isAlone,
5263
5297
  isSomeonePresenting
5264
5298
  ]);
5265
5299
  (0, $3Sbms$useEffect)(()=>{
@@ -5270,12 +5304,6 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5270
5304
  containerWidth,
5271
5305
  containerHeight
5272
5306
  ]);
5273
- (0, $3Sbms$useEffect)(()=>{
5274
- if (isAlone && extended) setExtended(false);
5275
- }, [
5276
- isAlone,
5277
- extended
5278
- ]);
5279
5307
  (0, $3Sbms$useEffect)(()=>{
5280
5308
  if (!extended) {
5281
5309
  setSnapshotAnimation(false);
@@ -5381,7 +5409,7 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5381
5409
  })
5382
5410
  ]
5383
5411
  });
5384
- if (isSomeonePresenting && remoteTilesContainerRef?.current) return /*#__PURE__*/ (0, $3Sbms$createPortal)(/*#__PURE__*/ (0, $3Sbms$jsx)((0, $7ec04c1818c68245$export$798352b46783b18d), {
5412
+ if (remoteTilesContainerRef?.current && (isAlone || isSomeonePresenting)) return /*#__PURE__*/ (0, $3Sbms$createPortal)(/*#__PURE__*/ (0, $3Sbms$jsx)((0, $7ec04c1818c68245$export$798352b46783b18d), {
5385
5413
  style: {
5386
5414
  width: `${width}px`,
5387
5415
  height: `${height}px`
@@ -5393,7 +5421,6 @@ const $5939a59dc7c96d41$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5393
5421
  children: [
5394
5422
  /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $6efc75079651494a$export$98d9314e6a208b24), {
5395
5423
  ref: SelfTileRef,
5396
- full: isAlone,
5397
5424
  style: {
5398
5425
  width: tileWidth,
5399
5426
  height: tileHeight
@@ -6232,49 +6259,40 @@ var $b496fc6f0d99c06d$export$2e2bcd8739ae039 = $b496fc6f0d99c06d$var$Highlighted
6232
6259
 
6233
6260
 
6234
6261
 
6235
- const $b56218b5a57cb77c$export$d653589df987fd93 = (0, $3Sbms$styledcomponents).div`
6236
- display: flex;
6237
- position: absolute;
6238
- z-index: 20;
6239
- left: 0;
6240
- top: 0;
6241
- transition: all 0.4s;
6242
- width: ${({ orientation: orientation })=>orientation === "landscape" ? "50%" : "100%"};
6243
- height: ${({ orientation: orientation })=>orientation === "landscape" ? "100%" : "50%"};
6244
- padding: 17px 10px;
6245
- box-sizing: border-box;
6246
- `;
6247
6262
  const $b56218b5a57cb77c$export$dd2ac23a70f320dd = (0, $3Sbms$styledcomponents).div`
6248
- display: flex;
6263
+ display: ${({ show: show })=>show ? "flex" : "none"};
6249
6264
  flex-direction: column;
6250
6265
  justify-content: center;
6251
6266
  align-items: center;
6252
6267
  position: relative;
6253
- width: 100%;
6254
- height: 100%;
6268
+ width: ${({ width: width })=>width};
6269
+ height: ${({ height: height })=>height};
6255
6270
  background-color: ${({ theme: theme })=>theme.streamTileBackgroundColor};
6256
6271
  border: 2px solid ${({ theme: theme })=>theme.streamTileBorderColor};
6257
6272
  border-radius: 20px;
6258
6273
  box-sizing: border-box;
6259
6274
  color: #fff;
6260
6275
  font-family: Lato;
6276
+ padding: 20px;
6261
6277
  `;
6262
6278
  const $b56218b5a57cb77c$export$2dabfbe763cc7a4 = (0, $3Sbms$styledcomponents).h2`
6263
6279
  font-weight: 600;
6264
6280
  font-size: 16px;
6265
6281
  text-align: center;
6266
- width: 300px;
6282
+ max-width: 300px;
6267
6283
  `;
6268
6284
  const $b56218b5a57cb77c$export$6ed6e36e1b456f96 = (0, $3Sbms$styledcomponents).div`
6269
6285
  position: relative;
6270
6286
  display: flex;
6271
6287
  align-items: center;
6272
6288
  height: 50px;
6273
- width: 300px;
6289
+ width: 100%;
6290
+ max-width: 300px;
6274
6291
  background-color: ${({ theme: theme })=>theme.popupBackgroundSecondaryColor};
6275
6292
  border: 1px solid ${({ theme: theme })=>theme.popupBorderColor};
6276
6293
  border-radius: 15px;
6277
6294
  padding: 0 10px;
6295
+ box-sizing: border-box;
6278
6296
  `;
6279
6297
  const $b56218b5a57cb77c$export$5f759de1870a3e41 = (0, $3Sbms$styledcomponents).div`
6280
6298
  display: flex;
@@ -6316,7 +6334,7 @@ const $b56218b5a57cb77c$export$d7f3ab4b3437ad97 = (0, $3Sbms$styledcomponents).b
6316
6334
  const $b56218b5a57cb77c$export$c22678f0e7b404e0 = (0, $3Sbms$styledcomponents).p`
6317
6335
  font-size: 12px;
6318
6336
  font-weight: 400;
6319
- width: 300px;
6337
+ max-width: 300px;
6320
6338
  text-align: center;
6321
6339
  `;
6322
6340
 
@@ -6391,11 +6409,14 @@ const $93a0377c243d965e$export$c7df1b15b59b1df2 = /*#__PURE__*/ (0, $3Sbms$jsxs)
6391
6409
  });
6392
6410
 
6393
6411
 
6394
- const $f0b0b18fe6c6ae77$var$InvitationTile = ({ orientation: orientation })=>{
6412
+
6413
+
6414
+ const $f0b0b18fe6c6ae77$var$InvitationTile = ({ show: show , orientation: orientation , width: width , height: height })=>{
6395
6415
  const { t: t } = (0, $3Sbms$useTranslation)();
6416
+ const { options: options } = (0, $3Sbms$useContext)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039));
6396
6417
  const onCopyCallLinkClick = async ()=>{
6397
6418
  try {
6398
- await (0, $57162bcada7d6f66$export$2e2bcd8739ae039)(window.location.href);
6419
+ await (0, $57162bcada7d6f66$export$2e2bcd8739ae039)(options.sharedURL || window.location.href);
6399
6420
  (0, $a5146f9062d7bf28$export$3a57e165650c636f)(t("copyLink.copied"), {
6400
6421
  duration: 2000
6401
6422
  });
@@ -6406,37 +6427,37 @@ const $f0b0b18fe6c6ae77$var$InvitationTile = ({ orientation: orientation })=>{
6406
6427
  });
6407
6428
  }
6408
6429
  };
6409
- return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$d653589df987fd93), {
6430
+ return /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$dd2ac23a70f320dd), {
6431
+ show: show,
6432
+ width: width,
6433
+ height: height,
6410
6434
  orientation: orientation,
6411
- children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$dd2ac23a70f320dd), {
6412
- orientation: orientation,
6413
- children: [
6414
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$2dabfbe763cc7a4), {
6415
- children: t("invite.title")
6416
- }),
6417
- /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$6ed6e36e1b456f96), {
6418
- children: [
6419
- /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$5f759de1870a3e41), {
6420
- children: [
6421
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $1ec1d06e0a21fdaa$export$2e2bcd8739ae039), {
6422
- color: "black"
6423
- }),
6424
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$c6b180e8ec79154e), {
6425
- children: window.location.href
6426
- })
6427
- ]
6428
- }),
6429
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$d7f3ab4b3437ad97), {
6430
- onClick: onCopyCallLinkClick,
6431
- children: t("invite.copy")
6432
- })
6433
- ]
6434
- }),
6435
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$c22678f0e7b404e0), {
6436
- children: t("invite.description")
6437
- })
6438
- ]
6439
- })
6435
+ children: [
6436
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$2dabfbe763cc7a4), {
6437
+ children: t("invite.title")
6438
+ }),
6439
+ /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$6ed6e36e1b456f96), {
6440
+ children: [
6441
+ /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $b56218b5a57cb77c$export$5f759de1870a3e41), {
6442
+ children: [
6443
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $1ec1d06e0a21fdaa$export$2e2bcd8739ae039), {
6444
+ color: "black"
6445
+ }),
6446
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$c6b180e8ec79154e), {
6447
+ children: options.sharedURL || window.location.href
6448
+ })
6449
+ ]
6450
+ }),
6451
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$d7f3ab4b3437ad97), {
6452
+ onClick: onCopyCallLinkClick,
6453
+ children: t("invite.copy")
6454
+ })
6455
+ ]
6456
+ }),
6457
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $b56218b5a57cb77c$export$c22678f0e7b404e0), {
6458
+ children: t("invite.description")
6459
+ })
6460
+ ]
6440
6461
  });
6441
6462
  };
6442
6463
  var $f0b0b18fe6c6ae77$export$2e2bcd8739ae039 = $f0b0b18fe6c6ae77$var$InvitationTile;
@@ -6515,6 +6536,7 @@ const $cdab47bb8796991e$var$Video = ()=>{
6515
6536
  });
6516
6537
  const { streams: streams , highlightedTile: highlightedTile , dispatch: dispatch } = (0, $cce9fd41d8a55a18$export$b5633a7cfbe42d9f)();
6517
6538
  const [containerWidth, containerHeight] = (0, $af23c74942bdcae7$export$2b86bedf890eab8)(remoteTilesContainerRef.current);
6539
+ const showInvitation = streams.length < 1 && !highlightedTile && containerWidth > 0;
6518
6540
  (0, $3Sbms$useEffect)(()=>{
6519
6541
  if (options.GDPRDisclaimer) (0, $b8963bf62cf5b984$export$2e2bcd8739ae039)({
6520
6542
  message: "Para mejorar la calidad de nuestro servicio, esta llamada ser\xe1 grabada",
@@ -6525,9 +6547,10 @@ const $cdab47bb8796991e$var$Video = ()=>{
6525
6547
  options.GDPRDisclaimer
6526
6548
  ]);
6527
6549
  (0, $3Sbms$useEffect)(()=>{
6528
- if (remoteTilesContainerRef?.current && containerWidth && containerHeight) {
6550
+ if (remoteTilesContainerRef?.current) {
6529
6551
  const ratio = 1;
6530
- const numberOfTiles = remoteTilesContainerRef.current.childElementCount;
6552
+ let numberOfTiles = remoteTilesContainerRef.current.childElementCount;
6553
+ if (!showInvitation) numberOfTiles -= 1;
6531
6554
  const videoWidth = (0, $b8e10de7c6dba8c4$export$4d43009c33055644)({
6532
6555
  availableWidth: containerWidth - 16 * (numberOfTiles - 1),
6533
6556
  availableHeight: containerHeight - 16 * (numberOfTiles - 1),
@@ -6545,7 +6568,8 @@ const $cdab47bb8796991e$var$Video = ()=>{
6545
6568
  containerWidth,
6546
6569
  containerHeight,
6547
6570
  streams.length,
6548
- highlightedTile
6571
+ highlightedTile,
6572
+ showInvitation,
6549
6573
  ]);
6550
6574
  (0, $3Sbms$useEffect)(()=>{
6551
6575
  if (userInteractionTriggered) {
@@ -6699,7 +6723,10 @@ const $cdab47bb8796991e$var$Video = ()=>{
6699
6723
  height: tileSize.height
6700
6724
  }, stream.id);
6701
6725
  }),
6702
- streams.length < 1 && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $f0b0b18fe6c6ae77$export$2e2bcd8739ae039), {
6726
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $f0b0b18fe6c6ae77$export$2e2bcd8739ae039), {
6727
+ show: showInvitation,
6728
+ width: `${tileSize.width}px`,
6729
+ height: `${tileSize.height}px`,
6703
6730
  orientation: orientation
6704
6731
  })
6705
6732
  ]
@@ -9068,38 +9095,38 @@ const $d493afe60dcea711$var$backgroundOptions = [
9068
9095
  {
9069
9096
  title: "Blue",
9070
9097
  id: "background-blue",
9071
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/blue_background_icon.png`,
9072
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/blue_background.png`
9098
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/blue_background_icon.png`,
9099
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/blue_background.png`
9073
9100
  },
9074
9101
  {
9075
9102
  title: "Cold",
9076
9103
  id: "background-cold",
9077
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/cold_background_icon.png`,
9078
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/cold_background.png`
9104
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/cold_background_icon.png`,
9105
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/cold_background.png`
9079
9106
  },
9080
9107
  {
9081
9108
  title: "Bricks",
9082
9109
  id: "background-bricks",
9083
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/bricks_background_icon.png`,
9084
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/bricks_background.png`
9110
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/bricks_background_icon.png`,
9111
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/bricks_background.png`
9085
9112
  },
9086
9113
  {
9087
9114
  title: "White",
9088
9115
  id: "background-white",
9089
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/white_background_icon.png`,
9090
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/white_background.png`
9116
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/white_background_icon.png`,
9117
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/white_background.png`
9091
9118
  },
9092
9119
  {
9093
9120
  title: "Yellow",
9094
9121
  id: "background-yellow",
9095
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/yellow_background_icon.png`,
9096
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/yellow_background.png`
9122
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/yellow_background_icon.png`,
9123
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/yellow_background.png`
9097
9124
  },
9098
9125
  {
9099
9126
  title: "Warm",
9100
9127
  id: "background-warm",
9101
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/warm_background_icon.png`,
9102
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/warm_background.png`
9128
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/warm_background_icon.png`,
9129
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/warm_background.png`
9103
9130
  },
9104
9131
  {
9105
9132
  title: "None",
@@ -9992,7 +10019,7 @@ const $15a01b611391c1e7$var$audioSource = new Blob([
9992
10019
  const $15a01b611391c1e7$var$audioURL = URL.createObjectURL($15a01b611391c1e7$var$audioSource);
9993
10020
  let $15a01b611391c1e7$var$mediaResult = undefined;
9994
10021
  const $15a01b611391c1e7$export$716eeec86fd18da7 = ()=>{
9995
- $15a01b611391c1e7$var$mediaResult?.getAudioTracks().forEach((track)=>{
10022
+ $15a01b611391c1e7$var$mediaResult?.getTracks().forEach((track)=>{
9996
10023
  track.stop();
9997
10024
  });
9998
10025
  $15a01b611391c1e7$var$mediaResult = undefined;
@@ -10004,7 +10031,8 @@ const $15a01b611391c1e7$export$494039379563c94d = async ()=>{
10004
10031
  } catch (err) {
10005
10032
  console.warn("User interaction is required, asking audio GUM");
10006
10033
  $15a01b611391c1e7$var$mediaResult = await navigator.mediaDevices.getUserMedia({
10007
- audio: true
10034
+ audio: true,
10035
+ video: true
10008
10036
  });
10009
10037
  }
10010
10038
  };
@@ -10327,7 +10355,6 @@ window.hj = window.hj || function() {
10327
10355
 
10328
10356
 
10329
10357
 
10330
-
10331
10358
  const $9a3d651cab8c9249$var$GreetingSnapcallLogo = ()=>{
10332
10359
  return /*#__PURE__*/ (0, $3Sbms$jsx)("svg", {
10333
10360
  width: "72",
@@ -10559,90 +10586,87 @@ const $35c6a4b506b7dc62$export$d4a1a815e49dfefd = (0, $3Sbms$styledcomponents).d
10559
10586
 
10560
10587
 
10561
10588
 
10562
- const $f8d57e3d223f5089$var$getUserMedia = async (device)=>{
10563
- try {
10564
- const stream = navigator.mediaDevices.getUserMedia({
10565
- video: device === "webcam",
10566
- audio: device === "microphone"
10567
- });
10568
- return stream;
10569
- } catch (err) {
10570
- console.error("Get User Media Failed: ", err);
10571
- return null;
10572
- }
10573
- };
10574
- let $f8d57e3d223f5089$var$videoTrack;
10589
+
10575
10590
  const $f8d57e3d223f5089$var$GreetingView = ({ onGreetingDone: onGreetingDone })=>{
10576
10591
  const { t: t } = (0, $3Sbms$useTranslation)();
10577
- const mainContainerRef = (0, $3Sbms$useRef)(null);
10578
- const videoRef = (0, $3Sbms$useRef)(null);
10592
+ const [mainContainerRef, { width: width , height: height }] = (0, $af23c74942bdcae7$export$e295b0c537d32d7d)();
10579
10593
  const inputRef = (0, $3Sbms$useRef)(null);
10580
- const stream = (0, $3Sbms$useMemo)(()=>new MediaStream(), []);
10581
- const [webcamEnabled, setWebcamEnabled] = (0, $3Sbms$useState)(false);
10594
+ const videoRef = (0, $3Sbms$useRef)(null);
10595
+ const [videoTrack1, setVideoTrack] = (0, $3Sbms$useState)(undefined);
10582
10596
  const [micEnabled, setMicEnabled] = (0, $3Sbms$useState)(false);
10583
10597
  const [joining, setJoining] = (0, $3Sbms$useState)(false);
10584
- const [firstRender, setFirstRender] = (0, $3Sbms$useState)(true);
10585
- const [width, height] = (0, $af23c74942bdcae7$export$2b86bedf890eab8)(mainContainerRef.current);
10586
10598
  const desktop = width >= height;
10587
10599
  const onSubmit = ()=>{
10588
10600
  const displayName = inputRef.current?.value;
10601
+ const cameraEnabled = Boolean(videoTrack1);
10602
+ videoTrack1?.stop();
10589
10603
  setJoining(true);
10590
10604
  setTimeout(()=>{
10591
10605
  onGreetingDone({
10592
- cameraEnabled: webcamEnabled,
10606
+ cameraEnabled: cameraEnabled,
10593
10607
  micEnabled: micEnabled,
10594
10608
  displayName: displayName
10595
10609
  });
10596
10610
  }, 4000);
10597
10611
  };
10598
- const onCameraClick = (0, $3Sbms$useCallback)(()=>{
10599
- if (!webcamEnabled) $f8d57e3d223f5089$var$getUserMedia("webcam").then((videoStream)=>{
10600
- if (!videoStream || !videoRef.current) return;
10601
- $f8d57e3d223f5089$var$videoTrack = videoStream.getVideoTracks()[0];
10602
- stream.addTrack($f8d57e3d223f5089$var$videoTrack);
10603
- setWebcamEnabled(true);
10604
- if (!videoRef.current.srcObject) videoRef.current.srcObject = stream;
10612
+ const getUserMedia = async (opt)=>{
10613
+ try {
10614
+ const stream = await navigator.mediaDevices.getUserMedia(opt);
10615
+ const videoTrack = stream.getVideoTracks()[0];
10616
+ const audioTrack = stream.getAudioTracks()[0];
10617
+ if (videoTrack) setVideoTrack(videoTrack);
10618
+ if (audioTrack) setMicEnabled(true);
10619
+ audioTrack?.stop();
10620
+ } catch (err) {
10621
+ console.error("Get User Media Failed: ", err);
10622
+ }
10623
+ };
10624
+ const onCameraClick = (0, $3Sbms$useCallback)(async ()=>{
10625
+ if (!videoTrack1) await getUserMedia({
10626
+ video: true
10605
10627
  });
10606
10628
  else {
10607
- if ($f8d57e3d223f5089$var$videoTrack) stream.removeTrack($f8d57e3d223f5089$var$videoTrack);
10608
- $f8d57e3d223f5089$var$videoTrack = undefined;
10609
- setWebcamEnabled(false);
10629
+ videoTrack1.stop();
10630
+ setVideoTrack(undefined);
10610
10631
  }
10611
10632
  }, [
10612
- webcamEnabled,
10613
- stream
10633
+ videoTrack1
10614
10634
  ]);
10615
10635
  const onMicrophoneClick = (0, $3Sbms$useCallback)(async ()=>{
10616
- if (!micEnabled) $f8d57e3d223f5089$var$getUserMedia("microphone").then(()=>{
10617
- if (!videoRef.current) return;
10618
- setMicEnabled(true);
10636
+ if (!micEnabled) await getUserMedia({
10637
+ audio: true
10619
10638
  });
10620
10639
  else setMicEnabled(false);
10621
10640
  }, [
10622
10641
  micEnabled
10623
10642
  ]);
10624
10643
  (0, $3Sbms$useEffect)(()=>{
10625
- if (!firstRender) return;
10626
- try {
10627
- onCameraClick();
10628
- onMicrophoneClick();
10629
- } catch (err) {
10630
- console.error("Error: ", err);
10631
- } finally{
10632
- setFirstRender(false);
10644
+ if (videoRef.current) {
10645
+ if (videoTrack1) videoRef.current.srcObject = new MediaStream([
10646
+ videoTrack1
10647
+ ]);
10648
+ else videoRef.current.srcObject = null;
10633
10649
  }
10634
10650
  }, [
10635
- firstRender,
10636
- onCameraClick,
10637
- onMicrophoneClick
10651
+ videoRef,
10652
+ videoTrack1,
10653
+ width,
10654
+ height
10638
10655
  ]);
10656
+ (0, $3Sbms$useEffect)(()=>{
10657
+ getUserMedia({
10658
+ audio: true,
10659
+ video: true
10660
+ });
10661
+ }, []);
10639
10662
  if (joining === true) return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $35c6a4b506b7dc62$export$d4a1a815e49dfefd), {
10640
10663
  children: /*#__PURE__*/ (0, $3Sbms$jsx)("img", {
10641
- src: `${"https://stream-assets.snapcall.io/v1.7.0"}/animations/snapcall-logo-animation.gif`,
10664
+ src: `${"https://stream-assets.snapcall.io/v1.8.0"}/animations/snapcall-logo-animation.gif`,
10642
10665
  alt: "Snapcall logo animation",
10643
10666
  height: 40
10644
10667
  })
10645
10668
  });
10669
+ const webcamEnabled = Boolean(videoTrack1);
10646
10670
  return /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $35c6a4b506b7dc62$export$d653589df987fd93), {
10647
10671
  ref: mainContainerRef,
10648
10672
  children: [