@lvce-editor/title-bar-worker 4.20.1 → 4.20.2
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 +28 -4
- package/package.json +1 -1
|
@@ -3554,14 +3554,31 @@ const set = rpc => {
|
|
|
3554
3554
|
state.connected = true;
|
|
3555
3555
|
};
|
|
3556
3556
|
|
|
3557
|
+
const commandQueues = new Map();
|
|
3557
3558
|
const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
|
|
3558
3559
|
const executeViewletCommand = async (uid, command, ...args) => {
|
|
3559
3560
|
const fn = viewletCommandMap[`TitleBar.${command}`];
|
|
3560
3561
|
if (typeof fn !== 'function') {
|
|
3561
3562
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
3562
3563
|
}
|
|
3563
|
-
|
|
3564
|
-
|
|
3564
|
+
const previous = commandQueues.get(uid);
|
|
3565
|
+
const {
|
|
3566
|
+
promise: next,
|
|
3567
|
+
resolve
|
|
3568
|
+
} = Promise.withResolvers();
|
|
3569
|
+
commandQueues.set(uid, next);
|
|
3570
|
+
if (previous) {
|
|
3571
|
+
await previous;
|
|
3572
|
+
}
|
|
3573
|
+
try {
|
|
3574
|
+
await fn(uid, ...args);
|
|
3575
|
+
await invoke$1('Viewlet.requestRender', uid);
|
|
3576
|
+
} finally {
|
|
3577
|
+
resolve();
|
|
3578
|
+
if (commandQueues.get(uid) === next) {
|
|
3579
|
+
commandQueues.delete(uid);
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3565
3582
|
};
|
|
3566
3583
|
const rpc = await create$5({
|
|
3567
3584
|
commandMap: {
|
|
@@ -4866,6 +4883,7 @@ const create = (id, uri, x, y, width, height) => {
|
|
|
4866
4883
|
|
|
4867
4884
|
const closeMenu = (state, keepFocus) => {
|
|
4868
4885
|
const {
|
|
4886
|
+
focused,
|
|
4869
4887
|
focusedIndex,
|
|
4870
4888
|
isMenuOpen,
|
|
4871
4889
|
menus
|
|
@@ -4873,12 +4891,14 @@ const closeMenu = (state, keepFocus) => {
|
|
|
4873
4891
|
// TODO send to renderer process
|
|
4874
4892
|
// 1. close menu
|
|
4875
4893
|
// 2. focus top level entry
|
|
4894
|
+
const newFocused = keepFocus ? focused : false;
|
|
4876
4895
|
const newFocusedIndex = keepFocus ? focusedIndex : -1;
|
|
4877
|
-
if (!isMenuOpen && menus.length === 0 && focusedIndex === newFocusedIndex) {
|
|
4896
|
+
if (!isMenuOpen && menus.length === 0 && focused === newFocused && focusedIndex === newFocusedIndex) {
|
|
4878
4897
|
return state;
|
|
4879
4898
|
}
|
|
4880
4899
|
return {
|
|
4881
4900
|
...state,
|
|
4901
|
+
focused: newFocused,
|
|
4882
4902
|
focusedIndex: newFocusedIndex,
|
|
4883
4903
|
isMenuOpen: false,
|
|
4884
4904
|
menus: []
|
|
@@ -4951,7 +4971,11 @@ const handleClick = async (state, button, index) => {
|
|
|
4951
4971
|
if (index === -1) {
|
|
4952
4972
|
return state;
|
|
4953
4973
|
}
|
|
4954
|
-
|
|
4974
|
+
const newState = await toggleIndex(state, index);
|
|
4975
|
+
return {
|
|
4976
|
+
...newState,
|
|
4977
|
+
focused: true
|
|
4978
|
+
};
|
|
4955
4979
|
};
|
|
4956
4980
|
|
|
4957
4981
|
const handleClickAt = async (state, button, eventX, eventY) => {
|