@lvce-editor/hover-worker 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$6 = (id, fn) => {
519
- callbacks[id] = fn;
520
- };
521
511
  const get$2 = id => {
522
512
  return callbacks[id];
523
513
  };
524
- const remove = id => {
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$6(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);
@@ -706,7 +664,7 @@ const resolve = (id, response) => {
706
664
  return;
707
665
  }
708
666
  fn(response);
709
- remove(id);
667
+ remove$1(id);
710
668
  };
711
669
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
712
670
  const getErrorType = prettyError => {
@@ -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$4 = (ipc, method, ...params) => {
883
- return invokeHelper(ipc, method, params, false);
884
- };
885
- const invokeAndTransfer$2 = (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$1 = (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$4(ipc, method, ...params);
922
- },
923
- invokeAndTransfer(method, ...params) {
924
- return invokeAndTransfer$2(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$1;
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,9 +1021,9 @@ 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
  };
@@ -1060,10 +1061,11 @@ const create$2 = () => {
1060
1061
  wrapCommand(fn) {
1061
1062
  const wrapped = async (uid, ...args) => {
1062
1063
  const {
1064
+ oldState,
1063
1065
  newState
1064
1066
  } = states[uid];
1065
1067
  const newerState = await fn(newState, ...args);
1066
- if (newState === newerState) {
1068
+ if (oldState === newerState || newState === newerState) {
1067
1069
  return;
1068
1070
  }
1069
1071
  const latest = states[uid];
@@ -1125,9 +1127,17 @@ const set$5 = (id, rpc) => {
1125
1127
  const get$1 = id => {
1126
1128
  return rpcs[id];
1127
1129
  };
1130
+ const remove = id => {
1131
+ delete rpcs[id];
1132
+ };
1128
1133
 
1134
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1129
1135
  const create$1 = rpcId => {
1130
1136
  return {
1137
+ async dispose() {
1138
+ const rpc = get$1(rpcId);
1139
+ await rpc.dispose();
1140
+ },
1131
1141
  // @ts-ignore
1132
1142
  invoke(method, ...params) {
1133
1143
  const rpc = get$1(rpcId);
@@ -1140,21 +1150,30 @@ const create$1 = rpcId => {
1140
1150
  // @ts-ignore
1141
1151
  return rpc.invokeAndTransfer(method, ...params);
1142
1152
  },
1153
+ registerMockRpc(commandMap) {
1154
+ const mockRpc = createMockRpc({
1155
+ commandMap
1156
+ });
1157
+ set$5(rpcId, mockRpc);
1158
+ // @ts-ignore
1159
+ mockRpc[Symbol.dispose] = () => {
1160
+ remove(rpcId);
1161
+ };
1162
+ // @ts-ignore
1163
+ return mockRpc;
1164
+ },
1143
1165
  set(rpc) {
1144
1166
  set$5(rpcId, rpc);
1145
- },
1146
- async dispose() {
1147
- const rpc = get$1(rpcId);
1148
- await rpc.dispose();
1149
1167
  }
1150
1168
  };
1151
1169
  };
1152
1170
 
1153
1171
  const {
1172
+ dispose: dispose$3,
1154
1173
  invoke: invoke$3,
1155
1174
  invokeAndTransfer: invokeAndTransfer$1,
1156
- set: set$4,
1157
- dispose: dispose$3
1175
+ registerMockRpc: registerMockRpc$1,
1176
+ set: set$4
1158
1177
  } = create$1(EditorWorker$1);
1159
1178
  const sendMessagePortToExtensionHostWorker$2 = async port => {
1160
1179
  const command = 'HandleMessagePort.handleMessagePort2';
@@ -1171,6 +1190,10 @@ const applyEdit = async (editorUid, changes) => {
1171
1190
  // @ts-ignore
1172
1191
  await invoke$3('Editor.applyEdit2', editorUid, changes);
1173
1192
  };
1193
+ const applyDocumentEdits = async (editorUid, changes) => {
1194
+ // @ts-ignore
1195
+ await invoke$3('Editor.applyDocumentEdits', editorUid, changes);
1196
+ };
1174
1197
  const applyWorkspaceEdit = async (editorUid, changes) => {
1175
1198
  // @ts-ignore
1176
1199
  await invoke$3('Editor.applyWorkspaceEdit', editorUid, changes);
@@ -1203,6 +1226,9 @@ const getSelections = async editorUid => {
1203
1226
  const getWordAtOffset2$1 = async editorUid => {
1204
1227
  return invoke$3('Editor.getWordAtOffset2', editorUid);
1205
1228
  };
1229
+ const closeFind2 = async editorUid => {
1230
+ return invoke$3('Editor.closeFind2', editorUid);
1231
+ };
1206
1232
  const getWordBefore$1 = async (editorUid, rowIndex, columnIndex) => {
1207
1233
  return invoke$3('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
1208
1234
  };
@@ -1221,19 +1247,14 @@ const getProblems = async () => {
1221
1247
  // @ts-ignore
1222
1248
  return invoke$3('Editor.getProblems');
1223
1249
  };
1224
- const registerMockRpc$1 = commandMap => {
1225
- const mockRpc = createMockRpc({
1226
- commandMap
1227
- });
1228
- set$4(mockRpc);
1229
- return mockRpc;
1230
- };
1231
1250
 
1232
1251
  const EditorWorker = {
1233
1252
  __proto__: null,
1234
1253
  activateByEvent: activateByEvent$1,
1254
+ applyDocumentEdits,
1235
1255
  applyEdit,
1236
1256
  applyWorkspaceEdit,
1257
+ closeFind2,
1237
1258
  closeWidget,
1238
1259
  dispose: dispose$3,
1239
1260
  getLanguageId,
@@ -1255,10 +1276,11 @@ const EditorWorker = {
1255
1276
  };
1256
1277
 
1257
1278
  const {
1279
+ dispose: dispose$2,
1258
1280
  invoke: invoke$2,
1259
1281
  invokeAndTransfer,
1260
- set: set$3,
1261
- dispose: dispose$2
1282
+ registerMockRpc,
1283
+ set: set$3
1262
1284
  } = create$1(ExtensionHostWorker);
1263
1285
  const executeReferenceProvider = async (id, offset) => {
1264
1286
  // @ts-ignore
@@ -1272,12 +1294,9 @@ const getRuntimeStatus = async extensionId => {
1272
1294
  // @ts-ignore
1273
1295
  return invoke$2('ExtensionHost.getRuntimeStatus', extensionId);
1274
1296
  };
1275
- const registerMockRpc = commandMap => {
1276
- const mockRpc = createMockRpc({
1277
- commandMap
1278
- });
1279
- set$3(mockRpc);
1280
- return mockRpc;
1297
+ const getEnabledOutputProviderIds = async () => {
1298
+ const channels = await invoke$2('Output.getEnabledProviders');
1299
+ return channels;
1281
1300
  };
1282
1301
 
1283
1302
  const ExtensionHost = {
@@ -1285,6 +1304,7 @@ const ExtensionHost = {
1285
1304
  dispose: dispose$2,
1286
1305
  executeFileReferenceProvider,
1287
1306
  executeReferenceProvider,
1307
+ getEnabledOutputProviderIds,
1288
1308
  getRuntimeStatus,
1289
1309
  invoke: invoke$2,
1290
1310
  invokeAndTransfer,
@@ -1293,11 +1313,11 @@ const ExtensionHost = {
1293
1313
  };
1294
1314
 
1295
1315
  const {
1296
- invoke: invoke$1,
1297
- set: set$2,
1298
1316
  getWordAtOffset2,
1299
1317
  getWordBefore,
1300
- sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1
1318
+ invoke: invoke$1,
1319
+ sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
1320
+ set: set$2
1301
1321
  } = EditorWorker;
1302
1322
 
1303
1323
  const FocusEditorHovers = 9;
@@ -1315,37 +1335,38 @@ const close = async state => {
1315
1335
  };
1316
1336
 
1317
1337
  const {
1338
+ dispose: dispose$1,
1318
1339
  get,
1319
1340
  set: set$1,
1320
- wrapCommand,
1321
- dispose: dispose$1
1341
+ wrapCommand
1322
1342
  } = create$2();
1323
1343
 
1324
1344
  const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
1325
1345
  const state = {
1326
- uid,
1327
- focusedIndex: -1,
1328
- x: 0,
1329
- y: 0,
1330
- width: 0,
1331
- height: 0,
1332
- focused: false,
1333
- leadingWord: '',
1334
- version: 0,
1335
- editorUid,
1346
+ documentation: '',
1336
1347
  editorLanguageId,
1348
+ editorUid,
1337
1349
  fallbackDisplayStringLanguageId: 'typescript',
1338
- hoverDocumentationFontSize: 15,
1339
- hoverDocumentationFontFamily: 'Fira Code',
1340
- hoverDocumentationLineHeight: '1.33333',
1350
+ focused: false,
1351
+ focusedIndex: -1,
1352
+ height: 0,
1341
1353
  hoverBorderLeft: 1,
1342
1354
  hoverBorderRight: 1,
1355
+ hoverDocumentationFontFamily: 'Fira Code',
1356
+ // TODO make it configurable
1357
+ hoverDocumentationFontSize: 15,
1358
+ hoverDocumentationLineHeight: '1.33333',
1359
+ hoverFullWidth: 400,
1343
1360
  hoverPaddingLeft: 8,
1344
1361
  hoverPaddingRight: 8,
1345
- hoverFullWidth: 400,
1346
- documentation: '',
1362
+ leadingWord: '',
1347
1363
  lineInfos: [],
1348
- matchingDiagnostics: []
1364
+ matchingDiagnostics: [],
1365
+ uid,
1366
+ version: 0,
1367
+ width: 0,
1368
+ x: 0,
1369
+ y: 0
1349
1370
  };
1350
1371
  set$1(uid, state, state);
1351
1372
  };
@@ -1393,8 +1414,8 @@ const diff = (oldState, newState) => {
1393
1414
 
1394
1415
  const diff2 = uid => {
1395
1416
  const {
1396
- oldState,
1397
- newState
1417
+ newState,
1418
+ oldState
1398
1419
  } = get(uid);
1399
1420
  const diffResult = diff(oldState, newState);
1400
1421
  return diffResult;
@@ -1422,8 +1443,8 @@ const CtrlCmd = 1 << 11 >>> 0;
1422
1443
 
1423
1444
  const getCommand = shortId => {
1424
1445
  return {
1425
- command: 'Editor.executeWidgetCommand',
1426
- args: ['Hovers', `Hovers.${shortId}`, 0, Hover]
1446
+ args: ['Hovers', `Hovers.${shortId}`, 0, Hover],
1447
+ command: 'Editor.executeWidgetCommand'
1427
1448
  };
1428
1449
  };
1429
1450
  const getKeyBindings = () => {
@@ -1510,19 +1531,20 @@ const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
1510
1531
  const getHoverDetails = async (hover, error, hoverFullWidth, hoverPaddingLeft, hoverPaddingRight, hoverBorderLeft, hoverBorderRight, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, fallbackDisplayStringLanguageId) => {
1511
1532
  if (error) {
1512
1533
  return {
1513
- lineInfos: [],
1514
1534
  documentation: '',
1515
- documentationHeight: 0
1535
+ documentationHeight: 0,
1536
+ lineInfos: []
1516
1537
  };
1517
1538
  }
1518
1539
  const {
1519
- documentation} = hover;
1540
+ documentation
1541
+ } = hover;
1520
1542
  const lineInfos = await tokenizeCodeBlock();
1521
1543
  const documentationHeight = await measureTextBlockHeight();
1522
1544
  return {
1523
- lineInfos,
1524
1545
  documentation,
1525
- documentationHeight
1546
+ documentationHeight,
1547
+ lineInfos
1526
1548
  };
1527
1549
  };
1528
1550
 
@@ -1582,9 +1604,9 @@ const activateByEvent = async event => {
1582
1604
  };
1583
1605
 
1584
1606
  const execute = async ({
1607
+ args,
1585
1608
  editorLanguageId,
1586
1609
  editorUid,
1587
- args,
1588
1610
  event,
1589
1611
  method,
1590
1612
  noProviderFoundMessage,
@@ -1600,10 +1622,10 @@ const executeHoverProvider = async (editorUid, editorLanguageId, offset) => {
1600
1622
  number(editorUid);
1601
1623
  number(offset);
1602
1624
  return execute({
1603
- event: OnHover,
1625
+ args: [offset],
1604
1626
  editorUid,
1627
+ event: OnHover,
1605
1628
  method: HoverExecute,
1606
- args: [offset],
1607
1629
  noProviderFoundMessage: 'No hover provider found'
1608
1630
  });
1609
1631
  };
@@ -1615,13 +1637,13 @@ const getHover = async (editorUid, editorLanguageId, offset) => {
1615
1637
  // TODO invoke extension host worker directly
1616
1638
  const hover = await executeHoverProvider(editorUid, editorLanguageId, offset);
1617
1639
  return {
1618
- hover,
1619
- error: undefined
1640
+ error: undefined,
1641
+ hover
1620
1642
  };
1621
1643
  } catch (error) {
1622
1644
  return {
1623
- hover: undefined,
1624
- error
1645
+ error,
1646
+ hover: undefined
1625
1647
  };
1626
1648
  }
1627
1649
  };
@@ -1638,8 +1660,8 @@ const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
1638
1660
  const getEditorHoverInfo = async (editorUid, editorLanguageId, hoverFullWidth, hoverPaddingLeft, hoverPaddingRight, hoverBorderLeft, hoverBorderRight, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, fallbackDisplayStringLanguageId) => {
1639
1661
  number(editorUid);
1640
1662
  const {
1641
- rowIndex,
1642
- columnIndex
1663
+ columnIndex,
1664
+ rowIndex
1643
1665
  } = await getPositionAtCursor(editorUid);
1644
1666
  const offset = getOffsetAtCursor();
1645
1667
 
@@ -1657,16 +1679,16 @@ const getEditorHoverInfo = async (editorUid, editorLanguageId, hoverFullWidth, h
1657
1679
  // @ts-ignore
1658
1680
  const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
1659
1681
  const {
1660
- hover,
1661
- error
1682
+ error,
1683
+ hover
1662
1684
  } = await getHover(editorUid, editorLanguageId, offset);
1663
1685
  if (!hover) {
1664
1686
  return {
1665
- lineInfos: [],
1666
1687
  documentation: '',
1688
+ lineInfos: [],
1689
+ matchingDiagnostics,
1667
1690
  x,
1668
- y,
1669
- matchingDiagnostics
1691
+ y
1670
1692
  };
1671
1693
  }
1672
1694
  const {
@@ -1674,11 +1696,11 @@ const getEditorHoverInfo = async (editorUid, editorLanguageId, hoverFullWidth, h
1674
1696
  lineInfos
1675
1697
  } = await getHoverDetails(hover, error);
1676
1698
  return {
1677
- lineInfos,
1678
1699
  documentation,
1700
+ lineInfos,
1701
+ matchingDiagnostics,
1679
1702
  x,
1680
- y,
1681
- matchingDiagnostics
1703
+ y
1682
1704
  };
1683
1705
  };
1684
1706
 
@@ -1723,11 +1745,11 @@ const SetEventListeners = 'Viewlet.registerEventListeners';
1723
1745
 
1724
1746
  const renderBounds = (oldState, newState) => {
1725
1747
  const {
1726
- x,
1727
- y,
1728
- width,
1729
1748
  height,
1730
- uid
1749
+ uid,
1750
+ width,
1751
+ x,
1752
+ y
1731
1753
  } = newState;
1732
1754
  return [SetBounds, uid, x, y, width, height];
1733
1755
  };
@@ -1775,25 +1797,25 @@ const Span = 8;
1775
1797
 
1776
1798
  const text = data => {
1777
1799
  return {
1778
- type: Text,
1800
+ childCount: 0,
1779
1801
  text: data,
1780
- childCount: 0
1802
+ type: Text
1781
1803
  };
1782
1804
  };
1783
1805
 
1784
1806
  const getLineInfoVirtualDom = lineInfo => {
1785
1807
  const dom = [{
1786
- type: Div,
1808
+ childCount: lineInfo.length / 2,
1787
1809
  className: HoverEditorRow,
1788
- childCount: lineInfo.length / 2
1810
+ type: Div
1789
1811
  }];
1790
1812
  for (let i = 0; i < lineInfo.length; i += 2) {
1791
1813
  const tokenText = lineInfo[i];
1792
1814
  const tokenClass = lineInfo[i + 1];
1793
1815
  dom.push({
1794
- type: Span,
1816
+ childCount: 1,
1795
1817
  className: tokenClass,
1796
- childCount: 1
1818
+ type: Span
1797
1819
  }, text(tokenText));
1798
1820
  }
1799
1821
  return dom;
@@ -1803,15 +1825,17 @@ const getLineInfosVirtualDom = lineInfos => {
1803
1825
  return dom;
1804
1826
  };
1805
1827
 
1828
+ /* eslint-disable unicorn/no-immediate-mutation */
1829
+
1806
1830
  const hoverProblemMessage = {
1807
- type: Span,
1831
+ childCount: 1,
1808
1832
  className: HoverProblemMessage,
1809
- childCount: 1
1833
+ type: Span
1810
1834
  };
1811
1835
  const hoverProblemDetail = {
1812
- type: Span,
1836
+ childCount: 1,
1813
1837
  className: HoverProblemDetail,
1814
- childCount: 1
1838
+ type: Span
1815
1839
  };
1816
1840
  const getChildCount = (lineInfos, documentation, diagnostics) => {
1817
1841
  const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
@@ -1820,15 +1844,15 @@ const getChildCount = (lineInfos, documentation, diagnostics) => {
1820
1844
  const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
1821
1845
  const dom = [];
1822
1846
  dom.push({
1823
- type: Div,
1847
+ childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
1824
1848
  className: 'Viewlet EditorHover',
1825
- childCount: getChildCount(lineInfos, documentation, diagnostics) + 1
1849
+ type: Div
1826
1850
  });
1827
1851
  if (diagnostics && diagnostics.length > 0) {
1828
1852
  dom.push({
1829
- type: Div,
1853
+ childCount: diagnostics.length * 2,
1830
1854
  className: `${HoverDisplayString} ${HoverProblem}`,
1831
- childCount: diagnostics.length * 2
1855
+ type: Div
1832
1856
  });
1833
1857
  for (const diagnostic of diagnostics) {
1834
1858
  dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(`${diagnostic.source} (${diagnostic.code})`));
@@ -1837,33 +1861,33 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
1837
1861
  if (lineInfos.length > 0) {
1838
1862
  const lineInfosDom = getLineInfosVirtualDom(lineInfos);
1839
1863
  dom.push({
1840
- type: Div,
1864
+ childCount: lineInfos.length,
1841
1865
  className: HoverDisplayString,
1842
- childCount: lineInfos.length
1866
+ type: Div
1843
1867
  }, ...lineInfosDom);
1844
1868
  }
1845
1869
  if (documentation) {
1846
1870
  dom.push({
1847
- type: Div,
1871
+ childCount: 1,
1848
1872
  className: HoverDocumentation,
1849
- childCount: 1
1873
+ type: Div
1850
1874
  }, text(documentation));
1851
1875
  }
1852
1876
  dom.push({
1853
- type: Div,
1854
- className: 'Sash SashVertical SashResize',
1855
1877
  childCount: 0,
1856
- onPointerDown: HandleSashPointerDown
1878
+ className: 'Sash SashVertical SashResize',
1879
+ onPointerDown: HandleSashPointerDown,
1880
+ type: Div
1857
1881
  });
1858
1882
  return dom;
1859
1883
  };
1860
1884
 
1861
1885
  const renderItems = (oldState, newState) => {
1862
1886
  const {
1863
- uid,
1864
- matchingDiagnostics,
1865
1887
  documentation,
1866
- lineInfos
1888
+ lineInfos,
1889
+ matchingDiagnostics,
1890
+ uid
1867
1891
  } = newState;
1868
1892
  const dom = getHoverVirtualDom(lineInfos, documentation, matchingDiagnostics);
1869
1893
  return [/* method */'Viewlet.setDom2', uid, dom];
@@ -1871,26 +1895,26 @@ const renderItems = (oldState, newState) => {
1871
1895
 
1872
1896
  const renderUid = (oldState, newState) => {
1873
1897
  const {
1874
- uid,
1875
- editorUid
1898
+ editorUid,
1899
+ uid
1876
1900
  } = newState;
1877
1901
  return [SetUid, uid, editorUid];
1878
1902
  };
1879
1903
 
1880
1904
  const getRenderer = diffType => {
1881
1905
  switch (diffType) {
1882
- case RenderContent:
1883
- return renderContent;
1884
1906
  case RenderBounds:
1885
1907
  return renderBounds;
1908
+ case RenderContent:
1909
+ return renderContent;
1886
1910
  case RenderEventListeners:
1887
1911
  return renderEventListeners;
1888
- case RenderUid:
1889
- return renderUid;
1890
1912
  case RenderFocusContext:
1891
1913
  return renderFocusContext;
1892
1914
  case RenderItems:
1893
1915
  return renderItems;
1916
+ case RenderUid:
1917
+ return renderUid;
1894
1918
  default:
1895
1919
  throw new Error('unknown renderer');
1896
1920
  }
@@ -1907,8 +1931,8 @@ const applyRender = (oldState, newState, diffResult) => {
1907
1931
 
1908
1932
  const render2 = (uid, diffResult) => {
1909
1933
  const {
1910
- oldState,
1911
- newState
1934
+ newState,
1935
+ oldState
1912
1936
  } = get(uid);
1913
1937
  set$1(uid, newState, newState);
1914
1938
  const commands = applyRender(oldState, newState, diffResult);
@@ -1922,12 +1946,12 @@ const commandMap = {
1922
1946
  'Hover.dispose': dispose,
1923
1947
  'Hover.getCommandIds': getCommandIds,
1924
1948
  'Hover.getKeyBindings': getKeyBindings,
1949
+ 'Hover.handleSashPointerDown': wrapCommand(handleSashPointerDown),
1950
+ 'Hover.handleSashPointerMove': wrapCommand(handleSashPointerMove),
1951
+ 'Hover.handleSashPointerUp': wrapCommand(handleSashPointerUp),
1925
1952
  'Hover.initialize': initialize,
1926
1953
  'Hover.loadContent': wrapCommand(loadContent),
1927
1954
  'Hover.render2': render2,
1928
- 'Hover.handleSashPointerUp': wrapCommand(handleSashPointerUp),
1929
- 'Hover.handleSashPointerDown': wrapCommand(handleSashPointerDown),
1930
- 'Hover.handleSashPointerMove': wrapCommand(handleSashPointerMove),
1931
1955
  'Hover.terminate': terminate
1932
1956
  };
1933
1957
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/hover-worker",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",