@lvce-editor/editor-worker 1.13.0 → 1.15.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.
@@ -274,7 +274,7 @@ const applyEdits = (textDocument, changes) => {
274
274
  const getLine = (textDocument, index) => {
275
275
  return textDocument.lines[index];
276
276
  };
277
- const getText = state => {
277
+ const getText$1 = state => {
278
278
  return joinLines$2(state.lines);
279
279
  };
280
280
  const RE_WHITESPACE = /^\s+/;
@@ -2771,7 +2771,6 @@ const editorCursorHorizontalRight = (editor, getDelta) => {
2771
2771
  return scheduleSelections(editor, newSelections);
2772
2772
  };
2773
2773
 
2774
- // @ts-ignore
2775
2774
  const cursorCharacterRight = editor => {
2776
2775
  return editorCursorHorizontalRight(editor, characterRight);
2777
2776
  };
@@ -3532,7 +3531,6 @@ const Alt = 2;
3532
3531
 
3533
3532
  // TODO first change cursor position, then run go to definition
3534
3533
  // cursor should appear at mousedown position immediately
3535
- // @ts-ignore
3536
3534
  const handleSingleClickWithAlt = async (editor, position) => {
3537
3535
  const {
3538
3536
  rowIndex,
@@ -3547,8 +3545,6 @@ const handleSingleClickWithAlt = async (editor, position) => {
3547
3545
  const newEditor2 = await goToDefinition(newEditor);
3548
3546
  return newEditor2;
3549
3547
  };
3550
-
3551
- // @ts-ignore
3552
3548
  const handleSingleClickWithCtrl = async (editor, position) => {
3553
3549
  const selections = editor.selections;
3554
3550
  for (let i = 0; i < selections.length; i += 4) {
@@ -3572,8 +3568,6 @@ const handleSingleClickWithCtrl = async (editor, position) => {
3572
3568
  newSelections[insertIndex + 3] = position.columnIndex;
3573
3569
  return scheduleSelections(editor, newSelections);
3574
3570
  };
3575
-
3576
- // @ts-ignore
3577
3571
  const handleSingleClickDefault = (editor, position) => {
3578
3572
  setPosition$1(position);
3579
3573
  return {
@@ -3582,8 +3576,6 @@ const handleSingleClickDefault = (editor, position) => {
3582
3576
  focused: true
3583
3577
  };
3584
3578
  };
3585
-
3586
- // @ts-ignore
3587
3579
  const getFn = modifier => {
3588
3580
  switch (modifier) {
3589
3581
  case Alt:
@@ -3594,8 +3586,6 @@ const getFn = modifier => {
3594
3586
  return handleSingleClickDefault;
3595
3587
  }
3596
3588
  };
3597
-
3598
- // @ts-ignore
3599
3589
  const handleSingleClick = async (editor, modifier, x, y) => {
3600
3590
  object(editor);
3601
3591
  number$1(modifier);
@@ -3647,7 +3637,6 @@ const handleTripleClick = (editor, modifier, x, y) => {
3647
3637
  };
3648
3638
  };
3649
3639
 
3650
- // @ts-ignore
3651
3640
  const handleMouseDown = (state, modifier, x, y, detail) => {
3652
3641
  switch (detail) {
3653
3642
  case Single:
@@ -4468,6 +4457,25 @@ const openFind = async state => {
4468
4457
  return state;
4469
4458
  };
4470
4459
 
4460
+ const getEditor = editorUid => {
4461
+ const instance = get$6(editorUid);
4462
+ if (!instance) {
4463
+ throw new Error(`editor ${editorUid} not found`);
4464
+ }
4465
+ const {
4466
+ newState
4467
+ } = instance;
4468
+ return newState;
4469
+ };
4470
+
4471
+ const getText = editorUid => {
4472
+ const editor = getEditor(editorUid);
4473
+ const {
4474
+ lines
4475
+ } = editor;
4476
+ return lines.join('\n');
4477
+ };
4478
+
4471
4479
  const organizeImports = async editor => {
4472
4480
  // TODO ask extension host worker directly
4473
4481
  const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
@@ -4624,7 +4632,7 @@ const save = async editor => {
4624
4632
  try {
4625
4633
  const uri = editor.uri;
4626
4634
  const newEditor = await getNewEditor(editor);
4627
- const content = getText(newEditor);
4635
+ const content = getText$1(newEditor);
4628
4636
  await invoke$3('FileSystem.writeFile', uri, content);
4629
4637
  return newEditor;
4630
4638
  } catch (error) {
@@ -5181,17 +5189,6 @@ const setDecorations = (editor, decorations, diagnostics) => {
5181
5189
  };
5182
5190
  };
5183
5191
 
5184
- const getEditor = editorUid => {
5185
- const instance = get$6(editorUid);
5186
- if (!instance) {
5187
- throw new Error(`editor ${editorUid} not found`);
5188
- }
5189
- const {
5190
- newState
5191
- } = instance;
5192
- return newState;
5193
- };
5194
-
5195
5192
  /**
5196
5193
  * @enum number
5197
5194
  */
@@ -6874,6 +6871,14 @@ const ensure = async (fontName, fontUrl) => {
6874
6871
  setLoaded(fontName);
6875
6872
  };
6876
6873
 
6874
+ const getSelections = editorUid => {
6875
+ const editor = getEditor(editorUid);
6876
+ const {
6877
+ selections
6878
+ } = editor;
6879
+ return selections;
6880
+ };
6881
+
6877
6882
  const executeHoverProvider = (editor, offset) => {
6878
6883
  object(editor);
6879
6884
  number$1(offset);
@@ -7867,6 +7872,11 @@ const renderFocus = {
7867
7872
  return oldState.focused === newState.focused;
7868
7873
  },
7869
7874
  apply(oldState, newState) {
7875
+ // TODO avoid side effect
7876
+ if (newState.focused) {
7877
+ const FocusEditorText = 12;
7878
+ invoke$3('Focus.setFocus', FocusEditorText);
7879
+ }
7870
7880
  return [/* method */'setFocused', newState.focused];
7871
7881
  }
7872
7882
  };
@@ -7919,7 +7929,7 @@ const renderEditor = async id => {
7919
7929
  return commands;
7920
7930
  };
7921
7931
 
7922
- const keep = ['ColorPicker.handleSliderPointerDown', 'ColorPicker.handleSliderPointerMove', 'ColorPicker.loadContent', 'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'FindWidget.focusFirst', 'FindWidget.focusIndex', 'FindWidget.focusLast', 'FindWidget.focusNext', 'FindWidget.focusPrevious', 'FindWidget.handleInput', 'FindWidget.loadContent', 'Font.ensure', 'Hover.getHoverInfo', 'Initialize.initialize', 'EditorCompletion.advance', 'EditorCompletion.handleEditorBlur', 'EditorCompletion.handleEditorClick', 'EditorCompletion.handleEditorDeleteLeft', 'EditorCompletion.handleEditorType', 'EditorCompletion.loadContent', 'EditorCompletion.selectCurrent', 'EditorCompletion.selectIndex', 'ColorPicker.render', 'Hover.render', 'Hover.loadContent', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp'];
7932
+ const keep = ['ColorPicker.handleSliderPointerDown', 'ColorPicker.handleSliderPointerMove', 'ColorPicker.loadContent', 'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'ColorPicker.render', 'Editor.getText', 'Editor.getSelections', 'EditorCompletion.advance', 'EditorCompletion.handleEditorBlur', 'EditorCompletion.handleEditorClick', 'EditorCompletion.handleEditorDeleteLeft', 'EditorCompletion.handleEditorType', 'EditorCompletion.loadContent', 'EditorCompletion.selectCurrent', 'EditorCompletion.selectIndex', 'FindWidget.focusFirst', 'FindWidget.focusIndex', 'FindWidget.focusLast', 'FindWidget.focusNext', 'FindWidget.focusPrevious', 'FindWidget.handleInput', 'FindWidget.loadContent', 'Font.ensure', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize'];
7923
7933
 
7924
7934
  // TODO wrap commands globally, not per editor
7925
7935
  // TODO only store editor state in editor worker, not in renderer worker also
@@ -8137,9 +8147,6 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
8137
8147
  childCount: 0,
8138
8148
  onPointerDown: HandleSashPointerDown
8139
8149
  });
8140
- console.log({
8141
- dom
8142
- });
8143
8150
  return dom;
8144
8151
  };
8145
8152
 
@@ -8228,6 +8235,7 @@ const commandMap = {
8228
8235
  'Editor.findAllReferences': findAllReferences,
8229
8236
  'Editor.format': format,
8230
8237
  'Editor.getWordAt': getWordAt,
8238
+ 'Editor.getText': getText,
8231
8239
  'Editor.getWordBefore': getWordBefore,
8232
8240
  'Editor.goToDefinition': goToDefinition,
8233
8241
  'Editor.goToTypeDefinition': goToTypeDefinition,
@@ -8304,6 +8312,7 @@ const commandMap = {
8304
8312
  'Editor.typeWithAutoClosing': typeWithAutoClosing,
8305
8313
  'Editor.undo': undo,
8306
8314
  'Editor.unIndent': editorUnindent,
8315
+ 'Editor.getSelections': getSelections,
8307
8316
  'EditorCompletion.advance': advance,
8308
8317
  'EditorCompletion.handleEditorBlur': handleEditorBlur,
8309
8318
  'EditorCompletion.handleEditorClick': handleEditorClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",