filecoin-pin
Version:
Bridge IPFS content to Filecoin Onchain Cloud using familiar tools
89 lines • 3.02 kB
TypeScript
/**
* Multi-operation spinner flow manager
*
* Manages a spinner that can track multiple parallel operations, automatically
* updating the spinner message as operations are added, updated, or completed.
*
* Usage:
* const flow = createSpinnerFlow(spinner)
* flow.addOperation('upload', 'Uploading file...')
* flow.addOperation('validate', 'Validating...')
* flow.updateOperation('upload', 'Uploading file... 50%')
* flow.completeOperation('upload', 'Upload complete', { type: 'success', details: {...} })
* flow.completeOperation('validate', 'Validation complete', { type: 'success' })
*/
import type { Spinner } from './cli-helpers.js';
export type OperationStatus = 'success' | 'warning' | 'error' | 'info';
export interface OperationCompletionOptions {
/**
* Visual status of the completion
* @default 'success'
*/
type?: OperationStatus;
/**
* Optional details section to display after completion
* Format: { title: string, content: string[] }
*/
details?: {
title: string;
content: string[];
} | undefined;
}
/**
* Multi-operation spinner flow manager
*/
export declare class MultiOperationSpinner {
private operations;
private spinner;
private spinnerRunning;
constructor(spinner: Spinner | undefined);
/**
* Get the combined message for all active operations
*/
private getCombinedMessage;
/**
* Update the spinner message
* Handles starting the spinner if needed, or updating if already running
*/
private updateSpinner;
/**
* Add or update an operation
* @param id - Unique identifier for the operation
* @param message - Message to display for this operation
*/
addOperation(id: string, message: string): void;
/**
* Update an existing operation's message
* @param id - Operation identifier
* @param message - New message
*/
updateOperation(id: string, message: string): void;
/**
* Mark that the spinner was started externally
* Use this when you start the spinner outside of the flow manager
*/
markSpinnerStarted(): void;
/**
* Mark that the spinner was stopped externally
* Use this when you stop the spinner outside of the flow manager
*/
markSpinnerStopped(): void;
/**
* Complete an operation
* @param id - Operation identifier
* @param message - Completion message
* @param options - Completion options (status type and optional details)
*/
completeOperation(id: string, message: string, options?: OperationCompletionOptions): void;
/**
* Get the icon for a status type
*/
private getStatusIcon;
}
/**
* Create a new multi-operation spinner flow
* @param spinner - The spinner instance to manage
* @returns A MultiOperationSpinner instance
*/
export declare function createSpinnerFlow(spinner: Spinner | undefined): MultiOperationSpinner;
//# sourceMappingURL=multi-operation-spinner.d.ts.map