First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { TransferProgressInfo } from "./transfer-statistics.js";
import { Options as PrettyMsOptions } from "pretty-ms";
import { ProgressStatus } from "../download-engine/download-file/progress-status-file.js";
export type CliInfoStatus = TransferProgressInfo & {
fileName?: string;
comment?: string;
};
export type FormattedStatus = ProgressStatus & CliInfoStatus & {
formattedSpeed: string;
formatTransferred: string;
formatTotal: string;
formatTransferredOfTotal: string;
formatTimeLeft: string;
formattedPercentage: string;
formattedComment: string;
};
export declare const PRETTY_MS_OPTIONS: PrettyMsOptions;
export declare function createFormattedStatus(status: ProgressStatus | FormattedStatus): FormattedStatus;

View File

@@ -0,0 +1,63 @@
import prettyBytes from "pretty-bytes";
import prettyMilliseconds from "pretty-ms";
import { DownloadStatus } from "../download-engine/download-file/progress-status-file.js";
const DEFAULT_LOCALIZATION = "en-US";
const NUMBER_FORMAT_OPTIONS = {
maximumFractionDigits: 2,
minimumFractionDigits: 2,
minimumIntegerDigits: 3
};
export const PRETTY_MS_OPTIONS = {
...NUMBER_FORMAT_OPTIONS,
keepDecimalsOnWholeSeconds: true,
secondsDecimalDigits: 2,
compact: true
};
const PRETTY_BYTES_OPTIONS = { ...NUMBER_FORMAT_OPTIONS, space: false, locale: DEFAULT_LOCALIZATION };
const DEFAULT_CLI_INFO_STATUS = {
speed: 0,
transferredBytes: 0,
totalBytes: 0,
percentage: 0,
timeLeft: 0,
ended: false
};
function formatSpeed(speed) {
return prettyBytes(Math.min(speed, 9999999999) || 0, PRETTY_BYTES_OPTIONS) + "/s";
}
export function createFormattedStatus(status) {
if ("formattedSpeed" in status) {
return status;
}
const fullStatus = { ...DEFAULT_CLI_INFO_STATUS, ...status };
const formattedSpeed = formatSpeed(fullStatus.speed);
const formatTransferred = prettyBytes(fullStatus.transferredBytes, PRETTY_BYTES_OPTIONS);
const formatTotal = fullStatus.totalBytes === 0 ? "???" : prettyBytes(fullStatus.totalBytes, PRETTY_BYTES_OPTIONS);
const formatTransferredOfTotal = `${formatTransferred}/${formatTotal}`;
const formatTimeLeft = fullStatus.totalBytes === 0 ? "unknown time" : prettyMilliseconds(fullStatus.timeLeft, PRETTY_MS_OPTIONS);
const formattedPercentage = fullStatus.percentage.toLocaleString(DEFAULT_LOCALIZATION, {
minimumIntegerDigits: 1,
minimumFractionDigits: 4
})
.slice(0, 5) + "%";
let fullComment = fullStatus.comment;
if (status.downloadStatus === DownloadStatus.Cancelled || status.downloadStatus === DownloadStatus.Paused) {
if (fullComment) {
fullComment += " | " + status.downloadStatus;
}
else {
fullComment = status.downloadStatus;
}
}
return {
...fullStatus,
formattedSpeed,
formatTransferred,
formatTransferredOfTotal,
formatTotal,
formatTimeLeft,
formattedPercentage,
formattedComment: fullComment ? `(${fullComment})` : ""
};
}
//# sourceMappingURL=format-transfer-status.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"format-transfer-status.js","sourceRoot":"","sources":["../../../src/download/transfer-visualize/format-transfer-status.ts"],"names":[],"mappings":"AACA,OAAO,WAA4C,MAAM,cAAc,CAAC;AACxE,OAAO,kBAAgD,MAAM,WAAW,CAAC;AACzE,OAAO,EAAC,cAAc,EAAiB,MAAM,0DAA0D,CAAC;AAExG,MAAM,oBAAoB,GAAyB,OAAO,CAAC;AAiB3D,MAAM,qBAAqB,GAA6B;IACpD,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;IACxB,oBAAoB,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAC9C,GAAG,qBAAqB;IACxB,0BAA0B,EAAE,IAAI;IAChC,oBAAoB,EAAE,CAAC;IACvB,OAAO,EAAE,IAAI;CAChB,CAAC;AAEF,MAAM,oBAAoB,GAAuB,EAAC,GAAG,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAC,CAAC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CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IAEvB,IAAI,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC;IACrC,IAAI,MAAM,CAAC,cAAc,KAAK,cAAc,CAAC,SAAS,IAAI,MAAM,CAAC,cAAc,KAAK,cAAc,CAAC,MAAM,EAAE,CAAC;QACxG,IAAI,WAAW,EAAE,CAAC;YACd,WAAW,IAAI,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;QACjD,CAAC;aAAM,CAAC;YACJ,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC;QACxC,CAAC;IACL,CAAC;IAED,OAAO;QACH,GAAG,UAAU;QACb,cAAc;QACd,iBAAiB;QACjB,wBAAwB;QACxB,WAAW;QACX,cAAc;QACd,mBAAmB;QACnB,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE;KAC1D,CAAC;AACN,CAAC"}

View File

@@ -0,0 +1,36 @@
import BaseDownloadEngine from "../download-engine/engine/base-download-engine.js";
import { EventEmitter } from "eventemitter3";
import { FormattedStatus } from "./format-transfer-status.js";
import DownloadEngineFile from "../download-engine/download-file/download-engine-file.js";
import { DownloadStatus } from "../download-engine/download-file/progress-status-file.js";
import DownloadEngineMultiDownload from "../download-engine/engine/download-engine-multi-download.js";
export type ProgressStatusWithIndex = FormattedStatus & {
index: number;
};
interface CliProgressBuilderEvents {
progress: (progress: ProgressStatusWithIndex) => void;
}
export type AnyEngine = DownloadEngineFile | BaseDownloadEngine | DownloadEngineMultiDownload;
export default class ProgressStatisticsBuilder extends EventEmitter<CliProgressBuilderEvents> {
private _engines;
private _activeTransfers;
private _totalBytes;
private _transferredBytes;
private _activeDownloadPart;
private _startTime;
private _statistics;
private _lastStatus?;
downloadStatus: DownloadStatus;
get totalBytes(): number;
get transferredBytesWithActiveTransfers(): number;
get status(): ProgressStatusWithIndex | undefined;
/**
* Add engines to the progress statistics builder, will only add engines once
*/
add(...engines: AnyEngine[]): void;
private _initEvents;
private _sendProgress;
static oneStatistics(engine: DownloadEngineFile): FormattedStatus;
static loadingStatusEmptyStatistics(): FormattedStatus;
}
export {};

View File

@@ -0,0 +1,99 @@
import { EventEmitter } from "eventemitter3";
import TransferStatistics from "./transfer-statistics.js";
import { createFormattedStatus } from "./format-transfer-status.js";
import ProgressStatusFile, { DownloadStatus } from "../download-engine/download-file/progress-status-file.js";
export default class ProgressStatisticsBuilder extends EventEmitter {
_engines = [];
_activeTransfers = {};
_totalBytes = 0;
_transferredBytes = 0;
/**
* @internal
*/
_totalDownloadParts = 0;
_activeDownloadPart = 0;
_startTime = 0;
_statistics = new TransferStatistics();
_lastStatus;
downloadStatus = null;
get totalBytes() {
return this._totalBytes;
}
get transferredBytesWithActiveTransfers() {
return this._transferredBytes + Object.values(this._activeTransfers)
.reduce((acc, bytes) => acc + bytes, 0);
}
get status() {
return this._lastStatus;
}
/**
* Add engines to the progress statistics builder, will only add engines once
*/
add(...engines) {
for (const engine of engines) {
if (!this._engines.includes(engine)) {
this._initEvents(engine, engines.at(-1) === engine);
}
}
}
_initEvents(engine, sendProgress = false) {
this._engines.push(engine);
this._totalBytes += engine.downloadSize;
const index = this._engines.length - 1;
const downloadPartStart = this._totalDownloadParts;
this._totalDownloadParts += engine.status.totalDownloadParts;
engine.on("progress", (data) => {
this._sendProgress(data, index, downloadPartStart);
});
engine.on("finished", () => {
delete this._activeTransfers[index];
this._transferredBytes += engine.downloadSize;
});
if (sendProgress) {
this._sendProgress(engine.status, index, downloadPartStart);
}
}
_sendProgress(data, index, downloadPartStart) {
this._startTime ||= data.startTime;
this._activeTransfers[index] = data.transferredBytes;
if (downloadPartStart + data.downloadPart > this._activeDownloadPart) {
this._activeDownloadPart = downloadPartStart + data.downloadPart;
}
const progress = this._statistics.updateProgress(this.transferredBytesWithActiveTransfers, this.totalBytes);
const activeDownloads = Object.keys(this._activeTransfers).length;
this._lastStatus = {
...createFormattedStatus({
...progress,
downloadPart: this._activeDownloadPart,
totalDownloadParts: this._totalDownloadParts,
startTime: this._startTime,
fileName: data.fileName,
comment: data.comment,
transferAction: data.transferAction,
downloadStatus: this.downloadStatus || data.downloadStatus,
endTime: activeDownloads <= 1 ? data.endTime : 0,
downloadFlags: data.downloadFlags
}),
index
};
this.emit("progress", this._lastStatus);
}
static oneStatistics(engine) {
const progress = engine.status;
const statistics = TransferStatistics.oneStatistics(progress.transferredBytes, progress.totalBytes);
return createFormattedStatus({
...progress,
...statistics
});
}
static loadingStatusEmptyStatistics() {
const statistics = TransferStatistics.oneStatistics(0, 0);
const status = new ProgressStatusFile(0, "???");
status.downloadStatus = DownloadStatus.Loading;
return createFormattedStatus({
...status,
...statistics
});
}
}
//# sourceMappingURL=progress-statistics-builder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"progress-statistics-builder.js","sourceRoot":"","sources":["../../../src/download/transfer-visualize/progress-statistics-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAkB,MAAM,6BAA6B,CAAC;AAEnF,OAAO,kBAAkB,EAAE,EAAC,cAAc,EAAiB,MAAM,0DAA0D,CAAC;AAY5H,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,YAAsC;IACjF,QAAQ,GAAgB,EAAE,CAAC;IAC3B,gBAAgB,GAAgC,EAAE,CAAC;IACnD,WAAW,GAAG,CAAC,CAAC;IAChB,iBAAiB,GAAG,CAAC,CAAC;IAC9B;;OAEG;IACH,mBAAmB,GAAG,CAAC,CAAC;IAChB,mBAAmB,GAAG,CAAC,CAAC;IACxB,UAAU,GAAG,CAAC,CAAC;IACf,WAAW,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACvC,WAAW,CAA2B;IACvC,cAAc,GAAmB,IAAK,CAAC;IAE9C,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC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AAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAChD,aAAa,EAAE,IAAI,CAAC,aAAa;aACpC,CAAC;YACF,KAAK;SACR,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAA0B;QAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,MAAM,UAAU,GAAG,kBAAkB,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEpG,OAAO,qBAAqB,CAAC;YACzB,GAAG,QAAQ;YACX,GAAG,UAAU;SAChB,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,4BAA4B;QAC/B,MAAM,UAAU,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC;QAE/C,OAAO,qBAAqB,CAAC;YACzB,GAAG,MAAM;YACT,GAAG,UAAU;SAChB,CAAC,CAAC;IACP,CAAC;CACJ"}

View File

@@ -0,0 +1,27 @@
import DownloadEngineNodejs from "../../download-engine/engine/download-engine-nodejs.js";
import DownloadEngineMultiDownload from "../../download-engine/engine/download-engine-multi-download.js";
import { AvailableCLIProgressStyle } from "./progress-bars/switch-cli-progress-style.js";
import { CliFormattedStatus } from "./progress-bars/base-transfer-cli-progress-bar.js";
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
import cliSpinners from "cli-spinners";
type AllowedDownloadEngines = DownloadEngineNodejs | DownloadEngineMultiDownload;
export type CliProgressDownloadEngineOptions = {
truncateName?: boolean | number;
cliProgress?: boolean;
maxViewDownloads?: number;
createMultiProgressBar?: typeof BaseMultiProgressBar;
cliStyle?: AvailableCLIProgressStyle | ((status: CliFormattedStatus) => string);
cliName?: string;
cliAction?: string;
fetchStrategy?: "localFile" | "fetch";
loadingAnimation?: cliSpinners.SpinnerName;
};
export default class CliAnimationWrapper {
private readonly _downloadEngine;
private readonly _options;
private _activeCLI?;
constructor(downloadEngine: Promise<AllowedDownloadEngines>, _options: CliProgressDownloadEngineOptions);
private _init;
attachAnimation(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,60 @@
import switchCliProgressStyle from "./progress-bars/switch-cli-progress-style.js";
import TransferCli from "./transfer-cli.js";
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
const DEFAULT_CLI_STYLE = "auto";
export default class CliAnimationWrapper {
_downloadEngine;
_options;
_activeCLI;
constructor(downloadEngine, _options) {
this._options = _options;
this._downloadEngine = downloadEngine;
this._init();
}
_init() {
if (!this._options.cliProgress) {
return;
}
this._options.cliAction ??= this._options.fetchStrategy === "localFile" ? "Copying" : "Downloading";
const cliOptions = { ...this._options };
if (this._options.cliAction) {
cliOptions.action = this._options.cliAction;
}
if (this._options.cliName) {
cliOptions.name = this._options.cliName;
}
cliOptions.createProgressBar = typeof this._options.cliStyle === "function" ?
{
createStatusLine: this._options.cliStyle,
multiProgressBar: this._options.createMultiProgressBar ?? BaseMultiProgressBar
} :
switchCliProgressStyle(this._options.cliStyle ?? DEFAULT_CLI_STYLE, {
truncateName: this._options.truncateName,
loadingSpinner: this._options.loadingAnimation
});
this._activeCLI = new TransferCli(cliOptions, this._options.cliLevel);
}
async attachAnimation() {
if (!this._activeCLI) {
return;
}
this._activeCLI.loadingAnimation.start();
try {
const engine = await this._downloadEngine;
this._activeCLI.loadingAnimation.stop();
engine.once("start", () => {
this._activeCLI?.start();
engine.on("progress", (progress) => {
this._activeCLI?.updateStatues(engine.downloadStatues, progress);
});
engine.on("closed", () => {
this._activeCLI?.stop();
});
});
}
finally {
this._activeCLI.loadingAnimation.stop();
}
}
}
//# sourceMappingURL=cli-animation-wrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cli-animation-wrapper.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/transfer-cli/cli-animation-wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAmD,MAAM,8CAA8C,CAAC;AAE/G,OAAO,WAA4C,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAC,oBAAoB,EAAC,MAAM,6CAA6C,CAAC;AAGjF,MAAM,iBAAiB,GAA8B,MAAM,CAAC;AAiB5D,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACnB,eAAe,CAAkC;IACjD,QAAQ,CAAmC;IACpD,UAAU,CAAe;IAEjC,YAAmB,cAA+C,EAAE,QAA0C;QAC1G,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,aAAa,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;QAEpG,MAAM,UAAU,GAAgC,EAAC,GAAG,IAAI,CAAC,QAAQ,EAAC,CAAC;QACnE,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC1B,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxB,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC5C,CAAC;QAED,UAAU,CAAC,iBAAiB,GAAG,OAAO,IAAI,CAAC,Q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AC;QACP,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC5C,CAAC;IACL,CAAC;CACJ"}

View File

@@ -0,0 +1,19 @@
import UpdateManager from "stdout-update";
import { CLIProgressPrintType } from "../multiProgressBars/BaseMultiProgressBar.js";
export type BaseLoadingAnimationOptions = {
updateIntervalMs?: number | null;
loadingText?: string;
logType: CLIProgressPrintType;
};
export declare const DEFAULT_LOADING_ANIMATION_OPTIONS: BaseLoadingAnimationOptions;
export default abstract class BaseLoadingAnimation {
protected options: BaseLoadingAnimationOptions;
protected stdoutManager: UpdateManager;
protected _animationActive: boolean;
protected constructor(options?: BaseLoadingAnimationOptions);
protected _render(): void;
protected abstract createFrame(): string;
start(): Promise<void>;
stop(): void;
private _processExit;
}

View File

@@ -0,0 +1,52 @@
import UpdateManager from "stdout-update";
import sleep from "sleep-promise";
export const DEFAULT_LOADING_ANIMATION_OPTIONS = {
loadingText: "Gathering information",
logType: "update"
};
const DEFAULT_UPDATE_INTERVAL_MS = 300;
export default class BaseLoadingAnimation {
options;
stdoutManager = UpdateManager.getInstance();
_animationActive = false;
constructor(options = DEFAULT_LOADING_ANIMATION_OPTIONS) {
this.options = options;
this._processExit = this._processExit.bind(this);
}
_render() {
const frame = this.createFrame();
if (this.options.logType === "update") {
this.stdoutManager.update([frame]);
}
else {
console.log(frame);
}
}
async start() {
process.on("SIGINT", this._processExit);
if (this.options.logType === "update") {
this.stdoutManager.hook();
}
this._animationActive = true;
while (this._animationActive) {
this._render();
await sleep(this.options.updateIntervalMs || DEFAULT_UPDATE_INTERVAL_MS);
}
}
stop() {
if (!this._animationActive) {
return;
}
this._animationActive = false;
if (this.options.logType === "update") {
this.stdoutManager.erase();
this.stdoutManager.unhook(false);
}
process.off("SIGINT", this._processExit);
}
_processExit() {
this.stop();
process.exit(0);
}
}
//# sourceMappingURL=base-loading-animation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base-loading-animation.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,eAAe,CAAC;AASlC,MAAM,CAAC,MAAM,iCAAiC,GAAgC;IAC1E,WAAW,EAAE,uBAAuB;IACpC,OAAO,EAAE,QAAQ;CACpB,CAAC;AAEF,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAgB,oBAAoB;IACpC,OAAO,CAA8B;IACrC,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC5C,gBAAgB,GAAG,KAAK,CAAC;IAGnC,YAAsB,UAAuC,iCAAiC;QAC1F,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAES,OAAO;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAID,KAAK,CAAC,KAAK;QACP,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAExC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC;IAED,IAAI;QACA,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAE9B,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY;QAChB,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;CACJ"}

View File

@@ -0,0 +1,8 @@
import BaseLoadingAnimation, { BaseLoadingAnimationOptions } from "./base-loading-animation.js";
import { Spinner } from "cli-spinners";
export default class CliSpinnersLoadingAnimation extends BaseLoadingAnimation {
private _spinner;
private _frameIndex;
constructor(spinner: Spinner, options: BaseLoadingAnimationOptions);
protected createFrame(): string;
}

View File

@@ -0,0 +1,20 @@
import BaseLoadingAnimation, { DEFAULT_LOADING_ANIMATION_OPTIONS } from "./base-loading-animation.js";
export default class CliSpinnersLoadingAnimation extends BaseLoadingAnimation {
_spinner;
_frameIndex = 0;
constructor(spinner, options) {
options = { ...DEFAULT_LOADING_ANIMATION_OPTIONS, ...options };
options.updateIntervalMs ??= spinner.interval;
super(options);
this._spinner = spinner;
}
createFrame() {
const frame = this._spinner.frames[this._frameIndex];
this._frameIndex++;
if (this._frameIndex >= this._spinner.frames.length) {
this._frameIndex = 0;
}
return `${frame} ${this.options.loadingText}`;
}
}
//# sourceMappingURL=cli-spinners-loading-animation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cli-spinners-loading-animation.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,EAAE,EAA8B,iCAAiC,EAAC,MAAM,6BAA6B,CAAC;AAGjI,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,oBAAoB;IACjE,QAAQ,CAAU;IAClB,WAAW,GAAG,CAAC,CAAC;IAExB,YAAmB,OAAgB,EAAE,OAAoC;QACrE,OAAO,GAAG,EAAC,GAAG,iCAAiC,EAAE,GAAG,OAAO,EAAC,CAAC;QAC7D,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,QAAQ,CAAC;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAClD,CAAC;CACJ"}

View File

@@ -0,0 +1,24 @@
import { TransferCliProgressBar } from "../progress-bars/base-transfer-cli-progress-bar.js";
import { FormattedStatus } from "../../format-transfer-status.js";
export type MultiProgressBarOptions = {
maxViewDownloads: number;
createProgressBar: TransferCliProgressBar;
action?: string;
};
export type CLIProgressPrintType = "update" | "log";
export declare class BaseMultiProgressBar {
protected options: MultiProgressBarOptions;
readonly updateIntervalMs: null | number;
readonly printType: CLIProgressPrintType;
constructor(options: MultiProgressBarOptions);
protected createProgresses(statuses: FormattedStatus[]): string;
/**
* Sorts the statuses by importance, active downloads first, then remaining, then finished (by end time - latest first)
*/
protected recorderStatusByImportance(statuses: FormattedStatus[]): {
notFinished: boolean;
remaining: number;
allStatusesSorted: FormattedStatus[];
};
createMultiProgressBar(statuses: FormattedStatus[], oneStatus: FormattedStatus): string;
}

View File

@@ -0,0 +1,50 @@
import { DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";
import chalk from "chalk";
import prettyBytes from "pretty-bytes";
export class BaseMultiProgressBar {
options;
updateIntervalMs = null;
printType = "update";
constructor(options) {
this.options = options;
}
createProgresses(statuses) {
return statuses.map((status) => {
status.transferAction = this.options.action ?? status.transferAction;
return this.options.createProgressBar.createStatusLine(status);
})
.join("\n");
}
/**
* Sorts the statuses by importance, active downloads first, then remaining, then finished (by end time - latest first)
*/
recorderStatusByImportance(statuses) {
const activeTasks = statuses.filter(status => status.downloadStatus === DownloadStatus.Active);
const remaining = statuses.filter(status => [DownloadStatus.Paused, DownloadStatus.NotStarted].includes(status.downloadStatus));
const loading = statuses.filter(status => status.downloadStatus === DownloadStatus.Loading);
const finishedTasks = statuses.filter(status => status.downloadStatus === DownloadStatus.Finished)
.sort((a, b) => b.endTime - a.endTime);
const showTotalTasks = activeTasks.concat(remaining)
.concat(loading);
const showTotalTasksWithFinished = showTotalTasks.concat(finishedTasks);
return {
notFinished: showTotalTasks.length > 0,
remaining: remaining.length + loading.length,
allStatusesSorted: showTotalTasksWithFinished
};
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
createMultiProgressBar(statuses, oneStatus) {
if (statuses.length < this.options.maxViewDownloads) {
return this.createProgresses(statuses);
}
const { notFinished, remaining, allStatusesSorted } = this.recorderStatusByImportance(statuses);
const tasksLogs = this.createProgresses(allStatusesSorted.slice(0, this.options.maxViewDownloads));
if (notFinished) {
return tasksLogs + `\nand ${chalk.gray(remaining)} more out of ${chalk.blueBright(statuses.length)} downloads.`;
}
const totalSize = allStatusesSorted.reduce((acc, status) => acc + status.totalBytes, 0);
return tasksLogs + `\n${chalk.green(`All ${statuses.length} downloads (${prettyBytes(totalSize)}) finished.`)}`;
}
}
//# sourceMappingURL=BaseMultiProgressBar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BaseMultiProgressBar.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/multiProgressBars/BaseMultiProgressBar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,gEAAgE,CAAC;AAC9F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,cAAc,CAAC;AAUvC,MAAM,OAAO,oBAAoB;IAIA;IAHb,gBAAgB,GAAkB,IAAI,CAAC;IACvC,SAAS,GAAyB,QAAQ,CAAC;IAE3D,YAA6B,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;IAC7D,CAAC;IAES,gBAAgB,CAAC,QAA2B;QAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC3B,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACnE,CAAC,CAAC;aACG,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACO,0BAA0B,CAAC,QAA2B;QAC5D,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC;QAC/F,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC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,EAAE,CAAC;YACd,OAAO,SAAS,GAAG,SAAS,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;QACpH,CAAC;QAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACxF,OAAO,SAAS,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,MAAM,eAAe,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;IACpH,CAAC;CACJ"}

View File

@@ -0,0 +1,5 @@
import { SummaryMultiProgressBar } from "./SummaryMultiProgressBar.js";
export declare class CIMultiProgressBar extends SummaryMultiProgressBar {
readonly printType = "log";
readonly updateIntervalMs: number;
}

View File

@@ -0,0 +1,6 @@
import { SummaryMultiProgressBar } from "./SummaryMultiProgressBar.js";
export class CIMultiProgressBar extends SummaryMultiProgressBar {
printType = "log";
updateIntervalMs = parseInt(process.env.IPULL_CI_UPDATE_INTERVAL ?? "0") || 8_000;
}
//# sourceMappingURL=CIMultiProgressBar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CIMultiProgressBar.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/multiProgressBars/CIMultiProgressBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAErE,MAAM,OAAO,kBAAmB,SAAQ,uBAAuB;IAClC,SAAS,GAAG,KAAK,CAAC;IAClB,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;CAC9G"}

View File

@@ -0,0 +1,9 @@
import { BaseMultiProgressBar, CLIProgressPrintType } from "./BaseMultiProgressBar.js";
import { FormattedStatus } from "../../format-transfer-status.js";
export declare class SummaryMultiProgressBar extends BaseMultiProgressBar {
readonly printType: CLIProgressPrintType;
readonly updateIntervalMs: number;
private _parallelDownloads;
private _lastStatuses;
createMultiProgressBar(statuses: FormattedStatus[], oneStatus: FormattedStatus): string;
}

View File

@@ -0,0 +1,35 @@
import { BaseMultiProgressBar } from "./BaseMultiProgressBar.js";
import { DownloadFlags, DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";
export class SummaryMultiProgressBar extends BaseMultiProgressBar {
printType = "update";
updateIntervalMs = 0;
_parallelDownloads = 0;
_lastStatuses = [];
createMultiProgressBar(statuses, oneStatus) {
oneStatus = structuredClone(oneStatus);
oneStatus.downloadFlags.push(DownloadFlags.DownloadSequence);
const linesToPrint = [];
let index = 0;
for (const status of statuses) {
const isStatusChanged = this._lastStatuses[index++]?.downloadStatus !== status.downloadStatus;
const copyStatus = structuredClone(status);
if (isStatusChanged) {
linesToPrint.push(copyStatus);
}
}
if (this.printType === "log") {
this._lastStatuses = structuredClone(statuses);
}
const { allStatusesSorted } = this.recorderStatusByImportance(linesToPrint);
const filterStatusesSliced = allStatusesSorted.slice(0, this.options.maxViewDownloads);
if (statuses.length > 1 || oneStatus.downloadStatus === DownloadStatus.Active) {
filterStatusesSliced.push(oneStatus);
}
const activeDownloads = statuses.filter((status) => status.downloadStatus === DownloadStatus.Active).length;
this._parallelDownloads ||= activeDownloads;
const finishedDownloads = statuses.filter((status) => status.downloadStatus === DownloadStatus.Finished).length;
oneStatus.comment = `${finishedDownloads}/${statuses.length} files done${this._parallelDownloads > 1 ? ` (${activeDownloads} active)` : ""}`;
return this.createProgresses(filterStatusesSliced);
}
}
//# sourceMappingURL=SummaryMultiProgressBar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SummaryMultiProgressBar.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/multiProgressBars/SummaryMultiProgressBar.ts"],"names":[],"mappings":"AAAA,OAA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cAAc,CAAC,MAAM,EAAE,CAAC;YAC5E,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAC5G,IAAI,CAAC,kBAAkB,KAAK,eAAe,CAAC;QAC5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,KAAK,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;QAChH,SAAS,CAAC,OAAO,GAAG,GAAG,iBAAiB,IAAI,QAAQ,CAAC,MAAM,cAAc,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,eAAe,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAE7I,OAAO,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IACvD,CAAC;CACJ"}

View File

@@ -0,0 +1,39 @@
import { FormattedStatus } from "../../format-transfer-status.js";
import { BaseMultiProgressBar } from "../multiProgressBars/BaseMultiProgressBar.js";
import { DataLine, DataPart } from "../../utils/data-line.js";
import cliSpinners, { Spinner } from "cli-spinners";
export type CliFormattedStatus = FormattedStatus & {
transferAction: string;
};
export type BaseCliOptions = {
truncateName?: boolean | number;
loadingSpinner?: cliSpinners.SpinnerName;
};
export interface TransferCliProgressBar {
multiProgressBar: typeof BaseMultiProgressBar;
createStatusLine(status: CliFormattedStatus): string;
}
/**
* A class to display transfer progress in the terminal, with a progress bar and other information.
*/
export default class BaseTransferCliProgressBar implements TransferCliProgressBar {
multiProgressBar: typeof BaseMultiProgressBar;
downloadLoadingSpinner: Spinner;
private _spinnerState;
protected status: CliFormattedStatus;
protected options: BaseCliOptions;
protected minNameLength: number;
constructor(options: BaseCliOptions);
switchTransferToShortText(): string;
protected get showETA(): boolean;
protected getNameSize(fileName?: string): number;
protected getSpinnerText(): string;
protected getNameAndCommentDataParts(): DataPart[];
protected getETA(spacer?: string, formatter?: (text: string, size: number, type: "spacer" | "time") => string): DataLine;
protected createProgressBarLine(length: number): string;
protected renderProgressLine(): string;
protected renderFinishedLine(): string;
protected renderPendingLine(): string;
protected renderLoadingLine(): string;
createStatusLine(status: CliFormattedStatus): string;
}

View File

@@ -0,0 +1,284 @@
import chalk from "chalk";
import { truncateText } from "../../utils/cli-text.js";
import { clamp } from "../../utils/numbers.js";
import { DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";
import { BaseMultiProgressBar } from "../multiProgressBars/BaseMultiProgressBar.js";
import { STATUS_ICONS } from "../../utils/progressBarIcons.js";
import { renderDataLine } from "../../utils/data-line.js";
import cliSpinners from "cli-spinners";
const SKIP_ETA_START_TIME = 1000 * 2;
const MIN_NAME_LENGTH = 20;
const MIN_COMMENT_LENGTH = 15;
const DEFAULT_SPINNER_UPDATE_INTERVAL_MS = 10;
/**
* A class to display transfer progress in the terminal, with a progress bar and other information.
*/
export default class BaseTransferCliProgressBar {
multiProgressBar = BaseMultiProgressBar;
downloadLoadingSpinner;
_spinnerState = {
step: 0,
lastChanged: 0
};
status = null;
options;
minNameLength = MIN_NAME_LENGTH;
constructor(options) {
this.options = options;
this.downloadLoadingSpinner = cliSpinners[options.loadingSpinner ?? "dots"];
}
switchTransferToShortText() {
switch (this.status.transferAction) {
case "Downloading":
return "Pull";
case "Copying":
return "Copy";
}
return this.status.transferAction;
}
get showETA() {
return this.status.startTime < Date.now() - SKIP_ETA_START_TIME;
}
getNameSize(fileName = this.status.fileName) {
return this.options.truncateName === false
? fileName.length
: typeof this.options.truncateName === "number"
? this.options.truncateName
: Math.min(fileName.length, this.minNameLength);
}
getSpinnerText() {
const spinner = this.downloadLoadingSpinner.frames[this._spinnerState.step];
if (this._spinnerState.lastChanged + DEFAULT_SPINNER_UPDATE_INTERVAL_MS < Date.now()) {
this._spinnerState.step++;
if (this._spinnerState.step >= this.downloadLoadingSpinner.frames.length) {
this._spinnerState.step = 0;
}
this._spinnerState.lastChanged = Date.now();
}
return spinner;
}
getNameAndCommentDataParts() {
const { fileName, comment, downloadStatus } = this.status;
let fullComment = comment;
if (downloadStatus === DownloadStatus.Cancelled || downloadStatus === DownloadStatus.Paused) {
if (fullComment) {
fullComment += " | " + downloadStatus;
}
else {
fullComment = downloadStatus;
}
}
return [{
type: "name",
fullText: fileName,
size: this.getNameSize(),
flex: typeof this.options.truncateName === "number"
? undefined
: 1,
maxSize: fileName.length,
cropper: truncateText,
formatter: (text) => chalk.bold(text)
}, ...((fullComment == null || fullComment.length === 0)
? []
: [{
type: "spacer",
fullText: " (",
size: " (".length,
formatter: (text) => chalk.dim(text)
}, {
type: "nameComment",
fullText: fullComment,
size: Math.min(fullComment.length, MIN_COMMENT_LENGTH),
maxSize: fullComment.length,
flex: 1,
cropper: truncateText,
formatter: (text) => chalk.dim(text)
}, {
type: "spacer",
fullText: ")",
size: ")".length,
formatter: (text) => chalk.dim(text)
}])];
}
getETA(spacer = " | ", formatter = text => text) {
const formatedTimeLeft = this.status.timeLeft < 1_000 ? "0s" : this.status.formatTimeLeft;
const timeLeft = `${formatedTimeLeft.padStart("10s".length)} left`;
if (this.showETA) {
return [{
type: "spacer",
fullText: spacer,
size: spacer.length,
formatter(text, size) {
return formatter(text, size, "spacer");
}
}, {
type: "timeLeft",
fullText: timeLeft,
size: timeLeft.length,
formatter(text, size) {
return formatter(text, size, "time");
}
}];
}
return [];
}
createProgressBarLine(length) {
const fileName = truncateText(this.status.fileName, length);
const percentage = clamp(this.status.transferredBytes / this.status.totalBytes, 0, 1);
const fullLength = Math.floor(percentage * length);
const emptyLength = length - fullLength;
return chalk.cyan(fileName.slice(0, fullLength)) + chalk.dim(fileName.slice(fullLength, fullLength + emptyLength));
}
renderProgressLine() {
const { formattedPercentage, formattedSpeed, formatTransferredOfTotal, formatTotal } = this.status;
const status = this.switchTransferToShortText();
return renderDataLine([
{
type: "status",
fullText: status,
size: status.length,
formatter: (text) => chalk.cyan(text)
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "percentage",
fullText: formattedPercentage,
size: "100.00%".length,
formatter: () => chalk.green(formattedPercentage)
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "progressBar",
size: this.getNameSize(),
fullText: "",
flex: 4,
addEndPadding: 4,
maxSize: 40,
formatter: (_, size) => {
return `[${this.createProgressBarLine(size)}]`;
}
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "transferred",
fullText: formatTransferredOfTotal,
size: `999.99MB/${formatTotal}`.length
},
{
type: "spacer",
fullText: " (",
size: " (".length
},
{
type: "speed",
fullText: formattedSpeed,
size: Math.max("00.00kB/s".length, formattedSpeed.length),
formatter: text => chalk.ansi256(31)(text)
},
{
type: "spacer",
fullText: ")",
size: ")".length
},
...this.getETA(" ~ ", text => chalk.dim(text))
]);
}
renderFinishedLine() {
const status = this.status.downloadStatus === DownloadStatus.Finished ? chalk.green(STATUS_ICONS.done) : chalk.red(STATUS_ICONS.failed);
return renderDataLine([
{
type: "status",
fullText: "",
size: 1,
formatter: () => status
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
...this.getNameAndCommentDataParts()
]);
}
renderPendingLine() {
return renderDataLine([
{
type: "status",
fullText: "",
size: 1,
formatter: () => STATUS_ICONS.pending
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
...this.getNameAndCommentDataParts(),
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "description",
fullText: this.status.formatTotal,
size: this.status.formatTotal.length,
formatter: (text) => chalk.dim(text)
}
]);
}
renderLoadingLine() {
const spinner = this.getSpinnerText();
const showText = "Gathering information";
return renderDataLine([
{
type: "status",
fullText: spinner,
size: spinner.length,
formatter: (text) => chalk.cyan(text)
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "name",
fullText: showText,
size: this.getNameSize(showText),
flex: typeof this.options.truncateName === "number"
? undefined
: 1,
maxSize: showText.length,
cropper: truncateText,
formatter: (text) => chalk.bold(text)
}
]);
}
createStatusLine(status) {
this.status = status;
if ([DownloadStatus.Finished, DownloadStatus.Error, DownloadStatus.Cancelled].includes(this.status.downloadStatus)) {
return this.renderFinishedLine();
}
if (this.status.downloadStatus === DownloadStatus.NotStarted) {
return this.renderPendingLine();
}
if (this.status.downloadStatus === DownloadStatus.Loading) {
return this.renderLoadingLine();
}
return this.renderProgressLine();
}
}
//# sourceMappingURL=base-transfer-cli-progress-bar.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
import SummaryTransferCliProgressBar from "./summary-transfer-cli-progress-bar.js";
import { CIMultiProgressBar } from "../multiProgressBars/CIMultiProgressBar.js";
export default class CiTransferCliProgressBar extends SummaryTransferCliProgressBar {
multiProgressBar: typeof CIMultiProgressBar;
minNameLength: number;
}

View File

@@ -0,0 +1,8 @@
import SummaryTransferCliProgressBar from "./summary-transfer-cli-progress-bar.js";
import { CIMultiProgressBar } from "../multiProgressBars/CIMultiProgressBar.js";
const MIN_NAME_LENGTH = 80;
export default class CiTransferCliProgressBar extends SummaryTransferCliProgressBar {
multiProgressBar = CIMultiProgressBar;
minNameLength = MIN_NAME_LENGTH;
}
//# sourceMappingURL=ci-transfer-cli-progress-bar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ci-transfer-cli-progress-bar.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/progress-bars/ci-transfer-cli-progress-bar.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,4CAA4C,CAAC;AAE9E,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,6BAA6B;IACtE,gBAAgB,GAAG,kBAAkB,CAAC;IACtC,aAAa,GAAG,eAAe,CAAC;CAC5C"}

View File

@@ -0,0 +1,9 @@
import BaseTransferCliProgressBar from "./base-transfer-cli-progress-bar.js";
/**
* A class to display transfer progress in the terminal, with a progress bar and other information.
*/
export default class FancyTransferCliProgressBar extends BaseTransferCliProgressBar {
protected renderProgressLine(): string;
protected renderFinishedLine(): string;
protected renderPendingLine(): string;
}

View File

@@ -0,0 +1,125 @@
import chalk from "chalk";
import { PRETTY_MS_OPTIONS } from "../../format-transfer-status.js";
import { renderDataLine } from "../../utils/data-line.js";
import prettyMilliseconds from "pretty-ms";
import sliceAnsi from "slice-ansi";
import stripAnsi from "strip-ansi";
import { DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";
import BaseTransferCliProgressBar from "./base-transfer-cli-progress-bar.js";
import { STATUS_ICONS } from "../../utils/progressBarIcons.js";
/**
* A class to display transfer progress in the terminal, with a progress bar and other information.
*/
export default class FancyTransferCliProgressBar extends BaseTransferCliProgressBar {
renderProgressLine() {
const { formattedSpeed, formatTransferred, formatTotal, formattedPercentage, percentage } = this.status;
const formattedPercentageWithPadding = formattedPercentage.padEnd(6, " ");
const progressBarText = ` ${formattedPercentageWithPadding} (${formatTransferred}/${formatTotal}) `;
const dimEta = this.getETA(" | ", text => chalk.dim(text));
return renderDataLine([{
type: "status",
fullText: "",
size: 1,
formatter: () => STATUS_ICONS.activeDownload
}, {
type: "spacer",
fullText: " ",
size: " ".length
}, ...this.getNameAndCommentDataParts(), {
type: "spacer",
fullText: " ",
size: " ".length
}, {
type: "progressBar",
fullText: progressBarText,
size: Math.max(progressBarText.length, `100.0% (1024.00MB/${formatTotal})`.length),
flex: 4,
addEndPadding: 4,
maxSize: 40,
formatter(_, size) {
const leftPad = " ".repeat(Math.floor((size - progressBarText.length) / 2));
return renderProgressBar({
barText: leftPad + ` ${chalk.black.bgWhiteBright(formattedPercentageWithPadding)} ${chalk.gray(`(${formatTransferred}/${formatTotal})`)} `,
backgroundText: leftPad + ` ${chalk.yellow.bgGray(formattedPercentageWithPadding)} ${chalk.white(`(${formatTransferred}/${formatTotal})`)} `,
length: size,
loadedPercentage: percentage / 100,
barStyle: chalk.black.bgWhiteBright,
backgroundStyle: chalk.bgGray
});
}
}, {
type: "spacer",
fullText: " ",
size: " ".length
}, {
type: "speed",
fullText: formattedSpeed,
size: Math.max("00.00kB/s".length, formattedSpeed.length)
}, ...dimEta]);
}
renderFinishedLine() {
const wasSuccessful = this.status.downloadStatus === DownloadStatus.Finished;
const { endTime, startTime } = this.status;
const downloadTime = (endTime || Date.now()) - startTime;
const finishedText = wasSuccessful
? `downloaded ${this.status.formatTransferred} in ${prettyMilliseconds(downloadTime, PRETTY_MS_OPTIONS)}`
: `failed downloading after ${prettyMilliseconds(endTime - startTime, PRETTY_MS_OPTIONS)}`;
return renderDataLine([{
type: "status",
fullText: "",
size: 1,
formatter: () => (wasSuccessful
? STATUS_ICONS.done
: STATUS_ICONS.failed)
}, {
type: "spacer",
fullText: " ",
size: " ".length,
formatter: (text) => text
}, ...this.getNameAndCommentDataParts(), {
type: "spacer",
fullText: " ",
size: " ".length,
formatter: (text) => text
}, {
type: "description",
fullText: finishedText,
size: finishedText.length,
formatter: (text) => chalk.dim(text)
}]);
}
renderPendingLine() {
const pendingText = `will download ${this.status.formatTotal}`;
return renderDataLine([{
type: "status",
fullText: "",
size: 1,
formatter: () => STATUS_ICONS.pending
}, {
type: "spacer",
fullText: " ",
size: " ".length,
formatter: (text) => text
}, ...this.getNameAndCommentDataParts(), {
type: "spacer",
fullText: " ",
size: " ".length,
formatter: (text) => text
}, {
type: "description",
fullText: pendingText,
size: pendingText.length,
formatter: (text) => chalk.dim(text)
}]);
}
}
function renderProgressBar({ barText, backgroundText, length, loadedPercentage, barStyle, backgroundStyle }) {
const barChars = Math.floor(length * loadedPercentage);
const backgroundChars = length - barChars;
const slicedBarText = sliceAnsi(barText, 0, barChars);
const paddedBarText = slicedBarText + " ".repeat(barChars - stripAnsi(slicedBarText).length);
const slicedBackgroundText = sliceAnsi(backgroundText, barChars, barChars + backgroundChars);
const paddedBackgroundText = slicedBackgroundText + " ".repeat(backgroundChars - stripAnsi(slicedBackgroundText).length);
return barStyle(paddedBarText) + backgroundStyle(paddedBackgroundText);
}
//# sourceMappingURL=fancy-transfer-cli-progress-bar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fancy-transfer-cli-progress-bar.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/progress-bars/fancy-transfer-cli-progress-bar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAW,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAClE,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,cAAc,EAAC,MAAM,gEAAgE,CAAC;AAC9F,OAAO,0BAA0B,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,0BAA0B;IAC5D,kBAAkB;QACjC,MAAM,EAAC,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAEtG,MAAM,8BAA8B,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC1E,MAAM,eAAe,GAAG,IAAI,8BAA8B,KAAK,iBAAiB,IAAI,WAAW,IAAI,CAAC;QAEpG,MAAM,MAAM,GAAa,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAErE,OAAO,cAAc,CAAC,CAAC;gBACnB,IAAI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GAAG,CAAC,IAAI,CAAC;aACvC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAED,SAAS,iBAAiB,CAAC,EAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAOvG;IACG,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,CAAC;IAE1C,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,aAAa,GAAG,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7F,MAAM,oBAAoB,GAAG,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC;IAC7F,MAAM,oBAAoB,GAAG,oBAAoB,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;IAEzH,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAC3E,CAAC"}

View File

@@ -0,0 +1,9 @@
import { SummaryMultiProgressBar } from "../multiProgressBars/SummaryMultiProgressBar.js";
import FancyTransferCliProgressBar from "./fancy-transfer-cli-progress-bar.js";
export default class SummaryTransferCliProgressBar extends FancyTransferCliProgressBar {
multiProgressBar: typeof SummaryMultiProgressBar;
switchTransferToIcon(): string;
getSpinnerText(): string;
renderProgressLine(): string;
protected renderDownloadSequence(): string;
}

View File

@@ -0,0 +1,103 @@
import chalk from "chalk";
import { SummaryMultiProgressBar } from "../multiProgressBars/SummaryMultiProgressBar.js";
import { renderDataLine } from "../../utils/data-line.js";
import FancyTransferCliProgressBar from "./fancy-transfer-cli-progress-bar.js";
import { STATUS_ICONS } from "../../utils/progressBarIcons.js";
import { DownloadFlags } from "../../../download-engine/download-file/progress-status-file.js";
export default class SummaryTransferCliProgressBar extends FancyTransferCliProgressBar {
multiProgressBar = SummaryMultiProgressBar;
switchTransferToIcon() {
switch (this.status.transferAction) {
case "Downloading":
return "↓";
case "Copying":
return "→";
}
return this.status.transferAction;
}
getSpinnerText() {
return STATUS_ICONS.pending;
}
renderProgressLine() {
if (this.status.downloadFlags.includes(DownloadFlags.DownloadSequence)) {
return this.renderDownloadSequence();
}
const pendingText = `downloading ${this.status.formatTotal}`;
return renderDataLine([{
type: "status",
fullText: "",
size: 1,
formatter: () => STATUS_ICONS.activeDownload
}, {
type: "spacer",
fullText: " ",
size: " ".length
}, ...this.getNameAndCommentDataParts(), {
type: "spacer",
fullText: " ",
size: " ".length
}, {
type: "description",
fullText: pendingText,
size: pendingText.length,
formatter: (text) => chalk.dim(text)
}]);
}
renderDownloadSequence() {
const { formatTransferredOfTotal, formattedSpeed, comment, formattedPercentage } = this.status;
const progressBar = `(${formatTransferredOfTotal})`;
return renderDataLine([
{
type: "status",
fullText: "",
size: 1,
formatter: () => chalk.cyan(this.switchTransferToIcon())
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "percentage",
fullText: formattedPercentage,
size: 6,
formatter: (text) => text
},
{
type: "spacer",
fullText: " ",
size: " ".length
},
{
type: "progressBar",
fullText: progressBar,
size: progressBar.length
},
{
type: "spacer",
fullText: " | ",
size: " | ".length,
formatter: (text) => chalk.dim(text)
},
{
type: "nameComment",
fullText: comment || "",
size: (comment || "").length
},
{
type: "spacer",
fullText: " | ",
size: " | ".length,
formatter: (text) => chalk.dim(text)
},
{
type: "speed",
fullText: formattedSpeed,
size: formattedSpeed.length
},
...this.getETA(" | ")
]);
}
}
//# sourceMappingURL=summary-transfer-cli-progress-bar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"summary-transfer-cli-progress-bar.js","sourceRoot":"","sources":["../../../../../src/download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IAAI,EAAE,KAAK,CAAC,MAAM;gBAClB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;aACvC;YACD;gBACI,IAAI,EAAE,aAAa;gBACnB,QAAQ,EAAE,OAAO,IAAI,EAAE;gBACvB,IAAI,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM;aAC/B;YACD;gBACI,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,KAAK,CAAC,MAAM;gBAClB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;aACvC;YACD;gBACI,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,cAAc,CAAC,MAAM;aAC9B;YACD,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;SACxB,CAAC,CAAC;IACP,CAAC;CACJ"}

View File

@@ -0,0 +1,3 @@
import BaseTransferCliProgressBar, { BaseCliOptions } from "./base-transfer-cli-progress-bar.js";
export type AvailableCLIProgressStyle = "basic" | "fancy" | "ci" | "summary" | "auto";
export default function switchCliProgressStyle(cliStyle: AvailableCLIProgressStyle, options: BaseCliOptions): BaseTransferCliProgressBar;

View File

@@ -0,0 +1,27 @@
import BaseTransferCliProgressBar from "./base-transfer-cli-progress-bar.js";
import FancyTransferCliProgressBar from "./fancy-transfer-cli-progress-bar.js";
import SummaryTransferCliProgressBar from "./summary-transfer-cli-progress-bar.js";
import ci from "ci-info";
import CiTransferCliProgressBar from "./ci-transfer-cli-progress-bar.js";
export default function switchCliProgressStyle(cliStyle, options) {
switch (cliStyle) {
case "basic":
return new BaseTransferCliProgressBar(options);
case "fancy":
return new FancyTransferCliProgressBar(options);
case "summary":
return new SummaryTransferCliProgressBar(options);
case "ci":
return new CiTransferCliProgressBar(options);
case "auto":
if (ci.isCI || process.env.IPULL_USE_CI_STYLE) {
return switchCliProgressStyle("ci", options);
}
else {
return switchCliProgressStyle("fancy", options);
}
}
void cliStyle;
throw new Error(`Unknown CLI progress style: ${cliStyle}`);
}
//# sourceMappingURL=switch-cli-progress-style.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"switch-cli-progress-style.js","sourceRoot":"","sources":["../../../../../src/download/transfer-visualize/transfer-cli/progress-bars/switch-cli-progress-style.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA4C,MAAM,qCAAqC,CAAC;AAC/F,OAAO,2BAA2B,MAAM,sCAAsC,CAAC;AAC/E,OAAO,6BAA6B,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,wBAAwB,MAAM,mCAAmC,CAAC;AAIzE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,QAAmC,EAAE,OAAuB;IACvG,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,OAAO;YACR,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAEnD,KAAK,OAAO;YACR,OAAO,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAEpD,KAAK,SAAS;YACV,OAAO,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAEtD,KAAK,IAAI;YACL,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAEjD,KAAK,MAAM;YACP,IAAI,EAAE,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;gBAC5C,OAAO,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACJ,OAAO,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACpD,CAAC;IACT,CAAC;IAED,KAAM,QAAyB,CAAC;IAChC,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;AAC/D,CAAC"}

View File

@@ -0,0 +1,42 @@
import UpdateManager from "stdout-update";
import { TransferCliProgressBar } from "./progress-bars/base-transfer-cli-progress-bar.js";
import cliSpinners from "cli-spinners";
import CliSpinnersLoadingAnimation from "./loading-animation/cli-spinners-loading-animation.js";
import { FormattedStatus } from "../format-transfer-status.js";
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
export type TransferCliOptions = {
action?: string;
name?: string;
maxViewDownloads: number;
truncateName: boolean | number;
debounceWait: number;
maxDebounceWait: number;
createProgressBar: TransferCliProgressBar;
createMultiProgressBar: typeof BaseMultiProgressBar;
loadingAnimation: cliSpinners.SpinnerName;
loadingText?: string;
};
export declare const DEFAULT_TRANSFER_CLI_OPTIONS: TransferCliOptions;
export declare enum CLI_LEVEL {
LOW = 0,
HIGH = 2
}
export default class TransferCli {
static activeCLILevel: CLI_LEVEL;
readonly loadingAnimation: CliSpinnersLoadingAnimation;
protected options: TransferCliOptions;
protected stdoutManager: UpdateManager;
protected myCLILevel: number;
protected latestProgress: [FormattedStatus[], FormattedStatus];
private _cliStopped;
private readonly _updateStatuesDebounce;
private _multiProgressBar;
private _isFirstPrint;
constructor(options: Partial<TransferCliOptions>, myCLILevel?: CLI_LEVEL);
start(): void;
stop(): void;
private _processExit;
updateStatues(statues: FormattedStatus[], oneStatus: FormattedStatus): void;
private _updateStatues;
protected _logUpdate(text: string): void;
}

View File

@@ -0,0 +1,99 @@
import UpdateManager from "stdout-update";
import debounce from "lodash.debounce";
import cliSpinners from "cli-spinners";
import CliSpinnersLoadingAnimation from "./loading-animation/cli-spinners-loading-animation.js";
import switchCliProgressStyle from "./progress-bars/switch-cli-progress-style.js";
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
export const DEFAULT_TRANSFER_CLI_OPTIONS = {
maxViewDownloads: 10,
truncateName: true,
debounceWait: 20,
maxDebounceWait: process.platform === "win32" ? 500 : 100,
createProgressBar: switchCliProgressStyle("auto", { truncateName: true }),
loadingAnimation: "dots",
loadingText: "Gathering information",
createMultiProgressBar: BaseMultiProgressBar
};
export var CLI_LEVEL;
(function (CLI_LEVEL) {
CLI_LEVEL[CLI_LEVEL["LOW"] = 0] = "LOW";
CLI_LEVEL[CLI_LEVEL["HIGH"] = 2] = "HIGH";
})(CLI_LEVEL || (CLI_LEVEL = {}));
export default class TransferCli {
static activeCLILevel = CLI_LEVEL.LOW;
loadingAnimation;
options;
stdoutManager = UpdateManager.getInstance();
myCLILevel;
latestProgress = null;
_cliStopped = true;
_updateStatuesDebounce;
_multiProgressBar;
_isFirstPrint = true;
constructor(options, myCLILevel = CLI_LEVEL.LOW) {
TransferCli.activeCLILevel = this.myCLILevel = myCLILevel;
this.options = { ...DEFAULT_TRANSFER_CLI_OPTIONS, ...options };
this._multiProgressBar = new this.options.createProgressBar.multiProgressBar(this.options);
const maxDebounceWait = this._multiProgressBar.updateIntervalMs || this.options.maxDebounceWait;
this._updateStatuesDebounce = debounce(this._updateStatues.bind(this), maxDebounceWait, {
maxWait: maxDebounceWait
});
this.loadingAnimation = new CliSpinnersLoadingAnimation(cliSpinners[this.options.loadingAnimation], {
loadingText: this.options.loadingText,
updateIntervalMs: this._multiProgressBar.updateIntervalMs,
logType: this._multiProgressBar.printType
});
this._processExit = this._processExit.bind(this);
}
start() {
if (this.myCLILevel !== TransferCli.activeCLILevel)
return;
this._cliStopped = false;
if (this._multiProgressBar.printType === "update") {
this.stdoutManager.hook();
}
process.on("SIGINT", this._processExit);
}
stop() {
if (this._cliStopped || this.myCLILevel !== TransferCli.activeCLILevel)
return;
this._updateStatues();
this._cliStopped = true;
if (this._multiProgressBar.printType === "update") {
this.stdoutManager.unhook(false);
}
process.off("SIGINT", this._processExit);
}
_processExit() {
this.stop();
process.exit(0);
}
updateStatues(statues, oneStatus) {
this.latestProgress = [statues, oneStatus];
if (this._isFirstPrint) {
this._isFirstPrint = false;
this._updateStatues();
}
else {
this._updateStatuesDebounce();
}
}
_updateStatues() {
if (this._cliStopped || this.myCLILevel !== TransferCli.activeCLILevel) {
return; // Do not update if there is a higher level CLI, meaning that this CLI is sub-CLI
}
const printLog = this._multiProgressBar.createMultiProgressBar(...this.latestProgress);
if (printLog) {
this._logUpdate(printLog);
}
}
_logUpdate(text) {
if (this._multiProgressBar.printType === "update") {
this.stdoutManager.update(text.split("\n"));
}
else {
console.log(text);
}
}
}
//# sourceMappingURL=transfer-cli.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transfer-cli.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/transfer-cli/transfer-cli.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,2BAA2B,MAAM,uDAAuD,CAAC;AAEhG,OAAO,sBAAsB,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAC,oBAAoB,EAAC,MAAM,6CAA6C,CAAC;AAejF,MAAM,CAAC,MAAM,4BAA4B,GAAuB;IAC5D,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;IACzD,iBAAiB,EAAE,sBAAsB,CAAC,MAAM,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC;IACvE,gBAAgB,EAAE,MAAM;IACxB,WAAW,EAAE,uBAAuB;IACpC,sBAAsB,EAAE,oBAAoB;CAC/C,CAAC;AAEF,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,uCAAO,CAAA;IACP,yCAAQ,CAAA;AACZ,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAGD,MAAM,CAAC,OAAO,OAAO,WAAW;IACrB,MAAM,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC;IAC7B,gBAAgB,CAA8B;IACp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AAC,iFAAiF;QAC7F,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;QACvF,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IAES,UAAU,CAAC,IAAY;QAC7B,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACL,CAAC"}

View File

@@ -0,0 +1,28 @@
export type TransferProgressInfo = {
transferredBytes: number;
totalBytes: number;
speed: number;
percentage: number;
timeLeft: number;
ended: boolean;
};
/**
* Class to calculate transfer statistics, such as speed, percentage, time left, etc.
* @example
* You need to call `updateProgress` on every progress update to get the latest statistics.
* ```ts
* const statistics = new TransferStatistics();
* const progress = statistics.updateProgress(100, 1000); // { speed: 100, percentage: 10, timeLeft: 900 ...}
* console.log(progress);
* ```
*/
export default class TransferStatistics {
protected static readonly _AVERAGE_SPEED_LAST_SECONDS = 10;
private _speeds;
private _lastTransferred;
private _latestProgress?;
get latestProgress(): TransferProgressInfo | undefined;
private _calculateSpeed;
updateProgress(transferred: number, total: number): TransferProgressInfo;
static oneStatistics(transferred: number, total: number): TransferProgressInfo;
}

View File

@@ -0,0 +1,55 @@
import { clamp } from "./utils/numbers.js";
const MAX_TIME_LEFT = 35 * 24 * 60 * 60 * 1000; // 35 days
/**
* Class to calculate transfer statistics, such as speed, percentage, time left, etc.
* @example
* You need to call `updateProgress` on every progress update to get the latest statistics.
* ```ts
* const statistics = new TransferStatistics();
* const progress = statistics.updateProgress(100, 1000); // { speed: 100, percentage: 10, timeLeft: 900 ...}
* console.log(progress);
* ```
*/
export default class TransferStatistics {
static _AVERAGE_SPEED_LAST_SECONDS = 10;
_speeds = [];
_lastTransferred = 0;
_latestProgress;
get latestProgress() {
return this._latestProgress;
}
_calculateSpeed(currentTransferred) {
const dateInSeconds = Math.floor(Date.now() / 1000);
this._speeds[dateInSeconds] ??= 0;
this._speeds[dateInSeconds] += currentTransferred - (this._lastTransferred || currentTransferred);
this._lastTransferred = currentTransferred;
let averageSecondsAverageSpeed = 0;
for (let i = 0; i < TransferStatistics._AVERAGE_SPEED_LAST_SECONDS; i++) {
averageSecondsAverageSpeed += this._speeds[dateInSeconds - i] || 0;
}
for (const key in this._speeds) {
if (parseInt(key) < dateInSeconds - TransferStatistics._AVERAGE_SPEED_LAST_SECONDS) {
delete this._speeds[key];
}
}
return averageSecondsAverageSpeed / TransferStatistics._AVERAGE_SPEED_LAST_SECONDS;
}
updateProgress(transferred, total) {
const speed = clamp(this._calculateSpeed(transferred));
const timeLeft = (total - transferred) / speed;
const timeLeftFinalNumber = clamp((timeLeft || 0) * 1000, 0, MAX_TIME_LEFT);
const percentage = clamp(((transferred / total) * 100), 0, 100);
return this._latestProgress = {
transferredBytes: clamp(transferred),
totalBytes: clamp(total),
speed,
percentage,
timeLeft: timeLeftFinalNumber,
ended: percentage == 100
};
}
static oneStatistics(transferred, total) {
return new TransferStatistics().updateProgress(transferred, total);
}
}
//# sourceMappingURL=transfer-statistics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transfer-statistics.js","sourceRoot":"","sources":["../../../src/download/transfer-visualize/transfer-statistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAWzC,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,UAAU;AAE1D;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACzB,MAAM,CAAU,2B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,CAAC,GAAG,KAAK,CAAC;QAC/C,MAAM,mBAAmB,GAAG,KAAK,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;QAC5E,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAC,eAAe,GAAG;YAC1B,gBAAgB,EAAE,KAAK,CAAC,WAAW,CAAC;YACpC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;YACxB,KAAK;YACL,UAAU;YACV,QAAQ,EAAE,mBAAmB;YAC7B,KAAK,EAAE,UAAU,IAAI,GAAG;SAC3B,CAAC;IACN,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,WAAmB,EAAE,KAAa;QACnD,OAAO,IAAI,kBAAkB,EAAE,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC"}

View File

@@ -0,0 +1,3 @@
export declare const TRUNCATE_TEXT_MAX_LENGTH = 30;
export declare function truncateText(text: string, maxLength?: number): string;
export declare function centerPad(text: string, length: number): string;

View File

@@ -0,0 +1,18 @@
export const TRUNCATE_TEXT_MAX_LENGTH = 30;
export function truncateText(text, maxLength = TRUNCATE_TEXT_MAX_LENGTH) {
if (text.length <= maxLength) {
return text;
}
const ellipsis = "...";
const charsToShow = maxLength - ellipsis.length;
const firstPartChars = Math.ceil(charsToShow / 2);
const secondPartChars = Math.floor(charsToShow / 2);
return text.substring(0, firstPartChars) + ellipsis + text.substring(text.length - secondPartChars);
}
export function centerPad(text, length) {
const padLength = Math.max(0, length - text.length);
const leftPad = Math.floor(padLength / 2);
const rightPad = Math.ceil(padLength / 2);
return " ".repeat(leftPad) + text + " ".repeat(rightPad);
}
//# sourceMappingURL=cli-text.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cli-text.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/utils/cli-text.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,SAAS,GAAG,wBAAwB;IAC3E,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC;IACvB,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IAEpD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC;AACxG,CAAC;AAGD,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,MAAc;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC"}

View File

@@ -0,0 +1,23 @@
export type DataPart = {
type: "status" | "name" | "nameComment" | "progressBar" | "percentage" | "transferred" | "speed" | "timeLeft" | "spacer" | "description";
fullText: string;
size: number;
addEndPadding?: number;
flex?: number;
maxSize?: number;
cropper?: (text: string, size: number) => string;
formatter?(text: string, size: number): string;
};
export type DataLine = DataPart[];
export declare function renderDataLine(dataLine: DataLine, lineLength?: number): string;
export declare function renderDataPart(dataPart: DataPart): string;
export declare function resizeDataLine(dataLine: DataLine, lineLength: number): {
type: "status" | "name" | "nameComment" | "progressBar" | "percentage" | "transferred" | "speed" | "timeLeft" | "spacer" | "description";
fullText: string;
size: number;
addEndPadding?: number;
flex?: number;
maxSize?: number;
cropper?: (text: string, size: number) => string;
formatter?(text: string, size: number): string;
}[];

View File

@@ -0,0 +1,68 @@
export function renderDataLine(dataLine, lineLength = process.stdout.columns - 1) {
return resizeDataLine(dataLine, lineLength)
.map(renderDataPart)
.join("");
}
export function renderDataPart(dataPart) {
let text = dataPart.fullText;
if (dataPart.cropper != null) {
text = dataPart
.cropper(text, dataPart.size)
.slice(0, dataPart.size)
.padEnd(dataPart.size);
}
else {
text = text
.slice(0, dataPart.size)
.padEnd(dataPart.size);
}
if (dataPart.formatter != null) {
text = dataPart.formatter(text, dataPart.size);
}
return text;
}
// only enlarges parts, doesn't shrink them at the moment
export function resizeDataLine(dataLine, lineLength) {
const res = dataLine.map((part) => ({ ...part }));
const currentSize = dataLine.reduce((acc, part) => acc + part.size, 0);
let sizeLeft = lineLength - currentSize;
if (sizeLeft <= 0)
return res;
for (let i = 0; i < res.length && sizeLeft > 0; i++) {
const part = res[i];
if (part.addEndPadding != null) {
const add = Math.min(part.addEndPadding, sizeLeft);
part.size += add;
sizeLeft -= add;
part.addEndPadding -= add;
if (part.addEndPadding === 0)
delete part.addEndPadding;
}
}
while (sizeLeft > 0) {
const flexBoxCandidates = [];
let totalFlexbox = 0;
for (let i = 0; i < res.length; i++) {
const part = res[i];
if (part.flex == null)
continue;
if (part.maxSize != null && part.size >= part.maxSize)
continue;
flexBoxCandidates.push(part);
totalFlexbox += part.flex;
}
flexBoxCandidates.sort((a, b) => a.flex - b.flex);
if (flexBoxCandidates.length === 0)
break;
const sizeLeftSnapshot = sizeLeft;
for (const part of flexBoxCandidates) {
let partSize = Math.ceil(sizeLeftSnapshot * (part.flex / totalFlexbox));
if (part.maxSize != null && partSize + part.size > part.maxSize)
partSize = part.maxSize - part.size;
part.size += partSize;
sizeLeft -= partSize;
}
}
return res;
}
//# sourceMappingURL=data-line.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"data-line.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/utils/data-line.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,cAAc,CAAC,QAAkB,EAAE,aAAqB,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC;IAC9F,OAAO,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC;SACtC,GAAG,CAAC,cAAc,CAAC;SACnB,IAAI,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAkB;IAC7C,IAAI,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,IAAI,GAAG,QAAQ;aACV,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;aAC5B,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC;aACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACJ,IAAI,GAAG,IAAI;aACN,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC;aACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,y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AAC,CAAC,CAAC,CAAC;YACpB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI;gBACjB,SAAS;YAEb,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO;gBACjD,SAAS;YAEb,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC;QAC9B,CAAC;QAED,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAK,GAAG,CAAC,CAAC,IAAK,CAAC,CAAC;QAEpD,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC;YAC9B,MAAM;QAEV,MAAM,gBAAgB,GAAG,QAAQ,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;YACnC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,IAAI,CAAC,IAAK,GAAG,YAAY,CAAC,CAAC,CAAC;YACzE,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO;gBAC3D,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;YAExC,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC;YACtB,QAAQ,IAAI,QAAQ,CAAC;QACzB,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}

View File

@@ -0,0 +1 @@
export declare function clamp(value: number, min?: number, max?: number): number;

View File

@@ -0,0 +1,4 @@
export function clamp(value, min = 0, max = Number.MAX_VALUE) {
return Math.min(Math.max(value, min), max);
}
//# sourceMappingURL=numbers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/utils/numbers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,SAAS;IAChE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC"}

View File

@@ -0,0 +1,6 @@
export declare const STATUS_ICONS: {
activeDownload: string;
done: string;
failed: string;
pending: string;
};

View File

@@ -0,0 +1,16 @@
import isUnicodeSupported from "is-unicode-supported";
import chalk from "chalk";
export const STATUS_ICONS = isUnicodeSupported()
? {
activeDownload: chalk.blue("⏵"),
done: chalk.green("✔"),
failed: chalk.red("✖"),
pending: chalk.yellow("\u25f7")
}
: {
activeDownload: chalk.blue.bold(">"),
done: chalk.green("√"),
failed: chalk.red("×"),
pending: chalk.yellow.bold("-")
};
//# sourceMappingURL=progressBarIcons.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"progressBarIcons.js","sourceRoot":"","sources":["../../../../src/download/transfer-visualize/utils/progressBarIcons.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE;IAC5C,CAAC,CAAC;QACE,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/B,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACtB,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QACtB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;KAClC;IACD,CAAC,CAAC;QACE,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACpC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACtB,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QACtB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KAClC,CAAC"}