@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.
package/dist/stream-ui.js CHANGED
@@ -1198,7 +1198,7 @@ class $a62e7f17be5cf3a0$export$2e2bcd8739ae039 {
1198
1198
 
1199
1199
 
1200
1200
  const $cb913ea078a876a6$var$log = new (0, $d0c6baf97675ab49$export$2e2bcd8739ae039)("MediaPipe");
1201
- const $cb913ea078a876a6$var$mediapipeUrl = "https://stream-assets.snapcall.io/v1.7.0";
1201
+ const $cb913ea078a876a6$var$mediapipeUrl = "https://stream-assets.snapcall.io/v1.8.0";
1202
1202
  let $cb913ea078a876a6$var$selfieSegmentationInitialized = false;
1203
1203
  const $cb913ea078a876a6$var$selfieSegmentation = new $jQDcL$mediapipeselfie_segmentation.SelfieSegmentation({
1204
1204
  locateFile: (file, prefix)=>{
@@ -1784,10 +1784,15 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
1784
1784
  async joinRoom() {
1785
1785
  this.streamerMediasoup = await (0, $a62e7f17be5cf3a0$export$2e2bcd8739ae039).create(this.protoo, this.config);
1786
1786
  // now we join
1787
- if (this.joinOptions.apiKey && this.joinOptions.email) try {
1788
- const agentInfo = await this.fetchAgentInfo({
1789
- apiKey: this.joinOptions.apiKey,
1790
- email: this.joinOptions.email
1787
+ const { apiKey: apiKey , email: email } = this.joinOptions;
1788
+ if (apiKey) try {
1789
+ let agentInfo = null;
1790
+ if (apiKey && email) agentInfo = await this.fetchAgentInfo({
1791
+ apiKey: apiKey,
1792
+ email: email
1793
+ });
1794
+ else if (apiKey) agentInfo = await this.fetchUserInfo({
1795
+ apiKey: apiKey
1791
1796
  });
1792
1797
  if (agentInfo) this.dispatchEvent(new $1dedebd5ff3002eb$var$SnapcallEvent("agentIdentity", {
1793
1798
  detail: {
@@ -1804,8 +1809,8 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
1804
1809
  }));
1805
1810
  }
1806
1811
  const { peers: peers } = await this.protoo.request("getRoomPeers", {
1807
- apiKey: this.joinOptions.apiKey,
1808
- email: this.joinOptions.email
1812
+ apiKey: apiKey,
1813
+ email: email
1809
1814
  });
1810
1815
  this.peers = new Map(peers.map((peer)=>[
1811
1816
  peer.id || peer.peerId,
@@ -2683,6 +2688,19 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
2683
2688
  });
2684
2689
  return agent;
2685
2690
  }
2691
+ async fetchUserInfo({ apiKey: apiKey }) {
2692
+ const apiURL = this.config.apiUrl;
2693
+ const user = await fetch(`${apiURL}/users/me`, {
2694
+ method: "get",
2695
+ headers: {
2696
+ Authorization: `Bearer ${apiKey}`
2697
+ }
2698
+ }).then((response)=>{
2699
+ if (response.ok) return response.json();
2700
+ throw new Error("Invalid user info");
2701
+ });
2702
+ return user;
2703
+ }
2686
2704
  setConfig(config) {
2687
2705
  this.config = {
2688
2706
  ...this.config,
@@ -3641,7 +3659,7 @@ const $e1930b467e7d8845$var$Header = ()=>{
3641
3659
  ]
3642
3660
  },
3643
3661
  ];
3644
- if ($e1930b467e7d8845$var$browser.platform.type === "desktop" && $e1930b467e7d8845$var$browser.engine.name === "Blink") computedCategories[2].items.push({
3662
+ if ($e1930b467e7d8845$var$browser.platform.type === "desktop" && $e1930b467e7d8845$var$browser.engine.name === "Blink") computedCategories[2].items.unshift({
3645
3663
  id: "virtualBackground",
3646
3664
  title: t("virtualBackground.title"),
3647
3665
  jsxIcon: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $cce7f1c9e9c29503$export$d5424e4dfe4be076), {}),
@@ -3710,6 +3728,35 @@ const $56e1e7a85d8bf4bb$export$2b86bedf890eab8 = (element)=>{
3710
3728
  ]);
3711
3729
  return size;
3712
3730
  };
3731
+ const $56e1e7a85d8bf4bb$var$defaultState = {
3732
+ bottom: 0,
3733
+ height: 0,
3734
+ left: 0,
3735
+ right: 0,
3736
+ top: 0,
3737
+ width: 0,
3738
+ x: 0,
3739
+ y: 0
3740
+ };
3741
+ function $56e1e7a85d8bf4bb$export$e295b0c537d32d7d() {
3742
+ const [element, ref] = (0, $jQDcL$react.useState)(null);
3743
+ const [rect, setRect] = (0, $jQDcL$react.useState)($56e1e7a85d8bf4bb$var$defaultState);
3744
+ (0, $jQDcL$react.useLayoutEffect)(()=>{
3745
+ if (!element) return;
3746
+ const updateSize = (entries)=>setRect(entries[0].contentRect);
3747
+ const observer = new ResizeObserver(updateSize);
3748
+ observer.observe(element);
3749
+ return ()=>{
3750
+ observer.disconnect();
3751
+ };
3752
+ }, [
3753
+ element
3754
+ ]);
3755
+ return [
3756
+ ref,
3757
+ rect
3758
+ ];
3759
+ }
3713
3760
 
3714
3761
 
3715
3762
 
@@ -4289,16 +4336,6 @@ const $2c45d365ee8aa1ab$export$98d9314e6a208b24 = (0, ($parcel$interopDefault($j
4289
4336
  bottom: 0;
4290
4337
  cursor: ${(props)=>props.cursor};
4291
4338
  transition: all 0.4s;
4292
-
4293
- ${(props)=>{
4294
- if (props.full) return (0, $jQDcL$styledcomponents.css)`
4295
- width: 100%;
4296
- height: 100%;
4297
- right: 0px;
4298
- padding: 17px 10px;
4299
- box-sizing: border-box;
4300
- `;
4301
- }}
4302
4339
  `;
4303
4340
  const $2c45d365ee8aa1ab$export$ba5a75b023bcdce2 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).div`
4304
4341
  display: flex;
@@ -5150,22 +5187,18 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5150
5187
  const { videosContainerRef: videosContainerRef , remoteTilesContainerRef: remoteTilesContainerRef , profile: profile , muted: muted , streaming: streaming , orientation: orientation , options: options , } = (0, $jQDcL$react.useContext)((0, $8b39f32976a7698a$export$2e2bcd8739ae039));
5151
5188
  const { streams: streams } = (0, $3f6e908c45fcc5b3$export$b5633a7cfbe42d9f)();
5152
5189
  const [containerWidth, containerHeight] = (0, $56e1e7a85d8bf4bb$export$2b86bedf890eab8)(videosContainerRef.current);
5190
+ const cursor = streaming && !extended ? "pointer" : "default";
5191
+ const computedWidth = (0, $7de6ded9bdec6f42$export$a6112fefa8de799d)({
5192
+ containerWidth: containerWidth,
5193
+ containerHeight: containerHeight,
5194
+ minimumWidth: $8393b5c887e16c8c$var$minimumTileWidth,
5195
+ maximumWidth: $8393b5c887e16c8c$var$maximumTileWidth,
5196
+ orientation: orientation,
5197
+ extended: extended
5198
+ });
5199
+ let tileWidth = `${computedWidth}px`;
5200
+ let tileHeight = `${computedWidth}px`;
5153
5201
  const isAlone = streams.length < 1;
5154
- const cursor = streaming && !isAlone && !extended ? "pointer" : "default";
5155
- let tileWidth = orientation === "landscape" ? "50%" : "100%";
5156
- let tileHeight = orientation === "landscape" ? "100%" : "50%";
5157
- if (!isAlone) {
5158
- const computedWidth = (0, $7de6ded9bdec6f42$export$a6112fefa8de799d)({
5159
- containerWidth: containerWidth,
5160
- containerHeight: containerHeight,
5161
- minimumWidth: $8393b5c887e16c8c$var$minimumTileWidth,
5162
- maximumWidth: $8393b5c887e16c8c$var$maximumTileWidth,
5163
- orientation: orientation,
5164
- extended: extended
5165
- });
5166
- tileWidth = `${computedWidth}px`;
5167
- tileHeight = `${computedWidth}px`;
5168
- }
5169
5202
  const onLocalVideoChange = (event)=>{
5170
5203
  if (!event.detail?.camera?.device) return;
5171
5204
  if (!videoElementRef.current) throw new Error("videoElementRef not available");
@@ -5175,7 +5208,7 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5175
5208
  setZoomAvailable((0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).isVideoZoomAvailable());
5176
5209
  };
5177
5210
  const onSelfTileClick = ()=>{
5178
- if (streaming && !isAlone && !deviceRequest && !extended && SelfTileRef.current) {
5211
+ if (streaming && !deviceRequest && !extended && SelfTileRef.current) {
5179
5212
  (0, $4ee7c4b0b3646a08$export$ab7d69e250642927)({
5180
5213
  element: SelfTileRef.current
5181
5214
  });
@@ -5243,7 +5276,7 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5243
5276
  });
5244
5277
  };
5245
5278
  const onSelfTileMouseDown = (mouseDownEvent)=>{
5246
- if (!isAlone && !extended && SelfTileRef.current && videosContainerRef.current) (0, $4ee7c4b0b3646a08$export$298c6ed7f6695dd6)({
5279
+ if (!extended && SelfTileRef.current && videosContainerRef.current) (0, $4ee7c4b0b3646a08$export$298c6ed7f6695dd6)({
5247
5280
  mouseDownEvent: mouseDownEvent,
5248
5281
  targetElement: SelfTileRef.current,
5249
5282
  containerElement: videosContainerRef.current
@@ -5268,6 +5301,7 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5268
5301
  if (streaming && videoElementRef.current && !videoElementRef.current.srcObject) videoElementRef.current.srcObject = videoMediaProviderRef.current;
5269
5302
  }, [
5270
5303
  streaming,
5304
+ isAlone,
5271
5305
  isSomeonePresenting
5272
5306
  ]);
5273
5307
  (0, $jQDcL$react.useEffect)(()=>{
@@ -5278,12 +5312,6 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5278
5312
  containerWidth,
5279
5313
  containerHeight
5280
5314
  ]);
5281
- (0, $jQDcL$react.useEffect)(()=>{
5282
- if (isAlone && extended) setExtended(false);
5283
- }, [
5284
- isAlone,
5285
- extended
5286
- ]);
5287
5315
  (0, $jQDcL$react.useEffect)(()=>{
5288
5316
  if (!extended) {
5289
5317
  setSnapshotAnimation(false);
@@ -5389,7 +5417,7 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5389
5417
  })
5390
5418
  ]
5391
5419
  });
5392
- if (isSomeonePresenting && remoteTilesContainerRef?.current) return /*#__PURE__*/ (0, $jQDcL$reactdom.createPortal)(/*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $66c45b20958474ec$export$798352b46783b18d), {
5420
+ if (remoteTilesContainerRef?.current && (isAlone || isSomeonePresenting)) return /*#__PURE__*/ (0, $jQDcL$reactdom.createPortal)(/*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $66c45b20958474ec$export$798352b46783b18d), {
5393
5421
  style: {
5394
5422
  width: `${width}px`,
5395
5423
  height: `${height}px`
@@ -5401,7 +5429,6 @@ const $8393b5c887e16c8c$var$SelfStreamTile = ({ isSomeonePresenting: isSomeonePr
5401
5429
  children: [
5402
5430
  /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $2c45d365ee8aa1ab$export$98d9314e6a208b24), {
5403
5431
  ref: SelfTileRef,
5404
- full: isAlone,
5405
5432
  style: {
5406
5433
  width: tileWidth,
5407
5434
  height: tileHeight
@@ -6240,49 +6267,40 @@ var $c225be5472ba393a$export$2e2bcd8739ae039 = $c225be5472ba393a$var$Highlighted
6240
6267
 
6241
6268
 
6242
6269
 
6243
- const $7e6d6d75bd13cce5$export$d653589df987fd93 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).div`
6244
- display: flex;
6245
- position: absolute;
6246
- z-index: 20;
6247
- left: 0;
6248
- top: 0;
6249
- transition: all 0.4s;
6250
- width: ${({ orientation: orientation })=>orientation === "landscape" ? "50%" : "100%"};
6251
- height: ${({ orientation: orientation })=>orientation === "landscape" ? "100%" : "50%"};
6252
- padding: 17px 10px;
6253
- box-sizing: border-box;
6254
- `;
6255
6270
  const $7e6d6d75bd13cce5$export$dd2ac23a70f320dd = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).div`
6256
- display: flex;
6271
+ display: ${({ show: show })=>show ? "flex" : "none"};
6257
6272
  flex-direction: column;
6258
6273
  justify-content: center;
6259
6274
  align-items: center;
6260
6275
  position: relative;
6261
- width: 100%;
6262
- height: 100%;
6276
+ width: ${({ width: width })=>width};
6277
+ height: ${({ height: height })=>height};
6263
6278
  background-color: ${({ theme: theme })=>theme.streamTileBackgroundColor};
6264
6279
  border: 2px solid ${({ theme: theme })=>theme.streamTileBorderColor};
6265
6280
  border-radius: 20px;
6266
6281
  box-sizing: border-box;
6267
6282
  color: #fff;
6268
6283
  font-family: Lato;
6284
+ padding: 20px;
6269
6285
  `;
6270
6286
  const $7e6d6d75bd13cce5$export$2dabfbe763cc7a4 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).h2`
6271
6287
  font-weight: 600;
6272
6288
  font-size: 16px;
6273
6289
  text-align: center;
6274
- width: 300px;
6290
+ max-width: 300px;
6275
6291
  `;
6276
6292
  const $7e6d6d75bd13cce5$export$6ed6e36e1b456f96 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).div`
6277
6293
  position: relative;
6278
6294
  display: flex;
6279
6295
  align-items: center;
6280
6296
  height: 50px;
6281
- width: 300px;
6297
+ width: 100%;
6298
+ max-width: 300px;
6282
6299
  background-color: ${({ theme: theme })=>theme.popupBackgroundSecondaryColor};
6283
6300
  border: 1px solid ${({ theme: theme })=>theme.popupBorderColor};
6284
6301
  border-radius: 15px;
6285
6302
  padding: 0 10px;
6303
+ box-sizing: border-box;
6286
6304
  `;
6287
6305
  const $7e6d6d75bd13cce5$export$5f759de1870a3e41 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).div`
6288
6306
  display: flex;
@@ -6324,7 +6342,7 @@ const $7e6d6d75bd13cce5$export$d7f3ab4b3437ad97 = (0, ($parcel$interopDefault($j
6324
6342
  const $7e6d6d75bd13cce5$export$c22678f0e7b404e0 = (0, ($parcel$interopDefault($jQDcL$styledcomponents))).p`
6325
6343
  font-size: 12px;
6326
6344
  font-weight: 400;
6327
- width: 300px;
6345
+ max-width: 300px;
6328
6346
  text-align: center;
6329
6347
  `;
6330
6348
 
@@ -6399,11 +6417,14 @@ const $e8ac63718934c648$export$c7df1b15b59b1df2 = /*#__PURE__*/ (0, $jQDcL$react
6399
6417
  });
6400
6418
 
6401
6419
 
6402
- const $23c39d8ee81f4f67$var$InvitationTile = ({ orientation: orientation })=>{
6420
+
6421
+
6422
+ const $23c39d8ee81f4f67$var$InvitationTile = ({ show: show , orientation: orientation , width: width , height: height })=>{
6403
6423
  const { t: t } = (0, $jQDcL$reacti18next.useTranslation)();
6424
+ const { options: options } = (0, $jQDcL$react.useContext)((0, $8b39f32976a7698a$export$2e2bcd8739ae039));
6404
6425
  const onCopyCallLinkClick = async ()=>{
6405
6426
  try {
6406
- await (0, $0bea101d3ef852fb$export$2e2bcd8739ae039)(window.location.href);
6427
+ await (0, $0bea101d3ef852fb$export$2e2bcd8739ae039)(options.sharedURL || window.location.href);
6407
6428
  (0, $84c6cbcbb594d072$export$3a57e165650c636f)(t("copyLink.copied"), {
6408
6429
  duration: 2000
6409
6430
  });
@@ -6414,37 +6435,37 @@ const $23c39d8ee81f4f67$var$InvitationTile = ({ orientation: orientation })=>{
6414
6435
  });
6415
6436
  }
6416
6437
  };
6417
- return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$d653589df987fd93), {
6438
+ return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$dd2ac23a70f320dd), {
6439
+ show: show,
6440
+ width: width,
6441
+ height: height,
6418
6442
  orientation: orientation,
6419
- children: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$dd2ac23a70f320dd), {
6420
- orientation: orientation,
6421
- children: [
6422
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$2dabfbe763cc7a4), {
6423
- children: t("invite.title")
6424
- }),
6425
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$6ed6e36e1b456f96), {
6426
- children: [
6427
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$5f759de1870a3e41), {
6428
- children: [
6429
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $daca1602b495441e$export$2e2bcd8739ae039), {
6430
- color: "black"
6431
- }),
6432
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$c6b180e8ec79154e), {
6433
- children: window.location.href
6434
- })
6435
- ]
6436
- }),
6437
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$d7f3ab4b3437ad97), {
6438
- onClick: onCopyCallLinkClick,
6439
- children: t("invite.copy")
6440
- })
6441
- ]
6442
- }),
6443
- /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$c22678f0e7b404e0), {
6444
- children: t("invite.description")
6445
- })
6446
- ]
6447
- })
6443
+ children: [
6444
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$2dabfbe763cc7a4), {
6445
+ children: t("invite.title")
6446
+ }),
6447
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$6ed6e36e1b456f96), {
6448
+ children: [
6449
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $7e6d6d75bd13cce5$export$5f759de1870a3e41), {
6450
+ children: [
6451
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $daca1602b495441e$export$2e2bcd8739ae039), {
6452
+ color: "black"
6453
+ }),
6454
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$c6b180e8ec79154e), {
6455
+ children: options.sharedURL || window.location.href
6456
+ })
6457
+ ]
6458
+ }),
6459
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$d7f3ab4b3437ad97), {
6460
+ onClick: onCopyCallLinkClick,
6461
+ children: t("invite.copy")
6462
+ })
6463
+ ]
6464
+ }),
6465
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $7e6d6d75bd13cce5$export$c22678f0e7b404e0), {
6466
+ children: t("invite.description")
6467
+ })
6468
+ ]
6448
6469
  });
6449
6470
  };
6450
6471
  var $23c39d8ee81f4f67$export$2e2bcd8739ae039 = $23c39d8ee81f4f67$var$InvitationTile;
@@ -6523,6 +6544,7 @@ const $88b23a8428e67b66$var$Video = ()=>{
6523
6544
  });
6524
6545
  const { streams: streams , highlightedTile: highlightedTile , dispatch: dispatch } = (0, $3f6e908c45fcc5b3$export$b5633a7cfbe42d9f)();
6525
6546
  const [containerWidth, containerHeight] = (0, $56e1e7a85d8bf4bb$export$2b86bedf890eab8)(remoteTilesContainerRef.current);
6547
+ const showInvitation = streams.length < 1 && !highlightedTile && containerWidth > 0;
6526
6548
  (0, $jQDcL$react.useEffect)(()=>{
6527
6549
  if (options.GDPRDisclaimer) (0, $537dcc6df507dc4a$export$2e2bcd8739ae039)({
6528
6550
  message: "Para mejorar la calidad de nuestro servicio, esta llamada ser\xe1 grabada",
@@ -6533,9 +6555,10 @@ const $88b23a8428e67b66$var$Video = ()=>{
6533
6555
  options.GDPRDisclaimer
6534
6556
  ]);
6535
6557
  (0, $jQDcL$react.useEffect)(()=>{
6536
- if (remoteTilesContainerRef?.current && containerWidth && containerHeight) {
6558
+ if (remoteTilesContainerRef?.current) {
6537
6559
  const ratio = 1;
6538
- const numberOfTiles = remoteTilesContainerRef.current.childElementCount;
6560
+ let numberOfTiles = remoteTilesContainerRef.current.childElementCount;
6561
+ if (!showInvitation) numberOfTiles -= 1;
6539
6562
  const videoWidth = (0, $7de6ded9bdec6f42$export$4d43009c33055644)({
6540
6563
  availableWidth: containerWidth - 16 * (numberOfTiles - 1),
6541
6564
  availableHeight: containerHeight - 16 * (numberOfTiles - 1),
@@ -6553,7 +6576,8 @@ const $88b23a8428e67b66$var$Video = ()=>{
6553
6576
  containerWidth,
6554
6577
  containerHeight,
6555
6578
  streams.length,
6556
- highlightedTile
6579
+ highlightedTile,
6580
+ showInvitation,
6557
6581
  ]);
6558
6582
  (0, $jQDcL$react.useEffect)(()=>{
6559
6583
  if (userInteractionTriggered) {
@@ -6707,7 +6731,10 @@ const $88b23a8428e67b66$var$Video = ()=>{
6707
6731
  height: tileSize.height
6708
6732
  }, stream.id);
6709
6733
  }),
6710
- streams.length < 1 && /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $23c39d8ee81f4f67$export$2e2bcd8739ae039), {
6734
+ /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $23c39d8ee81f4f67$export$2e2bcd8739ae039), {
6735
+ show: showInvitation,
6736
+ width: `${tileSize.width}px`,
6737
+ height: `${tileSize.height}px`,
6711
6738
  orientation: orientation
6712
6739
  })
6713
6740
  ]
@@ -9076,38 +9103,38 @@ const $8a52c9358bc52b86$var$backgroundOptions = [
9076
9103
  {
9077
9104
  title: "Blue",
9078
9105
  id: "background-blue",
9079
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/blue_background_icon.png`,
9080
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/blue_background.png`
9106
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/blue_background_icon.png`,
9107
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/blue_background.png`
9081
9108
  },
9082
9109
  {
9083
9110
  title: "Cold",
9084
9111
  id: "background-cold",
9085
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/cold_background_icon.png`,
9086
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/cold_background.png`
9112
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/cold_background_icon.png`,
9113
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/cold_background.png`
9087
9114
  },
9088
9115
  {
9089
9116
  title: "Bricks",
9090
9117
  id: "background-bricks",
9091
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/bricks_background_icon.png`,
9092
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/bricks_background.png`
9118
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/bricks_background_icon.png`,
9119
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/bricks_background.png`
9093
9120
  },
9094
9121
  {
9095
9122
  title: "White",
9096
9123
  id: "background-white",
9097
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/white_background_icon.png`,
9098
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/white_background.png`
9124
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/white_background_icon.png`,
9125
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/white_background.png`
9099
9126
  },
9100
9127
  {
9101
9128
  title: "Yellow",
9102
9129
  id: "background-yellow",
9103
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/yellow_background_icon.png`,
9104
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/yellow_background.png`
9130
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/yellow_background_icon.png`,
9131
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/yellow_background.png`
9105
9132
  },
9106
9133
  {
9107
9134
  title: "Warm",
9108
9135
  id: "background-warm",
9109
- iconUrl: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/warm_background_icon.png`,
9110
- value: `${"https://stream-assets.snapcall.io/v1.7.0"}/backgrounds/warm_background.png`
9136
+ iconUrl: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/warm_background_icon.png`,
9137
+ value: `${"https://stream-assets.snapcall.io/v1.8.0"}/backgrounds/warm_background.png`
9111
9138
  },
9112
9139
  {
9113
9140
  title: "None",
@@ -10000,7 +10027,7 @@ const $c3d5253d9d597eb5$var$audioSource = new Blob([
10000
10027
  const $c3d5253d9d597eb5$var$audioURL = URL.createObjectURL($c3d5253d9d597eb5$var$audioSource);
10001
10028
  let $c3d5253d9d597eb5$var$mediaResult = undefined;
10002
10029
  const $c3d5253d9d597eb5$export$716eeec86fd18da7 = ()=>{
10003
- $c3d5253d9d597eb5$var$mediaResult?.getAudioTracks().forEach((track)=>{
10030
+ $c3d5253d9d597eb5$var$mediaResult?.getTracks().forEach((track)=>{
10004
10031
  track.stop();
10005
10032
  });
10006
10033
  $c3d5253d9d597eb5$var$mediaResult = undefined;
@@ -10012,7 +10039,8 @@ const $c3d5253d9d597eb5$export$494039379563c94d = async ()=>{
10012
10039
  } catch (err) {
10013
10040
  console.warn("User interaction is required, asking audio GUM");
10014
10041
  $c3d5253d9d597eb5$var$mediaResult = await navigator.mediaDevices.getUserMedia({
10015
- audio: true
10042
+ audio: true,
10043
+ video: true
10016
10044
  });
10017
10045
  }
10018
10046
  };
@@ -10335,7 +10363,6 @@ window.hj = window.hj || function() {
10335
10363
 
10336
10364
 
10337
10365
 
10338
-
10339
10366
  const $d9d258dccafa26ef$var$GreetingSnapcallLogo = ()=>{
10340
10367
  return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)("svg", {
10341
10368
  width: "72",
@@ -10567,90 +10594,87 @@ const $5fd6e456b33aeaa7$export$d4a1a815e49dfefd = (0, ($parcel$interopDefault($j
10567
10594
 
10568
10595
 
10569
10596
 
10570
- const $3305ca02e86dabd1$var$getUserMedia = async (device)=>{
10571
- try {
10572
- const stream = navigator.mediaDevices.getUserMedia({
10573
- video: device === "webcam",
10574
- audio: device === "microphone"
10575
- });
10576
- return stream;
10577
- } catch (err) {
10578
- console.error("Get User Media Failed: ", err);
10579
- return null;
10580
- }
10581
- };
10582
- let $3305ca02e86dabd1$var$videoTrack;
10597
+
10583
10598
  const $3305ca02e86dabd1$var$GreetingView = ({ onGreetingDone: onGreetingDone })=>{
10584
10599
  const { t: t } = (0, $jQDcL$reacti18next.useTranslation)();
10585
- const mainContainerRef = (0, $jQDcL$react.useRef)(null);
10586
- const videoRef = (0, $jQDcL$react.useRef)(null);
10600
+ const [mainContainerRef, { width: width , height: height }] = (0, $56e1e7a85d8bf4bb$export$e295b0c537d32d7d)();
10587
10601
  const inputRef = (0, $jQDcL$react.useRef)(null);
10588
- const stream = (0, $jQDcL$react.useMemo)(()=>new MediaStream(), []);
10589
- const [webcamEnabled, setWebcamEnabled] = (0, $jQDcL$react.useState)(false);
10602
+ const videoRef = (0, $jQDcL$react.useRef)(null);
10603
+ const [videoTrack1, setVideoTrack] = (0, $jQDcL$react.useState)(undefined);
10590
10604
  const [micEnabled, setMicEnabled] = (0, $jQDcL$react.useState)(false);
10591
10605
  const [joining, setJoining] = (0, $jQDcL$react.useState)(false);
10592
- const [firstRender, setFirstRender] = (0, $jQDcL$react.useState)(true);
10593
- const [width, height] = (0, $56e1e7a85d8bf4bb$export$2b86bedf890eab8)(mainContainerRef.current);
10594
10606
  const desktop = width >= height;
10595
10607
  const onSubmit = ()=>{
10596
10608
  const displayName = inputRef.current?.value;
10609
+ const cameraEnabled = Boolean(videoTrack1);
10610
+ videoTrack1?.stop();
10597
10611
  setJoining(true);
10598
10612
  setTimeout(()=>{
10599
10613
  onGreetingDone({
10600
- cameraEnabled: webcamEnabled,
10614
+ cameraEnabled: cameraEnabled,
10601
10615
  micEnabled: micEnabled,
10602
10616
  displayName: displayName
10603
10617
  });
10604
10618
  }, 4000);
10605
10619
  };
10606
- const onCameraClick = (0, $jQDcL$react.useCallback)(()=>{
10607
- if (!webcamEnabled) $3305ca02e86dabd1$var$getUserMedia("webcam").then((videoStream)=>{
10608
- if (!videoStream || !videoRef.current) return;
10609
- $3305ca02e86dabd1$var$videoTrack = videoStream.getVideoTracks()[0];
10610
- stream.addTrack($3305ca02e86dabd1$var$videoTrack);
10611
- setWebcamEnabled(true);
10612
- if (!videoRef.current.srcObject) videoRef.current.srcObject = stream;
10620
+ const getUserMedia = async (opt)=>{
10621
+ try {
10622
+ const stream = await navigator.mediaDevices.getUserMedia(opt);
10623
+ const videoTrack = stream.getVideoTracks()[0];
10624
+ const audioTrack = stream.getAudioTracks()[0];
10625
+ if (videoTrack) setVideoTrack(videoTrack);
10626
+ if (audioTrack) setMicEnabled(true);
10627
+ audioTrack?.stop();
10628
+ } catch (err) {
10629
+ console.error("Get User Media Failed: ", err);
10630
+ }
10631
+ };
10632
+ const onCameraClick = (0, $jQDcL$react.useCallback)(async ()=>{
10633
+ if (!videoTrack1) await getUserMedia({
10634
+ video: true
10613
10635
  });
10614
10636
  else {
10615
- if ($3305ca02e86dabd1$var$videoTrack) stream.removeTrack($3305ca02e86dabd1$var$videoTrack);
10616
- $3305ca02e86dabd1$var$videoTrack = undefined;
10617
- setWebcamEnabled(false);
10637
+ videoTrack1.stop();
10638
+ setVideoTrack(undefined);
10618
10639
  }
10619
10640
  }, [
10620
- webcamEnabled,
10621
- stream
10641
+ videoTrack1
10622
10642
  ]);
10623
10643
  const onMicrophoneClick = (0, $jQDcL$react.useCallback)(async ()=>{
10624
- if (!micEnabled) $3305ca02e86dabd1$var$getUserMedia("microphone").then(()=>{
10625
- if (!videoRef.current) return;
10626
- setMicEnabled(true);
10644
+ if (!micEnabled) await getUserMedia({
10645
+ audio: true
10627
10646
  });
10628
10647
  else setMicEnabled(false);
10629
10648
  }, [
10630
10649
  micEnabled
10631
10650
  ]);
10632
10651
  (0, $jQDcL$react.useEffect)(()=>{
10633
- if (!firstRender) return;
10634
- try {
10635
- onCameraClick();
10636
- onMicrophoneClick();
10637
- } catch (err) {
10638
- console.error("Error: ", err);
10639
- } finally{
10640
- setFirstRender(false);
10652
+ if (videoRef.current) {
10653
+ if (videoTrack1) videoRef.current.srcObject = new MediaStream([
10654
+ videoTrack1
10655
+ ]);
10656
+ else videoRef.current.srcObject = null;
10641
10657
  }
10642
10658
  }, [
10643
- firstRender,
10644
- onCameraClick,
10645
- onMicrophoneClick
10659
+ videoRef,
10660
+ videoTrack1,
10661
+ width,
10662
+ height
10646
10663
  ]);
10664
+ (0, $jQDcL$react.useEffect)(()=>{
10665
+ getUserMedia({
10666
+ audio: true,
10667
+ video: true
10668
+ });
10669
+ }, []);
10647
10670
  if (joining === true) return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $5fd6e456b33aeaa7$export$d4a1a815e49dfefd), {
10648
10671
  children: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)("img", {
10649
- src: `${"https://stream-assets.snapcall.io/v1.7.0"}/animations/snapcall-logo-animation.gif`,
10672
+ src: `${"https://stream-assets.snapcall.io/v1.8.0"}/animations/snapcall-logo-animation.gif`,
10650
10673
  alt: "Snapcall logo animation",
10651
10674
  height: 40
10652
10675
  })
10653
10676
  });
10677
+ const webcamEnabled = Boolean(videoTrack1);
10654
10678
  return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $5fd6e456b33aeaa7$export$d653589df987fd93), {
10655
10679
  ref: mainContainerRef,
10656
10680
  children: [