@lvce-editor/preview-sandbox-worker 4.15.0 → 4.15.1
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.
|
@@ -721,14 +721,14 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
721
721
|
}
|
|
722
722
|
throw new JsonRpcError('unexpected response message');
|
|
723
723
|
};
|
|
724
|
-
const warn = (...args) => {
|
|
724
|
+
const warn$1 = (...args) => {
|
|
725
725
|
console.warn(...args);
|
|
726
726
|
};
|
|
727
727
|
const resolve = (id, response) => {
|
|
728
728
|
const fn = get$3(id);
|
|
729
729
|
if (!fn) {
|
|
730
730
|
console.log(response);
|
|
731
|
-
warn(`callback ${id} may already be disposed`);
|
|
731
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
732
732
|
return;
|
|
733
733
|
}
|
|
734
734
|
fn(response);
|
|
@@ -1417,6 +1417,21 @@ const getRect = (uid, hdId) => {
|
|
|
1417
1417
|
};
|
|
1418
1418
|
};
|
|
1419
1419
|
|
|
1420
|
+
const send = async (command, ...args) => {
|
|
1421
|
+
try {
|
|
1422
|
+
await invoke$1(command, ...args);
|
|
1423
|
+
} catch {
|
|
1424
|
+
// Logging must not break preview rendering when its output transport is unavailable.
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
const warn = message => {
|
|
1428
|
+
console.warn(message);
|
|
1429
|
+
void send('Preview.logWarning', message);
|
|
1430
|
+
};
|
|
1431
|
+
const clear$1 = () => {
|
|
1432
|
+
return send('Preview.clearOutput');
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1420
1435
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
1421
1436
|
|
|
1422
1437
|
const callBacks = Object.create(null);
|
|
@@ -1439,7 +1454,7 @@ const executeCallback = (id, ...args) => {
|
|
|
1439
1454
|
callback(args);
|
|
1440
1455
|
delete callBacks[id];
|
|
1441
1456
|
} else {
|
|
1442
|
-
|
|
1457
|
+
warn(`[preview-sandbox-worker] No callback found for id ${id}`);
|
|
1443
1458
|
}
|
|
1444
1459
|
};
|
|
1445
1460
|
const getOffscreenCanvas = async (uid, width, height) => {
|
|
@@ -2507,6 +2522,7 @@ const handle = async (uid, error) => {
|
|
|
2507
2522
|
const enabled = await get('preview.clearConsoleOnErrorResolved');
|
|
2508
2523
|
if (enabled === true) {
|
|
2509
2524
|
workerConsole$1.clear();
|
|
2525
|
+
await clear$1();
|
|
2510
2526
|
}
|
|
2511
2527
|
};
|
|
2512
2528
|
|
|
@@ -90398,14 +90414,19 @@ const createConsole = uid => {
|
|
|
90398
90414
|
const runtimeConsole = Object.create(console);
|
|
90399
90415
|
for (const level of consoleLevels) {
|
|
90400
90416
|
runtimeConsole[level] = (...values) => {
|
|
90417
|
+
const message = getMessage(values);
|
|
90401
90418
|
add(uid, {
|
|
90402
90419
|
level,
|
|
90403
|
-
message
|
|
90420
|
+
message,
|
|
90404
90421
|
type: 'console'
|
|
90405
90422
|
});
|
|
90406
90423
|
if (level === 'error' && values.length === 1 && values[0] instanceof Error) {
|
|
90407
90424
|
pendingConsoleErrors.set(uid, values[0]);
|
|
90408
90425
|
}
|
|
90426
|
+
if (level === 'warn') {
|
|
90427
|
+
warn(message);
|
|
90428
|
+
return;
|
|
90429
|
+
}
|
|
90409
90430
|
workerConsole[level](...values);
|
|
90410
90431
|
};
|
|
90411
90432
|
}
|
|
@@ -90970,7 +90991,8 @@ const loadContent = async (uid, width, height, content, scripts) => {
|
|
|
90970
90991
|
errorMessage
|
|
90971
90992
|
} = await updateContent(uid, width, height, content, scripts);
|
|
90972
90993
|
if (error) {
|
|
90973
|
-
|
|
90994
|
+
const formattedCodeFrame = codeFrame ? `\n${codeFrame}` : '';
|
|
90995
|
+
warn(`preview error: ${error}${formattedCodeFrame}`);
|
|
90974
90996
|
}
|
|
90975
90997
|
await handle(uid, error);
|
|
90976
90998
|
return {
|