@lvce-editor/editor-worker 7.21.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.
@@ -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,75 +6633,6 @@ const showHover = async state => {
6637
6633
  return state;
6638
6634
  };
6639
6635
 
6640
- const filterActions = (sourceActions, languageId) => {
6641
- return sourceActions.filter(action => action.languageId === languageId);
6642
- };
6643
-
6644
- // TODO ask extension host worker instead
6645
- const getEditorSourceActions = async editorId => {
6646
- if (!editorId) {
6647
- return [];
6648
- }
6649
- const {
6650
- newState
6651
- } = get$4(editorId);
6652
- const {
6653
- languageId
6654
- } = newState;
6655
- // @ts-ignore
6656
- const allActions = await invoke$8('GetEditorSourceActions.getEditorSourceActions');
6657
- const filtered = filterActions(allActions, languageId);
6658
- return filtered;
6659
- };
6660
-
6661
- const getHeight = sourceActionCount => {
6662
- if (sourceActionCount === 0) {
6663
- return 45;
6664
- }
6665
- return 150;
6666
- };
6667
- const getSourceActionWidgetPosition = (editor, sourceActionCount) => {
6668
- const width = 300;
6669
- const height = getHeight(sourceActionCount);
6670
- const cursor = getPositionAtCursor$1(editor);
6671
- const {
6672
- x
6673
- } = cursor;
6674
- const {
6675
- y
6676
- } = cursor;
6677
- // TODO support virtual list
6678
- return {
6679
- x,
6680
- y,
6681
- width,
6682
- height
6683
- };
6684
- };
6685
-
6686
- const loadSourceActions = async (editor, state) => {
6687
- // const editor = GetEditor.getEditor(editorUid)
6688
- // TODO request source actions information from extensions
6689
- const sourceActions = await getEditorSourceActions();
6690
- // TODO avoid side effect
6691
- const {
6692
- x,
6693
- y,
6694
- width,
6695
- height
6696
- } = getSourceActionWidgetPosition(editor, sourceActions.length);
6697
- return {
6698
- ...state,
6699
- sourceActions,
6700
- x,
6701
- y,
6702
- width,
6703
- height,
6704
- maxHeight: 150,
6705
- focusedIndex: 0
6706
- };
6707
- };
6708
-
6709
6636
  const create = () => {
6710
6637
  const completionUid = create$7();
6711
6638
  const widget = {
@@ -6736,13 +6663,6 @@ const create = () => {
6736
6663
  return widget;
6737
6664
  };
6738
6665
 
6739
- const showSourceActions$1 = async editor => {
6740
- const newStateGenerator = async state => {
6741
- return loadSourceActions(editor, state);
6742
- };
6743
- return addWidgetToEditor(SourceAction$1, SourceActions, editor, create, newStateGenerator);
6744
- };
6745
-
6746
6666
  const launchSourceActionWorker = async () => {
6747
6667
  const name = 'Source Action Worker';
6748
6668
  const url = 'sourceActionWorkerMain.js';
@@ -7586,6 +7506,7 @@ const isFunctional = widgetId => {
7586
7506
  case Rename:
7587
7507
  case Completion:
7588
7508
  case Find:
7509
+ case SourceAction$1:
7589
7510
  return true;
7590
7511
  default:
7591
7512
  return false;
@@ -7716,7 +7637,7 @@ const renderFull$4 = (oldState, newState) => {
7716
7637
  return commands;
7717
7638
  };
7718
7639
 
7719
- const render$c = widget => {
7640
+ const render$b = widget => {
7720
7641
  const commands = renderFull$4(widget.oldState, widget.newState);
7721
7642
  const wrappedCommands = [];
7722
7643
  const {
@@ -7732,7 +7653,7 @@ const render$c = widget => {
7732
7653
  return wrappedCommands;
7733
7654
  };
7734
7655
  const add$7 = widget => {
7735
- return addWidget$1(widget, 'EditorCompletion', render$c);
7656
+ return addWidget$1(widget, 'EditorCompletion', render$b);
7736
7657
  };
7737
7658
  const remove$7 = widget => {
7738
7659
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -7773,7 +7694,7 @@ const EditorCompletionWidget = {
7773
7694
  handleWheel: handleWheel$1,
7774
7695
  openDetails,
7775
7696
  remove: remove$7,
7776
- render: render$c,
7697
+ render: render$b,
7777
7698
  selectCurrent: selectCurrent$1,
7778
7699
  selectIndex: selectIndex$1,
7779
7700
  toggleDetails: toggleDetails$1
@@ -7786,7 +7707,7 @@ const renderFull$3 = (oldState, newState) => {
7786
7707
  return commands;
7787
7708
  };
7788
7709
 
7789
- const render$b = widget => {
7710
+ const render$a = widget => {
7790
7711
  const commands = renderFull$3(widget.oldState, widget.newState);
7791
7712
  const wrappedCommands = [];
7792
7713
  const {
@@ -7802,7 +7723,7 @@ const render$b = widget => {
7802
7723
  return wrappedCommands;
7803
7724
  };
7804
7725
  const add$6 = widget => {
7805
- return addWidget$1(widget, 'FindWidget', render$b);
7726
+ return addWidget$1(widget, 'FindWidget', render$a);
7806
7727
  };
7807
7728
  const remove$6 = widget => {
7808
7729
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -7849,7 +7770,7 @@ const EditorFindWidget = {
7849
7770
  handleReplaceInput,
7850
7771
  handleToggleReplaceFocus,
7851
7772
  remove: remove$6,
7852
- render: render$b,
7773
+ render: render$a,
7853
7774
  toggleReplace
7854
7775
  };
7855
7776
 
@@ -7904,8 +7825,6 @@ const EditorCursor = 'EditorCursor';
7904
7825
  const EditorRow = 'EditorRow';
7905
7826
  const EditorRowHighlighted = 'EditorRowHighlighted';
7906
7827
  const EditorSelection = 'EditorSelection';
7907
- const EditorSourceActions = 'EditorSourceActions';
7908
- const EditorSourceActionsList = 'EditorSourceActionsList';
7909
7828
  const HoverDisplayString = 'HoverDisplayString';
7910
7829
  const HoverDocumentation = 'HoverDocumentation';
7911
7830
  const HoverEditorRow = 'HoverEditorRow';
@@ -7915,16 +7834,10 @@ const HoverProblemMessage = 'HoverProblemMessage';
7915
7834
  const IconClose = 'IconClose';
7916
7835
  const InputBox = 'InputBox';
7917
7836
  const MaskIcon = 'MaskIcon';
7918
- const MaskIconSymbolFile = 'MaskIconSymbolFile';
7919
- const SourceActionHeading = 'SourceActionHeading';
7920
- const SourceActionIcon = 'SourceActionIcon';
7921
- const SourceActionItem = 'SourceActionItem';
7922
- const SourceActionItemFocused = 'SourceActionItemFocused';
7923
7837
  const Viewlet = 'Viewlet';
7924
7838
 
7925
7839
  const HandleBeforeInput = 'handleBeforeInput';
7926
7840
  const HandleBlur = 'handleBlur';
7927
- const HandleClick = 'handleClick';
7928
7841
  const HandleClose = 'handleClose';
7929
7842
  const HandleCompositionEnd = 'handleCompositionEnd';
7930
7843
  const HandleCompositionStart = 'handleCompositionStart';
@@ -7932,7 +7845,6 @@ const HandleCompositionUpdate = 'handleCompositionUpdate';
7932
7845
  const HandleContextMenu = 'handleContextMenu';
7933
7846
  const HandleCut = 'handleCut';
7934
7847
  const HandleFocus = 'handleFocus';
7935
- const HandleFocusIn = 'handleFocusIn';
7936
7848
  const HandleMouseMove = 'handleMouseMove';
7937
7849
  const HandleSashPointerDown = 'handleSashPointerDown';
7938
7850
  const HandleWheel = 'handleWheel';
@@ -8035,7 +7947,7 @@ const renderHoverDom = {
8035
7947
  return [/* method */SetDom2, dom];
8036
7948
  }
8037
7949
  };
8038
- const renderBounds$3 = {
7950
+ const renderBounds$2 = {
8039
7951
  isEqual(oldState, newState) {
8040
7952
  return oldState.x === newState.x && oldState.y === newState.y;
8041
7953
  },
@@ -8049,10 +7961,10 @@ const renderBounds$3 = {
8049
7961
  return [SetBounds, x, y, width, height];
8050
7962
  }
8051
7963
  };
8052
- const render$a = [renderHoverDom, renderBounds$3];
7964
+ const render$9 = [renderHoverDom, renderBounds$2];
8053
7965
  const renderHover = (oldState, newState) => {
8054
7966
  const commands = [];
8055
- for (const item of render$a) {
7967
+ for (const item of render$9) {
8056
7968
  if (!item.isEqual(oldState, newState)) {
8057
7969
  commands.push(item.apply(oldState, newState));
8058
7970
  }
@@ -8060,7 +7972,7 @@ const renderHover = (oldState, newState) => {
8060
7972
  return commands;
8061
7973
  };
8062
7974
 
8063
- const render$9 = widget => {
7975
+ const render$8 = widget => {
8064
7976
  const commands = renderFull$4(widget.oldState, widget.newState);
8065
7977
  const wrappedCommands = [];
8066
7978
  const {
@@ -8076,7 +7988,7 @@ const render$9 = widget => {
8076
7988
  return wrappedCommands;
8077
7989
  };
8078
7990
  const add$5 = widget => {
8079
- return addWidget$1(widget, 'EditorRename', render$9);
7991
+ return addWidget$1(widget, 'EditorRename', render$8);
8080
7992
  };
8081
7993
  const remove$5 = widget => {
8082
7994
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -8094,7 +8006,7 @@ const EditorRenameWidget = {
8094
8006
  close: close$1,
8095
8007
  handleInput,
8096
8008
  remove: remove$5,
8097
- render: render$9
8009
+ render: render$8
8098
8010
  };
8099
8011
 
8100
8012
  const rerender = editor => {
@@ -8120,127 +8032,14 @@ const removeWidget$1 = widget => {
8120
8032
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
8121
8033
  };
8122
8034
 
8123
- const getEditorMessageVirtualDom = message => {
8124
- const dom = [{
8125
- type: Div,
8126
- className: 'Viewlet EditorMessage',
8127
- tabIndex: -1,
8128
- childCount: 2
8129
- }, {
8130
- type: Div,
8131
- className: 'EditorMessageText',
8132
- childCount: 1
8133
- }, text(message), {
8134
- type: Div,
8135
- className: 'EditorMessageTriangle',
8136
- childCount: 0
8137
- }];
8138
- return dom;
8139
- };
8140
-
8141
- const getEmptySourceActionsVirtualDom = () => {
8142
- return getEditorMessageVirtualDom(noCodeActionsAvailable());
8143
- };
8144
-
8145
- const mergeClassNames = (...classNames) => {
8146
- return classNames.filter(Boolean).join(' ');
8147
- };
8148
-
8149
- const getActionClassName = isFocused => {
8150
- if (isFocused) {
8151
- return mergeClassNames(SourceActionItem, SourceActionItemFocused);
8152
- }
8153
- return SourceActionItem;
8154
- };
8155
- const getSourceActionListItemVirtualDom = sourceAction => {
8156
- const {
8157
- name,
8158
- isFocused
8159
- } = sourceAction;
8160
- const actionClassName = getActionClassName(isFocused);
8161
- return [{
8162
- type: Div,
8163
- className: actionClassName,
8164
- childCount: 2
8165
- }, {
8166
- type: Div,
8167
- className: mergeClassNames(SourceActionIcon, MaskIcon, MaskIconSymbolFile)
8168
- }, text(name)];
8169
- };
8170
-
8171
- const getSourceActionsVirtualDom = sourceActions => {
8172
- if (sourceActions.length === 0) {
8173
- return getEmptySourceActionsVirtualDom();
8174
- }
8175
- const dom = [{
8176
- type: Div,
8177
- className: mergeClassNames(Viewlet, EditorSourceActions),
8178
- tabIndex: -1,
8179
- childCount: 2,
8180
- onFocusIn: HandleFocusIn
8181
- }, {
8182
- type: Div,
8183
- className: SourceActionHeading,
8184
- childCount: 1
8185
- }, text(sourceAction()), {
8186
- type: Div,
8187
- className: EditorSourceActionsList,
8188
- childCount: sourceActions.length,
8189
- onClick: HandleClick
8190
- }, ...sourceActions.flatMap(getSourceActionListItemVirtualDom)];
8191
- return dom;
8192
- };
8193
-
8194
- const getVisibleSourceActions = (sourceActions, focusedIndex) => {
8195
- const visible = [];
8196
- for (let i = 0; i < sourceActions.length; i++) {
8197
- const isFocused = i === focusedIndex;
8198
- const sourceAction = sourceActions[i];
8199
- visible.push({
8200
- ...sourceAction,
8201
- isFocused
8202
- });
8203
- }
8204
- return visible;
8205
- };
8206
-
8207
- const renderSourceActions = {
8208
- isEqual(oldState, newState) {
8209
- return oldState.sourceActions === newState.sourceActions && oldState.focusedIndex === newState.focusedIndex;
8210
- },
8211
- apply(oldStatem, newState) {
8212
- const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
8213
- const dom = getSourceActionsVirtualDom(visible);
8214
- return [SetDom2, newState.uid, dom];
8215
- }
8216
- };
8217
- const renderBounds$2 = {
8218
- isEqual(oldState, newState) {
8219
- return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
8220
- },
8221
- apply(oldState, newState) {
8222
- return [SetBounds, newState.x, newState.y, newState.width, newState.height];
8223
- }
8224
- };
8225
- const render$8 = [renderSourceActions, renderBounds$2];
8226
- const doRender = (oldState, newState) => {
8227
- const commands = [];
8228
- for (const item of render$8) {
8229
- if (!item.isEqual(oldState, newState)) {
8230
- commands.push(item.apply(oldState, newState));
8231
- }
8232
- }
8233
- return commands;
8234
- };
8235
-
8236
8035
  const render$7 = widget => {
8237
- const commands = doRender(widget.oldState, widget.newState);
8036
+ const commands = renderFull$4(widget.oldState, widget.newState);
8238
8037
  const wrappedCommands = [];
8239
8038
  const {
8240
8039
  uid
8241
8040
  } = widget.newState;
8242
8041
  for (const command of commands) {
8243
- if (command[0] === SetDom2) {
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') {
8244
8043
  wrappedCommands.push(command);
8245
8044
  } else {
8246
8045
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -8321,6 +8120,27 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
8321
8120
  return newEditor;
8322
8121
  };
8323
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
+
8324
8144
  const RE_WORD = /[\w\-]+$/;
8325
8145
  const getWordAtOffset = editor => {
8326
8146
  const {
@@ -8696,7 +8516,7 @@ const getKeyBindings = () => {
8696
8516
  when: FocusEditorText
8697
8517
  }, {
8698
8518
  key: CtrlCmd | Period,
8699
- command: 'Editor.showSourceActions2',
8519
+ command: 'Editor.showSourceActions3',
8700
8520
  when: FocusEditorText
8701
8521
  }, {
8702
8522
  key: Tab,
@@ -9691,6 +9511,10 @@ const getDiagnosticClassName = type => {
9691
9511
  }
9692
9512
  };
9693
9513
 
9514
+ const mergeClassNames = (...classNames) => {
9515
+ return classNames.filter(Boolean).join(' ');
9516
+ };
9517
+
9694
9518
  const getDiagnosticVirtualDom = diagnostic => {
9695
9519
  const {
9696
9520
  x,
@@ -10332,8 +10156,8 @@ const commandMap = {
10332
10156
  'Editor.setSelections2': setSelections2,
10333
10157
  'Editor.showHover': showHover,
10334
10158
  'Editor.showHover2': showHover2,
10335
- 'Editor.showSourceActions': showSourceActions$1,
10336
- 'Editor.showSourceActions2': showSourceActions$1,
10159
+ 'Editor.showSourceActions': showSourceActions,
10160
+ 'Editor.showSourceActions2': showSourceActions,
10337
10161
  'Editor.showSourceActions3': showSourceActions,
10338
10162
  'Editor.sortLinesAscending': sortLinesAscending,
10339
10163
  'Editor.tabCompletion': tabCompletion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "7.21.0",
3
+ "version": "8.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Lvce Editor",
6
6
  "type": "module",