@lvce-editor/editor-worker 4.0.0 → 4.1.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;
@@ -2264,6 +2264,7 @@ const ColorPicker$2 = 'colorPicker';
2264
2264
  const Find = 'find';
2265
2265
  const Hover = 'hover';
2266
2266
  const SourceAction = 'sourceAction';
2267
+ const Rename$1 = 'rename';
2267
2268
 
2268
2269
  const isCompletionWidget = widget => {
2269
2270
  return widget.id === Completion;
@@ -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);
@@ -6615,7 +6732,7 @@ const loadSourceActions = async (editorUid, state) => {
6615
6732
  };
6616
6733
 
6617
6734
  const create$1 = () => {
6618
- const completionUid = create$6();
6735
+ const completionUid = create$7();
6619
6736
  const widget = {
6620
6737
  id: SourceAction,
6621
6738
  oldState: {
@@ -7525,7 +7642,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
7525
7642
  };
7526
7643
 
7527
7644
  const create = () => {
7528
- const completionUid = create$6();
7645
+ const completionUid = create$7();
7529
7646
  const completionWidget = {
7530
7647
  id: CompletionDetail$1,
7531
7648
  oldState: {
@@ -7755,6 +7872,7 @@ const Viewlet = 'Viewlet';
7755
7872
 
7756
7873
  const Button = 1;
7757
7874
  const Div = 4;
7875
+ const Input = 6;
7758
7876
  const Span = 8;
7759
7877
  const Text = 12;
7760
7878
  const Img = 17;
@@ -7869,7 +7987,7 @@ const renderHoverDom = {
7869
7987
  return [/* method */'Viewlet.setDom2', dom];
7870
7988
  }
7871
7989
  };
7872
- const renderBounds$5 = {
7990
+ const renderBounds$6 = {
7873
7991
  isEqual(oldState, newState) {
7874
7992
  return oldState.x === newState.x && oldState.y === newState.y;
7875
7993
  },
@@ -7883,10 +8001,10 @@ const renderBounds$5 = {
7883
8001
  return [SetBounds, x, y, renderWidth, height];
7884
8002
  }
7885
8003
  };
7886
- const render$c = [renderHoverDom, renderBounds$5];
8004
+ const render$e = [renderHoverDom, renderBounds$6];
7887
8005
  const renderHover = (oldState, newState) => {
7888
8006
  const commands = [];
7889
- for (const item of render$c) {
8007
+ for (const item of render$e) {
7890
8008
  if (!item.isEqual(oldState, newState)) {
7891
8009
  commands.push(item.apply(oldState, newState));
7892
8010
  }
@@ -8899,7 +9017,7 @@ const renderWidgets = {
8899
9017
  },
8900
9018
  multiple: true
8901
9019
  };
8902
- const render$b = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
9020
+ const render$d = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8903
9021
  const renderEditor = async id => {
8904
9022
  const instance = get$6(id);
8905
9023
  if (!instance) {
@@ -8911,7 +9029,7 @@ const renderEditor = async id => {
8911
9029
  } = instance;
8912
9030
  const commands = [];
8913
9031
  set$6(id, newState, newState);
8914
- for (const item of render$b) {
9032
+ for (const item of render$d) {
8915
9033
  if (!item.isEqual(oldState, newState)) {
8916
9034
  const result = await item.apply(oldState, newState);
8917
9035
  // @ts-ignore
@@ -9009,12 +9127,12 @@ const commandMap = {
9009
9127
  'ColorPicker.loadContent': loadContent$3,
9010
9128
  'Editor.addCursorAbove': addCursorAbove,
9011
9129
  'Editor.addCursorBelow': addCursorBelow,
9012
- 'Editor.handleTab': handleTab,
9013
9130
  'Editor.applyEdit': applyEdit,
9014
9131
  'Editor.braceCompletion': braceCompletion,
9015
9132
  'Editor.cancelSelection': cancelSelection,
9016
9133
  'Editor.closeCompletion': closeCompletion,
9017
9134
  'Editor.closeFind': closeFind,
9135
+ 'Editor.closeRename': closeRename,
9018
9136
  'Editor.closeSourceAction': closeSourceAction,
9019
9137
  'Editor.compositionEnd': compositionEnd,
9020
9138
  'Editor.compositionStart': compositionStart,
@@ -9077,6 +9195,7 @@ const commandMap = {
9077
9195
  'Editor.handleScrollBarVerticalPointerDown': handleScrollBarPointerDown,
9078
9196
  'Editor.handleScrollBarVerticalPointerMove': handleScrollBarVerticalPointerMove,
9079
9197
  'Editor.handleSingleClick': handleSingleClick,
9198
+ 'Editor.handleTab': handleTab,
9080
9199
  'Editor.handleTouchEnd': handleTouchEnd,
9081
9200
  'Editor.handleTouchMove': handleTouchMove,
9082
9201
  'Editor.handleTouchStart': handleTouchStart,
@@ -9095,6 +9214,7 @@ const commandMap = {
9095
9214
  'Editor.openCompletion': openCompletion,
9096
9215
  'Editor.openFind': openFind,
9097
9216
  'Editor.openFind2': openFind2,
9217
+ 'Editor.openRename': openRename,
9098
9218
  'Editor.organizeImports': organizeImports,
9099
9219
  'Editor.paste': paste,
9100
9220
  'Editor.pasteText': pasteText,
@@ -9173,8 +9293,8 @@ const commandMap = {
9173
9293
  'FindWidget.handleReplaceInput': handleReplaceInput,
9174
9294
  'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
9175
9295
  'FindWidget.loadContent': loadContent$1,
9176
- 'FindWidget.toggleReplace': toggleReplace,
9177
9296
  'FindWidget.replaceAll': replaceAll$1,
9297
+ 'FindWidget.toggleReplace': toggleReplace,
9178
9298
  'Font.ensure': ensure,
9179
9299
  'Hover.getHoverInfo': getEditorHoverInfo,
9180
9300
  'Hover.handleSashPointerDown': handleSashPointerDown,
@@ -9747,7 +9867,7 @@ const renderOffsetX = {
9747
9867
  return [/* method */SetOffsetX, /* offsetX */newState.offsetX];
9748
9868
  }
9749
9869
  };
9750
- const renderContent$1 = {
9870
+ const renderContent$2 = {
9751
9871
  isEqual(oldState, newState) {
9752
9872
  return oldState.x === newState.x && oldState.y === newState.y && oldState.min === newState.min && oldState.max === newState.max;
9753
9873
  },
@@ -9756,7 +9876,7 @@ const renderContent$1 = {
9756
9876
  return ['Viewlet.setDom2', newState.uid, dom];
9757
9877
  }
9758
9878
  };
9759
- const renderBounds$4 = {
9879
+ const renderBounds$5 = {
9760
9880
  isEqual(oldState, newState) {
9761
9881
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9762
9882
  },
@@ -9770,10 +9890,10 @@ const renderBounds$4 = {
9770
9890
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9771
9891
  }
9772
9892
  };
9773
- const render$a = [renderContent$1, renderBounds$4, renderColor, renderOffsetX];
9774
- const renderFull$1 = (oldState, newState) => {
9893
+ const render$c = [renderContent$2, renderBounds$5, renderColor, renderOffsetX];
9894
+ const renderFull$2 = (oldState, newState) => {
9775
9895
  const commands = [];
9776
- for (const item of render$a) {
9896
+ for (const item of render$c) {
9777
9897
  if (!item.isEqual(oldState, newState)) {
9778
9898
  commands.push(item.apply(oldState, newState));
9779
9899
  }
@@ -9786,8 +9906,8 @@ const removeWidget = widget => {
9786
9906
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
9787
9907
  };
9788
9908
 
9789
- const render$9 = widget => {
9790
- const commands = renderFull$1(widget.oldState, widget.newState);
9909
+ const render$b = widget => {
9910
+ const commands = renderFull$2(widget.oldState, widget.newState);
9791
9911
  const wrappedCommands = [];
9792
9912
  const uid = widget.newState.uid;
9793
9913
  for (const command of commands) {
@@ -9799,10 +9919,10 @@ const render$9 = widget => {
9799
9919
  }
9800
9920
  return wrappedCommands;
9801
9921
  };
9802
- const add$5 = widget => {
9803
- return addWidget(widget, 'ColorPicker', render$9);
9922
+ const add$6 = widget => {
9923
+ return addWidget(widget, 'ColorPicker', render$b);
9804
9924
  };
9805
- const remove$5 = removeWidget;
9925
+ const remove$6 = removeWidget;
9806
9926
  const Commands$1 = {
9807
9927
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
9808
9928
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
@@ -9811,9 +9931,9 @@ const Commands$1 = {
9811
9931
  const EditorColorPickerWidget = {
9812
9932
  __proto__: null,
9813
9933
  Commands: Commands$1,
9814
- add: add$5,
9815
- remove: remove$5,
9816
- render: render$9
9934
+ add: add$6,
9935
+ remove: remove$6,
9936
+ render: render$b
9817
9937
  };
9818
9938
 
9819
9939
  const getCompletionDetailVirtualDom = content => {
@@ -9848,7 +9968,7 @@ const renderParts = (render, oldState, newState) => {
9848
9968
  return commands;
9849
9969
  };
9850
9970
 
9851
- const renderContent = {
9971
+ const renderContent$1 = {
9852
9972
  isEqual(oldState, newState) {
9853
9973
  return oldState.content === newState.content;
9854
9974
  },
@@ -9857,7 +9977,7 @@ const renderContent = {
9857
9977
  return ['Viewlet.setDom2', newState.uid, dom];
9858
9978
  }
9859
9979
  };
9860
- const renderBounds$3 = {
9980
+ const renderBounds$4 = {
9861
9981
  isEqual(oldState, newState) {
9862
9982
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9863
9983
  },
@@ -9871,29 +9991,13 @@ const renderBounds$3 = {
9871
9991
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9872
9992
  }
9873
9993
  };
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
- };
9994
+ const render$a = [renderContent$1, renderBounds$4];
9995
+ const renderFull$1 = (oldState, newState) => {
9996
+ return renderParts(render$a, oldState, newState);
9893
9997
  };
9894
9998
 
9895
- const render$7 = widget => {
9896
- const commands = renderFull(widget.oldState, widget.newState);
9999
+ const render$9 = widget => {
10000
+ const commands = renderFull$1(widget.oldState, widget.newState);
9897
10001
  const wrappedCommands = [];
9898
10002
  const uid = widget.newState.uid;
9899
10003
  for (const command of commands) {
@@ -9905,10 +10009,10 @@ const render$7 = widget => {
9905
10009
  }
9906
10010
  return wrappedCommands;
9907
10011
  };
9908
- const add$4 = widget => {
9909
- return addWidget(widget, 'EditorCompletionDetails', render$7);
10012
+ const add$5 = widget => {
10013
+ return addWidget(widget, 'EditorCompletionDetails', render$9);
9910
10014
  };
9911
- const remove$4 = removeWidget;
10015
+ const remove$5 = removeWidget;
9912
10016
  const handleEditorType$1 = (editor, state) => {
9913
10017
  const completionState = getCompletionState(editor);
9914
10018
  if (!completionState) {
@@ -9940,11 +10044,11 @@ const handleEditorDeleteLeft$1 = (editor, state) => {
9940
10044
 
9941
10045
  const EditorCompletionDetailWidget = {
9942
10046
  __proto__: null,
9943
- add: add$4,
10047
+ add: add$5,
9944
10048
  handleEditorDeleteLeft: handleEditorDeleteLeft$1,
9945
10049
  handleEditorType: handleEditorType$1,
9946
- remove: remove$4,
9947
- render: render$7
10050
+ remove: remove$5,
10051
+ render: render$9
9948
10052
  };
9949
10053
 
9950
10054
  const CheckBox = 'checkbox';
@@ -10149,7 +10253,7 @@ const renderItems = {
10149
10253
  return ['setDom', dom];
10150
10254
  }
10151
10255
  };
10152
- const renderBounds$2 = {
10256
+ const renderBounds$3 = {
10153
10257
  isEqual(oldState, newState) {
10154
10258
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
10155
10259
  },
@@ -10195,10 +10299,10 @@ const renderScrollBar = {
10195
10299
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
10196
10300
  }
10197
10301
  };
10198
- const render$6 = [renderItems, renderBounds$2, renderHeight, renderNegativeMargin, renderScrollBar];
10302
+ const render$8 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
10199
10303
  const renderCompletion = (oldState, newState) => {
10200
10304
  const commands = [];
10201
- for (const item of render$6) {
10305
+ for (const item of render$8) {
10202
10306
  if (!item.isEqual(oldState, newState)) {
10203
10307
  commands.push(item.apply(oldState, newState));
10204
10308
  }
@@ -10206,7 +10310,7 @@ const renderCompletion = (oldState, newState) => {
10206
10310
  return commands;
10207
10311
  };
10208
10312
 
10209
- const render$5 = widget => {
10313
+ const render$7 = widget => {
10210
10314
  const commands = renderCompletion(widget.oldState, widget.newState);
10211
10315
  const wrappedCommands = [];
10212
10316
  const uid = widget.newState.uid;
@@ -10215,8 +10319,8 @@ const render$5 = widget => {
10215
10319
  }
10216
10320
  return wrappedCommands;
10217
10321
  };
10218
- const add$3 = widget => {
10219
- const commands = render$5(widget);
10322
+ const add$4 = widget => {
10323
+ const commands = render$7(widget);
10220
10324
  const id = 'EditorCompletion';
10221
10325
  // TODO how to generate a unique integer id
10222
10326
  // that doesn't collide with ids created in renderer worker?
@@ -10226,7 +10330,7 @@ const add$3 = widget => {
10226
10330
  allCommands.push(...commands);
10227
10331
  return allCommands;
10228
10332
  };
10229
- const remove$3 = removeWidget;
10333
+ const remove$4 = removeWidget;
10230
10334
  const handleEditorType = (editor, state) => {
10231
10335
  const {
10232
10336
  unfilteredItems,
@@ -10289,11 +10393,11 @@ const handleEditorDeleteLeft = (editor, state) => {
10289
10393
 
10290
10394
  const EditorCompletionWidget = {
10291
10395
  __proto__: null,
10292
- add: add$3,
10396
+ add: add$4,
10293
10397
  handleEditorDeleteLeft,
10294
10398
  handleEditorType,
10295
- remove: remove$3,
10296
- render: render$5
10399
+ remove: remove$4,
10400
+ render: render$7
10297
10401
  };
10298
10402
 
10299
10403
  /**
@@ -10596,7 +10700,7 @@ const renderDetails = {
10596
10700
  return ['Viewlet.setDom2', dom];
10597
10701
  }
10598
10702
  };
10599
- const renderBounds$1 = {
10703
+ const renderBounds$2 = {
10600
10704
  isEqual(oldState, newState) {
10601
10705
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10602
10706
  },
@@ -10639,16 +10743,16 @@ const renderFocus = {
10639
10743
  // },
10640
10744
  // }
10641
10745
 
10642
- const render$4 = [renderDetails, renderBounds$1, renderValue, renderFocus];
10746
+ const render$6 = [renderDetails, renderBounds$2, renderValue, renderFocus];
10643
10747
  const apply = (oldState, newState) => {
10644
10748
  // TODO avoid side effect
10645
10749
  if (oldState.focus !== newState.focus) {
10646
10750
  setFocus(newState.focus);
10647
10751
  }
10648
- return renderParts(render$4, oldState, newState);
10752
+ return renderParts(render$6, oldState, newState);
10649
10753
  };
10650
10754
 
10651
- const render$3 = widget => {
10755
+ const render$5 = widget => {
10652
10756
  const commands = apply(widget.oldState, widget.newState);
10653
10757
  const wrappedCommands = [];
10654
10758
  const uid = widget.newState.uid;
@@ -10661,10 +10765,10 @@ const render$3 = widget => {
10661
10765
  }
10662
10766
  return wrappedCommands;
10663
10767
  };
10664
- const add$2 = widget => {
10665
- return addWidget(widget, 'FindWidget', render$3);
10768
+ const add$3 = widget => {
10769
+ return addWidget(widget, 'FindWidget', render$5);
10666
10770
  };
10667
- const remove$2 = removeWidget;
10771
+ const remove$3 = removeWidget;
10668
10772
  const Commands = {
10669
10773
  'FindWidget.close': close$1,
10670
10774
  'FindWidget.focusNext': focusNext$1,
@@ -10679,18 +10783,84 @@ const Commands = {
10679
10783
  const EditorFindWidget = {
10680
10784
  __proto__: null,
10681
10785
  Commands,
10786
+ add: add$3,
10787
+ remove: remove$3,
10788
+ render: render$5
10789
+ };
10790
+
10791
+ const render$4 = widget => {
10792
+ const commands = renderHover(widget.oldState, widget.newState);
10793
+ const wrappedCommands = [];
10794
+ const uid = widget.newState.uid;
10795
+ for (const command of commands) {
10796
+ if (command[0] === 'Viewlet.setDom2') {
10797
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10798
+ } else {
10799
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
10800
+ }
10801
+ }
10802
+ return wrappedCommands;
10803
+ };
10804
+ const add$2 = widget => {
10805
+ return addWidget(widget, 'EditorHover', render$4);
10806
+ };
10807
+ const remove$2 = removeWidget;
10808
+
10809
+ const EditorHoverWidget = {
10810
+ __proto__: null,
10682
10811
  add: add$2,
10683
10812
  remove: remove$2,
10684
- render: render$3
10813
+ render: render$4
10814
+ };
10815
+
10816
+ const getRenameVirtualDom = state => {
10817
+ return [{
10818
+ type: Div,
10819
+ className: 'Viewlet EditorRename',
10820
+ childCount: 1
10821
+ }, {
10822
+ type: Input,
10823
+ className: 'InputBox RenameInputBox',
10824
+ value: state.newValue,
10825
+ childCount: 0
10826
+ }];
10827
+ };
10828
+
10829
+ const renderContent = {
10830
+ isEqual(oldState, newState) {
10831
+ return false;
10832
+ },
10833
+ apply(oldState, newState) {
10834
+ const dom = getRenameVirtualDom(newState);
10835
+ return ['Viewlet.setDom2', newState.uid, dom];
10836
+ }
10837
+ };
10838
+ const renderBounds$1 = {
10839
+ isEqual(oldState, newState) {
10840
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10841
+ },
10842
+ apply(oldState, newState) {
10843
+ const {
10844
+ x,
10845
+ y,
10846
+ width,
10847
+ height
10848
+ } = newState;
10849
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10850
+ }
10851
+ };
10852
+ const render$3 = [renderContent, renderBounds$1];
10853
+ const renderFull = (oldState, newState) => {
10854
+ return renderParts(render$3, oldState, newState);
10685
10855
  };
10686
10856
 
10687
10857
  const render$2 = widget => {
10688
- const commands = renderHover(widget.oldState, widget.newState);
10858
+ const commands = renderFull(widget.oldState, widget.newState);
10689
10859
  const wrappedCommands = [];
10690
10860
  const uid = widget.newState.uid;
10691
10861
  for (const command of commands) {
10692
10862
  if (command[0] === 'Viewlet.setDom2') {
10693
- wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10863
+ wrappedCommands.push(command);
10694
10864
  } else {
10695
10865
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10696
10866
  }
@@ -10698,11 +10868,11 @@ const render$2 = widget => {
10698
10868
  return wrappedCommands;
10699
10869
  };
10700
10870
  const add$1 = widget => {
10701
- return addWidget(widget, 'EditorHover', render$2);
10871
+ return addWidget(widget, 'EditorRename', render$2);
10702
10872
  };
10703
10873
  const remove$1 = removeWidget;
10704
10874
 
10705
- const EditorHoverWidget = {
10875
+ const EditorRenameWidget = {
10706
10876
  __proto__: null,
10707
10877
  add: add$1,
10708
10878
  remove: remove$1,
@@ -10824,6 +10994,7 @@ const registerWidgets = () => {
10824
10994
  set$7(CompletionDetail$1, EditorCompletionDetailWidget);
10825
10995
  set$7(Find, EditorFindWidget);
10826
10996
  set$7(Hover, EditorHoverWidget);
10997
+ set$7(Rename$1, EditorRenameWidget);
10827
10998
  set$7(SourceAction, EditorSourceActionWidget);
10828
10999
  };
10829
11000
 
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.1.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",