breakpoint-transfer-plugin 0.0.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/README.md +257 -0
- package/README.zh-CN.md +257 -0
- package/dist/index.cjs.js +6761 -0
- package/dist/index.es.js +6724 -0
- package/package.json +51 -0
- package/typings/index.d.ts +217 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "breakpoint-transfer-plugin",
|
|
3
|
+
"version": "v0.0.1",
|
|
4
|
+
"description": "JavaScript JDK plugin for implementing breakpoint continuation",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"typings": "typings/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"typings"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"lint": "eslint --fix --ext .ts src --quiet",
|
|
14
|
+
"prepare": "husky install",
|
|
15
|
+
"build": "rollup --config rollup.config.ts --configPlugin typescript"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"upload",
|
|
19
|
+
"big-file",
|
|
20
|
+
"breakpoint continuation"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://lvdaxianer.github.io/breakpoint-transfer-plugin",
|
|
23
|
+
"author": "lihh",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@commitlint/cli": "^17.4.2",
|
|
27
|
+
"@commitlint/config-conventional": "^17.4.2",
|
|
28
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
29
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
31
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
33
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
34
|
+
"eslint": "^8.40.0",
|
|
35
|
+
"eslint-config-prettier": "^8.8.0",
|
|
36
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
37
|
+
"husky": "^8.0.3",
|
|
38
|
+
"prettier": "^3.3.2",
|
|
39
|
+
"rollup": "^4.18.0",
|
|
40
|
+
"rollup-plugin-del": "^1.0.1",
|
|
41
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
42
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
43
|
+
"typescript": "^5.5.3",
|
|
44
|
+
"vue": "^3.4.21"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"i18next": "^23.11.5",
|
|
48
|
+
"jsmethod-extra": "^2.0.7",
|
|
49
|
+
"localforage": "^1.10.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export { SubscriberSort, emitterAndTaker, equals, isHas, isNotEmpty, strFormat } from 'jsmethod-extra';
|
|
2
|
+
|
|
3
|
+
declare enum UploadProgressState {
|
|
4
|
+
Prepare = "Prepare",
|
|
5
|
+
HashCalculationWaiting = "HashCalculationWaiting",
|
|
6
|
+
Waiting = "Waiting",
|
|
7
|
+
WaitAddQueue = "WaitAddQueue",
|
|
8
|
+
Uploading = "Uploading",
|
|
9
|
+
Merge = "Merge",
|
|
10
|
+
Done = "Done",
|
|
11
|
+
QuickUpload = "QuickUpload",
|
|
12
|
+
BreakPointUpload = "BreakPointUpload",
|
|
13
|
+
OtherUploading = "OtherUploading",
|
|
14
|
+
Pause = "Pause",
|
|
15
|
+
PauseRetry = "PauseRetry",
|
|
16
|
+
Canceled = "Canceled",
|
|
17
|
+
RequestError = "RequestError",
|
|
18
|
+
Retry = "Retry",
|
|
19
|
+
NetworkDisconnected = "NetworkDisconnected",
|
|
20
|
+
RetryFailed = "RetryFailed",
|
|
21
|
+
RefreshRetry = "RefreshRetry"
|
|
22
|
+
}
|
|
23
|
+
type QueueElementBase = Partial<{
|
|
24
|
+
type: UploadProgressState;
|
|
25
|
+
uniqueCode: string;
|
|
26
|
+
fileSize: number;
|
|
27
|
+
progress: number;
|
|
28
|
+
networkSpeed: number;
|
|
29
|
+
fileName: string;
|
|
30
|
+
uploadFile: File;
|
|
31
|
+
retryTimes: number;
|
|
32
|
+
requestErrorMsg: string;
|
|
33
|
+
}>;
|
|
34
|
+
type UploadConfigType = Partial<{
|
|
35
|
+
maxRetryTimes: number;
|
|
36
|
+
baseNetworkSpeed: number;
|
|
37
|
+
concurrentLimit: number;
|
|
38
|
+
persist: boolean;
|
|
39
|
+
language: LanguageEnumType;
|
|
40
|
+
maxHashNameCount: number;
|
|
41
|
+
}> & {
|
|
42
|
+
req: {
|
|
43
|
+
listFilesReq: IListFilesReq | null;
|
|
44
|
+
sectionUploadReq: ISectionUploadReq | null;
|
|
45
|
+
mergeUploadReq: IMergeUploadReq | null;
|
|
46
|
+
verifyFileExistReq: IVerifyFileExistReq | null;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
interface CurrentType<T = null> {
|
|
50
|
+
current: T;
|
|
51
|
+
}
|
|
52
|
+
type ProgressReturnType = [baseDir: string, fileName: string];
|
|
53
|
+
declare enum LocalforageTypeEnum {
|
|
54
|
+
p1 = "p1",
|
|
55
|
+
p2 = "p2"
|
|
56
|
+
}
|
|
57
|
+
type ICommonResponse<T = unknown> = {
|
|
58
|
+
data: T;
|
|
59
|
+
message?: string;
|
|
60
|
+
msg?: string;
|
|
61
|
+
success?: boolean;
|
|
62
|
+
code: number;
|
|
63
|
+
};
|
|
64
|
+
declare enum HTTPEnumState {
|
|
65
|
+
OK = "200"
|
|
66
|
+
}
|
|
67
|
+
declare enum LanguageEnumType {
|
|
68
|
+
EN = "en",
|
|
69
|
+
ZH = "zh",
|
|
70
|
+
JA_JP = "ja_JP"
|
|
71
|
+
}
|
|
72
|
+
type IListFilesReq = (calculationHashCode: string) => Promise<ICommonResponse<[number, number]>>;
|
|
73
|
+
type ISectionUploadReq = (calculationHashCode: string, chunkFileName: string, formData: FormData) => Promise<ICommonResponse<boolean>>;
|
|
74
|
+
type IMergeUploadReq = (calculationHashCode: string, fileName: string) => Promise<ICommonResponse>;
|
|
75
|
+
type IVerifyFileExistReq = (calculationHashName: string) => Promise<ICommonResponse<boolean>>;
|
|
76
|
+
|
|
77
|
+
declare const UploadProgressStateText: Record<Required<UploadProgressState>, Record<LanguageEnumType, string>>;
|
|
78
|
+
declare const COMPUTE_NETWORK_BYTE_SIZE: number;
|
|
79
|
+
declare const UPLOADING_FILE_SUBSCRIBE_DEFINE = "UPLOADING_FILE_SUBSCRIBE_DEFINE";
|
|
80
|
+
declare const REVERSE_CONTAINER_ACTION = "REVERSE_CONTAINER_ACTION";
|
|
81
|
+
declare const SERVER_REQUEST_FAIL_MSG = "fetch fail, \u8BF7\u68C0\u67E5\u670D\u52A1";
|
|
82
|
+
declare const NO_MESSAGE_DEFAULT_VALUE = "\u672A\u63D0\u4F9B\u9519\u8BEF\u6D88\u606F";
|
|
83
|
+
declare const INNER_PROGRESS_CONST = "innerProgress";
|
|
84
|
+
declare const CURRENT_CONSUME_BYTES = "currentConsumeBytes";
|
|
85
|
+
declare const FILE_SIZE_CONST = "fileSize";
|
|
86
|
+
declare const UPLOAD_FILE_CONST = "uploadFile";
|
|
87
|
+
declare const EXT_NAME_CONST = "extName";
|
|
88
|
+
declare const NETWORK_SPEED_CONST = "networkSpeed";
|
|
89
|
+
declare const UPLOAD_CONFIG_KEYS: {
|
|
90
|
+
FILE_NAME: "fileName";
|
|
91
|
+
UNIQUE_CODE: "uniqueCode";
|
|
92
|
+
FILE_SIZE: string;
|
|
93
|
+
EXT_NAME: string;
|
|
94
|
+
UPLOAD_FILE: string;
|
|
95
|
+
INNER_PROGRESS: string;
|
|
96
|
+
CURRENT_CONSUME_BYTES_KEY: string;
|
|
97
|
+
NETWORK_SPEED: string;
|
|
98
|
+
CALCULATION_HASH_NAME: "calculationHashName";
|
|
99
|
+
};
|
|
100
|
+
declare const SPEED_TEST_PREFIX = "__speed_test__";
|
|
101
|
+
declare const SYNC_NUMERIC_VALUE_KEYS: ReadonlySet<string>;
|
|
102
|
+
declare const SOME_CONSTANT_VALUES: {
|
|
103
|
+
KEY1: string;
|
|
104
|
+
KEY2: string;
|
|
105
|
+
KEY3: string;
|
|
106
|
+
KEY4: string;
|
|
107
|
+
KEY5: string;
|
|
108
|
+
KEY6: string;
|
|
109
|
+
KEY7: string;
|
|
110
|
+
KEY8: string;
|
|
111
|
+
KEY9: string;
|
|
112
|
+
KEY10: string;
|
|
113
|
+
};
|
|
114
|
+
declare const zhLanguage: Record<string, string>;
|
|
115
|
+
declare const jpLanguage: Record<string, string>;
|
|
116
|
+
declare const enLanguage: Record<string, string>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 固定小数点的方法
|
|
120
|
+
*
|
|
121
|
+
* @author lihh
|
|
122
|
+
* @param size 大小
|
|
123
|
+
* @param count 个数
|
|
124
|
+
*/
|
|
125
|
+
declare function toFixedHandler(size: number, count: number): number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 选择的多语言
|
|
129
|
+
*
|
|
130
|
+
* @author lihh
|
|
131
|
+
* @param key 设置类型
|
|
132
|
+
*/
|
|
133
|
+
declare function getLng(key: UploadProgressState): string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 重新 上传文件
|
|
137
|
+
*
|
|
138
|
+
* @author lihh
|
|
139
|
+
* @param uniqueCode 文件 唯一的code
|
|
140
|
+
* @param newType 要修改的状态
|
|
141
|
+
*/
|
|
142
|
+
declare function restartUploadFileHandler(uniqueCode: string, newType: UploadProgressState): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* 相同文件 是否继续下载
|
|
145
|
+
*
|
|
146
|
+
* @author lihh
|
|
147
|
+
* @param uniqueCode 文件 唯一的code
|
|
148
|
+
*/
|
|
149
|
+
declare function sameFileNeedProceedHandler(uniqueCode: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* 正常 异常结束的事件
|
|
152
|
+
*
|
|
153
|
+
* @author lihh
|
|
154
|
+
* @param el queue 消息
|
|
155
|
+
*/
|
|
156
|
+
declare function progressNormalOrErrorCompletionHandler(el: QueueElementBase): void;
|
|
157
|
+
/**
|
|
158
|
+
* 清除 缓存状态
|
|
159
|
+
*
|
|
160
|
+
* @author lihh
|
|
161
|
+
*/
|
|
162
|
+
declare function clearCacheStateHandler(uniqueCode: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* 计算断点续传的索引
|
|
165
|
+
*
|
|
166
|
+
* @author lihh
|
|
167
|
+
* @param calculationHashCode web worker 计算的code
|
|
168
|
+
* @param uniqueCode 表示唯一的code
|
|
169
|
+
*/
|
|
170
|
+
declare function computedBreakPointProgressHandler(calculationHashCode: string, uniqueCode: string): Promise<number>;
|
|
171
|
+
/**
|
|
172
|
+
* 分割文件 上传事件
|
|
173
|
+
*
|
|
174
|
+
* @author lihh
|
|
175
|
+
* @param uniqueCode 唯一的code
|
|
176
|
+
* @param calculationHashCode web worker 计算的hashCode
|
|
177
|
+
* @param idx 索引的值
|
|
178
|
+
* @param retryTimes 重试次数
|
|
179
|
+
*/
|
|
180
|
+
declare function splitFileUploadingHandler(uniqueCode: string, calculationHashCode: string, idx: number, retryTimes?: number): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* 开始执行任务
|
|
183
|
+
*
|
|
184
|
+
* @author lihh
|
|
185
|
+
* @param calculationHashCode 通过 webWorker 计算的hash值
|
|
186
|
+
* @param uniqueCode 唯一的值
|
|
187
|
+
*/
|
|
188
|
+
declare function startUploadFileNextHandler(calculationHashCode: string, uniqueCode: string): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* 开始上传文件
|
|
191
|
+
*
|
|
192
|
+
* @author lihh
|
|
193
|
+
* @param calculationHashName 通过web worker 计算的hash名称
|
|
194
|
+
* @param uniqueCode 生成的唯一 code
|
|
195
|
+
*/
|
|
196
|
+
declare function startUploadFileHandler(calculationHashName: string, uniqueCode: string): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* 这里生成任务 能让任务处理等待状态
|
|
199
|
+
*
|
|
200
|
+
* @author lihh
|
|
201
|
+
* @param uniqueCode 每个文件对应 唯一的值
|
|
202
|
+
*/
|
|
203
|
+
declare function generatorTask(uniqueCode: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* 表示上传的事件
|
|
206
|
+
*
|
|
207
|
+
* @author lihh
|
|
208
|
+
* @param uploadFile 要上传的文件
|
|
209
|
+
* @param callback 默认的回调方法
|
|
210
|
+
*/
|
|
211
|
+
declare function uploadHandler(uploadFile: File, callback?: (arr: ProgressReturnType) => void): Promise<ProgressReturnType>;
|
|
212
|
+
declare namespace uploadHandler {
|
|
213
|
+
var config: (config: UploadConfigType) => void;
|
|
214
|
+
var lng: (language?: LanguageEnumType) => Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { COMPUTE_NETWORK_BYTE_SIZE, CURRENT_CONSUME_BYTES, type CurrentType, EXT_NAME_CONST, FILE_SIZE_CONST, HTTPEnumState, type ICommonResponse, type IListFilesReq, type IMergeUploadReq, INNER_PROGRESS_CONST, type ISectionUploadReq, type IVerifyFileExistReq, LanguageEnumType, LocalforageTypeEnum, NETWORK_SPEED_CONST, NO_MESSAGE_DEFAULT_VALUE, type ProgressReturnType, type QueueElementBase, REVERSE_CONTAINER_ACTION, SERVER_REQUEST_FAIL_MSG, SOME_CONSTANT_VALUES, SPEED_TEST_PREFIX, SYNC_NUMERIC_VALUE_KEYS, UPLOADING_FILE_SUBSCRIBE_DEFINE, UPLOAD_CONFIG_KEYS, UPLOAD_FILE_CONST, type UploadConfigType, UploadProgressState, UploadProgressStateText, clearCacheStateHandler, computedBreakPointProgressHandler, enLanguage, generatorTask, getLng, jpLanguage, progressNormalOrErrorCompletionHandler, restartUploadFileHandler, sameFileNeedProceedHandler, splitFileUploadingHandler, startUploadFileHandler, startUploadFileNextHandler, toFixedHandler, uploadHandler, zhLanguage };
|