@lvce-editor/main-area-worker 9.34.0 → 9.34.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.
@@ -4776,6 +4776,9 @@ const getSplitDirection = (x, y, width, height) => {
4776
4776
  return None;
4777
4777
  };
4778
4778
 
4779
+ const isNotEmpty = group => {
4780
+ return !group.isEmpty;
4781
+ };
4779
4782
  const getDragOverlay = (state, eventX, eventY) => {
4780
4783
  const {
4781
4784
  height,
@@ -4788,7 +4791,7 @@ const getDragOverlay = (state, eventX, eventY) => {
4788
4791
  const {
4789
4792
  groups
4790
4793
  } = layout;
4791
- const hasOpenEditor = groups.some(group => !group.isEmpty);
4794
+ const hasOpenEditor = groups.some(isNotEmpty);
4792
4795
  const contentY = hasOpenEditor ? tabHeight : 0;
4793
4796
  const contentHeight = Math.max(0, height - contentY);
4794
4797
  const relativeX = eventX - x;
@@ -4815,6 +4818,7 @@ const handleDragOver = (state, eventX, eventY) => {
4815
4818
  };
4816
4819
 
4817
4820
  const lineSeparatorRegex = /\r?\n/;
4821
+ const chromiumDragIdRegex = /^[A-F\d]{32}$/i;
4818
4822
  const isUriList = item => {
4819
4823
  if (!item || typeof item !== 'object') {
4820
4824
  return false;
@@ -4825,12 +4829,37 @@ const isUriList = item => {
4825
4829
  const parseUriList = value => {
4826
4830
  return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4827
4831
  };
4832
+ const isChromiumDragId = item => {
4833
+ if (!item || typeof item !== 'object') {
4834
+ return false;
4835
+ }
4836
+ const candidate = item;
4837
+ return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
4838
+ };
4839
+ const isDragInfoItem = item => {
4840
+ if (!item || typeof item !== 'object') {
4841
+ return false;
4842
+ }
4843
+ const candidate = item;
4844
+ return candidate.type === 'text/uri-list' && typeof candidate.data === 'string';
4845
+ };
4846
+ const getUrisFromDragInfo = dragInfo => {
4847
+ if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
4848
+ return [];
4849
+ }
4850
+ return dragInfo.items.filter(isDragInfoItem).flatMap(item => parseUriList(item.data));
4851
+ };
4828
4852
  const getDroppedUris = async itemIds => {
4829
4853
  if (itemIds.length === 0) {
4830
4854
  return [];
4831
4855
  }
4832
4856
  const items = await getFileHandles(itemIds);
4833
- return items.filter(isUriList).flatMap(item => parseUriList(item.value));
4857
+ const uris = items.filter(isUriList).flatMap(item => parseUriList(item.value));
4858
+ if (uris.length > 0 || !items.some(isChromiumDragId)) {
4859
+ return uris;
4860
+ }
4861
+ const dragInfo = await invoke('Viewlet.getDragData');
4862
+ return getUrisFromDragInfo(dragInfo);
4834
4863
  };
4835
4864
 
4836
4865
  const openUrisWithContext = async (context, uris) => {
@@ -5096,6 +5125,13 @@ const handleModifiedStatusChangeWithContext = async (context, uri, newStatus) =>
5096
5125
  await context.updateState(state => handleModifiedStatusChange(state, uri, newStatus));
5097
5126
  };
5098
5127
 
5128
+ const resizeChild = async (editorUid, dimensions) => {
5129
+ try {
5130
+ return await invoke('Viewlet.resize', editorUid, dimensions);
5131
+ } catch {
5132
+ return [];
5133
+ }
5134
+ };
5099
5135
  const handleResize = async (state, dimensions) => {
5100
5136
  const {
5101
5137
  height,
@@ -5113,25 +5149,22 @@ const handleResize = async (state, dimensions) => {
5113
5149
  groups
5114
5150
  } = layout;
5115
5151
  const contentHeight = height - tabHeight;
5116
- const allResizeCommands = [];
5117
- for (const group of groups) {
5118
- for (const tab of group.tabs) {
5119
- if (tab.editorUid !== -1) {
5120
- try {
5121
- const resizeCommands = await invoke('Viewlet.resize', tab.editorUid, {
5122
- height: contentHeight,
5123
- width,
5124
- x,
5125
- y: y + tabHeight
5126
- });
5127
- allResizeCommands.push(...resizeCommands);
5128
- } catch {
5129
- // ignore
5130
- }
5131
- }
5152
+ const resizePromises = [];
5153
+ const tabs = groups.flatMap(group => group.tabs);
5154
+ for (const tab of tabs) {
5155
+ if (tab.editorUid === -1) {
5156
+ continue;
5132
5157
  }
5158
+ const resizePromise = resizeChild(tab.editorUid, {
5159
+ height: contentHeight,
5160
+ width,
5161
+ x,
5162
+ y: y + tabHeight
5163
+ });
5164
+ resizePromises.push(resizePromise);
5133
5165
  }
5134
- return allResizeCommands;
5166
+ const resizeCommands = await Promise.all(resizePromises);
5167
+ return resizeCommands.flat();
5135
5168
  };
5136
5169
 
5137
5170
  const offsetsMatch = (first, second) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.34.0",
3
+ "version": "9.34.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",