@lvce-editor/renderer-process 1.0.0 → 2.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.
@@ -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
@@ -3208,7 +3213,7 @@ const create$Menu$1 = () => {
3208
3213
  // })
3209
3214
  $Menu.onkeydown = handleKeyDown$5;
3210
3215
  $Menu.addEventListener(FocusOut, handleFocusOut$1);
3211
- $Menu.oncontextmenu = handleContextMenu$9;
3216
+ $Menu.oncontextmenu = handleContextMenu$a;
3212
3217
  // $ContextMenu.onfocus = handleFocus
3213
3218
  // $ContextMenu.onblur = handleBlur
3214
3219
  return $Menu;
@@ -3237,14 +3242,14 @@ const handleBackDropMouseDown = event => {
3237
3242
  stopPropagation(event);
3238
3243
  send( /* Menu.hide */'Menu.hide');
3239
3244
  };
3240
- const handleContextMenu$9 = event => {
3245
+ const handleContextMenu$a = event => {
3241
3246
  preventDefault(event);
3242
3247
  };
3243
3248
  const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom, mouseBlocking = false) => {
3244
3249
  if (mouseBlocking) {
3245
3250
  const $BackDrop = create$BackDrop();
3246
3251
  $BackDrop.onmousedown = handleBackDropMouseDown;
3247
- $BackDrop.oncontextmenu = handleContextMenu$9;
3252
+ $BackDrop.oncontextmenu = handleContextMenu$a;
3248
3253
  // @ts-expect-error
3249
3254
  state$2.$BackDrop = $BackDrop;
3250
3255
  append$1($BackDrop);
@@ -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,43 +4881,510 @@ 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,
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,
4916
5388
  promise
4917
5389
  } = withResolvers();
4918
5390
  const listenerMap = Object.create(null);
@@ -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,
@@ -5263,7 +5665,7 @@ const handleFocus$c = () => {
5263
5665
 
5264
5666
  // TODO use context menu events function again
5265
5667
 
5266
- const handleContextMenu$8 = event => {
5668
+ const handleContextMenu$9 = event => {
5267
5669
  preventDefault(event);
5268
5670
  const {
5269
5671
  button,
@@ -5277,7 +5679,7 @@ const returnValue$5 = true;
5277
5679
  const ViewletActivityBarEvents = {
5278
5680
  __proto__: null,
5279
5681
  handleBlur: handleBlur$9,
5280
- handleContextMenu: handleContextMenu$8,
5682
+ handleContextMenu: handleContextMenu$9,
5281
5683
  handleFocus: handleFocus$c,
5282
5684
  handleMouseDown: handleMouseDown$3,
5283
5685
  returnValue: returnValue$5
@@ -5307,10 +5709,10 @@ forwardViewletCommand('clearFilter');
5307
5709
  const close = forwardViewletCommand('close');
5308
5710
  forwardViewletCommand('closeEditor');
5309
5711
  const closeMenu$1 = forwardViewletCommand('closeMenu');
5310
- const compositionEnd = forwardViewletCommand('compositionEnd');
5311
- const compositionStart = forwardViewletCommand('compositionStart');
5312
- const compositionUpdate = forwardViewletCommand('compositionUpdate');
5313
- const cut = forwardViewletCommand('cut');
5712
+ forwardViewletCommand('compositionEnd');
5713
+ forwardViewletCommand('compositionStart');
5714
+ forwardViewletCommand('compositionUpdate');
5715
+ forwardViewletCommand('cut');
5314
5716
  forwardViewletCommand('focus');
5315
5717
  forwardViewletCommand('focusIndex');
5316
5718
  const focusNext = forwardViewletCommand('focusNext');
@@ -5332,7 +5734,7 @@ forwardViewletCommand('handleClickOpenFile');
5332
5734
  forwardViewletCommand('handleClickRestore');
5333
5735
  const handleClickTab$2 = forwardViewletCommand('handleClickTab');
5334
5736
  forwardViewletCommand('handleClickToggleMaximize');
5335
- const handleContextMenu$7 = forwardViewletCommand('handleContextMenu');
5737
+ const handleContextMenu$8 = forwardViewletCommand('handleContextMenu');
5336
5738
  const handleDoubleClick = forwardViewletCommand('handleDoubleClick');
5337
5739
  const handleDragEnd$1 = forwardViewletCommand('handleDragEnd');
5338
5740
  const handleDragLeave$1 = forwardViewletCommand('handleDragLeave');
@@ -5352,10 +5754,10 @@ forwardViewletCommand('handleListFocus');
5352
5754
  const handleMenuClick$1 = forwardViewletCommand('handleMenuClick');
5353
5755
  const handleMenuMouseOver$1 = forwardViewletCommand('handleMenuMouseOver');
5354
5756
  const handleMouseDown$2 = forwardViewletCommand('handleMouseDown');
5355
- const handleMouseMove$1 = forwardViewletCommand('handleMouseMove');
5757
+ forwardViewletCommand('handleMouseMove');
5356
5758
  const handleMouseOut$1 = forwardViewletCommand('handleMouseOut');
5357
5759
  const handleMouseOver$1 = forwardViewletCommand('handleMouseOver');
5358
- const handlePointerCaptureLost$3 = forwardViewletCommand('handlePointerCaptureLost');
5760
+ forwardViewletCommand('handlePointerCaptureLost');
5359
5761
  const handlePointerDown$7 = forwardViewletCommand('handlePointerDown');
5360
5762
  const handlePointerMove$1 = forwardViewletCommand('handlePointerMove');
5361
5763
  forwardViewletCommand('handlePointerOver');
@@ -5366,12 +5768,12 @@ const handleResizerClick = forwardViewletCommand('handleResizerClick');
5366
5768
  const handleResizerMove = forwardViewletCommand('handleResizerMove');
5367
5769
  const handleScrollBarCaptureLost = forwardViewletCommand('handleScrollBarCaptureLost');
5368
5770
  const handleScrollBarClick = forwardViewletCommand('handleScrollBarClick');
5369
- const handleScrollBarHorizontalMove = forwardViewletCommand('handleScrollBarHorizontalMove');
5370
- const handleScrollBarHorizontalPointerDown$1 = forwardViewletCommand('handleScrollBarHorizontalPointerDown');
5771
+ forwardViewletCommand('handleScrollBarHorizontalMove');
5772
+ forwardViewletCommand('handleScrollBarHorizontalPointerDown');
5371
5773
  const handleScrollBarMove = forwardViewletCommand('handleScrollBarMove');
5372
5774
  const handleScrollBarThumbPointerMove$3 = forwardViewletCommand('handleScrollBarThumbPointerMove');
5373
- const handleScrollBarVerticalMove = forwardViewletCommand('handleScrollBarMove');
5374
- const handleScrollBarVerticalPointerDown$1 = forwardViewletCommand('handleScrollBarVerticalPointerDown');
5775
+ forwardViewletCommand('handleScrollBarMove');
5776
+ forwardViewletCommand('handleScrollBarVerticalPointerDown');
5375
5777
  forwardViewletCommand('handleSliderPointerDown');
5376
5778
  const handleSliderPointerMove$1 = forwardViewletCommand('handleSliderPointerMove');
5377
5779
  const handleTabClick = forwardViewletCommand('handleTabClick');
@@ -5384,19 +5786,19 @@ const handleTouchMove$1 = forwardViewletCommand('handleTouchMove');
5384
5786
  const handleTouchStart$1 = forwardViewletCommand('handleTouchStart');
5385
5787
  const handleWheel$4 = forwardViewletCommand('handleWheel');
5386
5788
  const hidePanel = forwardViewletCommand('hidePanel');
5387
- const moveRectangleSelectionPx = forwardViewletCommand('moveRectangleSelectionPx');
5388
- const moveSelectionPx = forwardViewletCommand('moveSelectionPx');
5389
- const paste = forwardViewletCommand('paste');
5789
+ forwardViewletCommand('moveRectangleSelectionPx');
5790
+ forwardViewletCommand('moveSelectionPx');
5791
+ forwardViewletCommand('paste');
5390
5792
  forwardViewletCommand('replaceAll');
5391
5793
  const selectIndex = forwardViewletCommand('selectIndex');
5392
- const setDelta = forwardViewletCommand('setDelta');
5794
+ forwardViewletCommand('setDelta');
5393
5795
  forwardViewletCommand('toggleMatchCase');
5394
5796
  forwardViewletCommand('toggleMatchWholeWord');
5395
5797
  const toggleMaximize = forwardViewletCommand('toggleMaximize');
5396
5798
  const toggleReplace = forwardViewletCommand('toggleReplace');
5397
5799
  forwardViewletCommand('toggleUseRegularExpression');
5398
5800
  forwardViewletCommand('type');
5399
- const typeWithAutoClosing = forwardViewletCommand('typeWithAutoClosing');
5801
+ forwardViewletCommand('typeWithAutoClosing');
5400
5802
  const updateEditingValue = forwardViewletCommand('updateEditingValue');
5401
5803
 
5402
5804
  const handleAudioError = event => {
@@ -6124,7 +6526,7 @@ const handleWheel$2 = event => {
6124
6526
  *
6125
6527
  * @param {MouseEvent} event
6126
6528
  */
6127
- const handleContextMenu$6 = event => {
6529
+ const handleContextMenu$7 = event => {
6128
6530
  preventDefault(event);
6129
6531
  const {
6130
6532
  button,
@@ -6132,7 +6534,7 @@ const handleContextMenu$6 = event => {
6132
6534
  clientY
6133
6535
  } = event;
6134
6536
  const uid = fromEvent(event);
6135
- handleContextMenu$7(uid, button, clientX, clientY);
6537
+ handleContextMenu$8(uid, button, clientX, clientY);
6136
6538
  };
6137
6539
  const handleError$5 = event => {
6138
6540
  const uid = fromEvent(event);
@@ -6157,7 +6559,7 @@ const attachEvents$a = state => {
6157
6559
  attachEvents$c($Viewlet, {
6158
6560
  [PointerDown]: handlePointerDown$5,
6159
6561
  [PointerUp]: handlePointerUp,
6160
- [ContextMenu]: handleContextMenu$6,
6562
+ [ContextMenu]: handleContextMenu$7,
6161
6563
  [FocusIn]: handleFocus$9
6162
6564
  });
6163
6565
  $Viewlet.addEventListener(Error$3, handleError$5, Capture);
@@ -6221,12 +6623,26 @@ const QuickInput = 'Quick Input';
6221
6623
  const SideBar = 'Side Bar';
6222
6624
  const StatusBar = 'Status Bar';
6223
6625
 
6626
+ const attachEventsFunctional = ($Node, eventMap) => {
6627
+ for (const [key] of Object.entries(eventMap)) {
6628
+ if (key === 'returnValue') {
6629
+ continue;
6630
+ }
6631
+ attachEvent($Node, eventMap, key, key);
6632
+ }
6633
+ };
6634
+
6224
6635
  const Text$1 = 'text';
6225
6636
 
6226
6637
  const getText = clipBoardData => {
6227
6638
  return clipBoardData.getData(Text$1);
6228
6639
  };
6229
6640
 
6641
+ const detachEvent = ($Node, key, listener) => {
6642
+ const wrapped = getWrappedListener(listener, true);
6643
+ $Node.removeEventListener(key, wrapped);
6644
+ };
6645
+
6230
6646
  const None = 0;
6231
6647
  const Ctrl = 1;
6232
6648
  const Alt$1 = 2;
@@ -6241,8 +6657,6 @@ const getModifierKey = event => {
6241
6657
  return None;
6242
6658
  };
6243
6659
 
6244
- const InsertText = 'insertText';
6245
-
6246
6660
  const toSimpleTouch = touch => {
6247
6661
  return {
6248
6662
  x: touch.clientX,
@@ -6266,17 +6680,6 @@ const toSimpleTouchEvent = event => {
6266
6680
  };
6267
6681
  };
6268
6682
 
6269
- const handleContextMenu$5 = event => {
6270
- preventDefault(event);
6271
- const {
6272
- button,
6273
- clientX,
6274
- clientY
6275
- } = event;
6276
- const uid = fromEvent(event);
6277
- handleContextMenu$7(uid, button, clientX, clientY);
6278
- };
6279
-
6280
6683
  // TODO so many things in this file
6281
6684
 
6282
6685
 
@@ -6285,23 +6688,20 @@ const handleContextMenu$5 = event => {
6285
6688
  // TODO tree shake out mobile support when targeting electron -> less code -> less event listeners -> less memory -> less cpu
6286
6689
 
6287
6690
  const handleFocus$8 = event => {
6288
- const uid = fromEvent(event);
6289
- handleFocus$b(uid);
6691
+ return ['handleFocus'];
6290
6692
  };
6291
6693
  const handleMouseMove = event => {
6292
- const uid = fromEvent(event);
6293
6694
  const {
6294
6695
  clientX,
6295
6696
  clientY,
6296
6697
  altKey
6297
6698
  } = event;
6298
- handleMouseMove$1(uid, clientX, clientY, altKey);
6699
+ return ['handleMouseMove', clientX, clientY, altKey];
6299
6700
  };
6300
6701
  const handleBlur$6 = event => {
6301
6702
  // needed for save on blur
6302
6703
  // also needed to close completions on blur
6303
- const uid = fromEvent(event);
6304
- handleBlur$8(uid);
6704
+ return ['handleBlur'];
6305
6705
  };
6306
6706
 
6307
6707
  /**
@@ -6310,19 +6710,11 @@ const handleBlur$6 = event => {
6310
6710
  */
6311
6711
  const handleBeforeInput$1 = event => {
6312
6712
  preventDefault(event);
6313
- const uid = fromEvent(event);
6314
6713
  const {
6315
6714
  inputType,
6316
6715
  data
6317
6716
  } = event;
6318
- switch (inputType) {
6319
- case InsertText:
6320
- typeWithAutoClosing(uid, data);
6321
- break;
6322
- }
6323
- // if (!event.data) {
6324
- // return
6325
- // }
6717
+ return ['handleBeforeInput', inputType, data];
6326
6718
  };
6327
6719
 
6328
6720
  // TODO composition should be better supported,
@@ -6333,36 +6725,31 @@ const handleBeforeInput$1 = event => {
6333
6725
  // - vscode does not draw a line, but displays characters during composition
6334
6726
 
6335
6727
  const handleCompositionStart = event => {
6336
- const uid = fromEvent(event);
6337
6728
  const {
6338
6729
  data
6339
6730
  } = event;
6340
- compositionStart(uid, data);
6731
+ return ['compositionStart', data];
6341
6732
  };
6342
6733
  const handleCompositionUpdate = event => {
6343
- const uid = fromEvent(event);
6344
6734
  const {
6345
6735
  data
6346
6736
  } = event;
6347
- compositionUpdate(uid, data);
6737
+ return ['compositionUpdate', data];
6348
6738
  };
6349
6739
  const handleCompositionEnd = event => {
6350
- const uid = fromEvent(event);
6351
6740
  const {
6352
6741
  data
6353
6742
  } = event;
6354
- compositionEnd(uid, data);
6743
+ return ['compositionEnd', data];
6355
6744
  };
6356
6745
  const handleCut = event => {
6357
6746
  preventDefault(event);
6358
- const uid = fromEvent(event);
6359
- cut(uid);
6747
+ return ['cut'];
6360
6748
  };
6361
6749
  const isRightClick = event => {
6362
6750
  return event.button === RightClick;
6363
6751
  };
6364
6752
  const handleEditorPointerMove = event => {
6365
- const uid = fromEvent(event);
6366
6753
  const {
6367
6754
  clientX,
6368
6755
  clientY,
@@ -6370,19 +6757,17 @@ const handleEditorPointerMove = event => {
6370
6757
  } = event;
6371
6758
  // TODO if/else should be in renderer worker
6372
6759
  if (altKey) {
6373
- moveRectangleSelectionPx(uid, clientX, clientY);
6374
- } else {
6375
- moveSelectionPx(uid, clientX, clientY);
6760
+ return ['moveRectangleSelectionPx', clientX, clientY];
6376
6761
  }
6762
+ return ['moveSelectionPx', clientX, clientY];
6377
6763
  };
6378
6764
  const handleEditorLostPointerCapture = event => {
6379
- const uid = fromEvent(event);
6380
6765
  const {
6381
6766
  target
6382
6767
  } = event;
6383
- target.removeEventListener(PointerMove, handleEditorPointerMove);
6384
- target.removeEventListener(LostPointerCapture, handleEditorLostPointerCapture);
6385
- handlePointerCaptureLost$3(uid);
6768
+ detachEvent(target, PointerMove, handleEditorPointerMove);
6769
+ detachEvent(target, LostPointerCapture, handleEditorLostPointerCapture);
6770
+ return ['handlePointerCaptureLost'];
6386
6771
  };
6387
6772
 
6388
6773
  /**
@@ -6395,14 +6780,17 @@ const handleEditorPointerDown = event => {
6395
6780
  pointerId
6396
6781
  } = event;
6397
6782
  target.setPointerCapture(pointerId);
6398
- target.addEventListener(PointerMove, handleEditorPointerMove, Active);
6399
- target.addEventListener(LostPointerCapture, handleEditorLostPointerCapture);
6783
+ attachEventsFunctional(target, {
6784
+ [PointerMove]: handleEditorPointerMove,
6785
+ [LostPointerCapture]: handleEditorLostPointerCapture,
6786
+ returnValue: true
6787
+ });
6788
+ return [];
6400
6789
  };
6401
6790
  const handleMouseDown$1 = event => {
6402
6791
  if (isRightClick(event)) {
6403
- return;
6792
+ return [];
6404
6793
  }
6405
- const uid = fromEvent(event);
6406
6794
  preventDefault(event);
6407
6795
  const {
6408
6796
  clientX,
@@ -6410,7 +6798,7 @@ const handleMouseDown$1 = event => {
6410
6798
  detail
6411
6799
  } = event;
6412
6800
  const modifier = getModifierKey(event);
6413
- handleMouseDown$2(uid, modifier, clientX, clientY, detail);
6801
+ return ['handleMouseDown', modifier, clientX, clientY, detail];
6414
6802
  };
6415
6803
 
6416
6804
  // TODO figure out whether it is possible to register hover provider without mousemove
@@ -6421,7 +6809,6 @@ const handleMouseDown$1 = event => {
6421
6809
  * @param {WheelEvent} event
6422
6810
  */
6423
6811
  const handleWheel$1 = event => {
6424
- const uid = fromEvent(event);
6425
6812
  const {
6426
6813
  deltaMode,
6427
6814
  deltaX,
@@ -6430,16 +6817,15 @@ const handleWheel$1 = event => {
6430
6817
  // event.preventDefault()
6431
6818
  // const state = EditorHelper.getStateFromEvent(event)
6432
6819
  // TODO send editor id
6433
- setDelta(uid, deltaMode, deltaX, deltaY);
6820
+ return ['setDelta', deltaMode, deltaX, deltaY];
6434
6821
  };
6435
6822
  const handlePaste = event => {
6436
6823
  preventDefault(event);
6437
- const uid = fromEvent(event);
6438
6824
  const {
6439
6825
  clipboardData
6440
6826
  } = event;
6441
6827
  const text = getText(clipboardData);
6442
- paste(uid, text);
6828
+ return ['paste', text];
6443
6829
  };
6444
6830
 
6445
6831
  /**
@@ -6447,11 +6833,10 @@ const handlePaste = event => {
6447
6833
  * @param {PointerEvent} event
6448
6834
  */
6449
6835
  const handleScrollBarThumbVerticalPointerMove = event => {
6450
- const uid = fromEvent(event);
6451
6836
  const {
6452
6837
  clientY
6453
6838
  } = event;
6454
- handleScrollBarVerticalMove(uid, clientY);
6839
+ return ['handleScrollBarVerticalMove', clientY];
6455
6840
  };
6456
6841
 
6457
6842
  /**
@@ -6464,6 +6849,7 @@ const handleScrollBarVerticalPointerUp = event => {
6464
6849
  pointerId
6465
6850
  } = event;
6466
6851
  stopTracking(target, pointerId, handleScrollBarThumbVerticalPointerMove, handleScrollBarVerticalPointerUp);
6852
+ return [];
6467
6853
  };
6468
6854
 
6469
6855
  /**
@@ -6471,14 +6857,13 @@ const handleScrollBarVerticalPointerUp = event => {
6471
6857
  * @param {PointerEvent} event
6472
6858
  */
6473
6859
  const handleScrollBarVerticalPointerDown = event => {
6474
- const uid = fromEvent(event);
6475
6860
  const {
6476
6861
  target,
6477
6862
  pointerId,
6478
6863
  clientY
6479
6864
  } = event;
6480
6865
  startTracking(target, pointerId, handleScrollBarThumbVerticalPointerMove, handleScrollBarVerticalPointerUp);
6481
- handleScrollBarVerticalPointerDown$1(uid, clientY);
6866
+ return ['handleScrollBarVerticalPointerDown', clientY];
6482
6867
  };
6483
6868
 
6484
6869
  /**
@@ -6489,8 +6874,7 @@ const handleScrollBarThumbHorizontalPointerMove = event => {
6489
6874
  const {
6490
6875
  clientX
6491
6876
  } = event;
6492
- const uid = fromEvent(event);
6493
- handleScrollBarHorizontalMove(uid, clientX);
6877
+ return ['handleScrollBarHorizontalMove', clientX];
6494
6878
  };
6495
6879
 
6496
6880
  /**
@@ -6503,6 +6887,7 @@ const handleScrollBarHorizontalPointerUp = event => {
6503
6887
  pointerId
6504
6888
  } = event;
6505
6889
  stopTracking(target, pointerId, handleScrollBarThumbHorizontalPointerMove, handleScrollBarHorizontalPointerUp);
6890
+ return [];
6506
6891
  };
6507
6892
 
6508
6893
  /**
@@ -6516,12 +6901,21 @@ const handleScrollBarHorizontalPointerDown = event => {
6516
6901
  clientX
6517
6902
  } = event;
6518
6903
  startTracking(target, pointerId, handleScrollBarThumbHorizontalPointerMove, handleScrollBarHorizontalPointerUp);
6519
- handleScrollBarHorizontalPointerDown$1(clientX);
6904
+ return ['handleScrollBarHorizontalPointerDown', clientX];
6520
6905
  };
6521
6906
  const handleScrollBarContextMenu = event => {
6522
6907
  preventDefault(event);
6523
6908
  stopPropagation(event);
6524
6909
  };
6910
+ const handleContextMenu$6 = event => {
6911
+ preventDefault(event);
6912
+ const {
6913
+ button,
6914
+ clientX,
6915
+ clientY
6916
+ } = event;
6917
+ return ['handleContextMenu', button, clientX, clientY];
6918
+ };
6525
6919
 
6526
6920
  const setCursors = (state, dom) => {
6527
6921
  object(state);
@@ -6594,7 +6988,7 @@ const create$n = () => {
6594
6988
  $EditorInput.setAttribute('spellcheck', False);
6595
6989
  $EditorInput.role = TextBox;
6596
6990
  // TODO where to best put listeners (side effects)
6597
- attachEvents$c($EditorInput, {
6991
+ attachEventsFunctional($EditorInput, {
6598
6992
  [BeforeInput]: handleBeforeInput$1,
6599
6993
  [CompositionStart]: handleCompositionStart,
6600
6994
  [CompositionUpdate]: handleCompositionUpdate,
@@ -6602,7 +6996,8 @@ const create$n = () => {
6602
6996
  [Focus]: handleFocus$8,
6603
6997
  [Blur]: handleBlur$6,
6604
6998
  [Cut]: handleCut,
6605
- [Paste]: handlePaste
6999
+ [Paste]: handlePaste,
7000
+ returnValue: true
6606
7001
  });
6607
7002
  $EditorInput.name = 'editor';
6608
7003
  const $LayerCursor = document.createElement('div');
@@ -6611,9 +7006,10 @@ const create$n = () => {
6611
7006
  $LayerText.className = 'EditorRows';
6612
7007
  const $LayerGutter = document.createElement('div');
6613
7008
  $LayerGutter.className = 'Gutter';
6614
- attachEvents$c($LayerText, {
7009
+ attachEventsFunctional($LayerText, {
6615
7010
  [MouseDown]: handleMouseDown$1,
6616
- [PointerDown]: handleEditorPointerDown
7011
+ [PointerDown]: handleEditorPointerDown,
7012
+ returnValue: true
6617
7013
  });
6618
7014
  const $ScrollBarThumbVertical = document.createElement('div');
6619
7015
  $ScrollBarThumbVertical.className = 'ScrollBarThumb ScrollBarThumbVertical';
@@ -6623,9 +7019,10 @@ const create$n = () => {
6623
7019
  $ScrollBarDiagnostics.className = 'EditorScrollBarDiagnostics';
6624
7020
  const $ScrollBarVertical = document.createElement('div');
6625
7021
  $ScrollBarVertical.className = 'ScrollBar ScrollBarVertical';
6626
- attachEvents$c($ScrollBarVertical, {
7022
+ attachEventsFunctional($ScrollBarVertical, {
6627
7023
  [PointerDown]: handleScrollBarVerticalPointerDown,
6628
- [ContextMenu]: handleScrollBarContextMenu
7024
+ [ContextMenu]: handleScrollBarContextMenu,
7025
+ returnValue: true
6629
7026
  });
6630
7027
  $ScrollBarVertical.append($ScrollBarThumbVertical);
6631
7028
  const $ScrollBarThumbHorizontal = document.createElement('div');
@@ -6633,8 +7030,9 @@ const create$n = () => {
6633
7030
  const $ScrollBarHorizontal = document.createElement('div');
6634
7031
  $ScrollBarHorizontal.className = 'ScrollBar ScrollBarHorizontal';
6635
7032
  $ScrollBarHorizontal.append($ScrollBarThumbHorizontal);
6636
- attachEvents$c($ScrollBarHorizontal, {
6637
- [PointerDown]: handleScrollBarHorizontalPointerDown
7033
+ attachEventsFunctional($ScrollBarHorizontal, {
7034
+ [PointerDown]: handleScrollBarHorizontalPointerDown,
7035
+ returnValue: true
6638
7036
  });
6639
7037
 
6640
7038
  // $EditorRows.addEventListener('mousemove', handleMouseMove, { passive: true })
@@ -6664,11 +7062,11 @@ const create$n = () => {
6664
7062
  $Editor.className = 'Viewlet Editor';
6665
7063
  $Editor.role = Code;
6666
7064
  $Editor.append($LayerGutter, $EditorContent);
6667
- attachEvents$c($Editor, {
6668
- [ContextMenu]: handleContextMenu$5
7065
+ attachEventsFunctional($Editor, {
7066
+ [ContextMenu]: handleContextMenu$6,
7067
+ [Wheel]: handleWheel$1,
7068
+ returnValue: true
6669
7069
  });
6670
- $Editor.addEventListener(Wheel, handleWheel$1, Passive);
6671
- // $Editor.addEventListener(DomEventType.MouseMove, EditorEvents.handlePointerMove, DomEventOptions.Passive)
6672
7070
  return {
6673
7071
  $LayerCursor,
6674
7072
  $LayerSelections,
@@ -6864,6 +7262,17 @@ const ViewletError = {
6864
7262
  setMessage: setMessage$1
6865
7263
  };
6866
7264
 
7265
+ const handleContextMenu$5 = event => {
7266
+ preventDefault(event);
7267
+ const {
7268
+ button,
7269
+ clientX,
7270
+ clientY
7271
+ } = event;
7272
+ const uid = fromEvent(event);
7273
+ handleContextMenu$8(uid, button, clientX, clientY);
7274
+ };
7275
+
6867
7276
  const CopyMove = 'copyMove';
6868
7277
 
6869
7278
  const Text = 'text';
@@ -8347,7 +8756,7 @@ const handleContextMenu$4 = event => {
8347
8756
  clientY
8348
8757
  } = event;
8349
8758
  const uid = fromEvent(event);
8350
- handleContextMenu$7(uid, clientX, clientY);
8759
+ handleContextMenu$8(uid, clientX, clientY);
8351
8760
  };
8352
8761
 
8353
8762
  // TODO Main should not be bound to Editor -> Lazy load Editor