tri-cli 0.0.54 → 0.0.55
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/cli.js +27 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -265,13 +265,18 @@ const TreeRow = /*#__PURE__*/React.memo(({
|
|
|
265
265
|
color: oneHunter.purple
|
|
266
266
|
}, " [", formatCount(fileCount), " files]"), isLoading && /*#__PURE__*/React.createElement(Text, {
|
|
267
267
|
color: oneHunter.yellow
|
|
268
|
-
}, " ", SPINNER_FRAMES[spinnerFrame])), isLoading ? /*#__PURE__*/React.createElement(Text, {
|
|
268
|
+
}, " ", SPINNER_FRAMES[spinnerFrame])), isLoading && fileCount === undefined ? /*#__PURE__*/React.createElement(Text, {
|
|
269
269
|
color: oneHunter.yellow
|
|
270
270
|
}, " ", SPINNER_FRAMES[spinnerFrame]) : displaySize > 0 ? /*#__PURE__*/React.createElement(Text, {
|
|
271
271
|
color: oneHunter.cyan
|
|
272
272
|
}, " ", formatBytes(displaySize)) : /*#__PURE__*/React.createElement(Text, null, " "), renderShortcut(), lastModified && /*#__PURE__*/React.createElement(Text, {
|
|
273
273
|
color: oneHunter.text2
|
|
274
274
|
}, " ", formatDate(lastModified))));
|
|
275
|
+
},
|
|
276
|
+
// Custom comparison function to prevent unnecessary re-renders
|
|
277
|
+
(prevProps, nextProps) => {
|
|
278
|
+
// Only re-render if these specific props change
|
|
279
|
+
return prevProps.node.data.path === nextProps.node.data.path && prevProps.isSelected === nextProps.isSelected && prevProps.collapsed.has(prevProps.node.data.path) === nextProps.collapsed.has(nextProps.node.data.path) && prevProps.shortcutInput === nextProps.shortcutInput && prevProps.calculatedSizes.get(prevProps.node.data.path) === nextProps.calculatedSizes.get(nextProps.node.data.path) && prevProps.calculatedCounts.get(prevProps.node.data.path) === nextProps.calculatedCounts.get(nextProps.node.data.path) && prevProps.loadingPaths.has(prevProps.node.data.path) === nextProps.loadingPaths.has(nextProps.node.data.path) && prevProps.lastModifiedDates.get(prevProps.node.data.path) === nextProps.lastModifiedDates.get(nextProps.node.data.path) && prevProps.spinnerFrame === nextProps.spinnerFrame;
|
|
275
280
|
});
|
|
276
281
|
const TreeVisualization = ({
|
|
277
282
|
dirPath = '.',
|
|
@@ -441,21 +446,31 @@ const TreeVisualization = ({
|
|
|
441
446
|
nodesToCount.sort((a, b) => a.depth - b.depth);
|
|
442
447
|
|
|
443
448
|
// Mark all nodes as loading
|
|
444
|
-
|
|
445
|
-
setLoadingPaths(loadingSet);
|
|
446
|
-
const newMap = new Map(calculatedCounts);
|
|
449
|
+
setLoadingPaths(new Set(nodesToCount.map(n => n.data.path)));
|
|
447
450
|
|
|
448
|
-
//
|
|
451
|
+
// Track completed counts
|
|
452
|
+
const completedCounts = new Map();
|
|
453
|
+
const completedPaths = new Set();
|
|
454
|
+
|
|
455
|
+
// Process all nodes in parallel
|
|
449
456
|
const promises = nodesToCount.map(async targetNode => {
|
|
450
457
|
const count = await countFilesAsync(targetNode.data.path);
|
|
451
458
|
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
459
|
+
// Store result
|
|
460
|
+
completedCounts.set(targetNode.data.path, count);
|
|
461
|
+
completedPaths.add(targetNode.data.path);
|
|
455
462
|
|
|
456
|
-
//
|
|
457
|
-
setCalculatedCounts(
|
|
458
|
-
|
|
463
|
+
// Batch update state (React will batch these automatically)
|
|
464
|
+
setCalculatedCounts(prev => {
|
|
465
|
+
const next = new Map(prev);
|
|
466
|
+
next.set(targetNode.data.path, count);
|
|
467
|
+
return next;
|
|
468
|
+
});
|
|
469
|
+
setLoadingPaths(prev => {
|
|
470
|
+
const next = new Set(prev);
|
|
471
|
+
next.delete(targetNode.data.path);
|
|
472
|
+
return next;
|
|
473
|
+
});
|
|
459
474
|
});
|
|
460
475
|
|
|
461
476
|
// Wait for all counts to complete
|
|
@@ -785,7 +800,7 @@ const TreeVisualization = ({
|
|
|
785
800
|
}, "\u2191/\u2193: Navigate | Enter: Expand/Traverse | c: Count | d: Size | l: Date | m: Map | Shift+C: CountMap | q: Quit"), loadingPaths.size > 0 && /*#__PURE__*/React.createElement(Text, {
|
|
786
801
|
color: oneHunter.yellow
|
|
787
802
|
}, ' ', SPINNER_FRAMES[spinnerFrame], " Loading ", loadingPaths.size, "...")), viewportNodes.map((node, i) => /*#__PURE__*/React.createElement(TreeRow, {
|
|
788
|
-
key:
|
|
803
|
+
key: node.data.path,
|
|
789
804
|
node: node,
|
|
790
805
|
isSelected: start + i === selectedIndex,
|
|
791
806
|
collapsed: collapsed,
|