@lvce-editor/main-area-worker 9.73.2 → 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.
- package/dist/mainAreaWorkerMain.js +51 -12
- package/package.json +1 -1
|
@@ -628,9 +628,12 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
628
628
|
writable: true
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
restoredError
|
|
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,
|
|
@@ -2064,6 +2067,9 @@ const getLoadFileErrorMessage = error => {
|
|
|
2064
2067
|
}
|
|
2065
2068
|
return error.message;
|
|
2066
2069
|
};
|
|
2070
|
+
const isBinaryFileError = error => {
|
|
2071
|
+
return error instanceof Error && error.name === 'BinaryFileError';
|
|
2072
|
+
};
|
|
2067
2073
|
const loadTabContentAsync = async (tabId, path, requestId, getLatestState) => {
|
|
2068
2074
|
try {
|
|
2069
2075
|
await loadFileContent(path);
|
|
@@ -2101,6 +2107,16 @@ const loadTabContentAsync = async (tabId, path, requestId, getLatestState) => {
|
|
|
2101
2107
|
if (latestTab.loadingState !== 'loading') {
|
|
2102
2108
|
return latestState;
|
|
2103
2109
|
}
|
|
2110
|
+
if (isBinaryFileError(error)) {
|
|
2111
|
+
return updateTab(latestState, tabId, {
|
|
2112
|
+
editorInput: {
|
|
2113
|
+
type: 'binary',
|
|
2114
|
+
uri: path
|
|
2115
|
+
},
|
|
2116
|
+
errorMessage: undefined,
|
|
2117
|
+
loadingState: 'binary'
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2104
2120
|
const errorMessage = getLoadFileErrorMessage(error);
|
|
2105
2121
|
return updateTab(latestState, tabId, {
|
|
2106
2122
|
errorMessage,
|
|
@@ -4101,7 +4117,7 @@ const NewTextFile = 'New Text File';
|
|
|
4101
4117
|
const NewWindow = 'New Window';
|
|
4102
4118
|
const OpenFile = 'Open File';
|
|
4103
4119
|
const OpenAnyway = 'Open Anyway';
|
|
4104
|
-
const OpenInTextEditor = '
|
|
4120
|
+
const OpenInTextEditor = 'Reopen with Text Editor';
|
|
4105
4121
|
const BinaryFileNotDisplayed = 'The file is not displayed in the text editor because its contents are binary.';
|
|
4106
4122
|
const LargeFileNotDisplayed = 'The file is not displayed in the text editor because it is very large';
|
|
4107
4123
|
const SplitDown = 'Split Down';
|
|
@@ -5621,11 +5637,40 @@ const getViewletArgs = options => {
|
|
|
5621
5637
|
return [{
|
|
5622
5638
|
...context,
|
|
5623
5639
|
focus: options.focus,
|
|
5640
|
+
...(options.editorInput.type === 'editor' && options.editorInput.forceText === true && {
|
|
5641
|
+
forceText: true
|
|
5642
|
+
}),
|
|
5624
5643
|
...(options.forceOpen === true && {
|
|
5625
5644
|
largeFile: true
|
|
5626
5645
|
})
|
|
5627
5646
|
}, ...rest];
|
|
5628
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
|
+
};
|
|
5629
5674
|
const openInputWithContext = async (context, options) => {
|
|
5630
5675
|
const state = context.getState();
|
|
5631
5676
|
object(state);
|
|
@@ -5733,13 +5778,7 @@ const openInputWithContext = async (context, options) => {
|
|
|
5733
5778
|
return;
|
|
5734
5779
|
}
|
|
5735
5780
|
} catch (error) {
|
|
5736
|
-
|
|
5737
|
-
const errorMessage = error instanceof Error ? error.message : 'Failed to open URI';
|
|
5738
|
-
const errorState = updateTab(latestState, tabId, {
|
|
5739
|
-
errorMessage,
|
|
5740
|
-
loadingState: 'error'
|
|
5741
|
-
});
|
|
5742
|
-
await context.updateState(() => errorState);
|
|
5781
|
+
await handleOpenError(context, tabId, editorInput, uri, error);
|
|
5743
5782
|
}
|
|
5744
5783
|
};
|
|
5745
5784
|
const openInput = async (state, options) => {
|