@lvce-editor/editor-worker 5.7.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 => {
@@ -1933,7 +1894,7 @@ const createEditor = async ({
1933
1894
  uri,
1934
1895
  diagnosticsEnabled
1935
1896
  }) => {
1936
- number$1(id);
1897
+ number(id);
1937
1898
  string(content);
1938
1899
  const charWidth = measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
1939
1900
  const editor = {
@@ -2208,14 +2169,14 @@ const normalizeGuess = (line, guess, tabSize) => {
2208
2169
  // @ts-ignore
2209
2170
  const getAccurateColumnIndex = (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX) => {
2210
2171
  string(line);
2211
- number$1(fontWeight);
2212
- number$1(fontSize);
2172
+ number(fontWeight);
2173
+ number(fontSize);
2213
2174
  string(fontFamily);
2214
- number$1(letterSpacing);
2175
+ number(letterSpacing);
2215
2176
  boolean(isMonospaceFont);
2216
- number$1(charWidth);
2217
- number$1(tabSize);
2218
- number$1(eventX);
2177
+ number(charWidth);
2178
+ number(tabSize);
2179
+ number(eventX);
2219
2180
  // Assert.greaterZero(charWidth)
2220
2181
  const guess = guessOffset(eventX, charWidth);
2221
2182
  const normalize = shouldNormalizeText(line);
@@ -2235,8 +2196,8 @@ const getAccurateColumnIndex = (line, fontWeight, fontSize, fontFamily, letterSp
2235
2196
 
2236
2197
  const at = (editor, eventX, eventY) => {
2237
2198
  object(editor);
2238
- number$1(eventX);
2239
- number$1(eventY);
2199
+ number(eventX);
2200
+ number(eventY);
2240
2201
  const {
2241
2202
  y,
2242
2203
  deltaY,
@@ -2247,7 +2208,6 @@ const at = (editor, eventX, eventY) => {
2247
2208
  letterSpacing,
2248
2209
  lines,
2249
2210
  tabSize,
2250
- differences,
2251
2211
  isMonospaceFont,
2252
2212
  charWidth
2253
2213
  } = editor;
@@ -2309,8 +2269,8 @@ const state$7 = {
2309
2269
  // @ts-ignore
2310
2270
  const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError) => {
2311
2271
  object(editor);
2312
- number$1(rowIndex);
2313
- number$1(columnIndex);
2272
+ number(rowIndex);
2273
+ number(columnIndex);
2314
2274
  string(message);
2315
2275
  const x$1 = x(editor, rowIndex, columnIndex);
2316
2276
  const y$1 = y(editor, rowIndex);
@@ -2656,10 +2616,10 @@ const compositionEnd = (editor, data) => {
2656
2616
 
2657
2617
  const normalizeLine$1 = line => {
2658
2618
  if (line.startsWith('Error: ')) {
2659
- return line.slice(`Error: `.length);
2619
+ return line.slice('Error: '.length);
2660
2620
  }
2661
2621
  if (line.startsWith('VError: ')) {
2662
- return line.slice(`VError: `.length);
2622
+ return line.slice('VError: '.length);
2663
2623
  }
2664
2624
  return line;
2665
2625
  };
@@ -2782,7 +2742,7 @@ const copyLineDown = editor => {
2782
2742
  selections
2783
2743
  } = editor;
2784
2744
  const rowIndex = selections[0];
2785
- number$1(rowIndex);
2745
+ number(rowIndex);
2786
2746
  const position = {
2787
2747
  rowIndex,
2788
2748
  columnIndex: 0
@@ -3088,8 +3048,8 @@ const cursorHome = editor => {
3088
3048
 
3089
3049
  const cursorSet = (editor, rowIndex, columnIndex) => {
3090
3050
  object(editor);
3091
- number$1(rowIndex);
3092
- number$1(columnIndex);
3051
+ number(rowIndex);
3052
+ number(columnIndex);
3093
3053
  const selectionEdits = fromRange(rowIndex, columnIndex, rowIndex, columnIndex);
3094
3054
  return scheduleSelections(editor, selectionEdits);
3095
3055
  };
@@ -3486,16 +3446,12 @@ const i18nString = (key, placeholders = emptyObject) => {
3486
3446
  };
3487
3447
 
3488
3448
  const UiStrings$1 = {
3489
- GoToDefinition: 'Go to Definition',
3490
3449
  NoDefinitionFound: 'No definition found',
3491
3450
  NoDefinitionFoundFor: "No definition found for '{PH1}'",
3492
3451
  NoTypeDefinitionFound: 'No type definition found',
3493
3452
  NoTypeDefinitionFoundFor: "No type definition found for '{PH1}'",
3494
3453
  NoResults: 'No Results',
3495
- Replace: 'Replace',
3496
3454
  SourceAction: 'Source Action',
3497
- OrganizeImports: 'Organize Imports',
3498
- SortImports: 'Sort Imports',
3499
3455
  NoCodeActionsAvailable: 'No code actions available',
3500
3456
  EscapeToClose: 'Escape to close',
3501
3457
  EnterCode: 'Enter Code'
@@ -3815,9 +3771,9 @@ const getFn = modifier => {
3815
3771
  };
3816
3772
  const handleSingleClick = async (editor, modifier, x, y) => {
3817
3773
  object(editor);
3818
- number$1(modifier);
3819
- number$1(x);
3820
- number$1(y);
3774
+ number(modifier);
3775
+ number(x);
3776
+ number(y);
3821
3777
  const position = at(editor, x, y);
3822
3778
  const fn = getFn(modifier);
3823
3779
  const newEditor = await fn(editor, position);
@@ -3856,8 +3812,8 @@ const selectLine = editor => {
3856
3812
  // @ts-ignore
3857
3813
  const handleTripleClick = (editor, modifier, x, y) => {
3858
3814
  object(editor);
3859
- number$1(x);
3860
- number$1(y);
3815
+ number(x);
3816
+ number(y);
3861
3817
  return {
3862
3818
  newState: selectLine(editor),
3863
3819
  commands: []
@@ -3948,8 +3904,8 @@ const getTokenIndex = (tokens, offset) => {
3948
3904
  // @ts-ignore
3949
3905
  const handleMouseMoveWithAltKey = async (editor, x, y) => {
3950
3906
  object(editor);
3951
- number$1(x);
3952
- number$1(y);
3907
+ number(x);
3908
+ number(y);
3953
3909
  const position = at(editor, x, y);
3954
3910
  const documentOffset = offsetAt(editor, position.rowIndex, position.columnIndex);
3955
3911
  try {
@@ -4137,9 +4093,6 @@ const handleScrollBarHorizontalPointerDown = (state, eventX) => {
4137
4093
  x,
4138
4094
  deltaX,
4139
4095
  width,
4140
- finalDeltaY,
4141
- height,
4142
- scrollBarHeight,
4143
4096
  longestLineWidth
4144
4097
  } = state;
4145
4098
  const relativeX = eventX - x;
@@ -4287,14 +4240,12 @@ const setDeltaYFixedValue = (editor, deltaY) => {
4287
4240
 
4288
4241
  // @ts-ignore
4289
4242
  const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
4290
- number$1(deltaMode);
4291
- number$1(eventDeltaX);
4292
- number$1(eventDeltaY);
4243
+ number(deltaMode);
4244
+ number(eventDeltaX);
4245
+ number(eventDeltaY);
4293
4246
  // @ts-ignore
4294
4247
  const {
4295
- deltaX,
4296
- deltaY
4297
- } = editor;
4248
+ deltaX} = editor;
4298
4249
  if (eventDeltaX === 0) {
4299
4250
  return setDeltaY$1(editor, eventDeltaY);
4300
4251
  }
@@ -4648,8 +4599,8 @@ const continueScrollingAndMovingSelection = async () => {
4648
4599
  // @ts-ignore
4649
4600
  const moveSelectionPx = (editor, x, y) => {
4650
4601
  object(editor);
4651
- number$1(x);
4652
- number$1(y);
4602
+ number(x);
4603
+ number(y);
4653
4604
  const position = at(editor, x, y);
4654
4605
  if (!hasListener() && (position.rowIndex < editor.minLineY || position.rowIndex > editor.maxLineY)) {
4655
4606
  requestAnimationFrame(continueScrollingAndMovingSelection);
@@ -4748,9 +4699,6 @@ const create$5 = () => {
4748
4699
  return completionWidget;
4749
4700
  };
4750
4701
 
4751
- const combineResults$2 = results => {
4752
- return results[0] ?? [];
4753
- };
4754
4702
  const executeCompletionProvider = async (editor, offset) => {
4755
4703
  return execute({
4756
4704
  editor,
@@ -4758,12 +4706,7 @@ const executeCompletionProvider = async (editor, offset) => {
4758
4706
  method: CompletionExecute,
4759
4707
  args: [offset],
4760
4708
  noProviderFoundMessage: 'no completion provider found',
4761
- noProviderFoundResult: [],
4762
- combineResults: combineResults$2
4763
- });
4764
- };
4765
- const combineResultsResolve = items => {
4766
- return items[0] ?? undefined;
4709
+ noProviderFoundResult: []});
4767
4710
  };
4768
4711
  const executeResolveCompletionItem = async (editor, offset, name, completionItem) => {
4769
4712
  return execute({
@@ -4772,9 +4715,7 @@ const executeResolveCompletionItem = async (editor, offset, name, completionItem
4772
4715
  method: CompletionResolveExecute,
4773
4716
  args: [offset, name, completionItem],
4774
4717
  noProviderFoundMessage: 'no completion provider found',
4775
- noProviderFoundResult: [],
4776
- combineResults: combineResultsResolve
4777
- });
4718
+ noProviderFoundResult: []});
4778
4719
  };
4779
4720
 
4780
4721
  const getOffsetAtCursor = editor => {
@@ -5023,9 +4964,9 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
5023
4964
  };
5024
4965
 
5025
4966
  const getListHeight = (itemsLength, itemHeight, maxHeight) => {
5026
- number$1(itemsLength);
5027
- number$1(itemHeight);
5028
- number$1(maxHeight);
4967
+ number(itemsLength);
4968
+ number(itemHeight);
4969
+ number(maxHeight);
5029
4970
  if (itemsLength === 0) {
5030
4971
  return itemHeight;
5031
4972
  }
@@ -6449,14 +6390,7 @@ const TokenizePlainText = {
6449
6390
 
6450
6391
  const state$1 = {
6451
6392
  tokenizers: Object.create(null),
6452
- tokenizePaths: Object.create(null),
6453
- listeners: [],
6454
- pending: Object.create(null),
6455
- /**
6456
- * @type {number[]}
6457
- */
6458
- connectedEditors: []
6459
- };
6393
+ pending: Object.create(null)};
6460
6394
  const has = languageId => {
6461
6395
  return languageId in state$1.tokenizers;
6462
6396
  };
@@ -6479,7 +6413,7 @@ const getEnabled$1 = () => {
6479
6413
  };
6480
6414
 
6481
6415
  const {
6482
- listen: listen$6,
6416
+ listen: listen$5,
6483
6417
  invoke: invoke$1
6484
6418
  } = createRpc(SyntaxHighlightingWorker);
6485
6419
 
@@ -6642,7 +6576,7 @@ const create$2 = () => {
6642
6576
 
6643
6577
  const executeHoverProvider = async (editor, offset) => {
6644
6578
  object(editor);
6645
- number$1(offset);
6579
+ number(offset);
6646
6580
  return execute({
6647
6581
  event: OnHover,
6648
6582
  editor,
@@ -6654,14 +6588,14 @@ const executeHoverProvider = async (editor, offset) => {
6654
6588
 
6655
6589
  const getHover = async (editor, offset) => {
6656
6590
  object(editor);
6657
- number$1(offset);
6591
+ number(offset);
6658
6592
  // TODO invoke extension host worker directly
6659
6593
  const hover = await executeHoverProvider(editor, offset);
6660
6594
  return hover;
6661
6595
  };
6662
6596
 
6663
6597
  let _ipc;
6664
- const listen$5 = async () => {
6598
+ const listen$4 = async () => {
6665
6599
  const ipc = await create$a({
6666
6600
  method: RendererProcess
6667
6601
  });
@@ -6810,7 +6744,7 @@ const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) =>
6810
6744
  };
6811
6745
  };
6812
6746
  const getEditorHoverInfo = async (editorUid, position) => {
6813
- number$1(editorUid);
6747
+ number(editorUid);
6814
6748
  const instance = get$6(editorUid);
6815
6749
  const editor = instance.newState;
6816
6750
  const {
@@ -7026,9 +6960,6 @@ const sortLinesAscending = editor => {
7026
6960
  return scheduleDocumentAndCursorsSelections(editor, changes);
7027
6961
  };
7028
6962
 
7029
- const combineResults$1 = results => {
7030
- return results[0];
7031
- };
7032
6963
  const executeTabCompletionProvider = async (editor, offset) => {
7033
6964
  return execute({
7034
6965
  editor,
@@ -7036,7 +6967,6 @@ const executeTabCompletionProvider = async (editor, offset) => {
7036
6967
  method: TabCompletionExecuteTabCompletionProvider,
7037
6968
  args: [offset],
7038
6969
  noProviderFoundMessage: 'No tab completion provider found',
7039
- combineResults: combineResults$1,
7040
6970
  noProviderFoundResult: undefined
7041
6971
  });
7042
6972
  };
@@ -7802,7 +7732,7 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
7802
7732
 
7803
7733
  const setDeltaY = (state, value) => {
7804
7734
  object(state);
7805
- number$1(value);
7735
+ number(value);
7806
7736
  const {
7807
7737
  itemHeight,
7808
7738
  finalDeltaY,
@@ -7827,8 +7757,8 @@ const setDeltaY = (state, value) => {
7827
7757
  };
7828
7758
 
7829
7759
  const handleWheel = (state, deltaMode, deltaY) => {
7830
- number$1(deltaMode);
7831
- number$1(deltaY);
7760
+ number(deltaMode);
7761
+ number(deltaY);
7832
7762
  return setDeltaY(state, state.deltaY + deltaY);
7833
7763
  };
7834
7764
 
@@ -7898,9 +7828,7 @@ const getEdits = async (editor, completionItem) => {
7898
7828
  const child = getCompletionState(editor);
7899
7829
  // @ts-ignore
7900
7830
  const {
7901
- leadingWord,
7902
- uid
7903
- } = child;
7831
+ leadingWord} = child;
7904
7832
  const word = completionItem.label;
7905
7833
  const resolvedItem = await resolveCompletion(editor, word, completionItem);
7906
7834
  const inserted = resolvedItem ? resolvedItem.snippet : word;
@@ -8006,9 +7934,7 @@ const handleSashPointerDown = (state, eventX, eventY) => {
8006
7934
  const handleSashPointerMove = (state, eventX, eventY) => {
8007
7935
  // @ts-ignore
8008
7936
  const {
8009
- x,
8010
- y
8011
- } = state;
7937
+ x} = state;
8012
7938
  const minWidth = 100;
8013
7939
  const newWidth = Math.max(eventX - x, minWidth);
8014
7940
  return {
@@ -8228,9 +8154,6 @@ const renderHover = (oldState, newState) => {
8228
8154
  return commands;
8229
8155
  };
8230
8156
 
8231
- const combineResults = results => {
8232
- return results[0] ?? [];
8233
- };
8234
8157
  const executeRenameProvider = async (editor, offset, newName) => {
8235
8158
  return execute({
8236
8159
  editor,
@@ -8238,9 +8161,7 @@ const executeRenameProvider = async (editor, offset, newName) => {
8238
8161
  method: RenameExecuteRename,
8239
8162
  args: [offset, newName],
8240
8163
  noProviderFoundMessage: 'no rename provider found',
8241
- noProviderFoundResult: [],
8242
- combineResults
8243
- });
8164
+ noProviderFoundResult: []});
8244
8165
  };
8245
8166
 
8246
8167
  const getRenameState = editor => {
@@ -8480,15 +8401,15 @@ const getEnabled = () => {
8480
8401
  };
8481
8402
 
8482
8403
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
8483
- await listen$5();
8404
+ await listen$4();
8484
8405
  if (syntaxHighlightingEnabled) {
8485
8406
  setEnabled$1(true);
8486
- await listen$6();
8407
+ await listen$5();
8487
8408
  }
8488
8409
  if (syncIncremental) {
8489
8410
  setEnabled(true);
8490
8411
  }
8491
- await listen$7();
8412
+ await listen$6();
8492
8413
  };
8493
8414
 
8494
8415
  // TODO move cursor
@@ -9004,10 +8925,6 @@ const getVisible = async (editor, syncIncremental) => {
9004
8925
  lines,
9005
8926
  width,
9006
8927
  deltaX,
9007
- fontWeight,
9008
- fontSize,
9009
- fontFamily,
9010
- letterSpacing,
9011
8928
  charWidth
9012
8929
  } = editor;
9013
8930
  const maxLineY = Math.min(minLineY + numberOfVisibleLines, lines.length);
@@ -9671,6 +9588,27 @@ const Auto = () => {
9671
9588
  const getData$1 = event => {
9672
9589
  return event.data;
9673
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';
9674
9612
  const walkValue = (value, transferrables, isTransferrable) => {
9675
9613
  if (!value) {
9676
9614
  return;
@@ -9721,35 +9659,56 @@ const getTransferrables = value => {
9721
9659
  walkValue(value, transferrables, isTransferrable);
9722
9660
  return transferrables;
9723
9661
  };
9724
- const attachEvents = that => {
9725
- const handleMessage = (...args) => {
9726
- const data = that.getData(...args);
9727
- that.dispatchEvent(new MessageEvent('message', {
9728
- data
9729
- }));
9730
- };
9731
- that.onMessage(handleMessage);
9732
- const handleClose = event => {
9733
- that.dispatchEvent(new Event('close'));
9734
- };
9735
- that.onClose(handleClose);
9662
+ const listen$3 = ({
9663
+ port
9664
+ }) => {
9665
+ return port;
9736
9666
  };
9737
- class Ipc extends EventTarget {
9738
- constructor(rawIpc) {
9739
- super();
9740
- this._rawIpc = rawIpc;
9741
- 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();
9742
9693
  }
9743
9694
  }
9744
- const readyMessage = 'ready';
9745
- 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 = () => {
9746
9705
  // @ts-ignore
9747
9706
  if (typeof WorkerGlobalScope === 'undefined') {
9748
9707
  throw new TypeError('module is not in web worker scope');
9749
9708
  }
9750
9709
  return globalThis;
9751
9710
  };
9752
- const signal$3 = global => {
9711
+ const signal$2 = global => {
9753
9712
  global.postMessage(readyMessage);
9754
9713
  };
9755
9714
  class IpcChildWithModuleWorker extends Ipc {
@@ -9775,14 +9734,14 @@ class IpcChildWithModuleWorker extends Ipc {
9775
9734
  this._rawIpc.addEventListener('message', callback);
9776
9735
  }
9777
9736
  }
9778
- const wrap$6 = global => {
9737
+ const wrap$5 = global => {
9779
9738
  return new IpcChildWithModuleWorker(global);
9780
9739
  };
9781
9740
  const IpcChildWithModuleWorker$1 = {
9782
9741
  __proto__: null,
9783
- listen: listen$4,
9784
- signal: signal$3,
9785
- wrap: wrap$6
9742
+ listen: listen$2,
9743
+ signal: signal$2,
9744
+ wrap: wrap$5
9786
9745
  };
9787
9746
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
9788
9747
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
@@ -9899,10 +9858,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
9899
9858
  };
9900
9859
  const normalizeLine = line => {
9901
9860
  if (line.startsWith('Error: ')) {
9902
- return line.slice(`Error: `.length);
9861
+ return line.slice('Error: '.length);
9903
9862
  }
9904
9863
  if (line.startsWith('VError: ')) {
9905
- return line.slice(`VError: `.length);
9864
+ return line.slice('VError: '.length);
9906
9865
  }
9907
9866
  return line;
9908
9867
  };
@@ -10000,10 +9959,10 @@ const waitForFirstMessage = async port => {
10000
9959
  // @ts-ignore
10001
9960
  return event.data;
10002
9961
  };
10003
- const listen$3 = async () => {
10004
- const parentIpcRaw = listen$4();
10005
- signal$3(parentIpcRaw);
10006
- 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);
10007
9966
  const firstMessage = await waitForFirstMessage(parentIpc);
10008
9967
  if (firstMessage.method !== 'initialize') {
10009
9968
  throw new IpcError('unexpected first message');
@@ -10048,55 +10007,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
10048
10007
  this._rawIpc.start();
10049
10008
  }
10050
10009
  }
10051
- const wrap$5 = port => {
10010
+ const wrap$4 = port => {
10052
10011
  return new IpcChildWithModuleWorkerAndMessagePort(port);
10053
10012
  };
10054
10013
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
10055
10014
  __proto__: null,
10056
- listen: listen$3,
10057
- wrap: wrap$5
10058
- };
10059
- const listen$2 = ({
10060
- port
10061
- }) => {
10062
- return port;
10063
- };
10064
- const signal = port => {
10065
- port.postMessage(readyMessage);
10066
- };
10067
- class IpcChildWithMessagePort extends Ipc {
10068
- constructor(port) {
10069
- super(port);
10070
- }
10071
- getData(event) {
10072
- return getData$1(event);
10073
- }
10074
- send(message) {
10075
- this._rawIpc.postMessage(message);
10076
- }
10077
- sendAndTransfer(message) {
10078
- const transfer = getTransferrables(message);
10079
- this._rawIpc.postMessage(message, transfer);
10080
- }
10081
- dispose() {
10082
- // ignore
10083
- }
10084
- onClose(callback) {
10085
- // ignore
10086
- }
10087
- onMessage(callback) {
10088
- this._rawIpc.addEventListener('message', callback);
10089
- this._rawIpc.start();
10090
- }
10091
- }
10092
- const wrap$2 = port => {
10093
- return new IpcChildWithMessagePort(port);
10094
- };
10095
- const IpcChildWithMessagePort$1 = {
10096
- __proto__: null,
10097
- listen: listen$2,
10098
- signal,
10099
- wrap: wrap$2
10015
+ listen: listen$1$1,
10016
+ wrap: wrap$4
10100
10017
  };
10101
10018
 
10102
10019
  const getModule = method => {
@@ -10133,7 +10050,7 @@ const listen = async () => {
10133
10050
  method: Auto()
10134
10051
  });
10135
10052
  handleIpc(ipc);
10136
- listen$8(ipc);
10053
+ listen$7(ipc);
10137
10054
  };
10138
10055
 
10139
10056
  const addWidget = (widget, id, render) => {
@@ -10839,7 +10756,6 @@ const EditorCompletionWidget = {
10839
10756
  * @enum {string}
10840
10757
  */
10841
10758
  const UiStrings = {
10842
- MatchesFoundFor: '{PH1} of {PH2} found for {PH3}',
10843
10759
  MatchOf: '{PH1} of {PH2}',
10844
10760
  NoResults: 'No Results',
10845
10761
  Close: 'Close',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",