@hlw-uni-mp/request 1.0.1 → 1.0.3

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/dist/index.d.mts CHANGED
@@ -56,25 +56,30 @@ declare function sha256(rawInput: string): string;
56
56
  /**
57
57
  * 递归规范化参数排序串(与后端 1:1 对齐)
58
58
  */
59
- declare function sortString(data: any): string;
59
+ declare function sortString(data: unknown): string;
60
60
  interface SignOptions {
61
61
  timestamp: string | number;
62
62
  nonce: string;
63
63
  context: string;
64
64
  secret?: string;
65
- data?: any;
65
+ data?: unknown;
66
66
  }
67
67
  /**
68
68
  * 计算请求防篡改签名
69
69
  */
70
70
  declare function calculateSign(options: SignOptions): string;
71
71
 
72
+ /**
73
+ * 支持的 HTTP 请求动词
74
+ */
75
+ type HttpMethod = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT'
76
+
72
77
  /**
73
78
  * 请求配置项
74
79
  */
75
80
  interface RequestConfig {
76
81
  url: string
77
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | string
82
+ method?: HttpMethod | string
78
83
  data?: unknown
79
84
  params?: unknown
80
85
  baseURL?: string
@@ -85,7 +90,7 @@ interface RequestConfig {
85
90
  /**
86
91
  * 响应数据包
87
92
  */
88
- interface AxiosResponse<T = any> {
93
+ interface AxiosResponse<T = unknown> {
89
94
  data: T
90
95
  status: number
91
96
  statusText: string
@@ -98,7 +103,7 @@ interface AxiosResponse<T = any> {
98
103
  */
99
104
  interface InterceptorHandler<T> {
100
105
  fulfilled?: (value: T) => T | Promise<T>
101
- rejected?: (error: any) => any
106
+ rejected?: (error: unknown) => unknown
102
107
  }
103
108
 
104
109
  /**
@@ -126,7 +131,7 @@ interface ApiResData {
126
131
  /**
127
132
  * 接口响应表
128
133
  */
129
- interface ApiRes<T = any> {
134
+ interface ApiRes<T = unknown> {
130
135
  /**
131
136
  * 状态码数值 (1 为成功)
132
137
  */
@@ -168,7 +173,7 @@ interface HttpOptions {
168
173
  /**
169
174
  * 获取设备函数
170
175
  */
171
- getDevice?: () => DeviceInfo | Record<string, any>
176
+ getDevice?: () => DeviceInfo | Record<string, unknown>
172
177
  /**
173
178
  * 鉴权失败回调
174
179
  */
@@ -201,17 +206,14 @@ interface LocalUploadSign extends UploadSignBase {
201
206
  }
202
207
 
203
208
  /**
204
- * 阿里存储凭据
209
+ * 阿里存储凭据(严格遵循阿里云 PostObject 规范单一属性名)
205
210
  */
206
211
  interface AliossUploadSign extends UploadSignBase {
207
212
  type: 'alioss'
208
213
  OSSAccessKeyId: string
209
214
  policy: string
210
215
  Signature: string
211
- success_action_status: string
212
- oSSAccessKeyId?: string
213
- signature?: string
214
- successActionStatus?: string
216
+ success_action_status?: string
215
217
  }
216
218
 
217
219
  /**
@@ -290,7 +292,10 @@ declare function encryptRsa(plaintext: string, publicKey: string): string;
290
292
  * @param source 源文件路径或文件对象
291
293
  * @returns 资源访问地址
292
294
  */
293
- declare function uploadOss(oss: OssConfig, source: string | any): Promise<string>;
295
+ declare function uploadOss(oss: OssConfig, source: string | {
296
+ path?: string;
297
+ tempFilePath?: string;
298
+ }): Promise<string>;
294
299
 
295
300
  /**
296
301
  * 请求上传凭证
@@ -304,7 +309,7 @@ declare function postUploadSign(data: {
304
309
  size?: number;
305
310
  }, signUrl?: string): Promise<ApiRes<UploadSign>>;
306
311
  /**
307
- * 执行文件直传
312
+ * 执行文件直传(原生解析,杜绝 escape/decode 废弃 API)
308
313
  * @param cred 上传签名凭据
309
314
  * @param filePath 本地文件路径
310
315
  * @param customHeader 额外请求头
@@ -318,12 +323,25 @@ declare function doUpload(cred: UploadSign, filePath: string, customHeader?: Rec
318
323
  */
319
324
  declare function uploadFile(params: UploadFileParams): Promise<string>;
320
325
 
326
+ /**
327
+ * 统一网络请求异常类
328
+ */
329
+ declare class HttpError<T = unknown> extends Error {
330
+ response?: AxiosResponse<T>;
331
+ status?: number;
332
+ config?: RequestConfig;
333
+ constructor(message: string, options?: {
334
+ response?: AxiosResponse<T>;
335
+ status?: number;
336
+ config?: RequestConfig;
337
+ });
338
+ }
321
339
  /**
322
340
  * 拦截管理器
323
341
  */
324
342
  declare class InterceptorManager<T> {
325
343
  private handlers;
326
- use(fulfilled?: (value: T) => T | Promise<T>, rejected?: (error: any) => any): number;
344
+ use(fulfilled?: (value: T) => T | Promise<T>, rejected?: (error: unknown) => unknown): number;
327
345
  eject(id: number): void;
328
346
  forEach(fn: (handler: InterceptorHandler<T>) => void): void;
329
347
  }
@@ -338,18 +356,18 @@ declare class UniHttpClient {
338
356
  };
339
357
  interceptors: {
340
358
  request: InterceptorManager<RequestConfig>;
341
- response: InterceptorManager<AxiosResponse<any>>;
359
+ response: InterceptorManager<AxiosResponse<unknown>>;
342
360
  };
343
361
  constructor(options?: {
344
362
  baseURL?: string;
345
363
  timeout?: number;
346
364
  headers?: Record<string, string>;
347
365
  });
348
- request<T = any>(config: RequestConfig): Promise<AxiosResponse<T>>;
349
- get<T = any>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
350
- post<T = any>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
351
- put<T = any>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
352
- delete<T = any>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
366
+ request<T = unknown>(config: RequestConfig): Promise<AxiosResponse<T>>;
367
+ get<T = unknown>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
368
+ post<T = unknown>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
369
+ put<T = unknown>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
370
+ delete<T = unknown>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
353
371
  private resolveUrl;
354
372
  private send;
355
373
  }
@@ -364,23 +382,23 @@ declare function setupHttp(options?: Partial<HttpOptions>): UniHttpClient;
364
382
  /**
365
383
  * 发送通用请求
366
384
  */
367
- declare function request<T = any>(config: RequestConfig): Promise<ApiRes<T>>;
385
+ declare function request<T = unknown>(config: RequestConfig): Promise<ApiRes<T>>;
368
386
  /**
369
387
  * 发送 GET 读取请求
370
388
  */
371
- declare function get<T = any>(url: string, params?: unknown): Promise<ApiRes<T>>;
389
+ declare function get<T = unknown>(url: string, params?: unknown): Promise<ApiRes<T>>;
372
390
  /**
373
391
  * 发送 POST 提交请求
374
392
  */
375
- declare function post<T = any>(url: string, data?: unknown): Promise<ApiRes<T>>;
393
+ declare function post<T = unknown>(url: string, data?: unknown): Promise<ApiRes<T>>;
376
394
  /**
377
395
  * 发送 PUT 修改请求
378
396
  */
379
- declare function put<T = any>(url: string, data?: unknown): Promise<ApiRes<T>>;
397
+ declare function put<T = unknown>(url: string, data?: unknown): Promise<ApiRes<T>>;
380
398
  /**
381
399
  * 发送 DELETE 删除请求
382
400
  */
383
- declare function del<T = any>(url: string, params?: unknown): Promise<ApiRes<T>>;
401
+ declare function del<T = unknown>(url: string, params?: unknown): Promise<ApiRes<T>>;
384
402
  /**
385
403
  * 获取全局网络配置
386
404
  */
@@ -388,4 +406,4 @@ declare function getHttpOptions(): HttpOptions;
388
406
  declare const client: UniHttpClient;
389
407
  declare const http: UniHttpClient;
390
408
 
391
- export { type AliossUploadSign, type ApiRes, type ApiResData, type AxiosResponse, type DeviceInfo, type HttpOptions, type InterceptorHandler, InterceptorManager, type LocalUploadSign, type ModalOptions, type OssConfig, type QiniuUploadSign, type RequestConfig, type SignOptions, UniHttpClient, type UploadFileParams, type UploadSign, type UploadSignBase, calculateSign, client, request as default, del, doUpload, encryptRsa, get, getClient, getDevice, getHttpOptions, http, post, postUploadSign, put, request, setupHttp, sha256, sortString, uploadFile, uploadOss };
409
+ export { type AliossUploadSign, type ApiRes, type ApiResData, type AxiosResponse, type DeviceInfo, HttpError, type HttpMethod, type HttpOptions, type InterceptorHandler, InterceptorManager, type LocalUploadSign, type ModalOptions, type OssConfig, type QiniuUploadSign, type RequestConfig, type SignOptions, UniHttpClient, type UploadFileParams, type UploadSign, type UploadSignBase, calculateSign, client, request as default, del, doUpload, encryptRsa, get, getClient, getDevice, getHttpOptions, http, post, postUploadSign, put, request, setupHttp, sha256, sortString, uploadFile, uploadOss };
package/dist/index.d.ts CHANGED
@@ -56,25 +56,30 @@ declare function sha256(rawInput: string): string;
56
56
  /**
57
57
  * 递归规范化参数排序串(与后端 1:1 对齐)
58
58
  */
59
- declare function sortString(data: any): string;
59
+ declare function sortString(data: unknown): string;
60
60
  interface SignOptions {
61
61
  timestamp: string | number;
62
62
  nonce: string;
63
63
  context: string;
64
64
  secret?: string;
65
- data?: any;
65
+ data?: unknown;
66
66
  }
67
67
  /**
68
68
  * 计算请求防篡改签名
69
69
  */
70
70
  declare function calculateSign(options: SignOptions): string;
71
71
 
72
+ /**
73
+ * 支持的 HTTP 请求动词
74
+ */
75
+ type HttpMethod = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT'
76
+
72
77
  /**
73
78
  * 请求配置项
74
79
  */
75
80
  interface RequestConfig {
76
81
  url: string
77
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | string
82
+ method?: HttpMethod | string
78
83
  data?: unknown
79
84
  params?: unknown
80
85
  baseURL?: string
@@ -85,7 +90,7 @@ interface RequestConfig {
85
90
  /**
86
91
  * 响应数据包
87
92
  */
88
- interface AxiosResponse<T = any> {
93
+ interface AxiosResponse<T = unknown> {
89
94
  data: T
90
95
  status: number
91
96
  statusText: string
@@ -98,7 +103,7 @@ interface AxiosResponse<T = any> {
98
103
  */
99
104
  interface InterceptorHandler<T> {
100
105
  fulfilled?: (value: T) => T | Promise<T>
101
- rejected?: (error: any) => any
106
+ rejected?: (error: unknown) => unknown
102
107
  }
103
108
 
104
109
  /**
@@ -126,7 +131,7 @@ interface ApiResData {
126
131
  /**
127
132
  * 接口响应表
128
133
  */
129
- interface ApiRes<T = any> {
134
+ interface ApiRes<T = unknown> {
130
135
  /**
131
136
  * 状态码数值 (1 为成功)
132
137
  */
@@ -168,7 +173,7 @@ interface HttpOptions {
168
173
  /**
169
174
  * 获取设备函数
170
175
  */
171
- getDevice?: () => DeviceInfo | Record<string, any>
176
+ getDevice?: () => DeviceInfo | Record<string, unknown>
172
177
  /**
173
178
  * 鉴权失败回调
174
179
  */
@@ -201,17 +206,14 @@ interface LocalUploadSign extends UploadSignBase {
201
206
  }
202
207
 
203
208
  /**
204
- * 阿里存储凭据
209
+ * 阿里存储凭据(严格遵循阿里云 PostObject 规范单一属性名)
205
210
  */
206
211
  interface AliossUploadSign extends UploadSignBase {
207
212
  type: 'alioss'
208
213
  OSSAccessKeyId: string
209
214
  policy: string
210
215
  Signature: string
211
- success_action_status: string
212
- oSSAccessKeyId?: string
213
- signature?: string
214
- successActionStatus?: string
216
+ success_action_status?: string
215
217
  }
216
218
 
217
219
  /**
@@ -290,7 +292,10 @@ declare function encryptRsa(plaintext: string, publicKey: string): string;
290
292
  * @param source 源文件路径或文件对象
291
293
  * @returns 资源访问地址
292
294
  */
293
- declare function uploadOss(oss: OssConfig, source: string | any): Promise<string>;
295
+ declare function uploadOss(oss: OssConfig, source: string | {
296
+ path?: string;
297
+ tempFilePath?: string;
298
+ }): Promise<string>;
294
299
 
295
300
  /**
296
301
  * 请求上传凭证
@@ -304,7 +309,7 @@ declare function postUploadSign(data: {
304
309
  size?: number;
305
310
  }, signUrl?: string): Promise<ApiRes<UploadSign>>;
306
311
  /**
307
- * 执行文件直传
312
+ * 执行文件直传(原生解析,杜绝 escape/decode 废弃 API)
308
313
  * @param cred 上传签名凭据
309
314
  * @param filePath 本地文件路径
310
315
  * @param customHeader 额外请求头
@@ -318,12 +323,25 @@ declare function doUpload(cred: UploadSign, filePath: string, customHeader?: Rec
318
323
  */
319
324
  declare function uploadFile(params: UploadFileParams): Promise<string>;
320
325
 
326
+ /**
327
+ * 统一网络请求异常类
328
+ */
329
+ declare class HttpError<T = unknown> extends Error {
330
+ response?: AxiosResponse<T>;
331
+ status?: number;
332
+ config?: RequestConfig;
333
+ constructor(message: string, options?: {
334
+ response?: AxiosResponse<T>;
335
+ status?: number;
336
+ config?: RequestConfig;
337
+ });
338
+ }
321
339
  /**
322
340
  * 拦截管理器
323
341
  */
324
342
  declare class InterceptorManager<T> {
325
343
  private handlers;
326
- use(fulfilled?: (value: T) => T | Promise<T>, rejected?: (error: any) => any): number;
344
+ use(fulfilled?: (value: T) => T | Promise<T>, rejected?: (error: unknown) => unknown): number;
327
345
  eject(id: number): void;
328
346
  forEach(fn: (handler: InterceptorHandler<T>) => void): void;
329
347
  }
@@ -338,18 +356,18 @@ declare class UniHttpClient {
338
356
  };
339
357
  interceptors: {
340
358
  request: InterceptorManager<RequestConfig>;
341
- response: InterceptorManager<AxiosResponse<any>>;
359
+ response: InterceptorManager<AxiosResponse<unknown>>;
342
360
  };
343
361
  constructor(options?: {
344
362
  baseURL?: string;
345
363
  timeout?: number;
346
364
  headers?: Record<string, string>;
347
365
  });
348
- request<T = any>(config: RequestConfig): Promise<AxiosResponse<T>>;
349
- get<T = any>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
350
- post<T = any>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
351
- put<T = any>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
352
- delete<T = any>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
366
+ request<T = unknown>(config: RequestConfig): Promise<AxiosResponse<T>>;
367
+ get<T = unknown>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
368
+ post<T = unknown>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
369
+ put<T = unknown>(url: string, data?: unknown, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
370
+ delete<T = unknown>(url: string, config?: Partial<RequestConfig>): Promise<AxiosResponse<T>>;
353
371
  private resolveUrl;
354
372
  private send;
355
373
  }
@@ -364,23 +382,23 @@ declare function setupHttp(options?: Partial<HttpOptions>): UniHttpClient;
364
382
  /**
365
383
  * 发送通用请求
366
384
  */
367
- declare function request<T = any>(config: RequestConfig): Promise<ApiRes<T>>;
385
+ declare function request<T = unknown>(config: RequestConfig): Promise<ApiRes<T>>;
368
386
  /**
369
387
  * 发送 GET 读取请求
370
388
  */
371
- declare function get<T = any>(url: string, params?: unknown): Promise<ApiRes<T>>;
389
+ declare function get<T = unknown>(url: string, params?: unknown): Promise<ApiRes<T>>;
372
390
  /**
373
391
  * 发送 POST 提交请求
374
392
  */
375
- declare function post<T = any>(url: string, data?: unknown): Promise<ApiRes<T>>;
393
+ declare function post<T = unknown>(url: string, data?: unknown): Promise<ApiRes<T>>;
376
394
  /**
377
395
  * 发送 PUT 修改请求
378
396
  */
379
- declare function put<T = any>(url: string, data?: unknown): Promise<ApiRes<T>>;
397
+ declare function put<T = unknown>(url: string, data?: unknown): Promise<ApiRes<T>>;
380
398
  /**
381
399
  * 发送 DELETE 删除请求
382
400
  */
383
- declare function del<T = any>(url: string, params?: unknown): Promise<ApiRes<T>>;
401
+ declare function del<T = unknown>(url: string, params?: unknown): Promise<ApiRes<T>>;
384
402
  /**
385
403
  * 获取全局网络配置
386
404
  */
@@ -388,4 +406,4 @@ declare function getHttpOptions(): HttpOptions;
388
406
  declare const client: UniHttpClient;
389
407
  declare const http: UniHttpClient;
390
408
 
391
- export { type AliossUploadSign, type ApiRes, type ApiResData, type AxiosResponse, type DeviceInfo, type HttpOptions, type InterceptorHandler, InterceptorManager, type LocalUploadSign, type ModalOptions, type OssConfig, type QiniuUploadSign, type RequestConfig, type SignOptions, UniHttpClient, type UploadFileParams, type UploadSign, type UploadSignBase, calculateSign, client, request as default, del, doUpload, encryptRsa, get, getClient, getDevice, getHttpOptions, http, post, postUploadSign, put, request, setupHttp, sha256, sortString, uploadFile, uploadOss };
409
+ export { type AliossUploadSign, type ApiRes, type ApiResData, type AxiosResponse, type DeviceInfo, HttpError, type HttpMethod, type HttpOptions, type InterceptorHandler, InterceptorManager, type LocalUploadSign, type ModalOptions, type OssConfig, type QiniuUploadSign, type RequestConfig, type SignOptions, UniHttpClient, type UploadFileParams, type UploadSign, type UploadSignBase, calculateSign, client, request as default, del, doUpload, encryptRsa, get, getClient, getDevice, getHttpOptions, http, post, postUploadSign, put, request, setupHttp, sha256, sortString, uploadFile, uploadOss };
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ HttpError: () => HttpError,
33
34
  InterceptorManager: () => InterceptorManager,
34
35
  UniHttpClient: () => UniHttpClient,
35
36
  calculateSign: () => calculateSign,
@@ -58,64 +59,57 @@ module.exports = __toCommonJS(index_exports);
58
59
  // src/device/index.ts
59
60
  var deviceCache = null;
60
61
  var currentNetworkType = "";
61
- try {
62
- if (typeof uni !== "undefined" && uni.getNetworkType) {
63
- uni.getNetworkType({
64
- success(res) {
65
- currentNetworkType = res.networkType || "";
66
- if (deviceCache) {
67
- deviceCache.networkType = currentNetworkType;
68
- }
69
- }
70
- });
71
- if (uni.onNetworkStatusChange) {
72
- uni.onNetworkStatusChange((res) => {
73
- currentNetworkType = res.networkType || "";
74
- if (deviceCache) {
75
- deviceCache.networkType = currentNetworkType;
76
- }
77
- });
62
+ uni.getNetworkType({
63
+ success(res) {
64
+ currentNetworkType = res.networkType || "";
65
+ if (deviceCache) {
66
+ deviceCache.networkType = currentNetworkType;
78
67
  }
79
68
  }
80
- } catch {
81
- }
69
+ });
70
+ uni.onNetworkStatusChange((res) => {
71
+ currentNetworkType = res.networkType || "";
72
+ if (deviceCache) {
73
+ deviceCache.networkType = currentNetworkType;
74
+ }
75
+ });
82
76
  function getDevice() {
83
77
  if (deviceCache) return deviceCache;
84
- const deviceRaw = typeof uni !== "undefined" ? uni.getDeviceInfo?.() : void 0;
85
- const windowRaw = typeof uni !== "undefined" ? uni.getWindowInfo?.() : void 0;
86
- const appRaw = typeof uni !== "undefined" ? uni.getAppBaseInfo?.() : void 0;
87
- const accountRaw = typeof uni !== "undefined" ? uni.getAccountInfoSync?.() : void 0;
88
- const system = deviceRaw?.system || "";
78
+ const deviceRaw = uni.getDeviceInfo();
79
+ const windowRaw = uni.getWindowInfo();
80
+ const appRaw = uni.getAppBaseInfo();
81
+ const accountRaw = uni.getAccountInfoSync();
82
+ const system = deviceRaw.system || "";
89
83
  deviceCache = {
90
- appid: accountRaw?.miniProgram?.appId || "",
91
- appName: appRaw?.appName || "",
92
- version: appRaw?.appVersion || "",
93
- versionCode: appRaw?.appVersionCode || "",
94
- channel: appRaw?.appChannel || "",
95
- deviceId: deviceRaw?.deviceId || "",
96
- deviceType: deviceRaw?.deviceType || "",
97
- deviceOrientation: deviceRaw?.deviceOrientation || windowRaw?.deviceOrientation || "portrait",
98
- brand: deviceRaw?.brand || "",
99
- model: deviceRaw?.model || "",
84
+ appid: accountRaw.miniProgram?.appId || "",
85
+ appName: appRaw.appName || "",
86
+ version: appRaw.appVersion || "",
87
+ versionCode: appRaw.appVersionCode || "",
88
+ channel: appRaw.appChannel || "",
89
+ deviceId: deviceRaw.deviceId || "",
90
+ deviceType: deviceRaw.deviceType || "",
91
+ deviceOrientation: deviceRaw.deviceOrientation || windowRaw.deviceOrientation || "portrait",
92
+ brand: deviceRaw.brand || "",
93
+ model: deviceRaw.model || "",
100
94
  system,
101
95
  os: system.split(" ")[0] || "",
102
- pixelRatio: windowRaw?.pixelRatio || 0,
103
- screenWidth: windowRaw?.screenWidth || 0,
104
- screenHeight: windowRaw?.screenHeight || 0,
105
- windowWidth: windowRaw?.windowWidth || 0,
106
- windowHeight: windowRaw?.windowHeight || 0,
107
- statusBarHeight: windowRaw?.statusBarHeight || 0,
108
- sdkVersion: appRaw?.SDKVersion || "",
109
- hostName: appRaw?.hostName || "",
110
- hostVersion: appRaw?.hostVersion || "",
111
- hostLanguage: appRaw?.hostLanguage || "",
112
- hostTheme: appRaw?.hostTheme || "",
113
- platform: deviceRaw?.platform || "",
114
- language: appRaw?.appLanguage || appRaw?.language || "",
96
+ pixelRatio: windowRaw.pixelRatio || 0,
97
+ screenWidth: windowRaw.screenWidth || 0,
98
+ screenHeight: windowRaw.screenHeight || 0,
99
+ windowWidth: windowRaw.windowWidth || 0,
100
+ windowHeight: windowRaw.windowHeight || 0,
101
+ statusBarHeight: windowRaw.statusBarHeight || 0,
102
+ sdkVersion: appRaw.SDKVersion || "",
103
+ hostName: appRaw.hostName || "",
104
+ hostVersion: appRaw.hostVersion || "",
105
+ hostLanguage: appRaw.hostLanguage || "",
106
+ hostTheme: appRaw.hostTheme || "",
107
+ platform: deviceRaw.platform || "",
108
+ language: appRaw.appLanguage || appRaw.language || "",
115
109
  networkType: currentNetworkType,
116
- benchmarkLevel: deviceRaw?.benchmarkLevel || 0,
117
- theme: appRaw?.theme || "light",
118
- fontSizeSetting: appRaw?.fontSizeSetting || 16
110
+ benchmarkLevel: deviceRaw.benchmarkLevel || 0,
111
+ theme: appRaw.theme || "light",
112
+ fontSizeSetting: appRaw.fontSizeSetting || 16
119
113
  };
120
114
  return deviceCache;
121
115
  }
@@ -305,10 +299,11 @@ function sortString(data) {
305
299
  if (Array.isArray(data)) {
306
300
  return "[" + data.map((item) => sortString(item)).join(",") + "]";
307
301
  }
308
- const keys = Object.keys(data).sort();
302
+ const obj = data;
303
+ const keys = Object.keys(obj).sort();
309
304
  const parts = [];
310
305
  for (const key of keys) {
311
- const val = data[key];
306
+ const val = obj[key];
312
307
  if (val !== null && val !== void 0) {
313
308
  parts.push(`${key}=${sortString(val)}`);
314
309
  }
@@ -327,17 +322,17 @@ function calculateSign(options) {
327
322
 
328
323
  // src/oss.ts
329
324
  async function uploadOss(oss, source) {
330
- const filePath = typeof source === "string" ? source : source?.path || source?.tempFilePath || "";
331
- const name = oss.filename || filePath?.split("/").pop() || "file";
325
+ const filePath = typeof source === "string" ? source : source.path || source.tempFilePath || "";
326
+ const name = oss.filename || filePath.split("/").pop() || "file";
332
327
  const formData = {
333
- key: String(oss.key || ""),
328
+ key: oss.key || "",
334
329
  success_action_status: "200"
335
330
  };
336
- if (oss.policy) formData.policy = String(oss.policy);
337
- if (oss.OSSAccessKeyId) formData.OSSAccessKeyId = String(oss.OSSAccessKeyId);
338
- if (oss.signature) formData.signature = String(oss.signature);
331
+ if (oss.policy) formData.policy = oss.policy;
332
+ if (oss.OSSAccessKeyId) formData.OSSAccessKeyId = oss.OSSAccessKeyId;
333
+ if (oss.signature) formData.signature = oss.signature;
339
334
  if (oss["x-oss-security-token"]) formData["x-oss-security-token"] = String(oss["x-oss-security-token"]);
340
- const target2 = String(oss.host || "");
335
+ const target2 = oss.host || "";
341
336
  return new Promise((resolve, reject) => {
342
337
  uni.uploadFile({
343
338
  url: target2,
@@ -349,7 +344,7 @@ async function uploadOss(oss, source) {
349
344
  },
350
345
  success: (res) => {
351
346
  if (res.statusCode === 200 || res.statusCode === 204) {
352
- resolve(String(oss.url || ""));
347
+ resolve(oss.url || "");
353
348
  } else {
354
349
  reject(new Error(`\u4E0A\u4F20\u963F\u91CC\u4E91\u5931\u8D25 (${res.statusCode}): ${res.data || ""}`));
355
350
  }
@@ -372,9 +367,9 @@ function buildFormData(cred) {
372
367
  return {
373
368
  key: cred.key,
374
369
  policy: cred.policy,
375
- OSSAccessKeyId: cred.OSSAccessKeyId || cred.oSSAccessKeyId || "",
376
- Signature: cred.Signature || cred.signature || "",
377
- success_action_status: cred.success_action_status || cred.successActionStatus || "200"
370
+ OSSAccessKeyId: cred.OSSAccessKeyId,
371
+ Signature: cred.Signature,
372
+ success_action_status: cred.success_action_status || "200"
378
373
  };
379
374
  }
380
375
  return {
@@ -382,14 +377,6 @@ function buildFormData(cred) {
382
377
  token: cred.token
383
378
  };
384
379
  }
385
- function decodeUtf8(value) {
386
- if (!value) return value;
387
- try {
388
- return decodeURIComponent(escape(value));
389
- } catch {
390
- return value;
391
- }
392
- }
393
380
  function buildHeader(cred, customHeader) {
394
381
  if (cred.type !== "local" && !customHeader) {
395
382
  return void 0;
@@ -426,13 +413,13 @@ function doUpload(cred, filePath, customHeader) {
426
413
  return;
427
414
  }
428
415
  try {
429
- const body = JSON.parse(decodeUtf8(res.data));
430
- body.code === 1 ? resolve() : reject(new Error(body.msg || "\u4E0A\u4F20\u5931\u8D25"));
416
+ const body = typeof res.data === "string" ? JSON.parse(res.data) : res.data;
417
+ body?.code === 1 ? resolve() : reject(new Error(body?.msg || "\u4E0A\u4F20\u5931\u8D25"));
431
418
  } catch {
432
419
  reject(new Error("\u54CD\u5E94\u89E3\u6790\u5931\u8D25"));
433
420
  }
434
421
  },
435
- fail: (error) => reject(new Error(error?.errMsg || "\u4E0A\u4F20\u5931\u8D25"))
422
+ fail: (error) => reject(new Error(error.errMsg || "\u4E0A\u4F20\u5931\u8D25"))
436
423
  });
437
424
  });
438
425
  }
@@ -449,6 +436,15 @@ async function uploadFile(params) {
449
436
  }
450
437
 
451
438
  // src/index.ts
439
+ var HttpError = class extends Error {
440
+ constructor(message, options) {
441
+ super(message);
442
+ this.name = "HttpError";
443
+ this.response = options?.response;
444
+ this.status = options?.status;
445
+ this.config = options?.config;
446
+ }
447
+ };
452
448
  var InterceptorManager = class {
453
449
  constructor() {
454
450
  this.handlers = [];
@@ -537,9 +533,10 @@ var UniHttpClient = class {
537
533
  return new Promise((resolve, reject) => {
538
534
  const isGet = (cfg.method || "GET").toUpperCase() === "GET";
539
535
  const requestData = isGet ? cfg.params ?? cfg.data : cfg.data ?? cfg.params;
536
+ const method = cfg.method?.toUpperCase() || "GET";
540
537
  uni.request({
541
538
  url,
542
- method: cfg.method?.toUpperCase() || "GET",
539
+ method,
543
540
  data: requestData,
544
541
  header: cfg.headers,
545
542
  timeout: cfg.timeout,
@@ -555,16 +552,12 @@ var UniHttpClient = class {
555
552
  resolve(response);
556
553
  } else {
557
554
  const body = res.data;
558
- const error = new Error(String(body?.msg || `\u8BF7\u6C42\u5931\u8D25: ${res.statusCode}`));
559
- error.response = response;
560
- error.status = res.statusCode;
561
- reject(error);
555
+ const msg = typeof body?.msg === "string" ? body.msg : `\u8BF7\u6C42\u5931\u8D25: ${res.statusCode}`;
556
+ reject(new HttpError(msg, { response, status: res.statusCode, config: cfg }));
562
557
  }
563
558
  },
564
559
  fail: (errorResult) => {
565
- const error = new Error(errorResult.errMsg || "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");
566
- error.config = cfg;
567
- reject(error);
560
+ reject(new HttpError(errorResult.errMsg || "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25", { config: cfg }));
568
561
  }
569
562
  });
570
563
  });
@@ -577,9 +570,7 @@ function handleUnauthorized(message, callback) {
577
570
  const now = Date.now();
578
571
  if (now - lastToastTime > 3e3) {
579
572
  lastToastTime = now;
580
- if (typeof uni !== "undefined" && uni.showToast) {
581
- uni.showToast({ title: message, icon: "none" });
582
- }
573
+ uni.showToast({ title: message, icon: "none" });
583
574
  }
584
575
  if (callback) {
585
576
  callback(message);
@@ -629,7 +620,7 @@ function getClient() {
629
620
  config.headers["X-Client-Nonce"] = nonce;
630
621
  config.headers["X-Client-Sign"] = sign;
631
622
  config.headers["X-Client-Context"] = cipher;
632
- if (devInfo.appid) {
623
+ if ("appid" in devInfo && devInfo.appid) {
633
624
  config.headers["x-appid"] = String(devInfo.appid);
634
625
  }
635
626
  return config;
@@ -646,8 +637,10 @@ function getClient() {
646
637
  return response;
647
638
  },
648
639
  (error) => {
649
- const status = error.response?.status;
650
- const message = error.response?.data?.msg || error.message || "\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38";
640
+ const httpErr = error instanceof HttpError ? error : void 0;
641
+ const status = httpErr?.status ?? httpErr?.response?.status;
642
+ const body = httpErr?.response?.data;
643
+ const message = body?.msg || (error instanceof Error ? error.message : "\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38");
651
644
  if (status === 401 || status === 403) {
652
645
  handleUnauthorized(message, currentOptions.onUnauthorized);
653
646
  }
@@ -685,7 +678,7 @@ function getHttpOptions() {
685
678
  var client = new Proxy({}, {
686
679
  get(_, prop) {
687
680
  const inst = getClient();
688
- const val = inst[prop];
681
+ const val = Reflect.get(inst, prop);
689
682
  return typeof val === "function" ? val.bind(inst) : val;
690
683
  }
691
684
  });
@@ -693,6 +686,7 @@ var http = client;
693
686
  var index_default = request;
694
687
  // Annotate the CommonJS export names for ESM import in node:
695
688
  0 && (module.exports = {
689
+ HttpError,
696
690
  InterceptorManager,
697
691
  UniHttpClient,
698
692
  calculateSign,
package/dist/index.mjs CHANGED
@@ -1,64 +1,57 @@
1
1
  // src/device/index.ts
2
2
  var deviceCache = null;
3
3
  var currentNetworkType = "";
4
- try {
5
- if (typeof uni !== "undefined" && uni.getNetworkType) {
6
- uni.getNetworkType({
7
- success(res) {
8
- currentNetworkType = res.networkType || "";
9
- if (deviceCache) {
10
- deviceCache.networkType = currentNetworkType;
11
- }
12
- }
13
- });
14
- if (uni.onNetworkStatusChange) {
15
- uni.onNetworkStatusChange((res) => {
16
- currentNetworkType = res.networkType || "";
17
- if (deviceCache) {
18
- deviceCache.networkType = currentNetworkType;
19
- }
20
- });
4
+ uni.getNetworkType({
5
+ success(res) {
6
+ currentNetworkType = res.networkType || "";
7
+ if (deviceCache) {
8
+ deviceCache.networkType = currentNetworkType;
21
9
  }
22
10
  }
23
- } catch {
24
- }
11
+ });
12
+ uni.onNetworkStatusChange((res) => {
13
+ currentNetworkType = res.networkType || "";
14
+ if (deviceCache) {
15
+ deviceCache.networkType = currentNetworkType;
16
+ }
17
+ });
25
18
  function getDevice() {
26
19
  if (deviceCache) return deviceCache;
27
- const deviceRaw = typeof uni !== "undefined" ? uni.getDeviceInfo?.() : void 0;
28
- const windowRaw = typeof uni !== "undefined" ? uni.getWindowInfo?.() : void 0;
29
- const appRaw = typeof uni !== "undefined" ? uni.getAppBaseInfo?.() : void 0;
30
- const accountRaw = typeof uni !== "undefined" ? uni.getAccountInfoSync?.() : void 0;
31
- const system = deviceRaw?.system || "";
20
+ const deviceRaw = uni.getDeviceInfo();
21
+ const windowRaw = uni.getWindowInfo();
22
+ const appRaw = uni.getAppBaseInfo();
23
+ const accountRaw = uni.getAccountInfoSync();
24
+ const system = deviceRaw.system || "";
32
25
  deviceCache = {
33
- appid: accountRaw?.miniProgram?.appId || "",
34
- appName: appRaw?.appName || "",
35
- version: appRaw?.appVersion || "",
36
- versionCode: appRaw?.appVersionCode || "",
37
- channel: appRaw?.appChannel || "",
38
- deviceId: deviceRaw?.deviceId || "",
39
- deviceType: deviceRaw?.deviceType || "",
40
- deviceOrientation: deviceRaw?.deviceOrientation || windowRaw?.deviceOrientation || "portrait",
41
- brand: deviceRaw?.brand || "",
42
- model: deviceRaw?.model || "",
26
+ appid: accountRaw.miniProgram?.appId || "",
27
+ appName: appRaw.appName || "",
28
+ version: appRaw.appVersion || "",
29
+ versionCode: appRaw.appVersionCode || "",
30
+ channel: appRaw.appChannel || "",
31
+ deviceId: deviceRaw.deviceId || "",
32
+ deviceType: deviceRaw.deviceType || "",
33
+ deviceOrientation: deviceRaw.deviceOrientation || windowRaw.deviceOrientation || "portrait",
34
+ brand: deviceRaw.brand || "",
35
+ model: deviceRaw.model || "",
43
36
  system,
44
37
  os: system.split(" ")[0] || "",
45
- pixelRatio: windowRaw?.pixelRatio || 0,
46
- screenWidth: windowRaw?.screenWidth || 0,
47
- screenHeight: windowRaw?.screenHeight || 0,
48
- windowWidth: windowRaw?.windowWidth || 0,
49
- windowHeight: windowRaw?.windowHeight || 0,
50
- statusBarHeight: windowRaw?.statusBarHeight || 0,
51
- sdkVersion: appRaw?.SDKVersion || "",
52
- hostName: appRaw?.hostName || "",
53
- hostVersion: appRaw?.hostVersion || "",
54
- hostLanguage: appRaw?.hostLanguage || "",
55
- hostTheme: appRaw?.hostTheme || "",
56
- platform: deviceRaw?.platform || "",
57
- language: appRaw?.appLanguage || appRaw?.language || "",
38
+ pixelRatio: windowRaw.pixelRatio || 0,
39
+ screenWidth: windowRaw.screenWidth || 0,
40
+ screenHeight: windowRaw.screenHeight || 0,
41
+ windowWidth: windowRaw.windowWidth || 0,
42
+ windowHeight: windowRaw.windowHeight || 0,
43
+ statusBarHeight: windowRaw.statusBarHeight || 0,
44
+ sdkVersion: appRaw.SDKVersion || "",
45
+ hostName: appRaw.hostName || "",
46
+ hostVersion: appRaw.hostVersion || "",
47
+ hostLanguage: appRaw.hostLanguage || "",
48
+ hostTheme: appRaw.hostTheme || "",
49
+ platform: deviceRaw.platform || "",
50
+ language: appRaw.appLanguage || appRaw.language || "",
58
51
  networkType: currentNetworkType,
59
- benchmarkLevel: deviceRaw?.benchmarkLevel || 0,
60
- theme: appRaw?.theme || "light",
61
- fontSizeSetting: appRaw?.fontSizeSetting || 16
52
+ benchmarkLevel: deviceRaw.benchmarkLevel || 0,
53
+ theme: appRaw.theme || "light",
54
+ fontSizeSetting: appRaw.fontSizeSetting || 16
62
55
  };
63
56
  return deviceCache;
64
57
  }
@@ -248,10 +241,11 @@ function sortString(data) {
248
241
  if (Array.isArray(data)) {
249
242
  return "[" + data.map((item) => sortString(item)).join(",") + "]";
250
243
  }
251
- const keys = Object.keys(data).sort();
244
+ const obj = data;
245
+ const keys = Object.keys(obj).sort();
252
246
  const parts = [];
253
247
  for (const key of keys) {
254
- const val = data[key];
248
+ const val = obj[key];
255
249
  if (val !== null && val !== void 0) {
256
250
  parts.push(`${key}=${sortString(val)}`);
257
251
  }
@@ -270,17 +264,17 @@ function calculateSign(options) {
270
264
 
271
265
  // src/oss.ts
272
266
  async function uploadOss(oss, source) {
273
- const filePath = typeof source === "string" ? source : source?.path || source?.tempFilePath || "";
274
- const name = oss.filename || filePath?.split("/").pop() || "file";
267
+ const filePath = typeof source === "string" ? source : source.path || source.tempFilePath || "";
268
+ const name = oss.filename || filePath.split("/").pop() || "file";
275
269
  const formData = {
276
- key: String(oss.key || ""),
270
+ key: oss.key || "",
277
271
  success_action_status: "200"
278
272
  };
279
- if (oss.policy) formData.policy = String(oss.policy);
280
- if (oss.OSSAccessKeyId) formData.OSSAccessKeyId = String(oss.OSSAccessKeyId);
281
- if (oss.signature) formData.signature = String(oss.signature);
273
+ if (oss.policy) formData.policy = oss.policy;
274
+ if (oss.OSSAccessKeyId) formData.OSSAccessKeyId = oss.OSSAccessKeyId;
275
+ if (oss.signature) formData.signature = oss.signature;
282
276
  if (oss["x-oss-security-token"]) formData["x-oss-security-token"] = String(oss["x-oss-security-token"]);
283
- const target2 = String(oss.host || "");
277
+ const target2 = oss.host || "";
284
278
  return new Promise((resolve, reject) => {
285
279
  uni.uploadFile({
286
280
  url: target2,
@@ -292,7 +286,7 @@ async function uploadOss(oss, source) {
292
286
  },
293
287
  success: (res) => {
294
288
  if (res.statusCode === 200 || res.statusCode === 204) {
295
- resolve(String(oss.url || ""));
289
+ resolve(oss.url || "");
296
290
  } else {
297
291
  reject(new Error(`\u4E0A\u4F20\u963F\u91CC\u4E91\u5931\u8D25 (${res.statusCode}): ${res.data || ""}`));
298
292
  }
@@ -315,9 +309,9 @@ function buildFormData(cred) {
315
309
  return {
316
310
  key: cred.key,
317
311
  policy: cred.policy,
318
- OSSAccessKeyId: cred.OSSAccessKeyId || cred.oSSAccessKeyId || "",
319
- Signature: cred.Signature || cred.signature || "",
320
- success_action_status: cred.success_action_status || cred.successActionStatus || "200"
312
+ OSSAccessKeyId: cred.OSSAccessKeyId,
313
+ Signature: cred.Signature,
314
+ success_action_status: cred.success_action_status || "200"
321
315
  };
322
316
  }
323
317
  return {
@@ -325,14 +319,6 @@ function buildFormData(cred) {
325
319
  token: cred.token
326
320
  };
327
321
  }
328
- function decodeUtf8(value) {
329
- if (!value) return value;
330
- try {
331
- return decodeURIComponent(escape(value));
332
- } catch {
333
- return value;
334
- }
335
- }
336
322
  function buildHeader(cred, customHeader) {
337
323
  if (cred.type !== "local" && !customHeader) {
338
324
  return void 0;
@@ -369,13 +355,13 @@ function doUpload(cred, filePath, customHeader) {
369
355
  return;
370
356
  }
371
357
  try {
372
- const body = JSON.parse(decodeUtf8(res.data));
373
- body.code === 1 ? resolve() : reject(new Error(body.msg || "\u4E0A\u4F20\u5931\u8D25"));
358
+ const body = typeof res.data === "string" ? JSON.parse(res.data) : res.data;
359
+ body?.code === 1 ? resolve() : reject(new Error(body?.msg || "\u4E0A\u4F20\u5931\u8D25"));
374
360
  } catch {
375
361
  reject(new Error("\u54CD\u5E94\u89E3\u6790\u5931\u8D25"));
376
362
  }
377
363
  },
378
- fail: (error) => reject(new Error(error?.errMsg || "\u4E0A\u4F20\u5931\u8D25"))
364
+ fail: (error) => reject(new Error(error.errMsg || "\u4E0A\u4F20\u5931\u8D25"))
379
365
  });
380
366
  });
381
367
  }
@@ -392,6 +378,15 @@ async function uploadFile(params) {
392
378
  }
393
379
 
394
380
  // src/index.ts
381
+ var HttpError = class extends Error {
382
+ constructor(message, options) {
383
+ super(message);
384
+ this.name = "HttpError";
385
+ this.response = options?.response;
386
+ this.status = options?.status;
387
+ this.config = options?.config;
388
+ }
389
+ };
395
390
  var InterceptorManager = class {
396
391
  constructor() {
397
392
  this.handlers = [];
@@ -480,9 +475,10 @@ var UniHttpClient = class {
480
475
  return new Promise((resolve, reject) => {
481
476
  const isGet = (cfg.method || "GET").toUpperCase() === "GET";
482
477
  const requestData = isGet ? cfg.params ?? cfg.data : cfg.data ?? cfg.params;
478
+ const method = cfg.method?.toUpperCase() || "GET";
483
479
  uni.request({
484
480
  url,
485
- method: cfg.method?.toUpperCase() || "GET",
481
+ method,
486
482
  data: requestData,
487
483
  header: cfg.headers,
488
484
  timeout: cfg.timeout,
@@ -498,16 +494,12 @@ var UniHttpClient = class {
498
494
  resolve(response);
499
495
  } else {
500
496
  const body = res.data;
501
- const error = new Error(String(body?.msg || `\u8BF7\u6C42\u5931\u8D25: ${res.statusCode}`));
502
- error.response = response;
503
- error.status = res.statusCode;
504
- reject(error);
497
+ const msg = typeof body?.msg === "string" ? body.msg : `\u8BF7\u6C42\u5931\u8D25: ${res.statusCode}`;
498
+ reject(new HttpError(msg, { response, status: res.statusCode, config: cfg }));
505
499
  }
506
500
  },
507
501
  fail: (errorResult) => {
508
- const error = new Error(errorResult.errMsg || "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");
509
- error.config = cfg;
510
- reject(error);
502
+ reject(new HttpError(errorResult.errMsg || "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25", { config: cfg }));
511
503
  }
512
504
  });
513
505
  });
@@ -520,9 +512,7 @@ function handleUnauthorized(message, callback) {
520
512
  const now = Date.now();
521
513
  if (now - lastToastTime > 3e3) {
522
514
  lastToastTime = now;
523
- if (typeof uni !== "undefined" && uni.showToast) {
524
- uni.showToast({ title: message, icon: "none" });
525
- }
515
+ uni.showToast({ title: message, icon: "none" });
526
516
  }
527
517
  if (callback) {
528
518
  callback(message);
@@ -572,7 +562,7 @@ function getClient() {
572
562
  config.headers["X-Client-Nonce"] = nonce;
573
563
  config.headers["X-Client-Sign"] = sign;
574
564
  config.headers["X-Client-Context"] = cipher;
575
- if (devInfo.appid) {
565
+ if ("appid" in devInfo && devInfo.appid) {
576
566
  config.headers["x-appid"] = String(devInfo.appid);
577
567
  }
578
568
  return config;
@@ -589,8 +579,10 @@ function getClient() {
589
579
  return response;
590
580
  },
591
581
  (error) => {
592
- const status = error.response?.status;
593
- const message = error.response?.data?.msg || error.message || "\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38";
582
+ const httpErr = error instanceof HttpError ? error : void 0;
583
+ const status = httpErr?.status ?? httpErr?.response?.status;
584
+ const body = httpErr?.response?.data;
585
+ const message = body?.msg || (error instanceof Error ? error.message : "\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38");
594
586
  if (status === 401 || status === 403) {
595
587
  handleUnauthorized(message, currentOptions.onUnauthorized);
596
588
  }
@@ -628,13 +620,14 @@ function getHttpOptions() {
628
620
  var client = new Proxy({}, {
629
621
  get(_, prop) {
630
622
  const inst = getClient();
631
- const val = inst[prop];
623
+ const val = Reflect.get(inst, prop);
632
624
  return typeof val === "function" ? val.bind(inst) : val;
633
625
  }
634
626
  });
635
627
  var http = client;
636
628
  var index_default = request;
637
629
  export {
630
+ HttpError,
638
631
  InterceptorManager,
639
632
  UniHttpClient,
640
633
  calculateSign,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni-mp/request",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Universal Uni-App HTTP and upload client with RSA encryption & sign verification",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",