@lvce-editor/renderer-process 7.0.2 → 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.
@@ -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$c = {
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$c.load(moduleId);
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$c.pendingModules[moduleId]) {
307
- state$c.pendingModules[moduleId] = loadModule$1(moduleId);
305
+ if (!state$b.pendingModules[moduleId]) {
306
+ state$b.pendingModules[moduleId] = loadModule$1(moduleId);
308
307
  }
309
- return state$c.pendingModules[moduleId];
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$c.commands[commandId] = listener;
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$c.commands)) {
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$c.commands) {
335
- const fn = state$c.commands[command];
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$c.load = load;
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$2 = (string, startIndex = undefined) => {
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$2(lowerStack);
687
+ const indexNewLine = getNewLineIndex$1(lowerStack);
717
688
  const parentStack = getParentStack(error);
718
689
  // @ts-ignore
719
690
  restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
@@ -740,67 +711,6 @@ const unwrapJsonRpcResult = responseMessage => {
740
711
  }
741
712
  throw new JsonRpcError('unexpected response message');
742
713
  };
743
- const isMessagePort$1 = value => {
744
- return typeof MessagePort !== 'undefined' && value instanceof MessagePort;
745
- };
746
- const isInstanceOf = (value, constructorName) => {
747
- return value?.constructor?.name === constructorName;
748
- };
749
- const isMessagePortMain = value => {
750
- return isInstanceOf(value, 'MessagePortMain');
751
- };
752
- const isOffscreenCanvas = value => {
753
- return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
754
- };
755
- const isSocket = value => {
756
- return isInstanceOf(value, 'Socket');
757
- };
758
- const transferrables = [isMessagePort$1, isMessagePortMain, isOffscreenCanvas, isSocket];
759
- const isTransferrable$1 = value => {
760
- for (const fn of transferrables) {
761
- if (fn(value)) {
762
- return true;
763
- }
764
- }
765
- return false;
766
- };
767
- const walkValue$1 = (value, transferrables) => {
768
- if (!value) {
769
- return;
770
- }
771
- if (isTransferrable$1(value)) {
772
- transferrables.push(value);
773
- }
774
- if (Array.isArray(value)) {
775
- for (const item of value) {
776
- walkValue$1(item, transferrables);
777
- }
778
- return;
779
- }
780
- if (typeof value === 'object') {
781
- for (const property of Object.values(value)) {
782
- walkValue$1(property, transferrables);
783
- }
784
- }
785
- };
786
- const getTransferrables = value => {
787
- const transferrables = [];
788
- walkValue$1(value, transferrables);
789
- return transferrables;
790
- };
791
- const isSingleTransferrable = value => {
792
- return isSocket(value);
793
- };
794
- const getTransferrableParams = value => {
795
- const transferrables = getTransferrables(value);
796
- if (transferrables.length === 0) {
797
- return undefined;
798
- }
799
- if (isSingleTransferrable(transferrables[0])) {
800
- return transferrables[0];
801
- }
802
- return transferrables;
803
- };
804
714
  const create$1$1 = (message, error) => {
805
715
  return {
806
716
  jsonrpc: Two,
@@ -834,7 +744,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
834
744
  const errorProperty = getErrorProperty(error, prettyError);
835
745
  return create$1$1(message, errorProperty);
836
746
  };
837
- const create$M = (message, result) => {
747
+ const create$L = (message, result) => {
838
748
  return {
839
749
  jsonrpc: Two,
840
750
  id: message.id,
@@ -843,7 +753,7 @@ const create$M = (message, result) => {
843
753
  };
844
754
  const getSuccessResponse = (message, result) => {
845
755
  const resultProperty = result ?? null;
846
- return create$M(message, resultProperty);
756
+ return create$L(message, resultProperty);
847
757
  };
848
758
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
849
759
  try {
@@ -927,17 +837,15 @@ const invoke$2 = async (ipc, method, ...params) => {
927
837
  // TODO deprecated old typings,
928
838
  // always use automatic transferrable detection
929
839
  const invokeAndTransfer$1 = async (ipc, handle, method, ...params) => {
930
- let transfer = handle;
931
840
  if (typeof handle === 'string') {
932
841
  params = [method, ...params];
933
842
  method = handle;
934
- transfer = getTransferrableParams(params);
935
843
  }
936
844
  const {
937
845
  message,
938
846
  promise
939
847
  } = create$2$1(method, params);
940
- ipc.sendAndTransfer(message, transfer);
848
+ ipc.sendAndTransfer(message);
941
849
  const responseMessage = await promise;
942
850
  const result = unwrapJsonRpcResult(responseMessage);
943
851
  return result;
@@ -999,7 +907,7 @@ const getModule$1 = method => {
999
907
  }
1000
908
  };
1001
909
 
1002
- const create$L = async ({
910
+ const create$K = async ({
1003
911
  method,
1004
912
  ...options
1005
913
  }) => {
@@ -1008,6 +916,49 @@ const create$L = async ({
1008
916
  return module.create(options);
1009
917
  };
1010
918
 
919
+ const transferrables$1 = [];
920
+ if (typeof MessagePort !== 'undefined') {
921
+ transferrables$1.push(MessagePort);
922
+ }
923
+ if (typeof OffscreenCanvas !== 'undefined') {
924
+ transferrables$1.push(OffscreenCanvas);
925
+ }
926
+
927
+ const isTransferrable$1 = value => {
928
+ for (const fn of transferrables$1) {
929
+ if (value instanceof fn) {
930
+ return true;
931
+ }
932
+ }
933
+ return false;
934
+ };
935
+
936
+ const walkValue$1 = (value, transferrables) => {
937
+ if (!value) {
938
+ return;
939
+ }
940
+ if (isTransferrable$1(value)) {
941
+ transferrables.push(value);
942
+ }
943
+ if (Array.isArray(value)) {
944
+ for (const item of value) {
945
+ walkValue$1(item, transferrables);
946
+ }
947
+ return;
948
+ }
949
+ if (typeof value === 'object') {
950
+ for (const property of Object.values(value)) {
951
+ walkValue$1(property, transferrables);
952
+ }
953
+ }
954
+ };
955
+
956
+ const getTransfer = value => {
957
+ const transferrables = [];
958
+ walkValue$1(value, transferrables);
959
+ return transferrables;
960
+ };
961
+
1011
962
  const getData$2 = event => {
1012
963
  // TODO why are some events not instance of message event?
1013
964
  if (event instanceof MessageEvent) {
@@ -1019,7 +970,7 @@ const launchWorker = async ({
1019
970
  name,
1020
971
  url
1021
972
  }) => {
1022
- const worker = await create$L({
973
+ const worker = await create$K({
1023
974
  method: Auto,
1024
975
  url,
1025
976
  name
@@ -1031,9 +982,10 @@ const launchWorker = async ({
1031
982
  // @ts-ignore
1032
983
  this.worker.postMessage(message);
1033
984
  },
1034
- sendAndTransfer(message, transferables) {
985
+ sendAndTransfer(message) {
986
+ const transfer = getTransfer(message);
1035
987
  // @ts-ignore
1036
- this.worker.postMessage(message, transferables);
988
+ this.worker.postMessage(message, transfer);
1037
989
  },
1038
990
  get onmessage() {
1039
991
  return this.handleMessage;
@@ -1109,9 +1061,9 @@ const send = (method, ...params) => {
1109
1061
  const invoke$1 = (method, ...params) => {
1110
1062
  return invoke$2(state$9.ipc, method, ...params);
1111
1063
  };
1112
- const sendAndTransfer = (message, transfer) => {
1064
+ const sendAndTransfer = message => {
1113
1065
  // @ts-expect-error
1114
- state$9.ipc.sendAndTransfer(message, transfer);
1066
+ state$9.ipc.sendAndTransfer(message);
1115
1067
  };
1116
1068
  const invokeAndTransfer = (method, ...params) => {
1117
1069
  return invokeAndTransfer$1(state$9.ipc, method, ...params);
@@ -1187,65 +1139,6 @@ const boolean = value => {
1187
1139
  }
1188
1140
  };
1189
1141
 
1190
- /**
1191
- *
1192
- * @returns {Promise<any>}
1193
- */
1194
- const loadKy = async () => {
1195
- const url = `${assetDir}/js/ky.js`;
1196
- const module = await import(url);
1197
- return module;
1198
- };
1199
-
1200
- const getJson = async (url, options = {}) => {
1201
- const {
1202
- default: ky,
1203
- HTTPError
1204
- } = await loadKy();
1205
- try {
1206
- string(url);
1207
- // cannot use ky(url).json() because it sets "accept: application/json"
1208
- // which doesn't work with preload, see
1209
- // https://stackoverflow.com/questions/41655955/why-are-preload-link-not-working-for-json-requests#answer-48645748
1210
- const response = await ky(url, options);
1211
- return response.json();
1212
- } catch (error) {
1213
- if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
1214
- // @ts-expect-error
1215
- throw new VError$1(`Failed to request json from "${url}". Make sure that the server is running and has CORS enabled`);
1216
- }
1217
- if (error && error instanceof HTTPError) {
1218
- let json;
1219
- try {
1220
- // @ts-ignore
1221
- json = await error.response.json();
1222
- } catch {
1223
- throw error;
1224
- }
1225
- if (json?.message) {
1226
- // @ts-expect-error
1227
- throw new VError$1(`Failed to request json from "${url}": ${json.message}`);
1228
- }
1229
- }
1230
- // @ts-ignore
1231
- error.message = `Failed to request json from "${url}": ${error.message}`;
1232
- throw error;
1233
- }
1234
- };
1235
- const getText$1 = async (url, options = {}) => {
1236
- try {
1237
- const {
1238
- default: ky
1239
- } = await loadKy();
1240
- return await ky(url, options).text();
1241
- } catch (error) {
1242
- if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
1243
- throw new VError$1(error, `Failed to request text from "${url}". Make sure that the server is running and has CORS enabled`);
1244
- }
1245
- throw new VError$1(error, `Failed to request text from "${url}"`);
1246
- }
1247
- };
1248
-
1249
1142
  const NewLine$2 = '\n';
1250
1143
 
1251
1144
  const splitLines$1 = lines => {
@@ -1339,129 +1232,6 @@ const cleanStack = stack => {
1339
1232
  return merged;
1340
1233
  };
1341
1234
 
1342
- // based on https://github.com/babel/babel/blob/6be6e04f396f03feace4431f709564a8d842163a/packages/babel-code-frame/src/index.ts (License MIT)
1343
-
1344
- /**
1345
- * RegExp to test for newlines in terminal.
1346
- */
1347
-
1348
- const NEWLINE = /\n/;
1349
-
1350
- /**
1351
- * Extract what lines should be marked and highlighted.
1352
- */
1353
- const getMarkerLines = (loc, source, opts) => {
1354
- const startLoc = {
1355
- column: 0,
1356
- line: -1,
1357
- ...loc.start
1358
- };
1359
- const endLoc = {
1360
- ...startLoc,
1361
- ...loc.end
1362
- };
1363
- const {
1364
- linesAbove = 2,
1365
- linesBelow = 3
1366
- } = opts || {};
1367
- const startLine = startLoc.line;
1368
- const startColumn = startLoc.column;
1369
- const endLine = endLoc.line;
1370
- const endColumn = endLoc.column;
1371
- let start = Math.max(startLine - (linesAbove + 1), 0);
1372
- let end = Math.min(source.length, endLine + linesBelow);
1373
- if (startLine === -1) {
1374
- start = 0;
1375
- }
1376
- if (endLine === -1) {
1377
- end = source.length;
1378
- }
1379
- const lineDiff = endLine - startLine;
1380
- const markerLines = {};
1381
- if (lineDiff) {
1382
- for (let i = 0; i <= lineDiff; i++) {
1383
- const lineNumber = i + startLine;
1384
- if (!startColumn) {
1385
- markerLines[lineNumber] = true;
1386
- } else if (i === 0) {
1387
- const sourceLength = source[lineNumber - 1].length;
1388
- markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
1389
- } else if (i === lineDiff) {
1390
- markerLines[lineNumber] = [0, endColumn];
1391
- } else {
1392
- const sourceLength = source[lineNumber - i].length;
1393
- markerLines[lineNumber] = [0, sourceLength];
1394
- }
1395
- }
1396
- } else {
1397
- if (startColumn === endColumn) {
1398
- if (startColumn) {
1399
- markerLines[startLine] = [startColumn, 0];
1400
- } else {
1401
- markerLines[startLine] = true;
1402
- }
1403
- } else {
1404
- markerLines[startLine] = [startColumn, endColumn - startColumn];
1405
- }
1406
- }
1407
- return {
1408
- start,
1409
- end,
1410
- markerLines
1411
- };
1412
- };
1413
- const create$K = (rawLines, loc, opts = {}) => {
1414
- const lines = rawLines.split(NEWLINE);
1415
- const {
1416
- start,
1417
- end,
1418
- markerLines
1419
- } = getMarkerLines(loc, lines, opts);
1420
- const hasColumns = loc.start && typeof loc.start.column === 'number';
1421
- const numberMaxWidth = String(end).length;
1422
- let frame = rawLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
1423
- const number = start + 1 + index;
1424
- const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
1425
- const gutter = ` ${paddedNumber} |`;
1426
- const hasMarker = markerLines[number];
1427
- const lastMarkerLine = !markerLines[number + 1];
1428
- if (hasMarker) {
1429
- let markerLine = '';
1430
- if (Array.isArray(hasMarker)) {
1431
- const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, ' ');
1432
- const numberOfMarkers = hasMarker[1] || 1;
1433
- markerLine = ['\n ', gutter.replace(/\d/g, ' '), ' ', markerSpacing, '^'.repeat(numberOfMarkers)].join('');
1434
-
1435
- // @ts-ignore
1436
- if (lastMarkerLine && opts.message) {
1437
- // @ts-ignore
1438
- markerLine += ' ' + opts.message;
1439
- }
1440
- }
1441
- return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('');
1442
- } else {
1443
- return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`;
1444
- }
1445
- }).join(NewLine$2);
1446
-
1447
- // @ts-ignore
1448
- if (opts.message && !hasColumns) {
1449
- // @ts-ignore
1450
- frame = `${' '.repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
1451
- }
1452
- return frame;
1453
- };
1454
-
1455
- /**
1456
- *
1457
- * @param {string} string
1458
- * @param {number|undefined} startIndex
1459
- * @returns
1460
- */
1461
- const getNewLineIndex$1 = (string, startIndex = undefined) => {
1462
- return string.indexOf(NewLine$2, startIndex);
1463
- };
1464
-
1465
1235
  const isActualSourceFile = path => {
1466
1236
  if (path === '<anonymous>' || path === 'debugger eval code' || path.startsWith('"') || path.startsWith(`'`) || path.startsWith(')') || path.startsWith('file://')) {
1467
1237
  return false;
@@ -1501,139 +1271,6 @@ const info = (...args) => {
1501
1271
  console.info(...args);
1502
1272
  };
1503
1273
 
1504
- const isEmptyString = string => {
1505
- return string === '';
1506
- };
1507
-
1508
- // copied from https://github.com/Rich-Harris/vlq/blob/e3009f5757abeb0b5b6233045f3bbdaf86435d08/src/index.js by Rich Harris (License MIT)
1509
-
1510
- /** @type {Record<string, number>} */
1511
- const char_to_integer = {};
1512
- for (const [i, char] of 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').entries()) {
1513
- char_to_integer[char] = i;
1514
- }
1515
-
1516
- /** @param {string} string */
1517
- const decode = string => {
1518
- /** @type {number[]} */
1519
- const result = [];
1520
- let shift = 0;
1521
- let value = 0;
1522
- for (let i = 0; i < string.length; i += 1) {
1523
- let integer = char_to_integer[string[i]];
1524
- if (integer === undefined) {
1525
- throw new Error('Invalid character (' + string[i] + ')');
1526
- }
1527
- const has_continuation_bit = integer & 32;
1528
- integer &= 31;
1529
- value += integer << shift;
1530
- if (has_continuation_bit) {
1531
- shift += 5;
1532
- } else {
1533
- const should_negate = value & 1;
1534
- value >>>= 1;
1535
- if (should_negate) {
1536
- // @ts-expect-error
1537
- result.push(value === 0 ? -0x80000000 : -value);
1538
- } else {
1539
- // @ts-expect-error
1540
- result.push(value);
1541
- }
1542
-
1543
- // reset
1544
- value = shift = 0;
1545
- }
1546
- }
1547
- return result;
1548
- };
1549
-
1550
- const getColumnMapping = (mappings, line, column) => {
1551
- string(mappings);
1552
- number(line);
1553
- number(column);
1554
- let currentColumn = 0;
1555
- let currentLine = 1;
1556
- let originalSourceFileIndex = 0;
1557
- let originalLine = 0;
1558
- let originalColumn = 0;
1559
- let index = 0;
1560
- while (index !== -1) {
1561
- currentColumn = 0;
1562
- const newLineIndex = mappings.indexOf(';', index + 1);
1563
- currentLine++;
1564
- if (currentLine === line) {
1565
- const lineMapping = mappings.slice(index + 1, newLineIndex) + ',';
1566
- index = -1;
1567
- while (true) {
1568
- const newIndex = lineMapping.indexOf(',', index + 1);
1569
- if (newIndex === -1) {
1570
- throw new Error('no mapping found');
1571
- }
1572
- const chunk = lineMapping.slice(index + 1, newIndex);
1573
- const decodedChunk = decode(chunk);
1574
- currentColumn += decodedChunk[0];
1575
- originalSourceFileIndex += decodedChunk[1];
1576
- originalLine += decodedChunk[2];
1577
- originalColumn += decodedChunk[3];
1578
- index = newIndex;
1579
- if (currentColumn >= column) {
1580
- return {
1581
- originalSourceFileIndex,
1582
- originalLine: originalLine + 1,
1583
- originalColumn
1584
- };
1585
- }
1586
- }
1587
- } else {
1588
- const lineMappings = mappings.slice(index + 1, newLineIndex);
1589
- if (isEmptyString(lineMappings)) {
1590
- index = newLineIndex;
1591
- continue;
1592
- }
1593
- const chunks = lineMappings.split(',');
1594
- for (const chunk of chunks) {
1595
- const decodedChunk = decode(chunk);
1596
- currentColumn += decodedChunk[0];
1597
- originalSourceFileIndex += decodedChunk[1];
1598
- originalLine += decodedChunk[2];
1599
- originalColumn += decodedChunk[3];
1600
- }
1601
- }
1602
- index = newLineIndex;
1603
- }
1604
- throw new Error(`no mapping found`);
1605
- };
1606
- const getOriginalPosition = (sourceMap, line, column) => {
1607
- try {
1608
- object(sourceMap);
1609
- string(sourceMap.mappings);
1610
- array(sourceMap.sources);
1611
- array(sourceMap.names);
1612
- number(line);
1613
- number(column);
1614
- const {
1615
- sources,
1616
- mappings
1617
- } = sourceMap;
1618
- if (!mappings) {
1619
- throw new Error(`no source for line ${line} found`);
1620
- }
1621
- const {
1622
- originalLine,
1623
- originalColumn,
1624
- originalSourceFileIndex
1625
- } = getColumnMapping(mappings, line, column);
1626
- const source = sources[originalSourceFileIndex];
1627
- return {
1628
- source,
1629
- originalLine,
1630
- originalColumn
1631
- };
1632
- } catch (error) {
1633
- throw new VError$1(error, `Failed to get original sourcemap position`);
1634
- }
1635
- };
1636
-
1637
1274
  const getErrorMessage = error => {
1638
1275
  if (!error) {
1639
1276
  return `Error: ${error}`;
@@ -1680,8 +1317,6 @@ const RE_PATH_1 = /\((.*):(\d+):(\d+)\)$/;
1680
1317
  const RE_PATH_2 = /at (.*):(\d+):(\d+)$/;
1681
1318
  const RE_PATH_3 = /@(.*):(\d+):(\d+)$/; // Firefox
1682
1319
 
1683
- const RE_SOURCE_MAP = /^\/\/# sourceMappingURL=(.*)$/;
1684
-
1685
1320
  /**
1686
1321
  *
1687
1322
  * @param {readonly string[]} lines
@@ -1695,29 +1330,6 @@ const getFile = lines => {
1695
1330
  }
1696
1331
  return '';
1697
1332
  };
1698
- const getSourceMapAbsolutePath = (file, relativePath) => {
1699
- const folder = file.slice(0, file.lastIndexOf('/'));
1700
- const absolutePath = folder + '/' + relativePath;
1701
- return absolutePath;
1702
- };
1703
- const toAbsoluteUrl = (file, relativePath) => {
1704
- const url = new URL(relativePath, file);
1705
- return url.href;
1706
- };
1707
- const getSourceMapMatch = text => {
1708
- string(text);
1709
- const index = text.lastIndexOf(NewLine$2, text.length - 2);
1710
- const lastLine = text.slice(index + 1, -1);
1711
- const lastLineMatch = lastLine.match(RE_SOURCE_MAP);
1712
- if (lastLineMatch) {
1713
- return lastLineMatch;
1714
- }
1715
- // @ts-ignore
1716
- const secondLastLineIndex = getNewLineIndex$1(text, index - 1);
1717
- const secondLastLine = text.slice(secondLastLineIndex, index);
1718
- const secondLastLineMatch = secondLastLine.match(RE_SOURCE_MAP);
1719
- return secondLastLineMatch;
1720
- };
1721
1333
  const prepareErrorMessageWithoutCodeFrame = async error => {
1722
1334
  try {
1723
1335
  const lines = cleanStack(error.stack);
@@ -1732,59 +1344,12 @@ const prepareErrorMessageWithoutCodeFrame = async error => {
1732
1344
  if (!match) {
1733
1345
  return error;
1734
1346
  }
1735
- const [_, path, line, column] = match;
1347
+ const [_, path] = match;
1736
1348
  if (!isActualSourceFile(path)) {
1737
1349
  return error;
1738
1350
  }
1739
- const text = await getText$1(path);
1740
- const sourceMapMatch = getSourceMapMatch(text);
1741
- const parsedLine = parseInt(line);
1742
- const parsedColumn = parseInt(column);
1743
- const message = getErrorMessage(error);
1744
- const relevantStack = joinLines$1(lines);
1745
- if (sourceMapMatch) {
1746
- const sourceMapUrl = sourceMapMatch[1];
1747
- const sourceMapAbsolutePath = getSourceMapAbsolutePath(path, sourceMapUrl);
1748
- const sourceMap = await getJson(sourceMapAbsolutePath);
1749
- const {
1750
- source,
1751
- originalLine,
1752
- originalColumn
1753
- } = getOriginalPosition(sourceMap, parsedLine, parsedColumn);
1754
- const absoluteSourceUrl = toAbsoluteUrl(path, source);
1755
- const originalSourceContent = await getText$1(absoluteSourceUrl);
1756
- const codeFrame = create$K(originalSourceContent, {
1757
- start: {
1758
- line: originalLine,
1759
- column: originalColumn
1760
- },
1761
- end: {
1762
- line: originalLine,
1763
- column: originalColumn
1764
- }
1765
- });
1766
- return {
1767
- message,
1768
- codeFrame,
1769
- stack: relevantStack,
1770
- type: error.constructor.name,
1771
- _error: error
1772
- };
1773
- }
1774
- const codeFrame = create$K(text, {
1775
- start: {
1776
- line: parsedLine,
1777
- column: parsedColumn
1778
- },
1779
- end: {
1780
- line: parsedLine,
1781
- column: parsedColumn
1782
- }
1783
- });
1784
1351
  return {
1785
- message,
1786
- codeFrame,
1787
- stack: relevantStack,
1352
+ message: error?.message || '',
1788
1353
  type: error.constructor.name,
1789
1354
  _error: error
1790
1355
  };
@@ -3415,9 +2980,6 @@ const ImagePreview_ipc = {
3415
2980
  name: name$o
3416
2981
  };
3417
2982
 
3418
- const getOrigin = () => {
3419
- return location.origin;
3420
- };
3421
2983
  const getPathName = () => {
3422
2984
  return location.pathname;
3423
2985
  };
@@ -3481,7 +3043,7 @@ const InitData_ipc = {
3481
3043
 
3482
3044
  const name$m = 'IpcParent';
3483
3045
  const Commands$n = {
3484
- create: create$L
3046
+ create: create$K
3485
3047
  };
3486
3048
 
3487
3049
  const IpcParent_ipc = {
@@ -5482,6 +5044,56 @@ const ModuleWorkerAndMessagePort = 8;
5482
5044
  const getData$1 = event => {
5483
5045
  return event.data;
5484
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
+ };
5068
+ const isMessagePort$1 = value => {
5069
+ return value && value instanceof MessagePort;
5070
+ };
5071
+ const isMessagePortMain = value => {
5072
+ return value && value.constructor && value.constructor.name === 'MessagePortMain';
5073
+ };
5074
+ const isOffscreenCanvas = value => {
5075
+ return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
5076
+ };
5077
+ const isInstanceOf = (value, constructorName) => {
5078
+ return value?.constructor?.name === constructorName;
5079
+ };
5080
+ const isSocket = value => {
5081
+ return isInstanceOf(value, 'Socket');
5082
+ };
5083
+ const transferrables = [isMessagePort$1, isMessagePortMain, isOffscreenCanvas, isSocket];
5084
+ const isTransferrable = value => {
5085
+ for (const fn of transferrables) {
5086
+ if (fn(value)) {
5087
+ return true;
5088
+ }
5089
+ }
5090
+ return false;
5091
+ };
5092
+ const getTransferrables = value => {
5093
+ const transferrables = [];
5094
+ walkValue(value, transferrables, isTransferrable);
5095
+ return transferrables;
5096
+ };
5485
5097
  const attachEvents$a = that => {
5486
5098
  const handleMessage = (...args) => {
5487
5099
  const data = that.getData(...args);
@@ -5521,7 +5133,8 @@ class IpcChildWithModuleWorker extends Ipc {
5521
5133
  // @ts-ignore
5522
5134
  this._rawIpc.postMessage(message);
5523
5135
  }
5524
- sendAndTransfer(message, transfer) {
5136
+ sendAndTransfer(message) {
5137
+ const transfer = getTransferrables(message);
5525
5138
  // @ts-ignore
5526
5139
  this._rawIpc.postMessage(message, transfer);
5527
5140
  }
@@ -5786,7 +5399,8 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
5786
5399
  send(message) {
5787
5400
  this._rawIpc.postMessage(message);
5788
5401
  }
5789
- sendAndTransfer(message, transfer) {
5402
+ sendAndTransfer(message) {
5403
+ const transfer = getTransferrables(message);
5790
5404
  this._rawIpc.postMessage(message, transfer);
5791
5405
  }
5792
5406
  dispose() {
@@ -5810,24 +5424,15 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
5810
5424
  listen: listen$3,
5811
5425
  wrap: wrap$5
5812
5426
  };
5813
- const isTransferrable = value => {
5814
- return value instanceof MessagePort;
5815
- };
5816
- const UntransferrableValue = {};
5817
- const walkValue = (value, transferrables) => {
5427
+ const removeValues = (value, toRemove) => {
5818
5428
  if (!value) {
5819
5429
  return value;
5820
5430
  }
5821
- if (isTransferrable(value)) {
5822
- transferrables.push(value);
5823
- return UntransferrableValue;
5824
- }
5825
5431
  if (Array.isArray(value)) {
5826
5432
  const newItems = [];
5827
5433
  for (const item of value) {
5828
- const newItem = walkValue(item, transferrables);
5829
- if (newItem !== UntransferrableValue) {
5830
- newItems.push(newItem);
5434
+ if (!toRemove.includes(item)) {
5435
+ newItems.push(removeValues(item, toRemove));
5831
5436
  }
5832
5437
  }
5833
5438
  return newItems;
@@ -5835,9 +5440,8 @@ const walkValue = (value, transferrables) => {
5835
5440
  if (typeof value === 'object') {
5836
5441
  const newObject = Object.create(null);
5837
5442
  for (const [key, property] of Object.entries(value)) {
5838
- const newValue = walkValue(property, transferrables);
5839
- if (newValue !== UntransferrableValue) {
5840
- newObject[key] = newValue;
5443
+ if (!toRemove.includes(property)) {
5444
+ newObject[key] = removeValues(property, toRemove);
5841
5445
  }
5842
5446
  }
5843
5447
  return newObject;
@@ -5849,8 +5453,8 @@ const walkValue = (value, transferrables) => {
5849
5453
  // as parameters. If the transferrable object is a parameter, in electron
5850
5454
  // only an empty objected is received in the main process
5851
5455
  const fixElectronParameters = value => {
5852
- const transfer = [];
5853
- const newValue = walkValue(value, transfer);
5456
+ const transfer = getTransferrables(value);
5457
+ const newValue = removeValues(value, transfer);
5854
5458
  return {
5855
5459
  newValue,
5856
5460
  transfer
@@ -5869,7 +5473,7 @@ class IpcChildWithElectronWindow extends Ipc {
5869
5473
  send(message) {
5870
5474
  this._rawIpc.postMessage(message);
5871
5475
  }
5872
- sendAndTransfer(message, _transfer) {
5476
+ sendAndTransfer(message) {
5873
5477
  const {
5874
5478
  newValue,
5875
5479
  transfer
@@ -5923,7 +5527,8 @@ class IpcChildWithMessagePort extends Ipc {
5923
5527
  send(message) {
5924
5528
  this._rawIpc.postMessage(message);
5925
5529
  }
5926
- sendAndTransfer(message, transfer) {
5530
+ sendAndTransfer(message) {
5531
+ const transfer = getTransferrables(message);
5927
5532
  this._rawIpc.postMessage(message, transfer);
5928
5533
  }
5929
5534
  dispose() {
@@ -6075,14 +5680,14 @@ ${relevant}`;
6075
5680
  }
6076
5681
  }
6077
5682
 
6078
- const Module$1 = 'module';
5683
+ const Module = 'module';
6079
5684
 
6080
5685
  const create$B = async ({
6081
5686
  url,
6082
5687
  name
6083
5688
  }) => {
6084
5689
  const worker = new Worker(url, {
6085
- type: Module$1,
5690
+ type: Module,
6086
5691
  name
6087
5692
  });
6088
5693
  // @ts-expect-error
@@ -6100,12 +5705,7 @@ const create$B = async ({
6100
5705
  if (isErrorEvent(event)) {
6101
5706
  throw new WorkerError(event);
6102
5707
  }
6103
- const TryToGetActualWorkerErrorMessage$1 = await Promise.resolve().then(function () { return TryToGetActualWorkerErrorMessage; });
6104
- const actualErrorMessage = await TryToGetActualWorkerErrorMessage$1.tryToGetActualErrorMessage({
6105
- url,
6106
- name
6107
- });
6108
- throw new Error(actualErrorMessage);
5708
+ throw new Error(`Failed to start worker`);
6109
5709
  }
6110
5710
  return worker;
6111
5711
  };
@@ -6139,7 +5739,8 @@ const wrap = worker => {
6139
5739
  send(message) {
6140
5740
  worker.postMessage(message);
6141
5741
  },
6142
- sendAndTransfer(message, transfer) {
5742
+ sendAndTransfer(message) {
5743
+ const transfer = getTransfer(message);
6143
5744
  worker.postMessage(message, transfer);
6144
5745
  }
6145
5746
  };
@@ -11603,364 +11204,3 @@ const ViewletWebView = {
11603
11204
  setIframe,
11604
11205
  setPort
11605
11206
  };
11606
-
11607
- const getWorkerDisplayName = name => {
11608
- if (!name) {
11609
- return '<unknown> worker';
11610
- }
11611
- if (name.endsWith('Worker') || name.endsWith('worker')) {
11612
- return name.toLowerCase();
11613
- }
11614
- return `${name} Worker`;
11615
- };
11616
-
11617
- const NotFound = 404;
11618
-
11619
- const RE_LINE_COLUMN = /(.*)\(\d+:\d+\)/;
11620
- const getBabelErrorMessage = message => {
11621
- const match = message.match(RE_LINE_COLUMN);
11622
- if (match) {
11623
- return match[1].trim();
11624
- }
11625
- return message;
11626
- };
11627
- class BabelParseError extends SyntaxError {
11628
- constructor(url, error) {
11629
- const message = getBabelErrorMessage(error.message);
11630
- super(message);
11631
- this.name = 'BabelParseError';
11632
- const line = error.loc.line;
11633
- const column = error.loc.column + 1;
11634
- this.stack = `${message}
11635
- at ${url}:${line}:${column}`;
11636
- }
11637
- }
11638
-
11639
- const loadBabelParser = () => {
11640
- const url = `${assetDir}/js/babel-parser.js`;
11641
- return import(url);
11642
- };
11643
-
11644
- const parse = async (code, options) => {
11645
- const BabelParse = await loadBabelParser();
11646
- return BabelParse.parse(code, options);
11647
- };
11648
-
11649
- const Module = 'module';
11650
-
11651
- class ContentSecurityPolicyError extends Error {
11652
- constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
11653
- super(`Content Security Policy Violation: ${violatedDirective}`);
11654
- this.name = 'ContentSecurityPolicyError';
11655
- if (sourceFile) {
11656
- this.stack = `Content Security Policy Violation
11657
- at ${sourceFile}:${lineNumber}:${columnNumber}`;
11658
- } else {
11659
- this.stack = `Content Security Policy Violation
11660
- at <unknown>`;
11661
- }
11662
- }
11663
- }
11664
-
11665
- const getLineAndColumn = (text, start, end) => {
11666
- let index = -1;
11667
- let line = 0;
11668
- const column = 0;
11669
- while ((index = text.indexOf('\n', index + 1)) !== -1) {
11670
- line++;
11671
- if (index >= start) {
11672
- break;
11673
- }
11674
- }
11675
- return {
11676
- line,
11677
- column
11678
- };
11679
- };
11680
-
11681
- class DependencyNotFoundError extends Error {
11682
- constructor(code, start, end, dependencyRelativePath, dependencyUrl, sourceUrl) {
11683
- super(`Module not found "${dependencyRelativePath}"`);
11684
- const {
11685
- line,
11686
- column
11687
- } = getLineAndColumn(code, start);
11688
- this.stack = `${this.message}
11689
- at Module (${sourceUrl}:${line}:${column})`;
11690
- }
11691
- }
11692
-
11693
- const ArrowFunctionExpression = 'ArrowFunctionExpression';
11694
- const AwaitExpression = 'AwaitExpression';
11695
- const BlockStatement = 'BlockStatement';
11696
- const CallExpression = 'CallExpression';
11697
- const ExportAllDeclaration = 'ExportAllDeclaration';
11698
- const ExportNamedDeclaration = 'ExportNamedDeclaration';
11699
- const ExpressionStatement = 'ExpressionStatement';
11700
- const File$1 = 'File';
11701
- const Import = 'Import';
11702
- const ImportDeclaration = 'ImportDeclaration';
11703
- const Program = 'Program';
11704
- const StringLiteral = 'StringLiteral';
11705
- const VariableDeclaration = 'VariableDeclaration';
11706
- const VariableDeclarator = 'VariableDeclarator';
11707
-
11708
- const walk = (node, visitor) => {
11709
- if (!node) {
11710
- return;
11711
- }
11712
- if (Array.isArray(node)) {
11713
- for (const item of node) {
11714
- walk(item, visitor);
11715
- }
11716
- return;
11717
- }
11718
- visitor(node);
11719
- switch (node.type) {
11720
- case File$1:
11721
- walk(node.program, visitor);
11722
- break;
11723
- case Program:
11724
- walk(node.body, visitor);
11725
- break;
11726
- case ExportNamedDeclaration:
11727
- walk(node.declaration, visitor);
11728
- break;
11729
- case VariableDeclaration:
11730
- walk(node.declarations, visitor);
11731
- break;
11732
- case VariableDeclarator:
11733
- walk(node.init, visitor);
11734
- break;
11735
- case ArrowFunctionExpression:
11736
- walk(node.body, visitor);
11737
- break;
11738
- case BlockStatement:
11739
- walk(node.body, visitor);
11740
- break;
11741
- case ExpressionStatement:
11742
- walk(node.expression, visitor);
11743
- break;
11744
- case AwaitExpression:
11745
- walk(node.argument, visitor);
11746
- break;
11747
- case CallExpression:
11748
- walk(node.callee, visitor);
11749
- break;
11750
- }
11751
- };
11752
- const getBabelAstDependencies = (code, ast) => {
11753
- const {
11754
- program
11755
- } = ast;
11756
- const {
11757
- body
11758
- } = program;
11759
- const dependencies = [];
11760
- for (const node of body) {
11761
- if (node.type === ImportDeclaration || node.type === ExportAllDeclaration) {
11762
- const relativePath = node.source.extra.rawValue;
11763
- const start = node.source.start;
11764
- const end = node.source.end;
11765
- // @ts-ignore
11766
- dependencies.push({
11767
- relativePath,
11768
- code,
11769
- start,
11770
- end
11771
- });
11772
- } 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) {
11773
- const relativePath = node.declarations[0].init.argument.arguments[0].extra.rawValue;
11774
- const start = node.declarations[0].init.argument.arguments[0].start;
11775
- const end = node.declarations[0].init.argument.arguments[0].end;
11776
- // @ts-ignore
11777
- dependencies.push({
11778
- relativePath,
11779
- code,
11780
- start,
11781
- end
11782
- });
11783
- }
11784
- }
11785
- const visitor = node => {
11786
- if (node && node.type === CallExpression && node.callee && node.callee.type === Import && node.arguments && node.arguments[0] && node.arguments[0].type === StringLiteral) {
11787
- const relativePath = node.arguments[0].extra.rawValue;
11788
- const start = node.arguments[0].start;
11789
- const end = node.arguments[0].end;
11790
- // @ts-ignore
11791
- dependencies.push({
11792
- relativePath,
11793
- code,
11794
- start,
11795
- end
11796
- });
11797
- }
11798
- };
11799
- walk(ast, visitor);
11800
- return dependencies;
11801
- };
11802
-
11803
- const isSyntaxError = error => {
11804
- return error instanceof SyntaxError;
11805
- };
11806
-
11807
- const isBabelError = error => {
11808
- // @ts-ignore
11809
- return isSyntaxError(error) && error.code === BABEL_PARSER_SYNTAX_ERROR;
11810
- };
11811
-
11812
- const getAbsoluteUrl = (relativePath, sourceUrl) => {
11813
- if (sourceUrl.startsWith('/')) {
11814
- const origin = getOrigin();
11815
- const absoluteSourceUrl = new URL(sourceUrl, origin).toString();
11816
- return new URL(relativePath, absoluteSourceUrl).toString();
11817
- }
11818
- return new URL(relativePath, sourceUrl).toString();
11819
- };
11820
-
11821
- const isExternal = url => {
11822
- if (url.startsWith('/')) {
11823
- return false;
11824
- }
11825
- if (url.startsWith(location.protocol)) {
11826
- return false;
11827
- }
11828
- return true;
11829
- };
11830
- const isNpmDependency = relativePath => {
11831
- return relativePath.startsWith('@') && relativePath.includes('/');
11832
- };
11833
- const getErrorInDependencies = async ({
11834
- url,
11835
- dependencies,
11836
- workerName,
11837
- seenUrls
11838
- }) => {
11839
- for (const dependency of dependencies) {
11840
- if (isNpmDependency(dependency.relativePath)) {
11841
- throw new DependencyNotFoundError(dependency.code, dependency.start, dependency.end, dependency.relativePath, '', url);
11842
- }
11843
- const dependencyUrl = getAbsoluteUrl(dependency.relativePath, url);
11844
- if (isExternal(dependencyUrl) || seenUrls.includes(dependencyUrl)) {
11845
- continue;
11846
- }
11847
- seenUrls.push(dependencyUrl);
11848
- // let dependencyResponse
11849
- // try {
11850
- const dependencyResponse = await fetch(dependencyUrl);
11851
- // } catch (error) {}
11852
- if (dependencyResponse.ok) {
11853
- // @ts-expect-error
11854
- await tryToGetActualErrorMessage$1({
11855
- url: dependencyUrl,
11856
- response: dependencyResponse,
11857
- seenUrls,
11858
- workerName
11859
- });
11860
- } else {
11861
- switch (dependencyResponse.status) {
11862
- case NotFound:
11863
- throw new DependencyNotFoundError(dependency.code, dependency.start, dependency.end, dependency.relativePath, dependencyUrl, url);
11864
- // return `Failed to import ${url}: ${error}`
11865
- }
11866
- }
11867
- }
11868
- };
11869
-
11870
- /**
11871
- *
11872
- * @param {{error?:any, url:string, response?:Response, workerName?:string, seenUrls?:[]}} options
11873
- * @returns
11874
- */
11875
- const tryToGetActualErrorMessage$1 = async ({
11876
- error,
11877
- url,
11878
- response,
11879
- workerName,
11880
- seenUrls = []
11881
- }) => {
11882
- let text;
11883
- try {
11884
- text = await response.text();
11885
- } catch {
11886
- if (workerName) {
11887
- return `Failed to start ${workerName}: Unknown Network Error (${response.status})`;
11888
- }
11889
- return `Failed to import ${url}: Unknown Network Error (${response.status})`;
11890
- }
11891
- let ast;
11892
- try {
11893
- ast = await parse(text, {
11894
- sourceType: Module
11895
- });
11896
- } catch (error) {
11897
- if (isBabelError(error)) {
11898
- throw new BabelParseError(url, error);
11899
- }
11900
- throw error;
11901
- }
11902
- const dependencies = getBabelAstDependencies(text, ast);
11903
- await getErrorInDependencies({
11904
- url,
11905
- dependencies,
11906
- seenUrls,
11907
- workerName
11908
- });
11909
- if (hasRecentErrors()) {
11910
- const recentError = getRecentError();
11911
- // @ts-expect-error
11912
- throw new ContentSecurityPolicyError(recentError.violatedDirective, recentError.sourceFile, recentError.lineNumber, recentError.columnNumber);
11913
- }
11914
- if (workerName) {
11915
- return `Failed to start ${workerName}: Unknown Network Error (${response.status})`;
11916
- }
11917
- return `Failed to import ${url}: Unknown Network Error (${response.status})`;
11918
- };
11919
-
11920
- const javaScriptContentTypes = ['application/javascript', 'text/javascript', 'application/javascript; charset=UTF-8'];
11921
- const isJavaScriptContentType = contentType => {
11922
- return javaScriptContentTypes.includes(contentType);
11923
- };
11924
-
11925
- const tryToGetActualErrorMessage = async ({
11926
- url,
11927
- name
11928
- }) => {
11929
- const displayName = getWorkerDisplayName(name);
11930
- let response;
11931
- try {
11932
- response = await fetch(url);
11933
- } catch (error) {
11934
- return `Failed to start ${displayName}: ${error}`;
11935
- }
11936
- if (response.ok) {
11937
- const contentType = response.headers.get('Content-Type');
11938
- if (!isJavaScriptContentType(contentType)) {
11939
- return `Failed to start ${displayName}: Content type for worker must be application/javascript but is ${contentType}`;
11940
- }
11941
- const crossOriginEmbedderPolicy = response.headers.get('Cross-Origin-Embedder-Policy');
11942
- if (!crossOriginEmbedderPolicy) {
11943
- return `Failed to start ${displayName}: Cross Origin Embedder Policy header is missing`;
11944
- }
11945
- if (crossOriginEmbedderPolicy !== 'require-corp') {
11946
- return `Failed to start ${displayName}: Cross Origin Embedder Policy has wrong value`;
11947
- }
11948
- // @ts-expect-error
11949
- return tryToGetActualErrorMessage$1({
11950
- url,
11951
- response,
11952
- workerName: displayName
11953
- });
11954
- }
11955
- switch (response.status) {
11956
- case NotFound:
11957
- throw new Error(`Failed to start ${displayName}: Not found (404)`);
11958
- default:
11959
- return `Failed to start ${displayName}: Unknown Network Error`;
11960
- }
11961
- };
11962
-
11963
- const TryToGetActualWorkerErrorMessage = {
11964
- __proto__: null,
11965
- tryToGetActualErrorMessage
11966
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "7.0.2",
3
+ "version": "8.0.0",
4
4
  "description": "",
5
5
  "main": "dist/diffWorkerMain.js",
6
6
  "type": "module",