@lvce-editor/output-view 2.0.0 → 2.2.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.
@@ -225,8 +225,8 @@ const getModuleNotFoundError = stderr => {
225
225
  const messageIndex = lines.findIndex(isModuleNotFoundMessage);
226
226
  const message = lines[messageIndex];
227
227
  return {
228
- message,
229
- code: ERR_MODULE_NOT_FOUND
228
+ code: ERR_MODULE_NOT_FOUND,
229
+ message
230
230
  };
231
231
  };
232
232
  const isModuleNotFoundError = stderr => {
@@ -249,14 +249,14 @@ const isUnhelpfulNativeModuleError = stderr => {
249
249
  const getNativeModuleErrorMessage = stderr => {
250
250
  const message = getMessageCodeBlock(stderr);
251
251
  return {
252
- message: `Incompatible native node module: ${message}`,
253
- code: E_INCOMPATIBLE_NATIVE_MODULE
252
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
253
+ message: `Incompatible native node module: ${message}`
254
254
  };
255
255
  };
256
256
  const getModuleSyntaxError = () => {
257
257
  return {
258
- message: `ES Modules are not supported in electron`,
259
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
258
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
259
+ message: `ES Modules are not supported in electron`
260
260
  };
261
261
  };
262
262
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -275,8 +275,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
275
275
  rest
276
276
  } = getDetails(lines);
277
277
  return {
278
- message: actualMessage,
279
278
  code: '',
279
+ message: actualMessage,
280
280
  stack: rest
281
281
  };
282
282
  };
@@ -286,8 +286,8 @@ class IpcError extends VError {
286
286
  if (stdout || stderr) {
287
287
  // @ts-ignore
288
288
  const {
289
- message,
290
289
  code,
290
+ message,
291
291
  stack
292
292
  } = getHelpfulChildProcessError(stdout, stderr);
293
293
  const cause = new Error(message);
@@ -348,8 +348,8 @@ const wrap$f = global => {
348
348
  };
349
349
  const waitForFirstMessage = async port => {
350
350
  const {
351
- resolve,
352
- promise
351
+ promise,
352
+ resolve
353
353
  } = Promise.withResolvers();
354
354
  port.addEventListener('message', resolve, {
355
355
  once: true
@@ -369,8 +369,8 @@ const listen$6 = async () => {
369
369
  const type = firstMessage.params[0];
370
370
  if (type === 'message-port') {
371
371
  parentIpc.send({
372
- jsonrpc: '2.0',
373
372
  id: firstMessage.id,
373
+ jsonrpc: '2.0',
374
374
  result: null
375
375
  });
376
376
  parentIpc.dispose();
@@ -427,8 +427,8 @@ const removeListener = (emitter, type, callback) => {
427
427
  };
428
428
  const getFirstEvent = (eventEmitter, eventMap) => {
429
429
  const {
430
- resolve,
431
- promise
430
+ promise,
431
+ resolve
432
432
  } = Promise.withResolvers();
433
433
  const listenerMap = Object.create(null);
434
434
  const cleanup = value => {
@@ -440,8 +440,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
440
440
  for (const [event, type] of Object.entries(eventMap)) {
441
441
  const listener = event => {
442
442
  cleanup({
443
- type,
444
- event
443
+ event,
444
+ type
445
445
  });
446
446
  };
447
447
  addListener(eventEmitter, event, listener);
@@ -450,9 +450,9 @@ const getFirstEvent = (eventEmitter, eventMap) => {
450
450
  return promise;
451
451
  };
452
452
  const Message$1 = 3;
453
- const create$5$1 = async ({
454
- messagePort,
455
- isMessagePortOpen
453
+ const create$5 = async ({
454
+ isMessagePortOpen,
455
+ messagePort
456
456
  }) => {
457
457
  if (!isMessagePort(messagePort)) {
458
458
  throw new IpcError('port must be of type MessagePort');
@@ -465,8 +465,8 @@ const create$5$1 = async ({
465
465
  });
466
466
  messagePort.start();
467
467
  const {
468
- type,
469
- event
468
+ event,
469
+ type
470
470
  } = await eventPromise;
471
471
  if (type !== Message$1) {
472
472
  throw new IpcError('Failed to wait for ipc message');
@@ -501,61 +501,19 @@ const wrap$5 = messagePort => {
501
501
  };
502
502
  const IpcParentWithMessagePort$1 = {
503
503
  __proto__: null,
504
- create: create$5$1,
504
+ create: create$5,
505
505
  signal: signal$1,
506
506
  wrap: wrap$5
507
507
  };
508
508
 
509
- const Two = '2.0';
510
- const create$4$1 = (method, params) => {
511
- return {
512
- jsonrpc: Two,
513
- method,
514
- params
515
- };
516
- };
509
+ const Two$1 = '2.0';
517
510
  const callbacks = Object.create(null);
518
- const set$8 = (id, fn) => {
519
- callbacks[id] = fn;
520
- };
521
511
  const get$2 = id => {
522
512
  return callbacks[id];
523
513
  };
524
514
  const remove$1 = id => {
525
515
  delete callbacks[id];
526
516
  };
527
- let id = 0;
528
- const create$3$1 = () => {
529
- return ++id;
530
- };
531
- const registerPromise = () => {
532
- const id = create$3$1();
533
- const {
534
- resolve,
535
- promise
536
- } = Promise.withResolvers();
537
- set$8(id, resolve);
538
- return {
539
- id,
540
- promise
541
- };
542
- };
543
- const create$2$1 = (method, params) => {
544
- const {
545
- id,
546
- promise
547
- } = registerPromise();
548
- const message = {
549
- jsonrpc: Two,
550
- method,
551
- params,
552
- id
553
- };
554
- return {
555
- message,
556
- promise
557
- };
558
- };
559
517
  class JsonRpcError extends Error {
560
518
  constructor(message) {
561
519
  super(message);
@@ -749,9 +707,9 @@ const getErrorProperty = (error, prettyError) => {
749
707
  }
750
708
  };
751
709
  };
752
- const create$1$1 = (id, error) => {
710
+ const create$1$2 = (id, error) => {
753
711
  return {
754
- jsonrpc: Two,
712
+ jsonrpc: Two$1,
755
713
  id,
756
714
  error
757
715
  };
@@ -760,22 +718,22 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
760
718
  const prettyError = preparePrettyError(error);
761
719
  logError(error, prettyError);
762
720
  const errorProperty = getErrorProperty(error, prettyError);
763
- return create$1$1(id, errorProperty);
721
+ return create$1$2(id, errorProperty);
764
722
  };
765
- const create$6 = (message, result) => {
723
+ const create$3 = (message, result) => {
766
724
  return {
767
- jsonrpc: Two,
725
+ jsonrpc: Two$1,
768
726
  id: message.id,
769
727
  result: result ?? null
770
728
  };
771
729
  };
772
730
  const getSuccessResponse = (message, result) => {
773
731
  const resultProperty = result ?? null;
774
- return create$6(message, resultProperty);
732
+ return create$3(message, resultProperty);
775
733
  };
776
734
  const getErrorResponseSimple = (id, error) => {
777
735
  return {
778
- jsonrpc: Two,
736
+ jsonrpc: Two$1,
779
737
  id,
780
738
  error: {
781
739
  code: Custom,
@@ -862,29 +820,6 @@ const handleJsonRpcMessage = async (...args) => {
862
820
  }
863
821
  throw new JsonRpcError('unexpected message');
864
822
  };
865
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
866
- const {
867
- message,
868
- promise
869
- } = create$2$1(method, params);
870
- if (useSendAndTransfer && ipc.sendAndTransfer) {
871
- ipc.sendAndTransfer(message);
872
- } else {
873
- ipc.send(message);
874
- }
875
- const responseMessage = await promise;
876
- return unwrapJsonRpcResult(responseMessage);
877
- };
878
- const send = (transport, method, ...params) => {
879
- const message = create$4$1(method, params);
880
- transport.send(message);
881
- };
882
- const invoke$5 = (ipc, method, ...params) => {
883
- return invokeHelper(ipc, method, params, false);
884
- };
885
- const invokeAndTransfer$3 = (ipc, method, ...params) => {
886
- return invokeHelper(ipc, method, params, true);
887
- };
888
823
 
889
824
  class CommandNotFoundError extends Error {
890
825
  constructor(command) {
@@ -907,24 +842,87 @@ const execute = (command, ...args) => {
907
842
  return fn(...args);
908
843
  };
909
844
 
845
+ const Two = '2.0';
846
+ const create$s = (method, params) => {
847
+ return {
848
+ jsonrpc: Two,
849
+ method,
850
+ params
851
+ };
852
+ };
853
+ const create$r = (id, method, params) => {
854
+ const message = {
855
+ id,
856
+ jsonrpc: Two,
857
+ method,
858
+ params
859
+ };
860
+ return message;
861
+ };
862
+ let id = 0;
863
+ const create$q = () => {
864
+ return ++id;
865
+ };
866
+
867
+ /* eslint-disable n/no-unsupported-features/es-syntax */
868
+
869
+ const registerPromise = map => {
870
+ const id = create$q();
871
+ const {
872
+ promise,
873
+ resolve
874
+ } = Promise.withResolvers();
875
+ map[id] = resolve;
876
+ return {
877
+ id,
878
+ promise
879
+ };
880
+ };
881
+
882
+ // @ts-ignore
883
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
884
+ const {
885
+ id,
886
+ promise
887
+ } = registerPromise(callbacks);
888
+ const message = create$r(id, method, params);
889
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
890
+ ipc.sendAndTransfer(message);
891
+ } else {
892
+ ipc.send(message);
893
+ }
894
+ const responseMessage = await promise;
895
+ return unwrapJsonRpcResult(responseMessage);
896
+ };
910
897
  const createRpc = ipc => {
898
+ const callbacks = Object.create(null);
899
+ ipc._resolve = (id, response) => {
900
+ const fn = callbacks[id];
901
+ if (!fn) {
902
+ console.warn(`callback ${id} may already be disposed`);
903
+ return;
904
+ }
905
+ fn(response);
906
+ delete callbacks[id];
907
+ };
911
908
  const rpc = {
909
+ async dispose() {
910
+ await ipc?.dispose();
911
+ },
912
+ invoke(method, ...params) {
913
+ return invokeHelper(callbacks, ipc, method, params, false);
914
+ },
915
+ invokeAndTransfer(method, ...params) {
916
+ return invokeHelper(callbacks, ipc, method, params, true);
917
+ },
912
918
  // @ts-ignore
913
919
  ipc,
914
920
  /**
915
921
  * @deprecated
916
922
  */
917
923
  send(method, ...params) {
918
- send(ipc, method, ...params);
919
- },
920
- invoke(method, ...params) {
921
- return invoke$5(ipc, method, ...params);
922
- },
923
- invokeAndTransfer(method, ...params) {
924
- return invokeAndTransfer$3(ipc, method, ...params);
925
- },
926
- async dispose() {
927
- await ipc?.dispose();
924
+ const message = create$s(method, params);
925
+ ipc.send(message);
928
926
  }
929
927
  };
930
928
  return rpc;
@@ -941,7 +939,7 @@ const logError = () => {
941
939
  const handleMessage = event => {
942
940
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
943
941
  const actualExecute = event?.target?.execute || execute;
944
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
942
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
945
943
  };
946
944
  const handleIpc = ipc => {
947
945
  if ('addEventListener' in ipc) {
@@ -959,15 +957,16 @@ const listen$1 = async (module, options) => {
959
957
  const ipc = module.wrap(rawIpc);
960
958
  return ipc;
961
959
  };
962
- const create$5 = async ({
960
+ const create$4 = async ({
963
961
  commandMap,
962
+ isMessagePortOpen = true,
964
963
  messagePort
965
964
  }) => {
966
965
  // TODO create a commandMap per rpc instance
967
966
  register(commandMap);
968
967
  const rawIpc = await IpcParentWithMessagePort$1.create({
969
- messagePort,
970
- isMessagePortOpen: true
968
+ isMessagePortOpen,
969
+ messagePort
971
970
  });
972
971
  const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
973
972
  handleIpc(ipc);
@@ -975,8 +974,9 @@ const create$5 = async ({
975
974
  messagePort.start();
976
975
  return rpc;
977
976
  };
978
- const create$3 = async ({
977
+ const create$2$1 = async ({
979
978
  commandMap,
979
+ isMessagePortOpen,
980
980
  send
981
981
  }) => {
982
982
  const {
@@ -984,16 +984,17 @@ const create$3 = async ({
984
984
  port2
985
985
  } = new MessageChannel();
986
986
  await send(port1);
987
- return create$5({
987
+ return create$4({
988
988
  commandMap,
989
+ isMessagePortOpen,
989
990
  messagePort: port2
990
991
  });
991
992
  };
992
993
  const TransferMessagePortRpcParent = {
993
994
  __proto__: null,
994
- create: create$3
995
+ create: create$2$1
995
996
  };
996
- const create$4 = async ({
997
+ const create$1$1 = async ({
997
998
  commandMap
998
999
  }) => {
999
1000
  // TODO create a commandMap per rpc instance
@@ -1005,7 +1006,7 @@ const create$4 = async ({
1005
1006
  };
1006
1007
  const WebWorkerRpcClient = {
1007
1008
  __proto__: null,
1008
- create: create$4
1009
+ create: create$1$1
1009
1010
  };
1010
1011
  const createMockRpc = ({
1011
1012
  commandMap
@@ -1020,98 +1021,13 @@ const createMockRpc = ({
1020
1021
  return command(...params);
1021
1022
  };
1022
1023
  const mockRpc = {
1024
+ invocations,
1023
1025
  invoke,
1024
- invokeAndTransfer: invoke,
1025
- invocations
1026
+ invokeAndTransfer: invoke
1026
1027
  };
1027
1028
  return mockRpc;
1028
1029
  };
1029
1030
 
1030
- const toCommandId = key => {
1031
- const dotIndex = key.indexOf('.');
1032
- return key.slice(dotIndex + 1);
1033
- };
1034
- const create$2 = () => {
1035
- const states = Object.create(null);
1036
- const commandMapRef = {};
1037
- return {
1038
- get(uid) {
1039
- return states[uid];
1040
- },
1041
- set(uid, oldState, newState) {
1042
- states[uid] = {
1043
- oldState,
1044
- newState
1045
- };
1046
- },
1047
- dispose(uid) {
1048
- delete states[uid];
1049
- },
1050
- getKeys() {
1051
- return Object.keys(states).map(key => {
1052
- return Number.parseInt(key);
1053
- });
1054
- },
1055
- clear() {
1056
- for (const key of Object.keys(states)) {
1057
- delete states[key];
1058
- }
1059
- },
1060
- wrapCommand(fn) {
1061
- const wrapped = async (uid, ...args) => {
1062
- const {
1063
- oldState,
1064
- newState
1065
- } = states[uid];
1066
- const newerState = await fn(newState, ...args);
1067
- if (oldState === newerState || newState === newerState) {
1068
- return;
1069
- }
1070
- const latest = states[uid];
1071
- states[uid] = {
1072
- oldState: latest.oldState,
1073
- newState: newerState
1074
- };
1075
- };
1076
- return wrapped;
1077
- },
1078
- wrapGetter(fn) {
1079
- const wrapped = (uid, ...args) => {
1080
- const {
1081
- newState
1082
- } = states[uid];
1083
- return fn(newState, ...args);
1084
- };
1085
- return wrapped;
1086
- },
1087
- diff(uid, modules, numbers) {
1088
- const {
1089
- oldState,
1090
- newState
1091
- } = states[uid];
1092
- const diffResult = [];
1093
- for (let i = 0; i < modules.length; i++) {
1094
- const fn = modules[i];
1095
- if (!fn(oldState, newState)) {
1096
- diffResult.push(numbers[i]);
1097
- }
1098
- }
1099
- return diffResult;
1100
- },
1101
- getCommandIds() {
1102
- const keys = Object.keys(commandMapRef);
1103
- const ids = keys.map(toCommandId);
1104
- return ids;
1105
- },
1106
- registerCommands(commandMap) {
1107
- Object.assign(commandMapRef, commandMap);
1108
- }
1109
- };
1110
- };
1111
- const terminate = () => {
1112
- globalThis.close();
1113
- };
1114
-
1115
1031
  const ToolBar = 'toolbar';
1116
1032
 
1117
1033
  const Button = 1;
@@ -1132,24 +1048,25 @@ const UpArrow = 14;
1132
1048
  const RightArrow = 15;
1133
1049
  const DownArrow = 16;
1134
1050
 
1135
- const Script$1 = 2;
1136
-
1137
- const DebugWorker = 55;
1138
1051
  const ExtensionHostWorker = 44;
1139
1052
  const FileSystemWorker$1 = 209;
1140
1053
  const OutputWorker = 7001;
1141
- const RendererWorker$1 = 1;
1054
+ const RendererWorker = 1;
1142
1055
 
1143
1056
  const rpcs = Object.create(null);
1144
- const set$7 = (id, rpc) => {
1057
+ const set$6 = (id, rpc) => {
1145
1058
  rpcs[id] = rpc;
1146
1059
  };
1147
1060
  const get$1 = id => {
1148
1061
  return rpcs[id];
1149
1062
  };
1150
1063
 
1151
- const create$1 = rpcId => {
1064
+ const create$2 = rpcId => {
1152
1065
  return {
1066
+ async dispose() {
1067
+ const rpc = get$1(rpcId);
1068
+ await rpc.dispose();
1069
+ },
1153
1070
  // @ts-ignore
1154
1071
  invoke(method, ...params) {
1155
1072
  const rpc = get$1(rpcId);
@@ -1163,436 +1080,105 @@ const create$1 = rpcId => {
1163
1080
  return rpc.invokeAndTransfer(method, ...params);
1164
1081
  },
1165
1082
  set(rpc) {
1166
- set$7(rpcId, rpc);
1167
- },
1168
- async dispose() {
1169
- const rpc = get$1(rpcId);
1170
- await rpc.dispose();
1083
+ set$6(rpcId, rpc);
1171
1084
  }
1172
1085
  };
1173
1086
  };
1174
1087
 
1175
1088
  const {
1176
- invoke: invoke$4,
1089
+ dispose: dispose$1,
1090
+ invoke: invoke$3,
1177
1091
  invokeAndTransfer: invokeAndTransfer$2,
1178
- set: set$6,
1179
- dispose: dispose$2
1180
- } = create$1(ExtensionHostWorker);
1092
+ set: set$5
1093
+ } = create$2(ExtensionHostWorker);
1181
1094
  const executeReferenceProvider = async (id, offset) => {
1182
1095
  // @ts-ignore
1183
- return invoke$4('ExtensionHostReference.executeReferenceProvider', id, offset);
1096
+ return invoke$3('ExtensionHostReference.executeReferenceProvider', id, offset);
1184
1097
  };
1185
1098
  const executeFileReferenceProvider = async id => {
1186
1099
  // @ts-ignore
1187
- return invoke$4('ExtensionHostReference.executeFileReferenceProvider', id);
1100
+ return invoke$3('ExtensionHostReference.executeFileReferenceProvider', id);
1188
1101
  };
1189
1102
  const getRuntimeStatus = async extensionId => {
1190
1103
  // @ts-ignore
1191
- return invoke$4('ExtensionHost.getRuntimeStatus', extensionId);
1104
+ return invoke$3('ExtensionHost.getRuntimeStatus', extensionId);
1192
1105
  };
1193
- const registerMockRpc$2 = commandMap => {
1106
+ const registerMockRpc$1 = commandMap => {
1194
1107
  const mockRpc = createMockRpc({
1195
1108
  commandMap
1196
1109
  });
1197
- set$6(mockRpc);
1110
+ set$5(mockRpc);
1198
1111
  return mockRpc;
1199
1112
  };
1200
1113
 
1201
1114
  const ExtensionHost = {
1202
1115
  __proto__: null,
1203
- dispose: dispose$2,
1116
+ dispose: dispose$1,
1204
1117
  executeFileReferenceProvider,
1205
1118
  executeReferenceProvider,
1206
1119
  getRuntimeStatus,
1207
- invoke: invoke$4,
1208
- invokeAndTransfer: invokeAndTransfer$2,
1209
- registerMockRpc: registerMockRpc$2,
1210
- set: set$6
1211
- };
1212
-
1213
- const {
1214
- invoke: invoke$3,
1215
- invokeAndTransfer: invokeAndTransfer$1,
1216
- set: set$5,
1217
- dispose: dispose$1
1218
- } = create$1(FileSystemWorker$1);
1219
- const remove = async dirent => {
1220
- return invoke$3('FileSystem.remove', dirent);
1221
- };
1222
- const readDirWithFileTypes = async uri => {
1223
- return invoke$3('FileSystem.readDirWithFileTypes', uri);
1224
- };
1225
- const getPathSeparator = async root => {
1226
- // @ts-ignore
1227
- return invoke$3('FileSystem.getPathSeparator', root);
1228
- };
1229
- const getRealPath = async path => {
1230
- return invoke$3('FileSystem.getRealPath', path);
1231
- };
1232
- const stat = async dirent => {
1233
- return invoke$3('FileSystem.stat', dirent);
1234
- };
1235
- const createFile = async uri => {
1236
- return invoke$3('FileSystem.writeFile', uri, '');
1237
- };
1238
- const readFile$2 = async uri => {
1239
- return invoke$3('FileSystem.readFile', uri);
1240
- };
1241
- const writeFile$1 = async (uri, content) => {
1242
- return invoke$3('FileSystem.writeFile', uri, content);
1243
- };
1244
- const mkdir = async uri => {
1245
- return invoke$3('FileSystem.mkdir', uri);
1246
- };
1247
- const rename = async (oldUri, newUri) => {
1248
- return invoke$3('FileSystem.rename', oldUri, newUri);
1249
- };
1250
- const copy = async (oldUri, newUri) => {
1251
- return invoke$3('FileSystem.copy', oldUri, newUri);
1252
- };
1253
- const exists = async uri => {
1254
- // @ts-ignore
1255
- return invoke$3('FileSystem.exists', uri);
1256
- };
1257
- const getFolderSize$1 = async uri => {
1258
- // @ts-ignore
1259
- return invoke$3('FileSystem.getFolderSize', uri);
1260
- };
1261
- const readFileAsBlob = async uri => {
1262
- // @ts-ignore
1263
- return invoke$3('FileSystem.readFileAsBlob', uri);
1264
- };
1265
- const appendFile = async (uri, text) => {
1266
- // @ts-ignore
1267
- return invoke$3('FileSystem.appendFile', uri, text);
1268
- };
1269
- const registerMockRpc$1 = commandMap => {
1270
- const mockRpc = createMockRpc({
1271
- commandMap
1272
- });
1273
- set$5(mockRpc);
1274
- return mockRpc;
1275
- };
1276
-
1277
- const FileSystemWorker = {
1278
- __proto__: null,
1279
- appendFile,
1280
- copy,
1281
- createFile,
1282
- dispose: dispose$1,
1283
- exists,
1284
- getFolderSize: getFolderSize$1,
1285
- getPathSeparator,
1286
- getRealPath,
1287
1120
  invoke: invoke$3,
1288
- invokeAndTransfer: invokeAndTransfer$1,
1289
- mkdir,
1290
- readDirWithFileTypes,
1291
- readFile: readFile$2,
1292
- readFileAsBlob,
1121
+ invokeAndTransfer: invokeAndTransfer$2,
1293
1122
  registerMockRpc: registerMockRpc$1,
1294
- remove,
1295
- rename,
1296
- set: set$5,
1297
- stat,
1298
- writeFile: writeFile$1
1123
+ set: set$5
1299
1124
  };
1300
1125
 
1301
1126
  const {
1302
- invoke: invoke$2,
1303
- invokeAndTransfer,
1304
- set: set$4,
1305
- dispose
1306
- } = create$1(RendererWorker$1);
1307
- const searchFileHtml = async uri => {
1308
- return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1309
- };
1310
- const getFilePathElectron = async file => {
1311
- return invoke$2('FileSystemHandle.getFilePathElectron', file);
1312
- };
1313
- /**
1314
- * @deprecated
1315
- */
1316
- const showContextMenu = async (x, y, id, ...args) => {
1317
- return invoke$2('ContextMenu.show', x, y, id, ...args);
1318
- };
1319
- const showContextMenu2 = async (uid, menuId, x, y, args) => {
1320
- number(uid);
1321
- number(menuId);
1322
- number(x);
1323
- number(y);
1324
- // @ts-ignore
1325
- await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1326
- };
1327
- const getElectronVersion = async () => {
1328
- return invoke$2('Process.getElectronVersion');
1329
- };
1330
- const applyBulkReplacement = async bulkEdits => {
1331
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
1332
- };
1333
- const setColorTheme = async id => {
1334
- // @ts-ignore
1335
- return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1336
- };
1337
- const getNodeVersion = async () => {
1338
- return invoke$2('Process.getNodeVersion');
1339
- };
1340
- const getChromeVersion = async () => {
1341
- return invoke$2('Process.getChromeVersion');
1342
- };
1343
- const getV8Version = async () => {
1344
- return invoke$2('Process.getV8Version');
1345
- };
1346
- const getFileHandles = async fileIds => {
1347
- const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
1348
- return files;
1349
- };
1350
- const setWorkspacePath = async path => {
1351
- await invoke$2('Workspace.setPath', path);
1352
- };
1353
- const registerWebViewInterceptor = async (id, port) => {
1354
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
1355
- };
1356
- const unregisterWebViewInterceptor = async id => {
1357
- await invoke$2('WebView.unregisterInterceptor', id);
1358
- };
1359
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
1360
- const command = 'HandleMessagePort.handleMessagePort';
1361
- // @ts-ignore
1362
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1363
- };
1364
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
1365
- const command = 'Errors.handleMessagePort';
1366
- // @ts-ignore
1367
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1368
- };
1369
- const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1370
- const command = 'Markdown.handleMessagePort';
1371
- // @ts-ignore
1372
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1373
- };
1374
- const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1375
- const command = 'IconTheme.handleMessagePort';
1376
- // @ts-ignore
1377
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1378
- };
1379
- const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
1380
- const command = 'FileSystem.handleMessagePort';
1381
- // @ts-ignore
1382
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1383
- };
1384
- const readFile$1 = async uri => {
1385
- return invoke$2('FileSystem.readFile', uri);
1386
- };
1387
- const getWebViewSecret = async key => {
1388
- // @ts-ignore
1389
- return invoke$2('WebView.getSecret', key);
1390
- };
1391
- const setWebViewPort = async (uid, port, origin, portType) => {
1392
- return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1393
- };
1394
- const setFocus = key => {
1395
- return invoke$2('Focus.setFocus', key);
1396
- };
1397
- const getFileIcon = async options => {
1398
- return invoke$2('IconTheme.getFileIcon', options);
1399
- };
1400
- const getColorThemeNames = async () => {
1401
- return invoke$2('ColorTheme.getColorThemeNames');
1402
- };
1403
- const disableExtension = async id => {
1404
- // @ts-ignore
1405
- return invoke$2('ExtensionManagement.disable', id);
1406
- };
1407
- const enableExtension = async id => {
1408
- // @ts-ignore
1409
- return invoke$2('ExtensionManagement.enable', id);
1410
- };
1411
- const handleDebugChange = async params => {
1412
- // @ts-ignore
1413
- return invoke$2('Run And Debug.handleChange', params);
1414
- };
1415
- const getFolderIcon = async options => {
1416
- return invoke$2('IconTheme.getFolderIcon', options);
1417
- };
1418
- const handleWorkspaceRefresh = async () => {
1419
- return invoke$2('Layout.handleWorkspaceRefresh');
1420
- };
1421
- const closeWidget = async widgetId => {
1422
- return invoke$2('Viewlet.closeWidget', widgetId);
1423
- };
1424
- const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1425
- const command = 'HandleMessagePort.handleMessagePort2';
1426
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1427
- };
1428
- const sendMessagePortToSearchProcess = async port => {
1429
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1430
- };
1431
- const confirm = async (message, options) => {
1432
- // @ts-ignore
1433
- const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1434
- return result;
1435
- };
1436
- const getRecentlyOpened = async () => {
1437
- return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1438
- };
1439
- const getKeyBindings$1 = async () => {
1440
- return invoke$2('KeyBindingsInitial.getKeyBindings');
1441
- };
1442
- const writeClipBoardText = async text => {
1443
- await invoke$2('ClipBoard.writeText', /* text */text);
1444
- };
1445
- const readClipBoardText = async () => {
1446
- return invoke$2('ClipBoard.readText');
1447
- };
1448
- const writeClipBoardImage = async blob => {
1449
- // @ts-ignore
1450
- await invoke$2('ClipBoard.writeImage', /* text */blob);
1451
- };
1452
- const searchFileMemory = async uri => {
1453
- // @ts-ignore
1454
- return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1455
- };
1456
- const searchFileFetch = async uri => {
1457
- return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1458
- };
1459
- const showMessageBox = async options => {
1460
- return invoke$2('ElectronDialog.showMessageBox', options);
1461
- };
1462
- const handleDebugResumed = async params => {
1463
- await invoke$2('Run And Debug.handleResumed', params);
1464
- };
1465
- const openWidget = async name => {
1466
- await invoke$2('Viewlet.openWidget', name);
1467
- };
1468
- const getIcons = async requests => {
1469
- const icons = await invoke$2('IconTheme.getIcons', requests);
1470
- return icons;
1471
- };
1472
- const activateByEvent$1 = event => {
1473
- return invoke$2('ExtensionHostManagement.activateByEvent', event);
1474
- };
1475
- const setAdditionalFocus = focusKey => {
1476
- // @ts-ignore
1477
- return invoke$2('Focus.setAdditionalFocus', focusKey);
1478
- };
1479
- const getActiveEditorId = () => {
1480
- // @ts-ignore
1481
- return invoke$2('GetActiveEditor.getActiveEditorId');
1482
- };
1483
- const getWorkspacePath = () => {
1484
- return invoke$2('Workspace.getPath');
1485
- };
1486
- const sendMessagePortToRendererProcess = async port => {
1487
- const command = 'HandleMessagePort.handleMessagePort';
1488
- // @ts-ignore
1489
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1490
- };
1491
- const sendMessagePortToTextMeasurementWorker = async port => {
1492
- const command = 'TextMeasurement.handleMessagePort';
1493
- // @ts-ignore
1494
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1495
- };
1496
- const sendMessagePortToSourceControlWorker = async port => {
1497
- const command = 'SourceControl.handleMessagePort';
1498
- // @ts-ignore
1499
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1500
- };
1501
- const getPreference = async key => {
1502
- return await invoke$2('Preferences.get', key);
1503
- };
1504
- const getAllExtensions = async () => {
1505
- return invoke$2('ExtensionManagement.getAllExtensions');
1506
- };
1507
- const rerenderEditor = async key => {
1508
- // @ts-ignore
1509
- return invoke$2('Editor.rerender', key);
1510
- };
1511
- const handleDebugPaused = async params => {
1512
- await invoke$2('Run And Debug.handlePaused', params);
1513
- };
1514
- const openUri = async (uri, focus, options) => {
1515
- await invoke$2('Main.openUri', uri, focus, options);
1516
- };
1517
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
1518
- await invokeAndTransfer(
1519
- // @ts-ignore
1520
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1521
- };
1522
- const handleDebugScriptParsed = async script => {
1523
- await invoke$2('Run And Debug.handleScriptParsed', script);
1524
- };
1525
- const getWindowId = async () => {
1526
- return invoke$2('GetWindowId.getWindowId');
1527
- };
1528
- const getBlob = async uri => {
1529
- // @ts-ignore
1530
- return invoke$2('FileSystem.getBlob', uri);
1531
- };
1532
- const getExtensionCommands = async () => {
1533
- return invoke$2('ExtensionHost.getCommands');
1127
+ dispose,
1128
+ invoke: invoke$2,
1129
+ invokeAndTransfer: invokeAndTransfer$1,
1130
+ set: set$4
1131
+ } = create$2(FileSystemWorker$1);
1132
+ const remove = async dirent => {
1133
+ return invoke$2('FileSystem.remove', dirent);
1534
1134
  };
1535
- const showErrorDialog = async errorInfo => {
1536
- // @ts-ignore
1537
- await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1135
+ const readDirWithFileTypes = async uri => {
1136
+ return invoke$2('FileSystem.readDirWithFileTypes', uri);
1538
1137
  };
1539
- const getFolderSize = async uri => {
1540
- // @ts-ignore
1541
- return await invoke$2('FileSystem.getFolderSize', uri);
1138
+ const getPathSeparator = async root => {
1139
+ return invoke$2('FileSystem.getPathSeparator', root);
1542
1140
  };
1543
- const getExtension = async id => {
1544
- // @ts-ignore
1545
- return invoke$2('ExtensionManagement.getExtension', id);
1141
+ const getRealPath = async path => {
1142
+ return invoke$2('FileSystem.getRealPath', path);
1546
1143
  };
1547
- const getMarkdownDom = async html => {
1548
- // @ts-ignore
1549
- return invoke$2('Markdown.getVirtualDom', html);
1144
+ const stat = async dirent => {
1145
+ return invoke$2('FileSystem.stat', dirent);
1550
1146
  };
1551
- const renderMarkdown = async (markdown, options) => {
1552
- // @ts-ignore
1553
- return invoke$2('Markdown.renderMarkdown', markdown, options);
1147
+ const createFile = async uri => {
1148
+ return invoke$2('FileSystem.writeFile', uri, '');
1554
1149
  };
1555
- const openNativeFolder = async uri => {
1556
- // @ts-ignore
1557
- await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1150
+ const readFile$1 = async uri => {
1151
+ return invoke$2('FileSystem.readFile', uri);
1558
1152
  };
1559
- const uninstallExtension = async id => {
1560
- return invoke$2('ExtensionManagement.uninstall', id);
1153
+ const writeFile$1 = async (uri, content) => {
1154
+ return invoke$2('FileSystem.writeFile', uri, content);
1561
1155
  };
1562
- const installExtension = async id => {
1563
- // @ts-ignore
1564
- return invoke$2('ExtensionManagement.install', id);
1156
+ const mkdir = async uri => {
1157
+ return invoke$2('FileSystem.mkdir', uri);
1565
1158
  };
1566
- const openExtensionSearch = async () => {
1567
- // @ts-ignore
1568
- return invoke$2('SideBar.openViewlet', 'Extensions');
1159
+ const rename = async (oldUri, newUri) => {
1160
+ return invoke$2('FileSystem.rename', oldUri, newUri);
1569
1161
  };
1570
- const setExtensionsSearchValue = async searchValue => {
1571
- // @ts-ignore
1572
- return invoke$2('Extensions.handleInput', searchValue, Script$1);
1162
+ const copy = async (oldUri, newUri) => {
1163
+ return invoke$2('FileSystem.copy', oldUri, newUri);
1573
1164
  };
1574
- const openExternal = async uri => {
1575
- // @ts-ignore
1576
- await invoke$2('Open.openExternal', uri);
1165
+ const exists = async uri => {
1166
+ return invoke$2('FileSystem.exists', uri);
1577
1167
  };
1578
- const openUrl = async uri => {
1579
- // @ts-ignore
1580
- await invoke$2('Open.openUrl', uri);
1168
+ const getFolderSize = async uri => {
1169
+ return invoke$2('FileSystem.getFolderSize', uri);
1581
1170
  };
1582
- const getAllPreferences = async () => {
1583
- // @ts-ignore
1584
- return invoke$2('Preferences.getAll');
1171
+ const readFileAsBlob = async uri => {
1172
+ return invoke$2('FileSystem.readFileAsBlob', uri);
1585
1173
  };
1586
- const showSaveFilePicker = async () => {
1587
- // @ts-ignore
1588
- return invoke$2('FilePicker.showSaveFilePicker');
1174
+ const appendFile = async (uri, text) => {
1175
+ return invoke$2('FileSystem.appendFile', uri, text);
1589
1176
  };
1590
- const getLogsDir$1 = async () => {
1591
- // @ts-ignore
1592
- return invoke$2('PlatformPaths.getLogsDir');
1177
+ const watchFile = async (watchId, uri, rpcId) => {
1178
+ await invoke$2('FileSystem.watchFile', watchId, uri, rpcId);
1593
1179
  };
1594
- const measureTextBlockHeight = async (actualInput, fontFamily, fontSize, lineHeightPx, width) => {
1595
- return invoke$2(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
1180
+ const unwatchFile = async watchId => {
1181
+ await invoke$2('FileSystem.unwatchFile', watchId);
1596
1182
  };
1597
1183
  const registerMockRpc = commandMap => {
1598
1184
  const mockRpc = createMockRpc({
@@ -1602,96 +1188,146 @@ const registerMockRpc = commandMap => {
1602
1188
  return mockRpc;
1603
1189
  };
1604
1190
 
1605
- const RendererWorker = {
1191
+ const FileSystemWorker = {
1606
1192
  __proto__: null,
1607
- activateByEvent: activateByEvent$1,
1608
- applyBulkReplacement,
1609
- closeWidget,
1610
- confirm,
1611
- disableExtension,
1193
+ appendFile,
1194
+ copy,
1195
+ createFile,
1612
1196
  dispose,
1613
- enableExtension,
1614
- getActiveEditorId,
1615
- getAllExtensions,
1616
- getAllPreferences,
1617
- getBlob,
1618
- getChromeVersion,
1619
- getColorThemeNames,
1620
- getElectronVersion,
1621
- getExtension,
1622
- getExtensionCommands,
1623
- getFileHandles,
1624
- getFileIcon,
1625
- getFilePathElectron,
1626
- getFolderIcon,
1197
+ exists,
1627
1198
  getFolderSize,
1628
- getIcons,
1629
- getKeyBindings: getKeyBindings$1,
1630
- getLogsDir: getLogsDir$1,
1631
- getMarkdownDom,
1632
- getNodeVersion,
1633
- getPreference,
1634
- getRecentlyOpened,
1635
- getV8Version,
1636
- getWebViewSecret,
1637
- getWindowId,
1638
- getWorkspacePath,
1639
- handleDebugChange,
1640
- handleDebugPaused,
1641
- handleDebugResumed,
1642
- handleDebugScriptParsed,
1643
- handleWorkspaceRefresh,
1644
- installExtension,
1199
+ getPathSeparator,
1200
+ getRealPath,
1645
1201
  invoke: invoke$2,
1646
- invokeAndTransfer,
1647
- measureTextBlockHeight,
1648
- openExtensionSearch,
1649
- openExternal,
1650
- openNativeFolder,
1651
- openUri,
1652
- openUrl,
1653
- openWidget,
1654
- readClipBoardText,
1202
+ invokeAndTransfer: invokeAndTransfer$1,
1203
+ mkdir,
1204
+ readDirWithFileTypes,
1655
1205
  readFile: readFile$1,
1206
+ readFileAsBlob,
1656
1207
  registerMockRpc,
1657
- registerWebViewInterceptor,
1658
- renderMarkdown,
1659
- rerenderEditor,
1660
- searchFileFetch,
1661
- searchFileHtml,
1662
- searchFileMemory,
1663
- sendMessagePortToEditorWorker,
1664
- sendMessagePortToErrorWorker,
1665
- sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
1666
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
1667
- sendMessagePortToIconThemeWorker,
1668
- sendMessagePortToMarkdownWorker,
1669
- sendMessagePortToRendererProcess,
1670
- sendMessagePortToSearchProcess,
1671
- sendMessagePortToSourceControlWorker,
1672
- sendMessagePortToSyntaxHighlightingWorker,
1673
- sendMessagePortToTextMeasurementWorker,
1208
+ remove,
1209
+ rename,
1674
1210
  set: set$4,
1675
- setAdditionalFocus,
1676
- setColorTheme,
1677
- setExtensionsSearchValue,
1678
- setFocus,
1679
- setWebViewPort,
1680
- setWorkspacePath,
1681
- showContextMenu,
1682
- showContextMenu2,
1683
- showErrorDialog,
1684
- showMessageBox,
1685
- showSaveFilePicker,
1686
- uninstallExtension,
1687
- unregisterWebViewInterceptor,
1688
- writeClipBoardImage,
1689
- writeClipBoardText
1211
+ stat,
1212
+ unwatchFile,
1213
+ watchFile,
1214
+ writeFile: writeFile$1
1215
+ };
1216
+
1217
+ const {
1218
+ invoke: invoke$1,
1219
+ invokeAndTransfer,
1220
+ set: set$3
1221
+ } = create$2(RendererWorker);
1222
+ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1223
+ const command = 'FileSystem.handleMessagePort';
1224
+ // @ts-ignore
1225
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1226
+ };
1227
+ const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1228
+ const command = 'HandleMessagePort.handleMessagePort2';
1229
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1230
+ };
1231
+ const activateByEvent = (event, assetDir, platform) => {
1232
+ return invoke$1('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
1233
+ };
1234
+ const showSaveFilePicker = async () => {
1235
+ // @ts-ignore
1236
+ return invoke$1('FilePicker.showSaveFilePicker');
1237
+ };
1238
+ const getLogsDir$1 = async () => {
1239
+ // @ts-ignore
1240
+ return invoke$1('PlatformPaths.getLogsDir');
1241
+ };
1242
+
1243
+ const toCommandId = key => {
1244
+ const dotIndex = key.indexOf('.');
1245
+ return key.slice(dotIndex + 1);
1246
+ };
1247
+ const create$1 = () => {
1248
+ const states = Object.create(null);
1249
+ const commandMapRef = {};
1250
+ return {
1251
+ get(uid) {
1252
+ return states[uid];
1253
+ },
1254
+ set(uid, oldState, newState) {
1255
+ states[uid] = {
1256
+ oldState,
1257
+ newState
1258
+ };
1259
+ },
1260
+ dispose(uid) {
1261
+ delete states[uid];
1262
+ },
1263
+ getKeys() {
1264
+ return Object.keys(states).map(key => {
1265
+ return Number.parseInt(key);
1266
+ });
1267
+ },
1268
+ clear() {
1269
+ for (const key of Object.keys(states)) {
1270
+ delete states[key];
1271
+ }
1272
+ },
1273
+ wrapCommand(fn) {
1274
+ const wrapped = async (uid, ...args) => {
1275
+ const {
1276
+ oldState,
1277
+ newState
1278
+ } = states[uid];
1279
+ const newerState = await fn(newState, ...args);
1280
+ if (oldState === newerState || newState === newerState) {
1281
+ return;
1282
+ }
1283
+ const latest = states[uid];
1284
+ states[uid] = {
1285
+ oldState: latest.oldState,
1286
+ newState: newerState
1287
+ };
1288
+ };
1289
+ return wrapped;
1290
+ },
1291
+ wrapGetter(fn) {
1292
+ const wrapped = (uid, ...args) => {
1293
+ const {
1294
+ newState
1295
+ } = states[uid];
1296
+ return fn(newState, ...args);
1297
+ };
1298
+ return wrapped;
1299
+ },
1300
+ diff(uid, modules, numbers) {
1301
+ const {
1302
+ oldState,
1303
+ newState
1304
+ } = states[uid];
1305
+ const diffResult = [];
1306
+ for (let i = 0; i < modules.length; i++) {
1307
+ const fn = modules[i];
1308
+ if (!fn(oldState, newState)) {
1309
+ diffResult.push(numbers[i]);
1310
+ }
1311
+ }
1312
+ return diffResult;
1313
+ },
1314
+ getCommandIds() {
1315
+ const keys = Object.keys(commandMapRef);
1316
+ const ids = keys.map(toCommandId);
1317
+ return ids;
1318
+ },
1319
+ registerCommands(commandMap) {
1320
+ Object.assign(commandMapRef, commandMap);
1321
+ }
1322
+ };
1323
+ };
1324
+ const terminate = () => {
1325
+ globalThis.close();
1690
1326
  };
1691
1327
 
1692
1328
  const {
1693
- set: set$3,
1694
1329
  readFile,
1330
+ set: set$2,
1695
1331
  writeFile
1696
1332
  } = FileSystemWorker;
1697
1333
 
@@ -1764,31 +1400,31 @@ const loadLines = async uri => {
1764
1400
  const content = await readFile(uri);
1765
1401
  const lines = content.split('\n').map(parseLine);
1766
1402
  return {
1403
+ code: 0,
1767
1404
  error: '',
1768
- lines,
1769
- code: 0
1405
+ lines
1770
1406
  };
1771
1407
  } catch (error) {
1772
1408
  if (isFileNotFoundError(error)) {
1773
1409
  return {
1410
+ code: 1,
1774
1411
  error: `log file not found`,
1775
- lines: [],
1776
- code: 1
1412
+ lines: []
1777
1413
  };
1778
1414
  }
1779
1415
  return {
1416
+ code: 2,
1780
1417
  error: `${error}`,
1781
- lines: [],
1782
- code: 2
1418
+ lines: []
1783
1419
  };
1784
1420
  }
1785
1421
  };
1786
1422
 
1787
1423
  const clear = async state => {
1788
1424
  const {
1789
- selectedOption,
1425
+ filterValue,
1790
1426
  options,
1791
- filterValue
1427
+ selectedOption
1792
1428
  } = state;
1793
1429
  // TODO make uri a property of state to make the code simpler
1794
1430
  const option = options.find(option => option.id === selectedOption);
@@ -1800,17 +1436,17 @@ const clear = async state => {
1800
1436
  } = option;
1801
1437
  await writeFile(uri, '');
1802
1438
  const {
1803
- lines,
1804
1439
  code,
1805
- error
1440
+ error,
1441
+ lines
1806
1442
  } = await loadLines(uri);
1807
1443
  const filteredItems = filterItems(lines, filterValue);
1808
1444
  return {
1809
1445
  ...state,
1810
- listItems: lines,
1811
1446
  error,
1812
1447
  errorCode: code,
1813
- filteredItems
1448
+ filteredItems,
1449
+ listItems: lines
1814
1450
  };
1815
1451
  };
1816
1452
 
@@ -1826,12 +1462,13 @@ const Script = 2;
1826
1462
 
1827
1463
  const {
1828
1464
  get,
1829
- set: set$2,
1830
- wrapCommand,
1831
- wrapGetter,
1832
- getKeys,
1833
1465
  getCommandIds,
1834
- registerCommands} = create$2();
1466
+ getKeys,
1467
+ registerCommands,
1468
+ set: set$1,
1469
+ wrapCommand,
1470
+ wrapGetter
1471
+ } = create$1();
1835
1472
 
1836
1473
  const create = (id, uri, x, y, width, height, platform, parentId) => {
1837
1474
  number(parentId);
@@ -1865,7 +1502,7 @@ const create = (id, uri, x, y, width, height, platform, parentId) => {
1865
1502
  x,
1866
1503
  y
1867
1504
  };
1868
- set$2(id, state, state);
1505
+ set$1(id, state, state);
1869
1506
  };
1870
1507
 
1871
1508
  const isEqual$2 = (oldState, newState) => {
@@ -1900,8 +1537,8 @@ const diff = (oldState, newState) => {
1900
1537
 
1901
1538
  const diff2 = uid => {
1902
1539
  const {
1903
- oldState,
1904
- newState
1540
+ newState,
1541
+ oldState
1905
1542
  } = get(uid);
1906
1543
  const diffResult = diff(oldState, newState);
1907
1544
  return diffResult;
@@ -1946,9 +1583,9 @@ const mergeClassNames = (...classNames) => {
1946
1583
 
1947
1584
  const text = data => {
1948
1585
  return {
1949
- type: Text$1,
1586
+ childCount: 0,
1950
1587
  text: data,
1951
- childCount: 0
1588
+ type: Text$1
1952
1589
  };
1953
1590
  };
1954
1591
 
@@ -1956,53 +1593,53 @@ const FocusProblems = 19;
1956
1593
 
1957
1594
  const getKeyBindings = () => {
1958
1595
  return [{
1959
- key: DownArrow,
1960
1596
  command: 'Problems.focusNext',
1597
+ key: DownArrow,
1961
1598
  when: FocusProblems
1962
1599
  }, {
1963
- key: UpArrow,
1964
1600
  command: 'Problems.focusPrevious',
1601
+ key: UpArrow,
1965
1602
  when: FocusProblems
1966
1603
  }, {
1967
- key: Home,
1968
1604
  command: 'Problems.focusFirst',
1605
+ key: Home,
1969
1606
  when: FocusProblems
1970
1607
  }, {
1971
- key: PageUp,
1972
1608
  command: 'Problems.focusFirst',
1609
+ key: PageUp,
1973
1610
  when: FocusProblems
1974
1611
  }, {
1975
- key: PageDown,
1976
1612
  command: 'Problems.focusLast',
1613
+ key: PageDown,
1977
1614
  when: FocusProblems
1978
1615
  }, {
1979
- key: End,
1980
1616
  command: 'Problems.focusLast',
1617
+ key: End,
1981
1618
  when: FocusProblems
1982
1619
  }, {
1983
- key: Space,
1984
1620
  command: 'Problems.selectCurrent',
1621
+ key: Space,
1985
1622
  when: FocusProblems
1986
1623
  }, {
1987
- key: Home,
1988
1624
  command: 'Problems.focusFirst',
1625
+ key: Home,
1989
1626
  when: FocusProblems
1990
1627
  }, {
1991
- key: End,
1992
1628
  command: 'Problems.focusLast',
1629
+ key: End,
1993
1630
  when: FocusProblems
1994
1631
  }, {
1995
- key: LeftArrow,
1996
1632
  command: 'Problems.handleArrowLeft',
1633
+ key: LeftArrow,
1997
1634
  when: FocusProblems
1998
1635
  }, {
1999
- key: RightArrow,
2000
1636
  command: 'Problems.handleArrowRight',
1637
+ key: RightArrow,
2001
1638
  when: FocusProblems
2002
1639
  }];
2003
1640
  };
2004
1641
 
2005
- const Filter$1 = 'filter';
1642
+ const Filter$2 = 'filter';
2006
1643
  const Output$1 = 'output';
2007
1644
  const MainProcess = 'MainProcess';
2008
1645
  const SharedProcess = 'SharedProcess';
@@ -2053,8 +1690,8 @@ const handleFilterInput = async (state, value, inputSource = User) => {
2053
1690
  const filteredItems = filterItems(listItems, value);
2054
1691
  return {
2055
1692
  ...state,
2056
- filterValue: value,
2057
1693
  filteredItems: filteredItems,
1694
+ filterValue: value,
2058
1695
  inputSource
2059
1696
  };
2060
1697
  };
@@ -2064,14 +1701,6 @@ const createWatchId = () => {
2064
1701
  return watchId;
2065
1702
  };
2066
1703
 
2067
- const {
2068
- invoke: invoke$1,
2069
- sendMessagePortToExtensionHostWorker,
2070
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
2071
- set: set$1,
2072
- activateByEvent
2073
- } = RendererWorker;
2074
-
2075
1704
  const handleFileChange = async watchId => {
2076
1705
  const keys = getKeys();
2077
1706
  for (const key of keys) {
@@ -2098,14 +1727,12 @@ const setupChangeListener = async (oldWatchId, newWatchId, uri) => {
2098
1727
  try {
2099
1728
  if (oldWatchId) {
2100
1729
  unregisterWatchCallback(oldWatchId);
2101
- // @ts-ignore
2102
- await invoke$3('FileSystem.unwatchFile', oldWatchId);
1730
+ await unwatchFile(oldWatchId);
2103
1731
  }
2104
1732
  // TODO dispose old watcher
2105
1733
  const rpcId = OutputWorker;
2106
1734
  registerWatchCallback(newWatchId, handleFileChange);
2107
- // @ts-ignore
2108
- await invoke$3('FileSystem.watchFile', newWatchId, /* path */uri, rpcId);
1735
+ await watchFile(newWatchId, uri, rpcId);
2109
1736
  } catch {
2110
1737
  // ignore
2111
1738
  }
@@ -2113,8 +1740,8 @@ const setupChangeListener = async (oldWatchId, newWatchId, uri) => {
2113
1740
 
2114
1741
  const selectChannel = async (state, id) => {
2115
1742
  const {
2116
- options,
2117
1743
  filterValue,
1744
+ options,
2118
1745
  watchId
2119
1746
  } = state;
2120
1747
  const matchingOption = options.find(option => option.id === id);
@@ -2123,9 +1750,9 @@ const selectChannel = async (state, id) => {
2123
1750
  }
2124
1751
  // TODO potential race condtion when switching output channels fast
2125
1752
  const {
2126
- lines,
1753
+ code,
2127
1754
  error,
2128
- code
1755
+ lines
2129
1756
  } = await loadLines(matchingOption.uri);
2130
1757
 
2131
1758
  // TODO memory leak and race condition, need to dispose file watcher of previous uri
@@ -2136,8 +1763,8 @@ const selectChannel = async (state, id) => {
2136
1763
  ...state,
2137
1764
  error,
2138
1765
  errorCode: code,
2139
- listItems: lines,
2140
1766
  filteredItems,
1767
+ listItems: lines,
2141
1768
  selectedOption: id,
2142
1769
  watchId: newWatchId
2143
1770
  };
@@ -2164,8 +1791,8 @@ const createExtensionHostRpc = async () => {
2164
1791
  };
2165
1792
 
2166
1793
  const {
2167
- set,
2168
- invoke
1794
+ invoke,
1795
+ set
2169
1796
  } = ExtensionHost;
2170
1797
 
2171
1798
  const initializeExtensionHost = async () => {
@@ -2191,7 +1818,7 @@ const createFileSystemWorkerRpc = async () => {
2191
1818
 
2192
1819
  const initializeFileSystemWorker = async () => {
2193
1820
  const rpc = await createFileSystemWorkerRpc();
2194
- set$3(rpc);
1821
+ set$2(rpc);
2195
1822
  };
2196
1823
 
2197
1824
  const initialize = async () => {
@@ -2200,8 +1827,7 @@ const initialize = async () => {
2200
1827
 
2201
1828
  const getLogsDir = async () => {
2202
1829
  try {
2203
- // @ts-ignore
2204
- return await invoke$1('PlatformPaths.getLogsDir');
1830
+ return await getLogsDir$1();
2205
1831
  } catch {
2206
1832
  return `file:///tmp`;
2207
1833
  }
@@ -2232,6 +1858,7 @@ const i18nString = (key, placeholders = emptyObject) => {
2232
1858
  };
2233
1859
 
2234
1860
  const ClearOutput = 'clear output';
1861
+ const Filter$1 = 'Filter';
2235
1862
  const LogFileNotFound$1 = 'The log file was not found.';
2236
1863
  const Settings = 'Settings';
2237
1864
  const TurnOffAutoScroll = 'Turn auto scrolling off';
@@ -2248,20 +1875,23 @@ const settings = () => {
2248
1875
  const logFileNotFound = () => {
2249
1876
  return i18nString(LogFileNotFound$1);
2250
1877
  };
1878
+ const filter = () => {
1879
+ return i18nString(Filter$1);
1880
+ };
2251
1881
 
2252
1882
  const loadButtons = () => {
2253
1883
  return [{
1884
+ icon: 'MaskIconClearAll',
2254
1885
  id: Clear,
2255
- label: clearOutput(),
2256
- icon: 'MaskIconClearAll'
1886
+ label: clearOutput()
2257
1887
  }, {
1888
+ icon: 'MaskIconListFlat',
2258
1889
  id: ScrollLock,
2259
- label: turnOffAutoScroll(),
2260
- icon: 'MaskIconListFlat'
1890
+ label: turnOffAutoScroll()
2261
1891
  }, {
1892
+ icon: 'MaskIconSettingsGear',
2262
1893
  id: Settings$1,
2263
- label: settings(),
2264
- icon: 'MaskIconSettingsGear'
1894
+ label: settings()
2265
1895
  }];
2266
1896
  };
2267
1897
 
@@ -2274,6 +1904,7 @@ const getExtensionOptions = async () => {
2274
1904
  // TODO make api more declarative:
2275
1905
  // output channels are registered in extension manifest
2276
1906
  // only downside: it might show channels for extensions that are not active
1907
+ // @ts-ignore
2277
1908
  await activateByEvent('onOutput');
2278
1909
  // @ts-ignore
2279
1910
  const channels = await invoke('Output.getEnabledProviders');
@@ -2324,8 +1955,8 @@ const restoreState = savedState => {
2324
1955
  const scrollLockEnabled = getSavedScrollLockEnabled(savedState);
2325
1956
  return {
2326
1957
  filterValue,
2327
- selectedOption,
2328
- scrollLockEnabled
1958
+ scrollLockEnabled,
1959
+ selectedOption
2329
1960
  };
2330
1961
  };
2331
1962
 
@@ -2349,9 +1980,9 @@ const loadContent = async (state, savedState) => {
2349
1980
  const collapsedUris = getSavedCollapsedUris(savedState);
2350
1981
  const logsFolderPath = await getLogsDir();
2351
1982
  const {
2352
- selectedOption,
2353
1983
  filterValue,
2354
- scrollLockEnabled
1984
+ scrollLockEnabled,
1985
+ selectedOption
2355
1986
  } = restoreState(savedState);
2356
1987
  const selectedId = getSelectedItem(selectedOption, platform);
2357
1988
  const options = await loadOptions(platform, logsFolderPath);
@@ -2363,9 +1994,9 @@ const loadContent = async (state, savedState) => {
2363
1994
  uri
2364
1995
  } = option;
2365
1996
  const {
2366
- lines,
1997
+ code,
2367
1998
  error,
2368
- code
1999
+ lines
2369
2000
  } = await loadLines(uri);
2370
2001
  const filteredItems = filterItems(lines, filterValue);
2371
2002
  const newWatchId = createWatchId();
@@ -2410,22 +2041,22 @@ const refresh = async state => {
2410
2041
  return state;
2411
2042
  }
2412
2043
  const {
2413
- lines,
2044
+ code,
2414
2045
  error,
2415
- code
2046
+ lines
2416
2047
  } = await loadLines(matchingOption.uri);
2417
2048
  const filteredItems = filterItems(lines, filterValue);
2418
2049
  return {
2419
2050
  ...state,
2420
- listItems: lines,
2421
- filteredItems,
2422
2051
  error,
2423
- errorCode: code
2052
+ errorCode: code,
2053
+ filteredItems,
2054
+ listItems: lines
2424
2055
  };
2425
2056
  };
2426
2057
 
2427
2058
  const renderFilterValue = (oldState, newState) => {
2428
- return ['Viewlet.setValueByName', newState.parentId, Filter$1, newState.filterValue];
2059
+ return ['Viewlet.setValueByName', newState.parentId, Filter$2, newState.filterValue];
2429
2060
  };
2430
2061
 
2431
2062
  const Filter = 'Filter';
@@ -2444,9 +2075,9 @@ const Error$1 = 'Error';
2444
2075
  const Line = 'Line';
2445
2076
 
2446
2077
  const parentNode = {
2447
- type: Div,
2078
+ childCount: 1,
2448
2079
  className: Line,
2449
- childCount: 1
2080
+ type: Div
2450
2081
  };
2451
2082
  const getLineDom = parts => {
2452
2083
  const children = [];
@@ -2455,11 +2086,11 @@ const getLineDom = parts => {
2455
2086
  children.push(text(part.value));
2456
2087
  } else {
2457
2088
  children.push({
2458
- type: A,
2089
+ childCount: 1,
2459
2090
  href: part.value,
2460
- target: '_blank',
2461
2091
  rel: 'noopener noreferrer',
2462
- childCount: 1
2092
+ target: '_blank',
2093
+ type: A
2463
2094
  }, text(part.value));
2464
2095
  }
2465
2096
  }
@@ -2475,11 +2106,11 @@ const getContentDom = (lines, error) => {
2475
2106
  return [];
2476
2107
  }
2477
2108
  return [{
2478
- type: Div,
2109
+ childCount: lines.length,
2479
2110
  className: OutputContent,
2480
2111
  role: 'log',
2481
2112
  tabIndex: 0,
2482
- childCount: lines.length
2113
+ type: Div
2483
2114
  }, ...lines.flatMap(getLineDom)];
2484
2115
  };
2485
2116
 
@@ -2487,10 +2118,10 @@ const LogFileNotFound = 1;
2487
2118
 
2488
2119
  const getLogFileNotFoundDom = () => {
2489
2120
  return [{
2490
- type: Div,
2121
+ childCount: 1,
2491
2122
  className: Message,
2492
2123
  tabIndex: 0,
2493
- childCount: 1
2124
+ type: Div
2494
2125
  }, text(logFileNotFound())];
2495
2126
  };
2496
2127
 
@@ -2502,18 +2133,18 @@ const getErrorDom = (errorCode, error) => {
2502
2133
  return getLogFileNotFoundDom();
2503
2134
  }
2504
2135
  return [{
2505
- type: Div,
2136
+ childCount: 1,
2506
2137
  className: Error$1,
2507
2138
  tabIndex: 0,
2508
- childCount: 1
2139
+ type: Div
2509
2140
  }, text(error)];
2510
2141
  };
2511
2142
 
2512
2143
  const getOutputVirtualDom = (lines, errorCode, error) => {
2513
2144
  return [{
2514
- type: Div,
2145
+ childCount: 1,
2515
2146
  className: mergeClassNames(Viewlet, Output),
2516
- childCount: 1
2147
+ type: Div
2517
2148
  }, ...getContentDom(lines, error), ...getErrorDom(errorCode, error)];
2518
2149
  };
2519
2150
 
@@ -2530,10 +2161,10 @@ const renderSelectedItem = (oldState, newState) => {
2530
2161
 
2531
2162
  const getRenderer = diffType => {
2532
2163
  switch (diffType) {
2533
- case RenderItems:
2534
- return renderItems;
2535
2164
  case RenderFilterValue:
2536
2165
  return renderFilterValue;
2166
+ case RenderItems:
2167
+ return renderItems;
2537
2168
  case RenderSelectedItem:
2538
2169
  return renderSelectedItem;
2539
2170
  default:
@@ -2552,10 +2183,10 @@ const applyRender = (oldState, newState, diffResult) => {
2552
2183
 
2553
2184
  const render2 = (uid, diffResult) => {
2554
2185
  const {
2555
- oldState,
2556
- newState
2186
+ newState,
2187
+ oldState
2557
2188
  } = get(uid);
2558
- set$2(uid, newState, newState);
2189
+ set$1(uid, newState, newState);
2559
2190
  const commands = applyRender(oldState, newState, diffResult);
2560
2191
  return commands;
2561
2192
  };
@@ -2570,20 +2201,20 @@ const HandleButtonClick = 'handleButtonClick';
2570
2201
 
2571
2202
  const getActionButtonVirtualDom = button => {
2572
2203
  const {
2204
+ icon,
2573
2205
  id,
2574
- label,
2575
- icon
2206
+ label
2576
2207
  } = button;
2577
2208
  return [{
2578
- type: Button,
2209
+ childCount: 1,
2579
2210
  className: IconButton,
2580
2211
  name: id,
2212
+ onClick: HandleButtonClick,
2581
2213
  title: label,
2582
- childCount: 1,
2583
- onClick: HandleButtonClick
2214
+ type: Button
2584
2215
  }, {
2585
- type: Div,
2586
- className: mergeClassNames(MaskIcon, icon)
2216
+ className: mergeClassNames(MaskIcon, icon),
2217
+ type: Div
2587
2218
  }];
2588
2219
  };
2589
2220
 
@@ -2592,18 +2223,18 @@ const getActionButtonsVirtualDom = buttons => {
2592
2223
  };
2593
2224
 
2594
2225
  const getFilterVirtualDom = () => {
2595
- const placeholder = 'Filter';
2226
+ const placeholder = filter();
2596
2227
  return [{
2597
- type: Div,
2228
+ childCount: 1,
2598
2229
  className: Filter,
2599
- childCount: 1
2230
+ type: Div
2600
2231
  }, {
2601
- type: Input,
2602
- className: mergeClassNames(InputBox, FilterInput),
2603
2232
  childCount: 0,
2604
- placeholder,
2233
+ className: mergeClassNames(InputBox, FilterInput),
2234
+ name: Filter$2,
2605
2235
  onInput: HandleFilterInput,
2606
- name: Filter$1
2236
+ placeholder,
2237
+ type: Input
2607
2238
  }];
2608
2239
  };
2609
2240
 
@@ -2613,20 +2244,20 @@ const getOptionVirtualDom = option => {
2613
2244
  label
2614
2245
  } = option;
2615
2246
  return [{
2616
- type: Option$1,
2617
- className: Option,
2618
2247
  childCount: 1,
2248
+ className: Option,
2249
+ type: Option$1,
2619
2250
  value: id
2620
2251
  }, text(label)];
2621
2252
  };
2622
2253
 
2623
2254
  const getSelectVirtualDom = options => {
2624
2255
  return [{
2625
- type: Select$1,
2626
- className: Select,
2627
2256
  childCount: options.length,
2257
+ className: Select,
2628
2258
  name: Output$1,
2629
- onChange: HandleSelect
2259
+ onChange: HandleSelect,
2260
+ type: Select$1
2630
2261
  }, ...options.flatMap(getOptionVirtualDom)];
2631
2262
  };
2632
2263
 
@@ -2638,17 +2269,17 @@ const getChildCount = buttonsLength => {
2638
2269
  const getActionsVirtualDom = (options, buttons) => {
2639
2270
  const childCount = getChildCount(buttons.length);
2640
2271
  return [{
2641
- type: Div,
2272
+ childCount,
2642
2273
  className: Actions,
2643
2274
  role: ToolBar,
2644
- childCount
2275
+ type: Div
2645
2276
  }, ...getFilterVirtualDom(), ...getSelectVirtualDom(options), ...getActionButtonsVirtualDom(buttons)];
2646
2277
  };
2647
2278
 
2648
2279
  const renderActions = state => {
2649
2280
  const {
2650
- options,
2651
- buttons
2281
+ buttons,
2282
+ options
2652
2283
  } = state;
2653
2284
  const dom = getActionsVirtualDom(options, buttons);
2654
2285
  return dom;
@@ -2698,11 +2329,8 @@ const serializeLines = lines => {
2698
2329
  return lines.map(serializeLineParts).join('\n');
2699
2330
  };
2700
2331
 
2701
- // no local use of Line/LinePart here; serializeLines handles typing
2702
-
2703
2332
  const saveOutputAs = async state => {
2704
- // @ts-ignore
2705
- const uri = await invoke$1('FilePicker.showSaveFilePicker');
2333
+ const uri = await showSaveFilePicker();
2706
2334
  if (!uri) {
2707
2335
  return state;
2708
2336
  }
@@ -2717,16 +2345,16 @@ const saveOutputAs = async state => {
2717
2345
 
2718
2346
  const saveState = state => {
2719
2347
  const {
2720
- filterValue,
2721
2348
  collapsedUris,
2722
- selectedOption,
2723
- scrollLockEnabled
2349
+ filterValue,
2350
+ scrollLockEnabled,
2351
+ selectedOption
2724
2352
  } = state;
2725
2353
  return {
2726
- filterValue,
2727
2354
  collapsedUris,
2728
- selectedOption,
2729
- scrollLockEnabled
2355
+ filterValue,
2356
+ scrollLockEnabled,
2357
+ selectedOption
2730
2358
  };
2731
2359
  };
2732
2360
 
@@ -2786,7 +2414,7 @@ const listen = async () => {
2786
2414
  const rpc = await WebWorkerRpcClient.create({
2787
2415
  commandMap: commandMapRef
2788
2416
  });
2789
- set$1(rpc);
2417
+ set$3(rpc);
2790
2418
  };
2791
2419
 
2792
2420
  const main = async () => {