@lvce-editor/renderer-process 1.0.0 → 1.1.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.
@@ -51,6 +51,7 @@ const WindowTitle = 39;
51
51
  const KeyBindings$1 = 41;
52
52
  const PointerCapture = 42;
53
53
  const GetFilePathElectron = 43;
54
+ const HandleMessagePort = 44;
54
55
 
55
56
  const getModuleId = commandId => {
56
57
  switch (commandId) {
@@ -201,6 +202,8 @@ const getModuleId = commandId => {
201
202
  return PointerCapture;
202
203
  case 'GetFilePathElectron.getFilePathElectron':
203
204
  return GetFilePathElectron;
205
+ case 'HandleMessagePort.handleMessagePort':
206
+ return HandleMessagePort;
204
207
  default:
205
208
  throw new CommandNotFoundError(commandId);
206
209
  }
@@ -217,7 +220,7 @@ const getCombinedErrorMessage = (error, message) => {
217
220
  return `${error}`;
218
221
  };
219
222
 
220
- const mergeStacks = (parent, child) => {
223
+ const mergeStacks$1 = (parent, child) => {
221
224
  if (!child) {
222
225
  return parent;
223
226
  }
@@ -247,14 +250,14 @@ const getErrorStack = error => {
247
250
  }
248
251
  return '';
249
252
  };
250
- class VError extends Error {
253
+ let VError$1 = class VError extends Error {
251
254
  constructor(error, message) {
252
255
  const combinedMessage = getCombinedErrorMessage(error, message);
253
256
  super(combinedMessage);
254
257
  this.name = 'VError';
255
258
  if (error instanceof Error) {
256
259
  const errorStack = getErrorStack(error);
257
- this.stack = mergeStacks(this.stack, errorStack);
260
+ this.stack = mergeStacks$1(this.stack, errorStack);
258
261
  }
259
262
  if (error.codeFrame) {
260
263
  // @ts-ignore
@@ -262,7 +265,7 @@ class VError extends Error {
262
265
  }
263
266
  this.cause = error;
264
267
  }
265
- }
268
+ };
266
269
 
267
270
  const state$b = {
268
271
  commands: Object.create(null),
@@ -292,7 +295,7 @@ const loadModule$1 = async moduleId => {
292
295
  // @ts-ignore
293
296
  Error.captureStackTrace(error, loadModule$1);
294
297
  }
295
- throw new VError(error, `failed to load module ${moduleId}`);
298
+ throw new VError$1(error, `failed to load module ${moduleId}`);
296
299
  }
297
300
  };
298
301
  const getOrLoadModule = moduleId => {
@@ -312,7 +315,7 @@ const executeCommandAsync = async (command, ...args) => {
312
315
  try {
313
316
  await loadCommand(command);
314
317
  } catch (error) {
315
- throw new VError(error, `Failed to load command ${command}`);
318
+ throw new VError$1(error, `Failed to load command ${command}`);
316
319
  }
317
320
  if (!(command in state$b.commands)) {
318
321
  if (hasThrown.has(command)) {
@@ -454,6 +457,8 @@ const load$1 = moduleId => {
454
457
  return Promise.resolve().then(function () { return PointerCapture_ipc; });
455
458
  case GetFilePathElectron:
456
459
  return Promise.resolve().then(function () { return GetFilePathElectron_ipc; });
460
+ case HandleMessagePort:
461
+ return Promise.resolve().then(function () { return HandleMessagePort_ipc; });
457
462
  default:
458
463
  throw new Error(`module ${moduleId} not found`);
459
464
  }
@@ -546,7 +551,7 @@ const create$3$1 = () => {
546
551
  const warn$1 = (...args) => {
547
552
  console.warn(...args);
548
553
  };
549
- const withResolvers$1 = () => {
554
+ const withResolvers$2 = () => {
550
555
  /**
551
556
  * @type {any}
552
557
  */
@@ -564,7 +569,7 @@ const registerPromise = () => {
564
569
  const {
565
570
  resolve,
566
571
  promise
567
- } = withResolvers$1();
572
+ } = withResolvers$2();
568
573
  set$5(id, resolve);
569
574
  return {
570
575
  id,
@@ -604,7 +609,7 @@ class JsonRpcError extends Error {
604
609
  this.name = 'JsonRpcError';
605
610
  }
606
611
  }
607
- const NewLine$1 = '\n';
612
+ const NewLine$3 = '\n';
608
613
  const DomException = 'DOMException';
609
614
  const ReferenceError$1 = 'ReferenceError';
610
615
  const SyntaxError$1 = 'SyntaxError';
@@ -651,21 +656,21 @@ const constructError = (message, type, name) => {
651
656
  }
652
657
  return new ErrorConstructor(message);
653
658
  };
654
- const getNewLineIndex$1 = (string, startIndex = undefined) => {
655
- return string.indexOf(NewLine$1, startIndex);
659
+ const getNewLineIndex$2 = (string, startIndex = undefined) => {
660
+ return string.indexOf(NewLine$3, startIndex);
656
661
  };
657
- const joinLines$1 = lines => {
658
- return lines.join(NewLine$1);
662
+ const joinLines$2 = lines => {
663
+ return lines.join(NewLine$3);
659
664
  };
660
665
  const MethodNotFound = -32601;
661
666
  const Custom = -32001;
662
- const splitLines$1 = lines => {
663
- return lines.split(NewLine$1);
667
+ const splitLines$2 = lines => {
668
+ return lines.split(NewLine$3);
664
669
  };
665
670
  const getParentStack = error => {
666
671
  let parentStack = error.stack || error.data || error.message || '';
667
672
  if (parentStack.startsWith(' at')) {
668
- parentStack = error.message + NewLine$1 + parentStack;
673
+ parentStack = error.message + NewLine$3 + parentStack;
669
674
  }
670
675
  return parentStack;
671
676
  };
@@ -673,18 +678,18 @@ const restoreJsonRpcError = error => {
673
678
  if (error && error instanceof Error) {
674
679
  return error;
675
680
  }
676
- const currentStack = joinLines$1(splitLines$1(new Error().stack).slice(1));
681
+ const currentStack = joinLines$2(splitLines$2(new Error().stack).slice(1));
677
682
  if (error && error.code && error.code === MethodNotFound) {
678
683
  const restoredError = new JsonRpcError(error.message);
679
684
  const parentStack = getParentStack(error);
680
- restoredError.stack = parentStack + NewLine$1 + currentStack;
685
+ restoredError.stack = parentStack + NewLine$3 + currentStack;
681
686
  return restoredError;
682
687
  }
683
688
  if (error && error.message) {
684
689
  const restoredError = constructError(error.message, error.type, error.name);
685
690
  if (error.data) {
686
691
  if (error.data.stack && error.data.type && error.message) {
687
- restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
692
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
688
693
  } else if (error.data.stack) {
689
694
  restoredError.stack = error.data.stack;
690
695
  }
@@ -705,7 +710,7 @@ const restoreJsonRpcError = error => {
705
710
  // TODO accessing stack might be slow
706
711
  const lowerStack = restoredError.stack || '';
707
712
  // @ts-ignore
708
- const indexNewLine = getNewLineIndex$1(lowerStack);
713
+ const indexNewLine = getNewLineIndex$2(lowerStack);
709
714
  const parentStack = getParentStack(error);
710
715
  // @ts-ignore
711
716
  restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
@@ -852,18 +857,18 @@ const unhandleIpc = ipc => {
852
857
 
853
858
  const isElectron = platform === Electron$1;
854
859
 
855
- const MessagePort$1 = 1;
856
- const ModuleWorker = 2;
860
+ const MessagePort$2 = 1;
861
+ const ModuleWorker$1 = 2;
857
862
  const ReferencePort = 3;
858
863
  const ModuleWorkerWithMessagePort = 4;
859
864
  const Electron = 5;
860
- const Auto = ModuleWorker;
865
+ const Auto = ModuleWorker$1;
861
866
 
862
- const getModule = method => {
867
+ const getModule$1 = method => {
863
868
  switch (method) {
864
- case ModuleWorker:
869
+ case ModuleWorker$1:
865
870
  return Promise.resolve().then(function () { return IpcParentWithModuleWorker; });
866
- case MessagePort$1:
871
+ case MessagePort$2:
867
872
  return Promise.resolve().then(function () { return IpcParentWithMessagePort; });
868
873
  case ReferencePort:
869
874
  return Promise.resolve().then(function () { return IpcParentWithReferencePort; });
@@ -880,7 +885,7 @@ const create$K = async ({
880
885
  method,
881
886
  ...options
882
887
  }) => {
883
- const module = await getModule(method);
888
+ const module = await getModule$1(method);
884
889
  // @ts-ignore
885
890
  return module.create(options);
886
891
  };
@@ -1066,7 +1071,7 @@ const getJson = async (url, options = {}) => {
1066
1071
  } catch (error) {
1067
1072
  if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
1068
1073
  // @ts-expect-error
1069
- throw new VError(`Failed to request json from "${url}". Make sure that the server is running and has CORS enabled`);
1074
+ throw new VError$1(`Failed to request json from "${url}". Make sure that the server is running and has CORS enabled`);
1070
1075
  }
1071
1076
  if (error && error instanceof HTTPError) {
1072
1077
  let json;
@@ -1078,7 +1083,7 @@ const getJson = async (url, options = {}) => {
1078
1083
  }
1079
1084
  if (json?.message) {
1080
1085
  // @ts-expect-error
1081
- throw new VError(`Failed to request json from "${url}": ${json.message}`);
1086
+ throw new VError$1(`Failed to request json from "${url}": ${json.message}`);
1082
1087
  }
1083
1088
  }
1084
1089
  // @ts-ignore
@@ -1094,21 +1099,21 @@ const getText$1 = async (url, options = {}) => {
1094
1099
  return await ky(url, options).text();
1095
1100
  } catch (error) {
1096
1101
  if (error && error instanceof TypeError && error.message === 'Failed to fetch') {
1097
- throw new VError(error, `Failed to request text from "${url}". Make sure that the server is running and has CORS enabled`);
1102
+ throw new VError$1(error, `Failed to request text from "${url}". Make sure that the server is running and has CORS enabled`);
1098
1103
  }
1099
- throw new VError(error, `Failed to request text from "${url}"`);
1104
+ throw new VError$1(error, `Failed to request text from "${url}"`);
1100
1105
  }
1101
1106
  };
1102
1107
 
1103
- const NewLine = '\n';
1108
+ const NewLine$2 = '\n';
1104
1109
 
1105
- const splitLines = lines => {
1110
+ const splitLines$1 = lines => {
1106
1111
  string(lines);
1107
- return lines.split(NewLine);
1112
+ return lines.split(NewLine$2);
1108
1113
  };
1109
1114
 
1110
- const RE_AT = /^\s+at/;
1111
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
1115
+ const RE_AT$1 = /^\s+at/;
1116
+ const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
1112
1117
  const RE_OBJECT_AS = /^\s*at Object\.\w+ \[as ([\w.]+)]/;
1113
1118
  const RE_OBJECT = /^\s*at Object\.(\w+)/;
1114
1119
  const RE_PATH_1$1 = /\((.*):(\d+):(\d+)\)$/;
@@ -1121,13 +1126,13 @@ const RE_JSON_RPC_INVOKE = /^\s*at invoke .*JsonRpc\.js/;
1121
1126
  const RE_ASSERT = /^\s*at .*\/Assert\.js/;
1122
1127
  const RE_CONSTRUCT_ERROR = /^\s*at constructError /;
1123
1128
  const isInternalLine = line => {
1124
- return RE_AT_PROMISE_INDEX.test(line);
1129
+ return RE_AT_PROMISE_INDEX$1.test(line);
1125
1130
  };
1126
1131
  const isRelevantLine = line => {
1127
1132
  return !isInternalLine(line);
1128
1133
  };
1129
- const isNormalStackLine = line => {
1130
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line) || RE_PATH_2$1.test(line) || RE_PATH_3$1.test(line);
1134
+ const isNormalStackLine$1 = line => {
1135
+ return RE_AT$1.test(line) && !RE_AT_PROMISE_INDEX$1.test(line) || RE_PATH_2$1.test(line) || RE_PATH_3$1.test(line);
1131
1136
  };
1132
1137
  const isApplicationUsefulLine = (line, index) => {
1133
1138
  if (index === 0) {
@@ -1158,8 +1163,8 @@ const cleanLine = line => {
1158
1163
  }
1159
1164
  return line;
1160
1165
  };
1161
- const getDetails = lines => {
1162
- const index = lines.findIndex(isNormalStackLine);
1166
+ const getDetails$1 = lines => {
1167
+ const index = lines.findIndex(isNormalStackLine$1);
1163
1168
  return {
1164
1169
  custom: lines.slice(0, index),
1165
1170
  actualStack: lines.slice(index).map(cleanLine)
@@ -1183,11 +1188,11 @@ const mergeCustom = (custom, relevantStack) => {
1183
1188
  };
1184
1189
  const cleanStack = stack => {
1185
1190
  string(stack);
1186
- const lines = splitLines(stack);
1191
+ const lines = splitLines$1(stack);
1187
1192
  const {
1188
1193
  custom,
1189
1194
  actualStack
1190
- } = getDetails(lines);
1195
+ } = getDetails$1(lines);
1191
1196
  const relevantStack = actualStack.filter(isRelevantLine).filter(isApplicationUsefulLine);
1192
1197
  const merged = mergeCustom(custom, relevantStack);
1193
1198
  return merged;
@@ -1296,7 +1301,7 @@ const create$J = (rawLines, loc, opts = {}) => {
1296
1301
  } else {
1297
1302
  return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`;
1298
1303
  }
1299
- }).join(NewLine);
1304
+ }).join(NewLine$2);
1300
1305
 
1301
1306
  // @ts-ignore
1302
1307
  if (opts.message && !hasColumns) {
@@ -1312,8 +1317,8 @@ const create$J = (rawLines, loc, opts = {}) => {
1312
1317
  * @param {number|undefined} startIndex
1313
1318
  * @returns
1314
1319
  */
1315
- const getNewLineIndex = (string, startIndex = undefined) => {
1316
- return string.indexOf(NewLine, startIndex);
1320
+ const getNewLineIndex$1 = (string, startIndex = undefined) => {
1321
+ return string.indexOf(NewLine$2, startIndex);
1317
1322
  };
1318
1323
 
1319
1324
  const isActualSourceFile = path => {
@@ -1341,8 +1346,8 @@ const getIsFirefox = () => {
1341
1346
  */
1342
1347
  const isFirefox = getIsFirefox();
1343
1348
 
1344
- const joinLines = lines => {
1345
- return lines.join(NewLine);
1349
+ const joinLines$1 = lines => {
1350
+ return lines.join(NewLine$2);
1346
1351
  };
1347
1352
 
1348
1353
  const warn = (...args) => {
@@ -1484,7 +1489,7 @@ const getOriginalPosition = (sourceMap, line, column) => {
1484
1489
  originalColumn
1485
1490
  };
1486
1491
  } catch (error) {
1487
- throw new VError(error, `Failed to get original sourcemap position`);
1492
+ throw new VError$1(error, `Failed to get original sourcemap position`);
1488
1493
  }
1489
1494
  };
1490
1495
 
@@ -1511,7 +1516,7 @@ const prepareErrorMessageWithCodeFrame = error => {
1511
1516
  }
1512
1517
  const message = getErrorMessage(error);
1513
1518
  const lines = cleanStack(error.stack);
1514
- const relevantStack = joinLines(lines);
1519
+ const relevantStack = joinLines$1(lines);
1515
1520
  if (error.codeFrame) {
1516
1521
  return {
1517
1522
  message,
@@ -1560,14 +1565,14 @@ const toAbsoluteUrl = (file, relativePath) => {
1560
1565
  };
1561
1566
  const getSourceMapMatch = text => {
1562
1567
  string(text);
1563
- const index = text.lastIndexOf(NewLine, text.length - 2);
1568
+ const index = text.lastIndexOf(NewLine$2, text.length - 2);
1564
1569
  const lastLine = text.slice(index + 1, -1);
1565
1570
  const lastLineMatch = lastLine.match(RE_SOURCE_MAP);
1566
1571
  if (lastLineMatch) {
1567
1572
  return lastLineMatch;
1568
1573
  }
1569
1574
  // @ts-ignore
1570
- const secondLastLineIndex = getNewLineIndex(text, index - 1);
1575
+ const secondLastLineIndex = getNewLineIndex$1(text, index - 1);
1571
1576
  const secondLastLine = text.slice(secondLastLineIndex, index);
1572
1577
  const secondLastLineMatch = secondLastLine.match(RE_SOURCE_MAP);
1573
1578
  return secondLastLineMatch;
@@ -1595,7 +1600,7 @@ const prepareErrorMessageWithoutCodeFrame = async error => {
1595
1600
  const parsedLine = parseInt(line);
1596
1601
  const parsedColumn = parseInt(column);
1597
1602
  const message = getErrorMessage(error);
1598
- const relevantStack = joinLines(lines);
1603
+ const relevantStack = joinLines$1(lines);
1599
1604
  if (sourceMapMatch) {
1600
1605
  const sourceMapUrl = sourceMapMatch[1];
1601
1606
  const sourceMapAbsolutePath = getSourceMapAbsolutePath(path, sourceMapUrl);
@@ -1755,15 +1760,15 @@ const play = async src => {
1755
1760
  await audio.play();
1756
1761
  };
1757
1762
 
1758
- const name$w = 'Audio';
1759
- const Commands$x = {
1763
+ const name$x = 'Audio';
1764
+ const Commands$y = {
1760
1765
  play: play
1761
1766
  };
1762
1767
 
1763
1768
  const Audio_ipc = {
1764
1769
  __proto__: null,
1765
- Commands: Commands$x,
1766
- name: name$w
1770
+ Commands: Commands$y,
1771
+ name: name$x
1767
1772
  };
1768
1773
 
1769
1774
  const readText = async () => {
@@ -1784,8 +1789,8 @@ const execCopy = async () => {
1784
1789
  await writeText(text);
1785
1790
  };
1786
1791
 
1787
- const name$v = 'ClipBoard';
1788
- const Commands$w = {
1792
+ const name$w = 'ClipBoard';
1793
+ const Commands$x = {
1789
1794
  execCopy: execCopy,
1790
1795
  readText: readText,
1791
1796
  writeImage: writeImage,
@@ -1794,23 +1799,23 @@ const Commands$w = {
1794
1799
 
1795
1800
  const ClipBoard_ipc = {
1796
1801
  __proto__: null,
1797
- Commands: Commands$w,
1798
- name: name$v
1802
+ Commands: Commands$x,
1803
+ name: name$w
1799
1804
  };
1800
1805
 
1801
1806
  const prompt$1 = message => {
1802
1807
  return confirm(message);
1803
1808
  };
1804
1809
 
1805
- const name$u = 'ConfirmPrompt';
1806
- const Commands$v = {
1810
+ const name$v = 'ConfirmPrompt';
1811
+ const Commands$w = {
1807
1812
  prompt: prompt$1
1808
1813
  };
1809
1814
 
1810
1815
  const ConfirmPrompt_ipc = {
1811
1816
  __proto__: null,
1812
- Commands: Commands$v,
1813
- name: name$u
1817
+ Commands: Commands$w,
1818
+ name: name$v
1814
1819
  };
1815
1820
 
1816
1821
  const state$7 = {
@@ -1835,15 +1840,15 @@ const addCssStyleSheet = async (id, text) => {
1835
1840
  document.adoptedStyleSheets.push(sheet);
1836
1841
  };
1837
1842
 
1838
- const name$t = 'Css';
1839
- const Commands$u = {
1843
+ const name$u = 'Css';
1844
+ const Commands$v = {
1840
1845
  addCssStyleSheet: addCssStyleSheet
1841
1846
  };
1842
1847
 
1843
1848
  const Css_ipc = {
1844
1849
  __proto__: null,
1845
- Commands: Commands$u,
1846
- name: name$t
1850
+ Commands: Commands$v,
1851
+ name: name$u
1847
1852
  };
1848
1853
 
1849
1854
  const modules = ['ActivityBar', 'Ajax', 'Allocator', 'Callback', 'Command', 'Context', 'ContextMenu', 'Delay', 'Developer', 'DomPool', 'Editor', 'Exec', 'ExtensionHost', 'FileSystem', 'KeyBindings', 'Layout', 'Main', 'Notification', 'Panel', 'Parts', 'QuickPick', 'Renderer', 'RendererWorker', 'Search', 'SharedProcess', 'SideBar', 'StatusBar', 'TitleBar', 'Viewlet', 'ViewletController', 'ViewService', 'Vscode', 'Window', 'Workbench', 'Worker', 'Workspace'];
@@ -1863,15 +1868,15 @@ const showState = async () => {
1863
1868
  info(state);
1864
1869
  };
1865
1870
 
1866
- const name$s = 'Developer';
1867
- const Commands$t = {
1871
+ const name$t = 'Developer';
1872
+ const Commands$u = {
1868
1873
  showState: showState
1869
1874
  };
1870
1875
 
1871
1876
  const Developer_ipc = {
1872
1877
  __proto__: null,
1873
- Commands: Commands$t,
1874
- name: name$s
1878
+ Commands: Commands$u,
1879
+ name: name$t
1875
1880
  };
1876
1881
 
1877
1882
  const downloadFile = (fileName, url) => {
@@ -1881,15 +1886,15 @@ const downloadFile = (fileName, url) => {
1881
1886
  a.click();
1882
1887
  };
1883
1888
 
1884
- const name$r = 'Download';
1885
- const Commands$s = {
1889
+ const name$s = 'Download';
1890
+ const Commands$t = {
1886
1891
  downloadFile: downloadFile
1887
1892
  };
1888
1893
 
1889
1894
  const Download_ipc = {
1890
1895
  __proto__: null,
1891
- Commands: Commands$s,
1892
- name: name$r
1896
+ Commands: Commands$t,
1897
+ name: name$s
1893
1898
  };
1894
1899
 
1895
1900
  // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
@@ -2056,15 +2061,15 @@ const create$I = (message, x, y) => {
2056
2061
  };
2057
2062
  };
2058
2063
 
2059
- const name$q = 'EditorError';
2060
- const Commands$r = {
2064
+ const name$r = 'EditorError';
2065
+ const Commands$s = {
2061
2066
  create: create$I
2062
2067
  };
2063
2068
 
2064
2069
  const EditorError_ipc = {
2065
2070
  __proto__: null,
2066
- Commands: Commands$r,
2067
- name: name$q
2071
+ Commands: Commands$s,
2072
+ name: name$r
2068
2073
  };
2069
2074
 
2070
2075
  const state$4 = {
@@ -2191,8 +2196,8 @@ const finish = state => {
2191
2196
  return value;
2192
2197
  };
2193
2198
 
2194
- const name$p = 'EditorRename';
2195
- const Commands$q = {
2199
+ const name$q = 'EditorRename';
2200
+ const Commands$r = {
2196
2201
  create: create$G,
2197
2202
  dispose: dispose$i,
2198
2203
  finish: finish
@@ -2200,8 +2205,8 @@ const Commands$q = {
2200
2205
 
2201
2206
  const EditorRename_ipc = {
2202
2207
  __proto__: null,
2203
- Commands: Commands$q,
2204
- name: name$p
2208
+ Commands: Commands$r,
2209
+ name: name$q
2205
2210
  };
2206
2211
 
2207
2212
  const showDirectoryPicker = options => {
@@ -2217,8 +2222,8 @@ const showSaveFilePicker = options => {
2217
2222
  return window.showSaveFilePicker(options);
2218
2223
  };
2219
2224
 
2220
- const name$o = 'FilePicker';
2221
- const Commands$p = {
2225
+ const name$p = 'FilePicker';
2226
+ const Commands$q = {
2222
2227
  showDirectoryPicker: showDirectoryPicker,
2223
2228
  showFilePicker: showFilePicker,
2224
2229
  showSaveFilePicker: showSaveFilePicker
@@ -2226,23 +2231,23 @@ const Commands$p = {
2226
2231
 
2227
2232
  const FilePicker_ipc = {
2228
2233
  __proto__: null,
2229
- Commands: Commands$p,
2230
- name: name$o
2234
+ Commands: Commands$q,
2235
+ name: name$p
2231
2236
  };
2232
2237
 
2233
2238
  const requestPermission = (handle, options) => {
2234
2239
  return handle.requestPermission(options);
2235
2240
  };
2236
2241
 
2237
- const name$n = 'FileSystemHandle';
2238
- const Commands$o = {
2242
+ const name$o = 'FileSystemHandle';
2243
+ const Commands$p = {
2239
2244
  requestPermission: requestPermission
2240
2245
  };
2241
2246
 
2242
2247
  const FileSystemHandle_ipc = {
2243
2248
  __proto__: null,
2244
- Commands: Commands$o,
2245
- name: name$n
2249
+ Commands: Commands$p,
2250
+ name: name$o
2246
2251
  };
2247
2252
 
2248
2253
  const handleImageLoad = event => {
@@ -2316,8 +2321,8 @@ const ImagePreview$1 = {
2316
2321
  update
2317
2322
  };
2318
2323
 
2319
- const name$m = 'ImagePreview';
2320
- const Commands$n = {
2324
+ const name$n = 'ImagePreview';
2325
+ const Commands$o = {
2321
2326
  create: create$F,
2322
2327
  dispose: dispose$h,
2323
2328
  showError: showError,
@@ -2326,8 +2331,8 @@ const Commands$n = {
2326
2331
 
2327
2332
  const ImagePreview_ipc = {
2328
2333
  __proto__: null,
2329
- Commands: Commands$n,
2330
- name: name$m
2334
+ Commands: Commands$o,
2335
+ name: name$n
2331
2336
  };
2332
2337
 
2333
2338
  const getOrigin = () => {
@@ -2383,41 +2388,41 @@ const getInitData = () => {
2383
2388
  return initData;
2384
2389
  };
2385
2390
 
2386
- const name$l = 'InitData';
2387
- const Commands$m = {
2391
+ const name$m = 'InitData';
2392
+ const Commands$n = {
2388
2393
  getInitData: getInitData
2389
2394
  };
2390
2395
 
2391
2396
  const InitData_ipc = {
2392
2397
  __proto__: null,
2393
- Commands: Commands$m,
2394
- name: name$l
2398
+ Commands: Commands$n,
2399
+ name: name$m
2395
2400
  };
2396
2401
 
2397
- const name$k = 'IpcParent';
2398
- const Commands$l = {
2402
+ const name$l = 'IpcParent';
2403
+ const Commands$m = {
2399
2404
  create: create$K
2400
2405
  };
2401
2406
 
2402
2407
  const IpcParent_ipc = {
2403
2408
  __proto__: null,
2404
- Commands: Commands$l,
2405
- name: name$k
2409
+ Commands: Commands$m,
2410
+ name: name$l
2406
2411
  };
2407
2412
 
2408
- const name$j = 'Layout';
2409
- const Commands$k = {
2413
+ const name$k = 'Layout';
2414
+ const Commands$l = {
2410
2415
  getBounds: getBounds
2411
2416
  };
2412
2417
 
2413
2418
  const Layout_ipc = {
2414
2419
  __proto__: null,
2415
- Commands: Commands$k,
2416
- name: name$j
2420
+ Commands: Commands$l,
2421
+ name: name$k
2417
2422
  };
2418
2423
 
2419
- const name$i = 'Location';
2420
- const Commands$j = {
2424
+ const name$j = 'Location';
2425
+ const Commands$k = {
2421
2426
  getHref: getHref,
2422
2427
  getPathName: getPathName,
2423
2428
  hydrate: hydrate,
@@ -2426,8 +2431,8 @@ const Commands$j = {
2426
2431
 
2427
2432
  const Location_ipc = {
2428
2433
  __proto__: null,
2429
- Commands: Commands$j,
2430
- name: name$i
2434
+ Commands: Commands$k,
2435
+ name: name$j
2431
2436
  };
2432
2437
 
2433
2438
  const measureTextHeight = (text, fontSize, fontFamily) => {
@@ -2445,15 +2450,15 @@ const measureTextHeight = (text, fontSize, fontFamily) => {
2445
2450
  return height;
2446
2451
  };
2447
2452
 
2448
- const name$h = 'MeasureTextHeight';
2449
- const Commands$i = {
2453
+ const name$i = 'MeasureTextHeight';
2454
+ const Commands$j = {
2450
2455
  measureTextHeight: measureTextHeight
2451
2456
  };
2452
2457
 
2453
2458
  const MeasureTextHeight_ipc = {
2454
2459
  __proto__: null,
2455
- Commands: Commands$i,
2456
- name: name$h
2460
+ Commands: Commands$j,
2461
+ name: name$i
2457
2462
  };
2458
2463
 
2459
2464
  const setThemeColor = color => {
@@ -2465,15 +2470,15 @@ const setThemeColor = color => {
2465
2470
  meta.content = color;
2466
2471
  };
2467
2472
 
2468
- const name$g = 'Meta';
2469
- const Commands$h = {
2473
+ const name$h = 'Meta';
2474
+ const Commands$i = {
2470
2475
  setThemeColor: setThemeColor
2471
2476
  };
2472
2477
 
2473
2478
  const Meta_ipc = {
2474
2479
  __proto__: null,
2475
- Commands: Commands$h,
2476
- name: name$g
2480
+ Commands: Commands$i,
2481
+ name: name$h
2477
2482
  };
2478
2483
 
2479
2484
  const create$Notification = message => {
@@ -2531,10 +2536,10 @@ const dispose$g = id => {
2531
2536
  // const $Notification = state.$Notifications
2532
2537
  };
2533
2538
 
2534
- const name$f = 'Notification';
2539
+ const name$g = 'Notification';
2535
2540
 
2536
2541
  // prettier-ignore
2537
- const Commands$g = {
2542
+ const Commands$h = {
2538
2543
  create: create$E,
2539
2544
  createWithOptions: createWithOptions,
2540
2545
  dispose: dispose$g
@@ -2542,8 +2547,8 @@ const Commands$g = {
2542
2547
 
2543
2548
  const Notification_ipc = {
2544
2549
  __proto__: null,
2545
- Commands: Commands$g,
2546
- name: name$f
2550
+ Commands: Commands$h,
2551
+ name: name$g
2547
2552
  };
2548
2553
 
2549
2554
  const Two = '2.0';
@@ -2572,17 +2577,17 @@ const create$D = (canvasId, callbackId) => {
2572
2577
  }, [offscreenCanvas]);
2573
2578
  };
2574
2579
 
2575
- const name$e = 'OffscreenCanvas';
2580
+ const name$f = 'OffscreenCanvas';
2576
2581
 
2577
2582
  // prettier-ignore
2578
- const Commands$f = {
2583
+ const Commands$g = {
2579
2584
  create: create$D
2580
2585
  };
2581
2586
 
2582
2587
  const OffscreenCanvas_ipc = {
2583
2588
  __proto__: null,
2584
- Commands: Commands$f,
2585
- name: name$e
2589
+ Commands: Commands$g,
2590
+ name: name$f
2586
2591
  };
2587
2592
 
2588
2593
  // TODO this module should be called dom or dom utils
@@ -3343,8 +3348,8 @@ const hide = (restoreFocus = true) => {
3343
3348
  }
3344
3349
  };
3345
3350
 
3346
- const name$d = 'Menu';
3347
- const Commands$e = {
3351
+ const name$e = 'Menu';
3352
+ const Commands$f = {
3348
3353
  focusIndex: focusIndex,
3349
3354
  hide: hide,
3350
3355
  hideSubMenu: hideSubMenu,
@@ -3354,23 +3359,23 @@ const Commands$e = {
3354
3359
 
3355
3360
  const Menu_ipc = {
3356
3361
  __proto__: null,
3357
- Commands: Commands$e,
3358
- name: name$d
3362
+ Commands: Commands$f,
3363
+ name: name$e
3359
3364
  };
3360
3365
 
3361
3366
  const openUrl = url => {
3362
3367
  open(url);
3363
3368
  };
3364
3369
 
3365
- const name$c = 'Open';
3366
- const Commands$d = {
3370
+ const name$d = 'Open';
3371
+ const Commands$e = {
3367
3372
  openUrl: openUrl
3368
3373
  };
3369
3374
 
3370
3375
  const Open_ipc = {
3371
3376
  __proto__: null,
3372
- Commands: Commands$d,
3373
- name: name$c
3377
+ Commands: Commands$e,
3378
+ name: name$d
3374
3379
  };
3375
3380
 
3376
3381
  const isElectronUserAgentSpecificMemoryError = error => {
@@ -3409,18 +3414,18 @@ const getMemory = () => {
3409
3414
  };
3410
3415
  };
3411
3416
 
3412
- const name$b = 'Performance';
3417
+ const name$c = 'Performance';
3413
3418
 
3414
3419
  // prettier-ignore
3415
- const Commands$c = {
3420
+ const Commands$d = {
3416
3421
  getMemory: getMemory,
3417
3422
  measureUserAgentSpecificMemory: measureUserAgentSpecificMemory
3418
3423
  };
3419
3424
 
3420
3425
  const Performance_ipc = {
3421
3426
  __proto__: null,
3422
- Commands: Commands$c,
3423
- name: name$b
3427
+ Commands: Commands$d,
3428
+ name: name$c
3424
3429
  };
3425
3430
 
3426
3431
  const prompt = (message, defaultValue) => {
@@ -3428,15 +3433,15 @@ const prompt = (message, defaultValue) => {
3428
3433
  return window.prompt(message, defaultValue);
3429
3434
  };
3430
3435
 
3431
- const name$a = 'Prompt';
3432
- const Commands$b = {
3436
+ const name$b = 'Prompt';
3437
+ const Commands$c = {
3433
3438
  prompt: prompt
3434
3439
  };
3435
3440
 
3436
3441
  const Prompt_ipc = {
3437
3442
  __proto__: null,
3438
- Commands: Commands$b,
3439
- name: name$a
3443
+ Commands: Commands$c,
3444
+ name: name$b
3440
3445
  };
3441
3446
 
3442
3447
  const screenCaptures = Object.create(null);
@@ -3461,7 +3466,7 @@ const start = async (id, options) => {
3461
3466
  const captureStream = await navigator.mediaDevices.getUserMedia(options);
3462
3467
  set$1(id, captureStream);
3463
3468
  } catch (error) {
3464
- throw new VError(error, `Failed to start screen capture`);
3469
+ throw new VError$1(error, `Failed to start screen capture`);
3465
3470
  }
3466
3471
  };
3467
3472
  const dispose$f = async (id, options) => {
@@ -3473,20 +3478,20 @@ const dispose$f = async (id, options) => {
3473
3478
  }
3474
3479
  remove(id);
3475
3480
  } catch (error) {
3476
- throw new VError(error, `Failed to start screen capture`);
3481
+ throw new VError$1(error, `Failed to start screen capture`);
3477
3482
  }
3478
3483
  };
3479
3484
 
3480
- const name$9 = 'ScreenCapture';
3481
- const Commands$a = {
3485
+ const name$a = 'ScreenCapture';
3486
+ const Commands$b = {
3482
3487
  dispose: dispose$f,
3483
3488
  start: start
3484
3489
  };
3485
3490
 
3486
3491
  const ScreenCapture_ipc = {
3487
3492
  __proto__: null,
3488
- Commands: Commands$a,
3489
- name: name$9
3493
+ Commands: Commands$b,
3494
+ name: name$a
3490
3495
  };
3491
3496
 
3492
3497
  const htmlElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdo', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr'];
@@ -3992,10 +3997,10 @@ const checkMultiElementCondition = async (locator, fnName, options) => {
3992
3997
  throw new AssertionError(message);
3993
3998
  };
3994
3999
 
3995
- const name$8 = 'TestFrameWork';
4000
+ const name$9 = 'TestFrameWork';
3996
4001
 
3997
4002
  // prettier-ignore
3998
- const Commands$9 = {
4003
+ const Commands$a = {
3999
4004
  checkMultiElementCondition: checkMultiElementCondition,
4000
4005
  checkSingleElementCondition: checkSingleElementCondition,
4001
4006
  performAction: performAction,
@@ -4005,8 +4010,8 @@ const Commands$9 = {
4005
4010
 
4006
4011
  const TestFrameWork_ipc = {
4007
4012
  __proto__: null,
4008
- Commands: Commands$9,
4009
- name: name$8
4013
+ Commands: Commands$a,
4014
+ name: name$9
4010
4015
  };
4011
4016
 
4012
4017
  const objects = Object.create(null);
@@ -4014,15 +4019,15 @@ const transfer = (objectId, transferable) => {
4014
4019
  objects[objectId] = transferable;
4015
4020
  };
4016
4021
 
4017
- const name$7 = 'Transferrable';
4018
- const Commands$8 = {
4022
+ const name$8 = 'Transferrable';
4023
+ const Commands$9 = {
4019
4024
  transfer: transfer
4020
4025
  };
4021
4026
 
4022
4027
  const Transferrable_ipc = {
4023
4028
  __proto__: null,
4024
- Commands: Commands$8,
4025
- name: name$7
4029
+ Commands: Commands$9,
4030
+ name: name$8
4026
4031
  };
4027
4032
 
4028
4033
  const state$1 = {
@@ -4313,7 +4318,7 @@ const loadModule = async id => {
4313
4318
  const module = await load(id);
4314
4319
  state.modules[id] = module;
4315
4320
  } catch (error) {
4316
- throw new VError(error, `Failed to load ${id}`);
4321
+ throw new VError$1(error, `Failed to load ${id}`);
4317
4322
  }
4318
4323
  };
4319
4324
  const invoke = (viewletId, method, ...args) => {
@@ -4687,8 +4692,8 @@ const setBounds$5 = (id, left, top, width, height) => {
4687
4692
  setBounds$6($Viewlet, left, top, width, height);
4688
4693
  };
4689
4694
 
4690
- const name$6 = 'Viewlet';
4691
- const Commands$7 = {
4695
+ const name$7 = 'Viewlet';
4696
+ const Commands$8 = {
4692
4697
  addKeyBindings: addKeyBindings,
4693
4698
  appendViewlet: appendViewlet,
4694
4699
  dispose: dispose$e,
@@ -4708,8 +4713,8 @@ const Commands$7 = {
4708
4713
 
4709
4714
  const Viewlet_ipc = {
4710
4715
  __proto__: null,
4711
- Commands: Commands$7,
4712
- name: name$6
4716
+ Commands: Commands$8,
4717
+ name: name$7
4713
4718
  };
4714
4719
 
4715
4720
  const LocalStorage = 1;
@@ -4752,8 +4757,8 @@ const clear$1 = storageType => {
4752
4757
  storage.clear();
4753
4758
  };
4754
4759
 
4755
- const name$5 = 'WebStorage';
4756
- const Commands$6 = {
4760
+ const name$6 = 'WebStorage';
4761
+ const Commands$7 = {
4757
4762
  clear: clear$1,
4758
4763
  getAll: getAll,
4759
4764
  getItem: getItem,
@@ -4763,8 +4768,8 @@ const Commands$6 = {
4763
4768
 
4764
4769
  const WebStorage_ipc = {
4765
4770
  __proto__: null,
4766
- Commands: Commands$6,
4767
- name: name$5
4771
+ Commands: Commands$7,
4772
+ name: name$6
4768
4773
  };
4769
4774
 
4770
4775
  const reload$1 = () => {
@@ -4794,8 +4799,8 @@ const onVisibilityChange = () => {
4794
4799
  document.addEventListener('pointerleave', handlePointerLeave);
4795
4800
  };
4796
4801
 
4797
- const name$4 = 'Window';
4798
- const Commands$5 = {
4802
+ const name$5 = 'Window';
4803
+ const Commands$6 = {
4799
4804
  close: close$1,
4800
4805
  maximize: maximize,
4801
4806
  minimize: minimize,
@@ -4806,34 +4811,34 @@ const Commands$5 = {
4806
4811
 
4807
4812
  const Window_ipc = {
4808
4813
  __proto__: null,
4809
- Commands: Commands$5,
4810
- name: name$4
4814
+ Commands: Commands$6,
4815
+ name: name$5
4811
4816
  };
4812
4817
 
4813
4818
  const set = title => {
4814
4819
  document.title = title;
4815
4820
  };
4816
4821
 
4817
- const name$3 = 'WindowTitle';
4818
- const Commands$4 = {
4822
+ const name$4 = 'WindowTitle';
4823
+ const Commands$5 = {
4819
4824
  set: set
4820
4825
  };
4821
4826
 
4822
4827
  const WindowTitle_ipc = {
4823
4828
  __proto__: null,
4824
- Commands: Commands$4,
4825
- name: name$3
4829
+ Commands: Commands$5,
4830
+ name: name$4
4826
4831
  };
4827
4832
 
4828
- const name$2 = 'KeyBindings';
4829
- const Commands$3 = {
4833
+ const name$3 = 'KeyBindings';
4834
+ const Commands$4 = {
4830
4835
  setIdentifiers: setIdentifiers
4831
4836
  };
4832
4837
 
4833
4838
  const KeyBindings_ipc = {
4834
4839
  __proto__: null,
4835
- Commands: Commands$3,
4836
- name: name$2
4840
+ Commands: Commands$4,
4841
+ name: name$3
4837
4842
  };
4838
4843
 
4839
4844
  // workaround for not being setPointerCapture() not working on
@@ -4849,16 +4854,16 @@ const unmock = () => {
4849
4854
  Element.prototype.releasePointerCapture = globalThis._originalReleasePointerCapture;
4850
4855
  };
4851
4856
 
4852
- const name$1 = 'PointerCapture';
4853
- const Commands$2 = {
4857
+ const name$2 = 'PointerCapture';
4858
+ const Commands$3 = {
4854
4859
  mock: mock,
4855
4860
  unmock: unmock
4856
4861
  };
4857
4862
 
4858
4863
  const PointerCapture_ipc = {
4859
4864
  __proto__: null,
4860
- Commands: Commands$2,
4861
- name: name$1
4865
+ Commands: Commands$3,
4866
+ name: name$2
4862
4867
  };
4863
4868
 
4864
4869
  const isFile = value => {
@@ -4876,44 +4881,511 @@ const getFilePathElectron = async file => {
4876
4881
  return filePath;
4877
4882
  };
4878
4883
 
4879
- const name = 'GetFilePathElectron';
4880
- const Commands$1 = {
4884
+ const name$1 = 'GetFilePathElectron';
4885
+ const Commands$2 = {
4881
4886
  getFilePathElectron: getFilePathElectron
4882
4887
  };
4883
4888
 
4884
4889
  const GetFilePathElectron_ipc = {
4885
4890
  __proto__: null,
4886
- Commands: Commands$1,
4887
- name
4891
+ Commands: Commands$2,
4892
+ name: name$1
4888
4893
  };
4889
4894
 
4890
- const Message = 'message';
4891
- const Error$1 = 'error';
4895
+ const MessagePort$1 = 1;
4896
+ const ModuleWorker = 2;
4897
+ const ModuleWorkerAndMessagePort = 8;
4892
4898
 
4893
- const withResolvers = () => {
4894
- /**
4895
- * @type {any}
4896
- */
4897
- let _resolve;
4898
- /**
4899
- * @type {any}
4900
- */
4901
- let _reject;
4902
- const promise = new Promise((resolve, reject) => {
4903
- _resolve = resolve;
4904
- _reject = reject;
4905
- });
4906
- return {
4907
- resolve: _resolve,
4908
- reject: _reject,
4909
- promise
4910
- };
4899
+ const getData$1 = event => {
4900
+ return event.data;
4911
4901
  };
4912
-
4913
- const getFirstEvent = (eventTarget, eventMap) => {
4914
- const {
4915
- resolve,
4916
- promise
4902
+ const attachEvents$d = that => {
4903
+ const handleMessage = (...args) => {
4904
+ const data = that.getData(...args);
4905
+ that.dispatchEvent(new MessageEvent('message', {
4906
+ data
4907
+ }));
4908
+ };
4909
+ that.onMessage(handleMessage);
4910
+ const handleClose = event => {
4911
+ that.dispatchEvent(new Event('close'));
4912
+ };
4913
+ that.onClose(handleClose);
4914
+ };
4915
+ class Ipc extends EventTarget {
4916
+ constructor(rawIpc) {
4917
+ super();
4918
+ this._rawIpc = rawIpc;
4919
+ attachEvents$d(this);
4920
+ }
4921
+ }
4922
+ const readyMessage = 'ready';
4923
+ const listen$3 = () => {
4924
+ // @ts-ignore
4925
+ if (typeof WorkerGlobalScope === 'undefined') {
4926
+ throw new TypeError('module is not in web worker scope');
4927
+ }
4928
+ return globalThis;
4929
+ };
4930
+ const signal$2 = global => {
4931
+ global.postMessage(readyMessage);
4932
+ };
4933
+ class IpcChildWithModuleWorker extends Ipc {
4934
+ getData(event) {
4935
+ return getData$1(event);
4936
+ }
4937
+ send(message) {
4938
+ // @ts-ignore
4939
+ this._rawIpc.postMessage(message);
4940
+ }
4941
+ sendAndTransfer(message, transfer) {
4942
+ // @ts-ignore
4943
+ this._rawIpc.postMessage(message, transfer);
4944
+ }
4945
+ dispose() {
4946
+ // ignore
4947
+ }
4948
+ onClose(callback) {
4949
+ // ignore
4950
+ }
4951
+ onMessage(callback) {
4952
+ this._rawIpc.addEventListener('message', callback);
4953
+ }
4954
+ }
4955
+ const wrap$5 = global => {
4956
+ return new IpcChildWithModuleWorker(global);
4957
+ };
4958
+ const IpcChildWithModuleWorker$1 = {
4959
+ __proto__: null,
4960
+ listen: listen$3,
4961
+ signal: signal$2,
4962
+ wrap: wrap$5
4963
+ };
4964
+ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
4965
+ const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
4966
+ const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
4967
+ const NewLine$1 = '\n';
4968
+ const joinLines = lines => {
4969
+ return lines.join(NewLine$1);
4970
+ };
4971
+ const splitLines = lines => {
4972
+ return lines.split(NewLine$1);
4973
+ };
4974
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
4975
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
4976
+ const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
4977
+ const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
4978
+ const RE_AT = /^\s+at/;
4979
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
4980
+ const isUnhelpfulNativeModuleError = stderr => {
4981
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
4982
+ };
4983
+ const isMessageCodeBlockStartIndex = line => {
4984
+ return RE_MESSAGE_CODE_BLOCK_START.test(line);
4985
+ };
4986
+ const isMessageCodeBlockEndIndex = line => {
4987
+ return RE_MESSAGE_CODE_BLOCK_END.test(line);
4988
+ };
4989
+ const getMessageCodeBlock = stderr => {
4990
+ const lines = splitLines(stderr);
4991
+ const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
4992
+ const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
4993
+ const relevantLines = lines.slice(startIndex, endIndex);
4994
+ const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
4995
+ return relevantMessage;
4996
+ };
4997
+ const getNativeModuleErrorMessage = stderr => {
4998
+ const message = getMessageCodeBlock(stderr);
4999
+ return {
5000
+ message: `Incompatible native node module: ${message}`,
5001
+ code: E_INCOMPATIBLE_NATIVE_MODULE
5002
+ };
5003
+ };
5004
+ const isModulesSyntaxError = stderr => {
5005
+ if (!stderr) {
5006
+ return false;
5007
+ }
5008
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
5009
+ };
5010
+ const getModuleSyntaxError = () => {
5011
+ return {
5012
+ message: `ES Modules are not supported in electron`,
5013
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
5014
+ };
5015
+ };
5016
+ const isModuleNotFoundError = stderr => {
5017
+ if (!stderr) {
5018
+ return false;
5019
+ }
5020
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
5021
+ };
5022
+ const isModuleNotFoundMessage = line => {
5023
+ return line.includes('ERR_MODULE_NOT_FOUND');
5024
+ };
5025
+ const getModuleNotFoundError = stderr => {
5026
+ const lines = splitLines(stderr);
5027
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
5028
+ const message = lines[messageIndex];
5029
+ return {
5030
+ message,
5031
+ code: ERR_MODULE_NOT_FOUND
5032
+ };
5033
+ };
5034
+ const isNormalStackLine = line => {
5035
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
5036
+ };
5037
+ const getDetails = lines => {
5038
+ const index = lines.findIndex(isNormalStackLine);
5039
+ if (index === -1) {
5040
+ return {
5041
+ actualMessage: joinLines(lines),
5042
+ rest: []
5043
+ };
5044
+ }
5045
+ let lastIndex = index - 1;
5046
+ while (++lastIndex < lines.length) {
5047
+ if (!isNormalStackLine(lines[lastIndex])) {
5048
+ break;
5049
+ }
5050
+ }
5051
+ return {
5052
+ actualMessage: lines[index - 1],
5053
+ rest: lines.slice(index, lastIndex)
5054
+ };
5055
+ };
5056
+ const getHelpfulChildProcessError = (stdout, stderr) => {
5057
+ if (isUnhelpfulNativeModuleError(stderr)) {
5058
+ return getNativeModuleErrorMessage(stderr);
5059
+ }
5060
+ if (isModulesSyntaxError(stderr)) {
5061
+ return getModuleSyntaxError();
5062
+ }
5063
+ if (isModuleNotFoundError(stderr)) {
5064
+ return getModuleNotFoundError(stderr);
5065
+ }
5066
+ const lines = splitLines(stderr);
5067
+ const {
5068
+ actualMessage,
5069
+ rest
5070
+ } = getDetails(lines);
5071
+ return {
5072
+ message: `${actualMessage}`,
5073
+ code: '',
5074
+ stack: rest
5075
+ };
5076
+ };
5077
+ const normalizeLine = line => {
5078
+ if (line.startsWith('Error: ')) {
5079
+ return line.slice(`Error: `.length);
5080
+ }
5081
+ if (line.startsWith('VError: ')) {
5082
+ return line.slice(`VError: `.length);
5083
+ }
5084
+ return line;
5085
+ };
5086
+ const getCombinedMessage = (error, message) => {
5087
+ const stringifiedError = normalizeLine(`${error}`);
5088
+ if (message) {
5089
+ return `${message}: ${stringifiedError}`;
5090
+ }
5091
+ return stringifiedError;
5092
+ };
5093
+ const NewLine = '\n';
5094
+ const getNewLineIndex = (string, startIndex = undefined) => {
5095
+ return string.indexOf(NewLine, startIndex);
5096
+ };
5097
+ const mergeStacks = (parent, child) => {
5098
+ if (!child) {
5099
+ return parent;
5100
+ }
5101
+ const parentNewLineIndex = getNewLineIndex(parent);
5102
+ const childNewLineIndex = getNewLineIndex(child);
5103
+ if (childNewLineIndex === -1) {
5104
+ return parent;
5105
+ }
5106
+ const parentFirstLine = parent.slice(0, parentNewLineIndex);
5107
+ const childRest = child.slice(childNewLineIndex);
5108
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
5109
+ if (parentFirstLine.includes(childFirstLine)) {
5110
+ return parentFirstLine + childRest;
5111
+ }
5112
+ return child;
5113
+ };
5114
+ class VError extends Error {
5115
+ constructor(error, message) {
5116
+ const combinedMessage = getCombinedMessage(error, message);
5117
+ super(combinedMessage);
5118
+ this.name = 'VError';
5119
+ if (error instanceof Error) {
5120
+ this.stack = mergeStacks(this.stack, error.stack);
5121
+ }
5122
+ if (error.codeFrame) {
5123
+ // @ts-ignore
5124
+ this.codeFrame = error.codeFrame;
5125
+ }
5126
+ if (error.code) {
5127
+ // @ts-ignore
5128
+ this.code = error.code;
5129
+ }
5130
+ }
5131
+ }
5132
+ let IpcError$1 = class IpcError extends VError {
5133
+ // @ts-ignore
5134
+ constructor(betterMessage, stdout = '', stderr = '') {
5135
+ if (stdout || stderr) {
5136
+ // @ts-ignore
5137
+ const {
5138
+ message,
5139
+ code,
5140
+ stack
5141
+ } = getHelpfulChildProcessError(stdout, stderr);
5142
+ const cause = new Error(message);
5143
+ // @ts-ignore
5144
+ cause.code = code;
5145
+ cause.stack = stack;
5146
+ super(cause, betterMessage);
5147
+ } else {
5148
+ super(betterMessage);
5149
+ }
5150
+ // @ts-ignore
5151
+ this.name = 'IpcError';
5152
+ // @ts-ignore
5153
+ this.stdout = stdout;
5154
+ // @ts-ignore
5155
+ this.stderr = stderr;
5156
+ }
5157
+ };
5158
+ const withResolvers$1 = () => {
5159
+ let _resolve;
5160
+ const promise = new Promise(resolve => {
5161
+ _resolve = resolve;
5162
+ });
5163
+ return {
5164
+ resolve: _resolve,
5165
+ promise
5166
+ };
5167
+ };
5168
+ const waitForFirstMessage = async port => {
5169
+ const {
5170
+ resolve,
5171
+ promise
5172
+ } = withResolvers$1();
5173
+ port.addEventListener('message', resolve, {
5174
+ once: true
5175
+ });
5176
+ const event = await promise;
5177
+ // @ts-ignore
5178
+ return event.data;
5179
+ };
5180
+ const listen$2 = async () => {
5181
+ const parentIpcRaw = listen$3();
5182
+ signal$2(parentIpcRaw);
5183
+ const parentIpc = wrap$5(parentIpcRaw);
5184
+ const firstMessage = await waitForFirstMessage(parentIpc);
5185
+ if (firstMessage.method !== 'initialize') {
5186
+ throw new IpcError$1('unexpected first message');
5187
+ }
5188
+ const type = firstMessage.params[0];
5189
+ if (type === 'message-port') {
5190
+ parentIpc.dispose();
5191
+ const port = firstMessage.params[1];
5192
+ return port;
5193
+ }
5194
+ return globalThis;
5195
+ };
5196
+ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
5197
+ constructor(port) {
5198
+ super(port);
5199
+ }
5200
+ getData(event) {
5201
+ return getData$1(event);
5202
+ }
5203
+ send(message) {
5204
+ this._rawIpc.postMessage(message);
5205
+ }
5206
+ sendAndTransfer(message, transfer) {
5207
+ this._rawIpc.postMessage(message, transfer);
5208
+ }
5209
+ dispose() {
5210
+ if (this._rawIpc.close) {
5211
+ this._rawIpc.close();
5212
+ }
5213
+ }
5214
+ onClose(callback) {
5215
+ // ignore
5216
+ }
5217
+ onMessage(callback) {
5218
+ this._rawIpc.addEventListener('message', callback);
5219
+ this._rawIpc.start();
5220
+ }
5221
+ }
5222
+ const wrap$4 = port => {
5223
+ return new IpcChildWithModuleWorkerAndMessagePort(port);
5224
+ };
5225
+ const IpcChildWithModuleWorkerAndMessagePort$1 = {
5226
+ __proto__: null,
5227
+ listen: listen$2,
5228
+ wrap: wrap$4
5229
+ };
5230
+ const listen$1 = () => {
5231
+ return window;
5232
+ };
5233
+ const signal$1 = global => {
5234
+ global.postMessage(readyMessage);
5235
+ };
5236
+ class IpcChildWithWindow extends Ipc {
5237
+ getData(event) {
5238
+ return getData$1(event);
5239
+ }
5240
+ send(message) {
5241
+ this._rawIpc.postMessage(message);
5242
+ }
5243
+ sendAndTransfer(message, transfer) {
5244
+ this._rawIpc.postMessage(message, location.origin, transfer);
5245
+ }
5246
+ dispose() {
5247
+ // ignore
5248
+ }
5249
+ onClose(callback) {
5250
+ // ignore
5251
+ }
5252
+ onMessage(callback) {
5253
+ const wrapped = event => {
5254
+ const {
5255
+ ports
5256
+ } = event;
5257
+ if (ports.length) {
5258
+ return;
5259
+ }
5260
+ callback(event);
5261
+ this._rawIpc.removeEventListener('message', wrapped);
5262
+ };
5263
+ this._rawIpc.addEventListener('message', wrapped);
5264
+ }
5265
+ }
5266
+ const wrap$3 = window => {
5267
+ return new IpcChildWithWindow(window);
5268
+ };
5269
+ const IpcChildWithWindow$1 = {
5270
+ __proto__: null,
5271
+ listen: listen$1,
5272
+ signal: signal$1,
5273
+ wrap: wrap$3
5274
+ };
5275
+ const listen$4 = ({
5276
+ port
5277
+ }) => {
5278
+ return port;
5279
+ };
5280
+ const signal = port => {
5281
+ port.postMessage(readyMessage);
5282
+ };
5283
+ class IpcChildWithMessagePort extends Ipc {
5284
+ constructor(port) {
5285
+ super(port);
5286
+ }
5287
+ getData(event) {
5288
+ return getData$1(event);
5289
+ }
5290
+ send(message) {
5291
+ this._rawIpc.postMessage(message);
5292
+ }
5293
+ sendAndTransfer(message, transfer) {
5294
+ this._rawIpc.postMessage(message, transfer);
5295
+ }
5296
+ dispose() {
5297
+ // ignore
5298
+ }
5299
+ onClose(callback) {
5300
+ // ignore
5301
+ }
5302
+ onMessage(callback) {
5303
+ this._rawIpc.addEventListener('message', callback);
5304
+ this._rawIpc.start();
5305
+ }
5306
+ }
5307
+ const wrap$2 = port => {
5308
+ return new IpcChildWithMessagePort(port);
5309
+ };
5310
+ const IpcChildWithMessagePort$1 = {
5311
+ __proto__: null,
5312
+ listen: listen$4,
5313
+ signal,
5314
+ wrap: wrap$2
5315
+ };
5316
+
5317
+ const getModule = method => {
5318
+ switch (method) {
5319
+ case ModuleWorker:
5320
+ return IpcChildWithModuleWorker$1;
5321
+ case ModuleWorkerAndMessagePort:
5322
+ return IpcChildWithModuleWorkerAndMessagePort$1;
5323
+ case MessagePort$1:
5324
+ return IpcChildWithMessagePort$1;
5325
+ default:
5326
+ throw new Error('unexpected ipc type');
5327
+ }
5328
+ };
5329
+
5330
+ const listen = async ({
5331
+ method,
5332
+ ...options
5333
+ }) => {
5334
+ const module = await getModule(method);
5335
+ const rawIpc = await module.listen(options);
5336
+ if (module.signal) {
5337
+ module.signal(rawIpc);
5338
+ }
5339
+ const ipc = module.wrap(rawIpc);
5340
+ return ipc;
5341
+ };
5342
+
5343
+ const handleMessagePort = async port => {
5344
+ const ipc = await listen({
5345
+ method: MessagePort$1,
5346
+ port
5347
+ });
5348
+ handleIpc(ipc);
5349
+ };
5350
+
5351
+ const name = 'HandleMessagePort';
5352
+ const Commands$1 = {
5353
+ handleMessagePort: handleMessagePort
5354
+ };
5355
+
5356
+ const HandleMessagePort_ipc = {
5357
+ __proto__: null,
5358
+ Commands: Commands$1,
5359
+ name
5360
+ };
5361
+
5362
+ const Message = 'message';
5363
+ const Error$1 = 'error';
5364
+
5365
+ const withResolvers = () => {
5366
+ /**
5367
+ * @type {any}
5368
+ */
5369
+ let _resolve;
5370
+ /**
5371
+ * @type {any}
5372
+ */
5373
+ let _reject;
5374
+ const promise = new Promise((resolve, reject) => {
5375
+ _resolve = resolve;
5376
+ _reject = reject;
5377
+ });
5378
+ return {
5379
+ resolve: _resolve,
5380
+ reject: _reject,
5381
+ promise
5382
+ };
5383
+ };
5384
+
5385
+ const getFirstEvent = (eventTarget, eventMap) => {
5386
+ const {
5387
+ resolve,
5388
+ promise
4917
5389
  } = withResolvers();
4918
5390
  const listenerMap = Object.create(null);
4919
5391
  const cleanup = value => {
@@ -4961,9 +5433,9 @@ const isErrorEvent = event => {
4961
5433
  class WorkerError extends Error {
4962
5434
  constructor(event) {
4963
5435
  super(event.message);
4964
- const stackLines = splitLines(this.stack);
5436
+ const stackLines = splitLines$1(this.stack);
4965
5437
  const relevantLines = stackLines.slice(1);
4966
- const relevant = joinLines(relevantLines);
5438
+ const relevant = joinLines$1(relevantLines);
4967
5439
  this.stack = `${event.message}
4968
5440
  at Module (${event.filename}:${event.lineno}:${event.colno})
4969
5441
  ${relevant}`;
@@ -5131,76 +5603,6 @@ const handleIpcOnce = ipc => {
5131
5603
  }
5132
5604
  };
5133
5605
 
5134
- const getData$1 = event => {
5135
- return event.data;
5136
- };
5137
- const attachEvents$d = that => {
5138
- const handleMessage = (...args) => {
5139
- const data = that.getData(...args);
5140
- that.dispatchEvent(new MessageEvent('message', {
5141
- data
5142
- }));
5143
- };
5144
- that.onMessage(handleMessage);
5145
- const handleClose = event => {
5146
- that.dispatchEvent(new Event('close'));
5147
- };
5148
- that.onClose(handleClose);
5149
- };
5150
- class Ipc extends EventTarget {
5151
- constructor(rawIpc) {
5152
- super();
5153
- this._rawIpc = rawIpc;
5154
- attachEvents$d(this);
5155
- }
5156
- }
5157
- const readyMessage = 'ready';
5158
- const listen = () => {
5159
- return window;
5160
- };
5161
- const signal = global => {
5162
- global.postMessage(readyMessage);
5163
- };
5164
- class IpcChildWithWindow extends Ipc {
5165
- getData(event) {
5166
- return getData$1(event);
5167
- }
5168
- send(message) {
5169
- this._rawIpc.postMessage(message);
5170
- }
5171
- sendAndTransfer(message, transfer) {
5172
- this._rawIpc.postMessage(message, location.origin, transfer);
5173
- }
5174
- dispose() {
5175
- // ignore
5176
- }
5177
- onClose(callback) {
5178
- // ignore
5179
- }
5180
- onMessage(callback) {
5181
- const wrapped = event => {
5182
- const {
5183
- ports
5184
- } = event;
5185
- if (ports.length) {
5186
- return;
5187
- }
5188
- callback(event);
5189
- this._rawIpc.removeEventListener('message', wrapped);
5190
- };
5191
- this._rawIpc.addEventListener('message', wrapped);
5192
- }
5193
- }
5194
- const wrap$2 = window => {
5195
- return new IpcChildWithWindow(window);
5196
- };
5197
- const IpcChildWithWindow$1 = {
5198
- __proto__: null,
5199
- listen,
5200
- signal,
5201
- wrap: wrap$2
5202
- };
5203
-
5204
5606
  // TODO use handleIncomingIpc function
5205
5607
  const create$x = async ({
5206
5608
  port,