mediasfu-vue 1.2.0 → 1.2.1

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
@@ -1721,6 +1721,8 @@ async function addVideosGrid({
1721
1721
  keepBackground,
1722
1722
  virtualStream,
1723
1723
  forceFullDisplay,
1724
+ shared,
1725
+ shareScreenStarted,
1724
1726
  otherGridStreams,
1725
1727
  updateOtherGridStreams,
1726
1728
  updateMiniCardsGrid,
@@ -1742,6 +1744,11 @@ async function addVideosGrid({
1742
1744
  const newComponents = [[], []];
1743
1745
  let remoteProducerId = "";
1744
1746
  numtoadd = mainGridStreams.length;
1747
+ const sidePanelForceFullDisplay = mediasfuShared.resolveSidePanelForceFullDisplay({
1748
+ forceFullDisplay,
1749
+ screenShareActive: !!(shared || shareScreenStarted),
1750
+ itemCount: numtoadd + (removeAltGrid ? 0 : altGridStreams.length)
1751
+ });
1745
1752
  if (removeAltGrid) {
1746
1753
  updateAddAltGrid(false);
1747
1754
  }
@@ -1878,7 +1885,7 @@ async function addVideosGrid({
1878
1885
  videoStream: videoParticipant.stream || new MediaStream(),
1879
1886
  remoteProducerId: videoParticipant.stream?.id || "",
1880
1887
  eventType,
1881
- forceFullDisplay: eventType === "webinar" ? false : forceFullDisplay,
1888
+ forceFullDisplay: eventType === "webinar" ? false : sidePanelForceFullDisplay,
1882
1889
  customStyle: {
1883
1890
  border: themedBorder
1884
1891
  },
@@ -1920,7 +1927,7 @@ async function addVideosGrid({
1920
1927
  videoStream: participant.stream || new MediaStream(),
1921
1928
  remoteProducerId: remoteProducerId || "",
1922
1929
  eventType,
1923
- forceFullDisplay,
1930
+ forceFullDisplay: sidePanelForceFullDisplay,
1924
1931
  customStyle: {
1925
1932
  border: themedBorder
1926
1933
  },
@@ -2060,7 +2067,7 @@ async function addVideosGrid({
2060
2067
  videoStream: participant.stream || new MediaStream(),
2061
2068
  remoteProducerId: remoteProducerId || "",
2062
2069
  eventType,
2063
- forceFullDisplay,
2070
+ forceFullDisplay: sidePanelForceFullDisplay,
2064
2071
  customStyle: {
2065
2072
  border: themedBorder
2066
2073
  },
@@ -17560,6 +17567,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
17560
17567
  isVisible: { type: Boolean },
17561
17568
  onClose: {},
17562
17569
  parameters: {},
17570
+ keepProcessingWhenHidden: { type: Boolean, default: true },
17563
17571
  renderMode: {},
17564
17572
  position: { default: "topLeft" },
17565
17573
  backgroundColor: { default: "#f5f5f5" },
@@ -17691,7 +17699,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
17691
17699
  const saveBackgroundButtonRef = vue.ref(null);
17692
17700
  const mainCanvasRef = vue.ref(null);
17693
17701
  const previewLoopVersion = vue.ref(0);
17694
- const previewAnimationFrameId = vue.ref(null);
17702
+ let stopPreviewFrameLoop = null;
17695
17703
  const previewCaptureTimeoutId = vue.ref(null);
17696
17704
  const clonedStream = vue.ref(null);
17697
17705
  const clonedTrack = vue.ref(null);
@@ -17715,10 +17723,8 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
17715
17723
  };
17716
17724
  const stopPreviewProcessing = () => {
17717
17725
  previewLoopVersion.value++;
17718
- if (previewAnimationFrameId.value !== null) {
17719
- cancelAnimationFrame(previewAnimationFrameId.value);
17720
- previewAnimationFrameId.value = null;
17721
- }
17726
+ stopPreviewFrameLoop?.();
17727
+ stopPreviewFrameLoop = null;
17722
17728
  if (previewCaptureTimeoutId.value !== null) {
17723
17729
  clearTimeout(previewCaptureTimeoutId.value);
17724
17730
  previewCaptureTimeoutId.value = null;
@@ -18044,6 +18050,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
18044
18050
  prevKeepBackground.value = keepBackground.value;
18045
18051
  props.parameters.updatePrevKeepBackground?.(keepBackground.value);
18046
18052
  if (!doSegmentation) {
18053
+ stopPreviewProcessing();
18047
18054
  processedStream.value?.getVideoTracks().forEach((track) => track.stop());
18048
18055
  processedStream.value = null;
18049
18056
  props.parameters.updateProcessedStream?.(null);
@@ -18055,20 +18062,17 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
18055
18062
  stopPreviewProcessing();
18056
18063
  const loopVersion = previewLoopVersion.value;
18057
18064
  let startedProcessing = false;
18058
- const processFrame = () => {
18059
- if (loopVersion !== previewLoopVersion.value || !selfieSegmentation.value || pauseSegmentation.value || !videoElement || videoElement.videoWidth === 0 || videoElement.videoHeight === 0) {
18060
- return;
18061
- }
18062
- try {
18063
- void selfieSegmentation.value.send({ image: videoElement }).catch(() => void 0);
18064
- } catch {
18065
- }
18066
- previewAnimationFrameId.value = requestAnimationFrame(processFrame);
18067
- };
18068
18065
  const startProcessing = () => {
18069
18066
  if (startedProcessing) return;
18070
18067
  startedProcessing = true;
18071
- processFrame();
18068
+ const segmentation = selfieSegmentation.value;
18069
+ if (!segmentation) return;
18070
+ stopPreviewFrameLoop = mediasfuShared.startVirtualBackgroundFrameLoop({
18071
+ owner: segmentation,
18072
+ keepProcessingWhenHidden: props.keepProcessingWhenHidden,
18073
+ shouldContinue: () => loopVersion === previewLoopVersion.value && !pauseSegmentation.value && videoElement.srcObject?.getVideoTracks?.()[0]?.readyState === "live",
18074
+ processFrame: () => videoElement.videoWidth > 0 && videoElement.videoHeight > 0 ? segmentation.send({ image: videoElement }) : void 0
18075
+ });
18072
18076
  };
18073
18077
  videoElement.onloadeddata = startProcessing;
18074
18078
  if (videoElement.readyState >= 2 && videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
@@ -18853,7 +18857,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
18853
18857
  };
18854
18858
  }
18855
18859
  });
18856
- const BackgroundModal = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-b065eaa4"]]);
18860
+ const BackgroundModal = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-1410a1d9"]]);
18857
18861
  const _hoisted_1$e = { class: "card-header" };
18858
18862
  const _hoisted_2$b = { class: "room-title" };
18859
18863
  const _hoisted_3$a = { class: "room-actions" };
@@ -44867,6 +44871,7 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
44867
44871
  isVisible: { type: Boolean },
44868
44872
  onClose: {},
44869
44873
  parameters: {},
44874
+ keepProcessingWhenHidden: { type: Boolean, default: true },
44870
44875
  renderMode: { default: "modal" },
44871
44876
  position: { default: "topLeft" },
44872
44877
  backgroundColor: { default: void 0 },
@@ -44942,7 +44947,7 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
44942
44947
  const saveBackgroundButtonRef = vue.ref(null);
44943
44948
  const mainCanvasRef = vue.ref(null);
44944
44949
  const previewLoopVersion = vue.ref(0);
44945
- const previewAnimationFrameId = vue.ref(null);
44950
+ let stopPreviewFrameLoop = null;
44946
44951
  const previewCaptureTimeoutId = vue.ref(null);
44947
44952
  const uploadFileName = vue.ref("No file selected");
44948
44953
  const isAutoApplyBusy = vue.ref(false);
@@ -45299,6 +45304,7 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
45299
45304
  prevKeepBackground.value = keepBackground.value;
45300
45305
  props.parameters.updatePrevKeepBackground?.(keepBackground.value);
45301
45306
  if (!doSegmentation) {
45307
+ stopPreviewProcessing();
45302
45308
  processedStream.value?.getVideoTracks().forEach((track) => track.stop());
45303
45309
  processedStream.value = null;
45304
45310
  props.parameters.updateProcessedStream?.(null);
@@ -45312,20 +45318,17 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
45312
45318
  stopPreviewProcessing();
45313
45319
  const loopVersion = previewLoopVersion.value;
45314
45320
  let startedProcessing = false;
45315
- const processFrame = () => {
45316
- if (loopVersion !== previewLoopVersion.value || !selfieSegmentation.value || pauseSegmentation.value || videoElement.videoWidth === 0 || videoElement.videoHeight === 0) {
45317
- return;
45318
- }
45319
- try {
45320
- void selfieSegmentation.value.send({ image: videoElement }).catch(() => void 0);
45321
- } catch {
45322
- }
45323
- previewAnimationFrameId.value = requestAnimationFrame(processFrame);
45324
- };
45325
45321
  const startProcessing = () => {
45326
45322
  if (startedProcessing) return;
45327
45323
  startedProcessing = true;
45328
- processFrame();
45324
+ const segmentation = selfieSegmentation.value;
45325
+ if (!segmentation) return;
45326
+ stopPreviewFrameLoop = mediasfuShared.startVirtualBackgroundFrameLoop({
45327
+ owner: segmentation,
45328
+ keepProcessingWhenHidden: props.keepProcessingWhenHidden,
45329
+ shouldContinue: () => loopVersion === previewLoopVersion.value && !pauseSegmentation.value && videoElement.srcObject?.getVideoTracks?.()[0]?.readyState === "live",
45330
+ processFrame: () => videoElement.videoWidth > 0 && videoElement.videoHeight > 0 ? segmentation.send({ image: videoElement }) : void 0
45331
+ });
45329
45332
  };
45330
45333
  videoElement.onloadeddata = startProcessing;
45331
45334
  if (videoElement.readyState >= 2 && videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
@@ -45477,10 +45480,8 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
45477
45480
  };
45478
45481
  const stopPreviewProcessing = () => {
45479
45482
  previewLoopVersion.value++;
45480
- if (previewAnimationFrameId.value !== null) {
45481
- cancelAnimationFrame(previewAnimationFrameId.value);
45482
- previewAnimationFrameId.value = null;
45483
- }
45483
+ stopPreviewFrameLoop?.();
45484
+ stopPreviewFrameLoop = null;
45484
45485
  if (previewCaptureTimeoutId.value !== null) {
45485
45486
  clearTimeout(previewCaptureTimeoutId.value);
45486
45487
  previewCaptureTimeoutId.value = null;
@@ -45812,7 +45813,7 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
45812
45813
  display: "flex",
45813
45814
  alignItems: "center",
45814
45815
  justifyContent: "space-between",
45815
- gap: "10px",
45816
+ gap: "8px",
45816
45817
  padding: "12px 16px 10px",
45817
45818
  borderBottom: "1px solid var(--ms-modern-panel-border)",
45818
45819
  background: panelGradientBackground$2
@@ -46050,15 +46051,16 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
46050
46051
  const defaultApplyButtonProps = vue.computed(() => ({
46051
46052
  class: "ms-modern-background-modal__apply",
46052
46053
  style: {
46053
- minHeight: "36px",
46054
- minWidth: "136px",
46054
+ minHeight: "34px",
46055
+ minWidth: "110px",
46055
46056
  borderRadius: "9999px",
46056
46057
  border: "1px solid var(--ms-modern-panel-border)",
46057
- paddingInline: "16px",
46058
+ paddingInline: "14px",
46059
+ fontSize: "13px",
46058
46060
  background: "var(--ms-modern-field-background)",
46059
46061
  color: "var(--ms-modern-text-primary)",
46060
46062
  fontFamily: "var(--ms-modern-font-family)",
46061
- fontWeight: 700,
46063
+ fontWeight: 600,
46062
46064
  boxShadow: "var(--ms-modern-shadow-soft)",
46063
46065
  cursor: "pointer"
46064
46066
  }
@@ -46076,15 +46078,16 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
46076
46078
  const defaultSaveButtonProps = vue.computed(() => ({
46077
46079
  class: "ms-modern-background-modal__save",
46078
46080
  style: {
46079
- minHeight: "36px",
46080
- minWidth: "136px",
46081
+ minHeight: "34px",
46082
+ minWidth: "110px",
46081
46083
  borderRadius: "9999px",
46082
46084
  border: "none",
46083
- paddingInline: "16px",
46085
+ paddingInline: "14px",
46086
+ fontSize: "13px",
46084
46087
  background: "linear-gradient(135deg, var(--ms-modern-brand-primary) 0%, var(--ms-modern-brand-secondary) 55%, var(--ms-modern-accent) 100%)",
46085
46088
  color: "#ffffff",
46086
46089
  fontFamily: "var(--ms-modern-font-family)",
46087
- fontWeight: 700,
46090
+ fontWeight: 600,
46088
46091
  boxShadow: "var(--ms-modern-shadow-soft)",
46089
46092
  cursor: "pointer"
46090
46093
  }
@@ -46480,7 +46483,7 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
46480
46483
  };
46481
46484
  }
46482
46485
  });
46483
- const ModernBackgroundModal = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-e7acacc7"]]);
46486
+ const ModernBackgroundModal = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-fcfc461a"]]);
46484
46487
  const panelGradientBackground$1 = "linear-gradient(180deg, var(--ms-modern-panel-surface-elevated) 0%, var(--ms-modern-panel-surface) 100%)";
46485
46488
  const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
46486
46489
  __name: "ModernConfirmHereModal",