@zjlab-fe/data-hub-ui 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/instructions/i.instructions.md +249 -0
- package/dist/types/components/feature-card/demo/moha.d.ts +1 -0
- package/dist/types/components/feature-card/index.d.ts +7 -1
- package/dist/types/components/file-uploader/components/circle-progress.d.ts +6 -0
- package/dist/types/components/file-uploader/components/hooks/use-drop-zone.d.ts +17 -0
- package/dist/types/components/file-uploader/components/hooks/use-file-validation.d.ts +12 -0
- package/dist/types/components/file-uploader/components/icons.d.ts +5 -0
- package/dist/types/components/file-uploader/components/uploader-drop-zone.d.ts +49 -0
- package/dist/types/components/file-uploader/components/uploader-file-item.d.ts +40 -0
- package/dist/types/components/file-uploader/components/uploader-file-list.d.ts +29 -0
- package/dist/types/components/file-uploader/components/uploader.d.ts +64 -0
- package/dist/types/components/file-uploader/components/utils/directory-reader.d.ts +4 -0
- package/dist/types/components/file-uploader/constants.d.ts +27 -0
- package/dist/types/components/file-uploader/context/file-state-store.d.ts +64 -0
- package/dist/types/components/file-uploader/context/handler-registry.d.ts +96 -0
- package/dist/types/components/file-uploader/context/upload-context.d.ts +14 -0
- package/dist/types/components/file-uploader/context/upload-provider.d.ts +47 -0
- package/dist/types/components/file-uploader/context/upload-reducer.d.ts +6 -0
- package/dist/types/components/file-uploader/context/use-upload-engine.d.ts +22 -0
- package/dist/types/components/file-uploader/demo/index.d.ts +2 -0
- package/dist/types/components/file-uploader/engine/queue-callbacks.d.ts +21 -0
- package/dist/types/components/file-uploader/engine/queue-manager.d.ts +63 -0
- package/dist/types/components/file-uploader/engine/queue-types.d.ts +37 -0
- package/dist/types/components/file-uploader/engine/queue-uploader.d.ts +8 -0
- package/dist/types/components/file-uploader/hooks/use-upload-batch.d.ts +36 -0
- package/dist/types/components/file-uploader/hooks/use-upload-control.d.ts +37 -0
- package/dist/types/components/file-uploader/hooks/use-upload-files.d.ts +40 -0
- package/dist/types/components/file-uploader/hooks/use-upload-operations.d.ts +43 -0
- package/dist/types/components/file-uploader/hooks/use-upload.d.ts +74 -0
- package/dist/types/components/file-uploader/index.d.ts +16 -0
- package/dist/types/components/file-uploader/persistence/file-blob-store.d.ts +71 -0
- package/dist/types/components/file-uploader/persistence/file-handle-store.d.ts +116 -0
- package/dist/types/components/file-uploader/persistence/index.d.ts +42 -0
- package/dist/types/components/file-uploader/persistence/metadata-store.d.ts +63 -0
- package/dist/types/components/file-uploader/persistence/persistence-context.d.ts +20 -0
- package/dist/types/components/file-uploader/persistence/persistence-manager.d.ts +103 -0
- package/dist/types/components/file-uploader/persistence/persistence-provider.d.ts +49 -0
- package/dist/types/components/file-uploader/persistence/types.d.ts +266 -0
- package/dist/types/components/file-uploader/persistence/use-persistence.d.ts +78 -0
- package/dist/types/components/file-uploader/types.d.ts +138 -0
- package/dist/types/components/file-uploader/utils/chunk-handlers.d.ts +40 -0
- package/dist/types/components/file-uploader/utils/ensure-handlers.d.ts +7 -0
- package/dist/types/components/file-uploader/utils/error-handler.d.ts +59 -0
- package/dist/types/components/file-uploader/utils/upload-controllers.d.ts +72 -0
- package/dist/types/components/file-uploader/utils/upload-handler.d.ts +17 -0
- package/dist/types/components/file-uploader/utils/validate-handlers.d.ts +6 -0
- package/dist/types/components/section-heading/index.d.ts +1 -1
- package/dist/types/components/tip-tap/extensions/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/tailwind.config.js +4 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence Hooks - React integration for file persistence
|
|
3
|
+
*
|
|
4
|
+
* Provides hooks for:
|
|
5
|
+
* - Auto-saving file state changes
|
|
6
|
+
* - Restoring files on mount
|
|
7
|
+
* - Converting between UploadFile and StoredFileMeta
|
|
8
|
+
*/
|
|
9
|
+
import type { UploadFile, UploadState } from '../types';
|
|
10
|
+
import type { StoredFileMeta, PersistenceConfig, FileRecoveryResult } from './types';
|
|
11
|
+
import { PersistenceManager } from './persistence-manager';
|
|
12
|
+
/**
|
|
13
|
+
* Convert UploadFile to StoredFileMeta (for saving)
|
|
14
|
+
*/
|
|
15
|
+
export declare function uploadFileToStoredMeta(file: UploadFile): StoredFileMeta;
|
|
16
|
+
/**
|
|
17
|
+
* Convert StoredFileMeta back to partial UploadFile (file prop will be added by recovery)
|
|
18
|
+
*/
|
|
19
|
+
export declare function storedMetaToUploadFile(meta: StoredFileMeta, file: File | null): UploadFile | null;
|
|
20
|
+
/**
|
|
21
|
+
* Result of restore operation
|
|
22
|
+
*/
|
|
23
|
+
export interface RestoreResult {
|
|
24
|
+
/** Successfully restored files */
|
|
25
|
+
restored: UploadFile[];
|
|
26
|
+
/** Files that need user action (repick/permission) */
|
|
27
|
+
needsAction: Array<{
|
|
28
|
+
meta: StoredFileMeta;
|
|
29
|
+
reason: FileRecoveryResult['userActionReason'];
|
|
30
|
+
handle?: FileSystemFileHandle;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hook options
|
|
35
|
+
*/
|
|
36
|
+
export interface UsePersistenceOptions {
|
|
37
|
+
/** Persistence configuration */
|
|
38
|
+
config?: Partial<PersistenceConfig>;
|
|
39
|
+
/** Called when files are restored */
|
|
40
|
+
onRestore?: (result: RestoreResult) => void;
|
|
41
|
+
/** Called when a file needs user action */
|
|
42
|
+
onNeedsAction?: (fileId: string, reason: FileRecoveryResult['userActionReason']) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hook return type
|
|
46
|
+
*/
|
|
47
|
+
export interface UsePersistenceReturn {
|
|
48
|
+
/** Persistence manager instance */
|
|
49
|
+
manager: PersistenceManager | null;
|
|
50
|
+
/** Whether persistence is initialized */
|
|
51
|
+
isInitialized: boolean;
|
|
52
|
+
/** Current persistence mode */
|
|
53
|
+
mode: PersistenceManager['mode'] | null;
|
|
54
|
+
/** Save current files state */
|
|
55
|
+
saveFiles: (files: UploadFile[]) => Promise<void>;
|
|
56
|
+
/** Restore files from storage */
|
|
57
|
+
restoreFiles: () => Promise<RestoreResult>;
|
|
58
|
+
/** Request permission for a file (file-system-access mode) */
|
|
59
|
+
requestPermission: (fileId: string) => Promise<File | null>;
|
|
60
|
+
/** Remove a file from storage */
|
|
61
|
+
removeFile: (fileId: string) => Promise<void>;
|
|
62
|
+
/** Clear all storage */
|
|
63
|
+
clearAll: () => Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create persistence manager hook
|
|
67
|
+
* This is a factory that creates the manager - should be called once at provider level
|
|
68
|
+
*/
|
|
69
|
+
export declare function usePersistenceManager(config?: Partial<PersistenceConfig>): UsePersistenceReturn;
|
|
70
|
+
/**
|
|
71
|
+
* Hook to auto-save file state changes
|
|
72
|
+
* Should be used within UploadProvider
|
|
73
|
+
*/
|
|
74
|
+
export declare function useAutoSave(manager: PersistenceManager | null, state: UploadState, enabled?: boolean): void;
|
|
75
|
+
/**
|
|
76
|
+
* Hook to cleanup completed uploads from storage
|
|
77
|
+
*/
|
|
78
|
+
export declare function useCleanupCompleted(manager: PersistenceManager | null, state: UploadState, enabled?: boolean): void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { UploadStatusType, ChunkStatusType } from './constants';
|
|
2
|
+
import type { QueueManager } from './engine/queue-manager';
|
|
3
|
+
export interface UploadUrl {
|
|
4
|
+
uploadUrl: string;
|
|
5
|
+
partNum: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ChunkState {
|
|
8
|
+
partNum: number;
|
|
9
|
+
status: ChunkStatusType;
|
|
10
|
+
progress: number;
|
|
11
|
+
uploadUrl?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface UploadFile {
|
|
15
|
+
id: string;
|
|
16
|
+
file: File;
|
|
17
|
+
fileName: string;
|
|
18
|
+
fileSize: number;
|
|
19
|
+
lastModified: number;
|
|
20
|
+
status: UploadStatusType;
|
|
21
|
+
progress: number;
|
|
22
|
+
uploadId: string;
|
|
23
|
+
chunks: ChunkState[];
|
|
24
|
+
chunkSize: number;
|
|
25
|
+
runtime?: unknown;
|
|
26
|
+
error?: string;
|
|
27
|
+
errorCode?: string;
|
|
28
|
+
retryCount?: number;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
}
|
|
31
|
+
export type GetUploadUrlsResult = {
|
|
32
|
+
success: false;
|
|
33
|
+
reason?: string;
|
|
34
|
+
} | {
|
|
35
|
+
success: true;
|
|
36
|
+
uploadInfo: {
|
|
37
|
+
uploadUrls: UploadUrl[];
|
|
38
|
+
uploadId: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type CallbackResult = {
|
|
42
|
+
success: true;
|
|
43
|
+
} | {
|
|
44
|
+
success: false;
|
|
45
|
+
reason?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Upload lifecycle handler callbacks
|
|
49
|
+
* These hooks allow consumers to integrate with the upload process at various stages
|
|
50
|
+
*/
|
|
51
|
+
export interface UploadHandlers {
|
|
52
|
+
/** Called before requesting upload URLs. Return { status: false } to cancel upload */
|
|
53
|
+
onBeforeUpload?: (file: UploadFile) => Promise<CallbackResult>;
|
|
54
|
+
/** Request upload URLs from server (required) */
|
|
55
|
+
onGetUploadUrls: (fileName: string, partCount: number) => Promise<GetUploadUrlsResult>;
|
|
56
|
+
/** Called after URLs received, before chunk uploads begin */
|
|
57
|
+
onUploadStart?: (file: UploadFile) => void;
|
|
58
|
+
/** Called when file progress updates (0-100) */
|
|
59
|
+
onProgress?: (file: UploadFile, progress: number) => void;
|
|
60
|
+
/** Called when a chunk upload completes (required) */
|
|
61
|
+
onPartComplete: (fileName: string, uploadId: string, partNum: number) => Promise<CallbackResult>;
|
|
62
|
+
/** Called when upload is paused */
|
|
63
|
+
onPause?: (file: UploadFile) => void;
|
|
64
|
+
/** Called when upload is resumed */
|
|
65
|
+
onResume?: (file: UploadFile) => void;
|
|
66
|
+
/** Called when entire file upload completes (required) */
|
|
67
|
+
onFileComplete: (fileName: string, uploadId: string) => Promise<CallbackResult>;
|
|
68
|
+
/** Called when upload is successful */
|
|
69
|
+
onUploadSuccess?: (file: UploadFile) => void;
|
|
70
|
+
/** Called when upload is cancelled */
|
|
71
|
+
onUploadCancel?: (fileName: string, uploadId: string) => Promise<CallbackResult>;
|
|
72
|
+
/** Called when file is deleted */
|
|
73
|
+
onDeleteFile?: (file: UploadFile) => Promise<CallbackResult>;
|
|
74
|
+
/** Called when upload is retried (smart or full retry) */
|
|
75
|
+
onRetry?: (file: UploadFile, retryType: 'smart' | 'full') => void;
|
|
76
|
+
/** Called when an error occurs during upload */
|
|
77
|
+
onError?: (file: UploadFile, error: Error) => void;
|
|
78
|
+
}
|
|
79
|
+
export interface UploadConfig {
|
|
80
|
+
/** Maximum chunk size in bytes */
|
|
81
|
+
maxChunkSize?: number;
|
|
82
|
+
/** Minimum chunk size in bytes */
|
|
83
|
+
minChunkSize?: number;
|
|
84
|
+
/** Number of concurrent chunk uploads per file */
|
|
85
|
+
concurrentChunks?: number;
|
|
86
|
+
/** Number of concurrent file uploads */
|
|
87
|
+
concurrentFiles?: number;
|
|
88
|
+
}
|
|
89
|
+
type AddFilesHandlerOption = {
|
|
90
|
+
/**
|
|
91
|
+
* Static handlers applied to all files in a single addFiles call
|
|
92
|
+
*/
|
|
93
|
+
handlers: UploadHandlers;
|
|
94
|
+
getHandlers?: never;
|
|
95
|
+
} | {
|
|
96
|
+
/**
|
|
97
|
+
* Factory to derive handlers per file (runtime context like folder selection)
|
|
98
|
+
*/
|
|
99
|
+
handlers?: never;
|
|
100
|
+
getHandlers: (file: File) => UploadHandlers;
|
|
101
|
+
};
|
|
102
|
+
export type AddFilesOptions = AddFilesHandlerOption;
|
|
103
|
+
export interface UploadState {
|
|
104
|
+
files: UploadFile[];
|
|
105
|
+
}
|
|
106
|
+
export type UploadAction = {
|
|
107
|
+
type: 'ADD_FILES';
|
|
108
|
+
files: UploadFile[];
|
|
109
|
+
} | {
|
|
110
|
+
type: 'UPDATE_FILE';
|
|
111
|
+
id: string;
|
|
112
|
+
updates: Partial<UploadFile>;
|
|
113
|
+
} | {
|
|
114
|
+
type: 'UPDATE_CHUNK';
|
|
115
|
+
fileId: string;
|
|
116
|
+
partNum: number;
|
|
117
|
+
updates: Partial<ChunkState>;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'REMOVE_FILE';
|
|
120
|
+
id: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: 'CLEAR_COMPLETED';
|
|
123
|
+
} | {
|
|
124
|
+
type: 'CLEAR_ALL';
|
|
125
|
+
};
|
|
126
|
+
export interface UploadContextValue {
|
|
127
|
+
/** Upload state (files list, processing status) */
|
|
128
|
+
state: UploadState;
|
|
129
|
+
/** Dispatch function for state updates */
|
|
130
|
+
dispatch: React.Dispatch<UploadAction>;
|
|
131
|
+
/** Global upload configuration (chunk sizes, concurrency) */
|
|
132
|
+
config: Required<UploadConfig>;
|
|
133
|
+
/** Shared QueueManager ref - singleton across all useUploadEngine consumers */
|
|
134
|
+
queueManagerRef: React.MutableRefObject<QueueManager | null>;
|
|
135
|
+
/** Get or create the QueueManager singleton instance */
|
|
136
|
+
getQueueManager: () => QueueManager;
|
|
137
|
+
}
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ChunkState, UploadConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Calculate optimal chunk size based on file size and config constraints
|
|
4
|
+
*/
|
|
5
|
+
export declare function calculateChunkSize(fileSize: number, config: Required<UploadConfig>): number;
|
|
6
|
+
/**
|
|
7
|
+
* Calculate total number of chunks for a file
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateTotalChunks(fileSize: number, chunkSize: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Create initial chunk states for a file
|
|
12
|
+
* @param fileSize - Total file size in bytes
|
|
13
|
+
* @param chunkSize - Size of each chunk in bytes
|
|
14
|
+
* @returns Array of ChunkState objects
|
|
15
|
+
*/
|
|
16
|
+
export declare function createChunks(fileSize: number, chunkSize: number): ChunkState[];
|
|
17
|
+
/**
|
|
18
|
+
* Extract a specific chunk blob from file
|
|
19
|
+
* @param file - The File object
|
|
20
|
+
* @param partNum - 0-indexed part number
|
|
21
|
+
* @param chunkSize - Size of each chunk in bytes
|
|
22
|
+
* @returns Blob containing the chunk data
|
|
23
|
+
*/
|
|
24
|
+
export declare function getChunkBlob(file: File, partNum: number, chunkSize: number): Blob;
|
|
25
|
+
/**
|
|
26
|
+
* Get chunk byte range info
|
|
27
|
+
* @param fileSize - Total file size
|
|
28
|
+
* @param partNum - 0-indexed part number
|
|
29
|
+
* @param chunkSize - Size of each chunk
|
|
30
|
+
* @returns Object with start, end, and size
|
|
31
|
+
*/
|
|
32
|
+
export declare function getChunkRange(fileSize: number, partNum: number, chunkSize: number): {
|
|
33
|
+
start: number;
|
|
34
|
+
end: number;
|
|
35
|
+
size: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Generate unique upload file ID
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateUploadId(): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Dispatch } from 'react';
|
|
2
|
+
import type { UploadHandlers, UploadFile, UploadAction } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Pure helper to fetch and validate handlers for a file.
|
|
5
|
+
* Returns null and dispatches failure if required handlers are missing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensureHandlers(uploadFile: UploadFile, dispatch: Dispatch<UploadAction>): UploadHandlers | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard error codes for upload operations.
|
|
3
|
+
* Allows consumers to handle specific error scenarios.
|
|
4
|
+
*
|
|
5
|
+
* Using const object instead of enum for compatibility with --erasableSyntaxOnly
|
|
6
|
+
* (TypeScript 5.8+) and better tree-shaking.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UPLOAD_ERROR_CODE: {
|
|
9
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
10
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
11
|
+
readonly ABORT: "ABORT";
|
|
12
|
+
readonly URL_REQUEST_FAILED: "URL_REQUEST_FAILED";
|
|
13
|
+
readonly CHUNK_UPLOAD_FAILED: "CHUNK_UPLOAD_FAILED";
|
|
14
|
+
readonly MERGE_FAILED: "MERGE_FAILED";
|
|
15
|
+
readonly SERVER_ERROR: "SERVER_ERROR";
|
|
16
|
+
readonly FILE_TOO_LARGE: "FILE_TOO_LARGE";
|
|
17
|
+
readonly INVALID_FILE_TYPE: "INVALID_FILE_TYPE";
|
|
18
|
+
readonly FILE_VALIDATION_FAILED: "FILE_VALIDATION_FAILED";
|
|
19
|
+
readonly MISSING_FILE: "MISSING_FILE";
|
|
20
|
+
readonly MISSING_HANDLER: "MISSING_HANDLER";
|
|
21
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
22
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
23
|
+
};
|
|
24
|
+
export type UPLOAD_ERROR_CODE_TYPE = (typeof UPLOAD_ERROR_CODE)[keyof typeof UPLOAD_ERROR_CODE];
|
|
25
|
+
/**
|
|
26
|
+
* Structured error object with code, message, and context.
|
|
27
|
+
*/
|
|
28
|
+
export interface UploadError {
|
|
29
|
+
code: UPLOAD_ERROR_CODE_TYPE;
|
|
30
|
+
message: string;
|
|
31
|
+
originalError?: Error;
|
|
32
|
+
context?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a structured upload error.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createUploadError(code: UPLOAD_ERROR_CODE_TYPE, message: string, originalError?: Error, context?: Record<string, unknown>): UploadError;
|
|
38
|
+
/**
|
|
39
|
+
* Parse an unknown error into a structured UploadError.
|
|
40
|
+
* Attempts to extract meaningful information from various error types.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseError(error: unknown, defaultMessage?: string): UploadError;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if an error is an UploadError.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isUploadError(error: unknown): error is UploadError;
|
|
47
|
+
/**
|
|
48
|
+
* Get a user-friendly error message for display.
|
|
49
|
+
* Provides actionable guidance when possible.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getUserFriendlyMessage(error: UploadError): string;
|
|
52
|
+
/**
|
|
53
|
+
* Determine if an error is recoverable (retry might work).
|
|
54
|
+
*/
|
|
55
|
+
export declare function isRecoverableError(error: UploadError): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Determine if an error should trigger automatic retry.
|
|
58
|
+
*/
|
|
59
|
+
export declare function shouldAutoRetry(error: UploadError, attemptCount: number, maxAttempts?: number): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { UploadFile, ChunkState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Result of preparing chunks for resume
|
|
4
|
+
*/
|
|
5
|
+
export interface ResumeChunksResult {
|
|
6
|
+
/** Chunk part numbers that need to be uploaded */
|
|
7
|
+
pendingPartNums: number[];
|
|
8
|
+
/** Total chunks to upload */
|
|
9
|
+
pendingCount: number;
|
|
10
|
+
/** Already completed chunks */
|
|
11
|
+
completedCount: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get chunks that need to be uploaded after a resume.
|
|
15
|
+
* Returns pending and failed chunks (excludes completed).
|
|
16
|
+
*/
|
|
17
|
+
export declare function getChunksForResume(file: UploadFile): ResumeChunksResult;
|
|
18
|
+
/**
|
|
19
|
+
* Reset interrupted chunks to pending state.
|
|
20
|
+
* Called when pausing - any uploading chunks should be marked pending.
|
|
21
|
+
* Returns updated chunks array.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resetInterruptedChunks(chunks: ChunkState[]): ChunkState[];
|
|
24
|
+
/**
|
|
25
|
+
* Check if a file has any chunks that can be resumed.
|
|
26
|
+
* Returns true if there are pending or failed chunks.
|
|
27
|
+
*/
|
|
28
|
+
export declare function canResumeFile(file: UploadFile): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate progress from completed chunks.
|
|
31
|
+
*/
|
|
32
|
+
export declare function calculateProgressFromChunks(chunks: ChunkState[]): number;
|
|
33
|
+
/**
|
|
34
|
+
* Filter upload URLs to only include pending chunks.
|
|
35
|
+
* Used when resuming to avoid re-uploading completed chunks.
|
|
36
|
+
*/
|
|
37
|
+
export declare function filterUrlsForPendingChunks(uploadUrls: {
|
|
38
|
+
partNum: number;
|
|
39
|
+
uploadUrl: string;
|
|
40
|
+
}[], pendingPartNums: number[]): {
|
|
41
|
+
partNum: number;
|
|
42
|
+
uploadUrl: string;
|
|
43
|
+
}[];
|
|
44
|
+
/**
|
|
45
|
+
* Result of preparing chunks for retry
|
|
46
|
+
*/
|
|
47
|
+
export interface RetryChunksResult {
|
|
48
|
+
/** Chunk part numbers that failed */
|
|
49
|
+
failedPartNums: number[];
|
|
50
|
+
/** Total failed chunks */
|
|
51
|
+
failedCount: number;
|
|
52
|
+
/** Already completed chunks */
|
|
53
|
+
completedCount: number;
|
|
54
|
+
/** Has any failed chunks */
|
|
55
|
+
hasFailed: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get chunks that failed and need to be retried.
|
|
59
|
+
* Returns only FAILED chunks, preserves COMPLETED chunks.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getFailedChunks(file: UploadFile): RetryChunksResult;
|
|
62
|
+
/**
|
|
63
|
+
* Reset only failed chunks to pending state.
|
|
64
|
+
* Preserves completed chunks for efficient retry.
|
|
65
|
+
* Returns updated chunks array.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resetFailedChunks(chunks: ChunkState[]): ChunkState[];
|
|
68
|
+
/**
|
|
69
|
+
* Reset all chunks to pending state (for full retry).
|
|
70
|
+
* Used when smart retry fails or server state is lost.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resetAllChunks(chunks: ChunkState[]): ChunkState[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface UploadChunkResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
partNum: number;
|
|
4
|
+
error?: Error;
|
|
5
|
+
}
|
|
6
|
+
export type ChunkProgressCallback = (partNum: number, progress: number) => void;
|
|
7
|
+
export interface UploadRequestConfig {
|
|
8
|
+
timeout?: number;
|
|
9
|
+
withCredentials?: boolean;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
/** Upload a chunk with automatic retry and exponential backoff */
|
|
13
|
+
export declare function uploadChunkWithRetry(chunk: Blob, uploadUrl: string, partNum: number, options?: {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
requestConfig?: UploadRequestConfig;
|
|
16
|
+
maxRetries?: number;
|
|
17
|
+
}): Promise<UploadChunkResult>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const editorExtensions: (placeholder?: string) => (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-code-block-lowlight").CodeBlockLowlightOptions, any> | import("@tiptap/core").Extension<
|
|
1
|
+
export declare const editorExtensions: (placeholder?: string) => (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-code-block-lowlight").CodeBlockLowlightOptions, any> | import("@tiptap/core").Extension<import("@tiptap/markdown").MarkdownExtensionOptions, import("@tiptap/markdown").MarkdownExtensionStorage> | import("@tiptap/core").Extension<any, any>)[];
|
|
2
2
|
export declare const readerExtensions: () => (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-code-block-lowlight").CodeBlockLowlightOptions, any>)[];
|