@lvce-editor/editor-worker 7.20.0 → 7.21.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
@@ -6637,11 +6637,25 @@ const showHover = async state => {
6637
6637
  return state;
6638
6638
  };
6639
6639
 
6640
+ const filterActions = (sourceActions, languageId) => {
6641
+ return sourceActions.filter(action => action.languageId === languageId);
6642
+ };
6643
+
6640
6644
  // TODO ask extension host worker instead
6641
- const getEditorSourceActions = async () => {
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;
6642
6655
  // @ts-ignore
6643
- const sourceActions = await invoke$8('GetEditorSourceActions.getEditorSourceActions');
6644
- return sourceActions;
6656
+ const allActions = await invoke$8('GetEditorSourceActions.getEditorSourceActions');
6657
+ const filtered = filterActions(allActions, languageId);
6658
+ return filtered;
6645
6659
  };
6646
6660
 
6647
6661
  const getHeight = sourceActionCount => {
@@ -7724,45 +7738,45 @@ const remove$7 = widget => {
7724
7738
  return [['Viewlet.dispose', widget.newState.uid]];
7725
7739
  };
7726
7740
  const {
7727
- focusFirst,
7728
- focusIndex: focusIndex$1,
7729
- focusLast,
7730
- focusNext: focusNext$2,
7731
- focusPrevious: focusPrevious$1,
7741
+ focusFirst: focusFirst$1,
7742
+ focusIndex: focusIndex$2,
7743
+ focusLast: focusLast$1,
7744
+ focusNext: focusNext$3,
7745
+ focusPrevious: focusPrevious$2,
7732
7746
  handleEditorBlur,
7733
7747
  handleEditorClick,
7734
7748
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
7735
7749
  handleEditorType: handleEditorType$1,
7736
7750
  openDetails,
7737
- selectCurrent,
7738
- selectIndex,
7739
- toggleDetails,
7740
- closeDetails,
7741
- handleWheel,
7742
- close: close$2
7751
+ selectCurrent: selectCurrent$1,
7752
+ selectIndex: selectIndex$1,
7753
+ toggleDetails: toggleDetails$1,
7754
+ closeDetails: closeDetails$1,
7755
+ handleWheel: handleWheel$1,
7756
+ close: close$3
7743
7757
  } = createFns(['handleEditorType', 'focusFirst', 'focusNext', 'focusPrevious', 'focusLast', 'handleEditorDeleteLeft', 'openDetails', 'focusIndex', 'handleEditorBlur', 'handleEditorClick', 'openDetails', 'selectCurrent', 'selectIndex', 'toggleDetails', 'closeDetails', 'handleWheel', 'close'], 'Completions', Completion);
7744
7758
 
7745
7759
  const EditorCompletionWidget = {
7746
7760
  __proto__: null,
7747
7761
  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,
7762
+ close: close$3,
7763
+ closeDetails: closeDetails$1,
7764
+ focusFirst: focusFirst$1,
7765
+ focusIndex: focusIndex$2,
7766
+ focusLast: focusLast$1,
7767
+ focusNext: focusNext$3,
7768
+ focusPrevious: focusPrevious$2,
7755
7769
  handleEditorBlur,
7756
7770
  handleEditorClick,
7757
7771
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
7758
7772
  handleEditorType: handleEditorType$1,
7759
- handleWheel,
7773
+ handleWheel: handleWheel$1,
7760
7774
  openDetails,
7761
7775
  remove: remove$7,
7762
7776
  render: render$c,
7763
- selectCurrent,
7764
- selectIndex,
7765
- toggleDetails
7777
+ selectCurrent: selectCurrent$1,
7778
+ selectIndex: selectIndex$1,
7779
+ toggleDetails: toggleDetails$1
7766
7780
  };
7767
7781
 
7768
7782
  const renderFull$3 = (oldState, newState) => {
@@ -7794,12 +7808,12 @@ const remove$6 = widget => {
7794
7808
  return [['Viewlet.dispose', widget.newState.uid]];
7795
7809
  };
7796
7810
  const {
7797
- close: close$1,
7811
+ close: close$2,
7798
7812
  focusCloseButton,
7799
7813
  focusFind,
7800
- focusNext: focusNext$1,
7814
+ focusNext: focusNext$2,
7801
7815
  focusNextMatchButton,
7802
- focusPrevious,
7816
+ focusPrevious: focusPrevious$1,
7803
7817
  focusPreviousMatchButton,
7804
7818
  focusReplace,
7805
7819
  focusReplaceAllButton,
@@ -7817,12 +7831,12 @@ const {
7817
7831
  const EditorFindWidget = {
7818
7832
  __proto__: null,
7819
7833
  add: add$6,
7820
- close: close$1,
7834
+ close: close$2,
7821
7835
  focusCloseButton,
7822
7836
  focusFind,
7823
- focusNext: focusNext$1,
7837
+ focusNext: focusNext$2,
7824
7838
  focusNextMatchButton,
7825
- focusPrevious,
7839
+ focusPrevious: focusPrevious$1,
7826
7840
  focusPreviousMatchButton,
7827
7841
  focusReplace,
7828
7842
  focusReplaceAllButton,
@@ -8069,7 +8083,7 @@ const remove$5 = widget => {
8069
8083
  };
8070
8084
  const {
8071
8085
  handleInput,
8072
- close,
8086
+ close: close$1,
8073
8087
  accept
8074
8088
  } = createFns(['handleInput', 'close', 'accept'], 'Rename', Rename);
8075
8089
 
@@ -8077,7 +8091,7 @@ const EditorRenameWidget = {
8077
8091
  __proto__: null,
8078
8092
  accept,
8079
8093
  add: add$5,
8080
- close,
8094
+ close: close$1,
8081
8095
  handleInput,
8082
8096
  remove: remove$5,
8083
8097
  render: render$9
@@ -8088,7 +8102,7 @@ const rerender = editor => {
8088
8102
  return structuredClone(editor);
8089
8103
  };
8090
8104
 
8091
- const focusIndex = (state, index) => {
8105
+ const focusIndex$1 = (state, index) => {
8092
8106
  const newState = {
8093
8107
  ...state,
8094
8108
  focusedIndex: index
@@ -8096,9 +8110,180 @@ const focusIndex = (state, index) => {
8096
8110
  return newState;
8097
8111
  };
8098
8112
 
8099
- const focusNext = state => {
8113
+ const focusNext$1 = state => {
8100
8114
  const nextIndex = state.focusedIndex + 1;
8101
- return focusIndex(state, nextIndex);
8115
+ return focusIndex$1(state, nextIndex);
8116
+ };
8117
+
8118
+ const removeWidget$1 = widget => {
8119
+ // @ts-ignore
8120
+ return [['Viewlet.send', widget.newState.uid, 'dispose']];
8121
+ };
8122
+
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
+ const render$7 = widget => {
8237
+ const commands = doRender(widget.oldState, widget.newState);
8238
+ const wrappedCommands = [];
8239
+ const {
8240
+ uid
8241
+ } = widget.newState;
8242
+ for (const command of commands) {
8243
+ if (command[0] === SetDom2) {
8244
+ wrappedCommands.push(command);
8245
+ } else {
8246
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
8247
+ }
8248
+ }
8249
+ return wrappedCommands;
8250
+ };
8251
+ const add$4 = widget => {
8252
+ return addWidget$1(widget, 'EditorSourceActions', render$7);
8253
+ };
8254
+ const remove$4 = removeWidget$1;
8255
+ const {
8256
+ focusFirst,
8257
+ focusIndex,
8258
+ focusLast,
8259
+ focusNext,
8260
+ focusPrevious,
8261
+ selectCurrent,
8262
+ selectIndex,
8263
+ selectItem,
8264
+ toggleDetails,
8265
+ closeDetails,
8266
+ handleWheel,
8267
+ close
8268
+ } = createFns(['focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'selectCurrent', 'selectIndex', 'selectItem', 'toggleDetails', 'closeDetails', 'handleWheel', 'close'], 'SourceActions', SourceAction$1);
8269
+
8270
+ const EditorSourceActionWidget = {
8271
+ __proto__: null,
8272
+ add: add$4,
8273
+ close,
8274
+ closeDetails,
8275
+ focusFirst,
8276
+ focusIndex,
8277
+ focusLast,
8278
+ focusNext,
8279
+ focusPrevious,
8280
+ handleWheel,
8281
+ remove: remove$4,
8282
+ render: render$7,
8283
+ selectCurrent,
8284
+ selectIndex,
8285
+ selectItem,
8286
+ toggleDetails
8102
8287
  };
8103
8288
 
8104
8289
  const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
@@ -8253,6 +8438,10 @@ const applyEdits2 = async (editorUid, edits) => {
8253
8438
  const newEditor = await applyEdit(editor, edits);
8254
8439
  set$6(editorUid, editor, newEditor);
8255
8440
  };
8441
+ const getSourceActions = async editorUid => {
8442
+ const actions = await getEditorSourceActions(editorUid);
8443
+ return actions;
8444
+ };
8256
8445
 
8257
8446
  const pending = Object.create(null);
8258
8447
  const loaded = Object.create(null);
@@ -9502,10 +9691,6 @@ const getDiagnosticClassName = type => {
9502
9691
  }
9503
9692
  };
9504
9693
 
9505
- const mergeClassNames = (...classNames) => {
9506
- return classNames.filter(Boolean).join(' ');
9507
- };
9508
-
9509
9694
  const getDiagnosticVirtualDom = diagnostic => {
9510
9695
  const {
9511
9696
  x,
@@ -9634,7 +9819,7 @@ const renderWidget = widget => {
9634
9819
  }
9635
9820
  return module.render(widget);
9636
9821
  };
9637
- const removeWidget$1 = widget => {
9822
+ const removeWidget = widget => {
9638
9823
  const module = get$5(widget.id);
9639
9824
  if (!module) {
9640
9825
  throw new Error('unsupported widget');
@@ -9789,7 +9974,7 @@ const renderWidgets = {
9789
9974
  }
9790
9975
  const removeCommands = [];
9791
9976
  for (const removedWidget of removedWidgets) {
9792
- const childCommands = removeWidget$1(removedWidget);
9977
+ const childCommands = removeWidget(removedWidget);
9793
9978
  if (childCommands.length > 0) {
9794
9979
  removeCommands.push(...childCommands);
9795
9980
  }
@@ -9799,7 +9984,7 @@ const renderWidgets = {
9799
9984
  },
9800
9985
  multiple: true
9801
9986
  };
9802
- const render$8 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9987
+ const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9803
9988
  const renderEditor = async id => {
9804
9989
  const instance = get$4(id);
9805
9990
  if (!instance) {
@@ -9811,7 +9996,7 @@ const renderEditor = async id => {
9811
9996
  } = instance;
9812
9997
  const commands = [];
9813
9998
  set$6(id, newState, newState);
9814
- for (const item of render$8) {
9999
+ for (const item of render$6) {
9815
10000
  if (!item.isEqual(oldState, newState)) {
9816
10001
  const result = await item.apply(oldState, newState);
9817
10002
  // @ts-ignore
@@ -9911,7 +10096,7 @@ const editorDiagnosticEffect = {
9911
10096
  }
9912
10097
  };
9913
10098
 
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'
10099
+ 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
10100
  // 'ColorPicker.handleSliderPointerDown',
9916
10101
  // 'ColorPicker.handleSliderPointerMove',
9917
10102
  // 'ColorPicker.loadContent',
@@ -10019,6 +10204,7 @@ const commandMap = {
10019
10204
  'Editor.compositionEnd': compositionEnd,
10020
10205
  'Editor.compositionStart': compositionStart,
10021
10206
  'Editor.compositionUpdate': compositionUpdate,
10207
+ 'Editor.applyDocumentEdits': applyDocumentEdits,
10022
10208
  'Editor.contextMenu': handleContextMenu,
10023
10209
  'Editor.copy': copy,
10024
10210
  'Editor.copyLineDown': copyLineDown,
@@ -10058,6 +10244,7 @@ const commandMap = {
10058
10244
  'Editor.getLines2': getLines2,
10059
10245
  'Editor.getOffsetAtCursor': getOffsetAtCursor,
10060
10246
  'Editor.getPositionAtCursor': getPositionAtCursor,
10247
+ 'Editor.getSourceActions': getSourceActions,
10061
10248
  'Editor.getProblems': getProblems,
10062
10249
  'Editor.getQuickPickMenuEntries': getQuickPickMenuEntries,
10063
10250
  'Editor.getSelections': getSelections,
@@ -10159,31 +10346,42 @@ const commandMap = {
10159
10346
  'Editor.unIndent': editorUnindent,
10160
10347
  'Editor.updateDebugInfo': updateDebugInfo,
10161
10348
  '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,
10349
+ 'EditorCompletion.close': close$3,
10350
+ 'EditorCompletion.closeDetails': closeDetails$1,
10351
+ 'EditorCompletion.focusFirst': focusFirst$1,
10352
+ 'EditorCompletion.focusIndex': focusIndex$2,
10353
+ 'EditorCompletion.focusNext': focusNext$3,
10354
+ 'EditorCompletion.focusPrevious': focusPrevious$2,
10168
10355
  'EditorCompletion.handleEditorBlur': handleEditorBlur,
10169
10356
  'EditorCompletion.handleEditorClick': handleEditorClick,
10170
10357
  'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
10171
10358
  'EditorCompletion.handleEditorType': handleEditorType$1,
10172
- 'EditorCompletion.handleWheel': handleWheel,
10359
+ 'EditorCompletion.handleWheel': handleWheel$1,
10173
10360
  'EditorCompletion.openDetails': openDetails,
10174
- 'EditorCompletion.selectCurrent': selectCurrent,
10175
- 'EditorCompletion.selectIndex': selectIndex,
10176
- 'EditorCompletion.toggleDetails': toggleDetails,
10361
+ 'EditorCompletion.selectCurrent': selectCurrent$1,
10362
+ 'EditorCompletion.selectIndex': selectIndex$1,
10363
+ 'EditorCompletion.toggleDetails': toggleDetails$1,
10364
+ 'EditorSourceAction.close': close,
10365
+ 'EditorSourceAction.closeDetails': closeDetails,
10366
+ 'EditorSourceAction.focusFirst': focusFirst,
10367
+ 'EditorSourceAction.focusIndex': focusIndex,
10368
+ 'EditorSourceAction.focusNext': focusNext,
10369
+ 'EditorSourceAction.focusPrevious': focusPrevious,
10370
+ 'EditorSourceAction.handleWheel': handleWheel,
10371
+ 'EditorSourceAction.selectCurrent': selectCurrent,
10372
+ 'EditorSourceAction.selectIndex': selectIndex,
10373
+ 'EditorSourceAction.selectItem': selectItem,
10374
+ 'EditorSourceAction.toggleDetails': toggleDetails,
10177
10375
  'EditorRename.accept': accept,
10178
- 'EditorRename.close': close,
10376
+ 'EditorRename.close': close$1,
10179
10377
  'EditorRename.handleInput': handleInput,
10180
- 'EditorSourceActions.focusNext': focusNext,
10181
- 'FindWidget.close': close$1,
10378
+ 'EditorSourceActions.focusNext': focusNext$1,
10379
+ 'FindWidget.close': close$2,
10182
10380
  'FindWidget.focusCloseButton': focusCloseButton,
10183
10381
  'FindWidget.focusFind': focusFind,
10184
- 'FindWidget.focusNext': focusNext$1,
10382
+ 'FindWidget.focusNext': focusNext$2,
10185
10383
  'FindWidget.focusNextMatchButton': focusNextMatchButton,
10186
- 'FindWidget.focusPrevious': focusPrevious,
10384
+ 'FindWidget.focusPrevious': focusPrevious$1,
10187
10385
  'FindWidget.focusPreviousMatchButton': focusPreviousMatchButton,
10188
10386
  'FindWidget.focusReplace': focusReplace,
10189
10387
  'FindWidget.focusReplaceAllButton': focusReplaceAllButton,
@@ -10217,11 +10415,6 @@ const listen = async () => {
10217
10415
  set$8(rpc);
10218
10416
  };
10219
10417
 
10220
- const removeWidget = widget => {
10221
- // @ts-ignore
10222
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
10223
- };
10224
-
10225
10418
  const CodeGeneratorInput = 'CodeGeneratorInput';
10226
10419
 
10227
10420
  const getCodeGeneratorVirtualDom = state => {
@@ -10253,7 +10446,7 @@ const renderContent$1 = {
10253
10446
  return [SetDom2, newState.uid, dom];
10254
10447
  }
10255
10448
  };
10256
- const renderBounds$2 = {
10449
+ const renderBounds$1 = {
10257
10450
  isEqual(oldState, newState) {
10258
10451
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10259
10452
  },
@@ -10275,10 +10468,10 @@ const renderFocus = {
10275
10468
  return [Focus, '.CodeGeneratorInput', newState.focusSource];
10276
10469
  }
10277
10470
  };
10278
- const render$7 = [renderContent$1, renderBounds$2, renderFocus];
10471
+ const render$5 = [renderContent$1, renderBounds$1, renderFocus];
10279
10472
  const renderFull$2 = (oldState, newState) => {
10280
10473
  const commands = [];
10281
- for (const item of render$7) {
10474
+ for (const item of render$5) {
10282
10475
  if (!item.isEqual(oldState, newState)) {
10283
10476
  commands.push(item.apply(oldState, newState));
10284
10477
  }
@@ -10286,7 +10479,7 @@ const renderFull$2 = (oldState, newState) => {
10286
10479
  return commands;
10287
10480
  };
10288
10481
 
10289
- const render$6 = widget => {
10482
+ const render$4 = widget => {
10290
10483
  const commands = renderFull$2(widget.oldState, widget.newState);
10291
10484
  const wrappedCommands = [];
10292
10485
  const {
@@ -10302,16 +10495,16 @@ const render$6 = widget => {
10302
10495
  }
10303
10496
  return wrappedCommands;
10304
10497
  };
10305
- const add$4 = widget => {
10306
- return addWidget$1(widget, 'EditorCodeGenerator', render$6);
10498
+ const add$3 = widget => {
10499
+ return addWidget$1(widget, 'EditorCodeGenerator', render$4);
10307
10500
  };
10308
- const remove$4 = removeWidget;
10501
+ const remove$3 = removeWidget$1;
10309
10502
 
10310
10503
  const EditorCodeGeneratorWidget = {
10311
10504
  __proto__: null,
10312
- add: add$4,
10313
- remove: remove$4,
10314
- render: render$6
10505
+ add: add$3,
10506
+ remove: remove$3,
10507
+ render: render$4
10315
10508
  };
10316
10509
 
10317
10510
  const renderFull$1 = (oldState, newState) => {
@@ -10321,7 +10514,7 @@ const renderFull$1 = (oldState, newState) => {
10321
10514
  return commands;
10322
10515
  };
10323
10516
 
10324
- const render$5 = widget => {
10517
+ const render$3 = widget => {
10325
10518
  const commands = renderFull$1(widget.oldState, widget.newState);
10326
10519
  const wrappedCommands = [];
10327
10520
  const {
@@ -10336,18 +10529,18 @@ const render$5 = widget => {
10336
10529
  }
10337
10530
  return wrappedCommands;
10338
10531
  };
10339
- const add$3 = widget => {
10340
- return addWidget$1(widget, 'ColorPicker', render$5);
10532
+ const add$2 = widget => {
10533
+ return addWidget$1(widget, 'ColorPicker', render$3);
10341
10534
  };
10342
- const remove$3 = removeWidget;
10535
+ const remove$2 = removeWidget$1;
10343
10536
  const Commands = {};
10344
10537
 
10345
10538
  const EditorColorPickerWidget = {
10346
10539
  __proto__: null,
10347
10540
  Commands,
10348
- add: add$3,
10349
- remove: remove$3,
10350
- render: render$5
10541
+ add: add$2,
10542
+ remove: remove$2,
10543
+ render: render$3
10351
10544
  };
10352
10545
 
10353
10546
  const getCompletionDetailVirtualDom = content => {
@@ -10391,7 +10584,7 @@ const renderContent = {
10391
10584
  return [SetDom2, newState.uid, dom];
10392
10585
  }
10393
10586
  };
10394
- const renderBounds$1 = {
10587
+ const renderBounds = {
10395
10588
  isEqual(oldState, newState) {
10396
10589
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10397
10590
  },
@@ -10405,9 +10598,9 @@ const renderBounds$1 = {
10405
10598
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10406
10599
  }
10407
10600
  };
10408
- const render$4 = [renderContent, renderBounds$1];
10601
+ const render$2 = [renderContent, renderBounds];
10409
10602
  const renderFull = (oldState, newState) => {
10410
- return renderParts(render$4, oldState, newState);
10603
+ return renderParts(render$2, oldState, newState);
10411
10604
  };
10412
10605
 
10413
10606
  const getWidgetState = (editor, id) => {
@@ -10426,7 +10619,7 @@ const getCompletionState = editor => {
10426
10619
  return getWidgetState(editor, Completion);
10427
10620
  };
10428
10621
 
10429
- const render$3 = widget => {
10622
+ const render$1 = widget => {
10430
10623
  const commands = renderFull(widget.oldState, widget.newState);
10431
10624
  const wrappedCommands = [];
10432
10625
  const {
@@ -10441,10 +10634,10 @@ const render$3 = widget => {
10441
10634
  }
10442
10635
  return wrappedCommands;
10443
10636
  };
10444
- const add$2 = widget => {
10445
- return addWidget$1(widget, 'EditorCompletionDetails', render$3);
10637
+ const add$1 = widget => {
10638
+ return addWidget$1(widget, 'EditorCompletionDetails', render$1);
10446
10639
  };
10447
- const remove$2 = removeWidget;
10640
+ const remove$1 = removeWidget$1;
10448
10641
  const handleEditorType = (editor, state) => {
10449
10642
  const completionState = getCompletionState(editor);
10450
10643
  if (!completionState) {
@@ -10476,158 +10669,22 @@ const handleEditorDeleteLeft = (editor, state) => {
10476
10669
 
10477
10670
  const EditorCompletionDetailWidget = {
10478
10671
  __proto__: null,
10479
- add: add$2,
10672
+ add: add$1,
10480
10673
  handleEditorDeleteLeft,
10481
10674
  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
10675
  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;
10676
+ render: render$1
10620
10677
  };
10621
10678
 
10622
10679
  const render = widget => {
10623
- const commands = doRender(widget.oldState, widget.newState);
10680
+ const commands = renderHover(widget.oldState, widget.newState);
10624
10681
  const wrappedCommands = [];
10625
10682
  const {
10626
10683
  uid
10627
10684
  } = widget.newState;
10628
10685
  for (const command of commands) {
10629
10686
  if (command[0] === SetDom2) {
10630
- wrappedCommands.push(command);
10687
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10631
10688
  } else {
10632
10689
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10633
10690
  }
@@ -10635,11 +10692,11 @@ const render = widget => {
10635
10692
  return wrappedCommands;
10636
10693
  };
10637
10694
  const add = widget => {
10638
- return addWidget$1(widget, 'EditorSourceActions', render);
10695
+ return addWidget$1(widget, 'EditorHover', render);
10639
10696
  };
10640
- const remove = removeWidget;
10697
+ const remove = removeWidget$1;
10641
10698
 
10642
- const EditorSourceActionWidget = {
10699
+ const EditorHoverWidget = {
10643
10700
  __proto__: null,
10644
10701
  add,
10645
10702
  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": "7.21.0",
4
4
  "license": "MIT",
5
5
  "author": "Lvce Editor",
6
6
  "type": "module",