@lvce-editor/title-bar-worker 4.24.0 → 4.25.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 +88 -28
- package/package.json +1 -1
|
@@ -745,7 +745,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
745
745
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
746
746
|
return create$1$1(id, errorProperty);
|
|
747
747
|
};
|
|
748
|
-
const create$
|
|
748
|
+
const create$a = (message, result) => {
|
|
749
749
|
return {
|
|
750
750
|
id: message.id,
|
|
751
751
|
jsonrpc: Two$1,
|
|
@@ -754,7 +754,7 @@ const create$9 = (message, result) => {
|
|
|
754
754
|
};
|
|
755
755
|
const getSuccessResponse = (message, result) => {
|
|
756
756
|
const resultProperty = result ?? null;
|
|
757
|
-
return create$
|
|
757
|
+
return create$a(message, resultProperty);
|
|
758
758
|
};
|
|
759
759
|
const getErrorResponseSimple = (id, error) => {
|
|
760
760
|
return {
|
|
@@ -848,7 +848,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
848
848
|
|
|
849
849
|
const Two = '2.0';
|
|
850
850
|
|
|
851
|
-
const create$
|
|
851
|
+
const create$9 = (method, params) => {
|
|
852
852
|
return {
|
|
853
853
|
jsonrpc: Two,
|
|
854
854
|
method,
|
|
@@ -856,7 +856,7 @@ const create$8 = (method, params) => {
|
|
|
856
856
|
};
|
|
857
857
|
};
|
|
858
858
|
|
|
859
|
-
const create$
|
|
859
|
+
const create$8 = (id, method, params) => {
|
|
860
860
|
const message = {
|
|
861
861
|
id,
|
|
862
862
|
jsonrpc: Two,
|
|
@@ -867,12 +867,12 @@ const create$7 = (id, method, params) => {
|
|
|
867
867
|
};
|
|
868
868
|
|
|
869
869
|
let id = 0;
|
|
870
|
-
const create$
|
|
870
|
+
const create$7 = () => {
|
|
871
871
|
return ++id;
|
|
872
872
|
};
|
|
873
873
|
|
|
874
874
|
const registerPromise = map => {
|
|
875
|
-
const id = create$
|
|
875
|
+
const id = create$7();
|
|
876
876
|
const {
|
|
877
877
|
promise,
|
|
878
878
|
resolve
|
|
@@ -889,7 +889,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
889
889
|
id,
|
|
890
890
|
promise
|
|
891
891
|
} = registerPromise(callbacks);
|
|
892
|
-
const message = create$
|
|
892
|
+
const message = create$8(id, method, params);
|
|
893
893
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
894
894
|
ipc.sendAndTransfer(message);
|
|
895
895
|
} else {
|
|
@@ -925,7 +925,7 @@ const createRpc = ipc => {
|
|
|
925
925
|
* @deprecated
|
|
926
926
|
*/
|
|
927
927
|
send(method, ...params) {
|
|
928
|
-
const message = create$
|
|
928
|
+
const message = create$9(method, params);
|
|
929
929
|
ipc.send(message);
|
|
930
930
|
}
|
|
931
931
|
};
|
|
@@ -965,7 +965,7 @@ const listen$1 = async (module, options) => {
|
|
|
965
965
|
return ipc;
|
|
966
966
|
};
|
|
967
967
|
|
|
968
|
-
const create$
|
|
968
|
+
const create$6 = async ({
|
|
969
969
|
commandMap,
|
|
970
970
|
isMessagePortOpen = true,
|
|
971
971
|
messagePort
|
|
@@ -983,7 +983,7 @@ const create$5 = async ({
|
|
|
983
983
|
return rpc;
|
|
984
984
|
};
|
|
985
985
|
|
|
986
|
-
const create$
|
|
986
|
+
const create$5 = async ({
|
|
987
987
|
commandMap,
|
|
988
988
|
isMessagePortOpen,
|
|
989
989
|
send
|
|
@@ -993,13 +993,55 @@ const create$4 = async ({
|
|
|
993
993
|
port2
|
|
994
994
|
} = new MessageChannel();
|
|
995
995
|
await send(port1);
|
|
996
|
-
return create$
|
|
996
|
+
return create$6({
|
|
997
997
|
commandMap,
|
|
998
998
|
isMessagePortOpen,
|
|
999
999
|
messagePort: port2
|
|
1000
1000
|
});
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
|
+
const createSharedLazyRpc = factory => {
|
|
1004
|
+
let rpcPromise;
|
|
1005
|
+
const getOrCreate = () => {
|
|
1006
|
+
if (!rpcPromise) {
|
|
1007
|
+
rpcPromise = factory();
|
|
1008
|
+
}
|
|
1009
|
+
return rpcPromise;
|
|
1010
|
+
};
|
|
1011
|
+
return {
|
|
1012
|
+
async dispose() {
|
|
1013
|
+
const rpc = await getOrCreate();
|
|
1014
|
+
await rpc.dispose();
|
|
1015
|
+
},
|
|
1016
|
+
async invoke(method, ...params) {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
return rpc.invoke(method, ...params);
|
|
1019
|
+
},
|
|
1020
|
+
async invokeAndTransfer(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1023
|
+
},
|
|
1024
|
+
async send(method, ...params) {
|
|
1025
|
+
const rpc = await getOrCreate();
|
|
1026
|
+
rpc.send(method, ...params);
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
const create$4 = async ({
|
|
1032
|
+
commandMap,
|
|
1033
|
+
isMessagePortOpen,
|
|
1034
|
+
send
|
|
1035
|
+
}) => {
|
|
1036
|
+
return createSharedLazyRpc(() => {
|
|
1037
|
+
return create$5({
|
|
1038
|
+
commandMap,
|
|
1039
|
+
isMessagePortOpen,
|
|
1040
|
+
send
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1003
1045
|
const create$3 = async ({
|
|
1004
1046
|
commandMap
|
|
1005
1047
|
}) => {
|
|
@@ -1032,7 +1074,7 @@ const createMockRpc = ({
|
|
|
1032
1074
|
};
|
|
1033
1075
|
|
|
1034
1076
|
const rpcs = Object.create(null);
|
|
1035
|
-
const set$
|
|
1077
|
+
const set$5 = (id, rpc) => {
|
|
1036
1078
|
rpcs[id] = rpc;
|
|
1037
1079
|
};
|
|
1038
1080
|
const get$1 = id => {
|
|
@@ -1065,7 +1107,7 @@ const create$2 = rpcId => {
|
|
|
1065
1107
|
const mockRpc = createMockRpc({
|
|
1066
1108
|
commandMap
|
|
1067
1109
|
});
|
|
1068
|
-
set$
|
|
1110
|
+
set$5(rpcId, mockRpc);
|
|
1069
1111
|
// @ts-ignore
|
|
1070
1112
|
mockRpc[Symbol.dispose] = () => {
|
|
1071
1113
|
remove(rpcId);
|
|
@@ -1074,7 +1116,7 @@ const create$2 = rpcId => {
|
|
|
1074
1116
|
return mockRpc;
|
|
1075
1117
|
},
|
|
1076
1118
|
set(rpc) {
|
|
1077
|
-
set$
|
|
1119
|
+
set$5(rpcId, rpc);
|
|
1078
1120
|
}
|
|
1079
1121
|
};
|
|
1080
1122
|
};
|
|
@@ -1495,6 +1537,7 @@ const parseKey = rawKey => {
|
|
|
1495
1537
|
|
|
1496
1538
|
const Electron$1 = 2;
|
|
1497
1539
|
|
|
1540
|
+
const MainProcess = -5;
|
|
1498
1541
|
const RendererProcess = 1670;
|
|
1499
1542
|
const RendererWorker = 1;
|
|
1500
1543
|
|
|
@@ -1504,6 +1547,11 @@ const SetFocusContext = 'Viewlet.setFocusContext';
|
|
|
1504
1547
|
|
|
1505
1548
|
const FocusTitleBarMenuBar = 26;
|
|
1506
1549
|
|
|
1550
|
+
const {
|
|
1551
|
+
invoke: invoke$3,
|
|
1552
|
+
set: set$4
|
|
1553
|
+
} = create$2(MainProcess);
|
|
1554
|
+
|
|
1507
1555
|
const {
|
|
1508
1556
|
invoke: invoke$2,
|
|
1509
1557
|
set: set$3
|
|
@@ -1580,9 +1628,6 @@ const sendMessagePortToTextMeasurementWorker = async port => {
|
|
|
1580
1628
|
const command = 'TextMeasurement.handleMessagePort';
|
|
1581
1629
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1582
1630
|
};
|
|
1583
|
-
const getWindowId$1 = async () => {
|
|
1584
|
-
return invoke$1('GetWindowId.getWindowId');
|
|
1585
|
-
};
|
|
1586
1631
|
const minimizeWindow = async () => {
|
|
1587
1632
|
return invoke$1('ElectronWindow.minimize');
|
|
1588
1633
|
};
|
|
@@ -3203,11 +3248,18 @@ const getEntryMap = async (state, menuIds, platform) => {
|
|
|
3203
3248
|
return map;
|
|
3204
3249
|
};
|
|
3205
3250
|
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3251
|
+
const send = async port => {
|
|
3252
|
+
await invokeAndTransfer('SendMessagePortToMainProcess.sendMessagePortToMainProcess', port, 'HandleElectronMessagePort.handleElectronMessagePort', 0);
|
|
3253
|
+
};
|
|
3254
|
+
const initializeMainProcess = async () => {
|
|
3255
|
+
if (get$1(MainProcess)) {
|
|
3256
|
+
return;
|
|
3257
|
+
}
|
|
3258
|
+
const rpc = await create$4({
|
|
3259
|
+
commandMap: {},
|
|
3260
|
+
send
|
|
3261
|
+
});
|
|
3262
|
+
set$4(rpc);
|
|
3211
3263
|
};
|
|
3212
3264
|
|
|
3213
3265
|
// based on https://www.electronjs.org/docs/latest/api/menu-item#new-menuitemoptions
|
|
@@ -3349,8 +3401,8 @@ const toElectronMenu = (map, rootId) => {
|
|
|
3349
3401
|
};
|
|
3350
3402
|
|
|
3351
3403
|
const setItems = async items => {
|
|
3352
|
-
|
|
3353
|
-
return invoke$
|
|
3404
|
+
await initializeMainProcess();
|
|
3405
|
+
return invoke$3('ElectronApplicationMenu.setItems', items);
|
|
3354
3406
|
};
|
|
3355
3407
|
const hydrate = async state => {
|
|
3356
3408
|
const {
|
|
@@ -3868,7 +3920,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
3868
3920
|
}
|
|
3869
3921
|
}
|
|
3870
3922
|
};
|
|
3871
|
-
const rpc = await create$
|
|
3923
|
+
const rpc = await create$6({
|
|
3872
3924
|
commandMap: {
|
|
3873
3925
|
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
3874
3926
|
},
|
|
@@ -4242,7 +4294,7 @@ const getTitle = (workspaceUri, titleTemplate, appName) => {
|
|
|
4242
4294
|
};
|
|
4243
4295
|
|
|
4244
4296
|
const launchTextMeasurementWorker = async () => {
|
|
4245
|
-
const rpc = await create$
|
|
4297
|
+
const rpc = await create$5({
|
|
4246
4298
|
commandMap: {},
|
|
4247
4299
|
async send(port) {
|
|
4248
4300
|
await sendMessagePortToTextMeasurementWorker(port);
|
|
@@ -4286,7 +4338,9 @@ const handleWorkspaceChange = async (state, uri) => {
|
|
|
4286
4338
|
labelFontSize,
|
|
4287
4339
|
labelFontWeight,
|
|
4288
4340
|
labelLetterSpacing,
|
|
4289
|
-
titleTemplate
|
|
4341
|
+
titleTemplate,
|
|
4342
|
+
titleWidth: oldTitleWidth,
|
|
4343
|
+
width
|
|
4290
4344
|
} = state;
|
|
4291
4345
|
const title = getTitle(uri, titleTemplate, appName);
|
|
4292
4346
|
const titleWidth = await measureTitleWidth(title, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
|
|
@@ -4294,6 +4348,8 @@ const handleWorkspaceChange = async (state, uri) => {
|
|
|
4294
4348
|
...state,
|
|
4295
4349
|
title,
|
|
4296
4350
|
titleWidth,
|
|
4351
|
+
// The title is centered, so half its width change becomes available to the menu.
|
|
4352
|
+
width: width + (oldTitleWidth - titleWidth) / 2,
|
|
4297
4353
|
workspaceUri: uri
|
|
4298
4354
|
};
|
|
4299
4355
|
};
|
|
@@ -4842,6 +4898,8 @@ const setTitleTemplate = async (state, titleTemplate) => {
|
|
|
4842
4898
|
labelFontSize,
|
|
4843
4899
|
labelFontWeight,
|
|
4844
4900
|
labelLetterSpacing,
|
|
4901
|
+
titleWidth: oldTitleWidth,
|
|
4902
|
+
width,
|
|
4845
4903
|
workspaceUri
|
|
4846
4904
|
} = state;
|
|
4847
4905
|
const title = getTitle(workspaceUri, titleTemplate, appName);
|
|
@@ -4850,7 +4908,9 @@ const setTitleTemplate = async (state, titleTemplate) => {
|
|
|
4850
4908
|
...state,
|
|
4851
4909
|
title,
|
|
4852
4910
|
titleTemplate,
|
|
4853
|
-
titleWidth
|
|
4911
|
+
titleWidth,
|
|
4912
|
+
// The title is centered, so half its width change becomes available to the menu.
|
|
4913
|
+
width: width + (oldTitleWidth - titleWidth) / 2
|
|
4854
4914
|
};
|
|
4855
4915
|
};
|
|
4856
4916
|
|