@lvce-editor/editor-worker 13.3.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -903,7 +903,7 @@ const send$1 = (transport, method, ...params) => {
903
903
  const message = create$4$2(method, params);
904
904
  transport.send(message);
905
905
  };
906
- const invoke$c = (ipc, method, ...params) => {
906
+ const invoke$d = (ipc, method, ...params) => {
907
907
  return invokeHelper(ipc, method, params, false);
908
908
  };
909
909
  const invokeAndTransfer$3 = (ipc, method, ...params) => {
@@ -942,7 +942,7 @@ const createRpc = ipc => {
942
942
  send$1(ipc, method, ...params);
943
943
  },
944
944
  invoke(method, ...params) {
945
- return invoke$c(ipc, method, ...params);
945
+ return invoke$d(ipc, method, ...params);
946
946
  },
947
947
  invokeAndTransfer(method, ...params) {
948
948
  return invokeAndTransfer$3(ipc, method, ...params);
@@ -1130,6 +1130,12 @@ const CtrlCmd = 1 << 11 >>> 0;
1130
1130
  const Shift = 1 << 10 >>> 0;
1131
1131
  const Alt$1 = 1 << 9 >>> 0;
1132
1132
 
1133
+ const Editor$1 = 3;
1134
+ const SourceControl = 22;
1135
+
1136
+ const Separator = 1;
1137
+ const None = 0;
1138
+
1133
1139
  const CompletionWorker = 301;
1134
1140
  const DebugWorker = 55;
1135
1141
  const EditorWorker = 99;
@@ -1176,22 +1182,22 @@ const create$9 = rpcId => {
1176
1182
  };
1177
1183
 
1178
1184
  const {
1179
- invoke: invoke$b,
1185
+ invoke: invoke$c,
1180
1186
  invokeAndTransfer: invokeAndTransfer$2,
1181
1187
  set: set$a,
1182
1188
  dispose: dispose$2
1183
1189
  } = create$9(ExtensionHostWorker);
1184
1190
  const executeReferenceProvider = async (id, offset) => {
1185
1191
  // @ts-ignore
1186
- return invoke$b('ExtensionHostReference.executeReferenceProvider', id, offset);
1192
+ return invoke$c('ExtensionHostReference.executeReferenceProvider', id, offset);
1187
1193
  };
1188
1194
  const executeFileReferenceProvider = async id => {
1189
1195
  // @ts-ignore
1190
- return invoke$b('ExtensionHostReference.executeFileReferenceProvider', id);
1196
+ return invoke$c('ExtensionHostReference.executeFileReferenceProvider', id);
1191
1197
  };
1192
1198
  const getRuntimeStatus = async extensionId => {
1193
1199
  // @ts-ignore
1194
- return invoke$b('ExtensionHost.getRuntimeStatus', extensionId);
1200
+ return invoke$c('ExtensionHost.getRuntimeStatus', extensionId);
1195
1201
  };
1196
1202
  const registerMockRpc = commandMap => {
1197
1203
  const mockRpc = createMockRpc({
@@ -1207,16 +1213,24 @@ const ExtensionHost = {
1207
1213
  executeFileReferenceProvider,
1208
1214
  executeReferenceProvider,
1209
1215
  getRuntimeStatus,
1210
- invoke: invoke$b,
1216
+ invoke: invoke$c,
1211
1217
  invokeAndTransfer: invokeAndTransfer$2,
1212
1218
  registerMockRpc,
1213
1219
  set: set$a
1214
1220
  };
1215
1221
 
1216
1222
  const {
1217
- invoke: invoke$a,
1223
+ invoke: invoke$b,
1218
1224
  invokeAndTransfer: invokeAndTransfer$1,
1219
1225
  set: set$9} = create$9(RendererWorker);
1226
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1227
+ number(uid);
1228
+ number(menuId);
1229
+ number(x);
1230
+ number(y);
1231
+ // @ts-ignore
1232
+ await invoke$b('ContextMenu.show2', uid, menuId, x, y, args);
1233
+ };
1220
1234
  const sendMessagePortToTextMeasurementWorker = async port => {
1221
1235
  const command = 'TextMeasurement.handleMessagePort';
1222
1236
  // @ts-ignore
@@ -1224,7 +1238,7 @@ const sendMessagePortToTextMeasurementWorker = async port => {
1224
1238
  };
1225
1239
 
1226
1240
  const {
1227
- invoke: invoke$9,
1241
+ invoke: invoke$a,
1228
1242
  invokeAndTransfer,
1229
1243
  set: set$8,
1230
1244
  dispose: dispose$1
@@ -1233,7 +1247,7 @@ const {
1233
1247
  const SyntaxHighlightingWorker = {
1234
1248
  __proto__: null,
1235
1249
  dispose: dispose$1,
1236
- invoke: invoke$9,
1250
+ invoke: invoke$a,
1237
1251
  invokeAndTransfer,
1238
1252
  set: set$8
1239
1253
  };
@@ -1265,7 +1279,7 @@ const createLazyRpc = rpcId => {
1265
1279
 
1266
1280
  // TODO add tests for this
1267
1281
  const activateByEvent = async event => {
1268
- await invoke$a('ExtensionHostManagement.activateByEvent', event);
1282
+ await invoke$b('ExtensionHostManagement.activateByEvent', event);
1269
1283
  };
1270
1284
 
1271
1285
  const codeGeneratorAccept = state => {
@@ -1319,14 +1333,14 @@ const launchColorPickerWorker = async () => {
1319
1333
  };
1320
1334
 
1321
1335
  let workerPromise$3;
1322
- const getOrCreate$4 = () => {
1336
+ const getOrCreate$3 = () => {
1323
1337
  if (!workerPromise$3) {
1324
1338
  workerPromise$3 = launchColorPickerWorker();
1325
1339
  }
1326
1340
  return workerPromise$3;
1327
1341
  };
1328
- const invoke$8 = async (method, ...params) => {
1329
- const worker = await getOrCreate$4();
1342
+ const invoke$9 = async (method, ...params) => {
1343
+ const worker = await getOrCreate$3();
1330
1344
  return await worker.invoke(method, ...params);
1331
1345
  };
1332
1346
 
@@ -1338,10 +1352,10 @@ const loadContent$2 = async (state, parentUid) => {
1338
1352
  width,
1339
1353
  height
1340
1354
  } = state;
1341
- await invoke$8('ColorPicker.create', uid, x, y, width, height, parentUid);
1342
- await invoke$8('ColorPicker.loadContent', uid);
1343
- const diff = await invoke$8('ColorPicker.diff2', uid);
1344
- const commands = await invoke$8('ColorPicker.render2', uid, diff);
1355
+ await invoke$9('ColorPicker.create', uid, x, y, width, height, parentUid);
1356
+ await invoke$9('ColorPicker.loadContent', uid);
1357
+ const diff = await invoke$9('ColorPicker.diff2', uid);
1358
+ const commands = await invoke$9('ColorPicker.render2', uid, diff);
1345
1359
  return {
1346
1360
  ...state,
1347
1361
  commands
@@ -1536,7 +1550,7 @@ const getInitialLineState = initialLineState => {
1536
1550
  return deepCopy(initialLineState);
1537
1551
  };
1538
1552
 
1539
- const state$8 = {
1553
+ const state$7 = {
1540
1554
  warned: []
1541
1555
  };
1542
1556
  const flattenTokensArray = tokens => {
@@ -1548,10 +1562,10 @@ const flattenTokensArray = tokens => {
1548
1562
  return flattened;
1549
1563
  };
1550
1564
  const warnDeprecatedArrayReturn = (languageId, fn) => {
1551
- if (state$8.warned.includes(fn)) {
1565
+ if (state$7.warned.includes(fn)) {
1552
1566
  return;
1553
1567
  }
1554
- state$8.warned.push(fn);
1568
+ state$7.warned.push(fn);
1555
1569
  console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
1556
1570
  };
1557
1571
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
@@ -1622,22 +1636,22 @@ const getEnabled$1 = () => {
1622
1636
 
1623
1637
  const {
1624
1638
  set: set$5,
1625
- invoke: invoke$7} = SyntaxHighlightingWorker;
1639
+ invoke: invoke$8} = SyntaxHighlightingWorker;
1626
1640
 
1627
- const state$7 = {
1641
+ const state$6 = {
1628
1642
  tokenizers: Object.create(null),
1629
1643
  pending: Object.create(null)};
1630
1644
  const has = languageId => {
1631
- return languageId in state$7.tokenizers;
1645
+ return languageId in state$6.tokenizers;
1632
1646
  };
1633
1647
  const set$4 = (languageId, tokenizer) => {
1634
- state$7.tokenizers[languageId] = tokenizer;
1648
+ state$6.tokenizers[languageId] = tokenizer;
1635
1649
  };
1636
1650
  const get$4 = languageId => {
1637
- return state$7.tokenizers[languageId];
1651
+ return state$6.tokenizers[languageId];
1638
1652
  };
1639
1653
  const isPending = languageId => {
1640
- return languageId in state$7.pending;
1654
+ return languageId in state$6.pending;
1641
1655
  };
1642
1656
 
1643
1657
  const tokenMaps = Object.create(null);
@@ -1655,7 +1669,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
1655
1669
  }
1656
1670
  if (getEnabled$1()) {
1657
1671
  // @ts-ignore
1658
- const tokenMap = await invoke$7('Tokenizer.load', languageId, tokenizePath);
1672
+ const tokenMap = await invoke$8('Tokenizer.load', languageId, tokenizePath);
1659
1673
  set$3(languageId, tokenMap);
1660
1674
  return;
1661
1675
  }
@@ -1831,13 +1845,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
1831
1845
  languageId,
1832
1846
  invalidStartIndex
1833
1847
  };
1834
- return invoke$7('GetTokensViewport.getTokensViewport', slimEditor,
1848
+ return invoke$8('GetTokensViewport.getTokensViewport', slimEditor,
1835
1849
  // @ts-ignore
1836
1850
  startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
1837
1851
  }
1838
1852
  // TODO only send needed lines of text
1839
1853
  // @ts-ignore
1840
- return invoke$7('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
1854
+ return invoke$8('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
1841
1855
  }
1842
1856
  return getTokensViewport(editor, startLineIndex, endLineIndex);
1843
1857
  };
@@ -2400,7 +2414,7 @@ const getIncrementalEdits = async (oldState, newState) => {
2400
2414
  const oldLine = oldState.lines[rowIndex];
2401
2415
  const newLine = lines[rowIndex];
2402
2416
  // @ts-ignore
2403
- const incrementalEdits = await invoke$7(
2417
+ const incrementalEdits = await invoke$8(
2404
2418
  // @ts-ignore
2405
2419
  'TokenizeIncremental.tokenizeIncremental', newState.uid,
2406
2420
  // @ts-ignore
@@ -2441,69 +2455,31 @@ const getTabCount = string => {
2441
2455
  return count;
2442
2456
  };
2443
2457
 
2444
- const measureTextWidthFast = async (text, charWidth) => {
2445
- return text.length * charWidth;
2446
- };
2447
-
2448
- const getFontString = (fontWeight, fontSize, fontFamily) => {
2449
- return `${fontWeight} ${fontSize}px ${fontFamily}`;
2450
- };
2451
-
2452
- const getLetterSpacingString = letterSpacing => {
2453
- return `${letterSpacing}px`;
2454
- };
2455
-
2456
- const createMeasureContext = () => {
2457
- const canvas = new OffscreenCanvas(0, 0);
2458
- const ctx = /** @type {OffscreenCanvasRenderingContext2D} */canvas.getContext('2d');
2459
- if (!ctx) {
2460
- throw new Error('Failed to get canvas context 2d');
2461
- }
2462
- return ctx;
2463
- };
2464
-
2465
- const state$6 = {
2466
- ctx: undefined
2467
- };
2468
- const getOrCreate$3 = createCtx => {
2469
- if (state$6.ctx) {
2470
- return state$6.ctx;
2471
- }
2472
- state$6.ctx = createCtx();
2473
- return state$6.ctx;
2458
+ const RE_ASCII = /^[\p{ASCII}]*$/u;
2459
+ const isAscii = line => {
2460
+ return RE_ASCII.test(line);
2474
2461
  };
2475
2462
 
2476
- const getContext = () => {
2477
- const ctx = getOrCreate$3(createMeasureContext);
2478
- return ctx;
2463
+ const measureTextWidthFast = async (text, charWidth) => {
2464
+ return text.length * charWidth;
2479
2465
  };
2480
2466
 
2481
- // TODO for text editor, could dispose measuring canvas after editor has been initialized to free up offscreencanvas space
2467
+ const {
2468
+ invoke: invoke$7,
2469
+ setFactory: setFactory$1
2470
+ } = createLazyRpc(TextMeasurementWorker);
2482
2471
 
2483
2472
  const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
2484
- string(text);
2485
- number(fontWeight);
2486
- number(fontSize);
2487
- string(fontFamily);
2488
- boolean(isMonoSpaceFont);
2489
- number(charWidth);
2490
- if (typeof letterSpacing !== 'number') {
2491
- throw new TypeError('letterSpacing must be of type number');
2492
- }
2493
- const letterSpacingString = getLetterSpacingString(letterSpacing);
2494
- const fontString = getFontString(fontWeight, fontSize, fontFamily);
2495
- const ctx = getContext();
2496
- ctx.letterSpacing = letterSpacingString;
2497
- ctx.font = fontString;
2498
- const metrics = ctx.measureText(text);
2499
- const {
2500
- width
2501
- } = metrics;
2473
+ const width = await invoke$7('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
2502
2474
  return width;
2503
2475
  };
2504
2476
 
2505
2477
  const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
2506
- if (isMonoSpaceFont) {
2478
+ // TODO maybe have a property for the whole text document
2479
+ // whether the document is ascii or not
2480
+ // so that it doesn't need to be checked on every cursor change
2481
+ // or scroll position change
2482
+ if (isMonoSpaceFont && isAscii(text)) {
2507
2483
  return await measureTextWidthFast(text, charWidth);
2508
2484
  }
2509
2485
  return await measureTextWidthSlow(text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
@@ -3143,7 +3119,7 @@ const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpa
3143
3119
  };
3144
3120
 
3145
3121
  const get$1 = async key => {
3146
- const value = await invoke$a('Preferences.get', key);
3122
+ const value = await invoke$b('Preferences.get', key);
3147
3123
  return value;
3148
3124
  };
3149
3125
 
@@ -3243,7 +3219,7 @@ const updateDiagnostics = async newState => {
3243
3219
  };
3244
3220
  set$6(newState.id, latest.oldState, newEditor);
3245
3221
  // @ts-ignore
3246
- await invoke$a('Editor.rerender', newState.id);
3222
+ await invoke$b('Editor.rerender', newState.id);
3247
3223
  return newEditor;
3248
3224
  } catch (error) {
3249
3225
  // @ts-ignore
@@ -3396,7 +3372,7 @@ const createEditor = async ({
3396
3372
  };
3397
3373
 
3398
3374
  // @ts-ignore
3399
- const getNewSelections$d = selections => {
3375
+ const getNewSelections$c = selections => {
3400
3376
  const newSelections = [];
3401
3377
  for (let i = 0; i < selections.length; i += 4) {
3402
3378
  const startRowIndex = selections[i];
@@ -3416,7 +3392,7 @@ const addCursorAbove = editor => {
3416
3392
  const {
3417
3393
  selections
3418
3394
  } = editor;
3419
- const newSelections = getNewSelections$d(selections);
3395
+ const newSelections = getNewSelections$c(selections);
3420
3396
  return {
3421
3397
  ...editor,
3422
3398
  selections: newSelections
@@ -3424,7 +3400,7 @@ const addCursorAbove = editor => {
3424
3400
  };
3425
3401
 
3426
3402
  // @ts-ignore
3427
- const getNewSelections$c = (selections, linesLength) => {
3403
+ const getNewSelections$b = (selections, linesLength) => {
3428
3404
  const newSelections = [];
3429
3405
  for (let i = 0; i < selections.length; i += 4) {
3430
3406
  const startRowIndex = selections[i];
@@ -3445,7 +3421,7 @@ const addCursorBelow = editor => {
3445
3421
  selections,
3446
3422
  lines
3447
3423
  } = editor;
3448
- const newSelections = getNewSelections$c(selections, lines.length);
3424
+ const newSelections = getNewSelections$b(selections, lines.length);
3449
3425
  return {
3450
3426
  ...editor,
3451
3427
  selections: newSelections
@@ -3652,11 +3628,6 @@ const getAccurateColumnIndexUnicode = async (line, guess, averageCharWidth, even
3652
3628
  return line.length;
3653
3629
  };
3654
3630
 
3655
- const RE_ASCII = /^[\p{ASCII}]*$/u;
3656
- const isAscii = line => {
3657
- return RE_ASCII.test(line);
3658
- };
3659
-
3660
3631
  const guessOffset = (eventX, averageCharWidth) => {
3661
3632
  const guess = Math.round(eventX / averageCharWidth);
3662
3633
  return guess;
@@ -3779,7 +3750,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
3779
3750
  const y$1 = y(editor, rowIndex);
3780
3751
  const displayErrorMessage = message;
3781
3752
  // @ts-ignore
3782
- await invoke$a('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
3753
+ await invoke$b('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
3783
3754
  if (!isError) {
3784
3755
  const handleTimeout = () => {
3785
3756
  editorHideMessage(editor);
@@ -3836,7 +3807,7 @@ const braceCompletion = async (editor, text) => {
3836
3807
  // @ts-ignore
3837
3808
  const offset = offsetAt(editor, editor.cursor);
3838
3809
  // @ts-ignore
3839
- const result = await invoke$a('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
3810
+ const result = await invoke$b('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
3840
3811
  if (result) {
3841
3812
  const closingBrace = getMatchingClosingBrace$1(text);
3842
3813
  const insertText = text + closingBrace;
@@ -4104,7 +4075,7 @@ const compositionEnd = (editor, data) => {
4104
4075
  const writeText = async text => {
4105
4076
  try {
4106
4077
  string(text);
4107
- await invoke$a('ClipBoard.writeText', /* text */text);
4078
+ await invoke$b('ClipBoard.writeText', /* text */text);
4108
4079
  } catch (error) {
4109
4080
  throw new VError(error, 'Failed to write text to clipboard');
4110
4081
  }
@@ -4143,7 +4114,7 @@ const shouldCopyFullLine = (startRowIndex, startColumnIndex, endRowIndex, endCol
4143
4114
  };
4144
4115
 
4145
4116
  // @ts-ignore
4146
- const copy = async editor => {
4117
+ const copy$1 = async editor => {
4147
4118
  if (!hasSelection(editor)) {
4148
4119
  // TODO copy line where cursor is
4149
4120
  return editor;
@@ -4258,7 +4229,7 @@ const moveToPositionLeft = (selections, i, rowIndex, columnIndex, lines, getDelt
4258
4229
  // @ts-ignore
4259
4230
 
4260
4231
  // @ts-ignore
4261
- const getNewSelections$b = (selections, lines, getDelta) => {
4232
+ const getNewSelections$a = (selections, lines, getDelta) => {
4262
4233
  const newSelections = new Uint32Array(selections.length);
4263
4234
  for (let i = 0; i < selections.length; i += 4) {
4264
4235
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
@@ -4285,7 +4256,7 @@ const editorCursorHorizontalLeft = (editor, getDelta) => {
4285
4256
  lines,
4286
4257
  selections
4287
4258
  } = editor;
4288
- const newSelections = getNewSelections$b(selections, lines, getDelta);
4259
+ const newSelections = getNewSelections$a(selections, lines, getDelta);
4289
4260
  return scheduleSelections(editor, newSelections);
4290
4261
  };
4291
4262
 
@@ -4433,7 +4404,7 @@ const moveToPositionRight = (selections, i, rowIndex, columnIndex, lines, getDel
4433
4404
  }
4434
4405
  };
4435
4406
 
4436
- const getNewSelections$a = (selections, lines, getDelta) => {
4407
+ const getNewSelectionsWordRight = (selections, lines, getDelta) => {
4437
4408
  const newSelections = new Uint32Array(selections.length);
4438
4409
  for (let i = 0; i < selections.length; i += 4) {
4439
4410
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
@@ -4446,12 +4417,13 @@ const getNewSelections$a = (selections, lines, getDelta) => {
4446
4417
  }
4447
4418
  return newSelections;
4448
4419
  };
4420
+
4449
4421
  const editorCursorHorizontalRight = (editor, getDelta) => {
4450
4422
  const {
4451
4423
  lines,
4452
4424
  selections
4453
4425
  } = editor;
4454
- const newSelections = getNewSelections$a(selections, lines, getDelta);
4426
+ const newSelections = getNewSelectionsWordRight(selections, lines, getDelta);
4455
4427
  return scheduleSelections(editor, newSelections);
4456
4428
  };
4457
4429
 
@@ -4564,7 +4536,7 @@ const cutSelectedText = async editor => {
4564
4536
  return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
4565
4537
  };
4566
4538
 
4567
- const cut = async editor => {
4539
+ const cut$1 = async editor => {
4568
4540
  const {
4569
4541
  selections
4570
4542
  } = editor;
@@ -4739,9 +4711,9 @@ const deleteWordRight = editor => {
4739
4711
  return editorDeleteHorizontalRight(editor, wordRight);
4740
4712
  };
4741
4713
 
4742
- const findAllReferences = async editor => {
4714
+ const findAllReferences$1 = async editor => {
4743
4715
  // @ts-ignore
4744
- await invoke$a('SideBar.show', 'References', /* focus */true);
4716
+ await invoke$b('SideBar.show', 'References', /* focus */true);
4745
4717
  return editor;
4746
4718
  };
4747
4719
 
@@ -4829,7 +4801,7 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
4829
4801
  // @ts-ignore
4830
4802
  const getDefinition = async (editor, offset) => {
4831
4803
  // @ts-ignore
4832
- const definition = await invoke$a('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
4804
+ const definition = await invoke$b('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
4833
4805
  return definition;
4834
4806
  };
4835
4807
 
@@ -4845,6 +4817,8 @@ const i18nString = (key, placeholders = emptyObject) => {
4845
4817
  return key.replaceAll(RE_PLACEHOLDER, replacer);
4846
4818
  };
4847
4819
 
4820
+ const Copy = 'Copy';
4821
+ const Cut = 'Cut';
4848
4822
  const EditorCloseColorPicker = 'Editor: Close Color Picker';
4849
4823
  const EditorCopyLineDown = 'Editor: Copy Line Down';
4850
4824
  const EditorCopyLineUp = 'Editor: Copy Line Up';
@@ -4864,16 +4838,24 @@ const EditorToggleComment = 'Editor: Toggle Comment';
4864
4838
  const EditorUnindent = 'Editor: Unindent';
4865
4839
  const EnterCode = 'Enter Code';
4866
4840
  const EscapeToClose = 'Escape to close';
4841
+ const FindAllImplementations = 'Find All Implementations';
4842
+ const FindAllReferences = 'Find All References';
4867
4843
  const FormatDocument = 'Format Document';
4844
+ const GoToDefinition = 'Go to Definition';
4845
+ const GoToTypeDefinition = 'Go to Type Definition';
4868
4846
  const MoveLineDown = 'Move Line Down';
4869
4847
  const MoveLineUp = 'Move Line Up';
4870
4848
  const NoDefinitionFound = 'No definition found';
4871
4849
  const NoDefinitionFoundFor = "No definition found for '{PH1}'";
4872
4850
  const NoTypeDefinitionFound = 'No type definition found';
4873
4851
  const NoTypeDefinitionFoundFor = "No type definition found for '{PH1}'";
4852
+ const Paste = 'Paste';
4874
4853
  const SourceAction = 'Source Action';
4875
4854
  const ToggleBlockComment = 'Toggle Block Comment';
4876
4855
 
4856
+ const goToDefinition$1 = () => {
4857
+ return i18nString(GoToDefinition);
4858
+ };
4877
4859
  const noDefinitionFound = () => {
4878
4860
  return i18nString(NoDefinitionFound);
4879
4861
  };
@@ -4899,6 +4881,24 @@ const escapeToClose = () => {
4899
4881
  const enterCode = () => {
4900
4882
  return i18nString(EnterCode);
4901
4883
  };
4884
+ const goToTypeDefinition$1 = () => {
4885
+ return i18nString(GoToTypeDefinition);
4886
+ };
4887
+ const findAllReferences = () => {
4888
+ return i18nString(FindAllReferences);
4889
+ };
4890
+ const findAllImplementations = () => {
4891
+ return i18nString(FindAllImplementations);
4892
+ };
4893
+ const cut = () => {
4894
+ return i18nString(Cut);
4895
+ };
4896
+ const copy = () => {
4897
+ return i18nString(Copy);
4898
+ };
4899
+ const paste$1 = () => {
4900
+ return i18nString(Paste);
4901
+ };
4902
4902
  const toggleBlockComment$1 = () => {
4903
4903
  return i18nString(ToggleBlockComment);
4904
4904
  };
@@ -5008,7 +5008,7 @@ const goTo = async ({
5008
5008
  endRowIndex: definition.endRowIndex,
5009
5009
  endColumnIndex: definition.endColumnIndex
5010
5010
  };
5011
- await invoke$a(/* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
5011
+ await invoke$b(/* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
5012
5012
  return editor;
5013
5013
  } catch (error) {
5014
5014
  // TODO if editor is already disposed at this point, do nothing
@@ -5086,7 +5086,7 @@ const getNoLocationFoundMessage = info => {
5086
5086
 
5087
5087
  const getTypeDefinition = async (editor, offset) => {
5088
5088
  // @ts-ignore
5089
- const definition = await invoke$a('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
5089
+ const definition = await invoke$b('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
5090
5090
  return definition;
5091
5091
  };
5092
5092
 
@@ -5241,7 +5241,12 @@ const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) =>
5241
5241
  const Editor = 3;
5242
5242
 
5243
5243
  const handleContextMenu = async (editor, button, x, y) => {
5244
- await invoke$a(/* ContextMenu.show */'ContextMenu.show', /* x */x, /* y */y, /* id */Editor);
5244
+ const {
5245
+ uid
5246
+ } = editor;
5247
+ await showContextMenu2(uid, Editor, /* x */x, /* y */y, {
5248
+ menuId: Editor
5249
+ });
5245
5250
  return editor;
5246
5251
  };
5247
5252
 
@@ -5849,7 +5854,7 @@ const indentMore = editor => {
5849
5854
 
5850
5855
  const getLanguageConfiguration = async editor => {
5851
5856
  // @ts-ignore
5852
- return invoke$a('Languages.getLanguageConfiguration', {
5857
+ return invoke$b('Languages.getLanguageConfiguration', {
5853
5858
  uri: editor.uri,
5854
5859
  languageId: editor.languageId
5855
5860
  });
@@ -6192,7 +6197,7 @@ const create$4 = () => {
6192
6197
  };
6193
6198
 
6194
6199
  const {
6195
- setFactory: setFactory$1,
6200
+ setFactory,
6196
6201
  invoke: invoke$4
6197
6202
  } = createLazyRpc(CompletionWorker);
6198
6203
 
@@ -6430,7 +6435,7 @@ const pasteText = (editor, text) => {
6430
6435
 
6431
6436
  const paste = async editor => {
6432
6437
  // @ts-ignore
6433
- const text = await invoke$a('ClipBoard.readText');
6438
+ const text = await invoke$b('ClipBoard.readText');
6434
6439
  string(text);
6435
6440
  return pasteText(editor, text);
6436
6441
  };
@@ -6576,7 +6581,7 @@ const save = async editor => {
6576
6581
  } = editor;
6577
6582
  const newEditor = await getNewEditor(editor);
6578
6583
  const content = getText$1(newEditor);
6579
- await invoke$a('FileSystem.writeFile', uri, content);
6584
+ await invoke$b('FileSystem.writeFile', uri, content);
6580
6585
  return newEditor;
6581
6586
  } catch (error) {
6582
6587
  // @ts-ignore
@@ -6883,7 +6888,7 @@ const selectInsideString = editor => {
6883
6888
 
6884
6889
  const getNewSelections = async (editor, selections) => {
6885
6890
  // @ts-ignore
6886
- const newSelections = await invoke$a('ExtensionHostSelection.executeGrowSelection', editor, selections);
6891
+ const newSelections = await invoke$b('ExtensionHostSelection.executeGrowSelection', editor, selections);
6887
6892
  if (newSelections.length === 0) {
6888
6893
  return selections;
6889
6894
  }
@@ -7290,7 +7295,7 @@ const showHover3 = async editor => {
7290
7295
 
7291
7296
  const EditorHover = 'EditorHover';
7292
7297
  const showHover = async state => {
7293
- await invoke$a('Viewlet.openWidget', EditorHover);
7298
+ await invoke$b('Viewlet.openWidget', EditorHover);
7294
7299
  return state;
7295
7300
  };
7296
7301
 
@@ -7967,7 +7972,7 @@ const typeWithAutoClosingQuote = (editor, text) => {
7967
7972
  const typeWithAutoClosingTag = async (editor, text) => {
7968
7973
  const offset = offsetAt(editor, editor.selections[0], editor.selections[1]);
7969
7974
  // @ts-ignore
7970
- const result = await invoke$a('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
7975
+ const result = await invoke$b('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
7971
7976
  if (!result) {
7972
7977
  const changes = editorReplaceSelections(editor, [text], EditorType);
7973
7978
  return scheduleDocumentAndCursorsSelections(editor, changes);
@@ -8231,7 +8236,7 @@ const addWidget$1 = (widget, id, render) => {
8231
8236
  const getWidgetInvoke = widgetId => {
8232
8237
  switch (widgetId) {
8233
8238
  case ColorPicker$1:
8234
- return invoke$8;
8239
+ return invoke$9;
8235
8240
  case Completion:
8236
8241
  return invoke$4;
8237
8242
  case Find:
@@ -8988,7 +8993,7 @@ const getEditorSourceActions = async editorId => {
8988
8993
  languageId
8989
8994
  } = newState;
8990
8995
  // @ts-ignore
8991
- const allActions = await invoke$a('GetEditorSourceActions.getEditorSourceActions');
8996
+ const allActions = await invoke$b('GetEditorSourceActions.getEditorSourceActions');
8992
8997
  const filtered = filterActions(allActions, languageId);
8993
8998
  return filtered;
8994
8999
  };
@@ -9011,14 +9016,14 @@ const getWordAtOffset = editor => {
9011
9016
  };
9012
9017
 
9013
9018
  const setFocus = async focusKey => {
9014
- await invoke$a('Focus.setFocus', focusKey);
9019
+ await invoke$b('Focus.setFocus', focusKey);
9015
9020
  };
9016
9021
  const unsetAdditionalFocus = async focusKey => {
9017
9022
  if (!focusKey) {
9018
9023
  return;
9019
9024
  }
9020
9025
  // @ts-ignore
9021
- await invoke$a('Focus.removeAdditionalFocus', focusKey);
9026
+ await invoke$b('Focus.removeAdditionalFocus', focusKey);
9022
9027
  };
9023
9028
 
9024
9029
  const FocusEditor = 12;
@@ -9550,6 +9555,82 @@ const getKeys = () => {
9550
9555
  return getKeys$1();
9551
9556
  };
9552
9557
 
9558
+ /**
9559
+ * @enum {string}
9560
+ */
9561
+ const UiStrings = {
9562
+ CommandPalette: 'Command Palette'};
9563
+ const commandPalette = () => {
9564
+ return i18nString(UiStrings.CommandPalette);
9565
+ };
9566
+
9567
+ const menuEntrySeparator = {
9568
+ id: 'separator',
9569
+ label: '',
9570
+ flags: Separator,
9571
+ command: ''
9572
+ };
9573
+
9574
+ const getMenuEntries = () => {
9575
+ return [{
9576
+ id: 'go-to-definition',
9577
+ label: goToDefinition$1(),
9578
+ flags: None,
9579
+ command: 'Editor.goToDefinition'
9580
+ }, {
9581
+ id: 'go-to-type-definition',
9582
+ label: goToTypeDefinition$1(),
9583
+ flags: None,
9584
+ command: /* Editor.goToTypeDefinition */'Editor.goToTypeDefinition'
9585
+ }, menuEntrySeparator, {
9586
+ id: 'find-all-references',
9587
+ label: findAllReferences(),
9588
+ flags: None,
9589
+ command: /* ViewletSideBar.show */'SideBar.show',
9590
+ args: [/* id */'References', /* focus */true]
9591
+ }, {
9592
+ id: 'find-all-implementations',
9593
+ label: findAllImplementations(),
9594
+ flags: None,
9595
+ command: /* ViewletSideBar.show */'SideBar.show',
9596
+ args: [/* id */'Implementations', /* focus */true]
9597
+ }, menuEntrySeparator, {
9598
+ id: 'format',
9599
+ label: formatDocument(),
9600
+ flags: None,
9601
+ command: 'Editor.format'
9602
+ }, {
9603
+ id: SourceControl,
9604
+ label: sourceAction(),
9605
+ flags: None,
9606
+ command: 'Editor.showSourceActions2'
9607
+ }, menuEntrySeparator, {
9608
+ id: 'cut',
9609
+ label: cut(),
9610
+ flags: None,
9611
+ command: /* Editor.cut */'Editor.cut'
9612
+ }, {
9613
+ id: 'copy',
9614
+ label: copy(),
9615
+ flags: None,
9616
+ command: /* Editor.copy */'Editor.copy'
9617
+ }, {
9618
+ id: 'paste',
9619
+ label: paste$1(),
9620
+ flags: None,
9621
+ command: /* Editor.paste */'Editor.paste'
9622
+ }, menuEntrySeparator, {
9623
+ id: 'commandPalette',
9624
+ label: commandPalette(),
9625
+ flags: None,
9626
+ command: 'QuickPick.showEverything'
9627
+ }];
9628
+ };
9629
+
9630
+ const getMenuIds = () => {
9631
+ return [Editor$1];
9632
+ };
9633
+
9553
9634
  const getDiagnostics = editor => {
9554
9635
  return executeDiagnosticProvider(editor);
9555
9636
  };
@@ -9778,7 +9859,7 @@ const hotReload = async () => {
9778
9859
 
9779
9860
  // TODO ask renderer worker to rerender all editors
9780
9861
  // @ts-ignore
9781
- await invoke$a(`Editor.rerender`);
9862
+ await invoke$b(`Editor.rerender`);
9782
9863
  isReloading = false;
9783
9864
  };
9784
9865
 
@@ -9850,7 +9931,7 @@ const launchCompletionWorker = async () => {
9850
9931
  };
9851
9932
 
9852
9933
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
9853
- setFactory$1(launchCompletionWorker);
9934
+ setFactory(launchCompletionWorker);
9854
9935
  await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost()]);
9855
9936
  };
9856
9937
 
@@ -10317,7 +10398,7 @@ const updateDebugInfo = async debugId => {
10317
10398
  };
10318
10399
  set$6(key, oldState, newEditor);
10319
10400
  // @ts-ignore
10320
- await invoke$a('Editor.rerender', key);
10401
+ await invoke$b('Editor.rerender', key);
10321
10402
  };
10322
10403
 
10323
10404
  const keep = ['ActivateByEvent.activateByEvent', 'ExtensionHostManagement.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getSourceActions', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getOffsetAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.hotReload', 'Editor.getSelections2', 'Editor.getDiagnostics', 'Editor.getText', 'Editor.getWordAt', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getUri', 'Editor.getWordBefore', 'Editor.getWordBefore2', 'Editor.offsetAt', 'Editor.render', 'Editor.setSelections2', 'Editor.updateDebugInfo', 'Editor.getLanguageId', 'Editor.getProblems', 'Editor.getKeys', 'Font.ensure', 'HandleMessagePort.handleMessagePort', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker'
@@ -10404,9 +10485,10 @@ const commandMap = {
10404
10485
  'Editor.handleClickAtPosition': handleClickAtPosition,
10405
10486
  'Editor.applyDocumentEdits': applyDocumentEdits,
10406
10487
  'Editor.contextMenu': handleContextMenu,
10407
- 'Editor.copy': copy,
10488
+ 'Editor.copy': copy$1,
10408
10489
  'Editor.copyLineDown': copyLineDown,
10409
10490
  'Editor.copyLineUp': copyLineUp,
10491
+ 'Editor.getMenuIds': getMenuIds,
10410
10492
  'Editor.create': createEditor,
10411
10493
  'Editor.cursorCharacterLeft': cursorCharacterLeft,
10412
10494
  'Editor.cursorCharacterRight': cursorCharacterRight,
@@ -10421,7 +10503,7 @@ const commandMap = {
10421
10503
  'Editor.cursorWordPartLeft': cursorWordPartLeft,
10422
10504
  'Editor.cursorWordPartRight': cursorWordPartRight,
10423
10505
  'Editor.cursorWordRight': cursorWordRight,
10424
- 'Editor.cut': cut,
10506
+ 'Editor.cut': cut$1,
10425
10507
  'Editor.deleteAllLeft': deleteAllLeft,
10426
10508
  'Editor.deleteAllRight': deleteAllRight,
10427
10509
  'Editor.deleteCharacterLeft': deleteCharacterLeft,
@@ -10434,12 +10516,14 @@ const commandMap = {
10434
10516
  'Editor.deleteWordPartRight': deleteWordPartRight,
10435
10517
  'Editor.deleteWordRight': deleteWordRight,
10436
10518
  'Editor.executeWidgetCommand': executeWidgetCommand,
10437
- 'Editor.findAllReferences': findAllReferences,
10519
+ 'Editor.findAllReferences': findAllReferences$1,
10438
10520
  'Editor.format': format,
10439
10521
  'Editor.getKeyBindings': getKeyBindings,
10440
10522
  'Editor.getKeys': getKeys,
10441
10523
  'Editor.getLanguageId': getLanguageId,
10442
10524
  'Editor.getLines2': getLines2,
10525
+ 'Editor.getMenuEntries': getMenuEntries,
10526
+ 'Editor.getMenuEntries2': getMenuEntries,
10443
10527
  'Editor.getOffsetAtCursor': getOffsetAtCursor,
10444
10528
  'Editor.getPositionAtCursor': getPositionAtCursor,
10445
10529
  'Editor.getSourceActions': getSourceActions,
@@ -10634,12 +10718,8 @@ const createTextMeasurementWorkerRpc = async () => {
10634
10718
  }
10635
10719
  };
10636
10720
 
10637
- const {
10638
- setFactory
10639
- } = createLazyRpc(TextMeasurementWorker);
10640
-
10641
10721
  const listen = async () => {
10642
- setFactory(createTextMeasurementWorkerRpc);
10722
+ setFactory$1(createTextMeasurementWorkerRpc);
10643
10723
  const rpc = await WebWorkerRpcClient.create({
10644
10724
  commandMap: commandMap
10645
10725
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "13.3.0",
3
+ "version": "14.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"