@lvce-editor/main-area-worker 9.34.1 → 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 +114 -73
- package/package.json +1 -1
|
@@ -54,61 +54,6 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
class AssertionError extends Error {
|
|
58
|
-
constructor(message) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = 'AssertionError';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const Object$1 = 1;
|
|
64
|
-
const Number$1 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
66
|
-
const String$1 = 4;
|
|
67
|
-
const Boolean$1 = 5;
|
|
68
|
-
const Function = 6;
|
|
69
|
-
const Null = 7;
|
|
70
|
-
const Unknown = 8;
|
|
71
|
-
const getType = value => {
|
|
72
|
-
switch (typeof value) {
|
|
73
|
-
case 'number':
|
|
74
|
-
return Number$1;
|
|
75
|
-
case 'function':
|
|
76
|
-
return Function;
|
|
77
|
-
case 'string':
|
|
78
|
-
return String$1;
|
|
79
|
-
case 'object':
|
|
80
|
-
if (value === null) {
|
|
81
|
-
return Null;
|
|
82
|
-
}
|
|
83
|
-
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
85
|
-
}
|
|
86
|
-
return Object$1;
|
|
87
|
-
case 'boolean':
|
|
88
|
-
return Boolean$1;
|
|
89
|
-
default:
|
|
90
|
-
return Unknown;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const object = value => {
|
|
94
|
-
const type = getType(value);
|
|
95
|
-
if (type !== Object$1) {
|
|
96
|
-
throw new AssertionError('expected value to be of type object');
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const number = value => {
|
|
100
|
-
const type = getType(value);
|
|
101
|
-
if (type !== Number$1) {
|
|
102
|
-
throw new AssertionError('expected value to be of type number');
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const string = value => {
|
|
106
|
-
const type = getType(value);
|
|
107
|
-
if (type !== String$1) {
|
|
108
|
-
throw new AssertionError('expected value to be of type string');
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
57
|
const isMessagePort = value => {
|
|
113
58
|
return value && value instanceof MessagePort;
|
|
114
59
|
};
|
|
@@ -1543,6 +1488,61 @@ const getIcons = async iconRequests => {
|
|
|
1543
1488
|
return invoke$1('IconTheme.getIcons', iconRequests);
|
|
1544
1489
|
};
|
|
1545
1490
|
|
|
1491
|
+
class AssertionError extends Error {
|
|
1492
|
+
constructor(message) {
|
|
1493
|
+
super(message);
|
|
1494
|
+
this.name = 'AssertionError';
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
const Object$1 = 1;
|
|
1498
|
+
const Number$1 = 2;
|
|
1499
|
+
const Array$1 = 3;
|
|
1500
|
+
const String$1 = 4;
|
|
1501
|
+
const Boolean$1 = 5;
|
|
1502
|
+
const Function = 6;
|
|
1503
|
+
const Null = 7;
|
|
1504
|
+
const Unknown = 8;
|
|
1505
|
+
const getType = value => {
|
|
1506
|
+
switch (typeof value) {
|
|
1507
|
+
case 'number':
|
|
1508
|
+
return Number$1;
|
|
1509
|
+
case 'function':
|
|
1510
|
+
return Function;
|
|
1511
|
+
case 'string':
|
|
1512
|
+
return String$1;
|
|
1513
|
+
case 'object':
|
|
1514
|
+
if (value === null) {
|
|
1515
|
+
return Null;
|
|
1516
|
+
}
|
|
1517
|
+
if (Array.isArray(value)) {
|
|
1518
|
+
return Array$1;
|
|
1519
|
+
}
|
|
1520
|
+
return Object$1;
|
|
1521
|
+
case 'boolean':
|
|
1522
|
+
return Boolean$1;
|
|
1523
|
+
default:
|
|
1524
|
+
return Unknown;
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
const object = value => {
|
|
1528
|
+
const type = getType(value);
|
|
1529
|
+
if (type !== Object$1) {
|
|
1530
|
+
throw new AssertionError('expected value to be of type object');
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
const number = value => {
|
|
1534
|
+
const type = getType(value);
|
|
1535
|
+
if (type !== Number$1) {
|
|
1536
|
+
throw new AssertionError('expected value to be of type number');
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
const string = value => {
|
|
1540
|
+
const type = getType(value);
|
|
1541
|
+
if (type !== String$1) {
|
|
1542
|
+
throw new AssertionError('expected value to be of type string');
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
1546
|
const {
|
|
1547
1547
|
invoke,
|
|
1548
1548
|
invokeAndTransfer,
|
|
@@ -4817,49 +4817,80 @@ 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
|
-
return candidate.type === 'text/uri-list' && typeof candidate.
|
|
4843
|
+
return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
|
|
4845
4844
|
};
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
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: ''
|
|
4851
4854
|
};
|
|
4852
4855
|
const getDroppedUris = async itemIds => {
|
|
4853
4856
|
if (itemIds.length === 0) {
|
|
4854
4857
|
return [];
|
|
4855
4858
|
}
|
|
4856
4859
|
const items = await getFileHandles(itemIds);
|
|
4857
|
-
|
|
4858
|
-
|
|
4860
|
+
let hasChromiumDragId = false;
|
|
4861
|
+
const uris = [];
|
|
4862
|
+
for (const [index, item] of items.entries()) {
|
|
4863
|
+
if (isUriList(item)) {
|
|
4864
|
+
uris.push(...parseUriList(item.value));
|
|
4865
|
+
continue;
|
|
4866
|
+
}
|
|
4867
|
+
if (isChromiumDragId(item)) {
|
|
4868
|
+
hasChromiumDragId = true;
|
|
4869
|
+
continue;
|
|
4870
|
+
}
|
|
4871
|
+
if (!isDroppedFileSystemHandle(item)) {
|
|
4872
|
+
continue;
|
|
4873
|
+
}
|
|
4874
|
+
const handle = item.value;
|
|
4875
|
+
const suffix = suffixByHandleKind[handle.kind];
|
|
4876
|
+
const uri = `html:///dropped-files/${Date.now()}/${itemIds[index]}/${handle.name}${suffix}`;
|
|
4877
|
+
await invoke('PersistentFileHandle.addHandle', uri, handle);
|
|
4878
|
+
uris.push(uri);
|
|
4879
|
+
}
|
|
4880
|
+
if (uris.length > 0 || !hasChromiumDragId) {
|
|
4859
4881
|
return uris;
|
|
4860
4882
|
}
|
|
4861
4883
|
const dragInfo = await invoke('Viewlet.getDragData');
|
|
4862
|
-
|
|
4884
|
+
if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
|
|
4885
|
+
return uris;
|
|
4886
|
+
}
|
|
4887
|
+
for (const item of dragInfo.items) {
|
|
4888
|
+
const candidate = item;
|
|
4889
|
+
if (candidate.type === 'text/uri-list' && typeof candidate.data === 'string') {
|
|
4890
|
+
uris.push(...parseUriList(candidate.data));
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
return uris;
|
|
4863
4894
|
};
|
|
4864
4895
|
|
|
4865
4896
|
const openUrisWithContext = async (context, uris) => {
|
|
@@ -4871,6 +4902,16 @@ const openUrisWithContext = async (context, uris) => {
|
|
|
4871
4902
|
const handleDrop = async (context, itemIds) => {
|
|
4872
4903
|
await context.updateState(handleDragLeave);
|
|
4873
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
|
+
}
|
|
4874
4915
|
await openUrisWithContext(context, uris);
|
|
4875
4916
|
};
|
|
4876
4917
|
|