@lvce-editor/activity-bar-worker 7.9.0 → 7.9.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/activityBarWorkerMain.js +315 -13
- 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';
|
|
@@ -389,15 +679,15 @@ const Focused = 1 << 5;
|
|
|
389
679
|
const MarginTop = 1 << 6;
|
|
390
680
|
|
|
391
681
|
const emptyObject = {};
|
|
392
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
393
682
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
394
683
|
if (placeholders === emptyObject) {
|
|
395
684
|
return key;
|
|
396
685
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
686
|
+
let result = key;
|
|
687
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
688
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
689
|
+
}
|
|
690
|
+
return result;
|
|
401
691
|
};
|
|
402
692
|
|
|
403
693
|
const Account$1 = 'Account';
|
|
@@ -735,7 +1025,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
735
1025
|
for (const property of Object.values(value)) {
|
|
736
1026
|
walkValue(property, transferrables, isTransferrable);
|
|
737
1027
|
}
|
|
738
|
-
return;
|
|
739
1028
|
}
|
|
740
1029
|
};
|
|
741
1030
|
const getTransferrables = value => {
|
|
@@ -889,7 +1178,14 @@ class IpcError extends VError {
|
|
|
889
1178
|
const cause = new Error(message);
|
|
890
1179
|
// @ts-ignore
|
|
891
1180
|
cause.code = code;
|
|
892
|
-
|
|
1181
|
+
if (stack) {
|
|
1182
|
+
Object.defineProperty(cause, 'stack', {
|
|
1183
|
+
configurable: true,
|
|
1184
|
+
enumerable: false,
|
|
1185
|
+
value: stack,
|
|
1186
|
+
writable: true
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
893
1189
|
super(cause, betterMessage);
|
|
894
1190
|
} else {
|
|
895
1191
|
super(betterMessage);
|
|
@@ -2124,7 +2420,7 @@ const getCustomIconClass = (id, iconUrl) => {
|
|
|
2124
2420
|
};
|
|
2125
2421
|
|
|
2126
2422
|
const isCustomIconUrl = icon => {
|
|
2127
|
-
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
|
|
2423
|
+
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('lvce://') || icon.startsWith('/');
|
|
2128
2424
|
};
|
|
2129
2425
|
|
|
2130
2426
|
const Explorer = 'Explorer';
|
|
@@ -2214,7 +2510,11 @@ const getActivityBarItems = (state, contributedViews = []) => {
|
|
|
2214
2510
|
|
|
2215
2511
|
const getContributedViews = async platform => {
|
|
2216
2512
|
try {
|
|
2217
|
-
|
|
2513
|
+
const views = await invoke$1('Extensions.getViews', '', platform);
|
|
2514
|
+
if (!Array.isArray(views)) {
|
|
2515
|
+
return [];
|
|
2516
|
+
}
|
|
2517
|
+
return views.filter(view => view?.type !== 'preview');
|
|
2218
2518
|
} catch {
|
|
2219
2519
|
return [];
|
|
2220
2520
|
}
|
|
@@ -2566,6 +2866,8 @@ const text = data => {
|
|
|
2566
2866
|
};
|
|
2567
2867
|
};
|
|
2568
2868
|
|
|
2869
|
+
new Set(Object.values(VirtualDomElements));
|
|
2870
|
+
|
|
2569
2871
|
const SetText = 1;
|
|
2570
2872
|
const Replace = 2;
|
|
2571
2873
|
const SetAttribute = 3;
|
|
@@ -2905,7 +3207,7 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2905
3207
|
const isTab = flags & Tab;
|
|
2906
3208
|
const isSelected = flags & Selected;
|
|
2907
3209
|
const isFocused = flags & Focused;
|
|
2908
|
-
const role = isTab ? Tab$1 : Button$
|
|
3210
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2909
3211
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2910
3212
|
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2911
3213
|
const marginTop = flags & MarginTop;
|
|
@@ -2942,7 +3244,7 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2942
3244
|
const isTab = flags & Tab;
|
|
2943
3245
|
const isSelected = flags & Selected;
|
|
2944
3246
|
const isFocused = flags & Focused;
|
|
2945
|
-
const role = isTab ? Tab$1 : Button$
|
|
3247
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2946
3248
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2947
3249
|
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2948
3250
|
const marginTop = flags & MarginTop;
|
|
@@ -2994,7 +3296,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2994
3296
|
const isSelected = flags & Selected;
|
|
2995
3297
|
const isFocused = flags & Focused;
|
|
2996
3298
|
const isProgress = flags & Progress;
|
|
2997
|
-
const role = isTab ? Tab$1 : Button$
|
|
3299
|
+
const role = isTab ? Tab$1 : Button$3;
|
|
2998
3300
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2999
3301
|
const marginTop = flags & MarginTop;
|
|
3000
3302
|
const className = getClassName(isFocused, marginTop, isSelected);
|