@lvce-editor/title-bar-worker 4.7.0 → 4.8.1
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 +411 -59
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ class AssertionError extends Error {
|
|
|
63
63
|
const Object$1 = 1;
|
|
64
64
|
const Number$1 = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
|
-
const String = 4;
|
|
66
|
+
const String$1 = 4;
|
|
67
67
|
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
@@ -75,7 +75,7 @@ const getType = value => {
|
|
|
75
75
|
case 'function':
|
|
76
76
|
return Function;
|
|
77
77
|
case 'string':
|
|
78
|
-
return String;
|
|
78
|
+
return String$1;
|
|
79
79
|
case 'object':
|
|
80
80
|
if (value === null) {
|
|
81
81
|
return Null;
|
|
@@ -151,7 +151,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
151
151
|
for (const property of Object.values(value)) {
|
|
152
152
|
walkValue(property, transferrables, isTransferrable);
|
|
153
153
|
}
|
|
154
|
-
return;
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
156
|
const getTransferrables = value => {
|
|
@@ -305,7 +304,14 @@ class IpcError extends VError {
|
|
|
305
304
|
const cause = new Error(message);
|
|
306
305
|
// @ts-ignore
|
|
307
306
|
cause.code = code;
|
|
308
|
-
|
|
307
|
+
if (stack) {
|
|
308
|
+
Object.defineProperty(cause, 'stack', {
|
|
309
|
+
configurable: true,
|
|
310
|
+
enumerable: false,
|
|
311
|
+
value: stack,
|
|
312
|
+
writable: true
|
|
313
|
+
});
|
|
314
|
+
}
|
|
309
315
|
super(cause, betterMessage);
|
|
310
316
|
} else {
|
|
311
317
|
super(betterMessage);
|
|
@@ -609,8 +615,10 @@ const getCurrentStack = () => {
|
|
|
609
615
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
610
616
|
return currentStack;
|
|
611
617
|
};
|
|
612
|
-
const getNewLineIndex = (string, startIndex
|
|
613
|
-
|
|
618
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
619
|
+
{
|
|
620
|
+
return string.indexOf(NewLine);
|
|
621
|
+
}
|
|
614
622
|
};
|
|
615
623
|
const getParentStack = error => {
|
|
616
624
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -621,55 +629,77 @@ const getParentStack = error => {
|
|
|
621
629
|
};
|
|
622
630
|
const MethodNotFound = -32601;
|
|
623
631
|
const Custom = -32001;
|
|
632
|
+
const restoreExistingError = (error, currentStack) => {
|
|
633
|
+
if (typeof error.stack === 'string') {
|
|
634
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
635
|
+
}
|
|
636
|
+
return error;
|
|
637
|
+
};
|
|
638
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
639
|
+
const restoredError = new JsonRpcError(error.message);
|
|
640
|
+
const parentStack = getParentStack(error);
|
|
641
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
642
|
+
return restoredError;
|
|
643
|
+
};
|
|
644
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
645
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
646
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
if (error.data.stack) {
|
|
650
|
+
restoredError.stack = error.data.stack;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
const applyDataProperties = (restoredError, error) => {
|
|
654
|
+
if (!error.data) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
658
|
+
if (error.data.codeFrame) {
|
|
659
|
+
// @ts-ignore
|
|
660
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
661
|
+
}
|
|
662
|
+
if (error.data.code) {
|
|
663
|
+
// @ts-ignore
|
|
664
|
+
restoredError.code = error.data.code;
|
|
665
|
+
}
|
|
666
|
+
if (error.data.type) {
|
|
667
|
+
// @ts-ignore
|
|
668
|
+
restoredError.name = error.data.type;
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
672
|
+
if (error.stack) {
|
|
673
|
+
const lowerStack = restoredError.stack || '';
|
|
674
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
675
|
+
const parentStack = getParentStack(error);
|
|
676
|
+
// @ts-ignore
|
|
677
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
678
|
+
}
|
|
679
|
+
if (error.codeFrame) {
|
|
680
|
+
// @ts-ignore
|
|
681
|
+
restoredError.codeFrame = error.codeFrame;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
685
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
686
|
+
if (error.data) {
|
|
687
|
+
applyDataProperties(restoredError, error);
|
|
688
|
+
} else {
|
|
689
|
+
applyDirectProperties(restoredError, error);
|
|
690
|
+
}
|
|
691
|
+
return restoredError;
|
|
692
|
+
};
|
|
624
693
|
const restoreJsonRpcError = error => {
|
|
625
694
|
const currentStack = getCurrentStack();
|
|
626
695
|
if (error && error instanceof Error) {
|
|
627
|
-
|
|
628
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
629
|
-
}
|
|
630
|
-
return error;
|
|
696
|
+
return restoreExistingError(error, currentStack);
|
|
631
697
|
}
|
|
632
698
|
if (error && error.code && error.code === MethodNotFound) {
|
|
633
|
-
|
|
634
|
-
const parentStack = getParentStack(error);
|
|
635
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
636
|
-
return restoredError;
|
|
699
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
637
700
|
}
|
|
638
701
|
if (error && error.message) {
|
|
639
|
-
|
|
640
|
-
if (error.data) {
|
|
641
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
642
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
643
|
-
} else if (error.data.stack) {
|
|
644
|
-
restoredError.stack = error.data.stack;
|
|
645
|
-
}
|
|
646
|
-
if (error.data.codeFrame) {
|
|
647
|
-
// @ts-ignore
|
|
648
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
649
|
-
}
|
|
650
|
-
if (error.data.code) {
|
|
651
|
-
// @ts-ignore
|
|
652
|
-
restoredError.code = error.data.code;
|
|
653
|
-
}
|
|
654
|
-
if (error.data.type) {
|
|
655
|
-
// @ts-ignore
|
|
656
|
-
restoredError.name = error.data.type;
|
|
657
|
-
}
|
|
658
|
-
} else {
|
|
659
|
-
if (error.stack) {
|
|
660
|
-
const lowerStack = restoredError.stack || '';
|
|
661
|
-
// @ts-ignore
|
|
662
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
663
|
-
const parentStack = getParentStack(error);
|
|
664
|
-
// @ts-ignore
|
|
665
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
666
|
-
}
|
|
667
|
-
if (error.codeFrame) {
|
|
668
|
-
// @ts-ignore
|
|
669
|
-
restoredError.codeFrame = error.codeFrame;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
return restoredError;
|
|
702
|
+
return restoreMessageError(error);
|
|
673
703
|
}
|
|
674
704
|
if (typeof error === 'string') {
|
|
675
705
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -1095,12 +1125,174 @@ const MenuItemCheckBox = 'menuitemcheckbox';
|
|
|
1095
1125
|
const None$1 = 'none';
|
|
1096
1126
|
const Separator$2 = 'separator';
|
|
1097
1127
|
|
|
1128
|
+
const Audio = 0;
|
|
1098
1129
|
const Button$1 = 1;
|
|
1130
|
+
const Col = 2;
|
|
1131
|
+
const ColGroup = 3;
|
|
1099
1132
|
const Div = 4;
|
|
1133
|
+
const H1 = 5;
|
|
1134
|
+
const Input = 6;
|
|
1135
|
+
const Kbd = 7;
|
|
1100
1136
|
const Span = 8;
|
|
1137
|
+
const Table = 9;
|
|
1138
|
+
const TBody = 10;
|
|
1139
|
+
const Td = 11;
|
|
1101
1140
|
const Text = 12;
|
|
1141
|
+
const Th = 13;
|
|
1142
|
+
const THead = 14;
|
|
1143
|
+
const Tr = 15;
|
|
1102
1144
|
const I = 16;
|
|
1103
1145
|
const Img = 17;
|
|
1146
|
+
const Root = 0;
|
|
1147
|
+
const Ins = 20;
|
|
1148
|
+
const Del = 21;
|
|
1149
|
+
const H2 = 22;
|
|
1150
|
+
const H3 = 23;
|
|
1151
|
+
const H4 = 24;
|
|
1152
|
+
const H5 = 25;
|
|
1153
|
+
const H6 = 26;
|
|
1154
|
+
const Article = 27;
|
|
1155
|
+
const Aside = 28;
|
|
1156
|
+
const Footer = 29;
|
|
1157
|
+
const Header = 30;
|
|
1158
|
+
const Nav = 40;
|
|
1159
|
+
const Section = 41;
|
|
1160
|
+
const Search$1 = 42;
|
|
1161
|
+
const Dd = 43;
|
|
1162
|
+
const Dl = 44;
|
|
1163
|
+
const Figcaption = 45;
|
|
1164
|
+
const Figure = 46;
|
|
1165
|
+
const Hr = 47;
|
|
1166
|
+
const Li = 48;
|
|
1167
|
+
const Ol = 49;
|
|
1168
|
+
const P = 50;
|
|
1169
|
+
const Pre = 51;
|
|
1170
|
+
const A = 53;
|
|
1171
|
+
const Abbr = 54;
|
|
1172
|
+
const Br = 55;
|
|
1173
|
+
const Cite = 56;
|
|
1174
|
+
const Data = 57;
|
|
1175
|
+
const Time = 58;
|
|
1176
|
+
const Tfoot = 59;
|
|
1177
|
+
const Ul = 60;
|
|
1178
|
+
const Video = 61;
|
|
1179
|
+
const TextArea = 62;
|
|
1180
|
+
const Select = 63;
|
|
1181
|
+
const Option = 64;
|
|
1182
|
+
const Code = 65;
|
|
1183
|
+
const Label = 66;
|
|
1184
|
+
const Dt = 67;
|
|
1185
|
+
const Iframe = 68;
|
|
1186
|
+
const Main = 69;
|
|
1187
|
+
const Strong = 70;
|
|
1188
|
+
const Em = 71;
|
|
1189
|
+
const Style = 72;
|
|
1190
|
+
const Html = 73;
|
|
1191
|
+
const Head = 74;
|
|
1192
|
+
const Title = 75;
|
|
1193
|
+
const Meta = 76;
|
|
1194
|
+
const Canvas = 77;
|
|
1195
|
+
const Form = 78;
|
|
1196
|
+
const BlockQuote = 79;
|
|
1197
|
+
const Quote = 80;
|
|
1198
|
+
const Circle = 81;
|
|
1199
|
+
const Defs = 82;
|
|
1200
|
+
const Ellipse = 83;
|
|
1201
|
+
const G = 84;
|
|
1202
|
+
const Line = 85;
|
|
1203
|
+
const Path = 86;
|
|
1204
|
+
const Polygon = 87;
|
|
1205
|
+
const Polyline = 88;
|
|
1206
|
+
const Rect = 89;
|
|
1207
|
+
const Svg = 90;
|
|
1208
|
+
const Use = 91;
|
|
1209
|
+
const Reference = 100;
|
|
1210
|
+
|
|
1211
|
+
const VirtualDomElements = {
|
|
1212
|
+
__proto__: null,
|
|
1213
|
+
A,
|
|
1214
|
+
Abbr,
|
|
1215
|
+
Article,
|
|
1216
|
+
Aside,
|
|
1217
|
+
Audio,
|
|
1218
|
+
BlockQuote,
|
|
1219
|
+
Br,
|
|
1220
|
+
Button: Button$1,
|
|
1221
|
+
Canvas,
|
|
1222
|
+
Circle,
|
|
1223
|
+
Cite,
|
|
1224
|
+
Code,
|
|
1225
|
+
Col,
|
|
1226
|
+
ColGroup,
|
|
1227
|
+
Data,
|
|
1228
|
+
Dd,
|
|
1229
|
+
Defs,
|
|
1230
|
+
Del,
|
|
1231
|
+
Div,
|
|
1232
|
+
Dl,
|
|
1233
|
+
Dt,
|
|
1234
|
+
Ellipse,
|
|
1235
|
+
Em,
|
|
1236
|
+
Figcaption,
|
|
1237
|
+
Figure,
|
|
1238
|
+
Footer,
|
|
1239
|
+
Form,
|
|
1240
|
+
G,
|
|
1241
|
+
H1,
|
|
1242
|
+
H2,
|
|
1243
|
+
H3,
|
|
1244
|
+
H4,
|
|
1245
|
+
H5,
|
|
1246
|
+
H6,
|
|
1247
|
+
Head,
|
|
1248
|
+
Header,
|
|
1249
|
+
Hr,
|
|
1250
|
+
Html,
|
|
1251
|
+
I,
|
|
1252
|
+
Iframe,
|
|
1253
|
+
Img,
|
|
1254
|
+
Input,
|
|
1255
|
+
Ins,
|
|
1256
|
+
Kbd,
|
|
1257
|
+
Label,
|
|
1258
|
+
Li,
|
|
1259
|
+
Line,
|
|
1260
|
+
Main,
|
|
1261
|
+
Meta,
|
|
1262
|
+
Nav,
|
|
1263
|
+
Ol,
|
|
1264
|
+
Option,
|
|
1265
|
+
P,
|
|
1266
|
+
Path,
|
|
1267
|
+
Polygon,
|
|
1268
|
+
Polyline,
|
|
1269
|
+
Pre,
|
|
1270
|
+
Quote,
|
|
1271
|
+
Rect,
|
|
1272
|
+
Reference,
|
|
1273
|
+
Root,
|
|
1274
|
+
Search: Search$1,
|
|
1275
|
+
Section,
|
|
1276
|
+
Select,
|
|
1277
|
+
Span,
|
|
1278
|
+
Strong,
|
|
1279
|
+
Style,
|
|
1280
|
+
Svg,
|
|
1281
|
+
TBody,
|
|
1282
|
+
THead,
|
|
1283
|
+
Table,
|
|
1284
|
+
Td,
|
|
1285
|
+
Text,
|
|
1286
|
+
TextArea,
|
|
1287
|
+
Tfoot,
|
|
1288
|
+
Th,
|
|
1289
|
+
Time,
|
|
1290
|
+
Title,
|
|
1291
|
+
Tr,
|
|
1292
|
+
Ul,
|
|
1293
|
+
Use,
|
|
1294
|
+
Video
|
|
1295
|
+
};
|
|
1104
1296
|
|
|
1105
1297
|
const Button = 'event.button';
|
|
1106
1298
|
const ClientX = 'event.clientX';
|
|
@@ -1381,10 +1573,67 @@ const toCommandId = key => {
|
|
|
1381
1573
|
return key.slice(dotIndex + 1);
|
|
1382
1574
|
};
|
|
1383
1575
|
const create$1 = () => {
|
|
1576
|
+
const commandQueues = new Map();
|
|
1577
|
+
const generations = Object.create(null);
|
|
1384
1578
|
const states = Object.create(null);
|
|
1385
1579
|
const commandMapRef = {};
|
|
1580
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1581
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1582
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1583
|
+
};
|
|
1584
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1585
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1586
|
+
return Promise.resolve(fallbackState);
|
|
1587
|
+
}
|
|
1588
|
+
const current = states[uid];
|
|
1589
|
+
const updatedState = updater(current.newState);
|
|
1590
|
+
if (updatedState !== current.newState) {
|
|
1591
|
+
states[uid] = {
|
|
1592
|
+
newState: updatedState,
|
|
1593
|
+
oldState: current.oldState,
|
|
1594
|
+
scheduledState: updatedState
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
return Promise.resolve(updatedState);
|
|
1598
|
+
};
|
|
1599
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1600
|
+
let latestState = states[uid].newState;
|
|
1601
|
+
return {
|
|
1602
|
+
getState: () => {
|
|
1603
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1604
|
+
latestState = states[uid].newState;
|
|
1605
|
+
}
|
|
1606
|
+
return latestState;
|
|
1607
|
+
},
|
|
1608
|
+
updateState: async updater => {
|
|
1609
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1610
|
+
return latestState;
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
};
|
|
1614
|
+
const enqueueCommand = async (uid, command) => {
|
|
1615
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1616
|
+
const run = async () => {
|
|
1617
|
+
try {
|
|
1618
|
+
await previous;
|
|
1619
|
+
} catch {
|
|
1620
|
+
// The previous caller receives its error; later commands must still run.
|
|
1621
|
+
}
|
|
1622
|
+
await command();
|
|
1623
|
+
};
|
|
1624
|
+
const current = run();
|
|
1625
|
+
commandQueues.set(uid, current);
|
|
1626
|
+
try {
|
|
1627
|
+
await current;
|
|
1628
|
+
} finally {
|
|
1629
|
+
if (commandQueues.get(uid) === current) {
|
|
1630
|
+
commandQueues.delete(uid);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1386
1634
|
return {
|
|
1387
1635
|
clear() {
|
|
1636
|
+
commandQueues.clear();
|
|
1388
1637
|
for (const key of Object.keys(states)) {
|
|
1389
1638
|
delete states[key];
|
|
1390
1639
|
}
|
|
@@ -1404,6 +1653,7 @@ const create$1 = () => {
|
|
|
1404
1653
|
return diffResult;
|
|
1405
1654
|
},
|
|
1406
1655
|
dispose(uid) {
|
|
1656
|
+
commandQueues.delete(uid);
|
|
1407
1657
|
delete states[uid];
|
|
1408
1658
|
},
|
|
1409
1659
|
get(uid) {
|
|
@@ -1421,14 +1671,27 @@ const create$1 = () => {
|
|
|
1421
1671
|
Object.assign(commandMapRef, commandMap);
|
|
1422
1672
|
},
|
|
1423
1673
|
set(uid, oldState, newState, scheduledState) {
|
|
1674
|
+
const current = states[uid];
|
|
1675
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1676
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1677
|
+
}
|
|
1424
1678
|
states[uid] = {
|
|
1425
1679
|
newState,
|
|
1426
1680
|
oldState,
|
|
1427
1681
|
scheduledState: scheduledState ?? newState
|
|
1428
1682
|
};
|
|
1429
1683
|
},
|
|
1684
|
+
wrapAsyncCommand(fn) {
|
|
1685
|
+
const wrapped = async (uid, ...args) => {
|
|
1686
|
+
const generation = getGeneration(uid);
|
|
1687
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1688
|
+
await fn(context, ...args);
|
|
1689
|
+
};
|
|
1690
|
+
return wrapped;
|
|
1691
|
+
},
|
|
1430
1692
|
wrapCommand(fn) {
|
|
1431
1693
|
const wrapped = async (uid, ...args) => {
|
|
1694
|
+
const generation = getGeneration(uid);
|
|
1432
1695
|
const {
|
|
1433
1696
|
newState,
|
|
1434
1697
|
oldState
|
|
@@ -1437,6 +1700,9 @@ const create$1 = () => {
|
|
|
1437
1700
|
if (oldState === newerState || newState === newerState) {
|
|
1438
1701
|
return;
|
|
1439
1702
|
}
|
|
1703
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1704
|
+
return;
|
|
1705
|
+
}
|
|
1440
1706
|
const latestOld = states[uid];
|
|
1441
1707
|
const latestNew = {
|
|
1442
1708
|
...latestOld.newState,
|
|
@@ -1461,6 +1727,7 @@ const create$1 = () => {
|
|
|
1461
1727
|
},
|
|
1462
1728
|
wrapLoadContent(fn) {
|
|
1463
1729
|
const wrapped = async (uid, ...args) => {
|
|
1730
|
+
const generation = getGeneration(uid);
|
|
1464
1731
|
const {
|
|
1465
1732
|
newState,
|
|
1466
1733
|
oldState
|
|
@@ -1475,6 +1742,11 @@ const create$1 = () => {
|
|
|
1475
1742
|
error
|
|
1476
1743
|
};
|
|
1477
1744
|
}
|
|
1745
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1746
|
+
return {
|
|
1747
|
+
error
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1478
1750
|
const latestOld = states[uid];
|
|
1479
1751
|
const latestNew = {
|
|
1480
1752
|
...latestOld.newState,
|
|
@@ -1490,6 +1762,51 @@ const create$1 = () => {
|
|
|
1490
1762
|
};
|
|
1491
1763
|
};
|
|
1492
1764
|
return wrapped;
|
|
1765
|
+
},
|
|
1766
|
+
wrapSerialAsyncCommand(fn) {
|
|
1767
|
+
const wrapped = async (uid, ...args) => {
|
|
1768
|
+
await enqueueCommand(uid, async () => {
|
|
1769
|
+
if (!states[uid]) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
const generation = getGeneration(uid);
|
|
1773
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1774
|
+
await fn(context, ...args);
|
|
1775
|
+
});
|
|
1776
|
+
};
|
|
1777
|
+
return wrapped;
|
|
1778
|
+
},
|
|
1779
|
+
wrapSerialCommand(fn) {
|
|
1780
|
+
const wrapped = async (uid, ...args) => {
|
|
1781
|
+
await enqueueCommand(uid, async () => {
|
|
1782
|
+
if (!states[uid]) {
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
const generation = getGeneration(uid);
|
|
1786
|
+
const {
|
|
1787
|
+
newState,
|
|
1788
|
+
oldState
|
|
1789
|
+
} = states[uid];
|
|
1790
|
+
const newerState = await fn(newState, ...args);
|
|
1791
|
+
if (oldState === newerState || newState === newerState) {
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
const latestOld = states[uid];
|
|
1798
|
+
const latestNew = {
|
|
1799
|
+
...latestOld.newState,
|
|
1800
|
+
...newerState
|
|
1801
|
+
};
|
|
1802
|
+
states[uid] = {
|
|
1803
|
+
newState: latestNew,
|
|
1804
|
+
oldState: latestOld.oldState,
|
|
1805
|
+
scheduledState: latestNew
|
|
1806
|
+
};
|
|
1807
|
+
});
|
|
1808
|
+
};
|
|
1809
|
+
return wrapped;
|
|
1493
1810
|
}
|
|
1494
1811
|
};
|
|
1495
1812
|
};
|
|
@@ -1559,15 +1876,15 @@ const HandleContextMenu = 11;
|
|
|
1559
1876
|
const HandleTitleBarContextMenu = 12;
|
|
1560
1877
|
|
|
1561
1878
|
const emptyObject = {};
|
|
1562
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1563
1879
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
1564
1880
|
if (placeholders === emptyObject) {
|
|
1565
1881
|
return key;
|
|
1566
1882
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1883
|
+
let result = key;
|
|
1884
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
1885
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
1886
|
+
}
|
|
1887
|
+
return result;
|
|
1571
1888
|
};
|
|
1572
1889
|
|
|
1573
1890
|
const About = 'About';
|
|
@@ -1902,6 +2219,15 @@ const menuEntrySeparator = {
|
|
|
1902
2219
|
const notImplementedArgs$1 = [{
|
|
1903
2220
|
message: 'not implemented'
|
|
1904
2221
|
}];
|
|
2222
|
+
const sideBarLeft = 1;
|
|
2223
|
+
const sideBarRight = 2;
|
|
2224
|
+
const getSideBarPosition = async () => {
|
|
2225
|
+
try {
|
|
2226
|
+
return await invoke('Layout.getSideBarPosition');
|
|
2227
|
+
} catch {
|
|
2228
|
+
return sideBarRight;
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
1905
2231
|
const entry = (id, label, keyboardShortCut = '') => {
|
|
1906
2232
|
return {
|
|
1907
2233
|
args: notImplementedArgs$1,
|
|
@@ -1931,14 +2257,16 @@ const commandEntry = (id, label, command, keyboardShortCut = '', flags = None) =
|
|
|
1931
2257
|
label
|
|
1932
2258
|
};
|
|
1933
2259
|
};
|
|
1934
|
-
const getMenuEntries$e =
|
|
2260
|
+
const getMenuEntries$e = async sideBarPosition => {
|
|
2261
|
+
const currentSideBarPosition = sideBarPosition ?? (await getSideBarPosition());
|
|
2262
|
+
const movePrimarySideBarEntry = currentSideBarPosition === sideBarLeft ? commandEntry('movePrimarySideBarRight', 'Move Primary Side Bar Right', 'Layout.moveSideBarRight') : commandEntry('movePrimarySideBarLeft', 'Move Primary Side Bar Left', 'Layout.moveSideBarLeft');
|
|
1935
2263
|
return [{
|
|
1936
2264
|
command: 'Window.toggleFullScreen',
|
|
1937
2265
|
flags: None,
|
|
1938
2266
|
id: 'fullScreen',
|
|
1939
2267
|
keyboardShortCut: 'F11',
|
|
1940
2268
|
label: fullScreen()
|
|
1941
|
-
}, entry('zenMode', 'Zen Mode', 'Ctrl+K Z'), entry('centeredLayout', 'Centered Layout'), menuEntrySeparator, checkedEntry('menuBar', 'Menu Bar'), commandEntry('primarySideBar', 'Primary Side Bar', 'Layout.toggleSideBar', 'Ctrl+B'), commandEntry('secondarySideBar', 'Secondary Side Bar', 'Layout.toggleSecondarySideBar', 'Ctrl+Alt+B'), commandEntry('statusBar', 'Status Bar', 'Layout.toggleStatusBar', '', Checked), commandEntry('panel', 'Panel', 'Layout.togglePanel', 'Ctrl+J', Checked), menuEntrySeparator,
|
|
2269
|
+
}, entry('zenMode', 'Zen Mode', 'Ctrl+K Z'), entry('centeredLayout', 'Centered Layout'), menuEntrySeparator, checkedEntry('menuBar', 'Menu Bar'), commandEntry('primarySideBar', 'Primary Side Bar', 'Layout.toggleSideBar', 'Ctrl+B'), commandEntry('secondarySideBar', 'Secondary Side Bar', 'Layout.toggleSecondarySideBar', 'Ctrl+Alt+B'), commandEntry('statusBar', 'Status Bar', 'Layout.toggleStatusBar', '', Checked), commandEntry('panel', 'Panel', 'Layout.togglePanel', 'Ctrl+J', Checked), menuEntrySeparator, movePrimarySideBarEntry, entry('activityBarPosition', 'Activity Bar Position'), entry('panelPosition', 'Panel Position'), entry('alignPanel', 'Align Panel'), entry('tabBar', 'Tab Bar'), entry('editorActionsPosition', 'Editor Actions Position'), menuEntrySeparator, entry('minimap', 'Minimap'), entry('breadcrumbs', 'Breadcrumbs'), entry('stickyScroll', 'Sticky Scroll'), entry('renderWhitespace', 'Render Whitespace'), checkedEntry('renderControlCharacters', 'Render Control Characters'), menuEntrySeparator, commandEntry('zoomIn', 'Zoom In', 'Window.zoomIn', 'Ctrl+='), commandEntry('zoomOut', 'Zoom Out', 'Window.zoomOut', 'Ctrl+-'), commandEntry('resetZoom', 'Reset Zoom', 'Window.zoomReset', 'Ctrl+NumPad0')];
|
|
1942
2270
|
};
|
|
1943
2271
|
|
|
1944
2272
|
const cut = () => {
|
|
@@ -2131,6 +2459,7 @@ const getMenuEntries$c = () => {
|
|
|
2131
2459
|
*/
|
|
2132
2460
|
const UiStrings = {
|
|
2133
2461
|
AutoSave: 'Auto Save',
|
|
2462
|
+
CloseFolder: 'Close Folder',
|
|
2134
2463
|
Exit: 'Exit',
|
|
2135
2464
|
NewFile: 'New File',
|
|
2136
2465
|
NewWindow: 'New Window',
|
|
@@ -2138,10 +2467,14 @@ const UiStrings = {
|
|
|
2138
2467
|
OpenFolder: 'Open Folder',
|
|
2139
2468
|
OpenRecent: 'Open Recent',
|
|
2140
2469
|
Save: 'Save',
|
|
2141
|
-
SaveAll: 'Save All'
|
|
2470
|
+
SaveAll: 'Save All'
|
|
2471
|
+
};
|
|
2142
2472
|
const autoSave = () => {
|
|
2143
2473
|
return i18nString(UiStrings.AutoSave);
|
|
2144
2474
|
};
|
|
2475
|
+
const closeFolder = () => {
|
|
2476
|
+
return i18nString(UiStrings.CloseFolder);
|
|
2477
|
+
};
|
|
2145
2478
|
const newFile = () => {
|
|
2146
2479
|
return i18nString(UiStrings.NewFile);
|
|
2147
2480
|
};
|
|
@@ -2237,6 +2570,11 @@ const getMenuEntries$b = async (platform, autoSave$1, hasActiveTextEditor = fals
|
|
|
2237
2570
|
flags: isAutoSaveEnabled(autoSaveValue) ? Checked : Unchecked,
|
|
2238
2571
|
id: 'autoSave',
|
|
2239
2572
|
label: autoSave()
|
|
2573
|
+
}, menuEntrySeparator, {
|
|
2574
|
+
command: 'Workspace.close',
|
|
2575
|
+
flags: RestoreFocus,
|
|
2576
|
+
id: 'closeFolder',
|
|
2577
|
+
label: closeFolder()
|
|
2240
2578
|
}];
|
|
2241
2579
|
if (platform === Electron) {
|
|
2242
2580
|
entries.push(menuEntrySeparator, {
|
|
@@ -2276,7 +2614,18 @@ const getMenuEntries$a = () => {
|
|
|
2276
2614
|
flags: SubMenu$1,
|
|
2277
2615
|
id: MenuIdSwitchGroup,
|
|
2278
2616
|
label: 'Switch Group'
|
|
2279
|
-
}, menuEntrySeparator,
|
|
2617
|
+
}, menuEntrySeparator, {
|
|
2618
|
+
command: 'QuickPick.showFile',
|
|
2619
|
+
flags: None,
|
|
2620
|
+
id: 'goToFile',
|
|
2621
|
+
label: 'Go to File...'
|
|
2622
|
+
}, {
|
|
2623
|
+
args: ['workspace-symbol'],
|
|
2624
|
+
command: 'QuickPick.show',
|
|
2625
|
+
flags: None,
|
|
2626
|
+
id: 'goToSymbolInWorkspace',
|
|
2627
|
+
label: 'Go to Symbol in Workspace...'
|
|
2628
|
+
}, menuEntrySeparator, notImplementedEntry('goToSymbolInEditor', 'Go to Symbol in Editor...'), notImplementedEntry('goToDefinition', 'Go to Definition'), notImplementedEntry('goToDeclaration', 'Go to Declaration'), notImplementedEntry('goToTypeDefinition', 'Go to Type Definition'), notImplementedEntry('goToImplementations', 'Go to Implementations'), notImplementedEntry('goToReferences', 'Go to References'), menuEntrySeparator, notImplementedEntry('goToLineColumn', 'Go to Line/Column...'), notImplementedEntry('goToBracket', 'Go to Bracket'), menuEntrySeparator, notImplementedEntry('nextProblem', 'Next Problem'), notImplementedEntry('previousProblem', 'Previous Problem'), menuEntrySeparator, notImplementedEntry('nextChange', 'Next Change'), notImplementedEntry('previousChange', 'Previous Change')];
|
|
2280
2629
|
};
|
|
2281
2630
|
const getMenuEntriesSwitchEditor = () => {
|
|
2282
2631
|
return [notImplementedEntry('nextEditor', 'Next Editor', 'Ctrl+PageDown'), notImplementedEntry('previousEditor', 'Previous Editor', 'Ctrl+PageUp'), menuEntrySeparator, notImplementedEntry('nextUsedEditor', 'Next Used Editor'), notImplementedEntry('previousUsedEditor', 'Previous Used Editor'), menuEntrySeparator, notImplementedEntry('nextEditorInGroup', 'Next Editor in Group', 'Ctrl+K Ctrl+PageDown'), notImplementedEntry('previousEditorInGroup', 'Previous Editor in Group', 'Ctrl+K Ctrl+PageUp'), notImplementedEntry('nextUsedEditorInGroup', 'Next Used Editor in Group'), notImplementedEntry('previousUsedEditorInGroup', 'Previous Used Editor in Group')];
|
|
@@ -2941,6 +3290,8 @@ const text = data => {
|
|
|
2941
3290
|
};
|
|
2942
3291
|
};
|
|
2943
3292
|
|
|
3293
|
+
new Set(Object.values(VirtualDomElements));
|
|
3294
|
+
|
|
2944
3295
|
const getKeyBindings = () => {
|
|
2945
3296
|
return [{
|
|
2946
3297
|
command: 'TitleBar.handleKeyArrowDown',
|
|
@@ -4560,8 +4911,9 @@ const selectIndexNone = async (state, item) => {
|
|
|
4560
4911
|
|
|
4561
4912
|
const selectIndexRestoreFocus = async (state, item) => {
|
|
4562
4913
|
await executeMenuItemCommand(item);
|
|
4914
|
+
const latestState = get(state.uid)?.newState ?? state;
|
|
4563
4915
|
return {
|
|
4564
|
-
...
|
|
4916
|
+
...latestState,
|
|
4565
4917
|
isMenuOpen: false,
|
|
4566
4918
|
menus: []
|
|
4567
4919
|
};
|
|
@@ -4728,7 +5080,7 @@ const toggleMenu = async state => {
|
|
|
4728
5080
|
};
|
|
4729
5081
|
|
|
4730
5082
|
const commandMap = {
|
|
4731
|
-
'TitleBar.closeMenu': closeMenu,
|
|
5083
|
+
'TitleBar.closeMenu': wrapCommand(closeMenu),
|
|
4732
5084
|
'TitleBar.create': create,
|
|
4733
5085
|
'TitleBar.create3': create3,
|
|
4734
5086
|
'TitleBar.diff3': diff3,
|