/** * Loaders 类型定义 */ /** * 任务状态枚举 */ export declare enum TaskStatus { WAITING = "waiting",// 等待开始 START = "start",// 开始处理 COMPUTING_HASH = "computing_hash",// 计算哈希中(上传专用) CREATED = "created",// 已创建任务(上传专用) PREPARING = "preparing",// 准备中(下载专用) RUNNING = "running",// 正在执行 PAUSED = "paused",// 已暂停 COMPLETE = "complete",// 完成,等待确认(上传专用) CONFIRMING = "confirming",// 确认中(上传专用) SUCCESS = "success",// 成功 RAPID_SUCCESS = "rapid_success",// 秒传成功(上传专用) ERROR = "error",// 失败 CANCELED = "canceled" } /** * 文件信息接口 */ export interface IFile { name: string; size: number; type?: string; } /** * 进度信息接口 */ export interface ProgressInfo { state: string; loaded: number; total: number; progress: number; speed: number; leftTime: number; } /** * 上传分片信息 */ export interface IUpPartInfo { part_number: number; chunk_size: number; etag?: string; crc64?: string; from: number; to: number; start_time?: number; end_time?: number; } /** * 上传断点信息 */ export interface UploadCheckpoint { id: string; file: IFile; state: TaskStatus; progress: number; loaded: number; upload_id?: string; confirm_key?: string; bucket?: string; region?: string; key?: string; chunk_size: number; part_info_list: IUpPartInfo[]; crc64?: string; start_time?: number; end_time?: number; used_avg_speed?: number; used_time_len?: number; rapid_upload?: boolean; expiration?: string; } /** * 上传选项接口 */ export interface UploadOptions { libraryId: string; spaceId: string; filePath: string; file: File; accessToken: string; userId?: string; chunkSize?: number; parallel?: number; partFileSize?: number; conflictResolutionStrategy?: 'ask' | 'rename' | 'overwrite'; enableInstantUpload?: boolean; trafficLimit?: number; internalDomain?: 0 | 1; protocol?: 'https:' | 'http:'; autoCreateDir?: boolean; labels?: string[]; category?: string; localCreationTime?: string; localModificationTime?: string; onStateChange?: (checkpoint: UploadCheckpoint, state: TaskStatus, error?: Error) => void; onProgress?: (progress: ProgressInfo) => void; onPartComplete?: (checkpoint: UploadCheckpoint, partInfo: IUpPartInfo) => void; checkpoint?: UploadCheckpoint; verbose?: boolean; } /** * 下载分片信息 */ export interface IDownPartInfo { part_number: number; start: number; end: number; size: number; done?: boolean; crc64?: string; blob?: Blob; } /** * 下载断点信息 */ export interface DownloadCheckpoint { id: string; file: IFile; state: TaskStatus; progress: number; loaded: number; download_url?: string; chunk_size: number; part_info_list: IDownPartInfo[]; remote_crc64?: string; is_multipart?: boolean; start_time?: number; end_time?: number; used_avg_speed?: number; used_time_len?: number; } /** * 下载选项接口 */ export interface DownloadOptions { libraryId: string; spaceId: string; filePath: string; accessToken: string; userId?: string; chunkSize?: number; parallel?: number; partFileSize?: number; trafficLimit?: number; historyId?: string; internalDomain?: 0 | 1; onStateChange?: (checkpoint: DownloadCheckpoint, state: TaskStatus, error?: Error) => void; onProgress?: (progress: ProgressInfo) => void; onPartComplete?: (checkpoint: DownloadCheckpoint, partInfo: IDownPartInfo) => void; checkpoint?: DownloadCheckpoint; verbose?: boolean; } /** * 浏览器 URL 下载选项 */ export interface UrlDownloadOptions { libraryId: string; spaceId: string; filePath: string; accessToken: string; userId?: string; trafficLimit?: number; historyId?: string; internalDomain?: 0 | 1; /** 下载保存的文件名,默认从 filePath 提取 */ fileName?: string; } /** * CommonLoader 构造选项 */ export interface CommonLoaderOptions { verbose?: boolean; id?: string; }