@lvce-editor/main-area-worker 9.35.1 → 9.35.2

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.
@@ -1438,6 +1438,7 @@ const VirtualDomElements = {
1438
1438
  const Button$1 = 'event.button';
1439
1439
  const ClientX = 'event.clientX';
1440
1440
  const ClientY = 'event.clientY';
1441
+ const DataTransferFiles = 'event.dataTransfer.files';
1441
1442
  const DataTransferFiles2 = 'event.dataTransfer.files2';
1442
1443
  const EventTargetClassName = 'event.target.className';
1443
1444
  const TargetName = 'event.target.name';
@@ -1452,6 +1453,7 @@ const Add$1 = 6;
1452
1453
  const NavigateChild$1 = 7;
1453
1454
  const NavigateParent$1 = 8;
1454
1455
 
1456
+ const Web = 1;
1455
1457
  const Electron = 2;
1456
1458
 
1457
1459
  const ClipBoardWorker = 3400;
@@ -4839,11 +4841,37 @@ const parseUriList = value => {
4839
4841
  return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4840
4842
  };
4841
4843
 
4844
+ const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
4845
+ const encodeFilePath = path => {
4846
+ return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
4847
+ };
4848
+ const toFileUri$1 = path => {
4849
+ if (path.startsWith('file://')) {
4850
+ return path;
4851
+ }
4852
+ if (windowsDriveLetterRegex.test(path)) {
4853
+ const normalizedPath = path.replaceAll('\\', '/');
4854
+ return `file:///${encodeFilePath(normalizedPath)}`;
4855
+ }
4856
+ return `file://${encodeFilePath(path)}`;
4857
+ };
4858
+
4842
4859
  const suffixByHandleKind = {
4843
4860
  directory: '/',
4844
4861
  file: ''
4845
4862
  };
4846
- const getDroppedUris = async itemIds => {
4863
+ const getDroppedElectronUris = async (itemIds, files) => {
4864
+ if (itemIds.length > 0) {
4865
+ await getFileHandles(itemIds);
4866
+ }
4867
+ const uris = [];
4868
+ for (const file of files) {
4869
+ const path = await invoke('FileSystemHandle.getFilePathElectron', file);
4870
+ uris.push(toFileUri$1(path));
4871
+ }
4872
+ return uris;
4873
+ };
4874
+ const getDroppedBrowserUris = async itemIds => {
4847
4875
  if (itemIds.length === 0) {
4848
4876
  return [];
4849
4877
  }
@@ -4883,6 +4911,12 @@ const getDroppedUris = async itemIds => {
4883
4911
  }
4884
4912
  return uris;
4885
4913
  };
4914
+ const getDroppedUris = async (itemIds, files = [], platform = Web) => {
4915
+ if (platform === Electron && files.length > 0) {
4916
+ return getDroppedElectronUris(itemIds, files);
4917
+ }
4918
+ return getDroppedBrowserUris(itemIds);
4919
+ };
4886
4920
 
4887
4921
  const openUrisWithContext = async (context, uris) => {
4888
4922
  for (const uri of uris) {
@@ -4890,9 +4924,12 @@ const openUrisWithContext = async (context, uris) => {
4890
4924
  }
4891
4925
  };
4892
4926
 
4893
- const handleDrop = async (context, itemIds) => {
4927
+ const handleDrop = async (context, itemIds, files = []) => {
4894
4928
  await context.updateState(handleDragLeave);
4895
- const uris = await getDroppedUris(itemIds);
4929
+ const {
4930
+ platform
4931
+ } = context.getState();
4932
+ const uris = await getDroppedUris(itemIds, files, platform);
4896
4933
  for (const uri of uris) {
4897
4934
  if (uri.endsWith('/') || (await isDirectoryEditorInput({
4898
4935
  type: 'editor',
@@ -7353,7 +7390,7 @@ const renderEventListeners = () => {
7353
7390
  params: ['handleDragLeave']
7354
7391
  }, {
7355
7392
  name: HandleDrop,
7356
- params: ['handleDrop', DataTransferFiles2],
7393
+ params: ['handleDrop', DataTransferFiles2, DataTransferFiles],
7357
7394
  preventDefault: true
7358
7395
  }];
7359
7396
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.35.1",
3
+ "version": "9.35.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",