@lvce-editor/activity-bar-worker 7.9.0 → 7.9.3
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/activityBarWorkerMain.js +382 -49
- package/package.json +1 -1
|
@@ -3,10 +3,67 @@ const toCommandId = key => {
|
|
|
3
3
|
return key.slice(dotIndex + 1);
|
|
4
4
|
};
|
|
5
5
|
const create$a = () => {
|
|
6
|
+
const commandQueues = new Map();
|
|
7
|
+
const generations = Object.create(null);
|
|
6
8
|
const states = Object.create(null);
|
|
7
9
|
const commandMapRef = {};
|
|
10
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
11
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
12
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
13
|
+
};
|
|
14
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
15
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
16
|
+
return Promise.resolve(fallbackState);
|
|
17
|
+
}
|
|
18
|
+
const current = states[uid];
|
|
19
|
+
const updatedState = updater(current.newState);
|
|
20
|
+
if (updatedState !== current.newState) {
|
|
21
|
+
states[uid] = {
|
|
22
|
+
newState: updatedState,
|
|
23
|
+
oldState: current.oldState,
|
|
24
|
+
scheduledState: updatedState
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return Promise.resolve(updatedState);
|
|
28
|
+
};
|
|
29
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
30
|
+
let latestState = states[uid].newState;
|
|
31
|
+
return {
|
|
32
|
+
getState: () => {
|
|
33
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
+
latestState = states[uid].newState;
|
|
35
|
+
}
|
|
36
|
+
return latestState;
|
|
37
|
+
},
|
|
38
|
+
updateState: async updater => {
|
|
39
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
+
return latestState;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const enqueueCommand = async (uid, command) => {
|
|
45
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
46
|
+
const run = async () => {
|
|
47
|
+
try {
|
|
48
|
+
await previous;
|
|
49
|
+
} catch {
|
|
50
|
+
// The previous caller receives its error; later commands must still run.
|
|
51
|
+
}
|
|
52
|
+
await command();
|
|
53
|
+
};
|
|
54
|
+
const current = run();
|
|
55
|
+
commandQueues.set(uid, current);
|
|
56
|
+
try {
|
|
57
|
+
await current;
|
|
58
|
+
} finally {
|
|
59
|
+
if (commandQueues.get(uid) === current) {
|
|
60
|
+
commandQueues.delete(uid);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
8
64
|
return {
|
|
9
65
|
clear() {
|
|
66
|
+
commandQueues.clear();
|
|
10
67
|
for (const key of Object.keys(states)) {
|
|
11
68
|
delete states[key];
|
|
12
69
|
}
|
|
@@ -26,6 +83,7 @@ const create$a = () => {
|
|
|
26
83
|
return diffResult;
|
|
27
84
|
},
|
|
28
85
|
dispose(uid) {
|
|
86
|
+
commandQueues.delete(uid);
|
|
29
87
|
delete states[uid];
|
|
30
88
|
},
|
|
31
89
|
get(uid) {
|
|
@@ -43,14 +101,27 @@ const create$a = () => {
|
|
|
43
101
|
Object.assign(commandMapRef, commandMap);
|
|
44
102
|
},
|
|
45
103
|
set(uid, oldState, newState, scheduledState) {
|
|
104
|
+
const current = states[uid];
|
|
105
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
+
}
|
|
46
108
|
states[uid] = {
|
|
47
109
|
newState,
|
|
48
110
|
oldState,
|
|
49
111
|
scheduledState: scheduledState ?? newState
|
|
50
112
|
};
|
|
51
113
|
},
|
|
114
|
+
wrapAsyncCommand(fn) {
|
|
115
|
+
const wrapped = async (uid, ...args) => {
|
|
116
|
+
const generation = getGeneration(uid);
|
|
117
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
118
|
+
await fn(context, ...args);
|
|
119
|
+
};
|
|
120
|
+
return wrapped;
|
|
121
|
+
},
|
|
52
122
|
wrapCommand(fn) {
|
|
53
123
|
const wrapped = async (uid, ...args) => {
|
|
124
|
+
const generation = getGeneration(uid);
|
|
54
125
|
const {
|
|
55
126
|
newState,
|
|
56
127
|
oldState
|
|
@@ -59,6 +130,9 @@ const create$a = () => {
|
|
|
59
130
|
if (oldState === newerState || newState === newerState) {
|
|
60
131
|
return;
|
|
61
132
|
}
|
|
133
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
62
136
|
const latestOld = states[uid];
|
|
63
137
|
const latestNew = {
|
|
64
138
|
...latestOld.newState,
|
|
@@ -83,6 +157,7 @@ const create$a = () => {
|
|
|
83
157
|
},
|
|
84
158
|
wrapLoadContent(fn) {
|
|
85
159
|
const wrapped = async (uid, ...args) => {
|
|
160
|
+
const generation = getGeneration(uid);
|
|
86
161
|
const {
|
|
87
162
|
newState,
|
|
88
163
|
oldState
|
|
@@ -97,6 +172,11 @@ const create$a = () => {
|
|
|
97
172
|
error
|
|
98
173
|
};
|
|
99
174
|
}
|
|
175
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
+
return {
|
|
177
|
+
error
|
|
178
|
+
};
|
|
179
|
+
}
|
|
100
180
|
const latestOld = states[uid];
|
|
101
181
|
const latestNew = {
|
|
102
182
|
...latestOld.newState,
|
|
@@ -112,6 +192,51 @@ const create$a = () => {
|
|
|
112
192
|
};
|
|
113
193
|
};
|
|
114
194
|
return wrapped;
|
|
195
|
+
},
|
|
196
|
+
wrapSerialAsyncCommand(fn) {
|
|
197
|
+
const wrapped = async (uid, ...args) => {
|
|
198
|
+
await enqueueCommand(uid, async () => {
|
|
199
|
+
if (!states[uid]) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const generation = getGeneration(uid);
|
|
203
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
+
await fn(context, ...args);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return wrapped;
|
|
208
|
+
},
|
|
209
|
+
wrapSerialCommand(fn) {
|
|
210
|
+
const wrapped = async (uid, ...args) => {
|
|
211
|
+
await enqueueCommand(uid, async () => {
|
|
212
|
+
if (!states[uid]) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const generation = getGeneration(uid);
|
|
216
|
+
const {
|
|
217
|
+
newState,
|
|
218
|
+
oldState
|
|
219
|
+
} = states[uid];
|
|
220
|
+
const newerState = await fn(newState, ...args);
|
|
221
|
+
if (oldState === newerState || newState === newerState) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const latestOld = states[uid];
|
|
228
|
+
const latestNew = {
|
|
229
|
+
...latestOld.newState,
|
|
230
|
+
...newerState
|
|
231
|
+
};
|
|
232
|
+
states[uid] = {
|
|
233
|
+
newState: latestNew,
|
|
234
|
+
oldState: latestOld.oldState,
|
|
235
|
+
scheduledState: latestNew
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
return wrapped;
|
|
115
240
|
}
|
|
116
241
|
};
|
|
117
242
|
};
|
|
@@ -241,15 +366,180 @@ const focusNone = state => {
|
|
|
241
366
|
return focusIndex(state, -1);
|
|
242
367
|
};
|
|
243
368
|
|
|
244
|
-
const Button$
|
|
369
|
+
const Button$3 = 'button';
|
|
245
370
|
const None$1 = 'none';
|
|
246
371
|
const Tab$1 = 'tab';
|
|
247
372
|
const ToolBar = 'toolbar';
|
|
248
373
|
|
|
374
|
+
const Audio = 0;
|
|
375
|
+
const Button$2 = 1;
|
|
376
|
+
const Col = 2;
|
|
377
|
+
const ColGroup = 3;
|
|
249
378
|
const Div = 4;
|
|
379
|
+
const H1 = 5;
|
|
380
|
+
const Input = 6;
|
|
381
|
+
const Kbd = 7;
|
|
382
|
+
const Span = 8;
|
|
383
|
+
const Table = 9;
|
|
384
|
+
const TBody = 10;
|
|
385
|
+
const Td = 11;
|
|
250
386
|
const Text = 12;
|
|
387
|
+
const Th = 13;
|
|
388
|
+
const THead = 14;
|
|
389
|
+
const Tr = 15;
|
|
390
|
+
const I = 16;
|
|
391
|
+
const Img = 17;
|
|
392
|
+
const Root = 0;
|
|
393
|
+
const Ins = 20;
|
|
394
|
+
const Del = 21;
|
|
395
|
+
const H2 = 22;
|
|
396
|
+
const H3 = 23;
|
|
397
|
+
const H4 = 24;
|
|
398
|
+
const H5 = 25;
|
|
399
|
+
const H6 = 26;
|
|
400
|
+
const Article = 27;
|
|
401
|
+
const Aside = 28;
|
|
402
|
+
const Footer = 29;
|
|
403
|
+
const Header = 30;
|
|
404
|
+
const Nav = 40;
|
|
405
|
+
const Section = 41;
|
|
406
|
+
const Search$3 = 42;
|
|
407
|
+
const Dd = 43;
|
|
408
|
+
const Dl = 44;
|
|
409
|
+
const Figcaption = 45;
|
|
410
|
+
const Figure = 46;
|
|
411
|
+
const Hr = 47;
|
|
412
|
+
const Li = 48;
|
|
413
|
+
const Ol = 49;
|
|
414
|
+
const P = 50;
|
|
415
|
+
const Pre = 51;
|
|
416
|
+
const A = 53;
|
|
417
|
+
const Abbr = 54;
|
|
418
|
+
const Br = 55;
|
|
419
|
+
const Cite = 56;
|
|
420
|
+
const Data = 57;
|
|
421
|
+
const Time = 58;
|
|
422
|
+
const Tfoot = 59;
|
|
423
|
+
const Ul = 60;
|
|
424
|
+
const Video = 61;
|
|
425
|
+
const TextArea = 62;
|
|
426
|
+
const Select = 63;
|
|
427
|
+
const Option = 64;
|
|
428
|
+
const Code = 65;
|
|
429
|
+
const Label = 66;
|
|
430
|
+
const Dt = 67;
|
|
431
|
+
const Iframe = 68;
|
|
432
|
+
const Main = 69;
|
|
433
|
+
const Strong = 70;
|
|
434
|
+
const Em = 71;
|
|
435
|
+
const Style = 72;
|
|
436
|
+
const Html = 73;
|
|
437
|
+
const Head = 74;
|
|
438
|
+
const Title = 75;
|
|
439
|
+
const Meta = 76;
|
|
440
|
+
const Canvas = 77;
|
|
441
|
+
const Form = 78;
|
|
442
|
+
const BlockQuote = 79;
|
|
443
|
+
const Quote = 80;
|
|
444
|
+
const Circle = 81;
|
|
445
|
+
const Defs = 82;
|
|
446
|
+
const Ellipse = 83;
|
|
447
|
+
const G = 84;
|
|
448
|
+
const Line = 85;
|
|
449
|
+
const Path = 86;
|
|
450
|
+
const Polygon = 87;
|
|
451
|
+
const Polyline = 88;
|
|
452
|
+
const Rect = 89;
|
|
453
|
+
const Svg = 90;
|
|
454
|
+
const Use = 91;
|
|
251
455
|
const Reference = 100;
|
|
252
456
|
|
|
457
|
+
const VirtualDomElements = {
|
|
458
|
+
__proto__: null,
|
|
459
|
+
A,
|
|
460
|
+
Abbr,
|
|
461
|
+
Article,
|
|
462
|
+
Aside,
|
|
463
|
+
Audio,
|
|
464
|
+
BlockQuote,
|
|
465
|
+
Br,
|
|
466
|
+
Button: Button$2,
|
|
467
|
+
Canvas,
|
|
468
|
+
Circle,
|
|
469
|
+
Cite,
|
|
470
|
+
Code,
|
|
471
|
+
Col,
|
|
472
|
+
ColGroup,
|
|
473
|
+
Data,
|
|
474
|
+
Dd,
|
|
475
|
+
Defs,
|
|
476
|
+
Del,
|
|
477
|
+
Div,
|
|
478
|
+
Dl,
|
|
479
|
+
Dt,
|
|
480
|
+
Ellipse,
|
|
481
|
+
Em,
|
|
482
|
+
Figcaption,
|
|
483
|
+
Figure,
|
|
484
|
+
Footer,
|
|
485
|
+
Form,
|
|
486
|
+
G,
|
|
487
|
+
H1,
|
|
488
|
+
H2,
|
|
489
|
+
H3,
|
|
490
|
+
H4,
|
|
491
|
+
H5,
|
|
492
|
+
H6,
|
|
493
|
+
Head,
|
|
494
|
+
Header,
|
|
495
|
+
Hr,
|
|
496
|
+
Html,
|
|
497
|
+
I,
|
|
498
|
+
Iframe,
|
|
499
|
+
Img,
|
|
500
|
+
Input,
|
|
501
|
+
Ins,
|
|
502
|
+
Kbd,
|
|
503
|
+
Label,
|
|
504
|
+
Li,
|
|
505
|
+
Line,
|
|
506
|
+
Main,
|
|
507
|
+
Meta,
|
|
508
|
+
Nav,
|
|
509
|
+
Ol,
|
|
510
|
+
Option,
|
|
511
|
+
P,
|
|
512
|
+
Path,
|
|
513
|
+
Polygon,
|
|
514
|
+
Polyline,
|
|
515
|
+
Pre,
|
|
516
|
+
Quote,
|
|
517
|
+
Rect,
|
|
518
|
+
Reference,
|
|
519
|
+
Root,
|
|
520
|
+
Search: Search$3,
|
|
521
|
+
Section,
|
|
522
|
+
Select,
|
|
523
|
+
Span,
|
|
524
|
+
Strong,
|
|
525
|
+
Style,
|
|
526
|
+
Svg,
|
|
527
|
+
TBody,
|
|
528
|
+
THead,
|
|
529
|
+
Table,
|
|
530
|
+
Td,
|
|
531
|
+
Text,
|
|
532
|
+
TextArea,
|
|
533
|
+
Tfoot,
|
|
534
|
+
Th,
|
|
535
|
+
Time,
|
|
536
|
+
Title,
|
|
537
|
+
Tr,
|
|
538
|
+
Ul,
|
|
539
|
+
Use,
|
|
540
|
+
Video
|
|
541
|
+
};
|
|
542
|
+
|
|
253
543
|
const Button$1 = 'event.button';
|
|
254
544
|
const ClientX = 'event.clientX';
|
|
255
545
|
const ClientY = 'event.clientY';
|
|
@@ -330,8 +620,12 @@ const getKeyBindings = () => {
|
|
|
330
620
|
|
|
331
621
|
const ACCOUNT_SUBMENU_ID = 32_123;
|
|
332
622
|
const getAccountLabel = state => {
|
|
333
|
-
const
|
|
334
|
-
|
|
623
|
+
const {
|
|
624
|
+
userLoginProvider,
|
|
625
|
+
userName
|
|
626
|
+
} = state;
|
|
627
|
+
const name = userName || 'Account';
|
|
628
|
+
const provider = userLoginProvider || 'GitHub';
|
|
335
629
|
return `${name} (${provider})`;
|
|
336
630
|
};
|
|
337
631
|
const getMenuEntriesAccountLoggedIn = state => {
|
|
@@ -389,15 +683,15 @@ const Focused = 1 << 5;
|
|
|
389
683
|
const MarginTop = 1 << 6;
|
|
390
684
|
|
|
391
685
|
const emptyObject = {};
|
|
392
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
393
686
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
394
687
|
if (placeholders === emptyObject) {
|
|
395
688
|
return key;
|
|
396
689
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
690
|
+
let result = key;
|
|
691
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
692
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
693
|
+
}
|
|
694
|
+
return result;
|
|
401
695
|
};
|
|
402
696
|
|
|
403
697
|
const Account$1 = 'Account';
|
|
@@ -533,8 +827,11 @@ const getNumberOfVisibleItems = state => {
|
|
|
533
827
|
return numberOfVisibleItemsTop;
|
|
534
828
|
};
|
|
535
829
|
const getHiddenItems = state => {
|
|
830
|
+
const {
|
|
831
|
+
activityBarItems
|
|
832
|
+
} = state;
|
|
536
833
|
const numberOfVisibleItems = getNumberOfVisibleItems(state);
|
|
537
|
-
const items =
|
|
834
|
+
const items = activityBarItems.filter(item => item.flags & Enabled);
|
|
538
835
|
if (numberOfVisibleItems >= items.length) {
|
|
539
836
|
return [];
|
|
540
837
|
}
|
|
@@ -735,7 +1032,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
735
1032
|
for (const property of Object.values(value)) {
|
|
736
1033
|
walkValue(property, transferrables, isTransferrable);
|
|
737
1034
|
}
|
|
738
|
-
return;
|
|
739
1035
|
}
|
|
740
1036
|
};
|
|
741
1037
|
const getTransferrables = value => {
|
|
@@ -889,7 +1185,14 @@ class IpcError extends VError {
|
|
|
889
1185
|
const cause = new Error(message);
|
|
890
1186
|
// @ts-ignore
|
|
891
1187
|
cause.code = code;
|
|
892
|
-
|
|
1188
|
+
if (stack) {
|
|
1189
|
+
Object.defineProperty(cause, 'stack', {
|
|
1190
|
+
configurable: true,
|
|
1191
|
+
enumerable: false,
|
|
1192
|
+
value: stack,
|
|
1193
|
+
writable: true
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
893
1196
|
super(cause, betterMessage);
|
|
894
1197
|
} else {
|
|
895
1198
|
super(betterMessage);
|
|
@@ -1826,8 +2129,11 @@ const updateItemsWithBadgeCount = async items => {
|
|
|
1826
2129
|
};
|
|
1827
2130
|
|
|
1828
2131
|
const updateStateItems = (state, activityBarItems) => {
|
|
2132
|
+
const {
|
|
2133
|
+
filteredItems: currentFilteredItems
|
|
2134
|
+
} = state;
|
|
1829
2135
|
const itemById = new Map(activityBarItems.map(item => [item.id, item]));
|
|
1830
|
-
const filteredItems =
|
|
2136
|
+
const filteredItems = currentFilteredItems.map(item => itemById.get(item.id) || item);
|
|
1831
2137
|
return {
|
|
1832
2138
|
...state,
|
|
1833
2139
|
activityBarItems,
|
|
@@ -1835,7 +2141,10 @@ const updateStateItems = (state, activityBarItems) => {
|
|
|
1835
2141
|
};
|
|
1836
2142
|
};
|
|
1837
2143
|
const applyBadgeCountChanges = (state, badgeCounts) => {
|
|
1838
|
-
const
|
|
2144
|
+
const {
|
|
2145
|
+
activityBarItems: currentActivityBarItems
|
|
2146
|
+
} = state;
|
|
2147
|
+
const activityBarItems = currentActivityBarItems.map(item => {
|
|
1839
2148
|
if (!Object.hasOwn(badgeCounts, item.id)) {
|
|
1840
2149
|
return item;
|
|
1841
2150
|
}
|
|
@@ -1851,8 +2160,11 @@ const handleBadgeCountChange = async (state, badgeCounts) => {
|
|
|
1851
2160
|
if (badgeCounts) {
|
|
1852
2161
|
return applyBadgeCountChanges(state, badgeCounts);
|
|
1853
2162
|
}
|
|
1854
|
-
const
|
|
1855
|
-
|
|
2163
|
+
const {
|
|
2164
|
+
activityBarItems
|
|
2165
|
+
} = state;
|
|
2166
|
+
const newActivityBarItems = await updateItemsWithBadgeCount(activityBarItems);
|
|
2167
|
+
if (newActivityBarItems === activityBarItems) {
|
|
1856
2168
|
return state;
|
|
1857
2169
|
}
|
|
1858
2170
|
return updateStateItems(state, newActivityBarItems);
|
|
@@ -1958,24 +2270,6 @@ const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
|
1958
2270
|
return [...enabledItems.slice(0, numberOfVisibleItems - 2), showMoreItem, enabledItems.at(-1)];
|
|
1959
2271
|
};
|
|
1960
2272
|
|
|
1961
|
-
const setFlag = (item, flag, enabled) => {
|
|
1962
|
-
return {
|
|
1963
|
-
...item,
|
|
1964
|
-
flags: enabled ? item.flags | flag : item.flags & ~flag
|
|
1965
|
-
};
|
|
1966
|
-
};
|
|
1967
|
-
|
|
1968
|
-
const markSelected = (items, selectedIndex) => {
|
|
1969
|
-
return items.map((item, index) => {
|
|
1970
|
-
const isSelected = index === selectedIndex;
|
|
1971
|
-
return setFlag(item, Selected, isSelected);
|
|
1972
|
-
});
|
|
1973
|
-
};
|
|
1974
|
-
|
|
1975
|
-
const toggle = async id => {
|
|
1976
|
-
await invoke('Layout.toggleSideBarView', id);
|
|
1977
|
-
};
|
|
1978
|
-
|
|
1979
2273
|
const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
|
|
1980
2274
|
if (sideBarVisible) {
|
|
1981
2275
|
if (currentViewletId === viewletId) {
|
|
@@ -1994,6 +2288,25 @@ const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
|
|
|
1994
2288
|
viewletId
|
|
1995
2289
|
};
|
|
1996
2290
|
};
|
|
2291
|
+
|
|
2292
|
+
const setFlag = (item, flag, enabled) => {
|
|
2293
|
+
return {
|
|
2294
|
+
...item,
|
|
2295
|
+
flags: enabled ? item.flags | flag : item.flags & ~flag
|
|
2296
|
+
};
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2299
|
+
const markSelected = (items, selectedIndex) => {
|
|
2300
|
+
return items.map((item, index) => {
|
|
2301
|
+
const isSelected = index === selectedIndex;
|
|
2302
|
+
return setFlag(item, Selected, isSelected);
|
|
2303
|
+
});
|
|
2304
|
+
};
|
|
2305
|
+
|
|
2306
|
+
const toggle = async id => {
|
|
2307
|
+
await invoke('Layout.toggleSideBarView', id);
|
|
2308
|
+
};
|
|
2309
|
+
|
|
1997
2310
|
const handleClickOther = async (state, viewletId) => {
|
|
1998
2311
|
const {
|
|
1999
2312
|
activityBarItems,
|
|
@@ -2066,7 +2379,10 @@ const getIndexFromTarget = (state, targetName) => {
|
|
|
2066
2379
|
if (!targetName) {
|
|
2067
2380
|
return -1;
|
|
2068
2381
|
}
|
|
2069
|
-
|
|
2382
|
+
const {
|
|
2383
|
+
filteredItems
|
|
2384
|
+
} = state;
|
|
2385
|
+
return filteredItems.findIndex(item => item.id === targetName);
|
|
2070
2386
|
};
|
|
2071
2387
|
const handleClick = async (state, button, eventX, eventY, targetName = '') => {
|
|
2072
2388
|
const {
|
|
@@ -2124,7 +2440,7 @@ const getCustomIconClass = (id, iconUrl) => {
|
|
|
2124
2440
|
};
|
|
2125
2441
|
|
|
2126
2442
|
const isCustomIconUrl = icon => {
|
|
2127
|
-
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
|
|
2443
|
+
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('lvce://') || icon.startsWith('/');
|
|
2128
2444
|
};
|
|
2129
2445
|
|
|
2130
2446
|
const Explorer = 'Explorer';
|
|
@@ -2214,7 +2530,11 @@ const getActivityBarItems = (state, contributedViews = []) => {
|
|
|
2214
2530
|
|
|
2215
2531
|
const getContributedViews = async platform => {
|
|
2216
2532
|
try {
|
|
2217
|
-
|
|
2533
|
+
const views = await invoke$1('Extensions.getViews', '', platform);
|
|
2534
|
+
if (!Array.isArray(views)) {
|
|
2535
|
+
return [];
|
|
2536
|
+
}
|
|
2537
|
+
return views.filter(view => view?.type !== 'preview');
|
|
2218
2538
|
} catch {
|
|
2219
2539
|
return [];
|
|
2220
2540
|
}
|
|
@@ -2224,9 +2544,10 @@ const handleExtensionsChanged = async state => {
|
|
|
2224
2544
|
const {
|
|
2225
2545
|
height,
|
|
2226
2546
|
itemHeight,
|
|
2547
|
+
platform,
|
|
2227
2548
|
selectedIndex
|
|
2228
2549
|
} = state;
|
|
2229
|
-
const contributedViews = await getContributedViews(
|
|
2550
|
+
const contributedViews = await getContributedViews(platform);
|
|
2230
2551
|
const items = getActivityBarItems(state, contributedViews);
|
|
2231
2552
|
const itemsWithSelected = markSelected(items, selectedIndex);
|
|
2232
2553
|
const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
|
|
@@ -2286,11 +2607,13 @@ const getSideBarPosition = async () => {
|
|
|
2286
2607
|
|
|
2287
2608
|
const handleSettingsChanged = async state => {
|
|
2288
2609
|
const {
|
|
2610
|
+
accountEnabled: currentAccountEnabled,
|
|
2289
2611
|
height,
|
|
2290
2612
|
itemHeight,
|
|
2613
|
+
platform,
|
|
2291
2614
|
selectedIndex
|
|
2292
2615
|
} = state;
|
|
2293
|
-
const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(
|
|
2616
|
+
const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(currentAccountEnabled), getContributedViews(platform), getSideBarPosition()]);
|
|
2294
2617
|
const newState = {
|
|
2295
2618
|
...state,
|
|
2296
2619
|
accountEnabled
|
|
@@ -2320,12 +2643,14 @@ const clearItem = item => {
|
|
|
2320
2643
|
const withoutSelected = setFlag(item, Selected, false);
|
|
2321
2644
|
return setFlag(withoutSelected, Focused, false);
|
|
2322
2645
|
};
|
|
2323
|
-
const handleSideBarStateChange = async (state, id
|
|
2646
|
+
const handleSideBarStateChange = async (state, id, sideBarVisibleOverride) => {
|
|
2324
2647
|
const {
|
|
2325
2648
|
activityBarItems,
|
|
2649
|
+
currentViewletId,
|
|
2326
2650
|
height,
|
|
2327
2651
|
itemHeight
|
|
2328
2652
|
} = state;
|
|
2653
|
+
const resolvedId = id === undefined ? currentViewletId : id;
|
|
2329
2654
|
const sideBarVisible = typeof sideBarVisibleOverride === 'boolean' ? sideBarVisibleOverride : await getSideBarVisible();
|
|
2330
2655
|
if (!sideBarVisible) {
|
|
2331
2656
|
const itemsCleared = activityBarItems.map(clearItem);
|
|
@@ -2339,13 +2664,13 @@ const handleSideBarStateChange = async (state, id = state.currentViewletId, side
|
|
|
2339
2664
|
sideBarVisible: false
|
|
2340
2665
|
};
|
|
2341
2666
|
}
|
|
2342
|
-
const selectedIndex = findIndex(activityBarItems,
|
|
2667
|
+
const selectedIndex = findIndex(activityBarItems, resolvedId);
|
|
2343
2668
|
const newActivityBarItems = markSelected(activityBarItems, selectedIndex);
|
|
2344
2669
|
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
2345
2670
|
return {
|
|
2346
2671
|
...state,
|
|
2347
2672
|
activityBarItems: newActivityBarItems,
|
|
2348
|
-
currentViewletId:
|
|
2673
|
+
currentViewletId: resolvedId,
|
|
2349
2674
|
filteredItems,
|
|
2350
2675
|
selectedIndex,
|
|
2351
2676
|
sideBarVisible
|
|
@@ -2566,6 +2891,8 @@ const text = data => {
|
|
|
2566
2891
|
};
|
|
2567
2892
|
};
|
|
2568
2893
|
|
|
2894
|
+
new Set(Object.values(VirtualDomElements));
|
|
2895
|
+
|
|
2569
2896
|
const SetText = 1;
|
|
2570
2897
|
const Replace = 2;
|
|
2571
2898
|
const SetAttribute = 3;
|
|
@@ -2905,7 +3232,7 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2905
3232
|
const isTab = flags & Tab;
|
|
2906
3233
|
const isSelected = flags & Selected;
|
|
2907
3234
|
const isFocused = flags & Focused;
|
|
2908
|
-
const role = isTab ? Tab$1 : Button$
|
|
3235
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2909
3236
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2910
3237
|
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2911
3238
|
const marginTop = flags & MarginTop;
|
|
@@ -2913,7 +3240,6 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2913
3240
|
className += ' ' + ActivityBarItemNested;
|
|
2914
3241
|
return [{
|
|
2915
3242
|
ariaHasPopup,
|
|
2916
|
-
ariaLabel: '',
|
|
2917
3243
|
ariaSelected,
|
|
2918
3244
|
childCount: 2,
|
|
2919
3245
|
className,
|
|
@@ -2942,7 +3268,7 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2942
3268
|
const isTab = flags & Tab;
|
|
2943
3269
|
const isSelected = flags & Selected;
|
|
2944
3270
|
const isFocused = flags & Focused;
|
|
2945
|
-
const role = isTab ? Tab$1 : Button$
|
|
3271
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2946
3272
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2947
3273
|
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2948
3274
|
const marginTop = flags & MarginTop;
|
|
@@ -2950,7 +3276,6 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2950
3276
|
className += ' ' + ActivityBarItemNested;
|
|
2951
3277
|
return [{
|
|
2952
3278
|
ariaHasPopup,
|
|
2953
|
-
ariaLabel: '',
|
|
2954
3279
|
ariaSelected,
|
|
2955
3280
|
childCount: 2,
|
|
2956
3281
|
className,
|
|
@@ -2994,14 +3319,13 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2994
3319
|
const isSelected = flags & Selected;
|
|
2995
3320
|
const isFocused = flags & Focused;
|
|
2996
3321
|
const isProgress = flags & Progress;
|
|
2997
|
-
const role = isTab ? Tab$1 : Button$
|
|
3322
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2998
3323
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2999
3324
|
const marginTop = flags & MarginTop;
|
|
3000
3325
|
const className = getClassName(isFocused, marginTop, isSelected);
|
|
3001
3326
|
if (isSelected && !badgeText) {
|
|
3002
3327
|
return [{
|
|
3003
3328
|
ariaHasPopup,
|
|
3004
|
-
ariaLabel: '',
|
|
3005
3329
|
ariaSelected,
|
|
3006
3330
|
childCount: 1,
|
|
3007
3331
|
className,
|
|
@@ -3024,7 +3348,6 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
3024
3348
|
}
|
|
3025
3349
|
return [{
|
|
3026
3350
|
ariaHasPopup,
|
|
3027
|
-
ariaLabel: '',
|
|
3028
3351
|
ariaSelected,
|
|
3029
3352
|
childCount: 0,
|
|
3030
3353
|
className: mergeClassNames(className, getIconClass(item, 'Icon')),
|
|
@@ -3040,6 +3363,8 @@ const getVirtualDom = visibleItems => {
|
|
|
3040
3363
|
return dom;
|
|
3041
3364
|
};
|
|
3042
3365
|
|
|
3366
|
+
const Focusable = 0;
|
|
3367
|
+
|
|
3043
3368
|
const className = mergeClassNames(Viewlet, ActivityBar$1);
|
|
3044
3369
|
const getActivityBarVirtualDom = visibleItems => {
|
|
3045
3370
|
return [{
|
|
@@ -3053,7 +3378,7 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
3053
3378
|
onFocus: HandleFocus,
|
|
3054
3379
|
onMouseDown: HandleMouseDown,
|
|
3055
3380
|
role: ToolBar,
|
|
3056
|
-
tabIndex:
|
|
3381
|
+
tabIndex: Focusable,
|
|
3057
3382
|
type: Div
|
|
3058
3383
|
}, ...getVirtualDom(visibleItems)];
|
|
3059
3384
|
};
|
|
@@ -3071,7 +3396,15 @@ const renderItems = (oldState, newState) => {
|
|
|
3071
3396
|
return [SetDom2, uid, dom];
|
|
3072
3397
|
};
|
|
3073
3398
|
|
|
3399
|
+
const hasSameItemIds = (oldState, newState) => {
|
|
3400
|
+
const oldItems = oldState.filteredItems;
|
|
3401
|
+
const newItems = newState.filteredItems;
|
|
3402
|
+
return oldItems.length === newItems.length && oldItems.every((item, index) => item.id === newItems[index].id);
|
|
3403
|
+
};
|
|
3074
3404
|
const renderIncremental = (oldState, newState) => {
|
|
3405
|
+
if (!hasSameItemIds(oldState, newState)) {
|
|
3406
|
+
return renderItems(oldState, newState);
|
|
3407
|
+
}
|
|
3075
3408
|
const oldDom = renderItems(oldState, oldState)[2];
|
|
3076
3409
|
const newDom = renderItems(newState, newState)[2];
|
|
3077
3410
|
const patches = diffTree(oldDom, newDom);
|