@lvce-editor/main-area-worker 9.34.0 → 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 +129 -74
- 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,
|
|
@@ -4776,6 +4776,9 @@ const getSplitDirection = (x, y, width, height) => {
|
|
|
4776
4776
|
return None;
|
|
4777
4777
|
};
|
|
4778
4778
|
|
|
4779
|
+
const isNotEmpty = group => {
|
|
4780
|
+
return !group.isEmpty;
|
|
4781
|
+
};
|
|
4779
4782
|
const getDragOverlay = (state, eventX, eventY) => {
|
|
4780
4783
|
const {
|
|
4781
4784
|
height,
|
|
@@ -4788,7 +4791,7 @@ const getDragOverlay = (state, eventX, eventY) => {
|
|
|
4788
4791
|
const {
|
|
4789
4792
|
groups
|
|
4790
4793
|
} = layout;
|
|
4791
|
-
const hasOpenEditor = groups.some(
|
|
4794
|
+
const hasOpenEditor = groups.some(isNotEmpty);
|
|
4792
4795
|
const contentY = hasOpenEditor ? tabHeight : 0;
|
|
4793
4796
|
const contentHeight = Math.max(0, height - contentY);
|
|
4794
4797
|
const relativeX = eventX - x;
|
|
@@ -4815,6 +4818,7 @@ const handleDragOver = (state, eventX, eventY) => {
|
|
|
4815
4818
|
};
|
|
4816
4819
|
|
|
4817
4820
|
const lineSeparatorRegex = /\r?\n/;
|
|
4821
|
+
const chromiumDragIdRegex = /^[A-F\d]{32}$/i;
|
|
4818
4822
|
const isUriList = item => {
|
|
4819
4823
|
if (!item || typeof item !== 'object') {
|
|
4820
4824
|
return false;
|
|
@@ -4825,12 +4829,59 @@ const isUriList = item => {
|
|
|
4825
4829
|
const parseUriList = value => {
|
|
4826
4830
|
return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
|
|
4827
4831
|
};
|
|
4832
|
+
const isChromiumDragId = item => {
|
|
4833
|
+
if (!item || typeof item !== 'object') {
|
|
4834
|
+
return false;
|
|
4835
|
+
}
|
|
4836
|
+
const candidate = item;
|
|
4837
|
+
return candidate.kind === 'string' && (candidate.type === '' || candidate.type === 'chromium/x-drag-id') && typeof candidate.value === 'string' && chromiumDragIdRegex.test(candidate.value);
|
|
4838
|
+
};
|
|
4839
|
+
const isDroppedFile = item => {
|
|
4840
|
+
if (!item || typeof item !== 'object') {
|
|
4841
|
+
return false;
|
|
4842
|
+
}
|
|
4843
|
+
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';
|
|
4846
|
+
};
|
|
4828
4847
|
const getDroppedUris = async itemIds => {
|
|
4829
4848
|
if (itemIds.length === 0) {
|
|
4830
4849
|
return [];
|
|
4831
4850
|
}
|
|
4832
4851
|
const items = await getFileHandles(itemIds);
|
|
4833
|
-
|
|
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) {
|
|
4872
|
+
return uris;
|
|
4873
|
+
}
|
|
4874
|
+
const dragInfo = await invoke('Viewlet.getDragData');
|
|
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;
|
|
4834
4885
|
};
|
|
4835
4886
|
|
|
4836
4887
|
const openUrisWithContext = async (context, uris) => {
|
|
@@ -5096,6 +5147,13 @@ const handleModifiedStatusChangeWithContext = async (context, uri, newStatus) =>
|
|
|
5096
5147
|
await context.updateState(state => handleModifiedStatusChange(state, uri, newStatus));
|
|
5097
5148
|
};
|
|
5098
5149
|
|
|
5150
|
+
const resizeChild = async (editorUid, dimensions) => {
|
|
5151
|
+
try {
|
|
5152
|
+
return await invoke('Viewlet.resize', editorUid, dimensions);
|
|
5153
|
+
} catch {
|
|
5154
|
+
return [];
|
|
5155
|
+
}
|
|
5156
|
+
};
|
|
5099
5157
|
const handleResize = async (state, dimensions) => {
|
|
5100
5158
|
const {
|
|
5101
5159
|
height,
|
|
@@ -5113,25 +5171,22 @@ const handleResize = async (state, dimensions) => {
|
|
|
5113
5171
|
groups
|
|
5114
5172
|
} = layout;
|
|
5115
5173
|
const contentHeight = height - tabHeight;
|
|
5116
|
-
const
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
const resizeCommands = await invoke('Viewlet.resize', tab.editorUid, {
|
|
5122
|
-
height: contentHeight,
|
|
5123
|
-
width,
|
|
5124
|
-
x,
|
|
5125
|
-
y: y + tabHeight
|
|
5126
|
-
});
|
|
5127
|
-
allResizeCommands.push(...resizeCommands);
|
|
5128
|
-
} catch {
|
|
5129
|
-
// ignore
|
|
5130
|
-
}
|
|
5131
|
-
}
|
|
5174
|
+
const resizePromises = [];
|
|
5175
|
+
const tabs = groups.flatMap(group => group.tabs);
|
|
5176
|
+
for (const tab of tabs) {
|
|
5177
|
+
if (tab.editorUid === -1) {
|
|
5178
|
+
continue;
|
|
5132
5179
|
}
|
|
5180
|
+
const resizePromise = resizeChild(tab.editorUid, {
|
|
5181
|
+
height: contentHeight,
|
|
5182
|
+
width,
|
|
5183
|
+
x,
|
|
5184
|
+
y: y + tabHeight
|
|
5185
|
+
});
|
|
5186
|
+
resizePromises.push(resizePromise);
|
|
5133
5187
|
}
|
|
5134
|
-
|
|
5188
|
+
const resizeCommands = await Promise.all(resizePromises);
|
|
5189
|
+
return resizeCommands.flat();
|
|
5135
5190
|
};
|
|
5136
5191
|
|
|
5137
5192
|
const offsetsMatch = (first, second) => {
|