@lvce-editor/editor-worker 5.16.0 → 5.18.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.
@@ -266,7 +266,7 @@ const setDeltaY$3 = (state, value) => {
266
266
 
267
267
  const splitLines$2 = lines => {
268
268
  if (!lines) {
269
- return [];
269
+ return [''];
270
270
  }
271
271
  return lines.split('\n');
272
272
  };
@@ -325,8 +325,12 @@ const applyEdits = (textDocument, changes) => {
325
325
  const endRowIndex = change.end.rowIndex + linesDelta;
326
326
  const startColumnIndex = change.start.columnIndex;
327
327
  const endColumnIndex = change.end.columnIndex;
328
- const inserted = change.inserted;
329
- const deleted = change.deleted;
328
+ const {
329
+ inserted
330
+ } = change;
331
+ const {
332
+ deleted
333
+ } = change;
330
334
  number(startRowIndex);
331
335
  number(endRowIndex);
332
336
  number(startColumnIndex);
@@ -404,7 +408,9 @@ const offsetAtSync = async (textDocument, positionRowIndex, positionColumnIndex)
404
408
  number(positionColumnIndex);
405
409
  let offset = 0;
406
410
  let rowIndex = 0;
407
- const lines = textDocument.lines;
411
+ const {
412
+ lines
413
+ } = textDocument;
408
414
  const max = Math.min(positionRowIndex, textDocument.lines.length);
409
415
  while (rowIndex < max) {
410
416
  offset += lines[rowIndex].length + 1;
@@ -419,7 +425,9 @@ const offsetAt = (textDocument, positionRowIndex, positionColumnIndex) => {
419
425
  number(positionColumnIndex);
420
426
  let offset = 0;
421
427
  let rowIndex = 0;
422
- const lines = textDocument.lines;
428
+ const {
429
+ lines
430
+ } = textDocument;
423
431
  const max = Math.min(positionRowIndex, textDocument.lines.length);
424
432
  while (rowIndex < max) {
425
433
  offset += lines[rowIndex].length + 1;
@@ -534,7 +542,9 @@ const measureTextWidthSlow = (text, fontWeight, fontSize, fontFamily, letterSpac
534
542
  ctx.letterSpacing = letterSpacingString;
535
543
  ctx.font = fontString;
536
544
  const metrics = ctx.measureText(text);
537
- const width = metrics.width;
545
+ const {
546
+ width
547
+ } = metrics;
538
548
  return width;
539
549
  };
540
550
 
@@ -2281,7 +2291,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
2281
2291
 
2282
2292
  // TODO use wrapper timing module instead of this
2283
2293
  // @ts-ignore
2284
- state$7.timeout = setTimeout(handleTimeout, 3_000);
2294
+ state$7.timeout = setTimeout(handleTimeout, 3000);
2285
2295
  }
2286
2296
  return editor;
2287
2297
  };
@@ -2348,7 +2358,9 @@ const braceCompletion = async (editor, text) => {
2348
2358
  };
2349
2359
 
2350
2360
  const cancelSelection = editor => {
2351
- const selections = editor.selections;
2361
+ const {
2362
+ selections
2363
+ } = editor;
2352
2364
  if (selections.length === 4 && selections[0] === selections[2] && selections[1] === selections[3]) {
2353
2365
  return editor;
2354
2366
  }
@@ -2598,13 +2610,17 @@ const getCompositionChanges = (selections, data) => {
2598
2610
  return changes;
2599
2611
  };
2600
2612
  const compositionUpdate = (editor, data) => {
2601
- const selections = editor.selections;
2613
+ const {
2614
+ selections
2615
+ } = editor;
2602
2616
  const changes = getCompositionChanges(selections, data);
2603
2617
  state$6.compositionText = data;
2604
2618
  return scheduleDocumentAndCursorsSelections(editor, changes);
2605
2619
  };
2606
2620
  const compositionEnd = (editor, data) => {
2607
- const selections = editor.selections;
2621
+ const {
2622
+ selections
2623
+ } = editor;
2608
2624
  const changes = getCompositionChanges(selections, data);
2609
2625
  state$6.isComposing = false;
2610
2626
  state$6.compositionText = '';
@@ -2961,8 +2977,12 @@ const cursorCharacterLeft = editor => {
2961
2977
  };
2962
2978
 
2963
2979
  const editorGetPositionRight = (position, lines, getDelta) => {
2964
- const rowIndex = position.rowIndex;
2965
- const columnIndex = position.columnIndex;
2980
+ const {
2981
+ rowIndex
2982
+ } = position;
2983
+ const {
2984
+ columnIndex
2985
+ } = position;
2966
2986
  if (columnIndex >= lines[rowIndex].length) {
2967
2987
  if (rowIndex >= lines.length) {
2968
2988
  return position;
@@ -3230,10 +3250,14 @@ const deleteAllLeft = editor => {
3230
3250
 
3231
3251
  // @ts-ignore
3232
3252
  const getChanges$4 = (editor, getDelta) => {
3233
- const selections = editor.selections;
3253
+ const {
3254
+ selections
3255
+ } = editor;
3234
3256
  if (isEverySelectionEmpty(selections)) {
3235
3257
  const changes = [];
3236
- const lines = editor.lines;
3258
+ const {
3259
+ lines
3260
+ } = editor;
3237
3261
  for (let i = 0; i < selections.length; i += 4) {
3238
3262
  // @ts-ignore
3239
3263
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
@@ -3595,7 +3619,9 @@ const goTo = async ({
3595
3619
  // Logger.warn('invalid definition result', definition)
3596
3620
  return editor;
3597
3621
  }
3598
- const uri = definition.uri;
3622
+ const {
3623
+ uri
3624
+ } = definition;
3599
3625
  if (uri === editor.uri) {
3600
3626
  // TODO set cursor to the definition position
3601
3627
  const position = positionAt(editor, definition.startOffset);
@@ -3807,7 +3833,9 @@ const handleSingleClickWithAlt = async (editor, position) => {
3807
3833
  };
3808
3834
 
3809
3835
  const handleSingleClickWithCtrl = async (editor, position) => {
3810
- const selections = editor.selections;
3836
+ const {
3837
+ selections
3838
+ } = editor;
3811
3839
  for (let i = 0; i < selections.length; i += 4) {
3812
3840
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
3813
3841
  if (selectionStartRow === position.rowIndex && selectionStartColumn === position.columnIndex && selectionEndRow === position.rowIndex && selectionEndColumn === position.columnIndex) {
@@ -3884,7 +3912,9 @@ const getNewSelections$6 = (line, rowIndex) => {
3884
3912
 
3885
3913
  // @ts-ignore
3886
3914
  const selectLine = editor => {
3887
- const selections = editor.selections;
3915
+ const {
3916
+ selections
3917
+ } = editor;
3888
3918
  const rowIndex = selections[editor.primarySelectionIndex];
3889
3919
  const line = getLine(editor, rowIndex);
3890
3920
  const newSelections = getNewSelections$6(line, rowIndex);
@@ -4380,7 +4410,9 @@ const getChanges$2 = selections => {
4380
4410
 
4381
4411
  // @ts-ignore
4382
4412
  const indentLess = editor => {
4383
- const selections = editor.selections;
4413
+ const {
4414
+ selections
4415
+ } = editor;
4384
4416
  const changes = getChanges$2(selections);
4385
4417
  return scheduleDocumentAndCursorsSelections(editor, changes);
4386
4418
  };
@@ -5324,7 +5356,7 @@ const findRegexMatches = (lines, regex) => {
5324
5356
 
5325
5357
  const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
5326
5358
  const escapeRegExpCharacters = value => {
5327
- return value.replaceAll(RE_ESCAPE, '\\$&');
5359
+ return value.replaceAll(RE_ESCAPE, String.raw`\$&`);
5328
5360
  };
5329
5361
 
5330
5362
  const regexFlags = 'gi';
@@ -5666,7 +5698,9 @@ const getRenamePosition = editor => {
5666
5698
  const height = 30;
5667
5699
  const paddingTop = 10;
5668
5700
  const cursor = getPositionAtCursor(editor);
5669
- const x = cursor.x;
5701
+ const {
5702
+ x
5703
+ } = cursor;
5670
5704
  const y = cursor.y + paddingTop;
5671
5705
  return {
5672
5706
  y,
@@ -5774,7 +5808,9 @@ const getErrorMessage$1 = error => {
5774
5808
  if (!error) {
5775
5809
  return `Error: ${error}`;
5776
5810
  }
5777
- let message = error.message;
5811
+ let {
5812
+ message
5813
+ } = error;
5778
5814
  while (error.cause) {
5779
5815
  error = error.cause;
5780
5816
  message += `: ${error}`;
@@ -5900,7 +5936,9 @@ const getNewEditor = async editor => {
5900
5936
  // @ts-ignore
5901
5937
  const save = async editor => {
5902
5938
  try {
5903
- const uri = editor.uri;
5939
+ const {
5940
+ uri
5941
+ } = editor;
5904
5942
  const newEditor = await getNewEditor(editor);
5905
5943
  const content = getText$1(newEditor);
5906
5944
  await invoke$3('FileSystem.writeFile', uri, content);
@@ -5917,7 +5955,9 @@ const save = async editor => {
5917
5955
 
5918
5956
  // @ts-ignore
5919
5957
  const selectAll = editor => {
5920
- const lines = editor.lines;
5958
+ const {
5959
+ lines
5960
+ } = editor;
5921
5961
  const startRowIndex = 0;
5922
5962
  const startColumnIndex = 0;
5923
5963
  const endRowIndex = lines.length - 1;
@@ -6114,8 +6154,12 @@ const getNewSelections$2 = (selections, lines, getDelta) => {
6114
6154
 
6115
6155
  // @ts-ignore
6116
6156
  const editorSelectHorizontalRight = (editor, getDelta) => {
6117
- const lines = editor.lines;
6118
- const selections = editor.selections;
6157
+ const {
6158
+ lines
6159
+ } = editor;
6160
+ const {
6161
+ selections
6162
+ } = editor;
6119
6163
  const newSelections = getNewSelections$2(selections, lines, getDelta);
6120
6164
  return scheduleSelections(editor, newSelections);
6121
6165
  };
@@ -6190,8 +6234,12 @@ const getNewSelections$1 = (lines, selections) => {
6190
6234
  return newSelections;
6191
6235
  };
6192
6236
  const selectInsideString = editor => {
6193
- const selections = editor.selections;
6194
- const lines = editor.lines;
6237
+ const {
6238
+ selections
6239
+ } = editor;
6240
+ const {
6241
+ lines
6242
+ } = editor;
6195
6243
  const newSelections = getNewSelections$1(lines, selections);
6196
6244
  return scheduleSelections(editor, newSelections);
6197
6245
  };
@@ -6312,8 +6360,12 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
6312
6360
  return undefined;
6313
6361
  };
6314
6362
  const getSelectNextOccurrenceResult = editor => {
6315
- const lines = editor.lines;
6316
- const selections = editor.selections;
6363
+ const {
6364
+ lines
6365
+ } = editor;
6366
+ const {
6367
+ selections
6368
+ } = editor;
6317
6369
  if (isEverySelectionEmpty(selections)) {
6318
6370
  const newSelections = new Uint32Array(selections.length);
6319
6371
  for (let i = 0; i < selections.length; i += 4) {
@@ -6372,8 +6424,12 @@ const selectNextOccurrence = editor => {
6372
6424
  if (!result) {
6373
6425
  return editor;
6374
6426
  }
6375
- const revealRange = result.revealRange;
6376
- const selectionEdits = result.selectionEdits;
6427
+ const {
6428
+ revealRange
6429
+ } = result;
6430
+ const {
6431
+ selectionEdits
6432
+ } = result;
6377
6433
  const revealRangeStartRowIndex = selectionEdits[revealRange];
6378
6434
  const revealRangeEndRowIndex = selectionEdits[revealRange + 2];
6379
6435
  if (isRangeInViewPort(editor.minLineY, editor.maxLineY, revealRangeStartRowIndex, revealRangeEndRowIndex)) {
@@ -6916,8 +6972,12 @@ const getSourceActionWidgetPosition = (editor, sourceActionCount) => {
6916
6972
  const width = 300;
6917
6973
  const height = getHeight(sourceActionCount);
6918
6974
  const cursor = getPositionAtCursor(editor);
6919
- const x = cursor.x;
6920
- const y = cursor.y;
6975
+ const {
6976
+ x
6977
+ } = cursor;
6978
+ const {
6979
+ y
6980
+ } = cursor;
6921
6981
  // TODO support virtual list
6922
6982
  return {
6923
6983
  x,
@@ -9395,7 +9455,9 @@ const getLineInfoDefault = (line, tokenResults, embeddedResults, decorations, To
9395
9455
  break;
9396
9456
  }
9397
9457
  }
9398
- const tokens = tokenResults.tokens;
9458
+ const {
9459
+ tokens
9460
+ } = tokenResults;
9399
9461
  let {
9400
9462
  startIndex,
9401
9463
  start,
@@ -9614,8 +9676,12 @@ const getIncrementalEdits = async (oldState, newState) => {
9614
9676
  if (lastChanges && lastChanges.length === 1) {
9615
9677
  const lastChange = lastChanges[0];
9616
9678
  if (lastChange.origin === EditorType) {
9617
- const rowIndex = lastChange.start.rowIndex;
9618
- const lines = newState.lines;
9679
+ const {
9680
+ rowIndex
9681
+ } = lastChange.start;
9682
+ const {
9683
+ lines
9684
+ } = newState;
9619
9685
  const oldLine = oldState.lines[rowIndex];
9620
9686
  const newLine = lines[rowIndex];
9621
9687
  const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid, newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
@@ -10606,7 +10672,9 @@ const addWidget = (widget, id, render) => {
10606
10672
  // TODO how to generate a unique integer id
10607
10673
  // that doesn't collide with ids created in renderer worker?
10608
10674
  // @ts-ignore
10609
- const uid = widget.newState.uid;
10675
+ const {
10676
+ uid
10677
+ } = widget.newState;
10610
10678
  const allCommands = [];
10611
10679
  allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
10612
10680
  allCommands.push(...commands);
@@ -10700,7 +10768,9 @@ const renderFull$3 = (oldState, newState) => {
10700
10768
  const render$d = widget => {
10701
10769
  const commands = renderFull$3(widget.oldState, widget.newState);
10702
10770
  const wrappedCommands = [];
10703
- const uid = widget.newState.uid;
10771
+ const {
10772
+ uid
10773
+ } = widget.newState;
10704
10774
  for (const command of commands) {
10705
10775
  if (command[0] === SetDom2) {
10706
10776
  wrappedCommands.push(command);
@@ -10809,7 +10879,9 @@ const renderFull$2 = (oldState, newState) => {
10809
10879
  const render$b = widget => {
10810
10880
  const commands = renderFull$2(widget.oldState, widget.newState);
10811
10881
  const wrappedCommands = [];
10812
- const uid = widget.newState.uid;
10882
+ const {
10883
+ uid
10884
+ } = widget.newState;
10813
10885
  for (const command of commands) {
10814
10886
  if (command[0] === SetDom2) {
10815
10887
  wrappedCommands.push(command);
@@ -10899,7 +10971,9 @@ const renderFull$1 = (oldState, newState) => {
10899
10971
  const render$9 = widget => {
10900
10972
  const commands = renderFull$1(widget.oldState, widget.newState);
10901
10973
  const wrappedCommands = [];
10902
- const uid = widget.newState.uid;
10974
+ const {
10975
+ uid
10976
+ } = widget.newState;
10903
10977
  for (const command of commands) {
10904
10978
  if (command[0] === SetDom2) {
10905
10979
  wrappedCommands.push(command);
@@ -11213,7 +11287,9 @@ const renderCompletion = (oldState, newState) => {
11213
11287
  const render$7 = widget => {
11214
11288
  const commands = renderCompletion(widget.oldState, widget.newState);
11215
11289
  const wrappedCommands = [];
11216
- const uid = widget.newState.uid;
11290
+ const {
11291
+ uid
11292
+ } = widget.newState;
11217
11293
  for (const command of commands) {
11218
11294
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
11219
11295
  }
@@ -11224,7 +11300,9 @@ const add$4 = widget => {
11224
11300
  const id = 'EditorCompletion';
11225
11301
  // TODO how to generate a unique integer id
11226
11302
  // that doesn't collide with ids created in renderer worker?
11227
- const uid = widget.newState.uid;
11303
+ const {
11304
+ uid
11305
+ } = widget.newState;
11228
11306
  const allCommands = [];
11229
11307
  allCommands.push(['Viewlet.create', id, uid]);
11230
11308
  allCommands.push(...commands);
@@ -11692,7 +11770,9 @@ const apply = (oldState, newState) => {
11692
11770
  const render$5 = widget => {
11693
11771
  const commands = apply(widget.oldState, widget.newState);
11694
11772
  const wrappedCommands = [];
11695
- const uid = widget.newState.uid;
11773
+ const {
11774
+ uid
11775
+ } = widget.newState;
11696
11776
  for (const command of commands) {
11697
11777
  if (command[0] === SetDom2) {
11698
11778
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
@@ -11728,7 +11808,9 @@ const EditorFindWidget = {
11728
11808
  const render$4 = widget => {
11729
11809
  const commands = renderHover(widget.oldState, widget.newState);
11730
11810
  const wrappedCommands = [];
11731
- const uid = widget.newState.uid;
11811
+ const {
11812
+ uid
11813
+ } = widget.newState;
11732
11814
  for (const command of commands) {
11733
11815
  if (command[0] === SetDom2) {
11734
11816
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
@@ -11803,7 +11885,9 @@ const renderFull = (oldState, newState) => {
11803
11885
  const render$2 = widget => {
11804
11886
  const commands = renderFull(widget.oldState, widget.newState);
11805
11887
  const wrappedCommands = [];
11806
- const uid = widget.newState.uid;
11888
+ const {
11889
+ uid
11890
+ } = widget.newState;
11807
11891
  for (const command of commands) {
11808
11892
  if (command[0] === SetDom2) {
11809
11893
  wrappedCommands.push(command);
@@ -11939,7 +12023,9 @@ const doRender = (oldState, newState) => {
11939
12023
  const render = widget => {
11940
12024
  const commands = doRender(widget.oldState, widget.newState);
11941
12025
  const wrappedCommands = [];
11942
- const uid = widget.newState.uid;
12026
+ const {
12027
+ uid
12028
+ } = widget.newState;
11943
12029
  for (const command of commands) {
11944
12030
  if (command[0] === SetDom2) {
11945
12031
  wrappedCommands.push(command);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.16.0",
3
+ "version": "5.18.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",