Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipull

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipull - npm Package Compare versions

Comparing version 3.8.1 to 3.9.0

dist/download/download-engine/engine/error/no-download-engine-provided-error.d.ts

3

dist/browser.d.ts

@@ -17,3 +17,4 @@ import { downloadFileBrowser, DownloadFileBrowserOptions, downloadSequenceBrowser } from "./download/browser-download.js";

import { DownloadFlags, DownloadStatus } from "./download/download-engine/download-file/progress-status-file.js";
export { DownloadFlags, DownloadStatus, downloadFileBrowser, downloadSequenceBrowser, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError };
import { NoDownloadEngineProvidedError } from "./download/download-engine/engine/error/no-download-engine-provided-error.js";
export { DownloadFlags, DownloadStatus, downloadFileBrowser, downloadSequenceBrowser, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError, NoDownloadEngineProvidedError };
export type { BaseDownloadEngine, DownloadFileBrowserOptions, DownloadEngineBrowser, DownloadEngineMultiDownload, FormattedStatus, SaveProgressInfo };

@@ -12,3 +12,4 @@ import { downloadFileBrowser, downloadSequenceBrowser } from "./download/browser-download.js";

import { DownloadFlags, DownloadStatus } from "./download/download-engine/download-file/progress-status-file.js";
export { DownloadFlags, DownloadStatus, downloadFileBrowser, downloadSequenceBrowser, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError };
import { NoDownloadEngineProvidedError } from "./download/download-engine/engine/error/no-download-engine-provided-error.js";
export { DownloadFlags, DownloadStatus, downloadFileBrowser, downloadSequenceBrowser, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError, NoDownloadEngineProvidedError };
//# sourceMappingURL=browser.js.map
import DownloadEngineBrowser from "./download-engine/engine/download-engine-browser.js";
import DownloadEngineMultiDownload from "./download-engine/engine/download-engine-multi-download.js";
import { NoDownloadEngineProvidedError } from "./download-engine/engine/error/no-download-engine-provided-error.js";
const DEFAULT_PARALLEL_STREAMS_FOR_BROWSER = 3;

@@ -19,4 +20,7 @@ /**

export async function downloadSequenceBrowser(...downloads) {
if (downloads.length === 0) {
throw new NoDownloadEngineProvidedError();
}
return await DownloadEngineMultiDownload.fromEngines(downloads);
}
//# sourceMappingURL=browser-download.js.map

@@ -15,2 +15,3 @@ export type ProgressStatus = {

export declare enum DownloadStatus {
Loading = "Loading",
Active = "Active",

@@ -34,3 +35,3 @@ Paused = "Paused",

readonly transferAction: string;
readonly downloadStatus: DownloadStatus;
downloadStatus: DownloadStatus;
downloadFlags: DownloadFlags[];

@@ -37,0 +38,0 @@ totalBytes: number;

export var DownloadStatus;
(function (DownloadStatus) {
DownloadStatus["Loading"] = "Loading";
DownloadStatus["Active"] = "Active";

@@ -4,0 +5,0 @@ DownloadStatus["Paused"] = "Paused";

@@ -21,6 +21,11 @@ import { EventEmitter } from "eventemitter3";

protected _closeFiles: (() => Promise<void>)[];
protected _lastStatus?: ProgressStatusWithIndex;
protected _loadingDownloads: number;
protected constructor(engines: (DownloadEngineMultiAllowedEngines | DownloadEngineMultiDownload)[], options: DownloadEngineMultiDownloadOptions);
get downloadStatues(): (FormattedStatus | ProgressStatusWithIndex)[];
get status(): ProgressStatusWithIndex;
get downloadSize(): number;
protected _init(): void;
private _addEngine;
addDownload(engine: Engine | DownloadEngineMultiDownload<any> | Promise<Engine | DownloadEngineMultiDownload<any>>): Promise<void>;
download(): Promise<void>;

@@ -27,0 +32,0 @@ private _changeEngineFinishDownload;

@@ -6,2 +6,3 @@ import { EventEmitter } from "eventemitter3";

import { DownloadFlags, DownloadStatus } from "../download-file/progress-status-file.js";
import { NoDownloadEngineProvidedError } from "./error/no-download-engine-provided-error.js";
const DEFAULT_PARALLEL_DOWNLOADS = 1;

@@ -16,2 +17,4 @@ export default class DownloadEngineMultiDownload extends EventEmitter {

_closeFiles = [];
_lastStatus;
_loadingDownloads = 0;
constructor(engines, options) {

@@ -26,2 +29,8 @@ super();

}
get status() {
if (!this._lastStatus) {
throw new NoDownloadEngineProvidedError();
}
return this._lastStatus;
}
get downloadSize() {

@@ -32,11 +41,2 @@ return this.downloads.reduce((acc, engine) => acc + engine.downloadSize, 0);

this._progressStatisticsBuilder.downloadStatus = DownloadStatus.NotStarted;
this._changeEngineFinishDownload();
for (const [index, engine] of Object.entries(this.downloads)) {
const numberIndex = Number(index);
this._downloadStatues[numberIndex] = engine.status;
engine.on("progress", (progress) => {
this._downloadStatues[numberIndex] = progress;
});
}
this._progressStatisticsBuilder.add(...this.downloads);
this._progressStatisticsBuilder.on("progress", progress => {

@@ -47,5 +47,41 @@ progress = {

};
this._lastStatus = progress;
this.emit("progress", progress);
});
let index = 0;
for (const engine of this.downloads) {
this._addEngine(engine, index++);
}
// Prevent multiple progress events on adding engines
this._progressStatisticsBuilder.add(...this.downloads);
}
_addEngine(engine, index) {
this._downloadStatues[index] = engine.status;
engine.on("progress", (progress) => {
this._downloadStatues[index] = progress;
});
this._changeEngineFinishDownload(engine);
}
async addDownload(engine) {
const index = this.downloads.length + this._loadingDownloads;
this._downloadStatues[index] = ProgressStatisticsBuilder.loadingStatusEmptyStatistics();
this._loadingDownloads++;
this._progressStatisticsBuilder._totalDownloadParts++;
const awaitEngine = engine instanceof Promise ? await engine : engine;
this._progressStatisticsBuilder._totalDownloadParts--;
this._loadingDownloads--;
if (awaitEngine instanceof DownloadEngineMultiDownload) {
let countEngines = 0;
for (const subEngine of awaitEngine.downloads) {
this._addEngine(subEngine, index + countEngines++);
this.downloads.push(subEngine);
}
this._progressStatisticsBuilder.add(...awaitEngine.downloads);
}
else {
this._addEngine(awaitEngine, index);
this.downloads.push(awaitEngine);
this._progressStatisticsBuilder.add(awaitEngine);
}
}
async download() {

@@ -72,15 +108,13 @@ if (this._activeEngines.size) {

}
_changeEngineFinishDownload() {
for (const engine of this.downloads) {
const options = engine._fileEngineOptions;
const onFinishAsync = options.onFinishAsync;
const onCloseAsync = options.onCloseAsync;
options.onFinishAsync = undefined;
options.onCloseAsync = undefined;
this._closeFiles.push(async () => {
await onFinishAsync?.();
await options.writeStream.close();
await onCloseAsync?.();
});
}
_changeEngineFinishDownload(engine) {
const options = engine._fileEngineOptions;
const onFinishAsync = options.onFinishAsync;
const onCloseAsync = options.onCloseAsync;
options.onFinishAsync = undefined;
options.onCloseAsync = undefined;
this._closeFiles.push(async () => {
await onFinishAsync?.();
await options.writeStream.close();
await onCloseAsync?.();
});
}

@@ -87,0 +121,0 @@ async _finishEnginesDownload() {

@@ -6,2 +6,3 @@ import DownloadEngineNodejs from "./download-engine/engine/download-engine-nodejs.js";

import { CLI_LEVEL } from "./transfer-visualize/transfer-cli/transfer-cli.js";
import { NoDownloadEngineProvidedError } from "./download-engine/engine/error/no-download-engine-provided-error.js";
const DEFAULT_PARALLEL_STREAMS_FOR_NODEJS = 3;

@@ -33,2 +34,5 @@ /**

}
if (downloads.length === 0) {
throw new NoDownloadEngineProvidedError();
}
downloadOptions.cliLevel = CLI_LEVEL.HIGH;

@@ -35,0 +39,0 @@ const downloader = DownloadEngineMultiDownload.fromEngines(downloads, downloadOptions);

@@ -6,2 +6,3 @@ import BaseDownloadEngine from "../download-engine/engine/base-download-engine.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 & {

@@ -13,3 +14,3 @@ index: number;

}
export type AnyEngine = DownloadEngineFile | BaseDownloadEngine;
export type AnyEngine = DownloadEngineFile | BaseDownloadEngine | DownloadEngineMultiDownload;
export default class ProgressStatisticsBuilder extends EventEmitter<CliProgressBuilderEvents> {

@@ -20,9 +21,13 @@ private _engines;

private _transferredBytes;
private _totalDownloadParts;
private _activeDownloadPart;
private _startTime;
private statistics;
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;

@@ -32,3 +37,4 @@ private _initEvents;

static oneStatistics(engine: DownloadEngineFile): FormattedStatus;
static loadingStatusEmptyStatistics(): FormattedStatus;
}
export {};
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 {

@@ -9,6 +10,10 @@ _engines = [];

_transferredBytes = 0;
/**
* @internal
*/
_totalDownloadParts = 0;
_activeDownloadPart = 0;
_startTime = 0;
statistics = new TransferStatistics();
_statistics = new TransferStatistics();
_lastStatus;
downloadStatus = null;

@@ -22,8 +27,16 @@ get totalBytes() {

}
get status() {
return this._lastStatus;
}
/**
* Add engines to the progress statistics builder, will only add engines once
*/
add(...engines) {
for (const engine of engines) {
this._initEvents(engine);
if (!this._engines.includes(engine)) {
this._initEvents(engine, engines.at(-1) === engine);
}
}
}
_initEvents(engine) {
_initEvents(engine, sendProgress = false) {
this._engines.push(engine);

@@ -41,2 +54,5 @@ this._totalBytes += engine.downloadSize;

});
if (sendProgress) {
this._sendProgress(engine.status, index, downloadPartStart);
}
}

@@ -49,5 +65,5 @@ _sendProgress(data, index, downloadPartStart) {

}
const progress = this.statistics.updateProgress(this.transferredBytesWithActiveTransfers, this.totalBytes);
const progress = this._statistics.updateProgress(this.transferredBytesWithActiveTransfers, this.totalBytes);
const activeDownloads = Object.keys(this._activeTransfers).length;
this.emit("progress", {
this._lastStatus = {
...createFormattedStatus({

@@ -66,3 +82,4 @@ ...progress,

index
});
};
this.emit("progress", this._lastStatus);
}

@@ -77,3 +94,12 @@ static oneStatistics(engine) {

}
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

@@ -6,2 +6,3 @@ import DownloadEngineNodejs from "../../download-engine/engine/download-engine-nodejs.js";

import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
import cliSpinners from "cli-spinners";
type AllowedDownloadEngines = DownloadEngineNodejs | DownloadEngineMultiDownload;

@@ -17,2 +18,3 @@ export type CliProgressDownloadEngineOptions = {

fetchStrategy?: "localFile" | "fetch";
loadingAnimation?: cliSpinners.SpinnerName;
};

@@ -19,0 +21,0 @@ export default class CliAnimationWrapper {

@@ -31,3 +31,6 @@ import switchCliProgressStyle from "./progress-bars/switch-cli-progress-style.js";

} :
switchCliProgressStyle(this._options.cliStyle ?? DEFAULT_CLI_STYLE, { truncateName: this._options.truncateName });
switchCliProgressStyle(this._options.cliStyle ?? DEFAULT_CLI_STYLE, {
truncateName: this._options.truncateName,
loadingSpinner: this._options.loadingAnimation
});
this._activeCLI = new TransferCli(cliOptions, this._options.cliLevel);

@@ -34,0 +37,0 @@ }

@@ -33,3 +33,3 @@ import UpdateManager from "stdout-update";

this._render();
await sleep(this.options.updateIntervalMs ?? DEFAULT_UPDATE_INTERVAL_MS);
await sleep(this.options.updateIntervalMs || DEFAULT_UPDATE_INTERVAL_MS);
}

@@ -36,0 +36,0 @@ }

@@ -23,10 +23,12 @@ import { DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";

const activeTasks = statuses.filter(status => status.downloadStatus === DownloadStatus.Active);
const remaining = statuses.filter(status => status.downloadStatus === DownloadStatus.Paused || status.downloadStatus === DownloadStatus.NotStarted);
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);
const showTotalTasks = activeTasks.concat(remaining)
.concat(loading);
const showTotalTasksWithFinished = showTotalTasks.concat(finishedTasks);
return {
notFinished: showTotalTasks.length > 0,
remaining: remaining.length,
remaining: remaining.length + loading.length,
allStatusesSorted: showTotalTasksWithFinished

@@ -33,0 +35,0 @@ };

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 & {

@@ -9,2 +10,3 @@ transferAction: string;

truncateName?: boolean | number;
loadingSpinner?: cliSpinners.SpinnerName;
};

@@ -20,2 +22,4 @@ export interface TransferCliProgressBar {

multiProgressBar: typeof BaseMultiProgressBar;
downloadLoadingSpinner: Spinner;
private _spinnerState;
protected status: CliFormattedStatus;

@@ -27,3 +31,4 @@ protected options: BaseCliOptions;

protected get showETA(): boolean;
protected get nameSize(): number;
protected getNameSize(fileName?: string): number;
protected getSpinnerText(): string;
protected getNameAndCommentDataParts(): DataPart[];

@@ -35,3 +40,4 @@ protected getETA(spacer?: string, formatter?: (text: string, size: number, type: "spacer" | "time") => string): DataLine;

protected renderPendingLine(): string;
protected renderLoadingLine(): string;
createStatusLine(status: CliFormattedStatus): string;
}

@@ -8,5 +8,7 @@ import chalk from "chalk";

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;
/**

@@ -17,2 +19,7 @@ * A class to display transfer progress in the terminal, with a progress bar and other information.

multiProgressBar = BaseMultiProgressBar;
downloadLoadingSpinner;
_spinnerState = {
step: 0,
lastChanged: 0
};
status = null;

@@ -23,2 +30,3 @@ options;

this.options = options;
this.downloadLoadingSpinner = cliSpinners[options.loadingSpinner ?? "dots"];
}

@@ -37,4 +45,3 @@ switchTransferToShortText() {

}
get nameSize() {
const { fileName } = this.status;
getNameSize(fileName = this.status.fileName) {
return this.options.truncateName === false

@@ -46,2 +53,13 @@ ? fileName.length

}
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() {

@@ -61,3 +79,3 @@ const { fileName, comment, downloadStatus } = this.status;

fullText: fileName,
size: this.nameSize,
size: this.getNameSize(),
flex: typeof this.options.truncateName === "number"

@@ -148,3 +166,3 @@ ? undefined

type: "progressBar",
size: this.nameSize,
size: this.getNameSize(),
fullText: "",

@@ -231,2 +249,30 @@ flex: 4,

}
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) {

@@ -240,2 +286,5 @@ this.status = status;

}
if (this.status.downloadStatus === DownloadStatus.Loading) {
return this.renderLoadingLine();
}
return this.renderProgressLine();

@@ -242,0 +291,0 @@ }

@@ -6,4 +6,5 @@ import { SummaryMultiProgressBar } from "../multiProgressBars/SummaryMultiProgressBar.js";

switchTransferToIcon(): string;
getSpinnerText(): string;
renderProgressLine(): string;
protected renderDownloadSequence(): string;
}

@@ -18,2 +18,5 @@ import chalk from "chalk";

}
getSpinnerText() {
return STATUS_ICONS.pending;
}
renderProgressLine() {

@@ -20,0 +23,0 @@ if (this.status.downloadFlags.includes(DownloadFlags.DownloadSequence)) {

@@ -1,5 +0,3 @@

import BaseTransferCliProgressBar from "./base-transfer-cli-progress-bar.js";
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: {
truncateName?: boolean | number;
}): BaseTransferCliProgressBar;
export default function switchCliProgressStyle(cliStyle: AvailableCLIProgressStyle, options: BaseCliOptions): BaseTransferCliProgressBar;

@@ -11,3 +11,3 @@ import UpdateManager from "stdout-update";

debounceWait: 20,
maxDebounceWait: 100,
maxDebounceWait: process.platform === "win32" ? 500 : 100,
createProgressBar: switchCliProgressStyle("auto", { truncateName: true }),

@@ -14,0 +14,0 @@ loadingAnimation: "dots",

@@ -19,3 +19,4 @@ import DownloadEngineNodejs from "./download/download-engine/engine/download-engine-nodejs.js";

import { DownloadFlags, DownloadStatus } from "./download/download-engine/download-file/progress-status-file.js";
export { DownloadFlags, DownloadStatus, downloadFile, downloadSequence, BaseMultiProgressBar, PathNotAFileError, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError };
import { NoDownloadEngineProvidedError } from "./download/download-engine/engine/error/no-download-engine-provided-error.js";
export { DownloadFlags, DownloadStatus, downloadFile, downloadSequence, BaseMultiProgressBar, PathNotAFileError, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError, NoDownloadEngineProvidedError };
export type { BaseDownloadEngine, DownloadFileOptions, DownloadSequenceOptions, DownloadEngineNodejs, DownloadEngineMultiDownload, SaveProgressInfo, FormattedStatus, MultiProgressBarOptions };

@@ -14,3 +14,4 @@ import { downloadFile, downloadSequence } from "./download/node-download.js";

import { DownloadFlags, DownloadStatus } from "./download/download-engine/download-file/progress-status-file.js";
export { DownloadFlags, DownloadStatus, downloadFile, downloadSequence, BaseMultiProgressBar, PathNotAFileError, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError };
import { NoDownloadEngineProvidedError } from "./download/download-engine/engine/error/no-download-engine-provided-error.js";
export { DownloadFlags, DownloadStatus, downloadFile, downloadSequence, BaseMultiProgressBar, PathNotAFileError, EmptyResponseError, HttpError, StatusCodeError, XhrError, InvalidContentLengthError, FetchStreamError, IpullError, EngineError, InvalidOptionError, NoDownloadEngineProvidedError };
//# sourceMappingURL=index.js.map
{
"name": "ipull",
"version": "3.8.1",
"version": "3.9.0",
"description": "The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc