@lvce-editor/main-area-worker 9.32.0 → 9.32.1
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 +268 -22
- package/package.json +1 -1
|
@@ -1933,17 +1933,72 @@ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) =>
|
|
|
1933
1933
|
return getTitle$1(editorUid);
|
|
1934
1934
|
};
|
|
1935
1935
|
|
|
1936
|
+
const getActiveFileUri = state => {
|
|
1937
|
+
const {
|
|
1938
|
+
activeGroupId,
|
|
1939
|
+
groups
|
|
1940
|
+
} = state.layout;
|
|
1941
|
+
const activeGroup = groups.find(group => group.id === activeGroupId);
|
|
1942
|
+
const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
1943
|
+
if (!activeTab) {
|
|
1944
|
+
return '';
|
|
1945
|
+
}
|
|
1946
|
+
if (typeof activeTab.uri === 'string') {
|
|
1947
|
+
return activeTab.uri;
|
|
1948
|
+
}
|
|
1949
|
+
const {
|
|
1950
|
+
editorInput
|
|
1951
|
+
} = activeTab;
|
|
1952
|
+
return editorInput && 'uri' in editorInput ? editorInput.uri : '';
|
|
1953
|
+
};
|
|
1954
|
+
|
|
1955
|
+
const notifyActiveEditorChange = async (oldState, newState) => {
|
|
1956
|
+
const oldUri = getActiveFileUri(oldState);
|
|
1957
|
+
const newUri = getActiveFileUri(newState);
|
|
1958
|
+
if (oldUri === newUri) {
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
try {
|
|
1962
|
+
await invoke('Viewlet.executeViewletCommand', 'Problems', 'handleActiveEditorChange', newUri);
|
|
1963
|
+
} catch (error) {
|
|
1964
|
+
console.warn('Failed to notify Problems view about active editor change', error);
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1968
|
+
const withActiveEditorChange = fn => {
|
|
1969
|
+
return async (state, ...args) => {
|
|
1970
|
+
const newState = await fn(state, ...args);
|
|
1971
|
+
await notifyActiveEditorChange(state, newState);
|
|
1972
|
+
return newState;
|
|
1973
|
+
};
|
|
1974
|
+
};
|
|
1975
|
+
const withActiveEditorChangeAsync = fn => {
|
|
1976
|
+
return async (context, ...args) => {
|
|
1977
|
+
const oldState = context.getState();
|
|
1978
|
+
await fn(context, ...args);
|
|
1979
|
+
const newState = context.getState();
|
|
1980
|
+
await notifyActiveEditorChange(oldState, newState);
|
|
1981
|
+
};
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
const registry = create$f();
|
|
1936
1985
|
const {
|
|
1937
1986
|
get,
|
|
1938
1987
|
getCommandIds,
|
|
1939
1988
|
getKeys: getKeys$1,
|
|
1940
1989
|
registerCommands,
|
|
1941
1990
|
set,
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
}
|
|
1991
|
+
wrapGetter
|
|
1992
|
+
} = registry;
|
|
1993
|
+
const wrapAsyncCommand = fn => {
|
|
1994
|
+
return registry.wrapAsyncCommand(withActiveEditorChangeAsync(fn));
|
|
1995
|
+
};
|
|
1996
|
+
const wrapSerialAsyncCommand = fn => {
|
|
1997
|
+
return registry.wrapSerialAsyncCommand(withActiveEditorChangeAsync(fn));
|
|
1998
|
+
};
|
|
1999
|
+
const wrapSerialCommand = fn => {
|
|
2000
|
+
return registry.wrapSerialCommand(withActiveEditorChange(fn));
|
|
2001
|
+
};
|
|
1947
2002
|
|
|
1948
2003
|
const create$2 = () => {
|
|
1949
2004
|
return Math.random();
|
|
@@ -4721,6 +4776,155 @@ const handleResize = async (state, dimensions) => {
|
|
|
4721
4776
|
return allResizeCommands;
|
|
4722
4777
|
};
|
|
4723
4778
|
|
|
4779
|
+
const offsetsMatch = (first, second) => {
|
|
4780
|
+
return Math.abs(first - second) < 1e-6;
|
|
4781
|
+
};
|
|
4782
|
+
const getSashCorner = layout => {
|
|
4783
|
+
const segments = getGroupSegments(layout.groups, layout.direction);
|
|
4784
|
+
if (segments.length !== 2) {
|
|
4785
|
+
return undefined;
|
|
4786
|
+
}
|
|
4787
|
+
const [firstSegment, secondSegment] = segments;
|
|
4788
|
+
if (firstSegment.direction === undefined || secondSegment.direction !== firstSegment.direction || firstSegment.groups.length !== 2 || secondSegment.groups.length !== 2) {
|
|
4789
|
+
return undefined;
|
|
4790
|
+
}
|
|
4791
|
+
const firstSegmentSize = getSegmentSize(firstSegment);
|
|
4792
|
+
const secondSegmentSize = getSegmentSize(secondSegment);
|
|
4793
|
+
const totalSize = firstSegmentSize + secondSegmentSize;
|
|
4794
|
+
if (!firstSegmentSize || !secondSegmentSize || !totalSize) {
|
|
4795
|
+
return undefined;
|
|
4796
|
+
}
|
|
4797
|
+
const firstNestedOffset = firstSegment.groups[0].size / firstSegmentSize * 100;
|
|
4798
|
+
const secondNestedOffset = secondSegment.groups[0].size / secondSegmentSize * 100;
|
|
4799
|
+
if (!offsetsMatch(firstNestedOffset, secondNestedOffset)) {
|
|
4800
|
+
return undefined;
|
|
4801
|
+
}
|
|
4802
|
+
const rootOffset = firstSegmentSize / totalSize * 100;
|
|
4803
|
+
if (layout.direction === Horizontal) {
|
|
4804
|
+
return {
|
|
4805
|
+
leftOffset: rootOffset,
|
|
4806
|
+
topOffset: firstNestedOffset,
|
|
4807
|
+
xAfterGroupIds: secondSegment.groups.map(group => group.id),
|
|
4808
|
+
xBeforeGroupIds: firstSegment.groups.map(group => group.id),
|
|
4809
|
+
yAfterGroupIds: [firstSegment.groups[1].id, secondSegment.groups[1].id],
|
|
4810
|
+
yBeforeGroupIds: [firstSegment.groups[0].id, secondSegment.groups[0].id]
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4813
|
+
return {
|
|
4814
|
+
leftOffset: firstNestedOffset,
|
|
4815
|
+
topOffset: rootOffset,
|
|
4816
|
+
xAfterGroupIds: [firstSegment.groups[1].id, secondSegment.groups[1].id],
|
|
4817
|
+
xBeforeGroupIds: [firstSegment.groups[0].id, secondSegment.groups[0].id],
|
|
4818
|
+
yAfterGroupIds: secondSegment.groups.map(group => group.id),
|
|
4819
|
+
yBeforeGroupIds: firstSegment.groups.map(group => group.id)
|
|
4820
|
+
};
|
|
4821
|
+
};
|
|
4822
|
+
|
|
4823
|
+
const handleSashCornerPointerDown = async (state, clientX, clientY) => {
|
|
4824
|
+
if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
|
|
4825
|
+
return state;
|
|
4826
|
+
}
|
|
4827
|
+
const sashCorner = getSashCorner(state.layout);
|
|
4828
|
+
if (!sashCorner) {
|
|
4829
|
+
return state;
|
|
4830
|
+
}
|
|
4831
|
+
return {
|
|
4832
|
+
...state,
|
|
4833
|
+
sashCornerDrag: {
|
|
4834
|
+
groupSizes: state.layout.groups.map(group => ({
|
|
4835
|
+
id: group.id,
|
|
4836
|
+
size: group.size
|
|
4837
|
+
})),
|
|
4838
|
+
startClientX: clientX,
|
|
4839
|
+
startClientY: clientY,
|
|
4840
|
+
xAfterGroupIds: sashCorner.xAfterGroupIds,
|
|
4841
|
+
xBeforeGroupIds: sashCorner.xBeforeGroupIds,
|
|
4842
|
+
yAfterGroupIds: sashCorner.yAfterGroupIds,
|
|
4843
|
+
yBeforeGroupIds: sashCorner.yBeforeGroupIds
|
|
4844
|
+
}
|
|
4845
|
+
};
|
|
4846
|
+
};
|
|
4847
|
+
|
|
4848
|
+
const clamp = (value, min, max) => {
|
|
4849
|
+
return Math.min(max, Math.max(min, value));
|
|
4850
|
+
};
|
|
4851
|
+
|
|
4852
|
+
const getMinGroupSizePercent = (axisSize, minGroupSizePx) => {
|
|
4853
|
+
if (!axisSize) {
|
|
4854
|
+
return 0;
|
|
4855
|
+
}
|
|
4856
|
+
return minGroupSizePx / axisSize * 100;
|
|
4857
|
+
};
|
|
4858
|
+
|
|
4859
|
+
const round = value => {
|
|
4860
|
+
return Math.round(value * 100) / 100;
|
|
4861
|
+
};
|
|
4862
|
+
|
|
4863
|
+
const sumGroupSizes = (groupSizes, groupIds) => {
|
|
4864
|
+
return groupSizes.reduce((total, group) => total + (groupIds.includes(group.id) ? group.size : 0), 0);
|
|
4865
|
+
};
|
|
4866
|
+
const getBeforeSize = (startSize, deltaPx, axisSize, minSizePx, totalSize) => {
|
|
4867
|
+
let minSize = getMinGroupSizePercent(axisSize, minSizePx);
|
|
4868
|
+
if (2 * minSize > totalSize) {
|
|
4869
|
+
minSize = totalSize / 2;
|
|
4870
|
+
}
|
|
4871
|
+
const deltaSize = deltaPx / axisSize * totalSize;
|
|
4872
|
+
return clamp(startSize + deltaSize, minSize, totalSize - minSize);
|
|
4873
|
+
};
|
|
4874
|
+
const handleSashCornerPointerMove = async (state, clientX, clientY) => {
|
|
4875
|
+
const {
|
|
4876
|
+
height,
|
|
4877
|
+
sashCornerDrag,
|
|
4878
|
+
width
|
|
4879
|
+
} = state;
|
|
4880
|
+
if (!sashCornerDrag || !width || !height || !Number.isFinite(clientX) || !Number.isFinite(clientY)) {
|
|
4881
|
+
return state;
|
|
4882
|
+
}
|
|
4883
|
+
const {
|
|
4884
|
+
groupSizes,
|
|
4885
|
+
startClientX,
|
|
4886
|
+
startClientY,
|
|
4887
|
+
xBeforeGroupIds,
|
|
4888
|
+
yBeforeGroupIds
|
|
4889
|
+
} = sashCornerDrag;
|
|
4890
|
+
const totalSize = groupSizes.reduce((total, group) => total + group.size, 0);
|
|
4891
|
+
if (!totalSize) {
|
|
4892
|
+
return state;
|
|
4893
|
+
}
|
|
4894
|
+
const xBeforeStartSize = sumGroupSizes(groupSizes, xBeforeGroupIds);
|
|
4895
|
+
const yBeforeStartSize = sumGroupSizes(groupSizes, yBeforeGroupIds);
|
|
4896
|
+
const xBeforeSize = getBeforeSize(xBeforeStartSize, clientX - startClientX, width, state.minGroupWidthPx, totalSize);
|
|
4897
|
+
const yBeforeSize = getBeforeSize(yBeforeStartSize, clientY - startClientY, height, state.minGroupHeightPx, totalSize);
|
|
4898
|
+
const xAfterSize = totalSize - xBeforeSize;
|
|
4899
|
+
const yAfterSize = totalSize - yBeforeSize;
|
|
4900
|
+
const xBeforeGroupIdSet = new Set(xBeforeGroupIds);
|
|
4901
|
+
const yBeforeGroupIdSet = new Set(yBeforeGroupIds);
|
|
4902
|
+
return {
|
|
4903
|
+
...state,
|
|
4904
|
+
layout: {
|
|
4905
|
+
...state.layout,
|
|
4906
|
+
groups: state.layout.groups.map(group => {
|
|
4907
|
+
const xSize = xBeforeGroupIdSet.has(group.id) ? xBeforeSize : xAfterSize;
|
|
4908
|
+
const ySize = yBeforeGroupIdSet.has(group.id) ? yBeforeSize : yAfterSize;
|
|
4909
|
+
return {
|
|
4910
|
+
...group,
|
|
4911
|
+
size: round(xSize * ySize / totalSize)
|
|
4912
|
+
};
|
|
4913
|
+
})
|
|
4914
|
+
}
|
|
4915
|
+
};
|
|
4916
|
+
};
|
|
4917
|
+
|
|
4918
|
+
const handleSashCornerPointerUp = async state => {
|
|
4919
|
+
if (!state.sashCornerDrag) {
|
|
4920
|
+
return state;
|
|
4921
|
+
}
|
|
4922
|
+
return {
|
|
4923
|
+
...state,
|
|
4924
|
+
sashCornerDrag: undefined
|
|
4925
|
+
};
|
|
4926
|
+
};
|
|
4927
|
+
|
|
4724
4928
|
const create = (beforeGroupId, afterGroupId) => {
|
|
4725
4929
|
return `${beforeGroupId}:${afterGroupId}`;
|
|
4726
4930
|
};
|
|
@@ -4776,21 +4980,6 @@ const handleSashPointerDown = async (state, sashId, clientX, clientY) => {
|
|
|
4776
4980
|
};
|
|
4777
4981
|
};
|
|
4778
4982
|
|
|
4779
|
-
const clamp = (value, min, max) => {
|
|
4780
|
-
return Math.min(max, Math.max(min, value));
|
|
4781
|
-
};
|
|
4782
|
-
|
|
4783
|
-
const getMinGroupSizePercent = (axisSize, minGroupSizePx) => {
|
|
4784
|
-
if (!axisSize) {
|
|
4785
|
-
return 0;
|
|
4786
|
-
}
|
|
4787
|
-
return minGroupSizePx / axisSize * 100;
|
|
4788
|
-
};
|
|
4789
|
-
|
|
4790
|
-
const round = value => {
|
|
4791
|
-
return Math.round(value * 100) / 100;
|
|
4792
|
-
};
|
|
4793
|
-
|
|
4794
4983
|
const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
4795
4984
|
const {
|
|
4796
4985
|
height,
|
|
@@ -5749,6 +5938,27 @@ const getCss = (layout, width = 0) => {
|
|
|
5749
5938
|
}`, `.SashBorderVertical {
|
|
5750
5939
|
width: 1px;
|
|
5751
5940
|
height: 100%;
|
|
5941
|
+
}`, `.SashCorner {
|
|
5942
|
+
position: absolute;
|
|
5943
|
+
z-index: 2;
|
|
5944
|
+
display: flex;
|
|
5945
|
+
align-items: center;
|
|
5946
|
+
justify-content: center;
|
|
5947
|
+
width: 12px;
|
|
5948
|
+
height: 12px;
|
|
5949
|
+
padding: 0;
|
|
5950
|
+
border: 0;
|
|
5951
|
+
background: transparent;
|
|
5952
|
+
cursor: all-scroll;
|
|
5953
|
+
transform: translate(-50%, -50%);
|
|
5954
|
+
}`, `.SashCorner::after {
|
|
5955
|
+
content: '';
|
|
5956
|
+
width: 4px;
|
|
5957
|
+
height: 4px;
|
|
5958
|
+
background: var(--SashBorder, gray);
|
|
5959
|
+
}`, `.SashCorner:hover::after,
|
|
5960
|
+
.SashCorner:active::after {
|
|
5961
|
+
background: var(--SashHoverBorder, #3d5252);
|
|
5752
5962
|
}`, `.EditorGroup {
|
|
5753
5963
|
min-width: 250px;
|
|
5754
5964
|
width: var(--EditorGroupWidth, auto);
|
|
@@ -5756,6 +5966,13 @@ const getCss = (layout, width = 0) => {
|
|
|
5756
5966
|
}`];
|
|
5757
5967
|
if (layout) {
|
|
5758
5968
|
rules.push(...getEditorGroupCss(layout), ...getSashCss(layout, width));
|
|
5969
|
+
const sashCorner = getSashCorner(layout);
|
|
5970
|
+
if (sashCorner) {
|
|
5971
|
+
rules.push(`.SashCorner {
|
|
5972
|
+
left: ${sashCorner.leftOffset}%;
|
|
5973
|
+
top: ${sashCorner.topOffset}%;
|
|
5974
|
+
}`);
|
|
5975
|
+
}
|
|
5759
5976
|
}
|
|
5760
5977
|
const css = rules.join('\n');
|
|
5761
5978
|
return css;
|
|
@@ -6052,6 +6269,9 @@ const HandleSashPointerDown = 16;
|
|
|
6052
6269
|
const HandleSashPointerMove = 17;
|
|
6053
6270
|
const HandleSashPointerUp = 18;
|
|
6054
6271
|
const HandleDoubleClick = 19;
|
|
6272
|
+
const HandleSashCornerPointerDown = 20;
|
|
6273
|
+
const HandleSashCornerPointerMove = 21;
|
|
6274
|
+
const HandleSashCornerPointerUp = 22;
|
|
6055
6275
|
|
|
6056
6276
|
const renderContent = content => {
|
|
6057
6277
|
return [{
|
|
@@ -6397,6 +6617,16 @@ const renderSash = (direction, sashId) => {
|
|
|
6397
6617
|
}];
|
|
6398
6618
|
};
|
|
6399
6619
|
|
|
6620
|
+
const renderSashCorner = () => {
|
|
6621
|
+
return {
|
|
6622
|
+
childCount: 0,
|
|
6623
|
+
className: 'SashCorner',
|
|
6624
|
+
onPointerDown: HandleSashCornerPointerDown,
|
|
6625
|
+
role: None$1,
|
|
6626
|
+
type: Button$2
|
|
6627
|
+
};
|
|
6628
|
+
};
|
|
6629
|
+
|
|
6400
6630
|
const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
|
|
6401
6631
|
return [{
|
|
6402
6632
|
childCount: 1,
|
|
@@ -6504,16 +6734,18 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
6504
6734
|
childCount,
|
|
6505
6735
|
children
|
|
6506
6736
|
} = renderSegmentChildren(direction, groups, splitButtonEnabled);
|
|
6737
|
+
const sashCorner = getSashCorner(layout);
|
|
6738
|
+
const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
|
|
6507
6739
|
return [{
|
|
6508
6740
|
childCount: 1,
|
|
6509
6741
|
className: Main,
|
|
6510
6742
|
type: Div
|
|
6511
6743
|
}, {
|
|
6512
|
-
childCount,
|
|
6744
|
+
childCount: childCount + sashCornerChildren.length,
|
|
6513
6745
|
className: editorGroupsContainerClassName,
|
|
6514
6746
|
role: None$1,
|
|
6515
6747
|
type: Div
|
|
6516
|
-
}, ...children];
|
|
6748
|
+
}, ...children, ...sashCornerChildren];
|
|
6517
6749
|
};
|
|
6518
6750
|
|
|
6519
6751
|
const renderItems = (oldState, newState) => {
|
|
@@ -6621,6 +6853,17 @@ const renderEventListeners = () => {
|
|
|
6621
6853
|
}, {
|
|
6622
6854
|
name: HandleSashPointerUp,
|
|
6623
6855
|
params: ['handleSashPointerUp', ClientX, ClientY]
|
|
6856
|
+
}, {
|
|
6857
|
+
name: HandleSashCornerPointerDown,
|
|
6858
|
+
params: ['handleSashCornerPointerDown', ClientX, ClientY],
|
|
6859
|
+
preventDefault: true,
|
|
6860
|
+
trackPointerEvents: [HandleSashCornerPointerMove, HandleSashCornerPointerUp]
|
|
6861
|
+
}, {
|
|
6862
|
+
name: HandleSashCornerPointerMove,
|
|
6863
|
+
params: ['handleSashCornerPointerMove', ClientX, ClientY]
|
|
6864
|
+
}, {
|
|
6865
|
+
name: HandleSashCornerPointerUp,
|
|
6866
|
+
params: ['handleSashCornerPointerUp', ClientX, ClientY]
|
|
6624
6867
|
}];
|
|
6625
6868
|
};
|
|
6626
6869
|
|
|
@@ -7204,6 +7447,9 @@ const commandMap = {
|
|
|
7204
7447
|
'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
|
|
7205
7448
|
'MainArea.handleResize': wrapGetter(handleResize),
|
|
7206
7449
|
// TODO would need to have a function that returns newstate as well as commands
|
|
7450
|
+
'MainArea.handleSashCornerPointerDown': wrapSerialCommand(handleSashCornerPointerDown),
|
|
7451
|
+
'MainArea.handleSashCornerPointerMove': wrapSerialCommand(handleSashCornerPointerMove),
|
|
7452
|
+
'MainArea.handleSashCornerPointerUp': wrapSerialCommand(handleSashCornerPointerUp),
|
|
7207
7453
|
'MainArea.handleSashPointerDown': wrapSerialCommand(handleSashPointerDown),
|
|
7208
7454
|
'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
|
|
7209
7455
|
'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
|