@lvce-editor/title-bar-worker 2.9.0 → 2.10.0
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 +346 -195
- package/package.json +1 -1
|
@@ -995,47 +995,224 @@ const terminate = () => {
|
|
|
995
995
|
globalThis.close();
|
|
996
996
|
};
|
|
997
997
|
|
|
998
|
+
const Web = 1;
|
|
999
|
+
const Electron = 2;
|
|
1000
|
+
const Remote = 3;
|
|
1001
|
+
|
|
1002
|
+
const DEFAULT_UID = 1;
|
|
1003
|
+
const createDefaultState = (uid = DEFAULT_UID) => ({
|
|
1004
|
+
assetDir: '',
|
|
1005
|
+
buttons: [],
|
|
1006
|
+
controlsOverlayEnabled: false,
|
|
1007
|
+
focusedIndex: -1,
|
|
1008
|
+
height: 30,
|
|
1009
|
+
iconWidth: 30,
|
|
1010
|
+
isMenuOpen: false,
|
|
1011
|
+
labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
|
|
1012
|
+
labelFontSize: 13,
|
|
1013
|
+
labelFontWeight: 400,
|
|
1014
|
+
labelLetterSpacing: 0,
|
|
1015
|
+
labelPadding: 8,
|
|
1016
|
+
menus: [],
|
|
1017
|
+
platform: Electron,
|
|
1018
|
+
title: '',
|
|
1019
|
+
titleBarButtons: [],
|
|
1020
|
+
titleBarButtonsEnabled: true,
|
|
1021
|
+
titleBarButtonsWidth: 90,
|
|
1022
|
+
titleBarEntries: [],
|
|
1023
|
+
titleBarHeight: 30,
|
|
1024
|
+
titleBarIconEnabled: true,
|
|
1025
|
+
titleBarIconWidth: 30,
|
|
1026
|
+
titleBarMenuBarEnabled: true,
|
|
1027
|
+
titleBarStyleCustom: true,
|
|
1028
|
+
titleBarTitleEnabled: true,
|
|
1029
|
+
uid,
|
|
1030
|
+
width: 800,
|
|
1031
|
+
x: 0,
|
|
1032
|
+
y: 0
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
const emptyObject = {};
|
|
1036
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1037
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1038
|
+
if (placeholders === emptyObject) {
|
|
1039
|
+
return key;
|
|
1040
|
+
}
|
|
1041
|
+
const replacer = (match, rest) => {
|
|
1042
|
+
return placeholders[rest];
|
|
1043
|
+
};
|
|
1044
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
const About = 'About';
|
|
1048
|
+
const CheckForUpdates = 'Check For Updates';
|
|
1049
|
+
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1050
|
+
const Close = 'Close';
|
|
1051
|
+
const Edit$1 = 'Edit';
|
|
1052
|
+
const File$2 = 'File';
|
|
1053
|
+
const Go$1 = 'Go';
|
|
1054
|
+
const Help$1 = 'Help';
|
|
1055
|
+
const Maximize = 'Maximize';
|
|
1056
|
+
const Minimize = 'Minimize';
|
|
1057
|
+
const MoreDot = 'More ...';
|
|
1058
|
+
const NewTerminal = 'New Terminal';
|
|
1059
|
+
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1060
|
+
const Run$1 = 'Run';
|
|
1061
|
+
const Selection$1 = 'Selection';
|
|
1062
|
+
const Terminal$1 = 'Terminal';
|
|
1063
|
+
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1064
|
+
const View$1 = 'View';
|
|
1065
|
+
|
|
1066
|
+
const file = () => {
|
|
1067
|
+
return i18nString(File$2);
|
|
1068
|
+
};
|
|
1069
|
+
const edit = () => {
|
|
1070
|
+
return i18nString(Edit$1);
|
|
1071
|
+
};
|
|
1072
|
+
const selection = () => {
|
|
1073
|
+
return i18nString(Selection$1);
|
|
1074
|
+
};
|
|
1075
|
+
const view = () => {
|
|
1076
|
+
return i18nString(View$1);
|
|
1077
|
+
};
|
|
1078
|
+
const go = () => {
|
|
1079
|
+
return i18nString(Go$1);
|
|
1080
|
+
};
|
|
1081
|
+
const run = () => {
|
|
1082
|
+
return i18nString(Run$1);
|
|
1083
|
+
};
|
|
1084
|
+
const terminal = () => {
|
|
1085
|
+
return i18nString(Terminal$1);
|
|
1086
|
+
};
|
|
1087
|
+
const help = () => {
|
|
1088
|
+
return i18nString(Help$1);
|
|
1089
|
+
};
|
|
1090
|
+
const minimize$1 = () => {
|
|
1091
|
+
return i18nString(Minimize);
|
|
1092
|
+
};
|
|
1093
|
+
const maximize$1 = () => {
|
|
1094
|
+
return i18nString(Maximize);
|
|
1095
|
+
};
|
|
1096
|
+
const close$1 = () => {
|
|
1097
|
+
return i18nString(Close);
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
1101
|
+
if (controlsOverlayEnabled) {
|
|
1102
|
+
return [];
|
|
1103
|
+
}
|
|
1104
|
+
if (titleBarStyleCustom) {
|
|
1105
|
+
// TODO don't render title bar buttons on windows when electron window controls overlay is enabled
|
|
1106
|
+
return [{
|
|
1107
|
+
label: minimize$1(),
|
|
1108
|
+
icon: 'Minimize',
|
|
1109
|
+
id: 'Minimize',
|
|
1110
|
+
onClick: 'handleClickMinimize'
|
|
1111
|
+
}, {
|
|
1112
|
+
label: maximize$1(),
|
|
1113
|
+
icon: 'Maximize',
|
|
1114
|
+
id: 'ToggleMaximize',
|
|
1115
|
+
onClick: 'handleClickToggleMaximize'
|
|
1116
|
+
}, {
|
|
1117
|
+
label: close$1(),
|
|
1118
|
+
icon: 'ChromeClose',
|
|
1119
|
+
id: 'Close',
|
|
1120
|
+
onClick: 'handleClickClose'
|
|
1121
|
+
}];
|
|
1122
|
+
}
|
|
1123
|
+
return [];
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
const getTitleBarButtonsRemote = () => {
|
|
1127
|
+
return [];
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
const getTitleBarButtonsWeb = () => {
|
|
1131
|
+
return [];
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
1135
|
+
switch (platform) {
|
|
1136
|
+
case Electron:
|
|
1137
|
+
return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
|
|
1138
|
+
case Web:
|
|
1139
|
+
return getTitleBarButtonsWeb();
|
|
1140
|
+
case Remote:
|
|
1141
|
+
return getTitleBarButtonsRemote();
|
|
1142
|
+
default:
|
|
1143
|
+
return [];
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
const {
|
|
1148
|
+
get: get$1,
|
|
1149
|
+
set: set$3,
|
|
1150
|
+
getCommandIds,
|
|
1151
|
+
registerCommands,
|
|
1152
|
+
wrapCommand
|
|
1153
|
+
} = create$2();
|
|
1154
|
+
|
|
1155
|
+
const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
1156
|
+
const titleBarButtons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
|
|
1157
|
+
const state = {
|
|
1158
|
+
...createDefaultState(),
|
|
1159
|
+
uid: id,
|
|
1160
|
+
titleBarEntries: [],
|
|
1161
|
+
focusedIndex: -1,
|
|
1162
|
+
isMenuOpen: false,
|
|
1163
|
+
menus: [],
|
|
1164
|
+
labelFontWeight: 400,
|
|
1165
|
+
labelFontSize: 13,
|
|
1166
|
+
labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
|
|
1167
|
+
labelPadding: 8,
|
|
1168
|
+
labelLetterSpacing: 0,
|
|
1169
|
+
titleBarHeight: height,
|
|
1170
|
+
x,
|
|
1171
|
+
y,
|
|
1172
|
+
width,
|
|
1173
|
+
height,
|
|
1174
|
+
iconWidth: 30,
|
|
1175
|
+
platform,
|
|
1176
|
+
controlsOverlayEnabled,
|
|
1177
|
+
titleBarStyleCustom,
|
|
1178
|
+
titleBarButtons
|
|
1179
|
+
};
|
|
1180
|
+
set$3(id, state, state);
|
|
1181
|
+
return state;
|
|
1182
|
+
};
|
|
1183
|
+
|
|
998
1184
|
const RenderEntries = 1;
|
|
999
1185
|
const RenderFocusedIndex = 2;
|
|
1000
1186
|
const RenderMenus = 3;
|
|
1001
1187
|
|
|
1002
|
-
const
|
|
1003
|
-
const isEqual$2 = (oldState, newState) => {
|
|
1188
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1004
1189
|
return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
1005
1190
|
};
|
|
1006
1191
|
|
|
1007
|
-
const diffType$
|
|
1008
|
-
const isEqual$
|
|
1192
|
+
const diffType$2 = RenderFocusedIndex;
|
|
1193
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1009
1194
|
return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
|
|
1010
1195
|
};
|
|
1011
1196
|
|
|
1012
|
-
const diffType = RenderMenus;
|
|
1013
|
-
const isEqual = (oldState, newState) => {
|
|
1197
|
+
const diffType$1 = RenderMenus;
|
|
1198
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1014
1199
|
return oldState.menus === newState.menus;
|
|
1015
1200
|
};
|
|
1016
1201
|
|
|
1017
|
-
const modules = [isEqual$
|
|
1018
|
-
const numbers = [
|
|
1202
|
+
const modules$1 = [isEqual$3, isEqual$2, isEqual$1];
|
|
1203
|
+
const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus];
|
|
1019
1204
|
|
|
1020
1205
|
const diff = (oldState, newState) => {
|
|
1021
1206
|
const diffResult = [];
|
|
1022
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1023
|
-
const fn = modules[i];
|
|
1207
|
+
for (let i = 0; i < modules$1.length; i++) {
|
|
1208
|
+
const fn = modules$1[i];
|
|
1024
1209
|
if (!fn(oldState, newState)) {
|
|
1025
|
-
diffResult.push(numbers[i]);
|
|
1210
|
+
diffResult.push(numbers$1[i]);
|
|
1026
1211
|
}
|
|
1027
1212
|
}
|
|
1028
1213
|
return diffResult;
|
|
1029
1214
|
};
|
|
1030
1215
|
|
|
1031
|
-
const {
|
|
1032
|
-
get: get$1,
|
|
1033
|
-
set: set$3,
|
|
1034
|
-
getCommandIds,
|
|
1035
|
-
registerCommands,
|
|
1036
|
-
wrapCommand
|
|
1037
|
-
} = create$2();
|
|
1038
|
-
|
|
1039
1216
|
const diff2 = uid => {
|
|
1040
1217
|
const {
|
|
1041
1218
|
oldState,
|
|
@@ -1044,6 +1221,29 @@ const diff2 = uid => {
|
|
|
1044
1221
|
return diff(oldState, newState);
|
|
1045
1222
|
};
|
|
1046
1223
|
|
|
1224
|
+
const diffType = RenderEntries;
|
|
1225
|
+
const isEqual = (oldState, newState) => {
|
|
1226
|
+
return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.assetDir === newState.assetDir && oldState.titleBarIconEnabled === newState.titleBarIconEnabled && oldState.title === newState.title && oldState.titleBarTitleEnabled === newState.titleBarTitleEnabled && oldState.platform === newState.platform && oldState.controlsOverlayEnabled === newState.controlsOverlayEnabled && oldState.titleBarStyleCustom === newState.titleBarStyleCustom && oldState.titleBarButtonsEnabled === newState.titleBarButtonsEnabled && oldState.titleBarButtons === newState.titleBarButtons;
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
const modules = [isEqual, isEqual$2, isEqual$1];
|
|
1230
|
+
const numbers = [diffType, diffType$2, diffType$1];
|
|
1231
|
+
|
|
1232
|
+
const diff3 = uid => {
|
|
1233
|
+
const {
|
|
1234
|
+
oldState,
|
|
1235
|
+
newState
|
|
1236
|
+
} = get$1(uid);
|
|
1237
|
+
const diffResult = [];
|
|
1238
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1239
|
+
const fn = modules[i];
|
|
1240
|
+
if (!fn(oldState, newState)) {
|
|
1241
|
+
diffResult.push(numbers[i]);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return diffResult;
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1047
1247
|
const Menu$1 = 'menu';
|
|
1048
1248
|
const MenuBar = 'menubar';
|
|
1049
1249
|
const MenuItem$1 = 'menuitem';
|
|
@@ -1131,18 +1331,6 @@ const getKeyBindings$1 = () => {
|
|
|
1131
1331
|
}];
|
|
1132
1332
|
};
|
|
1133
1333
|
|
|
1134
|
-
const emptyObject = {};
|
|
1135
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1136
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1137
|
-
if (placeholders === emptyObject) {
|
|
1138
|
-
return key;
|
|
1139
|
-
}
|
|
1140
|
-
const replacer = (match, rest) => {
|
|
1141
|
-
return placeholders[rest];
|
|
1142
|
-
};
|
|
1143
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
1334
|
/**
|
|
1147
1335
|
* @enum {string}
|
|
1148
1336
|
*/
|
|
@@ -1196,16 +1384,16 @@ const moveLineDown = () => {
|
|
|
1196
1384
|
return i18nString(UiStrings$1.MoveLineDown);
|
|
1197
1385
|
};
|
|
1198
1386
|
|
|
1199
|
-
const Edit
|
|
1200
|
-
const File$
|
|
1201
|
-
const Go
|
|
1202
|
-
const Help
|
|
1387
|
+
const Edit = 2;
|
|
1388
|
+
const File$1 = 5;
|
|
1389
|
+
const Go = 6;
|
|
1390
|
+
const Help = 7;
|
|
1203
1391
|
const OpenRecent = 9;
|
|
1204
|
-
const Run
|
|
1205
|
-
const Selection
|
|
1206
|
-
const Terminal
|
|
1392
|
+
const Run = 10;
|
|
1393
|
+
const Selection = 11;
|
|
1394
|
+
const Terminal = 14;
|
|
1207
1395
|
const TitleBar = 15;
|
|
1208
|
-
const View
|
|
1396
|
+
const View = 16;
|
|
1209
1397
|
|
|
1210
1398
|
const Separator = 1;
|
|
1211
1399
|
const None = 0;
|
|
@@ -1223,7 +1411,7 @@ const menuEntrySeparator = {
|
|
|
1223
1411
|
command: ''
|
|
1224
1412
|
};
|
|
1225
1413
|
|
|
1226
|
-
const id$9 = Edit
|
|
1414
|
+
const id$9 = Edit;
|
|
1227
1415
|
const getMenuEntries$d = () => {
|
|
1228
1416
|
return [{
|
|
1229
1417
|
id: 'undo',
|
|
@@ -1307,11 +1495,7 @@ const exit = () => {
|
|
|
1307
1495
|
return i18nString(UiStrings.Exit);
|
|
1308
1496
|
};
|
|
1309
1497
|
|
|
1310
|
-
const
|
|
1311
|
-
const Electron = 2;
|
|
1312
|
-
const Remote = 3;
|
|
1313
|
-
|
|
1314
|
-
const id$8 = File$2;
|
|
1498
|
+
const id$8 = File$1;
|
|
1315
1499
|
const getMenuEntries$c = platform => {
|
|
1316
1500
|
const entries = [{
|
|
1317
1501
|
id: 'newFile',
|
|
@@ -1366,7 +1550,7 @@ const MenuEntriesFile = {
|
|
|
1366
1550
|
id: id$8
|
|
1367
1551
|
};
|
|
1368
1552
|
|
|
1369
|
-
const id$7 = Go
|
|
1553
|
+
const id$7 = Go;
|
|
1370
1554
|
const getMenuEntries$b = () => {
|
|
1371
1555
|
return [];
|
|
1372
1556
|
};
|
|
@@ -1377,25 +1561,6 @@ const MenuEntriesGo = {
|
|
|
1377
1561
|
id: id$7
|
|
1378
1562
|
};
|
|
1379
1563
|
|
|
1380
|
-
const About = 'About';
|
|
1381
|
-
const CheckForUpdates = 'Check For Updates';
|
|
1382
|
-
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1383
|
-
const Close = 'Close';
|
|
1384
|
-
const Edit = 'Edit';
|
|
1385
|
-
const File$1 = 'File';
|
|
1386
|
-
const Go = 'Go';
|
|
1387
|
-
const Help = 'Help';
|
|
1388
|
-
const Maximize = 'Maximize';
|
|
1389
|
-
const Minimize = 'Minimize';
|
|
1390
|
-
const MoreDot = 'More ...';
|
|
1391
|
-
const NewTerminal = 'New Terminal';
|
|
1392
|
-
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1393
|
-
const Run = 'Run';
|
|
1394
|
-
const Selection = 'Selection';
|
|
1395
|
-
const Terminal = 'Terminal';
|
|
1396
|
-
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1397
|
-
const View = 'View';
|
|
1398
|
-
|
|
1399
1564
|
const toggleDeveloperTools = () => {
|
|
1400
1565
|
return i18nString(ToggleDeveloperTools);
|
|
1401
1566
|
};
|
|
@@ -1416,7 +1581,7 @@ const isAutoUpdateSupported = platform => {
|
|
|
1416
1581
|
return false;
|
|
1417
1582
|
};
|
|
1418
1583
|
|
|
1419
|
-
const id$6 = Help
|
|
1584
|
+
const id$6 = Help;
|
|
1420
1585
|
const getMenuEntries$a = async platform => {
|
|
1421
1586
|
const autoUpdateSupported = isAutoUpdateSupported(platform);
|
|
1422
1587
|
const entries = [];
|
|
@@ -1917,7 +2082,7 @@ const MenuEntriesOpenRecent = {
|
|
|
1917
2082
|
id: id$5
|
|
1918
2083
|
};
|
|
1919
2084
|
|
|
1920
|
-
const id$4 = Run
|
|
2085
|
+
const id$4 = Run;
|
|
1921
2086
|
const getMenuEntries$8 = () => {
|
|
1922
2087
|
return [];
|
|
1923
2088
|
};
|
|
@@ -1928,7 +2093,7 @@ const MenuEntriesRun = {
|
|
|
1928
2093
|
id: id$4
|
|
1929
2094
|
};
|
|
1930
2095
|
|
|
1931
|
-
const id$3 = Selection
|
|
2096
|
+
const id$3 = Selection;
|
|
1932
2097
|
const getMenuEntries$7 = () => {
|
|
1933
2098
|
return [{
|
|
1934
2099
|
id: 'selectAll',
|
|
@@ -1964,7 +2129,7 @@ const MenuEntriesSelection = {
|
|
|
1964
2129
|
id: id$3
|
|
1965
2130
|
};
|
|
1966
2131
|
|
|
1967
|
-
const id$2 = Terminal
|
|
2132
|
+
const id$2 = Terminal;
|
|
1968
2133
|
const getMenuEntries$6 = () => {
|
|
1969
2134
|
return [{
|
|
1970
2135
|
id: 'newTerminal',
|
|
@@ -1981,73 +2146,39 @@ const MenuEntriesTerminal = {
|
|
|
1981
2146
|
id: id$2
|
|
1982
2147
|
};
|
|
1983
2148
|
|
|
1984
|
-
const file = () => {
|
|
1985
|
-
return i18nString(File$1);
|
|
1986
|
-
};
|
|
1987
|
-
const edit = () => {
|
|
1988
|
-
return i18nString(Edit);
|
|
1989
|
-
};
|
|
1990
|
-
const selection = () => {
|
|
1991
|
-
return i18nString(Selection);
|
|
1992
|
-
};
|
|
1993
|
-
const view = () => {
|
|
1994
|
-
return i18nString(View);
|
|
1995
|
-
};
|
|
1996
|
-
const go = () => {
|
|
1997
|
-
return i18nString(Go);
|
|
1998
|
-
};
|
|
1999
|
-
const run = () => {
|
|
2000
|
-
return i18nString(Run);
|
|
2001
|
-
};
|
|
2002
|
-
const terminal = () => {
|
|
2003
|
-
return i18nString(Terminal);
|
|
2004
|
-
};
|
|
2005
|
-
const help = () => {
|
|
2006
|
-
return i18nString(Help);
|
|
2007
|
-
};
|
|
2008
|
-
const minimize$1 = () => {
|
|
2009
|
-
return i18nString(Minimize);
|
|
2010
|
-
};
|
|
2011
|
-
const maximize$1 = () => {
|
|
2012
|
-
return i18nString(Maximize);
|
|
2013
|
-
};
|
|
2014
|
-
const close$1 = () => {
|
|
2015
|
-
return i18nString(Close);
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
2149
|
const getMenuEntries$5 = () => {
|
|
2019
2150
|
return [{
|
|
2020
|
-
id: File$
|
|
2151
|
+
id: File$1,
|
|
2021
2152
|
label: file(),
|
|
2022
2153
|
flags: SubMenu
|
|
2023
2154
|
}, {
|
|
2024
|
-
id: Edit
|
|
2155
|
+
id: Edit,
|
|
2025
2156
|
label: edit(),
|
|
2026
2157
|
flags: SubMenu
|
|
2027
2158
|
}, {
|
|
2028
|
-
id: Selection
|
|
2159
|
+
id: Selection,
|
|
2029
2160
|
label: selection(),
|
|
2030
2161
|
flags: SubMenu
|
|
2031
2162
|
}, {
|
|
2032
|
-
id: View
|
|
2163
|
+
id: View,
|
|
2033
2164
|
label: view(),
|
|
2034
2165
|
flags: SubMenu
|
|
2035
2166
|
}, {
|
|
2036
|
-
id: Go
|
|
2167
|
+
id: Go,
|
|
2037
2168
|
label: go(),
|
|
2038
2169
|
flags: SubMenu
|
|
2039
2170
|
}, {
|
|
2040
|
-
id: Run
|
|
2171
|
+
id: Run,
|
|
2041
2172
|
label: run(),
|
|
2042
2173
|
keyboardShortCut: 'Alt+r',
|
|
2043
2174
|
flags: SubMenu
|
|
2044
2175
|
}, {
|
|
2045
|
-
id: Terminal
|
|
2176
|
+
id: Terminal,
|
|
2046
2177
|
label: terminal(),
|
|
2047
2178
|
keyboardShortCut: 'Alt+t',
|
|
2048
2179
|
flags: SubMenu
|
|
2049
2180
|
}, {
|
|
2050
|
-
id: Help
|
|
2181
|
+
id: Help,
|
|
2051
2182
|
label: help(),
|
|
2052
2183
|
keyboardShortCut: 'Alt+h',
|
|
2053
2184
|
flags: SubMenu
|
|
@@ -2056,27 +2187,27 @@ const getMenuEntries$5 = () => {
|
|
|
2056
2187
|
|
|
2057
2188
|
const getMenuEntries$4 = () => {
|
|
2058
2189
|
return [{
|
|
2059
|
-
id: File$
|
|
2190
|
+
id: File$1,
|
|
2060
2191
|
label: file(),
|
|
2061
2192
|
flags: None
|
|
2062
2193
|
}, {
|
|
2063
|
-
id: Edit
|
|
2194
|
+
id: Edit,
|
|
2064
2195
|
label: edit(),
|
|
2065
2196
|
flags: None
|
|
2066
2197
|
}, {
|
|
2067
|
-
id: Selection
|
|
2198
|
+
id: Selection,
|
|
2068
2199
|
label: selection(),
|
|
2069
2200
|
flags: None
|
|
2070
2201
|
}, {
|
|
2071
|
-
id: View
|
|
2202
|
+
id: View,
|
|
2072
2203
|
label: view(),
|
|
2073
2204
|
flags: None
|
|
2074
2205
|
}, {
|
|
2075
|
-
id: Go
|
|
2206
|
+
id: Go,
|
|
2076
2207
|
label: go(),
|
|
2077
2208
|
flags: None
|
|
2078
2209
|
}, {
|
|
2079
|
-
id: Help
|
|
2210
|
+
id: Help,
|
|
2080
2211
|
label: help(),
|
|
2081
2212
|
flags: None
|
|
2082
2213
|
}];
|
|
@@ -2102,7 +2233,7 @@ const MenuEntriesTitleBar = {
|
|
|
2102
2233
|
id: id$1
|
|
2103
2234
|
};
|
|
2104
2235
|
|
|
2105
|
-
const id = View
|
|
2236
|
+
const id = View;
|
|
2106
2237
|
const getMenuEntries$2 = () => {
|
|
2107
2238
|
return [];
|
|
2108
2239
|
};
|
|
@@ -2126,53 +2257,6 @@ const getMenuEntries$1 = (id, platform) => {
|
|
|
2126
2257
|
return menu.getMenuEntries(platform);
|
|
2127
2258
|
};
|
|
2128
2259
|
|
|
2129
|
-
const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
2130
|
-
if (controlsOverlayEnabled) {
|
|
2131
|
-
return [];
|
|
2132
|
-
}
|
|
2133
|
-
if (titleBarStyleCustom) {
|
|
2134
|
-
// TODO don't render title bar buttons on windows when electron window controls overlay is enabled
|
|
2135
|
-
return [{
|
|
2136
|
-
label: minimize$1(),
|
|
2137
|
-
icon: 'Minimize',
|
|
2138
|
-
id: 'Minimize',
|
|
2139
|
-
onClick: 'handleClickMinimize'
|
|
2140
|
-
}, {
|
|
2141
|
-
label: maximize$1(),
|
|
2142
|
-
icon: 'Maximize',
|
|
2143
|
-
id: 'ToggleMaximize',
|
|
2144
|
-
onClick: 'handleClickToggleMaximize'
|
|
2145
|
-
}, {
|
|
2146
|
-
label: close$1(),
|
|
2147
|
-
icon: 'ChromeClose',
|
|
2148
|
-
id: 'Close',
|
|
2149
|
-
onClick: 'handleClickClose'
|
|
2150
|
-
}];
|
|
2151
|
-
}
|
|
2152
|
-
return [];
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
const getTitleBarButtonsRemote = () => {
|
|
2156
|
-
return [];
|
|
2157
|
-
};
|
|
2158
|
-
|
|
2159
|
-
const getTitleBarButtonsWeb = () => {
|
|
2160
|
-
return [];
|
|
2161
|
-
};
|
|
2162
|
-
|
|
2163
|
-
const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
2164
|
-
switch (platform) {
|
|
2165
|
-
case Electron:
|
|
2166
|
-
return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
|
|
2167
|
-
case Web:
|
|
2168
|
-
return getTitleBarButtonsWeb();
|
|
2169
|
-
case Remote:
|
|
2170
|
-
return getTitleBarButtonsRemote();
|
|
2171
|
-
default:
|
|
2172
|
-
return [];
|
|
2173
|
-
}
|
|
2174
|
-
};
|
|
2175
|
-
|
|
2176
2260
|
const MaskIconCheck = 'MaskIconCheck';
|
|
2177
2261
|
const Menu = 'Menu';
|
|
2178
2262
|
const MenuItem = 'MenuItem';
|
|
@@ -2634,8 +2718,11 @@ const measureTextWidths = (texts, fontWeight, fontSize, fontFamily, letterSpacin
|
|
|
2634
2718
|
return widths;
|
|
2635
2719
|
};
|
|
2636
2720
|
|
|
2721
|
+
const getLabel = entry => {
|
|
2722
|
+
return entry.label;
|
|
2723
|
+
};
|
|
2637
2724
|
const addWidths = (entries, labelPadding, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2638
|
-
const labels = entries.map(
|
|
2725
|
+
const labels = entries.map(getLabel);
|
|
2639
2726
|
const widths = measureTextWidths(labels, fontWeight, fontSize, fontFamily, letterSpacing);
|
|
2640
2727
|
const withWidths = [];
|
|
2641
2728
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -2652,6 +2739,9 @@ const addWidths = (entries, labelPadding, fontWeight, fontSize, fontFamily, lett
|
|
|
2652
2739
|
|
|
2653
2740
|
const loadContent = async (state, titleBarEntries) => {
|
|
2654
2741
|
const {
|
|
2742
|
+
platform,
|
|
2743
|
+
controlsOverlayEnabled,
|
|
2744
|
+
titleBarStyleCustom,
|
|
2655
2745
|
labelFontFamily,
|
|
2656
2746
|
labelFontSize,
|
|
2657
2747
|
labelFontWeight,
|
|
@@ -2659,9 +2749,13 @@ const loadContent = async (state, titleBarEntries) => {
|
|
|
2659
2749
|
labelPadding
|
|
2660
2750
|
} = state;
|
|
2661
2751
|
const withWidths = addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
|
|
2752
|
+
const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
|
|
2753
|
+
const title = 'test';
|
|
2662
2754
|
return {
|
|
2663
2755
|
...state,
|
|
2664
|
-
titleBarEntries: withWidths
|
|
2756
|
+
titleBarEntries: withWidths,
|
|
2757
|
+
buttons,
|
|
2758
|
+
title
|
|
2665
2759
|
};
|
|
2666
2760
|
};
|
|
2667
2761
|
|
|
@@ -3263,6 +3357,85 @@ const render2 = async (uid, diffResult) => {
|
|
|
3263
3357
|
return commands;
|
|
3264
3358
|
};
|
|
3265
3359
|
|
|
3360
|
+
const getIcon = assetDir => {
|
|
3361
|
+
return `${assetDir}/icons/icon.svg`;
|
|
3362
|
+
};
|
|
3363
|
+
|
|
3364
|
+
const getTitleBarVirtualDom = state => {
|
|
3365
|
+
const {
|
|
3366
|
+
titleBarEntries,
|
|
3367
|
+
width,
|
|
3368
|
+
focusedIndex,
|
|
3369
|
+
isMenuOpen,
|
|
3370
|
+
assetDir,
|
|
3371
|
+
title,
|
|
3372
|
+
titleBarButtons
|
|
3373
|
+
} = state;
|
|
3374
|
+
const dom = [];
|
|
3375
|
+
|
|
3376
|
+
// Add icon if enabled
|
|
3377
|
+
if (state.titleBarIconEnabled) {
|
|
3378
|
+
const iconSrc = getIcon(assetDir);
|
|
3379
|
+
const iconDom = getTitleBarIconVirtualDom(iconSrc);
|
|
3380
|
+
dom.push(...iconDom);
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
// Add menu bar if enabled
|
|
3384
|
+
if (state.titleBarMenuBarEnabled) {
|
|
3385
|
+
const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
|
|
3386
|
+
const menuBarDom = getTitleBarMenuBarVirtualDom(visibleEntries, focusedIndex);
|
|
3387
|
+
dom.push(...menuBarDom);
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
// Add title if enabled
|
|
3391
|
+
if (state.titleBarTitleEnabled) {
|
|
3392
|
+
const titleDom = getTitleVirtualDom(title);
|
|
3393
|
+
dom.push(...titleDom);
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
// Add buttons if enabled
|
|
3397
|
+
if (state.titleBarButtonsEnabled) {
|
|
3398
|
+
const buttonsDom = getTitleBarButtonsVirtualDom(titleBarButtons);
|
|
3399
|
+
dom.push(...buttonsDom);
|
|
3400
|
+
}
|
|
3401
|
+
return dom;
|
|
3402
|
+
};
|
|
3403
|
+
|
|
3404
|
+
const renderTitleBar = (oldState, newState) => {
|
|
3405
|
+
const dom = getTitleBarVirtualDom(newState);
|
|
3406
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3407
|
+
};
|
|
3408
|
+
|
|
3409
|
+
const getRenderer3 = diffType => {
|
|
3410
|
+
switch (diffType) {
|
|
3411
|
+
case RenderEntries:
|
|
3412
|
+
return renderTitleBar;
|
|
3413
|
+
case RenderFocusedIndex:
|
|
3414
|
+
return renderFocusedIndex;
|
|
3415
|
+
case RenderMenus:
|
|
3416
|
+
return renderMenus;
|
|
3417
|
+
default:
|
|
3418
|
+
throw new Error('unknown renderer');
|
|
3419
|
+
}
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3422
|
+
const render3 = async (uid, diffResult) => {
|
|
3423
|
+
const {
|
|
3424
|
+
oldState,
|
|
3425
|
+
newState
|
|
3426
|
+
} = get$1(uid);
|
|
3427
|
+
set$3(uid, newState, newState);
|
|
3428
|
+
const commands = [];
|
|
3429
|
+
for (const item of diffResult) {
|
|
3430
|
+
const fn = getRenderer3(item);
|
|
3431
|
+
const result = fn(oldState, newState);
|
|
3432
|
+
if (result.length > 0) {
|
|
3433
|
+
commands.push(result);
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
return commands;
|
|
3437
|
+
};
|
|
3438
|
+
|
|
3266
3439
|
const renderEventListeners = () => {
|
|
3267
3440
|
return [{
|
|
3268
3441
|
name: HandleClickMinimize,
|
|
@@ -3303,34 +3476,6 @@ const saveState = uid => {
|
|
|
3303
3476
|
};
|
|
3304
3477
|
};
|
|
3305
3478
|
|
|
3306
|
-
const DEFAULT_UID = 1;
|
|
3307
|
-
const createDefaultState = (uid = DEFAULT_UID) => ({
|
|
3308
|
-
assetDir: '',
|
|
3309
|
-
focusedIndex: -1,
|
|
3310
|
-
height: 30,
|
|
3311
|
-
iconWidth: 30,
|
|
3312
|
-
isMenuOpen: false,
|
|
3313
|
-
itleBarIconEnabled: true,
|
|
3314
|
-
labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
|
|
3315
|
-
labelFontSize: 13,
|
|
3316
|
-
labelFontWeight: 400,
|
|
3317
|
-
labelLetterSpacing: 0,
|
|
3318
|
-
labelPadding: 8,
|
|
3319
|
-
menus: [],
|
|
3320
|
-
titleBarButtonsEnabled: true,
|
|
3321
|
-
titleBarButtonsWidth: 90,
|
|
3322
|
-
titleBarEntries: [],
|
|
3323
|
-
titleBarHeight: 30,
|
|
3324
|
-
titleBarIconWidth: 30,
|
|
3325
|
-
titleBarMenuBarEnabled: true,
|
|
3326
|
-
titleBarTitleEnabled: true,
|
|
3327
|
-
uid,
|
|
3328
|
-
width: 800,
|
|
3329
|
-
x: 0,
|
|
3330
|
-
y: 0,
|
|
3331
|
-
title: ''
|
|
3332
|
-
});
|
|
3333
|
-
|
|
3334
3479
|
const create = (id, uri, x, y, width, height) => {
|
|
3335
3480
|
const state = {
|
|
3336
3481
|
...createDefaultState(),
|
|
@@ -3835,13 +3980,19 @@ const toggleMenu = async state => {
|
|
|
3835
3980
|
};
|
|
3836
3981
|
|
|
3837
3982
|
const commandMap = {
|
|
3983
|
+
'TitleBar.create3': create3,
|
|
3984
|
+
'TitleBar.diff3': diff3,
|
|
3838
3985
|
'TitleBar.getButtonsVirtualDom': getTitleBarButtonsVirtualDom,
|
|
3839
3986
|
'TitleBar.getIconVirtualDom': getTitleBarIconVirtualDom,
|
|
3840
3987
|
'TitleBar.getMenuEntries': getMenuEntries$1,
|
|
3841
3988
|
'TitleBar.getMenuIds': getMenuIds,
|
|
3842
3989
|
'TitleBar.getTitleVirtualDom': getTitleVirtualDom,
|
|
3843
3990
|
'TitleBar.handleButtonsClick': handleClick$1,
|
|
3991
|
+
'TitleBar.handleClickClose': wrapCommand(handleClickClose),
|
|
3992
|
+
'TitleBar.handleClickMinimize': wrapCommand(handleClickMinimize),
|
|
3993
|
+
'TitleBar.handleClickToggleMaximize': wrapCommand(handleClickToggleMaximize),
|
|
3844
3994
|
'TitleBar.handleContextMenu': handleContextMenu,
|
|
3995
|
+
'TitleBar.render3': render3,
|
|
3845
3996
|
'TitleBar.renderEventListeners': renderEventListeners,
|
|
3846
3997
|
'TitleBarMenuBar.closeMenu': closeMenu,
|
|
3847
3998
|
'TitleBarMenuBar.create': create,
|