@lvce-editor/main-area-worker 9.51.0 → 9.53.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 +115 -29
- package/package.json +1 -1
|
@@ -1748,12 +1748,13 @@ const getIcons = async iconRequests => {
|
|
|
1748
1748
|
|
|
1749
1749
|
const {
|
|
1750
1750
|
invoke: invoke$2,
|
|
1751
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1751
1752
|
set: set$3
|
|
1752
1753
|
} = create$3(RendererProcess);
|
|
1753
1754
|
|
|
1754
1755
|
const {
|
|
1755
1756
|
invoke: invoke$1,
|
|
1756
|
-
invokeAndTransfer,
|
|
1757
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
1757
1758
|
set: set$2
|
|
1758
1759
|
} = create$3(RendererWorker);
|
|
1759
1760
|
const handleModifiedStatusChange$1 = async (uri, modified) => {
|
|
@@ -1768,19 +1769,15 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1768
1769
|
};
|
|
1769
1770
|
const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
|
|
1770
1771
|
const command = 'ClipBoard.handleMessagePort';
|
|
1771
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
|
|
1772
|
-
};
|
|
1773
|
-
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1774
|
-
const command = 'DragAndDrop.handleMessagePort';
|
|
1775
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
|
|
1772
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
|
|
1776
1773
|
};
|
|
1777
1774
|
const sendMessagePortToDialogWorker = async port => {
|
|
1778
1775
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1779
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1776
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1780
1777
|
};
|
|
1781
1778
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1782
1779
|
const command = 'IconTheme.handleMessagePort';
|
|
1783
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1780
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1784
1781
|
};
|
|
1785
1782
|
const readFile = async uri => {
|
|
1786
1783
|
return invoke$1('FileSystem.readFile', uri);
|
|
@@ -2404,27 +2401,32 @@ const promptSave = async title => {
|
|
|
2404
2401
|
});
|
|
2405
2402
|
return shouldDiscard ? 'discard' : 'cancel';
|
|
2406
2403
|
};
|
|
2404
|
+
const canCloseTab = async tab => {
|
|
2405
|
+
if (tab.editorUid === -1 || !tab.isDirty) {
|
|
2406
|
+
return true;
|
|
2407
|
+
}
|
|
2408
|
+
const savePromptResult = await promptSave(tab.title);
|
|
2409
|
+
if (savePromptResult === 'cancel') {
|
|
2410
|
+
return false;
|
|
2411
|
+
}
|
|
2412
|
+
if (savePromptResult === 'save') {
|
|
2413
|
+
const editorState = await saveEditor(tab.editorUid);
|
|
2414
|
+
if (editorState?.modified !== false) {
|
|
2415
|
+
return false;
|
|
2416
|
+
}
|
|
2417
|
+
if (tab.uri) {
|
|
2418
|
+
await handleModifiedStatusChange$1(tab.uri, false);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
return savePromptResult === 'save' || savePromptResult === 'discard';
|
|
2422
|
+
};
|
|
2407
2423
|
const closeTabAndSave = async (state, groupId, tabId) => {
|
|
2408
2424
|
const tab = findTabInState(state, groupId, tabId);
|
|
2409
2425
|
if (!tab) {
|
|
2410
2426
|
return state;
|
|
2411
2427
|
}
|
|
2412
|
-
if (
|
|
2413
|
-
|
|
2414
|
-
if (savePromptResult === 'cancel') {
|
|
2415
|
-
return state;
|
|
2416
|
-
}
|
|
2417
|
-
if (savePromptResult === 'save') {
|
|
2418
|
-
const editorState = await saveEditor(tab.editorUid);
|
|
2419
|
-
if (editorState?.modified !== false) {
|
|
2420
|
-
return state;
|
|
2421
|
-
}
|
|
2422
|
-
if (tab.uri) {
|
|
2423
|
-
await handleModifiedStatusChange$1(tab.uri, false);
|
|
2424
|
-
}
|
|
2425
|
-
} else if (savePromptResult !== 'discard') {
|
|
2426
|
-
return state;
|
|
2427
|
-
}
|
|
2428
|
+
if (!(await canCloseTab(tab))) {
|
|
2429
|
+
return state;
|
|
2428
2430
|
}
|
|
2429
2431
|
return closeTabWithViewlet(state, groupId, tabId);
|
|
2430
2432
|
};
|
|
@@ -2488,6 +2490,16 @@ const closeAll$1 = async state => {
|
|
|
2488
2490
|
return withEmptyGroups(addClosedTabs(state, entries));
|
|
2489
2491
|
};
|
|
2490
2492
|
|
|
2493
|
+
const closeAllAndSave = async state => {
|
|
2494
|
+
const tabs = state.layout.groups.flatMap(group => group.tabs);
|
|
2495
|
+
for (const tab of tabs) {
|
|
2496
|
+
if (!(await canCloseTab(tab))) {
|
|
2497
|
+
return state;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
return closeAll$1(state);
|
|
2501
|
+
};
|
|
2502
|
+
|
|
2491
2503
|
const redistributeSizesWithRemainder = groups => {
|
|
2492
2504
|
const baseSize = Math.floor(100 / groups.length);
|
|
2493
2505
|
const remainder = 100 % groups.length;
|
|
@@ -2910,6 +2922,9 @@ const isConnected = () => {
|
|
|
2910
2922
|
const invoke = (method, ...params) => {
|
|
2911
2923
|
return invoke$2(method, ...params);
|
|
2912
2924
|
};
|
|
2925
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
2926
|
+
return invokeAndTransfer$2(method, ...params);
|
|
2927
|
+
};
|
|
2913
2928
|
const set = rpc => {
|
|
2914
2929
|
set$3(rpc);
|
|
2915
2930
|
state.connected = true;
|
|
@@ -3214,6 +3229,9 @@ const findTabById = (state, tabId) => {
|
|
|
3214
3229
|
const getSegmentSize = segment => {
|
|
3215
3230
|
return segment.groups.reduce((total, group) => total + group.size, 0);
|
|
3216
3231
|
};
|
|
3232
|
+
const getGroupSegment = (segments, groupId) => {
|
|
3233
|
+
return segments.find(segment => segment.groups.some(group => group.id === groupId));
|
|
3234
|
+
};
|
|
3217
3235
|
const getGroupSegments = (groups, parentDirection) => {
|
|
3218
3236
|
const segments = [];
|
|
3219
3237
|
let index = 0;
|
|
@@ -5433,7 +5451,7 @@ const handleHeaderDoubleClick = async (state, className, groupIndexRaw) => {
|
|
|
5433
5451
|
return newFile(state);
|
|
5434
5452
|
};
|
|
5435
5453
|
|
|
5436
|
-
const getAllTabs = layout => {
|
|
5454
|
+
const getAllTabs$1 = layout => {
|
|
5437
5455
|
const {
|
|
5438
5456
|
groups
|
|
5439
5457
|
} = layout;
|
|
@@ -5453,7 +5471,7 @@ const loadFileIcons = async state => {
|
|
|
5453
5471
|
groups
|
|
5454
5472
|
} = layout;
|
|
5455
5473
|
try {
|
|
5456
|
-
const allTabs = getAllTabs(layout);
|
|
5474
|
+
const allTabs = getAllTabs$1(layout);
|
|
5457
5475
|
const {
|
|
5458
5476
|
newFileIconCache
|
|
5459
5477
|
} = await getFileIconsForTabs(allTabs, fileIconCache);
|
|
@@ -5790,6 +5808,7 @@ const handleSashPointerDown = async (state, sashId, clientX, clientY) => {
|
|
|
5790
5808
|
layout
|
|
5791
5809
|
} = state;
|
|
5792
5810
|
const {
|
|
5811
|
+
direction,
|
|
5793
5812
|
groups
|
|
5794
5813
|
} = layout;
|
|
5795
5814
|
const beforeGroup = groups.find(group => group.id === parsed.beforeGroupId);
|
|
@@ -5800,13 +5819,20 @@ const handleSashPointerDown = async (state, sashId, clientX, clientY) => {
|
|
|
5800
5819
|
if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
|
|
5801
5820
|
return state;
|
|
5802
5821
|
}
|
|
5822
|
+
const segments = getGroupSegments(groups, direction);
|
|
5823
|
+
const beforeSegment = getGroupSegment(segments, parsed.beforeGroupId);
|
|
5824
|
+
const afterSegment = getGroupSegment(segments, parsed.afterGroupId);
|
|
5825
|
+
if (!beforeSegment || !afterSegment) {
|
|
5826
|
+
return state;
|
|
5827
|
+
}
|
|
5828
|
+
const isNestedSash = beforeSegment === afterSegment;
|
|
5803
5829
|
return {
|
|
5804
5830
|
...state,
|
|
5805
5831
|
sashDrag: {
|
|
5806
5832
|
afterGroupId: parsed.afterGroupId,
|
|
5807
|
-
afterSize: afterGroup.size,
|
|
5833
|
+
afterSize: isNestedSash ? afterGroup.size : getSegmentSize(afterSegment),
|
|
5808
5834
|
beforeGroupId: parsed.beforeGroupId,
|
|
5809
|
-
beforeSize: beforeGroup.size,
|
|
5835
|
+
beforeSize: isNestedSash ? beforeGroup.size : getSegmentSize(beforeSegment),
|
|
5810
5836
|
sashId,
|
|
5811
5837
|
startClientX: clientX,
|
|
5812
5838
|
startClientY: clientY
|
|
@@ -5814,6 +5840,14 @@ const handleSashPointerDown = async (state, sashId, clientX, clientY) => {
|
|
|
5814
5840
|
};
|
|
5815
5841
|
};
|
|
5816
5842
|
|
|
5843
|
+
const resizeGroupInSegment = (segment, groupId, segmentSize) => {
|
|
5844
|
+
const group = segment.groups.find(group => group.id === groupId);
|
|
5845
|
+
if (!group) {
|
|
5846
|
+
return undefined;
|
|
5847
|
+
}
|
|
5848
|
+
const previousSegmentSize = getSegmentSize(segment);
|
|
5849
|
+
return round(group.size / previousSegmentSize * segmentSize);
|
|
5850
|
+
};
|
|
5817
5851
|
const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
5818
5852
|
const {
|
|
5819
5853
|
height,
|
|
@@ -5833,6 +5867,13 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
|
5833
5867
|
direction,
|
|
5834
5868
|
groups
|
|
5835
5869
|
} = layout;
|
|
5870
|
+
const segments = getGroupSegments(groups, direction);
|
|
5871
|
+
const beforeSegment = getGroupSegment(segments, sashDrag.beforeGroupId);
|
|
5872
|
+
const afterSegment = getGroupSegment(segments, sashDrag.afterGroupId);
|
|
5873
|
+
if (!beforeSegment || !afterSegment) {
|
|
5874
|
+
return state;
|
|
5875
|
+
}
|
|
5876
|
+
const isNestedSash = beforeSegment === afterSegment;
|
|
5836
5877
|
const axisSize = direction === Horizontal ? width : height;
|
|
5837
5878
|
if (!axisSize) {
|
|
5838
5879
|
return state;
|
|
@@ -5850,6 +5891,23 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
|
5850
5891
|
const beforeSize = clamp(sashDrag.beforeSize + deltaPercent, minGroupSize, totalResizableSize - minGroupSize);
|
|
5851
5892
|
const afterSize = totalResizableSize - beforeSize;
|
|
5852
5893
|
const newGroups = groups.map(group => {
|
|
5894
|
+
if (!isNestedSash) {
|
|
5895
|
+
const resizedBeforeGroupSize = resizeGroupInSegment(beforeSegment, group.id, beforeSize);
|
|
5896
|
+
if (resizedBeforeGroupSize !== undefined) {
|
|
5897
|
+
return {
|
|
5898
|
+
...group,
|
|
5899
|
+
size: resizedBeforeGroupSize
|
|
5900
|
+
};
|
|
5901
|
+
}
|
|
5902
|
+
const resizedAfterGroupSize = resizeGroupInSegment(afterSegment, group.id, afterSize);
|
|
5903
|
+
if (resizedAfterGroupSize !== undefined) {
|
|
5904
|
+
return {
|
|
5905
|
+
...group,
|
|
5906
|
+
size: resizedAfterGroupSize
|
|
5907
|
+
};
|
|
5908
|
+
}
|
|
5909
|
+
return group;
|
|
5910
|
+
}
|
|
5853
5911
|
if (group.id === sashDrag.beforeGroupId) {
|
|
5854
5912
|
return {
|
|
5855
5913
|
...group,
|
|
@@ -6387,6 +6445,30 @@ const hasActiveTextEditor = state => {
|
|
|
6387
6445
|
return activeTab?.tab.editorInput?.type === 'editor';
|
|
6388
6446
|
};
|
|
6389
6447
|
|
|
6448
|
+
const getTabs = group => {
|
|
6449
|
+
return group.tabs;
|
|
6450
|
+
};
|
|
6451
|
+
const getAllTabs = state => {
|
|
6452
|
+
const {
|
|
6453
|
+
layout
|
|
6454
|
+
} = state;
|
|
6455
|
+
const {
|
|
6456
|
+
groups
|
|
6457
|
+
} = layout;
|
|
6458
|
+
return groups.flatMap(getTabs);
|
|
6459
|
+
};
|
|
6460
|
+
|
|
6461
|
+
const isDirty = tab => {
|
|
6462
|
+
return tab.isDirty;
|
|
6463
|
+
};
|
|
6464
|
+
const getDirtyTabs = state => {
|
|
6465
|
+
return getAllTabs(state).filter(isDirty);
|
|
6466
|
+
};
|
|
6467
|
+
|
|
6468
|
+
const hasDirtyTabs = state => {
|
|
6469
|
+
return getDirtyTabs(state).length > 0;
|
|
6470
|
+
};
|
|
6471
|
+
|
|
6390
6472
|
const initialize$1 = async () => {
|
|
6391
6473
|
// Kept as a compatibility command for existing renderer startup code.
|
|
6392
6474
|
};
|
|
@@ -8475,6 +8557,7 @@ const commandMap = {
|
|
|
8475
8557
|
'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
|
|
8476
8558
|
'Main.closeAll': wrapSerialCommand(closeAll$1),
|
|
8477
8559
|
'Main.closeAllEditors': wrapSerialCommand(closeAll$1),
|
|
8560
|
+
'Main.closeAllEditorsAndSave': wrapSerialCommand(closeAllAndSave),
|
|
8478
8561
|
'Main.closeFocusedTab': wrapSerialCommand(closeFocusedTab),
|
|
8479
8562
|
'Main.closeOthers': wrapSerialCommand(closeOtherTabs),
|
|
8480
8563
|
'Main.closeSaved': wrapSerialCommand(closeSaved$1),
|
|
@@ -8490,6 +8573,7 @@ const commandMap = {
|
|
|
8490
8573
|
'Main.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
|
|
8491
8574
|
'Main.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
|
|
8492
8575
|
'Main.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
|
|
8576
|
+
'Main.hasDirtyTabs': wrapGetter(hasDirtyTabs),
|
|
8493
8577
|
'Main.openInput': wrapSerialAsyncCommand(openInputWithContext),
|
|
8494
8578
|
'Main.openUri': wrapSerialAsyncCommand(openUriWithContext),
|
|
8495
8579
|
'Main.openUris': wrapSerialAsyncCommand(openUrisWithContext),
|
|
@@ -8500,6 +8584,7 @@ const commandMap = {
|
|
|
8500
8584
|
'MainArea.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
|
|
8501
8585
|
'MainArea.closeAll': wrapSerialCommand(closeAll$1),
|
|
8502
8586
|
'MainArea.closeAllEditors': wrapSerialCommand(closeAll$1),
|
|
8587
|
+
'MainArea.closeAllEditorsAndSave': wrapSerialCommand(closeAllAndSave),
|
|
8503
8588
|
'MainArea.closeEditorGroup': wrapSerialCommand(closeEditorGroup$1),
|
|
8504
8589
|
'MainArea.closeFocusedTab': wrapSerialCommand(closeFocusedTab),
|
|
8505
8590
|
'MainArea.closeOthers': wrapSerialCommand(closeOtherTabs),
|
|
@@ -8553,6 +8638,7 @@ const commandMap = {
|
|
|
8553
8638
|
'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
|
|
8554
8639
|
'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
|
|
8555
8640
|
'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
|
|
8641
|
+
'MainArea.hasDirtyTabs': wrapGetter(hasDirtyTabs),
|
|
8556
8642
|
'MainArea.initialize': initialize$1,
|
|
8557
8643
|
'MainArea.loadContent': loadContentTracked,
|
|
8558
8644
|
'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
|
|
@@ -8599,7 +8685,7 @@ const initializeClipBoardWorker = async () => {
|
|
|
8599
8685
|
};
|
|
8600
8686
|
|
|
8601
8687
|
const send$1 = async port => {
|
|
8602
|
-
await
|
|
8688
|
+
await invokeAndTransfer('DragAndDrop.handleMessagePort', port);
|
|
8603
8689
|
};
|
|
8604
8690
|
const createDragAndDropWorkerRpc = async () => {
|
|
8605
8691
|
return create$6({
|