@lvce-editor/extension-detail-view 7.3.0 → 7.5.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 +115 -151
- 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);
|
|
@@ -2608,7 +2580,6 @@ const getAllPreferences = async () => {
|
|
|
2608
2580
|
};
|
|
2609
2581
|
|
|
2610
2582
|
/* eslint-disable unicorn/prefer-export-from */
|
|
2611
|
-
|
|
2612
2583
|
const {
|
|
2613
2584
|
getRuntimeStatus: getRuntimeStatus$1,
|
|
2614
2585
|
set: set$4
|
|
@@ -2640,10 +2611,7 @@ const featureRuntimeStatusEnabled = extension => {
|
|
|
2640
2611
|
if (!extension || typeof extension !== 'object') {
|
|
2641
2612
|
return false;
|
|
2642
2613
|
}
|
|
2643
|
-
|
|
2644
|
-
return true;
|
|
2645
|
-
}
|
|
2646
|
-
return false;
|
|
2614
|
+
return 'main' in extension || 'browser' in extension;
|
|
2647
2615
|
};
|
|
2648
2616
|
|
|
2649
2617
|
const formatTime = time => {
|
|
@@ -2844,7 +2812,6 @@ const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
|
|
|
2844
2812
|
};
|
|
2845
2813
|
|
|
2846
2814
|
/* eslint-disable unicorn/prefer-export-from */
|
|
2847
|
-
|
|
2848
2815
|
const {
|
|
2849
2816
|
getVirtualDom,
|
|
2850
2817
|
render,
|
|
@@ -3233,13 +3200,13 @@ const create$1 = () => {
|
|
|
3233
3200
|
},
|
|
3234
3201
|
diff(uid, modules, numbers) {
|
|
3235
3202
|
const {
|
|
3236
|
-
|
|
3237
|
-
|
|
3203
|
+
oldState,
|
|
3204
|
+
scheduledState
|
|
3238
3205
|
} = states[uid];
|
|
3239
3206
|
const diffResult = [];
|
|
3240
3207
|
for (let i = 0; i < modules.length; i++) {
|
|
3241
3208
|
const fn = modules[i];
|
|
3242
|
-
if (!fn(oldState,
|
|
3209
|
+
if (!fn(oldState, scheduledState)) {
|
|
3243
3210
|
diffResult.push(numbers[i]);
|
|
3244
3211
|
}
|
|
3245
3212
|
}
|
|
@@ -3257,17 +3224,16 @@ const create$1 = () => {
|
|
|
3257
3224
|
return ids;
|
|
3258
3225
|
},
|
|
3259
3226
|
getKeys() {
|
|
3260
|
-
return Object.keys(states).map(
|
|
3261
|
-
return Number.parseFloat(key);
|
|
3262
|
-
});
|
|
3227
|
+
return Object.keys(states).map(Number);
|
|
3263
3228
|
},
|
|
3264
3229
|
registerCommands(commandMap) {
|
|
3265
3230
|
Object.assign(commandMapRef, commandMap);
|
|
3266
3231
|
},
|
|
3267
|
-
set(uid, oldState, newState) {
|
|
3232
|
+
set(uid, oldState, newState, scheduledState) {
|
|
3268
3233
|
states[uid] = {
|
|
3269
3234
|
newState,
|
|
3270
|
-
oldState
|
|
3235
|
+
oldState,
|
|
3236
|
+
scheduledState: scheduledState ?? newState
|
|
3271
3237
|
};
|
|
3272
3238
|
},
|
|
3273
3239
|
wrapCommand(fn) {
|
|
@@ -3287,7 +3253,8 @@ const create$1 = () => {
|
|
|
3287
3253
|
};
|
|
3288
3254
|
states[uid] = {
|
|
3289
3255
|
newState: latestNew,
|
|
3290
|
-
oldState: latestOld.oldState
|
|
3256
|
+
oldState: latestOld.oldState,
|
|
3257
|
+
scheduledState: latestNew
|
|
3291
3258
|
};
|
|
3292
3259
|
};
|
|
3293
3260
|
return wrapped;
|
|
@@ -3324,7 +3291,8 @@ const create$1 = () => {
|
|
|
3324
3291
|
};
|
|
3325
3292
|
states[uid] = {
|
|
3326
3293
|
newState: latestNew,
|
|
3327
|
-
oldState: latestOld.oldState
|
|
3294
|
+
oldState: latestOld.oldState,
|
|
3295
|
+
scheduledState: latestNew
|
|
3328
3296
|
};
|
|
3329
3297
|
return {
|
|
3330
3298
|
error
|
|
@@ -3339,14 +3307,13 @@ const terminate = () => {
|
|
|
3339
3307
|
};
|
|
3340
3308
|
|
|
3341
3309
|
const writeClipboardImage = async blob => {
|
|
3342
|
-
await
|
|
3310
|
+
await writeImage(blob);
|
|
3343
3311
|
};
|
|
3344
3312
|
const writeText = async text => {
|
|
3345
|
-
await
|
|
3313
|
+
await writeText$1(text);
|
|
3346
3314
|
};
|
|
3347
3315
|
|
|
3348
3316
|
/* eslint-disable unicorn/prefer-export-from */
|
|
3349
|
-
|
|
3350
3317
|
const {
|
|
3351
3318
|
exists,
|
|
3352
3319
|
invoke,
|
|
@@ -5175,15 +5142,11 @@ const sendMessagePortToMarkdownWorker = async port => {
|
|
|
5175
5142
|
};
|
|
5176
5143
|
|
|
5177
5144
|
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
|
-
}
|
|
5145
|
+
const rpc = await create$4({
|
|
5146
|
+
commandMap: {},
|
|
5147
|
+
send: sendMessagePortToMarkdownWorker
|
|
5148
|
+
});
|
|
5149
|
+
return rpc;
|
|
5187
5150
|
};
|
|
5188
5151
|
|
|
5189
5152
|
const initializeMarkdownWorker = async () => {
|
|
@@ -5318,6 +5281,7 @@ const getExtraProps = (title, onClick) => {
|
|
|
5318
5281
|
props.title = title;
|
|
5319
5282
|
}
|
|
5320
5283
|
if (onClick) {
|
|
5284
|
+
props.style = 'cursor: pointer';
|
|
5321
5285
|
props.tabIndex = 0;
|
|
5322
5286
|
}
|
|
5323
5287
|
return props;
|