@lvce-editor/editor-worker 4.0.0 → 4.2.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.
@@ -1080,7 +1080,7 @@ const set$5 = (id, fn) => {
1080
1080
  const get$5 = id => {
1081
1081
  return state$1$1.callbacks[id];
1082
1082
  };
1083
- const remove$6 = id => {
1083
+ const remove$7 = id => {
1084
1084
  delete state$1$1.callbacks[id];
1085
1085
  };
1086
1086
  const state$9 = {
@@ -1126,7 +1126,7 @@ const resolve = (id, args) => {
1126
1126
  return;
1127
1127
  }
1128
1128
  fn(args);
1129
- remove$6(id);
1129
+ remove$7(id);
1130
1130
  };
1131
1131
  const create$2$1 = (method, params) => {
1132
1132
  const {
@@ -1318,7 +1318,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
1318
1318
  const errorProperty = getErrorProperty(error, prettyError);
1319
1319
  return create$1$1(message, errorProperty);
1320
1320
  };
1321
- const create$c = (message, result) => {
1321
+ const create$d = (message, result) => {
1322
1322
  return {
1323
1323
  jsonrpc: Two,
1324
1324
  id: message.id,
@@ -1327,7 +1327,7 @@ const create$c = (message, result) => {
1327
1327
  };
1328
1328
  const getSuccessResponse = (message, result) => {
1329
1329
  const resultProperty = result ?? null;
1330
- return create$c(message, resultProperty);
1330
+ return create$d(message, resultProperty);
1331
1331
  };
1332
1332
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1333
1333
  try {
@@ -1527,7 +1527,7 @@ const waitForFirstMessage$1 = async port => {
1527
1527
  return event;
1528
1528
  };
1529
1529
 
1530
- const create$b = async () => {
1530
+ const create$c = async () => {
1531
1531
  const {
1532
1532
  port1,
1533
1533
  port2
@@ -1572,7 +1572,7 @@ const wrap$3 = port => {
1572
1572
 
1573
1573
  const IpcParentWithExtensionHostWorker = {
1574
1574
  __proto__: null,
1575
- create: create$b,
1575
+ create: create$c,
1576
1576
  wrap: wrap$3
1577
1577
  };
1578
1578
 
@@ -1580,7 +1580,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1580
1580
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1581
1581
  };
1582
1582
 
1583
- const create$a = async () => {
1583
+ const create$b = async () => {
1584
1584
  const {
1585
1585
  port1,
1586
1586
  port2
@@ -1625,7 +1625,7 @@ const wrap$1 = port => {
1625
1625
 
1626
1626
  const IpcParentWithSyntaxHighlightingWorker = {
1627
1627
  __proto__: null,
1628
- create: create$a,
1628
+ create: create$b,
1629
1629
  wrap: wrap$1
1630
1630
  };
1631
1631
 
@@ -1633,7 +1633,7 @@ const sendMessagePortToRendererProcess = async port => {
1633
1633
  await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1634
1634
  };
1635
1635
 
1636
- const create$9 = async () => {
1636
+ const create$a = async () => {
1637
1637
  const {
1638
1638
  port1,
1639
1639
  port2
@@ -1678,7 +1678,7 @@ const wrap = port => {
1678
1678
 
1679
1679
  const IpcParentWithRendererProcess = {
1680
1680
  __proto__: null,
1681
- create: create$9,
1681
+ create: create$a,
1682
1682
  wrap
1683
1683
  };
1684
1684
 
@@ -1695,7 +1695,7 @@ const getModule$1 = method => {
1695
1695
  }
1696
1696
  };
1697
1697
 
1698
- const create$8 = async ({
1698
+ const create$9 = async ({
1699
1699
  method,
1700
1700
  ...options
1701
1701
  }) => {
@@ -1713,7 +1713,7 @@ const create$8 = async ({
1713
1713
  const createRpc = method => {
1714
1714
  let _ipc;
1715
1715
  const listen = async () => {
1716
- const ipc = await create$8({
1716
+ const ipc = await create$9({
1717
1717
  method
1718
1718
  });
1719
1719
  handleIpc(ipc);
@@ -1990,7 +1990,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
1990
1990
  const supported = () => {
1991
1991
  return 'Segmenter' in Intl;
1992
1992
  };
1993
- const create$7 = () => {
1993
+ const create$8 = () => {
1994
1994
  // @ts-ignore
1995
1995
  const segmenter = new Intl.Segmenter();
1996
1996
  return {
@@ -2028,7 +2028,7 @@ const create$7 = () => {
2028
2028
 
2029
2029
  // @ts-ignore
2030
2030
  const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
2031
- const segmenter = create$7();
2031
+ const segmenter = create$8();
2032
2032
  const segments = segmenter.getSegments(line);
2033
2033
  const isMonospaceFont = false;
2034
2034
  const charWidth = 0;
@@ -2258,11 +2258,12 @@ const cancelSelection = editor => {
2258
2258
  };
2259
2259
 
2260
2260
  // TODO use numeric widget id
2261
+ const ColorPicker$2 = 'colorPicker';
2261
2262
  const Completion = 'completion';
2262
2263
  const CompletionDetail$1 = 'completionDetail';
2263
- const ColorPicker$2 = 'colorPicker';
2264
2264
  const Find = 'find';
2265
2265
  const Hover = 'hover';
2266
+ const Rename$1 = 'rename';
2266
2267
  const SourceAction = 'sourceAction';
2267
2268
 
2268
2269
  const isCompletionWidget = widget => {
@@ -2301,6 +2302,25 @@ const closeFind = editor => {
2301
2302
  };
2302
2303
  };
2303
2304
 
2305
+ // TODO duplicate code
2306
+ const isRenameWidget = widget => {
2307
+ return widget.id === Rename$1;
2308
+ };
2309
+ const closeRename = editor => {
2310
+ const {
2311
+ widgets
2312
+ } = editor;
2313
+ const renameWidgetIndex = widgets.findIndex(isRenameWidget);
2314
+ if (renameWidgetIndex === -1) {
2315
+ return editor;
2316
+ }
2317
+ const newWidgets = [...widgets.slice(0, renameWidgetIndex), ...widgets.slice(renameWidgetIndex + 1)];
2318
+ return {
2319
+ ...editor,
2320
+ widgets: newWidgets
2321
+ };
2322
+ };
2323
+
2304
2324
  const isMatchingWidget = widget => {
2305
2325
  return widget.id === SourceAction;
2306
2326
  };
@@ -2370,12 +2390,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
2370
2390
  return newEditor;
2371
2391
  };
2372
2392
 
2373
- const create$6 = () => {
2393
+ const create$7 = () => {
2374
2394
  return Math.random();
2375
2395
  };
2376
2396
 
2377
- const create$5 = () => {
2378
- const completionUid = create$6();
2397
+ const create$6 = () => {
2398
+ const completionUid = create$7();
2379
2399
  const widget = {
2380
2400
  id: ColorPicker$2,
2381
2401
  oldState: {
@@ -2418,12 +2438,13 @@ const FocusFindWidgetNextMatchButton = 49;
2418
2438
  const FocusFindWidgetPreviousMatchButton = 50;
2419
2439
  const FocusEditorHover = 51;
2420
2440
  const SourceActions = 38;
2441
+ const Rename = 999;
2421
2442
 
2422
2443
  const newStateGenerator$1 = state => {
2423
2444
  return loadContent$3(state);
2424
2445
  };
2425
2446
  const openColorPicker = async editor => {
2426
- return addWidgetToEditor(ColorPicker$2, ColorPicker$1, editor, create$5, newStateGenerator$1);
2447
+ return addWidgetToEditor(ColorPicker$2, ColorPicker$1, editor, create$6, newStateGenerator$1);
2427
2448
  };
2428
2449
 
2429
2450
  const state$6 = {
@@ -2720,7 +2741,7 @@ const characterLeft = (line, columnIndex) => {
2720
2741
  if (!supported()) {
2721
2742
  return 1;
2722
2743
  }
2723
- const segmenter = create$7();
2744
+ const segmenter = create$8();
2724
2745
  const last = segmenter.at(line, columnIndex - 1);
2725
2746
  return columnIndex - last.index;
2726
2747
  };
@@ -2731,7 +2752,7 @@ const characterRight = (line, columnIndex) => {
2731
2752
  if (!supported()) {
2732
2753
  return 1;
2733
2754
  }
2734
- const segmenter = create$7();
2755
+ const segmenter = create$8();
2735
2756
  const next = segmenter.at(line, columnIndex);
2736
2757
  return next.segment.length;
2737
2758
  };
@@ -4482,8 +4503,8 @@ const moveSelectionPx = (editor, x, y) => {
4482
4503
  return editorMoveSelection(editor, position);
4483
4504
  };
4484
4505
 
4485
- const create$4 = () => {
4486
- const completionUid = create$6();
4506
+ const create$5 = () => {
4507
+ const completionUid = create$7();
4487
4508
  const completionWidget = {
4488
4509
  id: Completion,
4489
4510
  oldState: {
@@ -4832,6 +4853,22 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
4832
4853
  return Math.min(totalHeight, maxHeight);
4833
4854
  };
4834
4855
 
4856
+ const getPositionAtCursor = editor => {
4857
+ const {
4858
+ selections
4859
+ } = editor;
4860
+ const rowIndex = selections[0];
4861
+ const columnIndex = selections[1];
4862
+ const x$1 = x(editor, rowIndex, columnIndex);
4863
+ const y$1 = y(editor, rowIndex);
4864
+ return {
4865
+ x: x$1,
4866
+ y: y$1,
4867
+ rowIndex,
4868
+ columnIndex
4869
+ };
4870
+ };
4871
+
4835
4872
  const RE_WORD = /[\w\-]+$/;
4836
4873
  const getWordAtOffset = editor => {
4837
4874
  const {
@@ -4934,11 +4971,12 @@ const loadContent$2 = async (editorUid, state) => {
4934
4971
  const unfilteredItems = await getCompletions(editor);
4935
4972
  const wordAtOffset = getWordAtOffset(editor);
4936
4973
  const items = filterCompletionItems(unfilteredItems, wordAtOffset);
4937
- const rowIndex = editor.selections[0];
4938
- const columnIndex = editor.selections[1];
4939
- const x$1 = x(editor, rowIndex, columnIndex);
4940
- // @ts-ignore
4941
- const y$1 = y(editor, rowIndex);
4974
+ const {
4975
+ rowIndex,
4976
+ columnIndex,
4977
+ x,
4978
+ y
4979
+ } = getPositionAtCursor(editor);
4942
4980
  const newMaxLineY = Math.min(items.length, 8);
4943
4981
  editor.widgets = editor.widgets || [];
4944
4982
  // editor.widgets.push(ViewletModuleId.EditorCompletion)
@@ -4951,8 +4989,8 @@ const loadContent$2 = async (editorUid, state) => {
4951
4989
  ...state,
4952
4990
  unfilteredItems,
4953
4991
  items,
4954
- x: x$1,
4955
- y: y$1,
4992
+ x,
4993
+ y,
4956
4994
  maxLineY: newMaxLineY,
4957
4995
  focusedIndex: newFocusedIndex,
4958
4996
  finalDeltaY,
@@ -4980,7 +5018,7 @@ const openCompletion = async editor => {
4980
5018
  if (hasWidget(widgets, Completion)) {
4981
5019
  return editor;
4982
5020
  }
4983
- const completionWidget = create$4();
5021
+ const completionWidget = create$5();
4984
5022
  const newWidgets = [...widgets, completionWidget];
4985
5023
  const newEditor = {
4986
5024
  ...editor,
@@ -5009,8 +5047,8 @@ const User = 1;
5009
5047
  const Script = 2;
5010
5048
  const Unknown$1 = 0;
5011
5049
 
5012
- const create$3 = () => {
5013
- const uid = create$6();
5050
+ const create$4 = () => {
5051
+ const uid = create$7();
5014
5052
  const widget = {
5015
5053
  id: Find,
5016
5054
  oldState: {
@@ -5415,13 +5453,92 @@ const openFind2 = async editor => {
5415
5453
  return latestState;
5416
5454
  };
5417
5455
  const fullFocus = true;
5418
- return addWidgetToEditor(Find, FindWidget, editor, create$3, newStateGenerator, fullFocus);
5456
+ return addWidgetToEditor(Find, FindWidget, editor, create$4, newStateGenerator, fullFocus);
5419
5457
  };
5420
5458
 
5421
5459
  const openFind = async state => {
5422
5460
  return openFind2(state);
5423
5461
  };
5424
5462
 
5463
+ const getRenamePosition = editor => {
5464
+ const width = 300;
5465
+ const height = 30;
5466
+ const paddingTop = 10;
5467
+ const cursor = getPositionAtCursor(editor);
5468
+ const x = cursor.x;
5469
+ const y = cursor.y + paddingTop;
5470
+ return {
5471
+ y,
5472
+ x,
5473
+ width,
5474
+ height
5475
+ };
5476
+ };
5477
+
5478
+ const create$3 = () => {
5479
+ const completionUid = create$7();
5480
+ const renameWidget = {
5481
+ id: Rename$1,
5482
+ oldState: {
5483
+ uid: completionUid,
5484
+ focusedIndex: -1,
5485
+ oldValue: '',
5486
+ newValue: '',
5487
+ focused: false,
5488
+ x: 0,
5489
+ y: 0,
5490
+ width: 0,
5491
+ height: 0
5492
+ },
5493
+ newState: {
5494
+ uid: completionUid,
5495
+ focusedIndex: -1,
5496
+ oldValue: '',
5497
+ newValue: '',
5498
+ focused: false,
5499
+ x: 0,
5500
+ y: 0,
5501
+ width: 0,
5502
+ height: 0
5503
+ }
5504
+ };
5505
+ return renameWidget;
5506
+ };
5507
+
5508
+ const openRename = async editor => {
5509
+ const {
5510
+ rowIndex,
5511
+ columnIndex
5512
+ } = getPositionAtCursor(editor);
5513
+ const {
5514
+ word
5515
+ } = getWordAt(editor, rowIndex, columnIndex);
5516
+ if (!word) {
5517
+ return editor;
5518
+ }
5519
+ const newStateGenerator = async state => {
5520
+ // TODO query if can rename from extension host
5521
+ const {
5522
+ x,
5523
+ y,
5524
+ width,
5525
+ height
5526
+ } = getRenamePosition(editor);
5527
+ const latestState = {
5528
+ ...state,
5529
+ x,
5530
+ y,
5531
+ width,
5532
+ height,
5533
+ oldValue: word,
5534
+ newValue: word
5535
+ };
5536
+ return latestState;
5537
+ };
5538
+ const fullFocus = true;
5539
+ return addWidgetToEditor(Rename$1, Rename, editor, create$3, newStateGenerator, fullFocus);
5540
+ };
5541
+
5425
5542
  const organizeImports = async editor => {
5426
5543
  // TODO ask extension host worker directly
5427
5544
  const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
@@ -6308,7 +6425,7 @@ const showHover = async state => {
6308
6425
  };
6309
6426
 
6310
6427
  const create$2 = () => {
6311
- const uid = create$6();
6428
+ const uid = create$7();
6312
6429
  const widget = {
6313
6430
  id: Hover,
6314
6431
  oldState: {
@@ -6361,7 +6478,7 @@ const getHover = async (editor, offset) => {
6361
6478
 
6362
6479
  let _ipc;
6363
6480
  const listen$5 = async () => {
6364
- const ipc = await create$8({
6481
+ const ipc = await create$9({
6365
6482
  method: RendererProcess
6366
6483
  });
6367
6484
  handleIpc(ipc);
@@ -6580,42 +6697,51 @@ const showHover2 = async editor => {
6580
6697
  return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6581
6698
  };
6582
6699
 
6583
- const EditorSourceActions = 'EditorSourceActions';
6584
- const showSourceActions$1 = async editor => {
6585
- // TODO
6586
- // 1. hide hover, completions, color picker
6587
- // 2. query source actions from extension host
6588
- // 3. show source actions menu
6589
-
6590
- await invoke$3('Viewlet.openWidget', EditorSourceActions);
6591
- return editor;
6592
- };
6593
-
6594
- // TODO maybe ask extension host worker instead
6700
+ // TODO ask extension host worker instead
6595
6701
  const getEditorSourceActions = async () => {
6596
6702
  const sourceActions = await invoke$3('GetEditorSourceActions.getEditorSourceActions');
6597
6703
  return sourceActions;
6598
6704
  };
6599
6705
 
6600
- const loadSourceActions = async (editorUid, state) => {
6706
+ const getSourceActionWidgetPosition = editor => {
6707
+ const width = 300;
6708
+ const height = 150;
6709
+ const cursor = getPositionAtCursor(editor);
6710
+ const x = cursor.x;
6711
+ const y = cursor.y;
6712
+ return {
6713
+ x,
6714
+ y,
6715
+ width,
6716
+ height
6717
+ };
6718
+ };
6719
+
6720
+ const loadSourceActions = async (editor, state) => {
6601
6721
  // const editor = GetEditor.getEditor(editorUid)
6602
6722
  // TODO request source actions information from extensions
6603
6723
  const sourceActions = await getEditorSourceActions();
6604
6724
  // TODO avoid side effect
6725
+ const {
6726
+ x,
6727
+ y,
6728
+ width,
6729
+ height
6730
+ } = getSourceActionWidgetPosition(editor);
6605
6731
  return {
6606
6732
  ...state,
6607
6733
  sourceActions,
6608
- x: 200,
6609
- y: -200,
6610
- width: 250,
6611
- height: 150,
6734
+ x,
6735
+ y,
6736
+ width,
6737
+ height,
6612
6738
  maxHeight: 150,
6613
6739
  focusedIndex: 0
6614
6740
  };
6615
6741
  };
6616
6742
 
6617
6743
  const create$1 = () => {
6618
- const completionUid = create$6();
6744
+ const completionUid = create$7();
6619
6745
  const widget = {
6620
6746
  id: SourceAction,
6621
6747
  oldState: {
@@ -6643,9 +6769,8 @@ const create$1 = () => {
6643
6769
  };
6644
6770
 
6645
6771
  const showSourceActions = async editor => {
6646
- const uid = editor.uid;
6647
6772
  const newStateGenerator = state => {
6648
- return loadSourceActions(uid, state);
6773
+ return loadSourceActions(editor, state);
6649
6774
  };
6650
6775
  return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
6651
6776
  };
@@ -7525,7 +7650,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
7525
7650
  };
7526
7651
 
7527
7652
  const create = () => {
7528
- const completionUid = create$6();
7653
+ const completionUid = create$7();
7529
7654
  const completionWidget = {
7530
7655
  id: CompletionDetail$1,
7531
7656
  oldState: {
@@ -7755,6 +7880,7 @@ const Viewlet = 'Viewlet';
7755
7880
 
7756
7881
  const Button = 1;
7757
7882
  const Div = 4;
7883
+ const Input = 6;
7758
7884
  const Span = 8;
7759
7885
  const Text = 12;
7760
7886
  const Img = 17;
@@ -7869,7 +7995,7 @@ const renderHoverDom = {
7869
7995
  return [/* method */'Viewlet.setDom2', dom];
7870
7996
  }
7871
7997
  };
7872
- const renderBounds$5 = {
7998
+ const renderBounds$6 = {
7873
7999
  isEqual(oldState, newState) {
7874
8000
  return oldState.x === newState.x && oldState.y === newState.y;
7875
8001
  },
@@ -7883,10 +8009,10 @@ const renderBounds$5 = {
7883
8009
  return [SetBounds, x, y, renderWidth, height];
7884
8010
  }
7885
8011
  };
7886
- const render$c = [renderHoverDom, renderBounds$5];
8012
+ const render$e = [renderHoverDom, renderBounds$6];
7887
8013
  const renderHover = (oldState, newState) => {
7888
8014
  const commands = [];
7889
- for (const item of render$c) {
8015
+ for (const item of render$e) {
7890
8016
  if (!item.isEqual(oldState, newState)) {
7891
8017
  commands.push(item.apply(oldState, newState));
7892
8018
  }
@@ -8899,7 +9025,7 @@ const renderWidgets = {
8899
9025
  },
8900
9026
  multiple: true
8901
9027
  };
8902
- const render$b = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9028
+ const render$d = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8903
9029
  const renderEditor = async id => {
8904
9030
  const instance = get$6(id);
8905
9031
  if (!instance) {
@@ -8911,7 +9037,7 @@ const renderEditor = async id => {
8911
9037
  } = instance;
8912
9038
  const commands = [];
8913
9039
  set$6(id, newState, newState);
8914
- for (const item of render$b) {
9040
+ for (const item of render$d) {
8915
9041
  if (!item.isEqual(oldState, newState)) {
8916
9042
  const result = await item.apply(oldState, newState);
8917
9043
  // @ts-ignore
@@ -9009,12 +9135,12 @@ const commandMap = {
9009
9135
  'ColorPicker.loadContent': loadContent$3,
9010
9136
  'Editor.addCursorAbove': addCursorAbove,
9011
9137
  'Editor.addCursorBelow': addCursorBelow,
9012
- 'Editor.handleTab': handleTab,
9013
9138
  'Editor.applyEdit': applyEdit,
9014
9139
  'Editor.braceCompletion': braceCompletion,
9015
9140
  'Editor.cancelSelection': cancelSelection,
9016
9141
  'Editor.closeCompletion': closeCompletion,
9017
9142
  'Editor.closeFind': closeFind,
9143
+ 'Editor.closeRename': closeRename,
9018
9144
  'Editor.closeSourceAction': closeSourceAction,
9019
9145
  'Editor.compositionEnd': compositionEnd,
9020
9146
  'Editor.compositionStart': compositionStart,
@@ -9077,6 +9203,7 @@ const commandMap = {
9077
9203
  'Editor.handleScrollBarVerticalPointerDown': handleScrollBarPointerDown,
9078
9204
  'Editor.handleScrollBarVerticalPointerMove': handleScrollBarVerticalPointerMove,
9079
9205
  'Editor.handleSingleClick': handleSingleClick,
9206
+ 'Editor.handleTab': handleTab,
9080
9207
  'Editor.handleTouchEnd': handleTouchEnd,
9081
9208
  'Editor.handleTouchMove': handleTouchMove,
9082
9209
  'Editor.handleTouchStart': handleTouchStart,
@@ -9095,6 +9222,7 @@ const commandMap = {
9095
9222
  'Editor.openCompletion': openCompletion,
9096
9223
  'Editor.openFind': openFind,
9097
9224
  'Editor.openFind2': openFind2,
9225
+ 'Editor.openRename': openRename,
9098
9226
  'Editor.organizeImports': organizeImports,
9099
9227
  'Editor.paste': paste,
9100
9228
  'Editor.pasteText': pasteText,
@@ -9124,7 +9252,7 @@ const commandMap = {
9124
9252
  'Editor.setSelections': setSelections,
9125
9253
  'Editor.showHover': showHover,
9126
9254
  'Editor.showHover2': showHover2,
9127
- 'Editor.showSourceActions': showSourceActions$1,
9255
+ 'Editor.showSourceActions': showSourceActions,
9128
9256
  'Editor.showSourceActions2': showSourceActions,
9129
9257
  'Editor.sortLinesAscending': sortLinesAscending,
9130
9258
  'Editor.tabCompletion': tabCompletion,
@@ -9173,8 +9301,8 @@ const commandMap = {
9173
9301
  'FindWidget.handleReplaceInput': handleReplaceInput,
9174
9302
  'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
9175
9303
  'FindWidget.loadContent': loadContent$1,
9176
- 'FindWidget.toggleReplace': toggleReplace,
9177
9304
  'FindWidget.replaceAll': replaceAll$1,
9305
+ 'FindWidget.toggleReplace': toggleReplace,
9178
9306
  'Font.ensure': ensure,
9179
9307
  'Hover.getHoverInfo': getEditorHoverInfo,
9180
9308
  'Hover.handleSashPointerDown': handleSashPointerDown,
@@ -9747,7 +9875,7 @@ const renderOffsetX = {
9747
9875
  return [/* method */SetOffsetX, /* offsetX */newState.offsetX];
9748
9876
  }
9749
9877
  };
9750
- const renderContent$1 = {
9878
+ const renderContent$2 = {
9751
9879
  isEqual(oldState, newState) {
9752
9880
  return oldState.x === newState.x && oldState.y === newState.y && oldState.min === newState.min && oldState.max === newState.max;
9753
9881
  },
@@ -9756,7 +9884,7 @@ const renderContent$1 = {
9756
9884
  return ['Viewlet.setDom2', newState.uid, dom];
9757
9885
  }
9758
9886
  };
9759
- const renderBounds$4 = {
9887
+ const renderBounds$5 = {
9760
9888
  isEqual(oldState, newState) {
9761
9889
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9762
9890
  },
@@ -9770,10 +9898,10 @@ const renderBounds$4 = {
9770
9898
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9771
9899
  }
9772
9900
  };
9773
- const render$a = [renderContent$1, renderBounds$4, renderColor, renderOffsetX];
9774
- const renderFull$1 = (oldState, newState) => {
9901
+ const render$c = [renderContent$2, renderBounds$5, renderColor, renderOffsetX];
9902
+ const renderFull$2 = (oldState, newState) => {
9775
9903
  const commands = [];
9776
- for (const item of render$a) {
9904
+ for (const item of render$c) {
9777
9905
  if (!item.isEqual(oldState, newState)) {
9778
9906
  commands.push(item.apply(oldState, newState));
9779
9907
  }
@@ -9786,8 +9914,8 @@ const removeWidget = widget => {
9786
9914
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
9787
9915
  };
9788
9916
 
9789
- const render$9 = widget => {
9790
- const commands = renderFull$1(widget.oldState, widget.newState);
9917
+ const render$b = widget => {
9918
+ const commands = renderFull$2(widget.oldState, widget.newState);
9791
9919
  const wrappedCommands = [];
9792
9920
  const uid = widget.newState.uid;
9793
9921
  for (const command of commands) {
@@ -9799,10 +9927,10 @@ const render$9 = widget => {
9799
9927
  }
9800
9928
  return wrappedCommands;
9801
9929
  };
9802
- const add$5 = widget => {
9803
- return addWidget(widget, 'ColorPicker', render$9);
9930
+ const add$6 = widget => {
9931
+ return addWidget(widget, 'ColorPicker', render$b);
9804
9932
  };
9805
- const remove$5 = removeWidget;
9933
+ const remove$6 = removeWidget;
9806
9934
  const Commands$1 = {
9807
9935
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
9808
9936
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
@@ -9811,9 +9939,9 @@ const Commands$1 = {
9811
9939
  const EditorColorPickerWidget = {
9812
9940
  __proto__: null,
9813
9941
  Commands: Commands$1,
9814
- add: add$5,
9815
- remove: remove$5,
9816
- render: render$9
9942
+ add: add$6,
9943
+ remove: remove$6,
9944
+ render: render$b
9817
9945
  };
9818
9946
 
9819
9947
  const getCompletionDetailVirtualDom = content => {
@@ -9848,7 +9976,7 @@ const renderParts = (render, oldState, newState) => {
9848
9976
  return commands;
9849
9977
  };
9850
9978
 
9851
- const renderContent = {
9979
+ const renderContent$1 = {
9852
9980
  isEqual(oldState, newState) {
9853
9981
  return oldState.content === newState.content;
9854
9982
  },
@@ -9857,7 +9985,7 @@ const renderContent = {
9857
9985
  return ['Viewlet.setDom2', newState.uid, dom];
9858
9986
  }
9859
9987
  };
9860
- const renderBounds$3 = {
9988
+ const renderBounds$4 = {
9861
9989
  isEqual(oldState, newState) {
9862
9990
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9863
9991
  },
@@ -9871,29 +9999,13 @@ const renderBounds$3 = {
9871
9999
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9872
10000
  }
9873
10001
  };
9874
- const render$8 = [renderContent, renderBounds$3];
9875
- const renderFull = (oldState, newState) => {
9876
- return renderParts(render$8, oldState, newState);
9877
- };
9878
-
9879
- const getPositionAtCursor = editor => {
9880
- const {
9881
- selections
9882
- } = editor;
9883
- const rowIndex = selections[0];
9884
- const columnIndex = selections[1];
9885
- const x$1 = x(editor, rowIndex, columnIndex);
9886
- const y$1 = y(editor, rowIndex);
9887
- return {
9888
- x: x$1,
9889
- y: y$1,
9890
- rowIndex,
9891
- columnIndex
9892
- };
10002
+ const render$a = [renderContent$1, renderBounds$4];
10003
+ const renderFull$1 = (oldState, newState) => {
10004
+ return renderParts(render$a, oldState, newState);
9893
10005
  };
9894
10006
 
9895
- const render$7 = widget => {
9896
- const commands = renderFull(widget.oldState, widget.newState);
10007
+ const render$9 = widget => {
10008
+ const commands = renderFull$1(widget.oldState, widget.newState);
9897
10009
  const wrappedCommands = [];
9898
10010
  const uid = widget.newState.uid;
9899
10011
  for (const command of commands) {
@@ -9905,10 +10017,10 @@ const render$7 = widget => {
9905
10017
  }
9906
10018
  return wrappedCommands;
9907
10019
  };
9908
- const add$4 = widget => {
9909
- return addWidget(widget, 'EditorCompletionDetails', render$7);
10020
+ const add$5 = widget => {
10021
+ return addWidget(widget, 'EditorCompletionDetails', render$9);
9910
10022
  };
9911
- const remove$4 = removeWidget;
10023
+ const remove$5 = removeWidget;
9912
10024
  const handleEditorType$1 = (editor, state) => {
9913
10025
  const completionState = getCompletionState(editor);
9914
10026
  if (!completionState) {
@@ -9940,11 +10052,11 @@ const handleEditorDeleteLeft$1 = (editor, state) => {
9940
10052
 
9941
10053
  const EditorCompletionDetailWidget = {
9942
10054
  __proto__: null,
9943
- add: add$4,
10055
+ add: add$5,
9944
10056
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
9945
10057
  handleEditorType: handleEditorType$1,
9946
- remove: remove$4,
9947
- render: render$7
10058
+ remove: remove$5,
10059
+ render: render$9
9948
10060
  };
9949
10061
 
9950
10062
  const CheckBox = 'checkbox';
@@ -10149,7 +10261,7 @@ const renderItems = {
10149
10261
  return ['setDom', dom];
10150
10262
  }
10151
10263
  };
10152
- const renderBounds$2 = {
10264
+ const renderBounds$3 = {
10153
10265
  isEqual(oldState, newState) {
10154
10266
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
10155
10267
  },
@@ -10195,10 +10307,10 @@ const renderScrollBar = {
10195
10307
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
10196
10308
  }
10197
10309
  };
10198
- const render$6 = [renderItems, renderBounds$2, renderHeight, renderNegativeMargin, renderScrollBar];
10310
+ const render$8 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
10199
10311
  const renderCompletion = (oldState, newState) => {
10200
10312
  const commands = [];
10201
- for (const item of render$6) {
10313
+ for (const item of render$8) {
10202
10314
  if (!item.isEqual(oldState, newState)) {
10203
10315
  commands.push(item.apply(oldState, newState));
10204
10316
  }
@@ -10206,7 +10318,7 @@ const renderCompletion = (oldState, newState) => {
10206
10318
  return commands;
10207
10319
  };
10208
10320
 
10209
- const render$5 = widget => {
10321
+ const render$7 = widget => {
10210
10322
  const commands = renderCompletion(widget.oldState, widget.newState);
10211
10323
  const wrappedCommands = [];
10212
10324
  const uid = widget.newState.uid;
@@ -10215,8 +10327,8 @@ const render$5 = widget => {
10215
10327
  }
10216
10328
  return wrappedCommands;
10217
10329
  };
10218
- const add$3 = widget => {
10219
- const commands = render$5(widget);
10330
+ const add$4 = widget => {
10331
+ const commands = render$7(widget);
10220
10332
  const id = 'EditorCompletion';
10221
10333
  // TODO how to generate a unique integer id
10222
10334
  // that doesn't collide with ids created in renderer worker?
@@ -10226,7 +10338,7 @@ const add$3 = widget => {
10226
10338
  allCommands.push(...commands);
10227
10339
  return allCommands;
10228
10340
  };
10229
- const remove$3 = removeWidget;
10341
+ const remove$4 = removeWidget;
10230
10342
  const handleEditorType = (editor, state) => {
10231
10343
  const {
10232
10344
  unfilteredItems,
@@ -10289,11 +10401,11 @@ const handleEditorDeleteLeft = (editor, state) => {
10289
10401
 
10290
10402
  const EditorCompletionWidget = {
10291
10403
  __proto__: null,
10292
- add: add$3,
10404
+ add: add$4,
10293
10405
  handleEditorDeleteLeft,
10294
10406
  handleEditorType,
10295
- remove: remove$3,
10296
- render: render$5
10407
+ remove: remove$4,
10408
+ render: render$7
10297
10409
  };
10298
10410
 
10299
10411
  /**
@@ -10596,7 +10708,7 @@ const renderDetails = {
10596
10708
  return ['Viewlet.setDom2', dom];
10597
10709
  }
10598
10710
  };
10599
- const renderBounds$1 = {
10711
+ const renderBounds$2 = {
10600
10712
  isEqual(oldState, newState) {
10601
10713
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10602
10714
  },
@@ -10639,16 +10751,16 @@ const renderFocus = {
10639
10751
  // },
10640
10752
  // }
10641
10753
 
10642
- const render$4 = [renderDetails, renderBounds$1, renderValue, renderFocus];
10754
+ const render$6 = [renderDetails, renderBounds$2, renderValue, renderFocus];
10643
10755
  const apply = (oldState, newState) => {
10644
10756
  // TODO avoid side effect
10645
10757
  if (oldState.focus !== newState.focus) {
10646
10758
  setFocus(newState.focus);
10647
10759
  }
10648
- return renderParts(render$4, oldState, newState);
10760
+ return renderParts(render$6, oldState, newState);
10649
10761
  };
10650
10762
 
10651
- const render$3 = widget => {
10763
+ const render$5 = widget => {
10652
10764
  const commands = apply(widget.oldState, widget.newState);
10653
10765
  const wrappedCommands = [];
10654
10766
  const uid = widget.newState.uid;
@@ -10661,10 +10773,10 @@ const render$3 = widget => {
10661
10773
  }
10662
10774
  return wrappedCommands;
10663
10775
  };
10664
- const add$2 = widget => {
10665
- return addWidget(widget, 'FindWidget', render$3);
10776
+ const add$3 = widget => {
10777
+ return addWidget(widget, 'FindWidget', render$5);
10666
10778
  };
10667
- const remove$2 = removeWidget;
10779
+ const remove$3 = removeWidget;
10668
10780
  const Commands = {
10669
10781
  'FindWidget.close': close$1,
10670
10782
  'FindWidget.focusNext': focusNext$1,
@@ -10679,18 +10791,84 @@ const Commands = {
10679
10791
  const EditorFindWidget = {
10680
10792
  __proto__: null,
10681
10793
  Commands,
10794
+ add: add$3,
10795
+ remove: remove$3,
10796
+ render: render$5
10797
+ };
10798
+
10799
+ const render$4 = widget => {
10800
+ const commands = renderHover(widget.oldState, widget.newState);
10801
+ const wrappedCommands = [];
10802
+ const uid = widget.newState.uid;
10803
+ for (const command of commands) {
10804
+ if (command[0] === 'Viewlet.setDom2') {
10805
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10806
+ } else {
10807
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
10808
+ }
10809
+ }
10810
+ return wrappedCommands;
10811
+ };
10812
+ const add$2 = widget => {
10813
+ return addWidget(widget, 'EditorHover', render$4);
10814
+ };
10815
+ const remove$2 = removeWidget;
10816
+
10817
+ const EditorHoverWidget = {
10818
+ __proto__: null,
10682
10819
  add: add$2,
10683
10820
  remove: remove$2,
10684
- render: render$3
10821
+ render: render$4
10822
+ };
10823
+
10824
+ const getRenameVirtualDom = state => {
10825
+ return [{
10826
+ type: Div,
10827
+ className: 'Viewlet EditorRename',
10828
+ childCount: 1
10829
+ }, {
10830
+ type: Input,
10831
+ className: 'InputBox RenameInputBox',
10832
+ value: state.newValue,
10833
+ childCount: 0
10834
+ }];
10835
+ };
10836
+
10837
+ const renderContent = {
10838
+ isEqual(oldState, newState) {
10839
+ return false;
10840
+ },
10841
+ apply(oldState, newState) {
10842
+ const dom = getRenameVirtualDom(newState);
10843
+ return ['Viewlet.setDom2', newState.uid, dom];
10844
+ }
10845
+ };
10846
+ const renderBounds$1 = {
10847
+ isEqual(oldState, newState) {
10848
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10849
+ },
10850
+ apply(oldState, newState) {
10851
+ const {
10852
+ x,
10853
+ y,
10854
+ width,
10855
+ height
10856
+ } = newState;
10857
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10858
+ }
10859
+ };
10860
+ const render$3 = [renderContent, renderBounds$1];
10861
+ const renderFull = (oldState, newState) => {
10862
+ return renderParts(render$3, oldState, newState);
10685
10863
  };
10686
10864
 
10687
10865
  const render$2 = widget => {
10688
- const commands = renderHover(widget.oldState, widget.newState);
10866
+ const commands = renderFull(widget.oldState, widget.newState);
10689
10867
  const wrappedCommands = [];
10690
10868
  const uid = widget.newState.uid;
10691
10869
  for (const command of commands) {
10692
10870
  if (command[0] === 'Viewlet.setDom2') {
10693
- wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10871
+ wrappedCommands.push(command);
10694
10872
  } else {
10695
10873
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10696
10874
  }
@@ -10698,11 +10876,11 @@ const render$2 = widget => {
10698
10876
  return wrappedCommands;
10699
10877
  };
10700
10878
  const add$1 = widget => {
10701
- return addWidget(widget, 'EditorHover', render$2);
10879
+ return addWidget(widget, 'EditorRename', render$2);
10702
10880
  };
10703
10881
  const remove$1 = removeWidget;
10704
10882
 
10705
- const EditorHoverWidget = {
10883
+ const EditorRenameWidget = {
10706
10884
  __proto__: null,
10707
10885
  add: add$1,
10708
10886
  remove: remove$1,
@@ -10824,6 +11002,7 @@ const registerWidgets = () => {
10824
11002
  set$7(CompletionDetail$1, EditorCompletionDetailWidget);
10825
11003
  set$7(Find, EditorFindWidget);
10826
11004
  set$7(Hover, EditorHoverWidget);
11005
+ set$7(Rename$1, EditorRenameWidget);
10827
11006
  set$7(SourceAction, EditorSourceActionWidget);
10828
11007
  };
10829
11008
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",