@justinechang39/maki
Version:
AI-powered CLI agent for file operations, CSV manipulation, todo management, and web content fetching using OpenRouter
35 lines (34 loc) • 1.58 kB
JavaScript
import React from 'react';
import { Box, Text } from 'ink';
import { ProgressBar } from '@inkjs/ui';
export function DownloadProgress({ url, filename, progress, downloadedSize, totalSize, speed }) {
const formatBytes = (bytes) => {
if (bytes === 0)
return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
};
const formatSpeed = (bytesPerSecond) => {
return formatBytes(bytesPerSecond) + '/s';
};
return (React.createElement(Box, { flexDirection: "column", marginY: 1 },
React.createElement(Text, null,
"Downloading: ",
React.createElement(Text, { bold: true, color: "blue" }, filename)),
React.createElement(Box, { marginY: 1 },
React.createElement(Box, { width: 50 },
React.createElement(ProgressBar, { value: progress })),
React.createElement(Text, null,
" ",
progress.toFixed(1),
"%")),
React.createElement(Box, { justifyContent: "space-between" },
React.createElement(Text, null,
formatBytes(downloadedSize),
" / ",
totalSize > 0 ? formatBytes(totalSize) : 'Unknown'),
speed && speed > 0 && (React.createElement(Text, { color: "gray" }, formatSpeed(speed)))),
React.createElement(Text, { color: "gray", dimColor: true }, url)));
}