dori-side-widget 1.5.9 → 1.5.10
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/assets/{main-D5YZ0MbB.js → main-B61E2ub_.js} +1 -1
- package/dist/assets/main-B61E2ub_.js.br +0 -0
- package/dist/assets/{main-D5YZ0MbB.js.gz → main-B61E2ub_.js.gz} +0 -0
- package/dist/widget.js +1 -1
- package/dist/widget.js.br +0 -0
- package/dist/widget.js.gz +0 -0
- package/package.json +1 -1
- package/dist/assets/main-D5YZ0MbB.js.br +0 -0
|
Binary file
|
|
Binary file
|
package/dist/widget.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={},e={BOT_DATA:"dori_widget_bot_data",CHAT_STATE:"dori_widget_chat_state",MESSAGES:"dori_widget_messages",CURRENT_STEP:"dori_widget_current_step",SESSION_TIMESTAMP:"dori_widget_session_timestamp",FAB_ANIMATION_TIMESTAMP:"dori_widget_fab_animation_timestamp",DORI_THREAD_ID:"dori_thread_id",DORI_SESSION_KEY:"dori_session_key",LOADED_FROM_STORAGE:"dori_loaded_from_storage"};function r(){try{const t="__test__";return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch{return!1}}function o(){r()&&localStorage.setItem(e.LOADED_FROM_STORAGE,"true")}function n(){r()&&localStorage.removeItem(e.LOADED_FROM_STORAGE)}function a(){return!!r()&&"true"===localStorage.getItem(e.LOADED_FROM_STORAGE)}function i(){try{const t=localStorage.getItem(e.SESSION_TIMESTAMP);if(!t)return!1;const r=parseInt(t,10);return Date.now()-r<864e5}catch{return!1}}function s(){if(r())try{Object.values(e).forEach(t=>{localStorage.removeItem(t)})}catch(t){console.error("Error clearing local storage:",t)}}function c(t){if(r())try{t?localStorage.setItem(e.BOT_DATA,JSON.stringify(t)):localStorage.removeItem(e.BOT_DATA)}catch(o){console.error("Error saving bot data:",o)}}function l(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.BOT_DATA);return t?JSON.parse(t):null}catch(t){return console.error("Error loading bot data:",t),null}}function u(t){if(r())try{localStorage.setItem(e.CHAT_STATE,JSON.stringify(t))}catch(o){console.error("Error saving chat state:",o)}}function d(t){if(r())try{const r=t.map(t=>({...t,timestamp:t.timestamp instanceof Date?t.timestamp.toISOString():t.timestamp}));localStorage.setItem(e.MESSAGES,JSON.stringify(r))}catch(o){console.error("Error saving messages:",o)}}function g(){if(!r()||!i())return[];try{const t=localStorage.getItem(e.MESSAGES);return t?JSON.parse(t).map(t=>({...t,timestamp:new Date(t.timestamp)})):[]}catch(t){return console.error("Error loading messages:",t),[]}}function m(t){if(r())try{localStorage.setItem(e.CURRENT_STEP,t)}catch(o){console.error("Error saving current step:",o)}}function f(){if(!r()||!i())return null;try{const t=l(),o=function(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.CHAT_STATE);return t?JSON.parse(t):null}catch(t){return console.error("Error loading chat state:",t),null}}(),n=g(),a=function(){if(!r()||!i())return"welcome";try{return localStorage.getItem(e.CURRENT_STEP)||"welcome"}catch(t){return console.error("Error loading current step:",t),"welcome"}}();return t||n.length>0?{botData:t,chatState:o||{repliedProduct:null,threadId:null,isRequestInProgress:!1},messages:n,currentStep:a,sessionTimestamp:Date.now()}:null}catch(t){return console.error("Error loading session data:",t),null}}function S(){if(console.log("hasValidSession",localStorage),!r()||!i())return!1;try{const t=l(),e=g();return!!(t||e.length>0)}catch{return!1}}function _(){if(r())try{localStorage.setItem(e.SESSION_TIMESTAMP,Date.now().toString())}catch(t){console.error("Error updating session timestamp:",t)}}function h(){if(r())try{localStorage.setItem(e.FAB_ANIMATION_TIMESTAMP,Date.now().toString())}catch(t){console.error("Error saving FAB animation timestamp:",t)}}function E(){const t=function(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.FAB_ANIMATION_TIMESTAMP);return t?parseInt(t,10):null}catch(t){return console.error("Error loading FAB animation timestamp:",t),null}}();return!t||Date.now()-t>=
|
|
1
|
+
const t={},e={BOT_DATA:"dori_widget_bot_data",CHAT_STATE:"dori_widget_chat_state",MESSAGES:"dori_widget_messages",CURRENT_STEP:"dori_widget_current_step",SESSION_TIMESTAMP:"dori_widget_session_timestamp",FAB_ANIMATION_TIMESTAMP:"dori_widget_fab_animation_timestamp",DORI_THREAD_ID:"dori_thread_id",DORI_SESSION_KEY:"dori_session_key",LOADED_FROM_STORAGE:"dori_loaded_from_storage"};function r(){try{const t="__test__";return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch{return!1}}function o(){r()&&localStorage.setItem(e.LOADED_FROM_STORAGE,"true")}function n(){r()&&localStorage.removeItem(e.LOADED_FROM_STORAGE)}function a(){return!!r()&&"true"===localStorage.getItem(e.LOADED_FROM_STORAGE)}function i(){try{const t=localStorage.getItem(e.SESSION_TIMESTAMP);if(!t)return!1;const r=parseInt(t,10);return Date.now()-r<864e5}catch{return!1}}function s(){if(r())try{Object.values(e).forEach(t=>{localStorage.removeItem(t)})}catch(t){console.error("Error clearing local storage:",t)}}function c(t){if(r())try{t?localStorage.setItem(e.BOT_DATA,JSON.stringify(t)):localStorage.removeItem(e.BOT_DATA)}catch(o){console.error("Error saving bot data:",o)}}function l(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.BOT_DATA);return t?JSON.parse(t):null}catch(t){return console.error("Error loading bot data:",t),null}}function u(t){if(r())try{localStorage.setItem(e.CHAT_STATE,JSON.stringify(t))}catch(o){console.error("Error saving chat state:",o)}}function d(t){if(r())try{const r=t.map(t=>({...t,timestamp:t.timestamp instanceof Date?t.timestamp.toISOString():t.timestamp}));localStorage.setItem(e.MESSAGES,JSON.stringify(r))}catch(o){console.error("Error saving messages:",o)}}function g(){if(!r()||!i())return[];try{const t=localStorage.getItem(e.MESSAGES);return t?JSON.parse(t).map(t=>({...t,timestamp:new Date(t.timestamp)})):[]}catch(t){return console.error("Error loading messages:",t),[]}}function m(t){if(r())try{localStorage.setItem(e.CURRENT_STEP,t)}catch(o){console.error("Error saving current step:",o)}}function f(){if(!r()||!i())return null;try{const t=l(),o=function(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.CHAT_STATE);return t?JSON.parse(t):null}catch(t){return console.error("Error loading chat state:",t),null}}(),n=g(),a=function(){if(!r()||!i())return"welcome";try{return localStorage.getItem(e.CURRENT_STEP)||"welcome"}catch(t){return console.error("Error loading current step:",t),"welcome"}}();return t||n.length>0?{botData:t,chatState:o||{repliedProduct:null,threadId:null,isRequestInProgress:!1},messages:n,currentStep:a,sessionTimestamp:Date.now()}:null}catch(t){return console.error("Error loading session data:",t),null}}function S(){if(console.log("hasValidSession",localStorage),!r()||!i())return!1;try{const t=l(),e=g();return!!(t||e.length>0)}catch{return!1}}function _(){if(r())try{localStorage.setItem(e.SESSION_TIMESTAMP,Date.now().toString())}catch(t){console.error("Error updating session timestamp:",t)}}function h(){if(r())try{localStorage.setItem(e.FAB_ANIMATION_TIMESTAMP,Date.now().toString())}catch(t){console.error("Error saving FAB animation timestamp:",t)}}function E(){const t=function(){if(!r()||!i())return null;try{const t=localStorage.getItem(e.FAB_ANIMATION_TIMESTAMP);return t?parseInt(t,10):null}catch(t){return console.error("Error loading FAB animation timestamp:",t),null}}();return!t||Date.now()-t>=1e4}function I(){if(!r())return"";try{let t=localStorage.getItem(e.DORI_SESSION_KEY);return t||(t="dori_session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),localStorage.setItem(e.DORI_SESSION_KEY,t)),t}catch(t){return console.error("Error generating session key:",t),""}}function p(t){if(r()&&t)try{localStorage.setItem(e.DORI_THREAD_ID,t)}catch(o){console.error("Error storing dori thread ID:",o)}}function A(){if(!r())return null;try{return localStorage.getItem(e.DORI_THREAD_ID)}catch(t){return console.error("Error retrieving dori thread ID:",t),null}}function w(t){const e=window?.chatbotData;if("undefined"!=typeof window&&e?.ajaxurl){const r=I();fetch(e.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"dori_store_thread_session",thread_id:t,session_key:r,nonce:e.nonce})}).catch(t=>console.warn("Failed to store thread in WooCommerce session:",t))}}!async function(){try{const t=document.querySelector("script#dori-side-widget"),e=t?.getAttribute("data-sharing-id");if(!e)return void console.warn("[Mori Widget] No sharing ID found");if(S()){const t=l();if(t)return console.log("[Mori Widget] Bot data found in session storage, skipping API call"),void(window.moriBotDataPromise=Promise.resolve(t));console.log("[Mori Widget] Session valid but no bot data in storage, fetching from API")}console.log("[Mori Widget] No valid session, prefetching bot data from API"),window.moriBotDataPromise=(async()=>{console.log("calling bot sharing data from unified js");const t=`https://standardapi.dori.tech/bot-sharing-data/${e}`,r=await fetch(t);if(200!==r.status)throw new Error(`Failed to fetch bot data: ${r.status}`);const o=await r.json();if(o.error)throw new Error(o.error);if(!o.data)throw new Error("No data received from bot sharing API");return o.data})()}catch(t){console.error("[Mori Widget] Error setting up prefetch:",t),window.moriBotDataPromise=Promise.reject(t instanceof Error?t.message:String(t))}}(),async function(){try{const{initializeDoriWidget:e}=await function(e,r,o){let n=Promise.resolve();if(r&&r.length>0){let e=function(t){return Promise.all(t.map(t=>Promise.resolve(t).then(t=>({status:"fulfilled",value:t}),t=>({status:"rejected",reason:t}))))};const a=document.getElementsByTagName("link"),i=document.querySelector("meta[property=csp-nonce]"),s=i?.nonce||i?.getAttribute("nonce");n=e(r.map(e=>{if(e=function(t,e){return new URL(t,e).href}(e,o),e in t)return;t[e]=!0;const r=e.endsWith(".css"),n=r?'[rel="stylesheet"]':"";if(o)for(let t=a.length-1;t>=0;t--){const o=a[t];if(o.href===e&&(!r||"stylesheet"===o.rel))return}else if(document.querySelector(`link[href="${e}"]${n}`))return;const i=document.createElement("link");return i.rel=r?"stylesheet":"modulepreload",r||(i.as="script"),i.crossOrigin="",i.href=e,s&&i.setAttribute("nonce",s),document.head.appendChild(i),r?new Promise((t,r)=>{i.addEventListener("load",t),i.addEventListener("error",()=>r(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function a(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return n.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})}(async()=>{const{initializeDoriWidget:t}=await import("./assets/main-B61E2ub_.js");return{initializeDoriWidget:t}},[],import.meta.url);e()}catch(e){console.error("[Mori Widget] Error initializing widget:",e)}}();export{u as a,d as b,m as c,f as d,s as e,n as f,A as g,S as h,p as i,w as j,a as k,g as l,o as m,I as n,E as o,h as p,c as s,_ as u};
|
package/dist/widget.js.br
CHANGED
|
Binary file
|
package/dist/widget.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|