@lvce-editor/status-bar-worker 3.29.0 → 3.30.1

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.
@@ -1288,6 +1288,9 @@ const restoreExistingError = (error, currentStack) => {
1288
1288
  };
1289
1289
  const restoreMethodNotFoundError = (error, currentStack) => {
1290
1290
  const restoredError = new JsonRpcError(error.message);
1291
+ Object.assign(restoredError, {
1292
+ code: error.code
1293
+ });
1291
1294
  const parentStack = getParentStack(error);
1292
1295
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
1293
1296
  return restoredError;
@@ -1307,9 +1310,13 @@ const applyDataProperties = (restoredError, error) => {
1307
1310
  // @ts-ignore
1308
1311
  restoredError.codeFrame = error.data.codeFrame;
1309
1312
  }
1310
- if (error.data.code) {
1313
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
1311
1314
  // @ts-ignore
1312
- restoredError.code = error.data.code;
1315
+ Object.defineProperty(restoredError, 'code', {
1316
+ configurable: true,
1317
+ value: error.data.code,
1318
+ writable: true
1319
+ });
1313
1320
  }
1314
1321
  if (error.data.type) {
1315
1322
  // @ts-ignore
@@ -1331,6 +1338,13 @@ const applyDirectProperties = (restoredError, error) => {
1331
1338
  };
1332
1339
  const restoreMessageError = (error, _currentStack) => {
1333
1340
  const restoredError = constructError(error.message, error.type, error.name);
1341
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
1342
+ Object.defineProperty(restoredError, 'code', {
1343
+ configurable: true,
1344
+ value: error.code,
1345
+ writable: true
1346
+ });
1347
+ }
1334
1348
  if (error.data) {
1335
1349
  applyDataProperties(restoredError, error);
1336
1350
  } else {
@@ -1409,7 +1423,7 @@ const getErrorProperty = (error, prettyError) => {
1409
1423
  return {
1410
1424
  code: Custom,
1411
1425
  data: {
1412
- code: prettyError.code,
1426
+ code: prettyError.code ?? error?.code,
1413
1427
  codeFrame: prettyError.codeFrame,
1414
1428
  name: prettyError.name,
1415
1429
  stack: getStack(prettyError),
@@ -1446,7 +1460,12 @@ const getErrorResponseSimple = (id, error) => {
1446
1460
  return {
1447
1461
  error: {
1448
1462
  code: Custom,
1449
- data: error,
1463
+ data: error instanceof Error ? {
1464
+ ...error,
1465
+ code: 'code' in error ? error.code : undefined,
1466
+ stack: error.stack,
1467
+ type: error.name
1468
+ } : error,
1450
1469
  // @ts-ignore
1451
1470
  message: error.message
1452
1471
  },
@@ -1880,7 +1899,7 @@ const applyUpdate = update => {
1880
1899
  ...editorStatus,
1881
1900
  ...update
1882
1901
  };
1883
- if (typeof next.column !== 'number' || typeof next.encoding !== 'string' || typeof next.endOfLine !== 'string' || typeof next.insertSpaces !== 'boolean' || typeof next.languageId !== 'string' || typeof next.line !== 'number' || typeof next.tabSize !== 'number') {
1902
+ if (typeof next.column !== 'number' || typeof next.encoding !== 'string' || typeof next.endOfLine !== 'string' || typeof next.insertSpaces !== 'boolean' || typeof next.languageId !== 'string' || typeof next.line !== 'number' || next.selectedChars !== undefined && typeof next.selectedChars !== 'number' || typeof next.tabSize !== 'number') {
1884
1903
  throw new TypeError('The first editor status update must contain a complete status');
1885
1904
  }
1886
1905
  editorStatus = next;
@@ -1908,12 +1927,15 @@ const getEditorStatusBarItems = status => {
1908
1927
  insertSpaces = true,
1909
1928
  languageId,
1910
1929
  line,
1930
+ selectedChars = 0,
1911
1931
  tabSize
1912
1932
  } = status;
1913
1933
  const encodingLabel = encoding === 'utf8' ? ['UTF', '8'].join('-') : encoding;
1914
1934
  const indentationLabel = insertSpaces ? `Spaces: ${tabSize}` : `Tab Size: ${tabSize}`;
1915
1935
  const endOfLineLabel = endOfLine.toUpperCase();
1916
- return [textItem(EditorPosition, `Ln ${line}, Col ${column}`, `Line ${line}, Column ${column}`, 'Go to Line/Column'), textItem(EditorIndentation, indentationLabel, indentationLabel, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorEndOfLine, endOfLineLabel, `End of Line: ${endOfLineLabel}`, 'Select End of Line Sequence'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
1936
+ const positionLabel = selectedChars > 0 ? `Ln ${line}, Col ${column} (${selectedChars} selected)` : `Ln ${line}, Col ${column}`;
1937
+ const positionAriaLabel = selectedChars > 0 ? `Line ${line}, Column ${column}, ${selectedChars} selected` : `Line ${line}, Column ${column}`;
1938
+ return [textItem(EditorPosition, positionLabel, positionAriaLabel, 'Go to Line/Column'), textItem(EditorIndentation, indentationLabel, indentationLabel, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorEndOfLine, endOfLineLabel, `End of Line: ${endOfLineLabel}`, 'Select End of Line Sequence'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
1917
1939
  };
1918
1940
 
1919
1941
  const dependencies = {
@@ -1921,7 +1943,7 @@ const dependencies = {
1921
1943
  [EditorEndOfLine]: ['endOfLine'],
1922
1944
  [EditorIndentation]: ['insertSpaces', 'tabSize'],
1923
1945
  [EditorLanguage]: ['languageId'],
1924
- [EditorPosition]: ['line', 'column']
1946
+ [EditorPosition]: ['line', 'column', 'selectedChars']
1925
1947
  };
1926
1948
  const handleEditorStatusChanged = (state, editorStatus, previous = state) => {
1927
1949
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.29.0",
3
+ "version": "3.30.1",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",