@lvce-editor/main-area-worker 9.34.2 → 9.35.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.
@@ -957,9 +957,9 @@ const create$d = (id, method, params) => {
957
957
  return message;
958
958
  };
959
959
 
960
- let id$1 = 0;
960
+ let id = 0;
961
961
  const create$c = () => {
962
- return ++id$1;
962
+ return ++id;
963
963
  };
964
964
 
965
965
  const registerPromise = map => {
@@ -1214,7 +1214,7 @@ const createMockRpc = ({
1214
1214
  };
1215
1215
 
1216
1216
  const rpcs = Object.create(null);
1217
- const set$6 = (id, rpc) => {
1217
+ const set$5 = (id, rpc) => {
1218
1218
  rpcs[id] = rpc;
1219
1219
  };
1220
1220
  const get$1 = id => {
@@ -1247,7 +1247,7 @@ const create$4 = rpcId => {
1247
1247
  const mockRpc = createMockRpc({
1248
1248
  commandMap
1249
1249
  });
1250
- set$6(rpcId, mockRpc);
1250
+ set$5(rpcId, mockRpc);
1251
1251
  // @ts-ignore
1252
1252
  mockRpc[Symbol.dispose] = () => {
1253
1253
  remove(rpcId);
@@ -1256,7 +1256,7 @@ const create$4 = rpcId => {
1256
1256
  return mockRpc;
1257
1257
  },
1258
1258
  set(rpc) {
1259
- set$6(rpcId, rpc);
1259
+ set$5(rpcId, rpc);
1260
1260
  }
1261
1261
  };
1262
1262
  };
@@ -1456,7 +1456,6 @@ const Electron = 2;
1456
1456
 
1457
1457
  const ClipBoardWorker = 3400;
1458
1458
  const DialogWorker = 7014;
1459
- const ExtensionHostWorker = 44;
1460
1459
  const IconThemeWorker = 7009;
1461
1460
  const RendererWorker = 1;
1462
1461
 
@@ -1467,17 +1466,13 @@ const SetPatches = 'Viewlet.setPatches';
1467
1466
  const FocusEditorText = 12;
1468
1467
 
1469
1468
  const {
1470
- set: set$5
1469
+ set: set$4
1471
1470
  } = create$4(ClipBoardWorker);
1472
1471
 
1473
1472
  const {
1474
1473
  invoke: invoke$2,
1475
- set: set$4
1476
- } = create$4(DialogWorker);
1477
-
1478
- const {
1479
1474
  set: set$3
1480
- } = create$4(ExtensionHostWorker);
1475
+ } = create$4(DialogWorker);
1481
1476
 
1482
1477
  const {
1483
1478
  invoke: invoke$1,
@@ -1577,10 +1572,6 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1577
1572
  const readFile = async uri => {
1578
1573
  return invoke('FileSystem.readFile', uri);
1579
1574
  };
1580
- const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1581
- const command = 'HandleMessagePort.handleMessagePort2';
1582
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1583
- };
1584
1575
  const confirm$1 = async (message, options) => {
1585
1576
  const result = await invoke('ConfirmPrompt.prompt', message, options);
1586
1577
  return result;
@@ -4817,32 +4808,40 @@ const handleDragOver = (state, eventX, eventY) => {
4817
4808
  };
4818
4809
  };
4819
4810
 
4820
- const lineSeparatorRegex = /\r?\n/;
4821
4811
  const chromiumDragIdRegex = /^[A-F\d]{32}$/i;
4822
- const isUriList = item => {
4812
+ const isChromiumDragId = item => {
4823
4813
  if (!item || typeof item !== 'object') {
4824
4814
  return false;
4825
4815
  }
4826
4816
  const candidate = item;
4827
- return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
4828
- };
4829
- const parseUriList = value => {
4830
- return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4817
+ return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
4831
4818
  };
4832
- const isChromiumDragId = item => {
4819
+
4820
+ const isDroppedFileSystemHandle = item => {
4833
4821
  if (!item || typeof item !== 'object') {
4834
4822
  return false;
4835
4823
  }
4836
4824
  const candidate = item;
4837
- return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
4825
+ const handle = candidate.value;
4826
+ return candidate.kind === 'file' && Boolean(handle) && typeof handle === 'object' && (handle.kind === 'directory' || handle.kind === 'file') && typeof handle.name === 'string';
4838
4827
  };
4839
- const isDroppedFile = item => {
4828
+
4829
+ const isUriList = item => {
4840
4830
  if (!item || typeof item !== 'object') {
4841
4831
  return false;
4842
4832
  }
4843
4833
  const candidate = item;
4844
- const handle = candidate.value;
4845
- return candidate.kind === 'file' && Boolean(handle) && typeof handle === 'object' && handle.kind === 'file' && typeof handle.name === 'string';
4834
+ return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
4835
+ };
4836
+
4837
+ const lineSeparatorRegex = /\r?\n/;
4838
+ const parseUriList = value => {
4839
+ return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4840
+ };
4841
+
4842
+ const suffixByHandleKind = {
4843
+ directory: '/',
4844
+ file: ''
4846
4845
  };
4847
4846
  const getDroppedUris = async itemIds => {
4848
4847
  if (itemIds.length === 0) {
@@ -4851,7 +4850,7 @@ const getDroppedUris = async itemIds => {
4851
4850
  const items = await getFileHandles(itemIds);
4852
4851
  let hasChromiumDragId = false;
4853
4852
  const uris = [];
4854
- for (const item of items) {
4853
+ for (const [index, item] of items.entries()) {
4855
4854
  if (isUriList(item)) {
4856
4855
  uris.push(...parseUriList(item.value));
4857
4856
  continue;
@@ -4860,11 +4859,12 @@ const getDroppedUris = async itemIds => {
4860
4859
  hasChromiumDragId = true;
4861
4860
  continue;
4862
4861
  }
4863
- if (!isDroppedFile(item)) {
4862
+ if (!isDroppedFileSystemHandle(item)) {
4864
4863
  continue;
4865
4864
  }
4866
4865
  const handle = item.value;
4867
- const uri = `html:///dropped-files/${handle.name}`;
4866
+ const suffix = suffixByHandleKind[handle.kind];
4867
+ const uri = `html:///dropped-files/${Date.now()}/${itemIds[index]}/${handle.name}${suffix}`;
4868
4868
  await invoke('PersistentFileHandle.addHandle', uri, handle);
4869
4869
  uris.push(uri);
4870
4870
  }
@@ -4873,7 +4873,7 @@ const getDroppedUris = async itemIds => {
4873
4873
  }
4874
4874
  const dragInfo = await invoke('Viewlet.getDragData');
4875
4875
  if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
4876
- return [];
4876
+ return uris;
4877
4877
  }
4878
4878
  for (const item of dragInfo.items) {
4879
4879
  const candidate = item;
@@ -4893,6 +4893,16 @@ const openUrisWithContext = async (context, uris) => {
4893
4893
  const handleDrop = async (context, itemIds) => {
4894
4894
  await context.updateState(handleDragLeave);
4895
4895
  const uris = await getDroppedUris(itemIds);
4896
+ for (const uri of uris) {
4897
+ if (uri.endsWith('/') || (await isDirectoryEditorInput({
4898
+ type: 'editor',
4899
+ uri
4900
+ }))) {
4901
+ const command = uri.startsWith('file://') ? 'Workspace.setUri' : 'Workspace.setPath';
4902
+ void invoke(command, uri).catch(() => {});
4903
+ return;
4904
+ }
4905
+ }
4896
4906
  await openUrisWithContext(context, uris);
4897
4907
  };
4898
4908
 
@@ -5862,26 +5872,8 @@ const hasActiveTextEditor = state => {
5862
5872
  return activeTab?.tab.editorInput?.type === 'editor';
5863
5873
  };
5864
5874
 
5865
- const id = 7201;
5866
- const sendMessagePortToExtensionHostWorker = async port => {
5867
- await sendMessagePortToExtensionHostWorker$1(port, id);
5868
- };
5869
-
5870
- const createExtensionHostRpc = async () => {
5871
- try {
5872
- const rpc = await create$9({
5873
- commandMap: {},
5874
- send: sendMessagePortToExtensionHostWorker
5875
- });
5876
- return rpc;
5877
- } catch (error) {
5878
- throw new VError(error, `Failed to create extension host rpc`);
5879
- }
5880
- };
5881
-
5882
5875
  const initialize = async () => {
5883
- const rpc = await createExtensionHostRpc();
5884
- set$3(rpc);
5876
+ // Kept as a compatibility command for existing renderer startup code.
5885
5877
  };
5886
5878
 
5887
5879
  const hasTargetGroup = groupId => {
@@ -8075,7 +8067,7 @@ const initializeClipBoardWorker = async () => {
8075
8067
  commandMap: {},
8076
8068
  send: sendMessagePortToClipBoardWorker
8077
8069
  });
8078
- set$5(rpc);
8070
+ set$4(rpc);
8079
8071
  };
8080
8072
 
8081
8073
  const send = port => {
@@ -8125,7 +8117,7 @@ const listen = async () => {
8125
8117
  commandMap: {},
8126
8118
  send: sendMessagePortToDialogWorker
8127
8119
  });
8128
- set$4(dialogRpc);
8120
+ set$3(dialogRpc);
8129
8121
  };
8130
8122
 
8131
8123
  const main$1 = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.34.2",
3
+ "version": "9.35.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",