@lvce-editor/title-bar-worker 4.25.4 → 4.25.6
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/titleBarWorkerMain.js +42 -11
- package/package.json +1 -1
|
@@ -721,6 +721,23 @@ const restoreMessageError = (error, _currentStack) => {
|
|
|
721
721
|
}
|
|
722
722
|
return restoredError;
|
|
723
723
|
};
|
|
724
|
+
const getFallbackMessage = error => {
|
|
725
|
+
if (error && typeof error.message === 'string' && error.message) {
|
|
726
|
+
return error.message;
|
|
727
|
+
}
|
|
728
|
+
if (error && error.data) {
|
|
729
|
+
return getFallbackMessage(error.data);
|
|
730
|
+
}
|
|
731
|
+
const stringified = String(error);
|
|
732
|
+
if (stringified !== '[object Object]') {
|
|
733
|
+
return stringified;
|
|
734
|
+
}
|
|
735
|
+
try {
|
|
736
|
+
return JSON.stringify(error);
|
|
737
|
+
} catch {
|
|
738
|
+
return stringified;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
724
741
|
const restoreJsonRpcError = error => {
|
|
725
742
|
const currentStack = getCurrentStack();
|
|
726
743
|
if (error && error instanceof Error) {
|
|
@@ -729,13 +746,13 @@ const restoreJsonRpcError = error => {
|
|
|
729
746
|
if (error && error.code && error.code === MethodNotFound) {
|
|
730
747
|
return restoreMethodNotFoundError(error, currentStack);
|
|
731
748
|
}
|
|
749
|
+
if (error && error.error) {
|
|
750
|
+
return restoreJsonRpcError(error.error);
|
|
751
|
+
}
|
|
732
752
|
if (error && error.message) {
|
|
733
753
|
return restoreMessageError(error);
|
|
734
754
|
}
|
|
735
|
-
|
|
736
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
737
|
-
}
|
|
738
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
755
|
+
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
739
756
|
};
|
|
740
757
|
const unwrapJsonRpcResult = responseMessage => {
|
|
741
758
|
if ('error' in responseMessage) {
|
|
@@ -2663,7 +2680,7 @@ const getSaveFlags = hasActiveTextEditor => {
|
|
|
2663
2680
|
}
|
|
2664
2681
|
return Disabled;
|
|
2665
2682
|
};
|
|
2666
|
-
const getMenuEntries$b = async (platform, autoSave$1, hasActiveTextEditor = false) => {
|
|
2683
|
+
const getMenuEntries$b = async (platform, autoSave$1, hasActiveTextEditor = false, hasOpenWorkspace = false) => {
|
|
2667
2684
|
const autoSaveValue = autoSave$1 ?? (await getAutoSave());
|
|
2668
2685
|
const saveFlags = getSaveFlags(hasActiveTextEditor);
|
|
2669
2686
|
const entries = [{
|
|
@@ -2708,7 +2725,7 @@ const getMenuEntries$b = async (platform, autoSave$1, hasActiveTextEditor = fals
|
|
|
2708
2725
|
label: autoSave()
|
|
2709
2726
|
}, menuEntrySeparator, {
|
|
2710
2727
|
command: 'Workspace.close',
|
|
2711
|
-
flags: RestoreFocus,
|
|
2728
|
+
flags: hasOpenWorkspace ? RestoreFocus : Disabled,
|
|
2712
2729
|
id: 'closeFolder',
|
|
2713
2730
|
label: closeFolder()
|
|
2714
2731
|
}];
|
|
@@ -3215,7 +3232,7 @@ const getMenuEntries2 = async (state, props) => {
|
|
|
3215
3232
|
case Edit$2:
|
|
3216
3233
|
return getMenuEntries$d();
|
|
3217
3234
|
case File$3:
|
|
3218
|
-
return getMenuEntries$b(props.platform, undefined, await hasOpenTextEditor());
|
|
3235
|
+
return getMenuEntries$b(props.platform, undefined, await hasOpenTextEditor(), Boolean(state.workspaceUri));
|
|
3219
3236
|
case Go$2:
|
|
3220
3237
|
return getMenuEntries$a();
|
|
3221
3238
|
case Help$3:
|
|
@@ -5354,19 +5371,33 @@ const selectIndexNone = async (state, item) => {
|
|
|
5354
5371
|
const {
|
|
5355
5372
|
uid
|
|
5356
5373
|
} = state;
|
|
5357
|
-
await executeMenuItemCommand(item);
|
|
5358
5374
|
const storedState = get(uid);
|
|
5359
5375
|
const latestState = storedState?.newState ?? state;
|
|
5360
|
-
const
|
|
5376
|
+
const closedState = {
|
|
5361
5377
|
...latestState,
|
|
5362
5378
|
focusedIndex: -1,
|
|
5363
5379
|
isMenuOpen: false,
|
|
5364
5380
|
menus: []
|
|
5365
5381
|
};
|
|
5366
5382
|
if (storedState) {
|
|
5367
|
-
set$1(uid, storedState.oldState,
|
|
5383
|
+
set$1(uid, storedState.oldState, closedState, closedState);
|
|
5384
|
+
if (latestState.menus.length > 0) {
|
|
5385
|
+
const [command, ...args] = renderMenus(latestState, closedState);
|
|
5386
|
+
await invoke$2(command, ...args);
|
|
5387
|
+
}
|
|
5368
5388
|
}
|
|
5369
|
-
|
|
5389
|
+
await executeMenuItemCommand(item);
|
|
5390
|
+
const latestCommandState = get(uid)?.newState ?? closedState;
|
|
5391
|
+
const finalState = {
|
|
5392
|
+
...latestCommandState,
|
|
5393
|
+
focusedIndex: -1,
|
|
5394
|
+
isMenuOpen: false,
|
|
5395
|
+
menus: []
|
|
5396
|
+
};
|
|
5397
|
+
if (storedState) {
|
|
5398
|
+
set$1(uid, finalState, finalState, finalState);
|
|
5399
|
+
}
|
|
5400
|
+
return finalState;
|
|
5370
5401
|
};
|
|
5371
5402
|
|
|
5372
5403
|
const selectIndexRestoreEditorFocus = async (state, item) => {
|