@metagptx/web-sdk 0.0.66 → 0.0.67-beta.2
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 +104 -55
- package/package.json +2 -2
package/dist/plugins.js
CHANGED
|
@@ -227,13 +227,15 @@ export const total = routesManifest.total;
|
|
|
227
227
|
${r}
|
|
228
228
|
export default routesManifest;
|
|
229
229
|
`}},transform(e,t){let n=t.replace(/\\/g,`/`),i=s.resolve(f,r).replace(/\\/g,`/`);if(n===i&&c){let t=`import "${a}";\n`;return e.includes(a)?null:{code:t+e,map:null}}return null},configureServer(e){let t=s.resolve(f,n);e.watcher.add(t),e.watcher.on(`change`,n=>{if(n===t){let t=e.moduleGraph.getModuleById(d);t&&(e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`}))}})}}}function L(){return`
|
|
230
|
+
import { createHotContext } from '/@vite/client';
|
|
231
|
+
|
|
232
|
+
const hot = createHotContext('/__mgx_vite_error_overlay__.js');
|
|
233
|
+
|
|
230
234
|
if (window.__MGX_VITE_ERROR_OVERLAY_INSTALLED__) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
}
|
|
235
|
+
hot.on('vite:beforeUpdate', function() {
|
|
236
|
+
const overlay = document.getElementById('custom-vite-error-overlay');
|
|
237
|
+
if (overlay) overlay.remove();
|
|
238
|
+
});
|
|
237
239
|
} else {
|
|
238
240
|
window.__MGX_VITE_ERROR_OVERLAY_INSTALLED__ = true;
|
|
239
241
|
|
|
@@ -278,6 +280,91 @@ function onEscape(e) {
|
|
|
278
280
|
if (e.key === 'Escape') removeOverlay();
|
|
279
281
|
}
|
|
280
282
|
|
|
283
|
+
function getErrorLocation(err) {
|
|
284
|
+
if (!err) {
|
|
285
|
+
return '';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const file = err.id || (err.loc && err.loc.file) || '';
|
|
289
|
+
const line = err.loc && typeof err.loc.line === 'number' ? err.loc.line : null;
|
|
290
|
+
const column = err.loc && typeof err.loc.column === 'number' ? err.loc.column : null;
|
|
291
|
+
|
|
292
|
+
if (!file) {
|
|
293
|
+
return '';
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (line === null) {
|
|
297
|
+
return file;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (column === null) {
|
|
301
|
+
return file + ':' + line;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return file + ':' + line + ':' + column;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function getPrimaryMessage(err) {
|
|
308
|
+
const message = err && err.message ? String(err.message) : 'Unknown Vite error';
|
|
309
|
+
const firstLine = message.split(/\\r?\\n/).find(Boolean);
|
|
310
|
+
|
|
311
|
+
return firstLine || 'Unknown Vite error';
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function buildErrorDetails(err) {
|
|
315
|
+
const parts = [];
|
|
316
|
+
const message = err && err.message ? String(err.message).trim() : '';
|
|
317
|
+
const frame = err && err.frame ? String(err.frame).trim() : '';
|
|
318
|
+
|
|
319
|
+
if (message) {
|
|
320
|
+
parts.push(message);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (frame && (!message || !message.includes(frame))) {
|
|
324
|
+
parts.push(frame);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return parts.filter(Boolean).join('\\n\\n');
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function normalizeViteError(payload) {
|
|
331
|
+
const source = payload && (payload.err || payload);
|
|
332
|
+
|
|
333
|
+
if (!source) {
|
|
334
|
+
return {
|
|
335
|
+
message: 'Unknown Vite error',
|
|
336
|
+
frame: '',
|
|
337
|
+
stack: '',
|
|
338
|
+
id: '',
|
|
339
|
+
loc: null,
|
|
340
|
+
plugin: '',
|
|
341
|
+
details: 'Unknown Vite error',
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (typeof source === 'string') {
|
|
346
|
+
return {
|
|
347
|
+
message: source,
|
|
348
|
+
frame: '',
|
|
349
|
+
stack: '',
|
|
350
|
+
id: '',
|
|
351
|
+
loc: null,
|
|
352
|
+
plugin: '',
|
|
353
|
+
details: source,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
message: source.message || 'Unknown Vite error',
|
|
359
|
+
frame: source.frame || '',
|
|
360
|
+
stack: source.stack || '',
|
|
361
|
+
id: source.id || '',
|
|
362
|
+
loc: source.loc || null,
|
|
363
|
+
plugin: source.plugin || '',
|
|
364
|
+
details: buildErrorDetails(source),
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
281
368
|
function postResolveMessage(err) {
|
|
282
369
|
const message = {
|
|
283
370
|
type: 'errorResolve',
|
|
@@ -288,6 +375,9 @@ function postResolveMessage(err) {
|
|
|
288
375
|
frame: err.frame || '',
|
|
289
376
|
id: err.id || '',
|
|
290
377
|
loc: err.loc || null,
|
|
378
|
+
plugin: err.plugin || '',
|
|
379
|
+
details: err.details || buildErrorDetails(err),
|
|
380
|
+
errorType: 'compile',
|
|
291
381
|
},
|
|
292
382
|
};
|
|
293
383
|
|
|
@@ -349,7 +439,7 @@ function createOverlay(err, shouldRequestChatInfo = true) {
|
|
|
349
439
|
'<div style="font-size:14px;line-height:24px;font-weight:400;color:rgba(12,12,12,0.8);text-align:center;">' + getOverlayTitle() + '</div>' +
|
|
350
440
|
|
|
351
441
|
'<div style="display:flex;align-items:flex-start;gap:8px;">' +
|
|
352
|
-
|
|
442
|
+
'<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;">' +
|
|
353
443
|
'<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>' +
|
|
354
444
|
'<span>Reload</span>' +
|
|
355
445
|
'</button>' +
|
|
@@ -395,45 +485,7 @@ function createOverlay(err, shouldRequestChatInfo = true) {
|
|
|
395
485
|
overlayElement = overlay;
|
|
396
486
|
}
|
|
397
487
|
|
|
398
|
-
function normalizeRuntimeError(payload) {
|
|
399
|
-
if (!payload) {
|
|
400
|
-
return { message: 'Unknown runtime error' };
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (payload instanceof Error) {
|
|
404
|
-
return {
|
|
405
|
-
message: payload.message || 'Unknown runtime error',
|
|
406
|
-
frame: payload.stack || '',
|
|
407
|
-
plugin: 'runtime',
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (typeof payload === 'string') {
|
|
412
|
-
return {
|
|
413
|
-
message: payload,
|
|
414
|
-
plugin: 'runtime',
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return {
|
|
419
|
-
message: payload.message || 'Unknown runtime error',
|
|
420
|
-
frame: payload.stack || '',
|
|
421
|
-
plugin: payload.plugin || 'runtime',
|
|
422
|
-
id: payload.id,
|
|
423
|
-
loc: payload.loc,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
window.addEventListener('error', function(event) {
|
|
428
|
-
const error = event.error || new Error(event.message || 'Unknown runtime error');
|
|
429
|
-
createOverlay(normalizeRuntimeError(error));
|
|
430
|
-
}, true);
|
|
431
|
-
|
|
432
|
-
window.addEventListener('unhandledrejection', function(event) {
|
|
433
|
-
createOverlay(normalizeRuntimeError(event.reason));
|
|
434
|
-
});
|
|
435
488
|
window.addEventListener('message', function(event) {
|
|
436
|
-
console.log('event',event)
|
|
437
489
|
const payload = event.data;
|
|
438
490
|
if (!payload || payload.type !== 'chat_info' || !payload.data) {
|
|
439
491
|
return;
|
|
@@ -451,15 +503,12 @@ window.addEventListener('message', function(event) {
|
|
|
451
503
|
}
|
|
452
504
|
});
|
|
453
505
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
createOverlay(err || { message: 'Unknown Vite error' });
|
|
458
|
-
});
|
|
506
|
+
hot.on('vite:error', function(data) {
|
|
507
|
+
createOverlay(normalizeViteError(data));
|
|
508
|
+
});
|
|
459
509
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
510
|
+
hot.on('vite:beforeUpdate', function() {
|
|
511
|
+
removeOverlay();
|
|
512
|
+
});
|
|
464
513
|
}
|
|
465
|
-
`}function R(){return{name:`vite-plugin-error`,apply:`serve`,config(){return{server:{hmr:{overlay:!1}}}},transformIndexHtml(){return[{tag:`script`,attrs:{type:`module`},children:L(),injectTo:`
|
|
514
|
+
`}function R(){return{name:`vite-plugin-error`,apply:`serve`,config(){return{server:{hmr:{overlay:!1}}}},transformIndexHtml(){return[{tag:`script`,attrs:{type:`module`},children:L(),injectTo:`head-prepend`}]}}}function z(e={}){let{404:t={},error:n={},routes:r={}}=e,{enable:i=!0}=t,{enable:a=!0}=n,{enable:o=!0,...s}=r,c=[];return a&&c.push(R()),i&&c.push(P()),o&&c.push(I(s)),c}export{z as atoms,R as vitePluginError};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metagptx/web-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.67-beta.2",
|
|
5
5
|
"description": "TypeScript SDK for interacting with FuncSea API",
|
|
6
6
|
"author": "MetaGPTX",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "vitest run",
|
|
37
37
|
"test:coverage": "vitest --coverage run",
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"release": "bumpp && npm publish",
|
|
39
|
+
"release": "bumpp && npm publish --tag beta",
|
|
40
40
|
"lint": "eslint",
|
|
41
41
|
"lint:fix": "eslint --fix",
|
|
42
42
|
"precommit": "npm run typecheck && lint-staged && npm run test:coverage",
|