@lvce-editor/main-area-worker 9.34.1 → 9.34.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.
- package/dist/mainAreaWorkerMain.js +88 -66
- 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,
|
|
@@ -4836,30 +4836,52 @@ const isChromiumDragId = item => {
|
|
|
4836
4836
|
const candidate = item;
|
|
4837
4837
|
return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
|
|
4838
4838
|
};
|
|
4839
|
-
const
|
|
4839
|
+
const isDroppedFile = item => {
|
|
4840
4840
|
if (!item || typeof item !== 'object') {
|
|
4841
4841
|
return false;
|
|
4842
4842
|
}
|
|
4843
4843
|
const candidate = item;
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
const getUrisFromDragInfo = dragInfo => {
|
|
4847
|
-
if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
|
|
4848
|
-
return [];
|
|
4849
|
-
}
|
|
4850
|
-
return dragInfo.items.filter(isDragInfoItem).flatMap(item => parseUriList(item.data));
|
|
4844
|
+
const handle = candidate.value;
|
|
4845
|
+
return candidate.kind === 'file' && Boolean(handle) && typeof handle === 'object' && handle.kind === 'file' && typeof handle.name === 'string';
|
|
4851
4846
|
};
|
|
4852
4847
|
const getDroppedUris = async itemIds => {
|
|
4853
4848
|
if (itemIds.length === 0) {
|
|
4854
4849
|
return [];
|
|
4855
4850
|
}
|
|
4856
4851
|
const items = await getFileHandles(itemIds);
|
|
4857
|
-
|
|
4858
|
-
|
|
4852
|
+
let hasChromiumDragId = false;
|
|
4853
|
+
const uris = [];
|
|
4854
|
+
for (const item of items) {
|
|
4855
|
+
if (isUriList(item)) {
|
|
4856
|
+
uris.push(...parseUriList(item.value));
|
|
4857
|
+
continue;
|
|
4858
|
+
}
|
|
4859
|
+
if (isChromiumDragId(item)) {
|
|
4860
|
+
hasChromiumDragId = true;
|
|
4861
|
+
continue;
|
|
4862
|
+
}
|
|
4863
|
+
if (!isDroppedFile(item)) {
|
|
4864
|
+
continue;
|
|
4865
|
+
}
|
|
4866
|
+
const handle = item.value;
|
|
4867
|
+
const uri = `html:///dropped-files/${handle.name}`;
|
|
4868
|
+
await invoke('PersistentFileHandle.addHandle', uri, handle);
|
|
4869
|
+
uris.push(uri);
|
|
4870
|
+
}
|
|
4871
|
+
if (uris.length > 0 || !hasChromiumDragId) {
|
|
4859
4872
|
return uris;
|
|
4860
4873
|
}
|
|
4861
4874
|
const dragInfo = await invoke('Viewlet.getDragData');
|
|
4862
|
-
|
|
4875
|
+
if (!dragInfo || typeof dragInfo !== 'object' || !Array.isArray(dragInfo.items)) {
|
|
4876
|
+
return [];
|
|
4877
|
+
}
|
|
4878
|
+
for (const item of dragInfo.items) {
|
|
4879
|
+
const candidate = item;
|
|
4880
|
+
if (candidate.type === 'text/uri-list' && typeof candidate.data === 'string') {
|
|
4881
|
+
uris.push(...parseUriList(candidate.data));
|
|
4882
|
+
}
|
|
4883
|
+
}
|
|
4884
|
+
return uris;
|
|
4863
4885
|
};
|
|
4864
4886
|
|
|
4865
4887
|
const openUrisWithContext = async (context, uris) => {
|