@lvce-editor/editor-worker 3.20.0 → 3.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.
@@ -128,141 +128,6 @@ const handleSliderPointerMove = (state, x, y) => {
128
128
  };
129
129
  };
130
130
 
131
- const ColoredMaskIcon = 'ColoredMaskIcon';
132
- const ColorPicker$2 = 'ColorPicker';
133
- const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
134
- const ColorPickerDark = 'ColorPickerDark';
135
- const ColorPickerLight = 'ColorPickerLight';
136
- const ColorPickerRectangle = 'ColorPickerRectangle';
137
- const ColorPickerSlider = 'ColorPickerSlider';
138
- const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
139
- const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
140
- const IconButtonDisabled = 'IconButtonDisabled';
141
- const IconButton = 'IconButton';
142
- const CompletionDetailContent = 'CompletionDetailContent';
143
- const Diagnostic = 'Diagnostic';
144
- const FindWidgetReplace = 'FindWidgetReplace';
145
- const FindWidgetFind = 'FindWidgetFind';
146
- const FindWidgetMatchCount = 'FindWidgetMatchCount';
147
- const FindWidgetRight = 'FindWidgetRight';
148
- const EditorCompletionItem = 'EditorCompletionItem';
149
- const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
150
- const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
151
- const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
152
- const EditorCursor = 'EditorCursor';
153
- const EditorRow = 'EditorRow';
154
- const EditorSelection = 'EditorSelection';
155
- const FileIcon = 'FileIcon';
156
- const HoverDisplayString = 'HoverDisplayString';
157
- const HoverDocumentation = 'HoverDocumentation';
158
- const SearchFieldButtons = 'SearchFieldButtons';
159
- const HoverEditorRow = 'HoverEditorRow';
160
- const MultilineInputBox = 'MultilineInputBox';
161
- const SearchField = 'SearchField';
162
- const HoverProblem = 'HoverProblem';
163
- const HoverProblemDetail = 'HoverProblemDetail';
164
- const HoverProblemMessage = 'HoverProblemMessage';
165
- const IconClose = 'IconClose';
166
- const Label = 'Label';
167
- const MaskIcon = 'MaskIcon';
168
- const Viewlet = 'Viewlet';
169
-
170
- const HandlePointerDown = 'handlePointerDown';
171
- const HandleSashPointerDown = 'handleSashPointerDown';
172
- const HandleClose = 'handleClose';
173
-
174
- const mergeClassNames = (...classNames) => {
175
- return classNames.filter(Boolean).join(' ');
176
- };
177
-
178
- const Button = 1;
179
- const Div = 4;
180
- const Span = 8;
181
- const Text = 12;
182
- const Img = 17;
183
- const TextArea = 62;
184
-
185
- const getColorPickerVirtualDom = () => {
186
- return [{
187
- type: Div,
188
- className: mergeClassNames(Viewlet, ColorPicker$2),
189
- onPointerDown: HandlePointerDown,
190
- childCount: 3
191
- }, {
192
- type: Div,
193
- className: ColorPickerRectangle,
194
- childCount: 3
195
- }, {
196
- type: Div,
197
- className: ColorPickerBackgroundColor,
198
- childCount: 0
199
- }, {
200
- type: Div,
201
- className: ColorPickerLight,
202
- childCount: 0
203
- }, {
204
- type: Div,
205
- className: ColorPickerDark,
206
- childCount: 0
207
- }, {
208
- type: Div,
209
- className: ColorPickerSlider,
210
- childCount: 0
211
- }, {
212
- type: Div,
213
- className: ColorPickerSliderThumb,
214
- childCount: 0
215
- }];
216
- };
217
-
218
- const SetBounds = 'setBounds';
219
- const SetColor = 'setColor';
220
- const SetContentHeight = 'setContentHeight';
221
- const SetNegativeMargin = 'setNegativeMargin';
222
- const SetOffsetX = 'setOffsetX';
223
- const SetScrollBar = 'setScrollBar';
224
- const SetValue = 'setValue';
225
-
226
- const renderParts = (render, oldState, newState) => {
227
- const commands = [];
228
- for (const item of render) {
229
- if (!item.isEqual(oldState, newState)) {
230
- commands.push(item.apply(oldState, newState));
231
- }
232
- }
233
- return commands;
234
- };
235
-
236
- const renderColor$1 = {
237
- isEqual(oldState, newState) {
238
- return oldState.color === newState.color;
239
- },
240
- apply(oldState, newState) {
241
- return [/* method */SetColor, /* color */newState.color];
242
- }
243
- };
244
- const renderOffsetX$1 = {
245
- isEqual(oldState, newState) {
246
- return oldState.offsetX === newState.offsetX;
247
- },
248
- apply(oldState, newState) {
249
- return [/* method */SetOffsetX, /* offsetX */newState.offsetX];
250
- }
251
- };
252
- const renderColorPickerDom = {
253
- isEqual(oldState, newState) {
254
- return oldState.min === newState.min && oldState.max === newState.max;
255
- },
256
- apply(oldState, newState) {
257
- const dom = getColorPickerVirtualDom();
258
- return ['Viewlet.setDom2', dom];
259
- }
260
- };
261
- const render$b = [renderColorPickerDom, renderColor$1, renderOffsetX$1];
262
- const renderColorPicker = async (oldState, newState) => {
263
- return renderParts(render$b, oldState, newState);
264
- };
265
-
266
131
  // TODO use numeric enum
267
132
  const CompositionUpdate = 'compositionUpdate';
268
133
  const ContentEditableInput = 'contentEditableInput';
@@ -1213,7 +1078,7 @@ const set$6 = (id, fn) => {
1213
1078
  const get$6 = id => {
1214
1079
  return state$1$1.callbacks[id];
1215
1080
  };
1216
- const remove$5 = id => {
1081
+ const remove$6 = id => {
1217
1082
  delete state$1$1.callbacks[id];
1218
1083
  };
1219
1084
  const state$9 = {
@@ -1259,7 +1124,7 @@ const resolve = (id, args) => {
1259
1124
  return;
1260
1125
  }
1261
1126
  fn(args);
1262
- remove$5(id);
1127
+ remove$6(id);
1263
1128
  };
1264
1129
  const create$2$1 = (method, params) => {
1265
1130
  const {
@@ -2392,7 +2257,7 @@ const cancelSelection = editor => {
2392
2257
  // TODO use numeric widget id
2393
2258
  const Completion = 'completion';
2394
2259
  const CompletionDetail$1 = 'completionDetail';
2395
- const ColorPicker$1 = 'colorPicker';
2260
+ const ColorPicker$2 = 'colorPicker';
2396
2261
  const Find = 'find';
2397
2262
  const Hover = 'hover';
2398
2263
  const SourceAction = 'sourceAction';
@@ -2473,7 +2338,7 @@ const create$6 = () => {
2473
2338
  const create$5 = () => {
2474
2339
  const completionUid = create$6();
2475
2340
  const widget = {
2476
- id: ColorPicker$1,
2341
+ id: ColorPicker$2,
2477
2342
  oldState: {
2478
2343
  color: '',
2479
2344
  offsetX: 0,
@@ -2500,7 +2365,7 @@ const create$5 = () => {
2500
2365
  return widget;
2501
2366
  };
2502
2367
 
2503
- const ColorPicker = 41;
2368
+ const ColorPicker$1 = 41;
2504
2369
  const FindWidget = 16;
2505
2370
  const EditorCompletion = 9;
2506
2371
  const CompletionDetail = 999;
@@ -2519,7 +2384,7 @@ const newStateGenerator$1 = state => {
2519
2384
  return loadContent$3(state);
2520
2385
  };
2521
2386
  const openColorPicker = async editor => {
2522
- return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$5, newStateGenerator$1);
2387
+ return addWidgetToEditor(ColorPicker$2, ColorPicker$1, editor, create$5, newStateGenerator$1);
2523
2388
  };
2524
2389
 
2525
2390
  const state$6 = {
@@ -3433,6 +3298,9 @@ const noTypeDefinitionFound = () => {
3433
3298
  const noResults$1 = () => {
3434
3299
  return i18nString(UiStrings$1.NoResults);
3435
3300
  };
3301
+ const sourceAction = () => {
3302
+ return i18nString(UiStrings$1.SourceAction);
3303
+ };
3436
3304
  const organizeImports$1 = () => {
3437
3305
  return i18nString(UiStrings$1.OrganizeImports);
3438
3306
  };
@@ -7765,6 +7633,55 @@ const handleSashPointerUp = (state, eventX, eventY) => {
7765
7633
  return state;
7766
7634
  };
7767
7635
 
7636
+ const ColoredMaskIcon = 'ColoredMaskIcon';
7637
+ const ColorPicker = 'ColorPicker';
7638
+ const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
7639
+ const ColorPickerDark = 'ColorPickerDark';
7640
+ const ColorPickerLight = 'ColorPickerLight';
7641
+ const ColorPickerRectangle = 'ColorPickerRectangle';
7642
+ const ColorPickerSlider = 'ColorPickerSlider';
7643
+ const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7644
+ const SourceActionItem = 'SourceActionItem';
7645
+ const SourceActionItemFocused = 'SourceActionItemFocused';
7646
+ const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7647
+ const IconButtonDisabled = 'IconButtonDisabled';
7648
+ const IconButton = 'IconButton';
7649
+ const SourceActionHeading = 'SourceActionHeading';
7650
+ const CompletionDetailContent = 'CompletionDetailContent';
7651
+ const Diagnostic = 'Diagnostic';
7652
+ const FindWidgetReplace = 'FindWidgetReplace';
7653
+ const FindWidgetFind = 'FindWidgetFind';
7654
+ const FindWidgetMatchCount = 'FindWidgetMatchCount';
7655
+ const FindWidgetRight = 'FindWidgetRight';
7656
+ const EditorCompletionItem = 'EditorCompletionItem';
7657
+ const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
7658
+ const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
7659
+ const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
7660
+ const EditorCursor = 'EditorCursor';
7661
+ const EditorRow = 'EditorRow';
7662
+ const EditorSelection = 'EditorSelection';
7663
+ const FileIcon = 'FileIcon';
7664
+ const HoverDisplayString = 'HoverDisplayString';
7665
+ const HoverDocumentation = 'HoverDocumentation';
7666
+ const SearchFieldButtons = 'SearchFieldButtons';
7667
+ const HoverEditorRow = 'HoverEditorRow';
7668
+ const MultilineInputBox = 'MultilineInputBox';
7669
+ const SearchField = 'SearchField';
7670
+ const HoverProblem = 'HoverProblem';
7671
+ const HoverProblemDetail = 'HoverProblemDetail';
7672
+ const HoverProblemMessage = 'HoverProblemMessage';
7673
+ const IconClose = 'IconClose';
7674
+ const Label = 'Label';
7675
+ const MaskIcon = 'MaskIcon';
7676
+ const Viewlet = 'Viewlet';
7677
+
7678
+ const Button = 1;
7679
+ const Div = 4;
7680
+ const Span = 8;
7681
+ const Text = 12;
7682
+ const Img = 17;
7683
+ const TextArea = 62;
7684
+
7768
7685
  const text = data => {
7769
7686
  return {
7770
7687
  type: Text,
@@ -7797,6 +7714,12 @@ const getLineInfosVirtualDom = lineInfos => {
7797
7714
  return dom;
7798
7715
  };
7799
7716
 
7717
+ const HandlePointerDown = 'handlePointerDown';
7718
+ const HandleSashPointerDown = 'handleSashPointerDown';
7719
+ const HandleClose = 'handleClose';
7720
+ const HandleFocusIn = 'handleFocusIn';
7721
+ const HandleClick = 'handleClick';
7722
+
7800
7723
  const hoverProblemMessage = {
7801
7724
  type: Span,
7802
7725
  className: HoverProblemMessage,
@@ -7851,6 +7774,14 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
7851
7774
  return dom;
7852
7775
  };
7853
7776
 
7777
+ const SetBounds = 'setBounds';
7778
+ const SetColor = 'setColor';
7779
+ const SetContentHeight = 'setContentHeight';
7780
+ const SetNegativeMargin = 'setNegativeMargin';
7781
+ const SetOffsetX = 'setOffsetX';
7782
+ const SetScrollBar = 'setScrollBar';
7783
+ const SetValue = 'setValue';
7784
+
7854
7785
  const renderHoverDom = {
7855
7786
  isEqual(oldState, newState) {
7856
7787
  return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics;
@@ -7860,7 +7791,7 @@ const renderHoverDom = {
7860
7791
  return [/* method */'Viewlet.setDom2', dom];
7861
7792
  }
7862
7793
  };
7863
- const renderBounds$4 = {
7794
+ const renderBounds$5 = {
7864
7795
  isEqual(oldState, newState) {
7865
7796
  return oldState.x === newState.x && oldState.y === newState.y;
7866
7797
  },
@@ -7874,10 +7805,10 @@ const renderBounds$4 = {
7874
7805
  return [SetBounds, x, y, renderWidth, height];
7875
7806
  }
7876
7807
  };
7877
- const render$a = [renderHoverDom, renderBounds$4];
7808
+ const render$c = [renderHoverDom, renderBounds$5];
7878
7809
  const renderHover = (oldState, newState) => {
7879
7810
  const commands = [];
7880
- for (const item of render$a) {
7811
+ for (const item of render$c) {
7881
7812
  if (!item.isEqual(oldState, newState)) {
7882
7813
  commands.push(item.apply(oldState, newState));
7883
7814
  }
@@ -8835,7 +8766,7 @@ const renderWidgets = {
8835
8766
  },
8836
8767
  multiple: true
8837
8768
  };
8838
- const render$9 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8769
+ const render$b = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8839
8770
  const renderEditor = async id => {
8840
8771
  const instance = get$7(id);
8841
8772
  if (!instance) {
@@ -8847,7 +8778,7 @@ const renderEditor = async id => {
8847
8778
  } = instance;
8848
8779
  const commands = [];
8849
8780
  set$7(id, newState, newState);
8850
- for (const item of render$9) {
8781
+ for (const item of render$b) {
8851
8782
  if (!item.isEqual(oldState, newState)) {
8852
8783
  const result = await item.apply(oldState, newState);
8853
8784
  // @ts-ignore
@@ -8893,8 +8824,8 @@ const wrapWidgetCommand = (widgetId, fn) => {
8893
8824
  };
8894
8825
 
8895
8826
  const widgetCommands = {
8896
- 'ColorPicker.handleSliderPointerDown': ColorPicker$1,
8897
- 'ColorPicker.handleSliderPointerMove': ColorPicker$1,
8827
+ 'ColorPicker.handleSliderPointerDown': ColorPicker$2,
8828
+ 'ColorPicker.handleSliderPointerMove': ColorPicker$2,
8898
8829
  // 'FindWidget.focusNext': WidgetId.Find,
8899
8830
  // 'FindWidget.focusPrevious': WidgetId.Find,
8900
8831
  'FindWidget.close': Find,
@@ -8945,7 +8876,6 @@ const commandMap = {
8945
8876
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
8946
8877
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove,
8947
8878
  'ColorPicker.loadContent': loadContent$3,
8948
- 'ColorPicker.render': renderColorPicker,
8949
8879
  'Editor.addCursorAbove': addCursorAbove,
8950
8880
  'Editor.addCursorBelow': addCursorBelow,
8951
8881
  'Editor.applyEdit': applyEdit,
@@ -9322,7 +9252,7 @@ const renderItems = {
9322
9252
  return ['setDom', dom];
9323
9253
  }
9324
9254
  };
9325
- const renderBounds$3 = {
9255
+ const renderBounds$4 = {
9326
9256
  isEqual(oldState, newState) {
9327
9257
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
9328
9258
  },
@@ -9368,10 +9298,10 @@ const renderScrollBar = {
9368
9298
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
9369
9299
  }
9370
9300
  };
9371
- const render$8 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
9301
+ const render$a = [renderItems, renderBounds$4, renderHeight, renderNegativeMargin, renderScrollBar];
9372
9302
  const renderCompletion = (oldState, newState) => {
9373
9303
  const commands = [];
9374
- for (const item of render$8) {
9304
+ for (const item of render$a) {
9375
9305
  if (!item.isEqual(oldState, newState)) {
9376
9306
  commands.push(item.apply(oldState, newState));
9377
9307
  }
@@ -9384,7 +9314,7 @@ const removeWidget = widget => {
9384
9314
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
9385
9315
  };
9386
9316
 
9387
- const render$7 = widget => {
9317
+ const render$9 = widget => {
9388
9318
  const commands = renderCompletion(widget.oldState, widget.newState);
9389
9319
  const wrappedCommands = [];
9390
9320
  const uid = widget.newState.uid;
@@ -9393,8 +9323,8 @@ const render$7 = widget => {
9393
9323
  }
9394
9324
  return wrappedCommands;
9395
9325
  };
9396
- const add$4 = widget => {
9397
- const commands = render$7(widget);
9326
+ const add$5 = widget => {
9327
+ const commands = render$9(widget);
9398
9328
  const id = 'EditorCompletion';
9399
9329
  // TODO how to generate a unique integer id
9400
9330
  // that doesn't collide with ids created in renderer worker?
@@ -9404,7 +9334,7 @@ const add$4 = widget => {
9404
9334
  allCommands.push(...commands);
9405
9335
  return allCommands;
9406
9336
  };
9407
- const remove$4 = removeWidget;
9337
+ const remove$5 = removeWidget;
9408
9338
  const handleEditorType = (editor, state) => {
9409
9339
  const {
9410
9340
  unfilteredItems,
@@ -9469,11 +9399,11 @@ const handleEditorDeleteLeft = (editor, state) => {
9469
9399
 
9470
9400
  const EditorCompletionWidget = {
9471
9401
  __proto__: null,
9472
- add: add$4,
9402
+ add: add$5,
9473
9403
  handleEditorDeleteLeft,
9474
9404
  handleEditorType,
9475
- remove: remove$4,
9476
- render: render$7
9405
+ remove: remove$5,
9406
+ render: render$9
9477
9407
  };
9478
9408
 
9479
9409
  const MessagePort$1 = 1;
@@ -9985,6 +9915,43 @@ const addWidget = (widget, id, render) => {
9985
9915
  return allCommands;
9986
9916
  };
9987
9917
 
9918
+ const mergeClassNames = (...classNames) => {
9919
+ return classNames.filter(Boolean).join(' ');
9920
+ };
9921
+
9922
+ const getColorPickerVirtualDom = () => {
9923
+ return [{
9924
+ type: Div,
9925
+ className: mergeClassNames(Viewlet, ColorPicker),
9926
+ onPointerDown: HandlePointerDown,
9927
+ childCount: 3
9928
+ }, {
9929
+ type: Div,
9930
+ className: ColorPickerRectangle,
9931
+ childCount: 3
9932
+ }, {
9933
+ type: Div,
9934
+ className: ColorPickerBackgroundColor,
9935
+ childCount: 0
9936
+ }, {
9937
+ type: Div,
9938
+ className: ColorPickerLight,
9939
+ childCount: 0
9940
+ }, {
9941
+ type: Div,
9942
+ className: ColorPickerDark,
9943
+ childCount: 0
9944
+ }, {
9945
+ type: Div,
9946
+ className: ColorPickerSlider,
9947
+ childCount: 0
9948
+ }, {
9949
+ type: Div,
9950
+ className: ColorPickerSliderThumb,
9951
+ childCount: 0
9952
+ }];
9953
+ };
9954
+
9988
9955
  const renderColor = {
9989
9956
  isEqual(oldState, newState) {
9990
9957
  return oldState.color === newState.color;
@@ -10010,7 +9977,7 @@ const renderContent$1 = {
10010
9977
  return ['Viewlet.setDom2', newState.uid, dom];
10011
9978
  }
10012
9979
  };
10013
- const renderBounds$2 = {
9980
+ const renderBounds$3 = {
10014
9981
  isEqual(oldState, newState) {
10015
9982
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10016
9983
  },
@@ -10024,10 +9991,10 @@ const renderBounds$2 = {
10024
9991
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10025
9992
  }
10026
9993
  };
10027
- const render$6 = [renderContent$1, renderBounds$2, renderColor, renderOffsetX];
9994
+ const render$8 = [renderContent$1, renderBounds$3, renderColor, renderOffsetX];
10028
9995
  const renderFull$1 = (oldState, newState) => {
10029
9996
  const commands = [];
10030
- for (const item of render$6) {
9997
+ for (const item of render$8) {
10031
9998
  if (!item.isEqual(oldState, newState)) {
10032
9999
  commands.push(item.apply(oldState, newState));
10033
10000
  }
@@ -10035,7 +10002,7 @@ const renderFull$1 = (oldState, newState) => {
10035
10002
  return commands;
10036
10003
  };
10037
10004
 
10038
- const render$5 = widget => {
10005
+ const render$7 = widget => {
10039
10006
  const commands = renderFull$1(widget.oldState, widget.newState);
10040
10007
  const wrappedCommands = [];
10041
10008
  const uid = widget.newState.uid;
@@ -10048,10 +10015,10 @@ const render$5 = widget => {
10048
10015
  }
10049
10016
  return wrappedCommands;
10050
10017
  };
10051
- const add$3 = widget => {
10052
- return addWidget(widget, 'ColorPicker', render$5);
10018
+ const add$4 = widget => {
10019
+ return addWidget(widget, 'ColorPicker', render$7);
10053
10020
  };
10054
- const remove$3 = removeWidget;
10021
+ const remove$4 = removeWidget;
10055
10022
  const Commands$1 = {
10056
10023
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
10057
10024
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
@@ -10060,9 +10027,9 @@ const Commands$1 = {
10060
10027
  const EditorColorPickerWidget = {
10061
10028
  __proto__: null,
10062
10029
  Commands: Commands$1,
10063
- add: add$3,
10064
- remove: remove$3,
10065
- render: render$5
10030
+ add: add$4,
10031
+ remove: remove$4,
10032
+ render: render$7
10066
10033
  };
10067
10034
 
10068
10035
  const getCompletionDetailVirtualDom = content => {
@@ -10087,6 +10054,16 @@ const getCompletionDetailVirtualDom = content => {
10087
10054
  return dom;
10088
10055
  };
10089
10056
 
10057
+ const renderParts = (render, oldState, newState) => {
10058
+ const commands = [];
10059
+ for (const item of render) {
10060
+ if (!item.isEqual(oldState, newState)) {
10061
+ commands.push(item.apply(oldState, newState));
10062
+ }
10063
+ }
10064
+ return commands;
10065
+ };
10066
+
10090
10067
  const renderContent = {
10091
10068
  isEqual(oldState, newState) {
10092
10069
  return oldState.content === newState.content;
@@ -10096,7 +10073,7 @@ const renderContent = {
10096
10073
  return ['Viewlet.setDom2', newState.uid, dom];
10097
10074
  }
10098
10075
  };
10099
- const renderBounds$1 = {
10076
+ const renderBounds$2 = {
10100
10077
  isEqual(oldState, newState) {
10101
10078
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10102
10079
  },
@@ -10110,12 +10087,12 @@ const renderBounds$1 = {
10110
10087
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10111
10088
  }
10112
10089
  };
10113
- const render$4 = [renderContent, renderBounds$1];
10090
+ const render$6 = [renderContent, renderBounds$2];
10114
10091
  const renderFull = (oldState, newState) => {
10115
- return renderParts(render$4, oldState, newState);
10092
+ return renderParts(render$6, oldState, newState);
10116
10093
  };
10117
10094
 
10118
- const render$3 = widget => {
10095
+ const render$5 = widget => {
10119
10096
  const commands = renderFull(widget.oldState, widget.newState);
10120
10097
  const wrappedCommands = [];
10121
10098
  const uid = widget.newState.uid;
@@ -10128,16 +10105,16 @@ const render$3 = widget => {
10128
10105
  }
10129
10106
  return wrappedCommands;
10130
10107
  };
10131
- const add$2 = widget => {
10132
- return addWidget(widget, 'EditorCompletionDetails', render$3);
10108
+ const add$3 = widget => {
10109
+ return addWidget(widget, 'EditorCompletionDetails', render$5);
10133
10110
  };
10134
- const remove$2 = removeWidget;
10111
+ const remove$3 = removeWidget;
10135
10112
 
10136
10113
  const EditorCompletionDetailWidget = {
10137
10114
  __proto__: null,
10138
- add: add$2,
10139
- remove: remove$2,
10140
- render: render$3
10115
+ add: add$3,
10116
+ remove: remove$3,
10117
+ render: render$5
10141
10118
  };
10142
10119
 
10143
10120
  /**
@@ -10440,7 +10417,7 @@ const renderDetails = {
10440
10417
  return ['Viewlet.setDom2', dom];
10441
10418
  }
10442
10419
  };
10443
- const renderBounds = {
10420
+ const renderBounds$1 = {
10444
10421
  isEqual(oldState, newState) {
10445
10422
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10446
10423
  },
@@ -10483,16 +10460,16 @@ const renderFocus = {
10483
10460
  // },
10484
10461
  // }
10485
10462
 
10486
- const render$2 = [renderDetails, renderBounds, renderValue, renderFocus];
10463
+ const render$4 = [renderDetails, renderBounds$1, renderValue, renderFocus];
10487
10464
  const apply = (oldState, newState) => {
10488
10465
  // TODO avoid side effect
10489
10466
  if (oldState.focus !== newState.focus) {
10490
10467
  setFocus(newState.focus);
10491
10468
  }
10492
- return renderParts(render$2, oldState, newState);
10469
+ return renderParts(render$4, oldState, newState);
10493
10470
  };
10494
10471
 
10495
- const render$1 = widget => {
10472
+ const render$3 = widget => {
10496
10473
  const commands = apply(widget.oldState, widget.newState);
10497
10474
  const wrappedCommands = [];
10498
10475
  const uid = widget.newState.uid;
@@ -10505,10 +10482,10 @@ const render$1 = widget => {
10505
10482
  }
10506
10483
  return wrappedCommands;
10507
10484
  };
10508
- const add$1 = widget => {
10509
- return addWidget(widget, 'FindWidget', render$1);
10485
+ const add$2 = widget => {
10486
+ return addWidget(widget, 'FindWidget', render$3);
10510
10487
  };
10511
- const remove$1 = removeWidget;
10488
+ const remove$2 = removeWidget;
10512
10489
  const Commands = {
10513
10490
  'FindWidget.close': close$1,
10514
10491
  'FindWidget.focusNext': focusNext$1,
@@ -10523,22 +10500,127 @@ const Commands = {
10523
10500
  const EditorFindWidget = {
10524
10501
  __proto__: null,
10525
10502
  Commands,
10503
+ add: add$2,
10504
+ remove: remove$2,
10505
+ render: render$3
10506
+ };
10507
+
10508
+ const render$2 = widget => {
10509
+ const commands = renderHover(widget.oldState, widget.newState);
10510
+ const wrappedCommands = [];
10511
+ const uid = widget.newState.uid;
10512
+ for (const command of commands) {
10513
+ if (command[0] === 'Viewlet.setDom2') {
10514
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10515
+ } else {
10516
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
10517
+ }
10518
+ }
10519
+ return wrappedCommands;
10520
+ };
10521
+ const add$1 = widget => {
10522
+ return addWidget(widget, 'EditorHover', render$2);
10523
+ };
10524
+ const remove$1 = removeWidget;
10525
+
10526
+ const EditorHoverWidget = {
10527
+ __proto__: null,
10526
10528
  add: add$1,
10527
10529
  remove: remove$1,
10528
- render: render$1
10530
+ render: render$2
10529
10531
  };
10530
10532
 
10531
- const SourceActionWidget = {
10532
- __proto__: null
10533
+ const getActionClassName = isFocused => {
10534
+ if (isFocused) {
10535
+ return mergeClassNames(SourceActionItem, SourceActionItemFocused);
10536
+ }
10537
+ return SourceActionItem;
10538
+ };
10539
+ const getSourceActionListItemVirtualDom = sourceAction => {
10540
+ const {
10541
+ name,
10542
+ isFocused
10543
+ } = sourceAction;
10544
+ const actionClassName = getActionClassName(isFocused);
10545
+ return [{
10546
+ type: Div,
10547
+ className: actionClassName,
10548
+ childCount: 2
10549
+ }, {
10550
+ type: Div,
10551
+ className: 'SourceActionIcon MaskIcon MaskIconSymbolFile'
10552
+ }, text(name)];
10553
+ };
10554
+
10555
+ const getSourceActionsVirtualDom = sourceActions => {
10556
+ const dom = [{
10557
+ type: Div,
10558
+ className: 'Viewlet EditorSourceActions',
10559
+ tabIndex: -1,
10560
+ childCount: 2,
10561
+ onFocusIn: HandleFocusIn
10562
+ }, {
10563
+ type: Div,
10564
+ className: SourceActionHeading,
10565
+ childCount: 1
10566
+ }, text(sourceAction()), {
10567
+ type: Div,
10568
+ className: 'EditorSourceActionsList',
10569
+ childCount: sourceActions.length,
10570
+ onClick: HandleClick
10571
+ }, ...sourceActions.flatMap(getSourceActionListItemVirtualDom)];
10572
+ return dom;
10573
+ };
10574
+
10575
+ const getVisibleSourceActions = (sourceActions, focusedIndex) => {
10576
+ const visible = [];
10577
+ for (let i = 0; i < sourceActions.length; i++) {
10578
+ const isFocused = i === focusedIndex;
10579
+ const sourceAction = sourceActions[i];
10580
+ visible.push({
10581
+ ...sourceAction,
10582
+ isFocused
10583
+ });
10584
+ }
10585
+ return visible;
10586
+ };
10587
+
10588
+ const renderSourceActions = {
10589
+ isEqual(oldState, newState) {
10590
+ return oldState.sourceActions === newState.sourceActions && oldState.focusedIndex === newState.focusedIndex;
10591
+ },
10592
+ apply(oldStatem, newState) {
10593
+ const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
10594
+ const dom = getSourceActionsVirtualDom(visible);
10595
+ return ['Viewlet.setDom2', newState.uid, dom];
10596
+ }
10597
+ };
10598
+ const renderBounds = {
10599
+ isEqual(oldState, newState) {
10600
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10601
+ },
10602
+ apply(oldState, newState) {
10603
+ return ['setBounds', newState.x, newState.y, newState.width, newState.height];
10604
+ }
10605
+ };
10606
+ const render$1 = [renderSourceActions, renderBounds];
10607
+ const doRender = (oldState, newState) => {
10608
+ const commands = [];
10609
+ for (const item of render$1) {
10610
+ if (!item.isEqual(oldState, newState)) {
10611
+ commands.push(item.apply(oldState, newState));
10612
+ }
10613
+ }
10614
+ return commands;
10533
10615
  };
10534
10616
 
10535
10617
  const render = widget => {
10536
- const commands = renderHover(widget.oldState, widget.newState);
10618
+ const commands = doRender(widget.oldState, widget.newState);
10537
10619
  const wrappedCommands = [];
10538
10620
  const uid = widget.newState.uid;
10539
10621
  for (const command of commands) {
10540
10622
  if (command[0] === 'Viewlet.setDom2') {
10541
- wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10623
+ wrappedCommands.push(command);
10542
10624
  } else {
10543
10625
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10544
10626
  }
@@ -10546,11 +10628,11 @@ const render = widget => {
10546
10628
  return wrappedCommands;
10547
10629
  };
10548
10630
  const add = widget => {
10549
- return addWidget(widget, 'EditorHover', render);
10631
+ return addWidget(widget, 'EditorSourceActions', render);
10550
10632
  };
10551
10633
  const remove = removeWidget;
10552
10634
 
10553
- const EditorHoverWidget = {
10635
+ const EditorSourceActionWidget = {
10554
10636
  __proto__: null,
10555
10637
  add,
10556
10638
  remove,
@@ -10558,12 +10640,12 @@ const EditorHoverWidget = {
10558
10640
  };
10559
10641
 
10560
10642
  const registerWidgets = () => {
10561
- set(ColorPicker$1, EditorColorPickerWidget);
10643
+ set(ColorPicker$2, EditorColorPickerWidget);
10562
10644
  set(Completion, EditorCompletionWidget);
10563
10645
  set(CompletionDetail$1, EditorCompletionDetailWidget);
10564
10646
  set(Find, EditorFindWidget);
10565
10647
  set(Hover, EditorHoverWidget);
10566
- set(SourceAction, SourceActionWidget);
10648
+ set(SourceAction, EditorSourceActionWidget);
10567
10649
  };
10568
10650
 
10569
10651
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",