@lvce-editor/editor-worker 19.45.0 → 19.47.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.
@@ -1151,7 +1151,7 @@ const createMockRpc = ({
1151
1151
  };
1152
1152
 
1153
1153
  const rpcs = Object.create(null);
1154
- const set$g = (id, rpc) => {
1154
+ const set$h = (id, rpc) => {
1155
1155
  rpcs[id] = rpc;
1156
1156
  };
1157
1157
  const get$9 = id => {
@@ -1184,7 +1184,7 @@ const create$a = rpcId => {
1184
1184
  const mockRpc = createMockRpc({
1185
1185
  commandMap
1186
1186
  });
1187
- set$g(rpcId, mockRpc);
1187
+ set$h(rpcId, mockRpc);
1188
1188
  // @ts-ignore
1189
1189
  mockRpc[Symbol.dispose] = () => {
1190
1190
  remove$8(rpcId);
@@ -1193,7 +1193,7 @@ const create$a = rpcId => {
1193
1193
  return mockRpc;
1194
1194
  },
1195
1195
  set(rpc) {
1196
- set$g(rpcId, rpc);
1196
+ set$h(rpcId, rpc);
1197
1197
  }
1198
1198
  };
1199
1199
  };
@@ -1439,6 +1439,7 @@ const Electron = 2;
1439
1439
  const CompletionWorker = 301;
1440
1440
  const DebugWorker = 55;
1441
1441
  const DialogWorker = 7014;
1442
+ const DragAndDropWorker = 3404;
1442
1443
  const EditorWorker = 99;
1443
1444
  const ErrorWorker = 3308;
1444
1445
  const ExtensionManagementWorker = 9006;
@@ -1454,10 +1455,15 @@ const SetPatches = 'Viewlet.setPatches';
1454
1455
 
1455
1456
  const FocusEditorText$1 = 12;
1456
1457
 
1458
+ const {
1459
+ invoke: invoke$g,
1460
+ set: set$g
1461
+ } = create$a(DialogWorker);
1462
+
1457
1463
  const {
1458
1464
  invoke: invoke$f,
1459
1465
  set: set$f
1460
- } = create$a(DialogWorker);
1466
+ } = create$a(DragAndDropWorker);
1461
1467
 
1462
1468
  const {
1463
1469
  invoke: invoke$e,
@@ -1485,7 +1491,7 @@ const createLazyRpc = rpcId => {
1485
1491
  throw new Error('Lazy RPC launch was superseded');
1486
1492
  }
1487
1493
  activeRpc = rpc;
1488
- set$g(rpcId, rpc);
1494
+ set$h(rpcId, rpc);
1489
1495
  return rpc;
1490
1496
  };
1491
1497
  const ensureRpc = async () => {
@@ -1570,6 +1576,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1570
1576
  number(y);
1571
1577
  await invoke$a('ContextMenu.show2', uid, menuId, x, y, args);
1572
1578
  };
1579
+ const sendMessagePortToDragAndDropWorker = async port => {
1580
+ const command = 'DragAndDrop.handleMessagePort';
1581
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
1582
+ };
1573
1583
  const sendMessagePortToOpenerWorker = async (port, rpcId) => {
1574
1584
  const command = 'HandleMessagePort.handleMessagePort';
1575
1585
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
@@ -1940,6 +1950,7 @@ const EditorPasteText = 'editorPasteText';
1940
1950
  const EditorSnippet = 'editorSnippet';
1941
1951
  const EditorType = 'editorType';
1942
1952
  const EditorTypeWithAutoClosing = 'editorTypeWithAutoClosing';
1953
+ const EditorTextDrag = 'editorTextDrag';
1943
1954
  const Format = 'format';
1944
1955
  const IndentLess = 'indentLess';
1945
1956
  const IndentMore = 'indentMore';
@@ -4361,6 +4372,44 @@ const updateColorPickerValue$1 = async (editor, value) => {
4361
4372
  };
4362
4373
  };
4363
4374
 
4375
+ const validTypes = new Set(['added', 'deleted', 'modified']);
4376
+ const isProviderDecoration$1 = value => {
4377
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
4378
+ };
4379
+ const getProviderDecorations$1 = results => {
4380
+ if (!Array.isArray(results)) {
4381
+ return [];
4382
+ }
4383
+ const decorations = [];
4384
+ for (const result of results) {
4385
+ if (!Array.isArray(result)) {
4386
+ continue;
4387
+ }
4388
+ for (const decoration of result) {
4389
+ if (isProviderDecoration$1(decoration) && Number.isSafeInteger(decoration.rowIndex) && decoration.rowIndex >= 0 && typeof decoration.type === 'string' && validTypes.has(decoration.type)) {
4390
+ decorations.push({
4391
+ rowIndex: decoration.rowIndex,
4392
+ type: decoration.type
4393
+ });
4394
+ }
4395
+ }
4396
+ }
4397
+ return decorations;
4398
+ };
4399
+ const getEditorGutterDecorations = async editor => {
4400
+ const textDocument = {
4401
+ languageId: editor.languageId,
4402
+ text: getText$1(editor),
4403
+ uri: editor.uri
4404
+ };
4405
+ try {
4406
+ const results = await invoke$d('Extensions.executeProvidersByEvent', 'onEditorGutterDecoration', 'ExtensionApi.executeEditorGutterDecorationProvider', textDocument);
4407
+ return getProviderDecorations$1(results);
4408
+ } catch {
4409
+ return [];
4410
+ }
4411
+ };
4412
+
4364
4413
  const diagnosticContainsPosition = (diagnostic, rowIndex, columnIndex) => {
4365
4414
  const {
4366
4415
  columnIndex: startColumnIndex,
@@ -4838,6 +4887,12 @@ const updateDerivedState = async (oldState, newState) => {
4838
4887
  lightBulbRowIndex: await getLightBulbRowIndex(finalState)
4839
4888
  };
4840
4889
  }
4890
+ if (oldState.lines !== nextState.lines || oldState.uri !== nextState.uri) {
4891
+ finalState = {
4892
+ ...finalState,
4893
+ gutterDecorations: await getEditorGutterDecorations(finalState)
4894
+ };
4895
+ }
4841
4896
  if (!shouldUpdateSelectionData(oldState, nextState)) {
4842
4897
  return finalState;
4843
4898
  }
@@ -4965,6 +5020,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4965
5020
  diagnosticsEnabled: false,
4966
5021
  differences: [],
4967
5022
  documentSymbols: [],
5023
+ dragAndDropEnabled: true,
4968
5024
  embeds: [],
4969
5025
  endOfLine: 'lf',
4970
5026
  endOfLineDecorations: [],
@@ -4977,6 +5033,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4977
5033
  fontFamily: '',
4978
5034
  fontSize: 0,
4979
5035
  fontWeight: 0,
5036
+ gutterDecorations: [],
4980
5037
  gutterWidth: 0,
4981
5038
  handleOffset: 0,
4982
5039
  handleOffsetX: 0,
@@ -5032,6 +5089,11 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
5032
5089
  selectionInfos: [],
5033
5090
  selections: new Uint32Array(),
5034
5091
  tabSize: 0,
5092
+ textDragDropPosition: {
5093
+ columnIndex: 0,
5094
+ rowIndex: 0
5095
+ },
5096
+ textDragId: 0,
5035
5097
  textInfos: [],
5036
5098
  tokenizerId: 0,
5037
5099
  uid: id,
@@ -5062,11 +5124,13 @@ const emptyEditor = {
5062
5124
  diagnostics: [],
5063
5125
  differences: [],
5064
5126
  documentSymbols: [],
5127
+ dragAndDropEnabled: true,
5065
5128
  embeds: [],
5066
5129
  endOfLine: 'lf',
5067
5130
  endOfLineDecorations: [],
5068
5131
  focused: false,
5069
5132
  foldingRanges: [],
5133
+ gutterDecorations: [],
5070
5134
  hasListener: false,
5071
5135
  height: 0,
5072
5136
  highlightedLine: -1,
@@ -5097,6 +5161,11 @@ const emptyEditor = {
5097
5161
  },
5098
5162
  selectionInfos: [],
5099
5163
  selections: new Uint32Array(),
5164
+ textDragDropPosition: {
5165
+ columnIndex: 0,
5166
+ rowIndex: 0
5167
+ },
5168
+ textDragId: 0,
5100
5169
  textInfos: [],
5101
5170
  tokenizerId: 0,
5102
5171
  undoStack: [],
@@ -5251,6 +5320,7 @@ const createEditor = async ({
5251
5320
  diagnostics: [],
5252
5321
  diagnosticsEnabled,
5253
5322
  differences: [],
5323
+ dragAndDropEnabled: true,
5254
5324
  endOfLine: getEndOfLine(content),
5255
5325
  endOfLineDecorations: [],
5256
5326
  finalDeltaY: 0,
@@ -5261,6 +5331,7 @@ const createEditor = async ({
5261
5331
  fontFamily,
5262
5332
  fontSize,
5263
5333
  fontWeight,
5334
+ gutterDecorations: [],
5264
5335
  gutterWidth: 0,
5265
5336
  handleOffset: 0,
5266
5337
  handleOffsetX: 0,
@@ -5307,6 +5378,11 @@ const createEditor = async ({
5307
5378
  selectionInfos: [],
5308
5379
  selections: new Uint32Array(),
5309
5380
  tabSize,
5381
+ textDragDropPosition: {
5382
+ columnIndex: 0,
5383
+ rowIndex: 0
5384
+ },
5385
+ textDragId: 0,
5310
5386
  textInfos: [],
5311
5387
  tokenizerId: 0,
5312
5388
  uid: id,
@@ -5455,7 +5531,7 @@ const isEqual$3 = (oldState, newState) => {
5455
5531
  };
5456
5532
 
5457
5533
  const isEqual$2 = (oldState, newState) => {
5458
- return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5534
+ return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5459
5535
  };
5460
5536
 
5461
5537
  const isEqual$1 = (oldState, newState) => {
@@ -6169,7 +6245,7 @@ const isPermissionDeniedError = error => {
6169
6245
  };
6170
6246
  const showSaveErrorDialog = async error => {
6171
6247
  if (isPermissionDeniedError(error)) {
6172
- await invoke$f('ElectronDialog.showMessageBox', {
6248
+ await invoke$g('ElectronDialog.showMessageBox', {
6173
6249
  buttons: ['OK'],
6174
6250
  defaultId: 0,
6175
6251
  message: "You don't have permission to save changes to this file.",
@@ -6178,7 +6254,7 @@ const showSaveErrorDialog = async error => {
6178
6254
  });
6179
6255
  return;
6180
6256
  }
6181
- await invoke$f('ElectronDialog.showMessageBox', {
6257
+ await invoke$g('ElectronDialog.showMessageBox', {
6182
6258
  buttons: ['OK'],
6183
6259
  defaultId: 0,
6184
6260
  detail: error.message,
@@ -8635,13 +8711,50 @@ const handleSecondaryMouseDown = async (state, x, y) => {
8635
8711
  }
8636
8712
  return handleClickAtPosition(state, 0, position.rowIndex, position.columnIndex);
8637
8713
  };
8638
- const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail) => {
8714
+ const startTextDrag = async (state, x, y) => {
8715
+ const position = await at(state, x, y);
8716
+ const selectionIndex = state.primarySelectionIndex || 0;
8717
+ const [startRowIndex, startColumnIndex, endRowIndex, endColumnIndex] = getSelectionPairs(state.selections, selectionIndex);
8718
+ const startOffset = offsetAt(state, startRowIndex, startColumnIndex);
8719
+ const endOffset = offsetAt(state, endRowIndex, endColumnIndex);
8720
+ const pointerOffset = offsetAt(state, position.rowIndex, position.columnIndex);
8721
+ if (startOffset === endOffset || pointerOffset < startOffset || pointerOffset >= endOffset) {
8722
+ return undefined;
8723
+ }
8724
+ try {
8725
+ if (state.textDragId) {
8726
+ await invoke$f('DragAndDrop.discardTextDrag', state.textDragId);
8727
+ }
8728
+ const text = getText$1(state).slice(startOffset, endOffset);
8729
+ const textDragId = await invoke$f('DragAndDrop.createTextDrag', {
8730
+ endOffset,
8731
+ sourceUri: state.uri,
8732
+ startOffset,
8733
+ text
8734
+ });
8735
+ return {
8736
+ ...state,
8737
+ isSelecting: false,
8738
+ textDragDropPosition: position,
8739
+ textDragId
8740
+ };
8741
+ } catch {
8742
+ return undefined;
8743
+ }
8744
+ };
8745
+ const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail, shiftKey = false) => {
8639
8746
  if (button === SecondaryButton) {
8640
8747
  return handleSecondaryMouseDown(state, x, y);
8641
8748
  }
8642
8749
  if (button !== PrimaryButton) {
8643
8750
  return state;
8644
8751
  }
8752
+ if (shiftKey && state.dragAndDropEnabled && detail === Single) {
8753
+ const dragState = await startTextDrag(state, x, y);
8754
+ if (dragState) {
8755
+ return dragState;
8756
+ }
8757
+ }
8645
8758
  const modifier = getModifier(altKey, ctrlKey);
8646
8759
  let newState;
8647
8760
  switch (detail) {
@@ -9173,7 +9286,14 @@ const editorHandleNativeSelectionChange = (editor, range) => {
9173
9286
  };
9174
9287
 
9175
9288
  // @ts-ignore
9176
- const handlePointerCaptureLost = editor => {
9289
+ const handlePointerCaptureLost = async editor => {
9290
+ if (editor.textDragId) {
9291
+ try {
9292
+ await invoke$f('DragAndDrop.discardTextDrag', editor.textDragId);
9293
+ } catch {
9294
+ // The pointer state still needs to be reset if the worker is unavailable.
9295
+ }
9296
+ }
9177
9297
  return {
9178
9298
  ...editor,
9179
9299
  hasListener: false,
@@ -9181,7 +9301,12 @@ const handlePointerCaptureLost = editor => {
9181
9301
  selectionAutoMovePosition: {
9182
9302
  columnIndex: 0,
9183
9303
  rowIndex: 0
9184
- }
9304
+ },
9305
+ textDragDropPosition: {
9306
+ columnIndex: 0,
9307
+ rowIndex: 0
9308
+ },
9309
+ textDragId: 0
9185
9310
  };
9186
9311
  };
9187
9312
 
@@ -9378,6 +9503,13 @@ const moveSelectionPx = async (editor, x, y) => {
9378
9503
  };
9379
9504
 
9380
9505
  const handlePointerMove = async (editor, x, y, altKey) => {
9506
+ if (editor.textDragId) {
9507
+ const textDragDropPosition = await at(editor, x, y);
9508
+ return {
9509
+ ...editor,
9510
+ textDragDropPosition
9511
+ };
9512
+ }
9381
9513
  if (!editor.isSelecting) {
9382
9514
  return editor;
9383
9515
  }
@@ -9387,16 +9519,84 @@ const handlePointerMove = async (editor, x, y, altKey) => {
9387
9519
  return moveSelectionPx(editor, x, y);
9388
9520
  };
9389
9521
 
9390
- const handlePointerUp = editor => {
9522
+ const getSelection = (lines, startOffset, endOffset) => {
9523
+ const start = positionAt({
9524
+ lines
9525
+ }, startOffset);
9526
+ const end = positionAt({
9527
+ lines
9528
+ }, endOffset);
9529
+ return new Uint32Array([start.rowIndex, start.columnIndex, end.rowIndex, end.columnIndex]);
9530
+ };
9531
+ const getTextDragEdit = (editor, data, target, origin) => {
9532
+ const documentText = getText$1(editor);
9533
+ const targetOffset = offsetAt(editor, target.rowIndex, target.columnIndex);
9534
+ const {
9535
+ endOffset,
9536
+ startOffset,
9537
+ text
9538
+ } = data;
9539
+ if (startOffset < 0 || startOffset >= endOffset || endOffset > documentText.length || documentText.slice(startOffset, endOffset) !== text || targetOffset >= startOffset && targetOffset <= endOffset) {
9540
+ return undefined;
9541
+ }
9542
+ const regionStartOffset = Math.min(startOffset, targetOffset);
9543
+ const regionEndOffset = Math.max(endOffset, targetOffset);
9544
+ const replacement = targetOffset < startOffset ? text + documentText.slice(targetOffset, startOffset) : documentText.slice(endOffset, targetOffset) + text;
9545
+ const newSelectionStartOffset = targetOffset < startOffset ? targetOffset : targetOffset - text.length;
9546
+ const newText = documentText.slice(0, regionStartOffset) + replacement + documentText.slice(regionEndOffset);
9547
+ const newLines = splitLines(newText);
9548
+ const start = positionAt(editor, regionStartOffset);
9549
+ const end = positionAt(editor, regionEndOffset);
9391
9550
  return {
9551
+ change: {
9552
+ deleted: splitLines(documentText.slice(regionStartOffset, regionEndOffset)),
9553
+ end,
9554
+ inserted: splitLines(replacement),
9555
+ origin,
9556
+ start
9557
+ },
9558
+ selections: getSelection(newLines, newSelectionStartOffset, newSelectionStartOffset + text.length)
9559
+ };
9560
+ };
9561
+
9562
+ const moveTextDrag = async (editor, data, target) => {
9563
+ if (data.sourceUri !== editor.uri) {
9564
+ return editor;
9565
+ }
9566
+ const result = getTextDragEdit(editor, data, target, EditorTextDrag);
9567
+ if (!result) {
9568
+ return editor;
9569
+ }
9570
+ return scheduleDocumentAndCursorsSelections(editor, [result.change], result.selections);
9571
+ };
9572
+
9573
+ const handlePointerUp = async editor => {
9574
+ const resetEditor = {
9392
9575
  ...editor,
9393
9576
  hasListener: false,
9394
9577
  isSelecting: false,
9395
9578
  selectionAutoMovePosition: {
9396
9579
  columnIndex: 0,
9397
9580
  rowIndex: 0
9398
- }
9581
+ },
9582
+ textDragDropPosition: {
9583
+ columnIndex: 0,
9584
+ rowIndex: 0
9585
+ },
9586
+ textDragId: 0
9399
9587
  };
9588
+ if (!editor.textDragId) {
9589
+ return resetEditor;
9590
+ }
9591
+ try {
9592
+ const data = await invoke$f('DragAndDrop.takeTextDrag', editor.textDragId);
9593
+ if (!data) {
9594
+ return resetEditor;
9595
+ }
9596
+ return moveTextDrag(resetEditor, data, editor.textDragDropPosition);
9597
+ } catch {
9598
+ return resetEditor;
9599
+ }
9400
9600
  };
9401
9601
 
9402
9602
  // @ts-ignore
@@ -10098,7 +10298,7 @@ const launch = async () => {
10098
10298
  return;
10099
10299
  }
10100
10300
  const rpc = await launchFindWidgetWorker();
10101
- set$g(rpcId, rpc);
10301
+ set$h(rpcId, rpc);
10102
10302
  };
10103
10303
  const invoke$3 = async (method, ...params) => {
10104
10304
  const rpc = get$9(rpcId);
@@ -13458,7 +13658,7 @@ const handleMessagePort = async (port, rpcId) => {
13458
13658
  messagePort: port
13459
13659
  });
13460
13660
  if (rpcId) {
13461
- set$g(rpcId, rpc);
13661
+ set$h(rpcId, rpc);
13462
13662
  }
13463
13663
  };
13464
13664
 
@@ -13492,6 +13692,10 @@ const kFontWeight = 'editor.fontWeight';
13492
13692
  const kHover = 'editor.hover';
13493
13693
  const kMinimapEnabled = 'editor.minimap.enabled';
13494
13694
  const kBreadcrumbsEnabled = 'breadcrumbs.enabled';
13695
+ const kDragAndDropEnabled = 'editor.dragAndDrop';
13696
+ const getDragAndDropEnabled = async () => {
13697
+ return (await get$3(kDragAndDropEnabled)) ?? true;
13698
+ };
13495
13699
  const isAutoClosingBracketsEnabled = async () => {
13496
13700
  return Boolean(await get$3(kAutoClosingBrackets));
13497
13701
  };
@@ -13548,11 +13752,12 @@ const getBreadcrumbsEnabled = async () => {
13548
13752
  };
13549
13753
 
13550
13754
  const getEditorPreferences = async () => {
13551
- const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled, insertSpaces] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled(), getInsertSpaces()]);
13755
+ const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled()]);
13552
13756
  return {
13553
13757
  breadcrumbsEnabled,
13554
13758
  completionTriggerCharacters,
13555
13759
  diagnosticsEnabled: diagnosticsEnabled$1,
13760
+ dragAndDropEnabled,
13556
13761
  fontFamily,
13557
13762
  fontSize,
13558
13763
  fontWeight,
@@ -13610,11 +13815,15 @@ const handleSettingsChanged = async state => {
13610
13815
  } else if (!state.breadcrumbsEnabled) {
13611
13816
  [documentSymbols, workspaceUri] = await Promise.all([getDocumentSymbols(editorWithUpdatedSettings), getWorkspaceUri$1()]);
13612
13817
  }
13613
- return resize({
13818
+ const resizedEditor = resize({
13614
13819
  ...editorWithUpdatedSettings,
13615
13820
  documentSymbols,
13616
13821
  workspaceUri
13617
13822
  }, {}, charWidth);
13823
+ return {
13824
+ ...resizedEditor,
13825
+ gutterDecorations: await getEditorGutterDecorations(resizedEditor)
13826
+ };
13618
13827
  };
13619
13828
 
13620
13829
  const applyTabCompletion = (editor, result) => {
@@ -13888,6 +14097,7 @@ const loadContent = async (state, savedState) => {
13888
14097
  breadcrumbsEnabled,
13889
14098
  completionTriggerCharacters,
13890
14099
  diagnosticsEnabled,
14100
+ dragAndDropEnabled,
13891
14101
  fontFamily,
13892
14102
  fontSize,
13893
14103
  fontWeight,
@@ -13919,6 +14129,7 @@ const loadContent = async (state, savedState) => {
13919
14129
  charWidth,
13920
14130
  completionTriggerCharacters,
13921
14131
  diagnosticsEnabled,
14132
+ dragAndDropEnabled,
13922
14133
  fontFamily,
13923
14134
  fontSize,
13924
14135
  fontWeight,
@@ -14087,6 +14298,31 @@ const moveLineUp = editor => {
14087
14298
  return moveLines(editor, -1);
14088
14299
  };
14089
14300
 
14301
+ const refreshGutterDecorations = async editor => {
14302
+ const gutterDecorations = await getEditorGutterDecorations(editor);
14303
+ return {
14304
+ ...editor,
14305
+ gutterDecorations
14306
+ };
14307
+ };
14308
+ const refreshGutterDecorationsAll = async () => {
14309
+ for (const key of getKeys$2()) {
14310
+ const editor = get$8(Number(key))?.newState;
14311
+ if (editor) {
14312
+ const refreshedEditor = await refreshGutterDecorations(editor);
14313
+ const latest = get$8(editor.id);
14314
+ if (!latest) {
14315
+ continue;
14316
+ }
14317
+ set$8(editor.id, latest.oldState, {
14318
+ ...latest.newState,
14319
+ gutterDecorations: refreshedEditor.gutterDecorations
14320
+ });
14321
+ await invoke$a('Editor.renderPending', editor.id);
14322
+ }
14323
+ }
14324
+ };
14325
+
14090
14326
  /**
14091
14327
  * Register a listener for editor events
14092
14328
  * @param listenerType - The type of event to listen for (from ListenerType enum)
@@ -14124,6 +14360,28 @@ ${editorSelector} .EditorLineDecoration {
14124
14360
  margin-left: 2em;
14125
14361
  user-select: none;
14126
14362
  }
14363
+ ${editorSelector} .LineNumber {
14364
+ position: relative;
14365
+ }
14366
+ ${editorSelector} .EditorGutterDecoration {
14367
+ bottom: 0;
14368
+ left: 0;
14369
+ pointer-events: none;
14370
+ position: absolute;
14371
+ top: 0;
14372
+ width: 3px;
14373
+ }
14374
+ ${editorSelector} .EditorGutterDecorationAdded {
14375
+ background: var(--EditorGutterAddedBackground, #2ea043);
14376
+ }
14377
+ ${editorSelector} .EditorGutterDecorationModified {
14378
+ background: var(--EditorGutterModifiedBackground, #0078d4);
14379
+ }
14380
+ ${editorSelector} .EditorGutterDecorationDeleted {
14381
+ background: var(--EditorGutterDeletedBackground, #f85149);
14382
+ height: 3px;
14383
+ top: calc(50% - 1px);
14384
+ }
14127
14385
  ${editorSelector} .R{background-color:#add6ff40}
14128
14386
  ${editorSelector} .BracketMatch {
14129
14387
  position: absolute;
@@ -14813,6 +15071,8 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
14813
15071
  const isBreakpoint = typeof gutterInfo === 'object' && gutterInfo.isBreakpoint;
14814
15072
  const isLightBulb = typeof gutterInfo === 'object' && gutterInfo.isLightBulb;
14815
15073
  const lineNumber = typeof gutterInfo === 'object' ? gutterInfo.lineNumber : gutterInfo;
15074
+ const gutterDecorations = typeof gutterInfo === 'object' ? gutterInfo.gutterDecorations || [] : [];
15075
+ const showLineNumber = typeof gutterInfo !== 'object' || gutterInfo.showLineNumber !== false;
14816
15076
  const label = isLightBulb ? `Show Code Actions on line ${lineNumber}` : `Breakpoint on line ${lineNumber}`;
14817
15077
  let className = lineNumber === activeLineNumber ? 'LineNumber LineNumberActive' : 'LineNumber';
14818
15078
  if (isLightBulb) {
@@ -14828,14 +15088,20 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
14828
15088
  ...(isBreakpoint && !isLightBulb && {
14829
15089
  style: 'color:var(--DebugIconBreakpointForeground,#e51400)'
14830
15090
  }),
14831
- childCount: 1,
15091
+ childCount: gutterDecorations.length + 1,
14832
15092
  className,
14833
15093
  ...(isLightBulb && {
14834
15094
  onClick: HandleLightBulbClick,
14835
15095
  role: Button
14836
15096
  }),
14837
15097
  type: Span
14838
- }, text(isLightBulb ? '' : isBreakpoint ? '●' : lineNumber)];
15098
+ }, ...gutterDecorations.map(decoration => ({
15099
+ ariaLabel: `${decoration.type[0].toUpperCase()}${decoration.type.slice(1)} line ${lineNumber}`,
15100
+ childCount: 0,
15101
+ className: mergeClassNames('EditorGutterDecoration', `EditorGutterDecoration${decoration.type[0].toUpperCase()}${decoration.type.slice(1)}`),
15102
+ title: `${decoration.type[0].toUpperCase()}${decoration.type.slice(1)} line ${lineNumber}`,
15103
+ type: Span
15104
+ })), text(isLightBulb ? '' : isBreakpoint ? '●' : showLineNumber ? lineNumber : '')];
14839
15105
  };
14840
15106
  const getEditorGutterVirtualDom$1 = (gutterInfos, activeLineNumber = -1) => {
14841
15107
  const dom = gutterInfos.flatMap(gutterInfo => getGutterInfoVirtualDom(gutterInfo, activeLineNumber));
@@ -14851,7 +15117,7 @@ const getEditorGutterVirtualDom = (gutterInfos, activeLineNumber = -1) => {
14851
15117
  }, ...gutterDom];
14852
15118
  };
14853
15119
 
14854
- const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true, lineIndices, lightBulbRowIndex = -1) => {
15120
+ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true, lineIndices, lightBulbRowIndex = -1, gutterDecorations = []) => {
14855
15121
  const gutterInfos = [];
14856
15122
  const rows = lineIndices || Array.from({
14857
15123
  length: maxLineY - minLineY
@@ -14860,17 +15126,30 @@ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true,
14860
15126
  const lineNumber = rowIndex + 1;
14861
15127
  const isBreakpoint = breakPoints.includes(rowIndex);
14862
15128
  const isLightBulb = rowIndex === lightBulbRowIndex;
15129
+ const rowDecorations = gutterDecorations.filter(decoration => decoration.rowIndex === rowIndex);
14863
15130
  if (isLightBulb) {
14864
15131
  gutterInfos.push({
15132
+ ...(rowDecorations.length > 0 && {
15133
+ gutterDecorations: rowDecorations
15134
+ }),
14865
15135
  isBreakpoint,
14866
15136
  isLightBulb: true,
14867
15137
  lineNumber
14868
15138
  });
14869
15139
  } else if (isBreakpoint) {
14870
15140
  gutterInfos.push({
15141
+ ...(rowDecorations.length > 0 && {
15142
+ gutterDecorations: rowDecorations
15143
+ }),
14871
15144
  isBreakpoint: true,
14872
15145
  lineNumber
14873
15146
  });
15147
+ } else if (rowDecorations.length > 0) {
15148
+ gutterInfos.push({
15149
+ gutterDecorations: rowDecorations,
15150
+ lineNumber,
15151
+ showLineNumber: showLineNumbers
15152
+ });
14874
15153
  } else {
14875
15154
  gutterInfos.push(showLineNumbers ? lineNumber : '');
14876
15155
  }
@@ -14914,6 +15193,7 @@ const getEditorVirtualDom = ({
14914
15193
  differences,
14915
15194
  documentSymbols = [],
14916
15195
  endOfLineDecorations = [],
15196
+ gutterDecorations = [],
14917
15197
  gutterInfos = [],
14918
15198
  highlightedLine = -1,
14919
15199
  lightBulbRowIndex = -1,
@@ -14943,8 +15223,8 @@ const getEditorVirtualDom = ({
14943
15223
  type: Div
14944
15224
  }, textEditorErrorIconNode, textEditorErrorMessageNode, text(loadError)];
14945
15225
  }
14946
- const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex) : gutterInfos;
14947
- const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0;
15226
+ const visibleGutterInfos = breakPoints.length > 0 || gutterDecorations.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations) : gutterInfos;
15227
+ const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0 || gutterDecorations.length > 0;
14948
15228
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
14949
15229
  const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos, primaryCursorRowIndex + 1) : [];
14950
15230
  const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
@@ -15210,6 +15490,7 @@ const renderGutterInfo = {
15210
15490
  apply(oldState, newState) {
15211
15491
  const {
15212
15492
  breakPoints,
15493
+ gutterDecorations,
15213
15494
  lightBulbRowIndex,
15214
15495
  lineNumbers,
15215
15496
  maxLineY,
@@ -15218,15 +15499,15 @@ const renderGutterInfo = {
15218
15499
  selections,
15219
15500
  visibleLineIndices
15220
15501
  } = newState;
15221
- if (!lineNumbers && breakPoints.length === 0 && lightBulbRowIndex === -1) {
15502
+ if (!lineNumbers && breakPoints.length === 0 && lightBulbRowIndex === -1 && gutterDecorations.length === 0) {
15222
15503
  return ['renderGutter', []];
15223
15504
  }
15224
- const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex);
15505
+ const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations);
15225
15506
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
15226
15507
  const dom = getEditorGutterVirtualDom$1(gutterInfos, primaryCursorRowIndex + 1);
15227
15508
  return ['renderGutter', dom];
15228
15509
  },
15229
- isEqual: (oldState, newState) => oldState.breakPoints === newState.breakPoints && oldState.lightBulbRowIndex === newState.lightBulbRowIndex && oldState.foldingRanges === newState.foldingRanges && oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && getPrimaryCursorRowIndex(oldState.selections, oldState.primarySelectionIndex) === getPrimaryCursorRowIndex(newState.selections, newState.primarySelectionIndex)
15510
+ isEqual: (oldState, newState) => oldState.breakPoints === newState.breakPoints && oldState.gutterDecorations === newState.gutterDecorations && oldState.lightBulbRowIndex === newState.lightBulbRowIndex && oldState.foldingRanges === newState.foldingRanges && oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && getPrimaryCursorRowIndex(oldState.selections, oldState.primarySelectionIndex) === getPrimaryCursorRowIndex(newState.selections, newState.primarySelectionIndex)
15230
15511
  };
15231
15512
  const renderWidgets = {
15232
15513
  apply: renderWidgets$1,
@@ -15300,7 +15581,7 @@ const renderEventListeners = () => {
15300
15581
  preventDefault: true
15301
15582
  }, {
15302
15583
  name: HandleMouseDown,
15303
- params: ['handleMouseDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY, 'event.detail']
15584
+ params: ['handleMouseDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY, 'event.detail', 'event.shiftKey']
15304
15585
  }, {
15305
15586
  name: HandlePointerDown,
15306
15587
  params: ['handlePointerDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY, 'event.detail', 'event.currentTarget.parentElement.parentElement.offsetLeft'],
@@ -15824,6 +16105,8 @@ const commandMap = {
15824
16105
  'Editor.pasteText': wrapCommand(pasteText),
15825
16106
  'Editor.previousDiagnostic': wrapCommand(previousDiagnostic),
15826
16107
  'Editor.redo': wrapCommand(redo),
16108
+ 'Editor.refreshGutterDecorations': wrapCommand(refreshGutterDecorations),
16109
+ 'Editor.refreshGutterDecorationsAll': refreshGutterDecorationsAll,
15827
16110
  'Editor.render': renderEditor,
15828
16111
  'Editor.render2': render2,
15829
16112
  'Editor.renderEventListeners': renderEventListeners,
@@ -15966,6 +16249,14 @@ for (const [key, value] of Object.entries(commandMap)) {
15966
16249
  }
15967
16250
  }
15968
16251
 
16252
+ const initializeDragAndDropWorker = async () => {
16253
+ const rpc = await create$d({
16254
+ commandMap: {},
16255
+ send: sendMessagePortToDragAndDropWorker
16256
+ });
16257
+ set$f(rpc);
16258
+ };
16259
+
15969
16260
  const initializeErrorWorker = async () => {
15970
16261
  const rpc = await create$d({
15971
16262
  commandMap: {},
@@ -16027,12 +16318,12 @@ const initializeTextMeasurementWorker = async () => {
16027
16318
 
16028
16319
  const listen = async () => {
16029
16320
  registerCommands(commandMap);
16030
- await Promise.all([initializeRendererWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
16321
+ await Promise.all([initializeRendererWorker(), initializeDragAndDropWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
16031
16322
  const dialogRpc = await create$d({
16032
16323
  commandMap: {},
16033
16324
  send: sendMessagePortToDialogWorker
16034
16325
  });
16035
- set$f(dialogRpc);
16326
+ set$g(dialogRpc);
16036
16327
  };
16037
16328
 
16038
16329
  const CodeGeneratorInput = 'CodeGeneratorInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.45.0",
3
+ "version": "19.47.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"