@lvce-editor/extension-host-worker 5.7.0 → 5.9.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.
@@ -834,6 +834,14 @@ const pause = async protocol => {
834
834
  throw new VError(error, 'Failed to execute debug provider');
835
835
  }
836
836
  };
837
+ const getScriptSource = async (protocol, scriptId) => {
838
+ try {
839
+ const provider = getDebugProvider(protocol);
840
+ return await provider.getScriptSource(scriptId);
841
+ } catch (error) {
842
+ throw new VError(error, 'Failed to execute debug provider');
843
+ }
844
+ };
837
845
  const stepInto = async protocol => {
838
846
  try {
839
847
  const provider = getDebugProvider(protocol);
@@ -1730,6 +1738,16 @@ const constructError = (message, type, name) => {
1730
1738
  }
1731
1739
  return new ErrorConstructor(message);
1732
1740
  };
1741
+ const joinLines = lines => {
1742
+ return lines.join(NewLine$1);
1743
+ };
1744
+ const splitLines$1 = lines => {
1745
+ return lines.split(NewLine$1);
1746
+ };
1747
+ const getCurrentStack = () => {
1748
+ const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(2));
1749
+ return currentStack;
1750
+ };
1733
1751
  const getNewLineIndex = (string, startIndex = undefined) => {
1734
1752
  return string.indexOf(NewLine$1, startIndex);
1735
1753
  };
@@ -1740,19 +1758,16 @@ const getParentStack = error => {
1740
1758
  }
1741
1759
  return parentStack;
1742
1760
  };
1743
- const joinLines = lines => {
1744
- return lines.join(NewLine$1);
1745
- };
1746
1761
  const MethodNotFound = -32601;
1747
1762
  const Custom = -32001;
1748
- const splitLines$1 = lines => {
1749
- return lines.split(NewLine$1);
1750
- };
1751
1763
  const restoreJsonRpcError = error => {
1764
+ const currentStack = getCurrentStack();
1752
1765
  if (error && error instanceof Error) {
1766
+ if (typeof error.stack === 'string') {
1767
+ error.stack = error.stack + NewLine$1 + currentStack;
1768
+ }
1753
1769
  return error;
1754
1770
  }
1755
- const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
1756
1771
  if (error && error.code && error.code === MethodNotFound) {
1757
1772
  const restoredError = new JsonRpcError(error.message);
1758
1773
  const parentStack = getParentStack(error);
@@ -1833,6 +1848,17 @@ const getErrorType = prettyError => {
1833
1848
  }
1834
1849
  return undefined;
1835
1850
  };
1851
+ const isAlreadyStack = line => {
1852
+ return line.trim().startsWith('at ');
1853
+ };
1854
+ const getStack = prettyError => {
1855
+ const stackString = prettyError.stack || '';
1856
+ const newLineIndex = stackString.indexOf('\n');
1857
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
1858
+ return stackString.slice(newLineIndex + 1);
1859
+ }
1860
+ return stackString;
1861
+ };
1836
1862
  const getErrorProperty = (error, prettyError) => {
1837
1863
  if (error && error.code === E_COMMAND_NOT_FOUND) {
1838
1864
  return {
@@ -1845,7 +1871,7 @@ const getErrorProperty = (error, prettyError) => {
1845
1871
  code: Custom,
1846
1872
  message: prettyError.message,
1847
1873
  data: {
1848
- stack: prettyError.stack,
1874
+ stack: getStack(prettyError),
1849
1875
  codeFrame: prettyError.codeFrame,
1850
1876
  type: getErrorType(prettyError),
1851
1877
  code: prettyError.code,
@@ -5576,6 +5602,7 @@ const commandMap = {
5576
5602
  'ExecuteExternalCommand.executeExternalCommand': executeExternalCommand,
5577
5603
  'ExtensionHostDebug.evaluate': evaluate,
5578
5604
  'ExtensionHostDebug.getProperties': getProperties,
5605
+ 'ExtensionHostDebug.getScriptSource': getScriptSource,
5579
5606
  'ExtensionHostDebug.listProcesses': listProcesses,
5580
5607
  'ExtensionHostDebug.pause': pause,
5581
5608
  'ExtensionHostDebug.resume': resume,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "5.7.0",
3
+ "version": "5.9.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"