@flowengage/react-chatbot 5.0.28 → 5.0.29

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.
@@ -3241,12 +3241,12 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3241
3241
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Tt.current = !0);
3242
3242
  }
3243
3243
  }, [Pe, _]);
3244
- let zt = p(null);
3244
+ let zt = p(null), Bt = p(!1);
3245
3245
  c(() => {
3246
3246
  let e = k.current;
3247
- !e || !y || zt.current !== C && (C ? e.updateChatStatus(y, "open").catch(() => {}) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
3247
+ !e || !y || zt.current !== C && (C && zt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Bt.current = !0) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
3248
3248
  }, [C, y]), c(() => {
3249
- if (!C || !y) return;
3249
+ if (!C || !y || !Bt.current) return;
3250
3250
  let e = setInterval(() => {
3251
3251
  let e = k.current;
3252
3252
  e && y && e.updateChatStatus(y, "open").catch(() => {});
@@ -3272,7 +3272,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3272
3272
  l,
3273
3273
  kt
3274
3274
  ]);
3275
- let Bt = async () => {
3275
+ let Vt = async () => {
3276
3276
  if (!(!He?.callId || !k.current || !at.current || !y)) {
3277
3277
  jt(), ht.current = He.callId, Mt();
3278
3278
  try {
@@ -3362,7 +3362,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3362
3362
  nt("We couldn't connect the call right now. Please try again.");
3363
3363
  }
3364
3364
  }
3365
- }, Vt = async () => {
3365
+ }, Ht = async () => {
3366
3366
  if (!He?.callId || !k.current || !y) {
3367
3367
  Pt("reject_call_without_server_context");
3368
3368
  return;
@@ -3375,15 +3375,15 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3375
3375
  } finally {
3376
3376
  Pt("reject_call_finally");
3377
3377
  }
3378
- }, Ht = p(Vt);
3379
- Ht.current = Vt, c(() => {
3378
+ }, Ut = p(Ht);
3379
+ Ut.current = Ht, c(() => {
3380
3380
  if (!He?.callId || qe) {
3381
3381
  Mt();
3382
3382
  return;
3383
3383
  }
3384
3384
  let e = He.callId;
3385
3385
  return Mt(), gt.current = window.setTimeout(() => {
3386
- ct.current?.callId === e && ht.current !== e && mt.current !== e && Ht.current();
3386
+ ct.current?.callId === e && ht.current !== e && mt.current !== e && Ut.current();
3387
3387
  }, oe), () => {
3388
3388
  gt.current &&= (window.clearTimeout(gt.current), null);
3389
3389
  };
@@ -3392,7 +3392,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3392
3392
  Mt,
3393
3393
  He?.callId
3394
3394
  ]);
3395
- let Ut = async () => {
3395
+ let Wt = async () => {
3396
3396
  if (!qe || !k.current || !y) {
3397
3397
  Pt("end_call_without_server_context");
3398
3398
  return;
@@ -3405,16 +3405,16 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3405
3405
  } finally {
3406
3406
  Pt("end_call_finally");
3407
3407
  }
3408
- }, Wt = () => {
3408
+ }, Gt = () => {
3409
3409
  let e = ut.current?.getAudioTracks?.() || [], t = lt.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
3410
3410
  if (n.length === 0) return;
3411
3411
  let r = !$e;
3412
3412
  n.forEach((e) => {
3413
3413
  e.enabled = !r;
3414
3414
  }), et(r);
3415
- }, Gt = async (e = {}) => {
3415
+ }, Kt = async (e = {}) => {
3416
3416
  let t = e.notifyChatInitiated === !0;
3417
- if (w(!0), !(!t || !k.current || !y || typeof window > "u")) {
3417
+ if (Bt.current = !0, w(!0), !(!t || !k.current || !y || typeof window > "u")) {
3418
3418
  try {
3419
3419
  await k.current.trackVisitor({
3420
3420
  chatId: y,
@@ -3425,7 +3425,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3425
3425
  await k.current.updateChatStatus(y, "open");
3426
3426
  } catch {}
3427
3427
  }
3428
- }, Kt = async (e) => {
3428
+ }, qt = async (e) => {
3429
3429
  let t = Nt(e);
3430
3430
  if (!t || !k.current || !ot.current) return t;
3431
3431
  try {
@@ -3438,26 +3438,26 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3438
3438
  console.error("[FlowEngageProvider] failed to persist visitor email", e);
3439
3439
  }
3440
3440
  return t;
3441
- }, qt = () => {
3441
+ }, Jt = () => {
3442
3442
  !y || !at.current?.connected || _t.current || (_t.current = !0, at.current.emit("typing:start", {
3443
3443
  chatId: y,
3444
3444
  sender: "user"
3445
3445
  }));
3446
- }, Jt = () => {
3446
+ }, Yt = () => {
3447
3447
  !y || !at.current?.connected || !_t.current || (_t.current = !1, at.current.emit("typing:stop", {
3448
3448
  chatId: y,
3449
3449
  sender: "user"
3450
3450
  }));
3451
- }, Yt = (e = "") => {
3451
+ }, Xt = (e = "") => {
3452
3452
  let t = typeof e == "string" ? e : "";
3453
3453
  !y || !at.current?.connected || t !== "" && vt.current === t || (vt.current = t, at.current.emit("typing:update", {
3454
3454
  chatId: y,
3455
3455
  sender: "user",
3456
3456
  text: t
3457
3457
  }));
3458
- }, Xt = async (e, t = "", n = null, a = {}) => {
3458
+ }, Zt = async (e, t = "", n = null, a = {}) => {
3459
3459
  if (!(typeof e == "string" && e.trim()) || !k.current || !y || l !== "ready" || Be) return;
3460
- Jt();
3460
+ Yt();
3461
3461
  let o = `pending-user-${Date.now()}`, s = {
3462
3462
  id: o,
3463
3463
  sender: "user",
@@ -3516,10 +3516,10 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3516
3516
  je(!1), O("");
3517
3517
  }, ie)) : h(e);
3518
3518
  }
3519
- }, Zt = async (e) => {
3519
+ }, Qt = async (e) => {
3520
3520
  if (!k.current || !e) throw Error("Upload is unavailable right now.");
3521
3521
  return k.current.uploadChatFile(e);
3522
- }, Qt = async (e) => {
3522
+ }, $t = async (e) => {
3523
3523
  if (!(!k.current || !y)) {
3524
3524
  try {
3525
3525
  let t = e ? "voice" : "text";
@@ -3527,7 +3527,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3527
3527
  } catch {}
3528
3528
  Fe(e), e && (Tt.current = !1);
3529
3529
  }
3530
- }, $t = async (e) => {
3530
+ }, en = async (e) => {
3531
3531
  if (Tt.current) return;
3532
3532
  if (Tt.current = !0, !k.current || !y || !e?.length) {
3533
3533
  Fe(!1);
@@ -3556,9 +3556,9 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3556
3556
  } finally {
3557
3557
  Fe(!1);
3558
3558
  }
3559
- }, en = async () => {
3559
+ }, tn = async () => {
3560
3560
  if (!(!k.current || !y)) {
3561
- Pe && !Tt.current && wt.current.length > 0 && await $t(wt.current);
3561
+ Pe && !Tt.current && wt.current.length > 0 && await en(wt.current);
3562
3562
  try {
3563
3563
  await k.current.endConversation(y);
3564
3564
  } catch {
@@ -3578,7 +3578,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3578
3578
  c(() => {
3579
3579
  if (Ye !== "connected" || !qe || !y || !Ze || !At) return;
3580
3580
  let e = new Date(Ze).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, At * 1e3 - t), r = window.setTimeout(() => {
3581
- nt("The call ended because it reached the time limit."), Ut();
3581
+ nt("The call ended because it reached the time limit."), Wt();
3582
3582
  }, n);
3583
3583
  return () => window.clearTimeout(r);
3584
3584
  }, [
@@ -3586,7 +3586,7 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3586
3586
  Ze,
3587
3587
  Ye,
3588
3588
  y,
3589
- Ut,
3589
+ Wt,
3590
3590
  At
3591
3591
  ]), c(() => {
3592
3592
  let e = () => {
@@ -3603,12 +3603,12 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3603
3603
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3604
3604
  };
3605
3605
  }, []);
3606
- let tn = o(() => {
3606
+ let nn = o(() => {
3607
3607
  let e = i?.siteId;
3608
3608
  ge(e), A.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), ot.current = "", Ve(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3609
- }, [i?.siteId]), nn = o((e) => {
3609
+ }, [i?.siteId]), rn = o((e) => {
3610
3610
  i?.siteId, A.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), ot.current = "", Ve(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3611
- }, [i?.siteId]), rn = f(() => ({
3611
+ }, [i?.siteId]), an = f(() => ({
3612
3612
  status: l,
3613
3613
  error: d,
3614
3614
  runtimeConfig: _,
@@ -3642,33 +3642,33 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3642
3642
  historyRef: wt,
3643
3643
  hasSyncedRef: Tt,
3644
3644
  dismissCallError: jt,
3645
- captureVisitorEmail: Kt,
3646
- startTyping: qt,
3647
- stopTyping: Jt,
3648
- updateTypingDraft: Yt,
3645
+ captureVisitorEmail: qt,
3646
+ startTyping: Jt,
3647
+ stopTyping: Yt,
3648
+ updateTypingDraft: Xt,
3649
3649
  notifyRouteChange: () => Ot.current?.notifyRouteChange?.(),
3650
- openWidget: Gt,
3650
+ openWidget: Kt,
3651
3651
  closeWidget: () => w(!1),
3652
3652
  toggleWidget: () => {
3653
3653
  if (C) {
3654
3654
  w(!1);
3655
3655
  return;
3656
3656
  }
3657
- Gt({ notifyChatInitiated: !0 });
3657
+ Kt({ notifyChatInitiated: !0 });
3658
3658
  },
3659
- sendMessage: Xt,
3660
- uploadChatFile: Zt,
3661
- setVoiceMode: Qt,
3662
- onMessageSync: $t,
3663
- endConversation: en,
3664
- startNewChat: tn,
3665
- resumeChat: nn,
3659
+ sendMessage: Zt,
3660
+ uploadChatFile: Qt,
3661
+ setVoiceMode: $t,
3662
+ onMessageSync: en,
3663
+ endConversation: tn,
3664
+ startNewChat: nn,
3665
+ resumeChat: rn,
3666
3666
  getVisitorChatHistory: () => k.current?.getVisitorChatHistory?.(),
3667
3667
  getVisitorChatThread: (e) => k.current?.getVisitorChatThread?.(e),
3668
- acceptCall: Bt,
3669
- rejectCall: Vt,
3670
- endWebRTCCall: Ut,
3671
- toggleCallMute: Wt
3668
+ acceptCall: Vt,
3669
+ rejectCall: Ht,
3670
+ endWebRTCCall: Wt,
3671
+ toggleCallMute: Gt
3672
3672
  }), [
3673
3673
  l,
3674
3674
  d,
@@ -3700,25 +3700,25 @@ function Nr({ siteId: e, config: t, children: n, language: r = "en" }) {
3700
3700
  $e,
3701
3701
  tt,
3702
3702
  r,
3703
- Kt,
3704
3703
  qt,
3705
3704
  Jt,
3706
3705
  Yt,
3707
- Bt,
3706
+ Xt,
3708
3707
  Vt,
3709
- Ut,
3708
+ Ht,
3710
3709
  Wt,
3711
3710
  Gt,
3712
- Xt,
3711
+ Kt,
3713
3712
  Zt,
3714
3713
  Qt,
3715
3714
  $t,
3716
3715
  en,
3717
3716
  tn,
3717
+ nn,
3718
3718
  jt
3719
3719
  ]);
3720
3720
  return /* @__PURE__ */ g(In.Provider, {
3721
- value: rn,
3721
+ value: an,
3722
3722
  children: n
3723
3723
  });
3724
3724
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "5.0.28",
3
+ "version": "5.0.29",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",