@lvce-editor/main-area-worker 9.37.6 → 9.38.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 -23
- package/package.json +1 -1
|
@@ -2854,6 +2854,8 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
2854
2854
|
minGroupHeightPx: 80,
|
|
2855
2855
|
minGroupWidthPx: 250,
|
|
2856
2856
|
platform,
|
|
2857
|
+
pointerDownGroupIndex: -1,
|
|
2858
|
+
pointerDownTabIndex: -1,
|
|
2857
2859
|
splitButtonEnabled: false,
|
|
2858
2860
|
tabHeight,
|
|
2859
2861
|
uid,
|
|
@@ -2865,10 +2867,14 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
2865
2867
|
set(uid, state, state);
|
|
2866
2868
|
};
|
|
2867
2869
|
|
|
2868
|
-
const isEqual$
|
|
2870
|
+
const isEqual$3 = (oldState, newState) => {
|
|
2869
2871
|
return false;
|
|
2870
2872
|
};
|
|
2871
2873
|
|
|
2874
|
+
const isEqual$2 = (oldState, newState) => {
|
|
2875
|
+
return oldState.pointerDownGroupIndex === newState.pointerDownGroupIndex && oldState.pointerDownTabIndex === newState.pointerDownTabIndex;
|
|
2876
|
+
};
|
|
2877
|
+
|
|
2872
2878
|
const isEqual$1 = (oldState, newState) => {
|
|
2873
2879
|
return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout;
|
|
2874
2880
|
};
|
|
@@ -2877,12 +2883,13 @@ const RenderItems = 4;
|
|
|
2877
2883
|
const RenderCss = 10;
|
|
2878
2884
|
const RenderIncremental = 11;
|
|
2879
2885
|
const RenderPendingViewletUpdate = 12;
|
|
2886
|
+
const RenderDragData = 13;
|
|
2880
2887
|
|
|
2881
2888
|
const isPendingViewletUpdateEqual = (oldState, newState) => {
|
|
2882
2889
|
return newState.pendingViewletUpdate === undefined;
|
|
2883
2890
|
};
|
|
2884
|
-
const modules = [isEqual$1, isEqual$
|
|
2885
|
-
const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate];
|
|
2891
|
+
const modules = [isEqual$1, isEqual$3, isPendingViewletUpdateEqual, isEqual$2];
|
|
2892
|
+
const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData];
|
|
2886
2893
|
|
|
2887
2894
|
const diff = (oldState, newState) => {
|
|
2888
2895
|
const diffResult = [];
|
|
@@ -3953,6 +3960,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3953
3960
|
if (activeGroup) {
|
|
3954
3961
|
const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
3955
3962
|
if (activeTab?.isPreview) {
|
|
3963
|
+
const tabId = create$2();
|
|
3956
3964
|
const updatedGroups = groups.map(group => {
|
|
3957
3965
|
if (group.id !== activeGroup.id) {
|
|
3958
3966
|
return group;
|
|
@@ -3968,6 +3976,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3968
3976
|
editorUid: create$2(),
|
|
3969
3977
|
errorMessage: '',
|
|
3970
3978
|
icon: '',
|
|
3979
|
+
id: tabId,
|
|
3971
3980
|
isDirty: false,
|
|
3972
3981
|
isPreview: preview,
|
|
3973
3982
|
language: '',
|
|
@@ -3979,6 +3988,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3979
3988
|
});
|
|
3980
3989
|
return {
|
|
3981
3990
|
...group,
|
|
3991
|
+
activeTabId: tabId,
|
|
3982
3992
|
tabs: updatedTabs
|
|
3983
3993
|
};
|
|
3984
3994
|
});
|
|
@@ -4697,7 +4707,16 @@ const handleClickTab = async (state, groupIndexRaw, indexRaw, button = 0) => {
|
|
|
4697
4707
|
}
|
|
4698
4708
|
const groupIndex = Number.parseInt(groupIndexRaw);
|
|
4699
4709
|
const index = Number.parseInt(indexRaw);
|
|
4700
|
-
|
|
4710
|
+
const group = state.layout.groups[groupIndex];
|
|
4711
|
+
if (!group || index < 0 || index >= group.tabs.length) {
|
|
4712
|
+
return state;
|
|
4713
|
+
}
|
|
4714
|
+
const newState = await selectTab(state, groupIndex, index);
|
|
4715
|
+
return {
|
|
4716
|
+
...newState,
|
|
4717
|
+
pointerDownGroupIndex: groupIndex,
|
|
4718
|
+
pointerDownTabIndex: index
|
|
4719
|
+
};
|
|
4701
4720
|
};
|
|
4702
4721
|
|
|
4703
4722
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -4871,6 +4890,10 @@ const handleDragOver = (state, eventX, eventY) => {
|
|
|
4871
4890
|
};
|
|
4872
4891
|
};
|
|
4873
4892
|
|
|
4893
|
+
const handleDragStart = state => {
|
|
4894
|
+
return state;
|
|
4895
|
+
};
|
|
4896
|
+
|
|
4874
4897
|
const openUrisWithContext = async (context, uris, reuseExisting = true) => {
|
|
4875
4898
|
for (const uri of uris) {
|
|
4876
4899
|
await openUriWithContext(context, {
|
|
@@ -5041,6 +5064,26 @@ const splitForDrop = (state, splitDirection) => {
|
|
|
5041
5064
|
return state;
|
|
5042
5065
|
}
|
|
5043
5066
|
};
|
|
5067
|
+
|
|
5068
|
+
const applyDropAction = async (context, action, splitDirection) => {
|
|
5069
|
+
switch (action.command) {
|
|
5070
|
+
case 'openFiles':
|
|
5071
|
+
{
|
|
5072
|
+
if (action.uris.length > 0 && splitDirection !== None) {
|
|
5073
|
+
await context.updateState(state => splitForDrop(state, splitDirection));
|
|
5074
|
+
}
|
|
5075
|
+
await openUrisWithContext(context, action.uris, splitDirection === None);
|
|
5076
|
+
break;
|
|
5077
|
+
}
|
|
5078
|
+
case 'setPath':
|
|
5079
|
+
void invoke('Workspace.setPath', action.value).catch(() => {});
|
|
5080
|
+
break;
|
|
5081
|
+
case 'setUri':
|
|
5082
|
+
void invoke('Workspace.setUri', action.value).catch(() => {});
|
|
5083
|
+
break;
|
|
5084
|
+
}
|
|
5085
|
+
};
|
|
5086
|
+
|
|
5044
5087
|
const getDropAction = async uris => {
|
|
5045
5088
|
for (const uri of uris) {
|
|
5046
5089
|
if (uri.endsWith('/') || (await isDirectoryEditorInput({
|
|
@@ -5064,24 +5107,7 @@ const getDropAction = async uris => {
|
|
|
5064
5107
|
uris
|
|
5065
5108
|
};
|
|
5066
5109
|
};
|
|
5067
|
-
|
|
5068
|
-
switch (action.command) {
|
|
5069
|
-
case 'openFiles':
|
|
5070
|
-
{
|
|
5071
|
-
if (action.uris.length > 0 && splitDirection !== None) {
|
|
5072
|
-
await context.updateState(state => splitForDrop(state, splitDirection));
|
|
5073
|
-
}
|
|
5074
|
-
await openUrisWithContext(context, action.uris, splitDirection === None);
|
|
5075
|
-
break;
|
|
5076
|
-
}
|
|
5077
|
-
case 'setPath':
|
|
5078
|
-
void invoke('Workspace.setPath', action.value).catch(() => {});
|
|
5079
|
-
break;
|
|
5080
|
-
case 'setUri':
|
|
5081
|
-
void invoke('Workspace.setUri', action.value).catch(() => {});
|
|
5082
|
-
break;
|
|
5083
|
-
}
|
|
5084
|
-
};
|
|
5110
|
+
|
|
5085
5111
|
const handleDrop = async (context, itemIds) => {
|
|
5086
5112
|
const splitDirection = context.getState().dragOverlay?.splitDirection ?? None;
|
|
5087
5113
|
await context.updateState(handleDragLeave);
|
|
@@ -6603,6 +6629,39 @@ const renderCss = (oldState, newState) => {
|
|
|
6603
6629
|
return [SetCss, newState.uid, css];
|
|
6604
6630
|
};
|
|
6605
6631
|
|
|
6632
|
+
const ensureUri = uri => {
|
|
6633
|
+
return uri.startsWith('/') ? `file://${uri}` : uri;
|
|
6634
|
+
};
|
|
6635
|
+
const renderDragData = (oldState, newState) => {
|
|
6636
|
+
const {
|
|
6637
|
+
layout,
|
|
6638
|
+
pointerDownGroupIndex,
|
|
6639
|
+
pointerDownTabIndex,
|
|
6640
|
+
uid
|
|
6641
|
+
} = newState;
|
|
6642
|
+
const {
|
|
6643
|
+
groups
|
|
6644
|
+
} = layout;
|
|
6645
|
+
if (pointerDownGroupIndex === -1 || pointerDownTabIndex === -1) {
|
|
6646
|
+
return [];
|
|
6647
|
+
}
|
|
6648
|
+
const tab = groups[pointerDownGroupIndex]?.tabs[pointerDownTabIndex];
|
|
6649
|
+
if (!tab?.uri) {
|
|
6650
|
+
return [];
|
|
6651
|
+
}
|
|
6652
|
+
const data = ensureUri(tab.uri);
|
|
6653
|
+
return ['Viewlet.setDragData', uid, {
|
|
6654
|
+
items: [{
|
|
6655
|
+
data,
|
|
6656
|
+
type: 'text/uri-list'
|
|
6657
|
+
}, {
|
|
6658
|
+
data,
|
|
6659
|
+
type: 'text/plain'
|
|
6660
|
+
}],
|
|
6661
|
+
label: tab.title
|
|
6662
|
+
}];
|
|
6663
|
+
};
|
|
6664
|
+
|
|
6606
6665
|
const mergeClassNames = (...classNames) => {
|
|
6607
6666
|
return classNames.filter(Boolean).join(' ');
|
|
6608
6667
|
};
|
|
@@ -6894,6 +6953,9 @@ const HandleSashCornerPointerUp = 22;
|
|
|
6894
6953
|
const HandleDragOver = 23;
|
|
6895
6954
|
const HandleDragLeave = 24;
|
|
6896
6955
|
const HandleDrop = 25;
|
|
6956
|
+
const HandleDragStart = 26;
|
|
6957
|
+
const HandleDragEnd = 27;
|
|
6958
|
+
const HandleTabMouseUp = 28;
|
|
6897
6959
|
|
|
6898
6960
|
const dragOverlayVirtualDom = {
|
|
6899
6961
|
childCount: 0,
|
|
@@ -7088,9 +7150,13 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
7088
7150
|
className,
|
|
7089
7151
|
'data-groupIndex': groupIndex,
|
|
7090
7152
|
'data-index': tabIndex,
|
|
7153
|
+
draggable: true,
|
|
7091
7154
|
onContextMenu: HandleTabContextMenu,
|
|
7092
7155
|
onDblClick: HandleDoubleClick,
|
|
7156
|
+
onDragEnd: HandleDragEnd,
|
|
7157
|
+
onDragStart: HandleDragStart,
|
|
7093
7158
|
onMouseDown: HandleClickTab,
|
|
7159
|
+
onMouseUp: HandleTabMouseUp,
|
|
7094
7160
|
role: Tab$1,
|
|
7095
7161
|
title: tab.uriTitle || tab.uri || tab.title,
|
|
7096
7162
|
type: Div
|
|
@@ -7463,6 +7529,8 @@ const getRenderer = diffType => {
|
|
|
7463
7529
|
switch (diffType) {
|
|
7464
7530
|
case RenderCss:
|
|
7465
7531
|
return renderCss;
|
|
7532
|
+
case RenderDragData:
|
|
7533
|
+
return renderDragData;
|
|
7466
7534
|
case RenderIncremental:
|
|
7467
7535
|
return renderIncremental;
|
|
7468
7536
|
case RenderItems:
|
|
@@ -7556,6 +7624,16 @@ const renderEventListeners = () => {
|
|
|
7556
7624
|
name: HandleDrop,
|
|
7557
7625
|
params: ['handleDrop', DataTransferFiles2],
|
|
7558
7626
|
preventDefault: true
|
|
7627
|
+
}, {
|
|
7628
|
+
dragEffect: 'copyMove',
|
|
7629
|
+
name: HandleDragStart,
|
|
7630
|
+
params: ['handleDragStart']
|
|
7631
|
+
}, {
|
|
7632
|
+
name: HandleDragEnd,
|
|
7633
|
+
params: ['handleDragEnd']
|
|
7634
|
+
}, {
|
|
7635
|
+
name: HandleTabMouseUp,
|
|
7636
|
+
params: ['handleTabMouseUp']
|
|
7559
7637
|
}];
|
|
7560
7638
|
};
|
|
7561
7639
|
|
|
@@ -7566,7 +7644,7 @@ const getViewProviderEntries = async uri => {
|
|
|
7566
7644
|
type: 'editor'
|
|
7567
7645
|
};
|
|
7568
7646
|
try {
|
|
7569
|
-
const providers = await invoke('WebView.
|
|
7647
|
+
const providers = await invoke('WebView.getEditorProviders');
|
|
7570
7648
|
const matchingProviders = providers.filter(provider => provider?.id && provider.selector?.some(selector => uri.endsWith(selector)));
|
|
7571
7649
|
return [textEditorEntry, ...matchingProviders.map(provider => {
|
|
7572
7650
|
const titleElement = provider.elements?.find(element => element.type === 'title');
|
|
@@ -7654,6 +7732,17 @@ const reopenEditorWith = async context => {
|
|
|
7654
7732
|
}
|
|
7655
7733
|
};
|
|
7656
7734
|
|
|
7735
|
+
const resetPointerDown = state => {
|
|
7736
|
+
if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
|
|
7737
|
+
return state;
|
|
7738
|
+
}
|
|
7739
|
+
return {
|
|
7740
|
+
...state,
|
|
7741
|
+
pointerDownGroupIndex: -1,
|
|
7742
|
+
pointerDownTabIndex: -1
|
|
7743
|
+
};
|
|
7744
|
+
};
|
|
7745
|
+
|
|
7657
7746
|
const resize$1 = (state, dimensions) => {
|
|
7658
7747
|
return {
|
|
7659
7748
|
...state,
|
|
@@ -8064,8 +8153,10 @@ const commandMap = {
|
|
|
8064
8153
|
'MainArea.handleClickTogglePreview': wrapSerialCommand(handleClickTogglePreview),
|
|
8065
8154
|
'MainArea.handleContextMenu': wrapSerialCommand(handleContextMenu),
|
|
8066
8155
|
'MainArea.handleDoubleClick': wrapSerialCommand(handleDoubleClick),
|
|
8156
|
+
'MainArea.handleDragEnd': wrapSerialCommand(resetPointerDown),
|
|
8067
8157
|
'MainArea.handleDragLeave': wrapSerialCommand(handleDragLeave),
|
|
8068
8158
|
'MainArea.handleDragOver': wrapSerialCommand(handleDragOver),
|
|
8159
|
+
'MainArea.handleDragStart': wrapSerialCommand(handleDragStart),
|
|
8069
8160
|
'MainArea.handleDrop': wrapSerialAsyncCommand(handleDrop),
|
|
8070
8161
|
'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
|
|
8071
8162
|
'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
|
|
@@ -8078,6 +8169,7 @@ const commandMap = {
|
|
|
8078
8169
|
'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
|
|
8079
8170
|
'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
|
|
8080
8171
|
'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
|
|
8172
|
+
'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
|
|
8081
8173
|
'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
|
|
8082
8174
|
'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
|
|
8083
8175
|
'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
|