@lvce-editor/status-bar-worker 3.34.0 → 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.
@@ -331,177 +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 Th = 13;
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;
415
338
  const Progress = 92;
416
339
  const Reference = 100;
417
340
 
418
- const VirtualDomElements = {
419
- __proto__: null,
420
- A,
421
- Abbr,
422
- Article,
423
- Aside,
424
- Audio,
425
- BlockQuote,
426
- Br,
427
- Button: Button$1,
428
- Canvas,
429
- Circle,
430
- Cite,
431
- Code,
432
- Col,
433
- ColGroup,
434
- Data,
435
- Dd,
436
- Defs,
437
- Del,
438
- Div,
439
- Dl,
440
- Dt,
441
- Ellipse,
442
- Em,
443
- Figcaption,
444
- Figure,
445
- Footer,
446
- Form,
447
- G,
448
- H1,
449
- H2,
450
- H3,
451
- H4,
452
- H5,
453
- H6,
454
- Head,
455
- Header,
456
- Hr,
457
- Html,
458
- I,
459
- Iframe,
460
- Img,
461
- Input,
462
- Ins,
463
- Kbd,
464
- Label,
465
- Li,
466
- Line,
467
- Main,
468
- Meta,
469
- Nav,
470
- Ol,
471
- Option,
472
- P,
473
- Path,
474
- Polygon,
475
- Polyline,
476
- Pre,
477
- Progress,
478
- Quote,
479
- Rect,
480
- Reference,
481
- Root,
482
- Search,
483
- Section,
484
- Select,
485
- Span,
486
- Strong,
487
- Style,
488
- Svg,
489
- TBody,
490
- THead,
491
- Table,
492
- Td,
493
- Text,
494
- TextArea,
495
- Tfoot,
496
- Th,
497
- Time,
498
- Title,
499
- Tr,
500
- Ul,
501
- Use,
502
- Video
503
- };
504
-
505
341
  const Button = 'event.button';
506
342
  const ClientX = 'event.clientX';
507
343
  const ClientY = 'event.clientY';
@@ -528,8 +364,6 @@ const text = data => {
528
364
  };
529
365
  };
530
366
 
531
- new Set(Object.values(VirtualDomElements));
532
-
533
367
  const SetText = 1;
534
368
  const Replace = 2;
535
369
  const SetAttribute = 3;
@@ -540,6 +374,7 @@ const NavigateParent = 8;
540
374
  const RemoveChild = 9;
541
375
  const NavigateSibling = 10;
542
376
  const SetReferenceNodeUid = 11;
377
+ const MultiNavigation = 18;
543
378
 
544
379
  const isKey = key => {
545
380
  return key !== 'type' && key !== 'childCount';
@@ -600,6 +435,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
600
435
  };
601
436
  };
602
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
+
603
487
  const compareNodes = (oldNode, newNode) => {
604
488
  // Check if node type changed - return null to signal incompatible nodes
605
489
  // (caller should handle this with a Replace operation)
@@ -664,25 +548,17 @@ const treeToArray = node => {
664
548
 
665
549
  const navigateToChild = (patches, currentChildIndex, index) => {
666
550
  if (currentChildIndex === -1) {
667
- patches.push({
668
- type: NavigateChild,
669
- index
670
- });
551
+ appendNavigationPatch(patches, NavigateChild, index);
671
552
  return index;
672
553
  }
673
554
  if (currentChildIndex !== index) {
674
- patches.push({
675
- type: NavigateSibling,
676
- index
677
- });
555
+ appendNavigationPatch(patches, NavigateSibling, index);
678
556
  }
679
557
  return index;
680
558
  };
681
559
  const navigateToParent = (patches, currentChildIndex) => {
682
560
  if (currentChildIndex >= 0) {
683
- patches.push({
684
- type: NavigateParent
685
- });
561
+ appendNavigationPatch(patches, NavigateParent, 0);
686
562
  }
687
563
  return -1;
688
564
  };
@@ -698,6 +574,29 @@ const replaceTree = (newNode, patches) => {
698
574
  nodes: treeToArray(newNode)
699
575
  });
700
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
+ };
701
600
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
702
601
  const nodePatches = compareNodes(oldNode.node, newNode.node);
703
602
  if (nodePatches === null) {
@@ -706,16 +605,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
706
605
  return nextChildIndex;
707
606
  }
708
607
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
709
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
608
+ const childPatches = [];
609
+ if (hasChildrenToCompare) {
610
+ diffChildren(oldNode.children, newNode.children, childPatches);
611
+ }
612
+ if (nodePatches.length === 0 && childPatches.length === 0) {
710
613
  return currentChildIndex;
711
614
  }
712
615
  const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
713
- if (nodePatches.length > 0) {
714
- patches.push(...nodePatches);
715
- }
716
- if (hasChildrenToCompare) {
717
- diffChildren(oldNode.children, newNode.children, patches);
718
- }
616
+ patches.push(...nodePatches);
617
+ appendPatches(patches, childPatches);
719
618
  return nextChildIndex;
720
619
  };
721
620
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -771,7 +670,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
771
670
  const removeTrailingNavigationPatches = patches => {
772
671
  while (patches.length > 0) {
773
672
  const patch = patches.at(-1);
774
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
673
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
775
674
  break;
776
675
  }
777
676
  patches.pop();
@@ -1965,6 +1864,9 @@ const logError = () => {
1965
1864
  // handled by renderer worker
1966
1865
  };
1967
1866
  const handleMessage = event => {
1867
+ if (event.data === 'ready') {
1868
+ return Promise.resolve();
1869
+ }
1968
1870
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
1969
1871
  const actualExecute = event?.target?.execute || execute;
1970
1872
  return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.34.0",
3
+ "version": "3.35.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",