@lvce-editor/editor-worker 19.30.0 → 19.30.2

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.
@@ -8054,6 +8054,55 @@ const requestAnimationFrame = fn => {
8054
8054
  globalThis.requestAnimationFrame(fn);
8055
8055
  };
8056
8056
 
8057
+ const getDiagnosticType = diagnostic => {
8058
+ return diagnostic.type;
8059
+ };
8060
+
8061
+ const getY = (row, minLineY, rowHeight) => {
8062
+ return (row - minLineY) * rowHeight;
8063
+ };
8064
+
8065
+ const getVisibleDiagnostics = async (editor, diagnostics) => {
8066
+ const visibleDiagnostics = [];
8067
+ const {
8068
+ charWidth,
8069
+ fontFamily,
8070
+ fontSize,
8071
+ fontWeight,
8072
+ isMonospaceFont,
8073
+ letterSpacing,
8074
+ lines,
8075
+ minLineY,
8076
+ rowHeight,
8077
+ tabSize,
8078
+ width
8079
+ } = editor;
8080
+ for (const diagnostic of diagnostics) {
8081
+ const {
8082
+ columnIndex,
8083
+ endColumnIndex,
8084
+ rowIndex
8085
+ } = diagnostic;
8086
+ const columnDelta = endColumnIndex - columnIndex;
8087
+ const diagnosticWidth = columnDelta * charWidth;
8088
+ const endLineDifference = 0;
8089
+ const halfCursorWidth = 0;
8090
+ const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
8091
+ const y = getY(rowIndex, minLineY, rowHeight);
8092
+ visibleDiagnostics.push({
8093
+ height: rowHeight,
8094
+ type: getDiagnosticType(diagnostic),
8095
+ width: diagnosticWidth,
8096
+ x,
8097
+ y
8098
+ });
8099
+ }
8100
+ return visibleDiagnostics;
8101
+ };
8102
+
8103
+ const shouldUpdateDiagnosticData = (oldState, newState) => {
8104
+ return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
8105
+ };
8057
8106
  const shouldUpdateSelectionData = (oldState, newState) => {
8058
8107
  return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
8059
8108
  };
@@ -8078,6 +8127,13 @@ const updateDerivedState = async (oldState, newState) => {
8078
8127
  textInfos
8079
8128
  };
8080
8129
  }
8130
+ if (shouldUpdateDiagnosticData(oldState, nextState)) {
8131
+ const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
8132
+ finalState = {
8133
+ ...finalState,
8134
+ visualDecorations
8135
+ };
8136
+ }
8081
8137
  if (!shouldUpdateSelectionData(oldState, nextState)) {
8082
8138
  return finalState;
8083
8139
  }
@@ -12003,7 +12059,10 @@ const getProblems = async () => {
12003
12059
  if (!editor?.newState) {
12004
12060
  return [];
12005
12061
  }
12006
- return editor.newState.diagnostics;
12062
+ return editor.newState.diagnostics.map(diagnostic => ({
12063
+ ...diagnostic,
12064
+ uri: diagnostic.uri || editor.newState.uri
12065
+ }));
12007
12066
  });
12008
12067
  return diagnostics;
12009
12068
  };
@@ -13710,52 +13769,6 @@ const executeDiagnosticProvider = async editor => {
13710
13769
  return executeIsolatedDiagnosticProvider(editor);
13711
13770
  };
13712
13771
 
13713
- const getDiagnosticType = diagnostic => {
13714
- return diagnostic.type;
13715
- };
13716
-
13717
- const getY = (row, minLineY, rowHeight) => {
13718
- return (row - minLineY) * rowHeight;
13719
- };
13720
-
13721
- const getVisibleDiagnostics = async (editor, diagnostics) => {
13722
- const visibleDiagnostics = [];
13723
- const {
13724
- charWidth,
13725
- fontFamily,
13726
- fontSize,
13727
- fontWeight,
13728
- isMonospaceFont,
13729
- letterSpacing,
13730
- lines,
13731
- minLineY,
13732
- rowHeight,
13733
- tabSize,
13734
- width
13735
- } = editor;
13736
- for (const diagnostic of diagnostics) {
13737
- const {
13738
- columnIndex,
13739
- endColumnIndex,
13740
- rowIndex
13741
- } = diagnostic;
13742
- const columnDelta = endColumnIndex - columnIndex;
13743
- const diagnosticWidth = columnDelta * charWidth;
13744
- const endLineDifference = 0;
13745
- const halfCursorWidth = 0;
13746
- const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
13747
- const y = getY(rowIndex, minLineY, rowHeight);
13748
- visibleDiagnostics.push({
13749
- height: rowHeight,
13750
- type: getDiagnosticType(diagnostic),
13751
- width: diagnosticWidth,
13752
- x,
13753
- y
13754
- });
13755
- }
13756
- return visibleDiagnostics;
13757
- };
13758
-
13759
13772
  /**
13760
13773
  * Merges link decorations with diagnostic decorations
13761
13774
  * Links should always be present, but we also need to include any diagnostic decorations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.30.0",
3
+ "version": "19.30.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"