@lvce-editor/editor-worker 7.20.0 → 8.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.
@@ -2506,6 +2506,49 @@ const addCursorBelow = editor => {
2506
2506
  };
2507
2507
  };
2508
2508
 
2509
+ const getDocumentEdits = (editor, edits) => {
2510
+ const documentEdits = [];
2511
+ for (const edit of edits) {
2512
+ const start = positionAt(editor, edit.startOffset);
2513
+ const end = positionAt(editor, edit.endOffset);
2514
+ const deleted = getSelectionText(editor, {
2515
+ start,
2516
+ end
2517
+ });
2518
+ const documentEdit = {
2519
+ start,
2520
+ end,
2521
+ inserted: splitLines(edit.inserted),
2522
+ deleted,
2523
+ origin: Format
2524
+ };
2525
+ if (documentEdit.inserted.length === 0) {
2526
+ documentEdit.inserted = [''];
2527
+ }
2528
+ documentEdits.push(documentEdit);
2529
+ }
2530
+ return documentEdits;
2531
+ };
2532
+
2533
+ const warn = (...args) => {
2534
+ console.warn(...args);
2535
+ };
2536
+ const error = (...args) => {
2537
+ console.error(...args);
2538
+ };
2539
+
2540
+ const applyDocumentEdits = (editor, edits) => {
2541
+ if (!Array.isArray(edits)) {
2542
+ warn('something is wrong with format on save', edits);
2543
+ return editor;
2544
+ }
2545
+ if (edits.length === 0) {
2546
+ return editor;
2547
+ }
2548
+ const documentEdits = getDocumentEdits(editor, edits);
2549
+ return scheduleDocumentAndCursorsSelections(editor, documentEdits);
2550
+ };
2551
+
2509
2552
  const applyEdit = async (editor, changes) => {
2510
2553
  object(editor);
2511
2554
  array(changes);
@@ -3808,49 +3851,6 @@ const isFormattingError = error => {
3808
3851
  return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
3809
3852
  };
3810
3853
 
3811
- const getDocumentEdits = (editor, edits) => {
3812
- const documentEdits = [];
3813
- for (const edit of edits) {
3814
- const start = positionAt(editor, edit.startOffset);
3815
- const end = positionAt(editor, edit.endOffset);
3816
- const deleted = getSelectionText(editor, {
3817
- start,
3818
- end
3819
- });
3820
- const documentEdit = {
3821
- start,
3822
- end,
3823
- inserted: splitLines(edit.inserted),
3824
- deleted,
3825
- origin: Format
3826
- };
3827
- if (documentEdit.inserted.length === 0) {
3828
- documentEdit.inserted = [''];
3829
- }
3830
- documentEdits.push(documentEdit);
3831
- }
3832
- return documentEdits;
3833
- };
3834
-
3835
- const warn = (...args) => {
3836
- console.warn(...args);
3837
- };
3838
- const error = (...args) => {
3839
- console.error(...args);
3840
- };
3841
-
3842
- const applyDocumentEdits = (editor, edits) => {
3843
- if (!Array.isArray(edits)) {
3844
- warn('something is wrong with format on save', edits);
3845
- return editor;
3846
- }
3847
- if (edits.length === 0) {
3848
- return editor;
3849
- }
3850
- const documentEdits = getDocumentEdits(editor, edits);
3851
- return scheduleDocumentAndCursorsSelections(editor, documentEdits);
3852
- };
3853
-
3854
3854
  const expectedErrorMessage = 'Failed to execute formatting provider: FormattingError:';
3855
3855
 
3856
3856
  // TODO also format with cursor
@@ -3957,7 +3957,6 @@ const EscapeToClose = 'Escape to close';
3957
3957
  const FormatDocument = 'Format Document';
3958
3958
  const MoveLineDown = 'Move Line Down';
3959
3959
  const MoveLineUp = 'Move Line Up';
3960
- const NoCodeActionsAvailable = 'No code actions available';
3961
3960
  const NoDefinitionFound = 'No definition found';
3962
3961
  const NoDefinitionFoundFor = "No definition found for '{PH1}'";
3963
3962
  const NoTypeDefinitionFound = 'No type definition found';
@@ -3984,9 +3983,6 @@ const noTypeDefinitionFound = () => {
3984
3983
  const sourceAction = () => {
3985
3984
  return i18nString(SourceAction);
3986
3985
  };
3987
- const noCodeActionsAvailable = () => {
3988
- return i18nString(NoCodeActionsAvailable);
3989
- };
3990
3986
  const escapeToClose = () => {
3991
3987
  return i18nString(EscapeToClose);
3992
3988
  };
@@ -6637,61 +6633,6 @@ const showHover = async state => {
6637
6633
  return state;
6638
6634
  };
6639
6635
 
6640
- // TODO ask extension host worker instead
6641
- const getEditorSourceActions = async () => {
6642
- // @ts-ignore
6643
- const sourceActions = await invoke$8('GetEditorSourceActions.getEditorSourceActions');
6644
- return sourceActions;
6645
- };
6646
-
6647
- const getHeight = sourceActionCount => {
6648
- if (sourceActionCount === 0) {
6649
- return 45;
6650
- }
6651
- return 150;
6652
- };
6653
- const getSourceActionWidgetPosition = (editor, sourceActionCount) => {
6654
- const width = 300;
6655
- const height = getHeight(sourceActionCount);
6656
- const cursor = getPositionAtCursor$1(editor);
6657
- const {
6658
- x
6659
- } = cursor;
6660
- const {
6661
- y
6662
- } = cursor;
6663
- // TODO support virtual list
6664
- return {
6665
- x,
6666
- y,
6667
- width,
6668
- height
6669
- };
6670
- };
6671
-
6672
- const loadSourceActions = async (editor, state) => {
6673
- // const editor = GetEditor.getEditor(editorUid)
6674
- // TODO request source actions information from extensions
6675
- const sourceActions = await getEditorSourceActions();
6676
- // TODO avoid side effect
6677
- const {
6678
- x,
6679
- y,
6680
- width,
6681
- height
6682
- } = getSourceActionWidgetPosition(editor, sourceActions.length);
6683
- return {
6684
- ...state,
6685
- sourceActions,
6686
- x,
6687
- y,
6688
- width,
6689
- height,
6690
- maxHeight: 150,
6691
- focusedIndex: 0
6692
- };
6693
- };
6694
-
6695
6636
  const create = () => {
6696
6637
  const completionUid = create$7();
6697
6638
  const widget = {
@@ -6722,13 +6663,6 @@ const create = () => {
6722
6663
  return widget;
6723
6664
  };
6724
6665
 
6725
- const showSourceActions$1 = async editor => {
6726
- const newStateGenerator = async state => {
6727
- return loadSourceActions(editor, state);
6728
- };
6729
- return addWidgetToEditor(SourceAction$1, SourceActions, editor, create, newStateGenerator);
6730
- };
6731
-
6732
6666
  const launchSourceActionWorker = async () => {
6733
6667
  const name = 'Source Action Worker';
6734
6668
  const url = 'sourceActionWorkerMain.js';
@@ -7572,6 +7506,7 @@ const isFunctional = widgetId => {
7572
7506
  case Rename:
7573
7507
  case Completion:
7574
7508
  case Find:
7509
+ case SourceAction$1:
7575
7510
  return true;
7576
7511
  default:
7577
7512
  return false;
@@ -7702,7 +7637,7 @@ const renderFull$4 = (oldState, newState) => {
7702
7637
  return commands;
7703
7638
  };
7704
7639
 
7705
- const render$c = widget => {
7640
+ const render$b = widget => {
7706
7641
  const commands = renderFull$4(widget.oldState, widget.newState);
7707
7642
  const wrappedCommands = [];
7708
7643
  const {
@@ -7718,51 +7653,51 @@ const render$c = widget => {
7718
7653
  return wrappedCommands;
7719
7654
  };
7720
7655
  const add$7 = widget => {
7721
- return addWidget$1(widget, 'EditorCompletion', render$c);
7656
+ return addWidget$1(widget, 'EditorCompletion', render$b);
7722
7657
  };
7723
7658
  const remove$7 = widget => {
7724
7659
  return [['Viewlet.dispose', widget.newState.uid]];
7725
7660
  };
7726
7661
  const {
7727
- focusFirst,
7728
- focusIndex: focusIndex$1,
7729
- focusLast,
7730
- focusNext: focusNext$2,
7731
- focusPrevious: focusPrevious$1,
7662
+ focusFirst: focusFirst$1,
7663
+ focusIndex: focusIndex$2,
7664
+ focusLast: focusLast$1,
7665
+ focusNext: focusNext$3,
7666
+ focusPrevious: focusPrevious$2,
7732
7667
  handleEditorBlur,
7733
7668
  handleEditorClick,
7734
7669
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
7735
7670
  handleEditorType: handleEditorType$1,
7736
7671
  openDetails,
7737
- selectCurrent,
7738
- selectIndex,
7739
- toggleDetails,
7740
- closeDetails,
7741
- handleWheel,
7742
- close: close$2
7672
+ selectCurrent: selectCurrent$1,
7673
+ selectIndex: selectIndex$1,
7674
+ toggleDetails: toggleDetails$1,
7675
+ closeDetails: closeDetails$1,
7676
+ handleWheel: handleWheel$1,
7677
+ close: close$3
7743
7678
  } = createFns(['handleEditorType', 'focusFirst', 'focusNext', 'focusPrevious', 'focusLast', 'handleEditorDeleteLeft', 'openDetails', 'focusIndex', 'handleEditorBlur', 'handleEditorClick', 'openDetails', 'selectCurrent', 'selectIndex', 'toggleDetails', 'closeDetails', 'handleWheel', 'close'], 'Completions', Completion);
7744
7679
 
7745
7680
  const EditorCompletionWidget = {
7746
7681
  __proto__: null,
7747
7682
  add: add$7,
7748
- close: close$2,
7749
- closeDetails,
7750
- focusFirst,
7751
- focusIndex: focusIndex$1,
7752
- focusLast,
7753
- focusNext: focusNext$2,
7754
- focusPrevious: focusPrevious$1,
7683
+ close: close$3,
7684
+ closeDetails: closeDetails$1,
7685
+ focusFirst: focusFirst$1,
7686
+ focusIndex: focusIndex$2,
7687
+ focusLast: focusLast$1,
7688
+ focusNext: focusNext$3,
7689
+ focusPrevious: focusPrevious$2,
7755
7690
  handleEditorBlur,
7756
7691
  handleEditorClick,
7757
7692
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
7758
7693
  handleEditorType: handleEditorType$1,
7759
- handleWheel,
7694
+ handleWheel: handleWheel$1,
7760
7695
  openDetails,
7761
7696
  remove: remove$7,
7762
- render: render$c,
7763
- selectCurrent,
7764
- selectIndex,
7765
- toggleDetails
7697
+ render: render$b,
7698
+ selectCurrent: selectCurrent$1,
7699
+ selectIndex: selectIndex$1,
7700
+ toggleDetails: toggleDetails$1
7766
7701
  };
7767
7702
 
7768
7703
  const renderFull$3 = (oldState, newState) => {
@@ -7772,7 +7707,7 @@ const renderFull$3 = (oldState, newState) => {
7772
7707
  return commands;
7773
7708
  };
7774
7709
 
7775
- const render$b = widget => {
7710
+ const render$a = widget => {
7776
7711
  const commands = renderFull$3(widget.oldState, widget.newState);
7777
7712
  const wrappedCommands = [];
7778
7713
  const {
@@ -7788,18 +7723,18 @@ const render$b = widget => {
7788
7723
  return wrappedCommands;
7789
7724
  };
7790
7725
  const add$6 = widget => {
7791
- return addWidget$1(widget, 'FindWidget', render$b);
7726
+ return addWidget$1(widget, 'FindWidget', render$a);
7792
7727
  };
7793
7728
  const remove$6 = widget => {
7794
7729
  return [['Viewlet.dispose', widget.newState.uid]];
7795
7730
  };
7796
7731
  const {
7797
- close: close$1,
7732
+ close: close$2,
7798
7733
  focusCloseButton,
7799
7734
  focusFind,
7800
- focusNext: focusNext$1,
7735
+ focusNext: focusNext$2,
7801
7736
  focusNextMatchButton,
7802
- focusPrevious,
7737
+ focusPrevious: focusPrevious$1,
7803
7738
  focusPreviousMatchButton,
7804
7739
  focusReplace,
7805
7740
  focusReplaceAllButton,
@@ -7817,12 +7752,12 @@ const {
7817
7752
  const EditorFindWidget = {
7818
7753
  __proto__: null,
7819
7754
  add: add$6,
7820
- close: close$1,
7755
+ close: close$2,
7821
7756
  focusCloseButton,
7822
7757
  focusFind,
7823
- focusNext: focusNext$1,
7758
+ focusNext: focusNext$2,
7824
7759
  focusNextMatchButton,
7825
- focusPrevious,
7760
+ focusPrevious: focusPrevious$1,
7826
7761
  focusPreviousMatchButton,
7827
7762
  focusReplace,
7828
7763
  focusReplaceAllButton,
@@ -7835,7 +7770,7 @@ const EditorFindWidget = {
7835
7770
  handleReplaceInput,
7836
7771
  handleToggleReplaceFocus,
7837
7772
  remove: remove$6,
7838
- render: render$b,
7773
+ render: render$a,
7839
7774
  toggleReplace
7840
7775
  };
7841
7776
 
@@ -7890,8 +7825,6 @@ const EditorCursor = 'EditorCursor';
7890
7825
  const EditorRow = 'EditorRow';
7891
7826
  const EditorRowHighlighted = 'EditorRowHighlighted';
7892
7827
  const EditorSelection = 'EditorSelection';
7893
- const EditorSourceActions = 'EditorSourceActions';
7894
- const EditorSourceActionsList = 'EditorSourceActionsList';
7895
7828
  const HoverDisplayString = 'HoverDisplayString';
7896
7829
  const HoverDocumentation = 'HoverDocumentation';
7897
7830
  const HoverEditorRow = 'HoverEditorRow';
@@ -7901,16 +7834,10 @@ const HoverProblemMessage = 'HoverProblemMessage';
7901
7834
  const IconClose = 'IconClose';
7902
7835
  const InputBox = 'InputBox';
7903
7836
  const MaskIcon = 'MaskIcon';
7904
- const MaskIconSymbolFile = 'MaskIconSymbolFile';
7905
- const SourceActionHeading = 'SourceActionHeading';
7906
- const SourceActionIcon = 'SourceActionIcon';
7907
- const SourceActionItem = 'SourceActionItem';
7908
- const SourceActionItemFocused = 'SourceActionItemFocused';
7909
7837
  const Viewlet = 'Viewlet';
7910
7838
 
7911
7839
  const HandleBeforeInput = 'handleBeforeInput';
7912
7840
  const HandleBlur = 'handleBlur';
7913
- const HandleClick = 'handleClick';
7914
7841
  const HandleClose = 'handleClose';
7915
7842
  const HandleCompositionEnd = 'handleCompositionEnd';
7916
7843
  const HandleCompositionStart = 'handleCompositionStart';
@@ -7918,7 +7845,6 @@ const HandleCompositionUpdate = 'handleCompositionUpdate';
7918
7845
  const HandleContextMenu = 'handleContextMenu';
7919
7846
  const HandleCut = 'handleCut';
7920
7847
  const HandleFocus = 'handleFocus';
7921
- const HandleFocusIn = 'handleFocusIn';
7922
7848
  const HandleMouseMove = 'handleMouseMove';
7923
7849
  const HandleSashPointerDown = 'handleSashPointerDown';
7924
7850
  const HandleWheel = 'handleWheel';
@@ -8021,7 +7947,7 @@ const renderHoverDom = {
8021
7947
  return [/* method */SetDom2, dom];
8022
7948
  }
8023
7949
  };
8024
- const renderBounds$3 = {
7950
+ const renderBounds$2 = {
8025
7951
  isEqual(oldState, newState) {
8026
7952
  return oldState.x === newState.x && oldState.y === newState.y;
8027
7953
  },
@@ -8035,10 +7961,10 @@ const renderBounds$3 = {
8035
7961
  return [SetBounds, x, y, width, height];
8036
7962
  }
8037
7963
  };
8038
- const render$a = [renderHoverDom, renderBounds$3];
7964
+ const render$9 = [renderHoverDom, renderBounds$2];
8039
7965
  const renderHover = (oldState, newState) => {
8040
7966
  const commands = [];
8041
- for (const item of render$a) {
7967
+ for (const item of render$9) {
8042
7968
  if (!item.isEqual(oldState, newState)) {
8043
7969
  commands.push(item.apply(oldState, newState));
8044
7970
  }
@@ -8046,7 +7972,7 @@ const renderHover = (oldState, newState) => {
8046
7972
  return commands;
8047
7973
  };
8048
7974
 
8049
- const render$9 = widget => {
7975
+ const render$8 = widget => {
8050
7976
  const commands = renderFull$4(widget.oldState, widget.newState);
8051
7977
  const wrappedCommands = [];
8052
7978
  const {
@@ -8062,14 +7988,14 @@ const render$9 = widget => {
8062
7988
  return wrappedCommands;
8063
7989
  };
8064
7990
  const add$5 = widget => {
8065
- return addWidget$1(widget, 'EditorRename', render$9);
7991
+ return addWidget$1(widget, 'EditorRename', render$8);
8066
7992
  };
8067
7993
  const remove$5 = widget => {
8068
7994
  return [['Viewlet.dispose', widget.newState.uid]];
8069
7995
  };
8070
7996
  const {
8071
7997
  handleInput,
8072
- close,
7998
+ close: close$1,
8073
7999
  accept
8074
8000
  } = createFns(['handleInput', 'close', 'accept'], 'Rename', Rename);
8075
8001
 
@@ -8077,10 +8003,10 @@ const EditorRenameWidget = {
8077
8003
  __proto__: null,
8078
8004
  accept,
8079
8005
  add: add$5,
8080
- close,
8006
+ close: close$1,
8081
8007
  handleInput,
8082
8008
  remove: remove$5,
8083
- render: render$9
8009
+ render: render$8
8084
8010
  };
8085
8011
 
8086
8012
  const rerender = editor => {
@@ -8088,7 +8014,7 @@ const rerender = editor => {
8088
8014
  return structuredClone(editor);
8089
8015
  };
8090
8016
 
8091
- const focusIndex = (state, index) => {
8017
+ const focusIndex$1 = (state, index) => {
8092
8018
  const newState = {
8093
8019
  ...state,
8094
8020
  focusedIndex: index
@@ -8096,9 +8022,67 @@ const focusIndex = (state, index) => {
8096
8022
  return newState;
8097
8023
  };
8098
8024
 
8099
- const focusNext = state => {
8025
+ const focusNext$1 = state => {
8100
8026
  const nextIndex = state.focusedIndex + 1;
8101
- return focusIndex(state, nextIndex);
8027
+ return focusIndex$1(state, nextIndex);
8028
+ };
8029
+
8030
+ const removeWidget$1 = widget => {
8031
+ // @ts-ignore
8032
+ return [['Viewlet.send', widget.newState.uid, 'dispose']];
8033
+ };
8034
+
8035
+ const render$7 = widget => {
8036
+ const commands = renderFull$4(widget.oldState, widget.newState);
8037
+ const wrappedCommands = [];
8038
+ const {
8039
+ uid
8040
+ } = widget.newState;
8041
+ for (const command of commands) {
8042
+ if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
8043
+ wrappedCommands.push(command);
8044
+ } else {
8045
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
8046
+ }
8047
+ }
8048
+ return wrappedCommands;
8049
+ };
8050
+ const add$4 = widget => {
8051
+ return addWidget$1(widget, 'EditorSourceActions', render$7);
8052
+ };
8053
+ const remove$4 = removeWidget$1;
8054
+ const {
8055
+ focusFirst,
8056
+ focusIndex,
8057
+ focusLast,
8058
+ focusNext,
8059
+ focusPrevious,
8060
+ selectCurrent,
8061
+ selectIndex,
8062
+ selectItem,
8063
+ toggleDetails,
8064
+ closeDetails,
8065
+ handleWheel,
8066
+ close
8067
+ } = createFns(['focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'selectCurrent', 'selectIndex', 'selectItem', 'toggleDetails', 'closeDetails', 'handleWheel', 'close'], 'SourceActions', SourceAction$1);
8068
+
8069
+ const EditorSourceActionWidget = {
8070
+ __proto__: null,
8071
+ add: add$4,
8072
+ close,
8073
+ closeDetails,
8074
+ focusFirst,
8075
+ focusIndex,
8076
+ focusLast,
8077
+ focusNext,
8078
+ focusPrevious,
8079
+ handleWheel,
8080
+ remove: remove$4,
8081
+ render: render$7,
8082
+ selectCurrent,
8083
+ selectIndex,
8084
+ selectItem,
8085
+ toggleDetails
8102
8086
  };
8103
8087
 
8104
8088
  const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
@@ -8136,6 +8120,27 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
8136
8120
  return newEditor;
8137
8121
  };
8138
8122
 
8123
+ const filterActions = (sourceActions, languageId) => {
8124
+ return sourceActions.filter(action => action.languageId === languageId);
8125
+ };
8126
+
8127
+ // TODO ask extension host worker instead
8128
+ const getEditorSourceActions = async editorId => {
8129
+ if (!editorId) {
8130
+ return [];
8131
+ }
8132
+ const {
8133
+ newState
8134
+ } = get$4(editorId);
8135
+ const {
8136
+ languageId
8137
+ } = newState;
8138
+ // @ts-ignore
8139
+ const allActions = await invoke$8('GetEditorSourceActions.getEditorSourceActions');
8140
+ const filtered = filterActions(allActions, languageId);
8141
+ return filtered;
8142
+ };
8143
+
8139
8144
  const RE_WORD = /[\w\-]+$/;
8140
8145
  const getWordAtOffset = editor => {
8141
8146
  const {
@@ -8253,6 +8258,10 @@ const applyEdits2 = async (editorUid, edits) => {
8253
8258
  const newEditor = await applyEdit(editor, edits);
8254
8259
  set$6(editorUid, editor, newEditor);
8255
8260
  };
8261
+ const getSourceActions = async editorUid => {
8262
+ const actions = await getEditorSourceActions(editorUid);
8263
+ return actions;
8264
+ };
8256
8265
 
8257
8266
  const pending = Object.create(null);
8258
8267
  const loaded = Object.create(null);
@@ -8507,7 +8516,7 @@ const getKeyBindings = () => {
8507
8516
  when: FocusEditorText
8508
8517
  }, {
8509
8518
  key: CtrlCmd | Period,
8510
- command: 'Editor.showSourceActions2',
8519
+ command: 'Editor.showSourceActions3',
8511
8520
  when: FocusEditorText
8512
8521
  }, {
8513
8522
  key: Tab,
@@ -9634,7 +9643,7 @@ const renderWidget = widget => {
9634
9643
  }
9635
9644
  return module.render(widget);
9636
9645
  };
9637
- const removeWidget$1 = widget => {
9646
+ const removeWidget = widget => {
9638
9647
  const module = get$5(widget.id);
9639
9648
  if (!module) {
9640
9649
  throw new Error('unsupported widget');
@@ -9789,7 +9798,7 @@ const renderWidgets = {
9789
9798
  }
9790
9799
  const removeCommands = [];
9791
9800
  for (const removedWidget of removedWidgets) {
9792
- const childCommands = removeWidget$1(removedWidget);
9801
+ const childCommands = removeWidget(removedWidget);
9793
9802
  if (childCommands.length > 0) {
9794
9803
  removeCommands.push(...childCommands);
9795
9804
  }
@@ -9799,7 +9808,7 @@ const renderWidgets = {
9799
9808
  },
9800
9809
  multiple: true
9801
9810
  };
9802
- const render$8 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9811
+ const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9803
9812
  const renderEditor = async id => {
9804
9813
  const instance = get$4(id);
9805
9814
  if (!instance) {
@@ -9811,7 +9820,7 @@ const renderEditor = async id => {
9811
9820
  } = instance;
9812
9821
  const commands = [];
9813
9822
  set$6(id, newState, newState);
9814
- for (const item of render$8) {
9823
+ for (const item of render$6) {
9815
9824
  if (!item.isEqual(oldState, newState)) {
9816
9825
  const result = await item.apply(oldState, newState);
9817
9826
  // @ts-ignore
@@ -9911,7 +9920,7 @@ const editorDiagnosticEffect = {
9911
9920
  }
9912
9921
  };
9913
9922
 
9914
- const keep = ['ActivateByEvent.activateByEvent', 'ExtensionHostManagement.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getOffsetAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.getSelections2', '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'
9923
+ 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.getSelections2', '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'
9915
9924
  // 'ColorPicker.handleSliderPointerDown',
9916
9925
  // 'ColorPicker.handleSliderPointerMove',
9917
9926
  // 'ColorPicker.loadContent',
@@ -10019,6 +10028,7 @@ const commandMap = {
10019
10028
  'Editor.compositionEnd': compositionEnd,
10020
10029
  'Editor.compositionStart': compositionStart,
10021
10030
  'Editor.compositionUpdate': compositionUpdate,
10031
+ 'Editor.applyDocumentEdits': applyDocumentEdits,
10022
10032
  'Editor.contextMenu': handleContextMenu,
10023
10033
  'Editor.copy': copy,
10024
10034
  'Editor.copyLineDown': copyLineDown,
@@ -10058,6 +10068,7 @@ const commandMap = {
10058
10068
  'Editor.getLines2': getLines2,
10059
10069
  'Editor.getOffsetAtCursor': getOffsetAtCursor,
10060
10070
  'Editor.getPositionAtCursor': getPositionAtCursor,
10071
+ 'Editor.getSourceActions': getSourceActions,
10061
10072
  'Editor.getProblems': getProblems,
10062
10073
  'Editor.getQuickPickMenuEntries': getQuickPickMenuEntries,
10063
10074
  'Editor.getSelections': getSelections,
@@ -10145,8 +10156,8 @@ const commandMap = {
10145
10156
  'Editor.setSelections2': setSelections2,
10146
10157
  'Editor.showHover': showHover,
10147
10158
  'Editor.showHover2': showHover2,
10148
- 'Editor.showSourceActions': showSourceActions$1,
10149
- 'Editor.showSourceActions2': showSourceActions$1,
10159
+ 'Editor.showSourceActions': showSourceActions,
10160
+ 'Editor.showSourceActions2': showSourceActions,
10150
10161
  'Editor.showSourceActions3': showSourceActions,
10151
10162
  'Editor.sortLinesAscending': sortLinesAscending,
10152
10163
  'Editor.tabCompletion': tabCompletion,
@@ -10159,31 +10170,42 @@ const commandMap = {
10159
10170
  'Editor.unIndent': editorUnindent,
10160
10171
  'Editor.updateDebugInfo': updateDebugInfo,
10161
10172
  'Editor.updateDiagnostics': updateDiagnostics,
10162
- 'EditorCompletion.close': close$2,
10163
- 'EditorCompletion.closeDetails': closeDetails,
10164
- 'EditorCompletion.focusFirst': focusFirst,
10165
- 'EditorCompletion.focusIndex': focusIndex$1,
10166
- 'EditorCompletion.focusNext': focusNext$2,
10167
- 'EditorCompletion.focusPrevious': focusPrevious$1,
10173
+ 'EditorCompletion.close': close$3,
10174
+ 'EditorCompletion.closeDetails': closeDetails$1,
10175
+ 'EditorCompletion.focusFirst': focusFirst$1,
10176
+ 'EditorCompletion.focusIndex': focusIndex$2,
10177
+ 'EditorCompletion.focusNext': focusNext$3,
10178
+ 'EditorCompletion.focusPrevious': focusPrevious$2,
10168
10179
  'EditorCompletion.handleEditorBlur': handleEditorBlur,
10169
10180
  'EditorCompletion.handleEditorClick': handleEditorClick,
10170
10181
  'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
10171
10182
  'EditorCompletion.handleEditorType': handleEditorType$1,
10172
- 'EditorCompletion.handleWheel': handleWheel,
10183
+ 'EditorCompletion.handleWheel': handleWheel$1,
10173
10184
  'EditorCompletion.openDetails': openDetails,
10174
- 'EditorCompletion.selectCurrent': selectCurrent,
10175
- 'EditorCompletion.selectIndex': selectIndex,
10176
- 'EditorCompletion.toggleDetails': toggleDetails,
10185
+ 'EditorCompletion.selectCurrent': selectCurrent$1,
10186
+ 'EditorCompletion.selectIndex': selectIndex$1,
10187
+ 'EditorCompletion.toggleDetails': toggleDetails$1,
10188
+ 'EditorSourceAction.close': close,
10189
+ 'EditorSourceAction.closeDetails': closeDetails,
10190
+ 'EditorSourceAction.focusFirst': focusFirst,
10191
+ 'EditorSourceAction.focusIndex': focusIndex,
10192
+ 'EditorSourceAction.focusNext': focusNext,
10193
+ 'EditorSourceAction.focusPrevious': focusPrevious,
10194
+ 'EditorSourceAction.handleWheel': handleWheel,
10195
+ 'EditorSourceAction.selectCurrent': selectCurrent,
10196
+ 'EditorSourceAction.selectIndex': selectIndex,
10197
+ 'EditorSourceAction.selectItem': selectItem,
10198
+ 'EditorSourceAction.toggleDetails': toggleDetails,
10177
10199
  'EditorRename.accept': accept,
10178
- 'EditorRename.close': close,
10200
+ 'EditorRename.close': close$1,
10179
10201
  'EditorRename.handleInput': handleInput,
10180
- 'EditorSourceActions.focusNext': focusNext,
10181
- 'FindWidget.close': close$1,
10202
+ 'EditorSourceActions.focusNext': focusNext$1,
10203
+ 'FindWidget.close': close$2,
10182
10204
  'FindWidget.focusCloseButton': focusCloseButton,
10183
10205
  'FindWidget.focusFind': focusFind,
10184
- 'FindWidget.focusNext': focusNext$1,
10206
+ 'FindWidget.focusNext': focusNext$2,
10185
10207
  'FindWidget.focusNextMatchButton': focusNextMatchButton,
10186
- 'FindWidget.focusPrevious': focusPrevious,
10208
+ 'FindWidget.focusPrevious': focusPrevious$1,
10187
10209
  'FindWidget.focusPreviousMatchButton': focusPreviousMatchButton,
10188
10210
  'FindWidget.focusReplace': focusReplace,
10189
10211
  'FindWidget.focusReplaceAllButton': focusReplaceAllButton,
@@ -10217,11 +10239,6 @@ const listen = async () => {
10217
10239
  set$8(rpc);
10218
10240
  };
10219
10241
 
10220
- const removeWidget = widget => {
10221
- // @ts-ignore
10222
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
10223
- };
10224
-
10225
10242
  const CodeGeneratorInput = 'CodeGeneratorInput';
10226
10243
 
10227
10244
  const getCodeGeneratorVirtualDom = state => {
@@ -10253,7 +10270,7 @@ const renderContent$1 = {
10253
10270
  return [SetDom2, newState.uid, dom];
10254
10271
  }
10255
10272
  };
10256
- const renderBounds$2 = {
10273
+ const renderBounds$1 = {
10257
10274
  isEqual(oldState, newState) {
10258
10275
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10259
10276
  },
@@ -10275,10 +10292,10 @@ const renderFocus = {
10275
10292
  return [Focus, '.CodeGeneratorInput', newState.focusSource];
10276
10293
  }
10277
10294
  };
10278
- const render$7 = [renderContent$1, renderBounds$2, renderFocus];
10295
+ const render$5 = [renderContent$1, renderBounds$1, renderFocus];
10279
10296
  const renderFull$2 = (oldState, newState) => {
10280
10297
  const commands = [];
10281
- for (const item of render$7) {
10298
+ for (const item of render$5) {
10282
10299
  if (!item.isEqual(oldState, newState)) {
10283
10300
  commands.push(item.apply(oldState, newState));
10284
10301
  }
@@ -10286,7 +10303,7 @@ const renderFull$2 = (oldState, newState) => {
10286
10303
  return commands;
10287
10304
  };
10288
10305
 
10289
- const render$6 = widget => {
10306
+ const render$4 = widget => {
10290
10307
  const commands = renderFull$2(widget.oldState, widget.newState);
10291
10308
  const wrappedCommands = [];
10292
10309
  const {
@@ -10302,16 +10319,16 @@ const render$6 = widget => {
10302
10319
  }
10303
10320
  return wrappedCommands;
10304
10321
  };
10305
- const add$4 = widget => {
10306
- return addWidget$1(widget, 'EditorCodeGenerator', render$6);
10322
+ const add$3 = widget => {
10323
+ return addWidget$1(widget, 'EditorCodeGenerator', render$4);
10307
10324
  };
10308
- const remove$4 = removeWidget;
10325
+ const remove$3 = removeWidget$1;
10309
10326
 
10310
10327
  const EditorCodeGeneratorWidget = {
10311
10328
  __proto__: null,
10312
- add: add$4,
10313
- remove: remove$4,
10314
- render: render$6
10329
+ add: add$3,
10330
+ remove: remove$3,
10331
+ render: render$4
10315
10332
  };
10316
10333
 
10317
10334
  const renderFull$1 = (oldState, newState) => {
@@ -10321,7 +10338,7 @@ const renderFull$1 = (oldState, newState) => {
10321
10338
  return commands;
10322
10339
  };
10323
10340
 
10324
- const render$5 = widget => {
10341
+ const render$3 = widget => {
10325
10342
  const commands = renderFull$1(widget.oldState, widget.newState);
10326
10343
  const wrappedCommands = [];
10327
10344
  const {
@@ -10336,18 +10353,18 @@ const render$5 = widget => {
10336
10353
  }
10337
10354
  return wrappedCommands;
10338
10355
  };
10339
- const add$3 = widget => {
10340
- return addWidget$1(widget, 'ColorPicker', render$5);
10356
+ const add$2 = widget => {
10357
+ return addWidget$1(widget, 'ColorPicker', render$3);
10341
10358
  };
10342
- const remove$3 = removeWidget;
10359
+ const remove$2 = removeWidget$1;
10343
10360
  const Commands = {};
10344
10361
 
10345
10362
  const EditorColorPickerWidget = {
10346
10363
  __proto__: null,
10347
10364
  Commands,
10348
- add: add$3,
10349
- remove: remove$3,
10350
- render: render$5
10365
+ add: add$2,
10366
+ remove: remove$2,
10367
+ render: render$3
10351
10368
  };
10352
10369
 
10353
10370
  const getCompletionDetailVirtualDom = content => {
@@ -10391,7 +10408,7 @@ const renderContent = {
10391
10408
  return [SetDom2, newState.uid, dom];
10392
10409
  }
10393
10410
  };
10394
- const renderBounds$1 = {
10411
+ const renderBounds = {
10395
10412
  isEqual(oldState, newState) {
10396
10413
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10397
10414
  },
@@ -10405,9 +10422,9 @@ const renderBounds$1 = {
10405
10422
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10406
10423
  }
10407
10424
  };
10408
- const render$4 = [renderContent, renderBounds$1];
10425
+ const render$2 = [renderContent, renderBounds];
10409
10426
  const renderFull = (oldState, newState) => {
10410
- return renderParts(render$4, oldState, newState);
10427
+ return renderParts(render$2, oldState, newState);
10411
10428
  };
10412
10429
 
10413
10430
  const getWidgetState = (editor, id) => {
@@ -10426,7 +10443,7 @@ const getCompletionState = editor => {
10426
10443
  return getWidgetState(editor, Completion);
10427
10444
  };
10428
10445
 
10429
- const render$3 = widget => {
10446
+ const render$1 = widget => {
10430
10447
  const commands = renderFull(widget.oldState, widget.newState);
10431
10448
  const wrappedCommands = [];
10432
10449
  const {
@@ -10441,10 +10458,10 @@ const render$3 = widget => {
10441
10458
  }
10442
10459
  return wrappedCommands;
10443
10460
  };
10444
- const add$2 = widget => {
10445
- return addWidget$1(widget, 'EditorCompletionDetails', render$3);
10461
+ const add$1 = widget => {
10462
+ return addWidget$1(widget, 'EditorCompletionDetails', render$1);
10446
10463
  };
10447
- const remove$2 = removeWidget;
10464
+ const remove$1 = removeWidget$1;
10448
10465
  const handleEditorType = (editor, state) => {
10449
10466
  const completionState = getCompletionState(editor);
10450
10467
  if (!completionState) {
@@ -10476,158 +10493,22 @@ const handleEditorDeleteLeft = (editor, state) => {
10476
10493
 
10477
10494
  const EditorCompletionDetailWidget = {
10478
10495
  __proto__: null,
10479
- add: add$2,
10496
+ add: add$1,
10480
10497
  handleEditorDeleteLeft,
10481
10498
  handleEditorType,
10482
- remove: remove$2,
10483
- render: render$3
10484
- };
10485
-
10486
- const render$2 = widget => {
10487
- const commands = renderHover(widget.oldState, widget.newState);
10488
- const wrappedCommands = [];
10489
- const {
10490
- uid
10491
- } = widget.newState;
10492
- for (const command of commands) {
10493
- if (command[0] === SetDom2) {
10494
- wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10495
- } else {
10496
- wrappedCommands.push(['Viewlet.send', uid, ...command]);
10497
- }
10498
- }
10499
- return wrappedCommands;
10500
- };
10501
- const add$1 = widget => {
10502
- return addWidget$1(widget, 'EditorHover', render$2);
10503
- };
10504
- const remove$1 = removeWidget;
10505
-
10506
- const EditorHoverWidget = {
10507
- __proto__: null,
10508
- add: add$1,
10509
10499
  remove: remove$1,
10510
- render: render$2
10511
- };
10512
-
10513
- const getEditorMessageVirtualDom = message => {
10514
- const dom = [{
10515
- type: Div,
10516
- className: 'Viewlet EditorMessage',
10517
- tabIndex: -1,
10518
- childCount: 2
10519
- }, {
10520
- type: Div,
10521
- className: 'EditorMessageText',
10522
- childCount: 1
10523
- }, text(message), {
10524
- type: Div,
10525
- className: 'EditorMessageTriangle',
10526
- childCount: 0
10527
- }];
10528
- return dom;
10529
- };
10530
-
10531
- const getEmptySourceActionsVirtualDom = () => {
10532
- return getEditorMessageVirtualDom(noCodeActionsAvailable());
10533
- };
10534
-
10535
- const getActionClassName = isFocused => {
10536
- if (isFocused) {
10537
- return mergeClassNames(SourceActionItem, SourceActionItemFocused);
10538
- }
10539
- return SourceActionItem;
10540
- };
10541
- const getSourceActionListItemVirtualDom = sourceAction => {
10542
- const {
10543
- name,
10544
- isFocused
10545
- } = sourceAction;
10546
- const actionClassName = getActionClassName(isFocused);
10547
- return [{
10548
- type: Div,
10549
- className: actionClassName,
10550
- childCount: 2
10551
- }, {
10552
- type: Div,
10553
- className: mergeClassNames(SourceActionIcon, MaskIcon, MaskIconSymbolFile)
10554
- }, text(name)];
10555
- };
10556
-
10557
- const getSourceActionsVirtualDom = sourceActions => {
10558
- if (sourceActions.length === 0) {
10559
- return getEmptySourceActionsVirtualDom();
10560
- }
10561
- const dom = [{
10562
- type: Div,
10563
- className: mergeClassNames(Viewlet, EditorSourceActions),
10564
- tabIndex: -1,
10565
- childCount: 2,
10566
- onFocusIn: HandleFocusIn
10567
- }, {
10568
- type: Div,
10569
- className: SourceActionHeading,
10570
- childCount: 1
10571
- }, text(sourceAction()), {
10572
- type: Div,
10573
- className: EditorSourceActionsList,
10574
- childCount: sourceActions.length,
10575
- onClick: HandleClick
10576
- }, ...sourceActions.flatMap(getSourceActionListItemVirtualDom)];
10577
- return dom;
10578
- };
10579
-
10580
- const getVisibleSourceActions = (sourceActions, focusedIndex) => {
10581
- const visible = [];
10582
- for (let i = 0; i < sourceActions.length; i++) {
10583
- const isFocused = i === focusedIndex;
10584
- const sourceAction = sourceActions[i];
10585
- visible.push({
10586
- ...sourceAction,
10587
- isFocused
10588
- });
10589
- }
10590
- return visible;
10591
- };
10592
-
10593
- const renderSourceActions = {
10594
- isEqual(oldState, newState) {
10595
- return oldState.sourceActions === newState.sourceActions && oldState.focusedIndex === newState.focusedIndex;
10596
- },
10597
- apply(oldStatem, newState) {
10598
- const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
10599
- const dom = getSourceActionsVirtualDom(visible);
10600
- return [SetDom2, newState.uid, dom];
10601
- }
10602
- };
10603
- const renderBounds = {
10604
- isEqual(oldState, newState) {
10605
- return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10606
- },
10607
- apply(oldState, newState) {
10608
- return [SetBounds, newState.x, newState.y, newState.width, newState.height];
10609
- }
10610
- };
10611
- const render$1 = [renderSourceActions, renderBounds];
10612
- const doRender = (oldState, newState) => {
10613
- const commands = [];
10614
- for (const item of render$1) {
10615
- if (!item.isEqual(oldState, newState)) {
10616
- commands.push(item.apply(oldState, newState));
10617
- }
10618
- }
10619
- return commands;
10500
+ render: render$1
10620
10501
  };
10621
10502
 
10622
10503
  const render = widget => {
10623
- const commands = doRender(widget.oldState, widget.newState);
10504
+ const commands = renderHover(widget.oldState, widget.newState);
10624
10505
  const wrappedCommands = [];
10625
10506
  const {
10626
10507
  uid
10627
10508
  } = widget.newState;
10628
10509
  for (const command of commands) {
10629
10510
  if (command[0] === SetDom2) {
10630
- wrappedCommands.push(command);
10511
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10631
10512
  } else {
10632
10513
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10633
10514
  }
@@ -10635,11 +10516,11 @@ const render = widget => {
10635
10516
  return wrappedCommands;
10636
10517
  };
10637
10518
  const add = widget => {
10638
- return addWidget$1(widget, 'EditorSourceActions', render);
10519
+ return addWidget$1(widget, 'EditorHover', render);
10639
10520
  };
10640
- const remove = removeWidget;
10521
+ const remove = removeWidget$1;
10641
10522
 
10642
- const EditorSourceActionWidget = {
10523
+ const EditorHoverWidget = {
10643
10524
  __proto__: null,
10644
10525
  add,
10645
10526
  remove,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "7.20.0",
3
+ "version": "8.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Lvce Editor",
6
6
  "type": "module",