@lvce-editor/editor-worker 19.45.0 → 19.46.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.
@@ -4361,6 +4361,44 @@ const updateColorPickerValue$1 = async (editor, value) => {
4361
4361
  };
4362
4362
  };
4363
4363
 
4364
+ const validTypes = new Set(['added', 'deleted', 'modified']);
4365
+ const isProviderDecoration$1 = value => {
4366
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
4367
+ };
4368
+ const getProviderDecorations$1 = results => {
4369
+ if (!Array.isArray(results)) {
4370
+ return [];
4371
+ }
4372
+ const decorations = [];
4373
+ for (const result of results) {
4374
+ if (!Array.isArray(result)) {
4375
+ continue;
4376
+ }
4377
+ for (const decoration of result) {
4378
+ if (isProviderDecoration$1(decoration) && Number.isSafeInteger(decoration.rowIndex) && decoration.rowIndex >= 0 && typeof decoration.type === 'string' && validTypes.has(decoration.type)) {
4379
+ decorations.push({
4380
+ rowIndex: decoration.rowIndex,
4381
+ type: decoration.type
4382
+ });
4383
+ }
4384
+ }
4385
+ }
4386
+ return decorations;
4387
+ };
4388
+ const getEditorGutterDecorations = async editor => {
4389
+ const textDocument = {
4390
+ languageId: editor.languageId,
4391
+ text: getText$1(editor),
4392
+ uri: editor.uri
4393
+ };
4394
+ try {
4395
+ const results = await invoke$d('Extensions.executeProvidersByEvent', 'onEditorGutterDecoration', 'ExtensionApi.executeEditorGutterDecorationProvider', textDocument);
4396
+ return getProviderDecorations$1(results);
4397
+ } catch {
4398
+ return [];
4399
+ }
4400
+ };
4401
+
4364
4402
  const diagnosticContainsPosition = (diagnostic, rowIndex, columnIndex) => {
4365
4403
  const {
4366
4404
  columnIndex: startColumnIndex,
@@ -4838,6 +4876,12 @@ const updateDerivedState = async (oldState, newState) => {
4838
4876
  lightBulbRowIndex: await getLightBulbRowIndex(finalState)
4839
4877
  };
4840
4878
  }
4879
+ if (oldState.lines !== nextState.lines || oldState.uri !== nextState.uri) {
4880
+ finalState = {
4881
+ ...finalState,
4882
+ gutterDecorations: await getEditorGutterDecorations(finalState)
4883
+ };
4884
+ }
4841
4885
  if (!shouldUpdateSelectionData(oldState, nextState)) {
4842
4886
  return finalState;
4843
4887
  }
@@ -4977,6 +5021,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4977
5021
  fontFamily: '',
4978
5022
  fontSize: 0,
4979
5023
  fontWeight: 0,
5024
+ gutterDecorations: [],
4980
5025
  gutterWidth: 0,
4981
5026
  handleOffset: 0,
4982
5027
  handleOffsetX: 0,
@@ -5067,6 +5112,7 @@ const emptyEditor = {
5067
5112
  endOfLineDecorations: [],
5068
5113
  focused: false,
5069
5114
  foldingRanges: [],
5115
+ gutterDecorations: [],
5070
5116
  hasListener: false,
5071
5117
  height: 0,
5072
5118
  highlightedLine: -1,
@@ -5261,6 +5307,7 @@ const createEditor = async ({
5261
5307
  fontFamily,
5262
5308
  fontSize,
5263
5309
  fontWeight,
5310
+ gutterDecorations: [],
5264
5311
  gutterWidth: 0,
5265
5312
  handleOffset: 0,
5266
5313
  handleOffsetX: 0,
@@ -5455,7 +5502,7 @@ const isEqual$3 = (oldState, newState) => {
5455
5502
  };
5456
5503
 
5457
5504
  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;
5505
+ 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
5506
  };
5460
5507
 
5461
5508
  const isEqual$1 = (oldState, newState) => {
@@ -13610,11 +13657,15 @@ const handleSettingsChanged = async state => {
13610
13657
  } else if (!state.breadcrumbsEnabled) {
13611
13658
  [documentSymbols, workspaceUri] = await Promise.all([getDocumentSymbols(editorWithUpdatedSettings), getWorkspaceUri$1()]);
13612
13659
  }
13613
- return resize({
13660
+ const resizedEditor = resize({
13614
13661
  ...editorWithUpdatedSettings,
13615
13662
  documentSymbols,
13616
13663
  workspaceUri
13617
13664
  }, {}, charWidth);
13665
+ return {
13666
+ ...resizedEditor,
13667
+ gutterDecorations: await getEditorGutterDecorations(resizedEditor)
13668
+ };
13618
13669
  };
13619
13670
 
13620
13671
  const applyTabCompletion = (editor, result) => {
@@ -14087,6 +14138,31 @@ const moveLineUp = editor => {
14087
14138
  return moveLines(editor, -1);
14088
14139
  };
14089
14140
 
14141
+ const refreshGutterDecorations = async editor => {
14142
+ const gutterDecorations = await getEditorGutterDecorations(editor);
14143
+ return {
14144
+ ...editor,
14145
+ gutterDecorations
14146
+ };
14147
+ };
14148
+ const refreshGutterDecorationsAll = async () => {
14149
+ for (const key of getKeys$2()) {
14150
+ const editor = get$8(Number(key))?.newState;
14151
+ if (editor) {
14152
+ const refreshedEditor = await refreshGutterDecorations(editor);
14153
+ const latest = get$8(editor.id);
14154
+ if (!latest) {
14155
+ continue;
14156
+ }
14157
+ set$8(editor.id, latest.oldState, {
14158
+ ...latest.newState,
14159
+ gutterDecorations: refreshedEditor.gutterDecorations
14160
+ });
14161
+ await invoke$a('Editor.renderPending', editor.id);
14162
+ }
14163
+ }
14164
+ };
14165
+
14090
14166
  /**
14091
14167
  * Register a listener for editor events
14092
14168
  * @param listenerType - The type of event to listen for (from ListenerType enum)
@@ -14124,6 +14200,28 @@ ${editorSelector} .EditorLineDecoration {
14124
14200
  margin-left: 2em;
14125
14201
  user-select: none;
14126
14202
  }
14203
+ ${editorSelector} .LineNumber {
14204
+ position: relative;
14205
+ }
14206
+ ${editorSelector} .EditorGutterDecoration {
14207
+ bottom: 0;
14208
+ left: 0;
14209
+ pointer-events: none;
14210
+ position: absolute;
14211
+ top: 0;
14212
+ width: 3px;
14213
+ }
14214
+ ${editorSelector} .EditorGutterDecorationAdded {
14215
+ background: var(--EditorGutterAddedBackground, #2ea043);
14216
+ }
14217
+ ${editorSelector} .EditorGutterDecorationModified {
14218
+ background: var(--EditorGutterModifiedBackground, #0078d4);
14219
+ }
14220
+ ${editorSelector} .EditorGutterDecorationDeleted {
14221
+ background: var(--EditorGutterDeletedBackground, #f85149);
14222
+ height: 3px;
14223
+ top: calc(50% - 1px);
14224
+ }
14127
14225
  ${editorSelector} .R{background-color:#add6ff40}
14128
14226
  ${editorSelector} .BracketMatch {
14129
14227
  position: absolute;
@@ -14813,6 +14911,8 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
14813
14911
  const isBreakpoint = typeof gutterInfo === 'object' && gutterInfo.isBreakpoint;
14814
14912
  const isLightBulb = typeof gutterInfo === 'object' && gutterInfo.isLightBulb;
14815
14913
  const lineNumber = typeof gutterInfo === 'object' ? gutterInfo.lineNumber : gutterInfo;
14914
+ const gutterDecorations = typeof gutterInfo === 'object' ? gutterInfo.gutterDecorations || [] : [];
14915
+ const showLineNumber = typeof gutterInfo !== 'object' || gutterInfo.showLineNumber !== false;
14816
14916
  const label = isLightBulb ? `Show Code Actions on line ${lineNumber}` : `Breakpoint on line ${lineNumber}`;
14817
14917
  let className = lineNumber === activeLineNumber ? 'LineNumber LineNumberActive' : 'LineNumber';
14818
14918
  if (isLightBulb) {
@@ -14828,14 +14928,20 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
14828
14928
  ...(isBreakpoint && !isLightBulb && {
14829
14929
  style: 'color:var(--DebugIconBreakpointForeground,#e51400)'
14830
14930
  }),
14831
- childCount: 1,
14931
+ childCount: gutterDecorations.length + 1,
14832
14932
  className,
14833
14933
  ...(isLightBulb && {
14834
14934
  onClick: HandleLightBulbClick,
14835
14935
  role: Button
14836
14936
  }),
14837
14937
  type: Span
14838
- }, text(isLightBulb ? '' : isBreakpoint ? '●' : lineNumber)];
14938
+ }, ...gutterDecorations.map(decoration => ({
14939
+ ariaLabel: `${decoration.type[0].toUpperCase()}${decoration.type.slice(1)} line ${lineNumber}`,
14940
+ childCount: 0,
14941
+ className: mergeClassNames('EditorGutterDecoration', `EditorGutterDecoration${decoration.type[0].toUpperCase()}${decoration.type.slice(1)}`),
14942
+ title: `${decoration.type[0].toUpperCase()}${decoration.type.slice(1)} line ${lineNumber}`,
14943
+ type: Span
14944
+ })), text(isLightBulb ? '' : isBreakpoint ? '●' : showLineNumber ? lineNumber : '')];
14839
14945
  };
14840
14946
  const getEditorGutterVirtualDom$1 = (gutterInfos, activeLineNumber = -1) => {
14841
14947
  const dom = gutterInfos.flatMap(gutterInfo => getGutterInfoVirtualDom(gutterInfo, activeLineNumber));
@@ -14851,7 +14957,7 @@ const getEditorGutterVirtualDom = (gutterInfos, activeLineNumber = -1) => {
14851
14957
  }, ...gutterDom];
14852
14958
  };
14853
14959
 
14854
- const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true, lineIndices, lightBulbRowIndex = -1) => {
14960
+ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true, lineIndices, lightBulbRowIndex = -1, gutterDecorations = []) => {
14855
14961
  const gutterInfos = [];
14856
14962
  const rows = lineIndices || Array.from({
14857
14963
  length: maxLineY - minLineY
@@ -14860,17 +14966,30 @@ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true,
14860
14966
  const lineNumber = rowIndex + 1;
14861
14967
  const isBreakpoint = breakPoints.includes(rowIndex);
14862
14968
  const isLightBulb = rowIndex === lightBulbRowIndex;
14969
+ const rowDecorations = gutterDecorations.filter(decoration => decoration.rowIndex === rowIndex);
14863
14970
  if (isLightBulb) {
14864
14971
  gutterInfos.push({
14972
+ ...(rowDecorations.length > 0 && {
14973
+ gutterDecorations: rowDecorations
14974
+ }),
14865
14975
  isBreakpoint,
14866
14976
  isLightBulb: true,
14867
14977
  lineNumber
14868
14978
  });
14869
14979
  } else if (isBreakpoint) {
14870
14980
  gutterInfos.push({
14981
+ ...(rowDecorations.length > 0 && {
14982
+ gutterDecorations: rowDecorations
14983
+ }),
14871
14984
  isBreakpoint: true,
14872
14985
  lineNumber
14873
14986
  });
14987
+ } else if (rowDecorations.length > 0) {
14988
+ gutterInfos.push({
14989
+ gutterDecorations: rowDecorations,
14990
+ lineNumber,
14991
+ showLineNumber: showLineNumbers
14992
+ });
14874
14993
  } else {
14875
14994
  gutterInfos.push(showLineNumbers ? lineNumber : '');
14876
14995
  }
@@ -14914,6 +15033,7 @@ const getEditorVirtualDom = ({
14914
15033
  differences,
14915
15034
  documentSymbols = [],
14916
15035
  endOfLineDecorations = [],
15036
+ gutterDecorations = [],
14917
15037
  gutterInfos = [],
14918
15038
  highlightedLine = -1,
14919
15039
  lightBulbRowIndex = -1,
@@ -14943,8 +15063,8 @@ const getEditorVirtualDom = ({
14943
15063
  type: Div
14944
15064
  }, textEditorErrorIconNode, textEditorErrorMessageNode, text(loadError)];
14945
15065
  }
14946
- const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex) : gutterInfos;
14947
- const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0;
15066
+ const visibleGutterInfos = breakPoints.length > 0 || gutterDecorations.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations) : gutterInfos;
15067
+ const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0 || gutterDecorations.length > 0;
14948
15068
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
14949
15069
  const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos, primaryCursorRowIndex + 1) : [];
14950
15070
  const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
@@ -15210,6 +15330,7 @@ const renderGutterInfo = {
15210
15330
  apply(oldState, newState) {
15211
15331
  const {
15212
15332
  breakPoints,
15333
+ gutterDecorations,
15213
15334
  lightBulbRowIndex,
15214
15335
  lineNumbers,
15215
15336
  maxLineY,
@@ -15218,15 +15339,15 @@ const renderGutterInfo = {
15218
15339
  selections,
15219
15340
  visibleLineIndices
15220
15341
  } = newState;
15221
- if (!lineNumbers && breakPoints.length === 0 && lightBulbRowIndex === -1) {
15342
+ if (!lineNumbers && breakPoints.length === 0 && lightBulbRowIndex === -1 && gutterDecorations.length === 0) {
15222
15343
  return ['renderGutter', []];
15223
15344
  }
15224
- const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex);
15345
+ const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations);
15225
15346
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
15226
15347
  const dom = getEditorGutterVirtualDom$1(gutterInfos, primaryCursorRowIndex + 1);
15227
15348
  return ['renderGutter', dom];
15228
15349
  },
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)
15350
+ 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
15351
  };
15231
15352
  const renderWidgets = {
15232
15353
  apply: renderWidgets$1,
@@ -15824,6 +15945,8 @@ const commandMap = {
15824
15945
  'Editor.pasteText': wrapCommand(pasteText),
15825
15946
  'Editor.previousDiagnostic': wrapCommand(previousDiagnostic),
15826
15947
  'Editor.redo': wrapCommand(redo),
15948
+ 'Editor.refreshGutterDecorations': wrapCommand(refreshGutterDecorations),
15949
+ 'Editor.refreshGutterDecorationsAll': refreshGutterDecorationsAll,
15827
15950
  'Editor.render': renderEditor,
15828
15951
  'Editor.render2': render2,
15829
15952
  'Editor.renderEventListeners': renderEventListeners,
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.46.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"