@lvce-editor/status-bar-worker 3.33.1 → 3.35.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/statusBarWorkerMain.js +165 -188
- package/package.json +1 -1
|
@@ -331,175 +331,13 @@ const Status = 'status';
|
|
|
331
331
|
|
|
332
332
|
const MaskIcon = 'MaskIcon';
|
|
333
333
|
|
|
334
|
-
const Audio = 0;
|
|
335
334
|
const Button$1 = 1;
|
|
336
|
-
const Col = 2;
|
|
337
|
-
const ColGroup = 3;
|
|
338
335
|
const Div = 4;
|
|
339
|
-
const H1 = 5;
|
|
340
|
-
const Input = 6;
|
|
341
|
-
const Kbd = 7;
|
|
342
336
|
const Span = 8;
|
|
343
|
-
const Table = 9;
|
|
344
|
-
const TBody = 10;
|
|
345
|
-
const Td = 11;
|
|
346
337
|
const Text = 12;
|
|
347
|
-
const
|
|
348
|
-
const THead = 14;
|
|
349
|
-
const Tr = 15;
|
|
350
|
-
const I = 16;
|
|
351
|
-
const Img = 17;
|
|
352
|
-
const Root = 0;
|
|
353
|
-
const Ins = 20;
|
|
354
|
-
const Del = 21;
|
|
355
|
-
const H2 = 22;
|
|
356
|
-
const H3 = 23;
|
|
357
|
-
const H4 = 24;
|
|
358
|
-
const H5 = 25;
|
|
359
|
-
const H6 = 26;
|
|
360
|
-
const Article = 27;
|
|
361
|
-
const Aside = 28;
|
|
362
|
-
const Footer = 29;
|
|
363
|
-
const Header = 30;
|
|
364
|
-
const Nav = 40;
|
|
365
|
-
const Section = 41;
|
|
366
|
-
const Search = 42;
|
|
367
|
-
const Dd = 43;
|
|
368
|
-
const Dl = 44;
|
|
369
|
-
const Figcaption = 45;
|
|
370
|
-
const Figure = 46;
|
|
371
|
-
const Hr = 47;
|
|
372
|
-
const Li = 48;
|
|
373
|
-
const Ol = 49;
|
|
374
|
-
const P = 50;
|
|
375
|
-
const Pre = 51;
|
|
376
|
-
const A = 53;
|
|
377
|
-
const Abbr = 54;
|
|
378
|
-
const Br = 55;
|
|
379
|
-
const Cite = 56;
|
|
380
|
-
const Data = 57;
|
|
381
|
-
const Time = 58;
|
|
382
|
-
const Tfoot = 59;
|
|
383
|
-
const Ul = 60;
|
|
384
|
-
const Video = 61;
|
|
385
|
-
const TextArea = 62;
|
|
386
|
-
const Select = 63;
|
|
387
|
-
const Option = 64;
|
|
388
|
-
const Code = 65;
|
|
389
|
-
const Label = 66;
|
|
390
|
-
const Dt = 67;
|
|
391
|
-
const Iframe = 68;
|
|
392
|
-
const Main = 69;
|
|
393
|
-
const Strong = 70;
|
|
394
|
-
const Em = 71;
|
|
395
|
-
const Style = 72;
|
|
396
|
-
const Html = 73;
|
|
397
|
-
const Head = 74;
|
|
398
|
-
const Title = 75;
|
|
399
|
-
const Meta = 76;
|
|
400
|
-
const Canvas = 77;
|
|
401
|
-
const Form = 78;
|
|
402
|
-
const BlockQuote = 79;
|
|
403
|
-
const Quote = 80;
|
|
404
|
-
const Circle = 81;
|
|
405
|
-
const Defs = 82;
|
|
406
|
-
const Ellipse = 83;
|
|
407
|
-
const G = 84;
|
|
408
|
-
const Line = 85;
|
|
409
|
-
const Path = 86;
|
|
410
|
-
const Polygon = 87;
|
|
411
|
-
const Polyline = 88;
|
|
412
|
-
const Rect = 89;
|
|
413
|
-
const Svg = 90;
|
|
414
|
-
const Use = 91;
|
|
338
|
+
const Progress = 92;
|
|
415
339
|
const Reference = 100;
|
|
416
340
|
|
|
417
|
-
const VirtualDomElements = {
|
|
418
|
-
__proto__: null,
|
|
419
|
-
A,
|
|
420
|
-
Abbr,
|
|
421
|
-
Article,
|
|
422
|
-
Aside,
|
|
423
|
-
Audio,
|
|
424
|
-
BlockQuote,
|
|
425
|
-
Br,
|
|
426
|
-
Button: Button$1,
|
|
427
|
-
Canvas,
|
|
428
|
-
Circle,
|
|
429
|
-
Cite,
|
|
430
|
-
Code,
|
|
431
|
-
Col,
|
|
432
|
-
ColGroup,
|
|
433
|
-
Data,
|
|
434
|
-
Dd,
|
|
435
|
-
Defs,
|
|
436
|
-
Del,
|
|
437
|
-
Div,
|
|
438
|
-
Dl,
|
|
439
|
-
Dt,
|
|
440
|
-
Ellipse,
|
|
441
|
-
Em,
|
|
442
|
-
Figcaption,
|
|
443
|
-
Figure,
|
|
444
|
-
Footer,
|
|
445
|
-
Form,
|
|
446
|
-
G,
|
|
447
|
-
H1,
|
|
448
|
-
H2,
|
|
449
|
-
H3,
|
|
450
|
-
H4,
|
|
451
|
-
H5,
|
|
452
|
-
H6,
|
|
453
|
-
Head,
|
|
454
|
-
Header,
|
|
455
|
-
Hr,
|
|
456
|
-
Html,
|
|
457
|
-
I,
|
|
458
|
-
Iframe,
|
|
459
|
-
Img,
|
|
460
|
-
Input,
|
|
461
|
-
Ins,
|
|
462
|
-
Kbd,
|
|
463
|
-
Label,
|
|
464
|
-
Li,
|
|
465
|
-
Line,
|
|
466
|
-
Main,
|
|
467
|
-
Meta,
|
|
468
|
-
Nav,
|
|
469
|
-
Ol,
|
|
470
|
-
Option,
|
|
471
|
-
P,
|
|
472
|
-
Path,
|
|
473
|
-
Polygon,
|
|
474
|
-
Polyline,
|
|
475
|
-
Pre,
|
|
476
|
-
Quote,
|
|
477
|
-
Rect,
|
|
478
|
-
Reference,
|
|
479
|
-
Root,
|
|
480
|
-
Search,
|
|
481
|
-
Section,
|
|
482
|
-
Select,
|
|
483
|
-
Span,
|
|
484
|
-
Strong,
|
|
485
|
-
Style,
|
|
486
|
-
Svg,
|
|
487
|
-
TBody,
|
|
488
|
-
THead,
|
|
489
|
-
Table,
|
|
490
|
-
Td,
|
|
491
|
-
Text,
|
|
492
|
-
TextArea,
|
|
493
|
-
Tfoot,
|
|
494
|
-
Th,
|
|
495
|
-
Time,
|
|
496
|
-
Title,
|
|
497
|
-
Tr,
|
|
498
|
-
Ul,
|
|
499
|
-
Use,
|
|
500
|
-
Video
|
|
501
|
-
};
|
|
502
|
-
|
|
503
341
|
const Button = 'event.button';
|
|
504
342
|
const ClientX = 'event.clientX';
|
|
505
343
|
const ClientY = 'event.clientY';
|
|
@@ -526,8 +364,6 @@ const text = data => {
|
|
|
526
364
|
};
|
|
527
365
|
};
|
|
528
366
|
|
|
529
|
-
new Set(Object.values(VirtualDomElements));
|
|
530
|
-
|
|
531
367
|
const SetText = 1;
|
|
532
368
|
const Replace = 2;
|
|
533
369
|
const SetAttribute = 3;
|
|
@@ -538,6 +374,7 @@ const NavigateParent = 8;
|
|
|
538
374
|
const RemoveChild = 9;
|
|
539
375
|
const NavigateSibling = 10;
|
|
540
376
|
const SetReferenceNodeUid = 11;
|
|
377
|
+
const MultiNavigation = 18;
|
|
541
378
|
|
|
542
379
|
const isKey = key => {
|
|
543
380
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -598,6 +435,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
598
435
|
};
|
|
599
436
|
};
|
|
600
437
|
|
|
438
|
+
const isNavigationPatch = patch => {
|
|
439
|
+
switch (patch.type) {
|
|
440
|
+
case NavigateChild:
|
|
441
|
+
case NavigateParent:
|
|
442
|
+
case NavigateSibling:
|
|
443
|
+
return true;
|
|
444
|
+
default:
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
const getNavigationIndex = patch => {
|
|
449
|
+
switch (patch.type) {
|
|
450
|
+
case NavigateChild:
|
|
451
|
+
case NavigateSibling:
|
|
452
|
+
return patch.index;
|
|
453
|
+
default:
|
|
454
|
+
return 0;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const appendNavigationPatch = (patches, type, index) => {
|
|
458
|
+
const previousPatch = patches.at(-1);
|
|
459
|
+
if (!previousPatch) {
|
|
460
|
+
patches.push(type === NavigateParent ? {
|
|
461
|
+
type
|
|
462
|
+
} : {
|
|
463
|
+
index,
|
|
464
|
+
type
|
|
465
|
+
});
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (previousPatch.type === MultiNavigation) {
|
|
469
|
+
previousPatch.navigations.push(type, index);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (isNavigationPatch(previousPatch)) {
|
|
473
|
+
patches[patches.length - 1] = {
|
|
474
|
+
navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
|
|
475
|
+
type: MultiNavigation
|
|
476
|
+
};
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
patches.push(type === NavigateParent ? {
|
|
480
|
+
type
|
|
481
|
+
} : {
|
|
482
|
+
index,
|
|
483
|
+
type
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
|
|
601
487
|
const compareNodes = (oldNode, newNode) => {
|
|
602
488
|
// Check if node type changed - return null to signal incompatible nodes
|
|
603
489
|
// (caller should handle this with a Replace operation)
|
|
@@ -662,25 +548,17 @@ const treeToArray = node => {
|
|
|
662
548
|
|
|
663
549
|
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
664
550
|
if (currentChildIndex === -1) {
|
|
665
|
-
patches
|
|
666
|
-
type: NavigateChild,
|
|
667
|
-
index
|
|
668
|
-
});
|
|
551
|
+
appendNavigationPatch(patches, NavigateChild, index);
|
|
669
552
|
return index;
|
|
670
553
|
}
|
|
671
554
|
if (currentChildIndex !== index) {
|
|
672
|
-
patches
|
|
673
|
-
type: NavigateSibling,
|
|
674
|
-
index
|
|
675
|
-
});
|
|
555
|
+
appendNavigationPatch(patches, NavigateSibling, index);
|
|
676
556
|
}
|
|
677
557
|
return index;
|
|
678
558
|
};
|
|
679
559
|
const navigateToParent = (patches, currentChildIndex) => {
|
|
680
560
|
if (currentChildIndex >= 0) {
|
|
681
|
-
patches
|
|
682
|
-
type: NavigateParent
|
|
683
|
-
});
|
|
561
|
+
appendNavigationPatch(patches, NavigateParent, 0);
|
|
684
562
|
}
|
|
685
563
|
return -1;
|
|
686
564
|
};
|
|
@@ -696,6 +574,29 @@ const replaceTree = (newNode, patches) => {
|
|
|
696
574
|
nodes: treeToArray(newNode)
|
|
697
575
|
});
|
|
698
576
|
};
|
|
577
|
+
const appendPatch = (patches, patch) => {
|
|
578
|
+
switch (patch.type) {
|
|
579
|
+
case MultiNavigation:
|
|
580
|
+
for (let i = 0; i < patch.navigations.length; i += 2) {
|
|
581
|
+
appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
|
|
582
|
+
}
|
|
583
|
+
return;
|
|
584
|
+
case NavigateChild:
|
|
585
|
+
case NavigateSibling:
|
|
586
|
+
appendNavigationPatch(patches, patch.type, patch.index);
|
|
587
|
+
return;
|
|
588
|
+
case NavigateParent:
|
|
589
|
+
appendNavigationPatch(patches, patch.type, 0);
|
|
590
|
+
return;
|
|
591
|
+
default:
|
|
592
|
+
patches.push(patch);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const appendPatches = (patches, newPatches) => {
|
|
596
|
+
for (const patch of newPatches) {
|
|
597
|
+
appendPatch(patches, patch);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
699
600
|
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
700
601
|
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
701
602
|
if (nodePatches === null) {
|
|
@@ -704,16 +605,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
|
|
|
704
605
|
return nextChildIndex;
|
|
705
606
|
}
|
|
706
607
|
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
707
|
-
|
|
608
|
+
const childPatches = [];
|
|
609
|
+
if (hasChildrenToCompare) {
|
|
610
|
+
diffChildren(oldNode.children, newNode.children, childPatches);
|
|
611
|
+
}
|
|
612
|
+
if (nodePatches.length === 0 && childPatches.length === 0) {
|
|
708
613
|
return currentChildIndex;
|
|
709
614
|
}
|
|
710
615
|
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
if (hasChildrenToCompare) {
|
|
715
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
716
|
-
}
|
|
616
|
+
patches.push(...nodePatches);
|
|
617
|
+
appendPatches(patches, childPatches);
|
|
717
618
|
return nextChildIndex;
|
|
718
619
|
};
|
|
719
620
|
const diffRootNode = (oldNode, newNode, patches) => {
|
|
@@ -769,7 +670,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
|
|
|
769
670
|
const removeTrailingNavigationPatches = patches => {
|
|
770
671
|
while (patches.length > 0) {
|
|
771
672
|
const patch = patches.at(-1);
|
|
772
|
-
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
673
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
|
|
773
674
|
break;
|
|
774
675
|
}
|
|
775
676
|
patches.pop();
|
|
@@ -813,6 +714,22 @@ const getIconVirtualDom = (element, name) => {
|
|
|
813
714
|
type: Div
|
|
814
715
|
}];
|
|
815
716
|
};
|
|
717
|
+
const getProgressVirtualDom = (element, name) => {
|
|
718
|
+
const node = {
|
|
719
|
+
ariaLabel: element.ariaLabel,
|
|
720
|
+
className: 'StatusBarItemProgress',
|
|
721
|
+
max: element.max,
|
|
722
|
+
name,
|
|
723
|
+
type: Progress
|
|
724
|
+
};
|
|
725
|
+
if (element.value !== undefined) {
|
|
726
|
+
return [{
|
|
727
|
+
...node,
|
|
728
|
+
value: element.value
|
|
729
|
+
}];
|
|
730
|
+
}
|
|
731
|
+
return [node];
|
|
732
|
+
};
|
|
816
733
|
const getStatusBarItemElementVirtualDom = (element, name) => {
|
|
817
734
|
if (element.type === 'text') {
|
|
818
735
|
return getTextVirtualDom(element, name);
|
|
@@ -820,6 +737,9 @@ const getStatusBarItemElementVirtualDom = (element, name) => {
|
|
|
820
737
|
if (element.type === 'icon') {
|
|
821
738
|
return getIconVirtualDom(element, name);
|
|
822
739
|
}
|
|
740
|
+
if (element.type === 'progress') {
|
|
741
|
+
return getProgressVirtualDom(element, name);
|
|
742
|
+
}
|
|
823
743
|
return [];
|
|
824
744
|
};
|
|
825
745
|
|
|
@@ -1944,6 +1864,9 @@ const logError = () => {
|
|
|
1944
1864
|
// handled by renderer worker
|
|
1945
1865
|
};
|
|
1946
1866
|
const handleMessage = event => {
|
|
1867
|
+
if (event.data === 'ready') {
|
|
1868
|
+
return Promise.resolve();
|
|
1869
|
+
}
|
|
1947
1870
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1948
1871
|
const actualExecute = event?.target?.execute || execute;
|
|
1949
1872
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
@@ -2515,6 +2438,7 @@ const fontSize = 12;
|
|
|
2515
2438
|
const fontFamily = 'system-ui, Ubuntu, Droid Sans, sans-serif';
|
|
2516
2439
|
const itemPaddingAndMargin = 16;
|
|
2517
2440
|
const iconWidth = 20;
|
|
2441
|
+
const progressWidth = 69;
|
|
2518
2442
|
const horizontalGroupPadding = 14;
|
|
2519
2443
|
const measuredWidths = new WeakMap();
|
|
2520
2444
|
const fallbackTextWidth = 150;
|
|
@@ -2528,6 +2452,16 @@ const measureTextWidths = async values => {
|
|
|
2528
2452
|
return values.map(() => fallbackTextWidth);
|
|
2529
2453
|
}
|
|
2530
2454
|
};
|
|
2455
|
+
const getElementWidth = (element, textWidths, textIndex) => {
|
|
2456
|
+
switch (element.type) {
|
|
2457
|
+
case 'icon':
|
|
2458
|
+
return iconWidth;
|
|
2459
|
+
case 'progress':
|
|
2460
|
+
return progressWidth;
|
|
2461
|
+
case 'text':
|
|
2462
|
+
return textWidths[textIndex];
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2531
2465
|
const getItemWidths = async items => {
|
|
2532
2466
|
const unmeasuredItems = [...new Set(items.filter(item => !measuredWidths.has(item)))];
|
|
2533
2467
|
const textElements = unmeasuredItems.flatMap(item => item.elements.filter(element => element.type === 'text'));
|
|
@@ -2536,10 +2470,8 @@ const getItemWidths = async items => {
|
|
|
2536
2470
|
for (const item of unmeasuredItems) {
|
|
2537
2471
|
let itemWidth = itemPaddingAndMargin;
|
|
2538
2472
|
for (const element of item.elements) {
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
} else {
|
|
2542
|
-
itemWidth += textWidths[textIndex];
|
|
2473
|
+
itemWidth += getElementWidth(element, textWidths, textIndex);
|
|
2474
|
+
if (element.type === 'text') {
|
|
2543
2475
|
textIndex++;
|
|
2544
2476
|
}
|
|
2545
2477
|
}
|
|
@@ -3082,6 +3014,50 @@ const handleProblemsSummaryChange = (state, summary) => {
|
|
|
3082
3014
|
};
|
|
3083
3015
|
};
|
|
3084
3016
|
|
|
3017
|
+
const itemName = 'update-progress';
|
|
3018
|
+
const handleUpdateProgress = (state, progress) => {
|
|
3019
|
+
const {
|
|
3020
|
+
statusBarItemsLeft
|
|
3021
|
+
} = state;
|
|
3022
|
+
const updatedStatusBarItems = statusBarItemsLeft.filter(item => item.name !== itemName);
|
|
3023
|
+
if (progress === null) {
|
|
3024
|
+
return {
|
|
3025
|
+
...state,
|
|
3026
|
+
statusBarItemsLeft: updatedStatusBarItems
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
3029
|
+
const value = progress === undefined ? undefined : Math.max(0, Math.min(1, progress));
|
|
3030
|
+
const percentage = value === undefined ? undefined : Math.round(value * 100);
|
|
3031
|
+
const ariaLabel = percentage === undefined ? 'Update download progress' : `Update download progress ${percentage}%`;
|
|
3032
|
+
const progressElement = {
|
|
3033
|
+
ariaLabel: 'Update download progress',
|
|
3034
|
+
max: 1,
|
|
3035
|
+
type: 'progress'
|
|
3036
|
+
};
|
|
3037
|
+
const elements = [{
|
|
3038
|
+
type: 'text',
|
|
3039
|
+
value: 'Update'
|
|
3040
|
+
}];
|
|
3041
|
+
if (value === undefined) {
|
|
3042
|
+
elements.push(progressElement);
|
|
3043
|
+
} else {
|
|
3044
|
+
elements.push({
|
|
3045
|
+
...progressElement,
|
|
3046
|
+
value
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
const item = {
|
|
3050
|
+
ariaLabel,
|
|
3051
|
+
elements,
|
|
3052
|
+
name: itemName,
|
|
3053
|
+
tooltip: ariaLabel
|
|
3054
|
+
};
|
|
3055
|
+
return {
|
|
3056
|
+
...state,
|
|
3057
|
+
statusBarItemsLeft: [...updatedStatusBarItems, item]
|
|
3058
|
+
};
|
|
3059
|
+
};
|
|
3060
|
+
|
|
3085
3061
|
const handleWorkspaceChange = async state => {
|
|
3086
3062
|
const {
|
|
3087
3063
|
assetDir,
|
|
@@ -3295,6 +3271,7 @@ const commandMap = {
|
|
|
3295
3271
|
'StatusBar.handleMessagePort': handleDirectMessagePort,
|
|
3296
3272
|
'StatusBar.handleNotificationCountChanged': wrapCommand(handleNotificationCountChanged),
|
|
3297
3273
|
'StatusBar.handleProblemsSummaryChange': wrapCommand(handleProblemsSummaryChange),
|
|
3274
|
+
'StatusBar.handleUpdateProgress': wrapCommand(handleUpdateProgress),
|
|
3298
3275
|
'StatusBar.handleWorkspaceChange': handleWorkspaceChangeAndRefresh,
|
|
3299
3276
|
'StatusBar.initialize': initialize,
|
|
3300
3277
|
'StatusBar.itemLeftUpdate': wrapCommand(itemLeftUpdate),
|