@lvce-editor/editor-worker 4.11.0 → 4.13.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.
@@ -1085,7 +1085,7 @@ const set$5 = (id, fn) => {
1085
1085
  const get$5 = id => {
1086
1086
  return state$1$1.callbacks[id];
1087
1087
  };
1088
- const remove$7 = id => {
1088
+ const remove$8 = id => {
1089
1089
  delete state$1$1.callbacks[id];
1090
1090
  };
1091
1091
  const state$9 = {
@@ -1118,7 +1118,7 @@ const resolve = (id, args) => {
1118
1118
  return;
1119
1119
  }
1120
1120
  fn(args);
1121
- remove$7(id);
1121
+ remove$8(id);
1122
1122
  };
1123
1123
  const create$2$1 = (method, params) => {
1124
1124
  const {
@@ -1310,7 +1310,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
1310
1310
  const errorProperty = getErrorProperty(error, prettyError);
1311
1311
  return create$1$1(message, errorProperty);
1312
1312
  };
1313
- const create$d = (message, result) => {
1313
+ const create$e = (message, result) => {
1314
1314
  return {
1315
1315
  jsonrpc: Two,
1316
1316
  id: message.id,
@@ -1319,7 +1319,7 @@ const create$d = (message, result) => {
1319
1319
  };
1320
1320
  const getSuccessResponse = (message, result) => {
1321
1321
  const resultProperty = result ?? null;
1322
- return create$d(message, resultProperty);
1322
+ return create$e(message, resultProperty);
1323
1323
  };
1324
1324
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1325
1325
  try {
@@ -1519,7 +1519,7 @@ const waitForFirstMessage$1 = async port => {
1519
1519
  return event;
1520
1520
  };
1521
1521
 
1522
- const create$c = async () => {
1522
+ const create$d = async () => {
1523
1523
  const {
1524
1524
  port1,
1525
1525
  port2
@@ -1564,7 +1564,7 @@ const wrap$3 = port => {
1564
1564
 
1565
1565
  const IpcParentWithExtensionHostWorker = {
1566
1566
  __proto__: null,
1567
- create: create$c,
1567
+ create: create$d,
1568
1568
  wrap: wrap$3
1569
1569
  };
1570
1570
 
@@ -1572,7 +1572,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1572
1572
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1573
1573
  };
1574
1574
 
1575
- const create$b = async () => {
1575
+ const create$c = async () => {
1576
1576
  const {
1577
1577
  port1,
1578
1578
  port2
@@ -1617,7 +1617,7 @@ const wrap$1 = port => {
1617
1617
 
1618
1618
  const IpcParentWithSyntaxHighlightingWorker = {
1619
1619
  __proto__: null,
1620
- create: create$b,
1620
+ create: create$c,
1621
1621
  wrap: wrap$1
1622
1622
  };
1623
1623
 
@@ -1625,7 +1625,7 @@ const sendMessagePortToRendererProcess = async port => {
1625
1625
  await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1626
1626
  };
1627
1627
 
1628
- const create$a = async () => {
1628
+ const create$b = async () => {
1629
1629
  const {
1630
1630
  port1,
1631
1631
  port2
@@ -1670,7 +1670,7 @@ const wrap = port => {
1670
1670
 
1671
1671
  const IpcParentWithRendererProcess = {
1672
1672
  __proto__: null,
1673
- create: create$a,
1673
+ create: create$b,
1674
1674
  wrap
1675
1675
  };
1676
1676
 
@@ -1687,7 +1687,7 @@ const getModule$1 = method => {
1687
1687
  }
1688
1688
  };
1689
1689
 
1690
- const create$9 = async ({
1690
+ const create$a = async ({
1691
1691
  method,
1692
1692
  ...options
1693
1693
  }) => {
@@ -1705,7 +1705,7 @@ const create$9 = async ({
1705
1705
  const createRpc = method => {
1706
1706
  let _ipc;
1707
1707
  const listen = async () => {
1708
- const ipc = await create$9({
1708
+ const ipc = await create$a({
1709
1709
  method
1710
1710
  });
1711
1711
  handleIpc(ipc);
@@ -1747,6 +1747,7 @@ const FocusFindWidgetReplaceAllButton = 47;
1747
1747
  const FocusFindWidgetReplaceButton = 46;
1748
1748
  const FocusFindWidgetToggleReplace = 42;
1749
1749
  const SourceActions = 38;
1750
+ const FocusCodeGenerator = 52;
1750
1751
 
1751
1752
  const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing) => {
1752
1753
  return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
@@ -1999,7 +2000,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
1999
2000
  const supported = () => {
2000
2001
  return 'Segmenter' in Intl;
2001
2002
  };
2002
- const create$8 = () => {
2003
+ const create$9 = () => {
2003
2004
  // @ts-ignore
2004
2005
  const segmenter = new Intl.Segmenter();
2005
2006
  return {
@@ -2037,7 +2038,7 @@ const create$8 = () => {
2037
2038
 
2038
2039
  // @ts-ignore
2039
2040
  const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
2040
- const segmenter = create$8();
2041
+ const segmenter = create$9();
2041
2042
  const segments = segmenter.getSegments(line);
2042
2043
  const isMonospaceFont = false;
2043
2044
  const charWidth = 0;
@@ -2282,13 +2283,14 @@ const removeEditorWidget = (widgets, id) => {
2282
2283
  };
2283
2284
 
2284
2285
  // TODO use numeric widget id
2285
- const ColorPicker$1 = 'colorPicker';
2286
- const Completion = 'completion';
2287
- const CompletionDetail = 'completionDetail';
2288
- const Find = 'find';
2289
- const Hover = 'hover';
2290
- const Rename = 'rename';
2291
- const SourceAction = 'sourceAction';
2286
+ const CodeGenerator = 1;
2287
+ const ColorPicker$1 = 2;
2288
+ const Completion = 3;
2289
+ const CompletionDetail = 4;
2290
+ const Find = 5;
2291
+ const Hover = 6;
2292
+ const Rename = 7;
2293
+ const SourceAction = 8;
2292
2294
 
2293
2295
  const isCompletionWidget = widget => {
2294
2296
  return widget.id === Completion;
@@ -2308,14 +2310,14 @@ const closeCompletion = editor => {
2308
2310
  };
2309
2311
  };
2310
2312
 
2311
- const isMatchingWidget$1 = widget => {
2313
+ const isMatchingWidget$2 = widget => {
2312
2314
  return widget.id === Find;
2313
2315
  };
2314
2316
  const closeFind = editor => {
2315
2317
  const {
2316
2318
  widgets
2317
2319
  } = editor;
2318
- const index = widgets.findIndex(isMatchingWidget$1);
2320
+ const index = widgets.findIndex(isMatchingWidget$2);
2319
2321
  if (index === -1) {
2320
2322
  return editor;
2321
2323
  }
@@ -2346,14 +2348,14 @@ const closeRename = editor => {
2346
2348
  };
2347
2349
  };
2348
2350
 
2349
- const isMatchingWidget = widget => {
2351
+ const isMatchingWidget$1 = widget => {
2350
2352
  return widget.id === SourceAction;
2351
2353
  };
2352
2354
  const closeSourceAction = editor => {
2353
2355
  const {
2354
2356
  widgets
2355
2357
  } = editor;
2356
- const index = widgets.findIndex(isMatchingWidget);
2358
+ const index = widgets.findIndex(isMatchingWidget$1);
2357
2359
  if (index === -1) {
2358
2360
  return editor;
2359
2361
  }
@@ -2418,12 +2420,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
2418
2420
  return newEditor;
2419
2421
  };
2420
2422
 
2421
- const create$7 = () => {
2423
+ const create$8 = () => {
2422
2424
  return Math.random();
2423
2425
  };
2424
2426
 
2425
- const create$6 = () => {
2426
- const completionUid = create$7();
2427
+ const create$7 = () => {
2428
+ const completionUid = create$8();
2427
2429
  const widget = {
2428
2430
  id: ColorPicker$1,
2429
2431
  oldState: {
@@ -2452,11 +2454,11 @@ const create$6 = () => {
2452
2454
  return widget;
2453
2455
  };
2454
2456
 
2455
- const newStateGenerator$1 = state => {
2457
+ const newStateGenerator$2 = state => {
2456
2458
  return loadContent$3(state);
2457
2459
  };
2458
2460
  const openColorPicker = async editor => {
2459
- return addWidgetToEditor(ColorPicker$1, ColorPicker$2, editor, create$6, newStateGenerator$1);
2461
+ return addWidgetToEditor(ColorPicker$1, ColorPicker$2, editor, create$7, newStateGenerator$2);
2460
2462
  };
2461
2463
 
2462
2464
  const state$6 = {
@@ -2753,7 +2755,7 @@ const characterLeft = (line, columnIndex) => {
2753
2755
  if (!supported()) {
2754
2756
  return 1;
2755
2757
  }
2756
- const segmenter = create$8();
2758
+ const segmenter = create$9();
2757
2759
  const last = segmenter.at(line, columnIndex - 1);
2758
2760
  return columnIndex - last.index;
2759
2761
  };
@@ -2764,7 +2766,7 @@ const characterRight = (line, columnIndex) => {
2764
2766
  if (!supported()) {
2765
2767
  return 1;
2766
2768
  }
2767
- const segmenter = create$8();
2769
+ const segmenter = create$9();
2768
2770
  const next = segmenter.at(line, columnIndex);
2769
2771
  return next.segment.length;
2770
2772
  };
@@ -3349,7 +3351,9 @@ const UiStrings$1 = {
3349
3351
  SourceAction: 'Source Action',
3350
3352
  OrganizeImports: 'Organize Imports',
3351
3353
  SortImports: 'Sort Imports',
3352
- NoCodeActionsAvailable: 'No code actions available'
3354
+ NoCodeActionsAvailable: 'No code actions available',
3355
+ EscapeToClose: 'Escape to close',
3356
+ EnterCode: 'Enter Code'
3353
3357
  };
3354
3358
  const noDefinitionFound = () => {
3355
3359
  return i18nString(UiStrings$1.NoDefinitionFound);
@@ -3376,6 +3380,12 @@ const sourceAction = () => {
3376
3380
  const noCodeActionsAvailable = () => {
3377
3381
  return i18nString(UiStrings$1.NoCodeActionsAvailable);
3378
3382
  };
3383
+ const escapeToClose = () => {
3384
+ return i18nString(UiStrings$1.EscapeToClose);
3385
+ };
3386
+ const enterCode = () => {
3387
+ return i18nString(UiStrings$1.EnterCode);
3388
+ };
3379
3389
 
3380
3390
  // @ts-ignore
3381
3391
  const goTo = async ({
@@ -4515,8 +4525,8 @@ const moveSelectionPx = (editor, x, y) => {
4515
4525
  return editorMoveSelection(editor, position);
4516
4526
  };
4517
4527
 
4518
- const create$5 = () => {
4519
- const completionUid = create$7();
4528
+ const create$6 = () => {
4529
+ const completionUid = create$8();
4520
4530
  const completionWidget = {
4521
4531
  id: Completion,
4522
4532
  oldState: {
@@ -5031,7 +5041,7 @@ const openCompletion = async editor => {
5031
5041
  if (hasWidget(widgets, Completion)) {
5032
5042
  return editor;
5033
5043
  }
5034
- const completionWidget = create$5();
5044
+ const completionWidget = create$6();
5035
5045
  const newWidgets = [...widgets, completionWidget];
5036
5046
  const newEditor = {
5037
5047
  ...editor,
@@ -5060,8 +5070,8 @@ const User = 1;
5060
5070
  const Script = 2;
5061
5071
  const Unknown$1 = 0;
5062
5072
 
5063
- const create$4 = () => {
5064
- const uid = create$7();
5073
+ const create$5 = () => {
5074
+ const uid = create$8();
5065
5075
  const widget = {
5066
5076
  id: Find,
5067
5077
  oldState: {
@@ -5466,7 +5476,7 @@ const openFind2 = async editor => {
5466
5476
  return latestState;
5467
5477
  };
5468
5478
  const fullFocus = true;
5469
- return addWidgetToEditor(Find, FindWidget, editor, create$4, newStateGenerator, fullFocus);
5479
+ return addWidgetToEditor(Find, FindWidget, editor, create$5, newStateGenerator, fullFocus);
5470
5480
  };
5471
5481
 
5472
5482
  const openFind = async state => {
@@ -5488,8 +5498,8 @@ const getRenamePosition = editor => {
5488
5498
  };
5489
5499
  };
5490
5500
 
5491
- const create$3 = () => {
5492
- const completionUid = create$7();
5501
+ const create$4 = () => {
5502
+ const completionUid = create$8();
5493
5503
  const renameWidget = {
5494
5504
  id: Rename,
5495
5505
  oldState: {
@@ -5549,7 +5559,7 @@ const openRename = async editor => {
5549
5559
  return latestState;
5550
5560
  };
5551
5561
  const fullFocus = true;
5552
- return addWidgetToEditor(Rename, FocusEditorRename, editor, create$3, newStateGenerator, fullFocus);
5562
+ return addWidgetToEditor(Rename, FocusEditorRename, editor, create$4, newStateGenerator, fullFocus);
5553
5563
  };
5554
5564
 
5555
5565
  const organizeImports = async editor => {
@@ -6437,8 +6447,8 @@ const showHover = async state => {
6437
6447
  return state;
6438
6448
  };
6439
6449
 
6440
- const create$2 = () => {
6441
- const uid = create$7();
6450
+ const create$3 = () => {
6451
+ const uid = create$8();
6442
6452
  const widget = {
6443
6453
  id: Hover,
6444
6454
  oldState: {
@@ -6491,7 +6501,7 @@ const getHover = async (editor, offset) => {
6491
6501
 
6492
6502
  let _ipc;
6493
6503
  const listen$5 = async () => {
6494
- const ipc = await create$9({
6504
+ const ipc = await create$a({
6495
6505
  method: RendererProcess
6496
6506
  });
6497
6507
  handleIpc(ipc);
@@ -6703,11 +6713,11 @@ const loadHoverContent = async state => {
6703
6713
  };
6704
6714
  };
6705
6715
 
6706
- const newStateGenerator = state => {
6716
+ const newStateGenerator$1 = state => {
6707
6717
  return loadHoverContent(state);
6708
6718
  };
6709
6719
  const showHover2 = async editor => {
6710
- return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6720
+ return addWidgetToEditor(Hover, FocusEditorHover, editor, create$3, newStateGenerator$1);
6711
6721
  };
6712
6722
 
6713
6723
  // TODO ask extension host worker instead
@@ -6760,8 +6770,8 @@ const loadSourceActions = async (editor, state) => {
6760
6770
  };
6761
6771
  };
6762
6772
 
6763
- const create$1 = () => {
6764
- const completionUid = create$7();
6773
+ const create$2 = () => {
6774
+ const completionUid = create$8();
6765
6775
  const widget = {
6766
6776
  id: SourceAction,
6767
6777
  oldState: {
@@ -6792,7 +6802,7 @@ const showSourceActions = async editor => {
6792
6802
  const newStateGenerator = state => {
6793
6803
  return loadSourceActions(editor, state);
6794
6804
  };
6795
- return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
6805
+ return addWidgetToEditor(SourceAction, SourceActions, editor, create$2, newStateGenerator);
6796
6806
  };
6797
6807
 
6798
6808
  const compareString = (a, b) => {
@@ -7669,8 +7679,8 @@ const handelWheel = (state, deltaMode, deltaY) => {
7669
7679
  return newState;
7670
7680
  };
7671
7681
 
7672
- const create = () => {
7673
- const completionUid = create$7();
7682
+ const create$1 = () => {
7683
+ const completionUid = create$8();
7674
7684
  const completionWidget = {
7675
7685
  id: CompletionDetail,
7676
7686
  oldState: {
@@ -7723,7 +7733,7 @@ const openDetails = editor => {
7723
7733
  };
7724
7734
  return newestState;
7725
7735
  };
7726
- return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
7736
+ return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create$1, newStateGenerator);
7727
7737
  };
7728
7738
 
7729
7739
  const getEdits = async (editor, completionItem) => {
@@ -7852,6 +7862,8 @@ const handleSashPointerUp = (state, eventX, eventY) => {
7852
7862
  return state;
7853
7863
  };
7854
7864
 
7865
+ const CodeGeneratorInput = 'CodeGeneratorInput';
7866
+ const CodeGeneratorWidget = 'CodeGeneratorWidget';
7855
7867
  const ColoredMaskIcon = 'ColoredMaskIcon';
7856
7868
  const ColorPicker = 'ColorPicker';
7857
7869
  const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
@@ -7860,20 +7872,10 @@ const ColorPickerLight = 'ColorPickerLight';
7860
7872
  const ColorPickerRectangle = 'ColorPickerRectangle';
7861
7873
  const ColorPickerSlider = 'ColorPickerSlider';
7862
7874
  const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7863
- const SourceActionItem = 'SourceActionItem';
7864
- const SourceActionItemFocused = 'SourceActionItemFocused';
7875
+ const CodeGeneratorMessage = 'CodeGeneratorMessage';
7865
7876
  const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7866
- const EditorSourceActionsList = 'EditorSourceActionsList';
7867
- const IconButtonDisabled = 'IconButtonDisabled';
7868
- const IconButton = 'IconButton';
7869
- const SourceActionHeading = 'SourceActionHeading';
7870
7877
  const CompletionDetailContent = 'CompletionDetailContent';
7871
7878
  const Diagnostic = 'Diagnostic';
7872
- const FindWidgetReplace = 'FindWidgetReplace';
7873
- const FindWidgetFind = 'FindWidgetFind';
7874
- const FindWidgetMatchCount = 'FindWidgetMatchCount';
7875
- const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7876
- const FindWidgetRight = 'FindWidgetRight';
7877
7879
  const EditorCompletionItem = 'EditorCompletionItem';
7878
7880
  const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
7879
7881
  const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
@@ -7881,19 +7883,32 @@ const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
7881
7883
  const EditorCursor = 'EditorCursor';
7882
7884
  const EditorRow = 'EditorRow';
7883
7885
  const EditorSelection = 'EditorSelection';
7886
+ const EditorSourceActions = 'EditorSourceActions';
7887
+ const EditorSourceActionsList = 'EditorSourceActionsList';
7884
7888
  const FileIcon = 'FileIcon';
7889
+ const FindWidgetFind = 'FindWidgetFind';
7890
+ const FindWidgetMatchCount = 'FindWidgetMatchCount';
7891
+ const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7892
+ const FindWidgetReplace = 'FindWidgetReplace';
7893
+ const FindWidgetRight = 'FindWidgetRight';
7885
7894
  const HoverDisplayString = 'HoverDisplayString';
7886
7895
  const HoverDocumentation = 'HoverDocumentation';
7887
- const SearchFieldButtons = 'SearchFieldButtons';
7888
7896
  const HoverEditorRow = 'HoverEditorRow';
7889
- const MultilineInputBox = 'MultilineInputBox';
7890
- const SearchField = 'SearchField';
7891
7897
  const HoverProblem = 'HoverProblem';
7892
7898
  const HoverProblemDetail = 'HoverProblemDetail';
7893
7899
  const HoverProblemMessage = 'HoverProblemMessage';
7900
+ const IconButton = 'IconButton';
7901
+ const IconButtonDisabled = 'IconButtonDisabled';
7894
7902
  const IconClose = 'IconClose';
7903
+ const InputBox = 'InputBox';
7895
7904
  const Label = 'Label';
7896
7905
  const MaskIcon = 'MaskIcon';
7906
+ const MultilineInputBox = 'MultilineInputBox';
7907
+ const SearchField = 'SearchField';
7908
+ const SearchFieldButtons = 'SearchFieldButtons';
7909
+ const SourceActionHeading = 'SourceActionHeading';
7910
+ const SourceActionItem = 'SourceActionItem';
7911
+ const SourceActionItemFocused = 'SourceActionItemFocused';
7897
7912
  const Viewlet = 'Viewlet';
7898
7913
 
7899
7914
  const Button = 1;
@@ -8012,6 +8027,8 @@ const SetNegativeMargin = 'setNegativeMargin';
8012
8027
  const SetOffsetX = 'setOffsetX';
8013
8028
  const SetScrollBar = 'setScrollBar';
8014
8029
  const SetValue = 'setValue';
8030
+ const SetDom2 = 'Viewlet.setDom2';
8031
+ const Focus = 'focus';
8015
8032
 
8016
8033
  const renderHoverDom = {
8017
8034
  isEqual(oldState, newState) {
@@ -8019,10 +8036,10 @@ const renderHoverDom = {
8019
8036
  },
8020
8037
  apply(oldState, newState) {
8021
8038
  const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
8022
- return [/* method */'Viewlet.setDom2', dom];
8039
+ return [/* method */SetDom2, dom];
8023
8040
  }
8024
8041
  };
8025
- const renderBounds$6 = {
8042
+ const renderBounds$7 = {
8026
8043
  isEqual(oldState, newState) {
8027
8044
  return oldState.x === newState.x && oldState.y === newState.y;
8028
8045
  },
@@ -8036,10 +8053,10 @@ const renderBounds$6 = {
8036
8053
  return [SetBounds, x, y, renderWidth, height];
8037
8054
  }
8038
8055
  };
8039
- const render$e = [renderHoverDom, renderBounds$6];
8056
+ const render$g = [renderHoverDom, renderBounds$7];
8040
8057
  const renderHover = (oldState, newState) => {
8041
8058
  const commands = [];
8042
- for (const item of render$e) {
8059
+ for (const item of render$g) {
8043
8060
  if (!item.isEqual(oldState, newState)) {
8044
8061
  commands.push(item.apply(oldState, newState));
8045
8062
  }
@@ -8333,6 +8350,49 @@ const moveLineDown = editor => {
8333
8350
  undefined(editor, documentEdits, cursorEdits);
8334
8351
  };
8335
8352
 
8353
+ const create = () => {
8354
+ const completionUid = create$8();
8355
+ const widget = {
8356
+ id: CodeGenerator,
8357
+ oldState: {
8358
+ uid: completionUid,
8359
+ questions: [],
8360
+ x: 0,
8361
+ y: 0,
8362
+ width: 0,
8363
+ height: 0,
8364
+ focused: false,
8365
+ focusSource: Unknown$1
8366
+ },
8367
+ newState: {
8368
+ uid: completionUid,
8369
+ questions: [],
8370
+ x: 0,
8371
+ y: 0,
8372
+ width: 0,
8373
+ height: 0,
8374
+ focused: true,
8375
+ focusSource: Script
8376
+ }
8377
+ };
8378
+ return widget;
8379
+ };
8380
+
8381
+ const newStateGenerator = async state => {
8382
+ const latestState = {
8383
+ ...state,
8384
+ x: 100,
8385
+ y: 100,
8386
+ width: 150,
8387
+ height: 45
8388
+ };
8389
+ return latestState;
8390
+ };
8391
+ const openCodeGenerator = async editor => {
8392
+ const fullFocus = true;
8393
+ return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create, newStateGenerator, fullFocus);
8394
+ };
8395
+
8336
8396
  // TODO handle multiple cursors
8337
8397
  const moveLineUp = editor => {
8338
8398
  const rowIndex = editor.cursor.rowIndex;
@@ -9045,7 +9105,7 @@ const renderScrollBarX = {
9045
9105
  return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
9046
9106
  }
9047
9107
  };
9048
- const renderFocus$2 = {
9108
+ const renderFocus$3 = {
9049
9109
  isEqual(oldState, newState) {
9050
9110
  return oldState.focused === newState.focused;
9051
9111
  },
@@ -9143,7 +9203,7 @@ const renderWidgets = {
9143
9203
  },
9144
9204
  multiple: true
9145
9205
  };
9146
- const render$d = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$2, renderDecorations, renderGutterInfo, renderWidgets];
9206
+ const render$f = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$3, renderDecorations, renderGutterInfo, renderWidgets];
9147
9207
  const renderEditor = async id => {
9148
9208
  const instance = get$6(id);
9149
9209
  if (!instance) {
@@ -9155,7 +9215,7 @@ const renderEditor = async id => {
9155
9215
  } = instance;
9156
9216
  const commands = [];
9157
9217
  set$6(id, newState, newState);
9158
- for (const item of render$d) {
9218
+ for (const item of render$f) {
9159
9219
  if (!item.isEqual(oldState, newState)) {
9160
9220
  const result = await item.apply(oldState, newState);
9161
9221
  // @ts-ignore
@@ -9169,6 +9229,24 @@ const renderEditor = async id => {
9169
9229
  return commands;
9170
9230
  };
9171
9231
 
9232
+ const isMatchingWidget = widget => {
9233
+ return widget.id === CodeGenerator;
9234
+ };
9235
+ const closeCodeGenerator = editor => {
9236
+ const {
9237
+ widgets
9238
+ } = editor;
9239
+ const index = widgets.findIndex(isMatchingWidget);
9240
+ if (index === -1) {
9241
+ return editor;
9242
+ }
9243
+ const newWidgets = removeEditorWidget(widgets, CodeGenerator);
9244
+ return {
9245
+ ...editor,
9246
+ widgets: newWidgets
9247
+ };
9248
+ };
9249
+
9172
9250
  const keep = [
9173
9251
  // 'ColorPicker.handleSliderPointerDown',
9174
9252
  // 'ColorPicker.handleSliderPointerMove',
@@ -9256,6 +9334,7 @@ const commandMap = {
9256
9334
  'Editor.applyEdit': applyEdit,
9257
9335
  'Editor.braceCompletion': braceCompletion,
9258
9336
  'Editor.cancelSelection': cancelSelection,
9337
+ 'Editor.closeCodeGenerator': closeCodeGenerator,
9259
9338
  'Editor.closeCompletion': closeCompletion,
9260
9339
  'Editor.closeFind': closeFind,
9261
9340
  'Editor.closeRename': closeRename,
@@ -9336,6 +9415,7 @@ const commandMap = {
9336
9415
  'Editor.moveSelection': editorMoveSelection,
9337
9416
  'Editor.moveSelectionPx': moveSelectionPx,
9338
9417
  'Editor.offsetAt': offsetAt,
9418
+ 'Editor.openCodeGenerator': openCodeGenerator,
9339
9419
  'Editor.openColorPicker': openColorPicker,
9340
9420
  'Editor.openCompletion': openCompletion,
9341
9421
  'Editor.openFind': openFind,
@@ -9945,10 +10025,103 @@ const addWidget = (widget, id, render) => {
9945
10025
  return allCommands;
9946
10026
  };
9947
10027
 
10028
+ const removeWidget = widget => {
10029
+ // @ts-ignore
10030
+ return [['Viewlet.send', widget.newState.uid, 'dispose']];
10031
+ };
10032
+
9948
10033
  const mergeClassNames = (...classNames) => {
9949
10034
  return classNames.filter(Boolean).join(' ');
9950
10035
  };
9951
10036
 
10037
+ const getCodeGeneratorVirtualDom = state => {
10038
+ const escapeToClose$1 = escapeToClose();
10039
+ const enterCode$1 = enterCode();
10040
+ return [{
10041
+ type: Div,
10042
+ className: mergeClassNames(Viewlet, CodeGeneratorWidget),
10043
+ childCount: 2
10044
+ }, {
10045
+ type: Input,
10046
+ className: mergeClassNames(CodeGeneratorInput, InputBox),
10047
+ childCount: 0,
10048
+ placeholder: enterCode$1,
10049
+ name: 'CodeGeneratorInput'
10050
+ }, {
10051
+ type: Div,
10052
+ className: CodeGeneratorMessage,
10053
+ childCount: 1
10054
+ }, text(escapeToClose$1)];
10055
+ };
10056
+
10057
+ const renderContent$3 = {
10058
+ isEqual(oldState, newState) {
10059
+ return oldState.questions === newState.questions;
10060
+ },
10061
+ apply(oldState, newState) {
10062
+ const dom = getCodeGeneratorVirtualDom();
10063
+ return [SetDom2, newState.uid, dom];
10064
+ }
10065
+ };
10066
+ const renderBounds$6 = {
10067
+ isEqual(oldState, newState) {
10068
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10069
+ },
10070
+ apply(oldState, newState) {
10071
+ const {
10072
+ x,
10073
+ y,
10074
+ width,
10075
+ height
10076
+ } = newState;
10077
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10078
+ }
10079
+ };
10080
+ const renderFocus$2 = {
10081
+ isEqual(oldState, newState) {
10082
+ return oldState.focused === newState.focused && oldState.focusSource === newState.focusSource;
10083
+ },
10084
+ apply(oldState, newState) {
10085
+ return [Focus, '.CodeGeneratorInput', newState.focusSource];
10086
+ }
10087
+ };
10088
+ const render$e = [renderContent$3, renderBounds$6, renderFocus$2];
10089
+ const renderFull$3 = (oldState, newState) => {
10090
+ const commands = [];
10091
+ for (const item of render$e) {
10092
+ if (!item.isEqual(oldState, newState)) {
10093
+ commands.push(item.apply(oldState, newState));
10094
+ }
10095
+ }
10096
+ return commands;
10097
+ };
10098
+
10099
+ const render$d = widget => {
10100
+ const commands = renderFull$3(widget.oldState, widget.newState);
10101
+ const wrappedCommands = [];
10102
+ const uid = widget.newState.uid;
10103
+ for (const command of commands) {
10104
+ if (command[0] === SetDom2) {
10105
+ wrappedCommands.push(command);
10106
+ } else {
10107
+ // @ts-ignore
10108
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
10109
+ }
10110
+ }
10111
+ return wrappedCommands;
10112
+ };
10113
+ const add$7 = widget => {
10114
+ return addWidget(widget, 'EditorCodeGenerator', render$d);
10115
+ };
10116
+ const remove$7 = removeWidget;
10117
+
10118
+ const EditorCodeGeneratorWidget = {
10119
+ __proto__: null,
10120
+ add: add$7,
10121
+ remove: remove$7,
10122
+ render: render$d
10123
+ };
10124
+
9952
10125
  const getColorPickerVirtualDom = () => {
9953
10126
  return [{
9954
10127
  type: Div,
@@ -10004,7 +10177,7 @@ const renderContent$2 = {
10004
10177
  },
10005
10178
  apply(oldState, newState) {
10006
10179
  const dom = getColorPickerVirtualDom();
10007
- return ['Viewlet.setDom2', newState.uid, dom];
10180
+ return [SetDom2, newState.uid, dom];
10008
10181
  }
10009
10182
  };
10010
10183
  const renderBounds$5 = {
@@ -10032,17 +10205,12 @@ const renderFull$2 = (oldState, newState) => {
10032
10205
  return commands;
10033
10206
  };
10034
10207
 
10035
- const removeWidget = widget => {
10036
- // @ts-ignore
10037
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
10038
- };
10039
-
10040
10208
  const render$b = widget => {
10041
10209
  const commands = renderFull$2(widget.oldState, widget.newState);
10042
10210
  const wrappedCommands = [];
10043
10211
  const uid = widget.newState.uid;
10044
10212
  for (const command of commands) {
10045
- if (command[0] === 'Viewlet.setDom2') {
10213
+ if (command[0] === SetDom2) {
10046
10214
  wrappedCommands.push(command);
10047
10215
  } else {
10048
10216
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10105,7 +10273,7 @@ const renderContent$1 = {
10105
10273
  },
10106
10274
  apply(oldState, newState) {
10107
10275
  const dom = getCompletionDetailVirtualDom(newState.content);
10108
- return ['Viewlet.setDom2', newState.uid, dom];
10276
+ return [SetDom2, newState.uid, dom];
10109
10277
  }
10110
10278
  };
10111
10279
  const renderBounds$4 = {
@@ -10132,7 +10300,7 @@ const render$9 = widget => {
10132
10300
  const wrappedCommands = [];
10133
10301
  const uid = widget.newState.uid;
10134
10302
  for (const command of commands) {
10135
- if (command[0] === 'Viewlet.setDom2') {
10303
+ if (command[0] === SetDom2) {
10136
10304
  wrappedCommands.push(command);
10137
10305
  } else {
10138
10306
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10848,7 +11016,7 @@ const renderDetails = {
10848
11016
  replaceButtons
10849
11017
  } = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled);
10850
11018
  const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount, newState.value);
10851
- return ['Viewlet.setDom2', dom];
11019
+ return [SetDom2, dom];
10852
11020
  }
10853
11021
  };
10854
11022
  const renderBounds$2 = {
@@ -10871,7 +11039,7 @@ const renderFocus$1 = {
10871
11039
  },
10872
11040
  apply(oldState, newState) {
10873
11041
  const key = getFindWidgetFocusSelector(newState.focus);
10874
- return ['focus', key, newState.focusSource];
11042
+ return [Focus, key, newState.focusSource];
10875
11043
  }
10876
11044
  };
10877
11045
  // const getAriaLabel = (state: FindWidgetState) => {
@@ -10908,7 +11076,7 @@ const render$5 = widget => {
10908
11076
  const wrappedCommands = [];
10909
11077
  const uid = widget.newState.uid;
10910
11078
  for (const command of commands) {
10911
- if (command[0] === 'Viewlet.setDom2') {
11079
+ if (command[0] === SetDom2) {
10912
11080
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10913
11081
  } else {
10914
11082
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10944,7 +11112,7 @@ const render$4 = widget => {
10944
11112
  const wrappedCommands = [];
10945
11113
  const uid = widget.newState.uid;
10946
11114
  for (const command of commands) {
10947
- if (command[0] === 'Viewlet.setDom2') {
11115
+ if (command[0] === SetDom2) {
10948
11116
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10949
11117
  } else {
10950
11118
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10984,7 +11152,7 @@ const renderContent = {
10984
11152
  },
10985
11153
  apply(oldState, newState) {
10986
11154
  const dom = getRenameVirtualDom(newState);
10987
- return ['Viewlet.setDom2', newState.uid, dom];
11155
+ return [SetDom2, newState.uid, dom];
10988
11156
  }
10989
11157
  };
10990
11158
  const renderBounds$1 = {
@@ -11019,7 +11187,7 @@ const render$2 = widget => {
11019
11187
  const wrappedCommands = [];
11020
11188
  const uid = widget.newState.uid;
11021
11189
  for (const command of commands) {
11022
- if (command[0] === 'Viewlet.setDom2') {
11190
+ if (command[0] === SetDom2) {
11023
11191
  wrappedCommands.push(command);
11024
11192
  } else if (command[0] === 'Viewlet.focusSelector') {
11025
11193
  wrappedCommands.push(command);
@@ -11041,28 +11209,6 @@ const EditorRenameWidget = {
11041
11209
  render: render$2
11042
11210
  };
11043
11211
 
11044
- const getActionClassName = isFocused => {
11045
- if (isFocused) {
11046
- return mergeClassNames(SourceActionItem, SourceActionItemFocused);
11047
- }
11048
- return SourceActionItem;
11049
- };
11050
- const getSourceActionListItemVirtualDom = sourceAction => {
11051
- const {
11052
- name,
11053
- isFocused
11054
- } = sourceAction;
11055
- const actionClassName = getActionClassName(isFocused);
11056
- return [{
11057
- type: Div,
11058
- className: actionClassName,
11059
- childCount: 2
11060
- }, {
11061
- type: Div,
11062
- className: 'SourceActionIcon MaskIcon MaskIconSymbolFile'
11063
- }, text(name)];
11064
- };
11065
-
11066
11212
  const getEditorMessageVirtualDom = message => {
11067
11213
  const dom = [{
11068
11214
  type: Div,
@@ -11085,13 +11231,35 @@ const getEmptySourceActionsVirtualDom = () => {
11085
11231
  return getEditorMessageVirtualDom(noCodeActionsAvailable());
11086
11232
  };
11087
11233
 
11234
+ const getActionClassName = isFocused => {
11235
+ if (isFocused) {
11236
+ return mergeClassNames(SourceActionItem, SourceActionItemFocused);
11237
+ }
11238
+ return SourceActionItem;
11239
+ };
11240
+ const getSourceActionListItemVirtualDom = sourceAction => {
11241
+ const {
11242
+ name,
11243
+ isFocused
11244
+ } = sourceAction;
11245
+ const actionClassName = getActionClassName(isFocused);
11246
+ return [{
11247
+ type: Div,
11248
+ className: actionClassName,
11249
+ childCount: 2
11250
+ }, {
11251
+ type: Div,
11252
+ className: 'SourceActionIcon MaskIcon MaskIconSymbolFile'
11253
+ }, text(name)];
11254
+ };
11255
+
11088
11256
  const getSourceActionsVirtualDom = sourceActions => {
11089
11257
  if (sourceActions.length === 0) {
11090
11258
  return getEmptySourceActionsVirtualDom();
11091
11259
  }
11092
11260
  const dom = [{
11093
11261
  type: Div,
11094
- className: 'Viewlet EditorSourceActions',
11262
+ className: mergeClassNames(Viewlet, EditorSourceActions),
11095
11263
  tabIndex: -1,
11096
11264
  childCount: 2,
11097
11265
  onFocusIn: HandleFocusIn
@@ -11128,7 +11296,7 @@ const renderSourceActions = {
11128
11296
  apply(oldStatem, newState) {
11129
11297
  const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
11130
11298
  const dom = getSourceActionsVirtualDom(visible);
11131
- return ['Viewlet.setDom2', newState.uid, dom];
11299
+ return [SetDom2, newState.uid, dom];
11132
11300
  }
11133
11301
  };
11134
11302
  const renderBounds = {
@@ -11136,7 +11304,7 @@ const renderBounds = {
11136
11304
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
11137
11305
  },
11138
11306
  apply(oldState, newState) {
11139
- return ['setBounds', newState.x, newState.y, newState.width, newState.height];
11307
+ return [SetBounds, newState.x, newState.y, newState.width, newState.height];
11140
11308
  }
11141
11309
  };
11142
11310
  const render$1 = [renderSourceActions, renderBounds];
@@ -11155,7 +11323,7 @@ const render = widget => {
11155
11323
  const wrappedCommands = [];
11156
11324
  const uid = widget.newState.uid;
11157
11325
  for (const command of commands) {
11158
- if (command[0] === 'Viewlet.setDom2') {
11326
+ if (command[0] === SetDom2) {
11159
11327
  wrappedCommands.push(command);
11160
11328
  } else {
11161
11329
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -11183,6 +11351,7 @@ const registerWidgets = () => {
11183
11351
  set$7(Hover, EditorHoverWidget);
11184
11352
  set$7(Rename, EditorRenameWidget);
11185
11353
  set$7(SourceAction, EditorSourceActionWidget);
11354
+ set$7(CodeGenerator, EditorCodeGeneratorWidget);
11186
11355
  };
11187
11356
 
11188
11357
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",