@lvce-editor/process-explorer-worker 3.21.0 → 3.21.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.
Files changed (2) hide show
  1. package/index.js +28 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -269,6 +269,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
269
269
  const state = {
270
270
  assetDir,
271
271
  collapsedPids: [],
272
+ errorCode: '',
272
273
  errorCodeFrame: '',
273
274
  errorMessage: '',
274
275
  errorStack: '',
@@ -1587,7 +1588,7 @@ const isEqual$1 = (oldState, newState) => {
1587
1588
  };
1588
1589
 
1589
1590
  const isEqual = (oldState, newState) => {
1590
- return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.focusedIndex === newState.focusedIndex && oldState.visibleProcesses === newState.visibleProcesses;
1591
+ return oldState.initial === newState.initial && oldState.errorCode === newState.errorCode && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.focusedIndex === newState.focusedIndex && oldState.visibleProcesses === newState.visibleProcesses;
1591
1592
  };
1592
1593
 
1593
1594
  const RenderItems = 1;
@@ -1658,10 +1659,15 @@ const restart = (uid, interval) => {
1658
1659
  start(uid, interval);
1659
1660
  };
1660
1661
 
1662
+ const ProcessExplorerError = 'E_PROCESS_EXPLORER_ERROR';
1663
+ const ProcessExplorerRefreshFailed = 'E_PROCESS_EXPLORER_REFRESH_FAILED';
1664
+ const ProcessExplorerRpcConnectionClosed = 'E_PROCESS_EXPLORER_RPC_CONNECTION_CLOSED';
1665
+
1661
1666
  const processExplorerRpcClosedMessage = 'Process explorer RPC connection was closed';
1662
1667
  const toProcessExplorerRpcClosedState = state => {
1663
1668
  return {
1664
1669
  ...state,
1670
+ errorCode: ProcessExplorerRpcConnectionClosed,
1665
1671
  errorCodeFrame: '',
1666
1672
  errorMessage: processExplorerRpcClosedMessage,
1667
1673
  errorStack: '',
@@ -2411,6 +2417,17 @@ const killProcess = async (state, index = state.focusedIndex) => {
2411
2417
  return state;
2412
2418
  };
2413
2419
 
2420
+ const getErrorCode = (error, fallback) => {
2421
+ if (!error || typeof error !== 'object') {
2422
+ return fallback;
2423
+ }
2424
+ const code = 'code' in error ? error.code : undefined;
2425
+ if (typeof code !== 'string' || !code) {
2426
+ return fallback;
2427
+ }
2428
+ return code;
2429
+ };
2430
+
2414
2431
  const getMeasureMemory = () => {
2415
2432
  const {
2416
2433
  measureUserAgentSpecificMemory
@@ -2564,6 +2581,7 @@ const refresh = async state => {
2564
2581
  const visibleProcesses = getVisibleProcesses(displayedProcesses, state.collapsedPids, rootPid);
2565
2582
  return {
2566
2583
  ...state,
2584
+ errorCode: '',
2567
2585
  errorCodeFrame: '',
2568
2586
  errorMessage: '',
2569
2587
  errorStack: '',
@@ -2577,6 +2595,7 @@ const refresh = async state => {
2577
2595
  const prettyError = await prepareError(error);
2578
2596
  return {
2579
2597
  ...state,
2598
+ errorCode: getErrorCode(error, ProcessExplorerRefreshFailed),
2580
2599
  errorCodeFrame: prettyError.codeFrame || '',
2581
2600
  errorMessage: prettyError.message || getErrorMessage(error),
2582
2601
  errorStack: prettyError.stack || '',
@@ -2586,7 +2605,7 @@ const refresh = async state => {
2586
2605
  };
2587
2606
 
2588
2607
  const hasError$1 = state => {
2589
- return Boolean(state.errorMessage || state.errorCodeFrame || state.errorStack);
2608
+ return Boolean(state.errorCode || state.errorMessage || state.errorCodeFrame || state.errorStack);
2590
2609
  };
2591
2610
  const loadContent = async state => {
2592
2611
  const newState = await refresh(state);
@@ -3032,27 +3051,30 @@ const getErrorSectionDom = (value, type) => {
3032
3051
  };
3033
3052
  const hasError = state => {
3034
3053
  const {
3054
+ errorCode,
3035
3055
  errorCodeFrame,
3036
3056
  errorMessage,
3037
3057
  errorStack
3038
3058
  } = state;
3039
- return Boolean(errorMessage || errorCodeFrame || errorStack);
3059
+ return Boolean(errorCode || errorMessage || errorCodeFrame || errorStack);
3040
3060
  };
3041
3061
  const getErrorDom = state => {
3042
3062
  const {
3063
+ errorCode,
3043
3064
  errorCodeFrame,
3044
3065
  errorMessage,
3045
3066
  errorStack
3046
3067
  } = state;
3068
+ const errorCodeDom = getErrorSectionDom(errorCode, Div);
3047
3069
  const messageDom = getErrorSectionDom(errorMessage, Div);
3048
3070
  const codeFrameDom = getErrorSectionDom(errorCodeFrame, Pre);
3049
3071
  const stackDom = getErrorSectionDom(errorStack, Pre);
3050
- const childCount = messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
3072
+ const childCount = errorCodeDom.length / 2 + messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
3051
3073
  return [processExplorer, {
3052
3074
  childCount,
3053
3075
  className: Error$1,
3054
3076
  type: Div
3055
- }, ...messageDom, ...codeFrameDom, ...stackDom];
3077
+ }, ...errorCodeDom, ...messageDom, ...codeFrameDom, ...stackDom];
3056
3078
  };
3057
3079
  const getTableDom = state => {
3058
3080
  const {
@@ -3206,6 +3228,7 @@ const setError = async (state, rawError) => {
3206
3228
  const prettyError = await prepareError(error);
3207
3229
  return {
3208
3230
  ...state,
3231
+ errorCode: getErrorCode(error, ProcessExplorerError),
3209
3232
  errorCodeFrame: prettyError.codeFrame || '',
3210
3233
  errorMessage: prettyError.message || getErrorMessage(error),
3211
3234
  errorStack: prettyError.stack || '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/process-explorer-worker",
3
- "version": "3.21.0",
3
+ "version": "3.21.1",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",