@lvce-editor/explorer-view 1.22.0 → 1.24.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/explorerViewWorkerMain.js +55 -33
- package/package.json +1 -1
|
@@ -1600,15 +1600,6 @@ const expandAll = async state => {
|
|
|
1600
1600
|
};
|
|
1601
1601
|
};
|
|
1602
1602
|
|
|
1603
|
-
const getParentEndIndex = (dirents, index) => {
|
|
1604
|
-
const dirent = dirents[index];
|
|
1605
|
-
let endIndex = index + 1;
|
|
1606
|
-
while (endIndex < dirents.length && dirents[endIndex].depth > dirent.depth) {
|
|
1607
|
-
endIndex++;
|
|
1608
|
-
}
|
|
1609
|
-
return endIndex;
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
1603
|
const makeExpanded = dirent => {
|
|
1613
1604
|
if (dirent.type === Directory) {
|
|
1614
1605
|
return {
|
|
@@ -1619,6 +1610,35 @@ const makeExpanded = dirent => {
|
|
|
1619
1610
|
return dirent;
|
|
1620
1611
|
};
|
|
1621
1612
|
|
|
1613
|
+
// TODO this is very inefficient
|
|
1614
|
+
const getChildDirentsRecursively = async (dirent, pathSeparator) => {
|
|
1615
|
+
switch (dirent.type) {
|
|
1616
|
+
case File:
|
|
1617
|
+
return [dirent];
|
|
1618
|
+
case Directory:
|
|
1619
|
+
case DirectoryExpanding:
|
|
1620
|
+
case DirectoryExpanded:
|
|
1621
|
+
const childDirents = await getChildDirents(pathSeparator, dirent);
|
|
1622
|
+
const all = [makeExpanded(dirent)];
|
|
1623
|
+
for (const childDirent of childDirents) {
|
|
1624
|
+
const childAll = await getChildDirentsRecursively(childDirent, pathSeparator);
|
|
1625
|
+
all.push(...childAll);
|
|
1626
|
+
}
|
|
1627
|
+
return all;
|
|
1628
|
+
default:
|
|
1629
|
+
return [];
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
const getParentEndIndex = (dirents, index) => {
|
|
1634
|
+
const dirent = dirents[index];
|
|
1635
|
+
let endIndex = index + 1;
|
|
1636
|
+
while (endIndex < dirents.length && dirents[endIndex].depth > dirent.depth) {
|
|
1637
|
+
endIndex++;
|
|
1638
|
+
}
|
|
1639
|
+
return endIndex;
|
|
1640
|
+
};
|
|
1641
|
+
|
|
1622
1642
|
const expandRecursively = async state => {
|
|
1623
1643
|
const {
|
|
1624
1644
|
items,
|
|
@@ -1637,47 +1657,42 @@ const expandRecursively = async state => {
|
|
|
1637
1657
|
if (dirent.type !== Directory && dirent.type !== DirectoryExpanding && dirent.type !== DirectoryExpanded) {
|
|
1638
1658
|
return state;
|
|
1639
1659
|
}
|
|
1640
|
-
// TODO this is very inefficient
|
|
1641
|
-
const getChildDirentsRecursively = async dirent => {
|
|
1642
|
-
switch (dirent.type) {
|
|
1643
|
-
case File:
|
|
1644
|
-
return [dirent];
|
|
1645
|
-
case Directory:
|
|
1646
|
-
case DirectoryExpanding:
|
|
1647
|
-
case DirectoryExpanded:
|
|
1648
|
-
const childDirents = await getChildDirents(pathSeparator, dirent);
|
|
1649
|
-
const all = [makeExpanded(dirent)];
|
|
1650
|
-
for (const childDirent of childDirents) {
|
|
1651
|
-
const childAll = await getChildDirentsRecursively(childDirent);
|
|
1652
|
-
all.push(...childAll);
|
|
1653
|
-
}
|
|
1654
|
-
return all;
|
|
1655
|
-
default:
|
|
1656
|
-
return [];
|
|
1657
|
-
}
|
|
1658
|
-
};
|
|
1659
1660
|
// TODO race condition: what if folder is being collapse while it is recursively expanding?
|
|
1660
1661
|
// TODO race condition: what if folder is being deleted while it is recursively expanding?
|
|
1661
1662
|
// TODO race condition: what if a new file/folder is created while the folder is recursively expanding?
|
|
1662
1663
|
// @ts-ignore
|
|
1663
|
-
const childDirents = await getChildDirentsRecursively(dirent);
|
|
1664
|
+
const childDirents = await getChildDirentsRecursively(dirent, pathSeparator);
|
|
1664
1665
|
const startIndex = focusedIndex;
|
|
1665
1666
|
if (focusedIndex >= 0) {
|
|
1666
1667
|
const endIndex = getParentEndIndex(items, focusedIndex);
|
|
1667
1668
|
const newDirents = [...items.slice(0, startIndex), ...childDirents, ...items.slice(endIndex)];
|
|
1668
1669
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
1670
|
+
const visible = newDirents.slice(minLineY, maxLineY);
|
|
1671
|
+
const {
|
|
1672
|
+
icons,
|
|
1673
|
+
newFileIconCache
|
|
1674
|
+
} = await getFileIcons(visible, state.fileIconCache);
|
|
1669
1675
|
return {
|
|
1670
1676
|
...state,
|
|
1671
1677
|
items: newDirents,
|
|
1672
|
-
maxLineY
|
|
1678
|
+
maxLineY,
|
|
1679
|
+
icons,
|
|
1680
|
+
fileIconCache: newFileIconCache
|
|
1673
1681
|
};
|
|
1674
1682
|
}
|
|
1675
1683
|
const newDirents = childDirents.slice(1);
|
|
1676
1684
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
1685
|
+
const visible = newDirents.slice(minLineY, maxLineY);
|
|
1686
|
+
const {
|
|
1687
|
+
icons,
|
|
1688
|
+
newFileIconCache
|
|
1689
|
+
} = await getFileIcons(visible, state.fileIconCache);
|
|
1677
1690
|
return {
|
|
1678
1691
|
...state,
|
|
1679
1692
|
items: newDirents,
|
|
1680
|
-
maxLineY
|
|
1693
|
+
maxLineY,
|
|
1694
|
+
icons,
|
|
1695
|
+
fileIconCache: newFileIconCache
|
|
1681
1696
|
};
|
|
1682
1697
|
};
|
|
1683
1698
|
|
|
@@ -3203,7 +3218,7 @@ const handleUpload = async (state, dirents) => {
|
|
|
3203
3218
|
}
|
|
3204
3219
|
};
|
|
3205
3220
|
|
|
3206
|
-
const setDeltaY = (state, deltaY) => {
|
|
3221
|
+
const setDeltaY = async (state, deltaY) => {
|
|
3207
3222
|
const {
|
|
3208
3223
|
itemHeight,
|
|
3209
3224
|
height,
|
|
@@ -3219,11 +3234,18 @@ const setDeltaY = (state, deltaY) => {
|
|
|
3219
3234
|
}
|
|
3220
3235
|
const minLineY = Math.round(deltaY / itemHeight);
|
|
3221
3236
|
const maxLineY = minLineY + Math.round(height / itemHeight);
|
|
3237
|
+
const visible = items.slice(minLineY, maxLineY);
|
|
3238
|
+
const {
|
|
3239
|
+
icons,
|
|
3240
|
+
newFileIconCache
|
|
3241
|
+
} = await getFileIcons(visible, state.fileIconCache);
|
|
3222
3242
|
return {
|
|
3223
3243
|
...state,
|
|
3224
3244
|
deltaY,
|
|
3225
3245
|
minLineY,
|
|
3226
|
-
maxLineY
|
|
3246
|
+
maxLineY,
|
|
3247
|
+
icons,
|
|
3248
|
+
fileIconCache: newFileIconCache
|
|
3227
3249
|
};
|
|
3228
3250
|
};
|
|
3229
3251
|
|