@lvce-editor/editor-worker 5.6.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,6 @@
1
1
  const commands = Object.create(null);
2
- const registerCommand = (key, fn) => {
3
- commands[key] = fn;
4
- };
5
2
  const register = commandMap => {
6
- for (const [key, value] of Object.entries(commandMap)) {
7
- registerCommand(key, value);
8
- }
3
+ Object.assign(commands, commandMap);
9
4
  };
10
5
  const getCommand = key => {
11
6
  return commands[key];
@@ -23,13 +18,13 @@ const codeGeneratorAccept = state => {
23
18
  return state;
24
19
  };
25
20
 
26
- let AssertionError$1 = class AssertionError extends Error {
21
+ class AssertionError extends Error {
27
22
  constructor(message) {
28
23
  super(message);
29
24
  this.name = 'AssertionError';
30
25
  }
31
- };
32
- const getType$1 = value => {
26
+ }
27
+ const getType = value => {
33
28
  switch (typeof value) {
34
29
  case 'number':
35
30
  return 'number';
@@ -52,40 +47,40 @@ const getType$1 = value => {
52
47
  }
53
48
  };
54
49
  const object = value => {
55
- const type = getType$1(value);
50
+ const type = getType(value);
56
51
  if (type !== 'object') {
57
- throw new AssertionError$1('expected value to be of type object');
52
+ throw new AssertionError('expected value to be of type object');
58
53
  }
59
54
  };
60
- const number$1 = value => {
61
- const type = getType$1(value);
55
+ const number = value => {
56
+ const type = getType(value);
62
57
  if (type !== 'number') {
63
- throw new AssertionError$1('expected value to be of type number');
58
+ throw new AssertionError('expected value to be of type number');
64
59
  }
65
60
  };
66
61
  const array = value => {
67
- const type = getType$1(value);
62
+ const type = getType(value);
68
63
  if (type !== 'array') {
69
- throw new AssertionError$1('expected value to be of type array');
64
+ throw new AssertionError('expected value to be of type array');
70
65
  }
71
66
  };
72
67
  const string = value => {
73
- const type = getType$1(value);
68
+ const type = getType(value);
74
69
  if (type !== 'string') {
75
- throw new AssertionError$1('expected value to be of type string');
70
+ throw new AssertionError('expected value to be of type string');
76
71
  }
77
72
  };
78
73
  const boolean = value => {
79
- const type = getType$1(value);
74
+ const type = getType(value);
80
75
  if (type !== 'boolean') {
81
- throw new AssertionError$1('expected value to be of type boolean');
76
+ throw new AssertionError('expected value to be of type boolean');
82
77
  }
83
78
  };
84
79
 
85
80
  const clamp = (num, min, max) => {
86
- number$1(num);
87
- number$1(min);
88
- number$1(max);
81
+ number(num);
82
+ number(min);
83
+ number(max);
89
84
  return Math.min(Math.max(num, min), max);
90
85
  };
91
86
 
@@ -304,10 +299,10 @@ const applyEdits = (textDocument, changes) => {
304
299
  const endColumnIndex = change.end.columnIndex;
305
300
  const inserted = change.inserted;
306
301
  const deleted = change.deleted;
307
- number$1(startRowIndex);
308
- number$1(endRowIndex);
309
- number$1(startColumnIndex);
310
- number$1(endColumnIndex);
302
+ number(startRowIndex);
303
+ number(endRowIndex);
304
+ number(startColumnIndex);
305
+ number(endColumnIndex);
311
306
  array(inserted);
312
307
  array(deleted);
313
308
  if (startRowIndex === endRowIndex) {
@@ -377,8 +372,8 @@ const getSelectionText = (textDocument, range) => {
377
372
  };
378
373
  const offsetAtSync = async (textDocument, positionRowIndex, positionColumnIndex) => {
379
374
  object(textDocument);
380
- number$1(positionRowIndex);
381
- number$1(positionColumnIndex);
375
+ number(positionRowIndex);
376
+ number(positionColumnIndex);
382
377
  let offset = 0;
383
378
  let rowIndex = 0;
384
379
  const lines = textDocument.lines;
@@ -392,8 +387,8 @@ const offsetAtSync = async (textDocument, positionRowIndex, positionColumnIndex)
392
387
  };
393
388
  const offsetAt = (textDocument, positionRowIndex, positionColumnIndex) => {
394
389
  object(textDocument);
395
- number$1(positionRowIndex);
396
- number$1(positionColumnIndex);
390
+ number(positionRowIndex);
391
+ number(positionColumnIndex);
397
392
  let offset = 0;
398
393
  let rowIndex = 0;
399
394
  const lines = textDocument.lines;
@@ -432,7 +427,7 @@ const positionAt = (textDocument, offset) => {
432
427
  // TODO this should be in a separate scrolling module
433
428
  const setDeltaY$3 = (state, value) => {
434
429
  object(state);
435
- number$1(value);
430
+ number(value);
436
431
  const {
437
432
  finalDeltaY,
438
433
  deltaY,
@@ -525,11 +520,11 @@ const getContext = () => {
525
520
 
526
521
  const measureTextWidthSlow = (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
527
522
  string(text);
528
- number$1(fontWeight);
529
- number$1(fontSize);
523
+ number(fontWeight);
524
+ number(fontSize);
530
525
  string(fontFamily);
531
526
  boolean(isMonoSpaceFont);
532
- number$1(charWidth);
527
+ number(charWidth);
533
528
  if (typeof letterSpacing !== 'number') {
534
529
  throw new TypeError('letterSpacing must be of type number');
535
530
  }
@@ -565,12 +560,12 @@ const getX = (line, column, fontWeight, fontSize, fontFamily, isMonospaceFont, l
565
560
  return 0;
566
561
  }
567
562
  string(line);
568
- number$1(tabSize);
569
- number$1(halfCursorWidth);
570
- number$1(width);
563
+ number(tabSize);
564
+ number(halfCursorWidth);
565
+ number(width);
571
566
  boolean(isMonospaceFont);
572
- number$1(averageCharWidth);
573
- number$1(difference);
567
+ number(averageCharWidth);
568
+ number(difference);
574
569
  if (column === 0) {
575
570
  return 0;
576
571
  }
@@ -1037,11 +1032,11 @@ const setText = (editor, text) => {
1037
1032
 
1038
1033
  const editors = Object.create(null);
1039
1034
  const get$6 = id => {
1040
- number$1(id);
1035
+ number(id);
1041
1036
  return editors[id];
1042
1037
  };
1043
1038
  const set$6 = (id, oldEditor, newEditor) => {
1044
- number$1(id);
1039
+ number(id);
1045
1040
  object(oldEditor);
1046
1041
  object(newEditor);
1047
1042
  editors[id] = {
@@ -1058,57 +1053,21 @@ const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompl
1058
1053
  const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
1059
1054
 
1060
1055
  const Two = '2.0';
1061
- class AssertionError extends Error {
1062
- constructor(message) {
1063
- super(message);
1064
- this.name = 'AssertionError';
1065
- }
1066
- }
1067
- const getType = value => {
1068
- switch (typeof value) {
1069
- case 'number':
1070
- return 'number';
1071
- case 'function':
1072
- return 'function';
1073
- case 'string':
1074
- return 'string';
1075
- case 'object':
1076
- if (value === null) {
1077
- return 'null';
1078
- }
1079
- if (Array.isArray(value)) {
1080
- return 'array';
1081
- }
1082
- return 'object';
1083
- case 'boolean':
1084
- return 'boolean';
1085
- default:
1086
- return 'unknown';
1087
- }
1088
- };
1089
- const number = value => {
1090
- const type = getType(value);
1091
- if (type !== 'number') {
1092
- throw new AssertionError('expected value to be of type number');
1093
- }
1094
- };
1095
- const state$1$1 = {
1056
+ const state$9 = {
1096
1057
  callbacks: Object.create(null)
1097
1058
  };
1098
1059
  const set$5 = (id, fn) => {
1099
- state$1$1.callbacks[id] = fn;
1060
+ state$9.callbacks[id] = fn;
1100
1061
  };
1101
1062
  const get$5 = id => {
1102
- return state$1$1.callbacks[id];
1063
+ return state$9.callbacks[id];
1103
1064
  };
1104
1065
  const remove$8 = id => {
1105
- delete state$1$1.callbacks[id];
1106
- };
1107
- const state$9 = {
1108
- id: 0
1066
+ delete state$9.callbacks[id];
1109
1067
  };
1068
+ let id = 0;
1110
1069
  const create$3$1 = () => {
1111
- return ++state$9.id;
1070
+ return ++id;
1112
1071
  };
1113
1072
  const warn$1 = (...args) => {
1114
1073
  console.warn(...args);
@@ -1125,15 +1084,14 @@ const registerPromise = () => {
1125
1084
  promise
1126
1085
  };
1127
1086
  };
1128
- const resolve = (id, args) => {
1129
- number(id);
1087
+ const resolve = (id, response) => {
1130
1088
  const fn = get$5(id);
1131
1089
  if (!fn) {
1132
- console.log(args);
1090
+ console.log(response);
1133
1091
  warn$1(`callback ${id} may already be disposed`);
1134
1092
  return;
1135
1093
  }
1136
- fn(args);
1094
+ fn(response);
1137
1095
  remove$8(id);
1138
1096
  };
1139
1097
  const create$2$1 = (method, params) => {
@@ -1355,32 +1313,42 @@ const defaultRequiresSocket = () => {
1355
1313
  return false;
1356
1314
  };
1357
1315
  const defaultResolve = resolve;
1358
- const handleJsonRpcMessage = async (...args) => {
1359
- let message;
1360
- let ipc;
1361
- let execute;
1362
- let preparePrettyError;
1363
- let logError;
1364
- let resolve;
1365
- let requiresSocket;
1316
+
1317
+ // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
1318
+ const normalizeParams = args => {
1366
1319
  if (args.length === 1) {
1367
- const arg = args[0];
1368
- message = arg.message;
1369
- ipc = arg.ipc;
1370
- execute = arg.execute;
1371
- preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
1372
- logError = arg.logError || defaultLogError;
1373
- requiresSocket = arg.requiresSocket || defaultRequiresSocket;
1374
- resolve = arg.resolve || defaultResolve;
1375
- } else {
1376
- ipc = args[0];
1377
- message = args[1];
1378
- execute = args[2];
1379
- resolve = args[3];
1380
- preparePrettyError = args[4];
1381
- logError = args[5];
1382
- requiresSocket = args[6];
1320
+ const options = args[0];
1321
+ return {
1322
+ ipc: options.ipc,
1323
+ message: options.message,
1324
+ execute: options.execute,
1325
+ resolve: options.resolve || defaultResolve,
1326
+ preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
1327
+ logError: options.logError || defaultLogError,
1328
+ requiresSocket: options.requiresSocket || defaultRequiresSocket
1329
+ };
1383
1330
  }
1331
+ return {
1332
+ ipc: args[0],
1333
+ message: args[1],
1334
+ execute: args[2],
1335
+ resolve: args[3],
1336
+ preparePrettyError: args[4],
1337
+ logError: args[5],
1338
+ requiresSocket: args[6]
1339
+ };
1340
+ };
1341
+ const handleJsonRpcMessage = async (...args) => {
1342
+ const options = normalizeParams(args);
1343
+ const {
1344
+ message,
1345
+ ipc,
1346
+ execute,
1347
+ resolve,
1348
+ preparePrettyError,
1349
+ logError,
1350
+ requiresSocket
1351
+ } = options;
1384
1352
  if ('id' in message) {
1385
1353
  if ('method' in message) {
1386
1354
  const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
@@ -1401,25 +1369,24 @@ const handleJsonRpcMessage = async (...args) => {
1401
1369
  }
1402
1370
  throw new JsonRpcError('unexpected message');
1403
1371
  };
1404
- const invoke$5 = async (ipc, method, ...params) => {
1372
+ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
1405
1373
  const {
1406
1374
  message,
1407
1375
  promise
1408
1376
  } = create$2$1(method, params);
1409
- ipc.send(message);
1377
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
1378
+ ipc.sendAndTransfer(message);
1379
+ } else {
1380
+ ipc.send(message);
1381
+ }
1410
1382
  const responseMessage = await promise;
1411
- const result = unwrapJsonRpcResult(responseMessage);
1412
- return result;
1383
+ return unwrapJsonRpcResult(responseMessage);
1413
1384
  };
1414
- const invokeAndTransfer$2 = async (ipc, method, ...params) => {
1415
- const {
1416
- message,
1417
- promise
1418
- } = create$2$1(method, params);
1419
- ipc.sendAndTransfer(message);
1420
- const responseMessage = await promise;
1421
- const result = unwrapJsonRpcResult(responseMessage);
1422
- return result;
1385
+ const invoke$5 = (ipc, method, ...params) => {
1386
+ return invokeHelper(ipc, method, params, false);
1387
+ };
1388
+ const invokeAndTransfer$2 = (ipc, method, ...params) => {
1389
+ return invokeHelper(ipc, method, params, true);
1423
1390
  };
1424
1391
 
1425
1392
  const requiresSocket = () => {
@@ -1492,7 +1459,7 @@ const invokeAndTransfer$1 = async (method, ...params) => {
1492
1459
  const ipc = get$4();
1493
1460
  return invokeAndTransfer$2(ipc, method, ...params);
1494
1461
  };
1495
- const listen$8 = ipc => {
1462
+ const listen$7 = ipc => {
1496
1463
  set$4(ipc);
1497
1464
  };
1498
1465
 
@@ -1547,7 +1514,7 @@ const create$d = async () => {
1547
1514
  }
1548
1515
  return port2;
1549
1516
  };
1550
- const wrap$3 = port => {
1517
+ const wrap$2 = port => {
1551
1518
  return {
1552
1519
  port,
1553
1520
  /**
@@ -1581,7 +1548,7 @@ const wrap$3 = port => {
1581
1548
  const IpcParentWithExtensionHostWorker = {
1582
1549
  __proto__: null,
1583
1550
  create: create$d,
1584
- wrap: wrap$3
1551
+ wrap: wrap$2
1585
1552
  };
1586
1553
 
1587
1554
  const sendMessagePortToSyntaxHighlightingWorker = async port => {
@@ -1737,7 +1704,7 @@ const createRpc = method => {
1737
1704
  };
1738
1705
 
1739
1706
  const {
1740
- listen: listen$7,
1707
+ listen: listen$6,
1741
1708
  invoke: invoke$2
1742
1709
  } = createRpc(ExtensionHostWorker);
1743
1710
 
@@ -1787,19 +1754,13 @@ const execute = async ({
1787
1754
  return result;
1788
1755
  };
1789
1756
 
1790
- const combineResults$3 = results => {
1791
- return results[0];
1792
- };
1793
1757
  const executeDiagnosticProvider = editor => {
1794
1758
  return execute({
1795
1759
  editor,
1796
1760
  event: OnDiagnostic,
1797
1761
  method: 'ExtensionHost.executeDiagnosticProvider',
1798
1762
  args: [],
1799
- noProviderFoundMessage: 'no diagnostic provider found',
1800
- noProviderResult: [],
1801
- combineResults: combineResults$3
1802
- });
1763
+ noProviderFoundMessage: 'no diagnostic provider found'});
1803
1764
  };
1804
1765
 
1805
1766
  const getDiagnosticType = diagnostic => {
@@ -1860,7 +1821,7 @@ const updateDiagnostics = async newState => {
1860
1821
  const diagnostics = await executeDiagnosticProvider(newState);
1861
1822
  const latest = get$6(newState.id);
1862
1823
  if (!latest) {
1863
- return;
1824
+ return newState;
1864
1825
  }
1865
1826
  const decorations = getVisibleDiagnostics(latest.newState, diagnostics);
1866
1827
  const newEditor = {
@@ -1870,6 +1831,7 @@ const updateDiagnostics = async newState => {
1870
1831
  };
1871
1832
  set$6(newState.id, latest.oldState, newEditor);
1872
1833
  await invoke$3('Editor.rerender', newState.id);
1834
+ return newEditor;
1873
1835
  } catch (error) {
1874
1836
  // @ts-ignore
1875
1837
  if (error && error.message.includes('No diagnostic provider found')) {
@@ -1932,7 +1894,7 @@ const createEditor = async ({
1932
1894
  uri,
1933
1895
  diagnosticsEnabled
1934
1896
  }) => {
1935
- number$1(id);
1897
+ number(id);
1936
1898
  string(content);
1937
1899
  const charWidth = measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
1938
1900
  const editor = {
@@ -2207,14 +2169,14 @@ const normalizeGuess = (line, guess, tabSize) => {
2207
2169
  // @ts-ignore
2208
2170
  const getAccurateColumnIndex = (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX) => {
2209
2171
  string(line);
2210
- number$1(fontWeight);
2211
- number$1(fontSize);
2172
+ number(fontWeight);
2173
+ number(fontSize);
2212
2174
  string(fontFamily);
2213
- number$1(letterSpacing);
2175
+ number(letterSpacing);
2214
2176
  boolean(isMonospaceFont);
2215
- number$1(charWidth);
2216
- number$1(tabSize);
2217
- number$1(eventX);
2177
+ number(charWidth);
2178
+ number(tabSize);
2179
+ number(eventX);
2218
2180
  // Assert.greaterZero(charWidth)
2219
2181
  const guess = guessOffset(eventX, charWidth);
2220
2182
  const normalize = shouldNormalizeText(line);
@@ -2234,8 +2196,8 @@ const getAccurateColumnIndex = (line, fontWeight, fontSize, fontFamily, letterSp
2234
2196
 
2235
2197
  const at = (editor, eventX, eventY) => {
2236
2198
  object(editor);
2237
- number$1(eventX);
2238
- number$1(eventY);
2199
+ number(eventX);
2200
+ number(eventY);
2239
2201
  const {
2240
2202
  y,
2241
2203
  deltaY,
@@ -2246,7 +2208,6 @@ const at = (editor, eventX, eventY) => {
2246
2208
  letterSpacing,
2247
2209
  lines,
2248
2210
  tabSize,
2249
- differences,
2250
2211
  isMonospaceFont,
2251
2212
  charWidth
2252
2213
  } = editor;
@@ -2308,8 +2269,8 @@ const state$7 = {
2308
2269
  // @ts-ignore
2309
2270
  const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError) => {
2310
2271
  object(editor);
2311
- number$1(rowIndex);
2312
- number$1(columnIndex);
2272
+ number(rowIndex);
2273
+ number(columnIndex);
2313
2274
  string(message);
2314
2275
  const x$1 = x(editor, rowIndex, columnIndex);
2315
2276
  const y$1 = y(editor, rowIndex);
@@ -2655,10 +2616,10 @@ const compositionEnd = (editor, data) => {
2655
2616
 
2656
2617
  const normalizeLine$1 = line => {
2657
2618
  if (line.startsWith('Error: ')) {
2658
- return line.slice(`Error: `.length);
2619
+ return line.slice('Error: '.length);
2659
2620
  }
2660
2621
  if (line.startsWith('VError: ')) {
2661
- return line.slice(`VError: `.length);
2622
+ return line.slice('VError: '.length);
2662
2623
  }
2663
2624
  return line;
2664
2625
  };
@@ -2781,7 +2742,7 @@ const copyLineDown = editor => {
2781
2742
  selections
2782
2743
  } = editor;
2783
2744
  const rowIndex = selections[0];
2784
- number$1(rowIndex);
2745
+ number(rowIndex);
2785
2746
  const position = {
2786
2747
  rowIndex,
2787
2748
  columnIndex: 0
@@ -3087,8 +3048,8 @@ const cursorHome = editor => {
3087
3048
 
3088
3049
  const cursorSet = (editor, rowIndex, columnIndex) => {
3089
3050
  object(editor);
3090
- number$1(rowIndex);
3091
- number$1(columnIndex);
3051
+ number(rowIndex);
3052
+ number(columnIndex);
3092
3053
  const selectionEdits = fromRange(rowIndex, columnIndex, rowIndex, columnIndex);
3093
3054
  return scheduleSelections(editor, selectionEdits);
3094
3055
  };
@@ -3485,16 +3446,12 @@ const i18nString = (key, placeholders = emptyObject) => {
3485
3446
  };
3486
3447
 
3487
3448
  const UiStrings$1 = {
3488
- GoToDefinition: 'Go to Definition',
3489
3449
  NoDefinitionFound: 'No definition found',
3490
3450
  NoDefinitionFoundFor: "No definition found for '{PH1}'",
3491
3451
  NoTypeDefinitionFound: 'No type definition found',
3492
3452
  NoTypeDefinitionFoundFor: "No type definition found for '{PH1}'",
3493
3453
  NoResults: 'No Results',
3494
- Replace: 'Replace',
3495
3454
  SourceAction: 'Source Action',
3496
- OrganizeImports: 'Organize Imports',
3497
- SortImports: 'Sort Imports',
3498
3455
  NoCodeActionsAvailable: 'No code actions available',
3499
3456
  EscapeToClose: 'Escape to close',
3500
3457
  EnterCode: 'Enter Code'
@@ -3814,9 +3771,9 @@ const getFn = modifier => {
3814
3771
  };
3815
3772
  const handleSingleClick = async (editor, modifier, x, y) => {
3816
3773
  object(editor);
3817
- number$1(modifier);
3818
- number$1(x);
3819
- number$1(y);
3774
+ number(modifier);
3775
+ number(x);
3776
+ number(y);
3820
3777
  const position = at(editor, x, y);
3821
3778
  const fn = getFn(modifier);
3822
3779
  const newEditor = await fn(editor, position);
@@ -3855,8 +3812,8 @@ const selectLine = editor => {
3855
3812
  // @ts-ignore
3856
3813
  const handleTripleClick = (editor, modifier, x, y) => {
3857
3814
  object(editor);
3858
- number$1(x);
3859
- number$1(y);
3815
+ number(x);
3816
+ number(y);
3860
3817
  return {
3861
3818
  newState: selectLine(editor),
3862
3819
  commands: []
@@ -3947,8 +3904,8 @@ const getTokenIndex = (tokens, offset) => {
3947
3904
  // @ts-ignore
3948
3905
  const handleMouseMoveWithAltKey = async (editor, x, y) => {
3949
3906
  object(editor);
3950
- number$1(x);
3951
- number$1(y);
3907
+ number(x);
3908
+ number(y);
3952
3909
  const position = at(editor, x, y);
3953
3910
  const documentOffset = offsetAt(editor, position.rowIndex, position.columnIndex);
3954
3911
  try {
@@ -4136,9 +4093,6 @@ const handleScrollBarHorizontalPointerDown = (state, eventX) => {
4136
4093
  x,
4137
4094
  deltaX,
4138
4095
  width,
4139
- finalDeltaY,
4140
- height,
4141
- scrollBarHeight,
4142
4096
  longestLineWidth
4143
4097
  } = state;
4144
4098
  const relativeX = eventX - x;
@@ -4286,14 +4240,12 @@ const setDeltaYFixedValue = (editor, deltaY) => {
4286
4240
 
4287
4241
  // @ts-ignore
4288
4242
  const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
4289
- number$1(deltaMode);
4290
- number$1(eventDeltaX);
4291
- number$1(eventDeltaY);
4243
+ number(deltaMode);
4244
+ number(eventDeltaX);
4245
+ number(eventDeltaY);
4292
4246
  // @ts-ignore
4293
4247
  const {
4294
- deltaX,
4295
- deltaY
4296
- } = editor;
4248
+ deltaX} = editor;
4297
4249
  if (eventDeltaX === 0) {
4298
4250
  return setDeltaY$1(editor, eventDeltaY);
4299
4251
  }
@@ -4647,8 +4599,8 @@ const continueScrollingAndMovingSelection = async () => {
4647
4599
  // @ts-ignore
4648
4600
  const moveSelectionPx = (editor, x, y) => {
4649
4601
  object(editor);
4650
- number$1(x);
4651
- number$1(y);
4602
+ number(x);
4603
+ number(y);
4652
4604
  const position = at(editor, x, y);
4653
4605
  if (!hasListener() && (position.rowIndex < editor.minLineY || position.rowIndex > editor.maxLineY)) {
4654
4606
  requestAnimationFrame(continueScrollingAndMovingSelection);
@@ -4747,9 +4699,6 @@ const create$5 = () => {
4747
4699
  return completionWidget;
4748
4700
  };
4749
4701
 
4750
- const combineResults$2 = results => {
4751
- return results[0] ?? [];
4752
- };
4753
4702
  const executeCompletionProvider = async (editor, offset) => {
4754
4703
  return execute({
4755
4704
  editor,
@@ -4757,12 +4706,7 @@ const executeCompletionProvider = async (editor, offset) => {
4757
4706
  method: CompletionExecute,
4758
4707
  args: [offset],
4759
4708
  noProviderFoundMessage: 'no completion provider found',
4760
- noProviderFoundResult: [],
4761
- combineResults: combineResults$2
4762
- });
4763
- };
4764
- const combineResultsResolve = items => {
4765
- return items[0] ?? undefined;
4709
+ noProviderFoundResult: []});
4766
4710
  };
4767
4711
  const executeResolveCompletionItem = async (editor, offset, name, completionItem) => {
4768
4712
  return execute({
@@ -4771,9 +4715,7 @@ const executeResolveCompletionItem = async (editor, offset, name, completionItem
4771
4715
  method: CompletionResolveExecute,
4772
4716
  args: [offset, name, completionItem],
4773
4717
  noProviderFoundMessage: 'no completion provider found',
4774
- noProviderFoundResult: [],
4775
- combineResults: combineResultsResolve
4776
- });
4718
+ noProviderFoundResult: []});
4777
4719
  };
4778
4720
 
4779
4721
  const getOffsetAtCursor = editor => {
@@ -5022,9 +4964,9 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
5022
4964
  };
5023
4965
 
5024
4966
  const getListHeight = (itemsLength, itemHeight, maxHeight) => {
5025
- number$1(itemsLength);
5026
- number$1(itemHeight);
5027
- number$1(maxHeight);
4967
+ number(itemsLength);
4968
+ number(itemHeight);
4969
+ number(maxHeight);
5028
4970
  if (itemsLength === 0) {
5029
4971
  return itemHeight;
5030
4972
  }
@@ -6448,14 +6390,7 @@ const TokenizePlainText = {
6448
6390
 
6449
6391
  const state$1 = {
6450
6392
  tokenizers: Object.create(null),
6451
- tokenizePaths: Object.create(null),
6452
- listeners: [],
6453
- pending: Object.create(null),
6454
- /**
6455
- * @type {number[]}
6456
- */
6457
- connectedEditors: []
6458
- };
6393
+ pending: Object.create(null)};
6459
6394
  const has = languageId => {
6460
6395
  return languageId in state$1.tokenizers;
6461
6396
  };
@@ -6478,7 +6413,7 @@ const getEnabled$1 = () => {
6478
6413
  };
6479
6414
 
6480
6415
  const {
6481
- listen: listen$6,
6416
+ listen: listen$5,
6482
6417
  invoke: invoke$1
6483
6418
  } = createRpc(SyntaxHighlightingWorker);
6484
6419
 
@@ -6641,7 +6576,7 @@ const create$2 = () => {
6641
6576
 
6642
6577
  const executeHoverProvider = async (editor, offset) => {
6643
6578
  object(editor);
6644
- number$1(offset);
6579
+ number(offset);
6645
6580
  return execute({
6646
6581
  event: OnHover,
6647
6582
  editor,
@@ -6653,14 +6588,14 @@ const executeHoverProvider = async (editor, offset) => {
6653
6588
 
6654
6589
  const getHover = async (editor, offset) => {
6655
6590
  object(editor);
6656
- number$1(offset);
6591
+ number(offset);
6657
6592
  // TODO invoke extension host worker directly
6658
6593
  const hover = await executeHoverProvider(editor, offset);
6659
6594
  return hover;
6660
6595
  };
6661
6596
 
6662
6597
  let _ipc;
6663
- const listen$5 = async () => {
6598
+ const listen$4 = async () => {
6664
6599
  const ipc = await create$a({
6665
6600
  method: RendererProcess
6666
6601
  });
@@ -6809,7 +6744,7 @@ const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) =>
6809
6744
  };
6810
6745
  };
6811
6746
  const getEditorHoverInfo = async (editorUid, position) => {
6812
- number$1(editorUid);
6747
+ number(editorUid);
6813
6748
  const instance = get$6(editorUid);
6814
6749
  const editor = instance.newState;
6815
6750
  const {
@@ -7025,9 +6960,6 @@ const sortLinesAscending = editor => {
7025
6960
  return scheduleDocumentAndCursorsSelections(editor, changes);
7026
6961
  };
7027
6962
 
7028
- const combineResults$1 = results => {
7029
- return results[0];
7030
- };
7031
6963
  const executeTabCompletionProvider = async (editor, offset) => {
7032
6964
  return execute({
7033
6965
  editor,
@@ -7035,7 +6967,6 @@ const executeTabCompletionProvider = async (editor, offset) => {
7035
6967
  method: TabCompletionExecuteTabCompletionProvider,
7036
6968
  args: [offset],
7037
6969
  noProviderFoundMessage: 'No tab completion provider found',
7038
- combineResults: combineResults$1,
7039
6970
  noProviderFoundResult: undefined
7040
6971
  });
7041
6972
  };
@@ -7801,7 +7732,7 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
7801
7732
 
7802
7733
  const setDeltaY = (state, value) => {
7803
7734
  object(state);
7804
- number$1(value);
7735
+ number(value);
7805
7736
  const {
7806
7737
  itemHeight,
7807
7738
  finalDeltaY,
@@ -7826,8 +7757,8 @@ const setDeltaY = (state, value) => {
7826
7757
  };
7827
7758
 
7828
7759
  const handleWheel = (state, deltaMode, deltaY) => {
7829
- number$1(deltaMode);
7830
- number$1(deltaY);
7760
+ number(deltaMode);
7761
+ number(deltaY);
7831
7762
  return setDeltaY(state, state.deltaY + deltaY);
7832
7763
  };
7833
7764
 
@@ -7897,9 +7828,7 @@ const getEdits = async (editor, completionItem) => {
7897
7828
  const child = getCompletionState(editor);
7898
7829
  // @ts-ignore
7899
7830
  const {
7900
- leadingWord,
7901
- uid
7902
- } = child;
7831
+ leadingWord} = child;
7903
7832
  const word = completionItem.label;
7904
7833
  const resolvedItem = await resolveCompletion(editor, word, completionItem);
7905
7834
  const inserted = resolvedItem ? resolvedItem.snippet : word;
@@ -8005,9 +7934,7 @@ const handleSashPointerDown = (state, eventX, eventY) => {
8005
7934
  const handleSashPointerMove = (state, eventX, eventY) => {
8006
7935
  // @ts-ignore
8007
7936
  const {
8008
- x,
8009
- y
8010
- } = state;
7937
+ x} = state;
8011
7938
  const minWidth = 100;
8012
7939
  const newWidth = Math.max(eventX - x, minWidth);
8013
7940
  return {
@@ -8227,9 +8154,6 @@ const renderHover = (oldState, newState) => {
8227
8154
  return commands;
8228
8155
  };
8229
8156
 
8230
- const combineResults = results => {
8231
- return results[0] ?? [];
8232
- };
8233
8157
  const executeRenameProvider = async (editor, offset, newName) => {
8234
8158
  return execute({
8235
8159
  editor,
@@ -8237,9 +8161,7 @@ const executeRenameProvider = async (editor, offset, newName) => {
8237
8161
  method: RenameExecuteRename,
8238
8162
  args: [offset, newName],
8239
8163
  noProviderFoundMessage: 'no rename provider found',
8240
- noProviderFoundResult: [],
8241
- combineResults
8242
- });
8164
+ noProviderFoundResult: []});
8243
8165
  };
8244
8166
 
8245
8167
  const getRenameState = editor => {
@@ -8479,15 +8401,15 @@ const getEnabled = () => {
8479
8401
  };
8480
8402
 
8481
8403
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
8482
- await listen$5();
8404
+ await listen$4();
8483
8405
  if (syntaxHighlightingEnabled) {
8484
8406
  setEnabled$1(true);
8485
- await listen$6();
8407
+ await listen$5();
8486
8408
  }
8487
8409
  if (syncIncremental) {
8488
8410
  setEnabled(true);
8489
8411
  }
8490
- await listen$7();
8412
+ await listen$6();
8491
8413
  };
8492
8414
 
8493
8415
  // TODO move cursor
@@ -9003,10 +8925,6 @@ const getVisible = async (editor, syncIncremental) => {
9003
8925
  lines,
9004
8926
  width,
9005
8927
  deltaX,
9006
- fontWeight,
9007
- fontSize,
9008
- fontFamily,
9009
- letterSpacing,
9010
8928
  charWidth
9011
8929
  } = editor;
9012
8930
  const maxLineY = Math.min(minLineY + numberOfVisibleLines, lines.length);
@@ -9596,6 +9514,7 @@ const commandMap = {
9596
9514
  'Editor.typeWithAutoClosing': typeWithAutoClosing,
9597
9515
  'Editor.undo': undo,
9598
9516
  'Editor.unIndent': editorUnindent,
9517
+ 'Editor.updateDiagnostics': updateDiagnostics,
9599
9518
  'EditorCompletion.advance': advance,
9600
9519
  'EditorCompletion.closeDetails': closeDetails,
9601
9520
  'EditorCompletion.focusFirst': focusFirst,
@@ -9669,6 +9588,27 @@ const Auto = () => {
9669
9588
  const getData$1 = event => {
9670
9589
  return event.data;
9671
9590
  };
9591
+ const attachEvents = that => {
9592
+ const handleMessage = (...args) => {
9593
+ const data = that.getData(...args);
9594
+ that.dispatchEvent(new MessageEvent('message', {
9595
+ data
9596
+ }));
9597
+ };
9598
+ that.onMessage(handleMessage);
9599
+ const handleClose = event => {
9600
+ that.dispatchEvent(new Event('close'));
9601
+ };
9602
+ that.onClose(handleClose);
9603
+ };
9604
+ class Ipc extends EventTarget {
9605
+ constructor(rawIpc) {
9606
+ super();
9607
+ this._rawIpc = rawIpc;
9608
+ attachEvents(this);
9609
+ }
9610
+ }
9611
+ const readyMessage = 'ready';
9672
9612
  const walkValue = (value, transferrables, isTransferrable) => {
9673
9613
  if (!value) {
9674
9614
  return;
@@ -9719,35 +9659,56 @@ const getTransferrables = value => {
9719
9659
  walkValue(value, transferrables, isTransferrable);
9720
9660
  return transferrables;
9721
9661
  };
9722
- const attachEvents = that => {
9723
- const handleMessage = (...args) => {
9724
- const data = that.getData(...args);
9725
- that.dispatchEvent(new MessageEvent('message', {
9726
- data
9727
- }));
9728
- };
9729
- that.onMessage(handleMessage);
9730
- const handleClose = event => {
9731
- that.dispatchEvent(new Event('close'));
9732
- };
9733
- that.onClose(handleClose);
9662
+ const listen$3 = ({
9663
+ port
9664
+ }) => {
9665
+ return port;
9734
9666
  };
9735
- class Ipc extends EventTarget {
9736
- constructor(rawIpc) {
9737
- super();
9738
- this._rawIpc = rawIpc;
9739
- attachEvents(this);
9667
+ const signal$3 = port => {
9668
+ port.postMessage(readyMessage);
9669
+ };
9670
+ class IpcChildWithMessagePort extends Ipc {
9671
+ constructor(port) {
9672
+ super(port);
9673
+ }
9674
+ getData(event) {
9675
+ return getData$1(event);
9676
+ }
9677
+ send(message) {
9678
+ this._rawIpc.postMessage(message);
9679
+ }
9680
+ sendAndTransfer(message) {
9681
+ const transfer = getTransferrables(message);
9682
+ this._rawIpc.postMessage(message, transfer);
9683
+ }
9684
+ dispose() {
9685
+ // ignore
9686
+ }
9687
+ onClose(callback) {
9688
+ // ignore
9689
+ }
9690
+ onMessage(callback) {
9691
+ this._rawIpc.addEventListener('message', callback);
9692
+ this._rawIpc.start();
9740
9693
  }
9741
9694
  }
9742
- const readyMessage = 'ready';
9743
- const listen$4 = () => {
9695
+ const wrap$6 = port => {
9696
+ return new IpcChildWithMessagePort(port);
9697
+ };
9698
+ const IpcChildWithMessagePort$1 = {
9699
+ __proto__: null,
9700
+ listen: listen$3,
9701
+ signal: signal$3,
9702
+ wrap: wrap$6
9703
+ };
9704
+ const listen$2 = () => {
9744
9705
  // @ts-ignore
9745
9706
  if (typeof WorkerGlobalScope === 'undefined') {
9746
9707
  throw new TypeError('module is not in web worker scope');
9747
9708
  }
9748
9709
  return globalThis;
9749
9710
  };
9750
- const signal$3 = global => {
9711
+ const signal$2 = global => {
9751
9712
  global.postMessage(readyMessage);
9752
9713
  };
9753
9714
  class IpcChildWithModuleWorker extends Ipc {
@@ -9773,14 +9734,14 @@ class IpcChildWithModuleWorker extends Ipc {
9773
9734
  this._rawIpc.addEventListener('message', callback);
9774
9735
  }
9775
9736
  }
9776
- const wrap$6 = global => {
9737
+ const wrap$5 = global => {
9777
9738
  return new IpcChildWithModuleWorker(global);
9778
9739
  };
9779
9740
  const IpcChildWithModuleWorker$1 = {
9780
9741
  __proto__: null,
9781
- listen: listen$4,
9782
- signal: signal$3,
9783
- wrap: wrap$6
9742
+ listen: listen$2,
9743
+ signal: signal$2,
9744
+ wrap: wrap$5
9784
9745
  };
9785
9746
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
9786
9747
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
@@ -9897,10 +9858,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
9897
9858
  };
9898
9859
  const normalizeLine = line => {
9899
9860
  if (line.startsWith('Error: ')) {
9900
- return line.slice(`Error: `.length);
9861
+ return line.slice('Error: '.length);
9901
9862
  }
9902
9863
  if (line.startsWith('VError: ')) {
9903
- return line.slice(`VError: `.length);
9864
+ return line.slice('VError: '.length);
9904
9865
  }
9905
9866
  return line;
9906
9867
  };
@@ -9998,10 +9959,10 @@ const waitForFirstMessage = async port => {
9998
9959
  // @ts-ignore
9999
9960
  return event.data;
10000
9961
  };
10001
- const listen$3 = async () => {
10002
- const parentIpcRaw = listen$4();
10003
- signal$3(parentIpcRaw);
10004
- const parentIpc = wrap$6(parentIpcRaw);
9962
+ const listen$1$1 = async () => {
9963
+ const parentIpcRaw = listen$2();
9964
+ signal$2(parentIpcRaw);
9965
+ const parentIpc = wrap$5(parentIpcRaw);
10005
9966
  const firstMessage = await waitForFirstMessage(parentIpc);
10006
9967
  if (firstMessage.method !== 'initialize') {
10007
9968
  throw new IpcError('unexpected first message');
@@ -10046,55 +10007,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
10046
10007
  this._rawIpc.start();
10047
10008
  }
10048
10009
  }
10049
- const wrap$5 = port => {
10010
+ const wrap$4 = port => {
10050
10011
  return new IpcChildWithModuleWorkerAndMessagePort(port);
10051
10012
  };
10052
10013
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
10053
10014
  __proto__: null,
10054
- listen: listen$3,
10055
- wrap: wrap$5
10056
- };
10057
- const listen$2 = ({
10058
- port
10059
- }) => {
10060
- return port;
10061
- };
10062
- const signal = port => {
10063
- port.postMessage(readyMessage);
10064
- };
10065
- class IpcChildWithMessagePort extends Ipc {
10066
- constructor(port) {
10067
- super(port);
10068
- }
10069
- getData(event) {
10070
- return getData$1(event);
10071
- }
10072
- send(message) {
10073
- this._rawIpc.postMessage(message);
10074
- }
10075
- sendAndTransfer(message) {
10076
- const transfer = getTransferrables(message);
10077
- this._rawIpc.postMessage(message, transfer);
10078
- }
10079
- dispose() {
10080
- // ignore
10081
- }
10082
- onClose(callback) {
10083
- // ignore
10084
- }
10085
- onMessage(callback) {
10086
- this._rawIpc.addEventListener('message', callback);
10087
- this._rawIpc.start();
10088
- }
10089
- }
10090
- const wrap$2 = port => {
10091
- return new IpcChildWithMessagePort(port);
10092
- };
10093
- const IpcChildWithMessagePort$1 = {
10094
- __proto__: null,
10095
- listen: listen$2,
10096
- signal,
10097
- wrap: wrap$2
10015
+ listen: listen$1$1,
10016
+ wrap: wrap$4
10098
10017
  };
10099
10018
 
10100
10019
  const getModule = method => {
@@ -10131,7 +10050,7 @@ const listen = async () => {
10131
10050
  method: Auto()
10132
10051
  });
10133
10052
  handleIpc(ipc);
10134
- listen$8(ipc);
10053
+ listen$7(ipc);
10135
10054
  };
10136
10055
 
10137
10056
  const addWidget = (widget, id, render) => {
@@ -10837,7 +10756,6 @@ const EditorCompletionWidget = {
10837
10756
  * @enum {string}
10838
10757
  */
10839
10758
  const UiStrings = {
10840
- MatchesFoundFor: '{PH1} of {PH2} found for {PH3}',
10841
10759
  MatchOf: '{PH1} of {PH2}',
10842
10760
  NoResults: 'No Results',
10843
10761
  Close: 'Close',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.6.0",
3
+ "version": "5.8.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",