@metagptx/web-sdk 0.0.65 → 0.0.66
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/plugins.js +30 -2
- package/package.json +1 -1
package/dist/plugins.js
CHANGED
|
@@ -304,10 +304,37 @@ function postResolveMessage(err) {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
function
|
|
307
|
+
function requestChatInfo() {
|
|
308
|
+
if (!isInMGXIframe) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const message = {
|
|
313
|
+
type: 'chat_info',
|
|
314
|
+
targetName: window.name || '',
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
if (window.top) {
|
|
319
|
+
window.top.postMessage(message, '*');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (window.opener && window.opener !== window.top) {
|
|
323
|
+
window.opener.postMessage(message, '*');
|
|
324
|
+
}
|
|
325
|
+
} catch (error) {
|
|
326
|
+
console.warn('Failed to request chat_info:', error);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function createOverlay(err, shouldRequestChatInfo = true) {
|
|
308
331
|
removeOverlay();
|
|
309
332
|
latestOverlayError = err;
|
|
310
333
|
|
|
334
|
+
if (shouldRequestChatInfo) {
|
|
335
|
+
requestChatInfo();
|
|
336
|
+
}
|
|
337
|
+
|
|
311
338
|
const overlay = document.createElement('div');
|
|
312
339
|
overlay.id = 'custom-vite-error-overlay';
|
|
313
340
|
|
|
@@ -406,6 +433,7 @@ window.addEventListener('unhandledrejection', function(event) {
|
|
|
406
433
|
createOverlay(normalizeRuntimeError(event.reason));
|
|
407
434
|
});
|
|
408
435
|
window.addEventListener('message', function(event) {
|
|
436
|
+
console.log('event',event)
|
|
409
437
|
const payload = event.data;
|
|
410
438
|
if (!payload || payload.type !== 'chat_info' || !payload.data) {
|
|
411
439
|
return;
|
|
@@ -419,7 +447,7 @@ window.addEventListener('message', function(event) {
|
|
|
419
447
|
chatInfoStatus = nextStatus;
|
|
420
448
|
|
|
421
449
|
if (overlayElement && latestOverlayError) {
|
|
422
|
-
createOverlay(latestOverlayError);
|
|
450
|
+
createOverlay(latestOverlayError, false);
|
|
423
451
|
}
|
|
424
452
|
});
|
|
425
453
|
|