@metagptx/web-sdk 0.0.63 → 0.0.65
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/index.js +1 -1
- package/dist/plugins.js +31 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import e from"axios";import t from"qs";const n=e=>{let t=e.response?.status;if(t&&t>=400&&t!==401)try{typeof window<`u`&&window.top&&window.top?.postMessage({type:`mgx-appview-error`,targetName:window.name,data:{errMsg:e.response?.data?.message||e.response?.data?.detail||`Server Error`,stack:JSON.stringify({url:e.response?.config?.url,data:e.response?.data,status:e.response?.status})}},`*`)}catch(e){console.warn(`Failed to notify parent window about API error:`,e)}},r=(r={})=>{let{onUnauthorized:i,...a}=r,o=typeof globalThis<`u`&&`localStorage`in globalThis&&typeof globalThis.localStorage?.getItem==`function`?globalThis.localStorage.getItem(`token`)??void 0:void 0,s={timeout:6e4,paramsSerializer:e=>t.stringify(e,{arrayFormat:`brackets`}),...a,headers:{"Content-Type":`application/json`,"App-Host":globalThis?.window?.location?.origin??``,...o?{Authorization:`Bearer ${o}`}:{},...a.headers}},c=e.create(s);return c.interceptors.request.use(e=>e,e=>Promise.reject(e)),c.interceptors.response.use(e=>e,e=>{let t=e.response?.status;return t===401&&i&&i(),n(e),Promise.reject(e)}),c},i=[`stripe.com`],a=e=>typeof e==`string`?e.startsWith(`_`)||e.startsWith(`$`)||e===`constructor`||e===`toString`||e===`valueOf`||e===`inspect`||e===`toJSON`:!0,o=()=>{let e=window.location?.href??``,t=``;e.startsWith(`/`)?t=e:e&&(t=e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]+/i,``));let n=new URLSearchParams({from_url:t});window.location.href=`/api/v1/auth/login?${n.toString()}`},s=()=>globalThis?.window?.name?.includes(`devIframe`),c=e=>e?i.some(t=>e.toString().includes(t)):!1,l=e=>{let{requestInstance:t}=e;return{async login(){let e=new URLSearchParams(window.location.search),t=e.get(`token`);t&&typeof globalThis<`u`&&`localStorage`in globalThis?(globalThis.localStorage?.setItem(`token`,t),globalThis.localStorage?.setItem(`isLougOutManual`,`false`),window.location.href=`/`):setTimeout(()=>{o()})},async me(){return t.get(`/api/v1/auth/me`)},async logout(){typeof globalThis<`u`&&`localStorage`in globalThis&&(globalThis.localStorage?.removeItem(`token`),globalThis.localStorage?.setItem(`isLougOutManual`,`true`));let e=await t.get(`/api/v1/auth/logout`);return typeof globalThis<`u`&&`window`in globalThis&&(globalThis.window.opener=null),window.location.href=`/`,e},toLogin:o}},u=e=>{let{requestInstance:t,entityName:n}=e,r=`/api/v1/entities/${n}`,i=e=>{if(!e)return;let t={...e};return e.fields&&Array.isArray(e.fields)&&(t.fields=e.fields.join(`,`)),e.query&&typeof e.query==`object`&&(t.query=JSON.stringify(e.query)),t};return{async query(e){let n=i(e);return t.get(r,{params:n})},async queryAll(e){let n=i(e);return t.get(`${r}/all`,{params:n})},async get(e){let{id:n,...a}=e,o=i(a);return t.get(`${r}/${n}`,{params:o})},async create(e){return t.post(r,e.data)},async update(e){return t.put(`${r}/${e.id}`,e.data)},async delete(e){return t.delete(`${r}/${e.id}`)},async deleteBatch(e){return t.delete(`${r}/batch`,{data:{ids:e.ids}})},async createBatch(e){return t.post(`${r}/batch`,e.data)},async updateBatch(e){return t.put(`${r}/batch`,e.data)}}},d=e=>{let{requestInstance:t}=e,n=new Map;return new Proxy({},{get(e,r){if(!a(r))return n.has(r)||n.set(r,u({requestInstance:t,entityName:r})),n.get(r)}})},f=e=>{let{requestInstance:t}=e;return{async invoke(e){let{url:n,method:r=`GET`,data:i,options:a={}}=e;if(typeof window<`u`&&a?.responseType===`stream`){let e;try{typeof globalThis<`u`&&`localStorage`in globalThis&&typeof globalThis.localStorage?.getItem==`function`&&(e=globalThis.localStorage.getItem(`token`)??void 0)}catch{}let t={"Content-Type":`application/json`,"App-Host":globalThis?.window?.location?.origin??``,...e?{Authorization:`Bearer ${e}`}:{},...a.headers||{}},o;i&&[`POST`,`PUT`,`PATCH`].includes(r.toUpperCase())&&(o=JSON.stringify(i));let s=await fetch(n,{method:r.toUpperCase(),headers:t,body:o});return s}let o={method:r.toUpperCase(),url:n,...a};return i&&[`POST`,`PUT`,`PATCH`].includes(o.method)?o.data=i:i&&[`GET`,`DELETE`].includes(o.method)&&(o.params=i),t.request(o)}}},p=e=>{let{requestInstance:t}=e;return new Proxy({},{get(e,n){if(!a(n))return new Proxy({},{get(e,r){if(!a(r))return(e={})=>{let i=`/api/integrations/core/${r}`;n!==`core`&&(i=`/api/integrations/providers/${n}/${r}`);let{payload:a={},option:o={}}=e,s=a instanceof FormData?{...o,headers:{...o.headers,"Content-Type":void 0}}:o;return t.post(i,a,s)}}})}})};let m=null;const h=e=>{if(m)return;let{requestInstance:t}=e,n=async e=>{let n=globalThis?.localStorage?.getItem(`token`);if(n)return;let r=e.token,i=await t.post(`/api/v1/auth/token/exchange`,{platform_token:r});i.status===200&&i.data.token&&(globalThis?.localStorage?.setItem(`token`,i.data.token),window.location.href=`/`)},r=e=>{switch(e.data.type){case`mgx-token-saved`:n(e.data.data);break;default:break}};m={requestInstance:t,handleMessage:r},globalThis?.window?.addEventListener(`message`,r)},g=()=>{let e=(e,t,n,r)=>{if(globalThis?.window===void 0||!globalThis?.window?.top){console.warn(`postMessage: window.top is not available`);return}try{let{targetOrigin:i=`*`,targetName:a=globalThis?.window?.name??``}=n||{},o={type:e,targetName:a,data:t};(r??globalThis?.window?.top)?.postMessage(o,i)}catch(e){console.warn(`Failed to send postMessage:`,e)}};return{postMessage:e}};let _=!1;const v=e=>{h(e);let{postMessage:t}=g(),n=()=>{if(_)return;_=!0;let e=globalThis?.localStorage?.getItem(`token`),n=globalThis?.localStorage?.getItem(`isLougOutManual`)===`true`,r=window.self!==window.top&&window.name?.includes(`devIframe`);!e&&!n&&r&&(t(`mgx-token-request`,{domain:globalThis?.window?.location?.href??``},{},globalThis?.window?.opener),t(`mgx-token-request`,{domain:globalThis?.window?.location?.href??``}))};return n(),{createPage(e){let{path:n,prompt:r}=e;t(`mgx-create-page`,{path:n??globalThis?.window?.location?.pathname??``,prompt:r})}}},y=()=>{let{postMessage:e}=g(),t=t=>{if(t){if(globalThis?.window===void 0){console.warn(`openUrl: window is not available`);return}if(c(t)&&s()){e(`mgx-open-url`,{url:t.toString()},{},globalThis?.window?.opener);return}globalThis.window.location.href=t.toString()}};return{openUrl:t}},b=e=>{let{requestInstance:t}=e;async function n(e,t,n,r){let i=e.body?.getReader();if(!i){let e=Error(`Response body is not readable`);throw r?.(e),e}let a=new TextDecoder,o=``,s=``;try{for(;;){let{done:e,value:n}=await i.read();if(e)break;s+=a.decode(n,{stream:!0});let c=s.split(`
|
|
2
|
-
`);s=c.pop()||``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=e.slice(6).trim();if(n===`[DONE]`)continue;try{let e=JSON.parse(n);if(e.content?.startsWith(`[ERROR]`)){let t=Error(e.content);throw r?.(t),t}e.content&&(o+=e.content,t?.({content:e.content}))}catch(e){if(e.message?.startsWith(`[ERROR]`))throw e}}}if(s.startsWith(`data: `)){let e=s.slice(6).trim();if(e!==`[DONE]`)try{let n=JSON.parse(e);if(n.content?.startsWith(`[ERROR]`)){let e=Error(n.content);throw r?.(e),e}n.content&&(o+=n.content,t?.({content:n.content}))}catch(e){if(e.message?.startsWith(`[ERROR]`))throw e}}let e={content:o};return n?.(e),e}catch(e){throw e instanceof Error&&r?.(e),e}}async function r(e){let{messages:r,model:i,stream:a,timeout:o}=e,s=`/api/v1/aihub/gentxt`,c={messages:r,model:i,stream:a};if(a){let r=e,{onChunk:i,onComplete:a,onError:l}=r;if(typeof window<`u`){let e;try{typeof globalThis<`u`&&`localStorage`in globalThis&&typeof globalThis.localStorage?.getItem==`function`&&(e=globalThis.localStorage.getItem(`token`)??void 0)}catch{}let t={"Content-Type":`application/json`,"App-Host":globalThis?.window?.location?.origin??``,...e?{Authorization:`Bearer ${e}`}:{}},r=new AbortController,u=o?setTimeout(()=>r.abort(),o):void 0;try{let e=await fetch(s,{method:`POST`,headers:t,body:JSON.stringify(c),signal:r.signal});if(u&&clearTimeout(u),!e.ok){let t=Error(`HTTP error! status: ${e.status}`);throw l?.(t),t}return await n(e,i,a,l)}catch(e){throw u&&clearTimeout(u),e instanceof Error&&l?.(e),e}}let u=await t.request({method:`POST`,url:s,data:c,responseType:`stream`,timeout:o});return{content:u.data}}return t.request({method:`POST`,url:s,data:c,timeout:o})}async function i(e,n={}){let{prompt:r,model:i,size:a=`1024x1024`,quality:o=`standard`,n:s=1,image:c}=e,{timeout:l=6e5}=n,u=`/api/v1/aihub/genimg`,d={prompt:r,model:i,size:a,n:s};return c||(d.quality=o),c&&(d.image=c),t.request({method:`POST`,url:u,data:d,timeout:l})}async function a(e,n={}){let{prompt:r,model:i,size:a=`1280x720`,seconds:o=`
|
|
2
|
+
`);s=c.pop()||``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=e.slice(6).trim();if(n===`[DONE]`)continue;try{let e=JSON.parse(n);if(e.content?.startsWith(`[ERROR]`)){let t=Error(e.content);throw r?.(t),t}e.content&&(o+=e.content,t?.({content:e.content}))}catch(e){if(e.message?.startsWith(`[ERROR]`))throw e}}}if(s.startsWith(`data: `)){let e=s.slice(6).trim();if(e!==`[DONE]`)try{let n=JSON.parse(e);if(n.content?.startsWith(`[ERROR]`)){let e=Error(n.content);throw r?.(e),e}n.content&&(o+=n.content,t?.({content:n.content}))}catch(e){if(e.message?.startsWith(`[ERROR]`))throw e}}let e={content:o};return n?.(e),e}catch(e){throw e instanceof Error&&r?.(e),e}}async function r(e){let{messages:r,model:i,stream:a,timeout:o}=e,s=`/api/v1/aihub/gentxt`,c={messages:r,model:i,stream:a};if(a){let r=e,{onChunk:i,onComplete:a,onError:l}=r;if(typeof window<`u`){let e;try{typeof globalThis<`u`&&`localStorage`in globalThis&&typeof globalThis.localStorage?.getItem==`function`&&(e=globalThis.localStorage.getItem(`token`)??void 0)}catch{}let t={"Content-Type":`application/json`,"App-Host":globalThis?.window?.location?.origin??``,...e?{Authorization:`Bearer ${e}`}:{}},r=new AbortController,u=o?setTimeout(()=>r.abort(),o):void 0;try{let e=await fetch(s,{method:`POST`,headers:t,body:JSON.stringify(c),signal:r.signal});if(u&&clearTimeout(u),!e.ok){let t=Error(`HTTP error! status: ${e.status}`);throw l?.(t),t}return await n(e,i,a,l)}catch(e){throw u&&clearTimeout(u),e instanceof Error&&l?.(e),e}}let u=await t.request({method:`POST`,url:s,data:c,responseType:`stream`,timeout:o});return{content:u.data}}return t.request({method:`POST`,url:s,data:c,timeout:o})}async function i(e,n={}){let{prompt:r,model:i,size:a=`1024x1024`,quality:o=`standard`,n:s=1,image:c}=e,{timeout:l=6e5}=n,u=`/api/v1/aihub/genimg`,d={prompt:r,model:i,size:a,n:s};return c||(d.quality=o),c&&(d.image=c),t.request({method:`POST`,url:u,data:d,timeout:l})}async function a(e,n={}){let{prompt:r,model:i,size:a=`1280x720`,seconds:o=`4`,image:s}=e,{timeout:c=6e5}=n,l=`/api/v1/aihub/genvideo`,u={prompt:r,model:i,size:a,seconds:o};return s&&(u.image=s),t.request({method:`POST`,url:l,data:u,timeout:c})}async function o(e,n={}){let{text:r,model:i,gender:a=`female`}=e,{timeout:o=6e4}=n,s=`/api/v1/aihub/genaudio`,c={text:r,model:i,gender:a};return t.request({method:`POST`,url:s,data:c,timeout:o})}async function s(e,n={}){let{audio:r,model:i=`scribe_V2`}=e,{timeout:a=6e4}=n,o=`/api/v1/aihub/transcribe`,s={audio:r,model:i};return t.request({method:`POST`,url:o,data:s,timeout:a})}return{gentxt:r,genimg:i,genvideo:a,genaudio:o,transcribe:s}};function x(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,e&&(n.accept=e),n.onchange=()=>{let e=n.files?.[0]??null;t(e)},n.oncancel=()=>{t(null)};let r=()=>{setTimeout(()=>{n.files?.length||t(null),window.removeEventListener(`focus`,r)},300)};window.addEventListener(`focus`,r),n.click()})}const S=e=>{let{requestInstance:t}=e;async function n(e){return t.request({method:`POST`,url:`/api/v1/storage/create-bucket`,data:e})}async function r(){return t.request({method:`GET`,url:`/api/v1/storage/list-buckets`})}async function i(e){return t.request({method:`GET`,url:`/api/v1/storage/list-objects`,params:e})}async function a(e){return t.request({method:`GET`,url:`/api/v1/storage/get-object-info`,params:e})}async function o(e){return t.request({method:`POST`,url:`/api/v1/storage/rename-object`,data:e})}async function s(e){return t.request({method:`POST`,url:`/api/v1/storage/upload-url`,data:e})}async function c(e){return t.request({method:`POST`,url:`/api/v1/storage/download-url`,data:e})}async function l(e){let{bucket_name:t,accept:n}=e,{file:r,object_key:i}=e;if(!r){if(typeof window>`u`||typeof document>`u`)throw TypeError(`File picker is only available in browser environment. Please provide a file.`);let e=await x(n);if(!e)throw Error(`File selection cancelled`);r=e}i||=r.name;let{data:a}=await s({bucket_name:t,object_key:i}),o=await fetch(a.upload_url,{method:`PUT`,body:r,headers:{"Content-Type":r.type||`application/octet-stream`}});if(!o.ok)throw Error(`Upload failed with status ${o.status}: ${o.statusText}`);return{bucket_name:t,object_key:i,size:r.size,file_name:r.name}}async function u(e){let{data:t}=await c(e);if(typeof window<`u`&&typeof document<`u`){let n=document.createElement(`a`);n.href=t.download_url;let r=e.object_key.split(`/`).pop()||`download`;n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n)}return t.download_url}return{createBucket:n,listBuckets:r,listObjects:i,getObjectInfo:a,renameObject:o,getUploadUrl:s,getDownloadUrl:c,upload:l,download:u}},C=(e={})=>{let t=r({baseURL:`/`,...e}),n=l({requestInstance:t}),i=d({requestInstance:t}),a=f({requestInstance:t}),o=p({requestInstance:t}),s=v({requestInstance:t}),c=y(),u=b({requestInstance:t}),m=S({requestInstance:t});return{auth:n,entities:i,apiCall:a,integrations:o,frame:s,utils:c,ai:u,storage:m}};export{C as createClient};
|
package/dist/plugins.js
CHANGED
|
@@ -239,6 +239,8 @@ if (window.__MGX_VITE_ERROR_OVERLAY_INSTALLED__) {
|
|
|
239
239
|
|
|
240
240
|
let overlayElement = null;
|
|
241
241
|
let cleanupRegistered = false;
|
|
242
|
+
let latestOverlayError = null;
|
|
243
|
+
let chatInfoStatus = 'not_working';
|
|
242
244
|
const mascotImage = 'https://public-frontend-cos.metadl.com/commonfile/engineer.svg';
|
|
243
245
|
const isInMGXIframe = window.self !== window.top && window.name && window.name.includes('devIframe');
|
|
244
246
|
|
|
@@ -264,6 +266,14 @@ function removeOverlay() {
|
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
|
|
269
|
+
function getOverlayTitle() {
|
|
270
|
+
if (chatInfoStatus === 'working') {
|
|
271
|
+
return 'Agent is on the job! Please check back in a bit.';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return 'Something is wrong';
|
|
275
|
+
}
|
|
276
|
+
|
|
267
277
|
function onEscape(e) {
|
|
268
278
|
if (e.key === 'Escape') removeOverlay();
|
|
269
279
|
}
|
|
@@ -296,6 +306,7 @@ function postResolveMessage(err) {
|
|
|
296
306
|
|
|
297
307
|
function createOverlay(err) {
|
|
298
308
|
removeOverlay();
|
|
309
|
+
latestOverlayError = err;
|
|
299
310
|
|
|
300
311
|
const overlay = document.createElement('div');
|
|
301
312
|
overlay.id = 'custom-vite-error-overlay';
|
|
@@ -308,14 +319,14 @@ function createOverlay(err) {
|
|
|
308
319
|
'<img alt="" src="' + mascotImage + '" style="width:80px;height:80px;object-fit:cover;pointer-events:none;" />' +
|
|
309
320
|
'</div>' +
|
|
310
321
|
|
|
311
|
-
'<div style="font-size:14px;line-height:24px;font-weight:400;color:rgba(12,12,12,0.8);text-align:center;">
|
|
312
|
-
|
|
322
|
+
'<div style="font-size:14px;line-height:24px;font-weight:400;color:rgba(12,12,12,0.8);text-align:center;">' + getOverlayTitle() + '</div>' +
|
|
323
|
+
|
|
313
324
|
'<div style="display:flex;align-items:flex-start;gap:8px;">' +
|
|
314
325
|
'<button id="cve-reload" style="display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border:none;border-radius:8px;background:rgba(12,12,12,0.06);color:rgba(12,12,12,0.95);font-size:14px;font-weight:500;line-height:22px;cursor:pointer;">' +
|
|
315
326
|
'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M11.105 5.20813C11.3465 5.20827 11.5425 5.40409 11.5425 5.64563C11.5425 8.78666 8.99598 11.333 5.85498 11.3331C4.11675 11.3331 2.56217 10.5521 1.51929 9.32422V10.1779C1.51929 10.4195 1.32341 10.6154 1.08179 10.6154C0.840163 10.6154 0.644287 10.4195 0.644287 10.1779V8.26892C0.644287 8.0273 0.840163 7.83142 1.08179 7.83142H2.99072C3.23235 7.83142 3.42822 8.0273 3.42822 8.26892C3.42814 8.51048 3.2323 8.70642 2.99072 8.70642H2.14392C3.02711 9.77583 4.36095 10.4581 5.85498 10.4581C8.51273 10.458 10.6675 8.30342 10.6675 5.64563C10.6675 5.40401 10.8634 5.20813 11.105 5.20813Z" fill="#0C0C0C" fill-opacity="0.95"/><path d="M5.6875 0C7.42573 0 8.98031 0.781055 10.0232 2.00891V1.15527C10.0232 0.913649 10.2191 0.717773 10.4607 0.717773C10.7023 0.717773 10.8982 0.913649 10.8982 1.15527V3.06421C10.898 3.30566 10.7022 3.50171 10.4607 3.50171H8.55176C8.31026 3.50171 8.11446 3.30566 8.11426 3.06421C8.11434 2.82265 8.31018 2.62671 8.55176 2.62671H9.39856C8.51537 1.5573 7.18153 0.875 5.6875 0.875C3.02975 0.87514 0.875 3.02971 0.875 5.6875C0.874798 5.92895 0.679 6.125 0.4375 6.125C0.196119 6.12486 0.000202109 5.92887 0 5.6875C0 2.54647 2.5465 0.000140261 5.6875 0Z" fill="#0C0C0C" fill-opacity="0.95"/></svg>' +
|
|
316
327
|
'<span>Reload</span>' +
|
|
317
328
|
'</button>' +
|
|
318
|
-
(isInMGXIframe
|
|
329
|
+
(isInMGXIframe && chatInfoStatus !== 'working'
|
|
319
330
|
? '<button id="cve-resolve" style="display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border:none;border-radius:8px;background:#111111;color:rgba(255,255,255,0.95);font-size:14px;font-weight:500;line-height:22px;cursor:pointer;">' +
|
|
320
331
|
'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M12.4186 3.77422C12.3921 3.70862 12.35 3.65045 12.296 3.60467C12.2421 3.5589 12.1778 3.5269 12.1088 3.51141C12.0397 3.49593 11.968 3.49742 11.8996 3.51576C11.8313 3.5341 11.7684 3.56874 11.7164 3.61672L9.5125 5.65054L8.57023 5.4482L8.36789 4.50593L10.4017 2.30203C10.4497 2.25002 10.4843 2.18714 10.5027 2.1188C10.521 2.05046 10.5225 1.97869 10.507 1.90965C10.4915 1.84061 10.4595 1.77635 10.4138 1.72239C10.368 1.66843 10.3098 1.62638 10.2442 1.59984C9.64645 1.35803 8.99844 1.26673 8.35713 1.33396C7.71581 1.40119 7.10083 1.62489 6.5662 1.98542C6.03158 2.34594 5.59367 2.83224 5.29097 3.4016C4.98827 3.97096 4.83003 4.60595 4.83015 5.25078C4.82945 5.79529 4.94115 6.33409 5.15828 6.83343L1.86554 9.68047C1.85734 9.68703 1.84968 9.69468 1.84203 9.70179C1.5138 10.03 1.32941 10.4752 1.32941 10.9394C1.32941 11.1692 1.37468 11.3968 1.46263 11.6091C1.55059 11.8215 1.67951 12.0144 1.84203 12.177C2.00455 12.3395 2.19749 12.4684 2.40983 12.5563C2.62218 12.6443 2.84977 12.6896 3.07961 12.6896C3.54379 12.6896 3.98896 12.5052 4.31718 12.177C4.32429 12.1698 4.33195 12.1616 4.33851 12.154L7.185 8.86015C7.78461 9.12336 8.4404 9.23287 9.09299 9.17876C9.74559 9.12466 10.3744 8.90865 10.9225 8.55028C11.4705 8.19192 11.9206 7.70253 12.2319 7.1264C12.5431 6.55028 12.7058 5.90562 12.7052 5.25078C12.706 4.74469 12.6087 4.24324 12.4186 3.77422ZM8.76765 8.31328C8.2498 8.31257 7.74054 8.18088 7.28726 7.93047C7.19945 7.88195 7.09762 7.86509 6.99886 7.88272C6.90009 7.90034 6.81038 7.95137 6.74476 8.02726L3.68773 11.5677C3.5223 11.7249 3.30202 11.8112 3.07385 11.8083C2.84569 11.8054 2.62769 11.7134 2.46634 11.5521C2.30499 11.3907 2.21305 11.1727 2.21013 10.9446C2.20721 10.7164 2.29353 10.4961 2.4507 10.3307L5.98843 7.27422C6.06446 7.20857 6.11557 7.11876 6.1332 7.01987C6.15082 6.92098 6.13389 6.81904 6.08523 6.73117C5.80634 6.22675 5.67546 5.65387 5.70763 5.07839C5.7398 4.50291 5.93372 3.94819 6.2671 3.478C6.60047 3.00782 7.05977 2.64125 7.59218 2.42045C8.12459 2.19965 8.70851 2.13359 9.27679 2.22984L7.57054 4.07883C7.52307 4.13033 7.48865 4.19247 7.47019 4.26004C7.45173 4.32761 7.44976 4.39862 7.46445 4.46711L7.77398 5.90703C7.79169 5.98938 7.83279 6.06488 7.89235 6.12444C7.95192 6.184 8.02741 6.22511 8.10976 6.24281L9.55078 6.55234C9.61927 6.56703 9.69028 6.56506 9.75784 6.5466C9.82541 6.52814 9.88756 6.49372 9.93906 6.44625L11.788 4.74C11.8618 5.17914 11.8389 5.62907 11.7211 6.0585C11.6033 6.48792 11.3934 6.88654 11.106 7.22661C10.8185 7.56669 10.4604 7.84006 10.0566 8.02772C9.65279 8.21538 9.21294 8.31283 8.76765 8.31328Z" fill="white" fill-opacity="0.95"/></svg>' +
|
|
321
332
|
'<span>Resolve</span>' +
|
|
@@ -330,10 +341,6 @@ function createOverlay(err) {
|
|
|
330
341
|
const backdrop = overlay.firstElementChild;
|
|
331
342
|
const card = backdrop && backdrop.firstElementChild;
|
|
332
343
|
|
|
333
|
-
if (backdrop) {
|
|
334
|
-
backdrop.addEventListener('click', removeOverlay);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
344
|
if (card) {
|
|
338
345
|
card.addEventListener('click', function(e) {
|
|
339
346
|
e.stopPropagation();
|
|
@@ -397,6 +404,23 @@ window.addEventListener('error', function(event) {
|
|
|
397
404
|
|
|
398
405
|
window.addEventListener('unhandledrejection', function(event) {
|
|
399
406
|
createOverlay(normalizeRuntimeError(event.reason));
|
|
407
|
+
});
|
|
408
|
+
window.addEventListener('message', function(event) {
|
|
409
|
+
const payload = event.data;
|
|
410
|
+
if (!payload || payload.type !== 'chat_info' || !payload.data) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const nextStatus = payload.data.status;
|
|
415
|
+
if (nextStatus !== 'working' && nextStatus !== 'not_working') {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
chatInfoStatus = nextStatus;
|
|
420
|
+
|
|
421
|
+
if (overlayElement && latestOverlayError) {
|
|
422
|
+
createOverlay(latestOverlayError);
|
|
423
|
+
}
|
|
400
424
|
});
|
|
401
425
|
|
|
402
426
|
if (import.meta.hot) {
|