@lvce-editor/title-bar-worker 4.15.6 → 4.15.8
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 +102 -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
|
}];
|
|
@@ -3099,7 +3150,7 @@ const getMenuEntries2 = async (state, props) => {
|
|
|
3099
3150
|
case Edit$2:
|
|
3100
3151
|
return getMenuEntries$d();
|
|
3101
3152
|
case File$3:
|
|
3102
|
-
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));
|
|
3103
3154
|
case Go$2:
|
|
3104
3155
|
return getMenuEntries$a();
|
|
3105
3156
|
case Help$3:
|
|
@@ -3109,7 +3160,7 @@ const getMenuEntries2 = async (state, props) => {
|
|
|
3109
3160
|
case Run$2:
|
|
3110
3161
|
return getMenuEntries$7();
|
|
3111
3162
|
case Selection$2:
|
|
3112
|
-
return getMenuEntries$6();
|
|
3163
|
+
return getMenuEntries$6(await hasOpenTextEditor());
|
|
3113
3164
|
case Terminal$2:
|
|
3114
3165
|
return getMenuEntries$5();
|
|
3115
3166
|
case TitleBar$3:
|
|
@@ -3860,16 +3911,24 @@ const getEndIndex = workspaceUri => {
|
|
|
3860
3911
|
}
|
|
3861
3912
|
return endIndex;
|
|
3862
3913
|
};
|
|
3863
|
-
const
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
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;
|
|
3871
3926
|
}
|
|
3872
|
-
|
|
3927
|
+
};
|
|
3928
|
+
const getWorkspaceTitle = (workspacePath, titleTemplate, appName) => {
|
|
3929
|
+
const endIndex = getEndIndex(workspacePath);
|
|
3930
|
+
const slashIndex = Math.max(workspacePath.lastIndexOf('/', endIndex - 1), workspacePath.lastIndexOf('\\', endIndex - 1));
|
|
3931
|
+
const folderName = workspacePath.slice(slashIndex + 1, endIndex);
|
|
3873
3932
|
|
|
3874
3933
|
// If titleTemplate is empty, return folderName directly
|
|
3875
3934
|
if (!titleTemplate) {
|
|
@@ -3882,6 +3941,19 @@ const getTitle = (workspaceUri, titleTemplate, appName) => {
|
|
|
3882
3941
|
}
|
|
3883
3942
|
return parseTitleTemplate(titleTemplate, folderName, appName);
|
|
3884
3943
|
};
|
|
3944
|
+
const getTitle = (workspaceUri, titleTemplate, appName) => {
|
|
3945
|
+
if (!workspaceUri) {
|
|
3946
|
+
return appName;
|
|
3947
|
+
}
|
|
3948
|
+
const remoteSshWorkspace = getRemoteSshWorkspace(workspaceUri);
|
|
3949
|
+
const workspacePath = remoteSshWorkspace?.path ?? workspaceUri;
|
|
3950
|
+
const title = getWorkspaceTitle(workspacePath, titleTemplate, appName);
|
|
3951
|
+
if (!remoteSshWorkspace) {
|
|
3952
|
+
return title || appName;
|
|
3953
|
+
}
|
|
3954
|
+
const remoteSuffix = `[SSH: ${remoteSshWorkspace.host}]`;
|
|
3955
|
+
return title ? `${title} ${remoteSuffix}` : remoteSuffix;
|
|
3956
|
+
};
|
|
3885
3957
|
|
|
3886
3958
|
const launchTextMeasurementWorker = async () => {
|
|
3887
3959
|
const rpc = await create$4({
|
|
@@ -4057,6 +4129,7 @@ const Menu = 'Menu';
|
|
|
4057
4129
|
const MenuItem = 'MenuItem';
|
|
4058
4130
|
const MenuItemCheckMark = 'MenuItemCheckMark';
|
|
4059
4131
|
const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
|
|
4132
|
+
const MenuItemDisabled = 'MenuItemDisabled';
|
|
4060
4133
|
const MenuItemFocused = 'MenuItemFocused';
|
|
4061
4134
|
const MenuItemKeyBinding = 'MenuItemKeyBinding';
|
|
4062
4135
|
const MenuItemSeparator = 'MenuItemSeparator';
|
|
@@ -4185,8 +4258,9 @@ const getMenuItemDisabledDom = menuItem => {
|
|
|
4185
4258
|
} = menuItem;
|
|
4186
4259
|
const keyDom = key ? getKeyDom(key) : [];
|
|
4187
4260
|
return [{
|
|
4261
|
+
ariaDisabled: true,
|
|
4188
4262
|
childCount: key ? 2 : 1,
|
|
4189
|
-
className: MenuItem,
|
|
4263
|
+
className: mergeClassNames(MenuItem, MenuItemDisabled),
|
|
4190
4264
|
disabled: true,
|
|
4191
4265
|
role: MenuItem$1,
|
|
4192
4266
|
tabIndex: -1,
|