@lvce-editor/main-area-worker 9.34.2 → 9.35.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 +34 -15
- package/package.json +1 -1
|
@@ -4817,32 +4817,40 @@ const handleDragOver = (state, eventX, eventY) => {
|
|
|
4817
4817
|
};
|
|
4818
4818
|
};
|
|
4819
4819
|
|
|
4820
|
-
const lineSeparatorRegex = /\r?\n/;
|
|
4821
4820
|
const chromiumDragIdRegex = /^[A-F\d]{32}$/i;
|
|
4822
|
-
const
|
|
4821
|
+
const isChromiumDragId = item => {
|
|
4823
4822
|
if (!item || typeof item !== 'object') {
|
|
4824
4823
|
return false;
|
|
4825
4824
|
}
|
|
4826
4825
|
const candidate = item;
|
|
4827
|
-
return candidate.kind === 'string' && candidate.type === '
|
|
4828
|
-
};
|
|
4829
|
-
const parseUriList = value => {
|
|
4830
|
-
return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
|
|
4826
|
+
return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
|
|
4831
4827
|
};
|
|
4832
|
-
|
|
4828
|
+
|
|
4829
|
+
const isDroppedFileSystemHandle = item => {
|
|
4833
4830
|
if (!item || typeof item !== 'object') {
|
|
4834
4831
|
return false;
|
|
4835
4832
|
}
|
|
4836
4833
|
const candidate = item;
|
|
4837
|
-
|
|
4834
|
+
const handle = candidate.value;
|
|
4835
|
+
return candidate.kind === 'file' && Boolean(handle) && typeof handle === 'object' && (handle.kind === 'directory' || handle.kind === 'file') && typeof handle.name === 'string';
|
|
4838
4836
|
};
|
|
4839
|
-
|
|
4837
|
+
|
|
4838
|
+
const isUriList = item => {
|
|
4840
4839
|
if (!item || typeof item !== 'object') {
|
|
4841
4840
|
return false;
|
|
4842
4841
|
}
|
|
4843
4842
|
const candidate = item;
|
|
4844
|
-
|
|
4845
|
-
|
|
4843
|
+
return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
|
|
4844
|
+
};
|
|
4845
|
+
|
|
4846
|
+
const lineSeparatorRegex = /\r?\n/;
|
|
4847
|
+
const parseUriList = value => {
|
|
4848
|
+
return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
|
|
4849
|
+
};
|
|
4850
|
+
|
|
4851
|
+
const suffixByHandleKind = {
|
|
4852
|
+
directory: '/',
|
|
4853
|
+
file: ''
|
|
4846
4854
|
};
|
|
4847
4855
|
const getDroppedUris = async itemIds => {
|
|
4848
4856
|
if (itemIds.length === 0) {
|
|
@@ -4851,7 +4859,7 @@ const getDroppedUris = async itemIds => {
|
|
|
4851
4859
|
const items = await getFileHandles(itemIds);
|
|
4852
4860
|
let hasChromiumDragId = false;
|
|
4853
4861
|
const uris = [];
|
|
4854
|
-
for (const item of items) {
|
|
4862
|
+
for (const [index, item] of items.entries()) {
|
|
4855
4863
|
if (isUriList(item)) {
|
|
4856
4864
|
uris.push(...parseUriList(item.value));
|
|
4857
4865
|
continue;
|
|
@@ -4860,11 +4868,12 @@ const getDroppedUris = async itemIds => {
|
|
|
4860
4868
|
hasChromiumDragId = true;
|
|
4861
4869
|
continue;
|
|
4862
4870
|
}
|
|
4863
|
-
if (!
|
|
4871
|
+
if (!isDroppedFileSystemHandle(item)) {
|
|
4864
4872
|
continue;
|
|
4865
4873
|
}
|
|
4866
4874
|
const handle = item.value;
|
|
4867
|
-
const
|
|
4875
|
+
const suffix = suffixByHandleKind[handle.kind];
|
|
4876
|
+
const uri = `html:///dropped-files/${Date.now()}/${itemIds[index]}/${handle.name}${suffix}`;
|
|
4868
4877
|
await invoke('PersistentFileHandle.addHandle', uri, handle);
|
|
4869
4878
|
uris.push(uri);
|
|
4870
4879
|
}
|
|
@@ -4873,7 +4882,7 @@ const getDroppedUris = async itemIds => {
|
|
|
4873
4882
|
}
|
|
4874
4883
|
const dragInfo = await invoke('Viewlet.getDragData');
|
|
4875
4884
|
if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
|
|
4876
|
-
return
|
|
4885
|
+
return uris;
|
|
4877
4886
|
}
|
|
4878
4887
|
for (const item of dragInfo.items) {
|
|
4879
4888
|
const candidate = item;
|
|
@@ -4893,6 +4902,16 @@ const openUrisWithContext = async (context, uris) => {
|
|
|
4893
4902
|
const handleDrop = async (context, itemIds) => {
|
|
4894
4903
|
await context.updateState(handleDragLeave);
|
|
4895
4904
|
const uris = await getDroppedUris(itemIds);
|
|
4905
|
+
for (const uri of uris) {
|
|
4906
|
+
if (uri.endsWith('/') || (await isDirectoryEditorInput({
|
|
4907
|
+
type: 'editor',
|
|
4908
|
+
uri
|
|
4909
|
+
}))) {
|
|
4910
|
+
const command = uri.startsWith('file://') ? 'Workspace.setUri' : 'Workspace.setPath';
|
|
4911
|
+
void invoke(command, uri).catch(() => {});
|
|
4912
|
+
return;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4896
4915
|
await openUrisWithContext(context, uris);
|
|
4897
4916
|
};
|
|
4898
4917
|
|