@wexio/messenger-widget-react 1.5.2 → 1.5.3
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 +6 -0
- package/dist/widget-react.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/widget-react.js
CHANGED
|
@@ -82,7 +82,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
82
82
|
themeModeEditable
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
`;function An(e){return F(kn,{...Tn,...e})}function $(e){if(e instanceof HTMLElement&&(e.hasAttribute(`data-wx-peek`)||e.hasAttribute(`data-wx-popup`)))return{left:e.offsetLeft,top:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight};let t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}var jn=[`fab`,`peek`,`popup`],Mn=new Map;function Nn(e,t){return Mn.set(e,t),()=>{Mn.get(e)===t&&Mn.delete(e)}}var Pn={fab:e=>e?Nn(`fab`,e):void 0,peek:e=>e?Nn(`peek`,e):void 0,popup:e=>e?Nn(`popup`,e):void 0};function Fn(e){return Mn.get(e)??null}function In(){let e=[];for(let t of jn){let n=Mn.get(t);n&&e.push($(n))}return e}function Ln({onRetry:e}){let n=t(`chunkError`);return Z(`div`,{role:`status`,className:`text-wx-fg-muted flex items-center gap-2 p-3 text-xs`,children:[X(`span`,{children:n(`failed`)}),X(`button`,{type:`button`,onClick:e,className:`text-wx-primary rounded-wx-sm font-medium underline underline-offset-2`,children:n(`retry`)})]})}var Rn=[800,2400],zn=/failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed|loading (css )?chunk|failed to fetch|load failed|networkerror/i;function Bn(e){return e instanceof Error?e.name===`ChunkLoadError`||zn.test(e.message):!1}var Vn=/(?:failed to fetch|error loading) dynamically imported module:\s*(\S+)/i;function Hn(e){return e instanceof Error?Vn.exec(e.message)?.[1]??null:null}function Un(e,t){let n=e.replace(/([?&])wexio-retry=[\w-]+&?/,`$1`).replace(/[?&]$/,``);return`${n}${n.includes(`?`)?`&`:`?`}wexio-retry=${t}`}function Wn(){let e=Error(`Failed to load the chunk: the module does not have the expected export`);return e.name=`ChunkLoadError`,e}async function Gn(e,t=Rn,n,r=()=>!0){let i=async()=>{let t=await e();if(!r(t))throw Wn();return t},a=i;for(let e=0;;e++)try{return await a()}catch(o){let s=t[e];if(s===void 0||!Bn(o))throw o;let c=n?Hn(o):null,l=e+1;c&&n&&(a=async()=>{let e=await n(c,l);return r(e)?e:i()}),await new Promise(e=>setTimeout(e,s))}}function Kn(e,t){return import(Un(e,`${Date.now().toString(36)}-${t}`))}function qn(e){return typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e}var Jn=e=>{try{return e()}catch{return}},Yn=new WeakSet;function Xn(e,t,n={}){let r=n.retryDelays??Rn,i=n.pick??(e=>e.default),a=()=>{let n={failed:!1,Loaded:It(async()=>{try{return{default:i(await Gn(t,r,(e,t)=>Kn(e,t),e=>qn(Jn(()=>i(e)))))}}catch(t){let r=t instanceof Error?t:Error(String(t));throw n.failed=!0,Yn.add(r),Bn(r)?console.warn(`[wexio] the "${e}" chunk failed to load; that feature is unavailable until it is retried`,r):console.error(`[wexio] the "${e}" chunk threw while loading`,r),r}})};return n},o=a(),s=()=>{o.failed&&(o=a())};return function(e){let[t,n]=Y(0),r=o.Loaded;return X(Zn,{onRetry:()=>{s(),n(e=>e+1)},children:X(r,{...e})},t)}}var Zn=class extends Mt{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){let{error:e}=this.state;if(!e)return this.props.children;if(!Yn.has(e))throw e;return X(Ln,{onRetry:this.props.onRetry})}};function Qn(e,t,n){return{width:e+n.marginX+64,height:t+n.marginY+32}}function $n(e,t,n=800){let r=performance.now(),i=0,a=!1,o=()=>{if(a)return;let s=e();if(!s||Number(getComputedStyle(s).opacity)<=.01||performance.now()-r>=n){t();return}i=requestAnimationFrame(o)};return i=requestAnimationFrame(o),()=>{a=!0,cancelAnimationFrame(i)}}function er(e){return e===`image/gif`?`[GIF]`:e.startsWith(`image/`)?`[Image]`:e.startsWith(`video/`)?`[Video]`:e.startsWith(`audio/`)?`[Audio]`:e===`application/pdf`?`[PDF]`:`[File]`}function tr(e){if(!e)return``;try{return(new DOMParser().parseFromString(e,`text/html`).body.textContent??``).replace(/\s+/g,` `).trim()}catch{return e.replace(/<[^>]*>/g,` `).replace(/\s+/g,` `).trim()}}function nr(e,t){let n=e.sender.kind;return n===`visitor`?t.visitorLabel:n===`ai`||n===`bot`?t.aiName:e.sender.name?.trim()||t.t(`operator`)}function rr(e){let t=(e.media??[]).map(e=>er(e.mimetype)),n=tr(e.text??``);return[...t,n].filter(Boolean).join(` `)}function ir(e,t,n){return new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,timeZone:n}).format(e)}function ar(e,t,n){let r=new Intl.DateTimeFormat(t,{dateStyle:`long`,timeStyle:`short`,timeZone:n}).format(e),i=or(e,t,n);return i?`${r} ${i}`:r}function or(e,t,n){let r=r=>{try{return new Intl.DateTimeFormat(t,{timeZone:n,timeZoneName:r}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``}catch{return``}},i=r(`long`),a=r(`longOffset`)||r(`shortOffset`);return i&&a?`${i} (${a})`:i||a}function sr(e,t){let{orgName:n,locale:r,timeZone:i,t:a}=t,o=t.now??new Date,s=e.map(e=>{let n=rr(e);if(!n)return null;let a=e.createdAt?new Date(e.createdAt):null;return`${a&&!Number.isNaN(a.getTime())?ir(a,r,i):``} | ${nr(e,t)}: ${n}`.replace(/^ \| /,``)}).filter(e=>e!==null),c=e.find(e=>e.createdAt)?.createdAt,l=c?new Date(c):o,u=[a(`title`,{org:n}),a(`started`,{when:ar(l,r,i)})].join(`
|
|
85
|
+
`;function An(e){return F(kn,{...Tn,...e})}function $(e){if(e instanceof HTMLElement&&(e.hasAttribute(`data-wx-peek`)||e.hasAttribute(`data-wx-popup`)))return{left:e.offsetLeft,top:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight};let t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}var jn=[`fab`,`peek`,`popup`],Mn=new Map;function Nn(e,t){return Mn.set(e,t),()=>{Mn.get(e)===t&&Mn.delete(e)}}var Pn={fab:e=>e?Nn(`fab`,e):void 0,peek:e=>e?Nn(`peek`,e):void 0,popup:e=>e?Nn(`popup`,e):void 0};function Fn(e){return Mn.get(e)??null}function In(){let e=[];for(let t of jn){let n=Mn.get(t);n&&e.push($(n))}return e}function Ln({onRetry:e}){let n=t(`chunkError`);return Z(`div`,{role:`status`,className:`text-wx-fg-muted flex items-center gap-2 p-3 text-xs`,children:[X(`span`,{children:n(`failed`)}),X(`button`,{type:`button`,onClick:e,className:`text-wx-primary rounded-wx-sm font-medium underline underline-offset-2`,children:n(`retry`)})]})}var Rn=[800,2400],zn=/failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed|loading (css )?chunk|failed to fetch|load failed|networkerror/i;function Bn(e){return e instanceof Error?e.name===`ChunkLoadError`||zn.test(e.message):!1}var Vn=/(?:failed to fetch|error loading) dynamically imported module:\s*(\S+)/i;function Hn(e){return e instanceof Error?Vn.exec(e.message)?.[1]??null:null}function Un(e,t){let n=e.replace(/([?&])wexio-retry=[\w-]+&?/,`$1`).replace(/[?&]$/,``);return`${n}${n.includes(`?`)?`&`:`?`}wexio-retry=${t}`}function Wn(){let e=Error(`Failed to load the chunk: the module does not have the expected export`);return e.name=`ChunkLoadError`,e}async function Gn(e,t=Rn,n,r=()=>!0){let i=async()=>{let t=await e();if(!r(t))throw Wn();return t},a=i;for(let e=0;;e++)try{return await a()}catch(o){let s=t[e];if(s===void 0||!Bn(o))throw o;let c=n?Hn(o):null,l=e+1;c&&n&&(a=async()=>{let e=await n(c,l);return r(e)?e:i()}),await new Promise(e=>setTimeout(e,s))}}function Kn(e,t){return import(/* webpackIgnore: true */ /* turbopackIgnore: true */ Un(e,`${Date.now().toString(36)}-${t}`))}function qn(e){return typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e}var Jn=e=>{try{return e()}catch{return}},Yn=new WeakSet;function Xn(e,t,n={}){let r=n.retryDelays??Rn,i=n.pick??(e=>e.default),a=()=>{let n={failed:!1,Loaded:It(async()=>{try{return{default:i(await Gn(t,r,(e,t)=>Kn(e,t),e=>qn(Jn(()=>i(e)))))}}catch(t){let r=t instanceof Error?t:Error(String(t));throw n.failed=!0,Yn.add(r),Bn(r)?console.warn(`[wexio] the "${e}" chunk failed to load; that feature is unavailable until it is retried`,r):console.error(`[wexio] the "${e}" chunk threw while loading`,r),r}})};return n},o=a(),s=()=>{o.failed&&(o=a())};return function(e){let[t,n]=Y(0),r=o.Loaded;return X(Zn,{onRetry:()=>{s(),n(e=>e+1)},children:X(r,{...e})},t)}}var Zn=class extends Mt{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){let{error:e}=this.state;if(!e)return this.props.children;if(!Yn.has(e))throw e;return X(Ln,{onRetry:this.props.onRetry})}};function Qn(e,t,n){return{width:e+n.marginX+64,height:t+n.marginY+32}}function $n(e,t,n=800){let r=performance.now(),i=0,a=!1,o=()=>{if(a)return;let s=e();if(!s||Number(getComputedStyle(s).opacity)<=.01||performance.now()-r>=n){t();return}i=requestAnimationFrame(o)};return i=requestAnimationFrame(o),()=>{a=!0,cancelAnimationFrame(i)}}function er(e){return e===`image/gif`?`[GIF]`:e.startsWith(`image/`)?`[Image]`:e.startsWith(`video/`)?`[Video]`:e.startsWith(`audio/`)?`[Audio]`:e===`application/pdf`?`[PDF]`:`[File]`}function tr(e){if(!e)return``;try{return(new DOMParser().parseFromString(e,`text/html`).body.textContent??``).replace(/\s+/g,` `).trim()}catch{return e.replace(/<[^>]*>/g,` `).replace(/\s+/g,` `).trim()}}function nr(e,t){let n=e.sender.kind;return n===`visitor`?t.visitorLabel:n===`ai`||n===`bot`?t.aiName:e.sender.name?.trim()||t.t(`operator`)}function rr(e){let t=(e.media??[]).map(e=>er(e.mimetype)),n=tr(e.text??``);return[...t,n].filter(Boolean).join(` `)}function ir(e,t,n){return new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,timeZone:n}).format(e)}function ar(e,t,n){let r=new Intl.DateTimeFormat(t,{dateStyle:`long`,timeStyle:`short`,timeZone:n}).format(e),i=or(e,t,n);return i?`${r} ${i}`:r}function or(e,t,n){let r=r=>{try{return new Intl.DateTimeFormat(t,{timeZone:n,timeZoneName:r}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``}catch{return``}},i=r(`long`),a=r(`longOffset`)||r(`shortOffset`);return i&&a?`${i} (${a})`:i||a}function sr(e,t){let{orgName:n,locale:r,timeZone:i,t:a}=t,o=t.now??new Date,s=e.map(e=>{let n=rr(e);if(!n)return null;let a=e.createdAt?new Date(e.createdAt):null;return`${a&&!Number.isNaN(a.getTime())?ir(a,r,i):``} | ${nr(e,t)}: ${n}`.replace(/^ \| /,``)}).filter(e=>e!==null),c=e.find(e=>e.createdAt)?.createdAt,l=c?new Date(c):o,u=[a(`title`,{org:n}),a(`started`,{when:ar(l,r,i)})].join(`
|
|
86
86
|
`),d=[...t.truncated?[a(`truncated`)]:[],a(`exported`,{org:n,when:ar(o,r,i)})].join(`
|
|
87
87
|
`);return`${u}\n\n---\n\n${s.join(`
|
|
88
88
|
|
package/package.json
CHANGED