@lvce-editor/title-bar-worker 4.15.5 → 4.15.7
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 +106 -28
- package/package.json +1 -1
|
@@ -2233,7 +2233,7 @@ const getMenuIds = () => {
|
|
|
2233
2233
|
return [Edit$2, File$3, Go$2, Help$3, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar$3, View$2, MenuIdAppearance, MenuIdEditorLayout, MenuIdSwitchEditor, MenuIdSwitchGroup, MenuIdTitleBarContextMenu, TitleBarContextMenu];
|
|
2234
2234
|
};
|
|
2235
2235
|
|
|
2236
|
-
const hasActiveTextEditor = async mainAreaUid => {
|
|
2236
|
+
const hasActiveTextEditor$1 = async mainAreaUid => {
|
|
2237
2237
|
try {
|
|
2238
2238
|
return await invoke('Main.hasActiveTextEditor', mainAreaUid);
|
|
2239
2239
|
} catch {
|
|
@@ -2241,6 +2241,50 @@ const hasActiveTextEditor = async mainAreaUid => {
|
|
|
2241
2241
|
}
|
|
2242
2242
|
};
|
|
2243
2243
|
|
|
2244
|
+
const nonTextEditorExtensions = new Set(['.avif', '.avi', '.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.m4v', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.ogv', '.png', '.svg', '.tif', '.tiff', '.webm', '.webp']);
|
|
2245
|
+
const nonTextEditorPrefixes = ['diff://?', 'extension-detail://', 'process-explorer://', 'running-extensions://'];
|
|
2246
|
+
const getPathEndIndex = uri => {
|
|
2247
|
+
const queryIndex = uri.indexOf('?');
|
|
2248
|
+
const hashIndex = uri.indexOf('#');
|
|
2249
|
+
if (queryIndex === -1) {
|
|
2250
|
+
return hashIndex === -1 ? uri.length : hashIndex;
|
|
2251
|
+
}
|
|
2252
|
+
if (hashIndex === -1) {
|
|
2253
|
+
return queryIndex;
|
|
2254
|
+
}
|
|
2255
|
+
return Math.min(queryIndex, hashIndex);
|
|
2256
|
+
};
|
|
2257
|
+
const isTextEditorUri = uri => {
|
|
2258
|
+
if (typeof uri !== 'string' || uri.length === 0 || nonTextEditorPrefixes.some(prefix => uri.startsWith(prefix))) {
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
const pathEndIndex = getPathEndIndex(uri);
|
|
2262
|
+
const path = uri.slice(0, pathEndIndex);
|
|
2263
|
+
const lastDotIndex = path.lastIndexOf('.');
|
|
2264
|
+
const lastSlashIndex = path.lastIndexOf('/');
|
|
2265
|
+
const extension = lastDotIndex > lastSlashIndex ? path.slice(lastDotIndex).toLowerCase() : '';
|
|
2266
|
+
return !nonTextEditorExtensions.has(extension);
|
|
2267
|
+
};
|
|
2268
|
+
const hasActiveTextEditor = async () => {
|
|
2269
|
+
try {
|
|
2270
|
+
const activeEditorId = await invoke('GetActiveEditor.getActiveEditorId');
|
|
2271
|
+
return typeof activeEditorId === 'number' && activeEditorId >= 0;
|
|
2272
|
+
} catch {
|
|
2273
|
+
return false;
|
|
2274
|
+
}
|
|
2275
|
+
};
|
|
2276
|
+
const hasOpenTextEditor = async () => {
|
|
2277
|
+
try {
|
|
2278
|
+
const openEditorUris = await invoke('GetActiveEditor.getOpenEditorUris');
|
|
2279
|
+
if (Array.isArray(openEditorUris)) {
|
|
2280
|
+
return openEditorUris.some(isTextEditorUri);
|
|
2281
|
+
}
|
|
2282
|
+
} catch {
|
|
2283
|
+
// Older renderer workers do not expose the open editor URI list.
|
|
2284
|
+
}
|
|
2285
|
+
return hasActiveTextEditor();
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2244
2288
|
const menuEntrySeparator = {
|
|
2245
2289
|
command: '',
|
|
2246
2290
|
flags: Separator$1,
|
|
@@ -2832,75 +2876,82 @@ const getMenuEntries$7 = () => {
|
|
|
2832
2876
|
return [];
|
|
2833
2877
|
};
|
|
2834
2878
|
|
|
2835
|
-
const
|
|
2879
|
+
const getCommandFlags = hasActiveTextEditor => {
|
|
2880
|
+
if (hasActiveTextEditor) {
|
|
2881
|
+
return RestoreEditorFocus;
|
|
2882
|
+
}
|
|
2883
|
+
return Disabled;
|
|
2884
|
+
};
|
|
2885
|
+
const getMenuEntries$6 = (hasActiveTextEditor = false) => {
|
|
2886
|
+
const commandFlags = getCommandFlags(hasActiveTextEditor);
|
|
2836
2887
|
return [{
|
|
2837
2888
|
command: 'Editor.selectAll',
|
|
2838
|
-
flags:
|
|
2889
|
+
flags: commandFlags,
|
|
2839
2890
|
id: 'selectAll',
|
|
2840
2891
|
label: selectAll()
|
|
2841
2892
|
}, {
|
|
2842
2893
|
command: 'Editor.expandSelection',
|
|
2843
|
-
flags:
|
|
2894
|
+
flags: commandFlags,
|
|
2844
2895
|
id: 'expandSelection',
|
|
2845
2896
|
label: expandSelection()
|
|
2846
2897
|
}, {
|
|
2847
2898
|
command: 'Editor.shrinkSelection',
|
|
2848
|
-
flags:
|
|
2899
|
+
flags: commandFlags,
|
|
2849
2900
|
id: 'shrinkSelection',
|
|
2850
2901
|
label: shrinkSelection()
|
|
2851
2902
|
}, menuEntrySeparator, {
|
|
2852
2903
|
command: 'Editor.copyLineUp',
|
|
2853
|
-
flags:
|
|
2904
|
+
flags: commandFlags,
|
|
2854
2905
|
id: 'copyLineUp',
|
|
2855
2906
|
label: copyLineUp()
|
|
2856
2907
|
}, {
|
|
2857
2908
|
command: 'Editor.copyLineDown',
|
|
2858
|
-
flags:
|
|
2909
|
+
flags: commandFlags,
|
|
2859
2910
|
id: 'copyLineDown',
|
|
2860
2911
|
label: copyLineDown()
|
|
2861
2912
|
}, {
|
|
2862
2913
|
command: 'Editor.moveLineUp',
|
|
2863
|
-
flags:
|
|
2914
|
+
flags: commandFlags,
|
|
2864
2915
|
id: 'moveLineUp',
|
|
2865
2916
|
label: moveLineUp()
|
|
2866
2917
|
}, {
|
|
2867
2918
|
command: 'Editor.moveLineDown',
|
|
2868
|
-
flags:
|
|
2919
|
+
flags: commandFlags,
|
|
2869
2920
|
id: 'moveLineDown',
|
|
2870
2921
|
label: moveLineDown()
|
|
2871
2922
|
}, {
|
|
2872
2923
|
command: 'Editor.duplicateSelection',
|
|
2873
|
-
flags:
|
|
2924
|
+
flags: commandFlags,
|
|
2874
2925
|
id: 'duplicateSelection',
|
|
2875
2926
|
label: duplicateSelection()
|
|
2876
2927
|
}, menuEntrySeparator, {
|
|
2877
2928
|
command: 'Editor.addCursorAbove',
|
|
2878
|
-
flags:
|
|
2929
|
+
flags: commandFlags,
|
|
2879
2930
|
id: 'addCursorAbove',
|
|
2880
2931
|
label: addCursorAbove()
|
|
2881
2932
|
}, {
|
|
2882
2933
|
command: 'Editor.addCursorBelow',
|
|
2883
|
-
flags:
|
|
2934
|
+
flags: commandFlags,
|
|
2884
2935
|
id: 'addCursorBelow',
|
|
2885
2936
|
label: addCursorBelow()
|
|
2886
2937
|
}, {
|
|
2887
2938
|
command: 'Editor.addCursorsToLineEnds',
|
|
2888
|
-
flags:
|
|
2939
|
+
flags: commandFlags,
|
|
2889
2940
|
id: 'addCursorsToLineEnds',
|
|
2890
2941
|
label: addCursorsToLineEnds()
|
|
2891
2942
|
}, {
|
|
2892
2943
|
command: 'Editor.addNextOccurrence',
|
|
2893
|
-
flags:
|
|
2944
|
+
flags: commandFlags,
|
|
2894
2945
|
id: 'addNextOccurrence',
|
|
2895
2946
|
label: addNextOccurrence()
|
|
2896
2947
|
}, {
|
|
2897
2948
|
command: 'Editor.addPreviousOccurrence',
|
|
2898
|
-
flags:
|
|
2949
|
+
flags: commandFlags,
|
|
2899
2950
|
id: 'addPreviousOccurrence',
|
|
2900
2951
|
label: addPreviousOccurrence()
|
|
2901
2952
|
}, {
|
|
2902
2953
|
command: 'Editor.selectAllOccurrences',
|
|
2903
|
-
flags:
|
|
2954
|
+
flags: commandFlags,
|
|
2904
2955
|
id: 'selectAllOccurrences',
|
|
2905
2956
|
label: selectAllOccurrences()
|
|
2906
2957
|
}];
|
|
@@ -3044,24 +3095,25 @@ const getMenuEntries$1 = () => {
|
|
|
3044
3095
|
id: 'search',
|
|
3045
3096
|
label: i18nString(Search)
|
|
3046
3097
|
}, {
|
|
3047
|
-
args: ['Source Control'],
|
|
3098
|
+
args: ['Source Control', true],
|
|
3048
3099
|
command: 'Layout.openSideBarViewlet',
|
|
3049
3100
|
flags: None,
|
|
3050
3101
|
id: 'sourceControl',
|
|
3051
3102
|
label: i18nString(SourceControl)
|
|
3052
3103
|
}, {
|
|
3053
|
-
args: ['Run And Debug'],
|
|
3104
|
+
args: ['Run And Debug', true],
|
|
3054
3105
|
command: 'Layout.openSideBarViewlet',
|
|
3055
3106
|
flags: None,
|
|
3056
3107
|
id: 'run',
|
|
3057
3108
|
label: i18nString(Run$1)
|
|
3058
3109
|
}, {
|
|
3059
|
-
args: ['Extensions'],
|
|
3110
|
+
args: ['Extensions', true],
|
|
3060
3111
|
command: 'Layout.openSideBarViewlet',
|
|
3061
3112
|
flags: None,
|
|
3062
3113
|
id: 'extensions',
|
|
3063
3114
|
label: i18nString(Extensions)
|
|
3064
3115
|
}, menuEntrySeparator, {
|
|
3116
|
+
args: [true],
|
|
3065
3117
|
command: 'Layout.openChat',
|
|
3066
3118
|
flags: None,
|
|
3067
3119
|
id: 'chat',
|
|
@@ -3098,7 +3150,7 @@ const getMenuEntries2 = async (state, props) => {
|
|
|
3098
3150
|
case Edit$2:
|
|
3099
3151
|
return getMenuEntries$d();
|
|
3100
3152
|
case File$3:
|
|
3101
|
-
return getMenuEntries$b(props.platform, undefined, await hasActiveTextEditor(state.mainAreaUid ?? DEFAULT_MAIN_AREA_UID));
|
|
3153
|
+
return getMenuEntries$b(props.platform, undefined, await hasActiveTextEditor$1(state.mainAreaUid ?? DEFAULT_MAIN_AREA_UID));
|
|
3102
3154
|
case Go$2:
|
|
3103
3155
|
return getMenuEntries$a();
|
|
3104
3156
|
case Help$3:
|
|
@@ -3108,7 +3160,7 @@ const getMenuEntries2 = async (state, props) => {
|
|
|
3108
3160
|
case Run$2:
|
|
3109
3161
|
return getMenuEntries$7();
|
|
3110
3162
|
case Selection$2:
|
|
3111
|
-
return getMenuEntries$6();
|
|
3163
|
+
return getMenuEntries$6(await hasOpenTextEditor());
|
|
3112
3164
|
case Terminal$2:
|
|
3113
3165
|
return getMenuEntries$5();
|
|
3114
3166
|
case TitleBar$3:
|
|
@@ -3859,16 +3911,27 @@ const getEndIndex = workspaceUri => {
|
|
|
3859
3911
|
}
|
|
3860
3912
|
return endIndex;
|
|
3861
3913
|
};
|
|
3862
|
-
const
|
|
3863
|
-
|
|
3864
|
-
|
|
3914
|
+
const getRemoteSshWorkspace = workspaceUri => {
|
|
3915
|
+
try {
|
|
3916
|
+
const url = new URL(workspaceUri);
|
|
3917
|
+
if (url.protocol !== 'remote-ssh:' || !url.hostname) {
|
|
3918
|
+
return undefined;
|
|
3919
|
+
}
|
|
3920
|
+
return {
|
|
3921
|
+
host: url.hostname,
|
|
3922
|
+
path: url.pathname
|
|
3923
|
+
};
|
|
3924
|
+
} catch {
|
|
3925
|
+
return undefined;
|
|
3865
3926
|
}
|
|
3866
|
-
|
|
3867
|
-
|
|
3927
|
+
};
|
|
3928
|
+
const getWorkspaceTitle = (workspacePath, titleTemplate, appName) => {
|
|
3929
|
+
const endIndex = getEndIndex(workspacePath);
|
|
3930
|
+
const slashIndex = workspacePath.lastIndexOf('/', endIndex - 1);
|
|
3868
3931
|
if (slashIndex === -1) {
|
|
3869
3932
|
return '';
|
|
3870
3933
|
}
|
|
3871
|
-
const folderName =
|
|
3934
|
+
const folderName = workspacePath.slice(slashIndex + 1, endIndex);
|
|
3872
3935
|
|
|
3873
3936
|
// If titleTemplate is empty, return folderName directly
|
|
3874
3937
|
if (!titleTemplate) {
|
|
@@ -3881,6 +3944,19 @@ const getTitle = (workspaceUri, titleTemplate, appName) => {
|
|
|
3881
3944
|
}
|
|
3882
3945
|
return parseTitleTemplate(titleTemplate, folderName, appName);
|
|
3883
3946
|
};
|
|
3947
|
+
const getTitle = (workspaceUri, titleTemplate, appName) => {
|
|
3948
|
+
if (!workspaceUri) {
|
|
3949
|
+
return '';
|
|
3950
|
+
}
|
|
3951
|
+
const remoteSshWorkspace = getRemoteSshWorkspace(workspaceUri);
|
|
3952
|
+
const workspacePath = remoteSshWorkspace?.path ?? workspaceUri;
|
|
3953
|
+
const title = getWorkspaceTitle(workspacePath, titleTemplate, appName);
|
|
3954
|
+
if (!remoteSshWorkspace) {
|
|
3955
|
+
return title;
|
|
3956
|
+
}
|
|
3957
|
+
const remoteSuffix = `[SSH: ${remoteSshWorkspace.host}]`;
|
|
3958
|
+
return title ? `${title} ${remoteSuffix}` : remoteSuffix;
|
|
3959
|
+
};
|
|
3884
3960
|
|
|
3885
3961
|
const launchTextMeasurementWorker = async () => {
|
|
3886
3962
|
const rpc = await create$4({
|
|
@@ -4056,6 +4132,7 @@ const Menu = 'Menu';
|
|
|
4056
4132
|
const MenuItem = 'MenuItem';
|
|
4057
4133
|
const MenuItemCheckMark = 'MenuItemCheckMark';
|
|
4058
4134
|
const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
|
|
4135
|
+
const MenuItemDisabled = 'MenuItemDisabled';
|
|
4059
4136
|
const MenuItemFocused = 'MenuItemFocused';
|
|
4060
4137
|
const MenuItemKeyBinding = 'MenuItemKeyBinding';
|
|
4061
4138
|
const MenuItemSeparator = 'MenuItemSeparator';
|
|
@@ -4184,8 +4261,9 @@ const getMenuItemDisabledDom = menuItem => {
|
|
|
4184
4261
|
} = menuItem;
|
|
4185
4262
|
const keyDom = key ? getKeyDom(key) : [];
|
|
4186
4263
|
return [{
|
|
4264
|
+
ariaDisabled: true,
|
|
4187
4265
|
childCount: key ? 2 : 1,
|
|
4188
|
-
className: MenuItem,
|
|
4266
|
+
className: mergeClassNames(MenuItem, MenuItemDisabled),
|
|
4189
4267
|
disabled: true,
|
|
4190
4268
|
role: MenuItem$1,
|
|
4191
4269
|
tabIndex: -1,
|