xframelib 0.9.2 → 0.9.4

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.
@@ -1,6 +1,17 @@
1
1
  import { XhrHeaders } from 'xhr';
2
2
  export type FileEventName = 'attempt' | 'attemptFailure' | 'chunkSuccess' | 'error' | 'offline' | 'online' | 'progress' | 'success';
3
3
  export type AllowedMethods = 'PUT' | 'POST' | 'PATCH';
4
+ /**
5
+ * 文件分片传输返回结果
6
+ */
7
+ export interface ChunkResult {
8
+ DATASOURCEID?: string;
9
+ NAME: string;
10
+ INDEX: number;
11
+ STATE: boolean;
12
+ END: boolean;
13
+ FILEPATH?: string;
14
+ }
4
15
  /**
5
16
  * 文件上传配置
6
17
  */
@@ -12,6 +23,7 @@ export interface FileUploadOptions {
12
23
  maxFileSize?: number;
13
24
  chunkSize?: number;
14
25
  attempts?: number;
26
+ threadNumber?: number;
15
27
  /**
16
28
  * 单位:秒
17
29
  */
@@ -30,9 +42,10 @@ export declare class FileUpload {
30
42
  attempts: number;
31
43
  delayBeforeAttempt: number;
32
44
  md5: string;
33
- private chunk?;
34
45
  private chunkCount;
35
46
  private chunkByteSize;
47
+ private cacheSize;
48
+ private currentMaxIndex;
36
49
  private maxFileBytes;
37
50
  private endpointValue?;
38
51
  private totalChunks;
@@ -40,8 +53,9 @@ export declare class FileUpload {
40
53
  private offline;
41
54
  private paused;
42
55
  private success;
43
- private currentXhr?;
44
- private reader;
56
+ private isResumed;
57
+ private mapXhrRequest;
58
+ private okRecordList;
45
59
  private eventTarget;
46
60
  private fileName;
47
61
  constructor(options: FileUploadOptions);
@@ -51,7 +65,7 @@ export declare class FileUpload {
51
65
  on(FileEventName: FileEventName, fn: (event: any) => void): void;
52
66
  abort(): void;
53
67
  pause(): void;
54
- resume(): void;
68
+ resume(): Promise<void>;
55
69
  /**
56
70
  * 发送消息
57
71
  */
@@ -76,7 +90,6 @@ export declare class FileUpload {
76
90
  /**
77
91
  * 失败处理和尝试
78
92
  */
79
- private manageRetries;
80
93
  /**
81
94
  * 进行分片上传,并处理错误和重试
82
95
  */
@@ -0,0 +1,90 @@
1
+ import { XhrHeaders } from 'xhr';
2
+ export type FileEventName = 'attempt' | 'attemptFailure' | 'chunkSuccess' | 'error' | 'offline' | 'online' | 'progress' | 'success';
3
+ export type AllowedMethods = 'PUT' | 'POST' | 'PATCH';
4
+ /**
5
+ * 文件上传配置
6
+ */
7
+ export interface FileUploadOptions {
8
+ endpoint: string | ((file?: File) => Promise<string>);
9
+ file: File;
10
+ method?: AllowedMethods;
11
+ headers?: XhrHeaders;
12
+ maxFileSize?: number;
13
+ chunkSize?: number;
14
+ attempts?: number;
15
+ /**
16
+ * 单位:秒
17
+ */
18
+ delayBeforeAttempt?: number;
19
+ md5?: string;
20
+ }
21
+ /**
22
+ * 文件上传类
23
+ */
24
+ export declare class FileUpload {
25
+ endpoint: string | ((file?: File) => Promise<string>);
26
+ file: File;
27
+ headers: XhrHeaders;
28
+ method: AllowedMethods;
29
+ chunkSize: number;
30
+ attempts: number;
31
+ delayBeforeAttempt: number;
32
+ md5: string;
33
+ private chunk?;
34
+ private chunkCount;
35
+ private chunkByteSize;
36
+ private maxFileBytes;
37
+ private endpointValue?;
38
+ private totalChunks;
39
+ private attemptCount;
40
+ private offline;
41
+ private paused;
42
+ private success;
43
+ private currentXhr?;
44
+ private reader;
45
+ private eventTarget;
46
+ private fileName;
47
+ constructor(options: FileUploadOptions);
48
+ /**
49
+ * 订阅事件
50
+ */
51
+ on(FileEventName: FileEventName, fn: (event: any) => void): void;
52
+ abort(): void;
53
+ pause(): void;
54
+ resume(): void;
55
+ /**
56
+ * 发送消息
57
+ */
58
+ private dispatch;
59
+ /**
60
+ *验证参数的正确性
61
+ */
62
+ private validateOptions;
63
+ /**
64
+ * Endpoint can either be a URL or a function that returns a promise that resolves to a string.
65
+ */
66
+ private getEndpoint;
67
+ /**
68
+ * Get portion of the file of x bytes corresponding to chunkSize
69
+ */
70
+ private getChunk;
71
+ private xhrPromise;
72
+ /**
73
+ * Send chunk of the file with appropriate headers and add post parameters if it's last chunk
74
+ */
75
+ private sendChunk;
76
+ /**
77
+ * 失败处理和尝试
78
+ */
79
+ private manageRetries;
80
+ /**
81
+ * 进行分片上传,并处理错误和重试
82
+ */
83
+ private sendChunks;
84
+ }
85
+ /**
86
+ * 创建文件上传对象方法
87
+ * @param options
88
+ * @returns
89
+ */
90
+ export declare const createFileUpload: (options: FileUploadOptions) => FileUpload;
@@ -0,0 +1,90 @@
1
+ import { XhrHeaders } from 'xhr';
2
+ export type FileEventName = 'attempt' | 'attemptFailure' | 'chunkSuccess' | 'error' | 'offline' | 'online' | 'progress' | 'success';
3
+ export type AllowedMethods = 'PUT' | 'POST' | 'PATCH';
4
+ /**
5
+ * 文件上传配置
6
+ */
7
+ export interface FileUploadOptions {
8
+ endpoint: string | ((file?: File) => Promise<string>);
9
+ file: File;
10
+ method?: AllowedMethods;
11
+ headers?: XhrHeaders;
12
+ maxFileSize?: number;
13
+ chunkSize?: number;
14
+ attempts?: number;
15
+ /**
16
+ * 单位:秒
17
+ */
18
+ delayBeforeAttempt?: number;
19
+ md5?: string;
20
+ }
21
+ /**
22
+ * 文件上传类
23
+ */
24
+ export declare class FileUpload {
25
+ endpoint: string | ((file?: File) => Promise<string>);
26
+ file: File;
27
+ headers: XhrHeaders;
28
+ method: AllowedMethods;
29
+ chunkSize: number;
30
+ attempts: number;
31
+ delayBeforeAttempt: number;
32
+ md5: string;
33
+ private chunk?;
34
+ private chunkCount;
35
+ private chunkByteSize;
36
+ private maxFileBytes;
37
+ private endpointValue?;
38
+ private totalChunks;
39
+ private attemptCount;
40
+ private offline;
41
+ private paused;
42
+ private success;
43
+ private currentXhr?;
44
+ private reader;
45
+ private eventTarget;
46
+ private fileName;
47
+ constructor(options: FileUploadOptions);
48
+ /**
49
+ * 订阅事件
50
+ */
51
+ on(FileEventName: FileEventName, fn: (event: any) => void): void;
52
+ abort(): void;
53
+ pause(): void;
54
+ resume(): void;
55
+ /**
56
+ * 发送消息
57
+ */
58
+ private dispatch;
59
+ /**
60
+ *验证参数的正确性
61
+ */
62
+ private validateOptions;
63
+ /**
64
+ * Endpoint can either be a URL or a function that returns a promise that resolves to a string.
65
+ */
66
+ private getEndpoint;
67
+ /**
68
+ * Get portion of the file of x bytes corresponding to chunkSize
69
+ */
70
+ private getChunk;
71
+ private xhrPromise;
72
+ /**
73
+ * Send chunk of the file with appropriate headers and add post parameters if it's last chunk
74
+ */
75
+ private sendChunk;
76
+ /**
77
+ * 失败处理和尝试
78
+ */
79
+ private manageRetries;
80
+ /**
81
+ * 进行分片上传,并处理错误和重试
82
+ */
83
+ private sendChunks;
84
+ }
85
+ /**
86
+ * 创建文件上传对象方法
87
+ * @param options
88
+ * @returns
89
+ */
90
+ export declare const createFileUpload: (options: FileUploadOptions) => FileUpload;
@@ -0,0 +1,102 @@
1
+ import { XhrHeaders } from 'xhr';
2
+ export type FileEventName = 'attempt' | 'attemptFailure' | 'chunkSuccess' | 'error' | 'offline' | 'online' | 'progress' | 'success';
3
+ export type AllowedMethods = 'PUT' | 'POST' | 'PATCH';
4
+ /**
5
+ * 文件分片传输返回结果
6
+ */
7
+ export interface ChunkResult {
8
+ DATASOURCEID?: string;
9
+ NAME: string;
10
+ INDEX: number;
11
+ STATE: boolean;
12
+ END: boolean;
13
+ FILEPATH?: string;
14
+ }
15
+ /**
16
+ * 文件上传配置
17
+ */
18
+ export interface FileUploadOptions {
19
+ endpoint: string | ((file?: File) => Promise<string>);
20
+ file: File;
21
+ method?: AllowedMethods;
22
+ headers?: XhrHeaders;
23
+ maxFileSize?: number;
24
+ chunkSize?: number;
25
+ attempts?: number;
26
+ /**
27
+ * 单位:秒
28
+ */
29
+ delayBeforeAttempt?: number;
30
+ md5?: string;
31
+ }
32
+ /**
33
+ * 文件上传类
34
+ */
35
+ export declare class FileUpload {
36
+ endpoint: string | ((file?: File) => Promise<string>);
37
+ file: File;
38
+ headers: XhrHeaders;
39
+ method: AllowedMethods;
40
+ chunkSize: number;
41
+ attempts: number;
42
+ delayBeforeAttempt: number;
43
+ md5: string;
44
+ private chunkCount;
45
+ private chunkByteSize;
46
+ private cacheSize;
47
+ private currentMaxIndex;
48
+ private maxFileBytes;
49
+ private endpointValue?;
50
+ private totalChunks;
51
+ private attemptCount;
52
+ private offline;
53
+ private paused;
54
+ private success;
55
+ private isResumed;
56
+ private mapXhrRequest;
57
+ private okRecordList;
58
+ private eventTarget;
59
+ private fileName;
60
+ constructor(options: FileUploadOptions);
61
+ /**
62
+ * 订阅事件
63
+ */
64
+ on(FileEventName: FileEventName, fn: (event: any) => void): void;
65
+ abort(): void;
66
+ pause(): void;
67
+ resume(): Promise<void>;
68
+ /**
69
+ * 发送消息
70
+ */
71
+ private dispatch;
72
+ /**
73
+ *验证参数的正确性
74
+ */
75
+ private validateOptions;
76
+ /**
77
+ * Endpoint can either be a URL or a function that returns a promise that resolves to a string.
78
+ */
79
+ private getEndpoint;
80
+ /**
81
+ * Get portion of the file of x bytes corresponding to chunkSize
82
+ */
83
+ private getChunk;
84
+ private xhrPromise;
85
+ /**
86
+ * Send chunk of the file with appropriate headers and add post parameters if it's last chunk
87
+ */
88
+ private sendChunk;
89
+ /**
90
+ * 失败处理和尝试
91
+ */
92
+ /**
93
+ * 进行分片上传,并处理错误和重试
94
+ */
95
+ private sendChunks;
96
+ }
97
+ /**
98
+ * 创建文件上传对象方法
99
+ * @param options
100
+ * @returns
101
+ */
102
+ export declare const createFileUpload: (options: FileUploadOptions) => FileUpload;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 为了解决循环引用依赖问题
3
+ */
1
4
  import { ITokenInfo } from '../model/IUserModel';
2
5
  import StorageHelper from '../utils/Storage';
3
6
  export declare const storageHelper: StorageHelper;
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "xframelib",
3
- "version": "0.9.2",
4
- "description": "积累的前端开发基础库",
5
- "main": "dist/index.js",
6
- "common": "dist/index.cjs",
7
- "typings": "dist/index.d.ts",
8
- "scripts": {
9
- "dev": "vite --port 8099",
10
- "build": "vite build",
11
- "lib": "rollup -c ",
12
- "serve": "vite preview",
13
- "clean": "rimraf dist && rimraf package-lock.json && rimraf node_modules/.cache && rimraf node_modules/.vite"
14
- },
15
- "keywords": [
16
- "hprose",
17
- "rpc",
18
- "typescript"
19
- ],
20
- "author": {
21
- "name": "zorrowm",
22
- "email": "zorrowm@126.com"
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/zorrowm/vue-widget-template.git"
27
- },
28
- "homepage": "https://zorrowm.github.io/doc/template.html",
29
- "license": "MIT",
30
- "dependencies": {
31
- "@hprose/io": "^3.0.10",
32
- "@hprose/rpc-core": "^3.0.10",
33
- "@hprose/rpc-html5": "^3.0.10",
34
- "@iconify/vue": "^4.3.0",
35
- "@microsoft/signalr": "^8.0.7",
36
- "axios": "^1.8.1",
37
- "fflate": "^0.8.2",
38
- "iconv-lite": "^0.6.3",
39
- "localforage": "^1.10.0",
40
- "loglevel": "^1.9.2",
41
- "qs": "^6.14.0",
42
- "spark-md5": "^3.0.2",
43
- "streamsaver": "^2.0.6",
44
- "xhr": "^2.6.0"
45
- },
46
- "devDependencies": {
47
- "@rollup/plugin-alias": "^5.1.1",
48
- "@rollup/plugin-commonjs": "^28.0.2",
49
- "@rollup/plugin-json": "^6.1.0",
50
- "@rollup/plugin-node-resolve": "^16.0.0",
51
- "@rollup/plugin-terser": "^0.4.4",
52
- "@rollup/plugin-typescript": "^12.1.2",
53
- "@types/streamsaver": "^2.0.5",
54
- "@vitejs/plugin-vue": "^5.2.1",
55
- "esbuild": "^0.25.0",
56
- "rimraf": "^6.0.1",
57
- "rollup-plugin-copy": "^3.5.0",
58
- "rollup-plugin-esbuild": "^6.2.1",
59
- "rollup-plugin-scss": "^4.0.1",
60
- "rollup-plugin-typescript2": "^0.36.0",
61
- "rollup-plugin-vue": "^6.0.0",
62
- "sass": "^1.85.1",
63
- "typescript": "^5.8.2",
64
- "vite": "^6.2.0",
65
- "vue": "^3.5.13",
66
- "vue-router": "^4.5.0"
67
- }
68
- }
1
+ {
2
+ "name": "xframelib",
3
+ "version": "0.9.4",
4
+ "description": "积累的前端开发基础库",
5
+ "main": "dist/index.js",
6
+ "common": "dist/index.cjs",
7
+ "typings": "dist/index.d.ts",
8
+ "type":"module",
9
+ "scripts": {
10
+ "dev": "vite --port 8099",
11
+ "build": "vite build",
12
+ "lib": "rollup -c ",
13
+ "serve": "vite preview",
14
+ "clean": "rimraf dist && rimraf package-lock.json && rimraf node_modules/.cache && rimraf node_modules/.vite"
15
+ },
16
+ "keywords": [
17
+ "hprose",
18
+ "rpc",
19
+ "typescript"
20
+ ],
21
+ "author": {
22
+ "name": "zorrowm",
23
+ "email": "zorrowm@126.com"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/zorrowm/vue-widget-template.git"
28
+ },
29
+ "homepage": "https://zorrowm.github.io/doc/template.html",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@hprose/io": "^3.0.10",
33
+ "@hprose/rpc-core": "^3.0.10",
34
+ "@hprose/rpc-html5": "^3.0.10",
35
+ "@iconify/vue": "^4.3.0",
36
+ "@microsoft/signalr": "^8.0.7",
37
+ "axios": "^1.8.4",
38
+ "fflate": "^0.8.2",
39
+ "iconv-lite": "^0.6.3",
40
+ "localforage": "^1.10.0",
41
+ "loglevel": "^1.9.2",
42
+ "qs": "^6.14.0",
43
+ "spark-md5": "^3.0.2",
44
+ "streamsaver": "^2.0.6",
45
+ "xhr": "^2.6.0"
46
+ },
47
+ "devDependencies": {
48
+ "@rollup/plugin-alias": "^5.1.1",
49
+ "@rollup/plugin-commonjs": "^28.0.3",
50
+ "@rollup/plugin-json": "^6.1.0",
51
+ "@rollup/plugin-node-resolve": "^16.0.1",
52
+ "@rollup/plugin-terser": "^0.4.4",
53
+ "@rollup/plugin-typescript": "^12.1.2",
54
+ "@types/streamsaver": "^2.0.5",
55
+ "@vitejs/plugin-vue": "^5.2.3",
56
+ "esbuild": "^0.25.3",
57
+ "rimraf": "^6.0.1",
58
+ "rollup-plugin-copy": "^3.5.0",
59
+ "rollup-plugin-esbuild": "^6.2.1",
60
+ "rollup-plugin-scss": "^4.0.1",
61
+ "rollup-plugin-typescript2": "^0.36.0",
62
+ "rollup-plugin-vue": "^6.0.0",
63
+ "sass": "^1.87.0",
64
+ "typescript": "^5.8.3",
65
+ "vite": "^6.3.3",
66
+ "vue": "^3.5.13",
67
+ "vue-router": "^4.5.0"
68
+ }
69
+ }