@lvce-editor/main-area-worker 9.74.0 → 9.74.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.
@@ -628,9 +628,12 @@ const applyDataProperties = (restoredError, error) => {
628
628
  writable: true
629
629
  });
630
630
  }
631
- if (error.data.type) {
632
- // @ts-ignore
633
- restoredError.name = error.data.type;
631
+ const name = error.data.name || error.data.type;
632
+ if (name) {
633
+ Object.defineProperty(restoredError, 'name', {
634
+ configurable: true,
635
+ value: name
636
+ });
634
637
  }
635
638
  };
636
639
  const applyDirectProperties = (restoredError, error) => {
@@ -647,7 +650,7 @@ const applyDirectProperties = (restoredError, error) => {
647
650
  }
648
651
  };
649
652
  const restoreMessageError = (error, _currentStack) => {
650
- const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
653
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name || error.data?.name);
651
654
  if (typeof error.code === 'string' || typeof error.code === 'number') {
652
655
  Object.defineProperty(restoredError, 'code', {
653
656
  configurable: true,
@@ -5642,6 +5645,32 @@ const getViewletArgs = options => {
5642
5645
  })
5643
5646
  }, ...rest];
5644
5647
  };
5648
+ const handleOpenError = async (context, tabId, editorInput, uri, error) => {
5649
+ const latestState = context.getState();
5650
+ if (editorInput.type === 'editor' && error instanceof Error && error.name === 'BinaryFileError') {
5651
+ const editorUid = findTabById(latestState, tabId)?.tab.editorUid ?? -1;
5652
+ const binaryState = updateTab(latestState, tabId, {
5653
+ editorInput: {
5654
+ type: 'binary',
5655
+ uri
5656
+ },
5657
+ editorUid: -1,
5658
+ errorMessage: undefined,
5659
+ loadingState: 'binary'
5660
+ });
5661
+ await context.updateState(() => binaryState);
5662
+ if (editorUid !== -1) {
5663
+ await disposeEditors([editorUid]);
5664
+ }
5665
+ return;
5666
+ }
5667
+ const errorMessage = error instanceof Error ? error.message : 'Failed to open URI';
5668
+ const errorState = updateTab(latestState, tabId, {
5669
+ errorMessage,
5670
+ loadingState: 'error'
5671
+ });
5672
+ await context.updateState(() => errorState);
5673
+ };
5645
5674
  const openInputWithContext = async (context, options) => {
5646
5675
  const state = context.getState();
5647
5676
  object(state);
@@ -5749,13 +5778,7 @@ const openInputWithContext = async (context, options) => {
5749
5778
  return;
5750
5779
  }
5751
5780
  } catch (error) {
5752
- const latestState = context.getState();
5753
- const errorMessage = error instanceof Error ? error.message : 'Failed to open URI';
5754
- const errorState = updateTab(latestState, tabId, {
5755
- errorMessage,
5756
- loadingState: 'error'
5757
- });
5758
- await context.updateState(() => errorState);
5781
+ await handleOpenError(context, tabId, editorInput, uri, error);
5759
5782
  }
5760
5783
  };
5761
5784
  const openInput = async (state, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.74.0",
3
+ "version": "9.74.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",