@askly/widget 3.5.0 → 3.6.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/README.md +14 -3
- package/dist/app/AttachmentTray-DG9ZzxdG.js +1 -0
- package/dist/app/{HelpTab-VtqHb4om.js → HelpTab-DuDsWPKO.js} +1 -1
- package/dist/app/VoiceRecorder-BeAFy0kG.js +1 -0
- package/dist/app/{ar-Cb1DoUxu.js → ar-DFWMvo3z.js} +1 -1
- package/dist/app/askly-app.js +1 -1
- package/dist/app/{de-DNVulDoA.js → de-vopt40BM.js} +1 -1
- package/dist/app/{es-DlJKn6Sy.js → es-0UHAEu3-.js} +1 -1
- package/dist/app/{fr-D7gvDP5q.js → fr-BadeuZgE.js} +1 -1
- package/dist/app/{hi-C_VyJEmY.js → hi-B1hMfrIh.js} +1 -1
- package/dist/app/{pt-YcrQpVFp.js → pt-DZsfWggo.js} +1 -1
- package/dist/app/replyStream-B4yzwiVJ.js +1 -0
- package/dist/app/{shared-CbUI7AAU.js → shared-CVNPA8EU.js} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/loader.js +1 -1
- package/dist/types/core/events.d.ts +1 -0
- package/dist/types/core/greeting.d.ts +2 -0
- package/dist/types/core/replyStream.d.ts +15 -0
- package/dist/types/core/sse.d.ts +17 -0
- package/dist/types/i18n/en.d.ts +0 -1
- package/dist/types/realtime.d.ts +2 -5
- package/dist/types/ui/GreetingBubble.d.ts +4 -4
- package/dist/types/ui/MessageList.d.ts +3 -0
- package/dist/widget.js +1 -1
- package/package.json +3 -3
- package/dist/app/AttachmentTray-V6_MacwL.js +0 -1
- package/dist/app/VoiceRecorder-DfmVzsvl.js +0 -1
package/dist/widget.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","requestHuman","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","requestHuman","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.5.0",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
|
|
1
|
+
!function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","requestHuman","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","requestHuman","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.6.1",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askly/widget",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Embeddable AI support chat widget for React
|
|
3
|
+
"version": "3.6.1",
|
|
4
|
+
"description": "Embeddable AI support chat widget for React — drop-in customer support chatbot with voice, RAG (docs-grounded) answers, and human handoff. One line to install.",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"unpkg": "dist/widget.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"types": "dist/types/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rm -rf dist && rollup -c rollup.config.mjs && npm run build:react",
|
|
12
|
-
"test": "tsc src/markdown.ts --outDir test/.build --module commonjs --target es2019 --strict --skipLibCheck && node --test test/markdown.test.cjs",
|
|
12
|
+
"test": "tsc src/markdown.ts src/core/sse.ts src/core/replyStream.ts --rootDir src --lib es2020,dom --outDir test/.build --module commonjs --target es2019 --strict --skipLibCheck && node --test test/markdown.test.cjs test/sse.test.cjs",
|
|
13
13
|
"typecheck": "tsc --noEmit -p .",
|
|
14
14
|
"test:e2e": "playwright test",
|
|
15
15
|
"size": "node scripts/check-size.cjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e,t,v as a,H as r,f as m,P as n,X as c}from"./shared-CbUI7AAU.js";function s({attachments:s,removeAttachment:o}){return e.createElement("ul",{className:"composer-attachments","aria-label":t(1===s.length?"attachments_summary_one":"attachments_summary_other",{count:m(s.length)})},s.map(s=>{const l=s.error?t("too-large"===s.error?"attachment_too_large":"rejected"===s.error?"attachment_rejected":"attachment_failed"):s.url?a(s.size,r()):t("attachment_uploading",{name:s.name,percent:m(s.progress)});return e.createElement("li",{key:s.id,className:"composer-attachment"+(s.error?" failed":s.url?" ready":" uploading")},s.previewUrl?e.createElement("img",{className:"composer-attachment-thumb",src:s.previewUrl,alt:""}):e.createElement("span",{className:"composer-attachment-icon","aria-hidden":"true"},e.createElement(n,{size:14})),e.createElement("span",{className:"composer-attachment-text"},e.createElement("span",{className:"composer-attachment-name"},s.name),e.createElement("span",{className:"composer-attachment-status",role:s.error?"alert":void 0},l)),!s.url&&!s.error&&e.createElement("span",{className:"composer-attachment-bar","aria-hidden":"true"},e.createElement("span",{style:{width:`${s.progress}%`}})),e.createElement("button",{type:"button",className:"composer-attachment-remove",onClick:()=>o(s.id),"aria-label":t("attachment_remove",{name:s.name}),title:t("attachment_remove",{name:s.name})},e.createElement(c,{size:12})))}))}export{s as AttachmentTray};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e,q as t,t as a,b as s,g as n,f as c,X as l}from"./shared-CbUI7AAU.js";function i({phase:i,meterRef:o,maxMs:r,onStop:m,onCancel:v}){const[u,p]=e([]),[d,y]=e(0);t(()=>{if("recording"!==i)return;const e=setInterval(()=>{const{level:e,elapsedMs:t}=o.current;y(t),p(t=>(t.length>=80?t.slice(1):t).concat(e))},100);return()=>clearInterval(e)},[i]);const b="recording"===i,_=r-d,h=Math.max(0,Math.ceil(_/1e3)),k=b&&_<=1e4,E=a("transcribing"===i?"voice_status_transcribing":b?"voice_status_listening":"voice_status_waiting"),g=b&&_<=5e3?`${E} ${s("voice_seconds_left",h)}`:E;return n.createElement("div",{className:`askly-voice ${i}`},n.createElement("button",{type:"button",className:"askly-voice-btn",onClick:v,title:a("voice_cancel"),"aria-label":a("voice_cancel")},n.createElement(l,{size:20})),n.createElement("span",{className:"askly-voice-meter","aria-hidden":"true"},u.map((e,t)=>n.createElement("i",{key:t,style:{height:`${Math.round(2+22*Math.min(1,e))}px`}}))),n.createElement("span",{className:"askly-voice-status",role:"status"},g),k&&n.createElement("span",{className:"askly-voice-time","aria-hidden":"true"},a("voice_countdown",{count:c(h)})),b?n.createElement("button",{type:"button",className:"askly-voice-btn done",onClick:m,title:a("voice_stop"),"aria-label":a("voice_stop")},n.createElement("span",{className:"askly-voice-stop"})):n.createElement("span",{className:"askly-voice-btn done busy","aria-hidden":"true"},n.createElement("span",{className:"askly-voice-spinner"})))}export{i as VoiceRecorder};
|