@lvce-editor/main-area-worker 9.63.0 → 9.64.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/mainAreaWorkerMain.js +90 -49
- package/package.json +1 -1
|
@@ -598,6 +598,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
598
598
|
};
|
|
599
599
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
600
600
|
const restoredError = new JsonRpcError(error.message);
|
|
601
|
+
Object.assign(restoredError, {
|
|
602
|
+
code: error.code
|
|
603
|
+
});
|
|
601
604
|
const parentStack = getParentStack(error);
|
|
602
605
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
603
606
|
return restoredError;
|
|
@@ -617,9 +620,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
617
620
|
// @ts-ignore
|
|
618
621
|
restoredError.codeFrame = error.data.codeFrame;
|
|
619
622
|
}
|
|
620
|
-
if (error.data.code) {
|
|
623
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
621
624
|
// @ts-ignore
|
|
622
|
-
restoredError
|
|
625
|
+
Object.defineProperty(restoredError, 'code', {
|
|
626
|
+
configurable: true,
|
|
627
|
+
value: error.data.code,
|
|
628
|
+
writable: true
|
|
629
|
+
});
|
|
623
630
|
}
|
|
624
631
|
if (error.data.type) {
|
|
625
632
|
// @ts-ignore
|
|
@@ -641,6 +648,13 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
641
648
|
};
|
|
642
649
|
const restoreMessageError = (error, _currentStack) => {
|
|
643
650
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
651
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
652
|
+
Object.defineProperty(restoredError, 'code', {
|
|
653
|
+
configurable: true,
|
|
654
|
+
value: error.code,
|
|
655
|
+
writable: true
|
|
656
|
+
});
|
|
657
|
+
}
|
|
644
658
|
if (error.data) {
|
|
645
659
|
applyDataProperties(restoredError, error);
|
|
646
660
|
} else {
|
|
@@ -719,7 +733,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
719
733
|
return {
|
|
720
734
|
code: Custom,
|
|
721
735
|
data: {
|
|
722
|
-
code: prettyError.code,
|
|
736
|
+
code: prettyError.code ?? error?.code,
|
|
723
737
|
codeFrame: prettyError.codeFrame,
|
|
724
738
|
name: prettyError.name,
|
|
725
739
|
stack: getStack(prettyError),
|
|
@@ -756,7 +770,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
756
770
|
return {
|
|
757
771
|
error: {
|
|
758
772
|
code: Custom,
|
|
759
|
-
data: error
|
|
773
|
+
data: error instanceof Error ? {
|
|
774
|
+
...error,
|
|
775
|
+
code: 'code' in error ? error.code : undefined,
|
|
776
|
+
stack: error.stack,
|
|
777
|
+
type: error.name
|
|
778
|
+
} : error,
|
|
760
779
|
// @ts-ignore
|
|
761
780
|
message: error.message
|
|
762
781
|
},
|
|
@@ -1503,6 +1522,8 @@ const getPreference = async key => {
|
|
|
1503
1522
|
return await invoke$2('Preferences.get', key);
|
|
1504
1523
|
};
|
|
1505
1524
|
|
|
1525
|
+
const cacheName = 'lvce0main-area-tabs';
|
|
1526
|
+
const cacheDuration = 90 * 24 * 60 * 60 * 1000;
|
|
1506
1527
|
const maxClosedTabs = 20;
|
|
1507
1528
|
const pendingOperations = new Map();
|
|
1508
1529
|
const sessionId = encodeURIComponent(`session-${new Date().toISOString()}`);
|
|
@@ -1536,9 +1557,23 @@ const isClosedTabEntry = value => {
|
|
|
1536
1557
|
return Boolean(entry.group && typeof entry.group === 'object' && entry.tab && typeof entry.tab === 'object' && typeof entry.groupIndex === 'number' && typeof entry.tabIndex === 'number');
|
|
1537
1558
|
};
|
|
1538
1559
|
const getEntries = async key => {
|
|
1539
|
-
const
|
|
1560
|
+
const cache = await caches.open(cacheName);
|
|
1561
|
+
const response = await cache.match(key);
|
|
1562
|
+
const entries = response ? await response.json() : [];
|
|
1540
1563
|
return Array.isArray(entries) ? entries.filter(isClosedTabEntry) : [];
|
|
1541
1564
|
};
|
|
1565
|
+
const setEntries = async (key, entries) => {
|
|
1566
|
+
const cache = await caches.open(cacheName);
|
|
1567
|
+
const value = JSON.stringify(entries);
|
|
1568
|
+
const expires = new Date(Date.now() + cacheDuration).toUTCString();
|
|
1569
|
+
await cache.put(key, new Response(value, {
|
|
1570
|
+
headers: {
|
|
1571
|
+
'Content-Length': String(value.length),
|
|
1572
|
+
'Content-Type': 'application/json',
|
|
1573
|
+
Expires: expires
|
|
1574
|
+
}
|
|
1575
|
+
}));
|
|
1576
|
+
};
|
|
1542
1577
|
const compact = entry => {
|
|
1543
1578
|
return {
|
|
1544
1579
|
...entry,
|
|
@@ -1557,7 +1592,7 @@ const add = (uid, entries) => {
|
|
|
1557
1592
|
const key = getKey(uid);
|
|
1558
1593
|
const existing = await getEntries(key);
|
|
1559
1594
|
const compactEntries = entries.map(compact);
|
|
1560
|
-
await
|
|
1595
|
+
await setEntries(key, [...existing, ...compactEntries].slice(-maxClosedTabs));
|
|
1561
1596
|
} catch {
|
|
1562
1597
|
// Closed tab history is optional and must never break editor commands.
|
|
1563
1598
|
}
|
|
@@ -1566,7 +1601,7 @@ const add = (uid, entries) => {
|
|
|
1566
1601
|
const clear = uid => {
|
|
1567
1602
|
return run(uid, async () => {
|
|
1568
1603
|
try {
|
|
1569
|
-
await
|
|
1604
|
+
await setEntries(getKey(uid), []);
|
|
1570
1605
|
} catch {
|
|
1571
1606
|
// Closed tab history is optional and must never break workspace changes.
|
|
1572
1607
|
}
|
|
@@ -1581,7 +1616,7 @@ const takeLast = uid => {
|
|
|
1581
1616
|
if (!isClosedTabEntry(entry)) {
|
|
1582
1617
|
return undefined;
|
|
1583
1618
|
}
|
|
1584
|
-
await
|
|
1619
|
+
await setEntries(key, entries.slice(0, -1));
|
|
1585
1620
|
return entry;
|
|
1586
1621
|
} catch {
|
|
1587
1622
|
return undefined;
|
|
@@ -2804,7 +2839,7 @@ const getEditorInputUri = editorInput => {
|
|
|
2804
2839
|
case 'webview':
|
|
2805
2840
|
return editorInput.uri;
|
|
2806
2841
|
case 'extension-detail-view':
|
|
2807
|
-
return `extension-detail
|
|
2842
|
+
return `extension-detail:///${encodeURIComponent(editorInput.extensionId)}`;
|
|
2808
2843
|
case 'process-explorer':
|
|
2809
2844
|
return 'process-explorer://';
|
|
2810
2845
|
case 'running-extensions':
|
|
@@ -2849,6 +2884,12 @@ const hasBinaryFileSuffix = uri => {
|
|
|
2849
2884
|
const cleanPath = pathName.slice(0, endIndex).toLowerCase();
|
|
2850
2885
|
return binaryFileSuffixes.some(suffix => cleanPath.endsWith(suffix));
|
|
2851
2886
|
};
|
|
2887
|
+
const getExtensionId = uri => {
|
|
2888
|
+
if (uri.startsWith('extension-detail:///')) {
|
|
2889
|
+
return decodeURIComponent(uri.slice('extension-detail:///'.length).split('/', 1)[0]);
|
|
2890
|
+
}
|
|
2891
|
+
return uri.slice('extension-detail://'.length).split('/', 1)[0];
|
|
2892
|
+
};
|
|
2852
2893
|
const getEditorInputFromUri = uri => {
|
|
2853
2894
|
if (uri.startsWith('diff://?') && URL.canParse(uri)) {
|
|
2854
2895
|
const parsed = new URL(uri);
|
|
@@ -2863,8 +2904,7 @@ const getEditorInputFromUri = uri => {
|
|
|
2863
2904
|
}
|
|
2864
2905
|
}
|
|
2865
2906
|
if (uri.startsWith('extension-detail://')) {
|
|
2866
|
-
const
|
|
2867
|
-
const extensionId = extensionIdWithPath.split('/', 1)[0];
|
|
2907
|
+
const extensionId = getExtensionId(uri);
|
|
2868
2908
|
if (extensionId) {
|
|
2869
2909
|
return {
|
|
2870
2910
|
extensionId,
|
|
@@ -2943,7 +2983,7 @@ const normalizeTabEditorInput = tab => {
|
|
|
2943
2983
|
if (!editorInput) {
|
|
2944
2984
|
return Object.hasOwn(tab, 'editorType') ? rest : tab;
|
|
2945
2985
|
}
|
|
2946
|
-
const uri = typeof tab.uri === 'string' ? tab.uri : getEditorInputUri(editorInput);
|
|
2986
|
+
const uri = editorInput.type !== 'extension-detail-view' && typeof tab.uri === 'string' ? tab.uri : getEditorInputUri(editorInput);
|
|
2947
2987
|
return {
|
|
2948
2988
|
...rest,
|
|
2949
2989
|
editorInput,
|
|
@@ -3766,8 +3806,7 @@ const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
|
|
|
3766
3806
|
const EditorGroupsVertical = 'EditorGroupsVertical';
|
|
3767
3807
|
const EditorContainer = 'EditorContainer';
|
|
3768
3808
|
const EditorGroupActions = 'EditorGroupActions';
|
|
3769
|
-
const
|
|
3770
|
-
const SplitEditorGroupButton = 'SplitEditorGroupButton';
|
|
3809
|
+
const SplitEditorGroupButton = 'EditorGroupActionButton SplitEditorGroupButton';
|
|
3771
3810
|
const MaskIconPreview = 'MaskIcon MaskIconPreview';
|
|
3772
3811
|
const MaskIconCircleFilled = 'MaskIcon MaskIconCircleFilled';
|
|
3773
3812
|
const MaskIconClose = 'MaskIcon MaskIconClose';
|
|
@@ -3836,6 +3875,10 @@ const getDragOverlayVirtualDom = () => {
|
|
|
3836
3875
|
return dragOverlayVirtualDom;
|
|
3837
3876
|
};
|
|
3838
3877
|
|
|
3878
|
+
const getEditorGroupClassName = groupId => {
|
|
3879
|
+
return `EditorGroup-${String(groupId).replaceAll('.', '-')}`;
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3839
3882
|
const offsetsMatch = (first, second) => {
|
|
3840
3883
|
return Math.abs(first - second) < 1e-6;
|
|
3841
3884
|
};
|
|
@@ -3884,10 +3927,6 @@ const getSashCorner = layout => {
|
|
|
3884
3927
|
};
|
|
3885
3928
|
};
|
|
3886
3929
|
|
|
3887
|
-
const getEditorGroupClassName = groupId => {
|
|
3888
|
-
return `EditorGroup-${groupId}`;
|
|
3889
|
-
};
|
|
3890
|
-
|
|
3891
3930
|
const CloseGroup = 'close-group';
|
|
3892
3931
|
const ConfigureLargeFileLimit = 'configure-large-file-limit';
|
|
3893
3932
|
const OpenLargeFile = 'open-large-file';
|
|
@@ -4400,7 +4439,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
|
|
|
4400
4439
|
if (splitButtonEnabled) {
|
|
4401
4440
|
buttons.push({
|
|
4402
4441
|
childCount: 1,
|
|
4403
|
-
className:
|
|
4442
|
+
className: SplitEditorGroupButton,
|
|
4404
4443
|
'data-action': SplitRight$1,
|
|
4405
4444
|
'data-groupId': String(group.id),
|
|
4406
4445
|
name: SplitRight$1,
|
|
@@ -4469,14 +4508,13 @@ const renderWaterMark = groupId => {
|
|
|
4469
4508
|
|
|
4470
4509
|
const Focusable = 0;
|
|
4471
4510
|
|
|
4472
|
-
const renderEmptyEditorGroup = (group, groupIndex,
|
|
4511
|
+
const renderEmptyEditorGroup = (group, groupIndex, closeButtonEnabled = true) => {
|
|
4473
4512
|
const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
|
|
4474
4513
|
return [{
|
|
4475
4514
|
childCount: closeButtonEnabled ? 2 : 1,
|
|
4476
4515
|
className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
|
|
4477
4516
|
'data-groupId': String(group.id),
|
|
4478
4517
|
onContextMenu: HandleContextMenu,
|
|
4479
|
-
style,
|
|
4480
4518
|
tabIndex: Focusable,
|
|
4481
4519
|
type: Div
|
|
4482
4520
|
}, ...closeButtonDom, ...renderWaterMark(group.id)];
|
|
@@ -4487,19 +4525,17 @@ const editorContainerNode = {
|
|
|
4487
4525
|
className: EditorContainer,
|
|
4488
4526
|
type: Div
|
|
4489
4527
|
};
|
|
4490
|
-
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false,
|
|
4528
|
+
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, closeButtonEnabled = true, tabDropIndicator) => {
|
|
4491
4529
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
4492
|
-
const style = `${sizeProperty}:${group.size}%;`;
|
|
4493
4530
|
const hasTabs = group.tabs.length > 0;
|
|
4494
4531
|
const hasEmptyGroupCloseButton = !hasTabs;
|
|
4495
4532
|
if (hasEmptyGroupCloseButton) {
|
|
4496
|
-
return renderEmptyEditorGroup(group, groupIndex,
|
|
4533
|
+
return renderEmptyEditorGroup(group, groupIndex, closeButtonEnabled);
|
|
4497
4534
|
}
|
|
4498
4535
|
return [{
|
|
4499
4536
|
childCount: 2,
|
|
4500
4537
|
className: mergeClassNames(EditorGroup, getEditorGroupClassName(group.id)),
|
|
4501
4538
|
'data-groupId': String(group.id),
|
|
4502
|
-
style,
|
|
4503
4539
|
type: Div
|
|
4504
4540
|
}, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
|
|
4505
4541
|
};
|
|
@@ -4547,11 +4583,11 @@ const mainNode$1 = {
|
|
|
4547
4583
|
onDrop: HandleDrop,
|
|
4548
4584
|
type: Div
|
|
4549
4585
|
};
|
|
4550
|
-
const renderSingleEditorGroup = (layout, splitButtonEnabled,
|
|
4586
|
+
const renderSingleEditorGroup = (layout, splitButtonEnabled, tabDropIndicator) => {
|
|
4551
4587
|
const {
|
|
4552
4588
|
groups
|
|
4553
4589
|
} = layout;
|
|
4554
|
-
return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled,
|
|
4590
|
+
return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, false, tabDropIndicator)];
|
|
4555
4591
|
};
|
|
4556
4592
|
|
|
4557
4593
|
const create = (beforeGroupId, afterGroupId) => {
|
|
@@ -4603,14 +4639,10 @@ const addDragOverlay = (dom, dragOverlay) => {
|
|
|
4603
4639
|
childCount: dom[0].childCount + 1
|
|
4604
4640
|
}, dom[1], ...dom.slice(2), getDragOverlayVirtualDom()];
|
|
4605
4641
|
};
|
|
4606
|
-
const getSizeProperty = direction => {
|
|
4607
|
-
return direction === Vertical ? 'height' : 'width';
|
|
4608
|
-
};
|
|
4609
4642
|
const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
|
|
4610
4643
|
const segments = getGroupSegments(groups, direction);
|
|
4611
4644
|
const children = [];
|
|
4612
4645
|
let childCount = 0;
|
|
4613
|
-
const sizeProperty = getSizeProperty(direction);
|
|
4614
4646
|
for (let i = 0; i < segments.length; i++) {
|
|
4615
4647
|
const segment = segments[i];
|
|
4616
4648
|
if (i > 0) {
|
|
@@ -4622,16 +4654,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
|
|
|
4622
4654
|
childCount++;
|
|
4623
4655
|
}
|
|
4624
4656
|
if (segment.direction === undefined) {
|
|
4625
|
-
children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled,
|
|
4657
|
+
children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, true, tabDropIndicator));
|
|
4626
4658
|
childCount++;
|
|
4627
4659
|
continue;
|
|
4628
4660
|
}
|
|
4629
4661
|
const nestedDirection = segment.direction;
|
|
4630
|
-
const nestedSizeProperty = getSizeProperty(nestedDirection);
|
|
4631
4662
|
const nestedChildCount = segment.groups.length + segment.groups.length - 1;
|
|
4632
4663
|
const nestedChildren = [];
|
|
4633
4664
|
let nestedCount = 0;
|
|
4634
|
-
const segmentSize = getSegmentSize(segment);
|
|
4635
4665
|
for (let j = 0; j < segment.groups.length; j++) {
|
|
4636
4666
|
if (j > 0) {
|
|
4637
4667
|
const beforeGroupId = segment.groups[j - 1].id;
|
|
@@ -4641,18 +4671,13 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
|
|
|
4641
4671
|
nestedCount++;
|
|
4642
4672
|
}
|
|
4643
4673
|
const group = segment.groups[j];
|
|
4644
|
-
|
|
4645
|
-
nestedChildren.push(...renderEditorGroup({
|
|
4646
|
-
...group,
|
|
4647
|
-
size: normalizedSize
|
|
4648
|
-
}, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty, true, tabDropIndicator));
|
|
4674
|
+
nestedChildren.push(...renderEditorGroup(group, segment.startIndex + j, splitButtonEnabled, true, tabDropIndicator));
|
|
4649
4675
|
nestedCount++;
|
|
4650
4676
|
}
|
|
4651
4677
|
children.push({
|
|
4652
4678
|
childCount: nestedChildCount,
|
|
4653
|
-
className: getContainerClassName(nestedDirection, segment.groups.length),
|
|
4679
|
+
className: mergeClassNames(getContainerClassName(nestedDirection, segment.groups.length), `${getEditorGroupClassName(segment.groups[0].id)}-Segment`),
|
|
4654
4680
|
role: None$2,
|
|
4655
|
-
style: `${sizeProperty}:${segmentSize}%;`,
|
|
4656
4681
|
type: Div
|
|
4657
4682
|
});
|
|
4658
4683
|
children.push(...nestedChildren);
|
|
@@ -4669,9 +4694,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay,
|
|
|
4669
4694
|
direction,
|
|
4670
4695
|
groups
|
|
4671
4696
|
} = layout;
|
|
4672
|
-
const sizeProperty = getSizeProperty(direction);
|
|
4673
4697
|
if (groups.length === 1) {
|
|
4674
|
-
return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled,
|
|
4698
|
+
return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, tabDropIndicator), dragOverlay);
|
|
4675
4699
|
}
|
|
4676
4700
|
const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
|
|
4677
4701
|
if (groups.length === 0) {
|
|
@@ -8084,17 +8108,34 @@ const getDragOverlayCss = dragOverlay => {
|
|
|
8084
8108
|
}`];
|
|
8085
8109
|
};
|
|
8086
8110
|
|
|
8111
|
+
const getSizeCss = (className, direction, size) => {
|
|
8112
|
+
const width = direction === Vertical ? 100 : size;
|
|
8113
|
+
const height = direction === Vertical ? size : 100;
|
|
8114
|
+
return `.${className} {
|
|
8115
|
+
width: ${width}%;
|
|
8116
|
+
height: ${height}%;
|
|
8117
|
+
}`;
|
|
8118
|
+
};
|
|
8087
8119
|
const getEditorGroupCss = layout => {
|
|
8088
8120
|
const {
|
|
8089
8121
|
direction,
|
|
8090
8122
|
groups
|
|
8091
8123
|
} = layout;
|
|
8092
|
-
const
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8124
|
+
const rules = [];
|
|
8125
|
+
for (const segment of getGroupSegments(groups, direction)) {
|
|
8126
|
+
if (segment.direction === undefined) {
|
|
8127
|
+
const group = segment.groups[0];
|
|
8128
|
+
rules.push(getSizeCss(getEditorGroupClassName(group.id), direction, group.size));
|
|
8129
|
+
continue;
|
|
8130
|
+
}
|
|
8131
|
+
const segmentSize = getSegmentSize(segment);
|
|
8132
|
+
rules.push(getSizeCss(`${getEditorGroupClassName(segment.groups[0].id)}-Segment`, direction, segmentSize));
|
|
8133
|
+
for (const group of segment.groups) {
|
|
8134
|
+
const normalizedSize = Number((group.size / segmentSize * 100).toFixed(6));
|
|
8135
|
+
rules.push(getSizeCss(getEditorGroupClassName(group.id), segment.direction, normalizedSize));
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
return rules;
|
|
8098
8139
|
};
|
|
8099
8140
|
|
|
8100
8141
|
const MIN_GROUP_WIDTH_PX = 250;
|