@lvce-editor/renderer-process 7.1.0 → 8.0.0
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/rendererProcessMain.js +44 -831
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const BABEL_PARSER_SYNTAX_ERROR = 'BABEL_PARSER_SYNTAX_ERROR';
|
|
2
1
|
const E_COMMAND_NOT_FOUND$1 = 'E_COMMAND_NOT_FOUND';
|
|
3
2
|
|
|
4
3
|
const processName = `renderer process`;
|
|
@@ -271,7 +270,7 @@ let VError$1 = class VError extends Error {
|
|
|
271
270
|
}
|
|
272
271
|
};
|
|
273
272
|
|
|
274
|
-
const state$
|
|
273
|
+
const state$b = {
|
|
275
274
|
commands: Object.create(null),
|
|
276
275
|
pendingModules: Object.create(null),
|
|
277
276
|
async load(moduleId) {}
|
|
@@ -292,7 +291,7 @@ const initializeModule = module => {
|
|
|
292
291
|
};
|
|
293
292
|
const loadModule$1 = async moduleId => {
|
|
294
293
|
try {
|
|
295
|
-
const module = await state$
|
|
294
|
+
const module = await state$b.load(moduleId);
|
|
296
295
|
initializeModule(module);
|
|
297
296
|
} catch (error) {
|
|
298
297
|
if (error && error instanceof SyntaxError && error.stack === `SyntaxError: ${error.message}`) {
|
|
@@ -303,16 +302,16 @@ const loadModule$1 = async moduleId => {
|
|
|
303
302
|
}
|
|
304
303
|
};
|
|
305
304
|
const getOrLoadModule = moduleId => {
|
|
306
|
-
if (!state$
|
|
307
|
-
state$
|
|
305
|
+
if (!state$b.pendingModules[moduleId]) {
|
|
306
|
+
state$b.pendingModules[moduleId] = loadModule$1(moduleId);
|
|
308
307
|
}
|
|
309
|
-
return state$
|
|
308
|
+
return state$b.pendingModules[moduleId];
|
|
310
309
|
};
|
|
311
310
|
const loadCommand = async command => {
|
|
312
311
|
await getOrLoadModule(getModuleId(command));
|
|
313
312
|
};
|
|
314
313
|
const register = (commandId, listener) => {
|
|
315
|
-
state$
|
|
314
|
+
state$b.commands[commandId] = listener;
|
|
316
315
|
};
|
|
317
316
|
const hasThrown = new Set();
|
|
318
317
|
const executeCommandAsync = async (command, ...args) => {
|
|
@@ -321,7 +320,7 @@ const executeCommandAsync = async (command, ...args) => {
|
|
|
321
320
|
} catch (error) {
|
|
322
321
|
throw new VError$1(error, `Failed to load command ${command}`);
|
|
323
322
|
}
|
|
324
|
-
if (!(command in state$
|
|
323
|
+
if (!(command in state$b.commands)) {
|
|
325
324
|
if (hasThrown.has(command)) {
|
|
326
325
|
return;
|
|
327
326
|
}
|
|
@@ -331,8 +330,8 @@ const executeCommandAsync = async (command, ...args) => {
|
|
|
331
330
|
return execute(command, ...args);
|
|
332
331
|
};
|
|
333
332
|
const execute = (command, ...args) => {
|
|
334
|
-
if (command in state$
|
|
335
|
-
const fn = state$
|
|
333
|
+
if (command in state$b.commands) {
|
|
334
|
+
const fn = state$b.commands[command];
|
|
336
335
|
if (typeof fn !== 'function') {
|
|
337
336
|
throw new Error(`[renderer-worker] Command ${command} is not a function`);
|
|
338
337
|
}
|
|
@@ -341,7 +340,7 @@ const execute = (command, ...args) => {
|
|
|
341
340
|
return executeCommandAsync(command, ...args);
|
|
342
341
|
};
|
|
343
342
|
const setLoad = load => {
|
|
344
|
-
state$
|
|
343
|
+
state$b.load = load;
|
|
345
344
|
};
|
|
346
345
|
|
|
347
346
|
/**
|
|
@@ -362,35 +361,7 @@ const handleBeforeInstallPrompt = event => {
|
|
|
362
361
|
preventDefault(event);
|
|
363
362
|
};
|
|
364
363
|
|
|
365
|
-
const state$b = {
|
|
366
|
-
/**
|
|
367
|
-
* @type {any[]}
|
|
368
|
-
*/
|
|
369
|
-
errors: []
|
|
370
|
-
};
|
|
371
|
-
const addError = error => {
|
|
372
|
-
// @ts-expect-error
|
|
373
|
-
state$b.errors.push(error);
|
|
374
|
-
};
|
|
375
|
-
const hasRecentErrors = () => {
|
|
376
|
-
return state$b.errors.length > 0;
|
|
377
|
-
};
|
|
378
|
-
const getRecentError = () => {
|
|
379
|
-
};
|
|
380
|
-
|
|
381
364
|
const handleContentSecurityPolicyViolation = event => {
|
|
382
|
-
const {
|
|
383
|
-
violatedDirective,
|
|
384
|
-
sourceFile,
|
|
385
|
-
lineNumber,
|
|
386
|
-
columnNumber
|
|
387
|
-
} = event;
|
|
388
|
-
addError({
|
|
389
|
-
violatedDirective,
|
|
390
|
-
sourceFile,
|
|
391
|
-
lineNumber,
|
|
392
|
-
columnNumber
|
|
393
|
-
});
|
|
394
365
|
};
|
|
395
366
|
|
|
396
367
|
const load$1 = moduleId => {
|
|
@@ -660,7 +631,7 @@ const constructError = (message, type, name) => {
|
|
|
660
631
|
}
|
|
661
632
|
return new ErrorConstructor(message);
|
|
662
633
|
};
|
|
663
|
-
const getNewLineIndex$
|
|
634
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
664
635
|
return string.indexOf(NewLine$3, startIndex);
|
|
665
636
|
};
|
|
666
637
|
const getParentStack = error => {
|
|
@@ -713,7 +684,7 @@ const restoreJsonRpcError = error => {
|
|
|
713
684
|
if (error.stack) {
|
|
714
685
|
const lowerStack = restoredError.stack || '';
|
|
715
686
|
// @ts-ignore
|
|
716
|
-
const indexNewLine = getNewLineIndex$
|
|
687
|
+
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
717
688
|
const parentStack = getParentStack(error);
|
|
718
689
|
// @ts-ignore
|
|
719
690
|
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
@@ -773,7 +744,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
773
744
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
774
745
|
return create$1$1(message, errorProperty);
|
|
775
746
|
};
|
|
776
|
-
const create$
|
|
747
|
+
const create$L = (message, result) => {
|
|
777
748
|
return {
|
|
778
749
|
jsonrpc: Two,
|
|
779
750
|
id: message.id,
|
|
@@ -782,7 +753,7 @@ const create$M = (message, result) => {
|
|
|
782
753
|
};
|
|
783
754
|
const getSuccessResponse = (message, result) => {
|
|
784
755
|
const resultProperty = result ?? null;
|
|
785
|
-
return create$
|
|
756
|
+
return create$L(message, resultProperty);
|
|
786
757
|
};
|
|
787
758
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
788
759
|
try {
|
|
@@ -936,7 +907,7 @@ const getModule$1 = method => {
|
|
|
936
907
|
}
|
|
937
908
|
};
|
|
938
909
|
|
|
939
|
-
const create$
|
|
910
|
+
const create$K = async ({
|
|
940
911
|
method,
|
|
941
912
|
...options
|
|
942
913
|
}) => {
|
|
@@ -999,7 +970,7 @@ const launchWorker = async ({
|
|
|
999
970
|
name,
|
|
1000
971
|
url
|
|
1001
972
|
}) => {
|
|
1002
|
-
const worker = await create$
|
|
973
|
+
const worker = await create$K({
|
|
1003
974
|
method: Auto,
|
|
1004
975
|
url,
|
|
1005
976
|
name
|
|
@@ -1168,65 +1139,6 @@ const boolean = value => {
|
|
|
1168
1139
|
}
|
|
1169
1140
|
};
|
|
1170
1141
|
|
|
1171
|
-
/**
|
|
1172
|
-
*
|
|
1173
|
-
* @returns {Promise<any>}
|
|
1174
|
-
*/
|
|
1175
|
-
const loadKy = async () => {
|
|
1176
|
-
const url = `${assetDir}/js/ky.js`;
|
|
1177
|
-
const module = await import(url);
|
|
1178
|
-
return module;
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
const getJson = async (url, options = {}) => {
|
|
1182
|
-
const {
|
|
1183
|
-
default: ky,
|
|
1184
|
-
HTTPError
|
|
1185
|
-
} = await loadKy();
|
|
1186
|
-
try {
|
|
1187
|
-
string(url);
|
|
1188
|
-
// cannot use ky(url).json() because it sets "accept: application/json"
|
|
1189
|
-
// which doesn't work with preload, see
|
|
1190
|
-
// https://stackoverflow.com/questions/41655955/why-are-preload-link-not-working-for-json-requests#answer-48645748
|
|
1191
|
-
const response = await ky(url, options);
|
|
1192
|
-
return response.json();
|
|
1193
|
-
} catch (error) {
|
|
1194
|
-
if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
|
|
1195
|
-
// @ts-expect-error
|
|
1196
|
-
throw new VError$1(`Failed to request json from "${url}". Make sure that the server is running and has CORS enabled`);
|
|
1197
|
-
}
|
|
1198
|
-
if (error && error instanceof HTTPError) {
|
|
1199
|
-
let json;
|
|
1200
|
-
try {
|
|
1201
|
-
// @ts-ignore
|
|
1202
|
-
json = await error.response.json();
|
|
1203
|
-
} catch {
|
|
1204
|
-
throw error;
|
|
1205
|
-
}
|
|
1206
|
-
if (json?.message) {
|
|
1207
|
-
// @ts-expect-error
|
|
1208
|
-
throw new VError$1(`Failed to request json from "${url}": ${json.message}`);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
// @ts-ignore
|
|
1212
|
-
error.message = `Failed to request json from "${url}": ${error.message}`;
|
|
1213
|
-
throw error;
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
const getText$1 = async (url, options = {}) => {
|
|
1217
|
-
try {
|
|
1218
|
-
const {
|
|
1219
|
-
default: ky
|
|
1220
|
-
} = await loadKy();
|
|
1221
|
-
return await ky(url, options).text();
|
|
1222
|
-
} catch (error) {
|
|
1223
|
-
if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
|
|
1224
|
-
throw new VError$1(error, `Failed to request text from "${url}". Make sure that the server is running and has CORS enabled`);
|
|
1225
|
-
}
|
|
1226
|
-
throw new VError$1(error, `Failed to request text from "${url}"`);
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
1142
|
const NewLine$2 = '\n';
|
|
1231
1143
|
|
|
1232
1144
|
const splitLines$1 = lines => {
|
|
@@ -1320,129 +1232,6 @@ const cleanStack = stack => {
|
|
|
1320
1232
|
return merged;
|
|
1321
1233
|
};
|
|
1322
1234
|
|
|
1323
|
-
// based on https://github.com/babel/babel/blob/6be6e04f396f03feace4431f709564a8d842163a/packages/babel-code-frame/src/index.ts (License MIT)
|
|
1324
|
-
|
|
1325
|
-
/**
|
|
1326
|
-
* RegExp to test for newlines in terminal.
|
|
1327
|
-
*/
|
|
1328
|
-
|
|
1329
|
-
const NEWLINE = /\n/;
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Extract what lines should be marked and highlighted.
|
|
1333
|
-
*/
|
|
1334
|
-
const getMarkerLines = (loc, source, opts) => {
|
|
1335
|
-
const startLoc = {
|
|
1336
|
-
column: 0,
|
|
1337
|
-
line: -1,
|
|
1338
|
-
...loc.start
|
|
1339
|
-
};
|
|
1340
|
-
const endLoc = {
|
|
1341
|
-
...startLoc,
|
|
1342
|
-
...loc.end
|
|
1343
|
-
};
|
|
1344
|
-
const {
|
|
1345
|
-
linesAbove = 2,
|
|
1346
|
-
linesBelow = 3
|
|
1347
|
-
} = opts || {};
|
|
1348
|
-
const startLine = startLoc.line;
|
|
1349
|
-
const startColumn = startLoc.column;
|
|
1350
|
-
const endLine = endLoc.line;
|
|
1351
|
-
const endColumn = endLoc.column;
|
|
1352
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
1353
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
1354
|
-
if (startLine === -1) {
|
|
1355
|
-
start = 0;
|
|
1356
|
-
}
|
|
1357
|
-
if (endLine === -1) {
|
|
1358
|
-
end = source.length;
|
|
1359
|
-
}
|
|
1360
|
-
const lineDiff = endLine - startLine;
|
|
1361
|
-
const markerLines = {};
|
|
1362
|
-
if (lineDiff) {
|
|
1363
|
-
for (let i = 0; i <= lineDiff; i++) {
|
|
1364
|
-
const lineNumber = i + startLine;
|
|
1365
|
-
if (!startColumn) {
|
|
1366
|
-
markerLines[lineNumber] = true;
|
|
1367
|
-
} else if (i === 0) {
|
|
1368
|
-
const sourceLength = source[lineNumber - 1].length;
|
|
1369
|
-
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
|
1370
|
-
} else if (i === lineDiff) {
|
|
1371
|
-
markerLines[lineNumber] = [0, endColumn];
|
|
1372
|
-
} else {
|
|
1373
|
-
const sourceLength = source[lineNumber - i].length;
|
|
1374
|
-
markerLines[lineNumber] = [0, sourceLength];
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
} else {
|
|
1378
|
-
if (startColumn === endColumn) {
|
|
1379
|
-
if (startColumn) {
|
|
1380
|
-
markerLines[startLine] = [startColumn, 0];
|
|
1381
|
-
} else {
|
|
1382
|
-
markerLines[startLine] = true;
|
|
1383
|
-
}
|
|
1384
|
-
} else {
|
|
1385
|
-
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
return {
|
|
1389
|
-
start,
|
|
1390
|
-
end,
|
|
1391
|
-
markerLines
|
|
1392
|
-
};
|
|
1393
|
-
};
|
|
1394
|
-
const create$K = (rawLines, loc, opts = {}) => {
|
|
1395
|
-
const lines = rawLines.split(NEWLINE);
|
|
1396
|
-
const {
|
|
1397
|
-
start,
|
|
1398
|
-
end,
|
|
1399
|
-
markerLines
|
|
1400
|
-
} = getMarkerLines(loc, lines, opts);
|
|
1401
|
-
const hasColumns = loc.start && typeof loc.start.column === 'number';
|
|
1402
|
-
const numberMaxWidth = String(end).length;
|
|
1403
|
-
let frame = rawLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
|
1404
|
-
const number = start + 1 + index;
|
|
1405
|
-
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
1406
|
-
const gutter = ` ${paddedNumber} |`;
|
|
1407
|
-
const hasMarker = markerLines[number];
|
|
1408
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
1409
|
-
if (hasMarker) {
|
|
1410
|
-
let markerLine = '';
|
|
1411
|
-
if (Array.isArray(hasMarker)) {
|
|
1412
|
-
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, ' ');
|
|
1413
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
1414
|
-
markerLine = ['\n ', gutter.replace(/\d/g, ' '), ' ', markerSpacing, '^'.repeat(numberOfMarkers)].join('');
|
|
1415
|
-
|
|
1416
|
-
// @ts-ignore
|
|
1417
|
-
if (lastMarkerLine && opts.message) {
|
|
1418
|
-
// @ts-ignore
|
|
1419
|
-
markerLine += ' ' + opts.message;
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('');
|
|
1423
|
-
} else {
|
|
1424
|
-
return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`;
|
|
1425
|
-
}
|
|
1426
|
-
}).join(NewLine$2);
|
|
1427
|
-
|
|
1428
|
-
// @ts-ignore
|
|
1429
|
-
if (opts.message && !hasColumns) {
|
|
1430
|
-
// @ts-ignore
|
|
1431
|
-
frame = `${' '.repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
1432
|
-
}
|
|
1433
|
-
return frame;
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
/**
|
|
1437
|
-
*
|
|
1438
|
-
* @param {string} string
|
|
1439
|
-
* @param {number|undefined} startIndex
|
|
1440
|
-
* @returns
|
|
1441
|
-
*/
|
|
1442
|
-
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1443
|
-
return string.indexOf(NewLine$2, startIndex);
|
|
1444
|
-
};
|
|
1445
|
-
|
|
1446
1235
|
const isActualSourceFile = path => {
|
|
1447
1236
|
if (path === '<anonymous>' || path === 'debugger eval code' || path.startsWith('"') || path.startsWith(`'`) || path.startsWith(')') || path.startsWith('file://')) {
|
|
1448
1237
|
return false;
|
|
@@ -1482,139 +1271,6 @@ const info = (...args) => {
|
|
|
1482
1271
|
console.info(...args);
|
|
1483
1272
|
};
|
|
1484
1273
|
|
|
1485
|
-
const isEmptyString = string => {
|
|
1486
|
-
return string === '';
|
|
1487
|
-
};
|
|
1488
|
-
|
|
1489
|
-
// copied from https://github.com/Rich-Harris/vlq/blob/e3009f5757abeb0b5b6233045f3bbdaf86435d08/src/index.js by Rich Harris (License MIT)
|
|
1490
|
-
|
|
1491
|
-
/** @type {Record<string, number>} */
|
|
1492
|
-
const char_to_integer = {};
|
|
1493
|
-
for (const [i, char] of 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').entries()) {
|
|
1494
|
-
char_to_integer[char] = i;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
/** @param {string} string */
|
|
1498
|
-
const decode = string => {
|
|
1499
|
-
/** @type {number[]} */
|
|
1500
|
-
const result = [];
|
|
1501
|
-
let shift = 0;
|
|
1502
|
-
let value = 0;
|
|
1503
|
-
for (let i = 0; i < string.length; i += 1) {
|
|
1504
|
-
let integer = char_to_integer[string[i]];
|
|
1505
|
-
if (integer === undefined) {
|
|
1506
|
-
throw new Error('Invalid character (' + string[i] + ')');
|
|
1507
|
-
}
|
|
1508
|
-
const has_continuation_bit = integer & 32;
|
|
1509
|
-
integer &= 31;
|
|
1510
|
-
value += integer << shift;
|
|
1511
|
-
if (has_continuation_bit) {
|
|
1512
|
-
shift += 5;
|
|
1513
|
-
} else {
|
|
1514
|
-
const should_negate = value & 1;
|
|
1515
|
-
value >>>= 1;
|
|
1516
|
-
if (should_negate) {
|
|
1517
|
-
// @ts-expect-error
|
|
1518
|
-
result.push(value === 0 ? -0x80000000 : -value);
|
|
1519
|
-
} else {
|
|
1520
|
-
// @ts-expect-error
|
|
1521
|
-
result.push(value);
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
// reset
|
|
1525
|
-
value = shift = 0;
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
return result;
|
|
1529
|
-
};
|
|
1530
|
-
|
|
1531
|
-
const getColumnMapping = (mappings, line, column) => {
|
|
1532
|
-
string(mappings);
|
|
1533
|
-
number(line);
|
|
1534
|
-
number(column);
|
|
1535
|
-
let currentColumn = 0;
|
|
1536
|
-
let currentLine = 1;
|
|
1537
|
-
let originalSourceFileIndex = 0;
|
|
1538
|
-
let originalLine = 0;
|
|
1539
|
-
let originalColumn = 0;
|
|
1540
|
-
let index = 0;
|
|
1541
|
-
while (index !== -1) {
|
|
1542
|
-
currentColumn = 0;
|
|
1543
|
-
const newLineIndex = mappings.indexOf(';', index + 1);
|
|
1544
|
-
currentLine++;
|
|
1545
|
-
if (currentLine === line) {
|
|
1546
|
-
const lineMapping = mappings.slice(index + 1, newLineIndex) + ',';
|
|
1547
|
-
index = -1;
|
|
1548
|
-
while (true) {
|
|
1549
|
-
const newIndex = lineMapping.indexOf(',', index + 1);
|
|
1550
|
-
if (newIndex === -1) {
|
|
1551
|
-
throw new Error('no mapping found');
|
|
1552
|
-
}
|
|
1553
|
-
const chunk = lineMapping.slice(index + 1, newIndex);
|
|
1554
|
-
const decodedChunk = decode(chunk);
|
|
1555
|
-
currentColumn += decodedChunk[0];
|
|
1556
|
-
originalSourceFileIndex += decodedChunk[1];
|
|
1557
|
-
originalLine += decodedChunk[2];
|
|
1558
|
-
originalColumn += decodedChunk[3];
|
|
1559
|
-
index = newIndex;
|
|
1560
|
-
if (currentColumn >= column) {
|
|
1561
|
-
return {
|
|
1562
|
-
originalSourceFileIndex,
|
|
1563
|
-
originalLine: originalLine + 1,
|
|
1564
|
-
originalColumn
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
} else {
|
|
1569
|
-
const lineMappings = mappings.slice(index + 1, newLineIndex);
|
|
1570
|
-
if (isEmptyString(lineMappings)) {
|
|
1571
|
-
index = newLineIndex;
|
|
1572
|
-
continue;
|
|
1573
|
-
}
|
|
1574
|
-
const chunks = lineMappings.split(',');
|
|
1575
|
-
for (const chunk of chunks) {
|
|
1576
|
-
const decodedChunk = decode(chunk);
|
|
1577
|
-
currentColumn += decodedChunk[0];
|
|
1578
|
-
originalSourceFileIndex += decodedChunk[1];
|
|
1579
|
-
originalLine += decodedChunk[2];
|
|
1580
|
-
originalColumn += decodedChunk[3];
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
index = newLineIndex;
|
|
1584
|
-
}
|
|
1585
|
-
throw new Error(`no mapping found`);
|
|
1586
|
-
};
|
|
1587
|
-
const getOriginalPosition = (sourceMap, line, column) => {
|
|
1588
|
-
try {
|
|
1589
|
-
object(sourceMap);
|
|
1590
|
-
string(sourceMap.mappings);
|
|
1591
|
-
array(sourceMap.sources);
|
|
1592
|
-
array(sourceMap.names);
|
|
1593
|
-
number(line);
|
|
1594
|
-
number(column);
|
|
1595
|
-
const {
|
|
1596
|
-
sources,
|
|
1597
|
-
mappings
|
|
1598
|
-
} = sourceMap;
|
|
1599
|
-
if (!mappings) {
|
|
1600
|
-
throw new Error(`no source for line ${line} found`);
|
|
1601
|
-
}
|
|
1602
|
-
const {
|
|
1603
|
-
originalLine,
|
|
1604
|
-
originalColumn,
|
|
1605
|
-
originalSourceFileIndex
|
|
1606
|
-
} = getColumnMapping(mappings, line, column);
|
|
1607
|
-
const source = sources[originalSourceFileIndex];
|
|
1608
|
-
return {
|
|
1609
|
-
source,
|
|
1610
|
-
originalLine,
|
|
1611
|
-
originalColumn
|
|
1612
|
-
};
|
|
1613
|
-
} catch (error) {
|
|
1614
|
-
throw new VError$1(error, `Failed to get original sourcemap position`);
|
|
1615
|
-
}
|
|
1616
|
-
};
|
|
1617
|
-
|
|
1618
1274
|
const getErrorMessage = error => {
|
|
1619
1275
|
if (!error) {
|
|
1620
1276
|
return `Error: ${error}`;
|
|
@@ -1661,8 +1317,6 @@ const RE_PATH_1 = /\((.*):(\d+):(\d+)\)$/;
|
|
|
1661
1317
|
const RE_PATH_2 = /at (.*):(\d+):(\d+)$/;
|
|
1662
1318
|
const RE_PATH_3 = /@(.*):(\d+):(\d+)$/; // Firefox
|
|
1663
1319
|
|
|
1664
|
-
const RE_SOURCE_MAP = /^\/\/# sourceMappingURL=(.*)$/;
|
|
1665
|
-
|
|
1666
1320
|
/**
|
|
1667
1321
|
*
|
|
1668
1322
|
* @param {readonly string[]} lines
|
|
@@ -1676,29 +1330,6 @@ const getFile = lines => {
|
|
|
1676
1330
|
}
|
|
1677
1331
|
return '';
|
|
1678
1332
|
};
|
|
1679
|
-
const getSourceMapAbsolutePath = (file, relativePath) => {
|
|
1680
|
-
const folder = file.slice(0, file.lastIndexOf('/'));
|
|
1681
|
-
const absolutePath = folder + '/' + relativePath;
|
|
1682
|
-
return absolutePath;
|
|
1683
|
-
};
|
|
1684
|
-
const toAbsoluteUrl = (file, relativePath) => {
|
|
1685
|
-
const url = new URL(relativePath, file);
|
|
1686
|
-
return url.href;
|
|
1687
|
-
};
|
|
1688
|
-
const getSourceMapMatch = text => {
|
|
1689
|
-
string(text);
|
|
1690
|
-
const index = text.lastIndexOf(NewLine$2, text.length - 2);
|
|
1691
|
-
const lastLine = text.slice(index + 1, -1);
|
|
1692
|
-
const lastLineMatch = lastLine.match(RE_SOURCE_MAP);
|
|
1693
|
-
if (lastLineMatch) {
|
|
1694
|
-
return lastLineMatch;
|
|
1695
|
-
}
|
|
1696
|
-
// @ts-ignore
|
|
1697
|
-
const secondLastLineIndex = getNewLineIndex$1(text, index - 1);
|
|
1698
|
-
const secondLastLine = text.slice(secondLastLineIndex, index);
|
|
1699
|
-
const secondLastLineMatch = secondLastLine.match(RE_SOURCE_MAP);
|
|
1700
|
-
return secondLastLineMatch;
|
|
1701
|
-
};
|
|
1702
1333
|
const prepareErrorMessageWithoutCodeFrame = async error => {
|
|
1703
1334
|
try {
|
|
1704
1335
|
const lines = cleanStack(error.stack);
|
|
@@ -1713,59 +1344,12 @@ const prepareErrorMessageWithoutCodeFrame = async error => {
|
|
|
1713
1344
|
if (!match) {
|
|
1714
1345
|
return error;
|
|
1715
1346
|
}
|
|
1716
|
-
const [_, path
|
|
1347
|
+
const [_, path] = match;
|
|
1717
1348
|
if (!isActualSourceFile(path)) {
|
|
1718
1349
|
return error;
|
|
1719
1350
|
}
|
|
1720
|
-
const text = await getText$1(path);
|
|
1721
|
-
const sourceMapMatch = getSourceMapMatch(text);
|
|
1722
|
-
const parsedLine = parseInt(line);
|
|
1723
|
-
const parsedColumn = parseInt(column);
|
|
1724
|
-
const message = getErrorMessage(error);
|
|
1725
|
-
const relevantStack = joinLines$1(lines);
|
|
1726
|
-
if (sourceMapMatch) {
|
|
1727
|
-
const sourceMapUrl = sourceMapMatch[1];
|
|
1728
|
-
const sourceMapAbsolutePath = getSourceMapAbsolutePath(path, sourceMapUrl);
|
|
1729
|
-
const sourceMap = await getJson(sourceMapAbsolutePath);
|
|
1730
|
-
const {
|
|
1731
|
-
source,
|
|
1732
|
-
originalLine,
|
|
1733
|
-
originalColumn
|
|
1734
|
-
} = getOriginalPosition(sourceMap, parsedLine, parsedColumn);
|
|
1735
|
-
const absoluteSourceUrl = toAbsoluteUrl(path, source);
|
|
1736
|
-
const originalSourceContent = await getText$1(absoluteSourceUrl);
|
|
1737
|
-
const codeFrame = create$K(originalSourceContent, {
|
|
1738
|
-
start: {
|
|
1739
|
-
line: originalLine,
|
|
1740
|
-
column: originalColumn
|
|
1741
|
-
},
|
|
1742
|
-
end: {
|
|
1743
|
-
line: originalLine,
|
|
1744
|
-
column: originalColumn
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
return {
|
|
1748
|
-
message,
|
|
1749
|
-
codeFrame,
|
|
1750
|
-
stack: relevantStack,
|
|
1751
|
-
type: error.constructor.name,
|
|
1752
|
-
_error: error
|
|
1753
|
-
};
|
|
1754
|
-
}
|
|
1755
|
-
const codeFrame = create$K(text, {
|
|
1756
|
-
start: {
|
|
1757
|
-
line: parsedLine,
|
|
1758
|
-
column: parsedColumn
|
|
1759
|
-
},
|
|
1760
|
-
end: {
|
|
1761
|
-
line: parsedLine,
|
|
1762
|
-
column: parsedColumn
|
|
1763
|
-
}
|
|
1764
|
-
});
|
|
1765
1351
|
return {
|
|
1766
|
-
message,
|
|
1767
|
-
codeFrame,
|
|
1768
|
-
stack: relevantStack,
|
|
1352
|
+
message: error?.message || '',
|
|
1769
1353
|
type: error.constructor.name,
|
|
1770
1354
|
_error: error
|
|
1771
1355
|
};
|
|
@@ -3396,9 +2980,6 @@ const ImagePreview_ipc = {
|
|
|
3396
2980
|
name: name$o
|
|
3397
2981
|
};
|
|
3398
2982
|
|
|
3399
|
-
const getOrigin = () => {
|
|
3400
|
-
return location.origin;
|
|
3401
|
-
};
|
|
3402
2983
|
const getPathName = () => {
|
|
3403
2984
|
return location.pathname;
|
|
3404
2985
|
};
|
|
@@ -3462,7 +3043,7 @@ const InitData_ipc = {
|
|
|
3462
3043
|
|
|
3463
3044
|
const name$m = 'IpcParent';
|
|
3464
3045
|
const Commands$n = {
|
|
3465
|
-
create: create$
|
|
3046
|
+
create: create$K
|
|
3466
3047
|
};
|
|
3467
3048
|
|
|
3468
3049
|
const IpcParent_ipc = {
|
|
@@ -5463,6 +5044,27 @@ const ModuleWorkerAndMessagePort = 8;
|
|
|
5463
5044
|
const getData$1 = event => {
|
|
5464
5045
|
return event.data;
|
|
5465
5046
|
};
|
|
5047
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
5048
|
+
if (!value) {
|
|
5049
|
+
return;
|
|
5050
|
+
}
|
|
5051
|
+
if (isTransferrable(value)) {
|
|
5052
|
+
transferrables.push(value);
|
|
5053
|
+
return;
|
|
5054
|
+
}
|
|
5055
|
+
if (Array.isArray(value)) {
|
|
5056
|
+
for (const item of value) {
|
|
5057
|
+
walkValue(item, transferrables, isTransferrable);
|
|
5058
|
+
}
|
|
5059
|
+
return;
|
|
5060
|
+
}
|
|
5061
|
+
if (typeof value === 'object') {
|
|
5062
|
+
for (const property of Object.values(value)) {
|
|
5063
|
+
walkValue(property, transferrables, isTransferrable);
|
|
5064
|
+
}
|
|
5065
|
+
return;
|
|
5066
|
+
}
|
|
5067
|
+
};
|
|
5466
5068
|
const isMessagePort$1 = value => {
|
|
5467
5069
|
return value && value instanceof MessagePort;
|
|
5468
5070
|
};
|
|
@@ -5487,32 +5089,9 @@ const isTransferrable = value => {
|
|
|
5487
5089
|
}
|
|
5488
5090
|
return false;
|
|
5489
5091
|
};
|
|
5490
|
-
const walkValue = (value, transferrables) => {
|
|
5491
|
-
if (!value) {
|
|
5492
|
-
return value;
|
|
5493
|
-
}
|
|
5494
|
-
if (isTransferrable(value)) {
|
|
5495
|
-
transferrables.push(value);
|
|
5496
|
-
return;
|
|
5497
|
-
}
|
|
5498
|
-
if (Array.isArray(value)) {
|
|
5499
|
-
for (const item of value) {
|
|
5500
|
-
walkValue(item, transferrables);
|
|
5501
|
-
}
|
|
5502
|
-
return;
|
|
5503
|
-
}
|
|
5504
|
-
if (typeof value === 'object') {
|
|
5505
|
-
const newObject = Object.create(null);
|
|
5506
|
-
for (const property of Object.values(value)) {
|
|
5507
|
-
walkValue(property, transferrables);
|
|
5508
|
-
}
|
|
5509
|
-
return newObject;
|
|
5510
|
-
}
|
|
5511
|
-
return value;
|
|
5512
|
-
};
|
|
5513
5092
|
const getTransferrables = value => {
|
|
5514
5093
|
const transferrables = [];
|
|
5515
|
-
walkValue(value, transferrables);
|
|
5094
|
+
walkValue(value, transferrables, isTransferrable);
|
|
5516
5095
|
return transferrables;
|
|
5517
5096
|
};
|
|
5518
5097
|
const attachEvents$a = that => {
|
|
@@ -6101,14 +5680,14 @@ ${relevant}`;
|
|
|
6101
5680
|
}
|
|
6102
5681
|
}
|
|
6103
5682
|
|
|
6104
|
-
const Module
|
|
5683
|
+
const Module = 'module';
|
|
6105
5684
|
|
|
6106
5685
|
const create$B = async ({
|
|
6107
5686
|
url,
|
|
6108
5687
|
name
|
|
6109
5688
|
}) => {
|
|
6110
5689
|
const worker = new Worker(url, {
|
|
6111
|
-
type: Module
|
|
5690
|
+
type: Module,
|
|
6112
5691
|
name
|
|
6113
5692
|
});
|
|
6114
5693
|
// @ts-expect-error
|
|
@@ -6126,12 +5705,7 @@ const create$B = async ({
|
|
|
6126
5705
|
if (isErrorEvent(event)) {
|
|
6127
5706
|
throw new WorkerError(event);
|
|
6128
5707
|
}
|
|
6129
|
-
|
|
6130
|
-
const actualErrorMessage = await TryToGetActualWorkerErrorMessage$1.tryToGetActualErrorMessage({
|
|
6131
|
-
url,
|
|
6132
|
-
name
|
|
6133
|
-
});
|
|
6134
|
-
throw new Error(actualErrorMessage);
|
|
5708
|
+
throw new Error(`Failed to start worker`);
|
|
6135
5709
|
}
|
|
6136
5710
|
return worker;
|
|
6137
5711
|
};
|
|
@@ -11630,364 +11204,3 @@ const ViewletWebView = {
|
|
|
11630
11204
|
setIframe,
|
|
11631
11205
|
setPort
|
|
11632
11206
|
};
|
|
11633
|
-
|
|
11634
|
-
const getWorkerDisplayName = name => {
|
|
11635
|
-
if (!name) {
|
|
11636
|
-
return '<unknown> worker';
|
|
11637
|
-
}
|
|
11638
|
-
if (name.endsWith('Worker') || name.endsWith('worker')) {
|
|
11639
|
-
return name.toLowerCase();
|
|
11640
|
-
}
|
|
11641
|
-
return `${name} Worker`;
|
|
11642
|
-
};
|
|
11643
|
-
|
|
11644
|
-
const NotFound = 404;
|
|
11645
|
-
|
|
11646
|
-
const RE_LINE_COLUMN = /(.*)\(\d+:\d+\)/;
|
|
11647
|
-
const getBabelErrorMessage = message => {
|
|
11648
|
-
const match = message.match(RE_LINE_COLUMN);
|
|
11649
|
-
if (match) {
|
|
11650
|
-
return match[1].trim();
|
|
11651
|
-
}
|
|
11652
|
-
return message;
|
|
11653
|
-
};
|
|
11654
|
-
class BabelParseError extends SyntaxError {
|
|
11655
|
-
constructor(url, error) {
|
|
11656
|
-
const message = getBabelErrorMessage(error.message);
|
|
11657
|
-
super(message);
|
|
11658
|
-
this.name = 'BabelParseError';
|
|
11659
|
-
const line = error.loc.line;
|
|
11660
|
-
const column = error.loc.column + 1;
|
|
11661
|
-
this.stack = `${message}
|
|
11662
|
-
at ${url}:${line}:${column}`;
|
|
11663
|
-
}
|
|
11664
|
-
}
|
|
11665
|
-
|
|
11666
|
-
const loadBabelParser = () => {
|
|
11667
|
-
const url = `${assetDir}/js/babel-parser.js`;
|
|
11668
|
-
return import(url);
|
|
11669
|
-
};
|
|
11670
|
-
|
|
11671
|
-
const parse = async (code, options) => {
|
|
11672
|
-
const BabelParse = await loadBabelParser();
|
|
11673
|
-
return BabelParse.parse(code, options);
|
|
11674
|
-
};
|
|
11675
|
-
|
|
11676
|
-
const Module = 'module';
|
|
11677
|
-
|
|
11678
|
-
class ContentSecurityPolicyError extends Error {
|
|
11679
|
-
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
11680
|
-
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
11681
|
-
this.name = 'ContentSecurityPolicyError';
|
|
11682
|
-
if (sourceFile) {
|
|
11683
|
-
this.stack = `Content Security Policy Violation
|
|
11684
|
-
at ${sourceFile}:${lineNumber}:${columnNumber}`;
|
|
11685
|
-
} else {
|
|
11686
|
-
this.stack = `Content Security Policy Violation
|
|
11687
|
-
at <unknown>`;
|
|
11688
|
-
}
|
|
11689
|
-
}
|
|
11690
|
-
}
|
|
11691
|
-
|
|
11692
|
-
const getLineAndColumn = (text, start, end) => {
|
|
11693
|
-
let index = -1;
|
|
11694
|
-
let line = 0;
|
|
11695
|
-
const column = 0;
|
|
11696
|
-
while ((index = text.indexOf('\n', index + 1)) !== -1) {
|
|
11697
|
-
line++;
|
|
11698
|
-
if (index >= start) {
|
|
11699
|
-
break;
|
|
11700
|
-
}
|
|
11701
|
-
}
|
|
11702
|
-
return {
|
|
11703
|
-
line,
|
|
11704
|
-
column
|
|
11705
|
-
};
|
|
11706
|
-
};
|
|
11707
|
-
|
|
11708
|
-
class DependencyNotFoundError extends Error {
|
|
11709
|
-
constructor(code, start, end, dependencyRelativePath, dependencyUrl, sourceUrl) {
|
|
11710
|
-
super(`Module not found "${dependencyRelativePath}"`);
|
|
11711
|
-
const {
|
|
11712
|
-
line,
|
|
11713
|
-
column
|
|
11714
|
-
} = getLineAndColumn(code, start);
|
|
11715
|
-
this.stack = `${this.message}
|
|
11716
|
-
at Module (${sourceUrl}:${line}:${column})`;
|
|
11717
|
-
}
|
|
11718
|
-
}
|
|
11719
|
-
|
|
11720
|
-
const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
11721
|
-
const AwaitExpression = 'AwaitExpression';
|
|
11722
|
-
const BlockStatement = 'BlockStatement';
|
|
11723
|
-
const CallExpression = 'CallExpression';
|
|
11724
|
-
const ExportAllDeclaration = 'ExportAllDeclaration';
|
|
11725
|
-
const ExportNamedDeclaration = 'ExportNamedDeclaration';
|
|
11726
|
-
const ExpressionStatement = 'ExpressionStatement';
|
|
11727
|
-
const File$1 = 'File';
|
|
11728
|
-
const Import = 'Import';
|
|
11729
|
-
const ImportDeclaration = 'ImportDeclaration';
|
|
11730
|
-
const Program = 'Program';
|
|
11731
|
-
const StringLiteral = 'StringLiteral';
|
|
11732
|
-
const VariableDeclaration = 'VariableDeclaration';
|
|
11733
|
-
const VariableDeclarator = 'VariableDeclarator';
|
|
11734
|
-
|
|
11735
|
-
const walk = (node, visitor) => {
|
|
11736
|
-
if (!node) {
|
|
11737
|
-
return;
|
|
11738
|
-
}
|
|
11739
|
-
if (Array.isArray(node)) {
|
|
11740
|
-
for (const item of node) {
|
|
11741
|
-
walk(item, visitor);
|
|
11742
|
-
}
|
|
11743
|
-
return;
|
|
11744
|
-
}
|
|
11745
|
-
visitor(node);
|
|
11746
|
-
switch (node.type) {
|
|
11747
|
-
case File$1:
|
|
11748
|
-
walk(node.program, visitor);
|
|
11749
|
-
break;
|
|
11750
|
-
case Program:
|
|
11751
|
-
walk(node.body, visitor);
|
|
11752
|
-
break;
|
|
11753
|
-
case ExportNamedDeclaration:
|
|
11754
|
-
walk(node.declaration, visitor);
|
|
11755
|
-
break;
|
|
11756
|
-
case VariableDeclaration:
|
|
11757
|
-
walk(node.declarations, visitor);
|
|
11758
|
-
break;
|
|
11759
|
-
case VariableDeclarator:
|
|
11760
|
-
walk(node.init, visitor);
|
|
11761
|
-
break;
|
|
11762
|
-
case ArrowFunctionExpression:
|
|
11763
|
-
walk(node.body, visitor);
|
|
11764
|
-
break;
|
|
11765
|
-
case BlockStatement:
|
|
11766
|
-
walk(node.body, visitor);
|
|
11767
|
-
break;
|
|
11768
|
-
case ExpressionStatement:
|
|
11769
|
-
walk(node.expression, visitor);
|
|
11770
|
-
break;
|
|
11771
|
-
case AwaitExpression:
|
|
11772
|
-
walk(node.argument, visitor);
|
|
11773
|
-
break;
|
|
11774
|
-
case CallExpression:
|
|
11775
|
-
walk(node.callee, visitor);
|
|
11776
|
-
break;
|
|
11777
|
-
}
|
|
11778
|
-
};
|
|
11779
|
-
const getBabelAstDependencies = (code, ast) => {
|
|
11780
|
-
const {
|
|
11781
|
-
program
|
|
11782
|
-
} = ast;
|
|
11783
|
-
const {
|
|
11784
|
-
body
|
|
11785
|
-
} = program;
|
|
11786
|
-
const dependencies = [];
|
|
11787
|
-
for (const node of body) {
|
|
11788
|
-
if (node.type === ImportDeclaration || node.type === ExportAllDeclaration) {
|
|
11789
|
-
const relativePath = node.source.extra.rawValue;
|
|
11790
|
-
const start = node.source.start;
|
|
11791
|
-
const end = node.source.end;
|
|
11792
|
-
// @ts-ignore
|
|
11793
|
-
dependencies.push({
|
|
11794
|
-
relativePath,
|
|
11795
|
-
code,
|
|
11796
|
-
start,
|
|
11797
|
-
end
|
|
11798
|
-
});
|
|
11799
|
-
} else if (node.type === VariableDeclaration && node.declarations && node.declarations[0] && node.declarations[0].type === VariableDeclarator && node.declarations[0].init && node.declarations[0].init.type === AwaitExpression && node.declarations[0].init.argument && node.declarations[0].init.argument.type === CallExpression && node.declarations[0].init.argument.callee && node.declarations[0].init.argument.callee.type === Import && node.declarations[0].init.argument.arguments && node.declarations[0].init.argument.arguments[0] && node.declarations[0].init.argument.arguments[0].type === StringLiteral) {
|
|
11800
|
-
const relativePath = node.declarations[0].init.argument.arguments[0].extra.rawValue;
|
|
11801
|
-
const start = node.declarations[0].init.argument.arguments[0].start;
|
|
11802
|
-
const end = node.declarations[0].init.argument.arguments[0].end;
|
|
11803
|
-
// @ts-ignore
|
|
11804
|
-
dependencies.push({
|
|
11805
|
-
relativePath,
|
|
11806
|
-
code,
|
|
11807
|
-
start,
|
|
11808
|
-
end
|
|
11809
|
-
});
|
|
11810
|
-
}
|
|
11811
|
-
}
|
|
11812
|
-
const visitor = node => {
|
|
11813
|
-
if (node && node.type === CallExpression && node.callee && node.callee.type === Import && node.arguments && node.arguments[0] && node.arguments[0].type === StringLiteral) {
|
|
11814
|
-
const relativePath = node.arguments[0].extra.rawValue;
|
|
11815
|
-
const start = node.arguments[0].start;
|
|
11816
|
-
const end = node.arguments[0].end;
|
|
11817
|
-
// @ts-ignore
|
|
11818
|
-
dependencies.push({
|
|
11819
|
-
relativePath,
|
|
11820
|
-
code,
|
|
11821
|
-
start,
|
|
11822
|
-
end
|
|
11823
|
-
});
|
|
11824
|
-
}
|
|
11825
|
-
};
|
|
11826
|
-
walk(ast, visitor);
|
|
11827
|
-
return dependencies;
|
|
11828
|
-
};
|
|
11829
|
-
|
|
11830
|
-
const isSyntaxError = error => {
|
|
11831
|
-
return error instanceof SyntaxError;
|
|
11832
|
-
};
|
|
11833
|
-
|
|
11834
|
-
const isBabelError = error => {
|
|
11835
|
-
// @ts-ignore
|
|
11836
|
-
return isSyntaxError(error) && error.code === BABEL_PARSER_SYNTAX_ERROR;
|
|
11837
|
-
};
|
|
11838
|
-
|
|
11839
|
-
const getAbsoluteUrl = (relativePath, sourceUrl) => {
|
|
11840
|
-
if (sourceUrl.startsWith('/')) {
|
|
11841
|
-
const origin = getOrigin();
|
|
11842
|
-
const absoluteSourceUrl = new URL(sourceUrl, origin).toString();
|
|
11843
|
-
return new URL(relativePath, absoluteSourceUrl).toString();
|
|
11844
|
-
}
|
|
11845
|
-
return new URL(relativePath, sourceUrl).toString();
|
|
11846
|
-
};
|
|
11847
|
-
|
|
11848
|
-
const isExternal = url => {
|
|
11849
|
-
if (url.startsWith('/')) {
|
|
11850
|
-
return false;
|
|
11851
|
-
}
|
|
11852
|
-
if (url.startsWith(location.protocol)) {
|
|
11853
|
-
return false;
|
|
11854
|
-
}
|
|
11855
|
-
return true;
|
|
11856
|
-
};
|
|
11857
|
-
const isNpmDependency = relativePath => {
|
|
11858
|
-
return relativePath.startsWith('@') && relativePath.includes('/');
|
|
11859
|
-
};
|
|
11860
|
-
const getErrorInDependencies = async ({
|
|
11861
|
-
url,
|
|
11862
|
-
dependencies,
|
|
11863
|
-
workerName,
|
|
11864
|
-
seenUrls
|
|
11865
|
-
}) => {
|
|
11866
|
-
for (const dependency of dependencies) {
|
|
11867
|
-
if (isNpmDependency(dependency.relativePath)) {
|
|
11868
|
-
throw new DependencyNotFoundError(dependency.code, dependency.start, dependency.end, dependency.relativePath, '', url);
|
|
11869
|
-
}
|
|
11870
|
-
const dependencyUrl = getAbsoluteUrl(dependency.relativePath, url);
|
|
11871
|
-
if (isExternal(dependencyUrl) || seenUrls.includes(dependencyUrl)) {
|
|
11872
|
-
continue;
|
|
11873
|
-
}
|
|
11874
|
-
seenUrls.push(dependencyUrl);
|
|
11875
|
-
// let dependencyResponse
|
|
11876
|
-
// try {
|
|
11877
|
-
const dependencyResponse = await fetch(dependencyUrl);
|
|
11878
|
-
// } catch (error) {}
|
|
11879
|
-
if (dependencyResponse.ok) {
|
|
11880
|
-
// @ts-expect-error
|
|
11881
|
-
await tryToGetActualErrorMessage$1({
|
|
11882
|
-
url: dependencyUrl,
|
|
11883
|
-
response: dependencyResponse,
|
|
11884
|
-
seenUrls,
|
|
11885
|
-
workerName
|
|
11886
|
-
});
|
|
11887
|
-
} else {
|
|
11888
|
-
switch (dependencyResponse.status) {
|
|
11889
|
-
case NotFound:
|
|
11890
|
-
throw new DependencyNotFoundError(dependency.code, dependency.start, dependency.end, dependency.relativePath, dependencyUrl, url);
|
|
11891
|
-
// return `Failed to import ${url}: ${error}`
|
|
11892
|
-
}
|
|
11893
|
-
}
|
|
11894
|
-
}
|
|
11895
|
-
};
|
|
11896
|
-
|
|
11897
|
-
/**
|
|
11898
|
-
*
|
|
11899
|
-
* @param {{error?:any, url:string, response?:Response, workerName?:string, seenUrls?:[]}} options
|
|
11900
|
-
* @returns
|
|
11901
|
-
*/
|
|
11902
|
-
const tryToGetActualErrorMessage$1 = async ({
|
|
11903
|
-
error,
|
|
11904
|
-
url,
|
|
11905
|
-
response,
|
|
11906
|
-
workerName,
|
|
11907
|
-
seenUrls = []
|
|
11908
|
-
}) => {
|
|
11909
|
-
let text;
|
|
11910
|
-
try {
|
|
11911
|
-
text = await response.text();
|
|
11912
|
-
} catch {
|
|
11913
|
-
if (workerName) {
|
|
11914
|
-
return `Failed to start ${workerName}: Unknown Network Error (${response.status})`;
|
|
11915
|
-
}
|
|
11916
|
-
return `Failed to import ${url}: Unknown Network Error (${response.status})`;
|
|
11917
|
-
}
|
|
11918
|
-
let ast;
|
|
11919
|
-
try {
|
|
11920
|
-
ast = await parse(text, {
|
|
11921
|
-
sourceType: Module
|
|
11922
|
-
});
|
|
11923
|
-
} catch (error) {
|
|
11924
|
-
if (isBabelError(error)) {
|
|
11925
|
-
throw new BabelParseError(url, error);
|
|
11926
|
-
}
|
|
11927
|
-
throw error;
|
|
11928
|
-
}
|
|
11929
|
-
const dependencies = getBabelAstDependencies(text, ast);
|
|
11930
|
-
await getErrorInDependencies({
|
|
11931
|
-
url,
|
|
11932
|
-
dependencies,
|
|
11933
|
-
seenUrls,
|
|
11934
|
-
workerName
|
|
11935
|
-
});
|
|
11936
|
-
if (hasRecentErrors()) {
|
|
11937
|
-
const recentError = getRecentError();
|
|
11938
|
-
// @ts-expect-error
|
|
11939
|
-
throw new ContentSecurityPolicyError(recentError.violatedDirective, recentError.sourceFile, recentError.lineNumber, recentError.columnNumber);
|
|
11940
|
-
}
|
|
11941
|
-
if (workerName) {
|
|
11942
|
-
return `Failed to start ${workerName}: Unknown Network Error (${response.status})`;
|
|
11943
|
-
}
|
|
11944
|
-
return `Failed to import ${url}: Unknown Network Error (${response.status})`;
|
|
11945
|
-
};
|
|
11946
|
-
|
|
11947
|
-
const javaScriptContentTypes = ['application/javascript', 'text/javascript', 'application/javascript; charset=UTF-8'];
|
|
11948
|
-
const isJavaScriptContentType = contentType => {
|
|
11949
|
-
return javaScriptContentTypes.includes(contentType);
|
|
11950
|
-
};
|
|
11951
|
-
|
|
11952
|
-
const tryToGetActualErrorMessage = async ({
|
|
11953
|
-
url,
|
|
11954
|
-
name
|
|
11955
|
-
}) => {
|
|
11956
|
-
const displayName = getWorkerDisplayName(name);
|
|
11957
|
-
let response;
|
|
11958
|
-
try {
|
|
11959
|
-
response = await fetch(url);
|
|
11960
|
-
} catch (error) {
|
|
11961
|
-
return `Failed to start ${displayName}: ${error}`;
|
|
11962
|
-
}
|
|
11963
|
-
if (response.ok) {
|
|
11964
|
-
const contentType = response.headers.get('Content-Type');
|
|
11965
|
-
if (!isJavaScriptContentType(contentType)) {
|
|
11966
|
-
return `Failed to start ${displayName}: Content type for worker must be application/javascript but is ${contentType}`;
|
|
11967
|
-
}
|
|
11968
|
-
const crossOriginEmbedderPolicy = response.headers.get('Cross-Origin-Embedder-Policy');
|
|
11969
|
-
if (!crossOriginEmbedderPolicy) {
|
|
11970
|
-
return `Failed to start ${displayName}: Cross Origin Embedder Policy header is missing`;
|
|
11971
|
-
}
|
|
11972
|
-
if (crossOriginEmbedderPolicy !== 'require-corp') {
|
|
11973
|
-
return `Failed to start ${displayName}: Cross Origin Embedder Policy has wrong value`;
|
|
11974
|
-
}
|
|
11975
|
-
// @ts-expect-error
|
|
11976
|
-
return tryToGetActualErrorMessage$1({
|
|
11977
|
-
url,
|
|
11978
|
-
response,
|
|
11979
|
-
workerName: displayName
|
|
11980
|
-
});
|
|
11981
|
-
}
|
|
11982
|
-
switch (response.status) {
|
|
11983
|
-
case NotFound:
|
|
11984
|
-
throw new Error(`Failed to start ${displayName}: Not found (404)`);
|
|
11985
|
-
default:
|
|
11986
|
-
return `Failed to start ${displayName}: Unknown Network Error`;
|
|
11987
|
-
}
|
|
11988
|
-
};
|
|
11989
|
-
|
|
11990
|
-
const TryToGetActualWorkerErrorMessage = {
|
|
11991
|
-
__proto__: null,
|
|
11992
|
-
tryToGetActualErrorMessage
|
|
11993
|
-
};
|