@lvce-editor/ports-view 0.7.3 → 0.8.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/portsViewWorkerMain.js +38 -25
- package/package.json +1 -1
|
@@ -1454,6 +1454,24 @@ const clamp = (value, minimum, maximum) => {
|
|
|
1454
1454
|
return Math.min(Math.max(value, minimum), maximum);
|
|
1455
1455
|
};
|
|
1456
1456
|
|
|
1457
|
+
const getVisiblePorts = state => {
|
|
1458
|
+
const {
|
|
1459
|
+
focusedIndex,
|
|
1460
|
+
maxLineY,
|
|
1461
|
+
minLineY,
|
|
1462
|
+
ports
|
|
1463
|
+
} = state;
|
|
1464
|
+
const visible = [];
|
|
1465
|
+
for (let index = minLineY; index < maxLineY; index++) {
|
|
1466
|
+
visible.push({
|
|
1467
|
+
...ports[index],
|
|
1468
|
+
index,
|
|
1469
|
+
selected: index === focusedIndex
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
return visible;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1457
1475
|
const recalculateVirtualList = state => {
|
|
1458
1476
|
const {
|
|
1459
1477
|
deltaY: oldDeltaY,
|
|
@@ -1473,7 +1491,7 @@ const recalculateVirtualList = state => {
|
|
|
1473
1491
|
const maxLineY = Math.min(ports.length, minLineY + visibleCount);
|
|
1474
1492
|
const scrollBarHeight = contentHeight <= listHeight || listHeight === 0 ? 0 : Math.max(minimumScrollBarSize, listHeight * listHeight / contentHeight);
|
|
1475
1493
|
const scrollBarY = finalDeltaY === 0 ? 0 : deltaY / finalDeltaY * (listHeight - scrollBarHeight);
|
|
1476
|
-
|
|
1494
|
+
const calculated = {
|
|
1477
1495
|
...state,
|
|
1478
1496
|
deltaY,
|
|
1479
1497
|
finalDeltaY,
|
|
@@ -1483,6 +1501,10 @@ const recalculateVirtualList = state => {
|
|
|
1483
1501
|
scrollBarHeight,
|
|
1484
1502
|
scrollBarY
|
|
1485
1503
|
};
|
|
1504
|
+
return {
|
|
1505
|
+
...calculated,
|
|
1506
|
+
visiblePorts: getVisiblePorts(calculated)
|
|
1507
|
+
};
|
|
1486
1508
|
};
|
|
1487
1509
|
|
|
1488
1510
|
const setPorts = (state, ports) => {
|
|
@@ -1596,6 +1618,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir, parentUid) =>
|
|
|
1596
1618
|
scrollBarHeight: 0,
|
|
1597
1619
|
scrollBarY: 0,
|
|
1598
1620
|
uid,
|
|
1621
|
+
visiblePorts: [],
|
|
1599
1622
|
width,
|
|
1600
1623
|
x,
|
|
1601
1624
|
y
|
|
@@ -2108,11 +2131,15 @@ const getMenuIds = () => {
|
|
|
2108
2131
|
};
|
|
2109
2132
|
|
|
2110
2133
|
const handleBlur = state => {
|
|
2111
|
-
|
|
2134
|
+
const updated = {
|
|
2112
2135
|
...state,
|
|
2113
2136
|
focused: false,
|
|
2114
2137
|
focusedIndex: -1
|
|
2115
2138
|
};
|
|
2139
|
+
return {
|
|
2140
|
+
...updated,
|
|
2141
|
+
visiblePorts: getVisiblePorts(updated)
|
|
2142
|
+
};
|
|
2116
2143
|
};
|
|
2117
2144
|
|
|
2118
2145
|
const getIndexAt = (state, clientY) => {
|
|
@@ -2159,7 +2186,7 @@ const togglePortActive = (state, portNumber) => {
|
|
|
2159
2186
|
const {
|
|
2160
2187
|
ports
|
|
2161
2188
|
} = state;
|
|
2162
|
-
|
|
2189
|
+
const updated = {
|
|
2163
2190
|
...state,
|
|
2164
2191
|
ports: ports.map(item => {
|
|
2165
2192
|
if (item.port !== portNumber) {
|
|
@@ -2171,6 +2198,10 @@ const togglePortActive = (state, portNumber) => {
|
|
|
2171
2198
|
};
|
|
2172
2199
|
})
|
|
2173
2200
|
};
|
|
2201
|
+
return {
|
|
2202
|
+
...updated,
|
|
2203
|
+
visiblePorts: getVisiblePorts(updated)
|
|
2204
|
+
};
|
|
2174
2205
|
};
|
|
2175
2206
|
|
|
2176
2207
|
const handleClick = async (state, clientY, name) => {
|
|
@@ -2531,24 +2562,6 @@ const getPortRowVirtualDom = port => {
|
|
|
2531
2562
|
}, text(port.forwardedAddress), ...getTextCell(port.runningProcess), ...getTextCell(port.origin)];
|
|
2532
2563
|
};
|
|
2533
2564
|
|
|
2534
|
-
const getVisiblePorts = state => {
|
|
2535
|
-
const {
|
|
2536
|
-
focusedIndex,
|
|
2537
|
-
maxLineY,
|
|
2538
|
-
minLineY,
|
|
2539
|
-
ports
|
|
2540
|
-
} = state;
|
|
2541
|
-
const visible = [];
|
|
2542
|
-
for (let index = minLineY; index < maxLineY; index++) {
|
|
2543
|
-
visible.push({
|
|
2544
|
-
...ports[index],
|
|
2545
|
-
index,
|
|
2546
|
-
selected: index === focusedIndex
|
|
2547
|
-
});
|
|
2548
|
-
}
|
|
2549
|
-
return visible;
|
|
2550
|
-
};
|
|
2551
|
-
|
|
2552
2565
|
const emptyBody = {
|
|
2553
2566
|
childCount: 1,
|
|
2554
2567
|
className: PortsTableBody,
|
|
@@ -2564,19 +2577,19 @@ const emptyMessage = {
|
|
|
2564
2577
|
const getPortsTableBodyVirtualDom = state => {
|
|
2565
2578
|
const {
|
|
2566
2579
|
loaded,
|
|
2567
|
-
ports
|
|
2580
|
+
ports,
|
|
2581
|
+
visiblePorts
|
|
2568
2582
|
} = state;
|
|
2569
2583
|
if (loaded && ports.length === 0) {
|
|
2570
2584
|
return [emptyBody, emptyMessage, text(noForwardedPorts())];
|
|
2571
2585
|
}
|
|
2572
|
-
const visible = getVisiblePorts(state);
|
|
2573
2586
|
return [{
|
|
2574
2587
|
ariaRowCount: ports.length + 1,
|
|
2575
|
-
childCount:
|
|
2588
|
+
childCount: visiblePorts.length,
|
|
2576
2589
|
className: PortsTableBody,
|
|
2577
2590
|
role: RowGroup,
|
|
2578
2591
|
type: Div
|
|
2579
|
-
}, ...
|
|
2592
|
+
}, ...visiblePorts.flatMap(getPortRowVirtualDom)];
|
|
2580
2593
|
};
|
|
2581
2594
|
|
|
2582
2595
|
const headerRow = {
|