@lvce-editor/main-area-worker 9.33.0 → 9.33.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.
@@ -1493,6 +1493,7 @@ const VirtualDomElements = {
1493
1493
  const Button$1 = 'event.button';
1494
1494
  const ClientX = 'event.clientX';
1495
1495
  const ClientY = 'event.clientY';
1496
+ const DataTransferFiles2 = 'event.dataTransfer.files2';
1496
1497
  const EventTargetClassName = 'event.target.className';
1497
1498
  const TargetName = 'event.target.name';
1498
1499
 
@@ -1553,6 +1554,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1553
1554
  number(y);
1554
1555
  await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1555
1556
  };
1557
+ const getFileHandles = async fileIds => {
1558
+ const files = await invoke('FileSystemHandle.getFileHandles', fileIds);
1559
+ return files;
1560
+ };
1556
1561
  const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1557
1562
  const command = 'ClipBoard.handleMessagePort';
1558
1563
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
@@ -4081,11 +4086,14 @@ const updateIconCache = (iconCache, missingRequests, newIcons) => {
4081
4086
  return newFileIconCache;
4082
4087
  };
4083
4088
 
4089
+ const getUri = tab => {
4090
+ return tab.uri || '';
4091
+ };
4084
4092
  const getFileIconsForTabs = async (tabs, fileIconCache) => {
4085
4093
  const missingRequests = getMissingIconRequestsForTabs(tabs, fileIconCache);
4086
4094
  const newIcons = await requestFileIcons(missingRequests);
4087
4095
  const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
4088
- const tabUris = tabs.map(tab => tab.uri || '');
4096
+ const tabUris = tabs.map(getUri);
4089
4097
  const icons = getIconsCached(tabUris, newFileIconCache);
4090
4098
  return {
4091
4099
  icons,
@@ -4633,23 +4641,6 @@ const Down = 2;
4633
4641
  const Left = 3;
4634
4642
  const Right = 4;
4635
4643
 
4636
- const getSplitDirection = (x, y, width, height) => {
4637
- const percentX = x / width;
4638
- if (percentX < 0.25) {
4639
- return Left;
4640
- }
4641
- if (percentX > 0.75) {
4642
- return Right;
4643
- }
4644
- const percentY = y / height;
4645
- if (percentY < 0.25) {
4646
- return Up;
4647
- }
4648
- if (percentY > 0.75) {
4649
- return Down;
4650
- }
4651
- return None;
4652
- };
4653
4644
  const getOverlay = (x, y, width, height, splitDirection) => {
4654
4645
  const halfHeight = height / 2;
4655
4646
  const halfWidth = width / 2;
@@ -4691,6 +4682,25 @@ const getOverlay = (x, y, width, height, splitDirection) => {
4691
4682
  };
4692
4683
  }
4693
4684
  };
4685
+
4686
+ const getSplitDirection = (x, y, width, height) => {
4687
+ const percentX = x / width;
4688
+ if (percentX < 0.25) {
4689
+ return Left;
4690
+ }
4691
+ if (percentX > 0.75) {
4692
+ return Right;
4693
+ }
4694
+ const percentY = y / height;
4695
+ if (percentY < 0.25) {
4696
+ return Up;
4697
+ }
4698
+ if (percentY > 0.75) {
4699
+ return Down;
4700
+ }
4701
+ return None;
4702
+ };
4703
+
4694
4704
  const getDragOverlay = (state, eventX, eventY) => {
4695
4705
  const {
4696
4706
  height,
@@ -4726,6 +4736,37 @@ const handleDragOver = (state, eventX, eventY) => {
4726
4736
  };
4727
4737
  };
4728
4738
 
4739
+ const lineSeparatorRegex = /\r?\n/;
4740
+ const isUriList = item => {
4741
+ if (!item || typeof item !== 'object') {
4742
+ return false;
4743
+ }
4744
+ const candidate = item;
4745
+ return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
4746
+ };
4747
+ const parseUriList = value => {
4748
+ return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4749
+ };
4750
+ const getDroppedUris = async itemIds => {
4751
+ if (itemIds.length === 0) {
4752
+ return [];
4753
+ }
4754
+ const items = await getFileHandles(itemIds);
4755
+ return items.filter(isUriList).flatMap(item => parseUriList(item.value));
4756
+ };
4757
+
4758
+ const openUrisWithContext = async (context, uris) => {
4759
+ for (const uri of uris) {
4760
+ await openUriWithContext(context, uri);
4761
+ }
4762
+ };
4763
+
4764
+ const handleDrop = async (context, itemIds) => {
4765
+ await context.updateState(handleDragLeave);
4766
+ const uris = await getDroppedUris(itemIds);
4767
+ await openUrisWithContext(context, uris);
4768
+ };
4769
+
4729
4770
  const EditorGroupHeader = 'EditorGroupHeader';
4730
4771
  const EmptyGroupHeader = 'EmptyGroupHeader';
4731
4772
  const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
@@ -6063,12 +6104,6 @@ const newWindow = async state => {
6063
6104
  return state;
6064
6105
  };
6065
6106
 
6066
- const openUrisWithContext = async (context, uris) => {
6067
- for (const uri of uris) {
6068
- await openUriWithContext(context, uri);
6069
- }
6070
- };
6071
-
6072
6107
  const refresh = state => {
6073
6108
  return {
6074
6109
  ...state
@@ -7182,7 +7217,7 @@ const renderEventListeners = () => {
7182
7217
  params: ['handleDragLeave']
7183
7218
  }, {
7184
7219
  name: HandleDrop,
7185
- params: ['handleDragLeave'],
7220
+ params: ['handleDrop', DataTransferFiles2],
7186
7221
  preventDefault: true
7187
7222
  }];
7188
7223
  };
@@ -7803,6 +7838,7 @@ const commandMap = {
7803
7838
  'MainArea.handleDoubleClick': wrapSerialCommand(handleDoubleClick),
7804
7839
  'MainArea.handleDragLeave': wrapSerialCommand(handleDragLeave),
7805
7840
  'MainArea.handleDragOver': wrapSerialCommand(handleDragOver),
7841
+ 'MainArea.handleDrop': wrapSerialAsyncCommand(handleDrop),
7806
7842
  'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
7807
7843
  'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
7808
7844
  'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.33.0",
3
+ "version": "9.33.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",