@skippr/live-agent-sdk 0.118.0 → 0.119.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.
@@ -6169,11 +6169,11 @@ function barPopsDown(pos) {
6169
6169
  function barLeftAligned(pos) {
6170
6170
  return pos.x + VOICE_BAR_WIDTH_PX / 2 < window.innerWidth / 2;
6171
6171
  }
6172
- function defaultBarPos() {
6172
+ function defaultBarPos(widthPx) {
6173
6173
  return clampBarPos({
6174
- x: window.innerWidth / 2 - VOICE_BAR_WIDTH_PX / 2,
6174
+ x: window.innerWidth / 2 - widthPx / 2,
6175
6175
  y: window.innerHeight - VOICE_BAR_EDGE_MARGIN_PX - VOICE_BAR_HEIGHT_PX
6176
- }, VOICE_BAR_WIDTH_PX);
6176
+ }, widthPx);
6177
6177
  }
6178
6178
  function barPosStyle(pos) {
6179
6179
  return {
@@ -12587,7 +12587,7 @@ function useBarNotifications() {
12587
12587
 
12588
12588
  // src/components/VoiceBarFrame.tsx
12589
12589
  import { useIsSpeaking, useLocalParticipant as useLocalParticipant13 } from "@livekit/components-react/hooks";
12590
- import { useCallback as useCallback34, useContext as useContext27, useEffect as useEffect48, useRef as useRef43, useState as useState39 } from "react";
12590
+ import { useCallback as useCallback34, useContext as useContext27, useEffect as useEffect48, useLayoutEffect as useLayoutEffect5, useRef as useRef43, useState as useState39 } from "react";
12591
12591
 
12592
12592
  // src/hooks/useKeyboardStop.ts
12593
12593
  import { useEffect as useEffect40, useRef as useRef37 } from "react";
@@ -13588,8 +13588,15 @@ function VoiceBarFrame({
13588
13588
  const showLivePill = !isLoading && isConnected && !textMode && !pushOrTap;
13589
13589
  const barWidthPx = !showLivePill ? VOICE_BAR_WIDTH_PX : isHeld ? 120 : 156;
13590
13590
  barWidthRef.current = barWidthPx;
13591
- useEffect48(() => {
13592
- const inBounds = clampBarPos(pos, barWidthPx);
13591
+ const effectivePos = pos ?? defaultBarPos(barWidthPx);
13592
+ const posWidthRef = useRef43(barWidthPx);
13593
+ useLayoutEffect5(() => {
13594
+ const prevWidthPx = posWidthRef.current;
13595
+ posWidthRef.current = barWidthPx;
13596
+ if (pos === null)
13597
+ return;
13598
+ const centered = prevWidthPx === barWidthPx ? pos : { x: pos.x + Math.trunc((prevWidthPx - barWidthPx) / 2), y: pos.y };
13599
+ const inBounds = clampBarPos(centered, barWidthPx);
13593
13600
  if (inBounds.x !== pos.x)
13594
13601
  onDrop(inBounds, barWidthPx);
13595
13602
  }, [pos, barWidthPx, onDrop]);
@@ -13674,8 +13681,8 @@ function VoiceBarFrame({
13674
13681
  const showAutoOffStrip = !slotClaimed && autoOffClosing;
13675
13682
  const hintSuppressed = slotClaimed || isCapturingSpeech || planCardActive || showLiveStrip || isHeld || showTimerStrip || showAutoOffStrip;
13676
13683
  const liveStripLabel = showActionControl ? copy.voiceBarWorking : copy.voiceBarThinking;
13677
- const popsDown = barPopsDown(pos);
13678
- const isLeftAligned = barLeftAligned(pos);
13684
+ const popsDown = barPopsDown(effectivePos);
13685
+ const isLeftAligned = barLeftAligned(effectivePos);
13679
13686
  const stripStyle = {
13680
13687
  position: "absolute",
13681
13688
  left: 0,
@@ -13697,7 +13704,7 @@ function VoiceBarFrame({
13697
13704
  const pillEvaporate = autoOffClosing ? "skippr:[animation:skippr-evaporate_3.2s_ease-in_forwards] skippr:motion-reduce:animate-none" : "";
13698
13705
  return /* @__PURE__ */ jsxs41("div", {
13699
13706
  ref: setContainerRefs,
13700
- style: { ...barPosStyle(pos), width: barWidthPx },
13707
+ style: { ...barPosStyle(effectivePos), width: barWidthPx },
13701
13708
  className: "skippr:fixed skippr:z-[9999] skippr:flex skippr:touch-none skippr:cursor-grab skippr:items-center",
13702
13709
  children: [
13703
13710
  glow && /* @__PURE__ */ jsx52("span", {
@@ -13848,7 +13855,7 @@ function VoiceBarFrame({
13848
13855
  }),
13849
13856
  bannerActive && !chatOpen && !isCapturingSpeech && !planCardActive && /* @__PURE__ */ jsx52(VoiceBarNotification, {
13850
13857
  notifications,
13851
- pos,
13858
+ pos: effectivePos,
13852
13859
  onDismiss: closeBanner
13853
13860
  }),
13854
13861
  /* @__PURE__ */ jsxs41("div", {
@@ -14548,9 +14555,8 @@ function VoiceBar({ revealed }) {
14548
14555
  if (isPanelOpen && splashSurfaces.panel) {
14549
14556
  return null;
14550
14557
  }
14551
- const effectiveBarPos = barPos ?? defaultBarPos();
14552
14558
  return /* @__PURE__ */ jsx55(VoiceBarFrame, {
14553
- pos: effectiveBarPos,
14559
+ pos: barPos,
14554
14560
  canFold,
14555
14561
  notifications,
14556
14562
  onDrop: setBarPos,
@@ -14922,7 +14928,7 @@ function LiveAgent(props) {
14922
14928
  const syncBarToViewport = () => {
14923
14929
  const ratios = barPosRatioRef.current;
14924
14930
  const measured = voiceBarRef.current?.getBoundingClientRect().width;
14925
- setBarPosState(ratios === null ? defaultBarPos() : clampBarPos({
14931
+ setBarPosState(ratios === null ? null : clampBarPos({
14926
14932
  x: ratios.xRatio * window.innerWidth,
14927
14933
  y: ratios.yRatio * window.innerHeight
14928
14934
  }, measured || VOICE_BAR_WIDTH_PX));