@seayoo-web/request 2.0.5 → 2.0.7

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.
Files changed (36) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.js +61 -61
  3. package/dist/node.cjs +1 -1
  4. package/dist/node.js +12 -12
  5. package/dist/request.fetch-CMHsH_k5.cjs +1 -0
  6. package/dist/request.fetch-qLDV6Xdq.js +51 -0
  7. package/dist/{version-BEDupKzt.js → version-DNvZe-sl.js} +158 -148
  8. package/dist/version-DgNkLRed.cjs +2 -0
  9. package/dist/wx.cjs +1 -1
  10. package/dist/wx.js +13 -13
  11. package/package.json +29 -38
  12. package/{dist → types}/index.d.ts +14 -12
  13. package/{dist → types}/node.d.ts +11 -11
  14. package/types/version.d.ts +1 -0
  15. package/{dist → types}/wx.d.ts +9 -9
  16. package/Migeration.md +0 -7
  17. package/dist/request.fetch-49pAyky3.js +0 -40
  18. package/dist/request.fetch-D0LxU0UO.cjs +0 -1
  19. package/dist/version-otf8Cl2Z.cjs +0 -2
  20. package/dist/version.d.ts +0 -1
  21. package/{dist → types}/inc/cache.d.ts +0 -0
  22. package/{dist → types}/inc/config.d.ts +0 -0
  23. package/{dist → types}/inc/detect.d.ts +0 -0
  24. package/{dist → types}/inc/guard.d.ts +1 -1
  25. package/{dist → types}/inc/jsonp.d.ts +0 -0
  26. package/{dist → types}/inc/main.d.ts +0 -0
  27. package/{dist → types}/inc/option.d.ts +1 -1
  28. package/{dist → types}/inc/request.fetch.d.ts +0 -0
  29. package/{dist → types}/inc/request.node.d.ts +0 -0
  30. package/{dist → types}/inc/request.wx.d.ts +0 -0
  31. package/{dist → types}/inc/request.xhr.d.ts +0 -0
  32. package/{dist → types}/inc/response.d.ts +0 -0
  33. package/{dist → types}/inc/retry.d.ts +1 -1
  34. package/{dist → types}/inc/rule.d.ts +0 -0
  35. package/{dist → types}/inc/sentry.d.ts +0 -0
  36. package/{dist → types}/inc/type.d.ts +1 -1
package/package.json CHANGED
@@ -1,57 +1,51 @@
1
1
  {
2
2
  "name": "@seayoo-web/request",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "requst tools for seayoo web",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
6
  "source": "./src/index.ts",
9
- "types": "./dist/index.d.ts",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./dist/index.d.ts",
12
+ "types": "./types/index.d.ts",
13
13
  "import": "./dist/index.js",
14
14
  "require": "./dist/index.cjs",
15
15
  "default": "./dist/index.js"
16
16
  },
17
17
  "./node": {
18
18
  "browser": null,
19
- "types": "./dist/node.d.ts",
19
+ "types": "./types/node.d.ts",
20
20
  "import": "./dist/node.js",
21
21
  "require": "./dist/node.cjs",
22
22
  "default": "./dist/node.cjs"
23
23
  },
24
24
  "./dist/node": {
25
25
  "browser": null,
26
- "types": "./dist/node.d.ts",
26
+ "types": "./types/node.d.ts",
27
27
  "import": "./dist/node.js",
28
28
  "require": "./dist/node.cjs",
29
29
  "default": "./dist/node.cjs"
30
30
  },
31
31
  "./wx": {
32
- "types": "./dist/wx.d.ts",
32
+ "types": "./types/wx.d.ts",
33
33
  "import": "./dist/wx.js",
34
34
  "require": "./dist/wx.cjs",
35
35
  "default": "./dist/wx.js"
36
36
  }
37
37
  },
38
+ "files": [
39
+ "dist",
40
+ "types",
41
+ "README.md"
42
+ ],
38
43
  "publishConfig": {
39
44
  "access": "public"
40
45
  },
41
46
  "engines": {
42
47
  "node": ">=18"
43
48
  },
44
- "scripts": {
45
- "build": "node scripts/emitVersion.mjs && vite build && tsc --emitDeclarationOnly",
46
- "emit-types": "tsc --emitDeclarationOnly",
47
- "clear": "rimraf dist && rimraf node_modules",
48
- "type-check": "tsc --noEmit",
49
- "lint": "eslint ./src/**/*.ts",
50
- "lint:fix": "eslint ./src/**/*.{ts,js} --fix",
51
- "pub": "pnpm lint:fix && pnpm build && npm publish",
52
- "test": "vitest --typecheck --dom",
53
- "coverage": "vitest run --coverage"
54
- },
55
49
  "keywords": [
56
50
  "request",
57
51
  "fetch",
@@ -59,29 +53,26 @@
59
53
  ],
60
54
  "author": "web@seayoo.com",
61
55
  "license": "ISC",
62
- "simple-git-hooks": {
63
- "pre-commit": "pnpm run lint",
64
- "commit-msg": "node scripts/verifyCommit.mjs $1"
65
- },
66
56
  "devDependencies": {
67
- "@types/node": "18.19.5",
68
- "@typescript-eslint/eslint-plugin": "^6.21.0",
69
- "@typescript-eslint/parser": "^6.21.0",
70
- "@vitest/browser": "^1.4.0",
71
- "@vitest/coverage-istanbul": "^1.4.0",
72
- "eslint": "^8.57.0",
73
- "eslint-config-prettier": "^9.1.0",
74
- "eslint-plugin-prettier": "^5.1.3",
57
+ "@vitest/browser": "^3.0.5",
58
+ "@vitest/coverage-istanbul": "^3.0.5",
75
59
  "happy-dom": "^12.10.3",
76
- "lint-staged": "^14.0.1",
77
- "msw": "^2.2.13",
78
- "rimraf": "^5.0.5",
79
- "simple-git-hooks": "^2.11.1",
80
- "typescript": "~5.2.2",
81
- "vite": "^5.2.8",
82
- "vitest": "1.4.0"
60
+ "msw": "^2.7.0",
61
+ "rimraf": "^6.0.1",
62
+ "vitest": "^3.0.5"
83
63
  },
84
64
  "dependencies": {
85
65
  "@seayoo-web/utils": "^1.20.0"
66
+ },
67
+ "scripts": {
68
+ "build": "node version.mjs && vite build && tsc --emitDeclarationOnly",
69
+ "emit-types": "tsc --emitDeclarationOnly",
70
+ "clear": "rimraf dist && rimraf node_modules",
71
+ "type-check": "tsc --noEmit",
72
+ "lint": "eslint ./src/**/*.ts",
73
+ "lint:fix": "eslint ./src/**/*.{ts,js} --fix",
74
+ "prepublish": "pnpm lint:fix && pnpm build",
75
+ "test": "vitest --typecheck --dom",
76
+ "coverage": "vitest run --coverage"
86
77
  }
87
78
  }
@@ -9,6 +9,8 @@ export type { IRequestOptions, IRequestGlobalConfig, IResponseRule, IResponseRes
9
9
  * 基于 xhr 模块的上传工具,支持上传进度
10
10
  */
11
11
  export declare const upload: (url: string, files: Parameters<typeof xhrUpload>[1], options?: Parameters<typeof xhrUpload>[2]) => ReturnType<typeof xhrUpload>;
12
+ /** NetRequest 工厂函数定义 */
13
+ export type NetRequestFactory = typeof NetRequest;
12
14
  /**
13
15
  * 创建新的实例空间,配置和缓存跟全局默认实例是隔离的,仅支持在浏览器环境使用
14
16
  */
@@ -20,18 +22,18 @@ export declare const setGlobalConfig: (config: IRequestGlobalConfig) => void;
20
22
  /**
21
23
  * 发送一个网络请求
22
24
  */
23
- export declare const request: (url: string, options?: import("./inc/type").IRequestOptions | undefined) => Promise<import("./inc/type").IResponseResult<unknown>>;
25
+ export declare const request: (url: string, options?: import("./inc/type").IRequestOptions) => Promise<import("./inc/type").IResponseResult<unknown>>;
24
26
  /**
25
27
  * 发送一个 HEAD 请求
26
28
  */
27
- export declare const head: (url: string, options?: import("./inc/type").IRequestOptions | undefined) => import("./inc/type").ResponseWithoutType;
29
+ export declare const head: (url: string, options?: import("./inc/type").IRequestOptions) => import("./inc/type").ResponseWithoutType;
28
30
  /**
29
31
  * 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
30
32
  */
31
33
  export declare const get: {
32
34
  (url: string): import("./inc/type").ResponseWithoutType;
33
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
34
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
35
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
36
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
35
37
  };
36
38
  /**
37
39
  * 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
@@ -39,16 +41,16 @@ export declare const get: {
39
41
  export declare const post: {
40
42
  (url: string): import("./inc/type").ResponseWithoutType;
41
43
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
42
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
43
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
44
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
45
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
44
46
  };
45
47
  /**
46
48
  * 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
47
49
  */
48
50
  export declare const del: {
49
51
  (url: string): import("./inc/type").ResponseWithoutType;
50
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
51
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
52
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
53
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
52
54
  };
53
55
  /**
54
56
  * 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
@@ -56,8 +58,8 @@ export declare const del: {
56
58
  export declare const put: {
57
59
  (url: string): import("./inc/type").ResponseWithoutType;
58
60
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
59
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
60
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
61
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
62
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
61
63
  };
62
64
  /**
63
65
  * 发送一个 PATCH 请求,可选 typeGuard 用于检查数据类型
@@ -65,6 +67,6 @@ export declare const put: {
65
67
  export declare const patch: {
66
68
  (url: string): import("./inc/type").ResponseWithoutType;
67
69
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
68
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
69
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
70
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
71
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
70
72
  };
@@ -13,14 +13,14 @@ export declare const setGlobalConfig: (config: IRequestGlobalConfig) => void;
13
13
  /**
14
14
  * 发送一个 HEAD 请求
15
15
  */
16
- export declare const head: (url: string, options?: import("./inc/type").IRequestOptions | undefined) => import("./inc/type").ResponseWithoutType;
16
+ export declare const head: (url: string, options?: import("./inc/type").IRequestOptions) => import("./inc/type").ResponseWithoutType;
17
17
  /**
18
18
  * 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
19
19
  */
20
20
  export declare const get: {
21
21
  (url: string): import("./inc/type").ResponseWithoutType;
22
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
23
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
22
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
23
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
24
24
  };
25
25
  /**
26
26
  * 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
@@ -28,16 +28,16 @@ export declare const get: {
28
28
  export declare const post: {
29
29
  (url: string): import("./inc/type").ResponseWithoutType;
30
30
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
31
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
32
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
31
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
32
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
33
33
  };
34
34
  /**
35
35
  * 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
36
36
  */
37
37
  export declare const del: {
38
38
  (url: string): import("./inc/type").ResponseWithoutType;
39
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
40
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
39
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
40
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
41
41
  };
42
42
  /**
43
43
  * 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
@@ -45,8 +45,8 @@ export declare const del: {
45
45
  export declare const put: {
46
46
  (url: string): import("./inc/type").ResponseWithoutType;
47
47
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
48
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
49
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
48
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
49
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
50
50
  };
51
51
  /**
52
52
  * 发送一个 PATCH 请求,可选 typeGuard 用于检查数据类型
@@ -54,6 +54,6 @@ export declare const put: {
54
54
  export declare const patch: {
55
55
  (url: string): import("./inc/type").ResponseWithoutType;
56
56
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
57
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
58
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
57
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
58
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
59
59
  };
@@ -0,0 +1 @@
1
+ export declare const version = "2.0.7";
@@ -13,14 +13,14 @@ export declare const setGlobalConfig: (config: IRequestGlobalConfig) => void;
13
13
  /**
14
14
  * 发送一个 HEAD 请求
15
15
  */
16
- export declare const head: (url: string, options?: import("./inc/type").IRequestOptions | undefined) => import("./inc/type").ResponseWithoutType;
16
+ export declare const head: (url: string, options?: import("./inc/type").IRequestOptions) => import("./inc/type").ResponseWithoutType;
17
17
  /**
18
18
  * 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
19
19
  */
20
20
  export declare const get: {
21
21
  (url: string): import("./inc/type").ResponseWithoutType;
22
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
23
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
22
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
23
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
24
24
  };
25
25
  /**
26
26
  * 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
@@ -28,16 +28,16 @@ export declare const get: {
28
28
  export declare const post: {
29
29
  (url: string): import("./inc/type").ResponseWithoutType;
30
30
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
31
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
32
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
31
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
32
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
33
33
  };
34
34
  /**
35
35
  * 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
36
36
  */
37
37
  export declare const del: {
38
38
  (url: string): import("./inc/type").ResponseWithoutType;
39
- (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
40
- <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
39
+ (url: string, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
40
+ <T>(url: string, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
41
41
  };
42
42
  /**
43
43
  * 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
@@ -45,6 +45,6 @@ export declare const del: {
45
45
  export declare const put: {
46
46
  (url: string): import("./inc/type").ResponseWithoutType;
47
47
  (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
48
- (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
49
- <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
48
+ (url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithoutType;
49
+ <T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions): import("./inc/type").ResponseWithType<T>;
50
50
  };
package/Migeration.md DELETED
@@ -1,7 +0,0 @@
1
- ## v1 to v2
2
-
3
- `RequestOptions` 破坏性更新如下:
4
-
5
- 1. 删除了 `requestHandler` 参数,可以使用 `requestTransformer` 来检查和修改请求数据
6
- 2. `errorHandler` 处理函数的参数改为单一 option,原有平铺的参数被收入到 option 中
7
- 3. `url` 现在不再支持通过前缀 `/` 来跳过全局 baseURL 的合并处理以保持跟社区习惯一致;跳过全局 baseURL 的唯一方法就是设置一个完整的 url 地址
@@ -1,40 +0,0 @@
1
- import { h as u, r as h, c as b, S as l, f as m } from "./version-BEDupKzt.js";
2
- const y = async function(r, o, s) {
3
- return u(await h(f, r, o, s), r, o, s);
4
- }, f = async function(r, o, s) {
5
- const t = await b(r, o, s), n = new URL(t.url), i = t.params;
6
- i instanceof Object && Object.keys(i).forEach((a) => n.searchParams.set(a, i[a]));
7
- const e = l.AbortController ? new AbortController() : null;
8
- function c() {
9
- e && !e.signal.aborted && e.abort();
10
- }
11
- t.abort && t.abort.addEventListener("abort", c);
12
- const d = t.timeout > 0 ? setTimeout(c, t.timeout) : null;
13
- return await fetch(n, {
14
- method: t.method,
15
- headers: Object.keys(t.headers).length > 0 ? new Headers(t.headers) : void 0,
16
- body: t.body,
17
- credentials: t.credentials,
18
- signal: e == null ? void 0 : e.signal,
19
- redirect: "follow"
20
- }).then(async (a) => ({
21
- url: n.toString(),
22
- method: t.method,
23
- status: a.status,
24
- statusText: a.statusText,
25
- headers: m([...a.headers.entries()]),
26
- body: t.method === "HEAD" ? "" : await a.text().catch(() => "")
27
- })).catch((a) => ({
28
- url: n.toString(),
29
- method: t.method,
30
- status: -1,
31
- statusText: e != null && e.signal.aborted ? "Aborted" : "Unknown",
32
- body: "",
33
- rawError: a
34
- })).finally(() => {
35
- d !== null && clearTimeout(d), t.abort && t.abort.removeEventListener("abort", c);
36
- });
37
- };
38
- export {
39
- y as f
40
- };
@@ -1 +0,0 @@
1
- "use strict";const r=require("./version-otf8Cl2Z.cjs"),h=async function(o,s,n){return r.handleResponse(await r.retryRequest(b,o,s,n),o,s,n)},b=async function(o,s,n){const t=await r.convertOptions(o,s,n),i=new URL(t.url),c=t.params;c instanceof Object&&Object.keys(c).forEach(a=>i.searchParams.set(a,c[a]));const e=r.Support.AbortController?new AbortController:null;function u(){e&&!e.signal.aborted&&e.abort()}t.abort&&t.abort.addEventListener("abort",u);const d=t.timeout>0?setTimeout(u,t.timeout):null;return await fetch(i,{method:t.method,headers:Object.keys(t.headers).length>0?new Headers(t.headers):void 0,body:t.body,credentials:t.credentials,signal:e==null?void 0:e.signal,redirect:"follow"}).then(async a=>({url:i.toString(),method:t.method,status:a.status,statusText:a.statusText,headers:r.fromEntries([...a.headers.entries()]),body:t.method==="HEAD"?"":await a.text().catch(()=>"")})).catch(a=>({url:i.toString(),method:t.method,status:-1,statusText:e!=null&&e.signal.aborted?"Aborted":"Unknown",body:"",rawError:a})).finally(()=>{d!==null&&clearTimeout(d),t.abort&&t.abort.removeEventListener("abort",u)})};exports.fetchRequest=h;
@@ -1,2 +0,0 @@
1
- "use strict";var K=Object.defineProperty;var N=(e,t,s)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var y=(e,t,s)=>(N(e,typeof t!="symbol"?t+"":t,s),s);const p=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof window<"u"?window:{},w={fetch:"fetch"in p,window:"window"in p,FormData:"FormData"in p,Blob:"Blob"in p,wx:"wx"in p,TextDecoder:"TextDecoder"in p,AbortController:"AbortController"in p};function q(e){return e.reduce((t,[s,r])=>(s&&(t[s]=r||""),t),{})}function G(e){return new Promise(t=>setTimeout(t,Math.max(0,e)))}function J(){}function V(e){const t=e||"CustomError";return class extends Error{constructor(s){super(s),Object.defineProperty(this,"name",{value:t,enumerable:!1,configurable:!0}),"setPrototypeOf"in Object&&Object.setPrototypeOf(this,new.target.prototype),"captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}}}function j(e){return e?e[0].toLowerCase()+e.slice(1):""}const _=/_\w*/,x=/-\w*/;function A(e){const t=_.test(e)?e.replace(/(?:^_*|_*$)/g,"").replace(/_+([^_])/g,(s,r)=>r.toUpperCase()):x.test(e)?e.replace(/(?:^-*|-*$)/g,"").replace(/-+(\w)/g,(s,r)=>r.toUpperCase()):e;return j(t)}function U(e){return _.test(e)?j(e).replace(/(?:^_*|_*$)/g,"").replace(/_+([^_])/g,(t,s)=>"_"+s.toLowerCase()):x.test(e)?j(e.replace(/(?:^-*|-*$)/g,"")).replace(/-+(\w)/g,(t,s)=>"_"+s.toLowerCase()):j(e).replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}const W=/^(?:https?:)?\/\/.+$/i,z=/^https?:\/\/.+$/i,Q=/^\{[\d\D]*\}$/,Z=/^\[[\d\D]*\]$/;function O(e,t=!1){return t?W.test(e):z.test(e)}function X(e){return e==null}function v(e,...t){if(!e||typeof e!="object")return!1;const s=Object.getPrototypeOf(e);return s!==Object.prototype&&s!==null?!1:t.every(r=>r in e)}function B(e){return Q.test(e)||Z.test(e)}function k(e,t){try{const s=JSON.parse(e);return t?t(s)?s:null:s}catch{return null}}""+Math.random().toString(32).slice(2);function E(e,t=!1){return typeof e=="string"?A(e):Array.isArray(e)?e.map(s=>!t||typeof s=="string"?E(s):typeof s=="object"&&s?E(s,!0):s):v(e)?Object.keys(e).reduce((s,r)=>{const a=A(String(r)),n=a.charAt(0).toLowerCase()+a.slice(1);return s[n]=t?e[r]:E(e[r]),s},{}):e}function $(e,t=!1){return typeof e=="string"?U(e):Array.isArray(e)?e.map(s=>!t||typeof s=="string"?$(s):typeof s=="object"&&s?$(s,t):s):v(e)?Object.keys(e).reduce((s,r)=>{const a=U(String(r));return s[a]=t?e[r]:$(e[r]),s},{}):e}async function Y(e){return await new Promise(function(t){const s=document.getElementsByTagName("head")[0],r=document.createElement("script");r.setAttribute("type","text/javascript"),r.setAttribute("charset","utf-8"),r.onload=function(){s.removeChild(r),t(!0)},r.onerror=function(){s.removeChild(r),t(!1)},r.setAttribute("src",e),s.appendChild(r)})}function ee(e,t="数据未能正确识别"){return typeof e=="function"?{guard:e,message:t}:{guard:e.guard,message:e.message||t}}function te(e,t=""){return!t||O(e,!0)?D(e):(D(t)+"/"+e).replace(/\/{2,}/g,"/").replace(/:\//,"://")}function D(e){return O(e,!0)?e.startsWith("http")?e:("location"in globalThis?location.protocol:"https:")+e:("location"in globalThis?location.origin:"http://127.0.0.1")+"/"+e.replace(/^\/+/,"")}function se(e,t){const s={};return(e.match(/([^=&#?]+)=[^&#]*/g)||[]).forEach(function(r){const a=r.split("="),n=a[0],o=decodeURIComponent(a[1]||"");s[n]!==void 0?s[n]+=","+o:s[n]=o}),t!==!0?s[t]||"":s}function re(e,t){if(t){if(t===!0)return e.replace(/\?[^#]*/,"")}else return e;const s=e.split("#"),r=s[0].split("?"),a=r[0],n=r.length>1?r[1]:"",o=s.length>1?"#"+s[1]:"",c=typeof t=="string"?[t]:Array.isArray(t)?t:[];return!c.length||!n?s[0]+o:(c.map(i=>i.replace(/([\\(){}[\]^$+\-*?|])/g,"\\$1")),(a+"?"+n.replace(new RegExp("(?:^|&)(?:"+c.join("|")+")=[^&$]+","g"),"").replace(/^&/,"")).replace(/\?$/,"")+o)}function ne(e,t,s=!1){const r=typeof t=="string"?t:Object.keys(t).map(o=>`${o}=${encodeURIComponent(t[o])}`).join("&");if(!r)return e;const a=e.split("#");s&&(a[0]=re(a[0],(r.match(/([^=&#?]+)=[^&#]+/g)||[]).map(o=>o.replace(/=.+$/,""))));const n=a[0].indexOf("?")+1?"&":"?";return(a[0]+n+r+(a.length>1?"#"+a[1]:"")).replace(/\?&/,"?")}function ae(e){const t=e.match(/(?:\?|&)([^=]+)(?:&|$)/g);return t?t.join("").replace(/(?:\?|^&+|&+$)/g,"").replace(/&{2}/g,"&").split("&").sort():[]}class oe{constructor(t=500){y(this,"ttl");y(this,"cache");this.cache={},this.ttl=Math.max(t,0)}getKey(t,s){const r=t.replace(/#.+/,""),a=r.replace(/\?.+/g,""),n=Object.assign(se(r,!0),s),o=ae(r),c=Object.keys(n).sort().map(i=>`${i}#${n[i]}`);return`${a}_${c.join(",")}_${o.join(",")}`}updateTTL(t){this.ttl=Math.max(t,0)}get(t){if(this.ttl===0)return null;const s=this.cache[t];return s?s.ttl<Date.now()?(delete this.cache[t],null):s.res:null}set(t,s){this.ttl!==0&&(this.cache[t]={ttl:Date.now()+this.ttl,res:s})}}const M="UnexpectResponse";function ce(e,t,s,r){if(t.ok&&!X(t.data)&&r){const a=ee(r,"响应数据未能正确识别");return a.guard(t.data)||(s.showMessage(!0,`${e} ${a.message}`,t.code,t.status),console.error(M,e,t.data),t.data=null,t.code=M,t.message=a.message),t}return t}class S{constructor(t){y(this,"config",{baseURL:"",maxRetry:0,retryInterval:1e3,retryResolve:"network",timeout:1e4,cacheTTL:500,credentials:"same-origin",responseRule:{ok:{resolve:"body"},failed:{resolve:"json",messageField:"message"}}});t&&this.set(t)}set(t){if(t.baseURL&&!/^\/.+/.test(t.baseURL)&&!O(t.baseURL))throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"),new Error("BaseURLError");Object.assign(this.config,t)}get(t){return this.config[t]}getFullUrl(t){return te(t,this.config.baseURL)}showMessage(t,s,r,a){this.config.messageHandler&&s&&this.config.messageHandler(t,s,r,a)}}class ie{constructor(t,s){y(this,"agent");y(this,"config");y(this,"cache");this.config=new S(s),this.agent=t,this.cache=new oe(this.config.get("cacheTTL")),this.setConfig=this.setConfig.bind(this),this.getConfig=this.getConfig.bind(this),this.request=this.request.bind(this),this.get=this.get.bind(this),this.post=this.post.bind(this),this.del=this.del.bind(this),this.patch=this.patch.bind(this),this.put=this.put.bind(this),this.head=this.head.bind(this)}async request(t,s){try{return await this.agent(t,this.config,s)}catch(r){return console.error("RequestError",r),{ok:!1,status:-9,code:"Unkonwn",message:String(r),headers:{},data:null}}}async guard(t,s,r){return ce(t,s,this.config,r)}setConfig(t){this.config.set(t),this.cache.updateTTL(this.config.get("cacheTTL"))}getConfig(t){return this.config.get(t)}async head(t,s){const r=Object.assign({},s||null);return r.method="HEAD",this.guard(t,await this.request(t,r),null)}async get(t,s,r){const a=Object.assign({},r||null);a.method="GET";const n=this.cache.getKey(t,a.params),o=this.cache.get(n);if(o)return this.guard(t,await o,s||null);const c=this.request(t,a);return this.cache.set(n,c),this.guard(t,await c,s||null)}async post(t,s,r,a){const n=Object.assign({},a||null);return n.method="POST",n.body=s||{},this.guard(t,await this.request(t,n),r||null)}async del(t,s,r){const a=Object.assign({},r||null);return a.method="DELETE",this.guard(t,await this.request(t,a),s||null)}async put(t,s,r,a){const n=Object.assign({},a||null);return n.method="PUT",n.body=s||{},this.guard(t,await this.request(t,n),r||null)}async patch(t,s,r,a){const n=Object.assign({},a||null);return n.method="PATCH",n.body=s||{},this.guard(t,await this.request(t,n),r||null)}}const H="data",R="message";function ue(e,t,s,r,a){const n=a||r;return T(e)?ye(n.ok||r.ok,e,t,s):he(n.failed||r.failed,t,s)}const le=function(e){const t=[],s=e.failed||{resolve:"json"};switch(t.push("- 当http状态码 <200 或者 >=400 时"),s.resolve){case"body":t.push(" 将响应内容格式化为字符串并作为错误消息");break;case"json":t.push(" 将响应解析为json,并读取 "+(s.messageField||R)+" 作为错误消息");break}const r=e.ok||{resolve:"body"};switch(t.push("- 当http状态码 >=200 并且 <400 时"),r.resolve){case"body":t.push(" 将响应尝试解析为 json,并作为数据内容返回");break;case"json":t.push(" 将响应解析为 json,读取 "+(r.dataField||H)+" 作为响应数据,读取 "+(r.messageField||R)+" 作为提示消息"),r.statusField&&t.push(" 当 "+r.statusField+" 为 "+(r.statusOKValue||"空值")+" 时是成功提示,否则是错误消息"),r.ignoreMessage&&t.push(" 并忽略以下消息:"+r.ignoreMessage);break}return t.join(`
2
- `)};function he(e,t,s){const r=e||{resolve:"json",messageField:R},a={ok:!1,code:t,message:s,data:null};switch(r.resolve){case"body":a.message=L(s)||s;break;case"json":const{code:n,message:o}=de(s,r.converter,r.statusField,r.messageField);a.code=n||t,a.message=L(s)||o;break}return a}function de(e,t,s,r=R){if(!B(e))return{message:""};const a=F(k(e),t);return!a||!v(a)?{message:e}:{code:s?C(a,s):"",message:C(a,r)||e}}function C(e,t){const s=Array.isArray(t)?t:[t];for(const r of s)if(r in e)return ge(e[r]);return""}function ge(e){return e?typeof e=="string"?e:JSON.stringify(e):""}const fe=/<title>([^<]+)<\/title>/i,me=/<message>([^<]+)<\/message>/i;function L(e){const t=e.match(fe);if(t)return t[1];const s=e.match(me);return s?s[1]:""}function ye(e,t,s,r){const a=e||{resolve:"body"},n={ok:!0,code:s,message:"",data:null};if(t===204||!r)return n;if(a.resolve==="body")return n.data=B(r)?F(k(r),e.converter):r,n;const o=F(k(r),e.converter);if(!o||!v(o))return n.ok=!1,n.code="ResponseFormatError",n.message="响应内容无法格式化为 Object",n;const c=a.statusField,i=a.statusOKValue||"",h=a.dataField||H,u=a.messageField||R,l=a.ignoreMessage||"";if(c&&!(c in o))return n.ok=!1,n.code="ResponseFieldMissing",n.message="响应内容找不到状态字段 "+c,n;const d=c?o[c]+"":"";return n.ok=c?d===i:!0,n.code=d||s,n.data=h===!0?o:h in o?o[h]:null,n.message=C(o,u),l&&n.message&&(Array.isArray(l)&&l.includes(n.message)||typeof l=="string"&&n.message===l)&&(n.message=""),n}function T(e){return e>=200&&e<400}function F(e,t){return t==="camelize"?E(e):t==="snakify"?$(e):e}async function I(e,t,s,r,a){const n=a||0,o=Math.max(0,Math.min(10,(r==null?void 0:r.maxRetry)??s.get("maxRetry")??0)),c=(r==null?void 0:r.retryResolve)??s.get("retryResolve"),i=s.get("logHandler")||J;i({type:"prepear",url:t,method:(r==null?void 0:r.method)||"GET",retry:n,maxRetry:o,message:n===0?"start":`retry ${n}/${o} start`,headers:r==null?void 0:r.headers,options:r});const h=Date.now(),u=await e(t,s,r),l=u.status,d=Date.now()-h,g=`[cost ${d}][${l}] ${l<0?u.body:""}`;i({type:"finished",url:t,method:u.method,retry:n,maxRetry:o,message:n===0?`finish ${g}`:`retry ${n}/${o} finish ${g}`,response:u,headers:u.headers,cost:d});const m=T(l);if(!o||c==="network"&&l>0||c==="status"&&m||Array.isArray(c)&&!c.includes(l)||typeof c=="function"&&c(u,n)!==!0||n>=o)return u;const f=(r==null?void 0:r.retryInterval)??s.get("retryInterval")??1e3;return await G(Math.max(100,f==="2EB"?Math.pow(2,n)*1e3:typeof f=="function"?f(n+1)||0:f)),await I(e,t,s,r,n+1)}async function pe(e,t,s){var f;const r=Object.assign({method:"GET"},s),a=w.FormData?r.body instanceof FormData:!1,n=a&&r.method!=="POST"&&r.method!=="PUT"?"POST":r.method,o=n==="GET"||n==="HEAD"||n==="DELETE";o&&r.body!==void 0&&(console.warn("request body is invalid with method get, head, delete"),delete r.body);const c=Object.assign(a||o?{}:{"Content-Type":w.Blob&&r.body instanceof Blob?r.body.type||"application/octet-stream":"application/json;charset=utf-8"},r.headers),i=r.params||{},h={};Object.keys(i).forEach(b=>{i[b]!==void 0&&(h[b]=be(i[b]))});const u=t.getFullUrl(e),l=we(r.body),d=r.timeout||t.get("timeout"),g=await async function(){const b=t.get("requestTransformer");if(b)return await b({headers:c,params:h,method:n,url:u,body:l})}(),m=typeof g=="string"&&g?g:u;return(f=t.get("logHandler"))==null||f({type:"ready",url:m,method:n,headers:c,timeout:d,body:l}),{url:m,method:n,body:l,params:h,headers:c,timeout:d,abort:r.abort,credentials:r.credentials||t.get("credentials")}}function be(e){return typeof e=="string"?e:Array.isArray(e)?e.join(","):e+""}function we(e){if(e)return typeof e=="string"||e instanceof URLSearchParams||e instanceof ArrayBuffer||w.Blob&&e instanceof Blob||w.FormData&&e instanceof FormData?e:JSON.stringify(e)}const Re=V("APIError");function je(e){const t={};for(const a in e.headers)(a.startsWith("x-")||a.includes("trace")||a.includes("server")||/\b(?:id|uuid)\b/.test(a))&&(t[a]=e.headers[a]);const s=e.url.replace(/^(?:https?:)?\/*/i,"").replace(/\?.+/,""),r=e.status<0?"unknown":e.status;return{sentryError:new Re(`${s} | ${r}${e.code?` | ${e.code}`:""}`),sentryTags:{...t,status:r,method:e.method,code:e.code||"unknown",message:e.message||"empty"},sentryExtra:{url:e.url,responseBody:e.body||"empty",responseHeaders:e.headers,rawError:e.error}}}function Ee(e,t,s,r){var g;const a=e.status,n=e.method,o=q(Object.entries(e.headers||{}).map(([m,f])=>[m.toLowerCase(),f])),{ok:c,code:i,data:h,message:u}=ue(a,e.statusText,e.body,s.get("responseRule"),r==null?void 0:r.responseRule);if(!T(a)){const m=je({url:e.url,method:e.method,status:a,code:i,message:u,body:e.body,headers:o,error:e.rawError});(s.get("errorHandler")||$e)({url:t,method:n,status:a,code:i,message:u,headers:o,rawError:e.rawError,responseBody:e.body,...m})}if(a<0)return P({ok:!1,status:a,code:e.statusText,headers:{},message:"",data:null},`${n} ${t} ${e.statusText}`,n,t,s,r);const l={ok:c,data:h,code:i,message:u,status:a,headers:o};(g=s.get("responseHandler"))==null||g({...l},n,t);const d=c?u:u||e.statusText;return P(l,d,n,t,s,r)}function P(e,t,s,r,a,n){const o=a.get("message"),c=o===!1||(n==null?void 0:n.message)===!1?!1:(n==null?void 0:n.message)||o;if(c!==!1){const i=typeof c=="function"?c(e,s,r,t):t;i instanceof Error?a.showMessage(!0,i.message,e.code,e.status):i&&typeof i=="object"&&"message"in i?a.showMessage(!1,i.message,e.code,e.status):a.showMessage(!e.ok,i,e.code,e.status)}return e}function $e(e){const t={};for(const s in e)s.startsWith("sentry")||(t[s]=e[s]);console.error("RequestError",t)}const Oe="2.0.5";exports.Ee=Y;exports.K=O;exports.NetRequestHandler=ie;exports.RequestGlobalConfig=S;exports.Support=w;exports.convertOptions=pe;exports.fromEntries=q;exports.getResponseRulesDescription=le;exports.handleResponse=Ee;exports.retryRequest=I;exports.version=Oe;exports.vt=ne;
package/dist/version.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const version = "2.0.5";
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
- import type { IResponseResult, TypeGuardParam } from "./type";
2
1
  import type { RequestGlobalConfig } from "./config";
2
+ import type { IResponseResult, TypeGuardParam } from "./type";
3
3
  export declare function checkTypedDataResult<T>(url: string, result: IResponseResult, config: RequestGlobalConfig, typeGard: TypeGuardParam<T> | null): IResponseResult<T | null | unknown>;
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import type { IBaseRequestOptions, IBaseRequestBody } from "./type";
2
1
  import type { RequestGlobalConfig } from "./config";
2
+ import type { IBaseRequestOptions, IBaseRequestBody } from "./type";
3
3
  type FixedRequestOptions = Omit<Required<IBaseRequestOptions>, "params" | "body" | "abort"> & {
4
4
  url: string;
5
5
  params: Record<string, string>;
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
- import type { NetRequestCoreFn, IRequestOptions } from "./type";
2
1
  import type { RequestGlobalConfig } from "./config";
2
+ import type { NetRequestCoreFn, IRequestOptions } from "./type";
3
3
  export declare function retryRequest(agent: NetRequestCoreFn, url: string, config: RequestGlobalConfig, options?: IRequestOptions, _try?: number): ReturnType<NetRequestCoreFn>;
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import type { MaybePromise, TypeGuard, TypeGuardFn } from "@seayoo-web/utils";
2
1
  import type { RequestGlobalConfig } from "./config";
2
+ import type { MaybePromise, TypeGuard, TypeGuardFn } from "@seayoo-web/utils";
3
3
  export type IBaseRequestBody = Blob | ArrayBuffer | FormData | URLSearchParams | string;
4
4
  /** 通用网络请求工具的基本配置 */
5
5
  export interface IBaseRequestOptions {