@lvce-editor/extension-detail-view 7.3.0 → 7.4.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/extensionDetailViewWorkerMain.js +103 -138
- package/package.json +1 -1
|
@@ -438,12 +438,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
438
438
|
};
|
|
439
439
|
|
|
440
440
|
const compareNodes = (oldNode, newNode) => {
|
|
441
|
-
const patches = [];
|
|
442
441
|
// Check if node type changed - return null to signal incompatible nodes
|
|
443
442
|
// (caller should handle this with a Replace operation)
|
|
444
443
|
if (oldNode.type !== newNode.type) {
|
|
445
444
|
return null;
|
|
446
445
|
}
|
|
446
|
+
const patches = [];
|
|
447
447
|
// Handle reference nodes - special handling for uid changes
|
|
448
448
|
if (oldNode.type === Reference) {
|
|
449
449
|
if (oldNode.uid !== newNode.uid) {
|
|
@@ -479,7 +479,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
479
479
|
}
|
|
480
480
|
// Check for removed attributes
|
|
481
481
|
for (const key of oldKeys) {
|
|
482
|
-
if (!(key
|
|
482
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
483
483
|
patches.push({
|
|
484
484
|
type: RemoveAttribute,
|
|
485
485
|
key
|
|
@@ -497,11 +497,78 @@ const treeToArray = node => {
|
|
|
497
497
|
return result;
|
|
498
498
|
};
|
|
499
499
|
|
|
500
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
501
|
+
if (currentChildIndex === -1) {
|
|
502
|
+
patches.push({
|
|
503
|
+
type: NavigateChild,
|
|
504
|
+
index
|
|
505
|
+
});
|
|
506
|
+
return index;
|
|
507
|
+
}
|
|
508
|
+
if (currentChildIndex !== index) {
|
|
509
|
+
patches.push({
|
|
510
|
+
type: NavigateSibling,
|
|
511
|
+
index
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
return index;
|
|
515
|
+
};
|
|
516
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
517
|
+
if (currentChildIndex >= 0) {
|
|
518
|
+
patches.push({
|
|
519
|
+
type: NavigateParent
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return -1;
|
|
523
|
+
};
|
|
524
|
+
const addTree = (newNode, patches) => {
|
|
525
|
+
patches.push({
|
|
526
|
+
type: Add,
|
|
527
|
+
nodes: treeToArray(newNode)
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const replaceTree = (newNode, patches) => {
|
|
531
|
+
patches.push({
|
|
532
|
+
type: Replace,
|
|
533
|
+
nodes: treeToArray(newNode)
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
537
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
538
|
+
if (nodePatches === null) {
|
|
539
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
540
|
+
replaceTree(newNode, patches);
|
|
541
|
+
return nextChildIndex;
|
|
542
|
+
}
|
|
543
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
544
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
545
|
+
return currentChildIndex;
|
|
546
|
+
}
|
|
547
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
548
|
+
if (nodePatches.length > 0) {
|
|
549
|
+
patches.push(...nodePatches);
|
|
550
|
+
}
|
|
551
|
+
if (hasChildrenToCompare) {
|
|
552
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
553
|
+
}
|
|
554
|
+
return nextChildIndex;
|
|
555
|
+
};
|
|
556
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
557
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
558
|
+
if (nodePatches === null) {
|
|
559
|
+
replaceTree(newNode, patches);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (nodePatches.length > 0) {
|
|
563
|
+
patches.push(...nodePatches);
|
|
564
|
+
}
|
|
565
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
566
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
500
569
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
501
570
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
502
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
503
571
|
let currentChildIndex = -1;
|
|
504
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
505
572
|
const indicesToRemove = [];
|
|
506
573
|
for (let i = 0; i < maxLength; i++) {
|
|
507
574
|
const oldNode = oldChildren[i];
|
|
@@ -510,88 +577,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
510
577
|
continue;
|
|
511
578
|
}
|
|
512
579
|
if (!oldNode) {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
});
|
|
519
|
-
currentChildIndex = -1;
|
|
520
|
-
}
|
|
521
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
522
|
-
const flatNodes = treeToArray(newNode);
|
|
523
|
-
patches.push({
|
|
524
|
-
type: Add,
|
|
525
|
-
nodes: flatNodes
|
|
526
|
-
});
|
|
527
|
-
} else if (newNode) {
|
|
528
|
-
// Compare nodes to see if we need any patches
|
|
529
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
530
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
531
|
-
if (nodePatches === null) {
|
|
532
|
-
// Navigate to this child
|
|
533
|
-
if (currentChildIndex === -1) {
|
|
534
|
-
patches.push({
|
|
535
|
-
type: NavigateChild,
|
|
536
|
-
index: i
|
|
537
|
-
});
|
|
538
|
-
currentChildIndex = i;
|
|
539
|
-
} else if (currentChildIndex !== i) {
|
|
540
|
-
patches.push({
|
|
541
|
-
type: NavigateSibling,
|
|
542
|
-
index: i
|
|
543
|
-
});
|
|
544
|
-
currentChildIndex = i;
|
|
545
|
-
}
|
|
546
|
-
// Replace the entire subtree
|
|
547
|
-
const flatNodes = treeToArray(newNode);
|
|
548
|
-
patches.push({
|
|
549
|
-
type: Replace,
|
|
550
|
-
nodes: flatNodes
|
|
551
|
-
});
|
|
552
|
-
// After replace, we're at the new element (same position)
|
|
553
|
-
continue;
|
|
554
|
-
}
|
|
555
|
-
// Check if we need to recurse into children
|
|
556
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
557
|
-
// Only navigate to this element if we need to do something
|
|
558
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
559
|
-
// Navigate to this child if not already there
|
|
560
|
-
if (currentChildIndex === -1) {
|
|
561
|
-
patches.push({
|
|
562
|
-
type: NavigateChild,
|
|
563
|
-
index: i
|
|
564
|
-
});
|
|
565
|
-
currentChildIndex = i;
|
|
566
|
-
} else if (currentChildIndex !== i) {
|
|
567
|
-
patches.push({
|
|
568
|
-
type: NavigateSibling,
|
|
569
|
-
index: i
|
|
570
|
-
});
|
|
571
|
-
currentChildIndex = i;
|
|
572
|
-
}
|
|
573
|
-
// Apply node patches (these apply to the current element, not children)
|
|
574
|
-
if (nodePatches.length > 0) {
|
|
575
|
-
patches.push(...nodePatches);
|
|
576
|
-
}
|
|
577
|
-
// Compare children recursively
|
|
578
|
-
if (hasChildrenToCompare) {
|
|
579
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
} else {
|
|
583
|
-
// Remove old node - collect the index for later removal
|
|
580
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
581
|
+
addTree(newNode, patches);
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (!newNode) {
|
|
584
585
|
indicesToRemove.push(i);
|
|
586
|
+
continue;
|
|
585
587
|
}
|
|
588
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
586
589
|
}
|
|
587
|
-
|
|
588
|
-
if (currentChildIndex >= 0) {
|
|
589
|
-
patches.push({
|
|
590
|
-
type: NavigateParent
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
// Add remove patches in reverse order (highest index first)
|
|
594
|
-
// This ensures indices remain valid as we remove
|
|
590
|
+
navigateToParent(patches, currentChildIndex);
|
|
595
591
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
596
592
|
patches.push({
|
|
597
593
|
type: RemoveChild,
|
|
@@ -600,33 +596,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
600
596
|
}
|
|
601
597
|
};
|
|
602
598
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
603
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
604
|
-
// So we compare the root node directly, then compare its children
|
|
605
599
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
// Compare root nodes
|
|
609
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
610
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
611
|
-
if (nodePatches === null) {
|
|
612
|
-
const flatNodes = treeToArray(newNode);
|
|
613
|
-
patches.push({
|
|
614
|
-
type: Replace,
|
|
615
|
-
nodes: flatNodes
|
|
616
|
-
});
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
if (nodePatches.length > 0) {
|
|
620
|
-
patches.push(...nodePatches);
|
|
621
|
-
}
|
|
622
|
-
// Compare children
|
|
623
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
624
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
625
|
-
}
|
|
626
|
-
} else {
|
|
627
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
628
|
-
diffChildren(oldTree, newTree, patches);
|
|
600
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
601
|
+
return;
|
|
629
602
|
}
|
|
603
|
+
diffChildren(oldTree, newTree, patches);
|
|
630
604
|
};
|
|
631
605
|
|
|
632
606
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -866,9 +840,9 @@ const getCellCodeVirtualDom = (value, props) => {
|
|
|
866
840
|
childCount: 1,
|
|
867
841
|
className: tdClassName,
|
|
868
842
|
type: Td,
|
|
869
|
-
...(props?.title
|
|
843
|
+
...(props?.title && {
|
|
870
844
|
title: props.title
|
|
871
|
-
}
|
|
845
|
+
})
|
|
872
846
|
}, {
|
|
873
847
|
childCount: 1,
|
|
874
848
|
type: Code$2
|
|
@@ -904,9 +878,9 @@ const getCellTextVirtualDom = (value, props) => {
|
|
|
904
878
|
childCount: 1,
|
|
905
879
|
className: tdClassName,
|
|
906
880
|
type: Td,
|
|
907
|
-
...(props?.title
|
|
881
|
+
...(props?.title && {
|
|
908
882
|
title: props.title
|
|
909
|
-
}
|
|
883
|
+
})
|
|
910
884
|
}, text(value)];
|
|
911
885
|
};
|
|
912
886
|
|
|
@@ -1029,10 +1003,7 @@ const isValidRelativePath = value => {
|
|
|
1029
1003
|
return false;
|
|
1030
1004
|
}
|
|
1031
1005
|
// Must contain at least one alphanumeric character
|
|
1032
|
-
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
return true;
|
|
1006
|
+
return !!/[A-Za-z0-9]/.test(value);
|
|
1036
1007
|
};
|
|
1037
1008
|
const getSchemaLinkUrl = (schema, extensionUri) => {
|
|
1038
1009
|
if (!schema || typeof schema !== 'string') {
|
|
@@ -1049,7 +1020,7 @@ const getSchemaLinkUrl = (schema, extensionUri) => {
|
|
|
1049
1020
|
return '';
|
|
1050
1021
|
}
|
|
1051
1022
|
try {
|
|
1052
|
-
return new URL(schema, extensionUri).
|
|
1023
|
+
return new URL(schema, extensionUri).href;
|
|
1053
1024
|
} catch {
|
|
1054
1025
|
return '';
|
|
1055
1026
|
}
|
|
@@ -2461,8 +2432,15 @@ const create$2 = rpcId => {
|
|
|
2461
2432
|
};
|
|
2462
2433
|
|
|
2463
2434
|
const {
|
|
2435
|
+
invoke: invoke$6,
|
|
2464
2436
|
set: set$a
|
|
2465
2437
|
} = create$2(ClipBoardWorker);
|
|
2438
|
+
const writeText$1 = async text => {
|
|
2439
|
+
return invoke$6('ClipBoard.writeText', text);
|
|
2440
|
+
};
|
|
2441
|
+
const writeImage = async image => {
|
|
2442
|
+
return invoke$6('ClipBoard.writeImage', image);
|
|
2443
|
+
};
|
|
2466
2444
|
|
|
2467
2445
|
const {
|
|
2468
2446
|
invoke: invoke$5,
|
|
@@ -2566,12 +2544,6 @@ const confirm = async (message, options) => {
|
|
|
2566
2544
|
const result = await invoke$1('ConfirmPrompt.prompt', message, options);
|
|
2567
2545
|
return result;
|
|
2568
2546
|
};
|
|
2569
|
-
const writeClipBoardText = async text => {
|
|
2570
|
-
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
2571
|
-
};
|
|
2572
|
-
const writeClipBoardImage = async blob => {
|
|
2573
|
-
await invoke$1('ClipBoard.writeImage', /* text */blob);
|
|
2574
|
-
};
|
|
2575
2547
|
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
2576
2548
|
const command = 'Extensions.handleMessagePort';
|
|
2577
2549
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
@@ -2640,10 +2612,7 @@ const featureRuntimeStatusEnabled = extension => {
|
|
|
2640
2612
|
if (!extension || typeof extension !== 'object') {
|
|
2641
2613
|
return false;
|
|
2642
2614
|
}
|
|
2643
|
-
|
|
2644
|
-
return true;
|
|
2645
|
-
}
|
|
2646
|
-
return false;
|
|
2615
|
+
return 'main' in extension || 'browser' in extension;
|
|
2647
2616
|
};
|
|
2648
2617
|
|
|
2649
2618
|
const formatTime = time => {
|
|
@@ -3339,10 +3308,10 @@ const terminate = () => {
|
|
|
3339
3308
|
};
|
|
3340
3309
|
|
|
3341
3310
|
const writeClipboardImage = async blob => {
|
|
3342
|
-
await
|
|
3311
|
+
await writeImage(blob);
|
|
3343
3312
|
};
|
|
3344
3313
|
const writeText = async text => {
|
|
3345
|
-
await
|
|
3314
|
+
await writeText$1(text);
|
|
3346
3315
|
};
|
|
3347
3316
|
|
|
3348
3317
|
/* eslint-disable unicorn/prefer-export-from */
|
|
@@ -5175,15 +5144,11 @@ const sendMessagePortToMarkdownWorker = async port => {
|
|
|
5175
5144
|
};
|
|
5176
5145
|
|
|
5177
5146
|
const createMarkdownWorkerRpc = async () => {
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
return rpc;
|
|
5184
|
-
} catch (error) {
|
|
5185
|
-
throw new VError(error, `Failed to create markdown worker rpc`);
|
|
5186
|
-
}
|
|
5147
|
+
const rpc = await create$4({
|
|
5148
|
+
commandMap: {},
|
|
5149
|
+
send: sendMessagePortToMarkdownWorker
|
|
5150
|
+
});
|
|
5151
|
+
return rpc;
|
|
5187
5152
|
};
|
|
5188
5153
|
|
|
5189
5154
|
const initializeMarkdownWorker = async () => {
|