@lvce-editor/ports-view 0.6.2 → 0.7.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 +44 -42
- package/package.json +1 -1
|
@@ -1366,17 +1366,18 @@ const normalizePort = input => {
|
|
|
1366
1366
|
if (!Number.isSafeInteger(port) || port < 1 || port > 65_535) {
|
|
1367
1367
|
throw new RangeError('port must be an integer between 1 and 65535');
|
|
1368
1368
|
}
|
|
1369
|
-
const
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1369
|
+
const rawInput = input;
|
|
1370
|
+
const forwardedAddress = rawInput.forwardedAddress ?? `localhost:${port}`;
|
|
1371
|
+
const runningProcess = rawInput.runningProcess ?? '';
|
|
1372
|
+
const origin = rawInput.origin ?? userForwarded();
|
|
1372
1373
|
assertString(forwardedAddress, 'forwardedAddress');
|
|
1373
1374
|
assertString(runningProcess, 'runningProcess');
|
|
1374
1375
|
assertString(origin, 'origin');
|
|
1375
|
-
if (
|
|
1376
|
+
if (rawInput.active !== undefined && typeof rawInput.active !== 'boolean') {
|
|
1376
1377
|
throw new TypeError('active must be a boolean');
|
|
1377
1378
|
}
|
|
1378
1379
|
return {
|
|
1379
|
-
active:
|
|
1380
|
+
active: rawInput.active ?? true,
|
|
1380
1381
|
forwardedAddress,
|
|
1381
1382
|
origin,
|
|
1382
1383
|
port,
|
|
@@ -1489,7 +1490,11 @@ const submitAddPort = state => {
|
|
|
1489
1490
|
}
|
|
1490
1491
|
return {
|
|
1491
1492
|
...addPort(state, {
|
|
1492
|
-
|
|
1493
|
+
active: true,
|
|
1494
|
+
forwardedAddress: `localhost:${port}`,
|
|
1495
|
+
origin: userForwarded(),
|
|
1496
|
+
port,
|
|
1497
|
+
runningProcess: ''
|
|
1493
1498
|
}),
|
|
1494
1499
|
addPortError: '',
|
|
1495
1500
|
addPortValue: '',
|
|
@@ -2028,26 +2033,25 @@ const handleBlur = state => {
|
|
|
2028
2033
|
};
|
|
2029
2034
|
};
|
|
2030
2035
|
|
|
2031
|
-
const
|
|
2036
|
+
const getIndexAt = (state, clientY) => {
|
|
2032
2037
|
const {
|
|
2033
2038
|
deltaY,
|
|
2034
2039
|
headerHeight,
|
|
2035
2040
|
itemHeight,
|
|
2041
|
+
listHeight,
|
|
2036
2042
|
minLineY,
|
|
2037
2043
|
ports,
|
|
2038
2044
|
y
|
|
2039
2045
|
} = state;
|
|
2040
|
-
if (name.startsWith('port-address-') || name.startsWith('port-status-')) {
|
|
2041
|
-
const port = Number(name.slice(name.lastIndexOf('-') + 1));
|
|
2042
|
-
const index = ports.findIndex(item => item.port === port);
|
|
2043
|
-
return index === -1 ? state : focusIndex(state, index);
|
|
2044
|
-
}
|
|
2045
2046
|
const relativeY = clientY - y - headerHeight;
|
|
2047
|
+
if (itemHeight <= 0 || relativeY < 0 || relativeY >= listHeight) {
|
|
2048
|
+
return -1;
|
|
2049
|
+
}
|
|
2046
2050
|
const index = minLineY + Math.floor((relativeY + deltaY % itemHeight) / itemHeight);
|
|
2047
|
-
if (
|
|
2048
|
-
return
|
|
2051
|
+
if (index < 0 || index >= ports.length) {
|
|
2052
|
+
return -1;
|
|
2049
2053
|
}
|
|
2050
|
-
return
|
|
2054
|
+
return index;
|
|
2051
2055
|
};
|
|
2052
2056
|
|
|
2053
2057
|
const SchemeRegex = /^[a-z][a-z\d+.-]*:\/\//i;
|
|
@@ -2085,26 +2089,23 @@ const togglePortActive = (state, portNumber) => {
|
|
|
2085
2089
|
};
|
|
2086
2090
|
};
|
|
2087
2091
|
|
|
2088
|
-
const parsePort = name => {
|
|
2089
|
-
return Number(name.slice(name.lastIndexOf('-') + 1));
|
|
2090
|
-
};
|
|
2091
2092
|
const handleClick = async (state, clientY, name) => {
|
|
2092
2093
|
const {
|
|
2093
2094
|
ports
|
|
2094
2095
|
} = state;
|
|
2096
|
+
const index = getIndexAt(state, clientY);
|
|
2097
|
+
if (index === -1) {
|
|
2098
|
+
return state;
|
|
2099
|
+
}
|
|
2100
|
+
const port = ports[index];
|
|
2101
|
+
const focused = focusIndex(state, index);
|
|
2095
2102
|
if (name.startsWith('port-address-')) {
|
|
2096
|
-
|
|
2097
|
-
const index = ports.findIndex(item => item.port === portNumber);
|
|
2098
|
-
const focused = index === -1 ? state : focusIndex(state, index);
|
|
2099
|
-
return openAddress(focused, portNumber);
|
|
2103
|
+
return openAddress(focused, port.port);
|
|
2100
2104
|
}
|
|
2101
2105
|
if (name.startsWith('port-status-')) {
|
|
2102
|
-
|
|
2103
|
-
const index = ports.findIndex(item => item.port === portNumber);
|
|
2104
|
-
const focused = index === -1 ? state : focusIndex(state, index);
|
|
2105
|
-
return togglePortActive(focused, portNumber);
|
|
2106
|
+
return togglePortActive(focused, port.port);
|
|
2106
2107
|
}
|
|
2107
|
-
return
|
|
2108
|
+
return focused;
|
|
2108
2109
|
};
|
|
2109
2110
|
|
|
2110
2111
|
const handleFocus = state => {
|
|
@@ -2244,7 +2245,7 @@ const PortsStatusIconActive = 'PortsStatusIconActive';
|
|
|
2244
2245
|
const PortsStatusIconInactive = 'PortsStatusIconInactive';
|
|
2245
2246
|
const PortsTable = 'PortsTable';
|
|
2246
2247
|
const PortsTableBody = 'PortsTableBody';
|
|
2247
|
-
const
|
|
2248
|
+
const PortsColumn = 'PortsColumn';
|
|
2248
2249
|
const PortsTableHeader = 'PortsTableHeader';
|
|
2249
2250
|
const PortsTableRow = 'PortsTableRow';
|
|
2250
2251
|
const PortsTableRowOdd = 'PortsTableRowOdd';
|
|
@@ -2369,10 +2370,10 @@ const getRowClassName = port => {
|
|
|
2369
2370
|
return className;
|
|
2370
2371
|
};
|
|
2371
2372
|
|
|
2372
|
-
const getTextCell =
|
|
2373
|
+
const getTextCell = value => {
|
|
2373
2374
|
return [{
|
|
2374
2375
|
childCount: 1,
|
|
2375
|
-
className:
|
|
2376
|
+
className: PortsColumn,
|
|
2376
2377
|
role: Cell,
|
|
2377
2378
|
title: value,
|
|
2378
2379
|
type: Div
|
|
@@ -2384,7 +2385,7 @@ const Unfocusable = -1;
|
|
|
2384
2385
|
|
|
2385
2386
|
const statusCell = {
|
|
2386
2387
|
childCount: 1,
|
|
2387
|
-
className:
|
|
2388
|
+
className: PortsColumn,
|
|
2388
2389
|
role: Cell,
|
|
2389
2390
|
type: Div
|
|
2390
2391
|
};
|
|
@@ -2396,9 +2397,9 @@ const getPortRowVirtualDom = port => {
|
|
|
2396
2397
|
className: getRowClassName(port),
|
|
2397
2398
|
role: Row,
|
|
2398
2399
|
type: Div
|
|
2399
|
-
}, statusCell, ...getPortsStatusVirtualDom(port.active, port.port), ...getTextCell(portText
|
|
2400
|
+
}, statusCell, ...getPortsStatusVirtualDom(port.active, port.port), ...getTextCell(portText), {
|
|
2400
2401
|
childCount: 1,
|
|
2401
|
-
className:
|
|
2402
|
+
className: PortsColumn,
|
|
2402
2403
|
role: Cell,
|
|
2403
2404
|
title: port.forwardedAddress,
|
|
2404
2405
|
type: Div
|
|
@@ -2409,7 +2410,7 @@ const getPortRowVirtualDom = port => {
|
|
|
2409
2410
|
role: Link,
|
|
2410
2411
|
tabIndex: Unfocusable,
|
|
2411
2412
|
type: A
|
|
2412
|
-
}, text(port.forwardedAddress), ...getTextCell(port.runningProcess
|
|
2413
|
+
}, text(port.forwardedAddress), ...getTextCell(port.runningProcess), ...getTextCell(port.origin)];
|
|
2413
2414
|
};
|
|
2414
2415
|
|
|
2415
2416
|
const getVisiblePorts = state => {
|
|
@@ -2466,16 +2467,17 @@ const headerRow = {
|
|
|
2466
2467
|
role: Row,
|
|
2467
2468
|
type: Div
|
|
2468
2469
|
};
|
|
2469
|
-
const
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2470
|
+
const headerCell = {
|
|
2471
|
+
childCount: 1,
|
|
2472
|
+
className: PortsColumn,
|
|
2473
|
+
role: ColumnHeader,
|
|
2474
|
+
type: Div
|
|
2475
|
+
};
|
|
2476
|
+
const getHeaderCell = label => {
|
|
2477
|
+
return [headerCell, text(label)];
|
|
2476
2478
|
};
|
|
2477
2479
|
const getPortsTableHeaderVirtualDom = () => {
|
|
2478
|
-
return [headerRow, ...getHeaderCell(''
|
|
2480
|
+
return [headerRow, ...getHeaderCell(''), ...getHeaderCell(port()), ...getHeaderCell(forwardedAddress()), ...getHeaderCell(runningProcess()), ...getHeaderCell(origin())];
|
|
2479
2481
|
};
|
|
2480
2482
|
|
|
2481
2483
|
const table = {
|