@lvce-editor/title-bar-worker 2.8.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 +364 -185
- package/package.json +2 -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';
|
|
@@ -1051,13 +1251,17 @@ const MenuItemCheckBox = 'menuitemcheckbox';
|
|
|
1051
1251
|
const None$1 = 'none';
|
|
1052
1252
|
const Separator$1 = 'separator';
|
|
1053
1253
|
|
|
1054
|
-
const Button = 1;
|
|
1254
|
+
const Button$1 = 1;
|
|
1055
1255
|
const Div = 4;
|
|
1056
1256
|
const Span = 8;
|
|
1057
1257
|
const Text = 12;
|
|
1058
1258
|
const I = 16;
|
|
1059
1259
|
const Img = 17;
|
|
1060
1260
|
|
|
1261
|
+
const Button = 'event.button';
|
|
1262
|
+
const ClientX = 'event.clientX';
|
|
1263
|
+
const ClientY = 'event.clientY';
|
|
1264
|
+
|
|
1061
1265
|
const Escape$2 = 8;
|
|
1062
1266
|
const Space$2 = 9;
|
|
1063
1267
|
const End$2 = 255;
|
|
@@ -1127,18 +1331,6 @@ const getKeyBindings$1 = () => {
|
|
|
1127
1331
|
}];
|
|
1128
1332
|
};
|
|
1129
1333
|
|
|
1130
|
-
const emptyObject = {};
|
|
1131
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1132
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1133
|
-
if (placeholders === emptyObject) {
|
|
1134
|
-
return key;
|
|
1135
|
-
}
|
|
1136
|
-
const replacer = (match, rest) => {
|
|
1137
|
-
return placeholders[rest];
|
|
1138
|
-
};
|
|
1139
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
1334
|
/**
|
|
1143
1335
|
* @enum {string}
|
|
1144
1336
|
*/
|
|
@@ -1192,16 +1384,16 @@ const moveLineDown = () => {
|
|
|
1192
1384
|
return i18nString(UiStrings$1.MoveLineDown);
|
|
1193
1385
|
};
|
|
1194
1386
|
|
|
1195
|
-
const Edit
|
|
1196
|
-
const File$
|
|
1197
|
-
const Go
|
|
1198
|
-
const Help
|
|
1387
|
+
const Edit = 2;
|
|
1388
|
+
const File$1 = 5;
|
|
1389
|
+
const Go = 6;
|
|
1390
|
+
const Help = 7;
|
|
1199
1391
|
const OpenRecent = 9;
|
|
1200
|
-
const Run
|
|
1201
|
-
const Selection
|
|
1202
|
-
const Terminal
|
|
1392
|
+
const Run = 10;
|
|
1393
|
+
const Selection = 11;
|
|
1394
|
+
const Terminal = 14;
|
|
1203
1395
|
const TitleBar = 15;
|
|
1204
|
-
const View
|
|
1396
|
+
const View = 16;
|
|
1205
1397
|
|
|
1206
1398
|
const Separator = 1;
|
|
1207
1399
|
const None = 0;
|
|
@@ -1219,7 +1411,7 @@ const menuEntrySeparator = {
|
|
|
1219
1411
|
command: ''
|
|
1220
1412
|
};
|
|
1221
1413
|
|
|
1222
|
-
const id$9 = Edit
|
|
1414
|
+
const id$9 = Edit;
|
|
1223
1415
|
const getMenuEntries$d = () => {
|
|
1224
1416
|
return [{
|
|
1225
1417
|
id: 'undo',
|
|
@@ -1303,11 +1495,7 @@ const exit = () => {
|
|
|
1303
1495
|
return i18nString(UiStrings.Exit);
|
|
1304
1496
|
};
|
|
1305
1497
|
|
|
1306
|
-
const
|
|
1307
|
-
const Electron = 2;
|
|
1308
|
-
const Remote = 3;
|
|
1309
|
-
|
|
1310
|
-
const id$8 = File$2;
|
|
1498
|
+
const id$8 = File$1;
|
|
1311
1499
|
const getMenuEntries$c = platform => {
|
|
1312
1500
|
const entries = [{
|
|
1313
1501
|
id: 'newFile',
|
|
@@ -1362,7 +1550,7 @@ const MenuEntriesFile = {
|
|
|
1362
1550
|
id: id$8
|
|
1363
1551
|
};
|
|
1364
1552
|
|
|
1365
|
-
const id$7 = Go
|
|
1553
|
+
const id$7 = Go;
|
|
1366
1554
|
const getMenuEntries$b = () => {
|
|
1367
1555
|
return [];
|
|
1368
1556
|
};
|
|
@@ -1373,25 +1561,6 @@ const MenuEntriesGo = {
|
|
|
1373
1561
|
id: id$7
|
|
1374
1562
|
};
|
|
1375
1563
|
|
|
1376
|
-
const About = 'About';
|
|
1377
|
-
const CheckForUpdates = 'Check For Updates';
|
|
1378
|
-
const ClearRecentlyOpened = 'Clear Recently Opened';
|
|
1379
|
-
const Close = 'Close';
|
|
1380
|
-
const Edit = 'Edit';
|
|
1381
|
-
const File$1 = 'File';
|
|
1382
|
-
const Go = 'Go';
|
|
1383
|
-
const Help = 'Help';
|
|
1384
|
-
const Maximize = 'Maximize';
|
|
1385
|
-
const Minimize = 'Minimize';
|
|
1386
|
-
const MoreDot = 'More ...';
|
|
1387
|
-
const NewTerminal = 'New Terminal';
|
|
1388
|
-
const OpenProcessExplorer = 'Open Process Explorer';
|
|
1389
|
-
const Run = 'Run';
|
|
1390
|
-
const Selection = 'Selection';
|
|
1391
|
-
const Terminal = 'Terminal';
|
|
1392
|
-
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1393
|
-
const View = 'View';
|
|
1394
|
-
|
|
1395
1564
|
const toggleDeveloperTools = () => {
|
|
1396
1565
|
return i18nString(ToggleDeveloperTools);
|
|
1397
1566
|
};
|
|
@@ -1412,7 +1581,7 @@ const isAutoUpdateSupported = platform => {
|
|
|
1412
1581
|
return false;
|
|
1413
1582
|
};
|
|
1414
1583
|
|
|
1415
|
-
const id$6 = Help
|
|
1584
|
+
const id$6 = Help;
|
|
1416
1585
|
const getMenuEntries$a = async platform => {
|
|
1417
1586
|
const autoUpdateSupported = isAutoUpdateSupported(platform);
|
|
1418
1587
|
const entries = [];
|
|
@@ -1913,7 +2082,7 @@ const MenuEntriesOpenRecent = {
|
|
|
1913
2082
|
id: id$5
|
|
1914
2083
|
};
|
|
1915
2084
|
|
|
1916
|
-
const id$4 = Run
|
|
2085
|
+
const id$4 = Run;
|
|
1917
2086
|
const getMenuEntries$8 = () => {
|
|
1918
2087
|
return [];
|
|
1919
2088
|
};
|
|
@@ -1924,7 +2093,7 @@ const MenuEntriesRun = {
|
|
|
1924
2093
|
id: id$4
|
|
1925
2094
|
};
|
|
1926
2095
|
|
|
1927
|
-
const id$3 = Selection
|
|
2096
|
+
const id$3 = Selection;
|
|
1928
2097
|
const getMenuEntries$7 = () => {
|
|
1929
2098
|
return [{
|
|
1930
2099
|
id: 'selectAll',
|
|
@@ -1960,7 +2129,7 @@ const MenuEntriesSelection = {
|
|
|
1960
2129
|
id: id$3
|
|
1961
2130
|
};
|
|
1962
2131
|
|
|
1963
|
-
const id$2 = Terminal
|
|
2132
|
+
const id$2 = Terminal;
|
|
1964
2133
|
const getMenuEntries$6 = () => {
|
|
1965
2134
|
return [{
|
|
1966
2135
|
id: 'newTerminal',
|
|
@@ -1977,73 +2146,39 @@ const MenuEntriesTerminal = {
|
|
|
1977
2146
|
id: id$2
|
|
1978
2147
|
};
|
|
1979
2148
|
|
|
1980
|
-
const file = () => {
|
|
1981
|
-
return i18nString(File$1);
|
|
1982
|
-
};
|
|
1983
|
-
const edit = () => {
|
|
1984
|
-
return i18nString(Edit);
|
|
1985
|
-
};
|
|
1986
|
-
const selection = () => {
|
|
1987
|
-
return i18nString(Selection);
|
|
1988
|
-
};
|
|
1989
|
-
const view = () => {
|
|
1990
|
-
return i18nString(View);
|
|
1991
|
-
};
|
|
1992
|
-
const go = () => {
|
|
1993
|
-
return i18nString(Go);
|
|
1994
|
-
};
|
|
1995
|
-
const run = () => {
|
|
1996
|
-
return i18nString(Run);
|
|
1997
|
-
};
|
|
1998
|
-
const terminal = () => {
|
|
1999
|
-
return i18nString(Terminal);
|
|
2000
|
-
};
|
|
2001
|
-
const help = () => {
|
|
2002
|
-
return i18nString(Help);
|
|
2003
|
-
};
|
|
2004
|
-
const minimize$1 = () => {
|
|
2005
|
-
return i18nString(Minimize);
|
|
2006
|
-
};
|
|
2007
|
-
const maximize$1 = () => {
|
|
2008
|
-
return i18nString(Maximize);
|
|
2009
|
-
};
|
|
2010
|
-
const close$1 = () => {
|
|
2011
|
-
return i18nString(Close);
|
|
2012
|
-
};
|
|
2013
|
-
|
|
2014
2149
|
const getMenuEntries$5 = () => {
|
|
2015
2150
|
return [{
|
|
2016
|
-
id: File$
|
|
2151
|
+
id: File$1,
|
|
2017
2152
|
label: file(),
|
|
2018
2153
|
flags: SubMenu
|
|
2019
2154
|
}, {
|
|
2020
|
-
id: Edit
|
|
2155
|
+
id: Edit,
|
|
2021
2156
|
label: edit(),
|
|
2022
2157
|
flags: SubMenu
|
|
2023
2158
|
}, {
|
|
2024
|
-
id: Selection
|
|
2159
|
+
id: Selection,
|
|
2025
2160
|
label: selection(),
|
|
2026
2161
|
flags: SubMenu
|
|
2027
2162
|
}, {
|
|
2028
|
-
id: View
|
|
2163
|
+
id: View,
|
|
2029
2164
|
label: view(),
|
|
2030
2165
|
flags: SubMenu
|
|
2031
2166
|
}, {
|
|
2032
|
-
id: Go
|
|
2167
|
+
id: Go,
|
|
2033
2168
|
label: go(),
|
|
2034
2169
|
flags: SubMenu
|
|
2035
2170
|
}, {
|
|
2036
|
-
id: Run
|
|
2171
|
+
id: Run,
|
|
2037
2172
|
label: run(),
|
|
2038
2173
|
keyboardShortCut: 'Alt+r',
|
|
2039
2174
|
flags: SubMenu
|
|
2040
2175
|
}, {
|
|
2041
|
-
id: Terminal
|
|
2176
|
+
id: Terminal,
|
|
2042
2177
|
label: terminal(),
|
|
2043
2178
|
keyboardShortCut: 'Alt+t',
|
|
2044
2179
|
flags: SubMenu
|
|
2045
2180
|
}, {
|
|
2046
|
-
id: Help
|
|
2181
|
+
id: Help,
|
|
2047
2182
|
label: help(),
|
|
2048
2183
|
keyboardShortCut: 'Alt+h',
|
|
2049
2184
|
flags: SubMenu
|
|
@@ -2052,27 +2187,27 @@ const getMenuEntries$5 = () => {
|
|
|
2052
2187
|
|
|
2053
2188
|
const getMenuEntries$4 = () => {
|
|
2054
2189
|
return [{
|
|
2055
|
-
id: File$
|
|
2190
|
+
id: File$1,
|
|
2056
2191
|
label: file(),
|
|
2057
2192
|
flags: None
|
|
2058
2193
|
}, {
|
|
2059
|
-
id: Edit
|
|
2194
|
+
id: Edit,
|
|
2060
2195
|
label: edit(),
|
|
2061
2196
|
flags: None
|
|
2062
2197
|
}, {
|
|
2063
|
-
id: Selection
|
|
2198
|
+
id: Selection,
|
|
2064
2199
|
label: selection(),
|
|
2065
2200
|
flags: None
|
|
2066
2201
|
}, {
|
|
2067
|
-
id: View
|
|
2202
|
+
id: View,
|
|
2068
2203
|
label: view(),
|
|
2069
2204
|
flags: None
|
|
2070
2205
|
}, {
|
|
2071
|
-
id: Go
|
|
2206
|
+
id: Go,
|
|
2072
2207
|
label: go(),
|
|
2073
2208
|
flags: None
|
|
2074
2209
|
}, {
|
|
2075
|
-
id: Help
|
|
2210
|
+
id: Help,
|
|
2076
2211
|
label: help(),
|
|
2077
2212
|
flags: None
|
|
2078
2213
|
}];
|
|
@@ -2098,7 +2233,7 @@ const MenuEntriesTitleBar = {
|
|
|
2098
2233
|
id: id$1
|
|
2099
2234
|
};
|
|
2100
2235
|
|
|
2101
|
-
const id = View
|
|
2236
|
+
const id = View;
|
|
2102
2237
|
const getMenuEntries$2 = () => {
|
|
2103
2238
|
return [];
|
|
2104
2239
|
};
|
|
@@ -2122,53 +2257,6 @@ const getMenuEntries$1 = (id, platform) => {
|
|
|
2122
2257
|
return menu.getMenuEntries(platform);
|
|
2123
2258
|
};
|
|
2124
2259
|
|
|
2125
|
-
const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
2126
|
-
if (controlsOverlayEnabled) {
|
|
2127
|
-
return [];
|
|
2128
|
-
}
|
|
2129
|
-
if (titleBarStyleCustom) {
|
|
2130
|
-
// TODO don't render title bar buttons on windows when electron window controls overlay is enabled
|
|
2131
|
-
return [{
|
|
2132
|
-
label: minimize$1(),
|
|
2133
|
-
icon: 'Minimize',
|
|
2134
|
-
id: 'Minimize',
|
|
2135
|
-
onClick: 'handleClickMinimize'
|
|
2136
|
-
}, {
|
|
2137
|
-
label: maximize$1(),
|
|
2138
|
-
icon: 'Maximize',
|
|
2139
|
-
id: 'ToggleMaximize',
|
|
2140
|
-
onClick: 'handleClickToggleMaximize'
|
|
2141
|
-
}, {
|
|
2142
|
-
label: close$1(),
|
|
2143
|
-
icon: 'ChromeClose',
|
|
2144
|
-
id: 'Close',
|
|
2145
|
-
onClick: 'handleClickClose'
|
|
2146
|
-
}];
|
|
2147
|
-
}
|
|
2148
|
-
return [];
|
|
2149
|
-
};
|
|
2150
|
-
|
|
2151
|
-
const getTitleBarButtonsRemote = () => {
|
|
2152
|
-
return [];
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
const getTitleBarButtonsWeb = () => {
|
|
2156
|
-
return [];
|
|
2157
|
-
};
|
|
2158
|
-
|
|
2159
|
-
const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
|
|
2160
|
-
switch (platform) {
|
|
2161
|
-
case Electron:
|
|
2162
|
-
return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
|
|
2163
|
-
case Web:
|
|
2164
|
-
return getTitleBarButtonsWeb();
|
|
2165
|
-
case Remote:
|
|
2166
|
-
return getTitleBarButtonsRemote();
|
|
2167
|
-
default:
|
|
2168
|
-
return [];
|
|
2169
|
-
}
|
|
2170
|
-
};
|
|
2171
|
-
|
|
2172
2260
|
const MaskIconCheck = 'MaskIconCheck';
|
|
2173
2261
|
const Menu = 'Menu';
|
|
2174
2262
|
const MenuItem = 'MenuItem';
|
|
@@ -2206,7 +2294,7 @@ const createTitleBarButton = button => {
|
|
|
2206
2294
|
onClick
|
|
2207
2295
|
} = button;
|
|
2208
2296
|
const dom = [{
|
|
2209
|
-
type: Button,
|
|
2297
|
+
type: Button$1,
|
|
2210
2298
|
className: `TitleBarButton TitleBarButton${id}`,
|
|
2211
2299
|
ariaLabel: label,
|
|
2212
2300
|
childCount: 1,
|
|
@@ -2630,8 +2718,11 @@ const measureTextWidths = (texts, fontWeight, fontSize, fontFamily, letterSpacin
|
|
|
2630
2718
|
return widths;
|
|
2631
2719
|
};
|
|
2632
2720
|
|
|
2721
|
+
const getLabel = entry => {
|
|
2722
|
+
return entry.label;
|
|
2723
|
+
};
|
|
2633
2724
|
const addWidths = (entries, labelPadding, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2634
|
-
const labels = entries.map(
|
|
2725
|
+
const labels = entries.map(getLabel);
|
|
2635
2726
|
const widths = measureTextWidths(labels, fontWeight, fontSize, fontFamily, letterSpacing);
|
|
2636
2727
|
const withWidths = [];
|
|
2637
2728
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -2648,6 +2739,9 @@ const addWidths = (entries, labelPadding, fontWeight, fontSize, fontFamily, lett
|
|
|
2648
2739
|
|
|
2649
2740
|
const loadContent = async (state, titleBarEntries) => {
|
|
2650
2741
|
const {
|
|
2742
|
+
platform,
|
|
2743
|
+
controlsOverlayEnabled,
|
|
2744
|
+
titleBarStyleCustom,
|
|
2651
2745
|
labelFontFamily,
|
|
2652
2746
|
labelFontSize,
|
|
2653
2747
|
labelFontWeight,
|
|
@@ -2655,9 +2749,13 @@ const loadContent = async (state, titleBarEntries) => {
|
|
|
2655
2749
|
labelPadding
|
|
2656
2750
|
} = state;
|
|
2657
2751
|
const withWidths = addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
|
|
2752
|
+
const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
|
|
2753
|
+
const title = 'test';
|
|
2658
2754
|
return {
|
|
2659
2755
|
...state,
|
|
2660
|
-
titleBarEntries: withWidths
|
|
2756
|
+
titleBarEntries: withWidths,
|
|
2757
|
+
buttons,
|
|
2758
|
+
title
|
|
2661
2759
|
};
|
|
2662
2760
|
};
|
|
2663
2761
|
|
|
@@ -3048,20 +3146,15 @@ const getMenuItemDefaultDom = menuItem => {
|
|
|
3048
3146
|
key
|
|
3049
3147
|
} = menuItem;
|
|
3050
3148
|
const className = getMenuItemClassName(isFocused);
|
|
3051
|
-
const
|
|
3052
|
-
|
|
3149
|
+
const keyDom = key ? getKeyDom(key) : [];
|
|
3150
|
+
const childCount = key ? 2 : 1;
|
|
3151
|
+
return [{
|
|
3053
3152
|
type: Div,
|
|
3054
3153
|
className,
|
|
3055
3154
|
role: MenuItem$1,
|
|
3056
3155
|
tabIndex: -1,
|
|
3057
|
-
childCount
|
|
3058
|
-
}, text(label)
|
|
3059
|
-
if (key) {
|
|
3060
|
-
dom[0].childCount++;
|
|
3061
|
-
const keyDom = getKeyDom(key);
|
|
3062
|
-
dom.push(...keyDom);
|
|
3063
|
-
}
|
|
3064
|
-
return dom;
|
|
3156
|
+
childCount
|
|
3157
|
+
}, text(label), ...keyDom];
|
|
3065
3158
|
};
|
|
3066
3159
|
|
|
3067
3160
|
const disabled = {
|
|
@@ -3264,6 +3357,85 @@ const render2 = async (uid, diffResult) => {
|
|
|
3264
3357
|
return commands;
|
|
3265
3358
|
};
|
|
3266
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
|
+
|
|
3267
3439
|
const renderEventListeners = () => {
|
|
3268
3440
|
return [{
|
|
3269
3441
|
name: HandleClickMinimize,
|
|
@@ -3279,22 +3451,22 @@ const renderEventListeners = () => {
|
|
|
3279
3451
|
params: ['handleFocus']
|
|
3280
3452
|
}, {
|
|
3281
3453
|
name: HandleMenuClick,
|
|
3282
|
-
params: ['handleMenuClick',
|
|
3454
|
+
params: ['handleMenuClick', ClientX, ClientY]
|
|
3283
3455
|
}, {
|
|
3284
3456
|
name: HandleMenuMouseOver,
|
|
3285
|
-
params: ['handleMenuMouseOver',
|
|
3457
|
+
params: ['handleMenuMouseOver', ClientX, ClientY]
|
|
3286
3458
|
}, {
|
|
3287
3459
|
name: HandleClick,
|
|
3288
|
-
params: ['handleClickAt',
|
|
3460
|
+
params: ['handleClickAt', Button, ClientX, ClientY]
|
|
3289
3461
|
}, {
|
|
3290
3462
|
name: HandlePointerOut,
|
|
3291
|
-
params: ['handlePointerOut',
|
|
3463
|
+
params: ['handlePointerOut', ClientX, ClientY]
|
|
3292
3464
|
}, {
|
|
3293
3465
|
name: HandlePointerOver,
|
|
3294
|
-
params: ['handlePointerOver',
|
|
3466
|
+
params: ['handlePointerOver', ClientX, ClientY]
|
|
3295
3467
|
}, {
|
|
3296
3468
|
name: HandleFocusOut,
|
|
3297
|
-
params: ['handleFocusOut',
|
|
3469
|
+
params: ['handleFocusOut', ClientX, ClientY] // TODO maybe check relatedTarget
|
|
3298
3470
|
}];
|
|
3299
3471
|
};
|
|
3300
3472
|
|
|
@@ -3306,6 +3478,7 @@ const saveState = uid => {
|
|
|
3306
3478
|
|
|
3307
3479
|
const create = (id, uri, x, y, width, height) => {
|
|
3308
3480
|
const state = {
|
|
3481
|
+
...createDefaultState(),
|
|
3309
3482
|
uid: id,
|
|
3310
3483
|
titleBarEntries: [],
|
|
3311
3484
|
focusedIndex: -1,
|
|
@@ -3807,13 +3980,19 @@ const toggleMenu = async state => {
|
|
|
3807
3980
|
};
|
|
3808
3981
|
|
|
3809
3982
|
const commandMap = {
|
|
3983
|
+
'TitleBar.create3': create3,
|
|
3984
|
+
'TitleBar.diff3': diff3,
|
|
3810
3985
|
'TitleBar.getButtonsVirtualDom': getTitleBarButtonsVirtualDom,
|
|
3811
3986
|
'TitleBar.getIconVirtualDom': getTitleBarIconVirtualDom,
|
|
3812
3987
|
'TitleBar.getMenuEntries': getMenuEntries$1,
|
|
3813
3988
|
'TitleBar.getMenuIds': getMenuIds,
|
|
3814
3989
|
'TitleBar.getTitleVirtualDom': getTitleVirtualDom,
|
|
3815
3990
|
'TitleBar.handleButtonsClick': handleClick$1,
|
|
3991
|
+
'TitleBar.handleClickClose': wrapCommand(handleClickClose),
|
|
3992
|
+
'TitleBar.handleClickMinimize': wrapCommand(handleClickMinimize),
|
|
3993
|
+
'TitleBar.handleClickToggleMaximize': wrapCommand(handleClickToggleMaximize),
|
|
3816
3994
|
'TitleBar.handleContextMenu': handleContextMenu,
|
|
3995
|
+
'TitleBar.render3': render3,
|
|
3817
3996
|
'TitleBar.renderEventListeners': renderEventListeners,
|
|
3818
3997
|
'TitleBarMenuBar.closeMenu': closeMenu,
|
|
3819
3998
|
'TitleBarMenuBar.create': create,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/title-bar-worker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Title Bar Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/titleBarWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@lvce-editor/constants": "^1.26.0",
|
|
14
15
|
"@lvce-editor/viewlet-registry": "^1.4.0"
|
|
15
16
|
}
|
|
16
17
|
}
|