efficient-storefront-blocks 0.126.3 → 0.126.4
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/CHANGELOG.md +13 -0
- package/dist/index.js +22 -22
- package/dist/render/lib/chat-socket.d.ts +1 -0
- package/dist/render/lib/chat-socket.js +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{API_URL as
|
|
1
|
+
import{API_URL as S}from"./api/index.js";function f(){return(S||(typeof window<"u"?window.location.origin:"")).replace(/^http/,"ws")}const m="efficient-access-token",_="efficient-chat-guest";function h(t,e){const n=`${f()}/ws/chat/?conversation=${encodeURIComponent(t)}`;return e.access?{url:n,protocols:[m,e.access]}:e.guest?{url:n,protocols:[_,e.guest]}:{url:n,protocols:[]}}function O(t,e){return`${f()}/ws/chat/?conversation=${t}&token=${encodeURIComponent(e)}`}const g=new Set(["employee","system"]);function k(t){if(typeof t!="string")return!1;try{const e=JSON.parse(t);return e.type==="chat_event"&&e.event==="message"&&typeof e.payload?.sender_role=="string"&&g.has(e.payload.sender_role)}catch{return!1}}function T({conversationId:t,credential:e,token:n,onFrame:u}){let s=!1,o=null,c,r=3e3;const a=()=>{if(s)return;const{url:l,protocols:p}=e?h(t,e()):{url:O(t,n?.()??""),protocols:[]};o=new WebSocket(l,p),o.onopen=()=>{r=3e3},o.onmessage=i=>u(i.data),o.onclose=()=>{s||(c=setTimeout(a,r),r=Math.min(r*2,3e4))},o.onerror=()=>o?.close()};return a(),()=>{s=!0,c&&clearTimeout(c),o?.close()}}export{m as ACCESS_TOKEN_SUBPROTOCOL,_ as GUEST_TOKEN_SUBPROTOCOL,h as chatSocketTarget,O as chatSocketUrl,k as isOffStreamMessage,T as openChatSocket};
|