First upload version 0.0.1
This commit is contained in:
19
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.d.ts
generated
vendored
Normal file
19
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.d.ts
generated
vendored
Normal 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;
|
||||
}
|
||||
52
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.js
generated
vendored
Normal file
52
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.js
generated
vendored
Normal 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
|
||||
1
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.js.map
generated
vendored
Normal file
1
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/base-loading-animation.js.map
generated
vendored
Normal 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,YAA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AED,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"}
|
||||
8
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.d.ts
generated
vendored
Normal file
8
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.d.ts
generated
vendored
Normal 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;
|
||||
}
|
||||
20
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.js
generated
vendored
Normal file
20
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.js
generated
vendored
Normal 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
|
||||
1
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.js.map
generated
vendored
Normal file
1
node_modules/ipull/dist/download/transfer-visualize/transfer-cli/loading-animation/cli-spinners-loading-animation.js.map
generated
vendored
Normal 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"}
|
||||
Reference in New Issue
Block a user